vkd3d-shader/hlsl: Use reg_size as component count when allocating a single register.

Otherwise, for instance, the added test results in:

debug_hlsl_writemask: Assertion `!(writemask & ~VKD3DSP_WRITEMASK_ALL)' failed.

Which happens in allocate_variable_temp_register() when the variable's
type reg_size is <= 4 but its component count is larger, which may
happen if it contains objects.
This commit is contained in:
Francisco Casas 2022-10-31 12:35:16 -03:00 committed by Alexandre Julliard
parent 90e6e418a3
commit f21693b284
Notes: Alexandre Julliard 2022-11-10 22:56:31 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Zebediah Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/42
2 changed files with 29 additions and 4 deletions

View File

@ -1927,7 +1927,7 @@ static void allocate_variable_temp_register(struct hlsl_ctx *ctx, struct hlsl_ir
var->last_read, var->data_type->reg_size);
else
var->reg = allocate_register(ctx, liveness, var->first_write,
var->last_read, hlsl_type_component_count(var->data_type));
var->last_read, var->data_type->reg_size);
TRACE("Allocated %s to %s (liveness %u-%u).\n", var->name,
debug_register('r', var->reg, var->data_type), var->first_write, var->last_read);
}
@ -1946,7 +1946,7 @@ static void allocate_temp_registers_recurse(struct hlsl_ctx *ctx, struct hlsl_bl
instr->last_read, instr->data_type->reg_size);
else
instr->reg = allocate_register(ctx, liveness, instr->index,
instr->last_read, instr->data_type->dimx);
instr->last_read, instr->data_type->reg_size);
TRACE("Allocated anonymous expression @%u to %s (liveness %u-%u).\n", instr->index,
debug_register('r', instr->reg, instr->data_type), instr->index, instr->last_read);
}
@ -2009,7 +2009,7 @@ static void allocate_const_registers_recurse(struct hlsl_ctx *ctx, struct hlsl_b
if (reg_size > 4)
constant->reg = allocate_range(ctx, liveness, 1, UINT_MAX, reg_size);
else
constant->reg = allocate_register(ctx, liveness, 1, UINT_MAX, type->dimx);
constant->reg = allocate_register(ctx, liveness, 1, UINT_MAX, reg_size);
TRACE("Allocated constant @%u to %s.\n", instr->index, debug_register('c', constant->reg, type));
if (!hlsl_array_reserve(ctx, (void **)&defs->values, &defs->size,
@ -2111,7 +2111,7 @@ static void allocate_const_registers(struct hlsl_ctx *ctx, struct hlsl_ir_functi
else
{
var->reg = allocate_register(ctx, &liveness, 1, UINT_MAX, 4);
var->reg.writemask = (1u << var->data_type->dimx) - 1;
var->reg.writemask = (1u << var->data_type->reg_size) - 1;
}
TRACE("Allocated %s to %s.\n", var->name, debug_register('c', var->reg, var->data_type));
}

View File

@ -118,3 +118,28 @@ float4 main() : sv_target
{
return tex[n].Load(0);
}
[pixel shader todo]
Texture2D tex;
uniform float f;
struct apple
{
Texture2D tex1;
Texture2D tex2;
float3 aa;
};
float4 main() : sv_target
{
struct apple a = {tex, tex, 1.0, 2.0, 3.0};
a.aa += f;
return a.aa.xyzx;
}
[test]
uniform 0 float 10.0
todo draw quad
todo probe (0, 0) rgba (11.0, 12.0, 13.0, 11.0)