Merge branch 'main' into ci/pr-template-check

This commit is contained in:
Ranveer Soni authored and GitHub committed 2026-11-24 13:08:58 +05:30
commit 67e6565fc2
22 files changed
+2041 -884

No files matched your search

+1 -1
View File
@@ -25,7 +25,7 @@ Closes #<!-- the issue you claimed -->
## Checklist
- [ ] I claimed the linked issue before starting, and the claim was still mine when I opened this pull request.
- [ ] I claimed the linked issue with a reply before starting, and nobody else held a live claim on it.
- [ ] I reviewed the changes and disclosed material AI assistance below, if applicable.
- [ ] The change preserves native ARM64 and Metal-first requirements.
- [ ] I added relevant tests or explained why they are not applicable.
+1 -1
View File
@@ -1,5 +1,5 @@
{
"lease_hours": 24,
"lease_hours": 168,
"upstream": "ranveersoni98/Xenora",
"maintainers": ["ranveersoni98"],
"contributors": {
+8 -8
View File
@@ -47,16 +47,16 @@ Read docs/interfaces.md and docs/progress.md before implementation.
## Claiming work before you start
Several people and coding agents work on this repository at the same time. An issue with no visible claim is the only signal that a task is free, so claim before you edit anything.
Several people and coding agents work on this repository at the same time. Claim an issue before you edit anything, and never take work someone else has claimed.
1. **Check.** Read the issue's comments, assignees and labels, its linked pull requests, and open pull requests that touch the same files. If someone holds a live claim, pick another task. Do not start parallel work on a claimed task.
2. **Claim.** Comment `/claim` on the issue (or run `scripts/agent-queue.sh claim <n>`). Where the claim workflow is enabled, wait for its grant comment and the `claimed-by:<login>` label; a refusal names the reason. Where it is not enabled yet, your comment is the claim and the earliest valid claim comment wins. One issue per claim; claim follow-up tasks separately.
3. **Respect file ownership.** Two claimed tasks never edit the same files at the same time. If the issue lists files, edit only those; ask the maintainer before widening the list.
4. **Keep it alive.** A claim lapses 24 hours after the latest grant, `/progress <what changed>` comment, or push to the linked pull request. Post `/progress` at least once a day while you work. Lapsed tasks return to the queue and may be claimed by anyone.
5. **Release.** If you stop, comment `/release` so the task returns to the queue. Use `/blocked <reason>` instead if you are waiting on another task.
6. **Link.** Open the pull request from a branch named `task/<n>-<slug>` with `Closes #<n>` in its description.
1. **Check.** Read every comment on the issue and look for open pull requests that link it. A claim is any comment in which someone says they are taking the issue, in any words (for example "I'll take this" or `/claim`). If a claim exists and is not stale (step 4), pick another issue.
2. **Claim.** Reply on the issue in plain words, for example: "I'm taking this. Plan: …". No command, label or bot step is needed. The earliest claim wins. Claim one issue per comment.
3. **Stay in scope.** If the issue lists files, edit only those, and ask on the issue before widening the list. Do not start work that edits the same files as another claimed issue.
4. **Stale claims.** A claim is stale when the claimer has not opened a pull request for the issue within about one week (7 days) of the claim. Only then may someone else take it, by replying on the issue, for example: "Taking this over: @name's claim from <date> has no pull request after 7 days." A claim with an open pull request is never stale; ask the claimer or the maintainer instead.
5. **Release.** If you stop working on an issue, say so on the issue so others can take it.
6. **Link.** Put `Closes #<n>` in the pull request description.
An agent acting for a contributor claims in that contributor's name and must not claim work for areas that contributor may not claim (`.github/agent-queue.json`). Never remove, overwrite or ignore another person's claim; ask the maintainer to `/reassign` instead. See `docs/coordination/agent-tasks.md` when present.
A coding agent claims in the name of the person it works for and follows the same rules. It must read the comments before claiming, and must never claim over, remove or ignore another person's claim. The optional task-queue commands in `docs/coordination/agent-tasks.md` do not replace these rules: a plain-reply claim counts even though the bot does not track it.
## Changelog maintenance
+14 -1
View File
@@ -11,7 +11,9 @@ remains unsupported.
### Added
- Added a *PR template* check (`.github/workflows/pr-template.yml`, `scripts/pr_template_check.py`) that fails when a pull request description skips the template: a missing or empty section, no `Closes #<number>` or `No linked issue: <reason>`, or an unticked claimed-first or DCO checkbox. It lists what is missing, runs again when the description is edited, never runs pull request code, and has unit tests in `tests/pr_template/`. It blocks merges only once marked required in branch protection.
- Added complete gfx1030 instruction metadata generated from AMD's public RDNA 2 XML: 1,465 base forms across 21 encoding families with fields, operands, flags and allowed extension words. A committed, normalised snapshot lets `crates/isa/generate_rdna2_meta.py --check` verify the generated table offline; CI runs it.
- Added `xenora_isa::meta::identify`, which finds any gfx1030 instruction's form and exact length, including literal, SDWA, DPP and NSA words, and rejects truncated, unassigned and disallowed-extension encodings. It agrees with every LLVM-assembled fixture and with LLVM 23.1.6 on a probe set covering each family and extension word. Identification does not make an instruction executable: 25 forms have semantic decoding.
- Added `xenora shaders coverage [--json]` and `xenora shaders inspect <file>` for per-family coverage and stream listings that separate decoding failures from unsupported semantics. Each instruction is decoded at its stream offset and branch targets are checked against the whole stream's boundaries, so supported branches are no longer misreported as unsupported operands. `xenora_decoder::decode_at` decodes a single instruction for such callers.
- Added an agent task queue for the cpu, gpu, runtime, shared and qa areas: an *Agent task* issue form with priority and interface fields, a workflow that decides `/claim`, `/release`, `/reassign`, `/progress`, `/blocked`, `/unblock` and `/approve-acceptance` comments one at a time (dependency, cycle and file-overlap checks, 24-hour leases renewed by progress), a pull request check (linked claimed task, file ownership, overlap with other pull requests, independent `/verified <head sha>`), `scripts/agent-queue.sh` and `scripts/agent-sync.sh` (upstream fetch every 12 minutes, task branches in separate worktrees) and a machine-readable queue summary. The rules are standard-library Python in `scripts/agent_queue/` with unit tests in `tests/agent_queue/`; issue text is never executed and acceptance commands need maintainer approval. Only comments that start with a command start a job, so ordinary pull request comments never re-run verification, and only an accepted `/verified <full head sha>` evaluates the check again; and each claim run decides every unanswered command in order, so commands whose pending runs GitHub cancelled are still answered. See `docs/coordination/agent-tasks.md`. Unit tests pass locally; the workflows have not run on GitHub yet, and the pull request check stays advisory (it never blocks a merge) until a live smoke test and the migration of existing issues are done.
- Added explicit claim-before-work rules for contributors and coding agents to `AGENTS.md`, `CONTRIBUTING.md` and the pull request template: check for existing claims, claim with `/claim`, keep a 24-hour lease alive with `/progress`, `/release` when stopping, and link the claimed issue. Without the claim workflow, the earliest valid claim comment wins.
- Added a CPU decoder for a bounded subset of BC6H (signed and unsigned HDR) in
@@ -20,6 +22,16 @@ remains unsupported.
zero as specified. The ten two-subset modes are rejected with `Bc6hError::UnsupportedMode`
and are not implemented. Tests check hand-derived values and 128 known-answer vectors from a
separate clean-room reference decoder.
- Added native Metal upload and readback of BC4 and BC5 textures (UNORM and SNORM):
`xenora-texture` gains a pitched `BcChannelUpload`, and `NativeCompute::read_bc_channel_upload`
sends the original blocks to `BC4_R*` or `BC5_RG*` textures when the device reports BC
support, failing with `supportsBCTextureCompression` otherwise. GPU tests cover six- and
eight-value interpolation, equal and extreme endpoints (signed -128 reads as -1.0), red-green
channel order, padded row and slice pitches, two layers and two mips against the CPU decoders
and hand-derived anchors. On an Apple M5 Pro interpolated codes were within 1.71 codes of the
exact values and up to two codes from the truncating CPU reference.
Edge levels of 5×3 and 1×1 and invalid payloads (zero extents, short, oversized or
block-count-mismatched buffers) are covered.
- Added native Metal upload and readback of BC2 and BC3 textures: `xenora-texture` gains a
pitched `BcAlphaUpload` for 16-byte blocks, and `NativeCompute::read_bc_alpha_upload` sends
the original blocks to `BC2_RGBA` or `BC3_RGBA` textures when the device reports BC support.
@@ -44,6 +56,7 @@ remains unsupported.
### Changed
- Simplified the claim rules in `AGENTS.md`, `CONTRIBUTING.md` and the pull request template at the maintainer's request: claim an issue by replying on it in plain words, never claim over an existing claim, and treat a claim as stale only after about one week without a pull request. The task-queue lease (`lease_hours` in `.github/agent-queue.json`) is now 168 hours to match, and `docs/coordination/agent-tasks.md` marks the queue commands as optional.
- The static PE probe now marks x86-64 SIB memory addressing as DBT-supported, matching the
native DBT.
+1 -1
View File
@@ -6,7 +6,7 @@ Xenora is an experimental Xbox Series X|S recompilation framework for Apple Sili
- Read `README.md` and, when present, `AGENTS.md`, `docs/interfaces.md`, `docs/status.toml` and the relevant architecture decisions.
- Discuss substantial changes in an issue before implementing them; small fixes do not require prior approval.
- Claim an issue before working on it by commenting `/claim`, and check that nobody else holds a live claim first. Claims lapse after 24 hours without a `/progress` comment or a push; comment `/release` if you stop. Coding agents follow the same rules; see "Claiming work before you start" in `AGENTS.md`.
- Claim an issue before working on it by replying on it in plain words, after checking its comments for an existing claim. Never claim over someone else. A claim with no pull request after about one week may be taken over with a reply saying so. Coding agents follow the same rules; see "Claiming work before you start" in `AGENTS.md`.
- Use a native ARM64 macOS environment with Rust and the appropriate Xcode/Metal tools. LLVM AMDGPU tools are needed for ISA fixture generation; extra tooling depends on the subsystem.
- Keep changes focused and preserve existing public interfaces unless a change is justified and documented.
+4
View File
@@ -327,6 +327,10 @@ Compiling a shader is not equivalent to proving its GPU output is correct.
---
### Contributors
[![Contributors](https://contrib.rocks/image?repo=ranveersoni98/Xenora)](https://github.com/ranveersoni98/Xenora/graphs/contributors)
## License
Xenora is licensed under the [GNU General Public License v3 or later](LICENSE).
+200 -28
View File
@@ -2,7 +2,7 @@
use std::process::ExitCode;
use xenora_decoder::{Architecture, SEMANTIC_FORMS, decode};
use xenora_decoder::{Architecture, SEMANTIC_FORMS, decode_at};
use xenora_isa::meta::{self, EncodingFamily, FORMS, identify};
const USAGE: &str = "usage: xenora shaders <coverage [--json] | inspect <gfx1030.bin>>";
@@ -34,12 +34,19 @@ fn semantic(family: EncodingFamily) -> usize {
/// with their length; "semantic" forms decode into executable instructions.
/// Reference, Metal and native GPU evidence per form stays in docs/status.toml.
fn coverage(json: bool) -> ExitCode {
print!("{}", coverage_report(json));
ExitCode::SUCCESS
}
fn coverage_report(json: bool) -> String {
use std::fmt::Write as _;
let rows: Vec<_> = meta::inventory()
.into_iter()
.map(|(family, discovered)| (family, discovered, semantic(family)))
.collect();
let total: usize = rows.iter().map(|row| row.1).sum();
let supported: usize = rows.iter().map(|row| row.2).sum();
let mut out = String::new();
if json {
let families: Vec<String> = rows
.iter()
@@ -50,20 +57,31 @@ fn coverage(json: bool) -> ExitCode {
)
})
.collect();
println!(
writeln!(
out,
"{{\"architecture\":\"gfx1030\",\"source_sha256\":\"{}\",\"discovered\":{total},\"semantic\":{supported},\"families\":[{}]}}",
meta::SOURCE_SHA256,
families.join(",")
);
)
.unwrap();
} else {
println!("{:<10} {:>10} {:>9}", "family", "discovered", "semantic");
writeln!(
out,
"{:<10} {:>10} {:>9}",
"family", "discovered", "semantic"
)
.unwrap();
for (family, discovered, semantic) in &rows {
println!("{:<10} {discovered:>10} {semantic:>9}", family.name());
writeln!(out, "{:<10} {discovered:>10} {semantic:>9}", family.name()).unwrap();
}
println!("{:<10} {total:>10} {supported:>9}", "total");
println!("Semantic forms decode for the operand subsets in docs/status.toml only.");
writeln!(out, "{:<10} {total:>10} {supported:>9}", "total").unwrap();
writeln!(
out,
"Semantic forms decode for the operand subsets in docs/status.toml only."
)
.unwrap();
}
ExitCode::SUCCESS
out
}
fn inspect(path: &str) -> ExitCode {
@@ -74,43 +92,197 @@ fn inspect(path: &str) -> ExitCode {
return ExitCode::FAILURE;
}
};
let listing = listing(&bytes);
for row in &listing.rows {
println!("{row}");
}
if let Some(failure) = listing.failure {
println!("{failure}");
return ExitCode::FAILURE;
}
println!(
"{} instructions inspected against {} gfx1030 forms; {} without semantic decoding",
listing.rows.len(),
FORMS.len(),
listing.unsupported
);
ExitCode::SUCCESS
}
/// The printed rows of `xenora shaders inspect`, the number of rows that do
/// not decode into executable instructions and the identification failure
/// that ended the stream early, if any.
struct Listing {
rows: Vec<String>,
unsupported: usize,
failure: Option<String>,
}
fn listing(bytes: &[u8]) -> Listing {
let mut listing = Listing {
rows: Vec::new(),
unsupported: 0,
failure: None,
};
// Identify every instruction first: a branch target is valid only if it
// lands on one of these boundaries, which no single instruction can show.
let mut forms = Vec::new();
let mut offset = 0;
let mut unsupported = 0;
let mut count = 0;
while offset < bytes.len() {
let found = match identify(&bytes[offset..]) {
Ok(found) => found,
Err(error) => {
println!("{offset:#06x} decode failure: {error}");
return ExitCode::FAILURE;
match identify(&bytes[offset..]) {
Ok(found) => {
forms.push((offset, found));
offset += found.len;
}
};
let words: Vec<String> = bytes[offset..offset + found.len]
Err(error) => {
listing.failure = Some(format!("{offset:#06x} decode failure: {error}"));
break;
}
}
}
let boundary = |target: usize| forms.binary_search_by_key(&target, |form| form.0).is_ok();
// Past the last identified instruction the boundaries are unknown.
let identified = forms
.last()
.map_or(0, |&(offset, found)| offset + found.len);
for &(offset, found) in &forms {
let instruction = &bytes[offset..offset + found.len];
let words: Vec<String> = instruction
.chunks(4)
.map(|chunk| format!("{:08x}", u32::from_le_bytes(chunk.try_into().unwrap())))
.collect();
let status = match decode(Architecture::Gfx1030, &bytes[offset..offset + found.len]) {
Ok(_) => "semantic".to_owned(),
let status = match decode_at(Architecture::Gfx1030, &bytes[..offset + found.len], offset) {
Ok(decoded) => match decoded.branch_target() {
Some(target) if listing.failure.is_some() && target >= identified => {
format!("branch target {target:#04x} unverified: stream not identified there")
}
Some(target) if !boundary(target) => {
format!("invalid branch target {target:#04x}")
}
_ => "semantic".to_owned(),
},
Err(error) if SEMANTIC_FORMS.contains(&(found.form.name, found.form.family)) => {
format!("unsupported operands: {error}")
}
Err(_) => "unsupported instruction semantics".to_owned(),
};
if status != "semantic" {
unsupported += 1;
listing.unsupported += 1;
}
println!(
listing.rows.push(format!(
"{offset:#06x} {:<8} {:<28} {:<26} {status}",
found.form.family.name(),
found.form.name.to_ascii_lowercase(),
words.join(" ")
));
}
listing
}
#[cfg(test)]
mod tests {
use super::{coverage_report, listing};
use xenora_decoder::SEMANTIC_FORMS;
use xenora_isa::meta::{EncodingFamily, FORMS};
#[test]
fn coverage_totals_match_the_generated_table() {
let json = coverage_report(true);
assert!(json.starts_with("{\"architecture\":\"gfx1030\""), "{json}");
assert!(json.ends_with("}]}\n"), "{json}");
assert_eq!(json.matches('{').count(), json.matches('}').count());
let totals = format!(
"\"discovered\":{},\"semantic\":{},\"families\":[",
FORMS.len(),
SEMANTIC_FORMS.len()
);
offset += found.len;
count += 1;
assert!(json.contains(&totals), "{json}");
let families: Vec<usize> = json
.split("{\"family\":")
.skip(1)
.map(|row| {
let count = row.split("\"discovered\":").nth(1).unwrap();
count[..count.find(',').unwrap()].parse().unwrap()
})
.collect();
assert_eq!(families.len(), EncodingFamily::ALL.len());
assert_eq!(families.iter().sum::<usize>(), FORMS.len());
let text = coverage_report(false);
let total = format!(
"{:<10} {:>10} {:>9}\n",
"total",
FORMS.len(),
SEMANTIC_FORMS.len()
);
assert!(text.contains(&total), "{text}");
}
fn program(words: &[u32]) -> Vec<u8> {
words.iter().flat_map(|word| word.to_le_bytes()).collect()
}
#[test]
fn branches_in_a_valid_program_are_semantic() {
let fixture = include_bytes!("../../../fixtures/rdna2/bitwise-branch.bin");
let listing = listing(fixture);
assert_eq!(listing.failure, None);
assert_eq!(listing.rows.len(), 15);
let branches: Vec<_> = listing
.rows
.iter()
.filter(|row| row.contains("branch"))
.collect();
assert_eq!(branches.len(), 3);
for row in &branches {
assert!(row.ends_with(" semantic"), "{row}");
}
assert_eq!(listing.unsupported, 0);
}
#[test]
fn targets_past_an_identification_failure_are_unverified() {
// s_branch 1 targets 0x08; 0xbfff0000 is not a gfx1030 form, so
// nothing past 0x04 is identified; s_endpgm.
let listing = listing(&program(&[0xbf82_0001, 0xbfff_0000, 0xbf81_0000]));
assert!(listing.failure.as_deref().unwrap().starts_with("0x0004"));
assert_eq!(listing.rows.len(), 1);
assert!(
listing.rows[0].ends_with("branch target 0x08 unverified: stream not identified there"),
"{}",
listing.rows[0]
);
}
#[test]
fn add_fixture_is_fully_semantic() {
let listing = listing(include_bytes!("../../../fixtures/rdna2/add.bin"));
assert_eq!(listing.failure, None);
assert_eq!(listing.rows.len(), 7);
assert_eq!(listing.unsupported, 0);
}
#[test]
fn branch_targets_are_checked_against_the_whole_stream() {
// s_branch 1 skips one word; s_cbranch_scc0 1 lands inside the
// two-word v_mov_b32 literal form; s_endpgm.
let listing = listing(&program(&[
0xbf82_0001,
0xbf84_0001,
0x7e04_02ff,
0x00ff_00ff,
0xbf81_0000,
]));
assert_eq!(listing.failure, None);
assert!(
listing.rows[0].ends_with(" semantic"),
"{}",
listing.rows[0]
);
assert!(
listing.rows[1].ends_with("invalid branch target 0x0c"),
"{}",
listing.rows[1]
);
assert_eq!(listing.unsupported, 1);
}
println!(
"{count} instructions inspected against {} gfx1030 forms; {unsupported} not executable",
FORMS.len()
);
ExitCode::SUCCESS
}
+44 -15
View File
@@ -56,6 +56,20 @@ pub struct DecodedInstruction {
pub instruction: Instruction,
}
impl DecodedInstruction {
/// Destination byte offset of a branch, from the start of the stream.
#[must_use]
pub fn branch_target(&self) -> Option<usize> {
match self.instruction {
Instruction::Branch { target }
| Instruction::BranchSccZero { target }
| Instruction::BranchExecZero { target }
| Instruction::BranchVccZero { target } => Some(target),
_ => None,
}
}
}
impl fmt::Display for DecodedInstruction {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(formatter, "{:04x}: {}", self.offset, self.instruction)
@@ -140,26 +154,15 @@ pub fn decode(
architecture: Architecture,
bytes: &[u8],
) -> Result<Vec<DecodedInstruction>, DecodeError> {
let decode_instruction = match architecture {
Architecture::Gfx1030 => decode_gfx1030,
};
let mut result = Vec::new();
let mut offset = 0;
while offset < bytes.len() {
let (instruction, byte_len) = decode_instruction(&bytes[offset..], offset)
.map_err(|kind| DecodeError { offset, kind })?;
result.push(DecodedInstruction {
offset,
byte_len,
instruction,
});
offset += usize::from(byte_len);
let decoded = decode_at(architecture, bytes, offset)?;
offset += usize::from(decoded.byte_len);
result.push(decoded);
}
for decoded in &result {
if let Instruction::Branch { target }
| Instruction::BranchSccZero { target }
| Instruction::BranchExecZero { target }
| Instruction::BranchVccZero { target } = decoded.instruction
if let Some(target) = decoded.branch_target()
&& result
.binary_search_by_key(&target, |item| item.offset)
.is_err()
@@ -173,6 +176,32 @@ pub fn decode(
Ok(result)
}
/// Decodes the one instruction that starts at `offset` in `bytes`. Branch
/// targets are stream offsets, but whether they land on an instruction
/// boundary is left to the caller, which knows the rest of the stream.
///
/// # Errors
///
/// Returns `offset` with a truncated instruction, unsupported opcode or
/// unsupported form. An `offset` at or past the end is truncated.
pub fn decode_at(
architecture: Architecture,
bytes: &[u8],
offset: usize,
) -> Result<DecodedInstruction, DecodeError> {
let decode_instruction = match architecture {
Architecture::Gfx1030 => decode_gfx1030,
};
let rest = bytes.get(offset..).unwrap_or_default();
let (instruction, byte_len) =
decode_instruction(rest, offset).map_err(|kind| DecodeError { offset, kind })?;
Ok(DecodedInstruction {
offset,
byte_len,
instruction,
})
}
fn word(bytes: &[u8], end: u8) -> Result<u32, DecodeErrorKind> {
let end_index = usize::from(end);
let Some(word) = bytes
+27 -1
View File
@@ -4,7 +4,7 @@ use std::process::{Command, Stdio};
use xenora_decoder::{
Architecture, DecodeError, DecodeErrorKind, DecodedInstruction, Instruction, ScalarSource,
VectorSource, decode,
VectorSource, decode, decode_at,
};
use xenora_ref::{BranchCondition, Op, Source, VectorAlu};
@@ -786,3 +786,29 @@ fn accepts_scalar_destination_105_and_vgpr_zero_add_sources() {
}
);
}
#[test]
fn decode_at_resolves_branch_targets_from_the_stream_offset() {
let decoded = decode_at(Architecture::Gfx1030, BITWISE_FIXTURE, 0x1c).unwrap();
assert_eq!(decoded.offset, 0x1c);
assert_eq!(decoded.byte_len, 4);
assert_eq!(decoded.branch_target(), Some(0x3c));
// Alone, the same branch still reports its stream target; only the whole
// stream can say whether that target is an instruction boundary.
let isolated = decode_at(Architecture::Gfx1030, &BITWISE_FIXTURE[..0x20], 0x1c).unwrap();
assert_eq!(isolated.branch_target(), Some(0x3c));
assert_eq!(
decode_at(
Architecture::Gfx1030,
BITWISE_FIXTURE,
BITWISE_FIXTURE.len()
),
Err(DecodeError {
offset: BITWISE_FIXTURE.len(),
kind: DecodeErrorKind::Truncated {
needed: 4,
available: 0
},
})
);
}
+5 -5
View File
@@ -2243,7 +2243,7 @@
{"condition":"has_lit_0","encoding":"SOPC_INST_LITERAL","instruction":"S_CMP_LT_U32","kind":"variant","opcode":10}
{"condition":"has_lit_0_has_lit_1","encoding":"SOPC_INST_LITERAL","instruction":"S_CMP_LT_U32","kind":"variant","opcode":10}
{"condition":"has_lit_1","encoding":"SOPC_INST_LITERAL","instruction":"S_CMP_LT_U32","kind":"variant","opcode":10}
{"condition":"default","encoding":"SOPK_INST_LITERAL","instruction":"S_SETREG_IMM32_B32","kind":"variant","opcode":21}
{"condition":"default","encoding":"SOPK_INST_LITERAL","flags":[],"group":"SALU","instruction":"S_SETREG_IMM32_B32","kind":"variant","opcode":21,"operands":[["SIMM16","FMT_NUM_B16","OPR_HWREG",16,false,true,false,true],["LITERAL","FMT_NUM_B32","OPR_SIMM32",32,true,false,false,true]],"subgroups":["NOT_ASSIGNED"]}
{"condition":"has_lit","encoding":"VOP1_INST_LITERAL","instruction":"V_BFREV_B32","kind":"variant","opcode":56}
{"condition":"has_lit","encoding":"VOP1_INST_LITERAL","instruction":"V_CEIL_F16","kind":"variant","opcode":92}
{"condition":"has_lit","encoding":"VOP1_INST_LITERAL","instruction":"V_CEIL_F32","kind":"variant","opcode":34}
@@ -2503,16 +2503,16 @@
{"condition":"has_lit","encoding":"VOP2_INST_LITERAL","instruction":"V_CVT_PKRTZ_F16_F32","kind":"variant","opcode":47}
{"condition":"has_lit","encoding":"VOP2_INST_LITERAL","instruction":"V_DOT2C_F32_F16","kind":"variant","opcode":2}
{"condition":"has_lit","encoding":"VOP2_INST_LITERAL","instruction":"V_DOT4C_I32_I8","kind":"variant","opcode":13}
{"condition":"default","encoding":"VOP2_INST_LITERAL","instruction":"V_FMAAK_F16","kind":"variant","opcode":56}
{"condition":"default","encoding":"VOP2_INST_LITERAL","flags":[],"group":"VALU","instruction":"V_FMAAK_F16","kind":"variant","opcode":56,"operands":[["VDST","FMT_NUM_F16","OPR_VGPR",16,false,true,false,true],["SRC0","FMT_NUM_F16","OPR_SRC",16,true,false,false,true],["VSRC1","FMT_NUM_F16","OPR_VGPR",16,true,false,false,true],["LITERAL","FMT_NUM_F16","OPR_SIMM16",16,true,false,false,true]],"subgroups":["NOT_ASSIGNED"]}
{"condition":"has_lit","encoding":"VOP2_INST_LITERAL","instruction":"V_FMAAK_F16","kind":"variant","opcode":56}
{"condition":"default","encoding":"VOP2_INST_LITERAL","instruction":"V_FMAAK_F32","kind":"variant","opcode":45}
{"condition":"default","encoding":"VOP2_INST_LITERAL","flags":[],"group":"VALU","instruction":"V_FMAAK_F32","kind":"variant","opcode":45,"operands":[["VDST","FMT_NUM_F32","OPR_VGPR",32,false,true,false,true],["SRC0","FMT_NUM_F32","OPR_SRC",32,true,false,false,true],["VSRC1","FMT_NUM_F32","OPR_VGPR",32,true,false,false,true],["LITERAL","FMT_NUM_F32","OPR_SIMM32",32,true,false,false,true]],"subgroups":["NOT_ASSIGNED"]}
{"condition":"has_lit","encoding":"VOP2_INST_LITERAL","instruction":"V_FMAAK_F32","kind":"variant","opcode":45}
{"condition":"has_lit","encoding":"VOP2_INST_LITERAL","instruction":"V_FMAC_F16","kind":"variant","opcode":54}
{"condition":"has_lit","encoding":"VOP2_INST_LITERAL","instruction":"V_FMAC_F32","kind":"variant","opcode":43}
{"condition":"has_lit","encoding":"VOP2_INST_LITERAL","instruction":"V_FMAC_LEGACY_F32","kind":"variant","opcode":6}
{"condition":"default","encoding":"VOP2_INST_LITERAL","instruction":"V_FMAMK_F16","kind":"variant","opcode":55}
{"condition":"default","encoding":"VOP2_INST_LITERAL","flags":[],"group":"VALU","instruction":"V_FMAMK_F16","kind":"variant","opcode":55,"operands":[["VDST","FMT_NUM_F16","OPR_VGPR",16,false,true,false,true],["SRC0","FMT_NUM_F16","OPR_SRC",16,true,false,false,true],["LITERAL","FMT_NUM_F16","OPR_SIMM16",16,true,false,false,true],["VSRC1","FMT_NUM_F16","OPR_VGPR",16,true,false,false,true]],"subgroups":["NOT_ASSIGNED"]}
{"condition":"has_lit","encoding":"VOP2_INST_LITERAL","instruction":"V_FMAMK_F16","kind":"variant","opcode":55}
{"condition":"default","encoding":"VOP2_INST_LITERAL","instruction":"V_FMAMK_F32","kind":"variant","opcode":44}
{"condition":"default","encoding":"VOP2_INST_LITERAL","flags":[],"group":"VALU","instruction":"V_FMAMK_F32","kind":"variant","opcode":44,"operands":[["VDST","FMT_NUM_F32","OPR_VGPR",32,false,true,false,true],["SRC0","FMT_NUM_F32","OPR_SRC",32,true,false,false,true],["LITERAL","FMT_NUM_F32","OPR_SIMM32",32,true,false,false,true],["VSRC1","FMT_NUM_F32","OPR_VGPR",32,true,false,false,true]],"subgroups":["NOT_ASSIGNED"]}
{"condition":"has_lit","encoding":"VOP2_INST_LITERAL","instruction":"V_FMAMK_F32","kind":"variant","opcode":44}
{"condition":"has_lit","encoding":"VOP2_INST_LITERAL","instruction":"V_LDEXP_F16","kind":"variant","opcode":59}
{"condition":"has_lit","encoding":"VOP2_INST_LITERAL","instruction":"V_LSHLREV_B32","kind":"variant","opcode":26}
+16 -5
View File
@@ -204,7 +204,7 @@ def snapshot_from_xml(data):
}
# Extension variants keep only what classifies them; their
# operands repeat the base form with a literal, SDWA, DPP or NSA word.
if encoding_name in BASE_ENCODINGS:
if encoding_name in BASE_ENCODINGS or condition == "default":
record.update({
"flags": sorted(flag for flag, value in flags.items() if value),
"group": text(group, "Name"),
@@ -256,22 +256,33 @@ def forms_from_snapshot(snapshot):
entry.add("always_literal")
entry.add(kind)
based = {(variant["instruction"], variant["encoding"]) for variant in variants if variant["encoding"] in BASE_ENCODINGS}
forms = []
for variant in variants:
encoding_name = variant["encoding"]
if encoding_name not in BASE_ENCODINGS:
identity = encoding_name
if encoding_name in EXTENSIONS:
# A few instructions exist only with a literal (S_SETREG_IMM32_B32,
# V_FMAMK_F32, ...): the XML lists them under the literal encoding's
# default condition and gives them no base variant.
base, kind = EXTENSIONS[encoding_name]
if kind != "literal" or variant["condition"] != "default" or (variant["instruction"], base) in based:
continue
encoding_name = base
elif encoding_name not in BASE_ENCODINGS:
continue
# Three VOP1/VOP3 relative moves name the excluded extensions instead of "default".
if variant["condition"] != "default" and not variant["condition"].startswith("Nothas_"):
fail(f"{variant['instruction']} has non-default base condition {variant['condition']}")
encoding = encodings[encoding_name]
id_encoding = encodings[identity]
fields = dict((name, ranges) for name, ranges in encoding["fields"])
prefix_mask, _ = place(0, fields["ENCODING"])
prefixes = {identifier & prefix_mask for identifier in encoding["identifiers"]}
prefixes = {identifier & prefix_mask for identifier in id_encoding["identifiers"]}
if len(prefixes) != 1:
fail(f"{encoding_name} has an ambiguous encoding prefix")
prefix = prefixes.pop()
id_mask = encoding["identifier_mask"]
id_mask = id_encoding["identifier_mask"] & 0xFFFFFFFF
opcode = variant["opcode"]
if "OP" in fields:
op_mask, op_bits = place(opcode, fields["OP"])
@@ -285,7 +296,7 @@ def forms_from_snapshot(snapshot):
# first-dword identifiers cannot express; carry it separately.
low = 0xFFFFFFFF
candidates = sorted({
identifier for identifier in encoding["identifiers"]
identifier & 0xFFFFFFFF for identifier in id_encoding["identifiers"]
if identifier & (prefix_mask | op_mask) & low == (prefix | op_bits) & low
})
if len(candidates) != 1:
File diff suppressed because it is too large. Load diff
+41
View File
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// One instruction per line for each family and extension word; checked against llvm-mc.
s_mov_b32 s0, 0x12345678
s_add_u32 s0, s1, 0x1234
s_cmp_eq_u32 s0, 0xdeadbeef
s_movk_i32 s0, 0x1234
s_setreg_imm32_b32 hwreg(HW_REG_MODE), 0x0
s_load_dwordx4 s[0:3], s[4:5], 0x10
s_nop 0
s_endpgm
v_mov_b32 v0, 0x12345678
v_mov_b32_sdwa v0, v1 dst_sel:BYTE_0 dst_unused:UNUSED_PAD src0_sel:DWORD
v_mov_b32_dpp v0, v1 quad_perm:[1,0,3,2] row_mask:0xf bank_mask:0xf
v_mov_b32_dpp v0, v1 dpp8:[1,0,3,2,5,4,7,6]
v_mov_b32_dpp v0, v1 dpp8:[1,0,3,2,5,4,7,6] fi:1
v_add_f32_sdwa v0, v1, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:DWORD
v_add_f32_dpp v0, v1, v2 row_shl:1 row_mask:0xf bank_mask:0xf
v_cmp_eq_u32_e32 vcc_lo, 0x1234, v1
v_cmp_eq_u32_sdwa s0, v1, v2 src0_sel:DWORD src1_sel:DWORD
v_fmamk_f32 v0, v1, 0x40000000, v2
v_fmaak_f32 v0, v1, v2, 0x40000000
v_fma_f32 v0, v1, v2, 0x3f800001
v_add_co_u32 v0, s0, v1, v2
v_readlane_b32 s0, v1, 0
v_pk_add_f16 v0, v1, v2
v_pk_fma_f16 v0, v1, v2, 0x3c01
v_interp_p1_f32 v0, v1, attr0.x
ds_write_b32 v0, v1
ds_read_b32 v0, v1 offset:16
buffer_load_dword v0, off, s[0:3], 0
tbuffer_load_format_x v0, off, s[0:3], 0 format:[BUF_FMT_32_FLOAT]
tbuffer_load_format_d16_x v0, off, s[0:3], 0 format:[BUF_FMT_32_FLOAT]
tbuffer_store_format_d16_xyzw v[0:1], off, s[0:3], 0 format:[BUF_FMT_32_FLOAT]
image_sample v[0:3], v[0:1], s[0:7], s[8:11] dmask:0xf dim:SQ_RSRC_IMG_2D
image_sample v[0:3], [v0, v2], s[0:7], s[8:11] dmask:0xf dim:SQ_RSRC_IMG_2D
image_sample_c v[0:3], [v0, v2, v4, v6], s[0:7], s[8:11] dmask:0xf dim:SQ_RSRC_IMG_2D_ARRAY
image_msaa_load v[0:3], v[0:2], s[0:7] dmask:0xf dim:SQ_RSRC_IMG_2D_MSAA unorm
flat_load_dword v0, v[0:1]
global_load_dword v0, v[0:1], off
scratch_load_dword v0, v1, off
exp mrt0 v0, v0, v0, v0 done
+29 -2
View File
@@ -70,8 +70,8 @@ fn hand_assembled_words_identify() {
assert_eq!(name_of(&[0x7e00_0301]), ("V_MOV_B32", 4));
// VOP2 v_add_f32 v0, v1, v2: opcode 3 at bits 30:25, VSRC1 = 2 at bits 16:9.
assert_eq!(name_of(&[0x0600_0501]), ("V_ADD_F32", 4));
// VOP3 v_add_f32_e64 v0, v1, v2: VOP3 opcode 259 = 256 + VOP2 opcode 3.
assert_eq!(name_of(&[0xd503_0000, 0x0002_0501]), ("V_ADD_F32", 8));
// VOP3 v_add_f32_e64 v0, v1, v2 (LLVM 23 encoding): opcode 259 = 256 + VOP2 opcode 3.
assert_eq!(name_of(&[0xd503_0000, 0x0202_0501]), ("V_ADD_F32", 8));
}
#[test]
@@ -154,6 +154,33 @@ fn every_form_identifies_as_itself() {
assert_eq!(total, FORMS.len());
}
#[test]
fn documented_form_counts_match_the_generated_table() {
let count = FORMS.len();
let count = format!("{},{:03}", count / 1000, count % 1000);
let families = EncodingFamily::ALL.len();
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
for (file, claim) in [
(
"docs/research/rdna2.md",
format!("{count} forms in {families} encoding families"),
),
(
"CHANGELOG.md",
format!("{count} base forms across {families} encoding families"),
),
] {
let text = fs::read_to_string(root.join(file)).unwrap();
assert!(
text.split_whitespace()
.collect::<Vec<_>>()
.join(" ")
.contains(&claim),
"{file} must state \"{claim}\""
);
}
}
#[test]
fn first_word_opcode_table_agrees_with_full_metadata() {
use xenora_isa::{BUFFER_LOAD_DWORD, S_ENDPGM, V_ADD_F32, V_ADD_NC_U32, V_MOV_B32};
+87
View File
@@ -0,0 +1,87 @@
//! LLVM oracle for instruction identification: names and lengths from llvm-mc encodings.
use std::process::Command;
use xenora_isa::meta::identify;
const SOURCE: &str = include_str!("llvm/identify.s");
fn encodings() -> Vec<(String, Vec<u8>)> {
let executable = std::env::var_os("LLVM_BIN").map_or_else(
|| "llvm-mc".into(),
|directory| std::path::PathBuf::from(directory).join("llvm-mc"),
);
let path = std::env::temp_dir().join(format!("xenora-identify-{}.s", std::process::id()));
std::fs::write(&path, SOURCE).unwrap();
let output = Command::new(executable)
.args([
"-triple=amdgcn-amd-amdhsa",
"-mcpu=gfx1030",
"-mattr=+wavefrontsize32",
"-show-encoding",
])
.arg(&path)
.output()
.expect("launch llvm-mc (provide its directory in LLVM_BIN or put it on PATH)");
std::fs::remove_file(&path).ok();
assert!(
output.status.success(),
"{}",
String::from_utf8_lossy(&output.stderr)
);
String::from_utf8(output.stdout)
.unwrap()
.lines()
.filter_map(|line| {
let (text, encoding) = line.split_once("; encoding: [")?;
let mnemonic = text.split_whitespace().next()?.to_ascii_uppercase();
let bytes = encoding
.trim_end_matches(']')
.split(',')
.map(|byte| u8::from_str_radix(byte.trim().trim_start_matches("0x"), 16).unwrap())
.collect();
Some((mnemonic, bytes))
})
.collect()
}
fn base_name(mnemonic: &str) -> &str {
["_E32", "_E64", "_SDWA", "_DPP"]
.iter()
.fold(mnemonic, |name, suffix| name.trim_end_matches(suffix))
}
#[test]
#[ignore = "requires LLVM with the gfx1030 AMDGPU target"]
fn identification_matches_llvm_names_and_lengths() {
let encodings = encodings();
let expected_lines = SOURCE
.lines()
.filter(|line| !line.is_empty() && !line.starts_with("//"))
.count();
assert_eq!(encodings.len(), expected_lines);
// The VOP3 and VOP3P literal probes must really carry a literal trailer:
// 1.0 in either width would be an inline constant and only eight bytes.
for (probe, literal) in [("V_FMA_F32", 0x3f80_0001_u32), ("V_PK_FMA_F16", 0x3c01)] {
let (_, bytes) = encodings
.iter()
.find(|(mnemonic, _)| mnemonic == probe)
.unwrap_or_else(|| panic!("{probe} probe missing"));
assert_eq!(bytes.len(), 12, "{probe}");
assert_eq!(bytes[8..], literal.to_le_bytes(), "{probe}");
}
let mut stream = Vec::new();
for (mnemonic, bytes) in &encodings {
let found = identify(bytes).unwrap_or_else(|error| panic!("{mnemonic}: {error}"));
assert_eq!(found.form.name, base_name(mnemonic), "{mnemonic}");
assert_eq!(found.len, bytes.len(), "{mnemonic}");
stream.extend_from_slice(bytes);
}
let mut offset = 0;
for (mnemonic, bytes) in &encodings {
let found = identify(&stream[offset..]).unwrap();
assert_eq!(found.len, bytes.len(), "{mnemonic} in stream");
offset += found.len;
}
assert_eq!(offset, stream.len());
}
+64 -7
View File
@@ -16,7 +16,9 @@ use objc2_metal::{
MTLResourceOptions, MTLShaderValidation, MTLSize, MTLStorageMode, MTLTexture,
MTLTextureDescriptor, MTLTextureUsage,
};
use xenora_texture::{Bc1Upload, BcAlphaFormat, BcAlphaUpload, TiledBc1};
use xenora_texture::{
Bc1Upload, BcAlphaFormat, BcAlphaUpload, BcChannelFormat, BcChannelUpload, TiledBc1,
};
#[path = "render.rs"]
mod render;
@@ -38,6 +40,20 @@ kernel void read_bc(texture2d<float, access::read> image [[texture(0)]],
}
";
// Signed formats return -1.0..=1.0; each byte holds the channel times 127.
const BC_SNORM_READBACK: &str = r"
#include <metal_stdlib>
using namespace metal;
kernel void read_bc_snorm(texture2d<float, access::read> image [[texture(0)]],
device uint *output [[buffer(1)]],
uint index [[thread_position_in_grid]]) {
uint width = image.get_width();
float4 texel = clamp(image.read(uint2(index % width, index / width)), -1.0f, 1.0f);
uint4 bytes = uint4(int4(round(texel * 127.0f))) & 0xffu;
output[index] = bytes.r | (bytes.g << 8u) | (bytes.b << 16u) | (bytes.a << 24u);
}
";
enum ComputeInput<'a> {
Words(&'a [u32]),
Texture(&'a ProtocolObject<dyn MTLTexture>, usize),
@@ -331,6 +347,45 @@ kernel void sample_rgba8(texture2d<float, access::sample> tex [[texture(0)]],
)
}
/// Read a selected subresource from a validated pitched BC4 or BC5 upload.
///
/// The original blocks go to a native `BC4_R*` or `BC5_RG*` texture.
/// Unsigned output has the layout of [`Self::read_bc1_upload`]. Signed
/// output stores each channel, times 127 and rounded, as a two's-complement
/// byte in the same order. Metal fills missing green and blue with 0 and
/// alpha with 1.
///
/// # Errors
///
/// Returns an error for an invalid layer or mip, out-of-policy size,
/// unavailable BC compression (operation `supportsBCTextureCompression`),
/// or Metal setup or execution failure.
pub fn read_bc_channel_upload(
&self,
upload: &BcChannelUpload<'_>,
layer: usize,
mip: u32,
) -> Result<Vec<u32>, MetalError> {
let level = upload
.subresource(layer, mip)
.map_err(|error| MetalError::new("texture subresource", format!("{error:?}")))?;
let (format, name) = match upload.format() {
BcChannelFormat::Bc4Unorm => (MTLPixelFormat::BC4_RUnorm, "BC4 UNORM"),
BcChannelFormat::Bc4Snorm => (MTLPixelFormat::BC4_RSnorm, "BC4 SNORM"),
BcChannelFormat::Bc5Unorm => (MTLPixelFormat::BC5_RGUnorm, "BC5 UNORM"),
BcChannelFormat::Bc5Snorm => (MTLPixelFormat::BC5_RGSnorm, "BC5 SNORM"),
};
let pixels = self.validate_bc_extent(level.width, level.height, name)?;
self.read_bc_blocks(
format,
level.bytes,
level.row_pitch,
level.width,
level.height,
pixels,
)
}
fn validate_bc_extent(
&self,
width: usize,
@@ -397,12 +452,14 @@ kernel void sample_rgba8(texture2d<float, access::sample> tex [[texture(0)]],
bytes_per_row,
);
}
self.run(
BC_READBACK,
"read_bc",
ComputeInput::Texture(&texture, pixels),
)
.map(|profile| profile.output)
let (source, entry) =
if format == MTLPixelFormat::BC4_RSnorm || format == MTLPixelFormat::BC5_RGSnorm {
(BC_SNORM_READBACK, "read_bc_snorm")
} else {
(BC_READBACK, "read_bc")
};
self.run(source, entry, ComputeInput::Texture(&texture, pixels))
.map(|profile| profile.output)
})
}
@@ -0,0 +1,535 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//! Native Metal upload and readback of original BC4 and BC5 blocks.
//!
//! Every block below was written for this test. The full-texel reference is
//! the `xenora-texture` CPU decoder; the anchor texels are worked by hand from
//! the Microsoft Direct3D 11 block-compression documentation (BC4, BC5) and
//! the Khronos Data Format Specification 1.3 (RGTC). Apple's GPU decoder is
//! the value under test, so expected and actual values come from different
//! decoders.
use super::{context, native};
use xenora_texture::{
BcChannelFormat, BcChannelUpload, BcChannelUploadDesc, decode_bc4_snorm, decode_bc4_unorm,
decode_bc5_snorm, decode_bc5_unorm,
};
/// The specifications define interpolation in real numbers and the CPU
/// reference truncates toward zero. On an Apple M5 Pro every format's
/// interpolated codes sit up to two codes from that reference; each test
/// prints its measured worst case. Endpoints and the six-value fixed codes
/// are exact and are pinned by the anchor checks.
const TOLERANCE: u8 = 2;
/// Bound for anchors against the real-number value of an interpolated code.
/// The measured worst on an Apple M5 Pro is 1.71 codes: signed eight-value
/// index 4 of 100 and -100 is (4 * 100 - 3 * 100) / 7 = 14.29 and reads 16.
const REAL_TOLERANCE: f64 = 2.0;
const WIDTH: usize = 5;
const HEIGHT: usize = 5;
/// One 8-byte channel block whose texel `t` selects palette entry
/// `(t + 6) % 8`: every row starts with indices 6 and 7, and a full block
/// uses all eight.
fn channel(first: u8, second: u8) -> [u8; 8] {
let bits = (0..16u64).fold(0, |bits, texel| bits | (((texel + 6) % 8) << (3 * texel)));
let i = bits.to_le_bytes();
[first, second, i[0], i[1], i[2], i[3], i[4], i[5]]
}
fn signed(first: i8, second: i8) -> [u8; 8] {
channel(first.to_le_bytes()[0], second.to_le_bytes()[0])
}
/// Index 0 everywhere at endpoint 0x7f: 127 unsigned or 1.0 signed, so a
/// wrong row or slice pitch reads visibly wrong texels.
const PAD: [u8; 8] = [0x7f, 0x7f, 0, 0, 0, 0, 0, 0];
/// Logical blocks of one layer: the 2×2 base-level grid, then mip 1.
type Layer = [Vec<u8>; 5];
struct Case {
format: BcChannelFormat,
/// Expected little-endian texel words of one block.
reference: fn(&[u8]) -> [u32; 16],
layers: [Layer; 2],
}
fn unorm_word(r: u8, g: u8) -> u32 {
u32::from_le_bytes([r, g, 0, 255])
}
/// Both -128 and -127 decode to -1.0, so the native output is -127 for each.
fn snorm_word(r: i8, g: i8) -> u32 {
let byte = |value: i8| value.max(-127).to_le_bytes()[0];
u32::from_le_bytes([byte(r), byte(g), 0, 127])
}
fn bc4_unorm(block: &[u8]) -> [u32; 16] {
decode_bc4_unorm(block.try_into().unwrap()).map(|r| unorm_word(r, 0))
}
fn bc4_snorm(block: &[u8]) -> [u32; 16] {
decode_bc4_snorm(block.try_into().unwrap()).map(|r| snorm_word(r, 0))
}
fn bc5_unorm(block: &[u8]) -> [u32; 16] {
decode_bc5_unorm(block.try_into().unwrap()).map(|[r, g]| unorm_word(r, g))
}
fn bc5_snorm(block: &[u8]) -> [u32; 16] {
decode_bc5_snorm(block.try_into().unwrap()).map(|[r, g]| snorm_word(r, g))
}
fn dual(red: [u8; 8], green: [u8; 8]) -> Vec<u8> {
[red, green].concat()
}
/// Seven physical blocks per subresource: rows of two logical blocks plus
/// one padding block, a padding block closing the slice, and mip 1 using
/// only its block zero. Returns the bytes with the row and slice pitch.
fn upload_bytes(format: BcChannelFormat, layers: &[Layer; 2]) -> (Vec<u8>, usize, usize) {
let block = format.block_bytes();
let pad = PAD.repeat(block / PAD.len());
let mut bytes = Vec::new();
for [b0, b1, b2, b3, small] in layers {
for slot in [b0, b1, &pad, b2, b3, &pad, &pad] {
bytes.extend_from_slice(slot);
}
bytes.extend_from_slice(small);
for _ in 0..6 {
bytes.extend_from_slice(&pad);
}
}
(bytes, 3 * block, 7 * block)
}
/// Crops decoded blocks (a row-major block grid) to a `width`×`height` level.
fn crop<T: Copy>(blocks: &[[T; 16]], blocks_x: usize, width: usize, height: usize) -> Vec<T> {
let mut texels = Vec::new();
for y in 0..height {
for x in 0..width {
texels.push(blocks[(y / 4) * blocks_x + x / 4][(y % 4) * 4 + x % 4]);
}
}
texels
}
/// Per-channel distances; signed formats compare bytes as two's complement.
fn distances(format: BcChannelFormat, got: u32, want: u32) -> [u8; 4] {
let signed = matches!(
format,
BcChannelFormat::Bc4Snorm | BcChannelFormat::Bc5Snorm
);
let (got, want) = (got.to_le_bytes(), want.to_le_bytes());
std::array::from_fn(|c| {
if signed {
(got[c] as i8).abs_diff(want[c] as i8)
} else {
got[c].abs_diff(want[c])
}
})
}
/// Per-channel tolerance of each texel: zero where a channel block's index
/// selects a stored endpoint or a six-value fixed code (and for the constant
/// channels), [`TOLERANCE`] only for interpolated codes.
fn tolerances(format: BcChannelFormat, block: &[u8]) -> [[u8; 4]; 16] {
let signed = matches!(
format,
BcChannelFormat::Bc4Snorm | BcChannelFormat::Bc5Snorm
);
let limit = |channel: &[u8], t: usize| {
let mut bits = [0; 8];
bits[..6].copy_from_slice(&channel[2..8]);
let index = (u64::from_le_bytes(bits) >> (3 * t)) & 7;
let six_value = if signed {
channel[0] as i8 <= channel[1] as i8
} else {
channel[0] <= channel[1]
};
if index < 2 || (six_value && index >= 6) {
0
} else {
TOLERANCE
}
};
std::array::from_fn(|t| {
let green = if block.len() == 16 {
limit(&block[8..], t)
} else {
0
};
[limit(&block[..8], t), green, 0, 0]
})
}
/// Asserts every channel is within its tolerance and returns the worst.
fn check_texels(
label: &str,
format: BcChannelFormat,
actual: &[u32],
expected: &[(u32, [u8; 4])],
) -> u8 {
assert_eq!(actual.len(), expected.len(), "{label}: texel count");
let mut worst = 0;
for (texel, (&got, &(want, limit))) in actual.iter().zip(expected).enumerate() {
let diff = distances(format, got, want);
assert!(
diff.iter().zip(limit).all(|(&d, l)| d <= l),
"{label}: texel {texel} got {got:#010x}, want {want:#010x} (per-channel limit {limit:?})"
);
worst = worst.max(*diff.iter().max().unwrap());
}
worst
}
/// CPU reference words of `block` with their per-channel tolerances.
fn expected_block(
case_format: BcChannelFormat,
reference: fn(&[u8]) -> [u32; 16],
block: &[u8],
) -> [(u32, [u8; 4]); 16] {
let words = reference(block);
let limits = tolerances(case_format, block);
std::array::from_fn(|t| (words[t], limits[t]))
}
/// GPU reads of both layers: `[layer][mip]`.
type Reads = [[Vec<u32>; 2]; 2];
/// Uploads both layers, reads all four subresources on the GPU, compares
/// them with the CPU decoder and returns the reads with the worst difference.
fn read_and_compare(case: &Case) -> (Reads, u8) {
let (bytes, row_pitch, slice_pitch) = upload_bytes(case.format, &case.layers);
let upload = BcChannelUpload::new(
&bytes,
BcChannelUploadDesc {
width: WIDTH,
height: HEIGHT,
mips: 2,
layers: 2,
format: case.format,
row_pitch,
slice_pitch,
},
)
.unwrap();
let gpu = context();
let mut worst = 0;
let reads = std::array::from_fn(|layer| {
let decoded: Vec<_> = case.layers[layer]
.iter()
.map(|block| expected_block(case.format, case.reference, block))
.collect();
let levels = [
crop(&decoded[..4], 2, WIDTH, HEIGHT),
crop(&decoded[4..], 1, 2, 2),
];
std::array::from_fn(|mip| {
let actual = native(gpu.read_bc_channel_upload(&upload, layer, mip as u32));
let expected = &levels[mip];
let label = format!("{:?} layer {layer} mip {mip}", case.format);
worst = worst.max(check_texels(&label, case.format, &actual, expected));
actual
})
});
for (layer, mip) in [(2, 0), (0, 2)] {
assert_eq!(
gpu.read_bc_channel_upload(&upload, layer, mip)
.unwrap_err()
.operation,
"texture subresource"
);
}
(reads, worst)
}
fn assert_near(label: &str, actual: f64, real: f64) {
assert!(
(actual - real).abs() <= REAL_TOLERANCE,
"{label}: got {actual}, real value {real:.2}"
);
}
fn byte(word: u32, channel: usize) -> u8 {
word.to_le_bytes()[channel]
}
fn sbyte(word: u32, channel: usize) -> i8 {
byte(word, channel) as i8
}
/// Unsigned blocks: eight-value (200 > 20), six-value (20 < 200), extremes
/// in both orders, and equal endpoints, which select the six-value mode.
fn unsigned_blocks() -> [[u8; 8]; 5] {
[
channel(200, 20),
channel(20, 200),
channel(128, 128),
channel(255, 0),
channel(0, 255),
]
}
/// Signed blocks: eight-value (100 > -100), six-value (-100 < 100), equal
/// zeros, and the extremes 127 and -128 in both orders.
fn signed_blocks() -> [[u8; 8]; 5] {
[
signed(100, -100),
signed(-100, 100),
signed(0, 0),
signed(127, -128),
signed(-128, 127),
]
}
/// Checks the hand-derived values of the base level of layer 0, whose
/// blocks are the five channel blocks in order.
fn unsigned_anchors(base: &[u32], channel: usize) {
let v = |x: usize, y: usize| byte(base[y * WIDTH + x], channel);
// Block 0, eight-value 200, 20: row 0 indices 6, 7, 0, 1, row 1 2..=5.
assert_eq!([v(2, 0), v(3, 0)], [200, 20]);
for (x, k) in (0..2).chain(0..4).zip([5, 6, 1, 2, 3, 4]) {
let y = usize::from(k < 5);
let real = f64::from((7 - k) * 200 + k * 20) / 7.0;
assert_near(
&format!("eight-value index {}", k + 1),
v(x, y).into(),
real,
);
}
// Block 1, six-value 20, 200: column 4 holds indices 6, 2, 6, 2; index 6
// is the fixed 0 and index 2 is (4 * 20 + 200) / 5 = 56.
assert_eq!([v(4, 0), v(4, 2)], [0, 0]);
assert_near("six-value index 2", v(4, 1).into(), 56.0);
// Block 2, equal 128: row 4 indices 6, 7, 0, 1 -> fixed 0 and 255.
assert_eq!([v(0, 4), v(1, 4), v(2, 4), v(3, 4)], [0, 255, 128, 128]);
// Block 3, 255 > 0: texel (4, 4) is its texel 0, index 6:
// (2 * 255) / 7 = 72.9.
assert_near("extreme index 6", v(4, 4).into(), 510.0 / 7.0);
}
fn signed_anchors(base: &[u32], channel: usize) {
let v = |x: usize, y: usize| sbyte(base[y * WIDTH + x], channel);
// Block 0, eight-value 100, -100: row 0 indices 6, 7, 0, 1.
assert_eq!([v(2, 0), v(3, 0)], [100, -100]);
for (x, k) in (0..2).chain(0..4).zip([5, 6, 1, 2, 3, 4]) {
let y = usize::from(k < 5);
let real = f64::from((7 - k) * 100 - k * 100) / 7.0;
assert_near(
&format!("eight-value index {}", k + 1),
v(x, y).into(),
real,
);
}
// Block 1, six-value -100, 100: column 4 holds indices 6, 2, 6, 2; index
// 6 is the fixed -1.0 and index 2 is (4 * -100 + 100) / 5 = -60.
assert_eq!([v(4, 0), v(4, 2)], [-127, -127]);
assert_near("six-value index 2", v(4, 1).into(), -60.0);
// Block 2, equal zeros: row 4 indices 6, 7, 0, 1 -> fixed -1.0, 1.0, 0, 0.
assert_eq!([v(0, 4), v(1, 4), v(2, 4), v(3, 4)], [-127, 127, 0, 0]);
// Block 3, 127 > -128: index 6 is (2 * 127 + 5 * -127) / 7 = -54.4, with
// -128 read as -1.0.
assert_near("extreme index 6", v(4, 4).into(), -381.0 / 7.0);
}
fn layers(
blocks: [[u8; 8]; 5],
other: [[u8; 8]; 5],
pair: fn([u8; 8], [u8; 8]) -> Vec<u8>,
) -> [Layer; 2] {
[
blocks.map(|b| pair(b, other[0])),
// Layer 1 rotates the blocks so each layer and mip differs.
std::array::from_fn(|i| pair(blocks[(i + 2) % 5], other[(i + 1) % 5])),
]
}
fn single(block: [u8; 8], _: [u8; 8]) -> Vec<u8> {
block.to_vec()
}
/// BC5 with the first block in red and a different block in green.
fn red_green(red: [u8; 8], green: [u8; 8]) -> Vec<u8> {
dual(red, green)
}
#[test]
fn reads_pitched_bc4_unorm_across_mips_and_layers() {
let blocks = unsigned_blocks();
let case = Case {
format: BcChannelFormat::Bc4Unorm,
reference: bc4_unorm,
layers: layers(blocks, blocks, single),
};
let (reads, worst) = read_and_compare(&case);
let base = &reads[0][0];
unsigned_anchors(base, 0);
// A single channel reads as (red, 0, 0, 1).
assert!(base.iter().all(|&word| word & 0xffff_ff00 == 0xff00_0000));
println!("checked 58 BC4 UNORM texels, worst channel difference {worst}");
}
#[test]
fn reads_pitched_bc4_snorm_across_mips_and_layers() {
let blocks = signed_blocks();
let case = Case {
format: BcChannelFormat::Bc4Snorm,
reference: bc4_snorm,
layers: layers(blocks, blocks, single),
};
let (reads, worst) = read_and_compare(&case);
let base = &reads[0][0];
signed_anchors(base, 0);
assert!(base.iter().all(|&word| word & 0xffff_ff00 == 0x7f00_0000));
// Layer 1 mip 1 is block 1 (-100 < 100, six-value): indices 6, 7, 2, 3.
let small: Vec<_> = reads[1][1].iter().map(|&word| sbyte(word, 0)).collect();
assert_eq!(small[..2], [-127, 127]);
println!("checked 58 BC4 SNORM texels, worst channel difference {worst}");
}
#[test]
fn reads_pitched_bc5_unorm_in_red_green_order() {
let blocks = unsigned_blocks();
let case = Case {
format: BcChannelFormat::Bc5Unorm,
reference: bc5_unorm,
layers: [
blocks.map(|b| red_green(b, blocks[1])),
layers(blocks, blocks, red_green)[1].clone(),
],
};
let (reads, worst) = read_and_compare(&case);
let base = &reads[0][0];
unsigned_anchors(base, 0);
// Green holds the six-value block 1 throughout layer 0: (0, 0) is its
// index 6, the fixed 0, and (1, 0) its index 7, the fixed 255.
assert_eq!([byte(base[0], 1), byte(base[1], 1)], [0, 255]);
assert!(base.iter().all(|&word| word & 0xffff_0000 == 0xff00_0000));
println!("checked 58 BC5 UNORM texels, worst channel difference {worst}");
}
#[test]
fn reads_pitched_bc5_snorm_in_red_green_order() {
let blocks = signed_blocks();
let case = Case {
format: BcChannelFormat::Bc5Snorm,
reference: bc5_snorm,
layers: [
blocks.map(|b| red_green(b, blocks[1])),
layers(blocks, blocks, red_green)[1].clone(),
],
};
let (reads, worst) = read_and_compare(&case);
let base = &reads[0][0];
signed_anchors(base, 0);
// Green holds the six-value block 1 throughout layer 0: (0, 0) and
// (1, 0) are its fixed -1.0 and 1.0.
assert_eq!([sbyte(base[0], 1), sbyte(base[1], 1)], [-127, 127]);
assert!(base.iter().all(|&word| word & 0xffff_0000 == 0x7f00_0000));
println!("checked 58 BC5 SNORM texels, worst channel difference {worst}");
}
/// Reads a one-mip, one-layer upload of `width`×`height` from `blocks` with
/// one padding block per row, comparing with the CPU decoder.
fn read_edge(
format: BcChannelFormat,
reference: fn(&[u8]) -> [u32; 16],
blocks: &[Vec<u8>],
(width, height): (usize, usize),
) -> Vec<u32> {
let block = format.block_bytes();
let pad = PAD.repeat(block / PAD.len());
let blocks_x = width.div_ceil(4);
let mut bytes = Vec::new();
for row in blocks.chunks(blocks_x) {
for slot in row {
bytes.extend_from_slice(slot);
}
bytes.extend_from_slice(&pad);
}
let upload = BcChannelUpload::new(
&bytes,
BcChannelUploadDesc {
width,
height,
mips: 1,
layers: 1,
format,
row_pitch: (blocks_x + 1) * block,
slice_pitch: bytes.len(),
},
)
.unwrap();
let actual = native(context().read_bc_channel_upload(&upload, 0, 0));
let decoded: Vec<_> = blocks
.iter()
.map(|block| expected_block(format, reference, block))
.collect();
let expected = crop(&decoded, blocks_x, width, height);
check_texels(
&format!("{format:?} {width}x{height}"),
format,
&actual,
&expected,
);
actual
}
#[test]
fn reads_bc4_and_bc5_edge_blocks() {
let [eight, six, ..] = unsigned_blocks();
let [s_eight, s_six, _, _, s_low] = signed_blocks();
// 5×3 is one row of two blocks (Metal's zero row stride), both cut at
// row 3 and the second at column 1; 1×1 is one block cut to texel 0.
// Row 0 of every block holds indices 6, 7, 0, 1; column 0 holds 6, 2, 6.
let wide = read_edge(
BcChannelFormat::Bc4Unorm,
bc4_unorm,
&[eight.to_vec(), six.to_vec()],
(5, 3),
);
let red: Vec<_> = wide.iter().map(|&w| byte(w, 0)).collect();
assert_eq!([red[2], red[3], red[4], red[14]], [200, 20, 0, 0]);
assert_near("six-value index 2", red[9].into(), 56.0);
let wide = read_edge(
BcChannelFormat::Bc5Snorm,
bc5_snorm,
&[dual(s_eight, s_six), dual(s_six, s_eight)],
(5, 3),
);
// Block 0: red eight-value endpoints 100, -100; green six-value 0 and 1
// indices -100, 100. Block 1: red six-value fixed -1.0 at index 6, green
// eight-value index 6 (2 * 100 + 5 * -100) / 7 = -42.9.
let texel = |i: usize| [sbyte(wide[i], 0), sbyte(wide[i], 1)];
assert_eq!([texel(2), texel(3)], [[100, -100], [-100, 100]]);
assert_eq!(texel(4)[0], -127);
assert_near(
"green eight-value index 6",
texel(4)[1].into(),
-300.0 / 7.0,
);
// Index 6 of -128 < 127 is the six-value fixed -1.0.
let one = read_edge(
BcChannelFormat::Bc4Snorm,
bc4_snorm,
&[s_low.to_vec()],
(1, 1),
);
assert_eq!(one, [0x7f00_0081]);
let one = read_edge(
BcChannelFormat::Bc5Unorm,
bc5_unorm,
&[dual(six, eight)],
(1, 1),
);
assert_eq!(byte(one[0], 0), 0);
assert_near(
"green eight-value index 6",
byte(one[0], 1).into(),
500.0 / 7.0,
);
println!("checked 32 BC4 and BC5 texels from 5x3 and 1x1 edge levels");
}
+2
View File
@@ -8,6 +8,8 @@ mod offscreen;
mod texture;
#[path = "native/texture_bc_alpha.rs"]
mod texture_bc_alpha;
#[path = "native/texture_bc_channel.rs"]
mod texture_bc_channel;
#[path = "native/texture_sampling.rs"]
mod texture_sampling;
#[path = "native/translated_render.rs"]
+1
View File
@@ -20,6 +20,7 @@ pub use bc6h::{
pub use sampler::{AddressMode, FilterMode, SamplerDesc, SamplerError, TextureMetadata};
pub use upload::{
Bc1Subresource, Bc1Upload, Bc1UploadDesc, BcAlphaFormat, BcAlphaUpload, BcAlphaUploadDesc,
BcChannelFormat, BcChannelUpload, BcChannelUploadDesc,
};
const BLOCK_BYTES: usize = 8;
+127
View File
@@ -114,6 +114,72 @@ impl<'a> BcAlphaUpload<'a> {
}
}
/// A single- or dual-channel block-compressed format: BC4 stores one 8-byte
/// red block, BC5 a red block followed by a green block.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum BcChannelFormat {
Bc4Unorm,
Bc4Snorm,
Bc5Unorm,
Bc5Snorm,
}
impl BcChannelFormat {
/// Size of one block in bytes.
pub const fn block_bytes(self) -> usize {
match self {
Self::Bc4Unorm | Self::Bc4Snorm => 8,
Self::Bc5Unorm | Self::Bc5Snorm => 16,
}
}
}
/// A layer-major BC4 or BC5 upload with the same pitch rules as
/// [`Bc1UploadDesc`], measured in the format's block size.
#[derive(Clone, Copy, Debug)]
pub struct BcChannelUploadDesc {
pub width: usize,
pub height: usize,
pub mips: u32,
pub layers: usize,
pub format: BcChannelFormat,
pub row_pitch: usize,
pub slice_pitch: usize,
}
#[derive(Debug)]
pub struct BcChannelUpload<'a> {
bytes: &'a [u8],
desc: BcChannelUploadDesc,
}
impl<'a> BcChannelUpload<'a> {
pub fn new(bytes: &'a [u8], desc: BcChannelUploadDesc) -> Result<Self, TextureError> {
Self::layout(desc).validate(bytes.len(), desc.format.block_bytes())?;
Ok(Self { bytes, desc })
}
pub fn format(&self) -> BcChannelFormat {
self.desc.format
}
/// Selects one level; the returned rows hold blocks of this format.
pub fn subresource(&self, layer: usize, mip: u32) -> Result<Bc1Subresource<'a>, TextureError> {
Self::layout(self.desc).subresource(self.bytes, layer, mip)
}
fn layout(desc: BcChannelUploadDesc) -> PitchedLayout {
PitchedLayout {
width: desc.width,
height: desc.height,
mips: desc.mips,
layers: desc.layers,
row_pitch: desc.row_pitch,
slice_pitch: desc.slice_pitch,
}
}
}
/// Format-independent pitch rules shared by the pitched uploads.
struct PitchedLayout {
width: usize,
@@ -383,4 +449,65 @@ mod tests {
TextureError::SizeOverflow
);
}
#[test]
fn sizes_bc4_and_bc5_pitches_by_their_block() {
let desc = BcChannelUploadDesc {
width: 5,
height: 5,
mips: 2,
layers: 2,
format: BcChannelFormat::Bc4Unorm,
row_pitch: 24,
slice_pitch: 56,
};
let mut bytes = [0; 224];
bytes[144] = 0x3c; // Layer 1, mip 0, row 1, block 1.
let upload = BcChannelUpload::new(&bytes, desc).unwrap();
assert_eq!(upload.format(), BcChannelFormat::Bc4Unorm);
let base = upload.subresource(1, 0).unwrap();
assert_eq!((base.bytes.len(), base.bytes[32]), (48, 0x3c));
// A BC4 pitch holds only half a BC5 row, and 24 is not a 16-byte multiple.
for format in [BcChannelFormat::Bc5Unorm, BcChannelFormat::Bc5Snorm] {
assert_eq!(
BcChannelUpload::new(&bytes, BcChannelUploadDesc { format, ..desc }).unwrap_err(),
TextureError::InvalidLayout
);
}
let bc5 = BcChannelUploadDesc {
format: BcChannelFormat::Bc5Snorm,
row_pitch: 48,
slice_pitch: 112,
..desc
};
let bytes = [0; 448];
assert_eq!(
BcChannelUpload::new(&bytes, bc5)
.unwrap()
.subresource(1, 1)
.unwrap()
.bytes
.len(),
48
);
// Short, oversized, and one block too few or too many for the layout.
for len in [447, 449, 432, 464] {
assert_eq!(
BcChannelUpload::new(&vec![0; len], bc5).unwrap_err(),
TextureError::InvalidByteLength
);
}
for desc in [
BcChannelUploadDesc { width: 0, ..bc5 },
BcChannelUploadDesc { height: 0, ..bc5 },
BcChannelUploadDesc { layers: 0, ..bc5 },
BcChannelUploadDesc { mips: 0, ..bc5 },
BcChannelUploadDesc { mips: 4, ..bc5 },
] {
assert_eq!(
BcChannelUpload::new(&bytes, desc).unwrap_err(),
TextureError::InvalidLayout
);
}
}
}
+6 -2
View File
@@ -1,7 +1,11 @@
# Agent task queue
Work items are GitHub issues. Contributors and coding agents claim them with a comment, work in
their own branch, and open a pull request that is checked against the claim. The queue is
their own branch, and open a pull request that is checked against the claim. The claim rules for
everyone are in `AGENTS.md` ("Claiming work before you start"): a plain reply is a valid claim, and
a claim goes stale after about one week without a pull request. The commands below are an optional
layer for contributors listed in `.github/agent-queue.json`; the bot only sees `/claim` comments, so
read the issue's comments before using it and never `/claim` over a plain-reply claim. The queue is
deterministic: the rules live in `scripts/agent_queue/` (standard-library Python, no network, no
model or external service), and GitHub Actions and the shell helpers only call it.
@@ -58,7 +62,7 @@ done
4. `scripts/agent-queue.sh start <n>` creates branch `task/<n>-<slug>` from `upstream/main` in a
separate worktree `../xenora-task-<n>` (`--here` uses the current clean checkout instead).
5. Keep the lease alive with `scripts/agent-queue.sh progress <n> "what changed"`. A claim lapses
`lease_hours` (24) after the latest of: the grant, your `/progress` comment, a push to your
`lease_hours` (168, one week) after the latest of: the grant, your `/progress` comment, a push to your
linked pull request. Other people's comments never renew it. A lapsed task returns to the queue.
6. Open the pull request with `Closes #<n>` and a DCO sign-off (`git commit -s`).
7. A different person (not the author, not the task holder) who is a maintainer or has `qa`
+14 -3
View File
@@ -42,7 +42,7 @@ python3 crates/isa/generate_rdna2.py path/to/amdgpu_isa_rdna2.xml | diff -u crat
## Complete instruction metadata
`crates/isa/generate_rdna2_meta.py` reduces the same approved XML to every
gfx1030 base instruction form: 1,460 forms in 21 encoding families, with
gfx1030 base instruction form: 1,465 forms in 21 encoding families, with
identifying bits, field layouts, operands (field, data format, operand type,
width, direction), control-flow flags and allowed extension words. It runs in
two stages so regeneration and CI checks need no network and no XML:
@@ -66,8 +66,19 @@ VOP1, VOP2 and VOPC `SRC0` values 0xF9, 0xFA, 0xE9 and 0xEA add an SDWA, DPP16
or DPP8 control dword (from the RDNA 2 ISA guide's SDWA and DPP sections, not
the XML); MIMG `NSA` adds that many address dwords. An extension the form does
not list is rejected. Every LLVM-assembled fixture identifies with exact
boundaries and matching mnemonics. A broader LLVM comparison of the extension
rules is still open because it needs the LLVM oracle.
boundaries and matching mnemonics. `crates/isa/tests/llvm/identify.s` holds one
instruction per family and extension word (literal, SDWA, DPP16, DPP8 with and
without fetch-inactive, VOP3 and VOP3P literals, NSA images, MTBUF opcodes
above 7, MSAA loads); its LLVM oracle compares every name and length:
```sh
LLVM_BIN=path/to/llvm/bin cargo test --locked -p xenora-isa --test meta_llvm -- --include-ignored
```
The oracle found five instructions that the XML lists only under a literal
encoding (`S_SETREG_IMM32_B32`, `V_FMAMK_F32`, `V_FMAAK_F32`, `V_FMAMK_F16`,
`V_FMAAK_F16`); the generator now treats them as base forms that always carry a
literal.
Identification is not execution. `xenora shaders coverage` reports forms
discovered in metadata against forms the semantic decoder accepts