[PR #3245] [MERGED] shader_recompiler: Implement guest barycentrics #3335

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

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/3245
Author: @raphaelthegreat
Created: 7/15/2025
Status: Merged
Merged: 7/15/2025
Merged by: @georgemoralis

Base: mainHead: barycentrics


📝 Commits (2)

  • 3b0d08c shader_recompiler: Implement guest barycentrics
  • f3e2d98 Review comments and some cleanup

📊 Changes

17 files changed (+314 additions, -229 deletions)

View changed files

📝 externals/sirit (+1 -1)
📝 src/shader_recompiler/backend/spirv/emit_spirv.cpp (+11 -3)
📝 src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp (+46 -66)
📝 src/shader_recompiler/backend/spirv/emit_spirv_special.cpp (+1 -1)
📝 src/shader_recompiler/backend/spirv/spirv_emit_context.cpp (+77 -78)
📝 src/shader_recompiler/backend/spirv/spirv_emit_context.h (+10 -5)
📝 src/shader_recompiler/frontend/translate/translate.cpp (+32 -31)
📝 src/shader_recompiler/frontend/translate/translate.h (+2 -3)
📝 src/shader_recompiler/frontend/translate/vector_interpolation.cpp (+67 -8)
📝 src/shader_recompiler/info.h (+16 -3)
📝 src/shader_recompiler/ir/attribute.cpp (+14 -0)
📝 src/shader_recompiler/ir/attribute.h (+14 -22)
📝 src/shader_recompiler/profile.h (+3 -6)
📝 src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp (+2 -1)
📝 src/video_core/renderer_vulkan/vk_instance.cpp (+6 -1)
📝 src/video_core/renderer_vulkan/vk_instance.h (+6 -0)
📝 src/video_core/renderer_vulkan/vk_pipeline_cache.cpp (+6 -0)

📄 Description

This is second part of attribute restructuring and aims to do the following:

  • Further cleanup and de-duplicate attribute handling code
  • Move as much logic into IR level (such as manual interpolation)
  • Implement manual interpolation on the guest shader

For the first goal the following changes are included:

  • De-duplicated access to TessellationEvaluationPointU/V
  • Removed frag_outputs in favor of output_params as they are the same thing
  • Make usage of GetAttributeInfo consistent everywhere
  • Implement remaining attribute qualifiers such as centroid and sample
  • Implement reading of param array attributes to merge geometry shader special path

The last change is important as it allows for the second goal, moving the manual interpolation NVIDIA path into IR. GCN ISA has special instructions V_INTERP_P1_F32/V_INTERP_P2_F32 for interpolating attributes and those can be used to implement that path.

Manual interpolation also requires the IR to become aware of barycentric coordinate variables. In case of an AMD host GPU, the VK_AMD_shader_explicit_vertex_parameter extension has been added, which maps 1-1 to guest functionality. For NVIDIA and other platforms the fragment barycentric extension can also provide most of the functionality necessary (though needs a small remap of barycentric coord). If barycentrics are not supported at all, frontend will request a flat qualifier instead, which is a fallback to previous behavior.

This fixes the menu screen of The Order 1886 for both AMD and NVIDIA GPUs (though reaching the title screen technically requires https://github.com/shadps4-emu/shadPS4/pull/3020 which only works on AMD properly. Regardless I have verified it on NVIDIA as well)


🔄 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/3245 **Author:** [@raphaelthegreat](https://github.com/raphaelthegreat) **Created:** 7/15/2025 **Status:** ✅ Merged **Merged:** 7/15/2025 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `barycentrics` --- ### 📝 Commits (2) - [`3b0d08c`](https://github.com/shadps4-emu/shadPS4/commit/3b0d08c7306ad900094e5a6960d4a26fcdd81660) shader_recompiler: Implement guest barycentrics - [`f3e2d98`](https://github.com/shadps4-emu/shadPS4/commit/f3e2d985f7932788ea2bfae07caf0ece539bd562) Review comments and some cleanup ### 📊 Changes **17 files changed** (+314 additions, -229 deletions) <details> <summary>View changed files</summary> 📝 `externals/sirit` (+1 -1) 📝 `src/shader_recompiler/backend/spirv/emit_spirv.cpp` (+11 -3) 📝 `src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp` (+46 -66) 📝 `src/shader_recompiler/backend/spirv/emit_spirv_special.cpp` (+1 -1) 📝 `src/shader_recompiler/backend/spirv/spirv_emit_context.cpp` (+77 -78) 📝 `src/shader_recompiler/backend/spirv/spirv_emit_context.h` (+10 -5) 📝 `src/shader_recompiler/frontend/translate/translate.cpp` (+32 -31) 📝 `src/shader_recompiler/frontend/translate/translate.h` (+2 -3) 📝 `src/shader_recompiler/frontend/translate/vector_interpolation.cpp` (+67 -8) 📝 `src/shader_recompiler/info.h` (+16 -3) 📝 `src/shader_recompiler/ir/attribute.cpp` (+14 -0) 📝 `src/shader_recompiler/ir/attribute.h` (+14 -22) 📝 `src/shader_recompiler/profile.h` (+3 -6) 📝 `src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp` (+2 -1) 📝 `src/video_core/renderer_vulkan/vk_instance.cpp` (+6 -1) 📝 `src/video_core/renderer_vulkan/vk_instance.h` (+6 -0) 📝 `src/video_core/renderer_vulkan/vk_pipeline_cache.cpp` (+6 -0) </details> ### 📄 Description This is second part of attribute restructuring and aims to do the following: * Further cleanup and de-duplicate attribute handling code * Move as much logic into IR level (such as manual interpolation) * Implement manual interpolation on the guest shader For the first goal the following changes are included: * De-duplicated access to TessellationEvaluationPointU/V * ~~Removed frag_outputs in favor of output_params as they are the same thing~~ * Make usage of GetAttributeInfo consistent everywhere * Implement remaining attribute qualifiers such as centroid and sample * Implement reading of param array attributes to merge geometry shader special path The last change is important as it allows for the second goal, moving the manual interpolation NVIDIA path into IR. GCN ISA has special instructions V_INTERP_P1_F32/V_INTERP_P2_F32 for interpolating attributes and those can be used to implement that path. Manual interpolation also requires the IR to become aware of barycentric coordinate variables. In case of an AMD host GPU, the VK_AMD_shader_explicit_vertex_parameter extension has been added, which maps 1-1 to guest functionality. For NVIDIA and other platforms the fragment barycentric extension can also provide most of the functionality necessary (though needs a small remap of barycentric coord). If barycentrics are not supported at all, frontend will request a flat qualifier instead, which is a fallback to previous behavior. This fixes the menu screen of The Order 1886 for both AMD and NVIDIA GPUs (though reaching the title screen technically requires https://github.com/shadps4-emu/shadPS4/pull/3020 which only works on AMD properly. Regardless I have verified it on NVIDIA as well) --- <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:19 +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#3335
No description provided.