fix(vk): give image descriptors a dummy view when nullDescriptor is off #403

Merged
HumanBean merged 1 commit from jcabarca/Longshot:fix/vk-dummy-views into main 2026-11-15 18:30:01 +00:00
Contributor

Type: fix · Risk: low · Tested on: Windows, AMD Radeon RX 9070 XT · Needs: none

Why

On a GPU without robustness2's nullDescriptor, a sampled or storage image that does not resolve to a view was written to its descriptor as VK_NULL_HANDLE. That breaks VUID-VkWriteDescriptorSet-descriptorType-02997: the validation layers flag it, and a driver may read garbage or crash. Now it gets a 1x1 black dummy view of the right view type.

How to reproduce

Seen on: not seen in the game: found by reading make_dummies() and build_descriptors() in gpu/vk/vk_draw.cpp; it happens on any device that does not enable nullDescriptor (the RX 9070 XT enables it, so it never takes this path)
Settings and switches: defaults
Steps: game-free: python -I tests/test_dummy_views.py --cxx clang++ --headers <Vulkan-Headers v1.4.345>/include --source <main checkout> (copy the test from this PR); it reads vk_draw.cpp and builds make_dummies() in a stubbed fixture
Expected: with nullDescriptor off, no image descriptor is written with a null imageView
Actual: on main make_dummies() makes nothing and a storage image that does not resolve is written as VK_NULL_HANDLE; the test fails with AssertionError: storage image written as VK_NULL_HANDLE

What changed

make_dummies() was an empty stub, so on a device without nullDescriptor every dummy view stayed null and an image that does not resolve was written as a null view. It now makes three 1x1 black images once, clears them in the first recording and makes one view per view type; build_descriptors() uses those views for storage images too. Devices with nullDescriptor are unchanged.

  • vk: make_dummies() in gpu/vk/vk_draw.cpp makes, once and only without nullDescriptor, three 1x1 black VK_FORMAT_R8G8B8A8_UNORM images (1D; 2D cube compatible with 6 layers; 3D), clears them in the first recording (rec_cmd) with a barrier to GENERAL before and after the clear, and makes one view per VkImageViewType in dummies.view[] (the cube array view only with imageCubeArray). If an image cannot be made, the ones made are destroyed, it logs vk: the dummy images (no nullDescriptor): not made (up to 4 times) and the views stay null, as before.
  • vk: build_descriptors() in gpu/vk/vk_draw.cpp: a storage image that does not resolve gets dummies.view[(int)vt] instead of VK_NULL_HANDLE.
  • tests: tests/test_dummy_views.py (new) cuts make_dummies() out of vk_draw.cpp into a stubbed fixture and checks the storage image line.

The bug, step by step:

  1. make_dummies() on main returned at once (if (dummies.view[0] || dev.null_descriptor) return;) and made nothing, so dummies.view[] stayed VK_NULL_HANDLE on every device.
  2. In build_descriptors(), a storage image whose handle does not resolve to a view kept view = VK_NULL_HANDLE (if (!view && !dev.null_descriptor) view = VK_NULL_HANDLE;), and a sampled one fell back to the null dummies.view[].
  3. That null view went into VkDescriptorImageInfo::imageView and to vkUpdateDescriptorSets with nullDescriptor off.

The rule, from Khronos validusage.json (Vulkan-Headers v1.4.345):

  • VUID-VkWriteDescriptorSet-descriptorType-02997: "If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, or VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, and the nullDescriptor feature is not enabled, the imageView member of each element of pImageInfo must not be VK_NULL_HANDLE"

Before (build_descriptors()):

if (!view && !dev.null_descriptor) view = VK_NULL_HANDLE;

After:

if (!view && !dev.null_descriptor) view = dummies.view[(int)vt];

Before (make_dummies()):

void make_dummies() {
    if (dummies.view[0] || dev.null_descriptor) return;
}

After (shortened; the full function is in the diff):

