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.
|
|
|
|
|
|
|
|
#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-03-27 18:17:35 +01:00
|
|
|
void MaxwellUniformData::SetFromRegs(const Maxwell3D& maxwell, std::size_t shader_stage) {
|
|
|
|
const auto& regs = maxwell.regs;
|
|
|
|
const auto& state = maxwell.state;
|
2018-04-18 22:42:40 +02:00
|
|
|
|
|
|
|
// TODO(bunnei): Support more than one viewport
|
2018-06-20 18:39:10 +02:00
|
|
|
viewport_flip[0] = regs.viewport_transform[0].scale_x < 0.0 ? -1.0f : 1.0f;
|
|
|
|
viewport_flip[1] = regs.viewport_transform[0].scale_y < 0.0 ? -1.0f : 1.0f;
|
2018-08-12 02:21:31 +02:00
|
|
|
|
2018-10-10 22:34:15 +02:00
|
|
|
u32 func = static_cast<u32>(regs.alpha_test_func);
|
|
|
|
// Normalize the gl variants of opCompare to be the same as the normal variants
|
2019-03-27 18:25:59 +01:00
|
|
|
const u32 op_gl_variant_base = static_cast<u32>(Maxwell3D::Regs::ComparisonOp::Never);
|
2018-10-10 22:34:15 +02:00
|
|
|
if (func >= op_gl_variant_base) {
|
|
|
|
func = func - op_gl_variant_base + 1U;
|
|
|
|
}
|
|
|
|
|
|
|
|
alpha_test.enabled = regs.alpha_test_enabled;
|
|
|
|
alpha_test.func = func;
|
|
|
|
alpha_test.ref = regs.alpha_test_ref;
|
|
|
|
|
2018-11-25 08:37:29 +01:00
|
|
|
instance_id = state.current_instance;
|
2018-10-07 04:17:31 +02:00
|
|
|
|
|
|
|
// Assign in which stage the position has to be flipped
|
|
|
|
// (the last stage before the fragment shader).
|
2019-03-27 18:17:35 +01:00
|
|
|
constexpr u32 geometry_index = static_cast<u32>(Maxwell3D::Regs::ShaderProgram::Geometry);
|
|
|
|
if (maxwell.regs.shader_config[geometry_index].enable) {
|
|
|
|
flip_stage = geometry_index;
|
2018-10-07 04:17:31 +02:00
|
|
|
} else {
|
2018-11-25 08:37:29 +01:00
|
|
|
flip_stage = static_cast<u32>(Maxwell3D::Regs::ShaderProgram::VertexB);
|
2018-10-07 04:17:31 +02:00
|
|
|
}
|
2018-11-25 08:37:29 +01:00
|
|
|
|
|
|
|
// Y_NEGATE controls what value S2R returns for the Y_DIRECTION system value.
|
|
|
|
y_direction = regs.screen_y_control.y_negate == 0 ? 1.f : -1.f;
|
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
|