vkd3d-shader/hlsl: Set default values for annotations variables.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Nikolay Sivov 2024-06-15 19:56:25 +02:00 committed by Henri Verbeet
parent 4d2ce385a7
commit 0f7ac0a054
Notes: Henri Verbeet 2024-07-08 18:55:00 +02:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/918
3 changed files with 29 additions and 6 deletions

View File

@ -388,6 +388,7 @@ struct hlsl_attribute
#define HLSL_STORAGE_LINEAR 0x00010000 #define HLSL_STORAGE_LINEAR 0x00010000
#define HLSL_MODIFIER_SINGLE 0x00020000 #define HLSL_MODIFIER_SINGLE 0x00020000
#define HLSL_MODIFIER_EXPORT 0x00040000 #define HLSL_MODIFIER_EXPORT 0x00040000
#define HLSL_STORAGE_ANNOTATION 0x00080000
#define HLSL_TYPE_MODIFIERS_MASK (HLSL_MODIFIER_PRECISE | HLSL_MODIFIER_VOLATILE | \ #define HLSL_TYPE_MODIFIERS_MASK (HLSL_MODIFIER_PRECISE | HLSL_MODIFIER_VOLATILE | \
HLSL_MODIFIER_CONST | HLSL_MODIFIER_ROW_MAJOR | \ HLSL_MODIFIER_CONST | HLSL_MODIFIER_ROW_MAJOR | \
@ -841,6 +842,8 @@ struct hlsl_scope
bool loop; bool loop;
/* The scope was created for the switch statement. */ /* The scope was created for the switch statement. */
bool _switch; bool _switch;
/* The scope contains annotation variables. */
bool annotations;
}; };
struct hlsl_profile_info struct hlsl_profile_info

View File

@ -2625,7 +2625,8 @@ static struct hlsl_block *initialize_vars(struct hlsl_ctx *ctx, struct list *var
unsigned int size, k; unsigned int size, k;
is_default_values_initializer = (ctx->cur_buffer != ctx->globals_buffer) 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) if (is_default_values_initializer)
{ {
@ -6058,19 +6059,31 @@ pass:
annotations_list: annotations_list:
variables_def_typed ';' variables_def_typed ';'
{
struct hlsl_block *block;
block = initialize_vars(ctx, $1);
destroy_block(block);
}
| annotations_list variables_def_typed ';' | annotations_list variables_def_typed ';'
{
struct hlsl_block *block;
block = initialize_vars(ctx, $2);
destroy_block(block);
}
annotations_opt: annotations_opt:
%empty %empty
{ {
$$ = NULL; $$ = NULL;
} }
| '<' scope_start '>' | '<' annotations_scope_start '>'
{ {
hlsl_pop_scope(ctx); hlsl_pop_scope(ctx);
$$ = NULL; $$ = NULL;
} }
| '<' scope_start annotations_list '>' | '<' annotations_scope_start annotations_list '>'
{ {
struct hlsl_scope *scope = ctx->cur_scope; struct hlsl_scope *scope = ctx->cur_scope;
@ -6598,6 +6611,13 @@ switch_scope_start:
ctx->cur_scope->_switch = true; ctx->cur_scope->_switch = true;
} }
annotations_scope_start:
%empty
{
hlsl_push_scope(ctx);
ctx->cur_scope->annotations = true;
}
var_identifier: var_identifier:
VAR_IDENTIFIER VAR_IDENTIFIER
| NEW_IDENTIFIER | NEW_IDENTIFIER

View File

@ -70,7 +70,7 @@ technique10
// Without initializer // Without initializer
technique10 < int a; > {} technique10 < int a; > {}
[effect fail todo] [effect fail]
// Only numeric types and strings are allowed // Only numeric types and strings are allowed
technique10 < DepthStencilState ds = { 0 }; > {} technique10 < DepthStencilState ds = { 0 }; > {}
@ -82,9 +82,9 @@ technique10 < struct s { int a; } var = { 2 }; > {}
// Static modifier is not allowed // Static modifier is not allowed
technique10 < static int a = 5; > {} technique10 < static int a = 5; > {}
[effect fail todo] [effect fail]
// Initializer should not depend on other annotations // Initializer should not depend on other annotations
technique10 < int a = 1, b = a; > {} technique10 < int a = 1, b = a; > {}
[effect fail todo] [effect fail]
technique10 < int a = 1; int b = a; > {} technique10 < int a = 1; int b = a; > {}