MOOR security

Dieser Eintrag ist auf Englisch verfasst.

46 bgfx examples match bgfx's own Metal renderer, after one missing format flag

Entry 036770 of 905 tests pass

46 of bgfx's example programs, built for Windows and run through Wine and the D3D12-on-Metal layer, now match bgfx's native Metal renderer at a fixed frame, and one of them only drew its scene after a single format-support flag was added.

What changed

  • bgfx's examples in the test suite. bgfx is a cross-platform rendering library (BSD-2-Clause) with 55 example programs. I build them twice: as Windows executables with mingw, run under Wine with --d3d12, and natively on macOS, where they use bgfx's own Metal renderer. With --fixed-fps 60 both builds animate the same way, so frame 60 of the native build (our present 66, after startup frames) is a reference image. 46 examples now pass that comparison.
  • Acceleration structure compaction. A compacting copy now uses the size the GPU measured after the build, not the source's size. In the new api test rt_compaction, a compacted structure was 91,136 bytes against a measured 35,584 before the fix.
  • Animated devlog frames. The gallery renders a scene N times with a phase t = i / N, and a small script turns the frames into a looping GIF.
The first loop from that tooling, the gallery scene rayquery: the camera circles the ray-traced pyramids in three seconds.
How one missing format flag made 46-fsr black.bgfx init: CheckFeatureSupport(D32_FLOAT) → MULTISAMPLE_RENDERTARGET in Support1?; MULTISAMPLE_RENDERTARGET in Support1? → no MSAA cap for D32_FLOAT (before: no); no MSAA cap for D32_FLOAT → 46-fsr asks for a 4x depth target; 46-fsr asks for a 4x depth target → bgfx refuses the texture: the frame buffer is invalid; bgfx refuses the texture: the frame buffer is invalid → scene never drawn: UI over black; MULTISAMPLE_RENDERTARGET in Support1? → 4x colour + 4x depth frame buffer (after: yes); 4x colour + 4x depth frame buffer → ResolveSubresource into a 1x texture; ResolveSubresource into a 1x texture → FSR upscale and present: matches nativebgfx init:CheckFeatureSupport(D32_FLOAT)MULTISAMPLE_RENDERTARGETin Support1?no MSAA capfor D32_FLOAT46-fsr asks for a4x depth targetbgfx refuses the texture:the frame buffer is invalidscene never drawn:UI over black4x colour + 4x depthframe bufferResolveSubresourceinto a 1x textureFSR upscale and present:matches nativebefore: noafter: yes
How one missing format flag made 46-fsr black. (Mermaid source)

The interesting part

Example 46-fsr (AMD's FidelityFX Super Resolution upscaler) drew its user interface over a black scene. The resolve (averaging a multisampled image into a normal one) was the first suspect, so I wrote a test for it: a 4x RGBA16F target resolved into a single-sample texture. It passed. The logging didn't help: bgfx's examples are Windows GUI programs, and the layer's Windows-side warnings go to stderr, which Wine doesn't connect to the terminal for GUI programs.

The cause was one bit. Before creating a multisampled texture, bgfx asks CheckFeatureSupport whether the format can be a multisampled render target. The layer said yes for colour formats and no for depth formats, so bgfx refused the 4x depth buffer, the frame buffer was invalid, and the scene never drew. The resolve was never even called. Depth formats now report the flag; a new test checks that this flag and the sample-count query agree for every format.

A dead end worth knowing: example 37 can never match. It places objects with the C library's rand(), and Wine's msvcrt and macOS's libc are different generators, so the two builds draw different scenes.

Numbers

  • Full run: 770 pass, 27 fail, 108 skip of 905 tests. 0 newly failing, 49 newly passing against entry 035's run (721 / 27 / 108 of 856): 46 bgfx examples and 3 api tests.
  • 46-fsr against native: 0 pixels differ by more than 16 of 255, the largest difference is 8.
  • Still differing and open: 21-deferred, 43-denoise, 44-sss and 45-bokeh.
Tests by suite at the end of this entry: 770 of 905 pass (data as CSV)
  • pass
  • fail
  • skip

suite · share of each row's total

  1. vkd3d-proton455 pass, 18 fail, 104 skip of 577
  2. vkd3d177 pass, 9 fail, 4 skip of 190
  3. apps (+46)76 pass, 0 fail, 0 skip of 76
  4. api (+3)58 pass, 0 fail, 0 skip of 58
  5. samples4 pass, 0 fail, 0 skip of 4