diff options
| author | 2018-10-27 13:25:00 -0400 | |
|---|---|---|
| committer | 2018-10-27 13:25:00 -0400 | |
| commit | ed95ce6bb7ae91eb294ab044959eef91bf6dd975 (patch) | |
| tree | c800613b85c3e7bd33baf86f58e1c071e205e73e | |
| parent | Merge pull request #1599 from FernandoS27/stalemate (diff) | |
| parent | gl_rasterizer: Implement primitive restart. (diff) | |
| download | yuzu-ed95ce6bb7ae91eb294ab044959eef91bf6dd975.tar.gz yuzu-ed95ce6bb7ae91eb294ab044959eef91bf6dd975.tar.xz yuzu-ed95ce6bb7ae91eb294ab044959eef91bf6dd975.zip | |
Merge pull request #1592 from bunnei/prim-restart
gl_rasterizer: Implement primitive restart.
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 10 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 3 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_state.cpp | 15 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_state.h | 5 |
5 files changed, 40 insertions, 1 deletions
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 754a149fa..d6978162a 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -751,7 +751,14 @@ public: | |||
| 751 | }; | 751 | }; |
| 752 | } draw; | 752 | } draw; |
| 753 | 753 | ||
| 754 | INSERT_PADDING_WORDS(0x6B); | 754 | INSERT_PADDING_WORDS(0xA); |
| 755 | |||
| 756 | struct { | ||
| 757 | u32 enabled; | ||
| 758 | u32 index; | ||
| 759 | } primitive_restart; | ||
| 760 | |||
| 761 | INSERT_PADDING_WORDS(0x5F); | ||
| 755 | 762 | ||
| 756 | struct { | 763 | struct { |
| 757 | u32 start_addr_high; | 764 | u32 start_addr_high; |
| @@ -1082,6 +1089,7 @@ ASSERT_REG_POSITION(stencil_back_func_func, 0x569); | |||
| 1082 | ASSERT_REG_POSITION(point_coord_replace, 0x581); | 1089 | ASSERT_REG_POSITION(point_coord_replace, 0x581); |
| 1083 | ASSERT_REG_POSITION(code_address, 0x582); | 1090 | ASSERT_REG_POSITION(code_address, 0x582); |
| 1084 | ASSERT_REG_POSITION(draw, 0x585); | 1091 | ASSERT_REG_POSITION(draw, 0x585); |
| 1092 | ASSERT_REG_POSITION(primitive_restart, 0x591); | ||
| 1085 | ASSERT_REG_POSITION(index_array, 0x5F2); | 1093 | ASSERT_REG_POSITION(index_array, 0x5F2); |
| 1086 | ASSERT_REG_POSITION(instanced_arrays, 0x620); | 1094 | ASSERT_REG_POSITION(instanced_arrays, 0x620); |
| 1087 | ASSERT_REG_POSITION(cull, 0x646); | 1095 | ASSERT_REG_POSITION(cull, 0x646); |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index b472f421f..cd4216c4e 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 | SyncPrimitiveRestart(); | ||
| 573 | SyncDepthRange(); | 574 | SyncDepthRange(); |
| 574 | SyncScissorTest(); | 575 | SyncScissorTest(); |
| 575 | // Alpha Testing is synced on shaders. | 576 | // Alpha Testing is synced on shaders. |
| @@ -924,6 +925,13 @@ void RasterizerOpenGL::SyncCullMode() { | |||
| 924 | } | 925 | } |
| 925 | } | 926 | } |
| 926 | 927 | ||
| 928 | void RasterizerOpenGL::SyncPrimitiveRestart() { | ||
| 929 | const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; | ||
| 930 | |||
| 931 | state.primitive_restart.enabled = regs.primitive_restart.enabled; | ||
| 932 | state.primitive_restart.index = regs.primitive_restart.index; | ||
| 933 | } | ||
| 934 | |||
| 927 | void RasterizerOpenGL::SyncDepthRange() { | 935 | void RasterizerOpenGL::SyncDepthRange() { |
| 928 | const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; | 936 | const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; |
| 929 | 937 | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 731a336d5..5020a5392 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -144,6 +144,9 @@ 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 primitve restart to match the guest state | ||
| 148 | void SyncPrimitiveRestart(); | ||
| 149 | |||
| 147 | /// Syncs the depth range to match the guest state | 150 | /// Syncs the depth range to match the guest state |
| 148 | void SyncDepthRange(); | 151 | void SyncDepthRange(); |
| 149 | 152 | ||
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index ba6c6919a..f9d41ca24 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp | |||
| @@ -24,6 +24,9 @@ OpenGLState::OpenGLState() { | |||
| 24 | depth.depth_range_near = 0.0f; | 24 | depth.depth_range_near = 0.0f; |
| 25 | depth.depth_range_far = 1.0f; | 25 | depth.depth_range_far = 1.0f; |
| 26 | 26 | ||
| 27 | primitive_restart.enabled = false; | ||
| 28 | primitive_restart.index = 0; | ||
| 29 | |||
| 27 | color_mask.red_enabled = GL_TRUE; | 30 | color_mask.red_enabled = GL_TRUE; |
| 28 | color_mask.green_enabled = GL_TRUE; | 31 | color_mask.green_enabled = GL_TRUE; |
| 29 | color_mask.blue_enabled = GL_TRUE; | 32 | color_mask.blue_enabled = GL_TRUE; |
| @@ -127,6 +130,18 @@ void OpenGLState::Apply() const { | |||
| 127 | glDepthRange(depth.depth_range_near, depth.depth_range_far); | 130 | glDepthRange(depth.depth_range_near, depth.depth_range_far); |
| 128 | } | 131 | } |
| 129 | 132 | ||
| 133 | // Primitive restart | ||
| 134 | if (primitive_restart.enabled != cur_state.primitive_restart.enabled) { | ||
| 135 | if (primitive_restart.enabled) { | ||
| 136 | glEnable(GL_PRIMITIVE_RESTART); | ||
| 137 | } else { | ||
| 138 | glDisable(GL_PRIMITIVE_RESTART); | ||
| 139 | } | ||
| 140 | } | ||
| 141 | if (primitive_restart.index != cur_state.primitive_restart.index) { | ||
| 142 | glPrimitiveRestartIndex(primitive_restart.index); | ||
| 143 | } | ||
| 144 | |||
| 130 | // Color mask | 145 | // Color mask |
| 131 | if (color_mask.red_enabled != cur_state.color_mask.red_enabled || | 146 | if (color_mask.red_enabled != cur_state.color_mask.red_enabled || |
| 132 | color_mask.green_enabled != cur_state.color_mask.green_enabled || | 147 | 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 daf7eb533..4334b0d35 100644 --- a/src/video_core/renderer_opengl/gl_state.h +++ b/src/video_core/renderer_opengl/gl_state.h | |||
| @@ -50,6 +50,11 @@ public: | |||
| 50 | } depth; | 50 | } depth; |
| 51 | 51 | ||
| 52 | struct { | 52 | struct { |
| 53 | bool enabled; | ||
| 54 | GLuint index; | ||
| 55 | } primitive_restart; // GL_PRIMITIVE_RESTART | ||
| 56 | |||
| 57 | struct { | ||
| 53 | GLboolean red_enabled; | 58 | GLboolean red_enabled; |
| 54 | GLboolean green_enabled; | 59 | GLboolean green_enabled; |
| 55 | GLboolean blue_enabled; | 60 | GLboolean blue_enabled; |