wined3d: Implement SM4 discard in the GLSL shader backend.

This commit is contained in:
Henri Verbeet 2015-06-15 14:07:33 +02:00 committed by Alexandre Julliard
parent b4b2a29dec
commit c9227bccc5
1 changed files with 22 additions and 15 deletions

View File

@ -4703,22 +4703,29 @@ static void shader_glsl_texreg2rgb(const struct wined3d_shader_instruction *ins)
/** Process the WINED3DSIO_TEXKILL instruction in GLSL.
* If any of the first 3 components are < 0, discard this pixel */
static void shader_glsl_texkill(const struct wined3d_shader_instruction *ins)
{
if (ins->ctx->reg_maps->shader_version.major >= 4)
{
struct glsl_src_param src_param;
shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_0, &src_param);
shader_addline(ins->ctx->buffer, "if (bool(floatBitsToUint(%s))) discard;\n", src_param.param_str);
}
else
{
struct glsl_dst_param dst_param;
/* The argument is a destination parameter, and no writemasks are allowed */
shader_glsl_add_dst_param(ins, &ins->dst[0], &dst_param);
/* 2.0 shaders compare all 4 components in texkill. */
if (ins->ctx->reg_maps->shader_version.major >= 2)
{
if (ins->ctx->reg_maps->shader_version.major >= 4)
FIXME("SM4 discard not implemented.\n");
/* 2.0 shaders compare all 4 components in texkill */
shader_addline(ins->ctx->buffer, "if (any(lessThan(%s.xyzw, vec4(0.0)))) discard;\n", dst_param.reg_name);
} else {
/* 1.X shaders only compare the first 3 components, probably due to the nature of the texkill
* instruction as a tex* instruction, and phase, which kills all a / w components. Even if all
* 4 components are defined, only the first 3 are used
*/
/* 1.x shaders only compare the first 3 components, probably due to
* the nature of the texkill instruction as a tex* instruction, and
* phase, which kills all .w components. Even if all 4 components are
* defined, only the first 3 are used. */
else
shader_addline(ins->ctx->buffer, "if (any(lessThan(%s.xyz, vec3(0.0)))) discard;\n", dst_param.reg_name);
}
}