void make_dummies() {
    static VkImage img[3]{};
    static VmaAllocation mem[3]{};
    if (img[0] || dev.null_descriptor || !rec_cmd) return;
    // 1x1 1D, 2D (cube compatible, 6 layers) and 3D images, SAMPLED | STORAGE | TRANSFER_DST;
    // on a failure the images made are given back and the views stay null
    // barrier UNDEFINED -> GENERAL, vkCmdClearColorImage to black, barrier to shader read/write
    // one view per VkImageViewType (CUBE_ARRAY only with imageCubeArray)
}

Start reading at make_dummies() in vk_draw.cpp: the images are made only when a recording is open (rec_cmd), so the clear goes in that command buffer.

Measurements

Verdict: it fixes the bug: tests/test_dummy_views.py fails on main (a storage image is written as VK_NULL_HANDLE) and passes with this PR, in both interleaved runs. No speed change is expected: devices with nullDescriptor do nothing new; the others make three 1x1 images and up to 7 views once.

Hardware: AMD Radeon RX 9070 XT, Windows; the test itself is game-free (it does not use the GPU); clang++ from llvm-mingw 20261104 (ucrt x86_64)
Scene: none, game-free
Method: tests/test_dummy_views.py from this PR against each side's gpu/vk/vk_draw.cpp (--source pointed at a checkout of main), 2 runs each, interleaved (main, PR, main, PR); the result is pass/fail, so the median is the result both runs gave
How to reproduce: python -I tests/test_dummy_views.py --cxx clang++ --headers <Vulkan-Headers v1.4.345>/include (with --source <checkout> to point at main)

Before: main @ 93344a7c After: this PR @ 1b5553e0
tests/test_dummy_views.py, run 1 fails passes (4 cases: made, no-cube-array, null-descriptor, image-fails)
tests/test_dummy_views.py, run 2 fails passes (4 cases)
Median fails passes
run 1, main @ 93344a7c:
AssertionError: storage image written as VK_NULL_HANDLE
exit 1
run 1, this PR @ 1b5553e0:
exit 0
run 2, main @ 93344a7c:
AssertionError: storage image written as VK_NULL_HANDLE
exit 1
run 2, this PR @ 1b5553e0:
exit 0

What the test checks:

  • made: with imageCubeArray, every one of the 7 view types gets a non-null dummy view; 3 images are made and cleared; a second call makes nothing more.
  • no-cube-array: without imageCubeArray, no cube array view is made, the 2D one is.
  • null-descriptor: with nullDescriptor, nothing is made (null views stay valid there).
  • image-fails: if the second image cannot be made, the first is destroyed and the views stay null.
  • And vk_draw.cpp no longer writes a storage image as VK_NULL_HANDLE.

Flags and settings

None.

Testing

Tested: on this branch, Windows, clang++ from llvm-mingw 20261104: test_dummy_views passes (fails on main), and the other checks that read the changed code pass: test_desc_clock, test_desc_counts, test_drawn_page_map, test_prof_symbols, test_draw_stream_visibility, test_fsr_uniform_ownership, test_recording_admission. test_drawn_page_map first failed twice on this branch only in its temp-folder cleanup on Windows (WinError 32: its built f.exe was still locked, after every check had passed), then passed in 2 of 2 runs interleaved with main (main: 2 of 2 too).

Built and played: this commit builds on Windows (llvm-mingw back end) and on Linux (longshot_vk.so, without and with AMD FSR 4). Played on Windows, AMD Radeon RX 9070 XT: the game runs normally.

Not tested: a device without nullDescriptor: the RX 9070 XT has it, so in the game this path (and the dummy views) is never reached, and the validation layers were not run on such a device. Linux was built, not run.

Must be tested: None: the game-free test covers the new path on every GPU and OS.

Risks

What could break: only devices without nullDescriptor take the new path: three 1x1 images and up to 7 views made once, cleared in the first recording. A shader that reads an image that does not resolve now reads black instead of whatever a null view gave. If an image cannot be made, the views stay null, as on main.

Turning it off: revert the commit.

