vkd3d-shader/glsl: Implement VKD3DSIH_ELSE.

This commit is contained in:
Henri Verbeet 2024-05-03 21:35:39 +02:00
parent 01ba2ba6db
commit 3452d126a8
Notes: Henri Verbeet 2024-10-01 17:35:47 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1134
4 changed files with 24 additions and 14 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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)]

View File

@ -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)]