identity domains: a 2D bicubic sample reads its slot's format treatment from a pushed word
Under the identity domains (Device::from_queries, the new runtime's translator device) every
kernel that sampled a texture through a bicubic constexpr sampler was refused as
Unsupported{IdentityDomains} ("a bicubic filter"), because the filter's treatment of the bound
format (its inner taps, its clamp and its border texels) was a SpecKey::BicubicTexels
specialization the old binder sets from the bound texture. One compute pipeline of every macOS
guest boot met that refusal; the old runtime builds it.
The treatment is now one u32 field per bicubic slot, PushField::BicubicTexels(SlotRef), placed
and filled as TextureIntegerChannels is. The 2D routine already took the bits as a run-time value
(Bits::Value), so a sample reads the field instead of the constant; no per-format pipeline, no
new descriptor. metal::format::bicubic_texels_word(pf, swizzle) gives the word the binder
specializes the constant to (BICUBIC_TEXELS_UNBOUND for a slot bound to nothing), and None for a
format of no measured family or of 8-bit sRGB codes. rt fills the field from the bound texture
when the slot's texture changes, and refuses a dispatch whose bicubic slot holds a texture with no
word as Gap::BicubicTexels, naming the slot and the pixel format. The static precision note
BicubicFilterArithmetic stays.
Still refused under the identity domains, each the refusal it was: a bicubic sample of a 1D
texture or at pixel coordinates (and the in-place two-plane routine), an argument buffer's
texture, an array of samplers. The default domains (Device::new, the frozen old runtime's path)
are unchanged: they still specialize SpecKey::BicubicTexels and state RuntimeFact::BicubicTexels,
and the binders refuse the new field.
SEMANTICS_VERSION 2199 -> 2200, ARTIFACT_FORMAT_VERSION 554 -> 555 (a new push field tag).
docs/REFUSALS.md regenerated; api_signatures table blessed; docs/API.md and the rt README's known
gaps say what is lowered and what is refused.
Tests:
- engine_identity::a_bicubic_kernel_reads_each_slots_format_treatment_from_its_pushed_field
(replaces the refusal test; fails without the change): bcu_formats on lavapipe and moltenvk-m3
profiles under the default domains keeps its 10 facts and 10 spec keys and no push field; under
the identity domains it compiles, passes L3, pushes the 10 slots' fields, declares no spec key
and no fact, and keeps the precision note; bcu_forms (1D) and bcu_address (pixel) still compile
on the default domains and are refused under the identity domains.
- rt tests::bicubic (device cfg): each format bound at every slot of bcu_formats pushes its word,
its arm asserted per format (R32Float linear; RGBA8Unorm, RGBA16Unorm, R8Unorm the [0, 1] clamp;
RGBA8Snorm the [-1, 1] clamp; RGBA16Float no clamp), an unbound slot the unbound word, and an
RGBA8Unorm_sRGB texture at slot 3 is Gap::BicubicTexels naming slot 3 and the format.
This commit is contained in:
1 parent
b506518794
commit
6833eba8e2
23 files changed
+474
-58
No files matched your search
@@ -1321,6 +1321,13 @@ made, with no lock, and never rewritten for layouts.
|
||||
changes: its read would answer the texel unswizzled, where Metal reads it through the swizzle. A texture's
|
||||
own descriptor takes a swizzle only without shader-write and render-target usage
|
||||
(`Refusal::TextureSwizzleWithWrites`), so this reaches views alone.
|
||||
- A kernel samples a 2D texture slot through a bicubic constexpr sampler at normalized
|
||||
coordinates by the arm its slot's pushed word selects, which the runtime writes from the bound
|
||||
texture's format and swizzle (`metal2vulkan::metal::format::bicubic_texels_word`). A dispatch
|
||||
whose slot holds a texture of a format with no such word (a compressed, YUV, stencil, integer
|
||||
or extended-range format, or one of 8-bit sRGB codes such as `RGBA8Unorm_sRGB`, whose taps
|
||||
Metal filters decoded) is `Gap::BicubicTexels`, naming the slot and the format, found when the
|
||||
pipeline state or a binding changes: each such format's arm is built when a guest binds one.
|
||||
- An opaque-black border sampled through a view whose component mapping is not the identity (a
|
||||
swizzle, or the mapping a pixel format takes: `A8Unorm` is held in `R8_UNORM` read through
|
||||
`(0, 0, 0, r)` on every device, as rt uses Vulkan 1.3 and does not enable
|
||||
@@ -2246,6 +2253,10 @@ or does not check is rebuilt from the generations' names, with young counted ful
|
||||
- a sample, gather or comparison of an argument buffer's texture, and a depth texture of one
|
||||
both compared and sampled without comparison: no test yet;
|
||||
- an argument buffer's sampler, and an array of samplers: no test yet;
|
||||
- a bicubic sample of a 1D texture or at pixel coordinates ("a bicubic filter of a 1D texture
|
||||
or at pixel coordinates, or a two-plane texture's linear sample read in place"): the
|
||||
translator test
|
||||
`a_bicubic_kernel_reads_each_slots_format_treatment_from_its_pushed_field` asserts it;
|
||||
- an argument buffer's texture of a type the identity arrays hold no element of (a texture
|
||||
buffer, a cube read as an array, level views, a two-plane, extended-range, RGBX or `ulong`
|
||||
form, or a storage texture with a format), one read through another numeric type than its
|
||||
|
||||
@@ -20,7 +20,7 @@ use crate::ring::CHUNK;
|
||||
use crate::sampler::SamplerState;
|
||||
use crate::texture::{Region, Texture, TextureObject};
|
||||
use ash::vk;
|
||||
use metal2vulkan::metal::format::integer_channels_word;
|
||||
use metal2vulkan::metal::format::{integer_channels_word, BICUBIC_TEXELS_UNBOUND};
|
||||
use metal2vulkan::metal::PixelFormat;
|
||||
use metal2vulkan::pipeline::{
|
||||
grid_tile, nonuniform_region_bytes, region_bytes, DEEP_THREADGROUP, GRID_TILE_THREADS,
|
||||
@@ -844,7 +844,7 @@ impl ComputeCommandEncoder {
|
||||
/// Err: [`Refusal::NoPipeline`]; [`Refusal::ThreadgroupSize`] past Metal's limit for the
|
||||
/// kernel; [`Limit::ThreadgroupThreads`] within it and past this device's;
|
||||
/// [`Refusal::BufferOffsetAlignment`] for a buffer the kernel reaches bound off its argument's
|
||||
/// alignment, which nothing records; [`Gap::SwizzledReadWrite`];
|
||||
/// alignment, which nothing records; [`Gap::SwizzledReadWrite`]; [`Gap::BicubicTexels`];
|
||||
/// [`Limit::ThreadgroupMemory`]; [`Gap::PartialSimdgroups`] for a threadgroup that is not
|
||||
/// whole SIMD groups of a kernel whose tier needs them and that has no emulated module;
|
||||
/// [`Error::Quiesced`] where the device was quiesced before that module was lowered;
|
||||
@@ -957,6 +957,19 @@ impl ComputeCommandEncoder {
|
||||
}
|
||||
}
|
||||
let interface = &inner.whole.interface;
|
||||
// A bicubic sample's texture, of a format the filter's treatment is known for.
|
||||
for field in &interface.fields {
|
||||
if let FieldValue::BicubicTexels(slot) = field.value {
|
||||
if let Some(Some(texture)) = self.textures.get(slot as usize) {
|
||||
if texture.bicubic_texels().is_none() {
|
||||
return Err(Error::Unsupported(Gap::BicubicTexels {
|
||||
slot,
|
||||
pixel_format: texture.descriptor().pixel_format,
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for &(slot, access) in &interface.textures {
|
||||
let read = interface.storage_reads.contains(&slot);
|
||||
let stored = access != Access::Read || read;
|
||||
@@ -1409,6 +1422,16 @@ impl Parameters {
|
||||
};
|
||||
bytes[at..at + 4].copy_from_slice(&word.to_le_bytes());
|
||||
}
|
||||
// A texture of no bicubic treatment was refused at the dispatch's checks.
|
||||
FieldValue::BicubicTexels(slot) => {
|
||||
let word = match textures.get(slot as usize) {
|
||||
Some(Some(texture)) => {
|
||||
texture.bicubic_texels().unwrap_or(BICUBIC_TEXELS_UNBOUND)
|
||||
}
|
||||
_ => BICUBIC_TEXELS_UNBOUND,
|
||||
};
|
||||
bytes[at..at + 4].copy_from_slice(&word.to_le_bytes());
|
||||
}
|
||||
FieldValue::ConstexprSampler(place) => {
|
||||
let index = sampler_ids.get(place).copied().unwrap_or(0);
|
||||
bytes[at..at + 4].copy_from_slice(&index.to_le_bytes());
|
||||
@@ -1430,6 +1453,15 @@ impl Parameters {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
impl ComputeCommandEncoder {
|
||||
/// The push bytes the encoder's last dispatch filled, which `tests::bicubic` reads its
|
||||
/// fields' words from.
|
||||
pub(crate) fn pushed(&self) -> &[u8] {
|
||||
&self.parameters.push
|
||||
}
|
||||
}
|
||||
|
||||
/// A dispatch's parameters: the push window's bytes, and the ring block's with where its address
|
||||
/// goes in the window.
|
||||
#[derive(Default)]
|
||||
|
||||
@@ -1187,6 +1187,23 @@ pub enum Gap {
|
||||
/// The texture's pixel format.
|
||||
pixel_format: PixelFormat,
|
||||
},
|
||||
/// A dispatch whose kernel samples texture slot `slot` through a constexpr sampler with
|
||||
/// Metal's bicubic filter (`filter::bicubic`), where the texture bound there is of a pixel
|
||||
/// format whose treatment under that filter the runtime does not establish: a format of no
|
||||
/// family Metal's bicubic filter was measured on (compressed, YUV, stencil, integer and
|
||||
/// extended-range formats), or of 8-bit sRGB codes, whose taps the filter sums decoded. The
|
||||
/// function reads how the filter treats the bound format's texels (its inner taps, its clamp
|
||||
/// and its border texels) from a field the runtime writes from the bound texture
|
||||
/// (`metal2vulkan::metal::format::bicubic_texels_word`). Found when the pipeline state or a
|
||||
/// binding changes.
|
||||
///
|
||||
/// Basis: ours (each refused format's treatment is built when a guest binds one).
|
||||
BicubicTexels {
|
||||
/// The kernel's texture slot.
|
||||
slot: u32,
|
||||
/// The bound texture's pixel format.
|
||||
pixel_format: PixelFormat,
|
||||
},
|
||||
/// [`Texture::new_texture_view`](crate::Texture::new_texture_view) of a kind Metal makes and
|
||||
/// the runtime does not build: what `kind` names.
|
||||
///
|
||||
@@ -2180,6 +2197,11 @@ impl fmt::Display for Gap {
|
||||
useResource declared a write of a {pixel_format:?} texture with no storage \
|
||||
element on this device, is not built"
|
||||
),
|
||||
Gap::BicubicTexels { slot, pixel_format } => write!(
|
||||
f,
|
||||
"texture slot {slot}, which a kernel samples through a bicubic filter, bound to a \
|
||||
{pixel_format:?} texture, whose bicubic sample is not built"
|
||||
),
|
||||
Gap::RenderPipeline { kind } => {
|
||||
write!(f, "a render pipeline state with {kind:?} is not built")
|
||||
}
|
||||
|
||||
@@ -629,6 +629,11 @@ pub(crate) enum FieldValue {
|
||||
/// A `u32`: the channel widths of the texture bound at the slot, as an integer write
|
||||
/// saturates to them (`metal::format::integer_channels_word`), 0 where none is.
|
||||
IntegerChannels(u32),
|
||||
/// A `u32`: how Metal's bicubic filter treats the texels of the texture bound at the slot
|
||||
/// (`metal::format::bicubic_texels_word`, under the swizzle it is sampled through),
|
||||
/// `metal::format::BICUBIC_TEXELS_UNBOUND` where none is; a texture of a format with no
|
||||
/// such treatment is refused at the dispatch ([`Gap::BicubicTexels`]).
|
||||
BicubicTexels(u32),
|
||||
/// A `u32`: the sampler index the consumer gave the constexpr sampler at this place of the
|
||||
/// state's numbered samplers (a render state's: the vertex function's, then the fragment
|
||||
/// function's).
|
||||
@@ -1150,6 +1155,14 @@ fn interface(
|
||||
}),
|
||||
_,
|
||||
) => FieldValue::IntegerChannels(index),
|
||||
(
|
||||
PushField::BicubicTexels(SlotRef {
|
||||
stage: Stage::Kernel,
|
||||
class: SlotClass::Texture,
|
||||
index,
|
||||
}),
|
||||
_,
|
||||
) => FieldValue::BicubicTexels(index),
|
||||
(PushField::ConstexprSampler(sampler), _) => {
|
||||
let SamplerRef::Constexpr(words) = sampler.sampler else {
|
||||
return Err(gap());
|
||||
|
||||
@@ -2606,8 +2606,11 @@ fn fill_push(
|
||||
.map_or(0, |target| target.texture.second_resource_id().index);
|
||||
bytes[at..at + 4].copy_from_slice(&index.to_le_bytes());
|
||||
}
|
||||
// A render content has no dispatch or stage-in region (`render::draws`).
|
||||
FieldValue::DispatchRegion | FieldValue::StageInRegion => {}
|
||||
// A render content has no dispatch or stage-in region, and no bicubic slot's field
|
||||
// (`render::draws`).
|
||||
FieldValue::DispatchRegion
|
||||
| FieldValue::StageInRegion
|
||||
| FieldValue::BicubicTexels(_) => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
//! A kernel that samples 2D textures through a bicubic constexpr sampler at normalized
|
||||
//! coordinates (the owned fixture `engine/bcu_formats`, ten slots, the last two with `half`
|
||||
//! results), under a device cfg on every device of the cfg's kind. Each dispatch pushes, for each
|
||||
//! slot, how Metal's bicubic filter treats the format bound there, which selects the filter's arm
|
||||
//! at run time: the linear inner taps for `R32Float`, a clamp to [0, 1] for `RGBA8Unorm`,
|
||||
//! `RGBA16Unorm` and `R8Unorm`, a clamp to [-1, 1] for `RGBA8Snorm`, and no clamp for
|
||||
//! `RGBA16Float`. Each format is bound at every slot over six dispatches; a slot bound to nothing
|
||||
//! pushes the unbound word. A dispatch whose slot holds an `RGBA8Unorm_sRGB` texture is refused,
|
||||
//! naming the slot and the format. The command buffer is never committed.
|
||||
//!
|
||||
//! `llvm-as` assembles the kernel; without it the test skips visibly.
|
||||
|
||||
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
|
||||
mod on_device {
|
||||
use crate::pipeline::{FieldValue, Place};
|
||||
use crate::tests::command::on_device::each_device;
|
||||
use crate::tests::draw::on_device::Buffers;
|
||||
use crate::{
|
||||
ComputePipelineDescriptor, DispatchType, Error, FunctionDescriptor, Gap, IndexClass,
|
||||
Library, NumberedSampler, PixelFormat, StageSource, Texture, TextureDescriptor,
|
||||
TextureType, TextureUsage,
|
||||
};
|
||||
use metal2vulkan::metal::format::{bicubic_texels_word, BICUBIC_TEXELS_UNBOUND};
|
||||
use metal2vulkan::metal::TextureSwizzleChannels;
|
||||
use metal2vulkan_devtools::{engine_dir, llvm_assemble, AssembleError};
|
||||
|
||||
/// The kernel's texture slots.
|
||||
const SLOTS: usize = 10;
|
||||
/// The constexpr sampler's index the test gives the kernel.
|
||||
const CONSTEXPR: u32 = 1;
|
||||
|
||||
/// The filter's arm, the word's low four bits (`metal::bicubic::BicubicTexels`): the linear
|
||||
/// inner taps, a clamp to [0, 1], a clamp to [-1, 1], and no clamp.
|
||||
const LINEAR: u32 = 1 << 0;
|
||||
const UNORM: u32 = 1 << 1;
|
||||
const SNORM: u32 = 1 << 2;
|
||||
const HALF: u32 = 1 << 3;
|
||||
|
||||
/// Each format the test binds, with its arm.
|
||||
const ARMS: [(PixelFormat, u32); 6] = [
|
||||
(PixelFormat::R32Float, LINEAR),
|
||||
(PixelFormat::RGBA8Unorm, UNORM),
|
||||
(PixelFormat::RGBA8Snorm, SNORM),
|
||||
(PixelFormat::RGBA16Float, HALF),
|
||||
(PixelFormat::RGBA16Unorm, UNORM),
|
||||
(PixelFormat::R8Unorm, UNORM),
|
||||
];
|
||||
|
||||
/// A 2D texture of `format`, 4 texels a side, of shader-read usage at `index`.
|
||||
fn texture(name: &str, device: &crate::Device, format: PixelFormat, index: u32) -> Texture {
|
||||
let mut d = TextureDescriptor::new(TextureType::Type2D, format, 4, 4);
|
||||
d.usage = TextureUsage::SHADER_READ;
|
||||
(device.new_texture(&d, Some(index))).unwrap_or_else(|error| panic!("{name}: {error}"))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_device_pushes_each_bicubic_slots_format_treatment() {
|
||||
let library = match llvm_assemble(&engine_dir().join("bcu_formats.ll")) {
|
||||
Ok(bitcode) => Library::from_air(&bitcode).expect("the library"),
|
||||
Err(AssembleError::Missing(why)) => {
|
||||
eprintln!("SKIPPED: {why}");
|
||||
return;
|
||||
}
|
||||
Err(error) => panic!("bcu_formats.ll: {error:?}"),
|
||||
};
|
||||
let function = library.function("bcu_formats").expect("the kernel");
|
||||
let descriptor = ComputePipelineDescriptor::new(StageSource::Function(
|
||||
FunctionDescriptor::new(function),
|
||||
));
|
||||
each_device("bicubic_texels", |name, _, device| {
|
||||
let _grants = [
|
||||
(IndexClass::Texture, 1, ARMS.len() as u32 + 1),
|
||||
(IndexClass::Sampler, CONSTEXPR, 1),
|
||||
]
|
||||
.map(|(class, first, count)| {
|
||||
(device.grant_indices(class, first, count))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"))
|
||||
});
|
||||
let state = device
|
||||
.new_compute_pipeline_state(&descriptor, |samplers| {
|
||||
assert!(
|
||||
matches!(samplers, [NumberedSampler::Constexpr(_)]),
|
||||
"{name}: {samplers:?}"
|
||||
);
|
||||
Ok(vec![CONSTEXPR])
|
||||
})
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
// Each slot's field, in the push window.
|
||||
let mut at = [None; SLOTS];
|
||||
for field in &state.inner.compiled.whole.interface.fields {
|
||||
if let FieldValue::BicubicTexels(slot) = field.value {
|
||||
let Place::Push(offset) = field.place else {
|
||||
panic!("{name}: slot {slot}'s field in a parameter block");
|
||||
};
|
||||
assert!(
|
||||
at[slot as usize].replace(offset as usize).is_none(),
|
||||
"{name}"
|
||||
);
|
||||
}
|
||||
}
|
||||
let at = at.map(|at| at.unwrap_or_else(|| panic!("{name}: a slot with no field")));
|
||||
let textures: Vec<Texture> = (ARMS.iter().zip(1..))
|
||||
.map(|(&(format, _), index)| texture(name, &device, format, index))
|
||||
.collect();
|
||||
let srgb = texture(
|
||||
name,
|
||||
&device,
|
||||
PixelFormat::RGBA8UnormSRGB,
|
||||
ARMS.len() as u32 + 1,
|
||||
);
|
||||
let mut buffers = Buffers::new(&device);
|
||||
let (coords, out) = (
|
||||
buffers.of(&device, &[0; 64]),
|
||||
buffers.of(&device, &[0; 4096]),
|
||||
);
|
||||
let queue = device.new_command_queue(1).expect("a queue");
|
||||
let command_buffer = queue.command_buffer().expect("a command buffer");
|
||||
let mut encoder = (command_buffer.compute_command_encoder(DispatchType::Serial))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let call = |result: Result<(), Error>| result.unwrap_or_else(|e| panic!("{name}: {e}"));
|
||||
call(encoder.set_compute_pipeline_state(&state));
|
||||
call(encoder.set_buffer(Some(&coords), 0, 0));
|
||||
call(encoder.set_buffer(Some(&out), 0, 1));
|
||||
// Dispatch `d` binds format `(d + k) mod 6` at slot `k`, and nothing at the last slot
|
||||
// in the first dispatch.
|
||||
for d in 0..ARMS.len() {
|
||||
for (slot, k) in (0..SLOTS).zip(d..) {
|
||||
let texture = (d, slot) != (0, SLOTS - 1);
|
||||
let texture = texture.then(|| &textures[k % ARMS.len()]);
|
||||
call(encoder.set_texture(texture, slot as u32));
|
||||
}
|
||||
call(encoder.dispatch_threads([4, 1, 1], [4, 1, 1]));
|
||||
let push = encoder.pushed().to_vec();
|
||||
for (slot, k) in (0..SLOTS).zip(d..) {
|
||||
let word = u32::from_le_bytes(push[at[slot]..at[slot] + 4].try_into().unwrap());
|
||||
if (d, slot) == (0, SLOTS - 1) {
|
||||
assert_eq!(word, BICUBIC_TEXELS_UNBOUND, "{name}: slot {slot}, unbound");
|
||||
continue;
|
||||
}
|
||||
let (format, arm) = ARMS[k % ARMS.len()];
|
||||
let want = bicubic_texels_word(format, TextureSwizzleChannels::DEFAULT);
|
||||
assert_eq!(
|
||||
(word & 0xf, Some(word)),
|
||||
(arm, want),
|
||||
"{name}: slot {slot}, {format:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
// An sRGB texture at slot 3 is refused, the slot and the format named.
|
||||
call(encoder.set_texture(Some(&srgb), 3));
|
||||
let refused = encoder.dispatch_threads([4, 1, 1], [4, 1, 1]);
|
||||
let Err(Error::Unsupported(gap)) = refused else {
|
||||
panic!("{name}: an sRGB texture's bicubic sample: {refused:?}");
|
||||
};
|
||||
assert_eq!(
|
||||
gap,
|
||||
Gap::BicubicTexels {
|
||||
slot: 3,
|
||||
pixel_format: PixelFormat::RGBA8UnormSRGB
|
||||
},
|
||||
"{name}"
|
||||
);
|
||||
let text = gap.to_string();
|
||||
assert!(
|
||||
text.contains("texture slot 3") && text.contains("RGBA8UnormSRGB"),
|
||||
"{name}: {text}"
|
||||
);
|
||||
encoder.end_encoding();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ mod ahead;
|
||||
mod alpha_test;
|
||||
mod argument_tier;
|
||||
mod arrays;
|
||||
mod bicubic;
|
||||
mod blit;
|
||||
mod border;
|
||||
mod cache;
|
||||
|
||||
@@ -54,7 +54,7 @@ use crate::staging::Stage;
|
||||
use crate::submit::Held;
|
||||
use ash::vk;
|
||||
use metal2vulkan::device::FormatUsage;
|
||||
use metal2vulkan::metal::format::{self as formats, FormatEmulation};
|
||||
use metal2vulkan::metal::format::{self as formats, bicubic_texels_word, FormatEmulation};
|
||||
use metal2vulkan::metal::resource_word::TextureWord;
|
||||
use metal2vulkan::metal::{
|
||||
PixelFormat, TextureSwizzle, TextureSwizzleChannels, TextureType, TextureUsage,
|
||||
@@ -4282,6 +4282,13 @@ pub(crate) trait TextureObject {
|
||||
TextureInner::reads(self.object()) != TextureSwizzleChannels::DEFAULT
|
||||
}
|
||||
|
||||
/// How Metal's bicubic filter treats its texels, under the swizzle it is sampled through
|
||||
/// (`metal::format::bicubic_texels_word`): `None` for a format with no such treatment.
|
||||
pub(crate) fn bicubic_texels(&self) -> Option<u32> {
|
||||
let inner = self.object();
|
||||
bicubic_texels_word(inner.descriptor.pixel_format, inner.reads())
|
||||
}
|
||||
|
||||
/// Whether the host reads the GPU's writes to it with no copy: a texture in place over a
|
||||
/// Shared buffer.
|
||||
fn host_reads(&self) -> bool {
|
||||
|
||||
@@ -1785,8 +1785,11 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
// The bound buffer's bytes before its bind offset and its length, which
|
||||
// instantiation reads from the state.
|
||||
PushField::SlotBounds(slot) if planned(slot).is_some() => {}
|
||||
// The identity domains' zero range is the new runtime's own memory.
|
||||
PushField::ZeroAddress => return Err(not_implemented(Feature::IdentityDomains)),
|
||||
// The identity domains' zero range is the new runtime's own memory, and their
|
||||
// bicubic slot's format treatment the new runtime's own field.
|
||||
PushField::ZeroAddress | PushField::BicubicTexels(_) => {
|
||||
return Err(not_implemented(Feature::IdentityDomains))
|
||||
}
|
||||
PushField::SlotBindOffset(SlotRef {
|
||||
class: SlotClass::Texture,
|
||||
..
|
||||
|
||||
@@ -452,8 +452,11 @@ fn plan(p: &ComputePipeline, device: &Device, shape: &BindShape) -> Result<Bindi
|
||||
// The bound buffer's bytes before its bind offset and its length, which instantiation
|
||||
// reads from the state.
|
||||
PushField::SlotBounds(slot) if planned(slot).is_some() => {}
|
||||
// The identity domains' zero range is the new runtime's own memory.
|
||||
PushField::ZeroAddress => return Err(not_implemented(Feature::IdentityDomains)),
|
||||
// The identity domains' zero range is the new runtime's own memory, and their bicubic
|
||||
// slot's format treatment the new runtime's own field.
|
||||
PushField::ZeroAddress | PushField::BicubicTexels(_) => {
|
||||
return Err(not_implemented(Feature::IdentityDomains))
|
||||
}
|
||||
PushField::SlotBindOffset(SlotRef {
|
||||
class: SlotClass::Texture,
|
||||
..
|
||||
|
||||
+1
@@ -908,6 +908,7 @@ codec_enum! {
|
||||
StorageKeptChannels,
|
||||
ShaderStencilState,
|
||||
TextureIntegerChannels(f0),
|
||||
BicubicTexels(f0),
|
||||
Specialized(f0),
|
||||
HalfBlendColor,
|
||||
SnapshotPhase,
|
||||
|
||||
Vendored
+2
-2
@@ -62,7 +62,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 = 2199;
|
||||
pub const SEMANTICS_VERSION: u32 = 2200;
|
||||
|
||||
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
|
||||
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
|
||||
@@ -72,7 +72,7 @@ pub const SEMANTICS_VERSION: u32 = 2199;
|
||||
/// 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 = 554;
|
||||
pub const ARTIFACT_FORMAT_VERSION: u32 = 555;
|
||||
|
||||
/// 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
|
||||
|
||||
@@ -166,9 +166,11 @@ pub const fn shape(f: PushField) -> FieldShape {
|
||||
PushField::ZeroAddress => FieldShape::U64,
|
||||
// A texture's mipmap level count, an acceleration structure's instance count, the render
|
||||
// encoder's viewport count, the render pass's array length, a kernel stage-in buffer's
|
||||
// bound stride, a storage texture's integer channels' widths.
|
||||
// bound stride, a storage texture's integer channels' widths, a bicubic slot's format
|
||||
// treatment.
|
||||
PushField::TextureLevels(_)
|
||||
| PushField::TextureIntegerChannels(_)
|
||||
| PushField::BicubicTexels(_)
|
||||
| PushField::InstanceCount(_)
|
||||
| PushField::ViewportCount
|
||||
| PushField::RenderTargetArrayLength
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
//! `clamp_to_zero` reads the border color too). The level is always the base level (Metal's bicubic
|
||||
//! sampler has no mip filter, so the level, bias, gradients, and fragment derivatives select
|
||||
//! nothing), a 2D array's layer is clamped into the array, and what is done with the sum depends on
|
||||
//! the bound format: the [`SpecKey::BicubicTexels`] specialization of the texture slot selects the
|
||||
//! bilinear inner 2x2 instead (32-bit float channels), clamps the sum into `[0, 1]` or `[-1, 1]`
|
||||
//! (normalized channels), or rounds it to `half` (half and small-float channels). A 1D texture is
|
||||
//! filtered bilinearly over taps `i` and `i + 1` whatever its format, with the same fraction.
|
||||
//! the bound format: the [`SpecKey::BicubicTexels`] specialization of the texture slot (under the
|
||||
//! identity domains the same bits, read at run time from the slot's `PushField::BicubicTexels`)
|
||||
//! selects the bilinear inner 2x2 instead (32-bit float channels), clamps the sum into `[0, 1]` or
|
||||
//! `[-1, 1]` (normalized channels), or rounds it to `half` (half and small-float channels). A 1D
|
||||
//! texture is filtered bilinearly over taps `i` and `i + 1` whatever its format, with the same
|
||||
//! fraction.
|
||||
//!
|
||||
//! **Small levels and mirrored axes** (Apple M3 Max, macOS 26.7, the primary Metal reference; the
|
||||
//! probes probes, every lane of each run with and without Metal's validation layer,
|
||||
@@ -89,7 +91,7 @@ use crate::lower::texture::{OffsetBase, TexelConv};
|
||||
use crate::metal::bicubic::BicubicTexels;
|
||||
use crate::metal::sampler::SamplerWord;
|
||||
use crate::metal::{SamplerAddressMode, SamplerBorderColor};
|
||||
use crate::pipeline::sym::SamplerRef;
|
||||
use crate::pipeline::sym::{PushField, SamplerRef};
|
||||
use crate::spirv::builder::FunctionBuilder;
|
||||
use crate::spirv::error::{BResult, BuildError, OperandRule};
|
||||
use crate::spirv::ids::{ConstId, TypeId, Value as SValue};
|
||||
@@ -124,7 +126,8 @@ pub enum TapAddress {
|
||||
/// docs state.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct Bicubic {
|
||||
/// The texture slot whose `BicubicTexels` specialization states the bound format's treatment.
|
||||
/// The texture slot whose `BicubicTexels` specialization (under the identity domains, push
|
||||
/// field) states the bound format's treatment.
|
||||
pub texture: u32,
|
||||
/// The addressing of each plane axis (`s`, then `t` for a 2D texture).
|
||||
pub address: Vec<TapAddress>,
|
||||
@@ -1277,11 +1280,22 @@ pub(super) fn emit(
|
||||
image: CombinedImage,
|
||||
b: &Bicubic,
|
||||
) -> BResult<SValue> {
|
||||
let Some(&spec) = cx.decl.families.sampler.bicubic.get(&b.texture) else {
|
||||
return Err(cx.fail(format!(
|
||||
"texture slot {} has no bicubic specialization",
|
||||
b.texture
|
||||
)));
|
||||
let bits = match cx.decl.families.sampler.bicubic.get(&b.texture) {
|
||||
Some(&spec) => Bits::Spec(spec),
|
||||
// Under the identity domains the slot's push field, which the consumer writes from the
|
||||
// bound texture.
|
||||
None if cx.plan.families.access.identity => {
|
||||
let Some(slot) = cx.plan.families.texture.slots.get(&b.texture) else {
|
||||
return Err(cx.fail(format!("texture slot {} is not planned", b.texture)));
|
||||
};
|
||||
Bits::Value(cx.push_field(fb, PushField::BicubicTexels(slot.slot))?)
|
||||
}
|
||||
None => {
|
||||
return Err(cx.fail(format!(
|
||||
"texture slot {} has no bicubic specialization",
|
||||
b.texture
|
||||
)))
|
||||
}
|
||||
};
|
||||
let half = half_result(cx, s)?;
|
||||
let t = Tys::new(fb)?;
|
||||
@@ -1291,7 +1305,6 @@ pub(super) fn emit(
|
||||
let zero_u = fb.u32_const(0)?;
|
||||
let zero_u = value(fb, zero_u)?;
|
||||
let size = fb.query(ImageQuery::SizeLod(zero_u), img)?;
|
||||
let bits = Bits::Spec(spec);
|
||||
let fp = footprint_on(cx, fb, &t, s, (size, image), bits, &taps)?;
|
||||
let x = filter(cx, fb, (&t, &fp, size), b, bits, Texels::Own(img))?;
|
||||
narrowed(fb, x, half)
|
||||
|
||||
@@ -1243,8 +1243,11 @@ pub struct SamplerPlan {
|
||||
/// The use each one's binding is made for, set by [`finish`]: one binding per distinct array
|
||||
/// and use.
|
||||
pub heap_array_decls: BTreeMap<HeapArrayKey, SamplerUse>,
|
||||
/// The texture slots a bicubic sample reads, each with its `BicubicTexels` specialization.
|
||||
/// The texture slots a bicubic sample reads, each with its `BicubicTexels` specialization,
|
||||
/// or under the identity domains its `PushField::BicubicTexels` field.
|
||||
pub bicubic: BTreeSet<u32>,
|
||||
/// A bicubic sample reads pixel coordinates.
|
||||
pub bicubic_pixel: bool,
|
||||
/// The bicubic routines the samples call, by dimension, an extended-range sample's among them.
|
||||
pub bicubic_routines: BTreeSet<bicubic::routines::Routine>,
|
||||
/// A sample relies on the device's sampler: the module requires `VkProperty::MetalSampler`
|
||||
@@ -1336,7 +1339,8 @@ pub struct Declared {
|
||||
/// sample at its texel's centre reads ([`PixelPosition::TexelBySpec`]).
|
||||
pub nearest: BTreeMap<u32, SValue>,
|
||||
/// The `BicubicTexels` specialization constant (`u32`) of each texture slot a bicubic sample
|
||||
/// reads.
|
||||
/// reads; none under the identity domains, where the sample reads the slot's
|
||||
/// `PushField::BicubicTexels`.
|
||||
pub bicubic: BTreeMap<u32, ConstId>,
|
||||
/// The 2D bicubic samples' routine, when the module has one.
|
||||
pub bicubic_plane: Option<bicubic::routines::Plane>,
|
||||
@@ -1536,7 +1540,9 @@ pub fn finish(cx: &mut SelectCx<'_>) -> Result<(), Error> {
|
||||
SamplerUse::new(key.compare, texel != TexelClass::Float),
|
||||
);
|
||||
}
|
||||
// The bound format's treatment under the bicubic filter.
|
||||
// The bound format's treatment under the bicubic filter: a specialization the binder sets, or
|
||||
// under the identity domains a push field the consumer writes from the bound texture, as for
|
||||
// any slot's push field.
|
||||
for index in &cx.families.sampler.bicubic {
|
||||
let s = cx
|
||||
.families
|
||||
@@ -1544,7 +1550,12 @@ pub fn finish(cx: &mut SelectCx<'_>) -> Result<(), Error> {
|
||||
.slots
|
||||
.get(index)
|
||||
.ok_or_else(|| invariant("a bicubic sample of an unplanned texture slot"))?;
|
||||
cx.facts.insert(RuntimeFact::BicubicTexels { slot: s.slot });
|
||||
if crate::lower::access::identity(cx.profile) {
|
||||
cx.push
|
||||
.insert(crate::pipeline::sym::PushField::BicubicTexels(s.slot));
|
||||
} else {
|
||||
cx.facts.insert(RuntimeFact::BicubicTexels { slot: s.slot });
|
||||
}
|
||||
}
|
||||
// Under the identity domains a runtime sampler slot's resource ID is pushed, and the shader
|
||||
// reads the sampler's word from it (`emit::sampler_word`): the consumer makes the device's
|
||||
@@ -1816,7 +1827,9 @@ pub fn declare(
|
||||
d.nearest.insert(*n, mb.const_value(c)?);
|
||||
}
|
||||
}
|
||||
for index in &plan.families.sampler.bicubic {
|
||||
// Under the identity domains a bicubic sample reads its slot's push field instead
|
||||
// (`bicubic::emit`).
|
||||
for index in plan.families.sampler.bicubic.iter().filter(|_| !identity) {
|
||||
let Some(s) = plan.families.texture.slots.get(index) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
@@ -2400,6 +2400,7 @@ fn select_one(
|
||||
}
|
||||
if let SampleOp::Bicubic(b) = &op {
|
||||
cx.families.sampler.bicubic.insert(b.texture);
|
||||
cx.families.sampler.bicubic_pixel |= b.pixel;
|
||||
// A 2D sample's level below four texels on an axis takes the linear 2D routines.
|
||||
let routines: &[_] = if shape.dim == ImageDim::D1 {
|
||||
&[super::bicubic::routines::Routine::Line]
|
||||
|
||||
@@ -1971,6 +1971,7 @@ fn identity_refusal(plan: &Plan, p: &DeviceProfile) -> Option<String> {
|
||||
| PushField::ZeroAddress
|
||||
| PushField::DispatchRegion
|
||||
| PushField::TextureIntegerChannels(_)
|
||||
| PushField::BicubicTexels(_)
|
||||
| PushField::ConstexprSampler(_)
|
||||
| PushField::StageInRegion
|
||||
| PushField::VertexBufferStride(_)
|
||||
@@ -2054,9 +2055,11 @@ fn identity_refusal(plan: &Plan, p: &DeviceProfile) -> Option<String> {
|
||||
));
|
||||
}
|
||||
// Samples only of a texture slot through a runtime sampler slot or a constexpr sampler
|
||||
// (`sampler::IdentitySampling`), a runtime sampler's word read from its resource ID: no
|
||||
// argument buffer's sampler, array of samplers, bicubic filter or specialization of a slot's
|
||||
// state.
|
||||
// (`sampler::IdentitySampling`), a runtime sampler's word read from its resource ID, and a 2D
|
||||
// texture slot's bicubic sample at normalized coordinates, the bound format's treatment read
|
||||
// from its push field (`PushField::BicubicTexels`): no argument buffer's sampler, array of
|
||||
// samplers, bicubic sample of a 1D texture or at pixel coordinates, two-plane texture's linear
|
||||
// sample read in place, or specialization of a slot's state.
|
||||
let sampled = &plan.families.sampler;
|
||||
let refused = [
|
||||
(
|
||||
@@ -2077,8 +2080,11 @@ fn identity_refusal(plan: &Plan, p: &DeviceProfile) -> Option<String> {
|
||||
"an array of samplers",
|
||||
),
|
||||
(
|
||||
!sampled.bicubic.is_empty() || !sampled.bicubic_routines.is_empty(),
|
||||
"a bicubic filter",
|
||||
sampled.bicubic_pixel
|
||||
|| (sampled.bicubic_routines.iter())
|
||||
.any(|r| *r != crate::lower::sampler::bicubic::routines::Routine::Plane),
|
||||
"a bicubic filter of a 1D texture or at pixel coordinates, or a two-plane texture's \
|
||||
linear sample read in place",
|
||||
),
|
||||
(
|
||||
(sampled.slots.values()).any(|r| r.min_level || r.emulated),
|
||||
|
||||
@@ -2161,6 +2161,29 @@ pub fn integer_channels_word(pf: PixelFormat) -> u32 {
|
||||
})
|
||||
}
|
||||
|
||||
/// The word `PushField::BicubicTexels` carries for a texture of pixel format `pf` sampled
|
||||
/// through swizzle `swizzle` (the texture's own over its parent's, for a view): how Metal's
|
||||
/// bicubic filter treats its texels, the value the binder specializes `SpecKey::BicubicTexels`
|
||||
/// to for such a texture. Its bits select the bilinear inner taps (32-bit float channels), the
|
||||
/// clamp into `[0, 1]` or `[-1, 1]` (normalized channels) or neither (half and small-float
|
||||
/// channels), and the border texels of the format's channels under `swizzle`.
|
||||
///
|
||||
/// `None` for a format of no measured family (compressed, YUV, stencil, integer and
|
||||
/// extended-range formats), whose bicubic sample Metal does not establish, and for a format of
|
||||
/// 8-bit sRGB codes, whose decode before the sum the identity domains do not establish (the
|
||||
/// binder's form of a texture held as its UNORM twin decodes the codes a UNORM view reads): a
|
||||
/// consumer refuses a bicubic sample of such a texture.
|
||||
pub fn bicubic_texels_word(pf: PixelFormat, swizzle: TextureSwizzleChannels) -> Option<u32> {
|
||||
if crate::metal::texel_format::srgb_coded(pf) {
|
||||
return None;
|
||||
}
|
||||
crate::metal::bicubic::texels(pf).map(|t| t.with_border(pf, swizzle).0)
|
||||
}
|
||||
|
||||
/// The word `PushField::BicubicTexels` carries for a slot bound to nothing, whose neutral texture
|
||||
/// reads zero: every channel present, the sum unchanged, a four-channel format's border texels.
|
||||
pub const BICUBIC_TEXELS_UNBOUND: u32 = crate::metal::bicubic::BicubicTexels::NEUTRAL.0;
|
||||
|
||||
/// The class of pixel format `pf` (`metal::texel_format::TexelFormat`'s word, as its `half`
|
||||
/// conversion takes it): the value a specialized note's test of
|
||||
/// `SpecKey::BoundTexelFormat` reads for a texture of `pf` bound at its slot
|
||||
|
||||
@@ -1243,6 +1243,12 @@ pub enum PushField {
|
||||
/// signedness, as Metal stores it (`RuntimeFact::StorageTextureIntegerChannels`, a slot whose
|
||||
/// storage choice declares no format).
|
||||
TextureIntegerChannels(SlotRef),
|
||||
/// Under the identity domains, how Metal's bicubic filter treats the texels of the texture
|
||||
/// bound to the slot (`u32`; `metal::format::bicubic_texels_word`, the bits the binder
|
||||
/// specializes `SpecKey::BicubicTexels` to elsewhere, `metal::format::BICUBIC_TEXELS_UNBOUND`
|
||||
/// where the slot is bound to nothing): a bicubic sample of the slot selects its filter, clamp
|
||||
/// and border texels on it at run time, so one module serves every bound format.
|
||||
BicubicTexels(SlotRef),
|
||||
/// The render encoder's blend color (`setBlendColorRed:green:blue:alpha:`) for a fragment
|
||||
/// function that computes a blend in the shader under a blend that reads it (an
|
||||
/// extended-range attachment's, or a fetched attachment's in the storage form): one `uvec4`
|
||||
|
||||
@@ -58,9 +58,13 @@
|
||||
//! the Iris Xe, which reads storage so by the formats' own bits alone, is declared without a
|
||||
//! format where every read-write tier format has the read bit, and refused where one lacks it;
|
||||
//! `Device::new`'s answer there is unchanged.
|
||||
//! - A kernel that samples through a bicubic constexpr sampler (`engine/a2_bicubic_weights`) is
|
||||
//! still refused as `Unsupported{IdentityDomains}`, not implemented, where the default domains
|
||||
//! compile it.
|
||||
//! - A kernel that samples 2D textures through a bicubic constexpr sampler at normalized
|
||||
//! coordinates (`engine/bcu_formats`, `float` and `half` results) reads how the filter treats
|
||||
//! each slot's bound format from the slot's pushed field (`PushField::BicubicTexels`): no
|
||||
//! specialization constant and no fact, where the default domains specialize
|
||||
//! `SpecKey::BicubicTexels` and state `RuntimeFact::BicubicTexels` as before. It passes L3. A
|
||||
//! bicubic sample of a 1D texture (`engine/bcu_forms`) or at pixel coordinates
|
||||
//! (`engine/bcu_address`) is still refused as `Unsupported{IdentityDomains}`, not implemented.
|
||||
//! - A kernel that encodes compute commands into an indirect command buffer it reaches through an
|
||||
//! argument buffer (`engine/icb_replay_encode`) is refused as
|
||||
//! `Unsupported{GpuEncodedIndirectCommands}`, not implemented: the feature it uses, not the
|
||||
@@ -733,35 +737,98 @@ fn identity_arrays() -> Vec<(u32, vk::DescriptorType, u32)> {
|
||||
]
|
||||
}
|
||||
|
||||
/// A kernel that samples a texture through a bicubic constexpr sampler is not lowered under the
|
||||
/// identity domains yet.
|
||||
/// `bcu_formats`' texture slots: ten 2D textures, the last two sampled with `half` results.
|
||||
fn bicubic_slots() -> BTreeSet<SlotRef> {
|
||||
(0..10)
|
||||
.map(|index| SlotRef {
|
||||
stage: Stage::Kernel,
|
||||
class: SlotClass::Texture,
|
||||
index,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// A kernel that samples 2D textures through a bicubic constexpr sampler at normalized
|
||||
/// coordinates reads how the filter treats each slot's bound format from the slot's push field
|
||||
/// under the identity domains, where the default domains specialize it and state its fact; a
|
||||
/// bicubic sample of a 1D texture or at pixel coordinates is still refused there.
|
||||
#[test]
|
||||
fn a_bicubic_kernel_is_refused_under_the_identity_domains() {
|
||||
let Some(bc) = assemble("a2_bicubic_weights") else {
|
||||
fn a_bicubic_kernel_reads_each_slots_format_treatment_from_its_pushed_field() {
|
||||
use crate::pipeline::artifact::PrecisionNote;
|
||||
let (Some(formats), Some(forms), Some(address)) = (
|
||||
assemble("bcu_formats"),
|
||||
assemble("bcu_forms"),
|
||||
assemble("bcu_address"),
|
||||
) else {
|
||||
return;
|
||||
};
|
||||
let slots = bicubic_slots();
|
||||
for stem in PROFILES {
|
||||
let default = profile(stem, DevicePolicy::default()).unwrap_or_else(|e| panic!("{e}"));
|
||||
compile(&bc, "a2_bicubic_weights", &default)
|
||||
let (a, plan, _) = compile_kept(&formats, "bcu_formats", &default)
|
||||
.unwrap_or_else(|e| panic!("{stem}: default domains: {e}"));
|
||||
let facts: BTreeSet<SlotRef> = (plan.facts.iter())
|
||||
.filter_map(|f| match f {
|
||||
RuntimeFact::BicubicTexels { slot } => Some(*slot),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
let specialized: BTreeSet<SlotRef> = (a.interface.spec.iter())
|
||||
.filter_map(|c| match c.key {
|
||||
SpecKey::BicubicTexels(slot) => Some(slot),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(
|
||||
(&facts, &specialized),
|
||||
(&slots, &slots),
|
||||
"{stem}: default domains"
|
||||
);
|
||||
assert!(
|
||||
!(plan.push.fields.iter()).any(|f| matches!(f.field, PushField::BicubicTexels(_))),
|
||||
"{stem}: default domains"
|
||||
);
|
||||
let p = profile(stem, identity()).unwrap_or_else(|e| panic!("{e}"));
|
||||
match compile(&bc, "a2_bicubic_weights", &p) {
|
||||
Err(Error::Unsupported(u)) => {
|
||||
assert_eq!(
|
||||
let (a, plan, _) =
|
||||
compile_kept(&formats, "bcu_formats", &p).unwrap_or_else(|e| panic!("{stem}: {e}"));
|
||||
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{stem}: L3: {e}"));
|
||||
let pushed: BTreeSet<SlotRef> = (plan.push.fields.iter())
|
||||
.filter_map(|f| match f.field {
|
||||
PushField::BicubicTexels(slot) => Some(slot),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(pushed, slots, "{stem}");
|
||||
assert!(
|
||||
!(a.interface.spec.iter()).any(|c| matches!(c.key, SpecKey::BicubicTexels(_))),
|
||||
"{stem}: {:?}",
|
||||
a.interface.spec
|
||||
);
|
||||
assert!(
|
||||
!(plan.facts.iter()).any(|f| matches!(f, RuntimeFact::BicubicTexels { .. })),
|
||||
"{stem}: {:?}",
|
||||
plan.facts
|
||||
);
|
||||
assert!(
|
||||
a.precision
|
||||
.contains(&PrecisionNote::BicubicFilterArithmetic),
|
||||
"{stem}"
|
||||
);
|
||||
for (bc, entry) in [(&forms, "bcu_forms"), (&address, "bcu_address")] {
|
||||
compile(bc, entry, &default)
|
||||
.unwrap_or_else(|e| panic!("{stem}: {entry}: default domains: {e}"));
|
||||
match compile(bc, entry, &p) {
|
||||
Err(Error::Unsupported(u)) => assert_eq!(
|
||||
(u.feature, u.needs),
|
||||
(Feature::IdentityDomains, Needs::NotImplemented),
|
||||
"{stem}"
|
||||
);
|
||||
"{stem}: {entry}"
|
||||
),
|
||||
other => panic!("{stem}: {entry}: {other:?}"),
|
||||
}
|
||||
other => panic!("{stem}: {other:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// What the identity domains' refusal of argument buffers tier 2's pointer-indexed form names, the
|
||||
/// first form of the gate `ab_indexed` holds (`lower::select`'s `identity_refusal`): the texture
|
||||
/// handle a pointer member's argument buffer holds is read through the root table, whose address
|
||||
/// the identity domains do not push.
|
||||
const POINTER_INDEXED_FORM: &str = "an encoder value the function reads as RootTableAddress";
|
||||
|
||||
/// Argument buffers tier 2's forms under the identity domains (`engine/ab_tier2`): a kernel that
|
||||
|
||||
@@ -1171,6 +1171,7 @@ const metal2vulkan::cache::RUNTIME_VERSION pub const RUNTIME_VERSION: u32
|
||||
const metal2vulkan::cache::SEMANTICS_VERSION pub const SEMANTICS_VERSION: u32
|
||||
const metal2vulkan::cache::SOURCE_DIGEST pub const SOURCE_DIGEST: &str
|
||||
const metal2vulkan::device::NVIDIA_AMPERE_GA10X pub const NVIDIA_AMPERE_GA10X: &[u32]
|
||||
const metal2vulkan::metal::format::BICUBIC_TEXELS_UNBOUND pub const BICUBIC_TEXELS_UNBOUND: u32
|
||||
const metal2vulkan::metal::sampler::NOT_MIPMAPPED_MAX_LOD pub const NOT_MIPMAPPED_MAX_LOD: f32
|
||||
const metal2vulkan::metal::vertex::MAX_VERTEX_ALIGNMENT pub const MAX_VERTEX_ALIGNMENT: u32
|
||||
const metal2vulkan::pipeline::DEEP_THREADGROUP pub const DEEP_THREADGROUP: u32
|
||||
@@ -1276,6 +1277,7 @@ const-value metal2vulkan::bind::indirect_commands::THREADGROUP_BUFFER_ARGUMENT_C
|
||||
const-value metal2vulkan::bind::indirect_commands::WRITTEN_FLAG_BYTES 4
|
||||
const-value metal2vulkan::cache::SOURCE_DIGEST env!("M2V_SOURCE_DIGEST")
|
||||
const-value metal2vulkan::device::NVIDIA_AMPERE_GA10X &[0x2200, 0x2203, 0x2204, 0x2205, 0x2206, 0x2207, 0x2208, 0x220a, 0x220d, 0x2216, 0x222b, 0x222f, 0x2230, 0x2231, 0x2232, 0x2233, 0x2235, 0x2236, 0x2237, 0x2238, 0x223f, 0x2414, 0x2420, 0x2438, 0x2460, 0x2480, 0x2482, 0x2483, 0x2484, 0x2486, 0x2487, 0x2488, 0x2489, 0x248a, 0x248c, 0x248d, 0x248e, 0x249c, 0x249d, 0x249f, 0x24a0, 0x24a4, 0x24ac, 0x24ad, 0x24af, 0x24b0, 0x24b1, 0x24b6, 0x24b7, 0x24b8, 0x24b9, 0x24ba, 0x24bb, 0x24bf, 0x24c0, 0x24c7, 0x24c8, 0x24c9, 0x24dc, 0x24dd, 0x24df, 0x24e0, 0x24fa, 0x2501, 0x2503, 0x2504, 0x2505, 0x2507, 0x2508, 0x2509, 0x2520, 0x2521, 0x2523, 0x252f, 0x2531, 0x2544, 0x2560, 0x2561, 0x2563, 0x2571, 0x2582, 0x2583, 0x2584, 0x25a0, 0x25a2, 0x25a3, 0x25a4, 0x25a5, 0x25a6, 0x25a7, 0x25a9, 0x25aa, 0x25ab, 0x25ac, 0x25ad, 0x25af, 0x25b0, 0x25b2, 0x25b5, 0x25b6, 0x25b8, 0x25b9, 0x25ba, 0x25bb, 0x25bc, 0x25bd, 0x25e0, 0x25e2, 0x25e5, 0x25ec, 0x25ed, 0x25f9, 0x25fa, 0x25fb]
|
||||
const-value metal2vulkan::metal::format::BICUBIC_TEXELS_UNBOUND crate::metal::bicubic::BicubicTexels::NEUTRAL.0
|
||||
const-value metal2vulkan::metal::sampler::NOT_MIPMAPPED_MAX_LOD 0.25
|
||||
const-value metal2vulkan::metal::vertex::MAX_VERTEX_ALIGNMENT 4
|
||||
const-value metal2vulkan::pipeline::DEEP_THREADGROUP 64
|
||||
@@ -6313,6 +6315,7 @@ fn metal2vulkan::device::vk_stage pub fn vk_stage(stage: Stage) -> vk::ShaderSta
|
||||
fn metal2vulkan::metal::format::alpha_in_red pub fn alpha_in_red(pf: PixelFormat, profile: &DeviceProfile) -> bool
|
||||
fn metal2vulkan::metal::format::alpha_in_red_format pub fn alpha_in_red_format(pf: PixelFormat) -> Option<vk::Format>
|
||||
fn metal2vulkan::metal::format::aspects pub fn aspects(pf: PixelFormat) -> Option<vk::ImageAspectFlags>
|
||||
fn metal2vulkan::metal::format::bicubic_texels_word pub fn bicubic_texels_word(pf: PixelFormat, swizzle: TextureSwizzleChannels) -> Option<u32>
|
||||
fn metal2vulkan::metal::format::block_extent pub fn block_extent(pf: PixelFormat) -> Option<[u32; 2]>
|
||||
fn metal2vulkan::metal::format::bound_texel_format pub fn bound_texel_format(pf: PixelFormat) -> u32
|
||||
fn metal2vulkan::metal::format::byte_format pub fn byte_format(pf: PixelFormat) -> Option<vk::Format>
|
||||
@@ -13921,6 +13924,7 @@ variant metal2vulkan-rt::Error::Vulkan Vulkan { call: &'static str, result: vk::
|
||||
variant metal2vulkan-rt::ExportHandle::DmaBuf DmaBuf
|
||||
variant metal2vulkan-rt::ExportHandle::OpaqueFd OpaqueFd
|
||||
variant metal2vulkan-rt::ExportHandle::OpaqueWin32 OpaqueWin32
|
||||
variant metal2vulkan-rt::Gap::BicubicTexels BicubicTexels { slot: u32, pixel_format: PixelFormat }
|
||||
variant metal2vulkan-rt::Gap::BufferCopyAlignment BufferCopyAlignment { pixel_format: PixelFormat, offset: u64, bytes_per_row: u64, bytes_per_image: u64 }
|
||||
variant metal2vulkan-rt::Gap::CubeArrayTexture CubeArrayTexture
|
||||
variant metal2vulkan-rt::Gap::CubicSampler CubicSampler
|
||||
@@ -17061,6 +17065,7 @@ variant metal2vulkan::pipeline::PushField::AmplificationLayerOffset Amplificatio
|
||||
variant metal2vulkan::pipeline::PushField::AmplificationViewportOffset AmplificationViewportOffset
|
||||
variant metal2vulkan::pipeline::PushField::ArgumentTableAddress ArgumentTableAddress
|
||||
variant metal2vulkan::pipeline::PushField::BaseVertexInstance BaseVertexInstance
|
||||
variant metal2vulkan::pipeline::PushField::BicubicTexels BicubicTexels(SlotRef)
|
||||
variant metal2vulkan::pipeline::PushField::CaptureIndexAddress CaptureIndexAddress
|
||||
variant metal2vulkan::pipeline::PushField::CaptureLayout CaptureLayout
|
||||
variant metal2vulkan::pipeline::PushField::CommandRecordsAddress CommandRecordsAddress
|
||||
|
||||
|
Can't render this file because it is too large.
|
+15
-4
@@ -178,8 +178,18 @@ compile does. `DevicePolicy::default()` is `DevicePolicy::UNTRUSTED`:
|
||||
consumer pushes for it (`PushField::ConstexprSampler`), where the consumer places the device
|
||||
sampler `CombinedSampler::constexpr_sampler` describes, normalized: the shader scales a pixel
|
||||
sampler's coordinate. An integer write to a storage slot without a format saturates to the channel
|
||||
widths the consumer pushes (`PushField::TextureIntegerChannels`). A fragment function under the
|
||||
pipeline's private alpha test (`PrivateRenderState::alpha_test_enabled`, a compare function other
|
||||
widths the consumer pushes (`PushField::TextureIntegerChannels`). A sample of a 2D texture
|
||||
slot through a bicubic constexpr sampler at normalized coordinates reads how Metal's bicubic
|
||||
filter treats the bound texture's texels (its inner taps, its clamp and its border texels) from
|
||||
the word the consumer pushes for that slot (`PushField::BicubicTexels`:
|
||||
`metal::format::bicubic_texels_word` of the bound texture's format and swizzle,
|
||||
`metal::format::BICUBIC_TEXELS_UNBOUND` for a slot bound to nothing), the bits the default
|
||||
domains specialize `SpecKey::BicubicTexels` to. `bicubic_texels_word` has no word for a
|
||||
compressed, YUV, stencil, integer, extended-range or 8-bit sRGB format, so such a texture has
|
||||
no bicubic sample there (the new runtime refuses the dispatch, `Gap::BicubicTexels`). Its
|
||||
arithmetic is noted `PrecisionNote::BicubicFilterArithmetic`, as on the default domains. A
|
||||
fragment function under the pipeline's private alpha test
|
||||
(`PrivateRenderState::alpha_test_enabled`, a compare function other
|
||||
than `Never` or `Always`) compares its color 0's alpha with the code the consumer pushes
|
||||
(`PushField::AlphaTestReference`): `bind::alpha_test_code` of the encoder's
|
||||
`setAlphaTestReferenceValue:`, 1 until the encoder sets it. It is Metal's 8-bit unorm code of the
|
||||
@@ -197,8 +207,9 @@ compile does. `DevicePolicy::default()` is `DevicePolicy::UNTRUSTED`:
|
||||
and its constexpr samplers. Any other function is refused as `Unsupported{IdentityDomains}`,
|
||||
whose symbol names the first such form the function holds: one that samples through an
|
||||
argument buffer's sampler or an array of samplers or samples an argument buffer's texture,
|
||||
emulates a sampler's anisotropy or bicubic filter, uses a texture buffer, a slot's levels or
|
||||
swizzle, a two-plane, extended-range or sRGB-twin form, reads an argument buffer's texture
|
||||
emulates a sampler's anisotropy, samples a 1D texture or at pixel coordinates through a bicubic
|
||||
filter, uses a texture buffer, a slot's levels or swizzle, a two-plane, extended-range or
|
||||
sRGB-twin form, reads an argument buffer's texture
|
||||
through another numeric type or as raw texels, reads the texture of an argument buffer that a
|
||||
pointer another argument buffer holds reaches (it reads the root table, `RootTableAddress`), or
|
||||
uses any other state of a texture or sampler beyond its ID.
|
||||
|
||||
+4
-2
@@ -39,7 +39,7 @@ Columns:
|
||||
| Devices below the new runtime's floor | 8 | 8 | 0 | 0 | 0 | 0 | 0 |
|
||||
| The new runtime's `Refusal` | 75 | 75 | 0 | 0 | 0 | 0 | 0 |
|
||||
| The new runtime's `Limit` | 17 | 17 | 0 | 0 | 0 | 0 | 0 |
|
||||
| The new runtime's `Gap` | 29 | 29 | 0 | 0 | 0 | 0 | 0 |
|
||||
| The new runtime's `Gap` | 30 | 30 | 0 | 0 | 0 | 0 | 0 |
|
||||
|
||||
## Totals by basis
|
||||
|
||||
@@ -57,7 +57,7 @@ Columns:
|
||||
| Devices below the new runtime's floor | 0 | 0 | 0 | 8 | 0 | 0 | 0 | 0 |
|
||||
| The new runtime's `Refusal` | 20 | 20 | 0 | 0 | 35 | 0 | 0 | 0 |
|
||||
| The new runtime's `Limit` | 0 | 0 | 0 | 13 | 4 | 0 | 0 | 0 |
|
||||
| The new runtime's `Gap` | 0 | 0 | 0 | 2 | 27 | 0 | 0 | 0 |
|
||||
| The new runtime's `Gap` | 0 | 0 | 0 | 2 | 28 | 0 | 0 | 0 |
|
||||
|
||||
## 1. Translator and front-end refusals (`Unsupported`: a `Feature` and its `Needs`)
|
||||
|
||||
@@ -744,6 +744,7 @@ Columns:
|
||||
| `RenderPipeline` | A render pipeline state of something the runtime does not build yet | every device (a public call's own check of its arguments) | `ours`: the replay streams' render pipelines draw into colour, depth and stencil attachments of one sample, with no tessellation and no framebuffer fetch; each other kind is built when a replay stream makes one | 5: `crates/metal2vulkan-rt/src/render.rs (draw_input)`, `crates/metal2vulkan-rt/src/render.rs (of, 3 sites)` (+1) | `-` |
|
||||
| `SwizzledReadWrite` | A draw or dispatch whose function declares `access::read_write` at texture slot `slot` and reads it, where the texture bound there has a swizzle... | every device (a public call's own check of its arguments) | `ours`: built when a replay stream counts one | 2: `crates/metal2vulkan-rt/src/encoder.rs (dispatch)`, `crates/metal2vulkan-rt/src/render_encoder.rs (find)` | `-` |
|
||||
| `StorageElement` | A draw or dispatch whose function writes a texture slot, or reads one through its storage image (`access::read_write`), bound to a texture made... | every device (a public call's own check of its arguments) | `ours`: the storage element through a view of the nearest format whose storage Vulkan requires of every device, with the translator's conversion, is the form to build | 3: `crates/metal2vulkan-rt/src/encoder.rs (dispatch, 2 sites)`, `crates/metal2vulkan-rt/src/render_encoder.rs (find)` | `-` |
|
||||
| `BicubicTexels` | A dispatch whose kernel samples texture slot `slot` through a constexpr sampler with Metal's bicubic filter (`filter::bicubic`), where the texture... | every device (a public call's own check of its arguments) | `ours`: each refused format's treatment is built when a guest binds one | 1: `crates/metal2vulkan-rt/src/encoder.rs (dispatch)` | `-` |
|
||||
| `TextureView` | `Texture::new_texture_view` of a kind Metal makes and the runtime does not build | every device (a public call's own check of its arguments) | `ours`: the replay streams' views that compute binds are same-format views of every slice, 2D views of one slice of a 2D array, and level subranges, swizzled or not; each other kind is built when a replay stream binds one | 1: `crates/metal2vulkan-rt/src/texture.rs (view)` | `-` |
|
||||
| `RenderPass` | A render pass of something the runtime does not build yet (`CommandBuffer::render_command_encoder`) | every device (a public call's own check of its arguments) | `ours`: the replay streams' passes render into one to two color attachments and a stencil or a depth attachment, each a level of a 2D texture of one sample, with no resolve and a clear depth of 1, none naming two textures for its depth and stencil; each other kind is built when a replay stream makes one; `DepthStencilViews` and `ClearDepth` are what Vulkan's rendering under the floor takes no form of | 5: `crates/metal2vulkan-rt/src/pass.rs (check)`, `crates/metal2vulkan-rt/src/pass.rs (ops)` (+3) | `-` |
|
||||
| `Draw` | A draw or render encoder state the runtime does not build yet (`RenderCommandEncoder`) | every device (a public call's own check of its arguments) | `ours`: the replay streams draw lines and triangles through one viewport Vulkan's is, with pipeline states of their pass's formats, under depth biases with no clamp, filled and clipped; each other kind is built when a replay stream draws one), and device for [`DrawKind::DividedBaseInstance`] (a device that does not report `supportsNonZeroFirstInstance` | 13: `crates/metal2vulkan-rt/src/render_encoder.rs (attachment_reads, 2 sites)`, `crates/metal2vulkan-rt/src/render_encoder.rs (draw)` (+10) | `-` |
|
||||
@@ -1357,6 +1358,7 @@ Each refusal's sites, with the function that builds it.
|
||||
- `rt:Gap::RenderPipeline`: `crates/metal2vulkan-rt/src/render.rs (draw_input)`; `crates/metal2vulkan-rt/src/render.rs (of, 3 sites)`; `crates/metal2vulkan-rt/src/render.rs (refuse)`
|
||||
- `rt:Gap::SwizzledReadWrite`: `crates/metal2vulkan-rt/src/encoder.rs (dispatch)`; `crates/metal2vulkan-rt/src/render_encoder.rs (find)`
|
||||
- `rt:Gap::StorageElement`: `crates/metal2vulkan-rt/src/encoder.rs (dispatch, 2 sites)`; `crates/metal2vulkan-rt/src/render_encoder.rs (find)`
|
||||
- `rt:Gap::BicubicTexels`: `crates/metal2vulkan-rt/src/encoder.rs (dispatch)`
|
||||
- `rt:Gap::TextureView`: `crates/metal2vulkan-rt/src/texture.rs (view)`
|
||||
- `rt:Gap::RenderPass`: `crates/metal2vulkan-rt/src/pass.rs (check)`; `crates/metal2vulkan-rt/src/pass.rs (ops)`; `crates/metal2vulkan-rt/src/pass.rs (resolve)`; `crates/metal2vulkan-rt/src/render_encoder.rs (later_store)`; `crates/metal2vulkan-rt/src/texture.rs (attachment)`
|
||||
- `rt:Gap::Draw`: `crates/metal2vulkan-rt/src/render_encoder.rs (attachment_reads, 2 sites)`; `crates/metal2vulkan-rt/src/render_encoder.rs (draw)`; `crates/metal2vulkan-rt/src/render_encoder.rs (draw_patches)`; `crates/metal2vulkan-rt/src/render_encoder.rs (primitives)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_depth_bias)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_depth_clip_mode)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_scissor_rects)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_triangle_fill_mode)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_viewport)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_viewports)`; `crates/metal2vulkan-rt/src/render_encoder.rs (set_visibility_result_mode)`; `crates/metal2vulkan-rt/src/render_encoder.rs (shadow_copies)`
|
||||
|
||||
Reference in new issue
Block a user