d3dcompiler: Prepend static initializers to the function body.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
cc1c4759ba
commit
142be50629
|
@ -979,6 +979,8 @@ struct hlsl_parse_ctx
|
|||
struct hlsl_type *sampler[HLSL_SAMPLER_DIM_MAX + 1];
|
||||
struct hlsl_type *Void;
|
||||
} builtin_types;
|
||||
|
||||
struct list static_initializers;
|
||||
};
|
||||
|
||||
extern struct hlsl_parse_ctx hlsl_ctx DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -888,14 +888,17 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers,
|
|||
continue;
|
||||
}
|
||||
|
||||
list_move_tail(statements_list, v->initializer.instrs);
|
||||
d3dcompiler_free(v->initializer.instrs);
|
||||
|
||||
load = new_var_load(var, var->loc);
|
||||
list_add_tail(statements_list, &load->node.entry);
|
||||
list_add_tail(v->initializer.instrs, &load->node.entry);
|
||||
assignment = make_assignment(&load->node, ASSIGN_OP_ASSIGN, v->initializer.args[0]);
|
||||
d3dcompiler_free(v->initializer.args);
|
||||
list_add_tail(statements_list, &assignment->entry);
|
||||
list_add_tail(v->initializer.instrs, &assignment->entry);
|
||||
|
||||
if (modifiers & HLSL_STORAGE_STATIC)
|
||||
list_move_tail(&hlsl_ctx.static_initializers, v->initializer.instrs);
|
||||
else
|
||||
list_move_tail(statements_list, v->initializer.instrs);
|
||||
d3dcompiler_free(v->initializer.instrs);
|
||||
}
|
||||
d3dcompiler_free(v);
|
||||
}
|
||||
|
@ -1514,6 +1517,10 @@ hlsl_prog: /* empty */
|
|||
| hlsl_prog declaration_statement
|
||||
{
|
||||
TRACE("Declaration statement parsed.\n");
|
||||
|
||||
if (!list_empty($2))
|
||||
FIXME("Uniform initializer.\n");
|
||||
free_instr_list($2);
|
||||
}
|
||||
| hlsl_prog preproc_directive
|
||||
{
|
||||
|
@ -2961,6 +2968,7 @@ HRESULT parse_hlsl(enum shader_type type, DWORD major, DWORD minor,
|
|||
list_init(&hlsl_ctx.scopes);
|
||||
list_init(&hlsl_ctx.types);
|
||||
init_functions_tree(&hlsl_ctx.functions);
|
||||
list_init(&hlsl_ctx.static_initializers);
|
||||
|
||||
push_scope(&hlsl_ctx);
|
||||
hlsl_ctx.globals = hlsl_ctx.cur_scope;
|
||||
|
@ -2984,6 +2992,8 @@ HRESULT parse_hlsl(enum shader_type type, DWORD major, DWORD minor,
|
|||
"entry point \"%s\" is missing a return value semantic", entry_func->func->name);
|
||||
}
|
||||
|
||||
list_move_head(entry_func->body, &hlsl_ctx.static_initializers);
|
||||
|
||||
/* Index 0 means unused; index 1 means function entry, so start at 2. */
|
||||
index_instructions(entry_func->body, 2);
|
||||
|
||||
|
|
Loading…
Reference in New Issue