Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion d3d12/crates/leonida-gpu/src/ambient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ mod tests {
/// The passes compile with the system's compiler and the host takes them.
#[test]
fn the_passes_build() {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
return;
};
make(&host.device, |bytes| host.uav_buffer(bytes)).expect("the passes");
Expand Down
2 changes: 1 addition & 1 deletion d3d12/crates/leonida-gpu/src/book.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ mod tests {
/// live, and not after.
#[test]
fn a_pooled_texture_and_its_block_are_in_the_book() {
let Some(host) = crate::host::host() else { return };
let Some(host) = crate::host::require_host() else { return };
FORCED.store(true, Ordering::Relaxed);
let desc = D3D12_RESOURCE_DESC {
Dimension: D3D12_RESOURCE_DIMENSION_TEXTURE2D,
Expand Down
2 changes: 1 addition & 1 deletion d3d12/crates/leonida-gpu/src/census.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ mod tests {
/// is counted, with the 64 KiB it takes, until the device destroys it.
#[test]
fn a_buffer_is_counted_while_the_device_holds_it() {
let Some(host) = crate::host::host() else { return };
let Some(host) = crate::host::require_host() else { return };
let Some(buffer) = host.uav_buffer(256) else { return };
let (what, bytes) = counted(&buffer).expect("counted when made");
assert_eq!(what, "card buffers");
Expand Down
4 changes: 2 additions & 2 deletions d3d12/crates/leonida-gpu/src/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2524,7 +2524,7 @@ mod tests {
#[test]
fn a_fresh_table_holds_the_half_views_past_its_range_starts() {
use leonida_shader::{ResourceType, RootType, UsedResource};
let Some(device) = crate::host::host() else {
let Some(device) = crate::host::require_host() else {
return; // no host GPU
};
let list = device.new_list().expect("a host list");
Expand Down Expand Up @@ -2588,7 +2588,7 @@ mod tests {
#[cfg(windows)]
#[test]
fn the_list_ahead_of_a_frame_is_for_a_heap_the_title_still_has() {
let Some(device) = crate::host::host() else {
let Some(device) = crate::host::require_host() else {
return; // no host GPU
};
let desc = HeapDesc {
Expand Down
14 changes: 7 additions & 7 deletions d3d12/crates/leonida-gpu/src/descriptor/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7041,7 +7041,7 @@ mod tests {
/// 2D textures and arrays have a neutral stand-in, others a null view.
#[test]
fn a_texture_not_there_yet_has_a_neutral_stand_in() {
let Some(host) = host() else { return };
let Some(host) = crate::host::require_host() else { return };
// SAFETY: plain heap creation and queries.
unsafe {
let heap: ID3D12DescriptorHeap = host
Expand Down Expand Up @@ -7216,7 +7216,7 @@ void BY_FLOATS_OR_NOT(uint3 id : SV_DispatchThreadID) {
const ELEMENTS: usize = 1 << 14;
const BYTES: u64 = ELEMENTS as u64 * 8;
const TITLES: u32 = 12; // R16G16B16A16_UINT
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
return; // no host GPU
};
let heap: ID3D12DescriptorHeap = {
Expand Down Expand Up @@ -7483,7 +7483,7 @@ void BY_FLOATS_OR_NOT(uint3 id : SV_DispatchThreadID) {
/// takes: the device, which such a view removes, stays.
#[test]
fn an_oversized_constant_buffer_view_leaves_the_device_alive() {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
return; // no host GPU
};
let Some(heap) = HostHeap::new(false, 4) else {
Expand Down Expand Up @@ -7511,7 +7511,7 @@ void BY_FLOATS_OR_NOT(uint3 id : SV_DispatchThreadID) {
/// A null 3D UAV made on the real device leaves it alive.
#[test]
fn null_3d_uav_is_accepted_by_the_device() {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
return; // no host GPU
};
let Some(heap) = HostHeap::new(false, 4) else {
Expand Down Expand Up @@ -7591,7 +7591,7 @@ void BY_FLOATS_OR_NOT(uint3 id : SV_DispatchThreadID) {
/// own.
#[test]
fn views_are_made_beside_the_heap_and_copied_in() {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
return; // no host GPU here
};
let Some(heap) = HostHeap::new(false, 4) else {
Expand Down Expand Up @@ -7700,7 +7700,7 @@ void BY_FLOATS_OR_NOT(uint3 id : SV_DispatchThreadID) {
/// brought up to date for it; another's is its buffer's.
#[test]
fn views_off_their_elements_get_a_copy_of_their_bytes() {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
return; // no host GPU here
};
let memory = vec![0u64; 1 << 13];
Expand Down Expand Up @@ -8752,7 +8752,7 @@ mod bake_flip_tests {
/// keeps the first record's key, so it does not show the new record.
#[test]
fn an_upload_cannot_publish_a_replacement_slot_record() {
let Some(host) = host() else { return };
let Some(host) = crate::host::require_host() else { return };
let heap = HostHeap::new(false, 4).unwrap();
let list = host.new_list().unwrap();
let record = |address| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ fn sub_dword_views_null_twins_and_recycled_raw_cbv_clears_bias() {
return;
}
const SIZE: u64 = 4096;
let Some(host) = host() else { return };
let Some(host) = crate::host::require_host() else { return };
let mut heap = HostHeap::new(false, 4).expect("a host view heap");
if heap.raw == 0 {
// Portable hosts (1,000,000-descriptor cap) still have room inside this test's small heap
Expand Down
2 changes: 1 addition & 1 deletion d3d12/crates/leonida-gpu/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ mod tests {
use windows::Win32::Graphics::Direct3D12::{
D3D12_FENCE_FLAG_NONE, ID3D12Device5, ID3D12Fence,
};
let Some(host) = crate::host::host() else {
let Some(host) = crate::host::require_host() else {
return; // no host GPU here
};
// SAFETY: plain calls on the host device and its fence.
Expand Down
4 changes: 2 additions & 2 deletions d3d12/crates/leonida-gpu/src/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7018,7 +7018,7 @@ mod batch_tests {
/// shader is bound to behind the pass is not, and the next batch begins with nothing.
#[test]
fn what_shaders_may_write_is_kept_since_the_pass() {
let Some(host) = crate::host::host() else {
let Some(host) = crate::host::require_host() else {
return;
};
let Ok(list) = host.new_list() else {
Expand Down Expand Up @@ -7257,7 +7257,7 @@ mod cache_tests {
/// A host list that continues the title's (`replay`) has nothing set.
#[test]
fn a_new_host_list_after_a_cut_has_nothing_cached() {
let Some(host) = crate::host::host() else {
let Some(host) = crate::host::require_host() else {
return; // no host GPU
};
let list = host.new_list().expect("a host list");
Expand Down
25 changes: 18 additions & 7 deletions d3d12/crates/leonida-gpu/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,17 @@ pub(crate) fn host() -> Option<&'static Host> {
.as_ref()
}

/// The host GPU, or a SKIP line and `None` when this machine has no D3D12
/// device: a test that needs one then returns, and the run says it did.
#[cfg(test)]
pub(crate) fn require_host() -> Option<&'static Host> {
let host = host();
if host.is_none() {
eprintln!("SKIP: no D3D12 device");
}
host
}

fn create() -> windows::core::Result<Host> {
// SAFETY: plain D3D12 object creation with valid descriptions.
unsafe {
Expand Down Expand Up @@ -5749,7 +5760,7 @@ mod late_tests {
fn a_late_texture_readback_blocks_a_following_cpu_copy() {
use super::{INFINITE, WHY_READ, WaitForSingleObject, blocked_by, host, read_backs};

let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
eprintln!("no D3D12 device; texture readback dependency not tested");
return;
};
Expand Down Expand Up @@ -10533,7 +10544,7 @@ mod scratch_address_tests {
/// chunk has a buffer to itself.
#[test]
fn a_lists_scratch_memory_is_at_its_buffers_address() {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
eprintln!("no D3D12 device; scratch addresses not tested");
return;
};
Expand Down Expand Up @@ -10577,7 +10588,7 @@ mod read_back_pool_tests {
/// when the list is reset is not kept.
#[test]
fn a_reset_lists_read_back_buffer_is_the_next_read_backs() {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
eprintln!("no D3D12 device; the read-back buffers' table not tested");
return;
};
Expand Down Expand Up @@ -10642,7 +10653,7 @@ mod batch_scratch_tests {
/// bytes, get a fill of their own.
#[test]
fn constant_buffers_with_the_same_bytes_share_one_fill_until_title_memory_is_written() {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
eprintln!("no D3D12 device; constant buffer fills not tested");
return;
};
Expand Down Expand Up @@ -10701,7 +10712,7 @@ mod batch_scratch_tests {
/// into it, closes and is reset again as any list.
#[test]
fn a_reset_takes_an_old_allocator_anew() {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
eprintln!("no D3D12 device; the allocator trim not tested");
return;
};
Expand Down Expand Up @@ -10738,7 +10749,7 @@ mod batch_scratch_tests {
#[test]
fn a_reset_list_gives_its_batch_scratch_buffers_back() {
use crate::indirect::batch::{JOBS, SLOT};
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
eprintln!("no D3D12 device; the table of batch scratch buffers not tested");
return;
};
Expand Down Expand Up @@ -15632,7 +15643,7 @@ mod gate_tests {
#[test]
#[ignore = "wants LEONIDA_LATE_WAIT=3 and a process of its own"]
fn a_list_behind_the_gate_reads_what_was_done_before_it_opened() {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
return;
};
assert!(late(), "set LEONIDA_LATE_WAIT=3");
Expand Down
2 changes: 1 addition & 1 deletion d3d12/crates/leonida-gpu/src/host/awake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ mod tests {
/// awake meanwhile; the thread ends when it is let go.
#[test]
fn mapped_card_memory_is_written_by_the_cpu_and_read_by_the_card() {
let Some(host) = crate::host::host() else {
let Some(host) = crate::host::require_host() else {
return;
};
let awake = start(&host.device, || true);
Expand Down
6 changes: 3 additions & 3 deletions d3d12/crates/leonida-gpu/src/host/card_steps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,7 @@ mod tests {
/// the buffers are usable in the lists that follow in the same call.
#[test]
fn the_card_copies_what_is_recorded() {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
return; // no host GPU
};
let (a, a_data) = host.shared_buffer(1 << 16).unwrap();
Expand Down Expand Up @@ -1644,7 +1644,7 @@ mod tests {
/// piece, and a level that cannot be gathered between them and behind.
#[test]
fn the_card_gathers_what_is_recorded() {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
return; // no host GPU
};
let Some(pass) = pass(host) else {
Expand Down Expand Up @@ -1729,7 +1729,7 @@ mod tests {
// under a flight's writes: the flights that declared them are waited
// for.
let write_watch = if std::env::var_os("TEST_UNWATCHED").is_some() { 0 } else { 0x20_0000 };
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
return;
};
assert!(relay_exact() && stage() == 2, "set LEONIDA_RELAY=2 LEONIDA_CARD_STEPS=2");
Expand Down
2 changes: 1 addition & 1 deletion d3d12/crates/leonida-gpu/src/host/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ mod tests {
#[test]
#[ignore]
fn small_buffers_cost() {
let Some(host) = super::host() else {
let Some(host) = crate::host::require_host() else {
return;
};
const N: usize = 1000;
Expand Down
2 changes: 1 addition & 1 deletion d3d12/crates/leonida-gpu/src/host/stamps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ mod tests {
/// PC's own counter.
#[test]
fn a_submissions_times_are_the_pcs() {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
return;
};
timeline_ready();
Expand Down
14 changes: 7 additions & 7 deletions d3d12/crates/leonida-gpu/src/host/upcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ mod tests {
#[test]
#[ignore = "wants LEONIDA_RELAY=2 LEONIDA_RELAY_COPY=1 and a process of its own"]
fn a_result_caught_in_between_is_put_right() {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
return;
};
let (title, start, shadow) = title(0x3333, false);
Expand Down Expand Up @@ -909,7 +909,7 @@ mod tests {
#[test]
#[ignore = "wants LEONIDA_RELAY=2 LEONIDA_RELAY_COPY=1 LEONIDA_UPCOPY_CHECK=1 and a process of its own"]
fn the_check_finds_an_undeclared_write_undone() {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
return;
};
assert!(on(), "set LEONIDA_UPCOPY_CHECK=1");
Expand Down Expand Up @@ -1022,7 +1022,7 @@ mod tests {
#[test]
#[ignore = "wants LEONIDA_RELAY=2 LEONIDA_RELAY_COPY=1 LEONIDA_PICKED_WRITES=2 LEONIDA_PICKED_MB=1 and a process of its own"]
fn writes_through_picked_views_come_back() {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
return;
};
assert!(crate::picked::lands(), "set LEONIDA_PICKED_WRITES=2");
Expand Down Expand Up @@ -1067,7 +1067,7 @@ mod tests {
/// card is busy meanwhile, so all three are prepared before the first
/// runs: each must read its own.
fn each_reads_its_own(len: usize, resource: usize, carded: bool) {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
return;
};
let (title, start, shadow) = title_of(resource, true, len);
Expand Down Expand Up @@ -1153,7 +1153,7 @@ mod tests {
/// between: every read sees what stands before it, and in the end title
/// memory and the copies hold the last of everything.
fn in_order(resource: usize, sizes: [usize; 3]) {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
return;
};
let buffers: Vec<_> = sizes.iter().enumerate().map(|(i, &n)| title_of(resource + i, i == 0, n)).collect();
Expand Down Expand Up @@ -1311,7 +1311,7 @@ mod tests {
#[test]
#[ignore = "wants LEONIDA_RELAY=2 LEONIDA_RELAY_COPY=1 and a process of its own"]
fn copy_draw_copy_draw() {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
return;
};
let (title, start, shadow) = title_of(0x9400, true, LEN);
Expand Down Expand Up @@ -1379,7 +1379,7 @@ mod tests {
#[test]
#[ignore = "wants LEONIDA_RELAY=2 LEONIDA_RELAY_COPY=1 and a process of its own"]
fn declared_writes_beside_the_titles_own_stay() {
let Some(host) = host() else {
let Some(host) = crate::host::require_host() else {
return;
};
for view in [false, true] {
Expand Down
10 changes: 5 additions & 5 deletions d3d12/crates/leonida-gpu/src/indirect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2800,7 +2800,7 @@ void main(uint3 g : SV_GroupID, uint i : SV_GroupIndex) {
/// the host device.
#[test]
fn host_list_reuses_and_grows_scratch_across_submissions() {
let Some(host) = super::host() else {
let Some(host) = crate::host::require_host() else {
return;
};
// What earlier tests left in the debug layer's queue, if it is on.
Expand Down Expand Up @@ -2983,7 +2983,7 @@ void main(uint3 g : SV_GroupID, uint i : SV_GroupIndex) {
/// small record still runs.
#[test]
fn host_list_budget_starts_empty_at_each_submission() {
let Some(host) = super::host() else {
let Some(host) = crate::host::require_host() else {
return;
};
let Ok(list) = host.new_list() else {
Expand Down Expand Up @@ -3169,7 +3169,7 @@ void main(uint3 g : SV_GroupID, uint i : SV_GroupIndex) {
/// diagnostics build) no barrier names a state the buffer is not in.
#[test]
fn host_list_window_executions_need_no_barrier_of_their_own() {
let Some(host) = super::host() else {
let Some(host) = crate::host::require_host() else {
return;
};
// What earlier tests left in the debug layer's queue, if it is on.
Expand Down Expand Up @@ -3822,7 +3822,7 @@ void main(uint3 g : SV_GroupID) {
/// the debug layer on no barrier names a state the buffer is not in.
#[test]
fn host_list_batches() {
let Some(host) = super::host() else {
let Some(host) = crate::host::require_host() else {
return;
};
let _ = host.log_messages();
Expand Down Expand Up @@ -3903,7 +3903,7 @@ void main() {
const WRITTEN: D3D12_RESOURCE_STATES = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
// Where the title has the records (32 bytes apart).
const TITLE: u64 = 0x10_0000;
let Some(host) = super::host() else {
let Some(host) = crate::host::require_host() else {
return;
};
let _ = host.log_messages();
Expand Down
Loading
Loading