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
48
examples/HDRBloom/project.cpp
Normal file
48
examples/HDRBloom/project.cpp
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import std;
|
||||
import Crafter.Build;
|
||||
namespace fs = std::filesystem;
|
||||
using namespace Crafter;
|
||||
|
||||
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
|
||||
bool isWasm = false;
|
||||
for (std::string_view a : args) {
|
||||
if (a.starts_with("--target=") && a.find("wasm") != std::string_view::npos) {
|
||||
isWasm = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> graphicsArgs(args.begin(), args.end());
|
||||
Configuration* graphics = LocalProject({
|
||||
.projectFile = "../../project.cpp",
|
||||
.args = graphicsArgs,
|
||||
});
|
||||
|
||||
Configuration cfg;
|
||||
cfg.path = "./";
|
||||
cfg.name = "HDRBloom";
|
||||
cfg.outputName = "HDRBloom";
|
||||
cfg.type = ConfigurationType::Executable;
|
||||
if (isWasm) {
|
||||
cfg.target = "wasm32-wasip1";
|
||||
cfg.defines.push_back({"CRAFTER_GRAPHICS_WINDOW_DOM", ""});
|
||||
cfg.compileFlags.push_back("-msimd128");
|
||||
}
|
||||
ApplyStandardArgs(cfg, args);
|
||||
cfg.dependencies = { graphics };
|
||||
|
||||
std::array<fs::path, 0> ifaces = {};
|
||||
std::array<fs::path, 1> impls = { "main" };
|
||||
cfg.GetInterfacesAndImplementations(ifaces, impls);
|
||||
|
||||
if (isWasm) {
|
||||
cfg.files.emplace_back(fs::path("raygen.wgsl"));
|
||||
cfg.files.emplace_back(fs::path("closesthit.wgsl"));
|
||||
cfg.files.emplace_back(fs::path("miss.wgsl"));
|
||||
cfg.files.emplace_back(fs::path("threshold.comp.wgsl"));
|
||||
cfg.files.emplace_back(fs::path("blur.comp.wgsl"));
|
||||
cfg.files.emplace_back(fs::path("composite.comp.wgsl"));
|
||||
EnableWasiBrowserRuntime(cfg);
|
||||
}
|
||||
return cfg;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue