Link: the synthesized geometry stage goes, both forms (the barycentric weights and the rate map's fan-out)
The translator built geometry stages in two forms that no Metal function asks for: - the barycentric weights: a fragment function's [[barycentric_coord]] read as varyings, which a generated geometry stage of each topology class wrote, on a device without fragmentShaderBarycentric; - the rate map's fan-out: a draw of a rasterization-rate-mapped pass's triangles once, a geometry stage emitting a copy of each per region, with its probe and its region-copy vertex variant. Neither form reached a guest. The runtime enables no geometryShader, so it refused the weights form already. It never sets BindShape::region_fan_out, and draws a rate-mapped pass region by region (the regions route, RateMapRegions, and region_viewports, which stay). Validation never set region_fan_out either. After this change, one form is left for each: - A fragment function that reads [[barycentric_coord]] reads the device's own BaryCoordKHR/BaryCoordNoPerspKHR. Without fragmentShaderBarycentric it is refused as Unsupported(Barycentrics) needing that feature alone; geometryShader is no longer offered. - A rate-mapped pass draws through the regions route. Rule 1: no precision note stops being raised. The fan-out's copies were a near-equivalent of the regions route, which carries its own note (RateMapRegions::precision), and the weights form raised none. The catalogue is unchanged. Removed: - pipeline::link::geometry (GeometryStages, the three classes' stages) and pipeline::link::fan_out, with their tests (link/tests/geometry.rs, link/tests/fan_out.rs) and tests/engine_region_fan_out; - bind::fan_out (the region table, the probe's word layout and its constants); - RegionFanOut and FanOutState; - the region_fan_out fields of GraphicsState, BindState, BindShape, VariantKey and RenderLinkInputs, and LoweringInputs::region_copies; - the region copy's lowering: StageIoPlan::region_copy, RegionCopy and the region table's declaration; - PushField::RegionBox and RegionProbe; - SyntheticBinding::RateMapRegions and RateMapFlags, and WriteSource::RateMapRegions and RateMapFlags; - RuntimeFact::SynthesizedGeometry, RenderPipeline::runs_stage and Linked::geometry; - IoRole::Barycentric with VaryingKey::barycentric and its key tag; - VkProperty::SubgroupGeometryStage; - the SPIR-V IR's geometry execution model, which only these stages produced: ExecModel::Geometry, OpEmitVertex and OpEndPrimitive, the InputPoints, InputLines, OutputLineStrip, OutputTriangleStrip and Invocations modes, ModelNeed::Geometry, EntryRule::GeometryModes and the builder's geometry ops; - from scripts/regen-spirv-grammar/items.txt, the opcodes EmitVertex and EndPrimitive, the execution model Geometry and those five execution modes. spv.rs is regenerated: the opcodes and the model stay as test-only values, which the test parser reads, and the modes go; - in validation, the census's geometry stage filter, the draw's runs_stage filter and the candidate's GEOMETRY stage arm. The census test that read three geometry stages from engine/bary_weights goes with them. The SPIR-V builder now marks only Position Invariant; ClipDistance was the fan-out's. band::plan loses its geometry flag, and takes the four SPIR-V helpers it shared with the geometry module. The binder's stage map takes a geometry stage as no render stage. Validation cases that executed either form: none. - Fan-out: no validation code sets region_fan_out. - Weights: two authored cases read [[barycentric_coord]], fa8b920d3cf3 and ae0a7e39b12f. Neither has a stored Vulkan observation on a profile without fragmentShaderBarycentric. fa8b920d3cf3 is observed on Metal and MoltenVK, and moltenvk-m3 has the feature. ae0a7e39b12f is observed on Metal only. Fourth user of GeometryStages: none. It was used by link, the compile API's splice, the binder's selection (through RuntimeFact::SynthesizedGeometry and GraphicsState::region_fan_out) and its own tests. Tests: - engine_stage_io_tail's weights test is now without_the_feature_the_weights_are_refused: on lavapipe, ANV's Iris Xe, NVIDIA's Pascal (each with geometryShader) and runtime-floor (without it), both barycentric entries are refused needing fragmentShaderBarycentric. - engine_target_indices checks each pipeline's stages valid where it counted geometry stages, and loses the_weights_stage_beside_a_vertex_layer_is_not_implemented: that combination is now the plain refusal above. - engine_amplification no longer counts geometry stages. - The binder's render stage test refuses a geometry stage. - The builder's invariant test refuses ClipDistance. - engine_rotated_weights' rotated draw runs on moltenvk-m3 and RDNA3's RADV, each with fragmentShaderBarycentric, where it ran on lavapipe through the weights form. - The fact mechanism test numbers its 100 RuntimeFact variants densely again (PrivateArena, which development added, takes 99). Bless due until the next named pin, where the M3 bless job takes them; nothing is blessed here: - tests::public_fixtures_engine (the inventory): every [[barycentric_coord]] cell on a profile without fragmentShaderBarycentric becomes Unsupported(Barycentrics) needing it alone, where it compiled through the geometry stages (with geometryShader) or offered GeometryShader as the alternative; - tests::golden_hashes, and pipeline::compile::tests::the_old_render_descriptor_key_keeps_its_value (the render key), as under the commit below: the profiles' fingerprints change; - the authored compile census. SEMANTICS_VERSION 2247 -> 2248 and ARTIFACT_FORMAT_VERSION 583 -> 584 are placeholders that main renumbers. SEMANTICS: a fragment function's weights and every rate-mapped variant change form. ARTIFACT: the codec loses the RegionFanOut, FanOutState, GraphicsState::region_fan_out, IoRole::Barycentric, RuntimeFact::SynthesizedGeometry, PushField, SyntheticBinding and VkProperty tags. RUNTIME_VERSION stays: the runtime's render-pipeline kind no longer reads region_fan_out, which it never set, and its SynthesizedStages doc names the bands alone. runtime-sources.sha256 keeps development's (land-pkt re-pins it), api_signatures and api_surface drop the removed items, and docs/REFUSALS.md is regenerated. API.md drops the geometry stages from RenderPipeline's stages, its barycentric bullet and its band bullet. ARCHITECTURE.md's link line drops pipeline::link::geometry, and the runtime README's Barycentrics gap names the feature alone. Consumer check (consumer_check.sh, consumer development b76d6ac4a9): region_fan_out, RegionFanOut, FanOutState, region_copies, region_copy, RateMapFlags, RegionBox, RegionProbe, SynthesizedGeometry, FEW_COPIES, PROBE_DRAW_WORDS, RegionCopies and runs_stage have 0 hits. GeometryStages appears in crates/reims-vgpu-c/link-order.txt only. fan_out's hits are the consumer's own event fan-out in crates/reims-vgpu/src/graphics/decode/cmdbuf.rs, not this module. Verified (jobs read): - m3-max-61801: the suites at this change's work in progress (4f1f934423); its real reds were the mechanism numbering and the rotated weights on amd-rdna3-radv, both fixed here; the render key reads bless-due. - At the stack's tip over this change (dvl-5 1fa4aed963 and dvl-6 92fe40c38f): 61978 and 61987, fmt, clippy in every configuration, Rustdoc, each feature alone, the API docs and the Windows clippy, green; 61891, the suites at dvl-4: 13 failures, each a bless-due golden above or development's own (the raster state test, the inventory's sample_fill rows); 61968, the lavapipe device suite of metal2vulkan-validation, 1483 of 1483, and public case qualification Match; 62042, the metal2vulkan-validation suite at dvl-5, 1378 of 1378 passed. - States-only play of this change's player (p-gd.zst) over 35 distinct streams on gem10 (61919), um870 (61924), ms01 (61967) and um790 (62004): 456,384 render and 91,972 compute states made, 0 refused, every stream exit 0. The msi stream (windrag-780m-b2) is not played: msi had no memory free. Rebased onto development4cf936ed4d(selidx landed as3ecf606aa8). The conflicts: the version lines; the mechanism test, where development added RuntimeFact::PrivateArena; runtime-sources.sha256, where development's is kept; and api_signatures.tsv and docs/REFUSALS.md, both regenerated (signatures.py --bless, refusal_surface.py) and differing from development by this change's items alone. The jobs above ran at the old base; the rebased tip's are in the report to main.
This commit is contained in:
1 parent
fa70528de2
commit
57855c6097
72 files changed
+200
-4247
No files matched your search
@@ -2907,8 +2907,7 @@ or does not check is rebuilt from the generations' names, with young counted ful
|
||||
Xe, lavapipe and KosmicKrisp on the M3 Max report it (m3-max-48727 to 48731, 48737 and 61508).
|
||||
- On a device without `fragmentShaderBarycentric` (Barycentrics, under Floor), a fragment function
|
||||
that reads `[[barycentric_coord]]` is refused at creation, an `Error::Translation` naming
|
||||
`Barycentrics`: the translator's other form, weights a generated geometry stage writes, needs
|
||||
`geometryShader`, which device creation does not enable. Of the venues run, lavapipe, ANV on the
|
||||
`Barycentrics` and `fragmentShaderBarycentric`. Of the venues run, lavapipe, ANV on the
|
||||
Iris Xe, RADV on the RX 550, the UHD 630's Windows driver and KosmicKrisp on the M3 Max list no
|
||||
`VK_KHR_fragment_shader_barycentric` (`vulkaninfo`, jobs m3-max-61287, 61291, 61292 and 61296);
|
||||
NVIDIA's driver on the RTX 3090, RTX 2080 and RTX 5080 Laptop, and RADV on the RX 7900 XTX and
|
||||
|
||||
@@ -1354,8 +1354,8 @@ pub enum RenderPipelineKind {
|
||||
/// (`tessellationControlPointIndexType`) itself. A descriptor's tessellation state with a vertex
|
||||
/// function that is not post-tessellation is ignored, as Metal ignores it.
|
||||
Tessellation,
|
||||
/// Stages the translator synthesizes beside the functions' but a tessellation's: geometry
|
||||
/// stages, lines drawn as bands of triangles, or a rate map's fan-out.
|
||||
/// Stages the translator synthesizes beside the functions' but a tessellation's: lines drawn as
|
||||
/// bands of triangles.
|
||||
SynthesizedStages,
|
||||
/// A fragment function that reaches the render pass's imageblock.
|
||||
Imageblock,
|
||||
|
||||
@@ -760,7 +760,6 @@ fn unbuilt(pipeline: &RenderPipeline, enabled: &EnabledCaps) -> Option<RenderPip
|
||||
None => &[ShaderStage::VERTEX, ShaderStage::FRAGMENT],
|
||||
};
|
||||
let synthesized = g.line_band.is_some()
|
||||
|| g.region_fan_out.is_some()
|
||||
|| (pipeline.stages.iter()).any(|stage| !stages.contains(&stage.stage));
|
||||
let unenabled = !(requirements.features).is_subset(&enabled.features)
|
||||
|| !(requirements.extensions).is_subset(&enabled.extensions);
|
||||
|
||||
@@ -78,7 +78,6 @@ const GRAPHICS_STATE: &[(&str, Verdict)] = &[
|
||||
("storage_attachments", Refused(SET_0)),
|
||||
("shadow_stencil", Applied),
|
||||
("line_band", Applied),
|
||||
("region_fan_out", Applied),
|
||||
("writes_point_size", Applied),
|
||||
(
|
||||
"writes_depth",
|
||||
|
||||
@@ -1558,8 +1558,7 @@ pub fn select_target(
|
||||
/// The Metal stage whose function `module` runs in a render pipeline that is `tessellated` or
|
||||
/// not, `None` for a stage the link synthesized: a tessellation pipeline's Metal stages are its
|
||||
/// evaluation stage (the vertex function) and its fragment stage, and its vertex and control
|
||||
/// stages run no Metal function, nor do the geometry stages of barycentric weights read as
|
||||
/// varyings.
|
||||
/// stages run no Metal function.
|
||||
pub fn stage_of(
|
||||
module: &StageModule,
|
||||
tessellated: bool,
|
||||
@@ -1571,7 +1570,6 @@ pub fn stage_of(
|
||||
Ok(Some(ShaderStage::Vertex))
|
||||
}
|
||||
s if tessellated && (s == S::VERTEX || s == S::TESSELLATION_CONTROL) => Ok(None),
|
||||
s if s == S::GEOMETRY => Ok(None),
|
||||
other => Err(format!("a render pipeline stage {other:?}").into()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -516,18 +516,13 @@ pub(super) fn create_graphics_pipeline(
|
||||
.collect();
|
||||
let mut stages = Vec::with_capacity(pipeline.stages.len());
|
||||
let topology = metal2vulkan::vk::PrimitiveTopology::from_raw(consumer.topology.as_raw());
|
||||
// Of a pipeline's barycentric geometry stages, only the draw's class's runs.
|
||||
for (at, (((stage, module), (entry, spec)), subgroup)) in pipeline
|
||||
for (((stage, module), (entry, spec)), subgroup) in pipeline
|
||||
.stages
|
||||
.iter()
|
||||
.zip(consumer.modules)
|
||||
.zip(entries.iter().zip(&spec_infos))
|
||||
.zip(subgroups.iter_mut())
|
||||
.enumerate()
|
||||
{
|
||||
if !pipeline.runs_stage(at, topology) {
|
||||
continue;
|
||||
}
|
||||
let mut info = vk::PipelineShaderStageCreateInfo::default()
|
||||
.stage(stage.stage.into())
|
||||
.module(*module)
|
||||
|
||||
@@ -309,10 +309,7 @@ impl ModuleCensus {
|
||||
/// The census of each module of a linked pipeline's `modules` (in pipeline order) that runs
|
||||
/// a Metal function, compiled for `profile`. A tessellation pipeline's synthesized vertex and
|
||||
/// control stages run none and are left out: the pipeline is tessellated exactly when it has an
|
||||
/// evaluation stage. So are a render pipeline's geometry stages: Metal has no geometry
|
||||
/// function, so every one is a stage link synthesizes between the vertex and fragment
|
||||
/// functions (`metal2vulkan::pipeline::link::geometry`: the barycentric weights). `Err` names
|
||||
/// a module of a stage no Metal function has.
|
||||
/// evaluation stage. `Err` names a module of a stage no Metal function has.
|
||||
pub fn of_pipeline_modules(
|
||||
modules: &[StageModule],
|
||||
profile: &DeviceProfile,
|
||||
@@ -332,7 +329,6 @@ impl ModuleCensus {
|
||||
.any(|m| m.stage == vk::ShaderStage::TESSELLATION_EVALUATION);
|
||||
modules
|
||||
.iter()
|
||||
.filter(|m| m.stage != vk::ShaderStage::GEOMETRY)
|
||||
.filter(|m| {
|
||||
!tessellated
|
||||
|| (m.stage != vk::ShaderStage::VERTEX
|
||||
|
||||
@@ -238,79 +238,6 @@ fn a_tessellation_pipeline_census_is_its_functions() {
|
||||
assert!(error.contains("TESSELLATION_CONTROL"), "{error}");
|
||||
}
|
||||
|
||||
/// A render pipeline's census leaves out its geometry stages, which run no Metal function: a
|
||||
/// fragment function that reads `[[barycentric_coord]]` (`engine/bary_weights`) reads the weights
|
||||
/// from the synthesized geometry stage of each topology class on a device without
|
||||
/// `fragmentShaderBarycentric` (the Radeon 780M's committed capture without it), so the
|
||||
/// pipeline's modules are its vertex function's, three geometry stages and its fragment
|
||||
/// function's, and its census is the two functions'.
|
||||
#[test]
|
||||
fn a_render_pipeline_census_leaves_out_its_geometry_stages() {
|
||||
use metal2vulkan::device::{Device, DevicePolicy};
|
||||
use metal2vulkan::library::Library;
|
||||
use metal2vulkan::metal::PixelFormat;
|
||||
use metal2vulkan::pipeline::{
|
||||
ColorAttachmentDescriptor, FunctionDescriptor, RenderPipelineDescriptor, StageSource,
|
||||
};
|
||||
use metal2vulkan::Budget;
|
||||
use metal2vulkan_devtools::{engine_dir, llvm_assemble, AssembleError};
|
||||
let bitcode = match llvm_assemble(&engine_dir().join("bary_weights.ll")) {
|
||||
Ok(bytes) => bytes,
|
||||
Err(AssembleError::Missing(why)) => {
|
||||
eprintln!("SKIPPED: {why}");
|
||||
return;
|
||||
}
|
||||
Err(AssembleError::Rejected(why)) => panic!("llvm-as rejected bary_weights.ll: {why}"),
|
||||
};
|
||||
let path = crate::engine::profiles_dir().join("amd-780m-radv.json");
|
||||
let text = std::fs::read_to_string(&path).unwrap();
|
||||
let mut description = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
assert!(description
|
||||
.features
|
||||
.remove(&VkFeature::FragmentShaderBarycentric));
|
||||
let device = Device::from_queries(description, DevicePolicy::default()).unwrap();
|
||||
let library = Library::from_air(&bitcode).unwrap();
|
||||
let stage = |name: &str| {
|
||||
StageSource::Function(FunctionDescriptor::new(library.function(name).unwrap()))
|
||||
};
|
||||
let mut d = RenderPipelineDescriptor::new(stage("bw_vertex"));
|
||||
d.fragment = Some(stage("bw_perspective"));
|
||||
d.color_attachments[0] = Some(ColorAttachmentDescriptor::new(PixelFormat::RGBA32Float));
|
||||
let pipeline = device
|
||||
.compile_render_pipeline(&d, &Budget::standard())
|
||||
.unwrap();
|
||||
let stages: Vec<vk::ShaderStage> = pipeline.stages.iter().map(|m| m.stage).collect();
|
||||
assert_eq!(
|
||||
stages,
|
||||
[
|
||||
vk::ShaderStage::VERTEX,
|
||||
vk::ShaderStage::GEOMETRY,
|
||||
vk::ShaderStage::GEOMETRY,
|
||||
vk::ShaderStage::GEOMETRY,
|
||||
vk::ShaderStage::FRAGMENT
|
||||
]
|
||||
);
|
||||
let profile = device.profile();
|
||||
let census = ModuleCensus::of_pipeline_modules(&pipeline.stages, profile).unwrap();
|
||||
assert_eq!(
|
||||
census,
|
||||
[
|
||||
ModuleCensus::of_stage_module_under(&pipeline.stages[0], profile, None).unwrap(),
|
||||
ModuleCensus::of_stage_module_under(&pipeline.stages[4], profile, None).unwrap()
|
||||
]
|
||||
);
|
||||
assert_eq!(
|
||||
census.iter().map(|m| m.stage).collect::<Vec<_>>(),
|
||||
[Stage::Vertex, Stage::Fragment]
|
||||
);
|
||||
for geometry in &pipeline.stages[1..4] {
|
||||
assert_eq!(
|
||||
ModuleCensus::of_stage_module_under(geometry, profile, None),
|
||||
None
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The tier table holds every committed profile as stated and, where it states a robustness
|
||||
/// feature, in its robustness-off leg: the stated leg compiles the robust
|
||||
/// encodings the profile states, the off leg the in-shader ones, on the same device class and
|
||||
|
||||
@@ -1,292 +0,0 @@
|
||||
//! The region table of a rate-mapped pass drawn by fan-out: each primitive once, its vertices
|
||||
//! shaded once, and a geometry stage that emits a copy of each triangle per region it touches
|
||||
//! (`pipeline::link::geometry`, the fan-out stage), where the regions route
|
||||
//! ([`RateMapRegions`](crate::bind::RateMapRegions)) records each draw once per region.
|
||||
//!
|
||||
//! A region of the plan is a viewport and a scissor: its line maps the guest's normalized device
|
||||
//! coordinates to physical pixels, and its scissor keeps its own pixels. The fan-out draw has one
|
||||
//! viewport over the whole target, so a copy of a triangle for a region carries both in clip
|
||||
//! space, per axis:
|
||||
//!
|
||||
//! - its position, `x' = a·x + b·w`, where the target's viewport `(X₀, W₀)` maps `x'` to the
|
||||
//! same window coordinate as the region's viewport `(X, W)` maps `x`: `a = W / W₀` and
|
||||
//! `b = (2X + W − 2X₀) / W₀ − 1` (Vulkan's viewport transform, `window = X + (ndc + 1)·W / 2`,
|
||||
//! whatever the sign of `W`);
|
||||
//! - two clip distances that hold the window coordinate within the scissor's pixels `[p₀, p₁)`:
|
||||
//! `(W/2)·x + (X + W/2 − p₀)·w` and `−(W/2)·x + (p₁ − X − W/2)·w`, the window coordinate times
|
||||
//! `w` less `p₀`, and `p₁` less it. Clipping keeps a fragment whose pixel centre lies inside, and
|
||||
//! a pixel centre lies half a pixel from every scissor edge, so each pixel the triangle covers is
|
||||
//! shaded by the one copy of its region.
|
||||
//!
|
||||
//! A copy's fragments are its region viewport's up to rounding: its window coordinates are the
|
||||
//! region viewport's computed another way, so a pixel centre that lies within a rounding error of
|
||||
//! a triangle's edge may be covered by the copy and not through the region's own viewport (a
|
||||
//! near-equivalent, rule 1's fast default; `RateMapRegionPolicy::Exact`, which draws every region
|
||||
//! through its own viewport, is the exact one).
|
||||
//!
|
||||
//! **One route per pass.** Where a pass fans its triangles out, the draws it records region by
|
||||
//! region take their region-copy variant (`RegionFanOut::RegionCopies`), a row of the table's
|
||||
//! regions a recording: the row its recording pushes (`PushField::RegionBox`), its first region's
|
||||
//! segments `x0` and `y0`, and its draw's `DrawIndex` `d` among a multi-draw's or an indirect
|
||||
//! draw's (0 for a draw that is neither's) pick the segments `(x0 + d, y0)`, the row's regions in
|
||||
//! order, and the
|
||||
//! vertex function puts each vertex in that region by the emitter of the fan-out stage's copies
|
||||
//! (`pipeline::link::fan_out::region_copy`), storing 0 as `ViewportIndex`, the recording's one
|
||||
//! viewport. The recording sets that viewport, the target's, and its row's scissor, the union of
|
||||
//! its regions' ([`scissors`]), so a row's recording and a recording of each of its regions alone
|
||||
//! run the same pipeline and differ only in their dynamic viewport and scissor and in the integer
|
||||
//! region each draw selects (Vulkan's Invariance, Rule 4, and Rule 2: "Scissor parameters (other
|
||||
//! than enable)" have no side effects): the clip distances keep each copy to its region's pixels,
|
||||
//! as a fanned-out copy's are kept, and the scissor rejects what lies outside the row. A border
|
||||
//! between two of a row's regions holds no pixel centre and no sample at Vulkan's standard
|
||||
//! locations, which lie a sixteenth of a pixel or more inside a pixel, while each copy's clip
|
||||
//! distance there is its window coordinate less the border's times `w`, zero on the border up to
|
||||
//! rounding: each such sample is covered by the one copy of its region, as under each region's
|
||||
//! own scissor. A pass whose sample positions put a sample on a pixel's left edge (an x of 0)
|
||||
//! records each region of a row alone, so that a border such a sample lies on is a recording's
|
||||
//! scissor's edge; a row's top and bottom edges are its scissor's. Every route then hands the
|
||||
//! rasterizer the same position and clip distances for a vertex in a region, through the same
|
||||
//! viewport transform: a later pass that tests `Equal` the depth one draw stored meets it where
|
||||
//! the other route drew it. The copy's arithmetic is decorated `NoContraction`, each operation
|
||||
//! correctly rounded on its own (Vulkan's *Precision and Operation of SPIR-V Instructions*), and
|
||||
//! its `Position` and `ClipDistance` outputs are `Invariant`. The routes run the copy in different pipelines and different stages
|
||||
//! (the region-copy variant's vertex function, the fan-out variant's geometry stage), each on the
|
||||
//! position its own vertex function computes: the identity rests on those correctly rounded
|
||||
//! operations and on the guest's position computation compiling alike in both pipelines, which
|
||||
//! Vulkan's invariance appendix does not promise across pipelines (its Rule 4), and which is
|
||||
//! checked by running it.
|
||||
//!
|
||||
//! The table holds, for each axis, the segments of the plan's regions that hold a pixel, in the
|
||||
//! order of their normalized device coordinates: a region is a segment of each axis. The stage
|
||||
//! reads a triangle's bounds in normalized device coordinates (`x / w`, every `w` positive),
|
||||
//! finds the segments of each axis they reach by bisection, and emits a copy for each pair, at
|
||||
//! most its copies; a triangle with more, or with a `w` not positive and another positive, is
|
||||
//! the probe's to find, whose bounds are widened by [`WIDEN_PIXELS`] of a pixel so that a draw
|
||||
//! the probe passed reaches no more.
|
||||
//!
|
||||
//! The layout (`std430`, 16-byte entries): a header of the counts `uvec4(nx, ny, 0, 0)` and the
|
||||
//! widenings `vec4(ex, ey, 0, 0)`, then [`MAX_SEGMENTS`] lines and as many clips per axis, x's
|
||||
//! then y's: a line `vec4(ndc_lo, ndc_hi, a, b)`, a clip `vec4(W/2, X + W/2 − p₀, p₁ − X − W/2,
|
||||
//! 0)`.
|
||||
|
||||
/// The words of a probe's flags each probed draw takes: its flag, then [`PROBE_SETS`] sets of
|
||||
/// [`PROBE_COUNT_WORDS`] (`pipeline::link::fan_out`, the probe), then its blocks' bounds
|
||||
/// ([`PROBE_BOUNDS_AT`]), from word `PROBE_DRAW_WORDS·i` for the draw of index `i`, each zero
|
||||
/// before the probe. The consumer sums a draw's counts, draws a draw none of whose wide words is
|
||||
/// marked through its variant of few copies (`RegionFanOut::DrawFew`), takes the first and the
|
||||
/// last flagged primitive of a flagged draw from the least of the third set and the greatest of
|
||||
/// the fourth, sums the fifth for its flagged triangles, reads the sixth as the bits of its
|
||||
/// blocks that hold a flagged one, which it draws region by region, sums the seventh for its
|
||||
/// flagged triangles with some `w` not positive beside a positive one, and draws a run of blocks
|
||||
/// only into the regions its blocks' bounds reach.
|
||||
pub const PROBE_DRAW_WORDS: u32 = PROBE_BOUNDS_AT + PROBE_BLOCKS;
|
||||
|
||||
/// The sets of [`PROBE_COUNT_WORDS`] after a probed draw's flag ([`PROBE_DRAW_WORDS`]), in
|
||||
/// order: the counts its triangles add their copies into; the marks of its triangles that it
|
||||
/// does not flag and that reach more than [`FEW_COPIES`] pairs of segments; the greatest
|
||||
/// `u32::MAX − PrimitiveId` of its flagged triangles; the greatest `PrimitiveId + 1` of them;
|
||||
/// the counts its flagged triangles add one each into; the bits of its blocks of
|
||||
/// [`BLOCK_TRIANGLES`] that hold a flagged triangle, block `b` bit `b mod 32` of word `b / 32`
|
||||
/// ([`PROBE_BLOCKS`] of them, the last also every triangle past them; [`BLOCK_SET`]); and the
|
||||
/// counts its flagged triangles with some `w` not positive beside a positive one add one each
|
||||
/// into ([`STRADDLE_SET`]).
|
||||
pub const PROBE_SETS: u32 = 7;
|
||||
|
||||
/// The set of a probed draw's words that holds the bits of its blocks ([`PROBE_SETS`]).
|
||||
pub const BLOCK_SET: u32 = 5;
|
||||
|
||||
/// The set of a probed draw's words its flagged triangles with some `w` not positive beside a
|
||||
/// positive one count into ([`PROBE_SETS`]).
|
||||
pub const STRADDLE_SET: u32 = 6;
|
||||
|
||||
/// The word of a probed draw's words ([`PROBE_DRAW_WORDS`]) its blocks' bounds begin at: one
|
||||
/// word a block of [`BLOCK_TRIANGLES`] ([`PROBE_BLOCKS`] of them, the last also every triangle
|
||||
/// past them), the bits of the [`BOUND_BUCKETS`] buckets of each axis its triangles' bounds
|
||||
/// reach ([`bucket`]), x's in bits 0 to 15 and y's in bits 16 to 31, widened as the probe's
|
||||
/// bounds are; for a triangle with some `w` not positive beside a positive one, the bounds of
|
||||
/// its part where `w` is positive, unbounded on each side an edge crosses `w = 0`.
|
||||
pub const PROBE_BOUNDS_AT: u32 = 1 + PROBE_SETS * PROBE_COUNT_WORDS;
|
||||
|
||||
/// The buckets of segments of each axis a block's bounds hold ([`PROBE_BOUNDS_AT`], [`bucket`]).
|
||||
pub const BOUND_BUCKETS: u32 = 16;
|
||||
|
||||
/// The bucket of segment `segment` of an axis of `segments` segments ([`BOUND_BUCKETS`]):
|
||||
/// `segment · BOUND_BUCKETS / segments`, so each bucket holds consecutive segments and every
|
||||
/// segment one bucket.
|
||||
pub const fn bucket(segment: u32, segments: u32) -> u32 {
|
||||
segment * BOUND_BUCKETS / segments
|
||||
}
|
||||
|
||||
/// The triangles of a probed draw's block (`PrimitiveId / BLOCK_TRIANGLES`; [`PROBE_SETS`]):
|
||||
/// [`PROBE_BLOCKS`] of them cover 65,536 triangles, more than a command of the pieces lane draws
|
||||
/// (161,820 indices, 53,940 triangles), and a block drawn region by region for one flagged
|
||||
/// triangle draws at most 63 others so.
|
||||
pub const BLOCK_TRIANGLES: u32 = 64;
|
||||
|
||||
/// The blocks of a probed draw whose bits its last set holds ([`PROBE_SETS`]): one a bit.
|
||||
pub const PROBE_BLOCKS: u32 = 32 * PROBE_COUNT_WORDS;
|
||||
|
||||
// A block is a shift of the primitive's index.
|
||||
const _: () = assert!(BLOCK_TRIANGLES.is_power_of_two());
|
||||
|
||||
/// The words a probed draw's triangles add their copies into, and in each of the other sets of
|
||||
/// its words ([`PROBE_DRAW_WORDS`]) as many, a triangle the one of each set its `PrimitiveId`
|
||||
/// picks (`PrimitiveId mod PROBE_COUNT_WORDS`): one
|
||||
/// word every triangle of a draw added into made the probe 15.4 to 20.7 ms of an RTX 3090's GPU
|
||||
/// time for 64 draws of 306,036 triangles; spread over these, 1.45 ms (NVIDIA 620.70.06, the
|
||||
/// pieces lane).
|
||||
pub const PROBE_COUNT_WORDS: u32 = 32;
|
||||
|
||||
/// The most copies of a triangle a draw's variant of few copies emits (`RegionFanOut::DrawFew`),
|
||||
/// which a draw whose triangles each reach at most this many pairs of segments draws through: its
|
||||
/// geometry stage declares the output of this many copies' vertices, not the most copies'. The
|
||||
/// pieces lane's draws are all of few copies: in one run a Radeon 780M (Mesa 26.2.6) drew two warm
|
||||
/// frames in 29.7 and 30.8 ms of command buffer GPU time, where the same draws through the most
|
||||
/// copies took 36.8 and 34.5 ms; an Iris Xe (Mesa 26.2.6) drew it in 40.0 ms and an RTX 3090
|
||||
/// (NVIDIA 620.70.06) in 6.1 ms, as through the most copies in earlier runs (40.5 and 6.2 ms).
|
||||
pub const FEW_COPIES: u32 = 4;
|
||||
|
||||
/// The most segments an axis holds: [`RateMapRegions::MAX_REGIONS`](crate::bind::RateMapRegions) is
|
||||
/// this many per axis squared.
|
||||
pub const MAX_SEGMENTS: u32 = 128;
|
||||
|
||||
/// The entries before the lines: the counts and the widenings.
|
||||
pub const HEADER_ENTRIES: u32 = 2;
|
||||
|
||||
/// The table's bytes.
|
||||
pub const TABLE_BYTES: u64 = (HEADER_ENTRIES as u64 + 4 * MAX_SEGMENTS as u64) * 16;
|
||||
|
||||
/// How far, in physical pixels, the probe widens a triangle's bounds before it counts the
|
||||
/// segments they reach: past the difference rounding makes between the probe's and the draw's
|
||||
/// vertex positions, each its own pipeline's.
|
||||
pub const WIDEN_PIXELS: f64 = 0.125;
|
||||
|
||||
/// The entry of axis `axis`'s line `k`.
|
||||
pub const fn line_entry(axis: u32, k: u32) -> u32 {
|
||||
HEADER_ENTRIES + axis * MAX_SEGMENTS + k
|
||||
}
|
||||
|
||||
/// The entry of axis `axis`'s clip `k`.
|
||||
pub const fn clip_entry(axis: u32, k: u32) -> u32 {
|
||||
HEADER_ENTRIES + 2 * MAX_SEGMENTS + axis * MAX_SEGMENTS + k
|
||||
}
|
||||
|
||||
/// One segment of an axis: the region viewport's `(X, W)` on it, Vulkan's (`W` negative where
|
||||
/// the consumer flips the axis), and its scissor's pixels `[p₀, p₁)`.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
struct Segment {
|
||||
origin: f64,
|
||||
extent: f64,
|
||||
pixels: [u32; 2],
|
||||
}
|
||||
|
||||
impl Segment {
|
||||
/// Its normalized device coordinates, least first: those of its pixels' edges.
|
||||
fn ndc(&self) -> [f64; 2] {
|
||||
let at = |p: u32| 2.0 * (f64::from(p) - self.origin) / self.extent - 1.0;
|
||||
let [a, b] = [at(self.pixels[0]), at(self.pixels[1])];
|
||||
[a.min(b), a.max(b)]
|
||||
}
|
||||
|
||||
/// Its line `vec4(ndc_lo, ndc_hi, a, b)` for the target's viewport `(X₀, W₀)` on its axis.
|
||||
fn line(&self, (x0, w0): (f64, f64)) -> [f32; 4] {
|
||||
let [lo, hi] = self.ndc();
|
||||
let a = self.extent / w0;
|
||||
let b = (2.0 * self.origin + self.extent - 2.0 * x0) / w0 - 1.0;
|
||||
[lo, hi, a, b].map(|v| v as f32)
|
||||
}
|
||||
|
||||
/// Its clip `vec4(W/2, X + W/2 − p₀, p₁ − X − W/2, 0)`.
|
||||
fn clip(&self) -> [f32; 4] {
|
||||
let half = self.extent / 2.0;
|
||||
let centre = self.origin + half;
|
||||
[
|
||||
half,
|
||||
centre - f64::from(self.pixels[0]),
|
||||
f64::from(self.pixels[1]) - centre,
|
||||
0.0,
|
||||
]
|
||||
.map(|v| v as f32)
|
||||
}
|
||||
}
|
||||
|
||||
/// The segments of each axis of `regions` ([`table`]'s), in the order of their normalized device
|
||||
/// coordinates, or `None` where they make no table.
|
||||
fn segments(regions: &[([f32; 4], [u32; 4])]) -> Option<[Vec<Segment>; 2]> {
|
||||
let axis = |a: usize| {
|
||||
let mut segments: Vec<Segment> = Vec::new();
|
||||
for &(viewport, scissor) in regions {
|
||||
let segment = Segment {
|
||||
origin: f64::from(viewport[a]),
|
||||
extent: f64::from(viewport[a + 2]),
|
||||
pixels: [scissor[a], scissor[a] + scissor[a + 2]],
|
||||
};
|
||||
if !segments.contains(&segment) {
|
||||
segments.push(segment);
|
||||
}
|
||||
}
|
||||
segments.sort_by(|s, t| s.ndc()[0].total_cmp(&t.ndc()[0]));
|
||||
segments
|
||||
};
|
||||
let [xs, ys] = [axis(0), axis(1)];
|
||||
let fits = |s: &[Segment]| !s.is_empty() && s.len() <= MAX_SEGMENTS as usize;
|
||||
if !fits(&xs) || !fits(&ys) || xs.len() * ys.len() != regions.len() {
|
||||
return None;
|
||||
}
|
||||
Some([xs, ys])
|
||||
}
|
||||
|
||||
/// The region table of a fan-out draw through the Vulkan viewport `target` (`[x, y, width,
|
||||
/// height]`, its height negative where the consumer flips y) over the regions `regions`, each its
|
||||
/// Vulkan viewport and its scissor `[x, y, width, height]`, those that hold a pixel (the module
|
||||
/// docs). `None` where the regions are not one segment of each axis per pair (a plan's are), or an
|
||||
/// axis has more than [`MAX_SEGMENTS`] or none.
|
||||
pub fn table(target: [f32; 4], regions: &[([f32; 4], [u32; 4])]) -> Option<Vec<u8>> {
|
||||
let [xs, ys] = segments(regions)?;
|
||||
let mut entries = vec![[0u32; 4]; (TABLE_BYTES / 16) as usize];
|
||||
entries[0] = [xs.len() as u32, ys.len() as u32, 0, 0];
|
||||
// A physical pixel is `2 / |W|` of normalized device coordinates; the widening is the least
|
||||
// segment's.
|
||||
let widen = |s: &[Segment]| {
|
||||
(s.iter())
|
||||
.map(|s| WIDEN_PIXELS * 2.0 / s.extent.abs())
|
||||
.fold(0.0f64, f64::max) as f32
|
||||
};
|
||||
entries[1] = [widen(&xs), widen(&ys), 0.0, 0.0].map(f32::to_bits);
|
||||
for (a, segments) in [&xs, &ys].into_iter().enumerate() {
|
||||
let a32 = a as u32;
|
||||
let target = (f64::from(target[a]), f64::from(target[a + 2]));
|
||||
for (k, segment) in segments.iter().enumerate() {
|
||||
let k = k as u32;
|
||||
entries[line_entry(a32, k) as usize] = segment.line(target).map(f32::to_bits);
|
||||
entries[clip_entry(a32, k) as usize] = segment.clip().map(f32::to_bits);
|
||||
}
|
||||
}
|
||||
Some(
|
||||
entries
|
||||
.iter()
|
||||
.flatten()
|
||||
.flat_map(|w| w.to_le_bytes())
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
|
||||
/// The scissors `[x, y, width, height]` of the regions of [`table`]'s table over `regions`, in
|
||||
/// the table's order: region `k` of segments `(k mod nx, k / nx)` (the module docs, **One route
|
||||
/// per pass**), the scissor a region-copy variant's draw of region `k` takes. `None` where
|
||||
/// [`table`] makes none.
|
||||
pub fn scissors(regions: &[([f32; 4], [u32; 4])]) -> Option<Vec<[u32; 4]>> {
|
||||
let [xs, ys] = segments(regions)?;
|
||||
let scissor = |x: &Segment, y: &Segment| {
|
||||
let ([x0, x1], [y0, y1]) = (x.pixels, y.pixels);
|
||||
[x0, y0, x1 - x0, y1 - y0]
|
||||
};
|
||||
Some(
|
||||
(ys.iter())
|
||||
.flat_map(|y| xs.iter().map(|x| scissor(x, y)))
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
@@ -174,18 +174,7 @@
|
||||
//! index among a multi-draw's as `ViewportIndex` (`VariantKey::region_viewports`), where its
|
||||
//! pipeline is a vertex pipeline without tessellation drawn in one pass of no views; a mesh,
|
||||
//! tessellated or amplified draw keeps the plain variant, and the consumer draws its regions one
|
||||
//! at a time: the plan's variant says which. A draw of a rate-mapped pass's triangles fanned
|
||||
//! out to their regions (`BindShape::region_fan_out`) runs the variant whose triangle stage does
|
||||
//! so (`VariantKey::region_fan_out`) where its pipeline is such a pipeline of no amplification,
|
||||
//! whose stages synthesize no geometry stage of their own
|
||||
//! (`RuntimeFact::SynthesizedGeometry`), draw no band and choose no slice or viewport; it binds
|
||||
//! the region table (`WriteSource::RateMapRegions`) and, for a probe, the flags
|
||||
//! (`WriteSource::RateMapFlags`), and a probe pushes its flag's index to the geometry stage. A
|
||||
//! region-copy variant (`RegionFanOut::RegionCopies`) draws no geometry stage: its vertex
|
||||
//! function draws its region's copy, binding the region table, and its draw pushes its row of
|
||||
//! regions (`PushField::RegionBox`) in the vertex stage's range. Elsewhere the plan keeps the
|
||||
//! plain variant, and the consumer draws the regions one at a time. A fanned-out draw draws no
|
||||
//! regions several at a time.
|
||||
//! at a time: the plan's variant says which.
|
||||
//! - **Index buffer bounds**. A direct indexed draw whose indices run past where Metal's fetch
|
||||
//! stops reading its index buffer (`IndexBufferRef::fetch_end`: the length rounded up to 4 bytes;
|
||||
//! Metal's API validation rejects the draw, and Apple's GPUs read index 0 past there) is drawn
|
||||
@@ -314,7 +303,7 @@ use crate::pipeline::sym::{
|
||||
Axis, DispatchKeys, PushField, SlotClass, SlotRef, SpecKey, Stage, SyntheticBinding,
|
||||
};
|
||||
use crate::pipeline::vertex::{VertexAttribute, VertexStride};
|
||||
use crate::pipeline::{AmplificationDraws, RegionFanOut};
|
||||
use crate::pipeline::AmplificationDraws;
|
||||
use crate::vk;
|
||||
|
||||
/// A Metal draw call.
|
||||
@@ -578,9 +567,8 @@ impl RenderPipeline {
|
||||
/// a Metal function, with its Vulkan stage: a tessellation pipeline's (`tessellated`) synthesized
|
||||
/// vertex and control stages run none, and its post-tessellation vertex function is its
|
||||
/// evaluation stage; a mesh render pipeline's object and mesh functions are its task and mesh
|
||||
/// stages; the geometry stages link
|
||||
/// generates (`link::geometry`: barycentric weights read as varyings) run none and bind nothing,
|
||||
/// nor do a band variant's (`banded`) control and evaluation stages (`link::band`).
|
||||
/// stages; a band variant's (`banded`) control and evaluation stages (`link::band`) run none
|
||||
/// and bind nothing.
|
||||
fn metal_stages(
|
||||
stages: impl ExactSizeIterator<Item = vk::ShaderStage>,
|
||||
(tessellated, banded): (bool, bool),
|
||||
@@ -599,7 +587,6 @@ fn metal_stages(
|
||||
Stage::Vertex
|
||||
} else if tessellated
|
||||
&& (s == vk::ShaderStage::VERTEX || s == vk::ShaderStage::TESSELLATION_CONTROL)
|
||||
|| s == vk::ShaderStage::GEOMETRY
|
||||
|| banded
|
||||
&& (s == vk::ShaderStage::TESSELLATION_CONTROL
|
||||
|| s == vk::ShaderStage::TESSELLATION_EVALUATION)
|
||||
@@ -799,9 +786,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
.dependencies
|
||||
.iter()
|
||||
.any(|d| d.fact == RuntimeFact::RegionViewports);
|
||||
// A draw of a rate-mapped pass's triangles fanned out to their regions: the variant whose
|
||||
// triangle stage does so, which its graphics state states.
|
||||
let compiled_fan_out = p.graphics.region_fan_out.map(|f| f.mode);
|
||||
let route = route(
|
||||
&shape.vertex_amplification,
|
||||
p.graphics.max_vertex_amplification_count,
|
||||
@@ -841,25 +825,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
&& !tessellation
|
||||
&& amplification_draws.is_none()
|
||||
&& views.view_mask == 0;
|
||||
// A draw of a rate-mapped pass's triangles once, the variant's triangle stage fanning each out
|
||||
// to the regions it touches, where the pipeline is such a vertex pipeline of no amplification,
|
||||
// whose stages synthesize no geometry stage of their own, draw
|
||||
// no band and choose no slice or viewport; it draws no regions several at a time.
|
||||
let synthesized =
|
||||
(p.dependencies.iter()).any(|d| matches!(d.fact, RuntimeFact::SynthesizedGeometry { .. }));
|
||||
let region_fan_out = shape.region_fan_out.filter(|_| {
|
||||
!mesh
|
||||
&& !tessellation
|
||||
&& amplification_draws.is_none()
|
||||
&& views.view_mask == 0
|
||||
&& p.graphics.max_vertex_amplification_count <= 1
|
||||
&& shape.line_band.is_none()
|
||||
&& !synthesized
|
||||
&& !p.graphics.writes_viewport_index
|
||||
&& !p.graphics.declares_layer
|
||||
&& vertex_layer.is_none()
|
||||
});
|
||||
let region_viewports = region_viewports && region_fan_out.is_none();
|
||||
// The variant the pipeline was compiled under: its vertex function states it.
|
||||
let compiled_draws = p.dependencies.iter().find_map(|d| match d.fact {
|
||||
RuntimeFact::AmplificationDraws { layered, viewports } => {
|
||||
@@ -1319,14 +1284,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
| PushField::AmplificationLayerOffset
|
||||
| PushField::AmplificationViewportOffset
|
||||
if matches!(field.loc, PushLoc::Push { .. }) => {}
|
||||
// A region-copy variant's row of regions of a recording, which instantiation
|
||||
// writes from the state and the consumer pushes before each recording, in the
|
||||
// window as the amplification fields are.
|
||||
PushField::RegionBox
|
||||
if stage == Stage::Vertex
|
||||
&& (p.graphics.region_fan_out)
|
||||
.is_some_and(|f| f.mode == RegionFanOut::RegionCopies)
|
||||
&& matches!(field.loc, PushLoc::Push { .. }) => {}
|
||||
PushField::VertexBufferStride(layout) if stage == Stage::Vertex => {
|
||||
match pulled_stride(layout) {
|
||||
Some(VertexStride::Static(_)) => {}
|
||||
@@ -1612,16 +1569,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
}
|
||||
// The command buffer's status, on a device that does not address buffers.
|
||||
SyntheticBinding::ExecutionStatus => WriteSource::ExecutionStatus,
|
||||
// A fan-out variant's region table, and a probe's flags.
|
||||
SyntheticBinding::RateMapRegions if p.graphics.region_fan_out.is_some() => {
|
||||
WriteSource::RateMapRegions
|
||||
}
|
||||
SyntheticBinding::RateMapFlags
|
||||
if (p.graphics.region_fan_out)
|
||||
.is_some_and(|f| f.mode == RegionFanOut::Probe) =>
|
||||
{
|
||||
WriteSource::RateMapFlags
|
||||
}
|
||||
other => return Err(internal(format!("a render binding {other:?}"))),
|
||||
},
|
||||
BindingSource::Heap(_)
|
||||
@@ -2038,7 +1985,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
variant.quad_primitive_ids = quad_primitive_ids;
|
||||
variant.private_list = private_list;
|
||||
variant.region_viewports = region_viewports;
|
||||
variant.region_fan_out = region_fan_out;
|
||||
// Tables that may pass `maxStorageBufferRange`: the variant that reads them at their
|
||||
// addresses (and a pipeline compiled so states it).
|
||||
variant.addressed_function_tables = crate::bind::heap::addressed_function_tables(
|
||||
@@ -2074,8 +2020,7 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
|| compiled_tests != read_only_tests
|
||||
|| compiled_quads != quad_primitive_ids
|
||||
|| compiled_list != private_list
|
||||
|| compiled_regions != region_viewports
|
||||
|| compiled_fan_out != region_fan_out,
|
||||
|| compiled_regions != region_viewports,
|
||||
amplifications,
|
||||
indirect_first_instance_missing: !profile
|
||||
.fields()
|
||||
@@ -2105,9 +2050,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
private_list,
|
||||
storage_kept: storage_kept(p)?,
|
||||
line_band: p.graphics.line_band.map(|b| b.push_offset),
|
||||
region_probe: (p.graphics.region_fan_out)
|
||||
.filter(|f| f.mode == RegionFanOut::Probe)
|
||||
.map(|f| f.push_offset),
|
||||
}),
|
||||
views,
|
||||
})
|
||||
@@ -3559,15 +3501,6 @@ fn instantiate(
|
||||
)
|
||||
}
|
||||
PushField::VertexBufferStride(layout) => pulled_stride(t, state, layout)?,
|
||||
// A region-copy variant's row of regions: the state's first region's segment of
|
||||
// x in the table's first row, which the consumer pushes again, with its row's
|
||||
// segments, before each recording of its regions.
|
||||
PushField::RegionBox => {
|
||||
let (_, x0) = state.region_fan_out.ok_or_else(|| {
|
||||
internal("a region-copy variant's draw without its region")
|
||||
})?;
|
||||
FieldBytes::words([x0, 0])
|
||||
}
|
||||
field => slot_field(field, &bound.residuals, &t.resources, state)
|
||||
.ok_or_else(|| internal(format!("a render push field {field:?}")))?,
|
||||
};
|
||||
@@ -3672,17 +3605,6 @@ fn instantiate(
|
||||
bytes: band.iter().flat_map(|v| v.to_le_bytes()).collect(),
|
||||
});
|
||||
}
|
||||
// A fan-out probe's draw pushes the index of its flag to the geometry stage's own range.
|
||||
if let Some(offset) = t.region_probe {
|
||||
let (_, index) = state
|
||||
.region_fan_out
|
||||
.ok_or_else(|| internal("a draw of a fan-out probe without its flag's index"))?;
|
||||
push_constants.push(PushConstantWrite {
|
||||
stages: vk::ShaderStageFlags::GEOMETRY,
|
||||
offset,
|
||||
bytes: index.to_le_bytes().to_vec(),
|
||||
});
|
||||
}
|
||||
// The CPU reads the arguments of an indirect draw whose base vertex and instance the profile
|
||||
// emulates, of a multiview plan, or without `drawIndirectFirstInstance`, and of an indexed one
|
||||
// whose index fetch nothing bounds, which the GPU pass may bound instead.
|
||||
|
||||
@@ -111,8 +111,7 @@ fn draws_map_to_the_vulkan_draw_of_the_same_arguments() {
|
||||
|
||||
/// A render plan names only vertex and fragment stages; a tessellation pipeline's vertex
|
||||
/// function is its evaluation stage, and its synthesized vertex and control stages are none, as
|
||||
/// are the geometry stages of barycentric weights read as varyings and a band's control and
|
||||
/// evaluation stages.
|
||||
/// are a band's control and evaluation stages; a geometry stage is no render stage.
|
||||
#[test]
|
||||
fn only_vertex_and_fragment_stages_are_render_stages() {
|
||||
use vk::ShaderStage as S;
|
||||
@@ -153,24 +152,9 @@ fn only_vertex_and_fragment_stages_are_render_stages() {
|
||||
(Stage::Fragment, S::FRAGMENT)
|
||||
])
|
||||
);
|
||||
assert_eq!(
|
||||
stages(
|
||||
&[
|
||||
S::VERTEX,
|
||||
S::GEOMETRY,
|
||||
S::GEOMETRY,
|
||||
S::GEOMETRY,
|
||||
S::FRAGMENT
|
||||
],
|
||||
false
|
||||
),
|
||||
Ok(vec![
|
||||
(Stage::Vertex, S::VERTEX),
|
||||
(Stage::Fragment, S::FRAGMENT)
|
||||
])
|
||||
);
|
||||
for (modules, tessellated) in [
|
||||
(&[S::COMPUTE][..], false),
|
||||
(&[S::VERTEX, S::GEOMETRY, S::FRAGMENT][..], false),
|
||||
(&[S::TESSELLATION_EVALUATION][..], false),
|
||||
(&[S::TESSELLATION_CONTROL][..], false),
|
||||
(&[S::COMPUTE][..], true),
|
||||
@@ -621,7 +605,6 @@ fn instantiation_bounds_a_draw_by_its_index_buffer() {
|
||||
private_list: false,
|
||||
storage_kept: 0,
|
||||
line_band: None,
|
||||
region_probe: None,
|
||||
};
|
||||
let state = BindState::default();
|
||||
let past = indexed_in(vk::IndexType::UINT32, 40, 8, 10);
|
||||
@@ -670,7 +653,6 @@ fn a_draw_of_no_index_binds_inside_the_buffer() {
|
||||
private_list: false,
|
||||
storage_kept: 0,
|
||||
line_band: None,
|
||||
region_probe: None,
|
||||
};
|
||||
let state = BindState::default();
|
||||
let bound = |cmds: &DrawCommands| match cmds.draw {
|
||||
@@ -754,7 +736,6 @@ fn an_unbounded_indexed_indirect_draw_reads_its_arguments() {
|
||||
private_list: false,
|
||||
storage_kept: 0,
|
||||
line_band: None,
|
||||
region_probe: None,
|
||||
};
|
||||
let state = BindState::default();
|
||||
for robust in [false, true] {
|
||||
@@ -810,7 +791,6 @@ fn draws_bind_vertex_buffers_at_aligned_offsets_with_their_windows() {
|
||||
private_list: false,
|
||||
storage_kept: 0,
|
||||
line_band: None,
|
||||
region_probe: None,
|
||||
};
|
||||
let state = |offsets: (u64, u64), stride| {
|
||||
let buffer = |offset, attribute_stride| BoundBuffer::Buffer {
|
||||
@@ -901,7 +881,6 @@ fn inline_vertex_bytes_bind_the_strides_a_dynamic_layout_reads() {
|
||||
private_list: false,
|
||||
storage_kept: 0,
|
||||
line_band: None,
|
||||
region_probe: None,
|
||||
};
|
||||
let state = |attribute_stride| {
|
||||
let mut t = StageTable::default();
|
||||
@@ -1504,7 +1483,6 @@ fn mesh_template(flat: bool, multiples: Vec<u32>) -> GraphicsTemplate {
|
||||
private_list: false,
|
||||
storage_kept: 0,
|
||||
line_band: None,
|
||||
region_probe: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,6 @@ pub(crate) mod depth_clamp;
|
||||
pub(crate) mod depth_stencil_copy;
|
||||
pub(crate) mod dispatch;
|
||||
pub(crate) mod etc_decode;
|
||||
pub mod fan_out;
|
||||
pub(crate) mod graphics;
|
||||
pub(crate) mod heap;
|
||||
pub mod indirect_commands;
|
||||
|
||||
@@ -234,11 +234,6 @@ pub struct GraphicsTemplate {
|
||||
/// push range, where its draws push `BindState::line_band` (`PushField::LineBand`).
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub(crate) line_band: Option<u32>,
|
||||
/// A fan-out probe variant's (`GraphicsState::region_fan_out`): the byte offset of its
|
||||
/// geometry stage's push range, where its draws push the index of their flag
|
||||
/// (`BindState::region_fan_out`, `PushField::RegionProbe`).
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub(crate) region_probe: Option<u32>,
|
||||
}
|
||||
|
||||
/// What a mesh draw of a mesh render pipeline instantiates: the pipeline's specialization layout
|
||||
@@ -663,21 +658,6 @@ pub enum WriteSource {
|
||||
/// The encoder's tessellation factor buffer (`BindState::tessellation_factors`), a
|
||||
/// read-only storage buffer of the control stage over the draw's `DescriptorRange`.
|
||||
TessellationFactors,
|
||||
/// A rate-mapped pass's region table (`SyntheticBinding::RateMapRegions`) of a fan-out
|
||||
/// variant's draw (`GraphicsState::region_fan_out`): a read-only storage buffer of
|
||||
/// [`fan_out::TABLE_BYTES`](crate::bind::fan_out::TABLE_BYTES) bytes holding
|
||||
/// [`fan_out::table`](crate::bind::fan_out::table) of the draw's one viewport over the
|
||||
/// pass's regions, bound whole.
|
||||
RateMapRegions,
|
||||
/// A fan-out probe's flags (`SyntheticBinding::RateMapFlags`,
|
||||
/// [`RegionFanOut::Probe`](crate::pipeline::RegionFanOut)): a storage buffer of `u32`s the
|
||||
/// consumer keeps for its probes, `bind::fan_out::PROBE_DRAW_WORDS` zeros at each draw's index
|
||||
/// (`BindState::region_fan_out`) before the draw, where the draw writes 1 into the first for
|
||||
/// a triangle it cannot fan out, adds into the counts after it the copies it would emit of
|
||||
/// the others, marks those after them for a triangle too wide for few copies, and for a
|
||||
/// flagged triangle raises its first's and last's words, adds one into its flagged count and
|
||||
/// sets its block's bit (`GraphicsState::region_fan_out`); bound whole.
|
||||
RateMapFlags,
|
||||
/// The top-level structure of the acceleration structure bound at buffer slot `slot`
|
||||
/// (`setAccelerationStructure:atBufferIndex:`): the bound instance structure itself when
|
||||
/// `level` is `Instance`, and, when `level` is `Primitive`, the top-level structure of one
|
||||
|
||||
@@ -147,24 +147,6 @@ pub struct BindState {
|
||||
/// docs). Part of the shape (`BindShape::region_viewports`); `false` for every other draw.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub region_viewports: bool,
|
||||
/// The draw records a rasterization-rate-mapped pass's triangles once, through one viewport
|
||||
/// over the whole target, the variant's triangle stage fanning each out to the regions it
|
||||
/// touches (`VariantKey::region_fan_out`, `GraphicsState::region_fan_out`), or probing which
|
||||
/// of the draw's triangles it cannot ([`RegionFanOut::Probe`](crate::pipeline::RegionFanOut)),
|
||||
/// and the index of the pair of words a probe writes (`PushField::RegionProbe`,
|
||||
/// `WriteSource::RateMapFlags`; 0 for a draw); or records them region by region through that
|
||||
/// viewport, its vertex function putting each vertex in its region as the triangle stage
|
||||
/// puts a copy's ([`RegionFanOut::RegionCopies`](crate::pipeline::RegionFanOut)), and the
|
||||
/// segment of x of its recording's first region in the region table's first row
|
||||
/// (`PushField::RegionBox`, `[x0, 0]`), which the consumer pushes again, with its row's
|
||||
/// segments, for each of its recordings. The consumer sets it only for a draw of triangles.
|
||||
/// The plan's variant fans out only a vertex pipeline without tessellation drawn in one pass
|
||||
/// of no views, whose stages synthesize no geometry stage of their own and draw no band
|
||||
/// (`bind::graphics`'s module docs). Its variant
|
||||
/// is part of the shape (`BindShape::region_fan_out`), its index only of the draw's bytes;
|
||||
/// `None` for every other draw.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub region_fan_out: Option<(crate::pipeline::RegionFanOut, u32)>,
|
||||
/// Where the heap arrays (set 1) hold the command's heap members and argument samplers
|
||||
/// ([`HeapPlacement`]). Only the instantiated tables and the elements the consumer writes
|
||||
/// ([`BindingPlan::heap_elements`]) depend on it, so it is not part of the shape.
|
||||
@@ -614,7 +596,6 @@ impl BindState {
|
||||
private_list: self.private_list,
|
||||
far_vertex_buffers: self.far_vertex_buffers.clone(),
|
||||
region_viewports: self.region_viewports,
|
||||
region_fan_out: self.region_fan_out.map(|(mode, _)| mode),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -700,7 +681,6 @@ impl BindState {
|
||||
private_list,
|
||||
far_vertex_buffers,
|
||||
region_viewports,
|
||||
region_fan_out,
|
||||
} = shape;
|
||||
let tables = self.stages.iter().filter(|(_, t)| !t.has_empty_shape());
|
||||
tables.clone().count() == stages.len()
|
||||
@@ -729,7 +709,6 @@ impl BindState {
|
||||
&& self.private_list == *private_list
|
||||
&& self.far_vertex_buffers == *far_vertex_buffers
|
||||
&& self.region_viewports == *region_viewports
|
||||
&& self.region_fan_out.map(|(mode, _)| mode) == *region_fan_out
|
||||
}
|
||||
|
||||
/// `used_resources` by token ([`BindShape::used`]): one token names one resource, and listing
|
||||
@@ -1724,11 +1703,6 @@ pub struct BindShape {
|
||||
/// (`VariantKey::region_viewports`).
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub region_viewports: bool,
|
||||
/// `BindState.region_fan_out`'s variant: a draw of a rate-mapped pass's triangles once, its
|
||||
/// variant's triangle stage fanning them out to their regions, or probing which it cannot, or
|
||||
/// region by region through its vertex function's copies (`VariantKey::region_fan_out`).
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub region_fan_out: Option<crate::pipeline::RegionFanOut>,
|
||||
}
|
||||
|
||||
impl BindShape {}
|
||||
|
||||
+5
-12
@@ -40,9 +40,9 @@ use crate::pipeline::artifact::{
|
||||
use crate::pipeline::descriptor::TessellationDescriptor;
|
||||
use crate::pipeline::facts::{Mechanism, RuntimeFact, UniformViewChoice};
|
||||
use crate::pipeline::graphics::{
|
||||
BandPrimitive, BlendState, ColorAttachmentState, FanOutState, FragmentImageblock,
|
||||
GraphicsState, ImageblockMechanism, InputAttachmentUse, LineBandState, RegionFanOut,
|
||||
ShadowStencilUse, StorageAttachmentUse, StorageAttachmentView, TessellationState,
|
||||
BandPrimitive, BlendState, ColorAttachmentState, FragmentImageblock, GraphicsState,
|
||||
ImageblockMechanism, InputAttachmentUse, LineBandState, ShadowStencilUse, StorageAttachmentUse,
|
||||
StorageAttachmentView, TessellationState,
|
||||
};
|
||||
use crate::pipeline::interface::{
|
||||
AccessSet, BufferForm, BufferKind, BufferSlot, CommandWrites, DescriptorView, LevelReads,
|
||||
@@ -848,7 +848,6 @@ codec_enum! {
|
||||
HandleClass { Image(f0), Sampler { compare, integer }, FunctionTable }
|
||||
SyntheticBinding {
|
||||
ArgumentTable, ExecutionStatus, RootTable, HandleTable, ConstantBlob, TessellationFactors, Imageblock,
|
||||
RateMapRegions, RateMapFlags,
|
||||
SamplerTable,
|
||||
ShadowStencil,
|
||||
FunctionTableDirectory,
|
||||
@@ -899,8 +898,6 @@ codec_enum! {
|
||||
AlphaTestReference,
|
||||
YCbCrInPlace(f0),
|
||||
LineBand,
|
||||
RegionProbe,
|
||||
RegionBox,
|
||||
TexelRows(f0),
|
||||
ArgumentTableAddress,
|
||||
ConstexprSampler(f0),
|
||||
@@ -1048,7 +1045,6 @@ codec_enum! {
|
||||
DeviceSampling,
|
||||
ProvokingVertexModePerPipeline,
|
||||
InterpolateAtOffsetFromSevenSixteenths,
|
||||
SubgroupGeometryStage,
|
||||
}
|
||||
VkLimit {
|
||||
MaxComputeWorkGroupSize(f0), MaxComputeWorkGroupCount(f0), MaxComputeWorkGroupInvocations,
|
||||
@@ -1183,7 +1179,7 @@ codec_enum! {
|
||||
Attribute { index }, Varying { user, interpolation },
|
||||
Color { attachment, index },
|
||||
ViewportIndex, RenderTargetArrayIndex, PrimitiveVarying { user },
|
||||
Barycentric { perspective }, PrimitiveId, MergedCommand,
|
||||
PrimitiveId, MergedCommand,
|
||||
}
|
||||
IoInterpolation { Flat, Smooth { sampling, perspective } }
|
||||
IoSampling { Center, Centroid, Sample, Interpolant { center, centroid, sample } }
|
||||
@@ -1283,7 +1279,6 @@ codec_enum! {
|
||||
AnisotropicSampler { slot },
|
||||
StorageTextureIntegerChannels { slot },
|
||||
MovableStorageWrites { early_variant },
|
||||
SynthesizedGeometry { weights },
|
||||
ObjectThreadgroupArena { static_bytes, payload },
|
||||
MergedDraws,
|
||||
QuadPrimitiveIds,
|
||||
@@ -1391,14 +1386,13 @@ codec_struct! {
|
||||
tessellation, fragment_imageblock, vertex_writes_memory, writes_viewport_index,
|
||||
storage_attachments, shadow_stencil, writes_point_size, writes_depth,
|
||||
reads_barycentric_coord, reads_primitive_id, fragment_writes_memory, color_outputs,
|
||||
sample_mask, snapshot_reads, logic_op, line_band, region_fan_out,
|
||||
sample_mask, snapshot_reads, logic_op, line_band,
|
||||
}
|
||||
TessellationState {
|
||||
patch_control_points, domain, control_points, factor_step_function, push_offset,
|
||||
control_point_index_type,
|
||||
}
|
||||
LineBandState { push_offset, primitive }
|
||||
FanOutState { mode, copies, push_offset }
|
||||
FragmentImageblock { mechanism, words, master, data_size, alignment }
|
||||
ColorAttachmentState { format, write_mask, blend }
|
||||
BlendState { src_color, dst_color, color_op, src_alpha, dst_alpha, alpha_op }
|
||||
@@ -1415,7 +1409,6 @@ codec_enum! {
|
||||
ImageblockMechanism { StorageImageInterlock }
|
||||
StorageAttachmentView { Attachment, SamplePlanes { layers } }
|
||||
BandPrimitive { Lines, Triangles }
|
||||
RegionFanOut { Draw, Probe, DrawFew, RegionCopies }
|
||||
PrecisionNote {
|
||||
F16FmaDoubleRounding, F16IntConvDoubleRounding, GradFromBias,
|
||||
DeviceTranscendentals, ReductionOrder, DeviceDenormals,
|
||||
|
||||
Vendored
+2
-12
@@ -61,7 +61,7 @@ mod tests;
|
||||
/// unchanged version, and its bless records the version. Independent of the crate's version and of
|
||||
/// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no
|
||||
/// history.
|
||||
pub const SEMANTICS_VERSION: u32 = 2247;
|
||||
pub const SEMANTICS_VERSION: u32 = 2248;
|
||||
|
||||
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
|
||||
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
|
||||
@@ -71,7 +71,7 @@ pub const SEMANTICS_VERSION: u32 = 2247;
|
||||
/// re-typed in an encoded type, its `codec` body or its `envelope`. A variant removed while its tag
|
||||
/// stays unused needs no bump: an entry holding it fails to decode, which is a miss. The commit that
|
||||
/// bumps it says what changed; this comment keeps no history.
|
||||
pub const ARTIFACT_FORMAT_VERSION: u32 = 583;
|
||||
pub const ARTIFACT_FORMAT_VERSION: u32 = 584;
|
||||
|
||||
/// The version of what this crate's runtime does with a compiled pipeline: instantiating a binding
|
||||
/// plan (`BindingPlan::instantiate_*`: descriptor ranges, push bytes, root, argument, and handle
|
||||
@@ -466,12 +466,6 @@ pub struct VariantKey {
|
||||
/// (`RuntimeFact::RegionViewports`).
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub region_viewports: bool,
|
||||
/// The render pipeline draws a rasterization-rate-mapped pass's triangles once, its
|
||||
/// triangle class's synthesized geometry stage emitting a copy of each per region it touches,
|
||||
/// or probing which draws it cannot (`BindShape::region_fan_out`, `pipeline::link::fan_out`).
|
||||
/// Its graphics state states it (`GraphicsState::region_fan_out`).
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub region_fan_out: Option<crate::pipeline::RegionFanOut>,
|
||||
}
|
||||
|
||||
impl VariantKey {
|
||||
@@ -581,7 +575,6 @@ impl VariantKey {
|
||||
&& self.anisotropic_samplers.is_empty()
|
||||
&& self.open_cl_lines.is_empty()
|
||||
&& !self.region_viewports
|
||||
&& self.region_fan_out.is_none()
|
||||
}
|
||||
|
||||
/// The lowering inputs of the function of `stage` under this key: its storage-image choices,
|
||||
@@ -648,9 +641,6 @@ impl VariantKey {
|
||||
.filter(|_| stage != crate::pipeline::sym::Stage::Kernel);
|
||||
out.region_viewports =
|
||||
self.region_viewports && stage == crate::pipeline::sym::Stage::Vertex;
|
||||
out.region_copies = self.region_fan_out
|
||||
== Some(crate::pipeline::RegionFanOut::RegionCopies)
|
||||
&& stage == crate::pipeline::sym::Stage::Vertex;
|
||||
out.storage_view_slots = self
|
||||
.storage_view_slots
|
||||
.iter()
|
||||
|
||||
@@ -558,9 +558,6 @@ fn enabled_caps(desc: &DeviceDescription) -> EnabledCaps {
|
||||
properties.insert(VkProperty::RequiredSubgroupSizeStage(stage));
|
||||
}
|
||||
}
|
||||
if sg.supported_stages.contains(vk::ShaderStageFlags::GEOMETRY) {
|
||||
properties.insert(VkProperty::SubgroupGeometryStage);
|
||||
}
|
||||
for op in SUBGROUP_OPS {
|
||||
if OpBits(sg.supported_operations.as_raw()).contains(OpBits::of(op)) {
|
||||
properties.insert(VkProperty::SubgroupOperation(op));
|
||||
|
||||
@@ -258,8 +258,5 @@ pub fn mechanism(fact: &RuntimeFact, profile: &DeviceProfile) -> Mechanism {
|
||||
// Keyed by the slots bound to a sampler whose word states anisotropy, where the
|
||||
// function's samples take Metal's anisotropic filter, emulated.
|
||||
RuntimeFact::AnisotropicSampler { .. } => Mechanism::Variant,
|
||||
// The pipeline's own stages, which every draw of its class runs; the consumer announces
|
||||
// them.
|
||||
RuntimeFact::SynthesizedGeometry { .. } => Mechanism::None,
|
||||
}
|
||||
}
|
||||
@@ -267,15 +267,11 @@ fn unsupported_features(profile: &DeviceProfile) -> Vec<Unsupported> {
|
||||
// Framebuffer fetch refuses on no device: ordered by rasterization-order access, by the pixel
|
||||
// interlock's storage form, or, with neither, through input attachments ordered between draws
|
||||
// (`PrecisionNote::UnorderedFetchWithinDraw`).
|
||||
// `[[barycentric_coord]]`: the device's builtins, or varyings a generated geometry stage
|
||||
// writes (`pipeline::link::geometry`).
|
||||
if !f.fragment.barycentric && !f.fragment.geometry_shader {
|
||||
out.push(Unsupported::needs_any_of(
|
||||
// `[[barycentric_coord]]`: the device's builtins.
|
||||
if !f.fragment.barycentric {
|
||||
out.push(Unsupported::needs(
|
||||
Feature::Barycentrics,
|
||||
vec![
|
||||
vec![feature(VkFeature::FragmentShaderBarycentric)],
|
||||
vec![feature(VkFeature::GeometryShader)],
|
||||
],
|
||||
feature(VkFeature::FragmentShaderBarycentric),
|
||||
));
|
||||
}
|
||||
for stage in [Stage::Vertex, Stage::Fragment, Stage::Kernel] {
|
||||
|
||||
@@ -643,10 +643,6 @@ pub enum VkProperty {
|
||||
/// that hands Metal's `interpolate_at_offset` to the instruction moved by 7/16 requires it in
|
||||
/// place of [`VkProperty::InterpolateAtOffsetCentered`].
|
||||
InterpolateAtOffsetFromSevenSixteenths,
|
||||
/// `subgroupSupportedStages` contains the geometry stage, which runs only the translator's
|
||||
/// own geometry stages (`pipeline::link::geometry`): a geometry module's subgroup operations
|
||||
/// require it, where a Metal stage's require [`VkProperty::SubgroupStage`].
|
||||
SubgroupGeometryStage,
|
||||
}
|
||||
|
||||
/// One depth or stencil resolve mode (`VkResolveModeFlagBits`), named by
|
||||
|
||||
@@ -265,8 +265,6 @@ fn every_fact() -> Vec<RuntimeFact> {
|
||||
RuntimeFact::MovableStorageWrites {
|
||||
early_variant: true,
|
||||
},
|
||||
RuntimeFact::SynthesizedGeometry { weights: true },
|
||||
RuntimeFact::SynthesizedGeometry { weights: false },
|
||||
RuntimeFact::ObjectThreadgroupArena {
|
||||
static_bytes: 16,
|
||||
payload: Some(64),
|
||||
@@ -358,7 +356,6 @@ fn variant(f: &RuntimeFact) -> usize {
|
||||
RuntimeFact::AnisotropicSampler { .. } => 80,
|
||||
RuntimeFact::StorageTextureIntegerChannels { .. } => 81,
|
||||
RuntimeFact::MovableStorageWrites { .. } => 83,
|
||||
RuntimeFact::SynthesizedGeometry { .. } => 84,
|
||||
RuntimeFact::ObjectThreadgroupArena { .. } => 85,
|
||||
RuntimeFact::WordInputMerge { .. } => 87,
|
||||
RuntimeFact::ReplayBindings => 88,
|
||||
@@ -377,13 +374,13 @@ fn variant(f: &RuntimeFact) -> usize {
|
||||
RuntimeFact::RegionViewports => 96,
|
||||
RuntimeFact::CallThreadgroups => 97,
|
||||
RuntimeFact::PartialThreadgroups => 98,
|
||||
RuntimeFact::TexelRows { .. } => 99,
|
||||
RuntimeFact::TexelRows { .. } => 84,
|
||||
RuntimeFact::UnitAxes { .. } => 57,
|
||||
RuntimeFact::TexelBufferParts { .. } => 70,
|
||||
RuntimeFact::OpenClLineTexture { .. } => 74,
|
||||
RuntimeFact::AddressAlignment { .. } => 71,
|
||||
RuntimeFact::GridTiles => 55,
|
||||
RuntimeFact::PrivateArena { .. } => 100,
|
||||
RuntimeFact::PrivateArena { .. } => 99,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,7 +388,7 @@ fn variant(f: &RuntimeFact) -> usize {
|
||||
fn mechanism_is_total_over_every_fact_and_profile() {
|
||||
let facts = every_fact();
|
||||
let covered: std::collections::BTreeSet<usize> = facts.iter().map(variant).collect();
|
||||
assert_eq!(covered, (0..101).collect(), "every_fact misses a variant");
|
||||
assert_eq!(covered, (0..100).collect(), "every_fact misses a variant");
|
||||
for (stem, _) in super::committed_profiles() {
|
||||
let dev = device(&stem);
|
||||
let p = dev.profile();
|
||||
@@ -528,9 +525,7 @@ fn mechanism_is_total_over_every_fact_and_profile() {
|
||||
| RuntimeFact::ViewportCount
|
||||
| RuntimeFact::PrivateArena { .. } => Mechanism::PushConstant,
|
||||
RuntimeFact::AliasedImageblock { .. } => Mechanism::None,
|
||||
RuntimeFact::CallStackDepth { .. }
|
||||
| RuntimeFact::OpenClMode
|
||||
| RuntimeFact::SynthesizedGeometry { .. } => Mechanism::None,
|
||||
RuntimeFact::CallStackDepth { .. } | RuntimeFact::OpenClMode => Mechanism::None,
|
||||
};
|
||||
assert_eq!(m, expected, "{stem}: {fact:?}");
|
||||
}
|
||||
|
||||
@@ -221,13 +221,8 @@ pub const fn shape(f: PushField) -> FieldShape {
|
||||
| PushField::PatchIndexOffset
|
||||
| PushField::PatchIndexBound
|
||||
| PushField::ControlPointIndexOffset => FieldShape::U32,
|
||||
// The row of regions a recording of a rate-mapped pass's regions draws: its first region's
|
||||
// segments of x and y.
|
||||
PushField::RegionBox => FieldShape::UVec2,
|
||||
// A band's viewport half extent and half width, four `f32`s.
|
||||
PushField::LineBand => FieldShape::UVec4Array(1),
|
||||
// A fan-out probe's flag index.
|
||||
PushField::RegionProbe => FieldShape::U32,
|
||||
// The whole indices from the bound index offset to the buffer's end, unsaturated:
|
||||
// `firstIndex + indexCount` reaches `2^33`.
|
||||
PushField::IndexCapacity => FieldShape::U64,
|
||||
|
||||
@@ -22,10 +22,8 @@
|
||||
//! enabling capabilities the profile enables (`requirements::builtin_enablers`);
|
||||
//! `[[barycentric_coord]]` reads `BaryCoordKHR` or `BaryCoordNoPerspKHR`, a `float` or `float2`
|
||||
//! its leading lanes, a `float3` its first two lanes and `1 - (x + y)` of them as the third,
|
||||
//! Metal's third weight. On a device without `fragmentShaderBarycentric` it reads the first two
|
||||
//! lanes from a `float2` center varying of its perspective (`IoRole::Barycentric`) that the
|
||||
//! pipeline's synthesized geometry stage writes (`link::geometry`), read at the pixel center
|
||||
//! as a center varying is, the same way.
|
||||
//! Metal's third weight. On a device without `fragmentShaderBarycentric` it is refused needing
|
||||
//! the feature.
|
||||
//! - On a device that enables neither of `PrimitiveId`'s capabilities (`geometryShader`,
|
||||
//! `tessellationShader`), `[[primitive_id]]` reads a flat `uint` varying (`IoRole::PrimitiveId`)
|
||||
//! that the pipeline's vertex function, compiled under `LoweringInputs::primitive_id_varying`,
|
||||
@@ -107,13 +105,6 @@
|
||||
//! through more than one variant of its pipeline (each color group's) rasterizes the same
|
||||
//! positions in each.
|
||||
//!
|
||||
//! A vertex function compiled under `LoweringInputs::region_copies` stores its region's copy at
|
||||
//! every return ([`RegionCopy`]): the region of segments `(x0 + DrawIndex, y0)` of the region
|
||||
//! table, `[x0, y0]` its `PushField::RegionBox`, its position through the region's line and four
|
||||
//! clip distances after its own, by the emitter a fan-out stage's copies share
|
||||
//! (`pipeline::link::fan_out::region_copy`), and 0 as `ViewportIndex`, the recording's one
|
||||
//! viewport; those clip distances are `Invariant` too.
|
||||
//!
|
||||
//! A fragment function compiled for a render pipeline that rasterizes more than one sample
|
||||
//! (`LoweringInputs::multisampled`) reads what Metal reads at the pixel center in every invocation
|
||||
//! there ([`Source::PixelCenter`]): `[[position]]`'s x and y as `floor(FragCoord.xy) + 0.5`, and,
|
||||
@@ -359,18 +350,6 @@ pub struct RegionViewport {
|
||||
pub viewport: usize,
|
||||
}
|
||||
|
||||
/// The region's copy a vertex function compiled under `LoweringInputs::region_copies` stores
|
||||
/// (`plan::region_copy`): interface objects `position`, its `Position` output, `draw_index`, the
|
||||
/// `DrawIndex` input, `viewport`, the `ViewportIndex` output it stores 0 to, and `clip`, its
|
||||
/// `ClipDistance` object and the first of the four elements it writes after its own.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct RegionCopy {
|
||||
pub position: usize,
|
||||
pub draw_index: usize,
|
||||
pub viewport: usize,
|
||||
pub clip: (usize, u32),
|
||||
}
|
||||
|
||||
/// The private alpha test a fragment function compiled under `LoweringInputs::alpha_test` runs
|
||||
/// at each return ([`alpha_test`]): the returned field of its color 0, four `float` lanes (a
|
||||
/// `half` output held widened), and the comparison.
|
||||
@@ -400,10 +379,6 @@ pub struct StageIoPlan {
|
||||
/// A vertex function compiled under `LoweringInputs::region_viewports` that returns outputs:
|
||||
/// its `DrawIndex` input, which it stores to its `ViewportIndex` output at every return.
|
||||
pub region_viewport: Option<RegionViewport>,
|
||||
/// A vertex function compiled under `LoweringInputs::region_copies` that returns outputs: the
|
||||
/// region's copy it stores at every return, its position through the region's line and four
|
||||
/// clip distances keeping the region's pixels.
|
||||
pub region_copy: Option<RegionCopy>,
|
||||
/// The color outputs a fragment function compiled under `LoweringInputs::zeroed_colors`
|
||||
/// stores zero to at every return, one per such color.
|
||||
pub zeroed: Vec<Link>,
|
||||
@@ -617,9 +592,6 @@ pub struct Declared {
|
||||
/// covered samples is read into at every sample before the loop, where the driver's
|
||||
/// interpolation needs the whole quad ([`read_at_every_sample`]).
|
||||
pub at_samples: BTreeMap<usize, GlobalId>,
|
||||
/// The region table a vertex function that stores its region's copy reads
|
||||
/// ([`StageIoPlan::region_copy`]).
|
||||
pub region_table: Option<GlobalId>,
|
||||
}
|
||||
|
||||
/// Plan the entry's stage interface: its outputs and execution modes. A kernel has none (and a
|
||||
@@ -1111,8 +1083,8 @@ fn one_less_sum(fb: &mut FunctionBuilder<'_>, x: SValue, y: SValue) -> BResult<S
|
||||
}
|
||||
|
||||
/// The three barycentric weights of `x`, a `float3` (`BaryCoordKHR`) or `float2`
|
||||
/// (`IoRole::Barycentric`, or [`rotated_weights`]') whose first two lanes are the first two
|
||||
/// weights: those, and `1 - (x + y)` as the third, Metal's (`plan::input_builtin`).
|
||||
/// ([`rotated_weights`]') whose first two lanes are the first two weights: those, and
|
||||
/// `1 - (x + y)` as the third, Metal's (`plan::input_builtin`).
|
||||
fn weights(fb: &mut FunctionBuilder<'_>, x: SValue) -> BResult<SValue> {
|
||||
let f32_ty = fb.module().ty(SType::Float { width: 32 })?;
|
||||
let ty = fb.module().ty(SType::Vector {
|
||||
@@ -1786,7 +1758,6 @@ pub fn emit_return(
|
||||
let plan = &cx.plan.families.stage_io;
|
||||
let (outputs, returned, point) = (plan.outputs.clone(), plan.returned, plan.point_size_default);
|
||||
let seconds = plan.rotated_seconds.clone();
|
||||
let region_copy = plan.region_copy;
|
||||
let depth_clamp = plan.depth_clamp;
|
||||
let primitive_id = plan.primitive_id;
|
||||
// The private masks: the pixel's ANDed into the function's own `[[sample_mask]]` output
|
||||
@@ -1815,10 +1786,6 @@ pub fn emit_return(
|
||||
true => metal_point_size(fb, part)?,
|
||||
false => part,
|
||||
};
|
||||
let part = match region_copy.filter(|r| r.position == o.link.object) {
|
||||
Some(r) => store_region_copy(cx, fb, r, part)?,
|
||||
None => part,
|
||||
};
|
||||
let part = match depth_clamp.filter(|d| d.object == o.link.object) {
|
||||
Some(d) => {
|
||||
let kill = nan_drop(cx)?;
|
||||
@@ -2322,61 +2289,6 @@ fn rotated_second(
|
||||
fb.vector_shuffle(first, constants, &lanes)
|
||||
}
|
||||
|
||||
/// `position`, a vertex function's `float4` position, as its region's copy (`r`,
|
||||
/// `LoweringInputs::region_copies`): the region of segments `(x0 + DrawIndex, y0)` of the region
|
||||
/// table, `[x0, y0]` its `PushField::RegionBox` (a draw of a row's regions in order), its position
|
||||
/// through the region's line and its four clip distances stored after the function's own, by the
|
||||
/// emitter a fan-out stage's copies share (`pipeline::link::fan_out::region_copy`), and 0 stored
|
||||
/// as `ViewportIndex`, the recording's one viewport (the routes' agreement is checked with these
|
||||
/// outputs, `ViewportIndex` among them: `bind::fan_out`, **One route per pass**). The clip
|
||||
/// distances alone keep the copy to its region's pixels, as a fan-out stage's copies' do: the
|
||||
/// recording's scissor is its row's.
|
||||
fn store_region_copy(
|
||||
cx: &mut EmitCx<'_>,
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
r: RegionCopy,
|
||||
position: SValue,
|
||||
) -> BResult<SValue> {
|
||||
use crate::pipeline::link::fan_out;
|
||||
let Some(table) = cx.decl.families.stage_io.region_table else {
|
||||
return Err(cx.fail("a region's copy without its region table"));
|
||||
};
|
||||
let row = cx.push_field(fb, PushField::RegionBox)?;
|
||||
let x0 = fb.composite_extract(row, &[0])?;
|
||||
let y0 = fb.composite_extract(row, &[1])?;
|
||||
let draw = fetch::load_builtin(cx, fb, r.draw_index)?;
|
||||
let segments = fan_out::row_segments(fb, [x0, y0], draw)?;
|
||||
// Viewport 0, the recording's one.
|
||||
let link = Link {
|
||||
object: r.viewport,
|
||||
place: Place::Whole,
|
||||
form: Form {
|
||||
held: Held::Int {
|
||||
bits: 32,
|
||||
container: 32,
|
||||
},
|
||||
lanes: 1,
|
||||
},
|
||||
};
|
||||
let zero = fb.u32_const(0)?;
|
||||
let zero = fb.module().const_value(zero)?;
|
||||
store(cx, fb, &link, zero)?;
|
||||
let f32_ = fb.module().ty(SType::Float { width: 32 })?;
|
||||
let vec4 = fb.module().ty(SType::Vector { elem: f32_, len: 4 })?;
|
||||
let terms = fan_out::region_terms(fb, (table, f32_), segments)?;
|
||||
let (moved, distances) = fan_out::region_copy(fb, &terms, position, vec4)?;
|
||||
let (object, first) = r.clip;
|
||||
let g = global(cx, object)?;
|
||||
let base = fb.module().global_value(g)?;
|
||||
for (k, d) in (first..).zip(distances) {
|
||||
let kc = fb.u32_const(k)?;
|
||||
let kc = fb.module().const_value(kc)?;
|
||||
let p = fb.access_chain(base, &[kc])?;
|
||||
fb.store(p, d, MemAccess::default())?;
|
||||
}
|
||||
Ok(moved)
|
||||
}
|
||||
|
||||
/// How a return drops a positive NaN depth, which fails Metal's depth test (`clamp_depth`).
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
enum NanDrop {
|
||||
@@ -2740,14 +2652,6 @@ pub fn declare(
|
||||
if let Some(g) = sp.invariant.and_then(|i| d.globals.get(i)) {
|
||||
mb.invariant(*g)?;
|
||||
}
|
||||
// A region's copy: its clip distances computed alike in every pipeline that draws the
|
||||
// function's region copies, as a fan-out stage's are, and the table it reads.
|
||||
if let Some(r) = sp.region_copy {
|
||||
if let Some(g) = d.globals.get(r.clip.0) {
|
||||
mb.invariant(*g)?;
|
||||
}
|
||||
d.region_table = Some(crate::pipeline::link::fan_out::declare_table(mb)?);
|
||||
}
|
||||
modes.extend(sp.modes.iter().copied());
|
||||
Ok(d)
|
||||
}
|
||||
@@ -91,7 +91,7 @@ pub enum Place {
|
||||
Spread(u32),
|
||||
/// A read of this many (1 to 3) leading lanes of Metal's three barycentric weights, of a
|
||||
/// variable whose first two lanes are the first two weights of the primitive as drawn
|
||||
/// (`BaryCoordKHR`, or the `float2` of `IoRole::Barycentric`): `1 - (x + y)` of the first
|
||||
/// (`BaryCoordKHR`): `1 - (x + y)` of the first
|
||||
/// two is Metal's third weight (see `input_builtin`). Where `rotated`
|
||||
/// (`LoweringInputs::rotated_weights`), the primitive is a triangle drawn with Metal's last
|
||||
/// vertex first, `(c, a, b)` for Metal's `(a, b, c)`, so Metal's first two weights are the
|
||||
@@ -909,43 +909,16 @@ pub fn param(cx: &mut SelectCx<'_>, b: &ParamBinding) -> Result<(), Error> {
|
||||
{
|
||||
return draw_base(cx, b, ty, DrawBase::Instance);
|
||||
}
|
||||
// Without `fragmentShaderBarycentric`, the weights are the `float2` varying of their form
|
||||
// that the pipeline's synthesized geometry stage writes (`IoRole::Barycentric`,
|
||||
// `link::geometry`): `(1, 0)`, `(0, 1)` and `(0, 0)` at the primitive's vertices in its
|
||||
// order, whose interpolation is Metal's first two weights, read at the pixel center as a
|
||||
// center varying is.
|
||||
(ParamRole::Builtin(Builtin::BarycentricCoord(i)), Stage::Fragment)
|
||||
// Without `fragmentShaderBarycentric` the weights have no form: the device's builtin is
|
||||
// the one way to read them.
|
||||
(ParamRole::Builtin(Builtin::BarycentricCoord(_)), Stage::Fragment)
|
||||
if !frag.barycentric =>
|
||||
{
|
||||
refuse_int64_interface(cx.entry, ty)?;
|
||||
let f = form_on(cx.entry, cx.profile, ty)?;
|
||||
let (perspective, place) = barycentric_read(*i, f, cx.inputs.rotated_weights)?;
|
||||
if !frag.geometry_shader {
|
||||
return Err(Unsupported::needs_any_of(
|
||||
Feature::Barycentrics,
|
||||
vec![
|
||||
vec![Capability::Feature(VkFeature::FragmentShaderBarycentric)],
|
||||
vec![Capability::Feature(VkFeature::GeometryShader)],
|
||||
],
|
||||
)
|
||||
.into());
|
||||
}
|
||||
let interp = Interpolation::Smooth {
|
||||
sampling: Sampling::Center,
|
||||
perspective,
|
||||
};
|
||||
note_device_interpolation(cx, interp);
|
||||
let center = cx.inputs.multisampled;
|
||||
at_pixel = center && interpolation_functions(cx);
|
||||
let sp = &mut cx.families.stage_io;
|
||||
sp.interface.varyings_at_pixel |= at_pixel;
|
||||
let object = barycentric_weights(sp, perspective)?;
|
||||
note_rotated_weights(cx, place);
|
||||
Link {
|
||||
object,
|
||||
place,
|
||||
form: f,
|
||||
}
|
||||
return Err(Unsupported::needs(
|
||||
Feature::Barycentrics,
|
||||
Capability::Feature(VkFeature::FragmentShaderBarycentric),
|
||||
)
|
||||
.into());
|
||||
}
|
||||
(ParamRole::Builtin(bi), _) => {
|
||||
refuse_int64_interface(cx.entry, ty)?;
|
||||
@@ -1604,35 +1577,6 @@ fn primitive_id_output(cx: &mut SelectCx<'_>) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The barycentric weights' `float2` input of form `perspective` (`IoRole::Barycentric`): a
|
||||
/// center-sampled varying, perspective-correct or not, which the pipeline's synthesized geometry
|
||||
/// stage writes.
|
||||
fn barycentric_weights(sp: &mut StageIoPlan, perspective: bool) -> Result<usize, Error> {
|
||||
let key = VaryingKey::barycentric(perspective);
|
||||
let ty = IoType {
|
||||
numeric: IoNumeric::Float,
|
||||
components: 2,
|
||||
source_bits: 32,
|
||||
};
|
||||
let deco = IoDecor {
|
||||
interpolation: if perspective {
|
||||
SInterp::Smooth
|
||||
} else {
|
||||
SInterp::NoPerspective
|
||||
},
|
||||
..IoDecor::default()
|
||||
};
|
||||
push_var(
|
||||
&mut sp.interface.inputs,
|
||||
IoVariable {
|
||||
key: key.clone(),
|
||||
role: IoRole::Barycentric { perspective },
|
||||
ty,
|
||||
},
|
||||
);
|
||||
user(sp, key, IoDir::Input, ty, deco)
|
||||
}
|
||||
|
||||
/// The perspective and place of a `[[barycentric_coord]]` read of interpolation `i` into form
|
||||
/// `f`, of a triangle drawn with Metal's last vertex first where `rotated`
|
||||
/// (`LoweringInputs::rotated_weights`). Metal declares the weights at the pixel center (MSL
|
||||
@@ -1984,7 +1928,7 @@ fn input_builtin(
|
||||
// triangle drawn with Metal's last vertex first takes them rotated back
|
||||
// (`LoweringInputs::rotated_weights`).
|
||||
let (perspective, place) = barycentric_read(i, f, cx.inputs.rotated_weights)?;
|
||||
// `param` reads the weights from a varying without `fragmentShaderBarycentric`.
|
||||
// `param` refuses the weights without `fragmentShaderBarycentric`.
|
||||
if !frag.barycentric {
|
||||
return Err(cx.invariant("a barycentric builtin without the feature"));
|
||||
}
|
||||
@@ -2447,9 +2391,6 @@ pub fn entry(cx: &mut SelectCx<'_>) -> Result<(), Error> {
|
||||
if cx.inputs.region_viewports && cx.stage == Stage::Vertex {
|
||||
region_viewport(cx, &outputs, returned)?;
|
||||
}
|
||||
if cx.inputs.region_copies && cx.stage == Stage::Vertex {
|
||||
region_copy(cx, &outputs, returned)?;
|
||||
}
|
||||
// The primitive ID a fragment function reads from its varying.
|
||||
if cx.inputs.primitive_id_varying && cx.stage == Stage::Vertex {
|
||||
primitive_id_output(cx)?;
|
||||
@@ -2711,154 +2652,6 @@ pub(crate) fn finish_merged(cx: &mut SelectCx<'_>) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Add `added` clip distances past a vertex function's own, for `feature`: its `ClipDistance`
|
||||
/// object, `added` elements longer, or a new one, and the first of the added elements. Refused as
|
||||
/// `feature` where the device writes no clip distances or the count passes its limits.
|
||||
fn added_clip_distances(
|
||||
cx: &mut SelectCx<'_>,
|
||||
added: u32,
|
||||
feature: Feature,
|
||||
) -> Result<(usize, u32), Error> {
|
||||
if !cx.profile.fields().fragment.clip_distance {
|
||||
return Err(needs(feature, VkFeature::ShaderClipDistance));
|
||||
}
|
||||
let is = |o: &IoObject| {
|
||||
matches!(
|
||||
o,
|
||||
IoObject::Builtin {
|
||||
builtin: B::ClipDistance,
|
||||
dir: IoDir::Output,
|
||||
..
|
||||
}
|
||||
)
|
||||
};
|
||||
let limits = cx.profile.fields().limits;
|
||||
let sp = &mut cx.families.stage_io;
|
||||
let own = sp.objects.iter().position(is);
|
||||
let first = match own.and_then(|i| sp.objects.get(i)) {
|
||||
Some(IoObject::Builtin {
|
||||
shape: Shape::F32Array(n),
|
||||
..
|
||||
}) => *n,
|
||||
Some(_) => return Err(not_lowered()),
|
||||
None => 0,
|
||||
};
|
||||
let count = first + added;
|
||||
for (lim, max) in [
|
||||
(VkLimit::MaxClipDistances, limits.max_clip_distances),
|
||||
(
|
||||
VkLimit::MaxCombinedClipAndCullDistances,
|
||||
limits.max_combined_clip_and_cull_distances,
|
||||
),
|
||||
] {
|
||||
if count > max {
|
||||
return Err(limit(feature, lim, u64::from(count), max));
|
||||
}
|
||||
}
|
||||
let object = match own {
|
||||
// The function's own clip distances, `added` elements longer.
|
||||
Some(i) => {
|
||||
if let Some(IoObject::Builtin { shape, .. }) = sp.objects.get_mut(i) {
|
||||
*shape = Shape::F32Array(count);
|
||||
}
|
||||
let builtins = &mut sp.interface.builtins;
|
||||
builtins.retain(|b| !matches!(b, StageBuiltin::ClipDistance { .. }));
|
||||
builtins.push(StageBuiltin::ClipDistance { count });
|
||||
builtins.sort();
|
||||
i
|
||||
}
|
||||
None => builtin(
|
||||
sp,
|
||||
B::ClipDistance,
|
||||
IoDir::Output,
|
||||
Shape::F32Array(count),
|
||||
StageBuiltin::ClipDistance { count },
|
||||
),
|
||||
};
|
||||
Ok((object, first))
|
||||
}
|
||||
|
||||
/// Plan the region's copy a vertex function with outputs `outputs`, returning `returned`,
|
||||
/// compiled under `LoweringInputs::region_copies`, stores at every return: the region of segments
|
||||
/// `(x0 + DrawIndex, y0)` of the region table (`PushField::RegionBox`'s `[x0, y0]`, the
|
||||
/// specification's `DrawIndex`, 0 for a draw that is no multi-draw's), its position moved
|
||||
/// by the region's line and four clip distances past its own keeping the region's pixels
|
||||
/// ([`super::RegionCopy`], `pipeline::link::fan_out::region_copy`), and 0 as `ViewportIndex`,
|
||||
/// the recording's one viewport. A merged draw's vertex function (`merged_draws`) takes it too:
|
||||
/// its corner is its `VertexIndex` and `InstanceIndex`'s, which a multi-draw's draws each give
|
||||
/// from their own first vertex, and its region its `DrawIndex`'s; so does a draw replay's of one
|
||||
/// draw per command (`replay_bindings`), whose buffers are in the slot table at its push. A
|
||||
/// function that writes its own viewport or slice index, one under another field that moves its
|
||||
/// indices or position (`amplification_draws`), runs behind the
|
||||
/// tessellator or returns no outputs is `NotImplemented(RasterizationRateMap)`: the runtime draws those through each
|
||||
/// region's viewport. A device that cannot store `ViewportIndex` from a vertex function, read
|
||||
/// `DrawIndex` or write four more clip distances refuses it.
|
||||
fn region_copy(
|
||||
cx: &mut SelectCx<'_>,
|
||||
outputs: &[OutputBinding],
|
||||
returned: Returned,
|
||||
) -> Result<(), Error> {
|
||||
let i = &cx.inputs;
|
||||
let indexed = outputs.iter().any(|o| {
|
||||
matches!(
|
||||
o.role,
|
||||
OutputRole::ViewportArrayIndex | OutputRole::RenderTargetArrayIndex
|
||||
)
|
||||
});
|
||||
let tessellated = matches!(cx.entry.ep.stage, AirStage::Vertex { patch: Some(_) });
|
||||
let sp = &cx.families.stage_io;
|
||||
let position = sp.objects.iter().position(|o| {
|
||||
matches!(
|
||||
o,
|
||||
IoObject::Builtin {
|
||||
builtin: B::Position,
|
||||
dir: IoDir::Output,
|
||||
..
|
||||
}
|
||||
)
|
||||
});
|
||||
let position = match position {
|
||||
Some(p) if returned != Returned::Void => p,
|
||||
_ => return Err(Unsupported::not_implemented(Feature::RasterizationRateMap).into()),
|
||||
};
|
||||
if indexed || tessellated || i.amplification_draws.is_some() || i.region_viewports {
|
||||
return Err(Unsupported::not_implemented(Feature::RasterizationRateMap).into());
|
||||
}
|
||||
let f = cx.profile.fields();
|
||||
if !(f.fragment.output_viewport_index && f.draw_parameters) {
|
||||
return Err(Unsupported::needs_any_of(
|
||||
Feature::RasterizationRateMap,
|
||||
vec![vec![
|
||||
Capability::Feature(VkFeature::ShaderOutputViewportIndex),
|
||||
Capability::Feature(VkFeature::ShaderDrawParameters),
|
||||
]],
|
||||
)
|
||||
.into());
|
||||
}
|
||||
let clip = added_clip_distances(cx, 4, Feature::RasterizationRateMap)?;
|
||||
cx.push.insert(PushField::RegionBox);
|
||||
// The region table, one more storage buffer of the stage.
|
||||
let d = &mut cx.descriptors;
|
||||
d.storage_buffers = d.storage_buffers.saturating_add(1);
|
||||
let sp = &mut cx.families.stage_io;
|
||||
let draw_index = builtin(
|
||||
sp,
|
||||
B::DrawIndex,
|
||||
IoDir::Input,
|
||||
Shape::U32,
|
||||
StageBuiltin::DrawIndex,
|
||||
);
|
||||
// Not the contract's `ViewportIndex`, as a region viewport's is not (`region_viewport`).
|
||||
let viewport = builtin_object(sp, B::ViewportIndex, IoDir::Output, Shape::U32);
|
||||
sp.region_copy = Some(super::RegionCopy {
|
||||
position,
|
||||
draw_index,
|
||||
viewport,
|
||||
clip,
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Plan one output of AIR type `ty`.
|
||||
fn output(cx: &mut SelectCx<'_>, o: &OutputBinding, ty: AirTypeId) -> Result<Link, Error> {
|
||||
// A shared output (`air.shared`) has the same value for every amplification; each view
|
||||
|
||||
@@ -272,7 +272,6 @@ mod serde_round_trips {
|
||||
anisotropic_samplers: BTreeSet::from([slot(Stage::Fragment, SlotClass::Sampler, 1)]),
|
||||
open_cl_lines: BTreeSet::from([slot(Stage::Kernel, SlotClass::Texture, 1)]),
|
||||
region_viewports: true,
|
||||
region_fan_out: Some(crate::pipeline::RegionFanOut::Probe),
|
||||
});
|
||||
round_trip(&SpecializationKey {
|
||||
data: vec![1, 0, 0, 0],
|
||||
@@ -477,7 +476,6 @@ mod serde_round_trips {
|
||||
instanced_attributes: BTreeSet::from([1]),
|
||||
object_payload: Some(64),
|
||||
region_viewports: true,
|
||||
region_copies: true,
|
||||
unit_axes: 2,
|
||||
push_base: 24,
|
||||
});
|
||||
@@ -630,11 +628,6 @@ mod serde_round_trips {
|
||||
push_offset: 112,
|
||||
primitive: crate::pipeline::BandPrimitive::Triangles,
|
||||
}),
|
||||
region_fan_out: Some(crate::pipeline::FanOutState {
|
||||
mode: crate::pipeline::RegionFanOut::Probe,
|
||||
copies: 7,
|
||||
push_offset: 116,
|
||||
}),
|
||||
});
|
||||
let mut slots = BTreeMap::new();
|
||||
slots.insert(
|
||||
@@ -989,7 +982,6 @@ mod bind_serde_round_trips {
|
||||
private_list: true,
|
||||
far_vertex_buffers: BTreeSet::from([2]),
|
||||
region_viewports: true,
|
||||
region_fan_out: Some((crate::pipeline::RegionFanOut::Probe, 9)),
|
||||
});
|
||||
let mut shape = StageShape::default();
|
||||
shape.buffers.insert(
|
||||
@@ -1051,7 +1043,6 @@ mod bind_serde_round_trips {
|
||||
private_list: true,
|
||||
far_vertex_buffers: BTreeSet::from([1, 30]),
|
||||
region_viewports: true,
|
||||
region_fan_out: Some(crate::pipeline::RegionFanOut::Draw),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -26,11 +26,7 @@ pub struct RenderPipeline {
|
||||
pub profile: Hash256,
|
||||
/// Vertex, then fragment when rasterization is enabled. A post-tessellation vertex function's
|
||||
/// pipeline has the synthesized vertex and tessellation control stages, then its evaluation
|
||||
/// stage, then the fragment stage. A pipeline whose fragment function reads
|
||||
/// `[[barycentric_coord]]` on a device without `fragmentShaderBarycentric` has three
|
||||
/// synthesized geometry stages before its fragment stage, or last without one, for the point,
|
||||
/// line and triangle topology classes in that order: a `VkPipeline` runs only the one of its
|
||||
/// draw's class ([`runs_stage`](Self::runs_stage)).
|
||||
/// stage, then the fragment stage.
|
||||
pub stages: Vec<StageModule>,
|
||||
pub layout: PipelineLayout,
|
||||
pub vertex_input: VertexInputState,
|
||||
@@ -44,31 +40,6 @@ pub struct RenderPipeline {
|
||||
}
|
||||
|
||||
impl RenderPipeline {
|
||||
/// Whether a `VkPipeline` drawing `topology` runs stage `at` of
|
||||
/// [`stages`](Self::stages): every stage but a geometry stage of another topology class (a
|
||||
/// pipeline's geometry stages are the point, line and triangle classes' in that order). A
|
||||
/// stage past the list runs nothing.
|
||||
pub fn runs_stage(&self, at: usize, topology: vk::PrimitiveTopology) -> bool {
|
||||
use vk::PrimitiveTopology as T;
|
||||
let Some(stage) = self.stages.get(at) else {
|
||||
return false;
|
||||
};
|
||||
if stage.stage != vk::ShaderStage::GEOMETRY {
|
||||
return true;
|
||||
}
|
||||
let class = match topology {
|
||||
T::POINT_LIST => 0,
|
||||
T::LINE_LIST | T::LINE_STRIP => 1,
|
||||
T::TRIANGLE_LIST | T::TRIANGLE_STRIP | T::TRIANGLE_FAN => 2,
|
||||
_ => return false,
|
||||
};
|
||||
let nth = self.stages[..at]
|
||||
.iter()
|
||||
.filter(|s| s.stage == vk::ShaderStage::GEOMETRY)
|
||||
.count();
|
||||
nth == class
|
||||
}
|
||||
|
||||
/// The bytes this pipeline keeps live: its own storage, its stages' and its dependencies',
|
||||
/// and each stage's SPIR-V words, constant blob, entry point, specialization constants,
|
||||
/// notes and attachment lists.
|
||||
|
||||
@@ -52,7 +52,6 @@ use crate::pipeline::descriptor::{
|
||||
};
|
||||
use crate::pipeline::facts::RuntimeFact;
|
||||
use crate::pipeline::graphics::{GraphicsState, StorageAttachmentView};
|
||||
use crate::pipeline::link::geometry;
|
||||
use crate::pipeline::link::tessellation::{note_evaluation_stage, synthesized_stages};
|
||||
use crate::pipeline::link::{link, LinkInputs, Linked, RenderLinkInputs};
|
||||
use crate::pipeline::lower_inputs::LoweringInputs;
|
||||
@@ -948,21 +947,6 @@ impl Device {
|
||||
all.extend(stages);
|
||||
stages = all;
|
||||
}
|
||||
// A fragment function that reads `[[barycentric_coord]]` as varyings, or a fan-out variant:
|
||||
// the geometry stages of the point, line and triangle classes, before the fragment stage,
|
||||
// or last without one.
|
||||
if let Some(g) = &linked.geometry {
|
||||
let at = stages
|
||||
.iter()
|
||||
.position(|s| s.stage == vk::ShaderStage::FRAGMENT)
|
||||
.unwrap_or(stages.len());
|
||||
let mut added = Vec::with_capacity(geometry::CLASSES.len());
|
||||
for (module, r) in g.stages(&linked, p, m)? {
|
||||
requirements = p.union_requirements(&requirements, &r);
|
||||
added.push(module);
|
||||
}
|
||||
stages.splice(at..at, added);
|
||||
}
|
||||
// A variant that draws its lines as bands: the band's control and evaluation stages,
|
||||
// right after the vertex stage.
|
||||
if let Some(band) = &linked.band {
|
||||
@@ -977,18 +961,7 @@ impl Device {
|
||||
}
|
||||
stages.splice(at..at, added);
|
||||
}
|
||||
let mut dependencies = dependencies(&artifacts, self);
|
||||
// A fan-out variant's stages are the consumer's choice of how to draw its rate-mapped
|
||||
// pass, which its graphics state states (`GraphicsState::region_fan_out`).
|
||||
if let Some(g) = linked.geometry.as_ref().filter(|g| g.fan_out.is_none()) {
|
||||
let fact = RuntimeFact::SynthesizedGeometry {
|
||||
weights: !g.forms.is_empty(),
|
||||
};
|
||||
dependencies.push(RuntimeDependency {
|
||||
fact,
|
||||
mechanism: mechanism(&fact, self.profile()),
|
||||
});
|
||||
}
|
||||
let dependencies = dependencies(&artifacts, self);
|
||||
let (mut graphics, requirements) =
|
||||
graphics_requirements(requirements, &linked, &artifacts, p)?;
|
||||
graphics.sample_mask = crate::pipeline::private_state::sample_mask(
|
||||
@@ -1636,16 +1609,6 @@ fn variant_fields(v: &VariantKey) -> String {
|
||||
Some(crate::pipeline::BandPrimitive::Lines) => fields.push_str(" line_band"),
|
||||
Some(crate::pipeline::BandPrimitive::Triangles) => fields.push_str(" line_band triangles"),
|
||||
}
|
||||
// The fan-out's synthesized geometry stages, in no stage's key.
|
||||
match v.region_fan_out {
|
||||
None => {}
|
||||
Some(crate::pipeline::RegionFanOut::Draw) => fields.push_str(" region_fan_out"),
|
||||
Some(crate::pipeline::RegionFanOut::Probe) => fields.push_str(" region_fan_out probe"),
|
||||
Some(crate::pipeline::RegionFanOut::DrawFew) => fields.push_str(" region_fan_out few"),
|
||||
Some(crate::pipeline::RegionFanOut::RegionCopies) => {
|
||||
fields.push_str(" region_fan_out copies")
|
||||
}
|
||||
}
|
||||
fields
|
||||
}
|
||||
|
||||
@@ -1658,9 +1621,7 @@ fn render_fields(d: &RenderPipelineDescriptor) -> String {
|
||||
RenderLinkInputs::from(d),
|
||||
d.support_indirect_command_buffers
|
||||
)
|
||||
)
|
||||
// A descriptor's inputs never fan out (`variant_fields` keys a variant that does).
|
||||
.replace(", region_fan_out: None", "");
|
||||
);
|
||||
// Appended only past Metal's defaults, so a default descriptor keeps its key.
|
||||
let fields = match (
|
||||
d.max_vertex_call_stack_depth,
|
||||
|
||||
@@ -501,10 +501,6 @@ pub fn function_key(
|
||||
h.bytes(b"region-viewports");
|
||||
}
|
||||
// Appended only when set.
|
||||
if inputs.region_copies {
|
||||
h.bytes(b"region-copies");
|
||||
}
|
||||
// Appended only when set.
|
||||
if inputs.unit_axes != 0 {
|
||||
h.bytes(b"unit-axes").u64(u64::from(inputs.unit_axes));
|
||||
}
|
||||
|
||||
@@ -733,7 +733,6 @@ fn the_inputs_encoding_is_the_earlier_derived_debug() {
|
||||
.replace(", object_payload: None", "")
|
||||
.replace(", tessellation: None", "")
|
||||
.replace(", region_viewports: false", "")
|
||||
.replace(", region_copies: false", "")
|
||||
.replace(", unit_axes: 0", "")
|
||||
.replace(", push_base: 0", ""),
|
||||
"{derived}"
|
||||
|
||||
@@ -705,12 +705,6 @@ pub enum RuntimeFact {
|
||||
/// where a Vulkan write of a value the channel cannot represent is undefined. The binder
|
||||
/// writes `metal::format::integer_channels_word` of the bound format, and 0 for a neutral.
|
||||
StorageTextureIntegerChannels { slot: SlotRef },
|
||||
/// The render pipeline draws through synthesized geometry stages, one per topology class, of
|
||||
/// which a draw runs its class's (`RenderPipeline::runs_stage`): its fragment function reads
|
||||
/// `[[barycentric_coord]]` on a device without `fragmentShaderBarycentric` (`weights`)
|
||||
/// (`pipeline::link::geometry`). Each draw runs a stage Metal's draw does not, at the stage's
|
||||
/// cost, with Metal's answer; the consumer announces it. Nothing binds it.
|
||||
SynthesizedGeometry { weights: bool },
|
||||
/// An object function's `[[threadgroup(n)]]` arguments, whose lengths the render encoder sets
|
||||
/// (`setObjectThreadgroupMemoryLength:atIndex:`, the object stage's
|
||||
/// `StageTable::threadgroup_lengths`), each a `ThreadgroupMemoryLength`: the static part of
|
||||
@@ -930,7 +924,6 @@ impl RuntimeFact {
|
||||
RuntimeFact::HeapStorageReads { .. } => "HeapStorageReads",
|
||||
RuntimeFact::AnisotropicSampler { .. } => "AnisotropicSampler",
|
||||
RuntimeFact::StorageTextureIntegerChannels { .. } => "StorageTextureIntegerChannels",
|
||||
RuntimeFact::SynthesizedGeometry { .. } => "SynthesizedGeometry",
|
||||
RuntimeFact::ObjectThreadgroupArena { .. } => "ObjectThreadgroupArena",
|
||||
RuntimeFact::QuadPrimitiveIds => "QuadPrimitiveIds",
|
||||
RuntimeFact::PrivateList => "PrivateList",
|
||||
|
||||
@@ -136,11 +136,6 @@ pub struct GraphicsState {
|
||||
/// evaluation stages, then the fragment stage. `None` for every other pipeline.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub line_band: Option<LineBandState>,
|
||||
/// A render pipeline variant that draws a rate-mapped pass's triangles once, fanned out to
|
||||
/// their regions by its triangle class's geometry stage (`VariantKey::region_fan_out`,
|
||||
/// `pipeline::link::fan_out`). `None` for every other pipeline.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub region_fan_out: Option<FanOutState>,
|
||||
/// The vertex function writes `[[point_size]]` (as its compiled function's
|
||||
/// `writes_point_size` answers; a post-tessellation vertex function's is dropped and
|
||||
/// answers `false`). Metal sizes a point
|
||||
@@ -158,9 +153,7 @@ pub struct GraphicsState {
|
||||
pub writes_depth: bool,
|
||||
/// Whether the fragment function reads `[[barycentric_coord]]`, perspective-correct or not
|
||||
/// and of any width (`float`, `float2`, `float3`), from the translated fragment stage's
|
||||
/// builtins (`BaryCoordKHR`, `BaryCoordNoPerspKHR`) or, on a device without
|
||||
/// `fragmentShaderBarycentric`, its varyings, which the pipeline's synthesized geometry stages
|
||||
/// write. Metal reads the weights at the pixel center (MSL 5.2.3.4), under a `centroid` or
|
||||
/// builtins (`BaryCoordKHR`, `BaryCoordNoPerspKHR`). Metal reads the weights at the pixel center (MSL 5.2.3.4), under a `centroid` or
|
||||
/// `sample` qualifier too, and so does the stage. `false` for a pipeline without a fragment
|
||||
/// function. A primitive's weights follow the order its vertices are drawn in, so
|
||||
/// a consumer that draws them in another order can change what a draw shows where this is
|
||||
@@ -311,79 +304,6 @@ impl BandPrimitive {
|
||||
}
|
||||
}
|
||||
|
||||
/// What a fan-out variant of a render pipeline does with a rate-mapped pass's triangles
|
||||
/// (`VariantKey::region_fan_out`, `GraphicsState::region_fan_out`).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum RegionFanOut {
|
||||
/// Draw each triangle once per region it touches, at most the stage's copies.
|
||||
Draw,
|
||||
/// Draw nothing, and flag the draw whose triangles the draw cannot fan out.
|
||||
Probe,
|
||||
/// [`Draw`](Self::Draw) through a stage of at most `bind::fan_out::FEW_COPIES` copies, for a
|
||||
/// draw the probe found none of whose triangles reaches more pairs of segments.
|
||||
DrawFew,
|
||||
/// Draw the plan's regions region by region, each region's copy of each vertex computed by
|
||||
/// the vertex function as a fanned-out copy's is, the draw's index stored as `ViewportIndex`
|
||||
/// (`LoweringInputs::region_copies`): no geometry stage. A draw of a pass whose triangles a
|
||||
/// draw fans out that is not fanned out itself, so that every route of the pass puts a vertex
|
||||
/// in a region at the same position (`bind::fan_out`, **One route per pass**).
|
||||
RegionCopies,
|
||||
}
|
||||
|
||||
/// What a consumer and the binder need of a render pipeline variant that draws a rate-mapped
|
||||
/// pass's triangles once, its triangle class's geometry stage fanning each out to the regions it
|
||||
/// touches (`GraphicsState::region_fan_out`, `pipeline::link::fan_out`, `bind::fan_out` for the
|
||||
/// table).
|
||||
///
|
||||
/// Draw triangles alone, through one Vulkan viewport over the whole target and a scissor over it,
|
||||
/// with the region table (`bind::fan_out::table`, `SyntheticBinding::RateMapRegions`) of that
|
||||
/// viewport over the plan's regions bound. A draw of [`RegionFanOut::RegionCopies`] records the
|
||||
/// plan's regions a row of the table's at a time, `k` of them a recording (one draw of a
|
||||
/// `vkCmdDrawMultiEXT` or `vkCmdDrawMultiIndexedEXT` each, or a draw alone), each recording
|
||||
/// pushing its row's first region's segments of x and y, `x0` and `y0`, to its vertex function's
|
||||
/// `PushField::RegionBox`, at [`push_offset`](Self::push_offset) of its stage `VERTEX`: the
|
||||
/// vertex function draws the region of segments `(x0 + DrawIndex, y0)`, whose clip distances keep
|
||||
/// its pixels, and stores 0 as `ViewportIndex`. Such a recording sets the one viewport its
|
||||
/// pipeline takes to the one over the whole target, and the scissor of its row's pixels, the
|
||||
/// union of its regions' (`bind::fan_out::scissors`, in the table's order). A probe
|
||||
/// ([`RegionFanOut::Probe`]) draws nothing. Of
|
||||
/// the flags buffer's (`SyntheticBinding::RateMapFlags`) `bind::fan_out::PROBE_DRAW_WORDS`
|
||||
/// `u32`s from `PROBE_DRAW_WORDS·i`, `i` its pushed index (`PushField::RegionProbe`, at
|
||||
/// [`push_offset`](Self::push_offset) for stage `GEOMETRY`), it writes 1 into the first where a
|
||||
/// triangle of the draw touches more regions than [`copies`](Self::copies), or crosses `w = 0`,
|
||||
/// and raises the words after those below to that triangle's `PrimitiveId` and adds one into
|
||||
/// its flagged count, and sets the bit of its block of `bind::fan_out::BLOCK_TRIANGLES`; the
|
||||
/// consumer draws such a draw's blocks that hold a flagged triangle region by region, cut to its
|
||||
/// first and last flagged one, the others fanned out, or, where it cannot draw the draw in parts,
|
||||
/// the whole draw region by region, and counts its flagged triangles. It
|
||||
/// adds the copies the draw emits of each triangle it fans out into one of the
|
||||
/// `bind::fan_out::PROBE_COUNT_WORDS` after the flag, which the draw's work counts; and writes 1
|
||||
/// into one of the as many after those where a triangle it does not flag touches more regions
|
||||
/// than `bind::fan_out::FEW_COPIES`: a draw none of whose such words is 1 draws, or its parts
|
||||
/// fanned out draw, through its [`RegionFanOut::DrawFew`] variant. The words' layout is
|
||||
/// `bind::fan_out::PROBE_DRAW_WORDS`'s.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct FanOutState {
|
||||
/// What the variant does.
|
||||
pub mode: RegionFanOut,
|
||||
/// The most copies of a triangle its stage emits; 0 for [`RegionFanOut::RegionCopies`], which
|
||||
/// emits each vertex once.
|
||||
pub copies: u32,
|
||||
/// Byte offset of the probe's push range (`PipelineLayout::push_constants`, stage
|
||||
/// `GEOMETRY`, [`PUSH_BYTES`](Self::PUSH_BYTES)); of the vertex function's
|
||||
/// `PushField::RegionBox` in its push window for [`RegionFanOut::RegionCopies`]; 0 for a
|
||||
/// draw.
|
||||
pub push_offset: u32,
|
||||
}
|
||||
|
||||
impl FanOutState {
|
||||
/// The probe's push range's bytes: one `u32`.
|
||||
pub const PUSH_BYTES: u32 = crate::pipeline::link::fan_out::PUSH_BYTES;
|
||||
}
|
||||
|
||||
/// What a consumer and the binder need of a render pipeline variant that draws its lines, or its
|
||||
/// triangles' edges, as bands (`GraphicsState::line_band`): Apple's `setLineWidth:` at a width the
|
||||
/// device's own lines do not draw.
|
||||
@@ -452,7 +372,6 @@ impl GraphicsState {
|
||||
storage_attachments: Vec::new(),
|
||||
shadow_stencil: None,
|
||||
line_band: None,
|
||||
region_fan_out: None,
|
||||
writes_point_size: false,
|
||||
writes_depth: false,
|
||||
reads_barycentric_coord: false,
|
||||
|
||||
@@ -55,8 +55,8 @@ pub struct DescriptorBinding {
|
||||
/// The most variables one stage's entry point uses at the binding (those its `OpEntryPoint`
|
||||
/// lists): a function that reaches a buffer through several types uses a variable of each
|
||||
/// type at the buffer's binding (each `Aliased` where it is writable). 0 where only a stage
|
||||
/// the pipeline adds at its creation uses it (a tessellation pipeline's control stage, a
|
||||
/// synthesized geometry stage), whose module the layout does not see, or no stage uses it. A
|
||||
/// the pipeline adds at its creation uses it (a tessellation pipeline's control stage), whose
|
||||
/// module the layout does not see, or no stage uses it. A
|
||||
/// translator from SPIR-V to another language may handle a binding of several variables
|
||||
/// apart: MoltenVK 1.4.1's SPIRV-Cross writes Metal that does not compile for a dynamic buffer
|
||||
/// binding of more than one.
|
||||
|
||||
@@ -50,9 +50,7 @@
|
||||
|
||||
pub mod band;
|
||||
pub mod contract;
|
||||
pub mod fan_out;
|
||||
pub mod fetch;
|
||||
pub mod geometry;
|
||||
pub mod graphics;
|
||||
pub mod imageblock;
|
||||
pub mod mesh;
|
||||
@@ -154,7 +152,6 @@ impl LinkInputs {
|
||||
r.pulled_vertex_buffers = variant.pulled_vertex_buffers.clone();
|
||||
r.pull_every = variant.primitive_id_indices.is_some() || variant.private_list;
|
||||
r.line_band = variant.line_band;
|
||||
r.region_fan_out = variant.region_fan_out;
|
||||
LinkInputs::Render(Box::new(r))
|
||||
}
|
||||
|
||||
@@ -196,10 +193,6 @@ pub struct RenderLinkInputs {
|
||||
/// tessellation stages (`VariantKey::line_band`, [`band`]), each patch one primitive of this
|
||||
/// kind; `None` for every other variant.
|
||||
pub line_band: Option<crate::pipeline::BandPrimitive>,
|
||||
/// The variant draws a rate-mapped pass's triangles once, its triangle class's geometry stage
|
||||
/// fanning each out to its regions (`VariantKey::region_fan_out`, [`fan_out`]); `None` for
|
||||
/// every other variant.
|
||||
pub region_fan_out: Option<crate::pipeline::RegionFanOut>,
|
||||
}
|
||||
|
||||
impl RenderLinkInputs {
|
||||
@@ -221,7 +214,6 @@ impl RenderLinkInputs {
|
||||
tessellation: None,
|
||||
texture_write_rounding_mode: metal::TextureWriteRoundingMode::TowardZero,
|
||||
line_band: None,
|
||||
region_fan_out: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -250,7 +242,6 @@ impl From<&RenderPipelineDescriptor> for RenderLinkInputs {
|
||||
tessellation: d.tessellation,
|
||||
texture_write_rounding_mode: d.texture_write_rounding_mode,
|
||||
line_band: None,
|
||||
region_fan_out: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -298,9 +289,6 @@ pub struct Linked {
|
||||
/// The synthesized control stage of a tessellation pipeline, with its push fields placed: the
|
||||
/// compile API builds its vertex and control stages from it.
|
||||
pub control: Option<tessellation::control::Control>,
|
||||
/// The synthesized geometry stages of a render pipeline whose fragment function reads
|
||||
/// `[[barycentric_coord]]` as varyings ([`geometry`]): the compile API builds them.
|
||||
pub geometry: Option<geometry::GeometryStages>,
|
||||
/// The synthesized control and evaluation stages of a render pipeline variant that draws its
|
||||
/// lines as bands ([`band`]), with their push range placed: the compile API builds them.
|
||||
pub band: Option<band::LineBand>,
|
||||
@@ -360,34 +348,13 @@ pub fn link(
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
// A fragment function that reads `[[barycentric_coord]]` as varyings draws through
|
||||
// synthesized geometry stages, which write them.
|
||||
let geometry = match inputs {
|
||||
LinkInputs::Render(r) => geometry::plan(
|
||||
&ifaces,
|
||||
r.input_primitive_topology,
|
||||
r.max_vertex_amplification_count,
|
||||
false,
|
||||
r.region_fan_out,
|
||||
p,
|
||||
)?,
|
||||
LinkInputs::Mesh(r) => geometry::plan(
|
||||
&ifaces,
|
||||
r.input_primitive_topology,
|
||||
r.max_vertex_amplification_count,
|
||||
true,
|
||||
r.region_fan_out,
|
||||
p,
|
||||
)?,
|
||||
LinkInputs::Standalone | LinkInputs::Compute => None,
|
||||
};
|
||||
// A variant that draws its lines, or its triangles' edges, as bands draws them through
|
||||
// synthesized tessellation stages.
|
||||
let band = match inputs {
|
||||
LinkInputs::Render(r) => match r.line_band {
|
||||
Some(primitive) => Some(band::plan(
|
||||
&ifaces,
|
||||
(primitive, geometry.is_some()),
|
||||
primitive,
|
||||
r.max_vertex_amplification_count,
|
||||
p,
|
||||
)?),
|
||||
@@ -400,21 +367,13 @@ pub fn link(
|
||||
mesh::payload(&ifaces)?;
|
||||
}
|
||||
let mut table = LinkTable::default();
|
||||
let mut synthesized: Vec<(ResourceSlot, vk::ShaderStageFlags)> = plan
|
||||
let synthesized: Vec<(ResourceSlot, vk::ShaderStageFlags)> = plan
|
||||
.as_ref()
|
||||
.map(tessellation::ControlPlan::slots)
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.map(|slot| (slot, vk::ShaderStageFlags::TESSELLATION_CONTROL))
|
||||
.collect();
|
||||
// A fan-out variant's triangle stage reads the region table, and a probe's writes its flags.
|
||||
if let Some(fan) = geometry.as_ref().and_then(|g| g.fan_out) {
|
||||
let stage = vk::ShaderStageFlags::GEOMETRY;
|
||||
synthesized.push((fan_out::REGIONS_SLOT, stage));
|
||||
if fan.mode == crate::pipeline::RegionFanOut::Probe {
|
||||
synthesized.push((fan_out::FLAGS_SLOT, stage));
|
||||
}
|
||||
}
|
||||
let mut layout = layout(&ifaces, &synthesized, &mut table, p)?;
|
||||
count_variables(&mut layout, stages, &table);
|
||||
let control = match plan {
|
||||
@@ -452,29 +411,8 @@ pub fn link(
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
// A fan-out probe's stage pushes the index of its flag.
|
||||
let mut geometry = geometry;
|
||||
if let Some(fan) = geometry.as_mut().and_then(|g| g.fan_out.as_mut()) {
|
||||
if fan.mode == crate::pipeline::RegionFanOut::Probe {
|
||||
let offset = tessellation::push_offset(
|
||||
&layout.push_constants,
|
||||
(fan_out::PUSH_BYTES, 4),
|
||||
Feature::RasterizationRateMap,
|
||||
p,
|
||||
)?;
|
||||
layout.push_constants.push(PushConstantRange {
|
||||
stages: vk::ShaderStageFlags::GEOMETRY,
|
||||
offset,
|
||||
size: fan_out::PUSH_BYTES,
|
||||
});
|
||||
fan.push_offset = offset;
|
||||
}
|
||||
}
|
||||
let specialization = specialize(&ifaces, &mut table)?;
|
||||
table.locations = varyings::assign(stages, p)?;
|
||||
if let Some(g) = &mut geometry {
|
||||
g.check_limits(&table.locations, p)?;
|
||||
}
|
||||
let mut interface = pipeline_interface(&ifaces);
|
||||
// The address form's control stage states its push fields as the vertex stage's.
|
||||
if let Some(placement) = control.and_then(|(plan, offset)| plan.placement(offset)) {
|
||||
@@ -516,22 +454,6 @@ pub fn link(
|
||||
primitive: b.primitive,
|
||||
});
|
||||
}
|
||||
if let Some(fan) = geometry.as_ref().and_then(|g| g.fan_out) {
|
||||
gs.region_fan_out = Some(crate::pipeline::graphics::FanOutState {
|
||||
mode: fan.mode,
|
||||
copies: fan.copies,
|
||||
push_offset: fan.push_offset,
|
||||
});
|
||||
}
|
||||
// A region-copy variant draws no geometry stage: its vertex function draws its region's
|
||||
// copy, the row of regions of a recording pushed at its `RegionBox` field.
|
||||
if r.region_fan_out == Some(crate::pipeline::RegionFanOut::RegionCopies) {
|
||||
gs.region_fan_out = Some(crate::pipeline::graphics::FanOutState {
|
||||
mode: crate::pipeline::RegionFanOut::RegionCopies,
|
||||
copies: 0,
|
||||
push_offset: region_box(vs)?,
|
||||
});
|
||||
}
|
||||
(vi, Some(gs))
|
||||
}
|
||||
// The mesh stage stands in the vertex stage's place; the fragment stage follows it.
|
||||
@@ -575,29 +497,12 @@ pub fn link(
|
||||
graphics,
|
||||
specialization,
|
||||
control: control.map(|(plan, offset)| plan.control(offset)),
|
||||
geometry,
|
||||
band,
|
||||
})
|
||||
}
|
||||
|
||||
/// The graphics state of a render or mesh render pipeline whose geometry stage (its vertex or
|
||||
/// mesh stage) is `geometry`, with its fragment stage's.
|
||||
/// The byte offset of the push-constant block a region-copy variant's vertex function `vs` reads
|
||||
/// its recording's row of regions at (`PushField::RegionBox`): each recording pushes its own, so
|
||||
/// a function that holds it in its `ArgumentTable`, or reads none, is
|
||||
/// `NotImplemented(RasterizationRateMap)`.
|
||||
fn region_box(vs: &StageInterface) -> Result<u32, Error> {
|
||||
let at = vs
|
||||
.push
|
||||
.fields
|
||||
.iter()
|
||||
.find(|f| f.field == crate::pipeline::sym::PushField::RegionBox);
|
||||
match at.map(|f| f.loc) {
|
||||
Some(crate::pipeline::interface::PushLoc::Push { offset }) => Ok(offset),
|
||||
_ => Err(Unsupported::not_implemented(Feature::RasterizationRateMap).into()),
|
||||
}
|
||||
}
|
||||
|
||||
fn render_state(
|
||||
r: &RenderLinkInputs,
|
||||
geometry: &StageInterface,
|
||||
|
||||
@@ -85,9 +85,8 @@
|
||||
//!
|
||||
//! Refused (`Unsupported{WideLines}`): a device without `tessellationShader` (needing it), and as
|
||||
//! not implemented a post-tessellation vertex function, a vertex function that writes
|
||||
//! `[[render_target_array_index]]` or `[[viewport_array_index]]`, a pipeline with synthesized
|
||||
//! geometry stages (`link::geometry`), a fragment function that reads `[[barycentric_coord]]`, a
|
||||
//! pipeline drawn as multiview, and stages past `maxTessellationEvaluationOutputComponents`.
|
||||
//! `[[render_target_array_index]]` or `[[viewport_array_index]]`, a fragment function that reads
|
||||
//! `[[barycentric_coord]]`, a pipeline drawn as multiview, and stages past `maxTessellationEvaluationOutputComponents`.
|
||||
|
||||
use crate::budget::Meter;
|
||||
use crate::device::requirements::{Requirements, VkFeature, VkLimit};
|
||||
@@ -96,14 +95,14 @@ use crate::error::{Capability, Error, Feature, Unsupported};
|
||||
use crate::pipeline::artifact::{Reconvergence, SpecializationLayout, StageModule, StrategyCensus};
|
||||
use crate::pipeline::graphics::BandPrimitive;
|
||||
use crate::pipeline::interface::StageInterface;
|
||||
use crate::pipeline::link::geometry::{array, kf, ku, scalar};
|
||||
use crate::pipeline::stage_io::{Interpolation, IoNumeric, IoRole, IoType, StageBuiltin};
|
||||
use crate::pipeline::sym::{PushField, Stage, VaryingKey};
|
||||
use crate::spirv::builder::{FunctionBuilder, ModuleBuilder};
|
||||
use crate::spirv::error::BResult;
|
||||
use crate::spirv::ids::{GlobalId, TypeId, Value};
|
||||
use crate::spirv::ir::{
|
||||
BinOp, ConvOp, ExecMode, ExecModel, GlslOp, IoDecor, IoDir, MemAccess, Type, TypedModule, UnOp,
|
||||
BinOp, ConstBits, Constant, ConvOp, ExecMode, ExecModel, GlslOp, IoDecor, IoDir, MemAccess,
|
||||
Type, TypedModule, UnOp,
|
||||
};
|
||||
use crate::spirv::serialize::{SymbolTable, ENTRY_NAME};
|
||||
use crate::spv::BuiltIn as B;
|
||||
@@ -226,12 +225,11 @@ impl LineBand {
|
||||
}
|
||||
|
||||
/// The band stages of the render pipeline of stages `ifaces` (vertex, then fragment when it has
|
||||
/// one), drawing each `primitive` as a patch, whose synthesized geometry stages are `geometry`
|
||||
/// (`link::geometry`), drawn with vertex amplification up to `amplification`; its push offset left
|
||||
/// 0 for link to place. Refused as the module docs state.
|
||||
/// one), drawing each `primitive` as a patch, drawn with vertex amplification up to
|
||||
/// `amplification`; its push offset left 0 for link to place. Refused as the module docs state.
|
||||
pub fn plan(
|
||||
ifaces: &[&StageInterface],
|
||||
(primitive, geometry): (BandPrimitive, bool),
|
||||
primitive: BandPrimitive,
|
||||
amplification: u32,
|
||||
p: &DeviceProfile,
|
||||
) -> Result<LineBand, Error> {
|
||||
@@ -259,13 +257,9 @@ pub fn plan(
|
||||
f.io.builtins
|
||||
.iter()
|
||||
.any(|b| matches!(b, StageBuiltin::BaryCoord { .. }))
|
||||
|| f.io
|
||||
.inputs
|
||||
.iter()
|
||||
.any(|i| matches!(i.role, IoRole::Barycentric { .. }))
|
||||
});
|
||||
let multiview = amplification.min(f.limits.max_multiview_view_count.max(1)) > 1;
|
||||
if selects || weights || geometry || multiview {
|
||||
if selects || weights || multiview {
|
||||
return Err(not_implemented());
|
||||
}
|
||||
let clip_distances = vertex
|
||||
@@ -971,3 +965,48 @@ fn mix(
|
||||
}
|
||||
fb.composite_construct(ty, &out)
|
||||
}
|
||||
|
||||
/// An array of `n` elements of `elem`.
|
||||
fn array(mb: &mut ModuleBuilder, elem: TypeId, n: u32) -> BResult<TypeId> {
|
||||
let u32_ = scalar(mb, IoNumeric::Uint)?;
|
||||
let len = mb.constant(Constant::Scalar {
|
||||
ty: u32_,
|
||||
bits: ConstBits(u64::from(n)),
|
||||
})?;
|
||||
mb.ty(Type::Array {
|
||||
elem,
|
||||
len,
|
||||
stride: None,
|
||||
})
|
||||
}
|
||||
|
||||
/// The `uint` constant `v`.
|
||||
fn ku(fb: &mut FunctionBuilder<'_>, v: u32) -> BResult<Value> {
|
||||
let c = fb.u32_const(v)?;
|
||||
fb.module().const_value(c)
|
||||
}
|
||||
|
||||
/// The `float` constant `v`.
|
||||
fn kf(fb: &mut FunctionBuilder<'_>, v: f32) -> BResult<Value> {
|
||||
let ty = fb.module().ty(Type::Float { width: 32 })?;
|
||||
let c = fb.module().constant(Constant::Scalar {
|
||||
ty,
|
||||
bits: ConstBits(u64::from(v.to_bits())),
|
||||
})?;
|
||||
fb.module().const_value(c)
|
||||
}
|
||||
|
||||
/// The scalar type of `numeric`.
|
||||
fn scalar(mb: &mut ModuleBuilder, numeric: IoNumeric) -> BResult<TypeId> {
|
||||
match numeric {
|
||||
IoNumeric::Float => mb.ty(Type::Float { width: 32 }),
|
||||
IoNumeric::Sint => mb.ty(Type::Int {
|
||||
width: 32,
|
||||
signed: true,
|
||||
}),
|
||||
IoNumeric::Uint => mb.ty(Type::Int {
|
||||
width: 32,
|
||||
signed: false,
|
||||
}),
|
||||
}
|
||||
}
|
||||
@@ -1,765 +0,0 @@
|
||||
//! The fan-out geometry stage of a render pipeline variant that draws a rate-mapped pass's
|
||||
//! triangles once (`VariantKey::region_fan_out`): the vertex function runs once per vertex, and
|
||||
//! the triangle class's geometry stage emits a copy of each triangle for each region it touches,
|
||||
//! through the region table's lines and clip distances (`bind::fan_out`, its layout and math),
|
||||
//! where the regions route records each draw once per region.
|
||||
//!
|
||||
//! The stage passes through what [`GeometryStages`] passes through (the vertex outputs the
|
||||
//! fragment stage reads, the vertex function's clip distances, `PrimitiveId`), emits each copy's
|
||||
//! vertices in the order it receives them, so a copy keeps the triangle's winding and provoking
|
||||
//! vertex, and writes four clip distances past the vertex function's, which keep the copy's
|
||||
//! region's pixels. Its point and line classes' stages are the plain ones: the variant draws
|
||||
//! triangles alone.
|
||||
//!
|
||||
//! - **Draw** ([`RegionFanOut::Draw`]): a triangle every `w` of which is positive emits one copy
|
||||
//! per pair of segments its bounds reach, at most [`FanOutStage::copies`]; one with no positive
|
||||
//! `w`, or one past the segments, emits none, and so does one with some `w` not positive, which
|
||||
//! the probe found. Each copy's vertices are [`region_copy`]'s, the emitter a vertex function
|
||||
//! that draws its region's copy shares (`LoweringInputs::region_copies`), and the stage's
|
||||
//! `Position` and `ClipDistance` outputs are `Invariant`. The copies are a loop the driver is
|
||||
//! asked not to unroll (`DontUnroll`): its
|
||||
//! body compiled once, the pipeline is made in about a third of the time 16 unrolled copies
|
||||
//! took (on an RTX 3090 45.2 against 81.3 ms for the probe's and the draw's, Iris Xe 20.0
|
||||
//! against 66.9 ms, Radeon 780M 14.4 against 44.5 ms), with the same GPU time. A draw of few
|
||||
//! copies ([`RegionFanOut::DrawFew`]) is the same stage of at most `bind::fan_out::FEW_COPIES`
|
||||
//! copies, which declares the output of that many.
|
||||
//! - **Probe** ([`RegionFanOut::Probe`]): emits nothing. Of the flags buffer's words of the
|
||||
//! index `i` the draw pushes (`PushField::RegionProbe`; [`PROBE_DRAW_WORDS`] of them from
|
||||
//! `PROBE_DRAW_WORDS·i`), it writes 1 into the first for a triangle the draw cannot fan out: one
|
||||
//! with some `w` not positive and another positive, or whose bounds, widened by the table's
|
||||
//! widening, reach more pairs than the copies; and adds the copies the draw emits of each
|
||||
//! triangle it fans out, the pairs its bounds reach unwidened, into the count its `PrimitiveId`
|
||||
//! picks of the [`PROBE_COUNT_WORDS`] after it, so the consumer sums the draw's work and no
|
||||
//! word takes every triangle's add; for a triangle it does not flag whose bounds, widened,
|
||||
//! reach more pairs than [`FEW_COPIES`], writes 1 into the word its `PrimitiveId` picks of the
|
||||
//! as many after those, which mark the draw one its variant of few copies cannot draw; and for
|
||||
//! a triangle it flags, raises the word its `PrimitiveId` picks of the as many after those to
|
||||
//! `u32::MAX − PrimitiveId`, and of the as many after them to `PrimitiveId + 1`, so the
|
||||
//! consumer finds the draw's first and last flagged triangle, adds one into the word it
|
||||
//! picks of the fifth set, so the consumer counts them, and sets the bit of its block of
|
||||
//! [`BLOCK_TRIANGLES`] in the sixth ([`BLOCK_SET`]), so the consumer draws only the blocks that
|
||||
//! hold a flagged triangle region by region; for a flagged triangle with some `w` not positive
|
||||
//! beside a positive one, adds one into the word it picks of the seventh ([`STRADDLE_SET`]).
|
||||
//! Of every triangle it reaches, it sets the bits of the buckets of segments its widened bounds
|
||||
//! reach in its block's bounds ([`PROBE_BOUNDS_AT`], [`BOUND_BUCKETS`]), every bit for one with
|
||||
//! some `w` not positive beside a positive one, so the consumer draws a run of blocks only into
|
||||
//! the regions its blocks reach. Its writes need `vertexPipelineStoresAndAtomics`.
|
||||
|
||||
use super::geometry::{array, kf, ku, scalar, GeometryStages};
|
||||
use crate::bind::fan_out::{
|
||||
clip_entry, line_entry, BLOCK_SET, BLOCK_TRIANGLES, BOUND_BUCKETS, FEW_COPIES, MAX_SEGMENTS,
|
||||
PROBE_BLOCKS, PROBE_BOUNDS_AT, PROBE_COUNT_WORDS, PROBE_DRAW_WORDS, STRADDLE_SET,
|
||||
};
|
||||
use crate::pipeline::graphics::RegionFanOut;
|
||||
use crate::pipeline::stage_io::IoNumeric;
|
||||
use crate::pipeline::sym::{PushField, ResourceKind, ResourceSlot, Stage, SyntheticBinding};
|
||||
use crate::spirv::builder::constructs::{ArmEnd, ArmFn, LoopFn, LoopSpec};
|
||||
use crate::spirv::builder::ops::group::GroupMode;
|
||||
use crate::spirv::builder::{FunctionBuilder, ModuleBuilder};
|
||||
use crate::spirv::error::BResult;
|
||||
use crate::spirv::ids::{GlobalId, TypeId, Value};
|
||||
use crate::spirv::ir::{
|
||||
natural_layout, AtomicOp, BinOp, ConvOp, ExecMode, ExecModel, GlslOp, GroupArith, IoDecor,
|
||||
IoDir, LayoutRule, MemAccess, Scope, Semantics, StorageClass, Type, TypedModule, UnOp,
|
||||
};
|
||||
use crate::spv::BuiltIn as B;
|
||||
|
||||
/// The most copies of a triangle a draw's stage emits: past it, a device's geometry stage
|
||||
/// reserves output for vertices most triangles never emit.
|
||||
pub const MOST_COPIES: u32 = 16;
|
||||
|
||||
/// The bytes of the probe's push range: the index of the flag it writes.
|
||||
pub const PUSH_BYTES: u32 = 4;
|
||||
|
||||
/// The binding symbol of the region table (`SyntheticBinding::RateMapRegions`), declared with
|
||||
/// the vertex stage's symbols.
|
||||
pub const REGIONS_SLOT: ResourceSlot = ResourceSlot {
|
||||
stage: Stage::Vertex,
|
||||
kind: ResourceKind::Synthetic(SyntheticBinding::RateMapRegions),
|
||||
index: 0,
|
||||
};
|
||||
|
||||
/// The binding symbol of the probe's flags (`SyntheticBinding::RateMapFlags`), declared with the
|
||||
/// vertex stage's symbols.
|
||||
pub const FLAGS_SLOT: ResourceSlot = ResourceSlot {
|
||||
stage: Stage::Vertex,
|
||||
kind: ResourceKind::Synthetic(SyntheticBinding::RateMapFlags),
|
||||
index: 0,
|
||||
};
|
||||
|
||||
/// A fan-out variant's triangle stage (the module docs).
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct FanOutStage {
|
||||
/// What it does.
|
||||
pub mode: RegionFanOut,
|
||||
/// The most copies of a triangle it emits, what the device's geometry limits leave for its
|
||||
/// vertices' outputs, at most [`MOST_COPIES`]: set once link placed the varyings.
|
||||
pub copies: u32,
|
||||
/// The byte offset of the probe's push range ([`PUSH_BYTES`]); 0 for a draw.
|
||||
pub push_offset: u32,
|
||||
/// Whether a probe's triangles of a subgroup raise each block's bounds word once, their
|
||||
/// bounds ORed together (`bind::fan_out::PROBE_BOUNDS_AT`), rather than each its own: the
|
||||
/// device runs subgroup operations of the basic, arithmetic and ballot classes in the
|
||||
/// geometry stage (`VkProperty::SubgroupGeometryStage`). Set once link placed the varyings,
|
||||
/// as the copies are; false for a draw.
|
||||
pub subgroup_bounds: bool,
|
||||
}
|
||||
|
||||
impl FanOutStage {
|
||||
/// The stage of `mode`, its copies and push offset not yet placed.
|
||||
pub fn new(mode: RegionFanOut) -> FanOutStage {
|
||||
FanOutStage {
|
||||
mode,
|
||||
copies: 0,
|
||||
push_offset: 0,
|
||||
subgroup_bounds: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The values the copies are made from.
|
||||
struct Copies {
|
||||
table: GlobalId,
|
||||
positions: [Value; 3],
|
||||
own_clips: Option<GlobalId>,
|
||||
own: u32,
|
||||
clips: GlobalId,
|
||||
position: GlobalId,
|
||||
carried: Vec<(GlobalId, GlobalId)>,
|
||||
primitive: Option<(GlobalId, GlobalId)>,
|
||||
vec4: TypeId,
|
||||
f32_: TypeId,
|
||||
}
|
||||
|
||||
/// The table's word `word` (a `uint` value).
|
||||
fn word(fb: &mut FunctionBuilder<'_>, table: GlobalId, word: Value) -> BResult<Value> {
|
||||
let base = fb.module().global_value(table)?;
|
||||
let member = ku(fb, 0)?;
|
||||
let ptr = fb.access_chain(base, &[member, word])?;
|
||||
fb.load(ptr, MemAccess::default())
|
||||
}
|
||||
|
||||
/// Component `c` of entry `entry` plus `k` of the table, as a float: `k` a `uint` value, or none.
|
||||
fn component(
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
(table, f32_): (GlobalId, TypeId),
|
||||
entry: u32,
|
||||
k: Option<Value>,
|
||||
c: u32,
|
||||
) -> BResult<Value> {
|
||||
let at = ku(fb, entry * 4 + c)?;
|
||||
let at = match k {
|
||||
Some(k) => {
|
||||
let four = ku(fb, 4)?;
|
||||
let k4 = fb.binary(BinOp::IMul, k, four)?;
|
||||
fb.binary(BinOp::IAdd, at, k4)?
|
||||
}
|
||||
None => at,
|
||||
};
|
||||
let bits = word(fb, table, at)?;
|
||||
fb.convert(ConvOp::Bitcast, bits, f32_)
|
||||
}
|
||||
|
||||
/// The last segment of axis `axis` (of `n`) whose least coordinate is at most `v`, or the first:
|
||||
/// a bisection of `log2(MAX_SEGMENTS)` steps over the table's lines.
|
||||
fn find(
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
table: (GlobalId, TypeId),
|
||||
axis: u32,
|
||||
n: Value,
|
||||
v: Value,
|
||||
) -> BResult<Value> {
|
||||
let zero = ku(fb, 0)?;
|
||||
let one = ku(fb, 1)?;
|
||||
let empty = fb.binary(BinOp::IEqual, n, zero)?;
|
||||
let last = fb.binary(BinOp::ISub, n, one)?;
|
||||
let mut lo = zero;
|
||||
let mut hi = fb.select(empty, zero, last)?;
|
||||
for _ in 0..MAX_SEGMENTS.ilog2() {
|
||||
let open = fb.binary(BinOp::ULessThan, lo, hi)?;
|
||||
let sum = fb.binary(BinOp::IAdd, lo, hi)?;
|
||||
let sum = fb.binary(BinOp::IAdd, sum, one)?;
|
||||
let mid = fb.binary(BinOp::ShiftRightLogical, sum, one)?;
|
||||
let at = component(fb, table, line_entry(axis, 0), Some(mid), 0)?;
|
||||
let below = fb.binary(BinOp::FOrdLessThanEqual, at, v)?;
|
||||
let above = fb.unary(UnOp::LogicalNot, below)?;
|
||||
let up = fb.binary(BinOp::LogicalAnd, open, below)?;
|
||||
let down = fb.binary(BinOp::LogicalAnd, open, above)?;
|
||||
let before = fb.binary(BinOp::ISub, mid, one)?;
|
||||
lo = fb.select(up, mid, lo)?;
|
||||
hi = fb.select(down, before, hi)?;
|
||||
}
|
||||
Ok(lo)
|
||||
}
|
||||
|
||||
/// The least and the greatest normalized coordinate of axis `axis` (0 x, 1 y) that a triangle of
|
||||
/// clip-space `positions` reaches where its `w` is positive (`positive`, a vertex's; `ndc`, its
|
||||
/// coordinate over its `w`), as the probe bounds a straddling triangle's block: those of its
|
||||
/// vertices of positive `w`, and infinity on each side an edge from such a vertex `a` to one `b`
|
||||
/// of `w` not positive crosses `w = 0`, the sign of `w_a·v_b − v_a·w_b`, a sign within a
|
||||
/// rounding margin of zero (or not a number) taking both sides. A triangle of every `w` positive
|
||||
/// reaches from its least vertex's to its greatest's; one of none, nothing.
|
||||
fn visible_reach(
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
positions: [Value; 3],
|
||||
positive: [Value; 3],
|
||||
ndc: [Value; 3],
|
||||
axis: u32,
|
||||
) -> BResult<(Value, Value)> {
|
||||
let below = kf(fb, f32::NEG_INFINITY)?;
|
||||
let above = kf(fb, f32::INFINITY)?;
|
||||
let mut least = Vec::with_capacity(3);
|
||||
let mut greatest = Vec::with_capacity(3);
|
||||
for (&positive, &v) in positive.iter().zip(&ndc) {
|
||||
least.push(fb.select(positive, v, above)?);
|
||||
greatest.push(fb.select(positive, v, below)?);
|
||||
}
|
||||
let mut lo = extreme(fb, GlslOp::FMin, [least[0], least[1], least[2]])?;
|
||||
let mut hi = extreme(fb, GlslOp::FMax, [greatest[0], greatest[1], greatest[2]])?;
|
||||
let zero = kf(fb, 0.0)?;
|
||||
// The margin: 2^-16 of the products' magnitudes, past a float's rounding of their difference.
|
||||
let margin = kf(fb, 1.0 / 65536.0)?;
|
||||
for (a, b) in [(0, 1), (1, 2), (2, 0)] {
|
||||
let crosses = fb.binary(BinOp::LogicalNotEqual, positive[a], positive[b])?;
|
||||
let v_a = fb.composite_extract(positions[a], &[axis])?;
|
||||
let w_a = fb.composite_extract(positions[a], &[3])?;
|
||||
let v_b = fb.composite_extract(positions[b], &[axis])?;
|
||||
let w_b = fb.composite_extract(positions[b], &[3])?;
|
||||
let m = fb.binary(BinOp::FMul, w_a, v_b)?;
|
||||
let n = fb.binary(BinOp::FMul, v_a, w_b)?;
|
||||
let side = fb.binary(BinOp::FSub, m, n)?;
|
||||
let flipped = fb.unary(UnOp::FNegate, side)?;
|
||||
let side = fb.select(positive[a], side, flipped)?;
|
||||
let m = fb.glsl(GlslOp::FAbs, &[m])?;
|
||||
let n = fb.glsl(GlslOp::FAbs, &[n])?;
|
||||
let size = fb.binary(BinOp::FAdd, m, n)?;
|
||||
let size = fb.binary(BinOp::FMul, size, margin)?;
|
||||
let up = fb.binary(BinOp::FAdd, side, size)?;
|
||||
let up = fb.binary(BinOp::FUnordGreaterThanEqual, up, zero)?;
|
||||
let up = fb.binary(BinOp::LogicalAnd, crosses, up)?;
|
||||
let down = fb.binary(BinOp::FSub, side, size)?;
|
||||
let down = fb.binary(BinOp::FUnordLessThanEqual, down, zero)?;
|
||||
let down = fb.binary(BinOp::LogicalAnd, crosses, down)?;
|
||||
hi = fb.select(up, above, hi)?;
|
||||
lo = fb.select(down, below, lo)?;
|
||||
}
|
||||
Ok((lo, hi))
|
||||
}
|
||||
|
||||
/// The least or the greatest of three floats.
|
||||
fn extreme(fb: &mut FunctionBuilder<'_>, op: GlslOp, v: [Value; 3]) -> BResult<Value> {
|
||||
let two = fb.glsl(op, &[v[0], v[1]])?;
|
||||
fb.glsl(op, &[two, v[2]])
|
||||
}
|
||||
|
||||
/// Declare the region table (`SyntheticBinding::RateMapRegions`, [`REGIONS_SLOT`]) in `mb`: a
|
||||
/// `Block { uint[] }` storage buffer, which a fan-out stage reads and a vertex function that
|
||||
/// draws its region's copy (`LoweringInputs::region_copies`) reads alike.
|
||||
pub(crate) fn declare_table(mb: &mut ModuleBuilder) -> BResult<GlobalId> {
|
||||
let u32_ = mb.ty(Type::Int {
|
||||
width: 32,
|
||||
signed: false,
|
||||
})?;
|
||||
let words = mb.ty(Type::RuntimeArray {
|
||||
elem: u32_,
|
||||
stride: Some(4),
|
||||
})?;
|
||||
let layout = natural_layout(mb.types(), LayoutRule::Std430, true, &[words])?;
|
||||
let block = mb.ty(Type::Struct {
|
||||
members: [words].into(),
|
||||
layout: Some(layout),
|
||||
})?;
|
||||
mb.resource(REGIONS_SLOT, StorageClass::StorageBuffer, block)
|
||||
}
|
||||
|
||||
/// The segments of draw `d` (a `uint`) of a row of regions whose first region's segments are `x0`
|
||||
/// and `y0` (`uint`s; `bind::fan_out`, **One route per pass**): `(x0 + d, y0)`, the row's regions
|
||||
/// in order. Nothing of it reads memory or divides.
|
||||
pub(crate) fn row_segments(
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
[x0, y0]: [Value; 2],
|
||||
d: Value,
|
||||
) -> BResult<(Value, Value)> {
|
||||
Ok((fb.binary(BinOp::IAdd, x0, d)?, y0))
|
||||
}
|
||||
|
||||
/// The terms of the copy for segments `sx` and `sy` (`uint`s) of the table `table` (its global
|
||||
/// and `float` type), of axis x then y: `[a, b, W/2, X + W/2 − p₀, p₁ − X − W/2]`, its line's
|
||||
/// `a` and `b` and its clip (the layout of `bind::fan_out`).
|
||||
pub(crate) fn region_terms(
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
table: (GlobalId, TypeId),
|
||||
(sx, sy): (Value, Value),
|
||||
) -> BResult<[[Value; 5]; 2]> {
|
||||
let mut axes = [[sx; 5]; 2];
|
||||
for (axis, s) in [(0, sx), (1, sy)] {
|
||||
let terms = &mut axes[axis as usize];
|
||||
terms[0] = component(fb, table, line_entry(axis, 0), Some(s), 2)?;
|
||||
terms[1] = component(fb, table, line_entry(axis, 0), Some(s), 3)?;
|
||||
for (t, c) in [(2, 0), (3, 1), (4, 2)] {
|
||||
terms[t] = component(fb, table, clip_entry(axis, 0), Some(s), c)?;
|
||||
}
|
||||
}
|
||||
Ok(axes)
|
||||
}
|
||||
|
||||
/// The copy of the clip-space position `p` (a `vec4` of type `vec4`) through `terms`
|
||||
/// ([`region_terms`]): `(a·x + b·w, a·y + b·w, z, w)`, each axis's own `a` and `b`, and the clip
|
||||
/// distances `W/2·v + lo·w` and `hi·w − W/2·v` of x then y. The one emitter of a region's copy:
|
||||
/// a fan-out stage's of each vertex it emits, and a vertex function's that draws its region's
|
||||
/// copy (`LoweringInputs::region_copies`). Each operation is decorated `NoContraction`, so each
|
||||
/// is correctly rounded on its own (Vulkan's *Precision and Operation of SPIR-V Instructions*)
|
||||
/// and both put a vertex in a region at the same bits (`bind::fan_out`, **One route per pass**).
|
||||
pub(crate) fn region_copy(
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
terms: &[[Value; 5]; 2],
|
||||
p: Value,
|
||||
vec4: TypeId,
|
||||
) -> BResult<(Value, [Value; 4])> {
|
||||
let w = fb.composite_extract(p, &[3])?;
|
||||
let z = fb.composite_extract(p, &[2])?;
|
||||
let mut moved = [w; 2];
|
||||
let mut distances = [w; 4];
|
||||
for (axis, &[a, b, half, lo, hi]) in terms.iter().enumerate() {
|
||||
let v = fb.composite_extract(p, &[axis as u32])?;
|
||||
let av = fb.binary_no_contraction(BinOp::FMul, a, v)?;
|
||||
let bw = fb.binary_no_contraction(BinOp::FMul, b, w)?;
|
||||
moved[axis] = fb.binary_no_contraction(BinOp::FAdd, av, bw)?;
|
||||
let hv = fb.binary_no_contraction(BinOp::FMul, half, v)?;
|
||||
let low = fb.binary_no_contraction(BinOp::FMul, lo, w)?;
|
||||
distances[2 * axis] = fb.binary_no_contraction(BinOp::FAdd, hv, low)?;
|
||||
let high = fb.binary_no_contraction(BinOp::FMul, hi, w)?;
|
||||
distances[2 * axis + 1] = fb.binary_no_contraction(BinOp::FSub, high, hv)?;
|
||||
}
|
||||
let position = fb.composite_construct(vec4, &[moved[0], moved[1], z, w])?;
|
||||
Ok((position, distances))
|
||||
}
|
||||
|
||||
/// Emit the copy of the triangle for segments `sx` and `sy`: each vertex through their lines,
|
||||
/// with their clip distances past the vertex function's ([`region_copy`]).
|
||||
fn emit_copy(fb: &mut FunctionBuilder<'_>, c: &Copies, (sx, sy): (Value, Value)) -> BResult<()> {
|
||||
let terms = region_terms(fb, (c.table, c.f32_), (sx, sy))?;
|
||||
for (k, &p) in c.positions.iter().enumerate() {
|
||||
let at = ku(fb, k as u32)?;
|
||||
let (position, distances) = region_copy(fb, &terms, p, c.vec4)?;
|
||||
let to = fb.module().global_value(c.position)?;
|
||||
fb.store(to, position, MemAccess::default())?;
|
||||
let clips = fb.module().global_value(c.clips)?;
|
||||
if let Some(own) = c.own_clips {
|
||||
let from = fb.module().global_value(own)?;
|
||||
for e in 0..c.own {
|
||||
let element = ku(fb, e)?;
|
||||
let ptr = fb.access_chain(from, &[at, element])?;
|
||||
let value = fb.load(ptr, MemAccess::default())?;
|
||||
let to = fb.access_chain(clips, &[element])?;
|
||||
fb.store(to, value, MemAccess::default())?;
|
||||
}
|
||||
}
|
||||
for (e, &d) in distances.iter().enumerate() {
|
||||
let element = ku(fb, c.own + e as u32)?;
|
||||
let to = fb.access_chain(clips, &[element])?;
|
||||
fb.store(to, d, MemAccess::default())?;
|
||||
}
|
||||
for &(input, output) in &c.carried {
|
||||
let base = fb.module().global_value(input)?;
|
||||
let from = fb.access_chain(base, &[at])?;
|
||||
let value = fb.load(from, MemAccess::default())?;
|
||||
let to = fb.module().global_value(output)?;
|
||||
fb.store(to, value, MemAccess::default())?;
|
||||
}
|
||||
if let Some((input, output)) = c.primitive {
|
||||
let from = fb.module().global_value(input)?;
|
||||
let value = fb.load(from, MemAccess::default())?;
|
||||
let to = fb.module().global_value(output)?;
|
||||
fb.store(to, value, MemAccess::default())?;
|
||||
}
|
||||
fb.emit_vertex()?;
|
||||
}
|
||||
fb.end_primitive()
|
||||
}
|
||||
|
||||
/// The fan-out variant's triangle stage of `stages` (the module docs).
|
||||
pub(super) fn module(stages: &GeometryStages, fan: FanOutStage) -> BResult<TypedModule> {
|
||||
let mut mb = ModuleBuilder::new();
|
||||
let u32_ = scalar(&mut mb, IoNumeric::Uint)?;
|
||||
let f32_ = scalar(&mut mb, IoNumeric::Float)?;
|
||||
let vec4 = mb.ty(Type::Vector { elem: f32_, len: 4 })?;
|
||||
let void = mb.ty(Type::Void)?;
|
||||
let ty = array(&mut mb, vec4, 3)?;
|
||||
let positions = mb.builtin(B::Position, IoDir::Input, ty)?;
|
||||
let position = mb.builtin(B::Position, IoDir::Output, vec4)?;
|
||||
mb.invariant(position)?;
|
||||
let own = stages.clip_distances;
|
||||
let own_clips = match own {
|
||||
0 => None,
|
||||
n => {
|
||||
let clip = array(&mut mb, f32_, n)?;
|
||||
let ty = array(&mut mb, clip, 3)?;
|
||||
Some(mb.builtin(B::ClipDistance, IoDir::Input, ty)?)
|
||||
}
|
||||
};
|
||||
let ty = array(&mut mb, f32_, own + 4)?;
|
||||
let clips = mb.builtin(B::ClipDistance, IoDir::Output, ty)?;
|
||||
mb.invariant(clips)?;
|
||||
let packed = IoDecor {
|
||||
packed: true,
|
||||
..IoDecor::default()
|
||||
};
|
||||
let mut carried = Vec::with_capacity(stages.varyings.len());
|
||||
for (key, io) in &stages.varyings {
|
||||
let elem = scalar(&mut mb, io.numeric)?;
|
||||
let ty = match io.components {
|
||||
1 => elem,
|
||||
c => mb.ty(Type::Vector { elem, len: c })?,
|
||||
};
|
||||
let input_ty = array(&mut mb, ty, 3)?;
|
||||
carried.push((
|
||||
mb.io(key.clone(), IoDir::Input, input_ty, packed)?,
|
||||
mb.io(key.clone(), IoDir::Output, ty, packed)?,
|
||||
));
|
||||
}
|
||||
let primitive = match stages.primitive_id {
|
||||
true => Some((
|
||||
mb.builtin(B::PrimitiveId, IoDir::Input, u32_)?,
|
||||
mb.builtin(B::PrimitiveId, IoDir::Output, u32_)?,
|
||||
)),
|
||||
false => None,
|
||||
};
|
||||
let table = declare_table(&mut mb)?;
|
||||
let probe = match fan.mode {
|
||||
RegionFanOut::Probe => {
|
||||
let words = mb.ty(Type::RuntimeArray {
|
||||
elem: u32_,
|
||||
stride: Some(4),
|
||||
})?;
|
||||
let layout = natural_layout(mb.types(), LayoutRule::Std430, true, &[words])?;
|
||||
let block = mb.ty(Type::Struct {
|
||||
members: [words].into(),
|
||||
layout: Some(layout),
|
||||
})?;
|
||||
let flags = mb.resource(FLAGS_SLOT, StorageClass::StorageBuffer, block)?;
|
||||
let member = (mb.push_member(PushField::RegionProbe, u32_, fan.push_offset)?).index;
|
||||
// The probe picks a triangle's count by its `PrimitiveId`.
|
||||
let id = match primitive {
|
||||
Some((input, _)) => input,
|
||||
None => mb.builtin(B::PrimitiveId, IoDir::Input, u32_)?,
|
||||
};
|
||||
Some((flags, member, mb.push_global()?, id))
|
||||
}
|
||||
RegionFanOut::Draw | RegionFanOut::DrawFew | RegionFanOut::RegionCopies => None,
|
||||
};
|
||||
let mut fb = mb.function(void)?;
|
||||
let mut loaded = Vec::with_capacity(3);
|
||||
for k in 0..3 {
|
||||
let at = ku(&mut fb, k)?;
|
||||
let base = fb.module().global_value(positions)?;
|
||||
let from = fb.access_chain(base, &[at])?;
|
||||
loaded.push(fb.load(from, MemAccess::default())?);
|
||||
}
|
||||
let positions = [loaded[0], loaded[1], loaded[2]];
|
||||
let zero = kf(&mut fb, 0.0)?;
|
||||
let mut positive = Vec::with_capacity(3);
|
||||
for &p in &positions {
|
||||
let w = fb.composite_extract(p, &[3])?;
|
||||
positive.push(fb.binary(BinOp::FOrdGreaterThan, w, zero)?);
|
||||
}
|
||||
let two = fb.binary(BinOp::LogicalAnd, positive[0], positive[1])?;
|
||||
let every = fb.binary(BinOp::LogicalAnd, two, positive[2])?;
|
||||
let two = fb.binary(BinOp::LogicalOr, positive[0], positive[1])?;
|
||||
let some = fb.binary(BinOp::LogicalOr, two, positive[2])?;
|
||||
let table_f = (table, f32_);
|
||||
let header = ku(&mut fb, 0)?;
|
||||
let nx = word(&mut fb, table, header)?;
|
||||
let header = ku(&mut fb, 1)?;
|
||||
let ny = word(&mut fb, table, header)?;
|
||||
let one = ku(&mut fb, 1)?;
|
||||
// Per axis: the first segment its bounds reach, how many, and whether they reach any.
|
||||
let mut reach = Vec::with_capacity(2);
|
||||
for (axis, n) in [(0u32, nx), (1, ny)] {
|
||||
let mut ndc = Vec::with_capacity(3);
|
||||
for &p in &positions {
|
||||
let v = fb.composite_extract(p, &[axis])?;
|
||||
let w = fb.composite_extract(p, &[3])?;
|
||||
ndc.push(fb.binary(BinOp::FDiv, v, w)?);
|
||||
}
|
||||
let ndc = [ndc[0], ndc[1], ndc[2]];
|
||||
let (mut lo, mut hi) = match probe {
|
||||
Some(_) => {
|
||||
let positive = [positive[0], positive[1], positive[2]];
|
||||
visible_reach(&mut fb, positions, positive, ndc, axis)?
|
||||
}
|
||||
None => (
|
||||
extreme(&mut fb, GlslOp::FMin, ndc)?,
|
||||
extreme(&mut fb, GlslOp::FMax, ndc)?,
|
||||
),
|
||||
};
|
||||
if probe.is_some() {
|
||||
let widen = component(&mut fb, table_f, 1, None, axis)?;
|
||||
lo = fb.binary(BinOp::FSub, lo, widen)?;
|
||||
hi = fb.binary(BinOp::FAdd, hi, widen)?;
|
||||
}
|
||||
let first = component(&mut fb, table_f, line_entry(axis, 0), None, 0)?;
|
||||
let last = fb.binary(BinOp::ISub, n, one)?;
|
||||
let end = component(&mut fb, table_f, line_entry(axis, 0), Some(last), 1)?;
|
||||
let after = fb.binary(BinOp::FOrdGreaterThanEqual, hi, first)?;
|
||||
let before = fb.binary(BinOp::FOrdLessThanEqual, lo, end)?;
|
||||
let inside = fb.binary(BinOp::LogicalAnd, after, before)?;
|
||||
let i0 = find(&mut fb, table_f, axis, n, lo)?;
|
||||
let i1 = find(&mut fb, table_f, axis, n, hi)?;
|
||||
let span = fb.binary(BinOp::ISub, i1, i0)?;
|
||||
let span = fb.binary(BinOp::IAdd, span, one)?;
|
||||
reach.push((i0, span, inside));
|
||||
}
|
||||
let (x0, xs, x_in) = reach[0];
|
||||
let (y0, ys, y_in) = reach[1];
|
||||
let both = fb.binary(BinOp::LogicalAnd, x_in, y_in)?;
|
||||
let fans = fb.binary(BinOp::LogicalAnd, every, both)?;
|
||||
let pairs = fb.binary(BinOp::IMul, xs, ys)?;
|
||||
let none = ku(&mut fb, 0)?;
|
||||
let count = fb.select(fans, pairs, none)?;
|
||||
let copies = fan.copies.max(1);
|
||||
let mut ctx = ();
|
||||
match probe {
|
||||
Some((flags, member, push, id)) => {
|
||||
// Some `w` not positive beside a positive one, or more pairs than the copies.
|
||||
let straddles = fb.unary(UnOp::LogicalNot, every)?;
|
||||
let straddles = fb.binary(BinOp::LogicalAnd, some, straddles)?;
|
||||
let most = ku(&mut fb, copies)?;
|
||||
let over = fb.binary(BinOp::UGreaterThan, count, most)?;
|
||||
let flagged = fb.binary(BinOp::LogicalOr, straddles, over)?;
|
||||
// The draw's words: its flag, then the counts of the copies its triangles emit, this
|
||||
// triangle's the one its `PrimitiveId` picks.
|
||||
let base = fb.module().global_value(push)?;
|
||||
let index = ku(&mut fb, member)?;
|
||||
let ptr = fb.access_chain(base, &[index])?;
|
||||
let pushed = fb.load(ptr, MemAccess::default())?;
|
||||
let draw_words = ku(&mut fb, PROBE_DRAW_WORDS)?;
|
||||
let flag_at = fb.binary(BinOp::IMul, pushed, draw_words)?;
|
||||
let from = fb.module().global_value(id)?;
|
||||
let id = fb.load(from, MemAccess::default())?;
|
||||
let mask = ku(&mut fb, PROBE_COUNT_WORDS - 1)?;
|
||||
let lane = fb.binary(BinOp::BitwiseAnd, id, mask)?;
|
||||
let lane = fb.binary(BinOp::IAdd, lane, one)?;
|
||||
let count_at = fb.binary(BinOp::IAdd, flag_at, lane)?;
|
||||
let word_ptr = move |fb: &mut FunctionBuilder<'_>, at: Value| {
|
||||
let base = fb.module().global_value(flags)?;
|
||||
let zero = ku(fb, 0)?;
|
||||
fb.access_chain(base, &[zero, at])
|
||||
};
|
||||
// A flagged triangle: the draw's flag, its `PrimitiveId` raised into the first's and
|
||||
// the last's words it picks, and one added into the flagged count it picks: the
|
||||
// sets after the counts, its word the same lane of each.
|
||||
let lanes = ku(&mut fb, PROBE_COUNT_WORDS)?;
|
||||
let wide_at = fb.binary(BinOp::IAdd, count_at, lanes)?;
|
||||
let first_at = fb.binary(BinOp::IAdd, wide_at, lanes)?;
|
||||
let last_at = fb.binary(BinOp::IAdd, first_at, lanes)?;
|
||||
let flagged_at = fb.binary(BinOp::IAdd, last_at, lanes)?;
|
||||
let most_id = ku(&mut fb, u32::MAX)?;
|
||||
let first = fb.binary(BinOp::ISub, most_id, id)?;
|
||||
let last = fb.binary(BinOp::IAdd, id, one)?;
|
||||
// Its block's bit, in the last set: the block of its `PrimitiveId`, the last for one
|
||||
// past the blocks.
|
||||
let shift = ku(&mut fb, BLOCK_TRIANGLES.ilog2())?;
|
||||
let block = fb.binary(BinOp::ShiftRightLogical, id, shift)?;
|
||||
let most_block = ku(&mut fb, PROBE_BLOCKS - 1)?;
|
||||
let block = fb.glsl(GlslOp::UMin, &[block, most_block])?;
|
||||
let five = ku(&mut fb, 5)?;
|
||||
let block_word = fb.binary(BinOp::ShiftRightLogical, block, five)?;
|
||||
let blocks = ku(&mut fb, 1 + BLOCK_SET * PROBE_COUNT_WORDS)?;
|
||||
let block_at = fb.binary(BinOp::IAdd, flag_at, blocks)?;
|
||||
let block_at = fb.binary(BinOp::IAdd, block_at, block_word)?;
|
||||
let low = ku(&mut fb, 31)?;
|
||||
let bit = fb.binary(BinOp::BitwiseAnd, block, low)?;
|
||||
let bit = fb.binary(BinOp::ShiftLeftLogical, one, bit)?;
|
||||
let arm: ArmFn<'_, ()> = Box::new(move |fb, _| {
|
||||
let ptr = word_ptr(fb, flag_at)?;
|
||||
let one = ku(fb, 1)?;
|
||||
fb.atomic_store(ptr, Scope::Device, Semantics::RELAXED, one)?;
|
||||
for (at, value) in [(first_at, first), (last_at, last)] {
|
||||
let ptr = word_ptr(fb, at)?;
|
||||
fb.atomic(
|
||||
AtomicOp::UMax,
|
||||
ptr,
|
||||
Scope::Device,
|
||||
Semantics::RELAXED,
|
||||
value,
|
||||
)?;
|
||||
}
|
||||
let ptr = word_ptr(fb, flagged_at)?;
|
||||
fb.atomic(AtomicOp::IAdd, ptr, Scope::Device, Semantics::RELAXED, one)?;
|
||||
let ptr = word_ptr(fb, block_at)?;
|
||||
fb.atomic(AtomicOp::Or, ptr, Scope::Device, Semantics::RELAXED, bit)?;
|
||||
Ok(ArmEnd::FallThrough(Vec::new()))
|
||||
});
|
||||
fb.if_(&mut ctx, flagged, arm, None)?;
|
||||
// A straddling triangle: one added into the straddle count its `PrimitiveId` picks.
|
||||
let straddle_at = ku(&mut fb, 1 + STRADDLE_SET * PROBE_COUNT_WORDS)?;
|
||||
let straddle_at = fb.binary(BinOp::IAdd, flag_at, straddle_at)?;
|
||||
let lane_at = fb.binary(BinOp::ISub, lane, one)?;
|
||||
let straddle_at = fb.binary(BinOp::IAdd, straddle_at, lane_at)?;
|
||||
let arm: ArmFn<'_, ()> = Box::new(move |fb, _| {
|
||||
let ptr = word_ptr(fb, straddle_at)?;
|
||||
let one = ku(fb, 1)?;
|
||||
fb.atomic(AtomicOp::IAdd, ptr, Scope::Device, Semantics::RELAXED, one)?;
|
||||
Ok(ArmEnd::FallThrough(Vec::new()))
|
||||
});
|
||||
fb.if_(&mut ctx, straddles, arm, None)?;
|
||||
// Its block's bounds: the buckets of segments its widened bounds reach of each axis
|
||||
// where its `w` is positive (`visible_reach`), x's in the low half and y's in the
|
||||
// high, for a triangle of some `w` positive that reaches the regions
|
||||
// (`bind::fan_out::PROBE_BOUNDS_AT`).
|
||||
let buckets = ku(&mut fb, BOUND_BUCKETS)?;
|
||||
let mut halves = Vec::with_capacity(2);
|
||||
for (from, span, n) in [(x0, xs, nx), (y0, ys, ny)] {
|
||||
let lo = fb.binary(BinOp::IMul, from, buckets)?;
|
||||
let lo = fb.binary(BinOp::UDiv, lo, n)?;
|
||||
let to = fb.binary(BinOp::IAdd, from, span)?;
|
||||
let to = fb.binary(BinOp::ISub, to, one)?;
|
||||
let hi = fb.binary(BinOp::IMul, to, buckets)?;
|
||||
let hi = fb.binary(BinOp::UDiv, hi, n)?;
|
||||
let two = ku(&mut fb, 2)?;
|
||||
let past = fb.binary(BinOp::ShiftLeftLogical, two, hi)?;
|
||||
let below = fb.binary(BinOp::ShiftLeftLogical, one, lo)?;
|
||||
halves.push(fb.binary(BinOp::ISub, past, below)?);
|
||||
}
|
||||
let sixteen = ku(&mut fb, 16)?;
|
||||
let high = fb.binary(BinOp::ShiftLeftLogical, halves[1], sixteen)?;
|
||||
let bounds = fb.binary(BinOp::BitwiseOr, halves[0], high)?;
|
||||
let bounded = fb.binary(BinOp::LogicalAnd, some, both)?;
|
||||
let bounds_at = ku(&mut fb, PROBE_BOUNDS_AT)?;
|
||||
let bounds_at = fb.binary(BinOp::IAdd, flag_at, bounds_at)?;
|
||||
let bounds_at = fb.binary(BinOp::IAdd, bounds_at, block)?;
|
||||
let arm: ArmFn<'_, ()> = match fan.subgroup_bounds {
|
||||
// A subgroup's triangles raise a block's word once (`FanOutStage::subgroup_bounds`):
|
||||
// the lanes of the first lane's word OR their bounds together and one of them
|
||||
// raises it, then the lanes of another word, until none is left.
|
||||
true => Box::new(move |fb, ctx| {
|
||||
let body: LoopFn<'_, ()> = Box::new(move |fb, ctx, lc| {
|
||||
let first = fb.group_broadcast_first(bounds_at)?;
|
||||
let mine = fb.binary(BinOp::IEqual, bounds_at, first)?;
|
||||
let raise: ArmFn<'_, ()> = Box::new(move |fb, ctx| {
|
||||
let all =
|
||||
fb.group_arith(GroupArith::BitwiseOr, GroupMode::Reduce, bounds)?;
|
||||
let elected = fb.group_elect()?;
|
||||
let write: ArmFn<'_, ()> = Box::new(move |fb, _| {
|
||||
let ptr = word_ptr(fb, bounds_at)?;
|
||||
fb.atomic(
|
||||
AtomicOp::Or,
|
||||
ptr,
|
||||
Scope::Device,
|
||||
Semantics::RELAXED,
|
||||
all,
|
||||
)?;
|
||||
Ok(ArmEnd::FallThrough(Vec::new()))
|
||||
});
|
||||
fb.if_(ctx, elected, write, None)?;
|
||||
lc.break_(fb)?;
|
||||
Ok(ArmEnd::Exits)
|
||||
});
|
||||
fb.if_(ctx, mine, raise, None)?;
|
||||
Ok(())
|
||||
});
|
||||
let spec = LoopSpec {
|
||||
unrolling: crate::spirv::ir::Unrolling::DontUnroll,
|
||||
..LoopSpec::default()
|
||||
};
|
||||
fb.loop_(ctx, spec, body)?;
|
||||
Ok(ArmEnd::FallThrough(Vec::new()))
|
||||
}),
|
||||
false => Box::new(move |fb, _| {
|
||||
let ptr = word_ptr(fb, bounds_at)?;
|
||||
fb.atomic(AtomicOp::Or, ptr, Scope::Device, Semantics::RELAXED, bounds)?;
|
||||
Ok(ArmEnd::FallThrough(Vec::new()))
|
||||
}),
|
||||
};
|
||||
fb.if_(&mut ctx, bounded, arm, None)?;
|
||||
let counted = fb.binary(BinOp::UGreaterThan, count, none)?;
|
||||
let arm: ArmFn<'_, ()> = Box::new(move |fb, _| {
|
||||
let ptr = word_ptr(fb, count_at)?;
|
||||
fb.atomic(
|
||||
AtomicOp::IAdd,
|
||||
ptr,
|
||||
Scope::Device,
|
||||
Semantics::RELAXED,
|
||||
count,
|
||||
)?;
|
||||
Ok(ArmEnd::FallThrough(Vec::new()))
|
||||
});
|
||||
fb.if_(&mut ctx, counted, arm, None)?;
|
||||
// A triangle it does not flag of more pairs than a draw of few copies emits: the wide
|
||||
// word its `PrimitiveId` picks.
|
||||
let few = ku(&mut fb, FEW_COPIES)?;
|
||||
let wide = fb.binary(BinOp::UGreaterThan, count, few)?;
|
||||
let fanned = fb.unary(UnOp::LogicalNot, flagged)?;
|
||||
let wide = fb.binary(BinOp::LogicalAnd, fanned, wide)?;
|
||||
let arm: ArmFn<'_, ()> = Box::new(move |fb, _| {
|
||||
let ptr = word_ptr(fb, wide_at)?;
|
||||
let one = ku(fb, 1)?;
|
||||
fb.atomic_store(ptr, Scope::Device, Semantics::RELAXED, one)?;
|
||||
Ok(ArmEnd::FallThrough(Vec::new()))
|
||||
});
|
||||
fb.if_(&mut ctx, wide, arm, None)?;
|
||||
}
|
||||
None => {
|
||||
let c = Copies {
|
||||
table,
|
||||
positions,
|
||||
own_clips,
|
||||
own,
|
||||
clips,
|
||||
position,
|
||||
carried,
|
||||
primitive,
|
||||
vec4,
|
||||
f32_,
|
||||
};
|
||||
// Copy `i` of the `count`, no more than the stage's copies, its index carried in a
|
||||
// `Function` variable.
|
||||
let u32_ty = fb.uint_ty(32)?;
|
||||
let at = fb.local_var(u32_ty, None)?;
|
||||
let at = fb.var_ptr(at)?;
|
||||
let zero = ku(&mut fb, 0)?;
|
||||
fb.store(at, zero, MemAccess::default())?;
|
||||
let most = ku(&mut fb, copies)?;
|
||||
let count = fb.glsl(GlslOp::UMin, &[count, most])?;
|
||||
let c = &c;
|
||||
let body: LoopFn<'_, ()> = Box::new(move |fb, ctx, lc| {
|
||||
let i = fb.load(at, MemAccess::default())?;
|
||||
let done = fb.binary(BinOp::UGreaterThanEqual, i, count)?;
|
||||
let exit: ArmFn<'_, ()> = Box::new(move |fb, _| {
|
||||
lc.break_(fb)?;
|
||||
Ok(ArmEnd::Exits)
|
||||
});
|
||||
fb.if_(ctx, done, exit, None)?;
|
||||
let across = fb.binary(BinOp::UMod, i, xs)?;
|
||||
let down = fb.binary(BinOp::UDiv, i, xs)?;
|
||||
let sx = fb.binary(BinOp::IAdd, x0, across)?;
|
||||
let sy = fb.binary(BinOp::IAdd, y0, down)?;
|
||||
emit_copy(fb, c, (sx, sy))?;
|
||||
let one = ku(fb, 1)?;
|
||||
let next = fb.binary(BinOp::IAdd, i, one)?;
|
||||
fb.store(at, next, MemAccess::default())
|
||||
});
|
||||
let spec = LoopSpec {
|
||||
unrolling: crate::spirv::ir::Unrolling::DontUnroll,
|
||||
..LoopSpec::default()
|
||||
};
|
||||
fb.loop_(&mut ctx, spec, body)?;
|
||||
}
|
||||
}
|
||||
fb.ret(None)?;
|
||||
let f = fb.finish()?;
|
||||
let vertices = match fan.mode {
|
||||
RegionFanOut::Draw | RegionFanOut::DrawFew | RegionFanOut::RegionCopies => 3 * copies,
|
||||
RegionFanOut::Probe => 3,
|
||||
};
|
||||
let modes = vec![
|
||||
ExecMode::Triangles,
|
||||
ExecMode::OutputTriangleStrip,
|
||||
ExecMode::OutputVertices { n: vertices },
|
||||
ExecMode::Invocations { n: 1 },
|
||||
];
|
||||
mb.entry(ExecModel::Geometry, f, modes)?;
|
||||
mb.finalize()
|
||||
}
|
||||
@@ -1,639 +0,0 @@
|
||||
//! The synthesized geometry stages of a render pipeline whose fragment function reads
|
||||
//! `[[barycentric_coord]]` on a device without `fragmentShaderBarycentric`.
|
||||
//!
|
||||
//! Such a fragment function reads the weights from a `float2` center varying of each form it reads
|
||||
//! (`IoRole::Barycentric`, perspective-correct or not), and a `float3` read computes the third as
|
||||
//! `1 - (x + y)`, as Metal does (`lower::stage_io`). Metal's first two weights are, bit for bit,
|
||||
//! the interpolation of a varying that holds `(1, 0)`, `(0, 1)` and `(0, 0)` at a triangle's
|
||||
//! vertices in its vertex order, which is Vulkan's first-vertex order: a list's in index order, a
|
||||
//! strip's even triangle `(i, i + 1, i + 2)` and odd one `(i, i + 2, i + 1)`, the parity restarting
|
||||
//! after a primitive restart; a line's `(1 - t, t)` from its first vertex; a point's `(1, 0)`
|
||||
//! (Metal probes on the Apple M3 Max, macOS 27.0.1).
|
||||
//!
|
||||
//! A geometry stage receives a primitive's vertices in that order (measured on RADV, NVIDIA, ANV
|
||||
//! and lavapipe, every topology), so link adds one between the vertex and fragment stages
|
||||
//! ([`module`](GeometryStages::module)) that emits the primitive's vertices in the order it
|
||||
//! receives them:
|
||||
//!
|
||||
//! - one invocation per input primitive, of a topology class: points (`InputPoints`,
|
||||
//! `OutputPoints`), lines (`InputLines`, `OutputLineStrip`) or triangles (`Triangles`,
|
||||
//! `OutputTriangleStrip`), emitting one primitive of the same vertices, so its winding, and
|
||||
//! with it its facing, is the input's, and its provoking vertex, the one a flat input reads,
|
||||
//! stays the first;
|
||||
//! - each vertex's `Position` and clip distances, and in the point class its point size, as the
|
||||
//! vertex function wrote them;
|
||||
//! - each vertex output the fragment stage reads, at its location and component;
|
||||
//! - `PrimitiveId` from its input `PrimitiveId` where the fragment stage reads it: the count
|
||||
//! Vulkan gives the fragment stage without the stage;
|
||||
//! - the weights, at the locations link gives them after the vertex outputs' (`link::varyings`).
|
||||
//!
|
||||
//! The point class writes a point size exactly where the profile enables
|
||||
//! `shaderTessellationAndGeometryPointSize`, under which a geometry stage that writes none draws
|
||||
//! points of an undefined size: the vertex function's, or 1, its default (Metal sizes a point of
|
||||
//! the point class 1 where the vertex function writes none). Without the feature it writes none,
|
||||
//! and Vulkan draws points of size 1.
|
||||
//!
|
||||
//! A pipeline draws a class other than its input primitive topology class's where Metal does (the
|
||||
//! unspecified class draws every class, and a draw of another class draws as plain Metal does), so
|
||||
//! it carries the three stages, the point class's, the line class's and the triangle class's, in
|
||||
//! that order before its fragment stage (or last, without one): a `VkPipeline` runs the one of its
|
||||
//! draw's class (`RenderPipeline::runs_stage`).
|
||||
//!
|
||||
//! Refused, as `Unsupported{Barycentrics}`:
|
||||
//!
|
||||
//! - a post-tessellation vertex function, and a mesh render pipeline that reads the weights:
|
||||
//! not implemented; and a vertex function that writes `[[render_target_array_index]]` or
|
||||
//! `[[viewport_array_index]]` to its builtin beside a fragment function that reads the weights,
|
||||
//! whose `Layer` and `ViewportIndex` a geometry stage cannot read: not implemented;
|
||||
//! - a pipeline drawn as multiview (vertex amplification above 1 within `maxMultiviewViewCount`,
|
||||
//! where no stage declares `Layer`: such a pipeline is never drawn as views) on a device without
|
||||
//! `multiviewGeometryShader`;
|
||||
//! - a pipeline of the point or the unspecified class whose vertex function writes
|
||||
//! `[[point_size]]`, on a device without `shaderTessellationAndGeometryPointSize`;
|
||||
//! - a stage past `maxGeometryInputComponents`, `maxGeometryOutputComponents` or
|
||||
//! `maxGeometryTotalOutputComponents`, counted in whole locations as link counts the vertex and
|
||||
//! fragment limits.
|
||||
//!
|
||||
//! Each needs `fragmentShaderBarycentric` instead. A device without `geometryShader` either is
|
||||
//! refused at the function (`lower::stage_io`).
|
||||
//!
|
||||
//! A variant that draws a rate-mapped pass's triangles once (`VariantKey::region_fan_out`)
|
||||
//! carries the stages too, its triangle class's the fan-out stage ([`fan_out`]),
|
||||
//! which needs `geometryShader` and `shaderClipDistance`, four clip distances past the vertex
|
||||
//! function's within `maxClipDistances` and `maxCombinedClipAndCullDistances`, and room in
|
||||
//! `maxGeometryTotalOutputComponents` for one copy's vertices; and, for the probe,
|
||||
//! `vertexPipelineStoresAndAtomics`. Refused as `NotImplemented(RasterizationRateMap)` beside
|
||||
//! the weights, for a mesh or post-tessellation vertex function or one that selects its slice or
|
||||
//! viewport, and a pipeline that amplifies its vertices; as `Unsupported{RasterizationRateMap}`
|
||||
//! needing what the device lacks otherwise, a limit of the stage included. The consumer draws
|
||||
//! such a pipeline region by region instead.
|
||||
|
||||
use super::fan_out::{self, FanOutStage};
|
||||
use crate::budget::Meter;
|
||||
use crate::device::requirements::{Requirements, SubgroupOp, VkFeature, VkLimit, VkProperty};
|
||||
use crate::device::DeviceProfile;
|
||||
use crate::error::{Capability, Error, Feature, Unsupported};
|
||||
use crate::metal::PrimitiveTopologyClass;
|
||||
use crate::pipeline::artifact::{Reconvergence, SpecializationLayout, StageModule, StrategyCensus};
|
||||
use crate::pipeline::graphics::RegionFanOut;
|
||||
use crate::pipeline::interface::StageInterface;
|
||||
use crate::pipeline::link::varyings::Locations;
|
||||
use crate::pipeline::stage_io::{IoNumeric, IoRole, IoType, StageBuiltin};
|
||||
use crate::pipeline::sym::{Stage, VaryingKey};
|
||||
use crate::spirv::builder::{FunctionBuilder, ModuleBuilder};
|
||||
use crate::spirv::error::BResult;
|
||||
use crate::spirv::ids::{GlobalId, TypeId, Value};
|
||||
use crate::spirv::ir::{
|
||||
ConstBits, Constant, ExecMode, ExecModel, IoDecor, IoDir, MemAccess, Type, TypedModule,
|
||||
};
|
||||
use crate::spirv::serialize::{SymbolTable, ENTRY_NAME};
|
||||
use crate::spv::BuiltIn as B;
|
||||
use crate::vk;
|
||||
|
||||
/// The topology classes a pipeline's geometry stages are made for, in their order among its
|
||||
/// stages.
|
||||
pub const CLASSES: [PrimitiveTopologyClass; 3] = [
|
||||
PrimitiveTopologyClass::Point,
|
||||
PrimitiveTopologyClass::Line,
|
||||
PrimitiveTopologyClass::Triangle,
|
||||
];
|
||||
|
||||
/// What a pipeline's geometry stages pass through and write (the module docs).
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct GeometryStages {
|
||||
/// The vertex outputs the fragment stage reads, each with its type, in output order.
|
||||
pub varyings: Vec<(VaryingKey, IoType)>,
|
||||
/// The forms of the weights the fragment stage reads: `true` perspective-correct.
|
||||
pub forms: Vec<bool>,
|
||||
/// The elements of the vertex function's `ClipDistance`, 0 for none.
|
||||
pub clip_distances: u32,
|
||||
/// The vertex function declares `PointSize`.
|
||||
pub point_size: bool,
|
||||
/// The point class's stage writes `PointSize` (the profile enables
|
||||
/// `shaderTessellationAndGeometryPointSize`).
|
||||
pub writes_point_size: bool,
|
||||
/// The fragment stage reads `PrimitiveId`.
|
||||
pub primitive_id: bool,
|
||||
/// The pipeline is drawn as multiview.
|
||||
pub multiview: bool,
|
||||
/// The triangle class's stage is the fan-out stage ([`fan_out`]).
|
||||
pub fan_out: Option<FanOutStage>,
|
||||
}
|
||||
|
||||
/// The weights' stages refused as not implemented on every device.
|
||||
fn not_implemented() -> Error {
|
||||
Unsupported::not_implemented(Feature::Barycentrics).into()
|
||||
}
|
||||
|
||||
/// The weights' stages refused as needing `fragmentShaderBarycentric`, which makes them needless,
|
||||
/// or `capability`.
|
||||
fn refused(capability: Capability) -> Error {
|
||||
let needs = vec![
|
||||
vec![Capability::Feature(VkFeature::FragmentShaderBarycentric)],
|
||||
vec![capability],
|
||||
];
|
||||
Unsupported::needs_any_of(Feature::Barycentrics, needs).into()
|
||||
}
|
||||
|
||||
/// The geometry stages of the render pipeline of stages `ifaces` (vertex, then fragment when it
|
||||
/// has one), drawn as `class` with vertex amplification up to `amplification`, where its fragment
|
||||
/// stage reads the weights as varyings, or its variant fans a rate-mapped pass's triangles out
|
||||
/// (`fan_out`); `None` where neither. Refused as
|
||||
/// the module docs state. A mesh pipeline (`mesh`) whose fragment stage reads the weights is not
|
||||
/// implemented.
|
||||
pub fn plan(
|
||||
ifaces: &[&StageInterface],
|
||||
class: PrimitiveTopologyClass,
|
||||
amplification: u32,
|
||||
mesh: bool,
|
||||
fan_out: Option<RegionFanOut>,
|
||||
p: &DeviceProfile,
|
||||
) -> Result<Option<GeometryStages>, Error> {
|
||||
let fragment = ifaces.iter().find(|i| i.stage == Stage::Fragment);
|
||||
let vertex = ifaces.iter().find(|i| i.stage == Stage::Vertex);
|
||||
let mut forms: Vec<bool> = fragment
|
||||
.iter()
|
||||
.flat_map(|f| &f.io.inputs)
|
||||
.filter_map(|v| match v.role {
|
||||
IoRole::Barycentric { perspective } => Some(perspective),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
forms.sort_unstable();
|
||||
forms.dedup();
|
||||
// A variant that draws its regions' copies from its vertex function synthesizes no stage
|
||||
// for them (`LoweringInputs::region_copies`).
|
||||
if let Some(mode) = fan_out.filter(|&mode| mode != RegionFanOut::RegionCopies) {
|
||||
return fan_plan(ifaces, (!forms.is_empty(), mode), (amplification, mesh), p).map(Some);
|
||||
}
|
||||
if forms.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
let vertex = match vertex {
|
||||
Some(v) if !mesh && v.tessellation.is_none() => v,
|
||||
_ => return Err(not_implemented()),
|
||||
};
|
||||
let builtins = &vertex.io.builtins;
|
||||
// A stage after the vertex function stores the indices Vulkan uses: a vertex function's own
|
||||
// `Layer` or `ViewportIndex` would not reach the rasterizer.
|
||||
if builtins
|
||||
.iter()
|
||||
.any(|b| matches!(b, StageBuiltin::Layer | StageBuiltin::ViewportIndex))
|
||||
{
|
||||
return Err(not_implemented());
|
||||
}
|
||||
let f = p.fields();
|
||||
let enabled = &f.enabled.features;
|
||||
// Drawn as multiview where its views fit the device's, as `compile::api` requires them, unless
|
||||
// a stage declares `Layer`: the binder draws such a pipeline's amplifications one at a time.
|
||||
let declares_layer = fragment.is_some_and(|f| {
|
||||
f.io.builtins.contains(&StageBuiltin::Layer)
|
||||
|| f.io.zero_indices.contains(&StageBuiltin::Layer)
|
||||
});
|
||||
let multiview =
|
||||
!declares_layer && amplification.min(f.limits.max_multiview_view_count.max(1)) > 1;
|
||||
if multiview && !enabled.contains(&VkFeature::MultiviewGeometryShader) {
|
||||
return Err(refused(Capability::Feature(
|
||||
VkFeature::MultiviewGeometryShader,
|
||||
)));
|
||||
}
|
||||
let point_size = builtins
|
||||
.iter()
|
||||
.any(|b| matches!(b, StageBuiltin::PointSize { .. }));
|
||||
let written_size = builtins
|
||||
.iter()
|
||||
.any(|b| matches!(b, StageBuiltin::PointSize { default: false }));
|
||||
let writes_point_size = enabled.contains(&VkFeature::ShaderTessellationAndGeometryPointSize);
|
||||
let draws_points = matches!(
|
||||
class,
|
||||
PrimitiveTopologyClass::Point | PrimitiveTopologyClass::Unspecified
|
||||
);
|
||||
if draws_points && written_size && !writes_point_size {
|
||||
return Err(refused(Capability::Feature(
|
||||
VkFeature::ShaderTessellationAndGeometryPointSize,
|
||||
)));
|
||||
}
|
||||
let clip_distances = builtins
|
||||
.iter()
|
||||
.find_map(|b| match b {
|
||||
StageBuiltin::ClipDistance { count } => Some(*count),
|
||||
_ => None,
|
||||
})
|
||||
.unwrap_or(0);
|
||||
let varyings = vertex
|
||||
.io
|
||||
.outputs
|
||||
.iter()
|
||||
.filter(|o| fragment.is_some_and(|f| f.io.inputs.iter().any(|i| i.key == o.key)))
|
||||
.map(|o| (o.key.clone(), o.ty))
|
||||
.collect();
|
||||
Ok(Some(GeometryStages {
|
||||
varyings,
|
||||
forms,
|
||||
clip_distances,
|
||||
point_size,
|
||||
writes_point_size,
|
||||
primitive_id: fragment.is_some_and(|f| f.io.builtins.contains(&StageBuiltin::PrimitiveId)),
|
||||
multiview,
|
||||
fan_out: None,
|
||||
}))
|
||||
}
|
||||
|
||||
/// The stages of a fan-out variant (the module docs): refused beside the weights (`weights`), and
|
||||
/// where the pipeline or the device cannot carry the stage, `mode`'s.
|
||||
fn fan_plan(
|
||||
ifaces: &[&StageInterface],
|
||||
(weights, mode): (bool, RegionFanOut),
|
||||
(amplification, mesh): (u32, bool),
|
||||
p: &DeviceProfile,
|
||||
) -> Result<GeometryStages, Error> {
|
||||
let not_implemented = || Unsupported::not_implemented(Feature::RasterizationRateMap).into();
|
||||
let fragment = ifaces.iter().find(|i| i.stage == Stage::Fragment);
|
||||
let vertex = match ifaces.iter().find(|i| i.stage == Stage::Vertex) {
|
||||
Some(v) if !mesh && v.tessellation.is_none() => v,
|
||||
_ => return Err(not_implemented()),
|
||||
};
|
||||
let builtins = &vertex.io.builtins;
|
||||
let selects = builtins
|
||||
.iter()
|
||||
.any(|b| matches!(b, StageBuiltin::Layer | StageBuiltin::ViewportIndex));
|
||||
if weights || selects || amplification > 1 {
|
||||
return Err(not_implemented());
|
||||
}
|
||||
let f = p.fields();
|
||||
let enabled = &f.enabled.features;
|
||||
let mut needs = vec![VkFeature::GeometryShader, VkFeature::ShaderClipDistance];
|
||||
if mode == RegionFanOut::Probe {
|
||||
needs.push(VkFeature::VertexPipelineStoresAndAtomics);
|
||||
}
|
||||
if let Some(&lacks) = needs.iter().find(|n| !enabled.contains(n)) {
|
||||
return Err(Unsupported::needs_any_of(
|
||||
Feature::RasterizationRateMap,
|
||||
vec![vec![Capability::Feature(lacks)]],
|
||||
)
|
||||
.into());
|
||||
}
|
||||
let clip_distances = builtins
|
||||
.iter()
|
||||
.find_map(|b| match b {
|
||||
StageBuiltin::ClipDistance { count } => Some(*count),
|
||||
_ => None,
|
||||
})
|
||||
.unwrap_or(0);
|
||||
let l = &f.limits;
|
||||
for (limit, available) in [
|
||||
(VkLimit::MaxClipDistances, l.max_clip_distances),
|
||||
(
|
||||
VkLimit::MaxCombinedClipAndCullDistances,
|
||||
l.max_combined_clip_and_cull_distances,
|
||||
),
|
||||
] {
|
||||
let required = u64::from(clip_distances) + 4;
|
||||
if required > u64::from(available) {
|
||||
return Err(Unsupported::needs_any_of(
|
||||
Feature::RasterizationRateMap,
|
||||
vec![vec![Capability::Limit {
|
||||
limit,
|
||||
required,
|
||||
available: u64::from(available),
|
||||
}]],
|
||||
)
|
||||
.into());
|
||||
}
|
||||
}
|
||||
let varyings = vertex
|
||||
.io
|
||||
.outputs
|
||||
.iter()
|
||||
.filter(|o| fragment.is_some_and(|f| f.io.inputs.iter().any(|i| i.key == o.key)))
|
||||
.map(|o| (o.key.clone(), o.ty))
|
||||
.collect();
|
||||
let point_size = builtins
|
||||
.iter()
|
||||
.any(|b| matches!(b, StageBuiltin::PointSize { .. }));
|
||||
Ok(GeometryStages {
|
||||
varyings,
|
||||
forms: Vec::new(),
|
||||
clip_distances,
|
||||
point_size,
|
||||
writes_point_size: enabled.contains(&VkFeature::ShaderTessellationAndGeometryPointSize),
|
||||
primitive_id: fragment.is_some_and(|f| f.io.builtins.contains(&StageBuiltin::PrimitiveId)),
|
||||
multiview: false,
|
||||
fan_out: Some(FanOutStage::new(mode)),
|
||||
})
|
||||
}
|
||||
|
||||
impl GeometryStages {
|
||||
/// Refuses stages whose inputs or outputs at `locations` pass the device's geometry limits
|
||||
/// (the module docs); for a fan-out variant, sets the copies its triangle stage emits.
|
||||
pub fn check_limits(&mut self, locations: &Locations, p: &DeviceProfile) -> Result<(), Error> {
|
||||
let l = &p.fields().limits;
|
||||
let end = |keys: &mut dyn Iterator<Item = &VaryingKey>| -> Result<u64, Error> {
|
||||
let mut end = 0u64;
|
||||
for k in keys {
|
||||
let (location, _) = locations.get(k).copied().ok_or_else(|| {
|
||||
Error::Internal(crate::error::InternalError::new(
|
||||
crate::error::InternalKind::Invariant,
|
||||
"a geometry stage's varying without its location",
|
||||
))
|
||||
})?;
|
||||
end = end.max(u64::from(location) + 1);
|
||||
}
|
||||
Ok(end)
|
||||
};
|
||||
let weights: Vec<VaryingKey> = self
|
||||
.forms
|
||||
.iter()
|
||||
.map(|&p| VaryingKey::barycentric(p))
|
||||
.collect();
|
||||
let inputs = end(&mut self.varyings.iter().map(|(k, _)| k))?;
|
||||
let outputs = end(&mut self.varyings.iter().map(|(k, _)| k).chain(&weights))?;
|
||||
// A copy's vertex: its varyings' locations, its position, its clip distances and its
|
||||
// primitive ID, in components.
|
||||
if let Some(fan) = &mut self.fan_out {
|
||||
let vertex = outputs * 4 + 4 + u64::from(self.clip_distances) + 4 + 1;
|
||||
let room = u64::from(l.max_geometry_total_output_components) / (3 * vertex);
|
||||
if room == 0 {
|
||||
return Err(Unsupported::needs_any_of(
|
||||
Feature::RasterizationRateMap,
|
||||
vec![vec![Capability::Limit {
|
||||
limit: VkLimit::MaxGeometryTotalOutputComponents,
|
||||
required: 3 * vertex,
|
||||
available: u64::from(l.max_geometry_total_output_components),
|
||||
}]],
|
||||
)
|
||||
.into());
|
||||
}
|
||||
let most = match fan.mode {
|
||||
RegionFanOut::DrawFew => crate::bind::fan_out::FEW_COPIES,
|
||||
RegionFanOut::Draw | RegionFanOut::Probe | RegionFanOut::RegionCopies => {
|
||||
fan_out::MOST_COPIES
|
||||
}
|
||||
};
|
||||
fan.copies = room.min(u64::from(most)) as u32;
|
||||
let properties = &p.enabled().properties;
|
||||
fan.subgroup_bounds = fan.mode == RegionFanOut::Probe
|
||||
&& [
|
||||
VkProperty::SubgroupGeometryStage,
|
||||
VkProperty::SubgroupOperation(SubgroupOp::Basic),
|
||||
VkProperty::SubgroupOperation(SubgroupOp::Arithmetic),
|
||||
VkProperty::SubgroupOperation(SubgroupOp::Ballot),
|
||||
]
|
||||
.iter()
|
||||
.all(|property| properties.contains(property));
|
||||
}
|
||||
let vertices = 3u64;
|
||||
for (limit, required, available) in [
|
||||
(
|
||||
VkLimit::MaxGeometryInputComponents,
|
||||
inputs * 4,
|
||||
l.max_geometry_input_components,
|
||||
),
|
||||
(
|
||||
VkLimit::MaxGeometryOutputComponents,
|
||||
outputs * 4,
|
||||
l.max_geometry_output_components,
|
||||
),
|
||||
(
|
||||
VkLimit::MaxGeometryTotalOutputComponents,
|
||||
outputs * 4 * vertices,
|
||||
l.max_geometry_total_output_components,
|
||||
),
|
||||
] {
|
||||
if required > u64::from(available) {
|
||||
let limit = Capability::Limit {
|
||||
limit,
|
||||
required,
|
||||
available: u64::from(available),
|
||||
};
|
||||
return Err(match self.fan_out {
|
||||
Some(_) => {
|
||||
Unsupported::needs_any_of(Feature::RasterizationRateMap, vec![vec![limit]])
|
||||
.into()
|
||||
}
|
||||
None => refused(limit),
|
||||
});
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The pipeline's geometry stages, one per class of [`CLASSES`] in its order, as final modules
|
||||
/// under link table `table`, with their requirements: verified by the owned verifier,
|
||||
/// serialized and relocated, as a compiled function's module is.
|
||||
pub fn stages(
|
||||
&self,
|
||||
table: &impl SymbolTable,
|
||||
p: &DeviceProfile,
|
||||
m: &mut Meter,
|
||||
) -> Result<Vec<(StageModule, Requirements)>, Error> {
|
||||
let mut out = Vec::with_capacity(CLASSES.len());
|
||||
for class in CLASSES {
|
||||
let module = self.module(class)?;
|
||||
let stats = crate::spirv::verify::verify(&module, p, m)?;
|
||||
let module = crate::spirv::serialize::serialize(module)?;
|
||||
let words = crate::spirv::serialize::relocate(&module, table)?;
|
||||
let mut requirements = module.requirements;
|
||||
if self.multiview {
|
||||
requirements
|
||||
.features
|
||||
.insert(VkFeature::MultiviewGeometryShader);
|
||||
}
|
||||
out.push((
|
||||
StageModule {
|
||||
stage: vk::ShaderStage::GEOMETRY,
|
||||
entry_point: ENTRY_NAME.to_owned(),
|
||||
spirv: words.into(),
|
||||
specialization: SpecializationLayout::default(),
|
||||
required_subgroup_size: None,
|
||||
stage_flags: vk::PipelineShaderStageCreateFlags::empty(),
|
||||
reconvergence: Reconvergence::Guaranteed,
|
||||
precision_notes: Vec::new(),
|
||||
strategies: StrategyCensus::default(),
|
||||
constant_blob: None,
|
||||
rounded_colors: Vec::new(),
|
||||
specialized_notes: Vec::new(),
|
||||
own_pixel_textures: Vec::new(),
|
||||
snapshot_textures: Vec::new(),
|
||||
snapshot_refusals: Vec::new(),
|
||||
level_reads: Vec::new(),
|
||||
private_bytes: 0,
|
||||
stats,
|
||||
},
|
||||
requirements,
|
||||
));
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// The geometry stage of `class` (the module docs).
|
||||
pub fn module(&self, class: PrimitiveTopologyClass) -> BResult<TypedModule> {
|
||||
if let (PrimitiveTopologyClass::Triangle, Some(fan)) = (class, self.fan_out) {
|
||||
return fan_out::module(self, fan);
|
||||
}
|
||||
let (n, input, output) = match class {
|
||||
PrimitiveTopologyClass::Point => (1, ExecMode::InputPoints, ExecMode::OutputPoints),
|
||||
PrimitiveTopologyClass::Line => (2, ExecMode::InputLines, ExecMode::OutputLineStrip),
|
||||
_ => (3, ExecMode::Triangles, ExecMode::OutputTriangleStrip),
|
||||
};
|
||||
let mut mb = ModuleBuilder::new();
|
||||
let u32_ = scalar(&mut mb, IoNumeric::Uint)?;
|
||||
let f32_ = scalar(&mut mb, IoNumeric::Float)?;
|
||||
let vec2 = mb.ty(Type::Vector { elem: f32_, len: 2 })?;
|
||||
let vec4 = mb.ty(Type::Vector { elem: f32_, len: 4 })?;
|
||||
let void = mb.ty(Type::Void)?;
|
||||
let per_vertex = |mb: &mut ModuleBuilder, elem: TypeId| array(mb, elem, n);
|
||||
// Each value a vertex carries: its input, read per vertex, and its output.
|
||||
let mut carried: Vec<(GlobalId, GlobalId)> = Vec::new();
|
||||
let ty = per_vertex(&mut mb, vec4)?;
|
||||
carried.push((
|
||||
mb.builtin(B::Position, IoDir::Input, ty)?,
|
||||
mb.builtin(B::Position, IoDir::Output, vec4)?,
|
||||
));
|
||||
if self.clip_distances > 0 {
|
||||
let clip = array(&mut mb, f32_, self.clip_distances)?;
|
||||
let ty = per_vertex(&mut mb, clip)?;
|
||||
carried.push((
|
||||
mb.builtin(B::ClipDistance, IoDir::Input, ty)?,
|
||||
mb.builtin(B::ClipDistance, IoDir::Output, clip)?,
|
||||
));
|
||||
}
|
||||
let points = class == PrimitiveTopologyClass::Point && self.writes_point_size;
|
||||
// The vertex function's point size, or 1 where it declares none.
|
||||
let mut size = None;
|
||||
if points {
|
||||
let output = mb.builtin(B::PointSize, IoDir::Output, f32_)?;
|
||||
let input = match self.point_size {
|
||||
true => {
|
||||
let ty = per_vertex(&mut mb, f32_)?;
|
||||
Some(mb.builtin(B::PointSize, IoDir::Input, ty)?)
|
||||
}
|
||||
false => None,
|
||||
};
|
||||
size = Some((input, output));
|
||||
}
|
||||
let packed = IoDecor {
|
||||
packed: true,
|
||||
..IoDecor::default()
|
||||
};
|
||||
for (key, io) in &self.varyings {
|
||||
let elem = scalar(&mut mb, io.numeric)?;
|
||||
let ty = match io.components {
|
||||
1 => elem,
|
||||
c => mb.ty(Type::Vector { elem, len: c })?,
|
||||
};
|
||||
let input_ty = per_vertex(&mut mb, ty)?;
|
||||
carried.push((
|
||||
mb.io(key.clone(), IoDir::Input, input_ty, packed)?,
|
||||
mb.io(key.clone(), IoDir::Output, ty, packed)?,
|
||||
));
|
||||
}
|
||||
let mut weights = Vec::with_capacity(self.forms.len());
|
||||
for &perspective in &self.forms {
|
||||
let key = VaryingKey::barycentric(perspective);
|
||||
weights.push(mb.io(key, IoDir::Output, vec2, IoDecor::default())?);
|
||||
}
|
||||
let primitive = match self.primitive_id {
|
||||
true => Some((
|
||||
mb.builtin(B::PrimitiveId, IoDir::Input, u32_)?,
|
||||
mb.builtin(B::PrimitiveId, IoDir::Output, u32_)?,
|
||||
)),
|
||||
false => None,
|
||||
};
|
||||
let mut fb = mb.function(void)?;
|
||||
for k in 0..n {
|
||||
let at = ku(&mut fb, k)?;
|
||||
for &(input, output) in &carried {
|
||||
let base = fb.module().global_value(input)?;
|
||||
let from = fb.access_chain(base, &[at])?;
|
||||
let value = fb.load(from, MemAccess::default())?;
|
||||
let to = fb.module().global_value(output)?;
|
||||
fb.store(to, value, MemAccess::default())?;
|
||||
}
|
||||
if let Some((input, output)) = size {
|
||||
let value = match input {
|
||||
Some(input) => {
|
||||
let base = fb.module().global_value(input)?;
|
||||
let from = fb.access_chain(base, &[at])?;
|
||||
fb.load(from, MemAccess::default())?
|
||||
}
|
||||
None => kf(&mut fb, 1.0)?,
|
||||
};
|
||||
let to = fb.module().global_value(output)?;
|
||||
fb.store(to, value, MemAccess::default())?;
|
||||
}
|
||||
// `(1, 0)`, `(0, 1)`, `(0, 0)` at the first, second and third vertex.
|
||||
let x = kf(&mut fb, if k == 0 { 1.0 } else { 0.0 })?;
|
||||
let y = kf(&mut fb, if k == 1 { 1.0 } else { 0.0 })?;
|
||||
let value = fb.composite_construct(vec2, &[x, y])?;
|
||||
for &g in &weights {
|
||||
let to = fb.module().global_value(g)?;
|
||||
fb.store(to, value, MemAccess::default())?;
|
||||
}
|
||||
if let Some((input, output)) = primitive {
|
||||
let from = fb.module().global_value(input)?;
|
||||
let value = fb.load(from, MemAccess::default())?;
|
||||
let to = fb.module().global_value(output)?;
|
||||
fb.store(to, value, MemAccess::default())?;
|
||||
}
|
||||
fb.emit_vertex()?;
|
||||
}
|
||||
fb.end_primitive()?;
|
||||
fb.ret(None)?;
|
||||
let f = fb.finish()?;
|
||||
let modes = vec![
|
||||
input,
|
||||
output,
|
||||
ExecMode::OutputVertices { n },
|
||||
ExecMode::Invocations { n: 1 },
|
||||
];
|
||||
mb.entry(ExecModel::Geometry, f, modes)?;
|
||||
mb.finalize()
|
||||
}
|
||||
}
|
||||
|
||||
/// An array of `n` elements of `elem`.
|
||||
pub(super) fn array(mb: &mut ModuleBuilder, elem: TypeId, n: u32) -> BResult<TypeId> {
|
||||
let u32_ = scalar(mb, IoNumeric::Uint)?;
|
||||
let len = mb.constant(Constant::Scalar {
|
||||
ty: u32_,
|
||||
bits: ConstBits(u64::from(n)),
|
||||
})?;
|
||||
mb.ty(Type::Array {
|
||||
elem,
|
||||
len,
|
||||
stride: None,
|
||||
})
|
||||
}
|
||||
|
||||
/// The `uint` constant `v`.
|
||||
pub(super) fn ku(fb: &mut FunctionBuilder<'_>, v: u32) -> BResult<Value> {
|
||||
let c = fb.u32_const(v)?;
|
||||
fb.module().const_value(c)
|
||||
}
|
||||
|
||||
/// The `float` constant `v`.
|
||||
pub(super) fn kf(fb: &mut FunctionBuilder<'_>, v: f32) -> BResult<Value> {
|
||||
let ty = fb.module().ty(Type::Float { width: 32 })?;
|
||||
let c = fb.module().constant(Constant::Scalar {
|
||||
ty,
|
||||
bits: ConstBits(u64::from(v.to_bits())),
|
||||
})?;
|
||||
fb.module().const_value(c)
|
||||
}
|
||||
|
||||
/// The scalar type of `numeric`.
|
||||
pub(super) fn scalar(mb: &mut ModuleBuilder, numeric: IoNumeric) -> BResult<TypeId> {
|
||||
match numeric {
|
||||
IoNumeric::Float => mb.ty(Type::Float { width: 32 }),
|
||||
IoNumeric::Sint => mb.ty(Type::Int {
|
||||
width: 32,
|
||||
signed: true,
|
||||
}),
|
||||
IoNumeric::Uint => mb.ty(Type::Int {
|
||||
width: 32,
|
||||
signed: false,
|
||||
}),
|
||||
}
|
||||
}
|
||||
@@ -764,8 +764,6 @@ pub fn graphics_state(
|
||||
.any(|o| o.role == IoRole::ViewportIndex),
|
||||
// A band variant's pipeline states its band (`link`).
|
||||
line_band: None,
|
||||
// A fan-out variant's pipeline states its fan-out (`link`).
|
||||
region_fan_out: None,
|
||||
writes_point_size: vs.writes_point_size(),
|
||||
writes_depth: fs.is_some_and(|fs| {
|
||||
fs.io
|
||||
@@ -790,16 +788,11 @@ pub fn graphics_state(
|
||||
}
|
||||
|
||||
/// Whether a fragment stage of interface `io` reads `[[barycentric_coord]]`
|
||||
/// (`GraphicsState::reads_barycentric_coord`): either `BaryCoord` builtin, or either form's
|
||||
/// varying (`IoRole::Barycentric`), perspective-correct or not.
|
||||
/// (`GraphicsState::reads_barycentric_coord`): either `BaryCoord` builtin.
|
||||
fn reads_barycentric_coord(io: &StageIo) -> bool {
|
||||
io.builtins
|
||||
.iter()
|
||||
.any(|b| matches!(b, StageBuiltin::BaryCoord { .. }))
|
||||
|| io
|
||||
.inputs
|
||||
.iter()
|
||||
.any(|v| matches!(v.role, IoRole::Barycentric { .. }))
|
||||
}
|
||||
|
||||
/// Whether a fragment stage of interface `io` reads `[[primitive_id]]`
|
||||
@@ -832,15 +825,13 @@ fn sample_invocations(
|
||||
return Ok(());
|
||||
}
|
||||
let io = &fs.io;
|
||||
// The barycentric weights' varyings are center varyings, and an interpolant read at the
|
||||
// center is read as one.
|
||||
// An interpolant read at the center is read as a center varying.
|
||||
let interpolated = |reads: fn(Sampling) -> bool| {
|
||||
io.inputs.iter().any(|v| match v.role {
|
||||
IoRole::Varying {
|
||||
interpolation: Some(Interpolation::Smooth { sampling, .. }),
|
||||
..
|
||||
} => reads(sampling),
|
||||
IoRole::Barycentric { .. } => reads(Sampling::Center),
|
||||
_ => false,
|
||||
})
|
||||
};
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
//! limits (the sweep over every committed profile), stage-interface locations and packing, vertex
|
||||
//! input, graphics state, and the property over random pipelines.
|
||||
|
||||
mod fan_out;
|
||||
mod geometry;
|
||||
mod property;
|
||||
mod render;
|
||||
mod sweep;
|
||||
|
||||
@@ -1,411 +0,0 @@
|
||||
//! The fan-out variant's geometry stages (`link::fan_out`): its triangle class's stage emits as
|
||||
//! many copies as the device's limits leave room for, a probe's none, each module valid on the
|
||||
//! device; a probe pushes its flag's index and adds a triangle's copies into the count its
|
||||
//! primitive's index picks; and the refusals.
|
||||
|
||||
use super::*;
|
||||
use crate::error::Needs;
|
||||
use crate::metal::PrimitiveTopologyClass as Class;
|
||||
use crate::pipeline::link::geometry::{plan, GeometryStages, CLASSES};
|
||||
use crate::pipeline::stage_io::StageBuiltin;
|
||||
use crate::pipeline::RegionFanOut;
|
||||
|
||||
fn stage(stage: Stage, io: StageIo) -> FunctionArtifact {
|
||||
let mut i = iface(stage, vec![], vec![]);
|
||||
i.io = io;
|
||||
artifact(i, None)
|
||||
}
|
||||
|
||||
/// A vertex function writing `a` (`float4`), its position and two clip distances, and a
|
||||
/// fragment function reading `a` and the primitive ID.
|
||||
fn pipeline() -> (FunctionArtifact, FunctionArtifact) {
|
||||
let f4 = io_ty(IoNumeric::Float, 4);
|
||||
let mut vio = stage_io(vec![], vec![varying("a", f4, None)]);
|
||||
vio.builtins = vec![
|
||||
StageBuiltin::Position { invariant: false },
|
||||
StageBuiltin::ClipDistance { count: 2 },
|
||||
];
|
||||
let mut fio = stage_io(vec![varying("a", f4, SMOOTH)], vec![color(0, 0, f4)]);
|
||||
fio.builtins = vec![StageBuiltin::PrimitiveId];
|
||||
(stage(Stage::Vertex, vio), stage(Stage::Fragment, fio))
|
||||
}
|
||||
|
||||
fn fanned(mode: RegionFanOut) -> LinkInputs {
|
||||
let mut r = RenderLinkInputs::new();
|
||||
r.color_attachments[0] = Some(crate::pipeline::descriptor::ColorAttachmentDescriptor::new(
|
||||
crate::metal::PixelFormat::RGBA32Float,
|
||||
));
|
||||
r.input_primitive_topology = Class::Triangle;
|
||||
r.region_fan_out = Some(mode);
|
||||
LinkInputs::Render(Box::new(r))
|
||||
}
|
||||
|
||||
/// How many instructions of `words` have opcode `op`.
|
||||
fn count_ops(words: &[u32], op: u32) -> usize {
|
||||
let mut i = 5;
|
||||
let mut n = 0;
|
||||
while let Some(&w) = words.get(i) {
|
||||
let len = (w >> 16) as usize;
|
||||
n += usize::from(w & 0xFFFF == op);
|
||||
if len == 0 {
|
||||
break;
|
||||
}
|
||||
i += len;
|
||||
}
|
||||
n
|
||||
}
|
||||
|
||||
/// A draw's triangle stage emits three vertices a copy, in a loop of as many copies as its state
|
||||
/// says, its output vertices three a copy, its copies' arithmetic `NoContraction`, and a probe's
|
||||
/// none and pushes its flag's index in the geometry stage's own range, its one loop its
|
||||
/// subgroups' raise of the blocks' bounds where the device runs subgroup operations in the
|
||||
/// geometry stage (`FanOutStage::subgroup_bounds`: the Iris Xe's and the Pascal's, not
|
||||
/// lavapipe's); its `Position` and `ClipDistance` are `Invariant`; every class's module is valid
|
||||
/// on the device.
|
||||
#[test]
|
||||
fn a_fan_out_variant_s_triangle_stage_emits_its_copies() {
|
||||
for stem in ["lavapipe", "intel-irisxe-rplp-anv", "nvidia-pascal-linux"] {
|
||||
let p = profile(stem);
|
||||
let (v, f) = pipeline();
|
||||
for mode in [
|
||||
RegionFanOut::Draw,
|
||||
RegionFanOut::Probe,
|
||||
RegionFanOut::DrawFew,
|
||||
] {
|
||||
let linked =
|
||||
link(&[&v, &f], &fanned(mode), &p).unwrap_or_else(|e| panic!("{stem}: {e}"));
|
||||
let g = linked.geometry.as_ref().expect("geometry stages");
|
||||
let fan = g.fan_out.expect("the fan-out stage");
|
||||
let most = match mode {
|
||||
RegionFanOut::DrawFew => crate::bind::fan_out::FEW_COPIES,
|
||||
_ => 16,
|
||||
};
|
||||
assert!((1..=most).contains(&fan.copies), "{stem}: {}", fan.copies);
|
||||
let state = linked
|
||||
.graphics
|
||||
.as_ref()
|
||||
.and_then(|g| g.region_fan_out)
|
||||
.expect("the fan-out state");
|
||||
assert_eq!(
|
||||
(state.mode, state.copies, state.push_offset),
|
||||
(mode, fan.copies, fan.push_offset),
|
||||
"{stem}"
|
||||
);
|
||||
let pushes = (linked.layout.push_constants.iter())
|
||||
.filter(|r| r.stages == vk::ShaderStageFlags::GEOMETRY)
|
||||
.map(|r| (r.offset, r.size))
|
||||
.collect::<Vec<_>>();
|
||||
match mode {
|
||||
RegionFanOut::Probe => assert_eq!(pushes, [(fan.push_offset, 4)], "{stem}"),
|
||||
_ => assert!(pushes.is_empty(), "{stem} {mode:?}"),
|
||||
}
|
||||
let made = g
|
||||
.stages(&linked, &p, &mut crate::pipeline::testing::meter())
|
||||
.unwrap_or_else(|e| panic!("{stem} {mode:?}: {e}"));
|
||||
for ((module, requirements), class) in made.iter().zip(CLASSES) {
|
||||
crate::spirv::testing::check_words_valid(&module.spirv, requirements, &p)
|
||||
.unwrap_or_else(|e| panic!("{stem} {mode:?} {class:?}: {e}"));
|
||||
let emits = count_ops(&module.spirv, crate::spv::Op::EmitVertex as u32);
|
||||
let (expected, outputs) = match (class, mode) {
|
||||
(Class::Point, _) => (1, 1),
|
||||
(Class::Line, _) => (2, 2),
|
||||
(_, RegionFanOut::Probe) => (0, 3),
|
||||
(_, _) => (3, 3 * fan.copies),
|
||||
};
|
||||
assert_eq!(emits, expected, "{stem} {mode:?} {class:?}");
|
||||
let loops = count_ops(&module.spirv, crate::spv::Op::LoopMerge as u32);
|
||||
let looped = class == Class::Triangle
|
||||
&& (mode != RegionFanOut::Probe || fan.subgroup_bounds);
|
||||
assert_eq!(loops, usize::from(looped), "{stem} {mode:?} {class:?}");
|
||||
let subgroups = mode == RegionFanOut::Probe && stem != "lavapipe";
|
||||
assert_eq!(fan.subgroup_bounds, subgroups, "{stem} {mode:?}");
|
||||
let declared = (instructions(&module.spirv, crate::spv::Op::ExecutionMode))
|
||||
.into_iter()
|
||||
.filter(|m| {
|
||||
m.get(1) == Some(&(crate::spv::ExecutionMode::OutputVertices as u32))
|
||||
})
|
||||
.map(|m| m[2])
|
||||
.collect::<Vec<u32>>();
|
||||
assert_eq!(declared, [outputs], "{stem} {mode:?} {class:?}");
|
||||
if class != Class::Triangle {
|
||||
continue;
|
||||
}
|
||||
let decorated = |decoration: crate::spv::Decoration| {
|
||||
(instructions(&module.spirv, crate::spv::Op::Decorate).into_iter())
|
||||
.filter(|d| d.get(1) == Some(&(decoration as u32)))
|
||||
.count()
|
||||
};
|
||||
// Of each of a copy's three vertices, each axis's coordinate and its two clip
|
||||
// distances: five products and three sums.
|
||||
let contracted = match mode {
|
||||
RegionFanOut::Probe => 0,
|
||||
_ => 3 * 2 * 8,
|
||||
};
|
||||
let no_contraction = decorated(crate::spv::Decoration::NoContraction);
|
||||
assert_eq!(no_contraction, contracted, "{stem} {mode:?}");
|
||||
let invariant = decorated(crate::spv::Decoration::Invariant);
|
||||
assert_eq!(invariant, 2, "{stem} {mode:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The instructions of `words` with opcode `op`, each its operand words after the opcode's.
|
||||
fn instructions(words: &[u32], op: crate::spv::Op) -> Vec<&[u32]> {
|
||||
let mut i = 5;
|
||||
let mut found = Vec::new();
|
||||
while let Some(&w) = words.get(i) {
|
||||
let len = (w >> 16) as usize;
|
||||
if len == 0 {
|
||||
break;
|
||||
}
|
||||
if w & 0xFFFF == op as u32 {
|
||||
found.extend(words.get(i + 1..i + len));
|
||||
}
|
||||
i += len;
|
||||
}
|
||||
found
|
||||
}
|
||||
|
||||
/// A probe's triangle stage adds each triangle's copies once, into the count of its draw's
|
||||
/// [`PROBE_COUNT_WORDS`](crate::bind::fan_out::PROBE_COUNT_WORDS) that its `PrimitiveId` picks
|
||||
/// (masked by their number less one), whether or not the fragment function reads the primitive's
|
||||
/// index: no one word takes every triangle's add. A flagged triangle raises its draw's first's and
|
||||
/// last's words once each, adds one into its flagged count once, and sets its block's bit once,
|
||||
/// the block its primitive's index shifted by the block's triangles picks; a straddling one adds
|
||||
/// one into its straddle count once; and a triangle raises its block's bounds once, a straddling
|
||||
/// one's those of its part where `w` is positive, reaching infinity on a side an edge crosses
|
||||
/// `w = 0`.
|
||||
#[test]
|
||||
fn a_probe_adds_a_triangle_s_copies_into_the_count_its_primitive_picks() {
|
||||
use crate::spv::{BuiltIn, Decoration, Op};
|
||||
let p = profile("nvidia-pascal-linux");
|
||||
let f4 = io_ty(IoNumeric::Float, 4);
|
||||
let (v, reads_id) = pipeline();
|
||||
let fio = stage_io(vec![varying("a", f4, SMOOTH)], vec![color(0, 0, f4)]);
|
||||
let reads_none = stage(Stage::Fragment, fio);
|
||||
for (f, reads) in [(&reads_id, true), (&reads_none, false)] {
|
||||
let linked = link(&[&v, f], &fanned(RegionFanOut::Probe), &p).expect("linked");
|
||||
let g = linked.geometry.as_ref().expect("geometry stages");
|
||||
let made = (g.stages(&linked, &p, &mut crate::pipeline::testing::meter())).expect("made");
|
||||
let ((module, _), _) = (made.iter().zip(CLASSES))
|
||||
.find(|(_, class)| *class == Class::Triangle)
|
||||
.expect("the triangle stage");
|
||||
let words = &module.spirv;
|
||||
// The copies' add, a flagged triangle's count, and a straddling one's.
|
||||
assert_eq!(instructions(words, Op::AtomicIAdd).len(), 3, "three adds");
|
||||
// The flag's store, and the wide word's.
|
||||
assert_eq!(instructions(words, Op::AtomicStore).len(), 2, "two stores");
|
||||
// A flagged triangle's raise of the first's and the last's words.
|
||||
assert_eq!(instructions(words, Op::AtomicUMax).len(), 2, "two raises");
|
||||
// A flagged triangle's block bit, and a triangle's block bounds.
|
||||
assert_eq!(instructions(words, Op::AtomicOr).len(), 2, "two ors");
|
||||
// A straddling triangle's bounds: infinity on each side, where an edge crossing `w = 0`
|
||||
// takes it, a sign within the margin taking both.
|
||||
let infinities = (instructions(words, Op::Constant).into_iter())
|
||||
.filter(|c| {
|
||||
[f32::INFINITY, f32::NEG_INFINITY]
|
||||
.map(f32::to_bits)
|
||||
.contains(&c[2])
|
||||
})
|
||||
.count();
|
||||
assert_eq!(infinities, 2, "the bounds' infinities");
|
||||
assert_eq!(
|
||||
instructions(words, Op::FUnordGreaterThanEqual).len()
|
||||
+ instructions(words, Op::FUnordLessThanEqual).len(),
|
||||
12,
|
||||
"an edge's side of each axis, up and down"
|
||||
);
|
||||
let shift = crate::bind::fan_out::BLOCK_TRIANGLES.ilog2();
|
||||
let shifts: Vec<u32> = (instructions(words, Op::Constant).into_iter())
|
||||
.filter(|c| c.get(2) == Some(&shift))
|
||||
.map(|c| c[1])
|
||||
.collect();
|
||||
let blocked = (instructions(words, Op::ShiftRightLogical).into_iter())
|
||||
.any(|a| a[3..].iter().any(|operand| shifts.contains(operand)));
|
||||
assert!(blocked, "the primitive's index shifted to its block");
|
||||
let primitive = (instructions(words, Op::Decorate).into_iter())
|
||||
.filter(|d| d[1..] == [Decoration::BuiltIn as u32, BuiltIn::PrimitiveId as u32])
|
||||
.count();
|
||||
// Its input, and the output it passes on where the fragment function reads it.
|
||||
assert_eq!(
|
||||
primitive,
|
||||
1 + usize::from(reads),
|
||||
"the primitive's index read"
|
||||
);
|
||||
let mask = crate::bind::fan_out::PROBE_COUNT_WORDS - 1;
|
||||
let masks: Vec<u32> = (instructions(words, Op::Constant).into_iter())
|
||||
.filter(|c| c.get(2) == Some(&mask))
|
||||
.map(|c| c[1])
|
||||
.collect();
|
||||
let masked = (instructions(words, Op::BitwiseAnd).into_iter())
|
||||
.any(|a| a[2..].iter().any(|operand| masks.contains(operand)));
|
||||
assert!(masked, "the primitive's index masked to the counts");
|
||||
}
|
||||
}
|
||||
|
||||
/// A probe's triangles raise their blocks' bounds words (`bind::fan_out::PROBE_BOUNDS_AT`): on a
|
||||
/// device that runs subgroup operations in the geometry stage (`FanOutStage::subgroup_bounds`),
|
||||
/// once a subgroup for each word, the lanes of a word ORing their bounds together
|
||||
/// (`OpGroupNonUniformBitwiseOr`) and the one elected among them (`OpGroupNonUniformElect`)
|
||||
/// raising it, the module requiring the geometry stage's subgroups and not the vertex stage's;
|
||||
/// elsewhere each triangle its own.
|
||||
#[test]
|
||||
fn a_probe_raises_a_block_s_bounds_once_a_subgroup_where_the_geometry_stage_has_subgroups() {
|
||||
use crate::device::requirements::VkProperty;
|
||||
use crate::spv::Op;
|
||||
for (stem, subgroups) in [("nvidia-pascal-linux", true), ("lavapipe", false)] {
|
||||
let p = profile(stem);
|
||||
let (v, f) = pipeline();
|
||||
let linked = link(&[&v, &f], &fanned(RegionFanOut::Probe), &p).expect("linked");
|
||||
let g = linked.geometry.as_ref().expect("geometry stages");
|
||||
let made = (g.stages(&linked, &p, &mut crate::pipeline::testing::meter())).expect("made");
|
||||
let ((module, requirements), _) = (made.iter().zip(CLASSES))
|
||||
.find(|(_, class)| *class == Class::Triangle)
|
||||
.expect("the triangle stage");
|
||||
let words = &module.spirv;
|
||||
let results = |op| -> Vec<u32> {
|
||||
(instructions(words, op).into_iter())
|
||||
.map(|i| i[1])
|
||||
.collect()
|
||||
};
|
||||
let reduced = results(Op::GroupNonUniformBitwiseOr);
|
||||
let elected = results(Op::GroupNonUniformElect);
|
||||
let ors = instructions(words, Op::AtomicOr);
|
||||
// An `OpAtomicOr`'s value is its sixth operand word, a branch's condition its first.
|
||||
let raised = (ors.iter()).filter(|o| reduced.contains(&o[5])).count();
|
||||
let by_elected = (instructions(words, Op::BranchConditional).into_iter())
|
||||
.filter(|b| elected.contains(&b[0]))
|
||||
.count();
|
||||
let geometry = requirements
|
||||
.properties
|
||||
.contains(&VkProperty::SubgroupGeometryStage);
|
||||
let any_stage =
|
||||
(requirements.properties.iter()).any(|q| matches!(q, VkProperty::SubgroupStage(_)));
|
||||
assert_eq!(ors.len(), 2, "{stem}: the block bit's or and the bounds'");
|
||||
match subgroups {
|
||||
true => {
|
||||
assert_eq!(reduced.len(), 1, "{stem}: a word's lanes' bounds ORed");
|
||||
assert_eq!(raised, 1, "{stem}: the word raised by their or");
|
||||
assert_eq!(by_elected, 1, "{stem}: by the elected lane alone");
|
||||
assert!(
|
||||
geometry && !any_stage,
|
||||
"{stem}: the geometry stage's subgroups"
|
||||
);
|
||||
}
|
||||
false => {
|
||||
assert_eq!(
|
||||
[reduced.len(), elected.len()],
|
||||
[0, 0],
|
||||
"{stem}: no subgroup"
|
||||
);
|
||||
assert!(!geometry && !any_stage, "{stem}: no subgroup requirement");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn not_implemented(e: Error) {
|
||||
match e {
|
||||
Error::Unsupported(u) => {
|
||||
assert_eq!(u.feature, Feature::RasterizationRateMap);
|
||||
assert_eq!(u.needs, Needs::NotImplemented);
|
||||
}
|
||||
other => panic!("{other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
/// A fan-out beside another reason for the stages (a fragment function reading the weights where
|
||||
/// the device reads none), of a mesh or post-tessellation vertex function, or of a pipeline that
|
||||
/// amplifies its vertices is not implemented; a probe on a device without
|
||||
/// `vertexPipelineStoresAndAtomics` needs it, where a draw takes the stages.
|
||||
#[test]
|
||||
fn what_the_fan_out_cannot_carry_is_refused() {
|
||||
let mut p = profile("lavapipe");
|
||||
p.edit(|x| {
|
||||
x.enabled
|
||||
.features
|
||||
.remove(&VkFeature::FragmentShaderBarycentric);
|
||||
});
|
||||
let (v, f) = pipeline();
|
||||
let run = |v: &FunctionArtifact,
|
||||
f: &FunctionArtifact,
|
||||
amplification,
|
||||
mesh,
|
||||
mode,
|
||||
p: &DeviceProfile| {
|
||||
let i = [v.interface.clone(), f.interface.clone()];
|
||||
let refs: Vec<&StageInterface> = i.iter().collect();
|
||||
plan(&refs, Class::Triangle, amplification, mesh, Some(mode), p)
|
||||
};
|
||||
for mode in [RegionFanOut::Draw, RegionFanOut::Probe] {
|
||||
let g: GeometryStages = run(&v, &f, 1, false, mode, &p).unwrap().unwrap();
|
||||
assert_eq!(g.fan_out.map(|s| s.mode), Some(mode));
|
||||
assert_eq!(g.clip_distances, 2);
|
||||
let mut weights = f.clone();
|
||||
weights.interface.io.inputs.push(IoVariable {
|
||||
key: VaryingKey::barycentric(true),
|
||||
role: IoRole::Barycentric { perspective: true },
|
||||
ty: io_ty(IoNumeric::Float, 2),
|
||||
});
|
||||
not_implemented(run(&v, &weights, 1, false, mode, &p).unwrap_err());
|
||||
not_implemented(run(&v, &f, 2, false, mode, &p).unwrap_err());
|
||||
not_implemented(run(&v, &f, 1, true, mode, &p).unwrap_err());
|
||||
let mut tess = v.clone();
|
||||
tess.interface.tessellation = Some(crate::pipeline::interface::TessellationStage::new(
|
||||
crate::pipeline::interface::PatchDomain::Triangle,
|
||||
3,
|
||||
));
|
||||
not_implemented(run(&tess, &f, 1, false, mode, &p).unwrap_err());
|
||||
}
|
||||
let mut no_stores = p.clone();
|
||||
no_stores.edit(|x| {
|
||||
x.enabled
|
||||
.features
|
||||
.remove(&VkFeature::VertexPipelineStoresAndAtomics);
|
||||
});
|
||||
assert!(run(&v, &f, 1, false, RegionFanOut::Draw, &no_stores).is_ok());
|
||||
match run(&v, &f, 1, false, RegionFanOut::Probe, &no_stores).unwrap_err() {
|
||||
Error::Unsupported(u) => {
|
||||
assert_eq!(u.feature, Feature::RasterizationRateMap);
|
||||
assert_eq!(
|
||||
u.needs,
|
||||
Needs::AnyOf(vec![vec![Capability::Feature(
|
||||
VkFeature::VertexPipelineStoresAndAtomics
|
||||
)]])
|
||||
);
|
||||
}
|
||||
other => panic!("{other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
/// A region-copy variant draws no geometry stage: its vertex function draws its region's copy, at
|
||||
/// the first region it reads pushed (`PushField::RegionBox`), which its graphics state names; a
|
||||
/// vertex function that reads none is refused.
|
||||
#[test]
|
||||
fn a_regions_variant_draws_its_vertex_function_s_copies() {
|
||||
let p = profile("lavapipe");
|
||||
let (mut v, f) = pipeline();
|
||||
let regions = fanned(RegionFanOut::RegionCopies);
|
||||
not_implemented(link(&[&v, &f], ®ions, &p).unwrap_err());
|
||||
let fields = BTreeSet::from([PushField::RegionBox]);
|
||||
v.interface.push = crate::lower::push::place(Stage::Vertex, 0, &fields);
|
||||
let offset = match v.interface.push.fields.as_slice() {
|
||||
[placed] => match placed.loc {
|
||||
crate::pipeline::interface::PushLoc::Push { offset } => offset,
|
||||
other => panic!("{other:?}"),
|
||||
},
|
||||
other => panic!("{other:?}"),
|
||||
};
|
||||
let linked = link(&[&v, &f], ®ions, &p).unwrap_or_else(|e| panic!("{e}"));
|
||||
assert!(linked.geometry.is_none());
|
||||
let fan = linked.graphics.and_then(|g| g.region_fan_out);
|
||||
assert_eq!(
|
||||
fan,
|
||||
Some(crate::pipeline::graphics::FanOutState {
|
||||
mode: RegionFanOut::RegionCopies,
|
||||
copies: 0,
|
||||
push_offset: offset,
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -1,238 +0,0 @@
|
||||
//! The synthesized geometry stages (`link::geometry`) of a fragment function that reads
|
||||
//! `[[barycentric_coord]]` as varyings: what they pass through, where the weights live, each
|
||||
//! class's module, and the typed refusals.
|
||||
|
||||
use super::*;
|
||||
use crate::error::Needs;
|
||||
use crate::metal::PrimitiveTopologyClass as Class;
|
||||
use crate::pipeline::link::geometry::{plan, GeometryStages, CLASSES};
|
||||
use crate::pipeline::stage_io::StageBuiltin;
|
||||
|
||||
/// The weights' `float2` input of form `perspective`.
|
||||
fn weights(perspective: bool) -> IoVariable {
|
||||
IoVariable {
|
||||
key: VaryingKey::barycentric(perspective),
|
||||
role: IoRole::Barycentric { perspective },
|
||||
ty: io_ty(IoNumeric::Float, 2),
|
||||
}
|
||||
}
|
||||
|
||||
fn stage(stage: Stage, io: StageIo) -> FunctionArtifact {
|
||||
let mut i = iface(stage, vec![], vec![]);
|
||||
i.io = io;
|
||||
artifact(i, None)
|
||||
}
|
||||
|
||||
/// A vertex function writing `a` (`float4`) and `t` (`uint`) and its position, and a fragment
|
||||
/// function reading `a`, the perspective weights and the primitive ID.
|
||||
fn pipeline() -> (FunctionArtifact, FunctionArtifact) {
|
||||
let f4 = io_ty(IoNumeric::Float, 4);
|
||||
let u1 = io_ty(IoNumeric::Uint, 1);
|
||||
let mut vio = stage_io(vec![], vec![varying("a", f4, None), varying("t", u1, None)]);
|
||||
vio.builtins = vec![StageBuiltin::Position { invariant: false }];
|
||||
let mut fio = stage_io(
|
||||
vec![varying("a", f4, SMOOTH), weights(true)],
|
||||
vec![color(0, 0, f4)],
|
||||
);
|
||||
fio.builtins = vec![StageBuiltin::PrimitiveId];
|
||||
(stage(Stage::Vertex, vio), stage(Stage::Fragment, fio))
|
||||
}
|
||||
|
||||
fn render() -> LinkInputs {
|
||||
let mut r = RenderLinkInputs::new();
|
||||
r.color_attachments[0] = Some(crate::pipeline::descriptor::ColorAttachmentDescriptor::new(
|
||||
crate::metal::PixelFormat::RGBA32Float,
|
||||
));
|
||||
LinkInputs::Render(Box::new(r))
|
||||
}
|
||||
|
||||
/// The geometry stages pass through the vertex outputs the fragment stage reads, and the weights
|
||||
/// take whole locations after every vertex output's; each class's module is valid on the device.
|
||||
#[test]
|
||||
fn the_weights_follow_the_vertex_outputs_and_each_class_has_its_stage() {
|
||||
for stem in ["lavapipe", "intel-irisxe-rplp-anv", "nvidia-pascal-linux"] {
|
||||
let p = profile(stem);
|
||||
let (v, f) = pipeline();
|
||||
let linked = link(&[&v, &f], &render(), &p).unwrap_or_else(|e| panic!("{stem}: {e}"));
|
||||
let b = linked.geometry.as_ref().expect("geometry stages");
|
||||
assert_eq!(
|
||||
b.varyings,
|
||||
[(key("a"), io_ty(IoNumeric::Float, 4))],
|
||||
"{stem}"
|
||||
);
|
||||
assert_eq!(b.forms, [true], "{stem}");
|
||||
assert!(b.primitive_id && !b.multiview, "{stem}");
|
||||
assert_eq!(linked.table.locations[&key("a")], (0, 0), "{stem}");
|
||||
assert_eq!(
|
||||
linked.table.locations[&VaryingKey::barycentric(true)],
|
||||
(2, 0),
|
||||
"{stem}"
|
||||
);
|
||||
assert!(
|
||||
linked
|
||||
.graphics
|
||||
.as_ref()
|
||||
.expect("graphics")
|
||||
.reads_barycentric_coord,
|
||||
"{stem}"
|
||||
);
|
||||
let made = b
|
||||
.stages(&linked, &p, &mut crate::pipeline::testing::meter())
|
||||
.unwrap_or_else(|e| panic!("{stem}: {e}"));
|
||||
assert_eq!(made.len(), CLASSES.len());
|
||||
for ((module, requirements), (class, emitted)) in
|
||||
made.iter().zip(CLASSES.iter().zip([1, 2, 3]))
|
||||
{
|
||||
assert_eq!(module.stage, vk::ShaderStage::GEOMETRY, "{stem} {class:?}");
|
||||
assert!(requirements.features.contains(&VkFeature::GeometryShader));
|
||||
crate::spirv::testing::check_words_valid(&module.spirv, requirements, &p)
|
||||
.unwrap_or_else(|e| panic!("{stem} {class:?}: {e}"));
|
||||
let emits = count_ops(&module.spirv, crate::spv::Op::EmitVertex as u32);
|
||||
assert_eq!(emits, emitted, "{stem} {class:?}");
|
||||
assert_eq!(
|
||||
count_ops(&module.spirv, crate::spv::Op::EndPrimitive as u32),
|
||||
1,
|
||||
"{stem} {class:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// How many instructions of `words` have opcode `op`.
|
||||
fn count_ops(words: &[u32], op: u32) -> usize {
|
||||
let mut i = 5;
|
||||
let mut n = 0;
|
||||
while let Some(&w) = words.get(i) {
|
||||
let len = (w >> 16) as usize;
|
||||
n += usize::from(w & 0xFFFF == op);
|
||||
if len == 0 {
|
||||
break;
|
||||
}
|
||||
i += len;
|
||||
}
|
||||
n
|
||||
}
|
||||
|
||||
fn refused_needing(e: Error, capability: Capability) {
|
||||
match e {
|
||||
Error::Unsupported(u) => {
|
||||
assert_eq!(u.feature, Feature::Barycentrics);
|
||||
assert_eq!(
|
||||
u.needs,
|
||||
Needs::AnyOf(vec![
|
||||
vec![Capability::Feature(VkFeature::FragmentShaderBarycentric)],
|
||||
vec![capability],
|
||||
])
|
||||
);
|
||||
}
|
||||
other => panic!("{other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
fn not_implemented(e: Error) {
|
||||
match e {
|
||||
Error::Unsupported(u) => {
|
||||
assert_eq!(u.feature, Feature::Barycentrics);
|
||||
assert_eq!(u.needs, Needs::NotImplemented);
|
||||
}
|
||||
other => panic!("{other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
/// What the geometry stages cannot carry is refused typed: a mesh pipeline, a post-tessellation
|
||||
/// vertex function and a vertex function's own layer or viewport as not implemented; multiview
|
||||
/// without `multiviewGeometryShader`; a vertex function's point size in the point class without
|
||||
/// `shaderTessellationAndGeometryPointSize`; and the geometry limits. A fragment function that
|
||||
/// reads no weights has no stages.
|
||||
#[test]
|
||||
fn what_a_geometry_stage_cannot_carry_is_refused() {
|
||||
let p = profile("lavapipe");
|
||||
let (v, f) = pipeline();
|
||||
let ifaces = |v: &FunctionArtifact, f: &FunctionArtifact| -> Vec<StageInterface> {
|
||||
vec![v.interface.clone(), f.interface.clone()]
|
||||
};
|
||||
let run = |v: &FunctionArtifact,
|
||||
f: &FunctionArtifact,
|
||||
class,
|
||||
amplification,
|
||||
mesh,
|
||||
p: &DeviceProfile| {
|
||||
let i = ifaces(v, f);
|
||||
let refs: Vec<&StageInterface> = i.iter().collect();
|
||||
plan(&refs, class, amplification, mesh, None, p)
|
||||
};
|
||||
assert!(run(&v, &f, Class::Triangle, 1, false, &p)
|
||||
.unwrap()
|
||||
.is_some());
|
||||
not_implemented(run(&v, &f, Class::Triangle, 1, true, &p).unwrap_err());
|
||||
for builtin in [StageBuiltin::Layer, StageBuiltin::ViewportIndex] {
|
||||
let mut w = v.clone();
|
||||
w.interface.io.builtins.push(builtin);
|
||||
not_implemented(run(&w, &f, Class::Triangle, 1, false, &p).unwrap_err());
|
||||
}
|
||||
let mut tess = v.clone();
|
||||
tess.interface.tessellation = Some(crate::pipeline::interface::TessellationStage::new(
|
||||
crate::pipeline::interface::PatchDomain::Triangle,
|
||||
3,
|
||||
));
|
||||
not_implemented(run(&tess, &f, Class::Triangle, 1, false, &p).unwrap_err());
|
||||
// Multiview.
|
||||
let mut lacking = p.clone();
|
||||
lacking.edit(|x| {
|
||||
x.enabled
|
||||
.features
|
||||
.remove(&VkFeature::MultiviewGeometryShader);
|
||||
});
|
||||
let views = p.fields().limits.max_multiview_view_count;
|
||||
assert!(views > 1);
|
||||
let b = run(&v, &f, Class::Triangle, 2, false, &p).unwrap().unwrap();
|
||||
assert!(b.multiview);
|
||||
refused_needing(
|
||||
run(&v, &f, Class::Triangle, 2, false, &lacking).unwrap_err(),
|
||||
Capability::Feature(VkFeature::MultiviewGeometryShader),
|
||||
);
|
||||
assert!(run(&v, &f, Class::Triangle, 1, false, &lacking).is_ok());
|
||||
// A written point size, in the classes that draw points.
|
||||
let mut sized = v.clone();
|
||||
sized
|
||||
.interface
|
||||
.io
|
||||
.builtins
|
||||
.push(StageBuiltin::PointSize { default: false });
|
||||
let mut no_size = p.clone();
|
||||
no_size.edit(|x| {
|
||||
x.enabled
|
||||
.features
|
||||
.remove(&VkFeature::ShaderTessellationAndGeometryPointSize);
|
||||
});
|
||||
for class in [Class::Point, Class::Unspecified] {
|
||||
refused_needing(
|
||||
run(&sized, &f, class, 1, false, &no_size).unwrap_err(),
|
||||
Capability::Feature(VkFeature::ShaderTessellationAndGeometryPointSize),
|
||||
);
|
||||
let b: GeometryStages = run(&sized, &f, class, 1, false, &p).unwrap().unwrap();
|
||||
assert!(b.point_size && b.writes_point_size);
|
||||
}
|
||||
let b = run(&sized, &f, Class::Triangle, 1, false, &no_size)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
assert!(b.point_size && !b.writes_point_size);
|
||||
// No weights, no stages.
|
||||
let mut plain = f.clone();
|
||||
plain.interface.io.inputs.retain(|x| x.key == key("a"));
|
||||
assert!(run(&v, &plain, Class::Triangle, 1, true, &p)
|
||||
.unwrap()
|
||||
.is_none());
|
||||
// The limits, in whole locations.
|
||||
let mut narrow = p.clone();
|
||||
narrow.edit(|x| x.limits.max_geometry_output_components = 8);
|
||||
let linked = link(&[&v, &f], &render(), &narrow).unwrap_err();
|
||||
refused_needing(
|
||||
linked,
|
||||
Capability::Limit {
|
||||
limit: VkLimit::MaxGeometryOutputComponents,
|
||||
required: 12,
|
||||
available: 8,
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -26,11 +26,6 @@
|
||||
//! `PrimitiveId` behind a vertex function that writes the varying). A mesh function writes none,
|
||||
//! so a mesh render pipeline whose fragment function reads it is refused as needing
|
||||
//! `geometryShader` or `tessellationShader`.
|
||||
//! - **Barycentric weights** (`IoRole::Barycentric`), which a fragment function compiled for a
|
||||
//! device without `fragmentShaderBarycentric` reads and the pipeline's synthesized geometry
|
||||
//! stage writes (`link::geometry`), no vertex function: each takes one whole location after
|
||||
//! every vertex output's, below `maxFragmentInputComponents / 4`, and is never packed. A
|
||||
//! fragment function alone numbers them with its other inputs.
|
||||
//! - **Mesh outputs**, per vertex and per primitive alike, are numbered densely in output order,
|
||||
//! one location each at component 0, within `maxMeshOutputComponents / 4` locations. In a mesh render pipeline each fragment input takes the
|
||||
//! number of the mesh output of its key and type (`UnmatchedVarying` without one), below
|
||||
@@ -150,7 +145,6 @@ fn check_roles(stage: Stage, io: &StageIo) -> Result<(), Error> {
|
||||
..
|
||||
} | IoRole::ViewportIndex
|
||||
| IoRole::RenderTargetArrayIndex
|
||||
| IoRole::Barycentric { .. }
|
||||
| IoRole::PrimitiveId
|
||||
| IoRole::MergedCommand
|
||||
)
|
||||
@@ -422,30 +416,9 @@ pub fn assign(stages: &[&FunctionArtifact], p: &DeviceProfile) -> Result<Locatio
|
||||
}
|
||||
}
|
||||
};
|
||||
let mut next = placed.iter().map(|at| at.0 + 1).max().unwrap_or(0);
|
||||
for (v, at) in varyings.iter().zip(placed) {
|
||||
table.insert(v.key.clone(), at);
|
||||
}
|
||||
// The barycentric weights a synthesized geometry stage writes: whole locations after the
|
||||
// vertex outputs', which a fragment function alone numbered with its other inputs.
|
||||
if vertex.is_some() {
|
||||
let mut weights = false;
|
||||
for x in fragment.into_iter().flat_map(|f| &f.inputs) {
|
||||
if matches!(x.role, IoRole::Barycentric { .. }) {
|
||||
table.insert(x.key.clone(), (next, 0));
|
||||
next += 1;
|
||||
weights = true;
|
||||
}
|
||||
}
|
||||
if weights && u64::from(next).saturating_mul(4) > u64::from(l.max_fragment_input_components)
|
||||
{
|
||||
return Err(limit_error(
|
||||
VkLimit::MaxFragmentInputComponents,
|
||||
u64::from(next),
|
||||
l.max_fragment_input_components,
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok(table)
|
||||
}
|
||||
|
||||
@@ -463,18 +436,12 @@ fn varyings<'a>(
|
||||
| IoRole::RenderTargetArrayIndex
|
||||
| IoRole::PrimitiveId
|
||||
| IoRole::MergedCommand => Some(Interpolation::Flat),
|
||||
IoRole::Barycentric { perspective } => Some(Interpolation::Smooth {
|
||||
sampling: crate::pipeline::stage_io::Sampling::Center,
|
||||
perspective: *perspective,
|
||||
}),
|
||||
IoRole::Attribute { .. } | IoRole::Color { .. } | IoRole::PrimitiveVarying { .. } => None,
|
||||
};
|
||||
// The barycentric weights are the synthesized geometry stage's, no vertex output's.
|
||||
let reads: BTreeMap<&VaryingKey, (IoType, Option<Interpolation>)> = fragment
|
||||
.map(|f| {
|
||||
f.inputs
|
||||
.iter()
|
||||
.filter(|x| !matches!(x.role, IoRole::Barycentric { .. }))
|
||||
.map(|x| (&x.key, (x.ty, interpolation(x))))
|
||||
.collect()
|
||||
})
|
||||
|
||||
@@ -824,30 +824,6 @@ pub struct LoweringInputs {
|
||||
/// function that writes none. Any other stage compiles as without it.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub region_viewports: bool,
|
||||
/// The function's render pipeline draws a rasterization-rate-mapped pass's regions through
|
||||
/// the target's viewport, each region's copy of each vertex computed in the vertex function
|
||||
/// (`VariantKey::region_fan_out`, `RegionFanOut::RegionCopies`), as a fanned-out copy's is:
|
||||
/// the region of segments `(x0 + DrawIndex, y0)` of the region table
|
||||
/// (`SyntheticBinding::RateMapRegions`, `bind::fan_out`), `[x0, y0]` its recording's
|
||||
/// `PushField::RegionBox` and `DrawIndex` its draw's among a `vkCmdDrawMultiEXT`'s (0 for any
|
||||
/// other draw). The vertex function stores the position the region's line moves
|
||||
/// (`pipeline::link::fan_out::region_copy`, the emitter the fan-out stage shares, its
|
||||
/// operations `NoContraction`), four clip distances past its own that keep the region's
|
||||
/// pixels, and 0 as `ViewportIndex`: the one viewport the runtime sets is the target's and
|
||||
/// its scissor its row's. It needs the device to store `ViewportIndex` from a
|
||||
/// vertex function (`shaderOutputViewportIndex`), read `DrawIndex` (`shaderDrawParameters`)
|
||||
/// and write clip
|
||||
/// distances (`shaderClipDistance`), four more within `maxClipDistances` and
|
||||
/// `maxCombinedClipAndCullDistances`: `Unsupported(RasterizationRateMap)` names them otherwise.
|
||||
/// A merged draw's vertex function (`merged_draws`) takes it too, its corner from its
|
||||
/// `VertexIndex` and `InstanceIndex` as without it, and so does a draw replay's of one draw
|
||||
/// per command (`replay_bindings`). A function that writes its own
|
||||
/// `[[viewport_array_index]]` or `[[render_target_array_index]]`, one compiled under
|
||||
/// `amplification_draws`, a post-tessellation vertex function and
|
||||
/// one that returns no outputs are `NotImplemented(RasterizationRateMap)` under it: the runtime draws those region by region
|
||||
/// through each region's viewport. Any other stage compiles as without it.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub region_copies: bool,
|
||||
/// The axes along which every threadgroup the kernel runs has one thread
|
||||
/// (`VariantKey::unit_axes`; bit 0 `x`, bit 1 `y`, bit 2 `z`): there every thread's
|
||||
/// `thread_position_in_threadgroup` is 0 and its `thread_position_in_grid` is its
|
||||
|
||||
@@ -116,9 +116,9 @@ pub use descriptor::{
|
||||
VertexAttributeDescriptor, VertexBufferLayoutDescriptor, VertexDescriptor,
|
||||
};
|
||||
pub use graphics::{
|
||||
BandPrimitive, BlendState, ColorAttachmentState, FanOutState, FragmentImageblock,
|
||||
GraphicsState, ImageblockMechanism, InputAttachmentUse, LineBandState, RegionFanOut,
|
||||
ShadowStencilUse, StorageAttachmentUse, StorageAttachmentView, TessellationState,
|
||||
BandPrimitive, BlendState, ColorAttachmentState, FragmentImageblock, GraphicsState,
|
||||
ImageblockMechanism, InputAttachmentUse, LineBandState, ShadowStencilUse, StorageAttachmentUse,
|
||||
StorageAttachmentView, TessellationState,
|
||||
};
|
||||
pub use interface::{
|
||||
AccessSet, AttributeFetch, BufferForm, BufferKind, BufferSlot, CommandWrites, DescriptorView,
|
||||
|
||||
@@ -18,10 +18,6 @@
|
||||
//! - [`IoRole::RenderTargetArrayIndex`]: the `[[render_target_array_index]]` a vertex function
|
||||
//! writes, as written, carried to a fragment function that reads it. A flat `uint` varying for
|
||||
//! link, one key ([`VaryingKey::render_target_array_index`]) on both sides.
|
||||
//! - [`IoRole::Barycentric`]: the first two barycentric weights a fragment function reads as
|
||||
//! `[[barycentric_coord]]` on a device without `fragmentShaderBarycentric`, which the pipeline's
|
||||
//! synthesized geometry stage writes. A `float2` varying, perspective-correct or not, one key
|
||||
//! per form ([`VaryingKey::barycentric`]).
|
||||
//! - [`IoRole::PrimitiveId`]: Metal's `[[primitive_id]]` on a device that cannot declare a
|
||||
//! fragment `PrimitiveId`, which the pipeline's vertex function computes for the primitive each
|
||||
//! vertex provokes. A flat `uint` varying for link, one key ([`VaryingKey::primitive_id`]) on
|
||||
@@ -33,7 +29,7 @@
|
||||
//! The roles live in disjoint key namespaces ([`VaryingKey::user`], [`VaryingKey::attribute`],
|
||||
//! [`VaryingKey::color`], [`VaryingKey::viewport_index`],
|
||||
//! [`VaryingKey::render_target_array_index`],
|
||||
//! [`VaryingKey::barycentric`], [`VaryingKey::primitive_id`],
|
||||
//! [`VaryingKey::primitive_id`],
|
||||
//! [`VaryingKey::merged_command`]): the key bytes start with a
|
||||
//! namespace tag, so no AIR user key can collide with another role's key. Keys stay opaque to
|
||||
//! link; it reads the role here, never the bytes.
|
||||
@@ -65,7 +61,6 @@ const ATTRIBUTE: u8 = 1;
|
||||
const COLOR: u8 = 2;
|
||||
const VIEWPORT_INDEX: u8 = 3;
|
||||
const RENDER_TARGET_ARRAY_INDEX: u8 = 4;
|
||||
const BARYCENTRIC: u8 = 6;
|
||||
const PRIMITIVE_ID: u8 = 9;
|
||||
const MERGED_COMMAND: u8 = 10;
|
||||
|
||||
@@ -105,13 +100,6 @@ impl VaryingKey {
|
||||
VaryingKey(AirUserKey(vec![RENDER_TARGET_ARRAY_INDEX].into()))
|
||||
}
|
||||
|
||||
/// The key of the barycentric weights a pipeline's synthesized geometry stage writes and a
|
||||
/// fragment function reads as `[[barycentric_coord]]` (`IoRole::Barycentric`), in the form
|
||||
/// `perspective` names.
|
||||
pub fn barycentric(perspective: bool) -> VaryingKey {
|
||||
VaryingKey(AirUserKey(vec![BARYCENTRIC, u8::from(perspective)].into()))
|
||||
}
|
||||
|
||||
/// The key of the primitive ID a vertex function writes and a fragment function reads as
|
||||
/// `[[primitive_id]]` (`IoRole::PrimitiveId`).
|
||||
pub fn primitive_id() -> VaryingKey {
|
||||
@@ -704,13 +692,6 @@ pub enum IoRole {
|
||||
/// flat [`IoRole::Varying`] its function reads per primitive
|
||||
/// ([`StageIo::primitive_inputs`]).
|
||||
PrimitiveVarying { user: AirUserKey },
|
||||
/// The first two barycentric weights a fragment function compiled for a device without
|
||||
/// `fragmentShaderBarycentric` reads as its `[[barycentric_coord]]`: a center-sampled `float2`
|
||||
/// input, perspective-correct when `perspective`, which no Metal function writes. Link
|
||||
/// synthesizes the pipeline's geometry stage, which writes `(1, 0)`, `(0, 1)` and `(0, 0)` at
|
||||
/// a triangle's vertices in their order (`(1, 0)` and `(0, 1)` at a line's, `(1, 0)` at a
|
||||
/// point), and passes the fragment stage's other inputs through.
|
||||
Barycentric { perspective: bool },
|
||||
/// Metal's `[[primitive_id]]` carried from a vertex function to its fragment function: the
|
||||
/// flat `uint` output of a vertex function compiled under
|
||||
/// `LoweringInputs::primitive_id_varying`, and the input a fragment function reads as its
|
||||
@@ -734,8 +715,7 @@ pub enum IoRole {
|
||||
|
||||
impl IoRole {
|
||||
/// Whether the role is a varying: a user varying, a raw index a vertex function writes for its
|
||||
/// fragment function, the barycentric weights a synthesized geometry stage writes, the
|
||||
/// primitive ID, or a merged draw's command. Link numbers these, and packs those a vertex
|
||||
/// fragment function, the primitive ID, or a merged draw's command. Link numbers these, and packs those a vertex
|
||||
/// function writes.
|
||||
pub(crate) fn is_varying(&self) -> bool {
|
||||
matches!(
|
||||
@@ -743,7 +723,6 @@ impl IoRole {
|
||||
IoRole::Varying { .. }
|
||||
| IoRole::ViewportIndex
|
||||
| IoRole::RenderTargetArrayIndex
|
||||
| IoRole::Barycentric { .. }
|
||||
| IoRole::PrimitiveId
|
||||
| IoRole::MergedCommand
|
||||
)
|
||||
@@ -909,9 +888,7 @@ mod tests {
|
||||
let color = VaryingKey::color(3, 0);
|
||||
let viewport = VaryingKey::viewport_index();
|
||||
let layer = VaryingKey::render_target_array_index();
|
||||
let perspective = VaryingKey::barycentric(true);
|
||||
let linear = VaryingKey::barycentric(false);
|
||||
let tagged = [&attr, &color, &viewport, &layer, &perspective, &linear];
|
||||
let tagged = [&attr, &color, &viewport, &layer];
|
||||
for (i, a) in tagged.iter().enumerate() {
|
||||
for b in &tagged[i + 1..] {
|
||||
assert_ne!(a, b);
|
||||
|
||||
@@ -285,17 +285,6 @@ pub enum SyntheticBinding {
|
||||
HandleTable,
|
||||
/// The pipeline constant blob, a read-only storage buffer.
|
||||
ConstantBlob,
|
||||
/// A rate-mapped pass's region table (`bind::fan_out`), a read-only storage buffer of a
|
||||
/// fan-out variant's geometry stage (`GraphicsState::region_fan_out`), declared with the
|
||||
/// vertex stage's symbols.
|
||||
RateMapRegions,
|
||||
/// A fan-out probe's flags (`GraphicsState::region_fan_out`), a storage buffer of `u32`s its
|
||||
/// geometry stage writes into at the pushed index (`PushField::RegionProbe`,
|
||||
/// `bind::fan_out::PROBE_DRAW_WORDS` a draw): a flag, the copies its draw emits, the marks
|
||||
/// of its triangles too wide for few copies, its first and last flagged triangle, the
|
||||
/// count of its flagged triangles, and the bits of its blocks that hold one. Declared with
|
||||
/// the vertex stage's symbols.
|
||||
RateMapFlags,
|
||||
/// The render encoder's tessellation factor buffer (`setTessellationFactorBuffer:offset:
|
||||
/// instanceStride:`), a read-only storage buffer of a tessellation pipeline's synthesized
|
||||
/// control stage, declared with the vertex stage's symbols.
|
||||
@@ -958,13 +947,6 @@ pub enum PushField {
|
||||
/// That amplification's `viewportArrayIndexOffset` (`u32`), added to the viewport index and
|
||||
/// read as `AmplificationLayerOffset` is.
|
||||
AmplificationViewportOffset,
|
||||
/// The row of regions a recording of a rate-mapped pass's regions draws (`uvec2`;
|
||||
/// `RegionFanOut::RegionCopies`, `LoweringInputs::region_copies`): its first region's
|
||||
/// segments of x and y in the region table, `x0` and `y0`. Its vertex function draws the
|
||||
/// region of segments `(x0 + DrawIndex, y0)`: the row's regions in order. Placed with the
|
||||
/// amplification fields, so the vertex window holds it, as a recording writes it before its
|
||||
/// draws.
|
||||
RegionBox,
|
||||
/// Region base and grid of a multi-region dispatch (`lower::dispatch`'s module docs). Under
|
||||
/// the identity domains every dispatch the host knows is a region: its first threadgroup in
|
||||
/// Metal's grid (0 unless the consumer splits the dispatch), Metal's threadgroup size, and
|
||||
@@ -1066,9 +1048,6 @@ pub enum PushField {
|
||||
/// height negative, as the runtime's viewports are) and half the band's width in pixels
|
||||
/// (`BindState::line_band`).
|
||||
LineBand,
|
||||
/// The index a fan-out probe writes its flag at (`u32`; `GraphicsState::region_fan_out`,
|
||||
/// `link::fan_out`): one field of the synthesized geometry stage's own push range.
|
||||
RegionProbe,
|
||||
/// The stride (`u32`) the compute encoder binds the kernel buffer at this Metal index with
|
||||
/// (`setBuffer:offset:attributeStride:atIndex:` and its forms, its low 32 bits,
|
||||
/// `MTLAttributeStrideStatic`'s `2^32 - 1` included), 0 where it binds none, which a
|
||||
|
||||
@@ -796,13 +796,12 @@ impl ModuleBuilder {
|
||||
|
||||
/// Decorate builtin output `g` `Invariant`: SPIR-V's "expressions computing its value be
|
||||
/// computed invariantly with respect to other shaders computing the same expressions". Only
|
||||
/// the `Position` output (Metal's `[[invariant]]` position) and the `ClipDistance` output (a
|
||||
/// rate-mapped pass's copies of its triangles, `pipeline::link::fan_out`) can be invariant.
|
||||
/// the `Position` output (Metal's `[[invariant]]` position) can be invariant.
|
||||
pub fn invariant(&mut self, g: GlobalId) -> BResult<()> {
|
||||
use crate::spv::BuiltIn as B;
|
||||
match self.global(g)?.kind {
|
||||
GlobalKind::BuiltIn {
|
||||
builtin: B::Position | B::ClipDistance,
|
||||
builtin: B::Position,
|
||||
dir: IoDir::Output,
|
||||
} => {
|
||||
self.invariant.insert(g);
|
||||
@@ -1134,11 +1133,6 @@ impl ModuleBuilder {
|
||||
{
|
||||
return err(EntryRule::TessellationModes);
|
||||
}
|
||||
ExecMode::OutputVertices { n: 0 } | ExecMode::Invocations { n: 0 }
|
||||
if model == ExecModel::Geometry =>
|
||||
{
|
||||
return err(EntryRule::GeometryModes);
|
||||
}
|
||||
ExecMode::OutputVertices { n: 0 } | ExecMode::OutputPrimitives { n: 0 } => {
|
||||
return err(EntryRule::MeshModes);
|
||||
}
|
||||
@@ -1176,26 +1170,6 @@ impl ModuleBuilder {
|
||||
if !mesh_ok {
|
||||
return err(EntryRule::MeshModes);
|
||||
}
|
||||
// A geometry entry states its input and output primitives and the most vertices it emits.
|
||||
let geometry_ok = model != ExecModel::Geometry
|
||||
|| (patch_size
|
||||
&& modes.iter().any(|m| {
|
||||
matches!(
|
||||
m,
|
||||
ExecMode::InputPoints | ExecMode::InputLines | ExecMode::Triangles
|
||||
)
|
||||
})
|
||||
&& modes.iter().any(|m| {
|
||||
matches!(
|
||||
m,
|
||||
ExecMode::OutputPoints
|
||||
| ExecMode::OutputLineStrip
|
||||
| ExecMode::OutputTriangleStrip
|
||||
)
|
||||
}));
|
||||
if !geometry_ok {
|
||||
return err(EntryRule::GeometryModes);
|
||||
}
|
||||
let has_local_size = has_local_size || self.consts.workgroup_size_const().is_some();
|
||||
let workgroups = matches!(
|
||||
model,
|
||||
@@ -1457,8 +1431,6 @@ fn mode_contract(m: ExecMode) -> (u8, Option<u8>, &'static [ExecModel]) {
|
||||
const WORKGROUPS: &[ExecModel] =
|
||||
&[ExecModel::GLCompute, ExecModel::TaskEXT, ExecModel::MeshEXT];
|
||||
const MESH: &[ExecModel] = &[ExecModel::MeshEXT];
|
||||
const GEOMETRY: &[ExecModel] = &[ExecModel::Geometry];
|
||||
const MESH_OR_GEOMETRY: &[ExecModel] = &[ExecModel::MeshEXT, ExecModel::Geometry];
|
||||
const ALL: &[ExecModel] = &[
|
||||
ExecModel::Vertex,
|
||||
ExecModel::Fragment,
|
||||
@@ -1467,7 +1439,6 @@ fn mode_contract(m: ExecMode) -> (u8, Option<u8>, &'static [ExecModel]) {
|
||||
ExecModel::TessellationControl,
|
||||
ExecModel::TaskEXT,
|
||||
ExecModel::MeshEXT,
|
||||
ExecModel::Geometry,
|
||||
];
|
||||
// Vulkan lets either tessellation stage declare the domain, spacing, and vertex order; the
|
||||
// output patch size is the control stage's.
|
||||
@@ -1475,18 +1446,8 @@ fn mode_contract(m: ExecMode) -> (u8, Option<u8>, &'static [ExecModel]) {
|
||||
ExecModel::TessellationEvaluation,
|
||||
ExecModel::TessellationControl,
|
||||
];
|
||||
// The triangle domain, or a geometry entry's triangle input.
|
||||
const TRIANGLES: &[ExecModel] = &[
|
||||
ExecModel::TessellationEvaluation,
|
||||
ExecModel::TessellationControl,
|
||||
ExecModel::Geometry,
|
||||
];
|
||||
// The output patch size, or a mesh or geometry entry's most vertices.
|
||||
const OUTPUT_VERTICES: &[ExecModel] = &[
|
||||
ExecModel::TessellationControl,
|
||||
ExecModel::MeshEXT,
|
||||
ExecModel::Geometry,
|
||||
];
|
||||
// The output patch size, or a mesh entry's most vertices.
|
||||
const OUTPUT_VERTICES: &[ExecModel] = &[ExecModel::TessellationControl, ExecModel::MeshEXT];
|
||||
match m {
|
||||
ExecMode::OriginUpperLeft => (0, None, FRAG),
|
||||
ExecMode::EarlyFragmentTests => (1, None, FRAG),
|
||||
@@ -1501,21 +1462,18 @@ fn mode_contract(m: ExecMode) -> (u8, Option<u8>, &'static [ExecModel]) {
|
||||
ExecMode::RoundingModeRte { width } => (10, Some(width), ALL),
|
||||
ExecMode::SubgroupUniformControlFlow => (11, None, ALL),
|
||||
ExecMode::MaximallyReconverges => (12, None, ALL),
|
||||
ExecMode::Triangles => (13, None, TRIANGLES),
|
||||
ExecMode::Quads => (13, None, TESS),
|
||||
ExecMode::InputPoints | ExecMode::InputLines => (13, None, GEOMETRY),
|
||||
ExecMode::Triangles | ExecMode::Quads => (13, None, TESS),
|
||||
ExecMode::SpacingEqual
|
||||
| ExecMode::SpacingFractionalEven
|
||||
| ExecMode::SpacingFractionalOdd => (14, None, TESS),
|
||||
ExecMode::VertexOrderCw | ExecMode::VertexOrderCcw => (15, None, TESS),
|
||||
ExecMode::OutputVertices { .. } => (16, None, OUTPUT_VERTICES),
|
||||
ExecMode::OutputPrimitives { .. } => (17, None, MESH),
|
||||
ExecMode::OutputPoints => (18, None, MESH_OR_GEOMETRY),
|
||||
ExecMode::OutputLines | ExecMode::OutputTriangles => (18, None, MESH),
|
||||
ExecMode::OutputLineStrip | ExecMode::OutputTriangleStrip => (18, None, GEOMETRY),
|
||||
ExecMode::OutputPoints | ExecMode::OutputLines | ExecMode::OutputTriangles => {
|
||||
(18, None, MESH)
|
||||
}
|
||||
ExecMode::RequireFullQuads => (19, None, FRAG),
|
||||
ExecMode::PostDepthCoverage => (21, None, FRAG),
|
||||
ExecMode::Invocations { .. } => (20, None, GEOMETRY),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
//! A geometry entry's instructions: emitting a vertex and ending the output primitive.
|
||||
|
||||
use crate::spirv::builder::function::FunctionBuilder;
|
||||
use crate::spirv::error::BResult;
|
||||
use crate::spirv::ir::Inst;
|
||||
|
||||
impl FunctionBuilder<'_> {
|
||||
/// `OpEmitVertex`: emit a vertex of the current output values (a geometry entry only, checked
|
||||
/// at finalize). Every output is undefined after it until it is stored again.
|
||||
pub fn emit_vertex(&mut self) -> BResult<()> {
|
||||
self.emit_void(Inst::EmitVertex)
|
||||
}
|
||||
|
||||
/// `OpEndPrimitive`: end the output primitive (a geometry entry only, checked at finalize).
|
||||
pub fn end_primitive(&mut self) -> BResult<()> {
|
||||
self.emit_void(Inst::EndPrimitive)
|
||||
}
|
||||
}
|
||||
@@ -10,14 +10,12 @@
|
||||
//! [`memory`] (access chains, array length, copies, calls), [`atomic`] (atomics, texel pointers,
|
||||
//! barriers), [`image`] (sampling, fetch, gather, read/write, queries, derivatives), [`group`]
|
||||
//! (subgroup operations), [`glsl`] (`GLSL.std.450`), [`misc`] (undef, helper invocation,
|
||||
//! interlock), [`mesh`] (a mesh pipeline's output counts and launch), [`geometry`] (a geometry
|
||||
//! entry's vertices and primitives), and [`ray`] (ray queries).
|
||||
//! interlock), [`mesh`] (a mesh pipeline's output counts and launch), and [`ray`] (ray queries).
|
||||
|
||||
pub mod arith;
|
||||
pub mod atomic;
|
||||
pub mod composite;
|
||||
pub mod convert;
|
||||
pub mod geometry;
|
||||
pub mod glsl;
|
||||
pub mod group;
|
||||
pub mod image;
|
||||
@@ -269,7 +267,6 @@ pub(super) fn check_entry_model(
|
||||
ExecModel::GLCompute | ExecModel::TaskEXT | ExecModel::MeshEXT
|
||||
),
|
||||
ModelNeed::Mesh => entry.model == ExecModel::MeshEXT,
|
||||
ModelNeed::Geometry => entry.model == ExecModel::Geometry,
|
||||
};
|
||||
if !ok {
|
||||
return Err(BuildError::Entry(EntryRule::InstructionForModel(model_op(
|
||||
@@ -301,8 +298,6 @@ fn model_op(inst: &Inst) -> crate::spv::Op {
|
||||
Inst::MemoryBarrier { .. } => Op::MemoryBarrier,
|
||||
Inst::Group { op, .. } => op.to_spirv(),
|
||||
Inst::SetMeshOutputs { .. } => Op::SetMeshOutputsEXT,
|
||||
Inst::EmitVertex => Op::EmitVertex,
|
||||
Inst::EndPrimitive => Op::EndPrimitive,
|
||||
_ => Op::ExtInst,
|
||||
}
|
||||
}
|
||||
@@ -1089,8 +1089,7 @@ fn only_the_position_and_clip_distances_are_invariant() {
|
||||
t.b.io(key("color"), IoDir::Output, v4, IoDecor::default())
|
||||
.expect("varying");
|
||||
assert_eq!(t.b.invariant(pos), Ok(()));
|
||||
assert_eq!(t.b.invariant(clips), Ok(()));
|
||||
for g in [depth, size, color] {
|
||||
for g in [clips, depth, size, color] {
|
||||
assert_eq!(
|
||||
t.b.invariant(g),
|
||||
Err(BuildError::Global(GlobalRule::InvariantTarget))
|
||||
|
||||
@@ -248,9 +248,6 @@ pub enum EntryRule {
|
||||
TessellationModes,
|
||||
/// A mesh entry without a nonzero vertex and primitive count and its primitive kind.
|
||||
MeshModes,
|
||||
/// A geometry entry without its input primitive, its output primitive, and a nonzero count of
|
||||
/// output vertices and invocations.
|
||||
GeometryModes,
|
||||
/// An instruction the entry's execution model (and modes) cannot run: implicit derivatives
|
||||
/// outside fragment (or derivative-group compute), fragment-only operations elsewhere, or
|
||||
/// interlock without an interlock mode.
|
||||
|
||||
@@ -464,8 +464,6 @@ pub(super) fn exec(p: &Prog<'_>, l: &mut Lane, sh: &mut Shared, node: &InstNode)
|
||||
}
|
||||
Inst::IsHelperInvocation => return unmodelled(crate::spv::Op::IsHelperInvocationEXT),
|
||||
Inst::SetMeshOutputs { .. } => return unmodelled(crate::spv::Op::SetMeshOutputsEXT),
|
||||
Inst::EmitVertex => return unmodelled(crate::spv::Op::EmitVertex),
|
||||
Inst::EndPrimitive => return unmodelled(crate::spv::Op::EndPrimitive),
|
||||
// The interpreter has no acceleration structures: it cannot trace a ray.
|
||||
Inst::RayQuery(op) => return unmodelled(op.to_spirv()),
|
||||
};
|
||||
|
||||
@@ -1158,6 +1158,4 @@ pub enum ModelNeed {
|
||||
WorkgroupScope,
|
||||
/// The mesh execution model (`OpSetMeshOutputsEXT`).
|
||||
Mesh,
|
||||
/// The geometry execution model (`OpEmitVertex`, `OpEndPrimitive`).
|
||||
Geometry,
|
||||
}
|
||||
@@ -404,10 +404,6 @@ pub enum Inst {
|
||||
IsHelperInvocation,
|
||||
/// `OpSetMeshOutputsEXT`: the vertices and primitives a mesh workgroup outputs.
|
||||
SetMeshOutputs { vertices: Value, primitives: Value },
|
||||
/// `OpEmitVertex`: a geometry entry emits a vertex of its output values.
|
||||
EmitVertex,
|
||||
/// `OpEndPrimitive`: a geometry entry ends its output primitive.
|
||||
EndPrimitive,
|
||||
// ---- Ray queries (builder/ops/ray.rs) ----
|
||||
/// A `SPV_KHR_ray_query` instruction.
|
||||
RayQuery(RayQueryInst),
|
||||
@@ -583,9 +579,7 @@ impl Inst {
|
||||
| Inst::DemoteToHelperInvocation
|
||||
| Inst::IsHelperInvocation
|
||||
| Inst::ControlBarrier { .. }
|
||||
| Inst::MemoryBarrier { .. }
|
||||
| Inst::EmitVertex
|
||||
| Inst::EndPrimitive => {}
|
||||
| Inst::MemoryBarrier { .. } => {}
|
||||
Inst::SetMeshOutputs {
|
||||
vertices,
|
||||
primitives,
|
||||
@@ -812,9 +806,7 @@ impl Inst {
|
||||
| Inst::DemoteToHelperInvocation
|
||||
| Inst::IsHelperInvocation
|
||||
| Inst::ControlBarrier { .. }
|
||||
| Inst::MemoryBarrier { .. }
|
||||
| Inst::EmitVertex
|
||||
| Inst::EndPrimitive => {}
|
||||
| Inst::MemoryBarrier { .. } => {}
|
||||
Inst::SetMeshOutputs {
|
||||
vertices,
|
||||
primitives,
|
||||
@@ -1018,9 +1010,7 @@ impl Inst {
|
||||
| Inst::EndInterlock
|
||||
| Inst::DemoteToHelperInvocation
|
||||
| Inst::IsHelperInvocation
|
||||
| Inst::SetMeshOutputs { .. }
|
||||
| Inst::EmitVertex
|
||||
| Inst::EndPrimitive => {}
|
||||
| Inst::SetMeshOutputs { .. } => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1041,7 +1031,6 @@ impl Inst {
|
||||
} => Some(ModelNeed::Fragment),
|
||||
Inst::BeginInterlock | Inst::EndInterlock => Some(ModelNeed::Interlock),
|
||||
Inst::SetMeshOutputs { .. } => Some(ModelNeed::Mesh),
|
||||
Inst::EmitVertex | Inst::EndPrimitive => Some(ModelNeed::Geometry),
|
||||
Inst::AtomicLoad { scope, .. }
|
||||
| Inst::AtomicStore { scope, .. }
|
||||
| Inst::Atomic { scope, .. }
|
||||
@@ -1291,9 +1280,6 @@ pub enum ExecModel {
|
||||
TaskEXT,
|
||||
/// A mesh function (`SPV_EXT_mesh_shader`).
|
||||
MeshEXT,
|
||||
/// The pass-through geometry stage link synthesizes for a fragment function that reads
|
||||
/// `[[barycentric_coord]]` on a device without `fragmentShaderBarycentric`.
|
||||
Geometry,
|
||||
}
|
||||
|
||||
impl ExecModel {
|
||||
@@ -1372,20 +1358,6 @@ pub enum ExecMode {
|
||||
OutputLines,
|
||||
/// Triangles (`OutputTrianglesEXT`).
|
||||
OutputTriangles,
|
||||
// ---- Geometry ----
|
||||
/// A geometry entry's input primitive: points (`InputPoints`). Its triangles are
|
||||
/// [`ExecMode::Triangles`] and its output points [`ExecMode::OutputPoints`].
|
||||
InputPoints,
|
||||
/// Lines (`InputLines`).
|
||||
InputLines,
|
||||
/// A geometry entry's output primitive: line strips (`OutputLineStrip`).
|
||||
OutputLineStrip,
|
||||
/// Triangle strips (`OutputTriangleStrip`).
|
||||
OutputTriangleStrip,
|
||||
/// A geometry entry's invocations per input primitive (`Invocations`).
|
||||
Invocations {
|
||||
n: u32,
|
||||
},
|
||||
}
|
||||
|
||||
impl ExecMode {
|
||||
|
||||
@@ -233,14 +233,13 @@ pub fn interface(m: &ModuleView<'_>) -> BResult<Vec<GlobalId>> {
|
||||
Ok(interface)
|
||||
}
|
||||
|
||||
/// The Metal stage of an execution model: both tessellation stages and the synthesized geometry
|
||||
/// stage belong to Metal's vertex stage.
|
||||
/// The Metal stage of an execution model: both tessellation stages belong to Metal's vertex
|
||||
/// stage.
|
||||
pub(crate) fn metal_stage(model: ExecModel) -> Stage {
|
||||
match model {
|
||||
ExecModel::Vertex
|
||||
| ExecModel::TessellationEvaluation
|
||||
| ExecModel::TessellationControl
|
||||
| ExecModel::Geometry => Stage::Vertex,
|
||||
ExecModel::Vertex | ExecModel::TessellationEvaluation | ExecModel::TessellationControl => {
|
||||
Stage::Vertex
|
||||
}
|
||||
ExecModel::Fragment => Stage::Fragment,
|
||||
ExecModel::GLCompute => Stage::Kernel,
|
||||
ExecModel::TaskEXT => Stage::Object,
|
||||
@@ -274,10 +273,6 @@ pub fn derive(m: &ModuleView<'_>) -> BResult<Requirements> {
|
||||
d.cap(Cap::Tessellation);
|
||||
d.feat(VkFeature::TessellationShader);
|
||||
}
|
||||
if m.entry.model == ExecModel::Geometry {
|
||||
d.cap(Cap::Geometry);
|
||||
d.feat(VkFeature::GeometryShader);
|
||||
}
|
||||
// A task or mesh entry, and a fragment entry reading a mesh entry's primitive outputs
|
||||
// (`PerPrimitiveEXT`), declare mesh shading.
|
||||
let stage_feature = match m.entry.model {
|
||||
@@ -468,8 +463,9 @@ impl Deriver<'_> {
|
||||
match self.model {
|
||||
ExecModel::Vertex
|
||||
| ExecModel::TessellationEvaluation
|
||||
| ExecModel::TessellationControl
|
||||
| ExecModel::Geometry => self.feat(VkFeature::VertexPipelineStoresAndAtomics),
|
||||
| ExecModel::TessellationControl => {
|
||||
self.feat(VkFeature::VertexPipelineStoresAndAtomics)
|
||||
}
|
||||
ExecModel::Fragment => self.feat(VkFeature::FragmentStoresAndAtomics),
|
||||
// Vulkan's stage store features name no task or mesh stage.
|
||||
ExecModel::GLCompute | ExecModel::TaskEXT | ExecModel::MeshEXT => {}
|
||||
@@ -699,16 +695,13 @@ impl Deriver<'_> {
|
||||
ty: TypeId,
|
||||
) -> BResult<()> {
|
||||
use crate::spv::BuiltIn as B;
|
||||
// A mesh entry's outputs are arrayed per vertex or per primitive, and a geometry or
|
||||
// evaluation entry's per-vertex inputs and a control entry's per-vertex inputs and
|
||||
// outputs per vertex: a builtin's own array, a clip or cull distance's, is that array's
|
||||
// A mesh entry's outputs are arrayed per vertex or per primitive, and an evaluation
|
||||
// entry's per-vertex inputs and a control entry's per-vertex inputs and outputs per
|
||||
// vertex: a builtin's own array, a clip or cull distance's, is that array's
|
||||
// element.
|
||||
let arrays_vertices = matches!(
|
||||
(self.model, dir),
|
||||
(
|
||||
ExecModel::Geometry | ExecModel::TessellationEvaluation,
|
||||
IoDir::Input
|
||||
) | (ExecModel::TessellationControl, _)
|
||||
(ExecModel::TessellationEvaluation, IoDir::Input) | (ExecModel::TessellationControl, _)
|
||||
);
|
||||
let arrayed = (self.model == ExecModel::MeshEXT && dir == IoDir::Output)
|
||||
|| (arrays_vertices && crate::spirv::builder::geometry_per_vertex(b));
|
||||
@@ -723,35 +716,18 @@ impl Deriver<'_> {
|
||||
_ => Ok(None),
|
||||
}
|
||||
};
|
||||
// A tessellation stage's `PrimitiveId` is enabled by `Tessellation`, and a geometry stage's
|
||||
// by `Geometry`, which the entry declared.
|
||||
if b == B::PrimitiveId
|
||||
&& (self.model.is_tessellation() || self.model == ExecModel::Geometry)
|
||||
{
|
||||
// A tessellation stage's `PrimitiveId` is enabled by `Tessellation`, which the entry
|
||||
// declared.
|
||||
if b == B::PrimitiveId && self.model.is_tessellation() {
|
||||
return Ok(());
|
||||
}
|
||||
// A geometry stage's `Layer` output is enabled by `Geometry`, which the entry declared, and
|
||||
// its `ViewportIndex` output by `MultiViewport` (`multiViewport`).
|
||||
if self.model == ExecModel::Geometry && dir == IoDir::Output {
|
||||
match b {
|
||||
B::Layer => return Ok(()),
|
||||
B::ViewportIndex => {
|
||||
self.cap(Cap::MultiViewport);
|
||||
self.feat(VkFeature::MultiViewport);
|
||||
return Ok(());
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
// A task or mesh entry's `DrawIndex` is enabled by `MeshShadingEXT` (as the grammar lists
|
||||
// it), which the entry declared: it needs no `DrawParameters`.
|
||||
if b == B::DrawIndex && matches!(self.model, ExecModel::TaskEXT | ExecModel::MeshEXT) {
|
||||
return Ok(());
|
||||
}
|
||||
// A geometry stage's point size, input or output, is `GeometryPointSize`'s, and a
|
||||
// tessellation stage's `TessellationPointSize`'s.
|
||||
// A tessellation stage's point size, input or output, is `TessellationPointSize`'s.
|
||||
let point_size = match self.model {
|
||||
ExecModel::Geometry => Some(Cap::GeometryPointSize),
|
||||
ExecModel::TessellationControl | ExecModel::TessellationEvaluation => {
|
||||
Some(Cap::TessellationPointSize)
|
||||
}
|
||||
@@ -943,15 +919,6 @@ impl Deriver<'_> {
|
||||
| ExecMode::OutputPoints
|
||||
| ExecMode::OutputLines
|
||||
| ExecMode::OutputTriangles => {}
|
||||
// The entry's `Geometry` covers a geometry entry's modes. The synthesized stage
|
||||
// emits at most 3 vertices in one invocation, within every device's
|
||||
// `maxGeometryOutputVertices` (at least 256) and `maxGeometryShaderInvocations`
|
||||
// (at least 32) where `geometryShader` is.
|
||||
ExecMode::InputPoints
|
||||
| ExecMode::InputLines
|
||||
| ExecMode::OutputLineStrip
|
||||
| ExecMode::OutputTriangleStrip
|
||||
| ExecMode::Invocations { .. } => {}
|
||||
}
|
||||
}
|
||||
// The widths the denormal and rounding modes name: a width without one keeps the
|
||||
@@ -983,12 +950,7 @@ impl Deriver<'_> {
|
||||
// ---- Instructions ----
|
||||
|
||||
fn subgroup(&mut self, op: SubgroupOp) {
|
||||
// A geometry module's are the geometry stage's, though its Metal stage is the vertex
|
||||
// function's (`metal_stage`).
|
||||
self.prop(match self.model {
|
||||
ExecModel::Geometry => VkProperty::SubgroupGeometryStage,
|
||||
_ => VkProperty::SubgroupStage(self.stage),
|
||||
});
|
||||
self.prop(VkProperty::SubgroupStage(self.stage));
|
||||
self.prop(VkProperty::SubgroupOperation(SubgroupOp::Basic));
|
||||
self.prop(VkProperty::SubgroupOperation(op));
|
||||
}
|
||||
|
||||
@@ -953,7 +953,6 @@ impl Ser<'_> {
|
||||
ExecModel::TessellationControl => crate::spv::ExecutionModel::TessellationControl,
|
||||
ExecModel::TaskEXT => crate::spv::ExecutionModel::TaskEXT,
|
||||
ExecModel::MeshEXT => crate::spv::ExecutionModel::MeshEXT,
|
||||
ExecModel::Geometry => crate::spv::ExecutionModel::Geometry,
|
||||
};
|
||||
let f = self.ids.func(e.func)?;
|
||||
let mut ops = vec![model as u32, f];
|
||||
@@ -1014,11 +1013,6 @@ impl Ser<'_> {
|
||||
ExecMode::OutputPoints => plain(w, M::OutputPoints, &[]),
|
||||
ExecMode::OutputLines => plain(w, M::OutputLinesEXT, &[]),
|
||||
ExecMode::OutputTriangles => plain(w, M::OutputTrianglesEXT, &[]),
|
||||
ExecMode::InputPoints => plain(w, M::InputPoints, &[]),
|
||||
ExecMode::InputLines => plain(w, M::InputLines, &[]),
|
||||
ExecMode::OutputLineStrip => plain(w, M::OutputLineStrip, &[]),
|
||||
ExecMode::OutputTriangleStrip => plain(w, M::OutputTriangleStrip, &[]),
|
||||
ExecMode::Invocations { n } => plain(w, M::Invocations, &[n]),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1117,8 +1111,7 @@ impl Ser<'_> {
|
||||
(
|
||||
ExecModel::Vertex
|
||||
| ExecModel::TessellationEvaluation
|
||||
| ExecModel::MeshEXT
|
||||
| ExecModel::Geometry,
|
||||
| ExecModel::MeshEXT,
|
||||
IoDir::Output
|
||||
) | (ExecModel::Fragment, IoDir::Input)
|
||||
);
|
||||
@@ -2088,8 +2081,6 @@ impl Ser<'_> {
|
||||
vertices,
|
||||
primitives,
|
||||
} => w.inst(Op::SetMeshOutputsEXT, &[v(*vertices)?, v(*primitives)?]),
|
||||
Inst::EmitVertex => w.inst(Op::EmitVertex, &[]),
|
||||
Inst::EndPrimitive => w.inst(Op::EndPrimitive, &[]),
|
||||
Inst::RayQuery(op) => {
|
||||
let o = match op {
|
||||
RayQueryInst::Initialize { .. } | RayQueryInst::Confirm { .. } => {
|
||||
|
||||
@@ -208,9 +208,7 @@ fn memory_write(inst: &Inst) -> Option<Write> {
|
||||
| Inst::EndInterlock
|
||||
| Inst::DemoteToHelperInvocation
|
||||
| Inst::IsHelperInvocation
|
||||
| Inst::SetMeshOutputs { .. }
|
||||
| Inst::EmitVertex
|
||||
| Inst::EndPrimitive => None,
|
||||
| Inst::SetMeshOutputs { .. } => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,8 +75,6 @@ fn leaves_nothing(m: &TypedModule, inst: &Inst) -> bool {
|
||||
| Inst::EndInterlock
|
||||
| Inst::DemoteToHelperInvocation
|
||||
| Inst::SetMeshOutputs { .. }
|
||||
| Inst::EmitVertex
|
||||
| Inst::EndPrimitive
|
||||
| Inst::RayQuery(_) => false,
|
||||
Inst::Load { .. }
|
||||
| Inst::Unary { .. }
|
||||
|
||||
@@ -202,10 +202,8 @@ pub(super) fn check_stage(m: &TypedModule) -> Result<(), VerifyError> {
|
||||
let per_element = m.entry.model == ExecModel::MeshEXT && dir == IoDir::Output;
|
||||
let arrays_vertices = matches!(
|
||||
(m.entry.model, dir),
|
||||
(
|
||||
ExecModel::Geometry | ExecModel::TessellationEvaluation,
|
||||
IoDir::Input
|
||||
) | (ExecModel::TessellationControl, _)
|
||||
(ExecModel::TessellationEvaluation, IoDir::Input)
|
||||
| (ExecModel::TessellationControl, _)
|
||||
);
|
||||
let per_vertex = arrays_vertices && geometry_per_vertex(builtin);
|
||||
let vertex_form = arrays_vertices && element_array(m, builtin, g.pointee)?;
|
||||
@@ -373,26 +371,6 @@ fn builtin_in_model(b: crate::spv::BuiltIn, dir: IoDir, model: ExecModel) -> boo
|
||||
| B::ViewIndex
|
||||
),
|
||||
(ExecModel::TaskEXT, IoDir::Output) => false,
|
||||
(ExecModel::Geometry, IoDir::Input) => matches!(
|
||||
b,
|
||||
B::Position
|
||||
| B::PointSize
|
||||
| B::ClipDistance
|
||||
| B::CullDistance
|
||||
| B::PrimitiveId
|
||||
| B::InvocationId
|
||||
| B::ViewIndex
|
||||
),
|
||||
(ExecModel::Geometry, IoDir::Output) => matches!(
|
||||
b,
|
||||
B::Position
|
||||
| B::PointSize
|
||||
| B::ClipDistance
|
||||
| B::CullDistance
|
||||
| B::PrimitiveId
|
||||
| B::Layer
|
||||
| B::ViewportIndex
|
||||
),
|
||||
(ExecModel::MeshEXT, IoDir::Output) => matches!(
|
||||
b,
|
||||
B::Position
|
||||
|
||||
@@ -303,7 +303,9 @@ pub enum Op {
|
||||
DPdyCoarse = 214,
|
||||
#[cfg(test)]
|
||||
FwidthCoarse = 215,
|
||||
#[cfg(test)]
|
||||
EmitVertex = 218,
|
||||
#[cfg(test)]
|
||||
EndPrimitive = 219,
|
||||
#[cfg(test)]
|
||||
EmitStreamVertex = 220,
|
||||
@@ -1793,7 +1795,9 @@ impl std::fmt::Debug for Op {
|
||||
Self::DPdyCoarse => "DPdyCoarse",
|
||||
#[cfg(test)]
|
||||
Self::FwidthCoarse => "FwidthCoarse",
|
||||
#[cfg(test)]
|
||||
Self::EmitVertex => "EmitVertex",
|
||||
#[cfg(test)]
|
||||
Self::EndPrimitive => "EndPrimitive",
|
||||
#[cfg(test)]
|
||||
Self::EmitStreamVertex => "EmitStreamVertex",
|
||||
@@ -3489,7 +3493,9 @@ impl Op {
|
||||
214 => Self::DPdyCoarse,
|
||||
#[cfg(test)]
|
||||
215 => Self::FwidthCoarse,
|
||||
#[cfg(test)]
|
||||
218 => Self::EmitVertex,
|
||||
#[cfg(test)]
|
||||
219 => Self::EndPrimitive,
|
||||
#[cfg(test)]
|
||||
220 => Self::EmitStreamVertex,
|
||||
@@ -5625,6 +5631,7 @@ pub enum ExecutionModel {
|
||||
Vertex = 0,
|
||||
TessellationControl = 1,
|
||||
TessellationEvaluation = 2,
|
||||
#[cfg(test)]
|
||||
Geometry = 3,
|
||||
Fragment = 4,
|
||||
GLCompute = 5,
|
||||
@@ -5658,6 +5665,7 @@ impl ExecutionModel {
|
||||
0 => Self::Vertex,
|
||||
1 => Self::TessellationControl,
|
||||
2 => Self::TessellationEvaluation,
|
||||
#[cfg(test)]
|
||||
3 => Self::Geometry,
|
||||
4 => Self::Fragment,
|
||||
5 => Self::GLCompute,
|
||||
@@ -5706,7 +5714,6 @@ pub enum MemoryModel {
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
#[repr(u32)]
|
||||
pub enum ExecutionMode {
|
||||
Invocations = 0,
|
||||
SpacingEqual = 1,
|
||||
SpacingFractionalEven = 2,
|
||||
SpacingFractionalOdd = 3,
|
||||
@@ -5718,14 +5725,10 @@ pub enum ExecutionMode {
|
||||
DepthGreater = 14,
|
||||
DepthLess = 15,
|
||||
LocalSize = 17,
|
||||
InputPoints = 19,
|
||||
InputLines = 20,
|
||||
Triangles = 22,
|
||||
Quads = 24,
|
||||
OutputVertices = 26,
|
||||
OutputPoints = 27,
|
||||
OutputLineStrip = 28,
|
||||
OutputTriangleStrip = 29,
|
||||
#[cfg(test)]
|
||||
ContractionOff = 31,
|
||||
SubgroupUniformControlFlowKHR = 4421,
|
||||
|
||||
@@ -901,14 +901,8 @@ fn a_profile_without_shader_output_layer_draws_or_refuses_every_amplification()
|
||||
assert_eq!(draws.layered, length > 1, "{what}");
|
||||
match dev.compile_render_variant(&d, &plan.variant, &budget) {
|
||||
Ok(variant) => {
|
||||
let stages = variant
|
||||
.stages
|
||||
.iter()
|
||||
.filter(|m| m.stage == crate::vk::ShaderStage::GEOMETRY)
|
||||
.count();
|
||||
assert!(!draws.layered, "{what}: compiled");
|
||||
assert!(!variant.graphics.declares_layer, "{what}");
|
||||
assert_eq!(stages, 0, "{what}");
|
||||
drawn += 1;
|
||||
for m in &variant.stages {
|
||||
check_words_valid(&m.spirv, &variant.requirements, dev.profile())
|
||||
|
||||
@@ -256,7 +256,7 @@ fn the_band_takes_flat_varyings_from_the_first_control_point() {
|
||||
for primitive in PRIMITIVES {
|
||||
let plan = band::plan(
|
||||
&[&vertex.interface, &fragment.interface],
|
||||
(primitive, false),
|
||||
primitive,
|
||||
1,
|
||||
&profile,
|
||||
)
|
||||
|
||||
@@ -1,422 +0,0 @@
|
||||
//! A render pipeline's fan-out variant (`VariantKey::region_fan_out`, `pipeline::link::fan_out`),
|
||||
//! over the owned fixtures `engine/rfb_viewports` (Metal's fullscreen triangle) and
|
||||
//! `engine/rt6_viewports` (a fragment function writing white):
|
||||
//!
|
||||
//! - A plan whose shape fans a draw's triangles out to a rate-mapped pass's regions states the
|
||||
//! variant, which the base pipeline does not draw (`BindError::NeedsVariant`); compiled, its
|
||||
//! modules pass L3, its graphics state states the fan-out, it states no synthesized-geometry
|
||||
//! fact, and its plan settles on itself. A draw binds the region table; a probe binds its flags
|
||||
//! too and pushes its flag's index to the geometry stage. A region-copy variant draws no geometry
|
||||
//! stage: its vertex function draws its region's copy, sixteen more `NoContraction`
|
||||
//! operations than the plain one's and its clip distances `Invariant` too, binds the region
|
||||
//! table and pushes its first region to the vertex stage.
|
||||
//! - A merged draw replay's variant (`VariantKey::merged_draws`, `bind::replay::merged`) fans out
|
||||
//! in every mode as a draw's does: its modules pass L3, its vertex function pushes the header's
|
||||
//! address, and its plan settles on itself; its region-copy variant draws no geometry stage, its
|
||||
//! vertex function storing its region's viewport index and pushing its first region beside the
|
||||
//! header's address. So does its variant that draws a pass's regions several at a time
|
||||
//! (`VariantKey::region_viewports`), its vertex function storing the draw's index as its
|
||||
//! viewport's.
|
||||
//! - Drawn amplified, the plan keeps the plain variant, and draws the regions one at a time.
|
||||
//!
|
||||
//! `llvm-as` assembles the fixtures; a missing tool skips visibly. No GPU is used.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use crate::bind::{BindState, DrawCall, WriteSource};
|
||||
use crate::budget::Budget;
|
||||
use crate::device::{Device, DeviceDescription, DevicePolicy};
|
||||
use crate::error::BindError;
|
||||
use crate::library::Library;
|
||||
use crate::metal::PixelFormat;
|
||||
use crate::pipeline::descriptor::{
|
||||
ColorAttachmentDescriptor, FunctionDescriptor, RenderPipelineDescriptor, StageSource,
|
||||
};
|
||||
use crate::pipeline::facts::RuntimeFact;
|
||||
use crate::pipeline::testing::{engine_dir, llvm_assemble, AssembleError};
|
||||
use crate::pipeline::RegionFanOut;
|
||||
use crate::spirv::testing::check_words_valid;
|
||||
use crate::vk;
|
||||
|
||||
/// The bitcode of the owned fixture `stem` (`engine/<stem>.ll`), or `None` (printed) where
|
||||
/// `llvm-as` is missing.
|
||||
fn fixture(stem: &str) -> Option<Vec<u8>> {
|
||||
match llvm_assemble(&engine_dir().join(format!("{stem}.ll"))) {
|
||||
Ok(b) => Some(b),
|
||||
Err(AssembleError::Missing(why)) => {
|
||||
eprintln!("SKIPPED: {why}");
|
||||
None
|
||||
}
|
||||
Err(AssembleError::Rejected(why)) => panic!("llvm-as rejected {stem}.ll: {why}"),
|
||||
}
|
||||
}
|
||||
|
||||
fn description(stem: &str) -> DeviceDescription {
|
||||
let path = Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../metal2vulkan-validation/profiles")
|
||||
.join(format!("{stem}.json"));
|
||||
let text = std::fs::read_to_string(path).expect("profile");
|
||||
DeviceDescription::from_khronos_json(&text, None).expect("description")
|
||||
}
|
||||
|
||||
/// The fullscreen triangle's vertex function and the white fragment function, into one
|
||||
/// `RGBA8Unorm` attachment.
|
||||
fn descriptor() -> Option<RenderPipelineDescriptor> {
|
||||
let full = Library::from_air(&fixture("rfb_viewports")?).expect("library");
|
||||
let white = Library::from_air(&fixture("rt6_viewports")?).expect("library");
|
||||
let mut d = RenderPipelineDescriptor::new(StageSource::Function(FunctionDescriptor::new(
|
||||
full.function("rfb_full").expect("function"),
|
||||
)));
|
||||
d.fragment = Some(StageSource::Function(FunctionDescriptor::new(
|
||||
white.function("rt6_white").expect("function"),
|
||||
)));
|
||||
d.color_attachments[0] = Some(ColorAttachmentDescriptor::new(PixelFormat::RGBA8Unorm));
|
||||
Some(d)
|
||||
}
|
||||
|
||||
const TRIANGLE: DrawCall = DrawCall::Primitives {
|
||||
vertex_start: 0,
|
||||
vertex_count: 3,
|
||||
instance_count: 1,
|
||||
base_instance: 0,
|
||||
};
|
||||
|
||||
/// A plan whose shape fans triangles out states the variant, which the base pipeline does not
|
||||
/// draw; compiled, the variant's modules pass L3, its state states the fan-out, and its plan
|
||||
/// settles on itself, binding the region table and, for a probe, the flags and the index.
|
||||
#[test]
|
||||
fn a_fanned_out_draw_runs_its_variant() {
|
||||
let Some(d) = descriptor() else {
|
||||
return;
|
||||
};
|
||||
let budget = Budget::standard();
|
||||
for stem in ["lavapipe", "intel-irisxe-rplp-anv", "nvidia-pascal-linux"] {
|
||||
let dev = Device::from_queries(description(stem), DevicePolicy::default()).expect("device");
|
||||
let base = dev
|
||||
.compile_render_pipeline(&d, &budget)
|
||||
.unwrap_or_else(|e| panic!("{stem}: {e}"));
|
||||
let plain = (base.stages.iter())
|
||||
.find(|m| m.stage == vk::ShaderStage::VERTEX)
|
||||
.map(|m| decorated(&m.spirv))
|
||||
.expect("a vertex module");
|
||||
for mode in [
|
||||
RegionFanOut::Draw,
|
||||
RegionFanOut::Probe,
|
||||
RegionFanOut::DrawFew,
|
||||
RegionFanOut::RegionCopies,
|
||||
] {
|
||||
let state = BindState {
|
||||
region_fan_out: Some((mode, 5)),
|
||||
region_viewports: true,
|
||||
..Default::default()
|
||||
};
|
||||
let plan = base
|
||||
.plan(&dev, &state.shape())
|
||||
.unwrap_or_else(|e| panic!("{stem}: {e:?}"));
|
||||
assert_eq!(plan.variant.region_fan_out, Some(mode), "{stem}");
|
||||
// It draws no regions several at a time.
|
||||
assert!(!plan.variant.region_viewports, "{stem}");
|
||||
assert_eq!(
|
||||
plan.instantiate_draw(&state, &TRIANGLE),
|
||||
Err(BindError::NeedsVariant {
|
||||
variant: Box::new(plan.variant.clone())
|
||||
}),
|
||||
"{stem}"
|
||||
);
|
||||
let key = plan.variant.clone();
|
||||
let p = dev
|
||||
.compile_render_variant(&d, &key, &budget)
|
||||
.unwrap_or_else(|e| panic!("{stem} {mode:?}: {e}"));
|
||||
for m in &p.stages {
|
||||
check_words_valid(&m.spirv, &p.requirements, dev.profile())
|
||||
.unwrap_or_else(|e| panic!("{stem} {mode:?} {:?}: L3: {e}", m.stage));
|
||||
}
|
||||
let geometry = (p.stages.iter())
|
||||
.filter(|m| m.stage == vk::ShaderStage::GEOMETRY)
|
||||
.count();
|
||||
let stages = match mode {
|
||||
RegionFanOut::RegionCopies => 0,
|
||||
_ => 3,
|
||||
};
|
||||
assert_eq!(geometry, stages, "{stem} {mode:?}");
|
||||
let fan = p.graphics.region_fan_out.expect("the fan-out state");
|
||||
assert_eq!(fan.mode, mode, "{stem}");
|
||||
assert!(
|
||||
!(p.dependencies.iter())
|
||||
.any(|x| matches!(x.fact, RuntimeFact::SynthesizedGeometry { .. })),
|
||||
"{stem} {mode:?}"
|
||||
);
|
||||
let plan = p
|
||||
.plan(&dev, &state.shape())
|
||||
.unwrap_or_else(|e| panic!("{stem}: {e:?}"));
|
||||
assert_eq!(plan.variant, key, "{stem}");
|
||||
let sources: Vec<&WriteSource> = plan.descriptors.iter().map(|w| &w.source).collect();
|
||||
assert!(sources.contains(&&WriteSource::RateMapRegions), "{stem}");
|
||||
assert_eq!(
|
||||
sources.contains(&&WriteSource::RateMapFlags),
|
||||
mode == RegionFanOut::Probe,
|
||||
"{stem}"
|
||||
);
|
||||
let commands = plan
|
||||
.instantiate_draw(&state, &TRIANGLE)
|
||||
.unwrap_or_else(|e| panic!("{stem} {mode:?}: {e:?}"));
|
||||
let pushed: Vec<_> = (commands.push_constants.iter())
|
||||
.filter(|w| w.stages == vk::ShaderStageFlags::GEOMETRY)
|
||||
.map(|w| (w.offset, w.bytes.clone()))
|
||||
.collect();
|
||||
match mode {
|
||||
RegionFanOut::Probe => {
|
||||
assert_eq!(pushed, [(fan.push_offset, 5u32.to_le_bytes().to_vec())])
|
||||
}
|
||||
_ => assert!(pushed.is_empty(), "{stem}"),
|
||||
}
|
||||
if mode != RegionFanOut::RegionCopies {
|
||||
continue;
|
||||
}
|
||||
// Its row of regions, in the vertex stage's push range: its first region's segments,
|
||||
// the state's of x in the table's first row.
|
||||
let at = fan.push_offset;
|
||||
let row = (commands.push_constants.iter())
|
||||
.filter(|w| w.stages.contains(vk::ShaderStageFlags::VERTEX))
|
||||
.find(|w| w.offset <= at && at + 8 <= w.offset + w.bytes.len() as u32)
|
||||
.map(|w| w.bytes[(at - w.offset) as usize..][..8].to_vec());
|
||||
let words = [5u32, 0].map(u32::to_le_bytes);
|
||||
assert_eq!(row, Some(words.as_flattened().to_vec()), "{stem}");
|
||||
let spirv = (p.stages.iter())
|
||||
.find(|m| m.stage == vk::ShaderStage::VERTEX)
|
||||
.map(|m| &m.spirv)
|
||||
.expect("a vertex module");
|
||||
// Its region is its row's first plus its draw's index: no division picks it.
|
||||
let plain_spirv = (base.stages.iter())
|
||||
.find(|m| m.stage == vk::ShaderStage::VERTEX)
|
||||
.map(|m| &m.spirv)
|
||||
.expect("a vertex module");
|
||||
assert_eq!(divisions(spirv), divisions(plain_spirv), "{stem}");
|
||||
let vertex = decorated(spirv);
|
||||
// Of each axis's coordinate and its two clip distances, five products and three sums.
|
||||
assert_eq!(vertex[0], plain[0] + 2 * 8, "{stem}");
|
||||
assert_eq!(vertex[1], plain[1] + 1, "{stem}");
|
||||
// It stores a viewport index, the recording's one viewport's.
|
||||
assert_eq!(vertex[2], plain[2] + 1, "{stem}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A merged draw replay's variant fans out in every mode: its modules pass L3, its graphics state
|
||||
/// states the fan-out, its vertex function pushes the header's address (and a region-copy one its
|
||||
/// first region too, storing its region's viewport index), and its plan settles on itself; and so
|
||||
/// does its variant that draws regions several at a time.
|
||||
#[test]
|
||||
fn a_merged_draw_s_variant_fans_out() {
|
||||
replay_variant_fans_out(true);
|
||||
}
|
||||
|
||||
/// A draw replay's variant of one draw per command fans out in every mode, as a merged one's
|
||||
/// does ([`a_merged_draw_s_variant_fans_out`]), its vertex function reading its command's slot
|
||||
/// table at its push (`RootTableAddress`) and no merged header.
|
||||
#[test]
|
||||
fn a_replay_variant_fans_out() {
|
||||
replay_variant_fans_out(false);
|
||||
}
|
||||
|
||||
/// A draw replay's variant, `merged` into one draw or of one draw per command, in every fan-out
|
||||
/// mode and drawing regions several at a time: its modules pass L3, its state states the
|
||||
/// fan-out, its vertex function pushes the merged header's address where merged, else its slot
|
||||
/// table's (and a region-copy one its first region too, storing its region's viewport index),
|
||||
/// and its plan settles on itself.
|
||||
fn replay_variant_fans_out(merged: bool) {
|
||||
use crate::pipeline::sym::PushField;
|
||||
let Some(d) = descriptor() else {
|
||||
return;
|
||||
};
|
||||
let read = match merged {
|
||||
true => PushField::MergedDrawAddress,
|
||||
false => PushField::RootTableAddress,
|
||||
};
|
||||
let budget = Budget::standard();
|
||||
for stem in ["lavapipe", "intel-irisxe-rplp-anv", "nvidia-pascal-linux"] {
|
||||
let dev = Device::from_queries(description(stem), DevicePolicy::default()).expect("device");
|
||||
let base = dev
|
||||
.compile_render_pipeline(&d, &budget)
|
||||
.unwrap_or_else(|e| panic!("{stem}: {e}"));
|
||||
let plain = (base.stages.iter())
|
||||
.find(|m| m.stage == vk::ShaderStage::VERTEX)
|
||||
.map(|m| decorated(&m.spirv))
|
||||
.expect("a vertex module");
|
||||
for mode in [
|
||||
RegionFanOut::Draw,
|
||||
RegionFanOut::Probe,
|
||||
RegionFanOut::DrawFew,
|
||||
RegionFanOut::RegionCopies,
|
||||
] {
|
||||
let state = BindState {
|
||||
region_fan_out: Some((mode, 5)),
|
||||
region_viewports: true,
|
||||
..Default::default()
|
||||
};
|
||||
let plan = base
|
||||
.plan(&dev, &state.shape())
|
||||
.unwrap_or_else(|e| panic!("{stem}: {e:?}"));
|
||||
// The runtime's merged form (`BufferForms::Merged`), or its replay form
|
||||
// (`BufferForms::Replay`).
|
||||
let mut key = plan.variant.clone();
|
||||
key.replay_bindings = true;
|
||||
key.merged_draws = merged;
|
||||
let p = dev
|
||||
.compile_render_variant(&d, &key, &budget)
|
||||
.unwrap_or_else(|e| panic!("{stem} {mode:?}: {e}"));
|
||||
for m in &p.stages {
|
||||
check_words_valid(&m.spirv, &p.requirements, dev.profile())
|
||||
.unwrap_or_else(|e| panic!("{stem} {mode:?} {:?}: L3: {e}", m.stage));
|
||||
}
|
||||
let geometry = (p.stages.iter())
|
||||
.filter(|m| m.stage == vk::ShaderStage::GEOMETRY)
|
||||
.count();
|
||||
let stages = match mode {
|
||||
RegionFanOut::RegionCopies => 0,
|
||||
_ => 3,
|
||||
};
|
||||
assert_eq!(geometry, stages, "{stem} {mode:?}");
|
||||
let fan = p.graphics.region_fan_out.expect("the fan-out state");
|
||||
assert_eq!(fan.mode, mode, "{stem}");
|
||||
let facts = |fact| (p.dependencies.iter()).any(|x| x.fact == fact);
|
||||
assert!(facts(RuntimeFact::ReplayBindings), "{stem} {mode:?}");
|
||||
assert_eq!(facts(RuntimeFact::MergedDraws), merged, "{stem} {mode:?}");
|
||||
let fields: Vec<PushField> = (p.interface.push.iter())
|
||||
.flat_map(|p| p.fields.iter().map(|f| f.field))
|
||||
.collect();
|
||||
assert!(fields.contains(&read), "{stem} {mode:?}: {fields:?}");
|
||||
assert_eq!(
|
||||
fields.contains(&PushField::MergedDrawAddress),
|
||||
merged,
|
||||
"{stem} {mode:?}: {fields:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
fields.contains(&PushField::RegionBox),
|
||||
mode == RegionFanOut::RegionCopies,
|
||||
"{stem} {mode:?}: {fields:?}"
|
||||
);
|
||||
let settled = p
|
||||
.plan(&dev, &state.shape())
|
||||
.unwrap_or_else(|e| panic!("{stem} {mode:?}: {e:?}"));
|
||||
assert_eq!(settled.variant, key, "{stem} {mode:?}");
|
||||
if mode != RegionFanOut::RegionCopies {
|
||||
continue;
|
||||
}
|
||||
let vertex = (p.stages.iter())
|
||||
.find(|m| m.stage == vk::ShaderStage::VERTEX)
|
||||
.map(|m| decorated(&m.spirv))
|
||||
.expect("a vertex module");
|
||||
// Its copy's arithmetic, as a draw's: five products and three sums of each axis's
|
||||
// coordinate and its two clip distances; and the recording's one viewport's index.
|
||||
assert_eq!(vertex[0], plain[0] + 2 * 8, "{stem}");
|
||||
assert_eq!(vertex[2], plain[2] + 1, "{stem}");
|
||||
}
|
||||
// Its regions several at a time, where the pass's draws are drawn region by region.
|
||||
let state = BindState {
|
||||
region_viewports: true,
|
||||
..Default::default()
|
||||
};
|
||||
let plan = base
|
||||
.plan(&dev, &state.shape())
|
||||
.unwrap_or_else(|e| panic!("{stem}: {e:?}"));
|
||||
assert!(plan.variant.region_viewports, "{stem}");
|
||||
let mut key = plan.variant.clone();
|
||||
key.replay_bindings = true;
|
||||
key.merged_draws = merged;
|
||||
let p = dev
|
||||
.compile_render_variant(&d, &key, &budget)
|
||||
.unwrap_or_else(|e| panic!("{stem} region viewports: {e}"));
|
||||
for m in &p.stages {
|
||||
check_words_valid(&m.spirv, &p.requirements, dev.profile())
|
||||
.unwrap_or_else(|e| panic!("{stem} region viewports {:?}: L3: {e}", m.stage));
|
||||
}
|
||||
let facts = |fact| (p.dependencies.iter()).any(|x| x.fact == fact);
|
||||
for fact in [RuntimeFact::RegionViewports, RuntimeFact::ReplayBindings] {
|
||||
assert!(facts(fact), "{stem}: {fact:?}");
|
||||
}
|
||||
assert_eq!(facts(RuntimeFact::MergedDraws), merged, "{stem}");
|
||||
let vertex = (p.stages.iter())
|
||||
.find(|m| m.stage == vk::ShaderStage::VERTEX)
|
||||
.map(|m| decorated(&m.spirv))
|
||||
.expect("a vertex module");
|
||||
assert_eq!(
|
||||
vertex[2],
|
||||
plain[2] + 1,
|
||||
"{stem}: the draw's index as its viewport's"
|
||||
);
|
||||
let settled = p
|
||||
.plan(&dev, &state.shape())
|
||||
.unwrap_or_else(|e| panic!("{stem} region viewports: {e:?}"));
|
||||
assert_eq!(settled.variant, key, "{stem} region viewports");
|
||||
}
|
||||
}
|
||||
|
||||
/// How many `NoContraction`, `Invariant` and `BuiltIn ViewportIndex` decorations module `words`
|
||||
/// holds.
|
||||
fn decorated(words: &[u32]) -> [usize; 3] {
|
||||
use crate::spv::{BuiltIn, Decoration};
|
||||
let mut n = [0; 3];
|
||||
let mut i = 5;
|
||||
while let Some(&w) = words.get(i) {
|
||||
let len = (w >> 16) as usize;
|
||||
if w & 0xFFFF == crate::spv::Op::Decorate as u32 {
|
||||
match words.get(i + 2).copied() {
|
||||
Some(d) if d == Decoration::NoContraction as u32 => n[0] += 1,
|
||||
Some(d) if d == Decoration::Invariant as u32 => n[1] += 1,
|
||||
Some(d)
|
||||
if d == Decoration::BuiltIn as u32
|
||||
&& words.get(i + 3).copied() == Some(BuiltIn::ViewportIndex as u32) =>
|
||||
{
|
||||
n[2] += 1
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
if len == 0 {
|
||||
break;
|
||||
}
|
||||
i += len;
|
||||
}
|
||||
n
|
||||
}
|
||||
|
||||
/// The integer divisions and remainders of the module of `words`.
|
||||
fn divisions(words: &[u32]) -> usize {
|
||||
use crate::spv::Op;
|
||||
let ops = [Op::UDiv, Op::SDiv, Op::UMod, Op::SMod, Op::SRem].map(|op| op as u32);
|
||||
let mut n = 0;
|
||||
let mut i = 5;
|
||||
while let Some(&w) = words.get(i) {
|
||||
let len = (w >> 16) as usize;
|
||||
n += usize::from(ops.contains(&(w & 0xFFFF)));
|
||||
if len == 0 {
|
||||
break;
|
||||
}
|
||||
i += len;
|
||||
}
|
||||
n
|
||||
}
|
||||
|
||||
/// Drawn amplified, a plan whose shape fans triangles out keeps the plain variant.
|
||||
#[test]
|
||||
fn an_amplified_draw_keeps_the_plain_variant() {
|
||||
let Some(mut d) = descriptor() else {
|
||||
return;
|
||||
};
|
||||
d.max_vertex_amplification_count = 2;
|
||||
let budget = Budget::standard();
|
||||
let dev =
|
||||
Device::from_queries(description("lavapipe"), DevicePolicy::default()).expect("device");
|
||||
let base = dev
|
||||
.compile_render_pipeline(&d, &budget)
|
||||
.unwrap_or_else(|e| panic!("{e}"));
|
||||
let state = BindState {
|
||||
region_fan_out: Some((RegionFanOut::Draw, 0)),
|
||||
..Default::default()
|
||||
};
|
||||
let plan = base
|
||||
.plan(&dev, &state.shape())
|
||||
.unwrap_or_else(|e| panic!("{e:?}"));
|
||||
assert_eq!(plan.variant.region_fan_out, None);
|
||||
}
|
||||
@@ -201,7 +201,7 @@ fn a_rotated_draw_runs_the_rotated_weights_variant() {
|
||||
rotated_weights: true,
|
||||
..Default::default()
|
||||
};
|
||||
for stem in ["moltenvk-m3", "lavapipe"] {
|
||||
for stem in ["moltenvk-m3", "amd-rdna3-radv"] {
|
||||
let path = Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../metal2vulkan-validation/profiles")
|
||||
.join(format!("{stem}.json"));
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
//! their features on a profile with none.
|
||||
//! - `[[barycentric_coord]]` reads `BaryCoordKHR` or `BaryCoordNoPerspKHR`, its leading lanes for a
|
||||
//! `float` or `float2`, and for a `float3` its first two lanes and `1 - (x + y)` of them as the
|
||||
//! third, Metal's, on a profile with `fragmentShaderBarycentric`; the linked graphics state states
|
||||
//! whether the fragment function reads it.
|
||||
//! third, Metal's, on a profile with `fragmentShaderBarycentric`, and is refused needing the
|
||||
//! feature on a profile without it; the linked graphics state states whether the fragment
|
||||
//! function reads it.
|
||||
//!
|
||||
//! Every module that compiles passes L3 (`spirv-val` and requirements within the profile) under
|
||||
//! the stage-only numbering. `llvm-as` assembles the fixture; a missing tool skips visibly. No
|
||||
@@ -310,83 +311,33 @@ fn barycentric_coordinates_read_the_khr_builtins() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Without `fragmentShaderBarycentric`, `[[barycentric_coord]]` reads the `float2` center varying
|
||||
/// of each form it reads (`IoRole::Barycentric`), which the pipeline's synthesized geometry stage
|
||||
/// writes: no barycentric builtin, no barycentric feature, and a `float3` read's third weight
|
||||
/// `1 - (x + y)` of it, as with the builtin. Behind a vertex function the pipeline links with the
|
||||
/// stages. Without `geometryShader` either it needs one of the two.
|
||||
/// Without `fragmentShaderBarycentric`, `[[barycentric_coord]]` is refused needing the feature,
|
||||
/// with `geometryShader` (`lavapipe`, `intel-irisxe-rplp-anv`, `nvidia-pascal-linux`) or without
|
||||
/// it (`runtime-floor`).
|
||||
#[test]
|
||||
fn without_the_feature_the_weights_are_varyings() {
|
||||
fn without_the_feature_the_weights_are_refused() {
|
||||
let Some(bc) = fixture() else { return };
|
||||
let float2 = IoType {
|
||||
numeric: IoNumeric::Float,
|
||||
components: 2,
|
||||
source_bits: 32,
|
||||
};
|
||||
for stem in ["lavapipe", "intel-irisxe-rplp-anv", "nvidia-pascal-linux"] {
|
||||
for stem in [
|
||||
"lavapipe",
|
||||
"intel-irisxe-rplp-anv",
|
||||
"nvidia-pascal-linux",
|
||||
"runtime-floor",
|
||||
] {
|
||||
let p = prof(stem);
|
||||
assert!(!p.fields().fragment.barycentric, "{stem}");
|
||||
for (entry, forms, weights) in [
|
||||
("tail_fragment_barycentric", &[true, false][..], 3),
|
||||
("tail_fragment_barycentric_scalar", &[true][..], 0),
|
||||
for entry in [
|
||||
"tail_fragment_barycentric",
|
||||
"tail_fragment_barycentric_scalar",
|
||||
] {
|
||||
let (a, _, kept) =
|
||||
compile_kept(&bc, entry, &p).unwrap_or_else(|e| panic!("{entry} on {stem}: {e:?}"));
|
||||
assert!(
|
||||
!a.interface
|
||||
.io
|
||||
.builtins
|
||||
.iter()
|
||||
.any(|b| matches!(b, StageBuiltin::BaryCoord { .. })),
|
||||
assert_eq!(
|
||||
refused(compile(&bc, entry, &p), entry),
|
||||
(
|
||||
Feature::Barycentrics,
|
||||
any_of(&[F::FragmentShaderBarycentric])
|
||||
),
|
||||
"{entry} on {stem}"
|
||||
);
|
||||
let read: Vec<(IoRole, IoType)> = a
|
||||
.interface
|
||||
.io
|
||||
.inputs
|
||||
.iter()
|
||||
.map(|v| (v.role.clone(), v.ty))
|
||||
.collect();
|
||||
let want: Vec<(IoRole, IoType)> = forms
|
||||
.iter()
|
||||
.map(|&perspective| (IoRole::Barycentric { perspective }, float2))
|
||||
.collect();
|
||||
assert_eq!(read, want, "{entry} on {stem}");
|
||||
assert!(!a
|
||||
.requirements
|
||||
.features
|
||||
.contains(&F::FragmentShaderBarycentric));
|
||||
assert_eq!(third_weights(&kept), weights, "{entry} on {stem}");
|
||||
validate(&a, &p);
|
||||
}
|
||||
let mut r = RenderLinkInputs::new();
|
||||
r.color_attachments[0] = Some(ColorAttachmentDescriptor::new(PixelFormat::RGBA8Unorm));
|
||||
let v = compile(&bc, "tail_vertex_bool", &p).expect("vertex");
|
||||
let f = compile_with(
|
||||
&bc,
|
||||
"tail_fragment_barycentric",
|
||||
&p,
|
||||
&fragment_inputs(&r, &p),
|
||||
)
|
||||
.unwrap_or_else(|e| panic!("{stem}: {e}"));
|
||||
let linked = link(&[&v, &f], &LinkInputs::Render(Box::new(r)), &p)
|
||||
.unwrap_or_else(|e| panic!("{stem}: link: {e}"));
|
||||
let stages = linked.geometry.as_ref().expect("geometry stages");
|
||||
assert_eq!(stages.forms, [false, true], "{stem}");
|
||||
assert!(stages.varyings.is_empty(), "{stem}");
|
||||
}
|
||||
let floor = prof("runtime-floor");
|
||||
for entry in [
|
||||
"tail_fragment_barycentric",
|
||||
"tail_fragment_barycentric_scalar",
|
||||
] {
|
||||
assert_eq!(
|
||||
refused(compile(&bc, entry, &floor), entry),
|
||||
(
|
||||
Feature::Barycentrics,
|
||||
any_of(&[F::FragmentShaderBarycentric, F::GeometryShader])
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
//! same.
|
||||
//! - A fragment function that reads an index no stage writes, on a device that cannot declare its
|
||||
//! builtin, reads 0 (`StageIo::zero_indices`).
|
||||
//! - The weights' geometry stage cannot sit beside a vertex function's own `Layer`: refused as not
|
||||
//! implemented.
|
||||
//!
|
||||
//! Every module that compiles passes L3 (`spirv-val` and requirements within the profile).
|
||||
//! `llvm-as` assembles the fixtures; a missing tool skips visibly. No GPU is used.
|
||||
@@ -40,7 +38,6 @@ use crate::pipeline::testing::{compile, engine_dir, llvm_assemble, AssembleError
|
||||
use crate::pipeline::RenderPipeline;
|
||||
use crate::spirv::testing::check_words_valid;
|
||||
use crate::spv::Capability as Cap;
|
||||
use crate::vk;
|
||||
|
||||
fn assemble(name: &str) -> Option<Vec<u8>> {
|
||||
let path = engine_dir().join(name);
|
||||
@@ -86,16 +83,12 @@ fn render(
|
||||
d
|
||||
}
|
||||
|
||||
/// The geometry stages of `p`, each valid on `dev`, every other stage too.
|
||||
fn geometry_stages(p: &RenderPipeline, dev: &Device, what: &str) -> usize {
|
||||
/// Every stage of `p` valid on `dev`.
|
||||
fn validate(p: &RenderPipeline, dev: &Device, what: &str) {
|
||||
for m in &p.stages {
|
||||
check_words_valid(&m.spirv, &p.requirements, dev.profile())
|
||||
.unwrap_or_else(|e| panic!("{what} {:?}: L3: {e}", m.stage));
|
||||
}
|
||||
p.stages
|
||||
.iter()
|
||||
.filter(|m| m.stage == vk::ShaderStage::GEOMETRY)
|
||||
.count()
|
||||
}
|
||||
|
||||
/// The roles of the vertex outputs `entry` of `bc` declares on `dev`, and its builtins.
|
||||
@@ -148,7 +141,7 @@ fn a_uniform_slice_takes_the_output_and_nothing_else() {
|
||||
let p = native
|
||||
.compile_render_pipeline(&d, &budget)
|
||||
.expect("pipeline");
|
||||
assert_eq!(geometry_stages(&p, &native, "native"), 0);
|
||||
validate(&p, &native, "native");
|
||||
assert!(p.graphics.declares_layer);
|
||||
assert!(p.requirements.features.contains(&F::ShaderOutputLayer));
|
||||
for (stem, without) in [
|
||||
@@ -168,7 +161,7 @@ fn a_uniform_slice_takes_the_output_and_nothing_else() {
|
||||
let one = without
|
||||
.compile_render_variant(&d, &key, &budget)
|
||||
.unwrap_or_else(|e| panic!("{stem}, one layer: {e}"));
|
||||
assert_eq!(geometry_stages(&one, &without, stem), 0);
|
||||
validate(&one, &without, stem);
|
||||
assert!(!one.requirements.features.contains(&F::ShaderOutputLayer));
|
||||
}
|
||||
}
|
||||
@@ -200,7 +193,7 @@ fn a_uniform_viewport_takes_the_output_or_goes_nowhere() {
|
||||
let p = native
|
||||
.compile_render_pipeline(&d, &budget)
|
||||
.expect("pipeline");
|
||||
assert_eq!(geometry_stages(&p, &native, "native"), 0);
|
||||
validate(&p, &native, "native");
|
||||
assert!(p.graphics.writes_viewport_index);
|
||||
let index = crate::device::SpirvCapability::from_raw(Cap::ShaderViewportIndex as u32);
|
||||
assert!(p.requirements.spirv_capabilities.contains(&index));
|
||||
@@ -221,7 +214,7 @@ fn a_uniform_viewport_takes_the_output_or_goes_nowhere() {
|
||||
assert_eq!(outputs, [IoRole::ViewportIndex], "{builtins:?}");
|
||||
assert!(!builtins.contains(&StageBuiltin::ViewportIndex));
|
||||
let p = dev.compile_render_pipeline(&d, &budget).expect("pipeline");
|
||||
assert_eq!(geometry_stages(&p, &dev, "one viewport"), 0);
|
||||
validate(&p, &dev, "one viewport");
|
||||
// The function still writes the index: the runtime refuses its draw while the encoder
|
||||
// holds more than one viewport.
|
||||
assert!(p.graphics.writes_viewport_index);
|
||||
@@ -312,35 +305,3 @@ fn on_the_floor_a_read_of_an_index_no_stage_writes_is_zero() {
|
||||
.any(|b| matches!(b, StageBuiltin::Layer | StageBuiltin::ViewportIndex)));
|
||||
}
|
||||
}
|
||||
|
||||
/// The weights' synthesized geometry stages cannot read a vertex function's own `Layer`: a
|
||||
/// pipeline whose vertex function stores its slice beside a fragment function that reads the
|
||||
/// weights, on a device without `fragmentShaderBarycentric`, is refused as not implemented, and
|
||||
/// compiles with no geometry stage where the device reads the weights itself (the 780M's profile,
|
||||
/// with and without the feature).
|
||||
#[test]
|
||||
fn the_weights_stage_beside_a_vertex_layer_is_not_implemented() {
|
||||
let Some(bc) = assemble("rt6_layered.ll") else {
|
||||
return;
|
||||
};
|
||||
let d = render(
|
||||
&bc,
|
||||
"rt6_layered_vertex",
|
||||
"rt6_layered_weights",
|
||||
PixelFormat::R32Uint,
|
||||
);
|
||||
let mixed = device("amd-780m-radv", &[F::FragmentShaderBarycentric]);
|
||||
match mixed.compile_render_pipeline(&d, &Budget::standard()) {
|
||||
Err(Error::Unsupported(u)) => {
|
||||
assert_eq!(u.feature, Feature::Barycentrics);
|
||||
assert_eq!(u.needs, Needs::NotImplemented);
|
||||
}
|
||||
other => panic!("{:?}", other.map(|_| ())),
|
||||
}
|
||||
let native = device("amd-780m-radv", &[]);
|
||||
let p = native
|
||||
.compile_render_pipeline(&d, &Budget::standard())
|
||||
.expect("pipeline");
|
||||
assert_eq!(geometry_stages(&p, &native, "native weights"), 0);
|
||||
assert!(p.graphics.declares_layer);
|
||||
}
|
||||
@@ -144,7 +144,6 @@ mod engine_ray_tracing;
|
||||
mod engine_read_through_constant;
|
||||
mod engine_recursion;
|
||||
mod engine_refused_families;
|
||||
mod engine_region_fan_out;
|
||||
mod engine_region_viewports;
|
||||
mod engine_render_target_slice;
|
||||
mod engine_rgbx_storage;
|
||||
|
||||
@@ -212,7 +212,6 @@ assoc-const metal2vulkan::pipeline::CommandWrites::RENDER_STATE pub const RENDER
|
||||
assoc-const metal2vulkan::pipeline::CommandWrites::RESET pub const RESET: u32
|
||||
assoc-const metal2vulkan::pipeline::CommandWrites::STAGE_IN_REGION pub const STAGE_IN_REGION: u32
|
||||
assoc-const metal2vulkan::pipeline::CommandWrites::THREADGROUP_MEMORY pub const THREADGROUP_MEMORY: u32
|
||||
assoc-const metal2vulkan::pipeline::FanOutState::PUSH_BYTES pub const PUSH_BYTES: u32
|
||||
assoc-const metal2vulkan::pipeline::FunctionHandle::NULL_WORD pub const NULL_WORD: u32
|
||||
assoc-const metal2vulkan::pipeline::FunctionHandle::RESERVED_WORD pub const RESERVED_WORD: u32
|
||||
assoc-const metal2vulkan::pipeline::KernelVariant::ALL pub const ALL: [KernelVariant; 3]
|
||||
@@ -426,7 +425,6 @@ assoc-const-value metal2vulkan::pipeline::CommandWrites::RENDER_STATE 1 <<9
|
||||
assoc-const-value metal2vulkan::pipeline::CommandWrites::RESET 1 <<13
|
||||
assoc-const-value metal2vulkan::pipeline::CommandWrites::STAGE_IN_REGION 1 <<11
|
||||
assoc-const-value metal2vulkan::pipeline::CommandWrites::THREADGROUP_MEMORY 1 <<10
|
||||
assoc-const-value metal2vulkan::pipeline::FanOutState::PUSH_BYTES crate::pipeline::link::fan_out::PUSH_BYTES
|
||||
assoc-const-value metal2vulkan::pipeline::FunctionHandle::NULL_WORD 0
|
||||
assoc-const-value metal2vulkan::pipeline::FunctionHandle::RESERVED_WORD 1
|
||||
assoc-const-value metal2vulkan::pipeline::KernelVariant::ALL [KernelVariant::Plain, KernelVariant::PartialThreadgroups, KernelVariant::EmulatedSimdgroups]
|
||||
@@ -498,20 +496,6 @@ const metal2vulkan::bind::METAL_MESH_GRID_AXIS pub const METAL_MESH_GRID_AXIS: u
|
||||
const metal2vulkan::bind::METAL_MESH_GRID_TOTAL pub const METAL_MESH_GRID_TOTAL: u32
|
||||
const metal2vulkan::bind::METAL_OBJECT_GRID_TOTAL pub const METAL_OBJECT_GRID_TOTAL: u32
|
||||
const metal2vulkan::bind::NEUTRAL_HEAP_ELEMENT pub const NEUTRAL_HEAP_ELEMENT: u32
|
||||
const metal2vulkan::bind::fan_out::BLOCK_SET pub const BLOCK_SET: u32
|
||||
const metal2vulkan::bind::fan_out::BLOCK_TRIANGLES pub const BLOCK_TRIANGLES: u32
|
||||
const metal2vulkan::bind::fan_out::BOUND_BUCKETS pub const BOUND_BUCKETS: u32
|
||||
const metal2vulkan::bind::fan_out::FEW_COPIES pub const FEW_COPIES: u32
|
||||
const metal2vulkan::bind::fan_out::HEADER_ENTRIES pub const HEADER_ENTRIES: u32
|
||||
const metal2vulkan::bind::fan_out::MAX_SEGMENTS pub const MAX_SEGMENTS: u32
|
||||
const metal2vulkan::bind::fan_out::PROBE_BLOCKS pub const PROBE_BLOCKS: u32
|
||||
const metal2vulkan::bind::fan_out::PROBE_BOUNDS_AT pub const PROBE_BOUNDS_AT: u32
|
||||
const metal2vulkan::bind::fan_out::PROBE_COUNT_WORDS pub const PROBE_COUNT_WORDS: u32
|
||||
const metal2vulkan::bind::fan_out::PROBE_DRAW_WORDS pub const PROBE_DRAW_WORDS: u32
|
||||
const metal2vulkan::bind::fan_out::PROBE_SETS pub const PROBE_SETS: u32
|
||||
const metal2vulkan::bind::fan_out::STRADDLE_SET pub const STRADDLE_SET: u32
|
||||
const metal2vulkan::bind::fan_out::TABLE_BYTES pub const TABLE_BYTES: u64
|
||||
const metal2vulkan::bind::fan_out::WIDEN_PIXELS pub const WIDEN_PIXELS: f64
|
||||
const metal2vulkan::bind::indirect_commands::BINDING_COUNT pub const BINDING_COUNT: usize
|
||||
const metal2vulkan::bind::indirect_commands::COMMAND_BUFFER_HEADER_BYTES pub const COMMAND_BUFFER_HEADER_BYTES: usize
|
||||
const metal2vulkan::bind::indirect_commands::COMMAND_BYTES pub const COMMAND_BYTES: usize
|
||||
@@ -593,20 +577,6 @@ const-value metal2vulkan::bind::METAL_MESH_GRID_AXIS 65_535
|
||||
const-value metal2vulkan::bind::METAL_MESH_GRID_TOTAL 1_048_575
|
||||
const-value metal2vulkan::bind::METAL_OBJECT_GRID_TOTAL 1 <<29
|
||||
const-value metal2vulkan::bind::NEUTRAL_HEAP_ELEMENT NEUTRAL_ELEMENT
|
||||
const-value metal2vulkan::bind::fan_out::BLOCK_SET 5
|
||||
const-value metal2vulkan::bind::fan_out::BLOCK_TRIANGLES 64
|
||||
const-value metal2vulkan::bind::fan_out::BOUND_BUCKETS 16
|
||||
const-value metal2vulkan::bind::fan_out::FEW_COPIES 4
|
||||
const-value metal2vulkan::bind::fan_out::HEADER_ENTRIES 2
|
||||
const-value metal2vulkan::bind::fan_out::MAX_SEGMENTS 128
|
||||
const-value metal2vulkan::bind::fan_out::PROBE_BLOCKS 32 * PROBE_COUNT_WORDS
|
||||
const-value metal2vulkan::bind::fan_out::PROBE_BOUNDS_AT 1 + PROBE_SETS * PROBE_COUNT_WORDS
|
||||
const-value metal2vulkan::bind::fan_out::PROBE_COUNT_WORDS 32
|
||||
const-value metal2vulkan::bind::fan_out::PROBE_DRAW_WORDS PROBE_BOUNDS_AT + PROBE_BLOCKS
|
||||
const-value metal2vulkan::bind::fan_out::PROBE_SETS 7
|
||||
const-value metal2vulkan::bind::fan_out::STRADDLE_SET 6
|
||||
const-value metal2vulkan::bind::fan_out::TABLE_BYTES (HEADER_ENTRIES as u64 + 4 * MAX_SEGMENTS as u64) * 16
|
||||
const-value metal2vulkan::bind::fan_out::WIDEN_PIXELS 0.125
|
||||
const-value metal2vulkan::bind::indirect_commands::BINDING_COUNT 32
|
||||
const-value metal2vulkan::bind::indirect_commands::COMMAND_BUFFER_HEADER_BYTES 16
|
||||
const-value metal2vulkan::bind::indirect_commands::COMMAND_BYTES ((THREADGROUP_WORD + THREADGROUP_COUNT + 2) * 4).next_multiple_of(8)
|
||||
@@ -942,7 +912,6 @@ enum metal2vulkan::pipeline::PrecisionNote #[cfg_attr(feature = "serde", derive(
|
||||
enum metal2vulkan::pipeline::PushField #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum PushField
|
||||
enum metal2vulkan::pipeline::PushLoc #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum PushLoc
|
||||
enum metal2vulkan::pipeline::Reconvergence #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum Reconvergence
|
||||
enum metal2vulkan::pipeline::RegionFanOut #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum RegionFanOut
|
||||
enum metal2vulkan::pipeline::ResourceKind #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum ResourceKind
|
||||
enum metal2vulkan::pipeline::RuntimeFact #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum RuntimeFact
|
||||
enum metal2vulkan::pipeline::SampledType #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum SampledType
|
||||
@@ -1996,7 +1965,6 @@ field metal2vulkan::bind::BindShape.line_band pub line_band: Option<crate::pipel
|
||||
field metal2vulkan::bind::BindShape.primitive_id_indices pub primitive_id_indices: Option<metal::IndexType>
|
||||
field metal2vulkan::bind::BindShape.private_list pub private_list: bool
|
||||
field metal2vulkan::bind::BindShape.quad_primitive_ids pub quad_primitive_ids: bool
|
||||
field metal2vulkan::bind::BindShape.region_fan_out pub region_fan_out: Option<crate::pipeline::RegionFanOut>
|
||||
field metal2vulkan::bind::BindShape.region_viewports pub region_viewports: bool
|
||||
field metal2vulkan::bind::BindShape.render_area pub render_area: [u32; 2]
|
||||
field metal2vulkan::bind::BindShape.render_target_array_length pub render_target_array_length: u32
|
||||
@@ -2026,7 +1994,6 @@ field metal2vulkan::bind::BindState.primitive_id_indices pub primitive_id_indice
|
||||
field metal2vulkan::bind::BindState.primitive_type pub primitive_type: Option<metal::PrimitiveType>
|
||||
field metal2vulkan::bind::BindState.private_list pub private_list: bool
|
||||
field metal2vulkan::bind::BindState.quad_primitive_ids pub quad_primitive_ids: bool
|
||||
field metal2vulkan::bind::BindState.region_fan_out pub region_fan_out: Option<(crate::pipeline::RegionFanOut, u32)>
|
||||
field metal2vulkan::bind::BindState.region_viewports pub region_viewports: bool
|
||||
field metal2vulkan::bind::BindState.render_area pub render_area: [u32; 2]
|
||||
field metal2vulkan::bind::BindState.render_target_array_length pub render_target_array_length: u32
|
||||
@@ -2442,7 +2409,6 @@ field metal2vulkan::cache::VariantKey.psb_slots pub psb_slots: BTreeSet<SlotRef>
|
||||
field metal2vulkan::cache::VariantKey.pulled_vertex_buffers pub pulled_vertex_buffers: BTreeSet<u32>
|
||||
field metal2vulkan::cache::VariantKey.quad_primitive_ids pub quad_primitive_ids: bool
|
||||
field metal2vulkan::cache::VariantKey.read_only_tests pub read_only_tests: bool
|
||||
field metal2vulkan::cache::VariantKey.region_fan_out pub region_fan_out: Option<crate::pipeline::RegionFanOut>
|
||||
field metal2vulkan::cache::VariantKey.region_viewports pub region_viewports: bool
|
||||
field metal2vulkan::cache::VariantKey.replay_bindings pub replay_bindings: bool
|
||||
field metal2vulkan::cache::VariantKey.rotated_weights pub rotated_weights: bool
|
||||
@@ -2892,9 +2858,6 @@ field metal2vulkan::pipeline::EntryPlan.strategies pub strategies: BTreeMap<Stri
|
||||
field metal2vulkan::pipeline::ExtendedRangeColor.blended pub blended: bool
|
||||
field metal2vulkan::pipeline::ExtendedRangeColor.form pub form: metal::format::ExtendedRange
|
||||
field metal2vulkan::pipeline::ExtendedRangeColor.nearest_even pub nearest_even: bool
|
||||
field metal2vulkan::pipeline::FanOutState.copies pub copies: u32
|
||||
field metal2vulkan::pipeline::FanOutState.mode pub mode: RegionFanOut
|
||||
field metal2vulkan::pipeline::FanOutState.push_offset pub push_offset: u32
|
||||
field metal2vulkan::pipeline::FetchedAttachment.blending_enabled pub blending_enabled: bool
|
||||
field metal2vulkan::pipeline::FetchedAttachment.equation pub equation: Option<BlendEquation>
|
||||
field metal2vulkan::pipeline::FetchedAttachment.pixel_format pub pixel_format: metal::PixelFormat
|
||||
@@ -2932,7 +2895,6 @@ field metal2vulkan::pipeline::GraphicsState.rasterization_samples pub rasterizat
|
||||
field metal2vulkan::pipeline::GraphicsState.rasterizer_discard pub rasterizer_discard: bool
|
||||
field metal2vulkan::pipeline::GraphicsState.reads_barycentric_coord pub reads_barycentric_coord: bool
|
||||
field metal2vulkan::pipeline::GraphicsState.reads_primitive_id pub reads_primitive_id: bool
|
||||
field metal2vulkan::pipeline::GraphicsState.region_fan_out pub region_fan_out: Option<FanOutState>
|
||||
field metal2vulkan::pipeline::GraphicsState.sample_mask pub sample_mask: Option<u32>
|
||||
field metal2vulkan::pipeline::GraphicsState.shadow_stencil pub shadow_stencil: Option<ShadowStencilUse>
|
||||
field metal2vulkan::pipeline::GraphicsState.snapshot_reads pub snapshot_reads: bool
|
||||
@@ -3010,7 +2972,6 @@ field metal2vulkan::pipeline::LoweringInputs.psb_slots pub psb_slots: BTreeSet<S
|
||||
field metal2vulkan::pipeline::LoweringInputs.push_base pub push_base: u32
|
||||
field metal2vulkan::pipeline::LoweringInputs.quad_primitive_ids pub quad_primitive_ids: bool
|
||||
field metal2vulkan::pipeline::LoweringInputs.read_only_tests pub read_only_tests: bool
|
||||
field metal2vulkan::pipeline::LoweringInputs.region_copies pub region_copies: bool
|
||||
field metal2vulkan::pipeline::LoweringInputs.region_viewports pub region_viewports: bool
|
||||
field metal2vulkan::pipeline::LoweringInputs.render_target_array_index_varying pub render_target_array_index_varying: bool
|
||||
field metal2vulkan::pipeline::LoweringInputs.replay_bindings pub replay_bindings: bool
|
||||
@@ -3385,11 +3346,6 @@ fn metal2vulkan::bind::draw_replay_primitive_type pub fn draw_replay_primitive_t
|
||||
fn metal2vulkan::bind::draw_replay_slots pub fn draw_replay_slots(interface: &PipelineInterface) -> (u32, u32)
|
||||
fn metal2vulkan::bind::draw_replay_state pub fn draw_replay_state(graphics: &GraphicsState, merged: bool) -> Result<(), DrawReplayRule>
|
||||
fn metal2vulkan::bind::draw_replay_vertex_layouts pub fn draw_replay_vertex_layouts(input: &VertexInputState) -> Result<BTreeSet<u32>, DrawReplayRule>
|
||||
fn metal2vulkan::bind::fan_out::bucket pub const fn bucket(segment: u32, segments: u32) -> u32
|
||||
fn metal2vulkan::bind::fan_out::clip_entry pub const fn clip_entry(axis: u32, k: u32) -> u32
|
||||
fn metal2vulkan::bind::fan_out::line_entry pub const fn line_entry(axis: u32, k: u32) -> u32
|
||||
fn metal2vulkan::bind::fan_out::scissors pub fn scissors(regions: &[([f32; 4], [u32; 4])]) -> Option<Vec<[u32; 4]>>
|
||||
fn metal2vulkan::bind::fan_out::table pub fn table(target: [f32; 4], regions: &[([f32; 4], [u32; 4])]) -> Option<Vec<u8>>
|
||||
fn metal2vulkan::bind::fold_object_grid pub fn fold_object_grid(groups: [u32; 3], threads: [u32; 3], task: MeshGridLimits, direct: bool) -> Option<ObjectFold>
|
||||
fn metal2vulkan::bind::geometry_flags pub fn geometry_flags(opaque: bool, allow_duplicate_invocation: bool) -> u32
|
||||
fn metal2vulkan::bind::geometry_table_offset pub fn geometry_table_offset(offsets: &[u64]) -> Result<u32, Unsupported>
|
||||
@@ -7295,7 +7251,6 @@ method metal2vulkan::pipeline::PrivateRenderState::new pub const fn new() -> Pri
|
||||
method metal2vulkan::pipeline::RenderPipeline::content_digest pub fn content_digest(&self) -> Hash256
|
||||
method metal2vulkan::pipeline::RenderPipeline::footprint pub fn footprint(&self) -> u64
|
||||
method metal2vulkan::pipeline::RenderPipeline::plan pub fn plan(&self, device: &Device, shape: &BindShape) -> Result<BindingPlan, BindError>
|
||||
method metal2vulkan::pipeline::RenderPipeline::runs_stage pub fn runs_stage(&self, at: usize, topology: vk::PrimitiveTopology) -> bool
|
||||
method metal2vulkan::pipeline::RenderPipelineDescriptor::fragment_writes_depth_unattached pub fn fragment_writes_depth_unattached(&self, budget: &crate::Budget, entries: &StageEntries) -> Result<bool, Error>
|
||||
method metal2vulkan::pipeline::RenderPipelineDescriptor::new pub fn new(vertex: StageSource) -> RenderPipelineDescriptor
|
||||
method metal2vulkan::pipeline::RenderPipelineDescriptor::reflection pub fn reflection(&self, budget: &crate::Budget) -> Result<RenderPipelineReflection, Error>
|
||||
@@ -7343,7 +7298,6 @@ method metal2vulkan::pipeline::TileRenderPipelineDescriptor::new pub fn new(tile
|
||||
method metal2vulkan::pipeline::TileRenderPipelineDescriptor::reflection pub fn reflection(&self, budget: &crate::Budget) -> Result<RenderPipelineReflection, Error>
|
||||
method metal2vulkan::pipeline::TileRenderPipelineDescriptor::slot_writes pub fn slot_writes(&self, budget: &crate::Budget) -> Result<SlotWrites, Error>
|
||||
method metal2vulkan::pipeline::VaryingKey::attribute pub fn attribute(index: u32) -> VaryingKey
|
||||
method metal2vulkan::pipeline::VaryingKey::barycentric pub fn barycentric(perspective: bool) -> VaryingKey
|
||||
method metal2vulkan::pipeline::VaryingKey::color pub fn color(attachment: u32, index: u32) -> VaryingKey
|
||||
method metal2vulkan::pipeline::VaryingKey::merged_command pub fn merged_command() -> VaryingKey
|
||||
method metal2vulkan::pipeline::VaryingKey::primitive_id pub fn primitive_id() -> VaryingKey
|
||||
@@ -7849,7 +7803,6 @@ struct metal2vulkan::pipeline::DynamicLibraries #[derive(Clone, Debug, Default,
|
||||
struct metal2vulkan::pipeline::EntryDescriptor #[derive(Clone, Debug)] #[non_exhaustive] pub struct EntryDescriptor<'a>
|
||||
struct metal2vulkan::pipeline::EntryPlan #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct EntryPlan
|
||||
struct metal2vulkan::pipeline::ExtendedRangeColor #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct ExtendedRangeColor
|
||||
struct metal2vulkan::pipeline::FanOutState #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct FanOutState
|
||||
struct metal2vulkan::pipeline::FetchedAttachment #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct FetchedAttachment
|
||||
struct metal2vulkan::pipeline::FragmentImageblock #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct FragmentImageblock
|
||||
struct metal2vulkan::pipeline::FramebufferFetchInputs #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct FramebufferFetchInputs
|
||||
@@ -9760,8 +9713,6 @@ variant metal2vulkan::bind::WriteSource::Imageblock Imageblock
|
||||
variant metal2vulkan::bind::WriteSource::InlineBytes InlineBytes { slot: SlotRef }
|
||||
variant metal2vulkan::bind::WriteSource::Neutral Neutral(NeutralResource)
|
||||
variant metal2vulkan::bind::WriteSource::PatchIndices PatchIndices { min_bytes: u32 }
|
||||
variant metal2vulkan::bind::WriteSource::RateMapFlags RateMapFlags
|
||||
variant metal2vulkan::bind::WriteSource::RateMapRegions RateMapRegions
|
||||
variant metal2vulkan::bind::WriteSource::Sampler Sampler { slot: SlotRef, compare: bool, integer: bool, opaque_black: OpaqueBlackBorder }
|
||||
variant metal2vulkan::bind::WriteSource::ShadowStencil ShadowStencil
|
||||
variant metal2vulkan::bind::WriteSource::SnapshotTexels SnapshotTexels { slot: u32 }
|
||||
@@ -10275,7 +10226,6 @@ variant metal2vulkan::device::VkProperty::RoundingIndependenceAll RoundingIndepe
|
||||
variant metal2vulkan::device::VkProperty::SampleLocationSampleCount SampleLocationSampleCount(u32)
|
||||
variant metal2vulkan::device::VkProperty::StencilResolveMode StencilResolveMode(ResolveMode)
|
||||
variant metal2vulkan::device::VkProperty::StorageImageSampleCount StorageImageSampleCount(u32)
|
||||
variant metal2vulkan::device::VkProperty::SubgroupGeometryStage SubgroupGeometryStage
|
||||
variant metal2vulkan::device::VkProperty::SubgroupOperation SubgroupOperation(SubgroupOp)
|
||||
variant metal2vulkan::device::VkProperty::SubgroupQuadOperationsInAllStages SubgroupQuadOperationsInAllStages
|
||||
variant metal2vulkan::device::VkProperty::SubgroupStage SubgroupStage(Stage)
|
||||
@@ -10957,8 +10907,6 @@ variant metal2vulkan::pipeline::PushField::MergedDrawAddress MergedDrawAddress
|
||||
variant metal2vulkan::pipeline::PushField::PatchIndexBound PatchIndexBound
|
||||
variant metal2vulkan::pipeline::PushField::PatchIndexOffset PatchIndexOffset
|
||||
variant metal2vulkan::pipeline::PushField::PrivateArenaAddress PrivateArenaAddress
|
||||
variant metal2vulkan::pipeline::PushField::RegionBox RegionBox
|
||||
variant metal2vulkan::pipeline::PushField::RegionProbe RegionProbe
|
||||
variant metal2vulkan::pipeline::PushField::RenderTargetArrayLength RenderTargetArrayLength
|
||||
variant metal2vulkan::pipeline::PushField::ReplayRegionAddress ReplayRegionAddress
|
||||
variant metal2vulkan::pipeline::PushField::RootTableAddress RootTableAddress
|
||||
@@ -10987,10 +10935,6 @@ variant metal2vulkan::pipeline::PushLoc::ArgumentTable ArgumentTable { offset: u
|
||||
variant metal2vulkan::pipeline::PushLoc::Push Push { offset: u32 }
|
||||
variant metal2vulkan::pipeline::Reconvergence::Guaranteed Guaranteed
|
||||
variant metal2vulkan::pipeline::Reconvergence::ImplementationDefined ImplementationDefined
|
||||
variant metal2vulkan::pipeline::RegionFanOut::Draw Draw
|
||||
variant metal2vulkan::pipeline::RegionFanOut::DrawFew DrawFew
|
||||
variant metal2vulkan::pipeline::RegionFanOut::Probe Probe
|
||||
variant metal2vulkan::pipeline::RegionFanOut::RegionCopies RegionCopies
|
||||
variant metal2vulkan::pipeline::ResourceKind::AccelerationStructure AccelerationStructure(AccelerationStructureLevel)
|
||||
variant metal2vulkan::pipeline::ResourceKind::Buffer Buffer
|
||||
variant metal2vulkan::pipeline::ResourceKind::CombinedTextureSampler CombinedTextureSampler(CombinedSampler)
|
||||
@@ -11085,7 +11029,6 @@ variant metal2vulkan::pipeline::RuntimeFact::StorageTextureLevelViews StorageTex
|
||||
variant metal2vulkan::pipeline::RuntimeFact::StorageTextureLevels StorageTextureLevels { slot: SlotRef }
|
||||
variant metal2vulkan::pipeline::RuntimeFact::StorageTextureNumericType StorageTextureNumericType { slot: SlotRef }
|
||||
variant metal2vulkan::pipeline::RuntimeFact::StorageTextureWriteRounding StorageTextureWriteRounding { slot: SlotRef, halves: bool }
|
||||
variant metal2vulkan::pipeline::RuntimeFact::SynthesizedGeometry SynthesizedGeometry { weights: bool }
|
||||
variant metal2vulkan::pipeline::RuntimeFact::TestedStorageWrites TestedStorageWrites { early_tests: bool, early_variant: bool }
|
||||
variant metal2vulkan::pipeline::RuntimeFact::TexelBufferParts TexelBufferParts { slot: SlotRef }
|
||||
variant metal2vulkan::pipeline::RuntimeFact::TexelBufferRange TexelBufferRange { slot: SlotRef }
|
||||
@@ -11210,8 +11153,6 @@ variant metal2vulkan::pipeline::SyntheticBinding::FunctionTableSnapshot Function
|
||||
variant metal2vulkan::pipeline::SyntheticBinding::HandleTable HandleTable
|
||||
variant metal2vulkan::pipeline::SyntheticBinding::Imageblock Imageblock
|
||||
variant metal2vulkan::pipeline::SyntheticBinding::PatchIndices PatchIndices
|
||||
variant metal2vulkan::pipeline::SyntheticBinding::RateMapFlags RateMapFlags
|
||||
variant metal2vulkan::pipeline::SyntheticBinding::RateMapRegions RateMapRegions
|
||||
variant metal2vulkan::pipeline::SyntheticBinding::RootTable RootTable
|
||||
variant metal2vulkan::pipeline::SyntheticBinding::SamplerTable SamplerTable
|
||||
variant metal2vulkan::pipeline::SyntheticBinding::ShadowStencil ShadowStencil
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -355,13 +355,11 @@ surface! {
|
||||
enum BandPrimitive E;
|
||||
struct BlendState N;
|
||||
struct ColorAttachmentState N;
|
||||
struct FanOutState N;
|
||||
struct FragmentImageblock N;
|
||||
struct GraphicsState N;
|
||||
enum ImageblockMechanism N;
|
||||
struct InputAttachmentUse N;
|
||||
struct LineBandState N;
|
||||
enum RegionFanOut E;
|
||||
struct ShadowStencilUse N;
|
||||
struct StorageAttachmentUse N;
|
||||
enum StorageAttachmentView E;
|
||||
@@ -652,30 +650,8 @@ surface! {
|
||||
struct DepthStencilCopyModules N;
|
||||
struct StencilBit O;
|
||||
struct StencilSplitModule N;
|
||||
mod fan_out;
|
||||
mod indirect_commands;
|
||||
}
|
||||
"bind::fan_out" => metal2vulkan::bind::fan_out {
|
||||
const BLOCK_SET;
|
||||
const BLOCK_TRIANGLES;
|
||||
const BOUND_BUCKETS;
|
||||
const FEW_COPIES;
|
||||
const HEADER_ENTRIES;
|
||||
const MAX_SEGMENTS;
|
||||
const PROBE_BLOCKS;
|
||||
const PROBE_BOUNDS_AT;
|
||||
const PROBE_COUNT_WORDS;
|
||||
const PROBE_DRAW_WORDS;
|
||||
const PROBE_SETS;
|
||||
const STRADDLE_SET;
|
||||
const TABLE_BYTES;
|
||||
const WIDEN_PIXELS;
|
||||
fn bucket;
|
||||
fn clip_entry;
|
||||
fn line_entry;
|
||||
fn scissors;
|
||||
fn table;
|
||||
}
|
||||
"bind::indirect_commands" => metal2vulkan::bind::indirect_commands {
|
||||
enum Action E;
|
||||
enum AddressError N;
|
||||
@@ -2107,7 +2083,6 @@ fn scanned_modules() -> Vec<&'static str> {
|
||||
"reflection",
|
||||
"pipeline",
|
||||
"bind",
|
||||
"bind::fan_out",
|
||||
"bind::indirect_commands",
|
||||
"cache",
|
||||
"metal",
|
||||
|
||||
+5
-18
@@ -743,10 +743,7 @@ let pipeline = device.compile_render_pipeline(&descriptor, &Budget::standard())?
|
||||
|
||||
A `RenderPipeline` holds:
|
||||
|
||||
- `stages`: vertex, then fragment when rasterization is enabled, with three geometry stages
|
||||
before the fragment stage when the fragment function reads `[[barycentric_coord]]` on a device
|
||||
without `fragmentShaderBarycentric` (below). A `VkPipeline` takes the stages
|
||||
`RenderPipeline::runs_stage(at, topology)` says its topology runs;
|
||||
- `stages`: vertex, then fragment when rasterization is enabled;
|
||||
- `layout`: one pipeline layout for every stage;
|
||||
- `vertex_input`: Vulkan bindings and attributes. An attribute Vulkan cannot fetch as described is
|
||||
pulled in the shader instead, and so is every attribute on a device without
|
||||
@@ -866,18 +863,8 @@ Where Metal's rules differ from Vulkan's, the pipeline gives Metal's answer:
|
||||
- `[[barycentric_coord]]` reads `BaryCoordKHR` or `BaryCoordNoPerspKHR`, whose vertex order is
|
||||
Vulkan's first-vertex order and Metal's for every primitive type. A `float3` read takes the
|
||||
first two weights and computes the third as `1 - (x + y)` in `float`, as Metal does, not the
|
||||
device's own third lane.
|
||||
On a device without `fragmentShaderBarycentric` the weights are a varying instead: the pipeline
|
||||
carries a generated geometry stage for each topology class (points, lines, triangles, in that
|
||||
order), which writes `(1, 0)`, `(0, 1)` and `(0, 0)` at the primitive's vertices in their order
|
||||
and passes the vertex function's outputs, clip distances, point size and the primitive ID
|
||||
through, and a draw runs its class's. A `centroid` or `sample` qualifier reads the pixel
|
||||
center's weights, as Metal does. That needs `geometryShader`; without it, or for what a geometry
|
||||
stage cannot carry (tessellation, mesh pipelines, a vertex function's own layer or viewport
|
||||
index, amplification without `multiviewGeometryShader`, a written point size in a point draw
|
||||
without `shaderTessellationAndGeometryPointSize`, more varyings than the geometry limits), the
|
||||
pipeline is refused, naming what it needs. Measured on the Iris Xe (ANV), such a pipeline takes
|
||||
about 2.6 ms longer to create, and a geometry stage's presence costs about 15% of fill rate.
|
||||
device's own third lane. On a device without `fragmentShaderBarycentric` the function is
|
||||
refused, `Unsupported{Barycentrics}` needing the feature.
|
||||
- A vertex function stores `Layer` or `ViewportIndex` only where it writes the index the same at
|
||||
every vertex of a primitive, decided from its structure (computed from constants, `constant`
|
||||
memory, the instance, the amplification and per-instance attributes, as
|
||||
@@ -938,8 +925,8 @@ Where Metal's rules differ from Vulkan's, the pipeline gives Metal's answer:
|
||||
counter-clockwise one). A smooth varying and the clip distances are each endpoint's, a flat or
|
||||
integer varying the first vertex's. It needs `tessellationShader` (`Unsupported{WideLines}`
|
||||
needing it); a post-tessellation vertex function, a vertex function that writes a layer or
|
||||
viewport index, synthesized geometry stages, a fragment function that reads barycentric weights
|
||||
and multiview are not implemented.
|
||||
viewport index, a fragment function that reads barycentric weights and multiview are not
|
||||
implemented.
|
||||
- `graphics` also states what the runtime needs to record draws correctly: whether the fragment
|
||||
function reads flat inputs, barycentrics or its position's depth, whether the vertex function
|
||||
writes memory or a layer or viewport index, and which colors the function may write.
|
||||
|
||||
@@ -31,10 +31,9 @@ metallib | AIR bitcode
|
||||
── serialize ───► SPIR-V 1.5 words with typed relocations spirv::serialize
|
||||
= CompiledFunction, keyed by FunctionCompileKey (the caller may cache it)
|
||||
── link ────────► bindings, Locations, spec ids, the pipeline pipeline::link
|
||||
layout, pipeline-wide limits, the generated pipeline::link::geometry
|
||||
geometry stages (barycentric weights read as pipeline::link::band
|
||||
varyings), the generated tessellation stages
|
||||
that draw a wide line as a band
|
||||
layout, pipeline-wide limits, the generated pipeline::link::band
|
||||
tessellation stages that draw a wide line as a
|
||||
band
|
||||
── relocate ────► the final words of each stage pipeline::relocate
|
||||
= ComputePipeline | RenderPipeline | tile and mesh pipelines
|
||||
|
||||
|
||||
+5
-5
@@ -40,7 +40,7 @@ Columns:
|
||||
|
||||
| Kind | `metal-measured` | `metal-documented` | `metal-takes` | `device` | `ours` | `unknown` | `delegated` | `-` |
|
||||
|---|---|---|---|---|---|---|---|---|
|
||||
| Translator and front-end refusals | 0 | 0 | 0 | 42 | 57 | 0 | 0 | 36 |
|
||||
| Translator and front-end refusals | 0 | 0 | 0 | 43 | 56 | 0 | 0 | 36 |
|
||||
| Binder refusals at a device limit | 0 | 0 | 0 | 9 | 0 | 0 | 0 | 0 |
|
||||
| Translation caps | 0 | 0 | 0 | 0 | 14 | 0 | 0 | 0 |
|
||||
| Rate maps the compile layer does not compile | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 |
|
||||
@@ -117,7 +117,7 @@ Columns:
|
||||
| `LayeredRendering` | Layered rendering (`render_target_array_index`, `viewport_array_index`) | devices short of a Vulkan feature the site names; devices without VkFeature::ShaderOutputLayer; devices without VkFeature::ShaderOutputViewportIndex; every device (not implemented) | `ours` | 4: `crates/metal2vulkan/src/lower/mesh/mod.rs (target_index, 2 sites)`, `crates/metal2vulkan/src/lower/stage_io/plan.rs (index_store, 2 sites)` | `rare`: layered rendering on a device without its features |
|
||||
| `ClipDistance` | Clip or cull distances | devices without VkFeature::ShaderClipDistance; devices without VkLimit::MaxClipDistances | `device` | 2: `crates/metal2vulkan/src/lower/mesh/mod.rs (select, 2 sites)` | `rare`: clip distances on a device without them |
|
||||
| `DualSourceBlending` | Dual-source blending | devices without VkFeature::DualSrcBlend; devices without VkLimit::MaxFragmentDualSrcAttachments | `device` | 3: `crates/metal2vulkan/src/metal/state.rs (blend_factor)`, `crates/metal2vulkan/src/pipeline/link/graphics.rs (check_outputs)` (+1) | `rare`: dual-source blending on a device without it |
|
||||
| `Barycentrics` | Barycentric coordinates | devices without VkFeature::FragmentShaderBarycentric; devices without VkFeature::GeometryShader; devices without a capability the site computes (`needs`); every device (not implemented) | `ours` | 4: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`, `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)` (+2) | `rare`: barycentric coordinates |
|
||||
| `Barycentrics` | Barycentric coordinates | devices without VkFeature::FragmentShaderBarycentric | `device` | 2: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`, `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)` | `rare`: barycentric coordinates |
|
||||
| `StencilExport` | Stencil export | devices without VkExtension::ExtShaderStencilExport; every device (not implemented) | `ours` | 5: `crates/metal2vulkan/src/bind/graphics.rs (shadow_stencil_words)`, `crates/metal2vulkan/src/lower/fragment/stencil.rs (device_form)` (+2) | `rare`: stencil from the shader |
|
||||
| `SampleRateShading` | Per-sample shading | devices without VkFeature::SampleRateShading; devices without a capability the site computes (`needs`); every device (not implemented) | `ours` | 3: `crates/metal2vulkan/src/pipeline/link/graphics.rs (sample_invocations, 3 sites)` | `rare`: per-sample shading |
|
||||
| `PullModelInterpolation` | Metal's pull-model interpolation (`interpolant` fragment inputs and their `interpolate_at_center`, `_centroid`, `_sample` and `_offset` functions)... | devices without VkProperty::InterpolateAtOffsetCentered; devices without VkProperty::InterpolateAtOffsetFromSevenSixteenths; devices without a capability the site computes (`lacks`); every device (not implemented) | `ours` | 5: `crates/metal2vulkan/src/lower/fragment/interpolate.rs (select, 2 sites)`, `crates/metal2vulkan/src/lower/stage_io/plan.rs (interpolant, 2 sites)` (+1) | `rare`: interpolant inputs read at the centroid, a sample or an offset |
|
||||
@@ -135,7 +135,7 @@ Columns:
|
||||
| `Imageblocks` | An imageblock outside the forms implemented | devices without VkFeature::SampleRateShading; devices without a capability the site computes (`missing`); every device (not implemented) | `ours` | 8: `crates/metal2vulkan/src/lower/access/imageblock.rs (imageblocks)`, `crates/metal2vulkan/src/lower/access/mod.rs (select_param)` (+6) | `rare`: imageblocks (Apple GPU families) |
|
||||
| `RayTracing` | | devices without a capability the site computes (`missing`); every device (no Vulkan mechanism); every device (not implemented) | `ours` | 12: `crates/metal2vulkan/src/bind/acceleration.rs (instance_record, 2 sites)`, `crates/metal2vulkan/src/lower/raytracing/mod.rs (instance_count)` (+5) | `rare`: ray tracing (out of scope by ruling) |
|
||||
| `Tensors` | | every device (not implemented) | `ours` | 2: `crates/metal2vulkan-air/src/canon/matmul2d/synth.rs (refuse)`, `crates/metal2vulkan/src/lower/select.rs (route_air)` | `rare`: shader tensors |
|
||||
| `RasterizationRateMap` | | devices without VkFeature::MultiViewport; devices without VkFeature::ShaderDrawParameters; devices without VkFeature::ShaderOutputViewportIndex; devices without VkLimit::MaxGeometryTotalOutputComponents; devices without a capability the site computes; devices without a capability the site computes (`vec![Capability::Feature(lacks)]`); devices without a capability the site computes (`vec![limit]`); every device (not implemented) | `ours` | 11: `crates/metal2vulkan/src/lower/stage_io/plan.rs (region_copy, 3 sites)`, `crates/metal2vulkan/src/lower/stage_io/plan.rs (region_viewport, 2 sites)` (+3) | `rare`: rasterization rate maps |
|
||||
| `RasterizationRateMap` | | devices without VkFeature::MultiViewport; devices without VkFeature::ShaderDrawParameters; devices without VkFeature::ShaderOutputViewportIndex; every device (not implemented) | `ours` | 2: `crates/metal2vulkan/src/lower/stage_io/plan.rs (region_viewport, 2 sites)` | `rare`: rasterization rate maps |
|
||||
| `GpuEncodedIndirectCommands` | | devices short of a Vulkan feature the site names; devices without buffer device addresses (`addressed_needs`); every device (no Vulkan mechanism); every device (not implemented) | `ours` | 20: `crates/metal2vulkan/src/bind/replay.rs (preprocess)`, `crates/metal2vulkan/src/bind/replay.rs (replay_preprocess_module)` (+12) | `rare`: indirect command buffers encoded by a kernel |
|
||||
| `VulkanVersion` | The device's Vulkan version is below the 1.2 floor | devices without ApiVersion::V1_2 | `device` | 2: `crates/metal2vulkan/src/ash_interop/query.rs (query)`, `crates/metal2vulkan/src/device/derive.rs (from_queries)` | `none`: a device below Vulkan 1.2 |
|
||||
| `PushWindow` | The device's `maxPushConstantsSize` is below the 256 bytes of the push window every stage is lowered for | devices without VkLimit::MaxPushConstantsSize | `device` | 1: `crates/metal2vulkan/src/device/derive.rs (from_queries)` | `none`: a device whose maxPushConstantsSize is below 256 bytes |
|
||||
@@ -458,7 +458,7 @@ Each refusal's sites, with the function that builds it.
|
||||
- `feature::LayeredRendering`: `crates/metal2vulkan/src/lower/mesh/mod.rs (target_index, 2 sites)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (index_store, 2 sites)`
|
||||
- `feature::ClipDistance`: `crates/metal2vulkan/src/lower/mesh/mod.rs (select, 2 sites)`
|
||||
- `feature::DualSourceBlending`: `crates/metal2vulkan/src/metal/state.rs (blend_factor)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (check_outputs)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (rotated_blend)`
|
||||
- `feature::Barycentrics`: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs (not_implemented)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs (refused)`
|
||||
- `feature::Barycentrics`: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)`
|
||||
- `feature::StencilExport`: `crates/metal2vulkan/src/bind/graphics.rs (shadow_stencil_words)`; `crates/metal2vulkan/src/lower/fragment/stencil.rs (device_form)`; `crates/metal2vulkan/src/lower/fragment/stencil.rs (not_implemented)`; `crates/metal2vulkan/src/pipeline/link/stencil.rs (shadow_stencil, 2 sites)`
|
||||
- `feature::SampleRateShading`: `crates/metal2vulkan/src/pipeline/link/graphics.rs (sample_invocations, 3 sites)`
|
||||
- `feature::PullModelInterpolation`: `crates/metal2vulkan/src/lower/fragment/interpolate.rs (select, 2 sites)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (interpolant, 2 sites)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (interpolant_reads)`
|
||||
@@ -475,7 +475,7 @@ Each refusal's sites, with the function that builds it.
|
||||
- `feature::Imageblocks`: `crates/metal2vulkan/src/lower/access/imageblock.rs (imageblocks)`; `crates/metal2vulkan/src/lower/access/mod.rs (select_param)`; `crates/metal2vulkan/src/lower/fragment/imageblock.rs (not_implemented)`; `crates/metal2vulkan/src/lower/fragment/imageblock.rs (reach)`; `crates/metal2vulkan/src/lower/fragment/imageblock.rs (require)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select)`; `crates/metal2vulkan/src/lower/texture/slice.rs (imageblocks)`; `crates/metal2vulkan/src/pipeline/link/imageblock.rs (fragment_imageblock)`
|
||||
- `feature::RayTracing`: `crates/metal2vulkan/src/bind/acceleration.rs (instance_record, 2 sites)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (instance_count)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (intersect, 5 sites)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (primitive_data_read)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (select_param)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (slot_of)`; `crates/metal2vulkan/src/lower/select.rs (route_air)`
|
||||
- `feature::Tensors`: `crates/metal2vulkan-air/src/canon/matmul2d/synth.rs (refuse)`; `crates/metal2vulkan/src/lower/select.rs (route_air)`
|
||||
- `feature::RasterizationRateMap`: `crates/metal2vulkan/src/lower/stage_io/plan.rs (region_copy, 3 sites)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (region_viewport, 2 sites)`; `crates/metal2vulkan/src/pipeline/link.rs (region_box)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs (check_limits, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs (fan_plan, 3 sites)`
|
||||
- `feature::RasterizationRateMap`: `crates/metal2vulkan/src/lower/stage_io/plan.rs (region_viewport, 2 sites)`
|
||||
- `feature::GpuEncodedIndirectCommands`: `crates/metal2vulkan/src/bind/replay.rs (preprocess)`; `crates/metal2vulkan/src/bind/replay.rs (replay_preprocess_module)`; `crates/metal2vulkan/src/bind/replay/draws.rs (draw_replay_module)`; `crates/metal2vulkan/src/bind/replay/draws.rs (draw_replay_preprocess)`; `crates/metal2vulkan/src/bind/replay/merged.rs (draw_merge_module)`; `crates/metal2vulkan/src/lower/access/encode.rs (needs, 3 sites)`; `crates/metal2vulkan/src/lower/access/encode.rs (select_command)`; `crates/metal2vulkan/src/lower/access/mod.rs (plan_replay, 3 sites)`; `crates/metal2vulkan/src/lower/mesh/mod.rs (plan_partial_groups)`; `crates/metal2vulkan/src/lower/select.rs (finish, 2 sites)`; `crates/metal2vulkan/src/lower/simd/divergent.rs (barriers)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (merged)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)`; `crates/metal2vulkan/src/pipeline/compile.rs (analyze_one, 2 sites)`
|
||||
- `feature::VulkanVersion`: `crates/metal2vulkan/src/ash_interop/query.rs (query)`; `crates/metal2vulkan/src/device/derive.rs (from_queries)`
|
||||
- `feature::PushWindow`: `crates/metal2vulkan/src/device/derive.rs (from_queries)`
|
||||
|
||||
@@ -55,7 +55,7 @@ values GroupNonUniformBitwiseOr GroupNonUniformBitwiseXor GroupNonUniformLogical
|
||||
values GroupNonUniformLogicalOr GroupNonUniformLogicalXor GroupNonUniformQuadBroadcast
|
||||
values GroupNonUniformQuadSwap TerminateInvocation FmaKHR TypeRayQueryKHR RayQueryInitializeKHR
|
||||
values RayQueryConfirmIntersectionKHR RayQueryProceedKHR RayQueryGetIntersectionTypeKHR
|
||||
values EmitVertex EndPrimitive EmitMeshTasksEXT SetMeshOutputsEXT TypeAccelerationStructureKHR BeginInvocationInterlockEXT
|
||||
values EmitMeshTasksEXT SetMeshOutputsEXT TypeAccelerationStructureKHR BeginInvocationInterlockEXT
|
||||
values EndInvocationInterlockEXT DemoteToHelperInvocation IsHelperInvocationEXT
|
||||
values RayQueryGetIntersectionTKHR RayQueryGetIntersectionInstanceCustomIndexKHR
|
||||
values RayQueryGetIntersectionInstanceIdKHR
|
||||
@@ -72,7 +72,7 @@ values *
|
||||
|
||||
enum ExecutionModel
|
||||
from_u32 test
|
||||
values Vertex TessellationControl TessellationEvaluation Geometry Fragment GLCompute TaskEXT MeshEXT
|
||||
values Vertex TessellationControl TessellationEvaluation Fragment GLCompute TaskEXT MeshEXT
|
||||
test-values *
|
||||
|
||||
enum AddressingModel
|
||||
@@ -87,8 +87,8 @@ values OriginUpperLeft EarlyFragmentTests DepthReplacing DepthGreater DepthLess
|
||||
values Quads OutputVertices OutputPoints SubgroupUniformControlFlowKHR SignedZeroInfNanPreserve
|
||||
values StencilRefReplacingEXT RequireFullQuadsKHR OutputLinesEXT OutputPrimitivesEXT
|
||||
values DerivativeGroupLinearKHR OutputTrianglesEXT PixelInterlockOrderedEXT
|
||||
values SampleInterlockOrderedEXT MaximallyReconvergesKHR InputPoints InputLines Invocations
|
||||
values OutputLineStrip OutputTriangleStrip DenormPreserve RoundingModeRTE PostDepthCoverage
|
||||
values SampleInterlockOrderedEXT MaximallyReconvergesKHR DenormPreserve RoundingModeRTE
|
||||
values PostDepthCoverage
|
||||
test-values ContractionOff FPFastMathDefault
|
||||
|
||||
enum StorageClass
|
||||
|
||||
Reference in new issue
Block a user