From 7934b405d8cda58b961a432811fecbdb97f6b2a0 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 19 Nov 2026 15:16:09 -0800 Subject: [PATCH] fetch (draft): surfaces read through the loop where their query offers it; loop reads counted; tests and docs A surface plane whose texture is a shader-read render target takes the feedback usage where the handle's image format query offers it with the export features alike (Query::plane; a D3D11 import's query the same), and the in-place make retries without it where the images with it do not hold the layout; a plane without it reads through its shadow, the counted copy. The fetch and the texture read choose the loop or the shadow by the image, not the device. Metrics::attachment_loop_reads counts every draw that reads an attachment of its own pass through the loop. Device tests (tests/fetch.rs): N fetching draws exact, N-1 barriers or copies more than one; a surface plane of each fetched format. RenderPipelineKind::FramebufferFetch removed. SEMANTICS_VERSION 2193, ARTIFACT_FORMAT_VERSION 550 (PushField::FetchedColor). REFUSALS.md and api_signatures regenerated; README and API.md. Draft: the old render key re-pin follows the compile check. --- crates/metal2vulkan-rt/README.md | 50 ++- crates/metal2vulkan-rt/src/counters.rs | 14 + crates/metal2vulkan-rt/src/d3d11.rs | 8 + crates/metal2vulkan-rt/src/error.rs | 9 +- crates/metal2vulkan-rt/src/render.rs | 5 - crates/metal2vulkan-rt/src/render_encoder.rs | 27 +- crates/metal2vulkan-rt/src/surface.rs | 53 ++- crates/metal2vulkan-rt/src/tests/draw.rs | 13 +- crates/metal2vulkan-rt/src/tests/fetch.rs | 410 ++++++++++++++++++ crates/metal2vulkan-rt/src/tests/mod.rs | 1 + crates/metal2vulkan-rt/src/texture.rs | 72 ++- .../src/replay/new_runtime/mod.rs | 1 + .../metal2vulkan/src/lower/fragment/color.rs | 18 +- crates/metal2vulkan/src/pipeline/artifact.rs | 5 +- .../src/pipeline/compile/tests.rs | 121 ++++++ crates/metal2vulkan/tests/api_signatures.tsv | 4 +- docs/API.md | 21 +- docs/REFUSALS.md | 8 +- 18 files changed, 781 insertions(+), 59 deletions(-) create mode 100644 crates/metal2vulkan-rt/src/tests/fetch.rs diff --git a/crates/metal2vulkan-rt/README.md b/crates/metal2vulkan-rt/README.md index c8b701792..f57e2d2c5 100644 --- a/crates/metal2vulkan-rt/README.md +++ b/crates/metal2vulkan-rt/README.md @@ -605,6 +605,19 @@ list; a view of another format it does not list is `Gap::TextureView` of images move out of the undefined layout into the general one in the runtime's next submission, and stay in it through every copy. +A plane whose texture's usage holds both `ShaderRead` and `RenderTarget` takes, on a device with +the attachment feedback loop, the feedback usage beside the rest where the handle's image format +query (`vkGetPhysicalDeviceImageFormatProperties2` of the plane's format in the handle's tiling, +external as the handle, with the feedback usage added) offers it with the same export features, +and the layout checks above then run on the images with it. A draw reads such a plane as an +attachment of its own pass through the loop, as it reads a texture of an image of its own (Render +encoders): the pass moves the plane's image from the general layout to the feedback layout and +back. Where the query refuses the feedback usage, or the images with it do not hold the layout +and the images without it do, the plane takes none, and a draw reads it through its shadow, the +counted copy a device without the loop takes (Known gaps of render encoders). The image stays a +linear image on the surface's own memory, at the pitch and starts the export states. A Direct3D +11 plane asks its import's query the same. + **The ready point.** That move may discard what the memory holds, so the other API writes an in-place surface's memory only once it has completed: before the other API's first write, the consumer calls `Surface::wait_until_ready()` on its own thread, which returns once the move's @@ -2338,7 +2351,7 @@ or does not check is rebuilt from the generations' names, with young counted ful count bits), vertex amplification, a post-tessellation vertex function's per-instance factor step function or enabled factor scale (`Tessellation`; a descriptor's tessellation state with any other vertex function is ignored, as Metal ignores it), - stages the translator synthesizes beside the functions' and a tessellation's, framebuffer fetch, an imageblock, a + stages the translator synthesizes beside the functions' and a tessellation's, an imageblock, a fragment function's stencil output, constant data the binder supplies, a specialization other than the sample and amplification counts, dynamic state beyond Vulkan 1.3's (a vertex buffer layout whose stride is set per bind among it), a @@ -2521,8 +2534,11 @@ or does not check is rebuilt from the generations' names, with young counted ful pass reads the image's textures through their second elements (Set 1), a texture that reaches no rendered level among them. Every render pipeline takes the feedback loop's enable as dynamic state, which the encoder sets at its first draw and where it changes: colour for a draw that - reads an attachment, none otherwise, so a pass of no such draw sets it once. -- Through a copy, on a device without the feedback loop, the draw reads the image's shadow: an + reads an attachment, none otherwise, so a pass of no such draw sets it once. Each draw that + reads an attachment through the loop, through a texture or by a fetch (below), counts in + `Metrics::attachment_loop_reads`, its barriers in `Metrics::barriers`. +- Through a copy, on a device without the feedback loop, and for a surface plane whose image took + no feedback usage (Exported surfaces), the draw reads the image's shadow: an image of the same format, extent, levels and layers, made at the first draw that reads the image and freed with it (`Gauges::shadows` and `shadow_bytes`). A texture that reaches the attachment's level and layer reads the shadow through its second element; one that reaches @@ -2538,6 +2554,17 @@ or does not check is rebuilt from the generations' names, with young counted ful render area, the shadow's level and layer is cleared to the pass's clear colour between the same barriers instead of copied (the shadow is of the attachment's format, so the clear writes the texels the pass's did); a draw of the pass before it, of any pipeline, leaves the copy. +- A fragment function's read of a colour attachment (`[[color(n)]]`, framebuffer fetch) reads the + attachment's texture at the fragment's own pixel, through its second element, whose index the + draw pushes (`PushField::FetchedColor`): in the feedback layout, or through the image's shadow, + copied at the draw's scissor a pixel wider each way, as above. Metal orders the read after every + earlier fragment of the pass at the pixel, with no barrier from the program, so a fetching draw + after a draw of the pass pays the barrier `memory_barrier` owes (the rendering ends, one global + barrier, and it begins again), and through a copy copies what it reads into the shadow again: a + pass of N fetching draws records N - 1 such barriers, or N - 1 copies. The texture is a 2D + texture (a 2D multisample one in a multisampled pass) whose first level and slice the pass + renders, made with an index, of a shader-read colour render target's image: a texture of its + own image, or a surface plane's (Exported surfaces). - `memory_barrier` after a draw of the encoder that wrote memory ends the rendering, records one barrier and begins the rendering again, loading what it stored. After draws that only rendered, in a pass that moved an image to the feedback layout, the barrier is owed to the next draw that @@ -2594,6 +2621,23 @@ or does not check is rebuilt from the generations' names, with young counted ful through the image's shadow, the counted copy a device without the feedback loop takes, first, and then, where the device has the feedback loop, unified image layouts and a `LINEAR` image with the feedback usage, the loop on the attachment in the general layout. +- A fetch (`[[color(n)]]`) orders the fragments of earlier draws before it, not the fragments of + its own draw that cover the same pixel, which Metal orders in primitive order: a fragment may + read the texel from before an earlier fragment of its draw wrote it + (`PrecisionNote::UnorderedFetchWithinDraw`). Exact for a draw whose primitives do not overlap + at a pixel. A fetch of an attachment the draw cannot read through is `Gap::Draw` of + `FetchedAttachment`: a drawable's texture (its image has no feedback usage and no second + element; no boot or replay stream fetched one), a texture made with no index, one that is no 2D + texture at its first level and slice, a texture of an image another attachment of the pass + shares (two planes of one surface), and every attachment on a device without the attachment + reads. +- A surface plane whose texture's usage holds `ShaderRead` and `RenderTarget`, where the handle's + image format query (`vkGetPhysicalDeviceImageFormatProperties2`: the plane's format, the + handle's linear tiling, external as the handle, with the feedback usage added) refuses the + feedback usage, or where the images with it do not hold the export's layout, is read as an + attachment of its own pass through its shadow, the copy a device without the feedback loop + takes, which Metal does not make (`Metrics::attachment_read_copies` and + `attachment_read_copy_bytes`, in `bytes_copied` too). - A draw that reaches an attachment of its own pass through an argument buffer's texture is not seen: it reads through the texture's own element, in its home layout, while the pass may have moved the image to the feedback layout, or, without the feedback loop, while the pass renders diff --git a/crates/metal2vulkan-rt/src/counters.rs b/crates/metal2vulkan-rt/src/counters.rs index dd8720671..276dbeaad 100644 --- a/crates/metal2vulkan-rt/src/counters.rs +++ b/crates/metal2vulkan-rt/src/counters.rs @@ -79,6 +79,8 @@ pub(crate) enum Metric { SurfacesCopied, /// [`Metrics::texture_clear_barriers`]. TextureClearBarriers, + /// [`Metrics::attachment_loop_reads`]. + AttachmentLoopReads, /// [`Metrics::sparse_binds`]. SparseBinds, /// [`Metrics::resolves`]. @@ -117,6 +119,7 @@ const METRIC_ORDER: [Metric; METRICS] = [ Metric::SurfacesInPlace, Metric::SurfacesCopied, Metric::TextureClearBarriers, + Metric::AttachmentLoopReads, Metric::SparseBinds, Metric::Resolves, ]; @@ -315,6 +318,7 @@ struct Atomics { over_copy_bytes_imported: AtomicU64, attachment_read_copies: AtomicU64, attachment_read_copy_bytes: AtomicU64, + attachment_loop_reads: AtomicU64, allocations_freed: AtomicU64, submissions_during_frees: AtomicU64, idle_frees_by_age: [AtomicU64; FREE_AGES_MS.len() + 1], @@ -448,6 +452,7 @@ impl Counters { Metric::SurfacesInPlace => &a.surfaces_in_place, Metric::SurfacesCopied => &a.surfaces_copied, Metric::TextureClearBarriers => &a.texture_clear_barriers, + Metric::AttachmentLoopReads => &a.attachment_loop_reads, Metric::SparseBinds => &a.sparse_binds, Metric::Resolves => &a.resolves, } @@ -866,6 +871,7 @@ impl Counters { over_copy_bytes_imported: a.over_copy_bytes_imported.load(Relaxed), attachment_read_copies: a.attachment_read_copies.load(Relaxed), attachment_read_copy_bytes: a.attachment_read_copy_bytes.load(Relaxed), + attachment_loop_reads: a.attachment_loop_reads.load(Relaxed), allocations_freed: a.allocations_freed.load(Relaxed), submissions_during_frees: a.submissions_during_frees.load(Relaxed), idle_frees_by_age: std::array::from_fn(|at| a.idle_frees_by_age[at].load(Relaxed)), @@ -1186,6 +1192,14 @@ pub struct Metrics { pub attachment_read_copies: u64, /// The bytes of those copies, which count in [`bytes_copied`](Self::bytes_copied) too. pub attachment_read_copy_bytes: u64, + /// Draws that read an attachment of their own pass through the attachment feedback loop, a + /// fragment function's colour read (`[[color(n)]]`) or a texture argument over the + /// attachment: each with the image in the feedback layout, after the barrier that moved it + /// there or the barrier an earlier draw owed it, counted in [`barriers`](Self::barriers). A + /// count, no bytes. Metal records no barrier for such a draw. On a device without the loop + /// such a draw reads the image's shadow instead, its copies in + /// [`attachment_read_copies`](Self::attachment_read_copies). + pub attachment_loop_reads: u64, /// Copies between a texture over a buffer the device's linear image does not hold in place /// and its image of its own ([`Buffer::new_texture`](crate::Buffer::new_texture)): the /// buffer's bytes into the image, in the upload that leads a submission or after a command diff --git a/crates/metal2vulkan-rt/src/d3d11.rs b/crates/metal2vulkan-rt/src/d3d11.rs index 873e4aee3..ebc81562e 100644 --- a/crates/metal2vulkan-rt/src/d3d11.rs +++ b/crates/metal2vulkan-rt/src/d3d11.rs @@ -226,6 +226,14 @@ impl Device { if usage.is_empty() || !imports(usage) { return Err(Error::Limit(Limit::NoImport { handle })); } + // With the feedback usage where the plane asks it and the import offers it with the + // rest, so a draw reads it as an attachment of its own pass through the loop; else + // through its shadow. + let looped = usage | vk::ImageUsageFlags::ATTACHMENT_FEEDBACK_LOOP_EXT; + let usage = match plan.looped && imports(looped) { + true => looped, + false => usage, + }; let missing = plan.usage & !usage; if !missing.is_empty() { return Err(Error::Unsupported(Gap::SurfaceUsage { diff --git a/crates/metal2vulkan-rt/src/error.rs b/crates/metal2vulkan-rt/src/error.rs index e5e2576bb..c47a4e2b0 100644 --- a/crates/metal2vulkan-rt/src/error.rs +++ b/crates/metal2vulkan-rt/src/error.rs @@ -1237,8 +1237,6 @@ pub enum RenderPipelineKind { /// Stages the translator synthesizes beside the functions' but a tessellation's: geometry /// stages, lines drawn as bands of triangles, a rate map's fan-out, or mesh records. SynthesizedStages, - /// A fragment function that reads its colour attachments (framebuffer fetch). - FramebufferFetch, /// A fragment function that reaches the render pass's imageblock. Imageblock, /// A fragment function's stencil output applied by the shader. @@ -1298,9 +1296,10 @@ pub enum DrawKind { /// A draw through a pipeline state whose fragment function reads a colour attachment /// (`[[color(n)]]`, framebuffer fetch) whose texture the draw cannot read it through: one that /// is no 2D texture (a 2D multisample texture in a multisampled pass) whose first level and - /// slice the pass renders, that no shader reaches (made with no index), or that a device - /// reads no attachment through, as `AttachmentRead` says. Metal reads the attachment at the - /// fragment's pixel. + /// slice the pass renders, that no shader reaches (made with no index), whose image another + /// attachment of the pass shares (two planes of one surface), or that the device reads no + /// attachment through, as `AttachmentRead` says, a drawable's texture among them. Metal + /// reads the attachment at the fragment's pixel. FetchedAttachment, /// A draw at a base instance other than 0 through a pipeline state that steps a vertex layout /// per instance at a rate above 1, on a device that does not report diff --git a/crates/metal2vulkan-rt/src/render.rs b/crates/metal2vulkan-rt/src/render.rs index 3c2d4646e..62c8d53bf 100644 --- a/crates/metal2vulkan-rt/src/render.rs +++ b/crates/metal2vulkan-rt/src/render.rs @@ -613,11 +613,6 @@ fn unbuilt(pipeline: &RenderPipeline, enabled: &EnabledCaps) -> Option { diff --git a/crates/metal2vulkan-rt/src/surface.rs b/crates/metal2vulkan-rt/src/surface.rs index beba5b04d..08e9362c0 100644 --- a/crates/metal2vulkan-rt/src/surface.rs +++ b/crates/metal2vulkan-rt/src/surface.rs @@ -257,11 +257,16 @@ impl std::fmt::Debug for Surface { } } -/// A plane's checked texture: its image format, the image usage its uses ask, the formats its -/// views may take and its texel's bytes. +/// A plane's checked texture: its image format, the image usage its uses ask, whether its image +/// asks the feedback usage, the formats its views may take and its texel's bytes. +#[derive(Clone)] pub(crate) struct PlanePlan { pub(crate) format: vk::Format, pub(crate) usage: vk::ImageUsageFlags, + /// A draw may read an attachment of its own pass through the texture, on a device with the + /// attachment feedback loop: its image takes the feedback usage where the handle's query + /// offers it with the rest ([`Query::plane`]), else a draw reads it through its shadow. + pub(crate) looped: bool, pub(crate) view_formats: Vec, pub(crate) texel: u64, } @@ -363,9 +368,11 @@ impl Query<'_> { } /// The plane's image in place: its usage, every bit of `IN_PLACE_USAGE`, storage and the - /// plan's usage that the query offers, and its view-format list, the plan's formats the - /// tiling samples (none where the query refuses it), and the export features; `Err` with the - /// copy form's reason, or the gap of a usage the plan asks that the tiling lacks. + /// plan's usage that the query offers, with the feedback usage where the plan asks it and the + /// query offers it with the rest and the export features alike, and its view-format list, the + /// plan's formats the tiling samples (none where the query refuses it), and the export + /// features; `Err` with the copy form's reason, or the gap of a usage the plan asks that the + /// tiling lacks. fn plane( &self, at: usize, @@ -417,7 +424,15 @@ impl Query<'_> { } } }; - Ok(tiling_verdict(at, offered, features).map(|()| (offered, list))) + if let Err(reason) = tiling_verdict(at, offered, features) { + return Ok(Err(reason)); + } + let looped = offered | vk::ImageUsageFlags::ATTACHMENT_FEEDBACK_LOOP_EXT; + let keeps = |features| tiling_verdict(at, looped, features).is_ok(); + if plan.looped && self.external(plan.format, looped, &list).is_some_and(keeps) { + return Ok(Ok((looped, list))); + } + Ok(Ok((offered, list))) } } @@ -698,13 +713,29 @@ impl Device { start_multiple: spec.start_multiple, }))?; step!("plans"); - let in_place = match handle { + let in_place = |plans: &[PlanePlan]| match handle { ExportHandle::DmaBuf if !core.exports.modifiers => Ok(Err(SurfaceCopy::NoModifier)), #[cfg(unix)] - ExportHandle::DmaBuf => self.dma_buf_in_place(spec, &plans, multiple), - _ => self.opaque_in_place(spec, &plans, multiple), - }?; - let made = match in_place { + ExportHandle::DmaBuf => self.dma_buf_in_place(spec, plans, multiple), + _ => self.opaque_in_place(spec, plans, multiple), + }; + let mut in_place_made = in_place(&plans)?; + // Where the images with the feedback usage do not hold the layout, the images without it + // may: a draw then reads such a plane as an attachment of its own pass through its shadow. + let laid = matches!( + in_place_made, + Ok(_) | Err(SurfaceCopy::Tiling { .. } | SurfaceCopy::NoModifier) + ); + if !laid && plans.iter().any(|plan| plan.looped) { + let plain: Vec = (plans.iter()) + .map(|plan| PlanePlan { + looped: false, + ..plan.clone() + }) + .collect(); + in_place_made = in_place(&plain)?; + } + let made = match in_place_made { Ok(made) => made, Err(reason) => return self.copy_form(spec, &plans, multiple, reason), }; diff --git a/crates/metal2vulkan-rt/src/tests/draw.rs b/crates/metal2vulkan-rt/src/tests/draw.rs index 0f778459e..81851d16d 100644 --- a/crates/metal2vulkan-rt/src/tests/draw.rs +++ b/crates/metal2vulkan-rt/src/tests/draw.rs @@ -2037,7 +2037,12 @@ define internal void @_GLOBAL__sub_I_() section "air.static_init" { } /// A shader-read render target of `format`, `SIDE` a side and `levels` levels, at `index`. - fn readable(device: &Device, format: PixelFormat, levels: u32, index: u32) -> Texture { + pub(crate) fn readable( + device: &Device, + format: PixelFormat, + levels: u32, + index: u32, + ) -> Texture { let mut d = TextureDescriptor::new(TextureType::Type2D, format, SIDE, SIDE); d.usage = TextureUsage::RENDER_TARGET | TextureUsage::SHADER_READ; d.storage_mode = StorageMode::Shared; @@ -2167,6 +2172,12 @@ define internal void @_GLOBAL__sub_I_() section "air.static_init" { !looped, "{name} {case}: the target's shadow, live with it" ); + // Through the loop, both reading draws count; through a copy, neither. + assert_eq!( + after.attachment_loop_reads - before.attachment_loop_reads, + if looped { 2 } else { 0 }, + "{name} {case}: draws that read an attachment through the loop" + ); println!( "{name} {case}: attachment_read_copies {}, attachment_read_copy_bytes {}; \ live shadows {} of {} bytes", diff --git a/crates/metal2vulkan-rt/src/tests/fetch.rs b/crates/metal2vulkan-rt/src/tests/fetch.rs new file mode 100644 index 000000000..d19f05806 --- /dev/null +++ b/crates/metal2vulkan-rt/src/tests/fetch.rs @@ -0,0 +1,410 @@ +//! Framebuffer fetch (`[[color(n)]]`) on every device of the cfg's kind: a pass of N draws of one +//! triangle over the whole target, each reading the colour under it and writing a function of +//! it, which Metal orders draw after draw, so the target holds that function applied N times. +//! The fetch reads the attachment's texture at the fragment's own pixel: through the attachment +//! feedback loop, one barrier before each fetching draw after the first, or through the image's +//! shadow, one copy before each. Both forms are counted, and a device without the attachment +//! reads refuses the draw. + +#[cfg(any(m2v_gpu, m2v_cpu_icd))] +mod on_device { + use crate::tests::blit::on_device::settled; + use crate::tests::command::on_device::each_device; + use crate::tests::draw::on_device::{ + descriptor, examples, floats, library, read, readable, run, state, Buffers, SIDE, + }; + use crate::texture::TextureObject; + use crate::{ + BufferLayout, ClearColor, CommandQueue, Device, DrawKind, Error, ExportHandle, + FunctionDescriptor, Gap, IndexClass, Library, LoadAction, MemoryClass, PixelFormat, + PlaneSpec, PrimitiveType, RenderPassDescriptor, RenderPipelineDescriptor, StageSource, + SurfaceForm, SurfaceSpec, Texture, TextureDescriptor, TexturePlace, TextureType, + TextureUsage, + }; + use metal2vulkan_devtools::engine_dir; + + /// The draw counts of the passes, each over a target of its own. + const DRAWS: [u32; 2] = [1, 4]; + + /// The opaque handle of this host. + const OPAQUE: ExportHandle = match cfg!(windows) { + true => ExportHandle::OpaqueWin32, + false => ExportHandle::OpaqueFd, + }; + + /// The handles a surface plane is made over, where the device exports them. + #[cfg(unix)] + const HANDLES: [ExportHandle; 2] = [OPAQUE, ExportHandle::DmaBuf]; + #[cfg(not(unix))] + const HANDLES: [ExportHandle; 1] = [OPAQUE]; + + /// `colored_vertex` with `fragment` of the owned fixture `engine/.ll`, into one + /// colour attachment of `format`; `None` where `llvm-as` is missing. + fn fetching( + fixture: &str, + fragment: &str, + format: PixelFormat, + ) -> Option { + let examples: Library = examples()?; + let engine = library(&engine_dir().join(format!("{fixture}.ll")))?; + let mut d = descriptor(&examples, "colored_fragment", format); + d.fragment = Some(StageSource::Function(FunctionDescriptor::new( + (engine.function(fragment)).expect("the function"), + ))); + Some(d) + } + + /// What a pass of draws changed: barriers, draws through the loop, copies into shadows and + /// their bytes. + #[derive(Clone, Copy, Debug, PartialEq, Eq)] + struct Counted { + barriers: u64, + loop_reads: u64, + copies: u64, + copy_bytes: u64, + } + + /// A pass over `color`, cleared to `clear`, of `draws` draws of the triangle over the whole + /// target through `state`: its result, and what it counted. The new target's move home is + /// recorded first, in a submission of its own. + fn pass_of( + (name, device, queue): (&str, &Device, &CommandQueue), + state: &crate::RenderPipelineState, + color: &Texture, + clear: ClearColor, + draws: u32, + ) -> (Result<(), Error>, Counted) { + let mut buffers = Buffers::new(device); + let whole = [-1.0, -1.0, 3.0, -1.0, -1.0, 3.0]; + let positions = buffers.of(device, &floats(&whole)); + let colors = buffers.of(device, &floats(&[0.0; 12])); + let upload = queue.command_buffer().expect("a command buffer"); + (upload.record_for_test(&[], |_, _| {})).expect("a command buffer's commands"); + run(name, &upload); + let counters = device.counters(); + settled(device); + let before = counters.metrics(); + let mut d = RenderPassDescriptor::default(); + let c = &mut d.color_attachments[0]; + c.texture = Some(color.clone()); + c.load_action = LoadAction::Clear; + c.clear_color = clear; + let command_buffer = queue.command_buffer().expect("a command buffer"); + let mut encoder = (command_buffer.render_command_encoder(&d)) + .unwrap_or_else(|error| panic!("{name}: {error}")); + let set = |result: Result<(), Error>| result.unwrap_or_else(|e| panic!("{name}: {e}")); + set(encoder.set_vertex_buffer(Some(&positions), 0, 0)); + set(encoder.set_vertex_buffer(Some(&colors), 0, 1)); + set(encoder.set_render_pipeline_state(state)); + let mut drew = Ok(()); + for _ in 0..draws { + drew = encoder.draw_primitives(PrimitiveType::Triangle, 0, 3, 1, 0); + if drew.is_err() { + break; + } + } + encoder.end_encoding(); + run(name, &command_buffer); + let after = counters.metrics(); + let counted = Counted { + barriers: after.barriers - before.barriers, + loop_reads: after.attachment_loop_reads - before.attachment_loop_reads, + copies: after.attachment_read_copies - before.attachment_read_copies, + copy_bytes: after.attachment_read_copy_bytes - before.attachment_read_copy_bytes, + }; + (drew, counted) + } + + /// What a pass of `draws` fetching draws counts beyond a pass of one, through the loop + /// (`looped`) or through copies of `texel` bytes a texel, and the loop reads it counts itself. + fn more(looped: bool, draws: u32, texel: u64) -> (Counted, u64) { + let later = u64::from(draws - 1); + let bytes = u64::from(SIDE * SIDE) * texel; + match looped { + // One barrier before each fetching draw after the first; every draw through the loop. + true => ( + Counted { + barriers: later, + loop_reads: later, + copies: 0, + copy_bytes: 0, + }, + u64::from(draws), + ), + // One copy of the whole target before each, between two barriers of its own. + false => ( + Counted { + barriers: 2 * later, + loop_reads: 0, + copies: later, + copy_bytes: later * bytes, + }, + 0, + ), + } + } + + /// The texels of `texture`, `texel` bytes each, through a blit into a Shared buffer: a + /// surface plane's bytes, which the host reads no other way. + fn blitted( + name: &str, + device: &Device, + queue: &CommandQueue, + texture: &Texture, + texel: u64, + ) -> Vec { + let len = u64::from(SIDE * SIDE) * texel; + let block = (device.take_block(MemoryClass::Shared, len)).expect("a block"); + let out = (device.new_buffer(block.id, 0, len, None)).expect("a buffer"); + let command_buffer = queue.command_buffer().expect("a command buffer"); + let mut encoder = command_buffer.blit_command_encoder().expect("an encoder"); + let layout = BufferLayout { + offset: 0, + bytes_per_row: u64::from(SIDE) * texel, + bytes_per_image: 0, + }; + (encoder.copy_from_texture_to_buffer( + texture, + TexturePlace::default(), + [SIDE, SIDE, 1], + &out, + layout, + )) + .unwrap_or_else(|error| panic!("{name}: the read: {error}")); + encoder.end_encoding(); + run(name, &command_buffer); + let contents = out.contents().expect("a Shared buffer"); + // SAFETY: the buffer is alive, `len` bytes long, and no GPU work uses it. + unsafe { std::slice::from_raw_parts(contents.as_ptr(), len as usize) }.to_vec() + } + + /// The `half` of `2^e`, a normal number: its exponent field alone. + fn half_power(e: i32) -> u16 { + ((e + 15) as u16) << 10 + } + + /// The difference of two passes' counts. + fn less(a: Counted, b: Counted) -> Counted { + Counted { + barriers: a.barriers - b.barriers, + loop_reads: a.loop_reads - b.loop_reads, + copies: a.copies - b.copies, + copy_bytes: a.copy_bytes - b.copy_bytes, + } + } + + /// `exf_fetch_count` reads its `RGBA32Uint` attachment and writes `count * 3 + (1, 2, 3, 4)`: + /// after N draws over a target cleared to `(0, 0, 0, 1)` every texel holds + /// `c * 3^N + (k + 1)(3^N - 1) / 2` in channel `k`, exact only where each draw read what the + /// one before it wrote. Through the loop, a pass of N draws records N - 1 barriers more than + /// a pass of one and counts N draws through the loop; through the shadow, N - 1 copies of the + /// target more, each between two barriers. A device without the attachment reads refuses the + /// first draw, `Gap::Draw { FetchedAttachment }`. + #[test] + fn every_device_orders_each_fetching_draw_after_the_draws_before_it() { + let Some(d) = fetching( + "exf_fetch_count", + "exf_fetch_count", + PixelFormat::RGBA32Uint, + ) else { + return; + }; + each_device("fetch", |name, _, device| { + (device.grant_indices(IndexClass::Texture, 4096, DRAWS.len() as u32)) + .unwrap_or_else(|error| panic!("{name}: {error}")); + let reads = device.core().attachment_reads; + let looped = device.core().feedback.is_some(); + let state = state(name, &device, &d); + let queue = device.new_command_queue(4).expect("a queue"); + let clear = ClearColor { + red: 0.0, + green: 0.0, + blue: 0.0, + alpha: 1.0, + }; + let mut counts = Vec::new(); + for (at, &draws) in DRAWS.iter().enumerate() { + let color = readable(&device, PixelFormat::RGBA32Uint, 1, 4096 + at as u32); + let (drew, counted) = + pass_of((name, &device, &queue), &state, &color, clear, draws); + if !reads { + assert_eq!( + format!("{drew:?}"), + format!( + "{:?}", + Err::<(), _>(Error::Unsupported(Gap::Draw { + kind: DrawKind::FetchedAttachment + })) + ), + "{name}: a device without the attachment reads" + ); + continue; + } + drew.unwrap_or_else(|error| panic!("{name}: {draws} draws: {error}")); + let three = 3u32.pow(draws); + let want: Vec = (0..SIDE * SIDE) + .flat_map(|_| { + [0u32, 0, 0, 1] + .into_iter() + .enumerate() + .map(move |(k, c)| c * three + (k as u32 + 1) * (three - 1) / 2) + }) + .flat_map(u32::to_le_bytes) + .collect(); + assert_eq!(read(&color, 16), want, "{name}: {draws} draws, every texel"); + counts.push(counted); + } + if !reads { + println!("{name}: no attachment reads; the fetching draw refused"); + return; + } + let draws = DRAWS[1]; + let (want, loop_reads) = more(looped, draws, 16); + assert_eq!( + less(counts[1], counts[0]), + want, + "{name}: {draws} draws against 1" + ); + assert_eq!( + counts[1].loop_reads, loop_reads, + "{name}: {draws} draws through the loop" + ); + println!( + "{name}: {draws} fetching draws exact through {}: {:?} against one draw's {:?}", + if looped { + "the feedback loop" + } else { + "copies into the shadow" + }, + counts[1], + counts[0], + ); + }); + } + + /// A surface plane fetched as a texture of an image of its own is: for each handle the device + /// exports and each format the compositor's fetches carry (`RGBA16Float`, `BGRA8Unorm` and + /// `RGBA8Unorm`), a one-plane surface of a shader-read render target, whose image takes the + /// feedback usage where the device has the loop and the handle's query offers it (printed + /// with its form and pitch). On the `RGBA16Float` plane, `fetch_ordered` halves the colour + /// under it in each of N draws over a target cleared to `(1, 0.5, 0.25, 1)`: every texel + /// `2^-N` of it, exact in `half`, through the loop or the plane's shadow, counted as on a + /// texture of its own image. + #[test] + fn every_device_fetches_a_surface_plane_through_the_loop_or_its_shadow() { + let Some(d) = fetching("fragment_fetch", "fetch_ordered", PixelFormat::RGBA16Float) else { + return; + }; + each_device("fetch_surface", |name, _, device| { + let first = IndexClass::Texture.range().start; + let _grant = (device.grant_indices(IndexClass::Texture, first, 1)) + .unwrap_or_else(|error| panic!("{name}: {error}")); + let reads = device.core().attachment_reads; + let state = state(name, &device, &d); + let queue = device.new_command_queue(4).expect("a queue"); + let clear = ClearColor { + red: 1.0, + green: 0.5, + blue: 0.25, + alpha: 1.0, + }; + for handle in HANDLES { + if !device.core().exports.offers(handle) { + println!("fetch-surface: {name}: {handle:?} not exported"); + continue; + } + for format in [ + PixelFormat::RGBA16Float, + PixelFormat::BGRA8Unorm, + PixelFormat::RGBA8Unorm, + ] { + let label = format!("{name}: {handle:?} {format:?}"); + let mut descriptor = + TextureDescriptor::new(TextureType::Type2D, format, SIDE, SIDE); + descriptor.usage = TextureUsage::RENDER_TARGET | TextureUsage::SHADER_READ; + let planes = [PlaneSpec { + descriptor, + index: Some(first), + rows_below: 0, + }]; + let spec = SurfaceSpec { + handle, + pitch_multiple: 4, + start_multiple: 1, + planes: &planes, + }; + let (surface, export) = (device.new_exported_surface(&spec)) + .unwrap_or_else(|error| panic!("{label}: {error}")); + let plane = &surface.planes()[0]; + let in_place = export.form == SurfaceForm::InPlace; + let looped = in_place && plane.looped(); + println!( + "fetch-surface: {label}: form {:?}, pitch {}, the feedback usage {}, \ + read through {}", + export.form, + export.planes[0].row_pitch, + looped, + match (plane.attachment_reads(), looped) { + (false, _) => "nothing (refused)", + (true, true) => "the feedback loop", + (true, false) => "its shadow", + }, + ); + if format != PixelFormat::RGBA16Float { + continue; + } + let mut counts = Vec::new(); + for draws in DRAWS { + let (drew, counted) = + pass_of((&label, &device, &queue), &state, plane, clear, draws); + if !reads { + assert!( + matches!( + drew, + Err(Error::Unsupported(Gap::Draw { + kind: DrawKind::FetchedAttachment + })) + ), + "{label}: a device without the attachment reads: {drew:?}" + ); + break; + } + drew.unwrap_or_else(|error| panic!("{label}: {draws} draws: {error}")); + // The clear's channels are 2^0, 2^-1, 2^-2 and 2^0, each halved per draw. + let n = draws as i32; + let texel: Vec = [0, -1, -2, 0] + .into_iter() + .flat_map(|e| half_power(e - n).to_le_bytes()) + .collect(); + let want = texel.repeat((SIDE * SIDE) as usize); + assert_eq!( + blitted(&label, &device, &queue, plane, 8), + want, + "{label}: {draws} draws, every texel" + ); + counts.push(counted); + } + if !reads { + continue; + } + let draws = DRAWS[1]; + let (want, loop_reads) = more(looped, draws, 8); + assert_eq!( + less(counts[1], counts[0]), + want, + "{label}: {draws} draws against 1" + ); + assert_eq!( + counts[1].loop_reads, loop_reads, + "{label}: through the loop" + ); + println!( + "fetch-surface: {label}: {draws} fetching draws exact: {:?} against one \ + draw's {:?}", + counts[1], counts[0], + ); + } + } + }); + } +} diff --git a/crates/metal2vulkan-rt/src/tests/mod.rs b/crates/metal2vulkan-rt/src/tests/mod.rs index 76f03273f..ad85e6ce6 100644 --- a/crates/metal2vulkan-rt/src/tests/mod.rs +++ b/crates/metal2vulkan-rt/src/tests/mod.rs @@ -16,6 +16,7 @@ mod dma_bufs; mod draw; mod export; mod fence; +mod fetch; mod floor; mod hazard; mod heap; diff --git a/crates/metal2vulkan-rt/src/texture.rs b/crates/metal2vulkan-rt/src/texture.rs index ea46e5fcb..a27880263 100644 --- a/crates/metal2vulkan-rt/src/texture.rs +++ b/crates/metal2vulkan-rt/src/texture.rs @@ -1531,6 +1531,36 @@ impl Plan { self.usage & !vk::ImageUsageFlags::ATTACHMENT_FEEDBACK_LOOP_EXT } + /// Whether a draw may read an attachment of its own pass through a texture of the plan, where + /// its image takes the feedback usage or a shadow: a shader-read colour render target of no + /// storage view, on a device that reads attachments. + fn reads_attachments(&self, core: &Core) -> bool { + let render = + vk::ImageUsageFlags::COLOR_ATTACHMENT | vk::ImageUsageFlags::DEPTH_STENCIL_ATTACHMENT; + core.attachment_reads + && self.usage.contains(vk::ImageUsageFlags::SAMPLED) + && self.usage.intersects(render) + && !self.storage + && self.aspects == vk::ImageAspectFlags::COLOR + } + + /// Whether the device makes the shadow of an image of the plan over `shape`: its image format + /// query of an optimal image of the plan's format, flags and view formats, with the shadow's + /// usage. + fn shadow_offered(&self, core: &Core, shape: &Shape) -> bool { + let mut list = self.format_list(); + let mut info = vk::PhysicalDeviceImageFormatInfo2::default() + .format(self.format) + .ty(shape.image_type) + .tiling(vk::ImageTiling::OPTIMAL) + .usage(SHADOW_USAGE) + .flags(self.flags(shape)); + if !self.view_formats.is_empty() { + info = info.push_next(&mut list); + } + core.image_format_properties(&info).is_some() + } + /// The plan of the image's shadow (`crate::shadow`): its format, samples and aspects, with /// the shadow's usage and no view of its own. fn shadow(&self) -> Plan { @@ -1948,18 +1978,10 @@ fn plan( true => vk::ImageCreateFlags::CUBE_COMPATIBLE, false => vk::ImageCreateFlags::empty(), }; - let read = plan.usage.contains(vk::ImageUsageFlags::SAMPLED); - let render = plan.usage.intersects( - vk::ImageUsageFlags::COLOR_ATTACHMENT | vk::ImageUsageFlags::DEPTH_STENCIL_ATTACHMENT, - ); // A draw may read an attachment of its own pass through such a texture // (`crate::render_encoder`), where the device reads attachments: in the feedback layout where // it has the attachment feedback loop, else through a copy into the image's shadow. - let mut attachment_reads = core.attachment_reads - && read - && render - && !plan.storage - && plan.aspects == vk::ImageAspectFlags::COLOR; + let mut attachment_reads = plan.reads_attachments(core); let looped = attachment_reads && core.feedback.is_some(); let mut image_usage = plan.usage; if looped { @@ -3801,6 +3823,13 @@ pub(crate) trait TextureObject { image.attachment_reads && (image.looped() || self.object().shadow.is_some()) } + /// Whether a draw reads an attachment of its own pass through it in the feedback layout + /// ([`Image`]'s `looped`), where its image has the feedback usage; else through its view of + /// the image's shadow. + fn looped(&self) -> bool { + self.object().image.looped() + } + /// Its resource id while a draw reads an attachment through it: its second element's, at its /// index plus [`TEXTURES`](crate::floor::TEXTURES), with its own word. Nil for a /// texture no shader reaches. @@ -4415,6 +4444,7 @@ impl Device { Ok(crate::surface::PlanePlan { format: plan.format, usage: plan.linear_usage(), + looped: plan.reads_attachments(self.core()) && self.core().feedback.is_some(), view_formats: plan.view_formats.clone(), texel, }) @@ -4484,6 +4514,21 @@ impl Device { // A view of the image's format as the texture's takes the image's usage that its own // format's features hold, as a texture view of another format does. let views_usage = (made.format != plan.format).then_some(made.usage & plan.supported); + // A draw may read an attachment of its own pass through it as through a texture of its + // own image: in the feedback layout where the plane's image took the feedback usage + // (`crate::surface`), else through a copy into its shadow. + let looped = made + .usage + .contains(vk::ImageUsageFlags::ATTACHMENT_FEEDBACK_LOOP_EXT); + let shadowing = (!looped + && plan.reads_attachments(core) + && plan.shadow_offered(core, &shape)) + .then(|| { + Box::new(Shadowing { + made: (d, shape, plan.shadow()), + shadow: Mutex::new(None), + }) + }); let image = Arc::new(Image { core: Arc::clone(core), image: made.image, @@ -4492,8 +4537,8 @@ impl Device { sampled, storage, home, - attachment_reads: false, - shadowing: None, + attachment_reads: looped || shadowing.is_some(), + shadowing, shadow: false, aspects: plan.aspects, format: made.format, @@ -4510,6 +4555,7 @@ impl Device { drawable: None, _under: Some(Under::Surface { _block: made.block }), }); + let shadow = ShadowView::of(&image, &plan, index, shape.view_type, whole); // The texture's elements of set 1, written as it takes its index; a refusal frees the // image as `image` drops. let index = match index { @@ -4524,7 +4570,7 @@ impl Device { &core.counters, index, (sampled, storage), - false, + image.looped(), ) }?; Some((index, owner)) @@ -4546,7 +4592,7 @@ impl Device { view: None, emulation: plan.emulation, attachments: Mutex::new(Vec::new()), - shadow: None, + shadow, }; let texture = Texture { inner: Arc::new(inner), diff --git a/crates/metal2vulkan-validation/src/replay/new_runtime/mod.rs b/crates/metal2vulkan-validation/src/replay/new_runtime/mod.rs index 3e012d891..924090fbc 100644 --- a/crates/metal2vulkan-validation/src/replay/new_runtime/mod.rs +++ b/crates/metal2vulkan-validation/src/replay/new_runtime/mod.rs @@ -2647,6 +2647,7 @@ impl Backend for NewRuntime { "attachment_read_copy_bytes", metrics.attachment_read_copy_bytes, ), + ("attachment_loop_reads", metrics.attachment_loop_reads), ("bytes_zeroed", metrics.bytes_zeroed), ("takes_from_free_ranges", metrics.takes_from_free_ranges), ("block_zero_fills", metrics.block_zero_fills), diff --git a/crates/metal2vulkan/src/lower/fragment/color.rs b/crates/metal2vulkan/src/lower/fragment/color.rs index 3fd778875..d3fbc86b5 100644 --- a/crates/metal2vulkan/src/lower/fragment/color.rs +++ b/crates/metal2vulkan/src/lower/fragment/color.rs @@ -95,8 +95,8 @@ use crate::spirv::builder::{FunctionBuilder, ModuleBuilder}; use crate::spirv::error::BResult; use crate::spirv::ids::{GlobalId, Value as SValue}; use crate::spirv::ir::{ - Constant, Dim, ImageOperands, ImageType, ImageUsage, MemAccess, StorageClass, TexelMemory, - Type as SType, + Constant, ConvOp, Dim, ImageOperands, ImageType, ImageUsage, MemAccess, StorageClass, + TexelMemory, Type as SType, }; use super::not_lowered; @@ -628,7 +628,8 @@ pub(super) fn input_texel( /// The texel of color `color` read through the sampled-texture array's element the consumer pushes /// for it (`PushField::FetchedColor`), an element of `class`: a fetch at level 0 of the integer /// part of the invocation's `FragCoord`, its own pixel, and at its `SampleId` for a per-sample -/// function. The element is uniform over the draw. +/// function, a signed-integer texel's bits as the `uint`s the input attachment form reads. The +/// element is uniform over the draw. fn pushed_texel( cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, @@ -663,5 +664,14 @@ fn pushed_texel( } } }; - fb.fetch(img, coord, &ops) + let texel = fb.fetch(img, coord, &ops)?; + if class.sampled_type != SampledType::Sint { + return Ok(texel); + } + let u32_ = fb.module().ty(SType::Int { + width: 32, + signed: false, + })?; + let uvec4 = fb.module().ty(SType::Vector { elem: u32_, len: 4 })?; + fb.convert(ConvOp::Bitcast, texel, uvec4) } diff --git a/crates/metal2vulkan/src/pipeline/artifact.rs b/crates/metal2vulkan/src/pipeline/artifact.rs index bd272b9a4..8e1f3adab 100644 --- a/crates/metal2vulkan/src/pipeline/artifact.rs +++ b/crates/metal2vulkan/src/pipeline/artifact.rs @@ -2356,7 +2356,10 @@ pub enum PrecisionNote { /// dependency on itself, by region, from the color writes of the draws before to the input /// attachment reads of a draw that fetches (and from those reads to the color writes of the /// draws after): a fetch reads what every earlier draw stored at its pixel, Metal's answer. - /// Vulkan orders nothing between the overlapping fragments of one draw + /// Under the identity domains it reads the attachment's texture at its own pixel instead + /// ([`PushField::FetchedColor`](crate::pipeline::PushField::FetchedColor)), and the + /// consumer orders each fetching draw after the earlier draws of its pass by a barrier between + /// them. Vulkan orders nothing between the overlapping fragments of one draw /// (`GraphicsState::rasterization_order_attachment_access` false), where Metal orders them in /// primitive order: a fragment that covers a pixel an earlier fragment of its own draw /// covered may read the texel from before that fragment's write, and its own write may land diff --git a/crates/metal2vulkan/src/pipeline/compile/tests.rs b/crates/metal2vulkan/src/pipeline/compile/tests.rs index 536b5debc..f9ff36195 100644 --- a/crates/metal2vulkan/src/pipeline/compile/tests.rs +++ b/crates/metal2vulkan/src/pipeline/compile/tests.rs @@ -1975,6 +1975,127 @@ fn a_framebuffer_fetch_pipeline_is_ordered_exactly_where_the_device_orders_it() } } +/// Under the identity domains on a device that orders framebuffer fetch in neither form (rt's +/// profile), a color read takes no input attachment and no descriptor: the fragment fetches the +/// sampled-texture array's element pushed for the attachment (`PushField::FetchedColor`), in the +/// attachment's own numeric class (an unsigned read of a signed-integer attachment as `int`, which +/// the element's view takes), noted `UnorderedFetchWithinDraw`. A read of another class than the +/// attachment's is Metal's pipeline error, at link. +#[test] +fn an_identity_fetch_reads_its_attachments_pushed_texture_in_the_attachments_class() { + use crate::device::requirements::VkFeature; + use crate::device::{HandleDomain, PointerDomain}; + use crate::error::MetalAnswer; + use crate::pipeline::sym::{PushField, SampledType, Stage}; + use crate::pipeline::{PrecisionNote, RenderPipeline}; + let (Some(io), Some(fetch), Some(count)) = ( + fixture("stage_io"), + fixture("fragment_fetch"), + fixture("exf_fetch_count"), + ) else { + return; + }; + let function = |bytes: &[u8], name: &str| { + StageSource::Function(FunctionDescriptor::new( + (Library::from_air(bytes).expect("library").function(name)).expect(name), + )) + }; + let pipeline = |fragment: StageSource, format: metal::PixelFormat| { + let mut d = RenderPipelineDescriptor::new(function(&io, "stage_io_vertex_position")); + d.fragment = Some(fragment); + d.color_attachments[0] = Some(ColorAttachmentDescriptor::new(format)); + d + }; + let mut without = description("lavapipe"); + for f in [ + VkFeature::RasterizationOrderColorAttachmentAccess, + VkFeature::FragmentShaderPixelInterlock, + ] { + without.features.remove(&f); + } + let mut policy = DevicePolicy::default(); + policy.pointer_domain = PointerDomain::Identity; + policy.handle_domain = HandleDomain::Identity; + let dev = Device::from_queries(without, policy).expect("device"); + let compile = + |d: &RenderPipelineDescriptor| dev.compile_render_pipeline(d, &Budget::standard()); + let fetched = |pipe: &RenderPipeline| -> Vec { + (pipe.interface.push.iter()) + .filter(|p| p.stage == Stage::Fragment) + .flat_map(|p| p.fields.iter().map(|f| f.field)) + .filter(|f| matches!(f, PushField::FetchedColor { .. })) + .collect() + }; + for (fragment, format, texels) in [ + ( + "fetch_scalar", + metal::PixelFormat::R32Float, + SampledType::Float, + ), + ( + "exf_fetch_count", + metal::PixelFormat::RGBA32Uint, + SampledType::Uint, + ), + ( + "exf_fetch_count", + metal::PixelFormat::RGBA32Sint, + SampledType::Sint, + ), + ] { + let bytes = match fragment { + "fetch_scalar" => &fetch, + _ => &count, + }; + let pipe = compile(&pipeline(function(bytes, fragment), format)) + .unwrap_or_else(|e| panic!("{fragment} {format:?}: {e:?}")); + assert_eq!( + fetched(&pipe), + [PushField::FetchedColor { color: 0, texels }], + "{fragment} {format:?}: the element pushed for attachment 0, of its class" + ); + assert!( + pipe.graphics.input_attachments.is_empty(), + "{fragment} {format:?}" + ); + assert!( + pipe.graphics.storage_attachments.is_empty(), + "{fragment} {format:?}" + ); + assert!(!pipe.graphics.rasterization_order_attachment_access); + assert!( + (pipe.layout.sets.iter()) + .filter(|s| s.set == 0) + .all(|s| s.bindings.is_empty()), + "{fragment} {format:?}: no descriptor in set 0" + ); + let fragment_stage = (pipe.stages.iter()) + .find(|s| s.stage == vk::ShaderStage::FRAGMENT) + .expect("a fragment stage"); + assert!(fragment_stage + .precision_notes + .contains(&PrecisionNote::UnorderedFetchWithinDraw)); + for s in &pipe.stages { + l3(&s.spirv, &pipe.requirements, &dev); + } + } + for (fragment, format) in [ + ("fetch_scalar", metal::PixelFormat::R32Uint), + ("exf_fetch_count", metal::PixelFormat::RGBA32Float), + ] { + let bytes = match fragment { + "fetch_scalar" => &fetch, + _ => &count, + }; + match compile(&pipeline(function(bytes, fragment), format)) { + Err(Error::InvalidDescriptor(DescriptorError::ColorAttachment { index, metal })) => { + assert_eq!((index, metal), (0, MetalAnswer::NilWithError), "{fragment}") + } + other => panic!("{fragment} {format:?}: {:?}", other.map(|_| ())), + } + } +} + /// The SPIR-V `OpTypeImage`s of `words` as `(dim, arrayed, ms)` operand triples, and whether a /// variable is decorated `BuiltIn SampleId`. fn images_and_sample_id(words: &[u32]) -> (Vec<(u32, u32, u32)>, bool) { diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index c9b04e31b..a2c26548a 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -2371,6 +2371,7 @@ field metal2vulkan-rt::Metrics.allocation_map_refusals pub allocation_map_refusa field metal2vulkan-rt::Metrics.allocations_freed pub allocations_freed: u64 field metal2vulkan-rt::Metrics.allocations_mapped pub allocations_mapped: u64 field metal2vulkan-rt::Metrics.allocations_mapped_on_takes pub allocations_mapped_on_takes: u64 +field metal2vulkan-rt::Metrics.attachment_loop_reads pub attachment_loop_reads: u64 field metal2vulkan-rt::Metrics.attachment_read_copies pub attachment_read_copies: u64 field metal2vulkan-rt::Metrics.attachment_read_copy_bytes pub attachment_read_copy_bytes: u64 field metal2vulkan-rt::Metrics.barriers pub barriers: u64 @@ -13839,6 +13840,7 @@ variant metal2vulkan-rt::DrawKind::AttachmentRead AttachmentRead variant metal2vulkan-rt::DrawKind::DepthBiasClamp DepthBiasClamp variant metal2vulkan-rt::DrawKind::DepthClamp DepthClamp variant metal2vulkan-rt::DrawKind::DividedBaseInstance DividedBaseInstance +variant metal2vulkan-rt::DrawKind::FetchedAttachment FetchedAttachment variant metal2vulkan-rt::DrawKind::FillMode FillMode variant metal2vulkan-rt::DrawKind::LineWidth LineWidth variant metal2vulkan-rt::DrawKind::PatchIndexBuffer PatchIndexBuffer @@ -14102,7 +14104,6 @@ variant metal2vulkan-rt::RenderPipelineKind::DepthStencilFormats DepthStencilFor variant metal2vulkan-rt::RenderPipelineKind::DeviceFeature DeviceFeature variant metal2vulkan-rt::RenderPipelineKind::DrawInput DrawInput variant metal2vulkan-rt::RenderPipelineKind::DynamicState DynamicState -variant metal2vulkan-rt::RenderPipelineKind::FramebufferFetch FramebufferFetch variant metal2vulkan-rt::RenderPipelineKind::Imageblock Imageblock variant metal2vulkan-rt::RenderPipelineKind::SampleCount SampleCount variant metal2vulkan-rt::RenderPipelineKind::ShaderStencil ShaderStencil @@ -17005,6 +17006,7 @@ variant metal2vulkan::pipeline::PushField::ControlPointIndexOffset ControlPointI variant metal2vulkan::pipeline::PushField::DepthClampRange DepthClampRange variant metal2vulkan::pipeline::PushField::DispatchRegion DispatchRegion variant metal2vulkan::pipeline::PushField::ExecutionStatusAddress ExecutionStatusAddress +variant metal2vulkan::pipeline::PushField::FetchedColor FetchedColor { color: u32, texels: SampledType } variant metal2vulkan::pipeline::PushField::HalfBlendColor HalfBlendColor variant metal2vulkan::pipeline::PushField::IndexCapacity IndexCapacity variant metal2vulkan::pipeline::PushField::InstanceCount InstanceCount(SlotRef) diff --git a/docs/API.md b/docs/API.md index 115d49eb0..0873208cc 100644 --- a/docs/API.md +++ b/docs/API.md @@ -177,7 +177,12 @@ compile does. `DevicePolicy::default()` is `DevicePolicy::UNTRUSTED`: `setAlphaTestReferenceValue:`, 1 until the encoder sets it. It is Metal's 8-bit unorm code of the reference (a NaN taken as 0, clamped to `[0, 1]`, the exact product with 255 rounded to nearest), the form the function converts its alpha to, so a consumer that pushes it compares as - Metal does. Every precision note is + Metal does. A fragment function's read of a color attachment (framebuffer fetch, section 4) on a + device with neither ordered form takes no input attachment: it reads, at the integer part of + its position (its own sample where the pass is multisampled), level 0, the sampled-texture + array's element at the index the consumer pushes for that attachment + (`PushField::FetchedColor { color, texels }`, `texels` the read's numeric class), and a + read-only signed-integer attachment joins `signed_color_attachments`. Every precision note is static there: no constant or binder decides one. So far they lower a kernel that reaches memory through its buffer slots and reads, writes, sizes or tests for nil its texture slots and its argument buffers' textures, and samples its texture slots through its runtime sampler slots @@ -1330,7 +1335,13 @@ Where Metal's rules differ from Vulkan's, the pipeline gives Metal's answer: attachments after an earlier draw of the subpass, or its load operations, wrote a color, and before each draw that writes a color after an earlier one read them: a fetch reads what every earlier draw stored, Metal's answer, but the overlapping fragments of one draw are not ordered, which the fragment stage - records (`PrecisionNote::UnorderedFetchWithinDraw`; the runtime does all of this itself). A + records (`PrecisionNote::UnorderedFetchWithinDraw`; the runtime does all of this itself). Under + the identity domains the read is the pushed texture of section 1 instead, at the fragment's own + pixel, with the same note: the consumer reads the attachment's texture there and orders each + fetching draw after the earlier draws of its pass. Linking refuses an attachment the read + cannot take: none attached, or one of another numeric class than the read's + (`InvalidDescriptor` at the color attachment), or one of a rotated, Y'CbCr or extended-range + format (`Unsupported{Format}`). A raster order group on such a color input, or on a color output of an attachment the function reads, orders that read alone there and takes no interlock; a group on anything else still needs the pixel interlock (`Unsupported{RasterOrderGroups}`). @@ -4927,7 +4938,11 @@ bound. dependency on itself, by region, before each draw that reads input attachments after an earlier draw of its render pass instance, or its load operations, wrote a color, and before each draw that writes a color after an earlier one read them (`WorkCounts::fetch_draw_barriers`): a fetch reads what every earlier - draw stored at its pixel, Metal's answer. Vulkan orders nothing between the overlapping + draw stored at its pixel, Metal's answer. Under the identity domains it reads the attachment's + texture at its own pixel instead (`PushField::FetchedColor`), and the consumer orders each + fetching draw after the earlier draws of its pass by a barrier between them (the new runtime's + `Metrics::attachment_loop_reads`, or its copies into the attachment's shadow on a device + without the attachment feedback loop). Vulkan orders nothing between the overlapping fragments of one draw there, where Metal orders them in primitive order: a fragment that covers a pixel an earlier fragment of its own draw covered may read the texel from before that fragment's write. Exact for a draw whose primitives do not overlap at a pixel; otherwise each diff --git a/docs/REFUSALS.md b/docs/REFUSALS.md index 766b00e40..3c49130c6 100644 --- a/docs/REFUSALS.md +++ b/docs/REFUSALS.md @@ -103,7 +103,7 @@ Columns: | `BufferRange` | A buffer window beyond the descriptor range limits | devices without a capability the site computes (`needs`); devices without buffer device addresses (`addressed_needs`); every device (no Vulkan mechanism) | `device` | 8: `crates/metal2vulkan-runtime/src/function_table.rs (past_storage_buffer_range)`, `crates/metal2vulkan/src/bind/graphics.rs (patch_binding, 3 sites)` (+4) | `app`: a buffer window past a device's descriptor range | | `Int64Arithmetic` | 64-bit integer arithmetic | devices without VkFeature::ShaderInt64 | `device` | 2: `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)`, `crates/metal2vulkan/src/lower/select.rs (selector_form)` | `rare`: 64-bit integers on a device without shaderInt64 | | `Float64Arithmetic` | 64-bit float arithmetic | devices without VkFeature::ShaderFloat64 | `device` | 2: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`, `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)` | `rare`: doubles (MSL has none outside Apple's own code) | -| `Format` | A pixel or vertex format not supported for the required use | devices without VkFeature::ShaderStorageImageExtendedFormats; devices without a capability the site computes; devices without a capability the site computes (`alternatives`); devices without a capability the site computes (`c`); devices without a capability the site computes (`missing`); devices without a capability the site computes (`routes`); devices without a format's usage; every device (no Vulkan mechanism); every device (not implemented) | `ours` | 129: `crates/metal2vulkan-runtime/src/binding_view.rs (binding_view, 2 sites)`, `crates/metal2vulkan-runtime/src/blit_fill.rs (fill)` (+84) | `system`: pixel formats a device lacks for a use (CoreVideo's 4:2:x and 10-bit formats among them) | +| `Format` | A pixel or vertex format not supported for the required use | devices without VkFeature::ShaderStorageImageExtendedFormats; devices without a capability the site computes; devices without a capability the site computes (`alternatives`); devices without a capability the site computes (`c`); devices without a capability the site computes (`missing`); devices without a capability the site computes (`routes`); devices without a format's usage; every device (no Vulkan mechanism); every device (not implemented) | `ours` | 131: `crates/metal2vulkan-runtime/src/binding_view.rs (binding_view, 2 sites)`, `crates/metal2vulkan-runtime/src/blit_fill.rs (fill)` (+85) | `system`: pixel formats a device lacks for a use (CoreVideo's 4:2:x and 10-bit formats among them) | | `DivergentImplicitLod` | Divergent implicit-LOD sampling or LOD query through a multi-candidate handle | every device (not implemented) | `ours` | 1: `crates/metal2vulkan/src/lower/sampler/select.rs (tangled)` | `app`: implicit-LOD sampling through a dynamically chosen texture | | `ImplicitLodOutsideFragment` | Implicit-LOD sampling outside fragment | every device (not implemented) | `ours` | 3: `crates/metal2vulkan/src/lower/sampler/constexpr.rs (query_min_level)`, `crates/metal2vulkan/src/lower/sampler/select.rs (query_level_measured)` (+1) | `rare`: implicit-LOD sampling outside fragment functions | | `MinLodClamp` | `min_lod_clamp` without `shaderResourceMinLod` | devices without VkFeature::ShaderResourceMinLod; every device (not implemented) | `ours` | 2: `crates/metal2vulkan/src/lower/sampler/select.rs (min_lod)`, `crates/metal2vulkan/src/lower/sampler/select.rs (select_one)` | `rare`: min_lod_clamp on a device without shaderResourceMinLod | @@ -746,7 +746,7 @@ Columns: | `StorageElement` | A draw or dispatch whose function writes a texture slot, or reads one through its storage image (`access::read_write`), bound to a texture made... | every device (a public call's own check of its arguments) | `ours`: the storage element through a view of the nearest format whose storage Vulkan requires of every device, with the translator's conversion, is the form to build | 3: `crates/metal2vulkan-rt/src/encoder.rs (dispatch, 2 sites)`, `crates/metal2vulkan-rt/src/render_encoder.rs (find)` | `-` | | `TextureView` | `Texture::new_texture_view` of a kind Metal makes and the runtime does not build | every device (a public call's own check of its arguments) | `ours`: the replay streams' views that compute binds are same-format views of every slice, 2D views of one slice of a 2D array, and level subranges, swizzled or not; each other kind is built when a replay stream binds one | 1: `crates/metal2vulkan-rt/src/texture.rs (view)` | `-` | | `RenderPass` | A render pass of something the runtime does not build yet (`CommandBuffer::render_command_encoder`) | every device (a public call's own check of its arguments) | `ours`: the replay streams' passes render into one to two color attachments and a stencil or a depth attachment, each a level of a 2D texture of one sample, with no resolve and a clear depth of 1, none naming two textures for its depth and stencil; each other kind is built when a replay stream makes one; `DepthStencilViews` and `ClearDepth` are what Vulkan's rendering under the floor takes no form of | 5: `crates/metal2vulkan-rt/src/pass.rs (check)`, `crates/metal2vulkan-rt/src/pass.rs (ops)` (+3) | `-` | -| `Draw` | A draw or render encoder state the runtime does not build yet (`RenderCommandEncoder`) | every device (a public call's own check of its arguments) | `ours`: the replay streams draw lines and triangles through one viewport Vulkan's is, with pipeline states of their pass's formats, under depth biases with no clamp, filled and clipped; each other kind is built when a replay stream draws one), and device for [`DrawKind::DividedBaseInstance`] (a device that does not report `supportsNonZeroFirstInstance` | 12: `crates/metal2vulkan-rt/src/render_encoder.rs (attachment_reads)`, `crates/metal2vulkan-rt/src/render_encoder.rs (draw)` (+10) | `-` | +| `Draw` | A draw or render encoder state the runtime does not build yet (`RenderCommandEncoder`) | every device (a public call's own check of its arguments) | `ours`: the replay streams draw lines and triangles through one viewport Vulkan's is, with pipeline states of their pass's formats, under depth biases with no clamp, filled and clipped; each other kind is built when a replay stream draws one), and device for [`DrawKind::DividedBaseInstance`] (a device that does not report `supportsNonZeroFirstInstance` | 13: `crates/metal2vulkan-rt/src/render_encoder.rs (attachment_reads, 2 sites)`, `crates/metal2vulkan-rt/src/render_encoder.rs (draw)` (+10) | `-` | ## Appendix: every site @@ -792,7 +792,7 @@ Each refusal's sites, with the function that builds it. - `feature::BufferRange`: `crates/metal2vulkan-runtime/src/function_table.rs (past_storage_buffer_range)`; `crates/metal2vulkan/src/bind/graphics.rs (patch_binding, 3 sites)`; `crates/metal2vulkan/src/bind/graphics.rs (rebind_with)`; `crates/metal2vulkan/src/bind/instantiate.rs (bind_buffers)`; `crates/metal2vulkan/src/lower/access/function_table.rs (select)`; `crates/metal2vulkan/src/lower/access/mod.rs (place_slots)` - `feature::Int64Arithmetic`: `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)`; `crates/metal2vulkan/src/lower/select.rs (selector_form)` - `feature::Float64Arithmetic`: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`; `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)` -- `feature::Format`: `crates/metal2vulkan-runtime/src/binding_view.rs (binding_view, 2 sites)`; `crates/metal2vulkan-runtime/src/blit_fill.rs (fill)`; `crates/metal2vulkan-runtime/src/blit_plan.rs (check_formats, 3 sites)`; `crates/metal2vulkan-runtime/src/blit_plan.rs (pair_unit)`; `crates/metal2vulkan-runtime/src/blit_plan.rs (plan_levels_copy)`; `crates/metal2vulkan-runtime/src/blit_texture.rs (through_buffer)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs (shape_over, 3 sites)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs (texture_buffer_texel)`; `crates/metal2vulkan-runtime/src/color_resolve.rs (of_attachment)`; `crates/metal2vulkan-runtime/src/copy_plan.rs (colour_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs (copy_unit, 2 sites)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs (usable_twin)`; `crates/metal2vulkan-runtime/src/families/features.rs (read_write_tier)`; `crates/metal2vulkan-runtime/src/families/formats.rs (answers, 3 sites)`; `crates/metal2vulkan-runtime/src/families/formats.rs (atomic_gap)`; `crates/metal2vulkan-runtime/src/families/formats.rs (lacking)`; `crates/metal2vulkan-runtime/src/families/formats.rs (none)`; `crates/metal2vulkan-runtime/src/families/formats.rs (probe, 2 sites)`; `crates/metal2vulkan-runtime/src/families/formats.rs (sparse_missing)`; `crates/metal2vulkan-runtime/src/families/formats.rs (unsupported)`; `crates/metal2vulkan-runtime/src/image_plan.rs (plan_held, 3 sites)`; `crates/metal2vulkan-runtime/src/render.rs (viewing)`; `crates/metal2vulkan-runtime/src/render_pass.rs (attachment_format)`; `crates/metal2vulkan-runtime/src/render_pass.rs (check_target)`; `crates/metal2vulkan-runtime/src/render_pass.rs (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs (target)`; `crates/metal2vulkan-runtime/src/resolve.rs (unmodelled_resolve)`; `crates/metal2vulkan-runtime/src/sample_copy.rs (checked_twin)`; `crates/metal2vulkan-runtime/src/sample_copy.rs (plan)`; `crates/metal2vulkan-runtime/src/sample_interleave.rs (interleave_merge)`; `crates/metal2vulkan-runtime/src/shadow.rs (unmerged, 2 sites)`; `crates/metal2vulkan-runtime/src/texture.rs (plan_sparse_texture)`; `crates/metal2vulkan-runtime/src/texture.rs (texture_as)`; `crates/metal2vulkan-runtime/src/texture.rs (two_planes_refused)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs (astc_texels)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs (etc_texels)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs (with_decoded_twin)`; `crates/metal2vulkan-runtime/src/texture/heap.rs (planned_heap_texture)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs (refused)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs (converted_storage)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs (new_render_shadow)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs (ycbcr_write_shadow)`; `crates/metal2vulkan-runtime/src/two_planes.rs (unmeasured)`; `crates/metal2vulkan-runtime/src/view_plan.rs (check_format, 5 sites)`; `crates/metal2vulkan-runtime/src/ycbcr.rs (refused)`; `crates/metal2vulkan/src/bind/extended_shadow.rs (extended_shadow_module)`; `crates/metal2vulkan/src/bind/heap.rs (array)`; `crates/metal2vulkan/src/bind/plan/resources.rs (extended_sampler)`; `crates/metal2vulkan/src/bind/plan/resources.rs (plain_texture, 2 sites)`; `crates/metal2vulkan/src/bind/plan/resources.rs (require_filter_features)`; `crates/metal2vulkan/src/bind/sample_interleave.rs (finish)`; `crates/metal2vulkan/src/bind/sample_interleave.rs (interleave_split_module)`; `crates/metal2vulkan/src/bind/shadow_copy_in.rs (shadow_copy_in_module)`; `crates/metal2vulkan/src/lower/access/tile.rs (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs (select_param, 3 sites)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (extended_range_blend, 5 sites)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (select_output, 3 sites)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (select_read)`; `crates/metal2vulkan/src/lower/fragment/input_blend.rs (rotated)`; `crates/metal2vulkan/src/lower/sampler/select.rs (select_extended)`; `crates/metal2vulkan/src/lower/sampler/select.rs (texel_in)`; `crates/metal2vulkan/src/lower/stage_io/extended_color.rs (plan)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (entry)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (zeroed_output)`; `crates/metal2vulkan/src/lower/stage_io/word_color.rs (plan)`; `crates/metal2vulkan/src/lower/texture/mod.rs (cross_class)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_image)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_read_as, 2 sites)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_write)`; `crates/metal2vulkan/src/lower/texture/slot.rs (atomic_format, 2 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (declare_slot, 3 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (storage_format, 5 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (ulong_format, 3 sites)`; `crates/metal2vulkan/src/metal/format/mod.rs (candidates)`; `crates/metal2vulkan/src/metal/format/mod.rs (held_storage_choice, 3 sites)`; `crates/metal2vulkan/src/metal/format/mod.rs (storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs (vk_format, 2 sites)`; `crates/metal2vulkan/src/metal/vertex.rs (fetch_as, 2 sites)`; `crates/metal2vulkan/src/pipeline/color_writes.rs (rotated_blend_in_shader)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (extended_write_mask, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (graphics_state, 3 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (reads_alpha_to_coverage, 2 sites)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (alpha_in_red_blend)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (rotated_blend)` +- `feature::Format`: `crates/metal2vulkan-runtime/src/binding_view.rs (binding_view, 2 sites)`; `crates/metal2vulkan-runtime/src/blit_fill.rs (fill)`; `crates/metal2vulkan-runtime/src/blit_plan.rs (check_formats, 3 sites)`; `crates/metal2vulkan-runtime/src/blit_plan.rs (pair_unit)`; `crates/metal2vulkan-runtime/src/blit_plan.rs (plan_levels_copy)`; `crates/metal2vulkan-runtime/src/blit_texture.rs (through_buffer)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs (shape_over, 3 sites)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs (texture_buffer_texel)`; `crates/metal2vulkan-runtime/src/color_resolve.rs (of_attachment)`; `crates/metal2vulkan-runtime/src/copy_plan.rs (colour_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs (copy_unit, 2 sites)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs (usable_twin)`; `crates/metal2vulkan-runtime/src/families/features.rs (read_write_tier)`; `crates/metal2vulkan-runtime/src/families/formats.rs (answers, 3 sites)`; `crates/metal2vulkan-runtime/src/families/formats.rs (atomic_gap)`; `crates/metal2vulkan-runtime/src/families/formats.rs (lacking)`; `crates/metal2vulkan-runtime/src/families/formats.rs (none)`; `crates/metal2vulkan-runtime/src/families/formats.rs (probe, 2 sites)`; `crates/metal2vulkan-runtime/src/families/formats.rs (sparse_missing)`; `crates/metal2vulkan-runtime/src/families/formats.rs (unsupported)`; `crates/metal2vulkan-runtime/src/image_plan.rs (plan_held, 3 sites)`; `crates/metal2vulkan-runtime/src/render.rs (viewing)`; `crates/metal2vulkan-runtime/src/render_pass.rs (attachment_format)`; `crates/metal2vulkan-runtime/src/render_pass.rs (check_target)`; `crates/metal2vulkan-runtime/src/render_pass.rs (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs (target)`; `crates/metal2vulkan-runtime/src/resolve.rs (unmodelled_resolve)`; `crates/metal2vulkan-runtime/src/sample_copy.rs (checked_twin)`; `crates/metal2vulkan-runtime/src/sample_copy.rs (plan)`; `crates/metal2vulkan-runtime/src/sample_interleave.rs (interleave_merge)`; `crates/metal2vulkan-runtime/src/shadow.rs (unmerged, 2 sites)`; `crates/metal2vulkan-runtime/src/texture.rs (plan_sparse_texture)`; `crates/metal2vulkan-runtime/src/texture.rs (texture_as)`; `crates/metal2vulkan-runtime/src/texture.rs (two_planes_refused)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs (astc_texels)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs (etc_texels)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs (with_decoded_twin)`; `crates/metal2vulkan-runtime/src/texture/heap.rs (planned_heap_texture)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs (refused)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs (converted_storage)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs (new_render_shadow)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs (ycbcr_write_shadow)`; `crates/metal2vulkan-runtime/src/two_planes.rs (unmeasured)`; `crates/metal2vulkan-runtime/src/view_plan.rs (check_format, 5 sites)`; `crates/metal2vulkan-runtime/src/ycbcr.rs (refused)`; `crates/metal2vulkan/src/bind/extended_shadow.rs (extended_shadow_module)`; `crates/metal2vulkan/src/bind/heap.rs (array)`; `crates/metal2vulkan/src/bind/plan/resources.rs (extended_sampler)`; `crates/metal2vulkan/src/bind/plan/resources.rs (plain_texture, 2 sites)`; `crates/metal2vulkan/src/bind/plan/resources.rs (require_filter_features)`; `crates/metal2vulkan/src/bind/sample_interleave.rs (finish)`; `crates/metal2vulkan/src/bind/sample_interleave.rs (interleave_split_module)`; `crates/metal2vulkan/src/bind/shadow_copy_in.rs (shadow_copy_in_module)`; `crates/metal2vulkan/src/lower/access/tile.rs (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs (select_param, 4 sites)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (extended_range_blend, 5 sites)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (select_output, 3 sites)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (select_read)`; `crates/metal2vulkan/src/lower/fragment/input_blend.rs (rotated)`; `crates/metal2vulkan/src/lower/sampler/select.rs (select_extended)`; `crates/metal2vulkan/src/lower/sampler/select.rs (texel_in)`; `crates/metal2vulkan/src/lower/stage_io/extended_color.rs (plan)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (entry)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (zeroed_output)`; `crates/metal2vulkan/src/lower/stage_io/word_color.rs (plan)`; `crates/metal2vulkan/src/lower/texture/mod.rs (cross_class)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_image)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_read_as, 2 sites)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_write)`; `crates/metal2vulkan/src/lower/texture/slot.rs (atomic_format, 2 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (declare_slot, 3 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (storage_format, 5 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (ulong_format, 3 sites)`; `crates/metal2vulkan/src/metal/format/mod.rs (candidates)`; `crates/metal2vulkan/src/metal/format/mod.rs (held_storage_choice, 3 sites)`; `crates/metal2vulkan/src/metal/format/mod.rs (storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs (vk_format, 2 sites)`; `crates/metal2vulkan/src/metal/vertex.rs (fetch_as, 2 sites)`; `crates/metal2vulkan/src/pipeline/color_writes.rs (rotated_blend_in_shader)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (extended_write_mask, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (graphics_state, 3 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (reads_alpha_to_coverage, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (textured_fetches)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (alpha_in_red_blend)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (rotated_blend)` - `feature::DivergentImplicitLod`: `crates/metal2vulkan/src/lower/sampler/select.rs (tangled)` - `feature::ImplicitLodOutsideFragment`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs (query_min_level)`; `crates/metal2vulkan/src/lower/sampler/select.rs (query_level_measured)`; `crates/metal2vulkan/src/lower/sampler/select.rs (query_min_level)` - `feature::MinLodClamp`: `crates/metal2vulkan/src/lower/sampler/select.rs (min_lod)`; `crates/metal2vulkan/src/lower/sampler/select.rs (select_one)` @@ -1358,5 +1358,5 @@ Each refusal's sites, with the function that builds it. - `rt:Gap::StorageElement`: `crates/metal2vulkan-rt/src/encoder.rs (dispatch, 2 sites)`; `crates/metal2vulkan-rt/src/render_encoder.rs (find)` - `rt:Gap::TextureView`: `crates/metal2vulkan-rt/src/texture.rs (view)` - `rt:Gap::RenderPass`: `crates/metal2vulkan-rt/src/pass.rs (check)`; `crates/metal2vulkan-rt/src/pass.rs (ops)`; `crates/metal2vulkan-rt/src/pass.rs (resolve)`; `crates/metal2vulkan-rt/src/render_encoder.rs (later_store)`; `crates/metal2vulkan-rt/src/texture.rs (attachment)` -- `rt:Gap::Draw`: `crates/metal2vulkan-rt/src/render_encoder.rs (attachment_reads)`; `crates/metal2vulkan-rt/src/render_encoder.rs (draw)`; `crates/metal2vulkan-rt/src/render_encoder.rs (draw_patches)`; `crates/metal2vulkan-rt/src/render_encoder.rs (primitives)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_depth_bias)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_depth_clip_mode)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_scissor_rects)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_triangle_fill_mode)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_viewport)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_viewports)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_visibility_result_mode)`; `crates/metal2vulkan-rt/src/render_encoder.rs (shadow_copies)` +- `rt:Gap::Draw`: `crates/metal2vulkan-rt/src/render_encoder.rs (attachment_reads, 2 sites)`; `crates/metal2vulkan-rt/src/render_encoder.rs (draw)`; `crates/metal2vulkan-rt/src/render_encoder.rs (draw_patches)`; `crates/metal2vulkan-rt/src/render_encoder.rs (primitives)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_depth_bias)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_depth_clip_mode)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_scissor_rects)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_triangle_fill_mode)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_viewport)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_viewports)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_visibility_result_mode)`; `crates/metal2vulkan-rt/src/render_encoder.rs (shadow_copies)`