@@ -6659,32 +6659,34 @@ lvk::Result lvk::VulkanContext::growDescriptorPool(uint32_t maxTextures, uint32_
66596659 deferredTask (std::packaged_task<void ()>([device = vkDevice_, dp = vkDPool_]() { vkDestroyDescriptorPool (device, dp, nullptr ); }));
66606660 }
66616661
6662- bool hasYUVImages = false ;
6662+ VkSampler firstYcbcrSampler = VK_NULL_HANDLE ;
66636663
66646664 // check if we have any YUV images
66656665 for (const auto & obj : texturesPool_.objects_ ) {
66666666 const VulkanImage* img = &obj.obj_ ;
66676667 // multisampled images cannot be directly accessed from shaders
66686668 const bool isTextureAvailable = (img->vkSamples_ & VK_SAMPLE_COUNT_1_BIT) == VK_SAMPLE_COUNT_1_BIT;
6669- hasYUVImages = isTextureAvailable && img->isSampledImage () && lvk::getNumImagePlanes (img->vkImageFormat_ ) > 1 ;
6670- if (hasYUVImages) {
6669+ const bool isYUVImage = isTextureAvailable && img->isSampledImage () && lvk::getNumImagePlanes (img->vkImageFormat_ ) > 1 ;
6670+ if (isYUVImage) {
6671+ // find the first Ycbcr sampler and use it as a dummy
6672+ // (https://docs.vulkan.org/spec/latest/chapters/descriptorsets.html#VUID-VkDescriptorSetLayoutBinding-descriptorType-12200)
6673+ firstYcbcrSampler = getOrCreateYcbcrSampler (vkFormatToFormat (img->vkImageFormat_ ));
66716674 break ;
66726675 }
66736676 }
66746677
66756678 std::vector<VkSampler> immutableSamplers;
66766679 const VkSampler* immutableSamplersData = nullptr ;
66776680
6678- if (hasYUVImages) {
6679- VkSampler dummySampler = samplersPool_.objects_ [0 ].obj_ ;
6680- immutableSamplers.resize (maxTextures, dummySampler);
6681+ if (firstYcbcrSampler) {
6682+ immutableSamplers.resize (maxTextures, firstYcbcrSampler);
66816683 for (size_t i = 0 ; i != texturesPool_.objects_ .size (); i++) {
66826684 const auto & obj = texturesPool_.objects_ [i];
66836685 const VulkanImage* img = &obj.obj_ ;
66846686 // multisampled images cannot be directly accessed from shaders
66856687 const bool isTextureAvailable = (img->vkSamples_ & VK_SAMPLE_COUNT_1_BIT) == VK_SAMPLE_COUNT_1_BIT;
66866688 const bool isYUVImage = isTextureAvailable && img->isSampledImage () && lvk::getNumImagePlanes (img->vkImageFormat_ ) > 1 ;
6687- immutableSamplers[i] = isYUVImage ? getOrCreateYcbcrSampler (vkFormatToFormat (img->vkImageFormat_ )) : dummySampler ;
6689+ immutableSamplers[i] = isYUVImage ? getOrCreateYcbcrSampler (vkFormatToFormat (img->vkImageFormat_ )) : firstYcbcrSampler ;
66886690 }
66896691 immutableSamplersData = immutableSamplers.data ();
66906692 }
0 commit comments