[PR #3447] [MERGED] shader_recompiler: Improve shader exports accuracy (part 1) #3474

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

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/3447
Author: @raphaelthegreat
Created: 8/23/2025
Status: Merged
Merged: 8/23/2025
Merged by: @squidbus

Base: mainHead: comp_swap


📝 Commits (3)

  • c8ed5c2 video_core: support for RT layer outputs
  • 4985d7f export: Rework render target exports
  • 0c2fe89 vk_pipeline_cache: Apply swizzle to write masks

📊 Changes

17 files changed (+286 additions, -272 deletions)

View changed files

📝 src/shader_recompiler/backend/spirv/emit_spirv.cpp (+3 -0)
📝 src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp (+15 -51)
📝 src/shader_recompiler/backend/spirv/spirv_emit_context.cpp (+19 -28)
📝 src/shader_recompiler/backend/spirv/spirv_emit_context.h (+2 -0)
📝 src/shader_recompiler/frontend/translate/export.cpp (+87 -121)
📝 src/shader_recompiler/frontend/translate/translate.h (+1 -7)
📝 src/shader_recompiler/info.h (+1 -0)
📝 src/shader_recompiler/ir/passes/ring_access_elimination.cpp (+7 -5)
📝 src/shader_recompiler/ir/passes/shader_info_collection_pass.cpp (+4 -0)
src/shader_recompiler/ir/position.h (+53 -0)
📝 src/shader_recompiler/runtime_info.h (+8 -6)
📝 src/video_core/amdgpu/pixel_format.h (+11 -6)
📝 src/video_core/renderer_vulkan/vk_instance.cpp (+1 -0)
📝 src/video_core/renderer_vulkan/vk_pipeline_cache.cpp (+64 -47)
📝 src/video_core/renderer_vulkan/vk_rasterizer.cpp (+7 -0)
📝 src/video_core/renderer_vulkan/vk_scheduler.cpp (+2 -1)
📝 src/video_core/renderer_vulkan/vk_scheduler.h (+1 -0)

📄 Description

This includes 2 changes

  • Rebased version of https://github.com/shadps4-emu/shadPS4/pull/3226. The code there is relevant to the file being refactored so it would cause more conflict. It's also an effort to prevent that PR from code-rotting a second time

  • MRT swizzle is now applied to the color vector instead of the destination channels. This appears more accurate to what hardware does, I've also written an example in the commit description of a broken output because of it.

This is part 1 because this code also needs fixes to account for broken blending. The comp_swap swizzle is applied after blending on hardware, so swizzling shader output can break blending step because it swaps its inputs. In most cases when no swizzle is applied or simple BGR swizzles it's okay but when alpha and RGB components are swapped (e.g ARGB) it doesn't work, and iirc this affects some effects in Knack.

That probably needs to implement blending step in software with fragment shader interlock which is a big change in itself


🔄 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/3447 **Author:** [@raphaelthegreat](https://github.com/raphaelthegreat) **Created:** 8/23/2025 **Status:** ✅ Merged **Merged:** 8/23/2025 **Merged by:** [@squidbus](https://github.com/squidbus) **Base:** `main` ← **Head:** `comp_swap` --- ### 📝 Commits (3) - [`c8ed5c2`](https://github.com/shadps4-emu/shadPS4/commit/c8ed5c2822e6e66fb316ad832ec8a1f84b7ce656) video_core: support for RT layer outputs - [`4985d7f`](https://github.com/shadps4-emu/shadPS4/commit/4985d7faaa5051a6e9a9c28553cddfb9f35b332a) export: Rework render target exports - [`0c2fe89`](https://github.com/shadps4-emu/shadPS4/commit/0c2fe896f12225547443d93b5f1f4f570ba3523a) vk_pipeline_cache: Apply swizzle to write masks ### 📊 Changes **17 files changed** (+286 additions, -272 deletions) <details> <summary>View changed files</summary> 📝 `src/shader_recompiler/backend/spirv/emit_spirv.cpp` (+3 -0) 📝 `src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp` (+15 -51) 📝 `src/shader_recompiler/backend/spirv/spirv_emit_context.cpp` (+19 -28) 📝 `src/shader_recompiler/backend/spirv/spirv_emit_context.h` (+2 -0) 📝 `src/shader_recompiler/frontend/translate/export.cpp` (+87 -121) 📝 `src/shader_recompiler/frontend/translate/translate.h` (+1 -7) 📝 `src/shader_recompiler/info.h` (+1 -0) 📝 `src/shader_recompiler/ir/passes/ring_access_elimination.cpp` (+7 -5) 📝 `src/shader_recompiler/ir/passes/shader_info_collection_pass.cpp` (+4 -0) ➕ `src/shader_recompiler/ir/position.h` (+53 -0) 📝 `src/shader_recompiler/runtime_info.h` (+8 -6) 📝 `src/video_core/amdgpu/pixel_format.h` (+11 -6) 📝 `src/video_core/renderer_vulkan/vk_instance.cpp` (+1 -0) 📝 `src/video_core/renderer_vulkan/vk_pipeline_cache.cpp` (+64 -47) 📝 `src/video_core/renderer_vulkan/vk_rasterizer.cpp` (+7 -0) 📝 `src/video_core/renderer_vulkan/vk_scheduler.cpp` (+2 -1) 📝 `src/video_core/renderer_vulkan/vk_scheduler.h` (+1 -0) </details> ### 📄 Description This includes 2 changes * Rebased version of https://github.com/shadps4-emu/shadPS4/pull/3226. The code there is relevant to the file being refactored so it would cause more conflict. It's also an effort to prevent that PR from code-rotting a second time * MRT swizzle is now applied to the color vector instead of the destination channels. This appears more accurate to what hardware does, I've also written an example in the commit description of a broken output because of it. This is part 1 because this code also needs fixes to account for broken blending. The comp_swap swizzle is applied after blending on hardware, so swizzling shader output can break blending step because it swaps its inputs. In most cases when no swizzle is applied or simple BGR swizzles it's okay but when alpha and RGB components are swapped (e.g ARGB) it doesn't work, and iirc this affects some effects in Knack. That probably needs to implement blending step in software with fragment shader interlock which is a big change in itself --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 22:03:50 +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#3474
No description provided.