custom shader webgpu

This commit is contained in:
Jorijn van der Graaf 2026-05-18 05:39:17 +02:00
commit 64116cd980
12 changed files with 445 additions and 36 deletions

View file

@ -168,14 +168,17 @@ export namespace Crafter {
void DispatchText(GraphicsCommandBuffer cmd, std::uint32_t bufferSlot, std::uint32_t itemCount,
std::array<float,4> clipRectPx = {0.0f, 0.0f, 1e9f, 1e9f});
#ifndef CRAFTER_GRAPHICS_WINDOW_DOM
// Generic dispatch — user-authored shaders. Vulkan-only in v1; on DOM
// the WebGPU side has no bindless and would need per-shader bind-group
// declaration. See plan section 3b for the design path.
void Dispatch(GraphicsCommandBuffer cmd, const ComputeShader& shader,
// Generic dispatch for user-authored shaders. On Vulkan, `shader` is
// a SPIR-V compute pipeline (bindless via VK_EXT_descriptor_heap, so
// any resource indices baked into push data resolve through the
// global heap). On DOM, `shader` carries a UICustomBinding list
// declared at Load time; the renderer reads the listed slot uints
// out of `push`, resolves them against heap.bufferTable /
// imageTable / samplerTable, and builds the bind groups before
// dispatching.
void Dispatch(GraphicsCommandBuffer cmd, const GraphicsComputeShader& shader,
const void* push, std::uint32_t pushBytes,
std::uint32_t gx, std::uint32_t gy = 1, std::uint32_t gz = 1);
#endif
// Allocates a heap slot for the buffer and registers the GPU handle.
// Returns a move-only BufferSlot RAII handle.