mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Allocate textures for SM4.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
832e740248
commit
899c2f25e2
@ -1197,6 +1197,64 @@ static void allocate_buffers(struct hlsl_ctx *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
static const struct hlsl_ir_var *get_reserved_texture(struct hlsl_ctx *ctx, uint32_t index)
|
||||
{
|
||||
const struct hlsl_ir_var *var;
|
||||
|
||||
LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, const struct hlsl_ir_var, extern_entry)
|
||||
{
|
||||
if (var->has_resource_access && var->reg_reservation.type == 't' && var->reg_reservation.index == index)
|
||||
return var;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void allocate_textures(struct hlsl_ctx *ctx)
|
||||
{
|
||||
struct hlsl_ir_var *var;
|
||||
uint32_t index = 0;
|
||||
|
||||
LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
|
||||
{
|
||||
if (!var->has_resource_access || var->data_type->type != HLSL_CLASS_OBJECT
|
||||
|| var->data_type->base_type != HLSL_TYPE_TEXTURE)
|
||||
continue;
|
||||
|
||||
if (var->reg_reservation.type == 't')
|
||||
{
|
||||
const struct hlsl_ir_var *reserved_texture = get_reserved_texture(ctx, var->reg_reservation.index);
|
||||
|
||||
if (reserved_texture && reserved_texture != var)
|
||||
{
|
||||
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_OVERLAPPING_RESERVATIONS,
|
||||
"Multiple textures bound to t%u.", var->reg_reservation.index);
|
||||
hlsl_note(ctx, reserved_texture->loc, VKD3D_SHADER_LOG_ERROR,
|
||||
"Texture '%s' is already bound to t%u.", reserved_texture->name,
|
||||
var->reg_reservation.index);
|
||||
}
|
||||
|
||||
var->reg.id = var->reg_reservation.index;
|
||||
var->reg.allocated = true;
|
||||
TRACE("Allocated reserved %s to t%u.\n", var->name, index);
|
||||
}
|
||||
else if (!var->reg_reservation.type)
|
||||
{
|
||||
while (get_reserved_texture(ctx, index))
|
||||
++index;
|
||||
|
||||
var->reg.id = index;
|
||||
var->reg.allocated = true;
|
||||
TRACE("Allocated %s to t%u.\n", var->name, index);
|
||||
++index;
|
||||
}
|
||||
else
|
||||
{
|
||||
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION,
|
||||
"Textures must be bound to register type 't'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool type_is_single_reg(const struct hlsl_type *type)
|
||||
{
|
||||
return type->type == HLSL_CLASS_SCALAR || type->type == HLSL_CLASS_VECTOR;
|
||||
@ -1315,9 +1373,14 @@ int hlsl_emit_dxbc(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_fun
|
||||
|
||||
allocate_temp_registers(ctx, entry_func);
|
||||
if (ctx->profile->major_version < 4)
|
||||
{
|
||||
allocate_const_registers(ctx, entry_func);
|
||||
}
|
||||
else
|
||||
{
|
||||
allocate_buffers(ctx);
|
||||
allocate_textures(ctx);
|
||||
}
|
||||
allocate_semantic_registers(ctx);
|
||||
|
||||
if (ctx->result)
|
||||
|
Loading…
x
Reference in New Issue
Block a user