Compatibility: Nothing changes.

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched). (no issue fits)
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named). (the checks that read the changed code, on this PR, Windows: test_dummy_views, test_desc_clock, test_desc_counts, test_drawn_page_map, test_prof_symbols, test_draw_stream_visibility, test_fsr_uniform_ownership, test_recording_admission, all pass)
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • A game-free test added for the fix, failing on main and passing here. (tests/test_dummy_views.py, new)
  • A check under tests/ that reads changed source updated in this PR, not weakened. (tests/test_dummy_views.py, new, reads gpu/vk/vk_draw.cpp)
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. (built on Windows with llvm-mingw and on Linux, longshot_vk.so without and with AMD FSR 4; no OS-specific code or paths)
**Type:** fix · **Risk:** low · **Tested on:** Windows, AMD Radeon RX 9070 XT · **Needs:** none ## Why On a GPU without robustness2's `nullDescriptor`, a sampled or storage image that does not resolve to a view was written to its descriptor as `VK_NULL_HANDLE`. That breaks VUID-VkWriteDescriptorSet-descriptorType-02997: the validation layers flag it, and a driver may read garbage or crash. Now it gets a 1x1 black dummy view of the right view type. ## How to reproduce **Seen on:** not seen in the game: found by reading `make_dummies()` and `build_descriptors()` in `gpu/vk/vk_draw.cpp`; it happens on any device that does not enable `nullDescriptor` (the RX 9070 XT enables it, so it never takes this path) **Settings and switches:** defaults **Steps:** game-free: `python -I tests/test_dummy_views.py --cxx clang++ --headers <Vulkan-Headers v1.4.345>/include --source <main checkout>` (copy the test from this PR); it reads `vk_draw.cpp` and builds `make_dummies()` in a stubbed fixture **Expected:** with `nullDescriptor` off, no image descriptor is written with a null `imageView` **Actual:** on main `make_dummies()` makes nothing and a storage image that does not resolve is written as `VK_NULL_HANDLE`; the test fails with `AssertionError: storage image written as VK_NULL_HANDLE` ## What changed `make_dummies()` was an empty stub, so on a device without `nullDescriptor` every dummy view stayed null and an image that does not resolve was written as a null view. It now makes three 1x1 black images once, clears them in the first recording and makes one view per view type; `build_descriptors()` uses those views for storage images too. Devices with `nullDescriptor` are unchanged. - vk: `make_dummies()` in `gpu/vk/vk_draw.cpp` makes, once and only without `nullDescriptor`, three 1x1 black `VK_FORMAT_R8G8B8A8_UNORM` images (1D; 2D cube compatible with 6 layers; 3D), clears them in the first recording (`rec_cmd`) with a barrier to `GENERAL` before and after the clear, and makes one view per `VkImageViewType` in `dummies.view[]` (the cube array view only with `imageCubeArray`). If an image cannot be made, the ones made are destroyed, it logs `vk: the dummy images (no nullDescriptor): not made` (up to 4 times) and the views stay null, as before. - vk: `build_descriptors()` in `gpu/vk/vk_draw.cpp`: a storage image that does not resolve gets `dummies.view[(int)vt]` instead of `VK_NULL_HANDLE`. - tests: `tests/test_dummy_views.py` (new) cuts `make_dummies()` out of `vk_draw.cpp` into a stubbed fixture and checks the storage image line. The bug, step by step: 1. `make_dummies()` on main returned at once (`if (dummies.view[0] || dev.null_descriptor) return;`) and made nothing, so `dummies.view[]` stayed `VK_NULL_HANDLE` on every device. 2. In `build_descriptors()`, a storage image whose handle does not resolve to a view kept `view = VK_NULL_HANDLE` (`if (!view && !dev.null_descriptor) view = VK_NULL_HANDLE;`), and a sampled one fell back to the null `dummies.view[]`. 3. That null view went into `VkDescriptorImageInfo::imageView` and to `vkUpdateDescriptorSets` with `nullDescriptor` off. The rule, from Khronos `validusage.json` (Vulkan-Headers v1.4.345): - VUID-VkWriteDescriptorSet-descriptorType-02997: "If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, or VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, and the nullDescriptor feature is not enabled, the imageView member of each element of pImageInfo must not be VK_NULL_HANDLE" Before (`build_descriptors()`): ```cpp if (!view && !dev.null_descriptor) view = VK_NULL_HANDLE; ``` After: ```cpp if (!view && !dev.null_descriptor) view = dummies.view[(int)vt]; ``` Before (`make_dummies()`): ```cpp void make_dummies() { if (dummies.view[0] || dev.null_descriptor) return; } ``` After (shortened; the full function is in the diff): ```cpp void make_dummies() { static VkImage img[3]{}; static VmaAllocation mem[3]{}; if (img[0] || dev.null_descriptor || !rec_cmd) return; // 1x1 1D, 2D (cube compatible, 6 layers) and 3D images, SAMPLED | STORAGE | TRANSFER_DST; // on a failure the images made are given back and the views stay null // barrier UNDEFINED -> GENERAL, vkCmdClearColorImage to black, barrier to shader read/write // one view per VkImageViewType (CUBE_ARRAY only with imageCubeArray) } ``` Start reading at `make_dummies()` in `vk_draw.cpp`: the images are made only when a recording is open (`rec_cmd`), so the clear goes in that command buffer. ## Measurements **Verdict:** it fixes the bug: `tests/test_dummy_views.py` fails on main (a storage image is written as `VK_NULL_HANDLE`) and passes with this PR, in both interleaved runs. No speed change is expected: devices with `nullDescriptor` do nothing new; the others make three 1x1 images and up to 7 views once. Hardware: AMD Radeon RX 9070 XT, Windows; the test itself is game-free (it does not use the GPU); clang++ from llvm-mingw 20261104 (ucrt x86_64) Scene: none, game-free Method: `tests/test_dummy_views.py` from this PR against each side's `gpu/vk/vk_draw.cpp` (`--source` pointed at a checkout of main), 2 runs each, interleaved (main, PR, main, PR); the result is pass/fail, so the median is the result both runs gave How to reproduce: `python -I tests/test_dummy_views.py --cxx clang++ --headers <Vulkan-Headers v1.4.345>/include` (with `--source <checkout>` to point at main) | | Before: main @ 93344a7c | After: this PR @ 1b5553e0 | |---|---|---| | `tests/test_dummy_views.py`, run 1 | fails | passes (4 cases: made, no-cube-array, null-descriptor, image-fails) | | `tests/test_dummy_views.py`, run 2 | fails | passes (4 cases) | | Median | fails | passes | ``` run 1, main @ 93344a7c: AssertionError: storage image written as VK_NULL_HANDLE exit 1 run 1, this PR @ 1b5553e0: exit 0 run 2, main @ 93344a7c: AssertionError: storage image written as VK_NULL_HANDLE exit 1 run 2, this PR @ 1b5553e0: exit 0 ``` What the test checks: - `made`: with `imageCubeArray`, every one of the 7 view types gets a non-null dummy view; 3 images are made and cleared; a second call makes nothing more. - `no-cube-array`: without `imageCubeArray`, no cube array view is made, the 2D one is. - `null-descriptor`: with `nullDescriptor`, nothing is made (null views stay valid there). - `image-fails`: if the second image cannot be made, the first is destroyed and the views stay null. - And `vk_draw.cpp` no longer writes a storage image as `VK_NULL_HANDLE`. ### Flags and settings None. ## Testing **Tested:** on this branch, Windows, clang++ from llvm-mingw 20261104: `test_dummy_views` passes (fails on main), and the other checks that read the changed code pass: `test_desc_clock`, `test_desc_counts`, `test_drawn_page_map`, `test_prof_symbols`, `test_draw_stream_visibility`, `test_fsr_uniform_ownership`, `test_recording_admission`. `test_drawn_page_map` first failed twice on this branch only in its temp-folder cleanup on Windows (WinError 32: its built `f.exe` was still locked, after every check had passed), then passed in 2 of 2 runs interleaved with main (main: 2 of 2 too). **Built and played:** this commit builds on Windows (llvm-mingw back end) and on Linux (`longshot_vk.so`, without and with AMD FSR 4). Played on Windows, AMD Radeon RX 9070 XT: the game runs normally. **Not tested:** a device without `nullDescriptor`: the RX 9070 XT has it, so in the game this path (and the dummy views) is never reached, and the validation layers were not run on such a device. Linux was built, not run. **Must be tested:** None: the game-free test covers the new path on every GPU and OS. ## Risks **What could break:** only devices without `nullDescriptor` take the new path: three 1x1 images and up to 7 views made once, cleared in the first recording. A shader that reads an image that does not resolve now reads black instead of whatever a null view gave. If an image cannot be made, the views stay null, as on main. **Turning it off:** revert the commit. **Compatibility:** Nothing changes. ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). (no issue fits) - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). (the checks that read the changed code, on this PR, Windows: `test_dummy_views`, `test_desc_clock`, `test_desc_counts`, `test_drawn_page_map`, `test_prof_symbols`, `test_draw_stream_visibility`, `test_fsr_uniform_ownership`, `test_recording_admission`, all pass) - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] A game-free test added for the fix, failing on `main` and passing here. (`tests/test_dummy_views.py`, new) - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. (`tests/test_dummy_views.py`, new, reads `gpu/vk/vk_draw.cpp`) - [x] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. (built on Windows with llvm-mingw and on Linux, `longshot_vk.so` without and with AMD FSR 4; no OS-specific code or paths)
fix(vk): make the dummy image views on devices without nullDescriptor
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 3s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
6c55b3968a
make_dummies() returned without making anything, so without robustness2 nullDescriptor a missing sampled or storage image view was written as VK_NULL_HANDLE (VUID-VkWriteDescriptorSet-descriptorType-02997). It now makes 1x1 black 1D, 2D (cube compatible) and 3D images, clears them in the first recording and makes a view per view type; storage images use the dummy view too. tests/test_dummy_views.py fails on main and passes with the fix.

