BabylonJS / BabylonJS/BabylonNative

OpenGL: ExternalTexture does not support MSAA render targets

Open
#1,809 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
919
Forks
162
Avg merge
1d 15h
Merged PRs (30d)
19

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`):

```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:

```cpp
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.

Contributor guide

Open the contributing guide

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.