]> git.nega.tv - josh/narcissus/commitdiff
Improve default for ImageSubresourceRange
authorJoshua Simmons <josh@nega.tv>
Thu, 17 Nov 2022 08:03:32 +0000 (09:03 +0100)
committerJoshua Simmons <josh@nega.tv>
Thu, 17 Nov 2022 08:03:32 +0000 (09:03 +0100)
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

index 781483d8cafe9e7fffc7d20a9863b0460a8ee48b..b76d0e6c2c1b8192ea701d7efa3526f2b8af5086 100644 (file)
@@ -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,
         }
     }
 }