vkd3d-shader: Use the correct union members for raw and structured resources.

This commit is contained in:
Elizabeth Figura
2025-05-06 13:41:30 -05:00
committed by Henri Verbeet
parent 85d2703c03
commit 9552dab5aa
Notes: Henri Verbeet 2025-06-04 13:13:50 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1531
2 changed files with 56 additions and 43 deletions

View File

@@ -3859,9 +3859,8 @@ static uint32_t pack_resource_data_type(const enum vkd3d_data_type *resource_dat
static void tpf_dcl_texture(const struct tpf_compiler *tpf, const struct vkd3d_shader_instruction *ins)
{
const struct vkd3d_shader_structured_resource *structured_resource = &ins->declaration.structured_resource;
const struct vkd3d_shader_semantic *semantic = &ins->declaration.semantic;
const struct vkd3d_shader_version *version = &tpf->program->shader_version;
const struct vkd3d_shader_resource *resource;
const struct vkd3d_sm4_opcode_info *info;
struct sm4_instruction instr = {0};
bool uav;
@@ -3875,27 +3874,38 @@ static void tpf_dcl_texture(const struct tpf_compiler *tpf, const struct vkd3d_s
instr.opcode = info->opcode;
instr.dsts[0] = semantic->resource.reg;
instr.dst_count = 1;
if (ins->opcode == VKD3DSIH_DCL || ins->opcode == VKD3DSIH_DCL_UAV_TYPED)
{
instr.idx[0] = pack_resource_data_type(semantic->resource_data_type);
instr.idx[0] = pack_resource_data_type(ins->declaration.semantic.resource_data_type);
instr.idx_count = 1;
instr.extra_bits |= ins->declaration.semantic.sample_count << VKD3D_SM4_RESOURCE_SAMPLE_COUNT_SHIFT;
resource = &ins->declaration.semantic.resource;
}
if (vkd3d_shader_ver_ge(version, 5, 1))
else if (ins->opcode == VKD3DSIH_DCL_RESOURCE_RAW || ins->opcode == VKD3DSIH_DCL_UAV_RAW)
{
instr.dsts[0].reg.idx[0].offset = semantic->resource.reg.reg.idx[0].offset;
instr.dsts[0].reg.idx[1].offset = semantic->resource.range.first;
instr.dsts[0].reg.idx[2].offset = semantic->resource.range.last;
instr.dsts[0].reg.idx_count = 3;
instr.idx[instr.idx_count++] = semantic->resource.range.space;
resource = &ins->declaration.raw_resource.resource;
}
else
{
instr.dsts[0].reg.idx[0].offset = semantic->resource.range.first;
instr.byte_stride = ins->declaration.structured_resource.byte_stride;
resource = &ins->declaration.structured_resource.resource;
}
instr.dsts[0] = resource->reg;
instr.dst_count = 1;
if (vkd3d_shader_ver_ge(version, 5, 1))
{
instr.dsts[0].reg.idx[0].offset = resource->reg.reg.idx[0].offset;
instr.dsts[0].reg.idx[1].offset = resource->range.first;
instr.dsts[0].reg.idx[2].offset = resource->range.last;
instr.dsts[0].reg.idx_count = 3;
instr.idx[instr.idx_count++] = resource->range.space;
}
else
{
instr.dsts[0].reg.idx[0].offset = resource->range.first;
instr.dsts[0].reg.idx_count = 1;
}
@@ -3903,10 +3913,6 @@ static void tpf_dcl_texture(const struct tpf_compiler *tpf, const struct vkd3d_s
instr.extra_bits |= ins->flags << VKD3D_SM5_UAV_FLAGS_SHIFT;
instr.extra_bits |= (sm4_resource_dimension(ins->resource_type) << VKD3D_SM4_RESOURCE_TYPE_SHIFT);
instr.extra_bits |= semantic->sample_count << VKD3D_SM4_RESOURCE_SAMPLE_COUNT_SHIFT;
if (ins->structured)
instr.byte_stride = structured_resource->byte_stride;
write_sm4_instruction(tpf, &instr);
}