Skip to content

Improve MRT support #5356

Description

@mvaligursky

Issue for initial implementation of MRT: #4230

Possible improvements:

  • Per-attachment clear colors and clear flags on the render pass. RenderPass#setClearColor accepts an optional attachment index, and WebGL clears the color attachments individually using clearBufferfv, applying their own clear colors and clear flags. Previously a single gl.clear applied attachment 0's clear color to all attachments, and ignored the per-attachment clear flags. Done in Add per-attachment clear colors for multiple render targets #9142.
  • Per-attachment blend state and color write mask. BlendState#setAttachment gives an individual color attachment its own blend state and write mask - supported natively on WebGPU, and using the OES_draw_buffers_indexed extension on WebGL2, with GraphicsDevice#supportsIndependentBlending reporting the support. Done in Add independent blending for multiple render targets #9140.
  • Expand the API on the camera to specify the clear color per color attachment, and use those with MRT.
  • Expand the layer clear color flag to be per color attachment. Note that the mid-render-pass clear this uses (GraphicsDevice#clear) is implemented differently per platform, and the platforms currently disagree on MRT: WebGL uses gl.clear which applies a single color to all attachments (and does not support integer formats), while WebGPU uses a fullscreen quad (WebgpuClearRenderer) with a float color output, which only writes attachment 0. Converging these means per-attachment clearBuffer* calls on WebGL, and an MRT-aware clear shader on WebGPU. Also blocked on the camera API above, as the layer flags are booleans and the clear color currently comes from the camera, which only has a single color.
  • Clearing of integer format color attachments at the render pass start (clearBufferiv / clearBufferuiv on WebGL - WebGPU supports this natively via clearValue), which would also allow the Picker to use a uint32 format instead of encoding the id into RGBA8. Note the picker migration additionally needs uint fragment outputs for the pick shader variants. Mid-render-pass integer clears (layers) are excluded - on WebGPU the clear shader would need integer output variants, and nothing currently needs it. Done in Add clear support for integer format color attachments #9143.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions