Native MRT framebuffer creation ignores generateMipMaps: false

Open
#2,027 1 comment 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
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp, javascript
Domain
backend

Research direction

Start with BabylonNative's NativeEngine::CreateMultiFrameBuffer and Babylon.js's ThinNativeEngine._createNativeMultiFrameBuffer; trace how MRT generation intent reaches framebuffer creation, including layered targets and recreation after sample-count changes. Check existing bridge argument ordering and defaults before changing them. Add regression coverage for authored mip preservation, requested automatic generation, legacy calls, and the affected framebuffer paths.

Written by the indexing model from the issue text.

Description

Context

Separate follow-up to the non-blocking review comment on PR #2025. Keep that PR unchanged; this fix requires coordinated BabylonNative and Babylon.js changes.

Problem

Multiple-render-target framebuffer creation ignores generateMipMaps: false. A target can allocate mip storage with createMipMaps: true while the caller authors each mip itself. Resolving or switching away from its base-level framebuffer can nevertheless regenerate and overwrite those authored levels.

This predates #2025. Enabling Metal automatic mip generation for R32F/RG32F also exposes the problem for those formats.

Confirmed paths

  • BabylonNative NativeEngine::CreateMultiFrameBuffer calls CreateFrameBufferImpl without specifying autoGenerateMips, so it defaults to true. The single-attachment path already accepts an optional generation flag.
  • Babylon.js ThinNativeEngine._createNativeMultiFrameBuffer does not forward the target's generation intent.
  • Existing MRT arguments include per-attachment layers and an explicit depth texture; their positions and legacy behavior must remain compatible.

Coordinated fix

  • Add backward-compatible optional MRT generation control to the Native bridge.
  • Forward the requested generation behavior from Babylon.js for normal and layered MRTs, including framebuffer recreation after sample-count changes.
  • Keep mip allocation (createMipMaps / existing storage) separate from automatic-generation intent.

Regression coverage

  • Allocate a mip chain with automatic generation disabled, populate higher mips, render the MRT base level, switch targets, and verify authored mip values remain unchanged.
  • Verify automatic generation still works when requested and that legacy calls retain their previous defaults.
  • Cover the newly affected float32 formats on a supporting Metal device and exercise relevant layered/recreated-framebuffer paths.
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.