NativeEngine: enableScissor before a render-target pass adds a back-buffer render pass
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 70/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- cpp
- Ambito
- backend, performance
Direzione di ricerca
Start with NativeEngine::SetScissor and GetBoundFrameBuffer in Plugins/NativeEngine/Source/NativeEngine.cpp, then trace scissor reconciliation in FrameBuffer::Submit, Blit, and Clear in Core/Graphics/Source/FrameBuffer.cpp. Confirm how the proposed change handles a scissor set before binding a render target and when the default framebuffer is first drawn. Done means that sequence no longer submits an unnecessary back-buffer clear pass, while scissor state still applies to later rendering.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
NativeEngine::SetScissor resolves its target through GetBoundFrameBuffer(). If the default framebuffer has not been used yet in the frame, that call binds it and runs ResetDefaultFrameBuffer(), which submits a depth/stencil clear view on the back buffer. When the next draws go to an offscreen target, the frame gets a back-buffer render pass ahead of the offscreen pass whose only content is that clear:
back buffer (clear only) -> offscreen target -> back buffer (the frame's real draws)
On tile-based GPUs every render pass on the drawable loads and stores it, so the extra pass adds a full-screen colour load and store. Context: we run these paths on a fork with XR whose low end is iPhone XS, Apple TV 4K 1st gen, and Meta Quest 1
Raised in https://github.com/BabylonJS/BabylonNative/pull/2075#discussion_r4529937270.
Platform / backend
The NativeEngine code path is backend-independent. The render-pass consequence described here is for Metal on Apple GPUs.
Code path (master 020832ba)
- JS calls
engine.enableScissor(x, y, w, h)while no render target is bound (COMMAND_SETSCISSOR). NativeEngine::SetScissor(Plugins/NativeEngine/Source/NativeEngine.cpp) storesm_scissor, then callsGetBoundFrameBuffer().SetScissor(...).NativeEngine::GetBoundFrameBufferbindsm_defaultFrameBufferwhenm_boundFrameBufferis null.m_defaultFrameBufferNeedsResetis true on the first use in a frame, so it callsResetDefaultFrameBuffer(). The same happens when the default framebuffer is already bound but has not been used this frame.ResetDefaultFrameBuffercallsm_defaultFrameBuffer.Clear(...)with the depth/stencil flags.FrameBuffer::Clear(Core/Graphics/Source/FrameBuffer.cpp) acquires a view on the back buffer and submits to it.FrameBuffer::SetScissor->SetBgfxViewPortAndScissorthen acquires a second view id on the back buffer. Nothing is drawn to it.- JS binds the render target and draws, which starts a view on a different framebuffer. In the bgfx Metal renderer (pinned 6d878f16,
src/renderer_mtl.cpp,submit), a view whose framebuffer differs from the open encoder's ends that encoder and begins a new render pass. For the depth/stencil-only clear in step 4, colour isLoadActionLoad/StoreActionStore.
Without steps 3-4 the reset would run when the back buffer is first drawn, inside the pass that draws to it.
Reproduce
engine.enableScissor(0, 0, 16, 16); // no render target bound
renderTarget.render(); // offscreen pass
engine.disableScissor();
scene.render();
Babylon.js has this shape in packages/dev/loaders/src/SPLAT/gaussianSplattingWorkBuffer.ts (restoreRegion and the streaming bake call enableScissor before mrt.render()), the flow #2075 fixed. A Metal GPU capture of such a frame should show a pass on the drawable before the atlas pass.
Not measured
This is established from the code path only. The extra back-buffer pass has not been captured on a device, and there is no frame-time or bandwidth number for it.
Suggested direction
m_scissor is the source of truth since #2075, so SetScissor does not need to bind anything: store the rect and, when m_boundFrameBuffer is non-null, call InheritScissor on it. FrameBuffer::Submit, Blit and Clear already reconcile m_desiredScissor when the next view starts, and BindWithScissor applies it on the next bind.
- Lingua principale
- C++
- Stelle
- 931
- Fork
- 169
- Merge medio
- 2g 17h
- PR unite (30g)
- 66
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di BabylonJS/BabylonNative
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
BabylonJS/BabylonNative#2138 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
BabylonJS/BabylonNative#2042 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
BabylonJS/BabylonNative#2052 ·
I maintainer di solito rispondono entro 1 giorno
-
testing
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
BabylonJS/BabylonNative#2136 ·
I maintainer di solito rispondono entro 1 giorno
-
Support useNDCHalfZRange (half-range NDC depth) so Babylon.js half-range depth visual tests can runAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
BabylonJS/BabylonNative#2134 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di BabylonJS/BabylonNative
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
simnJS/AnyPS5#735 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
needs-format
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Niko1221/Strata#7719 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni
-
area:tests kind:test
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno