mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-09-13 09:16:14 -07:00
vkd3d-shader/hlsl: Allocate register spaces for constant buffers.
This commit is contained in:
parent
28a5e23814
commit
7b61b0219e
Notes:
Henri Verbeet
2024-06-11 17:09:29 +02:00
Approved-by: Francisco Casas (@fcasas) Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/865
@ -271,6 +271,8 @@ struct hlsl_reg
|
||||
* ignored.
|
||||
* For numeric registers "index" is not used. */
|
||||
uint32_t index;
|
||||
/* Register space of a descriptor. Not used for numeric registers. */
|
||||
uint32_t space;
|
||||
/* Number of registers to be allocated.
|
||||
* Unlike the variable's type's regsize, it is not expressed in register components, but rather
|
||||
* in whole registers, and may depend on which components are used within the shader. */
|
||||
|
@ -4767,13 +4767,14 @@ static void allocate_semantic_registers(struct hlsl_ctx *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
static const struct hlsl_buffer *get_reserved_buffer(struct hlsl_ctx *ctx, uint32_t index)
|
||||
static const struct hlsl_buffer *get_reserved_buffer(struct hlsl_ctx *ctx, uint32_t space, uint32_t index)
|
||||
{
|
||||
const struct hlsl_buffer *buffer;
|
||||
|
||||
LIST_FOR_EACH_ENTRY(buffer, &ctx->buffers, const struct hlsl_buffer, entry)
|
||||
{
|
||||
if (buffer->used_size && buffer->reservation.reg_type == 'b' && buffer->reservation.reg_index == index)
|
||||
if (buffer->used_size && buffer->reservation.reg_type == 'b'
|
||||
&& buffer->reservation.reg_space == space && buffer->reservation.reg_index == index)
|
||||
return buffer;
|
||||
}
|
||||
return NULL;
|
||||
@ -4943,33 +4944,40 @@ static void allocate_buffers(struct hlsl_ctx *ctx)
|
||||
|
||||
if (buffer->type == HLSL_BUFFER_CONSTANT)
|
||||
{
|
||||
if (buffer->reservation.reg_type == 'b')
|
||||
const struct hlsl_reg_reservation *reservation = &buffer->reservation;
|
||||
|
||||
if (reservation->reg_type == 'b')
|
||||
{
|
||||
const struct hlsl_buffer *reserved_buffer = get_reserved_buffer(ctx, buffer->reservation.reg_index);
|
||||
const struct hlsl_buffer *reserved_buffer = get_reserved_buffer(ctx,
|
||||
reservation->reg_space, reservation->reg_index);
|
||||
|
||||
if (reserved_buffer && reserved_buffer != buffer)
|
||||
{
|
||||
hlsl_error(ctx, &buffer->loc, VKD3D_SHADER_ERROR_HLSL_OVERLAPPING_RESERVATIONS,
|
||||
"Multiple buffers bound to index %u.", buffer->reservation.reg_index);
|
||||
"Multiple buffers bound to space %u, index %u.",
|
||||
reservation->reg_space, reservation->reg_index);
|
||||
hlsl_note(ctx, &reserved_buffer->loc, VKD3D_SHADER_LOG_ERROR,
|
||||
"Buffer %s is already bound to index %u.",
|
||||
reserved_buffer->name, buffer->reservation.reg_index);
|
||||
"Buffer %s is already bound to space %u, index %u.",
|
||||
reserved_buffer->name, reservation->reg_space, reservation->reg_index);
|
||||
}
|
||||
|
||||
buffer->reg.index = buffer->reservation.reg_index;
|
||||
buffer->reg.space = reservation->reg_space;
|
||||
buffer->reg.index = reservation->reg_index;
|
||||
if (hlsl_version_ge(ctx, 5, 1))
|
||||
buffer->reg.id = id++;
|
||||
else
|
||||
buffer->reg.id = buffer->reg.index;
|
||||
buffer->reg.allocation_size = 1;
|
||||
buffer->reg.allocated = true;
|
||||
TRACE("Allocated reserved %s to index %u, id %u.\n", buffer->name, buffer->reg.index, buffer->reg.id);
|
||||
TRACE("Allocated reserved %s to space %u, index %u, id %u.\n",
|
||||
buffer->name, buffer->reg.space, buffer->reg.index, buffer->reg.id);
|
||||
}
|
||||
else if (!buffer->reservation.reg_type)
|
||||
else if (!reservation->reg_type)
|
||||
{
|
||||
while (get_reserved_buffer(ctx, index))
|
||||
while (get_reserved_buffer(ctx, 0, index))
|
||||
++index;
|
||||
|
||||
buffer->reg.space = 0;
|
||||
buffer->reg.index = index;
|
||||
if (hlsl_version_ge(ctx, 5, 1))
|
||||
buffer->reg.id = id++;
|
||||
@ -4977,7 +4985,7 @@ static void allocate_buffers(struct hlsl_ctx *ctx)
|
||||
buffer->reg.id = buffer->reg.index;
|
||||
buffer->reg.allocation_size = 1;
|
||||
buffer->reg.allocated = true;
|
||||
TRACE("Allocated %s to index %u, id %u.\n", buffer->name, buffer->reg.index, buffer->reg.id);
|
||||
TRACE("Allocated %s to space 0, index %u, id %u.\n", buffer->name, buffer->reg.index, buffer->reg.id);
|
||||
++index;
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user