Translator: OpenGL mode makes a rasterizing void vertex function's state as Metal does

Metal makes, under the private OpenGL mode, a rasterizing render pipeline
state whose vertex function returns void, with or without a fragment
function, and its draws run the vertex function and rasterize nothing (an
Apple M3 Max, macOS 27.0.1, conformance/probes/opengl_mode.m). The link
refused it whatever the mode (DescriptorError::RasterizedVoidVertex), so the
runtime refused a state the guest GL renderer may make.

The compile now takes such a descriptor as the descriptor with rasterization
disabled and no fragment function (private_state::unrasterized_void_vertex),
in both render_variant_key and render_pipeline, before anything compiles: a
Function vertex stage's answer through StageEntries::returns_value (the
decode its specialization through the same object shares), a Compiled one's
from its interface's position, as the link reads it. The fragment function,
which never runs, is neither compiled nor checked; a state Metal would refuse
for another reason is then made, an answer not measured, recorded in
private_state's docs. Without the mode the refusal stands, as Metal's.

The runtime needs no change: its pipelines with rasterization disabled take
the discard as dynamic state. The runtime README's known gap for this state
is removed; docs/REFUSALS.md does not list descriptor errors (its --check
passes unchanged). SEMANTICS_VERSION 2312 -> 2313 (a refusal lifted).

Verified on lavapipe (llvmpipe, msi): job m3-max-78373 at 6aab044c24 (this
change before its rebase onto 472cfba642): the runtime's opengl_mode tests 3
run, 3 passed; the translator's link test 1 run, 1 passed. Job m3-max-78378 at
24d71d71be, this commit's tree but for the version and development's two
translator commits since (edabd70447, fd8b132834) and the four that followed
up to f29613d057: clippy -D warnings over the
workspace (all targets, all features) and over the runtime under m2v_cpu_icd
and m2v_gpu, rustdoc -D warnings and the private docs of metal2vulkan and the
runtime, all clean; the runtime's suite on lavapipe 868 run, 868 passed, 3
skipped; the translator's and AIR's suites without the tables a bless is due
for 3392 run, 3392 passed, 37 skipped. No card run: the state is one form on
every device (rasterization disabled, its discard dynamic state), the form
every_device_runs_a_vertex_function_that_stores already draws on each card.
This commit is contained in:
Anees Iqbal committed 2026-12-02 06:36:32 -08:00
1 parent 0538a8395d
commit 0b71bdf72a
7 files changed
+71 -19

No files matched your search

