vkd3d-shader/hlsl: Write the SM4 dcl_temps instruction.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-08-19 18:44:30 -05:00 committed by Alexandre Julliard
parent 62456beeda
commit 40ec063a26
3 changed files with 21 additions and 0 deletions

View File

@ -469,6 +469,7 @@ struct hlsl_ctx
struct hlsl_vec4 *values;
size_t count, size;
} constant_defs;
uint32_t temp_count;
};
enum hlsl_error_level

View File

@ -685,6 +685,7 @@ static void compute_liveness(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl
struct liveness
{
size_t size;
uint32_t reg_count;
struct
{
/* 0 if not live yet. */
@ -747,6 +748,7 @@ static struct hlsl_reg allocate_register(struct hlsl_ctx *ctx, struct liveness *
ret.id = component_idx / 4;
ret.writemask = writemask;
ret.allocated = true;
liveness->reg_count = max(liveness->reg_count, ret.id + 1);
return ret;
}
@ -782,6 +784,7 @@ static struct hlsl_reg allocate_range(struct hlsl_ctx *ctx, struct liveness *liv
liveness->regs[component_idx + i].last_read = last_read;
ret.id = component_idx / 4;
ret.allocated = true;
liveness->reg_count = max(liveness->reg_count, ret.id + align(component_count, 4));
return ret;
}
@ -1008,6 +1011,7 @@ static void allocate_temp_registers(struct hlsl_ctx *ctx, struct hlsl_ir_functio
{
struct liveness liveness = {0};
allocate_temp_registers_recurse(ctx, entry_func->body, &liveness);
ctx->temp_count = liveness.reg_count;
}
static void allocate_semantic_register(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, unsigned int *counter, bool output)

View File

@ -762,6 +762,19 @@ static void write_sm4_dcl_semantic(struct hlsl_ctx *ctx, struct vkd3d_bytecode_b
write_sm4_instruction(buffer, &instr);
}
static void write_sm4_dcl_temps(struct vkd3d_bytecode_buffer *buffer, uint32_t temp_count)
{
struct sm4_instruction instr =
{
.opcode = VKD3D_SM4_OP_DCL_TEMPS,
.idx = {temp_count},
.idx_count = 1,
};
write_sm4_instruction(buffer, &instr);
}
static void write_sm4_shdr(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc)
{
const struct hlsl_profile_info *profile = ctx->profile;
@ -797,6 +810,9 @@ static void write_sm4_shdr(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc)
write_sm4_dcl_semantic(ctx, &buffer, var);
}
if (ctx->temp_count)
write_sm4_dcl_temps(&buffer, ctx->temp_count);
dxbc_writer_add_section(dxbc, TAG_SHDR, buffer.data, buffer.size);
}