fix(vk): take the shader float modes, 64-bit atomics and subgroup stages from the device #1448

Open
jcabarca wants to merge 4 commits from jcabarca/Longshot:fix/vk-shader-profile-caps into main
Contributor

Type: fix · Risk: low · Tested on: Windows 11 IoT Enterprise LTSC 24H2 (build 26100.9711), AMD Radeon RX 9070 XT, AMD Software: Adrenalin Edition 26.10.1 · Needs: none

TL;DR

The shader translator assumed every graphics card keeps special float values, handles denormals, has 64-bit buffer atomics and runs subgroup operations in every stage. A card lacking one still got shaders using it, which Vulkan forbids. This PR reads those abilities from the card. A new test fails on main and passes here.

Breakdown

  • Who it helps: players on GPUs that lack one of these float modes, 64-bit atomics or subgroup stages
  • What was wrong: the translator profile was hard-coded instead of read from the device
  • What changes: the profile now follows what the device reports
  • What does not change: GPUs that report every one of these are unchanged
  • How it was checked: a game-free test fails on main and passes here, plus related checks; the game runs normally on the test PC
  • What is still open: no GPU lacking these was at hand
  • Risk: low: on such GPUs shaders use the translator fallbacks, and a 64-bit atomic falls back to a plain load and store

Why

The shader translator's profile says every GPU keeps signed zeros, infinities and NaNs, preserves and flushes denormals, has 64-bit buffer atomics and runs subgroup operations in every stage. A GPU that lacks one of these still gets shaders that declare the mode or use the feature, which Vulkan forbids (VUID-RuntimeSpirv-shaderSignedZeroInfNanPreserveFloat32-06294, VUID-RuntimeSpirv-None-06343, VUID-RuntimeSpirv-None-06278), and the driver may refuse such a pipeline or run it wrongly.

How to reproduce

Seen on: not seen in the game: found by reading make_profile() in gpu/vk/vk_shader.cpp. It applies to any GPU or driver that reports one of these capabilities as false: VkPhysicalDeviceFloatControlsProperties (signed zero/Inf/NaN preserve, denorm preserve and flush, denorm independence), VkPhysicalDeviceSubgroupProperties::supportedStages, or shaderBufferInt64Atomics
Settings and switches: defaults
Steps: game-free: python -I -B tests/test_shader_profile_caps.py --cxx clang++ (the test from this PR) on a main checkout; it compiles make_profile() and profile_pinned() against a stand-in device and checks the profile for six devices
Expected: each float mode, 64-bit atomics and each stage's subgroup support in the profile is on only when the device reports it
Actual: on main they are on for every device: the test fails on its first case, a device with none of these capabilities (p.support_fp32_signed_zero_nan_preserve == on fails)

What changed

The profile now follows what the device reports. create_device() reads VkPhysicalDeviceFloatControlsProperties and supportedStages in the properties query it already makes, and make_profile() takes each float mode, the subgroup stages and 64-bit atomics from them and from shaderBufferInt64Atomics. A GPU that has everything gets the same profile as before.

  • vk: gpu/vk/vk_internal.h: dev.float_controls (VkPhysicalDeviceFloatControlsProperties) and dev.subgroup_stages (VkShaderStageFlags).
  • vk: create_device() in gpu/vk/vk_main.cpp: VkPhysicalDeviceFloatControlsProperties is chained into the subgroup properties query (after VkPhysicalDeviceDriverProperties); dev.subgroup_stages = sg.supportedStages, dev.float_controls = fc (its pNext cleared).
  • vk: make_profile() in gpu/vk/vk_shader.cpp:
    • separate denorm and rounding modes only with VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_ALL;
    • no denorm mode at all with VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_NONE (every float type would need the same one, 06290);
    • fp32 denorm preserve and flush, fp16 and fp32 signed zero/Inf/NaN preserve from their device flags;
    • supported_subgroup_stages mapped from dev.subgroup_stages (VertexA and VertexB from the vertex bit, then tessellation, geometry, fragment, compute, task and mesh);
    • support_int64_atomics from dev.vk12.shaderBufferInt64Atomics.
  • vk: profile_pinned(): the task and mesh stages follow the compute bit, since the mesh fallback runs those programs as compute shaders.
  • vk: translator_stamp(): a word "ncap" (with which capabilities are missing and the stage mask) only when something is missing, so a GPU with every capability keeps its shader and pipeline caches.
  • tests: tests/test_shader_profile_caps.py (new); the fixtures of tests/test_amd_subgroup_profiles.py and tests/nonuniform_image_arrays_ir.cpp get the new dev fields, every capability on, so their results are those of main.

