=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: wined3d: Implement SM5 firstbit_* instructions.

Alexandre Julliard julliard at winehq.org
Tue Jan 31 15:42:52 CST 2017


Module: wine
Branch: master
Commit: ab6557fd9719b36092a39009eccbbd32bef72ce6
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ab6557fd9719b36092a39009eccbbd32bef72ce6

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Sat Jan 28 17:14:11 2017 +0100

wined3d: Implement SM5 firstbit_* instructions.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/arb_program_shader.c | 3 +++
 dlls/wined3d/glsl_shader.c        | 9 +++++++++
 dlls/wined3d/shader.c             | 3 +++
 dlls/wined3d/shader_sm4.c         | 6 ++++++
 dlls/wined3d/wined3d_private.h    | 3 +++
 5 files changed, 24 insertions(+)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 0ab724c..3dbf584 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -5109,6 +5109,9 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL
     /* WINED3DSIH_F16TOF32                         */ NULL,
     /* WINED3DSIH_F32TOF16                         */ NULL,
     /* WINED3DSIH_FCALL                            */ NULL,
+    /* WINED3DSIH_FIRSTBIT_HI                      */ NULL,
+    /* WINED3DSIH_FIRSTBIT_LO                      */ NULL,
+    /* WINED3DSIH_FIRSTBIT_SHI                     */ NULL,
     /* WINED3DSIH_FRC                              */ shader_hw_map2gl,
     /* WINED3DSIH_FTOI                             */ NULL,
     /* WINED3DSIH_FTOU                             */ NULL,
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index eaa903a..cdd440d 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -3731,6 +3731,9 @@ static void shader_glsl_map2gl(const struct wined3d_shader_instruction *ins)
         case WINED3DSIH_DSY: instruction = "ycorrection.y * dFdy"; break;
         case WINED3DSIH_DSY_COARSE: instruction = "ycorrection.y * dFdyCoarse"; break;
         case WINED3DSIH_DSY_FINE: instruction = "ycorrection.y * dFdyFine"; break;
+        case WINED3DSIH_FIRSTBIT_HI: instruction = "findMSB"; break;
+        case WINED3DSIH_FIRSTBIT_LO: instruction = "findLSB"; break;
+        case WINED3DSIH_FIRSTBIT_SHI: instruction = "findMSB"; break;
         case WINED3DSIH_FRC: instruction = "fract"; break;
         case WINED3DSIH_IMAX: instruction = "max"; break;
         case WINED3DSIH_IMIN: instruction = "min"; break;
@@ -3750,6 +3753,9 @@ static void shader_glsl_map2gl(const struct wined3d_shader_instruction *ins)
 
     write_mask = shader_glsl_append_dst(buffer, ins);
 
+    /* In D3D bits are numbered from the most significant bit. */
+    if (ins->handler_idx == WINED3DSIH_FIRSTBIT_HI || ins->handler_idx == WINED3DSIH_FIRSTBIT_SHI)
+        shader_addline(buffer, "31 - ");
     shader_addline(buffer, "%s(", instruction);
 
     if (ins->src_count)
@@ -8963,6 +8969,9 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB
     /* WINED3DSIH_F16TOF32                         */ shader_glsl_float16,
     /* WINED3DSIH_F32TOF16                         */ shader_glsl_float16,
     /* WINED3DSIH_FCALL                            */ NULL,
+    /* WINED3DSIH_FIRSTBIT_HI                      */ shader_glsl_map2gl,
+    /* WINED3DSIH_FIRSTBIT_LO                      */ shader_glsl_map2gl,
+    /* WINED3DSIH_FIRSTBIT_SHI                     */ shader_glsl_map2gl,
     /* WINED3DSIH_FRC                              */ shader_glsl_map2gl,
     /* WINED3DSIH_FTOI                             */ shader_glsl_to_int,
     /* WINED3DSIH_FTOU                             */ shader_glsl_to_uint,
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index a4e74fd..d3dbca3 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -134,6 +134,9 @@ static const char * const shader_opcode_names[] =
     /* WINED3DSIH_F16TOF32                         */ "f16tof32",
     /* WINED3DSIH_F32TOF16                         */ "f32tof16",
     /* WINED3DSIH_FCALL                            */ "fcall",
+    /* WINED3DSIH_FIRSTBIT_HI                      */ "firstbit_hi",
+    /* WINED3DSIH_FIRSTBIT_LO                      */ "firstbit_lo",
+    /* WINED3DSIH_FIRSTBIT_SHI                     */ "firstbit_shi",
     /* WINED3DSIH_FRC                              */ "frc",
     /* WINED3DSIH_FTOI                             */ "ftoi",
     /* WINED3DSIH_FTOU                             */ "ftou",
diff --git a/dlls/wined3d/shader_sm4.c b/dlls/wined3d/shader_sm4.c
index a7adb64..bcb55af 100644
--- a/dlls/wined3d/shader_sm4.c
+++ b/dlls/wined3d/shader_sm4.c
@@ -234,6 +234,9 @@ enum wined3d_sm4_opcode
     WINED3D_SM5_OP_F32TOF16                         = 0x82,
     WINED3D_SM5_OP_F16TOF32                         = 0x83,
     WINED3D_SM5_OP_COUNTBITS                        = 0x86,
+    WINED3D_SM5_OP_FIRSTBIT_HI                      = 0x87,
+    WINED3D_SM5_OP_FIRSTBIT_LO                      = 0x88,
+    WINED3D_SM5_OP_FIRSTBIT_SHI                     = 0x89,
     WINED3D_SM5_OP_UBFE                             = 0x8a,
     WINED3D_SM5_OP_BFI                              = 0x8c,
     WINED3D_SM5_OP_BFREV                            = 0x8d,
@@ -928,6 +931,9 @@ static const struct wined3d_sm4_opcode_info opcode_table[] =
     {WINED3D_SM5_OP_F32TOF16,                         WINED3DSIH_F32TOF16,                         "u",    "f"},
     {WINED3D_SM5_OP_F16TOF32,                         WINED3DSIH_F16TOF32,                         "f",    "u"},
     {WINED3D_SM5_OP_COUNTBITS,                        WINED3DSIH_COUNTBITS,                        "u",    "u"},
+    {WINED3D_SM5_OP_FIRSTBIT_HI,                      WINED3DSIH_FIRSTBIT_HI,                      "u",    "u"},
+    {WINED3D_SM5_OP_FIRSTBIT_LO,                      WINED3DSIH_FIRSTBIT_LO,                      "u",    "u"},
+    {WINED3D_SM5_OP_FIRSTBIT_SHI,                     WINED3DSIH_FIRSTBIT_SHI,                     "u",    "i"},
     {WINED3D_SM5_OP_UBFE,                             WINED3DSIH_UBFE,                             "u",    "iiu"},
     {WINED3D_SM5_OP_BFI,                              WINED3DSIH_BFI,                              "u",    "iiuu"},
     {WINED3D_SM5_OP_BFREV,                            WINED3DSIH_BFREV,                            "u",    "u"},
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index ff8337d..436cade 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -664,6 +664,9 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER
     WINED3DSIH_F16TOF32,
     WINED3DSIH_F32TOF16,
     WINED3DSIH_FCALL,
+    WINED3DSIH_FIRSTBIT_HI,
+    WINED3DSIH_FIRSTBIT_LO,
+    WINED3DSIH_FIRSTBIT_SHI,
     WINED3DSIH_FRC,
     WINED3DSIH_FTOI,
     WINED3DSIH_FTOU,




More information about the wine-cvs mailing list