panvk: Fix input attachment support

Lower input attachments to texture operations as it was meant to be
according to the set layout accounting, and fix the descriptor set
logic to fill texture descriptors instead of image descriptors.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28417>
This commit is contained in:
Boris Brezillon 2024-03-28 09:40:51 +01:00 committed by Marge Bot
parent 502a1ca300
commit 3c3476bae8
2 changed files with 22 additions and 4 deletions

View file

@ -658,6 +658,7 @@ panvk_per_arch(UpdateDescriptorSets)(
break;
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
for (uint32_t j = 0; j < write->descriptorCount; j++) {
panvk_write_tex_desc(set, write->dstBinding,
write->dstArrayElement + j,
@ -666,7 +667,6 @@ panvk_per_arch(UpdateDescriptorSets)(
break;
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
for (uint32_t j = 0; j < write->descriptorCount; j++) {
panvk_write_img_desc(set, write->dstBinding,
write->dstArrayElement + j,
@ -772,6 +772,7 @@ panvk_per_arch(UpdateDescriptorSets)(
break;
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
for (uint32_t j = 0; j < copy->descriptorCount; j++) {
panvk_copy_tex_desc(dst_set, copy->dstBinding,
@ -781,7 +782,6 @@ panvk_per_arch(UpdateDescriptorSets)(
break;
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
for (uint32_t j = 0; j < copy->descriptorCount; j++) {
panvk_copy_img_desc(dst_set, copy->dstBinding,
@ -848,6 +848,7 @@ panvk_per_arch(UpdateDescriptorSetWithTemplate)(
case VK_DESCRIPTOR_TYPE_SAMPLER:
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
for (unsigned j = 0; j < entry->array_count; j++) {
const VkDescriptorImageInfo *info =
data + entry->offset + j * entry->stride;
@ -861,7 +862,8 @@ panvk_per_arch(UpdateDescriptorSetWithTemplate)(
}
if (entry->type == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE ||
entry->type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) {
entry->type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER ||
entry->type == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) {
panvk_write_tex_desc(set, entry->binding,
entry->array_element + j, info);
@ -870,7 +872,6 @@ panvk_per_arch(UpdateDescriptorSetWithTemplate)(
break;
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
for (unsigned j = 0; j < entry->array_count; j++) {
const VkDescriptorImageInfo *info =
data + entry->offset + j * entry->stride;

View file

@ -115,6 +115,14 @@ panvk_lower_sysvals(nir_builder *b, nir_instr *instr, void *data)
val = load_sysval_from_ubo(b, intr, SYSVAL(blend_constants));
}
break;
case nir_intrinsic_load_layer_id:
/* We don't support layered rendering yet, so force the layer_id to
* zero for now.
*/
val = nir_imm_int(b, 0);
break;
default:
return false;
}
@ -274,6 +282,15 @@ panvk_per_arch(shader_create)(struct panvk_device *dev, gl_shader_stage stage,
NIR_PASS_V(nir, nir_opt_combine_stores, nir_var_all);
NIR_PASS_V(nir, nir_opt_loop);
if (stage == MESA_SHADER_FRAGMENT) {
struct nir_input_attachment_options lower_input_attach_opts = {
.use_fragcoord_sysval = true,
.use_layer_id_sysval = true,
};
NIR_PASS_V(nir, nir_lower_input_attachments, &lower_input_attach_opts);
}
/* Do texture lowering here. Yes, it's a duplication of the texture
* lowering in bifrost_compile. However, we need to lower texture stuff
* now, before we call panvk_per_arch(nir_lower_descriptors)() because some