From cf7c05f4315dd21a96f60653497c1228a38f61af Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Sun, 25 Feb 2024 02:42:54 +0100 Subject: [PATCH] vkd3d-shader: Remove a token for 'precise' modifier. Signed-off-by: Nikolay Sivov --- Makefile.am | 1 + libs/vkd3d-shader/hlsl.l | 1 - libs/vkd3d-shader/hlsl.y | 14 ++++---- libs/vkd3d-shader/vkd3d_shader_private.h | 1 + tests/hlsl/precise-modifier.shader_test | 41 ++++++++++++++++++++++++ 5 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 tests/hlsl/precise-modifier.shader_test diff --git a/Makefile.am b/Makefile.am index d07218d8..52e154fe 100644 --- a/Makefile.am +++ b/Makefile.am @@ -155,6 +155,7 @@ vkd3d_shader_tests = \ tests/hlsl/object-parameters.shader_test \ tests/hlsl/object-references.shader_test \ tests/hlsl/pow.shader_test \ + tests/hlsl/precise-modifier.shader_test \ tests/hlsl/rasteriser-ordered-views.shader_test \ tests/hlsl/reflect.shader_test \ tests/hlsl/register-reservations-numeric.shader_test \ diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l index 8dcceb94..600e2cf2 100644 --- a/libs/vkd3d-shader/hlsl.l +++ b/libs/vkd3d-shader/hlsl.l @@ -109,7 +109,6 @@ packoffset {return KW_PACKOFFSET; } pass {return KW_PASS; } PixelShader {return KW_PIXELSHADER; } pixelshader {return KW_PIXELSHADER; } -precise {return KW_PRECISE; } RasterizerOrderedBuffer {return KW_RASTERIZERORDEREDBUFFER; } RasterizerOrderedStructuredBuffer {return KW_RASTERIZERORDEREDSTRUCTUREDBUFFER; } RasterizerOrderedTexture1D {return KW_RASTERIZERORDEREDTEXTURE1D; } diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 47d126ac..fda6f597 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -5363,7 +5363,6 @@ static void validate_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, %token KW_PACKOFFSET %token KW_PASS %token KW_PIXELSHADER -%token KW_PRECISE %token KW_RASTERIZERORDEREDBUFFER %token KW_RASTERIZERORDEREDSTRUCTUREDBUFFER %token KW_RASTERIZERORDEREDTEXTURE1D @@ -6823,10 +6822,6 @@ var_modifiers: { $$ = add_modifiers(ctx, $2, HLSL_STORAGE_NOPERSPECTIVE, &@1); } - | KW_PRECISE var_modifiers - { - $$ = add_modifiers(ctx, $2, HLSL_MODIFIER_PRECISE, &@1); - } | KW_SHARED var_modifiers { $$ = add_modifiers(ctx, $2, HLSL_STORAGE_SHARED, &@1); @@ -6875,7 +6870,14 @@ var_modifiers: { $$ = add_modifiers(ctx, $2, HLSL_MODIFIER_INLINE, &@1); } - + | var_identifier var_modifiers + { + if (!strcmp($1, "precise")) + $$ = add_modifiers(ctx, $2, HLSL_MODIFIER_PRECISE, &@1); + else + hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_UNKNOWN_MODIFIER, + "Unknown modifier %s.", debugstr_a($1)); + } complex_initializer: initializer_expr diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index ea52f151..07b9f94c 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -149,6 +149,7 @@ enum vkd3d_shader_error VKD3D_SHADER_ERROR_HLSL_NON_FINITE_RESULT = 5027, VKD3D_SHADER_ERROR_HLSL_DUPLICATE_SWITCH_CASE = 5028, VKD3D_SHADER_ERROR_HLSL_MISSING_TECHNIQUE = 5029, + VKD3D_SHADER_ERROR_HLSL_UNKNOWN_MODIFIER = 5030, VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION = 5300, VKD3D_SHADER_WARNING_HLSL_DIVISION_BY_ZERO = 5301, diff --git a/tests/hlsl/precise-modifier.shader_test b/tests/hlsl/precise-modifier.shader_test new file mode 100644 index 00000000..7ad8f39e --- /dev/null +++ b/tests/hlsl/precise-modifier.shader_test @@ -0,0 +1,41 @@ +[pixel shader] +// 'precise' is not a keyword +float4 precise; + +float4 main() : sv_target +{ + return precise; +} + +[test] +uniform 0 float4 0.1 0.2 0.3 0.4 +draw quad +probe all rgba (0.1, 0.2, 0.3, 0.4) + +[pixel shader fail(sm>=6)] +precise float4 var; +typedef float4 precise; + +precise main() : sv_target +{ + return var; +} + +[test] +uniform 0 float4 0.1 0.2 0.3 0.4 +draw quad +probe all rgba (0.1, 0.2, 0.3, 0.4) + +[pixel shader] +float4 precise; +precise float4 var; + +float4 main() : sv_target +{ + return precise; +} + +[test] +uniform 0 float4 0.1 0.2 0.3 0.4 +draw quad +probe all rgba (0.1, 0.2, 0.3, 0.4)