test(webgpu): HDRBloom example exercising the HDR post-process primitives (#27)
RT→rgba16float→threshold→blur→composite, end-to-end proof of the three primitives. threshold/blur run from onBeforeUpdate (one submit each) so the storage-write→sampled-read dependency gets WebGPU's per-submit barrier (there is none between dispatches within a compute pass); the composite is a UI custom shader so it owns the canvas ping-pong. Documents the Vulkan symmetry (gap 4): the native present path records passes generically and barriers between them, so the same chain is wireable today. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
097cc37347
commit
bbe1b21c22
10 changed files with 518 additions and 0 deletions
35
examples/HDRBloom/raygen.wgsl
Normal file
35
examples/HDRBloom/raygen.wgsl
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
// HDRBloom raygen (runs in GENERATE). Host-driven pinhole camera at
|
||||
// @group(3) (groups 0..2 are reserved by the wavefront pipeline:
|
||||
// 0 = WfParams, 1 = data heaps, 2 = indirect args). Primary rays only —
|
||||
// maxDepth = 1.
|
||||
struct Camera {
|
||||
origin: vec3<f32>,
|
||||
pad0: f32,
|
||||
right: vec3<f32>,
|
||||
tanHalf: f32,
|
||||
up: vec3<f32>,
|
||||
aspect: f32,
|
||||
forward: vec3<f32>,
|
||||
pad1: f32,
|
||||
};
|
||||
@group(3) @binding(0) var<storage, read> camera : Camera;
|
||||
|
||||
fn raygen_main(gid: vec3<u32>) {
|
||||
if (gid.x >= wfParams.surfaceW || gid.y >= wfParams.surfaceH) { return; }
|
||||
|
||||
let pixelf = vec2<f32>(f32(gid.x), f32(gid.y));
|
||||
let res = vec2<f32>(f32(wfParams.surfaceW), f32(wfParams.surfaceH));
|
||||
let uv = (pixelf + vec2<f32>(0.5)) / res;
|
||||
let ndc = uv * 2.0 - vec2<f32>(1.0);
|
||||
|
||||
let direction = normalize(
|
||||
camera.right * (ndc.x * camera.aspect * camera.tanHalf) +
|
||||
camera.up * (-ndc.y * camera.tanHalf) +
|
||||
camera.forward);
|
||||
|
||||
var p: Payload;
|
||||
p.color = vec3<f32>(0.0);
|
||||
|
||||
rtEmitPrimaryRay(camera.origin, 0.01, direction, 100000.0,
|
||||
0u, 0xFFu, 0u, 0u, p);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue