@@ -38,28 +38,30 @@ IGPUDescriptorSet::~IGPUDescriptorSet()
38
38
m_pool->deleteSetStorage (m_storageOffsets.getSetOffset ());
39
39
}
40
40
41
- asset::IDescriptor::E_TYPE IGPUDescriptorSet::validateWrite (const IGPUDescriptorSet::SWriteDescriptorSet& write) const
41
+ IGPUDescriptorSet::SWriteValidationResult IGPUDescriptorSet::validateWrite (const IGPUDescriptorSet::SWriteDescriptorSet& write) const
42
42
{
43
43
assert (write.dstSet == this );
44
44
45
45
const char * debugName = getDebugName ();
46
46
using redirect_t = IGPUDescriptorSetLayout::CBindingRedirect;
47
47
const redirect_t ::binding_number_t bindingNumber (write.binding );
48
48
49
+ SWriteValidationResult validationResult;
50
+
49
51
// screw it, we'll need to replace the descriptor writing with update templates of descriptor buffer soon anyway
50
- redirect_t ::storage_range_index_t descriptorRedirectBindingIndex;
51
- const auto descriptorType = getBindingType (bindingNumber, descriptorRedirectBindingIndex);
52
+ const auto descriptorType = getBindingType (bindingNumber, validationResult.descriptorRedirectBindingIndex );
52
53
if (asset::IDescriptor::E_TYPE::ET_COUNT == descriptorType)
53
54
{
54
55
if (debugName)
55
56
m_pool->m_logger .log (" Descriptor set (%s, %p) has no binding %u." , system::ILogger::ELL_ERROR, debugName, this , write.binding );
56
57
else
57
58
m_pool->m_logger .log (" Descriptor set (%p) has no binding %u." , system::ILogger::ELL_ERROR, this , write.binding );
58
59
59
- return asset::IDescriptor::E_TYPE::ET_COUNT;
60
+ validationResult.type = asset::IDescriptor::E_TYPE::ET_COUNT;
61
+ return validationResult;
60
62
}
61
63
62
- auto * descriptors = getDescriptors (descriptorType, descriptorRedirectBindingIndex);
64
+ auto * descriptors = getDescriptors (descriptorType, validationResult. descriptorRedirectBindingIndex );
63
65
// Left this check, but if the above passed then this should never be nullptr I believe
64
66
if (!descriptors)
65
67
{
@@ -68,7 +70,8 @@ asset::IDescriptor::E_TYPE IGPUDescriptorSet::validateWrite(const IGPUDescriptor
68
70
else
69
71
m_pool->m_logger .log (" Descriptor set (%p) doesn't allow descriptor of such type at binding %u." , system::ILogger::ELL_ERROR, this , write.binding );
70
72
71
- return asset::IDescriptor::E_TYPE::ET_COUNT;
73
+ validationResult.type = asset::IDescriptor::E_TYPE::ET_COUNT;
74
+ return validationResult;
72
75
}
73
76
74
77
for (uint32_t i = 0 ; i < write.count ; ++i)
@@ -80,7 +83,8 @@ asset::IDescriptor::E_TYPE IGPUDescriptorSet::validateWrite(const IGPUDescriptor
80
83
else
81
84
m_pool->m_logger .log (" Descriptor set (%p) doesn't allow descriptor of such type category at binding %u." , system::ILogger::ELL_ERROR, this , write.binding );
82
85
83
- return asset::IDescriptor::E_TYPE::ET_COUNT;
86
+ validationResult.type = asset::IDescriptor::E_TYPE::ET_COUNT;
87
+ return validationResult;
84
88
}
85
89
}
86
90
@@ -92,7 +96,8 @@ asset::IDescriptor::E_TYPE IGPUDescriptorSet::validateWrite(const IGPUDescriptor
92
96
m_pool->m_logger .log (" Trying to write samplers at binding %u of Descriptor set (%s, %p), but those are immutable." , system::ILogger::ELL_ERROR, write.binding , debugName, this );
93
97
else
94
98
m_pool->m_logger .log (" Trying to write samplers at binding %u of Descriptor set (%p), but those are immutable." , system::ILogger::ELL_ERROR, write.binding , this );
95
- return asset::IDescriptor::E_TYPE::ET_COUNT;
99
+ validationResult.type = asset::IDescriptor::E_TYPE::ET_COUNT;
100
+ return validationResult;
96
101
}
97
102
98
103
for (uint32_t i=0 ; i<write.count ; ++i)
@@ -103,19 +108,23 @@ asset::IDescriptor::E_TYPE IGPUDescriptorSet::validateWrite(const IGPUDescriptor
103
108
m_pool->m_logger .log (" Null sampler provided when trying to write descriptor set (%s, %p) at binding %u. All writes should provide a sampler." , system::ILogger::ELL_ERROR, debugName, this , write.binding );
104
109
else
105
110
m_pool->m_logger .log (" Null sampler provided when trying to write descriptor set (%p) at binding %u. All writes should provide a sampler." , system::ILogger::ELL_ERROR, this , write.binding );
106
- return asset::IDescriptor::E_TYPE::ET_COUNT;
111
+ validationResult.type = asset::IDescriptor::E_TYPE::ET_COUNT;
112
+ return validationResult;
107
113
}
108
114
if (not sampler->isCompatibleDevicewise (write.dstSet )) {
109
115
const char * samplerDebugName = sampler->getDebugName ();
110
116
if (samplerDebugName && debugName)
111
117
m_pool->m_logger .log (" Sampler (%s, %p) does not exist or is not device-compatible with descriptor set (%s, %p)." , system::ILogger::ELL_ERROR, samplerDebugName, sampler, debugName, this );
112
118
else
113
119
m_pool->m_logger .log (" Sampler (%p) does not exist or is not device-compatible with descriptor set (%p)." , system::ILogger::ELL_ERROR, sampler, this );
114
- return asset::IDescriptor::E_TYPE::ET_COUNT;
120
+ validationResult.type = asset::IDescriptor::E_TYPE::ET_COUNT;
121
+ return validationResult;
115
122
}
116
123
}
117
124
if (descriptorType == asset::IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER) {
118
- core::smart_refctd_ptr<video::IGPUSampler>* mutableSamplers = getMutableCombinedSamplers (bindingNumber);
125
+ validationResult.mutableSamplerRedirectBindingIndex = getLayout ()->getMutableCombinedSamplerRedirect ().findBindingStorageIndex (bindingNumber);
126
+ auto mutableSamplers = getMutableCombinedSamplers (validationResult.mutableSamplerRedirectBindingIndex );
127
+
119
128
// Should never reach here, the GetTypeCategory check earlier should ensure that
120
129
if (!mutableSamplers)
121
130
{
@@ -124,7 +133,8 @@ asset::IDescriptor::E_TYPE IGPUDescriptorSet::validateWrite(const IGPUDescriptor
124
133
else
125
134
m_pool->m_logger .log (" Descriptor set (%p) only allows standalone mutable samplers at binding %u (no combined image samplers)." , system::ILogger::ELL_ERROR, this , write.binding );
126
135
127
- return asset::IDescriptor::E_TYPE::ET_COUNT;
136
+ validationResult.type = asset::IDescriptor::E_TYPE::ET_COUNT;
137
+ return validationResult;
128
138
}
129
139
}
130
140
}
@@ -143,24 +153,22 @@ asset::IDescriptor::E_TYPE IGPUDescriptorSet::validateWrite(const IGPUDescriptor
143
153
}
144
154
}
145
155
146
- return descriptorType;
156
+ validationResult.type = descriptorType;
157
+ return validationResult;
147
158
}
148
159
149
- void IGPUDescriptorSet::processWrite (const IGPUDescriptorSet::SWriteDescriptorSet& write, const asset::IDescriptor::E_TYPE type )
160
+ void IGPUDescriptorSet::processWrite (const IGPUDescriptorSet::SWriteDescriptorSet& write, const SWriteValidationResult& validationResult )
150
161
{
151
162
assert (write.dstSet == this );
152
163
153
- using redirect_t = IGPUDescriptorSetLayout::CBindingRedirect;
154
- const redirect_t ::binding_number_t bindingNumber (write.binding );
155
- auto descriptorRedirectBindingIndex = getLayout ()->getDescriptorRedirect (type).findBindingStorageIndex (bindingNumber);
156
- auto * descriptors = getDescriptors (type, descriptorRedirectBindingIndex);
164
+ auto * descriptors = getDescriptors (validationResult.type , validationResult.descriptorRedirectBindingIndex );
157
165
assert (descriptors);
158
166
159
167
core::smart_refctd_ptr<video::IGPUSampler>* mutableSamplers = nullptr ;
160
- if (type == asset::IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER
168
+ if (validationResult. type == asset::IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER
161
169
and write.info ->info .combinedImageSampler .sampler )
162
170
{
163
- mutableSamplers = getMutableCombinedSamplers (bindingNumber );
171
+ mutableSamplers = getMutableCombinedSamplers (validationResult. mutableSamplerRedirectBindingIndex );
164
172
assert (mutableSamplers);
165
173
}
166
174
@@ -171,8 +179,8 @@ void IGPUDescriptorSet::processWrite(const IGPUDescriptorSet::SWriteDescriptorSe
171
179
if (mutableSamplers)
172
180
mutableSamplers[j] = write.info [j].info .combinedImageSampler .sampler ;
173
181
}
174
- auto & bindingRedirect = m_layout->getDescriptorRedirect (type);
175
- auto bindingCreateFlags = bindingRedirect.getCreateFlags (descriptorRedirectBindingIndex);
182
+ auto & bindingRedirect = m_layout->getDescriptorRedirect (validationResult. type );
183
+ auto bindingCreateFlags = bindingRedirect.getCreateFlags (validationResult. descriptorRedirectBindingIndex );
176
184
if (IGPUDescriptorSetLayout::writeIncrementsVersion (bindingCreateFlags))
177
185
incrementVersion ();
178
186
}
@@ -207,7 +215,7 @@ void IGPUDescriptorSet::dropDescriptors(const IGPUDescriptorSet::SDropDescriptor
207
215
incrementVersion ();
208
216
}
209
217
210
- bool IGPUDescriptorSet::validateCopy (const IGPUDescriptorSet::SCopyDescriptorSet& copy) const
218
+ IGPUDescriptorSet::SCopyValidationResult IGPUDescriptorSet::validateCopy (const IGPUDescriptorSet::SCopyDescriptorSet& copy) const
211
219
{
212
220
assert (copy.dstSet == this );
213
221
@@ -218,15 +226,35 @@ bool IGPUDescriptorSet::validateCopy(const IGPUDescriptorSet::SCopyDescriptorSet
218
226
const char * srcDebugName = copy.srcSet ->getDebugName ();
219
227
const char * dstDebugName = copy.dstSet ->getDebugName ();
220
228
229
+ const auto srcLayout = copy.srcSet ->getLayout ();
230
+ const auto dstLayout = copy.dstSet ->getLayout ();
231
+
232
+ SCopyValidationResult validationResult;
233
+
221
234
for (uint32_t t = 0 ; t < static_cast <uint32_t >(asset::IDescriptor::E_TYPE::ET_COUNT); ++t)
222
235
{
223
- const auto type = static_cast <asset::IDescriptor::E_TYPE>(t);
236
+ validationResult. type = static_cast <asset::IDescriptor::E_TYPE>(t);
224
237
225
- auto * srcDescriptors = copy.srcSet ->getDescriptors (type, srcBindingNumber);
226
- auto * dstDescriptors = copy.dstSet ->getDescriptors (type, dstBindingNumber);
238
+ validationResult.srcDescriptorRedirectBindingIndex = srcLayout->getDescriptorRedirect (validationResult.type ).findBindingStorageIndex (srcBindingNumber);
239
+ validationResult.dstDescriptorRedirectBindingIndex = dstLayout->getDescriptorRedirect (validationResult.type ).findBindingStorageIndex (dstBindingNumber);
240
+ auto * srcDescriptors = copy.srcSet ->getDescriptors (validationResult.type , validationResult.srcDescriptorRedirectBindingIndex );
241
+ auto * dstDescriptors = copy.dstSet ->getDescriptors (validationResult.type , validationResult.dstDescriptorRedirectBindingIndex );
227
242
228
- auto * srcSamplers = type != asset::IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER ? nullptr : copy.srcSet ->getMutableCombinedSamplers (srcBindingNumber);
229
- auto * dstSamplers = type != asset::IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER ? nullptr : copy.dstSet ->getMutableCombinedSamplers (dstBindingNumber);
243
+ if (!srcDescriptors)
244
+ {
245
+ assert (!dstDescriptors);
246
+ continue ;
247
+ }
248
+ assert (dstDescriptors);
249
+
250
+ core::smart_refctd_ptr<IGPUSampler> *srcSamplers = nullptr , *dstSamplers = nullptr ;
251
+ if (asset::IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER == validationResult.type )
252
+ {
253
+ validationResult.srcMutableSamplerRedirectBindingIndex = srcLayout->getMutableCombinedSamplerRedirect ().findBindingStorageIndex (srcBindingNumber);
254
+ validationResult.dstMutableSamplerRedirectBindingIndex = dstLayout->getMutableCombinedSamplerRedirect ().findBindingStorageIndex (dstBindingNumber);
255
+ srcSamplers = copy.srcSet ->getMutableCombinedSamplers (validationResult.srcMutableSamplerRedirectBindingIndex );
256
+ dstSamplers = copy.dstSet ->getMutableCombinedSamplers (validationResult.dstMutableSamplerRedirectBindingIndex );
257
+ }
230
258
231
259
if ((!srcDescriptors != !dstDescriptors) || (!srcSamplers != !dstSamplers))
232
260
{
@@ -235,53 +263,34 @@ bool IGPUDescriptorSet::validateCopy(const IGPUDescriptorSet::SCopyDescriptorSet
235
263
else
236
264
m_pool->m_logger .log (" Incompatible copy from descriptor set (%p) at binding %u to descriptor set (%p) at binding %u." , system::ILogger::ELL_ERROR, copy.srcSet , copy.srcBinding , copy.dstSet , copy.dstBinding );
237
265
238
- return false ;
266
+ validationResult.type = asset::IDescriptor::E_TYPE::ET_COUNT;
267
+ return validationResult;
239
268
}
240
269
}
241
270
242
- return true ;
271
+ return validationResult ;
243
272
}
244
273
245
- void IGPUDescriptorSet::processCopy (const IGPUDescriptorSet::SCopyDescriptorSet& copy)
274
+ void IGPUDescriptorSet::processCopy (const IGPUDescriptorSet::SCopyDescriptorSet& copy, const SCopyValidationResult& validationResult )
246
275
{
247
276
assert (copy.dstSet == this );
248
277
249
- using redirect_t = IGPUDescriptorSetLayout::CBindingRedirect;
250
- redirect_t ::binding_number_t srcBindingNumber (copy.srcBinding );
251
- redirect_t ::binding_number_t dstBindingNumber (copy.dstBinding );
278
+ auto & bindingRedirect = m_layout->getDescriptorRedirect (validationResult.type );
252
279
253
- for (uint32_t t = 0 ; t < static_cast <uint32_t >(asset::IDescriptor::E_TYPE::ET_COUNT); ++t)
254
- {
255
- const auto type = static_cast <asset::IDescriptor::E_TYPE>(t);
256
- auto & bindingRedirect = m_layout->getDescriptorRedirect (type);
280
+ auto * srcDescriptors = copy.srcSet ->getDescriptors (validationResult.type , validationResult.srcDescriptorRedirectBindingIndex );
281
+ auto * dstDescriptors = copy.dstSet ->getDescriptors (validationResult.type , validationResult.dstDescriptorRedirectBindingIndex );
257
282
258
- auto * srcDescriptors = copy.srcSet ->getDescriptors (type, srcBindingNumber);
259
- // We can do this because dstSet === this as asserted at the start
260
- auto descriptorRedirectBindingIndex = bindingRedirect.findBindingStorageIndex (dstBindingNumber);
261
- auto * dstDescriptors = copy.dstSet ->getDescriptors (type, descriptorRedirectBindingIndex);
262
- if (!srcDescriptors)
263
- {
264
- assert (!dstDescriptors);
265
- continue ;
266
- }
267
- assert (dstDescriptors);
268
-
269
- auto * srcSamplers = type != asset::IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER ? nullptr : copy.srcSet ->getMutableCombinedSamplers (srcBindingNumber);
270
- auto * dstSamplers = type != asset::IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER ? nullptr : copy.dstSet ->getMutableCombinedSamplers (dstBindingNumber);
271
- assert (!(!srcSamplers != !dstSamplers));
272
-
273
-
274
- auto bindingCreateFlags = bindingRedirect.getCreateFlags (descriptorRedirectBindingIndex);
275
- if (IGPUDescriptorSetLayout::writeIncrementsVersion (bindingCreateFlags))
276
- incrementVersion ();
277
-
278
- std::copy_n (srcDescriptors, copy.count , dstDescriptors);
283
+ auto * srcSamplers = validationResult.type != asset::IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER ? nullptr : copy.srcSet ->getMutableCombinedSamplers (validationResult.srcMutableSamplerRedirectBindingIndex );
284
+ auto * dstSamplers = validationResult.type != asset::IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER ? nullptr : copy.dstSet ->getMutableCombinedSamplers (validationResult.dstMutableSamplerRedirectBindingIndex );
285
+
286
+ auto bindingCreateFlags = bindingRedirect.getCreateFlags (validationResult.dstDescriptorRedirectBindingIndex );
287
+ if (IGPUDescriptorSetLayout::writeIncrementsVersion (bindingCreateFlags))
288
+ incrementVersion ();
279
289
280
- if (srcSamplers && dstSamplers)
281
- std::copy_n (srcSamplers, copy.count , dstSamplers);
290
+ std::copy_n (srcDescriptors, copy.count , dstDescriptors);
282
291
283
- break ;
284
- }
292
+ if (srcSamplers && dstSamplers)
293
+ std::copy_n (srcSamplers, copy. count , dstSamplers);
285
294
}
286
295
287
296
}
0 commit comments