OpenGL: ExternalTexture does not support MSAA render targets

Open
#1,809 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
cpp

Research direction

Start with ExternalTexture.RenderWithMsaaSamples4 and the SKIP_MULTISAMPLE_TESTS entry in Apps/UnitTests/CMakeLists.txt, then inspect TextureGL::create and createMsaaFbo in bgfx/src/renderer_gl.cpp. Check the OpenGL ES 3.0 configuration in Dependencies/CMakeLists.txt. Done means the OpenGL external-texture MSAA test is enabled and passes without affecting the existing D3D11 and Metal behavior.

Written by the indexing model from the issue text.

Description

[Filed by Copilot on behalf of @bghgary]

ExternalTexture.RenderWithMsaaSamples4 is skipped on OpenGL via SKIP_MULTISAMPLE_TESTS
(Apps/UnitTests/CMakeLists.txt). There are two independent blockers.

bgfx renders MSAA render targets into a renderbuffer it owns

TextureGL::create (bgfx/src/renderer_gl.cpp):

const bool msaaSample = 0 != (m_flags&BGFX_TEXTURE_MSAA_SAMPLE);

if (!msaaSample
&& (0 != msaaQuality || writeOnly)
&&  !textureArray)
{
    GL_CHECK(glGenRenderbuffers(1, &m_rbo) );

The imported texture name is never the attachment being rendered to, so an external texture
imported as an MSAA render target never receives the resolved pixels. bgfx does implement the
ES 3.0-capable EXT_multisampled_render_to_texture, but only in createMsaaFbo for its own
back buffer — never for user framebuffers.

The multisample-texture path requires ES 3.1

The alternative is BGFX_TEXTURE_MSAA_SAMPLE, which selects a real multisample texture:

GLenum target = msaaSample ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D;

GL_TEXTURE_2D_MULTISAMPLE is ES 3.1, and Babylon Native pins bgfx to ES 3.0
(Dependencies/CMakeLists.txt, BGFX_CONFIG_RENDERER_OPENGLES=30), so it is unreachable as
configured.

D3D11 and Metal are unaffected — the test passes there.

Dominant language
C++
Stars
931
Forks
169
Avg merge
2d 17h
Merged PRs (30d)
66

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from BabylonJS/BabylonNative

All issues in BabylonJS/BabylonNative

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.