diff --git a/AGENTS.md b/AGENTS.md index 6196083d4..d4b53541d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -145,7 +145,7 @@ The video crates' checks: ```sh ulimit -c 0 scripts/internal/gpu-locks.sh --all -- cargo nextest run --workspace --no-fail-fast \ - --features reims-vgpu-core/testkit,reims-vgpu/testkit,reims-vgpu/vulkan,reims-vgpu-c/vulkan + --features reims-vgpu-vulkan/testkit,reims-vgpu/testkit,reims-vgpu/vulkan,reims-vgpu-c/vulkan scripts/internal/gpu-locks.sh --all -- cargo nextest run -p reims-vgpu-video --run-ignored only -E 'test(/^vaapi::/)' # the VA-API host scripts/internal/gpu-locks.sh --all -- cargo nextest run -p reims-vgpu-video --run-ignored only -E 'test(/^nvidia::/)' # the NVIDIA host ``` diff --git a/Cargo.lock b/Cargo.lock index 3eda91935..036808d77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -448,7 +448,6 @@ dependencies = [ "objc2-foundation", "objc2-metal", "parking_lot", - "reims-vgpu-core", "reims-vgpu-graphics", "reims-vgpu-video", "reims-vgpu-vulkan", @@ -467,21 +466,11 @@ dependencies = [ "objc2-foundation", "parking_lot", "reims-vgpu", - "reims-vgpu-core", "reims-vgpu-graphics", + "reims-vgpu-vulkan", "tikv-jemallocator", ] -[[package]] -name = "reims-vgpu-core" -version = "0.1.0" -dependencies = [ - "log", - "lzma-rs", - "parking_lot", - "zerocopy", -] - [[package]] name = "reims-vgpu-graphics" version = "0.1.0" @@ -516,6 +505,7 @@ dependencies = [ "ash", "libc", "log", + "lzma-rs", "mach2", "metal2vulkan", "metal2vulkan-runtime", @@ -523,8 +513,10 @@ dependencies = [ "objc2-foundation", "objc2-io-surface", "objc2-metal", - "reims-vgpu-core", + "parking_lot", + "reims-vgpu-vulkan", "sha2 0.10.9", + "zerocopy", ] [[package]] @@ -542,7 +534,6 @@ dependencies = [ "objc2-foundation", "objc2-metal", "objc2-quartz-core", - "reims-vgpu-core", "reims-vgpu-vulkan", "sdl3-sys", ] diff --git a/Cargo.toml b/Cargo.toml index d257855aa..5a645f551 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,6 @@ [workspace] resolver = "3" members = [ - "crates/reims-vgpu-core", "crates/reims-vgpu-window", "crates/reims-vgpu", "crates/reims-vgpu-c", @@ -21,7 +20,6 @@ publish = false license = "GPL-2.0-or-later OR LGPL-3.0-or-later" [workspace.dependencies] -reims-vgpu-core = { path = "crates/reims-vgpu-core" } # Without their default features: each member that wants SDL3's macOS window asks for it # (`macos-sdl`), so `reims-vgpu-c`'s default decides whether the library has it. reims-vgpu-window = { path = "crates/reims-vgpu-window", default-features = false } diff --git a/crates/reims-ctl/src/cli.rs b/crates/reims-ctl/src/cli.rs index f9788f6f9..3d9a8ea31 100644 --- a/crates/reims-ctl/src/cli.rs +++ b/crates/reims-ctl/src/cli.rs @@ -355,7 +355,7 @@ pub struct SetArgs { pub gpu: Option, #[arg(long, num_args = 0..=1, default_missing_value = "true")] pub logs: Option, - /// REIMS_VGPU_LOG's filter, such as info or warn,reims_vgpu_core=debug + /// REIMS_VGPU_LOG's filter, such as info or warn,reims_vgpu_vulkan::core=debug #[arg(long)] pub log_level: Option, #[arg(long, num_args = 0..=1, default_missing_value = "true")] diff --git a/crates/reims-vgpu-c/Cargo.toml b/crates/reims-vgpu-c/Cargo.toml index 59c49cec8..73e097886 100644 --- a/crates/reims-vgpu-c/Cargo.toml +++ b/crates/reims-vgpu-c/Cargo.toml @@ -27,7 +27,7 @@ reims-vgpu.workspace = true reims-vgpu-graphics.workspace = true # The death of a NULL handle, and the mark of the library's threads (the unit tests' testkit # platform stands where VulkanPlatform stands in the product). -reims-vgpu-core.workspace = true +reims-vgpu-vulkan.workspace = true # A refusal of a memory map's files. log.workspace = true # `fstat` and the host's page size, for the files behind a memory map's ranges. @@ -43,7 +43,7 @@ objc2.workspace = true [dev-dependencies] reims-vgpu = { workspace = true, features = ["testkit"] } -reims-vgpu-core = { workspace = true, features = ["testkit"] } +reims-vgpu-vulkan = { workspace = true, features = ["testkit"] } # The window tests' recorder. parking_lot.workspace = true diff --git a/crates/reims-vgpu-c/src/ffi.rs b/crates/reims-vgpu-c/src/ffi.rs index e063ddf92..0fa03619d 100644 --- a/crates/reims-vgpu-c/src/ffi.rs +++ b/crates/reims-vgpu-c/src/ffi.rs @@ -15,8 +15,8 @@ //! Linux. The host's function-pointer types stay `extern "C-unwind"`, since both are sound only //! around an ABI that unwinds. -use reims_vgpu_core::raise::death::{DeathId, fatal}; -use reims_vgpu_core::rt::enter_ours; +use reims_vgpu_vulkan::core::raise::death::{DeathId, fatal}; +use reims_vgpu_vulkan::core::rt::enter_ours; mod catch; diff --git a/crates/reims-vgpu-c/src/ffi/tests.rs b/crates/reims-vgpu-c/src/ffi/tests.rs index 0f0085b75..2b258fb45 100644 --- a/crates/reims-vgpu-c/src/ffi/tests.rs +++ b/crates/reims-vgpu-c/src/ffi/tests.rs @@ -3,8 +3,8 @@ use std::os::unix::process::ExitStatusExt as _; use std::process::Command; -use reims_vgpu_core::raise::death::{DeathKind, DeathSite}; -use reims_vgpu_core::rt::is_our_thread; +use reims_vgpu_vulkan::core::raise::death::{DeathKind, DeathSite}; +use reims_vgpu_vulkan::core::rt::is_our_thread; use super::*; diff --git a/crates/reims-vgpu-c/src/ffi/tests/linux.rs b/crates/reims-vgpu-c/src/ffi/tests/linux.rs index d6fcd1aa7..c5eae1a11 100644 --- a/crates/reims-vgpu-c/src/ffi/tests/linux.rs +++ b/crates/reims-vgpu-c/src/ffi/tests/linux.rs @@ -1,7 +1,7 @@ //! The catch on Linux: a Rust unwind out of the host's code that no panic hook ended first ends //! the process at the call. -use reims_vgpu_core::testkit::capture::catch_death; +use reims_vgpu_vulkan::core::testkit::capture::catch_death; use super::*; diff --git a/crates/reims-vgpu-c/src/ffi/tests/macos.rs b/crates/reims-vgpu-c/src/ffi/tests/macos.rs index 4f1b34eef..229776829 100644 --- a/crates/reims-vgpu-c/src/ffi/tests/macos.rs +++ b/crates/reims-vgpu-c/src/ffi/tests/macos.rs @@ -5,7 +5,7 @@ use objc2::exception::{self, Exception}; use objc2::rc::Retained; use objc2::runtime::{AnyObject, NSObject}; use objc2_foundation::{NSException, NSString}; -use reims_vgpu_core::testkit::capture::catch_death; +use reims_vgpu_vulkan::core::testkit::capture::catch_death; use super::*; diff --git a/crates/reims-vgpu-c/src/lib.rs b/crates/reims-vgpu-c/src/lib.rs index 39ccda41c..b5da45991 100644 --- a/crates/reims-vgpu-c/src/lib.rs +++ b/crates/reims-vgpu-c/src/lib.rs @@ -57,11 +57,11 @@ static ALLOCATOR: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; pub(crate) type Plat = reims_vgpu::VulkanPlatform; /// The platform every handle is made on: core's testkit platform in this crate's unit tests. #[cfg(test)] -pub(crate) type Plat = reims_vgpu_core::testkit::FakePlatform; +pub(crate) type Plat = reims_vgpu_vulkan::core::testkit::FakePlatform; /// Ends the process: `call` was given a NULL handle it cannot answer without one. pub(crate) fn null_handle(call: &'static str) -> ! { - use reims_vgpu_core::raise::death::{DeathId, DeathKind, fatal}; + use reims_vgpu_vulkan::core::raise::death::{DeathId, DeathKind, fatal}; fatal(DeathId::Platform { kind: DeathKind::NullDeref, call, diff --git a/crates/reims-vgpu-core/Cargo.toml b/crates/reims-vgpu-core/Cargo.toml deleted file mode 100644 index 11c792e77..000000000 --- a/crates/reims-vgpu-core/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "reims-vgpu-core" -description = "What the graphics device and its platform share, generic over the platform; links no Apple framework" -version.workspace = true -edition.workspace = true -rust-version.workspace = true -publish.workspace = true -license.workspace = true - -[features] -# core::testkit and testkit::capture outside this crate's own unit tests (architecture 13.2). -testkit = ["dep:lzma-rs"] - -# Architecture 2.2: no objc2, block2, dispatch2, mach2 or libc here. -[dependencies] -parking_lot.workspace = true -zerocopy.workspace = true -log.workspace = true -# testkit::metal_answers: the recorded answers too long for text, in xz files. -lzma-rs = { workspace = true, optional = true } - -[dev-dependencies] -lzma-rs.workspace = true - -[lints] -workspace = true diff --git a/crates/reims-vgpu-vulkan/Cargo.toml b/crates/reims-vgpu-vulkan/Cargo.toml index 7a829cdd9..7a71ace6c 100644 --- a/crates/reims-vgpu-vulkan/Cargo.toml +++ b/crates/reims-vgpu-vulkan/Cargo.toml @@ -7,8 +7,16 @@ rust-version.workspace = true publish.workspace = true license.workspace = true +[features] +# core::testkit and testkit::capture outside this crate's own unit tests (architecture 13.2). +testkit = ["dep:lzma-rs"] + [dependencies] -reims-vgpu-core.workspace = true +# core (`core`): its locks (`core::sync`), and the guest's physical ranges as bytes (`core::host`). +parking_lot.workspace = true +zerocopy.workspace = true +# core's testkit::metal_answers: the recorded answers too long for text, in xz files. +lzma-rs = { workspace = true, optional = true } metal2vulkan-runtime.workspace = true metal2vulkan.workspace = true # The debug lines that time the runtime's compiles (gpu/timing.rs), through core's logger. @@ -39,7 +47,11 @@ libc.workspace = true sha2.workspace = true [dev-dependencies] -reims-vgpu-core = { workspace = true, features = ["testkit"] } +# core's testkit for the integration tests (`tests/`), which link the library as other +# crates do. +reims-vgpu-vulkan = { path = ".", features = ["testkit"] } +# core's testkit in the unit tests, compiled under cfg(test). +lzma-rs.workspace = true [lints] workspace = true diff --git a/crates/reims-vgpu-vulkan/src/answer.rs b/crates/reims-vgpu-vulkan/src/answer.rs index 17913b584..97f06072d 100644 --- a/crates/reims-vgpu-vulkan/src/answer.rs +++ b/crates/reims-vgpu-vulkan/src/answer.rs @@ -128,11 +128,11 @@ use std::cell::{Cell, RefCell}; use std::ptr::NonNull; +use crate::core::platform::types::NsErrorText; +use crate::core::raise::death::{DeathId, DeathKind, fatal_with_detail}; +use crate::core::raise::{OnFault, Raise, RaiseResult}; use metal2vulkan_runtime as rt; use metal2vulkan_runtime::Error; -use reims_vgpu_core::platform::types::NsErrorText; -use reims_vgpu_core::raise::death::{DeathId, DeathKind, fatal_with_detail}; -use reims_vgpu_core::raise::{OnFault, Raise, RaiseResult}; pub mod census; pub mod native; @@ -1921,8 +1921,8 @@ pub fn trace_degradations() -> bool { } /// The kinds the trace saw, which the runtime announces once without it. -static TRACED_KINDS: reims_vgpu_core::sync::Mutex> = - reims_vgpu_core::sync::Mutex::new(Vec::new()); +static TRACED_KINDS: crate::core::sync::Mutex> = + crate::core::sync::Mutex::new(Vec::new()); /// The runtime's message sink (`DeviceOptions::messages`, [`crate::platform`]): a degradation /// of [`DIES`] is relayed and counted, or in strict mode kept for the call here it was announced @@ -1940,10 +1940,10 @@ pub fn notice(message: &rt::DebugMessage) { if UNHEARD.with(Cell::get) { return; } - if trace_degradations() && reims_vgpu_core::trace::on() { + if trace_degradations() && crate::core::trace::on() { let kind = notice.degradation; // deg: an occurrence of a degradation, its code - reims_vgpu_core::trace::event_text("deg", &[], kind.code()); + crate::core::trace::event_text("deg", &[], kind.code()); // A kind announced once without the trace goes on only at its first occurrence. if !DIES.contains(&kind) && !HEARD.contains(&kind) { let mut seen = TRACED_KINDS.lock(); @@ -2014,8 +2014,8 @@ fn hear(kind: rt::Degradation) { /// The degradations not of [`DIES`] the runtime announced in this process, in order, which /// [`notice`] relays and a test reads. #[cfg(test)] -pub(crate) static RELAYED: reims_vgpu_core::sync::Mutex> = - reims_vgpu_core::sync::Mutex::new(Vec::new()); +pub(crate) static RELAYED: crate::core::sync::Mutex> = + crate::core::sync::Mutex::new(Vec::new()); /// The least severity the sink hears of the messages that are no degradation /// (`MessageSink::with_least_severity`): `Verbose` where the log takes this module's debug lines, @@ -2147,8 +2147,8 @@ pub fn refused(sel: &'static str, e: &Error) -> ! { /// The line of the last death [`dies`] made in this process, which a test reads: the test /// capture takes a death before its line is written. #[cfg(test)] -pub(crate) static LAST_LINE: reims_vgpu_core::sync::Mutex> = - reims_vgpu_core::sync::Mutex::new(None); +pub(crate) static LAST_LINE: crate::core::sync::Mutex> = + crate::core::sync::Mutex::new(None); /// The death at `sel` of [`refused`], [`metal_aborts`] and [`unrepresentable`], its line /// `line`. @@ -2494,7 +2494,7 @@ pub fn relays_gap(e: &Error) -> bool { /// writing a line on stderr naming the refusal and `descriptor` ([`refusal_describing`]). The /// creator then answers nil, a pipeline or library creator with [`error_text`] as its /// `NSError`, and the relay is noted for core on the creator's thread -/// ([`reims_vgpu_core::platform::device::note_relayed_gap`]), which faults the work that names a +/// ([`crate::core::platform::device::note_relayed_gap`]), which faults the work that names a /// function so refused where Metal would end the process at the nil one create later. `false` in /// strict mode and for every other refusal, which the creator decides as before: a death at /// `sel`. @@ -2502,7 +2502,7 @@ pub fn relay_gap(sel: &'static str, e: &Error, descriptor: Option<&str>) -> bool if !relays_gap(e) { return false; } - reims_vgpu_core::platform::device::note_relayed_gap(); + crate::core::platform::device::note_relayed_gap(); if counted_first(Inexact::RefusedCreate) { let line = format!( "reims-vgpu: {sel}: {}; answered nil, relayed ({}), the first of its kind: \ @@ -2576,9 +2576,9 @@ pub fn hang() -> ! { pub(crate) fn dies_of( kind: rt::Degradation, call: impl FnOnce() -> T, -) -> reims_vgpu_core::raise::death::DeathSite { +) -> crate::core::raise::death::DeathSite { *LAST_LINE.lock() = None; - let Err(site) = reims_vgpu_core::testkit::capture::catch_death(call) else { + let Err(site) = crate::core::testkit::capture::catch_death(call) else { panic!("it did not die, where {} dies", kind.code()); }; let line = LAST_LINE.lock().take().unwrap_or_default(); @@ -2593,10 +2593,10 @@ pub(crate) fn dies_of( #[cfg(test)] mod tests { use super::*; + use crate::core::platform::device::relaying_gaps; + use crate::core::raise::{Origin, RaiseId}; + use crate::core::testkit::capture::catch_death; use metal2vulkan_runtime::{Invalid, Problem, RuntimeGap}; - use reims_vgpu_core::platform::device::relaying_gaps; - use reims_vgpu_core::raise::{Origin, RaiseId}; - use reims_vgpu_core::testkit::capture::catch_death; fn invalid() -> Error { Error::Invalid(Invalid::new("fill_buffer", Problem::StorageMode)) @@ -3175,7 +3175,7 @@ mod tests { relaxed(|| inexact("sel:", Inexact::HeapLayout, || "a value".into())); assert_eq!(counted(), before + 2); *LAST_LINE.lock() = None; - let site = reims_vgpu_core::testkit::capture::catch_death(|| { + let site = crate::core::testkit::capture::catch_death(|| { inexact("sel:", Inexact::HeapLayout, || "a value".into()); }) .unwrap_err(); @@ -3236,10 +3236,10 @@ mod tests { /// `two_plane_xr10_blits_metal_was_not_measured_at_die`) #[test] fn a_call_that_unwinds_lets_its_notice_go() { - use reims_vgpu_core::platform::Platform as _; - use reims_vgpu_core::platform::device::GpuDevice as _; - use reims_vgpu_core::platform::values::TextureDesc; - use reims_vgpu_core::raise::OnFault; + use crate::core::platform::Platform as _; + use crate::core::platform::device::GpuDevice as _; + use crate::core::platform::values::TextureDesc; + use crate::core::raise::OnFault; let d = crate::gpu::device::tests::dev(); let desc = crate::platform::tests::platform().texture_descriptor(&TextureDesc { pixel_format: 550, @@ -3287,10 +3287,10 @@ mod tests { /// The copy of `a_call_that_unwinds_lets_its_notice_go` announces `TwoPlaneTextureCopy` #[test] fn a_kind_of_dies_is_relayed_and_counted_by_default() { - use reims_vgpu_core::platform::Platform as _; - use reims_vgpu_core::platform::device::GpuDevice as _; - use reims_vgpu_core::platform::values::TextureDesc; - use reims_vgpu_core::raise::OnFault; + use crate::core::platform::Platform as _; + use crate::core::platform::device::GpuDevice as _; + use crate::core::platform::values::TextureDesc; + use crate::core::raise::OnFault; let kind = rt::Degradation::TwoPlaneTextureCopy; let counted = || { (relayed_counts().into_iter()) diff --git a/crates/reims-vgpu-vulkan/src/answer/census.rs b/crates/reims-vgpu-vulkan/src/answer/census.rs index 5f6bb4f8c..b3df6dbaa 100644 --- a/crates/reims-vgpu-vulkan/src/answer/census.rs +++ b/crates/reims-vgpu-vulkan/src/answer/census.rs @@ -35,9 +35,9 @@ use std::path::{Path, PathBuf}; use std::sync::{Once, OnceLock}; use std::time::Duration; +use crate::core::platform::os::{Clock as _, Deadline}; +use crate::core::sync::{Condvar, Mutex}; use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::os::{Clock as _, Deadline}; -use reims_vgpu_core::sync::{Condvar, Mutex}; use super::native::{self, Placement}; diff --git a/crates/reims-vgpu-vulkan/src/api.rs b/crates/reims-vgpu-vulkan/src/api.rs index 0f5a3a8fd..5d9b3fcc4 100644 --- a/crates/reims-vgpu-vulkan/src/api.rs +++ b/crates/reims-vgpu-vulkan/src/api.rs @@ -1,8 +1,8 @@ //! What the Rust API (`reims-vgpu`) asks of this platform beyond core's `Platform`: a frame //! target's pixels ([`read_pixels`]). +use crate::core::num::ToU64; use metal2vulkan_runtime as rt; -use reims_vgpu_core::num::ToU64; use crate::answer::{get, plain}; use crate::gpu::resource::VulkanTexture; @@ -23,8 +23,8 @@ pub fn read_pixels(texture: &VulkanTexture, dst: &mut [u8], bytes_per_row: usize #[cfg(test)] mod tests { + use crate::core::platform::Handle as _; use metal2vulkan::metal::PixelFormat; - use reims_vgpu_core::platform::Handle as _; use super::*; use crate::gpu::device::tests::dev; diff --git a/crates/reims-vgpu-vulkan/src/awake.rs b/crates/reims-vgpu-vulkan/src/awake.rs index 4606a50cf..0183d7d6b 100644 --- a/crates/reims-vgpu-vulkan/src/awake.rs +++ b/crates/reims-vgpu-vulkan/src/awake.rs @@ -72,10 +72,10 @@ use std::sync::{Arc, OnceLock}; use std::thread::Thread; use std::time::Duration; +use crate::core::platform::os::clock::{Clock as _, Deadline, MonoTime}; +use crate::core::sync::{Mutex, MutexGuard}; use ash::vk; use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::os::clock::{Clock as _, Deadline, MonoTime}; -use reims_vgpu_core::sync::{Mutex, MutexGuard}; /// How long after the guest's last GPU work the GPU is kept awake. pub(crate) const AWAKE_FOR: Duration = Duration::from_secs(5 * 60); diff --git a/crates/reims-vgpu-core/src/lib.rs b/crates/reims-vgpu-vulkan/src/core.rs similarity index 88% rename from crates/reims-vgpu-core/src/lib.rs rename to crates/reims-vgpu-vulkan/src/core.rs index 554f664a5..9f98c97b4 100644 --- a/crates/reims-vgpu-core/src/lib.rs +++ b/crates/reims-vgpu-vulkan/src/core.rs @@ -3,10 +3,10 @@ //! deaths, the guest's RAM as the host maps it, and the testkit's fake platform, which the tests //! run in the Vulkan platform's place. Links no Apple framework. -// The crate root denies `unsafe_code` (D43): `forbid` cannot be lowered by the per-module +// The module denies `unsafe_code` (D43): `forbid` cannot be lowered by the per-module // `#![allow(unsafe_code)]` that 17.3 grants `testkit/guest_ram.rs` (E0453). #![deny(unsafe_code)] -// The crate's lint set. Tests are exempt: clippy.toml lets them unwrap, index and panic, +// The module's lint set. Tests are exempt: clippy.toml lets them unwrap, index and panic, // and the conversion and division lints apply outside cfg(test) only, as clippy has no in-tests // switch for them. `arithmetic_side_effects` is denied only in the modules guest data flows // through (their own attributes). diff --git a/crates/reims-vgpu-core/src/collections.rs b/crates/reims-vgpu-vulkan/src/core/collections.rs similarity index 100% rename from crates/reims-vgpu-core/src/collections.rs rename to crates/reims-vgpu-vulkan/src/core/collections.rs diff --git a/crates/reims-vgpu-core/src/collections/hasher.rs b/crates/reims-vgpu-vulkan/src/core/collections/hasher.rs similarity index 99% rename from crates/reims-vgpu-core/src/collections/hasher.rs rename to crates/reims-vgpu-vulkan/src/core/collections/hasher.rs index 4d3b0b92b..b9d69f9e2 100644 --- a/crates/reims-vgpu-core/src/collections/hasher.rs +++ b/crates/reims-vgpu-vulkan/src/core/collections/hasher.rs @@ -9,7 +9,7 @@ use std::hash::{BuildHasherDefault, Hasher}; -use crate::num::ToU64; +use crate::core::num::ToU64; /// The odd multiplier, a 64-bit constant with its bits spread (the one `rustc-hash` 2 uses). const K: u64 = 0xf135_7aea_2e62_a9c5; diff --git a/crates/reims-vgpu-core/src/collections/lookup.rs b/crates/reims-vgpu-vulkan/src/core/collections/lookup.rs similarity index 100% rename from crates/reims-vgpu-core/src/collections/lookup.rs rename to crates/reims-vgpu-vulkan/src/core/collections/lookup.rs diff --git a/crates/reims-vgpu-core/src/display.rs b/crates/reims-vgpu-vulkan/src/core/display.rs similarity index 82% rename from crates/reims-vgpu-core/src/display.rs rename to crates/reims-vgpu-vulkan/src/core/display.rs index 6cfa261f8..c23225232 100644 --- a/crates/reims-vgpu-core/src/display.rs +++ b/crates/reims-vgpu-vulkan/src/core/display.rs @@ -5,7 +5,7 @@ pub mod pipeline; use std::fmt; -use crate::raise::death::DeathId; +use crate::core::raise::death::DeathId; /// Where a display's pipelines end the process. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] @@ -32,14 +32,14 @@ impl DeathKind { } /// The kind of death. - pub(crate) const fn class(self) -> crate::raise::death::DeathKind { - crate::raise::death::DeathKind::Assert + pub(crate) const fn class(self) -> crate::core::raise::death::DeathKind { + crate::core::raise::death::DeathKind::Assert } /// The site a death of this kind names (tests). #[cfg(test)] - pub(crate) fn site(self) -> crate::raise::death::DeathSite { - crate::raise::death::DeathId::from(self).site() + pub(crate) fn site(self) -> crate::core::raise::death::DeathSite { + crate::core::raise::death::DeathId::from(self).site() } } diff --git a/crates/reims-vgpu-core/src/display/pipeline.rs b/crates/reims-vgpu-vulkan/src/core/display/pipeline.rs similarity index 95% rename from crates/reims-vgpu-core/src/display/pipeline.rs rename to crates/reims-vgpu-vulkan/src/core/display/pipeline.rs index fcdc5ca08..92f9bd5c5 100644 --- a/crates/reims-vgpu-core/src/display/pipeline.rs +++ b/crates/reims-vgpu-vulkan/src/core/display/pipeline.rs @@ -1,13 +1,13 @@ //! A display's render pipelines, by the target's pixel format and whether there is a gamma //! table. The table is looked up and set under its mutex, never iterated. -use crate::collections::LookupMap; -use crate::display::DeathKind; -use crate::platform::device::GpuDevice; -use crate::platform::resource::Library; -use crate::platform::values::RenderPipelineDesc; -use crate::platform::{Handle, Platform}; -use crate::raise::OnFault; +use crate::core::collections::LookupMap; +use crate::core::display::DeathKind; +use crate::core::platform::device::GpuDevice; +use crate::core::platform::resource::Library; +use crate::core::platform::values::RenderPipelineDesc; +use crate::core::platform::{Handle, Platform}; +use crate::core::raise::OnFault; /// The name of the vertex function in the platform's shader library. pub const VERTEX_FUNCTION: &str = "displayPresentVertex"; @@ -124,9 +124,9 @@ impl Drop for DisplayPipelineCache

{ #[cfg(test)] mod tests { use super::*; - use crate::testkit::calllog::Arg; - use crate::testkit::capture::catch_death; - use crate::testkit::{FakePlatform, Step}; + use crate::core::testkit::calllog::Arg; + use crate::core::testkit::capture::catch_death; + use crate::core::testkit::{FakePlatform, Step}; fn cache(p: &FakePlatform) -> DisplayPipelineCache { DisplayPipelineCache::new(p.device()).unwrap() @@ -207,7 +207,7 @@ mod tests { assert_eq!( r.err().map(|s| (s.kind, s.file, s.line)), Some(( - crate::raise::DeathKind::UncaughtObjc, + crate::core::raise::DeathKind::UncaughtObjc, "newLibraryWithSource:options:error:", 0 )) diff --git a/crates/reims-vgpu-core/src/host.rs b/crates/reims-vgpu-vulkan/src/core/host.rs similarity index 91% rename from crates/reims-vgpu-core/src/host.rs rename to crates/reims-vgpu-vulkan/src/core/host.rs index 0c9bcd454..31dc6e4e4 100644 --- a/crates/reims-vgpu-core/src/host.rs +++ b/crates/reims-vgpu-vulkan/src/core/host.rs @@ -2,7 +2,7 @@ //! (`queue`). //! //! These are the consumer's (QEMU's) values, not platform APIs: the platform is what core calls -//! on Apple's frameworks, the host is who called core. Every item is at `crate::host::…`. +//! on Apple's frameworks, the host is who called core. Every item is at `crate::core::host::…`. mod queue; mod types; diff --git a/crates/reims-vgpu-core/src/host/queue.rs b/crates/reims-vgpu-vulkan/src/core/host/queue.rs similarity index 94% rename from crates/reims-vgpu-core/src/host/queue.rs rename to crates/reims-vgpu-vulkan/src/core/host/queue.rs index a141fc811..f5900afd3 100644 --- a/crates/reims-vgpu-core/src/host/queue.rs +++ b/crates/reims-vgpu-vulkan/src/core/host/queue.rs @@ -5,7 +5,7 @@ use std::sync::Arc; -use crate::rt::queue::Executor; +use crate::core::rt::queue::Executor; /// The queue a display's calls into the host run on (the display descriptor's `queue`): each /// call of a display handler is submitted to it, and the newFrame source targets it. Jobs run one @@ -26,7 +26,7 @@ mod tests { fn host_queue_upcasts() { struct Inline; impl Executor for Inline { - fn exec_async(&self, job: crate::rt::Job) { + fn exec_async(&self, job: crate::core::rt::Job) { job() } } diff --git a/crates/reims-vgpu-core/src/host/types.rs b/crates/reims-vgpu-vulkan/src/core/host/types.rs similarity index 100% rename from crates/reims-vgpu-core/src/host/types.rs rename to crates/reims-vgpu-vulkan/src/core/host/types.rs diff --git a/crates/reims-vgpu-core/src/logging.rs b/crates/reims-vgpu-vulkan/src/core/logging.rs similarity index 98% rename from crates/reims-vgpu-core/src/logging.rs rename to crates/reims-vgpu-vulkan/src/core/logging.rs index 676a5ab0d..d4de66cdc 100644 --- a/crates/reims-vgpu-core/src/logging.rs +++ b/crates/reims-vgpu-vulkan/src/core/logging.rs @@ -28,7 +28,7 @@ use std::sync::{Arc, OnceLock}; use log::{Level, LevelFilter, Log, Metadata, Record}; -use crate::sync::Mutex; +use crate::core::sync::Mutex; /// The environment variable that turns the stderr logger on, and holds its filter. pub const ENV_VAR: &str = "REIMS_VGPU_LOG"; @@ -410,7 +410,7 @@ mod tests { (Some("info,reims_vgpu::work=debug"), true), ] { let out = child( - "logging::tests::the_process_names_a_target_only_by_the_variables_pair", + "core::logging::tests::the_process_names_a_target_only_by_the_variables_pair", env, ); assert!(out.status.success(), "{env:?}: {out:?}"); @@ -561,7 +561,7 @@ mod tests { return; } let out = child( - "logging::tests::the_process_logger_writes_stderr_until_a_hook_takes_over", + "core::logging::tests::the_process_logger_writes_stderr_until_a_hook_takes_over", Some("info,reims_vgpu::graphics=debug"), ); assert!(out.status.success(), "{out:?}"); @@ -608,7 +608,7 @@ mod tests { return; } let out = child( - "logging::tests::the_process_logger_is_silent_without_the_variable", + "core::logging::tests::the_process_logger_is_silent_without_the_variable", None, ); assert!(out.status.success(), "{out:?}"); @@ -643,7 +643,7 @@ mod tests { return; } let out = child( - "logging::tests::the_process_logger_yields_to_the_hosts", + "core::logging::tests::the_process_logger_yields_to_the_hosts", Some("trace"), ); assert!(out.status.success(), "{out:?}"); diff --git a/crates/reims-vgpu-core/src/memory.rs b/crates/reims-vgpu-vulkan/src/core/memory.rs similarity index 97% rename from crates/reims-vgpu-core/src/memory.rs rename to crates/reims-vgpu-vulkan/src/core/memory.rs index 041f6829c..275fabb51 100644 --- a/crates/reims-vgpu-core/src/memory.rs +++ b/crates/reims-vgpu-vulkan/src/core/memory.rs @@ -32,8 +32,8 @@ pub mod mapping; use std::fmt; -use crate::raise::DeathId; -use crate::raise::death::{self, DeathSite}; +use crate::core::raise::DeathId; +use crate::core::raise::death::{self, DeathSite}; /// The granule a mapping's length is whole multiples of ([`map::MemoryMap::new_range_mapping`]): /// 16 KiB, 4 KiB in an x86-64 build. diff --git a/crates/reims-vgpu-core/src/memory/descriptor.rs b/crates/reims-vgpu-vulkan/src/core/memory/descriptor.rs similarity index 98% rename from crates/reims-vgpu-core/src/memory/descriptor.rs rename to crates/reims-vgpu-vulkan/src/core/memory/descriptor.rs index 7b46b840c..dd19f4617 100644 --- a/crates/reims-vgpu-core/src/memory/descriptor.rs +++ b/crates/reims-vgpu-vulkan/src/core/memory/descriptor.rs @@ -1,6 +1,6 @@ //! The host's description of guest memory: its ranges, as the host added them. -use crate::host::HostPtr; +use crate::core::host::HostPtr; /// One range of guest physical memory and where the host mapped it. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] diff --git a/crates/reims-vgpu-core/src/memory/map.rs b/crates/reims-vgpu-vulkan/src/core/memory/map.rs similarity index 96% rename from crates/reims-vgpu-core/src/memory/map.rs rename to crates/reims-vgpu-vulkan/src/core/memory/map.rs index 127a7538c..be21b2ec6 100644 --- a/crates/reims-vgpu-core/src/memory/map.rs +++ b/crates/reims-vgpu-vulkan/src/core/memory/map.rs @@ -4,13 +4,13 @@ use std::num::NonZeroU64; use std::sync::Arc; -use crate::host::{HostPtr, PhysRange}; -use crate::memory::descriptor::MemoryMapDescriptor; -use crate::memory::mapping::{Mapping, Teardown}; -use crate::memory::{DeathKind, PAGE_SIZE}; -use crate::num::{ToU64, ToUsize}; -use crate::platform::Platform; -use crate::platform::os::vm::{HostVm, VmProt}; +use crate::core::host::{HostPtr, PhysRange}; +use crate::core::memory::descriptor::MemoryMapDescriptor; +use crate::core::memory::mapping::{Mapping, Teardown}; +use crate::core::memory::{DeathKind, PAGE_SIZE}; +use crate::core::num::{ToU64, ToUsize}; +use crate::core::platform::Platform; +use crate::core::platform::os::vm::{HostVm, VmProt}; /// One range of the map: `{start, start + length, length, host pointer}`. The field names are /// ours. @@ -441,13 +441,13 @@ impl MemoryMap

{ #[cfg(test)] mod tests { use super::*; - use crate::memory::descriptor::GuestPhysicalRange; - use crate::platform::os::vm::KernReturn; - use crate::testkit::calllog::{Arg, Call}; - use crate::testkit::capture::catch_death; - use crate::testkit::guest_ram::GuestRam; - use crate::testkit::platform::FakePlatform; - use crate::testkit::script::Step; + use crate::core::memory::descriptor::GuestPhysicalRange; + use crate::core::platform::os::vm::KernReturn; + use crate::core::testkit::calllog::{Arg, Call}; + use crate::core::testkit::capture::catch_death; + use crate::core::testkit::guest_ram::GuestRam; + use crate::core::testkit::platform::FakePlatform; + use crate::core::testkit::script::Step; type Map = MemoryMap; @@ -460,11 +460,11 @@ mod tests { } /// The memory area's lines `logs` took since its last take, in order. - fn memory_lines(logs: &crate::testkit::logs::Capture) -> Vec { + fn memory_lines(logs: &crate::core::testkit::logs::Capture) -> Vec { logs.take() .into_iter() .filter(|(_, target, _)| { - target.starts_with(concat!(env!("CARGO_CRATE_NAME"), "::memory")) + target.starts_with(concat!(env!("CARGO_CRATE_NAME"), "::core::memory")) }) .map(|(_, _, message)| message) .collect() @@ -582,7 +582,7 @@ mod tests { gpr(0x4000, 0x8000, fake_host(1)), // would be an intersection after the sort gpr(u64::MAX, 1, fake_host(2)), ]); - let logs = crate::testkit::logs::capture(); + let logs = crate::core::testkit::logs::capture(); assert!(Map::new(p.clone(), &d).is_none()); assert_eq!( memory_lines(&logs), @@ -609,7 +609,7 @@ mod tests { gpr(0x8000, 0x4000, fake_host(1)), gpr(0x4000, 0x8000, fake_host(0)), ]); - let logs = crate::testkit::logs::capture(); + let logs = crate::core::testkit::logs::capture(); assert!(Map::new(p.clone(), &d).is_none()); assert_eq!(memory_lines(&logs), vec![INTERSECTION.to_owned()]); } @@ -659,7 +659,7 @@ mod tests { gpr(0x8000, 0x8000, fake_host(1)), gpr(0x8000, 0x4000, fake_host(0)), ]); - let logs = crate::testkit::logs::capture(); + let logs = crate::core::testkit::logs::capture(); assert!(Map::new(p.clone(), &d).is_none()); assert_eq!(memory_lines(&logs), vec![INTERSECTION.to_owned()]); } @@ -751,7 +751,7 @@ mod tests { fn a_straddle_is_refused_with_a_log() { let p = plat(); let m = map(&p); - let logs = crate::testkit::logs::capture(); + let logs = crate::core::testkit::logs::capture(); assert!(m.virtual_address_for_physical(0x7ff0, 0x20).is_null()); assert_eq!( memory_lines(&logs), @@ -767,7 +767,7 @@ mod tests { fn overflow_is_refused_with_a_log() { let p = plat(); let m = map(&p); - let logs = crate::testkit::logs::capture(); + let logs = crate::core::testkit::logs::capture(); assert!(m.virtual_address_for_physical(0x4000, u64::MAX).is_null()); assert_eq!( memory_lines(&logs), @@ -779,7 +779,7 @@ mod tests { fn outside_every_range_and_empty_ranges_are_null_silently() { let p = plat(); let m = map(&p); - let logs = crate::testkit::logs::capture(); + let logs = crate::core::testkit::logs::capture(); assert!(m.virtual_address_for_physical(0x0, 1).is_null()); assert!(m.virtual_address_for_physical(0xc000, 1).is_null()); assert!(m.virtual_address_for_physical(0x10000, 0).is_null()); @@ -843,7 +843,7 @@ mod tests { let (_ram, m) = ram_map(&p, &[(0x4000, 0x8000)]); p.script() .push("mach_vm_allocate", Step::value(KernReturn(3))); - let logs = crate::testkit::logs::capture(); + let logs = crate::core::testkit::logs::capture(); assert!(m.new_range_mapping(&[pr(0x4000, PAGE)], PAGE, 0).is_none()); assert_eq!(sels(&p), vec!["mach_vm_allocate"]); assert!(memory_lines(&logs).is_empty()); @@ -1160,7 +1160,7 @@ mod tests { mod map_memory_at_virtual_address { use super::*; - use crate::platform::os::vm::HostVm; + use crate::core::platform::os::vm::HostVm; fn region(p: &FakePlatform, len: u64) -> HostPtr { p.fake_vm().unlogged().allocate_anywhere(len).unwrap() @@ -1213,7 +1213,7 @@ mod tests { let p = plat(); let (_ram, m) = ram_map(&p, &[(0x4000, 0x4000)]); let dst = region(&p, PAGE); - let logs = crate::testkit::logs::capture(); + let logs = crate::core::testkit::logs::capture(); assert!(!m.map_memory_at_virtual_address(dst, &[pr(0, 0)], false)); assert!(vm_calls(&p).is_empty()); assert!(memory_lines(&logs).is_empty()); @@ -1224,7 +1224,7 @@ mod tests { let p = plat(); let (_ram, m) = ram_map(&p, &[(0x4000, 0x4000)]); let dst = region(&p, PAGE); - let logs = crate::testkit::logs::capture(); + let logs = crate::core::testkit::logs::capture(); assert!(!m.map_memory_at_virtual_address( dst, &[pr(0x4000, PAGE), pr(0x4000, u64::MAX)], @@ -1247,7 +1247,7 @@ mod tests { let p = plat(); let (_ram, m) = ram_map(&p, &[(0x4000, 0x4000)]); let dst = region(&p, PAGE); - let logs = crate::testkit::logs::capture(); + let logs = crate::core::testkit::logs::capture(); assert!(!m.map_memory_at_virtual_address(dst, &[pr(u64::MAX, 1)], false)); assert_eq!( memory_lines(&logs), @@ -1264,7 +1264,7 @@ mod tests { let (_ram, m) = ram_map(&p, &[(0x4000, 0x4000)]); let dst = region(&p, PAGE); p.script().push("mach_vm_remap", Step::value(KernReturn(1))); - let logs = crate::testkit::logs::capture(); + let logs = crate::core::testkit::logs::capture(); assert!(!m.map_memory_at_virtual_address(dst, &[pr(0x4000, PAGE)], false)); assert_eq!(memory_lines(&logs), vec![NOT_REMAPPED.to_owned()]); assert_eq!(sels(&p), vec!["mach_vm_remap"]); @@ -1276,7 +1276,7 @@ mod tests { let (_ram, m) = ram_map(&p, &[(0x4000, 0x4000), (0x8000, 0x4000)]); let dst = region(&p, 2 * PAGE); p.script().push("mach_vm_remap", Step::value(KernReturn(1))); - let logs = crate::testkit::logs::capture(); + let logs = crate::core::testkit::logs::capture(); assert!(!m.map_memory_at_virtual_address(dst, &[pr(0x4000, 2 * PAGE)], false)); assert_eq!(memory_lines(&logs), vec![NOT_REMAPPED.to_owned()]); } @@ -1290,7 +1290,7 @@ mod tests { let p = plat(); let (_ram, m) = ram_map(&p, &[(0x4000, 0x4000)]); let dst = region(&p, 2 * PAGE); - let logs = crate::testkit::logs::capture(); + let logs = crate::core::testkit::logs::capture(); assert!(!m.map_memory_at_virtual_address(dst, &[pr(0x4000, 2 * PAGE)], false)); assert_eq!( memory_lines(&logs), @@ -1316,7 +1316,7 @@ mod tests { let dst = region(&p, PAGE); p.script() .push("mach_vm_protect", Step::value(KernReturn(-1))); - let logs = crate::testkit::logs::capture(); + let logs = crate::core::testkit::logs::capture(); assert!(!m.map_memory_at_virtual_address(dst, &[pr(0x4000, PAGE)], false)); // `kr` is an `int`, printed in hex as its bits. assert_eq!( diff --git a/crates/reims-vgpu-core/src/memory/mapping.rs b/crates/reims-vgpu-vulkan/src/core/memory/mapping.rs similarity index 95% rename from crates/reims-vgpu-core/src/memory/mapping.rs rename to crates/reims-vgpu-vulkan/src/core/memory/mapping.rs index 18a4def6b..f49127aa7 100644 --- a/crates/reims-vgpu-core/src/memory/mapping.rs +++ b/crates/reims-vgpu-vulkan/src/core/memory/mapping.rs @@ -2,8 +2,8 @@ use std::sync::Arc; -use crate::host::HostPtr; -use crate::platform::Platform; +use crate::core::host::HostPtr; +use crate::core::platform::Platform; /// What a mapping's last release does. pub enum Teardown { @@ -83,8 +83,8 @@ impl Drop for Mapping

{ #[cfg(test)] mod tests { use super::*; - use crate::testkit::calllog::Arg; - use crate::testkit::platform::FakePlatform; + use crate::core::testkit::calllog::Arg; + use crate::core::testkit::platform::FakePlatform; mod plain { use super::*; diff --git a/crates/reims-vgpu-core/src/num.rs b/crates/reims-vgpu-vulkan/src/core/num.rs similarity index 100% rename from crates/reims-vgpu-core/src/num.rs rename to crates/reims-vgpu-vulkan/src/core/num.rs diff --git a/crates/reims-vgpu-core/src/platform.rs b/crates/reims-vgpu-vulkan/src/core/platform.rs similarity index 98% rename from crates/reims-vgpu-core/src/platform.rs rename to crates/reims-vgpu-vulkan/src/core/platform.rs index bf03606ab..c6819213d 100644 --- a/crates/reims-vgpu-core/src/platform.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform.rs @@ -21,9 +21,9 @@ pub mod resource; pub mod types; pub mod values; -use crate::raise::OnFault; -pub use crate::raise::Raise; -pub use crate::raise::RaiseResult; +use crate::core::raise::OnFault; +pub use crate::core::raise::Raise; +pub use crate::core::raise::RaiseResult; pub use event::EventRef; pub use host_range::HostRange; pub use types::NilDefault; @@ -196,7 +196,7 @@ macro_rules! nil_send { ($recv:expr, $method:ident ( $($arg:expr),* $(,)? )) => { match &$recv { Some(r) => r.$method($($arg),*), - None => $crate::platform::NilDefault::nil_default(), + None => $crate::core::platform::NilDefault::nil_default(), } }; } diff --git a/crates/reims-vgpu-core/src/platform/blit.rs b/crates/reims-vgpu-vulkan/src/core/platform/blit.rs similarity index 99% rename from crates/reims-vgpu-core/src/platform/blit.rs rename to crates/reims-vgpu-vulkan/src/core/platform/blit.rs index 01fbb09e4..338febf2f 100644 --- a/crates/reims-vgpu-core/src/platform/blit.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform/blit.rs @@ -16,7 +16,7 @@ use std::ops::Range; use super::host_range::HostRange; use super::types::{ClearColor, MtlOrigin, MtlRegion, MtlSize, NsRange}; use super::{Handle, Platform}; -use crate::raise::{OnFault, RaiseResult}; +use crate::core::raise::{OnFault, RaiseResult}; /// An `id` core passes to `synchronizeResource:`, `useResources:count:usage:[stages:]` /// and `memoryBarrierWithResources:count:`. diff --git a/crates/reims-vgpu-core/src/platform/caps.rs b/crates/reims-vgpu-vulkan/src/core/platform/caps.rs similarity index 98% rename from crates/reims-vgpu-core/src/platform/caps.rs rename to crates/reims-vgpu-vulkan/src/core/platform/caps.rs index 78a5dff46..82148019e 100644 --- a/crates/reims-vgpu-core/src/platform/caps.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform/caps.rs @@ -7,7 +7,7 @@ //! its accessor raises it again at the site that uses it, with the same identity and origin. use super::types::{MtlSize, SizeAndAlign}; -use crate::raise::{OnFault, RaiseResult}; +use crate::core::raise::{OnFault, RaiseResult}; /// The sample counts core asks `supportsTextureSampleCount:` about, in order. pub const SAMPLE_COUNTS: [u64; 4] = [1, 2, 4, 8]; @@ -327,8 +327,8 @@ impl DeviceCaps { #[cfg(test)] mod tests { use super::*; - use crate::raise::Raise; - use crate::testkit::impls::device::fake_caps; + use crate::core::raise::Raise; + use crate::core::testkit::impls::device::fake_caps; /// A raise kept in the caps is raised again where it is asked: the caller's under a handler, /// and a death with none (the alignment is asked only with none); a kept answer is the @@ -352,14 +352,14 @@ mod tests { align: 0x4000 }) ); - let death = crate::testkit::capture::catch_death(|| { + let death = crate::core::testkit::capture::catch_death(|| { let _ = caps.min_linear_alignment_bgra8(); }); assert_eq!( death.map_err(|d| d.file), Err("minimumLinearTextureAlignmentForPixelFormat:") ); - let death = crate::testkit::capture::catch_death(|| { + let death = crate::core::testkit::capture::catch_death(|| { let _ = caps.heap_buffer_page_private(OnFault::Die); }); assert!(death.is_err()); diff --git a/crates/reims-vgpu-core/src/platform/command.rs b/crates/reims-vgpu-vulkan/src/core/platform/command.rs similarity index 96% rename from crates/reims-vgpu-core/src/platform/command.rs rename to crates/reims-vgpu-vulkan/src/core/platform/command.rs index 2bbe3be14..cb8958d54 100644 --- a/crates/reims-vgpu-core/src/platform/command.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform/command.rs @@ -4,7 +4,7 @@ use super::event::EventRef; use super::types::{CommandBufferStatus, NsErrorText}; use super::values::ComputePassDesc; use super::{Handle, Platform}; -use crate::raise::{OnFault, RaiseResult}; +use crate::core::raise::{OnFault, RaiseResult}; /// What a completed handler learns of its buffer: core's handlers read `status`, `error` and the /// GPU times of the buffer they were added to, on Metal's completion thread. The platform reads @@ -23,7 +23,7 @@ pub struct CompletedInfo { /// The domain of the error a command buffer completes with where the platform's read of it, as /// its completed handler ran, died in the refusal scope the handler's registration carried -/// ([`crate::raise::refusals::carry`]): the platform failed it there, where outside every scope +/// ([`crate::core::raise::refusals::carry`]): the platform failed it there, where outside every scope /// the death ends the process. Not Metal's: only the graphics lane's handlers see it. pub const REFUSED_DOMAIN: &str = "reims-vgpu.refused"; @@ -64,7 +64,7 @@ pub fn inside_commit() -> bool { impl CompletedInfo { /// What a completed handler learns of a command buffer whose read the platform refused /// ([`REFUSED_DOMAIN`]): status `Error`, and an internal error naming the refusal. - pub fn refused(refusal: &crate::raise::refusals::Refusal) -> CompletedInfo { + pub fn refused(refusal: &crate::core::raise::refusals::Refusal) -> CompletedInfo { CompletedInfo { status: CommandBufferStatus::ERROR, error: Some(NsErrorText { @@ -100,12 +100,12 @@ impl CompletedInfo { } /// Runs completed handler `block` with what `read` finds of its command buffer, in the scope -/// `carried` names, the one the handler's registration carried ([`crate::raise::refusals::carry`]): +/// `carried` names, the one the handler's registration carried ([`crate::core::raise::refusals::carry`]): /// a death in `read` hands `block` [`CompletedInfo::refused`] instead, and a death in `block` ends /// only `block`, each logged. Outside every scope `read` and `block` run plainly, one after the /// other, as they always did. pub fn run_completed( - carried: crate::raise::refusals::Carried, + carried: crate::core::raise::refusals::Carried, read: impl FnOnce() -> CompletedInfo, block: CompletedHandler, ) { @@ -126,7 +126,7 @@ pub fn run_completed( /// A completed handler (`addCompletedHandler:`'s block). Runs once, on a Metal thread (4.2 item 6). /// Where it is added inside a refusal scope, the platform runs its read of the buffer and the -/// handler in that scope ([`crate::raise::refusals::Carried`]): a death in the read hands the +/// handler in that scope ([`crate::core::raise::refusals::Carried`]): a death in the read hands the /// handler [`CompletedInfo::refused`], and a death in the handler ends only the handler. pub type CompletedHandler = Box; diff --git a/crates/reims-vgpu-core/src/platform/compute.rs b/crates/reims-vgpu-vulkan/src/core/platform/compute.rs similarity index 99% rename from crates/reims-vgpu-core/src/platform/compute.rs rename to crates/reims-vgpu-vulkan/src/core/platform/compute.rs index 24105d388..caf2d6e4a 100644 --- a/crates/reims-vgpu-core/src/platform/compute.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform/compute.rs @@ -15,7 +15,7 @@ use super::blit::ResourceRef; use super::types::{MtlRegion, MtlSize, NsRange}; use super::{Handle, Platform}; -use crate::raise::{OnFault, RaiseResult}; +use crate::core::raise::{OnFault, RaiseResult}; /// One `MTLComputeCommandEncoder` command. /// diff --git a/crates/reims-vgpu-core/src/platform/descriptor.rs b/crates/reims-vgpu-vulkan/src/core/platform/descriptor.rs similarity index 99% rename from crates/reims-vgpu-core/src/platform/descriptor.rs rename to crates/reims-vgpu-vulkan/src/core/platform/descriptor.rs index 1b71e4dee..51040331b 100644 --- a/crates/reims-vgpu-core/src/platform/descriptor.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform/descriptor.rs @@ -17,7 +17,7 @@ use super::values::{ AttachmentState, ColorAttachmentSet, DepthAttachmentSet, PassSet, StencilAttachmentSet, }; use super::{Handle, Platform}; -use crate::raise::{OnFault, RaiseResult}; +use crate::core::raise::{OnFault, RaiseResult}; /// `MTLTextureDescriptor` (with its private selectors), made from a `TextureDesc` value /// (`Platform::texture_descriptor`) or by the class method diff --git a/crates/reims-vgpu-core/src/platform/device.rs b/crates/reims-vgpu-vulkan/src/core/platform/device.rs similarity index 99% rename from crates/reims-vgpu-core/src/platform/device.rs rename to crates/reims-vgpu-vulkan/src/core/platform/device.rs index 3035040fe..e5996780f 100644 --- a/crates/reims-vgpu-core/src/platform/device.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform/device.rs @@ -25,7 +25,7 @@ use super::values::{ PagesPlane, RenderPipelineDesc, SamplerDesc, }; use super::{Handle, Platform}; -use crate::raise::{OnFault, RaiseResult}; +use crate::core::raise::{OnFault, RaiseResult}; /// A deallocator Metal calls once when a no-copy buffer is freed (the /// `newBufferWithBytesNoCopy:…deallocator:` block). `None` is a nil block. diff --git a/crates/reims-vgpu-core/src/platform/event.rs b/crates/reims-vgpu-vulkan/src/core/platform/event.rs similarity index 98% rename from crates/reims-vgpu-core/src/platform/event.rs rename to crates/reims-vgpu-vulkan/src/core/platform/event.rs index d8a219b01..507cb9b66 100644 --- a/crates/reims-vgpu-core/src/platform/event.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform/event.rs @@ -1,7 +1,7 @@ //! Platform trait: `SharedEvent`; the event kinds a command buffer waits on or signals. use super::{Handle, Platform}; -use crate::raise::RaiseResult; +use crate::core::raise::RaiseResult; /// `id`. pub trait SharedEvent: Handle { diff --git a/crates/reims-vgpu-core/src/platform/host_range.rs b/crates/reims-vgpu-vulkan/src/core/platform/host_range.rs similarity index 97% rename from crates/reims-vgpu-core/src/platform/host_range.rs rename to crates/reims-vgpu-vulkan/src/core/platform/host_range.rs index e949b162a..88cb12da1 100644 --- a/crates/reims-vgpu-core/src/platform/host_range.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform/host_range.rs @@ -7,8 +7,8 @@ use std::marker::PhantomData; -use crate::host::HostPtr; -use crate::num::ToU64; +use crate::core::host::HostPtr; +use crate::core::num::ToU64; /// `len` bytes of host memory at `ptr`, mapped for `'a`. /// diff --git a/crates/reims-vgpu-core/src/platform/icb.rs b/crates/reims-vgpu-vulkan/src/core/platform/icb.rs similarity index 99% rename from crates/reims-vgpu-core/src/platform/icb.rs rename to crates/reims-vgpu-vulkan/src/core/platform/icb.rs index 627bdf38d..f1388abbb 100644 --- a/crates/reims-vgpu-core/src/platform/icb.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform/icb.rs @@ -12,7 +12,7 @@ use super::types::{MtlRegion, MtlSize}; use super::{Handle, Platform}; -use crate::raise::RaiseResult; +use crate::core::raise::RaiseResult; /// `MTLIndirectCommandBuffer` (with `MTLIndirectCommandBufferSPI`). pub trait IndirectCommandBuffer: Handle { diff --git a/crates/reims-vgpu-core/src/platform/os.rs b/crates/reims-vgpu-vulkan/src/core/platform/os.rs similarity index 100% rename from crates/reims-vgpu-core/src/platform/os.rs rename to crates/reims-vgpu-vulkan/src/core/platform/os.rs diff --git a/crates/reims-vgpu-core/src/platform/os/autorelease.rs b/crates/reims-vgpu-vulkan/src/core/platform/os/autorelease.rs similarity index 97% rename from crates/reims-vgpu-core/src/platform/os/autorelease.rs rename to crates/reims-vgpu-vulkan/src/core/platform/os/autorelease.rs index 26ea9dd51..f53c47c51 100644 --- a/crates/reims-vgpu-core/src/platform/os/autorelease.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform/os/autorelease.rs @@ -11,7 +11,7 @@ use std::ffi::c_void; use std::sync::OnceLock; -use crate::platform::Platform; +use crate::core::platform::Platform; /// The platform's real autorelease pool. #[derive(Debug, Clone, Copy)] diff --git a/crates/reims-vgpu-core/src/platform/os/clock.rs b/crates/reims-vgpu-vulkan/src/core/platform/os/clock.rs similarity index 99% rename from crates/reims-vgpu-core/src/platform/os/clock.rs rename to crates/reims-vgpu-vulkan/src/core/platform/os/clock.rs index 94a8ccca8..12afa902a 100644 --- a/crates/reims-vgpu-core/src/platform/os/clock.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform/os/clock.rs @@ -3,7 +3,7 @@ use std::time::Duration; -use crate::sync::{Condvar, MutexGuard}; +use crate::core::sync::{Condvar, MutexGuard}; /// A point on the monotonic clock, in nanoseconds (name is ours: architecture 4.5 names the type; /// the device's 2 s stamp-wait report waits on it). The clock is libc++'s diff --git a/crates/reims-vgpu-core/src/platform/os/surface.rs b/crates/reims-vgpu-vulkan/src/core/platform/os/surface.rs similarity index 98% rename from crates/reims-vgpu-core/src/platform/os/surface.rs rename to crates/reims-vgpu-vulkan/src/core/platform/os/surface.rs index 4a0f055c0..eee972f00 100644 --- a/crates/reims-vgpu-core/src/platform/os/surface.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform/os/surface.rs @@ -5,8 +5,8 @@ //! reference: not `Clone`, `.clone_ref()` is a `CFRetain` core makes, and `Drop` is `CFRelease` //! (D6). -use crate::host::{HostPtr, PhysicalMemoryRange}; -use crate::platform::{Handle, Platform}; +use crate::core::host::{HostPtr, PhysicalMemoryRange}; +use crate::core::platform::{Handle, Platform}; use super::vm::KernReturn; diff --git a/crates/reims-vgpu-core/src/platform/os/threads.rs b/crates/reims-vgpu-vulkan/src/core/platform/os/threads.rs similarity index 98% rename from crates/reims-vgpu-core/src/platform/os/threads.rs rename to crates/reims-vgpu-vulkan/src/core/platform/os/threads.rs index ab73f315d..fb71b4932 100644 --- a/crates/reims-vgpu-core/src/platform/os/threads.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform/os/threads.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use super::{Clock, Deadline}; -use crate::sync::{Condvar, MutexGuard}; +use crate::core::sync::{Condvar, MutexGuard}; /// How core gets its threads (architecture 7.1). Core creates no OS thread that runs /// Objective-C itself: the platform does, so that in production no Rust unwind handler sits at diff --git a/crates/reims-vgpu-core/src/platform/os/vm.rs b/crates/reims-vgpu-vulkan/src/core/platform/os/vm.rs similarity index 99% rename from crates/reims-vgpu-core/src/platform/os/vm.rs rename to crates/reims-vgpu-vulkan/src/core/platform/os/vm.rs index 7a37f5a13..b2cb720bc 100644 --- a/crates/reims-vgpu-core/src/platform/os/vm.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform/os/vm.rs @@ -5,7 +5,7 @@ use std::ops::BitOr; -use crate::host::HostPtr; +use crate::core::host::HostPtr; /// A host virtual address (`mach_vm_address_t`). Host addresses are [`HostPtr`]s throughout core, /// so that `guest` is the only place that turns one into a pointer. diff --git a/crates/reims-vgpu-core/src/platform/rate_map.rs b/crates/reims-vgpu-vulkan/src/core/platform/rate_map.rs similarity index 97% rename from crates/reims-vgpu-core/src/platform/rate_map.rs rename to crates/reims-vgpu-vulkan/src/core/platform/rate_map.rs index a58b4639d..a891a1acd 100644 --- a/crates/reims-vgpu-core/src/platform/rate_map.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform/rate_map.rs @@ -11,8 +11,8 @@ use super::types::{MtlCoordinate2D, MtlSize, SizeAndAlign}; use super::{Handle, Platform}; -use crate::host::HostPtr; -use crate::raise::{OnFault, RaiseResult}; +use crate::core::host::HostPtr; +use crate::core::raise::{OnFault, RaiseResult}; /// `MTLRasterizationRateMap` (with `MTLRasterizationRateMapSPI`). pub trait RateMap: Handle { diff --git a/crates/reims-vgpu-core/src/platform/render.rs b/crates/reims-vgpu-vulkan/src/core/platform/render.rs similarity index 99% rename from crates/reims-vgpu-core/src/platform/render.rs rename to crates/reims-vgpu-vulkan/src/core/platform/render.rs index fbdc0fe42..b6e965cfe 100644 --- a/crates/reims-vgpu-core/src/platform/render.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform/render.rs @@ -19,7 +19,7 @@ use super::types::{ MtlRegion, MtlScissorRect, MtlSize, MtlViewport, NsRange, VertexAmplificationViewMapping, }; use super::{Handle, Platform}; -use crate::raise::{OnFault, RaiseResult}; +use crate::core::raise::{OnFault, RaiseResult}; /// One `MTLRenderCommandEncoder` command. /// diff --git a/crates/reims-vgpu-core/src/platform/resource.rs b/crates/reims-vgpu-vulkan/src/core/platform/resource.rs similarity index 99% rename from crates/reims-vgpu-core/src/platform/resource.rs rename to crates/reims-vgpu-vulkan/src/core/platform/resource.rs index 7ce6b2260..e52d791b8 100644 --- a/crates/reims-vgpu-core/src/platform/resource.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform/resource.rs @@ -14,8 +14,8 @@ use super::host_range::HostRange; use super::types::{MtlRegion, MtlSize, NsRange, Swizzle}; use super::values::SurfacePlane; use super::{Handle, Platform}; -use crate::host::HostPtr; -use crate::raise::{OnFault, RaiseResult}; +use crate::core::host::HostPtr; +use crate::core::raise::{OnFault, RaiseResult}; /// Architecture 4.1's name for the sampler state's bound (`type SamplerState: StateObject`). pub use self::SamplerState as StateObject; diff --git a/crates/reims-vgpu-core/src/platform/types.rs b/crates/reims-vgpu-vulkan/src/core/platform/types.rs similarity index 99% rename from crates/reims-vgpu-core/src/platform/types.rs rename to crates/reims-vgpu-vulkan/src/core/platform/types.rs index babd6d0b6..441810a0f 100644 --- a/crates/reims-vgpu-core/src/platform/types.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform/types.rs @@ -402,7 +402,7 @@ impl NilDefault for Result { } } -impl NilDefault for crate::raise::RaiseResult { +impl NilDefault for crate::core::raise::RaiseResult { fn nil_default() -> Self { Ok(T::nil_default()) } @@ -446,7 +446,7 @@ nil_default_is_default!( PixelFormatInfo, TextureLevelInfo, CommandBufferStatus, - crate::host::HostPtr, + crate::core::host::HostPtr, ); const _: () = assert!(size_of::() == 24); @@ -469,7 +469,7 @@ const _: () = assert!(std::mem::offset_of!(TextureLevelInfo, bytes_per_row) == 0 #[cfg(test)] mod tests { use super::*; - use crate::raise::RaiseResult; + use crate::core::raise::RaiseResult; /// The `Make` constructors put each argument in its field #[test] diff --git a/crates/reims-vgpu-core/src/platform/values.rs b/crates/reims-vgpu-vulkan/src/core/platform/values.rs similarity index 97% rename from crates/reims-vgpu-core/src/platform/values.rs rename to crates/reims-vgpu-vulkan/src/core/platform/values.rs index b15307e29..92fdcf34f 100644 --- a/crates/reims-vgpu-core/src/platform/values.rs +++ b/crates/reims-vgpu-vulkan/src/core/platform/values.rs @@ -12,7 +12,7 @@ use std::fmt; use super::host_range::HostRange; use super::types::{ClearColor, MtlSize, Swizzle}; use super::{Handle, ObjId, Platform}; -use crate::host::HostPtr; +use crate::core::host::HostPtr; /// One storage property of a buffer or heap descriptor. They alias one another in Metal /// (`resourceOptions` holds the storage and hazard-tracking modes), so they apply in list order @@ -786,7 +786,7 @@ impl Default for TextureDesc { /// Where plane `plane` of an IOSurface lies in a buffer that stands for the surface, its first /// byte the surface's base address, and what a texture over it reads of the surface besides -/// ([`crate::platform::resource::Buffer::new_texture_over_surface_plane`], Metal's +/// ([`crate::core::platform::resource::Buffer::new_texture_over_surface_plane`], Metal's /// `newTextureWithDescriptor:iosurface:plane:` over such a buffer, which reads these from the /// `IOSurfaceRef`). #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] @@ -834,7 +834,7 @@ pub struct SurfaceFacts { } /// One plane of an IOSurface as its pages hold it, for -/// [`crate::platform::device::GpuDevice::surface_pages_in_place`]: where its rows of elements lie +/// [`crate::core::platform::device::GpuDevice::surface_pages_in_place`]: where its rows of elements lie /// from the surface's first byte. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] pub struct PagesPlane { @@ -857,7 +857,7 @@ impl PagesPlane { } /// What a device answers of textures over an IOSurface's own pages -/// ([`crate::platform::device::GpuDevice::surface_pages_in_place`]). +/// ([`crate::core::platform::device::GpuDevice::surface_pages_in_place`]). #[derive(Debug, Clone, PartialEq, Eq)] pub enum PagesInPlace { /// Every texture over them, for any access, lies in place in the pages. @@ -1040,17 +1040,17 @@ set_struct_impls!(StencilAttachmentSet { texture, resolve_texture } { #[cfg(test)] mod tests { use super::*; - use crate::platform::command::{CommandBuffer, CommandQueue}; - use crate::platform::descriptor::{RenderPassDescriptor, TextureDescriptor}; - use crate::platform::device::GpuDevice; - use crate::platform::rate_map::RateMapDescriptor; - use crate::platform::resource::{ + use crate::core::platform::command::{CommandBuffer, CommandQueue}; + use crate::core::platform::descriptor::{RenderPassDescriptor, TextureDescriptor}; + use crate::core::platform::device::GpuDevice; + use crate::core::platform::rate_map::RateMapDescriptor; + use crate::core::platform::resource::{ Buffer, GpuResource, Heap, Library, RenderPipeline, SamplerState, }; - use crate::raise::OnFault; + use crate::core::raise::OnFault; - use crate::testkit::calllog::Arg; - use crate::testkit::{FakePlatform, Step}; + use crate::core::testkit::calllog::Arg; + use crate::core::testkit::{FakePlatform, Step}; /// The selectors sent since `m`. fn sels(p: &FakePlatform, m: u64) -> Vec<&'static str> { @@ -1084,8 +1084,11 @@ mod tests { assert_eq!(sels(&p, m), ["setResourceOptions:"]); assert_eq!((d.rotation(), d.storage_mode()), (2, 0)); let t = p.device().new_texture(OnFault::Die, &d).unwrap().unwrap(); - assert_eq!(crate::platform::resource::Texture::resource_index(&t), 5); - assert_eq!(crate::platform::resource::Texture::width(&t), 8); + assert_eq!( + crate::core::platform::resource::Texture::resource_index(&t), + 5 + ); + assert_eq!(crate::core::platform::resource::Texture::width(&t), 8); } /// The rate-map value, then the typed layer reads @@ -1149,7 +1152,7 @@ mod tests { assert_eq!( pass.color( 2, - crate::testkit::impls::descriptor::AttachmentModel::texture_id + crate::core::testkit::impls::descriptor::AttachmentModel::texture_id ), Some(t.id()) ); @@ -1247,7 +1250,7 @@ mod tests { .unwrap() .unwrap(); assert_eq!( - crate::platform::icb::IndirectCommandBuffer::resource_index(&icb), + crate::core::platform::icb::IndirectCommandBuffer::resource_index(&icb), 3 ); diff --git a/crates/reims-vgpu-core/src/raise.rs b/crates/reims-vgpu-vulkan/src/core/raise.rs similarity index 93% rename from crates/reims-vgpu-core/src/raise.rs rename to crates/reims-vgpu-vulkan/src/core/raise.rs index 17c42dc37..911cfea4c 100644 --- a/crates/reims-vgpu-core/src/raise.rs +++ b/crates/reims-vgpu-vulkan/src/core/raise.rs @@ -19,7 +19,7 @@ pub use death::{DeathId, DeathKind, DeathSite, fatal}; pub use kept::{Kept, keep_forever}; pub use on_fault::OnFault; -use crate::rt::held::Deferred; +use crate::core::rt::held::Deferred; /// A raise's identity: what raised and why. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] @@ -66,7 +66,7 @@ pub struct Raise { detail: Option>, origin: Origin, /// Released where a catch ends the raise, in its hold's holder - /// ([`Hold::land`](crate::rt::Hold::land)). + /// ([`Hold::land`](crate::core::rt::Hold::land)). deferred: Deferred, } @@ -148,7 +148,7 @@ impl Raise { } /// The same raise, carrying `v` outward: `v` is released where a catch ends the raise, in its - /// hold's holder ([`Hold::land`](crate::rt::Hold::land)), after the catcher's report, and + /// hold's holder ([`Hold::land`](crate::core::rt::Hold::land)), after the catcher's report, and /// never if it dies. It takes its place among that holder's values at the point it was /// deferred. pub fn defer(mut self, v: T) -> Raise { @@ -156,8 +156,8 @@ impl Raise { self } - /// What it carries, for a landing frame to add its values to ([`crate::rt::Held::raising`]) - /// and a catch to land ([`Hold::land`](crate::rt::Hold::land)). + /// What it carries, for a landing frame to add its values to ([`crate::core::rt::Held::raising`]) + /// and a catch to land ([`Hold::land`](crate::core::rt::Hold::land)). pub(crate) fn deferred_mut(&mut self) -> &mut Deferred { &mut self.deferred } @@ -250,16 +250,16 @@ impl fmt::Display for Raise { #[macro_export] macro_rules! raise { ($on:expr => $id:expr) => { - return $on.throw($crate::raise::Raise::new($id)) + return $on.throw($crate::core::raise::Raise::new($id)) }; ($on:expr => $id:expr, $detail:expr) => { - return $on.throw($crate::raise::Raise::new($id).with_detail($detail)) + return $on.throw($crate::core::raise::Raise::new($id).with_detail($detail)) }; ($id:expr) => { - return Err($crate::raise::Raise::new($id)) + return Err($crate::core::raise::Raise::new($id)) }; ($id:expr, $detail:expr) => { - return Err($crate::raise::Raise::new($id).with_detail($detail)) + return Err($crate::core::raise::Raise::new($id).with_detail($detail)) }; } diff --git a/crates/reims-vgpu-core/src/raise/death.rs b/crates/reims-vgpu-vulkan/src/core/raise/death.rs similarity index 91% rename from crates/reims-vgpu-core/src/raise/death.rs rename to crates/reims-vgpu-vulkan/src/core/raise/death.rs index f7059bc9f..a1d84ff92 100644 --- a/crates/reims-vgpu-core/src/raise/death.rs +++ b/crates/reims-vgpu-vulkan/src/core/raise/death.rs @@ -4,7 +4,7 @@ //! process ends at the guest op that caused it and nothing after it reaches the host or the //! guest. Where the process dies is the contract; the message and the signal are diagnostics. //! The one exception unwinds instead: a death inside a refusal scope refuses the op it met -//! ([`crate::raise::refusals`]), which only the graphics lane opens. +//! ([`crate::core::raise::refusals`]), which only the graphics lane opens. //! //! [`DeathId`] names what died: an area's reason (its `Display` a dotted id), a raise nothing may //! catch, a platform call, or a host call that raised. [`DeathSite`] and [`DeathKind`] are the @@ -15,7 +15,7 @@ use std::fmt; -use crate::raise::{Origin, RaiseId}; +use crate::core::raise::{Origin, RaiseId}; /// A death as the test capture names it: its [`DeathKind`], and the dotted id, call or selector /// it names with a line (0 for a named id, the Rust line for a raise that dies where it was @@ -45,7 +45,7 @@ pub enum DeathKind { /// An out-of-bounds read that faults. OutOfBounds, /// A raise of core's own that dies at its site ([`DeathId::Raised`]): no handler is live - /// there, or the site lets none take it ([`crate::raise::Raise::fatal`]). + /// there, or the site lets none take it ([`crate::core::raise::Raise::fatal`]). UnhandledRaise, /// A platform exception with no handler live, or at a send that no handler may take. UncaughtObjc, @@ -83,12 +83,12 @@ pub enum DeathId { /// The call: the block's SDK property name. call: &'static str, }, - /// Memory's (`crate::memory::DeathKind`). - Memory(crate::memory::DeathKind), + /// Memory's (`crate::core::memory::DeathKind`). + Memory(crate::core::memory::DeathKind), /// A display's pipelines'. - Display(crate::display::DeathKind), + Display(crate::core::display::DeathKind), /// A panic in a refusal scope, which the scope refuses as a death there - /// ([`crate::raise::refusals`], "Panics"): no death site raises it. + /// ([`crate::core::raise::refusals`], "Panics"): no death site raises it. Panic, /// A test's own death at a site it names (the testkit's fakes and the tests of the death /// machinery). @@ -118,7 +118,7 @@ impl DeathId { /// The site the test capture records: an area's death by its dotted name at line 0. pub fn site(self) -> DeathSite { match self { - DeathId::Raised { id, origin } => crate::raise::death_site(id, origin), + DeathId::Raised { id, origin } => crate::core::raise::death_site(id, origin), DeathId::Platform { kind, call } => DeathSite { kind, file: call, @@ -186,16 +186,16 @@ pub fn fatal_with_detail(id: impl Into, detail: &str) -> ! { /// [`fatal`] with a detail after the id (a raise's). pub(crate) fn die(id: DeathId, detail: Option<&str>) -> ! { // A death inside a refusal scope (the graphics lane's ops) refuses the op instead. - crate::raise::refusals::trap(id, detail); + crate::core::raise::refusals::trap(id, detail); #[cfg(any(test, feature = "testkit"))] - if crate::testkit::capture::capture_enabled() { + if crate::core::testkit::capture::capture_enabled() { // A captured death unwinds quietly, before its line below is written: the line goes to // stderr first, so a test that dies where it should not shows what it died of. let _ = std::io::Write::write_all( &mut std::io::stderr(), format!("{}\n", message(&id, detail)).as_bytes(), ); - crate::testkit::capture::capture(id.site()) + crate::core::testkit::capture::capture(id.site()) } let mut line = message(&id, detail); // The subprocess harness names the death by its site (`testkit::death::parse_death_line`). @@ -213,7 +213,7 @@ pub(crate) fn die(id: DeathId, detail: Option<&str>) -> ! { // One write, so the line never interleaves with another thread's. let _ = std::io::stderr().write_all(line.as_bytes()); // The trace's last lines, the events that led here (a diagnostic). - crate::trace::flush_before_death(); + crate::core::trace::flush_before_death(); #[allow(clippy::disallowed_methods)] // the one fatal path's abort (6.4) std::process::abort() } @@ -230,7 +230,7 @@ fn message(id: &DeathId, detail: Option<&str>) -> String { #[macro_export] macro_rules! fatal { ($id:expr) => { - $crate::raise::death::fatal($id) + $crate::core::raise::death::fatal($id) }; } @@ -239,7 +239,7 @@ macro_rules! fatal { macro_rules! fatal_unless { ($cond:expr, $id:expr) => { if !($cond) { - $crate::raise::death::fatal($id) + $crate::core::raise::death::fatal($id) } }; } @@ -247,7 +247,7 @@ macro_rules! fatal_unless { #[cfg(test)] mod tests { use super::*; - use crate::testkit::capture::catch_death; + use crate::core::testkit::capture::catch_death; /// `fatal` dies with the id's site; a test site names itself #[test] @@ -302,7 +302,7 @@ mod tests { message(&raised, Some("the reason")), "reims-vgpu: fatal: uncaught raise platform.raised at setPurgeableState:: the reason" ); - let area = DeathId::from(crate::display::DeathKind::NoLibrary); + let area = DeathId::from(crate::core::display::DeathKind::NoLibrary); assert_eq!( message(&area, None), "reims-vgpu: fatal: display.pipeline.no_library" diff --git a/crates/reims-vgpu-core/src/raise/kept.rs b/crates/reims-vgpu-vulkan/src/core/raise/kept.rs similarity index 100% rename from crates/reims-vgpu-core/src/raise/kept.rs rename to crates/reims-vgpu-vulkan/src/core/raise/kept.rs diff --git a/crates/reims-vgpu-core/src/raise/on_fault.rs b/crates/reims-vgpu-vulkan/src/core/raise/on_fault.rs similarity index 95% rename from crates/reims-vgpu-core/src/raise/on_fault.rs rename to crates/reims-vgpu-vulkan/src/core/raise/on_fault.rs index 1a4bed8ad..1f64c5edc 100644 --- a/crates/reims-vgpu-core/src/raise/on_fault.rs +++ b/crates/reims-vgpu-vulkan/src/core/raise/on_fault.rs @@ -5,7 +5,7 @@ //! ([`Raise::fatal`]), and a function its callers reach both ways takes an [`OnFault`] from its //! caller, which says which of the two the call is (`raise!(on => id)`, [`OnFault::throw`]). -use crate::raise::{Raise, RaiseResult}; +use crate::core::raise::{Raise, RaiseResult}; /// What a raise does in a function its callers reach both under a handler and with none: the /// caller, which knows which of the two it is, says so. A caller reached only under a handler @@ -34,9 +34,9 @@ impl OnFault { #[cfg(test)] mod tests { use super::*; - use crate::raise::RaiseId; - use crate::raise::death::{DeathKind, DeathSite}; - use crate::testkit::capture::catch_death; + use crate::core::raise::RaiseId; + use crate::core::raise::death::{DeathKind, DeathSite}; + use crate::core::testkit::capture::catch_death; fn a_raise() -> Raise { Raise::new(RaiseId::Test { name: "on_fault" }) diff --git a/crates/reims-vgpu-core/src/raise/refusals.rs b/crates/reims-vgpu-vulkan/src/core/raise/refusals.rs similarity index 97% rename from crates/reims-vgpu-core/src/raise/refusals.rs rename to crates/reims-vgpu-vulkan/src/core/raise/refusals.rs index a7b2f0975..d619ef9ec 100644 --- a/crates/reims-vgpu-core/src/raise/refusals.rs +++ b/crates/reims-vgpu-vulkan/src/core/raise/refusals.rs @@ -39,7 +39,7 @@ use std::cell::Cell; use std::fmt; use std::panic::{AssertUnwindSafe, catch_unwind, resume_unwind}; -use crate::raise::death::DeathId; +use crate::core::raise::death::DeathId; thread_local! { /// How many scopes this thread is inside. @@ -137,7 +137,7 @@ fn panic_message(payload: &(dyn std::any::Any + Send)) -> Option { fn panics_refused() -> bool { #[cfg(any(test, feature = "testkit"))] { - !crate::testkit::capture::capture_enabled() + !crate::core::testkit::capture::capture_enabled() } #[cfg(not(any(test, feature = "testkit")))] { @@ -207,9 +207,9 @@ pub(crate) fn trap(id: DeathId, detail: Option<&str>) { #[cfg(test)] mod tests { use super::*; - use crate::raise::death::{DeathKind, DeathSite, fatal_with_detail}; - use crate::raise::{Raise, RaiseResult}; - use crate::testkit::capture::catch_death; + use crate::core::raise::death::{DeathKind, DeathSite, fatal_with_detail}; + use crate::core::raise::{Raise, RaiseResult}; + use crate::core::testkit::capture::catch_death; const SITE: DeathSite = DeathSite { kind: DeathKind::Abort, @@ -340,7 +340,7 @@ mod tests { /// passes every scope by #[test] fn a_panic_in_a_scope_is_its_refusal() { - use crate::testkit::capture::{capture_enabled, set_capture_enabled}; + use crate::core::testkit::capture::{capture_enabled, set_capture_enabled}; assert!(capture_enabled()); let r = catch_unwind(|| refusing(|| -> u32 { panic!("a test's assertion") })); let payload = r.unwrap_err(); @@ -349,7 +349,7 @@ mod tests { let out = std::process::Command::new(std::env::current_exe().unwrap()) .args([ "--exact", - "raise::refusals::tests::a_panic_in_a_scope_is_its_refusal", + "core::raise::refusals::tests::a_panic_in_a_scope_is_its_refusal", "--nocapture", "--test-threads=1", ]) diff --git a/crates/reims-vgpu-core/src/rt.rs b/crates/reims-vgpu-vulkan/src/core/rt.rs similarity index 100% rename from crates/reims-vgpu-core/src/rt.rs rename to crates/reims-vgpu-vulkan/src/core/rt.rs diff --git a/crates/reims-vgpu-core/src/rt/block_env.rs b/crates/reims-vgpu-vulkan/src/core/rt/block_env.rs similarity index 92% rename from crates/reims-vgpu-core/src/rt/block_env.rs rename to crates/reims-vgpu-vulkan/src/core/rt/block_env.rs index 76a562921..991326cfa 100644 --- a/crates/reims-vgpu-core/src/rt/block_env.rs +++ b/crates/reims-vgpu-vulkan/src/core/rt/block_env.rs @@ -3,7 +3,7 @@ //! A queue's block, a source's handler, a once's block and a Metal completion handler are callouts //! an exception never unwinds out of: a raise in one with no handler of its own dies at the raise, //! whatever handlers the thread had (measured for `dispatch_sync` on macOS 26.7). Its code holds -//! under [`Hold::NONE`](crate::rt::Hold::NONE), with no holder: a callout is `Send` and its +//! under [`Hold::NONE`](crate::core::rt::Hold::NONE), with no holder: a callout is `Send` and its //! caller's hold is not, so none reaches it. While a queue's block runs, the thread owns the queue, //! and a `sync` onto a queue it owns runs its block at once, as a nested call (`rt::queue`'s //! module doc). So a queue's block or a completion handler enters: @@ -16,7 +16,7 @@ use std::cell::Cell; -use crate::rt::thread::{OursGuard, enter_ours}; +use crate::core::rt::thread::{OursGuard, enter_ours}; /// One queue of a thread's ownership chain: its id and label. pub(crate) type Owned = (u64, &'static str); @@ -92,7 +92,7 @@ pub(crate) struct Submitted { owned: Vec, ours: bool, #[cfg(any(test, feature = "testkit"))] - slot: Option>, + slot: Option>, } impl Submitted { @@ -102,7 +102,7 @@ impl Submitted { owned, ours, #[cfg(any(test, feature = "testkit"))] - slot: crate::testkit::capture::current_slot(), + slot: crate::core::testkit::capture::current_slot(), } } @@ -119,7 +119,7 @@ impl Submitted { f() }; #[cfg(any(test, feature = "testkit"))] - return crate::testkit::capture::with_slot(slot, run); + return crate::core::testkit::capture::with_slot(slot, run); #[cfg(not(any(test, feature = "testkit")))] run() } @@ -128,7 +128,7 @@ impl Submitted { #[cfg(test)] mod tests { use super::*; - use crate::rt::thread::is_our_thread; + use crate::core::rt::thread::is_our_thread; /// A block owns its chain, marked ours; the caller's come back after #[test] diff --git a/crates/reims-vgpu-core/src/rt/held.rs b/crates/reims-vgpu-vulkan/src/core/rt/held.rs similarity index 97% rename from crates/reims-vgpu-core/src/rt/held.rs rename to crates/reims-vgpu-vulkan/src/core/rt/held.rs index 969b3d0ef..4623652b2 100644 --- a/crates/reims-vgpu-core/src/rt/held.rs +++ b/crates/reims-vgpu-vulkan/src/core/rt/held.rs @@ -15,11 +15,11 @@ //! //! A hold with no holder ([`Hold::NONE`]: a queue's block, a thread's body, a drop) holds to the //! thread's last-resort holder: a thread core started (a queue's worker, a named thread) keeps -//! one, released once the worker has left its queue ([`crate::rt::pool::drain_idle`]) and at the +//! one, released once the worker has left its queue ([`crate::core::rt::pool::drain_idle`]) and at the //! thread's end, just before its last-resort real pool pops. On any other thread (Metal's, a //! test's) the value drops there. //! -//! A raise carries values outward too: [`crate::raise::Raise::defer`] puts one in the raise's +//! A raise carries values outward too: [`crate::core::raise::Raise::defer`] puts one in the raise's //! [`Deferred`], and the catch that ends the raise ([`Hold::land`]) hands them to its hold's //! holder. A landing frame whose body raises puts what it holds in the raise the same way. A raise //! that dies releases none of them, and one dropped with values still in it is a bug, which builds @@ -39,7 +39,7 @@ use std::fmt; use std::marker::PhantomData; use std::sync::atomic::{AtomicU64, Ordering}; -use crate::raise::{Raise, RaiseResult}; +use crate::core::raise::{Raise, RaiseResult}; /// A held value. struct Value { @@ -105,7 +105,7 @@ impl Held { /// A landing frame: runs `body` with a new holder, which `body` names in the hold its work /// runs under ([`Hold::of`]). When `body` returns a value the holder releases what it holds /// there, most recent first. When it raises, what the holder holds goes on with - /// the raise instead, as [`crate::raise::Raise::defer`]'s values do, and is released where the + /// the raise instead, as [`crate::core::raise::Raise::defer`]'s values do, and is released where the /// raise ends, after the catcher's report. A death releases none of it. pub fn raising(body: impl FnOnce(&Held) -> RaiseResult) -> RaiseResult { let held = Held::new(); @@ -237,7 +237,7 @@ fn to_last_resort(v: Value) { /// Releases the thread's last-resort holder, most recent first, and, when `again`, makes the /// next one (the thread goes on idle; at its end, none). -pub(in crate::rt) fn release_last_resort(again: bool) { +pub(in crate::core::rt) fn release_last_resort(again: bool) { let last = LAST_RESORT.try_with(RefCell::take).ok().flatten(); drop(last); if again { @@ -245,7 +245,7 @@ pub(in crate::rt) fn release_last_resort(again: bool) { } } -/// The values a raise carries outward ([`crate::raise::Raise::defer`], [`Held::raising`]), in the +/// The values a raise carries outward ([`crate::core::raise::Raise::defer`], [`Held::raising`]), in the /// order they were first held, until the catch that ends the raise ([`Hold::land`]) lands them /// in its hold's holder, among whose own values they take their place, and whose /// drop releases them most recent first. A death forgets them. @@ -323,9 +323,9 @@ impl Drop for Deferred { #[cfg(test)] mod tests { use super::*; - use crate::raise::{OnFault, Raise, RaiseId, RaiseResult}; - use crate::rt::pool::test_native::{events, note, with_test_native}; - use crate::testkit::capture::catch_death; + use crate::core::raise::{OnFault, Raise, RaiseId, RaiseResult}; + use crate::core::rt::pool::test_native::{events, note, with_test_native}; + use crate::core::testkit::capture::catch_death; use std::sync::Arc; use std::sync::atomic::AtomicU32; diff --git a/crates/reims-vgpu-core/src/rt/pool.rs b/crates/reims-vgpu-vulkan/src/core/rt/pool.rs similarity index 93% rename from crates/reims-vgpu-core/src/rt/pool.rs rename to crates/reims-vgpu-vulkan/src/core/rt/pool.rs index 32ac793a9..647dc3598 100644 --- a/crates/reims-vgpu-core/src/rt/pool.rs +++ b/crates/reims-vgpu-vulkan/src/core/rt/pool.rs @@ -12,14 +12,14 @@ //! The threads core starts (a queue's worker, a named thread) also keep a last-resort pool, for //! what is autoreleased on them outside any unit: [`drain_idle`] pops it and pushes the next once //! the worker has left its queue, and [`drain_thread_end`] pops it at the thread's end. The -//! thread's last-resort holder ([`crate::rt::held`]) is released first at both points. +//! thread's last-resort holder ([`crate::core::rt::held`]) is released first at both points. use std::cell::Cell; use std::ffi::c_void; -use crate::platform::os::Autorelease; -use crate::platform::os::autorelease::NativePool; -use crate::raise::RaiseResult; +use crate::core::platform::os::Autorelease; +use crate::core::platform::os::autorelease::NativePool; +use crate::core::raise::RaiseResult; #[cfg(test)] thread_local! { @@ -32,7 +32,7 @@ pub(crate) fn native() -> Option { if let Some(n) = TEST_NATIVE.with(Cell::get) { return Some(n); } - crate::platform::os::autorelease::installed() + crate::core::platform::os::autorelease::installed() } /// One real pool, pushed while it lives. Thread-bound (`!Send`: the pool is the thread's). @@ -105,7 +105,7 @@ thread_local! { /// and pushes the next. A worker calls it once it has left its queue (as libdispatch's pool /// around a worker's drain), a named thread at its start. pub(crate) fn drain_idle() { - crate::rt::held::release_last_resort(true); + crate::core::rt::held::release_last_resort(true); let Some(n) = native() else { return }; if let Some(token) = LAST_RESORT.with(Cell::take) { (n.pop)(token); @@ -117,7 +117,7 @@ pub(crate) fn drain_idle() { /// A core thread's end, outside any unit: releases its last-resort holder, then pops its /// last-resort real pool. pub(crate) fn drain_thread_end() { - crate::rt::held::release_last_resort(false); + crate::core::rt::held::release_last_resort(false); if let (Some(token), Some(n)) = (LAST_RESORT.with(Cell::take), native()) { (n.pop)(token); } @@ -128,7 +128,7 @@ pub(crate) fn drain_thread_end() { #[cfg(test)] pub(crate) mod test_native { use super::TEST_NATIVE; - use crate::platform::os::autorelease::NativePool; + use crate::core::platform::os::autorelease::NativePool; use std::cell::{Cell, RefCell}; use std::ffi::c_void; @@ -181,9 +181,9 @@ pub(crate) mod test_native { mod tests { use super::test_native::{events, note, with_test_native}; use super::*; - use crate::raise::{Raise, RaiseId}; - use crate::rt::Hold; - use crate::testkit::FakePlatform; + use crate::core::raise::{Raise, RaiseId}; + use crate::core::rt::Hold; + use crate::core::testkit::FakePlatform; /// A pool pops at its drop, after the work inside it #[test] diff --git a/crates/reims-vgpu-core/src/rt/queue.rs b/crates/reims-vgpu-vulkan/src/core/rt/queue.rs similarity index 95% rename from crates/reims-vgpu-core/src/rt/queue.rs rename to crates/reims-vgpu-vulkan/src/core/rt/queue.rs index e8b983384..8250cdf3e 100644 --- a/crates/reims-vgpu-core/src/rt/queue.rs +++ b/crates/reims-vgpu-vulkan/src/core/rt/queue.rs @@ -5,7 +5,7 @@ //! the next block starts another. What every block sees, whichever thread runs it: //! - an async block starts with no handler, so a raise in it with no handler of its own dies at //! the raise, its site labelled as having none (6.2). Its code holds under -//! [`Hold::NONE`](crate::rt::Hold::NONE), with no holder; +//! [`Hold::NONE`](crate::core::rt::Hold::NONE), with no holder; //! - a sync block runs on the caller's thread, directly, once every block submitted before it has //! run, and holds the queue until it returns. It too starts with no handler, whatever handler //! the caller is in, so a raise in it with no handler of its own dies at the raise, even under @@ -37,12 +37,12 @@ use std::sync::Arc; use std::sync::atomic::{AtomicU64, Ordering}; use std::time::Duration; -use crate::platform::os::{Threads, TimerClock}; +use crate::core::platform::os::{Threads, TimerClock}; #[cfg(test)] -pub(crate) use crate::rt::block_env::current_label; -use crate::rt::block_env::{Owned, Submitted, owned_chain}; -use crate::rt::pool; -use crate::sync::{Condvar, Mutex, MutexGuard}; +pub(crate) use crate::core::rt::block_env::current_label; +use crate::core::rt::block_env::{Owned, Submitted, owned_chain}; +use crate::core::rt::pool; +use crate::core::sync::{Condvar, Mutex, MutexGuard}; /// A block submitted to a queue. pub type Job = Box; @@ -113,7 +113,7 @@ impl Turn { struct Block { job: Job, #[cfg(any(test, feature = "testkit"))] - slot: Option>, + slot: Option>, } /// What a queue holds, in submission order. @@ -213,7 +213,7 @@ impl SerialQueue { /// Runs `f` after every block submitted before it, on the queue's worker, with no handler (a /// raise in it with no handler of its own dies at the raise) and no holder - /// ([`Hold::NONE`](crate::rt::Hold::NONE)), owning only this queue. + /// ([`Hold::NONE`](crate::core::rt::Hold::NONE)), owning only this queue. pub fn exec_async(&self, f: impl FnOnce() + Send + 'static) { let block = Submitted::new(vec![self.me()], true); Shared::submit( @@ -221,7 +221,7 @@ impl SerialQueue { Block { job: Box::new(move || block.run(f)), #[cfg(any(test, feature = "testkit"))] - slot: crate::testkit::capture::current_slot(), + slot: crate::core::testkit::capture::current_slot(), }, ); } @@ -256,7 +256,7 @@ impl SerialQueue { /// Runs `f` on the caller's thread once every block submitted before it has run, and holds /// the queue until it returns. `f` starts with no handler (a raise in it with no handler of /// its own dies at the raise, whatever handler the caller has) and no holder - /// ([`Hold::NONE`](crate::rt::Hold::NONE)), and what it autoreleases goes to the caller's + /// ([`Hold::NONE`](crate::core::rt::Hold::NONE)), and what it autoreleases goes to the caller's /// real pool. A caller that owns the queue already runs `f` at once (module doc). /// `f` is `Send`, as a block of the queue's own is: it takes nothing that is bound to the /// caller's thread, its hold included. @@ -335,7 +335,7 @@ impl Shared { &self, st: &mut MutexGuard<'_, State>, #[cfg(any(test, feature = "testkit"))] slot: &mut Option< - Arc, + Arc, >, ) -> bool { if st.owner != Owner::Idle { @@ -366,7 +366,7 @@ impl Shared { /// caller holds it), and ends once the last handle is gone or it has waited /// [`IDLE_EXIT`] with nothing to do. fn work(this: &Arc) { - crate::rt::thread::become_ours(); + crate::core::rt::thread::become_ours(); WORKER_OF.with(|w| w.set(this.id)); // The first last-resort pool. pool::drain_idle(); @@ -391,7 +391,7 @@ impl Shared { { let s = slot.clone(); MutexGuard::unlocked(&mut st, || { - crate::testkit::capture::with_slot(s, pool::drain_idle) + crate::core::testkit::capture::with_slot(s, pool::drain_idle) }); } #[cfg(not(any(test, feature = "testkit")))] @@ -489,14 +489,14 @@ impl Executor for SerialQueue { #[cfg(test)] mod tests { use super::*; - use crate::raise::OnFault; - use crate::raise::RaiseResult; - use crate::raise::death::DeathSite; - use crate::rt::signal::CoalescingSignal; - use crate::rt::thread::is_our_thread; - use crate::rt::thread::test_threads::StdThreads; - use crate::testkit::capture::{expect_death, raise}; - use crate::testkit::threads::FakeThreads; + use crate::core::raise::OnFault; + use crate::core::raise::RaiseResult; + use crate::core::raise::death::DeathSite; + use crate::core::rt::signal::CoalescingSignal; + use crate::core::rt::thread::is_our_thread; + use crate::core::rt::thread::test_threads::StdThreads; + use crate::core::testkit::capture::{expect_death, raise}; + use crate::core::testkit::threads::FakeThreads; use std::sync::atomic::AtomicBool; use std::sync::mpsc; use std::time::Duration; @@ -818,7 +818,7 @@ mod tests { let queue = q("q"); expect_death( DeathSite { - kind: crate::raise::DeathKind::UnhandledRaise, + kind: crate::core::raise::DeathKind::UnhandledRaise, file: "gpu_task", line: 0, }, @@ -842,7 +842,7 @@ mod tests { let q3 = queue2.clone(); expect_death( DeathSite { - kind: crate::raise::DeathKind::UnhandledRaise, + kind: crate::core::raise::DeathKind::UnhandledRaise, file: "device", line: 0, }, diff --git a/crates/reims-vgpu-core/src/rt/signal.rs b/crates/reims-vgpu-vulkan/src/core/rt/signal.rs similarity index 99% rename from crates/reims-vgpu-core/src/rt/signal.rs rename to crates/reims-vgpu-vulkan/src/core/rt/signal.rs index f5c69e256..df8b9a2b1 100644 --- a/crates/reims-vgpu-core/src/rt/signal.rs +++ b/crates/reims-vgpu-vulkan/src/core/rt/signal.rs @@ -28,7 +28,7 @@ use std::sync::Arc; use parking_lot::Mutex; -use crate::rt::queue::Executor; +use crate::core::rt::queue::Executor; /// How merged data combines (`DISPATCH_SOURCE_TYPE_DATA_ADD` / `_OR`). #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -250,8 +250,8 @@ impl Inner { #[cfg(test)] mod tests { use super::*; - use crate::rt::queue::{Job, SerialQueue}; - use crate::rt::thread::test_threads::StdThreads; + use crate::core::rt::queue::{Job, SerialQueue}; + use crate::core::rt::thread::test_threads::StdThreads; use std::sync::atomic::{AtomicU64, Ordering}; /// A target that holds jobs until the test runs them: a busy queue (not suspended), as the diff --git a/crates/reims-vgpu-core/src/rt/thread.rs b/crates/reims-vgpu-vulkan/src/core/rt/thread.rs similarity index 85% rename from crates/reims-vgpu-core/src/rt/thread.rs rename to crates/reims-vgpu-vulkan/src/core/rt/thread.rs index db7cf1cb5..c8ff375f4 100644 --- a/crates/reims-vgpu-core/src/rt/thread.rs +++ b/crates/reims-vgpu-vulkan/src/core/rt/thread.rs @@ -4,12 +4,12 @@ //! and each serial queue's worker (`rt::queue`). This wrapper adds what such a thread needs: //! the "ours" mark the panic hook reads (6.5), the thread's own last-resort holder and pool, and, //! in tests, the creator's death slot. Its body starts with no handler, and holds under -//! [`Hold::NONE`](crate::rt::Hold::NONE): a hold is not `Send`, so none reaches it. +//! [`Hold::NONE`](crate::core::rt::Hold::NONE): a hold is not `Send`, so none reaches it. use std::cell::Cell; use std::marker::PhantomData; -use crate::platform::os::Threads; +use crate::core::platform::os::Threads; thread_local! { static OURS: Cell = const { Cell::new(false) }; @@ -61,7 +61,7 @@ impl Drop for OursGuard { /// A detached thread named `name` with `stack_size` bytes of stack, from the platform's /// [`Threads::spawn`], whose body runs marked as ours, with the thread's /// last-resort holder and real pool. The thread ends in this order: `body` returns, the -/// last-resort holder is released and the pool popped ([`crate::rt::pool::drain_thread_end`]), +/// last-resort holder is released and the pool popped ([`crate::core::rt::pool::drain_thread_end`]), /// and then `target` is dropped, on the thread. pub fn spawn_named( threads: &dyn Threads, @@ -71,7 +71,7 @@ pub fn spawn_named( body: impl FnOnce() + Send + 'static, ) { #[cfg(any(test, feature = "testkit"))] - let slot = crate::testkit::capture::current_slot(); + let slot = crate::core::testkit::capture::current_slot(); // The target's release is the thread's too: a death there reaches the test's slot. #[cfg(any(test, feature = "testkit"))] let target: Box = Box::new(InSlot { @@ -79,9 +79,9 @@ pub fn spawn_named( value: Some(target), }); let run = move || { - crate::rt::pool::drain_idle(); + crate::core::rt::pool::drain_idle(); body(); - crate::rt::pool::drain_thread_end(); + crate::core::rt::pool::drain_thread_end(); }; threads.spawn( name, @@ -89,7 +89,7 @@ pub fn spawn_named( Box::new(move || { become_ours(); #[cfg(any(test, feature = "testkit"))] - crate::testkit::capture::with_slot(slot, run); + crate::core::testkit::capture::with_slot(slot, run); #[cfg(not(any(test, feature = "testkit")))] run(); drop(target); @@ -100,7 +100,7 @@ pub fn spawn_named( /// A value dropped with a test's death slot current (`spawn_named`'s target). #[cfg(any(test, feature = "testkit"))] struct InSlot { - slot: Option>, + slot: Option>, value: Option>, } @@ -108,7 +108,7 @@ struct InSlot { impl Drop for InSlot { fn drop(&mut self) { let value = self.value.take(); - crate::testkit::capture::with_slot(self.slot.take(), move || drop(value)); + crate::core::testkit::capture::with_slot(self.slot.take(), move || drop(value)); } } @@ -126,7 +126,7 @@ pub(crate) mod test_threads { use std::sync::Arc; - use crate::platform::os::{Threads, TimerClock}; + use crate::core::platform::os::{Threads, TimerClock}; /// Spawns detached std threads: named ones with the requested stack, and unnamed queue /// workers. It makes no timers. @@ -166,7 +166,7 @@ mod tests { use std::sync::mpsc; /// A named thread's stack in these tests: a queue worker's and 64 KiB more. - const STACK: usize = crate::rt::queue::WORKER_STACK + 64 * 1024; + const STACK: usize = crate::core::rt::queue::WORKER_STACK + 64 * 1024; /// The spawned body is ours and named #[test] @@ -221,12 +221,15 @@ mod tests { struct Dies; impl Drop for Dies { fn drop(&mut self) { - crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "named") + crate::core::testkit::capture::die( + crate::core::raise::death::DeathKind::Abort, + "named", + ) } } - crate::testkit::capture::expect_death( - crate::raise::death::DeathSite { - kind: crate::raise::death::DeathKind::Abort, + crate::core::testkit::capture::expect_death( + crate::core::raise::death::DeathSite { + kind: crate::core::raise::death::DeathKind::Abort, file: "named", line: 0, }, @@ -258,15 +261,18 @@ mod tests { /// A death on a spawned thread lands in the creator's slot #[test] fn death_on_spawned_thread_is_captured() { - crate::testkit::capture::expect_death( - crate::raise::death::DeathSite { - kind: crate::raise::death::DeathKind::Abort, + crate::core::testkit::capture::expect_death( + crate::core::raise::death::DeathSite { + kind: crate::core::raise::death::DeathKind::Abort, file: "named", line: 0, }, || { spawn_named(&StdThreads, "reims-vgpu.test", STACK, Box::new(()), || { - crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "named") + crate::core::testkit::capture::die( + crate::core::raise::death::DeathKind::Abort, + "named", + ) }); loop { std::thread::park(); diff --git a/crates/reims-vgpu-core/src/rt/timer.rs b/crates/reims-vgpu-vulkan/src/core/rt/timer.rs similarity index 91% rename from crates/reims-vgpu-core/src/rt/timer.rs rename to crates/reims-vgpu-vulkan/src/core/rt/timer.rs index 84dd7eada..b467e1a76 100644 --- a/crates/reims-vgpu-core/src/rt/timer.rs +++ b/crates/reims-vgpu-vulkan/src/core/rt/timer.rs @@ -11,11 +11,11 @@ use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use std::time::Duration; -use crate::platform::os::{Deadline, MonoTime, TimerClock, WallTime}; -use crate::raise::{Kept, keep_forever}; -use crate::rt::queue::{Executor, SerialQueue}; -use crate::rt::signal::CoalescingSignal; -use crate::sync::{Condvar, Mutex}; +use crate::core::platform::os::{Deadline, MonoTime, TimerClock, WallTime}; +use crate::core::raise::{Kept, keep_forever}; +use crate::core::rt::queue::{Executor, SerialQueue}; +use crate::core::rt::signal::CoalescingSignal; +use crate::core::sync::{Condvar, Mutex}; /// What the timer's thread and its handle share. #[derive(Default)] @@ -77,8 +77,8 @@ impl Timer { ) -> Timer { let Some(clock) = queue.timer_clock() else { // No production platform lacks a clock; a fake made without one refuses here. - crate::raise::death::fatal(crate::raise::death::DeathId::Platform { - kind: crate::raise::death::DeathKind::Abort, + crate::core::raise::death::fatal(crate::core::raise::death::DeathId::Platform { + kind: crate::core::raise::death::DeathKind::Abort, call: "timer: no clock", }) }; @@ -94,12 +94,12 @@ impl Timer { .name("reims-vgpu.timer".into()) .stack_size(TIMER_STACK) .spawn(move || { - crate::rt::thread::become_ours(); + crate::core::rt::thread::become_ours(); run(&*clock, &sh, &sig, start, step) }); if r.is_err() { - crate::raise::death::fatal(crate::raise::death::DeathId::Platform { - kind: crate::raise::death::DeathKind::Abort, + crate::core::raise::death::fatal(crate::core::raise::death::DeathId::Platform { + kind: crate::core::raise::death::DeathKind::Abort, call: "pthread_create", }) } @@ -174,11 +174,11 @@ fn run(clock: &dyn TimerClock, sh: &Shared, sig: &CoalescingSignal, start: Deadl #[cfg(test)] mod tests { use super::*; - use crate::platform::os::{Clock, Threads}; - use crate::rt::queue::current_label; - use crate::rt::thread::is_our_thread; - use crate::sync::test_clock::ManualClock; - use crate::testkit::threads::FakeThreads; + use crate::core::platform::os::{Clock, Threads}; + use crate::core::rt::queue::current_label; + use crate::core::rt::thread::is_our_thread; + use crate::core::sync::test_clock::ManualClock; + use crate::core::testkit::threads::FakeThreads; use std::sync::atomic::AtomicU64; use std::sync::mpsc; diff --git a/crates/reims-vgpu-core/src/sync.rs b/crates/reims-vgpu-vulkan/src/core/sync.rs similarity index 98% rename from crates/reims-vgpu-core/src/sync.rs rename to crates/reims-vgpu-vulkan/src/core/sync.rs index e44bf3b97..8138ca091 100644 --- a/crates/reims-vgpu-core/src/sync.rs +++ b/crates/reims-vgpu-vulkan/src/core/sync.rs @@ -18,7 +18,7 @@ pub(crate) mod test_clock { //! `VirtualClock`). use super::{Condvar, Mutex, MutexGuard}; - use crate::platform::os::{Clock, Deadline, MonoTime, TimedOut, WallTime}; + use crate::core::platform::os::{Clock, Deadline, MonoTime, TimedOut, WallTime}; use std::time::Duration; /// Virtual time. Timed waits poll in 1 ms real slices, so an `advance` is seen promptly. @@ -154,7 +154,7 @@ pub(crate) mod test_clock { mod tests { use super::test_clock::ManualClock; use super::*; - use crate::platform::os::{Clock, Deadline, MonoTime}; + use crate::core::platform::os::{Clock, Deadline, MonoTime}; use std::sync::Arc; use std::time::Duration; diff --git a/crates/reims-vgpu-core/src/sync/rwlock.rs b/crates/reims-vgpu-vulkan/src/core/sync/rwlock.rs similarity index 100% rename from crates/reims-vgpu-core/src/sync/rwlock.rs rename to crates/reims-vgpu-vulkan/src/core/sync/rwlock.rs diff --git a/crates/reims-vgpu-core/src/testkit/calllog.rs b/crates/reims-vgpu-vulkan/src/core/testkit/calllog.rs similarity index 99% rename from crates/reims-vgpu-core/src/testkit/calllog.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/calllog.rs index 4e455aad4..a925956f0 100644 --- a/crates/reims-vgpu-core/src/testkit/calllog.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/calllog.rs @@ -18,9 +18,9 @@ use std::fmt::Debug; use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}; use std::sync::{Arc, Weak}; -use crate::sync::Mutex; +use crate::core::sync::Mutex; -use crate::platform::{Handle, ObjId}; +use crate::core::platform::{Handle, ObjId}; /// One argument of a recorded call. Handles are recorded by identity; value structs by their /// `Debug` text ([`Arg::val`]), so a test compares them with `Arg::val(&expected)`. @@ -434,7 +434,7 @@ pub(crate) fn as_completion_thread(f: impl FnOnce() -> R) -> R { fn thread_class() -> ThreadClass { if COMPLETION.with(Cell::get) { ThreadClass::Completion - } else if crate::rt::thread::is_core_thread() { + } else if crate::core::rt::thread::is_core_thread() { if std::thread::current().name().is_some() { ThreadClass::Core } else { diff --git a/crates/reims-vgpu-core/src/testkit/capture.rs b/crates/reims-vgpu-vulkan/src/core/testkit/capture.rs similarity index 98% rename from crates/reims-vgpu-core/src/testkit/capture.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/capture.rs index e5d239242..bda49e3ee 100644 --- a/crates/reims-vgpu-core/src/testkit/capture.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/capture.rs @@ -21,8 +21,8 @@ use std::time::{Duration, Instant}; use parking_lot::{Condvar, Mutex}; -use crate::raise::death::{DeathKind, DeathSite}; -use crate::raise::{OnFault, Raise, RaiseId, RaiseResult}; +use crate::core::raise::death::{DeathKind, DeathSite}; +use crate::core::raise::{OnFault, Raise, RaiseId, RaiseResult}; /// The panic payload a captured death unwinds with. #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -155,7 +155,7 @@ fn returned(thrown: RaiseResult) -> Raise { /// A test's own death of `kind` at the site `name`. pub fn die(kind: DeathKind, name: &'static str) -> ! { - crate::raise::death::fatal(crate::raise::death::DeathId::Test { kind, name }) + crate::core::raise::death::fatal(crate::core::raise::death::DeathId::Test { kind, name }) } /// How long `expect_death` waits, in real time, for `f` to die or return. diff --git a/crates/reims-vgpu-core/src/testkit/clock.rs b/crates/reims-vgpu-vulkan/src/core/testkit/clock.rs similarity index 98% rename from crates/reims-vgpu-core/src/testkit/clock.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/clock.rs index 3cefc8c11..2a424b138 100644 --- a/crates/reims-vgpu-core/src/testkit/clock.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/clock.rs @@ -26,9 +26,9 @@ use std::time::Duration; use parking_lot::RawMutex; use parking_lot::lock_api::RawMutex as _; -use crate::platform::os::{Clock, Deadline, MonoTime, TimedOut, WallTime}; -use crate::sync::{Condvar, Mutex, MutexGuard}; -use crate::testkit::capture::VirtualTime; +use crate::core::platform::os::{Clock, Deadline, MonoTime, TimedOut, WallTime}; +use crate::core::sync::{Condvar, Mutex, MutexGuard}; +use crate::core::testkit::capture::VirtualTime; /// Wall time at virtual zero (nanoseconds since the Unix epoch): 2026-01-01T00:00:00Z. Mono /// and wall differ, so a test can tell which clock a wait used. @@ -473,7 +473,7 @@ mod tests { fn works_with_expect_hang() { let c = Arc::new(VirtualClock::new()); let c2 = c.clone(); - crate::testkit::capture::expect_hang(&*c, Duration::from_secs(1), move || { + crate::core::testkit::capture::expect_hang(&*c, Duration::from_secs(1), move || { c2.sleep_until(Deadline::Mono(MonoTime::from_nanos(5_000_000_000))); }); } diff --git a/crates/reims-vgpu-core/src/testkit/death.rs b/crates/reims-vgpu-vulkan/src/core/testkit/death.rs similarity index 95% rename from crates/reims-vgpu-core/src/testkit/death.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/death.rs index 76efe58d7..2cb7efed0 100644 --- a/crates/reims-vgpu-core/src/testkit/death.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/death.rs @@ -54,14 +54,14 @@ use std::sync::OnceLock; use std::sync::atomic::{AtomicPtr, AtomicU32, AtomicU64, AtomicUsize, Ordering}; use std::time::{Duration, Instant}; -use crate::num::{ToU64, ToUsize, Truncate}; -use crate::raise::death::DeathSite; -use crate::sync::Mutex; -use crate::testkit::capture::DeathSlot; -use crate::testkit::capture::VirtualTime; -use crate::testkit::capture::set_capture_enabled; -use crate::testkit::capture::with_slot; -use crate::testkit::guest_ram::{GuestRam, RawRegion}; +use crate::core::num::{ToU64, ToUsize, Truncate}; +use crate::core::raise::death::DeathSite; +use crate::core::sync::Mutex; +use crate::core::testkit::capture::DeathSlot; +use crate::core::testkit::capture::VirtualTime; +use crate::core::testkit::capture::set_capture_enabled; +use crate::core::testkit::capture::with_slot; +use crate::core::testkit::guest_ram::{GuestRam, RawRegion}; /// The environment marker: set to the full test name in the child that runs it. pub const ENV_CHILD: &str = "REIMS_VGPU_DEATH_CHILD"; @@ -1426,8 +1426,8 @@ macro_rules! death_test { $(#[$meta])* #[test] fn $name() { - $crate::testkit::death::run( - $crate::testkit::death::Expect::Death, + $crate::core::testkit::death::run( + $crate::core::testkit::death::Expect::Death, $opts, module_path!(), stringify!($name), @@ -1439,7 +1439,7 @@ macro_rules! death_test { ($(#[$meta:meta])* $name:ident, $body:expr, $check:expr $(,)?) => { $crate::death_test!( $(#[$meta])* $name, - options = $crate::testkit::death::Options::default(), + options = $crate::core::testkit::death::Options::default(), $body, $check ); @@ -1448,7 +1448,7 @@ macro_rules! death_test { /// A test whose body hangs: `hang_test!(name, |t| { …; t.hang(&clock, d, f) }, |r| check)`. /// As [`death_test!`], but the parent asserts a hang -/// ([`Child::hang`](crate::testkit::death::Child::hang)) with nothing recorded after it. It takes +/// ([`Child::hang`](crate::core::testkit::death::Child::hang)) with nothing recorded after it. It takes /// `options = …` as `death_test!` does. #[macro_export] macro_rules! hang_test { @@ -1456,8 +1456,8 @@ macro_rules! hang_test { $(#[$meta])* #[test] fn $name() { - $crate::testkit::death::run( - $crate::testkit::death::Expect::Hang, + $crate::core::testkit::death::run( + $crate::core::testkit::death::Expect::Hang, $opts, module_path!(), stringify!($name), @@ -1469,7 +1469,7 @@ macro_rules! hang_test { ($(#[$meta:meta])* $name:ident, $body:expr, $check:expr $(,)?) => { $crate::hang_test!( $(#[$meta])* $name, - options = $crate::testkit::death::Options::default(), + options = $crate::core::testkit::death::Options::default(), $body, $check ); @@ -1479,11 +1479,11 @@ macro_rules! hang_test { #[cfg(test)] mod tests { use super::*; - use crate::platform::os::{Clock as _, Deadline, MonoTime}; - use crate::raise::death::DeathKind; - use crate::raise::death::DeathSite; - use crate::testkit::capture::capture_enabled; - use crate::testkit::clock::VirtualClock; + use crate::core::platform::os::{Clock as _, Deadline, MonoTime}; + use crate::core::raise::death::DeathKind; + use crate::core::raise::death::DeathSite; + use crate::core::testkit::capture::capture_enabled; + use crate::core::testkit::clock::VirtualClock; use std::sync::Arc; use std::sync::atomic::AtomicBool; @@ -1529,7 +1529,10 @@ mod tests { t.op(&format!("capture={}", capture_enabled())); ram.write_u32(0x1_0000_0040, 0xdead_beef); t.op("effect"); - crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_t") + crate::core::testkit::capture::die( + crate::core::raise::death::DeathKind::Abort, + "site_t", + ) }, |r| { let d = r.assert_died_at(SITE, "effect"); @@ -1562,7 +1565,10 @@ mod tests { std::thread::sleep(Duration::from_millis(50)); t.op("first: dying"); let _held = held; - crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_t") + crate::core::testkit::capture::die( + crate::core::raise::death::DeathKind::Abort, + "site_t", + ) }, |r| { let d = r.assert_died_at(SITE, "first: dying"); @@ -1592,7 +1598,10 @@ mod tests { ram.write_u64(0x2_0000_0008, 0x0123_4567_89ab_cdef); assert!(root.store_16_atomic(0, 5, 6)); trace("wrote"); - crate::testkit::capture::die(crate::raise::death::DeathKind::NullDeref, "site_w") + crate::core::testkit::capture::die( + crate::core::raise::death::DeathKind::NullDeref, + "site_w", + ) }); park_forever() }, @@ -1788,8 +1797,8 @@ mod tests { ] ); assert_eq!( - test_name("reims_vgpu_core::testkit::death::tests", "x"), - "testkit::death::tests::x" + test_name("reims_vgpu_vulkan::core::testkit::death::tests", "x"), + "core::testkit::death::tests::x" ); assert_eq!(test_name("machines_guest", "x"), "x"); } @@ -1889,7 +1898,10 @@ mod tests { std::hint::spin_loop(); } t.op("dying"); - crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_t") + crate::core::testkit::capture::die( + crate::core::raise::death::DeathKind::Abort, + "site_t", + ) }, |r| { let d = r.assert_died(SITE); @@ -1918,8 +1930,8 @@ mod tests { /// the op that preceded it, not at the worker's stale op a_death_on_a_reused_worker_is_at_the_op_before_it, |t| { - let q = crate::rt::queue::SerialQueue::new( - &crate::testkit::threads::FakeThreads::default(), + let q = crate::core::rt::queue::SerialQueue::new( + &crate::core::testkit::threads::FakeThreads::default(), "A", ); let done = Arc::new(AtomicBool::new(false)); @@ -1932,7 +1944,10 @@ mod tests { wait_until(|| done.load(Ordering::Acquire)); t.op("body: submit C"); q.exec_async(|| { - crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_t") + crate::core::testkit::capture::die( + crate::core::raise::death::DeathKind::Abort, + "site_t", + ) }); park_forever() }, @@ -1953,10 +1968,10 @@ mod tests { /// A dying block on one of two workers that each ran a block is at the op before it a_death_on_either_of_two_workers_is_at_the_op_before_it, |t| { - let threads = crate::testkit::threads::FakeThreads::default(); + let threads = crate::core::testkit::threads::FakeThreads::default(); let (qa, qb) = ( - crate::rt::queue::SerialQueue::new(&threads, "A"), - crate::rt::queue::SerialQueue::new(&threads, "B"), + crate::core::rt::queue::SerialQueue::new(&threads, "A"), + crate::core::rt::queue::SerialQueue::new(&threads, "B"), ); let go = Arc::new(AtomicBool::new(false)); let started = Arc::new(AtomicUsize::new(0)); @@ -1978,7 +1993,10 @@ mod tests { wait_until(|| finished.load(Ordering::Acquire) == 2); t.op("body: submit C"); qa.exec_async(|| { - crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_t") + crate::core::testkit::capture::die( + crate::core::raise::death::DeathKind::Abort, + "site_t", + ) }); park_forever() }, @@ -2004,7 +2022,10 @@ mod tests { let base = SHARED.load(Ordering::Acquire); let _ = header_u64(base, H_CURSOR).fetch_add(1, Ordering::AcqRel); t.op("after"); - crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_t") + crate::core::testkit::capture::die( + crate::core::raise::death::DeathKind::Abort, + "site_t", + ) }, |r| { assert!(r.torn()); @@ -2058,7 +2079,7 @@ mod tests { } let out = Command::new(std::env::current_exe().unwrap()) .args([ - "testkit::death::tests::a_stack_overflow_without_the_harness_aborts", + "core::testkit::death::tests::a_stack_overflow_without_the_harness_aborts", "--exact", "--nocapture", "--test-threads=1", @@ -2112,7 +2133,10 @@ mod tests { child.op("body: returning"); child.finish(); named("late", || { - crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_t") + crate::core::testkit::capture::die( + crate::core::raise::death::DeathKind::Abort, + "site_t", + ) }); park_forever() } @@ -2133,13 +2157,13 @@ mod tests { let go = Arc::new(AtomicBool::new(false)); let g2 = go.clone(); let judged = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - crate::testkit::capture::expect_death(SITE, move || { - let slot = crate::testkit::capture::current_slot(); + crate::core::testkit::capture::expect_death(SITE, move || { + let slot = crate::core::testkit::capture::current_slot(); named("late", move || { - crate::testkit::capture::with_slot(slot, || { + crate::core::testkit::capture::with_slot(slot, || { wait_until(|| g2.load(Ordering::Acquire)); - crate::testkit::capture::die( - crate::raise::death::DeathKind::Abort, + crate::core::testkit::capture::die( + crate::core::raise::death::DeathKind::Abort, "site_t", ) }) @@ -2159,8 +2183,8 @@ mod tests { #[should_panic(expected = "expected a death")] a_death_deferred_past_the_call_fails, |t| { - let q = crate::rt::queue::SerialQueue::new( - &crate::testkit::threads::FakeThreads::default(), + let q = crate::core::rt::queue::SerialQueue::new( + &crate::core::testkit::threads::FakeThreads::default(), "Q", ); t.op("body: calling"); @@ -2168,7 +2192,10 @@ mod tests { q.exec_async(|| { let base = SHARED.load(Ordering::Acquire); wait_until(|| header_u32(base, H_STATE).load(Ordering::Acquire) == STATE_RETURNED); - crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_t") + crate::core::testkit::capture::die( + crate::core::raise::death::DeathKind::Abort, + "site_t", + ) }); // The call returned: the body is done. std::mem::forget(q); @@ -2272,7 +2299,10 @@ mod tests { |_| { printed_not_marked("a", "site_a", 0); named("b", || { - crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_b") + crate::core::testkit::capture::die( + crate::core::raise::death::DeathKind::Abort, + "site_b", + ) }); park_forever() }, @@ -2328,7 +2358,10 @@ mod tests { }); wait_until(|| marked.load(Ordering::Acquire)); named("b", || { - crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_b") + crate::core::testkit::capture::die( + crate::core::raise::death::DeathKind::Abort, + "site_b", + ) }); park_forever() }, @@ -2354,7 +2387,10 @@ mod tests { /// A hang test whose body dies fails (the outcome check) #[should_panic(expected = "expected a hang")] a_hang_test_whose_body_dies_fails, - |_| crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_t"), + |_| crate::core::testkit::capture::die( + crate::core::raise::death::DeathKind::Abort, + "site_t" + ), |_| {} ); @@ -2375,7 +2411,10 @@ mod tests { }); assert!(unwound.is_err()); named("late", || { - crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_t") + crate::core::testkit::capture::die( + crate::core::raise::death::DeathKind::Abort, + "site_t", + ) }); park_forever() } @@ -2400,13 +2439,13 @@ mod tests { let go = Arc::new(AtomicBool::new(false)); let g2 = go.clone(); let judged = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - crate::testkit::capture::expect_death(SITE, move || { - let slot = crate::testkit::capture::current_slot(); + crate::core::testkit::capture::expect_death(SITE, move || { + let slot = crate::core::testkit::capture::current_slot(); named("late", move || { - crate::testkit::capture::with_slot(slot, || { + crate::core::testkit::capture::with_slot(slot, || { wait_until(|| g2.load(Ordering::Acquire)); - crate::testkit::capture::die( - crate::raise::death::DeathKind::Abort, + crate::core::testkit::capture::die( + crate::core::raise::death::DeathKind::Abort, "site_t", ) }) @@ -2433,7 +2472,10 @@ mod tests { named("late", || { let base = SHARED.load(Ordering::Acquire); wait_until(|| header_u32(base, H_STATE).load(Ordering::Acquire) == STATE_PANICKED); - crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_t") + crate::core::testkit::capture::die( + crate::core::raise::death::DeathKind::Abort, + "site_t", + ) }); t.op("body: checking"); assert_eq!( diff --git a/crates/reims-vgpu-core/src/testkit/death/sys.rs b/crates/reims-vgpu-vulkan/src/core/testkit/death/sys.rs similarity index 100% rename from crates/reims-vgpu-core/src/testkit/death/sys.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/death/sys.rs diff --git a/crates/reims-vgpu-core/src/testkit/death/sys/linux.rs b/crates/reims-vgpu-vulkan/src/core/testkit/death/sys/linux.rs similarity index 100% rename from crates/reims-vgpu-core/src/testkit/death/sys/linux.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/death/sys/linux.rs diff --git a/crates/reims-vgpu-core/src/testkit/death/sys/macos.rs b/crates/reims-vgpu-vulkan/src/core/testkit/death/sys/macos.rs similarity index 100% rename from crates/reims-vgpu-core/src/testkit/death/sys/macos.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/death/sys/macos.rs diff --git a/crates/reims-vgpu-core/src/testkit/faults.rs b/crates/reims-vgpu-vulkan/src/core/testkit/faults.rs similarity index 92% rename from crates/reims-vgpu-core/src/testkit/faults.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/faults.rs index dce66f327..6f4d1ba6b 100644 --- a/crates/reims-vgpu-core/src/testkit/faults.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/faults.rs @@ -8,8 +8,8 @@ //! are consulted in the order they were added. use super::script::{HeldCall, Key, Script, Step}; -use crate::platform::ObjId; -use crate::platform::types::NsErrorText; +use crate::core::platform::ObjId; +use crate::core::platform::types::NsErrorText; /// What happens at the faulted call. #[derive(Debug, Clone)] @@ -78,14 +78,14 @@ impl Faults { #[cfg(test)] mod tests { use super::*; - use crate::platform::Handle; - use crate::platform::blit::{BlitCmd, BlitEncoder}; - use crate::platform::command::{CommandBuffer, CommandQueue}; - use crate::platform::compute::{ComputeCmd, ComputeEncoder}; - use crate::platform::device::GpuDevice; - use crate::raise::OnFault; + use crate::core::platform::Handle; + use crate::core::platform::blit::{BlitCmd, BlitEncoder}; + use crate::core::platform::command::{CommandBuffer, CommandQueue}; + use crate::core::platform::compute::{ComputeCmd, ComputeEncoder}; + use crate::core::platform::device::GpuDevice; + use crate::core::raise::OnFault; - use crate::testkit::FakePlatform; + use crate::core::testkit::FakePlatform; /// A fault keyed by one class leaves another class's same selector alone, and lets `skip` /// calls of its own pass first diff --git a/crates/reims-vgpu-core/src/testkit/guest_ram.rs b/crates/reims-vgpu-vulkan/src/core/testkit/guest_ram.rs similarity index 99% rename from crates/reims-vgpu-core/src/testkit/guest_ram.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/guest_ram.rs index e8dda8647..71a7b2c82 100644 --- a/crates/reims-vgpu-core/src/testkit/guest_ram.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/guest_ram.rs @@ -12,10 +12,10 @@ use std::alloc::{Layout, alloc_zeroed}; use std::sync::Arc; -use crate::sync::Mutex; +use crate::core::sync::Mutex; -use crate::host::{HostPtr, PhysicalMemoryRange}; -use crate::num::{ToU64, ToUsize}; +use crate::core::host::{HostPtr, PhysicalMemoryRange}; +use crate::core::num::{ToU64, ToUsize}; // A vCPU's one 16-byte store and load, in one file per architecture. #[cfg_attr(target_arch = "aarch64", path = "guest_ram/raw/aarch64.rs")] diff --git a/crates/reims-vgpu-core/src/testkit/guest_ram/raw/aarch64.rs b/crates/reims-vgpu-vulkan/src/core/testkit/guest_ram/raw/aarch64.rs similarity index 100% rename from crates/reims-vgpu-core/src/testkit/guest_ram/raw/aarch64.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/guest_ram/raw/aarch64.rs diff --git a/crates/reims-vgpu-core/src/testkit/guest_ram/raw/x86_64.rs b/crates/reims-vgpu-vulkan/src/core/testkit/guest_ram/raw/x86_64.rs similarity index 100% rename from crates/reims-vgpu-core/src/testkit/guest_ram/raw/x86_64.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/guest_ram/raw/x86_64.rs diff --git a/crates/reims-vgpu-core/src/testkit/impls/blit.rs b/crates/reims-vgpu-vulkan/src/core/testkit/impls/blit.rs similarity index 98% rename from crates/reims-vgpu-core/src/testkit/impls/blit.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/impls/blit.rs index 79df2cf73..28b1b5d05 100644 --- a/crates/reims-vgpu-core/src/testkit/impls/blit.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/impls/blit.rs @@ -9,9 +9,9 @@ use super::super::calllog::Arg; use super::super::objects::{Fk, kind}; use super::super::platform::FakePlatform; use super::res_id; -use crate::platform::blit::*; -use crate::raise::{OnFault, RaiseResult}; -use crate::testkit::script::Policy; +use crate::core::platform::blit::*; +use crate::core::raise::{OnFault, RaiseResult}; +use crate::core::testkit::script::Policy; /// The name the fake logs and scripts [`BlitEncoder::copy_from_guest_ram`] under, with the runs /// (each run's start and end, in order), the destination and its offset: no selector of Metal's @@ -34,7 +34,7 @@ impl BlitEncoder for Fk { &self, on: OnFault, runs: &[Range], - destination: &::Buffer, + destination: &::Buffer, destination_offset: u64, ) -> RaiseResult { let copies = self.world().copies_guest_ram(); @@ -49,7 +49,7 @@ impl BlitEncoder for Fk { fn copy_to_guest_ram( &self, on: OnFault, - source: &::Buffer, + source: &::Buffer, source_offset: u64, runs: &[Range], ) -> RaiseResult { diff --git a/crates/reims-vgpu-core/src/testkit/impls/command.rs b/crates/reims-vgpu-vulkan/src/core/testkit/impls/command.rs similarity index 91% rename from crates/reims-vgpu-core/src/testkit/impls/command.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/impls/command.rs index d5766d684..66eb36606 100644 --- a/crates/reims-vgpu-core/src/testkit/impls/command.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/impls/command.rs @@ -8,11 +8,11 @@ use super::super::calllog::Arg; use super::super::objects::{CommandBufferModel, Fk, Model, completion_read, kind}; use super::super::platform::FakePlatform; use super::fatal; -use crate::platform::command::*; -use crate::platform::types::{CommandBufferStatus, NsErrorText}; -use crate::platform::{EventRef, Platform}; -use crate::raise::{OnFault, RaiseResult}; -use crate::testkit::script::Policy; +use crate::core::platform::command::*; +use crate::core::platform::types::{CommandBufferStatus, NsErrorText}; +use crate::core::platform::{EventRef, Platform}; +use crate::core::raise::{OnFault, RaiseResult}; +use crate::core::testkit::script::Policy; impl CommandQueue for Fk { fn command_buffer( @@ -43,7 +43,7 @@ impl CommandBuffer for Fk { "addCompletedHandler:", vec![Arg::Block(true)], )?; - let carried = crate::raise::refusals::carry(); + let carried = crate::core::raise::refusals::carry(); let block: CompletedHandler = Box::new(move |info| { run_completed(carried, || completion_read(info), block); }); @@ -90,7 +90,7 @@ impl CommandBuffer for Fk { "addCompletionSeenHandler", vec![Arg::Block(true)], )?; - let carried = crate::raise::refusals::carry(); + let carried = crate::core::raise::refusals::carry(); let block: CompletedHandler = Box::new(move |info| { run_completed(carried, || completion_read(info), block); }); @@ -111,12 +111,14 @@ impl CommandBuffer for Fk { /// Its submission handlers, and those of the buffers the world takes at this commit /// ([`World::release_submissions_at_next_commit`]), run inside the call, marked so - /// ([`crate::platform::command::committing`]), as the Vulkan platform's runtime runs them. + /// ([`crate::core::platform::command::committing`]), as the Vulkan platform's runtime runs them. /// - /// [`World::release_submissions_at_next_commit`]: crate::testkit::objects::World::release_submissions_at_next_commit + /// [`World::release_submissions_at_next_commit`]: crate::core::testkit::objects::World::release_submissions_at_next_commit fn commit(&self, on: OnFault) -> RaiseResult<()> { self.act(Policy::On(on), "commit", vec![])?; - crate::platform::command::committing(|| super::super::objects::commit_obj(self.obj())); + crate::core::platform::command::committing(|| { + super::super::objects::commit_obj(self.obj()) + }); Ok(()) } @@ -254,7 +256,7 @@ impl CommandBuffer for Fk { /// A new encoder, with the value in the log. fn compute_encoder_for_pass( &self, - desc: &crate::platform::values::ComputePassDesc, + desc: &crate::core::platform::values::ComputePassDesc, ) -> RaiseResult::ComputeEncoder>> { self.make( Policy::Caught, diff --git a/crates/reims-vgpu-core/src/testkit/impls/compute.rs b/crates/reims-vgpu-vulkan/src/core/testkit/impls/compute.rs similarity index 98% rename from crates/reims-vgpu-core/src/testkit/impls/compute.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/impls/compute.rs index ee43ef4b3..866df0706 100644 --- a/crates/reims-vgpu-core/src/testkit/impls/compute.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/impls/compute.rs @@ -7,10 +7,10 @@ use super::super::calllog::Arg; use super::super::objects::{Fk, kind}; use super::super::platform::FakePlatform; use super::res_ids; -use crate::platform::Platform; -use crate::platform::compute::*; -use crate::raise::{OnFault, RaiseResult}; -use crate::testkit::script::Policy; +use crate::core::platform::Platform; +use crate::core::platform::compute::*; +use crate::core::raise::{OnFault, RaiseResult}; +use crate::core::testkit::script::Policy; impl ComputeEncoder for Fk { fn encode(&self, on: OnFault, cmd: ComputeCmd<'_, FakePlatform>) -> RaiseResult<()> { diff --git a/crates/reims-vgpu-core/src/testkit/impls/descriptor.rs b/crates/reims-vgpu-vulkan/src/core/testkit/impls/descriptor.rs similarity index 98% rename from crates/reims-vgpu-core/src/testkit/impls/descriptor.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/impls/descriptor.rs index a07ca7949..c2b22350e 100644 --- a/crates/reims-vgpu-core/src/testkit/impls/descriptor.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/impls/descriptor.rs @@ -8,20 +8,20 @@ //! mode, and `setSamplePositions:count:`, which Metal checks); the others write the model, and the //! getters read it. -use crate::testkit::script::Policy; +use crate::core::testkit::script::Policy; use std::collections::BTreeMap; use super::super::calllog::Arg; use super::super::objects::{AnyHandle, Fk, Kind, TexDesc, kind}; use super::super::platform::FakePlatform; -use crate::platform::ObjId; -use crate::platform::descriptor::*; -use crate::platform::types::{ClearColor, MtlSamplePosition}; -use crate::platform::values::{ +use crate::core::platform::ObjId; +use crate::core::platform::descriptor::*; +use crate::core::platform::types::{ClearColor, MtlSamplePosition}; +use crate::core::platform::values::{ AttachmentState, ColorAttachmentSet, DepthAttachmentSet, PassSet, StencilAttachmentSet, TextureDesc, }; -use crate::raise::{OnFault, RaiseResult}; +use crate::core::raise::{OnFault, RaiseResult}; /// A texture descriptor's model. #[derive(Debug, Default)] diff --git a/crates/reims-vgpu-core/src/testkit/impls/device.rs b/crates/reims-vgpu-vulkan/src/core/testkit/impls/device.rs similarity index 98% rename from crates/reims-vgpu-core/src/testkit/impls/device.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/impls/device.rs index 81857c9d0..9ef26629c 100644 --- a/crates/reims-vgpu-core/src/testkit/impls/device.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/impls/device.rs @@ -4,7 +4,7 @@ //! (`fake::script`) before its model; a value's creator logs the value. The device's //! capabilities come from its [`DeviceModel`], neither logged nor scripted. -use crate::testkit::script::Policy; +use crate::core::testkit::script::Policy; use std::sync::Arc; use super::super::calllog::Arg; @@ -16,22 +16,22 @@ use super::icb::IcbModel; use super::rate_map::RateMapModel; use super::resource::{MeshLimits, PipelineModel}; use super::{Backing, common, new_buffer, new_state, new_texture}; -use crate::num; -use crate::platform::caps::{ +use crate::core::num; +use crate::core::platform::caps::{ self, DeviceCaps, FormatAnswers, IdentityCaps, IdentityFlags, IdentitySizes, }; -use crate::platform::device::*; -use crate::platform::types::{ +use crate::core::platform::device::*; +use crate::core::platform::types::{ ArgumentKind, ArgumentLayout, ArgumentMember, MtlSize, NsErrorText, PixelFormatInfo, SizeAndAlign, TextureLevelInfo, TextureLevelQuery, }; -use crate::platform::values::{ +use crate::core::platform::values::{ ArgumentDesc, BufferDesc, DepthStencilDesc, FullComputePipelineDesc, FullMeshRenderPipelineDesc, FullRenderPipelineDesc, HeapDesc, HeapMade, IcbDesc, OptionSet, PagesInPlace, PagesPlane, RenderPipelineDesc, SamplerDesc, }; -use crate::platform::{Handle, HostRange, Platform}; -use crate::raise::{OnFault, RaiseResult}; +use crate::core::platform::{Handle, HostRange, Platform}; +use crate::core::raise::{OnFault, RaiseResult}; /// The name the fake logs and scripts [`GpuDevice::new_command_queue_unshared`] under: no selector /// of Metal's names it. @@ -146,8 +146,8 @@ impl GpuDevice for Fk { |w| { let s = surface?; let (base, len) = ( - crate::platform::os::surface::Surface::base_address(&s), - crate::platform::os::surface::Surface::alloc_size(&s), + crate::core::platform::os::surface::Surface::base_address(&s), + crate::core::platform::os::surface::Surface::alloc_size(&s), ); let b = new_buffer(w, len, 0, Backing::At(base), None)?; if let Model::Buffer(m) = &mut b.state().model { @@ -188,14 +188,14 @@ impl GpuDevice for Fk { /// Unlogged, as the property the platform answers it from: [`World::copy_guest_ram`]. /// - /// [`World::copy_guest_ram`]: crate::testkit::objects::World::copy_guest_ram + /// [`World::copy_guest_ram`]: crate::core::testkit::objects::World::copy_guest_ram fn copies_guest_ram(&self) -> bool { self.world().copies_guest_ram() } /// Unlogged, as the world answers it: [`World::answer_surface_pages`]. /// - /// [`World::answer_surface_pages`]: crate::testkit::objects::World::answer_surface_pages + /// [`World::answer_surface_pages`]: crate::core::testkit::objects::World::answer_surface_pages fn surface_pages_in_place( &self, _pages: &::Buffer, diff --git a/crates/reims-vgpu-core/src/testkit/impls/event.rs b/crates/reims-vgpu-vulkan/src/core/testkit/impls/event.rs similarity index 90% rename from crates/reims-vgpu-core/src/testkit/impls/event.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/impls/event.rs index 93e1a3b79..44f5ec0e8 100644 --- a/crates/reims-vgpu-core/src/testkit/impls/event.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/impls/event.rs @@ -7,10 +7,10 @@ use super::super::calllog::Arg; use super::super::objects::{Fk, kind}; use super::super::platform::FakePlatform; use super::fatal; -use crate::platform::Platform; -use crate::platform::event::*; -use crate::raise::RaiseResult; -use crate::testkit::script::Policy; +use crate::core::platform::Platform; +use crate::core::platform::event::*; +use crate::core::raise::RaiseResult; +use crate::core::testkit::script::Policy; impl SharedEvent for Fk { fn set_signaled_value(&self, signaled_value: u64) -> RaiseResult<()> { @@ -50,7 +50,7 @@ impl SharedEvent for Fk { value: u64, block: Notification, ) -> RaiseResult<()> { - use crate::platform::Handle as _; + use crate::core::platform::Handle as _; self.act( Policy::Caught, "notifyListener:atValue:block:", diff --git a/crates/reims-vgpu-core/src/testkit/impls/icb.rs b/crates/reims-vgpu-vulkan/src/core/testkit/impls/icb.rs similarity index 99% rename from crates/reims-vgpu-core/src/testkit/impls/icb.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/impls/icb.rs index 67592dd14..61d41c0d4 100644 --- a/crates/reims-vgpu-core/src/testkit/impls/icb.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/impls/icb.rs @@ -4,16 +4,16 @@ //! logs its encoded commands, which are ordered, and records what they set in its //! [`IcbCommandModel`], which the free read-back getters answer from. -use crate::testkit::script::Policy; +use crate::core::testkit::script::Policy; use std::collections::BTreeMap; use super::super::calllog::Arg; use super::super::objects::{Fk, Kind, Model, ResourceCommon, kind}; use super::super::platform::FakePlatform; -use crate::platform::Platform; -use crate::platform::icb::*; -use crate::platform::types::{MtlRegion, MtlSize}; -use crate::raise::RaiseResult; +use crate::core::platform::Platform; +use crate::core::platform::icb::*; +use crate::core::platform::types::{MtlRegion, MtlSize}; +use crate::core::raise::RaiseResult; /// An indirect command buffer's model. #[derive(Debug, Default)] diff --git a/crates/reims-vgpu-core/src/testkit/impls/mod.rs b/crates/reims-vgpu-vulkan/src/core/testkit/impls/mod.rs similarity index 90% rename from crates/reims-vgpu-core/src/testkit/impls/mod.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/impls/mod.rs index aad2eba7a..0a255f29c 100644 --- a/crates/reims-vgpu-core/src/testkit/impls/mod.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/impls/mod.rs @@ -33,14 +33,14 @@ use super::objects::{ TextureModel, World, kind, }; use super::script::Policy; -use crate::host::HostPtr; -use crate::platform::Handle; -use crate::platform::blit::ResourceRef; -use crate::platform::types::NsErrorText; -use crate::raise::RaiseResult; +use crate::core::host::HostPtr; +use crate::core::platform::Handle; +use crate::core::platform::blit::ResourceRef; +use crate::core::platform::types::NsErrorText; +use crate::core::raise::RaiseResult; /// The identity of a resource argument. -pub fn res_id(r: &ResourceRef<'_, super::platform::FakePlatform>) -> crate::platform::ObjId { +pub fn res_id(r: &ResourceRef<'_, super::platform::FakePlatform>) -> crate::core::platform::ObjId { match r { ResourceRef::Buffer(b) => b.id(), ResourceRef::Texture(t) => t.id(), @@ -277,14 +277,14 @@ mod tests { use super::super::platform::FakePlatform; use super::super::script::Step; use super::*; - use crate::platform::Platform; - use crate::platform::command::{CommandBuffer, CommandQueue}; - use crate::platform::device::GpuDevice; - use crate::platform::event::SharedEvent; - use crate::platform::resource::{Buffer, GpuResource, Texture}; - use crate::platform::types::{CommandBufferStatus, MtlSize}; - use crate::platform::values::{IcbDesc, RateMapDesc, TextureDesc}; - use crate::raise::OnFault; + use crate::core::platform::Platform; + use crate::core::platform::command::{CommandBuffer, CommandQueue}; + use crate::core::platform::device::GpuDevice; + use crate::core::platform::event::SharedEvent; + use crate::core::platform::resource::{Buffer, GpuResource, Texture}; + use crate::core::platform::types::{CommandBufferStatus, MtlSize}; + use crate::core::platform::values::{IcbDesc, RateMapDesc, TextureDesc}; + use crate::core::raise::OnFault; /// Buffers get a GPU VA, contents unless private, and refuse past the fake's limit #[test] @@ -345,7 +345,7 @@ mod tests { let p = FakePlatform::new(); let q = p.device().new_command_queue().unwrap(); let cb = q.command_buffer(OnFault::Die).unwrap().unwrap(); - let seen = Arc::new(crate::sync::Mutex::new(Vec::new())); + let seen = Arc::new(crate::core::sync::Mutex::new(Vec::new())); let s = seen.clone(); cb.add_completed_handler(OnFault::Die, Box::new(move |i| s.lock().push(i.status))) .unwrap(); @@ -362,7 +362,7 @@ mod tests { /// A device answers the fake's default caps until a test sets its own #[test] fn device_caps() { - use crate::platform::caps::DeviceCaps; + use crate::core::platform::caps::DeviceCaps; let p = FakePlatform::new(); let d = p.device(); let read = d.caps(); @@ -372,7 +372,7 @@ mod tests { let mut caps = DeviceCaps::clone(&read); caps.limits.max_viewport_count = 3; caps.flags.supports_tile_shaders = false; - caps.families[0] = Err(crate::raise::Raise::foreign("supportsFamily:")); + caps.families[0] = Err(crate::core::raise::Raise::foreign("supportsFamily:")); caps.gpu_core_count = None; d.set_caps(caps.clone()); assert_eq!(*d.caps(), caps); @@ -381,11 +381,11 @@ mod tests { /// The model setters change what the free getters answer, and log nothing #[test] fn model_setters() { - use crate::platform::descriptor::TextureDescriptor; - use crate::platform::icb::{IndirectCommandBuffer, IndirectRenderCommand}; - use crate::platform::rate_map::{RateMap, RateMapDescriptor, RateMapLayerDescriptor}; - use crate::platform::resource::ComputePipeline; - use crate::platform::types::SizeAndAlign; + use crate::core::platform::descriptor::TextureDescriptor; + use crate::core::platform::icb::{IndirectCommandBuffer, IndirectRenderCommand}; + use crate::core::platform::rate_map::{RateMap, RateMapDescriptor, RateMapLayerDescriptor}; + use crate::core::platform::resource::ComputePipeline; + use crate::core::platform::types::SizeAndAlign; let p = FakePlatform::new(); let d = p.device(); let td = p.texture_descriptor(&TextureDesc { @@ -415,8 +415,8 @@ mod tests { .unwrap(); let quiet = p.call_log().mark(); layer.set_sample_count(MtlSize::new(1, 1, 0)); - layer.set_horizontal_sample_storage(crate::host::HostPtr::NULL); - layer.set_vertical_sample_storage(crate::host::HostPtr::from_addr(0x40)); + layer.set_horizontal_sample_storage(crate::core::host::HostPtr::NULL); + layer.set_vertical_sample_storage(crate::core::host::HostPtr::from_addr(0x40)); assert!(p.call_log().since(quiet).is_empty()); assert_eq!(layer.sample_count(), MtlSize::new(1, 1, 0)); assert!(layer.horizontal_sample_storage().is_null()); @@ -447,7 +447,7 @@ mod tests { cmd.set_command_type(0x10); assert_eq!(cmd.command_type(), 0x10); assert_eq!(cmd.draw_args(), None); - cmd.encode(crate::platform::icb::IcbRenderCmd::DrawPrimitives { + cmd.encode(crate::core::platform::icb::IcbRenderCmd::DrawPrimitives { primitive_type: 3, vertex_start: 1, vertex_count: 6, @@ -457,7 +457,7 @@ mod tests { .unwrap(); assert_eq!( cmd.draw_args(), - Some(crate::platform::icb::DrawArgs { + Some(crate::core::platform::icb::DrawArgs { primitive_type: 3, vertex_start: 1, vertex_count: 6, @@ -466,13 +466,13 @@ mod tests { }) ); // A reset forgets the draw and its type. - cmd.encode(crate::platform::icb::IcbRenderCmd::Reset) + cmd.encode(crate::core::platform::icb::IcbRenderCmd::Reset) .unwrap(); assert_eq!((cmd.draw_args(), cmd.command_type()), (None, 0)); let compute = icb.compute_command(1).unwrap().unwrap(); compute.set_command_type(0x20); assert_eq!( - crate::platform::icb::IndirectComputeCommand::command_type(&compute), + crate::core::platform::icb::IndirectComputeCommand::command_type(&compute), 0x20 ); } diff --git a/crates/reims-vgpu-core/src/testkit/impls/rate_map.rs b/crates/reims-vgpu-vulkan/src/core/testkit/impls/rate_map.rs similarity index 96% rename from crates/reims-vgpu-core/src/testkit/impls/rate_map.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/impls/rate_map.rs index bbc8199e2..a3154b33c 100644 --- a/crates/reims-vgpu-core/src/testkit/impls/rate_map.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/impls/rate_map.rs @@ -4,7 +4,7 @@ //! index); a rate map holds what it was made from. The ordered calls (`setLayer:atIndex:`, the //! map's copies, mappings and reset) are logged and scripted; the getters read the models. -use crate::testkit::script::Policy; +use crate::core::testkit::script::Policy; use std::sync::Arc; use super::super::calllog::Arg; @@ -12,12 +12,12 @@ use super::super::guest_ram::RawRegion; use super::super::objects::{Fk, LayerModel, Model, ResourceCommon, World, kind}; use super::super::platform::FakePlatform; use super::fatal; -use crate::host::HostPtr; -use crate::platform::Platform; -use crate::platform::rate_map::*; -use crate::platform::types::{MtlCoordinate2D, MtlSize, SizeAndAlign}; -use crate::platform::values::RateMapDesc; -use crate::raise::{OnFault, RaiseResult}; +use crate::core::host::HostPtr; +use crate::core::platform::Platform; +use crate::core::platform::rate_map::*; +use crate::core::platform::types::{MtlCoordinate2D, MtlSize, SizeAndAlign}; +use crate::core::platform::values::RateMapDesc; +use crate::core::raise::{OnFault, RaiseResult}; /// A rasterization rate map's model. #[derive(Debug)] diff --git a/crates/reims-vgpu-core/src/testkit/impls/render.rs b/crates/reims-vgpu-vulkan/src/core/testkit/impls/render.rs similarity index 99% rename from crates/reims-vgpu-core/src/testkit/impls/render.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/impls/render.rs index cb99026ce..be8cb72f0 100644 --- a/crates/reims-vgpu-core/src/testkit/impls/render.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/impls/render.rs @@ -8,9 +8,9 @@ use super::super::calllog::Arg; use super::super::objects::{Fk, kind}; use super::super::platform::FakePlatform; use super::res_ids; -use crate::platform::render::*; -use crate::raise::{OnFault, RaiseResult}; -use crate::testkit::script::Policy; +use crate::core::platform::render::*; +use crate::core::raise::{OnFault, RaiseResult}; +use crate::core::testkit::script::Policy; impl RenderEncoder for Fk { fn encode(&self, on: OnFault, cmd: RenderCmd<'_, FakePlatform>) -> RaiseResult<()> { diff --git a/crates/reims-vgpu-core/src/testkit/impls/resource.rs b/crates/reims-vgpu-vulkan/src/core/testkit/impls/resource.rs similarity index 98% rename from crates/reims-vgpu-core/src/testkit/impls/resource.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/impls/resource.rs index 98b90f854..c80648739 100644 --- a/crates/reims-vgpu-core/src/testkit/impls/resource.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/impls/resource.rs @@ -8,13 +8,13 @@ use super::super::calllog::Arg; use super::super::objects::{Fk, Model, ResourceCommon, TexDesc, TextureModel, kind}; use super::super::platform::FakePlatform; use super::{Backing, new_buffer, new_texture}; -use crate::host::HostPtr; -use crate::platform::resource::*; -use crate::platform::types::{MtlRegion, MtlSize, NsRange, Swizzle}; -use crate::platform::values::SurfacePlane; -use crate::platform::{Handle, HostRange, Platform}; -use crate::raise::{OnFault, RaiseResult}; -use crate::testkit::script::Policy; +use crate::core::host::HostPtr; +use crate::core::platform::resource::*; +use crate::core::platform::types::{MtlRegion, MtlSize, NsRange, Swizzle}; +use crate::core::platform::values::SurfacePlane; +use crate::core::platform::{Handle, HostRange, Platform}; +use crate::core::raise::{OnFault, RaiseResult}; +use crate::core::testkit::script::Policy; impl Fk { /// `f` of the buffer's model; the default of `T` for a buffer a test made with no model. @@ -731,7 +731,7 @@ impl Library for Fk { &self, on: OnFault, function_name: &str, - constants: &[crate::platform::resource::FunctionConstant], + constants: &[crate::core::platform::resource::FunctionConstant], ) -> RaiseResult::Function>> { let name = function_name.to_owned(); let mut args = vec![Arg::Str(function_name.to_owned())]; @@ -752,7 +752,7 @@ impl Library for Fk { &self, on: OnFault, function_name: &str, - constants: &[crate::platform::resource::FunctionConstant], + constants: &[crate::core::platform::resource::FunctionConstant], options: u64, specialized_name: Option<&str>, ) -> RaiseResult::Function>> { diff --git a/crates/reims-vgpu-core/src/testkit/logs.rs b/crates/reims-vgpu-vulkan/src/core/testkit/logs.rs similarity index 96% rename from crates/reims-vgpu-core/src/testkit/logs.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/logs.rs index 7bfb0b2bb..5d5308d31 100644 --- a/crates/reims-vgpu-core/src/testkit/logs.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/logs.rs @@ -8,7 +8,7 @@ //! //! A test that captures relies on nextest running each test in its own process: only there are //! the lines it takes its own test's, and is the test logger sure to be the process's rather than -//! [`crate::logging`]'s. Under `cargo test`'s threads, a line another test writes during the +//! [`crate::core::logging`]'s. Under `cargo test`'s threads, a line another test writes during the //! capture is taken with it. //! //! ```ignore @@ -26,7 +26,7 @@ use std::sync::OnceLock; use log::{Level, LevelFilter, Log, Metadata, Record}; -use crate::sync::{Mutex, MutexGuard}; +use crate::core::sync::{Mutex, MutexGuard}; /// One line: its level, its target and its message. pub type Line = (Level, String, String); diff --git a/crates/reims-vgpu-core/src/testkit/metal_answers.rs b/crates/reims-vgpu-vulkan/src/core/testkit/metal_answers.rs similarity index 88% rename from crates/reims-vgpu-core/src/testkit/metal_answers.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/metal_answers.rs index 7514e961d..eb01888f1 100644 --- a/crates/reims-vgpu-core/src/testkit/metal_answers.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/metal_answers.rs @@ -31,7 +31,7 @@ use std::collections::HashMap; use std::fmt::{Debug, Display}; use std::path::{Path, PathBuf}; -use crate::sync::Mutex; +use crate::core::sync::Mutex; /// The longest byte buffer a file of answers holds as `hex`: a longer one is in its `.xz` file. pub const HEX_LIMIT: usize = 256; @@ -400,7 +400,7 @@ raw_tuple!( (0 A, 1 B, 2 C, 3 D, 4 E, 5 F, 6 G, 7 H) ); -impl Raw for crate::platform::types::TextureLevelInfo { +impl Raw for crate::core::platform::types::TextureLevelInfo { fn raw(&self, out: &mut Vec) { for v in [ self.field_0, @@ -422,7 +422,7 @@ impl Raw for crate::platform::types::TextureLevelInfo { } } -impl Raw for crate::platform::types::PixelFormatInfo { +impl Raw for crate::core::platform::types::PixelFormatInfo { fn raw(&self, out: &mut Vec) { self.name.raw(out); for v in [ @@ -442,12 +442,14 @@ impl Raw for crate::platform::types::PixelFormatInfo { #[macro_export] macro_rules! metal_check_raw { ($ours:expr $(,)?) => { - $crate::metal_check_bytes!(&$crate::testkit::metal_answers::Raw::raw_bytes(&$ours)) + $crate::metal_check_bytes!(&$crate::core::testkit::metal_answers::Raw::raw_bytes( + &$ours + )) }; ($key:expr, $ours:expr $(,)?) => { $crate::metal_check_bytes!( $key, - &$crate::testkit::metal_answers::Raw::raw_bytes(&$ours) + &$crate::core::testkit::metal_answers::Raw::raw_bytes(&$ours) ) }; } @@ -456,12 +458,14 @@ macro_rules! metal_check_raw { #[macro_export] macro_rules! metal_matches_raw { ($ours:expr $(,)?) => { - $crate::metal_matches_bytes!(&$crate::testkit::metal_answers::Raw::raw_bytes(&$ours)) + $crate::metal_matches_bytes!(&$crate::core::testkit::metal_answers::Raw::raw_bytes( + &$ours + )) }; ($key:expr, $ours:expr $(,)?) => { $crate::metal_matches_bytes!( $key, - &$crate::testkit::metal_answers::Raw::raw_bytes(&$ours) + &$crate::core::testkit::metal_answers::Raw::raw_bytes(&$ours) ) }; } @@ -470,7 +474,12 @@ macro_rules! metal_matches_raw { #[macro_export] macro_rules! metal_near { ($key:expr, $ours:expr $(,)?) => { - $crate::testkit::metal_answers::near(file!(), env!("CARGO_MANIFEST_DIR"), &$key, $ours) + $crate::core::testkit::metal_answers::near( + file!(), + env!("CARGO_MANIFEST_DIR"), + &$key, + $ours, + ) }; } @@ -478,7 +487,12 @@ macro_rules! metal_near { #[macro_export] macro_rules! metal_answer { ($key:expr, $ours:expr $(,)?) => { - $crate::testkit::metal_answers::answer(file!(), env!("CARGO_MANIFEST_DIR"), &$key, $ours) + $crate::core::testkit::metal_answers::answer( + file!(), + env!("CARGO_MANIFEST_DIR"), + &$key, + $ours, + ) }; } @@ -486,7 +500,7 @@ macro_rules! metal_answer { #[macro_export] macro_rules! metal_full { ($key:expr $(,)?) => { - $crate::testkit::metal_answers::full(file!(), env!("CARGO_MANIFEST_DIR"), &$key) + $crate::core::testkit::metal_answers::full(file!(), env!("CARGO_MANIFEST_DIR"), &$key) }; } @@ -494,7 +508,7 @@ macro_rules! metal_full { #[macro_export] macro_rules! metal_value { ($key:expr $(,)?) => { - $crate::testkit::metal_answers::value(file!(), env!("CARGO_MANIFEST_DIR"), &$key) + $crate::core::testkit::metal_answers::value(file!(), env!("CARGO_MANIFEST_DIR"), &$key) }; } @@ -502,15 +516,20 @@ macro_rules! metal_value { #[macro_export] macro_rules! metal_check { ($ours:expr $(,)?) => { - $crate::testkit::metal_answers::check( + $crate::core::testkit::metal_answers::check( file!(), env!("CARGO_MANIFEST_DIR"), - &$crate::testkit::metal_answers::next_key(file!(), env!("CARGO_MANIFEST_DIR")), + &$crate::core::testkit::metal_answers::next_key(file!(), env!("CARGO_MANIFEST_DIR")), &$ours, ) }; ($key:expr, $ours:expr $(,)?) => { - $crate::testkit::metal_answers::check(file!(), env!("CARGO_MANIFEST_DIR"), &$key, &$ours) + $crate::core::testkit::metal_answers::check( + file!(), + env!("CARGO_MANIFEST_DIR"), + &$key, + &$ours, + ) }; } @@ -518,15 +537,15 @@ macro_rules! metal_check { #[macro_export] macro_rules! metal_check_bytes { ($ours:expr $(,)?) => { - $crate::testkit::metal_answers::check_bytes( + $crate::core::testkit::metal_answers::check_bytes( file!(), env!("CARGO_MANIFEST_DIR"), - &$crate::testkit::metal_answers::next_key(file!(), env!("CARGO_MANIFEST_DIR")), + &$crate::core::testkit::metal_answers::next_key(file!(), env!("CARGO_MANIFEST_DIR")), $ours, ) }; ($key:expr, $ours:expr $(,)?) => { - $crate::testkit::metal_answers::check_bytes( + $crate::core::testkit::metal_answers::check_bytes( file!(), env!("CARGO_MANIFEST_DIR"), &$key, @@ -539,15 +558,20 @@ macro_rules! metal_check_bytes { #[macro_export] macro_rules! metal_matches { ($ours:expr $(,)?) => { - $crate::testkit::metal_answers::matches( + $crate::core::testkit::metal_answers::matches( file!(), env!("CARGO_MANIFEST_DIR"), - &$crate::testkit::metal_answers::next_key(file!(), env!("CARGO_MANIFEST_DIR")), + &$crate::core::testkit::metal_answers::next_key(file!(), env!("CARGO_MANIFEST_DIR")), &$ours, ) }; ($key:expr, $ours:expr $(,)?) => { - $crate::testkit::metal_answers::matches(file!(), env!("CARGO_MANIFEST_DIR"), &$key, &$ours) + $crate::core::testkit::metal_answers::matches( + file!(), + env!("CARGO_MANIFEST_DIR"), + &$key, + &$ours, + ) }; } @@ -555,15 +579,15 @@ macro_rules! metal_matches { #[macro_export] macro_rules! metal_matches_bytes { ($ours:expr $(,)?) => { - $crate::testkit::metal_answers::matches_bytes( + $crate::core::testkit::metal_answers::matches_bytes( file!(), env!("CARGO_MANIFEST_DIR"), - &$crate::testkit::metal_answers::next_key(file!(), env!("CARGO_MANIFEST_DIR")), + &$crate::core::testkit::metal_answers::next_key(file!(), env!("CARGO_MANIFEST_DIR")), $ours, ) }; ($key:expr, $ours:expr $(,)?) => { - $crate::testkit::metal_answers::matches_bytes( + $crate::core::testkit::metal_answers::matches_bytes( file!(), env!("CARGO_MANIFEST_DIR"), &$key, diff --git a/crates/reims-vgpu-core/src/testkit/mod.rs b/crates/reims-vgpu-vulkan/src/core/testkit/mod.rs similarity index 100% rename from crates/reims-vgpu-core/src/testkit/mod.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/mod.rs diff --git a/crates/reims-vgpu-core/src/testkit/objects.rs b/crates/reims-vgpu-vulkan/src/core/testkit/objects.rs similarity index 96% rename from crates/reims-vgpu-core/src/testkit/objects.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/objects.rs index 3e50daa6d..0e7e27d2d 100644 --- a/crates/reims-vgpu-core/src/testkit/objects.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/objects.rs @@ -33,8 +33,8 @@ use std::marker::PhantomData; use std::sync::atomic::{AtomicBool, AtomicI64, AtomicU64, Ordering}; use std::sync::{Arc, Weak}; -use crate::platform::values::{PagesInPlace, PagesPlane}; -use crate::sync::{Condvar, Mutex, MutexGuard}; +use crate::core::platform::values::{PagesInPlace, PagesPlane}; +use crate::core::sync::{Condvar, Mutex, MutexGuard}; use super::calllog::{Arg, CallLog, Event, ReleaseContext}; use super::clock::VirtualClock; @@ -46,16 +46,16 @@ use super::impls::rate_map::{RateMapDescriptorModel, RateMapModel}; use super::impls::resource::PipelineModel; use super::script::{HeldCall, Script, Step}; use super::vm::FakeVm; -use crate::host::HostPtr; -use crate::num; -use crate::platform::command::{CompletedHandler, CompletedInfo, ScheduledHandler}; -use crate::platform::device::NoCopyDeallocator; -use crate::platform::event::Notification; -use crate::platform::os::{Clock, Deadline}; -use crate::platform::types::{ +use crate::core::host::HostPtr; +use crate::core::num; +use crate::core::platform::command::{CompletedHandler, CompletedInfo, ScheduledHandler}; +use crate::core::platform::device::NoCopyDeallocator; +use crate::core::platform::event::Notification; +use crate::core::platform::os::{Clock, Deadline}; +use crate::core::platform::types::{ CommandBufferStatus, MtlSize, NsErrorText, ResourceAddressRange, Swizzle, }; -use crate::platform::{Handle, ObjId}; +use crate::core::platform::{Handle, ObjId}; /// A handle kind: the Objective-C class the fake stands in for. pub trait Kind: Send + Sync + 'static { @@ -161,7 +161,7 @@ pub const PURGEABLE_NON_VOLATILE: u64 = 2; pub enum CompleteOn { /// On the calling thread, as a foreign thread would run them: owning no queue /// (`rt::BlockEnv::foreign`), with no handler live and no holder - /// ([`Hold::NONE`](crate::rt::Hold::NONE)), as every completion handler runs, so a raise in a + /// ([`Hold::NONE`](crate::core::rt::Hold::NONE)), as every completion handler runs, so a raise in a /// handler dies as it does on Metal's completion thread. The calling thread's locks stay held, /// though, which Metal's thread never holds: use it only where the caller holds no core lock (a /// test thread, or `commit` under auto-complete from code that holds none); otherwise use @@ -411,9 +411,9 @@ pub struct SurfaceModel { /// Outstanding `IOSurfaceLock`s. pub lock_count: i64, /// The creation spec, when made by `IOSurfaceCreate`. - pub spec: Option, + pub spec: Option, /// The creation properties, when made by `initWithProperties:`. - pub backing_spec: Option, + pub backing_spec: Option, } /// A rasterization-rate layer: its sample count and sample storage. @@ -725,7 +725,7 @@ impl Drop for Fk { .push(self.id(), K::CLASS, "CFRelease", vec![]); } if !std::thread::panicking() && self.obj().world.take_release_death(self.id()) { - crate::raise::Raise::platform("release") + crate::core::raise::Raise::platform("release") .with_detail("the platform died letting go of the object") .fatal(); } @@ -937,12 +937,12 @@ pub struct World { splits: AtomicBool, /// What the devices' [`GpuDevice::copies_guest_ram`] answers ([`World::copy_guest_ram`]). /// - /// [`GpuDevice::copies_guest_ram`]: crate::platform::device::GpuDevice::copies_guest_ram + /// [`GpuDevice::copies_guest_ram`]: crate::core::platform::device::GpuDevice::copies_guest_ram guest_ram_copies: AtomicBool, /// What the devices' [`GpuDevice::surface_pages_in_place`] answers /// ([`World::answer_surface_pages`]), and the planes each call was asked of, in order. /// - /// [`GpuDevice::surface_pages_in_place`]: crate::platform::device::GpuDevice::surface_pages_in_place + /// [`GpuDevice::surface_pages_in_place`]: crate::core::platform::device::GpuDevice::surface_pages_in_place surface_pages: Mutex<(PagesInPlace, Vec>)>, } @@ -989,7 +989,7 @@ impl World { /// Has the devices answer `answer` to [`GpuDevice::surface_pages_in_place`] from now on; /// [`PagesInPlace::Yes`] at first. /// - /// [`GpuDevice::surface_pages_in_place`]: crate::platform::device::GpuDevice::surface_pages_in_place + /// [`GpuDevice::surface_pages_in_place`]: crate::core::platform::device::GpuDevice::surface_pages_in_place pub fn answer_surface_pages(&self, answer: PagesInPlace) { self.surface_pages.lock().0 = answer; } @@ -997,7 +997,7 @@ impl World { /// What the devices answer to [`GpuDevice::surface_pages_in_place`] asked of `planes`, the /// call recorded ([`World::surface_pages_asked`]). /// - /// [`GpuDevice::surface_pages_in_place`]: crate::platform::device::GpuDevice::surface_pages_in_place + /// [`GpuDevice::surface_pages_in_place`]: crate::core::platform::device::GpuDevice::surface_pages_in_place pub fn surface_pages_in_place(&self, planes: &[PagesPlane]) -> PagesInPlace { let mut state = self.surface_pages.lock(); state.1.push(planes.to_vec()); @@ -1006,7 +1006,7 @@ impl World { /// The planes each call of [`GpuDevice::surface_pages_in_place`] was asked of, in order. /// - /// [`GpuDevice::surface_pages_in_place`]: crate::platform::device::GpuDevice::surface_pages_in_place + /// [`GpuDevice::surface_pages_in_place`]: crate::core::platform::device::GpuDevice::surface_pages_in_place pub fn surface_pages_asked(&self) -> Vec> { self.surface_pages.lock().1.clone() } @@ -1028,7 +1028,7 @@ impl World { /// not, as a device of the Vulkan platform handed the guest's RAM whole does; not at first. /// The copies answer as scripted ([`GUEST_RAM_TO_BUFFER`], [`BUFFER_TO_GUEST_RAM`]). /// - /// [`GpuDevice::copies_guest_ram`]: crate::platform::device::GpuDevice::copies_guest_ram + /// [`GpuDevice::copies_guest_ram`]: crate::core::platform::device::GpuDevice::copies_guest_ram /// [`GUEST_RAM_TO_BUFFER`]: super::impls::blit::GUEST_RAM_TO_BUFFER /// [`BUFFER_TO_GUEST_RAM`]: super::impls::blit::BUFFER_TO_GUEST_RAM pub fn copy_guest_ram(&self, on: bool) { @@ -1037,7 +1037,7 @@ impl World { /// What the devices' [`GpuDevice::copies_guest_ram`] answers. /// - /// [`GpuDevice::copies_guest_ram`]: crate::platform::device::GpuDevice::copies_guest_ram + /// [`GpuDevice::copies_guest_ram`]: crate::core::platform::device::GpuDevice::copies_guest_ram pub fn copies_guest_ram(&self) -> bool { self.guest_ram_copies.load(Ordering::SeqCst) } @@ -1046,8 +1046,8 @@ impl World { // `this` is set at construction and `self` is alive, so the upgrade holds. match self.this.upgrade() { Some(w) => w, - None => crate::testkit::capture::die( - crate::raise::death::DeathKind::Abort, + None => crate::core::testkit::capture::die( + crate::core::raise::death::DeathKind::Abort, "fake/objects.rs", ), } @@ -1463,7 +1463,7 @@ fn with_read_death(detail: Option, f: impl FnOnce() -> R) -> R { /// Vulkan platform dies at for a failure it reads there. pub(crate) fn completion_read(info: CompletedInfo) -> CompletedInfo { if let Some(detail) = READ_DIES.with(|d| d.borrow().clone()) { - crate::raise::Raise::platform("commit") + crate::core::raise::Raise::platform("commit") .with_detail(detail) .fatal(); } @@ -1514,14 +1514,14 @@ pub fn complete_obj( }; match on { CompleteOn::Caller => { - let _env = crate::rt::BlockEnv::foreign(); + let _env = crate::core::rt::BlockEnv::foreign(); run() } CompleteOn::Thread | CompleteOn::Detached => { - let slot = crate::testkit::capture::current_slot(); + let slot = crate::core::testkit::capture::current_slot(); let spawned = std::thread::Builder::new() .name("com.Metal.CompletionQueueDispatch".into()) - .spawn(move || crate::testkit::capture::with_slot(slot, run)); + .spawn(move || crate::core::testkit::capture::with_slot(slot, run)); if on == CompleteOn::Thread && let Ok(j) = spawned { @@ -1602,7 +1602,7 @@ pub fn wait_status(cb: &Arc, at_least: CommandBufferStatus) { #[cfg(test)] mod tests { use super::*; - use crate::num::ToU64; + use crate::core::num::ToU64; /// Handles count retains; erase and cast keep the object #[test] @@ -1794,8 +1794,8 @@ mod tests { /// the caller's mark is restored after #[test] fn caller_mode_handlers_run_as_foreign_thread() { - use crate::rt::block_env::current_label; - use crate::rt::is_our_thread; + use crate::core::rt::block_env::current_label; + use crate::core::rt::is_our_thread; let w = World::new(); let cb: Fk = w.new_obj(Model::CommandBuffer(CommandBufferModel::default())); @@ -1956,8 +1956,8 @@ mod tests { // In a sync block of a queue, on the caller's thread. let p = super::super::platform::FakePlatform::new(); - let q = crate::rt::queue::SerialQueue::new( - crate::platform::Platform::threads(&p), + let q = crate::core::rt::queue::SerialQueue::new( + crate::core::platform::Platform::threads(&p), "test.events.sync", ); let h: Fk = w.new_obj(Model::None); @@ -1978,8 +1978,8 @@ mod tests { let p = super::super::platform::FakePlatform::new(); let w = p.world().clone(); p.record_events(true); - let threads = crate::platform::Platform::threads(&p); - let q = crate::rt::queue::SerialQueue::new(threads, "test.events.async"); + let threads = crate::core::platform::Platform::threads(&p); + let q = crate::core::rt::queue::SerialQueue::new(threads, "test.events.async"); let a: Fk = w.new_obj(Model::None); let a_id = a.id(); let (tx, rx) = std::sync::mpsc::channel(); @@ -1991,7 +1991,7 @@ mod tests { rx.recv().unwrap(); let c: Fk = w.new_obj(Model::None); let c_id = c.id(); - crate::rt::thread::spawn_named( + crate::core::rt::thread::spawn_named( threads, "test.events.thread", 1 << 20, diff --git a/crates/reims-vgpu-core/src/testkit/platform.rs b/crates/reims-vgpu-vulkan/src/core/testkit/platform.rs similarity index 94% rename from crates/reims-vgpu-core/src/testkit/platform.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/platform.rs index ebcde63d3..156647800 100644 --- a/crates/reims-vgpu-core/src/testkit/platform.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/platform.rs @@ -11,8 +11,8 @@ //! p.world().complete_all(CompleteOn::Thread); // the GPU finishes //! ``` -use crate::num::ToU64; -use crate::testkit::script::Policy; +use crate::core::num::ToU64; +use crate::core::testkit::script::Policy; use std::sync::Arc; use super::calllog::{Arg, CallLog}; @@ -25,13 +25,13 @@ use super::script::Script; use super::surfaces::FakeSurfaces; use super::threads::FakeThreads; use super::vm::FakeVm; -use crate::platform::os::Threads; -use crate::platform::os::surface::IoSurfaces; -use crate::platform::os::vm::HostVm; -use crate::platform::types::{MtlSize, ResourceAddressRange}; -use crate::platform::values::{RateMapDesc, TextureDesc}; -use crate::platform::{Handle, ObjId, Platform}; -use crate::raise::{OnFault, RaiseResult}; +use crate::core::platform::os::Threads; +use crate::core::platform::os::surface::IoSurfaces; +use crate::core::platform::os::vm::HostVm; +use crate::core::platform::types::{MtlSize, ResourceAddressRange}; +use crate::core::platform::values::{RateMapDesc, TextureDesc}; +use crate::core::platform::{Handle, ObjId, Platform}; +use crate::core::raise::{OnFault, RaiseResult}; /// The fake's device registry ID (`-[MTLDevice registryID]`). pub const FAKE_REGISTRY_ID: u64 = 0x1_0000_0f00; @@ -325,10 +325,10 @@ impl Platform for FakePlatform { mod tests { use super::super::script::Step; use super::*; - use crate::platform::descriptor::TextureDescriptor; - use crate::platform::device::GpuDevice; - use crate::platform::rate_map::RateMapLayerDescriptor; - use crate::platform::values::{RateMapDesc, TextureDesc}; + use crate::core::platform::descriptor::TextureDescriptor; + use crate::core::platform::device::GpuDevice; + use crate::core::platform::rate_map::RateMapLayerDescriptor; + use crate::core::platform::values::{RateMapDesc, TextureDesc}; /// Class methods make fresh objects; only the listener's `new` is ordered, and logged #[test] @@ -434,7 +434,10 @@ mod tests { }]) .unwrap(); assert!(matches!(&r.state().model, Model::Ranges(v) if v.len() == 1)); - assert_eq!(p.vm().page_size(), crate::testkit::guest_ram::PAGE_SIZE); + assert_eq!( + p.vm().page_size(), + crate::core::testkit::guest_ram::PAGE_SIZE + ); let _ = p.clock(); let _ = p.threads(); } diff --git a/crates/reims-vgpu-core/src/testkit/script.rs b/crates/reims-vgpu-vulkan/src/core/testkit/script.rs similarity index 96% rename from crates/reims-vgpu-core/src/testkit/script.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/script.rs index bf941c991..fdc1f13a4 100644 --- a/crates/reims-vgpu-core/src/testkit/script.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/script.rs @@ -19,12 +19,12 @@ use std::any::Any; use std::sync::Arc; use std::time::Duration; -use crate::sync::{Condvar, Mutex}; +use crate::core::sync::{Condvar, Mutex}; -use crate::platform::ObjId; -use crate::platform::types::NsErrorText; -use crate::raise::death::{DeathId, DeathKind, DeathSite, fatal}; -use crate::raise::{OnFault, Raise, RaiseResult}; +use crate::core::platform::ObjId; +use crate::core::platform::types::NsErrorText; +use crate::core::raise::death::{DeathId, DeathKind, DeathSite, fatal}; +use crate::core::raise::{OnFault, Raise, RaiseResult}; /// What a scripted raise at a send does: the label the platform's answer layer gives the same send /// (the Vulkan crate's `answer::Policy`), so that the fake decides each raise as the real platform @@ -65,7 +65,7 @@ pub enum Step { /// method without an error out-parameter treats it as `Nil`. Error(NsErrorText), /// A creator the platform refuses for a gap of its own, where Metal makes the object: noted - /// as a relayed gap ([`crate::platform::device::note_relayed_gap`]), then as `Error`, nil + /// as a relayed gap ([`crate::core::platform::device::note_relayed_gap`]), then as `Error`, nil /// with this `NSError` where the creator has an error out-parameter, else `Nil`. Gap(NsErrorText), /// Metal raised `name` with `reason` at the send (6.3). @@ -281,7 +281,7 @@ impl Step { ) -> RaiseResult> { self.throws(policy, sel)?; if let Step::Gap(_) = self { - crate::platform::device::note_relayed_gap(); + crate::core::platform::device::note_relayed_gap(); } if self.is_nil() { return Ok(None); @@ -301,7 +301,7 @@ impl Step { match self { Step::Error(e) => Ok(Err(e.clone())), Step::Gap(e) => { - crate::platform::device::note_relayed_gap(); + crate::core::platform::device::note_relayed_gap(); Ok(Err(e.clone())) } Step::Nil => Ok(Ok(None)), @@ -452,7 +452,7 @@ impl Script { #[cfg(test)] mod tests { use super::*; - use crate::testkit::capture::catch_death; + use crate::core::testkit::capture::catch_death; /// One-shot, counted and permanent entries #[test] @@ -544,7 +544,10 @@ mod tests { let r = Step::raise("NSInvalidArgumentException", "bad") .throws(Policy::Caught, "setLineWidth:"); let t = r.unwrap_err(); - assert_eq!(t.origin(), crate::raise::Origin::Boundary("setLineWidth:")); + assert_eq!( + t.origin(), + crate::core::raise::Origin::Boundary("setLineWidth:") + ); let u = Step::unrecognized("setLineWidth:").create::( Policy::On(OnFault::Return), "setLineWidth:", diff --git a/crates/reims-vgpu-core/src/testkit/surfaces.rs b/crates/reims-vgpu-vulkan/src/core/testkit/surfaces.rs similarity index 95% rename from crates/reims-vgpu-core/src/testkit/surfaces.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/surfaces.rs index b3cd660ca..4cac3a7f0 100644 --- a/crates/reims-vgpu-core/src/testkit/surfaces.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/surfaces.rs @@ -12,10 +12,10 @@ use super::calllog::Arg; use super::guest_ram::RawRegion; use super::objects::{FAKE_MAX_BYTES, Fk, Model, SurfaceModel, World, kind}; use super::platform::FakePlatform; -use crate::host::HostPtr; -use crate::num::ToU64; -use crate::platform::os::surface::{BackingSurfaceSpec, IoSurfaces, Surface, SurfaceSpec}; -use crate::platform::os::vm::KernReturn; +use crate::core::host::HostPtr; +use crate::core::num::ToU64; +use crate::core::platform::os::surface::{BackingSurfaceSpec, IoSurfaces, Surface, SurfaceSpec}; +use crate::core::platform::os::vm::KernReturn; /// A fake `IOSurfaceRef`. pub type FakeSurface = Fk; @@ -59,7 +59,7 @@ impl FakeSurfaces { impl IoSurfaces for FakeSurfaces { fn create(&self, spec: &SurfaceSpec) -> Option { self.world.log.push( - crate::platform::ObjId(0), + crate::core::platform::ObjId(0), "IOSurface", "IOSurfaceCreate", vec![Arg::val(spec)], @@ -67,7 +67,7 @@ impl IoSurfaces for FakeSurfaces { let step = self .world .script - .next(crate::platform::ObjId(0), "IOSurfaceCreate"); + .next(crate::core::platform::ObjId(0), "IOSurfaceCreate"); step.getter("IOSurfaceCreate"); if step.is_nil() { return None; @@ -93,7 +93,7 @@ impl IoSurfaces for FakeSurfaces { fn create_backing(&self, spec: &BackingSurfaceSpec) -> Option { self.world.log.push( - crate::platform::ObjId(0), + crate::core::platform::ObjId(0), "IOSurface", "initWithProperties:", vec![Arg::val(spec)], @@ -101,7 +101,7 @@ impl IoSurfaces for FakeSurfaces { let step = self .world .script - .next(crate::platform::ObjId(0), "initWithProperties:"); + .next(crate::core::platform::ObjId(0), "initWithProperties:"); step.getter("initWithProperties:"); if step.is_nil() { return None; @@ -259,8 +259,8 @@ impl Surface for Fk { mod tests { use super::super::script::Step; use super::*; - use crate::platform::Handle; - use crate::platform::os::surface::BackingPlaneSpec; + use crate::core::platform::Handle; + use crate::core::platform::os::surface::BackingPlaneSpec; fn surfaces() -> (Arc, FakeSurfaces) { let w = World::new(); diff --git a/crates/reims-vgpu-core/src/testkit/threads.rs b/crates/reims-vgpu-vulkan/src/core/testkit/threads.rs similarity index 90% rename from crates/reims-vgpu-core/src/testkit/threads.rs rename to crates/reims-vgpu-vulkan/src/core/testkit/threads.rs index 1c015e583..ff64fe1d8 100644 --- a/crates/reims-vgpu-core/src/testkit/threads.rs +++ b/crates/reims-vgpu-vulkan/src/core/testkit/threads.rs @@ -2,9 +2,9 @@ use std::sync::Arc; -use crate::platform::os::{Threads, TimerClock}; -use crate::sync::{Condvar, Mutex, MutexGuard}; -use crate::testkit::objects::World; +use crate::core::platform::os::{Threads, TimerClock}; +use crate::core::sync::{Condvar, Mutex, MutexGuard}; +use crate::core::testkit::objects::World; /// `Threads` over `std::thread`: no Objective-C runs on a fake thread, so a Rust thread base is /// harmless here (4.5). Named spawns are recorded `(name, stack size)`, and each queue worker's @@ -40,7 +40,7 @@ impl Default for FakeThreads { struct WorldClock(Arc); impl TimerClock for WorldClock { - fn now_on(&self, d: crate::platform::os::Deadline) -> u64 { + fn now_on(&self, d: crate::core::platform::os::Deadline) -> u64 { TimerClock::now_on(&self.0.clock, d) } @@ -48,7 +48,7 @@ impl TimerClock for WorldClock { &self, cv: &Condvar, g: &mut MutexGuard<'_, bool>, - d: crate::platform::os::Deadline, + d: crate::core::platform::os::Deadline, ) { TimerClock::wait_until(&self.0.clock, cv, g, d) } @@ -97,7 +97,10 @@ fn spawn_std(name: Option<&'static str>, stack_size: usize, body: Box (FakeVm, CallLog, Script) { let (log, script) = (CallLog::new(), Script::new()); diff --git a/crates/reims-vgpu-core/src/trace.rs b/crates/reims-vgpu-vulkan/src/core/trace.rs similarity index 98% rename from crates/reims-vgpu-core/src/trace.rs rename to crates/reims-vgpu-vulkan/src/core/trace.rs index 8574a92b8..6cded239f 100644 --- a/crates/reims-vgpu-core/src/trace.rs +++ b/crates/reims-vgpu-vulkan/src/core/trace.rs @@ -19,7 +19,7 @@ use std::io::{BufWriter, Write as _}; use std::sync::OnceLock; use std::sync::atomic::{AtomicU64, Ordering}; -use crate::sync::Mutex; +use crate::core::sync::Mutex; /// The environment variable naming the file. pub const ENV_VAR: &str = "REIMS_VGPU_TRACE"; @@ -81,7 +81,7 @@ fn open(path: &OsStr) -> Option> { } /// Writes the lines the buffer holds to the file, for a death, which ends the process with no -/// `Drop` run ([`crate::raise::death`]). It opens no file, and takes the file's lock only where +/// `Drop` run ([`crate::core::raise::death`]). It opens no file, and takes the file's lock only where /// it is free: the dying thread may hold it, or a thread the death stops before it lets go. pub fn flush_before_death() { if let Some(mut w) = WRITER diff --git a/crates/reims-vgpu-vulkan/src/gpu.rs b/crates/reims-vgpu-vulkan/src/gpu.rs index f7e622d0a..af34fbe01 100644 --- a/crates/reims-vgpu-vulkan/src/gpu.rs +++ b/crates/reims-vgpu-vulkan/src/gpu.rs @@ -59,11 +59,11 @@ pub mod ycbcr; use std::ops::Range; +use crate::core::platform::types::{MtlOrigin, MtlRegion, MtlSize, NsRange, Swizzle}; use metal2vulkan::metal::{ PixelFormat, TextureSwizzle, TextureSwizzleChannels, TextureType, TextureUsage, }; use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::types::{MtlOrigin, MtlRegion, MtlSize, NsRange, Swizzle}; use crate::answer::unrepresentable; @@ -226,16 +226,16 @@ pub(crate) fn resource_options(sel: &'static str, raw: u64) -> rt::ResourceOptio #[cfg(test)] mod tests { use super::*; - use reims_vgpu_core::raise::death::DeathKind; - use reims_vgpu_core::testkit::capture::catch_death; + use crate::core::raise::death::DeathKind; + use crate::core::testkit::capture::catch_death; /// The platform's own buffers lie outside the Metal address space, `[2^47, 2^48)`, where no /// guest buffer lies #[test] fn own_buffers_take_no_metal_address() { - use reims_vgpu_core::platform::device::GpuDevice as _; - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::raise::OnFault; + use crate::core::platform::device::GpuDevice as _; + use crate::core::platform::resource::Buffer as _; + use crate::core::raise::OnFault; let d = crate::gpu::device::tests::dev(); let shared = rt::ResourceOptions::shared(); diff --git a/crates/reims-vgpu-vulkan/src/gpu/backing.rs b/crates/reims-vgpu-vulkan/src/gpu/backing.rs index 454abbbbe..a4f9a8c9f 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/backing.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/backing.rs @@ -188,15 +188,15 @@ use std::ptr::NonNull; use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}; use std::sync::{Arc, Weak}; +use crate::core::host::HostPtr; +use crate::core::num::ToU64; +use crate::core::platform::os::vm::{HostVm, KernReturn, VmProt}; +use crate::core::platform::types::ResourceAddressRange; +use crate::core::raise::RaiseResult; +use crate::core::raise::death::{DeathId, DeathKind, fatal_with_detail}; +use crate::core::rt::BlockEnv; +use crate::core::sync::Mutex; use metal2vulkan_runtime as rt; -use reims_vgpu_core::host::HostPtr; -use reims_vgpu_core::num::ToU64; -use reims_vgpu_core::platform::os::vm::{HostVm, KernReturn, VmProt}; -use reims_vgpu_core::platform::types::ResourceAddressRange; -use reims_vgpu_core::raise::RaiseResult; -use reims_vgpu_core::raise::death::{DeathId, DeathKind, fatal_with_detail}; -use reims_vgpu_core::rt::BlockEnv; -use reims_vgpu_core::sync::Mutex; use crate::answer::unrepresentable; use crate::os::OsVm; @@ -1269,7 +1269,7 @@ impl ImportSite { } /// The trace of the host memory this platform hands the runtime for one no-copy buffer, heap or -/// rebind, with `REIMS_VGPU_TRACE` set ([`reims_vgpu_core::trace`]): `imp` as its keep-alive is +/// rebind, with `REIMS_VGPU_TRACE` set ([`crate::core::trace`]): `imp` as its keep-alive is /// made (the site, the first byte given, its length, the first byte handed over), and `impfree` /// as the keep-alive goes ([`keep_alive`]). It marks each buffer, not each import: a buffer /// made over exactly the bytes a live no-copy buffer was made over lies in that one's import @@ -1287,14 +1287,14 @@ impl ImportTrace { ) -> Self { let at = imported.as_ptr().addr().to_u64(); let given = given.as_ptr().addr().to_u64(); - reims_vgpu_core::trace::event("imp", &[site.code(), given, length, at]); + crate::core::trace::event("imp", &[site.code(), given, length, at]); Self(at) } } impl Drop for ImportTrace { fn drop(&mut self) { - reims_vgpu_core::trace::event("impfree", &[self.0]); + crate::core::trace::event("impfree", &[self.0]); } } @@ -1861,8 +1861,8 @@ mod tests { /// first, as Metal makes nothing of them #[test] fn a_first_range_off_its_page_dies() { - use reims_vgpu_core::raise::death::DeathKind; - use reims_vgpu_core::testkit::capture::catch_death; + use crate::core::raise::death::DeathKind; + use crate::core::testkit::capture::catch_death; let guest = pages(3, 0); for (into, sel) in [(0x40, REPLACE), (PAGE / 4, "newHeapWithDescriptor:")] { let ranges = [range(address(guest) + into, 2 * PAGE)]; @@ -1925,7 +1925,7 @@ mod tests { /// it, or none, gathers nothing; read-only pages gather #[test] fn refused_ranges_gather_nothing() { - use reims_vgpu_core::platform::os::vm::VmProt; + use crate::core::platform::os::vm::VmProt; let vm = OsVm::new(); // A hole of one page between two mapped ones, where no alias of two pages fits. let around = pages(3, 0); @@ -2015,7 +2015,7 @@ mod tests { /// caller's #[test] fn replace_answers_as_metal() { - use reims_vgpu_core::testkit::capture::catch_death; + use crate::core::testkit::capture::catch_death; let guest = pages(2, 0xa1); let ranges = [range(address(guest), 2 * PAGE)]; let [id, other] = ids(); @@ -2285,20 +2285,20 @@ mod tests { /// writes #[test] fn a_commit_while_detached_fails_on_every_host() { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder}; - use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue}; - use reims_vgpu_core::platform::device::GpuDevice; - use reims_vgpu_core::platform::resource::Buffer; - use reims_vgpu_core::platform::types::NsRange; - use reims_vgpu_core::platform::values::{BufferDesc, OptionSet}; - use reims_vgpu_core::raise::OnFault; + use crate::core::platform::blit::{BlitCmd, BlitEncoder}; + use crate::core::platform::command::{CommandBuffer, CommandQueue}; + use crate::core::platform::device::GpuDevice; + use crate::core::platform::resource::Buffer; + use crate::core::platform::types::NsRange; + use crate::core::platform::values::{BufferDesc, OptionSet}; + use crate::core::raise::OnFault; const TEST: &str = "gpu::backing::tests::a_commit_while_detached_fails_on_every_host"; if std::env::var("RVG_CHILD").as_deref() == Ok(TEST) { - reims_vgpu_core::testkit::capture::set_capture_enabled(false); + crate::core::testkit::capture::set_capture_enabled(false); let d = crate::gpu::device::tests::dev(); let memory = pages(1, 0xd0); // SAFETY: the pages stay mapped for the process, which exits below. - let contents = unsafe { reims_vgpu_core::platform::HostRange::new(memory, PAGE) }; + let contents = unsafe { crate::core::platform::HostRange::new(memory, PAGE) }; let buffer = d .new_buffer(BufferDesc { length: PAGE, @@ -2355,16 +2355,16 @@ mod tests { /// code 8 by a detached use #[test] fn a_command_buffer_took_the_object_until_it_completed() { + use crate::core::platform::blit::{BlitCmd, BlitEncoder}; + use crate::core::platform::command::{CommandBuffer, CommandQueue}; + use crate::core::platform::device::GpuDevice; + use crate::core::platform::event::{EventRef, SharedEvent}; + use crate::core::platform::resource::Buffer; + use crate::core::platform::types::NsRange; + use crate::core::platform::values::{BufferDesc, OptionSet}; + use crate::core::raise::OnFault; use crate::gpu::command::VulkanCommandBuffer; use crate::gpu::resource::VulkanBuffer; - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder}; - use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue}; - use reims_vgpu_core::platform::device::GpuDevice; - use reims_vgpu_core::platform::event::{EventRef, SharedEvent}; - use reims_vgpu_core::platform::resource::Buffer; - use reims_vgpu_core::platform::types::NsRange; - use reims_vgpu_core::platform::values::{BufferDesc, OptionSet}; - use reims_vgpu_core::raise::OnFault; fn fill(cb: &VulkanCommandBuffer, buffer: &VulkanBuffer) { let e = cb.blit_encoder(OnFault::Return).unwrap().unwrap(); for command in [ @@ -2382,7 +2382,7 @@ mod tests { // A no-copy buffer over a page of the test's, which stays mapped for the process. let no_copy = || { // SAFETY: the page stays mapped for the process. - let contents = unsafe { reims_vgpu_core::platform::HostRange::new(pages(1, 0), PAGE) }; + let contents = unsafe { crate::core::platform::HostRange::new(pages(1, 0), PAGE) }; d.new_buffer(BufferDesc { length: PAGE, options: vec![OptionSet::StorageMode(0)], diff --git a/crates/reims-vgpu-vulkan/src/gpu/caps.rs b/crates/reims-vgpu-vulkan/src/gpu/caps.rs index 67872e219..ac4397a57 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/caps.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/caps.rs @@ -162,17 +162,17 @@ use std::sync::Arc; +use crate::core::num::ToU64; +use crate::core::platform::caps::{ + DeviceCaps, FAMILIES, Flags, HEAP_QUERY_OPTIONS, Limits, PRIMITIVE_TYPE_COUNT, SAMPLE_COUNTS, + WRITE_ROUNDING_MODES, +}; +use crate::core::platform::types::{MtlSize, SizeAndAlign}; +use crate::core::raise::RaiseResult; use metal2vulkan::device::{VkExtension, VkFeature}; use metal2vulkan::error::Feature; use metal2vulkan::metal::PixelFormat; use metal2vulkan_runtime as rt; -use reims_vgpu_core::num::ToU64; -use reims_vgpu_core::platform::caps::{ - DeviceCaps, FAMILIES, Flags, HEAP_QUERY_OPTIONS, Limits, PRIMITIVE_TYPE_COUNT, SAMPLE_COUNTS, - WRITE_ROUNDING_MODES, -}; -use reims_vgpu_core::platform::types::{MtlSize, SizeAndAlign}; -use reims_vgpu_core::raise::RaiseResult; use crate::answer::{Policy, refused, send}; use crate::gpu::resource_options; @@ -495,7 +495,7 @@ const _: () = assert!(PRIMITIVE_TYPE_COUNT == PUBLIC_PRIMITIVE_TYPES + 5); #[cfg(test)] mod tests { - use reims_vgpu_core::platform::device::GpuDevice; + use crate::core::platform::device::GpuDevice; use super::*; use crate::gpu::device::tests::dev; diff --git a/crates/reims-vgpu-vulkan/src/gpu/caps/tests/metal_tests.rs b/crates/reims-vgpu-vulkan/src/gpu/caps/tests/metal_tests.rs index 4bc146f10..5fe9cc299 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/caps/tests/metal_tests.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/caps/tests/metal_tests.rs @@ -1,6 +1,6 @@ //! The tests of `caps` that compare with Metal on this host: macOS only. -use reims_vgpu_core::platform::caps::LINEAR_ALIGNMENT_FORMAT; +use crate::core::platform::caps::LINEAR_ALIGNMENT_FORMAT; use super::*; @@ -143,7 +143,7 @@ fn answers(caps: &DeviceCaps) -> Vec<(String, String)> { #[test] fn every_cap_is_metals() { let ours = answers(&dev().caps()); - if !reims_vgpu_core::metal_matches!("name", ours[0].1) { + if !crate::metal_matches!("name", ours[0].1) { eprintln!( "{}: not the GPU Metal's answers were recorded on", ours[0].1 @@ -152,7 +152,7 @@ fn every_cap_is_metals() { } let differ: Vec = ours .iter() - .filter(|(name, o)| name != "registryID" && !reims_vgpu_core::metal_matches!(name, o)) + .filter(|(name, o)| name != "registryID" && !crate::metal_matches!(name, o)) .map(|(name, o)| format!("{name}: ours {o}, not Metal's")) .collect(); assert!( diff --git a/crates/reims-vgpu-vulkan/src/gpu/command.rs b/crates/reims-vgpu-vulkan/src/gpu/command.rs index 71956db5a..fad250f90 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/command.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/command.rs @@ -214,21 +214,21 @@ use std::sync::Arc; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; -use metal2vulkan::metal::DispatchType; -use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::Handle; -use reims_vgpu_core::platform::command::committing as committing_here; -use reims_vgpu_core::platform::command::{ +use crate::core::platform::Handle; +use crate::core::platform::command::committing as committing_here; +use crate::core::platform::command::{ CommandBuffer, CommandQueue, CompletedHandler, CompletedInfo, ScheduledHandler, run_completed, }; -use reims_vgpu_core::platform::event::EventRef; -use reims_vgpu_core::platform::types::{CommandBufferStatus, NsErrorText}; -use reims_vgpu_core::platform::values::ComputePassDesc; -use reims_vgpu_core::raise::death::{DeathId, DeathKind, fatal_with_detail}; -use reims_vgpu_core::raise::refusals::{self, Carried}; -use reims_vgpu_core::raise::{OnFault, RaiseResult}; -use reims_vgpu_core::rt::BlockEnv; -use reims_vgpu_core::sync::Mutex; +use crate::core::platform::event::EventRef; +use crate::core::platform::types::{CommandBufferStatus, NsErrorText}; +use crate::core::platform::values::ComputePassDesc; +use crate::core::raise::death::{DeathId, DeathKind, fatal_with_detail}; +use crate::core::raise::refusals::{self, Carried}; +use crate::core::raise::{OnFault, RaiseResult}; +use crate::core::rt::BlockEnv; +use crate::core::sync::Mutex; +use metal2vulkan::metal::DispatchType; +use metal2vulkan_runtime as rt; use crate::answer::{ Policy, get, hang, metal_aborts, plain, plain_at, refusal, refused, send, unrepresentable, @@ -585,7 +585,7 @@ impl CommandBufferObject { progress: Some(Arc::clone(&progress)), carried: refusals::carry(), #[cfg(test)] - slot: reims_vgpu_core::testkit::capture::current_slot(), + slot: crate::core::testkit::capture::current_slot(), }; let handler: rt::Handler = Box::new(move |cb: &rt::CommandBuffer| ending.run(cb)); plain(|| self.raw.add_completed_handler(handler)).unwrap_or_else(|e| refused(sel, &e)); @@ -759,7 +759,7 @@ struct Ending { carried: Carried, /// The test's death slot, which a death in the handler lands in. #[cfg(test)] - slot: Option>, + slot: Option>, } impl Ending { @@ -801,7 +801,7 @@ impl Ending { progress.end(stage, carried); }; #[cfg(test)] - reims_vgpu_core::testkit::capture::with_slot(self.slot.take(), end); + crate::core::testkit::capture::with_slot(self.slot.take(), end); #[cfg(not(test))] end(); } @@ -1273,7 +1273,7 @@ fn completed_handler( read: impl FnOnce(&rt::CommandBuffer) + Send + 'static, ) -> rt::Handler { #[cfg(test)] - let slot = reims_vgpu_core::testkit::capture::current_slot(); + let slot = crate::core::testkit::capture::current_slot(); let carried = refusals::carry(); Box::new(move |cb: &rt::CommandBuffer| { // A callout on the runtime's thread: marked ours, so a panic here aborts. @@ -1300,7 +1300,7 @@ fn completed_handler( ); }; #[cfg(test)] - reims_vgpu_core::testkit::capture::with_slot(slot, run); + crate::core::testkit::capture::with_slot(slot, run); #[cfg(not(test))] run(); }) @@ -1311,12 +1311,12 @@ fn completed_handler( /// took its last batch. fn scheduled_handler(block: ScheduledHandler) -> rt::Handler { #[cfg(test)] - let slot = reims_vgpu_core::testkit::capture::current_slot(); + let slot = crate::core::testkit::capture::current_slot(); Box::new(move |_cb: &rt::CommandBuffer| { // A callout on the runtime's thread: marked ours, so a panic here aborts. let _env = BlockEnv::foreign(); #[cfg(test)] - reims_vgpu_core::testkit::capture::with_slot(slot, block); + crate::core::testkit::capture::with_slot(slot, block); #[cfg(not(test))] block(); }) @@ -1409,7 +1409,7 @@ impl CommandBuffer for VulkanCommandBuffer { /// ([`backing::submission_check`]), the tiler's handler the process's space /// ([`tiler_handler`]), and the decoder's handlers their records' locks and the completion /// ring's. The call is marked as one that runs submission handlers inside it - /// (`reims_vgpu_core::platform::command::committing`), so a handler of a buffer whose records + /// (`crate::core::platform::command::committing`), so a handler of a buffer whose records /// go to a guest knows it runs on the committing thread, which may be one that must not post /// them. fn commit(&self, _on: OnFault) -> RaiseResult<()> { @@ -1695,7 +1695,7 @@ fn trace_event( event: Option<&EventRef<'_, VulkanPlatform>>, value: u64, ) { - if !reims_vgpu_core::trace::on() { + if !crate::core::trace::on() { return; } let id = match event { @@ -1707,17 +1707,17 @@ fn trace_event( } fn trace_event_id(kind: &str, cb: &rt::CommandBuffer, event: u64, value: u64) { - reims_vgpu_core::trace::event(kind, &[crate::gpu::timing::id(cb), event, value]); + crate::core::trace::event(kind, &[crate::gpu::timing::id(cb), event, value]); } #[cfg(test)] mod tests { use std::sync::mpsc; - use reims_vgpu_core::platform::device::GpuDevice; - use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; - use reims_vgpu_core::raise::death::DeathKind; - use reims_vgpu_core::testkit::capture::catch_death; + use crate::core::platform::device::GpuDevice; + use crate::core::platform::event::{EventRef, SharedEvent as _}; + use crate::core::raise::death::DeathKind; + use crate::core::testkit::capture::catch_death; use super::*; use crate::gpu::device::tests::dev; @@ -1789,12 +1789,12 @@ mod tests { /// detach registry's lock ([`backing::submission_check`]), the decoder's handlers their /// records' locks and the completion ring's, and the tiler's handler the process's space /// ([`tiler_handler`]), none of which a commit's caller holds. The commit is marked on its - /// thread (`reims_vgpu_core::platform::command::committing`), so a decoder's handler run there + /// thread (`crate::core::platform::command::committing`), so a decoder's handler run there /// on a thread the host's raise is not named for hands its records over to post. #[test] fn a_commit_checks_and_submits_inside_the_call_under_the_caller_s_locks() { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::types::NsRange; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::types::NsRange; let d = dev(); let q = d.new_command_queue().unwrap(); @@ -1815,7 +1815,7 @@ mod tests { OnFault::Return, Box::new(move || { let held = lock.try_lock().is_none(); - let inside = reims_vgpu_core::platform::command::inside_commit(); + let inside = crate::core::platform::command::inside_commit(); *at.lock() = Some((std::thread::current().id(), held, inside)); }), ) @@ -1849,7 +1849,7 @@ mod tests { #[cfg(target_os = "macos")] #[test] fn a_scheduled_signal_sent_after_the_commit_sets_nothing_as_metals() { - use reims_vgpu_core::platform::Platform; + use crate::core::platform::Platform; /// Whether the value reached the scheduled signal's 1 and the late one's 7, once the /// command buffer completed. @@ -1897,10 +1897,10 @@ mod tests { /// handler, so the guest's buffer reads scheduled no earlier #[test] fn a_command_buffer_waiting_for_an_event_is_scheduled_at_its_signal() { - use reims_vgpu_core::platform::Platform; - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::platform::types::NsRange; + use crate::core::platform::Platform; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::resource::Buffer as _; + use crate::core::platform::types::NsRange; /// On `d`: the buffer's status 100 ms after its commit, then the order its scheduled /// and completed handlers ran in around the CPU's signal, and the first byte its blit @@ -1967,9 +1967,9 @@ mod tests { /// Metal's on this host #[test] fn a_completed_handler_learns_the_gpu_times() { - use reims_vgpu_core::platform::Platform; - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::types::NsRange; + use crate::core::platform::Platform; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::types::NsRange; /// On `d`: the GPU times a blit fill's completed handler learned. fn learned(d: &P::Device) -> Option<(u64, u64)> { @@ -2075,10 +2075,10 @@ mod tests { /// is taken as the runtime submits its command buffer, before it reads scheduled #[test] fn a_render_encoders_tiler_work_is_taken_as_it_is_submitted() { - use reims_vgpu_core::platform::Platform as _; - use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; - use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; - use reims_vgpu_core::platform::values::{ColorAttachmentSet, TextureDesc}; + use crate::core::platform::Platform as _; + use crate::core::platform::descriptor::RenderPassDescriptor as _; + use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; + use crate::core::platform::values::{ColorAttachmentSet, TextureDesc}; let d = dev(); let q = d.new_command_queue().unwrap(); let p = crate::platform::tests::platform(); @@ -2287,8 +2287,8 @@ mod tests { /// runtime refuses: the wait dies at its selector, as Metal's answer there is not measured #[test] fn a_cycle_of_handlers_waits_dies() { - use reims_vgpu_core::raise::death::DeathSite; - use reims_vgpu_core::testkit::capture::expect_death; + use crate::core::raise::death::DeathSite; + use crate::core::testkit::capture::expect_death; let site = DeathSite { kind: DeathKind::Abort, @@ -2337,7 +2337,7 @@ mod tests { /// can show. fn in_child(test: &str, body: impl FnOnce()) -> std::process::ExitStatus { if std::env::var("RVG_CHILD").as_deref() == Ok(test) { - reims_vgpu_core::testkit::capture::set_capture_enabled(false); + crate::core::testkit::capture::set_capture_enabled(false); body(); std::process::exit(0); } @@ -2402,7 +2402,7 @@ mod tests { /// carried it is refused, and the command buffer's progress ends all the same #[test] fn a_refused_command_buffer_dies_at_its_execution() { - use reims_vgpu_core::platform::values::IcbDesc; + use crate::core::platform::values::IcbDesc; let d = dev(); let desc = IcbDesc { @@ -2683,8 +2683,8 @@ mod tests { /// A Shared buffer of 16 zero bytes, and a blit encoder of `cb` that fills it with `value` /// and ends. fn filled(cb: &VulkanCommandBuffer, value: u8) -> crate::gpu::resource::VulkanBuffer { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::types::NsRange; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::types::NsRange; let b = crate::gpu::resource::tests::shared(16); let blit = cb.blit_encoder(OnFault::Return).unwrap().unwrap(); let range = NsRange::new(0, 16); @@ -2700,7 +2700,7 @@ mod tests { /// The 16 bytes of a Shared buffer. fn sixteen(b: &crate::gpu::resource::VulkanBuffer) -> Vec { - use reims_vgpu_core::platform::resource::Buffer as _; + use crate::core::platform::resource::Buffer as _; // SAFETY: a Shared buffer of 16 bytes, read after its command buffer completed. unsafe { std::slice::from_raw_parts(b.contents().as_ptr::(), 16) }.to_vec() } @@ -2804,8 +2804,8 @@ mod tests { /// options from 0x10 up, die #[test] fn protection_options_that_end_the_process_die() { - use reims_vgpu_core::platform::Platform as _; - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::Platform as _; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; let q = dev().new_command_queue().unwrap(); for options in [1, 3, 7] { let cb = buffer(&q); @@ -2915,7 +2915,7 @@ mod tests { /// plain Metal asserts as the encoder goes (the runtime's statement) #[test] fn an_open_encoder_kills_what_metal_asserts_at() { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; let d = dev(); let q = d.new_command_queue().unwrap(); let cb = buffer(&q); diff --git a/crates/reims-vgpu-vulkan/src/gpu/command/executions.rs b/crates/reims-vgpu-vulkan/src/gpu/command/executions.rs index c57f30907..91d68a0b3 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/command/executions.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/command/executions.rs @@ -49,10 +49,10 @@ use std::ops::Range; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; +use crate::core::platform::icb::IndirectCommandBuffer as _; use metal2vulkan::metal::PrimitiveType; use metal2vulkan::pipeline::CommandWrites; use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::icb::IndirectCommandBuffer as _; use crate::answer::{get, plain, unrepresentable}; use crate::gpu::command::Progress; @@ -325,19 +325,19 @@ impl Drop for Read { #[cfg(test)] mod tests { + use crate::core::platform::Handle as _; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::device::GpuDevice as _; + use crate::core::platform::icb::{IcbRenderCmd, IndirectRenderCommand as _}; + use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; + use crate::core::platform::types::NsRange; + use crate::core::platform::values::IcbDesc; + use crate::core::raise::OnFault; + use crate::core::testkit::capture::catch_death; use metal2vulkan::metal::PixelFormat; use metal2vulkan::pipeline::{ ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource, }; - use reims_vgpu_core::platform::Handle as _; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::device::GpuDevice as _; - use reims_vgpu_core::platform::icb::{IcbRenderCmd, IndirectRenderCommand as _}; - use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; - use reims_vgpu_core::platform::types::NsRange; - use reims_vgpu_core::platform::values::IcbDesc; - use reims_vgpu_core::raise::OnFault; - use reims_vgpu_core::testkit::capture::catch_death; use super::*; use crate::gpu::device::VulkanDevice; diff --git a/crates/reims-vgpu-vulkan/src/gpu/depth_denormals.rs b/crates/reims-vgpu-vulkan/src/gpu/depth_denormals.rs index 4b78ca70a..a71adcb21 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/depth_denormals.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/depth_denormals.rs @@ -1,18 +1,18 @@ //! A `Depth32Float` texture's denormal depths, stored and compared as Metal does: what the //! runtime announces as `depth-denormals` on this host's MoltenVK is measured against Metal here. -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; -use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; -use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; -use reims_vgpu_core::platform::resource::{Buffer as _, Library as _}; -use reims_vgpu_core::platform::types::{ClearColor, MtlOrigin, MtlSize}; -use reims_vgpu_core::platform::values::{ +use crate::core::platform::Platform; +use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; +use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; +use crate::core::platform::descriptor::RenderPassDescriptor as _; +use crate::core::platform::device::GpuDevice as _; +use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; +use crate::core::platform::resource::{Buffer as _, Library as _}; +use crate::core::platform::types::{ClearColor, MtlOrigin, MtlSize}; +use crate::core::platform::values::{ ColorAttachmentSet, DepthAttachmentSet, DepthStencilDesc, FullRenderPipelineDesc, TextureDesc, }; -use reims_vgpu_core::raise::OnFault; +use crate::core::raise::OnFault; use crate::gpu::device::tests::dev; use crate::platform::tests::platform; @@ -290,7 +290,7 @@ fn denormal_depths_store_and_compare_as_metals() { for compare in 1..=6 { let ours = denormal_depth_drawn(&p, &d, stored, cleared, compare); let case = format!("{bits:#010x}, cleared {cleared}, compare {compare}"); - reims_vgpu_core::metal_check_raw!(&case, ours); + crate::metal_check_raw!(&case, ours); cases += 1; } } diff --git a/crates/reims-vgpu-vulkan/src/gpu/desc.rs b/crates/reims-vgpu-vulkan/src/gpu/desc.rs index 3b3d9822f..4e80299fe 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/desc.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/desc.rs @@ -111,17 +111,17 @@ //! the pass by the map as the GPU runs it, and decides what it decides by the map's class at the //! encoder's creation ([`crate::gpu::rate_map`]). -use metal2vulkan::metal::PixelFormat; -use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::Handle; -use reims_vgpu_core::platform::descriptor::{RenderPassDescriptor, TextureDescriptor}; -use reims_vgpu_core::platform::types::{ClearColor, MtlSamplePosition}; -use reims_vgpu_core::platform::values::TextureDesc; -use reims_vgpu_core::platform::values::{ +use crate::core::platform::Handle; +use crate::core::platform::descriptor::{RenderPassDescriptor, TextureDescriptor}; +use crate::core::platform::types::{ClearColor, MtlSamplePosition}; +use crate::core::platform::values::TextureDesc; +use crate::core::platform::values::{ AttachmentState, ColorAttachmentSet, DepthAttachmentSet, PassSet, StencilAttachmentSet, }; -use reims_vgpu_core::raise::{OnFault, RaiseResult}; -use reims_vgpu_core::sync::Mutex; +use crate::core::raise::{OnFault, RaiseResult}; +use crate::core::sync::Mutex; +use metal2vulkan::metal::PixelFormat; +use metal2vulkan_runtime as rt; use crate::answer::{Policy, metal_aborts, plain, send, unrepresentable}; use crate::gpu::rate_map::VulkanRateMap; diff --git a/crates/reims-vgpu-vulkan/src/gpu/device.rs b/crates/reims-vgpu-vulkan/src/gpu/device.rs index a4233a7aa..ed8acef85 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/device.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/device.rs @@ -26,25 +26,25 @@ use std::fmt; use std::ptr::NonNull; use std::sync::{Arc, OnceLock, Weak}; -use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; -use metal2vulkan_runtime as rt; -use reims_vgpu_core::host::HostPtr; -use reims_vgpu_core::platform::caps::{DeviceCaps, IdentityCaps}; -use reims_vgpu_core::platform::device::{GpuDevice, NoCopyDeallocator}; -use reims_vgpu_core::platform::os::vm::HostVm; -use reims_vgpu_core::platform::types::{ +use crate::core::host::HostPtr; +use crate::core::platform::caps::{DeviceCaps, IdentityCaps}; +use crate::core::platform::device::{GpuDevice, NoCopyDeallocator}; +use crate::core::platform::os::vm::HostVm; +use crate::core::platform::types::{ ArgumentKind, ArgumentLayout, ArgumentMember, NsErrorText, PixelFormatInfo, ResourceAddressRange, SizeAndAlign, TextureLevelInfo, TextureLevelQuery, }; -use reims_vgpu_core::platform::values::{ +use crate::core::platform::values::{ ArgumentDesc, BufferDeallocator, BufferDesc, DepthStencilDesc, FullComputePipelineDesc, FullMeshRenderPipelineDesc, FullRenderPipelineDesc, HeapDesc, HeapMade, IcbDesc, OptionSet, PagesInPlace, PagesPlane, RenderPipelineDesc, SamplerDesc, }; -use reims_vgpu_core::platform::{Handle, HostRange}; -use reims_vgpu_core::raise::{Kept, OnFault, RaiseResult, keep_forever}; -use reims_vgpu_core::rt::BlockEnv; -use reims_vgpu_core::sync::Mutex; +use crate::core::platform::{Handle, HostRange}; +use crate::core::raise::{Kept, OnFault, RaiseResult, keep_forever}; +use crate::core::rt::BlockEnv; +use crate::core::sync::Mutex; +use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; +use metal2vulkan_runtime as rt; use crate::answer::{ Nil, Policy, create, created_or_decided, decide, error_text, get, get_describing, hearing, @@ -129,7 +129,7 @@ pub struct OnSurface<'a> { impl fmt::Display for OnSurface<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - use reims_vgpu_core::platform::os::surface::Surface as _; + use crate::core::platform::os::surface::Surface as _; let OnSurface { fields, surface, @@ -739,7 +739,7 @@ impl VulkanDevice { shares: Option<&rt::Buffer>, nil: Nil, ) -> RaiseResult> { - use reims_vgpu_core::platform::os::surface::Surface as _; + use crate::core::platform::os::surface::Surface as _; let held = Arc::clone(surface); let run: rt::Deallocator = Box::new(move |_, _| { let _env = BlockEnv::foreign(); @@ -1073,7 +1073,7 @@ impl GpuDevice for VulkanDevice { &self, iosurface: Option<&OsSurface>, ) -> RaiseResult> { - use reims_vgpu_core::platform::os::surface::Surface as _; + use crate::core::platform::os::surface::Surface as _; let sel = "newBufferWithIOSurface:"; let surface = iosurface.unwrap_or_else(|| unrepresentable(sel, "a nil IOSurface")); let _making = SURFACE_BUFFER_MAKES.lock(); @@ -1516,8 +1516,7 @@ impl GpuDevice for VulkanDevice { // Metal asserts at a plane past 0 of a surface without planes, whatever the format // ("IOSurface is non-planar, but plane 1 specified"), and answers nil at a plane past a // planar surface's last (measured: `textures_over_planes_a_surface_lacks_are_metals`). - if plane != 0 && reims_vgpu_core::platform::os::surface::Surface::plane_count(surface) == 0 - { + if plane != 0 && crate::core::platform::os::surface::Surface::plane_count(surface) == 0 { metal_aborts(sel, &format!("plane {plane} of a surface without planes")); } let Some(mut at) = crate::os::plane(surface, plane) else { @@ -1538,7 +1537,7 @@ impl GpuDevice for VulkanDevice { // command buffer that used the texture completed, as Metal frees it ([`metal_space::Hold`]). let space = Arc::new(metal_space::surface( surface.id().0, - reims_vgpu_core::platform::os::surface::Surface::alloc_size(&*surface), + crate::core::platform::os::surface::Surface::alloc_size(&*surface), )); let token: rt::RangeToken = Box::new(Arc::clone(&space)); let Some(buffer) = self.buffer_over_surface(sel, &surface, token)? else { @@ -2125,10 +2124,10 @@ pub(crate) fn two_plane_xr10(pf: metal2vulkan::metal::PixelFormat) -> bool { pub(crate) mod tests { use std::sync::LazyLock; - use reims_vgpu_core::platform::Handle; - use reims_vgpu_core::platform::device::GpuDevice; - use reims_vgpu_core::raise::death::DeathKind; - use reims_vgpu_core::testkit::capture::catch_death; + use crate::core::platform::Handle; + use crate::core::platform::device::GpuDevice; + use crate::core::raise::death::DeathKind; + use crate::core::testkit::capture::catch_death; use super::*; @@ -2158,7 +2157,7 @@ pub(crate) mod tests { /// The one function of a fixture metallib. pub(crate) fn fixture_function(bytes: &[u8]) -> VulkanFunction { - use reims_vgpu_core::platform::resource::Library as _; + use crate::core::platform::resource::Library as _; let library = dev().new_library(bytes).unwrap().unwrap().unwrap(); let name = library.function_names().remove(0); library @@ -2176,8 +2175,8 @@ pub(crate) mod tests { /// its write mask; Metal's defaults for those unnamed. pub(crate) fn colours_of( colours: &[&[(u8, u32)]], - ) -> Vec<(u64, reims_vgpu_core::platform::values::ColorAttachmentDesc)> { - use reims_vgpu_core::platform::values::ColorAttachmentDesc; + ) -> Vec<(u64, crate::core::platform::values::ColorAttachmentDesc)> { + use crate::core::platform::values::ColorAttachmentDesc; colours .iter() .map(|properties| { @@ -2206,12 +2205,12 @@ pub(crate) mod tests { /// The whole render value of `vertex` and `fragment` into `colours` ([`colours_of`]) at /// `samples` samples, Metal's defaults elsewhere. #[cfg(target_os = "macos")] - pub(crate) fn render_value<'a, P: reims_vgpu_core::platform::Platform>( + pub(crate) fn render_value<'a, P: crate::core::platform::Platform>( (vertex, fragment): (&'a P::Function, &'a P::Function), samples: u64, colours: &[&[(u8, u32)]], - ) -> reims_vgpu_core::platform::values::FullRenderPipelineDesc<'a, P> { - use reims_vgpu_core::platform::values::FullRenderPipelineDesc; + ) -> crate::core::platform::values::FullRenderPipelineDesc<'a, P> { + use crate::core::platform::values::FullRenderPipelineDesc; FullRenderPipelineDesc { colors: colours_of(colours), raster_sample_count: samples, @@ -2259,7 +2258,7 @@ pub(crate) mod tests { kept(registry_id(&raw)).is_none(), "the test's process adopted a device before" ); - use reims_vgpu_core::platform::os::Clock as _; + use crate::core::platform::os::Clock as _; let device = adopt(raw); let clock = crate::os::OsClock::new(); let began = clock.now_mono(); @@ -2279,8 +2278,8 @@ pub(crate) mod tests { /// runtime's layout, Metal's rules, reaches the guest unchanged #[test] fn argument_layouts_are_metals() { - use reims_vgpu_core::platform::resource::Library as _; - use reims_vgpu_core::platform::types::ArgumentKind as K; + use crate::core::platform::resource::Library as _; + use crate::core::platform::types::ArgumentKind as K; let d = dev(); let arg = |data_type: u64, index: u64, array_length: u64| ArgumentDesc { data_type, @@ -2384,9 +2383,9 @@ pub(crate) mod tests { /// refusal: the held range the pin met. #[test] fn a_pinned_buffer_the_runtime_refuses_logs_why() { - use reims_vgpu_core::platform::resource::Buffer; - use reims_vgpu_core::platform::values::OptionSet; - use reims_vgpu_core::testkit::logs; + use crate::core::platform::resource::Buffer; + use crate::core::platform::values::OptionSet; + use crate::core::testkit::logs; let d = dev(); let pin = metal_space::END / 4 + 0x100_0000; let pinned = || BufferDesc { @@ -2424,11 +2423,11 @@ pub(crate) mod tests { /// the runtime's granule make none. #[test] fn a_heap_over_host_memory_lies_in_its_bytes() { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder}; - use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue}; - use reims_vgpu_core::platform::resource::{Buffer, Heap}; - use reims_vgpu_core::platform::types::NsRange; - use reims_vgpu_core::platform::values::{HeapDesc, OptionSet}; + use crate::core::platform::blit::{BlitCmd, BlitEncoder}; + use crate::core::platform::command::{CommandBuffer, CommandQueue}; + use crate::core::platform::resource::{Buffer, Heap}; + use crate::core::platform::types::NsRange; + use crate::core::platform::values::{HeapDesc, OptionSet}; let d = dev(); // Private anonymous memory, as the graphics device's region is, kept for the process. let layout = std::alloc::Layout::from_size_align(0x2_0000, 0x4000).unwrap(); @@ -2505,7 +2504,7 @@ pub(crate) mod tests { /// the pin, as the runtime would make it and Metal's answer there is not measured #[test] fn sparse_heaps_die_at_pins_the_space_refuses() { - use reims_vgpu_core::platform::values::{HeapDesc, OptionSet}; + use crate::core::platform::values::{HeapDesc, OptionSet}; let d = dev(); let sparse = |pin: Option| HeapDesc { size: 0x40000, @@ -2544,8 +2543,8 @@ pub(crate) mod tests { #[cfg(target_os = "linux")] #[test] fn a_buffer_is_vouched_for_while_its_pages_are_writable() { - use reims_vgpu_core::num::ToUsize as _; - use reims_vgpu_core::platform::os::vm::HostVm as _; + use crate::core::num::ToUsize as _; + use crate::core::platform::os::vm::HostVm as _; const PAGE: u64 = 0x1000; let d = dev(); @@ -2607,10 +2606,10 @@ pub(crate) mod tests { use std::sync::mpsc; use std::time::Duration; - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder}; - use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue}; - use reims_vgpu_core::platform::resource::Buffer; - use reims_vgpu_core::platform::types::CommandBufferStatus; + use crate::core::platform::blit::{BlitCmd, BlitEncoder}; + use crate::core::platform::command::{CommandBuffer, CommandQueue}; + use crate::core::platform::resource::Buffer; + use crate::core::platform::types::CommandBufferStatus; use crate::gpu::spin; @@ -2766,15 +2765,15 @@ pub(crate) mod tests { use std::sync::atomic::{AtomicU32, Ordering}; use std::time::Duration; - use reims_vgpu_core::host::PhysicalMemoryRange; - use reims_vgpu_core::num::ToU64 as _; - use reims_vgpu_core::platform::blit::ResourceRef; - use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue}; - use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder}; - use reims_vgpu_core::platform::os::surface::{IoSurfaces as _, Surface as _, SurfaceSpec}; - use reims_vgpu_core::platform::os::vm::HostVm as _; - use reims_vgpu_core::platform::resource::{Buffer, Library, Texture as _}; - use reims_vgpu_core::platform::types::{CommandBufferStatus, MtlSize, NsRange}; + use crate::core::host::PhysicalMemoryRange; + use crate::core::num::ToU64 as _; + use crate::core::platform::blit::ResourceRef; + use crate::core::platform::command::{CommandBuffer, CommandQueue}; + use crate::core::platform::compute::{ComputeCmd, ComputeEncoder}; + use crate::core::platform::os::surface::{IoSurfaces as _, Surface as _, SurfaceSpec}; + use crate::core::platform::os::vm::HostVm as _; + use crate::core::platform::resource::{Buffer, Library, Texture as _}; + use crate::core::platform::types::{CommandBufferStatus, MtlSize, NsRange}; use crate::gpu::resource::tests::bgra; @@ -3001,10 +3000,10 @@ pub(crate) mod tests { #[cfg(target_os = "linux")] #[test] fn textures_over_a_surface_map_its_pages_once_more_at_most() { - use reims_vgpu_core::host::PhysicalMemoryRange; - use reims_vgpu_core::num::ToU64 as _; - use reims_vgpu_core::platform::os::surface::{IoSurfaces as _, SurfaceSpec}; - use reims_vgpu_core::platform::os::vm::HostVm as _; + use crate::core::host::PhysicalMemoryRange; + use crate::core::num::ToU64 as _; + use crate::core::platform::os::surface::{IoSurfaces as _, SurfaceSpec}; + use crate::core::platform::os::vm::HostVm as _; use crate::gpu::resource::tests::bgra; @@ -3108,7 +3107,7 @@ pub(crate) mod tests { (made(), other.join().unwrap()) }); let (one, two) = (one.unwrap(), two.unwrap()); - use reims_vgpu_core::platform::resource::Buffer as _; + use crate::core::platform::resource::Buffer as _; assert_eq!(one.gpu_address(), two.gpu_address(), "round {round}"); } } @@ -3126,7 +3125,7 @@ pub(crate) mod tests { /// device made answers none #[test] fn a_made_device_is_kept_by_its_registry_id() { - use reims_vgpu_core::platform::Platform as _; + use crate::core::platform::Platform as _; let d = dev(); assert_eq!(kept(d.registry_id).map(|k| k.id()), Some(d.id())); assert!(kept(d.registry_id ^ 0xdead_beef).is_none()); @@ -3140,7 +3139,7 @@ pub(crate) mod tests { /// and rows, or the surface's own for a surface of no planes #[test] fn a_texture_over_a_surface_has_a_debug_line_of_its_shape() { - use reims_vgpu_core::platform::values::TextureDesc; + use crate::core::platform::values::TextureDesc; let fields = |pixel_format, (width, height), usage, resource_options| { TextureFields::of(&TextureDesc { texture_type: 2, @@ -3236,8 +3235,8 @@ pub(crate) mod tests { /// aborts ([`a_stopped_multisample_padded_texture_dies_at_its_creator`]) #[test] fn multisample_padded_textures_die_where_metal_aborts() { - use reims_vgpu_core::platform::Platform as _; - use reims_vgpu_core::platform::values::TextureDesc; + use crate::core::platform::Platform as _; + use crate::core::platform::values::TextureDesc; let p = crate::platform::tests::platform(); let sel = "newTextureWithDescriptor:"; for raw in 576..=579 { @@ -3269,9 +3268,9 @@ pub(crate) mod tests { /// without it, where a guest texture held in its place moves them #[test] fn an_own_texture_takes_no_resource_id_or_metal_space() { - use reims_vgpu_core::platform::Platform as _; - use reims_vgpu_core::platform::resource::{Buffer as _, Texture as _}; - use reims_vgpu_core::platform::values::TextureDesc; + use crate::core::platform::Platform as _; + use crate::core::platform::resource::{Buffer as _, Texture as _}; + use crate::core::platform::values::TextureDesc; let p = crate::platform::tests::platform(); let d = dev(); let desc = p.texture_descriptor(&TextureDesc { @@ -3318,8 +3317,8 @@ pub(crate) mod tests { /// and every reference to a state answers its own #[test] fn each_compute_pipeline_creation_takes_a_new_identifier() { - use reims_vgpu_core::platform::resource::ComputePipeline as _; - use reims_vgpu_core::platform::resource::Library as _; + use crate::core::platform::resource::ComputePipeline as _; + use crate::core::platform::resource::Library as _; let d = dev(); let library = d .new_library(include_bytes!("../../../../tests/shaders/kernel.metallib")) @@ -3365,7 +3364,7 @@ pub(crate) mod tests { /// (`MaxCommandBufferCount`), where the platform asks for Metal's 64. #[test] fn an_unshared_queue_runs_and_its_refusals_are_the_runtimes() { - use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue}; + use crate::core::platform::command::{CommandBuffer, CommandQueue}; let d = dev(); match unshared_queue(&d.raw, 0) { Err(rt::Error::Invalid(i)) => assert_eq!(i.problem, rt::Problem::MaxCommandBufferCount), diff --git a/crates/reims-vgpu-vulkan/src/gpu/device/tests/metal_tests.rs b/crates/reims-vgpu-vulkan/src/gpu/device/tests/metal_tests.rs index 820fde117..dc6c800cc 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/device/tests/metal_tests.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/device/tests/metal_tests.rs @@ -9,9 +9,9 @@ use super::*; /// own on Metal's device. Another type dies #[test] fn reservations_keep_ids_from_plain_allocation() { - use reims_vgpu_core::platform::Platform; - use reims_vgpu_core::platform::icb::IndirectCommandBuffer as _; - use reims_vgpu_core::platform::resource::{SamplerState as _, Texture as _}; + use crate::core::platform::Platform; + use crate::core::platform::icb::IndirectCommandBuffer as _; + use crate::core::platform::resource::{SamplerState as _, Texture as _}; fn ids(d: &P::Device, texture: &P::TextureDescriptor) -> Vec> { for (kind, indices) in [ @@ -78,7 +78,7 @@ fn ycbcr8_420_on( plane: u64, size: (u64, u64), ) -> RaiseResult> { - use reims_vgpu_core::platform::Platform as _; + use crate::core::platform::Platform as _; let desc = crate::platform::tests::platform() .texture_descriptor(&crate::gpu::ycbcr::measure::desc(500, size)); d.new_texture_on_surface(&desc, Some(surface), plane) @@ -141,7 +141,7 @@ fn blended( /// A linear sampler of `p`'s device `d`, clamped to the edge, of `normalized` coordinates or /// not, with a linear mip filter where `mipped`. -fn linear( +fn linear( d: &P::Device, normalized: bool, mipped: bool, @@ -168,7 +168,7 @@ type Linear = (String, Vec, Vec<(f32, f32)>); /// ([`minified`]) through the same three samplers; and a kernel's through a constexpr /// sampler; each into halves and into floats. A kernel's sample has no derivatives, so it /// reads level 0 magnified. -fn linear_samples( +fn linear_samples( p: &P, d: &P::Device, t: &P::Texture, @@ -285,11 +285,11 @@ fn ycbcr8_420_textures_over_surfaces_read_as_metals() { assert!(blends > 0, "{how} reads no blend of texels: {case}"); } let key = format!("{case}: read"); - reims_vgpu_core::metal_check_raw!(key, float_bits(&read)); + crate::metal_check_raw!(key, float_bits(&read)); let key = format!("{case}: nearest"); - reims_vgpu_core::metal_check_raw!(key, float_bits(¢red)); + crate::metal_check_raw!(key, float_bits(¢red)); for (how, o, _) in &ours { - reims_vgpu_core::metal_check_bytes!(format!("{case}: {how}"), o); + crate::metal_check_bytes!(format!("{case}: {how}"), o); } } } @@ -313,12 +313,12 @@ fn ycbcr8_420_textures_over_surfaces_read_as_metals() { ignore = "MoltenVK: the runtime records pixel-sampler-scaling, a death in strict mode; Mac-only test, off everywhere; ledger: MoltenVK strict deaths" )] fn ycbcr8_420_samples_the_exact_filter_does_not_reach_die() { + use crate::core::platform::Platform as _; + use crate::core::platform::compute::ComputeCmd; + use crate::core::platform::render::RenderCmd; + use crate::core::platform::types::{MtlSize, Swizzle}; use crate::gpu::ycbcr::measure::probed_texels; use crate::gpu::ycbcr::measure::{Shape, desc, drawn}; - use reims_vgpu_core::platform::Platform as _; - use reims_vgpu_core::platform::compute::ComputeCmd; - use reims_vgpu_core::platform::render::RenderCmd; - use reims_vgpu_core::platform::types::{MtlSize, Swizzle}; let (d, _cache) = device_with_own_cache(); let p = crate::platform::tests::platform(); let size = (33, 17); @@ -394,9 +394,9 @@ fn b3a8_read_only( size: (u64, u64), rows: (u64, u64), seed: u64, -) -> (crate::os::OsSurface, reims_vgpu_core::host::HostPtr, u64) { - use reims_vgpu_core::host::PhysicalMemoryRange; - use reims_vgpu_core::platform::os::vm::HostVm as _; +) -> (crate::os::OsSurface, crate::core::host::HostPtr, u64) { + use crate::core::host::PhysicalMemoryRange; + use crate::core::platform::os::vm::HostVm as _; let vm = crate::os::OsVm::new(); let page = vm.page_size(); let mut spec = b3a8_spec(size, rows); @@ -424,15 +424,15 @@ fn xr10_desc( format: u64, (width, height): (u64, u64), options: u64, -) -> reims_vgpu_core::platform::values::TextureDesc { - reims_vgpu_core::platform::values::TextureDesc { +) -> crate::core::platform::values::TextureDesc { + crate::core::platform::values::TextureDesc { texture_type: 2, pixel_format: format, width, height, usage: 1, resource_options: Some(options), - ..reims_vgpu_core::platform::values::TextureDesc::default() + ..crate::core::platform::values::TextureDesc::default() } } @@ -443,7 +443,7 @@ fn xr10_over( plane: u64, (size, options): ((u64, u64), u64), ) -> RaiseResult> { - use reims_vgpu_core::platform::Platform as _; + use crate::core::platform::Platform as _; let p = crate::platform::tests::platform(); let desc = p.texture_descriptor(&xr10_desc(format, size, options)); dev().new_texture_on_surface(&desc, Some(surface), plane) @@ -462,8 +462,8 @@ fn xr10_over( ignore = "MoltenVK: the runtime records device-pack-conversion, a death in strict mode; Mac-only test, off everywhere; ledger: MoltenVK strict deaths" )] fn two_plane_xr10_textures_over_surfaces_read_as_metals() { + use crate::core::platform::resource::Texture as _; use crate::gpu::ycbcr::measure::{probe, read_floats, sampled_only_floats}; - use reims_vgpu_core::platform::resource::Texture as _; let bits = |texels: Vec<[f32; 4]>| -> Vec<[u32; 4]> { texels.into_iter().map(|t| t.map(f32::to_bits)).collect() }; @@ -480,7 +480,7 @@ fn two_plane_xr10_textures_over_surfaces_read_as_metals() { let t = xr10_over(format, &s, 0, (size, options)).unwrap().unwrap(); assert_eq!(t.pixel_format(), format, "{case}"); let ours = bits(read_floats::(&d, &t, size)); - reims_vgpu_core::metal_check_raw!(format!("read: {case}"), ours); + crate::metal_check_raw!(format!("read: {case}"), ours); let grid = ((size.0 + 4) * 3, (size.1 + 4) * 3); for filter in [0, 1] { for (address, normalized) in [(0, false), (2, true)] { @@ -488,7 +488,7 @@ fn two_plane_xr10_textures_over_surfaces_read_as_metals() { let key = format!("{state:?}: {case}"); let at = probe((-2.0, -2.0), 1.0 / 3.0, grid, normalized, 0); let ours = sampled_only_floats::(&d, &t, state, grid, &at); - reims_vgpu_core::metal_check_raw!(key, bits(ours)); + crate::metal_check_raw!(key, bits(ours)); } } } @@ -508,8 +508,8 @@ fn two_plane_xr10_textures_over_surfaces_read_as_metals() { ignore = "MoltenVK: the runtime records device-pack-conversion, a death in strict mode; Mac-only test, off everywhere; ledger: MoltenVK strict deaths" )] fn two_plane_xr10_textures_over_unaligned_planes_are_metals() { + use crate::core::platform::resource::Texture as _; use crate::gpu::ycbcr::measure::{probe, read_floats, sampled_only_floats}; - use reims_vgpu_core::platform::resource::Texture as _; let bits = |texels: Vec<[f32; 4]>| -> Vec<[u32; 4]> { texels.into_iter().map(|t| t.map(f32::to_bits)).collect() }; @@ -534,14 +534,14 @@ fn two_plane_xr10_textures_over_unaligned_planes_are_metals() { let t = xr10_over(format, &s, 0, (size, 0x10)).unwrap().unwrap(); assert_eq!(t.pixel_format(), format, "{case}"); let ours = bits(read_floats::(&d, &t, size)); - reims_vgpu_core::metal_check_raw!(format!("read: {case}"), ours); + crate::metal_check_raw!(format!("read: {case}"), ours); let grid = ((size.0 + 4) * 3, (size.1 + 4) * 3); for filter in [0, 1] { let state = (filter, 0, false, 0); let key = format!("{state:?}: {case}"); let at = probe((-2.0, -2.0), 1.0 / 3.0, grid, false, 0); let ours = sampled_only_floats::(&d, &t, state, grid, &at); - reims_vgpu_core::metal_check_raw!(key, bits(ours)); + crate::metal_check_raw!(key, bits(ours)); } } } @@ -553,7 +553,7 @@ fn two_plane_xr10_textures_over_unaligned_planes_are_metals() { /// type ('420v'), and rotated (framebuffer only) over plane 0 of a 'b3a8' surface #[test] fn two_plane_xr10_textures_the_runtime_refuses_die() { - use reims_vgpu_core::platform::Platform as _; + use crate::core::platform::Platform as _; let size = (16, 16); let two = b3a8(size, (64, 64), 5); let one = crate::os::tests::bgra_surface(16, 16); @@ -577,7 +577,7 @@ fn two_plane_xr10_textures_the_runtime_refuses_die() { refused(&case, &|| xr10_over(format, surface, plane, (size, 0x10))); } // Metal aborts at a rotation of a descriptor not framebufferOnly. - let rotated = reims_vgpu_core::platform::values::TextureDesc { + let rotated = crate::core::platform::values::TextureDesc { usage: 0x5, framebuffer_only: Some(true), rotation: Some(1), @@ -595,19 +595,19 @@ fn two_plane_xr10_textures_the_runtime_refuses_die() { /// `RenderTarget` usage too (E26d's 0x5), after a pass of platform `p` that clears it to /// `color` and stores it: the surface's bytes from its base address to `length`, once the /// command buffer completed. -fn cleared>( +fn cleared>( p: &P, d: &P::Device, format: u64, surface: &crate::os::OsSurface, (size, options): ((u64, u64), u64), - color: reims_vgpu_core::platform::types::ClearColor, + color: crate::core::platform::types::ClearColor, length: u64, ) -> Vec { - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; - use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; - use reims_vgpu_core::platform::values::ColorAttachmentSet; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::descriptor::RenderPassDescriptor as _; + use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; + use crate::core::platform::values::ColorAttachmentSet; let mut desc = xr10_desc(format, size, options); desc.usage = 0x5; let t = d @@ -634,7 +634,7 @@ fn cleared(); let length = usize::try_from(length).unwrap(); // SAFETY: the surface's bytes, read after the command buffer that wrote them completed. @@ -647,7 +647,7 @@ fn cleared { /// `fillTexture:level:slice:region:bytes:length:`. Bytes(&'a [u8]), /// `fillTexture:level:slice:region:color:pixelFormat:`. - Color(reims_vgpu_core::platform::types::ClearColor, u64), + Color(crate::core::platform::types::ClearColor, u64), } /// What a fill of `region` (its origin and size) of a texture of `format` over plane 0 of /// `surface` (`size`, `options`) with `pattern` writes on `p`'s device `d`: the surface's /// bytes from its base address to `length`, once the command buffer completed. #[allow(clippy::too_many_arguments)] -fn filled>( +fn filled>( p: &P, d: &P::Device, format: u64, @@ -694,11 +694,11 @@ fn filled pattern: Pattern<'_>, length: u64, ) -> Vec { - use reims_vgpu_core::platform::HostRange; - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::os::surface::Surface as _; - use reims_vgpu_core::platform::types::{MtlOrigin, MtlRegion, MtlSize}; + use crate::core::platform::HostRange; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::os::surface::Surface as _; + use crate::core::platform::types::{MtlOrigin, MtlRegion, MtlSize}; let desc = p.texture_descriptor(&xr10_desc(format, size, options)); let t = d .new_texture_on_surface(&desc, Some(surface), 0) @@ -744,7 +744,7 @@ fn filled /// size #[test] fn a_filled_two_plane_xr10_texture_over_a_surface_writes_as_metals() { - use reims_vgpu_core::platform::types::ClearColor; + use crate::core::platform::types::ClearColor; let p = crate::platform::tests::platform(); let d = dev(); let color = ClearColor { @@ -774,7 +774,7 @@ fn a_filled_two_plane_xr10_texture_over_a_surface_writes_as_metals() { let ours = b3a8(size, rows, seed); let shape = (size, options); let ours = filled(&p, &d, format, &ours, shape, region, pattern, length); - reims_vgpu_core::metal_check_bytes!(case, &ours); + crate::metal_check_bytes!(case, &ours); } } } @@ -812,18 +812,18 @@ impl Memory { /// blit encoder, of a texture of `format` over `memory` (a surface's of luma `size`, or a /// buffer's rows of `size`) write on `p`'s device `d`: every byte of the memory, which starts as /// `i * 37 % 251` at byte `i` on every platform, once the command buffer completed. -fn memory_fill_on>( +fn memory_fill_on>( p: &P, d: &P::Device, (format, size, memory): (u64, (u64, u64), Memory), fills: &[MemoryFill<'_>], ) -> Vec { - use reims_vgpu_core::platform::HostRange; - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::os::surface::Surface as _; - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::platform::types::{MtlOrigin, MtlRegion, MtlSize}; + use crate::core::platform::HostRange; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::os::surface::Surface as _; + use crate::core::platform::resource::Buffer as _; + use crate::core::platform::types::{MtlOrigin, MtlRegion, MtlSize}; let texture_size = memory.texture_size(size); let desc = p.texture_descriptor(&crate::gpu::ycbcr::measure::desc(format, texture_size)); let write = |to: *mut u8, length: u64| { @@ -945,8 +945,8 @@ fn memory_fill_textures(size: (u64, u64)) -> Vec<(u64, (u64, u64), Memory)> { /// writes nothing on either. #[test] fn fills_of_ycbcr_and_padded_textures_are_metals() { - use reims_vgpu_core::platform::types::ClearColor; - use reims_vgpu_core::testkit::capture::catch_death; + use crate::core::platform::types::ClearColor; + use crate::core::testkit::capture::catch_death; let p = crate::platform::tests::platform(); let d = dev(); let color = ClearColor { @@ -975,7 +975,7 @@ fn fills_of_ycbcr_and_padded_textures_are_metals() { let what = format!("{texture:?} {fills:?}"); let ours = catch_death(|| memory_fill_on(&p, &d, texture, &fills)); match ours { - Ok(ours) if reims_vgpu_core::metal_matches_bytes!(what, &ours) => {} + Ok(ours) if crate::metal_matches_bytes!(what, &ours) => {} Ok(_) => differ.push(format!("{what}: bytes differ from Metal's")), Err(site) => { let line = crate::answer::LAST_LINE.lock().take().unwrap_or_default(); @@ -996,12 +996,12 @@ fn fills_of_ycbcr_and_padded_textures_are_metals() { /// Runs `cmd` in a blit encoder of a command buffer of `d`'s queue `q` of its own, and waits /// for it. -fn blit_one( +fn blit_one( q: &P::CommandQueue, - cmd: reims_vgpu_core::platform::blit::BlitCmd<'_, P>, + cmd: crate::core::platform::blit::BlitCmd<'_, P>, ) { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; let cb = q.command_buffer(OnFault::Die).unwrap().unwrap(); let e = cb.blit_encoder(OnFault::Die).unwrap().unwrap(); e.encode(OnFault::Die, cmd).unwrap(); @@ -1012,13 +1012,13 @@ fn blit_one( } /// A copy of `size` texels from `from` at `at` into `to` at `to_at`. -fn copy_region<'a, P: reims_vgpu_core::platform::Platform>( +fn copy_region<'a, P: crate::core::platform::Platform>( (from, at): (&'a P::Texture, [u64; 2]), (to, to_at): (&'a P::Texture, [u64; 2]), [w, h]: [u64; 2], -) -> reims_vgpu_core::platform::blit::BlitCmd<'a, P> { - use reims_vgpu_core::platform::types::{MtlOrigin, MtlSize}; - reims_vgpu_core::platform::blit::BlitCmd::CopyTextureRegion { +) -> crate::core::platform::blit::BlitCmd<'a, P> { + use crate::core::platform::types::{MtlOrigin, MtlSize}; + crate::core::platform::blit::BlitCmd::CopyTextureRegion { source_texture: from, source_slice: 0, source_level: 0, @@ -1033,7 +1033,7 @@ fn copy_region<'a, P: reims_vgpu_core::platform::Platform>( /// The bytes of `surface` from its base address to `length`. fn surface_bytes(surface: &crate::os::OsSurface, length: u64) -> Vec { - use reims_vgpu_core::platform::os::surface::Surface as _; + use crate::core::platform::os::surface::Surface as _; let base = surface.base_address().as_ptr::(); let length = usize::try_from(length).unwrap(); // SAFETY: the surface's bytes, read after the command buffers that wrote them completed. @@ -1058,7 +1058,7 @@ fn surface_bytes(surface: &crate::os::OsSurface, length: u64) -> Vec { /// times each at once, two copied zeros 1 and 2 times and four lost a command buffer to the /// recovery; copying the top quarter, none in 240 copies of each format; one process alone /// copying all of them, none in 200). The top quarter holds every byte the copy into `b` reads. -fn surface_copies>( +fn surface_copies>( p: &P, d: &P::Device, format: u64, @@ -1121,7 +1121,7 @@ fn copies_between_two_plane_xr10_textures_over_surfaces_write_as_metals() { let ours = pair(); let ours = surface_copies(&p, &d, format, (&ours.0, &ours.1), size, length); for (step, ours) in ours.iter().enumerate() { - reims_vgpu_core::metal_check_bytes!(format!("{case}: copy {step}"), ours); + crate::metal_check_bytes!(format!("{case}: copy {step}"), ours); } } } @@ -1131,7 +1131,7 @@ fn copies_between_two_plane_xr10_textures_over_surfaces_write_as_metals() { /// surface dies at the copy, naming the runtime's refusal (`Format`), where Metal copies #[test] fn a_copy_within_a_two_plane_xr10_texture_over_a_surface_dies() { - use reims_vgpu_core::platform::Platform; + use crate::core::platform::Platform; fn within>( p: &P, d: &P::Device, @@ -1170,9 +1170,9 @@ fn a_copy_within_a_two_plane_xr10_texture_over_a_surface_dies() { /// of one page made read-only for the GPU, which this platform writes itself #[test] fn cpu_writes_and_buffer_blits_of_two_plane_xr10_textures_over_surfaces_are_metals() { + use crate::core::platform::os::vm::HostVm as _; use crate::gpu::ycbcr::sampling::Op; use crate::gpu::ycbcr::sampling::written; - use reims_vgpu_core::platform::os::vm::HostVm as _; let (p, d) = (crate::platform::tests::platform(), dev()); let (size, rows) = ((16, 8), (64, 16)); for format in [550, 551] { @@ -1181,7 +1181,7 @@ fn cpu_writes_and_buffer_blits_of_two_plane_xr10_textures_over_surfaces_are_meta let (s, other) = pair(); let ours = written(&p, &d, op, format, (&s, &other), size); let key = format!("{format} {op:?}"); - assert!(reims_vgpu_core::metal_matches_raw!(key, ours), "{key}"); + assert!(crate::metal_matches_raw!(key, ours), "{key}"); } let vm = crate::os::OsVm::new(); let other = b3a8(size, rows, 22); @@ -1190,7 +1190,7 @@ fn cpu_writes_and_buffer_blits_of_two_plane_xr10_textures_over_surfaces_are_meta drop(s); assert!(vm.deallocate(pages, length).is_success()); let key = format!("{format}: read-only for the GPU"); - assert!(reims_vgpu_core::metal_matches_raw!(key, ours), "{key}"); + assert!(crate::metal_matches_raw!(key, ours), "{key}"); } } @@ -1235,10 +1235,10 @@ fn cpu_writes_and_buffer_blits_of_two_plane_xr10_textures_over_surfaces_are_meta /// ("-[MTLDebugDevice newSharedTextureWithDescriptor:]:553") rather than answering nil. #[test] fn formats_the_runtime_lacks_die_where_textures_are_made() { - use reims_vgpu_core::platform::Platform as _; - use reims_vgpu_core::platform::descriptor::TextureDescriptor as _; - use reims_vgpu_core::platform::resource::{Buffer as _, Heap as _, Texture as _}; - use reims_vgpu_core::platform::values::{HeapDesc, OptionSet, TextureDesc}; + use crate::core::platform::Platform as _; + use crate::core::platform::descriptor::TextureDescriptor as _; + use crate::core::platform::resource::{Buffer as _, Heap as _, Texture as _}; + use crate::core::platform::values::{HeapDesc, OptionSet, TextureDesc}; let p = crate::platform::tests::platform(); let desc = |format, storage: u64| TextureDesc { texture_type: 2, @@ -1368,10 +1368,10 @@ fn formats_the_runtime_lacks_die_where_textures_are_made() { let two_d = p.texture_2d_descriptor(OnFault::Return, format, 16, 16, false); assert_eq!(two_d.unwrap().pixel_format(), format, "a 2D descriptor's"); if let (Some(ours), true) = (size, described) { - reims_vgpu_core::metal_check!(format!("{format}'s size"), ours); + crate::metal_check!(format!("{format}'s size"), ours); } if let Some(ours) = texture_buffer_size { - reims_vgpu_core::metal_check!(format!("{format}: a texture buffer's size"), ours); + crate::metal_check!(format!("{format}: a texture buffer's size"), ours); } } for format in [2, 45, 48, 95, 100, 120, 122, 653, 2000] { @@ -1399,9 +1399,9 @@ fn formats_the_runtime_lacks_die_where_textures_are_made() { /// 16 cases #[test] fn shareable_padded_textures_are_metals() { - use reims_vgpu_core::platform::Platform as _; - use reims_vgpu_core::platform::resource::Texture as _; - use reims_vgpu_core::platform::values::TextureDesc; + use crate::core::platform::Platform as _; + use crate::core::platform::resource::Texture as _; + use crate::core::platform::values::TextureDesc; let p = crate::platform::tests::platform(); let mut differ = Vec::new(); for format in [576, 577, 578, 579] { @@ -1426,19 +1426,15 @@ fn shareable_padded_textures_are_metals() { } /// A 64x64 2D descriptor of `format` at storage mode `storage`, of `usage`. -fn packed_10( - format: u64, - storage: u64, - usage: u64, -) -> reims_vgpu_core::platform::values::TextureDesc { - reims_vgpu_core::platform::values::TextureDesc { +fn packed_10(format: u64, storage: u64, usage: u64) -> crate::core::platform::values::TextureDesc { + crate::core::platform::values::TextureDesc { texture_type: 2, pixel_format: format, width: 64, height: 64, usage, resource_options: Some(storage << 4), - ..reims_vgpu_core::platform::values::TextureDesc::default() + ..crate::core::platform::values::TextureDesc::default() } } @@ -1451,7 +1447,7 @@ fn packed_10( /// either format #[test] fn packed_10_bit_textures_are_metals_or_die_named() { - use reims_vgpu_core::platform::Platform as _; + use crate::core::platform::Platform as _; let p = crate::platform::tests::platform(); for format in [588, 589] { for storage in [0, 2] { @@ -1488,9 +1484,9 @@ fn packed_10_bit_textures_are_metals_or_die_named() { /// (`Unsupported`, `NotImplemented`): the runtime holds no image of a packed code stream #[test] fn packed_10_bit_textures_over_memory_die_named() { - use reims_vgpu_core::platform::Platform as _; - use reims_vgpu_core::platform::resource::{Buffer as _, Heap as _}; - use reims_vgpu_core::platform::values::{HeapDesc, OptionSet}; + use crate::core::platform::Platform as _; + use crate::core::platform::resource::{Buffer as _, Heap as _}; + use crate::core::platform::values::{HeapDesc, OptionSet}; let p = crate::platform::tests::platform(); // A placement heap's descriptor at `storage`, for this platform or Metal's. macro_rules! heap { @@ -1557,10 +1553,10 @@ fn packed_10_bit_textures_over_memory_die_named() { ignore = "MoltenVK: the runtime records device-pack-conversion, a death in strict mode; Mac-only test, off everywhere; ledger: MoltenVK strict deaths" )] fn padded_samples_are_metals() { + use crate::core::platform::Platform; + use crate::core::platform::resource::Buffer as _; + use crate::core::platform::values::TextureDesc; use crate::gpu::ycbcr::measure::{drawn, probe, probed_texels, sampler}; - use reims_vgpu_core::platform::Platform; - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::platform::values::TextureDesc; // A texture of `format` over a Shared buffer of noise on `p`'s device `d`. fn over_buffer( p: &P, @@ -1644,7 +1640,7 @@ fn padded_samples_are_metals() { let ours = samples(&p, &d, format); for (case, ours) in &ours { let key = format!("{format}: {case}"); - assert!(reims_vgpu_core::metal_matches_bytes!(key, ours), "{key}"); + assert!(crate::metal_matches_bytes!(key, ours), "{key}"); } } } @@ -1654,8 +1650,8 @@ fn padded_samples_are_metals() { /// `Private` rather than abort at the size; in `Private` storage it dies where Metal aborts. #[test] fn a_shareable_texture_of_no_width_is_nil_but_private() { - use reims_vgpu_core::platform::Platform; - use reims_vgpu_core::platform::values::TextureDesc; + use crate::core::platform::Platform; + use crate::core::platform::values::TextureDesc; let desc = |storage: u64| TextureDesc { pixel_format: 80, width: 0, @@ -1704,10 +1700,10 @@ fn a_shareable_texture_of_no_width_is_nil_but_private() { /// measurement). #[test] fn write_swizzles_are_made_where_read_alone() { - use reims_vgpu_core::platform::Platform; - use reims_vgpu_core::platform::resource::{Buffer as _, Heap as _, Texture as _}; - use reims_vgpu_core::platform::types::Swizzle; - use reims_vgpu_core::platform::values::{HeapDesc, OptionSet, TextureDesc}; + use crate::core::platform::Platform; + use crate::core::platform::resource::{Buffer as _, Heap as _, Texture as _}; + use crate::core::platform::types::Swizzle; + use crate::core::platform::values::{HeapDesc, OptionSet, TextureDesc}; let desc = |usage, storage: u64| TextureDesc { texture_type: 2, pixel_format: 70, @@ -1773,7 +1769,7 @@ fn write_swizzles_are_made_where_read_alone() { let ours = made(&p, &dev(), &read); assert_eq!(ours, [70; 6], "read alone"); let size = sized::(&dev(), &p.texture_descriptor(&read)); - reims_vgpu_core::metal_check!("read alone: the size query", size); + crate::metal_check!("read alone: the size query", size); for (what, usage) in [("written", 3), ("rendered", 5)] { let d = dev(); let written = p.texture_descriptor(&desc(usage, 2)); @@ -1816,7 +1812,7 @@ fn write_swizzles_are_made_where_read_alone() { } let size = sized::(&d, &written); assert_ne!(size.0, 0, "{what}: the size query"); - reims_vgpu_core::metal_check!(format!("{what}: the size query"), size); + crate::metal_check!(format!("{what}: the size query"), size); } } @@ -1826,11 +1822,11 @@ fn write_swizzles_are_made_where_read_alone() { /// creator of both makes one. #[test] fn texture_setters_act_where_metal_does() { - use reims_vgpu_core::platform::Platform as _; - use reims_vgpu_core::platform::descriptor::TextureDescriptor as _; - use reims_vgpu_core::platform::resource::{Buffer as _, Heap as _, Texture as _}; - use reims_vgpu_core::platform::types::Swizzle; - use reims_vgpu_core::platform::values::{HeapDesc, OptionSet, TextureDesc}; + use crate::core::platform::Platform as _; + use crate::core::platform::descriptor::TextureDescriptor as _; + use crate::core::platform::resource::{Buffer as _, Heap as _, Texture as _}; + use crate::core::platform::types::Swizzle; + use crate::core::platform::values::{HeapDesc, OptionSet, TextureDesc}; let p = crate::platform::tests::platform(); let base = TextureDesc { texture_type: 2, @@ -1925,7 +1921,7 @@ fn texture_setters_act_where_metal_does() { every_creator_aborts(&desc, &format!("swizzle ({channel}, 3, 4, 5)")); } // What each creator answers on `d` for `desc`: made, nil, or the size query's answer. - fn answers( + fn answers( p: &P, d: &P::Device, desc: &TextureDesc, @@ -2001,7 +1997,7 @@ fn texture_setters_act_where_metal_does() { 0 }; let key = format!("{desc:?}"); - reims_vgpu_core::metal_check!(key, &ours[compared..]); + crate::metal_check!(key, &ours[compared..]); if desc.protection_options.is_none() { continue; } @@ -2024,10 +2020,10 @@ fn texture_setters_act_where_metal_does() { /// dies, as Metal asserts. #[test] fn invalid_formats_are_metals() { - use reims_vgpu_core::platform::Platform as _; - use reims_vgpu_core::platform::descriptor::TextureDescriptor as _; - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::platform::values::TextureDesc; + use crate::core::platform::Platform as _; + use crate::core::platform::descriptor::TextureDescriptor as _; + use crate::core::platform::resource::Buffer as _; + use crate::core::platform::values::TextureDesc; let p = crate::platform::tests::platform(); let desc = |format, storage: u64| TextureDesc { texture_type: 2, @@ -2087,10 +2083,10 @@ fn invalid_formats_are_metals() { /// (measured one value a process with `MTL_DEBUG_LAYER` unset) #[test] fn the_setter_takes_what_metals_takes() { - use reims_vgpu_core::platform::Platform as _; - use reims_vgpu_core::platform::descriptor::TextureDescriptor as _; + use crate::core::platform::Platform as _; + use crate::core::platform::descriptor::TextureDescriptor as _; let p = crate::platform::tests::platform(); - let ours = p.texture_descriptor(&reims_vgpu_core::platform::values::TextureDesc::default()); + let ours = p.texture_descriptor(&crate::core::platform::values::TextureDesc::default()); let mut taken = 0; for raw in 0..2048 { match catch_death(|| ours.set_pixel_format(raw)) { @@ -2117,8 +2113,8 @@ fn the_setter_takes_what_metals_takes() { /// ([`crate::gpu::no_texture`]) #[test] fn two_d_descriptors_keep_raw_formats_as_the_setter_does() { - use reims_vgpu_core::platform::Platform as _; - use reims_vgpu_core::platform::descriptor::TextureDescriptor as _; + use crate::core::platform::Platform as _; + use crate::core::platform::descriptor::TextureDescriptor as _; let p = crate::platform::tests::platform(); let raw = [505, 543].into_iter(); for format in raw.chain(crate::gpu::no_texture::FORMATS) { @@ -2134,7 +2130,7 @@ fn two_d_descriptors_keep_raw_formats_as_the_setter_does() { /// YCbCr family alike #[test] fn textures_over_planes_a_surface_lacks_are_metals() { - use reims_vgpu_core::platform::Platform as _; + use crate::core::platform::Platform as _; let p = crate::platform::tests::platform(); let size = (32, 16); for (format, ostype) in [ @@ -2177,8 +2173,8 @@ fn textures_over_planes_a_surface_lacks_are_metals() { /// process of its own, so its IDs start fresh, as Metal's did #[test] fn a_texture_takes_a_live_ones_id_where_metal_gives_it() { - use reims_vgpu_core::platform::Platform; - use reims_vgpu_core::platform::resource::Texture as _; + use crate::core::platform::Platform; + use crate::core::platform::resource::Texture as _; /// The IDs and `uniqueIdentifier`s of five textures made after a queue and the /// reservation, which stay live. @@ -2209,9 +2205,9 @@ fn a_texture_takes_a_live_ones_id_where_metal_gives_it() { /// answers #[test] fn two_plane_cubes_are_nil_where_metal_answers_nil() { - use reims_vgpu_core::platform::Platform as _; - use reims_vgpu_core::platform::types::Swizzle; - use reims_vgpu_core::platform::values::TextureDesc; + use crate::core::platform::Platform as _; + use crate::core::platform::types::Swizzle; + use crate::core::platform::values::TextureDesc; /// A cube of `RGB10A8_2P_XR10`, 16 x 16, one level, usage `ShaderRead | ShaderWrite`, /// storage `Private`, then `change`. @@ -2317,8 +2313,8 @@ fn two_plane_cubes_are_nil_where_metal_answers_nil() { /// and 3 reserved gives 1, 2, then 4 on #[test] fn a_reservation_past_32_bits_leaves_it_to_the_next_call() { - use reims_vgpu_core::platform::Platform; - use reims_vgpu_core::platform::resource::{SamplerState as _, Texture as _}; + use crate::core::platform::Platform; + use crate::core::platform::resource::{SamplerState as _, Texture as _}; fn ids(d: &P::Device, texture: &P::TextureDescriptor) -> Vec> { for (kind, indices) in [ @@ -2359,13 +2355,13 @@ fn a_reservation_past_32_bits_leaves_it_to_the_next_call() { /// (`colour`, `blended`, `depth` or `stencil`) is pixel format `format`, the fragment function /// with a colour attachment alone; `blended`'s with blending enabled, its factors and operations /// Metal's defaults. -fn attachment_state( +fn attachment_state( d: &P::Device, attachment: &str, format: u32, -) -> Result, reims_vgpu_core::platform::types::NsErrorText> { - use reims_vgpu_core::platform::resource::Library as _; - use reims_vgpu_core::platform::values::FullRenderPipelineDesc; +) -> Result, crate::core::platform::types::NsErrorText> { + use crate::core::platform::resource::Library as _; + use crate::core::platform::values::FullRenderPipelineDesc; use crate::gpu::device::tests::colours_of; let refused = d @@ -2440,14 +2436,14 @@ fn pipeline_formats_the_runtime_makes_are_metals() { /// source colour and zero over the source alpha, adding (a multiply), of `v_plain` and /// `f_plain` of `refused.metallib`: the command buffer's status and error code once it /// completed. -fn rotated_blend_draw(p: &P, d: &P::Device) -> (u64, u64) { - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; - use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; - use reims_vgpu_core::platform::resource::Library as _; - use reims_vgpu_core::platform::values::{ColorAttachmentSet, TextureDesc}; +fn rotated_blend_draw(p: &P, d: &P::Device) -> (u64, u64) { + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::descriptor::RenderPassDescriptor as _; + use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; + use crate::core::platform::resource::Library as _; + use crate::core::platform::values::{ColorAttachmentSet, TextureDesc}; - use reims_vgpu_core::platform::values::FullRenderPipelineDesc; + use crate::core::platform::values::FullRenderPipelineDesc; use crate::gpu::device::tests::colours_of; let library = d.new_library(include_bytes!(concat!( @@ -2555,8 +2551,8 @@ fn an_unmeasured_rotated_blend_dies_on_a_native_device() { /// Whether `d` makes a no-copy buffer over two fresh pages after `case`: 0 leaves them /// readable and writable, 1 takes all access from the second, 2 from both, 3 unmaps the /// second, 4 leaves both read-only. -fn no_copy_made(d: &P::Device, case: u8) -> bool { - use reims_vgpu_core::platform::os::vm::VmProt; +fn no_copy_made(d: &P::Device, case: u8) -> bool { + use crate::core::platform::os::vm::VmProt; let vm = OsVm::new(); let page = vm.page_size(); let at = vm.allocate_anywhere(2 * page).unwrap(); @@ -2592,7 +2588,7 @@ fn no_copy_buffers_over_pages_without_access_are_nil_as_metals() { /// A queue [`test_queue`] keeps: its platform, its device's identity and the queue. type TestQueue = ( std::any::TypeId, - reims_vgpu_core::platform::ObjId, + crate::core::platform::ObjId, Box, ); @@ -2611,7 +2607,7 @@ std::thread_local! { /// same command buffer's compute pass ran and it completed without an error. This platform's /// queues share the device's Vulkan queues and cost nothing; they are kept the same way so /// that both sides of a comparison run alike. -pub(crate) fn test_queue(d: &P::Device) -> P::CommandQueue { +pub(crate) fn test_queue(d: &P::Device) -> P::CommandQueue { let at = (std::any::TypeId::of::

(), d.id()); TEST_QUEUES.with(|queues| { let mut queues = queues.borrow_mut(); @@ -2648,7 +2644,7 @@ pub(crate) fn device_with_own_cache() -> (VulkanDevice, OwnCache) { fn b3a8_spec( size: (u64, u64), rows: (u64, u64), -) -> reims_vgpu_core::platform::os::surface::SurfaceSpec { +) -> crate::core::platform::os::surface::SurfaceSpec { let alpha_offset = (rows.0 * size.1).next_multiple_of(4096); b3a8_spec_at(size, rows, alpha_offset) } @@ -2658,8 +2654,8 @@ fn b3a8_spec_at( size: (u64, u64), rows: (u64, u64), alpha_offset: u64, -) -> reims_vgpu_core::platform::os::surface::SurfaceSpec { - use reims_vgpu_core::platform::os::surface::{SurfacePlaneSpec, SurfaceSpec}; +) -> crate::core::platform::os::surface::SurfaceSpec { + use crate::core::platform::os::surface::{SurfacePlaneSpec, SurfaceSpec}; let (width, height) = size; let (color_row, alpha_row) = rows; let plane = |offset, bytes_per_row, bytes_per_element| SurfacePlaneSpec { @@ -2693,10 +2689,10 @@ fn b3a8_spec_at( /// The surface of `spec`, every byte of its allocation `noise(seed)`'s. fn noisy_surface( - spec: &reims_vgpu_core::platform::os::surface::SurfaceSpec, + spec: &crate::core::platform::os::surface::SurfaceSpec, seed: u64, ) -> crate::os::OsSurface { - use reims_vgpu_core::platform::os::surface::{IoSurfaces as _, Surface as _}; + use crate::core::platform::os::surface::{IoSurfaces as _, Surface as _}; let s = crate::os::OsSurfaces::new().create(spec).unwrap(); let mut next = crate::gpu::ycbcr::measure::noise(seed); let base = s.base_address().as_ptr::(); @@ -2726,25 +2722,25 @@ enum Order { /// texture, then a blit of the second texture's texels into a buffer, ordered as `order` says, /// the buffer's bytes answered once both command buffers completed. The two textures are made /// first, as a guest makes two over one surface. -fn read_through_another>( +fn read_through_another>( p: &P, d: &P::Device, surface: &crate::os::OsSurface, ((width, height), order): ((u64, u64), Order), texels: &[u8], ) -> Vec { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::event::EventRef; - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::platform::types::{MtlOrigin, MtlSize}; - let desc = p.texture_descriptor(&reims_vgpu_core::platform::values::TextureDesc { + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::event::EventRef; + use crate::core::platform::resource::Buffer as _; + use crate::core::platform::types::{MtlOrigin, MtlSize}; + let desc = p.texture_descriptor(&crate::core::platform::values::TextureDesc { texture_type: 2, pixel_format: 80, width, height, usage: 1, - ..reims_vgpu_core::platform::values::TextureDesc::default() + ..crate::core::platform::values::TextureDesc::default() }); let written = (d.new_texture_on_surface(&desc, Some(surface), 0)) .unwrap() @@ -2883,7 +2879,7 @@ fn a_texture_over_a_copied_surface_reads_another_ones_writes_as_metals() { copies() > before, "{order:?}: the runtime copied the surface's pages" ); - let metals = reims_vgpu_core::metal_matches_bytes!(key, &read); + let metals = crate::metal_matches_bytes!(key, &read); stale.push((order, metals, read.len())); drop(ours); free(pages, length); diff --git a/crates/reims-vgpu-vulkan/src/gpu/encode_blit.rs b/crates/reims-vgpu-vulkan/src/gpu/encode_blit.rs index ed3ed562f..8782745b6 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/encode_blit.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/encode_blit.rs @@ -113,13 +113,13 @@ use std::cell::RefCell; use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}; use std::sync::{Arc, Weak}; +use crate::core::platform::blit::{BlitCmd, BlitEncoder, ResourceRef}; +use crate::core::platform::icb::IndirectCommandBuffer as _; +use crate::core::platform::types::{ClearColor, MtlOrigin, MtlRegion, MtlSize}; +use crate::core::raise::{OnFault, RaiseResult}; +use crate::core::sync::{Mutex, ReentrantMutex}; use metal2vulkan::metal::PixelFormat; use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder, ResourceRef}; -use reims_vgpu_core::platform::icb::IndirectCommandBuffer as _; -use reims_vgpu_core::platform::types::{ClearColor, MtlOrigin, MtlRegion, MtlSize}; -use reims_vgpu_core::raise::{OnFault, RaiseResult}; -use reims_vgpu_core::sync::{Mutex, ReentrantMutex}; use crate::answer::{ Policy, decide, metal_aborts, plain, plain_at, send, send_describing, unrepresentable, @@ -325,10 +325,7 @@ fn some<'a, T>(sel: &'static str, object: Option<&'a T>, what: &str) -> &'a T { } /// The indices `r` names, for `sel`; a range whose end passes `u64::MAX` dies. -fn indices( - sel: &'static str, - r: reims_vgpu_core::platform::types::NsRange, -) -> std::ops::Range { +fn indices(sel: &'static str, r: crate::core::platform::types::NsRange) -> std::ops::Range { range(r).unwrap_or_else(|| unrepresentable(sel, &format!("the range {r:?}"))) } @@ -345,7 +342,7 @@ impl VulkanBlitEncoder { sel: &'static str, texture: &VulkanTexture, (level, slice, region): (u64, u64, MtlRegion), - bytes: reims_vgpu_core::platform::HostRange<'_>, + bytes: crate::core::platform::HostRange<'_>, ) -> RaiseResult<()> { let raw = texture.copied(sel); let shape = plain(|| fill::Shape { @@ -1152,13 +1149,13 @@ impl BlitEncoder for VulkanBlitEncoder { #[cfg(test)] mod tests { - use reims_vgpu_core::platform::Platform as _; - use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue}; - use reims_vgpu_core::platform::device::GpuDevice; - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::platform::types::{MtlOrigin, MtlSize, NsRange}; - use reims_vgpu_core::platform::values::TextureDesc; - use reims_vgpu_core::testkit::capture::catch_death; + use crate::core::platform::Platform as _; + use crate::core::platform::command::{CommandBuffer, CommandQueue}; + use crate::core::platform::device::GpuDevice; + use crate::core::platform::resource::Buffer as _; + use crate::core::platform::types::{MtlOrigin, MtlSize, NsRange}; + use crate::core::platform::values::TextureDesc; + use crate::core::testkit::capture::catch_death; use super::*; use crate::gpu::command::VulkanCommandBuffer; @@ -1304,7 +1301,7 @@ mod tests { || (d.raw.properties().driver_facts) .contains(&rt::DriverFact::DepthImageKeepsValuesOutsideUnitRange); let desc = crate::platform::tests::platform().texture_descriptor( - &reims_vgpu_core::platform::values::TextureDesc { + &crate::core::platform::values::TextureDesc { pixel_format: 260, width: 4, height: 4, @@ -1409,8 +1406,8 @@ mod tests { /// them in an order that varies from run to run. Each case's last blit is the one that dies #[test] fn two_plane_xr10_blits_metal_was_not_measured_at_die() { - use reims_vgpu_core::platform::resource::Heap as _; - use reims_vgpu_core::platform::values::{HeapDesc, OptionSet}; + use crate::core::platform::resource::Heap as _; + use crate::core::platform::values::{HeapDesc, OptionSet}; let d = dev(); let p = crate::platform::tests::platform(); let made = |desc: TextureDesc| { @@ -1564,7 +1561,7 @@ mod tests { cb.wait_until_completed(OnFault::Return).unwrap(); }) .unwrap_err(); - let abort = reims_vgpu_core::raise::death::DeathKind::Abort; + let abort = crate::core::raise::death::DeathKind::Abort; assert_eq!((site.kind, site.file), (abort, sel), "{case}"); } } diff --git a/crates/reims-vgpu-vulkan/src/gpu/encode_blit/tests/metal_tests.rs b/crates/reims-vgpu-vulkan/src/gpu/encode_blit/tests/metal_tests.rs index 683db705e..c01073bcc 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/encode_blit/tests/metal_tests.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/encode_blit/tests/metal_tests.rs @@ -1,6 +1,6 @@ //! The tests of `encode_blit` that compare with Metal on this host: macOS only. -use reims_vgpu_core::platform::types::{ClearColor, MtlOrigin, MtlSize, NsRange}; +use crate::core::platform::types::{ClearColor, MtlOrigin, MtlSize, NsRange}; use super::*; @@ -9,15 +9,15 @@ const TWO_PLANE_XR10: [u64; 2] = [550, 551]; /// The 4 by 4 BGRA8Unorm texture a copy of 64 bytes from a no-copy buffer of 63 over a page /// of `0..=255` fills on platform `P`, read back. -fn copied_past_a_no_copy_buffer_on( +fn copied_past_a_no_copy_buffer_on( d: &P::Device, desc: &dyn Fn(&TextureDesc) -> P::TextureDescriptor, ) -> Vec { use std::alloc::{Layout, alloc, dealloc}; - use reims_vgpu_core::host::HostPtr; - use reims_vgpu_core::platform::HostRange; - use reims_vgpu_core::platform::resource::Buffer as _; + use crate::core::host::HostPtr; + use crate::core::platform::HostRange; + use crate::core::platform::resource::Buffer as _; let layout = Layout::from_size_align(16384, 16384).unwrap(); // SAFETY: a nonzero size. let page = unsafe { alloc(layout) }; @@ -117,7 +117,7 @@ fn pvrtc_copy_texture(suites: bool) -> TextureDesc { /// The bytes of [`pvrtc_copy_texture`]'s texture of the suite's shape on platform `P`, a /// shareable one (`newSharedTextureWithDescriptor:`), filled from 128 bytes of `0..128` row by /// row (`MTLBlitOptionRowLinearPVRTC`), read back row by row with rows 32 and 48 bytes apart. -fn pvrtc_copies_on( +fn pvrtc_copies_on( d: &P::Device, desc: &dyn Fn(&TextureDesc) -> P::TextureDescriptor, ) -> [Vec; 2] { @@ -193,7 +193,7 @@ fn pvrtc_row_linear_copies_are_metals() { let vulkan_desc = |t: &TextureDesc| crate::platform::tests::platform().texture_descriptor(t); let vulkan = pvrtc_copies_on::(&d, &vulkan_desc); assert_eq!(vulkan[0], (0..128).collect::>()); - reims_vgpu_core::metal_check_raw!("copies", vulkan); + crate::metal_check_raw!("copies", vulkan); } /// A texture of a PVRTC format is made by `newTextureWithDescriptor:`, as Metal makes one on @@ -209,7 +209,7 @@ fn pvrtc_texture_takes_metals_size(t: &TextureDesc) { "{what}" ); let ours = d.heap_texture_size_and_align(&desc).unwrap(); - reims_vgpu_core::metal_check!(format!("{t:?}"), (ours.size, ours.align)); + crate::metal_check!(format!("{t:?}"), (ours.size, ours.align)); } /// The PVRTC textures the row-linear copies are measured with ([`pvrtc_copy_texture`]), at the @@ -241,14 +241,14 @@ const TWO_PLANE_SIZE: (u64, u64) = (48, 20); /// buffer with rows 4 bytes a texel apart and into one with rows 5 bytes a texel apart (its /// other bytes 0xaa), then, after a copy of a 17 by 9 region to (13, 11) from a buffer at /// offset 256 with rows 8 bytes a texel apart, the whole texture again. -fn two_plane_copies_on( +fn two_plane_copies_on( d: &P::Device, desc: &dyn Fn(&TextureDesc) -> P::TextureDescriptor, format: u64, ) -> [Vec; 3] { - use reims_vgpu_core::num::ToU64 as _; - use reims_vgpu_core::platform::HostRange; - use reims_vgpu_core::platform::resource::Texture as _; + use crate::core::num::ToU64 as _; + use crate::core::platform::HostRange; + use crate::core::platform::resource::Texture as _; let (w, h) = TWO_PLANE_SIZE; let t = d .new_texture( @@ -338,7 +338,7 @@ fn two_plane_xr10_copies_are_metals() { let vulkan = two_plane_copies_on::(&d, &vulkan_desc, format); assert_eq!(vulkan[0], noise(1, w * h * 4), "{format}"); let key = format!("{format}"); - reims_vgpu_core::metal_check_raw!(key, vulkan); + crate::metal_check_raw!(key, vulkan); } } @@ -363,7 +363,7 @@ enum TwoPlaneCopy { /// blit of a 16 by 8 texture of `from` into it, on `P`'s `d`: of the whole texture /// (`region` `None`), or of a region (origin, size) to a destination origin /// ([`two_plane_copy_on`]). -fn two_plane_blit_on( +fn two_plane_blit_on( d: &P::Device, desc: &dyn Fn(&TextureDesc) -> P::TextureDescriptor, formats: (u64, u64), @@ -394,18 +394,18 @@ type TwoPlaneShape = (((u64, u64), (u64, u64)), TwoPlaneCopy, TwoPlaneStorage); /// on `P`'s `d`. Each texture's texels are written first by a kernel from an `RGBA16Float` /// texture of halves in [-0.5, 1.25), apart in every channel and in each texture, so the /// blit moves both planes. -fn two_plane_copy_on( +fn two_plane_copy_on( d: &P::Device, desc: &dyn Fn(&TextureDesc) -> P::TextureDescriptor, (from, to): (u64, u64), (sizes, copy, storage): TwoPlaneShape, ) -> Vec { + use crate::core::platform::HostRange; + use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; + use crate::core::platform::resource::{Heap as _, Library as _, Texture as _}; + use crate::core::platform::types::MtlRegion; + use crate::core::platform::values::{HeapDesc, OptionSet}; use crate::gpu::ycbcr::measure::{PROBE, probed_texels}; - use reims_vgpu_core::platform::HostRange; - use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; - use reims_vgpu_core::platform::resource::{Heap as _, Library as _, Texture as _}; - use reims_vgpu_core::platform::types::MtlRegion; - use reims_vgpu_core::platform::values::{HeapDesc, OptionSet}; let texture_desc = |format, (w, h): (u64, u64), options| { desc(&TextureDesc { pixel_format: format, @@ -597,7 +597,7 @@ fn two_plane_xr10_copies_of_any_region_are_metals() { for formats in [(550, 550), (550, 551), (551, 550), (551, 551)] { let key = format!("{shape:?} {formats:?}"); let ours = two_plane_copy_on::(&d, &vulkan_desc, formats, shape); - reims_vgpu_core::metal_check_raw!(key, ours); + crate::metal_check_raw!(key, ours); } } }); @@ -644,7 +644,7 @@ fn two_plane_xr10_blits_are_metals() { let ours = two_plane_blit_on::(&d, &vulkan_desc, formats, region); assert_eq!(region.is_none(), ours == whole, "{formats:?} {region:?}"); let key = format!("{formats:?} {region:?}"); - reims_vgpu_core::metal_check_raw!(key, ours); + crate::metal_check_raw!(key, ours); } } }); @@ -658,19 +658,19 @@ fn two_plane_xr10_blits_are_metals() { /// (`CopyTextureSlices`) where `region` is `None`, or of a region (origin, size) to a /// destination origin. A buffer placed over the texture's span and 4096 bytes past it, each /// first its offset's low byte, reads the heap's bytes, through a copy into a Shared buffer. -fn two_plane_copy_into_heap_on( +fn two_plane_copy_into_heap_on( d: &P::Device, desc: &dyn Fn(&TextureDesc) -> P::TextureDescriptor, storage: u64, region: Option, fills: &[Fill], ) -> Vec { - use reims_vgpu_core::platform::HostRange; - use reims_vgpu_core::platform::blit::BlitEncoder as _; - use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; - use reims_vgpu_core::platform::resource::{Heap as _, Library as _, Texture as _}; - use reims_vgpu_core::platform::types::MtlRegion; - use reims_vgpu_core::platform::values::{HeapDesc, OptionSet}; + use crate::core::platform::HostRange; + use crate::core::platform::blit::BlitEncoder as _; + use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; + use crate::core::platform::resource::{Heap as _, Library as _, Texture as _}; + use crate::core::platform::types::MtlRegion; + use crate::core::platform::values::{HeapDesc, OptionSet}; use crate::gpu::ycbcr::measure::PROBE; let (w, h) = (16, 8); @@ -870,7 +870,7 @@ fn two_plane_copies_into_a_heap_are_metals() { &[], ); let key = format!("storage {storage} {region:?}"); - reims_vgpu_core::metal_check_raw!(key, ours); + crate::metal_check_raw!(key, ours); } } }); @@ -921,16 +921,16 @@ const STENCIL8: u64 = 253; /// rows `units.len() / height` bytes apart, a pixel's samples consecutive, Metal's layout. Where /// `cleared`, a pass that clears and stores the texture's depth (its stencil, for `Stencil8`) /// runs first in the same command buffer, as a guest's first pass over a new target does. -fn multisampled_copies_on( +fn multisampled_copies_on( p: &P, d: &P::Device, cleared: bool, (format, samples, width, height): (u64, u64, u64, u64), units: &[u8], ) -> Vec { - use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; - use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; - use reims_vgpu_core::platform::values::{DepthAttachmentSet, StencilAttachmentSet}; + use crate::core::platform::descriptor::RenderPassDescriptor as _; + use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; + use crate::core::platform::values::{DepthAttachmentSet, StencilAttachmentSet}; let t = d .new_texture( OnFault::Return, @@ -1095,7 +1095,7 @@ enum Fill { } /// The blit of `fill` into `t`. -fn fill_of<'a, P: reims_vgpu_core::platform::Platform>( +fn fill_of<'a, P: crate::core::platform::Platform>( t: &'a P::Texture, fill: &'a Fill, ) -> BlitCmd<'a, P> { @@ -1111,7 +1111,7 @@ fn fill_of<'a, P: reims_vgpu_core::platform::Platform>( level, slice, region: region(o, s), - bytes: reims_vgpu_core::platform::HostRange::of_slice(bytes), + bytes: crate::core::platform::HostRange::of_slice(bytes), }, Fill::Color(level, slice, o, s, [red, green, blue, alpha], pixel_format) => { BlitCmd::FillTextureColor { @@ -1173,12 +1173,12 @@ fn texture_of(c: &Case) -> TextureDesc { /// Each (slice, level) of `c`'s texture after its fills on platform `P`, read back, in order, /// each aspect's bytes in turn. -fn fills_on( +fn fills_on( d: &P::Device, desc: &dyn Fn(&TextureDesc) -> P::TextureDescriptor, c: &Case, ) -> Vec { - use reims_vgpu_core::platform::resource::Buffer as _; + use crate::core::platform::resource::Buffer as _; let desc = desc(&texture_of(c)); let t = match c.shared { true => d.new_shared_texture(&desc), @@ -1301,10 +1301,7 @@ fn fills_on( region: region(o, sz), // SAFETY: the source buffer's bytes, live past the send. bytes: unsafe { - reims_vgpu_core::platform::HostRange::new( - source.contents(), - bytes.len() as u64, - ) + crate::core::platform::HostRange::new(source.contents(), bytes.len() as u64) }, } } @@ -1366,7 +1363,7 @@ fn fills_on( /// a fill larger than the staging buffer #[test] fn texture_fills_are_metals() { - use reims_vgpu_core::platform::Platform as _; + use crate::core::platform::Platform as _; let rgba = [1.0, 0.5, 0.25, 1.0]; let b = |level, slice, o, s, bytes: &[u8]| Fill::Bytes(level, slice, o, s, bytes.to_vec()); let k = |level, slice, o, s, color, pf| Fill::Color(level, slice, o, s, color, pf); @@ -1582,7 +1579,7 @@ fn texture_fills_are_metals() { for (i, c) in cases.iter().enumerate() { let ours = fills_on::(&dev(), &vulkan_desc, c); let key = format!("case {i}"); - reims_vgpu_core::metal_check_bytes!(key, &ours); + crate::metal_check_bytes!(key, &ours); } } @@ -1597,14 +1594,14 @@ fn fills_are_metals(cases: &[Case]) { let line = crate::answer::LAST_LINE.lock().clone(); panic!("{what}: died at {} ({:?}): {line:?}", site.file, site.kind) }); - reims_vgpu_core::metal_check_bytes!(what, &ours); + crate::metal_check_bytes!(what, &ours); } } /// The bytes of a Private 2D texture of `format`, of `bpp` bytes a texel, 64 texels wide, on /// platform `P`, every byte 0xee, once each of `colours` filled a texel of it, in order from /// its first, packed in `format`. -fn packed_on( +fn packed_on( d: &P::Device, desc: &dyn Fn(&TextureDesc) -> P::TextureDescriptor, (format, bpp): (u64, u64), @@ -1753,7 +1750,7 @@ fn colours_the_runtime_packs_are_metals() { let bfloats = rotations(&bfloat_values()); // Metal's edges, by their bits: the colours the rest fills. let edge_key = "the XR sRGB edges' bits"; - let edge_bits = reims_vgpu_core::metal_value!(edge_key); + let edge_bits = crate::metal_value!(edge_key); let mut edges: Vec = (edge_bits.trim_matches(['[', ']']).split(", ")) .map(|b| f64::from_bits(b.parse().unwrap())) .collect(); @@ -1828,7 +1825,7 @@ fn colours_the_runtime_packs_are_metals() { // The colours' texels alone: past them lie texels no colour filled, whose bytes Metal's // blit out of a texture it keeps compressed rewrites (553's), where the runtime keeps them. let filled = colours.len() * usize::try_from(bpp).unwrap(); - if !reims_vgpu_core::metal_matches_bytes!(key, &ours[..filled]) { + if !crate::metal_matches_bytes!(key, &ours[..filled]) { differ.push(format!("{format}: the bytes differ from Metal's")); } } @@ -2233,14 +2230,14 @@ fn astc_cases(formats: &[(u64, [u64; 2])]) -> Vec { /// offset 0, in one blit encoder. A buffer placed over the texture's span and 4096 bytes past /// it, each first its offset's low byte, reads the heap's bytes, the alpha plane's among /// them, through a copy into a Shared buffer. -fn two_plane_heap_fill_on( +fn two_plane_heap_fill_on( d: &P::Device, desc: &dyn Fn(&TextureDesc) -> P::TextureDescriptor, (storage, format, (w, h)): (u64, u64, (u64, u64)), fills: &[Fill], ) -> Vec { - use reims_vgpu_core::platform::resource::Heap as _; - use reims_vgpu_core::platform::values::{HeapDesc, OptionSet}; + use crate::core::platform::resource::Heap as _; + use crate::core::platform::values::{HeapDesc, OptionSet}; let heap = d .new_heap(&HeapDesc { size: 0x10000, @@ -2347,7 +2344,7 @@ fn two_plane_fills_in_a_heap_are_metals() { site.file, site.kind ) }); - reims_vgpu_core::metal_check_bytes!(key, &ours); + crate::metal_check_bytes!(key, &ours); } } } @@ -2386,8 +2383,8 @@ fn two_plane_fills_off_a_surface_keep_the_alpha_as_metals() { /// cut at its end, nothing for an empty range, and across more than the staging buffer #[test] fn pattern_fills_are_metals() { - use reims_vgpu_core::platform::Platform; - use reims_vgpu_core::platform::resource::Buffer as _; + use crate::core::platform::Platform; + use crate::core::platform::resource::Buffer as _; fn on(d: &P::Device) -> Vec { let length = 9 << 20; let b = d @@ -2424,8 +2421,8 @@ fn pattern_fills_are_metals() { unsafe { std::slice::from_raw_parts(b.contents().as_ptr::(), length as usize) }.to_vec() } let ours = on::(&dev()); - reims_vgpu_core::metal_check_bytes!("the first 64 bytes", &ours[..64]); - reims_vgpu_core::metal_check_bytes!("the fills", &ours); + crate::metal_check_bytes!("the first 64 bytes", &ours[..64]); + crate::metal_check_bytes!("the fills", &ours); } /// The runtime's record of Metal's `generateMipmapsForTexture:` on an Apple M4: @@ -2519,7 +2516,7 @@ fn designed_first_level(extent: [u64; 2], ties: &[Tie], seed: u32) -> Vec { /// Each level of a Private 2D texture of `format` (4 bytes a texel, 8 for `BGRA10_XR` and /// `BGRA10_XR_sRGB`), `extent` and `levels` levels, of `usage`, on platform `P`, its first /// level `first`, read back once `generateMipmapsForTexture:` made the others. -fn mipmaps_on( +fn mipmaps_on( d: &P::Device, desc: &dyn Fn(&TextureDesc) -> P::TextureDescriptor, (format, extent, levels): (u64, [u64; 2], u64), @@ -2651,10 +2648,7 @@ fn two_bit_alpha_mipmaps_are_metals() { panic!("{what}: died at {} ({:?}): {line:?}", site.file, site.kind) }); for (level, o) in ours.iter().enumerate() { - if !reims_vgpu_core::metal_matches_bytes!( - format!("chain {seed}: {what} level {level}"), - o - ) { + if !crate::metal_matches_bytes!(format!("chain {seed}: {what} level {level}"), o) { differ.push(format!( "{what} level {level}: the texels differ from Metal's" )); @@ -2723,7 +2717,7 @@ fn m3_max_chains(formats: &[u64]) -> Vec { panic!("{what}: died at {} ({:?}): {line:?}", site.file, site.kind) }); for (level, o) in ours.iter().enumerate() { - if !reims_vgpu_core::metal_matches_bytes!(format!("{what} level {level}"), o) { + if !crate::metal_matches_bytes!(format!("{what} level {level}"), o) { differ.push(format!("{what} level {level}: the texels differ")); } } @@ -2817,11 +2811,11 @@ fn extended_range_mipmaps_are_metals() { panic!("{what}: died at {} ({:?}): {line:?}", site.file, site.kind) }); let step = usize::try_from(texel).unwrap(); - if !reims_vgpu_core::metal_matches_bytes!(format!("{what} level 0"), &ours[0]) { + if !crate::metal_matches_bytes!(format!("{what} level 0"), &ours[0]) { differ.push(format!("{what} level 0: the texels differ from Metal's")); } for (level, o) in ours.iter().enumerate().skip(1) { - let m = reims_vgpu_core::metal_full!(format!("{what} level {level}")); + let m = crate::metal_full!(format!("{what} level {level}")); let m = &m.unwrap_or_else(|| panic!("{what} level {level}: no bytes recorded")); assert_eq!(o.len(), m.len(), "{what} level {level}"); let far = (o.chunks(step).zip(m.chunks(step))) @@ -2853,7 +2847,7 @@ fn each_fill_reads_back_as_metals(cases: &[Case]) { for (i, c) in cases.iter().enumerate() { let what = format!("case {i}, {} {:?}: {:?}", c.format, c.extent, c.fills); match catch_death(|| fills_on::(&dev(), &vulkan_desc, c)) { - Ok(ours) if reims_vgpu_core::metal_matches_bytes!(what, &ours) => {} + Ok(ours) if crate::metal_matches_bytes!(what, &ours) => {} Ok(_) => differ.push(format!("{what}: the bytes differ from Metal's")), Err(site) => { let line = crate::answer::LAST_LINE.lock().take().unwrap_or_default(); @@ -2940,7 +2934,7 @@ fn a_wide_two_plane_fill_relays_the_copy_into_its_rows() { let named = "(metal2vulkan-degrade-two-plane-buffer-blit)"; assert!(line.contains(named), "{what}: {line}"); let ours = crate::answer::relaxed(|| fills_on::(&dev(), &vulkan_desc, &c)); - let metals = reims_vgpu_core::metal_matches_bytes!(what, &ours); + let metals = crate::metal_matches_bytes!(what, &ours); assert!(metals, "{what}: the bytes differ from Metal's"); } let relayed = crate::answer::relayed_counts(); @@ -3018,7 +3012,7 @@ fn two_plane_heap_fills_of_more_levels_or_slices_are_metals() { continue; } }; - if !reims_vgpu_core::metal_matches_bytes!(what, &ours) { + if !crate::metal_matches_bytes!(what, &ours) { differ.push(format!("{what}: the bytes differ from Metal's")); } } @@ -3033,14 +3027,14 @@ fn two_plane_heap_fills_of_more_levels_or_slices_are_metals() { /// The bytes of a Shared placement heap holding a texture of `shape` at offset 0, each byte its /// offset's low byte first, once `fills` filled the texture in one blit encoder, on platform /// `P`: the texture's size and a page more. -fn two_plane_heap_texture_fill_on( +fn two_plane_heap_texture_fill_on( d: &P::Device, desc: &dyn Fn(&TextureDesc) -> P::TextureDescriptor, shape: &TextureDesc, fills: &[Fill], ) -> Vec { - use reims_vgpu_core::platform::resource::{Buffer as _, Heap as _}; - use reims_vgpu_core::platform::values::{HeapDesc, OptionSet}; + use crate::core::platform::resource::{Buffer as _, Heap as _}; + use crate::core::platform::values::{HeapDesc, OptionSet}; let heap = d .new_heap(&HeapDesc { size: 0x20000, @@ -3109,13 +3103,13 @@ fn depth24_stencil8_textures_die_where_made_as_metals() { /// The bytes of a Shared buffer of 512 bytes, or of 64 past the texture where it ends later, /// byte `i` written `i * 37 % 251` first, holding a texture buffer of `format`, `width` texels /// wide, at `offset`, once `fills` filled the texture in one blit encoder, on platform `P`. -fn texture_buffer_fill_on( +fn texture_buffer_fill_on( d: &P::Device, desc: &dyn Fn(&TextureDesc) -> P::TextureDescriptor, (format, bpp, width, offset): (u64, u64, u64, u64), fills: &[Fill], ) -> Vec { - use reims_vgpu_core::platform::resource::Buffer as _; + use crate::core::platform::resource::Buffer as _; let bytes = usize::try_from((offset + width * bpp + 64).max(512)).unwrap(); let b = d .new_buffer_of_length(OnFault::Return, bytes as u64, 0) @@ -3180,7 +3174,7 @@ fn texture_buffer_fills_of_width_are_metals(cases: &[TextureBufferCase], width: let shape = (*format, *bpp, width, *offset); match catch_death(|| texture_buffer_fill_on::(&d, &ours_desc, shape, fills)) { - Ok(ours) if reims_vgpu_core::metal_matches_bytes!(key, &ours) => {} + Ok(ours) if crate::metal_matches_bytes!(key, &ours) => {} Ok(_) => differ.push(format!("{what}: the bytes differ from Metal's")), Err(site) => { let line = crate::answer::LAST_LINE.lock().take().unwrap_or_default(); @@ -3376,14 +3370,14 @@ type MultisampleShape = (u64, u64, u64, u64); /// Private, read by shaders and rendered to) on platform `P`: written from a buffer of `init`, /// each slice's samples in turn, then `fills` in one blit encoder, then copied back into a /// buffer, a pixel's samples consecutive, Metal's layout of a multisample copy. -fn multisample_fills_on( +fn multisample_fills_on( d: &P::Device, desc: &dyn Fn(&TextureDesc) -> P::TextureDescriptor, (format, samples, bpp, slices): MultisampleShape, init: &[u8], fills: &[Fill], ) -> Vec { - use reims_vgpu_core::platform::resource::Buffer as _; + use crate::core::platform::resource::Buffer as _; let (width, height) = (5, 3); let t = d .new_texture( @@ -3542,7 +3536,7 @@ fn multisample_fills_are_metals() { match catch_death(|| { multisample_fills_on::(&d, &ours_desc, *shape, &init, fills) }) { - Ok(ours) if reims_vgpu_core::metal_matches_bytes!(key, &ours) => {} + Ok(ours) if crate::metal_matches_bytes!(key, &ours) => {} Ok(_) => differ.push(format!("{what}: the bytes differ from Metal's")), Err(site) => { let line = crate::answer::LAST_LINE.lock().take().unwrap_or_default(); diff --git a/crates/reims-vgpu-vulkan/src/gpu/encode_compute.rs b/crates/reims-vgpu-vulkan/src/gpu/encode_compute.rs index 87803cd99..be190bbc9 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/encode_compute.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/encode_compute.rs @@ -47,13 +47,13 @@ use std::cell::Cell; use std::ops::Range; use std::sync::atomic::Ordering; +use crate::core::platform::Handle as _; +use crate::core::platform::blit::ResourceRef; +use crate::core::platform::compute::{ComputeCmd, ComputeEncoder}; +use crate::core::platform::types::NsRange; +use crate::core::raise::{OnFault, RaiseResult}; use metal2vulkan::metal::{BarrierScope, DispatchType, ResourceUsage}; use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::Handle as _; -use reims_vgpu_core::platform::blit::ResourceRef; -use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder}; -use reims_vgpu_core::platform::types::NsRange; -use reims_vgpu_core::raise::{OnFault, RaiseResult}; use crate::answer::{Policy, plain, send, unrepresentable}; use crate::gpu::command::executions::{self, Execution, Points}; @@ -498,17 +498,17 @@ impl ComputeEncoder for VulkanComputeEncoder { #[cfg(test)] mod tests { + use crate::core::platform::Platform as _; + use crate::core::platform::command::{CommandBuffer, CommandQueue}; + use crate::core::platform::descriptor::TextureDescriptor as _; + use crate::core::platform::device::GpuDevice; + use crate::core::platform::resource::{Buffer as _, Library as _}; + use crate::core::platform::types::MtlSize; + use crate::core::platform::values::{ComputePassDesc, TextureDesc}; + use crate::core::raise::death::DeathKind; + use crate::core::testkit::capture::catch_death; use metal2vulkan::bind::SamplerDescriptor; use metal2vulkan::metal::SamplerAddressMode; - use reims_vgpu_core::platform::Platform as _; - use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue}; - use reims_vgpu_core::platform::descriptor::TextureDescriptor as _; - use reims_vgpu_core::platform::device::GpuDevice; - use reims_vgpu_core::platform::resource::{Buffer as _, Library as _}; - use reims_vgpu_core::platform::types::MtlSize; - use reims_vgpu_core::platform::values::{ComputePassDesc, TextureDesc}; - use reims_vgpu_core::raise::death::DeathKind; - use reims_vgpu_core::testkit::capture::catch_death; use super::*; use crate::gpu::command::VulkanCommandBuffer; @@ -597,7 +597,7 @@ mod tests { #[cfg(target_os = "linux")] #[test] fn a_dispatch_through_a_read_only_surface_dies_on_linux() { - use reims_vgpu_core::platform::os::vm::HostVm as _; + use crate::core::platform::os::vm::HostVm as _; use crate::gpu::resource::tests::on_read_only_surface; use crate::os::{OsVm, PAGE}; @@ -667,7 +667,7 @@ mod tests { /// the pages on Linux, and Metal's read-only view on macOS. The kernel reads it as the pages #[test] fn a_kernel_store_into_a_read_only_buffer_is_dropped() { - use reims_vgpu_core::platform::os::vm::HostVm as _; + use crate::core::platform::os::vm::HostVm as _; use crate::gpu::resource::tests::{host_bytes_at, read_only_buffer}; use crate::os::{OsVm, PAGE}; @@ -723,7 +723,7 @@ mod tests { #[test] #[ignore = "a measurement, run by hand: prints the times"] fn dispatches_after_a_large_residency() { - use reims_vgpu_core::platform::os::Clock as _; + use crate::core::platform::os::Clock as _; let now = || crate::os::OsClock::new().now_mono(); let add = pipeline(ADD, "add_one"); let (input, out) = (shared(1024), shared(1024)); @@ -1060,8 +1060,8 @@ mod tests { /// of the buffer, whose command dispatches nothing #[test] fn a_dispatch_after_an_icb_made_writable_runs() { - use reims_vgpu_core::platform::icb::IndirectCommandBuffer as _; - use reims_vgpu_core::platform::values::IcbDesc; + use crate::core::platform::icb::IndirectCommandBuffer as _; + use crate::core::platform::values::IcbDesc; let d = dev(); d.reserve_resource_indices(5, &[2, (1 << 23) + 1]).unwrap(); diff --git a/crates/reims-vgpu-vulkan/src/gpu/encode_compute/tests/metal_tests.rs b/crates/reims-vgpu-vulkan/src/gpu/encode_compute/tests/metal_tests.rs index 5960102c6..7b2634800 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/encode_compute/tests/metal_tests.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/encode_compute/tests/metal_tests.rs @@ -1,6 +1,6 @@ //! The tests of `encode_compute` that compare with Metal on this host: macOS only. -use reims_vgpu_core::platform::resource::ComputePipeline; +use crate::core::platform::resource::ComputePipeline; use super::*; @@ -65,7 +65,7 @@ fn pipelines_of_functions() { .collect(); assert_eq!(ours[2].4, 256, "tg_static's 64 words"); for (&(_, name), ours) in kernels.iter().zip(&ours) { - reims_vgpu_core::metal_check!(name, ours); + crate::metal_check!(name, ours); } let sel = "newComputePipelineStateWithFunction:error:"; let site = catch_death(|| dev().new_compute_pipeline_state_for_function(None)).unwrap_err(); @@ -111,7 +111,7 @@ fn encoders_of_pass_descriptors() { assert_eq!(words(&out), [2, 3, 4, 5]); /// An encoder of `dispatch_type` of a pass descriptor on `d` that names a nil resource /// in its residency and adds one to 4 words: its output, once it completed. - fn unknown_type( + fn unknown_type( d: &P::Device, dispatch_type: u64, ) -> Vec { @@ -209,9 +209,9 @@ enum Dispatch { } /// `parts` in one command buffer on `d`, committed: the 4 words `add_one` wrote. -fn unit(d: &P::Device, parts: &[Part]) -> Vec { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; +fn unit(d: &P::Device, parts: &[Part]) -> Vec { + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::event::{EventRef, SharedEvent as _}; let lib = d.new_library(ADD).unwrap().unwrap().unwrap(); let f = lib diff --git a/crates/reims-vgpu-vulkan/src/gpu/encode_render.rs b/crates/reims-vgpu-vulkan/src/gpu/encode_render.rs index 3aff31489..a92220f45 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/encode_render.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/encode_render.rs @@ -256,19 +256,19 @@ use std::ops::Range; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; +use crate::core::platform::Handle as _; +use crate::core::platform::blit::ResourceRef; +use crate::core::platform::render::{RenderCmd, RenderEncoder, VertexDraw, encode_each}; +use crate::core::platform::resource::RenderPipeline as _; +use crate::core::platform::types::{MtlScissorRect, MtlSize, MtlViewport, NsRange}; +use crate::core::raise::{OnFault, RaiseResult}; +use crate::core::sync::{Mutex, ReentrantMutex}; use metal2vulkan::metal::{ BarrierScope, CullMode, DepthClipMode, IndexType, PixelFormat, PrimitiveTopologyClass, PrimitiveType, RenderStages, ResourceUsage, TextureType, TriangleFillMode, Winding, }; use metal2vulkan::pipeline::ColorAttachmentDescriptor; use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::Handle as _; -use reims_vgpu_core::platform::blit::ResourceRef; -use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder, VertexDraw, encode_each}; -use reims_vgpu_core::platform::resource::RenderPipeline as _; -use reims_vgpu_core::platform::types::{MtlScissorRect, MtlSize, MtlViewport, NsRange}; -use reims_vgpu_core::raise::{OnFault, RaiseResult}; -use reims_vgpu_core::sync::{Mutex, ReentrantMutex}; use crate::answer::{Policy, decide, get, metal_aborts, plain, plain_at, refused, unrepresentable}; use crate::gpu::command::VulkanCommandBuffer; @@ -4401,19 +4401,19 @@ pub(crate) mod tests { } } - use reims_vgpu_core::display::pipeline::{DisplayPipelineCache, PipelineKey}; - use reims_vgpu_core::platform::blit::ResourceRef; - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder}; - use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue}; - use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; - use reims_vgpu_core::platform::device::GpuDevice; - use reims_vgpu_core::platform::resource::{Buffer, Texture}; - use reims_vgpu_core::platform::types::{ + use crate::core::display::pipeline::{DisplayPipelineCache, PipelineKey}; + use crate::core::platform::blit::ResourceRef; + use crate::core::platform::blit::{BlitCmd, BlitEncoder}; + use crate::core::platform::command::{CommandBuffer, CommandQueue}; + use crate::core::platform::descriptor::RenderPassDescriptor as _; + use crate::core::platform::device::GpuDevice; + use crate::core::platform::resource::{Buffer, Texture}; + use crate::core::platform::types::{ ClearColor, MtlOrigin, MtlRegion, MtlScissorRect, MtlSize, NsRange, }; - use reims_vgpu_core::platform::values::{ColorAttachmentSet, TextureDesc}; - use reims_vgpu_core::platform::{Handle, HostRange, Platform}; - use reims_vgpu_core::testkit::capture::catch_death; + use crate::core::platform::values::{ColorAttachmentSet, TextureDesc}; + use crate::core::platform::{Handle, HostRange, Platform}; + use crate::core::testkit::capture::catch_death; use super::*; use crate::gpu::device::tests::dev; @@ -4632,7 +4632,7 @@ pub(crate) mod tests { /// `vertex_ids` and `simd_stages`, the crate's own [`BARYCENTRIC`], [`VERTEX_IDS`] and /// [`SIMD_STAGES`]. fn fixture(d: &P::Device, function: &str) -> P::Function { - use reims_vgpu_core::platform::resource::Library as _; + use crate::core::platform::resource::Library as _; let (file, name) = function.split_once(':').unwrap_or((function, function)); let bytes = if file == "barycentric" { BARYCENTRIC.to_vec() @@ -4655,7 +4655,7 @@ pub(crate) mod tests { vertex: &str, fragment: &str, ) -> P::RenderPipeline { - use reims_vgpu_core::platform::values::RenderPipelineDesc; + use crate::core::platform::values::RenderPipelineDesc; let (v, f) = (fixture::

(d, vertex), fixture::

(d, fragment)); d.new_render_pipeline_state(&RenderPipelineDesc { label: None, @@ -4856,8 +4856,8 @@ pub(crate) mod tests { /// commands after the draw in its encoder are taken #[test] fn a_type_9_draw_fails_its_command_buffer_as_metals_gpu_does() { - use reims_vgpu_core::platform::event::EventRef; - use reims_vgpu_core::platform::types::NsRange; + use crate::core::platform::event::EventRef; + use crate::core::platform::types::NsRange; let (p, d) = (platform(), dev()); let (dst, pass) = pass_of(&p, &d, (4, 4)); @@ -4923,8 +4923,8 @@ pub(crate) mod tests { d: &P::Device, fragment: &str, ) -> String { - use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; - use reims_vgpu_core::platform::render::RenderEncoder as _; + use crate::core::platform::event::{EventRef, SharedEvent as _}; + use crate::core::platform::render::RenderEncoder as _; /// `MTLResourceStorageModeMemoryless`, and `MTLTextureUsageShaderWrite`. const MEMORYLESS: u64 = 0x30; @@ -4943,7 +4943,7 @@ pub(crate) mod tests { }); let memoryless = d.new_texture(OnFault::Die, &desc).unwrap().unwrap(); let sampler = d - .new_sampler_state(&reims_vgpu_core::platform::values::SamplerDesc::default()) + .new_sampler_state(&crate::core::platform::values::SamplerDesc::default()) .unwrap() .unwrap(); let state = fixture_state::

(d, "vert:tri_vert", fragment); @@ -5089,9 +5089,9 @@ pub(crate) mod tests { /// however long the other queue's takes to run under load #[test] fn a_type_9_hang_is_in_flight_as_long_as_metals() { - use reims_vgpu_core::platform::event::EventRef; - use reims_vgpu_core::platform::os::Clock as _; - use reims_vgpu_core::platform::types::NsRange; + use crate::core::platform::event::EventRef; + use crate::core::platform::os::Clock as _; + use crate::core::platform::types::NsRange; let (p, d) = (platform(), dev()); let (_dst, pass) = pass_of(&p, &d, (4, 4)); @@ -5186,9 +5186,9 @@ pub(crate) mod tests { /// queue runs meanwhile, as Metal's (the runtime's measurement, `command_buffer/hang.rs`) #[test] fn a_type_9_fault_is_in_flight_as_long_as_metals() { - use reims_vgpu_core::platform::event::EventRef; - use reims_vgpu_core::platform::os::Clock as _; - use reims_vgpu_core::platform::types::NsRange; + use crate::core::platform::event::EventRef; + use crate::core::platform::os::Clock as _; + use crate::core::platform::types::NsRange; let (p, d) = (platform(), dev()); let (_dst, pass) = pass_of(&p, &d, (4, 4)); @@ -5488,9 +5488,9 @@ pub(crate) mod tests { #[cfg(target_os = "linux")] #[test] fn a_draw_through_a_read_only_surface_at_slots_it_cannot_write_draws_on_linux() { - use reims_vgpu_core::platform::os::vm::HostVm as _; - use reims_vgpu_core::platform::resource::Library as _; - use reims_vgpu_core::platform::values::RenderPipelineDesc; + use crate::core::platform::os::vm::HostVm as _; + use crate::core::platform::resource::Library as _; + use crate::core::platform::values::RenderPipelineDesc; use crate::gpu::resource::VulkanRenderPipeline; use crate::gpu::resource::tests::on_read_only_surface; @@ -5603,7 +5603,7 @@ pub(crate) mod tests { /// the pages stayed zeros. #[cfg(target_os = "linux")] fn read_only_pass(load: u64, store: u64, late: Option) -> (u64, Option, bool) { - use reims_vgpu_core::platform::os::vm::HostVm as _; + use crate::core::platform::os::vm::HostVm as _; use crate::gpu::resource::tests::{bgra_over, host_bytes_at, read_only_buffer}; use crate::os::{OsVm, PAGE}; @@ -5713,7 +5713,7 @@ pub(crate) mod tests { #[cfg(target_os = "linux")] #[test] fn a_resolve_into_read_only_memory_dies() { - use reims_vgpu_core::platform::os::vm::HostVm as _; + use crate::core::platform::os::vm::HostVm as _; use crate::gpu::resource::tests::{bgra_over, read_only_buffer}; use crate::os::{OsVm, PAGE}; @@ -6066,7 +6066,7 @@ pub(crate) mod tests { /// `metal_tests::lines_take_metals_flat_inputs_at_the_last_vertex`) #[test] fn empty_draws_go_on_after_the_private_setters() { - use reims_vgpu_core::platform::values::IcbDesc; + use crate::core::platform::values::IcbDesc; let (e, indices) = drawing_encoder(FLAT.0, FLAT.1); let icb = dev() @@ -6165,8 +6165,8 @@ pub(crate) mod tests { /// `render_state_misc` sends them #[test] fn an_amplification_mode_kills_draws_only_where_it_changes_the_count() { - use reims_vgpu_core::platform::types::VertexAmplificationViewMapping; - use reims_vgpu_core::platform::values::IcbDesc; + use crate::core::platform::types::VertexAmplificationViewMapping; + use crate::core::platform::values::IcbDesc; let (e, _indices) = drawing_encoder("vert:tri_vert", "frag:tri_frag"); let icb = dev() @@ -6236,7 +6236,7 @@ pub(crate) mod tests { let (e, dst) = open_encoder(); let d = dev(); let sampler = d - .new_sampler_state(&reims_vgpu_core::platform::values::SamplerDesc::default()) + .new_sampler_state(&crate::core::platform::values::SamplerDesc::default()) .unwrap() .unwrap(); let buf = d @@ -6367,14 +6367,14 @@ pub(crate) mod tests { }, ) .unwrap(); - pass.set_depth_attachment(&reims_vgpu_core::platform::values::DepthAttachmentSet { + pass.set_depth_attachment(&crate::core::platform::values::DepthAttachmentSet { texture: Some(Some(&depth)), resolve_texture: Some(Some(&depth_resolve)), load_action: Some(CLEAR), store_action: Some(STORE), ..Default::default() }); - pass.set_stencil_attachment(&reims_vgpu_core::platform::values::StencilAttachmentSet { + pass.set_stencil_attachment(&crate::core::platform::values::StencilAttachmentSet { texture: Some(Some(&depth)), resolve_texture: Some(Some(&depth_resolve)), load_action: Some(CLEAR), @@ -6461,7 +6461,7 @@ pub(crate) mod tests { }, ) .unwrap(); - pass.set_pass(&reims_vgpu_core::platform::values::PassSet { + pass.set_pass(&crate::core::platform::values::PassSet { render_target_width: Some(16), render_target_height: Some(8), default_raster_sample_count: Some(1), @@ -6506,7 +6506,7 @@ pub(crate) mod tests { let r = pass.set_color_attachment(OnFault::Return, 8, &ColorAttachmentSet::default()); assert!(r.is_err()); assert!(pass.color_attachment_state(8).is_err()); - pass.set_pass(&reims_vgpu_core::platform::values::PassSet { + pass.set_pass(&crate::core::platform::values::PassSet { default_color_sample_count: Some(4), ..Default::default() }); @@ -6516,7 +6516,7 @@ pub(crate) mod tests { /// request the runtime answers its cached state for; every reference answers its handle's #[test] fn every_render_pipeline_creation_takes_a_new_identifier() { - use reims_vgpu_core::platform::resource::RenderPipeline as _; + use crate::core::platform::resource::RenderPipeline as _; let d = dev(); let key = PipelineKey { format: BGRA8, @@ -6537,7 +6537,7 @@ pub(crate) mod tests { /// past it #[test] fn binds_at_the_last_slot_die_at_their_selector() { - use reims_vgpu_core::raise::death::DeathKind; + use crate::core::raise::death::DeathKind; let (p, d) = (platform(), dev()); let b = crate::gpu::resource::tests::shared(64); @@ -6589,9 +6589,9 @@ pub(crate) mod tests { /// (code 1); 1, 4 and 7 complete it #[test] fn a_pass_without_attachments_answers_metals_default_sample_counts() { - use reims_vgpu_core::platform::types::CommandBufferStatus; - use reims_vgpu_core::platform::values::PassSet; - use reims_vgpu_core::raise::death::DeathKind; + use crate::core::platform::types::CommandBufferStatus; + use crate::core::platform::values::PassSet; + use crate::core::raise::death::DeathKind; let p = platform(); let q = dev().new_command_queue().unwrap(); @@ -6651,7 +6651,7 @@ pub(crate) mod tests { /// pipeline state. The execution of one whose commands set their own is taken #[test] fn what_runs_the_pipeline_after_a_nil_one_dies() { - use reims_vgpu_core::platform::values::IcbDesc; + use crate::core::platform::values::IcbDesc; let p = platform(); let d = dev(); @@ -6723,14 +6723,14 @@ pub(crate) mod tests { /// pipeline state draws to RGBA16Float in a pass of a BGRA8 target, which the runtime refuses, /// the buffer made resident with `usage`. fn execute_a_mismatched_draw(usage: u64) { + use crate::core::platform::icb::{ + IcbRenderCmd, IndirectCommandBuffer as _, IndirectRenderCommand as _, + }; + use crate::core::platform::values::IcbDesc; use metal2vulkan::metal::PixelFormat; use metal2vulkan::pipeline::{ ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource, }; - use reims_vgpu_core::platform::icb::{ - IcbRenderCmd, IndirectCommandBuffer as _, IndirectRenderCommand as _, - }; - use reims_vgpu_core::platform::values::IcbDesc; const VERT: &[u8] = include_bytes!("../../../../tests/shaders/vert.metallib"); const FRAG: &[u8] = include_bytes!("../../../../tests/shaders/frag.metallib"); @@ -6814,8 +6814,8 @@ pub(crate) mod tests { /// still refused, which dies at the execution's selector, as no handler of core's learns of it #[test] fn refused_icb_records_die_naming_the_execution() { - use reims_vgpu_core::raise::death::{DeathKind, DeathSite}; - use reims_vgpu_core::testkit::capture::expect_death; + use crate::core::raise::death::{DeathKind, DeathSite}; + use crate::core::testkit::capture::expect_death; let site = catch_death(|| execute_a_mismatched_draw(1)).unwrap_err(); assert_eq!((site.kind, site.file), (DeathKind::Abort, "commit")); @@ -7037,14 +7037,14 @@ pub(crate) mod tests { /// `device-color-conversion` (`PrecisionNote::DeviceColorConversion`) #[test] fn a_pass_executes_an_icbs_draws() { + use crate::core::platform::icb::{ + IcbRenderCmd, IndirectCommandBuffer as _, IndirectRenderCommand as _, + }; + use crate::core::platform::values::IcbDesc; use metal2vulkan::metal::PixelFormat; use metal2vulkan::pipeline::{ ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource, }; - use reims_vgpu_core::platform::icb::{ - IcbRenderCmd, IndirectCommandBuffer as _, IndirectRenderCommand as _, - }; - use reims_vgpu_core::platform::values::IcbDesc; const VERT: &[u8] = include_bytes!("../../../../tests/shaders/vert.metallib"); const FRAG: &[u8] = include_bytes!("../../../../tests/shaders/frag.metallib"); @@ -7216,17 +7216,17 @@ pub(crate) mod tests { /// made resident for writing, it dies at the execution #[test] fn an_execution_of_states_of_its_own_writes_no_bound_texture() { + use crate::core::host::PhysicalMemoryRange; + use crate::core::platform::icb::{ + IcbRenderCmd, IndirectCommandBuffer as _, IndirectRenderCommand as _, + }; + use crate::core::platform::os::surface::SurfaceSpec; + use crate::core::platform::os::vm::HostVm as _; + use crate::core::platform::values::IcbDesc; use metal2vulkan::metal::PixelFormat; use metal2vulkan::pipeline::{ ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource, }; - use reims_vgpu_core::host::PhysicalMemoryRange; - use reims_vgpu_core::platform::icb::{ - IcbRenderCmd, IndirectCommandBuffer as _, IndirectRenderCommand as _, - }; - use reims_vgpu_core::platform::os::surface::SurfaceSpec; - use reims_vgpu_core::platform::os::vm::HostVm as _; - use reims_vgpu_core::platform::values::IcbDesc; const VERT: &[u8] = include_bytes!("../../../../tests/shaders/vert.metallib"); const FRAG: &[u8] = include_bytes!("../../../../tests/shaders/frag.metallib"); @@ -7292,7 +7292,7 @@ pub(crate) mod tests { element_height: 1, client_direction: Some(2), client_address_ranges: Some(vec![PhysicalMemoryRange { - physical_address: reims_vgpu_core::num::ToU64::to_u64(guest.addr()), + physical_address: crate::core::num::ToU64::to_u64(guest.addr()), physical_length: page, }]), ..SurfaceSpec::default() @@ -7360,16 +7360,16 @@ pub(crate) mod tests { /// there #[test] fn a_pass_of_a_mutable_rate_map_not_yet_reset_rasterizes_nothing() { + use crate::core::platform::rate_map::{ + RateMap as _, RateMapDescriptor as _, RateMapLayerDescriptor as _, + }; + use crate::core::platform::values::{ + DepthAttachmentSet, DepthStencilDesc, PassSet, RateMapDesc, + }; use metal2vulkan::metal::PixelFormat; use metal2vulkan::pipeline::{ ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource, }; - use reims_vgpu_core::platform::rate_map::{ - RateMap as _, RateMapDescriptor as _, RateMapLayerDescriptor as _, - }; - use reims_vgpu_core::platform::values::{ - DepthAttachmentSet, DepthStencilDesc, PassSet, RateMapDesc, - }; const VERT: &[u8] = include_bytes!("../../../../tests/shaders/vert.metallib"); const FRAG: &[u8] = include_bytes!("../../../../tests/shaders/mutdec_fwrite.metallib"); @@ -7561,10 +7561,10 @@ pub(crate) mod tests { side: u64, mutability: u64, ) -> crate::gpu::rate_map::VulkanRateMapDescriptor { - use reims_vgpu_core::platform::rate_map::{ + use crate::core::platform::rate_map::{ RateMapDescriptor as _, RateMapLayerDescriptor as _, }; - use reims_vgpu_core::platform::values::RateMapDesc; + use crate::core::platform::values::RateMapDesc; let m = p.rate_map_descriptor(&RateMapDesc { screen_size: MtlSize::new(side, side, 1), @@ -7595,11 +7595,11 @@ pub(crate) mod tests { fn a_reset_waits_for_a_committed_pass_core_let_go_of() { use std::sync::mpsc; - use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; - use reims_vgpu_core::platform::rate_map::RateMap as _; - use reims_vgpu_core::platform::values::PassSet; + use crate::core::platform::event::{EventRef, SharedEvent as _}; + use crate::core::platform::rate_map::RateMap as _; + use crate::core::platform::values::PassSet; - use reims_vgpu_core::platform::values::RateMapDesc; + use crate::core::platform::values::RateMapDesc; let p = platform(); let d = dev(); @@ -7651,11 +7651,11 @@ pub(crate) mod tests { /// creation or a reset, and a draw in a pass over it is taken #[test] fn draws_over_a_map_of_varying_rates_die() { - use reims_vgpu_core::platform::rate_map::{ + use crate::core::platform::rate_map::{ RateMap as _, RateMapDescriptor as _, RateMapLayerDescriptor as _, }; - use reims_vgpu_core::platform::values::{PassSet, RateMapDesc}; - use reims_vgpu_core::raise::death::DeathKind; + use crate::core::platform::values::{PassSet, RateMapDesc}; + use crate::core::raise::death::DeathKind; use crate::gpu::rate_map::{VulkanRateMap, VulkanRateMapDescriptor}; @@ -7829,8 +7829,8 @@ pub(crate) mod tests { /// reuses it. Every pass completes with no error, none failed as a GPU hang #[test] fn no_draw_moves_later_plain_identifiers_only_for_a_pass_that_drew_nothing() { - use reims_vgpu_core::platform::rate_map::RateMap as _; - use reims_vgpu_core::platform::values::PassSet; + use crate::core::platform::rate_map::RateMap as _; + use crate::core::platform::values::PassSet; /// `MTLPrimitiveTypeTriangle` and `TriangleStrip`. const TRIANGLE: u64 = 3; diff --git a/crates/reims-vgpu-vulkan/src/gpu/encode_render/tests/many_passes.rs b/crates/reims-vgpu-vulkan/src/gpu/encode_render/tests/many_passes.rs index 412112b6f..9b701dab6 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/encode_render/tests/many_passes.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/encode_render/tests/many_passes.rs @@ -19,11 +19,11 @@ //! runtime's device memory grows by no attachment's bytes a pass, and the target holds what the //! draws left. -use reims_vgpu_core::host::HostPtr; -use reims_vgpu_core::num::{ToU64, ToUsize}; -use reims_vgpu_core::platform::os::vm::HostVm as _; -use reims_vgpu_core::platform::resource::Library as _; -use reims_vgpu_core::platform::values::{ +use crate::core::host::HostPtr; +use crate::core::num::{ToU64, ToUsize}; +use crate::core::platform::os::vm::HostVm as _; +use crate::core::platform::resource::Library as _; +use crate::core::platform::values::{ ColorAttachmentDesc, DepthAttachmentSet, DepthStencilDesc, FullRenderPipelineDesc, LinkedFunctionsDesc, PassSet, StencilAttachmentSet, StencilDesc, SurfaceFacts, SurfacePlane, }; diff --git a/crates/reims-vgpu-vulkan/src/gpu/encode_render/tests/mesh.rs b/crates/reims-vgpu-vulkan/src/gpu/encode_render/tests/mesh.rs index 708769982..52dd01b5a 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/encode_render/tests/mesh.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/encode_render/tests/mesh.rs @@ -6,9 +6,9 @@ //! `mesh.metal` holds. MoltenVK has no `VK_EXT_mesh_shader`, so on a Mac the runtime draws them //! emulated (the module docs). -use reims_vgpu_core::platform::resource::Library as _; -use reims_vgpu_core::platform::types::NsErrorText; -use reims_vgpu_core::platform::values::{ +use crate::core::platform::resource::Library as _; +use crate::core::platform::types::NsErrorText; +use crate::core::platform::values::{ ColorAttachmentDesc, FullMeshRenderPipelineDesc, LinkedFunctionsDesc, SamplerDesc, }; diff --git a/crates/reims-vgpu-vulkan/src/gpu/encode_render/tests/metal_tests.rs b/crates/reims-vgpu-vulkan/src/gpu/encode_render/tests/metal_tests.rs index 4bc6d2c44..d7106aac1 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/encode_render/tests/metal_tests.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/encode_render/tests/metal_tests.rs @@ -2,7 +2,7 @@ use std::sync::Arc; -use reims_vgpu_core::platform::values::FullRenderPipelineDesc; +use crate::core::platform::values::FullRenderPipelineDesc; use super::*; @@ -559,7 +559,7 @@ fn variant_on_both(variant: Variant, on_metal: bool) -> Vec<[u8; 4]> { let (p, d) = (platform(), dev()); let vulkan = present_as(&p, &d, &frame.make(&p, &d), None, variant); if on_metal { - reims_vgpu_core::metal_check!(format!("{variant:?}"), vulkan); + crate::metal_check!(format!("{variant:?}"), vulkan); } vulkan } @@ -656,7 +656,7 @@ fn quads_give_metals_primitive_ids() { let key = format!("{draw:?} at mode {mode}"); let ours = flat_pass(&p, &d, PRIMITIVES, mode, draw); assert!(ours != clear, "{key}"); - assert!(reims_vgpu_core::metal_matches_raw!(key, ours), "{key}"); + assert!(crate::metal_matches_raw!(key, ours), "{key}"); } } } @@ -701,7 +701,7 @@ fn private_types_from_far_vertex_starts_draw_as_metals() { differ.push(format!("{draw:?} at mode {mode}: drew nothing")); } let key = format!("{draw:?} at mode {mode}"); - if !reims_vgpu_core::metal_matches_raw!(key, ours) { + if !crate::metal_matches_raw!(key, ours) { differ.push(format!("{key}: pixels differ")); } } @@ -772,7 +772,7 @@ fn private_types_draw_over_indices_and_arguments_as_metals() { let ours = provoked(&p, &d, functions, (mode, restart), draw); blank += usize::from(ours == clear); let key = format!("{draw:?} of {functions:?} at mode {mode}"); - assert!(reims_vgpu_core::metal_matches_raw!(key, ours), "{key}"); + assert!(crate::metal_matches_raw!(key, ours), "{key}"); } } } @@ -915,10 +915,10 @@ fn provoked( (mode, restart): (u64, Option<(bool, u64)>), draw: Provoked<'_>, ) -> Vec<[u8; 4]> { - use reims_vgpu_core::platform::icb::{ + use crate::core::platform::icb::{ IcbRenderCmd, IndirectCommandBuffer as _, IndirectRenderCommand as _, }; - use reims_vgpu_core::platform::values::IcbDesc; + use crate::core::platform::values::IcbDesc; let executed = matches!(draw, Provoked::Executed { .. }); let state = value_state::

(d, functions, |v| { @@ -1200,7 +1200,7 @@ fn flat_inputs_take_metals_provoking_vertex_at_every_draw() { assert_eq!(first == last, execution, "{draw:?}"); for (mode, ours) in [(0, &first), (1, &last)] { let key = format!("{draw:?} at mode {mode}"); - assert!(reims_vgpu_core::metal_matches_raw!(key, ours), "{key}"); + assert!(crate::metal_matches_raw!(key, ours), "{key}"); } } for draw in [ @@ -1256,17 +1256,11 @@ fn lines_take_metals_flat_inputs_at_the_last_vertex() { assert!(first != last, "{draw:?}"); let keys = [0, 1].map(|mode| format!("{draw:?} at mode {mode}")); let colours = format!("{draw:?} at mode 1: the colours"); - assert!( - reims_vgpu_core::metal_matches_raw!(keys[0], first), - "{draw:?}" - ); + assert!(crate::metal_matches_raw!(keys[0], first), "{draw:?}"); if native { - assert!( - reims_vgpu_core::metal_matches_raw!(keys[1], last), - "{draw:?}" - ); + assert!(crate::metal_matches_raw!(keys[1], last), "{draw:?}"); } else { - reims_vgpu_core::metal_check!(colours, colours_of(&last)); + crate::metal_check!(colours, colours_of(&last)); } } } @@ -1334,7 +1328,7 @@ fn lines_draw_at_metals_widths() { lit_at.push(lit(&ours)); let key = format!("{primitive_type} at {w}"); if exact { - assert!(reims_vgpu_core::metal_matches_raw!(key, ours), "{key}"); + assert!(crate::metal_matches_raw!(key, ours), "{key}"); } } assert!(lit_at[1] > lit_at[0], "{primitive_type}: {lit_at:?}"); @@ -1366,7 +1360,7 @@ fn barycentric_weights_take_metals_order_at_the_last_vertex() { let ours = provoked(&p, &d, smooth, (mode, None), draw); assert_ne!(ours, vec![[0, 0, 0, 0xff]; 256], "{draw:?}"); let key = format!("smooth: {draw:?} at mode {mode}"); - assert!(reims_vgpu_core::metal_matches_raw!(key, ours), "{key}"); + assert!(crate::metal_matches_raw!(key, ours), "{key}"); } } for draw in [ @@ -1383,15 +1377,9 @@ fn barycentric_weights_take_metals_order_at_the_last_vertex() { None }; let keys = [0, 1].map(|mode| format!("flat: {draw:?} at mode {mode}")); - assert!( - reims_vgpu_core::metal_matches_raw!(keys[0], first), - "{draw:?}" - ); + assert!(crate::metal_matches_raw!(keys[0], first), "{draw:?}"); if let Some(last) = last { - assert!( - reims_vgpu_core::metal_matches_raw!(keys[1], last), - "{draw:?}" - ); + assert!(crate::metal_matches_raw!(keys[1], last), "{draw:?}"); } } } @@ -1437,7 +1425,7 @@ fn modes_past_1_draw_metals_third_way() { // Metal's third way, which a list's triangles draw as at mode 1. let key = format!("{draw:?}: the third way"); if at == 0 { - assert!(reims_vgpu_core::metal_matches_raw!(key, last), "{draw:?}"); + assert!(crate::metal_matches_raw!(key, last), "{draw:?}"); } } } @@ -1466,7 +1454,7 @@ fn re_indexed_draws_keep_metals_vertex_ids() { "{draw:?}" ); let key = format!("{mode} {draw:?}"); - reims_vgpu_core::metal_check_raw!(key, ours); + crate::metal_check_raw!(key, ours); } } @@ -1506,7 +1494,7 @@ fn re_indexed_draws_keep_metals_draw_bases() { "{mode} {draw:?}" ); let key = format!("{mode} {draw:?}"); - reims_vgpu_core::metal_check_raw!(key, ours); + crate::metal_check_raw!(key, ours); } } @@ -1517,7 +1505,7 @@ fn classed_state( (vertex, indirect): (&str, bool), class: PrimitiveTopologyClass, ) -> crate::gpu::resource::VulkanRenderPipeline { - use reims_vgpu_core::platform::resource::Library as _; + use crate::core::platform::resource::Library as _; let library = d.new_library(VERTEX_IDS).unwrap().unwrap().unwrap(); let function = |name| library.new_function(OnFault::Die, name).unwrap().unwrap(); @@ -1581,7 +1569,7 @@ fn points_die_where_metal_sizes_none() { pass_pixels(&p, &d, points::(&classed)), ours ); - reims_vgpu_core::metal_check_raw!("the sized points", ours); + crate::metal_check_raw!("the sized points", ours); } /// An indirect command buffer of two commands whose first draws `count` points from vertex 1 @@ -1591,10 +1579,10 @@ fn points_icb( state: Option<&crate::gpu::resource::VulkanRenderPipeline>, count: u64, ) -> crate::gpu::icb::VulkanIcb { - use reims_vgpu_core::platform::icb::{ + use crate::core::platform::icb::{ IcbRenderCmd, IndirectCommandBuffer as _, IndirectRenderCommand as _, }; - use reims_vgpu_core::platform::values::IcbDesc; + use crate::core::platform::values::IcbDesc; let icb = d .new_indirect_command_buffer( @@ -1671,7 +1659,7 @@ fn commit_dies(cmds: Vec>) -> String { /// the buffer's commands #[test] fn executed_points_die_where_metal_sizes_none() { - use reims_vgpu_core::platform::event::EventRef; + use crate::core::platform::event::EventRef; let (p, d) = (platform(), dev()); let unsizing = classed_state( @@ -1760,7 +1748,7 @@ fn executed_points_die_where_metal_sizes_none() { blit.encode(OnFault::Die, reset).unwrap(); } -reims_vgpu_core::death_test!( +crate::death_test!( /// An execution of a buffer whose records the GPU may have written (a blit's reset of another /// of its commands) is asked at the runtime's host step, once the work before it completed: /// its draw of points under a state of its own that writes no `[[point_size]]` outside the @@ -1792,7 +1780,7 @@ reims_vgpu_core::death_test!( pass_pixels(&p, &d, execute_first(&written, None)); }, |report| { - use reims_vgpu_core::raise::death::{DeathId, DeathKind}; + use crate::core::raise::death::{DeathId, DeathKind}; report.assert_died( DeathId::Platform { kind: DeathKind::Abort, @@ -1812,10 +1800,10 @@ reims_vgpu_core::death_test!( /// cannot, and one where the buffer made resident for writing is numbered 1 #[test] fn work_that_can_encode_after_an_icb_made_writable_runs() { - use reims_vgpu_core::platform::icb::{ + use crate::core::platform::icb::{ IcbRenderCmd, IndirectCommandBuffer as _, IndirectRenderCommand as _, }; - use reims_vgpu_core::platform::values::IcbDesc; + use crate::core::platform::values::IcbDesc; let (p, d) = (platform(), dev()); d.reserve_resource_indices(5, &[2, (1 << 23) + 1]).unwrap(); @@ -2007,7 +1995,7 @@ fn re_indexed_draws_run_the_vertex_function_as_often_as_metals() { let ours = vertex_runs(&p, &d, mode, draw); assert!(ours.iter().any(|&n| n > 1), "{mode} {draw:?}"); let key = format!("{mode} {draw:?}"); - reims_vgpu_core::metal_check_raw!(key, ours); + crate::metal_check_raw!(key, ours); } } @@ -2046,7 +2034,7 @@ fn private_types_run_the_vertex_function_as_often_as_metals_at_every_draw() { let ours = crate::answer::relaxed(|| provoked_runs(&p, &d, (mode, restart), draw)); assert!(ours.iter().any(|&n| n > 1), "{draw:?} at mode {mode}"); let key = format!("{draw:?} at mode {mode}"); - reims_vgpu_core::metal_check_raw!(key, ours); + crate::metal_check_raw!(key, ours); } } } @@ -2089,11 +2077,11 @@ fn swept( kind: u32, drawn: Drawn<'_>, ) -> Vec { - use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; - use reims_vgpu_core::platform::resource::Library as _; - use reims_vgpu_core::platform::types::NsRange; + use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; + use crate::core::platform::resource::Library as _; + use crate::core::platform::types::NsRange; - use reims_vgpu_core::platform::values::FullComputePipelineDesc; + use crate::core::platform::values::FullComputePipelineDesc; use crate::gpu::device::tests::render_value; @@ -2226,12 +2214,12 @@ fn texture_writes_round_as_metals() { for format in half.into_iter().chain(rest) { let key = format!("kernel {format:?} sweep {kind}"); let ours = swept(&p, &d, true, format, kind, PLAIN); - assert!(reims_vgpu_core::metal_matches_bytes!(key, &ours), "{key}"); + assert!(crate::metal_matches_bytes!(key, &ours), "{key}"); } for format in half.into_iter().chain(rest).chain([srgb]) { let key = format!("render {format:?} sweep {kind}"); let ours = swept(&p, &d, false, format, kind, PLAIN); - assert!(reims_vgpu_core::metal_matches_bytes!(key, &ours), "{key}"); + assert!(crate::metal_matches_bytes!(key, &ours), "{key}"); } } } @@ -2257,8 +2245,8 @@ fn texture_writes_round_as_metals() { ignore = "MoltenVK: the runtime records device-pack-conversion, a death in strict mode; Mac-only test, off everywhere; ledger: MoltenVK strict deaths" )] fn extended_range_fetches_are_made_where_the_runtime_blends_them() { - use reims_vgpu_core::platform::resource::Library as _; - use reims_vgpu_core::raise::death::DeathKind; + use crate::core::platform::resource::Library as _; + use crate::core::raise::death::DeathKind; use crate::gpu::device::tests::render_value; @@ -2491,7 +2479,7 @@ fn blended_state( format: u32, blend: Option<[u32; 6]>, ) -> Result<(), i64> { - use reims_vgpu_core::platform::resource::Library as _; + use crate::core::platform::resource::Library as _; use crate::gpu::device::tests::render_value; @@ -2553,7 +2541,7 @@ fn second_source_blends_without_a_second_output_are_refused_as_metals() { catch_death(|| blended_state::(&d, (library, fragment), format, blend)); let line = crate::answer::LAST_LINE.lock().take().unwrap_or_default(); match ours { - Ok(ours) if reims_vgpu_core::metal_matches!(what, ours) => {} + Ok(ours) if crate::metal_matches!(what, ours) => {} Ok(ours) => differ.push(format!("{what}: ours {ours:?}, not Metal's")), Err(site) => differ.push(format!("{what}: died at {}: {line}", site.file)), } @@ -2585,9 +2573,9 @@ fn xr_blended_masked( (blend, mask): (Option<[u32; 6]>, Option), across: bool, ) -> Vec { - use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; - use reims_vgpu_core::platform::resource::Library as _; - use reims_vgpu_core::rt::Pool; + use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; + use crate::core::platform::resource::Library as _; + use crate::core::rt::Pool; use crate::gpu::device::tests::render_value; @@ -2685,8 +2673,8 @@ fn xr_read_back( library: &P::Library, t: &P::Texture, ) -> Vec { - use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; - use reims_vgpu_core::platform::resource::Library as _; + use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; + use crate::core::platform::resource::Library as _; let read = library .new_function(OnFault::Die, "xr_read") @@ -2800,9 +2788,9 @@ fn xr_compared( continue; } }; - let (count, wrong) = if reims_vgpu_core::metal_matches_bytes!(what, &ours) { + let (count, wrong) = if crate::metal_matches_bytes!(what, &ours) { (0, None) - } else if let Some(theirs) = reims_vgpu_core::metal_full!(what) { + } else if let Some(theirs) = crate::metal_full!(what) { let count = (ours.chunks(16).zip(theirs.chunks(16))) .filter(|(o, t)| o != t) .count(); @@ -2933,7 +2921,7 @@ fn float4_extended_range_blends_are_metals_here() { ignore = "MoltenVK: the runtime records device-pack-conversion, a death in strict mode; Mac-only test, off everywhere; ledger: MoltenVK strict deaths" )] fn float4_extended_range_blends_die_naming_their_source() { - use reims_vgpu_core::raise::death::DeathKind; + use crate::core::raise::death::DeathKind; const DRAW: &str = "drawPrimitives:vertexStart:vertexCount:"; let drawn = ("fast math", ROUNDING, "xr_float_fragment"); @@ -2991,7 +2979,7 @@ const XR_CONSTANT_DIFFERENCES: [[u32; 6]; 2] = [[11, 12, 1, 1, 1, 0], [12, 11, 2 ignore = "MoltenVK: the runtime records device-pack-conversion, a death in strict mode; Mac-only test, off everywhere; ledger: MoltenVK strict deaths" )] fn extended_range_blends_drawn_without_fast_math_alone_are_metals() { - use reims_vgpu_core::raise::death::DeathKind; + use crate::core::raise::death::DeathKind; const STATE: &str = "newRenderPipelineStateWithDescriptor:options:reflection:error:"; let fragments = [ @@ -3108,7 +3096,7 @@ const XR_DUAL_BLENDS: [[u32; 6]; 6] = [ ignore = "MoltenVK: the runtime records device-pack-conversion, a death in strict mode; Mac-only test, off everywhere; ledger: MoltenVK strict deaths" )] fn extended_range_masked_blends_and_two_output_states_are_metals() { - use reims_vgpu_core::raise::death::DeathKind; + use crate::core::raise::death::DeathKind; const STATE: &str = "newRenderPipelineStateWithDescriptor:options:reflection:error:"; let ours = xr_sides(); @@ -3129,7 +3117,7 @@ fn extended_range_masked_blends_and_two_output_states_are_metals() { *crate::answer::LAST_LINE.lock() = None; let ours = catch_death(|| ours.masked(library, format, shape, true)); match ours { - Ok(ours) if reims_vgpu_core::metal_matches_bytes!(what, &ours) => {} + Ok(ours) if crate::metal_matches_bytes!(what, &ours) => {} Ok(_) => differ.push(format!("{what}: the texels differ from Metal's")), Err(site) => { let line = crate::answer::LAST_LINE.lock().take().unwrap_or_default(); @@ -3161,7 +3149,7 @@ fn extended_range_masked_blends_and_two_output_states_are_metals() { *crate::answer::LAST_LINE.lock() = None; let ours = catch_death(|| ours.masked(library, format, shape, true)); match ours { - Ok(ours) if reims_vgpu_core::metal_matches_bytes!(what, &ours) => {} + Ok(ours) if crate::metal_matches_bytes!(what, &ours) => {} Ok(_) => differ.push(format!("{what}: the texels differ from Metal's")), Err(site) => { let line = crate::answer::LAST_LINE.lock().take().unwrap_or_default(); @@ -3318,10 +3306,10 @@ fn half4_extended_range_blends_are_metals_without_fast_math() { /// platform `P` that clears it to `clear` and draws `xr_half_fragment` of seed 1 into it under /// source and destination factor one, added, colour and alpha. fn xr_blended_onto_clear(p: &P, d: &P::Device, clear: [f64; 4]) -> Vec { - use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; - use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; - use reims_vgpu_core::platform::resource::Library as _; - use reims_vgpu_core::platform::types::ClearColor; + use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; + use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; + use crate::core::platform::resource::Library as _; + use crate::core::platform::types::ClearColor; use crate::gpu::device::tests::render_value; @@ -3575,7 +3563,7 @@ impl Channels { ignore = "MoltenVK: the runtime records device-nan-encoding, a death in strict mode; Mac-only test, off everywhere; ledger: MoltenVK strict deaths" )] fn half_outputs_store_within_the_bound_or_die_named() { - use reims_vgpu_core::platform::resource::Library as _; + use crate::core::platform::resource::Library as _; use crate::gpu::device::tests::render_value; @@ -3821,7 +3809,7 @@ fn half_outputs_store_within_the_bound_or_die_named() { let float4 = (ROUNDING, "sweep_fragment", kind); let key = format!("{format:?} {blend:?} sweep {kind}: a float4 output"); let ours = drawn((&p, &d), *format, float4, blend, under); - if !reims_vgpu_core::metal_matches_bytes!(key, &ours) { + if !crate::metal_matches_bytes!(key, &ours) { wrong.push(format!( "{format:?} {blend:?} sweep {kind}: a float4 output" )); @@ -3850,9 +3838,9 @@ fn half_outputs_store_within_the_bound_or_die_named() { let key = format!("{format:?} {blend:?} sweep {kind}: a half4 output"); let ours = drawn((&p, &d), *format, half4, blend, under); // Metal's bytes in full where ours differ from them, else by their digest. - let (far, count) = if reims_vgpu_core::metal_matches_bytes!(key, &ours) { + let (far, count) = if crate::metal_matches_bytes!(key, &ours) { (0.0, 0) - } else if let Some(theirs) = reims_vgpu_core::metal_full!(key) { + } else if let Some(theirs) = crate::metal_full!(key) { channels.apart(&ours, &theirs) } else { (f64::INFINITY, ours.len()) @@ -3900,7 +3888,7 @@ fn half_outputs_store_within_the_bound_or_die_named() { ignore = "MoltenVK: the runtime records device-pack-conversion, a death in strict mode; Mac-only test, off everywhere; ledger: MoltenVK strict deaths" )] fn bfloat_draws_store_metals_codes() { - use reims_vgpu_core::raise::death::DeathKind; + use crate::core::raise::death::DeathKind; const STATE: &str = "newRenderPipelineStateWithDescriptor:error:"; const DRAW: &str = "drawPrimitives:vertexStart:vertexCount:"; @@ -3917,7 +3905,7 @@ fn bfloat_draws_store_metals_codes() { let case = format!("{format:?} {output} sweep {kind}"); *crate::answer::LAST_LINE.lock() = None; match catch_death(|| swept(&p, &d, false, format, kind, how)) { - Ok(ours) if reims_vgpu_core::metal_matches_bytes!(case, &ours) => {} + Ok(ours) if crate::metal_matches_bytes!(case, &ours) => {} Ok(_) => differ.push(format!("{case}: the bytes differ from Metal's")), Err(site) => { let line = crate::answer::LAST_LINE.lock().take().unwrap_or_default(); @@ -3969,8 +3957,8 @@ fn resolved( kind: u32, (offset, apart): (f64, bool), ) -> Vec { - use reims_vgpu_core::platform::resource::Library as _; - use reims_vgpu_core::platform::types::ClearColor; + use crate::core::platform::resource::Library as _; + use crate::core::platform::types::ClearColor; use crate::gpu::device::tests::render_value; @@ -4108,7 +4096,7 @@ fn drawn_resolved( store: u64, tables: &[Vec<[f32; 4]>; 2], ) -> Vec { - use reims_vgpu_core::platform::resource::Library as _; + use crate::core::platform::resource::Library as _; use crate::gpu::device::tests::render_value; @@ -4306,7 +4294,7 @@ fn drawn_nan_and_infinite_samples_resolve_as_metals() { } let key = format!("{format} {samples}x store {store}"); let ours = drawn_resolved(&p, &d, case, store, &drawn_specials()); - if !reims_vgpu_core::metal_matches_bytes!(key, &ours) { + if !crate::metal_matches_bytes!(key, &ours) { differ.push(format!("{key}: the texels differ from Metal's")); } } @@ -4403,10 +4391,10 @@ fn drawn_extended_range_samples_resolve_as_metals() { } }; // Metal's texels in full where ours differ from them, else by their digest. - if reims_vgpu_core::metal_matches_bytes!(what, &ours) { + if crate::metal_matches_bytes!(what, &ours) { continue; } - let Some(theirs) = reims_vgpu_core::metal_full!(what) else { + let Some(theirs) = crate::metal_full!(what) else { differ.push(format!( "{what}: differs from Metal's, recorded by its digest" )); @@ -4675,7 +4663,7 @@ fn sweep_state( colours: &[(u32, u64)], depth: Option, ) -> P::RenderPipeline { - use reims_vgpu_core::platform::resource::Library as _; + use crate::core::platform::resource::Library as _; use crate::gpu::device::tests::render_value; @@ -4729,10 +4717,8 @@ fn copy_out<'a, P: Platform>( /// A rate map of a `width` by `height` screen, with one layer of one sample of 1 on each axis. fn even_rate_map(p: &P, d: &P::Device, (width, height): (u64, u64)) -> P::RateMap { - use reims_vgpu_core::platform::rate_map::{ - RateMapDescriptor as _, RateMapLayerDescriptor as _, - }; - use reims_vgpu_core::platform::values::RateMapDesc; + use crate::core::platform::rate_map::{RateMapDescriptor as _, RateMapLayerDescriptor as _}; + use crate::core::platform::values::RateMapDesc; let m = p.rate_map_descriptor(&RateMapDesc { screen_size: MtlSize::new(width, height, 1), @@ -4771,12 +4757,12 @@ fn resolved_into>( states: &States<'_, P>, c: Resolve, ) -> Resolved { - use reims_vgpu_core::platform::os::surface::{Surface as _, SurfaceSpec}; - use reims_vgpu_core::platform::values::{DepthAttachmentSet, PassSet, StencilAttachmentSet}; + use crate::core::platform::os::surface::{Surface as _, SurfaceSpec}; + use crate::core::platform::values::{DepthAttachmentSet, PassSet, StencilAttachmentSet}; /// `kIOSurfaceLockReadOnly`. const READ_ONLY: u32 = 1; - let _pool = reims_vgpu_core::rt::Pool::here(); + let _pool = crate::core::rt::Pool::here(); let (into, bytes) = c.into; let (width, height) = c.size; let length = width * height * bytes; @@ -5085,7 +5071,7 @@ fn resolved_into>( /// The death of `f`, which must abort at `sel`, and its line. fn died_at(sel: &str, f: impl FnOnce() -> T) -> String { - use reims_vgpu_core::raise::death::DeathKind; + use crate::core::raise::death::DeathKind; *crate::answer::LAST_LINE.lock() = None; let Err(site) = catch_death(f) else { panic!("no death at {sel}"); @@ -5226,7 +5212,7 @@ fn resolves_into_other_formats_are_metals_or_die_named() { let mut both = |c: Resolve, keeps: bool| { let resolved = resolved_into(&p, &d, &ours, c); let key = format!("{c:?}"); - if !reims_vgpu_core::metal_matches_raw!(key, raw(&resolved)) { + if !crate::metal_matches_raw!(key, raw(&resolved)) { differ.push(format!("{c:?}: ours {}, not Metal's", shown(&resolved))); } if kept(&resolved.resolved) != keeps { @@ -5480,7 +5466,7 @@ fn samples_resolved_into_the_twin_are_metals() { let c = Resolve::of(from, (twin, 4), made, (load, RESOLVE)); let key = format!("{c:?}"); let o = resolved_into(&p, &d, &ours, c); - if !reims_vgpu_core::metal_matches_bytes!(key, &o.samples) { + if !crate::metal_matches_bytes!(key, &o.samples) { let head = |b: &[u8]| b.iter().take(8).copied().collect::>(); let o = head(&o.samples); differ.push(format!("{c:?}: ours {o:02x?}, not Metal's")); @@ -5507,12 +5493,10 @@ fn samples_resolved_into_the_twin_are_metals() { /// by a store action left `Unknown`, which the runtime refuses as the pass is made #[test] fn untouched_resolves_in_shapes_not_measured_die_named() { - use reims_vgpu_core::platform::os::surface::{SurfacePlaneSpec, SurfaceSpec}; - use reims_vgpu_core::platform::rate_map::{ - RateMapDescriptor as _, RateMapLayerDescriptor as _, - }; - use reims_vgpu_core::platform::resource::Heap as _; - use reims_vgpu_core::platform::values::{ + use crate::core::platform::os::surface::{SurfacePlaneSpec, SurfaceSpec}; + use crate::core::platform::rate_map::{RateMapDescriptor as _, RateMapLayerDescriptor as _}; + use crate::core::platform::resource::Heap as _; + use crate::core::platform::values::{ DepthAttachmentSet, HeapDesc, OptionSet, PassSet, RateMapDesc, }; @@ -5813,7 +5797,7 @@ fn untouched_resolves_in_shapes_not_measured_die_named() { /// refuses.) #[test] fn late_setters_of_a_dropped_resolve_are_the_descriptors() { - use reims_vgpu_core::platform::values::{DepthAttachmentSet, StencilAttachmentSet}; + use crate::core::platform::values::{DepthAttachmentSet, StencilAttachmentSet}; /// `MTLPixelFormatBGRA8Unorm_sRGB`; `MTLStoreActionUnknown`. const BGRA8_SRGB: u64 = 81; @@ -5942,7 +5926,7 @@ fn late_setters_of_a_dropped_resolve_are_the_descriptors() { /// late `Store` #[test] fn late_resolves_beside_a_dropped_one_follow_late_store_actions() { - use reims_vgpu_core::platform::values::{DepthAttachmentSet, StencilAttachmentSet}; + use crate::core::platform::values::{DepthAttachmentSet, StencilAttachmentSet}; /// `MTLPixelFormatBGRA8Unorm_sRGB`; `MTLStoreActionUnknown`. const BGRA8_SRGB: u64 = 81; @@ -6118,7 +6102,7 @@ fn resolves_as_metals(samples: u64) { for how in hows { let ours = resolved(&p, &d, samples, format, kind, how); let key = key(format, kind, how); - assert!(reims_vgpu_core::metal_matches_bytes!(key, &ours), "{key}"); + assert!(crate::metal_matches_bytes!(key, &ours), "{key}"); } } } @@ -6144,8 +6128,8 @@ fn routed_pass( (indices, mode): (&[u32], u64), draw: RenderCmd<'_, P>, ) -> Vec<[u8; 4]> { - use reims_vgpu_core::platform::types::MtlViewport; - use reims_vgpu_core::platform::values::PassSet; + use crate::core::platform::types::MtlViewport; + use crate::core::platform::values::PassSet; let state = routed_state::

(d, vertex, class); let (pos, _) = flat_vertices::

(d, 16); @@ -6315,7 +6299,7 @@ fn the_last_vertex_routes_layers_and_viewports_as_metals() { let key = format!("{vertex} {indices:?} at mode {mode}, draw {kind}"); let compared = kind < 5 || mode == 0 || native; if compared { - assert!(reims_vgpu_core::metal_matches_raw!(key, ours), "{key}"); + assert!(crate::metal_matches_raw!(key, ours), "{key}"); } } } @@ -6361,7 +6345,7 @@ fn indexed_strips_restart_at_the_set_index_as_metals_do() { } for indirectly in [false, true] { let key = format!("{case}, Metal's indirect {indirectly}"); - reims_vgpu_core::metal_check_raw!(key, ours); + crate::metal_check_raw!(key, ours); } } } @@ -6379,7 +6363,7 @@ fn a_long_restarted_strip_draws_within_the_index_pool_as_metals() { let restart = Some((true, 3)); let ours = restart_draw(&p, &d, drawn, restart, (true, 0)); let key = format!("{index_type}"); - reims_vgpu_core::metal_check_raw!(key, ours); + crate::metal_check_raw!(key, ours); } } @@ -6420,7 +6404,7 @@ fn private_types_draw_after_a_restart_set_as_metals_do() { assert_eq!(ours, unset, "type {primitive_type} at {k}"); } let key = format!("type {primitive_type} at {k}"); - reims_vgpu_core::metal_check_raw!(key, ours); + crate::metal_check_raw!(key, ours); } } } @@ -6444,14 +6428,14 @@ fn executed_strip( (index_type, indices): (u64, &[u8]), (enabled, index): (bool, u64), ) -> Vec<[u8; 4]> { + use crate::core::platform::icb::{ + IcbRenderCmd, IndirectCommandBuffer as _, IndirectRenderCommand as _, + }; + use crate::core::platform::values::IcbDesc; use metal2vulkan::metal::PixelFormat; use metal2vulkan::pipeline::{ ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource, }; - use reims_vgpu_core::platform::icb::{ - IcbRenderCmd, IndirectCommandBuffer as _, IndirectRenderCommand as _, - }; - use reims_vgpu_core::platform::values::IcbDesc; let function = |name: &str| { let path = crate::gpu::device::tests::fixture_shaders().join(format!("{name}.metallib")); @@ -6562,8 +6546,8 @@ fn an_execution_draws_its_strips_after_a_restart_set_as_metals_does() { format!("{index_type} direct"), format!("{index_type} restarted"), ]; - reims_vgpu_core::metal_check_raw!(keys[0], direct); - reims_vgpu_core::metal_check_raw!(keys[1], restarted); + crate::metal_check_raw!(keys[0], direct); + crate::metal_check_raw!(keys[1], restarted); } } @@ -6573,7 +6557,7 @@ fn an_execution_draws_its_strips_after_a_restart_set_as_metals_does() { /// (`render_draw_icb`) #[test] fn empty_executions_run_nothing_under_any_pipeline_state() { - use reims_vgpu_core::platform::values::IcbDesc; + use crate::core::platform::values::IcbDesc; fn pixels(p: &P, d: &P::Device, inherit: bool) -> Vec<[u8; 4]> { let state = fixture_state::

(d, FLAT.0, FLAT.1); @@ -6622,8 +6606,8 @@ fn empty_executions_run_nothing_under_any_pipeline_state() { /// core makes one, the buffer's bytes at `0x100`, slice 1's being at `0x80` #[test] fn a_pass_past_its_attachments_slices_dies_where_metal_writes_past_the_texture() { - use reims_vgpu_core::platform::values::PassSet; - use reims_vgpu_core::raise::death::DeathKind; + use crate::core::platform::values::PassSet; + use crate::core::raise::death::DeathKind; /// The pass on `d`, and the ranges of the 16 KiB buffer under the texture that its /// commit changed from `0x55`. @@ -6725,7 +6709,7 @@ fn unknown_stores_over_resolves(p: &P, d: &P::Device) -> Vec { }, ) .unwrap(); - pass.set_depth_attachment(&reims_vgpu_core::platform::values::DepthAttachmentSet { + pass.set_depth_attachment(&crate::core::platform::values::DepthAttachmentSet { texture: Some(Some(&depth)), resolve_texture: Some(Some(&depth_resolve)), load_action: Some(CLEAR), @@ -6782,7 +6766,7 @@ fn unused_resolve( store: u64, memoryless: bool, ) -> Vec { - use reims_vgpu_core::platform::values::{DepthAttachmentSet, StencilAttachmentSet}; + use crate::core::platform::values::{DepthAttachmentSet, StencilAttachmentSet}; let resolve = d .new_texture( OnFault::Die, @@ -6932,7 +6916,7 @@ fn render_pass_values_metal_refuses_die_at_the_encoder() { assert_eq!( (site.kind, site.file), ( - reims_vgpu_core::raise::death::DeathKind::Abort, + crate::core::raise::death::DeathKind::Abort, "renderCommandEncoderWithDescriptor:" ), "{line}" @@ -6956,7 +6940,7 @@ fn render_pass_values_metal_refuses_die_at_the_encoder() { // action of 9, a depth resolve filter of 9 and a stencil resolve filter of 2 or 9 // ("resolveFilter is not a valid MTLMultisampleDepthResolveFilter.", and // "MTLMultisampleStencilResolveFilter."). A depth resolve filter of 2 makes the encoder. - use reims_vgpu_core::platform::values::{DepthAttachmentSet, StencilAttachmentSet}; + use crate::core::platform::values::{DepthAttachmentSet, StencilAttachmentSet}; let q = d.new_command_queue().unwrap(); let encoder = |pass: &VulkanRenderPassDescriptor| { let cb = q.command_buffer(OnFault::Die).unwrap().unwrap(); @@ -6994,7 +6978,7 @@ fn render_pass_values_metal_refuses_die_at_the_encoder() { assert_eq!( (site.kind, site.file), ( - reims_vgpu_core::raise::death::DeathKind::Abort, + crate::core::raise::death::DeathKind::Abort, "renderCommandEncoderWithDescriptor:" ), "{line}" @@ -7023,7 +7007,7 @@ fn an_integer_target_has_no_display_pipeline() { #[test] fn a_display_pipeline_answers_metals_values() { fn values(d: &P::Device) -> (bool, u64, u64, bool, u64) { - use reims_vgpu_core::platform::resource::RenderPipeline as _; + use crate::core::platform::resource::RenderPipeline as _; let cache = DisplayPipelineCache::

::new(d.clone_ref()).unwrap(); let state = cache .pipeline_for(PipelineKey { @@ -7040,7 +7024,7 @@ fn a_display_pipeline_answers_metals_values() { ) } let vulkan = values::(&dev()); - reims_vgpu_core::metal_check!("values", vulkan); + crate::metal_check!("values", vulkan); } /// A pass over a rasterization rate map of no layers made from an immutable descriptor that @@ -7053,11 +7037,11 @@ fn a_display_pipeline_answers_metals_values() { /// dies at its selector, naming the map, and a tile dispatch there dies by its own line #[test] fn a_drawless_pass_over_a_map_of_no_layers_is_metals() { - use reims_vgpu_core::platform::rate_map::{ + use crate::core::platform::rate_map::{ RateMap as _, RateMapDescriptor as _, RateMapLayerDescriptor as _, }; - use reims_vgpu_core::platform::values::{PassSet, RateMapDesc}; - use reims_vgpu_core::raise::death::DeathKind; + use crate::core::platform::values::{PassSet, RateMapDesc}; + use crate::core::raise::death::DeathKind; /// `MTLLoadActionLoad`. const LOAD: u64 = 1; @@ -7107,7 +7091,7 @@ fn a_drawless_pass_over_a_map_of_no_layers_is_metals() { /// it once its command buffer completed: on Metal, a map of no layers made after it draws, /// which a pass that only loads or clears and stores must not change. fn draw_and_release(p: &P, d: &P::Device) { - let _pool = reims_vgpu_core::rt::Pool::here(); + let _pool = crate::core::rt::Pool::here(); let map = d.new_rate_map(&one_layer(p, None)).unwrap().unwrap(); let (_dst, pass) = pass(p, d, &map, false); let state = fixture_state::

(d, "vert:tri_vert", "frag:tri_frag"); @@ -7270,14 +7254,14 @@ fn a_drawless_pass_over_a_map_of_no_layers_is_metals() { } for (shape, o) in shapes.iter().zip(&ours) { let key = format!("reset, load {shape:?}"); - assert!(reims_vgpu_core::metal_matches_raw!(key, o), "{key}"); + assert!(crate::metal_matches_raw!(key, o), "{key}"); } // After a map of one layer was drawn with and released, each platform's own. draw_and_release(&p, &d); let ours = shapes.map(|(reset, load)| stored(&p, &d, reset, load)); for (shape, o) in shapes.iter().zip(&ours) { let key = format!("after a released map, reset, load {shape:?}"); - assert!(reims_vgpu_core::metal_matches_raw!(key, o), "{key}"); + assert!(crate::metal_matches_raw!(key, o), "{key}"); } } @@ -7291,10 +7275,10 @@ fn a_drawless_pass_over_a_map_of_no_layers_is_metals() { /// command buffer of its own queue, before any command buffer drew over a mutable map #[test] fn drawless_passes_over_mutable_maps_store_as_metals() { - use reims_vgpu_core::platform::rate_map::{ + use crate::core::platform::rate_map::{ RateMap as _, RateMapDescriptor as _, RateMapLayerDescriptor as _, }; - use reims_vgpu_core::platform::values::{PassSet, RateMapDesc}; + use crate::core::platform::values::{PassSet, RateMapDesc}; const SIDE: u64 = 64; /// `MTLMutabilityMutable`. @@ -7472,12 +7456,12 @@ fn drawless_passes_over_mutable_maps_store_as_metals() { /// reset to 48 #[test] fn a_pass_over_a_mutable_map_draws_by_the_map_as_reset_before_it_runs() { - use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; - use reims_vgpu_core::platform::rate_map::{ + use crate::core::platform::event::{EventRef, SharedEvent as _}; + use crate::core::platform::rate_map::{ RateMap as _, RateMapDescriptor as _, RateMapLayerDescriptor as _, }; - use reims_vgpu_core::platform::values::{PassSet, RateMapDesc}; - use reims_vgpu_core::raise::death::DeathSite; + use crate::core::platform::values::{PassSet, RateMapDesc}; + use crate::core::raise::death::DeathSite; const SIDE: u64 = 16; const HALF: u64 = SIDE / 2; @@ -7636,10 +7620,10 @@ fn a_pass_over_a_mutable_map_draws_by_the_map_as_reset_before_it_runs() { /// Metal's GPU draws then ([`crate::gpu::rate_map`]) #[test] fn a_reset_of_a_varying_map_to_another_screen_dies_while_its_pass_may_run() { - use reims_vgpu_core::platform::rate_map::{ + use crate::core::platform::rate_map::{ RateMap as _, RateMapDescriptor as _, RateMapLayerDescriptor as _, }; - use reims_vgpu_core::platform::values::{PassSet, RateMapDesc}; + use crate::core::platform::values::{PassSet, RateMapDesc}; /// An immutable descriptor of a `side` by `side` screen of one layer of one sample of 0.5 /// on each axis. @@ -7723,7 +7707,7 @@ fn the_tile_size_is_metals() { fn simd_state( d: &P::Device, vertex: &str, -) -> Result, reims_vgpu_core::platform::types::NsErrorText> { +) -> Result, crate::core::platform::types::NsErrorText> { let v = fixture::

(d, &format!("simd_stages:{vertex}")); let f = fixture::

(d, "simd_stages:value_fragment"); d.new_render_pipeline_state_full(&crate::gpu::device::tests::render_value::

( @@ -7784,7 +7768,7 @@ fn simd_operations_in_a_vertex_function_draw_as_metals() { /// The words `simd_kernel` of `simd_stages.metal` writes on `d`, two a thread, over 64 threads /// in one threadgroup: each thread's `simd_sum` and explicit-width fill. fn simd_kernel_words(d: &P::Device) -> Vec<[u32; 2]> { - use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; + use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; let f = fixture::

(d, "simd_stages:simd_kernel"); let state = d .new_compute_pipeline_state_for_function(Some(&f)) @@ -7862,9 +7846,9 @@ fn simd_operations_in_kernels_and_fragments_run_as_metals() { let pixels = ["sum_fragment", "fill_fragment"].map(|f| simd_fragment_pixels(&p, &d, f)); assert!(pixels[0].iter().all(|px| px[3] == 255), "{:?}", pixels[0]); let fragments = ["sum_fragment", "fill_fragment"]; - reims_vgpu_core::metal_check_raw!("the kernel's words", words); + crate::metal_check_raw!("the kernel's words", words); for (fragment, ours) in fragments.into_iter().zip(&pixels) { - reims_vgpu_core::metal_check_raw!(fragment, ours); + crate::metal_check_raw!(fragment, ours); } } @@ -7901,8 +7885,8 @@ pub(crate) fn memoryless_fetched( d: &P::Device, tiles_written: bool, ) -> Vec { - use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; - use reims_vgpu_core::platform::resource::Library as _; + use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; + use crate::core::platform::resource::Library as _; use crate::gpu::device::tests::render_value; @@ -8007,7 +7991,7 @@ pub(crate) fn memoryless_fetched( } /// What [`filling`]'s completed handlers saw: each one's fill value, status and error code. -type Seen = Arc)>>>; +type Seen = Arc)>>>; /// A command buffer of `q` that waits for `wait` where given, fills a new 16-byte buffer of `d`'s /// with `value` in a blit, then signals a new event of its own to 1, with a completed handler that @@ -8018,7 +8002,7 @@ fn filling( (value, wait): (u8, Option<&P::SharedEvent>), seen: &Seen, ) -> (P::CommandBuffer, P::Buffer, P::SharedEvent) { - use reims_vgpu_core::platform::event::EventRef; + use crate::core::platform::event::EventRef; let b = buffer::

(d, 16, 0, &[0; 16]); let event = d.new_shared_event().unwrap(); let cb = q.command_buffer(OnFault::Die).unwrap().unwrap(); @@ -8072,7 +8056,7 @@ fn type_9_pass(p: &P, d: &P::Device, draw: Nine) -> String { /// first byte of each buffer, whether the signal fired, and the target's first texel, black /// where the pass's clear ran, read through a new queue. fn type_9_pass_on(p: &P, d: &P::Device, q: &P::CommandQueue, draw: Nine) -> String { - use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; + use crate::core::platform::event::{EventRef, SharedEvent as _}; let (dst, pass) = pass_of(p, d, (4, 4)); let region = MtlRegion::new(MtlOrigin::new(0, 0, 0), MtlSize::new(4, 4, 1)); dst.replace_region(region, 0, 0, HostRange::of_slice(&[0x11; 64]), 16, 0) @@ -8270,7 +8254,7 @@ fn type_9_draws_fail_their_command_buffers_as_metals() { /// some runs (the runtime's measurement, `command_buffer/revocation.rs`), where /// [`type_9_draws_fail_as_metals`] compares it on a GPU that ran just before. fn after_type_9s(p: &P, d: &P::Device, draws: &[Nine]) -> Vec { - use reims_vgpu_core::platform::event::SharedEvent as _; + use crate::core::platform::event::SharedEvent as _; let q = d.new_command_queue().unwrap(); let mut lines: Vec = (draws.iter()) .map(|&draw| { @@ -8378,7 +8362,7 @@ fn visibility_results( init: &[u64], passes: &[VisPass<'_>], ) -> Vec { - use reims_vgpu_core::platform::values::{DepthStencilDesc, PassSet}; + use crate::core::platform::values::{DepthStencilDesc, PassSet}; let words: Vec = init.iter().flat_map(|w| w.to_ne_bytes()).collect(); let length = u64::try_from(words.len()).unwrap(); @@ -8430,7 +8414,7 @@ fn visibility_results( .unwrap(); let depth = pass.depth.then(|| attachment(252)); if let Some(depth) = &depth { - rp.set_depth_attachment(&reims_vgpu_core::platform::values::DepthAttachmentSet { + rp.set_depth_attachment(&crate::core::platform::values::DepthAttachmentSet { texture: Some(Some(depth)), load_action: Some(CLEAR), store_action: Some(0), diff --git a/crates/reims-vgpu-vulkan/src/gpu/event.rs b/crates/reims-vgpu-vulkan/src/gpu/event.rs index e60d268b9..cc15a63b1 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/event.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/event.rs @@ -3,10 +3,10 @@ use std::time::Duration; +use crate::core::platform::event::{Notification, SharedEvent}; +use crate::core::raise::RaiseResult; +use crate::core::rt::BlockEnv; use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::event::{Notification, SharedEvent}; -use reims_vgpu_core::raise::RaiseResult; -use reims_vgpu_core::rt::BlockEnv; use crate::answer::plain; use crate::platform::{Obj, VulkanPlatform}; @@ -24,7 +24,7 @@ impl SharedEvent for VulkanSharedEvent { /// The value becomes at least `signaled_value`; the runtime refuses no value. fn set_signaled_value(&self, signaled_value: u64) -> RaiseResult<()> { // evset: event, value: the guest's or the device's host set - reims_vgpu_core::trace::event( + crate::core::trace::event( "evset", &[crate::gpu::command::event_id(self), signaled_value], ); @@ -60,13 +60,13 @@ impl SharedEvent for VulkanSharedEvent { block: Notification, ) -> RaiseResult<()> { #[cfg(test)] - let slot = reims_vgpu_core::testkit::capture::current_slot(); + let slot = crate::core::testkit::capture::current_slot(); let notification: rt::SharedEventNotification = Box::new(move |_event: &rt::SharedEvent, _value: u64| { // A callout on the runtime's thread: marked ours, so a panic here aborts. let _env = BlockEnv::foreign(); #[cfg(test)] - reims_vgpu_core::testkit::capture::with_slot(slot, block); + crate::core::testkit::capture::with_slot(slot, block); #[cfg(not(test))] block(); }); @@ -77,7 +77,7 @@ impl SharedEvent for VulkanSharedEvent { #[cfg(test)] mod tests { - use reims_vgpu_core::platform::device::GpuDevice; + use crate::core::platform::device::GpuDevice; use super::*; use crate::gpu::device::tests::dev; @@ -98,7 +98,7 @@ mod tests { /// thread, and once only; at once for a value reached already #[test] fn notify_listener_runs_once_the_value_is_reached() { - use reims_vgpu_core::platform::Platform as _; + use crate::core::platform::Platform as _; let listener = crate::platform::tests::platform().new_shared_event_listener(); let e = dev().new_shared_event().unwrap(); let (ran, runs) = std::sync::mpsc::channel(); diff --git a/crates/reims-vgpu-vulkan/src/gpu/fill.rs b/crates/reims-vgpu-vulkan/src/gpu/fill.rs index 40900bfa8..dad300939 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/fill.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/fill.rs @@ -75,9 +75,9 @@ //! (`encode_blit`'s `multisample_fills_are_metals`). The runtime refuses one only //! where the device cannot run its sample copies, which dies naming the refusal. +use crate::core::platform::types::MtlRegion; use metal2vulkan::metal::{PixelFormat, TextureType}; use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::types::MtlRegion; use crate::answer::unrepresentable; @@ -266,7 +266,7 @@ pub fn texture_buffer_writes(sel: &'static str, region: MtlRegion) -> bool { /// (`LongTextureBufferFillPattern`), before the region is read: the runtime refuses it only for a /// region it is given, and this platform gives none of no texels across. pub fn streamed_pattern(sel: &'static str, length: u64) { - use reims_vgpu_core::num::ToU64 as _; + use crate::core::num::ToU64 as _; if length > MOST_STREAMED_PATTERN_BYTES.to_u64() { let problem = rt::Problem::LongTextureBufferFillPattern { length }; let e = rt::Error::Invalid(rt::Invalid::new("fill_texture", problem)); @@ -344,9 +344,9 @@ pub fn place( #[cfg(test)] mod tests { - use reims_vgpu_core::platform::types::{MtlOrigin, MtlSize}; - use reims_vgpu_core::raise::death::DeathKind; - use reims_vgpu_core::testkit::capture::catch_death; + use crate::core::platform::types::{MtlOrigin, MtlSize}; + use crate::core::raise::death::DeathKind; + use crate::core::testkit::capture::catch_death; use super::*; diff --git a/crates/reims-vgpu-vulkan/src/gpu/fill/tests/metal_tests.rs b/crates/reims-vgpu-vulkan/src/gpu/fill/tests/metal_tests.rs index a831c34b7..723786643 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/fill/tests/metal_tests.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/fill/tests/metal_tests.rs @@ -1,13 +1,13 @@ //! The tests of `fill` that compare with Metal on this host: macOS only. -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder}; -use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue}; -use reims_vgpu_core::platform::device::GpuDevice; -use reims_vgpu_core::platform::resource::Buffer; -use reims_vgpu_core::platform::types::ClearColor; -use reims_vgpu_core::platform::values::TextureDesc; -use reims_vgpu_core::raise::OnFault; +use crate::core::platform::Platform; +use crate::core::platform::blit::{BlitCmd, BlitEncoder}; +use crate::core::platform::command::{CommandBuffer, CommandQueue}; +use crate::core::platform::device::GpuDevice; +use crate::core::platform::resource::Buffer; +use crate::core::platform::types::ClearColor; +use crate::core::platform::values::TextureDesc; +use crate::core::raise::OnFault; use crate::platform::VulkanPlatform; @@ -393,7 +393,7 @@ fn assert_metals(formats: &[u64], colors: &[ClearColor]) { for &format in formats { let key = format!("call {call}: format {format}"); let ours = fills_of::(&d, &vulkan_desc, format, colors); - if !reims_vgpu_core::metal_matches_bytes!(key, &ours) { + if !crate::metal_matches_bytes!(key, &ours) { wrong.push(key); } } @@ -534,7 +534,7 @@ fn leftover_colours_fill_an_earlier_colours_bytes_as_metals() { ) }); match ours { - Ok(ours) if reims_vgpu_core::metal_matches!(key, ours) => {} + Ok(ours) if crate::metal_matches!(key, ours) => {} Ok(ours) => differ.push(format!("{what}: ours {ours:02x?}, not Metal's")), Err(site) => { let line = crate::answer::LAST_LINE.lock().take().unwrap_or_default(); diff --git a/crates/reims-vgpu-vulkan/src/gpu/format_info.rs b/crates/reims-vgpu-vulkan/src/gpu/format_info.rs index 17bc99cfe..733f915c4 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/format_info.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/format_info.rs @@ -38,8 +38,8 @@ //! The answers need a device, any of the process's, as every device answers alike //! ([`crate::platform::answering_device`]). +use crate::core::platform::types::{PixelFormatInfo, TextureLevelInfo, TextureLevelQuery}; use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::types::{PixelFormatInfo, TextureLevelInfo, TextureLevelQuery}; /// Metal's description of `raw`, asked by `sel` of the process's device /// ([`crate::platform::answering_device`]). diff --git a/crates/reims-vgpu-vulkan/src/gpu/format_info/tests/metal_tests.rs b/crates/reims-vgpu-vulkan/src/gpu/format_info/tests/metal_tests.rs index d03953d5a..b3df7b259 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/format_info/tests/metal_tests.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/format_info/tests/metal_tests.rs @@ -24,7 +24,7 @@ fn level(format: u64, width: u64, height: u64) -> TextureLevelQuery { /// rule where this module died before #[test] fn levels_are_metals() { - use reims_vgpu_core::platform::device::GpuDevice as _; + use crate::core::platform::device::GpuDevice as _; use crate::gpu::device::tests::dev; @@ -44,7 +44,7 @@ fn levels_are_metals() { // A format's levels, ours checked against Metal's, recorded a format at a time. let mut compare = |key: String, queries: Vec| { let ours: Vec<_> = queries.iter().map(|q| d.texture_level_info(q)).collect(); - if !reims_vgpu_core::metal_matches_raw!(key, ours) { + if !crate::metal_matches_raw!(key, ours) { differ.push(format!("{key}: ours differ from Metal's")); } }; @@ -94,7 +94,7 @@ fn levels_are_metals() { /// the device answers them; a format is named as the runtime names it #[test] fn descriptions_are_metals() { - use reims_vgpu_core::platform::device::GpuDevice as _; + use crate::core::platform::device::GpuDevice as _; use crate::gpu::device::tests::dev; @@ -121,6 +121,6 @@ fn descriptions_are_metals() { let values = (0..2048).chain([9999, u64::from(u32::MAX) + 70, (1 << 32) + 80]); for format in values { let key = format!("format {format}"); - reims_vgpu_core::metal_check!(key, d.pixel_format_info(format)); + crate::metal_check!(key, d.pixel_format_info(format)); } } diff --git a/crates/reims-vgpu-vulkan/src/gpu/frame_cost.rs b/crates/reims-vgpu-vulkan/src/gpu/frame_cost.rs index c3ab51e59..7f033fc8f 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/frame_cost.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/frame_cost.rs @@ -25,22 +25,22 @@ //! `FRAME_COST_RUNTIME_CHECK=1` a submission check on each of the runtime's command buffers //! ([`runtime_checks`]). -use metal2vulkan::metal::{PrimitiveType, ResourceUsage}; -use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _, ResourceRef}; -use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; -use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; -use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; -use reims_vgpu_core::platform::device::GpuDevice; -use reims_vgpu_core::platform::os::Clock as _; -use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; -use reims_vgpu_core::platform::resource::{Buffer as _, Library as _}; -use reims_vgpu_core::platform::types::{MtlSize, NsRange}; -use reims_vgpu_core::platform::values::{ +use crate::core::platform::Platform; +use crate::core::platform::blit::{BlitCmd, BlitEncoder as _, ResourceRef}; +use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; +use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; +use crate::core::platform::descriptor::RenderPassDescriptor as _; +use crate::core::platform::device::GpuDevice; +use crate::core::platform::os::Clock as _; +use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; +use crate::core::platform::resource::{Buffer as _, Library as _}; +use crate::core::platform::types::{MtlSize, NsRange}; +use crate::core::platform::values::{ ColorAttachmentSet, RenderPipelineDesc, SamplerDesc, TextureDesc, }; -use reims_vgpu_core::raise::OnFault; +use crate::core::raise::OnFault; +use metal2vulkan::metal::{PrimitiveType, ResourceUsage}; +use metal2vulkan_runtime as rt; use crate::gpu::device::VulkanDevice; use crate::platform::VulkanPlatform; diff --git a/crates/reims-vgpu-vulkan/src/gpu/icb.rs b/crates/reims-vgpu-vulkan/src/gpu/icb.rs index ab7d2a5c7..f64261d14 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/icb.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/icb.rs @@ -110,20 +110,20 @@ use std::ops::Range; use std::sync::Arc; use std::sync::atomic::AtomicUsize; -use metal2vulkan::metal::{IndexType, IndirectCommandType}; -use metal2vulkan_runtime as rt; -use reims_vgpu_core::num::Truncate; -use reims_vgpu_core::platform::Handle; -use reims_vgpu_core::platform::blit::ResourceRef; -use reims_vgpu_core::platform::icb::{ +use crate::core::num::Truncate; +use crate::core::platform::Handle; +use crate::core::platform::blit::ResourceRef; +use crate::core::platform::icb::{ DispatchThreadgroupsArgs, DispatchThreadsArgs, DrawArgs, DrawIndexedArgs, DrawIndexedPatchesArgs, DrawPatchesArgs, IcbComputeCmd, IcbRenderCmd, ImageBlockArgs, IndirectCommandBuffer, IndirectComputeCommand, IndirectRenderCommand, TessellationFactorArgs, }; -use reims_vgpu_core::platform::types::{MtlOrigin, MtlRegion, MtlSize}; -use reims_vgpu_core::platform::values::IcbDesc; -use reims_vgpu_core::raise::RaiseResult; -use reims_vgpu_core::sync::{Mutex, MutexGuard}; +use crate::core::platform::types::{MtlOrigin, MtlRegion, MtlSize}; +use crate::core::platform::values::IcbDesc; +use crate::core::raise::RaiseResult; +use crate::core::sync::{Mutex, MutexGuard}; +use metal2vulkan::metal::{IndexType, IndirectCommandType}; +use metal2vulkan_runtime as rt; use crate::answer::{ Inexact, Policy, created_or_decided, decide, get, hang, inexact, metal_aborts, plain, plain_at, @@ -1796,17 +1796,17 @@ impl IndirectComputeCommand for VulkanIndirectComputeCommand { /// the process, so under `cargo test`'s threads one test's states and releases reach another's. #[cfg(test)] mod tests { + use crate::core::platform::Platform; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _, ResourceRef}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; + use crate::core::platform::device::GpuDevice; + use crate::core::platform::resource::{Buffer as _, ComputePipeline as _}; + use crate::core::platform::types::NsRange; + use crate::core::raise::OnFault; + use crate::core::raise::death::DeathKind; + use crate::core::testkit::capture::catch_death; use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; - use reims_vgpu_core::platform::Platform; - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _, ResourceRef}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; - use reims_vgpu_core::platform::device::GpuDevice; - use reims_vgpu_core::platform::resource::{Buffer as _, ComputePipeline as _}; - use reims_vgpu_core::platform::types::NsRange; - use reims_vgpu_core::raise::OnFault; - use reims_vgpu_core::raise::death::DeathKind; - use reims_vgpu_core::testkit::capture::catch_death; use super::*; use crate::gpu::command::VulkanCommandBuffer; @@ -1856,7 +1856,7 @@ mod tests { /// (`metal_tests::identifiers_after_are_metals`) #[test] fn identifiers_after_a_scheduled_render_encoder_are_relayed() { - use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; + use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; let d = dev(); let before = make::(&d, &compute_desc(), 1); assert_eq!(before.unique_identifier(), 0x10_0001_8000); @@ -2265,8 +2265,8 @@ mod tests { d: &P::Device, library: &P::Library, ) -> (Vec, Vec) { - use reims_vgpu_core::platform::resource::Library as _; - use reims_vgpu_core::platform::values::{ + use crate::core::platform::resource::Library as _; + use crate::core::platform::values::{ ColorAttachmentDesc, FullComputePipelineDesc, FullRenderPipelineDesc, }; let function = |name: &str| { @@ -2319,7 +2319,7 @@ mod tests { icb: &P::Icb, state: u64, ) { - use reims_vgpu_core::platform::resource::Library as _; + use crate::core::platform::resource::Library as _; let f = library .new_function(OnFault::Return, name) .unwrap() @@ -2375,7 +2375,7 @@ mod tests { /// answer one identifier #[test] fn a_command_written_while_two_states_held_its_id_answers_their_identifier() { - use reims_vgpu_core::platform::resource::{ComputePipeline as _, Library as _}; + use crate::core::platform::resource::{ComputePipeline as _, Library as _}; let d = dev(); let library = d.new_library(ICB_ENCODE).unwrap().unwrap().unwrap(); let (mut computes, renders) = twin_states::(&d, &library); @@ -2441,8 +2441,8 @@ mod tests { /// A state of `mark` of `library`, made from a value that supports indirect command buffers. fn marking_state(d: &P::Device, library: &P::Library) -> P::ComputePipeline { - use reims_vgpu_core::platform::resource::Library as _; - use reims_vgpu_core::platform::values::FullComputePipelineDesc; + use crate::core::platform::resource::Library as _; + use crate::core::platform::values::FullComputePipelineDesc; let mark = library .new_function(OnFault::Return, "mark") .unwrap() @@ -2526,7 +2526,7 @@ mod tests { /// reaches the later state, as Metal's does #[test] fn a_state_a_command_names_goes_at_the_guests_release() { - use reims_vgpu_core::platform::resource::ComputePipeline as _; + use crate::core::platform::resource::ComputePipeline as _; let d = dev(); let library = d.new_library(ICB_ENCODE).unwrap().unwrap().unwrap(); let (mut computes, renders) = twin_states::(&d, &library); @@ -2860,7 +2860,7 @@ mod tests { /// intact is made resident #[test] fn a_buffer_a_copy_past_its_end_overwrote_dies_where_made_resident() { - use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; + use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; const USE: &str = "useResources:count:usage:"; let d = dev(); let p = crate::platform::tests::platform(); @@ -3086,8 +3086,8 @@ mod tests { use std::sync::mpsc; use std::time::Duration; - use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; - use reims_vgpu_core::platform::os::Clock as _; + use crate::core::platform::event::{EventRef, SharedEvent as _}; + use crate::core::platform::os::Clock as _; let d = dev(); let pipeline = icb_pipeline(&d); @@ -3177,7 +3177,7 @@ mod tests { fn blits_move_lengths_past_the_record_as_they_run() { use std::sync::mpsc; - use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; + use crate::core::platform::event::{EventRef, SharedEvent as _}; let d = dev(); let (a, b) = ( diff --git a/crates/reims-vgpu-vulkan/src/gpu/icb/tests/metal_tests.rs b/crates/reims-vgpu-vulkan/src/gpu/icb/tests/metal_tests.rs index 8dd956849..d5421d3cd 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/icb/tests/metal_tests.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/icb/tests/metal_tests.rs @@ -55,7 +55,7 @@ fn unique_identifiers_follow_metals_sizes() { live.iter().map(|b| b.unique_identifier() - first).collect() } let vulkan = offsets::(&dev()); - reims_vgpu_core::metal_check!("offsets", vulkan); + crate::metal_check!("offsets", vulkan); } /// An encoder [`identifiers_after_are_metals`] makes, of a command buffer never committed, on @@ -77,7 +77,7 @@ enum Made { impl Encoder for Made { fn encode(&self, p: &P, d: &P::Device, cb: &P::CommandBuffer) { - use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; + use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; match self { Made::Blit => { let e = cb.blit_encoder(OnFault::Return).unwrap().unwrap(); @@ -88,7 +88,7 @@ impl Encoder for Made { e.encode(OnFault::Return, ComputeCmd::EndEncoding).unwrap(); } Made::ComputePass => { - let desc = reims_vgpu_core::platform::values::ComputePassDesc::default(); + let desc = crate::core::platform::values::ComputePassDesc::default(); let e = cb.compute_encoder_for_pass(&desc).unwrap().unwrap(); e.encode(OnFault::Return, ComputeCmd::EndEncoding).unwrap(); } @@ -122,7 +122,7 @@ fn identifiers_after_are_metals(made: Made) { assert_eq!(vulkan[..2], [0x10_0001_8000; 2], "{made:?}"); assert_eq!(crate::answer::inexact_counts(), [], "{made:?}"); let from_first = |n: [u64; 3]| n.map(|x| x - n[0]); - reims_vgpu_core::metal_check!("from the first", from_first(vulkan)); + crate::metal_check!("from the first", from_first(vulkan)); } /// [`identifiers_after_are_metals`] an empty blit encoder @@ -195,7 +195,7 @@ fn icbs_take_metals_numbers() { let vulkan = numbers::(&dev()); assert_eq!(vulkan[0], (1, 1, 0x10_0001_8000, 1)); assert_eq!(vulkan[2].0, 5); - reims_vgpu_core::metal_check!("numbers", from_first(vulkan)); + crate::metal_check!("numbers", from_first(vulkan)); } /// An execution of a command a kernel encoded with a state the program released since, whose @@ -526,7 +526,7 @@ fn compute_commands_read_back_as_on_metal() { out } let vulkan = reads::(&dev()); - reims_vgpu_core::metal_check!("reads", vulkan); + crate::metal_check!("reads", vulkan); } /// What a render command's getters answer core, fresh, after each draw kind with its @@ -732,7 +732,7 @@ fn render_commands_read_back_as_on_metal() { out } let vulkan = reads::(&dev()); - reims_vgpu_core::metal_check!("reads", vulkan); + crate::metal_check!("reads", vulkan); } /// What the buffer getters answer of a slot through plain sets and stride forms of a buffer @@ -830,7 +830,7 @@ fn buffer_slots_read_back_as_on_metal() { out } let vulkan = [true, false].map(|dynamic| reads::(&dev(), dynamic)); - reims_vgpu_core::metal_check!("reads", vulkan); + crate::metal_check!("reads", vulkan); } /// What the buffer getters answer of slots past the 32 a record holds, of a descriptor of 64 @@ -904,7 +904,7 @@ fn slots_past_the_record_read_back_as_on_metal() { .collect() } let vulkan = [true, false].map(|dynamic| reads::(&dev(), dynamic)); - reims_vgpu_core::metal_check!("reads", vulkan); + crate::metal_check!("reads", vulkan); } /// What the threadgroup memory length getter answers past the 31 lengths a record holds, of @@ -1205,7 +1205,7 @@ fn offsets_keep_their_low_32_bits_as_on_metal() { /// of two states made from one descriptor: whether command 0 answers that state's identifier, /// whether it answers the first's, and what command 1, which nothing encoded, answers. fn encoded_by_a_kernel(d: &P::Device) -> [(bool, bool, u64); 2] { - use reims_vgpu_core::platform::resource::{ComputePipeline as _, RenderPipeline as _}; + use crate::core::platform::resource::{ComputePipeline as _, RenderPipeline as _}; let library = d.new_library(ICB_ENCODE).unwrap().unwrap().unwrap(); let (computes, renders) = twin_states::

(d, &library); let compute = make::

(d, &compute_desc(), 2); @@ -1266,7 +1266,7 @@ fn a_command_a_kernel_encoded_answers_its_states_identifier() { /// A compute buffer of 2 commands whose command 0 a kernel encoded with a state that, with /// every handle to it, was released since, and the identifier command 0 answered before. fn released_after_encoding(d: &P::Device) -> (P::Icb, u64) { - use reims_vgpu_core::platform::resource::ComputePipeline as _; + use crate::core::platform::resource::ComputePipeline as _; let library = d.new_library(ICB_ENCODE).unwrap().unwrap().unwrap(); let (computes, renders) = twin_states::

(d, &library); drop(renders); @@ -1314,7 +1314,7 @@ fn reached(made: &[u64], answer: u64) -> Option { fn made_by( (computes, renders): &(Vec, Vec), ) -> Vec { - use reims_vgpu_core::platform::resource::{ComputePipeline as _, RenderPipeline as _}; + use crate::core::platform::resource::{ComputePipeline as _, RenderPipeline as _}; let computes = computes.iter().map(|state| state.unique_identifier()); computes .chain(renders.iter().map(|state| state.unique_identifier())) @@ -1330,7 +1330,7 @@ fn a_command_naming_a_released_state_reaches_a_later_one_as_metals() { /// What the guest reaches by the command's answer, in making order, the index of the /// released state and whether a later state took its ID; `None` where the getter died fn reaches(d: &P::Device) -> (Option>, usize, bool) { - use reims_vgpu_core::platform::resource::ComputePipeline as _; + use crate::core::platform::resource::ComputePipeline as _; let library = d.new_library(ICB_ENCODE).unwrap().unwrap().unwrap(); let mut first = twin_states::

(d, &library); let mut made = made_by::

(&first); @@ -1403,7 +1403,7 @@ fn a_released_state_the_cpu_set_runs_as_metals() { /// state a kernel encodes on the command after is answered #[test] fn a_command_core_set_reaches_a_later_state_holding_its_identifier_as_metals() { - use reims_vgpu_core::platform::resource::ComputePipeline as _; + use crate::core::platform::resource::ComputePipeline as _; /// The command, what the guest reaches by its answer once the first was released and /// states were made after it (in making order; `None` where the getter died), and /// whether one of those took its ID @@ -1448,8 +1448,8 @@ fn a_command_core_set_reaches_a_later_state_holding_its_identifier_as_metals() { /// An ICB-capable state of `name` in `library`, made from a whole value, as `twin_states`' are fn icb_kernel(d: &P::Device, library: &P::Library, name: &str) -> P::ComputePipeline { - use reims_vgpu_core::platform::resource::Library as _; - use reims_vgpu_core::platform::values::FullComputePipelineDesc; + use crate::core::platform::resource::Library as _; + use crate::core::platform::values::FullComputePipelineDesc; let kernel = library .new_function(OnFault::Return, name) .unwrap() @@ -1468,7 +1468,7 @@ fn icb_kernel(d: &P::Device, library: &P::Library, name: &str) -> P /// execution opens a span on the buffer, which tells the two states of the ID apart #[test] fn a_command_an_executed_kernel_wrote_answers_the_state_holding_its_id_then() { - use reims_vgpu_core::platform::resource::ComputePipeline as _; + use crate::core::platform::resource::ComputePipeline as _; /// The index, in making order, of the state that took a released one's ID and that the /// kernel wrote, and of the state core's map reaches by the command's answer fn written_by_an_execution(d: &P::Device) -> (usize, Option) { @@ -1567,7 +1567,7 @@ fn a_command_an_executed_kernel_wrote_answers_the_state_holding_its_id_then() { /// released first, as Metal's does #[test] fn an_icb_capable_states_identifier_is_the_runtimes() { - use reims_vgpu_core::platform::resource::{ + use crate::core::platform::resource::{ ComputePipeline as _, Library as _, RenderPipeline as _, }; let d = dev(); @@ -1647,7 +1647,7 @@ fn a_copy_past_the_destinations_end_lands_what_fits_as_metal() { let neighbour = kind_and_width::(&c, render, i); assert_eq!(neighbour, (kind, 30 + i), "{shape}"); } - reims_vgpu_core::metal_check!(shape, landed); + crate::metal_check!(shape, landed); } } @@ -1715,7 +1715,7 @@ fn at(a: u64, base: u64) -> [u64; 2] { /// imageblock words, 20 a copy's, and the rest up to 24 none of them #[test] fn lengths_past_the_last_command_follow_metals_words() { - use reims_vgpu_core::platform::types::MtlSize; + use crate::core::platform::types::MtlSize; /// The places read, past the last command's lengths at 76. const PLACES: std::ops::Range = 76..101; /// What each place reads after `scenario` over buffers that inherit their pipeline state or @@ -1883,7 +1883,7 @@ fn lengths_past_the_last_command_follow_metals_words() { .map(|(place, _)| place - 76) .collect(); assert_eq!(none, relayed, "{what}"); - reims_vgpu_core::metal_check!(what, ours); + crate::metal_check!(what, ours); } } } diff --git a/crates/reims-vgpu-vulkan/src/gpu/identity.rs b/crates/reims-vgpu-vulkan/src/gpu/identity.rs index aa7e50297..47acd39d9 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/identity.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/identity.rs @@ -41,14 +41,14 @@ //! `supports32BitMSAA` and `supportsPullModelInterpolation` are the runtime's answers; a gap in the //! latter is `None`. -use ash::vk; -use metal2vulkan::metal::TextureType; -use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::caps::{ +use crate::core::platform::caps::{ DeviceCaps, FEATURE_SETS, FormatAnswers, IdentityCaps, IdentityFlags, IdentitySizes, LARGEST_COUNT_ASKED, SDK_FAMILIES, SDK_PIXEL_FORMATS, SPARSE_PAGE_SIZES, SPARSE_SAMPLE_COUNTS, TEXTURE_BUFFER_FORMATS, feature_set_family, }; +use ash::vk; +use metal2vulkan::metal::TextureType; +use metal2vulkan_runtime as rt; use crate::gpu::runtime_pixel_format; @@ -221,7 +221,7 @@ fn device_local_bytes(device: &rt::Device) -> u64 { /// physical device lists the extension, which a physical-device query may chain without the device /// enabling it, else the heaps' sizes ([`device_local_bytes`]). /// -/// [`GpuDevice::own_memory_budget`]: reims_vgpu_core::platform::device::GpuDevice::own_memory_budget +/// [`GpuDevice::own_memory_budget`]: crate::core::platform::device::GpuDevice::own_memory_budget pub(crate) fn device_local_budget(device: &rt::Device) -> u64 { // SAFETY: the instance and physical device are the runtime's, read only, while `device` // lives. @@ -384,7 +384,7 @@ pub fn read(device: &rt::Device, caps: &DeviceCaps) -> IdentityCaps { #[cfg(test)] mod tests { - use reims_vgpu_core::platform::device::GpuDevice; + use crate::core::platform::device::GpuDevice; use super::*; use crate::gpu::device::tests::dev; diff --git a/crates/reims-vgpu-vulkan/src/gpu/metal_space.rs b/crates/reims-vgpu-vulkan/src/gpu/metal_space.rs index c7e821f58..69f61fbab 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/metal_space.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/metal_space.rs @@ -76,9 +76,9 @@ use std::collections::{BTreeMap, BTreeSet}; use std::ops::Range; use std::sync::{Arc, OnceLock, Weak}; +use crate::core::platform::types::SizeAndAlign; +use crate::core::sync::{Mutex, MutexGuard}; use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::types::SizeAndAlign; -use reims_vgpu_core::sync::{Mutex, MutexGuard}; /// Metal's page on this host: a range holds whole pages. pub const PAGE: u64 = 0x4000; diff --git a/crates/reims-vgpu-vulkan/src/gpu/no_texture.rs b/crates/reims-vgpu-vulkan/src/gpu/no_texture.rs index 704ceaea1..578a512fb 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/no_texture.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/no_texture.rs @@ -172,9 +172,9 @@ fn runtime_passes(fields: &TextureFields) -> Option<&'static str> { #[cfg(test)] mod tests { - use reims_vgpu_core::platform::Platform; - use reims_vgpu_core::platform::descriptor::TextureDescriptor as _; - use reims_vgpu_core::platform::values::TextureDesc; + use crate::core::platform::Platform; + use crate::core::platform::descriptor::TextureDescriptor as _; + use crate::core::platform::values::TextureDesc; use crate::platform::tests::platform; diff --git a/crates/reims-vgpu-vulkan/src/gpu/no_texture/tests/metal_tests.rs b/crates/reims-vgpu-vulkan/src/gpu/no_texture/tests/metal_tests.rs index 0d9d203d3..f4324a459 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/no_texture/tests/metal_tests.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/no_texture/tests/metal_tests.rs @@ -1,12 +1,12 @@ //! The tests of `no_texture` that compare with Metal on this host: macOS only. -use reims_vgpu_core::platform::device::GpuDevice; -use reims_vgpu_core::platform::resource::{Buffer as _, Heap as _, Texture as _}; -use reims_vgpu_core::platform::types::{NsRange, SizeAndAlign, Swizzle}; -use reims_vgpu_core::platform::values::{BufferDesc, HeapDesc, OptionSet, TextureDesc}; -use reims_vgpu_core::raise::OnFault; -use reims_vgpu_core::raise::death::DeathKind; -use reims_vgpu_core::testkit::capture::catch_death; +use crate::core::platform::device::GpuDevice; +use crate::core::platform::resource::{Buffer as _, Heap as _, Texture as _}; +use crate::core::platform::types::{NsRange, SizeAndAlign, Swizzle}; +use crate::core::platform::values::{BufferDesc, HeapDesc, OptionSet, TextureDesc}; +use crate::core::raise::OnFault; +use crate::core::raise::death::DeathKind; +use crate::core::testkit::capture::catch_death; use super::super::NO_VIEW; use super::*; @@ -159,7 +159,7 @@ fn textures_of_formats_metal_makes_none_of_are_nil_as_metals_are() { assert_eq!(ours.0, format, "{format} {what}"); assert_eq!(ours.1, [false; 6], "{format} {what}"); assert_eq!(ours.2.size, 0, "{format} {what}"); - reims_vgpu_core::metal_check!(format!("{format} {what}"), ours); + crate::metal_check!(format!("{format} {what}"), ours); } } } diff --git a/crates/reims-vgpu-vulkan/src/gpu/pages_in_place.rs b/crates/reims-vgpu-vulkan/src/gpu/pages_in_place.rs index 20f3e9dd2..e7deb3e62 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/pages_in_place.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/pages_in_place.rs @@ -22,9 +22,9 @@ //! The verdicts are read from the runtime's report (`rt::Device::in_place_check_report`), in one //! place ([`verdict`]), until the runtime answers a texture's placement itself. +use crate::core::num::ToU64 as _; +use crate::core::platform::values::{PagesInPlace, PagesPlane}; use metal2vulkan_runtime as rt; -use reims_vgpu_core::num::ToU64 as _; -use reims_vgpu_core::platform::values::{PagesInPlace, PagesPlane}; use crate::answer::plain; diff --git a/crates/reims-vgpu-vulkan/src/gpu/predication.rs b/crates/reims-vgpu-vulkan/src/gpu/predication.rs index e33b18cd4..955590ebf 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/predication.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/predication.rs @@ -120,17 +120,17 @@ use std::collections::{BTreeMap, BTreeSet}; use std::ops::{Deref, Range}; use std::sync::{Arc, Weak}; +use crate::core::num::Truncate; +use crate::core::platform::Handle; +use crate::core::platform::blit::ResourceRef; +use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; +use crate::core::platform::types::{MtlRegion, MtlSize, NsRange}; +use crate::core::raise::death::{DeathId, DeathKind, fatal_with_detail}; +use crate::core::raise::{OnFault, RaiseResult}; +use crate::core::rt::BlockEnv; +use crate::core::sync::Mutex; use metal2vulkan::metal::{BarrierScope, DispatchType, ResourceUsage}; use metal2vulkan_runtime as rt; -use reims_vgpu_core::num::Truncate; -use reims_vgpu_core::platform::Handle; -use reims_vgpu_core::platform::blit::ResourceRef; -use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; -use reims_vgpu_core::platform::types::{MtlRegion, MtlSize, NsRange}; -use reims_vgpu_core::raise::death::{DeathId, DeathKind, fatal_with_detail}; -use reims_vgpu_core::raise::{OnFault, RaiseResult}; -use reims_vgpu_core::rt::BlockEnv; -use reims_vgpu_core::sync::Mutex; use crate::answer::{Policy, metal_aborts, plain, refused, send}; use crate::gpu::command::{CommandBufferObject, VulkanCommandBuffer}; @@ -2454,17 +2454,17 @@ pub fn end_do_while( #[cfg(test)] mod tests { - use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::device::GpuDevice as _; - use reims_vgpu_core::platform::event::EventRef; - use reims_vgpu_core::platform::icb::{ + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::device::GpuDevice as _; + use crate::core::platform::event::EventRef; + use crate::core::platform::icb::{ IcbComputeCmd, IndirectCommandBuffer as _, IndirectComputeCommand as _, }; - use reims_vgpu_core::platform::resource::{Buffer as _, Library as _}; - use reims_vgpu_core::platform::values::{ComputePassDesc, IcbDesc}; - use reims_vgpu_core::raise::death::DeathKind; - use reims_vgpu_core::testkit::capture::catch_death; + use crate::core::platform::resource::{Buffer as _, Library as _}; + use crate::core::platform::values::{ComputePassDesc, IcbDesc}; + use crate::core::raise::death::DeathKind; + use crate::core::testkit::capture::catch_death; + use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; use super::*; use crate::gpu::command::{QueueObject, VulkanCommandBuffer}; @@ -3305,7 +3305,7 @@ mod tests { }); } - reims_vgpu_core::death_test!( + crate::death_test!( /// A loop still running after its iterations laid down ends the process at the command /// buffer's completion, at its End's selector: Metal would run it on a_loop_past_its_copies_dies_at_completion, diff --git a/crates/reims-vgpu-vulkan/src/gpu/rate_map.rs b/crates/reims-vgpu-vulkan/src/gpu/rate_map.rs index c2a8c8dfb..8af990c83 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/rate_map.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/rate_map.rs @@ -105,16 +105,16 @@ use std::sync::Arc; use std::sync::atomic::{AtomicU32, Ordering}; +use crate::core::host::HostPtr; +use crate::core::platform::Handle; +use crate::core::platform::rate_map::{RateMap, RateMapDescriptor, RateMapLayerDescriptor}; +use crate::core::platform::types::{MtlCoordinate2D, MtlSize, SizeAndAlign}; +use crate::core::platform::values::RateMapDesc; +use crate::core::raise::{OnFault, RaiseResult}; +use crate::core::sync::Mutex; use metal2vulkan::bind; use metal2vulkan::metal::Mutability; use metal2vulkan_runtime as rt; -use reims_vgpu_core::host::HostPtr; -use reims_vgpu_core::platform::Handle; -use reims_vgpu_core::platform::rate_map::{RateMap, RateMapDescriptor, RateMapLayerDescriptor}; -use reims_vgpu_core::platform::types::{MtlCoordinate2D, MtlSize, SizeAndAlign}; -use reims_vgpu_core::platform::values::RateMapDesc; -use reims_vgpu_core::raise::{OnFault, RaiseResult}; -use reims_vgpu_core::sync::Mutex; use crate::answer::{ Policy, created_or_decided, get, hearing, plain, plain_at, refused, send, unrepresentable, @@ -495,8 +495,8 @@ static NO_DRAW: Mutex> = Mutex::new(Vec::new /// 1 on a device without multiview. A refusal of the library, the function or the pipeline dies /// at `sel`. pub(crate) fn no_draw(sel: &'static str, device: &VulkanDevice) -> rt::RenderPipelineState { + use crate::core::platform::device::GpuDevice as _; use metal2vulkan::pipeline::{RenderPipelineDescriptor, StageSource}; - use reims_vgpu_core::platform::device::GpuDevice as _; let id = device.registry_id; // Held through the make, so two first asks make one. @@ -688,10 +688,10 @@ impl RateMap for VulkanRateMap { #[cfg(test)] mod tests { - use reims_vgpu_core::platform::Platform; - use reims_vgpu_core::platform::device::GpuDevice; - use reims_vgpu_core::raise::death::DeathKind; - use reims_vgpu_core::testkit::capture::catch_death; + use crate::core::platform::Platform; + use crate::core::platform::device::GpuDevice; + use crate::core::raise::death::DeathKind; + use crate::core::testkit::capture::catch_death; use super::*; use crate::gpu::device::tests::dev; diff --git a/crates/reims-vgpu-vulkan/src/gpu/rate_map/tests/metal_tests.rs b/crates/reims-vgpu-vulkan/src/gpu/rate_map/tests/metal_tests.rs index 20ebf3082..d29d54ce8 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/rate_map/tests/metal_tests.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/rate_map/tests/metal_tests.rs @@ -1,6 +1,6 @@ //! The tests of `rate_map` that compare with Metal on this host: macOS only. -use reims_vgpu_core::platform::resource::Buffer as _; +use crate::core::platform::resource::Buffer as _; use super::*; @@ -45,7 +45,7 @@ fn layers_and_descriptors_answer_as_on_metal() { } let vulkan = answers(&platform()); assert_eq!(vulkan[..3], [u64::MAX; 3]); - reims_vgpu_core::metal_check!("answers", vulkan); + crate::metal_check!("answers", vulkan); } /// A map's answers: an immutable one's compiled at creation, a mutable one's of no @@ -111,7 +111,7 @@ fn maps_answer_as_on_metal() { .map(|a| a.iter().map(|x| x.to_bits()).collect()) .collect() }; - reims_vgpu_core::metal_check!("bits", bits(&vulkan)); + crate::metal_check!("bits", bits(&vulkan)); } /// The parameter copy writes Metal's 24,624 bytes at its offset, byte for byte as Metal's: @@ -150,9 +150,9 @@ fn the_parameter_copy_is_metals() { for bytes in &compiled { assert!(around(bytes)); } - reims_vgpu_core::metal_check_bytes!("unset", &unset); + crate::metal_check_bytes!("unset", &unset); for (quality, ours) in [1.0, 0.1].into_iter().zip(&compiled) { - reims_vgpu_core::metal_check_bytes!(format!("quality {quality}"), ours); + crate::metal_check_bytes!(format!("quality {quality}"), ours); } } @@ -218,7 +218,7 @@ fn maps_of_no_layers_are_made_as_metals() { } let which = ["immutable", "reset", "compiled and reset"]; for (which, o) in which.iter().zip(&ours) { - reims_vgpu_core::metal_check!(format!("{which}: sizes"), &o[..7]); - reims_vgpu_core::metal_check_raw!(format!("{which}: copy"), o[7..]); + crate::metal_check!(format!("{which}: sizes"), &o[..7]); + crate::metal_check_raw!(format!("{which}: copy"), o[7..]); } } diff --git a/crates/reims-vgpu-vulkan/src/gpu/resource.rs b/crates/reims-vgpu-vulkan/src/gpu/resource.rs index f9335163f..7e5ec78e4 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/resource.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/resource.rs @@ -14,22 +14,22 @@ use std::collections::BTreeMap; use std::ptr::NonNull; use std::sync::{Arc, Weak}; +use crate::core::host::HostPtr; +use crate::core::num::ToUsize; +use crate::core::platform::resource::{ + Buffer, ComputePipeline, DepthStencilState, ExportedMemory, GpuResource, Heap, Library, + RenderPipeline, SamplerState, Texture, +}; +use crate::core::platform::types::{MtlRegion, MtlSize, NsRange, Swizzle}; +use crate::core::platform::values::{SurfaceMatrix, SurfacePlane}; +use crate::core::platform::{Handle, HostRange}; +use crate::core::raise::{OnFault, Raise, RaiseResult}; +use crate::core::sync::Mutex; use metal2vulkan::metal::{PixelFormat, PrimitiveTopologyClass, TextureType, TextureUsage}; use metal2vulkan::pipeline::{ ComputePipelineDescriptor, MeshPipelineDescriptor, RenderPipelineDescriptor, }; use metal2vulkan_runtime as rt; -use reims_vgpu_core::host::HostPtr; -use reims_vgpu_core::num::ToUsize; -use reims_vgpu_core::platform::resource::{ - Buffer, ComputePipeline, DepthStencilState, ExportedMemory, GpuResource, Heap, Library, - RenderPipeline, SamplerState, Texture, -}; -use reims_vgpu_core::platform::types::{MtlRegion, MtlSize, NsRange, Swizzle}; -use reims_vgpu_core::platform::values::{SurfaceMatrix, SurfacePlane}; -use reims_vgpu_core::platform::{Handle, HostRange}; -use reims_vgpu_core::raise::{OnFault, Raise, RaiseResult}; -use reims_vgpu_core::sync::Mutex; use crate::answer::{ Nil, Policy, create, get, hearing, metal_aborts, plain, plain_at, refused, relay_gap, send, @@ -1747,7 +1747,7 @@ pub(crate) fn guest_bytes<'a>(sel: &'static str, range: HostRange<'a>) -> rt::Ho } let first = range.ptr().addr(); let start = NonNull::new(range.ptr().as_ptr::()) - .filter(|_| first >= reims_vgpu_core::host::ZERO_REGION_END) + .filter(|_| first >= crate::core::host::ZERO_REGION_END) .filter(|_| first.checked_add(length).is_some()); let Some(start) = start else { crate::answer::metal_reads_near_null(sel, &format!("{length} bytes at {first:#x}")); @@ -1770,7 +1770,7 @@ fn first_bytes(sel: &'static str, range: HostRange<'_>, most: usize) -> Vec } let start = range.ptr().as_ptr::(); let first = range.ptr().addr(); - if first < reims_vgpu_core::host::ZERO_REGION_END || first.checked_add(length).is_none() { + if first < crate::core::host::ZERO_REGION_END || first.checked_add(length).is_none() { crate::answer::metal_reads_near_null(sel, &format!("{length} bytes at {first:#x}")); } let read = length.min(most); @@ -1810,7 +1810,7 @@ pub(crate) fn fill_bytes( return Vec::new(); } let first = range.ptr().addr(); - if range.is_empty() && first < reims_vgpu_core::host::ZERO_REGION_END { + if range.is_empty() && first < crate::core::host::ZERO_REGION_END { crate::answer::metal_reads_near_null(sel, &format!("0 bytes at {first:#x}")); } first_bytes(sel, range, most) @@ -2283,7 +2283,7 @@ impl Library for VulkanLibrary { &self, _on: OnFault, function_name: &str, - constants: &[reims_vgpu_core::platform::resource::FunctionConstant], + constants: &[crate::core::platform::resource::FunctionConstant], ) -> RaiseResult> { let sel = "newFunctionWithName:constantValues:error:"; let Some(values) = constant_values(function_name, constants) else { @@ -2318,7 +2318,7 @@ impl Library for VulkanLibrary { &self, _on: OnFault, function_name: &str, - constants: &[reims_vgpu_core::platform::resource::FunctionConstant], + constants: &[crate::core::platform::resource::FunctionConstant], options: u64, specialized_name: Option<&str>, ) -> RaiseResult> { @@ -2363,7 +2363,7 @@ impl Library for VulkanLibrary { /// of a type the runtime does not know or no function constant takes. fn constant_values( function_name: &str, - constants: &[reims_vgpu_core::platform::resource::FunctionConstant], + constants: &[crate::core::platform::resource::FunctionConstant], ) -> Option { let mut values = metal2vulkan::library::FunctionConstantValues::defaults(); for c in constants { @@ -2391,17 +2391,15 @@ pub(crate) mod tests { use std::alloc::{Layout, alloc_zeroed, dealloc}; use std::sync::atomic::{AtomicU32, Ordering}; - use reims_vgpu_core::platform::Platform; - use reims_vgpu_core::platform::descriptor::TextureDescriptor as _; - use reims_vgpu_core::platform::device::{GpuDevice, NoCopyDeallocator}; - use reims_vgpu_core::platform::os::surface::{Surface, SurfacePlaneSpec, SurfaceSpec}; - use reims_vgpu_core::platform::types::MtlOrigin; - use reims_vgpu_core::platform::values::{ - BufferDesc, HeapDesc, HeapMade, OptionSet, TextureDesc, - }; - use reims_vgpu_core::raise::death::DeathKind; - use reims_vgpu_core::sync::Mutex; - use reims_vgpu_core::testkit::capture::catch_death; + use crate::core::platform::Platform; + use crate::core::platform::descriptor::TextureDescriptor as _; + use crate::core::platform::device::{GpuDevice, NoCopyDeallocator}; + use crate::core::platform::os::surface::{Surface, SurfacePlaneSpec, SurfaceSpec}; + use crate::core::platform::types::MtlOrigin; + use crate::core::platform::values::{BufferDesc, HeapDesc, HeapMade, OptionSet, TextureDesc}; + use crate::core::raise::death::DeathKind; + use crate::core::sync::Mutex; + use crate::core::testkit::capture::catch_death; use super::*; use crate::gpu::device::tests::dev; @@ -2415,7 +2413,7 @@ pub(crate) mod tests { /// gone. #[cfg(target_os = "linux")] fn over_read_only_pages(pages: u64) -> (VulkanBuffer, HostPtr) { - use reims_vgpu_core::platform::os::vm::{HostVm as _, VmProt}; + use crate::core::platform::os::vm::{HostVm as _, VmProt}; use crate::os::{OsVm, PAGE}; @@ -2442,9 +2440,9 @@ pub(crate) mod tests { /// frees once the buffer is gone. #[cfg(target_os = "linux")] pub(crate) fn on_read_only_surface() -> (VulkanBuffer, HostPtr) { - use reims_vgpu_core::host::PhysicalMemoryRange; - use reims_vgpu_core::num::ToU64 as _; - use reims_vgpu_core::platform::os::surface::{IoSurfaces as _, SurfaceSpec}; + use crate::core::host::PhysicalMemoryRange; + use crate::core::num::ToU64 as _; + use crate::core::platform::os::surface::{IoSurfaces as _, SurfaceSpec}; use crate::os::{OsSurfaces, PAGE, READ_ONLY_DIRECTION}; @@ -2537,11 +2535,11 @@ pub(crate) mod tests { #[cfg(target_os = "linux")] #[test] fn a_fill_into_read_only_pages_is_dropped_on_linux() { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::os::vm::HostVm as _; - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::platform::types::NsRange; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::os::vm::HostVm as _; + use crate::core::platform::resource::Buffer as _; + use crate::core::platform::types::NsRange; use crate::os::{OsVm, PAGE}; @@ -2578,11 +2576,11 @@ pub(crate) mod tests { /// there is unmeasured. Its contents answer the pages' address on both #[test] fn a_blit_into_a_read_only_buffer_is_dropped() { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::os::vm::HostVm as _; - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::platform::types::{MtlSize, NsRange}; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::os::vm::HostVm as _; + use crate::core::platform::resource::Buffer as _; + use crate::core::platform::types::{MtlSize, NsRange}; use crate::os::{OsVm, PAGE}; @@ -2649,9 +2647,9 @@ pub(crate) mod tests { #[cfg(target_os = "linux")] #[test] fn a_cpu_write_of_a_texture_over_a_read_only_buffer_dies_on_linux() { - use reims_vgpu_core::platform::os::vm::HostVm as _; - use reims_vgpu_core::platform::resource::Texture as _; - use reims_vgpu_core::platform::types::{MtlRegion, MtlSize}; + use crate::core::platform::os::vm::HostVm as _; + use crate::core::platform::resource::Texture as _; + use crate::core::platform::types::{MtlRegion, MtlSize}; use crate::os::{OsVm, PAGE}; @@ -2686,7 +2684,7 @@ pub(crate) mod tests { // SAFETY: an empty range is never read. let empty = unsafe { HostRange::new(HostPtr::NULL, 0) }; assert!(host_bytes("s", empty).is_empty()); - let last = u64::try_from(reims_vgpu_core::host::ZERO_REGION_END - 1).unwrap(); + let last = u64::try_from(crate::core::host::ZERO_REGION_END - 1).unwrap(); for at in [0, 0x10, 0x4000, last] { // SAFETY: a range of 4 bytes in the zero region, which the copy dies before reading. let near_null = unsafe { HostRange::new(HostPtr::NULL.wrapping_add(at), 4) }; @@ -2717,7 +2715,7 @@ pub(crate) mod tests { // SAFETY: an empty range is never read. let empty = unsafe { HostRange::new(HostPtr::NULL, 0) }; assert!(guest_bytes("s", empty).is_empty()); - let last = u64::try_from(reims_vgpu_core::host::ZERO_REGION_END - 1).unwrap(); + let last = u64::try_from(crate::core::host::ZERO_REGION_END - 1).unwrap(); for at in [0, 0x10, last] { // SAFETY: a range of 4 bytes in the zero region, which dies before any read. let near_null = unsafe { HostRange::new(HostPtr::NULL.wrapping_add(at), 4) }; @@ -2941,9 +2939,9 @@ pub(crate) mod tests { /// Metal), as the runtime frees the range then ([`crate::gpu::metal_space::Hold`]) #[test] fn a_released_buffers_range_comes_back_once_its_command_buffer_completes() { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::event::{EventRef, SharedEvent as _}; let d = dev(); let q = d.new_command_queue().unwrap(); let gate = d.new_shared_event().unwrap(); @@ -2996,9 +2994,9 @@ pub(crate) mod tests { /// width and no height, whose bytes Metal never reads, fills nothing and goes on #[test] fn a_fill_with_a_surface_buffers_bytes_dies() { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::types::{MtlOrigin, MtlRegion, MtlSize}; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::types::{MtlOrigin, MtlRegion, MtlSize}; let d = dev(); let s = bgra_surface(64, 32); let b = d.new_buffer_on_surface(Some(&s)).unwrap().unwrap(); @@ -3105,11 +3103,11 @@ pub(crate) mod tests { where P::Device: GpuDevice

, { - use reims_vgpu_core::host::HostPtr; - use reims_vgpu_core::platform::HostRange; - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::resource::Buffer as _; + use crate::core::host::HostPtr; + use crate::core::platform::HostRange; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::resource::Buffer as _; const LENGTH: usize = 0x10000; const SLICE: u64 = 60 * 3 * 4; @@ -3806,7 +3804,7 @@ pub(crate) mod tests { /// sends them #[test] fn bc_textures_over_a_surface_s_rows_are_made() { - use reims_vgpu_core::platform::values::SurfaceFacts; + use crate::core::platform::values::SurfaceFacts; let p = platform(); let (rows, pitch) = (64u64, 256u64); let b = shared(2 * rows * pitch); @@ -3901,12 +3899,12 @@ pub(crate) mod tests { /// meanwhile lies elsewhere, and one made after the completion at the range #[test] fn a_surface_texture_keeps_its_range_until_its_command_buffer_completed() { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::platform::types::MtlSize; - use reims_vgpu_core::rt::Pool; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::event::{EventRef, SharedEvent as _}; + use crate::core::platform::resource::Buffer as _; + use crate::core::platform::types::MtlSize; + use crate::core::rt::Pool; let (p, d) = (platform(), dev()); // 64 by 64, 4 bytes a texel: a page, whose range is the space's 0x8000. let side = 64; @@ -3977,12 +3975,12 @@ pub(crate) mod tests { /// and one made after the completion at the range #[test] fn a_texture_keeps_its_range_until_its_command_buffer_completed() { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::platform::types::MtlSize; - use reims_vgpu_core::rt::Pool; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::event::{EventRef, SharedEvent as _}; + use crate::core::platform::resource::Buffer as _; + use crate::core::platform::types::MtlSize; + use crate::core::rt::Pool; let (p, d) = (platform(), dev()); // BGRA8 at Private storage: 64 by 64 of its own memory, a heap size of a page, and a // shareable 8 by 8 of a page with its extra bytes; each a range of the space's 0x8000. @@ -4096,7 +4094,7 @@ pub(crate) mod tests { /// goes with it #[test] fn every_texture_takes_a_descriptor_while_it_lives() { - use reims_vgpu_core::platform::resource::{Heap as _, Texture as _}; + use crate::core::platform::resource::{Heap as _, Texture as _}; let (p, d) = (platform(), dev()); let live = || crate::gpu::metal_space::process().textures_live(); let of = |format, options| { @@ -4215,7 +4213,7 @@ pub(crate) mod tests { /// `metal_space::Hold`) #[test] fn an_opened_shared_texture_keeps_its_source_range() { - use reims_vgpu_core::platform::resource::Buffer as _; + use crate::core::platform::resource::Buffer as _; let d = dev(); let page = || { d.new_buffer_of_length(OnFault::Die, 0x4000, 0) @@ -4521,7 +4519,7 @@ pub(crate) mod tests { /// `ShaderRead` usage, whose blocks lie in Metal's tiles at every level #[test] fn heap_textures_over_guest_pages_in_metals_block_layout_are_made() { - use reims_vgpu_core::platform::types::ResourceAddressRange; + use crate::core::platform::types::ResourceAddressRange; const SIZE: u64 = 0x10000; let (p, d) = (platform(), dev()); @@ -4567,7 +4565,7 @@ pub(crate) mod tests { /// neither as host memory nor as a dma-buf #[test] fn a_heap_over_less_than_its_granule_is_made() { - use reims_vgpu_core::platform::types::ResourceAddressRange; + use crate::core::platform::types::ResourceAddressRange; const SIZE: u64 = 0x1000; let (p, d) = (platform(), dev()); @@ -4620,7 +4618,7 @@ pub(crate) mod tests { /// The address range array of the [`over_pages`] bytes at `address`. fn ranges_at(p: &P, address: u64) -> P::AddressRangeArray { - use reims_vgpu_core::platform::types::ResourceAddressRange; + use crate::core::platform::types::ResourceAddressRange; p.new_address_range_array(&[ResourceAddressRange { address, length: over_pages(), diff --git a/crates/reims-vgpu-vulkan/src/gpu/resource/tests/metal_tests.rs b/crates/reims-vgpu-vulkan/src/gpu/resource/tests/metal_tests.rs index b28dbd406..ce95b1fb7 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/resource/tests/metal_tests.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/resource/tests/metal_tests.rs @@ -1,7 +1,7 @@ //! The tests of `resource` that compare with Metal on this host: macOS only. -use reims_vgpu_core::platform::types::{MtlOrigin, SizeAndAlign}; -use reims_vgpu_core::platform::values::{ +use crate::core::platform::types::{MtlOrigin, SizeAndAlign}; +use crate::core::platform::values::{ BufferDesc, HeapDesc, HeapMade, OptionSet, SamplerDesc, TextureDesc, }; @@ -12,8 +12,8 @@ use crate::os::OsSurface; /// support and one with it (`supportIndirectCommandBuffers` set): whether /// each supports them, its `resourceIndex` and its `gpuResourceID`. fn kernel_states(d: &P::Device) -> [(bool, u64, u64); 2] { - use reims_vgpu_core::platform::resource::{ComputePipeline as _, Library as _}; - use reims_vgpu_core::platform::values::FullComputePipelineDesc; + use crate::core::platform::resource::{ComputePipeline as _, Library as _}; + use crate::core::platform::values::FullComputePipelineDesc; let kernel = include_bytes!("../../../../../../tests/shaders/kernel.metallib"); let library = d.new_library(kernel).unwrap().unwrap().unwrap(); let name = library.function_names()[0].clone(); @@ -105,7 +105,7 @@ type ComputeAnswer = Result<(u64, u64, u64, bool), String>; /// [`ComputeAnswer`]s of every function of `data` on `d`, sorted by name; one `Err` where it /// makes no library of `data` (a truncated metallib). fn compute_answers(d: &P::Device, data: &[u8]) -> Vec<(String, ComputeAnswer)> { - use reims_vgpu_core::platform::resource::{ComputePipeline as _, Library as _}; + use crate::core::platform::resource::{ComputePipeline as _, Library as _}; let Ok(Ok(Some(library))) = d.new_library(data) else { return vec![("the library".to_owned(), Err("no library".to_owned()))]; }; @@ -154,7 +154,7 @@ fn compute_state_answers_are_metals_for_every_kernel_here() { for (lib, data) in every_metallib() { let ours = compute_answers::(&d, &data); for (name, o) in &ours { - let m = reims_vgpu_core::metal_value!(format!("{lib} {name}")); + let m = crate::metal_value!(format!("{lib} {name}")); let made = m != "None"; match o { Ok(o) if made && format!("{:?}", Some(o)) == m => compared += 1, @@ -342,12 +342,12 @@ fn textures_and_buffers_answer_as_metals_across_descriptors() { let known = |o: &Option<[u64; 13]>| match *o { Some(mut o) if t.resource_options.is_none() && (o[9], o[10]) == (0, 0x200) => { (o[9], o[10]) = (1, 0x210); - reims_vgpu_core::metal_matches!(key, Some(o)) + crate::metal_matches!(key, Some(o)) } _ => false, }; match ours { - Ok(ours) if reims_vgpu_core::metal_matches!(key, ours) || known(&ours) => {} + Ok(ours) if crate::metal_matches!(key, ours) || known(&ours) => {} ours => differ.push(format!("{key}: ours {ours:?}, not Metal's")), } } @@ -373,12 +373,12 @@ fn textures_and_buffers_answer_as_metals_across_descriptors() { let pooled = length <= 4096 && options & 0xf0 == 0x20; let known = |o: &Option<(u64, u64, u64, bool)>| match *o { Some((l, o, 2, true)) if pooled => { - reims_vgpu_core::metal_matches!(key, Some((l, o, 2_u64, false))) + crate::metal_matches!(key, Some((l, o, 2_u64, false))) } _ => false, }; match ours { - Ok(ours) if reims_vgpu_core::metal_matches!(key, ours) || known(&ours) => {} + Ok(ours) if crate::metal_matches!(key, ours) || known(&ours) => {} ours => differ.push(format!("{key}: ours {ours:?}, not Metal's")), } } @@ -422,9 +422,9 @@ fn buffers_on_surfaces() { /// buffer over the surface lies at the address again #[test] fn buffers_over_a_surface_share_its_address() { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::event::{EventRef, SharedEvent as _}; fn waiting_fill( d: &P::Device, buffer: &P::Buffer, @@ -496,7 +496,7 @@ fn array_over_host_memory_is_metals() { true, ); for (step, ours) in steps.iter().zip(&ours) { - assert!(reims_vgpu_core::metal_matches_bytes!(step, ours), "{step}"); + assert!(crate::metal_matches_bytes!(step, ours), "{step}"); } } @@ -505,10 +505,10 @@ fn array_over_host_memory_is_metals() { /// surface's base address, its last bytes, past the allocation's end, 0 #[test] fn buffers_on_offset_surfaces_read_as_metals() { - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; - use reims_vgpu_core::platform::os::vm::HostVm as _; - use reims_vgpu_core::platform::resource::Library as _; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; + use crate::core::platform::os::vm::HostVm as _; + use crate::core::platform::resource::Library as _; // `copy_words` of the surface's buffer, on `d`: its length, and each 32-bit word of it. fn copied>(d: &P::Device, s: &OsSurface) -> (u64, Vec) { let b = d.new_buffer_on_surface(Some(s)).unwrap().unwrap(); @@ -585,7 +585,7 @@ fn buffers_on_offset_surfaces_read_as_metals() { "{offset:#x}: 0 past the allocation" ); let key = format!("{offset:#x}"); - let metals = reims_vgpu_core::metal_matches_raw!(key, (ours, words)); + let metals = crate::metal_matches_raw!(key, (ours, words)); assert!(metals, "{offset:#x}: Metal's"); drop(s); crate::os::OsVm::new().deallocate(pages, length); @@ -603,7 +603,7 @@ fn purgeable_answers_on( where P::Device: GpuDevice

, { - use reims_vgpu_core::platform::resource::{Buffer as _, GpuResource, Texture as _}; + use crate::core::platform::resource::{Buffer as _, GpuResource, Texture as _}; let states = [1, 3, 2, 4, 1, 2]; let answers = |r: &dyn GpuResource

| { states @@ -699,7 +699,7 @@ fn heap_texture_sizes_are_metals() { let ours = dev() .heap_texture_size_and_align(&platform().texture_descriptor(&t)) .unwrap(); - reims_vgpu_core::metal_check!(format!("{t:?}"), ours); + crate::metal_check!(format!("{t:?}"), ours); } } for (pixel_format, width, height, mipmap_level_count, usage, storage) in [ @@ -722,7 +722,7 @@ fn heap_texture_sizes_are_metals() { let ours = dev() .heap_texture_size_and_align(&platform().texture_descriptor(&t)) .unwrap(); - reims_vgpu_core::metal_check!(format!("{t:?}"), ours); + crate::metal_check!(format!("{t:?}"), ours); } } } @@ -775,7 +775,7 @@ fn multisample_heap_texture_sizes_are_metals() { .unwrap() }); match ours { - Ok(ours) if reims_vgpu_core::metal_matches!(key, ours) => {} + Ok(ours) if crate::metal_matches!(key, ours) => {} Ok(ours) => differ.push(format!("{t:?}: ours {ours:?}, not Metal's")), Err(site) => { let line = crate::answer::LAST_LINE.lock().take().unwrap_or_default(); @@ -801,8 +801,8 @@ fn multisample_heap_texture_sizes_are_metals() { /// Metal space, where they would move Metal's next range #[test] fn depth_stencil_textures_without_optimized_contents_take_metals_space() { - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::rt::Pool; + use crate::core::platform::resource::Buffer as _; + use crate::core::rt::Pool; fn taken(d: &P::Device, desc: &P::TextureDescriptor) -> (u64, u64) { let _pool = Pool::here(); let before = next_range::

(d); @@ -847,7 +847,7 @@ fn depth_stencil_textures_without_optimized_contents_take_metals_space() { let differ: Vec = (shapes.iter()) .filter_map(|t| { let ours = taken::(&d, &p.texture_descriptor(t)); - let metals = reims_vgpu_core::metal_matches!(key(t), ours); + let metals = crate::metal_matches!(key(t), ours); (!metals).then(|| format!("{}: ours {ours:x?}, not Metal's", key(t))) }) .collect(); @@ -903,7 +903,7 @@ fn heap_depth_stencil_sizes_with_optimized_contents_off() { assert_eq!((ours.size, ours.align), (answer.size, answer.align)); } let key = format!("{pixel_format} {allow:?}: the size"); - reims_vgpu_core::metal_check!(key, ours.unwrap().size); + crate::metal_check!(key, ours.unwrap().size); } } let mut differ = Vec::new(); @@ -920,7 +920,7 @@ fn heap_depth_stencil_sizes_with_optimized_contents_off() { if runtimes.size < ours.size || !runtimes.align.is_multiple_of(ours.align) { differ.push(format!("{case}: the runtime's {runtimes:x?} under")); } - if !reims_vgpu_core::metal_matches!(case, ours) { + if !crate::metal_matches!(case, ours) { differ.push(format!("{case}: {ours:x?}, not Metal's")); } } @@ -937,7 +937,7 @@ fn heap_depth_stencil_sizes_with_optimized_contents_off() { d.metal_answer_at(sel, &raw), "X32_Stencil8: the model's" ); - reims_vgpu_core::metal_check!("X32_Stencil8", ours); + crate::metal_check!("X32_Stencil8", ours); } /// The size query of each of [`LOSSLESS_MIPMAPPED_SHAPES`], which answers the runtime's model of @@ -951,7 +951,7 @@ fn lossless_mipmapped_heap_texture_sizes_are_metals() { let ours = d .heap_texture_size_and_align(&p.texture_descriptor(&t)) .unwrap(); - reims_vgpu_core::metal_check!(name, ours); + crate::metal_check!(name, ours); } } @@ -1155,7 +1155,7 @@ fn heap_depth_stencil_shapes_with_optimized_contents_off_are_metals() { match answered { Ok(ours) => { let ours = ours.unwrap(); - if !reims_vgpu_core::metal_matches!(case, ours) { + if !crate::metal_matches!(case, ours) { differ.push(format!("{case}: ours {ours:x?}, not Metal's")); } } @@ -1224,7 +1224,7 @@ fn optimized_depth_textures_take_metals_modelled_size() { assert!(made.unwrap().is_some(), "{name}"); let raw = desc.fields().descriptor(sel, Maker::Other); let modelled = d.metal_answer_at(sel, &raw); - reims_vgpu_core::metal_check!(name, modelled); + crate::metal_check!(name, modelled); } } @@ -1276,7 +1276,7 @@ fn x32_stencil8_size_queries_are_metals() { d.metal_answer_at(sel, &raw), "the model's: {name}" ); - reims_vgpu_core::metal_check!(name, ours); + crate::metal_check!(name, ours); let made = d.new_texture(OnFault::Return, &desc); assert!(made.unwrap().is_some(), "made: {name}"); } @@ -1345,10 +1345,10 @@ fn swizzled_extended_range_textures_are_made() { /// A `BGRA` surface of 64 by 16, rows 256 bytes apart, of `kIOSurfaceClientDirection` 2 over the /// guest's page `guest` of `page` bytes, whose GPU writes never reach its memory. -fn read_only_surface(guest: reims_vgpu_core::host::HostPtr, page: u64) -> OsSurface { - use reims_vgpu_core::host::PhysicalMemoryRange; - use reims_vgpu_core::num::ToU64 as _; - use reims_vgpu_core::platform::os::surface::IoSurfaces as _; +fn read_only_surface(guest: crate::core::host::HostPtr, page: u64) -> OsSurface { + use crate::core::host::PhysicalMemoryRange; + use crate::core::num::ToU64 as _; + use crate::core::platform::os::surface::IoSurfaces as _; let spec = SurfaceSpec { pixel_format: u32::from_be_bytes(*b"BGRA"), alloc_size: page, @@ -1381,9 +1381,9 @@ fn read_only_surface(guest: reims_vgpu_core::host::HostPtr, page: u64) -> OsSurf /// both make it, answering the usage asked. #[test] fn written_swizzles_over_read_only_memory_are_refused() { + use crate::core::platform::os::vm::HostVm as _; + use crate::core::platform::types::Swizzle; use crate::os::OsSurface; - use reims_vgpu_core::platform::os::vm::HostVm as _; - use reims_vgpu_core::platform::types::Swizzle; let vm = crate::os::OsVm::new(); let page = vm.page_size(); let guest = vm.allocate_anywhere(page).unwrap(); @@ -1458,7 +1458,7 @@ fn written_swizzles_over_read_only_memory_are_refused() { /// texture of `RenderTarget | 0x8` has too, Metal's answers on the M3 Max #[test] fn usage_bits_over_read_only_surfaces_are_answered_as_metals() { - use reims_vgpu_core::platform::os::vm::HostVm as _; + use crate::core::platform::os::vm::HostVm as _; let vm = crate::os::OsVm::new(); let page = vm.page_size(); let guest = vm.allocate_anywhere(page).unwrap(); @@ -1630,7 +1630,7 @@ fn surface_counts(s: &OsSurface) -> (i64, i32) { /// This platform lets go before the wait returns, as the runtime opens its waiters' gate only /// then. fn let_go(q: &P::CommandQueue) { - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; let cb = q.command_buffer(OnFault::Die).unwrap().unwrap(); cb.commit(OnFault::Die).unwrap(); cb.wait_until_completed(OnFault::Die).unwrap(); @@ -1650,15 +1650,15 @@ fn surface_references>( reach: Reach, made: &dyn Fn(&P::Device) -> u64, ) -> ([(i64, i32); 4], u64) { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _, ResourceRef}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; - use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; - use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; - use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; - use reims_vgpu_core::platform::resource::{Buffer as _, Library as _, Texture as _}; - use reims_vgpu_core::platform::values::{ColorAttachmentSet, RenderPipelineDesc}; - use reims_vgpu_core::rt::Pool; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _, ResourceRef}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; + use crate::core::platform::descriptor::RenderPassDescriptor as _; + use crate::core::platform::event::{EventRef, SharedEvent as _}; + use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; + use crate::core::platform::resource::{Buffer as _, Library as _, Texture as _}; + use crate::core::platform::values::{ColorAttachmentSet, RenderPipelineDesc}; + use crate::core::rt::Pool; use crate::gpu::ycbcr::measure::{PROBE, sampler}; use crate::gpu::ycbcr::measure::{Shape, desc as ycbcr_desc}; @@ -2058,12 +2058,12 @@ fn surface_holds>( d: &P::Device, beside: Beside, ) -> Vec<(i64, i32)> { - use reims_vgpu_core::platform::blit::ResourceRef; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; - use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; - use reims_vgpu_core::platform::resource::{Buffer as _, Library as _, Texture as _}; - use reims_vgpu_core::rt::Pool; + use crate::core::platform::blit::ResourceRef; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; + use crate::core::platform::event::{EventRef, SharedEvent as _}; + use crate::core::platform::resource::{Buffer as _, Library as _, Texture as _}; + use crate::core::rt::Pool; use crate::gpu::ycbcr::measure::PROBE; let side = 16; @@ -2371,7 +2371,7 @@ fn a_command_buffer_reaching_an_address_holds_no_surface_it_never_names() { /// The address of a one-page buffer made and released on `d`: where the next range lies. pub(crate) fn next_range(d: &P::Device) -> u64 { - use reims_vgpu_core::platform::resource::Buffer as _; + use crate::core::platform::resource::Buffer as _; let buffer = d.new_buffer_of_length(OnFault::Die, 0x4000, 0); buffer.unwrap().unwrap().gpu_address() } @@ -2428,7 +2428,7 @@ fn small_private_textures_and_buffers_fill_metals_private_pool() { .collect(); assert_eq!(pools(), before + 1, "16 textures"); let heap = d.heap_texture_size_and_align(&desc).unwrap().size; - reims_vgpu_core::metal_check!("the heap size", heap); + crate::metal_check!("the heap size", heap); let step = heap.next_multiple_of(0x100); let slots: Vec = textures .iter() @@ -2467,7 +2467,7 @@ fn small_private_textures_and_buffers_fill_metals_private_pool() { /// of its own. The managed pool goes with its last buffer, and comes back at the next #[test] fn small_buffers_lie_at_their_slots_in_metals_pools() { - use reims_vgpu_core::platform::resource::Buffer as _; + use crate::core::platform::resource::Buffer as _; use crate::gpu::metal_space::{PoolClass, process}; const LENGTHS: [u64; 5] = [1, 0x100, 0x101, 0x1001, 0x3fff]; @@ -2557,7 +2557,7 @@ fn sampler_states_grow_metals_sampler_mempool() { /// asserts first) #[test] fn views_metal_answers_nil_are_nil() { - use reims_vgpu_core::platform::resource::Texture as _; + use crate::core::platform::resource::Texture as _; let t = dev() .new_texture(OnFault::Return, &bgra(8, 8, 0)) .unwrap() @@ -2682,12 +2682,12 @@ fn rotated_uses>( rotation: u64, (load, drawn): (u64, Drawn), ) -> Vec<(&'static str, Vec)> { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; - use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; - use reims_vgpu_core::platform::resource::{Buffer as _, Library as _, Texture as _}; - use reims_vgpu_core::platform::values::{ColorAttachmentSet, RenderPipelineDesc}; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::descriptor::RenderPassDescriptor as _; + use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; + use crate::core::platform::resource::{Buffer as _, Library as _, Texture as _}; + use crate::core::platform::values::{ColorAttachmentSet, RenderPipelineDesc}; use crate::gpu::ycbcr::measure::{PROBE, probed}; let side = drawn.side(); @@ -2777,7 +2777,7 @@ fn rotated_uses>( pipeline_state: Some(&state), }; let scissor = RenderCmd::SetScissorRect { - rect: reims_vgpu_core::platform::types::MtlScissorRect { + rect: crate::core::platform::types::MtlScissorRect { x: 0, y: 0, width: 32, @@ -2842,7 +2842,7 @@ fn rotated_textures_read_copy_and_store_as_metals() { assert_ne!(ours[3], unturned[3], "{case}: the pass turns nothing"); } for (what, o) in &ours { - reims_vgpu_core::metal_check_bytes!(format!("{case}: {what}"), o); + crate::metal_check_bytes!(format!("{case}: {what}"), o); } } } @@ -2892,11 +2892,11 @@ fn rotated_view_pass>( view: u64, (load, drawn): (u64, Drawn), ) -> Vec { - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; - use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; - use reims_vgpu_core::platform::resource::{Library as _, Texture as _}; - use reims_vgpu_core::platform::values::{ColorAttachmentSet, RenderPipelineDesc}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::descriptor::RenderPassDescriptor as _; + use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; + use crate::core::platform::resource::{Library as _, Texture as _}; + use crate::core::platform::values::{ColorAttachmentSet, RenderPipelineDesc}; use crate::gpu::ycbcr::measure::PROBE; let (s, t) = rotated_named(p, d, drawn.side(), rotation); @@ -2956,12 +2956,12 @@ fn rotated_resolve>( rotation: u64, format: u64, ) -> Vec { - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; - use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; - use reims_vgpu_core::platform::resource::Texture as _; - use reims_vgpu_core::platform::types::ClearColor; - use reims_vgpu_core::platform::values::ColorAttachmentSet; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::descriptor::RenderPassDescriptor as _; + use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; + use crate::core::platform::resource::Texture as _; + use crate::core::platform::types::ClearColor; + use crate::core::platform::values::ColorAttachmentSet; let (s, t) = rotated_named(p, d, 32, rotation); let v = (format != 80).then(|| t.new_texture_view(format).unwrap().unwrap()); let msaa = d @@ -3031,7 +3031,7 @@ fn views_of_rotated_textures_store_and_load_as_metals() { continue; } let ours = rotated_view_pass::(&p, &d, rotation, view, pass); - reims_vgpu_core::metal_check_bytes!(case, &ours); + crate::metal_check_bytes!(case, &ours); } } } @@ -3048,7 +3048,7 @@ fn rotated_textures_and_their_views_resolve_as_metals() { type V = crate::platform::VulkanPlatform; let key = format!("format {format}, rotation {rotation}"); let ours = rotated_resolve::(&p, &d, rotation, format); - reims_vgpu_core::metal_check_bytes!(key, &ours); + crate::metal_check_bytes!(key, &ours); } } } @@ -3058,7 +3058,7 @@ fn rotated_textures_and_their_views_resolve_as_metals() { /// No view of another range can be asked: the texture has one level and one slice #[test] fn views_of_rotated_textures_the_runtime_refuses_die() { - use reims_vgpu_core::platform::resource::Texture as _; + use crate::core::platform::resource::Texture as _; let (p, d) = (platform(), dev()); let one = NsRange::new(0, 1); for rotation in 1..=4 { @@ -3131,9 +3131,9 @@ fn two_plane_samples_on( format: u64, seed: u32, ) -> Vec> { - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; - use reims_vgpu_core::platform::resource::{Library as _, Texture as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; + use crate::core::platform::resource::{Library as _, Texture as _}; use crate::gpu::ycbcr::measure::{PROBE, probed}; use crate::gpu::ycbcr::measure::{probe, sampler}; @@ -3237,7 +3237,7 @@ fn two_plane_xr10_samples_are_metals() { } for (i, o) in ours.iter().enumerate() { let key = format!("{format} seed {seed} case {i}"); - reims_vgpu_core::metal_check_bytes!(key, o); + crate::metal_check_bytes!(key, o); } } } @@ -3341,10 +3341,10 @@ fn two_plane_heap_bytes_on( where P::Device: GpuDevice

, { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; - use reims_vgpu_core::platform::resource::{Buffer as _, Heap as _, Library as _}; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; + use crate::core::platform::resource::{Buffer as _, Heap as _, Library as _}; use crate::gpu::ycbcr::measure::{PROBE, probed_texels}; let (w, h) = (16, 12); @@ -3491,8 +3491,8 @@ fn a_buffer_over_a_one_level_two_plane_heap_texture_sees_its_texels_as_metals() .enumerate() .filter(|&(i, &b)| b == (i & 0xff) as u8); assert!(offsets.count() < seen.len(), "the texels land: {case}"); - reims_vgpu_core::metal_check_bytes!(format!("seen: {case}"), &seen); - reims_vgpu_core::metal_check_bytes!(format!("read: {case}"), &texels); + crate::metal_check_bytes!(format!("seen: {case}"), &seen); + crate::metal_check_bytes!(format!("read: {case}"), &texels); } } }); @@ -3507,9 +3507,9 @@ fn a_buffer_over_a_one_level_two_plane_heap_texture_sees_its_texels_as_metals() /// options, as core sets them whatever the guest's descriptor names) #[test] fn heap_textures_over_guest_pages_metal_may_compress_are_made() { + use crate::core::platform::os::vm::HostVm as _; + use crate::core::platform::types::ResourceAddressRange; use crate::os::OsVm; - use reims_vgpu_core::platform::os::vm::HostVm as _; - use reims_vgpu_core::platform::types::ResourceAddressRange; const SIZE: u64 = 0x10000; @@ -3556,8 +3556,8 @@ fn heap_textures_over_guest_pages_metal_may_compress_are_made() { /// A fill of the bytes `range` of `buffer`, committed and waited for. fn fill_range(d: &P::Device, buffer: &P::Buffer, range: NsRange) { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; let q = d.new_command_queue().unwrap(); let cb = q.command_buffer(OnFault::Return).unwrap().unwrap(); let e = cb.blit_encoder(OnFault::Return).unwrap().unwrap(); @@ -3574,8 +3574,8 @@ fn fill_range(d: &P::Device, buffer: &P::Buffer, range: NsRange) { /// A compute pass that makes `heap` resident (`useHeaps:count:`), committed and waited for. fn use_heap(d: &P::Device, heap: &P::Heap) { - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; let q = d.new_command_queue().unwrap(); let cb = q.command_buffer(OnFault::Return).unwrap().unwrap(); let e = cb.compute_encoder(OnFault::Return).unwrap().unwrap(); @@ -3700,9 +3700,9 @@ fn a_view_keeps_its_released_textures_bytes() { /// to place one #[test] fn multisampled_textures_in_a_heap_over_guest_pages_die_where_metal_compresses_them() { + use crate::core::platform::os::vm::HostVm as _; + use crate::core::platform::types::ResourceAddressRange; use crate::os::OsVm; - use reims_vgpu_core::platform::os::vm::HostVm as _; - use reims_vgpu_core::platform::types::ResourceAddressRange; const SIZE: u64 = 0x10000; @@ -4086,7 +4086,7 @@ fn usage_bits_metal_takes_are_answered_as_metals() { .heap_texture_size_and_align(&p.texture_descriptor(&of_usage(usage & 0x37))) .unwrap(); assert_eq!(ours.2, without, "{usage:#x}"); - reims_vgpu_core::metal_check!(format!("{usage:#x}"), ours); + crate::metal_check!(format!("{usage:#x}"), ours); } } @@ -4138,8 +4138,8 @@ fn block_writes_only_sizes_are_metals_and_fit() { .unwrap(); let made = heap.new_texture(&p.texture_descriptor(&desc), 0).unwrap(); assert!(made.is_some(), "{case}"); - reims_vgpu_core::metal_check!(case, ours); - reims_vgpu_core::metal_check!(format!("{case} without the bit"), ours); + crate::metal_check!(case, ours); + crate::metal_check!(format!("{case} without the bit"), ours); } } let unmeasured = rt::Degradation::UnmeasuredHeapTextureSize; @@ -4194,7 +4194,7 @@ fn pvrtc_heap_sizes_are_metals() { assert!(made.is_some(), "{name}"); let ours = d.heap_texture_size_and_align(&desc).unwrap(); let key = format!("{name} {}x{}", t.width, t.height); - reims_vgpu_core::metal_check!(key, (ours.size, ours.align)); + crate::metal_check!(key, (ours.size, ours.align)); } } let t = suites(166); @@ -4340,7 +4340,7 @@ where P::Texture: Send, P::Device: Sync, { - use reims_vgpu_core::platform::resource::{Buffer as _, Heap as _, Texture as _}; + use crate::core::platform::resource::{Buffer as _, Heap as _, Texture as _}; let of = |format, options| TextureDesc { pixel_format: format, width: 4, @@ -4489,11 +4489,11 @@ fn texture_reuse_on( d: &P::Device, desc: &dyn Fn(&TextureDesc) -> P::TextureDescriptor, ) -> Vec<(String, u64, u64)> { - use reims_vgpu_core::platform::blit::BlitCmd; - use reims_vgpu_core::platform::blit::BlitEncoder as _; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::resource::Texture as _; - use reims_vgpu_core::platform::types::{ClearColor, MtlRegion}; + use crate::core::platform::blit::BlitCmd; + use crate::core::platform::blit::BlitEncoder as _; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::resource::Texture as _; + use crate::core::platform::types::{ClearColor, MtlRegion}; let private = desc(&TextureDesc { pixel_format: 80, width: 4, @@ -4541,8 +4541,8 @@ fn texture_reuse_on( level: 0, slice: 0, region: MtlRegion { - origin: reims_vgpu_core::platform::types::MtlOrigin { x: 0, y: 0, z: 0 }, - size: reims_vgpu_core::platform::types::MtlSize { + origin: crate::core::platform::types::MtlOrigin { x: 0, y: 0, z: 0 }, + size: crate::core::platform::types::MtlSize { width: 4, height: 4, depth: 1, @@ -4609,7 +4609,7 @@ fn texture_identifiers_are_metals() { for (what, unique, id) in &ours { assert_eq!(unique, id, "{what}"); } - reims_vgpu_core::metal_check!("identifiers", ours); + crate::metal_check!("identifiers", ours); } /// Texture identifiers are reused as Metal reuses them, from a process's start: the lowest @@ -4632,7 +4632,7 @@ fn texture_identifiers_are_reused_as_metals() { for (what, unique, id) in &ours { assert_eq!(unique, id, "{what}"); } - reims_vgpu_core::metal_check!("identifiers", ours); + crate::metal_check!("identifiers", ours); } /// Each texture's `uniqueIdentifier` and `gpuResourceID` on `d` where Metal hands out an ID a @@ -4645,7 +4645,7 @@ fn texture_reissue_on( d: &P::Device, desc: &dyn Fn(&TextureDesc) -> P::TextureDescriptor, ) -> Vec<(String, u64, u64)> { - use reims_vgpu_core::platform::resource::Texture as _; + use crate::core::platform::resource::Texture as _; let private = desc(&TextureDesc { pixel_format: 80, width: 4, @@ -4706,7 +4706,7 @@ fn texture_identifiers_are_reissued_as_metals() { for (what, unique, id) in &ours { assert_eq!(unique, id, "{what}"); } - reims_vgpu_core::metal_check!("identifiers", ours); + crate::metal_check!("identifiers", ours); } /// A format's block: its bytes, and its width and height in texels. @@ -4773,9 +4773,9 @@ fn legacy_heap_bytes_on( where P::Device: GpuDevice

, { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::resource::{Buffer as _, Heap as _}; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::resource::{Buffer as _, Heap as _}; const HEAP: u64 = 0x40_0000; let options = [OptionSet::StorageMode(2), OptionSet::HazardTrackingMode(0)]; @@ -5049,7 +5049,7 @@ fn legacy_heap_textures_are_metals_where_metal_keeps_them_plain() { let Ok((ours, _)) = legacy_heap_on_vulkan(&d, shape) else { continue; }; - assert!(reims_vgpu_core::metal_matches_raw!(case, ours), "{case}"); + assert!(crate::metal_matches_raw!(case, ours), "{case}"); if ours.is_some() { compared += 1; } @@ -5076,7 +5076,7 @@ fn legacy_heap_one_plane_textures_are_metals() { ] { let case = format!("{shape:?}"); let ours = legacy_heap_on_vulkan(&d, shape).unwrap().0; - assert!(reims_vgpu_core::metal_matches_raw!(case, ours), "{case}"); + assert!(crate::metal_matches_raw!(case, ours), "{case}"); } } } @@ -5122,7 +5122,7 @@ fn legacy_heap_depth_textures_are_metals_where_metal_keeps_them_plain() { !layouts.iter().any(|kind| relayed.contains(kind)), "{case}: {relayed:?}" ); - assert!(reims_vgpu_core::metal_matches_raw!(case, ours), "{case}"); + assert!(crate::metal_matches_raw!(case, ours), "{case}"); } } @@ -5214,12 +5214,12 @@ fn legacy_heap_textures_announce_the_runtimes_layouts() { assert_eq!(heard, kind == announced, "{case}: {kind:?} in {relayed:?}"); } if moltenvk && differs { - let out = reims_vgpu_core::metal_matches_bytes!(format!("{case}: copied out"), &ours.1); - let into = reims_vgpu_core::metal_matches_bytes!(format!("{case}: copied in"), &ours.2); + let out = crate::metal_matches_bytes!(format!("{case}: copied out"), &ours.1); + let into = crate::metal_matches_bytes!(format!("{case}: copied in"), &ours.2); assert!(!out || !into, "differs: {case}"); } if announced.is_none() { - let metals = reims_vgpu_core::metal_matches_raw!(case, ours); + let metals = crate::metal_matches_raw!(case, ours); assert!(metals, "Metal's bytes: {case}"); } } diff --git a/crates/reims-vgpu-vulkan/src/gpu/rgbx.rs b/crates/reims-vgpu-vulkan/src/gpu/rgbx.rs index a2d98f55f..85b32b371 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/rgbx.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/rgbx.rs @@ -27,22 +27,20 @@ //! single-plane extended-range formats, swizzled and not //! ([`extended_range_textures_read_as_metals`]). +use crate::core::platform::blit::{BlitCmd, BlitEncoder as _, ResourceRef}; +use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; +use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; +use crate::core::platform::descriptor::RenderPassDescriptor as _; +use crate::core::platform::device::GpuDevice as _; +use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; +use crate::core::platform::resource::{Buffer as _, Library as _, Texture as _}; +use crate::core::platform::types::{ClearColor, MtlOrigin, MtlRegion, MtlSize, NsRange, Swizzle}; +use crate::core::platform::values::{ColorAttachmentSet, SamplerDesc, TextureDesc}; +use crate::core::platform::{HostRange, Platform}; +use crate::core::raise::OnFault; +use crate::core::raise::death::{DeathKind, DeathSite}; +use crate::core::testkit::capture::catch_death; use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _, ResourceRef}; -use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; -use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; -use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; -use reims_vgpu_core::platform::resource::{Buffer as _, Library as _, Texture as _}; -use reims_vgpu_core::platform::types::{ - ClearColor, MtlOrigin, MtlRegion, MtlSize, NsRange, Swizzle, -}; -use reims_vgpu_core::platform::values::{ColorAttachmentSet, SamplerDesc, TextureDesc}; -use reims_vgpu_core::platform::{HostRange, Platform}; -use reims_vgpu_core::raise::OnFault; -use reims_vgpu_core::raise::death::{DeathKind, DeathSite}; -use reims_vgpu_core::testkit::capture::catch_death; use crate::gpu::device::tests::dev; use crate::gpu::encode_render::tests::metal_tests::memoryless_fetched; @@ -1067,9 +1065,9 @@ fn half_nans_only(metal: &[u8], ours: &[u8]) -> bool { .all(|(m, o)| m == o || (half_nan(m) && half_nan(o))) } -/// Metal's answer under `key` for a test to compare `mine` with ([`reims_vgpu_core::metal_answer`]). +/// Metal's answer under `key` for a test to compare `mine` with ([`crate::metal_answer`]). fn metals_of(key: &str, mine: &Result, (DeathSite, String)>) -> Vec { - reims_vgpu_core::metal_answer!(key, mine.as_ref().ok().map(Vec::as_slice)) + crate::metal_answer!(key, mine.as_ref().ok().map(Vec::as_slice)) } /// Adds to `differ` each of `ours`' cases whose bytes are not Metal's, named after `of`: how @@ -1079,9 +1077,9 @@ fn metals_of(key: &str, mine: &Result, (DeathSite, String)>) -> Vec /// ones recorded. fn compare(differ: &mut Vec, nans: &mut usize, of: &str, ours: &[(String, Vec)]) { let cases = format!("{of}: cases"); - reims_vgpu_core::metal_check!(&cases, ours.len()); + crate::metal_check!(&cases, ours.len()); for (case, mine) in ours { - let metal = &reims_vgpu_core::metal_near!(format!("{of} {case}"), mine); + let metal = &crate::metal_near!(format!("{of} {case}"), mine); assert_eq!(metal.len(), mine.len(), "{of} {case}"); let element = (metal.len() / TEXELS).max(1); let halves = ["rgbx_read_half", "rgbx_sample_half", "rgbx_read_held_half"] @@ -1607,10 +1605,10 @@ fn new_textures_read_as_metals() { let levels = format!("{name}: levels"); match survived(|| fresh_levels(&ours, &desc, texel, slices)) { Ok(mine) => { - reims_vgpu_core::metal_check!(&levels, mine.len()); + crate::metal_check!(&levels, mine.len()); for (level, o) in &mine { let key = format!("{name} {level}"); - let m = &reims_vgpu_core::metal_answer!(&key, Some(&o[..])); + let m = &crate::metal_answer!(&key, Some(&o[..])); if m != o { differ.push(format!( "{name} {level}: Metal {:02x?}, ours {:02x?}", @@ -2006,14 +2004,8 @@ fn nan_clears_are_metals() { _ => None, }; let metals = ( - reims_vgpu_core::metal_answer!( - format!("{of}: stored"), - made.map(|m| &m.0[..]) - ), - reims_vgpu_core::metal_answer!( - format!("{of}: samples"), - made.map(|m| &m.1[..]) - ), + crate::metal_answer!(format!("{of}: stored"), made.map(|m| &m.0[..])), + crate::metal_answer!(format!("{of}: samples"), made.map(|m| &m.1[..])), ); match mine { Ok(Some(mine)) if mine == metals => {} @@ -2449,7 +2441,7 @@ fn a_texture_of_usage_0x8_alone_is_metals() { assert_eq!(nans, 0); let colour = [0.25, 0.5, 0.75, 1.0]; let cleared = ours.read(&ours.cleared(BGRA.0, DROPPED, colour), 4); - reims_vgpu_core::metal_check_bytes!("a pass's clear", &cleared); + crate::metal_check_bytes!("a pass's clear", &cleared); let sized = TextureDesc { pixel_format: BGRA.0, width: 64, @@ -2461,7 +2453,7 @@ fn a_texture_of_usage_0x8_alone_is_metals() { let size = vd .heap_texture_size_and_align(&vp.texture_descriptor(&sized)) .unwrap(); - reims_vgpu_core::metal_check!("the heap's size query", size); + crate::metal_check!("the heap's size query", size); assert_eq!(size.size, 16512); let t = ours.texture_of(BGRA.0, DROPPED, PRIVATE, 1); let one = NsRange::new(0, 1); diff --git a/crates/reims-vgpu-vulkan/src/gpu/shaders.rs b/crates/reims-vgpu-vulkan/src/gpu/shaders.rs index cf2828507..ee062c759 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/shaders.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/shaders.rs @@ -9,10 +9,10 @@ //! (`device::registry_id`). A loaded library stays for the life of the process; one that fails to //! load is not kept, and the next ask loads again. +use crate::core::platform::Handle; +use crate::core::platform::types::NsErrorText; +use crate::core::sync::Mutex; use metal2vulkan_runtime::Error; -use reims_vgpu_core::platform::Handle; -use reims_vgpu_core::platform::types::NsErrorText; -use reims_vgpu_core::sync::Mutex; use crate::answer::{error_text, plain, refused}; use crate::gpu::device::VulkanDevice; diff --git a/crates/reims-vgpu-vulkan/src/gpu/slice_write_repro.rs b/crates/reims-vgpu-vulkan/src/gpu/slice_write_repro.rs index 71f2ed80b..20d20789f 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/slice_write_repro.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/slice_write_repro.rs @@ -4,15 +4,15 @@ //! BlockWritesOnly (0x10005), at a level from its uniforms, and reads zeros where the write is //! dropped. The kernels are `slice_write_repro.metal`'s, hand-written. -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; -use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; -use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::resource::{Buffer as _, Library as _, Texture as _}; -use reims_vgpu_core::platform::types::{MtlOrigin, MtlSize, NsRange}; -use reims_vgpu_core::platform::values::TextureDesc; -use reims_vgpu_core::raise::OnFault; +use crate::core::platform::Platform; +use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; +use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; +use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; +use crate::core::platform::device::GpuDevice as _; +use crate::core::platform::resource::{Buffer as _, Library as _, Texture as _}; +use crate::core::platform::types::{MtlOrigin, MtlSize, NsRange}; +use crate::core::platform::values::TextureDesc; +use crate::core::raise::OnFault; use crate::gpu::device::tests::dev; use crate::platform::tests::platform; @@ -201,7 +201,7 @@ fn imageblock_slice_writes_at_every_usage_are_metals() { for lod in [Some(0), Some(1), None] { let ours = slice_write_levels(&vp, &vd, usage, lod); let case = format!("usage {usage:#x} lod {lod:?} (None: a constant 0)"); - reims_vgpu_core::metal_check_raw!(&case, ours); + crate::metal_check_raw!(&case, ours); } } } diff --git a/crates/reims-vgpu-vulkan/src/gpu/spin.rs b/crates/reims-vgpu-vulkan/src/gpu/spin.rs index a314b9026..94c8a9a87 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/spin.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/spin.rs @@ -19,14 +19,14 @@ use std::time::Duration; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; -use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::os::Clock as _; -use reims_vgpu_core::platform::resource::{Buffer as _, Library as _}; -use reims_vgpu_core::platform::types::{CommandBufferStatus, MtlSize, NsRange}; -use reims_vgpu_core::raise::OnFault; +use crate::core::platform::Platform; +use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; +use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; +use crate::core::platform::device::GpuDevice as _; +use crate::core::platform::os::Clock as _; +use crate::core::platform::resource::{Buffer as _, Library as _}; +use crate::core::platform::types::{CommandBufferStatus, MtlSize, NsRange}; +use crate::core::raise::OnFault; use crate::VulkanPlatform; use crate::gpu::device::VulkanDevice; diff --git a/crates/reims-vgpu-vulkan/src/gpu/states.rs b/crates/reims-vgpu-vulkan/src/gpu/states.rs index 9e308b5f2..feade9808 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/states.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/states.rs @@ -150,6 +150,15 @@ use std::collections::BTreeMap; use std::sync::Weak; +use crate::core::platform::resource::RenderPipeline as _; +use crate::core::platform::types::{MtlSize, NsErrorText}; +use crate::core::platform::values::{ + ColorAttachmentDesc, DepthStencilDesc, FullComputePipelineDesc, FullMeshRenderPipelineDesc, + FullRenderPipelineDesc, LinkedFunctionsDesc, PrivateRenderDesc, RenderPipelineDesc, + SamplerDesc, StageInputDesc, StencilDesc, VertexDesc, +}; +use crate::core::raise::RaiseResult; +use crate::core::sync::Mutex; use metal2vulkan::bind::SamplerDescriptor; use metal2vulkan::metal::PrimitiveTopologyClass; use metal2vulkan::metal::state::{DepthStencilDescriptor, StencilDescriptor}; @@ -160,15 +169,6 @@ use metal2vulkan::pipeline::{ VertexBufferLayoutDescriptor, VertexDescriptor, }; use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::resource::RenderPipeline as _; -use reims_vgpu_core::platform::types::{MtlSize, NsErrorText}; -use reims_vgpu_core::platform::values::{ - ColorAttachmentDesc, DepthStencilDesc, FullComputePipelineDesc, FullMeshRenderPipelineDesc, - FullRenderPipelineDesc, LinkedFunctionsDesc, PrivateRenderDesc, RenderPipelineDesc, - SamplerDesc, StageInputDesc, StencilDesc, VertexDesc, -}; -use reims_vgpu_core::raise::RaiseResult; -use reims_vgpu_core::sync::Mutex; use crate::answer::{ Nil, Policy, create, decide_describing, error_text, get_describing, plain, plain_at, relay_gap, @@ -1202,13 +1202,13 @@ pub(crate) fn compute_formats(d: &ComputePipelineDescriptor) -> String { #[cfg(test)] mod tests { + use crate::core::platform::Handle; + use crate::core::platform::device::GpuDevice; + use crate::core::platform::resource::{DepthStencilState, SamplerState}; + use crate::core::platform::resource::{Library, RenderPipeline}; + use crate::core::raise::OnFault; + use crate::core::testkit::capture::catch_death; use metal2vulkan::metal::PixelFormat; - use reims_vgpu_core::platform::Handle; - use reims_vgpu_core::platform::device::GpuDevice; - use reims_vgpu_core::platform::resource::{DepthStencilState, SamplerState}; - use reims_vgpu_core::platform::resource::{Library, RenderPipeline}; - use reims_vgpu_core::raise::OnFault; - use reims_vgpu_core::testkit::capture::catch_death; use super::*; use crate::gpu::device::tests::dev; @@ -1308,7 +1308,7 @@ mod tests { /// attribute it lacks #[test] fn a_whole_render_value_carries_its_vertex_descriptor() { - use reims_vgpu_core::platform::values::{AttributeDesc, BufferLayoutDesc}; + use crate::core::platform::values::{AttributeDesc, BufferLayoutDesc}; let (v, f) = vertex_descriptor_functions(); let d = dev(); let mut desc = full_render(&v, Some(&f)); @@ -1430,9 +1430,9 @@ mod tests { /// value's other fields are the runtime descriptor's own #[test] fn a_whole_compute_value_carries_its_stage_input() { + use crate::core::platform::resource::ComputePipeline as _; + use crate::core::platform::values::{AttributeDesc, BufferLayoutDesc}; use crate::gpu::device::tests::{STAGEIN, fixture_function}; - use reims_vgpu_core::platform::resource::ComputePipeline as _; - use reims_vgpu_core::platform::values::{AttributeDesc, BufferLayoutDesc}; let f = fixture_function(STAGEIN); let sel = "newComputePipelineStateWithDescriptor:options:reflection:error:"; let mut desc = FullComputePipelineDesc { @@ -1614,10 +1614,10 @@ mod tests { include_bytes!(concat!(env!("OUT_DIR"), "/linked_callee.metallib")); /// The float constant of `index` whose value is `v`. - fn float_constant(index: u32, v: f32) -> reims_vgpu_core::platform::resource::FunctionConstant { - let mut value = [0; reims_vgpu_core::platform::resource::FunctionConstant::MAX_BYTES]; + fn float_constant(index: u32, v: f32) -> crate::core::platform::resource::FunctionConstant { + let mut value = [0; crate::core::platform::resource::FunctionConstant::MAX_BYTES]; value[..4].copy_from_slice(&v.to_le_bytes()); - reims_vgpu_core::platform::resource::FunctionConstant { + crate::core::platform::resource::FunctionConstant { index, data_type: 3, value, @@ -1627,7 +1627,7 @@ mod tests { /// `linked_callee.metal`'s `linked_gradient` of `callee` with `linked_gradient_scale` 0.5, /// made by descriptor under `specialized` where given: the function RenderBox links under /// `custom_fn`. `None` where the library makes none. - pub(super) fn gradient( + pub(super) fn gradient( callee: &P::Library, specialized: Option<&str>, ) -> Option { @@ -1646,19 +1646,19 @@ mod tests { /// `linked_effect_alpha` 0.75 and `linked` linked to its stage (RenderBox's custom effect), /// writes for each pixel of a 4x4 target on `p`'s device `d`, by its bits: `None` where the /// pipeline is refused. - pub(super) fn custom_effect( + pub(super) fn custom_effect( p: &P, d: &P::Device, caller: &P::Library, linked: &P::Function, ) -> Option> { - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; - use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::platform::types::NsRange; - use reims_vgpu_core::platform::values::{ColorAttachmentSet, TextureDesc}; - let _pool = reims_vgpu_core::rt::Pool::here(); + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::descriptor::RenderPassDescriptor as _; + use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; + use crate::core::platform::resource::Buffer as _; + use crate::core::platform::types::NsRange; + use crate::core::platform::values::{ColorAttachmentSet, TextureDesc}; + let _pool = crate::core::rt::Pool::here(); let vertex = caller .new_function(OnFault::Die, "linked_effect_vertex") .unwrap() @@ -1978,7 +1978,7 @@ mod tests { fn death_line(f: impl FnOnce() -> T) -> (&'static str, String) { *crate::answer::LAST_LINE.lock() = None; let site = catch_death(f).err().expect("it dies"); - assert_eq!(site.kind, reims_vgpu_core::raise::death::DeathKind::Abort); + assert_eq!(site.kind, crate::core::raise::death::DeathKind::Abort); let line = crate::answer::LAST_LINE.lock().take().unwrap_or_default(); (site.file, line) } @@ -2106,9 +2106,9 @@ mod tests { /// A stage of the platform's own vertex function, from its metallib on the CPU: the lines of /// a descriptor's formats read no stage. fn cpu_stage() -> StageSource { + use crate::core::display::pipeline::VERTEX_FUNCTION; use metal2vulkan::library::Library; use metal2vulkan::pipeline::FunctionDescriptor; - use reims_vgpu_core::display::pipeline::VERTEX_FUNCTION; let library = Library::from_metallib(crate::gpu::shaders::METALLIB).unwrap(); StageSource::Function(FunctionDescriptor::new( library.function(VERTEX_FUNCTION).unwrap(), diff --git a/crates/reims-vgpu-vulkan/src/gpu/states/tests/metal_tests.rs b/crates/reims-vgpu-vulkan/src/gpu/states/tests/metal_tests.rs index 29c127a93..1ef9ae6bd 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/states/tests/metal_tests.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/states/tests/metal_tests.rs @@ -8,7 +8,7 @@ const NUMBERED: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/numbered_sampl /// `f`'s value, made inside an autorelease pool of its own, as core runs each unit of work: /// what Metal autoreleases inside it goes at its end. fn pooled(f: impl FnOnce() -> T) -> T { - let _pool = reims_vgpu_core::rt::Pool::here(); + let _pool = crate::core::rt::Pool::here(); f() } @@ -17,8 +17,8 @@ fn pooled(f: impl FnOnce() -> T) -> T { /// device's own sampler ID for good: at each step a sampler state of a descriptor no other /// equals is made and kept to the end, so it takes the lowest ID no holder holds, and its /// `gpuResourceID` is read. Each creation and release runs in a pool of its own. -fn numbered_ids(d: &P::Device) -> Vec<(&'static str, u64)> { - use reims_vgpu_core::platform::values::RenderPipelineDesc; +fn numbered_ids(d: &P::Device) -> Vec<(&'static str, u64)> { + use crate::core::platform::values::RenderPipelineDesc; let _queue = pooled(|| d.new_command_queue().unwrap()); let mut kept: Vec = Vec::new(); let mut ids = Vec::new(); @@ -123,7 +123,7 @@ fn numbered_ids(d: &P::Device) -> Vec<(& fn sampler_ids_follow_pipeline_holders_as_metals() { crate::os::install_process_services(); let ours = numbered_ids::(&dev()); - reims_vgpu_core::metal_check!("ids", ours); + crate::metal_check!("ids", ours); } /// `five_samplers.metal`'s kernel, compiled by build.rs. @@ -133,7 +133,7 @@ const FIVE: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/five_samplers.meta /// kernel's function and its state are made, after a command queue, which takes the device's /// own sampler ID, and 250 sampler states of argument buffer support, each of its own LOD /// clamp, kept to the end. Each creation and release runs in a pool of its own. -fn five_samplers_move(d: &P::Device) -> u64 { +fn five_samplers_move(d: &P::Device) -> u64 { use crate::gpu::resource::tests::metal_tests::next_range; let _queue = pooled(|| d.new_command_queue().unwrap()); let states: Vec = (0..250u16) @@ -183,25 +183,25 @@ fn pipeline_samplers_grow_metals_sampler_mempool() { /// A 16 by 8 `RGBA16Float` texture on `p`'s device `d`, its halves `seed`'s noise of every /// sign below 2 in magnitude, written by the CPU. -fn noise_texture( +fn noise_texture( p: &P, d: &P::Device, seed: u64, ) -> P::Texture { - use reims_vgpu_core::platform::HostRange; - use reims_vgpu_core::platform::resource::Texture as _; - use reims_vgpu_core::platform::types::{MtlOrigin, MtlRegion, MtlSize}; + use crate::core::platform::HostRange; + use crate::core::platform::resource::Texture as _; + use crate::core::platform::types::{MtlOrigin, MtlRegion, MtlSize}; let (w, h) = (16, 8); let t = d .new_texture( OnFault::Die, - &p.texture_descriptor(&reims_vgpu_core::platform::values::TextureDesc { + &p.texture_descriptor(&crate::core::platform::values::TextureDesc { pixel_format: 115, width: w, height: h, usage: 1, resource_options: Some(0), - ..reims_vgpu_core::platform::values::TextureDesc::default() + ..crate::core::platform::values::TextureDesc::default() }), ) .unwrap() @@ -221,7 +221,7 @@ fn noise_texture( /// `d`, into floats, as their bits, by `kernel` (`sample_only_texels_float`, or /// `sample_texels_float`, which holds a gather too): at positions a third of a texel apart /// from two texels before the texture to two past it, normalized. -fn cubic_samples( +fn cubic_samples( p: &P, d: &P::Device, desc: &SamplerDesc, @@ -291,7 +291,7 @@ fn cubic_samplers_sample_as_metals() { continue; } let ours = cubic_samples(&p, &d, &desc, SAMPLE_ONLY); - reims_vgpu_core::metal_check_raw!(case, ours); + crate::metal_check_raw!(case, ours); } } for compare in [1, 3, 7] { @@ -319,7 +319,7 @@ fn cubic_samplers_sample_as_metals() { fn cubic_samplers_sample_in_a_fragment_function_as_metals() { use crate::gpu::ycbcr::measure::{drawn, float_texels, probe}; /// What `sample_fragment_float` reads of [`noise_texture`] through a sampler of `desc`. - fn fragment_samples( + fn fragment_samples( p: &P, d: &P::Device, desc: &SamplerDesc, @@ -361,7 +361,7 @@ fn cubic_samplers_sample_in_a_fragment_function_as_metals() { fn constexpr_bicubic_samplers_sample_as_metals() { use crate::gpu::ycbcr::measure::{float_texels, probe, probed_texels}; /// What `kernel` reads of [`noise_texture`] at the probe `at` over `grid`. - fn constexpr_samples( + fn constexpr_samples( p: &P, d: &P::Device, kernel: &str, @@ -465,17 +465,17 @@ enum Held { /// What `sample()` through a sampler of `desc`, made for argument buffers and held by its /// resource ID in an argument buffer as `held` says, reads of [`noise_texture`] on `p`'s /// device `d`, into floats, as their bits, at [`cubic_samples`]'s positions. -fn held_samples( +fn held_samples( p: &P, d: &P::Device, desc: &SamplerDesc, held: Held, ) -> Vec<[u32; 4]> { - use reims_vgpu_core::platform::blit::ResourceRef; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; - use reims_vgpu_core::platform::resource::{Buffer as _, Texture as _}; - use reims_vgpu_core::platform::types::{MtlSize, NsRange}; + use crate::core::platform::blit::ResourceRef; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; + use crate::core::platform::resource::{Buffer as _, Texture as _}; + use crate::core::platform::types::{MtlSize, NsRange}; use crate::gpu::ycbcr::measure::{PROBE, float_texels, probe}; let t = noise_texture(p, d, 5); @@ -569,7 +569,7 @@ fn a_cubic_sampler_in_an_argument_buffer_dies_where_its_failure_is_read() { let (p, d) = (crate::platform::tests::platform(), dev()); let linear = filtered(1, 1, 0); let ours = held_samples(&p, &d, &linear, Held::Both); - reims_vgpu_core::metal_check_raw!("linear", ours); + crate::metal_check_raw!("linear", ours); let cubic = filtered(2, 2, 0); let (sel, line) = death_line(|| held_samples(&p, &d, &cubic, Held::Both)); assert_eq!(sel, "waitUntilCompleted", "{line}"); @@ -589,7 +589,7 @@ fn a_live_cubic_sampler_leaves_argument_buffer_samples_metals() { let cubic = d.new_sampler_state(&filtered(2, 2, 0)).unwrap().unwrap(); let ours = held_samples(&p, &d, &linear, Held::Both); drop(cubic); - reims_vgpu_core::metal_check_raw!("linear", ours); + crate::metal_check_raw!("linear", ours); } /// What a draw over 16 by 8 `BGRA8Unorm` does on `p`'s device `d` whose fragment function @@ -597,19 +597,19 @@ fn a_live_cubic_sampler_leaves_argument_buffer_samples_metals() { /// argument buffer at fragment buffer 0 holds beside it (`sample_held_fragment`), a cubic /// sampler state made after the draw was encoded and before the commit where `cubic` says: /// the command buffer's status and error code once it completed. -fn held_draw( +fn held_draw( p: &P, d: &P::Device, desc: &SamplerDesc, cubic: bool, ) -> (u64, u64) { - use reims_vgpu_core::platform::blit::ResourceRef; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; - use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; - use reims_vgpu_core::platform::resource::{Buffer as _, Texture as _}; - use reims_vgpu_core::platform::types::NsRange; - use reims_vgpu_core::platform::values::{ColorAttachmentSet, RenderPipelineDesc, TextureDesc}; + use crate::core::platform::blit::ResourceRef; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::descriptor::RenderPassDescriptor as _; + use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; + use crate::core::platform::resource::{Buffer as _, Texture as _}; + use crate::core::platform::types::NsRange; + use crate::core::platform::values::{ColorAttachmentSet, RenderPipelineDesc, TextureDesc}; use crate::gpu::ycbcr::measure::PROBE; let t = noise_texture(p, d, 5); @@ -742,12 +742,12 @@ type Pipelines<'a> = (&'a [&'a str], &'a [(&'a str, &'a str)]); /// What each creator answers on `d` for the functions `pipelines` names of the metallib /// `library`, by name: `Ok` for a state, `Err` of the `NSError`'s code. -fn answers( +fn answers( d: &P::Device, library: &[u8], (kernels, renders): Pipelines<'_>, ) -> Vec<(String, Result<(), i64>)> { - use reims_vgpu_core::platform::values::FullComputePipelineDesc; + use crate::core::platform::values::FullComputePipelineDesc; use crate::gpu::device::tests::render_value; let library = d.new_library(library).unwrap().unwrap().unwrap(); @@ -909,11 +909,11 @@ type IndirectAnswer = Result<(), (i64, Vec)>; /// What the compute and render creators answer on `d` for each of `cases`, a whole value /// (compute where its name says so) of the fixture functions its refs 5 (a kernel), 0x21 (a /// vertex function) and 0x22 (a fragment function, where it has one) are, by name. -fn indirect_answers( +fn indirect_answers( d: &P::Device, cases: &[IndirectCase<'_>], ) -> Vec<(String, IndirectAnswer)> { - use reims_vgpu_core::platform::values::{FullComputePipelineDesc, FullRenderPipelineDesc}; + use crate::core::platform::values::{FullComputePipelineDesc, FullRenderPipelineDesc}; use crate::gpu::device::tests::colours_of; let function = |bytes: &[u8]| { @@ -1135,12 +1135,10 @@ fn indirect_states_of_direct_arguments_are_metals_nserror() { .unwrap() .unwrap(); let error = d - .new_compute_pipeline_state_full( - &reims_vgpu_core::platform::values::FullComputePipelineDesc { - support_indirect_command_buffers: true, - ..reims_vgpu_core::platform::values::FullComputePipelineDesc::new(&f) - }, - ) + .new_compute_pipeline_state_full(&crate::core::platform::values::FullComputePipelineDesc { + support_indirect_command_buffers: true, + ..crate::core::platform::values::FullComputePipelineDesc::new(&f) + }) .unwrap_err(); assert_eq!(error.domain, crate::answer::RUNTIME_DOMAIN); } @@ -1258,10 +1256,10 @@ fn an_input_no_vertex_output_writes_is_metals() { /// state of the vertex function alike #[test] fn states_whose_arguments_reflection_is_refused_are_decided_by_their_roles() { + use crate::core::platform::device::GpuDevice as _; + use crate::core::platform::resource::Library as _; + use crate::core::platform::values::{FullComputePipelineDesc, FullRenderPipelineDesc}; use metal2vulkan::error::{Error as Compile, Feature}; - use reims_vgpu_core::platform::device::GpuDevice as _; - use reims_vgpu_core::platform::resource::Library as _; - use reims_vgpu_core::platform::values::{FullComputePipelineDesc, FullRenderPipelineDesc}; let d = dev(); let library = d @@ -1316,13 +1314,13 @@ fn a_function_linked_under_a_specialized_name_is_metals() { assert_eq!(ours.name(), specialized.unwrap_or("linked_gradient")); let drawn = catch_death(|| custom_effect(&p, &d, &caller, &ours)); let drawn = drawn.unwrap_or_else(|site| panic!("{specialized:?}: died at {site:?}")); - reims_vgpu_core::metal_check!(key, drawn); + crate::metal_check!(key, drawn); } } /// A pipeline creator's answer in [`linked_answers`]: made, or the `NSError`'s code, or where the /// creator dies. -type LinkedAnswer = Result, reims_vgpu_core::raise::death::DeathSite>; +type LinkedAnswer = Result, crate::core::raise::death::DeathSite>; /// What the compute and render creators answer for `linked_caller.metal`'s functions with /// `linked_callee.metal`'s `linked_add_one`, which they call, linked by each list a value @@ -1334,7 +1332,7 @@ type LinkedAnswer = Result, reims_vgpu_core::raise::death::Death /// library made of the same bytes, and the copy turns the function made before it into that /// object (measured on the M3 Max, macOS 27.0.1). A case after the copy would link the binary /// where it names the function made by name. -fn linked_answers( +fn linked_answers( d: &P::Device, ) -> Vec<(&'static str, LinkedAnswer)> { let library = |bytes| d.new_library(bytes).unwrap().unwrap().unwrap(); @@ -1348,18 +1346,16 @@ fn linked_answers( let add_one = named(&callee, "linked_add_one"); let one = |f: &P::Function| vec![f.clone_ref()]; let group = || vec![("g".to_owned(), one(&add_one))]; - let answer = |made: Result< - Result, NsErrorText>, - reims_vgpu_core::raise::death::DeathSite, - >| { - made.map(|made| match made { - Ok(state) => { - assert!(state.is_some()); - Ok(()) - } - Err(e) => Err(e.code), - }) - }; + let answer = + |made: Result, NsErrorText>, crate::core::raise::death::DeathSite>| { + made.map(|made| match made { + Ok(state) => { + assert!(state.is_some()); + Ok(()) + } + Err(e) => Err(e.code), + }) + }; let compute = |functions, binary_functions, groups, private_functions| { answer(catch_death(|| { d.new_compute_pipeline_state_full(&FullComputePipelineDesc { @@ -1482,6 +1478,6 @@ fn unresolved_visible_calls_are_metals() { let ours = linked_answers::(&dev()); assert_eq!(ours.len(), 13); for (case, ours) in ours { - reims_vgpu_core::metal_check!(case, ours); + crate::metal_check!(case, ours); } } diff --git a/crates/reims-vgpu-vulkan/src/gpu/timing.rs b/crates/reims-vgpu-vulkan/src/gpu/timing.rs index a2b66e9a9..7aea0980d 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/timing.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/timing.rs @@ -43,15 +43,15 @@ use std::collections::BTreeMap; use std::sync::atomic::{AtomicU64, Ordering}; use std::time::Duration; +use crate::core::platform::os::{Clock as _, MonoTime}; use metal2vulkan::pipeline::{MeshPipelineDescriptor, RenderPipelineDescriptor, StageSource}; use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::os::{Clock as _, MonoTime}; +use crate::core::platform::types::NsErrorText; +use crate::core::raise::RaiseResult; +use crate::core::sync::Mutex; +use crate::core::trace; use crate::os::OsClock; -use reims_vgpu_core::platform::types::NsErrorText; -use reims_vgpu_core::raise::RaiseResult; -use reims_vgpu_core::sync::Mutex; -use reims_vgpu_core::trace; /// An encoder command or a commit that takes this long or longer is written. pub const SLOW_CALL: Duration = Duration::from_millis(5); @@ -522,12 +522,12 @@ mod tests { use std::sync::Arc; use std::sync::atomic::AtomicU64; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::device::GpuDevice as _; + use crate::core::platform::event::{EventRef, SharedEvent as _}; + use crate::core::raise::OnFault; + use crate::core::sync::Mutex; use log::LevelFilter; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::device::GpuDevice as _; - use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; - use reims_vgpu_core::raise::OnFault; - use reims_vgpu_core::sync::Mutex; use super::*; use crate::gpu::device::tests::dev; @@ -542,7 +542,7 @@ mod tests { fn hook() -> Seen { let seen = Seen::default(); let lines = Arc::clone(&seen); - let installed = reims_vgpu_core::logging::set_hook( + let installed = crate::core::logging::set_hook( LevelFilter::Debug, Box::new(move |_, target, message| { if target == module_path!().trim_end_matches("::tests") { @@ -568,7 +568,7 @@ mod tests { "--test-threads=1", ]) .env(CHILD, "1") - .env_remove(reims_vgpu_core::logging::ENV_VAR) + .env_remove(crate::core::logging::ENV_VAR) .output() .unwrap(); assert!(out.status.success(), "{out:?}"); @@ -698,8 +698,8 @@ mod tests { #[test] #[ignore = "a measurement, run by hand: prints the latencies"] fn commit_to_handler_latency() { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::types::NsRange; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::types::NsRange; let d = dev(); let q = d.new_command_queue().unwrap(); diff --git a/crates/reims-vgpu-vulkan/src/gpu/undefined.rs b/crates/reims-vgpu-vulkan/src/gpu/undefined.rs index a27117020..91892f2c8 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/undefined.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/undefined.rs @@ -9,20 +9,20 @@ //! **Measured on one GPU.** Every answer here is an Apple M3 Max's (40-core GPU) under macOS 26.7 //! (25G229). Other Apple GPU generations were not measured: an answer here may not hold on them. -use reims_vgpu_core::platform::HostRange; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; -use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; -use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; -use reims_vgpu_core::platform::resource::{Buffer as _, Library as _, Texture as _}; -use reims_vgpu_core::platform::types::{ClearColor, MtlOrigin, MtlRegion, MtlSize}; -use reims_vgpu_core::platform::values::{ +use crate::core::platform::HostRange; +use crate::core::platform::Platform; +use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; +use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; +use crate::core::platform::descriptor::RenderPassDescriptor as _; +use crate::core::platform::device::GpuDevice as _; +use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; +use crate::core::platform::resource::{Buffer as _, Library as _, Texture as _}; +use crate::core::platform::types::{ClearColor, MtlOrigin, MtlRegion, MtlSize}; +use crate::core::platform::values::{ ColorAttachmentSet, DepthAttachmentSet, DepthStencilDesc, FullRenderPipelineDesc, StencilAttachmentSet, StencilDesc, TextureDesc, }; -use reims_vgpu_core::raise::OnFault; +use crate::core::raise::OnFault; use crate::gpu::device::tests::colours_of; diff --git a/crates/reims-vgpu-vulkan/src/gpu/undefined/dont_care_load.rs b/crates/reims-vgpu-vulkan/src/gpu/undefined/dont_care_load.rs index e7dbdc6c6..a87594a2c 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/undefined/dont_care_load.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/undefined/dont_care_load.rs @@ -48,8 +48,8 @@ //! the draws' primitives reach (the runtime's tile-reach rule and capture replay, which its load //! pass of extended-range attachments uses), then load every attachment by `Load`. +use crate::core::platform::Platform; use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::Platform; use super::{ Aspect, CLEAR, Colour, DEPTH32F, DONT_CARE, Draw, IN_TILE_1_1, LOAD, MULTISAMPLE_RESOLVE, @@ -184,7 +184,7 @@ fn against_metal( for &c in cases { let key = format!("{c:?}"); let o = ours(c); - if !reims_vgpu_core::metal_matches_raw!(&key, o) { + if !crate::metal_matches_raw!(&key, o) { assert!( heard(KIND), "{c:?}: off Metal's, with no {} heard", @@ -333,7 +333,7 @@ fn a_depth_dont_care_load_clears_the_reached_tiles_once_the_pass_writes_depth() let mut differ = Vec::new(); for draws in [(false, false), (true, false), (true, true)] { let key = format!("{draws:?}"); - if !reims_vgpu_core::metal_matches_raw!(&key, colour_and_depth((&p, &d), draws)) { + if !crate::metal_matches_raw!(&key, colour_and_depth((&p, &d), draws)) { assert!( heard(KIND), "{draws:?}: off Metal's, with no {} heard", @@ -395,7 +395,7 @@ fn every_colour_attachment_of_a_reached_tile_is_zeroed() { let mut differ = Vec::new(); for mask in [None, Some(0)] { let key = format!("{mask:?}"); - if !reims_vgpu_core::metal_matches_raw!(&key, two_colours((&p, &d), mask)) { + if !crate::metal_matches_raw!(&key, two_colours((&p, &d), mask)) { assert!( heard(KIND), "{mask:?}: off Metal's, with no {} heard", diff --git a/crates/reims-vgpu-vulkan/src/gpu/undefined/extended_range.rs b/crates/reims-vgpu-vulkan/src/gpu/undefined/extended_range.rs index 723828619..f96c0e5a3 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/undefined/extended_range.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/undefined/extended_range.rs @@ -37,9 +37,9 @@ //! sparse texture's image); a NaN clear's codes (0, or 384 in an `_sRGB` twin) taken into the //! runtime's clear. +use crate::core::platform::Platform; +use crate::core::platform::types::ClearColor; use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::types::ClearColor; use super::{ Aspect, CLEAR, Colour, Draw, IN_TILE_1_1, LOAD, Pass, READ, SHARED, STORE, Shape, Step, TARGET, @@ -102,7 +102,7 @@ fn paths((p, d): (&P, &P::Device), shape: Shape, raw: &[u8]) -> [Ve /// Requires `ours` to be Metal's bytes, recorded, or the runtime to have announced /// `extended-range-bits-kept`; answers whether they differ. fn against(case: &str, ours: &[u8]) -> bool { - let differ = !reims_vgpu_core::metal_matches_bytes!(case, ours); + let differ = !crate::metal_matches_bytes!(case, ours); if differ { assert!( heard(rt::Degradation::ExtendedRangeBitsKept), diff --git a/crates/reims-vgpu-vulkan/src/gpu/undefined/heap_layout.rs b/crates/reims-vgpu-vulkan/src/gpu/undefined/heap_layout.rs index b838ff190..42c5c868c 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/undefined/heap_layout.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/undefined/heap_layout.rs @@ -47,12 +47,12 @@ //! every format and sample count, by every path that writes (blits, a pass's store, a clear), //! with the block's unused bytes kept. No public specification of the encoding is known. +use crate::core::platform::Platform; +use crate::core::platform::device::GpuDevice as _; +use crate::core::platform::resource::Heap as _; +use crate::core::platform::types::ResourceAddressRange; +use crate::core::platform::values::{HeapDesc, OptionSet}; use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::resource::Heap as _; -use reims_vgpu_core::platform::types::ResourceAddressRange; -use reims_vgpu_core::platform::values::{HeapDesc, OptionSet}; use super::{ Aspect, CLEAR, Pass, READ, RGBA8, STORE, Shape, Step, TARGET, WRITE, heard, random_bytes, @@ -198,11 +198,8 @@ fn heap_texture_bytes_are_metals_tiles_or_its_compressed_form() { let case = format!("{name} {write:?}"); let (o, ours_size) = heap_bytes((&p, &d), shape, write); // The texture's size in the heap, Metal's. - reims_vgpu_core::metal_check!(format!("{case}: size"), ours_size); - if !reims_vgpu_core::metal_matches_bytes!( - &case, - &o[..usize::try_from(ours_size).unwrap()] - ) { + crate::metal_check!(format!("{case}: size"), ours_size); + if !crate::metal_matches_bytes!(&case, &o[..usize::try_from(ours_size).unwrap()]) { let kind = rt::Degradation::HeapTextureLosslessLayout; assert!(compresses && heard(kind), "{case}: off Metal's"); differ.push(case); diff --git a/crates/reims-vgpu-vulkan/src/gpu/undefined/unreached_tiles.rs b/crates/reims-vgpu-vulkan/src/gpu/undefined/unreached_tiles.rs index 797ad9e83..6edfd6dfc 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/undefined/unreached_tiles.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/undefined/unreached_tiles.rs @@ -35,7 +35,7 @@ //! ([`super::extended_range`]), would take the signed normalized formats (the most negative code //! one up) and `Depth32Float` (the sign bit cleared, where a draw of the pass writes depth). -use reims_vgpu_core::platform::Platform; +use crate::core::platform::Platform; use super::{ Aspect, CLEAR, DEPTH32F, DONT_CARE, Draw, IN_TILE_1_1, LOAD, Pass, STENCIL8, STORE, Shape, @@ -116,7 +116,7 @@ fn unreached_tiles_keep_their_bytes_under_load_and_dont_care() { for drawn in [false, true] { let case = format!("{format} {size:?} load {load} drawn {drawn}"); let o = probe((&p, &d), (format, size), (load, drawn)); - if !reims_vgpu_core::metal_matches_raw!(&case, o) { + if !crate::metal_matches_raw!(&case, o) { let kind = metal2vulkan_runtime::Degradation::DontCareLoadTiles; assert!(load == DONT_CARE && heard(kind), "{case}: off Metal's"); differ.push(case); diff --git a/crates/reims-vgpu-vulkan/src/gpu/writes.rs b/crates/reims-vgpu-vulkan/src/gpu/writes.rs index f7e5f7d0e..7a6686da2 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/writes.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/writes.rs @@ -61,10 +61,10 @@ use std::ops::Range; use std::sync::Arc; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; +use crate::core::num::ToU64; use metal2vulkan::metal::{BindingType, PixelFormat}; use metal2vulkan::pipeline::ComputePipelineDescriptor; use metal2vulkan::reflection::{SlotWritability, SlotWrite, SlotWriteGap}; -use reims_vgpu_core::num::ToU64; use crate::answer::plain; use crate::gpu::backing::Pages; @@ -813,11 +813,11 @@ impl Whether { #[cfg(test)] pub(crate) mod tests { - use reims_vgpu_core::platform::Platform as _; - use reims_vgpu_core::platform::device::GpuDevice as _; - use reims_vgpu_core::platform::resource::{Buffer as _, Heap as _}; - use reims_vgpu_core::platform::values::TextureDesc; - use reims_vgpu_core::raise::OnFault; + use crate::core::platform::Platform as _; + use crate::core::platform::device::GpuDevice as _; + use crate::core::platform::resource::{Buffer as _, Heap as _}; + use crate::core::platform::values::TextureDesc; + use crate::core::raise::OnFault; use super::*; use crate::gpu::resource::tests::{guest_pages, heap_at, over_pages}; diff --git a/crates/reims-vgpu-vulkan/src/gpu/ycbcr.rs b/crates/reims-vgpu-vulkan/src/gpu/ycbcr.rs index 5a5db7202..edf3243e0 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/ycbcr.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/ycbcr.rs @@ -275,8 +275,8 @@ pub fn two_plane(pf: PixelFormat) -> bool { #[cfg(test)] mod tests { - use reims_vgpu_core::raise::death::DeathKind; - use reims_vgpu_core::testkit::capture::catch_death; + use crate::core::raise::death::DeathKind; + use crate::core::testkit::capture::catch_death; use crate::gpu::device::tests::dev; diff --git a/crates/reims-vgpu-vulkan/src/gpu/ycbcr/measure.rs b/crates/reims-vgpu-vulkan/src/gpu/ycbcr/measure.rs index f598d2ab6..69a56de32 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/ycbcr/measure.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/ycbcr/measure.rs @@ -4,7 +4,7 @@ //! halves and into floats. The same probes run for every member: a surface's shape is its //! OSType's ([`Shape`]), and the texture's format is a parameter of each probe ([`probes`]). //! Floats show a texel's value at full precision; a kernel that reads into halves rounds it. -use reims_vgpu_core::platform::os::surface::{IoSurfaces as _, SurfacePlaneSpec, SurfaceSpec}; +use crate::core::platform::os::surface::{IoSurfaces as _, SurfacePlaneSpec, SurfaceSpec}; use crate::os::{OsSurface, OsSurfaces}; diff --git a/crates/reims-vgpu-vulkan/src/gpu/ycbcr/measure/host.rs b/crates/reims-vgpu-vulkan/src/gpu/ycbcr/measure/host.rs index 35cf976f9..f0a3de5b1 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/ycbcr/measure/host.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/ycbcr/measure/host.rs @@ -3,15 +3,15 @@ use std::ffi::c_void; -use reims_vgpu_core::platform::Handle as _; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; -use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::resource::{Buffer as _, Library as _}; -use reims_vgpu_core::platform::types::{MtlSize, NsRange}; -use reims_vgpu_core::platform::values::{SamplerDesc, TextureDesc}; -use reims_vgpu_core::raise::OnFault; +use crate::core::platform::Handle as _; +use crate::core::platform::Platform; +use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; +use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; +use crate::core::platform::device::GpuDevice as _; +use crate::core::platform::resource::{Buffer as _, Library as _}; +use crate::core::platform::types::{MtlSize, NsRange}; +use crate::core::platform::values::{SamplerDesc, TextureDesc}; +use crate::core::raise::OnFault; use super::*; use crate::os::OsSurface; @@ -89,7 +89,7 @@ pub(crate) fn surface_420(ostype: &[u8; 4], size: (u64, u64)) -> OsSurface { pub(crate) fn surface_420_over( ostype: &[u8; 4], size: (u64, u64), -) -> (OsSurface, reims_vgpu_core::host::HostPtr, u64) { +) -> (OsSurface, crate::core::host::HostPtr, u64) { surface_420_over_at(ostype, size, 0) } @@ -99,10 +99,10 @@ pub(crate) fn surface_420_over_at( ostype: &[u8; 4], size: (u64, u64), offset: u64, -) -> (OsSurface, reims_vgpu_core::host::HostPtr, u64) { - use reims_vgpu_core::host::PhysicalMemoryRange; - use reims_vgpu_core::num::ToU64; - use reims_vgpu_core::platform::os::vm::HostVm as _; +) -> (OsSurface, crate::core::host::HostPtr, u64) { + use crate::core::host::PhysicalMemoryRange; + use crate::core::num::ToU64; + use crate::core::platform::os::vm::HostVm as _; let mut spec = spec_420(ostype, size); let vm = crate::os::OsVm::new(); let page = vm.page_size(); @@ -173,7 +173,7 @@ pub(crate) fn probed_texels( ) -> Vec { // What Metal autoreleases for the probe (its command buffer and encoder, which a dev build // cannot elide) goes at its end. - let _pool = reims_vgpu_core::rt::Pool::here(); + let _pool = crate::core::rt::Pool::here(); let library = d.new_library(PROBE).unwrap().unwrap().unwrap(); let f = library.new_function(OnFault::Die, kernel).unwrap().unwrap(); let state = d @@ -401,16 +401,16 @@ pub(crate) fn drawn( sampler: &P::SamplerState, bytes: &[u8], ) -> Vec { - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; - use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; - use reims_vgpu_core::platform::resource::{Buffer as _, Library as _}; - use reims_vgpu_core::platform::types::NsRange; - use reims_vgpu_core::platform::values::{ColorAttachmentSet, RenderPipelineDesc}; - use reims_vgpu_core::raise::OnFault; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::descriptor::RenderPassDescriptor as _; + use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; + use crate::core::platform::resource::{Buffer as _, Library as _}; + use crate::core::platform::types::NsRange; + use crate::core::platform::values::{ColorAttachmentSet, RenderPipelineDesc}; + use crate::core::raise::OnFault; // What Metal autoreleases for the draw goes at its end, and its queue is the tests' one // (`test_queue`): a draw of its own queue each would pass the process's limit of queues. - let _pool = reims_vgpu_core::rt::Pool::here(); + let _pool = crate::core::rt::Pool::here(); let library = d.new_library(PROBE).unwrap().unwrap().unwrap(); let function = |name| library.new_function(OnFault::Die, name).unwrap().unwrap(); let (vertex, fragment) = (function("cover_vertex"), function(fragment)); @@ -535,7 +535,7 @@ impl Shape { luma: impl Fn(u64, u64) -> u16, chroma: impl Fn(u64, u64) -> (u16, u16), ) { - use reims_vgpu_core::platform::os::surface::Surface as _; + use crate::core::platform::os::surface::Surface as _; let (y_plane, c_plane) = ( crate::os::plane(surface, 0).unwrap(), crate::os::plane(surface, 1).unwrap(), @@ -586,7 +586,7 @@ impl Shape { luma: impl Fn(u64, u64) -> u16, chroma: impl Fn(u64, u64) -> (u16, u16), ) { - use reims_vgpu_core::platform::os::surface::Surface as _; + use crate::core::platform::os::surface::Surface as _; let base = surface.base_address().as_ptr::(); let write = |plane: &metal2vulkan_runtime::IoSurfacePlane, y: u64, i: u64, code: u16| { let at = plane.offset + y * plane.bytes_per_row + i / 3 * 4; diff --git a/crates/reims-vgpu-vulkan/src/gpu/ycbcr/sampling.rs b/crates/reims-vgpu-vulkan/src/gpu/ycbcr/sampling.rs index 8a6102ac1..c1a59cea7 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/ycbcr/sampling.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/ycbcr/sampling.rs @@ -2,21 +2,19 @@ //! Metal's ([`super::runtime_makes`]): what they read and sample, their IDs and usage, their //! views, where the runtime cannot map their samplers, and what they show of writes of their //! surfaces. The harness is [`super::measure`]'s. +use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; +use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; +use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; +use crate::core::platform::device::GpuDevice as _; +use crate::core::platform::os::surface::Surface as _; +use crate::core::platform::resource::{Buffer as _, GpuResource as _, Library as _, Texture as _}; +use crate::core::platform::types::{MtlOrigin, MtlSize, NsRange}; +use crate::core::platform::values::TextureDesc; +use crate::core::platform::{Handle as _, Platform}; +use crate::core::raise::OnFault; +use crate::core::raise::death::DeathKind; +use crate::core::testkit::capture::catch_death; use metal2vulkan::metal::PixelFormat; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; -use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; -use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::os::surface::Surface as _; -use reims_vgpu_core::platform::resource::{ - Buffer as _, GpuResource as _, Library as _, Texture as _, -}; -use reims_vgpu_core::platform::types::{MtlOrigin, MtlSize, NsRange}; -use reims_vgpu_core::platform::values::TextureDesc; -use reims_vgpu_core::platform::{Handle as _, Platform}; -use reims_vgpu_core::raise::OnFault; -use reims_vgpu_core::raise::death::DeathKind; -use reims_vgpu_core::testkit::capture::catch_death; use super::measure::host::set_value; use super::measure::{ @@ -299,17 +297,9 @@ fn reads_as_metals_do( let ours = crate::answer::relaxed(read); let ours_floats = measure::read_floats::(&d, &t, size); let keys = [format!("read: {what}"), format!("read into floats: {what}")]; - assert!( - reims_vgpu_core::metal_matches_bytes!(keys[0], &ours), - "{}", - keys[0] - ); + assert!(crate::metal_matches_bytes!(keys[0], &ours), "{}", keys[0]); let floats = float_bits(&ours_floats); - assert!( - reims_vgpu_core::metal_matches_raw!(keys[1], floats), - "{}", - keys[1] - ); + assert!(crate::metal_matches_raw!(keys[1], floats), "{}", keys[1]); } /// A texture of each format of the family over plane 0 of a surface of each two-plane OSType @@ -464,29 +454,17 @@ fn sample_as_metals_do(format: u64, s: &OsSurface, size: (u64, u64), what: &str) ] }; assert!( - reims_vgpu_core::metal_matches_bytes!(keys[0], &ours_read), + crate::metal_matches_bytes!(keys[0], &ours_read), "{}", keys[0] ); let floats = float_bits(&ours_floats); - assert!( - reims_vgpu_core::metal_matches_raw!(keys[1], floats), - "{}", - keys[1] - ); + assert!(crate::metal_matches_raw!(keys[1], floats), "{}", keys[1]); for (case, (ours, ours_floats)) in cases.iter().zip(&ours_sampled) { let keys = probe_keys(case); - assert!( - reims_vgpu_core::metal_matches_bytes!(keys[0], ours), - "{}", - keys[0] - ); + assert!(crate::metal_matches_bytes!(keys[0], ours), "{}", keys[0]); let floats = float_bits(ours_floats); - assert!( - reims_vgpu_core::metal_matches_raw!(keys[1], floats), - "{}", - keys[1] - ); + assert!(crate::metal_matches_raw!(keys[1], floats), "{}", keys[1]); } } @@ -561,16 +539,8 @@ fn samples_in_fragments_as_metals_do(format: u64, s: &OsSurface, size: (u64, u64 }; for (case, ours) in cases.iter().zip(&ours) { let keys = keys(case); - assert!( - reims_vgpu_core::metal_matches_bytes!(keys[0], &ours.0), - "{}", - keys[0] - ); - assert!( - reims_vgpu_core::metal_matches_bytes!(keys[1], &ours.1), - "{}", - keys[1] - ); + assert!(crate::metal_matches_bytes!(keys[0], &ours.0), "{}", keys[0]); + assert!(crate::metal_matches_bytes!(keys[1], &ours.1), "{}", keys[1]); } } @@ -690,7 +660,7 @@ fn views_in_srgb_twins_read_as_metals() { assert_eq!(view.usage(), 1, "the view's usage: {what}"); let key = format!("the view: {what}"); let floats = float_bits(&viewed); - assert!(reims_vgpu_core::metal_matches_raw!(key, floats), "{key}"); + assert!(crate::metal_matches_raw!(key, floats), "{key}"); } } } @@ -711,7 +681,7 @@ fn views_in_srgb_twins_read_as_metals() { /// chroma #[test] fn own_format_views_are_metals() { - use reims_vgpu_core::platform::types::Swizzle; + use crate::core::platform::types::Swizzle; const BGRA: Swizzle = Swizzle { red: 4, green: 3, @@ -782,12 +752,12 @@ fn own_format_views_are_metals() { let key = format!("{format} {swizzle:?}"); let array_key = format!("the 2D array view's type and usage: {format} {swizzle:?}"); assert!( - reims_vgpu_core::metal_matches_raw!(key, ours), + crate::metal_matches_raw!(key, ours), "{key}: {:?}", (ours.0, ours.1) ); let array = view::(&t, format, (3, swizzle)).unwrap(); - reims_vgpu_core::metal_check!(array_key, (array.texture_type(), array.usage())); + crate::metal_check!(array_key, (array.texture_type(), array.usage())); let filtered = ours_on(&e, format, &s, size); let filtered = view::(&filtered, format, (3, swizzle)).unwrap(); for sample in [None, Some((0, 0)), Some((1, 0)), Some((0, 1)), Some((0, 2))] { @@ -797,7 +767,7 @@ fn own_format_views_are_metals() { }; let ours = arrayed::(on, subject, size, sample); let what = format!("{format} {swizzle:?} {sample:?}"); - if !reims_vgpu_core::metal_matches_raw!(what, ours) { + if !crate::metal_matches_raw!(what, ours) { differ.push(format!("{what}: the texels differ from Metal's")); } } @@ -877,7 +847,7 @@ fn samples_under_every_mode_as_metals(format: u64, ostypes: [&[u8; 4]; 2]) { border {border}", String::from_utf8_lossy(ostype) ); - reims_vgpu_core::metal_check_raw!(key, float_bits(&ours)); + crate::metal_check_raw!(key, float_bits(&ours)); } } } @@ -974,7 +944,7 @@ fn the_default_filter_samples_within_its_bound_of_metals() { let keys = [format!("{format}: halves"), format!("{format}: floats")]; let ours_bytes = [halves.clone(), float_bytes(&floats)]; let [metal_halves, metal_floats] = - [0, 1].map(|i| reims_vgpu_core::metal_near!(&keys[i], &ours_bytes[i])); + [0, 1].map(|i| crate::metal_near!(&keys[i], &ours_bytes[i])); let metal_floats: Vec = (metal_floats.chunks(4)) .map(|b| f32::from_le_bytes(b.try_into().unwrap())) .collect(); @@ -1047,7 +1017,7 @@ fn the_default_filter_samples_within_its_bound_of_metals() { ignore = "MoltenVK: the runtime records native-half-conversion, a death in strict mode; Mac-only test, off everywhere; ledger: MoltenVK strict deaths" )] fn the_guests_id_is_metals() { - use reims_vgpu_core::platform::event::SharedEvent as _; + use crate::core::platform::event::SharedEvent as _; fn ids>( d: &P::Device, descriptor: impl Fn(&TextureDesc) -> P::TextureDescriptor, @@ -1109,7 +1079,7 @@ fn the_guests_id_is_metals() { (ours[0] + 1, ours[1], ours[1]), "{ours:?}" ); - reims_vgpu_core::metal_check!("ids", ours); + crate::metal_check!("ids", ours); let d = dev(); let t = self::ours(505, &s, size); let kind = metal2vulkan_runtime::Degradation::HalfTexelConversion; @@ -1141,7 +1111,7 @@ fn usage_bits_metal_takes_are_answered_as_metals() { /// A command buffer of `d`'s committed in flight, waiting for its event's value 1, with a /// compute encoder before it that reads `t` and names no other texture, and the event. fn in_flight(d: &P::Device, t: &P::Texture) -> (P::CommandBuffer, P::SharedEvent) { - use reims_vgpu_core::platform::event::EventRef; + use crate::core::platform::event::EventRef; let library = d.new_library(PROBE).unwrap().unwrap().unwrap(); let f = library .new_function(OnFault::Die, "read_texels") @@ -1188,7 +1158,7 @@ fn in_flight(d: &P::Device, t: &P::Texture) -> (P::CommandBuffer, P /// `read_held` of an argument buffer holding `t`'s ID, made resident for reading. fn held(d: &P::Device, t: &P::Texture, (width, height): (u64, u64)) -> Vec { - use reims_vgpu_core::platform::blit::ResourceRef; + use crate::core::platform::blit::ResourceRef; let library = d.new_library(PROBE).unwrap().unwrap().unwrap(); let f = library .new_function(OnFault::Die, "read_held") @@ -1337,7 +1307,7 @@ fn sampling_a_mapped_texture_where_the_runtime_cannot_map_it_dies() { None, Some(&bytes), ); - reims_vgpu_core::metal_check_bytes!("clamped", &clamped); + crate::metal_check_bytes!("clamped", &clamped); } /// A texture of the family samples through a constexpr sampler as Metal's does, bit for bit, @@ -1407,7 +1377,7 @@ fn constexpr_samplers_sample_as_metals() { ); if in_place || !kernel.ends_with("_linear") { let ours = read_ours(); - if !reims_vgpu_core::metal_matches_raw!(&what, ours) { + if !crate::metal_matches_raw!(&what, ours) { differ.push(format!("{what}: not Metal's bits")); } continue; @@ -1428,7 +1398,7 @@ fn constexpr_samplers_sample_as_metals() { .collect() }; let ours_bytes = le(&ours); - let theirs: Vec = (reims_vgpu_core::metal_near!(&what, &ours_bytes).chunks(4)) + let theirs: Vec = (crate::metal_near!(&what, &ours_bytes).chunks(4)) .map(|b| u32::from_le_bytes(b.try_into().unwrap())) .collect(); let (ours, theirs) = (ours.as_flattened(), &theirs[..]); @@ -1683,7 +1653,7 @@ fn samples_see_the_writes_before_them() { write, ); assert!(ours != before, "{format} {write:?}: the write shows"); - reims_vgpu_core::metal_check_bytes!(format!("{format} {write:?}"), &ours); + crate::metal_check_bytes!(format!("{format} {write:?}"), &ours); } } } @@ -1791,7 +1761,7 @@ fn through>( /// a barrier or in a later encoder, as in a later one, and so does this platform's #[test] fn a_write_through_a_buffer_on_the_surface_shows_in_the_same_command_buffer() { - use reims_vgpu_core::platform::os::vm::HostVm as _; + use crate::core::platform::os::vm::HostVm as _; let size = (32, 16); let read = |p: &dyn Fn(&OsSurface) -> Vec| { let (s, pages, length) = surface_420_over(b"x420", size); @@ -1817,7 +1787,7 @@ fn a_write_through_a_buffer_on_the_surface_shows_in_the_same_command_buffer() { }); assert!(ours.iter().all(|o| *o != unwritten), "the write shows"); assert!(ours.iter().all(|o| *o == ours[2])); - reims_vgpu_core::metal_check_raw!("reads", ours); + crate::metal_check_raw!("reads", ours); } /// A texture of 505 made while a compute encoder is open is read by the encoder's next @@ -1889,7 +1859,7 @@ fn a_texture_made_in_an_encoder_reads_as_metals() { ours.iter().any(|&b| b != 0), "the texture reads its surface" ); - reims_vgpu_core::metal_check_bytes!("read", &ours); + crate::metal_check_bytes!("read", &ours); } /// What a test does with a texture of the family ([`written`]). @@ -1987,11 +1957,11 @@ fn written_at>( (s, other): (&OsSurface, &OsSurface), size: (u64, u64), ) -> [Vec; 3] { - use reims_vgpu_core::platform::HostRange; - use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; - use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; - use reims_vgpu_core::platform::types::{ClearColor, MtlRegion}; - use reims_vgpu_core::platform::values::ColorAttachmentSet; + use crate::core::platform::HostRange; + use crate::core::platform::descriptor::RenderPassDescriptor as _; + use crate::core::platform::render::{RenderCmd, RenderEncoder as _}; + use crate::core::platform::types::{ClearColor, MtlRegion}; + use crate::core::platform::values::ColorAttachmentSet; let mut desc = measure::desc(format, size); desc.usage = match op { Op::Clear @@ -2091,7 +2061,7 @@ fn written_at>( | Op::DontCareStore | Op::Masked | Op::Blended => { - use reims_vgpu_core::platform::values::RenderPipelineDesc; + use crate::core::platform::values::RenderPipelineDesc; use crate::gpu::device::tests::render_value; let pass = p.render_pass_descriptor(); @@ -2195,7 +2165,7 @@ fn written_at>( }); } Op::Fragment => { - use reims_vgpu_core::platform::values::RenderPipelineDesc; + use crate::core::platform::values::RenderPipelineDesc; let library = d.new_library(PROBE).unwrap().unwrap().unwrap(); let function = |name| library.new_function(OnFault::Die, name).unwrap().unwrap(); let (vertex, fragment) = (function("cover_vertex"), function("write_texels_fragment")); @@ -2280,7 +2250,7 @@ fn cpu_writes_and_buffer_blits_of_family_textures_are_metals() { let ours = noisy_pair(format, size, 3); let ours = written(&platform(), &dev(), op, format, (&ours.0, &ours.1), size); let case = format!("{format} {op:?}"); - reims_vgpu_core::metal_check_raw!(&case, ours); + crate::metal_check_raw!(&case, ours); } } } @@ -2370,8 +2340,8 @@ fn passes_are_metals(formats: &[u64]) { format!("{case}: bytes of the surface"), format!("{case}: the other surface and the buffer"), ]; - reims_vgpu_core::metal_check_bytes!(&keys[0], &ours[0]); - reims_vgpu_core::metal_check_raw!(&keys[1], &ours[1..]); + crate::metal_check_bytes!(&keys[0], &ours[0]); + crate::metal_check_raw!(&keys[1], &ours[1..]); } } } @@ -2454,10 +2424,10 @@ fn loaded_masked_and_blended_passes_are_metals() { format!("{case}: the surface"), format!("{case}: the other surface or the buffer"), ]; - if !reims_vgpu_core::metal_matches_raw!(&keys[1], &ours[1..]) { + if !crate::metal_matches_raw!(&keys[1], &ours[1..]) { differ.push(format!("{case}: the other surface or the buffer")); } - let theirs = reims_vgpu_core::metal_near!(&keys[0], &ours[0]); + let theirs = crate::metal_near!(&keys[0], &ours[0]); let within = u32::from(op == Op::Blended); let pairs = codes(&ours[0]).into_iter().zip(codes(&theirs)); let off = pairs @@ -2489,7 +2459,7 @@ fn packed_textures_copy_nothing_and_their_blits_die() { let before = bytes_of(&s); let ours = written(&platform(), &dev(), Op::Replace, format, (&s, &other), size); assert!(ours[0] == before, "{format}"); - reims_vgpu_core::metal_check_raw!(format!("{format}"), ours); + crate::metal_check_raw!(format!("{format}"), ours); for op in [Op::ToBuffer, Op::FromBuffer] { *crate::answer::LAST_LINE.lock() = None; let site = catch_death(|| written(&platform(), &dev(), op, format, (&s, &other), size)) @@ -2557,7 +2527,7 @@ fn kernel_writes_metal_drops_are_dropped_as_metals() { let before = bytes_of(&s); let ours = written(&platform(), &dev(), Op::Kernel, format, (&s, &other), size); assert!(ours[0] == before, "{format}"); - reims_vgpu_core::metal_check_raw!(format!("{format}"), ours); + crate::metal_check_raw!(format!("{format}"), ours); } } @@ -2579,7 +2549,7 @@ fn fragment_writes_of_444_textures_are_metals() { size, ); assert!(ours[0] != before, "{format}'s planes"); - reims_vgpu_core::metal_check_raw!(format!("{format}"), ours); + crate::metal_check_raw!(format!("{format}"), ours); } } @@ -2599,7 +2569,7 @@ fn writes_of_444_textures_are_metals() { let before = bytes_of(&s); let ours = written(&platform(), &dev(), Op::Kernel, format, (&s, &other), size); assert!(ours[0] != before, "{format}'s planes"); - reims_vgpu_core::metal_check_raw!(format!("{format}"), ours); + crate::metal_check_raw!(format!("{format}"), ours); } } @@ -2685,6 +2655,6 @@ fn every_luma_code_of_505_reads_as_metals() { let t = ours(505, &s, size); let ours = float_bits(&measure::read_floats::(&d, &t, size)); let key = String::from_utf8_lossy(ostype).into_owned(); - reims_vgpu_core::metal_check_raw!(&key, ours); + crate::metal_check_raw!(&key, ours); } } diff --git a/crates/reims-vgpu-vulkan/src/gpu/ycbcr/tests/metal_tests.rs b/crates/reims-vgpu-vulkan/src/gpu/ycbcr/tests/metal_tests.rs index 20c145011..6e631f95b 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/ycbcr/tests/metal_tests.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/ycbcr/tests/metal_tests.rs @@ -1,12 +1,12 @@ //! The tests of `ycbcr` that compare with Metal on this host: macOS only. -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::descriptor::TextureDescriptor as _; -use reims_vgpu_core::platform::device::GpuDevice; -use reims_vgpu_core::platform::resource::{Buffer as _, Heap as _, Texture as _}; -use reims_vgpu_core::platform::types::{SizeAndAlign, Swizzle}; -use reims_vgpu_core::platform::values::{BufferDesc, HeapDesc, OptionSet, TextureDesc}; -use reims_vgpu_core::raise::OnFault; +use crate::core::platform::Platform; +use crate::core::platform::descriptor::TextureDescriptor as _; +use crate::core::platform::device::GpuDevice; +use crate::core::platform::resource::{Buffer as _, Heap as _, Texture as _}; +use crate::core::platform::types::{SizeAndAlign, Swizzle}; +use crate::core::platform::values::{BufferDesc, HeapDesc, OptionSet, TextureDesc}; +use crate::core::raise::OnFault; use super::*; use crate::os::tests::bgra_surface; @@ -397,10 +397,10 @@ fn one_plane_copies( bytes: u64, pattern: &[u8], ) -> [Vec; 2] { - use reims_vgpu_core::platform::HostRange; - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::types::{MtlOrigin, MtlRegion, MtlSize}; + use crate::core::platform::HostRange; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::types::{MtlOrigin, MtlRegion, MtlSize}; let (row, image) = (16 * bytes, 16 * 16 * bytes); let size = MtlSize::new(16, 16, 1); @@ -486,9 +486,9 @@ fn one_plane_copies( /// ([`one_plane_reads_die_at_the_dispatch`]) #[test] fn one_plane_textures_are_made_and_copied_as_metals() { - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; - use reims_vgpu_core::platform::values::ColorAttachmentSet; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::descriptor::RenderPassDescriptor as _; + use crate::core::platform::values::ColorAttachmentSet; let d = dev(); let p = platform(); for (format, bytes) in one_plane_copies_only() { @@ -553,11 +553,11 @@ fn one_plane_textures_are_made_and_copied_as_metals() { #[test] fn one_plane_reads_die_at_the_dispatch() { fn read(d: &P::Device, desc: &P::TextureDescriptor, bytes: u64) -> Vec { - use reims_vgpu_core::platform::HostRange; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; - use reims_vgpu_core::platform::resource::Library as _; - use reims_vgpu_core::platform::types::{MtlOrigin, MtlRegion, MtlSize, NsRange}; + use crate::core::platform::HostRange; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; + use crate::core::platform::resource::Library as _; + use crate::core::platform::types::{MtlOrigin, MtlRegion, MtlSize, NsRange}; let t = d.new_texture(OnFault::Return, desc).unwrap().unwrap(); let n = usize::try_from(16 * 16 * bytes).unwrap(); let pattern: Vec = (0..n) diff --git a/crates/reims-vgpu-vulkan/src/lib.rs b/crates/reims-vgpu-vulkan/src/lib.rs index 4c63d129c..63bfd4114 100644 --- a/crates/reims-vgpu-vulkan/src/lib.rs +++ b/crates/reims-vgpu-vulkan/src/lib.rs @@ -24,6 +24,7 @@ pub mod answer; pub mod api; pub(crate) mod awake; +pub mod core; pub mod gpu; #[cfg(target_os = "linux")] pub mod host_gpus; diff --git a/crates/reims-vgpu-vulkan/src/os.rs b/crates/reims-vgpu-vulkan/src/os.rs index 834bd6bda..eabf5c5e2 100644 --- a/crates/reims-vgpu-vulkan/src/os.rs +++ b/crates/reims-vgpu-vulkan/src/os.rs @@ -99,7 +99,7 @@ pub struct GuestRamFile { #[cfg(test)] pub(crate) mod tests { - use reims_vgpu_core::platform::os::vm::HostVm as _; + use crate::core::platform::os::vm::HostVm as _; // The surface tests' helpers, which the crate's tests name here. pub(crate) use super::surface::tests::*; @@ -119,8 +119,8 @@ pub(crate) mod tests { /// start changes nothing, a remap's refused as an invalid argument #[test] fn the_vm_spans_its_calls_as_mach_does() { - use reims_vgpu_core::num::ToUsize as _; - use reims_vgpu_core::platform::os::vm::{HostAddr, KernReturn, VmProt}; + use crate::core::num::ToUsize as _; + use crate::core::platform::os::vm::{HostAddr, KernReturn, VmProt}; let vm = OsVm::new(); let page = vm.page_size(); diff --git a/crates/reims-vgpu-vulkan/src/os/linux/budget.rs b/crates/reims-vgpu-vulkan/src/os/linux/budget.rs index 5fca15788..a92c37b64 100644 --- a/crates/reims-vgpu-vulkan/src/os/linux/budget.rs +++ b/crates/reims-vgpu-vulkan/src/os/linux/budget.rs @@ -334,8 +334,8 @@ fn short(what: &str, kept: u64, level: log::Level) { #[cfg(test)] mod tests { - use reims_vgpu_core::num::ToU64 as _; - use reims_vgpu_core::platform::os::vm::{HostAddr, HostVm as _, VmProt}; + use crate::core::num::ToU64 as _; + use crate::core::platform::os::vm::{HostAddr, HostVm as _, VmProt}; use super::super::{LinuxVm, import, vm}; use super::*; @@ -361,8 +361,8 @@ mod tests { /// Whether `f` ends the process at the budget's death (`mmap`). fn dies_at_the_budget(f: impl FnOnce() -> R) -> bool { - use reims_vgpu_core::raise::death::DeathKind; - use reims_vgpu_core::testkit::capture::catch_death; + use crate::core::raise::death::DeathKind; + use crate::core::testkit::capture::catch_death; catch_death(f).is_err_and(|site| (site.kind, site.file) == (DeathKind::Abort, "mmap")) } @@ -421,7 +421,7 @@ mod tests { /// answer when memory runs out #[test] fn past_the_budget_answers_as_memory_runs_out_by_default() { - use reims_vgpu_core::platform::os::vm::KernReturn; + use crate::core::platform::os::vm::KernReturn; let v = LinuxVm::new(); let src = vm::allocate_aliasable(64 * PAGE).unwrap(); let at = v.allocate_anywhere(64 * PAGE).unwrap(); diff --git a/crates/reims-vgpu-vulkan/src/os/linux/clock.rs b/crates/reims-vgpu-vulkan/src/os/linux/clock.rs index 062247d63..36d7d636b 100644 --- a/crates/reims-vgpu-vulkan/src/os/linux/clock.rs +++ b/crates/reims-vgpu-vulkan/src/os/linux/clock.rs @@ -9,8 +9,8 @@ use std::time::Duration; -use reims_vgpu_core::platform::os::{Clock, Deadline, MonoTime, TimedOut, WallTime}; -use reims_vgpu_core::sync::{Condvar, MutexGuard}; +use crate::core::platform::os::{Clock, Deadline, MonoTime, TimedOut, WallTime}; +use crate::core::sync::{Condvar, MutexGuard}; /// `clock_gettime(clock)` in nanoseconds. fn nanos(clock: libc::clockid_t) -> u64 { @@ -93,7 +93,7 @@ impl Clock for LinuxClock { mod tests { use std::sync::Arc; - use reims_vgpu_core::sync::Mutex; + use crate::core::sync::Mutex; use super::*; diff --git a/crates/reims-vgpu-vulkan/src/os/linux/device_lend.rs b/crates/reims-vgpu-vulkan/src/os/linux/device_lend.rs index a0818dcf1..78b44cb50 100644 --- a/crates/reims-vgpu-vulkan/src/os/linux/device_lend.rs +++ b/crates/reims-vgpu-vulkan/src/os/linux/device_lend.rs @@ -12,7 +12,7 @@ use std::os::fd::OwnedFd; use std::ptr::NonNull; -use reims_vgpu_core::num::ToU64 as _; +use crate::core::num::ToU64 as _; use super::dma_buf::{self, Refusal, Zeros}; use super::vm; @@ -140,10 +140,10 @@ fn pages_of( mod tests { use std::os::fd::AsRawFd as _; - use reims_vgpu_core::host::PhysicalMemoryRange; - use reims_vgpu_core::num::ToUsize as _; - use reims_vgpu_core::platform::os::surface::{IoSurfaces as _, Surface as _, SurfaceSpec}; - use reims_vgpu_core::platform::os::vm::HostVm as _; + use crate::core::host::PhysicalMemoryRange; + use crate::core::num::ToUsize as _; + use crate::core::platform::os::surface::{IoSurfaces as _, Surface as _, SurfaceSpec}; + use crate::core::platform::os::vm::HostVm as _; use super::super::surface::LinuxSurfaces; use super::super::vm::{LinuxVm, allocate_aliasable}; @@ -200,7 +200,7 @@ mod tests { fn free(at: u64, length: u64) { let vm = LinuxVm::new(); - let at = reims_vgpu_core::host::HostPtr::from_addr(at.to_usize()); + let at = crate::core::host::HostPtr::from_addr(at.to_usize()); assert!(vm.deallocate(at, length).is_success()); } diff --git a/crates/reims-vgpu-vulkan/src/os/linux/dma_buf.rs b/crates/reims-vgpu-vulkan/src/os/linux/dma_buf.rs index 141fc15ad..393566473 100644 --- a/crates/reims-vgpu-vulkan/src/os/linux/dma_buf.rs +++ b/crates/reims-vgpu-vulkan/src/os/linux/dma_buf.rs @@ -68,8 +68,8 @@ use std::io; use std::os::fd::{AsRawFd as _, FromRawFd as _, OwnedFd}; use std::sync::{Arc, OnceLock}; +use crate::core::sync::Mutex; use metal2vulkan_runtime::DmaBufChunk; -use reims_vgpu_core::sync::Mutex; use super::files::{self, Backing}; use super::vm; @@ -556,8 +556,8 @@ fn create(device: &OwnedFd, runs: &[Run>]) -> Result Option>> { mod tests { use std::os::fd::AsRawFd as _; - use reims_vgpu_core::host::HostPtr; - use reims_vgpu_core::num::{ToU64 as _, ToUsize as _}; - use reims_vgpu_core::platform::HostRange; - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::device::GpuDevice as _; - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::platform::types::NsRange; - use reims_vgpu_core::raise::OnFault; + use crate::core::host::HostPtr; + use crate::core::num::{ToU64 as _, ToUsize as _}; + use crate::core::platform::HostRange; + use crate::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use crate::core::platform::device::GpuDevice as _; + use crate::core::platform::resource::Buffer as _; + use crate::core::platform::types::NsRange; + use crate::core::raise::OnFault; use super::super::import::imports_need_files; use super::super::vm::memfd; @@ -545,9 +545,9 @@ mod tests { #[test] #[ignore = "a measurement: run alone, holding the GPU"] fn slab_heap_costs() { - use reims_vgpu_core::platform::os::{Clock as _, MonoTime}; - use reims_vgpu_core::platform::resource::Heap as _; - use reims_vgpu_core::platform::values::{HeapDesc, OptionSet}; + use crate::core::platform::os::{Clock as _, MonoTime}; + use crate::core::platform::resource::Heap as _; + use crate::core::platform::values::{HeapDesc, OptionSet}; let clock = crate::os::OsClock::new(); let now = || clock.now_mono(); let since = |t: MonoTime| clock.now_mono().saturating_duration_since(t); @@ -802,9 +802,9 @@ mod tests { #[test] #[ignore = "a measurement: run alone, holding the GPU"] fn slab_nocopy_costs() { - use reims_vgpu_core::platform::os::{Clock as _, MonoTime}; - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::platform::values::{BufferDesc, OptionSet}; + use crate::core::platform::os::{Clock as _, MonoTime}; + use crate::core::platform::resource::Buffer as _; + use crate::core::platform::values::{BufferDesc, OptionSet}; let clock = crate::os::OsClock::new(); let now = || clock.now_mono(); let since = |t: MonoTime| clock.now_mono().saturating_duration_since(t); diff --git a/crates/reims-vgpu-vulkan/src/os/linux/import.rs b/crates/reims-vgpu-vulkan/src/os/linux/import.rs index 3542e0c28..1dbfe1721 100644 --- a/crates/reims-vgpu-vulkan/src/os/linux/import.rs +++ b/crates/reims-vgpu-vulkan/src/os/linux/import.rs @@ -102,10 +102,10 @@ use std::ptr::NonNull; use std::sync::Arc; use std::sync::atomic::{AtomicU64, Ordering}; +use crate::core::num::{ToU64, ToUsize}; +use crate::core::platform::os::vm::{HostAddr, KernReturn}; +use crate::core::sync::Mutex; use metal2vulkan_runtime as rt; -use reims_vgpu_core::num::{ToU64, ToUsize}; -use reims_vgpu_core::platform::os::vm::{HostAddr, KernReturn}; -use reims_vgpu_core::sync::Mutex; use super::budget; use super::files; @@ -268,7 +268,7 @@ impl Refused { /// Counts the refusal of `first..end`, which would have taken `adding` mappings: the count /// and the bytes so far, where the count is one to log. fn count(&self, first: u64, end: u64, adding: u64) -> Option<(u64, u64)> { - reims_vgpu_core::trace::event(self.record, &[first, end - first, adding]); + crate::core::trace::event(self.record, &[first, end - first, adding]); let bytes = self.bytes.fetch_add(end - first, Ordering::Relaxed) + (end - first); let count = self.count.fetch_add(1, Ordering::Relaxed) + 1; count.is_power_of_two().then_some((count, bytes)) @@ -351,7 +351,7 @@ fn addr_of(at: NonNull) -> u64 { /// 2026-10-27, `super::vm`'s module docs, "Imports of views"). Nothing is learned where the view is /// not mapped through dma-bufs (udmabuf not the process's): no import then needs it. pub(crate) fn learn_view_imports(device: &rt::Device) { - use reims_vgpu_core::platform::os::vm::HostVm as _; + use crate::core::platform::os::vm::HostVm as _; if IMPORTS_NEED_FILES.load(Ordering::Relaxed) { return; } @@ -791,7 +791,7 @@ fn address(at: u64) -> Option> { #[cfg(test)] mod tests { - use reims_vgpu_core::platform::os::vm::{HostVm as _, VmProt}; + use crate::core::platform::os::vm::{HostVm as _, VmProt}; use super::super::LinuxVm; use super::*; @@ -903,7 +903,7 @@ mod tests { assert!(view.vouched(), "every page writable"); drop(view); let second = address(first + PAGE).unwrap(); - let second = reims_vgpu_core::host::HostPtr::from_ptr(second.as_ptr()); + let second = crate::core::host::HostPtr::from_ptr(second.as_ptr()); assert!(vm.protect_max(second, PAGE, VmProt::READ).is_ok()); let view = import_view(p, 2 * PAGE, true); assert!(view.twinned(), "a twin of the read-only page"); @@ -1005,7 +1005,7 @@ mod tests { /// them, as its zeros map the block of zeros #[test] fn a_read_only_alias_with_zeros_past_its_pages_is_twinned() { - use reims_vgpu_core::platform::types::ResourceAddressRange; + use crate::core::platform::types::ResourceAddressRange; let vm = LinuxVm::new(); let guest = vm::allocate_aliasable(PAGE).unwrap(); @@ -1038,9 +1038,9 @@ mod tests { /// answers nil there by default, counted, as when memory runs out, and dies in strict mode #[test] fn a_gather_of_pages_without_a_file_is_the_hosts_refusal() { - use reims_vgpu_core::platform::types::ResourceAddressRange; - use reims_vgpu_core::raise::death::DeathKind; - use reims_vgpu_core::testkit::capture::catch_death; + use crate::core::platform::types::ResourceAddressRange; + use crate::core::raise::death::DeathKind; + use crate::core::testkit::capture::catch_death; let vm = LinuxVm::new(); let at = vm.allocate_anywhere(PAGE).unwrap(); @@ -1081,8 +1081,8 @@ mod tests { /// which nextest runs this test alone in. #[test] fn past_the_headroom_imports_are_refused_at_the_gate() { - use reims_vgpu_core::raise::death::DeathKind; - use reims_vgpu_core::testkit::capture::catch_death; + use crate::core::raise::death::DeathKind; + use crate::core::testkit::capture::catch_death; fn dies(f: impl FnOnce() -> R) -> bool { catch_death(f).is_err_and(|site| (site.kind, site.file) == (DeathKind::Abort, "mmap")) } diff --git a/crates/reims-vgpu-vulkan/src/os/linux/surface.rs b/crates/reims-vgpu-vulkan/src/os/linux/surface.rs index 1e8bb7b5c..e3877a94f 100644 --- a/crates/reims-vgpu-vulkan/src/os/linux/surface.rs +++ b/crates/reims-vgpu-vulkan/src/os/linux/surface.rs @@ -62,14 +62,14 @@ use std::mem::ManuallyDrop; use std::ptr::NonNull; use std::sync::Arc; -use reims_vgpu_core::host::{HostPtr, PhysicalMemoryRange}; -use reims_vgpu_core::num::{ToU64, ToUsize}; -use reims_vgpu_core::platform::os::surface::{ +use crate::core::host::{HostPtr, PhysicalMemoryRange}; +use crate::core::num::{ToU64, ToUsize}; +use crate::core::platform::os::surface::{ BackingSurfaceSpec, IoSurfaces, Surface, SurfacePlaneSpec, SurfaceSpec, }; -use reims_vgpu_core::platform::os::vm::{HostVm as _, KernReturn, VmProt}; -use reims_vgpu_core::platform::{Handle, ObjId}; -use reims_vgpu_core::sync::Mutex; +use crate::core::platform::os::vm::{HostVm as _, KernReturn, VmProt}; +use crate::core::platform::{Handle, ObjId}; +use crate::core::sync::Mutex; use super::vm::{LinuxVm, OwnMemory, allocate_aliasable}; use crate::gpu::backing::Alias; @@ -661,7 +661,7 @@ impl IoSurfaces for LinuxSurfaces { #[cfg(test)] mod tests { - use reims_vgpu_core::platform::os::surface::BackingPlaneSpec; + use crate::core::platform::os::surface::BackingPlaneSpec; use super::super::vm::tests::mapped; use super::*; @@ -1041,7 +1041,7 @@ mod tests { /// the range is made at once #[test] fn a_single_range_surfaces_hold_is_its_range() { - use reims_vgpu_core::platform::os::vm::HostVm as _; + use crate::core::platform::os::vm::HostVm as _; let page = page_size(); let (at, ranges) = guest_pages(4); @@ -1084,7 +1084,7 @@ mod tests { #[test] fn a_surface_lends_its_view_as_its_buffers_alias() { use super::super::vm::tests::writable; - use reims_vgpu_core::platform::os::vm::HostAddr; + use crate::core::platform::os::vm::HostAddr; let page = page_size(); let (at, ranges) = guest_pages(3); diff --git a/crates/reims-vgpu-vulkan/src/os/linux/threads.rs b/crates/reims-vgpu-vulkan/src/os/linux/threads.rs index ccffc262a..983a99226 100644 --- a/crates/reims-vgpu-vulkan/src/os/linux/threads.rs +++ b/crates/reims-vgpu-vulkan/src/os/linux/threads.rs @@ -11,8 +11,8 @@ use std::sync::Arc; -use reims_vgpu_core::platform::os::{Threads, TimerClock}; -use reims_vgpu_core::raise::death::{DeathId, DeathKind, fatal}; +use crate::core::platform::os::{Threads, TimerClock}; +use crate::core::raise::death::{DeathId, DeathKind, fatal}; use super::clock::LinuxClock; @@ -74,7 +74,7 @@ impl Threads for LinuxThreads { fn spawn_worker(&self, label: &'static str, body: Box) { spawn_thread( label, - reims_vgpu_core::rt::queue::WORKER_STACK, + crate::core::rt::queue::WORKER_STACK, Box::new(move || { super::hints::drop_inherited_hints(); body(); diff --git a/crates/reims-vgpu-vulkan/src/os/linux/vm.rs b/crates/reims-vgpu-vulkan/src/os/linux/vm.rs index dff2473d6..81cd926c7 100644 --- a/crates/reims-vgpu-vulkan/src/os/linux/vm.rs +++ b/crates/reims-vgpu-vulkan/src/os/linux/vm.rs @@ -108,9 +108,9 @@ use std::os::fd::{AsRawFd as _, FromRawFd as _, OwnedFd}; use std::sync::Arc; -use reims_vgpu_core::num::{ToU64, ToUsize}; -use reims_vgpu_core::platform::os::vm::{HostAddr, HostVm, KernReturn, VmProt}; -use reims_vgpu_core::sync::{ReadGuard, WriterPrefRwLock}; +use crate::core::num::{ToU64, ToUsize}; +use crate::core::platform::os::vm::{HostAddr, HostVm, KernReturn, VmProt}; +use crate::core::sync::{ReadGuard, WriterPrefRwLock}; use super::budget; use super::files::{self, Backing, Through}; @@ -910,7 +910,7 @@ pub(crate) fn unfold(first: u64, end: u64) -> Result<(), u64> { /// [`unfold`], once: what a refused map leaves through dma-bufs a second try maps. fn unfold_once(first: u64, end: u64) -> Result<(), u64> { - static UNFOLDING: reims_vgpu_core::sync::Mutex<()> = reims_vgpu_core::sync::Mutex::new(()); + static UNFOLDING: crate::core::sync::Mutex<()> = crate::core::sync::Mutex::new(()); let _one = UNFOLDING.lock(); let mut held = views(); let mut pieces = files::through_pieces(first, end); @@ -1226,7 +1226,7 @@ impl HostVm for LinuxVm { #[cfg(test)] pub(crate) mod tests { - use reims_vgpu_core::raise::death::DeathKind; + use crate::core::raise::death::DeathKind; use super::*; @@ -1465,11 +1465,11 @@ pub(crate) mod tests { /// a call that can try again, it ends the process in strict mode #[test] fn a_map_refused_at_the_limit_folds_the_views_and_tries_again() { - use reims_vgpu_core::testkit::capture::catch_death; + use crate::core::testkit::capture::catch_death; if !udmabuf_opens() { return; } - let dies = |site: Result| { + let dies = |site: Result| { site.is_err_and(|site| (site.kind, site.file) == (DeathKind::Abort, "mmap")) }; let at_limit = |on: bool| TEST_AT_LIMIT.with(|t| t.set(on)); @@ -1526,7 +1526,7 @@ pub(crate) mod tests { /// counted; in strict mode the process ends at the call that made no file #[test] fn no_file_answers_as_memory_runs_out() { - use reims_vgpu_core::testkit::capture::catch_death; + use crate::core::testkit::capture::catch_death; let p = page(); TEST_NO_FILE.with(|t| t.set(true)); let site = catch_death(|| allocate_aliasable(p)); @@ -1895,8 +1895,8 @@ pub(crate) mod tests { /// (`crate::gpu::backing::gather`, `super::dma_buf`) #[test] fn an_alias_with_zeros_past_its_pages_has_a_file_behind_every_byte() { + use crate::core::platform::types::ResourceAddressRange; use crate::gpu::backing::{REPLACE, gather}; - use reims_vgpu_core::platform::types::ResourceAddressRange; let p = page(); for read_only in [false, true] { let guest = allocate_aliasable(p).unwrap(); diff --git a/crates/reims-vgpu-vulkan/src/os/macos.rs b/crates/reims-vgpu-vulkan/src/os/macos.rs index 2db343d3d..801104a1e 100644 --- a/crates/reims-vgpu-vulkan/src/os/macos.rs +++ b/crates/reims-vgpu-vulkan/src/os/macos.rs @@ -28,11 +28,9 @@ use objc2::runtime::{NSObjectProtocol as _, ProtocolObject, Sel}; use objc2::{msg_send, sel}; use objc2_metal::{MTLCreateSystemDefaultDevice, MTLDevice}; -use reims_vgpu_core::platform::Handle; -use reims_vgpu_core::platform::os::surface::{ - BackingSurfaceSpec, IoSurfaces, Surface, SurfaceSpec, -}; -use reims_vgpu_core::platform::os::vm::{HostAddr, HostVm as _, KernReturn}; +use crate::core::platform::Handle; +use crate::core::platform::os::surface::{BackingSurfaceSpec, IoSurfaces, Surface, SurfaceSpec}; +use crate::core::platform::os::vm::{HostAddr, HostVm as _, KernReturn}; use self::clock::MacClock; use self::iosurface::{MacSurface, MacSurfaces}; @@ -344,7 +342,7 @@ pub(crate) const PAGE: u64 = if cfg!(target_arch = "aarch64") { /// maximum protection lowered to read. #[cfg(test)] pub(crate) fn writable(at: HostAddr, len: u64) -> bool { - use reims_vgpu_core::platform::os::vm::VmProt; + use crate::core::platform::os::vm::VmProt; let vm = MacVm::new(); vm.protect_max(at, len, VmProt::READ | VmProt::WRITE) .is_ok() @@ -356,11 +354,8 @@ pub(crate) fn writable(at: HostAddr, len: u64) -> bool { #[cfg(test)] pub(crate) fn mapped(at: HostAddr) -> bool { let vm = MacVm::new(); - vm.protect_max( - at, - vm.page_size(), - reims_vgpu_core::platform::os::vm::VmProt(7), - ) != Err(KernReturn(1)) + vm.protect_max(at, vm.page_size(), crate::core::platform::os::vm::VmProt(7)) + != Err(KernReturn(1)) } // IOSurface's plane and value queries, which [`iosurface`]'s surface does not answer. @@ -563,8 +558,8 @@ struct ClientPages { prune_at: usize, } -static CLIENT_PAGES: reims_vgpu_core::sync::Mutex = - reims_vgpu_core::sync::Mutex::new(ClientPages { +static CLIENT_PAGES: crate::core::sync::Mutex = + crate::core::sync::Mutex::new(ClientPages { entries: BTreeMap::new(), prune_at: 64, }); @@ -666,7 +661,7 @@ impl IoSurfaces for VulkanSurfaces { #[cfg(test)] mod tests { - use reims_vgpu_core::num::ToU64; + use crate::core::num::ToU64; use super::*; use crate::os::tests::{bgra_surface, bgra_surface_over_at, free}; @@ -678,7 +673,7 @@ mod tests { /// memory and its bytes' are found there #[test] fn an_offset_surface_is_at_its_offset_into_its_pages() { - use reims_vgpu_core::platform::os::vm::HostVm as _; + use crate::core::platform::os::vm::HostVm as _; for offset in [0x40, 0x1000, 0x4000] { let (s, pages, length) = crate::gpu::ycbcr::measure::surface_420_over_at(b"x420", (32, 16), offset); @@ -740,7 +735,7 @@ mod tests { /// ID handed out again on the M3 Max (macOS 27.0.1), and 0 of 40 with 64 #[test] fn a_surface_taking_the_id_of_one_gone_takes_none_of_its_record() { - use reims_vgpu_core::platform::os::surface::{BackingPlaneSpec, BackingSurfaceSpec}; + use crate::core::platform::os::surface::{BackingPlaneSpec, BackingSurfaceSpec}; let backing = BackingSurfaceSpec { pixel_format: u32::from_be_bytes(*b"BGRA"), planes: vec![BackingPlaneSpec { diff --git a/crates/reims-vgpu-vulkan/src/os/macos/autorelease.rs b/crates/reims-vgpu-vulkan/src/os/macos/autorelease.rs index 4b8694774..1e55c8597 100644 --- a/crates/reims-vgpu-vulkan/src/os/macos/autorelease.rs +++ b/crates/reims-vgpu-vulkan/src/os/macos/autorelease.rs @@ -5,7 +5,7 @@ use std::ffi::c_void; -use reims_vgpu_core::platform::os::autorelease::{NativePool, install_native}; +use crate::core::platform::os::autorelease::{NativePool, install_native}; /// `objc_autoreleasePoolPush()`. fn push() -> *mut c_void { diff --git a/crates/reims-vgpu-vulkan/src/os/macos/clock.rs b/crates/reims-vgpu-vulkan/src/os/macos/clock.rs index 19177ac60..bf6c7aa86 100644 --- a/crates/reims-vgpu-vulkan/src/os/macos/clock.rs +++ b/crates/reims-vgpu-vulkan/src/os/macos/clock.rs @@ -13,8 +13,8 @@ use std::time::Duration; -use reims_vgpu_core::platform::os::{Clock, Deadline, MonoTime, TimedOut, WallTime}; -use reims_vgpu_core::sync::{Condvar, MutexGuard}; +use crate::core::platform::os::{Clock, Deadline, MonoTime, TimedOut, WallTime}; +use crate::core::sync::{Condvar, MutexGuard}; /// `clockid_t` of `CLOCK_MONOTONIC_RAW` (``): libc++'s `steady_clock` on Apple. const CLOCK_MONOTONIC_RAW: libc::clockid_t = 4; @@ -99,7 +99,7 @@ impl Clock for MacClock { mod tests { use super::*; - use reims_vgpu_core::sync::Mutex; + use crate::core::sync::Mutex; use std::sync::Arc; const MS: Duration = Duration::from_millis(1); diff --git a/crates/reims-vgpu-vulkan/src/os/macos/iosurface.rs b/crates/reims-vgpu-vulkan/src/os/macos/iosurface.rs index 2325c780a..16f80eebb 100644 --- a/crates/reims-vgpu-vulkan/src/os/macos/iosurface.rs +++ b/crates/reims-vgpu-vulkan/src/os/macos/iosurface.rs @@ -11,6 +11,13 @@ use std::ffi::c_void; use std::mem::ManuallyDrop; use std::ptr::NonNull; +use crate::core::host::{HostPtr, PhysicalMemoryRange}; +use crate::core::num::ToU64; +use crate::core::platform::os::surface::{ + BackingPlaneSpec, BackingSurfaceSpec, SurfacePlaneSpec, SurfaceSpec, +}; +use crate::core::platform::os::vm::KernReturn; +use crate::core::platform::{Handle, ObjId}; use objc2::AnyThread; use objc2::rc::Retained; use objc2::runtime::AnyObject; @@ -24,13 +31,6 @@ use objc2_io_surface::{ IOSurfacePropertyKeyPlaneInfo, IOSurfacePropertyKeyPlaneOffset, IOSurfacePropertyKeyPlaneWidth, IOSurfacePropertyKeyWidth, IOSurfaceRef, }; -use reims_vgpu_core::host::{HostPtr, PhysicalMemoryRange}; -use reims_vgpu_core::num::ToU64; -use reims_vgpu_core::platform::os::surface::{ - BackingPlaneSpec, BackingSurfaceSpec, SurfacePlaneSpec, SurfaceSpec, -}; -use reims_vgpu_core::platform::os::vm::KernReturn; -use reims_vgpu_core::platform::{Handle, ObjId}; use super::msg::{fatal_send, value}; @@ -170,7 +170,7 @@ impl Handle for MacSurface { } } -impl reims_vgpu_core::platform::os::surface::Surface for MacSurface { +impl crate::core::platform::os::surface::Surface for MacSurface { fn retain_count(&self) -> i64 { // SAFETY: a live CF object this value holds a reference to. let n = unsafe { CFGetRetainCount(self.ptr.as_ptr().cast_const().cast()) }; @@ -572,9 +572,9 @@ impl MacSurfaces { mod tests { use super::*; + use crate::core::platform::os::surface::{Surface, SurfaceComponentSpec}; + use crate::core::platform::os::vm::HostVm; use objc2::runtime::AnyObject; - use reims_vgpu_core::platform::os::surface::{Surface, SurfaceComponentSpec}; - use reims_vgpu_core::platform::os::vm::HostVm; const BGRA: u32 = u32::from_be_bytes(*b"BGRA"); diff --git a/crates/reims-vgpu-vulkan/src/os/macos/msg.rs b/crates/reims-vgpu-vulkan/src/os/macos/msg.rs index 860526161..ee6112d8c 100644 --- a/crates/reims-vgpu-vulkan/src/os/macos/msg.rs +++ b/crates/reims-vgpu-vulkan/src/os/macos/msg.rs @@ -19,10 +19,10 @@ use std::panic::AssertUnwindSafe; +use crate::core::raise::Raise; +use crate::core::raise::death::{DeathId, DeathKind}; use objc2::exception::{self, Exception}; use objc2_foundation::{NSException, NSString}; -use reims_vgpu_core::raise::Raise; -use reims_vgpu_core::raise::death::{DeathId, DeathKind}; /// An Objective-C exception raised inside a call, caught at the call before any Rust frame /// unwound. Its name and reason are diagnostics: they reach logs, never a decision. @@ -132,8 +132,8 @@ pub fn value(sel: &'static str, f: impl FnOnce() -> R) -> R { call: sel, }; match exception_detail(&name, &reason) { - Some(detail) => reims_vgpu_core::raise::death::fatal_with_detail(id, &detail), - None => reims_vgpu_core::raise::fatal(id), + Some(detail) => crate::core::raise::death::fatal_with_detail(id, &detail), + None => crate::core::raise::fatal(id), } } } @@ -147,10 +147,10 @@ pub fn string_text(s: &NSString) -> String { #[cfg(test)] mod tests { use super::*; + use crate::core::testkit::capture::catch_death; use objc2::rc::Retained; use objc2::runtime::NSObject; use objc2_foundation::{NSArray, NSString}; - use reims_vgpu_core::testkit::capture::catch_death; fn array() -> Retained> { NSArray::new() diff --git a/crates/reims-vgpu-vulkan/src/os/macos/threads.rs b/crates/reims-vgpu-vulkan/src/os/macos/threads.rs index f36b0cfb6..9f8f2f7e6 100644 --- a/crates/reims-vgpu-vulkan/src/os/macos/threads.rs +++ b/crates/reims-vgpu-vulkan/src/os/macos/threads.rs @@ -14,8 +14,8 @@ use std::ffi::{CString, c_void}; use std::mem::MaybeUninit; use std::sync::Arc; -use reims_vgpu_core::platform::os::{Threads, TimerClock}; -use reims_vgpu_core::raise::death::{DeathId, DeathKind, fatal}; +use crate::core::platform::os::{Threads, TimerClock}; +use crate::core::raise::death::{DeathId, DeathKind, fatal}; use super::clock::MacClock; @@ -100,7 +100,7 @@ impl Threads for MacThreads { /// A worker named after its queue, with a GCD worker's 512 KiB of stack. fn spawn_worker(&self, label: &'static str, body: Box) { - spawn_pthread(label, reims_vgpu_core::rt::queue::WORKER_STACK, body) + spawn_pthread(label, crate::core::rt::queue::WORKER_STACK, body) } fn handle(&self) -> Arc { @@ -185,7 +185,7 @@ mod tests { /// thread, a queue's worker and a timer's handler. mod a_raising_block_dies_uncaught { use super::*; - use reims_vgpu_core::rt::{SerialQueue, Timer}; + use crate::core::rt::{SerialQueue, Timer}; /// Prints `DROPPED` when dropped: a block's capture. struct Tracer; @@ -201,14 +201,13 @@ mod tests { handler: Option, ); #[link_name = "_exit"] - fn libc_exit(status: std::ffi::c_int) -> !; + safe fn libc_exit(status: std::ffi::c_int) -> !; } /// The host's uncaught-exception handler: reports and ends the process with status 42. unsafe extern "C" fn uncaught(_exception: *mut objc2::runtime::AnyObject) { eprintln!("UNCAUGHT"); - // SAFETY: ends the process at once. - unsafe { libc_exit(42) } + libc_exit(42) } /// The host's code: raises an NSException. @@ -288,7 +287,7 @@ mod tests { unsafe { NSSetUncaughtExceptionHandler(Some(uncaught)) }; let q = SerialQueue::new(&MacThreads::new(), "dev.reims.vgpu.t.raise"); let tracer = Tracer; - use reims_vgpu_core::platform::os::{Clock as _, Deadline}; + use crate::core::platform::os::{Clock as _, Deadline}; let _t = Timer::start( &q, Deadline::Wall(MacClock::new().now_wall()), diff --git a/crates/reims-vgpu-vulkan/src/os/macos/vm.rs b/crates/reims-vgpu-vulkan/src/os/macos/vm.rs index 7d8f36bfd..c66d846e4 100644 --- a/crates/reims-vgpu-vulkan/src/os/macos/vm.rs +++ b/crates/reims-vgpu-vulkan/src/os/macos/vm.rs @@ -3,6 +3,8 @@ //! Every call is on `mach_task_self()`; the `kern_return_t` goes back raw. Only `== KERN_SUCCESS` //! is ever tested. +use crate::core::num::{ToU64, ToUsize}; +use crate::core::platform::os::vm::{HostAddr, KernReturn, VmProt}; use mach2::kern_return::{KERN_SUCCESS, kern_return_t}; use mach2::traps::mach_task_self; use mach2::vm::{mach_vm_allocate, mach_vm_deallocate, mach_vm_protect, mach_vm_remap}; @@ -10,8 +12,6 @@ use mach2::vm_inherit::VM_INHERIT_COPY; use mach2::vm_prot::vm_prot_t; use mach2::vm_statistics::{VM_FLAGS_ANYWHERE, VM_FLAGS_FIXED, VM_FLAGS_OVERWRITE}; use mach2::vm_types::mach_vm_address_t; -use reims_vgpu_core::num::{ToU64, ToUsize}; -use reims_vgpu_core::platform::os::vm::{HostAddr, KernReturn, VmProt}; /// Mach VM (`mach_vm_*`, `vm_page_size`). #[derive(Debug, Default)] @@ -81,7 +81,7 @@ fn check(kr: kern_return_t) -> Result<(), KernReturn> { } } -impl reims_vgpu_core::platform::os::vm::HostVm for MacVm { +impl crate::core::platform::os::vm::HostVm for MacVm { /// `vm_page_size`: 19 uses. fn page_size(&self) -> u64 { // SAFETY: `vm_page_size` is a libsystem_kernel global, set before `main` and never @@ -174,7 +174,7 @@ impl reims_vgpu_core::platform::os::vm::HostVm for MacVm { mod tests { use super::*; - use reims_vgpu_core::platform::os::vm::HostVm; + use crate::core::platform::os::vm::HostVm; /// `KERN_INVALID_ADDRESS`. const KERN_INVALID_ADDRESS: i32 = 1; diff --git a/crates/reims-vgpu-vulkan/src/os/surface.rs b/crates/reims-vgpu-vulkan/src/os/surface.rs index 0c44135ce..1cceb4cc0 100644 --- a/crates/reims-vgpu-vulkan/src/os/surface.rs +++ b/crates/reims-vgpu-vulkan/src/os/surface.rs @@ -5,9 +5,9 @@ use std::sync::{Arc, Weak}; +use crate::core::num::{ToU64, ToUsize}; +use crate::core::platform::os::surface::Surface; use metal2vulkan_runtime as rt; -use reims_vgpu_core::num::{ToU64, ToUsize}; -use reims_vgpu_core::platform::os::surface::Surface; use super::{OsSurface, host_os}; use crate::gpu::backing::Alias; @@ -324,10 +324,10 @@ pub(crate) fn page_runs(pages: impl IntoIterator) -> Vec &'static rt::DeviceOptions { options.messages = Some(sink.with_least_severity(crate::answer::least_severity())); options.announce_each = announced_each(crate::answer::strict_process() || crate::answer::census::on()); - if std::env::var_os(reims_vgpu_core::trace::ENV_VAR).is_some() { - reims_vgpu_core::trace::set_clock(crate::gpu::timing::trace_clock); - if crate::answer::trace_degradations() && reims_vgpu_core::trace::on() { + if std::env::var_os(crate::core::trace::ENV_VAR).is_some() { + crate::core::trace::set_clock(crate::gpu::timing::trace_clock); + if crate::answer::trace_degradations() && crate::core::trace::on() { // Every occurrence reaches the sink, which writes each to the trace and relays // a kind the runtime announces once only the first time: only where the trace's // file opened, the sink's own condition, so a refused file changes nothing. @@ -770,8 +770,8 @@ pub(crate) mod tests { /// for having none, naming the refusal; with no device or no loader it makes none #[test] fn a_refused_device_dies_at_the_creator() { - use reims_vgpu_core::raise::death::DeathKind; - use reims_vgpu_core::testkit::capture::catch_death; + use crate::core::raise::death::DeathKind; + use crate::core::testkit::capture::catch_death; for sel in ["MTLCreateSystemDefaultDevice()", "MTLCopyAllDevices()"] { let refusal = rt::Error::NotImplemented(rt::RuntimeGap::Textures); *crate::answer::LAST_LINE.lock() = None; diff --git a/crates/reims-vgpu-vulkan/src/records.rs b/crates/reims-vgpu-vulkan/src/records.rs index b1190c6a6..272d66c56 100644 --- a/crates/reims-vgpu-vulkan/src/records.rs +++ b/crates/reims-vgpu-vulkan/src/records.rs @@ -35,8 +35,8 @@ use std::path::{Path, PathBuf}; use std::sync::Arc; use std::sync::mpsc::{Receiver, Sender, channel}; +use crate::core::sync::Mutex; use metal2vulkan_runtime as rt; -use reims_vgpu_core::sync::Mutex; /// The records file under `HOME`, beside the shader cache's directory. pub(crate) const RECORDS: &str = ".cache/reims-vgpu-vulkan-pipelines"; diff --git a/crates/reims-vgpu-vulkan/src/remap.rs b/crates/reims-vgpu-vulkan/src/remap.rs index fe823c7cb..cc710fe48 100644 --- a/crates/reims-vgpu-vulkan/src/remap.rs +++ b/crates/reims-vgpu-vulkan/src/remap.rs @@ -121,10 +121,10 @@ use std::collections::BTreeMap; use std::ops::Range; use std::ptr::NonNull; -use reims_vgpu_core::host::HostPtr; -use reims_vgpu_core::num::{ToU64, ToUsize}; -use reims_vgpu_core::platform::os::vm::{HostAddr, HostVm, KernReturn, VmProt}; -use reims_vgpu_core::sync::Mutex; +use crate::core::host::HostPtr; +use crate::core::num::{ToU64, ToUsize}; +use crate::core::platform::os::vm::{HostAddr, HostVm, KernReturn, VmProt}; +use crate::core::sync::Mutex; use crate::os::OsVm; diff --git a/crates/reims-vgpu-vulkan/src/swapchain.rs b/crates/reims-vgpu-vulkan/src/swapchain.rs index 71fdfdd03..80e02a2db 100644 --- a/crates/reims-vgpu-vulkan/src/swapchain.rs +++ b/crates/reims-vgpu-vulkan/src/swapchain.rs @@ -115,12 +115,12 @@ use std::ffi::c_void; use std::sync::Arc; use std::time::Duration; +use crate::core::platform::Handle as _; +use crate::core::platform::os::Clock as _; +use crate::core::sync::{Mutex, MutexGuard}; use ash::{khr, vk}; use metal2vulkan::metal::{PixelFormat, TextureUsage}; use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::Handle as _; -use reims_vgpu_core::platform::os::Clock as _; -use reims_vgpu_core::sync::{Mutex, MutexGuard}; use crate::gpu::command::{VulkanCommandBuffer, VulkanCommandQueue}; use crate::gpu::device::VulkanDevice; @@ -1399,11 +1399,11 @@ mod tests { /// lives takes the ID it takes without it #[test] fn a_swapchain_images_texture_takes_no_resource_id() { - use reims_vgpu_core::platform::Platform as _; - use reims_vgpu_core::platform::device::GpuDevice as _; - use reims_vgpu_core::platform::resource::Texture as _; - use reims_vgpu_core::platform::values::TextureDesc; - use reims_vgpu_core::raise::OnFault; + use crate::core::platform::Platform as _; + use crate::core::platform::device::GpuDevice as _; + use crate::core::platform::resource::Texture as _; + use crate::core::platform::values::TextureDesc; + use crate::core::raise::OnFault; let p = crate::platform::tests::platform(); let d = crate::gpu::device::tests::dev(); diff --git a/crates/reims-vgpu-vulkan/src/work_log.rs b/crates/reims-vgpu-vulkan/src/work_log.rs index 2560711b7..03785c9ed 100644 --- a/crates/reims-vgpu-vulkan/src/work_log.rs +++ b/crates/reims-vgpu-vulkan/src/work_log.rs @@ -6,7 +6,7 @@ //! //! - **Asked for by name.** [`start`] makes the thread only where `REIMS_VGPU_LOG` names the //! target itself at debug as the device is adopted (`info,reims_vgpu::work=debug`, the lane -//! benches' filter: `reims_vgpu_core::logging::names`). A lone level, such as the `debug` a +//! benches' filter: `crate::core::logging::names`). A lone level, such as the `debug` a //! bug report's log asks for, and a pair of a target above it (`reims_vgpu=debug`) start none, //! though they write the target's lines: reading the counts costs the draws it counts (below). //! - **Off, it costs nothing.** No thread is made, and the thread reads no count while the @@ -28,8 +28,8 @@ use std::fmt::Write as _; use std::time::Duration; +use crate::core::platform::os::clock::{Clock as _, Deadline, MonoTime}; use metal2vulkan_runtime as rt; -use reims_vgpu_core::platform::os::clock::{Clock as _, Deadline, MonoTime}; /// The log target of the lines, at debug, which the filter names to start them ([`start`]). pub(crate) const TARGET: &str = "reims_vgpu::work"; @@ -43,7 +43,7 @@ type Flat = Vec<(String, u64)>; /// Starts the thread that logs `device`'s counts (the module docs), where the filter names the /// target at debug and its lines are written. pub(crate) fn start(device: &rt::Device) { - if !(reims_vgpu_core::logging::names(TARGET, log::Level::Debug) + if !(crate::core::logging::names(TARGET, log::Level::Debug) && log::log_enabled!(target: TARGET, log::Level::Debug)) { return; diff --git a/crates/reims-vgpu-vulkan/tests/client_direction.rs b/crates/reims-vgpu-vulkan/tests/client_direction.rs index c79cc3e8e..acf4961b2 100644 --- a/crates/reims-vgpu-vulkan/tests/client_direction.rs +++ b/crates/reims-vgpu-vulkan/tests/client_direction.rs @@ -33,24 +33,26 @@ unsafe_code )] -use reims_vgpu_core::host::{HostPtr, PhysicalMemoryRange}; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder, ResourceRef}; -use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue}; -use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder}; -use reims_vgpu_core::platform::descriptor::RenderPassDescriptor; -use reims_vgpu_core::platform::device::GpuDevice; -use reims_vgpu_core::platform::os::surface::SurfaceSpec; -use reims_vgpu_core::platform::os::vm::HostVm; -use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder}; -use reims_vgpu_core::platform::resource::{Buffer, Library, Texture}; -use reims_vgpu_core::platform::types::{ +use reims_vgpu_vulkan::VulkanPlatform; +use reims_vgpu_vulkan::core::host::{HostPtr, PhysicalMemoryRange}; +use reims_vgpu_vulkan::core::platform::blit::{BlitCmd, BlitEncoder, ResourceRef}; +use reims_vgpu_vulkan::core::platform::command::{CommandBuffer, CommandQueue}; +use reims_vgpu_vulkan::core::platform::compute::{ComputeCmd, ComputeEncoder}; +use reims_vgpu_vulkan::core::platform::descriptor::RenderPassDescriptor; +use reims_vgpu_vulkan::core::platform::device::GpuDevice; +use reims_vgpu_vulkan::core::platform::os::surface::SurfaceSpec; +use reims_vgpu_vulkan::core::platform::os::vm::HostVm; +use reims_vgpu_vulkan::core::platform::render::{RenderCmd, RenderEncoder}; +use reims_vgpu_vulkan::core::platform::resource::{Buffer, Library, Texture}; +use reims_vgpu_vulkan::core::platform::types::{ ClearColor, MtlOrigin, MtlRegion, MtlSize, NsRange, Swizzle, }; -use reims_vgpu_core::platform::values::{ColorAttachmentSet, RenderPipelineDesc, TextureDesc}; -use reims_vgpu_core::platform::{HostRange, Platform}; -use reims_vgpu_core::raise::OnFault; -use reims_vgpu_core::testkit::capture::catch_death; -use reims_vgpu_vulkan::VulkanPlatform; +use reims_vgpu_vulkan::core::platform::values::{ + ColorAttachmentSet, RenderPipelineDesc, TextureDesc, +}; +use reims_vgpu_vulkan::core::platform::{HostRange, Platform}; +use reims_vgpu_vulkan::core::raise::OnFault; +use reims_vgpu_vulkan::core::testkit::capture::catch_death; use reims_vgpu_vulkan::gpu::resource::VulkanTexture; use reims_vgpu_vulkan::os::OsVm; @@ -1182,7 +1184,7 @@ fn pass( attachment: &ColorAttachmentSet<'_, P>, visibility: Option<&P::Buffer>, ) -> P::RenderPassDescriptor { - use reims_vgpu_core::platform::values::PassSet; + use reims_vgpu_vulkan::core::platform::values::PassSet; let pass = p.render_pass_descriptor(); pass.set_color_attachment(OnFault::Die, 0, attachment) .unwrap(); @@ -1497,7 +1499,7 @@ fn read_only_textures_answer_metals_usage() { &VulkanPlatform::new(), &VulkanPlatform::system_default_device().unwrap(), ); - reims_vgpu_core::metal_check!("usages", vulkan); + reims_vgpu_vulkan::metal_check!("usages", vulkan); } /// The tests' vertex function that returns nothing (`src/gpu/unrasterized.metal`). @@ -1508,7 +1510,7 @@ const UNRASTERIZED: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/unrasteriz /// command buffer's status. Its vertex function returns nothing (`void_vertex`), and colour 0 is /// `BGRA8Unorm`. fn unrasterized_write(p: &P, d: &P::Device) -> u64 { - use reims_vgpu_core::platform::values::{ColorAttachmentDesc, FullRenderPipelineDesc}; + use reims_vgpu_vulkan::core::platform::values::{ColorAttachmentDesc, FullRenderPipelineDesc}; let q = d.new_command_queue().unwrap(); let (_s, t) = read_only_texture(p, d, &bgra(p, (64, 16), 3, 1)); let own = d diff --git a/crates/reims-vgpu-vulkan/tests/detach_backing.rs b/crates/reims-vgpu-vulkan/tests/detach_backing.rs index 30fa82de3..2beb46a5d 100644 --- a/crates/reims-vgpu-vulkan/tests/detach_backing.rs +++ b/crates/reims-vgpu-vulkan/tests/detach_backing.rs @@ -56,19 +56,19 @@ use std::sync::mpsc; -use reims_vgpu_core::host::HostPtr; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder}; -use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue}; -use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder}; -use reims_vgpu_core::platform::device::GpuDevice; -use reims_vgpu_core::platform::event::{EventRef, SharedEvent}; -use reims_vgpu_core::platform::os::vm::{HostVm, VmProt}; -use reims_vgpu_core::platform::resource::{Buffer, Heap, Library, Texture}; -use reims_vgpu_core::platform::types::{MtlOrigin, MtlSize, NsRange, ResourceAddressRange}; -use reims_vgpu_core::platform::values::{BufferDesc, HeapDesc, OptionSet, TextureDesc}; -use reims_vgpu_core::platform::{Handle, HostRange, Platform}; -use reims_vgpu_core::raise::OnFault; use reims_vgpu_vulkan::VulkanPlatform; +use reims_vgpu_vulkan::core::host::HostPtr; +use reims_vgpu_vulkan::core::platform::blit::{BlitCmd, BlitEncoder}; +use reims_vgpu_vulkan::core::platform::command::{CommandBuffer, CommandQueue}; +use reims_vgpu_vulkan::core::platform::compute::{ComputeCmd, ComputeEncoder}; +use reims_vgpu_vulkan::core::platform::device::GpuDevice; +use reims_vgpu_vulkan::core::platform::event::{EventRef, SharedEvent}; +use reims_vgpu_vulkan::core::platform::os::vm::{HostVm, VmProt}; +use reims_vgpu_vulkan::core::platform::resource::{Buffer, Heap, Library, Texture}; +use reims_vgpu_vulkan::core::platform::types::{MtlOrigin, MtlSize, NsRange, ResourceAddressRange}; +use reims_vgpu_vulkan::core::platform::values::{BufferDesc, HeapDesc, OptionSet, TextureDesc}; +use reims_vgpu_vulkan::core::platform::{Handle, HostRange, Platform}; +use reims_vgpu_vulkan::core::raise::OnFault; use reims_vgpu_vulkan::os::OsVm; const PAGE: u64 = 0x4000; @@ -1174,7 +1174,7 @@ const CHILD_CASE: &str = "RVG_BEHIND_A_WAIT"; #[test] fn behind_a_wait_on_vulkan() { if let Ok(case) = std::env::var(CHILD_CASE) { - reims_vgpu_core::testkit::capture::set_capture_enabled(false); + reims_vgpu_vulkan::core::testkit::capture::set_capture_enabled(false); let dev = VulkanPlatform::system_default_device().unwrap(); let p = VulkanPlatform::new(); println!("seen {:?}", behind_a_wait(&p, &dev, &case)); @@ -1287,7 +1287,7 @@ const DISPATCH_BEHIND_A_WAIT: [u64; 4] = [4, 0, 0, SPUN as u64]; fn a_dispatch_behind_a_wait_on_vulkan() { const CHILD: &str = "RVG_DISPATCH_BEHIND_A_WAIT"; if let Ok(warm) = std::env::var(CHILD) { - reims_vgpu_core::testkit::capture::set_capture_enabled(false); + reims_vgpu_vulkan::core::testkit::capture::set_capture_enabled(false); let dev = VulkanPlatform::system_default_device().unwrap(); let p = VulkanPlatform::new(); println!("seen {:?}", dispatch_behind_a_wait(&p, &dev, warm == "1")); @@ -1541,7 +1541,7 @@ fn expected_past_the_size() -> Steps { fn pages_past_the_size_on_vulkan() { const CHILD: &str = "RVG_PAGES_PAST_THE_SIZE"; if std::env::var_os(CHILD).is_some() { - reims_vgpu_core::testkit::capture::set_capture_enabled(false); + reims_vgpu_vulkan::core::testkit::capture::set_capture_enabled(false); let dev = VulkanPlatform::system_default_device().unwrap(); let p = VulkanPlatform::new(); println!("made {:?}", past_the_size(&p, &dev)); @@ -1578,7 +1578,7 @@ fn pages_past_the_size_on_vulkan() { fn pages_without_access_on_vulkan() { const CHILD: &str = "RVG_PAGES_WITHOUT_ACCESS"; if std::env::var_os(CHILD).is_some() { - reims_vgpu_core::testkit::capture::set_capture_enabled(false); + reims_vgpu_vulkan::core::testkit::capture::set_capture_enabled(false); let dev = VulkanPlatform::system_default_device().unwrap(); let p = VulkanPlatform::new(); println!("made {:?}", without_access(&p, &dev)); @@ -1763,8 +1763,8 @@ fn unaligned(p: &P, dev: &P::Device, index: usize, heap: bool) -> S /// (`src/gpu/backing.rs`'s `off_the_page`), which Metal's first words show #[test] fn unaligned_ranges_on_vulkan_are_metals() { - use reims_vgpu_core::raise::death::DeathKind; - use reims_vgpu_core::testkit::capture::catch_death; + use reims_vgpu_vulkan::core::raise::death::DeathKind; + use reims_vgpu_vulkan::core::testkit::capture::catch_death; let cases: Vec<(usize, bool)> = (0..UNALIGNED) .flat_map(|index| [(index, true), (index, false)]) .collect(); @@ -1784,7 +1784,7 @@ fn unaligned_ranges_on_vulkan_are_metals() { continue; } let ours = unaligned(&p, &dev, index, heap); - reims_vgpu_core::metal_check!(&case, ours); + reims_vgpu_vulkan::metal_check!(&case, ours); } } diff --git a/crates/reims-vgpu-vulkan/tests/new_images.rs b/crates/reims-vgpu-vulkan/tests/new_images.rs index 147dc0f08..c07f5cdf1 100644 --- a/crates/reims-vgpu-vulkan/tests/new_images.rs +++ b/crates/reims-vgpu-vulkan/tests/new_images.rs @@ -31,17 +31,17 @@ use std::sync::atomic::{AtomicU32, Ordering}; use std::time::Duration; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue}; -use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder}; -use reims_vgpu_core::platform::device::GpuDevice; -use reims_vgpu_core::platform::os::clock::{Clock, MonoTime}; -use reims_vgpu_core::platform::os::surface::SurfaceSpec; -use reims_vgpu_core::platform::resource::{Buffer, Library}; -use reims_vgpu_core::platform::types::{CommandBufferStatus, MtlSize, NsRange}; -use reims_vgpu_core::platform::values::TextureDesc; -use reims_vgpu_core::raise::OnFault; use reims_vgpu_vulkan::VulkanPlatform; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::platform::command::{CommandBuffer, CommandQueue}; +use reims_vgpu_vulkan::core::platform::compute::{ComputeCmd, ComputeEncoder}; +use reims_vgpu_vulkan::core::platform::device::GpuDevice; +use reims_vgpu_vulkan::core::platform::os::clock::{Clock, MonoTime}; +use reims_vgpu_vulkan::core::platform::os::surface::SurfaceSpec; +use reims_vgpu_vulkan::core::platform::resource::{Buffer, Library}; +use reims_vgpu_vulkan::core::platform::types::{CommandBufferStatus, MtlSize, NsRange}; +use reims_vgpu_vulkan::core::platform::values::TextureDesc; +use reims_vgpu_vulkan::core::raise::OnFault; /// The kernel that keeps the GPU busy (`src/gpu/spin.metal`). const SPIN: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/spin.metallib")); diff --git a/crates/reims-vgpu-vulkan/tests/no_copy_remap.rs b/crates/reims-vgpu-vulkan/tests/no_copy_remap.rs index cb9a4ff0f..abaf6390c 100644 --- a/crates/reims-vgpu-vulkan/tests/no_copy_remap.rs +++ b/crates/reims-vgpu-vulkan/tests/no_copy_remap.rs @@ -29,17 +29,17 @@ use std::sync::{Arc, mpsc}; use std::time::Duration; -use reims_vgpu_core::host::HostPtr; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder}; -use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue}; -use reims_vgpu_core::platform::device::{GpuDevice, NoCopyDeallocator}; -use reims_vgpu_core::platform::event::{EventRef, SharedEvent}; -use reims_vgpu_core::platform::os::vm::HostVm; -use reims_vgpu_core::platform::resource::Buffer; -use reims_vgpu_core::platform::types::NsRange; -use reims_vgpu_core::platform::{HostRange, Platform}; -use reims_vgpu_core::raise::OnFault; use reims_vgpu_vulkan::VulkanPlatform; +use reims_vgpu_vulkan::core::host::HostPtr; +use reims_vgpu_vulkan::core::platform::blit::{BlitCmd, BlitEncoder}; +use reims_vgpu_vulkan::core::platform::command::{CommandBuffer, CommandQueue}; +use reims_vgpu_vulkan::core::platform::device::{GpuDevice, NoCopyDeallocator}; +use reims_vgpu_vulkan::core::platform::event::{EventRef, SharedEvent}; +use reims_vgpu_vulkan::core::platform::os::vm::HostVm; +use reims_vgpu_vulkan::core::platform::resource::Buffer; +use reims_vgpu_vulkan::core::platform::types::NsRange; +use reims_vgpu_vulkan::core::platform::{HostRange, Platform}; +use reims_vgpu_vulkan::core::raise::OnFault; use reims_vgpu_vulkan::os::OsVm; const LEN: u64 = 0x8000; diff --git a/crates/reims-vgpu-vulkan/tests/no_copy_remap_linux.rs b/crates/reims-vgpu-vulkan/tests/no_copy_remap_linux.rs index c9f51a0b4..6c6d1f5b4 100644 --- a/crates/reims-vgpu-vulkan/tests/no_copy_remap_linux.rs +++ b/crates/reims-vgpu-vulkan/tests/no_copy_remap_linux.rs @@ -51,16 +51,16 @@ use std::sync::mpsc; use std::time::Duration; -use reims_vgpu_core::host::HostPtr; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder}; -use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue}; -use reims_vgpu_core::platform::device::{GpuDevice, NoCopyDeallocator}; -use reims_vgpu_core::platform::os::vm::HostVm; -use reims_vgpu_core::platform::resource::Buffer; -use reims_vgpu_core::platform::types::NsRange; -use reims_vgpu_core::platform::{HostRange, Platform}; -use reims_vgpu_core::raise::OnFault; use reims_vgpu_vulkan::VulkanPlatform; +use reims_vgpu_vulkan::core::host::HostPtr; +use reims_vgpu_vulkan::core::platform::blit::{BlitCmd, BlitEncoder}; +use reims_vgpu_vulkan::core::platform::command::{CommandBuffer, CommandQueue}; +use reims_vgpu_vulkan::core::platform::device::{GpuDevice, NoCopyDeallocator}; +use reims_vgpu_vulkan::core::platform::os::vm::HostVm; +use reims_vgpu_vulkan::core::platform::resource::Buffer; +use reims_vgpu_vulkan::core::platform::types::NsRange; +use reims_vgpu_vulkan::core::platform::{HostRange, Platform}; +use reims_vgpu_vulkan::core::raise::OnFault; use reims_vgpu_vulkan::os::OsVm; use reims_vgpu_vulkan::remap::VulkanVm; diff --git a/crates/reims-vgpu-window/Cargo.toml b/crates/reims-vgpu-window/Cargo.toml index 65348bcd6..8a4a9d405 100644 --- a/crates/reims-vgpu-window/Cargo.toml +++ b/crates/reims-vgpu-window/Cargo.toml @@ -8,7 +8,6 @@ publish.workspace = true license.workspace = true [dependencies] -reims-vgpu-core.workspace = true log.workspace = true # ash's Vulkan types for a window's surface (`present`): SDL's on Linux, the layer's on macOS. ash.workspace = true @@ -99,7 +98,7 @@ objc2-app-kit = { workspace = true, features = [ ] } [dev-dependencies] -reims-vgpu-core = { workspace = true, features = ["testkit"] } +reims-vgpu-vulkan = { workspace = true, features = ["testkit"] } [lints] workspace = true diff --git a/crates/reims-vgpu-window/src/handle.rs b/crates/reims-vgpu-window/src/handle.rs index 87d37bf2a..564c4f973 100644 --- a/crates/reims-vgpu-window/src/handle.rs +++ b/crates/reims-vgpu-window/src/handle.rs @@ -47,8 +47,8 @@ use std::sync::Arc; use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; use std::time::Duration; -use reims_vgpu_core::platform::os::MonoTime; -use reims_vgpu_core::sync::Mutex; +use reims_vgpu_vulkan::core::platform::os::MonoTime; +use reims_vgpu_vulkan::core::sync::Mutex; pub use crate::present::FrameSink; diff --git a/crates/reims-vgpu-window/src/native/linux.rs b/crates/reims-vgpu-window/src/native/linux.rs index 5016d1644..15c371ea9 100644 --- a/crates/reims-vgpu-window/src/native/linux.rs +++ b/crates/reims-vgpu-window/src/native/linux.rs @@ -15,7 +15,7 @@ mod ui; use std::sync::Arc; -use reims_vgpu_core::platform::os::{Clock as _, MonoTime}; +use reims_vgpu_vulkan::core::platform::os::{Clock as _, MonoTime}; use reims_vgpu_vulkan::os::OsClock; pub(crate) use render::Surface; diff --git a/crates/reims-vgpu-window/src/native/linux/render.rs b/crates/reims-vgpu-window/src/native/linux/render.rs index 6b0ee763d..19b9c092e 100644 --- a/crates/reims-vgpu-window/src/native/linux/render.rs +++ b/crates/reims-vgpu-window/src/native/linux/render.rs @@ -24,8 +24,8 @@ use std::sync::Arc; use ash::vk; -use reims_vgpu_core::rt::spawn_named; -use reims_vgpu_core::sync::{Condvar, Mutex}; +use reims_vgpu_vulkan::core::rt::spawn_named; +use reims_vgpu_vulkan::core::sync::{Condvar, Mutex}; use reims_vgpu_vulkan::os::OsThreads; use sdl3_sys::everything::{SDL_Vulkan_CreateSurface, SDL_Window}; diff --git a/crates/reims-vgpu-window/src/native/linux/ui.rs b/crates/reims-vgpu-window/src/native/linux/ui.rs index 6ab3d9c49..40fc1ec7f 100644 --- a/crates/reims-vgpu-window/src/native/linux/ui.rs +++ b/crates/reims-vgpu-window/src/native/linux/ui.rs @@ -29,8 +29,8 @@ use std::ffi::CStr; use std::sync::atomic::{AtomicU32, Ordering}; use std::time::Duration; -use reims_vgpu_core::rt::spawn_named; -use reims_vgpu_core::sync::{Condvar, Mutex}; +use reims_vgpu_vulkan::core::rt::spawn_named; +use reims_vgpu_vulkan::core::sync::{Condvar, Mutex}; use reims_vgpu_vulkan::os::OsThreads; use sdl3_sys::everything::*; diff --git a/crates/reims-vgpu-window/src/native/macos.rs b/crates/reims-vgpu-window/src/native/macos.rs index 9fd492a0d..7924ec191 100644 --- a/crates/reims-vgpu-window/src/native/macos.rs +++ b/crates/reims-vgpu-window/src/native/macos.rs @@ -38,7 +38,7 @@ use std::sync::Arc; use objc2::MainThreadMarker; use objc2_app_kit::{NSEvent, NSEventMask}; -use reims_vgpu_core::platform::os::{Clock as _, MonoTime}; +use reims_vgpu_vulkan::core::platform::os::{Clock as _, MonoTime}; use reims_vgpu_vulkan::os::OsClock; pub(crate) use self::iso::is_iso_keyboard; diff --git a/crates/reims-vgpu-window/src/native/macos/app.rs b/crates/reims-vgpu-window/src/native/macos/app.rs index e744d290a..787dfaeb2 100644 --- a/crates/reims-vgpu-window/src/native/macos/app.rs +++ b/crates/reims-vgpu-window/src/native/macos/app.rs @@ -46,7 +46,7 @@ use objc2_foundation::{ NSActivityOptions, NSNotification, NSNotificationCenter, NSObject, NSObjectProtocol, NSProcessInfo, NSString, ns_string, }; -use reims_vgpu_core::rt::BlockEnv; +use reims_vgpu_vulkan::core::rt::BlockEnv; use reims_vgpu_vulkan::os::msg; use super::main_thread::{self, MainOnly, ns_text, responds, shared_app}; diff --git a/crates/reims-vgpu-window/src/native/macos/hotkeys.rs b/crates/reims-vgpu-window/src/native/macos/hotkeys.rs index 6e6e2e252..8db4977ba 100644 --- a/crates/reims-vgpu-window/src/native/macos/hotkeys.rs +++ b/crates/reims-vgpu-window/src/native/macos/hotkeys.rs @@ -22,7 +22,7 @@ use std::ffi::{CStr, c_int, c_void}; use std::sync::OnceLock; -use reims_vgpu_core::sync::Mutex; +use reims_vgpu_vulkan::core::sync::Mutex; /// `CGSMainConnectionID()`: the process's connection to WindowServer. type MainConnectionId = unsafe extern "C" fn() -> c_int; diff --git a/crates/reims-vgpu-window/src/native/macos/input.rs b/crates/reims-vgpu-window/src/native/macos/input.rs index 43bb4c038..666f9b733 100644 --- a/crates/reims-vgpu-window/src/native/macos/input.rs +++ b/crates/reims-vgpu-window/src/native/macos/input.rs @@ -692,7 +692,7 @@ impl Drop for InputState { #[cfg(test)] mod tests { - use reims_vgpu_core::sync::Mutex; + use reims_vgpu_vulkan::core::sync::Mutex; use super::*; use crate::config::{BUTTON_LEFT, BUTTON_RIGHT}; diff --git a/crates/reims-vgpu-window/src/native/macos/main_thread.rs b/crates/reims-vgpu-window/src/native/macos/main_thread.rs index f0e6aab14..e9aa8bfee 100644 --- a/crates/reims-vgpu-window/src/native/macos/main_thread.rs +++ b/crates/reims-vgpu-window/src/native/macos/main_thread.rs @@ -33,8 +33,8 @@ use objc2::{MainThreadMarker, Message}; use objc2_app_kit::{NSApp, NSApplication}; use objc2_core_foundation::{CFRunLoop, kCFRunLoopCommonModes}; use objc2_foundation::NSString; -use reims_vgpu_core::rt::BlockEnv; -use reims_vgpu_core::sync::Mutex; +use reims_vgpu_vulkan::core::rt::BlockEnv; +use reims_vgpu_vulkan::core::sync::Mutex; use reims_vgpu_vulkan::os::msg; /// Work for the main thread. diff --git a/crates/reims-vgpu-window/src/native/macos/render.rs b/crates/reims-vgpu-window/src/native/macos/render.rs index 8e1e95e32..b1850d183 100644 --- a/crates/reims-vgpu-window/src/native/macos/render.rs +++ b/crates/reims-vgpu-window/src/native/macos/render.rs @@ -37,8 +37,8 @@ use objc2::rc::Retained; use objc2_core_graphics::{CGColor, CGColorSpace, kCGColorBlack, kCGColorSpaceSRGB}; use objc2_metal::MTLPixelFormat; use objc2_quartz_core::CAMetalLayer; -use reims_vgpu_core::rt::spawn_named; -use reims_vgpu_core::sync::{Condvar, Mutex}; +use reims_vgpu_vulkan::core::rt::spawn_named; +use reims_vgpu_vulkan::core::sync::{Condvar, Mutex}; use reims_vgpu_vulkan::os::OsThreads; use reims_vgpu_vulkan::os::msg; diff --git a/crates/reims-vgpu-window/src/native/macos/shell.rs b/crates/reims-vgpu-window/src/native/macos/shell.rs index d78b68550..00efc05c1 100644 --- a/crates/reims-vgpu-window/src/native/macos/shell.rs +++ b/crates/reims-vgpu-window/src/native/macos/shell.rs @@ -59,7 +59,7 @@ use objc2_app_kit::{ use objc2_foundation::{ NSNotification, NSNumber, NSObject, NSObjectProtocol, NSPoint, NSRect, NSSize, ns_string, }; -use reims_vgpu_core::rt::BlockEnv; +use reims_vgpu_vulkan::core::rt::BlockEnv; use reims_vgpu_vulkan::os::msg; use super::main_thread::{MainOnly, responds, shared_app}; diff --git a/crates/reims-vgpu-window/src/native/macos/view.rs b/crates/reims-vgpu-window/src/native/macos/view.rs index de02e717a..6b7090ffc 100644 --- a/crates/reims-vgpu-window/src/native/macos/view.rs +++ b/crates/reims-vgpu-window/src/native/macos/view.rs @@ -74,7 +74,7 @@ use objc2_app_kit::{ use objc2_core_foundation::CGFloat; use objc2_foundation::{NSObject, NSObjectProtocol, NSPoint, NSRect, NSSize}; use objc2_quartz_core::CAMetalLayer; -use reims_vgpu_core::rt::BlockEnv; +use reims_vgpu_vulkan::core::rt::BlockEnv; use reims_vgpu_vulkan::os::msg; use super::cursor::CursorCache; diff --git a/crates/reims-vgpu/Cargo.toml b/crates/reims-vgpu/Cargo.toml index 31e21ff20..15ca0d972 100644 --- a/crates/reims-vgpu/Cargo.toml +++ b/crates/reims-vgpu/Cargo.toml @@ -14,13 +14,12 @@ default = ["macos-sdl"] # Linux's window is SDL3's whatever this says. macos-sdl = ["reims-vgpu-window/macos-sdl"] # Tests: the core objects behind the public handles (`core()`), and core's testkit. -testkit = ["reims-vgpu-core/testkit"] +testkit = ["reims-vgpu-vulkan/testkit"] # Kept for the builds that name it (`--features vulkan`): the Vulkan platform is the library's only # one, everywhere, so the feature changes nothing. vulkan = [] [dependencies] -reims-vgpu-core.workspace = true reims-vgpu-window.workspace = true # The reims-graphics device's host video: its runtime, which the video arms run on (`video`), and # on Linux the arms' VA-API and NVDEC (`graphics::vaapi`, `graphics::nvidia`). @@ -48,7 +47,7 @@ reims-vgpu-vulkan.workspace = true metal2vulkan-runtime.workspace = true [dev-dependencies] -reims-vgpu-core = { workspace = true, features = ["testkit"] } +reims-vgpu-vulkan = { workspace = true, features = ["testkit"] } # The decoder's tests of Metal's own stitched functions (`graphics::decode`); `entry`'s tests read # retain counts with `objc2`. diff --git a/crates/reims-vgpu/src/device_writes.rs b/crates/reims-vgpu/src/device_writes.rs index 86fa6d3dd..c5168c668 100644 --- a/crates/reims-vgpu/src/device_writes.rs +++ b/crates/reims-vgpu/src/device_writes.rs @@ -16,7 +16,7 @@ use std::ops::Range; use std::sync::{Arc, Weak}; -use reims_vgpu_core::sync::Mutex; +use reims_vgpu_vulkan::core::sync::Mutex; /// What watches the host's devices' writes. pub(crate) trait Watcher: Send + Sync { diff --git a/crates/reims-vgpu/src/entry.rs b/crates/reims-vgpu/src/entry.rs index b59c20f8e..6ef833866 100644 --- a/crates/reims-vgpu/src/entry.rs +++ b/crates/reims-vgpu/src/entry.rs @@ -12,8 +12,8 @@ //! buffer) goes at the pool's pop, so no uncommitted buffer outlives the call and holds one of //! its queue's 64 slots. -use reims_vgpu_core::raise::RaiseResult; -use reims_vgpu_core::rt::{Held, Hold, Pool, enter_ours}; +use reims_vgpu_vulkan::core::raise::RaiseResult; +use reims_vgpu_vulkan::core::rt::{Held, Hold, Pool, enter_ours}; /// A raise that reaches an entry point: nothing catches it there, so it ends the process. pub(crate) fn no_catch(r: RaiseResult) -> T { @@ -38,8 +38,8 @@ pub(crate) fn run(body: impl for<'u> FnOnce(Hold<'u>) -> T) -> T { mod tests { use std::sync::Arc; - use reims_vgpu_core::rt::is_our_thread; - use reims_vgpu_core::sync::Mutex; + use reims_vgpu_vulkan::core::rt::is_our_thread; + use reims_vgpu_vulkan::core::sync::Mutex; use super::*; diff --git a/crates/reims-vgpu/src/graphics.rs b/crates/reims-vgpu/src/graphics.rs index 38a6f5e88..abee02479 100644 --- a/crates/reims-vgpu/src/graphics.rs +++ b/crates/reims-vgpu/src/graphics.rs @@ -43,17 +43,6 @@ use std::sync::{Arc, OnceLock, Weak}; use parking_lot::lock_api::ArcRwLockReadGuard; use parking_lot::{RawRwLock, RwLock}; -use reims_vgpu_core::host::HostQueue; -use reims_vgpu_core::memory::map::MemoryMap as CoreMemoryMap; -use reims_vgpu_core::num::ToU64; -use reims_vgpu_core::platform::command::CommandBuffer as _; -use reims_vgpu_core::platform::device::GpuDevice; -use reims_vgpu_core::platform::os::clock::Clock as _; -use reims_vgpu_core::platform::resource::Texture; -use reims_vgpu_core::platform::values::TextureDesc; -use reims_vgpu_core::platform::{Handle, Platform}; -use reims_vgpu_core::raise::{OnFault, Raise, RaiseResult}; -use reims_vgpu_core::sync::Mutex; use reims_vgpu_graphics::ops::RgfxCommandBuffer; use reims_vgpu_graphics::region::Region; use reims_vgpu_graphics::wire::{ @@ -84,6 +73,17 @@ use reims_vgpu_graphics::{ CompleteAnswer, CompletionPoster, CursorImage, Host, Mode, PresentAnswer, QueueClaim, Scanout, Screen, }; +use reims_vgpu_vulkan::core::host::HostQueue; +use reims_vgpu_vulkan::core::memory::map::MemoryMap as CoreMemoryMap; +use reims_vgpu_vulkan::core::num::ToU64; +use reims_vgpu_vulkan::core::platform::command::CommandBuffer as _; +use reims_vgpu_vulkan::core::platform::device::GpuDevice; +use reims_vgpu_vulkan::core::platform::os::clock::Clock as _; +use reims_vgpu_vulkan::core::platform::resource::Texture; +use reims_vgpu_vulkan::core::platform::values::TextureDesc; +use reims_vgpu_vulkan::core::platform::{Handle, Platform}; +use reims_vgpu_vulkan::core::raise::{OnFault, Raise, RaiseResult}; +use reims_vgpu_vulkan::core::sync::Mutex; use reims_vgpu_window::{FrameSink, Window, WindowConfig, geometry}; use zerocopy::{FromBytes, IntoBytes}; @@ -726,7 +726,7 @@ pub(crate) struct Presented { impl Default for Presented

{ fn default() -> Self { Presented::new(Box::new( - reims_vgpu_core::platform::os::clock::MonoTime::default, + reims_vgpu_vulkan::core::platform::os::clock::MonoTime::default, )) } } @@ -854,7 +854,9 @@ impl Presented

{ // goes on. let shown = std::mem::replace(&mut *self.texture.lock(), texture); let (shown, hold) = shown.map(|s| (s.texture, s.hold)).unzip(); - if let Err(refusal) = reims_vgpu_core::raise::refusals::refusing(move || drop(shown)) { + if let Err(refusal) = + reims_vgpu_vulkan::core::raise::refusals::refusing(move || drop(shown)) + { log::warn!( target: "reims_vgpu::graphics", "the texture of IOSurface {previous} was let go of, and its release was refused: \ @@ -885,7 +887,9 @@ impl Presented

{ let previous = self.surface_id.swap(0, Ordering::AcqRel); let shown = self.texture.lock().take(); let (shown, hold) = shown.map(|s| (s.texture, s.hold)).unzip(); - if let Err(refusal) = reims_vgpu_core::raise::refusals::refusing(move || drop(shown)) { + if let Err(refusal) = + reims_vgpu_vulkan::core::raise::refusals::refusing(move || drop(shown)) + { log::warn!( target: "reims_vgpu::graphics", "the texture of IOSurface {previous} was let go of at the device's reset, and its \ @@ -2238,7 +2242,7 @@ impl Host for CallbackHost

{ /// run a buffer's handlers); handed to the queue's service thread, which posts it and raises /// there, where a submission handler runs inside a commit on any other thread /// ([`foreign_committer`]). The platform's runtime may run every ready buffer's submission -/// handlers inside one commit (`reims_vgpu_core::platform::command::committing`): the window's +/// handlers inside one commit (`reims_vgpu_vulkan::core::platform::command::committing`): the window's /// render thread, the host's thread inside `rvg_graphics_device_read_display`, or another /// device's, which neither post nor raise for this one, so none of them waits for room on a full /// ring either. @@ -2251,11 +2255,11 @@ fn post_from_handler(poster: &CompletionPoster, record: &[u8]) { } /// Whether this thread runs a submission handler inside a platform commit -/// (`reims_vgpu_core::platform::command::inside_commit`) and is none of the threads the +/// (`reims_vgpu_vulkan::core::platform::command::inside_commit`) and is none of the threads the /// header names for the device's raise ([`RAISE_THREADS`]). A handler run outside a commit runs /// on the platform's own thread. fn foreign_committer() -> bool { - reims_vgpu_core::platform::command::inside_commit() + reims_vgpu_vulkan::core::platform::command::inside_commit() && !std::thread::current() .name() .is_some_and(|name| RAISE_THREADS.iter().any(|named| name.starts_with(named))) diff --git a/crates/reims-vgpu/src/graphics/compile.rs b/crates/reims-vgpu/src/graphics/compile.rs index f4ce60bf9..d0f8af08f 100644 --- a/crates/reims-vgpu/src/graphics/compile.rs +++ b/crates/reims-vgpu/src/graphics/compile.rs @@ -37,8 +37,6 @@ use std::sync::Arc; use std::sync::atomic::{AtomicU64, Ordering}; use std::time::Duration; -use reims_vgpu_core::platform::os::clock::MonoTime; -use reims_vgpu_core::sync::{Condvar, Mutex}; use reims_vgpu_graphics::icb::{ RGFX_ICB_OP_COMPUTE_PIPELINE, RGFX_ICB_OP_RENDER_PIPELINE, RGFX_ICB_SLOT_PIPELINE, RgfxIcbObject, RgfxIcbRecord, slot_bytes, @@ -56,6 +54,8 @@ use reims_vgpu_graphics::region::Region; use reims_vgpu_graphics::wire::{ RGFX_CONTEXT_OBJ_ID_SHIFT, RgfxIcbSlotRun, RgfxIcbSlots, RgfxIcbWrite, }; +use reims_vgpu_vulkan::core::platform::os::clock::MonoTime; +use reims_vgpu_vulkan::core::sync::{Condvar, Mutex}; use zerocopy::FromBytes; /// The most compile threads a device runs. diff --git a/crates/reims-vgpu/src/graphics/completion.rs b/crates/reims-vgpu/src/graphics/completion.rs index f31ff1998..22510368f 100644 --- a/crates/reims-vgpu/src/graphics/completion.rs +++ b/crates/reims-vgpu/src/graphics/completion.rs @@ -19,11 +19,11 @@ //! host could not carry a command buffer out at all, so a guest blocked on it //! unblocks. -use reims_vgpu_core::platform::types::NsErrorText; use reims_vgpu_graphics::wire::{ RGFX_CB_ACCESS_REVOKED, RGFX_CB_INTERNAL, RGFX_CB_INVALID_RESOURCE, RGFX_CB_OK, RGFX_CB_PAGE_FAULT, RGFX_CB_TIMEOUT, RGFX_EVT_CB_COMPLETE, RgfxCbComplete, RgfxMsgHeader, }; +use reims_vgpu_vulkan::core::platform::types::NsErrorText; /// `MTLCommandBufferErrorInternal`. const MTL_CB_ERROR_INTERNAL: i64 = 1; diff --git a/crates/reims-vgpu/src/graphics/decode/argument.rs b/crates/reims-vgpu/src/graphics/decode/argument.rs index 1328f1f59..33355c829 100644 --- a/crates/reims-vgpu/src/graphics/decode/argument.rs +++ b/crates/reims-vgpu/src/graphics/decode/argument.rs @@ -12,11 +12,6 @@ //! argument buffer, or is a struct, names its layout by its index. A layout's members follow every //! member of the layouts before it, so the guest reads the records in one pass. -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::device::GpuDevice; -use reims_vgpu_core::platform::types::{ArgumentKind, ArgumentLayout}; -use reims_vgpu_core::platform::values::ArgumentDesc; -use reims_vgpu_core::raise::RaiseResult; use reims_vgpu_graphics::wire::{ RGFX_ARGUMENT_ACCELERATION_STRUCTURE, RGFX_ARGUMENT_BUFFER, RGFX_ARGUMENT_COMPUTE_PIPELINE, RGFX_ARGUMENT_CONSTANT, RGFX_ARGUMENT_DEPTH_STENCIL, RGFX_ARGUMENT_INDIRECT_COMMAND_BUFFER, @@ -28,6 +23,11 @@ use reims_vgpu_graphics::wire::{ RgfxArgumentLayoutQuery, RgfxArgumentLayoutRecord, RgfxArgumentLayoutReply, RgfxArgumentMemberRecord, RgfxMsgHeader, }; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::platform::device::GpuDevice; +use reims_vgpu_vulkan::core::platform::types::{ArgumentKind, ArgumentLayout}; +use reims_vgpu_vulkan::core::platform::values::ArgumentDesc; +use reims_vgpu_vulkan::core::raise::RaiseResult; use zerocopy::{FromBytes, IntoBytes}; use super::{GraphicsDecoder, ObjHandle, constants_tail, read, specialised, str_tail}; @@ -218,13 +218,13 @@ impl GraphicsDecoder

{ mod tests { use std::sync::Arc; - use reims_vgpu_core::platform::device::GpuDevice; - use reims_vgpu_core::testkit::FakePlatform; use reims_vgpu_graphics::region::Region; use reims_vgpu_graphics::wire::{ RGFX_CMD_ARGUMENT_LAYOUT, RGFX_CONTEXT_ALLOCATIONS_OFFSET, RGFX_CURSOR_SPAN, RgfxFunctionConstant, }; + use reims_vgpu_vulkan::core::platform::device::GpuDevice; + use reims_vgpu_vulkan::core::testkit::FakePlatform; use super::super::{GraphicsDecoder, ObjHandle}; use super::*; diff --git a/crates/reims-vgpu/src/graphics/decode/blit.rs b/crates/reims-vgpu/src/graphics/decode/blit.rs index c66f4fcd9..406976be4 100644 --- a/crates/reims-vgpu/src/graphics/decode/blit.rs +++ b/crates/reims-vgpu/src/graphics/decode/blit.rs @@ -16,12 +16,14 @@ //! //! [`RGFX_OP_GROUP_BLIT`]: reims_vgpu_graphics::ops::RGFX_OP_GROUP_BLIT -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder, ResourceRef}; -use reims_vgpu_core::platform::host_range::HostRange; -use reims_vgpu_core::platform::types::{ClearColor, MtlOrigin, MtlRegion, MtlSize, NsRange}; -use reims_vgpu_core::raise::{OnFault, Raise, RaiseResult}; use reims_vgpu_graphics::ops::blit::*; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::platform::blit::{BlitCmd, BlitEncoder, ResourceRef}; +use reims_vgpu_vulkan::core::platform::host_range::HostRange; +use reims_vgpu_vulkan::core::platform::types::{ + ClearColor, MtlOrigin, MtlRegion, MtlSize, NsRange, +}; +use reims_vgpu_vulkan::core::raise::{OnFault, Raise, RaiseResult}; use zerocopy::FromBytes; use super::{GraphicsDecoder, op_fault}; @@ -530,17 +532,17 @@ fn clear_color(bits: [u64; 4]) -> ClearColor { mod tests { use std::sync::Arc; - use reims_vgpu_core::platform::Handle; - use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue}; - use reims_vgpu_core::platform::device::GpuDevice; - use reims_vgpu_core::platform::values::IcbDesc; - use reims_vgpu_core::testkit::FakePlatform; - use reims_vgpu_core::testkit::calllog::Arg; use reims_vgpu_graphics::ops::{RGFX_OP_BODY_OFFSET, RgfxOpHeader}; use reims_vgpu_graphics::wire::{ RGFX_CMD_BUFFER_CREATE, RGFX_CMD_FENCE_CREATE, RGFX_CMD_TEXTURE_CREATE, RgfxBufferCreate, RgfxMsgHeader, RgfxObjectCreate, RgfxTextureCreate, RgfxTextureDescriptor, }; + use reims_vgpu_vulkan::core::platform::Handle; + use reims_vgpu_vulkan::core::platform::command::{CommandBuffer, CommandQueue}; + use reims_vgpu_vulkan::core::platform::device::GpuDevice; + use reims_vgpu_vulkan::core::platform::values::IcbDesc; + use reims_vgpu_vulkan::core::testkit::FakePlatform; + use reims_vgpu_vulkan::core::testkit::calllog::Arg; use zerocopy::IntoBytes; use super::super::ObjHandle; diff --git a/crates/reims-vgpu/src/graphics/decode/close_cost.rs b/crates/reims-vgpu/src/graphics/decode/close_cost.rs index 7e41216d8..c1604f6fb 100644 --- a/crates/reims-vgpu/src/graphics/decode/close_cost.rs +++ b/crates/reims-vgpu/src/graphics/decode/close_cost.rs @@ -18,13 +18,13 @@ use std::sync::Arc; use std::time::Instant; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::values::{RenderPipelineDesc, SamplerDesc, TextureDesc}; -use reims_vgpu_core::raise::OnFault; use reims_vgpu_graphics::wire::{ RGFX_CMD_BUFFER_OVER_HOST_MEMORY, RGFX_CMD_QUEUE_CREATE, RGFX_CONTEXT_ALLOCATIONS_OFFSET, RGFX_CURSOR_SPAN, RgfxBufferOverHostMemory, RgfxMsgHeader, RgfxQueueCreate, }; +use reims_vgpu_vulkan::core::platform::device::GpuDevice as _; +use reims_vgpu_vulkan::core::platform::values::{RenderPipelineDesc, SamplerDesc, TextureDesc}; +use reims_vgpu_vulkan::core::raise::OnFault; use zerocopy::IntoBytes; use super::draw_cost::{counts, fixture, spread, test_shaders}; @@ -127,7 +127,7 @@ fn made(kind: Kind, n: u64) -> (GraphicsDecoder

, P::Device) { .unwrap() .unwrap() .unwrap(); - reims_vgpu_core::platform::resource::Library::new_function(&library, o, "add_one") + reims_vgpu_vulkan::core::platform::resource::Library::new_function(&library, o, "add_one") .unwrap() .unwrap() }); @@ -264,7 +264,7 @@ fn measure(platform: &str) { #[test] #[ignore = "a measurement, run by hand in a release build: prints a close's cost an object"] fn on_fake_close_cost() { - measure::("the fake platform"); + measure::("the fake platform"); } /// On the Vulkan platform: the decoder's, the platform's and the runtime's. diff --git a/crates/reims-vgpu/src/graphics/decode/cmdbuf.rs b/crates/reims-vgpu/src/graphics/decode/cmdbuf.rs index 6a435c70a..5e0f19330 100644 --- a/crates/reims-vgpu/src/graphics/decode/cmdbuf.rs +++ b/crates/reims-vgpu/src/graphics/decode/cmdbuf.rs @@ -90,25 +90,6 @@ use std::mem::MaybeUninit; use std::sync::Arc; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder}; -use reims_vgpu_core::platform::caps::{DeviceCaps, SAMPLE_COUNTS}; -use reims_vgpu_core::platform::command::{ - CommandBuffer, CommandQueue, CompletedHandler, CompletedInfo, ScheduledHandler, -}; -use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder}; -use reims_vgpu_core::platform::descriptor::RenderPassDescriptor; -use reims_vgpu_core::platform::device::GpuDevice; -use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; -use reims_vgpu_core::platform::os::clock::{Clock as _, MonoTime}; -use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder, VertexDraw}; -use reims_vgpu_core::platform::resource::Buffer as _; -use reims_vgpu_core::platform::types::{ClearColor, MtlSamplePosition}; -use reims_vgpu_core::platform::values::{ - ColorAttachmentSet, ComputePassDesc, DepthAttachmentSet, PassSet, StencilAttachmentSet, -}; -use reims_vgpu_core::platform::{Handle, Platform}; -use reims_vgpu_core::raise::{OnFault, Raise, RaiseResult}; -use reims_vgpu_core::sync::Mutex; use reims_vgpu_graphics::ops::render::{ RGFX_OP_RENDER_DRAW_PRIMITIVES, RGFX_OP_RENDER_SET_VERTEX_BUFFER, RgfxOpDrawPrimitives, RgfxOpSetVertexBuffer, @@ -131,6 +112,25 @@ use reims_vgpu_graphics::wire::{ RGFX_EVT_CB_SCHEDULED, RGFX_EVT_CB_SUBMITTED, RGFX_EVT_EVENT_SIGNALLED, RgfxCbScheduled, RgfxCbSubmitted, RgfxEventSignalled, RgfxMsgHeader, }; +use reims_vgpu_vulkan::core::platform::blit::{BlitCmd, BlitEncoder}; +use reims_vgpu_vulkan::core::platform::caps::{DeviceCaps, SAMPLE_COUNTS}; +use reims_vgpu_vulkan::core::platform::command::{ + CommandBuffer, CommandQueue, CompletedHandler, CompletedInfo, ScheduledHandler, +}; +use reims_vgpu_vulkan::core::platform::compute::{ComputeCmd, ComputeEncoder}; +use reims_vgpu_vulkan::core::platform::descriptor::RenderPassDescriptor; +use reims_vgpu_vulkan::core::platform::device::GpuDevice; +use reims_vgpu_vulkan::core::platform::event::{EventRef, SharedEvent as _}; +use reims_vgpu_vulkan::core::platform::os::clock::{Clock as _, MonoTime}; +use reims_vgpu_vulkan::core::platform::render::{RenderCmd, RenderEncoder, VertexDraw}; +use reims_vgpu_vulkan::core::platform::resource::Buffer as _; +use reims_vgpu_vulkan::core::platform::types::{ClearColor, MtlSamplePosition}; +use reims_vgpu_vulkan::core::platform::values::{ + ColorAttachmentSet, ComputePassDesc, DepthAttachmentSet, PassSet, StencilAttachmentSet, +}; +use reims_vgpu_vulkan::core::platform::{Handle, Platform}; +use reims_vgpu_vulkan::core::raise::{OnFault, Raise, RaiseResult}; +use reims_vgpu_vulkan::core::sync::Mutex; use zerocopy::{FromBytes, IntoBytes}; use super::super::completion::{cb_complete, cb_failed, cb_unlanded}; @@ -206,7 +206,7 @@ impl Drop for Finisher { /// ([`RgfxEventSignalled`]). A signal the buffer runs more work after (an encoder, or a wait for /// an event: [`work_after`]) is posted by the platform's notification as the host's event reaches /// its value -/// ([`notify_listener`](reims_vgpu_core::platform::event::SharedEvent::notify_listener)): where +/// ([`notify_listener`](reims_vgpu_vulkan::core::platform::event::SharedEvent::notify_listener)): where /// the GPU gets to it in the buffer, as Metal's value and listeners move there (measured: /// docs/graphics-kext/dgpu-oracle.md, Q18). So a guest thread that waits on the CPU for it before /// it sets a value the buffer waits for later is released, where a post at the buffer's end would @@ -2655,14 +2655,6 @@ fn clear_color(bits: [u64; 4]) -> ClearColor { mod tests { use std::sync::Arc; - use reims_vgpu_core::platform::Handle; - use reims_vgpu_core::platform::descriptor::RenderPassDescriptor; - use reims_vgpu_core::platform::values::AttachmentState; - use reims_vgpu_core::sync::Mutex; - use reims_vgpu_core::testkit::FakePlatform; - use reims_vgpu_core::testkit::Step; - use reims_vgpu_core::testkit::calllog::Arg; - use reims_vgpu_core::testkit::objects::CompleteOn; use reims_vgpu_graphics::ops::render::{ RGFX_OP_RENDER_DRAW_INDEXED_PRIMITIVES, RGFX_OP_RENDER_DRAW_PRIMITIVES, RGFX_OP_RENDER_SET_FRAGMENT_TEXTURE, RGFX_OP_RENDER_SET_RENDER_PIPELINE_STATE, @@ -2687,6 +2679,14 @@ mod tests { RgfxTextureFromIOSurface, RgfxVideoSessionCreate, }; use reims_vgpu_video::core::device_memory::MemoryIdentity; + use reims_vgpu_vulkan::core::platform::Handle; + use reims_vgpu_vulkan::core::platform::descriptor::RenderPassDescriptor; + use reims_vgpu_vulkan::core::platform::values::AttachmentState; + use reims_vgpu_vulkan::core::sync::Mutex; + use reims_vgpu_vulkan::core::testkit::FakePlatform; + use reims_vgpu_vulkan::core::testkit::Step; + use reims_vgpu_vulkan::core::testkit::calllog::Arg; + use reims_vgpu_vulkan::core::testkit::objects::CompleteOn; use zerocopy::IntoBytes; use super::super::split::SPLIT_AFTER; @@ -3173,8 +3173,8 @@ mod tests { } impl GraphicsVideoSession for FakeSession { - fn event(&self) -> reims_vgpu_core::platform::event::EventRef<'_, FakePlatform> { - reims_vgpu_core::platform::event::EventRef::Shared(&self.event) + fn event(&self) -> reims_vgpu_vulkan::core::platform::event::EventRef<'_, FakePlatform> { + reims_vgpu_vulkan::core::platform::event::EventRef::Shared(&self.event) } fn codec(&self) -> u32 { @@ -4010,7 +4010,7 @@ mod tests { /// as `GPUStartTime` and `GPUEndTime`; a failed buffer the platform gives none of carries 0. #[test] fn a_completion_record_carries_the_platforms_gpu_times() { - use reims_vgpu_core::platform::types::{CommandBufferStatus, NsErrorText}; + use reims_vgpu_vulkan::core::platform::types::{CommandBufferStatus, NsErrorText}; let (p, mut dec) = setup(); let device = p.device(); let captured = Arc::new(Mutex::new(Vec::::new())); @@ -4116,7 +4116,7 @@ mod tests { /// One whose submission handler ran has them posted there, once. #[test] fn a_buffer_never_submitted_is_scheduled_ahead_of_its_completion() { - use reims_vgpu_core::platform::types::CommandBufferStatus; + use reims_vgpu_vulkan::core::platform::types::CommandBufferStatus; let (_p, dec, posted) = posting(true); for ran in [false, true] { posted.lock().clear(); @@ -4849,7 +4849,7 @@ mod tests { /// queue, and its failure comes after that buffer's completion. #[test] fn a_refused_make_after_an_answer_fails_in_turn() { - use reims_vgpu_core::testkit::script::Step; + use reims_vgpu_vulkan::core::testkit::script::Step; let (p, mut dec, posted) = posting(false); let device = p.device(); @@ -4922,14 +4922,14 @@ mod tests { fn a_later_commit_on_another_queue() -> (bool, Vec) { use std::time::{Duration, Instant}; - use reims_vgpu_core::platform::resource::Buffer as _; use reims_vgpu_graphics::ops::blit::{ RGFX_OP_BLIT_COPY_BUFFER_TO_BUFFER, RGFX_OP_BLIT_FILL_BUFFER, RgfxBlitOpCopyBufferToBuffer, RgfxBlitOpFillBuffer, }; use reims_vgpu_graphics::wire::RgfxSharedEventSetValue; + use reims_vgpu_vulkan::core::platform::resource::Buffer as _; const LEN: u64 = 1 << 20; - let _pool = reims_vgpu_core::rt::Pool::here(); + let _pool = reims_vgpu_vulkan::core::rt::Pool::here(); let platform = P::process(); let device = platform.metal_device(None).unwrap(); let mut dec = GraphicsDecoder::

::new( @@ -5067,7 +5067,7 @@ mod tests { use reims_vgpu_graphics::ops::blit::{RGFX_OP_BLIT_FILL_BUFFER, RgfxBlitOpFillBuffer}; const LEN: u64 = 1 << 20; - let _pool = reims_vgpu_core::rt::Pool::here(); + let _pool = reims_vgpu_vulkan::core::rt::Pool::here(); let platform = P::process(); let device = platform.metal_device(None).unwrap(); let mut dec = GraphicsDecoder::

::new( @@ -5188,13 +5188,13 @@ mod tests { -> Vec { use std::time::{Duration, Instant}; - use reims_vgpu_core::platform::resource::Buffer as _; use reims_vgpu_graphics::ops::blit::{ RGFX_OP_BLIT_COPY_BUFFER_TO_BUFFER, RGFX_OP_BLIT_FILL_BUFFER, RgfxBlitOpCopyBufferToBuffer, RgfxBlitOpFillBuffer, }; + use reims_vgpu_vulkan::core::platform::resource::Buffer as _; const LEN: u64 = 1 << 20; - let _pool = reims_vgpu_core::rt::Pool::here(); + let _pool = reims_vgpu_vulkan::core::rt::Pool::here(); let platform = P::process(); let device = platform.metal_device(None).unwrap(); let mut dec = GraphicsDecoder::

::new( @@ -5266,7 +5266,7 @@ mod tests { std::thread::scope(|scope| { let device = &device; let taken_first = scope.spawn(|| { - let _pool = reims_vgpu_core::rt::Pool::here(); + let _pool = reims_vgpu_vulkan::core::rt::Pool::here(); let begun = second.begin_taken(device, &b, Some(2)).unwrap().unwrap(); let done = second.finish_command_buffer(device, &b, begun).unwrap(); second.end_message(); @@ -5334,14 +5334,14 @@ mod tests { -> (Vec, bool, Vec, Vec) { use std::time::{Duration, Instant}; - use reims_vgpu_core::platform::resource::Buffer as _; use reims_vgpu_graphics::ops::blit::{ RGFX_OP_BLIT_COPY_BUFFER_TO_BUFFER, RGFX_OP_BLIT_FILL_BUFFER, RgfxBlitOpCopyBufferToBuffer, RgfxBlitOpFillBuffer, }; use reims_vgpu_graphics::wire::RgfxSharedEventSetValue; + use reims_vgpu_vulkan::core::platform::resource::Buffer as _; const LEN: u64 = 1 << 20; - let _pool = reims_vgpu_core::rt::Pool::here(); + let _pool = reims_vgpu_vulkan::core::rt::Pool::here(); let platform = P::process(); let device = platform.metal_device(None).unwrap(); let mut dec = GraphicsDecoder::

::new( @@ -5495,13 +5495,13 @@ mod tests { fn sub_encoders_after_a_count() -> [u64; 4] { use std::time::{Duration, Instant}; - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::platform::values::{RenderPipelineDesc, TextureDesc}; + use reims_vgpu_vulkan::core::platform::resource::Buffer as _; + use reims_vgpu_vulkan::core::platform::values::{RenderPipelineDesc, TextureDesc}; use super::super::draw_cost::fixture; const SIDE: u64 = 64; const BGRA8: u64 = 80; - let _pool = reims_vgpu_core::rt::Pool::here(); + let _pool = reims_vgpu_vulkan::core::rt::Pool::here(); let platform = P::process(); let device = platform.metal_device(None).unwrap(); let mut dec = GraphicsDecoder::

::new( @@ -5744,7 +5744,7 @@ mod tests { fn on_vulkan_a_pin_meets_no_range_of_a_texture_buffer() { use reims_vgpu_graphics::wire::RGFX_CONTEXT_VA_BASE; let _pins = CONTEXT_RANGE_PINS.lock(); - let _pool = reims_vgpu_core::rt::Pool::here(); + let _pool = reims_vgpu_vulkan::core::rt::Pool::here(); let (mut dec, device) = decoder_with_a_texture_buffer(); let buffer = buffer_at(11, RGFX_CONTEXT_VA_BASE + 0x8000, 0x1_0000); assert_eq!(dec.decode(&device, buffer.as_bytes()).unwrap(), Ok(())); @@ -5756,12 +5756,12 @@ mod tests { /// are made. #[test] fn on_vulkan_the_host_s_own_ranges_lie_below_every_unit() { - use reims_vgpu_core::platform::resource::Buffer as _; use reims_vgpu_graphics::wire::{ RGFX_CONTEXT_VA_BASE, RGFX_CONTEXT_VA_END, RGFX_CONTEXT_VA_UNIT, RGFX_CONTEXT_VA_UNITS, }; + use reims_vgpu_vulkan::core::platform::resource::Buffer as _; let _pins = CONTEXT_RANGE_PINS.lock(); - let _pool = reims_vgpu_core::rt::Pool::here(); + let _pool = reims_vgpu_vulkan::core::rt::Pool::here(); let (mut dec, device) = decoder_with_a_texture_buffer(); let placed = buffer_at(11, 0, 64 << 20); assert_eq!(dec.decode(&device, placed.as_bytes()).unwrap(), Ok(())); @@ -5808,7 +5808,7 @@ mod tests { /// the flag sets none. #[test] fn a_render_pass_takes_its_sample_positions() { - use reims_vgpu_core::testkit::impls::descriptor::PassModel; + use reims_vgpu_vulkan::core::testkit::impls::descriptor::PassModel; let (p, dec) = setup(); let mut caps = (*p.device().caps()).clone(); caps.sample_counts = [Ok(true), Ok(true), Ok(true), Ok(false)]; @@ -5910,7 +5910,7 @@ mod tests { /// neither. #[test] fn a_render_pass_takes_its_visibility_result_buffer() { - use reims_vgpu_core::testkit::impls::descriptor::PassModel; + use reims_vgpu_vulkan::core::testkit::impls::descriptor::PassModel; let (_p, dec) = setup(); let Some(ObjHandle::Buffer(buffer)) = dec.object(2) else { panic!("no buffer 2"); @@ -6260,11 +6260,11 @@ mod tests { /// stands in for the GPU reaching the signal. So does a stand-in's signal before its wait. #[test] fn a_signal_before_more_of_its_buffer_goes_as_the_event_reaches_it() { - use reims_vgpu_core::platform::event::SharedEvent as _; use reims_vgpu_graphics::ops::compute::{ RGFX_OP_COMPUTE_SET_COMPUTE_PIPELINE_STATE, RgfxComputeOpSetComputePipelineState, }; use reims_vgpu_graphics::wire::RGFX_CB_INTERNAL; + use reims_vgpu_vulkan::core::platform::event::SharedEvent as _; let (p, mut dec) = setup(); let device = p.device(); create_events(&p, &mut dec, 0); @@ -6689,7 +6689,10 @@ mod tests { /// A gate the first walk to reach it stops at, after its op `at`, until the test opens it. /// Whether a walk took the gate, stopped at it, and whether it is open; and their moves. - type GateState = Arc<(Mutex<(bool, bool, bool)>, reims_vgpu_core::sync::Condvar)>; + type GateState = Arc<( + Mutex<(bool, bool, bool)>, + reims_vgpu_vulkan::core::sync::Condvar, + )>; struct Gate(GateState); @@ -6698,7 +6701,7 @@ mod tests { fn on(dec: &GraphicsDecoder, at: usize) -> Gate { let state = Arc::new(( Mutex::new((false, false, false)), - reims_vgpu_core::sync::Condvar::new(), + reims_vgpu_vulkan::core::sync::Condvar::new(), )); let hook = Arc::clone(&state); dec.set_walk_hook(Some(Arc::new(move |index: usize| { @@ -7108,7 +7111,7 @@ mod tests { /// that failed. #[test] fn a_buffer_walked_long_is_committed_in_parts_with_one_outcome() { - use reims_vgpu_core::platform::types::{CommandBufferStatus, NsErrorText}; + use reims_vgpu_vulkan::core::platform::types::{CommandBufferStatus, NsErrorText}; let Split { p, mut dec, @@ -7366,7 +7369,7 @@ mod tests { /// completion, after its last part, never at a part's. #[test] fn a_split_after_a_mid_buffer_signal_keeps_the_signal_before_the_cut() { - use reims_vgpu_core::platform::types::CommandBufferStatus; + use reims_vgpu_vulkan::core::platform::types::CommandBufferStatus; let Split { p, mut dec, posted, .. } = splitting(); diff --git a/crates/reims-vgpu/src/graphics/decode/commit_order.rs b/crates/reims-vgpu/src/graphics/decode/commit_order.rs index c1b050dd2..d77f10cf5 100644 --- a/crates/reims-vgpu/src/graphics/decode/commit_order.rs +++ b/crates/reims-vgpu/src/graphics/decode/commit_order.rs @@ -40,7 +40,7 @@ use std::sync::Arc; use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}; use std::time::Duration; -use reims_vgpu_core::sync::{Condvar, Mutex}; +use reims_vgpu_vulkan::core::sync::{Condvar, Mutex}; use super::surface_order::Marks; @@ -214,8 +214,6 @@ mod tests { use std::thread::JoinHandle; use std::time::{Duration, Instant}; - use reims_vgpu_core::sync::Mutex; - use reims_vgpu_core::testkit::FakePlatform; use reims_vgpu_graphics::ops::{ RGFX_COMMAND_BUFFER_OPS_OFFSET, RGFX_OP_COMMIT_ORDER, RGFX_OP_SUBMITTED, RgfxCommandBuffer, RgfxOpHeader, RgfxSurfaceOrderWait, @@ -224,6 +222,8 @@ mod tests { RGFX_CMD_COMMAND_BUFFER, RGFX_CMD_OBJECT_DESTROY, RGFX_CMD_QUEUE_CREATE, RGFX_CONTEXT_OBJ_ID_SHIFT, RgfxMsgHeader, RgfxObjectDestroy, RgfxQueueCreate, }; + use reims_vgpu_vulkan::core::sync::Mutex; + use reims_vgpu_vulkan::core::testkit::FakePlatform; use zerocopy::IntoBytes; use super::super::{DecodeError, GraphicsDecoder}; @@ -541,7 +541,7 @@ mod tests { /// failure is posted. #[test] fn a_buffer_named_whose_begin_fails_lets_the_buffer_that_names_it_go_on() { - use reims_vgpu_core::testkit::Step; + use reims_vgpu_vulkan::core::testkit::Step; use zerocopy::FromBytes; for how in ["op_bytes", "short", "refused"] { diff --git a/crates/reims-vgpu/src/graphics/decode/composite_cost.rs b/crates/reims-vgpu/src/graphics/decode/composite_cost.rs index 189a410b2..56fc10b6f 100644 --- a/crates/reims-vgpu/src/graphics/decode/composite_cost.rs +++ b/crates/reims-vgpu/src/graphics/decode/composite_cost.rs @@ -34,9 +34,6 @@ use std::sync::Arc; use std::sync::mpsc; use std::time::{Duration, Instant}; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::values::{FullRenderPipelineDesc, SamplerDesc, TextureDesc}; -use reims_vgpu_core::raise::OnFault; use reims_vgpu_graphics::ops::render::{ RGFX_OP_RENDER_DRAW_PRIMITIVES, RGFX_OP_RENDER_MEMORY_BARRIER_WITH_SCOPE, RGFX_OP_RENDER_SET_FRAGMENT_SAMPLER_STATES, RGFX_OP_RENDER_SET_FRAGMENT_TEXTURE, @@ -55,6 +52,9 @@ use reims_vgpu_graphics::wire::{ RGFX_CONTEXT_ALLOCATIONS_OFFSET, RGFX_CURSOR_SPAN, RgfxBufferOverHostMemory, RgfxCbComplete, RgfxMsgHeader, RgfxQueueCreate, }; +use reims_vgpu_vulkan::core::platform::device::GpuDevice as _; +use reims_vgpu_vulkan::core::platform::values::{FullRenderPipelineDesc, SamplerDesc, TextureDesc}; +use reims_vgpu_vulkan::core::raise::OnFault; use zerocopy::IntoBytes; use super::draw_cost::{counts, fixture, over, spread}; @@ -313,7 +313,7 @@ impl Bench

{ } let mut decoder = GraphicsDecoder::

::new(Arc::clone(&platform), Arc::new(region)); let (tx, completed) = mpsc::channel(); - let tx = reims_vgpu_core::sync::Mutex::new(tx); + let tx = reims_vgpu_vulkan::core::sync::Mutex::new(tx); decoder.set_completion_sink(Arc::new(move |m| { let _ = tx.lock().send((m, Instant::now())); })); @@ -406,7 +406,7 @@ impl Bench

{ #[allow(clippy::disallowed_methods)] // a measurement: real time is what it measures fn measure(name: &str, mut bench: Bench

) { let shape = bench.shape; - let _pool = reims_vgpu_core::rt::Pool::here(); + let _pool = reims_vgpu_vulkan::core::rt::Pool::here(); // On a Mac, the thread asks for the performance cores, as a lane's thread is mostly on one. #[cfg(target_os = "macos")] // SAFETY: sets this thread's own class, which takes no pointer. diff --git a/crates/reims-vgpu/src/graphics/decode/compute.rs b/crates/reims-vgpu/src/graphics/decode/compute.rs index 69fc3b579..b1f372748 100644 --- a/crates/reims-vgpu/src/graphics/decode/compute.rs +++ b/crates/reims-vgpu/src/graphics/decode/compute.rs @@ -16,11 +16,6 @@ //! //! [`RGFX_OP_GROUP_COMPUTE`]: reims_vgpu_graphics::ops::RGFX_OP_GROUP_COMPUTE -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::blit::ResourceRef; -use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder}; -use reims_vgpu_core::platform::types::{MtlOrigin, MtlRegion, MtlSize, NsRange}; -use reims_vgpu_core::raise::{OnFault, Raise, RaiseResult}; use reims_vgpu_graphics::ops::compute::{ RGFX_OP_COMPUTE_COMPRESSED_TEXTURE_REINTERPRETATION_FLUSH, RGFX_OP_COMPUTE_DISPATCH_THREADGROUPS, RGFX_OP_COMPUTE_DISPATCH_THREADGROUPS_INDIRECT, @@ -54,6 +49,11 @@ use reims_vgpu_graphics::ops::compute::{ RgfxComputeOpUseResources, RgfxComputeOpWaitForFence, RgfxComputeResourceRef, RgfxComputeSamplerBinding, RgfxComputeSamplerLodBinding, RgfxComputeTextureBinding, }; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::platform::blit::ResourceRef; +use reims_vgpu_vulkan::core::platform::compute::{ComputeCmd, ComputeEncoder}; +use reims_vgpu_vulkan::core::platform::types::{MtlOrigin, MtlRegion, MtlSize, NsRange}; +use reims_vgpu_vulkan::core::raise::{OnFault, Raise, RaiseResult}; use zerocopy::{FromBytes, Immutable}; use super::refused::{self, Bound, Marks, Slot, Stage}; @@ -612,18 +612,18 @@ pub(crate) fn decode_op( mod tests { use std::sync::Arc; - use reims_vgpu_core::platform::Handle; - use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue}; - use reims_vgpu_core::platform::device::GpuDevice; - use reims_vgpu_core::platform::values::ComputePassDesc; - use reims_vgpu_core::raise::OnFault; - use reims_vgpu_core::testkit::FakePlatform; - use reims_vgpu_core::testkit::calllog::Arg; use reims_vgpu_graphics::wire::{ RGFX_CMD_BUFFER_CREATE, RGFX_CMD_FENCE_CREATE, RGFX_CMD_QUEUE_CREATE, RGFX_CMD_TEXTURE_CREATE, RgfxBufferCreate, RgfxMsgHeader, RgfxObjectCreate, RgfxQueueCreate, RgfxTextureCreate, RgfxTextureDescriptor, }; + use reims_vgpu_vulkan::core::platform::Handle; + use reims_vgpu_vulkan::core::platform::command::{CommandBuffer, CommandQueue}; + use reims_vgpu_vulkan::core::platform::device::GpuDevice; + use reims_vgpu_vulkan::core::platform::values::ComputePassDesc; + use reims_vgpu_vulkan::core::raise::OnFault; + use reims_vgpu_vulkan::core::testkit::FakePlatform; + use reims_vgpu_vulkan::core::testkit::calllog::Arg; use zerocopy::IntoBytes; use super::*; diff --git a/crates/reims-vgpu/src/graphics/decode/draw_cost.rs b/crates/reims-vgpu/src/graphics/decode/draw_cost.rs index 37df14c84..2fc316033 100644 --- a/crates/reims-vgpu/src/graphics/decode/draw_cost.rs +++ b/crates/reims-vgpu/src/graphics/decode/draw_cost.rs @@ -31,17 +31,6 @@ use std::sync::Arc; use std::sync::mpsc; use std::time::{Duration, Instant}; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; -use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _, VertexDraw}; -use reims_vgpu_core::platform::resource::Library as _; -use reims_vgpu_core::platform::types::NsRange; -use reims_vgpu_core::platform::values::{ - ColorAttachmentDesc, ColorAttachmentSet, FullRenderPipelineDesc, SamplerDesc, TextureDesc, -}; -use reims_vgpu_core::raise::OnFault; use reims_vgpu_graphics::ops::render::{ RGFX_OP_RENDER_DRAW_PRIMITIVES, RGFX_OP_RENDER_SET_FRAGMENT_BUFFER, RGFX_OP_RENDER_SET_FRAGMENT_SAMPLER_STATES, RGFX_OP_RENDER_SET_FRAGMENT_TEXTURE, @@ -60,6 +49,17 @@ use reims_vgpu_graphics::wire::{ RGFX_CONTEXT_ALLOCATIONS_OFFSET, RGFX_CURSOR_SPAN, RgfxBufferOverHostMemory, RgfxMsgHeader, RgfxQueueCreate, }; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::platform::command::{CommandBuffer as _, CommandQueue as _}; +use reims_vgpu_vulkan::core::platform::descriptor::RenderPassDescriptor as _; +use reims_vgpu_vulkan::core::platform::device::GpuDevice as _; +use reims_vgpu_vulkan::core::platform::render::{RenderCmd, RenderEncoder as _, VertexDraw}; +use reims_vgpu_vulkan::core::platform::resource::Library as _; +use reims_vgpu_vulkan::core::platform::types::NsRange; +use reims_vgpu_vulkan::core::platform::values::{ + ColorAttachmentDesc, ColorAttachmentSet, FullRenderPipelineDesc, SamplerDesc, TextureDesc, +}; +use reims_vgpu_vulkan::core::raise::OnFault; use zerocopy::IntoBytes; use super::{GraphicsDecoder, ObjHandle}; @@ -562,7 +562,7 @@ impl Bench

{ let region = reims_vgpu_graphics::region::Region::new(region_size as usize).unwrap(); let mut decoder = GraphicsDecoder::

::new(Arc::clone(&platform), Arc::new(region)); let (tx, completed) = mpsc::channel(); - let tx = reims_vgpu_core::sync::Mutex::new(tx); + let tx = reims_vgpu_vulkan::core::sync::Mutex::new(tx); decoder.set_completion_sink(Arc::new(move |m| { let _ = tx.lock().send(m.cb_obj_id); })); @@ -990,7 +990,7 @@ fn measure( }) .collect::>() }; - let _pool = reims_vgpu_core::rt::Pool::here(); + let _pool = reims_vgpu_vulkan::core::rt::Pool::here(); // On a Mac, the thread asks for the performance cores, which an efficiency core's slower // draws would otherwise mix into the figures. #[cfg(target_os = "macos")] diff --git a/crates/reims-vgpu/src/graphics/decode/fuzz.rs b/crates/reims-vgpu/src/graphics/decode/fuzz.rs index 66da7b532..93faeed4c 100644 --- a/crates/reims-vgpu/src/graphics/decode/fuzz.rs +++ b/crates/reims-vgpu/src/graphics/decode/fuzz.rs @@ -26,9 +26,6 @@ use std::collections::HashMap; use std::sync::Arc; -use reims_vgpu_core::sync::Mutex; -use reims_vgpu_core::testkit::FakePlatform; -use reims_vgpu_core::testkit::objects::CompleteOn; use reims_vgpu_graphics::ops::{ RGFX_COMMAND_BUFFER_OPS_OFFSET, RGFX_OP_ENCODER_BEGIN_BLIT, RGFX_OP_ENCODER_BEGIN_COMPUTE, RGFX_OP_ENCODER_BEGIN_RENDER, RGFX_OP_ENCODER_END, RGFX_OP_SUBMITTED, RGFX_PASS_FLAG_RT_SIZE, @@ -42,6 +39,9 @@ use reims_vgpu_graphics::wire::{ RgfxCbScheduled, RgfxMsgHeader, RgfxObjectCreate, RgfxQueueCreate, RgfxSharedEventCreate, RgfxTextureCreate, RgfxTextureDescriptor, }; +use reims_vgpu_vulkan::core::sync::Mutex; +use reims_vgpu_vulkan::core::testkit::FakePlatform; +use reims_vgpu_vulkan::core::testkit::objects::CompleteOn; use zerocopy::{FromBytes, IntoBytes}; use super::{DecodeError, GraphicsDecoder, ObjHandle, refusing}; @@ -543,7 +543,7 @@ impl Outcomes { fn add( &mut self, r#type: u32, - outcome: &reims_vgpu_core::raise::RaiseResult>, + outcome: &reims_vgpu_vulkan::core::raise::RaiseResult>, ) { let r#type = if (0x200..0x400).contains(&r#type) { r#type diff --git a/crates/reims-vgpu/src/graphics/decode/handler_cost.rs b/crates/reims-vgpu/src/graphics/decode/handler_cost.rs index 9c9830516..157be6f4c 100644 --- a/crates/reims-vgpu/src/graphics/decode/handler_cost.rs +++ b/crates/reims-vgpu/src/graphics/decode/handler_cost.rs @@ -17,11 +17,13 @@ use std::sync::mpsc; use std::time::Duration; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; -use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _, CompletedInfo}; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::types::NsRange; -use reims_vgpu_core::raise::OnFault; +use reims_vgpu_vulkan::core::platform::blit::{BlitCmd, BlitEncoder as _}; +use reims_vgpu_vulkan::core::platform::command::{ + CommandBuffer as _, CommandQueue as _, CompletedInfo, +}; +use reims_vgpu_vulkan::core::platform::device::GpuDevice as _; +use reims_vgpu_vulkan::core::platform::types::NsRange; +use reims_vgpu_vulkan::core::raise::OnFault; use crate::platform::ApiPlatform; diff --git a/crates/reims-vgpu/src/graphics/decode/icb.rs b/crates/reims-vgpu/src/graphics/decode/icb.rs index 5291c2ca9..905f04cae 100644 --- a/crates/reims-vgpu/src/graphics/decode/icb.rs +++ b/crates/reims-vgpu/src/graphics/decode/icb.rs @@ -19,14 +19,6 @@ //! and dispatches are dropped until the guest resets it ([`Dropped`]). Nothing else of the //! buffer changes, and the command buffers that execute it go on. -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::device::GpuDevice; -use reims_vgpu_core::platform::icb::{ - IcbComputeCmd, IcbRenderCmd, IndirectCommandBuffer, IndirectComputeCommand, - IndirectRenderCommand, -}; -use reims_vgpu_core::platform::types::{MtlOrigin, MtlRegion, MtlSize}; -use reims_vgpu_core::platform::values::IcbDesc; use reims_vgpu_graphics::icb::*; use reims_vgpu_graphics::wire::{ RGFX_EVT_ICB_STATE, RGFX_ICB_INHERIT_BLEND_COLOR, RGFX_ICB_INHERIT_BUFFERS, @@ -39,11 +31,19 @@ use reims_vgpu_graphics::wire::{ RGFX_STATUS_INVALID_ARGUMENT, RGFX_STATUS_OK, RGFX_STATUS_REFUSED, RgfxIcbCreate, RgfxIcbSlotRun, RgfxIcbSlots, RgfxIcbState, RgfxIcbWrite, RgfxMsgHeader, }; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::platform::device::GpuDevice; +use reims_vgpu_vulkan::core::platform::icb::{ + IcbComputeCmd, IcbRenderCmd, IndirectCommandBuffer, IndirectComputeCommand, + IndirectRenderCommand, +}; +use reims_vgpu_vulkan::core::platform::types::{MtlOrigin, MtlRegion, MtlSize}; +use reims_vgpu_vulkan::core::platform::values::IcbDesc; use std::collections::BTreeSet; use std::sync::atomic::{AtomicUsize, Ordering}; -use reims_vgpu_core::raise::RaiseResult; -use reims_vgpu_core::sync::Mutex; +use reims_vgpu_vulkan::core::raise::RaiseResult; +use reims_vgpu_vulkan::core::sync::Mutex; use zerocopy::{FromBytes, IntoBytes}; use super::{DecodeError, Entry, GraphicsDecoder, ObjHandle, op_fault, read, refused, refusing}; @@ -1061,11 +1061,11 @@ fn slot_fields( mod tests { use std::sync::Arc; - use reims_vgpu_core::platform::Handle; - use reims_vgpu_core::testkit::{Arg, FakePlatform, Step}; use reims_vgpu_graphics::wire::{ RGFX_CMD_BUFFER_CREATE, RGFX_CMD_ICB_CREATE, RGFX_CMD_ICB_WRITE, RgfxBufferCreate, }; + use reims_vgpu_vulkan::core::platform::Handle; + use reims_vgpu_vulkan::core::testkit::{Arg, FakePlatform, Step}; use zerocopy::{Immutable, IntoBytes}; use reims_vgpu_graphics::region::Region; diff --git a/crates/reims-vgpu/src/graphics/decode/icb_slots_cost.rs b/crates/reims-vgpu/src/graphics/decode/icb_slots_cost.rs index e7897ee3e..e84a1bba8 100644 --- a/crates/reims-vgpu/src/graphics/decode/icb_slots_cost.rs +++ b/crates/reims-vgpu/src/graphics/decode/icb_slots_cost.rs @@ -21,20 +21,6 @@ use std::sync::Arc; -use reims_vgpu_core::platform::blit::ResourceRef; -use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; -use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::icb::{ - IcbRenderCmd, IndirectCommandBuffer as _, IndirectRenderCommand as _, -}; -use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; -use reims_vgpu_core::platform::types::NsRange; -use reims_vgpu_core::platform::values::{ - ColorAttachmentDesc, ColorAttachmentSet, FullRenderPipelineDesc, LinkedFunctionsDesc, - TextureDesc, -}; -use reims_vgpu_core::raise::OnFault; use reims_vgpu_graphics::icb::{ RGFX_ICB_OP_DRAW, RGFX_ICB_SLOT_ACTION, RGFX_ICB_SLOT_BUFFER_0, RGFX_ICB_SLOT_PIPELINE, RgfxIcbDraw, RgfxIcbRenderSlot, RgfxIcbSlotBuffer, @@ -44,6 +30,20 @@ use reims_vgpu_graphics::wire::{ RGFX_CMD_ICB_CREATE, RGFX_CMD_ICB_SLOTS, RGFX_CONTEXT_ALLOCATIONS_OFFSET, RGFX_CURSOR_SPAN, RGFX_ICB_SLOTS_RENDER, RgfxIcbCreate, RgfxIcbSlotRun, RgfxIcbSlots, RgfxMsgHeader, }; +use reims_vgpu_vulkan::core::platform::blit::ResourceRef; +use reims_vgpu_vulkan::core::platform::command::{CommandBuffer as _, CommandQueue as _}; +use reims_vgpu_vulkan::core::platform::descriptor::RenderPassDescriptor as _; +use reims_vgpu_vulkan::core::platform::device::GpuDevice as _; +use reims_vgpu_vulkan::core::platform::icb::{ + IcbRenderCmd, IndirectCommandBuffer as _, IndirectRenderCommand as _, +}; +use reims_vgpu_vulkan::core::platform::render::{RenderCmd, RenderEncoder as _}; +use reims_vgpu_vulkan::core::platform::types::NsRange; +use reims_vgpu_vulkan::core::platform::values::{ + ColorAttachmentDesc, ColorAttachmentSet, FullRenderPipelineDesc, LinkedFunctionsDesc, + TextureDesc, +}; +use reims_vgpu_vulkan::core::raise::OnFault; use zerocopy::IntoBytes; use super::draw_cost::{Counts, FIGURES, counts, fixture, spread}; @@ -389,7 +389,7 @@ fn measure( let only = only.as_deref(); let message = message(); let executed = std::env::var("ICB_SLOTS_COST_EXECUTED").is_ok_and(|v| v == "1"); - let _pool = reims_vgpu_core::rt::Pool::here(); + let _pool = reims_vgpu_vulkan::core::rt::Pool::here(); #[cfg(target_os = "macos")] // SAFETY: sets this thread's own class, which takes no pointer. unsafe { diff --git a/crates/reims-vgpu/src/graphics/decode/lane.rs b/crates/reims-vgpu/src/graphics/decode/lane.rs index c4224994a..d48697709 100644 --- a/crates/reims-vgpu/src/graphics/decode/lane.rs +++ b/crates/reims-vgpu/src/graphics/decode/lane.rs @@ -52,8 +52,8 @@ use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; use std::time::Duration; -use reims_vgpu_core::platform::os::Threads; -use reims_vgpu_core::sync::{Condvar, Mutex}; +use reims_vgpu_vulkan::core::platform::os::Threads; +use reims_vgpu_vulkan::core::sync::{Condvar, Mutex}; /// The most threads a lane runs its jobs on at once: its own and the budget's. pub(crate) const LANE_THREADS: usize = 4; @@ -643,7 +643,9 @@ mod tests { Arc::new(HintLog(Arc::clone(&self.0))) } - fn timer_clock(&self) -> Option> { + fn timer_clock( + &self, + ) -> Option> { None } } diff --git a/crates/reims-vgpu/src/graphics/decode/library.rs b/crates/reims-vgpu/src/graphics/decode/library.rs index 3f9122c9a..8c7093812 100644 --- a/crates/reims-vgpu/src/graphics/decode/library.rs +++ b/crates/reims-vgpu/src/graphics/decode/library.rs @@ -31,16 +31,16 @@ use std::collections::{BTreeMap, HashMap}; use std::sync::Arc; -use reims_vgpu_core::platform::device::GpuDevice; -use reims_vgpu_core::platform::{Handle, Platform}; -use reims_vgpu_core::raise::RaiseResult; -use reims_vgpu_core::sync::{Condvar, Mutex}; use reims_vgpu_graphics::wire::{ RGFX_CMD_LIBRARY_CREATE, RGFX_CMD_LIBRARY_FROM_REGION, RGFX_EVT_COMPLETE, RGFX_LIBRARY_BYTES_OFFSET, RGFX_LIBRARY_FLAG_KEYED, RGFX_STATUS_INVALID_ARGUMENT, RGFX_STATUS_NOT_FOUND, RGFX_STATUS_OK, RGFX_STATUS_REFUSED, RgfxComplete, RgfxLibraryCreate, RgfxLibraryFromRegion, RgfxLibraryLookup, RgfxMsgHeader, }; +use reims_vgpu_vulkan::core::platform::device::GpuDevice; +use reims_vgpu_vulkan::core::platform::{Handle, Platform}; +use reims_vgpu_vulkan::core::raise::RaiseResult; +use reims_vgpu_vulkan::core::sync::{Condvar, Mutex}; use sha2::{Digest, Sha256}; use reims_vgpu_graphics::wire::RGFX_CONTEXT_OBJ_ID_SHIFT; @@ -833,7 +833,7 @@ pub(crate) mod tests { /// leaves the list, and named entries are never dropped #[test] fn the_released_list_keeps_to_its_budget() { - use reims_vgpu_core::testkit::FakePlatform; + use reims_vgpu_vulkan::core::testkit::FakePlatform; let platform = FakePlatform::new(); let device = platform.device(); let library = || device.new_library(&[1]).unwrap().unwrap().unwrap(); diff --git a/crates/reims-vgpu/src/graphics/decode/managed.rs b/crates/reims-vgpu/src/graphics/decode/managed.rs index 7e17ba6df..69b093381 100644 --- a/crates/reims-vgpu/src/graphics/decode/managed.rs +++ b/crates/reims-vgpu/src/graphics/decode/managed.rs @@ -52,20 +52,20 @@ use std::ptr; use std::sync::Arc; -use reims_vgpu_core::host::HostPtr; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder}; -use reims_vgpu_core::platform::device::GpuDevice; -use reims_vgpu_core::platform::resource::{Buffer, Heap, Texture}; -use reims_vgpu_core::platform::types::{MtlOrigin, MtlRegion, MtlSize, NsRange}; -use reims_vgpu_core::platform::values::{BufferDesc, OptionSet}; -use reims_vgpu_core::platform::{Handle, HostRange, Platform}; -use reims_vgpu_core::raise::{OnFault, RaiseResult}; use reims_vgpu_graphics::managed::LinearLayout; use reims_vgpu_graphics::wire::{ RGFX_MANAGED_TEXTURE_LINEAR, RgfxBufferDidModifyRange, RgfxBufferManagedAtOffset, RgfxBufferOverHostMemory, RgfxManagedBufferCreate, RgfxManagedTextureCreate, RgfxTextureReplaceRegion, }; +use reims_vgpu_vulkan::core::host::HostPtr; +use reims_vgpu_vulkan::core::platform::blit::{BlitCmd, BlitEncoder}; +use reims_vgpu_vulkan::core::platform::device::GpuDevice; +use reims_vgpu_vulkan::core::platform::resource::{Buffer, Heap, Texture}; +use reims_vgpu_vulkan::core::platform::types::{MtlOrigin, MtlRegion, MtlSize, NsRange}; +use reims_vgpu_vulkan::core::platform::values::{BufferDesc, OptionSet}; +use reims_vgpu_vulkan::core::platform::{Handle, HostRange, Platform}; +use reims_vgpu_vulkan::core::raise::{OnFault, RaiseResult}; use super::tables::{Entry, GuestBytes}; use super::{DecodeError, Drain, GraphicsDecoder, ObjHandle, op_fault, read, texture_desc}; @@ -812,8 +812,6 @@ impl GraphicsDecoder

{ mod tests { use std::sync::Arc; - use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue}; - use reims_vgpu_core::testkit::{Arg, FakePlatform, GuestRam, Step}; use reims_vgpu_graphics::ops::blit::{ RGFX_BLIT_RESOURCE_BUFFER, RGFX_BLIT_RESOURCE_TEXTURE, RGFX_OP_BLIT_SYNCHRONIZE_RESOURCE, RGFX_OP_BLIT_SYNCHRONIZE_TEXTURE, RgfxBlitOpSynchronizeResource, @@ -829,6 +827,8 @@ mod tests { RGFX_SURFACE_PAGES_PRIVATE, RgfxBufferAtOffset, RgfxBufferOverPages, RgfxHeapOverHostMemory, RgfxMsgHeader, RgfxObjectDestroy, RgfxTextureDescriptor, }; + use reims_vgpu_vulkan::core::platform::command::{CommandBuffer, CommandQueue}; + use reims_vgpu_vulkan::core::testkit::{Arg, FakePlatform, GuestRam, Step}; use zerocopy::IntoBytes; use super::super::blit::decode_op; @@ -1968,10 +1968,10 @@ mod tests { /// the copy after a blit wrote 0x5a into slice 1 and synchronized it, as a guest does (the GPU /// writes it there, slices 0 and 2 kept). fn managed_array_in_place_on() -> (Vec, Vec) { - use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::device::GpuDevice as _; - use reims_vgpu_core::platform::resource::Buffer as _; + use reims_vgpu_vulkan::core::platform::blit::{BlitCmd, BlitEncoder as _}; + use reims_vgpu_vulkan::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use reims_vgpu_vulkan::core::platform::device::GpuDevice as _; + use reims_vgpu_vulkan::core::platform::resource::Buffer as _; const W: u64 = 48; const H: u64 = 16; diff --git a/crates/reims-vgpu/src/graphics/decode/mod.rs b/crates/reims-vgpu/src/graphics/decode/mod.rs index 9b54f11ce..b787feded 100644 --- a/crates/reims-vgpu/src/graphics/decode/mod.rs +++ b/crates/reims-vgpu/src/graphics/decode/mod.rs @@ -82,26 +82,6 @@ use std::ptr::NonNull; use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; use std::sync::{Arc, OnceLock, Weak}; -use reims_vgpu_core::host::HostPtr; -use reims_vgpu_core::memory::map::MemoryMap; -use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; -use reims_vgpu_core::platform::device::GpuDevice; -use reims_vgpu_core::platform::event::{EventRef, SharedEvent}; -use reims_vgpu_core::platform::os::clock::{Clock as _, MonoTime}; -use reims_vgpu_core::platform::resource::{ - Buffer, ComputePipeline, FunctionConstant, Heap, Library, RenderPipeline, SamplerState, -}; -use reims_vgpu_core::platform::types::{MtlSize, Swizzle}; -use reims_vgpu_core::platform::values::{ - AttributeDesc, BufferDesc, BufferLayoutDesc, ColorAttachmentDesc, DepthStencilDesc, - FullComputePipelineDesc, FullMeshRenderPipelineDesc, FullRenderPipelineDesc, HeapDesc, - LinkedFunctionsDesc, OptionSet, PagesInPlace, PagesPlane, PrivateRenderDesc, SamplerDesc, - StageInputDesc, StencilDesc, SurfaceFacts, SurfaceMatrix, SurfacePlane, TextureDesc, - VertexDesc, -}; -use reims_vgpu_core::platform::{Handle, HostRange, Platform}; -use reims_vgpu_core::raise::{OnFault, Raise, RaiseResult, refusals}; -use reims_vgpu_core::sync::Mutex; use reims_vgpu_graphics::region::Region; use reims_vgpu_graphics::wire::{ RGFX_CMD_BUFFER_AT_OFFSET, RGFX_CMD_BUFFER_CREATE, RGFX_CMD_BUFFER_DID_MODIFY_RANGE, @@ -153,6 +133,26 @@ use reims_vgpu_graphics::wire::{ RgfxVertexBufferLayout, RgfxVideoSessionCreate, }; use reims_vgpu_video::core::device_memory::MemoryLife; +use reims_vgpu_vulkan::core::host::HostPtr; +use reims_vgpu_vulkan::core::memory::map::MemoryMap; +use reims_vgpu_vulkan::core::platform::command::{CommandBuffer as _, CommandQueue as _}; +use reims_vgpu_vulkan::core::platform::device::GpuDevice; +use reims_vgpu_vulkan::core::platform::event::{EventRef, SharedEvent}; +use reims_vgpu_vulkan::core::platform::os::clock::{Clock as _, MonoTime}; +use reims_vgpu_vulkan::core::platform::resource::{ + Buffer, ComputePipeline, FunctionConstant, Heap, Library, RenderPipeline, SamplerState, +}; +use reims_vgpu_vulkan::core::platform::types::{MtlSize, Swizzle}; +use reims_vgpu_vulkan::core::platform::values::{ + AttributeDesc, BufferDesc, BufferLayoutDesc, ColorAttachmentDesc, DepthStencilDesc, + FullComputePipelineDesc, FullMeshRenderPipelineDesc, FullRenderPipelineDesc, HeapDesc, + LinkedFunctionsDesc, OptionSet, PagesInPlace, PagesPlane, PrivateRenderDesc, SamplerDesc, + StageInputDesc, StencilDesc, SurfaceFacts, SurfaceMatrix, SurfacePlane, TextureDesc, + VertexDesc, +}; +use reims_vgpu_vulkan::core::platform::{Handle, HostRange, Platform}; +use reims_vgpu_vulkan::core::raise::{OnFault, Raise, RaiseResult, refusals}; +use reims_vgpu_vulkan::core::sync::Mutex; use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout}; /// Metal's page on Apple silicon, to which a Shared heap's memory is rounded up: the guest's @@ -352,7 +352,7 @@ impl Drop for Drain { /// ends the process, fails alone, as a buffer Metal could not run does, and its process's later work /// is carried out (docs/graphics-kext/design.md, "Guest input the host refuses"). /// -/// [`CompletedInfo::refused`]: reims_vgpu_core::platform::command::CompletedInfo::refused +/// [`CompletedInfo::refused`]: reims_vgpu_vulkan::core::platform::command::CompletedInfo::refused #[derive(Default)] pub(crate) struct ClosedContexts { /// The contexts closed since the device's reset. @@ -872,7 +872,7 @@ impl Recent

{ /// What the tests call after each op of a command buffer's walk, with its index, but for the /// render ops, which run inside their encoder's runs -/// ([`reims_vgpu_core::platform::render::RenderEncoder::encoding`]) and are not counted. +/// ([`reims_vgpu_vulkan::core::platform::render::RenderEncoder::encoding`]) and are not counted. #[cfg(test)] pub(crate) type WalkHook = Arc; @@ -1545,7 +1545,7 @@ impl GraphicsDecoder

{ /// for the answer [`RGFX_STATUS_CACHE`]; the device's verdict not known yet keeps it in place, /// counted apart. /// - /// [`GpuDevice::surface_pages_in_place`]: reims_vgpu_core::platform::device::GpuDevice::surface_pages_in_place + /// [`GpuDevice::surface_pages_in_place`]: reims_vgpu_vulkan::core::platform::device::GpuDevice::surface_pages_in_place fn asks_cache(&self, device: &P::Device, block: u64, planes: &[PagesPlane]) -> bool { let views = &self.shared.surface_views; let Some(import) = views.lock().import_of(block) else { @@ -2037,7 +2037,7 @@ impl GraphicsDecoder

{ #[cfg(test)] pub(crate) fn caches( &self, - ) -> reims_vgpu_core::sync::MutexGuard<'_, surface_cache::SurfaceCaches

> { + ) -> reims_vgpu_vulkan::core::sync::MutexGuard<'_, surface_cache::SurfaceCaches

> { self.surface_caches.lock() } @@ -2112,7 +2112,7 @@ impl GraphicsDecoder

{ #[cfg(test)] pub(crate) fn views_of_surfaces( &self, - ) -> reims_vgpu_core::sync::MutexGuard<'_, surface_pages::SurfaceViews

> { + ) -> reims_vgpu_vulkan::core::sync::MutexGuard<'_, surface_pages::SurfaceViews

> { self.shared.surface_views.lock() } @@ -5263,11 +5263,11 @@ fn stencil(s: &RgfxStencilDescriptor) -> StencilDesc { mod tests { use std::sync::Arc; - use reims_vgpu_core::testkit::{Arg, FakePlatform, Step}; use reims_vgpu_graphics::wire::{ RGFX_CMD_HEAP_TEXTURE_SIZE_AND_ALIGN, RGFX_LIBRARY_BYTES_OFFSET, RGFX_RESOURCE_ID_CHUNKS, RgfxLibraryCreate, RgfxLibraryFromRegion, RgfxTextureView, }; + use reims_vgpu_vulkan::core::testkit::{Arg, FakePlatform, Step}; use zerocopy::IntoBytes; use super::*; @@ -5279,7 +5279,7 @@ mod tests { /// none (0) is no attachment #[test] fn a_pixel_format_the_device_describes_none_for_is_refused_before_the_platform() { - use reims_vgpu_core::platform::types::PixelFormatInfo; + use reims_vgpu_vulkan::core::platform::types::PixelFormatInfo; const INFO: &str = "MTLPixelFormatGetInfoForDevice()"; const MAKES: [&str; 3] = [ "newTextureWithDescriptor:", @@ -5816,10 +5816,10 @@ mod tests { /// way, is refused, and stores and makes nothing more. #[test] fn an_unshared_queue_create_makes_the_platforms_unshared_queue() { - use reims_vgpu_core::testkit::impls::device::UNSHARED_QUEUE; use reims_vgpu_graphics::wire::{ RGFX_QUEUE_QUIET_SCHEDULED, RGFX_QUEUE_UNSHARED, RgfxQueueCreateFlags, }; + use reims_vgpu_vulkan::core::testkit::impls::device::UNSHARED_QUEUE; let p = Arc::new(FakePlatform::new()); let device = p.device(); @@ -6066,7 +6066,7 @@ mod tests { /// message sees the destroy. #[test] fn a_message_names_what_its_own_destroys_and_makes_left() { - use reims_vgpu_core::platform::device::GpuDevice as _; + use reims_vgpu_vulkan::core::platform::device::GpuDevice as _; let p = Arc::new(FakePlatform::new()); let device = p.device(); let region = Arc::new(reims_vgpu_graphics::region::Region::new(0x10000).unwrap()); @@ -6122,8 +6122,8 @@ mod tests { /// a reset sets those of the contexts it drops. #[test] fn a_gone_context_s_events_are_set_past_every_value() { - use reims_vgpu_core::testkit::Call; - use reims_vgpu_core::testkit::impls::device::UNSHARED_QUEUE; + use reims_vgpu_vulkan::core::testkit::Call; + use reims_vgpu_vulkan::core::testkit::impls::device::UNSHARED_QUEUE; let p = Arc::new(FakePlatform::new()); let device = p.device(); @@ -6667,7 +6667,7 @@ mod tests { ); assert_eq!(format!("{:?}", dec.surface_texture(0x77).unwrap()), first); assert_eq!( - reims_vgpu_core::platform::resource::Texture::width(&shown), + reims_vgpu_vulkan::core::platform::resource::Texture::width(&shown), 64 ); drop(shown); @@ -7127,7 +7127,7 @@ mod tests { desc, writers_offset: RGFX_SURFACE_NO_WRITERS, }; - let logs = reims_vgpu_core::testkit::logs::capture(); + let logs = reims_vgpu_vulkan::core::testkit::logs::capture(); let script = p.script(); script.push("newTextureWithDescriptor:offset:bytesPerRow:", Step::Nil); script.push( @@ -7308,7 +7308,7 @@ mod tests { assert_eq!(made(), 2, "no platform call for a malformed message"); // A refused texture's warning names the facts. - let logs = reims_vgpu_core::testkit::logs::capture(); + let logs = reims_vgpu_vulkan::core::testkit::logs::capture(); p.script() .push("newTextureWithDescriptor:iosurface:plane:", Step::Nil); assert_eq!( @@ -7527,7 +7527,7 @@ mod tests { pub(super) fn pipeline_decoder() -> ( Arc, GraphicsDecoder, - Arc>>, + Arc>>, ) { pipeline_decoder_over(Arc::new( reims_vgpu_graphics::region::Region::new(0x10000).unwrap(), @@ -7540,12 +7540,12 @@ mod tests { ) -> ( Arc, GraphicsDecoder, - Arc>>, + Arc>>, ) { let p = Arc::new(FakePlatform::new()); let device = p.device(); let mut dec = GraphicsDecoder::::new(Arc::clone(&p), region); - let replies = Arc::new(reims_vgpu_core::sync::Mutex::new(Vec::new())); + let replies = Arc::new(reims_vgpu_vulkan::core::sync::Mutex::new(Vec::new())); let sink_replies = Arc::clone(&replies); dec.set_reflection_sink(Arc::new(move |r: PipelineReply| { sink_replies.lock().push(r.reflection); @@ -7947,10 +7947,10 @@ mod tests { /// kind, with no limits after it #[test] fn a_mesh_render_create_is_answered_with_its_mesh_limits() { - use reims_vgpu_core::testkit::faults::Fault; + use reims_vgpu_vulkan::core::testkit::faults::Fault; let (p, mut dec, _) = pipeline_decoder(); let device = p.device(); - let replies = Arc::new(reims_vgpu_core::sync::Mutex::new(Vec::new())); + let replies = Arc::new(reims_vgpu_vulkan::core::sync::Mutex::new(Vec::new())); let sink_replies = Arc::clone(&replies); dec.set_reflection_sink(Arc::new(move |r: PipelineReply| { sink_replies.lock().push(r.bytes()); @@ -8066,7 +8066,7 @@ lacks {part}" const MAKE: &str = "newRenderPipelineStateWithMeshDescriptor:options:reflection:error:"; let (p, mut dec, _) = pipeline_decoder(); let device = p.device(); - let replies = Arc::new(reims_vgpu_core::sync::Mutex::new(Vec::new())); + let replies = Arc::new(reims_vgpu_vulkan::core::sync::Mutex::new(Vec::new())); let sink_replies = Arc::clone(&replies); dec.set_reflection_sink(Arc::new(move |r: PipelineReply| { sink_replies.lock().push(r.bytes()); @@ -8101,7 +8101,7 @@ lacks {part}" /// [`DecodeError::Refused`] with a refused reply, nothing is stored, and the next is made #[test] fn a_compile_the_platform_refuses_in_the_decoder_is_a_refused_reply() { - use reims_vgpu_core::testkit::faults::Fault; + use reims_vgpu_vulkan::core::testkit::faults::Fault; let (p, mut dec, replies) = pipeline_decoder(); let device = p.device(); let faults = p.faults(); @@ -8500,7 +8500,7 @@ lacks {part}" /// at refuses the create #[test] fn a_create_s_bad_linked_function_makes_nothing() { - use reims_vgpu_core::testkit::faults::Fault; + use reims_vgpu_vulkan::core::testkit::faults::Fault; let (p, mut dec, replies) = pipeline_decoder(); let device = p.device(); let with = |obj_id, library, list| { @@ -8617,7 +8617,7 @@ lacks {part}" Arc::clone(&platform), Arc::new(reims_vgpu_graphics::region::Region::new(0x10000).unwrap()), ); - let replies = Arc::new(reims_vgpu_core::sync::Mutex::new(Vec::new())); + let replies = Arc::new(reims_vgpu_vulkan::core::sync::Mutex::new(Vec::new())); let sink_replies = Arc::clone(&replies); dec.set_reflection_sink(Arc::new(move |r: PipelineReply| { sink_replies @@ -8897,20 +8897,20 @@ lacks {part}" kernel: &str, linked: &str, ) -> Vec> { - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; - use reims_vgpu_core::platform::device::GpuDevice as _; - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::platform::types::{MtlSize, NsRange}; - use reims_vgpu_core::platform::values::ComputePassDesc; - use reims_vgpu_core::raise::OnFault; + use reims_vgpu_vulkan::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use reims_vgpu_vulkan::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; + use reims_vgpu_vulkan::core::platform::device::GpuDevice as _; + use reims_vgpu_vulkan::core::platform::resource::Buffer as _; + use reims_vgpu_vulkan::core::platform::types::{MtlSize, NsRange}; + use reims_vgpu_vulkan::core::platform::values::ComputePassDesc; + use reims_vgpu_vulkan::core::raise::OnFault; let platform = P::process(); let device = platform.metal_device(None).unwrap(); let mut dec = GraphicsDecoder::

::new( Arc::clone(&platform), Arc::new(reims_vgpu_graphics::region::Region::new(0x10000).unwrap()), ); - let replies = Arc::new(reims_vgpu_core::sync::Mutex::new(Vec::new())); + let replies = Arc::new(reims_vgpu_vulkan::core::sync::Mutex::new(Vec::new())); let sink_replies = Arc::clone(&replies); dec.set_reflection_sink(Arc::new(move |r: PipelineReply| { sink_replies @@ -9116,20 +9116,20 @@ lacks {part}" fn optional_constant_through_the_decoder( cases: &[&[RgfxFunctionConstant]], ) -> Vec> { - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; - use reims_vgpu_core::platform::device::GpuDevice as _; - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::platform::types::{MtlSize, NsRange}; - use reims_vgpu_core::platform::values::ComputePassDesc; - use reims_vgpu_core::raise::OnFault; + use reims_vgpu_vulkan::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use reims_vgpu_vulkan::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; + use reims_vgpu_vulkan::core::platform::device::GpuDevice as _; + use reims_vgpu_vulkan::core::platform::resource::Buffer as _; + use reims_vgpu_vulkan::core::platform::types::{MtlSize, NsRange}; + use reims_vgpu_vulkan::core::platform::values::ComputePassDesc; + use reims_vgpu_vulkan::core::raise::OnFault; let platform = P::process(); let device = platform.metal_device(None).unwrap(); let mut dec = GraphicsDecoder::

::new( Arc::clone(&platform), Arc::new(reims_vgpu_graphics::region::Region::new(0x10000).unwrap()), ); - let replies = Arc::new(reims_vgpu_core::sync::Mutex::new(Vec::new())); + let replies = Arc::new(reims_vgpu_vulkan::core::sync::Mutex::new(Vec::new())); let sink_replies = Arc::clone(&replies); dec.set_reflection_sink(Arc::new(move |r: PipelineReply| { sink_replies @@ -9267,10 +9267,10 @@ lacks {part}" grid: (u64, u64), (sampler, probe): (Option<&P::SamplerState>, Option<&[u8]>), ) -> Vec<[f32; 4]> { - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; - use reims_vgpu_core::platform::compute::{ComputeCmd, ComputeEncoder as _}; - use reims_vgpu_core::platform::types::{MtlSize, NsRange}; - let _pool = reims_vgpu_core::rt::Pool::here(); + use reims_vgpu_vulkan::core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use reims_vgpu_vulkan::core::platform::compute::{ComputeCmd, ComputeEncoder as _}; + use reims_vgpu_vulkan::core::platform::types::{MtlSize, NsRange}; + let _pool = reims_vgpu_vulkan::core::rt::Pool::here(); let library = device.new_library(PROBE_LIBRARY).unwrap().unwrap().unwrap(); let f = library.new_function(OnFault::Die, kernel).unwrap().unwrap(); let state = device @@ -9460,7 +9460,7 @@ lacks {part}" texture: &P::Texture, size: (u64, u64), ) -> TextureAnswer { - use reims_vgpu_core::platform::resource::{GpuResource as _, Texture as _}; + use reims_vgpu_vulkan::core::platform::resource::{GpuResource as _, Texture as _}; let t = texture; let getters = [ t.pixel_format(), @@ -9707,7 +9707,7 @@ lacks {part}" /// mean, median and 99th percentile of each. `RVG_SAMPLER_BENCH_LIVE` (comma-separated) sets /// other live counts. fn sampler_create_cost() { - use reims_vgpu_core::platform::os::Clock as _; + use reims_vgpu_vulkan::core::platform::os::Clock as _; let (mut dec, device) = surface_decoder::

(); let platform = P::process(); let now = || platform.clock().now_mono(); @@ -9840,7 +9840,7 @@ lacks {part}" /// non-library is a bad reference and makes nothing. #[test] fn render_and_compute_pipeline_creates() { - use reims_vgpu_core::sync::Mutex; + use reims_vgpu_vulkan::core::sync::Mutex; let p = Arc::new(FakePlatform::new()); let device = p.device(); diff --git a/crates/reims-vgpu/src/graphics/decode/refused.rs b/crates/reims-vgpu/src/graphics/decode/refused.rs index edb169f3a..39e39c3a5 100644 --- a/crates/reims-vgpu/src/graphics/decode/refused.rs +++ b/crates/reims-vgpu/src/graphics/decode/refused.rs @@ -39,7 +39,6 @@ use std::cell::{Cell, RefCell}; use std::collections::HashSet; use std::sync::atomic::{AtomicBool, Ordering}; -use reims_vgpu_core::raise::{Origin, Raise, RaiseResult}; use reims_vgpu_graphics::wire::{ RGFX_CMD_BUFFER_AT_OFFSET, RGFX_CMD_BUFFER_CREATE, RGFX_CMD_BUFFER_MANAGED_AT_OFFSET, RGFX_CMD_BUFFER_OVER_HOST_MEMORY, RGFX_CMD_BUFFER_OVER_PAGES, @@ -52,6 +51,7 @@ use reims_vgpu_graphics::wire::{ RGFX_CMD_TEXTURE_CREATE, RGFX_CMD_TEXTURE_FROM_BUFFER, RGFX_CMD_TEXTURE_FROM_IOSURFACE, RGFX_CMD_TEXTURE_VIEW, RGFX_CMD_VIDEO_SESSION_CREATE, RgfxObjectCreate, }; +use reims_vgpu_vulkan::core::raise::{Origin, Raise, RaiseResult}; use super::read; diff --git a/crates/reims-vgpu/src/graphics/decode/render.rs b/crates/reims-vgpu/src/graphics/decode/render.rs index 8cc2d9ab0..37a310978 100644 --- a/crates/reims-vgpu/src/graphics/decode/render.rs +++ b/crates/reims-vgpu/src/graphics/decode/render.rs @@ -27,15 +27,15 @@ use std::cell::Cell; // The render-op tags and body structs (`Rgfx*`): the whole render group, so a glob. -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::blit::ResourceRef; -use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder}; -use reims_vgpu_core::platform::types::{ +use reims_vgpu_graphics::ops::render::*; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::platform::blit::ResourceRef; +use reims_vgpu_vulkan::core::platform::render::{RenderCmd, RenderEncoder}; +use reims_vgpu_vulkan::core::platform::types::{ MtlOrigin, MtlRegion, MtlScissorRect, MtlSize, MtlViewport, NsRange, VertexAmplificationViewMapping, }; -use reims_vgpu_core::raise::{OnFault, Raise, RaiseResult}; -use reims_vgpu_graphics::ops::render::*; +use reims_vgpu_vulkan::core::raise::{OnFault, Raise, RaiseResult}; use zerocopy::FromBytes; use super::refused::{self, Bound, Marks, Slot, Stage}; @@ -1843,17 +1843,17 @@ pub(crate) fn decode_op( mod tests { use std::sync::Arc; - use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue}; - use reims_vgpu_core::platform::device::GpuDevice; - use reims_vgpu_core::platform::values::IcbDesc; - use reims_vgpu_core::platform::{Handle, Platform}; - use reims_vgpu_core::testkit::{Arg, FakePlatform}; use reims_vgpu_graphics::wire::{ RGFX_CMD_BUFFER_CREATE, RGFX_CMD_DEPTH_STENCIL_CREATE, RGFX_CMD_FENCE_CREATE, RGFX_CMD_HEAP_CREATE, RGFX_CMD_SAMPLER_CREATE, RGFX_CMD_TEXTURE_CREATE, RgfxBufferCreate, RgfxDepthStencilCreate, RgfxHeapCreate, RgfxMsgHeader, RgfxObjectCreate, RgfxSamplerCreate, RgfxTextureCreate, RgfxTextureDescriptor, }; + use reims_vgpu_vulkan::core::platform::command::{CommandBuffer, CommandQueue}; + use reims_vgpu_vulkan::core::platform::device::GpuDevice; + use reims_vgpu_vulkan::core::platform::values::IcbDesc; + use reims_vgpu_vulkan::core::platform::{Handle, Platform}; + use reims_vgpu_vulkan::core::testkit::{Arg, FakePlatform}; use zerocopy::IntoBytes; use super::super::ObjHandle; diff --git a/crates/reims-vgpu/src/graphics/decode/sequencer.rs b/crates/reims-vgpu/src/graphics/decode/sequencer.rs index 4aa11dc65..6b0aa5839 100644 --- a/crates/reims-vgpu/src/graphics/decode/sequencer.rs +++ b/crates/reims-vgpu/src/graphics/decode/sequencer.rs @@ -44,7 +44,7 @@ use std::collections::{HashMap, VecDeque}; use std::sync::Arc; use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering}; -use reims_vgpu_core::sync::{Condvar, Mutex, MutexGuard}; +use reims_vgpu_vulkan::core::sync::{Condvar, Mutex, MutexGuard}; /// A range message's work, carried out once its context's tickets before it are given back. pub(crate) type RangeOp = Box; diff --git a/crates/reims-vgpu/src/graphics/decode/shares.rs b/crates/reims-vgpu/src/graphics/decode/shares.rs index 0ef9391e4..08a8a37fb 100644 --- a/crates/reims-vgpu/src/graphics/decode/shares.rs +++ b/crates/reims-vgpu/src/graphics/decode/shares.rs @@ -39,15 +39,15 @@ use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; use std::time::Duration; -use reims_vgpu_core::platform::event::SharedEvent as _; -use reims_vgpu_core::platform::{Handle, Platform}; -use reims_vgpu_core::sync::Mutex; use reims_vgpu_graphics::wire::{ RGFX_CONTEXT_OBJ_ID_SHIFT, RGFX_EVT_EVENT_SIGNALLED, RGFX_EVT_SHARED_EVENT_VALUE, RGFX_STATUS_INVALID_ARGUMENT, RGFX_STATUS_NOT_FOUND, RGFX_STATUS_OK, RgfxEventSignalled, RgfxMsgHeader, RgfxSharedEventImport, RgfxSharedEventName, RgfxSharedEventUnname, RgfxSharedEventValue, }; +use reims_vgpu_vulkan::core::platform::event::SharedEvent as _; +use reims_vgpu_vulkan::core::platform::{Handle, Platform}; +use reims_vgpu_vulkan::core::sync::Mutex; use super::{Entry, GraphicsDecoder, ObjHandle, read}; @@ -564,8 +564,8 @@ impl Posts { mod tests { use std::sync::atomic::AtomicBool; - use reims_vgpu_core::platform::device::GpuDevice; - use reims_vgpu_core::testkit::FakePlatform; + use reims_vgpu_vulkan::core::platform::device::GpuDevice; + use reims_vgpu_vulkan::core::testkit::FakePlatform; use zerocopy::IntoBytes; use super::*; diff --git a/crates/reims-vgpu/src/graphics/decode/split.rs b/crates/reims-vgpu/src/graphics/decode/split.rs index ee77495c8..1d52f8324 100644 --- a/crates/reims-vgpu/src/graphics/decode/split.rs +++ b/crates/reims-vgpu/src/graphics/decode/split.rs @@ -75,9 +75,9 @@ use std::collections::HashMap; use std::sync::Arc; use std::time::Duration; -use reims_vgpu_core::platform::command::{CompletedHandler, CompletedInfo}; -use reims_vgpu_core::platform::types::{CommandBufferStatus, NsErrorText}; -use reims_vgpu_core::sync::{Condvar, Mutex}; +use reims_vgpu_vulkan::core::platform::command::{CompletedHandler, CompletedInfo}; +use reims_vgpu_vulkan::core::platform::types::{CommandBufferStatus, NsErrorText}; +use reims_vgpu_vulkan::core::sync::{Condvar, Mutex}; use super::sequencer::RangeOp; diff --git a/crates/reims-vgpu/src/graphics/decode/surface_cache.rs b/crates/reims-vgpu/src/graphics/decode/surface_cache.rs index cdebae53e..43bd01ac1 100644 --- a/crates/reims-vgpu/src/graphics/decode/surface_cache.rs +++ b/crates/reims-vgpu/src/graphics/decode/surface_cache.rs @@ -116,7 +116,7 @@ //! mapping of the pages, so the two never share a command buffer: each copy has a transfer //! command buffer of its own, and a refused copy by runs encodes nothing in it. //! -//! [`GpuDevice::copies_guest_ram`]: reims_vgpu_core::platform::device::GpuDevice::copies_guest_ram +//! [`GpuDevice::copies_guest_ram`]: reims_vgpu_vulkan::core::platform::device::GpuDevice::copies_guest_ram //! //! What the guest observes is IOSurface's contract under its locks: a lock after a GPU write sees //! it, and a GPU use after a read-write lock sees the CPU's writes. A CPU write made without a @@ -147,24 +147,24 @@ use std::ops::Range; use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::{Arc, OnceLock}; -use reims_vgpu_core::host::HostPtr; -use reims_vgpu_core::num::{ToU64 as _, ToUsize as _}; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder}; -use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue, CompletedInfo}; -use reims_vgpu_core::platform::device::GpuDevice; -use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; -use reims_vgpu_core::platform::resource::Buffer as _; -use reims_vgpu_core::platform::types::NsRange; -use reims_vgpu_core::platform::values::PagesPlane; -use reims_vgpu_core::platform::{Handle, Platform}; -use reims_vgpu_core::raise::{OnFault, Raise, RaiseResult, refusals}; -use reims_vgpu_core::sync::{Condvar, Mutex, MutexGuard}; use reims_vgpu_graphics::ops::{RGFX_SURFACE_USE_WRITES, RgfxOpSurfaceUse}; use reims_vgpu_graphics::region::Region; use reims_vgpu_graphics::wire::{ RGFX_BLOCK_RELEASE_NO_CLIENT, RGFX_BLOCK_RELEASE_UNHELD, RgfxBufferOverSurfacePages, }; use reims_vgpu_video::core::device_memory::{MemoryIdentity, MemoryLife}; +use reims_vgpu_vulkan::core::host::HostPtr; +use reims_vgpu_vulkan::core::num::{ToU64 as _, ToUsize as _}; +use reims_vgpu_vulkan::core::platform::blit::{BlitCmd, BlitEncoder}; +use reims_vgpu_vulkan::core::platform::command::{CommandBuffer, CommandQueue, CompletedInfo}; +use reims_vgpu_vulkan::core::platform::device::GpuDevice; +use reims_vgpu_vulkan::core::platform::event::{EventRef, SharedEvent as _}; +use reims_vgpu_vulkan::core::platform::resource::Buffer as _; +use reims_vgpu_vulkan::core::platform::types::NsRange; +use reims_vgpu_vulkan::core::platform::values::PagesPlane; +use reims_vgpu_vulkan::core::platform::{Handle, Platform}; +use reims_vgpu_vulkan::core::raise::{OnFault, Raise, RaiseResult, refusals}; +use reims_vgpu_vulkan::core::sync::{Condvar, Mutex, MutexGuard}; use super::refusing; use super::surface_pages::{SurfaceView, Unmade, buffer_over}; @@ -461,7 +461,7 @@ struct Transfer { /// Unshared ([`new_command_queue_unshared`]): a present of a surface waits for its fill, and /// a frame drawn from a cache for the fill before it ([`FillWait`]). /// - /// [`new_command_queue_unshared`]: reims_vgpu_core::platform::device::GpuDevice::new_command_queue_unshared + /// [`new_command_queue_unshared`]: reims_vgpu_vulkan::core::platform::device::GpuDevice::new_command_queue_unshared queue: P::CommandQueue, /// The early copies behind writers that hold no video encoder /// ([`SurfaceCaches::early_copies`]), apart from the fills, so neither waits behind the @@ -3549,9 +3549,6 @@ fn copy( mod tests { use std::sync::atomic::AtomicBool; - use reims_vgpu_core::testkit::FakePlatform; - use reims_vgpu_core::testkit::calllog::{Arg, Call}; - use reims_vgpu_core::testkit::objects::CompleteOn; use reims_vgpu_graphics::ops::{ RGFX_COMMAND_BUFFER_OPS_OFFSET, RGFX_OP_SUBMITTED, RGFX_OP_SURFACE_USE, RgfxCommandBuffer, RgfxOpHeader, @@ -3562,6 +3559,9 @@ mod tests { RGFX_SURFACE_PAGES_ATTACH, RGFX_SURFACE_PAGES_CACHED, RGFX_SURFACE_PAGES_DEFERRED, RgfxMsgHeader, RgfxObjectDestroy, RgfxPageRun, RgfxQueueCreate, RgfxSurfacePages, }; + use reims_vgpu_vulkan::core::testkit::FakePlatform; + use reims_vgpu_vulkan::core::testkit::calllog::{Arg, Call}; + use reims_vgpu_vulkan::core::testkit::objects::CompleteOn; use zerocopy::IntoBytes; use super::super::surface_pages::tests::{BLOCK, RAM, Rig, rig}; @@ -4517,7 +4517,7 @@ mod tests { /// queue #[test] fn the_transfer_queue_is_made_unshared_with_the_first_queue() { - use reims_vgpu_core::testkit::impls::device::UNSHARED_QUEUE; + use reims_vgpu_vulkan::core::testkit::impls::device::UNSHARED_QUEUE; let mut r = cached(); let (unshared, plain) = ( r.p.call_log().count(UNSHARED_QUEUE), @@ -5502,7 +5502,9 @@ mod tests { /// what the view then holds, as the guest's pages lie scattered and out of order #[test] fn a_cached_block_by_runs_copies_the_bytes_its_view_holds() { - use reims_vgpu_core::testkit::impls::blit::{BUFFER_TO_GUEST_RAM, GUEST_RAM_TO_BUFFER}; + use reims_vgpu_vulkan::core::testkit::impls::blit::{ + BUFFER_TO_GUEST_RAM, GUEST_RAM_TO_BUFFER, + }; let mut r = cached_by_runs(); let page = r.page; assert_eq!( @@ -5581,8 +5583,10 @@ mod tests { /// both ways: what a command buffer wrote of the cache still reaches the pages #[test] fn a_refused_fill_by_runs_fills_through_a_view_from_then_on() { - use reims_vgpu_core::testkit::Step; - use reims_vgpu_core::testkit::impls::blit::{BUFFER_TO_GUEST_RAM, GUEST_RAM_TO_BUFFER}; + use reims_vgpu_vulkan::core::testkit::Step; + use reims_vgpu_vulkan::core::testkit::impls::blit::{ + BUFFER_TO_GUEST_RAM, GUEST_RAM_TO_BUFFER, + }; let mut r = cached_by_runs(); let cache = cache_id(&r); r.p.script().push(GUEST_RAM_TO_BUFFER, Step::value(false)); @@ -5649,8 +5653,8 @@ mod tests { #[test] fn a_download_of_a_laid_out_cache_leaves_the_bytes_between_rows() { use super::super::surface_pages::tests::one_plane; - use reims_vgpu_core::platform::values::PagesInPlace; use reims_vgpu_graphics::wire::RGFX_STATUS_CACHE; + use reims_vgpu_vulkan::core::platform::values::PagesInPlace; let mut r = rig(16); let page = r.page; r.dec.set_unified_memory(true); @@ -5756,8 +5760,8 @@ mod tests { /// buffer's write is not lost, and the release that follows has nothing more to copy #[test] fn a_refused_download_by_runs_copies_through_a_view() { - use reims_vgpu_core::testkit::Step; - use reims_vgpu_core::testkit::impls::blit::BUFFER_TO_GUEST_RAM; + use reims_vgpu_vulkan::core::testkit::Step; + use reims_vgpu_vulkan::core::testkit::impls::blit::BUFFER_TO_GUEST_RAM; let mut r = cached_by_runs(); let cache = cache_id(&r); use_surfaces(&mut r, 1, 0x100, &[(BLOCK, 0, true)]); @@ -5806,7 +5810,7 @@ mod tests { /// its buffers lie over the view #[test] fn a_block_by_runs_with_no_cache_takes_its_view() { - use reims_vgpu_core::testkit::Step; + use reims_vgpu_vulkan::core::testkit::Step; let mut r = rig(8); let page = r.page; r.p.world().copy_guest_ram(true); @@ -5823,7 +5827,9 @@ mod tests { /// Each transfer command buffer's copies of the block's cache, as (copies by runs asked, /// copies through a view), from `commandBuffer` to its `commit`. fn copies_per_command_buffer(calls: &[Call]) -> Vec<(usize, usize)> { - use reims_vgpu_core::testkit::impls::blit::{BUFFER_TO_GUEST_RAM, GUEST_RAM_TO_BUFFER}; + use reims_vgpu_vulkan::core::testkit::impls::blit::{ + BUFFER_TO_GUEST_RAM, GUEST_RAM_TO_BUFFER, + }; let mut out = Vec::new(); let mut open: Option<(usize, usize)> = None; for c in calls { @@ -5852,8 +5858,8 @@ mod tests { /// copy having encoded nothing, and every copy after it goes through the view, each in its own #[test] fn a_copy_by_runs_and_one_through_the_view_never_share_a_command_buffer() { - use reims_vgpu_core::testkit::Step; - use reims_vgpu_core::testkit::impls::blit::BUFFER_TO_GUEST_RAM; + use reims_vgpu_vulkan::core::testkit::Step; + use reims_vgpu_vulkan::core::testkit::impls::blit::BUFFER_TO_GUEST_RAM; let mut r = cached_by_runs(); let mark = r.p.call_log().mark(); use_surfaces(&mut r, 1, 0x100, &[(BLOCK, 1, true)]); @@ -5881,7 +5887,7 @@ mod tests { /// follows copies the GPU's write out of it by them #[test] fn a_deferred_blocks_pages_are_taken_by_their_runs() { - use reims_vgpu_core::testkit::impls::blit::BUFFER_TO_GUEST_RAM; + use reims_vgpu_vulkan::core::testkit::impls::blit::BUFFER_TO_GUEST_RAM; let mut r = deferring(8); let page = r.page; r.p.world().copy_guest_ram(true); @@ -6139,7 +6145,7 @@ mod tests { /// its room back #[test] fn a_deferred_block_not_made_is_refused_with_nothing_left() { - use reims_vgpu_core::testkit::Step; + use reims_vgpu_vulkan::core::testkit::Step; let mut r = deferring(3); let page = r.page; let refused = RGFX_STATUS_REFUSED; @@ -6173,8 +6179,8 @@ mod tests { /// The live Shared buffer `id`'s bytes, each set to `with` first where given. fn buffer_bytes(r: &Rig, id: u64, with: Option) -> Vec { - use reims_vgpu_core::platform::ObjId; - use reims_vgpu_core::testkit::objects::kind; + use reims_vgpu_vulkan::core::platform::ObjId; + use reims_vgpu_vulkan::core::testkit::objects::kind; let buffer = (r.p.world().find(ObjId(id))) .and_then(|o| o.cast::()) .expect("a live buffer"); @@ -6214,7 +6220,7 @@ mod tests { /// surface's bytes are refused still #[test] fn a_deferred_blocks_pages_with_no_view_are_copied() { - use reims_vgpu_core::testkit::Step; + use reims_vgpu_vulkan::core::testkit::Step; let mut r = deferring(8); let page = r.page; let length = 2 * page; @@ -6408,7 +6414,7 @@ mod tests { /// writer copies the cache into the runs, and the download that follows copies nothing more #[test] fn a_surface_read_back_by_runs_is_copied_out_by_them_behind_its_next_writer() { - use reims_vgpu_core::testkit::impls::blit::BUFFER_TO_GUEST_RAM; + use reims_vgpu_vulkan::core::testkit::impls::blit::BUFFER_TO_GUEST_RAM; let r = cached_by_runs(); let cache = cache_id(&r); let queue = r.device.new_command_queue().unwrap(); diff --git a/crates/reims-vgpu/src/graphics/decode/surface_order.rs b/crates/reims-vgpu/src/graphics/decode/surface_order.rs index 23c966c39..69b078700 100644 --- a/crates/reims-vgpu/src/graphics/decode/surface_order.rs +++ b/crates/reims-vgpu/src/graphics/decode/surface_order.rs @@ -55,13 +55,13 @@ use std::collections::HashMap; use std::sync::Arc; use std::sync::atomic::{AtomicU64, Ordering}; -use reims_vgpu_core::platform::command::{CommandBuffer, CommandQueue, CompletedInfo}; -use reims_vgpu_core::platform::device::GpuDevice; -use reims_vgpu_core::platform::event::{EventRef, SharedEvent}; -use reims_vgpu_core::platform::{Handle, Platform}; -use reims_vgpu_core::raise::{OnFault, RaiseResult, refusals}; use reims_vgpu_graphics::ops::RgfxSurfaceOrderWait; use reims_vgpu_graphics::wire::RGFX_CONTEXT_OBJ_ID_SHIFT; +use reims_vgpu_vulkan::core::platform::command::{CommandBuffer, CommandQueue, CompletedInfo}; +use reims_vgpu_vulkan::core::platform::device::GpuDevice; +use reims_vgpu_vulkan::core::platform::event::{EventRef, SharedEvent}; +use reims_vgpu_vulkan::core::platform::{Handle, Platform}; +use reims_vgpu_vulkan::core::raise::{OnFault, RaiseResult, refusals}; use super::commit_order; @@ -716,10 +716,6 @@ mod tests { use std::sync::atomic::Ordering; - use reims_vgpu_core::sync::Mutex; - use reims_vgpu_core::testkit::calllog::{Arg, Call}; - use reims_vgpu_core::testkit::objects::CompleteOn; - use reims_vgpu_core::testkit::{FakePlatform, Step}; use reims_vgpu_graphics::ops::{ RGFX_COMMAND_BUFFER_OPS_OFFSET, RGFX_OP_SUBMITTED, RGFX_OP_SURFACE_ORDER, RgfxCommandBuffer, RgfxOpHeader, @@ -729,6 +725,10 @@ mod tests { RGFX_CONTEXT_OBJ_ID_SHIFT, RGFX_EVT_CB_SUBMITTED, RgfxMsgHeader, RgfxObjectDestroy, RgfxQueueCreate, }; + use reims_vgpu_vulkan::core::sync::Mutex; + use reims_vgpu_vulkan::core::testkit::calllog::{Arg, Call}; + use reims_vgpu_vulkan::core::testkit::objects::CompleteOn; + use reims_vgpu_vulkan::core::testkit::{FakePlatform, Step}; use zerocopy::IntoBytes; use super::super::{DecodeError, GraphicsDecoder, refusing}; diff --git a/crates/reims-vgpu/src/graphics/decode/surface_pages.rs b/crates/reims-vgpu/src/graphics/decode/surface_pages.rs index d64970e1b..801980d41 100644 --- a/crates/reims-vgpu/src/graphics/decode/surface_pages.rs +++ b/crates/reims-vgpu/src/graphics/decode/surface_pages.rs @@ -25,7 +25,7 @@ //! kept every one, ended sessions' among them, so the process's mappings only grew, from 3,220 at //! the desktop to 43,949, past the headroom. //! -//! [`HostVm::idle_view_mappings`]: reims_vgpu_core::platform::os::vm::HostVm::idle_view_mappings +//! [`HostVm::idle_view_mappings`]: reims_vgpu_vulkan::core::platform::os::vm::HostVm::idle_view_mappings //! //! The runs are the guest's: each must be whole pages of the guest's (4 KiB) and of the host's //! from a page, lie in guest RAM, and the runs must sum to the surface's length; else the block @@ -64,7 +64,7 @@ //! where the platform refuses a copy, or where it makes no cache, and the block then lies over //! the view as any other. A block whose runs leave the RAM's mapping takes its view as before. //! -//! [`GpuDevice::copies_guest_ram`]: reims_vgpu_core::platform::device::GpuDevice::copies_guest_ram +//! [`GpuDevice::copies_guest_ram`]: reims_vgpu_vulkan::core::platform::device::GpuDevice::copies_guest_ram //! //! **Device caches where the pages cannot serve** (`RGFX_FEATURE_SURFACE_CACHE_REFUSED`). On a //! device whose GPU shares the CPU's memory a surface's textures lie in its pages, but not every @@ -82,7 +82,7 @@ //! left in the cache of views, and the kext posts it again marked cached, which takes that view //! and a device cache ([`super::surface_cache`]). The counts keep how each ask was answered. //! -//! [`GpuDevice::surface_pages_in_place`]: reims_vgpu_core::platform::device::GpuDevice::surface_pages_in_place +//! [`GpuDevice::surface_pages_in_place`]: reims_vgpu_vulkan::core::platform::device::GpuDevice::surface_pages_in_place //! //! **Off ring 0's threads.** A view costs a kernel mapping per run, and the runtime's import of //! them: real surfaces' runs are single 4 KiB pages, most laid right below the run before (measured @@ -118,17 +118,6 @@ use std::ops::Range; use std::ptr::NonNull; use std::sync::Arc; -use reims_vgpu_core::host::{HostPtr, PhysRange}; -use reims_vgpu_core::memory::PAGE_SIZE as MAPPING_PAGE; -use reims_vgpu_core::memory::map::MemoryMap; -use reims_vgpu_core::memory::mapping::Mapping; -use reims_vgpu_core::num::{ToU64 as _, ToUsize as _}; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::os::clock::Clock as _; -use reims_vgpu_core::platform::values::{BufferDesc, HeapDesc, OptionSet, PagesPlane}; -use reims_vgpu_core::platform::{Handle, HostRange, Platform}; -use reims_vgpu_core::raise::{RaiseResult, refusals}; -use reims_vgpu_core::sync::Mutex; use reims_vgpu_graphics::wire::{ RGFX_SURFACE_PAGES_PLANES, RgfxBufferOverPages, RgfxBufferOverSurfacePages, RgfxHeapOverPages, RgfxPageRun, RgfxSurfacePages, RgfxSurfacePagesLayout, @@ -137,6 +126,17 @@ use reims_vgpu_video::core::device_memory::{DeviceMemory, HostView, MemoryIdenti #[cfg(target_os = "linux")] use reims_vgpu_video::core::device_memory::{DmaBufError, SurfaceDmaBuf}; use reims_vgpu_video::core::surfaces::SurfaceError; +use reims_vgpu_vulkan::core::host::{HostPtr, PhysRange}; +use reims_vgpu_vulkan::core::memory::PAGE_SIZE as MAPPING_PAGE; +use reims_vgpu_vulkan::core::memory::map::MemoryMap; +use reims_vgpu_vulkan::core::memory::mapping::Mapping; +use reims_vgpu_vulkan::core::num::{ToU64 as _, ToUsize as _}; +use reims_vgpu_vulkan::core::platform::device::GpuDevice as _; +use reims_vgpu_vulkan::core::platform::os::clock::Clock as _; +use reims_vgpu_vulkan::core::platform::values::{BufferDesc, HeapDesc, OptionSet, PagesPlane}; +use reims_vgpu_vulkan::core::platform::{Handle, HostRange, Platform}; +use reims_vgpu_vulkan::core::raise::{RaiseResult, refusals}; +use reims_vgpu_vulkan::core::sync::Mutex; use super::worker::{Settle, Worker}; @@ -1462,10 +1462,6 @@ mod costs; #[cfg(test)] pub(super) mod tests { - use reims_vgpu_core::memory::descriptor::{GuestPhysicalRange, MemoryMapDescriptor}; - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::platform::values::PagesInPlace; - use reims_vgpu_core::testkit::{Arg, FakePlatform, GuestRam}; use reims_vgpu_graphics::region::Region; use reims_vgpu_graphics::wire::{ RGFX_CMD_BUFFER_AT_OFFSET, RGFX_CMD_BUFFER_OVER_HOST_MEMORY, RGFX_CMD_BUFFER_OVER_PAGES, @@ -1478,6 +1474,10 @@ pub(super) mod tests { RgfxSurfacePagesLayout, RgfxSurfacePlaneLayout, RgfxTextureDescriptor, RgfxTextureFromBuffer, }; + use reims_vgpu_vulkan::core::memory::descriptor::{GuestPhysicalRange, MemoryMapDescriptor}; + use reims_vgpu_vulkan::core::platform::resource::Buffer as _; + use reims_vgpu_vulkan::core::platform::values::PagesInPlace; + use reims_vgpu_vulkan::core::testkit::{Arg, FakePlatform, GuestRam}; use zerocopy::IntoBytes; use super::super::{DecodeError, GraphicsDecoder, no_raise}; diff --git a/crates/reims-vgpu/src/graphics/decode/surface_pages/costs.rs b/crates/reims-vgpu/src/graphics/decode/surface_pages/costs.rs index 69a165a3d..53b57ffe8 100644 --- a/crates/reims-vgpu/src/graphics/decode/surface_pages/costs.rs +++ b/crates/reims-vgpu/src/graphics/decode/surface_pages/costs.rs @@ -48,9 +48,6 @@ use std::sync::Arc; use std::time::{Duration, Instant}; -use reims_vgpu_core::host::PhysRange; -use reims_vgpu_core::memory::map::MemoryMap as CoreMemoryMap; -use reims_vgpu_core::num::{ToU64 as _, ToUsize as _}; use reims_vgpu_graphics::region::Region; use reims_vgpu_graphics::wire::{ RGFX_CMD_BUFFER_AT_OFFSET, RGFX_CMD_BUFFER_OVER_PAGES, RGFX_CMD_BUFFER_OVER_SURFACE_PAGES, @@ -60,6 +57,9 @@ use reims_vgpu_graphics::wire::{ RgfxBufferOverSurfacePages, RgfxHeapOverPages, RgfxMsgHeader, RgfxObjectDestroy, RgfxPageRun, RgfxSurfacePages, }; +use reims_vgpu_vulkan::core::host::PhysRange; +use reims_vgpu_vulkan::core::memory::map::MemoryMap as CoreMemoryMap; +use reims_vgpu_vulkan::core::num::{ToU64 as _, ToUsize as _}; use zerocopy::IntoBytes; use super::super::{GraphicsDecoder, no_raise}; diff --git a/crates/reims-vgpu/src/graphics/decode/tables.rs b/crates/reims-vgpu/src/graphics/decode/tables.rs index 2f8c83a11..335622677 100644 --- a/crates/reims-vgpu/src/graphics/decode/tables.rs +++ b/crates/reims-vgpu/src/graphics/decode/tables.rs @@ -38,10 +38,10 @@ use std::sync::Arc; use std::sync::atomic::AtomicUsize; use parking_lot::RwLock; -use reims_vgpu_core::collections::hasher::KeyBuild; -use reims_vgpu_core::host::HostPtr; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::sync::Mutex; +use reims_vgpu_vulkan::core::collections::hasher::KeyBuild; +use reims_vgpu_vulkan::core::host::HostPtr; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::sync::Mutex; use super::lane::Lane; use super::managed::ManagedCopy; @@ -601,12 +601,12 @@ impl Drop for View

{ #[cfg(test)] mod tests { - use reims_vgpu_core::testkit::FakePlatform; + use reims_vgpu_vulkan::core::testkit::FakePlatform; use super::*; fn fence(p: &FakePlatform) -> ObjHandle { - use reims_vgpu_core::platform::device::GpuDevice as _; + use reims_vgpu_vulkan::core::platform::device::GpuDevice as _; let device = p.device(); ObjHandle::Fence(device.new_fence().unwrap().unwrap()) } diff --git a/crates/reims-vgpu/src/graphics/decode/video.rs b/crates/reims-vgpu/src/graphics/decode/video.rs index d319189d2..bce1bb31d 100644 --- a/crates/reims-vgpu/src/graphics/decode/video.rs +++ b/crates/reims-vgpu/src/graphics/decode/video.rs @@ -23,12 +23,6 @@ use std::ptr::NonNull; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::command::CommandBuffer as _; -use reims_vgpu_core::platform::event::EventRef; -use reims_vgpu_core::platform::resource::Buffer as _; -use reims_vgpu_core::platform::types::PixelFormatInfo; -use reims_vgpu_core::raise::RaiseResult; use reims_vgpu_graphics::ops::video::{ RGFX_OP_VIDEO_DECODE_H264, RGFX_OP_VIDEO_DECODE_H265, RGFX_OP_VIDEO_ENCODE_H264, RGFX_OP_VIDEO_ENCODE_H265, RGFX_VIDEO_ENCODE_FORCE_KEYFRAME, RgfxVideoEncodeResult, @@ -42,6 +36,12 @@ use reims_vgpu_video::core::device_memory::{DeviceMemory, HostView, MemoryIdenti #[cfg(target_os = "linux")] use reims_vgpu_video::core::device_memory::{DmaBufError, SurfaceDmaBuf}; use reims_vgpu_video::core::surfaces::SurfaceError; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::platform::command::CommandBuffer as _; +use reims_vgpu_vulkan::core::platform::event::EventRef; +use reims_vgpu_vulkan::core::platform::resource::Buffer as _; +use reims_vgpu_vulkan::core::platform::types::PixelFormatInfo; +use reims_vgpu_vulkan::core::raise::RaiseResult; use zerocopy::FromBytes; use super::worker::Worker; diff --git a/crates/reims-vgpu/src/graphics/decode/view.rs b/crates/reims-vgpu/src/graphics/decode/view.rs index b7acba4b8..a3b0cac23 100644 --- a/crates/reims-vgpu/src/graphics/decode/view.rs +++ b/crates/reims-vgpu/src/graphics/decode/view.rs @@ -14,13 +14,13 @@ //! of any refused create does. A view of a pixel format the device describes none for is //! refused before the platform is asked, as Metal asserts there ([`super::described`]). -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::resource::Texture; -use reims_vgpu_core::platform::types::{NsRange, Swizzle}; -use reims_vgpu_core::raise::RaiseResult; use reims_vgpu_graphics::wire::{ RGFX_TEXTURE_VIEW_SUBRANGE, RGFX_TEXTURE_VIEW_SWIZZLE, RgfxTextureView, }; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::platform::resource::Texture; +use reims_vgpu_vulkan::core::platform::types::{NsRange, Swizzle}; +use reims_vgpu_vulkan::core::raise::RaiseResult; use super::{DecodeError, GraphicsDecoder, ObjHandle, read}; @@ -99,12 +99,12 @@ fn swizzle(packed: u32) -> Swizzle { mod tests { use std::sync::Arc; - use reims_vgpu_core::testkit::{Arg, FakePlatform}; use reims_vgpu_graphics::wire::{ RGFX_CMD_RESOURCE_ID_CHUNK, RGFX_CMD_TEXTURE_CREATE, RGFX_CMD_TEXTURE_VIEW, RGFX_CONTEXT_ALLOCATIONS_OFFSET, RGFX_CURSOR_SPAN, RgfxMsgHeader, RgfxResourceIdChunk, RgfxTextureCreate, RgfxTextureDescriptor, }; + use reims_vgpu_vulkan::core::testkit::{Arg, FakePlatform}; use zerocopy::IntoBytes; use super::*; diff --git a/crates/reims-vgpu/src/graphics/decode/waits.rs b/crates/reims-vgpu/src/graphics/decode/waits.rs index b7f841051..e562217cd 100644 --- a/crates/reims-vgpu/src/graphics/decode/waits.rs +++ b/crates/reims-vgpu/src/graphics/decode/waits.rs @@ -17,9 +17,9 @@ use std::sync::atomic::AtomicU32; use std::sync::atomic::{AtomicBool, AtomicU8, Ordering}; use std::time::Duration; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::os::clock::{Clock, Deadline, MonoTime}; -use reims_vgpu_core::sync::{Condvar, Mutex}; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::platform::os::clock::{Clock, Deadline, MonoTime}; +use reims_vgpu_vulkan::core::sync::{Condvar, Mutex}; /// How long a waiting command buffer goes unfinished before the log names it. pub(crate) const WAIT_LOGGED_AFTER: Duration = Duration::from_secs(5); @@ -233,7 +233,7 @@ fn run(shared: &Shared

) { #[cfg(test)] mod tests { - use reims_vgpu_core::testkit::FakePlatform; + use reims_vgpu_vulkan::core::testkit::FakePlatform; use super::*; diff --git a/crates/reims-vgpu/src/graphics/decode/work.rs b/crates/reims-vgpu/src/graphics/decode/work.rs index 42b513339..f62e94bfc 100644 --- a/crates/reims-vgpu/src/graphics/decode/work.rs +++ b/crates/reims-vgpu/src/graphics/decode/work.rs @@ -9,7 +9,7 @@ //! - **Counted**: a command buffer made for a context's `COMMAND_BUFFER` message (its queue gave //! one, whatever its walk then does), and a render encoder opened for its `ENCODER_BEGIN_RENDER`. //! - **Asked for by name**: [`start`] turns counting on only where `REIMS_VGPU_LOG` names the -//! target itself at debug as the first decoder is made (`reims_vgpu_core::logging::names`), +//! target itself at debug as the first decoder is made (`reims_vgpu_vulkan::core::logging::names`), //! and makes the thread then: a lone level, such as a bug report's `debug`, or a pair of a //! target above it (`reims_vgpu=debug`) does not, as for the runtime's counts on the same //! target, whose reading costs the draws they count. @@ -23,9 +23,9 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, OnceLock}; use std::time::Duration; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::os::clock::{Clock as _, Deadline}; -use reims_vgpu_core::sync::Mutex; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::platform::os::clock::{Clock as _, Deadline}; +use reims_vgpu_vulkan::core::sync::Mutex; /// The log target of the lines, at debug, which the filter names to start them ([`start`]). pub(crate) const TARGET: &str = "reims_vgpu::work"; @@ -90,7 +90,7 @@ fn counts() -> &'static Counts { pub(crate) fn start(platform: &Arc

) { static STARTED: OnceLock<()> = OnceLock::new(); STARTED.get_or_init(|| { - if !(reims_vgpu_core::logging::names(TARGET, log::Level::Debug) + if !(reims_vgpu_vulkan::core::logging::names(TARGET, log::Level::Debug) && log::log_enabled!(target: TARGET, log::Level::Debug)) { return; diff --git a/crates/reims-vgpu/src/graphics/decode/worker.rs b/crates/reims-vgpu/src/graphics/decode/worker.rs index 04fb12864..970859c72 100644 --- a/crates/reims-vgpu/src/graphics/decode/worker.rs +++ b/crates/reims-vgpu/src/graphics/decode/worker.rs @@ -61,9 +61,9 @@ use std::collections::{HashMap, VecDeque}; use std::sync::Arc; use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}; -use reims_vgpu_core::platform::os::MonoTime; -use reims_vgpu_core::sync::{Condvar, Mutex}; use reims_vgpu_graphics::keep::{KEEP, Keep}; +use reims_vgpu_vulkan::core::platform::os::MonoTime; +use reims_vgpu_vulkan::core::sync::{Condvar, Mutex}; /// The most threads a [`Worker`] runs. pub(crate) const POOL_THREADS: usize = 4; diff --git a/crates/reims-vgpu/src/graphics/device_info.rs b/crates/reims-vgpu/src/graphics/device_info.rs index 6ee9297e9..4002a43de 100644 --- a/crates/reims-vgpu/src/graphics/device_info.rs +++ b/crates/reims-vgpu/src/graphics/device_info.rs @@ -12,18 +12,18 @@ //! [`RGFX_DEVICE_INFO_OFFSET`](reims_vgpu_graphics::wire::RGFX_DEVICE_INFO_OFFSET), //! and the guest bundle reads it there, not a guest command. -use reims_vgpu_core::platform::caps::{ - COUNTER_SAMPLING_POINTS, DeviceCaps, FAMILIES, FEATURE_SETS, Flags, FormatAnswers, - IdentityCaps, Limits, SDK_FAMILIES, SDK_PIXEL_FORMATS, SPARSE_PAGE_SIZES, SPARSE_SAMPLE_COUNTS, - feature_set_family, -}; -use reims_vgpu_core::raise::RaiseResult; use reims_vgpu_graphics::wire::{ RGFX_DEVICE_ARCHITECTURE_NAME_LEN, RGFX_DEVICE_INFO_COUNTER_POINTS, RGFX_DEVICE_INFO_FAMILIES, RGFX_DEVICE_INFO_FEATURE_SETS, RGFX_DEVICE_INFO_FORMATS, RGFX_DEVICE_INFO_IDENTITY_FLAGS, RGFX_DEVICE_INFO_SIZES, RGFX_DEVICE_INFO_SPARSE_TILES, RGFX_DEVICE_INFO_VERSION, RGFX_DEVICE_NAME_LEN, RgfxDeviceInfo, RgfxFormatAnswers, }; +use reims_vgpu_vulkan::core::platform::caps::{ + COUNTER_SAMPLING_POINTS, DeviceCaps, FAMILIES, FEATURE_SETS, Flags, FormatAnswers, + IdentityCaps, Limits, SDK_FAMILIES, SDK_PIXEL_FORMATS, SPARSE_PAGE_SIZES, SPARSE_SAMPLE_COUNTS, + feature_set_family, +}; +use reims_vgpu_vulkan::core::raise::RaiseResult; /// `MTLGPUFamilyMetal3`. const MTL_GPU_FAMILY_METAL3: i64 = 5001; @@ -579,9 +579,9 @@ const _: () = mod tests { use std::sync::Arc; - use reims_vgpu_core::platform::device::GpuDevice; - use reims_vgpu_core::raise::Raise; - use reims_vgpu_core::testkit::FakePlatform; + use reims_vgpu_vulkan::core::platform::device::GpuDevice; + use reims_vgpu_vulkan::core::raise::Raise; + use reims_vgpu_vulkan::core::testkit::FakePlatform; use super::*; diff --git a/crates/reims-vgpu/src/graphics/nvidia.rs b/crates/reims-vgpu/src/graphics/nvidia.rs index add0b85d8..2fa794d58 100644 --- a/crates/reims-vgpu/src/graphics/nvidia.rs +++ b/crates/reims-vgpu/src/graphics/nvidia.rs @@ -42,11 +42,6 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, LazyLock, Weak}; -use reims_vgpu_core::platform::Handle as _; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::resource::Buffer as _; -use reims_vgpu_core::raise::OnFault; -use reims_vgpu_core::sync::Mutex; use reims_vgpu_graphics::wire::{ RGFX_VIDEO_CODEC_H264, RGFX_VIDEO_CODEC_HEVC, RGFX_VIDEO_DECODE, RGFX_VIDEO_ENCODE, RGFX_VIDEO_FORMAT_NV12, RGFX_VIDEO_FORMAT_P010, RGFX_VIDEO_H264_BASELINE, RGFX_VIDEO_H264_HIGH, @@ -61,6 +56,11 @@ use reims_vgpu_video::nvidia::{ decode_capabilities, encode_profiles, }; use reims_vgpu_vulkan::VulkanPlatform; +use reims_vgpu_vulkan::core::platform::Handle as _; +use reims_vgpu_vulkan::core::platform::device::GpuDevice as _; +use reims_vgpu_vulkan::core::platform::resource::Buffer as _; +use reims_vgpu_vulkan::core::raise::OnFault; +use reims_vgpu_vulkan::core::sync::Mutex; use reims_vgpu_vulkan::gpu::device::VulkanDevice; use reims_vgpu_vulkan::gpu::resource::VulkanBuffer; diff --git a/crates/reims-vgpu/src/graphics/nvidia/encode.rs b/crates/reims-vgpu/src/graphics/nvidia/encode.rs index 2fda13df0..575fe6714 100644 --- a/crates/reims-vgpu/src/graphics/nvidia/encode.rs +++ b/crates/reims-vgpu/src/graphics/nvidia/encode.rs @@ -26,7 +26,6 @@ use std::sync::Arc; -use reims_vgpu_core::sync::Mutex; use reims_vgpu_graphics::ops::video::{ RGFX_VIDEO_ENTROPY_CABAC, RGFX_VIDEO_ENTROPY_CAVLC, RGFX_VIDEO_PICTURE_B, RGFX_VIDEO_PICTURE_I, RGFX_VIDEO_PICTURE_P, RGFX_VIDEO_RATE_CBR, RGFX_VIDEO_RATE_CQP, RGFX_VIDEO_RATE_VBR, @@ -41,6 +40,7 @@ use reims_vgpu_video::nvidia::{ EncodeParams, EncodeProfile, EncodeProfileSupport, EncodeRateControl, Gpu, NvencEncoder, PictureType, RawFrame, Tuning, }; +use reims_vgpu_vulkan::core::sync::Mutex; use super::super::video_host::{ BackendError, EncodeFrame, EncodeSource, Encoded, HostEncodedFrame, HostEncoder, SourcePlane, diff --git a/crates/reims-vgpu/src/graphics/nvidia/encode/tests.rs b/crates/reims-vgpu/src/graphics/nvidia/encode/tests.rs index bc79d2786..2ca4b2d5c 100644 --- a/crates/reims-vgpu/src/graphics/nvidia/encode/tests.rs +++ b/crates/reims-vgpu/src/graphics/nvidia/encode/tests.rs @@ -1,9 +1,3 @@ -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; -use reims_vgpu_core::platform::resource::Buffer as _; -use reims_vgpu_core::raise::OnFault; -use reims_vgpu_core::testkit::FakePlatform; use reims_vgpu_graphics::ops::video::{ RGFX_VIDEO_ENCODE_OK, RGFX_VIDEO_ENCODE_OVERFLOW, RGFX_VIDEO_ENCODED_KEYFRAME, RGFX_VIDEO_ENCODED_PARAMETER_SETS, RgfxVideoEncodeResult, @@ -11,6 +5,12 @@ use reims_vgpu_graphics::ops::video::{ use reims_vgpu_graphics::wire::RGFX_VIDEO_DECODE; use reims_vgpu_video::core::runtime::{Runtime, StdRuntime}; use reims_vgpu_video::nvidia::{AnnexBCodec, AnnexBDecoder, GpuSelector, encode_profiles}; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::platform::device::GpuDevice as _; +use reims_vgpu_vulkan::core::platform::event::{EventRef, SharedEvent as _}; +use reims_vgpu_vulkan::core::platform::resource::Buffer as _; +use reims_vgpu_vulkan::core::raise::OnFault; +use reims_vgpu_vulkan::core::testkit::FakePlatform; use zerocopy::FromBytes; use super::super::super::decode::{GraphicsVideoSession, VideoEncode, VideoPlane}; diff --git a/crates/reims-vgpu/src/graphics/nvidia/tests.rs b/crates/reims-vgpu/src/graphics/nvidia/tests.rs index e5a3f21d0..1b91e45d1 100644 --- a/crates/reims-vgpu/src/graphics/nvidia/tests.rs +++ b/crates/reims-vgpu/src/graphics/nvidia/tests.rs @@ -3,14 +3,14 @@ use std::sync::Arc; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; -use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; -use reims_vgpu_core::platform::types::CommandBufferStatus; use reims_vgpu_video::core::device_memory::MemoryLife; use reims_vgpu_video::nvidia::{ EncodeParams, EncodeProfile, EncodeRateControl, NvencEncoder, RawFrame, Tuning, }; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::platform::blit::{BlitCmd, BlitEncoder as _}; +use reims_vgpu_vulkan::core::platform::command::{CommandBuffer as _, CommandQueue as _}; +use reims_vgpu_vulkan::core::platform::types::CommandBufferStatus; use super::*; diff --git a/crates/reims-vgpu/src/graphics/present.rs b/crates/reims-vgpu/src/graphics/present.rs index 9957547df..52dd40e50 100644 --- a/crates/reims-vgpu/src/graphics/present.rs +++ b/crates/reims-vgpu/src/graphics/present.rs @@ -79,12 +79,12 @@ use std::collections::{BTreeSet, HashMap, VecDeque}; use std::sync::Arc; use std::time::Duration; -use reims_vgpu_core::num::{ToU64 as _, ToUsize as _}; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::os::clock::MonoTime; -use reims_vgpu_core::sync::Mutex; use reims_vgpu_graphics::wire::{RGFX_CONTEXT_OBJ_ID_SHIFT, RGFX_STATUS_OK, RgfxSurfaceWriter}; use reims_vgpu_graphics::{CompletionPoster, PresentAnswer}; +use reims_vgpu_vulkan::core::num::{ToU64 as _, ToUsize as _}; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::platform::os::clock::MonoTime; +use reims_vgpu_vulkan::core::sync::Mutex; use super::color::ColorChange; use super::compile::Now; @@ -336,7 +336,9 @@ impl PresentQueue

{ state.queues.clear(); std::mem::take(&mut state.waiting) }; - if let Err(refusal) = reims_vgpu_core::raise::refusals::refusing(move || drop(waiting)) { + if let Err(refusal) = + reims_vgpu_vulkan::core::raise::refusals::refusing(move || drop(waiting)) + { log::warn!( target: "reims_vgpu::graphics", "the presents waiting were dropped at the device's reset, and a texture's release \ @@ -649,8 +651,8 @@ mod tests { use std::sync::atomic::{AtomicU64, Ordering}; - use reims_vgpu_core::platform::os::clock::MonoTime; - use reims_vgpu_core::sync::Mutex; + use reims_vgpu_vulkan::core::platform::os::clock::MonoTime; + use reims_vgpu_vulkan::core::sync::Mutex; use super::{Answer, Drawing, PresentAnswers, TIMING}; @@ -841,7 +843,7 @@ mod tests { /// its draw's end, and the refresh that answered it, counted from its take #[test] fn each_answer_logs_its_timing_at_debug() { - let logs = reims_vgpu_core::testkit::logs::capture(); + let logs = reims_vgpu_vulkan::core::testkit::logs::capture(); // A clock 100 us on at each read. let clock = AtomicU64::new(0); let answers = PresentAnswers::::new(Box::new(move || { diff --git a/crates/reims-vgpu/src/graphics/read.rs b/crates/reims-vgpu/src/graphics/read.rs index 3b7134c53..6e3952c44 100644 --- a/crates/reims-vgpu/src/graphics/read.rs +++ b/crates/reims-vgpu/src/graphics/read.rs @@ -19,15 +19,15 @@ use std::sync::{Arc, OnceLock}; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::command::CommandBuffer as _; -use reims_vgpu_core::platform::descriptor::TextureDescriptor as _; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::types::CommandBufferStatus; -use reims_vgpu_core::raise::OnFault; -use reims_vgpu_core::sync::Mutex; use reims_vgpu_graphics::Screen; use reims_vgpu_graphics::region::Region; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::platform::command::CommandBuffer as _; +use reims_vgpu_vulkan::core::platform::descriptor::TextureDescriptor as _; +use reims_vgpu_vulkan::core::platform::device::GpuDevice as _; +use reims_vgpu_vulkan::core::platform::types::CommandBufferStatus; +use reims_vgpu_vulkan::core::raise::OnFault; +use reims_vgpu_vulkan::core::sync::Mutex; use reims_vgpu_window::PixelRect; use super::sink::ScanoutDraw; diff --git a/crates/reims-vgpu/src/graphics/sink.rs b/crates/reims-vgpu/src/graphics/sink.rs index 643ec3b10..9b73b93b9 100644 --- a/crates/reims-vgpu/src/graphics/sink.rs +++ b/crates/reims-vgpu/src/graphics/sink.rs @@ -69,37 +69,37 @@ use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; -use reims_vgpu_core::host::HostPtr; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; -use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; -use reims_vgpu_core::platform::descriptor::RenderPassDescriptor as _; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::render::{RenderCmd, RenderEncoder as _}; -use reims_vgpu_core::platform::resource::Texture as _; -use reims_vgpu_core::platform::types::{ - ClearColor, CommandBufferStatus, MtlOrigin, MtlRegion, MtlSize, -}; -use reims_vgpu_core::platform::values::{ColorAttachmentSet, TextureDesc}; -use reims_vgpu_core::platform::{Handle, HostRange, Platform}; -use reims_vgpu_core::raise::{OnFault, RaiseResult, refusals}; -use reims_vgpu_core::sync::Mutex; use reims_vgpu_graphics::Scanout; use reims_vgpu_graphics::region::Region; +use reims_vgpu_vulkan::core::host::HostPtr; +use reims_vgpu_vulkan::core::platform::blit::{BlitCmd, BlitEncoder as _}; +use reims_vgpu_vulkan::core::platform::command::{CommandBuffer as _, CommandQueue as _}; +use reims_vgpu_vulkan::core::platform::descriptor::RenderPassDescriptor as _; +use reims_vgpu_vulkan::core::platform::device::GpuDevice as _; +use reims_vgpu_vulkan::core::platform::render::{RenderCmd, RenderEncoder as _}; +use reims_vgpu_vulkan::core::platform::resource::Texture as _; +use reims_vgpu_vulkan::core::platform::types::{ + ClearColor, CommandBufferStatus, MtlOrigin, MtlRegion, MtlSize, +}; +use reims_vgpu_vulkan::core::platform::values::{ColorAttachmentSet, TextureDesc}; +use reims_vgpu_vulkan::core::platform::{Handle, HostRange, Platform}; +use reims_vgpu_vulkan::core::raise::{OnFault, RaiseResult, refusals}; +use reims_vgpu_vulkan::core::sync::Mutex; use reims_vgpu_window::PixelRect; -use reims_vgpu_core::display::pipeline::{DisplayPipelineCache, PipelineKey}; -use reims_vgpu_core::platform::resource::Buffer as _; -use reims_vgpu_core::platform::types::MtlViewport; +use reims_vgpu_vulkan::core::display::pipeline::{DisplayPipelineCache, PipelineKey}; +use reims_vgpu_vulkan::core::platform::resource::Buffer as _; +use reims_vgpu_vulkan::core::platform::types::MtlViewport; use super::color::DisplayColor; use super::{DisplayHold, DrawnPresents, Presented, Shown}; use crate::entry::no_catch; use crate::platform::ApiPlatform; -use reims_vgpu_core::platform::resource::Library as _; -use reims_vgpu_core::platform::values::RenderPipelineDesc; use reims_vgpu_graphics::wire::{ RGFX_COLOR_MATRIX, RGFX_COLOR_PLANE_GAMMA, RGFX_COLOR_POST_GAMMA, RGFX_COLOR_PRE_GAMMA, }; +use reims_vgpu_vulkan::core::platform::resource::Library as _; +use reims_vgpu_vulkan::core::platform::values::RenderPipelineDesc; /// `MTLLoadActionClear`. const LOAD_ACTION_CLEAR: u64 = 2; @@ -118,7 +118,7 @@ pub(crate) struct ScanoutDraw { /// reads of the display, which no present waits on, draw on a queue the platform may share /// ([`ScanoutDraw::for_reads`]). /// - /// [`new_command_queue_unshared`]: reims_vgpu_core::platform::device::GpuDevice::new_command_queue_unshared + /// [`new_command_queue_unshared`]: reims_vgpu_vulkan::core::platform::device::GpuDevice::new_command_queue_unshared pub(crate) queue: P::CommandQueue, /// The device's region. region: Arc, @@ -1337,9 +1337,9 @@ impl ScanoutDraw

{ #[cfg(test)] mod tests { - use reims_vgpu_core::platform::ObjId; - use reims_vgpu_core::testkit::objects::{CompleteOn, kind}; - use reims_vgpu_core::testkit::{Arg, FakePlatform}; + use reims_vgpu_vulkan::core::platform::ObjId; + use reims_vgpu_vulkan::core::testkit::objects::{CompleteOn, kind}; + use reims_vgpu_vulkan::core::testkit::{Arg, FakePlatform}; use super::super::color::Table; use super::super::{DisplayHold, ShownTexture}; @@ -1466,7 +1466,7 @@ mod tests { /// `a_death_in_a_table_s_draw_refuses_that_draw_alone`) #[test] fn a_death_in_a_draw_refuses_that_draw_alone() { - use reims_vgpu_core::testkit::Step; + use reims_vgpu_vulkan::core::testkit::Step; let (platform, draw, presented, drawable) = rig(); draw.without_tables(); let log = platform.call_log(); @@ -1509,7 +1509,7 @@ mod tests { /// and commits #[test] fn a_death_in_a_table_s_draw_refuses_that_draw_alone() { - use reims_vgpu_core::testkit::Step; + use reims_vgpu_vulkan::core::testkit::Step; const BEGIN: &str = "renderCommandEncoderWithDescriptor:"; let (platform, draw, presented, drawable) = rig(); let log = platform.call_log(); diff --git a/crates/reims-vgpu/src/graphics/tests.rs b/crates/reims-vgpu/src/graphics/tests.rs index 2078f5869..a2c55d769 100644 --- a/crates/reims-vgpu/src/graphics/tests.rs +++ b/crates/reims-vgpu/src/graphics/tests.rs @@ -1,15 +1,15 @@ use std::sync::atomic::{AtomicU32, AtomicU64, Ordering}; use std::time::Duration; -use reims_vgpu_core::platform::ObjId; -use reims_vgpu_core::platform::device::GpuDevice; -use reims_vgpu_core::platform::types::CommandBufferStatus; -use reims_vgpu_core::testkit::faults::Fault; -use reims_vgpu_core::testkit::impls::device::FAKE_LINEAR_ROW_ALIGNMENT; -use reims_vgpu_core::testkit::objects::CompleteOn; -use reims_vgpu_core::testkit::{Arg, FakePlatform, HeldCall}; use reims_vgpu_graphics::ops::{RGFX_COMMAND_BUFFER_OPS_OFFSET, RgfxCommandBuffer}; use reims_vgpu_graphics::wire::*; +use reims_vgpu_vulkan::core::platform::ObjId; +use reims_vgpu_vulkan::core::platform::device::GpuDevice; +use reims_vgpu_vulkan::core::platform::types::CommandBufferStatus; +use reims_vgpu_vulkan::core::testkit::faults::Fault; +use reims_vgpu_vulkan::core::testkit::impls::device::FAKE_LINEAR_ROW_ALIGNMENT; +use reims_vgpu_vulkan::core::testkit::objects::CompleteOn; +use reims_vgpu_vulkan::core::testkit::{Arg, FakePlatform, HeldCall}; use zerocopy::{FromBytes, IntoBytes}; use super::*; @@ -152,8 +152,8 @@ fn the_device_reserves_the_guest_s_texture_ids_first() { /// start fresh #[test] fn on_vulkan_guest_texture_ids_are_kept_from_the_host_s() { - use reims_vgpu_core::platform::resource::Texture as _; - use reims_vgpu_core::platform::values::TextureDesc; + use reims_vgpu_vulkan::core::platform::resource::Texture as _; + use reims_vgpu_vulkan::core::platform::values::TextureDesc; let platform = crate::singleton::platform(); let config = GraphicsConfig { callbacks: GraphicsCallbacks { @@ -2058,7 +2058,7 @@ fn the_guest_s_cursor_reaches_the_host() { /// scanout moves or changes size, and kept to the region #[test] fn the_sink_imports_only_the_scanout_s_pages() { - use reims_vgpu_core::platform::resource::Buffer as _; + use reims_vgpu_vulkan::core::platform::resource::Buffer as _; const IMPORT: &str = "newBufferWithBytesNoCopy:length:options:deallocator:"; let platform = Arc::new(FakePlatform::new()); @@ -2069,7 +2069,7 @@ fn the_sink_imports_only_the_scanout_s_pages() { assert_eq!(platform.call_log().count(IMPORT), 0); // Its queue is unshared: each draw is on a present's path. { - use reims_vgpu_core::testkit::impls::device::UNSHARED_QUEUE; + use reims_vgpu_vulkan::core::testkit::impls::device::UNSHARED_QUEUE; assert_eq!(platform.call_log().count(UNSHARED_QUEUE), 1); assert_eq!(platform.call_log().count("newCommandQueue"), 0); } @@ -2177,7 +2177,7 @@ fn draws_the_scanout( drawable: &::Texture, stride: u64, ) -> bool { - use reims_vgpu_core::platform::resource::Texture as _; + use reims_vgpu_vulkan::core::platform::resource::Texture as _; let blits = platform.call_log().count(SCANOUT_BLIT); let rect = reims_vgpu_window::PixelRect { x: 0, @@ -2608,8 +2608,8 @@ fn display_color_entries(stage: u32, entries: &[[f32; 3]]) -> Vec { /// the black a fade ends on #[test] fn a_kept_present_s_table_reaches_the_next_drawn_frame() { - use reims_vgpu_core::platform::resource::Buffer as _; - use reims_vgpu_core::testkit::objects::kind; + use reims_vgpu_vulkan::core::platform::resource::Buffer as _; + use reims_vgpu_vulkan::core::testkit::objects::kind; const FRAGMENT_BUFFER: &str = "setFragmentBuffer:offset:atIndex:"; /// `displayPipeColorScanoutFragment`'s buffer of the post-gamma table. const POST_TABLE: u64 = 3; @@ -3226,8 +3226,8 @@ fn sampler_command_buffer(queue_obj_id: u64, cb_obj_id: u64, sampler: u64) -> Ve /// a walk in flight, which holds nothing device-wide. /// Whether a walk took the gate, stopped at it, and whether it is open; and their moves. type GateState = Arc<( - reims_vgpu_core::sync::Mutex<(bool, bool, bool)>, - reims_vgpu_core::sync::Condvar, + reims_vgpu_vulkan::core::sync::Mutex<(bool, bool, bool)>, + reims_vgpu_vulkan::core::sync::Condvar, )>; struct WalkGate { @@ -3251,8 +3251,8 @@ impl WalkGate { /// short buffer whose commit would wait for nothing stops there on its queue's service thread. fn in_place(device: &GraphicsDevice) -> WalkGate { let state = Arc::new(( - reims_vgpu_core::sync::Mutex::new((false, false, false)), - reims_vgpu_core::sync::Condvar::new(), + reims_vgpu_vulkan::core::sync::Mutex::new((false, false, false)), + reims_vgpu_vulkan::core::sync::Condvar::new(), )); let passed = Arc::new(AtomicU32::new(0)); let taken_on = Arc::new(super::Mutex::new(None)); @@ -3353,7 +3353,7 @@ fn create_queue_flagged( /// The platform's queue creators' calls, newest last, once `count` of them were made (about 2 s): /// each queue's handle is made on its service thread, after its create is answered. fn queue_calls(platform: &FakePlatform, count: usize) -> Vec<&'static str> { - use reims_vgpu_core::testkit::impls::device::UNSHARED_QUEUE; + use reims_vgpu_vulkan::core::testkit::impls::device::UNSHARED_QUEUE; let made = || -> Vec<&'static str> { let calls = platform.call_log().calls(); let creators = calls.iter().map(|c| c.sel); @@ -3375,7 +3375,7 @@ fn queue_calls(platform: &FakePlatform, count: usize) -> Vec<&'static str> { /// did not take the feature, a flagged create is refused and the platform makes no queue for it. #[test] fn a_queue_the_kext_asks_unshared_is_the_platforms_unshared_queue() { - use reims_vgpu_core::testkit::impls::device::UNSHARED_QUEUE; + use reims_vgpu_vulkan::core::testkit::impls::device::UNSHARED_QUEUE; const RING_DATA: u32 = 0x1_0000; let rings = |n: u64| { let at = RGFX_CONTEXT_ALLOCATIONS_OFFSET + n * 0x4_0000; @@ -4049,7 +4049,7 @@ fn a_reader_in_another_process_waits_on_the_gpu_for_an_answered_writer() { message[8..16].copy_from_slice(&seqno.to_le_bytes()); message }; - let events = |calls: &[reims_vgpu_core::testkit::calllog::Call], sel: &str| { + let events = |calls: &[reims_vgpu_vulkan::core::testkit::calllog::Call], sel: &str| { (calls.iter()) .filter(|c| c.sel == sel) .map(|c| (c.args[0].as_obj(), c.args[1].as_u64())) @@ -4140,7 +4140,7 @@ fn a_queue_s_buffers_are_waited_for_before_its_handle_is_made() { message[8..16].copy_from_slice(&seqno.to_le_bytes()); message }; - let events = |calls: &[reims_vgpu_core::testkit::calllog::Call], sel: &str| { + let events = |calls: &[reims_vgpu_vulkan::core::testkit::calllog::Call], sel: &str| { (calls.iter()) .filter(|c| c.sel == sel) .map(|c| (c.args[0].as_obj(), c.args[1].as_u64())) @@ -4594,7 +4594,7 @@ fn a_lone_video_buffer_is_walked_on_its_queue_s_service_thread() { let raised = Arc::new(AtomicU32::new(0)); let (device, platform, _guest, mut ring) = one_queue(&raised); - let threads = Arc::new(reims_vgpu_core::sync::Mutex::new(Vec::new())); + let threads = Arc::new(reims_vgpu_vulkan::core::sync::Mutex::new(Vec::new())); let seen = Arc::clone(&threads); device .control @@ -4640,8 +4640,8 @@ fn a_lone_video_buffer_is_walked_on_its_queue_s_service_thread() { /// their walks began. fn walk_threads( device: &GraphicsDevice, -) -> Arc>> { - let threads = Arc::new(reims_vgpu_core::sync::Mutex::new(Vec::new())); +) -> Arc>> { + let threads = Arc::new(reims_vgpu_vulkan::core::sync::Mutex::new(Vec::new())); let seen = Arc::clone(&threads); device .control @@ -5641,9 +5641,9 @@ fn a_managed_range_is_carried_out_before_a_later_command_buffer() { }; let modified = at( "didModifyRange:", - Some(Arg::val(&reims_vgpu_core::platform::types::NsRange::new( - 0x40, 0x10, - ))), + Some(Arg::val( + &reims_vgpu_vulkan::core::platform::types::NsRange::new(0x40, 0x10), + )), ); assert!(modified < at("commit", None)); } @@ -5696,8 +5696,10 @@ fn a_managed_range_behind_an_answered_walk_holds_up_nothing_on_ring_0() { RGFX_STATUS_OK, "ring 0 waited for the walk" ); - let modified = |calls: &[reims_vgpu_core::testkit::calllog::Call]| { - let range = Arg::val(&reims_vgpu_core::platform::types::NsRange::new(0x40, 0x10)); + let modified = |calls: &[reims_vgpu_vulkan::core::testkit::calllog::Call]| { + let range = Arg::val(&reims_vgpu_vulkan::core::platform::types::NsRange::new( + 0x40, 0x10, + )); (calls.iter()).position(|c| c.sel == "didModifyRange:" && c.args.first() == Some(&range)) }; assert_eq!( @@ -6973,7 +6975,7 @@ fn presents_waiting(device: &GraphicsDevice, n: usize) { /// The width of the texture the display shows; `None` for the scanout. fn shown_width(device: &GraphicsDevice) -> Option { - use reims_vgpu_core::platform::resource::Texture as _; + use reims_vgpu_vulkan::core::platform::resource::Texture as _; device .control .presented @@ -7168,7 +7170,7 @@ fn a_later_buffer_failed_at_once_shows_no_present_of_an_earlier_writer() { /// new layout, the cursor) is on the GPU; once the release is answered, no draw reads the block #[test] fn a_presented_surface_s_block_waits_for_the_display() { - use reims_vgpu_core::platform::command::CommandBuffer as _; + use reims_vgpu_vulkan::core::platform::command::CommandBuffer as _; let raised = Arc::new(AtomicU32::new(0)); let (device, platform) = headless_on(&raised); let (mut guest, _ring) = surface_and_queue(&device); @@ -7546,7 +7548,7 @@ fn a_release_the_platform_dies_at_is_refused() { /// device of no surface pages leaves as they were #[test] fn a_memory_map_gives_the_surface_pages_feature_on_a_guest_sized_page() { - use reims_vgpu_core::testkit::GuestRam; + use reims_vgpu_vulkan::core::testkit::GuestRam; let platform = Arc::new(FakePlatform::new()); let ram = GuestRam::with_range(0x10_0000, 0x10_0000).unwrap(); @@ -8632,12 +8634,13 @@ fn surface_device( ) -> ( GraphicsDevice, Arc, - reims_vgpu_core::testkit::GuestRam, + reims_vgpu_vulkan::core::testkit::GuestRam, u64, ) { let platform = Arc::new(FakePlatform::new()); let page = platform.vm().page_size(); - let ram = reims_vgpu_core::testkit::GuestRam::with_range(SURFACE_RAM, pages * page).unwrap(); + let ram = + reims_vgpu_vulkan::core::testkit::GuestRam::with_range(SURFACE_RAM, pages * page).unwrap(); platform.fake_vm().adopt(&ram); let mut map = crate::MemoryMap::new(); for r in ram.ranges() { @@ -9967,7 +9970,7 @@ fn submitted_then_scheduled(ring: &mut QueueRing, cb_obj_id: u64) { /// across its commit: the raise never comes on the committing thread #[test] fn a_foreign_commit_hands_a_decoder_buffer_s_records_to_its_queue_s_thread() { - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use reims_vgpu_vulkan::core::platform::command::{CommandBuffer as _, CommandQueue as _}; let caller = Arc::new(parking_lot::Mutex::new(())); let raises = Raises::default(); @@ -10177,7 +10180,7 @@ fn a_commit_on_the_device_s_thread_posts_a_decoder_buffer_s_records_there() { #[ignore = "a measurement, run by hand"] #[allow(clippy::disallowed_methods)] // a measurement: the wall clock's time fn a_handed_over_record_s_cost() { - use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; + use reims_vgpu_vulkan::core::platform::command::{CommandBuffer as _, CommandQueue as _}; use std::time::Instant; const ROUNDS: usize = 1000; diff --git a/crates/reims-vgpu/src/graphics/vaapi.rs b/crates/reims-vgpu/src/graphics/vaapi.rs index ee6d9d216..797cee5a2 100644 --- a/crates/reims-vgpu/src/graphics/vaapi.rs +++ b/crates/reims-vgpu/src/graphics/vaapi.rs @@ -34,9 +34,6 @@ use std::path::Path; use std::sync::{Arc, LazyLock, Weak}; -use reims_vgpu_core::platform::Handle as _; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::sync::Mutex; use reims_vgpu_graphics::wire::{ RGFX_VIDEO_CODEC_H264, RGFX_VIDEO_CODEC_HEVC, RGFX_VIDEO_DECODE, RGFX_VIDEO_ENCODE, RGFX_VIDEO_FORMAT_NV12, RGFX_VIDEO_FORMAT_P010, RGFX_VIDEO_H264_BASELINE, RGFX_VIDEO_H264_HIGH, @@ -52,6 +49,9 @@ use reims_vgpu_video::vaapi::{ Capabilities, ConfigCapabilities, Display, EncoderSupport, Entrypoint, Frame, GuestWrites, H264Decoder, HevcDecoder, ImportWrites, PlaneRows, Profile, encoder_support, }; +use reims_vgpu_vulkan::core::platform::Handle as _; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::sync::Mutex; use super::decode::{GraphicsVideo, GraphicsVideoSession, PlanePages}; use reims_vgpu_vulkan::VulkanPlatform; diff --git a/crates/reims-vgpu/src/graphics/vaapi/encode.rs b/crates/reims-vgpu/src/graphics/vaapi/encode.rs index 5ed46fcd2..94aa63bf4 100644 --- a/crates/reims-vgpu/src/graphics/vaapi/encode.rs +++ b/crates/reims-vgpu/src/graphics/vaapi/encode.rs @@ -21,7 +21,6 @@ use std::sync::Arc; -use reims_vgpu_core::sync::Mutex; use reims_vgpu_graphics::ops::video::{ RGFX_VIDEO_ENCODE_HARD_LIMIT, RGFX_VIDEO_ENTROPY_CABAC, RGFX_VIDEO_ENTROPY_CAVLC, RGFX_VIDEO_PICTURE_B, RGFX_VIDEO_PICTURE_I, RGFX_VIDEO_PICTURE_P, RGFX_VIDEO_RATE_CBR, @@ -37,6 +36,7 @@ use reims_vgpu_video::codec::encode::{ Profile as EncodeProfile, RateControl, }; use reims_vgpu_video::vaapi::{Capabilities, Display, EncoderSupport, VideoEncoder}; +use reims_vgpu_vulkan::core::sync::Mutex; use super::super::video_host::{ BackendError, EncodeFrame, EncodeSource, Encoded, HostEncodedFrame, HostEncoder, SourcePlane, diff --git a/crates/reims-vgpu/src/graphics/video_host.rs b/crates/reims-vgpu/src/graphics/video_host.rs index e75445004..7afcc4d42 100644 --- a/crates/reims-vgpu/src/graphics/video_host.rs +++ b/crates/reims-vgpu/src/graphics/video_host.rs @@ -48,18 +48,18 @@ use std::sync::{Arc, mpsc}; use std::time::Duration; -use reims_vgpu_core::host::HostPtr; -use reims_vgpu_core::platform::Handle as _; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::blit::{BlitCmd, BlitEncoder as _}; -use reims_vgpu_core::platform::command::{CommandBuffer as _, CommandQueue as _}; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; -use reims_vgpu_core::platform::resource::Buffer as _; -use reims_vgpu_core::platform::types::CommandBufferStatus; -use reims_vgpu_core::raise::{OnFault, Raise, RaiseResult}; -use reims_vgpu_core::sync::Mutex; use reims_vgpu_video::core::device_memory::MemoryIdentity; +use reims_vgpu_vulkan::core::host::HostPtr; +use reims_vgpu_vulkan::core::platform::Handle as _; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::platform::blit::{BlitCmd, BlitEncoder as _}; +use reims_vgpu_vulkan::core::platform::command::{CommandBuffer as _, CommandQueue as _}; +use reims_vgpu_vulkan::core::platform::device::GpuDevice as _; +use reims_vgpu_vulkan::core::platform::event::{EventRef, SharedEvent as _}; +use reims_vgpu_vulkan::core::platform::resource::Buffer as _; +use reims_vgpu_vulkan::core::platform::types::CommandBufferStatus; +use reims_vgpu_vulkan::core::raise::{OnFault, Raise, RaiseResult}; +use reims_vgpu_vulkan::core::sync::Mutex; use super::decode::{ Decoded, GraphicsVideoSession, Landed, PlanePages, VideoDecode, VideoPlane, op_fault, diff --git a/crates/reims-vgpu/src/graphics/video_host/encode.rs b/crates/reims-vgpu/src/graphics/video_host/encode.rs index 387951f2f..7bfba58e2 100644 --- a/crates/reims-vgpu/src/graphics/video_host/encode.rs +++ b/crates/reims-vgpu/src/graphics/video_host/encode.rs @@ -28,14 +28,6 @@ use std::sync::{Arc, mpsc}; -use reims_vgpu_core::host::HostPtr; -use reims_vgpu_core::platform::Handle as _; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::device::GpuDevice as _; -use reims_vgpu_core::platform::event::{EventRef, SharedEvent as _}; -use reims_vgpu_core::platform::resource::Buffer as _; -use reims_vgpu_core::raise::{Raise, RaiseResult}; -use reims_vgpu_core::sync::Mutex; use reims_vgpu_graphics::ops::video::{ RGFX_VIDEO_ENCODE_FAILED, RGFX_VIDEO_ENCODE_OK, RGFX_VIDEO_ENCODE_OVERFLOW, RGFX_VIDEO_ENCODED_KEYFRAME, RGFX_VIDEO_ENCODED_PARAMETER_SETS, RGFX_VIDEO_ENTROPY_CABAC, @@ -47,6 +39,14 @@ use reims_vgpu_graphics::wire::{ RGFX_VIDEO_H264_BASELINE, RGFX_VIDEO_H264_HIGH, RGFX_VIDEO_H264_MAIN, RGFX_VIDEO_HEVC_MAIN, RGFX_VIDEO_HEVC_MAIN_10, }; +use reims_vgpu_vulkan::core::host::HostPtr; +use reims_vgpu_vulkan::core::platform::Handle as _; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::platform::device::GpuDevice as _; +use reims_vgpu_vulkan::core::platform::event::{EventRef, SharedEvent as _}; +use reims_vgpu_vulkan::core::platform::resource::Buffer as _; +use reims_vgpu_vulkan::core::raise::{Raise, RaiseResult}; +use reims_vgpu_vulkan::core::sync::Mutex; use zerocopy::IntoBytes; use super::super::decode::{Decoded, GraphicsVideoSession, VideoDecode, VideoEncode, op_fault}; diff --git a/crates/reims-vgpu/src/graphics/video_host/encode/tests.rs b/crates/reims-vgpu/src/graphics/video_host/encode/tests.rs index 27af393fe..fce946589 100644 --- a/crates/reims-vgpu/src/graphics/video_host/encode/tests.rs +++ b/crates/reims-vgpu/src/graphics/video_host/encode/tests.rs @@ -1,11 +1,11 @@ use std::collections::VecDeque; -use reims_vgpu_core::raise::OnFault; -use reims_vgpu_core::testkit::FakePlatform; -use reims_vgpu_core::testkit::calllog::Arg; -use reims_vgpu_core::testkit::objects::CompleteOn; use reims_vgpu_graphics::ops::video::{RGFX_VIDEO_PICTURE_I, RGFX_VIDEO_PICTURE_P}; use reims_vgpu_graphics::wire::RGFX_VIDEO_CODEC_H264; +use reims_vgpu_vulkan::core::raise::OnFault; +use reims_vgpu_vulkan::core::testkit::FakePlatform; +use reims_vgpu_vulkan::core::testkit::calllog::Arg; +use reims_vgpu_vulkan::core::testkit::objects::CompleteOn; use zerocopy::FromBytes; use super::super::super::decode::VideoPlane; diff --git a/crates/reims-vgpu/src/graphics/video_host/tests.rs b/crates/reims-vgpu/src/graphics/video_host/tests.rs index e0fb13726..2ddcea700 100644 --- a/crates/reims-vgpu/src/graphics/video_host/tests.rs +++ b/crates/reims-vgpu/src/graphics/video_host/tests.rs @@ -1,10 +1,10 @@ use std::collections::VecDeque; use std::time::Duration; -use reims_vgpu_core::testkit::FakePlatform; -use reims_vgpu_core::testkit::calllog::Arg; -use reims_vgpu_core::testkit::objects::CompleteOn; use reims_vgpu_graphics::wire::RGFX_VIDEO_CODEC_H264; +use reims_vgpu_vulkan::core::testkit::FakePlatform; +use reims_vgpu_vulkan::core::testkit::calllog::Arg; +use reims_vgpu_vulkan::core::testkit::objects::CompleteOn; use super::*; diff --git a/crates/reims-vgpu/src/graphics/vulkan.rs b/crates/reims-vgpu/src/graphics/vulkan.rs index 92f4c2e4e..c2302909f 100644 --- a/crates/reims-vgpu/src/graphics/vulkan.rs +++ b/crates/reims-vgpu/src/graphics/vulkan.rs @@ -4,10 +4,10 @@ use std::sync::Arc; -use reims_vgpu_core::platform::command::CommandBuffer as _; -use reims_vgpu_core::raise::OnFault; use reims_vgpu_graphics::region::Region; use reims_vgpu_vulkan::VulkanPlatform; +use reims_vgpu_vulkan::core::platform::command::CommandBuffer as _; +use reims_vgpu_vulkan::core::raise::OnFault; use reims_vgpu_vulkan::swapchain::{Acquired, Swapchain}; use reims_vgpu_window::{Drawn, DrawnCursor, FrameSink, PixelRect, Presenter, VulkanTarget}; diff --git a/crates/reims-vgpu/src/memory.rs b/crates/reims-vgpu/src/memory.rs index d58547a58..7b58e6ba9 100644 --- a/crates/reims-vgpu/src/memory.rs +++ b/crates/reims-vgpu/src/memory.rs @@ -6,8 +6,8 @@ use std::any::Any; use std::os::fd::OwnedFd; use std::sync::Arc; -use reims_vgpu_core::host::HostPtr; -use reims_vgpu_core::memory::descriptor::{ +use reims_vgpu_vulkan::core::host::HostPtr; +use reims_vgpu_vulkan::core::memory::descriptor::{ GuestPhysicalRange, MemoryMapDescriptor as CoreMemoryMap, }; diff --git a/crates/reims-vgpu/src/platform.rs b/crates/reims-vgpu/src/platform.rs index 184be1a90..fdd2e39de 100644 --- a/crates/reims-vgpu/src/platform.rs +++ b/crates/reims-vgpu/src/platform.rs @@ -5,7 +5,7 @@ //! **The display thread.** A graphics device queues its host's cursor callbacks onto one core //! [`SerialQueue`], made at the process's first device whose host takes them (`graphics`' //! `HostCursor`), so every display callback of the process runs one at a time in the order it -//! was queued. The queue's worker exits after [`reims_vgpu_core::rt::queue::IDLE_EXIT`] idle and +//! was queued. The queue's worker exits after [`reims_vgpu_vulkan::core::rt::queue::IDLE_EXIT`] idle and //! the next job starts another. The library never waits for it, and a queue's drop joins nothing. //! //! **By platform.** The Vulkan platform's `ApiPlatform` is `platform/vulkan.rs`. @@ -13,10 +13,10 @@ use std::any::Any; use std::sync::{Arc, OnceLock, Weak}; -use reims_vgpu_core::host::HostQueue; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::rt::{Executor, Job, SerialQueue}; -use reims_vgpu_core::sync::Mutex; +use reims_vgpu_vulkan::core::host::HostQueue; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::rt::{Executor, Job, SerialQueue}; +use reims_vgpu_vulkan::core::sync::Mutex; use crate::memory::MemoryMap; @@ -141,8 +141,8 @@ pub(crate) use vulkan::host_dma_buf; #[cfg(any(test, feature = "testkit"))] mod fake { - use reims_vgpu_core::testkit::FakePlatform; - use reims_vgpu_core::testkit::platform::FAKE_REGISTRY_ID; + use reims_vgpu_vulkan::core::testkit::FakePlatform; + use reims_vgpu_vulkan::core::testkit::platform::FAKE_REGISTRY_ID; use super::*; @@ -180,7 +180,7 @@ mod fake { mod tests { use std::sync::mpsc; - use reims_vgpu_core::testkit::FakePlatform; + use reims_vgpu_vulkan::core::testkit::FakePlatform; use super::*; @@ -219,8 +219,8 @@ mod tests { /// the platform answers for it, and none for an ID no device has (`UINT64_MAX`) #[test] fn vulkan_devices_by_registry_id() { - use reims_vgpu_core::platform::Handle as _; use reims_vgpu_vulkan::VulkanPlatform; + use reims_vgpu_vulkan::core::platform::Handle as _; let p = VulkanPlatform::new(); let d = p.metal_device(None).expect("a Vulkan device (MoltenVK)"); @@ -238,8 +238,8 @@ mod tests { fn the_vulkan_lease_lets_views_be_made_of_the_guests_ram() { use std::os::fd::{AsRawFd as _, FromRawFd as _, OwnedFd}; - use reims_vgpu_core::platform::os::vm::{HostAddr, HostVm as _}; use reims_vgpu_vulkan::VulkanPlatform; + use reims_vgpu_vulkan::core::platform::os::vm::{HostAddr, HostVm as _}; use reims_vgpu_vulkan::os::OsVm; use crate::memory::MemoryFile; diff --git a/crates/reims-vgpu/src/platform/vulkan.rs b/crates/reims-vgpu/src/platform/vulkan.rs index 3363c2e6b..4ce506c65 100644 --- a/crates/reims-vgpu/src/platform/vulkan.rs +++ b/crates/reims-vgpu/src/platform/vulkan.rs @@ -1,9 +1,9 @@ //! `VulkanPlatform` as an `ApiPlatform`: the runtime's devices, on macOS over MoltenVK, and on //! Linux natively. -use reims_vgpu_core::num::ToU64 as _; -use reims_vgpu_core::platform::Platform; use reims_vgpu_vulkan::VulkanPlatform; +use reims_vgpu_vulkan::core::num::ToU64 as _; +use reims_vgpu_vulkan::core::platform::Platform; use reims_vgpu_vulkan::os::GuestRamFile; use super::*; diff --git a/crates/reims-vgpu/src/platform/vulkan/dma_buf.rs b/crates/reims-vgpu/src/platform/vulkan/dma_buf.rs index 7450312ee..49e6c00bf 100644 --- a/crates/reims-vgpu/src/platform/vulkan/dma_buf.rs +++ b/crates/reims-vgpu/src/platform/vulkan/dma_buf.rs @@ -5,8 +5,8 @@ use std::ptr::NonNull; -use reims_vgpu_core::num::ToU64 as _; use reims_vgpu_video::core::device_memory::{DmaBufError, SurfaceDmaBuf}; +use reims_vgpu_vulkan::core::num::ToU64 as _; use reims_vgpu_vulkan::os::{LendRefusal, dma_buf_of_host}; /// A dma-buf of `ranges` of the `length` bytes from `first`, memory the library mapped from files diff --git a/crates/reims-vgpu/src/singleton.rs b/crates/reims-vgpu/src/singleton.rs index 4eb1b91c2..672178adc 100644 --- a/crates/reims-vgpu/src/singleton.rs +++ b/crates/reims-vgpu/src/singleton.rs @@ -4,13 +4,13 @@ //! platform instance (D17), so every public constructor goes through the process's: [`platform`], //! one `VulkanPlatform` per process, made on first use. Making it installs the aborting panic hook //! first (6.5), then the stderr logger if `REIMS_VGPU_LOG` asks for it -//! (`reims_vgpu_core::logging::init`). Every function of the C API installs the hook too, before +//! (`reims_vgpu_vulkan::core::logging::init`). Every function of the C API installs the hook too, before //! its body runs, since some make no platform. use std::sync::{Arc, Once, OnceLock}; -use reims_vgpu_core::rt::is_our_thread; use reims_vgpu_vulkan::VulkanPlatform; +use reims_vgpu_vulkan::core::rt::is_our_thread; static PLATFORM: OnceLock> = OnceLock::new(); static HOOK: Once = Once::new(); @@ -21,7 +21,7 @@ pub fn platform() -> Arc { PLATFORM .get_or_init(|| { install_panic_hook(); - reims_vgpu_core::logging::init(); + reims_vgpu_vulkan::core::logging::init(); Arc::new(VulkanPlatform::new()) }) .clone() @@ -38,7 +38,7 @@ pub(crate) fn hook_message(info: &dyn std::fmt::Display) -> String { /// process as a death does: one line on stderr, then `abort()`, before anything unwinds, so no /// panic crosses into the host's frames and no drop runs first. Inside a refusal scope (the /// graphics lane's ops) it is refused as a death there is: the line is written, and the panic -/// unwinds to the scope, which refuses the op (`reims_vgpu_core::raise::refusals`, "Panics"). A +/// unwinds to the scope, which refuses the op (`reims_vgpu_vulkan::core::raise::refusals`, "Panics"). A /// panic anywhere else is the host's own, and goes to the previous hook. pub fn install_panic_hook() { HOOK.call_once(|| { @@ -47,7 +47,7 @@ pub fn install_panic_hook() { if is_our_thread() { use std::io::Write as _; let _ = std::io::stderr().write_all(hook_message(info).as_bytes()); - if reims_vgpu_core::raise::refusals::refuses_panics() { + if reims_vgpu_vulkan::core::raise::refusals::refuses_panics() { return; } #[allow(clippy::disallowed_methods)] // a panic's abort (6.5) @@ -80,12 +80,12 @@ mod tests { /// capture off, as the product runs. #[test] fn a_panic_in_a_refusal_scope_is_refused_and_the_process_goes_on() { - use reims_vgpu_core::raise::death::DeathId; - use reims_vgpu_core::raise::refusals::refusing; + use reims_vgpu_vulkan::core::raise::death::DeathId; + use reims_vgpu_vulkan::core::raise::refusals::refusing; if std::env::var_os("RVG_SCOPED_PANIC_CHILD").is_some() { - reims_vgpu_core::testkit::capture::set_capture_enabled(false); + reims_vgpu_vulkan::core::testkit::capture::set_capture_enabled(false); install_panic_hook(); - let _ours = reims_vgpu_core::rt::enter_ours(); + let _ours = reims_vgpu_vulkan::core::rt::enter_ours(); let r: Result<(), _> = refusing(|| panic!("in a guest op")); assert_eq!(r.unwrap_err().id, DeathId::Panic); let _ = std::io::Write::write_all(&mut std::io::stderr(), b"the process goes on\n"); @@ -118,7 +118,7 @@ mod tests { let b = platform(); assert!(Arc::ptr_eq(&a, &b)); // The hook is in: a panic on our thread now aborts. - let _ours = reims_vgpu_core::rt::enter_ours(); + let _ours = reims_vgpu_vulkan::core::rt::enter_ours(); panic!("after platform()"); } let out = child( @@ -147,7 +147,7 @@ mod tests { } } install_panic_hook(); - let _ours = reims_vgpu_core::rt::enter_ours(); + let _ours = reims_vgpu_vulkan::core::rt::enter_ours(); let _l = Loud; panic!("ours panic"); } diff --git a/crates/reims-vgpu/src/video/runtime.rs b/crates/reims-vgpu/src/video/runtime.rs index 36f9e0388..715c7d8ac 100644 --- a/crates/reims-vgpu/src/video/runtime.rs +++ b/crates/reims-vgpu/src/video/runtime.rs @@ -17,13 +17,13 @@ use std::sync::Arc; -use reims_vgpu_core::platform::Platform; -use reims_vgpu_core::platform::os::{Clock as _, Deadline, MonoTime as CoreTime}; -#[cfg(doc)] -use reims_vgpu_core::platform::os::{Clock, Threads}; -use reims_vgpu_core::rt::enter_ours; use reims_vgpu_video::core::runtime::{MonoTime, Rings, Runtime, TimedOut}; use reims_vgpu_video::core::sync::{Condvar, MutexGuard}; +use reims_vgpu_vulkan::core::platform::Platform; +use reims_vgpu_vulkan::core::platform::os::{Clock as _, Deadline, MonoTime as CoreTime}; +#[cfg(doc)] +use reims_vgpu_vulkan::core::platform::os::{Clock, Threads}; +use reims_vgpu_vulkan::core::rt::enter_ours; /// `P` as a video crate's runtime (module doc). pub(crate) struct PlatformRuntime(Arc

); @@ -66,9 +66,9 @@ impl Runtime for PlatformRuntime

{ mod tests { use std::time::Duration; - use reims_vgpu_core::rt::is_our_thread; - use reims_vgpu_core::testkit::FakePlatform; use reims_vgpu_video::core::runtime::{Bell, StdRuntime, Unanswered, answer}; + use reims_vgpu_vulkan::core::rt::is_our_thread; + use reims_vgpu_vulkan::core::testkit::FakePlatform; use super::*; diff --git a/docs/development.md b/docs/development.md index c6acea1b2..a4e4b1f46 100644 --- a/docs/development.md +++ b/docs/development.md @@ -298,7 +298,7 @@ Set in `Cargo.toml` (architecture 2.3): SDL3's window on macOS, which `REIMS_VGPU_WINDOW_IMPL=sdl` opens in place of AppKit's. Without it the macOS library has no SDL. - `reims-vgpu-window/sdl-no-link`: SDL left unbuilt, for the Linux target's clippy on a Mac. -- `reims-vgpu-core/testkit`: `core::testkit` for other crates' tests. +- `reims-vgpu-vulkan/testkit`: `core::testkit` for other crates' tests. - `reims-vgpu/testkit`: the same, through the public crate, and each handle's core object. [api.md](api.md) section 2 lists the device's settings and the environment variables the library diff --git a/scripts/internal/lane-gate.sh b/scripts/internal/lane-gate.sh index b34320774..6eac507d4 100755 --- a/scripts/internal/lane-gate.sh +++ b/scripts/internal/lane-gate.sh @@ -358,7 +358,7 @@ do_cargo() { expr="$expr | package($p)" done echo "packages: ${pkgs[*]}; filter: $expr" - local feats=reims-vgpu-core/testkit,reims-vgpu/testkit,reims-vgpu/vulkan + local feats=reims-vgpu-vulkan/testkit,reims-vgpu/testkit,reims-vgpu/vulkan printf '[profile.default.junit]\npath = "junit.xml"\n' > "$GH/nextest-tool.toml" cargo nextest run --no-run "${pkgs[@]}" --features "$feats" # nextest keeps its store under the workspace's target/, whatever CARGO_TARGET_DIR says. diff --git a/xtask/src/dist/linux.rs b/xtask/src/dist/linux.rs index b8f300cf6..6eb3100dd 100644 --- a/xtask/src/dist/linux.rs +++ b/xtask/src/dist/linux.rs @@ -203,7 +203,7 @@ mod tests { /// What `cargo rustc --message-format json -- --print native-static-libs` prints: the note, /// once as its message and once rendered, among the other messages. - const CARGO: &str = r#"{"reason":"compiler-artifact","package_id":"path+file:///r/crates/reims-vgpu-core#0.1.0","filenames":["/t/release/deps/libreims_vgpu_core.rlib"],"fresh":true} + const CARGO: &str = r#"{"reason":"compiler-artifact","package_id":"path+file:///r/crates/reims-vgpu-vulkan#0.1.0","filenames":["/t/release/deps/libreims_vgpu_vulkan.rlib"],"fresh":true} {"reason":"compiler-message","package_id":"path+file:///r/crates/reims-vgpu-c#0.1.0","message":{"rendered":"note: Link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms.\n\n","children":[],"level":"note","message":"Link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms.","spans":[]}} {"reason":"compiler-message","package_id":"path+file:///r/crates/reims-vgpu-c#0.1.0","message":{"rendered":"note: native-static-libs: -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc\n\n","children":[],"level":"note","message":"native-static-libs: -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc","spans":[]}} {"reason":"build-finished","success":true}"#; diff --git a/xtask/src/lint.rs b/xtask/src/lint.rs index 29c5a26eb..fe89b0909 100644 --- a/xtask/src/lint.rs +++ b/xtask/src/lint.rs @@ -1,6 +1,6 @@ -//! The testkit manifest check (D50): the testkit stays out of the product. Core declares its -//! `testkit` module under `#[cfg(any(test, feature = "testkit"))]`, and only dev-dependencies -//! turn the feature on, so a product build cannot name it. +//! The testkit manifest check (D50): the testkit stays out of the product. The Vulkan crate's +//! `core` module declares its `testkit` module under `#[cfg(any(test, feature = "testkit"))]`, and +//! only dev-dependencies turn the crate's feature on, so a product build cannot name it. /// A check's result: errors fail the command. #[derive(Debug, Default, Clone, PartialEq, Eq)] @@ -8,10 +8,10 @@ pub struct Report { pub errors: Vec, } -/// The gate core's `lib.rs` puts on its testkit module. +/// The gate core's `core.rs` puts on its testkit module. const GATE: &str = "#[cfg(any(test, feature = \"testkit\"))]"; -/// Checks core's `lib.rs` (`lib`, its text) and the crates' manifests (path, text). +/// Checks core's `core.rs` (`lib`, its text) and the crates' manifests (path, text). pub fn testkit_manifests(lib: &str, manifests: &[(String, String)]) -> Report { let mut rep = Report::default(); let mut prev = ""; @@ -19,7 +19,7 @@ pub fn testkit_manifests(lib: &str, manifests: &[(String, String)]) -> Report { let t = line.trim(); if (t.starts_with("pub mod testkit") || t.starts_with("mod testkit")) && prev != GATE { rep.errors.push(format!( - "crates/reims-vgpu-core/src/lib.rs:{}: `mod testkit` must be under {GATE} (D50)", + "crates/reims-vgpu-vulkan/src/core.rs:{}: `mod testkit` must be under {GATE} (D50)", i + 1 )); } @@ -37,7 +37,7 @@ pub fn testkit_manifests(lib: &str, manifests: &[(String, String)]) -> Report { } let dev = section.contains("dev-dependencies"); let deps = section.contains("dependencies"); - if deps && !dev && t.starts_with("reims-vgpu-core") && t.contains("\"testkit\"") { + if deps && !dev && t.starts_with("reims-vgpu-vulkan") && t.contains("\"testkit\"") { rep.errors.push(format!( "{path}:{}: the `testkit` feature outside [dev-dependencies] (D50)", i + 1 @@ -63,7 +63,7 @@ mod tests { let lib = "#[cfg(any(test, feature = \"testkit\"))]\npub mod testkit;\npub mod real;\n"; let manifests = vec![( "crates/a/Cargo.toml".to_owned(), - "[dependencies]\nreims-vgpu-core = { path = \"x\", features = [\"testkit\"] }\n[dev-dependencies]\nreims-vgpu-core = { path = \"x\", features = [\"testkit\"] }\n[features]\ndefault = [\"testkit\"]\n".to_owned(), + "[dependencies]\nreims-vgpu-vulkan = { path = \"x\", features = [\"testkit\"] }\n[dev-dependencies]\nreims-vgpu-vulkan = { path = \"x\", features = [\"testkit\"] }\n[features]\ndefault = [\"testkit\"]\n".to_owned(), )]; let r = testkit_manifests(lib, &manifests); assert_eq!(r.errors.len(), 2, "{:#?}", r.errors); @@ -72,6 +72,6 @@ mod tests { assert!(testkit_manifests(lib, &[]).errors.is_empty()); let ungated = testkit_manifests("pub mod testkit;\n", &[]); assert_eq!(ungated.errors.len(), 1); - assert!(ungated.errors[0].contains("lib.rs:1")); + assert!(ungated.errors[0].contains("core.rs:1")); } } diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 8035c16d0..e6fa335df 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -102,7 +102,7 @@ fn show(name: &str, rep: &lint::Report) -> bool { fn cmd_testkit(_args: &[String]) -> Res { let root = repo_root(); - let lib = read(&root.join("crates/reims-vgpu-core/src/lib.rs"))?; + let lib = read(&root.join("crates/reims-vgpu-vulkan/src/core.rs"))?; let mut manifests = Vec::new(); for p in util::walk(&root.join("crates"), &["Cargo.toml"]) { manifests.push((util::rel(&p, &root), read(&p)?)); @@ -149,15 +149,15 @@ fn make(args: &[&str]) -> Res { /// nothing now that the Vulkan platform is the library's only one, and which the builds that name /// them keep. Clippy lints with every feature as well. const TESTED_FEATURES: &str = - "reims-vgpu-core/testkit,reims-vgpu/testkit,reims-vgpu/vulkan,reims-vgpu-c/vulkan"; + "reims-vgpu-vulkan/testkit,reims-vgpu/testkit,reims-vgpu/vulkan,reims-vgpu-c/vulkan"; /// The Linux the library ships for, which a Mac type-checks. const LINUX_TARGET: &str = "x86_64-unknown-linux-gnu"; /// The features a Mac type-checks Linux with: [`TESTED_FEATURES`], and SDL's sources left /// unbuilt, as a Mac has no Linux C toolchain for them and nothing links. -const LINUX_CHECK_FEATURES: &str = "reims-vgpu-core/testkit,reims-vgpu/testkit,reims-vgpu/vulkan,\ - reims-vgpu-c/vulkan,reims-vgpu-window/sdl-no-link"; +const LINUX_CHECK_FEATURES: &str = "reims-vgpu-vulkan/testkit,reims-vgpu/testkit,\ + reims-vgpu/vulkan,reims-vgpu-c/vulkan,reims-vgpu-window/sdl-no-link"; /// The variable jemalloc's build script (`tikv-jemalloc-sys`, the C API's allocator on /// [`LINUX_TARGET`]) reads for that target as a library to link in place of the one it builds. A @@ -178,6 +178,10 @@ fn empty_archive() -> Res { /// The macOS core's tests run as under Rosetta, with the x86-64 guest's pages. const X86_64_MACOS_TARGET: &str = "x86_64-apple-darwin"; +/// core's tests, which run as [`X86_64_MACOS_TARGET`] too: the Vulkan crate's unit tests in its +/// `core` module, a nextest filter over the crate's library (`-p reims-vgpu-vulkan --lib`). +const CORE_TESTS: &str = "test(/^core::/)"; + /// Whether this Mac runs x86-64 code: an x86-64 `true` run under `arch -x86_64` exits 0, which /// it does where Rosetta is installed (and on an Intel Mac); without Rosetta the launch fails. fn runs_x86_64() -> bool { @@ -236,10 +240,13 @@ fn cmd_check(args: &[String]) -> Res { "nextest", "run", "-p", - "reims-vgpu-core", + "reims-vgpu-vulkan", + "--lib", "--target", X86_64_MACOS_TARGET, "--no-fail-fast", + "-E", + CORE_TESTS, ])?; } else { println!(