git.lucas.co / cce-ui
GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git

commitb6c58ed50f8e8ffd9b4807f60b2780fb7120a96d
parent8580ee4a1a
authorLucas Galante <lsgalante12@gmail.com>
date2026-10-08 08:26
fix(draw): the Vulkan-only lit and image helpers are not dead code in the browser build

The wasm job's second run: with -D warnings, next_image_id and draw::lit's
uniform helpers failed the browser build as never used — the Vulkan
renderer is their only caller, and WebGPU has no lit pass yet. Allowed
dead there, by a cfg_attr on exactly those items.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

 src/draw/images.rs | 1 +
 src/draw/lit.rs    | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/src/draw/images.rs b/src/draw/images.rs
index 3ac6683..68b8084 100644
--- a/src/draw/images.rs
+++ b/src/draw/images.rs
@@ -75,6 +75,7 @@ static NEXT_ID: AtomicU32 = AtomicU32::new(1);
 /// A fresh image id from the process-wide counter, for a renderer that
 /// uploads into its own table directly (`ImageStage::upload_now`) — never
 /// one a queued upload also holds.
+#[cfg_attr(target_arch = "wasm32", allow(dead_code))] // only the Vulkan renderer uploads directly
 pub(crate) fn next_image_id() -> u32 {
     NEXT_ID.fetch_add(1, Ordering::Relaxed)
 }
diff --git a/src/draw/lit.rs b/src/draw/lit.rs
index 853d376..ff6117a 100644
--- a/src/draw/lit.rs
+++ b/src/draw/lit.rs
@@ -146,8 +146,10 @@ pub(crate) struct LitUniforms {
     ground: [f32; 4],
 }
 
+#[cfg_attr(target_arch = "wasm32", allow(dead_code))] // the Vulkan renderer's; WebGPU has no lit pass yet
 pub(crate) const LIT_UNIFORM_SIZE: usize = std::mem::size_of::<LitUniforms>();
 
+#[cfg_attr(target_arch = "wasm32", allow(dead_code))] // the Vulkan renderer's; WebGPU has no lit pass yet
 fn unit4(v: [f32; 3]) -> [f32; 4] {
     let l = (v[0] * v[0] + v[1] * v[1] + v[2] * v[2]).sqrt();
     if l > 0.0 {
@@ -157,6 +159,7 @@ fn unit4(v: [f32; 3]) -> [f32; 4] {
     }
 }
 
+#[cfg_attr(target_arch = "wasm32", allow(dead_code))] // the Vulkan renderer's; WebGPU has no lit pass yet
 fn pad(v: [f32; 3]) -> [f32; 4] {
     [v[0], v[1], v[2], 0.0]
 }
@@ -164,6 +167,7 @@ fn pad(v: [f32; 3]) -> [f32; 4] {
 /// The staged lit draws' uniform blocks, in order. A texture not resident
 /// in the renderer is bound as its white fallback, so "textured" with no
 /// texture yet draws the plain base colour.
+#[cfg_attr(target_arch = "wasm32", allow(dead_code))] // the Vulkan renderer's; WebGPU has no lit pass yet
 pub(crate) fn lit_uniforms(
     draws: &[LitDraw],
     light: &LitLight,