rt: draws of points, through a point-class pipeline, with largePoints on the floor
A draw of points was Gap::Draw (DrawKind::Points) on every device; a guest's Mac walk met it 324 times. It now draws. - render: a content keeps a point-class VkPipeline beside its line-class one, made with the state where the descriptor names the point class (inputPrimitiveTopology), else at the first draw of points, a first-use wait (Metrics::first_use_point_waits, FirstUse::Points). The vertex module writes PointSize (the function's [[point_size]], at most Metal's 511, or 1.0). - render_encoder: Metal rasterizes a point of a function without [[point_size]] only under the point class; under another it rasterizes nothing and runs the vertex function, so such a draw records an empty scissor and the next draw the encoder's again. Points take no depth bias, as lines do not. - floor: largePoints is required, so a written size draws (without it a device draws only 1.0). rt's floor is Vulkan 1.3; Vulkan 1.4 lists largePoints among the features it requires (vkspec 1.4.366, 55.1 Feature Requirements) and the committed roadmap-2022 profile holds it. Every card we run reports it, from vulkaninfo today (device, job, pointSizeRange): KosmicKrisp 26.3.1 on the M3 Max m3-max-59492 [1, 511]; RX 550 RADV POLARIS12 59525 [0, 8191.88]; 780M RADV PHOENIX 59525, 59527, 59528 [0, 8191.88]; RX 7900 XTX RADV NAVI31 59527 [0, 8191.88]; RTX 2080 NVIDIA 620.70.06 59527 [1, 2047.94]; RTX 3090 NVIDIA 620.70.06 59528, 59526 [1, 2047.94]; Iris Xe RPL-P ANV 59526 [0.125, 255.875]; RTX 5080 Laptop NVIDIA 615.71.09 59529 [1, 2047.94]; UHD 630 Intel's Windows driver 59532 [0.125, 255.875]; lavapipe 59525..59529 [0, 256]. The README's floor list says so. - DrawKind::Points is deleted; docs/REFUSALS.md and the API signature table regenerated. - tests: on every device, points of [[point_size]] 4 cover their 4 by 4 pixels, the point pipeline made once at the first draw of points; a point-class state makes it with the state and draws a function without a size 1 pixel wide; under no class such points rasterize nothing and a triangle after them draws; a vertex function that stores runs for a draw of points as for triangles; floor: largePoints missing is named. The replay player's draw of points plays.
This commit is contained in:
1 parent
241472b6fe
commit
b975f6ddf7
12 files changed
+376
-116
No files matched your search
@@ -2248,8 +2248,9 @@ while the driver's exit handler waited on a lock, with every runtime thread alre
|
||||
wait. Each such wait is counted in `Metrics::first_use_waits`, with its time in
|
||||
`first_use_wait_nanos` and the longest in `first_use_wait_max_nanos`, and again by where it
|
||||
waited, each with its count, time and longest: `first_use_variant_waits` (a kernel's pipeline
|
||||
for a new workgroup size, threadgroup memory lengths or tiles) and `first_use_line_waits` (a
|
||||
render content's line-class pipeline). No dispatch lowers a function.
|
||||
for a new workgroup size, threadgroup memory lengths or tiles), `first_use_line_waits` (a
|
||||
render content's line-class pipeline) and `first_use_point_waits` (its point-class pipeline).
|
||||
No dispatch lowers a function.
|
||||
- `ComputePipelineState::prepare_dispatch(Dispatch, threads_per_threadgroup,
|
||||
threadgroup_memory_lengths)` has no Metal counterpart: it is a hook for a consumer's pre-pass.
|
||||
Metal compiles a compute state whole when the state is made, and so does the state's creation
|
||||
@@ -2702,11 +2703,20 @@ or does not check is rebuilt from the generations' names, with young counted ful
|
||||
- the per-patch and per-patch-control-point steps for a vertex function that is not
|
||||
post-tessellation (`Tessellation`).
|
||||
- The triangle class's `VkPipeline` is made with the state, through the device's pipeline
|
||||
cache, and so is the line class's where the descriptor's `inputPrimitiveTopology` names
|
||||
`MTLPrimitiveTopologyClassLine`; otherwise the line class's is made by the content's first
|
||||
draw of lines, which waits for it (`Metrics::first_use_waits`). Of the two replay streams' 537 render contents
|
||||
cache, and so is the line or the point class's where the descriptor's `inputPrimitiveTopology`
|
||||
names `MTLPrimitiveTopologyClassLine` or `MTLPrimitiveTopologyClassPoint`; otherwise each is
|
||||
made by the content's first draw of lines or of points, which waits for it
|
||||
(`Metrics::first_use_waits`, `first_use_line_waits`, `first_use_point_waits`). Of the two replay streams' 537 render contents
|
||||
drawn, 527 draw only triangles and 2 lines and triangles; a content drawn only as lines (8 of
|
||||
them) makes a triangle `VkPipeline` it never uses.
|
||||
- A point is as wide as the `PointSize` the vertex module writes: the function's
|
||||
`[[point_size]]`, stored as Metal's largest point, 511 pixels, where it is past it, which the
|
||||
device draws through `largePoints` (Floor) and clamps to its `pointSizeRange`
|
||||
(`PrecisionNote::DevicePointSize` where the range ends below 511), or 1.0 for a function
|
||||
without one. Metal draws a point of a function without `[[point_size]]` only under a state whose
|
||||
descriptor names the point class, 1 pixel wide; under any other class it rasterizes nothing and
|
||||
runs the vertex function all the same (Metal probes, an M4), so such a draw records its points
|
||||
behind an empty scissor: the vertex function runs, its stores land, and no fragment runs.
|
||||
- A post-tessellation vertex function's state draws its patches through the device's tessellator
|
||||
(`tessellationShader`, Floor). Its one `VkPipeline` is the patch class's, made with the state:
|
||||
the translator's synthesized vertex stage (each patch one vertex of a `PATCH_LIST` of one control
|
||||
@@ -3009,7 +3019,7 @@ or does not check is rebuilt from the generations' names, with young counted ful
|
||||
|
||||
### Known gaps of render encoders
|
||||
|
||||
- Refused by `Gap::Draw`, naming its `DrawKind`: a draw of points, a depth bias clamp other
|
||||
- Refused by `Gap::Draw`, naming its `DrawKind`: a depth bias clamp other
|
||||
than 0 (`DepthBiasClamp`, set by `set_depth_bias`), a triangle fill mode but `Fill`
|
||||
(`FillMode`, `set_triangle_fill_mode`), the depth clip mode `Clamp` (`DepthClamp`,
|
||||
`set_depth_clip_mode`), a count of viewports or scissor rectangles other than 1 (`Viewports`,
|
||||
@@ -3356,6 +3366,7 @@ Presenting runs on the runtime's own device; nothing is exported or imported.
|
||||
| `shaderClipDistance` | `VkPhysicalDeviceFeatures` | a vertex or post-tessellation vertex function's `[[clip_distance]]` |
|
||||
| `tessellationShader` | `VkPhysicalDeviceFeatures` | a post-tessellation vertex function's patches, drawn through the device's tessellator |
|
||||
| `shaderTessellationAndGeometryPointSize` | `VkPhysicalDeviceFeatures` | a post-tessellation vertex function's `[[point_size]]`; without it the device draws every such point at size 1 |
|
||||
| `largePoints` | `VkPhysicalDeviceFeatures` | a draw of points at the `[[point_size]]` its vertex function writes, up to the device's `pointSizeRange`; without it a device draws only points of size 1.0; Vulkan 1.4 and Roadmap 2022 require it |
|
||||
| `dualSrcBlend` | `VkPhysicalDeviceFeatures` | a fragment function's second output for colour attachment 0 (`[[color(0), index(1)]]`) as the blend's second source (`Source1Color`, `Source1Alpha` and their complements) |
|
||||
| `sampleRateShading` | `VkPhysicalDeviceFeatures` | a fragment function that reads its `[[sample_id]]`, or an interpolant at a sample, run once per covered sample as Metal runs it; Vulkan 1.4 requires it |
|
||||
| `vertexPipelineStoresAndAtomics` | `VkPhysicalDeviceFeatures` | a vertex or post-tessellation vertex function's writes and atomics on device memory |
|
||||
|
||||
@@ -97,6 +97,9 @@ pub(crate) enum FirstUse {
|
||||
/// A render content's line-class pipeline, at its first draw of lines
|
||||
/// ([`Metrics::first_use_line_waits`]).
|
||||
Lines,
|
||||
/// A render content's point-class pipeline, at its first draw of points
|
||||
/// ([`Metrics::first_use_point_waits`]).
|
||||
Points,
|
||||
}
|
||||
|
||||
/// A [`Part`]'s longest call: its nanoseconds, its bytes, and whether it made an allocation of
|
||||
@@ -462,7 +465,7 @@ struct Atomics {
|
||||
first_use_wait_nanos: AtomicU64,
|
||||
first_use_wait_max_nanos: AtomicU64,
|
||||
/// Each [`FirstUse`] site's waits, at its index: their count, total and longest nanoseconds.
|
||||
first_use_sites: [[AtomicU64; 3]; 2],
|
||||
first_use_sites: [[AtomicU64; 3]; 3],
|
||||
/// The makes ahead of a dispatch: their count and total nanoseconds.
|
||||
made_ahead: [AtomicU64; 2],
|
||||
blocks_made: AtomicU64,
|
||||
@@ -1236,7 +1239,8 @@ impl Counters {
|
||||
};
|
||||
let first_use =
|
||||
|site: FirstUse| (a.first_use_sites[site as usize].each_ref()).map(|n| n.load(Relaxed));
|
||||
let (variant, lines) = (first_use(FirstUse::Variant), first_use(FirstUse::Lines));
|
||||
let [variant, lines, points] =
|
||||
[FirstUse::Variant, FirstUse::Lines, FirstUse::Points].map(first_use);
|
||||
let made_ahead = (a.made_ahead.each_ref()).map(|n| n.load(Relaxed));
|
||||
let part = |part: Part| {
|
||||
let [count, bytes, total, _, over_1, over_5, over_20] = &a.parts[part as usize];
|
||||
@@ -1295,6 +1299,9 @@ impl Counters {
|
||||
first_use_line_waits: lines[0],
|
||||
first_use_line_wait_nanos: lines[1],
|
||||
first_use_line_wait_max_nanos: lines[2],
|
||||
first_use_point_waits: points[0],
|
||||
first_use_point_wait_nanos: points[1],
|
||||
first_use_point_wait_max_nanos: points[2],
|
||||
made_ahead_variants: made_ahead[0],
|
||||
made_ahead_variant_nanos: made_ahead[1],
|
||||
blocks_made: a.blocks_made.load(Relaxed),
|
||||
@@ -1644,7 +1651,7 @@ pub struct Metrics {
|
||||
/// First-use waits: encoding calls that waited while the `VkPipeline` they needed was made,
|
||||
/// for a workgroup size (a threadgroup size, or the tile of an image-only kernel's grid more
|
||||
/// than one deep) or threadgroup memory lengths no state of the kernel's content had run with
|
||||
/// before, or for a render content's first draw of lines.
|
||||
/// before, or for a render content's first draw of lines or of points.
|
||||
pub first_use_waits: u64,
|
||||
/// The nanoseconds of [`host_time`](crate::host_time) the first-use waits took, in total.
|
||||
pub first_use_wait_nanos: u64,
|
||||
@@ -1669,6 +1676,14 @@ pub struct Metrics {
|
||||
/// The longest of the [`first_use_line_waits`](Self::first_use_line_waits), in nanoseconds;
|
||||
/// a maximum since the device was made.
|
||||
pub first_use_line_wait_max_nanos: u64,
|
||||
/// Of the [`first_use_waits`](Self::first_use_waits), those for a render content's
|
||||
/// point-class pipeline, made by its first draw of points.
|
||||
pub first_use_point_waits: u64,
|
||||
/// The nanoseconds of the [`first_use_point_waits`](Self::first_use_point_waits), in total.
|
||||
pub first_use_point_wait_nanos: u64,
|
||||
/// The longest of the [`first_use_point_waits`](Self::first_use_point_waits), in
|
||||
/// nanoseconds; a maximum since the device was made.
|
||||
pub first_use_point_wait_max_nanos: u64,
|
||||
/// The compute kernels' pipelines that
|
||||
/// [`prepare_dispatch`](crate::ComputePipelineState::prepare_dispatch) made on its caller's
|
||||
/// thread, ahead of the dispatches that run them (`vkCreateComputePipelines`).
|
||||
|
||||
@@ -1409,8 +1409,6 @@ pub enum KernelInputKind {
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum DrawKind {
|
||||
/// A draw of points (`MTLPrimitiveTypePoint`).
|
||||
Points,
|
||||
/// A depth bias clamp other than 0 (`setDepthBias:slopeScale:clamp:`'s `clamp`), which no
|
||||
/// replay stream sets.
|
||||
DepthBiasClamp,
|
||||
|
||||
@@ -394,6 +394,10 @@ pub(crate) const REQUIRED: &[Feature] = &[
|
||||
// takes. Without it the device draws every such point at size 1. Every floor driver reports
|
||||
// it.
|
||||
feature!(core.shader_tessellation_and_geometry_point_size => ShaderTessellationAndGeometryPointSize),
|
||||
// A point drawn at the size its vertex function writes, up to the device's `pointSizeRange`:
|
||||
// without it a device draws only points of size 1.0. Vulkan 1.4 and Roadmap 2022 require it
|
||||
// of every device.
|
||||
feature!(core.large_points),
|
||||
// A fragment function's second output for a colour attachment (`[[color(0), index(1)]]`)
|
||||
// blends with its first, as Metal's dual-source blending does. A device without it is below
|
||||
// the floor.
|
||||
|
||||
@@ -34,12 +34,18 @@
|
||||
//! A descriptor names no topology class unless it sets `inputPrimitiveTopology`, and the replay
|
||||
//! streams' never do, while nearly every content draws only triangles (527 of the 537 contents
|
||||
//! gb and b2 draw). So the triangle class's `VkPipeline` is made with the state, where Metal
|
||||
//! compiles, and so is the line class's where the descriptor names that class; otherwise the line
|
||||
//! class's comes with the draws, made by the first draw of lines, as only a draw gives the class
|
||||
//! (one `VkPipeline` for both classes would need a dynamic topology across classes, which Vulkan
|
||||
//! 1.3 does not give). The cost: a content drawn only as lines or points makes a triangle
|
||||
//! `VkPipeline` it never uses (8 contents of the 537). The replay streams draw no points: a draw
|
||||
//! of points is refused.
|
||||
//! compiles, and so is the line or the point class's where the descriptor names that class;
|
||||
//! otherwise each comes with the draws, made by the first draw of lines or of points, as only a
|
||||
//! draw gives the class (one `VkPipeline` for several classes would need a dynamic topology across
|
||||
//! classes, which Vulkan 1.3 does not give). The cost: a content drawn only as lines or points
|
||||
//! makes a triangle `VkPipeline` it never uses (8 contents of the 537).
|
||||
//!
|
||||
//! A point's size is the `PointSize` the vertex module writes: the function's `[[point_size]]`,
|
||||
//! at most Metal's 511 pixels, or 1.0 for a function without one, which the device draws with
|
||||
//! `largePoints` (Floor), clamped to its `pointSizeRange` (`PrecisionNote::DevicePointSize` where
|
||||
//! the range ends below 511). Metal draws a point of a function without a size only under the point
|
||||
//! class; under any other class it rasterizes nothing and runs the vertex function all the same,
|
||||
//! so the encoder draws such points behind an empty scissor.
|
||||
//!
|
||||
//! A content whose vertex function is post-tessellation draws patches alone, so its one
|
||||
//! `VkPipeline` is the patch class's, made with the state: the translator's synthesized vertex and
|
||||
@@ -51,7 +57,7 @@
|
||||
//! the replay streams' states never use, are refused ([`RenderPipelineKind::Tessellation`]).
|
||||
|
||||
use crate::cache::{self, Lowerings};
|
||||
use crate::counters::{Gauge, Metric};
|
||||
use crate::counters::{FirstUse, Gauge, Metric};
|
||||
use crate::device::{lock, Core};
|
||||
use crate::error::{Error, Gap, RenderPipelineKind};
|
||||
use crate::hazard::Access;
|
||||
@@ -186,6 +192,15 @@ pub(crate) struct RenderCompiled {
|
||||
/// The line class's: made with the content where its descriptor names that class, else by the
|
||||
/// first draw of lines; null until then.
|
||||
lines: Mutex<vk::Pipeline>,
|
||||
/// The point class's, as the line class's: made with the content where its descriptor names
|
||||
/// that class, else by the first draw of points; null until then.
|
||||
points: Mutex<vk::Pipeline>,
|
||||
/// Whether a draw of points rasterizes them: the vertex function writes `[[point_size]]`, or
|
||||
/// the descriptor names the point class, under which Metal draws a point of a function that
|
||||
/// writes no size 1 pixel wide (the module writes `PointSize` 1.0). Under any other class
|
||||
/// Metal rasterizes no point of such a function and runs its vertex function all the same
|
||||
/// (`metal2vulkan::pipeline::GraphicsState::writes_point_size`).
|
||||
rasterizes_points: bool,
|
||||
/// The translator's notes of where the pipeline's answers may differ from Metal's, and its
|
||||
/// functions' constexpr samplers' (`constexpr_notes`).
|
||||
notes: Vec<PrecisionNote>,
|
||||
@@ -905,6 +920,9 @@ impl RenderCompiled {
|
||||
fixed,
|
||||
primary: vk::Pipeline::null(),
|
||||
lines: Mutex::new(vk::Pipeline::null()),
|
||||
points: Mutex::new(vk::Pipeline::null()),
|
||||
rasterizes_points: pipeline.graphics.writes_point_size
|
||||
|| lowered.input_primitive_topology == PrimitiveTopologyClass::Point,
|
||||
notes,
|
||||
draws,
|
||||
numbered,
|
||||
@@ -918,47 +936,70 @@ impl RenderCompiled {
|
||||
false => vk::PrimitiveTopology::TRIANGLE_LIST,
|
||||
};
|
||||
compiled.primary = compiled.make(class)?;
|
||||
// A descriptor that names the line class (`inputPrimitiveTopology`) gives the line
|
||||
// class's key: its `VkPipeline` is made here too, and its draws wait for none.
|
||||
if !compiled.draws.patches
|
||||
&& lowered.input_primitive_topology == PrimitiveTopologyClass::Line
|
||||
{
|
||||
let lines = compiled.make(vk::PrimitiveTopology::LINE_LIST)?;
|
||||
*lock(&compiled.lines) = lines;
|
||||
// A descriptor that names the line or the point class (`inputPrimitiveTopology`) gives
|
||||
// that class's key: its `VkPipeline` is made here too, and its draws wait for none.
|
||||
let named = match lowered.input_primitive_topology {
|
||||
PrimitiveTopologyClass::Line => compiled.later(vk::PrimitiveTopology::LINE_LIST),
|
||||
PrimitiveTopologyClass::Point => compiled.later(vk::PrimitiveTopology::POINT_LIST),
|
||||
_ => None,
|
||||
};
|
||||
if let (false, Some((later, list, _))) = (compiled.draws.patches, named) {
|
||||
let made = compiled.make(list)?;
|
||||
*lock(later) = made;
|
||||
}
|
||||
Ok(compiled)
|
||||
}
|
||||
|
||||
/// Where the content keeps the `VkPipeline` of `topology`'s class when that is the line or
|
||||
/// the point class, which it makes after its triangle class's: the pipeline's place, the
|
||||
/// class's list topology it is made with, and the first-use site that counts its make at a
|
||||
/// draw. `None` for a triangle or patch topology.
|
||||
fn later(
|
||||
&self,
|
||||
topology: vk::PrimitiveTopology,
|
||||
) -> Option<(&Mutex<vk::Pipeline>, vk::PrimitiveTopology, FirstUse)> {
|
||||
use vk::PrimitiveTopology as T;
|
||||
match topology {
|
||||
T::LINE_LIST | T::LINE_STRIP => Some((&self.lines, T::LINE_LIST, FirstUse::Lines)),
|
||||
T::POINT_LIST => Some((&self.points, T::POINT_LIST, FirstUse::Points)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether a draw of points rasterizes them (`rasterizes_points`): else the encoder draws them
|
||||
/// behind an empty scissor, its vertex function run.
|
||||
pub(crate) fn rasterizes_points(&self) -> bool {
|
||||
self.rasterizes_points
|
||||
}
|
||||
|
||||
/// Whether the content's `VkPipeline`s discard every primitive (Metal's rasterization
|
||||
/// disabled): a dynamic state each bind sets.
|
||||
pub(crate) fn discards(&self) -> bool {
|
||||
self.fixed.discard
|
||||
}
|
||||
|
||||
/// The `VkPipeline` of the content for draws of `topology`'s class, a line or triangle one, or
|
||||
/// for a post-tessellation vertex function's content the patch one, which the encoder draws
|
||||
/// alone with it: the line class's, where the content was not made with it, made by its first
|
||||
/// draw, which waits for it, a first-use wait
|
||||
/// The `VkPipeline` of the content for draws of `topology`'s class, a point, line or triangle
|
||||
/// one, or for a post-tessellation vertex function's content the patch one, which the encoder
|
||||
/// draws alone with it: the point or line class's, where the content was not made with it,
|
||||
/// made by its first draw, which waits for it, a first-use wait
|
||||
/// ([`Metrics::first_use_waits`](crate::Metrics::first_use_waits)).
|
||||
///
|
||||
/// Err: [`Error::Vulkan`] where the pipeline cannot be made.
|
||||
pub(crate) fn pipeline(&self, topology: vk::PrimitiveTopology) -> Result<vk::Pipeline, Error> {
|
||||
if self.draws.patches
|
||||
|| (topology != vk::PrimitiveTopology::LINE_LIST
|
||||
&& topology != vk::PrimitiveTopology::LINE_STRIP)
|
||||
{
|
||||
let later = match self.draws.patches {
|
||||
true => None,
|
||||
false => self.later(topology),
|
||||
};
|
||||
let Some((later, list, site)) = later else {
|
||||
return Ok(self.primary);
|
||||
}
|
||||
let mut lines = lock(&self.lines);
|
||||
if *lines == vk::Pipeline::null() {
|
||||
};
|
||||
let mut made = lock(later);
|
||||
if *made == vk::Pipeline::null() {
|
||||
let began = host_time();
|
||||
*lines = self.make(vk::PrimitiveTopology::LINE_LIST)?;
|
||||
(self.core.counters).first_use_wait(
|
||||
crate::counters::FirstUse::Lines,
|
||||
host_time().saturating_sub(began),
|
||||
);
|
||||
*made = self.make(list)?;
|
||||
(self.core.counters).first_use_wait(site, host_time().saturating_sub(began));
|
||||
}
|
||||
Ok(*lines)
|
||||
Ok(*made)
|
||||
}
|
||||
|
||||
/// Whether the content's `VkPipeline`s render into `pass`'s attachments: its colour formats are
|
||||
@@ -1177,7 +1218,8 @@ impl Drop for RenderCompiled {
|
||||
// it retired.
|
||||
self.core.counters.fall(Gauge::RenderContents);
|
||||
let lines = *self.lines.get_mut().unwrap_or_else(|e| e.into_inner());
|
||||
for pipeline in [self.primary, lines] {
|
||||
let points = *self.points.get_mut().unwrap_or_else(|e| e.into_inner());
|
||||
for pipeline in [self.primary, lines, points] {
|
||||
if pipeline != vk::Pipeline::null() {
|
||||
(self.core.reaper).give(Job::Free(Free::Pipeline(pipeline)));
|
||||
}
|
||||
|
||||
@@ -476,8 +476,8 @@ enum Call<'a> {
|
||||
/// winding, a depth-stencil state's depth and stencil tests, the depth bias without a clamp, the
|
||||
/// stencil references, the blend color, the line width (lines drawn at 1 alone: a draw of lines
|
||||
/// at another width is [`DrawKind::LineWidth`]), the store actions an encoder sets for an
|
||||
/// attachment whose pass left them unknown, memory barriers, fences, direct draws of lines and triangles,
|
||||
/// indexed or not, direct draws of patches with a tessellation factor buffer, and the `Disabled`
|
||||
/// attachment whose pass left them unknown, memory barriers, fences, direct draws of points, lines
|
||||
/// and triangles, indexed or not, direct draws of patches with a tessellation factor buffer, and the `Disabled`
|
||||
/// visibility result mode (`Boolean` and `Counting` are [`DrawKind::VisibilityResults`]). Not
|
||||
/// built, and so not methods: indirect draws, several viewports or scissor rectangles, the
|
||||
/// triangle fill mode, the depth clip mode, `useResource:`, the store action options
|
||||
@@ -530,6 +530,9 @@ pub struct RenderCommandEncoder {
|
||||
depth_bias: [f32; 2],
|
||||
/// Whether the last draw recorded the depth bias enabled.
|
||||
biased: bool,
|
||||
/// Whether the last draw recorded an empty scissor, for points it does not rasterize
|
||||
/// ([`RenderCommandEncoder::draw_primitives`]).
|
||||
hidden: bool,
|
||||
/// The dynamic state to record before the next draw.
|
||||
dirty: u32,
|
||||
/// The topology and primitive restart the last draw set.
|
||||
@@ -615,6 +618,7 @@ impl CommandBuffer {
|
||||
line_width: 1.0,
|
||||
depth_bias: [0.0; 2],
|
||||
biased: false,
|
||||
hidden: false,
|
||||
recorded: None,
|
||||
dirty: ALL,
|
||||
topology: None,
|
||||
@@ -1588,8 +1592,14 @@ impl RenderCommandEncoder {
|
||||
/// The draw pushes its functions' fields (the addresses of their buffer slots plus their
|
||||
/// offsets, the resource IDs of their textures and sampler states, and the indices of the
|
||||
/// state's constexpr samplers), binds the vertex buffers the pipeline state's vertex
|
||||
/// descriptor reads, and sets the dynamic state that changed. A draw of lines first makes
|
||||
/// its content's line `VkPipeline`, where no draw made it before.
|
||||
/// descriptor reads, and sets the dynamic state that changed. A draw of lines or of points
|
||||
/// first makes its content's line or point `VkPipeline`, where no draw made it before.
|
||||
///
|
||||
/// A point is the `[[point_size]]` the vertex function writes wide, at most Metal's 511
|
||||
/// pixels, or 1 pixel for a function that writes none under a state whose descriptor names the
|
||||
/// point class (`inputPrimitiveTopology`). Under any other class Metal rasterizes no point of
|
||||
/// such a function and runs it all the same, and so does this: its points are drawn behind an
|
||||
/// empty scissor.
|
||||
///
|
||||
/// Err: [`Refusal::NoPipeline`]; [`Refusal::NoBufferAtIndex`] for a vertex buffer the vertex
|
||||
/// descriptor reads that is not bound; [`Refusal::VertexBufferOffset`];
|
||||
@@ -1611,7 +1621,7 @@ impl RenderCommandEncoder {
|
||||
vertex_count,
|
||||
};
|
||||
self.draw(
|
||||
primitives(primitive_type)?,
|
||||
primitives(primitive_type),
|
||||
call,
|
||||
instance_count,
|
||||
base_instance,
|
||||
@@ -1643,7 +1653,7 @@ impl RenderCommandEncoder {
|
||||
base_vertex,
|
||||
};
|
||||
self.draw(
|
||||
primitives(primitive_type)?,
|
||||
primitives(primitive_type),
|
||||
call,
|
||||
instance_count,
|
||||
base_instance,
|
||||
@@ -1856,6 +1866,8 @@ impl RenderCommandEncoder {
|
||||
if lines && self.line_width != 1.0 {
|
||||
return gap(DrawKind::LineWidth);
|
||||
}
|
||||
// Points Metal does not rasterize: the vertex function runs, behind an empty scissor.
|
||||
let hidden = topology == vk::PrimitiveTopology::POINT_LIST && !compiled.rasterizes_points();
|
||||
let pipeline = compiled.pipeline(topology)?;
|
||||
let discards = compiled.discards();
|
||||
let writes_memory = draws.writes_memory;
|
||||
@@ -1948,7 +1960,7 @@ impl RenderCommandEncoder {
|
||||
core.device.cmd_set_rasterizer_discard_enable(command, true);
|
||||
}
|
||||
}
|
||||
self.record_state(topology, restart);
|
||||
self.record_state(topology, restart, hidden);
|
||||
}
|
||||
let core = &*self.core;
|
||||
let device = &core.device;
|
||||
@@ -2283,12 +2295,18 @@ impl RenderCommandEncoder {
|
||||
}
|
||||
|
||||
/// Records the dynamic state that changed since the last draw, and the draw's topology and
|
||||
/// primitive restart where they changed.
|
||||
/// primitive restart where they changed; the scissor empty where the draw is `hidden`, and
|
||||
/// the encoder's again at the next draw that is not.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The encoder's command buffer is inside its pass's rendering.
|
||||
unsafe fn record_state(&mut self, topology: vk::PrimitiveTopology, restart: bool) {
|
||||
unsafe fn record_state(
|
||||
&mut self,
|
||||
topology: vk::PrimitiveTopology,
|
||||
restart: bool,
|
||||
hidden: bool,
|
||||
) {
|
||||
let device = &self.core.device;
|
||||
let feedback = self.core.feedback.as_ref();
|
||||
let command = self.command;
|
||||
@@ -2299,7 +2317,14 @@ impl RenderCommandEncoder {
|
||||
unsafe {
|
||||
if dirty & VIEWPORT != 0 {
|
||||
device.cmd_set_viewport(command, 0, &[vk_viewport(&self.viewport)]);
|
||||
device.cmd_set_scissor(command, 0, &[self.vk_scissor()]);
|
||||
}
|
||||
if dirty & VIEWPORT != 0 || hidden != self.hidden {
|
||||
let scissor = match hidden {
|
||||
true => vk::Rect2D::default(),
|
||||
false => self.vk_scissor(),
|
||||
};
|
||||
device.cmd_set_scissor(command, 0, &[scissor]);
|
||||
self.hidden = hidden;
|
||||
}
|
||||
if dirty & CULL != 0 {
|
||||
let mode = match self.cull_mode {
|
||||
@@ -2369,11 +2394,13 @@ impl RenderCommandEncoder {
|
||||
}
|
||||
// Metal biases triangles alone, where the bias or the slope scale is not zero.
|
||||
let [constant, slope] = self.depth_bias;
|
||||
let lines = matches!(
|
||||
let triangles = !matches!(
|
||||
topology,
|
||||
vk::PrimitiveTopology::LINE_LIST | vk::PrimitiveTopology::LINE_STRIP
|
||||
vk::PrimitiveTopology::LINE_LIST
|
||||
| vk::PrimitiveTopology::LINE_STRIP
|
||||
| vk::PrimitiveTopology::POINT_LIST
|
||||
);
|
||||
let biased = !lines && (constant != 0.0 || slope != 0.0);
|
||||
let biased = triangles && (constant != 0.0 || slope != 0.0);
|
||||
if dirty & BIAS != 0 {
|
||||
device.cmd_set_depth_bias(command, constant, 0.0, slope);
|
||||
}
|
||||
@@ -2513,17 +2540,9 @@ impl Drop for RenderCommandEncoder {
|
||||
}
|
||||
|
||||
/// The topology of a draw of `primitive_type`, and whether it restarts strips.
|
||||
///
|
||||
/// Err: [`Gap::Draw`] of [`DrawKind::Points`].
|
||||
fn primitives(primitive_type: PrimitiveType) -> Result<(vk::PrimitiveTopology, bool), Error> {
|
||||
fn primitives(primitive_type: PrimitiveType) -> (vk::PrimitiveTopology, bool) {
|
||||
let (topology, restart) = input_assembly(primitive_type);
|
||||
let topology = vk::PrimitiveTopology::from_raw(topology.as_raw());
|
||||
if topology == vk::PrimitiveTopology::POINT_LIST {
|
||||
return Err(Error::Unsupported(Gap::Draw {
|
||||
kind: DrawKind::Points,
|
||||
}));
|
||||
}
|
||||
Ok((topology, restart))
|
||||
(vk::PrimitiveTopology::from_raw(topology.as_raw()), restart)
|
||||
}
|
||||
|
||||
/// Fills `push`, the push bytes of a draw of `state`, and `blocks`, each function's parameter
|
||||
|
||||
@@ -21,6 +21,12 @@
|
||||
//! first draw of lines makes nothing and waits for nothing.
|
||||
//! - lines draw at width 1 alone: at width 2 a draw of lines or a line strip is
|
||||
//! `DrawKind::LineWidth` and a triangle draws; at 1 again, and in a later encoder, lines draw.
|
||||
//! - points (the owned fixture `engine/rt6_render_state.ll`'s `rt6_point`, of
|
||||
//! `[[point_size]]` 4) cover the pixels whose centres their square holds, the content's
|
||||
//! point `VkPipeline` made at its first draw of points, a first-use wait; a state whose
|
||||
//! descriptor names the point class makes that pipeline with the state, and its points of a
|
||||
//! function without `[[point_size]]` are 1 pixel each; under another class such points
|
||||
//! rasterize nothing, and a triangle drawn after them draws through the encoder's scissor.
|
||||
//! - a stencil state that replaces the stencil marks what a draw covers, and one that tests it
|
||||
//! keeps a later draw to those pixels.
|
||||
//! - a pass clears, loads and stores a shader-read `Depth32Float` depth attachment that its
|
||||
@@ -59,9 +65,8 @@
|
||||
//! - 32-bit indices 2 bytes past a multiple of 256 in their block are refused before anything
|
||||
//! is recorded, and 16-bit indices there draw.
|
||||
//! - what Metal refuses is refused, and what a draw does not build is a gap: no pipeline state,
|
||||
//! a pipeline state of other formats than the pass's, points, a depth test, a stencil test
|
||||
//! without a stencil attachment, a misaligned index offset, a non-finite viewport and a
|
||||
//! mirrored one.
|
||||
//! a pipeline state of other formats than the pass's, a depth test, a stencil test without a
|
||||
//! stencil attachment, a misaligned index offset, a non-finite viewport and a mirrored one.
|
||||
//! - a pass with a visibility result buffer draws, its command buffer keeps the buffer until it
|
||||
//! retires, and its bytes stay as they were; `Disabled` at any offset records nothing, the
|
||||
//! pass takes the submission, barrier and pass one without the buffer takes, and `Boolean`
|
||||
@@ -762,6 +767,154 @@ pub(crate) mod on_device {
|
||||
});
|
||||
}
|
||||
|
||||
/// The clip-space position (Metal's y up) of pixel `(x, y)`'s centre in a target `SIDE` a
|
||||
/// side.
|
||||
fn centre(x: u32, y: u32) -> [f32; 2] {
|
||||
let half = SIDE as f32 / 2.0;
|
||||
[(x as f32 + 0.5) / half - 1.0, 1.0 - (y as f32 + 0.5) / half]
|
||||
}
|
||||
|
||||
/// Points of `[[point_size]]` 4 (`rt6_point`, one at the target's centre) cover the 4 by 4
|
||||
/// pixels whose centres their square holds; the first draw of points makes the content's
|
||||
/// point pipeline, a first-use wait, and a second makes nothing. A state whose descriptor
|
||||
/// names the point class makes its point pipeline with the state, and draws a point of a
|
||||
/// function without `[[point_size]]` (`colored_vertex`) 1 pixel wide, its first draw making
|
||||
/// and waiting for nothing. Under no class such points rasterize nothing, as Metal's, and a
|
||||
/// triangle drawn after them in the encoder draws through its scissor again.
|
||||
#[test]
|
||||
fn every_device_draws_points_at_their_size_and_a_point_class_s_at_1() {
|
||||
use metal2vulkan::metal::PrimitiveTopologyClass;
|
||||
|
||||
let (Some(library), Some(engine)) = (
|
||||
examples(),
|
||||
library(&engine_dir().join("rt6_render_state.ll")),
|
||||
) else {
|
||||
return;
|
||||
};
|
||||
let function = |library: &Library, name: &str| {
|
||||
StageSource::Function(FunctionDescriptor::new(
|
||||
library.function(name).expect("the function"),
|
||||
))
|
||||
};
|
||||
let mut sized = RenderPipelineDescriptor::new(function(&engine, "rt6_point"));
|
||||
sized.fragment = Some(function(&engine, "rt6_white"));
|
||||
sized.color_attachments[0] = Some(ColorAttachmentDescriptor::new(PixelFormat::RGBA8Unorm));
|
||||
let plain = descriptor(&library, "colored_fragment", PixelFormat::RGBA8Unorm);
|
||||
let mut classed = plain.clone();
|
||||
classed.input_primitive_topology = PrimitiveTopologyClass::Point;
|
||||
let marks = [(1, 1), (6, 2), (3, 6)];
|
||||
each_device("draw_points", |name, _, device| {
|
||||
let counters = device.counters();
|
||||
let sized = state(name, &device, &sized);
|
||||
let plain = state(name, &device, &plain);
|
||||
let made = counters.metrics();
|
||||
let classed = state(name, &device, &classed);
|
||||
let created = counters.metrics();
|
||||
assert_eq!(
|
||||
created.pipelines_created - made.pipelines_created,
|
||||
2,
|
||||
"{name}: the point class's state: the triangle and the point pipelines"
|
||||
);
|
||||
let mut buffers = Buffers::new(&device);
|
||||
// The three marks as points, then a triangle over rows 4 to 7.
|
||||
let mut positions: Vec<f32> = marks.iter().flat_map(|&(x, y)| centre(x, y)).collect();
|
||||
positions.extend([-1.0, 0.0, 3.0, 0.0, -1.0, -4.0]);
|
||||
let positions = buffers.of(&device, &floats(&positions));
|
||||
let colors = [GREEN, GREEN, GREEN, WHITE, WHITE, WHITE].concat();
|
||||
let colors = buffers.of(&device, &floats(&colors));
|
||||
let depth = floats(&[0.0, 0.0]);
|
||||
let queue = device.new_command_queue(4).expect("a queue");
|
||||
let draw = |result: Result<(), Error>| result.unwrap_or_else(|e| panic!("{name}: {e}"));
|
||||
// Each case's target, read after its command buffer completes.
|
||||
let pixels = |case: &str, encode: &dyn Fn(&mut crate::RenderCommandEncoder)| {
|
||||
let color = target(
|
||||
&device,
|
||||
PixelFormat::RGBA8Unorm,
|
||||
TextureUsage::RENDER_TARGET,
|
||||
);
|
||||
let command_buffer = queue.command_buffer().expect("a command buffer");
|
||||
let mut encoder = (command_buffer.render_command_encoder(&pass(&color, None)))
|
||||
.unwrap_or_else(|error| panic!("{name}: {case}: {error}"));
|
||||
encode(&mut encoder);
|
||||
encoder.end_encoding();
|
||||
run(name, &command_buffer);
|
||||
let texels = read(&color, 4);
|
||||
move |x: u32, y: u32| {
|
||||
let i = ((y * SIDE + x) * 4) as usize;
|
||||
[texels[i], texels[i + 1], texels[i + 2], texels[i + 3]]
|
||||
}
|
||||
};
|
||||
for round in 0..2 {
|
||||
let before = counters.metrics();
|
||||
let at = pixels("sized", &|encoder: &mut crate::RenderCommandEncoder| {
|
||||
draw(encoder.set_render_pipeline_state(&sized));
|
||||
draw(encoder.set_vertex_bytes(&depth, 0));
|
||||
draw(encoder.draw_primitives(PrimitiveType::Point, 0, 1, 1, 0));
|
||||
});
|
||||
let after = counters.metrics();
|
||||
let made = u64::from(round == 0);
|
||||
assert_eq!(
|
||||
(
|
||||
after.pipelines_created - before.pipelines_created,
|
||||
after.first_use_point_waits - before.first_use_point_waits,
|
||||
),
|
||||
(made, made),
|
||||
"{name}: round {round}: pipelines made, first-use point waits"
|
||||
);
|
||||
for y in 0..SIDE {
|
||||
for x in 0..SIDE {
|
||||
let inside = (2..6).contains(&x) && (2..6).contains(&y);
|
||||
let want = if inside { WHITE } else { BLACK };
|
||||
assert_eq!(at(x, y), rgba8(want), "{name}: size 4: ({x}, {y})");
|
||||
}
|
||||
}
|
||||
}
|
||||
let before = counters.metrics();
|
||||
let at = pixels(
|
||||
"point class",
|
||||
&|encoder: &mut crate::RenderCommandEncoder| {
|
||||
draw(encoder.set_render_pipeline_state(&classed));
|
||||
draw(encoder.set_vertex_buffer(Some(&positions), 0, 0));
|
||||
draw(encoder.set_vertex_buffer(Some(&colors), 0, 1));
|
||||
draw(encoder.draw_primitives(PrimitiveType::Point, 0, 3, 1, 0));
|
||||
},
|
||||
);
|
||||
let after = counters.metrics();
|
||||
assert_eq!(
|
||||
(
|
||||
after.pipelines_created - before.pipelines_created,
|
||||
after.first_use_waits - before.first_use_waits,
|
||||
),
|
||||
(0, 0),
|
||||
"{name}: the point class's first draw of points: pipelines made, first-use waits"
|
||||
);
|
||||
for y in 0..SIDE {
|
||||
for x in 0..SIDE {
|
||||
let want = if marks.contains(&(x, y)) {
|
||||
GREEN
|
||||
} else {
|
||||
BLACK
|
||||
};
|
||||
assert_eq!(at(x, y), rgba8(want), "{name}: size 1: ({x}, {y})");
|
||||
}
|
||||
}
|
||||
let at = pixels("no class", &|encoder: &mut crate::RenderCommandEncoder| {
|
||||
draw(encoder.set_render_pipeline_state(&plain));
|
||||
draw(encoder.set_vertex_buffer(Some(&positions), 0, 0));
|
||||
draw(encoder.set_vertex_buffer(Some(&colors), 0, 1));
|
||||
draw(encoder.draw_primitives(PrimitiveType::Point, 0, 3, 1, 0));
|
||||
draw(encoder.draw_primitives(PrimitiveType::Triangle, 3, 3, 1, 0));
|
||||
});
|
||||
for y in 0..SIDE {
|
||||
for x in 0..SIDE {
|
||||
let want = if y >= 4 { WHITE } else { BLACK };
|
||||
assert_eq!(at(x, y), rgba8(want), "{name}: no class: ({x}, {y})");
|
||||
}
|
||||
}
|
||||
println!("{name}: points at size 4, at 1 under the point class, none under no class");
|
||||
});
|
||||
}
|
||||
|
||||
/// A stencil state that replaces marks the top half; one that tests keeps a later draw there.
|
||||
#[test]
|
||||
fn every_device_marks_and_tests_the_stencil() {
|
||||
@@ -1340,8 +1493,10 @@ pub(crate) mod on_device {
|
||||
/// A vertex function stores to device memory (the owned fixture `engine/rvc_draw_bases.ll`'s
|
||||
/// `draw_bases_in_a_vertex_function`, its state's rasterization disabled): vertex `vid` of
|
||||
/// instance `iid` writes `vid`, `iid` and the draw's base vertex and base instance to the
|
||||
/// four words of slot `(iid % 4) * 8 + vid % 8`, and no other slot is written. A device
|
||||
/// without `vertexPipelineStoresAndAtomics` is below the floor, so every device makes the state.
|
||||
/// four words of slot `(iid % 4) * 8 + vid % 8`, and no other slot is written, in a draw of
|
||||
/// triangles and in a draw of points, which Metal does not rasterize for a function without
|
||||
/// `[[point_size]]` under no class and runs all the same. A device without
|
||||
/// `vertexPipelineStoresAndAtomics` is below the floor, so every device makes the state.
|
||||
#[test]
|
||||
fn every_device_runs_a_vertex_function_that_stores() {
|
||||
let Some(engine) = library(&engine_dir().join("rvc_draw_bases.ll")) else {
|
||||
@@ -1357,36 +1512,39 @@ pub(crate) mod on_device {
|
||||
each_device("draw_vertex_stores", |name, _, device| {
|
||||
let state = state(name, &device, &d);
|
||||
let mut buffers = Buffers::new(&device);
|
||||
let out = buffers.of(&device, &[0u8; 32 * 16]);
|
||||
let color = target(
|
||||
&device,
|
||||
PixelFormat::RGBA8Unorm,
|
||||
TextureUsage::RENDER_TARGET,
|
||||
);
|
||||
let queue = device.new_command_queue(4).expect("a queue");
|
||||
let command_buffer = queue.command_buffer().expect("a command buffer");
|
||||
let mut encoder = (command_buffer.render_command_encoder(&pass(&color, None)))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let draw = |result: Result<(), Error>| result.unwrap_or_else(|e| panic!("{name}: {e}"));
|
||||
draw(encoder.set_render_pipeline_state(&state));
|
||||
draw(encoder.set_vertex_buffer(Some(&out), 0, 0));
|
||||
draw(encoder.draw_primitives(PrimitiveType::Triangle, start, count, instances, base));
|
||||
encoder.end_encoding();
|
||||
run(name, &command_buffer);
|
||||
let contents = out.contents().expect("a Shared buffer");
|
||||
// SAFETY: the buffer holds 32 slots of four words, which the finished draw wrote and
|
||||
// whose writes reach the host.
|
||||
let words =
|
||||
unsafe { std::slice::from_raw_parts(contents.as_ptr().cast::<u32>(), 32 * 4) };
|
||||
let mut want = [0u32; 32 * 4];
|
||||
for iid in base..base + instances {
|
||||
for vid in start..start + count {
|
||||
let slot = ((iid % 4) * 8 + vid % 8) as usize;
|
||||
want[slot * 4..slot * 4 + 4].copy_from_slice(&[vid, iid, start, base]);
|
||||
for primitive in [PrimitiveType::Triangle, PrimitiveType::Point] {
|
||||
let out = buffers.of(&device, &[0u8; 32 * 16]);
|
||||
let command_buffer = queue.command_buffer().expect("a command buffer");
|
||||
let mut encoder = (command_buffer.render_command_encoder(&pass(&color, None)))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let draw =
|
||||
|result: Result<(), Error>| result.unwrap_or_else(|e| panic!("{name}: {e}"));
|
||||
draw(encoder.set_render_pipeline_state(&state));
|
||||
draw(encoder.set_vertex_buffer(Some(&out), 0, 0));
|
||||
draw(encoder.draw_primitives(primitive, start, count, instances, base));
|
||||
encoder.end_encoding();
|
||||
run(name, &command_buffer);
|
||||
let contents = out.contents().expect("a Shared buffer");
|
||||
// SAFETY: the buffer holds 32 slots of four words, which the finished draw wrote
|
||||
// and whose writes reach the host.
|
||||
let words =
|
||||
unsafe { std::slice::from_raw_parts(contents.as_ptr().cast::<u32>(), 32 * 4) };
|
||||
let mut want = [0u32; 32 * 4];
|
||||
for iid in base..base + instances {
|
||||
for vid in start..start + count {
|
||||
let slot = ((iid % 4) * 8 + vid % 8) as usize;
|
||||
want[slot * 4..slot * 4 + 4].copy_from_slice(&[vid, iid, start, base]);
|
||||
}
|
||||
}
|
||||
assert_eq!(words, want, "{name}: {primitive:?}: the slots");
|
||||
}
|
||||
assert_eq!(words, want, "{name}: the slots");
|
||||
println!("{name}: a vertex function's stores reached its buffer");
|
||||
println!("{name}: a vertex function's stores reached its buffer, triangles and points");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2483,11 +2641,6 @@ define internal void @_GLOBAL__sub_I_() section "air.static_init" {
|
||||
"another format",
|
||||
);
|
||||
encoder.set_render_pipeline_state(&state).expect("a state");
|
||||
same(
|
||||
encoder.draw_primitives(PrimitiveType::Point, 0, 3, 1, 0),
|
||||
gap(DrawKind::Points),
|
||||
"points",
|
||||
);
|
||||
let viewport = Viewport {
|
||||
origin_x: 0.0,
|
||||
origin_y: 0.0,
|
||||
@@ -2792,7 +2945,7 @@ define internal void @_GLOBAL__sub_I_() section "air.static_init" {
|
||||
) else {
|
||||
return;
|
||||
};
|
||||
let function = |library: &Library, name| {
|
||||
let function = |library: &Library, name: &str| {
|
||||
StageSource::Function(FunctionDescriptor::new(
|
||||
library.function(name).expect("the function"),
|
||||
))
|
||||
|
||||
@@ -10,6 +10,7 @@ fn each_first_use_wait_adds_to_its_site_and_the_total() {
|
||||
counters.first_use_wait(FirstUse::Variant, 3_000);
|
||||
counters.first_use_wait(FirstUse::Variant, 7_000);
|
||||
counters.first_use_wait(FirstUse::Lines, 11_000);
|
||||
counters.first_use_wait(FirstUse::Points, 5_000);
|
||||
let m = counters.metrics();
|
||||
assert_eq!(
|
||||
(
|
||||
@@ -27,12 +28,20 @@ fn each_first_use_wait_adds_to_its_site_and_the_total() {
|
||||
),
|
||||
(1, 11_000, 11_000)
|
||||
);
|
||||
assert_eq!(
|
||||
(
|
||||
m.first_use_point_waits,
|
||||
m.first_use_point_wait_nanos,
|
||||
m.first_use_point_wait_max_nanos
|
||||
),
|
||||
(1, 5_000, 5_000)
|
||||
);
|
||||
assert_eq!(
|
||||
(
|
||||
m.first_use_waits,
|
||||
m.first_use_wait_nanos,
|
||||
m.first_use_wait_max_nanos
|
||||
),
|
||||
(3, 21_000, 11_000)
|
||||
(4, 26_000, 11_000)
|
||||
);
|
||||
}
|
||||
@@ -65,6 +65,7 @@ fn at_the_floor() -> Queried {
|
||||
features.core.full_draw_index_uint32 = vk::TRUE;
|
||||
features.core.shader_clip_distance = vk::TRUE;
|
||||
features.core.shader_tessellation_and_geometry_point_size = vk::TRUE;
|
||||
features.core.large_points = vk::TRUE;
|
||||
features.core.shader_int16 = vk::TRUE;
|
||||
features.vulkan12.shader_int8 = vk::TRUE;
|
||||
features.vulkan11.storage_buffer16_bit_access = vk::TRUE;
|
||||
@@ -359,7 +360,7 @@ fn each_missing_feature_is_named() {
|
||||
const CORE: &str = "VkPhysicalDeviceFeatures";
|
||||
const ROBUSTNESS2: &str = "VkPhysicalDeviceRobustness2FeaturesEXT";
|
||||
type Clear = fn(&mut Features);
|
||||
let cases: [(Clear, Missing); 50] = [
|
||||
let cases: [(Clear, Missing); 51] = [
|
||||
(
|
||||
|f| f.vulkan12.buffer_device_address = vk::FALSE,
|
||||
feature(V12, "bufferDeviceAddress"),
|
||||
@@ -563,6 +564,10 @@ fn each_missing_feature_is_named() {
|
||||
|f| f.core.shader_tessellation_and_geometry_point_size = vk::FALSE,
|
||||
feature(CORE, "shaderTessellationAndGeometryPointSize"),
|
||||
),
|
||||
(
|
||||
|f| f.core.large_points = vk::FALSE,
|
||||
feature(CORE, "largePoints"),
|
||||
),
|
||||
];
|
||||
assert_eq!(
|
||||
cases.len(),
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
//! - A draw of a render pipeline state, its vertices in buffers bound to the vertex stage, covers
|
||||
//! a pass's target that its setter records clear to red: a blit copies the target to a buffer,
|
||||
//! which the stream checks green, and nothing is skipped.
|
||||
//! - A draw of points after it, which the runtime does not build, is skipped and counted, and the
|
||||
//! report says the play is no verdict past it: its gap, frame and call.
|
||||
//! - A draw of points after it plays, nothing skipped.
|
||||
//! - `setLineWidth:` plays: at width 1 a draw of lines after it plays; at width 2 a draw of
|
||||
//! triangles plays and one of lines is the runtime's gap, skipped and counted.
|
||||
//! triangles plays and one of lines is the runtime's gap, skipped and counted, and the report
|
||||
//! says the play is no verdict past it: its gap, frame and call.
|
||||
//! - A compute pipeline state the runtime answers with a typed gap is skipped and counted by the
|
||||
//! gap, and a dispatch of it is skipped, and the play goes on.
|
||||
//! - A compute encoder's `setStageInRegion:` plays: the runtime takes it.
|
||||
@@ -442,24 +442,24 @@ fn a_draw_into_a_pass_plays_on_the_new_runtime() {
|
||||
assert_eq!(report.first_skip, None);
|
||||
}
|
||||
|
||||
/// A draw of points after the triangle (call 19) plays, nothing skipped, the target still green.
|
||||
#[test]
|
||||
fn a_draw_the_runtime_does_not_build_is_skipped_and_ends_the_verdict() {
|
||||
fn a_draw_of_points_plays_on_the_new_runtime() {
|
||||
let dir = ScratchDir::new("rt-replay-points").unwrap();
|
||||
let green: Vec<u8> = [0u8, 255, 0, 255].repeat(16);
|
||||
let path = draw_into_a_pass(&dir, &green, Then::Points);
|
||||
let (report, lines) = play("points", &path);
|
||||
let (report, _) = play("points", &path);
|
||||
assert_eq!(Some(report.checks[0].sha256), report.checks[0].recorded);
|
||||
let executed = &report.total.executed;
|
||||
assert_eq!(executed["skipped_render_commands"], 1, "{executed:?}");
|
||||
assert_eq!(report.first_skip, Some((0, 19)));
|
||||
let note = report.verdict_note();
|
||||
assert_eq!(note.as_deref(), Some("not a verdict past frame 0, call 19"));
|
||||
let line = "skipped render commands Draw { kind: Points } 1, the first at frame 0, call 19";
|
||||
assert!(lines.iter().any(|l| l == line), "{lines:?}");
|
||||
for skipped in ["skipped_render_commands", "skipped_draws", "skipped_calls"] {
|
||||
assert_eq!(executed[skipped], 0, "{skipped}: {executed:?}");
|
||||
}
|
||||
assert_eq!(report.first_skip, None);
|
||||
}
|
||||
|
||||
/// `setLineWidth:` plays: at width 1 the triangle and the line after it play, nothing skipped; at
|
||||
/// width 2 the triangle draws and the line is the runtime's gap, skipped and counted.
|
||||
/// width 2 the triangle draws and the line is the runtime's gap, skipped and counted, and the
|
||||
/// report says the play is no verdict past it.
|
||||
#[test]
|
||||
fn a_line_width_plays_and_a_line_drawn_at_another_width_is_skipped() {
|
||||
let green: Vec<u8> = [0u8, 255, 0, 255].repeat(16);
|
||||
@@ -483,6 +483,8 @@ fn a_line_width_plays_and_a_line_drawn_at_another_width_is_skipped() {
|
||||
let executed = &report.total.executed;
|
||||
assert_eq!(executed["skipped_render_commands"], 1, "{executed:?}");
|
||||
assert_eq!(report.first_skip, Some((0, 21)));
|
||||
let note = report.verdict_note();
|
||||
assert_eq!(note.as_deref(), Some("not a verdict past frame 0, call 21"));
|
||||
let line = "skipped render commands Draw { kind: LineWidth } 1, the first at frame 0, call 21";
|
||||
assert!(lines.iter().any(|l| l == line), "{lines:?}");
|
||||
}
|
||||
|
||||
@@ -2214,6 +2214,9 @@ field metal2vulkan-runtime::Metrics.external_releases pub external_releases: u64
|
||||
field metal2vulkan-runtime::Metrics.first_use_line_wait_max_nanos pub first_use_line_wait_max_nanos: u64
|
||||
field metal2vulkan-runtime::Metrics.first_use_line_wait_nanos pub first_use_line_wait_nanos: u64
|
||||
field metal2vulkan-runtime::Metrics.first_use_line_waits pub first_use_line_waits: u64
|
||||
field metal2vulkan-runtime::Metrics.first_use_point_wait_max_nanos pub first_use_point_wait_max_nanos: u64
|
||||
field metal2vulkan-runtime::Metrics.first_use_point_wait_nanos pub first_use_point_wait_nanos: u64
|
||||
field metal2vulkan-runtime::Metrics.first_use_point_waits pub first_use_point_waits: u64
|
||||
field metal2vulkan-runtime::Metrics.first_use_variant_wait_max_nanos pub first_use_variant_wait_max_nanos: u64
|
||||
field metal2vulkan-runtime::Metrics.first_use_variant_wait_nanos pub first_use_variant_wait_nanos: u64
|
||||
field metal2vulkan-runtime::Metrics.first_use_variant_waits pub first_use_variant_waits: u64
|
||||
@@ -10422,7 +10425,6 @@ variant metal2vulkan-runtime::DrawKind::FetchedAttachment FetchedAttachment
|
||||
variant metal2vulkan-runtime::DrawKind::FillMode FillMode
|
||||
variant metal2vulkan-runtime::DrawKind::LineWidth LineWidth
|
||||
variant metal2vulkan-runtime::DrawKind::PatchIndexBuffer PatchIndexBuffer
|
||||
variant metal2vulkan-runtime::DrawKind::Points Points
|
||||
variant metal2vulkan-runtime::DrawKind::Viewport Viewport
|
||||
variant metal2vulkan-runtime::DrawKind::Viewports Viewports
|
||||
variant metal2vulkan-runtime::DrawKind::VisibilityResults VisibilityResults
|
||||
|
||||
|
Can't render this file because it is too large.
|
+2
-2
@@ -389,7 +389,7 @@ Columns:
|
||||
| `BicubicTexels` | A dispatch whose kernel samples texture slot `slot` through a constexpr sampler with Metal's bicubic filter (`filter::bicubic`), where the texture... | every device (a public call's own check of its arguments) | `ours`: each refused format's treatment is built when a guest binds one | 1: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch)` | `-` |
|
||||
| `TextureView` | `Texture::new_texture_view` of a kind Metal makes and the runtime does not build | every device (a public call's own check of its arguments) | `ours`: the replay streams' views that compute binds are same-format views of every slice, 2D views of one slice of a 2D array, and level subranges, swizzled or not; each other kind is built when a replay stream binds one | 1: `crates/metal2vulkan-runtime/src/texture.rs (view)` | `-` |
|
||||
| `RenderPass` | A render pass of something the runtime does not build yet (`CommandBuffer::render_command_encoder`) | every device (a public call's own check of its arguments) | `ours`: the replay streams' passes render into one to two color attachments and a stencil or a depth attachment, each a level of a 2D texture of one sample, with no resolve and a clear depth of 1, none naming two textures for its depth and stencil; each other kind is built when a replay stream makes one; `DepthStencilViews` and `ClearDepth` are what Vulkan's rendering under the floor takes no form of | 5: `crates/metal2vulkan-runtime/src/pass.rs (check)`, `crates/metal2vulkan-runtime/src/pass.rs (ops)` (+3) | `-` |
|
||||
| `Draw` | A draw or render encoder state the runtime does not build yet (`RenderCommandEncoder`) | every device (a public call's own check of its arguments) | `ours`: the replay streams draw lines and triangles through one viewport Vulkan's is, with pipeline states of their pass's formats, under depth biases with no clamp, filled and clipped; each other kind is built when a replay stream draws one), and device for [`DrawKind::DividedBaseInstance`] (a device that does not report `supportsNonZeroFirstInstance` | 13: `crates/metal2vulkan-runtime/src/render_encoder.rs (attachment_reads, 2 sites)`, `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)` (+10) | `-` |
|
||||
| `Draw` | A draw or render encoder state the runtime does not build yet (`RenderCommandEncoder`) | every device (a public call's own check of its arguments) | `ours`: the replay streams draw lines and triangles through one viewport Vulkan's is, with pipeline states of their pass's formats, under depth biases with no clamp, filled and clipped; each other kind is built when a replay stream draws one), and device for [`DrawKind::DividedBaseInstance`] (a device that does not report `supportsNonZeroFirstInstance` | 12: `crates/metal2vulkan-runtime/src/render_encoder.rs (attachment_reads, 2 sites)`, `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)` (+9) | `-` |
|
||||
| `LinearPlanePass` | A render pass over a surface plane that renders as a linear colour attachment alone, in a shape the device does not render... | at the device's limit | `device`: VK_NV_linear_color_attachment renders such a format as a colour attachment only "as long as all the color attachments in the render pass instance have VK_IMAGE_TILING_LINEAR tiling"; the RTX 3090's driver lost the device rendering a linear colour attachment beside a depth or stencil attachment | 1: `crates/metal2vulkan-runtime/src/pass.rs (check)` | `-` |
|
||||
|
||||
## Appendix: every site
|
||||
@@ -675,6 +675,6 @@ Each refusal's sites, with the function that builds it.
|
||||
- `rt:Gap::BicubicTexels`: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch)`
|
||||
- `rt:Gap::TextureView`: `crates/metal2vulkan-runtime/src/texture.rs (view)`
|
||||
- `rt:Gap::RenderPass`: `crates/metal2vulkan-runtime/src/pass.rs (check)`; `crates/metal2vulkan-runtime/src/pass.rs (ops)`; `crates/metal2vulkan-runtime/src/pass.rs (resolve)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (later_store)`; `crates/metal2vulkan-runtime/src/texture.rs (attachment)`
|
||||
- `rt:Gap::Draw`: `crates/metal2vulkan-runtime/src/render_encoder.rs (attachment_reads, 2 sites)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw_patches)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (primitives)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_depth_bias)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_depth_clip_mode)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_scissor_rects)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_triangle_fill_mode)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_viewport)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_viewports)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_visibility_result_mode)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (shadow_copies)`
|
||||
- `rt:Gap::Draw`: `crates/metal2vulkan-runtime/src/render_encoder.rs (attachment_reads, 2 sites)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw_patches)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_depth_bias)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_depth_clip_mode)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_scissor_rects)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_triangle_fill_mode)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_viewport)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_viewports)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_visibility_result_mode)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (shadow_copies)`
|
||||
- `rt:Gap::LinearPlanePass`: `crates/metal2vulkan-runtime/src/pass.rs (check)`
|
||||
|
||||
Reference in new issue
Block a user