diff --git a/vulkano/src/image/mod.rs b/vulkano/src/image/mod.rs index d117cf21ff..8027746b7c 100644 --- a/vulkano/src/image/mod.rs +++ b/vulkano/src/image/mod.rs @@ -1300,7 +1300,7 @@ vulkan_enum! { /// ``` #[inline] pub fn max_mip_levels(extent: [u32; 3]) -> u32 { - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#resources-image-miplevel-sizing + // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#resources-image-mip-level-sizing // // This calculates `floor(log2(max(width, height, depth))) + 1` using fast integer operations. 32 - (extent[0] | extent[1] | extent[2]).leading_zeros() diff --git a/vulkano/src/image/sys.rs b/vulkano/src/image/sys.rs index 5c78575a66..7ccd1c5a77 100644 --- a/vulkano/src/image/sys.rs +++ b/vulkano/src/image/sys.rs @@ -737,9 +737,8 @@ impl RawImage { return Err(Box::new(ValidationError { problem: "`self.flags()` contains `ImageCreateFlags::DISJOINT`, and \ `self.tiling()` is `ImageTiling::Optimal` or \ - `ImageTiling::Linear`, but \ - the length of `allocations` does not equal \ - the number of planes in the format of the image" + `ImageTiling::Linear`, but the length of `allocations` does not \ + equal the number of planes in the format of the image" .into(), ..Default::default() })); @@ -749,10 +748,9 @@ impl RawImage { if allocations.len() != self.drm_format_modifier.unwrap().1 as usize { return Err(Box::new(ValidationError { problem: "`self.flags()` contains `ImageCreateFlags::DISJOINT`, and \ - `self.tiling()` is `ImageTiling::DrmFormatModifier`, but \ - the length of `allocations` does not equal \ - the number of memory planes of the DRM format modifier of the \ - image" + `self.tiling()` is `ImageTiling::DrmFormatModifier`, but the \ + length of `allocations` does not equal the number of memory planes \ + of the DRM format modifier of the image" .into(), ..Default::default() })); @@ -774,15 +772,37 @@ impl RawImage { .zip(self.memory_requirements.iter()) .enumerate() { - if allocation.allocation_type() == AllocationType::Linear { - return Err(Box::new(ValidationError { - problem: format!( - "`allocations[{}].allocation_type()` is `AllocationType::Linear`", - index - ) - .into(), - ..Default::default() - })); + match allocation.allocation_type() { + AllocationType::Unknown => { + // This allocation type is suitable for all image tilings by definition. + } + AllocationType::Linear => { + if self.tiling() != ImageTiling::Linear { + return Err(Box::new(ValidationError { + problem: format!( + "`allocations[{}].allocation_type()` is `AllocationType::Linear`, \ + but `self.tiling()` is not `ImageTiling::Linear`", + index + ) + .into(), + ..Default::default() + })); + } + } + AllocationType::NonLinear => { + if self.tiling() != ImageTiling::Optimal { + return Err(Box::new(ValidationError { + problem: format!( + "`allocations[{}].allocation_type()` is \ + `AllocationType::NonLinear`, but `self.tiling()` is not \ + `ImageTiling::Optimal`", + index + ) + .into(), + ..Default::default() + })); + } + } } let memory = allocation.device_memory(); diff --git a/vulkano/src/memory/allocator/suballocator.rs b/vulkano/src/memory/allocator/suballocator.rs index 1377e471c9..afe7c5af13 100644 --- a/vulkano/src/memory/allocator/suballocator.rs +++ b/vulkano/src/memory/allocator/suballocator.rs @@ -773,7 +773,7 @@ impl From for AllocationType { match tiling { ImageTiling::Optimal => AllocationType::NonLinear, ImageTiling::Linear => AllocationType::Linear, - ImageTiling::DrmFormatModifier => AllocationType::Linear, // TODO: improve + ImageTiling::DrmFormatModifier => AllocationType::Unknown, } } }