2018-04-07 11:12:38 +02:00
|
|
|
// Copyright 2018 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2019-04-11 00:26:27 +02:00
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "video_core/engines/maxwell_3d.h"
|
2018-04-07 11:12:38 +02:00
|
|
|
#include "video_core/renderer_opengl/gl_shader_manager.h"
|
|
|
|
|
2018-08-21 10:18:27 +02:00
|
|
|
namespace OpenGL::GLShader {
|
2018-04-07 11:12:38 +02:00
|
|
|
|
2019-03-27 18:25:59 +01:00
|
|
|
using Tegra::Engines::Maxwell3D;
|
|
|
|
|
2019-04-11 00:26:27 +02:00
|
|
|
ProgramManager::~ProgramManager() = default;
|
|
|
|
|
2019-12-26 20:04:41 +01:00
|
|
|
void ProgramManager::Create() {
|
|
|
|
pipeline.Create();
|
2019-04-11 00:26:27 +02:00
|
|
|
}
|
|
|
|
|
2019-12-26 20:04:41 +01:00
|
|
|
void ProgramManager::Update() {
|
2019-04-11 00:26:27 +02:00
|
|
|
// Avoid updating the pipeline when values have no changed
|
|
|
|
if (old_state == current_state) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Workaround for AMD bug
|
2019-12-26 20:04:41 +01:00
|
|
|
static constexpr GLenum all_used_stages{GL_VERTEX_SHADER_BIT | GL_GEOMETRY_SHADER_BIT |
|
|
|
|
GL_FRAGMENT_SHADER_BIT};
|
2019-04-11 00:26:27 +02:00
|
|
|
glUseProgramStages(pipeline.handle, all_used_stages, 0);
|
|
|
|
|
|
|
|
glUseProgramStages(pipeline.handle, GL_VERTEX_SHADER_BIT, current_state.vertex_shader);
|
|
|
|
glUseProgramStages(pipeline.handle, GL_GEOMETRY_SHADER_BIT, current_state.geometry_shader);
|
|
|
|
glUseProgramStages(pipeline.handle, GL_FRAGMENT_SHADER_BIT, current_state.fragment_shader);
|
|
|
|
|
|
|
|
old_state = current_state;
|
|
|
|
}
|
|
|
|
|
2019-10-30 04:23:09 +01:00
|
|
|
void MaxwellUniformData::SetFromRegs(const Maxwell3D& maxwell) {
|
2019-03-27 18:17:35 +01:00
|
|
|
const auto& regs = maxwell.regs;
|
2018-04-18 22:42:40 +02:00
|
|
|
|
2018-11-25 08:37:29 +01:00
|
|
|
// Y_NEGATE controls what value S2R returns for the Y_DIRECTION system value.
|
2019-10-30 04:23:09 +01:00
|
|
|
y_direction = regs.screen_y_control.y_negate == 0 ? 1.0f : -1.0f;
|
2018-04-18 22:42:40 +02:00
|
|
|
}
|
2018-04-07 11:12:38 +02:00
|
|
|
|
2018-08-21 10:18:27 +02:00
|
|
|
} // namespace OpenGL::GLShader
|