rt: a block-compressed texture carries the static note of its decode, CompressedTexelDecode

A read, sample or gather of a BC texel on metal2vulkan-rt is the device's decode of the texture's
own blocks, where Metal interpolates a block's endpoints with 6-bit weights. rt carried no note of
it, so the ten BC1 to BC5 decode cases read divergent on every Linux venue with no notice behind
them. The old runtime announces the same difference as compressed-texel-decode, gated by driver
facts; rt decides by the format class alone, on every device, RADV included.

- PrecisionNote::CompressedTexelDecode in the translator's public enum (codec, and
  ARTIFACT_FORMAT_VERSION 544; fast_paths' "elsewhere" list; validation allows it unbounded).
  No pipeline stage records it, so no translation changes.
- Texture::precision_note: Some(CompressedTexelDecode) for a texture or view whose own pixel
  format has a block extent (metal::format::block_extent: BC1 to BC7, ASTC, ETC2, EAC, PVRTC;
  rt makes the last four only where the device holds the format), None otherwise, as
  DepthStencilState::precision_note is shaped. Device test: a BC1, BC7, ETC2 and ASTC 4x4
  texture (where the device makes it) and its sRGB view carry the note; RGBA8Unorm and its sRGB
  view carry none.
- The old runtime's Degradation::from_precision_note maps the note to its existing
  compressed-texel-decode kind (one arm, which the exhaustive match requires).
- The conformance rt side announces the note of every texture it makes (one keep_texture helper,
  makes_texture, and the work runner's made resources).
- compressed-texel-decode leaves the suite's native notes: its catalogue entry states bounds, and
  a native note loosens nothing. The ten BC decode cases declare it and loosen each round's
  texels by the catalogue's largest bound for the family on any driver (BC1/BC2 4/255, BC3
  6/255, BC4/BC5 7.4/255, signed 0.065; an sRGB form the sRGB decode's largest step over
  4/255). The other families that make a compressed texture declare it at the notices site
  alone: the BC moves and views, ASTC, ETC2/EAC, the read-write tier tables and the usage
  table of the descriptor pairs.
- docs/API.md's catalogue entry covers both runtimes; rt's README states the note;
  api_signatures and CONFORMANCE-COVERAGE regenerated.
This commit is contained in:
Anees Iqbal committed 2026-11-19 01:40:29 -08:00
1 parent 9a5ce1d198
commit ae452ee883
24 files changed
+265 -69

No files matched your search

@@ -497,10 +497,15 @@ impl Case for AstcTextures {
// 14 HDR rows, which that card makes through the same carrier and twin since the HDR
// decode, have not run there since: their declaration counts as unchecked until a run on
// a device without unified memory announces it.
// Where the device holds the format's block itself, `metal2vulkan-rt` keeps the blocks in
// an image of it and reads the device's decode of them, the static note it announces as
// `compressed-texel-decode` for every block-compressed texture it makes. A declaration
// and not a tolerance: no ASTC bound is stated, so every texel still compares exactly.
let mut all = vec![
crate::replay::shared_memory_notice(),
crate::replay::notice_allowance(Degradation::CarriedDecodedTwin.code()),
crate::replay::notice_allowance(Degradation::CpuBlockDecode.code()),
crate::replay::notice_allowance(Degradation::CompressedTexelDecode.code()),
];
// An sRGB form's twin holds Metal's own 8-bit codes, which its slots decode through Metal's
// table, so its texels compare exactly and it names nothing further. A linear format's
@@ -25,17 +25,18 @@
//! lane uses, kept.
//!
//! **The device's decode is the answer.** A BC texture keeps no decoded twin: every device samples
//! its own BC image through its own decode, and one whose driver is not measured to decode a
//! format as Metal does announces `compressed-texel-decode`, one of the device's native answers the
//! suite declares for every case ([`crate::replay::NATIVE_NOTES`]). Like every native note it
//! loosens no value, so where such a device's texels differ from Metal's the site is a
//! `known-gaps.tsv` row of that venue naming the note and whether its stated bound covers the
//! difference. On MoltenVK, whose driver has both facts, every texel compares exactly.
//! its own BC image through its own decode, announced `compressed-texel-decode` where the runtime
//! makes it (the old runtime on a driver not measured to decode the format as Metal does;
//! `metal2vulkan-rt` for every block-compressed texture, its static note). Each round's texels are
//! loosened by the largest difference that notice's catalogue entry (docs/API.md) states for the
//! format's family on any driver, justified by the notice alone ([`CompressedDecode::decode_bound`]):
//! a texel past it is the notice's claim failing, a divergence. On MoltenVK, whose driver has both
//! facts, the old runtime announces nothing and every texel compares exactly.
//!
//! Nothing here can fault a GPU: one compute pass a round, one read-only texture, one buffer, one
//! thread a texel inside the texture, no loop and no sampling.
use crate::allowance::Allowance;
use crate::allowance::{Allowance, Justification, Loosening};
use crate::case::{call, made, Abort, Bindings, Case, Failure, Input, MetalSource, Side};
use crate::fixture::{Fixture, METAL_TEXT, RUNTIME_TEXT};
use crate::recording::ShaderRef;
@@ -44,6 +45,7 @@ use crate::transcript::{
Aspect, ByteLayout, Digest, Element, Gaps, Node, Observed, Region, Sites, Value,
};
use metal2vulkan::metal::PixelFormat;
use metal2vulkan_runtime::Degradation;
/// The fixture whose kernel reads a texture's texels as floats.
const FIXTURE: &str = "format_scout";
@@ -230,6 +232,26 @@ impl CompressedDecode {
TextureRequest::read_2d(self.format().format, SIDE, SIDE).loaded(uploads)
}
/// The largest difference from Metal's texel that `compressed-texel-decode`'s catalogue entry
/// (docs/API.md) states for the format's family, the largest of the drivers it names: a BC1
/// or BC2 channel 4/255 and BC3's 6/255 (its alpha), a BC4 or BC5 channel 7.4/255 and a signed
/// one 0.065, all on NVIDIA. An sRGB form's colour is the device's sRGB decode of a code within
/// 4/255 of Metal's, so its bound is that decode's largest step over 4/255, at the top of the
/// curve, which also covers its alpha.
fn decode_bound(&self) -> f64 {
let format = self.format();
if model::srgb(format.format) {
let decode = |value: f64| ((value + 0.055) / 1.055).powf(2.4);
return decode(1.0) - decode(1.0 - 4.0 / 255.0);
}
match format.kind {
Kind::Bc1 | Kind::Bc2 => 4.0 / 255.0,
Kind::Bc3 => 6.0 / 255.0,
Kind::Channels { signed: false, .. } => 7.4 / 255.0,
Kind::Channels { signed: true, .. } => 0.065,
}
}
/// The bytes a row of blocks takes: four blocks of a 16-texel row.
fn row_pitch(&self) -> u32 {
4 * self.format().kind.block_bytes() as u32
@@ -270,13 +292,14 @@ impl Case for CompressedDecode {
}
fn allowances(&self) -> Vec<Allowance> {
// A driver not measured to decode this format as Metal does reads the device's decode of
// the texture's own BC image, announced `compressed-texel-decode`, and a texel's `float`
// value is the device's conversion of its decoded codes, announced
// `device-texel-conversion`: both native notes the suite declares for every case. They
// loosen no texel, and a texel they move is a `known-gaps.tsv` row of the venue. On a
// device whose sampler is Metal's neither fires, and every texel compares exactly there
// too.
// The device's decode of the texture's own blocks, announced `compressed-texel-decode`
// where the runtime makes it, declared at the notices site, moves a texel by up to the
// largest difference its catalogue entry states for the format's family: each round's
// texels are loosened by that number and no further, justified by the notice, so a run
// past it is the notice's claim failing. A texel's `float` value is
// also the device's conversion of its decoded codes (`device-texel-conversion`), which
// loosens nothing. Where neither runtime announces the decode, every texel compares
// exactly.
// Every row reads its answer back through a `Shared` buffer, so on a device without
// unified memory the runtime announces `shared-in-system-memory`
// (`crate::replay::shared_memory_notice` holds the whole reason). It declares the
@@ -288,7 +311,18 @@ impl Case for CompressedDecode {
// nothing else (replay-nvidia.log). On MoltenVK, where
// the chip's GPU shares the CPU's memory, it cannot fire at all, which is why no
// recording of this suite declares it.
vec![crate::replay::shared_memory_notice()]
let mut all = vec![
crate::replay::shared_memory_notice(),
crate::replay::notice_allowance(Degradation::CompressedTexelDecode.code()),
];
for round in 0..ROUNDS {
all.push(Allowance::new(
format!("case/round/{round}/texels"),
Loosening::Absolute(self.decode_bound()),
Justification::notice(Degradation::CompressedTexelDecode),
));
}
all
}
fn shaders(&self) -> Result<Vec<ShaderRef>, String> {
@@ -842,12 +842,13 @@ pub fn out_tight(
}
/// The notices a BC case may name as justifying its notices site: the `Shared` buffer each row
/// reads its answer back through, which a device without unified memory announces.
/// reads its answer back through, which a device without unified memory announces, and the
/// device's decode of the texture's blocks.
///
/// A BC texture keeps no decoded twin on any venue: the device holds every BC format in its own
/// compressed form and decodes it itself, and where its driver is not measured to decode a format
/// as Metal does the runtime announces `compressed-texel-decode`, one of the device's native
/// answers the suite declares for every case ([`crate::replay::NATIVE_NOTES`]). Every block still
/// compressed form and decodes it itself, which the runtime announces as
/// `compressed-texel-decode` where it makes it (the old runtime where the driver is not measured
/// to decode a format as Metal does, `metal2vulkan-rt` for every such texture). Every block still
/// compares exactly: the only site these loosen is the set of notices, which Metal holds empty.
///
/// What is **not** here: `staged-texture-copy`. Our `replaceRegion:` into a compressed texture does
@@ -867,9 +868,10 @@ pub fn block_allowances() -> Vec<Allowance> {
// field and nothing else (replay-nvidia.log). On MoltenVK, where
// the chip's GPU shares the CPU's memory, it cannot fire at all, which is why no
// recording of this suite declares it.
vec![crate::replay::notice_allowance(
Degradation::SharedInSystemMemory.code(),
)]
vec![
crate::replay::notice_allowance(Degradation::SharedInSystemMemory.code()),
crate::replay::notice_allowance(Degradation::CompressedTexelDecode.code()),
]
}
/// The case for one format.
@@ -410,9 +410,8 @@ impl Case for CompressedViews {
fn allowances(&self) -> Vec<Allowance> {
// The same notices the first lane's cases name, for the same reason and from the same
// measurement: one mechanism, not two. A view of a BC texture reads the device's decode
// of its blocks, which the runtime announces as `compressed-texel-decode` where the
// driver is not measured to make Metal's: one of the suite's native notes
// ([`crate::replay::NATIVE_NOTES`]), declared for every case.
// of its blocks, which the runtime announces as `compressed-texel-decode` where it makes
// it.
crate::cases::compressed_moves::block_allowances()
}
@@ -325,10 +325,15 @@ impl Case for EtcTextures {
// nothing else (replay-nvidia.log). On MoltenVK, where
// the chip's GPU shares the CPU's memory, it cannot fire at all, which is why no
// recording of this suite declares it.
// Where the device holds the format's block itself, `metal2vulkan-rt` keeps the blocks in
// an image of it and reads the device's decode of them, the static note it announces as
// `compressed-texel-decode` for every block-compressed texture it makes. A declaration
// and not a tolerance: no ETC2 or EAC bound is stated, so every texel still compares exactly.
let mut all = vec![
crate::replay::shared_memory_notice(),
crate::replay::notice_allowance(Degradation::CarriedDecodedTwin.code()),
crate::replay::notice_allowance(Degradation::CpuBlockDecode.code()),
crate::replay::notice_allowance(Degradation::CompressedTexelDecode.code()),
];
// An 8-bit format's twin holds Metal's own codes, and the `float` the function answers is
// the **device's** conversion of a code (`device-texel-conversion`; lavapipe multiplies by
@@ -447,10 +447,17 @@ impl Case for ReadWriteDescriptors {
// The tables name block-compressed formats, which a device with no Vulkan format for one
// makes through a decoded twin carried beside the blocks, and the runtime says so: a
// performance notice at the notices site alone, every answer of the tables still
// compared. Measured firing on llvmpipe (LLVM 21.1.8).
vec![crate::replay::notice_allowance(
metal2vulkan_runtime::Degradation::CarriedDecodedTwin.code(),
)]
// compared. Measured firing on llvmpipe (LLVM 21.1.8). A texture of such a format the
// device holds itself announces the device's decode of its blocks
// (`compressed-texel-decode`), at the notices site alone too: the tables read no texel.
vec![
crate::replay::notice_allowance(
metal2vulkan_runtime::Degradation::CarriedDecodedTwin.code(),
),
crate::replay::notice_allowance(
metal2vulkan_runtime::Degradation::CompressedTexelDecode.code(),
),
]
}
fn inputs(&self) -> Result<Vec<Input>, String> {
@@ -593,6 +593,11 @@ impl Case for DescriptorPairs {
named.push(crate::replay::notice_allowance(
metal2vulkan_runtime::Degradation::CarriedDecodedTwin.code(),
));
// A compressed texture the device holds itself announces the device's decode of its
// blocks (`compressed-texel-decode`), which the row never reads either.
named.push(crate::replay::notice_allowance(
metal2vulkan_runtime::Degradation::CompressedTexelDecode.code(),
));
}
if self.name == STORAGE {
// The storage table names `Shared` among the modes it crosses, so this row alone
@@ -509,8 +509,7 @@ pub fn set_past_layout_notice() -> crate::allowance::Allowance {
/// the device's own depth conversion and depth test (`unorm-depth-rounding`, `depth-denormals`,
/// `signed-depth-test`);
/// - **texel, vertex and colour conversions**: `device-texel-conversion`,
/// `half-texel-conversion`, `srgb-texel-decode`, the device's decode of a BC texture's blocks
/// (`compressed-texel-decode`), the device's fixed-function conversion of a
/// `half-texel-conversion`, `srgb-texel-decode`, the device's fixed-function conversion of a
/// normalized vertex attribute (`device-vertex-conversion`), `device-color-conversion`;
/// - **sampling and filtering**: `device-sampling`, `device-sample-level`, the device's filter of a
/// generated mipmap chain (`device-filtered-mipmaps`), and Metal's own sampler filtering a
@@ -537,7 +536,10 @@ pub fn set_past_layout_notice() -> crate::allowance::Allowance {
/// `restricted-depth-range`), of an emulation's own precision (`decoded-texel-precision`,
/// `grad-from-bias`, `pixel-sampler-scaling`, `bicubic-filter-arithmetic`), of a Metal form not
/// measured or not built (`blended-write-rounding`, `unmeasured-resolve`, `device-interpolation`,
/// `reduction-order`), and every performance or validity notice.
/// `reduction-order`), a native answer whose catalogue entry states the bound the cases that
/// read it hold it to (the device's decode of a block-compressed texture's blocks,
/// `compressed-texel-decode`, which only a case that makes such a texture can announce), and every
/// performance or validity notice.
///
/// **It declares the notice, and nothing about a value.** Each entry loosens the notices site
/// alone, exactly as a case's own [`notice_allowance`] does, so every value of every case still
@@ -570,7 +572,6 @@ pub const NATIVE_NOTES: &[metal2vulkan_runtime::Degradation] = {
D::DeviceTexelConversion,
D::HalfTexelConversion,
D::SrgbTexelDecode,
D::CompressedTexelDecode,
D::DeviceVertexConversion,
D::DeviceColorConversion,
D::DeviceSampling,
+28 -15
View File
@@ -18,9 +18,10 @@
//!
//! The runtime announces no degrade notice: where a kernel's answers may differ from Metal's, its
//! state carries static precision notes ([`metal2vulkan_rt::ComputePipelineState::precision_notes`],
//! [`metal2vulkan_rt::RenderPipelineState::precision_notes`]). This side announces the notes of
//! each state its case dispatched or drew with, by the codes the suite's allowances name
//! (`metal2vulkan-degrade-<kind>`).
//! [`metal2vulkan_rt::RenderPipelineState::precision_notes`]), and so does a texture of a
//! block-compressed format ([`metal2vulkan_rt::Texture::precision_note`]). This side announces the
//! notes of each state its case dispatched or drew with, and of each texture it made, by the codes
//! the suite's allowances name (`metal2vulkan-degrade-<kind>`).
use crate::case::{
Answer, Bindings, Failure, Handle, SamplerSpec, ShaderSource, Side, StageInRegion, StageInput,
@@ -363,7 +364,8 @@ pub struct RtSide<'a> {
drawn: BTreeSet<usize>,
/// The static notes of what a pass the case encoded set beside its pipeline states: a depth
/// bias other than 0 (`RenderCommandEncoder::DEPTH_BIAS_NOTE`) and each depth-stencil state's
/// (`DepthStencilState::precision_note`), which [`Side::announced`] answers too.
/// (`DepthStencilState::precision_note`); and of each texture the case made
/// (`Texture::precision_note`), which [`Side::announced`] answers too.
encoder_notes: BTreeSet<rt::PrecisionNote>,
}
@@ -398,6 +400,13 @@ impl<'a> RtSide<'a> {
Ok(self.queue.as_ref().expect("made above"))
}
/// Keep `texture` as the case's, with the static note it carries (`Texture::precision_note`:
/// the device's decode of a block-compressed format), which [`Side::announced`] answers.
fn keep_texture(&mut self, texture: rt::Texture) -> Handle {
self.encoder_notes.extend(texture.precision_note());
keep(&mut self.textures, texture)
}
fn held(&self, handle: Handle) -> Answer<&rt::Buffer> {
(self.buffers.get(handle.0 as usize))
.map(|(buffer, _)| buffer)
@@ -624,7 +633,7 @@ impl Side for RtSide<'_> {
size: [size[0], size[1], 1],
};
(texture.replace_region(region, 0, 0, bytes, row_pitch.into(), 0)).map_err(of_rt)?;
Ok(keep(&mut self.textures, texture))
Ok(self.keep_texture(texture))
}
fn read_texture(&mut self, texture: Handle, size: [u32; 2], row_pitch: u32) -> Answer<Vec<u8>> {
@@ -678,7 +687,7 @@ impl Side for RtSide<'_> {
let texture = (self.on.device.new_texture(&descriptor, index))
.map_err(|error| Failure::of_rt(&error))?;
let facts = texture_facts(&texture);
keep(&mut self.textures, texture);
self.keep_texture(texture);
Ok(Some(facts))
}
@@ -697,7 +706,7 @@ impl Side for RtSide<'_> {
let made = buffer.new_texture(&descriptor, index, request.offset, request.bytes_per_row);
let texture = made.map_err(|error| Failure::of_rt(&error))?;
let facts = texture_facts(&texture);
keep(&mut self.textures, texture);
self.keep_texture(texture);
Ok(facts)
}
@@ -731,9 +740,10 @@ impl Side for RtSide<'_> {
fn makes_texture(&mut self, query: &crate::texture_query::HeapTextureQuery) -> Answer<bool> {
let descriptor = queried(query);
let index = self.on.texture_index(descriptor.usage);
(self.on.device.new_texture(&descriptor, index))
.map(|_| true)
.map_err(|error| Failure::of_rt(&error))
let texture = (self.on.device.new_texture(&descriptor, index))
.map_err(|error| Failure::of_rt(&error))?;
self.encoder_notes.extend(texture.precision_note());
Ok(true)
}
/// `newHeapWithDescriptor:` as the runtime's consumer makes a heap: a block of the heap's size
@@ -921,7 +931,7 @@ impl Side for RtSide<'_> {
),
}
.map_err(|error| Failure::of_rt(&error))?;
Ok(keep(&mut self.textures, view))
Ok(self.keep_texture(view))
}
/// The view's shape and swizzle, read of its descriptor; its parent's facts are the
@@ -1060,7 +1070,7 @@ impl Side for RtSide<'_> {
(texture.replace_region(region, 0, 0, bytes, spec.row_pitch.into(), 0))
.map_err(of_rt)?;
}
Ok(keep(&mut self.textures, texture))
Ok(self.keep_texture(texture))
}
/// The call the request names: the device's `newTextureWithDescriptor:`, the buffer's
@@ -1139,14 +1149,17 @@ impl Side for RtSide<'_> {
))
.map_err(of_rt)?;
}
Ok(keep(&mut self.textures, texture))
Ok(self.keep_texture(texture))
}
/// The program on the runtime, as the old runtime's side runs it (`rt_side::work`); a
/// program that generates mipmaps announces the blit encoder's static note of them.
/// program that generates mipmaps announces the blit encoder's static note of them, and one
/// that makes a texture its static note.
fn work(&mut self, work: &crate::work::Work) -> Answer<crate::work::Done> {
let on = self.on;
let done = work::run(on, self.queue()?, work)?;
self.queue()?;
let queue = self.queue.as_ref().expect("made above");
let done = work::run(on, queue, work, &mut self.encoder_notes)?;
let mipmaps =
|step: &crate::work::Step| matches!(step, crate::work::Step::GenerateMipmaps { .. });
if work.steps.iter().any(mipmaps) {
@@ -140,7 +140,7 @@ impl RtSide<'_> {
let buffer = self.held(over.buffer)?;
let texture = (buffer.new_texture(&descriptor, index, over.offset, over.bytes_per_row))
.map_err(of_rt)?;
return Ok(keep(&mut self.textures, texture));
return Ok(self.keep_texture(texture));
}
descriptor.storage_mode = match spec.shared {
true => rt::StorageMode::Shared,
@@ -163,7 +163,7 @@ impl RtSide<'_> {
let index = (spec.shader_read || spec.shader_write)
.then(|| self.on.next_index(rt::IndexClass::Texture));
let texture = (self.on.device.new_texture(&descriptor, index)).map_err(of_rt)?;
Ok(keep(&mut self.textures, texture))
Ok(self.keep_texture(texture))
}
/// `newRenderPipelineStateWithDescriptor:error:` of the descriptor the old runtime's side
@@ -21,6 +21,7 @@ use crate::work::{Clear, Done, Plane, Rect, Resource, Step, TextureKind, Texture
use metal2vulkan::metal::PixelFormat;
use metal2vulkan_devtools::{engine_dir, llvm_assemble};
use metal2vulkan_rt as rt;
use std::collections::BTreeSet;
/// A typed error of the runtime as the failure it records.
fn of_rt(error: rt::Error) -> Failure {
@@ -122,6 +123,16 @@ enum Made {
Released,
}
impl Made {
/// A texture's static note (`Texture::precision_note`); no other resource carries one.
fn precision_note(&self) -> Option<rt::PrecisionNote> {
match self {
Made::Texture(texture) => texture.precision_note(),
_ => None,
}
}
}
/// A read-back the device runs before its bytes are answered.
struct Pending {
/// The read's place among the program's reads.
@@ -354,6 +365,8 @@ fn make(on: &RtDevice, made: &[Made], resource: &Resource) -> Answer<Made> {
struct Run<'a> {
on: &'a RtDevice,
queue: &'a rt::CommandQueue,
/// The static notes of the textures the program made.
notes: &'a mut BTreeSet<rt::PrecisionNote>,
made: Vec<Made>,
/// The program's declarations, which a [`Step::Make`] reads to make a released resource again.
resources: &'a [Resource],
@@ -366,15 +379,24 @@ struct Run<'a> {
statuses: Vec<String>,
}
/// Run `work` on `on`'s device through `queue`, answering what it read.
pub(super) fn run(on: &RtDevice, queue: &rt::CommandQueue, work: &Work) -> Answer<Done> {
/// Run `work` on `on`'s device through `queue`, answering what it read, with the static note of
/// each texture it makes (`Texture::precision_note`) in `notes`.
pub(super) fn run(
on: &RtDevice,
queue: &rt::CommandQueue,
work: &Work,
notes: &mut BTreeSet<rt::PrecisionNote>,
) -> Answer<Done> {
let mut made: Vec<Made> = Vec::with_capacity(work.resources.len());
for (at, resource) in work.resources.iter().enumerate() {
made.push(make(on, &made, resource).map_err(|failure| failure.at_resource(at))?);
let one = make(on, &made, resource).map_err(|failure| failure.at_resource(at))?;
notes.extend(one.precision_note());
made.push(one);
}
let mut state = Run {
on,
queue,
notes,
made,
resources: &work.resources,
kernels: work.kernels,
@@ -787,6 +809,7 @@ impl Run<'_> {
let declared = (self.resources.get(at))
.ok_or_else(|| Failure::named("NoSuchResource", format!("resource {at}")))?;
let one = make(self.on, &self.made, declared)?;
self.notes.extend(one.precision_note());
self.made[at] = one;
Ok(())
}
+8
View File
@@ -687,6 +687,14 @@ made, with no lock, and never rewritten for layouts.
every texture an index, and this one has none, so its `gpu_resource_id` answers index 0 and a
slot that binds it reads Metal's nil texture. `new_texture` still refuses a texture shaders
reach made without an index (`Refusal::TextureIndex`).
- A texture or view whose own pixel format is block-compressed (BC1 to BC7, and the ASTC, ETC2
and EAC formats where the device makes them) holds its blocks in an image of that format, and a
read, sample or gather of its texels is the device's decode of them (an sRGB form's code through
the device's sRGB decode), where Metal interpolates a block's endpoints with 6-bit weights: the
static note `PrecisionNote::CompressedTexelDecode` (`Texture::precision_note`), decided by the
pixel format alone on every device. Its blocks' bytes, copies and sizes are Metal's. The
largest differences measured are in docs/API.md's catalogue
(`metal2vulkan-degrade-compressed-texel-decode`).
- `Device::pixel_format_info(raw)` is `MTLPixelFormatGetInfoForDevice` (Apple SPI): Metal's
description of a raw pixel format value, its name, Apple's flags word, cast class and four
words (a block's bytes and extent for a format of blocks), as an Apple M3 Max answers it under
+57 -4
View File
@@ -13,7 +13,9 @@
//! comes back to zero with the device, the views' image views among them. A view of a Managed
//! texture writes the texture's own named bytes. A command buffer keeps a view it uses after its
//! parent, as Metal's retains every object its encoders use: released while the command buffer
//! is pending, the view keeps its image views and its element of set 1 until it retires.
//! is pending, the view keeps its image views and its element of set 1 until it retires. A texture
//! or view of a block-compressed pixel format carries the static note of its decode
//! (`PrecisionNote::CompressedTexelDecode`), one of another format none.
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
mod on_device {
@@ -24,9 +26,9 @@ mod on_device {
use crate::tests::command::on_device::{each_device, finished, shared_event, within};
use crate::{
Buffer, BufferLayout, BytesPlace, CommandQueue, Device, Error, Gap, IndexClass,
MemoryClass, PixelFormat, Refusal, Region, StorageMode, Texture, TextureDescriptor,
TexturePlace, TextureSwizzle, TextureSwizzleChannels, TextureType, TextureUsage,
TextureViewKind,
MemoryClass, PixelFormat, PrecisionNote, Refusal, Region, StorageMode, Texture,
TextureDescriptor, TexturePlace, TextureSwizzle, TextureSwizzleChannels, TextureType,
TextureUsage, TextureViewKind,
};
use metal2vulkan::metal::resource_word::TextureWord;
@@ -366,6 +368,57 @@ mod on_device {
});
}
/// A texture of a block-compressed pixel format answers the static note of its decode, and so
/// does its view in its sRGB sibling, decided by the format alone; an uncompressed texture and
/// its view answer none. Each compressed format counts where the device makes it, and each
/// device makes at least one.
#[test]
fn every_device_notes_the_decode_of_a_block_compressed_texture_and_its_views() {
each_device("compressed_decode_note", |name, _, device| {
let note = Some(PrecisionNote::CompressedTexelDecode);
let made = |pixel_format| {
let mut d = TextureDescriptor::new(TextureType::Type2D, pixel_format, 8, 8);
d.usage = TextureUsage::SHADER_READ;
device.new_texture(&d, None)
};
let view = |texture: &Texture, pixel_format| {
(texture.new_texture_view(pixel_format, TextureType::Type2D, 0..1, 0..1, None))
.unwrap_or_else(|error| panic!("{name}: a {pixel_format:?} view: {error}"))
};
let compressed = [
(PixelFormat::BC1RGBA, PixelFormat::BC1RGBASRGB),
(PixelFormat::BC7RGBAUnorm, PixelFormat::BC7RGBAUnormSRGB),
(PixelFormat::ETC2RGB8, PixelFormat::ETC2RGB8SRGB),
(PixelFormat::ASTC4x4LDR, PixelFormat::ASTC4x4SRGB),
];
let mut noted = Vec::new();
for (pixel_format, srgb) in compressed {
let texture = match made(pixel_format) {
Ok(texture) => texture,
Err(Error::Unsupported(Gap::TextureFormat { .. })) => continue,
Err(error) => panic!("{name}: a {pixel_format:?} texture: {error}"),
};
assert_eq!(texture.precision_note(), note, "{name}: {pixel_format:?}");
assert_eq!(
view(&texture, srgb).precision_note(),
note,
"{name}: {srgb:?}"
);
noted.push(pixel_format);
}
assert!(
!noted.is_empty(),
"{name}: no block-compressed texture made"
);
eprintln!("{name}: the decode note on {noted:?} and their sRGB views");
let plain = (made(PixelFormat::RGBA8Unorm))
.unwrap_or_else(|error| panic!("{name}: an RGBA8Unorm texture: {error}"));
assert_eq!(plain.precision_note(), None, "{name}: RGBA8Unorm");
let plain_view = view(&plain, PixelFormat::RGBA8UnormSRGB);
assert_eq!(plain_view.precision_note(), None, "{name}: RGBA8UnormSRGB");
});
}
#[test]
fn every_device_views_a_managed_texture_s_named_bytes() {
each_device("managed texture views", |name, _, device| {
+11
View File
@@ -47,6 +47,7 @@ use metal2vulkan::metal::resource_word::TextureWord;
use metal2vulkan::metal::{
PixelFormat, TextureSwizzle, TextureSwizzleChannels, TextureType, TextureUsage,
};
use metal2vulkan::pipeline::PrecisionNote;
use std::ops::Range;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
@@ -3569,6 +3570,16 @@ impl Texture {
&self.inner.descriptor
}
/// No Metal counterpart: the static note of a read, sample or gather of its texels, where its
/// own pixel format is block-compressed ([`PrecisionNote::CompressedTexelDecode`]: a texel is
/// the device's decode of its blocks, where Metal interpolates with 6-bit weights); `None` for
/// any other format. Decided by the pixel format alone, on every device: a view answers by
/// its own format, and its blocks' bytes, copies and sizes are Metal's either way.
pub fn precision_note(&self) -> Option<PrecisionNote> {
let compressed = formats::block_extent(self.inner.descriptor.pixel_format).is_some();
compressed.then_some(PrecisionNote::CompressedTexelDecode)
}
/// `replaceRegion:mipmapLevel:slice:withBytes:bytesPerRow:bytesPerImage:`: the bytes of
/// `region` of `level` and `slice` (a 3D texture's slice is 0), rows `bytes_per_row` and
/// images `bytes_per_image` apart in `bytes`, a compressed format's rows being rows of
@@ -245,8 +245,10 @@ macro_rules! degradations {
/// profile of `Device::from_queries` records, announces this runtime's kind for the
/// same codes, [`Degradation::SnormMinimumKept`]; [`PrecisionNote::DepthDenormals`],
/// which `metal2vulkan-rt`'s depth-stencil state carries, announces
/// [`Degradation::DepthDenormals`]; and [`PrecisionNote::DeviceFilteredMipmaps`], which
/// its blit encoder carries, [`Degradation::DeviceFilteredMipmaps`].
/// [`Degradation::DepthDenormals`]; [`PrecisionNote::DeviceFilteredMipmaps`], which its
/// blit encoder carries, [`Degradation::DeviceFilteredMipmaps`]; and
/// [`PrecisionNote::CompressedTexelDecode`], which its block-compressed textures carry,
/// [`Degradation::CompressedTexelDecode`].
pub const fn from_precision_note(note: PrecisionNote) -> Degradation {
match note {
$(PrecisionNote::$note => Degradation::$note,)*
@@ -254,6 +256,7 @@ macro_rules! degradations {
PrecisionNote::SnormMinimumKept => Degradation::SnormMinimumKept,
PrecisionNote::DepthDenormals => Degradation::DepthDenormals,
PrecisionNote::DeviceFilteredMipmaps => Degradation::DeviceFilteredMipmaps,
PrecisionNote::CompressedTexelDecode => Degradation::CompressedTexelDecode,
PrecisionNote::DeviceReconvergence => {
Degradation::ImplementationDefinedReconvergence
}
@@ -347,7 +347,8 @@ pub fn allowance(note: PrecisionNote) -> Allowance {
| N::SnormMinimumKept
| N::DeviceDepthBias
| N::DepthDenormals
| N::DeviceFilteredMipmaps => Allowance::Unbounded,
| N::DeviceFilteredMipmaps
| N::CompressedTexelDecode => Allowance::Unbounded,
}
}
@@ -86,6 +86,7 @@ fn every_precision_note_has_its_table_row() {
(N::DeviceDepthBias, Allowance::Unbounded),
(N::DepthDenormals, Allowance::Unbounded),
(N::DeviceFilteredMipmaps, Allowance::Unbounded),
(N::CompressedTexelDecode, Allowance::Unbounded),
];
for (note, expected) in rows {
assert_eq!(allowance(note), expected, "{note:?}");
+1
View File
@@ -1539,6 +1539,7 @@ codec_enum! {
DepthDenormals,
DeviceFilteredMipmaps,
TessellationFractionalSpacing,
CompressedTexelDecode,
}
BindingSource {
Buffer(f0), Texture(f0), Sampler(f0), CombinedTextureSampler { texture, sampler },
+1 -1
View File
@@ -72,7 +72,7 @@ pub const SEMANTICS_VERSION: u32 = 2186;
/// 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 = 543;
pub const ARTIFACT_FORMAT_VERSION: u32 = 544;
/// 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
@@ -2488,6 +2488,19 @@ pub enum PrecisionNote {
/// Validation derives no tolerance from it: a difference stays a mismatch, which the note
/// explains.
DeviceFilteredMipmaps,
/// A texture, or a view, whose own pixel format is block-compressed (BC1 to BC7, and the ASTC,
/// ETC2 and EAC formats where the device makes them): a read, sample or gather of its texels
/// answers the device's decode of its blocks (an sRGB form's code through the device's sRGB
/// decode), where Metal interpolates a block's endpoints with 6-bit weights. Its blocks'
/// bytes, copies and sizes are Metal's. Static per texture, decided by its pixel format alone
/// on every device: no pipeline stage records it; `metal2vulkan-rt`'s texture carries it
/// (`Texture::precision_note`). `metal2vulkan-runtime` announces the same difference as its
/// `compressed-texel-decode` kind, for a BC texture on a driver not measured to decode its
/// format as Metal does, which this note announces too.
///
/// Validation derives no tolerance from it: a difference stays a mismatch, which the note
/// explains.
CompressedTexelDecode,
}
/// The math mode of an entry's module, which decides, on a device whose `float` functions are
@@ -235,6 +235,7 @@ fn notes() -> Vec<(&'static str, Ledger)> {
DeviceDepthBias,
DepthDenormals,
DeviceFilteredMipmaps,
CompressedTexelDecode,
],
}
}
+4 -1
View File
@@ -9132,7 +9132,7 @@ macro-template metal2vulkan-rt::vk_bit! ( $(#[$meta:meta])* $name:ident($raw:ty)
macro-template metal2vulkan-rt::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), } } } };
macro-template metal2vulkan-rt::vk_flags! ( $(#[$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, Default)] #[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, &'static str)] = &[$(($name::$konst, $vkname)),*]; const ALIASES: &'static [(&'static str, $name)] = &[$(($alias, $name::$target)),*]; pub const fn empty() -> $name { $name(0) } pub const fn from_raw(raw: $raw) -> $name { $name(raw) } pub const fn as_raw(self) -> $raw { self.0 } pub const fn is_empty(self) -> bool { self.0 == 0 } 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 const fn known_bits() -> $name { let mut bits: $raw = 0; let mut i = 0; while i < Self::KNOWN.len() { let v = Self::KNOWN[i].0 .0; if v.count_ones() == 1 { bits |= v; } i += 1; } $name(bits) } pub fn name(self) -> Option<&'static str> { Self::KNOWN.iter().find(|(v, _)| *v == self).map(|(_, n)| *n) } 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 ::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.name() { 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::commands! ( v1_0 { $($v0:ident $f0:ident $n0:literal ($($a0:ident: $t0:ty),*) $(-> $r0:ty)?;)* } v1_3 { $($v3:ident $f3:ident $n3:literal ($($a3:ident: $t3:ty),*) $(-> $r3:ty)?;)* } extension { $($ve:ident $fe:ident $ne:literal ($($ae:ident: $te:ty),*) $(-> $re:ty)?;)* } ) => { #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub(crate) enum Command { $($v0,)* $($v3,)* $($ve,)* } impl Command { pub(crate) const ALL: &'static [Command] = &[ $(Command::$v0,)* $(Command::$v3,)* $(Command::$ve,)* ]; pub(crate) const COUNT: usize = Command::ALL.len(); pub(crate) fn name(self) -> &'static CStr { match self { $(Command::$v0 => $n0,)* $(Command::$v3 => $n3,)* $(Command::$ve => $ne,)* } } } #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub struct CommandsRecorded { $( #[doc = concat!("The calls of `", stringify!($v0), "`.")] pub $f0: u64, )* $( #[doc = concat!("The calls of `", stringify!($v3), "`.")] pub $f3: u64, )* $( #[doc = concat!("The calls of `", stringify!($ve), "`.")] pub $fe: u64, )* } impl CommandsRecorded { fn read(shards: &[Shard; SHARDS + 1]) -> CommandsRecorded { let sum = |command: Command| { let counts = shards.iter().map(|shard| &shard.0[command as usize]); counts.map(|count| count.load(Ordering::Relaxed)).sum() }; CommandsRecorded { $($f0: sum(Command::$v0),)* $($f3: sum(Command::$v3),)* $($fe: sum(Command::$ve),)* } } } struct Real { $($f0: [AtomicPtr<c_void>; SLOTS],)* $($f3: [AtomicPtr<c_void>; SLOTS],)* $($fe: [AtomicPtr<c_void>; SLOTS],)* } static REAL: Real = Real { $($f0: [const { AtomicPtr::new(std::ptr::null_mut()) }; SLOTS],)* $($f3: [const { AtomicPtr::new(std::ptr::null_mut()) }; SLOTS],)* $($fe: [const { AtomicPtr::new(std::ptr::null_mut()) }; SLOTS],)* }; commands!(@thunks $($v0 $f0 $n0 ($($a0: $t0),*) $(-> $r0)?;)*); commands!(@thunks $($v3 $f3 $n3 ($($a3: $t3),*) $(-> $r3)?;)*); commands!(@thunks $($ve $fe $ne ($($ae: $te),*) $(-> $re)?;)*); pub(super) fn thunk<const S: usize>(command: Command) -> *const c_void { match command { $(Command::$v0 => $f0::<S> as *const c_void,)* $(Command::$v3 => $f3::<S> as *const c_void,)* $(Command::$ve => $fe::<S> as *const c_void,)* } } pub(super) fn store(index: usize, command: Command, real: *const c_void) { let real = real.cast_mut(); match command { $(Command::$v0 => REAL.$f0[index].store(real, Ordering::Release),)* $(Command::$v3 => REAL.$f3[index].store(real, Ordering::Release),)* $(Command::$ve => REAL.$fe[index].store(real, Ordering::Release),)* } } pub(super) fn real(index: usize, command: Command) -> *const c_void { let real = match command { $(Command::$v0 => REAL.$f0[index].load(Ordering::Acquire),)* $(Command::$v3 => REAL.$f3[index].load(Ordering::Acquire),)* $(Command::$ve => REAL.$fe[index].load(Ordering::Acquire),)* }; real.cast_const() } pub(super) fn clear(index: usize) { $(REAL.$f0[index].store(std::ptr::null_mut(), Ordering::Release);)* $(REAL.$f3[index].store(std::ptr::null_mut(), Ordering::Release);)* $(REAL.$fe[index].store(std::ptr::null_mut(), Ordering::Release);)* } pub(super) fn route_tables<const S: usize>( v1_0: &mut ash::DeviceFnV1_0, v1_3: &mut ash::DeviceFnV1_3, ) { $( store(S, Command::$v0, v1_0.$f0 as *const c_void); v1_0.$f0 = $f0::<S>; )* $( store(S, Command::$v3, v1_3.$f3 as *const c_void); v1_3.$f3 = $f3::<S>; )* } }; (@thunks $($v:ident $f:ident $n:literal ($($a:ident: $t:ty),*) $(-> $r:ty)?;)*) => { $( unsafe extern "system" fn $f<const S: usize>( command_buffer: vk::CommandBuffer, $($a: $t,)* ) $(-> $r)? { let at = held(); crate::shards::add(at, &COUNTS[S][at].0[Command::$v as usize], 1); let real = REAL.$f[S].load(Ordering::Acquire); if real.is_null() { missing($n); } unsafe { let real = std::mem::transmute::< *mut c_void, unsafe extern "system" fn(vk::CommandBuffer, $($t,)*) $(-> $r)?, >(real); real(command_buffer, $($a,)*) } } )* };
macro-template metal2vulkan-runtime::degradations! ( runtime { $( $(#[doc = $doc:literal])* $kind:ident = $code:literal, $category:ident, $cost:literal; )* } notes { $( $(#[doc = $note_doc:literal])* $note:ident = $note_code:literal; )* } ) => { #[non_exhaustive] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Degradation { $($(#[doc = $doc])* $kind,)* $( #[doc = concat!( "A pipeline stage records [`PrecisionNote::", stringify!($note), "`]." )] $(#[doc = $note_doc])* $note, )* } impl Degradation { pub const ALL: &'static [Degradation] = &[$(Degradation::$kind,)* $(Degradation::$note,)*]; pub const fn code(self) -> &'static str { match self { $(Degradation::$kind => concat!("metal2vulkan-degrade-", $code),)* $(Degradation::$note => concat!("metal2vulkan-degrade-", $note_code),)* } } pub const fn category(self) -> DegradationCategory { match self { $(Degradation::$kind => DegradationCategory::$category,)* $(Degradation::$note => DegradationCategory::Precision,)* } } pub const fn cost(self) -> &'static str { match self { $(Degradation::$kind => $cost,)* $(Degradation::$note => NOTE_COST,)* } } pub const fn precision_note(self) -> Option<PrecisionNote> { match self { $(Degradation::$kind => None,)* $(Degradation::$note => Some(PrecisionNote::$note),)* } } pub const fn from_precision_note(note: PrecisionNote) -> Degradation { match note { $(PrecisionNote::$note => Degradation::$note,)* PrecisionNote::CappedLodBias => Degradation::CappedLodBias, PrecisionNote::SnormMinimumKept => Degradation::SnormMinimumKept, PrecisionNote::DepthDenormals => Degradation::DepthDenormals, PrecisionNote::DeviceFilteredMipmaps => Degradation::DeviceFilteredMipmaps, PrecisionNote::DeviceReconvergence => { Degradation::ImplementationDefinedReconvergence } } } } };
macro-template metal2vulkan-runtime::degradations! ( runtime { $( $(#[doc = $doc:literal])* $kind:ident = $code:literal, $category:ident, $cost:literal; )* } notes { $( $(#[doc = $note_doc:literal])* $note:ident = $note_code:literal; )* } ) => { #[non_exhaustive] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Degradation { $($(#[doc = $doc])* $kind,)* $( #[doc = concat!( "A pipeline stage records [`PrecisionNote::", stringify!($note), "`]." )] $(#[doc = $note_doc])* $note, )* } impl Degradation { pub const ALL: &'static [Degradation] = &[$(Degradation::$kind,)* $(Degradation::$note,)*]; pub const fn code(self) -> &'static str { match self { $(Degradation::$kind => concat!("metal2vulkan-degrade-", $code),)* $(Degradation::$note => concat!("metal2vulkan-degrade-", $note_code),)* } } pub const fn category(self) -> DegradationCategory { match self { $(Degradation::$kind => DegradationCategory::$category,)* $(Degradation::$note => DegradationCategory::Precision,)* } } pub const fn cost(self) -> &'static str { match self { $(Degradation::$kind => $cost,)* $(Degradation::$note => NOTE_COST,)* } } pub const fn precision_note(self) -> Option<PrecisionNote> { match self { $(Degradation::$kind => None,)* $(Degradation::$note => Some(PrecisionNote::$note),)* } } pub const fn from_precision_note(note: PrecisionNote) -> Degradation { match note { $(PrecisionNote::$note => Degradation::$note,)* PrecisionNote::CappedLodBias => Degradation::CappedLodBias, PrecisionNote::SnormMinimumKept => Degradation::SnormMinimumKept, PrecisionNote::DepthDenormals => Degradation::DepthDenormals, PrecisionNote::DeviceFilteredMipmaps => Degradation::DeviceFilteredMipmaps, PrecisionNote::CompressedTexelDecode => Degradation::CompressedTexelDecode, PrecisionNote::DeviceReconvergence => { Degradation::ImplementationDefinedReconvergence } } } } };
macro-template metal2vulkan-runtime::exposures! ($($exposure:expr => [$($feature:ident),* $(,)?];)*) => { impl VkFeature { pub const ALL: &'static [VkFeature] = &[$($(VkFeature::$feature),*),*]; pub fn exposure(self) -> Exposure { match self { $($(VkFeature::$feature)|* => $exposure,)* } } } };
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 } } };
@@ -9724,6 +9724,7 @@ method metal2vulkan-rt::Texture::get_bytes pub fn get_bytes(&self, bytes: &mut [
method metal2vulkan-rt::Texture::gpu_resource_id pub fn gpu_resource_id(&self) -> ResourceId
method metal2vulkan-rt::Texture::new_texture_view pub fn new_texture_view(&self, pixel_format: PixelFormat, texture_type: TextureType, levels: Range<u32>, slices: Range<u32>, index: Option<u32>) -> Result<Texture, Error>
method metal2vulkan-rt::Texture::new_texture_view_with_swizzle pub fn new_texture_view_with_swizzle(&self, pixel_format: PixelFormat, texture_type: TextureType, levels: Range<u32>, slices: Range<u32>, swizzle: TextureSwizzleChannels, index: Option<u32>) -> Result<Texture, Error>
method metal2vulkan-rt::Texture::precision_note pub fn precision_note(&self) -> Option<PrecisionNote>
method metal2vulkan-rt::Texture::replace_region pub fn replace_region(&self, region: Region, level: u32, slice: u32, bytes: &[u8], bytes_per_row: u64, bytes_per_image: u64) -> Result<(), Error>
method metal2vulkan-rt::Texture::upload_region pub fn upload_region(&self, region: Region, level: u32, slice: u32) -> Result<(), Error>
method metal2vulkan-rt::TextureDescriptor::new pub fn new(texture_type: TextureType, pixel_format: PixelFormat, width: u32, height: u32) -> TextureDescriptor
@@ -13788,6 +13789,7 @@ variant metal2vulkan-rt::PrecisionNote::BlendedWriteRounding BlendedWriteRoundin
variant metal2vulkan-rt::PrecisionNote::CappedLodBias CappedLodBias
variant metal2vulkan-rt::PrecisionNote::ClippedCoverageSplit ClippedCoverageSplit
variant metal2vulkan-rt::PrecisionNote::ColorAttachmentGroups ColorAttachmentGroups
variant metal2vulkan-rt::PrecisionNote::CompressedTexelDecode CompressedTexelDecode
variant metal2vulkan-rt::PrecisionNote::ComputedSampleDepth ComputedSampleDepth
variant metal2vulkan-rt::PrecisionNote::CoverageReadsRoundedAlpha CoverageReadsRoundedAlpha
variant metal2vulkan-rt::PrecisionNote::CubeGradientFootprint CubeGradientFootprint
@@ -16743,6 +16745,7 @@ variant metal2vulkan::pipeline::PrecisionNote::BlendedWriteRounding BlendedWrite
variant metal2vulkan::pipeline::PrecisionNote::CappedLodBias CappedLodBias
variant metal2vulkan::pipeline::PrecisionNote::ClippedCoverageSplit ClippedCoverageSplit
variant metal2vulkan::pipeline::PrecisionNote::ColorAttachmentGroups ColorAttachmentGroups
variant metal2vulkan::pipeline::PrecisionNote::CompressedTexelDecode CompressedTexelDecode
variant metal2vulkan::pipeline::PrecisionNote::ComputedSampleDepth ComputedSampleDepth
variant metal2vulkan::pipeline::PrecisionNote::CoverageReadsRoundedAlpha CoverageReadsRoundedAlpha
variant metal2vulkan::pipeline::PrecisionNote::CubeGradientFootprint CubeGradientFootprint
Can't render this file because it is too large.
+11 -4
View File
@@ -4006,16 +4006,23 @@ bound.
where Metal's sees the nil buffer's offset as its address; neither holds a buffer, so only the
address's value differs.
- `metal2vulkan-degrade-compressed-texel-decode` (precision). `CompressedTexelDecode`: A texture of
a BC format (`BC1_RGBA` to `BC7_RGBAUnorm_sRGB`) made on a device whose driver is not measured to
a block-compressed format, where the runtime makes it. On `metal2vulkan-runtime`, a texture of a
BC format (`BC1_RGBA` to `BC7_RGBAUnorm_sRGB`) made on a device whose driver is not measured to
decode its texels as Metal does (BC1 to BC3 `DriverFact::ColorBlockDecodeIsMetals`: MoltenVK on
Apple's GPUs, RADV on the 780M and the RX 7900 XTX; BC4 and BC5
`DriverFact::ChannelBlockDecodeIsMetals`: MoltenVK on Apple's GPUs; BC6H
`DriverFact::Bc6hBlockDecodeIsMetals` and BC7 `DriverFact::Bc7BlockDecodeIsMetals`: MoltenVK on
Apple's GPUs, NVIDIA's on the RTX 3090 and RTX 5080 Laptop GPU, RADV on the 780M, ANV on the Iris
Xe of Raptor Lake-P, and lavapipe's BC6H). The texture's image is its own BC image, which the
device samples through its own decode: no BC texture keeps a decoded twin. The bounds are the
Xe of Raptor Lake-P, and lavapipe's BC6H). On `metal2vulkan-rt` it is the static note
`PrecisionNote::CompressedTexelDecode` of every texture or view whose own pixel format is
block-compressed (BC1 to BC7, and the ASTC, ETC2 and EAC formats where the device makes them;
`Texture::precision_note`), on every device, with no driver fact. The texture's image is its
own image of that format, which the device samples through its own decode: no BC texture keeps a
decoded twin. The bounds are the
largest differences from Metal's texels measured on random blocks of every format; a driver not
named is unmeasured, and validation derives no tolerance from them.
named is unmeasured. Validation derives no tolerance from them; the conformance suite's BC1 to
BC5 decode cases hold each texel to its family's largest bound on any driver (an sRGB form's to
the sRGB decode's largest step over 4/255), justified by the notice alone.
Cost: a read, sample or gather of its texels answers the device's decode of its blocks (an sRGB
form's code through the device's sRGB decode), where Metal interpolates with 6-bit weights: a BC1
to BC3 channel up to 4/255 off Metal's on NVIDIA (615.71.09, the RTX 3090 and RTX 5080 Laptop
+3 -3
View File
@@ -536,8 +536,8 @@ An implemented container no case's Metal leg touches. These are the families of
| cases whose Metal answer is `metal_run` | 1201 |
| cases whose Metal answer is `carried` | 80 |
| cases whose Metal answer is `never_returned` | 4 |
| modules that loosen a measured value | 12 |
| tolerances in all | 13 |
| modules that loosen a measured value | 13 |
| tolerances in all | 14 |
| modules declaring a notice (loosening no value) | 136 |
| loosenings used | `Unchecked`, `Absolute`, `AnyOf`, `Nonzero` |
| justifications named | `Degradation`, `AcceptedDifference`, `WithoutCompression` |
@@ -581,7 +581,7 @@ Each case module: the cases it holds, the `Side` methods it calls, and how many
| `command_buffer_facts` | 1 | 1 | every field | 29 |
| `command_queues` | 1 | 1 | every field | 5 |
| `compressed_blits` | 4 | 4 | every field | 49 |
| `compressed_decode` | 10 | 10 | every field | 43 |
| `compressed_decode` | 10 | 10 | 1 tolerance(s): `Degradation` | 43 |
| `compressed_moves` | 14 | 14 | every field | 41 |
| `compressed_views` | 14 | 14 | every field | 48 |
| `compute_encoder_commands` | 8 | 8 | every field | 66 |