Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vk: Promote barycentric interpolation to 64-bit #13690

Merged
merged 2 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 28 additions & 12 deletions rpcs3/Emu/RSX/Program/GLSLCommon.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#include "stdafx.h"
#include "Utilities/StrFmt.h"

#include "GLSLCommon.h"
#include "RSXFragmentProgram.h"

#include "../gcm_enums.h"
#include "Emu/system_config.h"
#include "Emu/RSX/gcm_enums.h"
#include "Utilities/StrFmt.h"

namespace program_common
{
Expand Down Expand Up @@ -1245,16 +1246,31 @@ namespace glsl

// Interpolate the input attributes manually.
// Matches AMD behavior where gl_BaryCoordSmoothAMD only provides x and y with z being autogenerated.
OS << fmt::replace_all(
"\n"
"vec4 _interpolate_varying3(const in vec4[3] v)\n"
"{\n"
" const float _gl_BaryCoord_z = 1.0 - ($gl_BaryCoord.x + $gl_BaryCoord.y);\n"
" return $gl_BaryCoord.x * v[0] + $gl_BaryCoord.y * v[1] + _gl_BaryCoord_z * v[2];\n"
"}\n\n",
{
{ "$gl_BaryCoord", "gl_BaryCoord"s + std::string(ext_flavour) }
});
std::string interpolate_function_block;
if (g_cfg.video.shader_precision == gpu_preset_level::ultra)
{
interpolate_function_block =
"\n"
"vec4 _interpolate_varying3(const in vec4[3] v)\n"
"{\n"
" const double _gl_BaryCoord_x = double($gl_BaryCoord.x);\n"
" const double _gl_BaryCoord_y = double($gl_BaryCoord.y);\n"
" const double _gl_BaryCoord_z = double(1.0) - (_gl_BaryCoord_x + _gl_BaryCoord_y);\n"
" return vec4(_gl_BaryCoord_x * v[0] + _gl_BaryCoord_y * v[1] + _gl_BaryCoord_z * v[2]);\n"
"}\n\n";
}
else
{
interpolate_function_block =
"\n"
"vec4 _interpolate_varying3(const in vec4[3] v)\n"
"{\n"
" vec3 _gl_BaryCoord = vec3($gl_BaryCoord.xy, 1.f);\n"
" _gl_BaryCoord.z = dot(_gl_BaryCoord, vec3(-1.f, -1.f, 1.f));\n"
" return vec4(_gl_BaryCoord.x * v[0] + _gl_BaryCoord.y * v[1] + _gl_BaryCoord.z * v[2]);\n"
"}\n\n";
}
OS << fmt::replace_all(interpolate_function_block, {{ "$gl_BaryCoord", "gl_BaryCoord"s + std::string(ext_flavour) }});

for (const auto& reg : varying_list)
{
Expand Down
1 change: 1 addition & 0 deletions rpcs3/Emu/system_config_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ void fmt_class_string<gpu_preset_level>::format(std::string& out, u64 arg)
switch (value)
{
case gpu_preset_level::_auto: return "Auto";
case gpu_preset_level::ultra: return "Ultra";
case gpu_preset_level::high: return "High";
case gpu_preset_level::low: return "Low";
}
Expand Down
1 change: 1 addition & 0 deletions rpcs3/Emu/system_config_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ enum class zcull_precision_level

enum class gpu_preset_level
{
ultra,
high,
low,
_auto
Expand Down
1 change: 1 addition & 0 deletions rpcs3/rpcs3qt/emu_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@ QString emu_settings::GetLocalizedSetting(const QString& original, emu_settings_
switch (static_cast<gpu_preset_level>(index))
{
case gpu_preset_level::_auto: return tr("Auto", "Shader Precision");
case gpu_preset_level::ultra: return tr("Ultra", "Shader Precision");
case gpu_preset_level::high: return tr("High", "Shader Precision");
case gpu_preset_level::low: return tr("Low", "Shader Precision");
}
Expand Down