Skip to content
Snippets Groups Projects
Commit 28d267b7 authored by Francisco Casas's avatar Francisco Casas Committed by Alexandre Julliard
Browse files

vkd3d-shader/hlsl: Allocate SM1 numeric uniforms in decreasing bind count.

parent e7450ce5
No related branches found
No related tags found
1 merge request!851tests: Fix SM1 constant register allocation for numerics.
......@@ -4553,11 +4553,47 @@ static void allocate_const_registers_recurse(struct hlsl_ctx *ctx,
}
}
static void sort_uniform_by_numeric_bind_count(struct list *sorted, struct hlsl_ir_var *to_sort)
{
struct hlsl_ir_var *var;
list_remove(&to_sort->extern_entry);
LIST_FOR_EACH_ENTRY(var, sorted, struct hlsl_ir_var, extern_entry)
{
uint32_t to_sort_size = to_sort->bind_count[HLSL_REGSET_NUMERIC];
uint32_t var_size = var->bind_count[HLSL_REGSET_NUMERIC];
if (to_sort_size > var_size)
{
list_add_before(&var->extern_entry, &to_sort->extern_entry);
return;
}
}
list_add_tail(sorted, &to_sort->extern_entry);
}
static void sort_uniforms_by_numeric_bind_count(struct hlsl_ctx *ctx)
{
struct list sorted = LIST_INIT(sorted);
struct hlsl_ir_var *var, *next;
LIST_FOR_EACH_ENTRY_SAFE(var, next, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
{
if (var->is_uniform)
sort_uniform_by_numeric_bind_count(&sorted, var);
}
list_move_tail(&ctx->extern_vars, &sorted);
}
static void allocate_const_registers(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func)
{
struct register_allocator allocator = {0};
struct hlsl_ir_var *var;
sort_uniforms_by_numeric_bind_count(ctx);
LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
{
unsigned int reg_size = var->data_type->reg_size[HLSL_REGSET_NUMERIC];
......
......@@ -50,7 +50,7 @@ uniform 0 float4 1 2 3 4
uniform 4 float4 11 12 13 14
uniform 8 float4 21 22 23 24
draw quad
todo probe all rgba (21, 22, 23, 11)
probe all rgba (21, 22, 23, 11)
[pixel shader]
......@@ -76,7 +76,7 @@ uniform 8 float4 21 22 23 24
uniform 12 float4 31 32 33 34
uniform 16 float4 41 42 43 44
draw quad
todo probe all rgba (41, 21, 0, 0)
probe all rgba (41, 21, 0, 0)
[pixel shader]
......@@ -224,7 +224,7 @@ uniform 20 float4 51 52 53 54
uniform 24 float4 61 62 63 64
uniform 28 float4 71 72 73 74
draw quad
todo probe all rgba (74, 31, 63, 0)
probe all rgba (74, 31, 63, 0)
[pixel shader]
......@@ -253,7 +253,7 @@ uniform 0 float4 1 2 3 4
uniform 4 float4 11 12 13 14
uniform 8 float4 21 22 23 24
draw quad
todo probe all rgba (21, 22, 1, 11)
probe all rgba (21, 22, 1, 11)
[pixel shader]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment