@@ -1714,20 +1714,22 @@ inline created_gpu_object_array<asset::ICPUDescriptorSet> IGPUObjectFromAssetCon
1714
1714
for (uint32_t t = 0u ; t < static_cast <uint32_t >(asset::IDescriptor::E_TYPE::ET_COUNT); ++t)
1715
1715
{
1716
1716
const auto type = static_cast <asset::IDescriptor::E_TYPE>(t);
1717
- const auto activeBindingCount = cpuds->getLayout ()->getDescriptorRedirect (type).getBindingCount ();
1718
1717
1719
- for (uint32_t b = 0u ; b < activeBindingCount; ++b)
1718
+ const auto & descriptorBindingRedirect = cpuds->getLayout ()->getDescriptorRedirect (type);
1719
+ const auto & mutableSamplerBindingRedirect = cpuds->getLayout ()->getMutableSamplerRedirect ();
1720
+
1721
+ for (uint32_t b = 0u ; b < descriptorBindingRedirect.getBindingCount (); ++b)
1720
1722
{
1721
1723
write_it->dstSet = gpuds;
1722
- write_it->binding = cpuds-> getLayout ()-> getDescriptorRedirect (type) .getBindingNumber (b).data ;
1724
+ write_it->binding = descriptorBindingRedirect .getBindingNumber (b).data ;
1723
1725
write_it->arrayElement = 0u ;
1724
1726
1725
- const uint32_t descriptorCount = cpuds-> getLayout ()-> getDescriptorRedirect (type) .getCount (b);
1727
+ const uint32_t descriptorCount = descriptorBindingRedirect .getCount (b);
1726
1728
write_it->count = descriptorCount;
1727
1729
write_it->descriptorType = type;
1728
1730
write_it->info = &(*info);
1729
1731
1730
- const uint32_t offset = cpuds-> getLayout ()-> getDescriptorRedirect (type) .getStorageOffset (b).data ;
1732
+ const uint32_t offset = descriptorBindingRedirect .getStorageOffset (b).data ;
1731
1733
1732
1734
// It is better to use getDescriptorInfoStorage over getDescriptorInfos, because the latter does a binary search
1733
1735
// over the bindings, which is not really required given we have the index of binding number (since we're iterating
@@ -1764,22 +1766,14 @@ inline created_gpu_object_array<asset::ICPUDescriptorSet> IGPUObjectFromAssetCon
1764
1766
{
1765
1767
info->desc = imgViewRedirs[ivi] >= gpuImgViews->size () ? nullptr : gpuImgViews->operator [](imgViewRedirs[ivi]);
1766
1768
++ivi;
1767
- // TODO: This should be set in the loader (or whoever is creating
1768
- // the descriptor)
1769
- if (info->info .image .imageLayout == asset::IImage::EL_UNDEFINED)
1769
+ info->info .image .imageLayout = descriptorInfos[offset + d].info .image .imageLayout ;
1770
+ assert (info->info .image .imageLayout != asset::IImage::EL_UNDEFINED);
1771
+
1772
+ if (!isStorageImgDesc (type))
1770
1773
{
1771
- if (isStorageImgDesc (type))
1772
- {
1773
- info->info .image .imageLayout = asset::IImage::EL_GENERAL;
1774
- }
1775
- else
1776
- {
1777
- const auto imageFormat = static_cast <asset::ICPUImageView*>(info->desc .get ())->getCreationParameters ().format ;
1778
- info->info .image .imageLayout = isDepthOrStencilFormat (imageFormat) ? asset::IImage::EL_DEPTH_STENCIL_READ_ONLY_OPTIMAL : asset::IImage::EL_SHADER_READ_ONLY_OPTIMAL;
1779
-
1780
- if (descriptorInfos.begin ()[offset + d].info .image .sampler )
1781
- info->info .image .sampler = gpuSamplers->operator [](smplrRedirs[si++]);
1782
- }
1774
+ const bool isMutableSamplerBinding = (mutableSamplerBindingRedirect.searchForBinding (asset::ICPUDescriptorSetLayout::CBindingRedirect::binding_number_t { write_it->binding }) != mutableSamplerBindingRedirect.Invalid );
1775
+ if (descriptorInfos.begin ()[offset + d].info .image .sampler && isMutableSamplerBinding)
1776
+ info->info .image .sampler = gpuSamplers->operator [](smplrRedirs[si++]);
1783
1777
}
1784
1778
}
1785
1779
allDescriptorsPresent = allDescriptorsPresent && info->desc ;
0 commit comments