Module: vkd3d Branch: master Commit: 2c1905b78093aca1bb1e61e2d0af06bf923e21ba URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/2c1905b78093aca1bb1e61e2d0af06...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Tue Nov 14 02:27:15 2023 +0100
vkd3d-shader/hlsl: Allow annotations on techniques.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
---
libs/vkd3d-shader/hlsl.y | 15 ++++++++------- tests/hlsl/annotations.shader_test | 30 +++++++++++++++--------------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 12c81d2d..69b20973 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1122,7 +1122,7 @@ static bool add_pass(struct hlsl_ctx *ctx, const char *name, struct hlsl_scope * }
static bool add_technique(struct hlsl_ctx *ctx, const char *name, struct hlsl_scope *scope, - const char *typename, const struct vkd3d_shader_location *loc) + struct hlsl_scope *annotations, const char *typename, const struct vkd3d_shader_location *loc) { struct hlsl_ir_var *var; struct hlsl_type *type; @@ -1131,6 +1131,7 @@ static bool add_technique(struct hlsl_ctx *ctx, const char *name, struct hlsl_sc if (!(var = hlsl_new_var(ctx, name, type, loc, NULL, 0, NULL))) return false; var->scope = scope; + var->annotations = annotations;
if (!hlsl_add_var(ctx, var, false)) { @@ -5306,17 +5307,17 @@ passes: | scope_start pass_list
technique9: - KW_TECHNIQUE name_opt '{' passes '}' + KW_TECHNIQUE name_opt annotations_opt '{' passes '}' { struct hlsl_scope *scope = ctx->cur_scope; hlsl_pop_scope(ctx);
- if (!add_technique(ctx, $2, scope, "technique", &@1)) + if (!add_technique(ctx, $2, scope, $3, "technique", &@1)) YYABORT; }
technique10: - KW_TECHNIQUE10 name_opt '{' passes '}' + KW_TECHNIQUE10 name_opt annotations_opt '{' passes '}' { struct hlsl_scope *scope = ctx->cur_scope; hlsl_pop_scope(ctx); @@ -5325,12 +5326,12 @@ technique10: hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "The 'technique10' keyword is invalid for this profile.");
- if (!add_technique(ctx, $2, scope, "technique10", &@1)) + if (!add_technique(ctx, $2, scope, $3, "technique10", &@1)) YYABORT; }
technique11: - KW_TECHNIQUE11 name_opt '{' passes '}' + KW_TECHNIQUE11 name_opt annotations_opt '{' passes '}' { struct hlsl_scope *scope = ctx->cur_scope; hlsl_pop_scope(ctx); @@ -5339,7 +5340,7 @@ technique11: hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "The 'technique11' keyword is invalid for this profile.");
- if (!add_technique(ctx, $2, scope, "technique11", &@1)) + if (!add_technique(ctx, $2, scope, $3, "technique11", &@1)) YYABORT; }
diff --git a/tests/hlsl/annotations.shader_test b/tests/hlsl/annotations.shader_test index 8592d274..40e383aa 100644 --- a/tests/hlsl/annotations.shader_test +++ b/tests/hlsl/annotations.shader_test @@ -2,19 +2,19 @@ shader model >= 4.0 shader model < 6.0
-[effect todo] +[effect] // Annotations on techniques technique10 t1 < int a = 1; > {} technique10 t2 < int a = 2; int t1 = 3; int t2 = 4; > {}
-[effect todo] +[effect] // Annotations on passes technique10 t1 < int a = 1; > { pass < int t1 = 2; > {} }
-[effect todo] +[effect] // Using names from the global scope float a;
@@ -23,32 +23,32 @@ technique10 t1 < int a = 1; > pass < int a = 2; > {} }
-[effect todo] +[effect] // Evaluated literal constant expression for initial values technique10 < int a = 1+2; > {}
-[effect todo] +[effect] // Using constant variables in the initializer static const int b = 123; technique10 < int a = b; > {}
-[effect todo] +[effect] // Implicitly sized array technique10 < float a[] = {1, 2}; > {}
-[effect todo] +[effect] // Nested braces technique10 < float4 a = {1, {{{2, {3}}, 4}}}; > {}
-[effect todo] +[effect] // Flattening technique10 < float4 a = {1, float2(2, 3), 4}; > {}
-[effect todo] +[effect] // Comma separated initializers technique10 < int a = 1, b = 2; > {}
-[effect todo] +[effect] // Majority modifier technique10 < row_major float3x2 m = {1, 2, 3, 4, 5, 6}; > {}
@@ -66,7 +66,7 @@ technique10 pass < int a = 0; float a = 1.0; > {} }
-[effect fail] +[effect fail todo] // Without initializer technique10 < int a; > {}
@@ -74,17 +74,17 @@ technique10 < int a; > {} // Only numeric types and strings are allowed technique10 < DepthStencilState ds = { 0 }; > {}
-[effect fail] +[effect fail todo] // Type declarations are not allowed technique10 < struct s { int a; } var = { 2 }; > {}
-[effect fail] +[effect fail todo] // Static modifier is not allowed technique10 < static int a = 5; > {}
-[effect fail] +[effect fail todo] // Initializer should not depend on other annotations technique10 < int a = 1, b = a; > {}
-[effect fail] +[effect fail todo] technique10 < int a = 1; int b = a; > {}