replay: an ID's low word is compared with the recording's, its high word with the documented word
The planner's ruling on resource IDs: the new runtime's layout stands (index | word << 32, docs/RESOURCE-ID.md). A recording made on the old runtime holds that runtime's high word, so a whole-ID comparison reported every texture whose word is not 0 as differing. Backend::resource_word gives the high word RESOURCE-ID.md's own functions give the descriptor the backend made the object of: TextureWord::of(pixel format, swizzle) for a texture, SamplerWord::of for a sampler state. Where a backend gives one (the new runtime's), the player compares the ID's low word with the recording's and its high word with that word, never with the recording's high word. Where it gives none (the old runtime's), the whole ID is compared as before. A differing ID's line carries the word: 'id #N RECORDED PLAYED word WORD'. Test a_resource_id_s_high_word_is_checked_against_the_documented_word: an ID with the recorded index and the word passes over a recorded high word of 0 or 1; another index or another high word is reported with the word.
This commit is contained in:
1 parent
76c6f5d071
commit
1fe1d69fc0
4 files changed
+101
-5
No files matched your search
@@ -25,6 +25,8 @@ use super::value::Value;
|
||||
use crate::gpu::wait::new_runtime::{wait_until_retired, Retired};
|
||||
use crate::gpu::wait::SubmissionBackend;
|
||||
use crate::gpu::DeviceType;
|
||||
use metal2vulkan::metal::resource_word::TextureWord;
|
||||
use metal2vulkan::metal::sampler::SamplerWord;
|
||||
use metal2vulkan::pipeline::{LinkedFunction, LinkedFunctions};
|
||||
use metal2vulkan_rt as rt;
|
||||
use places::{class_index, granule, Place, Places};
|
||||
@@ -2092,6 +2094,18 @@ impl Backend for NewRuntime {
|
||||
Ok(Some(id.to_bits()))
|
||||
}
|
||||
|
||||
fn resource_word(&mut self, object: u64) -> Option<u32> {
|
||||
match self.objects.get(&object)? {
|
||||
Object::Texture(texture) => {
|
||||
let descriptor = texture.descriptor();
|
||||
let word = TextureWord::of(descriptor.pixel_format, descriptor.swizzle);
|
||||
word.map(|word| word.0)
|
||||
}
|
||||
Object::Sampler(sampler) => Some(SamplerWord::of(sampler.descriptor()).0),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn counters(&mut self) -> Counters {
|
||||
let metrics = self.device.counters().metrics();
|
||||
// Every metric that sums: a frame's is the difference of two reads.
|
||||
|
||||
@@ -85,6 +85,14 @@ pub trait Backend {
|
||||
fn read(&mut self, object: u64) -> Result<Vec<u8>, PlayError>;
|
||||
/// The `gpuResourceID` the runtime gives `object`; none where its getter raises.
|
||||
fn resource_id(&mut self, object: u64) -> Result<Option<u64>, PlayError>;
|
||||
/// The high word docs/RESOURCE-ID.md gives `object`'s ID: its function of the descriptor the
|
||||
/// backend made the object of (a texture's `TextureWord`, a sampler state's `SamplerWord`).
|
||||
/// The player then compares only the ID's low word, its index, with the recording's, and
|
||||
/// checks the high word against this one. None where the runtime lays out no such word: the
|
||||
/// player compares the whole ID with the recording's.
|
||||
fn resource_word(&mut self, _object: u64) -> Option<u32> {
|
||||
None
|
||||
}
|
||||
/// The runtime's size and alignment, in bytes, of what `call` places in a placement heap: for
|
||||
/// `newTextureWithDescriptor:offset:`, its `heapTextureSizeAndAlignWithDescriptor:` of the
|
||||
/// texture descriptor that `descriptor`'s calls make and set, in order (the call that made
|
||||
@@ -194,13 +202,16 @@ pub struct Check {
|
||||
}
|
||||
|
||||
/// An object whose `gpuResourceID` in the runtime is not the one the program saw: the bytes that
|
||||
/// hold the program's ID name no object of the play.
|
||||
/// hold the program's ID name no object of the play. Where the backend gives the documented high
|
||||
/// word (`word`, [`Backend::resource_word`]), the ID differs where its low word is not the
|
||||
/// recording's or its high word is not that word.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct IdDiffers {
|
||||
pub object: u64,
|
||||
pub recorded: u64,
|
||||
/// None where the runtime's getter raises.
|
||||
pub played: Option<u64>,
|
||||
pub word: Option<u32>,
|
||||
}
|
||||
|
||||
/// One `m2v.privateBytes` record compared after its dispatch: how many of the range's 4-byte words
|
||||
@@ -602,7 +613,13 @@ impl Report {
|
||||
let played = id
|
||||
.played
|
||||
.map_or("none".to_owned(), |played| format!("{played:#x}"));
|
||||
lines.push(format!("id #{} {:#x} {played}", id.object, id.recorded));
|
||||
let word = id
|
||||
.word
|
||||
.map_or(String::new(), |word| format!(" word {word:#x}"));
|
||||
lines.push(format!(
|
||||
"id #{} {:#x} {played}{word}",
|
||||
id.object, id.recorded
|
||||
));
|
||||
}
|
||||
if !self.other_devices.is_empty() {
|
||||
let devices: String = (self.other_devices.iter())
|
||||
@@ -1463,7 +1480,10 @@ impl<'b, B: Backend> Player<'b, B> {
|
||||
}
|
||||
|
||||
/// Compare the ID the program saw of `call`'s receiver, where it saw one, with the runtime's,
|
||||
/// once per object, and report the object where they differ.
|
||||
/// once per object, and report the object where they differ: where the backend gives the
|
||||
/// documented high word ([`Backend::resource_word`]), the runtime's low word against the
|
||||
/// recording's and its high word against that word, as the recording's high word is the
|
||||
/// recording runtime's layout; else the whole ID.
|
||||
fn resource_id(&mut self, call: &Call) -> Result<(), PlayError> {
|
||||
let object = call.receiver;
|
||||
if !self.kinds.contains_key(&object) {
|
||||
@@ -1487,11 +1507,19 @@ impl<'b, B: Backend> Player<'b, B> {
|
||||
return Ok(());
|
||||
}
|
||||
let played = self.backend.resource_id(object)?;
|
||||
if played != Some(recorded) {
|
||||
let word = self.backend.resource_word(object);
|
||||
let same = match (played, word) {
|
||||
(Some(played), Some(word)) => {
|
||||
played as u32 == recorded as u32 && (played >> 32) as u32 == word
|
||||
}
|
||||
(played, _) => played == Some(recorded),
|
||||
};
|
||||
if !same {
|
||||
let differs = IdDiffers {
|
||||
object,
|
||||
recorded,
|
||||
played,
|
||||
word,
|
||||
};
|
||||
self.report.ids.push(differs);
|
||||
}
|
||||
|
||||
@@ -485,6 +485,8 @@ struct Kept {
|
||||
commits: u64,
|
||||
/// The resource IDs it gives; an object not here has none (its getter raises).
|
||||
ids: HashMap<u64, u64>,
|
||||
/// The documented high words it gives (`Backend::resource_word`); an object not here has none.
|
||||
words: HashMap<u64, u32>,
|
||||
asked: Vec<u64>,
|
||||
memory: HashMap<u64, Vec<u8>>,
|
||||
copies: u64,
|
||||
@@ -584,6 +586,10 @@ impl Backend for Kept {
|
||||
Ok(self.ids.get(&object).copied())
|
||||
}
|
||||
|
||||
fn resource_word(&mut self, object: u64) -> Option<u32> {
|
||||
self.words.get(&object).copied()
|
||||
}
|
||||
|
||||
fn heap_size_and_align(
|
||||
&mut self,
|
||||
call: &Call,
|
||||
@@ -1246,6 +1252,7 @@ fn a_resource_id_the_runtime_gives_otherwise_is_reported() {
|
||||
object,
|
||||
recorded,
|
||||
played,
|
||||
word: None,
|
||||
};
|
||||
let ids = [differs(3, 0x1_0000_0005, Some(0x99)), differs(4, 7, None)];
|
||||
assert_eq!(report.ids, ids);
|
||||
@@ -1257,6 +1264,49 @@ fn a_resource_id_the_runtime_gives_otherwise_is_reported() {
|
||||
assert!(lines.contains(&"id #4 0x7 none".to_owned()), "{lines:?}");
|
||||
}
|
||||
|
||||
/// Where the backend gives the documented high word of an object's ID, the player compares the
|
||||
/// ID's low word with the recording's and its high word with that word, never with the
|
||||
/// recording's high word: an ID of the recording's index and the word passes whatever high word
|
||||
/// the recording holds; another index, or another high word, is reported with the word.
|
||||
#[test]
|
||||
fn a_resource_id_s_high_word_is_checked_against_the_documented_word() {
|
||||
let mut kept = Kept {
|
||||
ids: HashMap::from([
|
||||
(2, 0x0001_0800_0000_0005),
|
||||
(3, 0x0001_0800_0000_0006),
|
||||
(4, 0x0002_0000_0000_0007),
|
||||
]),
|
||||
words: HashMap::from([(2, 0x0001_0800), (3, 0x0001_0800), (4, 0x0001_0800)]),
|
||||
..Kept::default()
|
||||
};
|
||||
let id = |id: u64| [("gpuResourceID", Value::Uint(id))];
|
||||
let (report, ended) = played(&mut kept, |w| {
|
||||
w.call("MTLCreateSystemDefaultDevice", 0, 1, &[], &[])?;
|
||||
for object in 2..=4 {
|
||||
w.call("newSamplerStateWithDescriptor:", 1, object, &[], &[])?;
|
||||
}
|
||||
// The recording's high words are its runtime's: 0 and 1.
|
||||
w.call("gpuResourceID", 2, 0, &[], &id(5))?;
|
||||
w.call("gpuResourceID", 3, 0, &[], &id(0x1_0000_0005))?;
|
||||
w.call("gpuResourceID", 4, 0, &[], &id(7))
|
||||
});
|
||||
ended.unwrap();
|
||||
let differs = |object, recorded, played| IdDiffers {
|
||||
object,
|
||||
recorded,
|
||||
played: Some(played),
|
||||
word: Some(0x0001_0800),
|
||||
};
|
||||
let ids = [
|
||||
differs(3, 0x1_0000_0005, 0x0001_0800_0000_0006),
|
||||
differs(4, 7, 0x0002_0000_0000_0007),
|
||||
];
|
||||
assert_eq!(report.ids, ids);
|
||||
let lines = report.lines();
|
||||
let line = "id #4 0x7 0x200000000007 word 0x10800";
|
||||
assert!(lines.contains(&line.to_owned()), "{lines:?}");
|
||||
}
|
||||
|
||||
/// A texture its descriptor marks `outside` is outside the program's IDs: a `gpuResourceID`
|
||||
/// record of it, where the mark or the record is wrong, stops the play, naming the call; a plain
|
||||
/// texture's is compared as ever.
|
||||
|
||||
@@ -707,7 +707,11 @@ of the blocks the backend holds for the stream by class, `shared_block_bytes` an
|
||||
`devices apart from the guest's: #ID ...` where the stream recorded devices besides the one the
|
||||
guest makes its objects on (section 4), `check ID SHA256 match|differs|unrecorded`, `id ID RECORDED PLAYED` for each object whose runtime
|
||||
gives another `gpuResourceID` than the program saw (both in hex, `PLAYED` `none` where the
|
||||
runtime's getter raises), `private ID DISPATCH LOCATION+LENGTH match|differs N/WORDS` for each
|
||||
runtime's getter raises), `id ID RECORDED PLAYED word WORD` on the new runtime, which lays its IDs
|
||||
out as [RESOURCE-ID.md](RESOURCE-ID.md) does: there the ID's low word, its index, is compared with
|
||||
the recording's, and its high word with `WORD`, the document's own function of the descriptor the
|
||||
object was made of (a texture's `TextureWord`, a sampler state's `SamplerWord`), never with the
|
||||
recording's high word, which is the recording runtime's own; `private ID DISPATCH LOCATION+LENGTH match|differs N/WORDS` for each
|
||||
`m2v.privateBytes` range compared, `split N executed COUNTS` where the player split compute
|
||||
encoders around them (`N` the encoders split, `COUNTS` the executed counts of their groups),
|
||||
`unsnapshotted N` where the backend took none of them (`N` the dispatches played as they are),
|
||||
|
||||
Reference in new issue
Block a user