fix(vk): name the view's format in custom border colours of packed 16-bit textures #1232

Open
jcabarca wants to merge 7 commits from jcabarca/Longshot:fix/vk-border-color-format into main
Contributor

Type: fix · Risk: low · Tested on: Windows 11 IoT Enterprise LTSC 24H2 (build 26100.9711), AMD Ryzen 7 9700X (Zen 5: AVX-512, no AVX512-FP16), 16 GB RAM, AMD Radeon RX 9070 XT, AMD Software: Adrenalin Edition 26.10.1 · Needs: none

TL;DR

An RGB565 texture sampled with a custom border colour used a sampler that named no format, which Vulkan forbids for that format, so the colour past the texture edge was undefined. This PR gives those samplers the texture format. A new test fails on main and passes here.

Breakdown

  • Who it helps: players of scenes that sample RGB565 textures with a custom border colour
  • What was wrong: the custom border colour named no format for formats that require one
  • What changes: for the packed 16-bit formats Vulkan names (today only RGB565 reaches them) the sampler names the view format and clamps the colour to 0 to 1
  • What does not change: every other format keeps its sampler as before
  • How it was checked: a game-free test fails on main and passes here, plus four related checks; the game runs normally on the test PC
  • What is still open: a texture with such a border was not looked at in the game
  • Risk: low: an RGB565 view with a custom border colour gets a sampler of its own

Why

A texture in NVN RGB565 (VK_FORMAT_B5G6R5_UNORM_PACK16) sampled with a custom border colour uses a sampler whose custom border colour names no format, which Vulkan forbids for that format (VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04015): the colour seen past the texture's edge is then undefined and can differ between drivers.

How to reproduce

Seen on: not seen in the game: found by reading sampler_make() in gpu/vk/vk_draw.cpp; it happens on any device with custom border colours (customBorderColors and customBorderColorWithoutFormat) whenever the game samples an RGB565 texture with a sampler whose border colour is not transparent black, opaque black or opaque white
Settings and switches: defaults
Steps: game-free: python -I -B tests/test_sampler_admission.py --cxx clang++ --headers <Vulkan-Headers include> with --source pointing at a main checkout (the test from this PR); its new border-format case asks for a sampler for a view of each of the four packed formats and checks the format its custom border colour names
Expected: the custom border colour names the view's format, and its colour is within what that UNORM format holds
Actual: on main the custom border colour names VK_FORMAT_UNDEFINED for every view; the test fails 6 of 153 cases (border-format and border-format-in-range on each of their three routes)

What changed

