Merge branch 'night/light' into local/next

This commit is contained in:
local committed 2026-11-25 06:21:08 -06:00
commit 02214f8c72
14 files changed
+1557 -246

No files matched your search

+23 -5
View File
@@ -114,7 +114,7 @@ struct List {
/// Ours, after the console layout: memory handed out by
/// [`allocate_upload`], kept until the list is reset; the host list the
/// calls record into (decision 0007), and the draw state the title set.
uploads: std::sync::Mutex<Vec<Vec<u8>>>,
uploads: std::sync::Mutex<Vec<Upload>>,
#[cfg(windows)]
host: Option<crate::host::HostList>,
#[cfg(windows)]
@@ -187,7 +187,7 @@ pub(crate) fn host_list<'a>(this: This) -> Option<&'a crate::host::HostList> {
#[cfg(windows)]
pub(crate) struct Detached {
host: crate::host::HostList,
_uploads: Vec<Vec<u8>>,
_uploads: Vec<Upload>,
_state: crate::draw::State,
}
@@ -1558,6 +1558,23 @@ extern "system" fn reset_x(this: This, allocator: This, pipeline: This, _flags:
reset(this, allocator, pipeline)
}
#[cfg(windows)]
use crate::upload::Upload;
/// The memory of [`allocate_upload`] where no host GPU reads it by address.
#[cfg(not(windows))]
struct Upload(Vec<u8>);
#[cfg(not(windows))]
impl Upload {
fn new(len: usize) -> Option<Upload> {
Some(Upload(vec![0; len]))
}
fn start(&mut self) -> *mut u8 {
self.0.as_mut_ptr()
}
}
/// Newer lists' 0x4a0 `(size, alignment) -> pointer`: memory the list
/// owns until it is reset, which the CPU writes and the GPU reads at the
/// same address; null on failure. The title's BVH builder puts
@@ -1571,13 +1588,14 @@ extern "system" fn allocate_upload(this: This, size: u64, alignment: u64) -> *mu
if this.is_null() || !align.is_power_of_two() {
return std::ptr::null_mut();
}
let mut block = vec![0u8; len];
let start = block.as_mut_ptr();
let Some(mut block) = Upload::new(len) else {
return std::ptr::null_mut();
};
let start = block.start();
// SAFETY: the offset is below `align`, so `size` bytes fit after it.
let at = unsafe { start.add(start.align_offset(align)) };
// SAFETY: the title passes one of our lists.
let uploads = unsafe { &(*this.cast::<List>()).uploads };
// Moving the vector keeps its heap block where it is.
uploads.lock().unwrap_or_else(|e| e.into_inner()).push(block);
at
}