File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -227,11 +227,13 @@ struct Image {
227
227
}
228
228
229
229
[[nodiscard]] u32 NumLayers () const noexcept {
230
+ // Depth is the number of layers for Array images.
230
231
u32 slices = depth + 1 ;
231
- const auto img_type = static_cast < ImageType>(type);
232
- if (img_type == ImageType::Color3D) {
232
+ if ( GetType () == ImageType::Color3D) {
233
+ // Depth is the actual texture depth for 3D images.
233
234
slices = 1 ;
234
- } else if (img_type == ImageType::Cube) {
235
+ } else if (IsCube ()) {
236
+ // Depth is the number of full cubes for Cube images.
235
237
slices *= 6 ;
236
238
}
237
239
if (pow2pad) {
@@ -315,7 +317,9 @@ struct Image {
315
317
case ImageType::Color2DMsaaArray:
316
318
return 1 ;
317
319
default :
318
- return last_level - base_level + 1 ;
320
+ // Constrain to actual number of available levels.
321
+ const auto max_level = std::min<u32 >(last_level + 1 , NumLevels ());
322
+ return max_level > base_level ? max_level - base_level : 1 ;
319
323
}
320
324
}
321
325
@@ -327,7 +331,9 @@ struct Image {
327
331
case ImageType::Color3D:
328
332
return 1 ;
329
333
default :
330
- return last_array - base_array + 1 ;
334
+ // Constrain to actual number of available layers.
335
+ const auto max_array = std::min<u32 >(last_array + 1 , NumLayers ());
336
+ return max_array > base_array ? max_array - base_array : 1 ;
331
337
}
332
338
}
333
339
};
You can’t perform that action at this time.
0 commit comments