vkd3d-shader/tpf: Do not emit HLSL_IR_CONSTANT instructions.

Since constants are now inlined.
This commit is contained in:
Giovanni Mascellani 2023-05-26 14:40:30 +02:00 committed by Alexandre Julliard
parent a471c5567a
commit 7c360330d7
Notes: Alexandre Julliard 2023-05-29 22:32:48 +02:00
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/215
2 changed files with 11 additions and 22 deletions

View File

@ -3004,6 +3004,10 @@ static void allocate_temp_registers_recurse(struct hlsl_ctx *ctx,
LIST_FOR_EACH_ENTRY(instr, &block->instrs, struct hlsl_ir_node, entry) LIST_FOR_EACH_ENTRY(instr, &block->instrs, struct hlsl_ir_node, entry)
{ {
/* In SM4 all constants are inlined. */
if (ctx->profile->major_version >= 4 && instr->type == HLSL_IR_CONSTANT)
continue;
if (!instr->reg.allocated && instr->last_read) if (!instr->reg.allocated && instr->last_read)
{ {
instr->reg = allocate_numeric_registers_for_type(ctx, allocator, instr->index, instr->last_read, instr->reg = allocate_numeric_registers_for_type(ctx, allocator, instr->index, instr->last_read,

View File

@ -4003,24 +4003,6 @@ static void write_sm4_binary_op_with_two_destinations(struct vkd3d_bytecode_buff
write_sm4_instruction(buffer, &instr); write_sm4_instruction(buffer, &instr);
} }
static void write_sm4_constant(struct hlsl_ctx *ctx,
struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_constant *constant)
{
const unsigned int dimx = constant->node.data_type->dimx;
struct sm4_instruction instr;
memset(&instr, 0, sizeof(instr));
instr.opcode = VKD3D_SM4_OP_MOV;
sm4_dst_from_node(&instr.dsts[0], &constant->node);
instr.dst_count = 1;
sm4_src_from_constant_value(&instr.srcs[0], &constant->value, dimx, instr.dsts[0].writemask);
instr.src_count = 1;
write_sm4_instruction(buffer, &instr);
}
static void write_sm4_ld(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, static void write_sm4_ld(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer,
const struct hlsl_type *resource_type, const struct hlsl_ir_node *dst, const struct hlsl_type *resource_type, const struct hlsl_ir_node *dst,
const struct hlsl_deref *resource, const struct hlsl_ir_node *coords, const struct hlsl_deref *resource, const struct hlsl_ir_node *coords,
@ -5097,16 +5079,19 @@ static void write_sm4_block(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *
} }
assert(instr->data_type->class == HLSL_CLASS_SCALAR || instr->data_type->class == HLSL_CLASS_VECTOR); assert(instr->data_type->class == HLSL_CLASS_SCALAR || instr->data_type->class == HLSL_CLASS_VECTOR);
if (!instr->reg.allocated)
{
assert(instr->type == HLSL_IR_CONSTANT);
continue;
}
} }
switch (instr->type) switch (instr->type)
{ {
case HLSL_IR_CALL: case HLSL_IR_CALL:
vkd3d_unreachable();
case HLSL_IR_CONSTANT: case HLSL_IR_CONSTANT:
write_sm4_constant(ctx, buffer, hlsl_ir_constant(instr)); vkd3d_unreachable();
break;
case HLSL_IR_EXPR: case HLSL_IR_EXPR:
write_sm4_expr(ctx, buffer, hlsl_ir_expr(instr)); write_sm4_expr(ctx, buffer, hlsl_ir_expr(instr));