mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-09-13 09:16:14 -07:00
vkd3d-shader/hlsl: Only error out on bind_count register reservation overlaps for SM1.
While on SM1 a register reservation reserves the whole size in registers of the variable's data type, overlapping conflicts are only checked up to the bind_count (used size) for each variable.
This commit is contained in:
parent
2179c79c91
commit
597e55691a
Notes:
Henri Verbeet
2024-07-08 18:19:36 +02:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/912
@ -4599,6 +4599,7 @@ static void sort_uniforms_by_numeric_bind_count(struct hlsl_ctx *ctx)
|
||||
|
||||
static void allocate_const_registers(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func)
|
||||
{
|
||||
struct register_allocator allocator_used = {0};
|
||||
struct register_allocator allocator = {0};
|
||||
struct hlsl_ir_var *var;
|
||||
|
||||
@ -4607,6 +4608,7 @@ static void allocate_const_registers(struct hlsl_ctx *ctx, struct hlsl_ir_functi
|
||||
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];
|
||||
unsigned int bind_count = var->bind_count[HLSL_REGSET_NUMERIC];
|
||||
|
||||
if (!var->is_uniform || reg_size == 0)
|
||||
continue;
|
||||
@ -4619,12 +4621,15 @@ static void allocate_const_registers(struct hlsl_ctx *ctx, struct hlsl_ir_functi
|
||||
assert(reg_size % 4 == 0);
|
||||
for (i = 0; i < reg_size / 4; ++i)
|
||||
{
|
||||
if (get_available_writemask(&allocator, 1, UINT_MAX, reg_idx + i) != VKD3DSP_WRITEMASK_ALL)
|
||||
if (i < bind_count)
|
||||
{
|
||||
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION,
|
||||
"Overlapping register() reservations on 'c%u'.", reg_idx + i);
|
||||
if (get_available_writemask(&allocator_used, 1, UINT_MAX, reg_idx + i) != VKD3DSP_WRITEMASK_ALL)
|
||||
{
|
||||
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION,
|
||||
"Overlapping register() reservations on 'c%u'.", reg_idx + i);
|
||||
}
|
||||
record_allocation(ctx, &allocator_used, reg_idx + i, VKD3DSP_WRITEMASK_ALL, 1, UINT_MAX);
|
||||
}
|
||||
|
||||
record_allocation(ctx, &allocator, reg_idx + i, VKD3DSP_WRITEMASK_ALL, 1, UINT_MAX);
|
||||
}
|
||||
|
||||
@ -4637,6 +4642,8 @@ static void allocate_const_registers(struct hlsl_ctx *ctx, struct hlsl_ir_functi
|
||||
}
|
||||
}
|
||||
|
||||
vkd3d_free(allocator_used.allocations);
|
||||
|
||||
LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
|
||||
{
|
||||
unsigned int alloc_size = 4 * var->bind_count[HLSL_REGSET_NUMERIC];
|
||||
|
@ -10,7 +10,7 @@ float4 main() : sv_target
|
||||
}
|
||||
|
||||
|
||||
[pixel shader todo(sm<4)]
|
||||
[pixel shader]
|
||||
// Overlapping reservations when both variables are unused.
|
||||
float4 a : register(c3);
|
||||
float4 b : register(c3);
|
||||
@ -20,7 +20,7 @@ float4 main() : sv_target
|
||||
return 42;
|
||||
}
|
||||
|
||||
[pixel shader fail(sm>=4 & sm<6) todo(sm<4)]
|
||||
[pixel shader fail(sm>=4 & sm<6)]
|
||||
// Overlapping reservations when only one variable is used.
|
||||
float4 a : register(c3);
|
||||
float4 b : register(c3);
|
||||
@ -31,7 +31,7 @@ float4 main() : sv_target
|
||||
}
|
||||
|
||||
|
||||
[pixel shader fail(sm>=4 & sm<6) todo(sm<4)]
|
||||
[pixel shader fail(sm>=4 & sm<6)]
|
||||
// Overlapping reservations when both variables are used, but their bind_count (used size) doesn't
|
||||
// cause an overlap.
|
||||
float4 a[2] : register(c3); // bind count: 1
|
||||
|
Loading…
Reference in New Issue
Block a user