Skip to content

fix(shader): type signed constants in the gather diagnostic - #16246

Open
lgqdaxia wants to merge 1 commit into
boykopovar:mainfrom
lgqdaxia:codex/fix-gather-signed-constant
Open

lgqdaxia wants to merge 1 commit into
boykopovar:mainfrom
lgqdaxia:codex/fix-gather-signed-constant

Conversation

@lgqdaxia

@lgqdaxia lgqdaxia commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

What

APS5_GATHER_CONST builds a signed gather result from unsigned constants. For an ivec4 result this produces invalid SPIR-V: the constituents and the vector components have different types. Use ConstantI32 for signed results, preserving the input's 32-bit pattern. The unsigned and floating-point paths keep their existing conversions.

Extend the existing synthetic ImageSint8 execution fixture with two separately registered modes (1 and 0xffffffff). Each checks signed, unsigned and floating-point gather results and the untouched output guard. The ordinary signed-texture test remains the control. The same fixture source builds on main without the production fix.

This was found while using the diagnostic switch to investigate a rendering problem. It repairs the opt-in diagnostic; it does not establish or fix the cause of that rendering problem.

Tested

Windows 11 Pro 10.0.26200, MinGW GCC 15.2.0, Release/Ninja, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=ON, ANYPS5_AGC_EXECUTION_TESTS=ImageSint8. Synthetic fixture only; no game input is needed.

The identical test source and registrations were run against main e647fe16fdee with only the tests applied, then against 38a33bc3568d with the production fix:

CTest Main + tests This PR
agc_driver_image_sint8 (ordinary loads, samples/gather and table checks) pass pass
agc_driver_image_sint8_gather_constant_one fails signed-vector SPIR-V validation pass, all three formats
agc_driver_image_sint8_gather_constant_all_bits fails signed-vector SPIR-V validation pass, all three formats

Both main failures report Expected Constituents to be scalars or vectors of the same type as Result Type components. They fail on the signed case before reaching the unsigned/float controls. With the fix, all 32 lanes and four components match, and the output guard is unchanged. The all-bits case checks 0xffffffff for both integer formats and the existing unsigned-to-float conversion (0x4f800000) for UNORM.

Both runs used ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation on the same NVIDIA GPU, with ctest --test-dir build-gather -R '^agc_driver_image_sint8($|_gather_constant_one$|_gather_constant_all_bits$)' -V --no-tests=error. The diagnostic tests set APS5_SPIRV_OPT=none and their respective APS5_GATHER_CONST values through CTest. The requested validation layer and expected AGC module were observed loaded in every fixture process. Neither run contains a missing-layer message, VUID- error or synchronization hazard; no tests skipped.

The affected target builds, and the configured project registration audit passes (2040 test executables, none newly unregistered). The complete title/body conventions check passes. This is focused Windows validation, not a full product or cross-vendor test run.

The required overlap scan had incomplete comparisons that were checked manually against its fetched heads. None carries this diagnostic fix. #9508 and its carriers (#7642, #10193, #13928, #13929) add an independent GPU-heap registration to the same new CMake fragment. That add/add text conflict needs both registrations preserved by whichever lands second; the diagnostic fix has no implementation dependency on them. The main-vs-PR conflicts reported for #907 and #5371 already exist without this change. The shader/AGC components are unchanged between the tested main and the scan's 7264864185f8 snapshot.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 3080 Laptop GPU, Windows driver 32.0.16.1074 (610.74), Windows 11 Pro 10.0.26200
  • AI-assisted: yes

@lgqdaxia

lgqdaxia commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@Raghav314, coordinating the test-registration add/add with #9508.

The changes are functionally independent. This PR fixes the signed constant type in the opt-in gather diagnostic; the overlap is the new agc_driver_image_sint8_tests.cmake fragment. Your branch adds agc_add_gpu_heap_test(agc_driver_image_sint8), while this one adds two separately named diagnostic CTests.

My recommendation is to choose the order by actual review/CI readiness. #9508 already has a review approval on its current head de1bbf1af31c and completed linked checks; this PR has just opened and its automatic checks were queued when I checked. If #9508 is already ready under the project's rules, it should proceed first and I will rebase this PR afterward. If this independent diagnostic fix becomes ready first, it can land first instead. The registration collision alone is not a technical reason to hold either change.

Whichever lands second should retain both the GPU-heap registration and the two diagnostic registrations. Can we use that plan? If you already have a concrete ordering preference based on the remaining work, please let me know; I will record the agreed order in Depends on where needed, without presenting it as a functional dependency.

@github-actions github-actions Bot added build shader core/shader agc libSceAgc* labels Nov 5, 2026
@AlfaRojo

AlfaRojo commented Nov 6, 2026

Copy link
Copy Markdown

