From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- libs/vkd3d-shader/hlsl.h | 2 ++ libs/vkd3d-shader/hlsl.y | 32 ++++++++++++++++++++++++--- tests/hlsl/technique-fx_5.shader_test | 4 ++-- 3 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 536b46873..bf2f757fe 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -408,6 +408,8 @@ struct hlsl_ir_var struct list extern_entry; /* Scope that variable itself defines, used to provide a container for techniques and passes. */ struct hlsl_scope *scope; + /* Scope that contains annotations for this variable. */ + struct hlsl_scope *annotations;
/* Indexes of the IR instructions where the variable is first written and last read (liveness * range). The IR instructions are numerated starting from 2, because 0 means unused, and 1 diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index b11cbde26..82dffa1d0 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1122,7 +1122,7 @@ static bool add_technique(struct hlsl_ctx *ctx, const char *name, struct hlsl_sc }
static bool add_effect_group(struct hlsl_ctx *ctx, const char *name, struct hlsl_scope *scope, - const struct vkd3d_shader_location *loc) + struct hlsl_scope *annotations, const struct vkd3d_shader_location *loc) { struct hlsl_ir_var *var; struct hlsl_type *type; @@ -1131,6 +1131,7 @@ static bool add_effect_group(struct hlsl_ctx *ctx, const char *name, struct hlsl 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)) { @@ -4916,6 +4917,7 @@ static void check_duplicated_switch_cases(struct hlsl_ctx *ctx, const struct hls struct hlsl_attribute *attr; struct parse_attribute_list attr_list; struct hlsl_ir_switch_case *switch_case; + struct hlsl_scope *scope; }
%token KW_BLENDSTATE @@ -5041,6 +5043,8 @@ static void check_duplicated_switch_cases(struct hlsl_ctx *ctx, const struct hls %token <name> STRING %token <name> TYPE_IDENTIFIER
+%type <scope> annotations_opt + %type <arrays> arrays
%type <assign_op> assign_op @@ -5159,6 +5163,28 @@ name_opt: pass: KW_PASS name_opt '{' '}'
+annotations_list: + variables_def_typed ';' + | annotations_list variables_def_typed ';' + +annotations_opt: + %empty + { + $$ = NULL; + } + | '<' scope_start '>' + { + hlsl_pop_scope(ctx); + $$ = NULL; + } + | '<' scope_start annotations_list '>' + { + struct hlsl_scope *scope = ctx->cur_scope; + + hlsl_pop_scope(ctx); + $$ = scope; + } + pass_list: pass | pass_list pass @@ -5219,11 +5245,11 @@ group_techniques: | group_techniques group_technique
effect_group: - KW_FXGROUP any_identifier '{' scope_start group_techniques '}' + KW_FXGROUP any_identifier annotations_opt '{' scope_start group_techniques '}' { struct hlsl_scope *scope = ctx->cur_scope; hlsl_pop_scope(ctx); - if (!(add_effect_group(ctx, $2, scope, &@2))) + if (!(add_effect_group(ctx, $2, scope, $3, &@2))) YYABORT; }
diff --git a/tests/hlsl/technique-fx_5.shader_test b/tests/hlsl/technique-fx_5.shader_test index f7851f9a8..1485ab84f 100644 --- a/tests/hlsl/technique-fx_5.shader_test +++ b/tests/hlsl/technique-fx_5.shader_test @@ -185,7 +185,7 @@ fxgroup group2 technique11 tech0 {} }
-[effect todo] +[effect] // Annotations on groups fxgroup group1 <> { @@ -202,7 +202,7 @@ fxgroup group3 < int a = 0; > technique11 {} }
-[effect todo] +[effect] struct s { int a;