Assisted-by: GitHub Copilot
Author
Contributor

Hardware named (AMD Radeon RX 9070 XT); Measured: 2 interleaved runs each side (main fails both, this PR passes both); run_all.py box: the checks that read the changed code, all passing; If applicable: tests/ check and builds boxes ticked; Needs other testers: None.

Hardware named (AMD Radeon RX 9070 XT); Measured: 2 interleaved runs each side (main fails both, this PR passes both); run_all.py box: the checks that read the changed code, all passing; If applicable: tests/ check and builds boxes ticked; Needs other testers: None.
jcabarca changed title from WIP: fix(vk): give image descriptors a dummy view when nullDescriptor is off to fix(vk): give image descriptors a dummy view when nullDescriptor is off 2026-11-14 10:37:23 +00:00
Author
Contributor

Description moved to the new PR template. Rebased onto main @ 93344a7c with no code change (same diff). test_dummy_views measured again, 2 interleaved runs each side: main @ 93344a7c fails both, this PR @ 1b5553e0 passes both. The checks that read the changed code pass on this PR.

Description moved to the new PR template. Rebased onto main @ 93344a7c with no code change (same diff). test_dummy_views measured again, 2 interleaved runs each side: main @ 93344a7c fails both, this PR @ 1b5553e0 passes both. The checks that read the changed code pass on this PR.
jcabarca force-pushed fix/vk-dummy-views from 6c55b3968a
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 3s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
to 1b5553e069
Some checks are pending
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 4s
2026-11-15 11:21:03 +00:00
Compare
Author
Contributor

