Module: vkd3d Branch: master Commit: 7c360330d74f5c2f6de962355927ee6e7d7dfbf0 URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/7c360330d74f5c2f6de962355927ee...
Author: Giovanni Mascellani gmascellani@codeweavers.com Date: Fri May 26 14:40:30 2023 +0200
vkd3d-shader/tpf: Do not emit HLSL_IR_CONSTANT instructions.
Since constants are now inlined.
---
libs/vkd3d-shader/hlsl_codegen.c | 4 ++++ libs/vkd3d-shader/tpf.c | 29 +++++++---------------------- 2 files changed, 11 insertions(+), 22 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index a9ef7f2d..2b6c595a 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -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) { + /* 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) { instr->reg = allocate_numeric_registers_for_type(ctx, allocator, instr->index, instr->last_read, diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index de4e9bc7..60948d64 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -4003,24 +4003,6 @@ static void write_sm4_binary_op_with_two_destinations(struct vkd3d_bytecode_buff 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, const struct hlsl_type *resource_type, const struct hlsl_ir_node *dst, 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); + + if (!instr->reg.allocated) + { + assert(instr->type == HLSL_IR_CONSTANT); + continue; + } }
switch (instr->type) { case HLSL_IR_CALL: - vkd3d_unreachable(); - case HLSL_IR_CONSTANT: - write_sm4_constant(ctx, buffer, hlsl_ir_constant(instr)); - break; + vkd3d_unreachable();
case HLSL_IR_EXPR: write_sm4_expr(ctx, buffer, hlsl_ir_expr(instr));