The sampler now knows the format of the view it samples. For the four packed 16-bit formats VUID 04015 names, its custom border colour names that format (and the colour is clamped to [0, 1], what a UNORM format holds); for every other format it stays VK_FORMAT_UNDEFINED, as before.

  • vk: gpu/vk/vk_draw.cpp:
    • border_format(VkFormat) (new): returns the view's format for B4G4R4A4_UNORM_PACK16, B5G6R5_UNORM_PACK16, A1B5G5R5_UNORM_PACK16_KHR (the alias named since Vulkan-Headers 1.3.246, so older distro headers build too) and B5G5R5A1_UNORM_PACK16, else VK_FORMAT_UNDEFINED. Today only B5G6R5 reaches it (NVN RGB565); the other three are listed because 04015 names them.
    • sampler_make(id, compare, one_level, view_format) and sampler_for(id, compare, one_level, view_format) take the view's format. sampler_make() mixes the border format into its cache key, sets VkSamplerCustomBorderColorCreateInfoEXT::format to it and clamps the colour when it is set; sampler_for()'s per-thread table keeps the border format in each entry, so a sampler made for one view format is not handed to a view of another.
    • SamplerInfo (the sampler book's key) records the custom border colour's format (19 to 20 words, still without padding).
    • texture_view_of() gains a format_out argument; HandleHit keeps the view's format, so a cached hit returns it too.
    • build_descriptors() passes each texture's view format to sampler_for() (repeated table entries reuse it; dummy views pass VK_FORMAT_UNDEFINED).
  • tests: tests/sampler_admission_test.cpp and tests/test_sampler_admission.py: a border-format case on the three routes (by id, sampler_make() directly, the cache off) with a colour past [0, 1], and a border-format-in-range case with the colour {0.25, 0.5, 0.75, 1}, which every format holds, so only the format tells the samplers apart (it fails if sampler_info() stops recording border_format); the fixture records the format each custom border colour names.

The bug, step by step:

  1. vk_formats.cpp maps NVN_FORMAT_RGB565 to VK_FORMAT_B5G6R5_UNORM_PACK16, one of the four formats 04015 names (NVN_FORMAT_RGB5 and RGB5A1 map to A1R5G5B5_UNORM_PACK16, which it does not name).
  2. vk_main.cpp turns custom border colours on only with customBorderColorWithoutFormat (dev.custom_border_color).
  3. For a border colour that is not one of the three standard ones, sampler_make() sets VK_BORDER_COLOR_FLOAT_CUSTOM_EXT with bc.format = VK_FORMAT_UNDEFINED.
  4. build_descriptors() pairs that sampler with whatever view the handle names (sampler_for((int)(handle >> 20), d.is_depth, tex && tex->levels <= 1)), including views of the formats in step 1. Every condition of 04015 holds.

The rules:

  • VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04015: "If the sampler is used to sample an image view of VK_FORMAT_B4G4R4A4_UNORM_PACK16, VK_FORMAT_B5G6R5_UNORM_PACK16, VK_FORMAT_A1B5G5R5_UNORM_PACK16, or VK_FORMAT_B5G5R5A1_UNORM_PACK16 format then format must not be VK_FORMAT_UNDEFINED". Main breaks it; this PR names the format for those four.
  • VUID-VkSamplerCreateInfo-borderColor-04442: "If borderColor is one of VK_BORDER_COLOR_FLOAT_CUSTOM_EXT or VK_BORDER_COLOR_INT_CUSTOM_EXT, and VkSamplerCustomBorderColorCreateInfoEXT::format is not VK_FORMAT_UNDEFINED, VkSamplerCustomBorderColorCreateInfoEXT::customBorderColor must be within the range of values representable in format". The colour is clamped to [0, 1] when a format is named.
  • VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-07605: "If format is not VK_FORMAT_UNDEFINED and format is not a depth/stencil format then the VkSamplerCreateInfo::borderColor type must match the sampled type of the provided format, as shown in the SPIR-V Type column of the Interpretation of Numeric Format table". The four formats are UNORM (float) and the border colour is VK_BORDER_COLOR_FLOAT_CUSTOM_EXT.
  • VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04014: "If the customBorderColorWithoutFormat feature is not enabled then format must not be VK_FORMAT_UNDEFINED". Unchanged: the feature is required for custom border colours, so VK_FORMAT_UNDEFINED stays valid for every other view.

Before:

    else if (dev.custom_border_color) {
        ci.borderColor = VK_BORDER_COLOR_FLOAT_CUSTOM_EXT;
        std::memcpy(bc.customBorderColor.float32, p.border, 16);
        bc.format = VK_FORMAT_UNDEFINED;
        ci.pNext = &bc;

After:

    else if (dev.custom_border_color) {
        ci.borderColor = VK_BORDER_COLOR_FLOAT_CUSTOM_EXT;
        std::memcpy(bc.customBorderColor.float32, p.border, 16);
        bc.format = bfmt;   // (VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04015)
        if (bfmt != VK_FORMAT_UNDEFINED)   // (VUID-VkSamplerCreateInfo-borderColor-04442: within what the UNORM format holds)
            for (float& c : bc.customBorderColor.float32) c = c > 0.0f ? std::min(c, 1.0f) : 0.0f;
        ci.pNext = &bc;

Measurements

Verdict: it fixes the bug: tests/test_sampler_admission.py fails on main and passes with this PR, in both interleaved runs (after the review: 6 of 153 fail on main, 153 of 153 pass here). Cost: the border format is part of every sampler's key, so an RGB565 view with a custom border colour gets a sampler of its own (one more per custom border colour that meets RGB565); every other view keeps the samplers it had. In the game: 84.35 fps median with this PR against 84.2 fps on main, within the spread between runs (see In the game below).

Hardware: Windows 11 IoT Enterprise LTSC 24H2 (build 26100.9711), AMD Ryzen 7 9700X (Zen 5: AVX-512, no AVX512-FP16), 16 GB RAM, AMD Radeon RX 9070 XT, AMD Software: Adrenalin Edition 26.10.1; the test itself is game-free (it compiles a cut-out of the source with clang++ from llvm-mingw and runs it on the CPU); Python 3.12
Scene: none, game-free
Method: tests/test_sampler_admission.py from this PR with --source set to each side's checkout, 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 -B tests/test_sampler_admission.py --cxx clang++ --headers <Vulkan-Headers include> --source <checkout> for each side

Before: main @ 9ea65c7b After: this PR @ e8f4d3c5
tests/test_sampler_admission.py, run 1 fails (6 of 153) passes (153 of 153)
tests/test_sampler_admission.py, run 2 fails (6 of 153) passes (153 of 153)
Median fails passes
run 1, main @ 9ea65c7b: 6 of 153 fail: border-format and border-format-in-range on the id, make and cache-off routes
run 1, this PR @ e8f4d3c5: 153 of 153 pass
run 2, main @ 9ea65c7b: 6 of 153 fail: border-format and border-format-in-range on the id, make and cache-off routes
run 2, this PR @ e8f4d3c5: 153 of 153 pass

What the test checks: for a view of each of the four packed formats, the custom border colour names that format and its colour {1.5, -0.5, 0.75, 1} becomes {1, 0, 0.75, 1}; for any other view it names VK_FORMAT_UNDEFINED and keeps the colour; a sampler made for one view format is not returned for a view of another. The border-format-in-range case (added after the review) uses a colour every format holds and checks that an RGB565 view still gets its own sampler naming that format.

In the game

Hardware: Windows 11 IoT Enterprise LTSC 24H2 (build 26100.9711), AMD Ryzen 7 9700X (Zen 5: AVX-512, no AVX512-FP16), 16 GB RAM, AMD Radeon RX 9070 XT, AMD Software: Adrenalin Edition 26.10.1
Scene: standing still for 2 minutes at the same spot after loading the same save, 2560x1440, the game's own upscaler at 100%, uncapped, V-Sync off, frame generation off, the same options file on both sides
Method: both DLLs built on the same PC with RX_MARCH=x86-64-v3 from main @ 9ea65c7b (Before) and main with this PR merged @ e8f4d3c5 (After); each side in one block (main first, then this PR), each block a warm-up run that builds that DLL's own shader cache, then 2 runs; the fps of a run is the median of the last 60 vk: N presents, X fps lines of longshot_log.txt, its range the lowest and highest of those 60; the shader start-up time is the vk: start-up: the shaders took line
How to reproduce: build both sides with RX_MARCH=x86-64-v3, play the same save the same way on each, and read those lines from longshot_log.txt

Before: main @ 9ea65c7b After: this PR @ e8f4d3c5
Warm-up, shaders at start-up 474.8 s (empty cache) 20.4 s
Run 1, fps (range) 84.1 (76.3-84.8) 84.4 (77.5-85.3)
Run 2, fps (range) 84.3 (75.3-85.1) 84.3 (83.6-84.9)
Median, fps 84.2 84.35
Run 1, shaders at start-up 21.3 s 21.1 s
Run 2, shaders at start-up 20.4 s 20.4 s
main @ 9ea65c7b warm-up: vk: start-up: the shaders took 474.8 s
main @ 9ea65c7b run 1:   vk: start-up: the shaders took 21.3 s
main @ 9ea65c7b run 2:   vk: start-up: the shaders took 20.4 s
this PR warm-up:         vk: start-up: the shaders took 20.4 s
this PR run 1:           vk: start-up: the shaders took 21.1 s
this PR run 2:           vk: start-up: the shaders took 20.4 s

The earlier game runs (main @ 2f1c0c9c 88.35 fps against this PR before the review @ 4c496b96 89.1 fps) are in docs/tested/2026-11-19-border-color-jcabarca-run01.md; these runs are in docs/tested/2026-11-19-border-color-jcabarca-run02.md.

Flags and settings

None.

Testing

Tested: on this branch, Windows, Python 3.12, clang++ from llvm-mingw: test_sampler_admission passes (fails on main), and the other checks that read the changed code pass: test_flat_map, test_handle_lookup, test_prof_symbols, test_taau_env_lookup (its seven cases pass; on Windows it then fails to delete its temporary fixture.exe, the same on main).

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 11 IoT Enterprise LTSC 24H2 (build 26100.9711), AMD Ryzen 7 9700X (Zen 5: AVX-512, no AVX512-FP16), 16 GB RAM, AMD Radeon RX 9070 XT, AMD Software: Adrenalin Edition 26.10.1: the game runs normally.

Not tested: a packed 16-bit texture sampled past its edge with a custom border colour, looked at in the game (which textures and samplers the game pairs that way was not traced). Linux was built, not run.

Must be tested: None: the change is the same on every GPU and OS, and the game-free test covers it.

Risks

What could break: an RGB565 view with a custom border colour now gets its own sampler (more sampler keys: at most one more sampler per custom border colour per packed format met). VUID-VkSamplerCreateInfo-None-04012 limits how many samplers with custom border colours a device can have (maxCustomBorderColorSamplers); main does not check that limit either, and this PR does not change that. A border colour outside [0, 1] on those views now reads clamped, which is all the format can hold.

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_sampler_admission, test_flat_map, test_handle_lookup, test_prof_symbols, test_taau_env_lookup; the last one's cleanup error on Windows also happens on main)
  • 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.
  • Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what wasn't is in Not tested.
  • Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and named in Measurements or Risks.

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. (the border-format case of tests/test_sampler_admission.py)
  • A check under tests/ that reads changed source updated in this PR, not weakened. (tests/sampler_admission_test.cpp follows the new arguments; no case removed)
  • 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)
  • A file in docs/tested/ for each new measured run (format in docs/tested-configurations.md). (docs/tested/2026-11-19-border-color-jcabarca-run01.md and docs/tested/2026-11-19-border-color-jcabarca-run02.md; tests/test_tested_configurations.py passes its fragment checks)
**Type:** fix · **Risk:** low · **Tested on:** Windows 11 IoT Enterprise LTSC 24H2 (build 26100.9711), AMD Ryzen 7 9700X (Zen 5: AVX-512, no AVX512-FP16), 16 GB RAM, AMD Radeon RX 9070 XT, AMD Software: Adrenalin Edition 26.10.1 · **Needs:** none ## TL;DR An RGB565 texture sampled with a custom border colour used a sampler that named no format, which Vulkan forbids for that format, so the colour past the texture edge was undefined. This PR gives those samplers the texture format. A new test fails on main and passes here. ## Breakdown - **Who it helps:** players of scenes that sample RGB565 textures with a custom border colour - **What was wrong:** the custom border colour named no format for formats that require one - **What changes:** for the packed 16-bit formats Vulkan names (today only RGB565 reaches them) the sampler names the view format and clamps the colour to 0 to 1 - **What does not change:** every other format keeps its sampler as before - **How it was checked:** a game-free test fails on main and passes here, plus four related checks; the game runs normally on the test PC - **What is still open:** a texture with such a border was not looked at in the game - **Risk:** low: an RGB565 view with a custom border colour gets a sampler of its own ## Why A texture in NVN RGB565 (`VK_FORMAT_B5G6R5_UNORM_PACK16`) sampled with a custom border colour uses a sampler whose custom border colour names no format, which Vulkan forbids for that format (VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04015): the colour seen past the texture's edge is then undefined and can differ between drivers. ## How to reproduce **Seen on:** not seen in the game: found by reading `sampler_make()` in `gpu/vk/vk_draw.cpp`; it happens on any device with custom border colours (`customBorderColors` and `customBorderColorWithoutFormat`) whenever the game samples an RGB565 texture with a sampler whose border colour is not transparent black, opaque black or opaque white **Settings and switches:** defaults **Steps:** game-free: `python -I -B tests/test_sampler_admission.py --cxx clang++ --headers <Vulkan-Headers include>` with `--source` pointing at a main checkout (the test from this PR); its new `border-format` case asks for a sampler for a view of each of the four packed formats and checks the format its custom border colour names **Expected:** the custom border colour names the view's format, and its colour is within what that UNORM format holds **Actual:** on main the custom border colour names `VK_FORMAT_UNDEFINED` for every view; the test fails 6 of 153 cases (`border-format` and `border-format-in-range` on each of their three routes) ## What changed The sampler now knows the format of the view it samples. For the four packed 16-bit formats VUID 04015 names, its custom border colour names that format (and the colour is clamped to [0, 1], what a UNORM format holds); for every other format it stays `VK_FORMAT_UNDEFINED`, as before. - vk: `gpu/vk/vk_draw.cpp`: - `border_format(VkFormat)` (new): returns the view's format for `B4G4R4A4_UNORM_PACK16`, `B5G6R5_UNORM_PACK16`, `A1B5G5R5_UNORM_PACK16_KHR` (the alias named since Vulkan-Headers 1.3.246, so older distro headers build too) and `B5G5R5A1_UNORM_PACK16`, else `VK_FORMAT_UNDEFINED`. Today only `B5G6R5` reaches it (NVN RGB565); the other three are listed because 04015 names them. - `sampler_make(id, compare, one_level, view_format)` and `sampler_for(id, compare, one_level, view_format)` take the view's format. `sampler_make()` mixes the border format into its cache key, sets `VkSamplerCustomBorderColorCreateInfoEXT::format` to it and clamps the colour when it is set; `sampler_for()`'s per-thread table keeps the border format in each entry, so a sampler made for one view format is not handed to a view of another. - `SamplerInfo` (the sampler book's key) records the custom border colour's format (19 to 20 words, still without padding). - `texture_view_of()` gains a `format_out` argument; `HandleHit` keeps the view's format, so a cached hit returns it too. - `build_descriptors()` passes each texture's view format to `sampler_for()` (repeated table entries reuse it; dummy views pass `VK_FORMAT_UNDEFINED`). - tests: `tests/sampler_admission_test.cpp` and `tests/test_sampler_admission.py`: a `border-format` case on the three routes (by id, `sampler_make()` directly, the cache off) with a colour past [0, 1], and a `border-format-in-range` case with the colour {0.25, 0.5, 0.75, 1}, which every format holds, so only the format tells the samplers apart (it fails if `sampler_info()` stops recording `border_format`); the fixture records the format each custom border colour names. The bug, step by step: 1. `vk_formats.cpp` maps `NVN_FORMAT_RGB565` to `VK_FORMAT_B5G6R5_UNORM_PACK16`, one of the four formats 04015 names (`NVN_FORMAT_RGB5` and `RGB5A1` map to `A1R5G5B5_UNORM_PACK16`, which it does not name). 2. `vk_main.cpp` turns custom border colours on only with `customBorderColorWithoutFormat` (`dev.custom_border_color`). 3. For a border colour that is not one of the three standard ones, `sampler_make()` sets `VK_BORDER_COLOR_FLOAT_CUSTOM_EXT` with `bc.format = VK_FORMAT_UNDEFINED`. 4. `build_descriptors()` pairs that sampler with whatever view the handle names (`sampler_for((int)(handle >> 20), d.is_depth, tex && tex->levels <= 1)`), including views of the formats in step 1. Every condition of 04015 holds. The rules: - VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04015: "If the sampler is used to sample an image view of VK_FORMAT_B4G4R4A4_UNORM_PACK16, VK_FORMAT_B5G6R5_UNORM_PACK16, VK_FORMAT_A1B5G5R5_UNORM_PACK16, or VK_FORMAT_B5G5R5A1_UNORM_PACK16 format then format must not be VK_FORMAT_UNDEFINED". Main breaks it; this PR names the format for those four. - VUID-VkSamplerCreateInfo-borderColor-04442: "If borderColor is one of VK_BORDER_COLOR_FLOAT_CUSTOM_EXT or VK_BORDER_COLOR_INT_CUSTOM_EXT, and VkSamplerCustomBorderColorCreateInfoEXT::format is not VK_FORMAT_UNDEFINED, VkSamplerCustomBorderColorCreateInfoEXT::customBorderColor must be within the range of values representable in format". The colour is clamped to [0, 1] when a format is named. - VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-07605: "If format is not VK_FORMAT_UNDEFINED and format is not a depth/stencil format then the VkSamplerCreateInfo::borderColor type must match the sampled type of the provided format, as shown in the SPIR-V Type column of the Interpretation of Numeric Format table". The four formats are UNORM (float) and the border colour is `VK_BORDER_COLOR_FLOAT_CUSTOM_EXT`. - VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04014: "If the customBorderColorWithoutFormat feature is not enabled then format must not be VK_FORMAT_UNDEFINED". Unchanged: the feature is required for custom border colours, so `VK_FORMAT_UNDEFINED` stays valid for every other view. Before: ```cpp else if (dev.custom_border_color) { ci.borderColor = VK_BORDER_COLOR_FLOAT_CUSTOM_EXT; std::memcpy(bc.customBorderColor.float32, p.border, 16); bc.format = VK_FORMAT_UNDEFINED; ci.pNext = &bc; ``` After: ```cpp else if (dev.custom_border_color) { ci.borderColor = VK_BORDER_COLOR_FLOAT_CUSTOM_EXT; std::memcpy(bc.customBorderColor.float32, p.border, 16); bc.format = bfmt; // (VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04015) if (bfmt != VK_FORMAT_UNDEFINED) // (VUID-VkSamplerCreateInfo-borderColor-04442: within what the UNORM format holds) for (float& c : bc.customBorderColor.float32) c = c > 0.0f ? std::min(c, 1.0f) : 0.0f; ci.pNext = &bc; ``` ## Measurements **Verdict:** it fixes the bug: `tests/test_sampler_admission.py` fails on main and passes with this PR, in both interleaved runs (after the review: 6 of 153 fail on main, 153 of 153 pass here). Cost: the border format is part of every sampler's key, so an RGB565 view with a custom border colour gets a sampler of its own (one more per custom border colour that meets RGB565); every other view keeps the samplers it had. In the game: 84.35 fps median with this PR against 84.2 fps on main, within the spread between runs (see In the game below). Hardware: Windows 11 IoT Enterprise LTSC 24H2 (build 26100.9711), AMD Ryzen 7 9700X (Zen 5: AVX-512, no AVX512-FP16), 16 GB RAM, AMD Radeon RX 9070 XT, AMD Software: Adrenalin Edition 26.10.1; the test itself is game-free (it compiles a cut-out of the source with clang++ from llvm-mingw and runs it on the CPU); Python 3.12 Scene: none, game-free Method: `tests/test_sampler_admission.py` from this PR with `--source` set to each side's checkout, 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 -B tests/test_sampler_admission.py --cxx clang++ --headers <Vulkan-Headers include> --source <checkout>` for each side | | Before: main @ 9ea65c7b | After: this PR @ e8f4d3c5 | |---|---|---| | `tests/test_sampler_admission.py`, run 1 | fails (6 of 153) | passes (153 of 153) | | `tests/test_sampler_admission.py`, run 2 | fails (6 of 153) | passes (153 of 153) | | Median | fails | passes | ``` run 1, main @ 9ea65c7b: 6 of 153 fail: border-format and border-format-in-range on the id, make and cache-off routes run 1, this PR @ e8f4d3c5: 153 of 153 pass run 2, main @ 9ea65c7b: 6 of 153 fail: border-format and border-format-in-range on the id, make and cache-off routes run 2, this PR @ e8f4d3c5: 153 of 153 pass ``` What the test checks: for a view of each of the four packed formats, the custom border colour names that format and its colour {1.5, -0.5, 0.75, 1} becomes {1, 0, 0.75, 1}; for any other view it names `VK_FORMAT_UNDEFINED` and keeps the colour; a sampler made for one view format is not returned for a view of another. The `border-format-in-range` case (added after the review) uses a colour every format holds and checks that an RGB565 view still gets its own sampler naming that format. ### In the game Hardware: Windows 11 IoT Enterprise LTSC 24H2 (build 26100.9711), AMD Ryzen 7 9700X (Zen 5: AVX-512, no AVX512-FP16), 16 GB RAM, AMD Radeon RX 9070 XT, AMD Software: Adrenalin Edition 26.10.1 Scene: standing still for 2 minutes at the same spot after loading the same save, 2560x1440, the game's own upscaler at 100%, uncapped, V-Sync off, frame generation off, the same options file on both sides Method: both DLLs built on the same PC with `RX_MARCH=x86-64-v3` from main @ 9ea65c7b (Before) and main with this PR merged @ e8f4d3c5 (After); each side in one block (main first, then this PR), each block a warm-up run that builds that DLL's own shader cache, then 2 runs; the fps of a run is the median of the last 60 `vk: N presents, X fps` lines of `longshot_log.txt`, its range the lowest and highest of those 60; the shader start-up time is the `vk: start-up: the shaders took` line How to reproduce: build both sides with `RX_MARCH=x86-64-v3`, play the same save the same way on each, and read those lines from `longshot_log.txt` | | Before: main @ 9ea65c7b | After: this PR @ e8f4d3c5 | |---|---|---| | Warm-up, shaders at start-up | 474.8 s (empty cache) | 20.4 s | | Run 1, fps (range) | 84.1 (76.3-84.8) | 84.4 (77.5-85.3) | | Run 2, fps (range) | 84.3 (75.3-85.1) | 84.3 (83.6-84.9) | | Median, fps | 84.2 | 84.35 | | Run 1, shaders at start-up | 21.3 s | 21.1 s | | Run 2, shaders at start-up | 20.4 s | 20.4 s | ``` main @ 9ea65c7b warm-up: vk: start-up: the shaders took 474.8 s main @ 9ea65c7b run 1: vk: start-up: the shaders took 21.3 s main @ 9ea65c7b run 2: vk: start-up: the shaders took 20.4 s this PR warm-up: vk: start-up: the shaders took 20.4 s this PR run 1: vk: start-up: the shaders took 21.1 s this PR run 2: vk: start-up: the shaders took 20.4 s ``` The earlier game runs (main @ 2f1c0c9c 88.35 fps against this PR before the review @ 4c496b96 89.1 fps) are in `docs/tested/2026-11-19-border-color-jcabarca-run01.md`; these runs are in `docs/tested/2026-11-19-border-color-jcabarca-run02.md`. ### Flags and settings None. ## Testing **Tested:** on this branch, Windows, Python 3.12, clang++ from llvm-mingw: `test_sampler_admission` passes (fails on main), and the other checks that read the changed code pass: `test_flat_map`, `test_handle_lookup`, `test_prof_symbols`, `test_taau_env_lookup` (its seven cases pass; on Windows it then fails to delete its temporary `fixture.exe`, the same on main). **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 11 IoT Enterprise LTSC 24H2 (build 26100.9711), AMD Ryzen 7 9700X (Zen 5: AVX-512, no AVX512-FP16), 16 GB RAM, AMD Radeon RX 9070 XT, AMD Software: Adrenalin Edition 26.10.1: the game runs normally. **Not tested:** a packed 16-bit texture sampled past its edge with a custom border colour, looked at in the game (which textures and samplers the game pairs that way was not traced). Linux was built, not run. **Must be tested:** None: the change is the same on every GPU and OS, and the game-free test covers it. ## Risks **What could break:** an RGB565 view with a custom border colour now gets its own sampler (more sampler keys: at most one more sampler per custom border colour per packed format met). `VUID-VkSamplerCreateInfo-None-04012` limits how many samplers with custom border colours a device can have (`maxCustomBorderColorSamplers`); main does not check that limit either, and this PR does not change that. A border colour outside [0, 1] on those views now reads clamped, which is all the format can hold. **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_sampler_admission`, `test_flat_map`, `test_handle_lookup`, `test_prof_symbols`, `test_taau_env_lookup`; the last one's cleanup error on Windows also happens on `main`) - [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. - [x] Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what wasn't is in Not tested. - [x] Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and named in Measurements or Risks. ### 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. (the `border-format` case of `tests/test_sampler_admission.py`) - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. (`tests/sampler_admission_test.cpp` follows the new arguments; no case removed) - [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) - [x] A file in `docs/tested/` for each new measured run (format in `docs/tested-configurations.md`). (`docs/tested/2026-11-19-border-color-jcabarca-run01.md` and `docs/tested/2026-11-19-border-color-jcabarca-run02.md`; `tests/test_tested_configurations.py` passes its fragment checks)
Author
Contributor

Tested in game: Played on Windows, AMD Radeon RX 9070 XT: the game runs normally.

Tested in game: Played on Windows, AMD Radeon RX 9070 XT: the game runs normally.
jcabarca changed title from WIP: fix(vk): name the view's format in custom border colours of packed 16-bit textures to fix(vk): name the view's format in custom border colours of packed 16-bit textures 2026-11-16 21:09:06 +00:00
TrashPanda approved these changes 2026-11-17 00:56:07 +00:00
Dismissed
TrashPanda left a comment

A packed 16-bit texture with a custom border colour now names that texture's format on the sampler. I read head e279a9b2. Approved.

Vulkan forbids a custom border colour with no format when the view is one of B4G4R4A4, B5G6R5, A1B5G5R5 or B5G5R5A1. The sampler was built with VK_FORMAT_UNDEFINED for every view. border_format returns the view's format for those four and VK_FORMAT_UNDEFINED for the rest, which customBorderColorWithoutFormat still allows. The colour is clamped to [0, 1] only when a format is named. The sampler cache, the per-thread table and the sampler book all keep that format, so a sampler made for one of those views is not handed to another.

The view's format comes back from texture_view on the thread that made it, and a cached handle keeps the format from when the view was made. A missing view still asks for no format. The check compiles sampler_make and records the format the custom border colour names: each of the four formats, the clamp of {1.5, -0.5, 0.75, 1} to {1, 0, 0.75, 1}, and an ordinary view left undefined. It fails on main. The Windows play on an RX 9070 XT did not look at a packed texture past its edge.

A packed 16-bit texture with a custom border colour now names that texture's format on the sampler. I read head `e279a9b2`. Approved. Vulkan forbids a custom border colour with no format when the view is one of `B4G4R4A4`, `B5G6R5`, `A1B5G5R5` or `B5G5R5A1`. The sampler was built with `VK_FORMAT_UNDEFINED` for every view. `border_format` returns the view's format for those four and `VK_FORMAT_UNDEFINED` for the rest, which `customBorderColorWithoutFormat` still allows. The colour is clamped to [0, 1] only when a format is named. The sampler cache, the per-thread table and the sampler book all keep that format, so a sampler made for one of those views is not handed to another. The view's format comes back from `texture_view` on the thread that made it, and a cached handle keeps the format from when the view was made. A missing view still asks for no format. The check compiles `sampler_make` and records the format the custom border colour names: each of the four formats, the clamp of {1.5, -0.5, 0.75, 1} to {1, 0, 0.75, 1}, and an ordinary view left undefined. It fails on main. The Windows play on an RX 9070 XT did not look at a packed texture past its edge.
Owner

Brought up to the ready-for-review standard (#1454): the checklist's Everyone list has two new boxes, added here from what this PR's description and comments show (please check they match what you know).

  • Tested on my own PC: ticked: Testing's Tested and the author's comment: played in game on Windows, AMD Radeon RX 9070 XT.
  • Nothing gets worse that I know of: not ticked: Risks names up to four extra samplers against a device limit that main does not check, and this is unmeasured. Measure that cost and state it in Risks, then tick it.
Brought up to the [ready-for-review standard](https://git.magicbean.dev/MagicBeanDev/Longshot/src/branch/main/CONTRIBUTING.md#ready-for-review-out-of-wip) (#1454): the checklist's Everyone list has two new boxes, added here from what this PR's description and comments show (please check they match what you know). - *Tested on my own PC*: ticked: Testing's Tested and the author's comment: played in game on Windows, AMD Radeon RX 9070 XT. - *Nothing gets worse that I know of*: not ticked: Risks names up to four extra samplers against a device limit that main does not check, and this is unmeasured. Measure that cost and state it in Risks, then tick it.
jcabarca force-pushed fix/vk-border-color-format from e279a9b28b
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Failing after 7s
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
Guide screenshots / Guide images and local UI source review (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 ee253de13b
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 4s
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
Guide screenshots / Guide images and local UI source review (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
Website / Website on Cloudflare (pull_request) Has been cancelled
2026-11-17 21:31:54 +00:00
Compare
jcabarca dismissed TrashPanda's review 2026-11-17 21:31:54 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

Author
Contributor

Rebased onto main @ c14641a6. Main added a one_level parameter to sampler_make() and sampler_for(), so the view format is now their fourth parameter (gpu/vk/vk_draw.cpp, tests/sampler_admission_test.cpp, tests/test_sampler_admission.py); the change itself is the same. The test now has 150 cases. Run again, interleaved main, PR, main, PR: main fails 3 of 150 (border-format on the id, make and cache-off routes) and this PR passes 150 of 150, both times. Measurements updated; the description also gets the two new Everyone boxes.

Rebased onto main @ c14641a6. Main added a one_level parameter to sampler_make() and sampler_for(), so the view format is now their fourth parameter (gpu/vk/vk_draw.cpp, tests/sampler_admission_test.cpp, tests/test_sampler_admission.py); the change itself is the same. The test now has 150 cases. Run again, interleaved main, PR, main, PR: main fails 3 of 150 (border-format on the id, make and cache-off routes) and this PR passes 150 of 150, both times. Measurements updated; the description also gets the two new Everyone boxes.
Author
Contributor

Rebased onto main @ 6fbeca96 to clear the conflict; head 4b237fb1, no change to the fix.

Rebased onto main @ 6fbeca96 to clear the conflict; head 4b237fb1, no change to the fix.
jcabarca force-pushed fix/vk-border-color-format from ee253de13b
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 4s
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
Guide screenshots / Guide images and local UI source review (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
Website / Website on Cloudflare (pull_request) Has been cancelled
to 4b237fb18f
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 4s
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
Guide screenshots / Guide images and local UI source review (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
Website / Website on Cloudflare (pull_request) Has been cancelled
2026-11-18 07:32:54 +00:00
Compare
Author
Contributor

Rebased onto main @ 7daafa7a; the related tests pass on it.

Added cost (read from the code, not measured in a game): sampler_for: a format switch and one more compare per sampled texture; more samplers for 4 packed formats; how often: every draw (about 48000 lookups a frame). On an AMD Radeon RX 9070 XT: yes (all GPUs). The box for nothing getting worse stays unticked until this is measured.

Rebased onto main @ 7daafa7a; the related tests pass on it. Added cost (read from the code, not measured in a game): sampler_for: a format switch and one more compare per sampled texture; more samplers for 4 packed formats; how often: every draw (about 48000 lookups a frame). On an AMD Radeon RX 9070 XT: yes (all GPUs). The box for nothing getting worse stays unticked until this is measured.
jcabarca force-pushed fix/vk-border-color-format from 4b237fb18f
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 4s
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
Guide screenshots / Guide images and local UI source review (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
Website / Website on Cloudflare (pull_request) Has been cancelled
to 51b1bd758a
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 7s
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
Guide screenshots / Guide images and local UI source review (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
Website / Website on Cloudflare (pull_request) Has been cancelled
2026-11-18 08:49:15 +00:00
Compare
Author
Contributor

Measured in the game against main on Windows 11 IoT Enterprise LTSC 24H2 (build 26100.9711), AMD Ryzen 7 9700X (Zen 5: AVX-512, no AVX512-FP16), 16 GB RAM, AMD Radeon RX 9070 XT, AMD Software: Adrenalin Edition 26.10.1 (both DLLs built with RX_MARCH=x86-64-v3, one block per side, a warm-up and 2 runs each): 89.1 fps median with this PR against 88.35 fps on main, within the spread between runs, and no Vulkan validation errors. The numbers are in Measurements, In the game, and the run is recorded in docs/tested/2026-11-19-border-color-jcabarca-run01.md.

Measured in the game against main on Windows 11 IoT Enterprise LTSC 24H2 (build 26100.9711), AMD Ryzen 7 9700X (Zen 5: AVX-512, no AVX512-FP16), 16 GB RAM, AMD Radeon RX 9070 XT, AMD Software: Adrenalin Edition 26.10.1 (both DLLs built with RX_MARCH=x86-64-v3, one block per side, a warm-up and 2 runs each): 89.1 fps median with this PR against 88.35 fps on main, within the spread between runs, and no Vulkan validation errors. The numbers are in Measurements, In the game, and the run is recorded in docs/tested/2026-11-19-border-color-jcabarca-run01.md.
jcabarca force-pushed fix/vk-border-color-format from 51b1bd758a
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 7s
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
Guide screenshots / Guide images and local UI source review (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
Website / Website on Cloudflare (pull_request) Has been cancelled
to 7ddf1dcb49
Some checks failed
PR description / Description follows the template (pull_request_target) Has been cancelled
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
Guide screenshots / Guide images and local UI source review (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
Website / Website on Cloudflare (pull_request) Has been cancelled
2026-11-19 06:14:07 +00:00
Compare
Merge branch 'main' into fix/vk-border-color-format
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 7s
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
Guide screenshots / Guide images and local UI source review (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
Website / Website on Cloudflare (pull_request) Has been cancelled
7dc8516586
HumanBean left a comment

I read head 7dc85165 (the fix 4c496b96 and its test d833035c, merged with main). The fix is right and kept small. The sampler names the view's format only inside the dev.custom_border_color branch, and vk_main.cpp:673 already requires both customBorderColors and customBorderColorWithoutFormat for that, so a device without the extension or its features keeps the transparent-black fallback it has on main. The view's format comes from texture_view(), which sets it before every return that gives a view. A cached HandleHit, a repeated table entry and the dummy view all carry it, or VK_FORMAT_UNDEFINED, correctly.

Should be fixed before merge

  • gpu/vk/vk_draw.cpp:3260 (and tests/sampler_admission_test.cpp:431): VK_FORMAT_A1B5G5R5_UNORM_PACK16 without a suffix is the core Vulkan 1.4 name. As far as I know, Vulkan-Headers before 1.4.303 have only VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR (from 1.3.246, KHR_maintenance5), and older ones have neither. A Linux build with distro headers under /usr, which docs/development.md supports, stops with an undeclared identifier on those headers (Ubuntu 24.04 ships 1.3.275). The rest of gpu/vk keeps to _EXT/_KHR names (VK_INDEX_TYPE_UINT8_EXT, for example), so this would be the first symbol that needs 1.4 headers. No NVN format maps to A1B5G5R5 or to B4G4R4A4 in vk_formats.cpp, so a fix is either static_cast<VkFormat>(1000470000) with a comment naming it, or VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR if 1.3.246 is an acceptable floor. Please check this against the oldest headers the build supports.

Suggestions

  • The test catches the fix's own lines being undone: bc.format = bfmt, the clamp, the key mix in sampler_make() (the make route), and the e.border compare in sampler_for() (the id route). It doesn't catch sampler_info()'s new i.border_format (vk_draw.cpp:3177) being dropped. The case's colour {1.5, -0.5, ...} is clamped, so the packed sampler's SamplerInfo already differs from the plain one. With a colour that is already inside [0, 1], book.made would hand the plain sampler (format UNDEFINED) to a packed view, which is the bug again, and no case would notice. A second pass of the loop with custom-border's {0.25, 0.5, 0.75, 1} would cover it. The build_descriptors()/texture_view_of() plumbing isn't modelled at all. It reads right, but that part was checked by reading the code only.
  • The description's step 1 is out of date: NVN_FORMAT_RGB5 maps to VK_FORMAT_A1R5G5B5_UNORM_PACK16 (vk_formats.cpp:129), which the VUID doesn't list. In this game only NVN_FORMAT_RGB565 (B5G6R5) reaches the rule, so "up to four more samplers" is in practice one more per custom border colour.
  • Cost: border_format() is applied to every view, not only to samplers with a custom colour. A sampler without one, sampled with an RGB565 view, gets its own key in mine/book.keys. It still shares its VkSampler through book.made, since its SamplerInfo is the same, so the cache can't grow by more than 5x keys and adds no device samplers. A sampler id bound to RGB565 and to other views in turn now misses sampler_for()'s per-thread entry each time and does a mine lookup. That is small, and the in-game run shows no cost.

Measurements: the game-free test fails 3 of 150 on main and passes 150 of 150 here, in two interleaved runs. That is the evidence a fix needs, and the test fails for the bug's reason. In the game on an RX 9070 XT, Windows: 89.1 fps against 88.35 fps (88.8/89.4 against 88.5/88.2), one block per side, which is within the spread. "No cost" is a fair reading, and no gain is claimed. The packed texture past its edge wasn't looked at in the game, and Linux was built but not run, as Testing says. The change is the same on every GPU, so no other hardware is needed. CI on the head hasn't run yet ("Blocked by required conditions").

I read head `7dc85165` (the fix `4c496b96` and its test `d833035c`, merged with main). The fix is right and kept small. The sampler names the view's format only inside the `dev.custom_border_color` branch, and `vk_main.cpp:673` already requires both `customBorderColors` and `customBorderColorWithoutFormat` for that, so a device without the extension or its features keeps the transparent-black fallback it has on main. The view's format comes from `texture_view()`, which sets it before every return that gives a view. A cached `HandleHit`, a repeated table entry and the dummy view all carry it, or `VK_FORMAT_UNDEFINED`, correctly. **Should be fixed before merge** - `gpu/vk/vk_draw.cpp:3260` (and `tests/sampler_admission_test.cpp:431`): `VK_FORMAT_A1B5G5R5_UNORM_PACK16` without a suffix is the core Vulkan 1.4 name. As far as I know, Vulkan-Headers before 1.4.303 have only `VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR` (from 1.3.246, KHR_maintenance5), and older ones have neither. A Linux build with distro headers under `/usr`, which docs/development.md supports, stops with an undeclared identifier on those headers (Ubuntu 24.04 ships 1.3.275). The rest of `gpu/vk` keeps to `_EXT`/`_KHR` names (`VK_INDEX_TYPE_UINT8_EXT`, for example), so this would be the first symbol that needs 1.4 headers. No NVN format maps to `A1B5G5R5` or to `B4G4R4A4` in `vk_formats.cpp`, so a fix is either `static_cast<VkFormat>(1000470000)` with a comment naming it, or `VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR` if 1.3.246 is an acceptable floor. Please check this against the oldest headers the build supports. **Suggestions** - The test catches the fix's own lines being undone: `bc.format = bfmt`, the clamp, the key mix in `sampler_make()` (the `make` route), and the `e.border` compare in `sampler_for()` (the id route). It doesn't catch `sampler_info()`'s new `i.border_format` (`vk_draw.cpp:3177`) being dropped. The case's colour {1.5, -0.5, ...} is clamped, so the packed sampler's `SamplerInfo` already differs from the plain one. With a colour that is already inside [0, 1], `book.made` would hand the plain sampler (format `UNDEFINED`) to a packed view, which is the bug again, and no case would notice. A second pass of the loop with `custom-border`'s {0.25, 0.5, 0.75, 1} would cover it. The `build_descriptors()`/`texture_view_of()` plumbing isn't modelled at all. It reads right, but that part was checked by reading the code only. - The description's step 1 is out of date: `NVN_FORMAT_RGB5` maps to `VK_FORMAT_A1R5G5B5_UNORM_PACK16` (`vk_formats.cpp:129`), which the VUID doesn't list. In this game only `NVN_FORMAT_RGB565` (`B5G6R5`) reaches the rule, so "up to four more samplers" is in practice one more per custom border colour. - Cost: `border_format()` is applied to every view, not only to samplers with a custom colour. A sampler without one, sampled with an RGB565 view, gets its own key in `mine`/`book.keys`. It still shares its `VkSampler` through `book.made`, since its `SamplerInfo` is the same, so the cache can't grow by more than 5x keys and adds no device samplers. A sampler id bound to RGB565 and to other views in turn now misses `sampler_for()`'s per-thread entry each time and does a `mine` lookup. That is small, and the in-game run shows no cost. Measurements: the game-free test fails 3 of 150 on main and passes 150 of 150 here, in two interleaved runs. That is the evidence a fix needs, and the test fails for the bug's reason. In the game on an RX 9070 XT, Windows: 89.1 fps against 88.35 fps (88.8/89.4 against 88.5/88.2), one block per side, which is within the spread. "No cost" is a fair reading, and no gain is claimed. The packed texture past its edge wasn't looked at in the game, and Linux was built but not run, as Testing says. The change is the same on every GPU, so no other hardware is needed. CI on the head hasn't run yet ("Blocked by required conditions").
@ -3175,0 +3174,4 @@
if (border) std::memcpy(i.custom, bc->customBorderColor.float32, sizeof i.custom);
// (the format whatever the address modes: VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04015 has no
// condition on them, so a sampler without it is not one for a view of those formats)
i.border_format = (uint32_t)bc->format;
Owner

Nothing in border-format catches this line being dropped: the clamped colour already makes the packed sampler's SamplerInfo differ. A pass with an in-range colour (e.g. custom-border's {0.25, 0.5, 0.75, 1}) would show book.made handing back the UNDEFINED-format sampler without it.

Nothing in `border-format` catches this line being dropped: the clamped colour already makes the packed sampler's `SamplerInfo` differ. A pass with an in-range colour (e.g. `custom-border`'s {0.25, 0.5, 0.75, 1}) would show `book.made` handing back the UNDEFINED-format sampler without it.
@ -3251,0 +3257,4 @@
/// customBorderColorWithoutFormat feature (required for custom border colours here) allows
VkFormat border_format(VkFormat view_format) {
switch (view_format) {
case VK_FORMAT_B4G4R4A4_UNORM_PACK16: case VK_FORMAT_B5G6R5_UNORM_PACK16: case VK_FORMAT_A1B5G5R5_UNORM_PACK16:
Owner

VK_FORMAT_A1B5G5R5_UNORM_PACK16 (no suffix) needs Vulkan-Headers 1.4.303 or newer, as far as I know. Older ones have only ..._KHR (1.3.246+) or nothing, so a build with distro headers (Ubuntu 24.04: 1.3.275) fails here. static_cast<VkFormat>(1000470000) with a comment naming it would build everywhere. No NVN format maps to it in vk_formats.cpp today.

`VK_FORMAT_A1B5G5R5_UNORM_PACK16` (no suffix) needs Vulkan-Headers 1.4.303 or newer, as far as I know. Older ones have only `..._KHR` (1.3.246+) or nothing, so a build with distro headers (Ubuntu 24.04: 1.3.275) fails here. `static_cast<VkFormat>(1000470000)` with a comment naming it would build everywhere. No NVN format maps to it in `vk_formats.cpp` today.
@ -411,0 +428,4 @@
// a B4G4R4A4, B5G6R5, A1B5G5R5 or B5G5R5A1 view names that format; VUID-VkSamplerCreateInfo-borderColor-04442: its colour
// then within what the format holds. Other views keep no format, as customBorderColorWithoutFormat allows)
policy = test;
const VkFormat packed[4] = {VK_FORMAT_B4G4R4A4_UNORM_PACK16, VK_FORMAT_B5G6R5_UNORM_PACK16, VK_FORMAT_A1B5G5R5_UNORM_PACK16,
Owner

Same header point as vk_draw.cpp:3260: the fixture compiles against --headers too.

Same header point as `vk_draw.cpp:3260`: the fixture compiles against `--headers` too.
Author
Contributor

Thanks for the review. New commit:

  • Right about the mapping: only NVN_FORMAT_RGB565 reaches B5G6R5_UNORM_PACK16; RGB5 and RGB5A1 map to A1R5G5B5_UNORM_PACK16, which 04015 does not name. Why, Seen on and step 1 now say so; border_format() keeps the four formats 04015 names.
  • A1B5G5R5_UNORM_PACK16 is now spelled with its _KHR alias, so headers older than 1.3.246 build.
  • New case border-format-in-range with a colour every format holds, so only the format tells the samplers apart; it fails if sampler_info() stops recording the border format. Main fails 6 of 153 cases, this PR passes 153 of 153.
  • The Verdict and Risks name the cost: an RGB565 view with a custom border colour gets a sampler of its own.
Thanks for the review. New commit: - Right about the mapping: only `NVN_FORMAT_RGB565` reaches `B5G6R5_UNORM_PACK16`; RGB5 and RGB5A1 map to `A1R5G5B5_UNORM_PACK16`, which 04015 does not name. Why, Seen on and step 1 now say so; `border_format()` keeps the four formats 04015 names. - `A1B5G5R5_UNORM_PACK16` is now spelled with its `_KHR` alias, so headers older than 1.3.246 build. - New case `border-format-in-range` with a colour every format holds, so only the format tells the samplers apart; it fails if `sampler_info()` stops recording the border format. Main fails 6 of 153 cases, this PR passes 153 of 153. - The Verdict and Risks name the cost: an RGB565 view with a custom border colour gets a sampler of its own.
jcabarca force-pushed fix/vk-border-color-format from 7dc8516586
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 7s
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
Guide screenshots / Guide images and local UI source review (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
Website / Website on Cloudflare (pull_request) Has been cancelled
to e8f4d3c5d1
Some checks failed
PR description / Description follows the template (pull_request_target) Has been cancelled
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
Guide screenshots / Guide images and local UI source review (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
Website / Website on Cloudflare (pull_request) Has been cancelled
2026-11-19 18:12:28 +00:00
Compare
Merge branch 'main' into fix/vk-border-color-format
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 24s
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
Guide screenshots / Guide images and local UI source review (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
Website / Website on Cloudflare (pull_request) Has been cancelled
a27b025b29
Author
Contributor

Measurements updated: the game-free test was run again, 2 interleaved runs, on main @ 9ea65c7b (6 of 153 cases fail) and on this PR @ e8f4d3c5 (153 of 153 pass); the table and the output show them. The game runs in Measurements predate the review commit, as the description now says.

Measurements updated: the game-free test was run again, 2 interleaved runs, on main @ 9ea65c7b (6 of 153 cases fail) and on this PR @ e8f4d3c5 (153 of 153 pass); the table and the output show them. The game runs in Measurements predate the review commit, as the description now says.
jcabarca force-pushed fix/vk-border-color-format from a27b025b29
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 24s
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
Guide screenshots / Guide images and local UI source review (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
Website / Website on Cloudflare (pull_request) Has been cancelled
to f702472be7
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 4s
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
Guide screenshots / Guide images and local UI source review (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
Website / Website on Cloudflare (pull_request) Has been cancelled
2026-11-19 22:10:14 +00:00
Compare
Author
Contributor

Game runs after the review: main @ 9ea65c7b against this PR @ e8f4d3c5, both built with RX_MARCH=x86-64-v3, each side a warm-up and 2 runs standing still for 2 minutes. Median 84.35 fps with this PR against 84.2 fps on main; shaders at start-up with a warm cache 21.1 and 20.4 s against 21.3 and 20.4 s. The tables and log lines are in Measurements, In the game; the new commit adds docs/tested/2026-11-19-border-color-jcabarca-run02.md.

Game runs after the review: main @ 9ea65c7b against this PR @ e8f4d3c5, both built with `RX_MARCH=x86-64-v3`, each side a warm-up and 2 runs standing still for 2 minutes. Median 84.35 fps with this PR against 84.2 fps on main; shaders at start-up with a warm cache 21.1 and 20.4 s against 21.3 and 20.4 s. The tables and log lines are in Measurements, In the game; the new commit adds `docs/tested/2026-11-19-border-color-jcabarca-run02.md`.
jcabarca force-pushed fix/vk-border-color-format from f702472be7
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 4s
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
Guide screenshots / Guide images and local UI source review (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
Website / Website on Cloudflare (pull_request) Has been cancelled
to 8e2e375070
Some checks failed
PR description / Description follows the template (pull_request_target) Failing after 6s
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
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (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
Website / Website on Cloudflare (pull_request) Has been cancelled
2026-11-20 11:54:10 +00:00
Compare
Author
Contributor

Rebased onto main 89c3d21e; the related tests pass again on the new head. The description now names the test PC in full. New commit: the test fixture's Recording gets the pool_sets and pool_descs counters the descriptor writer on main now counts (#1158), so the fixture compiles again; no change to the fix.

Rebased onto main 89c3d21e; the related tests pass again on the new head. The description now names the test PC in full. New commit: the test fixture's Recording gets the pool_sets and pool_descs counters the descriptor writer on main now counts (#1158), so the fixture compiles again; no change to the fix.
Merge branch 'main' into fix/vk-border-color-format
Some checks failed
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
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (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) Failing after 10s
ac958814c7
HumanBean left a comment

Recommendation: Request changes. The code is right and every point of the earlier review is fixed; only the description must change: it is in the old template, so pr status lists three things to fix (no ## Summary, no Still to test: in Testing, no ### Ready for review under Checklist) and the PR description check fails on the head. Once the description is moved to the current template, I would recommend approval.

For a player: a texture in NVN RGB565 sampled past its edge with a custom border colour gets the colour Vulkan defines rather than whatever the driver does with a format-less border; the code is a small, contained fix with its test.

Does it help: a fix, not a perf change. The game-free test fails on main for the bug's reason (6 of 153: border-format and border-format-in-range on the id, make and cache-off routes) and passes here, two interleaved runs. In the game on an RX 9070 XT, Windows: 84.35 against 84.2 fps median (and 89.1 against 88.35 before the review commit), within the spread: no cost seen, no gain claimed. The texture past its edge was not looked at in the game.
Other systems: the change is inside else if (dev.custom_border_color), which vk_main.cpp:644 turns on only with both customBorderColors and customBorderColorWithoutFormat. A driver or vendor without the extension or without customBorderColorWithoutFormat keeps the transparent-black fallback, exactly as on main (VUID 04014 would forbid UNDEFINED there, so the PR rightly does not try to enable custom colours on such devices). Nothing in gpu/ uses VK_EXT_border_color_swizzle, and the PR doesn't need it: views carry NVN component mappings (vk_texture.cpp:653), and a custom border colour on a non-identity view is undefined without that extension on main and here alike; this PR doesn't change it (a possible follow-up, not this PR's). Every vendor (NVIDIA, RADV/AMD Windows, ANV, the Deck) takes the same path; the only device-visible difference is the format field for the four packed formats, which drivers are required to accept. Sampler count: at most one more custom-border sampler per colour that meets RGB565 (maxCustomBorderColorSamplers stays unchecked, as on main, and Risks says so). Descriptor reuse: the view's format is a function of the handle and its registration, so a fingerprint hit can't pair a stale format.
Switches: none.

Reviewed: ac958814c7 against 8859673e (the merge's main parent; main@origin 3df5c13e is ahead only in vk_main.cpp's zstd lines, nothing this touches): gpu/vk/vk_draw.cpp (SamplerInfo, sampler_info, border_format, sampler_for, sampler_make, HandleHit, texture_view_of, build_descriptors' sampled-texture loop), tests/sampler_admission_test.cpp, tests/test_sampler_admission.py, in full where changed; vk_main.cpp's feature gate and vk_formats.cpp's packed mappings read around it; the two docs/tested/ rows skimmed. Nothing run (a code review). A re-review: compared against my earlier review's head 7dc85165; the new code since then is ca511a9c (the _KHR alias, the in-range case), f23235eb (docs/tested run02) and 8e2e3750 (the fixture's pool_sets/pool_descs, matching main's Recording).
Fixed in this review: nothing.
Checked and fine:

  • The header point is fixed: VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR in both border_format() and the fixture needs Vulkan-Headers 1.3.246; the build pins its own headers (mise.toml) and Ubuntu 24.04's 1.3.275 is past that floor.
  • The new border-format-in-range case catches sampler_info()'s i.border_format being dropped: with an in-range colour the SamplerInfo would then match the plain sampler's and book.made would hand it back, so packed != plain fails. It also checks creates == 2 and that both stay cached.
  • border-format still catches bc.format = bfmt, the clamp, the key mix in sampler_make() and the e.border compare in sampler_for(); on a --source from main the fixture builds with SAMPLER_VIEW_FORMAT 0 and fails on the format assertions, the bug's reason.
  • sampler_info() records the format whatever the address modes, which is right: 04015 has no address-mode condition.
  • The clamp (c > 0 ? min(c, 1) : 0) maps NaN to 0 and runs only when a format is named (04442); 07605 holds (UNORM formats, float custom colour).
  • texture_view_of(): the format is last_view_format only when a view was made, UNDEFINED otherwise; a cached HandleHit returns its stored format; the repeated table entry, the depth-compare refusal and the dummy view each set the format they should.
  • The Recording fixture change matches main's vk_internal.h struct (pool_sets, pool_descs[6]), no case removed or weakened.
  • Commits keep the author's Assisted-by: trailers; no game files.

Blocking (to change before merge)

  1. The PR description: move it to the current template so pr status passes: a ## Summary, Still to test: under Testing (None, or the in-game look past a packed texture's edge if you want it there), and the Checklist's ### Ready for review / Ready to merge lists in place of the old Everyone list. While at it, pr status warns that the numbers were taken on main 9ea65c7b and the PR is now on 8859673e: a line saying why they still hold (main's changes since don't touch the sampler path) is enough. pr status also hints at Docs updated for the two docs/tested/ files.

Suggestions (the author may take or leave)

  • From the earlier review and still open, small: border_format() is mixed into the key for every view, so a sampler without a custom colour sampled with an RGB565 view gets its own mine/book.keys key (it still shares the VkSampler through book.made), and a sampler id bound to RGB565 and other views in turn misses sampler_for()'s entry each time. Mixing it only when the sampler takes the custom-colour branch would avoid both; the game run shows no cost, so this is optional.

Testing: the author's game-free test (fails on main, passes here, twice) and two in-game blocks on an RX 9070 XT, Windows; Linux built, not run; TrashPanda's approval is stale. CI on the head is still blocked by required conditions, and the description check fails (point 1). No other hardware is needed: the path is the same on every GPU and the feature gate is unchanged.
Overlaps and merge order: none found. The author's other vk fixes, 925 and 1448, touch vk_texture.cpp and the shader profile (vk_main.cpp, vk_shader.cpp), not the sampler code: no order needed.

**Recommendation: Request changes.** The code is right and every point of the earlier review is fixed; only the description must change: it is in the old template, so `pr status` lists three things to fix (no `## Summary`, no *Still to test:* in Testing, no `### Ready for review` under Checklist) and the PR description check fails on the head. Once the description is moved to the current template, I would recommend approval. For a player: a texture in NVN RGB565 sampled past its edge with a custom border colour gets the colour Vulkan defines rather than whatever the driver does with a format-less border; the code is a small, contained fix with its test. **Does it help:** a fix, not a perf change. The game-free test fails on main for the bug's reason (6 of 153: `border-format` and `border-format-in-range` on the id, make and cache-off routes) and passes here, two interleaved runs. In the game on an RX 9070 XT, Windows: 84.35 against 84.2 fps median (and 89.1 against 88.35 before the review commit), within the spread: no cost seen, no gain claimed. The texture past its edge was not looked at in the game. **Other systems:** the change is inside `else if (dev.custom_border_color)`, which `vk_main.cpp:644` turns on only with both `customBorderColors` and `customBorderColorWithoutFormat`. A driver or vendor without the extension or without `customBorderColorWithoutFormat` keeps the transparent-black fallback, exactly as on main (VUID 04014 would forbid `UNDEFINED` there, so the PR rightly does not try to enable custom colours on such devices). Nothing in `gpu/` uses `VK_EXT_border_color_swizzle`, and the PR doesn't need it: views carry NVN component mappings (`vk_texture.cpp:653`), and a custom border colour on a non-identity view is undefined without that extension on main and here alike; this PR doesn't change it (a possible follow-up, not this PR's). Every vendor (NVIDIA, RADV/AMD Windows, ANV, the Deck) takes the same path; the only device-visible difference is the `format` field for the four packed formats, which drivers are required to accept. Sampler count: at most one more custom-border sampler per colour that meets RGB565 (`maxCustomBorderColorSamplers` stays unchecked, as on main, and Risks says so). Descriptor reuse: the view's format is a function of the handle and its registration, so a fingerprint hit can't pair a stale format. **Switches:** none. **Reviewed:** `ac958814c7` against `8859673e` (the merge's main parent; main@origin `3df5c13e` is ahead only in `vk_main.cpp`'s zstd lines, nothing this touches): `gpu/vk/vk_draw.cpp` (`SamplerInfo`, `sampler_info`, `border_format`, `sampler_for`, `sampler_make`, `HandleHit`, `texture_view_of`, `build_descriptors`' sampled-texture loop), `tests/sampler_admission_test.cpp`, `tests/test_sampler_admission.py`, in full where changed; `vk_main.cpp`'s feature gate and `vk_formats.cpp`'s packed mappings read around it; the two `docs/tested/` rows skimmed. Nothing run (a code review). A re-review: compared against my earlier review's head `7dc85165`; the new code since then is `ca511a9c` (the `_KHR` alias, the in-range case), `f23235eb` (docs/tested run02) and `8e2e3750` (the fixture's `pool_sets`/`pool_descs`, matching main's `Recording`). **Fixed in this review:** nothing. **Checked and fine:** - The header point is fixed: `VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR` in both `border_format()` and the fixture needs Vulkan-Headers 1.3.246; the build pins its own headers (`mise.toml`) and Ubuntu 24.04's 1.3.275 is past that floor. - The new `border-format-in-range` case catches `sampler_info()`'s `i.border_format` being dropped: with an in-range colour the `SamplerInfo` would then match the plain sampler's and `book.made` would hand it back, so `packed != plain` fails. It also checks `creates == 2` and that both stay cached. - `border-format` still catches `bc.format = bfmt`, the clamp, the key mix in `sampler_make()` and the `e.border` compare in `sampler_for()`; on a `--source` from main the fixture builds with `SAMPLER_VIEW_FORMAT 0` and fails on the format assertions, the bug's reason. - `sampler_info()` records the format whatever the address modes, which is right: 04015 has no address-mode condition. - The clamp (`c > 0 ? min(c, 1) : 0`) maps NaN to 0 and runs only when a format is named (04442); 07605 holds (UNORM formats, float custom colour). - `texture_view_of()`: the format is `last_view_format` only when a view was made, `UNDEFINED` otherwise; a cached `HandleHit` returns its stored format; the repeated table entry, the depth-compare refusal and the dummy view each set the format they should. - The `Recording` fixture change matches main's `vk_internal.h` struct (`pool_sets`, `pool_descs[6]`), no case removed or weakened. - Commits keep the author's `Assisted-by:` trailers; no game files. **Blocking** (to change before merge) 1. The PR description: move it to the current template so `pr status` passes: a `## Summary`, *Still to test:* under Testing (`None`, or the in-game look past a packed texture's edge if you want it there), and the Checklist's `### Ready for review` / *Ready to merge* lists in place of the old *Everyone* list. While at it, `pr status` warns that the numbers were taken on main `9ea65c7b` and the PR is now on `8859673e`: a line saying why they still hold (main's changes since don't touch the sampler path) is enough. `pr status` also hints at *Docs updated* for the two `docs/tested/` files. **Suggestions** (the author may take or leave) - From the earlier review and still open, small: `border_format()` is mixed into the key for every view, so a sampler without a custom colour sampled with an RGB565 view gets its own `mine`/`book.keys` key (it still shares the `VkSampler` through `book.made`), and a sampler id bound to RGB565 and other views in turn misses `sampler_for()`'s entry each time. Mixing it only when the sampler takes the custom-colour branch would avoid both; the game run shows no cost, so this is optional. **Testing:** the author's game-free test (fails on main, passes here, twice) and two in-game blocks on an RX 9070 XT, Windows; Linux built, not run; TrashPanda's approval is stale. CI on the head is still blocked by required conditions, and the description check fails (point 1). No other hardware is needed: the path is the same on every GPU and the feature gate is unchanged. **Overlaps and merge order:** none found. The author's other vk fixes, [925](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/925) and [1448](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1448), touch `vk_texture.cpp` and the shader profile (`vk_main.cpp`, `vk_shader.cpp`), not the sampler code: no order needed.
Some checks failed
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
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (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) Failing after 10s
This pull request has changes conflicting with the target branch.
  • tests/sampler_admission_test.cpp
Some workflows are waiting to be reviewed.
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/vk-border-color-format:jcabarca-fix/vk-border-color-format'
git switch 'jcabarca-fix/vk-border-color-format'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 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!1232
No description provided.