mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-26 00:05:58 +03:00
[PR #1644] [MERGED] shader_recompiler: Implement manual barycentric interpolation path #2221
Labels
No labels
Bloodborne
bug
contributor wanted
documentation
enhancement
frontend
good first issue
help wanted
linux
pull-request
question
release
verification progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/shadPS4#2221
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/shadps4-emu/shadPS4/pull/1644
Author: @raphaelthegreat
Created: 12/1/2024
Status: ✅ Merged
Merged: 12/2/2024
Merged by: @raphaelthegreat
Base:
main← Head:bary-fix📝 Commits (5)
77cfdb1shader_recompiler: Implement manual barycentric interpolation path84d745fclang formata9798d0emit_spirv: Fix typo83de6b7emit_spirv: Simplify variable definitionb775f47spirv_emit: clang format📊 Changes
9 files changed (+128 additions, -57 deletions)
View changed files
📝
src/shader_recompiler/backend/spirv/emit_spirv.cpp(+6 -2)📝
src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp(+44 -41)📝
src/shader_recompiler/backend/spirv/emit_spirv_special.cpp(+3 -0)📝
src/shader_recompiler/backend/spirv/spirv_emit_context.cpp(+54 -13)📝
src/shader_recompiler/backend/spirv/spirv_emit_context.h(+6 -1)📝
src/shader_recompiler/profile.h(+1 -0)📝
src/video_core/renderer_vulkan/vk_instance.cpp(+7 -0)📝
src/video_core/renderer_vulkan/vk_instance.h(+5 -0)📝
src/video_core/renderer_vulkan/vk_pipeline_cache.cpp(+2 -0)📄 Description
Credits to @vladmikhalin for initially investigating this issue.
In some areas in Bloodborne some instanced objects can have noticeable flicker, specifically on Nvidia GPUs, when moving in relation to them. This is hard to show in plain screenshots so I've recorded a video.
https://github.com/user-attachments/assets/be057dc6-013b-4fc7-98a2-588710c83ddd
This is because the shader used for rendering those objects passes the gl_InstanceIndex to the fragment shader using varying float attributes instead of a flat integer attribute. Nvidia has a different interpolation method compared to AMD hw, so 3 identical floats aren't interpolated to exactly the same value, which causes the instance index to get truncated to zero for some pixels and to one for others. This problem is also noted on other emulators like Xenia and RPCS3. To fix this we use the VK_KHR_fragment_shader_barycentric extension to manually interpolate the attributes according to the 2 step AMD formula (credit to Triang3l for providing the appropriate formula in their issue). This is only applied on Nvidia drivers that support the extension, which means Turing and newer GPUs. If your GPU is older than that you are probably out of luck.
https://github.com/user-attachments/assets/f7259e86-5691-457f-ab4b-2ee7764ed4d1
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.