mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d-shader/hlsl: Do not define a separate scope for function parameters.
Remove the no longer needed code to detect redefinition in this case.
This commit is contained in:
committed by
Henri Verbeet
parent
75ef230fbe
commit
2863d86bcc
Notes:
Henri Verbeet
2025-01-29 18:04:53 +01:00
Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1359
@ -93,7 +93,7 @@ char *hlsl_sprintf_alloc(struct hlsl_ctx *ctx, const char *fmt, ...)
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, bool local_var)
|
||||
bool hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl)
|
||||
{
|
||||
struct hlsl_scope *scope = ctx->cur_scope;
|
||||
struct hlsl_ir_var *var;
|
||||
@ -105,15 +105,6 @@ bool hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, bool local_var
|
||||
if (var->name && !strcmp(decl->name, var->name))
|
||||
return false;
|
||||
}
|
||||
if (local_var && scope->upper->upper == ctx->globals)
|
||||
{
|
||||
/* Check whether the variable redefines a function parameter. */
|
||||
LIST_FOR_EACH_ENTRY(var, &scope->upper->vars, struct hlsl_ir_var, scope_entry)
|
||||
{
|
||||
if (var->name && !strcmp(decl->name, var->name))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list_add_tail(&scope->vars, &decl->scope_entry);
|
||||
|
@ -1496,7 +1496,7 @@ const char *hlsl_node_type_to_string(enum hlsl_ir_node_type type);
|
||||
struct hlsl_ir_node *hlsl_add_conditional(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
||||
struct hlsl_ir_node *condition, struct hlsl_ir_node *if_true, struct hlsl_ir_node *if_false);
|
||||
void hlsl_add_function(struct hlsl_ctx *ctx, char *name, struct hlsl_ir_function_decl *decl);
|
||||
bool hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, bool local_var);
|
||||
bool hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl);
|
||||
|
||||
void hlsl_block_cleanup(struct hlsl_block *block);
|
||||
bool hlsl_clone_block(struct hlsl_ctx *ctx, struct hlsl_block *dst_block, const struct hlsl_block *src_block);
|
||||
|
@ -1311,7 +1311,7 @@ static bool add_func_parameter(struct hlsl_ctx *ctx, struct hlsl_func_parameters
|
||||
free_parse_initializer(¶m->initializer);
|
||||
}
|
||||
|
||||
if (!hlsl_add_var(ctx, var, false))
|
||||
if (!hlsl_add_var(ctx, var))
|
||||
{
|
||||
hlsl_free_var(var);
|
||||
return false;
|
||||
@ -1340,7 +1340,7 @@ static bool add_pass(struct hlsl_ctx *ctx, const char *name, struct hlsl_scope *
|
||||
var->state_block_count = 1;
|
||||
var->state_block_capacity = 1;
|
||||
|
||||
if (!hlsl_add_var(ctx, var, false))
|
||||
if (!hlsl_add_var(ctx, var))
|
||||
{
|
||||
struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, var->name);
|
||||
|
||||
@ -1366,7 +1366,7 @@ static bool add_technique(struct hlsl_ctx *ctx, const char *name, struct hlsl_sc
|
||||
var->scope = scope;
|
||||
var->annotations = annotations;
|
||||
|
||||
if (!hlsl_add_var(ctx, var, false))
|
||||
if (!hlsl_add_var(ctx, var))
|
||||
{
|
||||
struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, var->name);
|
||||
|
||||
@ -1392,7 +1392,7 @@ static bool add_effect_group(struct hlsl_ctx *ctx, const char *name, struct hlsl
|
||||
var->scope = scope;
|
||||
var->annotations = annotations;
|
||||
|
||||
if (!hlsl_add_var(ctx, var, false))
|
||||
if (!hlsl_add_var(ctx, var))
|
||||
{
|
||||
struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, var->name);
|
||||
|
||||
@ -2590,7 +2590,6 @@ static void declare_var(struct hlsl_ctx *ctx, struct parse_variable_def *v)
|
||||
bool constant_buffer = false;
|
||||
struct hlsl_ir_var *var;
|
||||
struct hlsl_type *type;
|
||||
bool local = true;
|
||||
char *var_name;
|
||||
unsigned int i;
|
||||
|
||||
@ -2726,8 +2725,6 @@ static void declare_var(struct hlsl_ctx *ctx, struct parse_variable_def *v)
|
||||
|
||||
if (ctx->cur_scope == ctx->globals)
|
||||
{
|
||||
local = false;
|
||||
|
||||
if ((modifiers & HLSL_STORAGE_UNIFORM) && (modifiers & HLSL_STORAGE_STATIC))
|
||||
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
|
||||
"Variable '%s' is declared as both \"uniform\" and \"static\".", var->name);
|
||||
@ -2790,7 +2787,7 @@ static void declare_var(struct hlsl_ctx *ctx, struct parse_variable_def *v)
|
||||
"Static variables cannot have both numeric and resource components.");
|
||||
}
|
||||
|
||||
if (!hlsl_add_var(ctx, var, local))
|
||||
if (!hlsl_add_var(ctx, var))
|
||||
{
|
||||
struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, var->name);
|
||||
|
||||
@ -7863,10 +7860,9 @@ compound_statement:
|
||||
if (!($$ = make_empty_block(ctx)))
|
||||
YYABORT;
|
||||
}
|
||||
| '{' scope_start statement_list '}'
|
||||
| '{' statement_list '}'
|
||||
{
|
||||
hlsl_pop_scope(ctx);
|
||||
$$ = $3;
|
||||
$$ = $2;
|
||||
}
|
||||
|
||||
scope_start:
|
||||
@ -9126,7 +9122,11 @@ statement_list:
|
||||
statement:
|
||||
declaration_statement
|
||||
| expr_statement
|
||||
| compound_statement
|
||||
| scope_start compound_statement
|
||||
{
|
||||
hlsl_pop_scope(ctx);
|
||||
$$ = $2;
|
||||
}
|
||||
| jump_statement
|
||||
| selection_statement
|
||||
| loop_statement
|
||||
|
Reference in New Issue
Block a user