summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFengChen <vonchenplus@gmail.com>2022-10-31 14:40:32 +0100
committerFengChen <vonchenplus@gmail.com>2022-10-31 14:57:38 +0100
commitb42b894785acd9591015476d78918b38c2f2f385 (patch)
treefad68e7f7d7f0f87f776fb41be1b748bd01a1c0c
parentMerge pull request #9155 from FernandoS27/goosfraba (diff)
downloadyuzu-b42b894785acd9591015476d78918b38c2f2f385.tar
yuzu-b42b894785acd9591015476d78918b38c2f2f385.tar.gz
yuzu-b42b894785acd9591015476d78918b38c2f2f385.tar.bz2
yuzu-b42b894785acd9591015476d78918b38c2f2f385.tar.lz
yuzu-b42b894785acd9591015476d78918b38c2f2f385.tar.xz
yuzu-b42b894785acd9591015476d78918b38c2f2f385.tar.zst
yuzu-b42b894785acd9591015476d78918b38c2f2f385.zip
Diffstat (limited to '')
-rw-r--r--src/video_core/engines/maxwell_3d.cpp57
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() {
Instance,
};
DrawMode draw_mode{DrawMode::Undefined};
- u32 instance_count = 1;
-
- u32 index = 0;
- u32 method = 0;
u32 method_count = static_cast<u32>(deferred_draw_method.size());
- for (; index < method_count &&
- (method = deferred_draw_method[index]) != MAXWELL3D_REG_INDEX(draw.begin);
- ++index)
- ;
-
- if (MAXWELL3D_REG_INDEX(draw.begin) != method) {
- return;
- }
-
- // The minimum number of methods for drawing must be greater than or equal to
- // 3[draw.begin->vertex(index)count(first)->draw.end] to avoid errors in index mode drawing
- if ((method_count - index) < 3) {
+ u32 method = deferred_draw_method[method_count - 1];
+ if (MAXWELL3D_REG_INDEX(draw.end) != method) {
return;
}
draw_mode = (regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::Subsequent) ||
(regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::Unchanged)
? DrawMode::Instance
: DrawMode::General;
-
- // Drawing will only begin with draw.begin or index_buffer method, other methods directly
- // clear
- if (draw_mode == DrawMode::Undefined) {
- deferred_draw_method.clear();
- return;
- }
-
+ u32 instance_count = 0;
if (draw_mode == DrawMode::Instance) {
- ASSERT_MSG(deferred_draw_method.size() % 4 == 0, "Instance mode method size error");
- instance_count = static_cast<u32>(method_count - index) / 4;
+ u32 vertex_buffer_count = 0;
+ u32 index_buffer_count = 0;
+ for (u32 index = 0; index < method_count; ++index) {
+ method = deferred_draw_method[index];
+ if (method == MAXWELL3D_REG_INDEX(vertex_buffer.count)) {
+ instance_count = ++vertex_buffer_count;
+ } else if (method == MAXWELL3D_REG_INDEX(index_buffer.count)) {
+ instance_count = ++index_buffer_count;
+ }
+ }
+ ASSERT_MSG(!(vertex_buffer_count && index_buffer_count),
+ "Instance both indexed and direct?");
} else {
- method = deferred_draw_method[index + 1];
- if (MAXWELL3D_REG_INDEX(draw_inline_index) == method ||
- MAXWELL3D_REG_INDEX(inline_index_2x16.even) == method ||
- MAXWELL3D_REG_INDEX(inline_index_4x8.index0) == method) {
- regs.index_buffer.count = static_cast<u32>(inline_index_draw_indexes.size() / 4);
- regs.index_buffer.format = Regs::IndexFormat::UnsignedInt;
+ instance_count = 1;
+ for (u32 index = 0; index < method_count; ++index) {
+ method = deferred_draw_method[index];
+ if (MAXWELL3D_REG_INDEX(draw_inline_index) == method ||
+ MAXWELL3D_REG_INDEX(inline_index_2x16.even) == method ||
+ MAXWELL3D_REG_INDEX(inline_index_4x8.index0) == method) {
+ regs.index_buffer.count = static_cast<u32>(inline_index_draw_indexes.size() / 4);
+ regs.index_buffer.format = Regs::IndexFormat::UnsignedInt;
+ break;
+ }
}
}