@@ -23,8 +23,7 @@ namespace nbl::video
23
23
size_t size = 0ull ;
24
24
core::bitflag<IDeviceMemoryAllocation::E_MEMORY_PROPERTY_FLAGS> memoryFlags = IDeviceMemoryAllocation::E_MEMORY_PROPERTY_FLAGS::EMPF_NONE;
25
25
};
26
- const MemoryRequirement* memoryRequirements = nullptr ;
27
- uint32_t memoryRequirementsCount = 0u ;
26
+ std::span<const MemoryRequirement> memoryRequirements = {};
28
27
29
28
struct QueueRequirement
30
29
{
@@ -49,8 +48,7 @@ namespace nbl::video
49
48
// family's transfer granularity needs to be <=
50
49
asset::VkExtent3D maxImageTransferGranularity = {0x80000000u ,0x80000000u ,0x80000000u };
51
50
};
52
- const QueueRequirement* queueRequirements = nullptr ;
53
- uint32_t queueRequirementsCount = 0u ;
51
+ std::span<const QueueRequirement> queueRequirements = {};
54
52
55
53
// To determine whether a queue family of a physical device supports presentation to a given surface
56
54
// See vkGetPhysicalDeviceSurfaceSupportKHR
@@ -60,8 +58,7 @@ namespace nbl::video
60
58
// 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
61
59
core::bitflag<IQueue::FAMILY_FLAGS> presentationQueueFlags = IQueue::FAMILY_FLAGS::NONE;
62
60
};
63
- const SurfaceCompatibility* requiredSurfaceCompatibilities = nullptr ;
64
- uint32_t requiredSurfaceCompatibilitiesCount = 0u ;
61
+ std::span<const SurfaceCompatibility> requiredSurfaceCompatibilities = {};
65
62
66
63
67
64
// sift through multiple devices
@@ -120,28 +117,24 @@ namespace nbl::video
120
117
return false ;
121
118
122
119
// Surface Compatibility
123
- if (requiredSurfaceCompatibilities != nullptr )
120
+ for ( const auto & requiredSurfaceCompatibility : requiredSurfaceCompatibilities )
124
121
{
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 :)
130
124
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 ;
144
134
}
135
+
136
+ if (!physicalDeviceSupportsSurfaceWithQueueFlags)
137
+ return false ;
145
138
}
146
139
147
140
// Memory Requirements Checking:
@@ -155,25 +148,23 @@ namespace nbl::video
155
148
}
156
149
// over-estimation, Not exact
157
150
// 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 )
159
152
{
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 )
165
158
return false ;
166
159
}
167
160
168
161
// Queue Requirements Checking:
169
162
// over-estimation, Not exact
170
163
// 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 )
172
165
{
173
- const auto & queueReqs = queueRequirements[q];
174
166
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)
177
168
{
178
169
const auto & queueFamilyProps = queueProps[qfam];
179
170
if (queueReqs.familyMatches (queueFamilyProps))
0 commit comments