metal: the resource ID word, its spec and test vectors

Under the identity binding domains a guest computes a texture's or sampler's gpuResourceID itself,
with no round trip: the index the consumer grants in the low 32 bits and a word in the high 32 bits
that is a pure function of the Metal descriptor. The guest's port needs the word specified and a
file of vectors both sides check.

- metal::resource_word::TextureWord::of(pixel_format, swizzle): bits 0-11 Metal's border texels
  after the swizzle (the existing border_texels rule), bit 12 the out-of-bounds alpha of a format
  without alpha, bits 16-31 the MTLPixelFormat raw value, so a texture's word is never 0. None for
  the placeholders and the formats the translator holds no texture of or only copies.
- The sampler word is the existing SamplerWord, unchanged.
- docs/RESOURCE-ID.md: the ID's layout, the index classes (0 nil; storage-capable textures 1 to
  4,095, valid in both arrays; other textures 4,096 to 65,535; samplers 1 to 3,999), both words'
  bits and the level rule, and the vectors file. README's documentation table lists it.
- crates/metal2vulkan/tests/resource_words.tsv: 392 vectors (every pixel format with a word under
  the default swizzle, each channel of seven formats from each other source, every sampler field
  through its values, the level clamps around the points the nearest level turns at, and one
  descriptor with every field changed). tests/resource_words.rs recomputes every line through the
  public API and holds the file equal to what the generator writes; an ignored test blesses it.
- api_surface lists the new module; api_signatures regenerated.

Verified:
- msi job 40810 at the same tree: clippy -p metal2vulkan --all-targets --all-features -D warnings,
  rustdoc -D warnings, nextest 18 of 18 (resource_words, the TextureWord unit test, api_surface,
  api_signatures).
- msi job 40811 at the same tree: clippy under --cfg m2v_gpu and --cfg m2v_cpu_icd.
- msi job 40809: the bless test wrote the vectors; the combined sampler line (0x58f6ab53) and the
  A8Unorm and R8Unorm texture lines checked by hand against the bit tables.
This commit is contained in:
Anees Iqbal committed 2026-11-17 07:01:32 -08:00
1 parent c944d63548
commit 737ccbf81a
8 files changed
+864

No files matched your search

