cube-vksc: Fix Windows D2D display acquisition and pipeline cache handling - #47
cube-vksc: Fix Windows D2D display acquisition and pipeline cache handling#47dgkoch wants to merge 2 commits into
Conversation
0b844c1 to
377d68e
Compare
No question, that's clearly a bug.
This seems arbitrary. The driver shouldn't report display modes that is not actually supported.
This looks like a bug in the pcutil JSON schema, as we did intend to retain the ability of the old schema allowing integer values (encoded as integer or string). We'll have to look into that.
Such PCC implementations seem to be broken, as the spec clearly states that the viewport/scissor arrays can be |
| "dstAlphaBlendFactor": "VK_BLEND_FACTOR_ZERO", | ||
| "alphaBlendOp": "VK_BLEND_OP_ADD", | ||
| "colorWriteMask": "0xf" | ||
| "colorWriteMask": "VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT" |
There was a problem hiding this comment.
Actually, I looked into the history of this. Apparently the 0xf format (while allowed by the legacy invalid JSON schema), was never accepted even by the legacy parser, but the legacy generator did produce it, so I think this part is a legitimate fix for remnants of the legacy tooling.
18d8b76 to
7484f28
Compare
I investigated this more after posting (trying to fix the alleged pcc bug), and it's actually the pcutils parser that rejects it. It turns out that the arrays can be NULL, but not |
I see. Then yes, the JSON has to be fixed. Unfortunately, that JSON pre-dates the new tools and we never went there to re-validate / fix it. Sure, the Vulkan SC Emulation PCC could use the new parser. It's one of the many good-to-have features we postponed due to other priorities. I guess we may have to revisit that. |
7484f28 to
c1d9bfa
Compare
Fair. However, our direct display implementation has behaved that way for Vulkan (and now Vulkan SC) for at least several years, so while I'll look into improving it, all of our shipping drivers behave this way today. That said the heuristic was a bit janky, so I've just replaced it with an explicit --native-resolution option. |
aqnuep
left a comment
There was a problem hiding this comment.
Otherwise this seems reasonable now.
c1d9bfa to
5c62969
Compare
|
Updated since last review:
Tested on both a 1920×1200 and a 3440×1440 display with 🤖 Generated with Claude Code |
5c62969 to
fd7b063
Compare
a010573 to
effb2d4
Compare
|
Updated since last review: Restructured into two commits:
🤖 Generated with Claude Code |
1. Fix inverted condition in WinRT display acquisition: the condition
`wsi_platform != WSI_PLATFORM_DISPLAY` was backwards; acquire the
display only when display mode is actually in use. Also fix a typo
in the error message ("get acqurie" -> "acquire").
2. Replace assert on vkCreateSwapchainKHR with a proper error exit so
the application terminates cleanly with a diagnostic message instead
of silently hanging on a null swapchain handle.
3. Add (int32_t) casts when storing the mode visibleRegion extents into
demo->width and demo->height (declared int32_t, initialized to -1).
4. Fix cube.pc.json: use named flag format for colorWriteMask as
required by the pcutil schema (VK_COLOR_COMPONENT_*_BIT instead of
the hex literal "0xf"). Use "NULL" for pViewports and pScissors
when those fields are dynamic state, matching the format the pcutil
serializer produces for null pointers. Also regenerate
pipeline_cache.h using the VulkanSC SDK 1.0.22 emulation layer PCC.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Some implementations only support swapchain creation at the display's native panel resolution. Add --native-resolution to opt in to selecting the native-resolution mode rather than mode[0]. When --native-resolution is specified, all available modes are enumerated and the one matching the display's physicalResolution is selected, preferring the highest refresh rate among matching modes (some implementations only support swapchain creation at the highest native rate). If no matching mode is found, a warning is printed and mode[0] is used as a fallback. The vkCreateSwapchainKHR error message in display mode now directs users to --native-resolution. Tested on NVIDIA RTX 5070 with VulkanSC SDK 1.0.22: - Direct-to-display with --native-resolution: spinning cube visible on 1920x1200 and 3440x1440 displays. - Without --native-resolution on an affected driver: clear error message directing the user to use --native-resolution. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
effb2d4 to
3a0f636
Compare
Summary
Fix inverted WinRT display acquisition condition:
wsi_platform != WSI_PLATFORM_DISPLAYwas backwards — the display was never acquired when using display mode. Fix to== WSI_PLATFORM_DISPLAY. Also fix typo in error message ("get acqurie" → "acquire").Add
--native-resolutionflag: Some implementations only support swapchain creation at the display's native panel resolution. When--native-resolutionis specified, all available modes are enumerated and the one matchingphysicalResolutionis selected; if none matches, falls back to mode[0] with a warning. Without the flag, mode[0] is used (default, spec-correct behaviour). If swapchain creation fails in display mode, an actionable error message directs the user to--native-resolution.Fix
cube.pc.json: Use named flag format forcolorWriteMaskas required by the pcutil JSON schema (VK_COLOR_COMPONENT_*_BITinstead of"0xf"). Use"NULL"forpViewportsandpScissorswhen those fields are dynamic state, matching the format the pcutil serializer produces for null pointers.Regenerate
pipeline_cache.husing the VulkanSC SDK 1.0.22 emulation layer PCC.Tested
On NVIDIA RTX 5070 with VulkanSC SDK 1.0.22:
--wsi display --native-resolution: spinning cube visible on 1920×1200 display, on both drivers that enumerate only native modes and drivers that enumerate non-native modes that fail swapchain creation. ✓--wsi displaywithout--native-resolutionon an affected driver: clear error message directing the user to use--native-resolution. ✓--wsi file: all pixels non-zero, max 230/255. ✓VK_DRIVER_FILES=<vksconvk.json>): exit code 0, embedded pipeline cache works. ✓🤖 Generated with Claude Code