From 9a222d2be14246cc6cedce7deb4592f8fd4a123d Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Mon, 4 Mar 2024 16:34:29 -0300 Subject: [PATCH] vkd3d-shader/d3dbc: Implement HLSL_OP2_LOGIC_AND for SM1. --- libs/vkd3d-shader/d3dbc.c | 4 ++++ libs/vkd3d-shader/hlsl_codegen.c | 1 + tests/hlsl/logic-operations.shader_test | 6 +++--- tests/hlsl/vertex-shader-ops.shader_test | 6 +++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/libs/vkd3d-shader/d3dbc.c b/libs/vkd3d-shader/d3dbc.c index 1be36a5b..099729fb 100644 --- a/libs/vkd3d-shader/d3dbc.c +++ b/libs/vkd3d-shader/d3dbc.c @@ -2333,6 +2333,10 @@ static void write_sm1_expr(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b } break; + case HLSL_OP2_LOGIC_AND: + write_sm1_binary_op(ctx, buffer, D3DSIO_MIN, &instr->reg, &arg1->reg, &arg2->reg); + break; + case HLSL_OP2_LOGIC_OR: write_sm1_binary_op(ctx, buffer, D3DSIO_MAX, &instr->reg, &arg1->reg, &arg2->reg); break; diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 95026eb8..5c09ce04 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -3622,6 +3622,7 @@ static bool lower_nonfloat_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst case HLSL_OP1_NEG: case HLSL_OP2_ADD: case HLSL_OP2_DIV: + case HLSL_OP2_LOGIC_AND: case HLSL_OP2_LOGIC_OR: case HLSL_OP2_MAX: case HLSL_OP2_MIN: diff --git a/tests/hlsl/logic-operations.shader_test b/tests/hlsl/logic-operations.shader_test index 15d2afeb..b698944b 100644 --- a/tests/hlsl/logic-operations.shader_test +++ b/tests/hlsl/logic-operations.shader_test @@ -158,7 +158,7 @@ todo(glsl) draw quad probe all rgba (0.0, 1.0, 1.0, 1.0) -[pixel shader todo(sm<4)] +[pixel shader] int a, b; float4 main() : SV_TARGET @@ -171,11 +171,11 @@ if(sm<4) uniform 0 float 5 if(sm<4) uniform 4 float 0 if(sm>=4) uniform 0 int 5 if(sm>=4) uniform 1 int 0 -todo(sm<4 | glsl) draw quad +todo(glsl) draw quad probe all rgba (1.0, 1.0, 0.0, 1.0) if(sm<4) uniform 0 float -1 if(sm<4) uniform 4 float 3 if(sm>=4) uniform 0 int -1 if(sm>=4) uniform 1 int 3 -todo(sm<4 | glsl) draw quad +todo(glsl) draw quad probe all rgba (0.0, 1.0, 0.0, 0.0) diff --git a/tests/hlsl/vertex-shader-ops.shader_test b/tests/hlsl/vertex-shader-ops.shader_test index 89e62a76..ee2a72f0 100644 --- a/tests/hlsl/vertex-shader-ops.shader_test +++ b/tests/hlsl/vertex-shader-ops.shader_test @@ -58,7 +58,7 @@ todo(glsl) draw quad probe all rgba (1.0, 0.0, 0.0, 1.0) -[vertex shader todo(sm<4)] +[vertex shader] int a, b; void main(out float4 res : COLOR1, in float4 pos : position, out float4 out_pos : sv_position) @@ -75,12 +75,12 @@ void main(out float4 res : COLOR1, in float4 pos : position, out float4 out_pos if(sm<4) uniform 0 float 0 if(sm<4) uniform 4 float 2 if(sm>=4) uniform 0 int4 0 2 0 0 -todo(sm<4 | glsl) draw quad +todo(glsl) draw quad probe all rgba (0.0, 1.0, 0.0, 1.0) if(sm<4) uniform 0 float -2 if(sm<4) uniform 4 float 8 if(sm>=4) uniform 0 int4 -2 8 0 0 -todo(sm<4 | glsl) draw quad +todo(glsl) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0)