mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-26 11:00:43 +00:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5aca73c55 | ||
|
|
5131de9cd6 | ||
|
|
82cb66e80f | ||
|
|
14d5083f0f | ||
|
|
0115af5c04 | ||
|
|
6de750b152 | ||
|
|
dc3b02b62f | ||
|
|
d847d7ea6e | ||
|
|
b55a4c24ef | ||
|
|
291c9807ee |
No files matched your search
@@ -35,6 +35,7 @@
|
||||
|
||||
__pycache__/
|
||||
*.pyc
|
||||
/diagnostics/probe/
|
||||
/diagnostics/gta6-candidate-*/
|
||||
/diagnostics/gta6-check/
|
||||
|
||||
|
||||
+3
-1
@@ -10,15 +10,17 @@ Guest execution uses original, purpose-built test programs. Commercial Xbox game
|
||||
remains unsupported.
|
||||
|
||||
### Changed
|
||||
- Resolve the tiled BC1 mip and array layer once per linearization and copy contiguous block runs within each tile row. Partial edge blocks are retained and padding slots are skipped. Closes #349.
|
||||
- Changed the default report folder of `xenora probe` and `xenora imports sync` to `diagnostics/probe`, which Git ignores (#364). Anyone relying on the earlier default has to pass `--report`.
|
||||
- Relocation reports now build their type histogram once per image, avoiding a tree lookup for every entry. Target checks and fixup order are unchanged; synthetic regressions and an opt-in relocation timing test cover the change (#109).
|
||||
- Moved the six supported gfx1030 SOPP compute control forms into the semantic registry, preserving instruction decoding and shader lowering. Part of #215.
|
||||
- Moved gfx1030 `s_mov_b32` (SOP1) into the semantic registry, preserving its existing decode domain and shader output. The move operand rule retains explicit VCC and EXEC half destinations. Part of #215.
|
||||
- Moved the six hand-written gfx1030 VOP2 logical and shift forms (`v_and_b32`, `v_or_b32`, `v_xor_b32`, `v_lshlrev_b32`, `v_lshrrev_b32`, `v_ashrrev_i32`, AMD guide section 12.7) into the semantic registry under a new VGPR-only operand rule `vop2_vgpr2`, with no behaviour change: a sweep of 132,608 VOP2, VOP1 and SOP1 words decodes to the same text, length and error before and after, the MSL goldens are unchanged, and the runtime-region allowlist admits exactly the same six forms. The per-lane `VectorBinary` gained `And`, `Or`, `Xor` and the three shifts (count masked to S0[4:0]); 6 hand-written instruction variants and their decoder and lowering arms are gone (17 hand-written forms remain). Part of #215.
|
||||
- Added non-blocking Metal compute submission through `submit_words` and `wait`, with completion-aware resource retirement and a sixteen-dispatch in-flight limit. Synchronous calls keep their existing behavior. The benchmark reports the host submission split and compares synchronous and pipelined batches.
|
||||
- Reuse up to 16 native Metal compute pipelines per context for repeated shader source and entry points. Pending dispatches retain their pipelines through completion, including after eviction. Dispatch profiles report zero library and pipeline setup time when a cached pipeline is reused. Closes #132.
|
||||
- Extended the read-only RDNA2 planning CLI (`python3 -m qa rdna2`) with family/status filters, compact summaries, Codex-ready manifests under `artifacts/`, active-claim exclusion (family claims exclude those families; path-only claims block overlapping permitted files), coverage reconcile against `semantic_coverage` without inflating counts, and inventory diffs. Covered by `tests/qa/test_rdna2_plan.py`; planning only, no GPU production edits.
|
||||
|
||||
### Added
|
||||
- Added a documented independent acceptance rule for promoting AMD RDNA2 desktop GPU (gfx1030) forms from local CPU and Metal results to `fixture verified`, including clean-commit evidence, reviewer independence, raw-log location, review-log summary, failure handling and status regeneration (#302).
|
||||
- Added the VOP3A (`_e64`) encodings of eleven gfx1030 VOP2 integer forms (`v_mul_{i32_i24,hi_i32_i24,u32_u24,hi_u32_u24}`, `v_{min,max}_{i32,u32}`, `v_xnor_b32`, `v_sub_nc_u32`, `v_subrev_nc_u32`) and of the sixteen Wave32 integer compares (explicit SGPR mask destination, `s_cbranch_vccz` through `vcc_lo`, a translation error for reads of runtime-only SGPR results) as semantic-registry encoding variants, with VGPR sources only. New fixtures `vop3-integer` and `vop3-compare` with IR and MSL goldens, and an independent guide-derived oracle (`tests/validation/tests/vop3_{integer,compare}.rs`) that agrees on both reference interpreters and on native Metal. Part of #215.
|
||||
- Added guest texture binding through D3D12-style descriptor tables (#303): shader-visible CBV_SRV_UAV and sampler heaps, `CreateShaderResourceView` for one-level RGBA8 and BC1 2D textures, a point/clamp `CreateSampler`, a root signature with one pixel-stage SRV table and one sampler table, and `SetDescriptorHeaps`/`SetGraphicsRootDescriptorTable` in `crates/loader/src/graphics.rs`, plus `NativeCompute::render_rgba8_sampled_bc1`. Verified locally on an Apple M5 Pro under Metal validation: a guest draw with the translated `image_sample_lz` pixel stage matches the software reference and hand-derived images on 16 of 16 pixels for two RGBA8 textures and 64 of 64 for an 8×8 BC1 texture. A wrong descriptor slot changes the image, off-centre and out-of-range coordinates point-sample with clamping, and a rejected binding, draw shape or resource state never reaches the backend. The software reference samples BC1 with the spec-exact decoder, while Apple's hardware rounds BC1's interpolated palette entries differently (171/84 against 170/85), so the BC1 fixtures use only endpoint colours. Not yet reachable from guest imports. Not yet independently accepted.
|
||||
- Added four Wave32 gfx1030 VOP2 select and carry forms through the semantic registry. Conditional select, add with carry and both subtract orders with borrow use a per-lane VCC bit and have a guide-derived oracle that passes on both CPU interpreters and on native Metal (local Apple M5, API and shader validation); independent acceptance is pending. Part of #215.
|
||||
|
||||
@@ -6,6 +6,9 @@ mod shaders;
|
||||
|
||||
use std::process::ExitCode;
|
||||
|
||||
/// Where `probe` writes and `imports sync` reads without `--report`.
|
||||
const DEFAULT_REPORT_DIR: &str = "diagnostics/probe";
|
||||
|
||||
fn main() -> ExitCode {
|
||||
match std::env::args().nth(1).as_deref() {
|
||||
Some("info") => {
|
||||
@@ -46,7 +49,7 @@ fn main() -> ExitCode {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
let mut pe_path: Option<String> = None;
|
||||
let mut mode = "static".to_string();
|
||||
let mut report_dir = "diagnostics/gta6-candidate-e95020b2".to_string();
|
||||
let mut report_dir = DEFAULT_REPORT_DIR.to_string();
|
||||
|
||||
let mut i = 2;
|
||||
while i < args.len() {
|
||||
@@ -373,7 +376,7 @@ fn run_imports_generate_cli(args: &[String]) -> ExitCode {
|
||||
}
|
||||
|
||||
fn run_imports_sync_cli(args: &[String]) -> ExitCode {
|
||||
let mut report_dir = "diagnostics/gta6-candidate-e95020b2".to_string();
|
||||
let mut report_dir = DEFAULT_REPORT_DIR.to_string();
|
||||
let mut check_mode = false;
|
||||
|
||||
let mut i = 0;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
//! Default report folder of `xenora probe` and `xenora imports sync`.
|
||||
|
||||
use std::process::Command;
|
||||
|
||||
#[test]
|
||||
fn probe_and_sync_use_the_same_default_folder() {
|
||||
let fixture = concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/../../fixtures/pe/delay-imports.exe"
|
||||
);
|
||||
let folder = std::env::temp_dir().join(format!("xenora-default-{}", std::process::id()));
|
||||
std::fs::create_dir(&folder).unwrap();
|
||||
for arguments in [&["probe", "--pe", fixture][..], &["imports", "sync"]] {
|
||||
let status = Command::new(env!("CARGO_BIN_EXE_xenora"))
|
||||
.args(arguments)
|
||||
.current_dir(&folder)
|
||||
.status()
|
||||
.unwrap();
|
||||
assert!(status.success(), "{arguments:?}");
|
||||
}
|
||||
let written = ["imports.csv", "import_backlog.md"]
|
||||
.map(|name| folder.join("diagnostics/probe").join(name).is_file());
|
||||
std::fs::remove_dir_all(folder).unwrap();
|
||||
assert_eq!(written, [true, true]);
|
||||
}
|
||||
+27
-76
@@ -1,4 +1,4 @@
|
||||
use std::collections::{BTreeMap, VecDeque};
|
||||
use std::collections::BTreeMap;
|
||||
use std::ffi::c_void;
|
||||
use std::fmt;
|
||||
use std::mem::size_of_val;
|
||||
@@ -37,16 +37,6 @@ const MAX_GROUPS: usize = 64;
|
||||
const MAX_GRID_WORDS: usize = MAX_GROUPS * MAX_THREADS_PER_GROUP;
|
||||
const MAX_SOURCE_BYTES: usize = 64 * 1024;
|
||||
const MAX_IN_FLIGHT: usize = 16;
|
||||
const MAX_CACHED_PIPELINES: usize = 16;
|
||||
|
||||
type ComputePipeline = Retained<ProtocolObject<dyn MTLComputePipelineState>>;
|
||||
|
||||
struct CachedPipeline {
|
||||
source: Box<str>,
|
||||
entry: Box<str>,
|
||||
shader_validation: bool,
|
||||
pipeline: ComputePipeline,
|
||||
}
|
||||
|
||||
const BC_READBACK: &str = r"
|
||||
#include <metal_stdlib>
|
||||
@@ -158,9 +148,7 @@ impl std::error::Error for MetalError {}
|
||||
/// measure a single submission and are not a benchmark distribution.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RunProfile {
|
||||
/// Host library compilation time, or zero when reusing a compute pipeline.
|
||||
pub library_seconds: f64,
|
||||
/// Host pipeline creation time, or zero when reusing a compute pipeline.
|
||||
pub pipeline_seconds: f64,
|
||||
pub gpu_seconds: f64,
|
||||
/// Host wall time from the start of setup until wait observes completion.
|
||||
@@ -183,8 +171,6 @@ pub struct NativeCompute {
|
||||
device: Retained<ProtocolObject<dyn MTLDevice>>,
|
||||
queue: Retained<ProtocolObject<dyn MTLCommandQueue>>,
|
||||
submissions: Mutex<SubmissionTable>,
|
||||
// Least recently used first. In-flight submissions retain their own reference.
|
||||
compute_pipelines: Mutex<VecDeque<CachedPipeline>>,
|
||||
}
|
||||
|
||||
/// A submitted dispatch whose result can be collected by its issuing context.
|
||||
@@ -261,7 +247,7 @@ struct SubmissionEntry {
|
||||
/// Metal reports Completed or Error.
|
||||
struct InFlightResources {
|
||||
command: Retained<ProtocolObject<dyn MTLCommandBuffer>>,
|
||||
_pipeline: ComputePipeline,
|
||||
_pipeline: Retained<ProtocolObject<dyn MTLComputePipelineState>>,
|
||||
_input: Option<Retained<ProtocolObject<dyn MTLBuffer>>>,
|
||||
output: Retained<ProtocolObject<dyn MTLBuffer>>,
|
||||
_texture: Option<Retained<ProtocolObject<dyn MTLTexture>>>,
|
||||
@@ -362,7 +348,6 @@ impl NativeCompute {
|
||||
device,
|
||||
queue,
|
||||
submissions: Mutex::default(),
|
||||
compute_pipelines: Mutex::default(),
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -916,7 +901,7 @@ kernel void sample_rgba8(texture2d<float, access::sample> tex [[texture(0)]],
|
||||
self.run_profiled_words(source, entry, input, Some(width))
|
||||
}
|
||||
|
||||
/// Find or compile the kernel and report the smaller of the device and pipeline width limits.
|
||||
/// Compile the kernel and report the smaller of the device and pipeline width limits.
|
||||
///
|
||||
/// Input size and threadgroup count are checked separately at dispatch.
|
||||
///
|
||||
@@ -926,7 +911,11 @@ kernel void sample_rgba8(texture2d<float, access::sample> tex [[texture(0)]],
|
||||
pub fn max_group_width(&self, source: &str, entry: &str) -> Result<usize, MetalError> {
|
||||
validate_source(source, &[entry])?;
|
||||
autoreleasepool(|_| {
|
||||
let (pipeline, _, _) = self.prepare_compute_pipeline(source, entry)?;
|
||||
let options = compile_options()?;
|
||||
let library = self.compile_library(source, &options)?;
|
||||
let function = find_function(&library, entry)?;
|
||||
let pipeline = self.compute_pipeline(&function)?;
|
||||
verify_shader_validation(&pipeline)?;
|
||||
Ok(self.pipeline_group_width_limit(&pipeline))
|
||||
})
|
||||
}
|
||||
@@ -974,8 +963,15 @@ kernel void sample_rgba8(texture2d<float, access::sample> tex [[texture(0)]],
|
||||
host_start: Instant,
|
||||
) -> Result<Submission<'_>, MetalError> {
|
||||
self.submissions().check_capacity()?;
|
||||
let (pipeline, library_seconds, pipeline_seconds) =
|
||||
self.prepare_compute_pipeline(source, entry)?;
|
||||
let options = compile_options()?;
|
||||
let library_start = Instant::now();
|
||||
let library = self.compile_library(source, &options)?;
|
||||
let library_seconds = library_start.elapsed().as_secs_f64();
|
||||
let function = find_function(&library, entry)?;
|
||||
let pipeline_start = Instant::now();
|
||||
let pipeline = self.compute_pipeline(&function)?;
|
||||
let pipeline_seconds = pipeline_start.elapsed().as_secs_f64();
|
||||
verify_shader_validation(&pipeline)?;
|
||||
|
||||
let limit = self.pipeline_group_width_limit(&pipeline);
|
||||
let width = match group_width {
|
||||
@@ -1112,67 +1108,18 @@ kernel void sample_rgba8(texture2d<float, access::sample> tex [[texture(0)]],
|
||||
})
|
||||
}
|
||||
|
||||
fn prepare_compute_pipeline(
|
||||
fn compute_pipeline(
|
||||
&self,
|
||||
source: &str,
|
||||
entry: &str,
|
||||
) -> Result<(ComputePipeline, f64, f64), MetalError> {
|
||||
let shader_validation = std::env::var("MTL_SHADER_VALIDATION").as_deref() == Ok("1");
|
||||
// Device identity is fixed by this context. All misses use the same
|
||||
// compile options (safe math, precise functions, default language,
|
||||
// no macros) and unspecialized functions. Any configurable options
|
||||
// must become part of the key before they are used here.
|
||||
let mut cache = self
|
||||
.compute_pipelines
|
||||
.lock()
|
||||
.unwrap_or_else(PoisonError::into_inner);
|
||||
if let Some(index) = cache.iter().position(|cached| {
|
||||
cached.source.as_ref() == source
|
||||
&& cached.entry.as_ref() == entry
|
||||
&& cached.shader_validation == shader_validation
|
||||
}) {
|
||||
let cached = cache.remove(index).expect("position in the locked cache");
|
||||
let pipeline = cached.pipeline.clone();
|
||||
cache.push_back(cached);
|
||||
return Ok((pipeline, 0.0, 0.0));
|
||||
}
|
||||
|
||||
// Serialize cache misses in this context so concurrent requests for
|
||||
// one key share the same build. The submission table is unlocked here.
|
||||
let options = compile_options()?;
|
||||
let library_start = Instant::now();
|
||||
let library = self.compile_library(source, &options)?;
|
||||
let library_seconds = library_start.elapsed().as_secs_f64();
|
||||
let function = find_function(&library, entry)?;
|
||||
let pipeline_start = Instant::now();
|
||||
let pipeline = self
|
||||
.device
|
||||
.newComputePipelineStateWithFunction_error(&function)
|
||||
function: &ProtocolObject<dyn MTLFunction>,
|
||||
) -> Result<Retained<ProtocolObject<dyn MTLComputePipelineState>>, MetalError> {
|
||||
self.device
|
||||
.newComputePipelineStateWithFunction_error(function)
|
||||
.map_err(|error| {
|
||||
MetalError::new(
|
||||
"newComputePipelineStateWithFunction",
|
||||
error.localizedDescription().to_string(),
|
||||
)
|
||||
})?;
|
||||
let pipeline_seconds = pipeline_start.elapsed().as_secs_f64();
|
||||
if shader_validation {
|
||||
verify_shader_validation(&pipeline)?;
|
||||
}
|
||||
|
||||
// Bound owned key text to 1 MiB. A valid oversized key can run
|
||||
// uncached, so this budget does not alter source or entry validation.
|
||||
if entry.len() <= MAX_SOURCE_BYTES.saturating_sub(source.len()) {
|
||||
if cache.len() == MAX_CACHED_PIPELINES {
|
||||
cache.pop_front();
|
||||
}
|
||||
cache.push_back(CachedPipeline {
|
||||
source: source.into(),
|
||||
entry: entry.into(),
|
||||
shader_validation,
|
||||
pipeline: pipeline.clone(),
|
||||
});
|
||||
}
|
||||
Ok((pipeline, library_seconds, pipeline_seconds))
|
||||
})
|
||||
}
|
||||
|
||||
fn pipeline_group_width_limit(
|
||||
@@ -1285,6 +1232,10 @@ fn check_command_status(
|
||||
fn verify_shader_validation(
|
||||
pipeline: &ProtocolObject<dyn MTLComputePipelineState>,
|
||||
) -> Result<(), MetalError> {
|
||||
if std::env::var("MTL_SHADER_VALIDATION").as_deref() != Ok("1") {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if !pipeline.respondsToSelector(sel!(shaderValidation)) {
|
||||
return Err(MetalError::new(
|
||||
"shaderValidation",
|
||||
|
||||
@@ -356,131 +356,6 @@ fn multiple_submissions() {
|
||||
assert_eq!(second, [5, 5, 1, 5]);
|
||||
}
|
||||
|
||||
fn pipeline_was_reused(profile: &xenora_metal::RunProfile) -> bool {
|
||||
profile.library_seconds == 0.0 && profile.pipeline_seconds == 0.0
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compute_pipeline_cache_distinguishes_source_entry_and_context() {
|
||||
let context = context();
|
||||
let source = fixture("output[id] = input[id] + 1u;");
|
||||
let second_entry =
|
||||
fixture("output[id] = input[id] * 2u;").replace("void fixture(", "void other(");
|
||||
let source = format!("{source}\n{second_entry}");
|
||||
let changed = source.replace("input[id] + 1u", "input[id] - 1u");
|
||||
let input = [0, 11, u32::MAX];
|
||||
|
||||
for (msl, entry, expected) in [
|
||||
(source.as_str(), "fixture", [1, 12, 0]),
|
||||
(source.as_str(), "other", [0, 22, u32::MAX - 1]),
|
||||
(changed.as_str(), "fixture", [u32::MAX, 10, u32::MAX - 1]),
|
||||
] {
|
||||
let cold = native(context.run_words_profiled(msl, entry, &input));
|
||||
let warm = native(context.run_words_profiled(msl, entry, &input));
|
||||
assert!(!pipeline_was_reused(&cold), "{entry}");
|
||||
assert!(pipeline_was_reused(&warm), "{entry}");
|
||||
assert_eq!(cold.output, expected, "{entry}");
|
||||
assert_eq!(warm.output, expected, "{entry}");
|
||||
}
|
||||
let separate = native(NativeCompute::new());
|
||||
let fresh = native(separate.run_words_profiled(&source, "fixture", &input));
|
||||
assert!(!pipeline_was_reused(&fresh));
|
||||
assert_eq!(fresh.output, [1, 12, 0]);
|
||||
|
||||
for _ in 0..2 {
|
||||
for (msl, entry, operation) in [
|
||||
(source.as_str(), "missing", "newFunctionWithName"),
|
||||
("not valid MSL", "fixture", "newLibraryWithSource"),
|
||||
] {
|
||||
let error = context
|
||||
.run_words_profiled(msl, entry, &input)
|
||||
.expect_err("invalid pipeline must still fail after warming the cache");
|
||||
assert_eq!(error.operation, operation);
|
||||
}
|
||||
}
|
||||
let error = context
|
||||
.run_words_with_group_width(&source, "fixture", &input, 0)
|
||||
.expect_err("cached pipeline must still check dispatch width");
|
||||
assert_eq!(error.operation, "threadgroup width");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compute_pipeline_cache_bounds_key_bytes_without_rejecting_maximum_source() {
|
||||
const SOURCE_LIMIT: usize = 64 * 1024;
|
||||
let context = context();
|
||||
let mut source = fixture("output[id] = input[id] ^ 1u;");
|
||||
source.push_str("\n// ");
|
||||
source.push_str(&" ".repeat(SOURCE_LIMIT - source.len()));
|
||||
|
||||
for _ in 0..2 {
|
||||
let profile = native(context.run_words_profiled(&source, "fixture", &[8]));
|
||||
assert_eq!(profile.output, [9]);
|
||||
assert!(!pipeline_was_reused(&profile));
|
||||
}
|
||||
source.push(' ');
|
||||
let error = context
|
||||
.run_words_profiled(&source, "fixture", &[8])
|
||||
.expect_err("source above 64 KiB must fail before pipeline lookup");
|
||||
assert_eq!(error.operation, "source bounds");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compute_pipeline_cache_evicts_oldest_unused_key_and_keeps_pending_work_alive() {
|
||||
let context = context();
|
||||
// Seventeen entries in one source fit in Metal's input limit and exceed
|
||||
// Xenora's 16-pipeline cache. Each kernel writes a distinct result.
|
||||
let source: String = (0..=16)
|
||||
.map(|id| {
|
||||
fixture(&format!("output[id] = input[id] + {id}u;"))
|
||||
.replace("void fixture(", &format!("void entry{id}("))
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
native(context.max_group_width(&source, "entry0"));
|
||||
let (pending, gate) = native(context.submit_words_gated(&source, "entry1", &[7]));
|
||||
for id in 2..16 {
|
||||
native(context.max_group_width(&source, &format!("entry{id}")));
|
||||
}
|
||||
native(context.max_group_width(&source, "entry0"));
|
||||
native(context.max_group_width(&source, "entry16"));
|
||||
gate.open();
|
||||
let finished = native(context.wait(pending));
|
||||
assert_eq!(finished.output, [8]);
|
||||
|
||||
let recent = native(context.run_words_profiled(&source, "entry0", &[29]));
|
||||
assert!(pipeline_was_reused(&recent));
|
||||
assert_eq!(recent.output, [29]);
|
||||
let rebuilt = native(context.run_words_profiled(&source, "entry1", &[17]));
|
||||
assert!(!pipeline_was_reused(&rebuilt));
|
||||
assert_eq!(rebuilt.output, [18]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn simultaneous_compute_submissions_share_one_pipeline_build() {
|
||||
let context = context();
|
||||
let source = fixture("output[id] = input[id] ^ 5u;");
|
||||
let start = std::sync::Barrier::new(4);
|
||||
std::thread::scope(|scope| {
|
||||
let workers: Vec<_> = (0..4)
|
||||
.map(|input| {
|
||||
let (context, source, start) = (&context, &source, &start);
|
||||
scope.spawn(move || {
|
||||
start.wait();
|
||||
let token = native(context.submit_words(source, "fixture", &[input]));
|
||||
let result = native(context.wait(token));
|
||||
assert_eq!(result.output, [input ^ 5]);
|
||||
usize::from(!pipeline_was_reused(&result))
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
let builds: usize = workers
|
||||
.into_iter()
|
||||
.map(|worker| worker.join().unwrap())
|
||||
.sum();
|
||||
assert_eq!(builds, 1);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn errors_propagate() {
|
||||
let context = context();
|
||||
@@ -538,52 +413,3 @@ kernel void fixture(device const uint *input [[buffer(0)]],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "manual GPU timing run"]
|
||||
fn compute_pipeline_reuse_benchmark() {
|
||||
const WARMUPS: usize = 10;
|
||||
const SAMPLES: usize = 101;
|
||||
let warm_context = context();
|
||||
let device = warm_context.device_name();
|
||||
let source = fixture("output[id] = input[id] * 7u + 3u;");
|
||||
let input = mixing_input(131);
|
||||
let expected: Vec<_> = input
|
||||
.iter()
|
||||
.map(|word| word.wrapping_mul(7).wrapping_add(3))
|
||||
.collect();
|
||||
let mut timings = [[[0.0; SAMPLES]; 4]; 2];
|
||||
|
||||
for round in 0..WARMUPS + SAMPLES {
|
||||
let cold_context = context();
|
||||
// Alternate order so neither measurement always follows the other.
|
||||
let contexts = [&cold_context, &warm_context];
|
||||
for index in [round % 2, (round + 1) % 2] {
|
||||
let profile = native(contexts[index].run_words_profiled(&source, "fixture", &input));
|
||||
assert_eq!(profile.output, expected, "context={index} round={round}");
|
||||
if round >= WARMUPS {
|
||||
for (samples, seconds) in timings[index].iter_mut().zip([
|
||||
profile.library_seconds,
|
||||
profile.pipeline_seconds,
|
||||
profile.host_seconds,
|
||||
profile.gpu_seconds,
|
||||
]) {
|
||||
samples[round - WARMUPS] = seconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (label, [mut library, mut pipeline, mut host, mut gpu]) in
|
||||
["fresh context", "repeated context"]
|
||||
.into_iter()
|
||||
.zip(timings)
|
||||
{
|
||||
println!(
|
||||
"device={device} {label} samples={SAMPLES} library_us[{}] pipeline_us[{}] host_us[{}] gpu_us[{}]",
|
||||
timing_summary(&mut library),
|
||||
timing_summary(&mut pipeline),
|
||||
timing_summary(&mut host),
|
||||
timing_summary(&mut gpu),
|
||||
);
|
||||
}
|
||||
}
|
||||
+47
-10
@@ -27,6 +27,8 @@ pub use upload::{
|
||||
|
||||
const BLOCK_BYTES: usize = 8;
|
||||
const TILE_BLOCKS: usize = 2;
|
||||
const TILE_ROW_BYTES: usize = TILE_BLOCKS * BLOCK_BYTES;
|
||||
const TILE_BYTES: usize = TILE_BLOCKS * TILE_ROW_BYTES;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum TextureError {
|
||||
@@ -91,19 +93,30 @@ impl<'a> TiledBc1<'a> {
|
||||
/// Copies one subresource as tightly packed row-major BC1 block rows.
|
||||
/// Padded tile slots are excluded, including at partial texel blocks.
|
||||
pub fn linearize(&self, layer: usize, mip: u32) -> Result<Vec<u8>, TextureError> {
|
||||
if layer >= self.layers {
|
||||
if layer >= self.layers || mip >= self.mips {
|
||||
return Err(TextureError::OutOfBounds);
|
||||
}
|
||||
self.mip_extent(mip)?;
|
||||
let (width, height) = mip_blocks(self.width, self.height, mip);
|
||||
let base = self.mip_base(layer, mip)?;
|
||||
let tile_row_stride = width.div_ceil(TILE_BLOCKS) * TILE_BYTES;
|
||||
let full_tiles = width / TILE_BLOCKS;
|
||||
let edge_bytes = (width % TILE_BLOCKS) * BLOCK_BYTES;
|
||||
let mut blocks = Vec::new();
|
||||
// Construction checked the larger, padded byte count.
|
||||
blocks
|
||||
.try_reserve_exact(width * height * BLOCK_BYTES)
|
||||
.map_err(|_| TextureError::AllocationFailed)?;
|
||||
// Construction requires the exact padded length, so each selected tile row is in bounds.
|
||||
for y in 0..height {
|
||||
for x in 0..width {
|
||||
blocks.extend_from_slice(&self.block(layer, mip, x, y)?);
|
||||
let row_start =
|
||||
base + (y / TILE_BLOCKS) * tile_row_stride + (y % TILE_BLOCKS) * TILE_ROW_BYTES;
|
||||
for tile in 0..full_tiles {
|
||||
let start = row_start + tile * TILE_BYTES;
|
||||
blocks.extend_from_slice(&self.bytes[start..start + TILE_ROW_BYTES]);
|
||||
}
|
||||
if edge_bytes != 0 {
|
||||
let start = row_start + full_tiles * TILE_BYTES;
|
||||
blocks.extend_from_slice(&self.bytes[start..start + edge_bytes]);
|
||||
}
|
||||
}
|
||||
Ok(blocks)
|
||||
@@ -124,19 +137,24 @@ impl<'a> TiledBc1<'a> {
|
||||
if x >= width || y >= height {
|
||||
return Err(TextureError::OutOfBounds);
|
||||
}
|
||||
let mut base = layer * self.layer_bytes;
|
||||
for prior in 0..mip {
|
||||
base += mip_bytes(self.width, self.height, prior)?;
|
||||
}
|
||||
let base = self.mip_base(layer, mip)?;
|
||||
// Construction checked the full padded size for every level and layer.
|
||||
let tile = (y / TILE_BLOCKS) * width.div_ceil(TILE_BLOCKS) + x / TILE_BLOCKS;
|
||||
let within_tile = (y % TILE_BLOCKS) * TILE_BLOCKS + x % TILE_BLOCKS;
|
||||
let offset = base + (tile * TILE_BLOCKS.pow(2) + within_tile) * BLOCK_BYTES;
|
||||
let offset = base + tile * TILE_BYTES + within_tile * BLOCK_BYTES;
|
||||
self.bytes
|
||||
.get(offset..offset + BLOCK_BYTES)
|
||||
.and_then(|bytes| bytes.try_into().ok())
|
||||
.ok_or(TextureError::InvalidByteLength)
|
||||
}
|
||||
|
||||
fn mip_base(&self, layer: usize, mip: u32) -> Result<usize, TextureError> {
|
||||
let mut base = layer * self.layer_bytes;
|
||||
for prior in 0..mip {
|
||||
base += mip_bytes(self.width, self.height, prior)?;
|
||||
}
|
||||
Ok(base)
|
||||
}
|
||||
}
|
||||
|
||||
fn mip_blocks(width: usize, height: usize, mip: u32) -> (usize, usize) {
|
||||
@@ -151,7 +169,7 @@ fn mip_bytes(width: usize, height: usize, mip: u32) -> Result<usize, TextureErro
|
||||
width
|
||||
.div_ceil(TILE_BLOCKS)
|
||||
.checked_mul(height.div_ceil(TILE_BLOCKS))
|
||||
.and_then(|tiles| tiles.checked_mul(TILE_BLOCKS.pow(2) * BLOCK_BYTES))
|
||||
.and_then(|tiles| tiles.checked_mul(TILE_BYTES))
|
||||
.ok_or(TextureError::SizeOverflow)
|
||||
}
|
||||
|
||||
@@ -216,6 +234,7 @@ mod tests {
|
||||
assert_eq!(tex.linearize(1, 0).unwrap(), logical_blocks.as_flattened());
|
||||
assert_eq!(tex.linearize(1, 1).unwrap(), [20; 8]);
|
||||
assert_eq!(tex.linearize(2, 0), Err(TextureError::OutOfBounds));
|
||||
assert_eq!(tex.linearize(0, 2), Err(TextureError::OutOfBounds));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -242,6 +261,24 @@ mod tests {
|
||||
assert_eq!(texture.block(0, 0, 2, 2), Ok([12; 8]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn linearizes_odd_tile_edges_in_each_layer() {
|
||||
// A 21×21 texture uses 9, 4 and 1 tiles across the three mips.
|
||||
// Mip 1 is 10×10 texels, so only nine of its sixteen slots are logical.
|
||||
let block = |slot: u8| [slot, 1, 2, 3, 4, 5, 6, !slot];
|
||||
let bytes: Vec<_> = (0..112).flat_map(block).collect();
|
||||
let texture = TiledBc1::new(&bytes, 21, 21, 3, 2).unwrap();
|
||||
for (layer, first_slot) in [(0, 36), (1, 92)] {
|
||||
let expected: Vec<_> = [0, 1, 4, 2, 3, 6, 8, 9, 12]
|
||||
.into_iter()
|
||||
.flat_map(|slot| block(first_slot + slot))
|
||||
.collect();
|
||||
assert_eq!(texture.linearize(layer, 1).unwrap(), expected);
|
||||
let last_mip: Vec<_> = (16..20).flat_map(|slot| block(first_slot + slot)).collect();
|
||||
assert_eq!(texture.linearize(layer, 2).unwrap(), last_mip);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn decodes_opaque_and_transparent_bc1_palettes() {
|
||||
let opaque = decode_bc1([0, 0xf8, 31, 0, 0xe4, 0xe4, 0xe4, 0xe4]);
|
||||
|
||||
@@ -40,6 +40,8 @@ either path. The [changelog](../CHANGELOG.md) records notable changes.
|
||||
|
||||
## Testing, validation, and benchmarks
|
||||
|
||||
- [Testing and acceptance index](testing/README.md) — Entry point for test procedures, evidence and review records.
|
||||
- [AMD RDNA2 desktop GPU (gfx1030) form acceptance](testing/shader-form-acceptance.md) — Independence, command, log and promotion rules for fixture-verified instruction forms.
|
||||
- [Engineering progress](progress.md) — Verification commands, metric definitions, and open release gates.
|
||||
- [Test inventory comparison](testing/test-inventory.md) — Detect missing or newly ignored Cargo tests across commits.
|
||||
- [Persistent resource and translated rendering acceptance](testing/x9-acceptance.md) — Pinned upstream tests, native ARM64 results and unsupported cases.
|
||||
|
||||
+2
-1
@@ -70,7 +70,8 @@ uses a Win64-aligned stack and terminates with HLT. The result includes the load
|
||||
guest memory and the entry execution outcome.
|
||||
|
||||
`xenora probe --mode static` inventories ordinary and delay-loaded PE imports
|
||||
without guest execution. `missing_imports.csv` lists unresolved ordinary keys
|
||||
without guest execution. Without `--report` it writes to `diagnostics/probe`,
|
||||
where `xenora imports sync` also looks. `missing_imports.csv` lists unresolved ordinary keys
|
||||
with their import address table relative virtual addresses. The full inventory,
|
||||
`imports.csv`, marks each entry `ordinary` or `delayed` in its `import_table`
|
||||
column and records whether each key is registered, its implementation
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# Testing and acceptance
|
||||
|
||||
- [AMD RDNA2 desktop GPU (gfx1030) form acceptance](shader-form-acceptance.md) — Rule and evidence required to promote a form from local results to `fixture verified`.
|
||||
- [Test inventory comparison](test-inventory.md) — Detect missing or newly ignored Cargo tests across commits.
|
||||
- [Persistent resource and translated rendering acceptance](x9-acceptance.md) — Native ARM64 results and unsupported cases.
|
||||
- [Baseline acceptance](phase-02-baseline.md) and [Phase 01 assurance](phase01-assurance.md) — Candidate-specific evidence.
|
||||
- [Independent reviews](review-log.md) — Review findings and acceptance records.
|
||||
- [Mutation testing](mutation.md) and [benchmark protocol](benchmarks.md) — Sensitivity and timing requirements.
|
||||
- [Infrastructure QA tooling](infrastructure/README.md) — Advisory orchestration, PR validation, benchmark analysis and release checks.
|
||||
@@ -1,5 +1,12 @@
|
||||
# Independent review
|
||||
|
||||
## gfx1030 form acceptance
|
||||
|
||||
Use the [AMD RDNA2 desktop GPU (gfx1030) form acceptance rule](shader-form-acceptance.md) for entries that
|
||||
promote instruction forms to `fixture verified`. Record only completed runs with
|
||||
a named commit, independent runner, host, exact commands and real counts. Raw
|
||||
logs stay under ignored `artifacts/acceptance/<commit>/`.
|
||||
|
||||
## R1. First synthetic compute checkpoint, 2026-11-22
|
||||
|
||||
Reviewed the integrated working tree before a candidate commit. The findings below cover the first checkpoint.
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
# AMD RDNA2 desktop GPU (gfx1030) form acceptance
|
||||
|
||||
This is the promotion rule for AMD RDNA2 desktop GPU (`gfx1030`) instruction
|
||||
forms in [`docs/status.toml`](../status.toml). It implements the documentation
|
||||
step of [#302](https://github.com/ranveersoni98/Xenora/issues/302). It does not
|
||||
claim Xbox-hardware verification or commercial-game compatibility.
|
||||
|
||||
The **LLVM three-way decoder check** is the ignored `llvm-mc` comparison in
|
||||
[`crates/decoder/tests/gfx1030.rs`](../../crates/decoder/tests/gfx1030.rs). It
|
||||
compares Xenora's decoder with LLVM's gfx1030 decoder over the fixture and
|
||||
probe encodings; it is encoding evidence, not GPU-semantics evidence.
|
||||
|
||||
## Status meanings
|
||||
|
||||
| Status | Meaning |
|
||||
| --- | --- |
|
||||
| `local known-answer test passed` | The implementation's CPU known-answer test passed locally. This is not independent acceptance. |
|
||||
| `local Apple M5 readback passed; acceptance pending` | A local native Metal readback passed with validation, but the independence and evidence rules below are incomplete. |
|
||||
| `fixture verified on Apple M5` | The host-qualified spelling used by three existing rows. `scripts/audit/status.py` treats it as equivalent to `fixture verified`; existing rows do not need re-acceptance solely for this wording. New entries should normally use `fixture verified` and record the host in the review log. |
|
||||
| `fixture verified` | The form or documented family batch passed independent acceptance at a named commit, with CPU, LLVM and native Metal evidence recorded. |
|
||||
|
||||
A skipped test is not a pass. A shader compile without readback is not GPU
|
||||
verification. Agreement with a spec-derived reference is not agreement with
|
||||
Xbox hardware.
|
||||
|
||||
## Independence
|
||||
|
||||
> **Proposed policy, pending maintainer confirmation.** The independence rule in
|
||||
> this section is the proposal from #302. Do not use it to promote forms until
|
||||
> the maintainer confirms or revises it.
|
||||
|
||||
The person running the acceptance pass must not be the author of the pull
|
||||
request that added the form being accepted. The runner may use the existing
|
||||
tests and commands, but must record their own results and review the evidence.
|
||||
If the maintainer runs the pass for forms they authored, the review-log entry
|
||||
must say so explicitly; that exception is not silent self-certification.
|
||||
|
||||
The expected values used by the test must remain independent of the production
|
||||
decoder, translator or Metal backend. Do not change fixtures, thresholds or test
|
||||
filters to make a form pass.
|
||||
|
||||
## Acceptance procedure
|
||||
|
||||
1. **Use a clean named commit.** Start from a clean checkout of `main` at the
|
||||
commit being accepted. Record the full commit hash. Do not accept a working
|
||||
tree with uncommitted changes.
|
||||
2. **Name the scope.** List each form, or a family batch with an explicit list of
|
||||
forms, covered by the pass. A family name alone is not enough.
|
||||
3. **Run the standard gates.** Format, Clippy, workspace tests, fixture checks,
|
||||
the LLVM three-way decoder check and the native GPU suite must pass. Record
|
||||
exact commands, environment variables and pass/fail/skip counts.
|
||||
4. **Run the form's CPU and Metal tests.** The CPU known-answer/reference tests
|
||||
and the native Metal readback must both pass. Metal API and shader validation
|
||||
must be enabled. Use a targeted test filter where useful, but keep the full
|
||||
standard-gate result for the same commit.
|
||||
5. **Check negative cases.** Unsupported encodings, malformed inputs and any
|
||||
documented rejection cases for the form must still pass.
|
||||
6. **Save raw logs.** Put raw output under ignored
|
||||
`artifacts/acceptance/<commit>/`. Do not commit raw logs.
|
||||
7. **Write the review-log summary.** Add an entry to
|
||||
[`review-log.md`](review-log.md) with the commit, runner's GitHub login, host,
|
||||
scope, exact commands or log path, and CPU/LLVM/Metal results. A reviewer
|
||||
confirms the entry if the runner is not the maintainer.
|
||||
8. **Promote only passed forms.** Change `cpu` and `gpu` in `docs/status.toml`
|
||||
only for forms covered by a passing entry. Regenerate the status tables and
|
||||
progress graphic, then run `python3 scripts/audit/status.py --check`.
|
||||
|
||||
## Standard gate set
|
||||
|
||||
Run on native Apple Silicon. The exact host and tool versions belong in the
|
||||
review-log entry.
|
||||
|
||||
```sh
|
||||
export CARGO_BUILD_JOBS=2
|
||||
cargo fmt --all -- --check
|
||||
cargo clippy --locked --workspace --all-targets --all-features -- -D warnings
|
||||
cargo test --locked --workspace
|
||||
scripts/assemble-fixture.sh --check
|
||||
LLVM_BIN="$(brew --prefix llvm)/bin" \
|
||||
cargo test --locked -p xenora-decoder --test gfx1030 -- --include-ignored --nocapture
|
||||
cargo test --locked -p xenora-semantic-review
|
||||
scripts/test-gpu.sh
|
||||
python3 scripts/audit/status.py --check
|
||||
```
|
||||
|
||||
For a targeted semantic-review pass, record the filter and use the same Metal
|
||||
validation environment as `scripts/test-gpu.sh`:
|
||||
|
||||
```sh
|
||||
cargo test --locked -p xenora-semantic-review <cpu-test-filter>
|
||||
MTL_DEBUG_LAYER=1 \
|
||||
MTL_SHADER_VALIDATION=1 \
|
||||
MTL_SHADER_VALIDATION_REPORT_TO_STDERR=1 \
|
||||
MTL_SHADER_VALIDATION_ABORT_ON_FAULT=1 \
|
||||
cargo test --locked -p xenora-semantic-review <native-metal-test-filter> \
|
||||
-- --ignored --exact --nocapture --test-threads=1
|
||||
```
|
||||
|
||||
A targeted filter does not replace the standard gate set; it attributes the
|
||||
result to a form or family batch.
|
||||
|
||||
## Review-log entry
|
||||
|
||||
Use one row per commit and scope. Add rows to
|
||||
[`review-log.md`](review-log.md); keep raw output only in `artifacts/`.
|
||||
|
||||
| Date | Commit | Runner (GitHub login) | Host and tools | Forms or batch | Commands / raw log | CPU | LLVM | Metal | Review |
|
||||
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
||||
| YYYY-MM-DD | full SHA | @login | Mac, macOS, Xcode, Rust, LLVM | explicit form list | exact commands and `artifacts/acceptance/<commit>/` path | pass/fail/skip counts | pass/fail counts | pass/fail/skip counts; validation on | reviewer GitHub login or maintainer exception |
|
||||
|
||||
Do not write `pass` without counts. Do not count a skipped native test as Metal
|
||||
evidence.
|
||||
|
||||
## Promotion and failures
|
||||
|
||||
After a passing entry, set the accepted rows to `fixture verified` and regenerate:
|
||||
|
||||
```sh
|
||||
python3 scripts/audit/status.py
|
||||
python3 scripts/audit/status.py --check
|
||||
```
|
||||
|
||||
If any required check fails or skips, leave the form pending. Record the commit,
|
||||
host, command and failure in the review log, and open a separate issue for the
|
||||
failure. Do not weaken the test or change the expected result in the acceptance
|
||||
pass.
|
||||
|
||||
The automated status-check enforcement proposed in #302 is a separate change.
|
||||
Until it lands, reviewers must enforce the review-log requirement manually.
|
||||
Reference in new issue
Block a user