From 2cbe8ce595f8e7eab2834c5190907b8cfb999fee Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Mon, 9 Nov 2026 04:05:39 -0800 Subject: [PATCH] Volume resolves: NVIDIA's leaves plane 1 unwritten, so it resolves through the scratch copied into the planes too On the RTX 5080 Laptop GPU (NVIDIA 615.71.09) runtime_lane::view_attachments::a_resolve_writes_the_volume_plane_it_names failed at base and tip alike, 3/3 each (t3d_resolve_plane1: byte 64 is 0x11, Metal's 0x33). Its VOLUME-RESOLVE lines and a probe of resolve orders (scratch branch, never merged) show a 4x multisampled RGBA8Unorm attachment resolved into the 2D view of a 4x4x4 or 4x4x8 volume that begins at depth plane 1 writes no plane: the volume keeps every byte it had. Into the views at planes 0, 2 and 3 it writes that plane alone, in every order tried (1023, 3210, 0123) and three times over into plane 1. A draw into plane 1 through the same kind of view writes it (a_volume_s_plane_is_an_attachment passes), and the validation layer reports nothing, so the usage is the valid one RADV's defect row already cites. Fix, the RADV fix's shape (c1a825d748): RuntimeDriverDefect::VolumeResolveFirstPlane gains an NVIDIA_PROPRIETARY row, every NVIDIA GPU until a probe finds one clean. Its meaning is stated for both drivers: the resolve is written where the view begins only at the image's first plane (RADV writes plane 0 whatever plane the view begins at; NVIDIA's writes no plane from plane 1). There a color resolve into a 3D texture's planes past its first, or into more than one, goes into the scratch image of the pass's layers that is copied into the planes after the pass, announced as resolve-scratch with the defect named. The variant, the table's doc, the resolve module's docs, the notice's reason and docs/API.md's catalogue entry say so. Tests: tests::driver_defects lists the defect for every committed NVIDIA profile (the RTX 5080 Laptop GPU's and the others'), so it fails without the row. Verified: cargo fmt. The lane on the 5080 at this commit and at its base follows through potluck. (cherry picked from commit 93795eaaa29dba62257ca9b4c569394e23c269da) --- .../metal2vulkan-runtime/src/degradation.rs | 8 ++++---- .../src/driver_defects.rs | 13 ++++++++++++ crates/metal2vulkan-runtime/src/resolve.rs | 19 +++++++++--------- .../src/tests/driver_defects.rs | 20 +++++++++++-------- crates/metal2vulkan/src/error/mod.rs | 9 +++++---- docs/API.md | 5 +++-- 6 files changed, 47 insertions(+), 27 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/degradation.rs b/crates/metal2vulkan-runtime/src/degradation.rs index dd0cdc79a..0a67457cf 100644 --- a/crates/metal2vulkan-runtime/src/degradation.rs +++ b/crates/metal2vulkan-runtime/src/degradation.rs @@ -514,8 +514,8 @@ degradations! { /// `RenderTarget`), or a layered pass into a texture whose slices from the resolve slice /// hold fewer layers than the pass's, or a pass resolves color into a 3D texture's planes /// past its first, or into more than one, on a device whose resolve into a 2D view of a - /// 3D image writes its first plane alone (`RuntimeDriverDefect::VolumeResolveFirstPlane`: - /// RADV). + /// 3D image is written where the view begins only at its first plane + /// (`RuntimeDriverDefect::VolumeResolveFirstPlane`: RADV, NVIDIA's). ResolveScratch = "resolve-scratch", Performance, "the pass resolves into a scratch image, whose render area is copied into the \ texture after the pass"; @@ -4501,8 +4501,8 @@ impl Device { scratch.layers, texture.layers ) } else if super::resolve::is_volume(texture) && super::resolve::first_plane_only(self) { - "the device's resolve into a 2D view of a 3D image writes its first depth plane, \ - whatever plane the view begins at (RuntimeDriverDefect::VolumeResolveFirstPlane)" + "the device's resolve into a 2D view of a 3D image is written where the view \ + begins only at its first depth plane (RuntimeDriverDefect::VolumeResolveFirstPlane)" .to_owned() } else { "its image cannot be an attachment: the texture's usage lacks `RenderTarget`" diff --git a/crates/metal2vulkan-runtime/src/driver_defects.rs b/crates/metal2vulkan-runtime/src/driver_defects.rs index 94d30e2a6..2a113c6d1 100644 --- a/crates/metal2vulkan-runtime/src/driver_defects.rs +++ b/crates/metal2vulkan-runtime/src/driver_defects.rs @@ -113,6 +113,14 @@ pub(super) struct Affected { /// refused: a color resolve into a 3D texture's planes past its first, or into more than one, /// goes into a scratch image of the pass's layers, copied into the planes after the pass /// (`resolve.rs`). Every RADV GPU takes the copy until a probe finds it clean. +/// - NVIDIA's (`NVIDIA_PROPRIETARY`): the same resolve, of a 4x multisampled `R8G8B8A8_UNORM` +/// attachment, into the 2D view of a 4x4x4 or a 4x4x8 volume whose first layer is depth plane 1 +/// wrote no plane, every byte of the volume as before; into the view beginning at plane 0, 2 or +/// 3 it wrote that plane alone, in any order of the four and three times over into plane 1, on +/// the RTX 5080 Laptop GPU (`deviceID` 0x2c19, 615.71.09; 3 runs of +/// `runtime_lane::view_attachments::a_resolve_writes_the_volume_plane_it_names` and a probe of +/// the orders), where a draw into plane 1 through such a view writes it and the validation layer +/// reports nothing. The same copy; every NVIDIA GPU takes it until a probe finds it clean. /// /// `PipelineCacheDataCompiledAtLoad`: /// - MoltenVK (`MOLTENVK`): `vkCreatePipelineCache` with initial data reads each shader module's @@ -579,6 +587,11 @@ pub(super) const AFFECTED: &[Affected] = &[ driver: DriverId::MESA_RADV, clean: &[], }, + Affected { + defect: RuntimeDriverDefect::VolumeResolveFirstPlane, + driver: DriverId::NVIDIA_PROPRIETARY, + clean: &[], + }, Affected { defect: RuntimeDriverDefect::LazilyAllocatedVolumePlaneViews, driver: DriverId::MOLTENVK, diff --git a/crates/metal2vulkan-runtime/src/resolve.rs b/crates/metal2vulkan-runtime/src/resolve.rs index dafbf0d3b..0fcb40c6c 100644 --- a/crates/metal2vulkan-runtime/src/resolve.rs +++ b/crates/metal2vulkan-runtime/src/resolve.rs @@ -197,13 +197,14 @@ //! ([`ResolveSource`]), which an instance of no draws, and each resolve after the pass, resolves //! from in its place. A memoryless attachment there, which takes no copy, is not built //! (`NotImplemented(DepthStencilResolve)`). -//! - **A render pass that resolves color into a 3D image's first plane alone** (RADV, -//! `RuntimeDriverDefect::VolumeResolveFirstPlane`): its color resolve into a 2D view of a 3D -//! image writes the image's first depth plane, whatever plane the view begins at. There a +//! - **A render pass whose color resolve into a 3D image's planes holds at its first alone** (RADV, +//! NVIDIA's, `RuntimeDriverDefect::VolumeResolveFirstPlane`): its color resolve into a 2D view of +//! a 3D image is written where the view begins only at the image's first depth plane (RADV writes +//! the first plane whatever plane the view begins at, NVIDIA's no plane from plane 1). There a //! resolve into a 3D texture's planes past its first, or into more than one, takes the scratch //! image, whose layers are copied into the planes after the pass (the copy's depth from the -//! resolve's first plane); a level of the texture reaching past the attachment, whose clear -//! there would be of the planes alone, is not built (`NotImplemented(Render)`). +//! resolve's first plane); a level of the texture reaching past the attachment, whose clear there +//! would be of the planes alone, is not built (`NotImplemented(Render)`). //! - The multisampled attachment of `MultisampleResolve` is stored `DONT_CARE`: Metal leaves its //! texels undefined (the recorded near-equivalent of a `DontCare` store). //! @@ -1170,8 +1171,8 @@ impl Destination { /// render pass's depth/stencil resolve (`depth_stencil`) on a device that writes its resolve /// attachment image's first layer and level alone ([`first_subresource_only`]) takes the /// scratch image where the destination begins at another, and a color resolve on a device - /// that writes a 3D image's first plane alone ([`first_plane_only`]) where the destination is - /// a 3D texture's planes past its first, or more than one. + /// whose resolve into a 3D image holds at its first plane alone ([`first_plane_only`]) where the + /// destination is a 3D texture's planes past its first, or more than one. fn attach( self, maker: &CommandBuffer, @@ -1187,7 +1188,7 @@ impl Destination { let misplaced = depth_stencil && first_subresource_only(device) && !at_first_subresource(&self.target); // Nor does a color resolve into a 3D texture's planes past its first, or into more than - // one, on a device that writes the image's first plane whatever plane the view begins at + // one, on a device that writes it where the view begins only at the image's first plane // ([`first_plane_only`]): the scratch image's layers are copied into the planes. let off_plane = !depth_stencil && first_plane_only(device) @@ -1581,7 +1582,7 @@ fn at_first_subresource(target: &Target) -> bool { } /// Whether `device`'s render pass resolves a color attachment into a 2D view of a 3D image's -/// planes by writing the image's first plane, whatever plane the view begins at +/// planes where the view begins only at the image's first plane /// (`RuntimeDriverDefect::VolumeResolveFirstPlane`). pub(super) fn first_plane_only(device: &Device) -> bool { device diff --git a/crates/metal2vulkan-runtime/src/tests/driver_defects.rs b/crates/metal2vulkan-runtime/src/tests/driver_defects.rs index bebddda4d..ca9493ed2 100644 --- a/crates/metal2vulkan-runtime/src/tests/driver_defects.rs +++ b/crates/metal2vulkan-runtime/src/tests/driver_defects.rs @@ -62,8 +62,9 @@ const VOLUME_RESOLVES: RuntimeDriverDefect = RuntimeDriverDefect::VolumeResolveF /// NVIDIA's the /// stencil colour copies on every GPU but the RTX 5080 Laptop GPU, measured clean (the GTX 1060 and /// the RTX 5080 desktop GPU, not measured, take them), the 10-bit codes its Y′CbCr conversion reads -/// with their unused bits and the host memory a failed import of unpinnable pages breaks on every -/// GPU; SwiftShader none. +/// with their unused bits, the host memory a failed import of unpinnable pages breaks and the color +/// resolve into a 3D image it writes where the view begins only at the first plane on every GPU; +/// SwiftShader none. #[test] fn the_committed_profiles_drivers_have_their_defects() { let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../metal2vulkan-validation/profiles"); @@ -110,9 +111,11 @@ fn the_committed_profiles_drivers_have_their_defects() { vec![COMPRESSION, COUNTS, STALE_PUSHES, ALIASED_BLITS] } Some(DriverId::NVIDIA_PROPRIETARY) if desc.device_id == 0x2c19 => { - vec![TEN_BIT_WORDS, UNPINNABLE] + vec![TEN_BIT_WORDS, UNPINNABLE, VOLUME_RESOLVES] + } + Some(DriverId::NVIDIA_PROPRIETARY) => { + vec![STENCIL_COPIES, TEN_BIT_WORDS, UNPINNABLE, VOLUME_RESOLVES] } - Some(DriverId::NVIDIA_PROPRIETARY) => vec![STENCIL_COPIES, TEN_BIT_WORDS, UNPINNABLE], _ => Vec::new(), }; let defects: Vec<_> = of(&desc).into_iter().collect(); @@ -144,8 +147,9 @@ fn a_clean_gpu_alone_lacks_the_defect() { /// NVIDIA's stencil colour-copy defect, measured on the RTX 3090 (`deviceID` 0x2204), is every /// NVIDIA GPU's but the RTX 5080 Laptop GPU's (0x2c19), measured clean: the RTX 3070 (0x2484) and /// an Ada GPU (0x2684) take it; a device that runs another driver has none. The unpinnable pages' -/// defect and the 10-bit codes read with their unused bits, measured on the 5080, are every NVIDIA -/// GPU's; no other driver has the unpinnable pages'. +/// defect, the 10-bit codes read with their unused bits and the volume resolve written where the +/// view begins only at the first plane, measured on the 5080, are every NVIDIA GPU's; no other +/// driver has the unpinnable pages'. #[test] fn nvidia_s_colour_copies_are_clean_on_the_gpu_measured_alone() { let nvidia = Some(DriverId::NVIDIA_PROPRIETARY); @@ -153,13 +157,13 @@ fn nvidia_s_colour_copies_are_clean_on_the_gpu_measured_alone() { for device in [0x2204, 0x2484, 0x2684] { assert_eq!( of(device).into_iter().collect::>(), - vec![STENCIL_COPIES, TEN_BIT_WORDS, UNPINNABLE], + vec![STENCIL_COPIES, TEN_BIT_WORDS, UNPINNABLE, VOLUME_RESOLVES], "{device:#x}" ); } assert_eq!( of(0x2c19).into_iter().collect::>(), - vec![TEN_BIT_WORDS, UNPINNABLE] + vec![TEN_BIT_WORDS, UNPINNABLE, VOLUME_RESOLVES] ); let radv = among(AFFECTED, Some(DriverId::MESA_RADV), 0x2204); assert!(!radv.contains(&COPIES) && !radv.contains(&STENCIL_COPIES)); diff --git a/crates/metal2vulkan/src/error/mod.rs b/crates/metal2vulkan/src/error/mod.rs index ed604e110..ee458e1f9 100644 --- a/crates/metal2vulkan/src/error/mod.rs +++ b/crates/metal2vulkan/src/error/mod.rs @@ -1087,10 +1087,11 @@ pub enum RuntimeDriverDefect { /// the object then waits for, so that every object over a chunk's pages lies in one import. AliasedImportBlitsUnordered, /// A render pass's color resolve into a 2D view of a 3D image (made - /// `VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT`, the view's layers depth planes of it) writes the - /// image's first depth plane, whatever plane the view begins at. Nothing is refused: the - /// runtime resolves into a scratch image of the pass's layers, copied into the planes the - /// resolve belongs in after the pass. + /// `VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT`, the view's layers depth planes of it) is + /// written where the view begins only at the image's first depth plane: RADV writes the first + /// plane whatever plane the view begins at, and NVIDIA's driver writes no plane where the view + /// begins at plane 1. Nothing is refused: the runtime resolves into a scratch image of the + /// pass's layers, copied into the planes the resolve belongs in after the pass. VolumeResolveFirstPlane, } diff --git a/docs/API.md b/docs/API.md index 83c4ec3c4..b68db7ac7 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1973,8 +1973,9 @@ bound. texture that cannot be an attachment (its usage lacks `RenderTarget`), or a layered pass into a texture whose slices from the resolve slice hold fewer layers than the pass's, or a pass resolves color into a 3D texture's planes past its first, or into more than one, on a device whose resolve - into a 2D view of a 3D image writes its first plane alone (RADV). Cost: the pass - resolves into a scratch image, whose render area is copied into the texture after the pass. + into a 2D view of a 3D image is written where the view begins only at its first plane (RADV, + NVIDIA's). Cost: the pass resolves into a scratch image, whose render area is copied into the + texture after the pass. - `metal2vulkan-degrade-shader-resolve` (performance). `ShaderResolve`: A multisample color resolve drawn after the pass by the crate-owned resolve: of an extended-range attachment, whose codes no device's resolve averages, or into the attachment's format's sRGB twin, whose encoding no