diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 0d3e7fee..1762a060 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -4222,7 +4222,7 @@ struct hlsl_ir_node *hlsl_add_conditional(struct hlsl_ctx *ctx, struct hlsl_bloc return hlsl_block_add_expr(ctx, instrs, HLSL_OP3_TERNARY, operands, if_true->data_type, &condition->loc); } -static bool lower_int_division(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block) +static bool lower_int_division_sm4(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block) { struct hlsl_ir_node *arg1, *arg2, *xor, *and, *abs1, *abs2, *div, *neg, *cast1, *cast2, *cast3, *high_bit; struct hlsl_type *type = instr->data_type, *utype; @@ -4262,7 +4262,7 @@ static bool lower_int_division(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, return hlsl_add_conditional(ctx, block, and, neg, cast3); } -static bool lower_int_modulus(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block) +static bool lower_int_modulus_sm4(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block) { struct hlsl_ir_node *arg1, *arg2, *and, *abs1, *abs2, *div, *neg, *cast1, *cast2, *cast3, *high_bit; struct hlsl_type *type = instr->data_type, *utype; @@ -7067,8 +7067,11 @@ void hlsl_run_const_passes(struct hlsl_ctx *ctx, struct hlsl_block *body) lower_ir(ctx, lower_narrowing_casts, body); lower_ir(ctx, lower_int_dot, body); - lower_ir(ctx, lower_int_division, body); - lower_ir(ctx, lower_int_modulus, body); + if (hlsl_version_ge(ctx, 4, 0)) + { + lower_ir(ctx, lower_int_modulus_sm4, body); + lower_ir(ctx, lower_int_division_sm4, body); + } lower_ir(ctx, lower_int_abs, body); lower_ir(ctx, lower_casts_to_bool, body); lower_ir(ctx, lower_float_modulus, body); diff --git a/tests/hlsl/arithmetic-int-uniform.shader_test b/tests/hlsl/arithmetic-int-uniform.shader_test index dc14052b..01de4915 100644 --- a/tests/hlsl/arithmetic-int-uniform.shader_test +++ b/tests/hlsl/arithmetic-int-uniform.shader_test @@ -1,4 +1,4 @@ -[pixel shader todo(sm<4)] +[pixel shader] uniform float2 a; float4 main() : SV_TARGET @@ -10,7 +10,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 5.0 16.0 0.0 0.0 -todo(sm<4 | glsl | msl) draw quad +todo(glsl | msl) draw quad probe (0, 0) rgba (21.0, -11.0, 80.0, 0.0) [pixel shader todo(sm<4)] @@ -28,7 +28,7 @@ uniform 0 float4 5.0 16.0 0.0 0.0 todo(sm<4 | glsl | msl) draw quad probe (0, 0) rgba (5.0, 5.0, -5.0, 3.0) -[pixel shader todo(sm<4)] +[pixel shader] uniform float2 a; float4 main() : SV_TARGET @@ -40,7 +40,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 42.0 5.0 0.0 0.0 -todo(sm<4 | glsl | msl) draw quad +todo(glsl | msl) draw quad probe (0, 0) rgba (8.0, -8.0, -8.0, 8.0) [pixel shader todo(sm<4)] @@ -58,7 +58,7 @@ uniform 0 float4 42.0 5.0 0.0 0.0 todo(sm<4 | glsl | msl) draw quad probe (0, 0) rgba (2.0, -2.0, 2.0, -2.0) -[pixel shader todo(sm<4)] +[pixel shader] uniform float2 a; float4 main() : SV_TARGET @@ -70,7 +70,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 45.0 5.0 0.0 0.0 -todo(sm<4 | glsl | msl) draw quad +todo(glsl | msl) draw quad probe (0, 0) rgba (9.0, -9.0, -9.0, 9.0) [pixel shader todo(sm<4)] @@ -137,7 +137,7 @@ todo(sm<4 | glsl | msl) draw quad if(sm<4) probe (0, 0) rgba(6, 6, -6, -6) if(sm>=4) probe (0, 0) rgba(7, 7, -7, -7) -[pixel shader todo(sm<4)] +[pixel shader] float f; float4 main() : sv_target @@ -150,11 +150,11 @@ float4 main() : sv_target [test] uniform 0 float 999.0 -todo(sm<4 | glsl | msl) draw quad +todo(glsl | msl) draw quad if(sm<4) probe (0, 0) rgba(16798, -16798, -16798, 16798) if(sm>=4) probe (0, 0) rgba(16799, -16799, -16799, 16799) -[pixel shader todo(sm<4)] +[pixel shader] float f; float4 main() : sv_target @@ -167,7 +167,7 @@ float4 main() : sv_target [test] uniform 0 float 999.0 -todo(sm<4 | glsl | msl) draw quad +todo(glsl | msl) draw quad probe (0, 0) rgba(16798, -16798, -16798, 16798) [require]