From 9f3bbab2f0931d23e5b6b38b7a5541e3b037fc48 Mon Sep 17 00:00:00 2001 From: "Anna (navi) Figueiredo Gomes" Date: Wed, 13 Nov 2024 21:13:13 +0100 Subject: [PATCH] vkd3d-shader/hlsl: Implement cast from bool to int for SM1. --- libs/vkd3d-shader/hlsl_codegen.c | 5 +--- tests/hlsl/bool-cast.shader_test | 8 +++--- tests/hlsl/non-const-indexing.shader_test | 10 +++---- tests/hlsl/sign.shader_test | 32 +++++++++++------------ 4 files changed, 26 insertions(+), 29 deletions(-) diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 070b5875..1fbf670f 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -7297,13 +7297,10 @@ static bool sm1_generate_vsir_instr_expr_cast(struct hlsl_ctx *ctx, case HLSL_TYPE_INT: case HLSL_TYPE_UINT: + case HLSL_TYPE_BOOL: generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_MOV, 0, 0, true); return true; - case HLSL_TYPE_BOOL: - hlsl_fixme(ctx, &instr->loc, "SM1 cast from bool to integer."); - break; - case HLSL_TYPE_DOUBLE: hlsl_fixme(ctx, &instr->loc, "SM1 cast from double to integer."); break; diff --git a/tests/hlsl/bool-cast.shader_test b/tests/hlsl/bool-cast.shader_test index fdc6d59f..a1731a9b 100644 --- a/tests/hlsl/bool-cast.shader_test +++ b/tests/hlsl/bool-cast.shader_test @@ -14,7 +14,7 @@ todo(msl) draw quad probe (0, 0) rgba (0.0, 0.0, 1.0, 1.0) -[pixel shader todo(sm<4)] +[pixel shader] uniform float4 x; uniform int4 y; @@ -27,11 +27,11 @@ 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 | msl) draw quad +todo(msl) draw quad probe (0, 0) rgba (0.0, 10.0, 1.0, 11.0) -[pixel shader todo(sm<4)] +[pixel shader] uniform bool4 b; float4 main() : sv_target @@ -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 | msl) draw quad +todo(msl) draw quad probe (0, 0) rgba (2.0, 2.0, 2.0, 0.0) diff --git a/tests/hlsl/non-const-indexing.shader_test b/tests/hlsl/non-const-indexing.shader_test index 6a5a0f69..c43bc1ad 100644 --- a/tests/hlsl/non-const-indexing.shader_test +++ b/tests/hlsl/non-const-indexing.shader_test @@ -65,7 +65,7 @@ todo(msl) draw quad probe (0, 0) rgba (3, 3, 3, 3) -[pixel shader todo(sm<4)] +[pixel shader] uniform float i; float4 main() : SV_TARGET @@ -77,16 +77,16 @@ float4 main() : SV_TARGET [test] uniform 0 float 0 -todo(sm<4 | msl) draw quad +todo(msl) draw quad probe (0, 0) rgba (21.0, 1.0, 24.0, 0.0) uniform 0 float 1 -todo(sm<4 | msl) draw quad +todo(msl) draw quad probe (0, 0) rgba (22.0, 0.0, 23.0, 1.0) uniform 0 float 2 -todo(sm<4 | msl) draw quad +todo(msl) draw quad probe (0, 0) rgba (23.0, 1.0, 22.0, 0.0) uniform 0 float 3 -todo(sm<4 | msl) draw quad +todo(msl) draw quad probe (0, 0) rgba (24.0, 0.0, 21.0, 1.0) diff --git a/tests/hlsl/sign.shader_test b/tests/hlsl/sign.shader_test index b31e35c0..c2df764f 100644 --- a/tests/hlsl/sign.shader_test +++ b/tests/hlsl/sign.shader_test @@ -1,4 +1,4 @@ -[pixel shader todo(sm<4)] +[pixel shader] uniform float f; float4 main() : sv_target @@ -8,17 +8,17 @@ float4 main() : sv_target [test] uniform 0 float4 1.0 0.0 0.0 0.0 -todo(sm<4 | msl) draw quad +todo(msl) draw quad probe (0, 0) rgba (1.0, 1.0, 1.0, 1.0) uniform 0 float4 -1.0 0.0 0.0 0.0 -todo(sm<4 | msl) draw quad +todo(msl) draw quad probe (0, 0) rgba (-1.0, -1.0, -1.0, -1.0) uniform 0 float4 0.0 0.0 0.0 0.0 -todo(sm<4 | msl) draw quad +todo(msl) draw quad probe (0, 0) rgba (0.0, 0.0, 0.0, 0.0) -[pixel shader todo(sm<4)] +[pixel shader] uniform float4 f; float4 main() : sv_target @@ -28,11 +28,11 @@ float4 main() : sv_target [test] uniform 0 float4 1.0 2.0 3.0 4.0 -todo(sm<4 | msl) draw quad +todo(msl) draw quad probe (0, 0) rgba (1.0, 1.0, 1.0, 1.0) -[pixel shader todo(sm<4)] +[pixel shader] uniform float2x2 f; float4 main() : sv_target @@ -43,11 +43,11 @@ float4 main() : sv_target [test] uniform 0 float4 1.0 2.0 0.0 0.0 uniform 4 float4 3.0 4.0 0.0 0.0 -todo(sm<4 | msl) draw quad +todo(msl) draw quad probe (0, 0) rgba (1.0, 1.0, 1.0, 1.0) -[pixel shader todo(sm<4)] +[pixel shader] uniform int f; float4 main() : sv_target @@ -58,19 +58,19 @@ float4 main() : sv_target [test] if(sm<4) uniform 0 float4 1 0 0 0 if(sm>=4) uniform 0 int4 1 0 0 0 -todo(sm<4 | msl) draw quad +todo(msl) draw quad probe (0, 0) rgba (1, 1, 1, 1) if(sm<4) uniform 0 float4 -1 0 0 0 if(sm>=4) uniform 0 int4 -1 0 0 0 -todo(sm<4 | msl) draw quad +todo(msl) draw quad probe (0, 0) rgba (-1, -1, -1, -1) if(sm<4) uniform 0 float4 0 0 0 0 if(sm>=4) uniform 0 int4 0 0 0 0 -todo(sm<4 | msl) draw quad +todo(msl) draw quad probe (0, 0) rgba (0, 0, 0, 0) -[pixel shader todo(sm<4)] +[pixel shader] uniform int4 f; float4 main() : sv_target @@ -81,11 +81,11 @@ float4 main() : sv_target [test] if(sm<4) uniform 0 float4 1 2 3 4 if(sm>=4) uniform 0 int4 1 2 3 4 -todo(sm<4 | msl) draw quad +todo(msl) draw quad probe (0, 0) rgba (1, 1, 1, 1) -[pixel shader todo(sm<4)] +[pixel shader] uniform int2x2 f; float4 main() : sv_target @@ -98,5 +98,5 @@ if(sm<4) uniform 0 float4 1 2 0 0 if(sm<4) uniform 4 float4 3 4 0 0 if(sm>=4) uniform 0 int4 1 2 0 0 if(sm>=4) uniform 4 int4 3 4 0 0 -todo(sm<4 | msl) draw quad +todo(msl) draw quad probe (0, 0) rgba (1, 1, 1, 1)