vkd3d-shader/d3dbc: Implement HLSL_OP1_{COS,SIN}_REDUCED for SM1.

Also enable SM1 trigonometry function tests.
This commit is contained in:
Shaun Ren 2024-07-09 16:33:47 -04:00 committed by Henri Verbeet
parent ea2ffc0b6c
commit 0202393d41
Notes: Henri Verbeet 2024-07-16 19:57:03 +02:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/923
3 changed files with 26 additions and 10 deletions

View File

@ -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;

View File

@ -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,

View File

@ -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)