Skip to content

feature: light tiling #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
325 changes: 300 additions & 25 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ exclude = ["./shaders"]
resolver = "2"

[workspace.dependencies]
acorn_prng = "3.0"
assert_approx_eq = "1.1.0"
async-channel = "1.8"
bytemuck = { version = "1.19.0", features = ["derive"] }
cfg_aliases = "0.2"
clap = { version = "4.5.23", features = ["derive"] }
craballoc = { version = "0.1.11" }
crabslab = { version = "0.6.3", default-features = false }
craballoc = { version = "0.2.0", path = "../crabslab/crates/craballoc" }
crabslab = { version = "0.6.3", default-features = false, path = "../crabslab/crates/crabslab" }
plotters = "0.3.7"
ctor = "0.2.2"
dagga = "0.2.1"
env_logger = "0.10.0"
Expand All @@ -41,7 +41,7 @@ serde = {version = "1.0", features = ["derive"]}
serde_json = "1.0.117"
send_wrapper = "0.6.0"
snafu = "0.8"
spirv-std = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "6e2c84d" }
spirv-std = { git = "https://github.com/LegNeato/rust-gpu.git", rev = "16b61ce" }
syn = { version = "2.0.49", features = ["full", "extra-traits", "parsing"] }
tracing = "0.1.41"
wasm-bindgen = "0.2"
Expand All @@ -62,4 +62,4 @@ opt-level = 3
opt-level = 3

[patch.crates-io]
spirv-std = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "6e2c84d" }
spirv-std = { git = "https://github.com/LegNeato/rust-gpu.git", rev = "16b61ce" }
42 changes: 31 additions & 11 deletions crates/renderling-build/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#![allow(unexpected_cfgs)]
use naga::{
back::wgsl::WriterFlags,
valid::{ValidationFlags, Validator},
};
use quote::quote;

#[derive(Debug, serde::Deserialize)]
Expand Down Expand Up @@ -91,19 +95,35 @@ fn wgsl(spv_filepath: impl AsRef<std::path::Path>, destination: impl AsRef<std::
});
let opts = naga::front::spv::Options::default();
let module = naga::front::spv::parse_u8_slice(&bytes, &opts).unwrap();
let mut validator =
naga::valid::Validator::new(Default::default(), naga::valid::Capabilities::empty());
let info = validator.validate(&module).unwrap_or_else(|e| {
panic!(
"Could not validate '{}': {e}",
spv_filepath.as_ref().display(),
)
});
let wgsl =
naga::back::wgsl::write_string(&module, &info, naga::back::wgsl::WriterFlags::empty())
.unwrap();
let mut wgsl = String::new();
let mut panic_msg: Option<String> = None;
for (vflags, name) in [
(ValidationFlags::empty(), "empty"),
(ValidationFlags::all(), "all"),
] {
let mut validator = Validator::new(vflags, Default::default());
match validator.validate(&module) {
Err(e) => {
panic_msg = Some(format!(
"Could not validate '{}' with WGSL validation flags {name}: {}",
spv_filepath.as_ref().display(),
e.emit_to_string(&wgsl)
));
}
Ok(i) => {
wgsl = naga::back::wgsl::write_string(&module, &i, WriterFlags::empty()).unwrap();
}
};
}

let destination = destination.as_ref().with_extension("wgsl");
std::fs::write(destination, wgsl).unwrap();
if let Some(msg) = panic_msg {
panic!(
"{msg}\nWGSL was written to {}",
spv_filepath.as_ref().display()
);
}
}

pub struct RenderlingPaths {
Expand Down
4 changes: 2 additions & 2 deletions crates/renderling-ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
//! Happy hacking!
use std::sync::{Arc, RwLock};

use craballoc::prelude::Hybrid;
use craballoc::prelude::{Hybrid, SourceId};
use crabslab::Id;
use glyph_brush::ab_glyph;
use renderling::{
Expand Down Expand Up @@ -150,7 +150,7 @@ pub struct Ui {
//
// The `usize` key here is the update source notifier index, which is needed
// to re-order after any transform performs an update.
transforms: Arc<RwLock<FxHashMap<usize, UiTransform>>>,
transforms: Arc<RwLock<FxHashMap<SourceId, UiTransform>>>,
default_stroke_options: Arc<RwLock<StrokeOptions>>,
default_fill_options: Arc<RwLock<FillOptions>>,
}
Expand Down
6 changes: 3 additions & 3 deletions crates/renderling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ wgpu = { workspace = true, features = ["spirv"] }
winit = { workspace = true, optional = true }

[dev-dependencies]
acorn_prng.workspace = true
assert_approx_eq = {workspace = true}
assert_approx_eq.workspace = true
ctor = "0.2.2"
env_logger = {workspace = true}
env_logger.workspace = true
example = { path = "../example" }
fastrand = "2.1.1"
icosahedron = "0.1"
img-diff = { path = "../img-diff" }
naga.workspace = true
plotters.workspace = true
ttf-parser = "0.20.0"
wgpu-core.workspace = true
winit.workspace = true
Expand Down
Binary file modified crates/renderling/shaders/cull-compute_culling.spv
Binary file not shown.
Binary file modified crates/renderling/shaders/debug-debug_overlay_fragment.spv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified crates/renderling/shaders/light-shadow_mapping_vertex.spv
Binary file not shown.
15 changes: 15 additions & 0 deletions crates/renderling/shaders/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@
"entry_point": "ibl::diffuse_irradiance::di_convolution_fragment",
"wgsl_entry_point": "ibldiffuse_irradiancedi_convolution_fragment"
},
{
"source_path": "shaders/light-light_tiling_compute_tiles.spv",
"entry_point": "light::light_tiling_compute_tiles",
"wgsl_entry_point": "lightlight_tiling_compute_tiles"
},
{
"source_path": "shaders/light-light_tiling_compute_tiles_multisampled.spv",
"entry_point": "light::light_tiling_compute_tiles_multisampled",
"wgsl_entry_point": "lightlight_tiling_compute_tiles_multisampled"
},
{
"source_path": "shaders/light-light_tiling_depth_pre_pass.spv",
"entry_point": "light::light_tiling_depth_pre_pass",
"wgsl_entry_point": "lightlight_tiling_depth_pre_pass"
},
{
"source_path": "shaders/light-shadow_mapping_fragment.spv",
"entry_point": "light::shadow_mapping_fragment",
Expand Down
Binary file modified crates/renderling/shaders/skybox-skybox_cubemap_vertex.spv
Binary file not shown.
Binary file added crates/renderling/shaders/stage-go_thing.spv
Binary file not shown.
Binary file modified crates/renderling/shaders/stage-renderlet_fragment.spv
Binary file not shown.
Binary file modified crates/renderling/shaders/stage-renderlet_vertex.spv
Binary file not shown.
3 changes: 1 addition & 2 deletions crates/renderling/src/bloom/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,7 @@ impl Bloom {
let runtime = runtime.as_ref();
let resolution = UVec2::new(hdr_texture.width(), hdr_texture.height());

let slab =
SlabAllocator::new_with_label(runtime, wgpu::BufferUsages::empty(), Some("bloom-slab"));
let slab = SlabAllocator::new(runtime, "bloom-slab", wgpu::BufferUsages::empty());
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
Loading
Loading