diff options
| author | 2018-10-26 00:12:20 -0400 | |
|---|---|---|
| committer | 2018-10-26 00:12:20 -0400 | |
| commit | 1f98dc30eaac7b799182c1998502c05b9fbb56d8 (patch) | |
| tree | 73e0ce98767d7a9b527a401dc89441697dd82e3a /src | |
| parent | Merge pull request #1569 from lioncash/amiibo (diff) | |
| parent | maxwell_3d: Add code for initializing register defaults. (diff) | |
| download | yuzu-1f98dc30eaac7b799182c1998502c05b9fbb56d8.tar.gz yuzu-1f98dc30eaac7b799182c1998502c05b9fbb56d8.tar.xz yuzu-1f98dc30eaac7b799182c1998502c05b9fbb56d8.zip | |
Merge pull request #1591 from bunnei/depth-range
gl_rasterizer: Implement depth range.
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/engines/maxwell_3d.cpp | 20 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 10 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 7 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_state.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_state.h | 8 |
6 files changed, 41 insertions, 14 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 78ba29fc1..27ef865a2 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <cinttypes> | 5 | #include <cinttypes> |
| 6 | #include <cstring> | ||
| 6 | #include "common/assert.h" | 7 | #include "common/assert.h" |
| 7 | #include "core/core.h" | 8 | #include "core/core.h" |
| 8 | #include "core/core_timing.h" | 9 | #include "core/core_timing.h" |
| @@ -19,7 +20,24 @@ namespace Tegra::Engines { | |||
| 19 | constexpr u32 MacroRegistersStart = 0xE00; | 20 | constexpr u32 MacroRegistersStart = 0xE00; |
| 20 | 21 | ||
| 21 | Maxwell3D::Maxwell3D(VideoCore::RasterizerInterface& rasterizer, MemoryManager& memory_manager) | 22 | Maxwell3D::Maxwell3D(VideoCore::RasterizerInterface& rasterizer, MemoryManager& memory_manager) |
| 22 | : memory_manager(memory_manager), rasterizer{rasterizer}, macro_interpreter(*this) {} | 23 | : memory_manager(memory_manager), rasterizer{rasterizer}, macro_interpreter(*this) { |
| 24 | InitializeRegisterDefaults(); | ||
| 25 | } | ||
| 26 | |||
| 27 | void Maxwell3D::InitializeRegisterDefaults() { | ||
| 28 | // Initializes registers to their default values - what games expect them to be at boot. This is | ||
| 29 | // for certain registers that may not be explicitly set by games. | ||
| 30 | |||
| 31 | // Reset all registers to zero | ||
| 32 | std::memset(®s, 0, sizeof(regs)); | ||
| 33 | |||
| 34 | // Depth range near/far is not always set, but is expected to be the default 0.0f, 1.0f. This is | ||
| 35 | // needed for ARMS. | ||
| 36 | for (std::size_t viewport{}; viewport < Regs::NumViewports; ++viewport) { | ||
| 37 | regs.viewport[viewport].depth_range_near = 0.0f; | ||
| 38 | regs.viewport[viewport].depth_range_far = 1.0f; | ||
| 39 | } | ||
| 40 | } | ||
| 23 | 41 | ||
| 24 | void Maxwell3D::CallMacroMethod(u32 method, std::vector<u32> parameters) { | 42 | void Maxwell3D::CallMacroMethod(u32 method, std::vector<u32> parameters) { |
| 25 | // Reset the current macro. | 43 | // Reset the current macro. |
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 0e09a7ee5..754a149fa 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -984,6 +984,8 @@ public: | |||
| 984 | Texture::FullTextureInfo GetStageTexture(Regs::ShaderStage stage, std::size_t offset) const; | 984 | Texture::FullTextureInfo GetStageTexture(Regs::ShaderStage stage, std::size_t offset) const; |
| 985 | 985 | ||
| 986 | private: | 986 | private: |
| 987 | void InitializeRegisterDefaults(); | ||
| 988 | |||
| 987 | VideoCore::RasterizerInterface& rasterizer; | 989 | VideoCore::RasterizerInterface& rasterizer; |
| 988 | 990 | ||
| 989 | std::unordered_map<u32, std::vector<u32>> uploaded_macros; | 991 | std::unordered_map<u32, std::vector<u32>> uploaded_macros; |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index be51c5215..b472f421f 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -570,6 +570,7 @@ void RasterizerOpenGL::DrawArrays() { | |||
| 570 | SyncBlendState(); | 570 | SyncBlendState(); |
| 571 | SyncLogicOpState(); | 571 | SyncLogicOpState(); |
| 572 | SyncCullMode(); | 572 | SyncCullMode(); |
| 573 | SyncDepthRange(); | ||
| 573 | SyncScissorTest(); | 574 | SyncScissorTest(); |
| 574 | // Alpha Testing is synced on shaders. | 575 | // Alpha Testing is synced on shaders. |
| 575 | SyncTransformFeedback(); | 576 | SyncTransformFeedback(); |
| @@ -923,12 +924,11 @@ void RasterizerOpenGL::SyncCullMode() { | |||
| 923 | } | 924 | } |
| 924 | } | 925 | } |
| 925 | 926 | ||
| 926 | void RasterizerOpenGL::SyncDepthScale() { | 927 | void RasterizerOpenGL::SyncDepthRange() { |
| 927 | UNREACHABLE(); | 928 | const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; |
| 928 | } | ||
| 929 | 929 | ||
| 930 | void RasterizerOpenGL::SyncDepthOffset() { | 930 | state.depth.depth_range_near = regs.viewport->depth_range_near; |
| 931 | UNREACHABLE(); | 931 | state.depth.depth_range_far = regs.viewport->depth_range_far; |
| 932 | } | 932 | } |
| 933 | 933 | ||
| 934 | void RasterizerOpenGL::SyncDepthTestState() { | 934 | void RasterizerOpenGL::SyncDepthTestState() { |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 0e90a31f5..731a336d5 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -144,11 +144,8 @@ private: | |||
| 144 | /// Syncs the cull mode to match the guest state | 144 | /// Syncs the cull mode to match the guest state |
| 145 | void SyncCullMode(); | 145 | void SyncCullMode(); |
| 146 | 146 | ||
| 147 | /// Syncs the depth scale to match the guest state | 147 | /// Syncs the depth range to match the guest state |
| 148 | void SyncDepthScale(); | 148 | void SyncDepthRange(); |
| 149 | |||
| 150 | /// Syncs the depth offset to match the guest state | ||
| 151 | void SyncDepthOffset(); | ||
| 152 | 149 | ||
| 153 | /// Syncs the depth test state to match the guest state | 150 | /// Syncs the depth test state to match the guest state |
| 154 | void SyncDepthTestState(); | 151 | void SyncDepthTestState(); |
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index 1fe26a2a9..ba6c6919a 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp | |||
| @@ -21,6 +21,8 @@ OpenGLState::OpenGLState() { | |||
| 21 | depth.test_enabled = false; | 21 | depth.test_enabled = false; |
| 22 | depth.test_func = GL_LESS; | 22 | depth.test_func = GL_LESS; |
| 23 | depth.write_mask = GL_TRUE; | 23 | depth.write_mask = GL_TRUE; |
| 24 | depth.depth_range_near = 0.0f; | ||
| 25 | depth.depth_range_far = 1.0f; | ||
| 24 | 26 | ||
| 25 | color_mask.red_enabled = GL_TRUE; | 27 | color_mask.red_enabled = GL_TRUE; |
| 26 | color_mask.green_enabled = GL_TRUE; | 28 | color_mask.green_enabled = GL_TRUE; |
| @@ -119,6 +121,12 @@ void OpenGLState::Apply() const { | |||
| 119 | glDepthMask(depth.write_mask); | 121 | glDepthMask(depth.write_mask); |
| 120 | } | 122 | } |
| 121 | 123 | ||
| 124 | // Depth range | ||
| 125 | if (depth.depth_range_near != cur_state.depth.depth_range_near || | ||
| 126 | depth.depth_range_far != cur_state.depth.depth_range_far) { | ||
| 127 | glDepthRange(depth.depth_range_near, depth.depth_range_far); | ||
| 128 | } | ||
| 129 | |||
| 122 | // Color mask | 130 | // Color mask |
| 123 | if (color_mask.red_enabled != cur_state.color_mask.red_enabled || | 131 | if (color_mask.red_enabled != cur_state.color_mask.red_enabled || |
| 124 | color_mask.green_enabled != cur_state.color_mask.green_enabled || | 132 | color_mask.green_enabled != cur_state.color_mask.green_enabled || |
diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h index dc21a2ee3..daf7eb533 100644 --- a/src/video_core/renderer_opengl/gl_state.h +++ b/src/video_core/renderer_opengl/gl_state.h | |||
| @@ -42,9 +42,11 @@ public: | |||
| 42 | } cull; | 42 | } cull; |
| 43 | 43 | ||
| 44 | struct { | 44 | struct { |
| 45 | bool test_enabled; // GL_DEPTH_TEST | 45 | bool test_enabled; // GL_DEPTH_TEST |
| 46 | GLenum test_func; // GL_DEPTH_FUNC | 46 | GLenum test_func; // GL_DEPTH_FUNC |
| 47 | GLboolean write_mask; // GL_DEPTH_WRITEMASK | 47 | GLboolean write_mask; // GL_DEPTH_WRITEMASK |
| 48 | GLfloat depth_range_near; // GL_DEPTH_RANGE | ||
| 49 | GLfloat depth_range_far; // GL_DEPTH_RANGE | ||
| 48 | } depth; | 50 | } depth; |
| 49 | 51 | ||
| 50 | struct { | 52 | struct { |