[PATCH 1/4] wined3d: Fix SM4 discard_z instruction.

Józef Kucia jkucia at codeweavers.com
Wed Nov 22 06:11:11 CST 2017


Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---

Fixes https://bugs.winehq.org/show_bug.cgi?id=43131

---
 dlls/wined3d/glsl_shader.c | 3 ++-
 dlls/wined3d/shader.c      | 3 ++-
 dlls/wined3d/shader_sm4.c  | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 0ff9ee44bb26..31810d6ddf29 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -6606,10 +6606,11 @@ static void shader_glsl_texkill(const struct wined3d_shader_instruction *ins)
 {
     if (ins->ctx->reg_maps->shader_version.major >= 4)
     {
+        const char *condition = ins->flags == WINED3D_SHADER_CONDITIONAL_OP_NZ ? "bool" : "!bool";
         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(%s)) discard;\n", src_param.param_str);
+        shader_addline(ins->ctx->buffer, "if (%s(%s)) discard;\n", condition, src_param.param_str);
     }
     else
     {
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 3707d1587f9d..c4eed76d78f0 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -2958,7 +2958,8 @@ static void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe
             if (ins.handler_idx == WINED3DSIH_BREAKP
                     || ins.handler_idx == WINED3DSIH_CONTINUEP
                     || ins.handler_idx == WINED3DSIH_IF
-                    || ins.handler_idx == WINED3DSIH_RETP)
+                    || ins.handler_idx == WINED3DSIH_RETP
+                    || ins.handler_idx == WINED3DSIH_TEXKILL)
             {
                 switch (ins.flags)
                 {
diff --git a/dlls/wined3d/shader_sm4.c b/dlls/wined3d/shader_sm4.c
index a04debe264d9..2665a67b80a6 100644
--- a/dlls/wined3d/shader_sm4.c
+++ b/dlls/wined3d/shader_sm4.c
@@ -894,7 +894,8 @@ static const struct wined3d_sm4_opcode_info opcode_table[] =
     {WINED3D_SM4_OP_DEFAULT,                          WINED3DSIH_DEFAULT,                          "",     ""},
     {WINED3D_SM4_OP_DERIV_RTX,                        WINED3DSIH_DSX,                              "f",    "f"},
     {WINED3D_SM4_OP_DERIV_RTY,                        WINED3DSIH_DSY,                              "f",    "f"},
-    {WINED3D_SM4_OP_DISCARD,                          WINED3DSIH_TEXKILL,                          "",     "u"},
+    {WINED3D_SM4_OP_DISCARD,                          WINED3DSIH_TEXKILL,                          "",     "u",
+            shader_sm4_read_conditional_op},
     {WINED3D_SM4_OP_DIV,                              WINED3DSIH_DIV,                              "f",    "ff"},
     {WINED3D_SM4_OP_DP2,                              WINED3DSIH_DP2,                              "f",    "ff"},
     {WINED3D_SM4_OP_DP3,                              WINED3DSIH_DP3,                              "f",    "ff"},
-- 
2.13.6




More information about the wine-devel mailing list