Windows check of head 38a33bc356, merged onto main 3cb1cd29ec (bf2d1ad4fc, clean merge), on both vendors, in a build without SPIRV-Tools: green everywhere, and the red arm does not fail without validation.

Setup: Windows 11 Pro (10.0.26200), WinLibs GCC 15.2.0 r7 UCRT, Release, ANYPS5_ENABLE_SPIRV_TOOLS=OFF, ANYPS5_AGC_EXECUTION_TESTS including ImageSint8, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, ANYPS5_GPU selecting the device; no validation layer on this machine.

GPU gather_constant_one and gather_constant_all_bits, this PR the same with SpirvImageEmitter.cpp reverted to main agc_driver_image_sint8
NVIDIA GeForce RTX 4070 (10de:2786, driver 32.0.16.1692) 3 of 3 pass 3 of 3 pass pass
AMD Radeon Graphics 1002:13c0 (RDNA 2 integrated, driver 32.0.21043.5001) 3 of 3 pass 3 of 3 pass pass

Both drivers accept the ill-typed OpConstantComposite and return the expected signed, unsigned and float values, so the failure of the main arm in your table is the spirv-val rejection, which needs ANYPS5_ENABLE_SPIRV_TOOLS=ON; the fix is correct either way. No title run.

AI-assisted: yes.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head 38a33bc merged onto main 82fcf46 · tested 2026-11-06 05:40 UTC · 20 min

GPU NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Vulkan 1.4.329
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,969 passed · 4 failed (0 new, 3 also fail on main, 1 unstable on main) · 56 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 3,029 of 4,158 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (981 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.1 s, ⚠️ agc_shader_sampler_limits 34.5 s
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 1 of the last 10 main runs
Failing on main too (3, not counted against this PR)
agc_driver_image_table
guest_mmap_executable
guest_socket_options_multicast
Validation IDs already present on main (9 IDs in 596 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (596 tests): agc_driver, agc_driver_address_draw_space_reuse, agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, agc_driver_bda_anchor_reads, and 588 more
VUID-VkShaderModuleCreateInfo-pCode-08737 (14 tests): agc_driver_dpp16_operands, agc_driver_dpp8_pk_fmac, agc_driver_dx10_clamp, agc_driver_f16_fma_denormal_modes, agc_driver_f16_fma_invalid_nan, agc_driver_float16_fma_rounding, agc_driver_float16_modifiers, agc_driver_float16_native, and 6 more
VUID-VkShaderModuleCreateInfo-pCode-08739 (14 tests): agc_driver_dpp16_operands, agc_driver_dpp8_pk_fmac, agc_driver_dx10_clamp, agc_driver_f16_fma_denormal_modes, agc_driver_f16_fma_invalid_nan, agc_driver_float16_fma_rounding, agc_driver_float16_modifiers, agc_driver_float16_native, and 6 more
VUID-VkShaderModuleCreateInfo-pCode-08741 (14 tests): agc_driver_dpp16_operands, agc_driver_dpp8_pk_fmac, agc_driver_dx10_clamp, agc_driver_f16_fma_denormal_modes, agc_driver_f16_fma_invalid_nan, agc_driver_float16_fma_rounding, agc_driver_float16_modifiers, agc_driver_float16_native, and 6 more
VUID-vkCmdCopyImage-srcImage-01548 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-vkCmdCopyImage-srcImage-01551 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (2 tests): agc_driver_prepared_exports, agc_driver_srgb8_color_target
VUID-VkPipelineShaderStageCreateInfo-module-parameter (1 test): agc_driver_float16_unused_nan_payloads
VUID-VkPipelineShaderStageCreateInfo-pSpecializationInfo-06849 (1 test): agc_driver_float16_unused_nan_payloads
Skipped (56)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_gcn_display_present: skipped, no display: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
agc_driver_sample_order_grid_reference: skipped, the device does not keep depth drawn at custom sample locations at those locations, even after a transition that names them: the composite of uniform renders holds the guest's depth in 0 of 3005 sloped samples, so no path can be compared with it bit for bit
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_stencil_ref_export: skipped, the device lacks VK_EXT_shader_stencil_export
agc_driver_vertex_elected_atomic_max: skipped, the device runs vertex programs in subgroups, so they keep their cross-lane reductions
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_net_ctl_disconnected: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_device_capability: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_disabled: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_four_k: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_height_only: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_limit: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_malformed: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_width_only: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip: skipped, no display or Vulkan de
Reproduce
git fetch origin 38a33bc3568dd74f3a98b6a34399624a50c335d2 82fcf46d250e0ec2f436ceffd607dd2ff04c62d7
git checkout 82fcf46d250e0ec2f436ceffd607dd2ff04c62d7 && git merge --no-ff 38a33bc3568dd74f3a98b6a34399624a50c335d2
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 32 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 4 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants