[PATCH 4/8] wined3d: Implement SM4 switch instruction.
Józef Kucia
jkucia at codeweavers.com
Fri Jun 3 04:33:03 CDT 2016
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
It seems that the argument to the switch instruction
is always integer, e.g.
float4 main(float4 position : SV_Position) : SV_Target
{
switch (position.x)
{
case 1.4:
return float4(1.0f, 0.0f, 0.0f, 1.0f);
case 0.5:
return float4(0.0f, 0.0f, 1.0f, 1.0f);
default:
return float4(0.0f, 1.0f, 0.0f, 1.0f);
}
}
compiles to
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_input_ps_siv linear noperspective v0.x, position
dcl_output o0.xyzw
dcl_temps 1
ftou r0.x, v0.x
switch r0.x
case l(1)
mov o0.xyzw, l(1.000000,0,0,1.000000)
ret
case l(0)
mov o0.xyzw, l(0,0,1.000000,1.000000)
ret
default
mov o0.xyzw, l(0,1.000000,0,1.000000)
ret
endswitch
ret
---
dlls/wined3d/arb_program_shader.c | 1 +
dlls/wined3d/glsl_shader.c | 9 +++++++++
dlls/wined3d/shader.c | 1 +
dlls/wined3d/shader_sm4.c | 2 ++
dlls/wined3d/wined3d_private.h | 1 +
5 files changed, 14 insertions(+)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 7b395e9..53b8f2c 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -5345,6 +5345,7 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL
/* WINED3DSIH_SQRT */ NULL,
/* WINED3DSIH_STORE_UAV_TYPED */ NULL,
/* WINED3DSIH_SUB */ shader_hw_map2gl,
+ /* WINED3DSIH_SWITCH */ NULL,
/* WINED3DSIH_TEX */ pshader_hw_tex,
/* WINED3DSIH_TEXBEM */ pshader_hw_texbem,
/* WINED3DSIH_TEXBEML */ pshader_hw_texbem,
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 517435d..69ff2bc 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -4228,6 +4228,14 @@ static void shader_glsl_rep(const struct wined3d_shader_instruction *ins)
++loop_state->current_depth;
}
+static void shader_glsl_switch(const struct wined3d_shader_instruction *ins)
+{
+ struct glsl_src_param src0_param;
+
+ shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_0, &src0_param);
+ shader_addline(ins->ctx->buffer, "switch (%s)\n{\n", src0_param.param_str);
+}
+
static void shader_glsl_if(const struct wined3d_shader_instruction *ins)
{
const char *condition = (ins->flags == WINED3D_SHADER_CONDITIONAL_OP_NZ) ? "bool" : "!bool";
@@ -8658,6 +8666,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB
/* WINED3DSIH_SQRT */ shader_glsl_map2gl,
/* WINED3DSIH_STORE_UAV_TYPED */ NULL,
/* WINED3DSIH_SUB */ shader_glsl_binop,
+ /* WINED3DSIH_SWITCH */ shader_glsl_switch,
/* WINED3DSIH_TEX */ shader_glsl_tex,
/* WINED3DSIH_TEXBEM */ shader_glsl_texbem,
/* WINED3DSIH_TEXBEML */ shader_glsl_texbem,
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 8c41afb..be12432 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -177,6 +177,7 @@ static const char * const shader_opcode_names[] =
/* WINED3DSIH_SQRT */ "sqrt",
/* WINED3DSIH_STORE_UAV_TYPED */ "store_uav_typed",
/* WINED3DSIH_SUB */ "sub",
+ /* WINED3DSIH_SWITCH */ "switch",
/* WINED3DSIH_TEX */ "texld",
/* WINED3DSIH_TEXBEM */ "texbem",
/* WINED3DSIH_TEXBEML */ "texbeml",
diff --git a/dlls/wined3d/shader_sm4.c b/dlls/wined3d/shader_sm4.c
index 62b5d65..ab39bf8 100644
--- a/dlls/wined3d/shader_sm4.c
+++ b/dlls/wined3d/shader_sm4.c
@@ -172,6 +172,7 @@ enum wined3d_sm4_opcode
WINED3D_SM4_OP_SAMPLE_GRAD = 0x49,
WINED3D_SM4_OP_SAMPLE_B = 0x4a,
WINED3D_SM4_OP_SQRT = 0x4b,
+ WINED3D_SM4_OP_SWITCH = 0x4c,
WINED3D_SM4_OP_SINCOS = 0x4d,
WINED3D_SM4_OP_UDIV = 0x4e,
WINED3D_SM4_OP_ULT = 0x4f,
@@ -685,6 +686,7 @@ static const struct wined3d_sm4_opcode_info opcode_table[] =
{WINED3D_SM4_OP_SAMPLE_GRAD, WINED3DSIH_SAMPLE_GRAD, "u", "fRSff"},
{WINED3D_SM4_OP_SAMPLE_B, WINED3DSIH_SAMPLE_B, "u", "fRSf"},
{WINED3D_SM4_OP_SQRT, WINED3DSIH_SQRT, "f", "f"},
+ {WINED3D_SM4_OP_SWITCH, WINED3DSIH_SWITCH, "", "u"},
{WINED3D_SM4_OP_SINCOS, WINED3DSIH_SINCOS, "ff", "f"},
{WINED3D_SM4_OP_UDIV, WINED3DSIH_UDIV, "uu", "uu"},
{WINED3D_SM4_OP_ULT, WINED3DSIH_ULT, "u", "uu"},
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 473a4b8..255dbd5 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -684,6 +684,7 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER
WINED3DSIH_SQRT,
WINED3DSIH_STORE_UAV_TYPED,
WINED3DSIH_SUB,
+ WINED3DSIH_SWITCH,
WINED3DSIH_TEX,
WINED3DSIH_TEXBEM,
WINED3DSIH_TEXBEML,
--
2.7.3
More information about the wine-patches
mailing list