From 34843c3ffefecb1b0503954c2e9d189f8cfa9cce Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 10 Jul 2020 10:08:23 +0100 Subject: [PATCH] xrt: Make some fields on xrt_vk_swapchain private --- src/xrt/compositor/client/comp_vk_client.c | 25 +++++++++++----------- src/xrt/compositor/client/comp_vk_client.h | 7 ++++++ src/xrt/include/xrt/xrt_compositor.h | 6 +----- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/xrt/compositor/client/comp_vk_client.c b/src/xrt/compositor/client/comp_vk_client.c index 229bc61f3..be8276fc9 100644 --- a/src/xrt/compositor/client/comp_vk_client.c +++ b/src/xrt/compositor/client/comp_vk_client.c @@ -57,10 +57,9 @@ client_vk_swapchain_destroy(struct xrt_swapchain *xsc) sc->base.images[i] = VK_NULL_HANDLE; } - if (sc->base.mems[i] != VK_NULL_HANDLE) { - c->vk.vkFreeMemory(c->vk.device, sc->base.mems[i], - NULL); - sc->base.mems[i] = VK_NULL_HANDLE; + if (sc->mems[i] != VK_NULL_HANDLE) { + c->vk.vkFreeMemory(c->vk.device, sc->mems[i], NULL); + sc->mems[i] = VK_NULL_HANDLE; } } @@ -88,7 +87,7 @@ client_vk_swapchain_acquire_image(struct xrt_swapchain *xsc, VkSubmitInfo submitInfo = { .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, .commandBufferCount = 1, - .pCommandBuffers = &sc->base.acquire[*out_index], + .pCommandBuffers = &sc->acquire[*out_index], }; VkResult ret = vk->vkQueueSubmit(vk->queue, 1, &submitInfo, VK_NULL_HANDLE); @@ -120,7 +119,7 @@ client_vk_swapchain_release_image(struct xrt_swapchain *xsc, uint32_t index) VkSubmitInfo submitInfo = { .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, .commandBufferCount = 1, - .pCommandBuffers = &sc->base.release[index], + .pCommandBuffers = &sc->release[index], }; VkResult ret = vk->vkQueueSubmit(vk->queue, 1, &submitInfo, VK_NULL_HANDLE); @@ -329,7 +328,7 @@ client_vk_swapchain_create(struct xrt_compositor *xc, ret = vk_create_image_from_native( &c->vk, info->bits, info->format, info->width, info->height, info->array_size, info->mip_count, &xscn->images[i], - &sc->base.images[i], &sc->base.mems[i]); + &sc->base.images[i], &sc->mems[i]); if (ret != VK_SUCCESS) { @@ -356,11 +355,11 @@ client_vk_swapchain_create(struct xrt_compositor *xc, // Prerecord command buffers for swapchain image ownership/layout // transitions for (uint32_t i = 0; i < xsc->num_images; i++) { - ret = vk_init_cmd_buffer(&c->vk, &sc->base.acquire[i]); + ret = vk_init_cmd_buffer(&c->vk, &sc->acquire[i]); if (ret != VK_SUCCESS) { return NULL; } - ret = vk_init_cmd_buffer(&c->vk, &sc->base.release[i]); + ret = vk_init_cmd_buffer(&c->vk, &sc->release[i]); if (ret != VK_SUCCESS) { return NULL; } @@ -414,22 +413,22 @@ client_vk_swapchain_create(struct xrt_compositor *xc, }; //! @todo less conservative pipeline stage masks based on usage - c->vk.vkCmdPipelineBarrier(sc->base.acquire[i], + c->vk.vkCmdPipelineBarrier(sc->acquire[i], VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, &acquire); - c->vk.vkCmdPipelineBarrier(sc->base.release[i], + c->vk.vkCmdPipelineBarrier(sc->release[i], VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, NULL, 0, NULL, 1, &release); - ret = c->vk.vkEndCommandBuffer(sc->base.acquire[i]); + ret = c->vk.vkEndCommandBuffer(sc->acquire[i]); if (ret != VK_SUCCESS) { VK_ERROR(vk, "vkEndCommandBuffer: %s", vk_result_string(ret)); return NULL; } - ret = c->vk.vkEndCommandBuffer(sc->base.release[i]); + ret = c->vk.vkEndCommandBuffer(sc->release[i]); if (ret != VK_SUCCESS) { VK_ERROR(vk, "vkEndCommandBuffer: %s", vk_result_string(ret)); diff --git a/src/xrt/compositor/client/comp_vk_client.h b/src/xrt/compositor/client/comp_vk_client.h index 1cd965854..375c967e2 100644 --- a/src/xrt/compositor/client/comp_vk_client.h +++ b/src/xrt/compositor/client/comp_vk_client.h @@ -43,6 +43,13 @@ struct client_vk_swapchain //! Non-owning reference to our parent compositor. struct client_vk_compositor *c; + + // Memory + VkDeviceMemory mems[XRT_MAX_SWAPCHAIN_IMAGES]; + + // Prerecorded swapchain image ownership/layout transition barriers + VkCommandBuffer acquire[XRT_MAX_SWAPCHAIN_IMAGES]; + VkCommandBuffer release[XRT_MAX_SWAPCHAIN_IMAGES]; }; /*! diff --git a/src/xrt/include/xrt/xrt_compositor.h b/src/xrt/include/xrt/xrt_compositor.h index 70868a849..3ecb2ba89 100644 --- a/src/xrt/include/xrt/xrt_compositor.h +++ b/src/xrt/include/xrt/xrt_compositor.h @@ -812,12 +812,8 @@ struct xrt_swapchain_vk //! @public Base struct xrt_swapchain base; + //! Images to be used by the caller. VkImage images[XRT_MAX_SWAPCHAIN_IMAGES]; - VkDeviceMemory mems[XRT_MAX_SWAPCHAIN_IMAGES]; - - // Prerecorded swapchain image ownership/layout transition barriers - VkCommandBuffer acquire[XRT_MAX_SWAPCHAIN_IMAGES]; - VkCommandBuffer release[XRT_MAX_SWAPCHAIN_IMAGES]; }; /*!