diff --git a/src/nbl/video/CVulkanLogicalDevice.cpp b/src/nbl/video/CVulkanLogicalDevice.cpp index ff5febb4b1..847885da02 100644 --- a/src/nbl/video/CVulkanLogicalDevice.cpp +++ b/src/nbl/video/CVulkanLogicalDevice.cpp @@ -635,12 +635,15 @@ core::smart_refctd_ptr CVulkanLogicalDevice::createDescriptorPo return nullptr; } +// a lot of empirical research went into defining this constant +constexpr uint32_t MaxDescriptorSetAsWrites = 69u; + void CVulkanLogicalDevice::updateDescriptorSets_impl(const SUpdateDescriptorSetsParams& params) { // Each pNext member of any structure (including this one) in the pNext chain must be either NULL or a pointer to a valid instance of // VkWriteDescriptorSetAccelerationStructureKHR, VkWriteDescriptorSetAccelerationStructureNV, or VkWriteDescriptorSetInlineUniformBlockEXT core::vector vk_writeDescriptorSets(params.writes.size(),{VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,nullptr}); - core::vector vk_writeDescriptorSetAS(69u,{VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR,nullptr}); + core::vector vk_writeDescriptorSetAS(MaxDescriptorSetAsWrites,{VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR,nullptr}); core::vector vk_bufferInfos(params.bufferCount); core::vector vk_imageInfos(params.imageCount); @@ -735,7 +738,7 @@ void CVulkanLogicalDevice::nullifyDescriptors_impl(const std::span vk_writeDescriptorSets(drops.size(),{VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,nullptr}); - core::vector vk_writeDescriptorSetAS(69u,{VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR,nullptr}); + core::vector vk_writeDescriptorSetAS(MaxDescriptorSetAsWrites,{VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR,nullptr}); size_t maxSize = 0; for (auto i = 0; i < drops.size(); i++) @@ -791,6 +794,7 @@ void CVulkanLogicalDevice::nullifyDescriptors_impl(const std::spanaccelerationStructureCount = write.count; outWriteAS->pAccelerationStructures = reinterpret_cast(nullDescriptors.data()); + outWrite->pNext = outWriteAS++; break; default: assert(!"Invalid code path."); diff --git a/src/nbl/video/ILogicalDevice.cpp b/src/nbl/video/ILogicalDevice.cpp index 3f00a80cfb..2c852c7631 100644 --- a/src/nbl/video/ILogicalDevice.cpp +++ b/src/nbl/video/ILogicalDevice.cpp @@ -451,6 +451,9 @@ bool ILogicalDevice::nullifyDescriptors(const std::spanwasCreatedBy(this)) return false; + // (no binding) + if (ds->getBindingType(drop.binding) == asset::IDescriptor::E_TYPE::ET_COUNT) + return false; } for (const auto& drop : dropDescriptors)