vkd3d-shader/hlsl: Unify add_shader_compilation() cleanup.

This commit is contained in:
Anna (navi) Figueiredo Gomes
2025-11-12 14:21:13 +01:00
committed by Henri Verbeet
parent d0318ca14b
commit ffe1a433d9
Notes: Henri Verbeet 2025-12-09 17:21:49 +01:00
Approved-by: Francisco Casas (@fcasas)
Approved-by: Nikolay Sivov (@nsivov)
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1340

View File

@@ -5610,13 +5610,13 @@ static struct hlsl_block *add_shader_compilation(struct hlsl_ctx *ctx, const cha
{ {
struct hlsl_ir_node *compile, *call_to_compile = NULL; struct hlsl_ir_node *compile, *call_to_compile = NULL;
struct hlsl_ir_function_decl *decl; struct hlsl_ir_function_decl *decl;
struct hlsl_block *block = NULL;
if (!ctx->in_state_block && ctx->cur_scope != ctx->globals) if (!ctx->in_state_block && ctx->cur_scope != ctx->globals)
{ {
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_MISPLACED_COMPILE, hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_MISPLACED_COMPILE,
"Shader compilation statements must be in global scope or a state block."); "Shader compilation statements must be in global scope or a state block.");
free_parse_initializer(args); goto out;
return NULL;
} }
if (!(decl = find_function_call(ctx, function_name, args, true, loc))) if (!(decl = find_function_call(ctx, function_name, args, true, loc)))
@@ -5632,8 +5632,7 @@ static struct hlsl_block *add_shader_compilation(struct hlsl_ctx *ctx, const cha
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED,
"Function \"%s\" is not defined.", function_name); "Function \"%s\" is not defined.", function_name);
} }
free_parse_initializer(args); goto out;
return NULL;
} }
for (unsigned int i = 0; i < args->args_count; ++i) for (unsigned int i = 0; i < args->args_count; ++i)
@@ -5647,20 +5646,17 @@ static struct hlsl_block *add_shader_compilation(struct hlsl_ctx *ctx, const cha
} }
if (!(call_to_compile = add_user_call(ctx, decl, args, true, loc))) if (!(call_to_compile = add_user_call(ctx, decl, args, true, loc)))
{ goto out;
free_parse_initializer(args);
return NULL;
}
if (!(compile = hlsl_new_compile(ctx, HLSL_COMPILE_TYPE_COMPILE, if (!(compile = hlsl_new_compile(ctx, HLSL_COMPILE_TYPE_COMPILE,
profile_name, &call_to_compile, 1, args->instrs, loc))) profile_name, &call_to_compile, 1, args->instrs, loc)))
{ goto out;
free_parse_initializer(args);
return NULL;
}
block = make_block(ctx, compile);
out:
free_parse_initializer(args); free_parse_initializer(args);
return make_block(ctx, compile); return block;
} }
static struct hlsl_block *add_constructor(struct hlsl_ctx *ctx, struct hlsl_type *type, static struct hlsl_block *add_constructor(struct hlsl_ctx *ctx, struct hlsl_type *type,