Replace the megakernel @compute entry with five wavefront kernels sharing one module, connected by GPU ray/hit/payload buffers and a GPU-driven indirect bounce loop: GENERATE -> (PREP -> TRACE -> SHADE) x maxDepth -> RESOLVE - TRACE contains zero user code (pure _rtwTraverseTlas/Blas, opaque-only). - PREP publishes dispatchWorkgroupsIndirect args from the live ray count; the indirect-args buffer lives in its own bind group so it is never bound read-write in the same dispatch that consumes it as INDIRECT. - New emit/accumulate API: rtEmitPrimaryRay / rtEmitRay / rtAccumulate, plus an optional user Resolve stage (tonemap hook; identity by default). - Per-pass WfParams via a dynamic-offset uniform ring (curIsA/bounce vary between passes within one submit). - Payload-typed wfPayload binding emitted in the codegen region after the user's struct Payload; payload travels with each ray (2*W*H slots). - Request maxBufferSize / maxStorageBufferBindingSize / maxComputeWorkgroups PerDimension so the W*H-sized work buffers fit past the 128MB baseline. VulkanTriangle ported to the new API and renders bit-identical to the megakernel baseline at maxDepth=1. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| CustomShader | ||
| Decompression | ||
| HelloDom | ||
| HelloUI | ||
| HelloWindow | ||
| InputSystem | ||
| Sponza | ||
| VulkanTriangle | ||
| README.md | ||
Examples
Each example is a self-contained crafter-build project that depends on
the parent Crafter.Graphics via LocalProject. To build and run any
of them:
cd examples/<name>
crafter-build -r
Index
HelloWindow
Minimum viable program: open a window, run the event loop. No Vulkan
rendering. Useful as a smoke test for Device::Initialize + Window +
the platform backend.
VulkanTriangle
Ray-traced single triangle through vkCmdTraceRaysKHR. Shows the full
ray-tracing setup: DescriptorHeapVulkan with image and buffer slots,
PipelineRTVulkan from raygen / miss / closesthit SPIR-V, BLAS via
Mesh::Build, TLAS via RenderingElement3D::BuildTLAS, direct
vkWriteResourceDescriptorsEXT for swapchain views, RTPass on
window.passes. Smallest test of the bindless ray-tracing path.
HelloUI
Compute-shader UI demo using all three UI tiers:
- Tier 3 components:
DrawButton,DrawSlider,DrawProgressBar, composed viaRect::SubRectfor resize-safe layout. - Tier 2 standard shaders:
DispatchQuadsfor the background and components,DispatchCirclesfor a cursor-tracking dot,DispatchTextfor the button label (with the FontAtlas wired up toUIRenderer). - Tier 1 is available too — any custom
ComputeShaderregistered on the same heap can be dispatched alongside the standard ones.
Hit-testing and animation are user code (see the EventListener
subscriptions on window.onMouseMove / onMouseLeftClick); the
library does not track widgets or focus.
Drop a TTF in this directory as font.ttf before running (the example
loads it via Font("font.ttf")).
InputSystem
Guided tour of Crafter::Input: name actions ("Jump", "Move", "Fire",
"Look", "Zoom"), bind them to keys / mouse / gamepad (with composite
bindings for WASD-as-Vector2 and analog sticks), and consume them as
events. Demonstrates:
- The compile-time
Key(CrafterKeys::Space)helper that folds to a per-platform raw scancode — bindings stay cross-platform-readable in source while runtime data stores raw codes only. - All four action types (Button, Axis1D, Vector2) with multiple bindings per action (any-of semantics).
Map::StartRebind— press R, then press any input to remap "Jump" at runtime. Captured input is filtered out for that frame.BindingToString/BindingFromStringround-trip — print the default bindings as the on-disk format.- Gamepad hot-plug events: plug a controller in mid-run and the bindings start firing immediately.
Console-driven (no UI rendering needed); focus the window and watch stdout.
CustomShader
Tier 1 demo: a user-authored compute shader (inverse-circle.comp.glsl)
running alongside the shipped drawQuads. The custom shader inverts RGB
under each item-circle — exactly the kind of effect attempt #2's closed
shader couldn't express. Shows:
- Defining your own item POD struct in C++ + matching
std430struct in GLSL. #include "../../shaders/ui-shared.glsl"for the bindless heap declarations +UIDispatchHeaderpush-constant contract.ComputeShader::Loadfor the.spv,UIRenderer::RegisterBufferfor your SSBO,FillHeaderto populate the standard prefix, andUIRenderer::Dispatchto launch — the same pattern the standard shaders use under the hood.- The inter-dispatch SHADER_WRITE → SHADER_READ|WRITE barrier is
inserted automatically, so the custom shader sees the colored stripes
drawn by the prior
DispatchQuadsand reads/writes the swapchain image safely.