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

This commit is contained in:
Francisco Casas 2024-11-08 12:16:46 -03:00 committed by Henri Verbeet
parent 4382af6e1b
commit c89f503604
Notes: Henri Verbeet 2024-11-24 00:11:40 +01:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1276
2 changed files with 29 additions and 26 deletions

View File

@ -9165,6 +9165,31 @@ static bool sm4_generate_vsir_instr_gather(struct hlsl_ctx *ctx, struct vsir_pro
return true;
}
static bool sm4_generate_vsir_instr_sample_info(struct hlsl_ctx *ctx,
struct vsir_program *program, const struct hlsl_ir_resource_load *load)
{
const struct hlsl_deref *resource = &load->resource;
const struct hlsl_ir_node *instr = &load->node;
struct hlsl_type *type = instr->data_type;
struct vkd3d_shader_instruction *ins;
VKD3D_ASSERT(type->e.numeric.type == HLSL_TYPE_UINT || type->e.numeric.type == HLSL_TYPE_FLOAT);
if (!(ins = generate_vsir_add_program_instruction(ctx, program, &instr->loc, VKD3DSIH_SAMPLE_INFO, 1, 1)))
return false;
if (type->e.numeric.type == HLSL_TYPE_UINT)
ins->flags = VKD3DSI_SAMPLE_INFO_UINT;
vsir_dst_from_hlsl_node(&ins->dst[0], ctx, instr);
if (!sm4_generate_vsir_init_src_param_from_deref(ctx, program,
&ins->src[0], resource, ins->dst[0].write_mask, &instr->loc))
return false;
return true;
}
static bool sm4_generate_vsir_instr_resource_load(struct hlsl_ctx *ctx,
struct vsir_program *program, const struct hlsl_ir_resource_load *load)
{
@ -9207,6 +9232,9 @@ static bool sm4_generate_vsir_instr_resource_load(struct hlsl_ctx *ctx,
case HLSL_RESOURCE_GATHER_ALPHA:
return sm4_generate_vsir_instr_gather(ctx, program, load, VKD3D_SHADER_SWIZZLE(W, W, W, W));
case HLSL_RESOURCE_SAMPLE_INFO:
return sm4_generate_vsir_instr_sample_info(ctx, program, load);
case HLSL_RESOURCE_SAMPLE_PROJ:
vkd3d_unreachable();

View File

@ -5007,28 +5007,6 @@ static void write_sm4_ret(const struct tpf_compiler *tpf)
write_sm4_instruction(tpf, &instr);
}
static void write_sm4_sampleinfo(const struct tpf_compiler *tpf, const struct hlsl_ir_resource_load *load)
{
const struct hlsl_deref *resource = &load->resource;
const struct hlsl_ir_node *dst = &load->node;
struct sm4_instruction instr;
VKD3D_ASSERT(dst->data_type->e.numeric.type == HLSL_TYPE_UINT || dst->data_type->e.numeric.type == HLSL_TYPE_FLOAT);
memset(&instr, 0, sizeof(instr));
instr.opcode = VKD3D_SM4_OP_SAMPLE_INFO;
if (dst->data_type->e.numeric.type == HLSL_TYPE_UINT)
instr.extra_bits |= VKD3DSI_SAMPLE_INFO_UINT << VKD3D_SM4_INSTRUCTION_FLAGS_SHIFT;
sm4_dst_from_node(&instr.dsts[0], dst);
instr.dst_count = 1;
sm4_src_from_deref(tpf, &instr.srcs[0], resource, instr.dsts[0].write_mask, &instr);
instr.src_count = 1;
write_sm4_instruction(tpf, &instr);
}
static void write_sm4_resinfo(const struct tpf_compiler *tpf, const struct hlsl_ir_resource_load *load)
{
const struct hlsl_deref *resource = &load->resource;
@ -5156,10 +5134,6 @@ static void write_sm4_resource_load(const struct tpf_compiler *tpf, const struct
switch (load->load_type)
{
case HLSL_RESOURCE_SAMPLE_INFO:
write_sm4_sampleinfo(tpf, load);
break;
case HLSL_RESOURCE_RESINFO:
write_sm4_resinfo(tpf, load);
break;
@ -5176,6 +5150,7 @@ static void write_sm4_resource_load(const struct tpf_compiler *tpf, const struct
case HLSL_RESOURCE_SAMPLE_GRAD:
case HLSL_RESOURCE_LOAD:
case HLSL_RESOURCE_SAMPLE_PROJ:
case HLSL_RESOURCE_SAMPLE_INFO:
vkd3d_unreachable();
}
}