From 78a289b9ead1ca8fc00418cc27ea8a8c9f74ab14 Mon Sep 17 00:00:00 2001 From: Joshua Simmons Date: Thu, 17 Nov 2022 09:03:32 +0100 Subject: [PATCH] Improve default for ImageSubresourceRange Previously it was hard-coding 1 for the `mip_level_count` and `array_layer_count`, however we can use all bits set as a sentinel for all remaining mip levels / array layers. --- narcissus-gpu/src/lib.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/narcissus-gpu/src/lib.rs b/narcissus-gpu/src/lib.rs index 781483d..b76d0e6 100644 --- a/narcissus-gpu/src/lib.rs +++ b/narcissus-gpu/src/lib.rs @@ -139,14 +139,20 @@ pub struct ImageSubresourceRange { pub array_layer_count: u32, } +impl ImageSubresourceRange { + /// Constant that can be used to represent "all remaining mip levels / array layers" in an + /// `ImageSubresourceRange` + pub const ALL_REMAINING: u32 = !0; +} + impl Default for ImageSubresourceRange { fn default() -> Self { Self { aspect: ImageAspectFlags::COLOR, base_mip_level: 0, - mip_level_count: 1, + mip_level_count: ImageSubresourceRange::ALL_REMAINING, base_array_layer: 0, - array_layer_count: 1, + array_layer_count: ImageSubresourceRange::ALL_REMAINING, } } } -- 2.49.0