c/render: Do not assume nullDescriptor is available

This commit is contained in:
Jakob Bornecrantz 2022-02-21 20:31:46 +00:00 committed by Jakob Bornecrantz
parent b1b6978069
commit dfb1b8d469
3 changed files with 61 additions and 16 deletions

View file

@ -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

View file

@ -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.

View file

@ -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);