Transform Feedback

Transform Feedback is the process of capturing primitives generated by the vertex processing step(s), recording data from those primitives into a vertex buffer. This allows one to preserve the post-transform rendering state of an object and resubmit this data multiple times.

Use Cases

This feature enables the user to utilize the vertex processing unit of the GPU to perform calculations and reuse the results. This is especially useful for debugging vertex transformations. Applications can also use it for use cases like speeding up particle systems.

drawing-4-1677055208.png

Usage in Candera:

  1. Before uploading your vertex shader that processes your data, use Shader::SetTransformVaryings to tell the engine which shader varying(s) need to be recorded into the feedback buffer.
  2. Upload the shader, activate the shader’s appearance, and source vertex buffer as usual. If you want to disable the output of the pixel pipeline stage, use RenderMode::SetRasterizerDiscardEnabled.
  3. Bind the source vertex buffer using Shader::BindAttributes.
  4. Call Renderer::BindTransformFeedbackBuffer, and Renderer::BeginTransformFeedbackBuffer using the destination vertex buffer that the processed primitives will be recorded into.
  5. Render the source vertex buffer as usual.
  6. Call Renderer::EndTransformFeedbackBuffer
  7. Call Renderer::MapTransformFeedbackBuffer to get a pointer to the processed, and recorded data.
  8. Before using that pointer for your own purposes, call Renderer::UnmapTransformFeedbackBuffer.
  9. The lifetime of that pointer’s data is tied to the lifetime of your destination vertex buffer.

Revision #1
Created 2023-02-22 08:39:26 UTC by Tsuyoshi.Kato
Updated 2023-05-01 01:35:53 UTC by Tsuyoshi.Kato