gl_shader_decompiler: Correct gl_FragCoord.x/y when render target is rescaled
This commit is contained in:
committed by
FernandoS27
parent
a9f741ac6e
commit
e2c76c4064
@@ -651,7 +651,7 @@ void RasterizerOpenGL::DrawPrelude() {
|
||||
SyncViewport(state, res_scaling);
|
||||
SyncScissorTest(state, res_scaling);
|
||||
|
||||
shader_program_manager->SetConstants(gpu);
|
||||
shader_program_manager->SetConstants(gpu, res_scaling);
|
||||
shader_program_manager->ApplyTo(state);
|
||||
state.Apply();
|
||||
|
||||
|
||||
@@ -943,12 +943,20 @@ private:
|
||||
case Attribute::Index::Position:
|
||||
switch (stage) {
|
||||
case ProgramType::Geometry:
|
||||
return {fmt::format("gl_in[{}].gl_Position{}", Visit(buffer).AsUint(),
|
||||
GetSwizzle(element)),
|
||||
Type::Float};
|
||||
case ProgramType::Fragment:
|
||||
return {element == 3 ? "1.0f" : ("gl_FragCoord"s + GetSwizzle(element)),
|
||||
Type::Float};
|
||||
return fmt::format("gl_in[{}].gl_Position{}", Visit(buffer).AsUint(),
|
||||
GetSwizzle(element));
|
||||
case ProgramType::Fragment: {
|
||||
switch (element) {
|
||||
case 0:
|
||||
return "(gl_FragCoord.x / utof(config_pack[3]))";
|
||||
case 1:
|
||||
return "(gl_FragCoord.y / utof(config_pack[3]))";
|
||||
case 2:
|
||||
return "gl_FragCoord.z";
|
||||
case 3:
|
||||
return "1.0f";
|
||||
}
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <array>
|
||||
#include "common/common_types.h"
|
||||
#include "core/settings.h"
|
||||
#include "video_core/engines/maxwell_3d.h"
|
||||
#include "video_core/renderer_opengl/gl_shader_manager.h"
|
||||
|
||||
@@ -37,7 +38,7 @@ ProgramManager::ProgramManager() {
|
||||
|
||||
ProgramManager::~ProgramManager() = default;
|
||||
|
||||
void ProgramManager::SetConstants(Tegra::Engines::Maxwell3D& maxwell_3d) {
|
||||
void ProgramManager::SetConstants(Tegra::Engines::Maxwell3D& maxwell_3d, bool rescaling) {
|
||||
const auto& regs = maxwell_3d.regs;
|
||||
const auto& state = maxwell_3d.state;
|
||||
|
||||
@@ -61,6 +62,8 @@ void ProgramManager::SetConstants(Tegra::Engines::Maxwell3D& maxwell_3d) {
|
||||
// Y_NEGATE controls what value S2R returns for the Y_DIRECTION system value.
|
||||
const GLfloat y_direction = regs.screen_y_control.y_negate == 0 ? 1.0f : -1.0f;
|
||||
|
||||
const GLfloat rescale_factor = rescaling ? Settings::values.resolution_factor : 1.0f;
|
||||
|
||||
for (const auto stage :
|
||||
std::array{current_state.vertex, current_state.geometry, current_state.fragment}) {
|
||||
if (!stage) {
|
||||
@@ -70,6 +73,7 @@ void ProgramManager::SetConstants(Tegra::Engines::Maxwell3D& maxwell_3d) {
|
||||
stage->SetFlipStage(flip_stage);
|
||||
stage->SetYDirection(y_direction);
|
||||
stage->SetViewportScale(flip_x, flip_y);
|
||||
stage->SetRescalingFactor(rescale_factor);
|
||||
stage->UpdateConstants();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,10 @@ public:
|
||||
state.y_direction = y_direction;
|
||||
}
|
||||
|
||||
void SetRescalingFactor(GLfloat rescaling_factor) {
|
||||
state.rescaling_factor = rescaling_factor;
|
||||
}
|
||||
|
||||
void SetViewportScale(GLfloat x, GLfloat y) {
|
||||
state.viewport_scale = {x, y};
|
||||
}
|
||||
@@ -52,6 +56,7 @@ private:
|
||||
GLuint instance_id;
|
||||
GLuint flip_stage;
|
||||
GLfloat y_direction;
|
||||
GLfloat rescaling_factor;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -67,7 +72,7 @@ public:
|
||||
explicit ProgramManager();
|
||||
~ProgramManager();
|
||||
|
||||
void SetConstants(Tegra::Engines::Maxwell3D& maxwell_3d);
|
||||
void SetConstants(Tegra::Engines::Maxwell3D& maxwell_3d, bool rescaling);
|
||||
|
||||
void ApplyTo(OpenGLState& state);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user