Skip to content

Commit

Permalink
bump craballoc, use labels
Browse files Browse the repository at this point in the history
  • Loading branch information
schell committed Jan 8, 2025
1 parent 663509f commit 5e9ad0c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion crates/renderling/src/bloom/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
);
Expand Down
4 changes: 2 additions & 2 deletions crates/renderling/src/cull/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -236,7 +236,7 @@ impl DepthPyramid {
}

pub fn new(runtime: impl AsRef<WgpuRuntime>, 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);

Expand Down
39 changes: 17 additions & 22 deletions crates/renderling/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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()
Expand All @@ -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<f32> = stage.new_value(1337.0);
//!
Expand All @@ -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()
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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};

Expand All @@ -193,7 +188,7 @@ pub mod prelude {
transform::Transform,
};

#[cfg(not(target_arch = "spirv"))]
#[cfg(cpu)]
pub use crate::context::*;
}

Expand Down

0 comments on commit 5e9ad0c

Please sign in to comment.