mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/hlsl: Parse function attributes.
This commit is contained in:
committed by
Alexandre Julliard
parent
da56f41ceb
commit
d6799bd5d3
Notes:
Alexandre Julliard
2022-11-08 23:05:16 +01:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/43
@@ -1180,7 +1180,7 @@ struct hlsl_ir_loop *hlsl_new_loop(struct hlsl_ctx *ctx, struct vkd3d_shader_loc
|
||||
}
|
||||
|
||||
struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hlsl_type *return_type,
|
||||
struct list *parameters, const struct hlsl_semantic *semantic, struct vkd3d_shader_location loc)
|
||||
struct list *parameters, const struct hlsl_semantic *semantic, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
struct hlsl_ir_function_decl *decl;
|
||||
|
||||
@@ -1189,11 +1189,11 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hl
|
||||
list_init(&decl->body.instrs);
|
||||
decl->return_type = return_type;
|
||||
decl->parameters = parameters;
|
||||
decl->loc = loc;
|
||||
decl->loc = *loc;
|
||||
|
||||
if (!hlsl_types_are_equal(return_type, ctx->builtin_types.Void))
|
||||
{
|
||||
if (!(decl->return_var = hlsl_new_synthetic_var(ctx, "retval", return_type, &loc)))
|
||||
if (!(decl->return_var = hlsl_new_synthetic_var(ctx, "retval", return_type, loc)))
|
||||
{
|
||||
vkd3d_free(decl);
|
||||
return NULL;
|
||||
@@ -2086,8 +2086,25 @@ void hlsl_free_instr(struct hlsl_ir_node *node)
|
||||
}
|
||||
}
|
||||
|
||||
void hlsl_free_attribute(struct hlsl_attribute *attr)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < attr->args_count; ++i)
|
||||
hlsl_src_remove(&attr->args[i]);
|
||||
hlsl_free_instr_list(&attr->instrs);
|
||||
vkd3d_free((void *)attr->name);
|
||||
vkd3d_free(attr);
|
||||
}
|
||||
|
||||
static void free_function_decl(struct hlsl_ir_function_decl *decl)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < decl->attr_count; ++i)
|
||||
hlsl_free_attribute((void *)decl->attrs[i]);
|
||||
vkd3d_free((void *)decl->attrs);
|
||||
|
||||
vkd3d_free(decl->parameters);
|
||||
hlsl_free_instr_list(&decl->body.instrs);
|
||||
vkd3d_free(decl);
|
||||
@@ -2135,6 +2152,7 @@ void hlsl_add_function(struct hlsl_ctx *ctx, char *name, struct hlsl_ir_function
|
||||
{
|
||||
struct hlsl_ir_function_decl *old_decl =
|
||||
RB_ENTRY_VALUE(old_entry, struct hlsl_ir_function_decl, entry);
|
||||
unsigned int i;
|
||||
|
||||
if (!decl->has_body)
|
||||
{
|
||||
@@ -2142,6 +2160,15 @@ void hlsl_add_function(struct hlsl_ctx *ctx, char *name, struct hlsl_ir_function
|
||||
vkd3d_free(name);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < decl->attr_count; ++i)
|
||||
hlsl_free_attribute((void *)decl->attrs[i]);
|
||||
vkd3d_free((void *)decl->attrs);
|
||||
decl->attr_count = old_decl->attr_count;
|
||||
decl->attrs = old_decl->attrs;
|
||||
old_decl->attr_count = 0;
|
||||
old_decl->attrs = NULL;
|
||||
|
||||
rb_remove(&func->overloads, old_entry);
|
||||
free_function_decl(old_decl);
|
||||
}
|
||||
|
Reference in New Issue
Block a user