diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/engines/maxwell_3d.cpp | 57 |
1 files changed, 25 insertions, 32 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index f9794dfe4..4a2f2c1fd 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -631,47 +631,40 @@ void Maxwell3D::ProcessDeferredDraw() { | |||
| 631 | Instance, | 631 | Instance, |
| 632 | }; | 632 | }; |
| 633 | DrawMode draw_mode{DrawMode::Undefined}; | 633 | DrawMode draw_mode{DrawMode::Undefined}; |
| 634 | u32 instance_count = 1; | ||
| 635 | |||
| 636 | u32 index = 0; | ||
| 637 | u32 method = 0; | ||
| 638 | u32 method_count = static_cast<u32>(deferred_draw_method.size()); | 634 | u32 method_count = static_cast<u32>(deferred_draw_method.size()); |
| 639 | for (; index < method_count && | 635 | u32 method = deferred_draw_method[method_count - 1]; |
| 640 | (method = deferred_draw_method[index]) != MAXWELL3D_REG_INDEX(draw.begin); | 636 | if (MAXWELL3D_REG_INDEX(draw.end) != method) { |
| 641 | ++index) | ||
| 642 | ; | ||
| 643 | |||
| 644 | if (MAXWELL3D_REG_INDEX(draw.begin) != method) { | ||
| 645 | return; | ||
| 646 | } | ||
| 647 | |||
| 648 | // The minimum number of methods for drawing must be greater than or equal to | ||
| 649 | // 3[draw.begin->vertex(index)count(first)->draw.end] to avoid errors in index mode drawing | ||
| 650 | if ((method_count - index) < 3) { | ||
| 651 | return; | 637 | return; |
| 652 | } | 638 | } |
| 653 | draw_mode = (regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::Subsequent) || | 639 | draw_mode = (regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::Subsequent) || |
| 654 | (regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::Unchanged) | 640 | (regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::Unchanged) |
| 655 | ? DrawMode::Instance | 641 | ? DrawMode::Instance |
| 656 | : DrawMode::General; | 642 | : DrawMode::General; |
| 657 | 643 | u32 instance_count = 0; | |
| 658 | // Drawing will only begin with draw.begin or index_buffer method, other methods directly | ||
| 659 | // clear | ||
| 660 | if (draw_mode == DrawMode::Undefined) { | ||
| 661 | deferred_draw_method.clear(); | ||
| 662 | return; | ||
| 663 | } | ||
| 664 | |||
| 665 | if (draw_mode == DrawMode::Instance) { | 644 | if (draw_mode == DrawMode::Instance) { |
| 666 | ASSERT_MSG(deferred_draw_method.size() % 4 == 0, "Instance mode method size error"); | 645 | u32 vertex_buffer_count = 0; |
| 667 | instance_count = static_cast<u32>(method_count - index) / 4; | 646 | u32 index_buffer_count = 0; |
| 647 | for (u32 index = 0; index < method_count; ++index) { | ||
| 648 | method = deferred_draw_method[index]; | ||
| 649 | if (method == MAXWELL3D_REG_INDEX(vertex_buffer.count)) { | ||
| 650 | instance_count = ++vertex_buffer_count; | ||
| 651 | } else if (method == MAXWELL3D_REG_INDEX(index_buffer.count)) { | ||
| 652 | instance_count = ++index_buffer_count; | ||
| 653 | } | ||
| 654 | } | ||
| 655 | ASSERT_MSG(!(vertex_buffer_count && index_buffer_count), | ||
| 656 | "Instance both indexed and direct?"); | ||
| 668 | } else { | 657 | } else { |
| 669 | method = deferred_draw_method[index + 1]; | 658 | instance_count = 1; |
| 670 | if (MAXWELL3D_REG_INDEX(draw_inline_index) == method || | 659 | for (u32 index = 0; index < method_count; ++index) { |
| 671 | MAXWELL3D_REG_INDEX(inline_index_2x16.even) == method || | 660 | method = deferred_draw_method[index]; |
| 672 | MAXWELL3D_REG_INDEX(inline_index_4x8.index0) == method) { | 661 | if (MAXWELL3D_REG_INDEX(draw_inline_index) == method || |
| 673 | regs.index_buffer.count = static_cast<u32>(inline_index_draw_indexes.size() / 4); | 662 | MAXWELL3D_REG_INDEX(inline_index_2x16.even) == method || |
| 674 | regs.index_buffer.format = Regs::IndexFormat::UnsignedInt; | 663 | MAXWELL3D_REG_INDEX(inline_index_4x8.index0) == method) { |
| 664 | regs.index_buffer.count = static_cast<u32>(inline_index_draw_indexes.size() / 4); | ||
| 665 | regs.index_buffer.format = Regs::IndexFormat::UnsignedInt; | ||
| 666 | break; | ||
| 667 | } | ||
| 675 | } | 668 | } |
| 676 | } | 669 | } |
| 677 | 670 | ||