Buffers: a declaration that the bytes between a texture's rows are unobserved
A consumer's cache buffer of the runtime's own memory (the 780M guest's 3662x2038 desktop
surface, more guest-page pieces than udmabuf takes) holds textures whose rows lie 14848 bytes
apart, 14648 bytes of texels each. linear_plan::holding shadows every such texture, since an image
at that pitch holds the bytes between rows and Vulkan lets its layout moves and a render pass's
load and store write them; the consumer's download copies each row's texels alone, so it never
reads those bytes, and the shadow's copies cost it about 1 G texels/s in a Finder drag.
BufferDescriptor::padding_unobserved (with_padding_unobserved) is the maker's declaration that
nothing reads the bytes between a texture's rows over the buffer (each row's bytes after its
texels to its pitch, the last row's included) nor between its slices. A runtime extension with
no Metal counterpart, only for the runtime's own memory: refused, Invalid
(PaddingUnobservedNoCopy), with NoCopy contents. The buffer keeps it (Buffer::padding_unobserved).
- The route (texture/route.rs) decides it for a buffer of the device's own memory:
Route::Device { holds } carries linear_plan::holding's answer, which with the declaration
holds rows and slices that lie apart (rows that share bytes stay refused). The making and the
placement query share it: the query answers NotHostPages where an image may hold the texels,
and the new TextureShadowReason::BytesBetweenRows where it may not (it answered NotHostPages
for both before).
- aliases takes the declaration: the image's subresources may then hold the padding
(linear_plan::within_padding: each subresource ends at its slice's last row's pitch or before,
slices at Metal's stride), never a byte past the last row's pitch, nor memory past the
buffer's. A byte of the image's memory past every subresource is reached by no operation on
it, the reading texels_alone already rests on, so no new check class is needed.
- WorkCounts::unobserved_padding_aliases counts the aliasing images that hold such bytes.
- A buffer the runtime lays in fresh pages (a long one where pointer imports cost submissions
nothing) keeps the in-place check's route: the declaration lets nothing more there (documented).
Docs: the field and builder, NotHostPages and BytesBetweenRows, HOWTO's paragraph on textures
over the runtime's own memory, API.md's shadow reasons and placement answers, the runtime
README; REFUSALS.md and api_signatures.tsv regenerated.
Tests: linear_plan's unit tests of the declared holding and aliasing (padding to the last row's
pitch held, past it or past the buffer refused, slices at Metal's stride alone, shared rows
refused); the route's placement test of both Route::Device answers; a device test
(tests/padding_unobserved.rs): a 101x48 BGRA8Unorm texture at 416, 448 and 512 bytes a row over
an undeclared buffer answers Shadow(BytesBetweenRows) and is a shadow, over a declared one answers
NotHostPages and is an aliasing image wherever the device lays one at the pitch (counted), at
least one pitch aliasing, its texels read back by a blit; and the declaration refused over the
caller's memory. The in-place lane's unobserved_padding_costs times a frame reading the
consumer's surface shape over a declared and an undeclared buffer.
Verified: pending (lavapipe and MoltenVK device tests, the 780M lane run next).
(cherry picked from commit 430523ce0e4dbd8433eb2b514f837d44ce1c5a9a)
This commit is contained in:
1 parent
9fdf288419
commit
b136c2531a
19 files changed
+671
-73
No files matched your search
+9
-5
@@ -390,10 +390,12 @@ arguments of `new_texture` and `new_texture_with_iosurface_plane`, where the tex
|
||||
then (`TexturePlacement`): in place; `Pending`, a shadow made before its verdict that moves in place
|
||||
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); no host pages; or a shape no image in place
|
||||
takes; `Buffer::tiled_texture_placement` answers it for `new_tiled_texture`'s. The making's
|
||||
own route answers it (`texture/route.rs`), after every check the making runs before it makes
|
||||
anything, so the same arguments are refused with the same errors; where the route is the image in
|
||||
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
|
||||
image aliasing the buffer's memory where the device lays one out as Metal does); or a shape no
|
||||
image in place takes; `Buffer::tiled_texture_placement` answers it for `new_tiled_texture`'s. The
|
||||
making's own route answers it (`texture/route.rs`), after every check the making runs before it
|
||||
makes anything, so the same arguments are refused with the same errors; where the route is the image in
|
||||
place, the query runs the image's making up to the bind (`texture/in_place_image.rs`): it makes the
|
||||
driver's linear image, and the `DRM_FORMAT_MOD_LINEAR` one where the driver lays the first out at
|
||||
another pitch, checks their requirements against the bytes' place and memory type, and releases
|
||||
@@ -1584,7 +1586,9 @@ bound.
|
||||
which an image over them would hold in its subresource, where 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; or no linear image of the device lays its texels out as Metal
|
||||
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
|
||||
does in the buffer's memory, holding no byte past them; or the buffer is over the caller's
|
||||
`VkBuffer`, whose memory backs no image of the runtime's; or it is a tiled texture of more than
|
||||
one level (`Buffer::new_tiled_texture`), over any buffer: no image over the buffer's memory holds
|
||||
|
||||
Reference in new issue
Block a user