Module: wine Branch: master Commit: 4f575813100de1ab397f7ed3079ae2a7f0aa29d6 URL: http://source.winehq.org/git/wine.git/?a=commit;h=4f575813100de1ab397f7ed307...
Author: Matteo Bruni mbruni@codeweavers.com Date: Thu Jul 2 17:41:34 2015 +0200
wined3d: Improve NP2 fixups in GLSL PS texture sampling code.
---
dlls/wined3d/glsl_shader.c | 57 ++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 22 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 06afa65..15cf873 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -2710,13 +2710,8 @@ static void PRINTF_ATTR(8, 9) shader_glsl_gen_sample_code(const struct wined3d_s const struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data; fixup = priv->cur_ps_args->color_fixup[sampler];
- if(priv->cur_ps_args->np2_fixup & (1 << sampler)) { - if(bias) { - FIXME("Biased sampling from NP2 textures is unsupported\n"); - } else { - np2_fixup = TRUE; - } - } + if (priv->cur_ps_args->np2_fixup & (1 << sampler)) + np2_fixup = TRUE; } else { @@ -2739,25 +2734,42 @@ static void PRINTF_ATTR(8, 9) shader_glsl_gen_sample_code(const struct wined3d_s break; }
- if(bias) { - shader_addline(ins->ctx->buffer, ", %s)%s);\n", bias, dst_swizzle); - } else { - if (np2_fixup) { - const struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data; - const unsigned char idx = priv->cur_np2fixup_info->idx[sampler]; - - shader_addline(ins->ctx->buffer, " * ps_samplerNP2Fixup[%u].%s)%s);\n", idx >> 1, - (idx % 2) ? "zw" : "xy", dst_swizzle); - } else if(dx && dy) { - shader_addline(ins->ctx->buffer, ", %s, %s)%s);\n", dx, dy, dst_swizzle); - } else { - shader_addline(ins->ctx->buffer, ")%s);\n", dst_swizzle); + if (np2_fixup) + { + const struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data; + const unsigned char idx = priv->cur_np2fixup_info->idx[sampler]; + + switch (shader_glsl_get_write_mask_size(sample_function->coord_mask)) + { + case 1: + shader_addline(ins->ctx->buffer, " * ps_samplerNP2Fixup[%u].%s", + idx >> 1, (idx % 2) ? "z" : "x"); + break; + case 2: + shader_addline(ins->ctx->buffer, " * ps_samplerNP2Fixup[%u].%s", + idx >> 1, (idx % 2) ? "zw" : "xy"); + break; + case 3: + shader_addline(ins->ctx->buffer, " * vec3(ps_samplerNP2Fixup[%u].%s, 1.0)", + idx >> 1, (idx % 2) ? "zw" : "xy"); + break; + case 4: + shader_addline(ins->ctx->buffer, " * vec4(ps_samplerNP2Fixup[%u].%s, 1.0, 1.0)", + idx >> 1, (idx % 2) ? "zw" : "xy"); + break; } } + if (dx && dy) + shader_addline(ins->ctx->buffer, ", %s, %s)", dx, dy); + else if (bias) + shader_addline(ins->ctx->buffer, ", %s)", bias); + else + shader_addline(ins->ctx->buffer, ")");
- if(!is_identity_fixup(fixup)) { + shader_addline(ins->ctx->buffer, "%s);\n", dst_swizzle); + + if (!is_identity_fixup(fixup)) shader_glsl_color_correction(ins, fixup); - } }
/***************************************************************************** @@ -3989,6 +4001,7 @@ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
shader_glsl_get_sample_function(ins->ctx, resource_idx, sample_flags, &sample_function); mask |= sample_function.coord_mask; + sample_function.coord_mask = mask;
if (shader_version < WINED3D_SHADER_VERSION(2,0)) swizzle = WINED3DSP_NOSWIZZLE; else swizzle = ins->src[1].swizzle;