Testing: noted a temp-folder cleanup failure of test_drawn_page_map on Windows (WinError 32) and its two clean reruns.

Testing: noted a temp-folder cleanup failure of test_drawn_page_map on Windows (WinError 32) and its two clean reruns.
HumanBean left a comment

First review, code only. I ran no tests here.

What holds up. On main, without nullDescriptor, both the sampled and the storage path wrote VK_NULL_HANDLE, and the PR fixes that write. The images and views are valid as written: 1x1 1D, 2D cube-compatible with 6 layers, and 3D. Each view type's subresource range fits its image, and CUBE_ARRAY is made only with imageCubeArray. R8G8B8A8_UNORM storage support is mandatory. The images go to GENERAL before the descriptors use them in GENERAL. They are never destroyed, which matches zero_buffer. The creation runs under ParLock in draw_begin_recording, so other recording threads see the views. Devices that have nullDescriptor are untouched: make_dummies returns at once and dummies.view[] stays null, so the sampled fallback at vk_draw.cpp:3987 still binds null there.

Who this reaches. Every Tier 1 and Tier 2 driver I know of reports robustness2 nullDescriptor: NVIDIA, AMD Windows, RADV/Steam Deck, Intel Arc and ANV. So this path runs only on hardware outside the tiers. That makes it low risk, but it also means no one on the team runs it by default.

