Skip to content

Add a render graph framework for the WebGPU renderer#250

Open
MatzeOGH wants to merge 1 commit into
AlpineMapsOrg:mainfrom
MatzeOGH:feature/rendergraph-core
Open

Add a render graph framework for the WebGPU renderer#250
MatzeOGH wants to merge 1 commit into
AlpineMapsOrg:mainfrom
MatzeOGH:feature/rendergraph-core

Conversation

@MatzeOGH

@MatzeOGH MatzeOGH commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Adds a render graph to webgpu/base (webgpu::rg). Each frame you declare the
resources and passes you need. The graph compiles them into an execution order, manages
resource lifetimes, and records the passes into your command encoder.

It handles pass ordering and resource lifetime. It is not a GPU-API wrapper! pass bodies
call wgpu* functions directly.

This PR is the library and its tests. Wiring it into webgpu_app (Window, renderers,
overlays, debug panel) is a separate PR #251 stacked on this one.

How it works

You declare resources and get back a TextureHandle or BufferHandle, cheap value types
that name a resource for the current frame. Handles are kind-tagged, so passing a buffer to
sampled() is a compile error rather than a runtime assert.

Passes are declared with add_pass(setup, execute). Setup runs immediately and declares
what the pass reads and writes through a PassBuilder: attachments, sampled and storage
textures and buffers, copies. Execute runs later inside execute(), once passes are
scheduled and resources are allocated. It gets a PassContext that resolves handles to
live WGPUTexture and WGPUBuffer objects and records the actual draw, dispatch, and copy
commands.

Ordering comes from the declared reads and writes. A pass whose output nothing consumes is
culled unless marked force_keep().

Resources can be transient (pooled and aliased onto shared memory when lifetimes don't
overlap), persistent, imported (the swapchain, for example), or history resources that
ping-pong across frames. Render, compute, and transfer passes are supported, along with
subresource and buffer-range targeting and hash-gated rebakes via initialize().

Files

  • webgpu/base/RenderGraph.{h,cpp}, RenderGraph_internal.h
  • unittests/webgpu_engine/test_RenderGraph.cpp
  • docs/rendergraph.md
  • CMake registration in webgpu/base and unittests/webgpu_engine

docs/rendergraph.md covers the architecture and has worked examples.

@MatzeOGH
MatzeOGH force-pushed the feature/rendergraph-core branch from 7e6683a to 5f77127 Compare July 20, 2026 07:11
@adam-ce

adam-ce commented Jul 20, 2026

Copy link
Copy Markdown
Member

Failing pipeline are unrelated unit tests. Review will be for Gerald :)

@MatzeOGH
MatzeOGH marked this pull request as ready for review July 21, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants