A texture that renders over padded rows in ordered memory is in place where the device's check of renders passed
linear_plan::holding refused every texture that renders over rows with bytes between them, ordered memory too (a Private buffer, a Managed one's own copy on a discrete GPU), since Vulkan lets a render pass's load and store read and write back any byte of the attachment's subresource. So each such render target was a shadow (BytesBetweenRows): 32 Managed textures at rows of 152 in 256 on reims's XTX walk. Now holding takes renders_kept: Device::ordered_renders_kept answers it where the device's policy takes images in place and its check of renders over its pooled memory (PagesClass::Pooled, Access::Renders, the texels' row ends) passed. That check renders into a linear image over padded rows, through its moves into the layouts a render takes, a pass that clears and stores it and a draw over its last column, while the CPU writes the bytes beside its texels, and passes only where every byte but a texel keeps what was last written: the owner's per-driver check, the same that takes images in place over host pages and pooled memory. In ordered memory no other agent writes those bytes meanwhile. The texture is then the device's linear image made PREINITIALIZED (Between::Kept), as one that only reads; a pending verdict starts the check, and a texture made meanwhile is a shadow. The pooled move path asks the same. Docs: the shadowed-texture notice (API.md), HOWTO, the degradation's declaration and linear_texture_bytes_per_row's doc say so. Verified: cargo fmt; unit test linear_plan::ordered_writes_let_a_ texture_that_renders_nothing_hold_its_rows_padding covers renders_kept (kept in ordered memory, refused outside it and over shared rows); device runs of tests::ordered_renders follow.
This commit is contained in:
1 parent
13e4f9ab24
commit
ed8b9a137b
8 files changed
+104
-34
No files matched your search
@@ -261,7 +261,8 @@ degradations! {
|
||||
/// Vulkan lets the image's layout transitions read and write any byte of its subresources,
|
||||
/// and a render pass's load and store operations read and write back any byte of an
|
||||
/// attachment's image subresource, and Metal leaves them as the program writes them (but
|
||||
/// for a texture that renders nothing over a buffer only the device's ordered commands
|
||||
/// for a texture that renders nothing, or renders on a device whose check of renders over
|
||||
/// its pooled memory passed, over a buffer only the device's ordered commands
|
||||
/// write, a `Private` one or a `Managed` one's own on a device without unified memory,
|
||||
/// whose linear image, made `PREINITIALIZED`, keeps them through its one layout
|
||||
/// transition, or whose `DRM_FORMAT_MOD_LINEAR` image at the buffer's pitch keeps them by
|
||||
|
||||
@@ -1296,7 +1296,8 @@ pub(crate) enum Between {
|
||||
/// operations change them.
|
||||
Unobserved,
|
||||
/// The bytes between their rows and slices, which only the device's ordered commands write, of
|
||||
/// a texture that renders nothing: the device's linear image made `PREINITIALIZED` holds
|
||||
/// a texture that renders nothing, or whose renders the device's check found keeping them
|
||||
/// ([`holding`]'s `renders_kept`): the device's linear image made `PREINITIALIZED` holds
|
||||
/// them, its one transition keeping them, or a `DRM_FORMAT_MOD_LINEAR` image of the runtime's
|
||||
/// own memory, made `UNDEFINED`, whose first move keeps them by copies around its transition
|
||||
/// (`texture/first_move.rs`'s `GpuKeep`).
|
||||
@@ -1347,8 +1348,9 @@ impl Between {
|
||||
/// reads those bytes: `BufferDescriptor::padding_unobserved`), any such image, whose operations
|
||||
/// may then change them ([`Between::Unobserved`]);
|
||||
/// - where `ordered` (only the device's commands, in the order the runtime records them, write the
|
||||
/// bytes the GPU uses: `Buffer::gpu_bytes_ordered`) and the texture renders nothing, the device's
|
||||
/// linear image made `PREINITIALIZED` alone ([`Between::Kept`]). Its one transition, its first
|
||||
/// bytes the GPU uses: `Buffer::gpu_bytes_ordered`) and the texture renders nothing (or
|
||||
/// `renders_kept`, below), the device's linear image made `PREINITIALIZED` alone
|
||||
/// ([`Between::Kept`]). Its one transition, its first
|
||||
/// move to `GENERAL`, is from the layout it is in, and of such a one the same section says "If
|
||||
/// the old layout matches the current layout of the image subresource range, the transition
|
||||
/// preserves the contents of that range" (Vulkan 7.1.1), ordered after every write of those
|
||||
@@ -1356,7 +1358,13 @@ impl Between {
|
||||
/// both host-accessible subresources, which "interpret the contents of the memory in
|
||||
/// consistent ways, and data written to one alias can be read by the other alias" (12.11, Memory
|
||||
/// Aliasing). A shader's writes of the texture may change its rows' padding, as on the x86 Macs
|
||||
/// (`in_place::Padding::Free`); no render pass writes them back. An image made `UNDEFINED` for
|
||||
/// (`in_place::Padding::Free`). A texture that renders is held so too where `renders_kept`: the
|
||||
/// device's policy takes images in place and its check of renders over its pooled memory
|
||||
/// passed for texels that lie in its lines as these do (`Device::ordered_renders_kept`), the
|
||||
/// check that a render pass's load and store and the image's moves leave every byte beside the
|
||||
/// texels as it was, the rows' padding among them, while the CPU writes them
|
||||
/// (`in_place_check.rs`), a render pass taking the device's one store path for linear images
|
||||
/// whatever memory they lie in. An image made `UNDEFINED` for
|
||||
/// external memory takes none of them: its first move may discard them. A
|
||||
/// `DRM_FORMAT_MOD_LINEAR` one of the runtime's own memory, made `UNDEFINED` too
|
||||
/// (`PREINITIALIZED` is for linear tiling alone), takes them where its first move copies what it
|
||||
@@ -1367,7 +1375,7 @@ pub(super) fn holding(
|
||||
layout: &BufferLayout,
|
||||
usage: TextureUsage,
|
||||
padding_unobserved: bool,
|
||||
ordered: bool,
|
||||
(ordered, renders_kept): (bool, bool),
|
||||
) -> Result<Between, String> {
|
||||
// An IOSurface plane's rows that overlap: no image holds them, whatever its usage.
|
||||
let shared = layout.shared_bytes();
|
||||
@@ -1396,10 +1404,14 @@ pub(super) fn holding(
|
||||
return Ok(Between::Nothing);
|
||||
};
|
||||
let renders = usage.contains(TextureUsage::RENDER_TARGET);
|
||||
if ordered && !renders {
|
||||
if ordered && (!renders || renders_kept) {
|
||||
return Ok(Between::Kept);
|
||||
}
|
||||
let writers = if renders {
|
||||
let writers = if renders && ordered {
|
||||
"its layout transitions read and write, and a render pass's load and store operations \
|
||||
write back, and the device's check of renders over its pooled memory has not passed for \
|
||||
texels that lie as these do"
|
||||
} else if renders {
|
||||
"its layout transitions read and write, and a render pass's load and store operations \
|
||||
write back"
|
||||
} else {
|
||||
|
||||
@@ -869,9 +869,12 @@ fn a_linear_image_aliases_only_metals_layout() {
|
||||
TextureUsage::RENDER_TARGET | TextureUsage::SHADER_READ,
|
||||
TextureUsage::SHADER_READ,
|
||||
] {
|
||||
assert!(holding(&padded, usage, false, false).is_err(), "{usage:?}");
|
||||
assert!(
|
||||
holding(&padded, usage, false, (false, false)).is_err(),
|
||||
"{usage:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
holding(&single, usage, false, false),
|
||||
holding(&single, usage, false, (false, false)),
|
||||
Ok(Between::Nothing),
|
||||
"{usage:?}"
|
||||
);
|
||||
@@ -883,7 +886,7 @@ fn a_linear_image_aliases_only_metals_layout() {
|
||||
..padded
|
||||
};
|
||||
assert_eq!(
|
||||
holding(&row, TextureUsage::SHADER_READ, false, false),
|
||||
holding(&row, TextureUsage::SHADER_READ, false, (false, false)),
|
||||
Ok(Between::Nothing)
|
||||
);
|
||||
assert!(!aliases(
|
||||
@@ -934,7 +937,10 @@ fn a_linear_image_aliases_only_metals_layout() {
|
||||
TextureUsage::RENDER_TARGET | TextureUsage::SHADER_READ,
|
||||
TextureUsage::SHADER_READ,
|
||||
] {
|
||||
assert!(holding(&apart, usage, false, false).is_err(), "{usage:?}");
|
||||
assert!(
|
||||
holding(&apart, usage, false, (false, false)).is_err(),
|
||||
"{usage:?}"
|
||||
);
|
||||
}
|
||||
assert!(!aliases(
|
||||
&apart,
|
||||
@@ -999,7 +1005,7 @@ fn unobserved_padding_lets_an_image_hold_the_bytes_between_rows_alone() {
|
||||
TextureUsage::SHADER_WRITE,
|
||||
] {
|
||||
assert_eq!(
|
||||
holding(&padded, usage, true, false),
|
||||
holding(&padded, usage, true, (false, false)),
|
||||
Ok(Between::Unobserved),
|
||||
"{usage:?}"
|
||||
);
|
||||
@@ -1033,7 +1039,7 @@ fn unobserved_padding_lets_an_image_hold_the_bytes_between_rows_alone() {
|
||||
..padded
|
||||
};
|
||||
assert_eq!(
|
||||
holding(&apart, TextureUsage::SHADER_READ, true, false),
|
||||
holding(&apart, TextureUsage::SHADER_READ, true, (false, false)),
|
||||
Ok(Between::Unobserved)
|
||||
);
|
||||
let stacked = LinearImage {
|
||||
@@ -1052,7 +1058,7 @@ fn unobserved_padding_lets_an_image_hold_the_bytes_between_rows_alone() {
|
||||
row_bytes: 96,
|
||||
..padded
|
||||
};
|
||||
assert!(holding(&shared, TextureUsage::SHADER_READ, true, false).is_err());
|
||||
assert!(holding(&shared, TextureUsage::SHADER_READ, true, (false, false)).is_err());
|
||||
assert!(!aliases(&shared, 4096, 320, &image, true));
|
||||
}
|
||||
|
||||
@@ -1060,8 +1066,10 @@ fn unobserved_padding_lets_an_image_hold_the_bytes_between_rows_alone() {
|
||||
/// the device's linear image made `PREINITIALIZED` may hold the bytes between a texture's rows and
|
||||
/// slices where the texture renders nothing (`Between::Kept`), as within declared padding
|
||||
/// (`linear_plan::within_padding`); a render target's stay refused, as a render pass's load and
|
||||
/// store write them back, and so do rows that share bytes. A declaration of the padding unobserved
|
||||
/// takes precedence, and texels with nothing between their rows hold nothing more.
|
||||
/// store write them back, but where the device's check of renders over its pooled memory found
|
||||
/// them kept (`Device::ordered_renders_kept`), and so do rows that share bytes. A declaration of
|
||||
/// the padding unobserved takes precedence, and texels with nothing between their rows hold
|
||||
/// nothing more.
|
||||
#[test]
|
||||
fn ordered_writes_let_a_texture_that_renders_nothing_hold_its_rows_padding() {
|
||||
let padded = BufferLayout {
|
||||
@@ -1079,12 +1087,12 @@ fn ordered_writes_let_a_texture_that_renders_nothing_hold_its_rows_padding() {
|
||||
TextureUsage::SHADER_READ | TextureUsage::PIXEL_FORMAT_VIEW,
|
||||
] {
|
||||
assert_eq!(
|
||||
holding(&padded, usage, false, true),
|
||||
holding(&padded, usage, false, (true, false)),
|
||||
Ok(Between::Kept),
|
||||
"{usage:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
holding(&padded, usage, true, true),
|
||||
holding(&padded, usage, true, (true, false)),
|
||||
Ok(Between::Unobserved),
|
||||
"{usage:?}"
|
||||
);
|
||||
@@ -1094,7 +1102,21 @@ fn ordered_writes_let_a_texture_that_renders_nothing_hold_its_rows_padding() {
|
||||
TextureUsage::RENDER_TARGET | TextureUsage::SHADER_READ,
|
||||
effective_usage(TextureUsage::UNKNOWN),
|
||||
] {
|
||||
assert!(holding(&padded, usage, false, true).is_err(), "{usage:?}");
|
||||
assert!(
|
||||
holding(&padded, usage, false, (true, false)).is_err(),
|
||||
"{usage:?}"
|
||||
);
|
||||
// Where the device's check of renders over its pooled memory passed, its renders keep
|
||||
// them; never outside ordered memory, and never over rows that share bytes.
|
||||
assert_eq!(
|
||||
holding(&padded, usage, false, (true, true)),
|
||||
Ok(Between::Kept),
|
||||
"{usage:?}"
|
||||
);
|
||||
assert!(
|
||||
holding(&padded, usage, false, (false, true)).is_err(),
|
||||
"{usage:?}"
|
||||
);
|
||||
}
|
||||
let apart = BufferLayout {
|
||||
slices: 3,
|
||||
@@ -1102,7 +1124,7 @@ fn ordered_writes_let_a_texture_that_renders_nothing_hold_its_rows_padding() {
|
||||
..padded
|
||||
};
|
||||
assert_eq!(
|
||||
holding(&apart, TextureUsage::SHADER_READ, false, true),
|
||||
holding(&apart, TextureUsage::SHADER_READ, false, (true, false)),
|
||||
Ok(Between::Kept)
|
||||
);
|
||||
let packed = BufferLayout {
|
||||
@@ -1110,14 +1132,16 @@ fn ordered_writes_let_a_texture_that_renders_nothing_hold_its_rows_padding() {
|
||||
..padded
|
||||
};
|
||||
assert_eq!(
|
||||
holding(&packed, TextureUsage::SHADER_READ, false, true),
|
||||
holding(&packed, TextureUsage::SHADER_READ, false, (true, false)),
|
||||
Ok(Between::Nothing)
|
||||
);
|
||||
let shared = BufferLayout {
|
||||
row_bytes: 96,
|
||||
..padded
|
||||
};
|
||||
assert!(holding(&shared, TextureUsage::SHADER_READ, false, true).is_err());
|
||||
assert!(holding(&shared, TextureUsage::SHADER_READ, false, (true, false)).is_err());
|
||||
let renders = TextureUsage::RENDER_TARGET | TextureUsage::SHADER_READ;
|
||||
assert!(holding(&shared, renders, false, (true, true)).is_err());
|
||||
// The image holds the bytes between rows to the last row's pitch, as within declared padding.
|
||||
let image = LinearImage {
|
||||
alignment: 16,
|
||||
@@ -1167,7 +1191,7 @@ fn a_padded_texture_s_shadow_names_what_may_write_its_padding() {
|
||||
TextureUsage::BLOCK_WRITES_ONLY,
|
||||
] {
|
||||
assert_eq!(
|
||||
holding(&padded, usage, false, false),
|
||||
holding(&padded, usage, false, (false, false)),
|
||||
Err(transitions.to_owned()),
|
||||
"{usage:?}"
|
||||
);
|
||||
@@ -1178,7 +1202,7 @@ fn a_padded_texture_s_shadow_names_what_may_write_its_padding() {
|
||||
effective_usage(TextureUsage::UNKNOWN),
|
||||
] {
|
||||
assert_eq!(
|
||||
holding(&padded, usage, false, false),
|
||||
holding(&padded, usage, false, (false, false)),
|
||||
Err(passes.to_owned()),
|
||||
"{usage:?}"
|
||||
);
|
||||
|
||||
@@ -3689,7 +3689,9 @@ impl Device {
|
||||
};
|
||||
let unobserved = texels.buffer.padding_unobserved();
|
||||
let ordered = texels.buffer.gpu_bytes_ordered();
|
||||
let holds = crate::linear_plan::holding(&texels.layout, pending.usage, unobserved, ordered);
|
||||
let kept = self.ordered_renders_kept(texels, pending.usage);
|
||||
let holds =
|
||||
crate::linear_plan::holding(&texels.layout, pending.usage, unobserved, (ordered, kept));
|
||||
let over = (texels, &holds, pending.usage);
|
||||
let made = self.alias_over_device(&pending.plan, (descriptor, &layout), over, facts)?;
|
||||
Ok(made.ok())
|
||||
|
||||
@@ -259,7 +259,8 @@ impl Device {
|
||||
/// meet exactly. The texture's offset must meet the image's memory alignment too
|
||||
/// (`BufferDescriptor::with_aligned_byte`), and rows with bytes between them hold those bytes
|
||||
/// in the image only over a buffer that declares them unobserved
|
||||
/// (`BufferDescriptor::with_padding_unobserved`) or, for a texture that renders nothing, one
|
||||
/// (`BufferDescriptor::with_padding_unobserved`) or, for a texture that renders nothing (or
|
||||
/// renders, where the device's check of renders over its pooled memory passed), one
|
||||
/// that only the device's commands write (a `Private` buffer, a `Managed` one on a device
|
||||
/// without unified memory): docs/API.md, `shadowed-texture`. `None` for a texture of more than
|
||||
/// one level, sample or slice, or of another type than 2D, and where the device makes no
|
||||
|
||||
@@ -34,7 +34,8 @@ pub(crate) enum Route {
|
||||
/// (an image over the texels may hold them, and what besides, `linear_plan::holding`: their
|
||||
/// rows lie one after another, the buffer declares the bytes between them unobserved,
|
||||
/// `BufferDescriptor::padding_unobserved`, or only the device's ordered commands write those
|
||||
/// bytes, of a texture that renders nothing) and the device makes one on Metal's layout, else
|
||||
/// bytes, of a texture that renders nothing or whose renders the device's check found keeping
|
||||
/// them, `Device::ordered_renders_kept`) and the device makes one on Metal's layout, else
|
||||
/// the shadow; `holds` says why not where it does not.
|
||||
Device { holds: Result<Between, String> },
|
||||
/// Over host pages of `class`, its texels lying in the device's lines as `rows` says, and
|
||||
@@ -136,6 +137,30 @@ impl Device {
|
||||
Ok(route.placement())
|
||||
}
|
||||
|
||||
/// Whether a texture of Metal `usage` that renders over `texels`, whose bytes only the
|
||||
/// device's ordered commands write (`Buffer::gpu_bytes_ordered`), keeps the bytes between its
|
||||
/// rows and slices in an image over them (`linear_plan::holding`'s `renders_kept`): where the
|
||||
/// device's policy takes images in place and its check of renders over its pooled memory
|
||||
/// ([`PagesClass::Pooled`], [`Access::Renders`]) passed for texels that lie in its lines as
|
||||
/// these do. That check renders into a linear image over a buffer's rows with bytes between
|
||||
/// them, through its moves into the layouts a render takes and a pass that clears and stores
|
||||
/// it and one that draws over its last column, while the CPU writes the bytes beside its
|
||||
/// texels, and passes where every byte but a texel reads what was last written there
|
||||
/// (`in_place_check.rs`). Vulkan lets a load and a store "read and write back any memory
|
||||
/// locations within the image subresource" (the Render Pass chapter); in ordered memory no
|
||||
/// other agent writes those bytes meanwhile, and the check found the device writing back
|
||||
/// nothing older there. A pending verdict starts the check, and a texture made meanwhile is a
|
||||
/// shadow.
|
||||
pub(super) fn ordered_renders_kept(&self, texels: &Texels, usage: TextureUsage) -> bool {
|
||||
if !usage.contains(TextureUsage::RENDER_TARGET) || !texels.buffer.gpu_bytes_ordered() {
|
||||
return false;
|
||||
}
|
||||
let policy = self.compile_device().policy().host_page_textures;
|
||||
let rows = texels.rows(self.shared().in_place.line());
|
||||
policy == HostPageTexturePolicy::InPlace
|
||||
&& self.in_place_verdict(PagesClass::Pooled, Access::Renders, rows) == Verdict::Passed
|
||||
}
|
||||
|
||||
/// The route of a texture of Metal `usage` (as the image is planned for it) and `levels` over
|
||||
/// `texels`, `past` where they run past the buffer's length (the module docs): the shadow for
|
||||
/// a tiled texture of more than one level, whatever holds the bytes. Over host pages (a no-copy
|
||||
@@ -186,10 +211,11 @@ impl Device {
|
||||
// Whether an image may hold the texels: none where their rows (or slices) lie
|
||||
// with the buffer's bytes between them, unless the buffer declares those bytes
|
||||
// unobserved, or only the device's ordered commands write them and the texture
|
||||
// renders nothing (`linear_plan::holding`), and else why.
|
||||
// renders nothing or its renders keep them (`linear_plan::holding`), and else why.
|
||||
let unobserved = texels.buffer.padding_unobserved();
|
||||
let ordered = texels.buffer.gpu_bytes_ordered();
|
||||
let holds = holding(&texels.layout, usage, unobserved, ordered);
|
||||
let kept = self.ordered_renders_kept(texels, usage);
|
||||
let holds = holding(&texels.layout, usage, unobserved, (ordered, kept));
|
||||
return Route::Device { holds };
|
||||
}
|
||||
};
|
||||
|
||||
+6
-3
@@ -1896,9 +1896,12 @@ bound.
|
||||
and no other byte does), or only the device's commands, in the runtime's order, write the
|
||||
buffer's bytes (a `Private` buffer, and a `Managed` buffer's own on a device without unified
|
||||
memory, whose host copy the program's `didModifyRange:` copies in; not one whose `VkBuffer` was
|
||||
handed out or whose memory is exportable) and the texture renders nothing: then the device's
|
||||
linear image, made `PREINITIALIZED`, holds them where its rows lie at the buffer's pitch
|
||||
(`WorkCounts::kept_padding_aliases`). Its one layout transition is out of the layout it is in,
|
||||
handed out or whose memory is exportable) and the texture renders nothing, or renders on a
|
||||
device whose policy takes images in place and whose check of renders over its pooled memory
|
||||
passed for texels that lie in its lines as these do (that a render pass's load and store, and
|
||||
the image's moves, left every byte beside the texels, the rows' padding among them): then the
|
||||
device's linear image, made `PREINITIALIZED`, holds them where its rows lie at the buffer's
|
||||
pitch (`WorkCounts::kept_padding_aliases`). Its one layout transition is out of the layout it is in,
|
||||
of which Vulkan says "If the old layout matches the current layout of the image subresource
|
||||
range, the transition preserves the contents of that range" (7.1.1, Image Layout Transitions),
|
||||
ordered with every write of those bytes; in `GENERAL` the buffer and the image are both
|
||||
|
||||
+2
-1
@@ -400,7 +400,8 @@ and the bytes between slices may change whenever the texture is made or used, an
|
||||
does (`WorkCounts::unobserved_padding_aliases` counts such images; `Buffer::texture_placement`
|
||||
answers `NotHostPages` for such a texture, else the shadow's cause, and
|
||||
`Shadow(TextureShadowReason::BytesBetweenRows)` without the declaration). Without it, a texture
|
||||
that renders nothing over a buffer whose bytes only the device's ordered commands write (a
|
||||
that renders nothing (or renders, on a device whose check of renders over its pooled memory
|
||||
passed) over a buffer whose bytes only the device's ordered commands write (a
|
||||
`Private` buffer, a `Managed` one's own on a device without unified memory) is the device's linear
|
||||
image at the pitch too, where the device lays one out so, made `PREINITIALIZED`, whose one layout
|
||||
transition keeps the bytes between its rows (`WorkCounts::kept_padding_aliases`; docs/API.md,
|
||||
|
||||
Reference in new issue
Block a user