What's left:

  1. The dummy views don't match every type a shader can declare (inline). Every fallback is an R8G8B8A8_UNORM single-sample colour view, so the following still break:

    • integer textures (d.is_integer);
    • depth-compare textures (d.is_depth), including the Lichii bd0171f7 case at :3943, which is meant to bind nothing;
    • multisampled textures (d.is_multisample);
    • storage images whose format is declared (image_format(d.format): R8/R16/R32 UINT/SINT, R32G32_UINT, R32G32B32A32_UINT), and atomics on them.

    These trade the write-time VUID-02997 for draw-time VUIDs and undefined reads. It is still better than a null view, but it isn't "no invalid descriptor" yet.

  2. "Must be tested: None" doesn't hold. The test stubs every Vulkan call (vkCreateImageView, the barriers, the clear), so no driver has ever created or cleared these images. Before merge, someone needs to run it on a real driver:

    • change dev.null_descriptor = dev.null_descriptor && robust2.nullDescriptor; (vk_main.cpp:563) to = false locally and don't commit it;
    • run on the RX 9070 XT with VK_LAYER_KHRONOS_validation, from the title screen into a gameplay area;
    • report: no VUID-...-02997, the game draws, and any other VUIDs the layers print. That run will also show item 1's mismatches.

    Please put that under Must be tested, or post a test request.

  3. A follow-up, not for this PR: texel buffer descriptors (texel_views, :3880-3899) are still written as VK_NULL_HANDLE when nothing resolves, and that is invalid without nullDescriptor too.

Verdict: comment. The code is correct for the view types it covers and can't reach Tier 1. Before merge it still needs one real-driver run with nullDescriptor forced off, and ideally integer/depth dummies. I made no push: the fixes aren't small, and maintainer edits are off. The branch merges cleanly, so it needs no rebase.

First review, code only. I ran no tests here. **What holds up.** On main, without `nullDescriptor`, both the sampled and the storage path wrote `VK_NULL_HANDLE`, and the PR fixes that write. The images and views are valid as written: 1x1 1D, 2D cube-compatible with 6 layers, and 3D. Each view type's subresource range fits its image, and CUBE_ARRAY is made only with `imageCubeArray`. `R8G8B8A8_UNORM` storage support is mandatory. The images go to `GENERAL` before the descriptors use them in `GENERAL`. They are never destroyed, which matches `zero_buffer`. The creation runs under `ParLock` in `draw_begin_recording`, so other recording threads see the views. Devices that have `nullDescriptor` are untouched: `make_dummies` returns at once and `dummies.view[]` stays null, so the sampled fallback at vk_draw.cpp:3987 still binds null there. **Who this reaches.** Every Tier 1 and Tier 2 driver I know of reports robustness2 `nullDescriptor`: NVIDIA, AMD Windows, RADV/Steam Deck, Intel Arc and ANV. So this path runs only on hardware outside the tiers. That makes it low risk, but it also means no one on the team runs it by default. **What's left:** 1. **The dummy views don't match every type a shader can declare** (inline). Every fallback is an `R8G8B8A8_UNORM` single-sample colour view, so the following still break: - integer textures (`d.is_integer`); - depth-compare textures (`d.is_depth`), including the Lichii bd0171f7 case at :3943, which is meant to bind *nothing*; - multisampled textures (`d.is_multisample`); - storage images whose format is declared (`image_format(d.format)`: R8/R16/R32 UINT/SINT, R32G32_UINT, R32G32B32A32_UINT), and atomics on them. These trade the write-time VUID-02997 for draw-time VUIDs and undefined reads. It is still better than a null view, but it isn't "no invalid descriptor" yet. 2. **"Must be tested: None" doesn't hold.** The test stubs every Vulkan call (`vkCreateImageView`, the barriers, the clear), so no driver has ever created or cleared these images. Before merge, someone needs to run it on a real driver: - change `dev.null_descriptor = dev.null_descriptor && robust2.nullDescriptor;` (vk_main.cpp:563) to `= false` locally and don't commit it; - run on the RX 9070 XT with `VK_LAYER_KHRONOS_validation`, from the title screen into a gameplay area; - report: no VUID-...-02997, the game draws, and any other VUIDs the layers print. That run will also show item 1's mismatches. Please put that under **Must be tested**, or post a test request. 3. A follow-up, not for this PR: texel buffer descriptors (`texel_views`, :3880-3899) are still written as `VK_NULL_HANDLE` when nothing resolves, and that is invalid without `nullDescriptor` too. **Verdict: comment.** The code is correct for the view types it covers and can't reach Tier 1. Before merge it still needs one real-driver run with `nullDescriptor` forced off, and ideally integer/depth dummies. I made no push: the fixes aren't small, and maintainer edits are off. The branch merges cleanly, so it needs no rebase.
@ -4021,3 +4021,3 @@
if (view && tex && d.is_written && (dump_on() || probe_on())) dump_written().push_back({tex, level});
if (dump_on()) dump_input(d.is_written ? 'W' : 'R', (uint32_t)out.imgs.size(), handle, view ? tex : nullptr);
if (!view && !dev.null_descriptor) view = VK_NULL_HANDLE;
if (!view && !dev.null_descriptor) view = dummies.view[(int)vt];
Owner

