From ec94c62dcef0e380f90278aaacff006d9da19187 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Sun, 8 Nov 2026 12:56:53 -0800 Subject: [PATCH] heap depth textures: a merge's keep holds the heap's bytes, not the image's A 2-slice Depth32Float 64x64 x2 multisample texture in a Shared placement heap on ANV (Iris Xe, RPL-P, Mesa 26.2.6) lost the samples a blit wrote into one slice: 16384 of 16384 were off Metal's tiles after the merge back, while a read straight from the image matched. The heap's bytes held 0xee before the blit. The copy in hands the image 0xeeeeeeee, a float outside [0, 1], which Vulkan leaves undefined in a depth image without VK_EXT_depth_range_unrestricted, and ANV stores 0.0. The merge's keep was moved out of the image (only drivers announced drawn-depth-copy kept the heap's bytes), so it held 0.0, and the merge kept the heap's 0xee in every byte of a written sample that equals 0.0's: a probe found 9155 0xee bytes left in the slice, the 9134 zero bytes of the samples plus 21 sample bytes that are 0xee, and no sample whole. Now a heap's tiled texture with a depth aspect, of any sample count, keeps the heap's bytes: the staging buffer its copy in filled where the keep follows it (WorkCounts::shadow_keeps_from_staging), else the heap's bytes themselves, and plans no moves out of the image for the keep. Every byte a command wrote is merged whatever the copy in changed; a value the copy in changed in a texel no command wrote is written back as stored, as a copy back writes it. That clamp is the device's: a heap's 32-bit float depth texture whose shadow copies the heap's bytes into its image now announces restricted-depth-upload as it is made, on a device without VK_EXT_depth_range_unrestricted whose driver is not measured to keep such a value (ANV; not MoltenVK, NVIDIA or lavapipe with the extension). Its declaration, docs/API.md's catalogue and a device-gap row in docs/FAST-PATHS.md say so. The measured drawn-depth-copy flag a multisample texture held for its keep is gone with its one reader; the announcement at making stays. heap_multisample_textures_keep_their_samples_in_metal_s_tiles now also checks, for each counted 32-bit float depth texture, restricted-depth-upload as it is made where the device clamps, and that a blit into one slice or aspect keeps from staging. Verification in the tip report. (cherry picked from commit 688e1dcc00ff67979833fdcbaf2f5484057e18a6) --- .../metal2vulkan-runtime/src/degradation.rs | 4 +- crates/metal2vulkan-runtime/src/shadow.rs | 33 ++++++---- .../metal2vulkan-runtime/src/shadow_merge.rs | 3 + crates/metal2vulkan-runtime/src/texture.rs | 65 ++++++++++++++----- .../metal2vulkan-runtime/src/texture/heap.rs | 4 ++ .../src/texture/heap_tiled.rs | 40 +++++++----- .../metal2vulkan-runtime/src/work_counts.rs | 3 +- .../src/runtime_lane/heap_textures.rs | 31 ++++++++- docs/API.md | 8 ++- docs/FAST-PATHS.md | 1 + 10 files changed, 140 insertions(+), 52 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/degradation.rs b/crates/metal2vulkan-runtime/src/degradation.rs index c8875c7a6..e59680414 100644 --- a/crates/metal2vulkan-runtime/src/degradation.rs +++ b/crates/metal2vulkan-runtime/src/degradation.rs @@ -884,7 +884,9 @@ degradations! { /// where Vulkan leaves a value outside `[0, 1]` undefined, whose driver is not measured to /// keep one (`DriverFact::DepthImageKeepsValuesOutsideUnitRange`). And a render pass's NaN /// clear depth on such a device, which Metal stores as `0x7fc00000`, cleared to 1.0 - /// (`nan_clear.rs`). + /// (`nan_clear.rs`). And a heap's texture of such a depth whose shadow's copies in move the + /// heap's bytes into its image, announced as it is made: its copies back write each value + /// as the image stored it, one no command wrote too (`texture/heap_tiled.rs`). RestrictedDepthUpload = "restricted-depth-upload", Precision, "a value outside [0, 1] may be stored clamped to [0, 1], where Metal's keeps it, so \ reads, samples, comparisons and depth tests of it can differ"; diff --git a/crates/metal2vulkan-runtime/src/shadow.rs b/crates/metal2vulkan-runtime/src/shadow.rs index 6ea2b52d7..1d911a7bf 100644 --- a/crates/metal2vulkan-runtime/src/shadow.rs +++ b/crates/metal2vulkan-runtime/src/shadow.rs @@ -1023,22 +1023,24 @@ impl ShadowCopies { /// Whether a merge's keep right after this shadow's copy in, with no copy of the shadow /// between, may copy the staging buffer that copy in filled /// ([`record_kept_from_staging`](Self::record_kept_from_staging)): a heap's tiled texture's - /// whose moves give back each byte they took (`HeapTiledCopies::moves_bits`). + /// whose moves give back each byte they took (`HeapTiledCopies::moves_bits`), or whose keep + /// holds the heap's bytes, a depth's (`HeapTiledCopies::takes_depth`). pub(super) fn keeps_from_staging(&self) -> bool { matches!( &self.source, ShadowSource::Bytes { target: ShadowTarget::Tiled { tiles, .. }, .. - } if tiles.moves_bits() + } if tiles.moves_bits() || tiles.takes_depth() ) } /// Record a merge's keep into `to` from `at` as a copy of the staging buffer, right after the /// shadow's copy in filled it with the heap's bytes and moved them into the image - /// ([`keeps_from_staging`](Self::keeps_from_staging)): the bytes a keep's move out of the - /// image would leave there ([`record_kept`](Self::record_kept)), the texture's bytes from its - /// first, without the move. Nothing for any other shadow. + /// ([`keeps_from_staging`](Self::keeps_from_staging)): the texture's bytes from its first as + /// the copy in took them, which a keep's move out of the image would leave there where the + /// moves give back each byte they took, without the move, and which a depth's keep holds + /// ([`record_kept`](Self::record_kept)). Nothing for any other shadow. /// /// # Safety /// @@ -1069,12 +1071,14 @@ impl ShadowCopies { /// Record a merge's keep of the shadow's texels into `to` from `at`, laid out as in the /// buffer from the texture's first byte (`shadow_merge.rs`): as - /// [`record_out`](Self::record_out) copies them; but where a heap's tiled texture's image - /// takes the bytes inexactly (`HeapTiledCopies::takes_inexactly`: a multisample depth the - /// driver's fragment depth changes), the heap's bytes themselves, so the merge writes each + /// [`record_out`](Self::record_out) copies them; but where a heap's tiled texture has a + /// depth aspect, whose moves into its image may change a value + /// (`HeapTiledCopies::takes_depth`: one outside `[0, 1]`, `restricted-depth-upload`, and + /// those `drawn-depth-copy` names), the heap's bytes themselves, so the merge writes each /// byte the image holds otherwise than the heap: every byte a command wrote, and the values - /// the copy in changed (the announced `drawn-depth-copy`), never a byte of the heap's in a - /// value a command wrote. + /// the copy in changed (both announced), never a byte of the heap's in a value a command + /// wrote. A keep of the image would hold the changed value, and keep the heap's byte in each + /// byte a command wrote that equals it. /// /// # Safety /// @@ -1092,7 +1096,7 @@ impl ShadowCopies { .. } = &self.source { - if tiles.takes_inexactly() { + if tiles.takes_depth() { let region = vk::BufferCopy { src_offset: staging.into.src_offset, dst_offset: at, @@ -1333,7 +1337,9 @@ impl ShadowCopy { /// The moves between a heap's multisample texture's image and Metal's tiles that the copy's /// record takes (`texture/heap_tiled.rs`), planned now through `maker`: into the image for a /// copy in, out of it for every other step (a copy back, a merge's keep and its copy of what - /// changed). `None` for every other texture. Refused as their images are made. + /// changed) but a depth's keep, which holds the heap's bytes + /// ([`ShadowCopies::record_kept`]). `None` for every other texture. Refused as their images + /// are made. pub(super) fn plan_moves(&self, maker: &UseMaker) -> Result, Error> { if !self.moves_samples() { return Ok(None); @@ -1341,6 +1347,9 @@ impl ShadowCopy { let Some(ShadowTarget::Tiled { tiles, .. }) = self.copies.target() else { return Ok(None); }; + if matches!(self.step, Step::Keep(_)) && tiles.takes_depth() { + return Ok(None); + } tiles.sample_moves(maker, matches!(self.step, Step::Into)) } diff --git a/crates/metal2vulkan-runtime/src/shadow_merge.rs b/crates/metal2vulkan-runtime/src/shadow_merge.rs index 8c17dea18..0e71e9f84 100644 --- a/crates/metal2vulkan-runtime/src/shadow_merge.rs +++ b/crates/metal2vulkan-runtime/src/shadow_merge.rs @@ -20,6 +20,9 @@ //! with no copy of its shadow between, copies the staging buffer that copy filled with the //! heap's bytes: the bytes a move of its texels out of the image would leave there, without //! the move (`ShadowCopies::record_kept_from_staging`, `WorkCounts::shadow_keeps_from_staging`). +//! A heap's tiled texture with a depth aspect, of any sample count, keeps the heap's bytes, not +//! its image's, which the copy in may have changed (`texture/heap_tiled.rs`): that staging +//! buffer right after its copy in, else the heap's bytes themselves. //! - **Merged in place**, where the texture's first byte is a whole word of its buffer, its last //! byte's word lies in the buffer, none of its bytes lie in its tail, and the bytes lie in pages //! when the merge is planned (not detached, `detach.rs`): the shadow's texels are copied into the diff --git a/crates/metal2vulkan-runtime/src/texture.rs b/crates/metal2vulkan-runtime/src/texture.rs index 16d3d522b..68037711e 100644 --- a/crates/metal2vulkan-runtime/src/texture.rs +++ b/crates/metal2vulkan-runtime/src/texture.rs @@ -5108,33 +5108,62 @@ impl Texture { aspect: ImageAspectFlags, signed: bool, ) { - let Ok(image) = self.image() else { - return; - }; - let float_depth = matches!( - image.plan().format, - Format::D32_SFLOAT | Format::D32_SFLOAT_S8_UINT - ); - if aspect != ImageAspectFlags::DEPTH || !float_depth { + if aspect != ImageAspectFlags::DEPTH || !self.float_depth_image() { return; } - let device = self.device(); - let profile = device.compile_device().profile(); - let restricted = device.shared().textures.facts(profile).depth_clamps(); let format = self.pixel_format(); - if restricted { - device.degrade(Degradation::RestrictedDepthUpload, || { - let why = format!( - "{call} wrote its depth image on a device without \ + if self.depth_clamps() { + self.device() + .degrade(Degradation::RestrictedDepthUpload, || { + let why = format!( + "{call} wrote its depth image on a device without \ VK_EXT_depth_range_unrestricted" - ); - (format!("a {format:?} texture"), why) - }); + ); + (format!("a {format:?} texture"), why) + }); } else if signed { self.degrade_signed_depth(call); } } + /// Announce `restricted-depth-upload` for a heap's texture made by `call` whose shadow's + /// copies in move the heap's bytes into its 32-bit float depth image (`texture/heap.rs`, + /// `shadowed-texture`), on a device that may store a value outside `[0, 1]` there clamped + /// (`ImageFacts::depth_clamps`): the bytes may hold any `float`, which Metal's texture keeps, + /// and the copies back write the stored value (`texture/heap_tiled.rs`). + pub(super) fn degrade_shadowed_depth(&self, call: &'static str) { + if !self.float_depth_image() || !self.depth_clamps() { + return; + } + let format = self.pixel_format(); + self.device() + .degrade(Degradation::RestrictedDepthUpload, || { + let why = format!( + "`{call}`'s texture in a heap takes the depth its bytes hold into its depth \ + image by copies, on a device without VK_EXT_depth_range_unrestricted" + ); + (format!("a {format:?} texture"), why) + }); + } + + /// Whether the texture's image holds a 32-bit float depth. + fn float_depth_image(&self) -> bool { + self.image().is_ok_and(|image| { + matches!( + image.plan().format, + Format::D32_SFLOAT | Format::D32_SFLOAT_S8_UINT + ) + }) + } + + /// Whether the device may store a value outside `[0, 1]` that a copy writes into a + /// `D32_SFLOAT` image clamped (`ImageFacts::depth_clamps`). + fn depth_clamps(&self) -> bool { + let device = self.device(); + let profile = device.compile_device().profile(); + device.shared().textures.facts(profile).depth_clamps() + } + /// Announce `signed-depth-test` for `call`'s write into the texture, which may store a negative /// value or a NaN, on a device that keeps such a value in a depth image: a render target's /// 32-bit float depth, which a depth test reads and a pass with depth writes stores. Metal's diff --git a/crates/metal2vulkan-runtime/src/texture/heap.rs b/crates/metal2vulkan-runtime/src/texture/heap.rs index faa801334..d0ddbfe58 100644 --- a/crates/metal2vulkan-runtime/src/texture/heap.rs +++ b/crates/metal2vulkan-runtime/src/texture/heap.rs @@ -3665,6 +3665,10 @@ impl Device { }; tiles.know_samples(self, call, &texture, inexact); } + // A shadow's copies in hand its depth image whatever float the heap's bytes hold. + if texture.shadow().is_some() { + texture.degrade_shadowed_depth(call); + } heap.hold_texture(&texture); if making.refit.is_some() { self.shared().counts.heap_texture_refit(); diff --git a/crates/metal2vulkan-runtime/src/texture/heap_tiled.rs b/crates/metal2vulkan-runtime/src/texture/heap_tiled.rs index bf9f55bc8..5a47efab0 100644 --- a/crates/metal2vulkan-runtime/src/texture/heap_tiled.rs +++ b/crates/metal2vulkan-runtime/src/texture/heap_tiled.rs @@ -152,10 +152,18 @@ //! (`copy_images.rs`); the encoder's command buffer holds them until it completes. The texture //! holds none: before, it planned them as it was made and held their images for its life. Where //! they write a 32-bit float depth by the `FragDepth` draw on a driver measured to change some -//! values, the texture announces `drawn-depth-copy` once, as it is made, and a merge's keep holds -//! the heap's bytes, not the image's (`ShadowCopies::record_kept`), so a byte the image holds -//! otherwise than the heap is written back: every byte a command wrote, and the values the copy -//! in changed. +//! values, the texture announces `drawn-depth-copy` once, as it is made. +//! +//! A texture with a **depth** aspect, of any sample count, takes the heap's bytes into its image +//! by moves that may change a value: Vulkan leaves a depth outside `[0, 1]` that a copy or a draw +//! writes undefined without `VK_EXT_depth_range_unrestricted` (ANV on the Iris Xe of RPL-P stores +//! a 32-bit float one clamped: `restricted-depth-upload`, announced as the texture is made), and +//! the drivers that `drawn-depth-copy` names change values inside it too. So a merge's keep holds +//! the heap's bytes, not the image's (`ShadowCopies::record_kept`): the staging buffer right after +//! the copy in filled it, else the heap's bytes themselves, and no move out of the image. A keep +//! of the image would hold the changed value, and the merge would keep the heap's byte in each +//! byte a command wrote that equals it. A byte the image holds otherwise than the heap is written +//! back: every byte a command wrote, and the values the copy in changed. use super::super::blit_plan::BufferLayout; use super::super::buffer::Buffer; @@ -1523,8 +1531,8 @@ pub(crate) struct HeapTiledCopies { /// The tight buffer's copies to and from the image, one a level: a single-sample image's /// copies; a multisample image's region, which its [`SampleMoves`] move. regions: Vec, - /// A multisample image's texture and what its moves into it change, known once the texture - /// is made ([`know_samples`](Self::know_samples)); `None` for a single-sample image. + /// A multisample image's texture, known once the texture is made + /// ([`know_samples`](Self::know_samples)); `None` for a single-sample image. samples: Option>, /// The tight buffer's planes and where it lies in its `VkBuffer`, which a multisample image's /// moves are planned over. @@ -1553,11 +1561,9 @@ pub(crate) struct SampleMoves { /// A multisample heap texture whose moves are planned as its copies are recorded /// ([`HeapTiledCopies::sample_moves`]): the texture, which holds the moves' tiles and so is held -/// weakly, and what the moves into its image change (`drawn-depth-copy`), `None` where they are -/// exact. +/// weakly. struct MovedTexture { texture: Weak, - inexact: Option<&'static str>, } impl HeapTiledCopies { @@ -1826,7 +1832,6 @@ impl HeapTiledCopies { } let known = MovedTexture { texture: texture.downgrade(), - inexact, }; // A texture is known once, as it is made, before any command records its copies. drop(slot.set(known)); @@ -1877,12 +1882,15 @@ impl HeapTiledCopies { .all(|region| region.image_subresource.aspect_mask == vk::ImageAspectFlags::COLOR) } - /// Whether the image takes the heap's bytes inexactly: a multisample depth whose moves into - /// it draw values the driver's fragment depth changes (`drawn-depth-copy`), which a merge's - /// keep then reads from the heap's bytes (`ShadowCopies::record_kept`). - pub(crate) fn takes_inexactly(&self) -> bool { - let known = self.samples.as_ref().and_then(OnceLock::get); - known.is_some_and(|known| known.inexact.is_some()) + /// Whether the image has a depth aspect, whose moves into it may change a value the heap's + /// bytes hold (the module docs: a 32-bit float depth outside `[0, 1]`, which Vulkan leaves + /// undefined without `VK_EXT_depth_range_unrestricted`, and the values `drawn-depth-copy` + /// names), so that a merge's keep holds the heap's bytes and moves nothing out of the image + /// (`ShadowCopies::record_kept`). Of a depth whose moves change none, the same bytes. + pub(crate) fn takes_depth(&self) -> bool { + (self.regions.iter()).any(|region| { + (region.image_subresource.aspect_mask).contains(vk::ImageAspectFlags::DEPTH) + }) } /// Record the move of the image's elements into the tight buffer: a single-sample image's diff --git a/crates/metal2vulkan-runtime/src/work_counts.rs b/crates/metal2vulkan-runtime/src/work_counts.rs index fd1bffa18..8a0411b44 100644 --- a/crates/metal2vulkan-runtime/src/work_counts.rs +++ b/crates/metal2vulkan-runtime/src/work_counts.rs @@ -6829,7 +6829,8 @@ pub struct WorkCounts { /// Of the keeps of merged shadowed textures, those of a heap's tiled texture recorded right /// after its copy in as one copy of the staging buffer that copy filled with the heap's /// bytes, in place of a move of the shadow's texels back into Metal's tiles: the same bytes - /// either way (`shadow.rs`). + /// either way, but a depth's, whose keep holds the heap's bytes where its image's may differ + /// (`shadow.rs`). pub shadow_keeps_from_staging: u64, /// The copies in of shadows over host pages a consumer logs whose regions the log decided as /// their batch was submitted (`dirty_pages.rs`). diff --git a/crates/metal2vulkan-validation/src/runtime_lane/heap_textures.rs b/crates/metal2vulkan-validation/src/runtime_lane/heap_textures.rs index 0074dac01..ca59a3f2f 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/heap_textures.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/heap_textures.rs @@ -2354,6 +2354,9 @@ fn heap_multisample_textures_keep_their_samples_in_metal_s_tiles() { let facts = &device.properties().driver_facts; let tiled = facts.contains(&DriverFact::DepthStencilImagesLieApart) || facts.contains(&DriverFact::DepthStencilImagesStayGpuOptimized); + // A device that may store a depth outside `[0, 1]` copied into a depth image clamped. + let clamps = !device.enables_extension(ash::ext::depth_range_unrestricted::NAME) + && !facts.contains(&DriverFact::DepthImageKeepsValuesOutsideUnitRange); let queue = device.new_command_queue().unwrap(); let options = tracked(StorageMode::Shared); let ds = PixelFormat::Depth32FloatStencil8; @@ -2465,6 +2468,15 @@ fn heap_multisample_textures_keep_their_samples_in_metal_s_tiles() { let before = device.work_counts().heap_textures_tiled; let texture = heap.new_texture_at_offset(&descriptor, 0).unwrap(); let counted = device.work_counts().heap_textures_tiled - before == 1; + let float_depth = format == d32 || format == ds; + if counted && float_depth { + // Its shadow's copies in hand its image whatever the heap's bytes hold. + let upload = announced(&messages, Degradation::RestrictedDepthUpload); + assert_eq!( + upload, clamps, + "{what}: restricted-depth-upload as it is made" + ); + } let over = heap.new_buffer_at_offset(answer.size, options, 0).unwrap(); gpu_fill(&queue, &over, 0..answer.size, 0xee); let read = || gpu_read(&queue, &over, 0..answer.size); @@ -2478,6 +2490,7 @@ fn heap_multisample_textures_keep_their_samples_in_metal_s_tiles() { run(&command_buffer); }; let shape = ([w, h], samples); + let staged = device.work_counts().shadow_keeps_from_staging; let Some((off, read_off)) = sample_round_trip(&queue, &texture, shape, &aspects, &read, &write) else { @@ -2485,16 +2498,22 @@ fn heap_multisample_textures_keep_their_samples_in_metal_s_tiles() { assert!(!counted, "{what}: tiled, but its blits refused"); continue; }; + let staged = device.work_counts().shadow_keeps_from_staging - staged; let total = w * h * samples * aspects.len() as u64; eprintln!( "HEAPTEX samples {what}: size {} align {}, Metal's {metal:?}; counted tiled \ {counted}; {off} of {total} samples off Metal's tiles, {read_off} read otherwise \ - from them", + from them; {staged} keeps from staging", answer.size, answer.align ); if counted { assert_eq!((answer.size, answer.align), metal, "{what}"); assert_eq!((off, read_off), (0, 0), "{what}: samples off Metal's tiles"); + // A blit into one slice or aspect of a depth leaves texels its merge keeps: the + // heap's bytes its copy in took, not its image's, which the copy in may change. + if float_depth && aspects.len() > 1 { + assert!(staged > 0, "{what}: a depth's keep of its image"); + } } let moved = matches!( format, @@ -2520,6 +2539,16 @@ fn heap_multisample_textures_keep_their_samples_in_metal_s_tiles() { layer_reported_nothing_at_all(&messages); } +/// Whether `messages` took or holds a notice of `kind`, left pending. +fn announced(messages: &Messages, kind: Degradation) -> bool { + let pending = messages.take_notices(); + messages.restore_notices(pending.clone()); + messages.taken_kinds().contains(&kind) + || (pending.iter()) + .filter_map(|message| message.degradation.as_ref()) + .any(|notice| notice.degradation == kind) +} + /// A heap's colour textures that Metal keeps uncompressed, in a `Private` placement heap over the /// device's memory, lie where Metal's tiles place each texel (`heap_layouts::tiled_offset`) on a /// driver whose colour images lie as Metal's heap textures diff --git a/docs/API.md b/docs/API.md index e3a8a2a67..28947e5c5 100644 --- a/docs/API.md +++ b/docs/API.md @@ -2218,9 +2218,11 @@ bound. on a device without `VK_EXT_depth_range_unrestricted` enabled, where Vulkan leaves a value outside `[0, 1]` undefined, whose driver is not measured to keep one (`DriverFact::DepthImageKeepsValuesOutsideUnitRange`). And a render pass's NaN clear depth on such - a device, which Metal stores as `0x7fc00000`, cleared to 1.0. Cost: a value outside [0, 1] may be - stored clamped to [0, 1], where Metal's keeps it, so reads, samples, comparisons and depth tests - of it can differ. + a device, which Metal stores as `0x7fc00000`, cleared to 1.0. And a heap's texture of such a depth + whose shadow's copies in move the heap's bytes into its image, announced as it is made: its + copies back write each value as the image stored it, one no command wrote too. Cost: a value + outside [0, 1] may be stored clamped to [0, 1], where Metal's keeps it, so reads, samples, + comparisons and depth tests of it can differ. - `metal2vulkan-degrade-host-read-dispatch-arguments` (performance). `HostReadDispatchArguments`: An indirect dispatch, or a dispatch after `setStageInRegionWithIndirectBuffer:indirectBufferOffset:`: its arguments or its stage-in region are GPU memory the work before it may write, so they are diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index cedc9fa25..41a1c9dd8 100644 --- a/docs/FAST-PATHS.md +++ b/docs/FAST-PATHS.md @@ -77,6 +77,7 @@ known. The rest of the differences are docs/API.md section 9's precision notes. | A draw biasing a `Depth16Unorm` depth by a constant, or by a slope alone, biases by Metal's constant `c` in the device's own unit `r` on every device: Metal biases by `c + 1` units of 1/65535 for `c` of 0 or more and `c - 1` below (one unit for a slope alone), added to the depth rounded toward zero, where Vulkan's `r` of a 16-bit unorm depth is the implementation's, at most `2 × 2^-16`, and the device rounds the sum its own way. MoltenVK hands Metal its constant (`DriverDeviation::MetalDepth16BiasedStores`). | The device's depth bias is the contract. | Another code than Metal's for a biased depth: one unit's difference or more. `UnormDepthBias` (`unorm-depth-bias`) | | A render pass that loads and stores an extended-range, padded 10-bit or bfloat color attachment (`BGR10_XR`, `BGRA10_XR`, `RGB10A8_2P_XR10`, `R10Unorm_X6`, `RG10Unorm_X12` and their sRGB twins, `RGB10A2Unorm_sRGB`, `R16Bfloat`, `RG16Bfloat`, `RGBA16Bfloat`) keeps the bytes its draws do not write, on every device, MoltenVK included (such an attachment is an image of an unsigned integer format there too): Metal's pass writes each 32 x 32 tile a draw reaches back through its tile store, the unused bits of the codes made canonical, `BGRA10_XR`'s alpha code clamped to `[384, 894]`, a padded sRGB twin's codes through Metal's table and a bfloat code through `half` (a NaN to `0x7fc0`). A single-sampled signed normalized or `RGB9E5Float` attachment likewise keeps its minimum codes and unnormalized words, but on MoltenVK, whose pass is a Metal pass (`DriverFact::TileStoreIsMetals`). | The device's load and store are the contract: no pass rewrites the texels its draws do not write. | Bytes no Metal write left (uploads, copies) differ in the tiles a draw reaches; an extended-range texel reads the same value either way, a bfloat code off `half`'s grid reads its own value. `ExtendedRangeBitsKept` (`extended-range-bits-kept`), `SnormMinimumKept` (`snorm-minimum-kept`), `SharedExponentKept` (`shared-exponent-kept`) | | Depth values outside [0, 1] stored clamped (RADV, ANV) on a device without `VK_EXT_depth_range_unrestricted`. | Vulkan leaves them undefined without the extension: enable it. | `RestrictedDepthRange` (`restricted-depth-range`) | +| A 32-bit float depth outside [0, 1] uploaded into a depth image, on a device without `VK_EXT_depth_range_unrestricted` whose driver is not measured to keep it (`DriverFact::DepthImageKeepsValuesOutsideUnitRange`; ANV on the Iris Xe of RPL-P stores it clamped): a blit from a buffer, `replace_region`, and a heap's depth texture whose shadow copies the heap's bytes into its image, whose copies back then write the stored value, in texels no command wrote too. | Vulkan leaves such a copied value undefined without the extension (`VUID-vkCmdCopyBufferToImage-pRegions-07931`), and a depth image holds a depth by no other means. | `RestrictedDepthUpload` (`restricted-depth-upload`) | | A multisampled 32-bit float depth written by a blit copy from a buffer or a colour texture, or a separate depth texture's copies to and from its pass's scratch image, on a device whose depth/colour copies are missing or wrong (lavapipe, MoltenVK, NVIDIA's GA10x, a device without `VK_KHR_maintenance8`): the values its driver's fragment depth changes (MoltenVK's, NVIDIA's), or on a driver not measured may change (outside [0, 1], denormals, -0), land changed. | Vulkan writes a multisampled depth image's samples by no other means there but a clear; a driver measured to store every fragment depth unchanged (lavapipe's measured releases) is exact. | `DrawnDepthCopy` (`drawn-depth-copy`) | | Signed zeros, infinities and NaNs where the device lacks `SignedZeroInfNanPreserve` at the operation's width. | A device capability. | `DeviceSignedZeroInfNan` (`device-signed-zero-inf-nan`) | | Every device but MoltenVK interpolates varyings by its own rounding, up to about `1.5e-4` from Metal's (`3e-4` on lavapipe). MoltenVK hands the varyings to Metal. | The exact path needs Metal's interpolation formula, which is not known. | `DeviceInterpolation` (`device-interpolation`) |