RUNTIME 2246: setTriangleFillMode: 2 (MTLTriangleFillModePoints, Apple-private) draws a triangle's vertices as points
Apple's GL renderer sends setTriangleFillMode:2 for glPolygonMode(GL_POINT) under its Intel and
Apple-silicon caps tables. The value is not in the public headers. Our TriangleFillMode had only
Fill and Lines, so the consumer's raw-value conversion failed and its host died. Measured on
Metal: an M3 Max and an Intel UHD 630 draw only a triangle's 3 vertex pixels (a Radeon Pro 5300M
fills it); our own probe on the M3 (m3-max-26811) draws 1-px points whether point_size is 4, 1 or
unwritten, culls them with CullMode Front, and draws them with Back.
Now TriangleFillMode::Points (2) exists. The generator (scripts/regen-metal-enums) takes a
PRIVATE line for it, with its evidence, and a PRIVATE_DOCS doc comment (metal_enum! accepts
variant attributes); generated.rs stays generated and `--check` passes. The runtime draws it as
VK_POLYGON_MODE_POINT. It needs fillModeNonSolid (refused otherwise:
Feature::TriangleFillPoints) and, on a portability-subset device, pointPolygons
(VkFeature::PointPolygons; MoltenVK withholds it, so it refuses Points). New degradation
TrianglePointSize ("triangle-point-size"): Vulkan sizes the points by the PointSize the vertex
function writes, where Metal draws 1 px. An ICB command still refuses set_triangle_fill_mode, as
before. New lane module runtime_lane::triangle_points.
Verified (fillpoints, 6b9927c402 on 25be73dddf):
- lavapipe lane 30/30: points light {(3,3),(3,12),(12,3)} (Metal's 3 vertex pixels); culled
front none, back the same 3; fill 45 px (the M3 lit 45); lines 27; fill/lines unchanged.
- msi: clippy plain, m2v_gpu and m2v_cpu_icd 0; rustdoc 0; touched tests 102/102.
- Owed: the XTX leg (m3-max-26943).
ARTIFACT_FORMAT_VERSION 519 -> 520 (VkFeature appended to the codec), RUNTIME_VERSION 2245 -> 2246.
This commit is contained in:
1 parent
7de85991e5
commit
977c9da12f
30 files changed
+435
-26
No files matched your search
@@ -2368,6 +2368,17 @@ degradations! {
|
||||
"the points rasterize nothing, the vertex function run for each, where what Metal \
|
||||
draws is undefined: most of its draws draw nothing, and some a few of the points \
|
||||
or a box";
|
||||
/// A draw of triangles in fill mode `TriangleFillMode::Points` (the raw value 2, which
|
||||
/// Apple's GL renderer sends), whose vertices the device draws as points, under a render
|
||||
/// pipeline state whose vertex function writes `[[point_size]]`
|
||||
/// (`render/draw_shape.rs`): a direct draw, an indirect one, or an indirect command's in
|
||||
/// an execution. The device sizes each point by the size the vertex function writes where its
|
||||
/// `polygonModePointSize` is set (every device profiled), where Metal draws one pixel
|
||||
/// whatever the function writes (measured on an Apple M3 Max). A vertex function that
|
||||
/// writes none draws points of one pixel: its module writes 1.
|
||||
TrianglePointSize = "triangle-point-size", Precision,
|
||||
"each vertex can draw at the point size the vertex function writes, where Metal \
|
||||
draws one pixel";
|
||||
/// A draw of lines at a width other than 1 (Apple's `setLineWidth:`), or of a triangle's
|
||||
/// edges in fill mode `Lines` or of a mesh draw, drawn by the device's own lines
|
||||
/// (`render/line_width.rs`), which no device's are taken to draw as Metal's
|
||||
|
||||
@@ -980,6 +980,7 @@ members! {
|
||||
PortabilitySubset.portability_subset.image_view2_d_on3_d_image => ImageView2DOn3DImage;
|
||||
PortabilitySubset.portability_subset.separate_stencil_mask_ref => SeparateStencilMaskRef;
|
||||
PortabilitySubset.portability_subset.image_view_format_swizzle => ImageViewFormatSwizzle;
|
||||
PortabilitySubset.portability_subset.point_polygons => PointPolygons;
|
||||
}
|
||||
|
||||
members! {
|
||||
|
||||
@@ -12805,7 +12805,15 @@ impl RenderCommandEncoder {
|
||||
}
|
||||
}
|
||||
|
||||
/// `setTriangleFillMode:`. `Lines` needs `fillModeNonSolid` (`Unsupported`).
|
||||
/// `setTriangleFillMode:` (`MTLTriangleFillMode`). `Lines` needs `fillModeNonSolid`
|
||||
/// (`Unsupported`). `Points` is the raw value 2, which no SDK header declares and Apple's GL
|
||||
/// renderer sends for `glPolygonMode(GL_POINT)`: Metal draws each triangle's vertices as points
|
||||
/// of one pixel on an Apple M3 Max and an Intel UHD Graphics 630 (a Radeon Pro 5300M fills the
|
||||
/// triangle), and the runtime draws them as points (`VK_POLYGON_MODE_POINT`). It needs
|
||||
/// `fillModeNonSolid`, and on a portability-subset device `pointPolygons` (`Unsupported`). A
|
||||
/// point takes the size the vertex function writes (`[[point_size]]`), where the M3 Max draws
|
||||
/// one pixel whatever it writes: a draw whose vertex function writes one announces
|
||||
/// `Degradation::TrianglePointSize`.
|
||||
pub fn set_triangle_fill_mode(&mut self, mode: TriangleFillMode) -> Result<(), Error> {
|
||||
match self.lowers_at_call() {
|
||||
true => self.at_call(|lowering| lowering.set_triangle_fill_mode(mode)),
|
||||
|
||||
@@ -83,7 +83,7 @@ use crate::sample_positions::Sixteenths;
|
||||
use crate::versioned::Versioned;
|
||||
use crate::Device;
|
||||
use metal2vulkan::bind::BindingPlan;
|
||||
use metal2vulkan::metal::{PixelFormat, PrimitiveTopologyClass, PrimitiveType};
|
||||
use metal2vulkan::metal::{PixelFormat, PrimitiveTopologyClass, PrimitiveType, TriangleFillMode};
|
||||
use metal2vulkan::pipeline::{GraphicsState, Stage};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::sync::{Arc, Mutex};
|
||||
@@ -424,6 +424,30 @@ impl ShapeInputs<'_> {
|
||||
)
|
||||
});
|
||||
}
|
||||
// A triangle's vertices drawn as points (fill mode `Points`) take the size the vertex
|
||||
// function writes where Metal draws one pixel: announced once at the draw, as above.
|
||||
let triangle_points = !base.rasterizer_discard
|
||||
&& base.writes_point_size
|
||||
&& self.state.fill_mode() == TriangleFillMode::Points
|
||||
&& matches!(
|
||||
topology,
|
||||
metal2vulkan::vk::PrimitiveTopology::TRIANGLE_LIST
|
||||
| metal2vulkan::vk::PrimitiveTopology::TRIANGLE_STRIP
|
||||
| metal2vulkan::vk::PrimitiveTopology::TRIANGLE_FAN
|
||||
);
|
||||
if announce && triangle_points {
|
||||
device.degrade(Degradation::TrianglePointSize, || {
|
||||
(
|
||||
format!(
|
||||
"{call}: a draw of triangles in fill mode Points under a pipeline state \
|
||||
whose vertex function writes a point size"
|
||||
),
|
||||
"the device sizes a polygon's points by the point size the last stage \
|
||||
writes (polygonModePointSize), where Metal draws one pixel"
|
||||
.to_owned(),
|
||||
)
|
||||
});
|
||||
}
|
||||
// A point size the vertex or mesh function writes past the device's largest point, which
|
||||
// draws at that bound: announced once at a draw that rasterizes points, a mesh draw's
|
||||
// points its mesh function's (`GraphicsState::mesh_corners`), and at no other draw, whose
|
||||
|
||||
@@ -476,7 +476,8 @@ impl EncoderState {
|
||||
self.alpha_test_reference = Some(value);
|
||||
}
|
||||
|
||||
/// `setTriangleFillMode:`: `Lines` needs `fillModeNonSolid`.
|
||||
/// `setTriangleFillMode:`: `Lines` needs `fillModeNonSolid`, `Points` that and, on a
|
||||
/// portability-subset device, `pointPolygons` (`metal::state::polygon_mode`).
|
||||
pub(super) fn set_fill_mode(
|
||||
&mut self,
|
||||
mode: TriangleFillMode,
|
||||
|
||||
@@ -1250,6 +1250,7 @@ members! {
|
||||
Some(F::SeparateStencilMaskRef);
|
||||
PortabilitySubset.portability_subset.image_view_format_swizzle =>
|
||||
Some(F::ImageViewFormatSwizzle);
|
||||
PortabilitySubset.portability_subset.point_polygons => Some(F::PointPolygons);
|
||||
GeneratedCommands.generated_commands.device_generated_commands => None,
|
||||
registry = "deviceGeneratedCommands";
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ fn the_old_engine_list_is_unchanged() {
|
||||
F::FragmentShaderBarycentric,
|
||||
// The portability subset's structure is chained with what the device supports, as
|
||||
// it always was; the vocabulary names these members, the next three since ARTIFACT 180,
|
||||
// and `imageViewFormatSwizzle` since ARTIFACT 203.
|
||||
// `imageViewFormatSwizzle` since ARTIFACT 203, and `pointPolygons`.
|
||||
F::ConstantAlphaColorBlendFactors,
|
||||
F::VertexAttributeAccessBeyondStride,
|
||||
F::SamplerMipLodBias,
|
||||
@@ -379,6 +379,7 @@ fn the_old_engine_list_is_unchanged() {
|
||||
F::ImageView2DOn3DImage,
|
||||
F::SeparateStencilMaskRef,
|
||||
F::ImageViewFormatSwizzle,
|
||||
F::PointPolygons,
|
||||
// `maintenance5` was always chained for the generated-commands path; the vocabulary
|
||||
// names it.
|
||||
F::Maintenance5,
|
||||
|
||||
@@ -960,6 +960,8 @@ mod tile_threadgroups;
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
mod topology_classes;
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
mod triangle_points;
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
mod two_plane_copies;
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
mod two_plane_heap_blits;
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
//! [`UNTIMED`], [`FROM_HOST`]), color fills packed where fills ignore the color
|
||||
//! ([`UNPACKED_FILL`]), texture buffers' fills reading bytes past their pattern's copies in
|
||||
//! `texture_buffer_fills` ([`TEXTURE_BUFFER_FILL`]), draws of points no state sizes in
|
||||
//! `topology_classes` ([`UNSIZED_POINTS`]),
|
||||
//! `topology_classes` ([`UNSIZED_POINTS`]), triangles in fill mode `Points` whose vertex function
|
||||
//! writes a point size in `triangle_points` ([`TRIANGLE_POINT_SIZE`]),
|
||||
//! resource IDs ([`UNLISTED`]),
|
||||
//! indirect command buffers' commands naming a released state ([`RELEASED_STATES`]) and their host
|
||||
//! steps ([`HOST_STEPS`]), indirect dispatches' host reads ([`INDIRECT_DISPATCHES`]), indexed draws
|
||||
@@ -231,6 +232,7 @@ use super::sparse_textures::SPARSE;
|
||||
use super::texture_blits::{MIPMAPS, UPLOADS};
|
||||
use super::tile_dispatches::TILE_DISPATCHES;
|
||||
use super::topology_classes::UNSIZED_POINTS;
|
||||
use super::triangle_points::TRIANGLE_POINT_SIZE;
|
||||
use super::two_plane_copies::TWO_PLANE_COPIES;
|
||||
use super::unorm_depth_bias::{UNORM_DEPTH_BIAS, UNORM_DEPTH_ROUNDING};
|
||||
use super::view_reinterpretation::VIEW_SHADOWS;
|
||||
@@ -610,6 +612,7 @@ fn every_kind_has_a_site_a_lane_test_takes() {
|
||||
&CREATED,
|
||||
&PRIVATE_PROPERTIES,
|
||||
&UNSIZED_POINTS,
|
||||
&TRIANGLE_POINT_SIZE,
|
||||
&SYNTHESIZED_GEOMETRY,
|
||||
&EMULATED_TESSELLATION,
|
||||
&GROUPED,
|
||||
|
||||
@@ -0,0 +1,219 @@
|
||||
//! A triangle in fill mode `Points` on the device the cfg selects, under the validation layer.
|
||||
//!
|
||||
//! `TriangleFillMode::Points` is `setTriangleFillMode:`'s raw value 2, which no SDK header
|
||||
//! declares and Apple's GL renderer sends for `glPolygonMode(GL_POINT)`. A Metal probe on an Apple
|
||||
//! M3 Max (macOS 27.0.1) drew one triangle, `(3.5, 3.5)`, `(12.5, 3.5)` and `(3.5, 12.5)` in a
|
||||
//! 16x16 target, clockwise and so front-facing under Metal's default winding: in `Points` each
|
||||
//! vertex's pixel alone ([`VERTICES`]), one pixel wide whether the vertex function wrote a
|
||||
//! `[[point_size]]` of 4, of 1 or none; nothing under `setCullMode:` `Front`, the three pixels under
|
||||
//! `Back`. The consumer's probe drew the three pixels on the M3 Max and an Intel UHD Graphics 630,
|
||||
//! where a Radeon Pro 5300M filled the triangle. The runtime draws the mode as
|
||||
//! `VK_POLYGON_MODE_POINT`, which culls the triangle first as Metal does.
|
||||
//!
|
||||
//! Here `rt6_restart`'s vertex function, which writes a `[[point_size]]` of 1, draws that triangle
|
||||
//! with `rt6_render_state`'s white fragment function: `Points` stores Metal's pixels, culled and
|
||||
//! not, and announces `triangle-point-size` ([`TRIANGLE_POINT_SIZE`]), its vertex function writing
|
||||
//! a point size; `Fill` covers the triangle's inside and `Lines` does not. `rt6_small`, which writes
|
||||
//! none, draws points of one pixel at its vertices through a viewport that puts them at pixel
|
||||
//! centers, announcing nothing. A device without `fillModeNonSolid` refuses the mode, as it does
|
||||
//! `Lines`, and so does a portability subset without `pointPolygons` (MoltenVK's), which Vulkan
|
||||
//! forbids the mode.
|
||||
|
||||
use super::buffer_with;
|
||||
use super::degrade_notices::{assert_made_once, made_render_kinds, shared_in_system_memory};
|
||||
use super::line_widths::line_ties;
|
||||
use super::render_state::{quiet, validated, validated_without, Probe, PASS, WHITE};
|
||||
use crate::air_library::AirLibrary;
|
||||
use metal2vulkan::device::VkFeature;
|
||||
use metal2vulkan::error::{Capability, Feature, Unsupported};
|
||||
use metal2vulkan::metal::{CullMode, PixelFormat, PrimitiveType, TriangleFillMode};
|
||||
use metal2vulkan::pipeline::{ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource};
|
||||
use metal2vulkan_devtools::{engine_dir, llvm_assemble};
|
||||
use metal2vulkan_runtime::{
|
||||
Buffer, Degradation, Error, PipelineOptions, RenderCommandEncoder, RenderPipelineState,
|
||||
Viewport,
|
||||
};
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
/// The kinds `triangle_points` takes: a triangle's points sized by its vertex function.
|
||||
pub(super) const TRIANGLE_POINT_SIZE: [Degradation; 1] = [Degradation::TrianglePointSize];
|
||||
|
||||
/// The probe's triangle, in pixels of the 16x16 target.
|
||||
const TRIANGLE: [[f32; 2]; 3] = [[3.5, 3.5], [12.5, 3.5], [3.5, 12.5]];
|
||||
|
||||
/// The pixels `(x, y)` Metal stored of [`TRIANGLE`] in fill mode `Points` (the module docs).
|
||||
const VERTICES: [(u32, u32); 3] = [(3, 3), (12, 3), (3, 12)];
|
||||
|
||||
/// A pixel inside [`TRIANGLE`], on none of its edges.
|
||||
const INSIDE: (u32, u32) = (5, 5);
|
||||
|
||||
/// The descriptor of a pipeline drawing `rt6_restart`'s vertices, white, of Metal's default
|
||||
/// input primitive topology class (none: Metal refuses a point size under the triangle class).
|
||||
fn sized_descriptor(probe: &Probe) -> RenderPipelineDescriptor {
|
||||
let function = |stem: &str, name: &str| {
|
||||
let bitcode = llvm_assemble(&engine_dir().join(format!("{stem}.ll"))).unwrap();
|
||||
probe
|
||||
.device
|
||||
.new_library_with_air(&bitcode)
|
||||
.unwrap()
|
||||
.new_function_with_name(name)
|
||||
.unwrap()
|
||||
.function_descriptor()
|
||||
};
|
||||
let mut descriptor = RenderPipelineDescriptor::new(StageSource::Function(function(
|
||||
"rt6_restart",
|
||||
"rt6_restart_vertex",
|
||||
)));
|
||||
descriptor.fragment = Some(StageSource::Function(function(
|
||||
"rt6_render_state",
|
||||
"rt6_white",
|
||||
)));
|
||||
descriptor.color_attachments[0] = Some(ColorAttachmentDescriptor::new(PixelFormat::RGBA8Unorm));
|
||||
descriptor
|
||||
}
|
||||
|
||||
/// The kinds a test forces where the device has not announced them, beside its pipeline states'
|
||||
/// makings': the `Shared` resources' system memory.
|
||||
fn shared(probe: &Probe) -> BTreeSet<Degradation> {
|
||||
BTreeSet::from_iter(
|
||||
shared_in_system_memory(&probe.device).then_some(Degradation::SharedInSystemMemory),
|
||||
)
|
||||
}
|
||||
|
||||
/// The lit pixels `(x, y)` of a 16x16 pass `body` draws into, the buffers it holds kept until the
|
||||
/// pass completed.
|
||||
fn lit(
|
||||
probe: &Probe,
|
||||
body: impl FnOnce(&mut RenderCommandEncoder, &mut Vec<Buffer>),
|
||||
) -> BTreeSet<(u32, u32)> {
|
||||
let stored = probe.run(PASS.size(16), |_, e, held| body(e, held));
|
||||
(stored.color.chunks(4).enumerate())
|
||||
.filter(|(_, texel)| texel[0] != 0)
|
||||
.map(|(i, _)| ((i % 16) as u32, (i / 16) as u32))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The refusal `setTriangleFillMode:` of `fill` returns in a pass of `probe`'s device, if any.
|
||||
fn refusal(probe: &Probe, fill: TriangleFillMode) -> Option<Unsupported> {
|
||||
let mut refusal = None;
|
||||
lit(probe, |e, _| refusal = e.set_triangle_fill_mode(fill).err());
|
||||
refusal.map(|error| match error {
|
||||
Error::Unsupported(unsupported) => unsupported,
|
||||
other => panic!("{fill:?} refused otherwise: {other:?}"),
|
||||
})
|
||||
}
|
||||
|
||||
/// Whether `probe`'s device refuses `Points` for its portability subset's withheld
|
||||
/// `pointPolygons` (MoltenVK), where the call returns that refusal.
|
||||
fn refuses_points(probe: &Probe) -> bool {
|
||||
let polygons = VkFeature::PointPolygons;
|
||||
let profile = probe.device.compile_device().profile();
|
||||
let refuses = profile.enabled().portability_withholds(polygons);
|
||||
if refuses {
|
||||
let needs = Unsupported::needs(Feature::TriangleFillPoints, Capability::Feature(polygons));
|
||||
assert_eq!(refusal(probe, TriangleFillMode::Points), Some(needs));
|
||||
}
|
||||
refuses
|
||||
}
|
||||
|
||||
/// [`TRIANGLE`] stores Metal's pixels in `Points`, culled and not, and its inside in `Fill` alone,
|
||||
/// and announces `triangle-point-size` once, the vertex function writing a point size (and the
|
||||
/// width-1 lines' `device-line-ties` where the driver's ties are not measured). A device that
|
||||
/// refuses `Points` ([`refuses_points`]) draws none of it.
|
||||
#[test]
|
||||
fn a_triangle_in_fill_mode_points_draws_its_vertices() {
|
||||
let (messages, _cache, probe) = validated();
|
||||
if refuses_points(&probe) {
|
||||
assert_made_once(&messages, &[], &shared(&probe));
|
||||
quiet(probe, &messages);
|
||||
return;
|
||||
}
|
||||
let descriptor = sized_descriptor(&probe);
|
||||
let pipeline: RenderPipelineState = probe
|
||||
.device
|
||||
.new_render_pipeline_state(&descriptor, &PipelineOptions::default())
|
||||
.unwrap();
|
||||
let positions: Vec<u8> = TRIANGLE
|
||||
.iter()
|
||||
.flat_map(|[x, y]| [x / 8.0 - 1.0, 1.0 - y / 8.0])
|
||||
.flat_map(f32::to_le_bytes)
|
||||
.collect();
|
||||
let positions = buffer_with(&probe.device, &positions).unwrap();
|
||||
let draw = |fill, cull| {
|
||||
lit(&probe, |e, _| {
|
||||
e.set_render_pipeline_state(&pipeline).unwrap();
|
||||
e.set_vertex_buffer(Some(&positions), 0, 0).unwrap();
|
||||
e.set_cull_mode(cull);
|
||||
e.set_triangle_fill_mode(fill).unwrap();
|
||||
e.draw_primitives(PrimitiveType::Triangle, 0, 3, 1, 0)
|
||||
.unwrap();
|
||||
})
|
||||
};
|
||||
let points = draw(TriangleFillMode::Points, CullMode::None);
|
||||
let front = draw(TriangleFillMode::Points, CullMode::Front);
|
||||
let back = draw(TriangleFillMode::Points, CullMode::Back);
|
||||
let fill = draw(TriangleFillMode::Fill, CullMode::None);
|
||||
let lines = draw(TriangleFillMode::Lines, CullMode::None);
|
||||
eprintln!(
|
||||
"TRIANGLE-POINTS {}: points {points:?}, culled front {front:?}, culled back {back:?}, \
|
||||
fill {} pixels, lines {}",
|
||||
probe.device.name(),
|
||||
fill.len(),
|
||||
lines.len()
|
||||
);
|
||||
let kinds = [&TRIANGLE_POINT_SIZE[..], line_ties(&probe.device)].concat();
|
||||
let mut first = made_render_kinds(&probe.device, &descriptor);
|
||||
first.extend(shared(&probe));
|
||||
assert_made_once(&messages, &kinds, &first);
|
||||
quiet(probe, &messages);
|
||||
let metal = BTreeSet::from(VERTICES);
|
||||
assert_eq!(points, metal);
|
||||
assert_eq!(front, BTreeSet::new());
|
||||
assert_eq!(back, metal);
|
||||
assert!(fill.contains(&INSIDE), "{fill:?}");
|
||||
assert!(
|
||||
!lines.contains(&INSIDE) && lines.len() > metal.len(),
|
||||
"{lines:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// `rt6_small`, which writes no point size, draws in fill mode `Points` a point of one pixel at
|
||||
/// each vertex: a 6x6 viewport puts its `(-0.5, -0.5)`, `(0.5, -0.5)` and `(-0.5, 0.5)` at the
|
||||
/// pixel centers `(1.5, 4.5)`, `(4.5, 4.5)` and `(1.5, 1.5)`. Nothing is announced.
|
||||
#[test]
|
||||
fn a_function_without_a_point_size_draws_points_of_one_pixel() {
|
||||
let (messages, _cache, probe) = validated();
|
||||
if refuses_points(&probe) {
|
||||
assert_made_once(&messages, &[], &shared(&probe));
|
||||
quiet(probe, &messages);
|
||||
return;
|
||||
}
|
||||
let pipe = WHITE.vertex("rt6_small");
|
||||
let stored = lit(&probe, |e, held| {
|
||||
e.set_viewport(Viewport::new(0.0, 0.0, 6.0, 6.0, 0.0, 1.0))
|
||||
.unwrap();
|
||||
e.set_triangle_fill_mode(TriangleFillMode::Points).unwrap();
|
||||
probe.draw(e, held, pipe, 0.5, 0.0);
|
||||
});
|
||||
let mut first = probe.made(pipe);
|
||||
first.extend(shared(&probe));
|
||||
assert_made_once(&messages, &[], &first);
|
||||
quiet(probe, &messages);
|
||||
assert_eq!(stored, BTreeSet::from([(1, 4), (4, 4), (1, 1)]));
|
||||
}
|
||||
|
||||
/// A device without `fillModeNonSolid` refuses `Points` at the call, naming the feature, as it
|
||||
/// refuses `Lines`.
|
||||
#[test]
|
||||
fn points_need_fill_mode_non_solid() {
|
||||
let (messages, _cache, probe) = validated_without(&[VkFeature::FillModeNonSolid]);
|
||||
for (fill, what) in [
|
||||
(TriangleFillMode::Points, Feature::TriangleFillPoints),
|
||||
(TriangleFillMode::Lines, Feature::TriangleFillLines),
|
||||
] {
|
||||
let needs = Unsupported::needs(what, Capability::Feature(VkFeature::FillModeNonSolid));
|
||||
assert_eq!(refusal(&probe, fill), Some(needs), "{fill:?}");
|
||||
}
|
||||
assert_made_once(&messages, &[], &shared(&probe));
|
||||
quiet(probe, &messages);
|
||||
}
|
||||
@@ -832,6 +832,7 @@ feature_sources! { c, x;
|
||||
ImageView2DOn3DImage => on(c.portability_subset.image_view2_d_on3_d_image);
|
||||
SeparateStencilMaskRef => on(c.portability_subset.separate_stencil_mask_ref);
|
||||
ImageViewFormatSwizzle => on(c.portability_subset.image_view_format_swizzle);
|
||||
PointPolygons => on(c.portability_subset.point_polygons);
|
||||
ShaderFmaFloat16 => on(c.shader_fma.shader_fma_float16);
|
||||
ShaderFmaFloat32 => on(c.shader_fma.shader_fma_float32);
|
||||
ShaderFloat8 => on(c.shader_float8.shader_float8);
|
||||
|
||||
@@ -597,6 +597,7 @@ fn unexposed_structures_are_never_chained() {
|
||||
VkFeature::ImageView2DOn3DImage,
|
||||
VkFeature::SeparateStencilMaskRef,
|
||||
VkFeature::ImageViewFormatSwizzle,
|
||||
VkFeature::PointPolygons,
|
||||
] {
|
||||
assert!(!desc.features.contains(&absent), "{absent:?}");
|
||||
}
|
||||
|
||||
+1
@@ -1006,6 +1006,7 @@ codec_enum! {
|
||||
WideLines,
|
||||
MultiDraw,
|
||||
ShaderFloat8,
|
||||
PointPolygons,
|
||||
}
|
||||
VkExtension {
|
||||
ExtRobustness2, ExtImageRobustness, ExtShaderAtomicFloat, ExtShaderAtomicFloat2,
|
||||
|
||||
Vendored
+2
-2
@@ -71,7 +71,7 @@ pub const SEMANTICS_VERSION: u32 = 2098;
|
||||
/// 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 = 519;
|
||||
pub const ARTIFACT_FORMAT_VERSION: u32 = 520;
|
||||
|
||||
/// 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
|
||||
@@ -94,7 +94,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 519;
|
||||
/// changes no behaviour, and then updates that hash alone with the commit saying why, or changes
|
||||
/// behaviour and also bumps this version. The commit that bumps it says what changed; this comment
|
||||
/// keeps no history.
|
||||
pub const RUNTIME_VERSION: u32 = 2245;
|
||||
pub const RUNTIME_VERSION: u32 = 2246;
|
||||
|
||||
/// The digest of the sources this build of the crate was compiled from: SHA-256, as lowercase hex,
|
||||
/// of the manifest, the build script, and exactly the files the crate roots' module tree compiles
|
||||
|
||||
@@ -305,7 +305,7 @@ exposures! {
|
||||
Extension(&[E::KhrPortabilitySubset]) => [
|
||||
ConstantAlphaColorBlendFactors, VertexAttributeAccessBeyondStride, SamplerMipLodBias,
|
||||
MutableComparisonSamplers, ShaderSampleRateInterpolationFunctions, MultisampleArrayImage,
|
||||
ImageView2DOn3DImage, SeparateStencilMaskRef, ImageViewFormatSwizzle,
|
||||
ImageView2DOn3DImage, SeparateStencilMaskRef, ImageViewFormatSwizzle, PointPolygons,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -1693,6 +1693,7 @@ pub(super) const FEATURE_MEMBERS: &[(&str, VkFeature)] = {
|
||||
("imageView2DOn3DImage", F::ImageView2DOn3DImage),
|
||||
("separateStencilMaskRef", F::SeparateStencilMaskRef),
|
||||
("imageViewFormatSwizzle", F::ImageViewFormatSwizzle),
|
||||
("pointPolygons", F::PointPolygons),
|
||||
("fullDrawIndexUint32", F::FullDrawIndexUint32),
|
||||
("depthClipEnable", F::DepthClipEnable),
|
||||
("depthClampControl", F::DepthClampControl),
|
||||
|
||||
@@ -371,6 +371,12 @@ pub enum VkFeature {
|
||||
/// of every device that lists the extension. The lowering converts an 8-bit float to a wider
|
||||
/// one through the device's own type where it has it (`lower::arith::narrow`'s `fp8_native`).
|
||||
ShaderFloat8,
|
||||
// Appended.
|
||||
/// `pointPolygons` (a portability-subset member): `VK_POLYGON_MODE_POINT` with rasterization
|
||||
/// on (`VUID-VkPipelineRasterizationStateCreateInfo-pointPolygons-04458`), as the render
|
||||
/// encoder's `TriangleFillMode::Points` draws. Like every portability member, a device without
|
||||
/// `VK_KHR_portability_subset` has no such restriction.
|
||||
PointPolygons,
|
||||
}
|
||||
|
||||
/// A Vulkan device extension the new core can require.
|
||||
|
||||
@@ -56,10 +56,10 @@ fn stated_flags(json: &Value, member: &str) -> BTreeSet<String> {
|
||||
}
|
||||
|
||||
/// The eight features ARTIFACT 180 adds, `imageViewFormatSwizzle` (ARTIFACT 203),
|
||||
/// `provokingVertexLast` and `multiDraw`, each with its structure, its member, and the extension
|
||||
/// that exposes it
|
||||
/// `provokingVertexLast`, `multiDraw` and `pointPolygons`, each with its structure, its member,
|
||||
/// and the extension that exposes it
|
||||
/// (`None`: `VkPhysicalDeviceFeatures`, Vulkan 1.0).
|
||||
const FEATURES: [(&str, &str, VkFeature, Option<VkExtension>); 11] = [
|
||||
const FEATURES: [(&str, &str, VkFeature, Option<VkExtension>); 12] = [
|
||||
(
|
||||
"VkPhysicalDeviceFeatures",
|
||||
"fullDrawIndexUint32",
|
||||
@@ -90,6 +90,12 @@ const FEATURES: [(&str, &str, VkFeature, Option<VkExtension>); 11] = [
|
||||
VkFeature::ImageViewFormatSwizzle,
|
||||
Some(VkExtension::KhrPortabilitySubset),
|
||||
),
|
||||
(
|
||||
"VkPhysicalDevicePortabilitySubsetFeaturesKHR",
|
||||
"pointPolygons",
|
||||
VkFeature::PointPolygons,
|
||||
Some(VkExtension::KhrPortabilitySubset),
|
||||
),
|
||||
(
|
||||
"VkPhysicalDeviceDepthClipEnableFeaturesEXT",
|
||||
"depthClipEnable",
|
||||
|
||||
@@ -1478,6 +1478,9 @@ pub enum Feature {
|
||||
/// The render encoder's `MTLTriangleFillModeLines` (`polygonMode` `LINE`) on a device
|
||||
/// without `fillModeNonSolid`.
|
||||
TriangleFillLines,
|
||||
/// The render encoder's `TriangleFillMode::Points` (`polygonMode` `POINT`) on a device
|
||||
/// without `fillModeNonSolid`, or on a portability-subset device without `pointPolygons`.
|
||||
TriangleFillPoints,
|
||||
/// The render encoder's `MTLDepthClipModeClamp` (`depthClampEnable`) on a device without
|
||||
/// `depthClamp`.
|
||||
DepthClipClamp,
|
||||
|
||||
@@ -789,6 +789,12 @@ metal_enum! {
|
||||
TriangleFillMode = "MTLTriangleFillMode" {
|
||||
Fill = 0, "MTLTriangleFillModeFill";
|
||||
Lines = 1, "MTLTriangleFillModeLines";
|
||||
///
|
||||
/// Not declared by the SDK headers: the raw value 2, which Apple's GL renderer sends
|
||||
/// for `glPolygonMode(GL_POINT)`. Metal draws each triangle's vertices as points of one
|
||||
/// pixel on an Apple M3 Max and an Intel UHD Graphics 630, where a Radeon Pro 5300M
|
||||
/// fills the triangle.
|
||||
Points = 2, "MTLTriangleFillModePoints";
|
||||
}
|
||||
aliases {
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ macro_rules! metal_enum {
|
||||
(
|
||||
$(#[$meta:meta])*
|
||||
$name:ident = $metal:literal {
|
||||
$($variant:ident = $value:literal, $mname:literal;)*
|
||||
$($(#[$vmeta:meta])* $variant:ident = $value:literal, $mname:literal;)*
|
||||
}
|
||||
aliases {
|
||||
$($alias:literal => $target:ident;)*
|
||||
@@ -46,6 +46,7 @@ macro_rules! metal_enum {
|
||||
pub enum $name {
|
||||
$(
|
||||
#[doc = concat!("`", $mname, "`.")]
|
||||
$(#[$vmeta])*
|
||||
$variant = $value,
|
||||
)*
|
||||
}
|
||||
|
||||
@@ -360,6 +360,14 @@ fn require(profile: &DeviceProfile, feature: VkFeature, what: Feature) -> Result
|
||||
/// `VkPipelineRasterizationStateCreateInfo::polygonMode`. Both APIs apply the mode to triangles
|
||||
/// only. `Lines` rasterizes each triangle's edges as lines (`LINE`, with `lineWidth` 1) and needs
|
||||
/// `fillModeNonSolid` (`VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507`).
|
||||
/// `Points`, the raw value 2 that no SDK header declares, rasterizes each triangle's vertices as
|
||||
/// points (`POINT`), as Metal draws them on an Apple M3 Max and an Intel UHD Graphics 630 (the
|
||||
/// M3 Max culls the triangle first, as Vulkan does): it needs `fillModeNonSolid`, and on a
|
||||
/// portability-subset device `pointPolygons`
|
||||
/// (`VUID-VkPipelineRasterizationStateCreateInfo-pointPolygons-04458`). The M3 Max draws each
|
||||
/// point one pixel wide whatever `[[point_size]]` the vertex function writes; Vulkan sizes it by
|
||||
/// the `PointSize` the last pre-rasterization stage writes where the device's
|
||||
/// `polygonModePointSize` is set.
|
||||
pub fn polygon_mode(
|
||||
mode: TriangleFillMode,
|
||||
profile: &DeviceProfile,
|
||||
@@ -374,6 +382,22 @@ pub fn polygon_mode(
|
||||
)?;
|
||||
vk::PolygonMode::LINE
|
||||
}
|
||||
TriangleFillMode::Points => {
|
||||
require(
|
||||
profile,
|
||||
VkFeature::FillModeNonSolid,
|
||||
Feature::TriangleFillPoints,
|
||||
)?;
|
||||
let polygons = VkFeature::PointPolygons;
|
||||
if profile.fields().enabled.portability_withholds(polygons) {
|
||||
return Err(Unsupported::needs(
|
||||
Feature::TriangleFillPoints,
|
||||
Capability::Feature(polygons),
|
||||
)
|
||||
.into());
|
||||
}
|
||||
vk::PolygonMode::POINT
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -630,6 +654,28 @@ mod tests {
|
||||
polygon_mode(TriangleFillMode::Lines, lavapipe.profile()),
|
||||
Ok(vk::PolygonMode::LINE)
|
||||
);
|
||||
// Points need `fillModeNonSolid` too, and on MoltenVK, whose portability subset withholds
|
||||
// `pointPolygons`, that member: lavapipe lists no portability subset.
|
||||
assert_eq!(
|
||||
polygon_mode(TriangleFillMode::Points, floor.profile()),
|
||||
Err(needs(
|
||||
Feature::TriangleFillPoints,
|
||||
VkFeature::FillModeNonSolid
|
||||
))
|
||||
);
|
||||
assert_eq!(
|
||||
polygon_mode(TriangleFillMode::Points, lavapipe.profile()),
|
||||
Ok(vk::PolygonMode::POINT)
|
||||
);
|
||||
let moltenvk = committed("moltenvk-m3");
|
||||
assert_eq!(
|
||||
polygon_mode(TriangleFillMode::Lines, moltenvk.profile()),
|
||||
Ok(vk::PolygonMode::LINE)
|
||||
);
|
||||
assert_eq!(
|
||||
polygon_mode(TriangleFillMode::Points, moltenvk.profile()),
|
||||
Err(needs(Feature::TriangleFillPoints, VkFeature::PointPolygons))
|
||||
);
|
||||
assert_eq!(
|
||||
depth_clamp_enable(DepthClipMode::Clip, floor.profile()),
|
||||
Ok(false)
|
||||
|
||||
@@ -5919,6 +5919,7 @@ macro-member metal2vulkan-runtime::Degradation::TessellationTriangleOrder Tessel
|
||||
macro-member metal2vulkan-runtime::Degradation::TessellationWinding TessellationWinding = "tessellation-winding";
|
||||
macro-member metal2vulkan-runtime::Degradation::TextureBufferFillLeftover TextureBufferFillLeftover = "texture-buffer-fill-leftover", Precision,
|
||||
macro-member metal2vulkan-runtime::Degradation::TileDispatchScratch TileDispatchScratch = "tile-dispatch-scratch", Performance,
|
||||
macro-member metal2vulkan-runtime::Degradation::TrianglePointSize TrianglePointSize = "triangle-point-size", Precision,
|
||||
macro-member metal2vulkan-runtime::Degradation::TwoPlaneBufferBlit TwoPlaneBufferBlit = "two-plane-buffer-blit", Precision,
|
||||
macro-member metal2vulkan-runtime::Degradation::TwoPlaneBufferBlitOrder TwoPlaneBufferBlitOrder = "two-plane-buffer-blit-order", Precision,
|
||||
macro-member metal2vulkan-runtime::Degradation::TwoPlaneTextureCopy TwoPlaneTextureCopy = "two-plane-texture-copy", Precision,
|
||||
@@ -6722,6 +6723,7 @@ macro-member metal2vulkan::metal::TextureUsage::aliases aliases
|
||||
macro-member metal2vulkan::metal::TextureUsage::dropped dropped
|
||||
macro-member metal2vulkan::metal::TriangleFillMode::Fill Fill = 0, "MTLTriangleFillModeFill";
|
||||
macro-member metal2vulkan::metal::TriangleFillMode::Lines Lines = 1, "MTLTriangleFillModeLines";
|
||||
macro-member metal2vulkan::metal::TriangleFillMode::Points Points = 2, "MTLTriangleFillModePoints";
|
||||
macro-member metal2vulkan::metal::TriangleFillMode::TriangleFillMode TriangleFillMode = "MTLTriangleFillMode"
|
||||
macro-member metal2vulkan::metal::TriangleFillMode::aliases aliases
|
||||
macro-member metal2vulkan::metal::VertexFormat::Char Char = 46, "MTLVertexFormatChar";
|
||||
@@ -7871,8 +7873,8 @@ macro-template metal2vulkan-air::exposures! ($($exposure:expr => [$($feature:ide
|
||||
macro-template metal2vulkan-air::flag_set! ( $(#[$doc:meta])* $name:ident { $($(#[$fdoc:meta])* $flag:ident = $bit:expr),* $(,)? } $(#[$all:meta])* ALL ) => { $(#[$doc])* #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] pub struct $name(u8); impl $name { pub const NONE: $name = $name(0); $($(#[$fdoc])* pub const $flag: $name = $name($bit);)* $(#[$all])* pub const ALL: &'static [($name, &'static str)] = &[$(($name::$flag, stringify!($flag))),*]; pub const fn union(self, other: $name) -> $name { $name(self.0 | other.0) } pub const fn contains(self, other: $name) -> bool { self.0 & other.0 == other.0 } #[cfg(test)] pub const fn bits(self) -> u8 { self.0 } } };
|
||||
macro-template metal2vulkan-air::id_type! ($(#[$doc:meta])* $name:ident) => { $(#[$doc])* #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct $name(pub u32); impl $name { pub const fn new(index: u32) -> $name { $name(index) } pub const fn index(self) -> usize { self.0 as usize } } };
|
||||
macro-template metal2vulkan-air::ir_id! ($(#[$doc:meta])* $name:ident, $prefix:literal) => { $(#[$doc])* #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct $name(u32); impl $name { pub const fn new(index: u32) -> $name { $name(index) } pub const fn raw(self) -> u32 { self.0 } } impl Idx for $name { fn from_index(index: usize) -> Option<$name> { u32::try_from(index).ok().map($name::new) } fn index(self) -> usize { self.raw() as usize } } impl fmt::Debug for $name { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, concat!($prefix, "{}"), self.0) } } };
|
||||
macro-template metal2vulkan-air::metal_enum! ( $(#[$meta:meta])* $name:ident = $metal:literal { $($(#[$vmeta:meta])* $variant:ident = $value:literal, $mname:literal;)* } aliases { $($alias:literal => $target:ident;)* } ) => { $(#[$meta])* #[repr(u32)] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum $name { $( #[doc = concat!("`", $mname, "`.")] $(#[$vmeta])* $variant = $value, )* } impl $name { pub const METAL_NAME: &'static str = $metal; pub const ALL: &'static [$name] = &[$($name::$variant),*]; const ALIASES: &'static [(&'static str, $name)] = &[$(($alias, $name::$target)),*]; pub const fn as_raw(self) -> u32 { self as u32 } pub const fn name(self) -> &'static str { match self { $($name::$variant => $mname,)* } } pub fn from_name(name: &str) -> Option<$name> { Self::ALL .iter() .copied() .find(|v| v.name() == name) .or_else(|| Self::ALIASES.iter().find(|(n, _)| *n == name).map(|(_, v)| *v)) } } impl From<$name> for u32 { fn from(value: $name) -> u32 { value.as_raw() } } impl TryFrom<u32> for $name { type Error = $crate::error::Error; fn try_from(value: u32) -> Result<$name, $crate::error::Error> { match value { $($value => Ok($name::$variant),)* _ => Err($crate::metal::unknown($metal, value)), } } } };
|
||||
macro-template metal2vulkan-air::metal_enum! ( $(#[$meta:meta])* $name:ident = $metal:literal { $($variant:ident = $value:literal, $mname:literal;)* } aliases { $($alias:literal => $target:ident;)* } ) => { $(#[$meta])* #[repr(u32)] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum $name { $( #[doc = concat!("`", $mname, "`.")] $variant = $value, )* } impl $name { pub const METAL_NAME: &'static str = $metal; pub const ALL: &'static [$name] = &[$($name::$variant),*]; const ALIASES: &'static [(&'static str, $name)] = &[$(($alias, $name::$target)),*]; pub const fn as_raw(self) -> u32 { self as u32 } pub const fn name(self) -> &'static str { match self { $($name::$variant => $mname,)* } } pub fn from_name(name: &str) -> Option<$name> { Self::ALL .iter() .copied() .find(|v| v.name() == name) .or_else(|| Self::ALIASES.iter().find(|(n, _)| *n == name).map(|(_, v)| *v)) } } impl From<$name> for u32 { fn from(value: $name) -> u32 { value.as_raw() } } impl TryFrom<u32> for $name { type Error = $crate::error::Error; fn try_from(value: u32) -> Result<$name, $crate::error::Error> { match value { $($value => Ok($name::$variant),)* _ => Err($crate::error::Error::InvalidRequest( $crate::error::RequestError::UnknownEnumValue { ty: $metal, value }, )), } } } };
|
||||
macro-template metal2vulkan-air::metal_enum! ( $(#[$meta:meta])* $name:ident = $metal:literal { $($variant:ident = $value:literal, $mname:literal;)* } aliases { $($alias:literal => $target:ident;)* } ) => { $(#[$meta])* #[repr(u32)] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum $name { $( #[doc = concat!("`", $mname, "`.")] $variant = $value, )* } impl $name { pub const METAL_NAME: &'static str = $metal; pub const ALL: &'static [$name] = &[$($name::$variant),*]; const ALIASES: &'static [(&'static str, $name)] = &[$(($alias, $name::$target)),*]; pub const fn as_raw(self) -> u32 { self as u32 } pub const fn name(self) -> &'static str { match self { $($name::$variant => $mname,)* } } pub fn from_name(name: &str) -> Option<$name> { Self::ALL .iter() .copied() .find(|v| v.name() == name) .or_else(|| Self::ALIASES.iter().find(|(n, _)| *n == name).map(|(_, v)| *v)) } } impl From<$name> for u32 { fn from(value: $name) -> u32 { value.as_raw() } } impl TryFrom<u32> for $name { type Error = $crate::error::Error; fn try_from(value: u32) -> Result<$name, $crate::error::Error> { match value { $($value => Ok($name::$variant),)* _ => Err($crate::metal::unknown($metal, value)), } } } };
|
||||
macro-template metal2vulkan-air::metal_flags! ( $(#[$meta:meta])* $name:ident = $metal:literal { $($konst:ident = $value:literal, $mname:literal;)* } aliases { $($alias:literal => $target:ident;)* } dropped { $($dropped:literal;)* } ) => { $(#[$meta])* #[repr(transparent)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(try_from = "u32", into = "u32"))] pub struct $name(u32); impl $name { $( #[doc = concat!("`", $mname, "`.")] pub const $konst: $name = $name($value); )* pub const METAL_NAME: &'static str = $metal; pub const KNOWN: &'static [($name, &'static str)] = &[$(($name::$konst, $mname)),*]; const ALIASES: &'static [(&'static str, $name)] = &[$(($alias, $name::$target)),*]; pub const ALL_KNOWN: $name = $name(0 $(| $value)*); pub const DROPPED: u32 = 0 $(| $dropped)*; pub const fn empty() -> $name { $name(0) } pub const fn as_raw(self) -> u32 { self.0 } pub const fn is_empty(self) -> bool { self.0 == 0 } pub const fn without_dropped(self) -> $name { $name(self.0 & !Self::DROPPED) } pub const fn contains(self, other: $name) -> bool { self.0 & other.0 == other.0 } pub const fn intersects(self, other: $name) -> bool { self.0 & other.0 != 0 } pub const fn union(self, other: $name) -> $name { $name(self.0 | other.0) } pub const fn intersection(self, other: $name) -> $name { $name(self.0 & other.0) } pub const fn difference(self, other: $name) -> $name { $name(self.0 & !other.0) } pub fn from_name(name: &str) -> Option<$name> { Self::KNOWN .iter() .find(|(_, n)| *n == name) .map(|(v, _)| *v) .or_else(|| Self::ALIASES.iter().find(|(n, _)| *n == name).map(|(_, v)| *v)) } } impl From<$name> for u32 { fn from(value: $name) -> u32 { value.as_raw() } } impl TryFrom<u32> for $name { type Error = $crate::error::Error; fn try_from(value: u32) -> Result<$name, $crate::error::Error> { if value & !($name::ALL_KNOWN.0 | $name::DROPPED) == 0 { Ok($name(value)) } else { Err($crate::metal::unknown($metal, value)) } } } impl ::std::ops::BitOr for $name { type Output = $name; fn bitor(self, rhs: $name) -> $name { self.union(rhs) } } impl ::std::ops::BitOrAssign for $name { fn bitor_assign(&mut self, rhs: $name) { *self = self.union(rhs); } } impl ::std::ops::BitAnd for $name { type Output = $name; fn bitand(self, rhs: $name) -> $name { self.intersection(rhs) } } impl ::std::ops::BitAndAssign for $name { fn bitand_assign(&mut self, rhs: $name) { *self = self.intersection(rhs); } } impl ::std::fmt::Debug for $name { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { if let Some((_, name)) = Self::KNOWN.iter().find(|(v, _)| v == self) { return f.write_str(name); } let mut rest = self.0; let mut first = true; for (v, n) in Self::KNOWN { if v.0.count_ones() == 1 && rest & v.0 != 0 { if !first { f.write_str(" | ")?; } f.write_str(n)?; rest &= !v.0; first = false; } } if rest != 0 || first { if !first { f.write_str(" | ")?; } write!(f, "{:#x}", rest)?; } Ok(()) } } };
|
||||
macro-template metal2vulkan-air::vk_bit! ( $(#[$meta:meta])* $name:ident($raw:ty) = $vk:literal in $flags:ident { $($konst:ident = $value:literal, $vkname:literal;)* } aliases { $($alias:literal => $target:ident;)* } ) => { $(#[$meta])* #[repr(transparent)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(try_from = "u32", into = "u32"))] pub struct $name($raw); impl $name { $( #[doc = concat!("`", $vkname, "`.")] pub const $konst: $name = $name($value); )* pub const VK_NAME: &'static str = $vk; pub const KNOWN: &'static [$name] = &[$($name::$konst),*]; const NAMES: &'static [($name, &'static str)] = &[$(($name::$konst, $vkname)),*]; const ALIASES: &'static [(&'static str, $name)] = &[$(($alias, $name::$target)),*]; pub const fn from_raw(raw: $raw) -> Option<$name> { let mut i = 0; while i < Self::KNOWN.len() { if Self::KNOWN[i].0 == raw { return Some(Self::KNOWN[i]); } i += 1; } None } pub const fn from_flags(flags: $flags) -> Option<$name> { Self::from_raw(flags.as_raw()) } pub const fn as_raw(self) -> $raw { self.0 } pub const fn flags(self) -> $flags { $flags::from_raw(self.0) } pub fn name(self) -> &'static str { Self::NAMES .iter() .find(|(v, _)| *v == self) .map(|(_, n)| *n) .expect("a single-bit value is always a named bit") } pub fn from_name(name: &str) -> Option<$name> { Self::NAMES .iter() .find(|(_, n)| *n == name) .map(|(v, _)| *v) .or_else(|| Self::ALIASES.iter().find(|(n, _)| *n == name).map(|(_, v)| *v)) } } impl ::std::convert::TryFrom<$raw> for $name { type Error = $raw; fn try_from(raw: $raw) -> Result<$name, $raw> { $name::from_raw(raw).ok_or(raw) } } impl From<$name> for $raw { fn from(bit: $name) -> $raw { bit.0 } } impl From<$name> for $flags { fn from(bit: $name) -> $flags { bit.flags() } } impl ::std::fmt::Debug for $name { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { f.write_str(self.name()) } } };
|
||||
macro-template metal2vulkan-air::vk_enum! ( $(#[$meta:meta])* $name:ident($raw:ty) = $vk:literal { $($konst:ident = $value:literal, $vkname:literal;)* } aliases { $($alias:literal => $target:ident;)* } ) => { $(#[$meta])* #[repr(transparent)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(transparent))] pub struct $name($raw); impl $name { $( #[doc = concat!("`", $vkname, "`.")] pub const $konst: $name = $name($value); )* pub const VK_NAME: &'static str = $vk; pub const KNOWN: &'static [$name] = &[$($name::$konst),*]; const NAMES: &'static [($name, &'static str)] = &[$(($name::$konst, $vkname)),*]; const ALIASES: &'static [(&'static str, $name)] = &[$(($alias, $name::$target)),*]; pub const fn from_raw(raw: $raw) -> $name { $name(raw) } pub const fn as_raw(self) -> $raw { self.0 } pub fn name(self) -> Option<&'static str> { Self::NAMES.iter().find(|(v, _)| *v == self).map(|(_, n)| *n) } pub fn is_known(self) -> bool { self.name().is_some() } pub fn from_name(name: &str) -> Option<$name> { Self::NAMES .iter() .find(|(_, n)| *n == name) .map(|(v, _)| *v) .or_else(|| Self::ALIASES.iter().find(|(n, _)| *n == name).map(|(_, v)| *v)) } } impl ::std::fmt::Debug for $name { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { match self.name() { Some(name) => f.write_str(name), None => write!(f, "{}({})", $vk, self.0), } } } };
|
||||
@@ -7883,8 +7885,8 @@ macro-template metal2vulkan-runtime::exposures! ($($exposure:expr => [$($feature
|
||||
macro-template metal2vulkan-runtime::flag_set! ( $(#[$doc:meta])* $name:ident { $($(#[$fdoc:meta])* $flag:ident = $bit:expr),* $(,)? } $(#[$all:meta])* ALL ) => { $(#[$doc])* #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] pub struct $name(u8); impl $name { pub const NONE: $name = $name(0); $($(#[$fdoc])* pub const $flag: $name = $name($bit);)* $(#[$all])* pub const ALL: &'static [($name, &'static str)] = &[$(($name::$flag, stringify!($flag))),*]; pub const fn union(self, other: $name) -> $name { $name(self.0 | other.0) } pub const fn contains(self, other: $name) -> bool { self.0 & other.0 == other.0 } #[cfg(test)] pub const fn bits(self) -> u8 { self.0 } } };
|
||||
macro-template metal2vulkan-runtime::id_type! ($(#[$doc:meta])* $name:ident) => { $(#[$doc])* #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct $name(pub u32); impl $name { pub const fn new(index: u32) -> $name { $name(index) } pub const fn index(self) -> usize { self.0 as usize } } };
|
||||
macro-template metal2vulkan-runtime::ir_id! ($(#[$doc:meta])* $name:ident, $prefix:literal) => { $(#[$doc])* #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct $name(u32); impl $name { pub const fn new(index: u32) -> $name { $name(index) } pub const fn raw(self) -> u32 { self.0 } } impl Idx for $name { fn from_index(index: usize) -> Option<$name> { u32::try_from(index).ok().map($name::new) } fn index(self) -> usize { self.raw() as usize } } impl fmt::Debug for $name { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, concat!($prefix, "{}"), self.0) } } };
|
||||
macro-template metal2vulkan-runtime::metal_enum! ( $(#[$meta:meta])* $name:ident = $metal:literal { $($(#[$vmeta:meta])* $variant:ident = $value:literal, $mname:literal;)* } aliases { $($alias:literal => $target:ident;)* } ) => { $(#[$meta])* #[repr(u32)] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum $name { $( #[doc = concat!("`", $mname, "`.")] $(#[$vmeta])* $variant = $value, )* } impl $name { pub const METAL_NAME: &'static str = $metal; pub const ALL: &'static [$name] = &[$($name::$variant),*]; const ALIASES: &'static [(&'static str, $name)] = &[$(($alias, $name::$target)),*]; pub const fn as_raw(self) -> u32 { self as u32 } pub const fn name(self) -> &'static str { match self { $($name::$variant => $mname,)* } } pub fn from_name(name: &str) -> Option<$name> { Self::ALL .iter() .copied() .find(|v| v.name() == name) .or_else(|| Self::ALIASES.iter().find(|(n, _)| *n == name).map(|(_, v)| *v)) } } impl From<$name> for u32 { fn from(value: $name) -> u32 { value.as_raw() } } impl TryFrom<u32> for $name { type Error = $crate::error::Error; fn try_from(value: u32) -> Result<$name, $crate::error::Error> { match value { $($value => Ok($name::$variant),)* _ => Err($crate::metal::unknown($metal, value)), } } } };
|
||||
macro-template metal2vulkan-runtime::metal_enum! ( $(#[$meta:meta])* $name:ident = $metal:literal { $($variant:ident = $value:literal, $mname:literal;)* } aliases { $($alias:literal => $target:ident;)* } ) => { $(#[$meta])* #[repr(u32)] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum $name { $( #[doc = concat!("`", $mname, "`.")] $variant = $value, )* } impl $name { pub const METAL_NAME: &'static str = $metal; pub const ALL: &'static [$name] = &[$($name::$variant),*]; const ALIASES: &'static [(&'static str, $name)] = &[$(($alias, $name::$target)),*]; pub const fn as_raw(self) -> u32 { self as u32 } pub const fn name(self) -> &'static str { match self { $($name::$variant => $mname,)* } } pub fn from_name(name: &str) -> Option<$name> { Self::ALL .iter() .copied() .find(|v| v.name() == name) .or_else(|| Self::ALIASES.iter().find(|(n, _)| *n == name).map(|(_, v)| *v)) } } impl From<$name> for u32 { fn from(value: $name) -> u32 { value.as_raw() } } impl TryFrom<u32> for $name { type Error = $crate::error::Error; fn try_from(value: u32) -> Result<$name, $crate::error::Error> { match value { $($value => Ok($name::$variant),)* _ => Err($crate::error::Error::InvalidRequest( $crate::error::RequestError::UnknownEnumValue { ty: $metal, value }, )), } } } };
|
||||
macro-template metal2vulkan-runtime::metal_enum! ( $(#[$meta:meta])* $name:ident = $metal:literal { $($variant:ident = $value:literal, $mname:literal;)* } aliases { $($alias:literal => $target:ident;)* } ) => { $(#[$meta])* #[repr(u32)] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum $name { $( #[doc = concat!("`", $mname, "`.")] $variant = $value, )* } impl $name { pub const METAL_NAME: &'static str = $metal; pub const ALL: &'static [$name] = &[$($name::$variant),*]; const ALIASES: &'static [(&'static str, $name)] = &[$(($alias, $name::$target)),*]; pub const fn as_raw(self) -> u32 { self as u32 } pub const fn name(self) -> &'static str { match self { $($name::$variant => $mname,)* } } pub fn from_name(name: &str) -> Option<$name> { Self::ALL .iter() .copied() .find(|v| v.name() == name) .or_else(|| Self::ALIASES.iter().find(|(n, _)| *n == name).map(|(_, v)| *v)) } } impl From<$name> for u32 { fn from(value: $name) -> u32 { value.as_raw() } } impl TryFrom<u32> for $name { type Error = $crate::error::Error; fn try_from(value: u32) -> Result<$name, $crate::error::Error> { match value { $($value => Ok($name::$variant),)* _ => Err($crate::metal::unknown($metal, value)), } } } };
|
||||
macro-template metal2vulkan-runtime::metal_flags! ( $(#[$meta:meta])* $name:ident = $metal:literal { $($konst:ident = $value:literal, $mname:literal;)* } aliases { $($alias:literal => $target:ident;)* } dropped { $($dropped:literal;)* } ) => { $(#[$meta])* #[repr(transparent)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(try_from = "u32", into = "u32"))] pub struct $name(u32); impl $name { $( #[doc = concat!("`", $mname, "`.")] pub const $konst: $name = $name($value); )* pub const METAL_NAME: &'static str = $metal; pub const KNOWN: &'static [($name, &'static str)] = &[$(($name::$konst, $mname)),*]; const ALIASES: &'static [(&'static str, $name)] = &[$(($alias, $name::$target)),*]; pub const ALL_KNOWN: $name = $name(0 $(| $value)*); pub const DROPPED: u32 = 0 $(| $dropped)*; pub const fn empty() -> $name { $name(0) } pub const fn as_raw(self) -> u32 { self.0 } pub const fn is_empty(self) -> bool { self.0 == 0 } pub const fn without_dropped(self) -> $name { $name(self.0 & !Self::DROPPED) } pub const fn contains(self, other: $name) -> bool { self.0 & other.0 == other.0 } pub const fn intersects(self, other: $name) -> bool { self.0 & other.0 != 0 } pub const fn union(self, other: $name) -> $name { $name(self.0 | other.0) } pub const fn intersection(self, other: $name) -> $name { $name(self.0 & other.0) } pub const fn difference(self, other: $name) -> $name { $name(self.0 & !other.0) } pub fn from_name(name: &str) -> Option<$name> { Self::KNOWN .iter() .find(|(_, n)| *n == name) .map(|(v, _)| *v) .or_else(|| Self::ALIASES.iter().find(|(n, _)| *n == name).map(|(_, v)| *v)) } } impl From<$name> for u32 { fn from(value: $name) -> u32 { value.as_raw() } } impl TryFrom<u32> for $name { type Error = $crate::error::Error; fn try_from(value: u32) -> Result<$name, $crate::error::Error> { if value & !($name::ALL_KNOWN.0 | $name::DROPPED) == 0 { Ok($name(value)) } else { Err($crate::metal::unknown($metal, value)) } } } impl ::std::ops::BitOr for $name { type Output = $name; fn bitor(self, rhs: $name) -> $name { self.union(rhs) } } impl ::std::ops::BitOrAssign for $name { fn bitor_assign(&mut self, rhs: $name) { *self = self.union(rhs); } } impl ::std::ops::BitAnd for $name { type Output = $name; fn bitand(self, rhs: $name) -> $name { self.intersection(rhs) } } impl ::std::ops::BitAndAssign for $name { fn bitand_assign(&mut self, rhs: $name) { *self = self.intersection(rhs); } } impl ::std::fmt::Debug for $name { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { if let Some((_, name)) = Self::KNOWN.iter().find(|(v, _)| v == self) { return f.write_str(name); } let mut rest = self.0; let mut first = true; for (v, n) in Self::KNOWN { if v.0.count_ones() == 1 && rest & v.0 != 0 { if !first { f.write_str(" | ")?; } f.write_str(n)?; rest &= !v.0; first = false; } } if rest != 0 || first { if !first { f.write_str(" | ")?; } write!(f, "{:#x}", rest)?; } Ok(()) } } };
|
||||
macro-template metal2vulkan-runtime::vk_bit! ( $(#[$meta:meta])* $name:ident($raw:ty) = $vk:literal in $flags:ident { $($konst:ident = $value:literal, $vkname:literal;)* } aliases { $($alias:literal => $target:ident;)* } ) => { $(#[$meta])* #[repr(transparent)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(try_from = "u32", into = "u32"))] pub struct $name($raw); impl $name { $( #[doc = concat!("`", $vkname, "`.")] pub const $konst: $name = $name($value); )* pub const VK_NAME: &'static str = $vk; pub const KNOWN: &'static [$name] = &[$($name::$konst),*]; const NAMES: &'static [($name, &'static str)] = &[$(($name::$konst, $vkname)),*]; const ALIASES: &'static [(&'static str, $name)] = &[$(($alias, $name::$target)),*]; pub const fn from_raw(raw: $raw) -> Option<$name> { let mut i = 0; while i < Self::KNOWN.len() { if Self::KNOWN[i].0 == raw { return Some(Self::KNOWN[i]); } i += 1; } None } pub const fn from_flags(flags: $flags) -> Option<$name> { Self::from_raw(flags.as_raw()) } pub const fn as_raw(self) -> $raw { self.0 } pub const fn flags(self) -> $flags { $flags::from_raw(self.0) } pub fn name(self) -> &'static str { Self::NAMES .iter() .find(|(v, _)| *v == self) .map(|(_, n)| *n) .expect("a single-bit value is always a named bit") } pub fn from_name(name: &str) -> Option<$name> { Self::NAMES .iter() .find(|(_, n)| *n == name) .map(|(v, _)| *v) .or_else(|| Self::ALIASES.iter().find(|(n, _)| *n == name).map(|(_, v)| *v)) } } impl ::std::convert::TryFrom<$raw> for $name { type Error = $raw; fn try_from(raw: $raw) -> Result<$name, $raw> { $name::from_raw(raw).ok_or(raw) } } impl From<$name> for $raw { fn from(bit: $name) -> $raw { bit.0 } } impl From<$name> for $flags { fn from(bit: $name) -> $flags { bit.flags() } } impl ::std::fmt::Debug for $name { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { f.write_str(self.name()) } } };
|
||||
macro-template metal2vulkan-runtime::vk_enum! ( $(#[$meta:meta])* $name:ident($raw:ty) = $vk:literal { $($konst:ident = $value:literal, $vkname:literal;)* } aliases { $($alias:literal => $target:ident;)* } ) => { $(#[$meta])* #[repr(transparent)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(transparent))] pub struct $name($raw); impl $name { $( #[doc = concat!("`", $vkname, "`.")] pub const $konst: $name = $name($value); )* pub const VK_NAME: &'static str = $vk; pub const KNOWN: &'static [$name] = &[$($name::$konst),*]; const NAMES: &'static [($name, &'static str)] = &[$(($name::$konst, $vkname)),*]; const ALIASES: &'static [(&'static str, $name)] = &[$(($alias, $name::$target)),*]; pub const fn from_raw(raw: $raw) -> $name { $name(raw) } pub const fn as_raw(self) -> $raw { self.0 } pub fn name(self) -> Option<&'static str> { Self::NAMES.iter().find(|(v, _)| *v == self).map(|(_, n)| *n) } pub fn is_known(self) -> bool { self.name().is_some() } pub fn from_name(name: &str) -> Option<$name> { Self::NAMES .iter() .find(|(_, n)| *n == name) .map(|(v, _)| *v) .or_else(|| Self::ALIASES.iter().find(|(n, _)| *n == name).map(|(_, v)| *v)) } } impl ::std::fmt::Debug for $name { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { match self.name() { Some(name) => f.write_str(name), None => write!(f, "{}({})", $vk, self.0), } } } };
|
||||
@@ -7893,8 +7895,8 @@ macro-template metal2vulkan::exposures! ($($exposure:expr => [$($feature:ident),
|
||||
macro-template metal2vulkan::flag_set! ( $(#[$doc:meta])* $name:ident { $($(#[$fdoc:meta])* $flag:ident = $bit:expr),* $(,)? } $(#[$all:meta])* ALL ) => { $(#[$doc])* #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] pub struct $name(u8); impl $name { pub const NONE: $name = $name(0); $($(#[$fdoc])* pub const $flag: $name = $name($bit);)* $(#[$all])* pub const ALL: &'static [($name, &'static str)] = &[$(($name::$flag, stringify!($flag))),*]; pub const fn union(self, other: $name) -> $name { $name(self.0 | other.0) } pub const fn contains(self, other: $name) -> bool { self.0 & other.0 == other.0 } #[cfg(test)] pub const fn bits(self) -> u8 { self.0 } } };
|
||||
macro-template metal2vulkan::id_type! ($(#[$doc:meta])* $name:ident) => { $(#[$doc])* #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct $name(pub u32); impl $name { pub const fn new(index: u32) -> $name { $name(index) } pub const fn index(self) -> usize { self.0 as usize } } };
|
||||
macro-template metal2vulkan::ir_id! ($(#[$doc:meta])* $name:ident, $prefix:literal) => { $(#[$doc])* #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct $name(u32); impl $name { pub const fn new(index: u32) -> $name { $name(index) } pub const fn raw(self) -> u32 { self.0 } } impl Idx for $name { fn from_index(index: usize) -> Option<$name> { u32::try_from(index).ok().map($name::new) } fn index(self) -> usize { self.raw() as usize } } impl fmt::Debug for $name { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, concat!($prefix, "{}"), self.0) } } };
|
||||
macro-template metal2vulkan::metal_enum! ( $(#[$meta:meta])* $name:ident = $metal:literal { $($(#[$vmeta:meta])* $variant:ident = $value:literal, $mname:literal;)* } aliases { $($alias:literal => $target:ident;)* } ) => { $(#[$meta])* #[repr(u32)] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum $name { $( #[doc = concat!("`", $mname, "`.")] $(#[$vmeta])* $variant = $value, )* } impl $name { pub const METAL_NAME: &'static str = $metal; pub const ALL: &'static [$name] = &[$($name::$variant),*]; const ALIASES: &'static [(&'static str, $name)] = &[$(($alias, $name::$target)),*]; pub const fn as_raw(self) -> u32 { self as u32 } pub const fn name(self) -> &'static str { match self { $($name::$variant => $mname,)* } } pub fn from_name(name: &str) -> Option<$name> { Self::ALL .iter() .copied() .find(|v| v.name() == name) .or_else(|| Self::ALIASES.iter().find(|(n, _)| *n == name).map(|(_, v)| *v)) } } impl From<$name> for u32 { fn from(value: $name) -> u32 { value.as_raw() } } impl TryFrom<u32> for $name { type Error = $crate::error::Error; fn try_from(value: u32) -> Result<$name, $crate::error::Error> { match value { $($value => Ok($name::$variant),)* _ => Err($crate::metal::unknown($metal, value)), } } } };
|
||||
macro-template metal2vulkan::metal_enum! ( $(#[$meta:meta])* $name:ident = $metal:literal { $($variant:ident = $value:literal, $mname:literal;)* } aliases { $($alias:literal => $target:ident;)* } ) => { $(#[$meta])* #[repr(u32)] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum $name { $( #[doc = concat!("`", $mname, "`.")] $variant = $value, )* } impl $name { pub const METAL_NAME: &'static str = $metal; pub const ALL: &'static [$name] = &[$($name::$variant),*]; const ALIASES: &'static [(&'static str, $name)] = &[$(($alias, $name::$target)),*]; pub const fn as_raw(self) -> u32 { self as u32 } pub const fn name(self) -> &'static str { match self { $($name::$variant => $mname,)* } } pub fn from_name(name: &str) -> Option<$name> { Self::ALL .iter() .copied() .find(|v| v.name() == name) .or_else(|| Self::ALIASES.iter().find(|(n, _)| *n == name).map(|(_, v)| *v)) } } impl From<$name> for u32 { fn from(value: $name) -> u32 { value.as_raw() } } impl TryFrom<u32> for $name { type Error = $crate::error::Error; fn try_from(value: u32) -> Result<$name, $crate::error::Error> { match value { $($value => Ok($name::$variant),)* _ => Err($crate::error::Error::InvalidRequest( $crate::error::RequestError::UnknownEnumValue { ty: $metal, value }, )), } } } };
|
||||
macro-template metal2vulkan::metal_enum! ( $(#[$meta:meta])* $name:ident = $metal:literal { $($variant:ident = $value:literal, $mname:literal;)* } aliases { $($alias:literal => $target:ident;)* } ) => { $(#[$meta])* #[repr(u32)] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum $name { $( #[doc = concat!("`", $mname, "`.")] $variant = $value, )* } impl $name { pub const METAL_NAME: &'static str = $metal; pub const ALL: &'static [$name] = &[$($name::$variant),*]; const ALIASES: &'static [(&'static str, $name)] = &[$(($alias, $name::$target)),*]; pub const fn as_raw(self) -> u32 { self as u32 } pub const fn name(self) -> &'static str { match self { $($name::$variant => $mname,)* } } pub fn from_name(name: &str) -> Option<$name> { Self::ALL .iter() .copied() .find(|v| v.name() == name) .or_else(|| Self::ALIASES.iter().find(|(n, _)| *n == name).map(|(_, v)| *v)) } } impl From<$name> for u32 { fn from(value: $name) -> u32 { value.as_raw() } } impl TryFrom<u32> for $name { type Error = $crate::error::Error; fn try_from(value: u32) -> Result<$name, $crate::error::Error> { match value { $($value => Ok($name::$variant),)* _ => Err($crate::metal::unknown($metal, value)), } } } };
|
||||
macro-template metal2vulkan::metal_flags! ( $(#[$meta:meta])* $name:ident = $metal:literal { $($konst:ident = $value:literal, $mname:literal;)* } aliases { $($alias:literal => $target:ident;)* } dropped { $($dropped:literal;)* } ) => { $(#[$meta])* #[repr(transparent)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(try_from = "u32", into = "u32"))] pub struct $name(u32); impl $name { $( #[doc = concat!("`", $mname, "`.")] pub const $konst: $name = $name($value); )* pub const METAL_NAME: &'static str = $metal; pub const KNOWN: &'static [($name, &'static str)] = &[$(($name::$konst, $mname)),*]; const ALIASES: &'static [(&'static str, $name)] = &[$(($alias, $name::$target)),*]; pub const ALL_KNOWN: $name = $name(0 $(| $value)*); pub const DROPPED: u32 = 0 $(| $dropped)*; pub const fn empty() -> $name { $name(0) } pub const fn as_raw(self) -> u32 { self.0 } pub const fn is_empty(self) -> bool { self.0 == 0 } pub const fn without_dropped(self) -> $name { $name(self.0 & !Self::DROPPED) } pub const fn contains(self, other: $name) -> bool { self.0 & other.0 == other.0 } pub const fn intersects(self, other: $name) -> bool { self.0 & other.0 != 0 } pub const fn union(self, other: $name) -> $name { $name(self.0 | other.0) } pub const fn intersection(self, other: $name) -> $name { $name(self.0 & other.0) } pub const fn difference(self, other: $name) -> $name { $name(self.0 & !other.0) } pub fn from_name(name: &str) -> Option<$name> { Self::KNOWN .iter() .find(|(_, n)| *n == name) .map(|(v, _)| *v) .or_else(|| Self::ALIASES.iter().find(|(n, _)| *n == name).map(|(_, v)| *v)) } } impl From<$name> for u32 { fn from(value: $name) -> u32 { value.as_raw() } } impl TryFrom<u32> for $name { type Error = $crate::error::Error; fn try_from(value: u32) -> Result<$name, $crate::error::Error> { if value & !($name::ALL_KNOWN.0 | $name::DROPPED) == 0 { Ok($name(value)) } else { Err($crate::metal::unknown($metal, value)) } } } impl ::std::ops::BitOr for $name { type Output = $name; fn bitor(self, rhs: $name) -> $name { self.union(rhs) } } impl ::std::ops::BitOrAssign for $name { fn bitor_assign(&mut self, rhs: $name) { *self = self.union(rhs); } } impl ::std::ops::BitAnd for $name { type Output = $name; fn bitand(self, rhs: $name) -> $name { self.intersection(rhs) } } impl ::std::ops::BitAndAssign for $name { fn bitand_assign(&mut self, rhs: $name) { *self = self.intersection(rhs); } } impl ::std::fmt::Debug for $name { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { if let Some((_, name)) = Self::KNOWN.iter().find(|(v, _)| v == self) { return f.write_str(name); } let mut rest = self.0; let mut first = true; for (v, n) in Self::KNOWN { if v.0.count_ones() == 1 && rest & v.0 != 0 { if !first { f.write_str(" | ")?; } f.write_str(n)?; rest &= !v.0; first = false; } } if rest != 0 || first { if !first { f.write_str(" | ")?; } write!(f, "{:#x}", rest)?; } Ok(()) } } };
|
||||
macro-template metal2vulkan::vk_bit! ( $(#[$meta:meta])* $name:ident($raw:ty) = $vk:literal in $flags:ident { $($konst:ident = $value:literal, $vkname:literal;)* } aliases { $($alias:literal => $target:ident;)* } ) => { $(#[$meta])* #[repr(transparent)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(try_from = "u32", into = "u32"))] pub struct $name($raw); impl $name { $( #[doc = concat!("`", $vkname, "`.")] pub const $konst: $name = $name($value); )* pub const VK_NAME: &'static str = $vk; pub const KNOWN: &'static [$name] = &[$($name::$konst),*]; const NAMES: &'static [($name, &'static str)] = &[$(($name::$konst, $vkname)),*]; const ALIASES: &'static [(&'static str, $name)] = &[$(($alias, $name::$target)),*]; pub const fn from_raw(raw: $raw) -> Option<$name> { let mut i = 0; while i < Self::KNOWN.len() { if Self::KNOWN[i].0 == raw { return Some(Self::KNOWN[i]); } i += 1; } None } pub const fn from_flags(flags: $flags) -> Option<$name> { Self::from_raw(flags.as_raw()) } pub const fn as_raw(self) -> $raw { self.0 } pub const fn flags(self) -> $flags { $flags::from_raw(self.0) } pub fn name(self) -> &'static str { Self::NAMES .iter() .find(|(v, _)| *v == self) .map(|(_, n)| *n) .expect("a single-bit value is always a named bit") } pub fn from_name(name: &str) -> Option<$name> { Self::NAMES .iter() .find(|(_, n)| *n == name) .map(|(v, _)| *v) .or_else(|| Self::ALIASES.iter().find(|(n, _)| *n == name).map(|(_, v)| *v)) } } impl ::std::convert::TryFrom<$raw> for $name { type Error = $raw; fn try_from(raw: $raw) -> Result<$name, $raw> { $name::from_raw(raw).ok_or(raw) } } impl From<$name> for $raw { fn from(bit: $name) -> $raw { bit.0 } } impl From<$name> for $flags { fn from(bit: $name) -> $flags { bit.flags() } } impl ::std::fmt::Debug for $name { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { f.write_str(self.name()) } } };
|
||||
macro-template metal2vulkan::vk_enum! ( $(#[$meta:meta])* $name:ident($raw:ty) = $vk:literal { $($konst:ident = $value:literal, $vkname:literal;)* } aliases { $($alias:literal => $target:ident;)* } ) => { $(#[$meta])* #[repr(transparent)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(transparent))] pub struct $name($raw); impl $name { $( #[doc = concat!("`", $vkname, "`.")] pub const $konst: $name = $name($value); )* pub const VK_NAME: &'static str = $vk; pub const KNOWN: &'static [$name] = &[$($name::$konst),*]; const NAMES: &'static [($name, &'static str)] = &[$(($name::$konst, $vkname)),*]; const ALIASES: &'static [(&'static str, $name)] = &[$(($alias, $name::$target)),*]; pub const fn from_raw(raw: $raw) -> $name { $name(raw) } pub const fn as_raw(self) -> $raw { self.0 } pub fn name(self) -> Option<&'static str> { Self::NAMES.iter().find(|(v, _)| *v == self).map(|(_, n)| *n) } pub fn is_known(self) -> bool { self.name().is_some() } pub fn from_name(name: &str) -> Option<$name> { Self::NAMES .iter() .find(|(_, n)| *n == name) .map(|(v, _)| *v) .or_else(|| Self::ALIASES.iter().find(|(n, _)| *n == name).map(|(_, v)| *v)) } } impl ::std::fmt::Debug for $name { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { match self.name() { Some(name) => f.write_str(name), None => write!(f, "{}({})", $vk, self.0), } } } };
|
||||
@@ -13850,6 +13852,7 @@ variant metal2vulkan::device::VkFeature::MultiviewTessellationShader MultiviewTe
|
||||
variant metal2vulkan::device::VkFeature::MutableComparisonSamplers MutableComparisonSamplers
|
||||
variant metal2vulkan::device::VkFeature::NullDescriptor NullDescriptor
|
||||
variant metal2vulkan::device::VkFeature::OcclusionQueryPrecise OcclusionQueryPrecise
|
||||
variant metal2vulkan::device::VkFeature::PointPolygons PointPolygons
|
||||
variant metal2vulkan::device::VkFeature::PrimitiveTopologyListRestart PrimitiveTopologyListRestart
|
||||
variant metal2vulkan::device::VkFeature::PrimitiveTopologyPatchListRestart PrimitiveTopologyPatchListRestart
|
||||
variant metal2vulkan::device::VkFeature::ProvokingVertexLast ProvokingVertexLast
|
||||
@@ -14423,6 +14426,7 @@ variant metal2vulkan::error::Feature::ThreadgroupMemorySize ThreadgroupMemorySiz
|
||||
variant metal2vulkan::error::Feature::TileShading TileShading
|
||||
variant metal2vulkan::error::Feature::TimelineSemaphores TimelineSemaphores { max_value_difference: u64 }
|
||||
variant metal2vulkan::error::Feature::TriangleFillLines TriangleFillLines
|
||||
variant metal2vulkan::error::Feature::TriangleFillPoints TriangleFillPoints
|
||||
variant metal2vulkan::error::Feature::Type Type { code: u32 }
|
||||
variant metal2vulkan::error::Feature::UndeclaredTextureUsage UndeclaredTextureUsage
|
||||
variant metal2vulkan::error::Feature::UnknownIntrinsic UnknownIntrinsic
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3883,6 +3883,13 @@ bound.
|
||||
direct draw, an indirect one, or an indirect command's in an execution. Cost: the points rasterize
|
||||
nothing, the vertex function run for each, where what Metal draws is undefined: most of its draws
|
||||
draw nothing, and some a few of the points or a box.
|
||||
- `metal2vulkan-degrade-triangle-point-size` (precision). `TrianglePointSize`: A draw of triangles
|
||||
in fill mode `TriangleFillMode::Points` (the raw value 2, which Apple's GL renderer sends) under a
|
||||
render pipeline state whose vertex function writes `[[point_size]]`: a direct draw, an indirect
|
||||
one, or an indirect command's in an execution. The device sizes each vertex's point by the size
|
||||
the function writes where its `polygonModePointSize` is set; Metal draws one pixel whatever the
|
||||
function writes (an Apple M3 Max). Cost: each vertex can draw at the point size the vertex
|
||||
function writes, where Metal draws one pixel.
|
||||
- `metal2vulkan-degrade-device-wide-lines` (precision). `DeviceWideLines`: A draw of lines at a
|
||||
width other than 1 (Apple's `setLineWidth:`), or of a triangle's edges in fill mode `Lines` or of
|
||||
a mesh draw, drawn by the device's own lines, which no device's are taken to draw as Metal's
|
||||
|
||||
@@ -79,18 +79,18 @@ What this axis cannot see, measured rather than asserted:
|
||||
| | |
|
||||
|---|---|
|
||||
| Metal enums and option sets with a generated value list | 60 |
|
||||
| their values | 760 |
|
||||
| their values | 761 |
|
||||
| of those, unreachable: no case can put them to Metal | 51 |
|
||||
| so reachable by some case | 709 |
|
||||
| so reachable by some case | 710 |
|
||||
| values compared | 678 |
|
||||
| share of the reachable compared | 96% |
|
||||
| share of the reachable compared | 95% |
|
||||
| values only the suite's shared sources name | 15 |
|
||||
| values no source names and no recording holds | 16 |
|
||||
| values no source names and no recording holds | 17 |
|
||||
| of the types above, those the suite also spells through its own vocabulary | 5 |
|
||||
| types every reachable value of which is compared | 45 |
|
||||
| types every reachable value of which is compared | 44 |
|
||||
| types no value of which is compared | 2 |
|
||||
|
||||
The share is weakly informative on its own: `MTLPixelFormat`, `MTLDataType`, `MTLAttributeFormat`, `MTLVertexFormat` hold 506 of the 760 values between them, so an aggregate over types this uneven is mostly theirs. The per-type table is the one to read.
|
||||
The share is weakly informative on its own: `MTLPixelFormat`, `MTLDataType`, `MTLAttributeFormat`, `MTLVertexFormat` hold 506 of the 761 values between them, so an aggregate over types this uneven is mostly theirs. The per-type table is the one to read.
|
||||
|
||||
### Depth by type
|
||||
|
||||
@@ -106,6 +106,7 @@ Deepest gap first, which is the order the work list reads in. *answered*, *at a
|
||||
| `MTLBarrierScope` | 3 | 2 | 0 | 0 | 2 | 0 | 0 | 1 |
|
||||
| `MTLReadWriteTextureTier` | 3 | 2 | 1 | 0 | 2 | 0 | 0 | 1 |
|
||||
| `MTLResourceUsage` | 3 | 2 | 0 | 0 | 2 | 0 | 0 | 1 |
|
||||
| `MTLTriangleFillMode` | 3 | 2 | 0 | 0 | 2 | 0 | 0 | 1 |
|
||||
| `MTLCommandBufferStatus` | 6 | 0 | 0 | 0 | 0 | 6 | 0 | 0 |
|
||||
| `MTLPurgeableState` | 4 | 1 | 0 | 0 | 1 | 3 | 0 | 0 |
|
||||
| `MTLSparseTextureRegionAlignmentMode` | 2 | 0 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
@@ -152,7 +153,6 @@ Deepest gap first, which is the order the work list reads in. *answered*, *at a
|
||||
| `MTLTextureSwizzle` | 6 | 6 | 0 | 0 | 6 | 0 | 0 | 0 |
|
||||
| `MTLTextureType` | 10 | 10 | 7 | 0 | 10 | 0 | 0 | 0 |
|
||||
| `MTLTextureUsage` | 9 | 9 | 0 | 0 | 9 | 0 | 0 | 0 |
|
||||
| `MTLTriangleFillMode` | 2 | 2 | 0 | 0 | 2 | 0 | 0 | 0 |
|
||||
| `MTLVertexFormat` | 54 | 54 | 2 | 52 | 18 | 0 | 0 | 0 |
|
||||
| `MTLVertexStepFunction` | 5 | 5 | 2 | 2 | 5 | 0 | 0 | 0 |
|
||||
| `MTLVisibilityResultMode` | 3 | 3 | 0 | 0 | 3 | 0 | 0 | 0 |
|
||||
@@ -303,7 +303,7 @@ The work list of this axis, and the shape of the answer to *is the depth suffici
|
||||
- **`MTLReadWriteTextureTier`**, 2 of 3 compared
|
||||
- **`MTLResourceUsage`**, 2 of 3 compared
|
||||
- **`MTLStoreActionOptions`**, 2 of 2 compared
|
||||
- **`MTLTriangleFillMode`**, 2 of 2 compared
|
||||
- **`MTLTriangleFillMode`**, 2 of 3 compared
|
||||
- **`MTLVisibilityResultType`**, 2 of 2 compared
|
||||
|
||||
### Types a case is about, whose values this axis cannot read
|
||||
@@ -333,6 +333,7 @@ The work list. A name here is a value of Metal's that no committed recording hol
|
||||
- **`MTLBarrierScope`**, 1 of 3: `MTLBarrierScopeBuffers`
|
||||
- **`MTLReadWriteTextureTier`**, 1 of 3: `MTLReadWriteTextureTier1`
|
||||
- **`MTLResourceUsage`**, 1 of 3: `MTLResourceUsageSample`
|
||||
- **`MTLTriangleFillMode`**, 1 of 3: `MTLTriangleFillModePoints`
|
||||
|
||||
And the values only the suite's shared sources name, which some case reaches and this cannot attribute:
|
||||
|
||||
|
||||
+4
-2
@@ -27,7 +27,7 @@ Columns:
|
||||
|
||||
| Kind | Variants | With a site | Reach system | Reach app | Reach rare | Reach none | Unassessed |
|
||||
|---|---|---|---|---|---|---|---|
|
||||
| Translator and front-end refusals | 130 | 130 | 7 | 32 | 72 | 19 | 0 |
|
||||
| Translator and front-end refusals | 131 | 131 | 8 | 32 | 72 | 19 | 0 |
|
||||
| Runtime gaps | 79 | 79 | 1 | 10 | 46 | 22 | 0 |
|
||||
| Apple-only calls | 4 | 4 | 0 | 0 | 0 | 4 | 0 |
|
||||
| Binder refusals at a device limit | 9 | 9 | 0 | 1 | 7 | 1 | 0 |
|
||||
@@ -41,7 +41,7 @@ Columns:
|
||||
|
||||
| Kind | `metal-measured` | `metal-documented` | `metal-takes` | `device` | `ours` | `unknown` | `delegated` | `-` |
|
||||
|---|---|---|---|---|---|---|---|---|
|
||||
| Translator and front-end refusals | 0 | 0 | 0 | 49 | 58 | 0 | 0 | 23 |
|
||||
| Translator and front-end refusals | 0 | 0 | 0 | 50 | 58 | 0 | 0 | 23 |
|
||||
| Runtime gaps | 0 | 0 | 0 | 0 | 79 | 0 | 0 | 0 |
|
||||
| Apple-only calls | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 |
|
||||
| Binder refusals at a device limit | 0 | 0 | 0 | 9 | 0 | 0 | 0 | 0 |
|
||||
@@ -152,6 +152,7 @@ Columns:
|
||||
| `IndependentBlending` | Color attachments whose write masks or blend states differ, as Metal sets them per attachment, on a device without `independentBlend`, where no... | devices without VkFeature::IndependentBlend | `device` | 2: `crates/metal2vulkan-runtime/src/render.rs (check_pipeline)`, `crates/metal2vulkan/src/pipeline/link/graphics.rs (uniform_blend)` | `rare`: per-attachment blending on a device without independentBlend |
|
||||
| `RasterSampleCount` | A `rasterSampleCount` outside the device's framebuffer sample counts for the pipeline's attachments (`framebuffer*SampleCounts`), and, for a color... | devices short of a Vulkan property the site names; devices without a capability the site computes | `device` | 2: `crates/metal2vulkan-runtime/src/families/limits.rs (sample_count)`, `crates/metal2vulkan/src/pipeline/graphics.rs (sample_count_properties)` | `app`: a sample count a device lacks for the attachments |
|
||||
| `TriangleFillLines` | The render encoder's `MTLTriangleFillModeLines` (`polygonMode` `LINE`) on a device without `fillModeNonSolid` | - | `-` | via a helper: 1: `crates/metal2vulkan/src/metal/state.rs (polygon_mode)` | `app`: wireframe on a device without fillModeNonSolid |
|
||||
| `TriangleFillPoints` | The render encoder's `TriangleFillMode::Points` (`polygonMode` `POINT`) on a device without `fillModeNonSolid`, or on a portability-subset device... | devices short of a Vulkan feature the site names | `device` | 1: `crates/metal2vulkan/src/metal/state.rs (polygon_mode)` | `system`: Apple's GL renderer's glPolygonMode(GL_POINT) on a device without fillModeNonSolid, or a portability-subset device without pointPolygons (MoltenVK) |
|
||||
| `DepthClipClamp` | The render encoder's `MTLDepthClipModeClamp` (`depthClampEnable`) on a device without `depthClamp` | - | `-` | via a helper: 1: `crates/metal2vulkan/src/metal/state.rs (depth_clamp_enable)` | `app`: depth clamp on a device without depthClamp |
|
||||
| `DepthBiasClamp` | The render encoder's depth bias clamp, nonzero with a nonzero bias, on a device without `depthBiasClamp` | - | `-` | via a helper: 1: `crates/metal2vulkan/src/metal/state.rs (depth_bias)` | `app`: depth bias clamp on a device without depthBiasClamp |
|
||||
| `ConstantAlphaBlendFactor` | `CONSTANT_ALPHA` or `ONE_MINUS_CONSTANT_ALPHA` (Metal's `BlendAlpha` factors) as a color blend factor on a portability-subset device without... | devices without VkFeature::ConstantAlphaColorBlendFactors | `device` | 1: `crates/metal2vulkan/src/metal/state.rs (check_constant_alpha)` | `app`: blend-alpha factors on a portability-subset device without them |
|
||||
@@ -678,6 +679,7 @@ Each refusal's sites, with the function that builds it.
|
||||
- `feature::IndependentBlending`: `crates/metal2vulkan-runtime/src/render.rs (check_pipeline)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (uniform_blend)`
|
||||
- `feature::RasterSampleCount`: `crates/metal2vulkan-runtime/src/families/limits.rs (sample_count)`; `crates/metal2vulkan/src/pipeline/graphics.rs (sample_count_properties)`
|
||||
- `feature::TriangleFillLines`: `crates/metal2vulkan/src/metal/state.rs (polygon_mode)`
|
||||
- `feature::TriangleFillPoints`: `crates/metal2vulkan/src/metal/state.rs (polygon_mode)`
|
||||
- `feature::DepthClipClamp`: `crates/metal2vulkan/src/metal/state.rs (depth_clamp_enable)`
|
||||
- `feature::DepthBiasClamp`: `crates/metal2vulkan/src/metal/state.rs (depth_bias)`
|
||||
- `feature::ConstantAlphaBlendFactor`: `crates/metal2vulkan/src/metal/state.rs (check_constant_alpha)`
|
||||
|
||||
@@ -99,6 +99,7 @@ feature IntersectionFunctionTable rare ray tracing (out of scope by ruling)
|
||||
feature IndependentBlending rare per-attachment blending on a device without independentBlend
|
||||
feature RasterSampleCount app a sample count a device lacks for the attachments
|
||||
feature TriangleFillLines app wireframe on a device without fillModeNonSolid
|
||||
feature TriangleFillPoints system Apple's GL renderer's glPolygonMode(GL_POINT) on a device without fillModeNonSolid, or a portability-subset device without pointPolygons (MoltenVK)
|
||||
feature DepthClipClamp app depth clamp on a device without depthClamp
|
||||
feature DepthBiasClamp app depth bias clamp on a device without depthBiasClamp
|
||||
feature ConstantAlphaBlendFactor app blend-alpha factors on a portability-subset device without them
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 17 and column 65.
|
@@ -14,6 +14,12 @@ for the front end's enums, `crates/metal2vulkan-air/src/metal/mod.rs`.
|
||||
Deprecated spellings with the same value are recorded as aliases. Value expressions other than
|
||||
integer literals, shifts, ors, and references to earlier enumerators fail generation.
|
||||
|
||||
Values the headers do not declare but Metal takes are the script's `PRIVATE` input, one line per
|
||||
value after the type's header enumerators, each with a comment giving the evidence that Metal takes
|
||||
it (the device, the macOS release, what Metal did with it); generation fails once the headers
|
||||
declare one. `PRIVATE_DOCS` gives such a value a doc comment on its variant, where a consumer needs
|
||||
to know what Metal does with it.
|
||||
|
||||
It also generates `scripts/conformance-coverage/metal_enumerators.tsv` from the `TABLE_ONLY` list:
|
||||
the SDK's enumerators and ordinals for the Metal enums and option sets the tree declares **by
|
||||
hand** rather than from these headers, because the compile-and-plan layer never reads them. No Rust
|
||||
|
||||
@@ -259,6 +259,24 @@ PRIVATE = {
|
||||
("MTLTextureUsageVideo", 0x8000),
|
||||
("MTLTextureUsageBlockWritesOnly", 0x10000),
|
||||
],
|
||||
# `setTriangleFillMode:`'s raw value 2, which Apple's GL renderer sends for
|
||||
# `glPolygonMode(GL_POINT)` under its Intel and Apple-silicon capability tables. Metal takes it
|
||||
# and draws each triangle's vertices as points of one pixel: an Apple M3 Max on macOS 27.0.1
|
||||
# (whatever `[[point_size]]` the vertex function writes, after culling) and an Intel UHD
|
||||
# Graphics 630 on macOS 26.7.1; a Radeon Pro 5300M fills the triangle. No object carries the
|
||||
# mode, so Metal prints no name for it: the name is this tree's.
|
||||
"MTLTriangleFillMode": [("MTLTriangleFillModePoints", 2)],
|
||||
}
|
||||
|
||||
# A doc comment for a `PRIVATE` enumerator, emitted on its variant after the enumerator's name, for
|
||||
# a value whose meaning a consumer of the variant needs.
|
||||
PRIVATE_DOCS = {
|
||||
"MTLTriangleFillModePoints": [
|
||||
"Not declared by the SDK headers: the raw value 2, which Apple's GL renderer sends",
|
||||
"for `glPolygonMode(GL_POINT)`. Metal draws each triangle's vertices as points of one",
|
||||
"pixel on an Apple M3 Max and an Intel UHD Graphics 630, where a Radeon Pro 5300M",
|
||||
"fills the triangle.",
|
||||
],
|
||||
}
|
||||
|
||||
# Bits of an option set the SDK headers do not declare that Metal takes and drops: every texture
|
||||
@@ -517,6 +535,7 @@ def render(found, sdk_version, enums, options):
|
||||
"// Regenerate with scripts/regen-metal-enums/regen_metal_enums.py; do not edit.",
|
||||
"",
|
||||
]
|
||||
documented = set()
|
||||
for name, flags in [(n, False) for n in enums] + [(n, True) for n in options]:
|
||||
if name not in found:
|
||||
raise ValueError(f"{name} not found in the SDK headers")
|
||||
@@ -538,6 +557,13 @@ def render(found, sdk_version, enums, options):
|
||||
out.append(f' {name[3:]} = "{name}" {{')
|
||||
for rust, ident, value in entries:
|
||||
shown = f"0x{value:x}" if flags else str(value)
|
||||
doc = PRIVATE_DOCS.get(ident)
|
||||
if doc is not None:
|
||||
if flags or ident not in dict(PRIVATE.get(name, [])):
|
||||
raise ValueError(f"{ident} has a doc, but no private value")
|
||||
documented.add(ident)
|
||||
out.append(" ///")
|
||||
out.extend(f" /// {line}" for line in doc)
|
||||
out.append(f' {rust} = {shown}, "{ident}";')
|
||||
out.append(" }")
|
||||
out.append(" aliases {")
|
||||
@@ -553,6 +579,10 @@ def render(found, sdk_version, enums, options):
|
||||
out.append(" }")
|
||||
out.append("}")
|
||||
out.append("")
|
||||
owned = {ident for name in enums for ident, _ in PRIVATE.get(name, [])}
|
||||
undocumented = (set(PRIVATE_DOCS) & owned) - documented
|
||||
if undocumented:
|
||||
raise ValueError(f"no variant took the docs of {sorted(undocumented)}")
|
||||
return "\n".join(out).rstrip("\n") + "\n"
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import unittest
|
||||
|
||||
from regen_metal_enums import DECL, parse_body, rows, strip_comments, variant_name
|
||||
from regen_metal_enums import DECL, parse_body, render, rows, strip_comments, variant_name
|
||||
|
||||
|
||||
class ParseTests(unittest.TestCase):
|
||||
@@ -46,6 +46,21 @@ class ParseTests(unittest.TestCase):
|
||||
with self.subTest(body=body), self.assertRaises(ValueError):
|
||||
rows("MTLX", parse_body("MTLX", body), flags=False)
|
||||
|
||||
def test_private_values_follow_the_headers_with_their_docs(self):
|
||||
found = {"MTLTriangleFillMode": (
|
||||
"ENUM", "MTLTriangleFillModeFill = 0, MTLTriangleFillModeLines = 1,")}
|
||||
text = render(found, "0.0", ["MTLTriangleFillMode"], [])
|
||||
lines = [line.strip() for line in text.splitlines()]
|
||||
after = lines.index('Lines = 1, "MTLTriangleFillModeLines";') + 1
|
||||
points = lines.index('Points = 2, "MTLTriangleFillModePoints";')
|
||||
self.assertEqual(lines[after], "///")
|
||||
self.assertTrue(all(line.startswith("/// ") for line in lines[after + 1:points]))
|
||||
self.assertLess(after + 1, points)
|
||||
declared = {"MTLTriangleFillMode": (
|
||||
"ENUM", "MTLTriangleFillModeFill = 0, MTLTriangleFillModePoints = 2,")}
|
||||
with self.assertRaises(ValueError):
|
||||
render(declared, "0.0", ["MTLTriangleFillMode"], [])
|
||||
|
||||
def test_variant_names(self):
|
||||
prefixes = ["MTLPixelFormat", "MTLPixelForma"]
|
||||
self.assertEqual(variant_name("MTLPixelFormatBGRA8Unorm_sRGB", prefixes),
|
||||
|
||||
Reference in new issue
Block a user