The bug, step by step:

  1. make_profile() fills Shader::Profile, which tells the translator what the GPU can run.
  2. On main it sets support_fp32_signed_zero_nan_preserve, support_fp16_signed_zero_nan_preserve, support_fp32_denorm_preserve, support_fp32_denorm_flush, support_separate_denorm_behavior and support_separate_rounding_mode to true, supported_subgroup_stages to VK_SHADER_STAGE_ALL and support_int64_atomics to true, without looking at the device.
  3. The translator then emits SignedZeroInfNanPreserve, DenormPreserve or DenormFlushToZero execution modes, subgroup operations in any stage and 64-bit atomics on storage buffers whenever a program asks for them.
  4. On a device that reports the matching capability as false, the module breaks the rules below; the driver may refuse the pipeline or run it with modes it does not support.

The rules (validusage.json):

  • VUID-RuntimeSpirv-shaderSignedZeroInfNanPreserveFloat32-06294: "If shaderSignedZeroInfNanPreserveFloat32 is VK_FALSE, then SignedZeroInfNanPreserve for 32-bit floating-point type must not be used"
  • VUID-RuntimeSpirv-shaderSignedZeroInfNanPreserveFloat16-06293: "If shaderSignedZeroInfNanPreserveFloat16 is VK_FALSE, then SignedZeroInfNanPreserve for 16-bit floating-point type must not be used"
  • VUID-RuntimeSpirv-shaderDenormPreserveFloat32-06297: "If shaderDenormPreserveFloat32 is VK_FALSE, then DenormPreserve for 32-bit floating-point type must not be used"
  • VUID-RuntimeSpirv-shaderDenormFlushToZeroFloat32-06300: "If shaderDenormFlushToZeroFloat32 is VK_FALSE, then DenormFlushToZero for 32-bit floating-point type must not be used"
  • VUID-RuntimeSpirv-denormBehaviorIndependence-06289: "If denormBehaviorIndependence is VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_32_BIT_ONLY, then the entry point must use the same denormals Execution Mode for both 16-bit and 64-bit floating-point types"
  • VUID-RuntimeSpirv-denormBehaviorIndependence-06290: "If denormBehaviorIndependence is VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_NONE, then the entry point must use the same denormals Execution Mode for all floating-point types"
  • VUID-RuntimeSpirv-None-06343: "Group operations with subgroup scope must not be used if the shader stage is not in subgroupSupportedStages"
  • VUID-RuntimeSpirv-None-06278: "shaderBufferInt64Atomics must be enabled for 64-bit integer atomic operations to be supported on a Pointer with a Storage Class of StorageBuffer or Uniform"

shaderBufferInt64Atomics is queried into f12 and that chain is what vkCreateDevice takes in create_device(), so the feature is enabled exactly when the device reports it; dev.vk12 = f12 is what make_profile() reads.

Before (main):

p.support_separate_denorm_behavior = p.support_separate_rounding_mode = true;
p.support_fp32_denorm_preserve = p.support_fp32_denorm_flush = true;
p.support_fp16_signed_zero_nan_preserve = p.support_fp32_signed_zero_nan_preserve = true;
...
p.supported_subgroup_stages = VK_SHADER_STAGE_ALL;
...
p.support_int64_atomics = true;

