diff --git a/libs/vkd3d-shader/glsl.c b/libs/vkd3d-shader/glsl.c index bd3622b1..196405c9 100644 --- a/libs/vkd3d-shader/glsl.c +++ b/libs/vkd3d-shader/glsl.c @@ -540,6 +540,13 @@ static void shader_glsl_if(struct vkd3d_glsl_generator *gen, const struct vkd3d_ ++gen->indent; } +static void shader_glsl_else(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins) +{ + unsigned int i = 4 * (gen->indent - 1); + + vkd3d_string_buffer_printf(gen->buffer, "%*s}\n%*selse\n%*s{\n", i, "", i, "", i, ""); +} + static void shader_glsl_endif(struct vkd3d_glsl_generator *gen) { --gen->indent; @@ -781,6 +788,9 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen, case VKD3DSIH_DP4: shader_glsl_dot(gen, ins, VKD3DSP_WRITEMASK_ALL); break; + case VKD3DSIH_ELSE: + shader_glsl_else(gen, ins); + break; case VKD3DSIH_ENDIF: shader_glsl_endif(gen); break; diff --git a/tests/hlsl/conditional.shader_test b/tests/hlsl/conditional.shader_test index 0c9aa08f..5404fe02 100644 --- a/tests/hlsl/conditional.shader_test +++ b/tests/hlsl/conditional.shader_test @@ -11,10 +11,10 @@ float4 main() : sv_target [test] uniform 0 float4 0.0 0.0 0.0 0.0 -todo(sm<4 | glsl) draw quad +todo(sm<4) draw quad probe (0, 0) rgba (0.9, 0.8, 0.7, 0.6) uniform 0 float4 0.1 0.0 0.0 0.0 -todo(sm<4 | glsl) draw quad +todo(sm<4) draw quad probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4) [pixel shader todo(sm<4)] @@ -43,7 +43,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.0 0.0 0.0 0.0 -todo(sm<4 | glsl) draw quad +todo(sm<4) draw quad probe (0, 0) rgba (0.9, 0.8, 0.7, 0.6) [pixel shader fail(sm<6)] @@ -108,7 +108,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.0 0.0 0.0 0.0 -todo(glsl) draw quad +draw quad probe (0, 0) rgba (0.9, 0.8, 0.7, 0.6) [pixel shader] @@ -209,13 +209,13 @@ if(sm<4) uniform 0 float -3 if(sm<4) uniform 4 float -2 if(sm>=4) uniform 0 int -3 if(sm>=4) uniform 1 int -2 -todo(glsl) draw quad +draw quad probe (0, 0) rgba (-1.0, -1.0, -1.0, -1.0) if(sm<4) uniform 0 float 4 if(sm<4) uniform 4 float 4 if(sm>=4) uniform 0 int 4 if(sm>=4) uniform 1 int 4 -todo(glsl) draw quad +draw quad probe (0, 0) rgba (1.0, 1.0, 1.0, 1.0) diff --git a/tests/hlsl/function-return.shader_test b/tests/hlsl/function-return.shader_test index dc09955a..995953b0 100644 --- a/tests/hlsl/function-return.shader_test +++ b/tests/hlsl/function-return.shader_test @@ -79,16 +79,16 @@ float4 main() : sv_target [test] uniform 0 float 0.1 -todo(sm<4 | glsl) draw quad +todo(sm<4) draw quad probe (0, 0) rgba (0.3, 0.2, 0.6, 0.3) 1 uniform 0 float 0.4 -todo(sm<4 | glsl) draw quad +todo(sm<4) draw quad probe (0, 0) rgba (0.6, 0.5, 0.6, 0.3) 1 uniform 0 float 0.6 -todo(sm<4 | glsl) draw quad +todo(sm<4) draw quad probe (0, 0) rgba (0.6, 0.5, 0.4, 0.5) 1 uniform 0 float 0.8 -todo(sm<4 | glsl) draw quad +todo(sm<4) draw quad probe (0, 0) rgba (0.8, 0.7, 0.4, 0.5) 1 [pixel shader todo(sm<4)] diff --git a/tests/hlsl/return.shader_test b/tests/hlsl/return.shader_test index 9fff7c09..c31f1111 100644 --- a/tests/hlsl/return.shader_test +++ b/tests/hlsl/return.shader_test @@ -63,10 +63,10 @@ void main(out float4 ret : sv_target) [test] uniform 0 float 0.2 -todo(sm<4 | glsl) draw quad +todo(sm<4) draw quad probe (0, 0) rgba (0.3, 0.4, 0.5, 0.6) uniform 0 float 0.8 -todo(sm<4 | glsl) draw quad +todo(sm<4) draw quad probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4) [pixel shader todo(sm<4)] @@ -204,10 +204,10 @@ void main(out float4 ret : sv_target) [test] uniform 0 float 0.2 -todo(sm<4 | glsl) draw quad +todo(sm<4) draw quad probe (0, 0) rgba (0.2, 0.2, 0.2, 0.2) uniform 0 float 0.8 -todo(sm<4 | glsl) draw quad +todo(sm<4) draw quad probe (0, 0) rgba (0.5, 0.5, 0.5, 0.5) [pixel shader todo(sm<4)]