NativeCapture: off-screen capture cannot describe NativeEngine render targets (unregistered, no sRGB flag)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start with Plugins/NativeCapture/Source/NativeCapture.cpp and trace how OffScreenBufferFrameProvider creates and blits its readback target. Read Core/Graphics/InternalInclude/Babylon/Graphics/DeviceContext.h, Plugins/NativeXr/Source/NativeXrImpl.cpp, and the NativeEngine::InitializeTexture path to understand the missing texture description and sRGB flag. Done means NativeCapture can use the framebuffer attachment's size, format, and flags to create a compatible target; the issue reports no device reproduction or validation result.
由索引模型根据 Issue 内容生成。
描述
Problem
OffScreenBufferFrameProvider in Plugins/NativeCapture/Source/NativeCapture.cpp creates its readback blit target from DeviceContext::GetTextureInfo:
bgfx::createTexture2D(m_textureInfo.Width, m_textureInfo.Height, m_textureInfo.HasMips, m_textureInfo.NumLayers,
m_textureInfo.Format, BGFX_TEXTURE_BLIT_DST | BGFX_TEXTURE_READ_BACK)
and blits the framebuffer's colour texture into it every frame. That description is incomplete in two ways.
- NativeEngine textures are not registered.
DeviceContext::AddTextureis only called by NativeXr (Plugins/NativeXr/Source/NativeXrImpl.cpp,BeginUpdate); NativeEngine stopped registering its textures in #1173.DeviceContext::GetTextureInforeturnsm_textureHandleToInfo[handle.idx], so an unknown handle yields a default-constructedTextureInfo. Capturing a framebuffer created through NativeEngine therefore builds the blit target from width 0, height 0 and format value 0, and the blit's source and destination formats differ on every backend. - No texture flags.
Graphics::TextureInfo(Core/Graphics/InternalInclude/Babylon/Graphics/DeviceContext.h) carries width, height, mips, layers and format only. A source created withBGFX_TEXTURE_SRGB(NativeEngine::InitializeTexturesets it for sRGB render targets) would get a non-sRGB blit target. The bgfx Metal renderer (pinned 6d878f16) maps that flag to the_sRGBpixel format and blits withcopyFromTexture, so the two pixel formats differ. This is the mismatch #2072 fixes forreadTexture, where Metal API validation reports it.
Gap 1 hides gap 2 today: the only registered source is the NativeXr colour texture, which is linear on both sides (ARKit allocates MTLPixelFormatBGRA8Unorm, imported as bgfx::TextureFormat::BGRA8). Registering NativeEngine textures without carrying their flags would expose gap 2 for sRGB render targets.
Raised in https://github.com/BabylonJS/BabylonNative/pull/2072#discussion_r4529937549. Checked on master 020832ba; #2072 (head 86bfe570) does not change NativeCapture or TextureInfo.
Platform / backend
Gap 1: all backends. Gap 2: Metal; other backends not examined.
Reproduce
Create a RenderTargetTexture with useSRGBBuffer: true, add it to scene.customRenderTargets, and pass its native framebuffer to new NativeCapture(frameBuffer) with a callback that logs each frame's width, height and format.
Expected: frames with the render target's size in RGBA8. From the code, the blit target is created from the zero-initialised description instead. With the texture info supplied, running with Metal API validation enabled should report the sRGB / non-sRGB blit.
Not measured
Both gaps are established from the code path only. Neither the capture above nor the Metal validation failure has been run or captured on a device.
Suggested direction
Have the capture path get size, format and flags from the framebuffer it is given (for example by having Graphics::FrameBuffer expose its colour attachment's description) instead of the AddTexture registry, which DeviceContext.h already marks with a TODO, and keep BGFX_TEXTURE_SRGB on the blit target as #2072 does for readTexture.
- 主要语言
- C++
- 星标
- 931
- 派生
- 169
- 平均合并
- 2 天 17 小时
- 30 天内合并 PR
- 66
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
BabylonJS/BabylonNative 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
BabylonJS/BabylonNative#2138 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
BabylonJS/BabylonNative#2042 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
BabylonJS/BabylonNative#2052 ·
维护者通常 1 天内回复
-
testing
难度 4/5 3-5 天 新手友好度 45/100
BabylonJS/BabylonNative#2136 ·
维护者通常 1 天内回复
-
Support useNDCHalfZRange (half-range NDC depth) so Babylon.js half-range depth visual tests can run可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 48/100
BabylonJS/BabylonNative#2134 ·
维护者通常 1 天内回复
查看 BabylonJS/BabylonNative 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
[Bug]: pip install -U cudaq-qec fails with a conflict that names cudaq-qec itself可能已有人在做 @fedonman 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
task
难度 2/5 1-3 小时 新手友好度 76/100
SparseLinearAlgebra/spla#316 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 3 天内回复