v3dv: initial support for input attachments

We are treating them as a special case of texture, so the commit is
mostly about integrating them with the existing
SAMPLER/SAMPLER_IMAGE/COMBINED_IMAGE_SAMPLER infrastructure.

This commit doesn't use in any special way the render pass
information, including the dependencies, so it is possible that we
would need to do something else. But this commit gets several CTS
tests, and two Sascha Willem Vulkan demos, so let's start with this
commit and handle any other use case for following commits.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
Alejandro Piñeiro 2020-06-23 15:47:53 +02:00 committed by Marge Bot
parent 19d3639ee7
commit 9833a5ae70
4 changed files with 29 additions and 6 deletions

View File

@ -2068,8 +2068,7 @@ cmd_buffer_subpass_create_job(struct v3dv_cmd_buffer *cmd_buffer,
subpass->color_count,
internal_bpp);
/* FIXME: we don't support input/resolve attachments yet */
assert(subpass->input_count == 0);
/* FIXME: we don't suppport resolve attachments yet */
assert(subpass->resolve_attachments == NULL);
}

View File

@ -38,6 +38,7 @@ descriptor_bo_size(VkDescriptorType type)
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
return sizeof(struct v3dv_combined_image_sampler_descriptor);
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
return sizeof(struct v3dv_sampled_image_descriptor);
default:
return 0;
@ -248,7 +249,8 @@ v3dv_descriptor_map_get_texture_shader_state(struct v3dv_descriptor_state *descr
index, &type);
assert(type == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE ||
type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER);
type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER ||
type == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT);
if (type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) {
reloc.offset += offsetof(struct v3dv_combined_image_sampler_descriptor,
@ -272,7 +274,9 @@ v3dv_descriptor_map_get_image_view(struct v3dv_descriptor_state *descriptor_stat
assert(image_descriptor);
assert(image_descriptor->type == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE ||
image_descriptor->type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER);
image_descriptor->type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER ||
image_descriptor->type == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT);
assert(image_descriptor->image_view);
assert(image_descriptor->image_view->image);
@ -376,6 +380,7 @@ v3dv_CreateDescriptorPool(VkDevice _device,
case VK_DESCRIPTOR_TYPE_SAMPLER:
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
break;
default:
unreachable("Unimplemented descriptor type");
@ -620,6 +625,7 @@ v3dv_CreateDescriptorSetLayout(VkDevice _device,
case VK_DESCRIPTOR_TYPE_SAMPLER:
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
/* Nothing here, just to keep the descriptor type filtering below */
break;
default:
@ -950,6 +956,7 @@ v3dv_UpdateDescriptorSets(VkDevice _device,
break;
}
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: {
const VkDescriptorImageInfo *image_info = writeset->pImageInfo + j;
V3DV_FROM_HANDLE(v3dv_image_view, iview, image_info->imageView);

View File

@ -63,7 +63,17 @@ pass_find_subpass_range_for_attachments(struct v3dv_render_pass *pass)
pass->attachments[ds_attachment_idx].last_subpass = i;
}
/* FIXME: input/resolve attachments */
for (uint32_t j = 0; j < subpass->input_count; j++) {
uint32_t input_attachment_idx = subpass->input_attachments[j].attachment;
if (input_attachment_idx == VK_ATTACHMENT_UNUSED)
continue;
if (i < pass->attachments[input_attachment_idx].first_subpass)
pass->attachments[input_attachment_idx].first_subpass = i;
if (i > pass->attachments[input_attachment_idx].last_subpass)
pass->attachments[input_attachment_idx].last_subpass = i;
}
/* FIXME: we don't support resolve attachments yet */
assert(subpass->resolve_attachments == NULL);
}
}

View File

@ -668,12 +668,19 @@ lower_tex_src_to_offset(nir_builder *b, nir_tex_instr *instr, unsigned src_idx,
struct v3dv_descriptor_set_binding_layout *binding_layout =
&set_layout->binding[binding];
/* For input attachments, the shader includes the attachment_idx. As we are
* treating them as a texture, we only want the base_index
*/
uint32_t array_index = binding_layout->type != VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT ?
deref->var->data.index + base_index :
base_index;
int desc_index =
descriptor_map_add(is_sampler ?
&pipeline->sampler_map : &pipeline->texture_map,
deref->var->data.descriptor_set,
deref->var->data.binding,
deref->var->data.index + base_index,
array_index,
binding_layout->array_size);
if (is_sampler)
instr->sampler_index = desc_index;