mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-12-02 11:42:47 +01:00
Merge pull request #2299 from lioncash/maxwell
gl_shader_manager: Remove reliance on a global accessor within MaxwellUniformData::SetFromRegs()
This commit is contained in:
commit
d7438d067f
4 changed files with 15 additions and 17 deletions
|
@ -318,7 +318,7 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {
|
||||||
const std::size_t stage{index == 0 ? 0 : index - 1}; // Stage indices are 0 - 5
|
const std::size_t stage{index == 0 ? 0 : index - 1}; // Stage indices are 0 - 5
|
||||||
|
|
||||||
GLShader::MaxwellUniformData ubo{};
|
GLShader::MaxwellUniformData ubo{};
|
||||||
ubo.SetFromRegs(gpu.state.shader_stages[stage]);
|
ubo.SetFromRegs(gpu, stage);
|
||||||
const GLintptr offset = buffer_cache.UploadHostMemory(
|
const GLintptr offset = buffer_cache.UploadHostMemory(
|
||||||
&ubo, sizeof(ubo), static_cast<std::size_t>(uniform_buffer_alignment));
|
&ubo, sizeof(ubo), static_cast<std::size_t>(uniform_buffer_alignment));
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,11 @@
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/hash.h"
|
#include "common/hash.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/memory.h"
|
|
||||||
#include "video_core/engines/maxwell_3d.h"
|
#include "video_core/engines/maxwell_3d.h"
|
||||||
#include "video_core/renderer_opengl/gl_rasterizer.h"
|
#include "video_core/renderer_opengl/gl_rasterizer.h"
|
||||||
#include "video_core/renderer_opengl/gl_shader_cache.h"
|
#include "video_core/renderer_opengl/gl_shader_cache.h"
|
||||||
#include "video_core/renderer_opengl/gl_shader_decompiler.h"
|
#include "video_core/renderer_opengl/gl_shader_decompiler.h"
|
||||||
#include "video_core/renderer_opengl/gl_shader_disk_cache.h"
|
#include "video_core/renderer_opengl/gl_shader_disk_cache.h"
|
||||||
#include "video_core/renderer_opengl/gl_shader_manager.h"
|
|
||||||
#include "video_core/renderer_opengl/utils.h"
|
#include "video_core/renderer_opengl/utils.h"
|
||||||
#include "video_core/shader/shader_ir.h"
|
#include "video_core/shader/shader_ir.h"
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "core/core.h"
|
|
||||||
#include "video_core/renderer_opengl/gl_shader_manager.h"
|
#include "video_core/renderer_opengl/gl_shader_manager.h"
|
||||||
|
|
||||||
namespace OpenGL::GLShader {
|
namespace OpenGL::GLShader {
|
||||||
|
|
||||||
void MaxwellUniformData::SetFromRegs(const Maxwell3D::State::ShaderStageInfo& shader_stage) {
|
using Tegra::Engines::Maxwell3D;
|
||||||
const auto& gpu = Core::System::GetInstance().GPU().Maxwell3D();
|
|
||||||
const auto& regs = gpu.regs;
|
void MaxwellUniformData::SetFromRegs(const Maxwell3D& maxwell, std::size_t shader_stage) {
|
||||||
const auto& state = gpu.state;
|
const auto& regs = maxwell.regs;
|
||||||
|
const auto& state = maxwell.state;
|
||||||
|
|
||||||
// TODO(bunnei): Support more than one viewport
|
// TODO(bunnei): Support more than one viewport
|
||||||
viewport_flip[0] = regs.viewport_transform[0].scale_x < 0.0 ? -1.0f : 1.0f;
|
viewport_flip[0] = regs.viewport_transform[0].scale_x < 0.0 ? -1.0f : 1.0f;
|
||||||
|
@ -18,7 +18,7 @@ void MaxwellUniformData::SetFromRegs(const Maxwell3D::State::ShaderStageInfo& sh
|
||||||
|
|
||||||
u32 func = static_cast<u32>(regs.alpha_test_func);
|
u32 func = static_cast<u32>(regs.alpha_test_func);
|
||||||
// Normalize the gl variants of opCompare to be the same as the normal variants
|
// Normalize the gl variants of opCompare to be the same as the normal variants
|
||||||
u32 op_gl_variant_base = static_cast<u32>(Tegra::Engines::Maxwell3D::Regs::ComparisonOp::Never);
|
const u32 op_gl_variant_base = static_cast<u32>(Maxwell3D::Regs::ComparisonOp::Never);
|
||||||
if (func >= op_gl_variant_base) {
|
if (func >= op_gl_variant_base) {
|
||||||
func = func - op_gl_variant_base + 1U;
|
func = func - op_gl_variant_base + 1U;
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,9 @@ void MaxwellUniformData::SetFromRegs(const Maxwell3D::State::ShaderStageInfo& sh
|
||||||
|
|
||||||
// Assign in which stage the position has to be flipped
|
// Assign in which stage the position has to be flipped
|
||||||
// (the last stage before the fragment shader).
|
// (the last stage before the fragment shader).
|
||||||
if (gpu.regs.shader_config[static_cast<u32>(Maxwell3D::Regs::ShaderProgram::Geometry)].enable) {
|
constexpr u32 geometry_index = static_cast<u32>(Maxwell3D::Regs::ShaderProgram::Geometry);
|
||||||
flip_stage = static_cast<u32>(Maxwell3D::Regs::ShaderProgram::Geometry);
|
if (maxwell.regs.shader_config[geometry_index].enable) {
|
||||||
|
flip_stage = geometry_index;
|
||||||
} else {
|
} else {
|
||||||
flip_stage = static_cast<u32>(Maxwell3D::Regs::ShaderProgram::VertexB);
|
flip_stage = static_cast<u32>(Maxwell3D::Regs::ShaderProgram::VertexB);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,14 +12,13 @@
|
||||||
|
|
||||||
namespace OpenGL::GLShader {
|
namespace OpenGL::GLShader {
|
||||||
|
|
||||||
using Tegra::Engines::Maxwell3D;
|
|
||||||
|
|
||||||
/// Uniform structure for the Uniform Buffer Object, all vectors must be 16-byte aligned
|
/// Uniform structure for the Uniform Buffer Object, all vectors must be 16-byte aligned
|
||||||
// NOTE: Always keep a vec4 at the end. The GL spec is not clear whether the alignment at
|
/// @note Always keep a vec4 at the end. The GL spec is not clear whether the alignment at
|
||||||
// the end of a uniform block is included in UNIFORM_BLOCK_DATA_SIZE or not.
|
/// the end of a uniform block is included in UNIFORM_BLOCK_DATA_SIZE or not.
|
||||||
// Not following that rule will cause problems on some AMD drivers.
|
/// Not following that rule will cause problems on some AMD drivers.
|
||||||
struct MaxwellUniformData {
|
struct MaxwellUniformData {
|
||||||
void SetFromRegs(const Maxwell3D::State::ShaderStageInfo& shader_stage);
|
void SetFromRegs(const Tegra::Engines::Maxwell3D& maxwell, std::size_t shader_stage);
|
||||||
|
|
||||||
alignas(16) GLvec4 viewport_flip;
|
alignas(16) GLvec4 viewport_flip;
|
||||||
struct alignas(16) {
|
struct alignas(16) {
|
||||||
GLuint instance_id;
|
GLuint instance_id;
|
||||||
|
|
Loading…
Reference in a new issue