Skip to content

Commit 215df72

Browse files
Make the SPhysicalDeviceFilter use spans for requirement arrays.
Adjust working examples accordingly Also correct bad DXC merge
1 parent b1bb802 commit 215df72

File tree

3 files changed

+28
-37
lines changed

3 files changed

+28
-37
lines changed

3rdparty/dxc/dxc

Submodule dxc updated 1614 files

include/nbl/video/utilities/SPhysicalDeviceFilter.h

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ namespace nbl::video
2323
size_t size = 0ull;
2424
core::bitflag<IDeviceMemoryAllocation::E_MEMORY_PROPERTY_FLAGS> memoryFlags = IDeviceMemoryAllocation::E_MEMORY_PROPERTY_FLAGS::EMPF_NONE;
2525
};
26-
const MemoryRequirement* memoryRequirements = nullptr;
27-
uint32_t memoryRequirementsCount = 0u;
26+
std::span<const MemoryRequirement> memoryRequirements = {};
2827

2928
struct QueueRequirement
3029
{
@@ -49,8 +48,7 @@ namespace nbl::video
4948
// family's transfer granularity needs to be <=
5049
asset::VkExtent3D maxImageTransferGranularity = {0x80000000u,0x80000000u,0x80000000u};
5150
};
52-
const QueueRequirement* queueRequirements = nullptr;
53-
uint32_t queueRequirementsCount = 0u;
51+
std::span<const QueueRequirement> queueRequirements = {};
5452

5553
// To determine whether a queue family of a physical device supports presentation to a given surface
5654
// See vkGetPhysicalDeviceSurfaceSupportKHR
@@ -60,8 +58,7 @@ namespace nbl::video
6058
// Setting this to `EQF_NONE` means it sufffices to find any queue family that can present to this surface, regardless of flags it might have
6159
core::bitflag<IQueue::FAMILY_FLAGS> presentationQueueFlags = IQueue::FAMILY_FLAGS::NONE;
6260
};
63-
const SurfaceCompatibility* requiredSurfaceCompatibilities = nullptr;
64-
uint32_t requiredSurfaceCompatibilitiesCount = 0u;
61+
std::span<const SurfaceCompatibility> requiredSurfaceCompatibilities = {};
6562

6663

6764
// sift through multiple devices
@@ -120,28 +117,24 @@ namespace nbl::video
120117
return false;
121118

122119
// Surface Compatibility
123-
if (requiredSurfaceCompatibilities != nullptr)
120+
for (const auto& requiredSurfaceCompatibility : requiredSurfaceCompatibilities)
124121
{
125-
for (uint32_t i = 0u; i < requiredSurfaceCompatibilitiesCount; ++i)
126-
{
127-
const auto& requiredSurfaceCompatibility = requiredSurfaceCompatibilities[i];
128-
if (requiredSurfaceCompatibility.surface == nullptr)
129-
continue; // we don't care about compatibility with a nullptr surface :)
122+
if (requiredSurfaceCompatibility.surface == nullptr)
123+
continue; // we don't care about compatibility with a nullptr surface :)
130124

131-
const auto& queueFamilyProperties = physicalDevice->getQueueFamilyProperties();
132-
133-
bool physicalDeviceSupportsSurfaceWithQueueFlags = false;
134-
for (uint32_t qfam = 0u; qfam < queueFamilyProperties.size(); ++qfam)
135-
{
136-
const auto& familyProperty = queueFamilyProperties[qfam];
137-
if(familyProperty.queueFlags.hasFlags(requiredSurfaceCompatibility.presentationQueueFlags))
138-
if(requiredSurfaceCompatibility.surface->isSupportedForPhysicalDevice(physicalDevice, qfam))
139-
physicalDeviceSupportsSurfaceWithQueueFlags = true;
140-
}
141-
142-
if(!physicalDeviceSupportsSurfaceWithQueueFlags)
143-
return false;
125+
const auto& queueFamilyProperties = physicalDevice->getQueueFamilyProperties();
126+
127+
bool physicalDeviceSupportsSurfaceWithQueueFlags = false;
128+
for (uint32_t qfam = 0u; qfam < queueFamilyProperties.size(); ++qfam)
129+
{
130+
const auto& familyProperty = queueFamilyProperties[qfam];
131+
if(familyProperty.queueFlags.hasFlags(requiredSurfaceCompatibility.presentationQueueFlags))
132+
if(requiredSurfaceCompatibility.surface->isSupportedForPhysicalDevice(physicalDevice, qfam))
133+
physicalDeviceSupportsSurfaceWithQueueFlags = true;
144134
}
135+
136+
if(!physicalDeviceSupportsSurfaceWithQueueFlags)
137+
return false;
145138
}
146139

147140
// Memory Requirements Checking:
@@ -155,25 +148,23 @@ namespace nbl::video
155148
}
156149
// over-estimation, Not exact
157150
// TODO: Exact or Better Logic -> try find a feasible fitting of requirements into heaps.
158-
for (uint32_t m = 0; m < memoryRequirementsCount; ++m)
151+
for (const auto& req : memoryRequirements)
159152
{
160-
size_t memSize = memoryRequirements[m].size;
161-
for (uint32_t h = 0; h < memoryProps.memoryHeapCount; ++h)
162-
if (heapFlags[h].hasFlags(memoryRequirements[m].memoryFlags))
163-
memSize = (memoryProps.memoryHeaps[h].size > memSize) ? 0ull : memSize - memoryProps.memoryHeaps[h].size;
164-
if (memSize > 0)
153+
size_t memSize = req.size;
154+
for (uint32_t h=0; h<memoryProps.memoryHeapCount; ++h)
155+
if (heapFlags[h].hasFlags(req.memoryFlags))
156+
memSize = memoryProps.memoryHeaps[h].size>memSize ? 0ull:(memSize-memoryProps.memoryHeaps[h].size);
157+
if (memSize>0)
165158
return false;
166159
}
167160

168161
// Queue Requirements Checking:
169162
// over-estimation, Not exact
170163
// TODO: Exact or Better Logic -> try find a feasible fitting of requirements into queue families.
171-
for (uint32_t q = 0; q < queueRequirementsCount; ++q)
164+
for (const auto& queueReqs : queueRequirements)
172165
{
173-
const auto& queueReqs = queueRequirements[q];
174166
uint32_t queueCount = queueReqs.queueCount;
175-
176-
for (uint32_t qfam = 0; qfam < queueProps.size(); ++qfam)
167+
for (uint32_t qfam=0; qfam<queueProps.size(); ++qfam)
177168
{
178169
const auto& queueFamilyProps = queueProps[qfam];
179170
if (queueReqs.familyMatches(queueFamilyProps))

0 commit comments

Comments
 (0)