diff --git a/Cargo.lock b/Cargo.lock index ca1f4cf..b64b450 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -695,9 +695,9 @@ dependencies = [ [[package]] name = "craballoc" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c4dfc568222e8df817d040c32671317994601bcac4a472cebfa37f3e1f27403" +checksum = "b378ae0de786477bac466f4ecd4a102402cd3a08cc05de38c0ae07443e9e1b0f" dependencies = [ "async-channel 1.9.0", "bytemuck", diff --git a/Cargo.toml b/Cargo.toml index b68be36..7e67589 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ async-channel = "1.8" bytemuck = { version = "1.13.0", features = ["derive"] } cfg_aliases = "0.2" clap = { version = "4.5.23", features = ["derive"] } -craballoc = { version = "0.1.0" } +craballoc = { version = "0.1.1" } crabslab = { version = "0.6.3", default-features = false } ctor = "0.2.2" dagga = "0.2.1" diff --git a/crates/renderling/src/bloom/cpu.rs b/crates/renderling/src/bloom/cpu.rs index c60b0bb..1ad04d1 100644 --- a/crates/renderling/src/bloom/cpu.rs +++ b/crates/renderling/src/bloom/cpu.rs @@ -406,7 +406,8 @@ impl Bloom { let runtime = runtime.as_ref(); let resolution = UVec2::new(hdr_texture.width(), hdr_texture.height()); - let slab = SlabAllocator::new(runtime, wgpu::BufferUsages::empty()); + let slab = + SlabAllocator::new_with_label(runtime, wgpu::BufferUsages::empty(), Some("bloom-slab")); let downsample_pixel_sizes = slab.new_array( config_resolutions(resolution).map(|r| 1.0 / Vec2::new(r.x as f32, r.y as f32)), ); diff --git a/crates/renderling/src/cull/cpu.rs b/crates/renderling/src/cull/cpu.rs index b577dcb..1e47175 100644 --- a/crates/renderling/src/cull/cpu.rs +++ b/crates/renderling/src/cull/cpu.rs @@ -210,7 +210,7 @@ pub struct DepthPyramid { } impl DepthPyramid { - const _LABEL: Option<&'static str> = Some("depth-pyramid"); + const LABEL: Option<&'static str> = Some("depth-pyramid"); fn allocate( size: UVec2, @@ -236,7 +236,7 @@ impl DepthPyramid { } pub fn new(runtime: impl AsRef, size: UVec2) -> Self { - let slab = SlabAllocator::new(runtime, wgpu::BufferUsages::empty()); + let slab = SlabAllocator::new_with_label(runtime, wgpu::BufferUsages::empty(), Self::LABEL); let desc = slab.new_value(DepthPyramidDescriptor::default()); let (mip_data, mip) = Self::allocate(size, &desc, &slab); diff --git a/crates/renderling/src/lib.rs b/crates/renderling/src/lib.rs index e751051..a812988 100644 --- a/crates/renderling/src/lib.rs +++ b/crates/renderling/src/lib.rs @@ -10,7 +10,7 @@ //! First you must create a [`crate::context::Context`]. //! //! ``` -//! use renderling::Context; +//! use renderling::prelude::*; //! //! // create a headless context with dimensions 100, 100. //! let ctx = Context::headless(100, 100); @@ -19,8 +19,7 @@ //! Then create a stage to place your camera, geometry, materials and lights. //! //! ``` -//! # use renderling::Context; -//! use renderling::stage::Stage; +//! # use renderling::prelude::*; //! # let ctx = Context::headless(100, 100); //! let stage: Stage = ctx //! .new_stage() @@ -32,15 +31,19 @@ //! The stage is neat in that it allows you to place values and arrays of values //! directly onto the GPU. Those values can be modified on the CPU and //! synchronization will happen during -//! [`Stage::render`](crate::stage::Stage::render). These values are called -//! [`Hybrid`](crate::slab::Hybrid)s and -//! [`HybridArray`](crate::slab::HybridArray)s. +//! [`Stage::render`](crate::stage::Stage::render). +//! +//! These values are called +//! [`Hybrid`](craballoc::Hybrid)s and +//! [`HybridArray`](craballoc::HybridArray)s. +//! +//! They come from the [`craballoc`] library, which is re-exported +//! from [the prelude](crate::prelude). //! //! ``` -//! # use renderling::{Context, stage::Stage}; +//! # use renderling::prelude::*; //! # let ctx = Context::headless(100, 100); //! # let stage: Stage = ctx.new_stage(); -//! use renderling::slab::{Hybrid, HybridArray}; //! //! let an_f32: Hybrid = stage.new_value(1337.0); //! @@ -57,13 +60,10 @@ //! counter-clockwise winding. //! //! ``` -//! # use renderling::{Context, stage::Stage}; +//! # use renderling::prelude::*; //! # let ctx = Context::headless(100, 100); //! # let stage: Stage = ctx.new_stage(); -//! use renderling::{ -//! camera::Camera, -//! stage::{Renderlet, Vertex}, -//! }; +//! //! let camera = stage.new_value(Camera::default_ortho2d(100.0, 100.0)); //! let vertices = stage.new_array([ //! Vertex::default() @@ -93,14 +93,7 @@ //! frame with [`Frame::present`]. //! //! ``` -//! # use renderling::{ -//! # Context, -//! # camera::Camera, -//! # stage::{ -//! # Vertex, -//! # Renderlet, -//! # } -//! # }; +//! # use renderling::prelude::*; //! # let ctx = Context::headless(100, 100); //! # let stage = ctx.new_stage(); //! # let camera = stage.new_value(Camera::default_ortho2d(100.0, 100.0)); @@ -180,9 +173,11 @@ pub use context::*; pub mod prelude { //! A prelude, meant to be glob-imported. + #[cfg(cpu)] pub extern crate craballoc; pub extern crate glam; + #[cfg(cpu)] pub use craballoc::prelude::*; pub use crabslab::{Array, Id}; @@ -193,7 +188,7 @@ pub mod prelude { transform::Transform, }; - #[cfg(not(target_arch = "spirv"))] + #[cfg(cpu)] pub use crate::context::*; }