[PATCH 02/13] wined3d: Implement SM5 f16tof32 instruction.

Józef Kucia jkucia at codeweavers.com
Sat Jan 28 10:14:01 CST 2017


Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 dlls/wined3d/arb_program_shader.c |  1 +
 dlls/wined3d/glsl_shader.c        | 23 +++++++++++++++++++++++
 dlls/wined3d/shader.c             |  1 +
 dlls/wined3d/shader_sm4.c         |  2 ++
 dlls/wined3d/wined3d_private.h    |  1 +
 5 files changed, 28 insertions(+)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index f2a5b38..97c545f 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -5105,6 +5105,7 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL
     /* WINED3DSIH_EQ                               */ NULL,
     /* WINED3DSIH_EXP                              */ shader_hw_scalar_op,
     /* WINED3DSIH_EXPP                             */ shader_hw_scalar_op,
+    /* WINED3DSIH_F16TOF32                         */ NULL,
     /* WINED3DSIH_FCALL                            */ NULL,
     /* WINED3DSIH_FRC                              */ shader_hw_map2gl,
     /* WINED3DSIH_FTOI                             */ NULL,
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index c955ec4..dd1a610 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -3764,6 +3764,28 @@ static void shader_glsl_map2gl(const struct wined3d_shader_instruction *ins)
     shader_addline(buffer, "));\n");
 }
 
+static void shader_glsl_f16tof32(const struct wined3d_shader_instruction *ins)
+{
+    struct wined3d_shader_dst_param dst;
+    struct glsl_src_param src;
+    DWORD write_mask;
+    unsigned int i;
+
+    dst = ins->dst[0];
+    for (i = 0; i < 4; ++i)
+    {
+        write_mask = WINED3DSP_WRITEMASK_0 << i;
+        dst.write_mask = ins->dst[0].write_mask & write_mask;
+
+        if (!(write_mask = shader_glsl_append_dst_ext(ins->ctx->buffer, ins,
+                &dst, dst.reg.data_type)))
+            continue;
+
+        shader_glsl_add_src_param(ins, &ins->src[0], write_mask, &src);
+        shader_addline(ins->ctx->buffer, "unpackHalf2x16(%s).x);\n", src.param_str);
+    }
+}
+
 static void shader_glsl_nop(const struct wined3d_shader_instruction *ins) {}
 
 static void shader_glsl_nrm(const struct wined3d_shader_instruction *ins)
@@ -8891,6 +8913,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB
     /* WINED3DSIH_EQ                               */ shader_glsl_relop,
     /* WINED3DSIH_EXP                              */ shader_glsl_scalar_op,
     /* WINED3DSIH_EXPP                             */ shader_glsl_expp,
+    /* WINED3DSIH_F16TOF32                         */ shader_glsl_f16tof32,
     /* WINED3DSIH_FCALL                            */ NULL,
     /* WINED3DSIH_FRC                              */ shader_glsl_map2gl,
     /* WINED3DSIH_FTOI                             */ shader_glsl_to_int,
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 4ca82c2..19fbbd1 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -130,6 +130,7 @@ static const char * const shader_opcode_names[] =
     /* WINED3DSIH_EQ                               */ "eq",
     /* WINED3DSIH_EXP                              */ "exp",
     /* WINED3DSIH_EXPP                             */ "expp",
+    /* WINED3DSIH_F16TOF32                         */ "f16tof32",
     /* WINED3DSIH_FCALL                            */ "fcall",
     /* WINED3DSIH_FRC                              */ "frc",
     /* WINED3DSIH_FTOI                             */ "ftoi",
diff --git a/dlls/wined3d/shader_sm4.c b/dlls/wined3d/shader_sm4.c
index 66c33b3..9dce166 100644
--- a/dlls/wined3d/shader_sm4.c
+++ b/dlls/wined3d/shader_sm4.c
@@ -231,6 +231,7 @@ enum wined3d_sm4_opcode
     WINED3D_SM5_OP_DERIV_RTY_FINE                   = 0x7d,
     WINED3D_SM5_OP_GATHER4_C                        = 0x7e,
     WINED3D_SM5_OP_RCP                              = 0x81,
+    WINED3D_SM5_OP_F16TOF32                         = 0x83,
     WINED3D_SM5_OP_UBFE                             = 0x8a,
     WINED3D_SM5_OP_BFI                              = 0x8c,
     WINED3D_SM5_OP_BFREV                            = 0x8d,
@@ -922,6 +923,7 @@ static const struct wined3d_sm4_opcode_info opcode_table[] =
     {WINED3D_SM5_OP_DERIV_RTY_FINE,                   WINED3DSIH_DSY_FINE,                         "f",    "f"},
     {WINED3D_SM5_OP_GATHER4_C,                        WINED3DSIH_GATHER4_C,                        "f",    "fRSf"},
     {WINED3D_SM5_OP_RCP,                              WINED3DSIH_RCP,                              "f",    "f"},
+    {WINED3D_SM5_OP_F16TOF32,                         WINED3DSIH_F16TOF32,                         "f",    "u"},
     {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 051836c..49d4d0a 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -660,6 +660,7 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER
     WINED3DSIH_EQ,
     WINED3DSIH_EXP,
     WINED3DSIH_EXPP,
+    WINED3DSIH_F16TOF32,
     WINED3DSIH_FCALL,
     WINED3DSIH_FRC,
     WINED3DSIH_FTOI,
-- 
2.10.2




More information about the wine-patches mailing list