diff options
| author | 2022-12-06 13:45:26 +0800 | |
|---|---|---|
| committer | 2022-12-08 10:12:19 +0800 | |
| commit | bf0b957c05013f33855e67c31a48e61b1e86d356 (patch) | |
| tree | 72db2458cb7e5b7572b53527e0755d4fe45e9db0 /src/video_core/buffer_cache | |
| parent | Merge pull request #9381 from liamwhite/uninit (diff) | |
| download | yuzu-bf0b957c05013f33855e67c31a48e61b1e86d356.tar.gz yuzu-bf0b957c05013f33855e67c31a48e61b1e86d356.tar.xz yuzu-bf0b957c05013f33855e67c31a48e61b1e86d356.zip | |
video_core: Implement maxwell3d draw manager and split draw logic
Diffstat (limited to 'src/video_core/buffer_cache')
| -rw-r--r-- | src/video_core/buffer_cache/buffer_cache.h | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 6881b34c4..502b4d90a 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include "video_core/control/channel_state_cache.h" | 26 | #include "video_core/control/channel_state_cache.h" |
| 27 | #include "video_core/delayed_destruction_ring.h" | 27 | #include "video_core/delayed_destruction_ring.h" |
| 28 | #include "video_core/dirty_flags.h" | 28 | #include "video_core/dirty_flags.h" |
| 29 | #include "video_core/engines/draw_manager.h" | ||
| 29 | #include "video_core/engines/kepler_compute.h" | 30 | #include "video_core/engines/kepler_compute.h" |
| 30 | #include "video_core/engines/maxwell_3d.h" | 31 | #include "video_core/engines/maxwell_3d.h" |
| 31 | #include "video_core/memory_manager.h" | 32 | #include "video_core/memory_manager.h" |
| @@ -664,9 +665,10 @@ void BufferCache<P>::BindHostGeometryBuffers(bool is_indexed) { | |||
| 664 | if (is_indexed) { | 665 | if (is_indexed) { |
| 665 | BindHostIndexBuffer(); | 666 | BindHostIndexBuffer(); |
| 666 | } else if constexpr (!HAS_FULL_INDEX_AND_PRIMITIVE_SUPPORT) { | 667 | } else if constexpr (!HAS_FULL_INDEX_AND_PRIMITIVE_SUPPORT) { |
| 667 | const auto& regs = maxwell3d->regs; | 668 | const auto& draw_state = maxwell3d->draw_manager->GetDrawState(); |
| 668 | if (regs.draw.topology == Maxwell::PrimitiveTopology::Quads) { | 669 | if (draw_state.topology == Maxwell::PrimitiveTopology::Quads) { |
| 669 | runtime.BindQuadArrayIndexBuffer(regs.vertex_buffer.first, regs.vertex_buffer.count); | 670 | runtime.BindQuadArrayIndexBuffer(draw_state.vertex_buffer.first, |
| 671 | draw_state.vertex_buffer.count); | ||
| 670 | } | 672 | } |
| 671 | } | 673 | } |
| 672 | BindHostVertexBuffers(); | 674 | BindHostVertexBuffers(); |
| @@ -993,28 +995,29 @@ void BufferCache<P>::BindHostIndexBuffer() { | |||
| 993 | TouchBuffer(buffer, index_buffer.buffer_id); | 995 | TouchBuffer(buffer, index_buffer.buffer_id); |
| 994 | const u32 offset = buffer.Offset(index_buffer.cpu_addr); | 996 | const u32 offset = buffer.Offset(index_buffer.cpu_addr); |
| 995 | const u32 size = index_buffer.size; | 997 | const u32 size = index_buffer.size; |
| 996 | if (maxwell3d->inline_index_draw_indexes.size()) { | 998 | const auto& draw_state = maxwell3d->draw_manager->GetDrawState(); |
| 999 | if (!draw_state.inline_index_draw_indexes.empty()) { | ||
| 997 | if constexpr (USE_MEMORY_MAPS) { | 1000 | if constexpr (USE_MEMORY_MAPS) { |
| 998 | auto upload_staging = runtime.UploadStagingBuffer(size); | 1001 | auto upload_staging = runtime.UploadStagingBuffer(size); |
| 999 | std::array<BufferCopy, 1> copies{ | 1002 | std::array<BufferCopy, 1> copies{ |
| 1000 | {BufferCopy{.src_offset = upload_staging.offset, .dst_offset = 0, .size = size}}}; | 1003 | {BufferCopy{.src_offset = upload_staging.offset, .dst_offset = 0, .size = size}}}; |
| 1001 | std::memcpy(upload_staging.mapped_span.data(), | 1004 | std::memcpy(upload_staging.mapped_span.data(), |
| 1002 | maxwell3d->inline_index_draw_indexes.data(), size); | 1005 | draw_state.inline_index_draw_indexes.data(), size); |
| 1003 | runtime.CopyBuffer(buffer, upload_staging.buffer, copies); | 1006 | runtime.CopyBuffer(buffer, upload_staging.buffer, copies); |
| 1004 | } else { | 1007 | } else { |
| 1005 | buffer.ImmediateUpload(0, maxwell3d->inline_index_draw_indexes); | 1008 | buffer.ImmediateUpload(0, draw_state.inline_index_draw_indexes); |
| 1006 | } | 1009 | } |
| 1007 | } else { | 1010 | } else { |
| 1008 | SynchronizeBuffer(buffer, index_buffer.cpu_addr, size); | 1011 | SynchronizeBuffer(buffer, index_buffer.cpu_addr, size); |
| 1009 | } | 1012 | } |
| 1010 | if constexpr (HAS_FULL_INDEX_AND_PRIMITIVE_SUPPORT) { | 1013 | if constexpr (HAS_FULL_INDEX_AND_PRIMITIVE_SUPPORT) { |
| 1011 | const u32 new_offset = offset + maxwell3d->regs.index_buffer.first * | 1014 | const u32 new_offset = |
| 1012 | maxwell3d->regs.index_buffer.FormatSizeInBytes(); | 1015 | offset + draw_state.index_buffer.first * draw_state.index_buffer.FormatSizeInBytes(); |
| 1013 | runtime.BindIndexBuffer(buffer, new_offset, size); | 1016 | runtime.BindIndexBuffer(buffer, new_offset, size); |
| 1014 | } else { | 1017 | } else { |
| 1015 | runtime.BindIndexBuffer(maxwell3d->regs.draw.topology, maxwell3d->regs.index_buffer.format, | 1018 | runtime.BindIndexBuffer(draw_state.topology, draw_state.index_buffer.format, |
| 1016 | maxwell3d->regs.index_buffer.first, | 1019 | draw_state.index_buffer.first, draw_state.index_buffer.count, |
| 1017 | maxwell3d->regs.index_buffer.count, buffer, offset, size); | 1020 | buffer, offset, size); |
| 1018 | } | 1021 | } |
| 1019 | } | 1022 | } |
| 1020 | 1023 | ||
| @@ -1282,15 +1285,16 @@ template <class P> | |||
| 1282 | void BufferCache<P>::UpdateIndexBuffer() { | 1285 | void BufferCache<P>::UpdateIndexBuffer() { |
| 1283 | // We have to check for the dirty flags and index count | 1286 | // We have to check for the dirty flags and index count |
| 1284 | // The index count is currently changed without updating the dirty flags | 1287 | // The index count is currently changed without updating the dirty flags |
| 1285 | const auto& index_array = maxwell3d->regs.index_buffer; | 1288 | const auto& draw_state = maxwell3d->draw_manager->GetDrawState(); |
| 1289 | const auto& index_array = draw_state.index_buffer; | ||
| 1286 | auto& flags = maxwell3d->dirty.flags; | 1290 | auto& flags = maxwell3d->dirty.flags; |
| 1287 | if (!flags[Dirty::IndexBuffer] && last_index_count == index_array.count) { | 1291 | if (!flags[Dirty::IndexBuffer] && last_index_count == index_array.count) { |
| 1288 | return; | 1292 | return; |
| 1289 | } | 1293 | } |
| 1290 | flags[Dirty::IndexBuffer] = false; | 1294 | flags[Dirty::IndexBuffer] = false; |
| 1291 | last_index_count = index_array.count; | 1295 | last_index_count = index_array.count; |
| 1292 | if (maxwell3d->inline_index_draw_indexes.size()) { | 1296 | if (!draw_state.inline_index_draw_indexes.empty()) { |
| 1293 | auto inline_index_size = static_cast<u32>(maxwell3d->inline_index_draw_indexes.size()); | 1297 | auto inline_index_size = static_cast<u32>(draw_state.inline_index_draw_indexes.size()); |
| 1294 | index_buffer = Binding{ | 1298 | index_buffer = Binding{ |
| 1295 | .cpu_addr = 0, | 1299 | .cpu_addr = 0, |
| 1296 | .size = inline_index_size, | 1300 | .size = inline_index_size, |