Skip to content

Commit 44fee81

Browse files
bunch of QOL improvements for handling null descriptor layouts in arrays
P.S. temporarily disabled queue cap checks in IGPUObjectFromAssetConverter
1 parent e9ee888 commit 44fee81

File tree

4 files changed

+32
-16
lines changed

4 files changed

+32
-16
lines changed

include/nbl/video/ILogicalDevice.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,11 @@ class NBL_API2 ILogicalDevice : public core::IReferenceCounted, public IDeviceMe
244244

245245
core::smart_refctd_ptr<IDescriptorPool> createDescriptorPoolForDSLayouts(const IDescriptorPool::E_CREATE_FLAGS flags, const IGPUDescriptorSetLayout* const* const begin, const IGPUDescriptorSetLayout* const* const end, const uint32_t* setCounts=nullptr)
246246
{
247-
IDescriptorPool::SCreateInfo createInfo;
247+
IDescriptorPool::SCreateInfo createInfo = {};
248248

249249
auto setCountsIt = setCounts;
250250
for (auto* curLayout = begin; curLayout!=end; curLayout++,setCountsIt++)
251+
if (*curLayout)
251252
{
252253
const auto setCount = setCounts ? (*setCountsIt):1u;
253254
createInfo.maxSets += setCount;

include/nbl/video/utilities/IGPUObjectFromAssetConverter.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,13 @@ class IGPUObjectFromAssetConverter
303303
bool computeQueueSupportsGraphics(const SParams& _params)
304304
{
305305
// assert that ComputeQueue also supports Graphics
306-
const uint32_t transferFamIx = _params.perQueue[EQU_TRANSFER].queue->getFamilyIndex();
306+
const uint32_t transferFamIx = _params.perQueue[EQU_TRANSFER].queue ? _params.perQueue[EQU_TRANSFER].queue->getFamilyIndex():~0u;
307307
const uint32_t computeFamIx = _params.perQueue[EQU_COMPUTE].queue ? _params.perQueue[EQU_COMPUTE].queue->getFamilyIndex() : transferFamIx;
308308

309309
auto queueFamProps = _params.device->getPhysicalDevice()->getQueueFamilyProperties();
310+
if (computeFamIx>=queueFamProps.size())
311+
return true; // no queue specified
312+
310313
const auto& familyProperty = queueFamProps.begin()[computeFamIx];
311314
bool hasGraphicsFlag = (familyProperty.queueFlags & IPhysicalDevice::EQF_GRAPHICS_BIT).value != 0;
312315
return hasGraphicsFlag;

src/nbl/video/IDescriptorPool.cpp

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,43 +30,55 @@ IDescriptorPool::IDescriptorPool(core::smart_refctd_ptr<const ILogicalDevice>&&
3030

3131
uint32_t IDescriptorPool::createDescriptorSets(uint32_t count, const IGPUDescriptorSetLayout* const* layouts, core::smart_refctd_ptr<IGPUDescriptorSet>* output)
3232
{
33+
core::vector<uint32_t> reverseMap(count,count);
34+
35+
core::vector<const IGPUDescriptorSetLayout*> repackedLayouts;
3336
core::vector<SStorageOffsets> offsets;
37+
repackedLayouts.reserve(count);
3438
offsets.reserve(count);
35-
36-
for (uint32_t i = 0u; i < count; ++i)
39+
for (uint32_t i=0u; i<count; ++i)
3740
{
41+
if (!layouts[i])
42+
{
43+
m_logger.log("Null descriptor set layout found at index %u, skipping!", system::ILogger::ELL_PERFORMANCE, i);
44+
continue;
45+
}
46+
3847
if (!isCompatibleDevicewise(layouts[i]))
3948
{
40-
m_logger.log("Device-Incompatible descriptor set layout found at index %u. Sets for the layouts following this index will not be created.", system::ILogger::ELL_ERROR, i);
41-
break;
49+
m_logger.log("Device-Incompatible descriptor set layout found at index %u.", system::ILogger::ELL_ERROR, i);
50+
continue;
4251
}
4352

44-
if (!allocateStorageOffsets(offsets.emplace_back(), layouts[i]))
53+
if (!allocateStorageOffsets(offsets.emplace_back(),layouts[i]))
4554
{
46-
m_logger.log("Failed to allocate descriptor or descriptor set offsets in the pool's storage for descriptor set layout at index %u. Sets for the layouts following this index will not be created.", system::ILogger::ELL_WARNING, i);
55+
m_logger.log("Failed to allocate descriptor or descriptor set offsets in the pool's storage for descriptor set layout at index %u.", system::ILogger::ELL_WARNING, i);
4756
offsets.pop_back();
48-
break;
57+
continue;
4958
}
59+
reverseMap[i] = repackedLayouts.size();
60+
repackedLayouts.push_back(layouts[i]);
5061
}
51-
5262
auto successCount = offsets.size();
5363

54-
const bool creationSuccess = createDescriptorSets_impl(successCount, layouts, offsets.data(), output);
64+
const bool creationSuccess = createDescriptorSets_impl(successCount,repackedLayouts.data(),offsets.data(),output);
5565
if (creationSuccess)
5666
{
57-
for (uint32_t i = 0u; i < successCount; ++i)
67+
for (uint32_t i=0u; i<successCount; ++i)
5868
m_allocatedDescriptorSets[offsets[i].getSetOffset()] = output[i].get();
69+
// shuffle the outputs
70+
for (int32_t i=count-1; i>=0; i--)
71+
output[i] = reverseMap[i]<count ? output[reverseMap[i]]:nullptr;
5972
}
6073
else
6174
{
6275
// Free the allocated offsets for all the successfully allocated descriptor sets and the offset of the descriptor sets themselves.
63-
rewindLastStorageAllocations(successCount, offsets.data(), layouts);
76+
rewindLastStorageAllocations(successCount,offsets.data(),layouts);
77+
std::fill_n(output,count,nullptr);
6478
successCount = 0;
6579
}
6680

6781
assert(count >= successCount);
68-
std::fill_n(output + successCount, count - successCount, nullptr);
69-
7082
return successCount;
7183
}
7284

0 commit comments

Comments
 (0)