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);
|
SyncViewport(state, res_scaling);
|
||||||
SyncScissorTest(state, res_scaling);
|
SyncScissorTest(state, res_scaling);
|
||||||
|
|
||||||
shader_program_manager->SetConstants(gpu);
|
shader_program_manager->SetConstants(gpu, res_scaling);
|
||||||
shader_program_manager->ApplyTo(state);
|
shader_program_manager->ApplyTo(state);
|
||||||
state.Apply();
|
state.Apply();
|
||||||
|
|
||||||
|
|||||||
@@ -943,12 +943,20 @@ private:
|
|||||||
case Attribute::Index::Position:
|
case Attribute::Index::Position:
|
||||||
switch (stage) {
|
switch (stage) {
|
||||||
case ProgramType::Geometry:
|
case ProgramType::Geometry:
|
||||||
return {fmt::format("gl_in[{}].gl_Position{}", Visit(buffer).AsUint(),
|
return fmt::format("gl_in[{}].gl_Position{}", Visit(buffer).AsUint(),
|
||||||
GetSwizzle(element)),
|
GetSwizzle(element));
|
||||||
Type::Float};
|
case ProgramType::Fragment: {
|
||||||
case ProgramType::Fragment:
|
switch (element) {
|
||||||
return {element == 3 ? "1.0f" : ("gl_FragCoord"s + GetSwizzle(element)),
|
case 0:
|
||||||
Type::Float};
|
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:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "core/settings.h"
|
||||||
#include "video_core/engines/maxwell_3d.h"
|
#include "video_core/engines/maxwell_3d.h"
|
||||||
#include "video_core/renderer_opengl/gl_shader_manager.h"
|
#include "video_core/renderer_opengl/gl_shader_manager.h"
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ ProgramManager::ProgramManager() {
|
|||||||
|
|
||||||
ProgramManager::~ProgramManager() = default;
|
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& regs = maxwell_3d.regs;
|
||||||
const auto& state = maxwell_3d.state;
|
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.
|
// 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 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 :
|
for (const auto stage :
|
||||||
std::array{current_state.vertex, current_state.geometry, current_state.fragment}) {
|
std::array{current_state.vertex, current_state.geometry, current_state.fragment}) {
|
||||||
if (!stage) {
|
if (!stage) {
|
||||||
@@ -70,6 +73,7 @@ void ProgramManager::SetConstants(Tegra::Engines::Maxwell3D& maxwell_3d) {
|
|||||||
stage->SetFlipStage(flip_stage);
|
stage->SetFlipStage(flip_stage);
|
||||||
stage->SetYDirection(y_direction);
|
stage->SetYDirection(y_direction);
|
||||||
stage->SetViewportScale(flip_x, flip_y);
|
stage->SetViewportScale(flip_x, flip_y);
|
||||||
|
stage->SetRescalingFactor(rescale_factor);
|
||||||
stage->UpdateConstants();
|
stage->UpdateConstants();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ public:
|
|||||||
state.y_direction = y_direction;
|
state.y_direction = y_direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetRescalingFactor(GLfloat rescaling_factor) {
|
||||||
|
state.rescaling_factor = rescaling_factor;
|
||||||
|
}
|
||||||
|
|
||||||
void SetViewportScale(GLfloat x, GLfloat y) {
|
void SetViewportScale(GLfloat x, GLfloat y) {
|
||||||
state.viewport_scale = {x, y};
|
state.viewport_scale = {x, y};
|
||||||
}
|
}
|
||||||
@@ -52,6 +56,7 @@ private:
|
|||||||
GLuint instance_id;
|
GLuint instance_id;
|
||||||
GLuint flip_stage;
|
GLuint flip_stage;
|
||||||
GLfloat y_direction;
|
GLfloat y_direction;
|
||||||
|
GLfloat rescaling_factor;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -67,7 +72,7 @@ public:
|
|||||||
explicit ProgramManager();
|
explicit ProgramManager();
|
||||||
~ProgramManager();
|
~ProgramManager();
|
||||||
|
|
||||||
void SetConstants(Tegra::Engines::Maxwell3D& maxwell_3d);
|
void SetConstants(Tegra::Engines::Maxwell3D& maxwell_3d, bool rescaling);
|
||||||
|
|
||||||
void ApplyTo(OpenGLState& state);
|
void ApplyTo(OpenGLState& state);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user