diff --git a/libs/vkd3d-shader/glsl.c b/libs/vkd3d-shader/glsl.c index b29f13f2..d363e04b 100644 --- a/libs/vkd3d-shader/glsl.c +++ b/libs/vkd3d-shader/glsl.c @@ -457,6 +457,28 @@ static void shader_glsl_relop(struct vkd3d_glsl_generator *gen, glsl_dst_cleanup(&dst, &gen->string_buffers); } +static void shader_glsl_cast(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins, + const char *scalar_constructor, const char *vector_constructor) +{ + unsigned int component_count; + struct glsl_src src; + struct glsl_dst dst; + uint32_t mask; + + mask = glsl_dst_init(&dst, gen, ins, &ins->dst[0]); + glsl_src_init(&src, gen, &ins->src[0], mask); + + if ((component_count = vsir_write_mask_component_count(mask)) > 1) + shader_glsl_print_assignment(gen, &dst, "%s%u(%s)", + vector_constructor, component_count, src.str->buffer); + else + shader_glsl_print_assignment(gen, &dst, "%s(%s)", + scalar_constructor, src.str->buffer); + + glsl_src_cleanup(&src, &gen->string_buffers); + glsl_dst_cleanup(&dst, &gen->string_buffers); +} + static void shader_glsl_mov(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins) { struct glsl_src src; @@ -665,6 +687,9 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen, case VKD3DSIH_NEU: shader_glsl_relop(gen, ins, "!=", "notEqual"); break; + case VKD3DSIH_ITOF: + shader_glsl_cast(gen, ins, "float", "vec"); + break; case VKD3DSIH_MOV: shader_glsl_mov(gen, ins); break; diff --git a/tests/hlsl/asint.shader_test b/tests/hlsl/asint.shader_test index 74222afb..cd717ed6 100644 --- a/tests/hlsl/asint.shader_test +++ b/tests/hlsl/asint.shader_test @@ -36,7 +36,7 @@ float4 main() : sv_target uniform 0 int4 11 12 0 0 uniform 4 int4 13 14 0 0 uniform 8 int4 20 21 22 23 -todo(glsl) draw quad +draw quad probe (320,240) rgba (13.0, 21.0, 0.0, 0.0) diff --git a/tests/hlsl/bool-cast.shader_test b/tests/hlsl/bool-cast.shader_test index 5409ea12..daf0283d 100644 --- a/tests/hlsl/bool-cast.shader_test +++ b/tests/hlsl/bool-cast.shader_test @@ -27,7 +27,7 @@ float4 main() : SV_TARGET uniform 0 float4 0.0 0.0 2.0 4.0 if(sm<4) uniform 4 float4 0 1 0 10 if(sm>=4) uniform 4 int4 0 1 0 10 -todo(sm<4 | glsl) draw quad +todo(sm<4) draw quad probe (0, 0) rgba (0.0, 10.0, 1.0, 11.0) @@ -42,5 +42,5 @@ float4 main() : sv_target [test] if(sm<4) uniform 0 float4 1.0 1.0 1.0 0.0 if(sm>=4) uniform 0 uint4 0x00000001 0x00000002 0x80000000 0x00000000 -todo(sm<4 | glsl) draw quad +todo(sm<4) draw quad probe (0, 0) rgba (2.0, 2.0, 2.0, 0.0) diff --git a/tests/hlsl/default-values.shader_test b/tests/hlsl/default-values.shader_test index afd5e41e..62722b68 100644 --- a/tests/hlsl/default-values.shader_test +++ b/tests/hlsl/default-values.shader_test @@ -111,7 +111,7 @@ if(sm<4) uniform 8 float4 70 90 0 0 if(sm<4) uniform 12 float4 80 100 0 0 if(sm>=4) uniform 8 int4 70 90 0 0 if(sm>=4) uniform 12 int4 80 100 0 0 -todo(glsl) draw quad +draw quad probe (0, 0) rgba (70, 80, 90, 100) @@ -216,7 +216,7 @@ if(sm<4) uniform 8 float4 70 90 0 0 if(sm<4) uniform 12 float4 80 100 0 0 if(sm>=4) uniform 8 int4 70 90 0 0 if(sm>=4) uniform 12 int4 80 100 0 0 -todo(glsl) draw quad +draw quad probe (0, 0) rgba (70, 80, 90, 100) diff --git a/tests/hlsl/lerp.shader_test b/tests/hlsl/lerp.shader_test index 17ffca77..dac2e051 100644 --- a/tests/hlsl/lerp.shader_test +++ b/tests/hlsl/lerp.shader_test @@ -33,7 +33,7 @@ if(sm<4) uniform 8 float4 0 1 -1 1000000 if(sm>=4) uniform 0 int4 2 3 4 0 if(sm>=4) uniform 4 int4 0 -10 10 1000000 if(sm>=4) uniform 8 int4 0 1 -1 1000000 -todo(glsl) draw quad +draw quad probe (0, 0) rgba (2.0, -10.0, -2.0, 1e12) 4