[PR #1869] [MERGED] shader_recompiler: Add swizzle support for unsupported formats. #2358

Closed
opened 2026-02-27 21:16:12 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/1869
Author: @squidbus
Created: 12/25/2024
Status: Merged
Merged: 12/31/2024
Merged by: @georgemoralis

Base: mainHead: swizzle-fmt


📝 Commits (8)

  • 8a006a2 shader_recompiler: Add swizzle support for unsupported formats.
  • 4e6a7e5 renderer_vulkan: Rework MRT swizzles and add unsupported format swizzle support.
  • 070c4af shader_recompiler: Clean up swizzle handling and handle ImageRead storage swizzle.
  • 0fe50e2 shader_recompiler: Fix type errors
  • 4d81b41 liverpool_to_vk: Remove redundant clear color swizzles.
  • 11eb741 shader_recompiler: Reduce CompositeConstruct to constants where possible.
  • 4702b53 shader_recompiler: Fix ImageRead/Write and StoreBufferFormatF32 types.
  • 03e8e99 amdgpu: Add a few more unsupported format remaps.

📊 Changes

22 files changed (+522 additions, -282 deletions)

View changed files

📝 CMakeLists.txt (+1 -0)
📝 src/shader_recompiler/backend/spirv/emit_spirv_composite.cpp (+80 -18)
📝 src/shader_recompiler/backend/spirv/emit_spirv_image.cpp (+3 -3)
📝 src/shader_recompiler/backend/spirv/emit_spirv_instructions.h (+29 -9)
📝 src/shader_recompiler/frontend/translate/export.cpp (+13 -19)
📝 src/shader_recompiler/frontend/translate/translate.cpp (+6 -19)
📝 src/shader_recompiler/frontend/translate/vector_memory.cpp (+2 -2)
📝 src/shader_recompiler/ir/ir_emitter.cpp (+80 -0)
📝 src/shader_recompiler/ir/ir_emitter.h (+7 -0)
📝 src/shader_recompiler/ir/opcodes.inc (+15 -3)
📝 src/shader_recompiler/ir/passes/resource_tracking_pass.cpp (+58 -42)
src/shader_recompiler/ir/reinterpret.h (+24 -0)
📝 src/shader_recompiler/runtime_info.h (+1 -1)
📝 src/shader_recompiler/specialization.h (+3 -7)
📝 src/video_core/amdgpu/liverpool.h (+47 -3)
📝 src/video_core/amdgpu/resource.h (+104 -52)
📝 src/video_core/renderer_vulkan/liverpool_to_vk.cpp (+35 -62)
📝 src/video_core/renderer_vulkan/liverpool_to_vk.h (+4 -3)
📝 src/video_core/renderer_vulkan/vk_graphics_pipeline.h (+1 -1)
📝 src/video_core/renderer_vulkan/vk_pipeline_cache.cpp (+5 -9)

...and 2 more files

📄 Description

Adds in implicit format and swizzle remapping in sharps for formats that are not commonly supported by graphics APIs but can be trivially supported by swapping components. This was the simplest way I arrived at to accomplish this for both non-storage image views and storage swizzles done within the shader, without introducing additional Vulkan-specific code inside the general AMDGPU resource and shader code. I've also left the door open here to remapping number formats, which can then be reinterpreted to the correct format in the shader.

For now this just remaps Format11_11_10 to Format10_11_11 since the former is not supported by Vulkan.

Needs testing with a game that uses this format.


🔄 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/1869 **Author:** [@squidbus](https://github.com/squidbus) **Created:** 12/25/2024 **Status:** ✅ Merged **Merged:** 12/31/2024 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `swizzle-fmt` --- ### 📝 Commits (8) - [`8a006a2`](https://github.com/shadps4-emu/shadPS4/commit/8a006a2bc6aaa57a7d94122abd47ce4e6d9aabe6) shader_recompiler: Add swizzle support for unsupported formats. - [`4e6a7e5`](https://github.com/shadps4-emu/shadPS4/commit/4e6a7e555ebb451406fb982bb199f66a01fd6264) renderer_vulkan: Rework MRT swizzles and add unsupported format swizzle support. - [`070c4af`](https://github.com/shadps4-emu/shadPS4/commit/070c4af208c22e18b6a6a2152de9c3aef3e4f381) shader_recompiler: Clean up swizzle handling and handle ImageRead storage swizzle. - [`0fe50e2`](https://github.com/shadps4-emu/shadPS4/commit/0fe50e281df25bbf51dca57b8c280fd561b5b8c1) shader_recompiler: Fix type errors - [`4d81b41`](https://github.com/shadps4-emu/shadPS4/commit/4d81b414628f865e783e51a5276db93d3a4ee1af) liverpool_to_vk: Remove redundant clear color swizzles. - [`11eb741`](https://github.com/shadps4-emu/shadPS4/commit/11eb7413fbb143a96a4fda71af7c18a7ce0c3399) shader_recompiler: Reduce CompositeConstruct to constants where possible. - [`4702b53`](https://github.com/shadps4-emu/shadPS4/commit/4702b53b9292ce5787075e2ce8c38123bc8e55bc) shader_recompiler: Fix ImageRead/Write and StoreBufferFormatF32 types. - [`03e8e99`](https://github.com/shadps4-emu/shadPS4/commit/03e8e9986f07020dd8b1afd861dc55938a99849d) amdgpu: Add a few more unsupported format remaps. ### 📊 Changes **22 files changed** (+522 additions, -282 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+1 -0) 📝 `src/shader_recompiler/backend/spirv/emit_spirv_composite.cpp` (+80 -18) 📝 `src/shader_recompiler/backend/spirv/emit_spirv_image.cpp` (+3 -3) 📝 `src/shader_recompiler/backend/spirv/emit_spirv_instructions.h` (+29 -9) 📝 `src/shader_recompiler/frontend/translate/export.cpp` (+13 -19) 📝 `src/shader_recompiler/frontend/translate/translate.cpp` (+6 -19) 📝 `src/shader_recompiler/frontend/translate/vector_memory.cpp` (+2 -2) 📝 `src/shader_recompiler/ir/ir_emitter.cpp` (+80 -0) 📝 `src/shader_recompiler/ir/ir_emitter.h` (+7 -0) 📝 `src/shader_recompiler/ir/opcodes.inc` (+15 -3) 📝 `src/shader_recompiler/ir/passes/resource_tracking_pass.cpp` (+58 -42) ➕ `src/shader_recompiler/ir/reinterpret.h` (+24 -0) 📝 `src/shader_recompiler/runtime_info.h` (+1 -1) 📝 `src/shader_recompiler/specialization.h` (+3 -7) 📝 `src/video_core/amdgpu/liverpool.h` (+47 -3) 📝 `src/video_core/amdgpu/resource.h` (+104 -52) 📝 `src/video_core/renderer_vulkan/liverpool_to_vk.cpp` (+35 -62) 📝 `src/video_core/renderer_vulkan/liverpool_to_vk.h` (+4 -3) 📝 `src/video_core/renderer_vulkan/vk_graphics_pipeline.h` (+1 -1) 📝 `src/video_core/renderer_vulkan/vk_pipeline_cache.cpp` (+5 -9) _...and 2 more files_ </details> ### 📄 Description Adds in implicit format and swizzle remapping in sharps for formats that are not commonly supported by graphics APIs but can be trivially supported by swapping components. This was the simplest way I arrived at to accomplish this for both non-storage image views and storage swizzles done within the shader, without introducing additional Vulkan-specific code inside the general AMDGPU resource and shader code. I've also left the door open here to remapping number formats, which can then be reinterpreted to the correct format in the shader. For now this just remaps `Format11_11_10` to `Format10_11_11` since the former is not supported by Vulkan. Needs testing with a game that uses this format. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 21:16:12 +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#2358
No description provided.