Give a tiled texture's shadow the word and unorm views of its first level
with_word_view and with_unorm_view required a one-level image, so the shadow of a tiled texture of more than one level (Buffer::new_tiled_texture) took neither: its merges copied the texels out instead of fetching them through the BGRA8/RGBA8 unorm view (every device), and on ANV its copies back stayed copies where a dispatch is measured faster. Both views are of level 0 alone, and its copies are one region of level 0, so a multi-level image takes them as a one-level one does. The condition is now one slice. sRGB and the other formats keep copying out, as every shadow's do (unorm_read), or take the word view where it is made. Verified by the device tests: see the tip's evidence. (cherry picked from commit 0d124cfc62ab10bb4be87ff5909f8602ff28db05)
This commit is contained in:
1 parent
beaa159d4f
commit
73e7638e4c
2 files changed
+18
-10
No files matched your search
@@ -4,8 +4,8 @@
|
||||
//! A texture over a buffer whose rows no image lays as Metal does renders through a shadow image,
|
||||
//! copied back into the buffer's rows after the commands that write it (`shadow.rs`). The copy is
|
||||
//! `vkCmdCopyImageToBuffer` on every device. On a device measured to run that copy slower than a
|
||||
//! dispatch that stores the same words, the shadow of a one-level, one-slice 2D texture whose
|
||||
//! texel is 4, 8 or 16 bytes, copied in place, is made `MUTABLE_FORMAT` with the unsigned-integer
|
||||
//! dispatch that stores the same words, the shadow of a one-slice 2D texture whose texel is 4, 8
|
||||
//! or 16 bytes, copied in place, is made `MUTABLE_FORMAT` with the unsigned-integer
|
||||
//! format of its texel's width listed (`R32_UINT`, `R32G32_UINT` or `R32G32B32A32_UINT`), and
|
||||
//! sampled usage ([`with_word_view`]), and its copies back are one dispatch of
|
||||
//! `bind::shadow_copy_back_module` each: invocation `(x, y)` fetches texel `(x0 + x, y0 + y)`
|
||||
@@ -44,8 +44,11 @@
|
||||
//! host (`tracker::Barrier::to_host`, `ALL_COMMANDS`/`MEMORY_WRITE` to `HOST`/`HOST_READ`, or
|
||||
//! `Barrier::to_all`, which adds every later command of its `VkQueue`: `batch_order.rs`).
|
||||
//!
|
||||
//! **Levels.** A tiled texture's shadow holds every level, and its copies move its first alone
|
||||
//! (`Buffer::new_tiled_texture`): the view is of that level, as the copies' one region is.
|
||||
//!
|
||||
//! **Where the copy stays.** A device without the fact, a texel of another width, a texture of
|
||||
//! more levels or slices, bytes copied through a staging buffer, a region past the device's
|
||||
//! more slices, bytes copied through a staging buffer, a region past the device's
|
||||
//! storage buffer range or workgroup counts, a buffer whose `VkBuffer` went, or a set the device
|
||||
//! does not make: each copies back as before, the exact form every device takes.
|
||||
|
||||
@@ -107,14 +110,15 @@ pub(super) fn word_format(bytes: u32, stores: bool) -> Option<(Format, ShadowTex
|
||||
/// [`dispatches_in`]), storage usage where the device stores the integer format and the image has
|
||||
/// it already or its own format is not a single 32-bit channel (the module's storage usage;
|
||||
/// `EXTENDED_USAGE` where its own format takes either not); with that format, the view and
|
||||
/// whether it stores. `None`, `plan` unchanged, for a one-level, one-slice 2D color image's texel
|
||||
/// of another width, a compressed block, or a device that does not sample the integer format.
|
||||
/// whether it stores. `None`, `plan` unchanged, for an image of more than one slice, a texel of
|
||||
/// another width, a compressed block, or a device that does not sample the integer format. An
|
||||
/// image of more levels takes it, its view of the first level alone (the module's levels).
|
||||
pub(super) fn with_word_view(
|
||||
mut plan: ImagePlan,
|
||||
facts: &ImageFacts<'_>,
|
||||
stores_in: bool,
|
||||
) -> (ImagePlan, Option<(Format, ShadowTexelView, bool)>) {
|
||||
let single = plan.levels == 1 && plan.layers == 1 && plan.extent[2] == 1;
|
||||
let one_slice = plan.layers == 1 && plan.extent[2] == 1;
|
||||
let single_channel_word = matches!(
|
||||
plan.format,
|
||||
Format::R32_UINT | Format::R32_SINT | Format::R32_SFLOAT
|
||||
@@ -127,7 +131,9 @@ pub(super) fn with_word_view(
|
||||
.and_then(|block| word_format(block.size, storing));
|
||||
let sampled = FormatFeatureFlags2::SAMPLED_IMAGE;
|
||||
let Some((format, texel)) = word.filter(|&(format, _)| {
|
||||
single && compatible(plan.format, format, false) && facts.optimal(format).contains(sampled)
|
||||
one_slice
|
||||
&& compatible(plan.format, format, false)
|
||||
&& facts.optimal(format).contains(sampled)
|
||||
}) else {
|
||||
return (plan, None);
|
||||
};
|
||||
|
||||
@@ -1279,7 +1279,9 @@ fn unorm_read(format: Format) -> Option<ShadowMergeRead> {
|
||||
|
||||
/// `plan`, a shadow's image, made to take its [`UnormView`]: sampled usage, with the kernel's read
|
||||
/// ([`unorm_read`]). `None`, `plan` unchanged, for an image of another format, of more than one
|
||||
/// level or slice, or of a format the device does not sample. Sampled usage changes nothing of
|
||||
/// slice, or of a format the device does not sample. An image of more levels takes it, its view of
|
||||
/// the first level alone: a tiled texture's shadow, whose copies move that level alone
|
||||
/// (`Buffer::new_tiled_texture`). Sampled usage changes nothing of
|
||||
/// the texture MoltenVK makes for the image: MoltenVK 1.4.1 gives a texture
|
||||
/// `MTLTextureUsageShaderRead` for transfer-source usage, which every shadow has, as for sampled
|
||||
/// usage (`MVKPixelFormats::getMTLTextureUsage`), and the view, of the image's own format and
|
||||
@@ -1288,11 +1290,11 @@ pub(super) fn with_unorm_view(
|
||||
mut plan: ImagePlan,
|
||||
facts: &ImageFacts<'_>,
|
||||
) -> (ImagePlan, Option<ShadowMergeRead>) {
|
||||
let single = plan.levels == 1 && plan.layers == 1 && plan.extent[2] == 1;
|
||||
let one_slice = plan.layers == 1 && plan.extent[2] == 1;
|
||||
let sampled = facts
|
||||
.optimal(plan.format)
|
||||
.contains(FormatFeatureFlags2::SAMPLED_IMAGE);
|
||||
let read = unorm_read(plan.format).filter(|_| single && sampled);
|
||||
let read = unorm_read(plan.format).filter(|_| one_slice && sampled);
|
||||
if read.is_some() {
|
||||
plan.usage |= ImageUsageFlags::SAMPLED;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user