rt: a render target with a storage view takes the feedback usage and is read in its own pass
Metal fetches ([[color(n)]]) and reads, through a texture, a render target of any usage. rt read
only a shader-read colour target with no storage view whose home is SHADER_READ_ONLY_OPTIMAL.
A target made for shader writes, or of an unknown usage (which rt takes as every usage), has a
storage view wherever the device stores its format, and its home is GENERAL, so every
fetching draw on it was refused with Gap::Draw { FetchedAttachment }. The macOS 26 guest's
surface shapes are such images: a storage shape takes usage 0, and every later view of that
extent views it.
The scope was rt's own, not Vulkan's. The feedback layout asks the image for the feedback usage
beside a colour or depth-stencil attachment usage and a sampled or input usage
(VUID-VkImageMemoryBarrier2-srcQueueFamilyIndex-07006, VUID-VkRenderingAttachmentInfo-imageView-10780),
and bars no other usage. While the image is in that layout it is only rendered and sampled.
The form that exists, with no new form:
- Plan::reads_attachments drops `!self.storage`. Such an image takes the feedback usage where
the device's image format query offers it beside the storage usage. Where the query refuses,
the draw is the shadow on a device without the loop, or the known gap, as today.
- The image keeps its own home, GENERAL for a storage image. A pass renders it there, moves it
whole to the feedback layout at its first reading draw, and moves it back home at its end;
the move code already takes the home and the rendering layout from the attachment.
- The image's attachment reads no longer require home SHADER_READ_ONLY_OPTIMAL; they exclude
only an image in place over a buffer, whose linear image takes no feedback usage (that shape
stays refused).
- A draw that writes the same image through a slot in the pass stays AttachmentRead, as today.
The README's attachment-read and fetch text and the AttachmentRead doc are updated.
Verified: see the check job named in the landing.
This commit is contained in:
1 parent
6a6431bfd4
commit
1ae9003019
4 files changed
+42
-28
No files matched your search
@@ -903,7 +903,7 @@ made, with no lock, and never rewritten for layouts.
|
||||
the texture's own index while it reads an attachment of its pass through the texture. Through
|
||||
the attachment feedback loop it is the texture's view in the feedback layout, written with
|
||||
element `i` for a texture whose image a pass may move there (a shader-read colour render target
|
||||
with no storage view); on a device without the loop it is the texture's view of its image's
|
||||
not in place over a buffer); on a device without the loop it is the texture's view of its image's
|
||||
shadow (Render encoders), written at the first draw that reads through it where the texture
|
||||
still owns index `i`. It is a null descriptor otherwise, and no grant reaches it.
|
||||
- A shader masks the index of a texture ID it reads from an argument buffer to its low 16 bits,
|
||||
@@ -2565,11 +2565,16 @@ or does not check is rebuilt from the generations' names, with young counted ful
|
||||
target, where the device reads attachments (Floor, Attachment reads): through the attachment
|
||||
feedback loop where the device has it, else through a copy. The texture reaches the
|
||||
attachment's level and layer, the fragment function reads it and nothing writes it, and its
|
||||
image is a shader-read colour render target with no storage view, which one attachment of the
|
||||
pass renders. Through the feedback loop, at the pass's first such draw the rendering ends, one
|
||||
barrier moves the whole image to the feedback layout (the attachment's level and layer from the
|
||||
attachment layout, the rest from home), and the rendering begins again with the attachment in
|
||||
that layout; the pass's second barrier moves the whole image home. Until then every draw of the
|
||||
image is a shader-read colour render target not in place over a buffer, which one attachment of
|
||||
the pass renders: its home is shader-read-only, or general where it has a storage view (made for
|
||||
shader writes, or of an unknown usage, where the device stores its format), and its image takes
|
||||
the feedback usage where the device's image format query offers it beside the rest, the storage
|
||||
usage included. Vulkan's feedback layout asks the attachment and sampled usages beside it and
|
||||
bars none (VUID-VkImageMemoryBarrier2-srcQueueFamilyIndex-07006); in it the image is only
|
||||
rendered and sampled. Through the feedback loop, at the pass's first such draw the rendering
|
||||
ends, one barrier moves the whole image to the feedback layout (the attachment's level and layer
|
||||
from the layout the pass renders it in, the rest from home), and the rendering begins again
|
||||
with the attachment in that layout; the pass's second barrier moves the whole image home. Until then every draw of the
|
||||
pass reads the image's textures through their second elements (Set 1), a texture that reaches
|
||||
no rendered level among them. Every render pipeline takes the feedback loop's enable as dynamic
|
||||
state, which the encoder sets at its first draw and where it changes: colour for a draw that
|
||||
@@ -2602,8 +2607,8 @@ or does not check is rebuilt from the generations' names, with young counted ful
|
||||
barrier, and it begins again), and through a copy copies what it reads into the shadow again: a
|
||||
pass of N fetching draws records N - 1 such barriers, or N - 1 copies. The texture is a 2D
|
||||
texture (a 2D multisample one in a multisampled pass) whose first level and slice the pass
|
||||
renders, made with an index, of a shader-read colour render target's image: a texture of its
|
||||
own image, or a surface plane's (Exported surfaces).
|
||||
renders, made with an index, of a shader-read colour render target's image, with a storage view
|
||||
or not: a texture of its own image, or a surface plane's (Exported surfaces).
|
||||
- `memory_barrier` after a draw of the encoder that wrote memory ends the rendering, records one
|
||||
barrier and begins the rendering again, loading what it stored. After draws that only rendered,
|
||||
in a pass that moved an image to the feedback layout, the barrier is owed to the next draw that
|
||||
@@ -2642,8 +2647,9 @@ or does not check is rebuilt from the generations' names, with young counted ful
|
||||
pipeline state whose formats are not the pass's attachments', a draw that binds a texture
|
||||
whose image the pass renders, where neither the feedback loop nor a copy reads it: on a device
|
||||
without the attachment reads, from the vertex function at the rendered level and layer, written, of a
|
||||
depth or stencil attachment, of an image with a storage view or over a buffer in place, or of
|
||||
an image two attachments of the pass render; and, on a device that does not report
|
||||
depth or stencil attachment, of an image over a buffer in place or whose format the device
|
||||
takes neither the feedback usage nor a shadow for, or of an image two attachments of the pass
|
||||
render; and, on a device that does not report
|
||||
`supportsNonZeroFirstInstance` (lavapipe and the UHD 630 among the lab's), a draw at a base
|
||||
instance other than 0 through a state that steps a layout per instance at a rate above 1
|
||||
(`DividedBaseInstance`: Vulkan's divisor takes `firstInstance` 0 alone there,
|
||||
@@ -2652,7 +2658,7 @@ or does not check is rebuilt from the generations' names, with young counted ful
|
||||
`PatchIndexBuffer`: the control stage takes each patch's index from its position, and no replay
|
||||
stream's patch draw names one. The replay streams draw lines and triangles
|
||||
under depth biases with no clamp; every attachment they read through a texture is
|
||||
a shader-read colour render target of `Private` storage, read from the fragment function; and
|
||||
a colour render target of `Private` storage, read from the fragment function; and
|
||||
their stepped draws (a WebGL stream's, at rates 2 and 3) are all at base instance 0.
|
||||
A draw that reads its own target over a buffer in place, a linear image on the buffer's memory
|
||||
that never leaves the general layout, is refused on every device (`AttachmentRead`): no play
|
||||
|
||||
@@ -1289,8 +1289,9 @@ pub enum DrawKind {
|
||||
/// A draw that binds a texture whose image the pass renders, where neither the attachment
|
||||
/// feedback loop nor a copy into the image's shadow reads it: on a device without the
|
||||
/// attachment reads (`floor::Capabilities::attachment_reads`), from the vertex function at the
|
||||
/// rendered level and layer, written, of a depth or stencil attachment, of an image with a
|
||||
/// storage view or over a buffer in place, or of an image two attachments of the pass render.
|
||||
/// rendered level and layer, written, of a depth or stencil attachment, of an image over a
|
||||
/// buffer in place or whose format the device takes neither the feedback usage nor a shadow
|
||||
/// for, or of an image two attachments of the pass render.
|
||||
/// Metal reads a render target through a texture.
|
||||
AttachmentRead,
|
||||
/// A draw through a pipeline state whose fragment function reads a colour attachment
|
||||
|
||||
@@ -24,8 +24,10 @@
|
||||
//!
|
||||
//! A draw may read an attachment of its own pass through a texture, as Metal reads a render target
|
||||
//! (`floor::Capabilities::attachment_reads`): through the attachment feedback loop where the
|
||||
//! device has it, else through a copy. Its image is a shader-read colour render target with no
|
||||
//! storage view, whose home is shader-read-only.
|
||||
//! device has it, else through a copy. Its image is a shader-read colour render target not in
|
||||
//! place over a buffer, whose home is shader-read-only, or general where it has a storage view.
|
||||
//! An attachment at home general renders there, and a move to the feedback layout and back is
|
||||
//! from and to general.
|
||||
//!
|
||||
//! Through the feedback loop: at the pass's first draw that reads the image, the rendering ends,
|
||||
//! one barrier moves the whole image to the feedback layout (its rendered level and layer from the
|
||||
|
||||
@@ -362,13 +362,13 @@ pub(crate) struct Image {
|
||||
/// The layout the image is in outside a copy, which its elements name.
|
||||
home: vk::ImageLayout,
|
||||
/// A draw may read an attachment of its own pass through a texture over the image (a
|
||||
/// shader-read colour render target of no storage view, its home shader-read-only, on a
|
||||
/// device that reads attachments): each such texture has a second element of the
|
||||
/// sampled-texture array, at its index plus [`TEXTURES`](crate::floor::TEXTURES). Through the
|
||||
/// attachment feedback loop the image has the feedback usage and the element names the
|
||||
/// feedback layout, which a pass moves the whole image to for a draw that reads it; on a
|
||||
/// device without the loop the element names the texture's view of the image's shadow
|
||||
/// (`shadowing`).
|
||||
/// shader-read colour render target not in place over a buffer, its home shader-read-only, or
|
||||
/// general where it has a storage view, on a device that reads attachments): each such
|
||||
/// texture has a second element of the sampled-texture array, at its index plus
|
||||
/// [`TEXTURES`](crate::floor::TEXTURES). Through the attachment feedback loop the image has
|
||||
/// the feedback usage and the element names the feedback layout, which a pass moves the whole
|
||||
/// image to from its home, and back, for a draw that reads it; on a device without the loop
|
||||
/// the element names the texture's view of the image's shadow (`shadowing`).
|
||||
attachment_reads: bool,
|
||||
/// Where a draw reads the image as an attachment on a device without the feedback loop: what
|
||||
/// its shadow is made of, and the shadow once made (`crate::shadow`).
|
||||
@@ -1386,8 +1386,11 @@ impl Device {
|
||||
core.counters.rise(Gauge::Textures);
|
||||
// A clear zeroes it in its move home.
|
||||
let zero = placed.then(|| Zero::of(&plan, d.mipmap_level_count, &shape));
|
||||
let attachment_reads =
|
||||
plan.attachment_reads && home == vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL;
|
||||
// An image in place over a buffer is the buffer's linear image, of no feedback usage
|
||||
// (`Plan::linear_usage`); any other keeps its home, shader-read-only or general, which a
|
||||
// pass moves it from to the feedback layout and back.
|
||||
let laid_over = named.as_ref().is_some_and(|n| n.form == Form::InPlace);
|
||||
let attachment_reads = plan.attachment_reads && !laid_over;
|
||||
// On a device without the feedback loop, a draw reads such an image through its shadow.
|
||||
let shadowing = (attachment_reads && core.feedback.is_none()).then(|| {
|
||||
Box::new(Shadowing {
|
||||
@@ -1527,21 +1530,23 @@ struct Plan {
|
||||
|
||||
impl Plan {
|
||||
/// The usage of a linear image of the plan, over a buffer in place: without the feedback
|
||||
/// usage, as its home is general and no pass moves it to the feedback layout.
|
||||
/// usage, as no pass moves it to the feedback layout.
|
||||
fn linear_usage(&self) -> vk::ImageUsageFlags {
|
||||
self.usage & !vk::ImageUsageFlags::ATTACHMENT_FEEDBACK_LOOP_EXT
|
||||
}
|
||||
|
||||
/// Whether a draw may read an attachment of its own pass through a texture of the plan, where
|
||||
/// its image takes the feedback usage or a shadow: a shader-read colour render target of no
|
||||
/// storage view, on a device that reads attachments.
|
||||
/// its image takes the feedback usage or a shadow: a shader-read colour render target, with a
|
||||
/// storage view or not, on a device that reads attachments. Vulkan's feedback layout asks the
|
||||
/// attachment and sampled usages beside the feedback usage
|
||||
/// (`VUID-VkImageMemoryBarrier2-srcQueueFamilyIndex-07006`) and bars none, the storage usage
|
||||
/// included; in it the image is only rendered and sampled.
|
||||
fn reads_attachments(&self, core: &Core) -> bool {
|
||||
let render =
|
||||
vk::ImageUsageFlags::COLOR_ATTACHMENT | vk::ImageUsageFlags::DEPTH_STENCIL_ATTACHMENT;
|
||||
core.attachment_reads
|
||||
&& self.usage.contains(vk::ImageUsageFlags::SAMPLED)
|
||||
&& self.usage.intersects(render)
|
||||
&& !self.storage
|
||||
&& self.aspects == vk::ImageAspectFlags::COLOR
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user