Storage images declare a format: image_format(d.format) is R8/R16/R32 UINT/SINT, R32G32_UINT or R32G32B32A32_UINT, and some programs use atomics on them. An R8G8B8A8_UNORM dummy breaks the numeric-type rule (VUID-vkCmdDraw-format-07753), and atomics on it break VUID-vkCmdDraw-None-02691, because RGBA8_UNORM has no STORAGE_IMAGE_ATOMIC_BIT. Failure case: a compute program does imageAtomicAdd on an r32ui image whose handle doesn't resolve. Without nullDescriptor that atomic now runs on an RGBA8 view, which is undefined, and on some drivers a fault.

Fix: when image_format(d.format) != VK_FORMAT_UNDEFINED, use a dummy of that format. Make them lazily, keyed by (view type, format), under the ParLock already held at :4019. Keep the RGBA8 one for UNDEFINED. R32_UINT can be a view of the existing images if they are created with VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT, since it is the same 32-bit size class.

Storage images declare a format: `image_format(d.format)` is R8/R16/R32 UINT/SINT, R32G32_UINT or R32G32B32A32_UINT, and some programs use atomics on them. An `R8G8B8A8_UNORM` dummy breaks the numeric-type rule (VUID-vkCmdDraw-format-07753), and atomics on it break VUID-vkCmdDraw-None-02691, because RGBA8_UNORM has no `STORAGE_IMAGE_ATOMIC_BIT`. Failure case: a compute program does `imageAtomicAdd` on an r32ui image whose handle doesn't resolve. Without `nullDescriptor` that atomic now runs on an RGBA8 view, which is undefined, and on some drivers a fault. Fix: when `image_format(d.format) != VK_FORMAT_UNDEFINED`, use a dummy of that format. Make them lazily, keyed by (view type, format), under the `ParLock` already held at :4019. Keep the RGBA8 one for `UNDEFINED`. R32_UINT can be a view of the existing images if they are created with `VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT`, since it is the same 32-bit size class.
@ -4963,0 +4971,4 @@
VkImageCreateInfo ci{VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO};
ci.flags = i == 1 ? VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT : 0;
ci.imageType = type[i];
ci.format = VK_FORMAT_R8G8B8A8_UNORM;
Owner

