diff options
| author | 2019-04-03 21:47:48 -0400 | |
|---|---|---|
| committer | 2019-04-03 21:47:48 -0400 | |
| commit | d7438d067f8c4f15e689f85dc92c244bdb134bf0 (patch) | |
| tree | 24495ef29ae433bb4116cf186dece3d29fcbccf7 | |
| parent | Merge pull request #2324 from lioncash/enum-unused (diff) | |
| parent | gl_shader_manager: Remove unnecessary gl_shader_manager inclusion (diff) | |
| download | yuzu-d7438d067f8c4f15e689f85dc92c244bdb134bf0.tar.gz yuzu-d7438d067f8c4f15e689f85dc92c244bdb134bf0.tar.xz yuzu-d7438d067f8c4f15e689f85dc92c244bdb134bf0.zip | |
Merge pull request #2299 from lioncash/maxwell
gl_shader_manager: Remove reliance on a global accessor within MaxwellUniformData::SetFromRegs()
Diffstat (limited to '')
4 files changed, 15 insertions, 17 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 046fc935b..8f012db62 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -318,7 +318,7 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) { | |||
| 318 | const std::size_t stage{index == 0 ? 0 : index - 1}; // Stage indices are 0 - 5 | 318 | const std::size_t stage{index == 0 ? 0 : index - 1}; // Stage indices are 0 - 5 |
| 319 | 319 | ||
| 320 | GLShader::MaxwellUniformData ubo{}; | 320 | GLShader::MaxwellUniformData ubo{}; |
| 321 | ubo.SetFromRegs(gpu.state.shader_stages[stage]); | 321 | ubo.SetFromRegs(gpu, stage); |
| 322 | const GLintptr offset = buffer_cache.UploadHostMemory( | 322 | const GLintptr offset = buffer_cache.UploadHostMemory( |
| 323 | &ubo, sizeof(ubo), static_cast<std::size_t>(uniform_buffer_alignment)); | 323 | &ubo, sizeof(ubo), static_cast<std::size_t>(uniform_buffer_alignment)); |
| 324 | 324 | ||
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index 290e654bc..7030db365 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp | |||
| @@ -6,13 +6,11 @@ | |||
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "common/hash.h" | 7 | #include "common/hash.h" |
| 8 | #include "core/core.h" | 8 | #include "core/core.h" |
| 9 | #include "core/memory.h" | ||
| 10 | #include "video_core/engines/maxwell_3d.h" | 9 | #include "video_core/engines/maxwell_3d.h" |
| 11 | #include "video_core/renderer_opengl/gl_rasterizer.h" | 10 | #include "video_core/renderer_opengl/gl_rasterizer.h" |
| 12 | #include "video_core/renderer_opengl/gl_shader_cache.h" | 11 | #include "video_core/renderer_opengl/gl_shader_cache.h" |
| 13 | #include "video_core/renderer_opengl/gl_shader_decompiler.h" | 12 | #include "video_core/renderer_opengl/gl_shader_decompiler.h" |
| 14 | #include "video_core/renderer_opengl/gl_shader_disk_cache.h" | 13 | #include "video_core/renderer_opengl/gl_shader_disk_cache.h" |
| 15 | #include "video_core/renderer_opengl/gl_shader_manager.h" | ||
| 16 | #include "video_core/renderer_opengl/utils.h" | 14 | #include "video_core/renderer_opengl/utils.h" |
| 17 | #include "video_core/shader/shader_ir.h" | 15 | #include "video_core/shader/shader_ir.h" |
| 18 | 16 | ||
diff --git a/src/video_core/renderer_opengl/gl_shader_manager.cpp b/src/video_core/renderer_opengl/gl_shader_manager.cpp index 6a30c28d2..eaf3e03a0 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.cpp +++ b/src/video_core/renderer_opengl/gl_shader_manager.cpp | |||
| @@ -2,15 +2,15 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "core/core.h" | ||
| 6 | #include "video_core/renderer_opengl/gl_shader_manager.h" | 5 | #include "video_core/renderer_opengl/gl_shader_manager.h" |
| 7 | 6 | ||
| 8 | namespace OpenGL::GLShader { | 7 | namespace OpenGL::GLShader { |
| 9 | 8 | ||
| 10 | void MaxwellUniformData::SetFromRegs(const Maxwell3D::State::ShaderStageInfo& shader_stage) { | 9 | using Tegra::Engines::Maxwell3D; |
| 11 | const auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); | 10 | |
| 12 | const auto& regs = gpu.regs; | 11 | void MaxwellUniformData::SetFromRegs(const Maxwell3D& maxwell, std::size_t shader_stage) { |
| 13 | const auto& state = gpu.state; | 12 | const auto& regs = maxwell.regs; |
| 13 | const auto& state = maxwell.state; | ||
| 14 | 14 | ||
| 15 | // TODO(bunnei): Support more than one viewport | 15 | // TODO(bunnei): Support more than one viewport |
| 16 | viewport_flip[0] = regs.viewport_transform[0].scale_x < 0.0 ? -1.0f : 1.0f; | 16 | 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 | |||
| 18 | 18 | ||
| 19 | u32 func = static_cast<u32>(regs.alpha_test_func); | 19 | u32 func = static_cast<u32>(regs.alpha_test_func); |
| 20 | // Normalize the gl variants of opCompare to be the same as the normal variants | 20 | // Normalize the gl variants of opCompare to be the same as the normal variants |
| 21 | u32 op_gl_variant_base = static_cast<u32>(Tegra::Engines::Maxwell3D::Regs::ComparisonOp::Never); | 21 | const u32 op_gl_variant_base = static_cast<u32>(Maxwell3D::Regs::ComparisonOp::Never); |
| 22 | if (func >= op_gl_variant_base) { | 22 | if (func >= op_gl_variant_base) { |
| 23 | func = func - op_gl_variant_base + 1U; | 23 | func = func - op_gl_variant_base + 1U; |
| 24 | } | 24 | } |
| @@ -31,8 +31,9 @@ void MaxwellUniformData::SetFromRegs(const Maxwell3D::State::ShaderStageInfo& sh | |||
| 31 | 31 | ||
| 32 | // Assign in which stage the position has to be flipped | 32 | // Assign in which stage the position has to be flipped |
| 33 | // (the last stage before the fragment shader). | 33 | // (the last stage before the fragment shader). |
| 34 | if (gpu.regs.shader_config[static_cast<u32>(Maxwell3D::Regs::ShaderProgram::Geometry)].enable) { | 34 | constexpr u32 geometry_index = static_cast<u32>(Maxwell3D::Regs::ShaderProgram::Geometry); |
| 35 | flip_stage = static_cast<u32>(Maxwell3D::Regs::ShaderProgram::Geometry); | 35 | if (maxwell.regs.shader_config[geometry_index].enable) { |
| 36 | flip_stage = geometry_index; | ||
| 36 | } else { | 37 | } else { |
| 37 | flip_stage = static_cast<u32>(Maxwell3D::Regs::ShaderProgram::VertexB); | 38 | flip_stage = static_cast<u32>(Maxwell3D::Regs::ShaderProgram::VertexB); |
| 38 | } | 39 | } |
diff --git a/src/video_core/renderer_opengl/gl_shader_manager.h b/src/video_core/renderer_opengl/gl_shader_manager.h index 4970aafed..8eef2a920 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.h +++ b/src/video_core/renderer_opengl/gl_shader_manager.h | |||
| @@ -12,14 +12,13 @@ | |||
| 12 | 12 | ||
| 13 | namespace OpenGL::GLShader { | 13 | namespace OpenGL::GLShader { |
| 14 | 14 | ||
| 15 | using Tegra::Engines::Maxwell3D; | ||
| 16 | |||
| 17 | /// Uniform structure for the Uniform Buffer Object, all vectors must be 16-byte aligned | 15 | /// Uniform structure for the Uniform Buffer Object, all vectors must be 16-byte aligned |
| 18 | // NOTE: Always keep a vec4 at the end. The GL spec is not clear whether the alignment at | 16 | /// @note Always keep a vec4 at the end. The GL spec is not clear whether the alignment at |
| 19 | // the end of a uniform block is included in UNIFORM_BLOCK_DATA_SIZE or not. | 17 | /// the end of a uniform block is included in UNIFORM_BLOCK_DATA_SIZE or not. |
| 20 | // Not following that rule will cause problems on some AMD drivers. | 18 | /// Not following that rule will cause problems on some AMD drivers. |
| 21 | struct MaxwellUniformData { | 19 | struct MaxwellUniformData { |
| 22 | void SetFromRegs(const Maxwell3D::State::ShaderStageInfo& shader_stage); | 20 | void SetFromRegs(const Tegra::Engines::Maxwell3D& maxwell, std::size_t shader_stage); |
| 21 | |||
| 23 | alignas(16) GLvec4 viewport_flip; | 22 | alignas(16) GLvec4 viewport_flip; |
| 24 | struct alignas(16) { | 23 | struct alignas(16) { |
| 25 | GLuint instance_id; | 24 | GLuint instance_id; |