Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl_codegen.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 505a77e7..611cd7d7 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -839,9 +839,25 @@ static void allocate_const_registers_recurse(struct list *instrs, struct livenes } }
-static void allocate_const_registers(struct hlsl_ir_function_decl *entry_func) +static void allocate_const_registers(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func) { struct liveness liveness = {0}; + struct hlsl_ir_var *var; + + LIST_FOR_EACH_ENTRY(var, &ctx->globals->vars, struct hlsl_ir_var, scope_entry) + { + if (var->is_uniform && var->last_read) + { + if (var->data_type->reg_size > 1) + var->reg = allocate_range(&liveness, 1, INT_MAX, var->data_type->reg_size); + else + { + var->reg = allocate_register(&liveness, 1, INT_MAX, 4); + var->reg.writemask = (1 << var->data_type->dimx) - 1; + } + TRACE("Allocated %s to %s.\n", debug_register('c', var->reg, var->data_type), var->name); + } + }
allocate_const_registers_recurse(entry_func->body, &liveness); } @@ -895,7 +911,7 @@ int hlsl_emit_dxbc(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_fun
allocate_temp_registers(entry_func); if (ctx->major_version < 4) - allocate_const_registers(entry_func); + allocate_const_registers(ctx, entry_func);
if (ctx->failed) return VKD3D_ERROR_INVALID_SHADER;