mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Separate an "array" rule.
This commit is contained in:
parent
94130c2394
commit
4cd2dd50f9
Notes:
Henri Verbeet
2024-07-08 18:54:04 +02:00
Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/916
@ -5930,6 +5930,8 @@ static bool state_block_add_entry(struct hlsl_state_block *state_block, struct h
|
||||
|
||||
%type <if_body> if_body
|
||||
|
||||
%type <intval> array
|
||||
|
||||
%type <modifiers> var_modifiers
|
||||
|
||||
%type <name> any_identifier
|
||||
@ -7385,52 +7387,43 @@ variable_def_typed:
|
||||
$$->modifiers_loc = @1;
|
||||
}
|
||||
|
||||
array:
|
||||
'[' ']'
|
||||
{
|
||||
$$ = HLSL_ARRAY_ELEMENTS_COUNT_IMPLICIT;
|
||||
}
|
||||
| '[' expr ']'
|
||||
{
|
||||
$$ = evaluate_static_expression_as_uint(ctx, $2, &@2);
|
||||
|
||||
if (!$$)
|
||||
{
|
||||
hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
|
||||
"Array size is not a positive integer constant.");
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
if ($$ > 65536)
|
||||
{
|
||||
hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
|
||||
"Array size %u is not between 1 and 65536.", $$);
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
destroy_block($2);
|
||||
}
|
||||
|
||||
arrays:
|
||||
%empty
|
||||
{
|
||||
$$.sizes = NULL;
|
||||
$$.count = 0;
|
||||
}
|
||||
| '[' expr ']' arrays
|
||||
{
|
||||
uint32_t *new_array;
|
||||
unsigned int size;
|
||||
|
||||
size = evaluate_static_expression_as_uint(ctx, $2, &@2);
|
||||
|
||||
destroy_block($2);
|
||||
|
||||
$$ = $4;
|
||||
|
||||
if (!size)
|
||||
{
|
||||
hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
|
||||
"Array size is not a positive integer constant.");
|
||||
vkd3d_free($$.sizes);
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
if (size > 65536)
|
||||
{
|
||||
hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
|
||||
"Array size %u is not between 1 and 65536.", size);
|
||||
vkd3d_free($$.sizes);
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
if (!(new_array = hlsl_realloc(ctx, $$.sizes, ($$.count + 1) * sizeof(*new_array))))
|
||||
{
|
||||
vkd3d_free($$.sizes);
|
||||
YYABORT;
|
||||
}
|
||||
$$.sizes = new_array;
|
||||
$$.sizes[$$.count++] = size;
|
||||
}
|
||||
| '[' ']' arrays
|
||||
| array arrays
|
||||
{
|
||||
uint32_t *new_array;
|
||||
|
||||
$$ = $3;
|
||||
$$ = $2;
|
||||
|
||||
if (!(new_array = hlsl_realloc(ctx, $$.sizes, ($$.count + 1) * sizeof(*new_array))))
|
||||
{
|
||||
@ -7439,7 +7432,7 @@ arrays:
|
||||
}
|
||||
|
||||
$$.sizes = new_array;
|
||||
$$.sizes[$$.count++] = HLSL_ARRAY_ELEMENTS_COUNT_IMPLICIT;
|
||||
$$.sizes[$$.count++] = $1;
|
||||
}
|
||||
|
||||
var_modifiers:
|
||||
|
Loading…
Reference in New Issue
Block a user