vkd3d-shader/hlsl: Store SM4 resource stores in the vsir program.

This commit is contained in:
Francisco Casas
2024-11-07 15:31:28 -03:00
committed by Henri Verbeet
parent 5b4af411f5
commit 13dfccc1c6
Notes: Henri Verbeet 2024-11-21 19:34:59 +01:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1253
2 changed files with 54 additions and 43 deletions

View File

@@ -5438,45 +5438,6 @@ static void write_sm4_resource_load(const struct tpf_compiler *tpf, const struct
}
}
static void write_sm4_resource_store(const struct tpf_compiler *tpf, const struct hlsl_ir_resource_store *store)
{
struct hlsl_type *resource_type = hlsl_deref_get_type(tpf->ctx, &store->resource);
struct hlsl_ir_node *coords = store->coords.node, *value = store->value.node;
struct sm4_instruction instr;
if (!store->resource.var->is_uniform)
{
hlsl_fixme(tpf->ctx, &store->node.loc, "Store to non-uniform resource variable.");
return;
}
if (resource_type->sampler_dim == HLSL_SAMPLER_DIM_STRUCTURED_BUFFER)
{
hlsl_fixme(tpf->ctx, &store->node.loc, "Structured buffers store is not implemented.");
return;
}
memset(&instr, 0, sizeof(instr));
sm4_register_from_deref(tpf, &instr.dsts[0].reg, &instr.dsts[0].write_mask, &store->resource, &instr);
instr.dst_count = 1;
if (resource_type->sampler_dim == HLSL_SAMPLER_DIM_RAW_BUFFER)
{
instr.opcode = VKD3D_SM5_OP_STORE_RAW;
instr.dsts[0].write_mask = vkd3d_write_mask_from_component_count(value->data_type->dimx);
}
else
{
instr.opcode = VKD3D_SM5_OP_STORE_UAV_TYPED;
}
sm4_src_from_node(tpf, &instr.srcs[0], coords, VKD3DSP_WRITEMASK_ALL);
sm4_src_from_node(tpf, &instr.srcs[1], value, VKD3DSP_WRITEMASK_ALL);
instr.src_count = 2;
write_sm4_instruction(tpf, &instr);
}
static void write_sm4_switch(struct tpf_compiler *tpf, const struct hlsl_ir_switch *s)
{
const struct hlsl_ir_node *selector = s->selector.node;
@@ -5664,6 +5625,8 @@ static void tpf_handle_instruction(struct tpf_compiler *tpf, const struct vkd3d_
case VKD3DSIH_SAMPLE_INFO:
case VKD3DSIH_SINCOS:
case VKD3DSIH_SQRT:
case VKD3DSIH_STORE_RAW:
case VKD3DSIH_STORE_UAV_TYPED:
case VKD3DSIH_UDIV:
case VKD3DSIH_UGE:
case VKD3DSIH_ULT:
@@ -5722,10 +5685,6 @@ static void write_sm4_block(struct tpf_compiler *tpf, const struct hlsl_block *b
write_sm4_resource_load(tpf, hlsl_ir_resource_load(instr));
break;
case HLSL_IR_RESOURCE_STORE:
write_sm4_resource_store(tpf, hlsl_ir_resource_store(instr));
break;
case HLSL_IR_LOOP:
write_sm4_loop(tpf, hlsl_ir_loop(instr));
break;