diff --git a/crates/metal2vulkan-runtime/src/degradation.rs b/crates/metal2vulkan-runtime/src/degradation.rs index 38ea267d0..7f0d132c2 100644 --- a/crates/metal2vulkan-runtime/src/degradation.rs +++ b/crates/metal2vulkan-runtime/src/degradation.rs @@ -1868,15 +1868,15 @@ degradations! { /// A CPU copy into a texture with a decoded twin (`replace_region`) whose CPU copies go /// on the host or the staging queue: its region is decoded on the CPU, on the device's /// decode thread, and copied into the twin; the first command buffer that may read the - /// texture waits at its submission for that, and the call itself where a command buffer - /// that may read it is submitted and not yet complete (which then reads the copied - /// texels, as Metal's does) or the texture is untracked (`texture/twin_decode.rs`). + /// texture waits at its submission for that (every command buffer, where the texture is + /// untracked). The call itself waits for no GPU work, as Metal's does not: only for room, + /// while 256 MiB of written blocks wait for the thread (`texture/twin_decode.rs`). CpuBlockDecode = "cpu-block-decode", Performance, "the written blocks decoded on the CPU, on the device's decode thread split over up \ to 8 threads, and their texels copied into the decoded twin on the host or the \ staging queue: the first command buffer that may read the texture waits at its \ - submission for that, and the call waits for it where a command buffer that may read \ - the texture is submitted and not yet complete, or the texture is untracked"; + submission for that (every command buffer, where the texture is untracked), and the \ + call waits only for room, while 256 MiB of written blocks wait for the thread"; /// A texture of an ASTC LDR format (`ASTC_4x4_LDR` to `ASTC_12x12_LDR`, the sRGB forms /// too) made on a device without that ASTC format (`textureCompressionASTC_LDR`), of an /// ASTC HDR format (`ASTC_4x4_HDR` to `ASTC_12x12_HDR`) on a device without its `SFLOAT` diff --git a/crates/metal2vulkan-runtime/src/tests/degradation.rs b/crates/metal2vulkan-runtime/src/tests/degradation.rs index 0218cc0c4..7444ba177 100644 --- a/crates/metal2vulkan-runtime/src/tests/degradation.rs +++ b/crates/metal2vulkan-runtime/src/tests/degradation.rs @@ -21,6 +21,16 @@ fn each_kind_is_announced_once() { assert!(other.now(Degradation::CopiedDrawBytes)); } +/// `CpuBlockDecode`'s cost says what `replace_region` waits for: no GPU work, only room under the +/// decode queue's bound (`texture/twin_decode.rs`), which it states as the queue holds it. +#[test] +fn the_cpu_block_decode_cost_states_the_calls_only_wait() { + let cost = Degradation::CpuBlockDecode.cost(); + let bound = crate::texture::twin_decode::QUEUED_BYTES >> 20; + let wait = format!("the call waits only for room, while {bound} MiB of written blocks wait"); + assert!(cost.contains(&wait), "{cost}"); +} + /// A kind the device's options ask for at each occurrence is announced at every one; every other /// kind once, as without them. #[test] diff --git a/crates/metal2vulkan-runtime/src/texture.rs b/crates/metal2vulkan-runtime/src/texture.rs index 3b1208b49..d30837cdf 100644 --- a/crates/metal2vulkan-runtime/src/texture.rs +++ b/crates/metal2vulkan-runtime/src/texture.rs @@ -180,7 +180,7 @@ pub(super) mod stand_in; pub(super) mod storage_form; pub(super) mod surface_depth; pub(super) mod surface_two_planes; -mod twin_decode; +pub(crate) mod twin_decode; mod usage_shadow; mod view_shadow; pub(super) mod wrapped; diff --git a/crates/metal2vulkan-runtime/src/texture/twin_decode.rs b/crates/metal2vulkan-runtime/src/texture/twin_decode.rs index 53f0f6e34..e625d2d86 100644 --- a/crates/metal2vulkan-runtime/src/texture/twin_decode.rs +++ b/crates/metal2vulkan-runtime/src/texture/twin_decode.rs @@ -51,7 +51,7 @@ const ROWS_PER_THREAD: usize = 16; pub(super) const ROWS_PER_PART: u32 = 64; /// The most bytes of written blocks the jobs queued hold. -pub(super) const QUEUED_BYTES: u64 = 256 << 20; +pub(crate) const QUEUED_BYTES: u64 = 256 << 20; /// How long the thread sleeps at most without looking for a job or a stop. const WAIT_SLICE: Duration = Duration::from_millis(100); diff --git a/docs/API.md b/docs/API.md index 07de18b6d..9761a0e56 100644 --- a/docs/API.md +++ b/docs/API.md @@ -2981,13 +2981,14 @@ bound. - `metal2vulkan-degrade-cpu-block-decode` (performance). `CpuBlockDecode`: A CPU copy into a texture with a decoded twin (`replace_region`) whose CPU copies go on the host or the staging queue: its region is decoded on the CPU, on the device's decode thread, and copied into the twin; the first - command buffer that may read the texture waits at its submission for that, and the call itself - where a command buffer that may read it is submitted and not yet complete (which then reads the - copied texels, as Metal's does) or the texture is untracked. Cost: the written blocks decoded on - the CPU, on the device's decode thread split over up to 8 threads, and their texels copied into - the decoded twin on the host or the staging queue: the first command buffer that may read the - texture waits at its submission for that, and the call waits for it where a command buffer that - may read the texture is submitted and not yet complete, or the texture is untracked. + command buffer that may read the texture waits at its submission for that (every command buffer, + where the texture is untracked). The call itself waits for no GPU work, as Metal's does not: only + for room, while 256 MiB of written blocks wait for the thread. Cost: the written blocks decoded + on the CPU, on the device's decode thread split over up to 8 threads, and their texels copied + into the decoded twin on the host or the staging queue: the first command buffer that may read + the texture waits at its submission for that (every command buffer, where the texture is + untracked), and the call waits only for room, while 256 MiB of written blocks wait for the + thread. - `metal2vulkan-degrade-carried-decoded-twin` (performance). `CarriedDecodedTwin`: A texture of an ASTC LDR format (`ASTC_4x4_LDR` to `ASTC_12x12_LDR`, the sRGB forms too) made on a device without that ASTC format, of an ASTC HDR format (`ASTC_4x4_HDR` to `ASTC_12x12_HDR`) on a device without its