-5
View File
@@ -4400,11 +4400,6 @@ cache is answered compile-required on both.
The states-only plays of the 35 replay streams on lavapipe refuse none of their render or compute
states (jobs m3-max-63105 to 63108, and m3-max-63132 and m3-max-63156 for the two streams that
ran past those jobs' 300-second limit).
- Under the private OpenGL mode (`PrivateRenderState::open_gl_mode_enabled`), a render pipeline
whose vertex function returns `void` with rasterization enabled is refused, an
`Error::Translation` naming `RasterizedVoidVertex`, where Metal makes a state that runs the
vertex function and rasterizes nothing (an Apple M3 Max, macOS 27.0.1, the probe
`metal2vulkan-conformance/probes/opengl_mode.m`).
- On a device that does not list `VK_EXT_shader_stencil_export`, a fragment function's `[[stencil]]`
output is drawn by bits (`RuntimeFact::StencilBitDraws`). Each draw through its state is drawn
once under the stencil reference 0, then once for each bit of the low 8 of the write masks of
+1 -1
View File
@@ -60,7 +60,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 = 2312;
pub const SEMANTICS_VERSION: u32 = 2313;
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
+3 -2
View File
@@ -1172,8 +1172,9 @@ pub enum DescriptorError {
/// returning `void`, as every other vertex function Metal's compiler builds returns its
/// position. `newRenderPipelineStateWithDescriptor:` refuses it ("RasterizationEnabled is true
/// but the vertex shader's return type is void", on an M3 Max under macOS 27.0.1), and makes it
/// under `PrivateRenderState::open_gl_mode_enabled` as a state that rasterizes nothing, which
/// is the descriptor with rasterization disabled: the link refuses it whatever the mode.
/// under `PrivateRenderState::open_gl_mode_enabled` as a state that runs the vertex function
/// and rasterizes nothing, which the compile makes as the descriptor with rasterization
/// disabled and no fragment function: refused without the mode only.
RasterizedVoidVertex,
/// A device description (or the Khronos profile JSON it was read from) is malformed or
/// inconsistent.
@@ -335,6 +335,14 @@ impl Device {
guarded(|| {
crate::pipeline::private_state::check_render(d)?;
let p = self.profile();
// The descriptor OpenGL mode makes of a rasterizing `void` vertex function
// (`render_pipeline`).
let unrasterized = crate::pipeline::private_state::unrasterized_void_vertex(
d,
entries,
&mut Meter::new(b),
)?;
let d = unrasterized.as_ref();
// The attachments as the private logic operation draws them (`render_pipeline`).
let (operated, _) = crate::pipeline::private_state::logic_operation(d, p)?;
let d = operated.as_ref();
@@ -445,7 +453,11 @@ impl Device {
/// Metal stops at an assertion. Each stage's recursion is sized for `d`'s
/// `maxVertexCallStackDepth` or `maxFragmentCallStackDepth`, as a compute kernel's is for its
/// pipeline's; a `Compiled` stage sized for another depth is
/// `InvalidDescriptor(MaxCallStackDepth)`.
/// `InvalidDescriptor(MaxCallStackDepth)`. Under `PrivateRenderState::open_gl_mode_enabled`, a
/// rasterizing pipeline whose vertex function returns `void` compiles as the descriptor with
/// rasterization disabled and no fragment function, which Metal's state of it draws as: the
/// vertex function runs and nothing rasterizes. Without the mode it is
/// `InvalidDescriptor(RasterizedVoidVertex)`, as Metal refuses it.
pub fn compile_render_pipeline(
&self,
d: &RenderPipelineDescriptor,
@@ -746,6 +758,12 @@ impl Device {
) -> Result<RenderPipeline, Error> {
crate::pipeline::private_state::check_render(d)?;
let p = self.profile();
// Under OpenGL mode a rasterizing state whose vertex function returns `void` is made as
// the descriptor with rasterization disabled and no fragment function, decided before
// anything compiles, as the keys decide it (`render_variant_key`).
let unrasterized =
crate::pipeline::private_state::unrasterized_void_vertex(d, &StageEntries::new(), m)?;
let d = unrasterized.as_ref();
// The attachments as the private logic operation draws them: its normalized and integer
// attachments unblended (unwritten under a no-op), and Vulkan's operation where one is
// needed.
@@ -512,10 +512,11 @@ pub struct PrivateRenderState {
/// `openGLModeEnabled` (default off): changes nothing Metal draws or reflects, and makes two
/// states Metal otherwise refuses (`pipeline::private_state`'s docs): a fragment function
/// writing depth without a depth attachment, its depth going nowhere, and a rasterizing state
/// whose vertex function returns `void`, which rasterizes nothing. The runtime answers both,
/// the second as the state of the
/// descriptor with rasterization disabled; the compile reads it not, and its link refuses a
/// rasterizing `void` vertex function whatever the mode
/// whose vertex function returns `void`, which runs the vertex function and rasterizes
/// nothing. The compile makes both: the second as the descriptor with rasterization disabled
/// and no fragment function, which never runs and is not compiled
/// ([`Device::compile_render_pipeline`](crate::device::Device::compile_render_pipeline));
/// without the mode that state is refused, as Metal refuses it
/// ([`DescriptorError::RasterizedVoidVertex`](crate::error::DescriptorError::RasterizedVoidVertex)).
pub open_gl_mode_enabled: bool,
}
+3 -1
View File
@@ -612,7 +612,9 @@ fn check_stages(ifaces: &[&StageInterface], inputs: &LinkInputs) -> Result<(), E
return Err(mismatch(*expected.last().unwrap_or(&Stage::Vertex), *extra));
}
// Metal refuses a rasterizing pipeline whose vertex function returns `void`, the one
// vertex function without a position, which the compile read from its entry.
// vertex function without a position, which the compile read from its entry. Under
// OpenGL mode Metal makes it, and the compile links it with rasterization disabled
// (`private_state::unrasterized_void_vertex`).
let positioned = |iface: &StageInterface| {
(iface.io.builtins.iter()).any(|b| matches!(b, StageBuiltin::Position { .. }))
};
@@ -98,10 +98,15 @@
//! the bindings a pipeline reflects): the properties above that change nothing change nothing
//! with it either. It makes two states Metal otherwise refuses, which the runtime answers: a
//! fragment function writing depth without a depth attachment, whose colors draw as without the
//! output, and a rasterizing state whose vertex function returns `void`, whose draws run the
//! vertex function and rasterize nothing. The other refusals tried stand: fragment inputs no
//! vertex output writes or of another type, a `float` output to an integer attachment, and
//! stage-in attributes without a vertex descriptor or missing from it. The compile reads it not.
//! output, and a rasterizing state whose vertex function returns `void`, with a fragment function
//! or none, whose draws run the vertex function, its stores landing, and leave the colors as
//! cleared. The other refusals tried stand: fragment inputs no vertex output writes or of
//! another type, a `float` output to an integer attachment, and stage-in attributes without a
//! vertex descriptor or missing from it. The compile makes the first as it makes it without the
//! mode, and the second as the descriptor with rasterization disabled and no fragment function
//! ([`unrasterized_void_vertex`]): that fragment function, which never runs, is neither compiled
//! nor checked, so a state of one Metal would refuse for another reason is made, an answer not
//! measured. The compile reads the mode nowhere else.
//! - `pointSmoothEnabled` changes what Metal draws; until the translation builds it, on is
//! refused `NotImplemented` naming it.
//! - `textureWriteRoundingMode` 2 rounds a fragment function's texture writes to half-float and
@@ -114,6 +119,7 @@
use std::borrow::Cow;
use crate::budget::Meter;
use crate::device::requirements::VkFeature;
use crate::device::DeviceProfile;
use crate::error::{
@@ -124,7 +130,8 @@ use crate::library::FunctionArtifact;
use crate::metal::format::{write_conversion, WriteConversion};
use crate::metal::{ColorWriteMask, CompareFunction, PixelFormat};
use crate::pipeline::artifact::{PrecisionNote, StageModule};
use crate::pipeline::descriptor::{PrivateRenderState, RenderPipelineDescriptor};
use crate::pipeline::compile::{stage_returns_value, StageEntries};
use crate::pipeline::descriptor::{PrivateRenderState, RenderPipelineDescriptor, StageSource};
use crate::pipeline::lower_inputs::ChannelWrite;
use crate::pipeline::stage_io::{DepthCompares, StageBuiltin};
use crate::pipeline::sym::SampledType;
@@ -167,6 +174,34 @@ pub(crate) fn check_render(d: &RenderPipelineDescriptor) -> Result<(), Error> {
}
}
/// `d` as Metal makes it under `openGLModeEnabled` where it rasterizes and its vertex function
/// returns `void` (the module docs): the descriptor with rasterization disabled and no fragment
/// function, which never runs; every other descriptor as it is. Whether a `Function` vertex stage
/// returns a value is read through `entries` under `m` ([`stage_returns_value`], a decode that
/// the stage's specialization through the same object shares); a `Compiled` one's from its
/// interface, as the link reads it: a vertex function that returns a value writes its position.
pub(crate) fn unrasterized_void_vertex<'a>(
d: &'a RenderPipelineDescriptor,
entries: &StageEntries,
m: &mut Meter,
) -> Result<Cow<'a, RenderPipelineDescriptor>, Error> {
if !(d.private.open_gl_mode_enabled && d.rasterization_enabled) {
return Ok(Cow::Borrowed(d));
}
let returns = match &d.vertex {
StageSource::Function(f) => stage_returns_value(f, entries, m)?,
StageSource::Compiled(c) => (c.artifact().interface.io.builtins.iter())
.any(|b| matches!(b, StageBuiltin::Position { .. })),
};
if returns {
return Ok(Cow::Borrowed(d));
}
let mut unrasterized = d.clone();
unrasterized.rasterization_enabled = false;
unrasterized.fragment = None;
Ok(Cow::Owned(unrasterized))
}
/// The samples of a pixel at `samples` samples, as a mask.
fn all_samples(samples: u32) -> u32 {
match samples {