Repository navigation
Conversation
|
My Discord username is |
|
Verified on main a73a57e (Ubuntu 24.04 x86-64, GCC 13.3, CMake 3.28, Ninja, no GPU). Merges cleanly. ctest -R '^clear_color$' passes with this PR; the PR's runtime/test/clear_color_test.cpp built against main's vulkan_replay.h fails, so the new case fails on main and passes with the change. AI-assisted: yes (Claude Code) |
|
Confirmed that the patch changes the stored RGB565 bits on an RTX 4090. For an RGB clear of (0.5, 0.5, 0.5), the Vulkan layer wrote I exercised
Here “exact scaling” means multiplying each supplied float32 by 31, 63 or 31 in double precision before rounding. “Float32 scaling” rounds that product to float32 first. The WARP result is an observation on this build. The two calculations can pick neighboring codes near a half-step. The 62 head/WARP disagreements were at most one code per channel. These inputs deliberately concentrate on thresholds, so the counts describe this test set. The full and rectangular readbacks agreed across all paths. Repeating the matrix gave identical results and no Vulkan validation errors. The PR's 519 CPU replay checks also passed. This verifies the layer's stated rounding rule on a Vulkan device where the midpoint changes. |
|
Ready for maintainer review. The RTX 4090 readback confirms the patch applies Leonida’s existing normalized-clear rounding rule. Native D3D12 on that GPU and WARP differed near rounding thresholds, as documented above. Is the existing Leonida rule the intended behavior for RGB565? The fork CI run reports action_required with zero jobs. Could a maintainer approve it if CI is wanted for review? The M5 Max suite completed with 105 passed and 3 skipped. I’ve kept the independent viewport fix (#2271) in draft. Should it enter review now or after this one lands? AI-assisted: yes. |
lixonik
left a comment
There was a problem hiding this comment.
Reviewed and tested merged onto main (493867366) on Windows 11 (MSVC 19.44, Ninja Release).
- Adding
VK_FORMAT_R5G6B5_UNORM_PACK16with{31, 63, 31, 0}channel widths torender_target_clear_color()accurately quantizesDXGI_FORMAT_B5G6R5_UNORMclears per channel (and complements the other 16-bit packed UNORM formats in #2479 without overlap). - Built
clear_color_testand ranctest --output-on-failure -V -R ^clear_color$: 1/1 passed (519 checks, 0.02 s).
AI-assisted (Antigravity, Gemini).
|
This changes stored RGB565 pixels on physical gfx906 (RADV Mesa 26.0.8), but not at the exact midpoint. Comparing main The difference covered all 315 pixels of the full clear and all 88 pixels inside the rectangle. Across 30 finite clears, the merge matched all 6,045 fill pixels; main missed 403. All 3,405 outside-rectangle pixels stayed unchanged. The identical replay unit test also went from a midpoint command-value failure to 519 checks passing. No validation errors or synchronization hazards; NaN cases were checked at the command boundary only. This verifies the runtime’s nearest-even rule, not a universal native D3D12 tie rule. AI-assisted. |
timbot103
left a comment
There was a problem hiding this comment.
Reviewed head 1e0de21b0 from the supplied diff against b6bf3aa0b. Static audit only. I ran no builds, tests, or GPU workloads.
runtime/shims/d3d12_vulkan_device.cpp:2454mapsDXGI_FORMAT_B5G6R5_UNORMtoVK_FORMAT_R5G6B5_UNORM_PACK16. Clear inputs stay in logical RGBA order, and the packed word places red in bits 11–15, green in bits 5–10, and blue in bits 0–4. The new maxima of 31, 63, and 31 match that layout. The fourth float is passed through, and the format has no alpha channel. BothvkCmdClearColorImageandvkCmdClearAttachmentsreceive the converted value fromruntime/src/vulkan_replay.h.- The shared converter sends NaN, nonpositive values, and negative infinity to zero, and sends values at or above one, including positive infinity, to one. For finite in-range float32 inputs, the double-precision product is rounded to nearest, ties to even. At these scales the only exactly representable half-step input is 0.5, where half-up and nearest-even both yield codes 16, 32, and 16. Vulkan receives floats representing the selected codes away from the half-step boundaries. The supplied native D3D12 measurements differ across drivers near thresholds, consistent with the variation documented in
docs/d3d12_vulkan.md:272. runtime/test/clear_color_test.cpp:140exercises the midpoint, NaN, and clamping through both replay callbacks. The midpoint assertion detects the original float passthrough. The existing packed readback check inruntime/test/d3d12_vulkan_device_test.cpp:6015covers the red and blue bit positions for whole and rectangular clears. The change uses an existing Vulkan format constant and standard C++ in the same CTest target for Windows/MSVC and Linux.- Both patch hunks fit
b6bf3aa0b. The packed-format change ate7d11f0dadiscussed as #2479 adds RGB5551 and RGBA4444 cases and updates the RGBA4444 fallback. Its switch and test additions are at distinct insertion points from the RGB565 changes. The merge labeled #2479 in the supplied main history isd09752898and changes Wine test tooling only.
AI-assisted.
Claimed in the coordination issue as RT-CLEAR-RGB565-UNORM.
What and why
The RTV replay path already pre-rounds normalized clear values so the conversion is independent of the driver’s tie handling. RGB565 fell through to the raw float path. Apply the existing converter with channel maxima of 31, 63 and 31. Cover full and rectangle clears, midpoint rounding, NaN and clamping.
Tested
On the parent revision the new midpoint case failed (red 0.5, expected 16/31). With the change all 519 clear replay checks passed. The no-game-data check passed for both changed files.
GPUs tested: Apple M5 Max, Apple Metal driver on macOS 27.3. A separate native Metal RGB565 clear and readback produced 0x8410 for both the raw and pre-rounded midpoint. That device already rounds this case the same way. The failing regression was at the renderer’s Vulkan command boundary; the replay test uses synthetic inputs and captures the clear without a GPU.
Full native runtime CTest suite on Apple M5 Max with MoltenVK 1.4.2: 105 passed, 0 failed, 3 skipped (shader_library_corpus, vk_device_markers, vk_sync_validation).
AI-assisted: yes.