diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/engines/maxwell_3d.cpp | 48 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 1 |
2 files changed, 22 insertions, 27 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 55462752c..34bbc72cf 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -126,7 +126,6 @@ void Maxwell3D::InitializeRegisterDefaults() { | |||
| 126 | draw_command[MAXWELL3D_REG_INDEX(draw_inline_index)] = true; | 126 | draw_command[MAXWELL3D_REG_INDEX(draw_inline_index)] = true; |
| 127 | draw_command[MAXWELL3D_REG_INDEX(inline_index_2x16.even)] = true; | 127 | draw_command[MAXWELL3D_REG_INDEX(inline_index_2x16.even)] = true; |
| 128 | draw_command[MAXWELL3D_REG_INDEX(inline_index_4x8.index0)] = true; | 128 | draw_command[MAXWELL3D_REG_INDEX(inline_index_4x8.index0)] = true; |
| 129 | draw_command[MAXWELL3D_REG_INDEX(draw.instance_id)] = true; | ||
| 130 | } | 129 | } |
| 131 | 130 | ||
| 132 | void Maxwell3D::ProcessMacro(u32 method, const u32* base_start, u32 amount, bool is_last_call) { | 131 | void Maxwell3D::ProcessMacro(u32 method, const u32* base_start, u32 amount, bool is_last_call) { |
| @@ -218,16 +217,19 @@ void Maxwell3D::ProcessMethodCall(u32 method, u32 argument, u32 nonshadow_argume | |||
| 218 | regs.index_buffer.count = regs.index_buffer32_first.count; | 217 | regs.index_buffer.count = regs.index_buffer32_first.count; |
| 219 | regs.index_buffer.first = regs.index_buffer32_first.first; | 218 | regs.index_buffer.first = regs.index_buffer32_first.first; |
| 220 | dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; | 219 | dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; |
| 220 | draw_indexed = true; | ||
| 221 | return ProcessDraw(); | 221 | return ProcessDraw(); |
| 222 | case MAXWELL3D_REG_INDEX(index_buffer16_first): | 222 | case MAXWELL3D_REG_INDEX(index_buffer16_first): |
| 223 | regs.index_buffer.count = regs.index_buffer16_first.count; | 223 | regs.index_buffer.count = regs.index_buffer16_first.count; |
| 224 | regs.index_buffer.first = regs.index_buffer16_first.first; | 224 | regs.index_buffer.first = regs.index_buffer16_first.first; |
| 225 | dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; | 225 | dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; |
| 226 | draw_indexed = true; | ||
| 226 | return ProcessDraw(); | 227 | return ProcessDraw(); |
| 227 | case MAXWELL3D_REG_INDEX(index_buffer8_first): | 228 | case MAXWELL3D_REG_INDEX(index_buffer8_first): |
| 228 | regs.index_buffer.count = regs.index_buffer8_first.count; | 229 | regs.index_buffer.count = regs.index_buffer8_first.count; |
| 229 | regs.index_buffer.first = regs.index_buffer8_first.first; | 230 | regs.index_buffer.first = regs.index_buffer8_first.first; |
| 230 | dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; | 231 | dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; |
| 232 | draw_indexed = true; | ||
| 231 | return ProcessDraw(); | 233 | return ProcessDraw(); |
| 232 | case MAXWELL3D_REG_INDEX(topology_override): | 234 | case MAXWELL3D_REG_INDEX(topology_override): |
| 233 | use_topology_override = true; | 235 | use_topology_override = true; |
| @@ -300,21 +302,33 @@ void Maxwell3D::CallMethod(u32 method, u32 method_argument, bool is_last_call) { | |||
| 300 | draw_mode = DrawMode::InlineIndex; | 302 | draw_mode = DrawMode::InlineIndex; |
| 301 | }; | 303 | }; |
| 302 | switch (method) { | 304 | switch (method) { |
| 305 | case MAXWELL3D_REG_INDEX(draw.begin): { | ||
| 306 | draw_mode = | ||
| 307 | (regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::Subsequent) || | ||
| 308 | (regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::Unchanged) | ||
| 309 | ? DrawMode::Instance | ||
| 310 | : DrawMode::General; | ||
| 311 | break; | ||
| 312 | } | ||
| 303 | case MAXWELL3D_REG_INDEX(draw.end): | 313 | case MAXWELL3D_REG_INDEX(draw.end): |
| 304 | switch (draw_mode) { | 314 | switch (draw_mode) { |
| 305 | case DrawMode::General: | 315 | case DrawMode::General: |
| 306 | ProcessDraw(1); | 316 | ProcessDraw(); |
| 307 | break; | 317 | break; |
| 308 | case DrawMode::InlineIndex: | 318 | case DrawMode::InlineIndex: |
| 309 | regs.index_buffer.count = static_cast<u32>(inline_index_draw_indexes.size() / 4); | 319 | regs.index_buffer.count = static_cast<u32>(inline_index_draw_indexes.size() / 4); |
| 310 | regs.index_buffer.format = Regs::IndexFormat::UnsignedInt; | 320 | regs.index_buffer.format = Regs::IndexFormat::UnsignedInt; |
| 311 | ProcessDraw(1); | 321 | draw_indexed = true; |
| 322 | ProcessDraw(); | ||
| 312 | inline_index_draw_indexes.clear(); | 323 | inline_index_draw_indexes.clear(); |
| 313 | break; | 324 | break; |
| 314 | case DrawMode::Instance: | 325 | case DrawMode::Instance: |
| 315 | break; | 326 | break; |
| 316 | } | 327 | } |
| 317 | break; | 328 | break; |
| 329 | case MAXWELL3D_REG_INDEX(index_buffer.count): | ||
| 330 | draw_indexed = true; | ||
| 331 | break; | ||
| 318 | case MAXWELL3D_REG_INDEX(draw_inline_index): | 332 | case MAXWELL3D_REG_INDEX(draw_inline_index): |
| 319 | update_inline_index(method_argument); | 333 | update_inline_index(method_argument); |
| 320 | break; | 334 | break; |
| @@ -328,13 +342,6 @@ void Maxwell3D::CallMethod(u32 method, u32 method_argument, bool is_last_call) { | |||
| 328 | update_inline_index(regs.inline_index_4x8.index2); | 342 | update_inline_index(regs.inline_index_4x8.index2); |
| 329 | update_inline_index(regs.inline_index_4x8.index3); | 343 | update_inline_index(regs.inline_index_4x8.index3); |
| 330 | break; | 344 | break; |
| 331 | case MAXWELL3D_REG_INDEX(draw.instance_id): | ||
| 332 | draw_mode = | ||
| 333 | (regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::Subsequent) || | ||
| 334 | (regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::Unchanged) | ||
| 335 | ? DrawMode::Instance | ||
| 336 | : DrawMode::General; | ||
| 337 | break; | ||
| 338 | } | 345 | } |
| 339 | } else { | 346 | } else { |
| 340 | ProcessDeferredDraw(); | 347 | ProcessDeferredDraw(); |
| @@ -624,27 +631,16 @@ void Maxwell3D::ProcessClearBuffers(u32 layer_count) { | |||
| 624 | 631 | ||
| 625 | void Maxwell3D::ProcessDraw(u32 instance_count) { | 632 | void Maxwell3D::ProcessDraw(u32 instance_count) { |
| 626 | LOG_TRACE(HW_GPU, "called, topology={}, count={}", regs.draw.topology.Value(), | 633 | LOG_TRACE(HW_GPU, "called, topology={}, count={}", regs.draw.topology.Value(), |
| 627 | regs.vertex_buffer.count); | 634 | draw_indexed ? regs.index_buffer.count : regs.vertex_buffer.count); |
| 628 | |||
| 629 | ASSERT_MSG(!(regs.index_buffer.count && regs.vertex_buffer.count), "Both indexed and direct?"); | ||
| 630 | |||
| 631 | // Both instance configuration registers can not be set at the same time. | ||
| 632 | ASSERT_MSG(regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::First || | ||
| 633 | regs.draw.instance_id != Maxwell3D::Regs::Draw::InstanceId::Unchanged, | ||
| 634 | "Illegal combination of instancing parameters"); | ||
| 635 | 635 | ||
| 636 | ProcessTopologyOverride(); | 636 | ProcessTopologyOverride(); |
| 637 | 637 | ||
| 638 | const bool is_indexed = regs.index_buffer.count && !regs.vertex_buffer.count; | ||
| 639 | if (ShouldExecute()) { | 638 | if (ShouldExecute()) { |
| 640 | rasterizer->Draw(is_indexed, instance_count); | 639 | rasterizer->Draw(draw_indexed, instance_count); |
| 641 | } | 640 | } |
| 642 | 641 | ||
| 643 | if (is_indexed) { | 642 | draw_indexed = false; |
| 644 | regs.index_buffer.count = 0; | 643 | deferred_draw_method.clear(); |
| 645 | } else { | ||
| 646 | regs.vertex_buffer.count = 0; | ||
| 647 | } | ||
| 648 | } | 644 | } |
| 649 | 645 | ||
| 650 | void Maxwell3D::ProcessDeferredDraw() { | 646 | void Maxwell3D::ProcessDeferredDraw() { |
| @@ -667,8 +663,6 @@ void Maxwell3D::ProcessDeferredDraw() { | |||
| 667 | ASSERT_MSG(!(vertex_buffer_count && index_buffer_count), "Instance both indexed and direct?"); | 663 | ASSERT_MSG(!(vertex_buffer_count && index_buffer_count), "Instance both indexed and direct?"); |
| 668 | 664 | ||
| 669 | ProcessDraw(instance_count); | 665 | ProcessDraw(instance_count); |
| 670 | |||
| 671 | deferred_draw_method.clear(); | ||
| 672 | } | 666 | } |
| 673 | 667 | ||
| 674 | } // namespace Tegra::Engines | 668 | } // namespace Tegra::Engines |
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index deba292a5..a541cd95f 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -3159,6 +3159,7 @@ private: | |||
| 3159 | std::vector<u32> deferred_draw_method; | 3159 | std::vector<u32> deferred_draw_method; |
| 3160 | enum class DrawMode : u32 { General = 0, Instance, InlineIndex }; | 3160 | enum class DrawMode : u32 { General = 0, Instance, InlineIndex }; |
| 3161 | DrawMode draw_mode{DrawMode::General}; | 3161 | DrawMode draw_mode{DrawMode::General}; |
| 3162 | bool draw_indexed{}; | ||
| 3162 | }; | 3163 | }; |
| 3163 | 3164 | ||
| 3164 | #define ASSERT_REG_POSITION(field_name, position) \ | 3165 | #define ASSERT_REG_POSITION(field_name, position) \ |