Skip to content

fix(shader): translate ds_min/max/add_src2_f32 through dsSrc2 - #14247

Open
StarMrGamer wants to merge 1 commit into
boykopovar:mainfrom
StarMrGamer:fix/shader-ds-src2-f32
Open

StarMrGamer wants to merge 1 commit into
boykopovar:mainfrom
StarMrGamer:fix/shader-ds-src2-f32

Conversation

@StarMrGamer

Copy link
Copy Markdown
Contributor

What

ds_min_src2_f32, ds_max_src2_f32 and ds_add_src2_f32 threw at translation because LDS float atomics did not model the f32 denormal mode. Since 731575c dsAtomic sets flushDenormals and flushDenormalResults from FLOAT_MODE bits 4 and 5. dsSrc2 now sets the same two fields on the DS[A] atomic, and the three opcodes go through it with SharedAtomicFMin32, SharedAtomicFMax32 and SharedAtomicFAdd32. The 64-bit, GDS and offset1[7] forms still throw.

Source of the semantics: the f32 src2 forms are taken to be the measured ds_min_f32, ds_max_f32 and ds_add_f32 (RDNA2, gfx1035, the oracle's hardware) applied to DS[A] and DS[B], which is how the integer src2 forms were done. No RDNA2 part has the src2 opcodes, so they are not measured on GFX10.1; the DS src2 entry in docs/dev/debt/shader.md now says so instead of giving the obsolete reason. This is the inference the question in #14089 asks about.

agc_driver_lds_src2 replaces the check that the f32 forms are refused with an execution check: for each op it stores the denormals 0x1 and 0x2 in LDS, runs the src2 form and the non-src2 form on them under FLOAT_MODE 0x00 and 0x30, and requires that both forms give the same result in each mode and that the two modes differ (0 in both forms under 0x00; 1, 2 and 3 under 0x30). With the two dsSrc2 flush lines removed, it fails with lds src2: min differs from ds_min_f32 in mode 0x00000000.

#14085 rewords the same debt sentence; whichever lands second rebases.

Tested

Arch Linux, AMD Radeon 780M (RADV PHOENIX, Mesa 26.2.5), GCC 16.2.1, Release.

  • ctest --test-dir build -R 'agc_driver_lds_src2|agc_driver_lds_float_atomic_modes|agc_driver_lds_add_f32' -V with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1 and ANYPS5_REQUIRE_VULKAN=1, on main dc9dc7e and on this branch on top of it: 3/3 passed on both, neither log contains was not found but was requested by env var VK_INSTANCE_LAYERS, and neither has any VUID- line.
  • ctest -R 'lds|shader|recompiler|ds_' with ANYPS5_REQUIRE_VULKAN=1: 165/165 passed (2 skipped by the tests themselves).
  • No title tested.
  • Rebased onto 3741ca9 afterwards; the 53 commits in between change none of the files this PR touches.

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: Fixes shader: ds_min/max/add_src2_f32 throw for a reason that no longer holds #14089
  • Unblocks: none
  • GPUs tested: AMD Radeon 780M (RDNA3, gfx1103), RADV PHOENIX, Mesa 26.2.5, Arch Linux (kernel 7.2.11)
  • AI-assisted: yes (Claude Code with DeepSeek V4.1 Flash)

🤖 Generated with Claude Code

The f32 src2 forms threw because LDS float atomics did not model the
f32 denormal mode. dsAtomic has modelled it since 731575c, so dsSrc2
now sets the same flush fields and the three opcodes use it. The
execution test checks each form against ds_min/max/add_f32 under flush
and keep modes.

Fixes boykopovar#14089

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — changes requested

The implementation and author-reported test evidence are plausible, but the PR overlaps #14085 and does not record an agreed landing order as the repository requires.

What I ran

Reviewed head 0f8ec048111e27629b48385e46b4e98cf6b3eca3 against PR base 5d3ad2112f60f35d463dc2c9d96d1c9d35871015. The fresh merge preview against current main 4a58bc29ad656ad7a54c1733b3b683e68b7ccf85 was clean. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0. No build or compile was run.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14247
python3 tools/pr_stack_check.py 14247 --repo boykopovar/AnyPS5
python3 tools/pr_abi_audit.py --repo boykopovar/AnyPS5 --base 5d3ad2112f60f35d463dc2c9d96d1c9d35871015 --head 0f8ec048111e27629b48385e46b4e98cf6b3eca3 --json
python3 tools/pr_test_quality.py --root /marc/AnyPS5 --json core/libs/prx/libSceAgcDriver/tests/execution/LdsSrc2.cpp core/shader/recompiler/Translation/src/MemoryInstructions/MemoryInstructionDispatch.cpp core/shader/recompiler/Translation/src/MemoryInstructions/SharedMemoryInstructions.cpp docs/dev/debt/shader.md

Results

Check Result
git diff --check and conventions/template Passed in precheck.
Current-main merge preview Clean against 4a58bc29ad656ad7a54c1733b3b683e68b7ccf85; no declared dependency found.
ABI audit Could not run: the helper could not resolve this remote repository checkout from its --repo argument. No ABI change is claimed.
Test-quality heuristic Warned that LdsSrc2.cpp may be unregistered. This is a false positive: the execution tests are included through CMake's tests/execution/*.cpp glob and registered by agc_add_default_test.
Hosted CI at refresh eligibility, intake, report, and library-portability passed; conventions, labels, and the relinker/Windows build jobs were queued or in progress; Linux, register-context, and write-watch jobs were skipped. These statuses are hosted CI, not local runs.
Author-reported tests The PR reports paired focused Vulkan tests passing 3/3 on baseline and change, plus 165/165 LDS/shader tests (2 self-skips). These were not independently run.
Local build/tests Not run; the C++/Vulkan tests require built binaries and GPU execution.
Raw output excerpts

Precheck:

All conventions checks passed.
Head unchanged at completion: True
Base unchanged at completion: True

Fresh stack check:

Target branch tip: `4a58bc29ad656ad7a54c1733b3b683e68b7ccf85`
All heads unchanged: **True**
- PR #14247: **clean** against current base; head `0f8ec048111e27629b48385e46b4e98cf6b3eca3`; changed paths: none reported
No declared PR dependencies were found in the target PR chain.

ABI audit:

ABI audit unavailable: fatal: cannot change to '/marc/AnyPS5/boykopovar/AnyPS5': No such file or directory

Test-quality heuristic:

{
  "findings": [
    {
      "path": "core/libs/prx/libSceAgcDriver/tests/execution/LdsSrc2.cpp",
      "line": 1,
      "kind": "possible-unregistered-cpp-test",
      "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage."
    }
  ],
  "negative_control_candidates": [],
  "limits": [
    "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.",
    "A test that passes against base is not by itself proof that the PR test is inadequate.",
    "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error."
  ]
}

Negative control

Assertion Change in control Result
The src2 float atomics follow the denormal-mode behavior of their existing ds counterparts The author reports removing the two new denormal-flush assignments The focused test reportedly failed with lds src2: min differs from ds_min_f32 in mode 0x00000000; not independently run.

Findings

Blocking: The PR changes the same DS src2 debt entry as open #14085. Its description says whichever lands second will rebase, but does not identify an agreed order, and its checklist says Depends on: none. The repository contribution rule asks authors of overlapping PRs to agree which lands first and record that dependency. Please coordinate with #14085's author and record the agreed order in the checklist.

Non-blocking: No implementation or test-source defect was found in the inspected changes.

Sources

Not verified

No local build, CTest, or GPU validation run was performed. The reported test runs are author-provided, not independently reproduced. Hosted CI was still in progress at the latest status refresh.

To get this to a good state

Coordinate with #14085's author and record which PR lands first. I will recheck the overlap and repeat applicable checks on the updated head.

@github-actions github-actions Bot added the fix error Closes an issue (Fixes #N) label Nov 1, 2026
@StarMrGamer

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I've asked on #14085 whether its author will leave the DS src2 bullet to this PR, the way #14085 left the libSceHttp2.md bullet to #11575. If they agree, Depends on stays none. If they'd rather keep it, I'll set Depends on: #14085 and rebase once it merges. Either way I'll update the checklist.

AI-assisted: yes (Claude Code).

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 12944 docs/dev/debt/shader.md L198-199

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 docs/dev/debt/shader.md
PR 5371 docs/dev/debt/shader.md
PR 6235 docs/dev/debt/shader.md
PR 6280 docs/dev/debt/shader.md
PR 6412 docs/dev/debt/shader.md
PR 6488 docs/dev/debt/shader.md
PR 6924 docs/dev/debt/shader.md
PR 7223 docs/dev/debt/shader.md
PR 7392 docs/dev/debt/shader.md
PR 7410 docs/dev/debt/shader.md
PR 7684 docs/dev/debt/shader.md
PR 8004 docs/dev/debt/shader.md
PR 9020 docs/dev/debt/shader.md
PR 9183 docs/dev/debt/shader.md
PR 9335 docs/dev/debt/shader.md
PR 9387 docs/dev/debt/shader.md
PR 9748 docs/dev/debt/shader.md
PR 10233 docs/dev/debt/shader.md
PR 10652 docs/dev/debt/shader.md
PR 10867 docs/dev/debt/shader.md
PR 10941 docs/dev/debt/shader.md
PR 11483 docs/dev/debt/shader.md
PR 12548 docs/dev/debt/shader.md
PR 14212 docs/dev/debt/shader.md

@github-actions github-actions Bot added shader core/shader docs agc libSceAgc* labels Nov 1, 2026
@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head 0f8ec04 merged onto main 3741ca9 · tested 2026-11-01 05:16 UTC · 28 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,424 passed · 4 failed (0 new, 3 also fail on main, 1 unstable on main) · 44 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 2,472 of 3,121 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 (929 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 47.7 s, ⚠️ agc_driver_graphics_maps_fallback 31.6 s
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)
agc_submit_progress: failed in 6 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 (5 IDs in 480 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (480 tests): agc_driver, 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, agc_driver_bda_span_reads, and 472 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 (1 test): agc_driver_prepared_exports
VUID-VkShaderModuleCreateInfo-pCode-08737 (1 test): agc_driver_image_sample_derivatives
Skipped (44)
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_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_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
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_video_out_color_space: 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_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 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_in_order: 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_dcc: 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_deferred: 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_eop: 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_eop_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_eop_main: 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_fresh: 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_f
Reproduce
git fetch origin 0f8ec048111e27629b48385e46b4e98cf6b3eca3 3741ca9327246d0df81638726a986cef862b6db5
git checkout 3741ca9327246d0df81638726a986cef862b6db5 && git merge --no-ff 0f8ec048111e27629b48385e46b4e98cf6b3eca3
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.

LeandroLP23 added a commit to LeandroLP23/AnyPS5 that referenced this pull request Nov 1, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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* docs fix error Closes an issue (Fixes #N) shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shader: ds_min/max/add_src2_f32 throw for a reason that no longer holds

3 participants