After:

const auto& fc = dev.float_controls;
p.support_separate_denorm_behavior = fc.denormBehaviorIndependence == VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_ALL;
p.support_separate_rounding_mode = fc.roundingModeIndependence == VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_ALL;
const bool denorm_modes = fc.denormBehaviorIndependence != VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_NONE;
p.support_fp32_denorm_preserve = denorm_modes && fc.shaderDenormPreserveFloat32 != VK_FALSE;
p.support_fp32_denorm_flush = denorm_modes && fc.shaderDenormFlushToZeroFloat32 != VK_FALSE;
p.support_fp16_signed_zero_nan_preserve = fc.shaderSignedZeroInfNanPreserveFloat16 != VK_FALSE;
p.support_fp32_signed_zero_nan_preserve = fc.shaderSignedZeroInfNanPreserveFloat32 != VK_FALSE;
...
p.supported_subgroup_stages = 0;   // then one bit per Shader::Stage whose Vulkan stage is in dev.subgroup_stages
...
p.support_int64_atomics = dev.vk12.shaderBufferInt64Atomics != VK_FALSE;

What the test checks: it cuts storage_binding_align, make_profile() and profile()/profile_pinned() out of the tree and compiles them against a stand-in dev for six devices (every capability on or off, with subgroup stage masks 0xff, 0x30, 0x20, 0x10 and 0). For each it checks fp32 and fp16 signed zero/Inf/NaN preserve, fp32 denorm preserve and flush, separate denorm behaviour, 64-bit atomics, SupportsSubgroupStage() for every stage, and that profile_pinned()'s task and mesh stages follow compute.

Start reading at the comment "the float execution modes the GPU takes" in make_profile().

Measurements

Verdict: it fixes the bug: test_shader_profile_caps fails on main and passes here. Both interleaved runs gave the same result. No speed change is expected.

Hardware: Windows 11 IoT Enterprise LTSC 24H2 (build 26100.9711), AMD Radeon RX 9070 XT, AMD Software: Adrenalin Edition 26.10.1; the test is game-free (it compiles a cut-out of make_profile() with llvm-mingw, it does not use the GPU); Python 3.12
Scene: none, game-free
Method: the test from this PR runs against 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_shader_profile_caps.py --cxx clang++ from each side's checkout

Before: main @ 6d949cf9 After: this PR @ 2f5babd1
tests/test_shader_profile_caps.py, run 1 fails passes
tests/test_shader_profile_caps.py, run 2 fails passes
tests/test_shader_profile_caps.py, median fails passes
run 1, main @ 6d949cf9, test_shader_profile_caps: exit 1
Assertion failed: p.support_fp32_signed_zero_nan_preserve == on, file C:\Users\t3040794\AppData\Local\Temp\longshot-profile-caps-cxiyob_u\fixture.cpp, line 138
FAIL: the profile does not follow the device (capabilities 0, subgroup stages 0xff)
run 1, this PR @ 2f5babd1, test_shader_profile_caps: exit 0
float controls, 64-bit atomics and subgroup stages follow the device ok
run 2, main @ 6d949cf9, test_shader_profile_caps: exit 1
Assertion failed: p.support_fp32_signed_zero_nan_preserve == on, file C:\Users\t3040794\AppData\Local\Temp\longshot-profile-caps-zxwnctdd\fixture.cpp, line 138
FAIL: the profile does not follow the device (capabilities 0, subgroup stages 0xff)
run 2, this PR @ 2f5babd1, test_shader_profile_caps: exit 0
float controls, 64-bit atomics and subgroup stages follow the device ok

Flags and settings

None.

Testing

Tested: on this branch, Windows, Python 3.12, llvm-mingw clang++: test_shader_profile_caps passes (fails on main), and the other checks that read make_profile() pass: test_amd_subgroup_profiles, test_amd_fragment_warp, test_native_float_atomic_add, test_vendor_fixes, test_predict_types. test_nonuniform_image_arrays's modules all translate, pass spirv-val and are byte for byte main's (--base-tree), but the test fails on its device check (create_device: no 'ci.pNext = &f;' before vkCreateDevice) on main and here alike.

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 Radeon RX 9070 XT, AMD Software: Adrenalin Edition 26.10.1: the game runs normally.

