Merge local/next (f61ecf3b) into night/cpu

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
localandClaude Opus 5.5 committed 2026-11-25 05:44:51 -06:00
commit db5a2be860
11 files changed
+813 -14

No files matched your search

+92
View File
@@ -3233,11 +3233,14 @@ fn late_line(frames: f64) {
}
pub(crate) mod aside;
pub(crate) mod awake;
mod card_steps;
pub(crate) mod indirects;
mod place;
mod send;
pub(crate) use send::{goes_as_words, words_under};
#[cfg(feature = "diagnostics")]
pub(crate) mod spans;
mod torn;
pub(crate) mod upcheck;
@@ -5117,11 +5120,17 @@ impl Host {
let prepared = std::time::Instant::now();
if late {
*submitted += 1;
#[cfg(feature = "diagnostics")]
if let Some([front, behind]) = self.span_lists() {
lists.insert(0, Some(front));
lists.push(Some(behind));
}
// SAFETY: closed lists; the fence is ours.
let signalled = unsafe {
self.queue.ExecuteCommandLists(&lists);
self.queue.Signal(&self.fence, *submitted)
};
awake::sent(&self.device);
self.card_sent();
if let Err(e) = signalled {
fail(format_args!("a submission sent ahead could not be followed by a signal ({e})"));
@@ -7686,6 +7695,8 @@ impl Meter {
late_line(frames);
crate::queue::behind_line(frames);
card_clock_line(frames, ms);
#[cfg(feature = "diagnostics")]
spans::line(frames);
crate::shadow::back_line(frames);
#[cfg(feature = "diagnostics")]
split_line(frames);
@@ -8273,6 +8284,87 @@ impl Host {
}
}
/// Whether buffers can lie in the card's memory and be mapped by the CPU
/// (`D3D12_HEAP_TYPE_GPU_UPLOAD`: a resizable BAR, and a system and driver
/// that offer it); logged once.
pub(crate) fn mapped_card_memory(&self) -> bool {
static THERE: OnceLock<bool> = OnceLock::new();
*THERE.get_or_init(|| {
let mut options = D3D12_FEATURE_DATA_D3D12_OPTIONS16::default();
// SAFETY: writes `options` of the given size.
let ok = unsafe {
self.device
.CheckFeatureSupport(
D3D12_FEATURE_D3D12_OPTIONS16,
(&raw mut options).cast(),
size_of_val(&options) as u32,
)
.is_ok()
};
let supported = ok && options.GPUUploadHeapSupported.as_bool();
tracing::info!(supported, "card memory the CPU maps");
supported
})
}
/// A buffer in the card's own memory that the CPU maps, shaders read and
/// (with `written`) may write. The CPU should only write it: a read of the
/// mapping crosses the bus a few bytes at a time.
pub(crate) fn mapped_card_buffer(&self, size: u64, written: bool) -> Option<(ID3D12Resource, *mut u8)> {
if !self.mapped_card_memory() {
return None;
}
MADE[4].fetch_add(1, Ordering::Relaxed);
MADE[5].fetch_add(size, Ordering::Relaxed);
let heap = D3D12_HEAP_PROPERTIES {
Type: D3D12_HEAP_TYPE_GPU_UPLOAD,
..Default::default()
};
let desc = D3D12_RESOURCE_DESC {
Dimension: D3D12_RESOURCE_DIMENSION_BUFFER,
Width: size.max(1),
Height: 1,
DepthOrArraySize: 1,
MipLevels: 1,
SampleDesc: DXGI_SAMPLE_DESC {
Count: 1,
Quality: 0,
},
Layout: D3D12_TEXTURE_LAYOUT_ROW_MAJOR,
Flags: if written {
D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS
} else {
D3D12_RESOURCE_FLAG_NONE
},
..Default::default()
};
let mut buffer: Option<ID3D12Resource> = None;
let mut data = std::ptr::null_mut();
// SAFETY: plain creation and mapping of a CPU-visible buffer.
let made = unsafe {
self.device
.CreateCommittedResource(
&heap,
D3D12_HEAP_FLAG_NONE,
&desc,
D3D12_RESOURCE_STATE_COMMON,
None,
&mut buffer,
)
.and_then(|()| {
let b = buffer.as_ref().ok_or_else(windows::core::Error::empty)?;
b.Map(0, None, Some(&mut data))
})
};
match made {
Ok(()) => Some((buffer?, data.cast())),
Err(e) => {
tracing::warn!(error = %e, size, "no buffer in card memory the CPU maps");
None
}
}
}
/// A device-local buffer shaders may write (unordered access) and indirect
/// execution may read, starting in the common state.
pub(crate) fn uav_buffer(&self, size: u64) -> Option<ID3D12Resource> {