wined3d: Improve NP2 fixups in GLSL PS texture sampling code.

This commit is contained in:
Matteo Bruni 2015-07-02 17:41:34 +02:00 committed by Alexandre Julliard
parent a8fb1eee49
commit 4f57581310

View File

@ -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; const struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data;
fixup = priv->cur_ps_args->color_fixup[sampler]; fixup = priv->cur_ps_args->color_fixup[sampler];
if(priv->cur_ps_args->np2_fixup & (1 << sampler)) { if (priv->cur_ps_args->np2_fixup & (1 << sampler))
if(bias) { np2_fixup = TRUE;
FIXME("Biased sampling from NP2 textures is unsupported\n");
} else {
np2_fixup = TRUE;
}
}
} }
else else
{ {
@ -2739,25 +2734,42 @@ static void PRINTF_ATTR(8, 9) shader_glsl_gen_sample_code(const struct wined3d_s
break; break;
} }
if(bias) { if (np2_fixup)
shader_addline(ins->ctx->buffer, ", %s)%s);\n", bias, dst_swizzle); {
} else { const struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data;
if (np2_fixup) { const unsigned char idx = priv->cur_np2fixup_info->idx[sampler];
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, switch (shader_glsl_get_write_mask_size(sample_function->coord_mask))
(idx % 2) ? "zw" : "xy", dst_swizzle); {
} else if(dx && dy) { case 1:
shader_addline(ins->ctx->buffer, ", %s, %s)%s);\n", dx, dy, dst_swizzle); shader_addline(ins->ctx->buffer, " * ps_samplerNP2Fixup[%u].%s",
} else { idx >> 1, (idx % 2) ? "z" : "x");
shader_addline(ins->ctx->buffer, ")%s);\n", dst_swizzle); 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); 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); shader_glsl_get_sample_function(ins->ctx, resource_idx, sample_flags, &sample_function);
mask |= sample_function.coord_mask; mask |= sample_function.coord_mask;
sample_function.coord_mask = mask;
if (shader_version < WINED3D_SHADER_VERSION(2,0)) swizzle = WINED3DSP_NOSWIZZLE; if (shader_version < WINED3D_SHADER_VERSION(2,0)) swizzle = WINED3DSP_NOSWIZZLE;
else swizzle = ins->src[1].swizzle; else swizzle = ins->src[1].swizzle;