summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-03-22 16:23:25 +0100
committerskal <pascal.massimino@gmail.com>2026-03-22 16:23:25 +0100
commitb3c69d188943269769b7fee305f135faadcc60f2 (patch)
tree34260ef2434652557e27443d665d2b180a2677cb
parent159ca2ca19345515cdfebed9fd88646730492cd2 (diff)
fix(cnn_v3/tools): remove unused sampler binding from FULL_PACK_SHADER
WebGPU auto-reflects the BGL from the shader; a declared-but-unused sampler binding is omitted from the layout, causing CreateBindGroup to reject it. Removed binding 6 (sampler) entirely — all reads use textureLoad(). Renumbered f0/f1 from 7/8 to 6/7 to match.
-rw-r--r--cnn_v3/docs/HOWTO.md7
-rw-r--r--cnn_v3/tools/shaders.js9
-rw-r--r--cnn_v3/tools/tester.js5
3 files changed, 10 insertions, 11 deletions
diff --git a/cnn_v3/docs/HOWTO.md b/cnn_v3/docs/HOWTO.md
index c6f306b..08979e7 100644
--- a/cnn_v3/docs/HOWTO.md
+++ b/cnn_v3/docs/HOWTO.md
@@ -444,9 +444,10 @@ WebGPU compute shader (`@workgroup_size(8,8)`) with 9 bindings:
| Binding | Resource | Format |
|---------|----------|--------|
| 0–5 | albedo, normal, depth, matid, shadow, transp | `texture_2d<f32>` (rgba8unorm, R channel for single-channel maps) |
-| 6 | linear sampler | `sampler` |
-| 7 | feat_tex0 output | `texture_storage_2d<rgba32uint,write>` |
-| 8 | feat_tex1 output | `texture_storage_2d<rgba32uint,write>` |
+| 6 | feat_tex0 output | `texture_storage_2d<rgba32uint,write>` |
+| 7 | feat_tex1 output | `texture_storage_2d<rgba32uint,write>` |
+
+No sampler — all reads use `textureLoad()` (integer texel coordinates).
Packs channels identically to `gbuf_pack.wgsl`:
- `feat_tex0`: `pack2x16float(alb.rg)`, `pack2x16float(alb.b, nrm.x)`, `pack2x16float(nrm.y, depth)`, `pack2x16float(dzdx, dzdy)`
diff --git a/cnn_v3/tools/shaders.js b/cnn_v3/tools/shaders.js
index d5b1fb4..a1b2929 100644
--- a/cnn_v3/tools/shaders.js
+++ b/cnn_v3/tools/shaders.js
@@ -252,9 +252,9 @@ const VIZ_U32=`
}`;
// Full G-buffer pack: assembles feat_tex0/feat_tex1 from individual G-buffer images.
-// Bindings: albedo(0) normal(1) depth(2) matid(3) shadow(4) transp(5) sampler(6) f0(7) f1(8)
+// Bindings: albedo(0) normal(1) depth(2) matid(3) shadow(4) transp(5) f0(6) f1(7)
// All source textures are rgba8unorm (browser-loaded images, R channel for depth/matid/shadow/transp).
-// Matches gbuf_pack.wgsl packing exactly so the CNN sees the same layout.
+// Uses textureLoad() only (no sampler needed). Matches gbuf_pack.wgsl packing exactly.
const FULL_PACK_SHADER=`
@group(0) @binding(0) var albedo: texture_2d<f32>;
@group(0) @binding(1) var normal: texture_2d<f32>;
@@ -262,9 +262,8 @@ const FULL_PACK_SHADER=`
@group(0) @binding(3) var matid: texture_2d<f32>;
@group(0) @binding(4) var shadow: texture_2d<f32>;
@group(0) @binding(5) var transp: texture_2d<f32>;
-@group(0) @binding(6) var smp: sampler;
-@group(0) @binding(7) var f0: texture_storage_2d<rgba32uint,write>;
-@group(0) @binding(8) var f1: texture_storage_2d<rgba32uint,write>;
+@group(0) @binding(6) var f0: texture_storage_2d<rgba32uint,write>;
+@group(0) @binding(7) var f1: texture_storage_2d<rgba32uint,write>;
fn ld(c:vec2i,d:vec2i)->f32{return textureLoad(depth,clamp(c,vec2i(0),d-vec2i(1)),0).r;}
fn b2(tl:vec2i,d:vec2i)->vec3f{
var s=vec3f(0.);
diff --git a/cnn_v3/tools/tester.js b/cnn_v3/tools/tester.js
index c1faec9..d58b87e 100644
--- a/cnn_v3/tools/tester.js
+++ b/cnn_v3/tools/tester.js
@@ -631,9 +631,8 @@ class CNNv3Tester {
{binding:3, resource: midTex.createView()},
{binding:4, resource: shdTex.createView()},
{binding:5, resource: trpTex.createView()},
- {binding:6, resource: this.linearSampler},
- {binding:7, resource: f0.createView()},
- {binding:8, resource: f1.createView()},
+ {binding:6, resource: f0.createView()},
+ {binding:7, resource: f1.createView()},
]});
const enc = this.device.createCommandEncoder();