mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-09-13 09:16:14 -07:00
vkd3d-shader/hlsl: Save hlsl_ir_jump in the vsir_program for SM1.
This commit is contained in:
parent
08fb683784
commit
0c621f9e4e
Notes:
Henri Verbeet
2024-09-12 18:57:08 +02:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1062
@ -2204,6 +2204,7 @@ static void d3dbc_write_vsir_instruction(struct d3dbc_compiler *d3dbc, const str
|
|||||||
case VKD3DSIH_SINCOS:
|
case VKD3DSIH_SINCOS:
|
||||||
case VKD3DSIH_SLT:
|
case VKD3DSIH_SLT:
|
||||||
case VKD3DSIH_TEX:
|
case VKD3DSIH_TEX:
|
||||||
|
case VKD3DSIH_TEXKILL:
|
||||||
case VKD3DSIH_TEXLDD:
|
case VKD3DSIH_TEXLDD:
|
||||||
d3dbc_write_vsir_simple_instruction(d3dbc, ins);
|
d3dbc_write_vsir_simple_instruction(d3dbc, ins);
|
||||||
break;
|
break;
|
||||||
@ -2340,35 +2341,6 @@ static void d3dbc_write_if(struct d3dbc_compiler *d3dbc, const struct hlsl_ir_no
|
|||||||
d3dbc_write_instruction(d3dbc, &sm1_endif);
|
d3dbc_write_instruction(d3dbc, &sm1_endif);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void d3dbc_write_jump(struct d3dbc_compiler *d3dbc, const struct hlsl_ir_node *instr)
|
|
||||||
{
|
|
||||||
const struct hlsl_ir_jump *jump = hlsl_ir_jump(instr);
|
|
||||||
|
|
||||||
switch (jump->type)
|
|
||||||
{
|
|
||||||
case HLSL_IR_JUMP_DISCARD_NEG:
|
|
||||||
{
|
|
||||||
struct hlsl_reg *reg = &jump->condition.node->reg;
|
|
||||||
|
|
||||||
struct sm1_instruction sm1_instr =
|
|
||||||
{
|
|
||||||
.opcode = VKD3D_SM1_OP_TEXKILL,
|
|
||||||
|
|
||||||
.dst.type = VKD3DSPR_TEMP,
|
|
||||||
.dst.reg = reg->id,
|
|
||||||
.dst.writemask = reg->writemask,
|
|
||||||
.has_dst = 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
d3dbc_write_instruction(d3dbc, &sm1_instr);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
hlsl_fixme(d3dbc->ctx, &jump->node.loc, "Jump type %s.", hlsl_jump_type_to_string(jump->type));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void d3dbc_write_block(struct d3dbc_compiler *d3dbc, const struct hlsl_block *block)
|
static void d3dbc_write_block(struct d3dbc_compiler *d3dbc, const struct hlsl_block *block)
|
||||||
{
|
{
|
||||||
struct vkd3d_shader_instruction *vsir_instr;
|
struct vkd3d_shader_instruction *vsir_instr;
|
||||||
@ -2399,10 +2371,6 @@ static void d3dbc_write_block(struct d3dbc_compiler *d3dbc, const struct hlsl_bl
|
|||||||
hlsl_fixme(ctx, &instr->loc, "Flatten \"if\" conditionals branches.");
|
hlsl_fixme(ctx, &instr->loc, "Flatten \"if\" conditionals branches.");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HLSL_IR_JUMP:
|
|
||||||
d3dbc_write_jump(d3dbc, instr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HLSL_IR_VSIR_INSTRUCTION_REF:
|
case HLSL_IR_VSIR_INSTRUCTION_REF:
|
||||||
vsir_instr_idx = hlsl_ir_vsir_instruction_ref(instr)->vsir_instr_idx;
|
vsir_instr_idx = hlsl_ir_vsir_instruction_ref(instr)->vsir_instr_idx;
|
||||||
vsir_instr = &d3dbc->program->instructions.elements[vsir_instr_idx];
|
vsir_instr = &d3dbc->program->instructions.elements[vsir_instr_idx];
|
||||||
|
@ -7203,6 +7203,42 @@ static void sm1_generate_vsir_instr_store(struct hlsl_ctx *ctx, struct vsir_prog
|
|||||||
hlsl_replace_node(instr, vsir_instr);
|
hlsl_replace_node(instr, vsir_instr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sm1_generate_vsir_instr_jump(struct hlsl_ctx *ctx,
|
||||||
|
struct vsir_program *program, struct hlsl_ir_jump *jump)
|
||||||
|
{
|
||||||
|
struct vkd3d_shader_instruction_array *instructions = &program->instructions;
|
||||||
|
struct hlsl_ir_node *condition = jump->condition.node;
|
||||||
|
struct hlsl_ir_node *instr = &jump->node;
|
||||||
|
struct vkd3d_shader_dst_param *dst_param;
|
||||||
|
struct vkd3d_shader_instruction *ins;
|
||||||
|
struct hlsl_ir_node *vsir_instr;
|
||||||
|
|
||||||
|
if (jump->type == HLSL_IR_JUMP_DISCARD_NEG)
|
||||||
|
{
|
||||||
|
if (!(ins = generate_vsir_add_program_instruction(ctx, program, &instr->loc, VKD3DSIH_TEXKILL, 1, 0)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
dst_param = &ins->dst[0];
|
||||||
|
vsir_register_init(&dst_param->reg, VKD3DSPR_TEMP, VKD3D_DATA_FLOAT, 1);
|
||||||
|
dst_param->reg.idx[0].offset = condition->reg.id;
|
||||||
|
dst_param->write_mask = condition->reg.writemask;
|
||||||
|
|
||||||
|
if (!(vsir_instr = hlsl_new_vsir_instruction_ref(ctx,
|
||||||
|
instructions->count - 1, instr->data_type, NULL, &instr->loc)))
|
||||||
|
{
|
||||||
|
ctx->result = VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
list_add_before(&instr->entry, &vsir_instr->entry);
|
||||||
|
hlsl_replace_node(instr, vsir_instr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hlsl_fixme(ctx, &instr->loc, "Jump type %s.", hlsl_jump_type_to_string(jump->type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool sm1_generate_vsir_instr(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
|
static bool sm1_generate_vsir_instr(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
|
||||||
{
|
{
|
||||||
struct vsir_program *program = context;
|
struct vsir_program *program = context;
|
||||||
@ -7216,6 +7252,10 @@ static bool sm1_generate_vsir_instr(struct hlsl_ctx *ctx, struct hlsl_ir_node *i
|
|||||||
case HLSL_IR_EXPR:
|
case HLSL_IR_EXPR:
|
||||||
return sm1_generate_vsir_instr_expr(ctx, program, hlsl_ir_expr(instr));
|
return sm1_generate_vsir_instr_expr(ctx, program, hlsl_ir_expr(instr));
|
||||||
|
|
||||||
|
case HLSL_IR_JUMP:
|
||||||
|
sm1_generate_vsir_instr_jump(ctx, program, hlsl_ir_jump(instr));
|
||||||
|
return true;
|
||||||
|
|
||||||
case HLSL_IR_LOAD:
|
case HLSL_IR_LOAD:
|
||||||
sm1_generate_vsir_instr_load(ctx, program, hlsl_ir_load(instr));
|
sm1_generate_vsir_instr_load(ctx, program, hlsl_ir_load(instr));
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user