vkd3d-shader/hlsl: Map the colour output for ps_1_* to r0.

This commit is contained in:
Zebediah Figura 2023-04-05 16:18:25 -05:00 committed by Alexandre Julliard
parent b2959739ed
commit 8b57a612d7
Notes: Alexandre Julliard 2023-05-03 22:38:49 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/168
2 changed files with 28 additions and 1 deletions

View File

@ -1832,7 +1832,12 @@ static void write_sm1_store(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *
if (store->lhs.var->is_output_semantic)
{
if (!hlsl_sm1_register_from_semantic(ctx, &store->lhs.var->semantic,
if (ctx->profile->type == VKD3D_SHADER_TYPE_PIXEL && ctx->profile->major_version == 1)
{
sm1_instr.dst.type = D3DSPR_TEMP;
sm1_instr.dst.reg = 0;
}
else if (!hlsl_sm1_register_from_semantic(ctx, &store->lhs.var->semantic,
true, &sm1_instr.dst.type, &sm1_instr.dst.reg))
{
assert(reg.allocated);

View File

@ -3098,6 +3098,24 @@ static void allocate_const_registers(struct hlsl_ctx *ctx, struct hlsl_ir_functi
static void allocate_temp_registers(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func)
{
struct register_allocator allocator = {0};
/* ps_1_* outputs are special and go in temp register 0. */
if (ctx->profile->major_version == 1 && ctx->profile->type == VKD3D_SHADER_TYPE_PIXEL)
{
size_t i;
for (i = 0; i < entry_func->parameters.count; ++i)
{
const struct hlsl_ir_var *var = entry_func->parameters.vars[i];
if (var->is_output_semantic)
{
record_allocation(ctx, &allocator, 0, VKD3DSP_WRITEMASK_ALL, var->first_write, var->last_read);
break;
}
}
}
allocate_temp_registers_recurse(ctx, &entry_func->body, &allocator);
ctx->temp_count = allocator.max_reg + 1;
vkd3d_free(allocator.allocations);
@ -3126,6 +3144,10 @@ static void allocate_semantic_register(struct hlsl_ctx *ctx, struct hlsl_ir_var
D3DDECLUSAGE usage;
uint32_t usage_idx;
/* ps_1_* outputs are special and go in temp register 0. */
if (ctx->profile->major_version == 1 && output && ctx->profile->type == VKD3D_SHADER_TYPE_PIXEL)
return;
builtin = hlsl_sm1_register_from_semantic(ctx, &var->semantic, output, &type, &reg);
if (!builtin && !hlsl_sm1_usage_from_semantic(&var->semantic, &usage, &usage_idx))
{