summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/engines/maxwell_3d.h10
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp8
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h3
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h62
-rw-r--r--src/video_core/renderer_opengl/gl_state.cpp15
-rw-r--r--src/video_core/renderer_opengl/gl_state.h5
6 files changed, 102 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);
1082ASSERT_REG_POSITION(point_coord_replace, 0x581); 1089ASSERT_REG_POSITION(point_coord_replace, 0x581);
1083ASSERT_REG_POSITION(code_address, 0x582); 1090ASSERT_REG_POSITION(code_address, 0x582);
1084ASSERT_REG_POSITION(draw, 0x585); 1091ASSERT_REG_POSITION(draw, 0x585);
1092ASSERT_REG_POSITION(primitive_restart, 0x591);
1085ASSERT_REG_POSITION(index_array, 0x5F2); 1093ASSERT_REG_POSITION(index_array, 0x5F2);
1086ASSERT_REG_POSITION(instanced_arrays, 0x620); 1094ASSERT_REG_POSITION(instanced_arrays, 0x620);
1087ASSERT_REG_POSITION(cull, 0x646); 1095ASSERT_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
928void 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
927void RasterizerOpenGL::SyncDepthRange() { 935void 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_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 50a7ab47d..181acfc68 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -255,6 +255,68 @@ struct SurfaceParams {
255 return compression_factor_table[static_cast<std::size_t>(format)]; 255 return compression_factor_table[static_cast<std::size_t>(format)];
256 } 256 }
257 257
258 static constexpr u32 GetDefaultBlockHeight(PixelFormat format) {
259 if (format == PixelFormat::Invalid)
260 return 0;
261 constexpr std::array<u32, MaxPixelFormat> block_height_table = {{
262 1, // ABGR8U
263 1, // ABGR8S
264 1, // ABGR8UI
265 1, // B5G6R5U
266 1, // A2B10G10R10U
267 1, // A1B5G5R5U
268 1, // R8U
269 1, // R8UI
270 1, // RGBA16F
271 1, // RGBA16U
272 1, // RGBA16UI
273 1, // R11FG11FB10F
274 1, // RGBA32UI
275 4, // DXT1
276 4, // DXT23
277 4, // DXT45
278 4, // DXN1
279 4, // DXN2UNORM
280 4, // DXN2SNORM
281 4, // BC7U
282 4, // BC6H_UF16
283 4, // BC6H_SF16
284 4, // ASTC_2D_4X4
285 1, // G8R8U
286 1, // G8R8S
287 1, // BGRA8
288 1, // RGBA32F
289 1, // RG32F
290 1, // R32F
291 1, // R16F
292 1, // R16U
293 1, // R16S
294 1, // R16UI
295 1, // R16I
296 1, // RG16
297 1, // RG16F
298 1, // RG16UI
299 1, // RG16I
300 1, // RG16S
301 1, // RGB32F
302 1, // SRGBA8
303 1, // RG8U
304 1, // RG8S
305 1, // RG32UI
306 1, // R32UI
307 8, // ASTC_2D_8X8
308 5, // ASTC_2D_8X5
309 4, // ASTC_2D_5X4
310 1, // Z32F
311 1, // Z16
312 1, // Z24S8
313 1, // S8Z24
314 1, // Z32FS8
315 }};
316 ASSERT(static_cast<std::size_t>(format) < block_height_table.size());
317 return block_height_table[static_cast<std::size_t>(format)];
318 }
319
258 static constexpr u32 GetFormatBpp(PixelFormat format) { 320 static constexpr u32 GetFormatBpp(PixelFormat format) {
259 if (format == PixelFormat::Invalid) 321 if (format == PixelFormat::Invalid)
260 return 0; 322 return 0;
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;