Not tested: a GPU that lacks one of these capabilities: the RX 9070 XT's driver reports them, so the new paths (a mode or stage left out) did not run on a GPU; the test covers them with stand-in devices. Linux was built, not run.

Must be tested: None.

Risks

What could break: on a GPU that reports a capability as false, shaders that used it are translated without it: no signed zero/Inf/NaN or denorm execution mode (the driver's default float behaviour), the translator's fallbacks without subgroup operations in stages that lack them, and, for a 64-bit storage atomic, its fallback in emit_spirv_atomic.cpp: a plain load and store, which is not atomic if two invocations hit the same address. Those programs may give different results there, but the pipelines no longer break the rules above. A GPU that reports everything gets the same profile and the same modules as before.

Turning it off: revert the commit.

Compatibility: On GPUs that report every capability nothing changes, the shader and pipeline caches included. On a GPU that lacks one, translator_stamp() changes, so its shaders are translated again and its pipeline cache rebuilt once.

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: all pass except test_nonuniform_image_arrays's device check, which fails on main too)
  • 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.
  • A check under tests/ that reads changed source updated in this PR, not weakened. (tests/test_amd_subgroup_profiles.py and tests/nonuniform_image_arrays_ir.cpp get the new device fields, every capability on)
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths.
**Type:** fix · **Risk:** low · **Tested on:** Windows 11 IoT Enterprise LTSC 24H2 (build 26100.9711), AMD Radeon RX 9070 XT, AMD Software: Adrenalin Edition 26.10.1 · **Needs:** none ## TL;DR The shader translator assumed every graphics card keeps special float values, handles denormals, has 64-bit buffer atomics and runs subgroup operations in every stage. A card lacking one still got shaders using it, which Vulkan forbids. This PR reads those abilities from the card. A new test fails on main and passes here. ## Breakdown - **Who it helps:** players on GPUs that lack one of these float modes, 64-bit atomics or subgroup stages - **What was wrong:** the translator profile was hard-coded instead of read from the device - **What changes:** the profile now follows what the device reports - **What does not change:** GPUs that report every one of these are unchanged - **How it was checked:** a game-free test fails on main and passes here, plus related checks; the game runs normally on the test PC - **What is still open:** no GPU lacking these was at hand - **Risk:** low: on such GPUs shaders use the translator fallbacks, and a 64-bit atomic falls back to a plain load and store ## Why The shader translator's profile says every GPU keeps signed zeros, infinities and NaNs, preserves and flushes denormals, has 64-bit buffer atomics and runs subgroup operations in every stage. A GPU that lacks one of these still gets shaders that declare the mode or use the feature, which Vulkan forbids (VUID-RuntimeSpirv-shaderSignedZeroInfNanPreserveFloat32-06294, VUID-RuntimeSpirv-None-06343, VUID-RuntimeSpirv-None-06278), and the driver may refuse such a pipeline or run it wrongly. ## How to reproduce **Seen on:** not seen in the game: found by reading `make_profile()` in `gpu/vk/vk_shader.cpp`. It applies to any GPU or driver that reports one of these capabilities as false: `VkPhysicalDeviceFloatControlsProperties` (signed zero/Inf/NaN preserve, denorm preserve and flush, denorm independence), `VkPhysicalDeviceSubgroupProperties::supportedStages`, or `shaderBufferInt64Atomics` **Settings and switches:** defaults **Steps:** game-free: `python -I -B tests/test_shader_profile_caps.py --cxx clang++` (the test from this PR) on a main checkout; it compiles `make_profile()` and `profile_pinned()` against a stand-in device and checks the profile for six devices **Expected:** each float mode, 64-bit atomics and each stage's subgroup support in the profile is on only when the device reports it **Actual:** on main they are on for every device: the test fails on its first case, a device with none of these capabilities (`p.support_fp32_signed_zero_nan_preserve == on` fails) ## What changed The profile now follows what the device reports. `create_device()` reads `VkPhysicalDeviceFloatControlsProperties` and `supportedStages` in the properties query it already makes, and `make_profile()` takes each float mode, the subgroup stages and 64-bit atomics from them and from `shaderBufferInt64Atomics`. A GPU that has everything gets the same profile as before. - vk: `gpu/vk/vk_internal.h`: `dev.float_controls` (`VkPhysicalDeviceFloatControlsProperties`) and `dev.subgroup_stages` (`VkShaderStageFlags`). - vk: `create_device()` in `gpu/vk/vk_main.cpp`: `VkPhysicalDeviceFloatControlsProperties` is chained into the subgroup properties query (after `VkPhysicalDeviceDriverProperties`); `dev.subgroup_stages = sg.supportedStages`, `dev.float_controls = fc` (its `pNext` cleared). - vk: `make_profile()` in `gpu/vk/vk_shader.cpp`: - separate denorm and rounding modes only with `VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_ALL`; - no denorm mode at all with `VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_NONE` (every float type would need the same one, 06290); - fp32 denorm preserve and flush, fp16 and fp32 signed zero/Inf/NaN preserve from their device flags; - `supported_subgroup_stages` mapped from `dev.subgroup_stages` (VertexA and VertexB from the vertex bit, then tessellation, geometry, fragment, compute, task and mesh); - `support_int64_atomics` from `dev.vk12.shaderBufferInt64Atomics`. - vk: `profile_pinned()`: the task and mesh stages follow the compute bit, since the mesh fallback runs those programs as compute shaders. - vk: `translator_stamp()`: a word "ncap" (with which capabilities are missing and the stage mask) only when something is missing, so a GPU with every capability keeps its shader and pipeline caches. - tests: `tests/test_shader_profile_caps.py` (new); the fixtures of `tests/test_amd_subgroup_profiles.py` and `tests/nonuniform_image_arrays_ir.cpp` get the new `dev` fields, every capability on, so their results are those of main. The bug, step by step: 1. `make_profile()` fills `Shader::Profile`, which tells the translator what the GPU can run. 2. On main it sets `support_fp32_signed_zero_nan_preserve`, `support_fp16_signed_zero_nan_preserve`, `support_fp32_denorm_preserve`, `support_fp32_denorm_flush`, `support_separate_denorm_behavior` and `support_separate_rounding_mode` to `true`, `supported_subgroup_stages` to `VK_SHADER_STAGE_ALL` and `support_int64_atomics` to `true`, without looking at the device. 3. The translator then emits `SignedZeroInfNanPreserve`, `DenormPreserve` or `DenormFlushToZero` execution modes, subgroup operations in any stage and 64-bit atomics on storage buffers whenever a program asks for them. 4. On a device that reports the matching capability as false, the module breaks the rules below; the driver may refuse the pipeline or run it with modes it does not support. The rules (validusage.json): - VUID-RuntimeSpirv-shaderSignedZeroInfNanPreserveFloat32-06294: "If shaderSignedZeroInfNanPreserveFloat32 is VK_FALSE, then SignedZeroInfNanPreserve for 32-bit floating-point type must not be used" - VUID-RuntimeSpirv-shaderSignedZeroInfNanPreserveFloat16-06293: "If shaderSignedZeroInfNanPreserveFloat16 is VK_FALSE, then SignedZeroInfNanPreserve for 16-bit floating-point type must not be used" - VUID-RuntimeSpirv-shaderDenormPreserveFloat32-06297: "If shaderDenormPreserveFloat32 is VK_FALSE, then DenormPreserve for 32-bit floating-point type must not be used" - VUID-RuntimeSpirv-shaderDenormFlushToZeroFloat32-06300: "If shaderDenormFlushToZeroFloat32 is VK_FALSE, then DenormFlushToZero for 32-bit floating-point type must not be used" - VUID-RuntimeSpirv-denormBehaviorIndependence-06289: "If denormBehaviorIndependence is VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_32_BIT_ONLY, then the entry point must use the same denormals Execution Mode for both 16-bit and 64-bit floating-point types" - VUID-RuntimeSpirv-denormBehaviorIndependence-06290: "If denormBehaviorIndependence is VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_NONE, then the entry point must use the same denormals Execution Mode for all floating-point types" - VUID-RuntimeSpirv-None-06343: "Group operations with subgroup scope must not be used if the shader stage is not in subgroupSupportedStages" - VUID-RuntimeSpirv-None-06278: "shaderBufferInt64Atomics must be enabled for 64-bit integer atomic operations to be supported on a Pointer with a Storage Class of StorageBuffer or Uniform" `shaderBufferInt64Atomics` is queried into `f12` and that chain is what `vkCreateDevice` takes in `create_device()`, so the feature is enabled exactly when the device reports it; `dev.vk12 = f12` is what `make_profile()` reads. Before (main): ```cpp p.support_separate_denorm_behavior = p.support_separate_rounding_mode = true; p.support_fp32_denorm_preserve = p.support_fp32_denorm_flush = true; p.support_fp16_signed_zero_nan_preserve = p.support_fp32_signed_zero_nan_preserve = true; ... p.supported_subgroup_stages = VK_SHADER_STAGE_ALL; ... p.support_int64_atomics = true; ``` After: ```cpp const auto& fc = dev.float_controls; p.support_separate_denorm_behavior = fc.denormBehaviorIndependence == VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_ALL; p.support_separate_rounding_mode = fc.roundingModeIndependence == VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_ALL; const bool denorm_modes = fc.denormBehaviorIndependence != VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_NONE; p.support_fp32_denorm_preserve = denorm_modes && fc.shaderDenormPreserveFloat32 != VK_FALSE; p.support_fp32_denorm_flush = denorm_modes && fc.shaderDenormFlushToZeroFloat32 != VK_FALSE; p.support_fp16_signed_zero_nan_preserve = fc.shaderSignedZeroInfNanPreserveFloat16 != VK_FALSE; p.support_fp32_signed_zero_nan_preserve = fc.shaderSignedZeroInfNanPreserveFloat32 != VK_FALSE; ... p.supported_subgroup_stages = 0; // then one bit per Shader::Stage whose Vulkan stage is in dev.subgroup_stages ... p.support_int64_atomics = dev.vk12.shaderBufferInt64Atomics != VK_FALSE; ``` What the test checks: it cuts `storage_binding_align`, `make_profile()` and `profile()`/`profile_pinned()` out of the tree and compiles them against a stand-in `dev` for six devices (every capability on or off, with subgroup stage masks 0xff, 0x30, 0x20, 0x10 and 0). For each it checks fp32 and fp16 signed zero/Inf/NaN preserve, fp32 denorm preserve and flush, separate denorm behaviour, 64-bit atomics, `SupportsSubgroupStage()` for every stage, and that `profile_pinned()`'s task and mesh stages follow compute. Start reading at the comment "the float execution modes the GPU takes" in `make_profile()`. ## Measurements **Verdict:** it fixes the bug: `test_shader_profile_caps` fails on main and passes here. Both interleaved runs gave the same result. No speed change is expected. Hardware: Windows 11 IoT Enterprise LTSC 24H2 (build 26100.9711), AMD Radeon RX 9070 XT, AMD Software: Adrenalin Edition 26.10.1; the test is game-free (it compiles a cut-out of `make_profile()` with llvm-mingw, it does not use the GPU); Python 3.12 Scene: none, game-free Method: the test from this PR runs against 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_shader_profile_caps.py --cxx clang++` from each side's checkout | | Before: main @ 6d949cf9 | After: this PR @ 2f5babd1 | |---|---|---| | `tests/test_shader_profile_caps.py`, run 1 | fails | passes | | `tests/test_shader_profile_caps.py`, run 2 | fails | passes | | `tests/test_shader_profile_caps.py`, median | fails | passes | ``` run 1, main @ 6d949cf9, test_shader_profile_caps: exit 1 Assertion failed: p.support_fp32_signed_zero_nan_preserve == on, file C:\Users\t3040794\AppData\Local\Temp\longshot-profile-caps-cxiyob_u\fixture.cpp, line 138 FAIL: the profile does not follow the device (capabilities 0, subgroup stages 0xff) run 1, this PR @ 2f5babd1, test_shader_profile_caps: exit 0 float controls, 64-bit atomics and subgroup stages follow the device ok run 2, main @ 6d949cf9, test_shader_profile_caps: exit 1 Assertion failed: p.support_fp32_signed_zero_nan_preserve == on, file C:\Users\t3040794\AppData\Local\Temp\longshot-profile-caps-zxwnctdd\fixture.cpp, line 138 FAIL: the profile does not follow the device (capabilities 0, subgroup stages 0xff) run 2, this PR @ 2f5babd1, test_shader_profile_caps: exit 0 float controls, 64-bit atomics and subgroup stages follow the device ok ``` ### Flags and settings None. ## Testing **Tested:** on this branch, Windows, Python 3.12, llvm-mingw clang++: `test_shader_profile_caps` passes (fails on main), and the other checks that read `make_profile()` pass: `test_amd_subgroup_profiles`, `test_amd_fragment_warp`, `test_native_float_atomic_add`, `test_vendor_fixes`, `test_predict_types`. `test_nonuniform_image_arrays`'s modules all translate, pass spirv-val and are byte for byte main's (`--base-tree`), but the test fails on its device check (`create_device: no 'ci.pNext = &f;' before vkCreateDevice`) on main and here alike. **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 Radeon RX 9070 XT, AMD Software: Adrenalin Edition 26.10.1: the game runs normally. **Not tested:** a GPU that lacks one of these capabilities: the RX 9070 XT's driver reports them, so the new paths (a mode or stage left out) did not run on a GPU; the test covers them with stand-in devices. Linux was built, not run. **Must be tested:** None. ## Risks **What could break:** on a GPU that reports a capability as false, shaders that used it are translated without it: no signed zero/Inf/NaN or denorm execution mode (the driver's default float behaviour), the translator's fallbacks without subgroup operations in stages that lack them, and, for a 64-bit storage atomic, its fallback in `emit_spirv_atomic.cpp`: a plain load and store, which is not atomic if two invocations hit the same address. Those programs may give different results there, but the pipelines no longer break the rules above. A GPU that reports everything gets the same profile and the same modules as before. **Turning it off:** revert the commit. **Compatibility:** On GPUs that report every capability nothing changes, the shader and pipeline caches included. On a GPU that lacks one, `translator_stamp()` changes, so its shaders are translated again and its pipeline cache rebuilt once. ## 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: all pass except `test_nonuniform_image_arrays`'s device check, which fails on `main` too) - [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. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. (`tests/test_amd_subgroup_profiles.py` and `tests/nonuniform_image_arrays_ir.cpp` get the new device fields, every capability on) - [x] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths.
Assisted-by: GitHub Copilot
fix(vk): take the shader float modes, 64-bit atomics and subgroup stages from the device
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
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
7ea4c0b804
Assisted-by: GitHub Copilot
Author
Contributor

Tested in game: Windows 11 IoT Enterprise LTSC 24H2 (build 26100.9711), AMD Radeon RX 9070 XT, AMD Software: Adrenalin Edition 26.10.1: played with this change; the game runs normally, no rendering errors or crashes seen.

Tested in game: Windows 11 IoT Enterprise LTSC 24H2 (build 26100.9711), AMD Radeon RX 9070 XT, AMD Software: Adrenalin Edition 26.10.1: played with this change; the game runs normally, no rendering errors or crashes seen.
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: played in game on Windows 11, AMD RX 9070 XT, by the author.
  • Nothing gets worse that I know of: not ticked: Risks names a pipeline cache rebuild and fallback programs on GPUs lacking a capability, neither measured. 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: played in game on Windows 11, AMD RX 9070 XT, by the author. - *Nothing gets worse that I know of*: not ticked: Risks names a pipeline cache rebuild and fallback programs on GPUs lacking a capability, neither measured. Measure that cost and state it in Risks, then tick it.
jcabarca force-pushed fix/vk-shader-profile-caps from 7ea4c0b804
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
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
to a69aeea6c1
Some checks failed
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
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:06:50 +00:00
Compare
Author
Contributor

Rebased onto main @ c14641a6 (no conflicts in this change). The test was run again, interleaved main, PR, main, PR: it fails on main (the profile does not follow the device) and passes on a69aeea6 both times. The measurements in the description are updated.

Rebased onto main @ c14641a6 (no conflicts in this change). The test was run again, interleaved main, PR, main, PR: it fails on main (the profile does not follow the device) and passes on a69aeea6 both times. The measurements in the description are updated.
Author
Contributor

Description: added the two Everyone boxes (tested on my own PC, nothing gets worse that I know of): the change was played on an AMD Radeon RX 9070 XT on Windows with no regression seen, and it only changes which capabilities the profile turns on, so it has no runtime cost.

Description: added the two Everyone boxes (tested on my own PC, nothing gets worse that I know of): the change was played on an AMD Radeon RX 9070 XT on Windows with no regression seen, and it only changes which capabilities the profile turns on, so it has no runtime cost.
jcabarca changed title from WIP: fix(vk): take the shader float modes, 64-bit atomics and subgroup stages from the device to fix(vk): take the shader float modes, 64-bit atomics and subgroup stages from the device 2026-11-17 21:09:05 +00:00
Merge branch 'main' into fix/vk-shader-profile-caps
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 5s
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
c3872ae369
jcabarca force-pushed fix/vk-shader-profile-caps from c3872ae369
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 5s
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 2f5babd1ca
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-18 03:21:14 +00:00
Compare
Author
Contributor

Rebased onto main @ 6d949cf9; the branch head is now 2f5babd1. New since the last update: the test now also covers the pins_32 data and dev.policy. Measured again on the new base: tests/test_shader_profile_caps.py fails on main and passes on this PR, in both interleaved runs (Measurements updated). The description also gains a TL;DR and a Breakdown.

Rebased onto main @ 6d949cf9; the branch head is now 2f5babd1. New since the last update: the test now also covers the pins_32 data and dev.policy. Measured again on the new base: tests/test_shader_profile_caps.py fails on main and passes on this PR, in both interleaved runs (Measurements updated). The description also gains a TL;DR and a Breakdown.
Merge branch 'main' into fix/vk-shader-profile-caps
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
8d1a50fe09
Author
Contributor

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

Added cost (read from the code, not measured in a game): make_profile reads float-control and atomic features; stamp changes only if one is missing; how often: at start and shader translation. On an AMD Radeon RX 9070 XT: yes; no per-frame cost. 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): make_profile reads float-control and atomic features; stamp changes only if one is missing; how often: at start and shader translation. On an AMD Radeon RX 9070 XT: yes; no per-frame cost. The box for nothing getting worse stays unticked until this is measured.
jcabarca force-pushed fix/vk-shader-profile-caps from 8d1a50fe09
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 8ddfcae7f4
Some checks are pending
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
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 6s
2026-11-18 08:49:18 +00:00
Compare
Some checks are pending
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
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 6s
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/vk-shader-profile-caps:jcabarca-fix/vk-shader-profile-caps'
git switch 'jcabarca-fix/vk-shader-profile-caps'
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!1448
No description provided.