diff --git a/crates/metal2vulkan-runtime/src/degradation.rs b/crates/metal2vulkan-runtime/src/degradation.rs index 41b8b62de..cfc14aa4a 100644 --- a/crates/metal2vulkan-runtime/src/degradation.rs +++ b/crates/metal2vulkan-runtime/src/degradation.rs @@ -1264,11 +1264,13 @@ degradations! { reason names, can land changed; every other value lands as Metal's copy leaves it"; /// A texture bound by a slot as a storage image without `ShaderWrite` usage, or as a /// sampled one without `ShaderRead`, whose image lacks that usage because adding it - /// would cost the image its size or the driver's compression: the binding takes an image - /// of its own with both shader usages, a shadow of the texture's texels - /// (`texture/usage_shadow.rs`). Also a texture without `RenderTarget` usage that a render - /// pass renders as an attachment, through a scratch image that has it - /// (`attachment_stand_in.rs`). + /// would cost the image its size or the driver's compression, or, for an image in place + /// over host pages, because the device's check failed for what the usage lets reach them + /// (`texture/in_place_image.rs`): the binding takes an image of its own with both shader + /// usages, a shadow of the texture's texels (`texture/usage_shadow.rs`). Also a texture + /// without `RenderTarget` usage that a render pass renders as an attachment, through a + /// scratch image that has it (`attachment_stand_in.rs`), but one in place whose image took + /// the attachment usage where the device's check passed for renders over its pages. UndeclaredUsageShadow = "undeclared-usage-shadow", Performance, "its texels are copied into an image of its own before each command that binds it \ beyond its declared usage, and back after each write through it"; diff --git a/crates/metal2vulkan-runtime/src/texture/in_place_image.rs b/crates/metal2vulkan-runtime/src/texture/in_place_image.rs index a9e7ce8e1..9485d5314 100644 --- a/crates/metal2vulkan-runtime/src/texture/in_place_image.rs +++ b/crates/metal2vulkan-runtime/src/texture/in_place_image.rs @@ -23,27 +23,29 @@ //! texels never reach them, and the check's bytes after its image are such bytes. //! - **Its usage** is the texture's declared plan's: one a shader writes (`ShaderWrite` or //! `ShaderAtomic`) has storage usage, through which its kernels write its texels in place, as -//! the device's check of storage writes covers ([`Texture::store_in_place`]). One that does not -//! render also takes the usages its descriptor lacks, each where the device's check passed for -//! what it lets reach the pages: the storage usage where the check passed for a shader's writes -//! over the class and the texels' row ends (those that let the rows' padding change where it is -//! free) and the texel is one its kernel stores, the attachment usage where it passed for -//! renders, and the sampled usage wherever (a read touches the texels alone), the first set of -//! them, the most first, the device makes the image in place with: plain Metal writes a texture -//! beyond its `ShaderWrite` and renders into one made without `RenderTarget`, and such a write -//! or pass then reaches the texels in place. A write or pass beyond what the image takes binds -//! the texture's usage shadow (`texture/usage_shadow.rs`), or renders through an attachment -//! stand-in (`attachment_stand_in.rs`), whose copies into it touch its texels alone. The usages -//! change neither the image's pitch nor its place: an image that would lie otherwise is not -//! made, and the next plan is tried. One that renders also takes the feedback loop usage a draw takes that reads the texture its own pass -//! renders through a snapshot (`texture::feedback_candidate`, `render/snapshot.rs`) where the -//! device makes the image with it, as an aliasing image over a buffer of the runtime's does, -//! and with it the storage usage the snapshot's fetch of the attachment in the pixel interlock -//! reads through (`framebuffer_fetch::storage_candidate`, which may list a view in another -//! format), where the device's check passed for a shader's writes over the pages' class too and -//! the texel is one its kernel stores (with that usage a shader writes the texels in place, as -//! one declared to does): the first of those plans the device makes the image in place with, -//! else the declared plan's image. +//! the device's check of storage writes covers ([`Texture::store_in_place`]). +//! - **The usages its descriptor lacks**, for one that does not render: each where the device's +//! check passed for what it lets reach the pages. The storage usage where it passed for a +//! shader's writes over the class and the texels' row ends (those that let the rows' padding +//! change, where it is free) and the texel is one the check's kernel stores; the attachment +//! usage where it passed for renders over them; the sampled usage wherever, as a read touches +//! the texels alone. The image takes the first set of them, the most first, the device makes it +//! in place with. Plain Metal writes a texture beyond its `ShaderWrite` and renders into one made +//! without `RenderTarget`; with the usage, such a write or pass reaches the texels in place. A +//! write or pass beyond what the image takes binds the texture's usage shadow +//! (`texture/usage_shadow.rs`), or renders through an attachment stand-in +//! (`attachment_stand_in.rs`), whose copies into it touch its texels alone. The usages change +//! neither the image's pitch nor its memory: an image that would lie otherwise is not made, and +//! the next set is tried. +//! - **One that renders** also takes the feedback loop usage a draw takes that reads the texture +//! its own pass renders through a snapshot (`texture::feedback_candidate`, `render/snapshot.rs`) +//! where the device makes the image with it, as an aliasing image over a buffer of the +//! runtime's does, and with it the storage usage the snapshot's fetch of the attachment in the +//! pixel interlock reads through (`framebuffer_fetch::storage_candidate`, which may list a view +//! in another format), where the device's check passed for a shader's writes over the pages' +//! class too, those that keep the rows' padding, and the texel is one its kernel stores (with +//! that usage a shader writes the texels in place, as one declared to does): the first of those +//! plans the device makes the image in place with, else the declared plan's image. //! - **A rebind** (`rebind.rs`) makes it again over the new pages, its texels as far from their //! first byte as from the old pages', as a no-copy heap's images are //! ([`Device::rebound_in_place_images`]); a detach makes it present a stand-in, as it does every @@ -484,9 +486,9 @@ impl Device { return false; } let line = self.shared().in_place.line(); - let written = match texels.padding(line) { - Padding::Free => Access::BufferWrites, - Padding::Kept => Access::Writes, + let written = match (texels.padding(line), renders) { + (Padding::Free, false) => Access::BufferWrites, + _ => Access::Writes, }; let rows = texels.rows(line); self.shared().in_place.verdict(class, written, rows) == Verdict::Passed @@ -1069,8 +1071,8 @@ impl Device { /// that lie in lines as `rows` says: an image of attachment usage renders, one of storage /// usage is written, one of neither reads. The writes of one that does not render whose /// rows' padding is free take the check that lets it change (`in_place::in_place`); one that - /// renders may hold the storage usage a render target takes where the check that keeps it - /// passed (`Device::storage_over_buffer`'s `storable`), which it asks. + /// renders may hold the storage usage where the check that keeps it passed (the route's + /// `storable`, `texture/route.rs`), which it asks. fn fresh_pages_take(&self, image: &Image, (rows, padding): (RowEnds, Padding)) -> bool { use metal2vulkan::vk::ImageUsageFlags; let usage = image.plan().usage; diff --git a/crates/metal2vulkan-validation/src/runtime_lane/in_place_textures.rs b/crates/metal2vulkan-validation/src/runtime_lane/in_place_textures.rs index 5f12e00dc..28ad84ef3 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/in_place_textures.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/in_place_textures.rs @@ -39,10 +39,12 @@ //! `RenderTarget`): where the device's check passed for a shader's writes (`Pointer buffer //! writes` where the rows' padding is free) or for renders over the class, the write or pass //! reaches the image in place, which took the usage it lacks: no shadow announced -//! (`undeclared-usage-shadow`), no texel copied in (`shadow_texels_copied_in`); elsewhere through -//! its shadow (or stand-in), announced. The image stays the texture's (`vk_image` the same -//! handle); every texel of the pages then holds the value, and the bytes between the rows hold -//! the pattern but where a shader's writes in place may change rows' padding that is free. +//! (`undeclared-usage-shadow`), no texel copied in (`shadow_texels_copied_in`, +//! `shadow_texels_copied_in_images`); elsewhere through its shadow (or stand-in), announced. +//! The image stays the texture's (`vk_image` the same handle), and its texels stay in the pages +//! at the buffer's pitch: every texel of the pages then holds the value, and the bytes between +//! the rows hold the pattern but where a shader's writes in place may change rows' padding that +//! is free. Printed (`IN-PLACE-USAGE`): each form's path and the texels copied in. //! - [`textures_that_render_or_write_take_the_path_their_checks_answered`], under the validation //! layer: a 64x64 `R32Uint` texture over a no-copy buffer of anonymous pages, of each usage that //! renders or writes, once the device's check answered: each is in place where the check passed @@ -882,7 +884,10 @@ fn writes_and_passes_beyond_the_usage_reach_the_pages_where_their_checks_passed( let notices = counts(&messages.take_notices()); let shadowed = notices.contains_key(&Degradation::UndeclaredUsageShadow); let after = device.work_counts(); - let copied = after.shadow_texels_copied_in - before.shadow_texels_copied_in; + // A shadow's copies in from a buffer's texels, and from an image's (the usage shadow + // copies the image in place, image to image). + let copied = (after.shadow_texels_copied_in - before.shadow_texels_copied_in) + + (after.shadow_texels_copied_in_images - before.shadow_texels_copied_in_images); // In place, the write or pass reaches the texels with no shadow and no copy; else it // takes the shadow (or stand-in), announced. assert_eq!(shadowed, !reaches, "{form}: {notices:?}"); diff --git a/docs/API.md b/docs/API.md index 6d822a213..5cdaffb94 100644 --- a/docs/API.md +++ b/docs/API.md @@ -2434,8 +2434,11 @@ bound. - `metal2vulkan-degrade-undeclared-usage-shadow` (performance). `UndeclaredUsageShadow`: A texture bound by a slot as a storage image without `ShaderWrite` usage, or as a sampled one without `ShaderRead`, whose image lacks that usage because adding it would cost the image its size or the - driver's compression: the binding takes an image of its own with both shader usages, a shadow of - the texture's texels. Cost: its texels are copied into an image of its own before each command + driver's compression, or, for a texture in place over host pages, because the device's in-place + check failed for what the usage lets reach them: the binding takes an image of its own with both + shader usages, a shadow of the texture's texels. Also a texture without `RenderTarget` usage that + a render pass renders into, through a scratch image that has it, except a texture in place whose + image took that usage where the check passed for renders over its pages. Cost: its texels are copied into an image of its own before each command that binds it beyond its declared usage, and back after each write through it. - `metal2vulkan-degrade-heap-two-plane-texture` (precision). `HeapTwoPlaneTexture`: A texture of `RGB10A8_2P_XR10` or its sRGB twin made in a heap whose planes no shadow of the heap's bytes