From 1655d309bd4be05f10dac6da66c64e9c3078e86b Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Wed, 28 Sep 2022 13:49:03 +0200 Subject: [PATCH] vkd3d-shader/hlsl: Write SM4 rsq instructions. --- libs/vkd3d-shader/hlsl_sm4.c | 5 +++++ tests/hlsl-normalize.shader_test | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 5d763c56..3ce6fc5e 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1669,6 +1669,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, write_sm4_unary_op(buffer, VKD3D_SM4_OP_ROUND_NE, &expr->node, arg1, 0); break; + case HLSL_OP1_RSQ: + assert(type_is_float(dst_type)); + write_sm4_unary_op(buffer, VKD3D_SM4_OP_RSQ, &expr->node, arg1, 0); + break; + case HLSL_OP1_SAT: assert(type_is_float(dst_type)); write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV diff --git a/tests/hlsl-normalize.shader_test b/tests/hlsl-normalize.shader_test index 3e4bb83e..71b900e8 100644 --- a/tests/hlsl-normalize.shader_test +++ b/tests/hlsl-normalize.shader_test @@ -8,7 +8,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 2.0 3.0 4.0 5.0 -todo draw quad +draw quad probe all rgba (0.272165537, 0.408248305, 0.544331074, 0.680413842) 1 [pixel shader] @@ -21,7 +21,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 2.0 3.0 4.0 0.0 -todo draw quad +draw quad probe all rgba (0.371390700, 0.557086051, 0.742781401, 0.0) 1 [pixel shader] @@ -34,7 +34,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 2.0 3.0 0.0 0.0 -todo draw quad +draw quad probe all rgba (0.554700196, 0.832050323, 0.0, 0.0) 1 [pixel shader] @@ -47,7 +47,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 2.0 0.0 0.0 0.0 -todo draw quad +draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) [pixel shader] @@ -60,7 +60,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 2.0 0.0 0.0 0.0 -todo draw quad +draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) [pixel shader fail]