Module: vkd3d Branch: master Commit: 0202393d41f00d8c9f20f59ec080b833b5436f5a URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/0202393d41f00d8c9f20f59ec080b8...
Author: Shaun Ren sren@codeweavers.com Date: Tue Jul 9 16:33:47 2024 -0400
vkd3d-shader/d3dbc: Implement HLSL_OP1_{COS,SIN}_REDUCED for SM1.
Also enable SM1 trigonometry function tests.
---
libs/vkd3d-shader/d3dbc.c | 16 ++++++++++++++++ libs/vkd3d-shader/hlsl.h | 4 ++-- tests/hlsl/trigonometry.shader_test | 16 ++++++++-------- 3 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/libs/vkd3d-shader/d3dbc.c b/libs/vkd3d-shader/d3dbc.c index e4b501c6..492ad9b6 100644 --- a/libs/vkd3d-shader/d3dbc.c +++ b/libs/vkd3d-shader/d3dbc.c @@ -2371,6 +2371,17 @@ static void d3dbc_write_per_component_unary_op(struct d3dbc_compiler *d3dbc, } }
+static void d3dbc_write_sincos(struct d3dbc_compiler *d3dbc, enum hlsl_ir_expr_op op, + const struct hlsl_reg *dst, const struct hlsl_reg *src) +{ + if (op == HLSL_OP1_COS_REDUCED) + assert(dst->writemask == VKD3DSP_WRITEMASK_0); + else /* HLSL_OP1_SIN_REDUCED */ + assert(dst->writemask == VKD3DSP_WRITEMASK_1); + + d3dbc_write_unary_op(d3dbc, D3DSIO_SINCOS, dst, src, 0, 0); +} + static void d3dbc_write_expr(struct d3dbc_compiler *d3dbc, const struct hlsl_ir_node *instr) { const struct vkd3d_shader_version *version = &d3dbc->program->shader_version; @@ -2439,6 +2450,11 @@ static void d3dbc_write_expr(struct d3dbc_compiler *d3dbc, const struct hlsl_ir_ d3dbc_write_per_component_unary_op(d3dbc, instr, D3DSIO_RSQ); break;
+ case HLSL_OP1_COS_REDUCED: + case HLSL_OP1_SIN_REDUCED: + d3dbc_write_sincos(d3dbc, expr->op, &instr->reg, &arg1->reg); + break; + case HLSL_OP2_ADD: d3dbc_write_binary_op(d3dbc, D3DSIO_ADD, &instr->reg, &arg1->reg, &arg2->reg); break; diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index cd6cf91e..d08dd4f2 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -645,7 +645,7 @@ enum hlsl_ir_expr_op HLSL_OP1_CAST, HLSL_OP1_CEIL, HLSL_OP1_COS, - HLSL_OP1_COS_REDUCED, /* Reduced range [-pi, pi] */ + HLSL_OP1_COS_REDUCED, /* Reduced range [-pi, pi], writes to .x */ HLSL_OP1_DSX, HLSL_OP1_DSX_COARSE, HLSL_OP1_DSX_FINE, @@ -666,7 +666,7 @@ enum hlsl_ir_expr_op HLSL_OP1_SAT, HLSL_OP1_SIGN, HLSL_OP1_SIN, - HLSL_OP1_SIN_REDUCED, /* Reduced range [-pi, pi] */ + HLSL_OP1_SIN_REDUCED, /* Reduced range [-pi, pi], writes to .y */ HLSL_OP1_SQRT, HLSL_OP1_TRUNC,
diff --git a/tests/hlsl/trigonometry.shader_test b/tests/hlsl/trigonometry.shader_test index 0b3e4c1a..86161e3d 100644 --- a/tests/hlsl/trigonometry.shader_test +++ b/tests/hlsl/trigonometry.shader_test @@ -5,7 +5,7 @@ void main(float4 pos : position, out float tex : texcoord, out float4 out_pos : out_pos = pos; }
-[pixel shader todo(sm<4)] +[pixel shader] float4 main(float tex : texcoord) : sv_target { tex = floor(tex + 0.25); @@ -13,7 +13,7 @@ float4 main(float tex : texcoord) : sv_target }
[test] -todo(sm<4 | glsl) draw quad +todo(glsl) draw quad probe ( 0, 0) rgba ( 0.00000000, 1.00000000, 0.00000000, 0.0) probe ( 1, 0) rgba ( 0.84147098, 0.54030231, 1.55740772, 0.0) 1024 probe ( 2, 0) rgba ( 0.90929743, -0.41614684, -2.18503986, 0.0) 1024 @@ -32,7 +32,7 @@ probe (14, 0) rgba ( 0.99060736, 0.13673722, 7.24460662, 0.0) 1024 probe (15, 0) rgba ( 0.65028784, -0.75968791, -0.85599340, 0.0) 1024
-[pixel shader todo(sm<4)] +[pixel shader] uniform float4 a;
float4 main() : sv_target @@ -42,11 +42,11 @@ float4 main() : sv_target
[test] uniform 0 float4 0.0 0.52359877 2.61799387 3.14159265 -todo(sm<4 | glsl) draw quad +todo(glsl) draw quad probe (0, 0) rgba (0.0, 500.0, 500.0, 0.0)
-[pixel shader todo(sm<4)] +[pixel shader] uniform float4 a;
float4 main() : sv_target @@ -56,11 +56,11 @@ float4 main() : sv_target
[test] uniform 0 float4 0.0 0.78539816 1.57079632 2.35619449 -todo(sm<4 | glsl) draw quad +todo(glsl) draw quad probe (0, 0) rgba (1000.0, 707.0, -0.0, -707.0)
-[pixel shader todo(sm<4)] +[pixel shader] uniform float4 a;
float4 main() : sv_target @@ -72,7 +72,7 @@ float4 main() : sv_target % tan(pi/2) is an asymtote and therefore undefined % so check 0, pi/4, 3pi/4, pi uniform 0 float4 0.0 0.78539816 2.35619449 3.14159265 -todo(sm<4 | glsl) draw quad +todo(glsl) draw quad probe (0, 0) rgba (0, 1000, -1000.0, 0)