radv: Implement VK_KHR_imageless_framebuffer.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Fri, 2 Aug 2019 12:42:50 +0000 (14:42 +0200)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Fri, 2 Aug 2019 20:35:19 +0000 (22:35 +0200)
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/vulkan/radv_cmd_buffer.c
src/amd/vulkan/radv_device.c

index e46c3ee9c4724255133a0033bbabc52343ff64ac..645e0155510227caac52894b090ff0df278f9cf5 100644 (file)
@@ -3008,6 +3008,13 @@ radv_cmd_state_setup_attachments(struct radv_cmd_buffer *cmd_buffer,
                                 const VkRenderPassBeginInfo *info)
 {
        struct radv_cmd_state *state = &cmd_buffer->state;
+       const struct VkRenderPassAttachmentBeginInfoKHR *attachment_info = NULL;
+
+       if (info) {
+               attachment_info = vk_find_struct_const(info->pNext,
+                                                      RENDER_PASS_ATTACHMENT_BEGIN_INFO_KHR);
+       }
+
 
        if (pass->attachment_count == 0) {
                state->attachments = NULL;
@@ -3058,7 +3065,14 @@ radv_cmd_state_setup_attachments(struct radv_cmd_buffer *cmd_buffer,
                state->attachments[i].current_layout = att->initial_layout;
                state->attachments[i].sample_location.count = 0;
 
-               struct radv_image_view *iview = state->framebuffer->attachments[i];
+               struct radv_image_view *iview;
+               if (attachment_info && attachment_info->attachmentCount > i) {
+                       iview = radv_image_view_from_handle(attachment_info->pAttachments[i]);
+               } else {
+                       iview = state->framebuffer->attachments[i];
+               }
+
+               state->attachments[i].iview = iview;
                if (iview->aspect_mask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) {
                        radv_initialise_ds_surface(cmd_buffer->device, &state->attachments[i].ds, iview);
                } else {
index 0d4b25c6969f4aa51369b31a6bda7d3230af2b17..280b297f4dfabe0f2305d7f115614d022f869aaa 100644 (file)
@@ -4806,11 +4806,15 @@ VkResult radv_CreateFramebuffer(
 {
        RADV_FROM_HANDLE(radv_device, device, _device);
        struct radv_framebuffer *framebuffer;
+       const VkFramebufferAttachmentsCreateInfoKHR *imageless_create_info =
+               vk_find_struct_const(pCreateInfo->pNext,
+                       FRAMEBUFFER_ATTACHMENTS_CREATE_INFO_KHR);
 
        assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO);
 
-       size_t size = sizeof(*framebuffer) +
-               sizeof(struct radv_image_view*) * pCreateInfo->attachmentCount;
+       size_t size = sizeof(*framebuffer);
+       if (!imageless_create_info)
+               size += sizeof(struct radv_image_view*) * pCreateInfo->attachmentCount;
        framebuffer = vk_alloc2(&device->alloc, pAllocator, size, 8,
                                  VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
        if (framebuffer == NULL)
@@ -4820,13 +4824,23 @@ VkResult radv_CreateFramebuffer(
        framebuffer->width = pCreateInfo->width;
        framebuffer->height = pCreateInfo->height;
        framebuffer->layers = pCreateInfo->layers;
-       for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) {
-               VkImageView _iview = pCreateInfo->pAttachments[i];
-               struct radv_image_view *iview = radv_image_view_from_handle(_iview);
-               framebuffer->attachments[i] = iview;
-               framebuffer->width = MIN2(framebuffer->width, iview->extent.width);
-               framebuffer->height = MIN2(framebuffer->height, iview->extent.height);
-               framebuffer->layers = MIN2(framebuffer->layers, radv_surface_max_layer_count(iview));
+       if (imageless_create_info) {
+               for (unsigned i = 0; i < imageless_create_info->attachmentImageInfoCount; ++i) {
+                       const VkFramebufferAttachmentImageInfoKHR *attachment =
+                               imageless_create_info->pAttachmentImageInfos + i;
+                       framebuffer->width = MIN2(framebuffer->width, attachment->width);
+                       framebuffer->height = MIN2(framebuffer->height, attachment->height);
+                       framebuffer->layers = MIN2(framebuffer->layers, attachment->layerCount);
+               }
+       } else {
+               for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) {
+                       VkImageView _iview = pCreateInfo->pAttachments[i];
+                       struct radv_image_view *iview = radv_image_view_from_handle(_iview);
+                       framebuffer->attachments[i] = iview;
+                       framebuffer->width = MIN2(framebuffer->width, iview->extent.width);
+                       framebuffer->height = MIN2(framebuffer->height, iview->extent.height);
+                       framebuffer->layers = MIN2(framebuffer->layers, radv_surface_max_layer_count(iview));
+               }
        }
 
        *pFramebuffer = radv_framebuffer_to_handle(framebuffer);