[PR #2739] [MERGED] shader_recompiler: Use VK_AMD_shader_trinary_minmax when available. #2945

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

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/2739
Author: @squidbus
Created: 4/1/2025
Status: Merged
Merged: 4/2/2025
Merged by: @raphaelthegreat

Base: mainHead: trinary


📝 Commits (2)

  • 8e56bba shader_recompiler: Use VK_AMD_shader_trinary_minmax when available.
  • 81b290a shader_recompiler: Simplify signed/unsigned trinary instruction variants.

📊 Changes

13 files changed (+168 additions, -34 deletions)

View changed files

📝 externals/sirit (+1 -1)
📝 src/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp (+22 -0)
📝 src/shader_recompiler/backend/spirv/emit_spirv_instructions.h (+9 -0)
📝 src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp (+44 -0)
📝 src/shader_recompiler/frontend/translate/translate.h (+2 -4)
📝 src/shader_recompiler/frontend/translate/vector_alu.cpp (+12 -29)
📝 src/shader_recompiler/ir/ir_emitter.cpp (+48 -0)
📝 src/shader_recompiler/ir/ir_emitter.h (+12 -0)
📝 src/shader_recompiler/ir/opcodes.inc (+9 -0)
📝 src/shader_recompiler/profile.h (+1 -0)
📝 src/video_core/renderer_vulkan/vk_instance.cpp (+1 -0)
📝 src/video_core/renderer_vulkan/vk_instance.h (+6 -0)
📝 src/video_core/renderer_vulkan/vk_pipeline_cache.cpp (+1 -0)

📄 Description

Implements use of VK_AMD_shader_trinary_minmax instructions for trinary min/max/median when available. Specifically this PR introduces separate IR instructions for these trinary operations, then determines whether to emit a trinary instruction or a compatibility fill based on what is available. This should reduce the number of instructions needed and possibly improve performance on supported drivers.

Note that these new IR instructions are named with the Tri suffix for trinary to avoid awkward naming with numbers like FPMin332 when the bit suffix is added.

Tested this with a few games on MoltenVK, which supports this extension.


🔄 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/2739 **Author:** [@squidbus](https://github.com/squidbus) **Created:** 4/1/2025 **Status:** ✅ Merged **Merged:** 4/2/2025 **Merged by:** [@raphaelthegreat](https://github.com/raphaelthegreat) **Base:** `main` ← **Head:** `trinary` --- ### 📝 Commits (2) - [`8e56bba`](https://github.com/shadps4-emu/shadPS4/commit/8e56bba04169ad3d4648bb0ba33099e85e8185d6) shader_recompiler: Use VK_AMD_shader_trinary_minmax when available. - [`81b290a`](https://github.com/shadps4-emu/shadPS4/commit/81b290a0694905f30d318330f169b223502ea694) shader_recompiler: Simplify signed/unsigned trinary instruction variants. ### 📊 Changes **13 files changed** (+168 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `externals/sirit` (+1 -1) 📝 `src/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp` (+22 -0) 📝 `src/shader_recompiler/backend/spirv/emit_spirv_instructions.h` (+9 -0) 📝 `src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp` (+44 -0) 📝 `src/shader_recompiler/frontend/translate/translate.h` (+2 -4) 📝 `src/shader_recompiler/frontend/translate/vector_alu.cpp` (+12 -29) 📝 `src/shader_recompiler/ir/ir_emitter.cpp` (+48 -0) 📝 `src/shader_recompiler/ir/ir_emitter.h` (+12 -0) 📝 `src/shader_recompiler/ir/opcodes.inc` (+9 -0) 📝 `src/shader_recompiler/profile.h` (+1 -0) 📝 `src/video_core/renderer_vulkan/vk_instance.cpp` (+1 -0) 📝 `src/video_core/renderer_vulkan/vk_instance.h` (+6 -0) 📝 `src/video_core/renderer_vulkan/vk_pipeline_cache.cpp` (+1 -0) </details> ### 📄 Description Implements use of `VK_AMD_shader_trinary_minmax` instructions for trinary min/max/median when available. Specifically this PR introduces separate IR instructions for these trinary operations, then determines whether to emit a trinary instruction or a compatibility fill based on what is available. This should reduce the number of instructions needed and possibly improve performance on supported drivers. Note that these new IR instructions are named with the `Tri` suffix for trinary to avoid awkward naming with numbers like `FPMin332` when the bit suffix is added. Tested this with a few games on MoltenVK, which supports this extension. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 22:01:52 +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#2945
No description provided.