diff --git a/libs/vkd3d-shader/msl.c b/libs/vkd3d-shader/msl.c index 8ce8719c..9c5df5bc 100644 --- a/libs/vkd3d-shader/msl.c +++ b/libs/vkd3d-shader/msl.c @@ -440,6 +440,31 @@ static void msl_mov(struct msl_generator *gen, const struct vkd3d_shader_instruc msl_dst_cleanup(&dst, &gen->string_buffers); } +static void msl_movc(struct msl_generator *gen, const struct vkd3d_shader_instruction *ins) +{ + unsigned int component_count; + struct msl_src src[3]; + struct msl_dst dst; + uint32_t mask; + + mask = msl_dst_init(&dst, gen, ins, &ins->dst[0]); + msl_src_init(&src[0], gen, &ins->src[0], mask); + msl_src_init(&src[1], gen, &ins->src[1], mask); + msl_src_init(&src[2], gen, &ins->src[2], mask); + + if ((component_count = vsir_write_mask_component_count(mask)) > 1) + msl_print_assignment(gen, &dst, "select(%s, %s, bool%u(%s))", + src[2].str->buffer, src[1].str->buffer, component_count, src[0].str->buffer); + else + msl_print_assignment(gen, &dst, "select(%s, %s, bool(%s))", + src[2].str->buffer, src[1].str->buffer, src[0].str->buffer); + + msl_src_cleanup(&src[2], &gen->string_buffers); + msl_src_cleanup(&src[1], &gen->string_buffers); + msl_src_cleanup(&src[0], &gen->string_buffers); + msl_dst_cleanup(&dst, &gen->string_buffers); +} + static void msl_ret(struct msl_generator *gen, const struct vkd3d_shader_instruction *ins) { msl_print_indent(gen->buffer, gen->indent); @@ -479,6 +504,9 @@ static void msl_handle_instruction(struct msl_generator *gen, const struct vkd3d case VKD3DSIH_MOV: msl_mov(gen, ins); break; + case VKD3DSIH_MOVC: + msl_movc(gen, ins); + break; case VKD3DSIH_MUL: msl_binop(gen, ins, "*"); break; diff --git a/tests/hlsl/arithmetic-float-uniform.shader_test b/tests/hlsl/arithmetic-float-uniform.shader_test index a48b3f3a..f63a6a9c 100644 --- a/tests/hlsl/arithmetic-float-uniform.shader_test +++ b/tests/hlsl/arithmetic-float-uniform.shader_test @@ -25,7 +25,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 5.0 15.0 0.0 0.0 -todo(msl) draw quad +draw quad probe (0, 0) rgba (5.0, 5.0, -5.0, 3.0) 1 [pixel shader] @@ -40,7 +40,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 42.0 5.0 0.0 0.0 -todo(msl) draw quad +draw quad probe (0, 0) rgba (2.0, -2.0, 2.0, -2.0) 16 [pixel shader] @@ -55,7 +55,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 45.0 5.0 0.0 0.0 -todo(msl) draw quad +draw quad probe (0, 0) rgba (0.0, 0.0, 0.0, 0.0) [pixel shader] @@ -69,7 +69,7 @@ float4 main() : sv_target [test] uniform 0 float4 5.0 -42.1 4.0 45.0 uniform 4 float4 15.0 -5.0 4.1 5.0 -todo(msl) draw quad +draw quad probe (0, 0) rgba (5.0, -2.1, 4.0, 0.0) 6 [require] diff --git a/tests/hlsl/fmod.shader_test b/tests/hlsl/fmod.shader_test index 7ff8e8b4..7d51ac7f 100644 --- a/tests/hlsl/fmod.shader_test +++ b/tests/hlsl/fmod.shader_test @@ -8,10 +8,10 @@ float4 main() : sv_target [test] uniform 0 float4 -0.5 6.5 0.0 0.0 -todo(msl) draw quad +draw quad probe (0, 0) rgba (-0.5, 0.0, 0.0, 0.0) 4 uniform 0 float4 1.1 0.3 0.0 0.0 -todo(msl) draw quad +draw quad probe (0, 0) rgba (0.2, 0.0, 0.0, 0.0) 4 [pixel shader] @@ -24,8 +24,8 @@ float4 main() : sv_target [test] uniform 0 float4 -0.5 6.5 2.0 0.0 -todo(msl) draw quad +draw quad probe (0, 0) rgba (-0.5, 0.5, 0.0, 0.0) 4 uniform 0 float4 1.1 0.3 3.0 0.0 -todo(msl) draw quad +draw quad probe (0, 0) rgba (1.1, 0.3, 0.0, 0.0) 4 diff --git a/tests/hlsl/ternary.shader_test b/tests/hlsl/ternary.shader_test index 9bce9a6c..fd1b3efd 100644 --- a/tests/hlsl/ternary.shader_test +++ b/tests/hlsl/ternary.shader_test @@ -13,10 +13,10 @@ float4 main() : sv_target [test] uniform 0 float4 2.0 3.0 4.0 5.0 -todo(msl) draw quad +draw quad probe (0, 0) rgba (2.0, 3.0, 4.0, 5.0) uniform 0 float4 0.0 10.0 11.0 12.0 -todo(msl) draw quad +draw quad probe (0, 0) rgba (-1.0, 9.0, 10.0, 11.0) @@ -35,7 +35,7 @@ float4 main() : sv_target [test] uniform 0 float4 1.1 3.0 4.0 5.0 -todo(msl) draw quad +draw quad probe (0, 0) rgba (1.1, 2.0, 0.0, 0.0) @@ -51,7 +51,7 @@ float4 main() : sv_target [test] uniform 0 float4 1.0 0.0 0.0 0.0 -todo(msl) draw quad +draw quad probe (0, 0) rgba (0.5, 0.6, 0.7, 0.0) @@ -67,7 +67,7 @@ float4 main() : sv_target uniform 0 float4 0.0 1.0 0.0 -3.0 uniform 4 float4 1.0 2.0 3.0 4.0 uniform 8 float4 5.0 6.0 7.0 8.0 -todo(msl) draw quad +draw quad probe (0, 0) rgba (5.0, 2.0, 7.0, 4.0) @@ -288,7 +288,7 @@ float4 main() : sv_target uniform 0 float4 1.0 0.0 0.0 0.0 uniform 4 float4 1.0 2.0 3.0 4.0 uniform 8 float4 5.0 6.0 7.0 8.0 -todo(msl) draw quad +draw quad probe (0, 0) rgba (1.0, 2.0, 3.0, 4.0) @@ -323,7 +323,7 @@ float4 main() : sv_target uniform 0 float4 1.0 0.0 1.0 0.0 uniform 4 float4 1.0 2.0 3.0 4.0 uniform 8 float4 5.0 6.0 7.0 8.0 -todo(msl) draw quad +draw quad probe (0, 0) rgba (1.0, 5.0, 1.0, 5.0)