From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- libs/vkd3d-shader/hlsl_codegen.c | 7 ++++++- tests/hlsl/arithmetic-float.shader_test | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 132f44a2a..65c68d460 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -2719,6 +2719,7 @@ static bool lower_float_modulus(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr { struct hlsl_ir_node *arg1, *arg2, *mul1, *neg1, *ge, *neg2, *div, *mul2, *frc, *cond, *one, *mul3; struct hlsl_type *type = instr->data_type, *btype; + struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS]; struct hlsl_constant_value one_value; struct hlsl_ir_expr *expr; unsigned int i; @@ -2753,8 +2754,12 @@ static bool lower_float_modulus(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr return false; hlsl_block_add_instr(block, neg2);
- if (!(cond = hlsl_add_conditional(ctx, block, ge, arg2, neg2))) + operands[0] = ge; + operands[1] = arg2; + operands[2] = neg2; + if (!(cond = hlsl_new_expr(ctx, HLSL_OP3_TERNARY, operands, arg2->data_type, &instr->loc))) return false; + hlsl_block_add_instr(block, cond);
for (i = 0; i < type->dimx; ++i) one_value.u[i].f = 1.0f; diff --git a/tests/hlsl/arithmetic-float.shader_test b/tests/hlsl/arithmetic-float.shader_test index 558d5d100..4e1dff58c 100644 --- a/tests/hlsl/arithmetic-float.shader_test +++ b/tests/hlsl/arithmetic-float.shader_test @@ -50,6 +50,20 @@ float4 main() : SV_TARGET draw quad probe all rgba (0.0, 0.0, 0.0, 0.0)
+[pixel shader] +float4 x, y; + +float4 main() : sv_target +{ + return x % y; +} + +[test] +uniform 0 float4 3.0 -5.0 4.0 2.3 +uniform 4 float4 2.0 -1.5 4.1 1.1 +draw quad +probe all rgba (1.0, -0.5, 4.0, 0.0999999) 4 + [require] % Infinities are not allowed in SM1 shader model >= 4.0