Repository navigation
D3D12.X: CopyIntoSubresource makes the blocks it wrote hot at once #3437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -719,6 +719,7 @@ unsafe extern "system" fn copy_into(p: *mut c_void, dst: *mut u8, plane: u32, su | |
| to.copy_from_slice(std::slice::from_raw_parts(src.add(from), row)); | ||
| } | ||
| t.chain.tile_volume(std::slice::from_raw_parts_mut(dst.add(at as usize), t.size() as usize), i, &linear); | ||
| crate::hle::d3d12x::title_textures::mark_hot(dst as usize + at as usize, t.size() as usize); | ||
| return S_OK; | ||
| } | ||
| let mut linear = vec![0u8; row * m.height]; | ||
|
|
@@ -727,6 +728,9 @@ unsafe extern "system" fn copy_into(p: *mut c_void, dst: *mut u8, plane: u32, su | |
| } | ||
| let slice = std::slice::from_raw_parts_mut(dst.add(at as usize + k * t.chain.slice_bytes), t.chain.slice_bytes); | ||
| t.chain.tile_level(slice, i, k, &linear); | ||
| // (a title submits right after this: the looks take these blocks now, not once the walk | ||
| // finds them, which can be after that submit for a block idle longer than `hot_for`) | ||
| crate::hle::d3d12x::title_textures::mark_hot(slice.as_ptr() as usize, slice.len()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not certain about this one: |
||
| S_OK | ||
| } | ||
|
|
||
|
|
@@ -804,6 +808,35 @@ mod tests { | |
| } | ||
| } | ||
|
|
||
| /// CopyIntoSubresource makes the write-watch blocks it wrote hot at once, both of them when | ||
| /// the texture spans two: a title submits right after it, before the walk finds the pages of | ||
| /// a block idle longer than `hot_for` (#3382). | ||
| #[test] | ||
| fn a_subresource_copy_makes_its_blocks_hot() { | ||
| use crate::hle::d3d12x::title_textures::hot_block; | ||
| if std::env::var("XCL_WATCH_HOT").is_ok_and(|v| v.trim() == "0") { | ||
| return; | ||
| } | ||
| type Six = unsafe extern "system" fn(*mut c_void, *mut u8, u32, u32, *const u8, u32, u32) -> HRESULT; | ||
| const BLOCK: usize = 2 << 20; | ||
| let d = desc(64, 32, 1, 1, 28, 0x109); | ||
| let mut c: *mut c_void = std::ptr::null_mut(); | ||
| unsafe { | ||
| assert!(XGCreateTextureComputer(d.as_ptr(), &mut c) >= 0); | ||
| let size = Texture::new(&d).unwrap().size() as usize; | ||
| let lin = vec![0x5Au8; 64 * 4 * 32]; | ||
| let into: Six = std::mem::transmute(*(*(c as *const *const usize)).add(8)); | ||
| // a destination across a block boundary, in neither block's hot list | ||
| let mut mem = vec![0u8; 2 * BLOCK + size]; | ||
| let dst = ((mem.as_mut_ptr() as usize + BLOCK) & !(BLOCK - 1)) - size / 2; | ||
| hot_block(dst, true); | ||
| hot_block(dst + size - 1, true); | ||
| assert_eq!(into(c, dst as *mut u8, 0, 0, lin.as_ptr(), 64 * 4, 0), S_OK); | ||
| assert!(hot_block(dst, false) && hot_block(dst + size - 1, false), "both blocks it wrote are hot"); | ||
| release(c); | ||
| } | ||
| } | ||
|
|
||
| /// As the console's library answers (seen on it): RGBA8 256×256, full chain, 64KB_S. | ||
| #[test] | ||
| fn rgba8_64kb_s_layout() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mark_hotmakes a block hot without bumpingWALK_FOUND, but theXCL_LOOK_SKIPcheck (closed_before_last_look_in) usesWALK_FOUNDto know a block became hot after the last look began. With XCL_LOOK_SKIP=1, a look begins, the title runs CopyIntoSubresource during or right after it, then submits lists closed before that look in the same frame.walk_found < began, so the look is skipped and the copied texels miss the submit, the delay this PR fixes, even though the block was just made hot. Bumping WALK_FOUND inmark_hotwould close it.