One R8G8B8A8_UNORM single-sample format also feeds the sampled fallback at :3987, so these textures get a view their shader doesn't expect:

  • d.is_integer (isampler/usampler) gets a UNORM view, against VUID-vkCmdDraw-format-07753. The read is undefined.
  • d.is_depth gets a colour view under the compare sampler from sampler_for(..., true). RGBA8 has no SAMPLED_IMAGE_DEPTH_COMPARISON_BIT (VUID-vkCmdDraw-None-06479). It is also the exact case the Lichii bd0171f7 block at :3943 calls vendor-dependent and deliberately binds as nothing. Without nullDescriptor, "nothing" now becomes this view.
  • d.is_multisample gets a 1-sample view for an MS image.

Suggested fix: add VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT and make R8G8B8A8_UINT and _SINT views of the same images. They are the same size class, so this costs no extra memory. For the depth-compare case, add a 1x1 D16_UNORM (or D32_SFLOAT) 2D/cube image; check SAMPLED_IMAGE_DEPTH_COMPARISON_BIT first. Then pick the view at :3987 from d.is_integer / d.is_depth. If MS is rare, a 4-sample 2D one can wait for a follow-up.

One `R8G8B8A8_UNORM` single-sample format also feeds the sampled fallback at :3987, so these textures get a view their shader doesn't expect: - `d.is_integer` (isampler/usampler) gets a UNORM view, against VUID-vkCmdDraw-format-07753. The read is undefined. - `d.is_depth` gets a colour view under the compare sampler from `sampler_for(..., true)`. RGBA8 has no `SAMPLED_IMAGE_DEPTH_COMPARISON_BIT` (VUID-vkCmdDraw-None-06479). It is also the exact case the Lichii bd0171f7 block at :3943 calls vendor-dependent and deliberately binds as nothing. Without `nullDescriptor`, "nothing" now becomes this view. - `d.is_multisample` gets a 1-sample view for an MS image. Suggested fix: add `VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT` and make `R8G8B8A8_UINT` and `_SINT` views of the same images. They are the same size class, so this costs no extra memory. For the depth-compare case, add a 1x1 `D16_UNORM` (or `D32_SFLOAT`) 2D/cube image; check `SAMPLED_IMAGE_DEPTH_COMPARISON_BIT` first. Then pick the view at :3987 from `d.is_integer` / `d.is_depth`. If MS is rare, a 4-sample 2D one can wait for a follow-up.
@ -4963,0 +4984,4 @@
img[j] = VK_NULL_HANDLE, mem[j] = nullptr;
}
static int logged;
if (logged++ < 4) logf("vk: the dummy images (no nullDescriptor): not made");
Owner

Nit: make_dummies runs only once (inside if (!zero_buffer)), so the < 4 cap never triggers. A plain logf is enough. It also means a failure here is never retried: the views stay null for the whole session. That's fine, but say so in the doc comment.

Nit: `make_dummies` runs only once (inside `if (!zero_buffer)`), so the `< 4` cap never triggers. A plain `logf` is enough. It also means a failure here is never retried: the views stay null for the whole session. That's fine, but say so in the doc comment.
@ -4963,0 +5000,4 @@
}
VkDependencyInfo d{VK_STRUCTURE_TYPE_DEPENDENCY_INFO};
d.imageMemoryBarrierCount = 3, d.pImageMemoryBarriers = b;
vkCmdPipelineBarrier2(rec_cmd, &d);
Owner

Minor. The clear goes into whichever recording calls draw_begin_recording first. Parallel segment recordings also call it (vk_replay.cpp:2141). If a recording that begins after this one is submitted before it, its draws read the dummy while it is still UNDEFINED. That is probably fine in practice, because the first recording at start-up is the serial one. Please either note why that holds, or do the clear in its own one-time submission and wait on it before returning. Then the views are ready whichever recording binds them first.

Minor. The clear goes into whichever recording calls `draw_begin_recording` first. Parallel segment recordings also call it (vk_replay.cpp:2141). If a recording that begins after this one is submitted before it, its draws read the dummy while it is still `UNDEFINED`. That is probably fine in practice, because the first recording at start-up is the serial one. Please either note why that holds, or do the clear in its own one-time submission and wait on it before returning. Then the views are ready whichever recording binds them first.
HumanBean deleted branch fix/vk-dummy-views 2026-11-15 18:30:02 +00:00
Some checks are pending
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 4s
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!403
No description provided.