Skip to content
Merged
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
17 changes: 17 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,30 @@ jobs:
${{ needs.install-cargo-gpu.outputs.cachepath-Windows }}
key: rust-gpu-cache-0-${{ runner.os }}
- uses: moonrepo/setup-rust@v1
- run: rustup install nightly
- run: rustup component add --toolchain nightly rustfmt
- run: cargo gpu show commitsh
- run: rm -rf crates/renderling/src/linkage/* crates/renderling/shaders
- run: cargo shaders
- run: cargo linkage
- run: cargo build -p renderling
- run: git diff --exit-code --no-ext-diff

# Ensures code is properly formatted with nightly rustfmt
renderling-fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v4
with:
path: ~/.cargo
# THIS KEY MUST MATCH ABOVE
key: cargo-cache-${{ env.CARGO_GPU_COMMITSH }}-${{ runner.os }}
- uses: moonrepo/setup-rust@v1
- run: rustup install nightly
- run: rustup component add --toolchain nightly rustfmt
- run: cargo +nightly fmt -- --check

# BAU clippy lints
renderling-clippy:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
- Tests: inline `#[cfg(test)] mod test { ... }` within modules
- CPU-only code: wrap with `#[cfg(cpu)]`

Always format with `cargo +nightly fmt`.

## Disallowed Methods (clippy.toml)
Avoid: `Vec{2,3,4}::normalize_or_zero`, `Mat4::to_scale_rotation_translation`, `f32::signum`
8 changes: 4 additions & 4 deletions crates/example/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,10 @@ impl App {

// self.lighting
// .shadow_map
// .update(&self.lighting.lighting, doc.primitives.values().flatten());
// self.lighting.light = light.light.clone();
// self.lighting.light_details = dir.clone();
// }
// .update(&self.lighting.lighting,
// doc.primitives.values().flatten()); self.lighting.light =
// light.light.clone(); self.lighting.light_details =
// dir.clone(); }
// }

self.model = Model::Gltf(Box::new(doc));
Expand Down
3 changes: 1 addition & 2 deletions crates/examples/src/gltf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ async fn manual_gltf() {
use renderling::{
camera::Camera,
context::Context,
glam::Vec4,
glam::{Mat4, Vec3},
glam::{Mat4, Vec3, Vec4},
stage::Stage,
};

Expand Down
6 changes: 2 additions & 4 deletions crates/examples/src/lighting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ async fn manual_lighting() {
use renderling::{
camera::Camera,
context::Context,
glam::Vec4,
glam::{Mat4, Vec3},
glam::{Mat4, Vec3, Vec4},
gltf::GltfDocument,
stage::Stage,
types::GpuOnlyArray,
Expand Down Expand Up @@ -155,8 +154,7 @@ async fn manual_lighting_ibl() {
use renderling::{
camera::Camera,
context::Context,
glam::Vec4,
glam::{Mat4, Vec3},
glam::{Mat4, Vec3, Vec4},
gltf::GltfDocument,
stage::Stage,
types::GpuOnlyArray,
Expand Down
3 changes: 1 addition & 2 deletions crates/examples/src/skybox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ pub async fn manual_skybox() {
use renderling::{
camera::Camera,
context::Context,
glam::Vec4,
glam::{Mat4, Vec3},
glam::{Mat4, Vec3, Vec4},
stage::Stage,
};

Expand Down
4 changes: 2 additions & 2 deletions crates/loading-bytes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ pub async fn post_bin_wasm<T: serde::de::DeserializeOwned>(
Ok(t)
}

/// Load the file at the given url fragment or path and return it as a vector of bytes, if
/// possible.
/// Load the file at the given url fragment or path and return it as a vector of
/// bytes, if possible.
pub async fn load(path: &str) -> Result<Vec<u8>, LoadingBytesError> {
#[cfg(target_arch = "wasm32")]
{
Expand Down
22 changes: 14 additions & 8 deletions crates/renderling-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ pub fn wasm_test_output_dir() -> std::path::PathBuf {

#[derive(Debug)]
pub struct RenderlingPaths {
/// `cargo_workspace` is not available when building outside of the project directory.
/// `cargo_workspace` is not available when building outside of the project
/// directory.
pub cargo_workspace: Option<std::path::PathBuf>,
pub renderling_crate: std::path::PathBuf,
pub shader_dir: std::path::PathBuf,
Expand All @@ -184,10 +185,12 @@ impl RenderlingPaths {
///
/// If the `CARGO_WORKSPACE_DIR` and subsequently the `cargo_workspace` is
/// _not_ available, this most likely means we're building renderling
/// outside of its own source tree, which means we **don't want to compile shaders**.
/// outside of its own source tree, which means we **don't want to compile
/// shaders**.
///
/// But we may still need to transpile the packaged SPIR-V into WGSL for WASM, and
/// so `cargo_workspace` is `Option` and the entire function also returns `Option`.
/// But we may still need to transpile the packaged SPIR-V into WGSL for
/// WASM, and so `cargo_workspace` is `Option` and the entire function
/// also returns `Option`.
pub fn new() -> Option<Self> {
let cargo_workspace = std::env::var("CARGO_WORKSPACE_DIR")
.map(std::path::PathBuf::from)
Expand Down Expand Up @@ -276,11 +279,14 @@ impl RenderlingPaths {

let contents = linkage.to_string();
std::fs::write(&filepath, contents).unwrap();
std::process::Command::new("rustfmt")
.args([&format!("{}", filepath.display())])
.output()
.expect("could not format generated code");
}
// Just format the whole project. I know this is less than ideal,
// but people should be running with a formatter in their editor, and all of
// this is temporary given the wgsl-rs re-stacking happening this year (2026)
std::process::Command::new("cargo")
.args(["+nightly", "fmt"])
.output()
.expect("could not format generated code");
log::info!("...done!")
}
}
3 changes: 2 additions & 1 deletion crates/renderling/src/atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
//! All images are packed into an atlas at staging time.
//! Texture descriptors describe where in the atlas an image is,
//! and how it should sample pixels. These descriptors are packed into a buffer
//! on the GPU. This keeps the number of texture binds to a minimum (one, in most cases).
//! on the GPU. This keeps the number of texture binds to a minimum (one, in
//! most cases).
//!
//! ## NOTE:
//! `Atlas` is a temporary work around until we can use bindless techniques
Expand Down
12 changes: 7 additions & 5 deletions crates/renderling/src/atlas/atlas_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,17 @@ impl From<AtlasImageFormat> for wgpu::TextureFormat {
match value {
AtlasImageFormat::R8 => wgpu::TextureFormat::R8Unorm,
AtlasImageFormat::R8G8 => wgpu::TextureFormat::Rg8Unorm,
AtlasImageFormat::R8G8B8 => wgpu::TextureFormat::Rgba8Unorm, // No direct 3-channel format, using 4-channel
AtlasImageFormat::R8G8B8 => wgpu::TextureFormat::Rgba8Unorm, /* No direct 3-channel */
// format, using
// 4-channel
AtlasImageFormat::R8G8B8A8 => wgpu::TextureFormat::Rgba8Unorm,
AtlasImageFormat::R16 => wgpu::TextureFormat::R16Unorm,
AtlasImageFormat::R16G16 => wgpu::TextureFormat::Rg16Unorm,
AtlasImageFormat::R16G16B16 => wgpu::TextureFormat::Rgba16Unorm, // No direct 3-channel format, using 4-channel
AtlasImageFormat::R16G16B16 => wgpu::TextureFormat::Rgba16Unorm, /* No direct 3-channel format, using 4-channel */
AtlasImageFormat::R16G16B16A16 => wgpu::TextureFormat::Rgba16Unorm,
AtlasImageFormat::R16G16B16A16FLOAT => wgpu::TextureFormat::Rgba16Float,
AtlasImageFormat::R32FLOAT => wgpu::TextureFormat::R32Float,
AtlasImageFormat::R32G32B32FLOAT => wgpu::TextureFormat::Rgba32Float, // No direct 3-channel format, using 4-channel
AtlasImageFormat::R32G32B32FLOAT => wgpu::TextureFormat::Rgba32Float, /* No direct 3-channel format, using 4-channel */
AtlasImageFormat::R32G32B32A32FLOAT => wgpu::TextureFormat::Rgba32Float,
AtlasImageFormat::D32FLOAT => wgpu::TextureFormat::Depth32Float,
}
Expand Down Expand Up @@ -272,8 +274,8 @@ fn apply_linear_xfer(bytes: &mut [u8], format: AtlasImageFormat) {
}
}

/// Interpret/convert the `AtlasImage` pixel data into `wgpu::TextureFormat` pixels,
/// if possible.
/// Interpret/convert the `AtlasImage` pixel data into `wgpu::TextureFormat`
/// pixels, if possible.
///
/// This applies the linear transfer function if `apply_linear_transfer` is
/// `true`.
Expand Down
Loading
Loading