[PR #2083] [MERGED] shader_recompiler: Improvements to array and cube handling. #2479

Closed
opened 2026-02-27 22:00:04 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/2083
Author: @squidbus
Created: 1/7/2025
Status: Merged
Merged: 1/10/2025
Merged by: @georgemoralis

Base: mainHead: fix-array


📝 Commits (6)

  • c05e48b shader_recompiler: Account for instruction array flag in image type.
  • 120e6ea shader_recompiler: Check da flag for all mimg instructions.
  • 501b921 shader_recompiler: Convert cube images into 2D arrays.
  • 40d3521 shader_recompiler: Move image resource functions into sharp type.
  • 3a7b2bf shader_recompiler: Use native AMD cube instructions when possible.
  • 2df4f24 specialization: Fix buffer storage mistake.

📊 Changes

28 files changed (+217 additions, -144 deletions)

View changed files

📝 externals/sirit (+1 -1)
📝 src/shader_recompiler/backend/spirv/emit_spirv_image.cpp (+19 -4)
📝 src/shader_recompiler/backend/spirv/emit_spirv_instructions.h (+2 -0)
📝 src/shader_recompiler/backend/spirv/spirv_emit_context.cpp (+4 -6)
📝 src/shader_recompiler/backend/spirv/spirv_emit_context.h (+1 -0)
📝 src/shader_recompiler/frontend/translate/translate.h (+3 -0)
📝 src/shader_recompiler/frontend/translate/vector_alu.cpp (+77 -4)
📝 src/shader_recompiler/frontend/translate/vector_memory.cpp (+25 -12)
📝 src/shader_recompiler/info.h (+0 -6)
📝 src/shader_recompiler/ir/ir_emitter.cpp (+8 -5)
📝 src/shader_recompiler/ir/ir_emitter.h (+3 -2)
📝 src/shader_recompiler/ir/opcodes.inc (+4 -0)
📝 src/shader_recompiler/ir/passes/resource_tracking_pass.cpp (+4 -42)
📝 src/shader_recompiler/ir/passes/shader_info_collection_pass.cpp (+1 -1)
📝 src/shader_recompiler/profile.h (+1 -0)
📝 src/shader_recompiler/specialization.h (+2 -2)
📝 src/video_core/amdgpu/resource.h (+41 -15)
📝 src/video_core/renderer_vulkan/vk_compute_pipeline.cpp (+2 -3)
📝 src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp (+2 -3)
📝 src/video_core/renderer_vulkan/vk_instance.cpp (+1 -0)

...and 8 more files

📄 Description

Enhances handling of array and cube images:

  • Image sharps may have an array type, but in the actual shader the image is accessed with the array flag not set. In this case we should override the image to the proper non-array variant and avoid indexing as an array.
    • Fixes missing rendering in CUSA28193. Multiple shaders would have a 2D texture array bound but address it as a single layer, with the register used for the array index being invalid.
  • Handles array flag for all MIMG instructions instead of just sampling instructions.
  • Converts cubes to 2D arrays. This helps deal with cases where layers are not a multiple of 6 for whatever reason, and also enables derivatives and offsets on cube images, which are not possible with Vulkan cube images.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/shadps4-emu/shadPS4/pull/2083 **Author:** [@squidbus](https://github.com/squidbus) **Created:** 1/7/2025 **Status:** ✅ Merged **Merged:** 1/10/2025 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `fix-array` --- ### 📝 Commits (6) - [`c05e48b`](https://github.com/shadps4-emu/shadPS4/commit/c05e48becbcd94ace3eb8d21a036b1f6430fd88f) shader_recompiler: Account for instruction array flag in image type. - [`120e6ea`](https://github.com/shadps4-emu/shadPS4/commit/120e6ea28f5f1571a6d52230ec30690ec8ff1924) shader_recompiler: Check da flag for all mimg instructions. - [`501b921`](https://github.com/shadps4-emu/shadPS4/commit/501b921e490bbe81bd9040bab5b54f0224ea8a2c) shader_recompiler: Convert cube images into 2D arrays. - [`40d3521`](https://github.com/shadps4-emu/shadPS4/commit/40d35211a35cda3d2fd5e6efce3e9203fb82292b) shader_recompiler: Move image resource functions into sharp type. - [`3a7b2bf`](https://github.com/shadps4-emu/shadPS4/commit/3a7b2bf948a74d37c166d9c5af7084f28c5ce7dd) shader_recompiler: Use native AMD cube instructions when possible. - [`2df4f24`](https://github.com/shadps4-emu/shadPS4/commit/2df4f24987e938a0e85ba05013e7a6c90c66de87) specialization: Fix buffer storage mistake. ### 📊 Changes **28 files changed** (+217 additions, -144 deletions) <details> <summary>View changed files</summary> 📝 `externals/sirit` (+1 -1) 📝 `src/shader_recompiler/backend/spirv/emit_spirv_image.cpp` (+19 -4) 📝 `src/shader_recompiler/backend/spirv/emit_spirv_instructions.h` (+2 -0) 📝 `src/shader_recompiler/backend/spirv/spirv_emit_context.cpp` (+4 -6) 📝 `src/shader_recompiler/backend/spirv/spirv_emit_context.h` (+1 -0) 📝 `src/shader_recompiler/frontend/translate/translate.h` (+3 -0) 📝 `src/shader_recompiler/frontend/translate/vector_alu.cpp` (+77 -4) 📝 `src/shader_recompiler/frontend/translate/vector_memory.cpp` (+25 -12) 📝 `src/shader_recompiler/info.h` (+0 -6) 📝 `src/shader_recompiler/ir/ir_emitter.cpp` (+8 -5) 📝 `src/shader_recompiler/ir/ir_emitter.h` (+3 -2) 📝 `src/shader_recompiler/ir/opcodes.inc` (+4 -0) 📝 `src/shader_recompiler/ir/passes/resource_tracking_pass.cpp` (+4 -42) 📝 `src/shader_recompiler/ir/passes/shader_info_collection_pass.cpp` (+1 -1) 📝 `src/shader_recompiler/profile.h` (+1 -0) 📝 `src/shader_recompiler/specialization.h` (+2 -2) 📝 `src/video_core/amdgpu/resource.h` (+41 -15) 📝 `src/video_core/renderer_vulkan/vk_compute_pipeline.cpp` (+2 -3) 📝 `src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp` (+2 -3) 📝 `src/video_core/renderer_vulkan/vk_instance.cpp` (+1 -0) _...and 8 more files_ </details> ### 📄 Description Enhances handling of array and cube images: * Image sharps may have an array type, but in the actual shader the image is accessed with the array flag not set. In this case we should override the image to the proper non-array variant and avoid indexing as an array. * Fixes missing rendering in CUSA28193. Multiple shaders would have a 2D texture array bound but address it as a single layer, with the register used for the array index being invalid. * Handles array flag for all MIMG instructions instead of just sampling instructions. * Converts cubes to 2D arrays. This helps deal with cases where layers are not a multiple of 6 for whatever reason, and also enables derivatives and offsets on cube images, which are not possible with Vulkan cube images. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 22:00:04 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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
starred/shadPS4#2479
No description provided.