From dfb1b8d469cfd9c64282690bdf60a4dfe321692b Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 21 Feb 2022 20:31:46 +0000 Subject: [PATCH] c/render: Do not assume nullDescriptor is available --- src/xrt/compositor/render/comp_compute.c | 30 ++++++++---------- src/xrt/compositor/render/comp_render.h | 10 ++++++ src/xrt/compositor/render/comp_resources.c | 37 ++++++++++++++++++++++ 3 files changed, 61 insertions(+), 16 deletions(-) diff --git a/src/xrt/compositor/render/comp_compute.c b/src/xrt/compositor/render/comp_compute.c index 5a21f6ae8..fb95083c3 100644 --- a/src/xrt/compositor/render/comp_compute.c +++ b/src/xrt/compositor/render/comp_compute.c @@ -618,25 +618,23 @@ comp_rendering_compute_clear(struct comp_rendering_compute *crc, // VkSampler sampler = r->compute.default_sampler; VkSampler src_samplers[2] = {sampler, sampler}; - VkImageView src_image_views[2] = {VK_NULL_HANDLE, VK_NULL_HANDLE}; + VkImageView src_image_views[2] = {r->dummy.color.image_view, r->dummy.color.image_view}; VkSampler distortion_samplers[6] = {sampler, sampler, sampler, sampler, sampler, sampler}; - VkImageView distortion_image_views[6] = {VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE, - VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE}; update_compute_discriptor_set( // - vk, // - r->compute.src_binding, // - src_samplers, // - src_image_views, // - r->compute.distortion_binding, // - distortion_samplers, // - distortion_image_views, // - r->compute.target_binding, // - target_image_view, // - r->compute.ubo_binding, // - r->compute.ubo.buffer, // - VK_WHOLE_SIZE, // - crc->descriptor_set); // + vk, // vk_bundle + r->compute.src_binding, // src_binding + src_samplers, // src_samplers[2] + src_image_views, // src_image_views[2] + r->compute.distortion_binding, // distortion_binding + distortion_samplers, // distortion_samplers[6] + r->distortion.image_views, // distortion_image_views[6] + r->compute.target_binding, // target_binding + target_image_view, // target_image_view + r->compute.ubo_binding, // ubo_binding + r->compute.ubo.buffer, // ubo_buffer + VK_WHOLE_SIZE, // ubo_size + crc->descriptor_set); // descriptor_set vk->vkCmdBindPipeline( // crc->cmd, // commandBuffer diff --git a/src/xrt/compositor/render/comp_render.h b/src/xrt/compositor/render/comp_render.h index e65e303ae..cfefb7c16 100644 --- a/src/xrt/compositor/render/comp_render.h +++ b/src/xrt/compositor/render/comp_render.h @@ -238,6 +238,16 @@ struct comp_resources struct comp_buffer ubos[2]; } mesh; + struct + { + struct + { + VkImage image; + VkImageView image_view; + VkDeviceMemory memory; + } color; + } dummy; + struct { //! Descriptor pool for compute work. diff --git a/src/xrt/compositor/render/comp_resources.c b/src/xrt/compositor/render/comp_resources.c index b3753616b..d544d0a21 100644 --- a/src/xrt/compositor/render/comp_resources.c +++ b/src/xrt/compositor/render/comp_resources.c @@ -507,6 +507,40 @@ comp_resources_init(struct comp_resources *r, r->compute.ubo_binding = 3; + /* + * Dummy + */ + + { + VkFormat format = VK_FORMAT_R8G8B8A8_UNORM; + VkImageUsageFlags usage = VK_IMAGE_USAGE_SAMPLED_BIT; + VkExtent2D extent = {1, 1}; + + VkImageSubresourceRange subresource_range = { + .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, + .baseMipLevel = 0, + .levelCount = 1, + .baseArrayLayer = 0, + .layerCount = 1, + }; + + C(vk_create_image_simple( // + vk, // vk_bundle + extent, // extent + format, // format + usage, // usage + &r->dummy.color.memory, // out_mem + &r->dummy.color.image)); // out_image + + C(vk_create_view( // + vk, // vk_bundle + r->dummy.color.image, // image + format, // format + subresource_range, // subresource_range + &r->dummy.color.image_view)); // out_view + } + + /* * Shared */ @@ -687,6 +721,9 @@ comp_resources_close(struct comp_resources *r) struct vk_bundle *vk = r->vk; + D(ImageView, r->dummy.color.image_view); + D(Image, r->dummy.color.image); + DF(Memory, r->dummy.color.memory); D(DescriptorSetLayout, r->mesh.descriptor_set_layout); D(PipelineLayout, r->mesh.pipeline_layout); D(PipelineCache, r->pipeline_cache);