vkd3d-shader/hlsl: Do not crash on initialization of a redefined variable.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Nikolay Sivov 2024-06-15 22:19:40 +02:00 committed by Henri Verbeet
parent 0a344bd3c9
commit 4d2ce385a7
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
2 changed files with 17 additions and 1 deletions

View File

@ -2629,7 +2629,14 @@ static struct hlsl_block *initialize_vars(struct hlsl_ctx *ctx, struct list *var
if (is_default_values_initializer) if (is_default_values_initializer)
{ {
assert(!var->default_values); /* Default values might have been allocated already for another variable of the same name,
in the same scope. */
if (var->default_values)
{
free_parse_variable_def(v);
continue;
}
if (!(var->default_values = hlsl_calloc(ctx, component_count, sizeof(*var->default_values)))) if (!(var->default_values = hlsl_calloc(ctx, component_count, sizeof(*var->default_values))))
{ {
free_parse_variable_def(v); free_parse_variable_def(v);

View File

@ -320,3 +320,12 @@ float4 main() : sv_target
{ {
return u.y; return u.y;
} }
[pixel shader fail]
float a = 1;
int a = 2;
float4 main() : sv_target
{
return 0;
}