diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index c31a227c..c7f5ae86 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -388,6 +388,7 @@ struct hlsl_attribute #define HLSL_STORAGE_LINEAR 0x00010000 #define HLSL_MODIFIER_SINGLE 0x00020000 #define HLSL_MODIFIER_EXPORT 0x00040000 +#define HLSL_STORAGE_ANNOTATION 0x00080000 #define HLSL_TYPE_MODIFIERS_MASK (HLSL_MODIFIER_PRECISE | HLSL_MODIFIER_VOLATILE | \ HLSL_MODIFIER_CONST | HLSL_MODIFIER_ROW_MAJOR | \ @@ -841,6 +842,8 @@ struct hlsl_scope bool loop; /* The scope was created for the switch statement. */ bool _switch; + /* The scope contains annotation variables. */ + bool annotations; }; struct hlsl_profile_info diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index c7af2a10..95be7e08 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -2625,7 +2625,8 @@ static struct hlsl_block *initialize_vars(struct hlsl_ctx *ctx, struct list *var unsigned int size, k; is_default_values_initializer = (ctx->cur_buffer != ctx->globals_buffer) - || (var->storage_modifiers & HLSL_STORAGE_UNIFORM); + || (var->storage_modifiers & HLSL_STORAGE_UNIFORM) + || ctx->cur_scope->annotations; if (is_default_values_initializer) { @@ -6058,19 +6059,31 @@ pass: annotations_list: variables_def_typed ';' + { + struct hlsl_block *block; + + block = initialize_vars(ctx, $1); + destroy_block(block); + } | annotations_list variables_def_typed ';' + { + struct hlsl_block *block; + + block = initialize_vars(ctx, $2); + destroy_block(block); + } annotations_opt: %empty { $$ = NULL; } - | '<' scope_start '>' + | '<' annotations_scope_start '>' { hlsl_pop_scope(ctx); $$ = NULL; } - | '<' scope_start annotations_list '>' + | '<' annotations_scope_start annotations_list '>' { struct hlsl_scope *scope = ctx->cur_scope; @@ -6598,6 +6611,13 @@ switch_scope_start: ctx->cur_scope->_switch = true; } +annotations_scope_start: + %empty + { + hlsl_push_scope(ctx); + ctx->cur_scope->annotations = true; + } + var_identifier: VAR_IDENTIFIER | NEW_IDENTIFIER diff --git a/tests/hlsl/annotations.shader_test b/tests/hlsl/annotations.shader_test index 4545f7ed..55a7e65e 100644 --- a/tests/hlsl/annotations.shader_test +++ b/tests/hlsl/annotations.shader_test @@ -70,7 +70,7 @@ technique10 // Without initializer technique10 < int a; > {} -[effect fail todo] +[effect fail] // Only numeric types and strings are allowed technique10 < DepthStencilState ds = { 0 }; > {} @@ -82,9 +82,9 @@ technique10 < struct s { int a; } var = { 2 }; > {} // Static modifier is not allowed technique10 < static int a = 5; > {} -[effect fail todo] +[effect fail] // Initializer should not depend on other annotations technique10 < int a = 1, b = a; > {} -[effect fail todo] +[effect fail] technique10 < int a = 1; int b = a; > {}