Textures over buffers only the device's ordered commands write hold their rows' padding in place
What: a texture that renders nothing over a buffer of the runtime's own memory whose rows lie
with the buffer's bytes between them is now the device's linear image, made PREINITIALIZED, at
the buffer's pitch, where only the device's commands, in the runtime's order, write those bytes:
a Private buffer, and a Managed buffer's own on a device without unified memory (a two-copy
no-copy buffer's device copy, or one with its own host copy), not one whose VkBuffer was handed
out or whose memory is exportable (Buffer::gpu_bytes_ordered). linear_plan::holding answers what
an image may hold besides the texels (Between::{Nothing, Unobserved, Kept}); Kept takes route 1
alone: the linear image whose rowPitch the driver reports equal to the buffer's
(vkGetImageSubresourceLayout, aliases with within_padding). No DRM_FORMAT_MOD_LINEAR image at
Metal's pitch, no image over exportable memory or in exportable blocks, as each is made
UNDEFINED. A render target stays a shadow. Counted: WorkCounts::kept_padding_aliases.
Also two pairs of counts of what the program asks of a two-copy Managed buffer, beside the bytes
the runtime copies: managed_ranges_modified and managed_bytes_modified (did_modify_range),
managed_resources_synchronized and managed_bytes_synchronized (synchronize_resource), to compare
with managed_bytes_copied_in and managed_bytes_copied_out.
Why: the RTX 2080 guest census (reims's v302 run) made 230 textures over Managed buffers, 200 of
them RGBA8 ShaderRead|ShaderWrite at 3884, 4208 and 2448 texels a row with rows rounded up to
256 bytes, every one a shadow for its padded rows ("its rows lie N bytes apart"): 2.52 G shadow
texels first copied in, 1.26 G kept, 1.26 G words examined by merges back. Owner's rule:
in place where possible, a shadow only where impossible. Main approved the route and its
conditions.
Basis (Vulkan 1.4, docs/API.md's shadowed-texture entry): 7.1.1 Image Layout Transitions, "Image
layout transitions may perform read and write accesses on all memory bound to the image
subresource range ... If the old layout matches the current layout of the image subresource
range, the transition preserves the contents of that range": the image's one transition is its
first move, PREINITIALIZED to GENERAL, out of the layout it is in, ordered after and before every
write of those bytes, as only the device's ordered commands write them. 12.11 Memory Aliasing:
"Buffers, linear tensors, and linear image subresources are considered host-accessible
subresources when they are in any of these layouts: VK_IMAGE_LAYOUT_PREINITIALIZED,
VK_IMAGE_LAYOUT_GENERAL ... If two aliases are both host-accessible, then they interpret the
contents of the memory in consistent ways, and data written to one alias can be read by the other
alias." VkSubresourceLayout's "size includes any extra memory that is required based on
rowPitch" puts the padding inside the range. A kernel's writes may change the padding as on the
x86 Macs (in_place::Padding::Free); a render pass's load and store "may read and write back" it,
so render targets keep the shadow.
Verified: not built yet. tests::kept_padding (a Private buffer at 416, 448 and 512 bytes a row,
the buffer read back whole after the image's first move; a Managed two-copy texture changed in
one row through did_modify_range, then a blit-written row synchronized out, every byte between
rows as given, against a Shared buffer's shadow), tests::linear_plan's holding cases and
tests::texture_placement run on lavapipe next, then one RTX 3090 run.
This commit is contained in:
1 parent
e1ba565ea3
commit
42e11abcd4
16 files changed
+749
-69
No files matched your search
+16
-2
@@ -459,7 +459,8 @@ then (`TexturePlacement`): in place; `Pending`, a shadow made before its verdict
|
||||
where the verdict passes; a shadow and why (`TextureShadowReason`: the policy, the texel width, the
|
||||
check's failed or unchecked verdict with its access and row ends, a refusal, a tiled texture's
|
||||
levels, texels past the buffer's length, a device copy, and over the device's own memory rows with
|
||||
bytes between them the buffer does not declare unobserved, `BytesBetweenRows`); no host pages (an
|
||||
bytes between them the buffer does not declare unobserved, of a texture that renders or of a
|
||||
buffer other writers than the device's ordered commands reach, `BytesBetweenRows`); no host pages (an
|
||||
image aliasing the buffer's memory: the device's linear image where it lays one out as Metal does,
|
||||
else a `DRM_FORMAT_MOD_LINEAR` image at Metal's pitch where the device's check passed for its pooled
|
||||
memory; a texture over that memory that takes neither answers its shadow's cause); or a shape no
|
||||
@@ -1885,7 +1886,20 @@ bound.
|
||||
operations read and write back any byte of an attachment's image subresource, and Metal leaves
|
||||
them as the program writes them, unless the buffer, of the runtime's own memory, declares them
|
||||
unobserved (`BufferDescriptor::padding_unobserved`, a runtime extension: they may then change,
|
||||
and no other byte does); or no linear image of the device lays its texels out as Metal
|
||||
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,
|
||||
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
|
||||
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
|
||||
kernel's writes of such a texture may change those bytes as on the x86 Macs (section 10,
|
||||
**Kernels**); no `DRM_FORMAT_MOD_LINEAR` image and no image over exportable memory holds them,
|
||||
as each is made `UNDEFINED`, whose first move may discard them; or no linear image of the device lays its texels out as Metal
|
||||
does in the buffer's memory, holding no byte past them (among them a texture whose offset in the
|
||||
buffer misses the device's linear-image alignment, as one 32 bytes in does on RADV, whose
|
||||
images start on a multiple of 256: a buffer made with `BufferDescriptor::aligned_byte` at that
|
||||
|
||||
Reference in new issue
Block a user