Skip to content

Add Transform Feedback manual page - #1115

Open
mvaligursky wants to merge 2 commits into
mainfrom
mv-transform-feedback-docs
Open

Add Transform Feedback manual page#1115
mvaligursky wants to merge 2 commits into
mainfrom
mv-transform-feedback-docs

Conversation

@mvaligursky

@mvaligursky mvaligursky commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Warning

Do not merge until engine 2.22 is released — the separate-buffer mode documented here ships with that release (playcanvas/engine#9109, playcanvas/engine#9131), as do the diagnostics this page now relies on (playcanvas/engine#9135). The embedded graphics/transform-feedback-separate example does not exist on the live examples site yet, so its thumbnail and iframe currently 404.

Transform feedback was documented nowhere on the site — no mentions in docs/ or i18n/. So this covers both the long-standing interleaved mode and the separate-buffer mode added in 2.22, as a single page.

New page

advanced-rendering/transform-feedback.md, following the structure of the neighbouring Multi-Draw and Hardware Instancing pages:

  • Platform Support — WebGL2 only, gated on GraphicsDevice.isWebGL2, with a pointer to compute shaders as the WebGPU equivalent since there is no direct one
  • Use Cases — GPU particles, flocking and crowds, cloth, trails
  • Live Examples — both engine examples embedded
  • A Single Interleaved Buffer — shader, createShader, process(), and why the automatic buffer swap means a mesh rendering from the input buffer needs no updating
  • One Buffer Per VaryingTRANSFORM_FEEDBACK_SEPARATE, the three buffer roles, and feeding instanced rendering
  • Input Attribute Semantics — declaration-order assignment and the location collision to avoid
  • Limitations
  • API Reference and Related

Notes worth reviewing

A few points in here are not apparent from the API reference, and were learned the hard way while building the example:

  • A buffer cannot be both a per-vertex simulation stream and a per-instance render stream. instancing is a property of VertexFormat, so the divisor applies to every use of the buffer. This is the reason the write-only buffer role exists, so the page explains it rather than just listing the roles.
  • Mixing standard and custom attribute names collides. vertex_position maps to location 0, and the first custom name is assigned ATTR0 — also location 0. Called out in a warning admonition.
  • Separate mode limits each varying to 4 components on baseline WebGL2, which drives how state gets packed.
    Two further rough edges — a buffer only ever written by the GPU still needing initial data, and BUFFER_GPUDYNAMIC being silently worked around — were filed as TransformFeedback: buffer allocation and usage requirements are implicit engine#9134 and are now reported by the engine itself in Report transform feedback buffer setup problems where they happen engine#9135. Since those asserts name the buffer and say how to fix it, the page does not document the workarounds. The underlying requirements still stand, so if TransformFeedback: buffer allocation and usage requirements are implicit engine#9134 is closed without changing VertexBuffer allocation, it is worth revisiting whether they belong here after all.

Also

  • Registered in sidebars.js (the Advanced Rendering list is manual, so the page is invisible without it), placed after Indirect Drawing
  • Japanese mirror added with translated frontmatter and English body, matching the convention used by html-in-canvas.md

Testing

  • npm run lint — 0 errors across 1306 files
  • Rendered locally: breadcrumb resolves as Graphics → Advanced Rendering → Transform Feedback, sidebar entry appears, all 9 sections, the table and the warning admonition render, no console errors
  • Both internal links verified against the file tree; compute-shaders lives under shaders/, which caught an initially wrong path
  • Both EngineExample placeholders render with the correct titles. The graphics/transform-feedback thumbnail resolves (HTTP 200); graphics/transform-feedback-separate is HTTP 404 until the examples site redeploys — hence the warning above

Transform feedback was not documented anywhere on the site, so this covers both the default
interleaved capture and the separate-buffer mode added in engine 2.22.

Documents the WebGL2-only constraint and the compute shader alternative on WebGPU, the single
interleaved buffer workflow including why the automatic buffer swap means a mesh rendering
from the input buffer needs no updating, and the separate-buffer mode with its three buffer
roles.

Also captures several things that are not apparent from the API reference: why a buffer
cannot be both a per-vertex simulation stream and a per-instance render stream, the
declaration-order attribute semantics and the location collision from mixing standard and
custom attribute names, the four-component limit per varying in separate mode, and the need
to supply initial data for a buffer only ever written by the GPU.

Adds the page to the Advanced Rendering sidebar and the Japanese mirror with translated
frontmatter.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The engine now asserts when a transform feedback buffer has no GPU storage, and warns when a
buffer was not created with BUFFER_GPUDYNAMIC (playcanvas/engine#9135). Both messages name the
buffer and say how to fix it, so the manual no longer needs to carry the workarounds.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant