From: Zebediah Figura Subject: [PATCH 6/6] d3dcompiler: Prepend static global initializers to the entry function's body. Message-Id: <20200611214422.275678-6-zfigura@codeweavers.com> Date: Thu, 11 Jun 2020 16:44:22 -0500 In-Reply-To: <20200611214422.275678-1-zfigura@codeweavers.com> References: <20200611214422.275678-1-zfigura@codeweavers.com> Signed-off-by: Zebediah Figura --- dlls/d3dcompiler_43/hlsl.y | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 734289f66a5..c651fb9d7fa 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -3005,6 +3005,21 @@ HRESULT parse_hlsl(enum shader_type type, DWORD major, DWORD minor, "entry point \"%s\" is missing a return value semantic", entry_func->func->name); } + /* Walk through the list in reverse, so that initializers are added in the + * order that they were declared. */ + LIST_FOR_EACH_ENTRY_REV(var, &hlsl_ctx.globals->vars, struct hlsl_ir_var, scope_entry) + { + if (var->modifiers & HLSL_STORAGE_STATIC) + { + if (!add_assignment_to_initializer(var)) + { + hlsl_ctx.status = PARSE_ERR; + hr = E_OUTOFMEMORY; + } + list_move_head(entry_func->body, &var->initializer); + } + } + /* Index 0 means unused; index 1 means function entry, so start at 2. */ index_instructions(entry_func->body, 2); -- 2.27.0