fix(vk): skip texel buffer views of formats the device cannot use #2741

Open
github-sync wants to merge 2 commits from github/pr/2741 into main
Owner

@juliotec opened this pull request on GitHub · 2026-11-12 10:31 UTC · original

texel_buffer_view created a VkBufferView for any format the texture maps to,
without checking the device's bufferFeatures. A format a driver has no
uniform or storage texel buffers of (AMD lacks several, such as some
3-component ones) makes an invalid view.

What changed (gpu/vk/vk_texture.cpp, texel_buffer_view): the format's
bufferFeatures must have UNIFORM_TEXEL_BUFFER (sampled) or STORAGE_TEXEL_BUFFER
(storage); otherwise no view is made and the slot stays unbound, logged at most
8 times. The answer comes from the existing format_props cache, so a bind does
not query the driver again. Supported formats behave as before.

How tested: release build; Zelda OoT on Radeon RX 9070 XT (Windows,
Adrenalin).

Assisted-by: GitHub Copilot

> [@juliotec](https://github.com/juliotec) opened this pull request on GitHub · 2026-11-12 10:31 UTC · [original](https://github.com/NotRexed/Hookshot/pull/2741) texel_buffer_view created a VkBufferView for any format the texture maps to, without checking the device's bufferFeatures. A format a driver has no uniform or storage texel buffers of (AMD lacks several, such as some 3-component ones) makes an invalid view. What changed (gpu/vk/vk_texture.cpp, texel_buffer_view): the format's bufferFeatures must have UNIFORM_TEXEL_BUFFER (sampled) or STORAGE_TEXEL_BUFFER (storage); otherwise no view is made and the slot stays unbound, logged at most 8 times. The answer comes from the existing format_props cache, so a bind does not query the driver again. Supported formats behave as before. How tested: release build; Zelda OoT on Radeon RX 9070 XT (Windows, Adrenalin). Assisted-by: GitHub Copilot <!-- github-sync:item:2741 -->
texel_buffer_view created a VkBufferView for any format the texture maps to,
without checking the device's bufferFeatures. A format a driver has no
uniform or storage texel buffers of (AMD lacks several, such as some
3-component ones) makes an invalid view.

What changed (gpu/vk/vk_texture.cpp, texel_buffer_view): the format's
bufferFeatures must have UNIFORM_TEXEL_BUFFER (sampled) or STORAGE_TEXEL_BUFFER
(storage); otherwise no view is made and the slot stays unbound, logged at most
8 times. The answer comes from the existing format_props cache, so a bind does
not query the driver again. Supported formats behave as before.

How tested: release build; Zelda OoT on Radeon RX 9070 XT (Windows,
Adrenalin).

Assisted-by: GitHub Copilot
Author
Owner

@Joey-Magnus requested changes on GitHub · 2026-11-12 14:34 UTC · original

The check itself makes sense. Creating a VkBufferView in a format without UNIFORM_TEXEL_BUFFER or STORAGE_TEXEL_BUFFER in bufferFeatures is invalid, and the descriptor path already handles a null view.

But it breaks an existing test. tests/test_texel_buffer_ownership.py cuts texel_buffer_view out of vk_texture.cpp and compiles it against the stubs in tests/texel_buffer_ownership_test.cpp. With this merged into current main it fails to compile: "fixture.cpp:156: 'format_props' was not declared in this scope". On main it passes its 23 cases. Please add a format_props stub to the fixture next to vk_format and logf (around lines 75-88). Even better, add a case where the stub reports no buffer feature and the function must return VK_NULL_HANDLE without calling texture_gpu_wrote or creating a view.

Two smaller points. format_props takes fmt_mu on every texel-buffer bind now, a second lock on that path, though it's cheap. And the description says AMD lacks some 3-component formats. A log line from the RX 9070 XT showing the new message would show the check is reached in OoT at all.

> [@Joey-Magnus](https://github.com/Joey-Magnus) requested changes on GitHub · 2026-11-12 14:34 UTC · [original](https://github.com/NotRexed/Hookshot/pull/2741#pullrequestreview-5876243766) The check itself makes sense. Creating a VkBufferView in a format without UNIFORM_TEXEL_BUFFER or STORAGE_TEXEL_BUFFER in bufferFeatures is invalid, and the descriptor path already handles a null view. But it breaks an existing test. tests/test_texel_buffer_ownership.py cuts texel_buffer_view out of vk_texture.cpp and compiles it against the stubs in tests/texel_buffer_ownership_test.cpp. With this merged into current main it fails to compile: "fixture.cpp:156: 'format_props' was not declared in this scope". On main it passes its 23 cases. Please add a format_props stub to the fixture next to vk_format and logf (around lines 75-88). Even better, add a case where the stub reports no buffer feature and the function must return VK_NULL_HANDLE without calling texture_gpu_wrote or creating a view. Two smaller points. format_props takes fmt_mu on every texel-buffer bind now, a second lock on that path, though it's cheap. And the description says AMD lacks some 3-component formats. A log line from the RX 9070 XT showing the new message would show the check is reached in OoT at all. <!-- github-sync:r:5876243766 -->
texel_buffer_view now asks format_props for buffer features, and the fixture
had no stub, so tests/test_texel_buffer_ownership.py failed to compile.
The stub reports both texel buffer features except for format 44
(R32G32B32_SFLOAT). The new case 'unsupported' binds that format as
uniform and as storage: no view, no buffer lookup, no texture_gpu_wrote.

How tested: tests/test_texel_buffer_ownership.py, 24 cases pass.

Assisted-by: GitHub Copilot
Author
Owner

@juliotec commented on GitHub · 2026-11-12 17:35 UTC · original

Thanks. Pushed b7f1be0f: tests/texel_buffer_ownership_test.cpp gets a format_props stub next to vk_format. It reports both texel buffer features except for format 44 (R32G32B32_SFLOAT). A new case, unsupported, binds that format as uniform and as storage and checks there is no view, no buffer lookup and no texture_gpu_wrote. The test passes its 24 cases.

On fmt_mu: format_props is the existing cached lookup, so this adds one short lock per texel-buffer bind. I can cache the result next to the view key if you prefer.

On the log line: I don't have an OoT capture showing the message yet. I'll post one if I get it, or drop the claim about 3-component formats from the description.

> [@juliotec](https://github.com/juliotec) commented on GitHub · 2026-11-12 17:35 UTC · [original](https://github.com/NotRexed/Hookshot/pull/2741#issuecomment-6831108463) Thanks. Pushed b7f1be0f: tests/texel_buffer_ownership_test.cpp gets a format_props stub next to vk_format. It reports both texel buffer features except for format 44 (R32G32B32_SFLOAT). A new case, unsupported, binds that format as uniform and as storage and checks there is no view, no buffer lookup and no texture_gpu_wrote. The test passes its 24 cases. On fmt_mu: format_props is the existing cached lookup, so this adds one short lock per texel-buffer bind. I can cache the result next to the view key if you prefer. On the log line: I don't have an OoT capture showing the message yet. I'll post one if I get it, or drop the claim about 3-component formats from the description. <!-- github-sync:c:6831108463 -->
Commenting is not possible because the repository is archived.
No description provided.