+1
View File
@@ -141,6 +141,7 @@ For the runtime, start at [its README](crates/metal2vulkan-runtime/README.md).
| [Runtime README](crates/metal2vulkan-runtime/README.md) | You use the Metal API on Vulkan |
| [docs/HOWTO.md](docs/HOWTO.md) | You integrate: tools, caching, failures, isolation, the runtime's shader cache |
| [docs/RUNTIME-PORTING.md](docs/RUNTIME-PORTING.md) | You port Metal calls (Objective-C or metal-rs) to the runtime |
| [docs/RESOURCE-ID.md](docs/RESOURCE-ID.md) | You compute a texture's or sampler's `gpuResourceID` on the guest's side |
| [docs/FAST-PATHS.md](docs/FAST-PATHS.md) | You need every speed-for-accuracy default and its exact switch |
| [docs/METAL-COVERAGE.md](docs/METAL-COVERAGE.md) | You ask whether a Metal API item is covered |
| [docs/REFUSALS.md](docs/REFUSALS.md) | You ask what Metal accepts that the code refuses |
+1
View File
@@ -444,6 +444,7 @@ impl TextureWriteRoundingMode {
pub(crate) mod bicubic;
pub mod format;
pub mod resource_word;
pub mod sampler;
pub mod state;
pub(crate) mod texel_format;
@@ -0,0 +1,83 @@
//! The high word of a texture's `gpuResourceID`: what a shader reads of a texture it learns only
//! at run time, as a pure function of the Metal texture descriptor, so a guest computes it with
//! no round trip. `docs/RESOURCE-ID.md` is the specification; a sampler's word is
//! [`SamplerWord`](crate::metal::sampler::SamplerWord).
use crate::metal::{PixelFormat, TextureSwizzleChannels};
/// The high word of a texture's `gpuResourceID`, from its pixel format and swizzle alone. The
/// bits:
///
/// | bits | field |
/// |---|---|
/// | 0-11 | [`BORDER_TEXELS`](Self::BORDER_TEXELS): Metal's border texel for each border color |
/// | 12 | [`OUT_OF_BOUNDS_ALPHA_ONE`](Self::OUT_OF_BOUNDS_ALPHA_ONE): the format has no alpha |
/// | 13-15 | 0 |
/// | 16-31 | [`PIXEL_FORMAT`](Self::PIXEL_FORMAT): the `MTLPixelFormat` raw value |
///
/// Bit `3c + b` of the border texels is set where channel `c` (0 red to 3 alpha) of the texel a
/// Metal 4.1 read through a sampler hands back outside the level on a border axis, for border
/// color `b` (`MTLSamplerBorderColor`'s raw value: transparent black, opaque black, opaque
/// white), reads 1 rather than 0, after the swizzle. A color format's channels are its own; a
/// depth or stencil format reads as red, green and blue, alpha 1. An out-of-bounds `read` of a
/// format without alpha reads alpha 1 (MSL 4.1 sections 2.9.1 and 6.13). Every pixel format's
/// raw value is above 0, so a texture's word is never 0, and the nil `gpuResourceID`, 0, has the
/// word 0.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct TextureWord(pub u32);
impl TextureWord {
/// The border texels' bits.
pub const BORDER_TEXELS: u32 = 0xfff;
/// The format has no alpha: an out-of-bounds read reads alpha 1.
pub const OUT_OF_BOUNDS_ALPHA_ONE: u32 = 1 << 12;
/// The lowest bit of the pixel format.
pub const PIXEL_FORMAT_SHIFT: u32 = 16;
/// The pixel format's bits.
pub const PIXEL_FORMAT: u32 = 0xffff << Self::PIXEL_FORMAT_SHIFT;
/// The word of a texture of `pixel_format` made with `swizzle`. `None` for the placeholders
/// (`Invalid`, `Unspecialized`) and the formats of which the translator holds no texture or
/// which it only copies, which no shader reads.
pub fn of(pixel_format: PixelFormat, swizzle: TextureSwizzleChannels) -> Option<TextureWord> {
let border = crate::metal::sampler::border_texels(pixel_format, swizzle)?;
let alpha_one = crate::metal::format::out_of_bounds_alpha_one(pixel_format)?;
let mut w = border | (pixel_format.as_raw() << Self::PIXEL_FORMAT_SHIFT);
if alpha_one {
w |= Self::OUT_OF_BOUNDS_ALPHA_ONE;
}
Some(TextureWord(w))
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::metal::TextureSwizzle;
/// Each field lands in its bits: `RGBA8Unorm` (raw 70) has every channel, so white reads 1 in
/// each and opaque black in alpha; `R8Unorm` (raw 10) has red alone, so its green and blue
/// read 0 under every color, its alpha 1 under every color, and its out-of-bounds alpha is 1;
/// a swizzle of red from one and green from zero sets and clears those channels' bits;
/// `Invalid` has no word.
#[test]
fn each_field_lands_in_its_bits() {
let rgba = TextureWord::of(PixelFormat::RGBA8Unorm, TextureSwizzleChannels::DEFAULT);
assert_eq!(rgba, Some(TextureWord(70 << 16 | 0b110_100_100_100)));
let r = TextureWord::of(PixelFormat::R8Unorm, TextureSwizzleChannels::DEFAULT);
assert_eq!(r, Some(TextureWord(10 << 16 | 1 << 12 | 0b111_000_000_100)));
let ones = TextureSwizzleChannels::new(
TextureSwizzle::One,
TextureSwizzle::Zero,
TextureSwizzle::Blue,
TextureSwizzle::Alpha,
);
let swizzled = TextureWord::of(PixelFormat::RGBA8Unorm, ones);
assert_eq!(swizzled, Some(TextureWord(70 << 16 | 0b110_100_000_111)));
assert_eq!(
TextureWord::of(PixelFormat::Invalid, TextureSwizzleChannels::DEFAULT),
None
);
}
}
@@ -468,6 +468,10 @@ assoc-const metal2vulkan::device::ResolveMode::ALL pub const ALL: [ResolveMode;
assoc-const metal2vulkan::metal::DataType::ALL pub const ALL: [DataType; 17]
assoc-const metal2vulkan::metal::TextureSwizzleChannels::DEFAULT pub const DEFAULT: TextureSwizzleChannels
assoc-const metal2vulkan::metal::format::ExtendedRange::HEAP_READ pub const HEAP_READ: [ExtendedRange; 7]
assoc-const metal2vulkan::metal::resource_word::TextureWord::BORDER_TEXELS pub const BORDER_TEXELS: u32
assoc-const metal2vulkan::metal::resource_word::TextureWord::OUT_OF_BOUNDS_ALPHA_ONE pub const OUT_OF_BOUNDS_ALPHA_ONE: u32
assoc-const metal2vulkan::metal::resource_word::TextureWord::PIXEL_FORMAT pub const PIXEL_FORMAT: u32
assoc-const metal2vulkan::metal::resource_word::TextureWord::PIXEL_FORMAT_SHIFT pub const PIXEL_FORMAT_SHIFT: u32
assoc-const metal2vulkan::metal::sampler::AddressModeMap::IDENTITY pub const IDENTITY: AddressModeMap
assoc-const metal2vulkan::metal::sampler::SamplerWord::ADDRESS pub const ADDRESS: [u32; 3]
assoc-const metal2vulkan::metal::sampler::SamplerWord::ADDRESS_SHIFT pub const ADDRESS_SHIFT: [u32; 3]
@@ -988,6 +992,10 @@ assoc-const-value metal2vulkan::device::ResolveMode::ALL [ResolveMode::SampleZer
assoc-const-value metal2vulkan::metal::DataType::ALL [DataType::Float32, DataType::Float16, DataType::BFloat16, DataType::Int2, DataType::Int4, DataType::Int8, DataType::Int16, DataType::Int32, DataType::UInt2, DataType::UInt4, DataType::UInt8, DataType::UInt16, DataType::UInt32, DataType::Fp4E2M1, DataType::Fp8E4M3, DataType::Fp8E5M2, DataType::Fp8UE8M0]
assoc-const-value metal2vulkan::metal::TextureSwizzleChannels::DEFAULT TextureSwizzleChannels
assoc-const-value metal2vulkan::metal::format::ExtendedRange::HEAP_READ [ExtendedRange::Bgr10 { srgb: false }, ExtendedRange::Bgra10 { srgb: false }, ExtendedRange::R10X6, ExtendedRange::Rg10X12, ExtendedRange::R16Bfloat, ExtendedRange::Rg16Bfloat, ExtendedRange::Rgba16Bfloat]
assoc-const-value metal2vulkan::metal::resource_word::TextureWord::BORDER_TEXELS 0xfff
assoc-const-value metal2vulkan::metal::resource_word::TextureWord::OUT_OF_BOUNDS_ALPHA_ONE 1 <<12
assoc-const-value metal2vulkan::metal::resource_word::TextureWord::PIXEL_FORMAT 0xffff <<Self::PIXEL_FORMAT_SHIFT
assoc-const-value metal2vulkan::metal::resource_word::TextureWord::PIXEL_FORMAT_SHIFT 16
assoc-const-value metal2vulkan::metal::sampler::AddressModeMap::IDENTITY AddressModeMap
assoc-const-value metal2vulkan::metal::sampler::SamplerWord::ADDRESS [0b111 <<Self::ADDRESS_SHIFT[0], 0b111 <<Self::ADDRESS_SHIFT[1], 0b111 <<Self::ADDRESS_SHIFT[2]]
assoc-const-value metal2vulkan::metal::sampler::SamplerWord::ADDRESS_SHIFT [5, 8, 11]
@@ -10338,6 +10346,7 @@ method metal2vulkan::metal::format::WordAttachment::of pub fn of(pf: PixelFormat
method metal2vulkan::metal::format::WordAttachment::output_word pub fn output_word(self, rgba: [f32; 4]) -> Option<u32>
method metal2vulkan::metal::format::WordAttachment::pack pub fn pack(self, codes: [u32; 4]) -> u32
method metal2vulkan::metal::format::WordAttachment::word_format pub fn word_format(self) -> vk::Format
method metal2vulkan::metal::resource_word::TextureWord::of pub fn of(pixel_format: PixelFormat, swizzle: TextureSwizzleChannels) -> Option<TextureWord>
method metal2vulkan::metal::sampler::AddressModeMap::constexpr_mode pub fn constexpr_mode(&self, from: SamplerAddressMode) -> Option<SamplerAddressMode>
method metal2vulkan::metal::sampler::AddressModeMap::is_identity pub fn is_identity(&self) -> bool
method metal2vulkan::metal::sampler::AddressModeMap::mode pub fn mode(&self, from: SamplerAddressMode) -> SamplerAddressMode
@@ -11133,6 +11142,7 @@ struct metal2vulkan::metal::TextureSwizzleChannels #[cfg_attr(feature = "serde",
struct metal2vulkan::metal::format::FormatMapping #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct FormatMapping
struct metal2vulkan::metal::format::WordField #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct WordField
struct metal2vulkan::metal::format::YCbCrFormat #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct YCbCrFormat
struct metal2vulkan::metal::resource_word::TextureWord #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct TextureWord(pub u32)
struct metal2vulkan::metal::sampler::AddressModeMap #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct AddressModeMap
struct metal2vulkan::metal::sampler::SamplerUse #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct SamplerUse
struct metal2vulkan::metal::sampler::SamplerWord #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SamplerWord(pub u32)
Can't render this file because it is too large.
+5
View File
@@ -958,6 +958,7 @@ surface! {
enum VertexStepFunction N;
enum Winding E;
mod format;
mod resource_word;
mod sampler;
mod state;
mod vertex;
@@ -1007,6 +1008,9 @@ surface! {
fn alpha_in_red;
fn alpha_in_red_format;
}
"metal::resource_word" => metal2vulkan::metal::resource_word {
struct TextureWord E;
}
"metal::sampler" => metal2vulkan::metal::sampler {
struct SamplerUse N;
struct SamplerWord E;
@@ -2372,6 +2376,7 @@ fn scanned_modules() -> Vec<&'static str> {
"cache",
"metal",
"metal::format",
"metal::resource_word",
"metal::sampler",
"metal::state",
"metal::vertex",
+283
View File
@@ -0,0 +1,283 @@
//! The `gpuResourceID` high words' test vectors (`docs/RESOURCE-ID.md`): `resource_words.tsv`
//! beside this file holds one Metal descriptor per line, as raw Metal values, and its word. A
//! guest's own computation of the words checks itself against the same file.
//!
//! `the_vectors_are_the_words` reads every line and computes its word through the public API, so
//! the file means what the specification says of its columns; `the_vectors_are_current` holds the
//! file equal to what `bless_resource_words` writes, so a change of any word is a change of this
//! file, which the guest's copy then fails on. Bless with
//! `cargo nextest run -p metal2vulkan --all-features --run-ignored ignored-only -E
//! 'test(bless_resource_words)'`.
use std::collections::BTreeSet;
use std::fmt::Write as _;
use std::path::PathBuf;
use metal2vulkan::bind::SamplerDescriptor;
use metal2vulkan::metal::resource_word::TextureWord;
use metal2vulkan::metal::sampler::SamplerWord;
use metal2vulkan::metal::{
CompareFunction, PixelFormat, SamplerAddressMode, SamplerBorderColor, SamplerMinMagFilter,
SamplerMipFilter, SamplerReductionMode, TextureSwizzle, TextureSwizzleChannels,
};
const HEADER: &str = "\
# gpuResourceID high words (docs/RESOURCE-ID.md): one Metal descriptor per line, raw Metal values.
# texture\tpixelFormat\tswizzleRed\tswizzleGreen\tswizzleBlue\tswizzleAlpha\tword
# sampler\tminFilter\tmagFilter\tmipFilter\tsAddressMode\ttAddressMode\trAddressMode\tborderColor\tnormalizedCoordinates\tlodMinClamp\tlodMaxClamp\tlodAverage\tmaxAnisotropy\tcompareFunction\treductionMode\tword
# lodMinClamp and lodMaxClamp are a float's IEEE-754 bits; booleans are 0 or 1; words are hex.
";
fn path() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/resource_words.tsv")
}
fn swizzle(channels: TextureSwizzleChannels) -> [TextureSwizzle; 4] {
[channels.red, channels.green, channels.blue, channels.alpha]
}
/// The texture lines: every pixel format with a word under the default swizzle, then each
/// channel of a few formats of one to four channels, depth, integer and rotated, read from each
/// other source.
fn textures(out: &mut String) {
let mut line = |pf: PixelFormat, channels: TextureSwizzleChannels| {
let Some(TextureWord(word)) = TextureWord::of(pf, channels) else {
return;
};
let s = swizzle(channels).map(|s| s.as_raw().to_string()).join("\t");
let _ = writeln!(out, "texture\t{}\t{s}\t{word:#010x}", pf.as_raw());
};
for &pf in PixelFormat::ALL {
line(pf, TextureSwizzleChannels::DEFAULT);
}
let formats = [
PixelFormat::A8Unorm,
PixelFormat::R8Unorm,
PixelFormat::RG8Unorm,
PixelFormat::RGBA8Unorm,
PixelFormat::BGRA8Unorm,
PixelFormat::R32Uint,
PixelFormat::Depth32Float,
];
for pf in formats {
for channel in 0..4 {
for &source in TextureSwizzle::ALL {
let mut s = swizzle(TextureSwizzleChannels::DEFAULT);
if s[channel] == source {
continue;
}
s[channel] = source;
line(pf, TextureSwizzleChannels::new(s[0], s[1], s[2], s[3]));
}
}
}
}
fn sampler_line(out: &mut String, d: &SamplerDescriptor) {
let SamplerWord(word) = SamplerWord::of(d);
let fields = [
d.min_filter.as_raw(),
d.mag_filter.as_raw(),
d.mip_filter.as_raw(),
d.s_address_mode.as_raw(),
d.t_address_mode.as_raw(),
d.r_address_mode.as_raw(),
d.border_color.as_raw(),
u32::from(d.normalized_coordinates),
];
let fields = fields.map(|f| f.to_string()).join("\t");
let _ = writeln!(
out,
"sampler\t{fields}\t{:#010x}\t{:#010x}\t{}\t{}\t{}\t{}\t{word:#010x}",
d.lod_min_clamp.to_bits(),
d.lod_max_clamp.to_bits(),
u32::from(d.lod_average),
d.max_anisotropy,
d.compare_function.as_raw(),
d.reduction_mode.as_raw(),
);
}
/// The sampler lines: the default descriptor, each field through each of its values with the
/// others at their defaults, the level clamps around the points a nearest mip filter's level
/// turns at, and one descriptor with every field away from its default.
fn samplers(out: &mut String) {
let base = SamplerDescriptor::new();
let mut each = |set: &dyn Fn(&mut SamplerDescriptor)| {
let mut d = base;
set(&mut d);
sampler_line(out, &d);
};
each(&|_| {});
for &f in SamplerMinMagFilter::ALL {
each(&|d| d.min_filter = f);
each(&|d| d.mag_filter = f);
}
for &f in SamplerMipFilter::ALL {
each(&|d| d.mip_filter = f);
}
for &m in SamplerAddressMode::ALL {
each(&|d| d.s_address_mode = m);
each(&|d| d.t_address_mode = m);
each(&|d| d.r_address_mode = m);
}
for &b in SamplerBorderColor::ALL {
each(&|d| d.border_color = b);
}
each(&|d| d.normalized_coordinates = false);
let mins = [
0.0,
0.25,
0.5,
0.515625,
0.53125,
1.0,
1.4,
1.6,
2.75,
14.5,
14.6,
15.0,
100.0,
f32::MAX,
];
for c in mins {
each(&|d| d.lod_min_clamp = c);
}
let maxes = [0.0, 0.5, 0.515625, 0.53125, 3.9, 14.0, 14.6, 15.0, 1000.0];
for c in maxes {
each(&|d| d.lod_max_clamp = c);
}
each(&|d| d.lod_average = true);
for a in [2, 3, 16] {
each(&|d| d.max_anisotropy = a);
}
for &f in CompareFunction::ALL {
each(&|d| d.compare_function = f);
}
for &r in SamplerReductionMode::ALL {
each(&|d| d.reduction_mode = r);
}
each(&|d| {
d.min_filter = SamplerMinMagFilter::Linear;
d.mag_filter = SamplerMinMagFilter::Cubic;
d.mip_filter = SamplerMipFilter::Linear;
d.s_address_mode = SamplerAddressMode::Repeat;
d.t_address_mode = SamplerAddressMode::MirrorRepeat;
d.r_address_mode = SamplerAddressMode::ClampToBorderColor;
d.border_color = SamplerBorderColor::OpaqueWhite;
d.normalized_coordinates = false;
d.lod_min_clamp = 2.75;
d.lod_max_clamp = 9.25;
d.lod_average = true;
d.max_anisotropy = 8;
d.compare_function = CompareFunction::GreaterEqual;
d.reduction_mode = SamplerReductionMode::Maximum;
});
}
/// The file: the header, then the texture and sampler lines, each line once.
fn generate() -> String {
let mut lines = String::new();
textures(&mut lines);
samplers(&mut lines);
let mut seen = BTreeSet::new();
let mut out = String::from(HEADER);
for line in lines.lines().filter(|l| seen.insert(*l)) {
out.push_str(line);
out.push('\n');
}
out
}
fn raw<T: Copy>(all: &[T], as_raw: impl Fn(T) -> u32, field: &str) -> T {
let v: u32 = field.parse().unwrap_or_else(|_| panic!("field {field}"));
all.iter()
.copied()
.find(|&t| as_raw(t) == v)
.unwrap_or_else(|| panic!("no value {v}"))
}
fn hex(field: &str) -> u32 {
let digits = field
.strip_prefix("0x")
.unwrap_or_else(|| panic!("hex {field}"));
u32::from_str_radix(digits, 16).unwrap_or_else(|_| panic!("hex {field}"))
}
fn flag(field: &str) -> bool {
match field {
"0" => false,
"1" => true,
_ => panic!("boolean {field}"),
}
}
/// The word a line's descriptor has, computed through the public API from its columns alone.
fn word_of(fields: &[&str]) -> u32 {
match fields {
["texture", pf, r, g, b, a] => {
let pf = raw(PixelFormat::ALL, PixelFormat::as_raw, pf);
let s = |f: &str| raw(TextureSwizzle::ALL, TextureSwizzle::as_raw, f);
let channels = TextureSwizzleChannels::new(s(r), s(g), s(b), s(a));
TextureWord::of(pf, channels).expect("a word").0
}
["sampler", min, mag, mip, sa, ta, ra, border, normalized, lo, hi, average, aniso, compare, reduction] =>
{
let mut d = SamplerDescriptor::new();
let filter = |f: &str| raw(SamplerMinMagFilter::ALL, SamplerMinMagFilter::as_raw, f);
let mode = |f: &str| raw(SamplerAddressMode::ALL, SamplerAddressMode::as_raw, f);
d.min_filter = filter(min);
d.mag_filter = filter(mag);
d.mip_filter = raw(SamplerMipFilter::ALL, SamplerMipFilter::as_raw, mip);
d.s_address_mode = mode(sa);
d.t_address_mode = mode(ta);
d.r_address_mode = mode(ra);
d.border_color = raw(SamplerBorderColor::ALL, SamplerBorderColor::as_raw, border);
d.normalized_coordinates = flag(normalized);
d.lod_min_clamp = f32::from_bits(hex(lo));
d.lod_max_clamp = f32::from_bits(hex(hi));
d.lod_average = flag(average);
d.max_anisotropy = aniso.parse().expect("maxAnisotropy");
d.compare_function = raw(CompareFunction::ALL, CompareFunction::as_raw, compare);
d.reduction_mode = raw(
SamplerReductionMode::ALL,
SamplerReductionMode::as_raw,
reduction,
);
SamplerWord::of(&d).0
}
_ => panic!("unknown line {fields:?}"),
}
}
#[test]
fn the_vectors_are_the_words() {
let text = std::fs::read_to_string(path()).expect("resource_words.tsv");
let mut lines = 0;
for line in text.lines().filter(|l| !l.starts_with('#')) {
let fields: Vec<&str> = line.split('\t').collect();
let Some((word, descriptor)) = fields.split_last() else {
panic!("empty line");
};
assert_eq!(word_of(descriptor), hex(word), "{line}");
lines += 1;
}
assert!(lines > 0, "no vectors");
}
#[test]
fn the_vectors_are_current() {
let text = std::fs::read_to_string(path()).expect("resource_words.tsv");
assert!(
text == generate(),
"resource_words.tsv is not what the words are now: bless it (this file's docs) and tell \
the guest's port"
);
}
#[test]
#[ignore = "writes tests/resource_words.tsv"]
fn bless_resource_words() {
std::fs::write(path(), generate()).expect("write resource_words.tsv");
}
@@ -0,0 +1,396 @@
# gpuResourceID high words (docs/RESOURCE-ID.md): one Metal descriptor per line, raw Metal values.
# texture pixelFormat swizzleRed swizzleGreen swizzleBlue swizzleAlpha word
# sampler minFilter magFilter mipFilter sAddressMode tAddressMode rAddressMode borderColor normalizedCoordinates lodMinClamp lodMaxClamp lodAverage maxAnisotropy compareFunction reductionMode word
# lodMinClamp and lodMaxClamp are a float's IEEE-754 bits; booleans are 0 or 1; words are hex.
texture 1 2 3 4 5 0x00010800
texture 10 2 3 4 5 0x000a1e04
texture 11 2 3 4 5 0x000b1e04
texture 12 2 3 4 5 0x000c1e04
texture 13 2 3 4 5 0x000d1e04
texture 14 2 3 4 5 0x000e1e04
texture 20 2 3 4 5 0x00141e04
texture 22 2 3 4 5 0x00161e04
texture 23 2 3 4 5 0x00171e04
texture 24 2 3 4 5 0x00181e04
texture 25 2 3 4 5 0x00191e04
texture 30 2 3 4 5 0x001e1e24
texture 31 2 3 4 5 0x001f1e24
texture 32 2 3 4 5 0x00201e24
texture 33 2 3 4 5 0x00211e24
texture 34 2 3 4 5 0x00221e24
texture 40 2 3 4 5 0x00281f24
texture 41 2 3 4 5 0x00290d24
texture 42 2 3 4 5 0x002a0d24
texture 43 2 3 4 5 0x002b0d24
texture 53 2 3 4 5 0x00351e04
texture 54 2 3 4 5 0x00361e04
texture 55 2 3 4 5 0x00371e04
texture 60 2 3 4 5 0x003c1e24
texture 62 2 3 4 5 0x003e1e24
texture 63 2 3 4 5 0x003f1e24
texture 64 2 3 4 5 0x00401e24
texture 65 2 3 4 5 0x00411e24
texture 70 2 3 4 5 0x00460d24
texture 71 2 3 4 5 0x00470d24
texture 72 2 3 4 5 0x00480d24
texture 73 2 3 4 5 0x00490d24
texture 74 2 3 4 5 0x004a0d24
texture 80 2 3 4 5 0x00500d24
texture 81 2 3 4 5 0x00510d24
texture 90 2 3 4 5 0x005a0d24
texture 91 2 3 4 5 0x005b0d24
texture 92 2 3 4 5 0x005c1f24
texture 93 2 3 4 5 0x005d1f24
texture 94 2 3 4 5 0x005e0d24
texture 554 2 3 4 5 0x022a1f24
texture 555 2 3 4 5 0x022b1f24
texture 103 2 3 4 5 0x00671e24
texture 104 2 3 4 5 0x00681e24
texture 105 2 3 4 5 0x00691e24
texture 110 2 3 4 5 0x006e0d24
texture 112 2 3 4 5 0x00700d24
texture 113 2 3 4 5 0x00710d24
texture 114 2 3 4 5 0x00720d24
texture 115 2 3 4 5 0x00730d24
texture 552 2 3 4 5 0x02280d24
texture 553 2 3 4 5 0x02290d24
texture 123 2 3 4 5 0x007b0d24
texture 124 2 3 4 5 0x007c0d24
texture 125 2 3 4 5 0x007d0d24
texture 130 2 3 4 5 0x00820d24
texture 131 2 3 4 5 0x00830d24
texture 132 2 3 4 5 0x00840d24
texture 133 2 3 4 5 0x00850d24
texture 134 2 3 4 5 0x00860d24
texture 135 2 3 4 5 0x00870d24
texture 140 2 3 4 5 0x008c1e04
texture 141 2 3 4 5 0x008d1e04
texture 142 2 3 4 5 0x008e1e24
texture 143 2 3 4 5 0x008f1e24
texture 150 2 3 4 5 0x00961f24
texture 151 2 3 4 5 0x00971f24
texture 152 2 3 4 5 0x00980d24
texture 153 2 3 4 5 0x00990d24
texture 160 2 3 4 5 0x00a01f24
texture 161 2 3 4 5 0x00a11f24
texture 162 2 3 4 5 0x00a21f24
texture 163 2 3 4 5 0x00a31f24
texture 164 2 3 4 5 0x00a40d24
texture 165 2 3 4 5 0x00a50d24
texture 166 2 3 4 5 0x00a60d24
texture 167 2 3 4 5 0x00a70d24
texture 170 2 3 4 5 0x00aa1e04
texture 172 2 3 4 5 0x00ac1e04
texture 174 2 3 4 5 0x00ae1e24
texture 176 2 3 4 5 0x00b01e24
texture 178 2 3 4 5 0x00b20d24
texture 179 2 3 4 5 0x00b30d24
texture 180 2 3 4 5 0x00b41f24
texture 181 2 3 4 5 0x00b51f24
texture 182 2 3 4 5 0x00b60d24
texture 183 2 3 4 5 0x00b70d24
texture 186 2 3 4 5 0x00ba0d24
texture 187 2 3 4 5 0x00bb0d24
texture 188 2 3 4 5 0x00bc0d24
texture 189 2 3 4 5 0x00bd0d24
texture 190 2 3 4 5 0x00be0d24
texture 192 2 3 4 5 0x00c00d24
texture 193 2 3 4 5 0x00c10d24
texture 194 2 3 4 5 0x00c20d24
texture 195 2 3 4 5 0x00c30d24
texture 196 2 3 4 5 0x00c40d24
texture 197 2 3 4 5 0x00c50d24
texture 198 2 3 4 5 0x00c60d24
texture 199 2 3 4 5 0x00c70d24
texture 200 2 3 4 5 0x00c80d24
texture 204 2 3 4 5 0x00cc0d24
texture 205 2 3 4 5 0x00cd0d24
texture 206 2 3 4 5 0x00ce0d24
texture 207 2 3 4 5 0x00cf0d24
texture 208 2 3 4 5 0x00d00d24
texture 210 2 3 4 5 0x00d20d24
texture 211 2 3 4 5 0x00d30d24
texture 212 2 3 4 5 0x00d40d24
texture 213 2 3 4 5 0x00d50d24
texture 214 2 3 4 5 0x00d60d24
texture 215 2 3 4 5 0x00d70d24
texture 216 2 3 4 5 0x00d80d24
texture 217 2 3 4 5 0x00d90d24
texture 218 2 3 4 5 0x00da0d24
texture 222 2 3 4 5 0x00de0d24
texture 223 2 3 4 5 0x00df0d24
texture 224 2 3 4 5 0x00e00d24
texture 225 2 3 4 5 0x00e10d24
texture 226 2 3 4 5 0x00e20d24
texture 228 2 3 4 5 0x00e40d24
texture 229 2 3 4 5 0x00e50d24
texture 230 2 3 4 5 0x00e60d24
texture 231 2 3 4 5 0x00e70d24
texture 232 2 3 4 5 0x00e80d24
texture 233 2 3 4 5 0x00e90d24
texture 234 2 3 4 5 0x00ea0d24
texture 235 2 3 4 5 0x00eb0d24
texture 236 2 3 4 5 0x00ec0d24
texture 240 2 3 4 5 0x00f01f24
texture 241 2 3 4 5 0x00f11f24
texture 250 2 3 4 5 0x00fa1f24
texture 252 2 3 4 5 0x00fc1f24
texture 253 2 3 4 5 0x00fd1f24
texture 255 2 3 4 5 0x00ff1f24
texture 260 2 3 4 5 0x01041f24
texture 261 2 3 4 5 0x01051f24
texture 262 2 3 4 5 0x01061f24
texture 84 2 3 4 5 0x005409a4
texture 550 2 3 4 5 0x02260d24
texture 551 2 3 4 5 0x02270d24
texture 500 2 3 4 5 0x01f41f24
texture 502 2 3 4 5 0x01f61f24
texture 503 2 3 4 5 0x01f71f24
texture 505 2 3 4 5 0x01f91f24
texture 506 2 3 4 5 0x01fa1f24
texture 507 2 3 4 5 0x01fb1f24
texture 508 2 3 4 5 0x01fc1f24
texture 509 2 3 4 5 0x01fd1f24
texture 510 2 3 4 5 0x01fe1f24
texture 520 2 3 4 5 0x02081f24
texture 522 2 3 4 5 0x020a1f24
texture 523 2 3 4 5 0x020b1f24
texture 525 2 3 4 5 0x020d1f24
texture 526 2 3 4 5 0x020e1f24
texture 527 2 3 4 5 0x020f1f24
texture 528 2 3 4 5 0x02101f24
texture 529 2 3 4 5 0x02111f24
texture 530 2 3 4 5 0x02121f24
texture 540 2 3 4 5 0x021c1f24
texture 541 2 3 4 5 0x021d1f24
texture 542 2 3 4 5 0x021e1f24
texture 543 2 3 4 5 0x021f1f24
texture 544 2 3 4 5 0x02201f24
texture 545 2 3 4 5 0x02211f24
texture 185 2 3 4 5 0x00b90d24
texture 191 2 3 4 5 0x00bf0d24
texture 203 2 3 4 5 0x00cb0d24
texture 209 2 3 4 5 0x00d10d24
texture 221 2 3 4 5 0x00dd0d24
texture 227 2 3 4 5 0x00e30d24
texture 26 2 3 4 5 0x001a1e04
texture 44 2 3 4 5 0x002c0d24
texture 66 2 3 4 5 0x00421e24
texture 116 2 3 4 5 0x00740d24
texture 300 2 3 4 5 0x012c1f24
texture 301 2 3 4 5 0x012d1f24
texture 302 2 3 4 5 0x012e1f24
texture 303 2 3 4 5 0x012f1f24
texture 304 2 3 4 5 0x01301f24
texture 313 2 3 4 5 0x01391f24
texture 314 2 3 4 5 0x013a1f24
texture 315 2 3 4 5 0x013b1f24
texture 323 2 3 4 5 0x01431f24
texture 324 2 3 4 5 0x01441f24
texture 325 2 3 4 5 0x01451f24
texture 576 2 3 4 5 0x02401e04
texture 577 2 3 4 5 0x02411e04
texture 578 2 3 4 5 0x02421e24
texture 579 2 3 4 5 0x02431e24
texture 586 2 3 4 5 0x024a0d24
texture 1 0 3 4 5 0x00010800
texture 1 1 3 4 5 0x00010807
texture 1 3 3 4 5 0x00010800
texture 1 4 3 4 5 0x00010800
texture 1 5 3 4 5 0x00010804
texture 1 2 0 4 5 0x00010800
texture 1 2 1 4 5 0x00010838
texture 1 2 2 4 5 0x00010800
texture 1 2 4 4 5 0x00010800
texture 1 2 5 4 5 0x00010820
texture 1 2 3 0 5 0x00010800
texture 1 2 3 1 5 0x000109c0
texture 1 2 3 2 5 0x00010800
texture 1 2 3 3 5 0x00010800
texture 1 2 3 5 5 0x00010900
texture 1 2 3 4 0 0x00010000
texture 1 2 3 4 1 0x00010e00
texture 1 2 3 4 2 0x00010000
texture 1 2 3 4 3 0x00010000
texture 1 2 3 4 4 0x00010000
texture 10 0 3 4 5 0x000a1e00
texture 10 1 3 4 5 0x000a1e07
texture 10 3 3 4 5 0x000a1e00
texture 10 4 3 4 5 0x000a1e00
texture 10 5 3 4 5 0x000a1e07
texture 10 2 0 4 5 0x000a1e04
texture 10 2 1 4 5 0x000a1e3c
texture 10 2 2 4 5 0x000a1e24
texture 10 2 4 4 5 0x000a1e04
texture 10 2 5 4 5 0x000a1e3c
texture 10 2 3 0 5 0x000a1e04
texture 10 2 3 1 5 0x000a1fc4
texture 10 2 3 2 5 0x000a1f04
texture 10 2 3 3 5 0x000a1e04
texture 10 2 3 5 5 0x000a1fc4
texture 10 2 3 4 0 0x000a1004
texture 10 2 3 4 1 0x000a1e04
texture 10 2 3 4 2 0x000a1804
texture 10 2 3 4 3 0x000a1004
texture 10 2 3 4 4 0x000a1004
texture 30 0 3 4 5 0x001e1e20
texture 30 1 3 4 5 0x001e1e27
texture 30 3 3 4 5 0x001e1e24
texture 30 4 3 4 5 0x001e1e20
texture 30 5 3 4 5 0x001e1e27
texture 30 2 0 4 5 0x001e1e04
texture 30 2 1 4 5 0x001e1e3c
texture 30 2 2 4 5 0x001e1e24
texture 30 2 4 4 5 0x001e1e04
texture 30 2 5 4 5 0x001e1e3c
texture 30 2 3 0 5 0x001e1e24
texture 30 2 3 1 5 0x001e1fe4
texture 30 2 3 2 5 0x001e1f24
texture 30 2 3 3 5 0x001e1f24
texture 30 2 3 5 5 0x001e1fe4
texture 30 2 3 4 0 0x001e1024
texture 30 2 3 4 1 0x001e1e24
texture 30 2 3 4 2 0x001e1824
texture 30 2 3 4 3 0x001e1824
texture 30 2 3 4 4 0x001e1024
texture 70 0 3 4 5 0x00460d20
texture 70 1 3 4 5 0x00460d27
texture 70 3 3 4 5 0x00460d24
texture 70 4 3 4 5 0x00460d24
texture 70 5 3 4 5 0x00460d26
texture 70 2 0 4 5 0x00460d04
texture 70 2 1 4 5 0x00460d3c
texture 70 2 2 4 5 0x00460d24
texture 70 2 4 4 5 0x00460d24
texture 70 2 5 4 5 0x00460d34
texture 70 2 3 0 5 0x00460c24
texture 70 2 3 1 5 0x00460de4
texture 70 2 3 2 5 0x00460d24
texture 70 2 3 3 5 0x00460d24
texture 70 2 3 5 5 0x00460da4
texture 70 2 3 4 0 0x00460124
texture 70 2 3 4 1 0x00460f24
texture 70 2 3 4 2 0x00460924
texture 70 2 3 4 3 0x00460924
texture 70 2 3 4 4 0x00460924
texture 80 0 3 4 5 0x00500d20
texture 80 1 3 4 5 0x00500d27
texture 80 3 3 4 5 0x00500d24
texture 80 4 3 4 5 0x00500d24
texture 80 5 3 4 5 0x00500d26
texture 80 2 0 4 5 0x00500d04
texture 80 2 1 4 5 0x00500d3c
texture 80 2 2 4 5 0x00500d24
texture 80 2 4 4 5 0x00500d24
texture 80 2 5 4 5 0x00500d34
texture 80 2 3 0 5 0x00500c24
texture 80 2 3 1 5 0x00500de4
texture 80 2 3 2 5 0x00500d24
texture 80 2 3 3 5 0x00500d24
texture 80 2 3 5 5 0x00500da4
texture 80 2 3 4 0 0x00500124
texture 80 2 3 4 1 0x00500f24
texture 80 2 3 4 2 0x00500924
texture 80 2 3 4 3 0x00500924
texture 80 2 3 4 4 0x00500924
texture 53 0 3 4 5 0x00351e00
texture 53 1 3 4 5 0x00351e07
texture 53 3 3 4 5 0x00351e00
texture 53 4 3 4 5 0x00351e00
texture 53 5 3 4 5 0x00351e07
texture 53 2 0 4 5 0x00351e04
texture 53 2 1 4 5 0x00351e3c
texture 53 2 2 4 5 0x00351e24
texture 53 2 4 4 5 0x00351e04
texture 53 2 5 4 5 0x00351e3c
texture 53 2 3 0 5 0x00351e04
texture 53 2 3 1 5 0x00351fc4
texture 53 2 3 2 5 0x00351f04
texture 53 2 3 3 5 0x00351e04
texture 53 2 3 5 5 0x00351fc4
texture 53 2 3 4 0 0x00351004
texture 53 2 3 4 1 0x00351e04
texture 53 2 3 4 2 0x00351804
texture 53 2 3 4 3 0x00351004
texture 53 2 3 4 4 0x00351004
texture 252 0 3 4 5 0x00fc1f20
texture 252 1 3 4 5 0x00fc1f27
texture 252 3 3 4 5 0x00fc1f24
texture 252 4 3 4 5 0x00fc1f24
texture 252 5 3 4 5 0x00fc1f27
texture 252 2 0 4 5 0x00fc1f04
texture 252 2 1 4 5 0x00fc1f3c
texture 252 2 2 4 5 0x00fc1f24
texture 252 2 4 4 5 0x00fc1f24
texture 252 2 5 4 5 0x00fc1f3c
texture 252 2 3 0 5 0x00fc1e24
texture 252 2 3 1 5 0x00fc1fe4
texture 252 2 3 2 5 0x00fc1f24
texture 252 2 3 3 5 0x00fc1f24
texture 252 2 3 5 5 0x00fc1fe4
texture 252 2 3 4 0 0x00fc1124
texture 252 2 3 4 1 0x00fc1f24
texture 252 2 3 4 2 0x00fc1924
texture 252 2 3 4 3 0x00fc1924
texture 252 2 3 4 4 0x00fc1924
sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000000
sampler 1 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000002
sampler 0 1 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000004
sampler 2 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x40000000
sampler 0 2 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x40000000
sampler 0 0 1 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000008
sampler 0 0 2 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000010
sampler 0 0 0 1 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000020
sampler 0 0 0 0 1 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000100
sampler 0 0 0 0 0 1 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000800
sampler 0 0 0 2 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000040
sampler 0 0 0 0 2 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000200
sampler 0 0 0 0 0 2 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00001000
sampler 0 0 0 3 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000060
sampler 0 0 0 0 3 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000300
sampler 0 0 0 0 0 3 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00001800
sampler 0 0 0 4 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000080
sampler 0 0 0 0 4 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000400
sampler 0 0 0 0 0 4 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00002000
sampler 0 0 0 5 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x000000a0
sampler 0 0 0 0 5 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000500
sampler 0 0 0 0 0 5 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00002800
sampler 0 0 0 0 0 0 1 1 0x00000000 0x7f7fffff 0 1 0 0 0x00004000
sampler 0 0 0 0 0 0 2 1 0x00000000 0x7f7fffff 0 1 0 0 0x00008000
sampler 0 0 0 0 0 0 0 0 0x00000000 0x7f7fffff 0 1 0 0 0x00000001
sampler 0 0 0 0 0 0 0 1 0x3e800000 0x7f7fffff 0 1 0 0 0x00000000
sampler 0 0 0 0 0 0 0 1 0x3f000000 0x7f7fffff 0 1 0 0 0x00000000
sampler 0 0 0 0 0 0 0 1 0x3f040000 0x7f7fffff 0 1 0 0 0x00400000
sampler 0 0 0 0 0 0 0 1 0x3f080000 0x7f7fffff 0 1 0 0 0x00400000
sampler 0 0 0 0 0 0 0 1 0x3f800000 0x7f7fffff 0 1 0 0 0x00400000
sampler 0 0 0 0 0 0 0 1 0x3fb33333 0x7f7fffff 0 1 0 0 0x00400000
sampler 0 0 0 0 0 0 0 1 0x3fcccccd 0x7f7fffff 0 1 0 0 0x00800000
sampler 0 0 0 0 0 0 0 1 0x40300000 0x7f7fffff 0 1 0 0 0x00c00000
sampler 0 0 0 0 0 0 0 1 0x41680000 0x7f7fffff 0 1 0 0 0x03800000
sampler 0 0 0 0 0 0 0 1 0x4169999a 0x7f7fffff 0 1 0 0 0x03c00000
sampler 0 0 0 0 0 0 0 1 0x41700000 0x7f7fffff 0 1 0 0 0x03c00000
sampler 0 0 0 0 0 0 0 1 0x42c80000 0x7f7fffff 0 1 0 0 0x03c00000
sampler 0 0 0 0 0 0 0 1 0x7f7fffff 0x7f7fffff 0 1 0 0 0x03c00000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x00000000 0 1 0 0 0x3c000000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x3f000000 0 1 0 0 0x3c000000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x3f040000 0 1 0 0 0x38000000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x3f080000 0 1 0 0 0x38000000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x4079999a 0 1 0 0 0x2c000000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x41600000 0 1 0 0 0x04000000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x4169999a 0 1 0 0 0x00000000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x41700000 0 1 0 0 0x00000000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x447a0000 0 1 0 0 0x00000000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 1 1 0 0 0x00000000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 2 0 0 0x00200000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 3 0 0 0x00200000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 16 0 0 0x00200000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 1 0 0x00010000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 2 0 0x00020000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 3 0 0x00030000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 4 0 0x00040000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 5 0 0x00050000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 6 0 0x00060000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 7 0 0x00070000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 1 0x00080000
sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 2 0x00100000
sampler 1 2 2 2 3 5 2 0 0x40300000 0x41140000 1 8 6 2 0x58f6ab53
1 # gpuResourceID high words (docs/RESOURCE-ID.md): one Metal descriptor per line, raw Metal values.
2 # texture pixelFormat swizzleRed swizzleGreen swizzleBlue swizzleAlpha word
3 # sampler minFilter magFilter mipFilter sAddressMode tAddressMode rAddressMode borderColor normalizedCoordinates lodMinClamp lodMaxClamp lodAverage maxAnisotropy compareFunction reductionMode word
4 # lodMinClamp and lodMaxClamp are a float's IEEE-754 bits; booleans are 0 or 1; words are hex.
5 texture 1 2 3 4 5 0x00010800
6 texture 10 2 3 4 5 0x000a1e04
7 texture 11 2 3 4 5 0x000b1e04
8 texture 12 2 3 4 5 0x000c1e04
9 texture 13 2 3 4 5 0x000d1e04
10 texture 14 2 3 4 5 0x000e1e04
11 texture 20 2 3 4 5 0x00141e04
12 texture 22 2 3 4 5 0x00161e04
13 texture 23 2 3 4 5 0x00171e04
14 texture 24 2 3 4 5 0x00181e04
15 texture 25 2 3 4 5 0x00191e04
16 texture 30 2 3 4 5 0x001e1e24
17 texture 31 2 3 4 5 0x001f1e24
18 texture 32 2 3 4 5 0x00201e24
19 texture 33 2 3 4 5 0x00211e24
20 texture 34 2 3 4 5 0x00221e24
21 texture 40 2 3 4 5 0x00281f24
22 texture 41 2 3 4 5 0x00290d24
23 texture 42 2 3 4 5 0x002a0d24
24 texture 43 2 3 4 5 0x002b0d24
25 texture 53 2 3 4 5 0x00351e04
26 texture 54 2 3 4 5 0x00361e04
27 texture 55 2 3 4 5 0x00371e04
28 texture 60 2 3 4 5 0x003c1e24
29 texture 62 2 3 4 5 0x003e1e24
30 texture 63 2 3 4 5 0x003f1e24
31 texture 64 2 3 4 5 0x00401e24
32 texture 65 2 3 4 5 0x00411e24
33 texture 70 2 3 4 5 0x00460d24
34 texture 71 2 3 4 5 0x00470d24
35 texture 72 2 3 4 5 0x00480d24
36 texture 73 2 3 4 5 0x00490d24
37 texture 74 2 3 4 5 0x004a0d24
38 texture 80 2 3 4 5 0x00500d24
39 texture 81 2 3 4 5 0x00510d24
40 texture 90 2 3 4 5 0x005a0d24
41 texture 91 2 3 4 5 0x005b0d24
42 texture 92 2 3 4 5 0x005c1f24
43 texture 93 2 3 4 5 0x005d1f24
44 texture 94 2 3 4 5 0x005e0d24
45 texture 554 2 3 4 5 0x022a1f24
46 texture 555 2 3 4 5 0x022b1f24
47 texture 103 2 3 4 5 0x00671e24
48 texture 104 2 3 4 5 0x00681e24
49 texture 105 2 3 4 5 0x00691e24
50 texture 110 2 3 4 5 0x006e0d24
51 texture 112 2 3 4 5 0x00700d24
52 texture 113 2 3 4 5 0x00710d24
53 texture 114 2 3 4 5 0x00720d24
54 texture 115 2 3 4 5 0x00730d24
55 texture 552 2 3 4 5 0x02280d24
56 texture 553 2 3 4 5 0x02290d24
57 texture 123 2 3 4 5 0x007b0d24
58 texture 124 2 3 4 5 0x007c0d24
59 texture 125 2 3 4 5 0x007d0d24
60 texture 130 2 3 4 5 0x00820d24
61 texture 131 2 3 4 5 0x00830d24
62 texture 132 2 3 4 5 0x00840d24
63 texture 133 2 3 4 5 0x00850d24
64 texture 134 2 3 4 5 0x00860d24
65 texture 135 2 3 4 5 0x00870d24
66 texture 140 2 3 4 5 0x008c1e04
67 texture 141 2 3 4 5 0x008d1e04
68 texture 142 2 3 4 5 0x008e1e24
69 texture 143 2 3 4 5 0x008f1e24
70 texture 150 2 3 4 5 0x00961f24
71 texture 151 2 3 4 5 0x00971f24
72 texture 152 2 3 4 5 0x00980d24
73 texture 153 2 3 4 5 0x00990d24
74 texture 160 2 3 4 5 0x00a01f24
75 texture 161 2 3 4 5 0x00a11f24
76 texture 162 2 3 4 5 0x00a21f24
77 texture 163 2 3 4 5 0x00a31f24
78 texture 164 2 3 4 5 0x00a40d24
79 texture 165 2 3 4 5 0x00a50d24
80 texture 166 2 3 4 5 0x00a60d24
81 texture 167 2 3 4 5 0x00a70d24
82 texture 170 2 3 4 5 0x00aa1e04
83 texture 172 2 3 4 5 0x00ac1e04
84 texture 174 2 3 4 5 0x00ae1e24
85 texture 176 2 3 4 5 0x00b01e24
86 texture 178 2 3 4 5 0x00b20d24
87 texture 179 2 3 4 5 0x00b30d24
88 texture 180 2 3 4 5 0x00b41f24
89 texture 181 2 3 4 5 0x00b51f24
90 texture 182 2 3 4 5 0x00b60d24
91 texture 183 2 3 4 5 0x00b70d24
92 texture 186 2 3 4 5 0x00ba0d24
93 texture 187 2 3 4 5 0x00bb0d24
94 texture 188 2 3 4 5 0x00bc0d24
95 texture 189 2 3 4 5 0x00bd0d24
96 texture 190 2 3 4 5 0x00be0d24
97 texture 192 2 3 4 5 0x00c00d24
98 texture 193 2 3 4 5 0x00c10d24
99 texture 194 2 3 4 5 0x00c20d24
100 texture 195 2 3 4 5 0x00c30d24
101 texture 196 2 3 4 5 0x00c40d24
102 texture 197 2 3 4 5 0x00c50d24
103 texture 198 2 3 4 5 0x00c60d24
104 texture 199 2 3 4 5 0x00c70d24
105 texture 200 2 3 4 5 0x00c80d24
106 texture 204 2 3 4 5 0x00cc0d24
107 texture 205 2 3 4 5 0x00cd0d24
108 texture 206 2 3 4 5 0x00ce0d24
109 texture 207 2 3 4 5 0x00cf0d24
110 texture 208 2 3 4 5 0x00d00d24
111 texture 210 2 3 4 5 0x00d20d24
112 texture 211 2 3 4 5 0x00d30d24
113 texture 212 2 3 4 5 0x00d40d24
114 texture 213 2 3 4 5 0x00d50d24
115 texture 214 2 3 4 5 0x00d60d24
116 texture 215 2 3 4 5 0x00d70d24
117 texture 216 2 3 4 5 0x00d80d24
118 texture 217 2 3 4 5 0x00d90d24
119 texture 218 2 3 4 5 0x00da0d24
120 texture 222 2 3 4 5 0x00de0d24
121 texture 223 2 3 4 5 0x00df0d24
122 texture 224 2 3 4 5 0x00e00d24
123 texture 225 2 3 4 5 0x00e10d24
124 texture 226 2 3 4 5 0x00e20d24
125 texture 228 2 3 4 5 0x00e40d24
126 texture 229 2 3 4 5 0x00e50d24
127 texture 230 2 3 4 5 0x00e60d24
128 texture 231 2 3 4 5 0x00e70d24
129 texture 232 2 3 4 5 0x00e80d24
130 texture 233 2 3 4 5 0x00e90d24
131 texture 234 2 3 4 5 0x00ea0d24
132 texture 235 2 3 4 5 0x00eb0d24
133 texture 236 2 3 4 5 0x00ec0d24
134 texture 240 2 3 4 5 0x00f01f24
135 texture 241 2 3 4 5 0x00f11f24
136 texture 250 2 3 4 5 0x00fa1f24
137 texture 252 2 3 4 5 0x00fc1f24
138 texture 253 2 3 4 5 0x00fd1f24
139 texture 255 2 3 4 5 0x00ff1f24
140 texture 260 2 3 4 5 0x01041f24
141 texture 261 2 3 4 5 0x01051f24
142 texture 262 2 3 4 5 0x01061f24
143 texture 84 2 3 4 5 0x005409a4
144 texture 550 2 3 4 5 0x02260d24
145 texture 551 2 3 4 5 0x02270d24
146 texture 500 2 3 4 5 0x01f41f24
147 texture 502 2 3 4 5 0x01f61f24
148 texture 503 2 3 4 5 0x01f71f24
149 texture 505 2 3 4 5 0x01f91f24
150 texture 506 2 3 4 5 0x01fa1f24
151 texture 507 2 3 4 5 0x01fb1f24
152 texture 508 2 3 4 5 0x01fc1f24
153 texture 509 2 3 4 5 0x01fd1f24
154 texture 510 2 3 4 5 0x01fe1f24
155 texture 520 2 3 4 5 0x02081f24
156 texture 522 2 3 4 5 0x020a1f24
157 texture 523 2 3 4 5 0x020b1f24
158 texture 525 2 3 4 5 0x020d1f24
159 texture 526 2 3 4 5 0x020e1f24
160 texture 527 2 3 4 5 0x020f1f24
161 texture 528 2 3 4 5 0x02101f24
162 texture 529 2 3 4 5 0x02111f24
163 texture 530 2 3 4 5 0x02121f24
164 texture 540 2 3 4 5 0x021c1f24
165 texture 541 2 3 4 5 0x021d1f24
166 texture 542 2 3 4 5 0x021e1f24
167 texture 543 2 3 4 5 0x021f1f24
168 texture 544 2 3 4 5 0x02201f24
169 texture 545 2 3 4 5 0x02211f24
170 texture 185 2 3 4 5 0x00b90d24
171 texture 191 2 3 4 5 0x00bf0d24
172 texture 203 2 3 4 5 0x00cb0d24
173 texture 209 2 3 4 5 0x00d10d24
174 texture 221 2 3 4 5 0x00dd0d24
175 texture 227 2 3 4 5 0x00e30d24
176 texture 26 2 3 4 5 0x001a1e04
177 texture 44 2 3 4 5 0x002c0d24
178 texture 66 2 3 4 5 0x00421e24
179 texture 116 2 3 4 5 0x00740d24
180 texture 300 2 3 4 5 0x012c1f24
181 texture 301 2 3 4 5 0x012d1f24
182 texture 302 2 3 4 5 0x012e1f24
183 texture 303 2 3 4 5 0x012f1f24
184 texture 304 2 3 4 5 0x01301f24
185 texture 313 2 3 4 5 0x01391f24
186 texture 314 2 3 4 5 0x013a1f24
187 texture 315 2 3 4 5 0x013b1f24
188 texture 323 2 3 4 5 0x01431f24
189 texture 324 2 3 4 5 0x01441f24
190 texture 325 2 3 4 5 0x01451f24
191 texture 576 2 3 4 5 0x02401e04
192 texture 577 2 3 4 5 0x02411e04
193 texture 578 2 3 4 5 0x02421e24
194 texture 579 2 3 4 5 0x02431e24
195 texture 586 2 3 4 5 0x024a0d24
196 texture 1 0 3 4 5 0x00010800
197 texture 1 1 3 4 5 0x00010807
198 texture 1 3 3 4 5 0x00010800
199 texture 1 4 3 4 5 0x00010800
200 texture 1 5 3 4 5 0x00010804
201 texture 1 2 0 4 5 0x00010800
202 texture 1 2 1 4 5 0x00010838
203 texture 1 2 2 4 5 0x00010800
204 texture 1 2 4 4 5 0x00010800
205 texture 1 2 5 4 5 0x00010820
206 texture 1 2 3 0 5 0x00010800
207 texture 1 2 3 1 5 0x000109c0
208 texture 1 2 3 2 5 0x00010800
209 texture 1 2 3 3 5 0x00010800
210 texture 1 2 3 5 5 0x00010900
211 texture 1 2 3 4 0 0x00010000
212 texture 1 2 3 4 1 0x00010e00
213 texture 1 2 3 4 2 0x00010000
214 texture 1 2 3 4 3 0x00010000
215 texture 1 2 3 4 4 0x00010000
216 texture 10 0 3 4 5 0x000a1e00
217 texture 10 1 3 4 5 0x000a1e07
218 texture 10 3 3 4 5 0x000a1e00
219 texture 10 4 3 4 5 0x000a1e00
220 texture 10 5 3 4 5 0x000a1e07
221 texture 10 2 0 4 5 0x000a1e04
222 texture 10 2 1 4 5 0x000a1e3c
223 texture 10 2 2 4 5 0x000a1e24
224 texture 10 2 4 4 5 0x000a1e04
225 texture 10 2 5 4 5 0x000a1e3c
226 texture 10 2 3 0 5 0x000a1e04
227 texture 10 2 3 1 5 0x000a1fc4
228 texture 10 2 3 2 5 0x000a1f04
229 texture 10 2 3 3 5 0x000a1e04
230 texture 10 2 3 5 5 0x000a1fc4
231 texture 10 2 3 4 0 0x000a1004
232 texture 10 2 3 4 1 0x000a1e04
233 texture 10 2 3 4 2 0x000a1804
234 texture 10 2 3 4 3 0x000a1004
235 texture 10 2 3 4 4 0x000a1004
236 texture 30 0 3 4 5 0x001e1e20
237 texture 30 1 3 4 5 0x001e1e27
238 texture 30 3 3 4 5 0x001e1e24
239 texture 30 4 3 4 5 0x001e1e20
240 texture 30 5 3 4 5 0x001e1e27
241 texture 30 2 0 4 5 0x001e1e04
242 texture 30 2 1 4 5 0x001e1e3c
243 texture 30 2 2 4 5 0x001e1e24
244 texture 30 2 4 4 5 0x001e1e04
245 texture 30 2 5 4 5 0x001e1e3c
246 texture 30 2 3 0 5 0x001e1e24
247 texture 30 2 3 1 5 0x001e1fe4
248 texture 30 2 3 2 5 0x001e1f24
249 texture 30 2 3 3 5 0x001e1f24
250 texture 30 2 3 5 5 0x001e1fe4
251 texture 30 2 3 4 0 0x001e1024
252 texture 30 2 3 4 1 0x001e1e24
253 texture 30 2 3 4 2 0x001e1824
254 texture 30 2 3 4 3 0x001e1824
255 texture 30 2 3 4 4 0x001e1024
256 texture 70 0 3 4 5 0x00460d20
257 texture 70 1 3 4 5 0x00460d27
258 texture 70 3 3 4 5 0x00460d24
259 texture 70 4 3 4 5 0x00460d24
260 texture 70 5 3 4 5 0x00460d26
261 texture 70 2 0 4 5 0x00460d04
262 texture 70 2 1 4 5 0x00460d3c
263 texture 70 2 2 4 5 0x00460d24
264 texture 70 2 4 4 5 0x00460d24
265 texture 70 2 5 4 5 0x00460d34
266 texture 70 2 3 0 5 0x00460c24
267 texture 70 2 3 1 5 0x00460de4
268 texture 70 2 3 2 5 0x00460d24
269 texture 70 2 3 3 5 0x00460d24
270 texture 70 2 3 5 5 0x00460da4
271 texture 70 2 3 4 0 0x00460124
272 texture 70 2 3 4 1 0x00460f24
273 texture 70 2 3 4 2 0x00460924
274 texture 70 2 3 4 3 0x00460924
275 texture 70 2 3 4 4 0x00460924
276 texture 80 0 3 4 5 0x00500d20
277 texture 80 1 3 4 5 0x00500d27
278 texture 80 3 3 4 5 0x00500d24
279 texture 80 4 3 4 5 0x00500d24
280 texture 80 5 3 4 5 0x00500d26
281 texture 80 2 0 4 5 0x00500d04
282 texture 80 2 1 4 5 0x00500d3c
283 texture 80 2 2 4 5 0x00500d24
284 texture 80 2 4 4 5 0x00500d24
285 texture 80 2 5 4 5 0x00500d34
286 texture 80 2 3 0 5 0x00500c24
287 texture 80 2 3 1 5 0x00500de4
288 texture 80 2 3 2 5 0x00500d24
289 texture 80 2 3 3 5 0x00500d24
290 texture 80 2 3 5 5 0x00500da4
291 texture 80 2 3 4 0 0x00500124
292 texture 80 2 3 4 1 0x00500f24
293 texture 80 2 3 4 2 0x00500924
294 texture 80 2 3 4 3 0x00500924
295 texture 80 2 3 4 4 0x00500924
296 texture 53 0 3 4 5 0x00351e00
297 texture 53 1 3 4 5 0x00351e07
298 texture 53 3 3 4 5 0x00351e00
299 texture 53 4 3 4 5 0x00351e00
300 texture 53 5 3 4 5 0x00351e07
301 texture 53 2 0 4 5 0x00351e04
302 texture 53 2 1 4 5 0x00351e3c
303 texture 53 2 2 4 5 0x00351e24
304 texture 53 2 4 4 5 0x00351e04
305 texture 53 2 5 4 5 0x00351e3c
306 texture 53 2 3 0 5 0x00351e04
307 texture 53 2 3 1 5 0x00351fc4
308 texture 53 2 3 2 5 0x00351f04
309 texture 53 2 3 3 5 0x00351e04
310 texture 53 2 3 5 5 0x00351fc4
311 texture 53 2 3 4 0 0x00351004
312 texture 53 2 3 4 1 0x00351e04
313 texture 53 2 3 4 2 0x00351804
314 texture 53 2 3 4 3 0x00351004
315 texture 53 2 3 4 4 0x00351004
316 texture 252 0 3 4 5 0x00fc1f20
317 texture 252 1 3 4 5 0x00fc1f27
318 texture 252 3 3 4 5 0x00fc1f24
319 texture 252 4 3 4 5 0x00fc1f24
320 texture 252 5 3 4 5 0x00fc1f27
321 texture 252 2 0 4 5 0x00fc1f04
322 texture 252 2 1 4 5 0x00fc1f3c
323 texture 252 2 2 4 5 0x00fc1f24
324 texture 252 2 4 4 5 0x00fc1f24
325 texture 252 2 5 4 5 0x00fc1f3c
326 texture 252 2 3 0 5 0x00fc1e24
327 texture 252 2 3 1 5 0x00fc1fe4
328 texture 252 2 3 2 5 0x00fc1f24
329 texture 252 2 3 3 5 0x00fc1f24
330 texture 252 2 3 5 5 0x00fc1fe4
331 texture 252 2 3 4 0 0x00fc1124
332 texture 252 2 3 4 1 0x00fc1f24
333 texture 252 2 3 4 2 0x00fc1924
334 texture 252 2 3 4 3 0x00fc1924
335 texture 252 2 3 4 4 0x00fc1924
336 sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000000
337 sampler 1 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000002
338 sampler 0 1 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000004
339 sampler 2 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x40000000
340 sampler 0 2 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x40000000
341 sampler 0 0 1 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000008
342 sampler 0 0 2 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000010
343 sampler 0 0 0 1 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000020
344 sampler 0 0 0 0 1 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000100
345 sampler 0 0 0 0 0 1 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000800
346 sampler 0 0 0 2 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000040
347 sampler 0 0 0 0 2 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000200
348 sampler 0 0 0 0 0 2 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00001000
349 sampler 0 0 0 3 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000060
350 sampler 0 0 0 0 3 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000300
351 sampler 0 0 0 0 0 3 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00001800
352 sampler 0 0 0 4 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000080
353 sampler 0 0 0 0 4 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000400
354 sampler 0 0 0 0 0 4 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00002000
355 sampler 0 0 0 5 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x000000a0
356 sampler 0 0 0 0 5 0 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00000500
357 sampler 0 0 0 0 0 5 0 1 0x00000000 0x7f7fffff 0 1 0 0 0x00002800
358 sampler 0 0 0 0 0 0 1 1 0x00000000 0x7f7fffff 0 1 0 0 0x00004000
359 sampler 0 0 0 0 0 0 2 1 0x00000000 0x7f7fffff 0 1 0 0 0x00008000
360 sampler 0 0 0 0 0 0 0 0 0x00000000 0x7f7fffff 0 1 0 0 0x00000001
361 sampler 0 0 0 0 0 0 0 1 0x3e800000 0x7f7fffff 0 1 0 0 0x00000000
362 sampler 0 0 0 0 0 0 0 1 0x3f000000 0x7f7fffff 0 1 0 0 0x00000000
363 sampler 0 0 0 0 0 0 0 1 0x3f040000 0x7f7fffff 0 1 0 0 0x00400000
364 sampler 0 0 0 0 0 0 0 1 0x3f080000 0x7f7fffff 0 1 0 0 0x00400000
365 sampler 0 0 0 0 0 0 0 1 0x3f800000 0x7f7fffff 0 1 0 0 0x00400000
366 sampler 0 0 0 0 0 0 0 1 0x3fb33333 0x7f7fffff 0 1 0 0 0x00400000
367 sampler 0 0 0 0 0 0 0 1 0x3fcccccd 0x7f7fffff 0 1 0 0 0x00800000
368 sampler 0 0 0 0 0 0 0 1 0x40300000 0x7f7fffff 0 1 0 0 0x00c00000
369 sampler 0 0 0 0 0 0 0 1 0x41680000 0x7f7fffff 0 1 0 0 0x03800000
370 sampler 0 0 0 0 0 0 0 1 0x4169999a 0x7f7fffff 0 1 0 0 0x03c00000
371 sampler 0 0 0 0 0 0 0 1 0x41700000 0x7f7fffff 0 1 0 0 0x03c00000
372 sampler 0 0 0 0 0 0 0 1 0x42c80000 0x7f7fffff 0 1 0 0 0x03c00000
373 sampler 0 0 0 0 0 0 0 1 0x7f7fffff 0x7f7fffff 0 1 0 0 0x03c00000
374 sampler 0 0 0 0 0 0 0 1 0x00000000 0x00000000 0 1 0 0 0x3c000000
375 sampler 0 0 0 0 0 0 0 1 0x00000000 0x3f000000 0 1 0 0 0x3c000000
376 sampler 0 0 0 0 0 0 0 1 0x00000000 0x3f040000 0 1 0 0 0x38000000
377 sampler 0 0 0 0 0 0 0 1 0x00000000 0x3f080000 0 1 0 0 0x38000000
378 sampler 0 0 0 0 0 0 0 1 0x00000000 0x4079999a 0 1 0 0 0x2c000000
379 sampler 0 0 0 0 0 0 0 1 0x00000000 0x41600000 0 1 0 0 0x04000000
380 sampler 0 0 0 0 0 0 0 1 0x00000000 0x4169999a 0 1 0 0 0x00000000
381 sampler 0 0 0 0 0 0 0 1 0x00000000 0x41700000 0 1 0 0 0x00000000
382 sampler 0 0 0 0 0 0 0 1 0x00000000 0x447a0000 0 1 0 0 0x00000000
383 sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 1 1 0 0 0x00000000
384 sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 2 0 0 0x00200000
385 sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 3 0 0 0x00200000
386 sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 16 0 0 0x00200000
387 sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 1 0 0x00010000
388 sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 2 0 0x00020000
389 sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 3 0 0x00030000
390 sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 4 0 0x00040000
391 sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 5 0 0x00050000
392 sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 6 0 0x00060000
393 sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 7 0 0x00070000
394 sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 1 0x00080000
395 sampler 0 0 0 0 0 0 0 1 0x00000000 0x7f7fffff 0 1 0 2 0x00100000
396 sampler 1 2 2 2 3 5 2 0 0x40300000 0x41140000 1 8 6 2 0x58f6ab53
+85
View File
@@ -0,0 +1,85 @@
# Resource IDs
A Metal texture's or sampler's `gpuResourceID` is a 64-bit value that a shader reads from an
argument buffer or a buffer of its own and then samples, reads or writes through. Under the
translator's identity binding domains the ID is computed on the guest's side, with no round trip
to the runtime, from the index the consumer grants and the object's Metal descriptor:
```text
gpuResourceID = index | word << 32
```
The low 32 bits are the index into the pipeline's heap arrays (set 1, [API.md](API.md) section 5);
the high 32 bits are the word, which carries what a shader reads of the object beyond its
descriptor. Both are pure functions of what the guest already holds, so the same program produces
the same IDs on every run, and a replay reproduces them.
## Index classes
| Index | Object | Arrays it is valid in |
|---|---|---|
| 0 | nil (the ID 0) | none |
| 1 to 4,095 | a storage-capable texture: usage with `MTLTextureUsageShaderWrite`, or `MTLTextureUsageUnknown` | the sampled-image array and the storage-image array |
| 4,096 to 65,535 | any other texture | the sampled-image array |
| 1 to 3,999 | a sampler | the sampler array |
A texture view takes its own index, in the class of its own usage. A texture buffer has no index:
it is a typed refusal under these domains.
## The texture word
`metal2vulkan::metal::resource_word::TextureWord::of(pixelFormat, swizzle)`:
| Bits | Field |
|---|---|
| 0-11 | the border texels: bit `3c + b` is set where channel `c` (0 red, 1 green, 2 blue, 3 alpha) reads 1 rather than 0 outside the level for border color `b` (`MTLSamplerBorderColor`'s raw value) |
| 12 | the format has no alpha, so an out-of-bounds `read` reads alpha 1 |
| 13-15 | 0 |
| 16-31 | the `MTLPixelFormat` raw value |
The border texels are taken after the swizzle. A color format's channels are its own, a missing
red, green or blue reads 0 and a missing alpha reads 1; `A8Unorm`'s alpha is the color's red; a
format held rotated (`ARGB8Unorm`) reads red from the color's green, green from its blue, blue from
its alpha and alpha from its red; a depth or stencil format reads as red, green and blue, alpha 1.
Every pixel format's raw value is above 0, so a texture's word is never 0. The placeholders
(`Invalid`, `Unspecialized`) and the formats the translator holds no texture of or only copies have
no word.
## The sampler word
`metal2vulkan::metal::sampler::SamplerWord::of(descriptor)`. Each field holds its
`MTLSamplerDescriptor` value's raw Metal value, so the default descriptor's word is 0:
| Bits | Field |
|---|---|
| 0 | `normalizedCoordinates` is false |
| 1 | `minFilter` is `Linear` |
| 2 | `magFilter` is `Linear` |
| 3-4 | `mipFilter` |
| 5-7, 8-10, 11-13 | `sAddressMode`, `tAddressMode`, `rAddressMode` |
| 14-15 | `borderColor` |
| 16-18 | `compareFunction` |
| 19-20 | `reductionMode` |
| 21 | `maxAnisotropy` is above 1 |
| 22-25 | the level a nearest mip filter reads at `lodMinClamp` |
| 26-29 | 15 less the level a nearest mip filter reads at `lodMaxClamp` |
| 30 | `minFilter` or `magFilter` is `Cubic` |
| 31 | 0 |
The level a nearest mip filter reads at a clamp `c`: take `c` below 0 as 0, and below 64 truncate
it onto sixty-fourths of a level; if the result is 15 or more the level is 15; otherwise, with `L`
its whole levels and `q` its fraction, the level is `L + 1` where `q` is above one half, else `L`.
The LOD clamps themselves, `lodAverage` and the anisotropy's degree are not in the word: the
Vulkan sampler applies them.
## Test vectors
[`crates/metal2vulkan/tests/resource_words.tsv`](../crates/metal2vulkan/tests/resource_words.tsv)
holds one descriptor per line with its word, in tab-separated raw Metal values; its header names
the columns. A texture line is a pixel format and its four swizzle sources; a sampler line is every
`MTLSamplerDescriptor` field above, with `lodMinClamp` and `lodMaxClamp` as the float's IEEE-754
bits. Words are hexadecimal.
The translator's tests (`tests/resource_words.rs`) recompute every line's word and hold the file
equal to what the word functions generate, so a changed word changes the file. A guest's own
computation of the words checks itself against the same file.