Graphics: opt-in RenderDoc capture via BABYLON_NATIVE_RENDERDOC - #1832
Merged
bkaradzic-microsoft merged 2 commits intoAug 12, 2026
Merged
Conversation
bgfx only loads RenderDoc -- and therefore only enables the BGFX_FRAME_DEBUG_CAPTURE trigger behind Playground's --capture -- when init.debug is set. Release builds leave that false, so a GPU capture cannot be taken from a normal build without recompiling. Gate it behind an environment variable that is only set when a capture is actually wanted, so the default path is untouched. Any value other than empty or "0" enables it. Verified on Win32: with the variable unset the run is unchanged, and with BABYLON_NATIVE_RENDERDOC=1 the debug device is created successfully and the test still passes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
bkaradzic-microsoft
requested review from
bghgary and
ryantrem
and
a lite review from Copilot
August 12, 2026 18:51
Contributor
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds an opt-in mechanism to enable bgfx’s debug device initialization (to allow RenderDoc captures via the existing --capture flow) by reading an environment variable, keeping default behavior unchanged when the variable is unset.
Changes:
- Include
<cstdlib>for environment variable access. - Set
init.debug = trueonly whenBABYLON_NATIVE_RENDERDOCis set (Windows via_dupenv_s, non-Windows viastd::getenv).
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ryantrem
approved these changes
Aug 12, 2026
…acter The check rejected any value whose first character was '0', so "01", "0x1" and "00" disabled the capture even though only an absent, empty or exactly "0" value is meant to. Extracted the test into IsEnvironmentFlagSet, which compares the whole string and is now shared by the Win32 and POSIX branches. The predicate is still only ever used to set init.debug to true, never to clear it: bgfx defaults init.debug to BGFX_CONFIG_DEBUG, so assigning the predicate directly would turn the debug device off in Debug builds that get it for free.
bkaradzic-microsoft
enabled auto-merge (squash)
August 12, 2026 22:07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
bgfx only loads RenderDoc — and therefore only arms the
BGFX_FRAME_DEBUG_CAPTUREtrigger that Playground's existing--captureflag relies on — wheninit.debugis set. Release builds leave thatfalse, so you can't take a GPU capture from a normal build without recompiling.Change
Gate
init.debugbehind an environment variable that's only set when a capture is actually wanted:Any value other than absent, empty or exactly
"0"enables it (compared in full, so01and0x1enable too). When unset, the code path is identical to today._dupenv_son MSVC /std::getenvelsewhere, so no CRT deprecation warning on Win32.Verification
BABYLON_NATIVE_RENDERDOC=1Worth noting explicitly: enabling
init.debugturns on the D3D11 debug layer, which can fail device creation on machines without the SDK layers installed. That's why this is opt-in per-run rather than, say, defaulted on in Debug builds — an unset variable can never affect anyone.Why
Chasing rendering-parity bugs against Babylon.js repeatedly needed a frame capture, and every time it meant a custom rebuild. This makes
--captureusable as shipped.