Skip to content

Commit

Permalink
feature: part out slab allocator into craballoc (#151)
Browse files Browse the repository at this point in the history
* feature: part out slab allocator into craballoc

* checkpoint

* refactor: Update function signatures to use WgpuRuntime instead of device and queue

* refactor: Simplify texture creation by passing runtime directly

* refactor: Update create_depth_texture to use WgpuRuntime instead of device

* refactor: Simplify HDR texture creation by using WgpuRuntime reference

* refactor: Replace device and queue parameters with WgpuRuntime reference

* refactor: Update functions to use device and queue parameters directly

* change many device, queue params into impl AsRef<WgpuRuntime>

* clippy

* update crabslab

* bump crabslab

* rebase on main

* bump craballoc, use labels
  • Loading branch information
schell authored Jan 8, 2025
1 parent c2c096e commit 74d06bc
Show file tree
Hide file tree
Showing 29 changed files with 792 additions and 2,108 deletions.
507 changes: 286 additions & 221 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = [
members = [
"crates/example",
"crates/example-culling",
"crates/example-wasm",
Expand All @@ -19,9 +19,10 @@ resolver = "2"
assert_approx_eq = "1.1.0"
async-channel = "1.8"
bytemuck = { version = "1.13.0", features = ["derive"] }
clap = { version = "4.5.23", features = ["derive"] }
cfg_aliases = "0.2"
crabslab = { version = "0.6.2", default-features = false }
clap = { version = "4.5.23", features = ["derive"] }
craballoc = { version = "0.1.1" }
crabslab = { version = "0.6.3", default-features = false }
ctor = "0.2.2"
dagga = "0.2.1"
env_logger = "0.10.0"
Expand All @@ -38,8 +39,9 @@ rustc-hash = "1.1"
serde = {version = "1.0", features = ["derive"]}
serde_json = "1.0.117"
send_wrapper = "0.6.0"
snafu = "0.7"
syn = { version = "2.0", features = ["full", "extra-traits", "parsing"] }
snafu = "0.8"
syn = { version = "2.0.49", features = ["full", "extra-traits", "parsing"] }
tracing = "0.1.41"
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
web-sys = "0.3"
Expand Down
1 change: 1 addition & 0 deletions crates/example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ name = "example"

[dependencies]
clap = { version = "^4.3", features = ["derive"] }
craballoc.workspace = true
#console-subscriber = "0.4.0"
env_logger = {workspace=true}
futures-lite = {workspace=true}
Expand Down
2 changes: 1 addition & 1 deletion crates/example/src/camera.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//! Camera control.
use std::str::FromStr;

use craballoc::prelude::Hybrid;
use renderling::{
bvol::Aabb,
camera::Camera,
math::{Mat4, Quat, UVec2, Vec2, Vec3},
slab::Hybrid,
};
use winit::{event::KeyEvent, keyboard::Key};

Expand Down
5 changes: 2 additions & 3 deletions crates/example/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ use std::{
sync::{Arc, Mutex},
};

use craballoc::prelude::{GpuArray, Hybrid};
use renderling::{
atlas::AtlasImage,
bvol::{Aabb, BoundingSphere},
camera::Camera,
math::{Mat4, UVec2, Vec2, Vec3, Vec4},
pbr::light::{DirectionalLight, Light},
skybox::Skybox,
slab::{GpuArray, Hybrid},
stage::{Animator, GltfDocument, Renderlet, Stage, Vertex},
Context,
};
Expand Down Expand Up @@ -216,8 +216,7 @@ impl App {

fn load_hdr_skybox(&mut self, bytes: Vec<u8>) {
let img = AtlasImage::from_hdr_bytes(&bytes).unwrap();
let (device, queue) = self.stage.get_device_and_queue_owned();
let skybox = Skybox::new(&device, &queue, img, self.camera.id());
let skybox = Skybox::new(self.stage.runtime(), img, self.camera.id());
self.skybox_image_bytes = Some(bytes);
self.stage.set_skybox(skybox);
}
Expand Down
1 change: 1 addition & 0 deletions crates/renderling-ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ categories = ["rendering", "game-development", "graphics"]
readme = "README.md"

[dependencies]
craballoc.workspace = true
crabslab = {workspace = true}
glyph_brush = "0.7.8"
image = {workspace=true}
Expand Down
2 changes: 1 addition & 1 deletion crates/renderling-ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
//! Happy hacking!
use std::sync::{Arc, RwLock};

use craballoc::prelude::Hybrid;
use crabslab::Id;
use glyph_brush::ab_glyph;
use renderling::{
atlas::AtlasTexture,
camera::Camera,
math::{Quat, UVec2, Vec2, Vec3Swizzles, Vec4},
slab::Hybrid,
stage::{NestedTransform, Renderlet, Stage},
transform::Transform,
Context,
Expand Down
2 changes: 1 addition & 1 deletion crates/renderling-ui/src/path.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Path and builder.
//!
//! Path colors are sRGB.
use craballoc::prelude::{GpuArray, Hybrid};
use crabslab::Id;
use lyon::{
path::traits::PathBuilder,
Expand All @@ -11,7 +12,6 @@ use lyon::{
use renderling::{
math::{Vec2, Vec3, Vec3Swizzles, Vec4},
pbr::Material,
slab::{GpuArray, Hybrid},
stage::{Renderlet, Vertex},
};

Expand Down
2 changes: 1 addition & 1 deletion crates/renderling-ui/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::{
};

use ab_glyph::Rect;
use craballoc::prelude::{GpuArray, Hybrid};
use glyph_brush::*;

pub use ab_glyph::FontArc;
Expand All @@ -18,7 +19,6 @@ use renderling::{
atlas::AtlasTexture,
math::{Vec2, Vec4},
pbr::Material,
slab::{GpuArray, Hybrid},
stage::{Renderlet, Vertex},
};

Expand Down
1 change: 1 addition & 0 deletions crates/renderling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ glam = { workspace = true, default-features = false, features = ["libm"] }
[target.'cfg(not(target_arch = "spirv"))'.dependencies]
async-channel = {workspace = true}
bytemuck = {workspace = true}
craballoc.workspace = true
crabslab = { workspace = true, features = ["default"] }
dagga = {workspace=true}
crunch = "0.5"
Expand Down
1 change: 0 additions & 1 deletion crates/renderling/src/atlas/atlas_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ pub fn convert_to_rgba8_bytes(
.chunks_exact(4)
.flat_map(|p| {
if let [r, g, b, a] = p {
todo!("f32_to_u8 erroneously used, use f16_to_u8 instead");
[f32_to_u8(*r), f32_to_u8(*g), f32_to_u8(*b), f32_to_u8(*a)]
} else {
unreachable!()
Expand Down
Loading

0 comments on commit 74d06bc

Please sign in to comment.