Commit 81a7bfe
Add programmatic GPU frame capture via TestUtils.captureNextFrame. (#1675)
Introduces a one-shot, cross-backend API for requesting a GPU debugger
capture of the next submitted frame. Wraps bgfx's
`BGFX_FRAME_DEBUG_CAPTURE` flag, so the same call works with Xcode Metal
capture on macOS/iOS, PIX or RenderDoc on Windows, and RenderDoc on
Linux/Android.
Primary use case: producing a .gputrace for a failing validation test
without having to manually time a capture in the IDE. Add "capture":
true to a test entry in Apps/Playground/Scripts/config.json and the test
harness will request a capture on the screenshot frame; with the
platform GPU debugger attached, a capture document opens automatically.
Implementation:
- DeviceImpl owns an `std::atomic<bool> m_captureNextFrame`. `Frame()`
consumes it via exchange(false) and ORs `BGFX_FRAME_DEBUG_CAPTURE` into
the `bgfx::frame()` flags, guaranteeing the request is applied to
exactly one frame even under concurrent JS-thread calls.
- DeviceContext exposes `RequestCaptureNextFrame()`as a thin forwarder,
extending the existing public surface alongside RequestScreenShot.
- TestUtils plugin adds a cross-platform `captureNextFrame()` JS method
(no per-platform .mm/.cpp variants required).
validation_native.js honors an optional per-test "capture" flag and arms
a capture before the final `currentScene.render()` of the screenshot
frame.
When no GPU debugger is attached the bgfx flag is a no-op, so the API is
safe to leave in JS that ships in release builds.
Co-authored-by: Branimir Karadzic <branimirkaradzic@Bgmail.com>1 parent d63e9fb commit 81a7bfe
7 files changed
Lines changed: 27 additions & 1 deletion
File tree
- Apps/Playground/Scripts
- Core/Graphics
- InternalInclude/Babylon/Graphics
- Source
- Plugins/TestUtils/Source
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
121 | 124 | | |
122 | 125 | | |
123 | 126 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
64 | 69 | | |
65 | 70 | | |
66 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
376 | 381 | | |
377 | 382 | | |
378 | 383 | | |
| |||
462 | 467 | | |
463 | 468 | | |
464 | 469 | | |
465 | | - | |
| 470 | + | |
| 471 | + | |
466 | 472 | | |
467 | 473 | | |
468 | 474 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
| |||
123 | 125 | | |
124 | 126 | | |
125 | 127 | | |
| 128 | + | |
| 129 | + | |
126 | 130 | | |
127 | 131 | | |
128 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
94 | 99 | | |
95 | 100 | | |
96 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| 73 | + | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
| |||
0 commit comments