Correct native render-target MSAA allocation - #1884
bkaradzic-microsoft wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Gate unsupported MSAA test cases and apply corrected flag selection to external-texture paths.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Corrects native render-target MSAA flag selection and initialization behavior, with regression coverage.
Changes:
- Selects mutually exclusive MSAA flags correctly.
- Omits CPU initialization data for sampled multisample storage.
- Adds native MSAA tests and registers them in CMake.
File summaries
| File | Summary |
|---|---|
Plugins/NativeEngine/Source/NativeEngine.cpp |
Corrects render-target MSAA flag selection; external-texture paths still need the same fix. |
Core/Graphics/Source/Texture.cpp |
Adjusts initialization behavior for multisample render targets. |
Apps/UnitTests/Source/Tests.NativeEngine.Msaa.cpp |
Adds MSAA allocation and framebuffer coverage; unsupported sample levels need to be skipped. |
Apps/UnitTests/CMakeLists.txt |
Registers the new native test source. |
Review details
Suppressed comments (2)
Apps/UnitTests/Source/Tests.NativeEngine.Msaa.cpp:62
- The capability probe does not use the flags that
Texture::Create2Dactually passes to bgfx: owned textures addBGFX_TEXTURE_BLIT_DSTincreateFlagsabove. A backend can therefore report this combination as valid here while rejecting the effective flags used bysampled.Create2D, making the test fail instead of skipping an unsupported allocation. Probe the effective flag set.
if (!bgfx::isTextureValid(0, false, 1, bgfx::TextureFormat::RGBA8, sampledFlags))
Plugins/NativeEngine/Source/NativeEngine.cpp:1648
- Please apply this field selection to the external-texture path as well. The D3D11/D3D12/Metal
GetInfoimplementations still ORBGFX_TEXTURE_RTwithRenderTargetSamplesToBgfxMsaaFlag(...)(for example,ExternalTexture_D3D11.cpp:204-210), and those flags flow unchanged intoTexture::Create2D. Thus wrapped sampled-MSAA resources still carry the same mutually exclusive RT/MSAA combination this change fixes here and can be interpreted as the next sample level. Centralize or reuse the same conditional selection for that shared path.
// RT and the MSAA levels are values in the same field, not independent bits.
const auto msaaFlag = RenderTargetSamplesToBgfxMsaaFlag(samples);
flags |= msaaFlag != BGFX_TEXTURE_NONE ? msaaFlag : BGFX_TEXTURE_RT;
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
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.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
|
Addressed the suppressed external-texture MSAA finding from the earlier Copilot review in b0ea3fc as well. D3D11/D3D12/Metal now share field selection that does not OR the single-sample RT value into a multisample level. The new wrapping regression reproduces 2x being labeled as 4x before the fix and verifies exact 1x/2x/4x flags afterward; all four selected D3D11 allocation/rendering controls pass. This complements the effective-BLIT_DST capability-probe fix already published in a1523bb. |
b0ea3fc to
d81ec6a
Compare
There was a problem hiding this comment.
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.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Select the render-target sample-count field rather than ORing its values, and avoid supplying CPU initialization data to sampled multisample storage. Retain zero initialization for ordinary render targets. Add native coverage for 1x/2x/4x/8x flags, matching color/depth attachments, and sampled multisample allocations. Keep protocol and dependency pins unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
Check the color and selected depth framebuffer flags before each sample count allocation. Skip unsupported backends/combinations explicitly and report unsupported sampled-storage cases instead of silently omitting them. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
Guard invalid framebuffer destruction, fail stalled allocation tasks after 30 seconds without unwinding resources they may still reference, and probe the effective texture creation flags. Spell out the sampled-MSAA mask test while preserving ordinary resolve-texture initialization. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
Apply the RT/MSAA field selection to D3D11, D3D12 and Metal external textures through their shared sample-count helper. Do not OR single-sample RT into a multisample field; preserve the independent MSAA sampling bit. Add a bounded native wrapping regression for 1x/2x/4x metadata. The 2x case reports the incorrect 4x field before the fix and passes afterward. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
d81ec6a to
c9e50ca
Compare
Summary
Independence
Rebased onto
master(2a9dc944). No Babylon.js changes, protocol changes, dependency updates, fixture changes, or tolerance changes. This does not include the separate D24 format fallback in #1874.Validation
Windows x64 / D3D11 / Chakra / RelWithDebInfo, using pinned upstream dependencies and published Babylon.js 9.21.2:
External-texture review follow-up
Commit
b0ea3fc6also applies exclusive RT/MSAA field selection to the D3D11, D3D12, and Metal external-texture paths through their shared sample-count helper. This addresses the suppressed finding in the earlier Copilot review; the independentBGFX_TEXTURE_MSAA_SAMPLEbit is preserved.A new bounded native wrapping regression checks exact 1x/2x/4x metadata. Before the fix, its 2x case reports the 4x field; after the fix it passes. All four selected D3D11 tests pass: that regression, native MSAA allocation, and the unchanged external 1x/4x rendering controls. D3D12/Metal runtime coverage is left to their supported CI configurations; the new case respects the existing external/render/multisample skip settings.