Skip to content

[#812] Typed render/compute graph with storage textures and hazard checks - #1362

Closed
godofecht wants to merge 3 commits into
mainfrom
cursor/gpu-render-compute-graph-3997
Closed

godofecht wants to merge 3 commits into
mainfrom
cursor/gpu-render-compute-graph-3997

Conversation

@godofecht

Copy link
Copy Markdown
Contributor

Intent

Linked issue or roadmap item: #812 ([gpu] typed render/compute graph with storage textures and hazard checks). Design context: docs/project/vgpu-parity.md P2.

What changed, and why is this the smallest useful change?

The vgpu-parity Resource IR is now a Flow library (lib/stdlib/gpu_graph.flow) rather than new syntax. A sibling session owns #811 (sampled textures, samplers, geometry, vertex/fragment stages); this PR does not define those types. Storage textures appear here only as graph descriptors (kind, format tag, read/write usage, lifetime) so hazards can be checked. gpu frame { ... } stays parse-only.

Overlap check

  • I searched open pull requests and recent commits for overlapping work.
  • This does not duplicate another active implementation, or the relationship is explained below.

Overlap / dependency notes:

No open PR implements #812. #811 is in flight in a sibling session; this graph binds resources by integer id so those types can plug in later. Open PRs on this repo (#1348, #1346, #1345, affine/codegen work) do not touch the GPU graph surface.

Evidence

Baseline before this change:

gpu frame parsed but did not lower. No storage-texture / ping-pong / hazard API on main. vgpu fluid and FFT-ocean cases did not exist.

Targeted proof that exercises the changed behaviour:

  • ./flow test-lang tests/lang/test_gpu_graph.flow — pass (hazards, aliases, derived deps, workgroup/barrier limits, fluid + FFT-ocean graphs, Metal and WGSL emit from one graph)
  • ./flow run examples/gpu/vgpu/fluid.flow — exit 0; prints Metal and WGSL for advect + display
  • ./flow run examples/gpu/vgpu/fft_ocean.flow — exit 0; prints Metal and WGSL for IFFT + present

Why that proof would detect the old failure or regression:

The lang test asserts same-pass R/W is GPU_GRAPH_ERR_SAME_PASS_RW unless feedback is set, conflicting slots fail, ping-pong of one physical id is refused, transients cannot be read before write, and both backend emitters contain the storage-texture / storage-buffer declarations. Those checks fail on a graph that skips validation or only has one backend.

Repository gate(s) run:

  • ./flow test-lang tests/lang/test_gpu_graph.flow
  • ./flow run examples/gpu/vgpu/fluid.flow
  • ./flow run examples/gpu/vgpu/fft_ocean.flow
  • ./flow tool gen_stdlib_docs (stdlib-api.md refreshed)
  • ./flow tool wiki_nav --problems (exit 0)

Generated/bootstrap state, if any:

No compiler/src changes; bootstrap C not regenerated.

Risk

Compatibility, performance, security, lifetime, backend, or release implications:

Additive stdlib module. No existing API or codegen path changes. Emitters produce skeleton pass modules (bindings + empty entries), not full fluid/FFT kernel math. Device dispatch is unchanged.

  • No unresolved language/API design decision is being implemented implicitly.
  • No unrelated generated artifacts or local state are included.
  • Docs changed when user-visible behaviour or syntax changed.
  • docs/project/Questions.md updated if this needs a language-design decision.

Compatibility

  • No user-visible compatibility change.
  • Compatibility change is documented in docs/project/CHANGELOG.md.

CHANGELOG records the addition under Unreleased.

Agent handoff

Agent/provider/session, when applicable: Cursor cloud agent, issue #812.

Any remaining blocker is recorded in GitHub rather than only in local/session state:

Part of #812. Remaining gaps:

  • Device dispatch and readback of the emitted Metal and WebGPU modules (P4 flow gpu test --suite vgpu harness; no storage-texture runtime on this path yet)
  • Upstream reference image/numerical compare for fluid and FFT ocean
  • Full kernel bodies for advect / Jacobi / Stockham (emitters are binding + skeleton entries)
  • Lowering the parse-only gpu frame { } hook onto this IR
  • Air-painting and radiance-cascade family graphs (named as representative cases, not in the acceptance pair)

Do not merge.

Open in Web Open in Cursor 

cursoragent and others added 3 commits October 5, 2026 11:52
…cks (#812)

Add a backend-independent GPU pass graph in stdlib/gpu_graph.flow:
storage buffers/textures, ping-pong and transient resources, dispatch
dimensions, workgroup memory/barriers, and pre-codegen hazard checks.
Pass dependencies are derived from typed resource access. The same
graph emits Metal and WGSL. Fluid and FFT-ocean vgpu families are
expressed as Flow graphs. Sampled textures, samplers and geometry
types are left to #811.

Co-authored-by: Abhishek Shivakumar <[email protected]>

Copy link
Copy Markdown
Contributor Author

Fixed the two CI blockers from run #2814 directly on this branch: registered stdlib:gpu_graph in docs/coverage.json against docs/library/gpu-graph.md, and re-recorded the LSP completion golden so the new gpu_graph symbols are expected. New CI should now validate the implementation rather than fail on stale coverage/goldens.

godofecht added a commit that referenced this pull request Oct 6, 2026
Closes #812

Builds on and supersedes #1362.

Co-authored-by: godofecht <[email protected]>
@godofecht

Copy link
Copy Markdown
Contributor Author

Duplicate of draft #1407, which continues the same lib/stdlib/gpu_graph.flow API (identical resource, access, lifetime, pass and error constants) with extra validation (GPU_GRAPH_ERR_INVALID_RESOURCE, launch-size overflow checks), kernels, WGSL export and a host adapter. #1407 is the live #812 graph PR. Docs pieces from this branch that #1407 does not carry are noted for folding there: docs/book/15-media-gpu-and-audio.md, the LANGUAGE_SPEC.md and spec-index.md rows, docs/library/stdlib-api.md entries, docs/coverage.json and tests/tools/lsp/completion.expected. Closing during PR triage; the branch is kept.

@godofecht godofecht closed this Oct 7, 2026
@godofecht
godofecht deleted the cursor/gpu-render-compute-graph-3997 branch October 12, 2026 23:02
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