From cb49df3bcae4fc8d0a3f0213530a2f79852700eb Mon Sep 17 00:00:00 2001 From: pezcode Date: Thu, 8 Apr 2021 05:05:17 +0200 Subject: [PATCH] Bind IMAGE2D_RO correctly as a texture2D without a sampler (#2454) --- src/renderer_vk.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/renderer_vk.cpp b/src/renderer_vk.cpp index 8bc6589db..adc37a45f 100644 --- a/src/renderer_vk.cpp +++ b/src/renderer_vk.cpp @@ -4355,19 +4355,32 @@ VK_IMPORT_DEVICE { case Binding::Image: { + const bool isImageDescriptor = BindType::Image == bindInfo.type; + wds[wdsCount].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; wds[wdsCount].pNext = NULL; wds[wdsCount].dstSet = descriptorSet; wds[wdsCount].dstBinding = bindInfo.binding; wds[wdsCount].dstArrayElement = 0; wds[wdsCount].descriptorCount = 1; - wds[wdsCount].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; + wds[wdsCount].descriptorType = isImageDescriptor + ? VK_DESCRIPTOR_TYPE_STORAGE_IMAGE + : VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE + ; wds[wdsCount].pImageInfo = NULL; wds[wdsCount].pBufferInfo = NULL; wds[wdsCount].pTexelBufferView = NULL; TextureVK& texture = m_textures[bind.m_idx]; - texture.setImageMemoryBarrier(m_commandBuffer, VK_IMAGE_LAYOUT_GENERAL); + + if (VK_IMAGE_LAYOUT_GENERAL != texture.m_currentImageLayout) + { + const VkImageLayout layout = isImageDescriptor + ? VK_IMAGE_LAYOUT_GENERAL + : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL + ; + texture.setImageMemoryBarrier(m_commandBuffer, layout); + } VkImageViewType type = texture.m_type; if (UINT32_MAX != bindInfo.index)