summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/video_core/engines/maxwell_3d.cpp69
-rw-r--r--src/video_core/engines/maxwell_3d.h7
-rw-r--r--src/video_core/rasterizer_interface.h2
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp12
4 files changed, 46 insertions, 44 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index b8f071bc0..e9c15beff 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -260,7 +260,7 @@ void Maxwell3D::CallMacroMethod(u32 method, std::size_t num_parameters, const u3
260 260
261 // Execute the current macro. 261 // Execute the current macro.
262 macro_interpreter.Execute(macro_positions[entry], num_parameters, parameters); 262 macro_interpreter.Execute(macro_positions[entry], num_parameters, parameters);
263 if (mme_draw.current_mode != MMMEDrawMode::Undefined) { 263 if (mme_draw.current_mode != MMEDrawMode::Undefined) {
264 FlushMMEInlineDraw(); 264 FlushMMEInlineDraw();
265 } 265 }
266} 266}
@@ -423,37 +423,40 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) {
423 } 423 }
424} 424}
425 425
426void Maxwell3D::StepInstance(const MMEDrawMode expected_mode, const u32 count) {
427 if (mme_draw.current_mode == MMEDrawMode::Undefined) {
428 if (mme_draw.gl_begin_consume) {
429 mme_draw.current_mode = expected_mode;
430 mme_draw.current_count = count;
431 mme_draw.instance_count = 1;
432 mme_draw.gl_begin_consume = false;
433 mme_draw.gl_end_count = 0;
434 }
435 return;
436 } else {
437 if (mme_draw.current_mode == expected_mode && count == mme_draw.current_count &&
438 mme_draw.instance_mode && mme_draw.gl_begin_consume) {
439 mme_draw.instance_count++;
440 mme_draw.gl_begin_consume = false;
441 return;
442 } else {
443 FlushMMEInlineDraw();
444 }
445 }
446 // Tail call in case it needs to retry.
447 StepInstance(expected_mode, count);
448}
449
426void Maxwell3D::CallMethodFromMME(const GPU::MethodCall& method_call) { 450void Maxwell3D::CallMethodFromMME(const GPU::MethodCall& method_call) {
427 const u32 method = method_call.method; 451 const u32 method = method_call.method;
428 if (mme_inline[method]) { 452 if (mme_inline[method]) {
429 regs.reg_array[method] = method_call.argument; 453 regs.reg_array[method] = method_call.argument;
430 if (method == MAXWELL3D_REG_INDEX(vertex_buffer.count) || 454 if (method == MAXWELL3D_REG_INDEX(vertex_buffer.count) ||
431 method == MAXWELL3D_REG_INDEX(index_array.count)) { 455 method == MAXWELL3D_REG_INDEX(index_array.count)) {
432 const MMMEDrawMode expected_mode = method == MAXWELL3D_REG_INDEX(vertex_buffer.count) 456 const MMEDrawMode expected_mode = method == MAXWELL3D_REG_INDEX(vertex_buffer.count)
433 ? MMMEDrawMode::Array 457 ? MMEDrawMode::Array
434 : MMMEDrawMode::Indexed; 458 : MMEDrawMode::Indexed;
435 const u32 count = method_call.argument; 459 StepInstance(expected_mode, method_call.argument);
436 while (true) {
437 if (mme_draw.current_mode == MMMEDrawMode::Undefined) {
438 if (mme_draw.gl_begin_consume) {
439 mme_draw.current_mode = expected_mode;
440 mme_draw.current_count = count;
441 mme_draw.instance_count = 1;
442 mme_draw.gl_begin_consume = false;
443 mme_draw.gl_end_count = 0;
444 }
445 break;
446 } else {
447 if (mme_draw.current_mode == expected_mode && count == mme_draw.current_count &&
448 mme_draw.instance_mode && mme_draw.gl_begin_consume) {
449 mme_draw.instance_count++;
450 mme_draw.gl_begin_consume = false;
451 break;
452 } else {
453 FlushMMEInlineDraw();
454 }
455 }
456 }
457 } else if (method == MAXWELL3D_REG_INDEX(draw.vertex_begin_gl)) { 460 } else if (method == MAXWELL3D_REG_INDEX(draw.vertex_begin_gl)) {
458 mme_draw.instance_mode = 461 mme_draw.instance_mode =
459 (regs.draw.instance_next != 0) || (regs.draw.instance_cont != 0); 462 (regs.draw.instance_next != 0) || (regs.draw.instance_cont != 0);
@@ -462,7 +465,7 @@ void Maxwell3D::CallMethodFromMME(const GPU::MethodCall& method_call) {
462 mme_draw.gl_end_count++; 465 mme_draw.gl_end_count++;
463 } 466 }
464 } else { 467 } else {
465 if (mme_draw.current_mode != MMMEDrawMode::Undefined) { 468 if (mme_draw.current_mode != MMEDrawMode::Undefined) {
466 FlushMMEInlineDraw(); 469 FlushMMEInlineDraw();
467 } 470 }
468 CallMethod(method_call); 471 CallMethod(method_call);
@@ -485,8 +488,10 @@ void Maxwell3D::FlushMMEInlineDraw() {
485 ASSERT_MSG(!regs.draw.instance_next || !regs.draw.instance_cont, 488 ASSERT_MSG(!regs.draw.instance_next || !regs.draw.instance_cont,
486 "Illegal combination of instancing parameters"); 489 "Illegal combination of instancing parameters");
487 490
488 const bool is_indexed = mme_draw.current_mode == MMMEDrawMode::Indexed; 491 const bool is_indexed = mme_draw.current_mode == MMEDrawMode::Indexed;
489 rasterizer.DrawMultiBatch(is_indexed); 492 if (ShouldExecute()) {
493 rasterizer.DrawMultiBatch(is_indexed);
494 }
490 495
491 if (debug_context) { 496 if (debug_context) {
492 debug_context->OnEvent(Tegra::DebugContext::Event::FinishedPrimitiveBatch, nullptr); 497 debug_context->OnEvent(Tegra::DebugContext::Event::FinishedPrimitiveBatch, nullptr);
@@ -501,7 +506,7 @@ void Maxwell3D::FlushMMEInlineDraw() {
501 } else { 506 } else {
502 regs.vertex_buffer.count = 0; 507 regs.vertex_buffer.count = 0;
503 } 508 }
504 mme_draw.current_mode = MMMEDrawMode::Undefined; 509 mme_draw.current_mode = MMEDrawMode::Undefined;
505 mme_draw.current_count = 0; 510 mme_draw.current_count = 0;
506 mme_draw.instance_count = 0; 511 mme_draw.instance_count = 0;
507 mme_draw.instance_mode = false; 512 mme_draw.instance_mode = false;
@@ -657,7 +662,9 @@ void Maxwell3D::DrawArrays() {
657 } 662 }
658 663
659 const bool is_indexed{regs.index_array.count && !regs.vertex_buffer.count}; 664 const bool is_indexed{regs.index_array.count && !regs.vertex_buffer.count};
660 rasterizer.DrawBatch(is_indexed); 665 if (ShouldExecute()) {
666 rasterizer.DrawBatch(is_indexed);
667 }
661 668
662 if (debug_context) { 669 if (debug_context) {
663 debug_context->OnEvent(Tegra::DebugContext::Event::FinishedPrimitiveBatch, nullptr); 670 debug_context->OnEvent(Tegra::DebugContext::Event::FinishedPrimitiveBatch, nullptr);
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 8fd3ec85c..4c97759ed 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -1269,14 +1269,14 @@ public:
1269 return execute_on; 1269 return execute_on;
1270 } 1270 }
1271 1271
1272 enum class MMMEDrawMode : u32 { 1272 enum class MMEDrawMode : u32 {
1273 Undefined, 1273 Undefined,
1274 Array, 1274 Array,
1275 Indexed, 1275 Indexed,
1276 }; 1276 };
1277 1277
1278 struct MMEDrawState { 1278 struct MMEDrawState {
1279 MMMEDrawMode current_mode{MMMEDrawMode::Undefined}; 1279 MMEDrawMode current_mode{MMEDrawMode::Undefined};
1280 u32 current_count{}; 1280 u32 current_count{};
1281 u32 instance_count{}; 1281 u32 instance_count{};
1282 bool instance_mode{}; 1282 bool instance_mode{};
@@ -1369,6 +1369,9 @@ private:
1369 1369
1370 /// Handles a write to the VERTEX_END_GL register, triggering a draw. 1370 /// Handles a write to the VERTEX_END_GL register, triggering a draw.
1371 void DrawArrays(); 1371 void DrawArrays();
1372
1373 // Handles a instance drawcall from MME
1374 void StepInstance(MMEDrawMode expected_mode, u32 count);
1372}; 1375};
1373 1376
1374#define ASSERT_REG_POSITION(field_name, position) \ 1377#define ASSERT_REG_POSITION(field_name, position) \
diff --git a/src/video_core/rasterizer_interface.h b/src/video_core/rasterizer_interface.h
index deadd70ec..5b0eca9e2 100644
--- a/src/video_core/rasterizer_interface.h
+++ b/src/video_core/rasterizer_interface.h
@@ -31,7 +31,7 @@ public:
31 /// Draw the current batch of vertex arrays 31 /// Draw the current batch of vertex arrays
32 virtual bool DrawBatch(bool is_indexed) = 0; 32 virtual bool DrawBatch(bool is_indexed) = 0;
33 33
34 /// Draw the current batch of multiple instasnces of vertex arrays 34 /// Draw the current batch of multiple instances of vertex arrays
35 virtual bool DrawMultiBatch(bool is_indexed) = 0; 35 virtual bool DrawMultiBatch(bool is_indexed) = 0;
36 36
37 /// Clear the current framebuffer 37 /// Clear the current framebuffer
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index a6fe7dd71..246b892c5 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -749,13 +749,9 @@ bool RasterizerOpenGL::DrawBatch(bool is_indexed) {
749 749
750 MICROPROFILE_SCOPE(OpenGL_Drawing); 750 MICROPROFILE_SCOPE(OpenGL_Drawing);
751 751
752 auto& maxwell3d = system.GPU().Maxwell3D();
753 if (!maxwell3d.ShouldExecute()) {
754 return false;
755 }
756
757 DrawPrelude(); 752 DrawPrelude();
758 753
754 auto& maxwell3d = system.GPU().Maxwell3D();
759 const auto& regs = maxwell3d.regs; 755 const auto& regs = maxwell3d.regs;
760 const auto current_instance = maxwell3d.state.current_instance; 756 const auto current_instance = maxwell3d.state.current_instance;
761 DrawParams draw_call{}; 757 DrawParams draw_call{};
@@ -785,13 +781,9 @@ bool RasterizerOpenGL::DrawMultiBatch(bool is_indexed) {
785 781
786 MICROPROFILE_SCOPE(OpenGL_Drawing); 782 MICROPROFILE_SCOPE(OpenGL_Drawing);
787 783
788 auto& maxwell3d = system.GPU().Maxwell3D();
789 if (!maxwell3d.ShouldExecute()) {
790 return false;
791 }
792
793 DrawPrelude(); 784 DrawPrelude();
794 785
786 auto& maxwell3d = system.GPU().Maxwell3D();
795 const auto& regs = maxwell3d.regs; 787 const auto& regs = maxwell3d.regs;
796 const auto& draw_setup = maxwell3d.mme_draw; 788 const auto& draw_setup = maxwell3d.mme_draw;
797 DrawParams draw_call{}; 789 DrawParams draw_call{};