summaryrefslogtreecommitdiff
path: root/src/video_core/buffer_cache
diff options
context:
space:
mode:
authorGravatar Feng Chen2022-11-09 15:57:42 +0800
committerGravatar Feng Chen2022-11-15 12:10:44 +0800
commitcb971ad654256f2de89119a7f9e2a98bb312241f (patch)
tree80c81ed8e12ab907c2d983467cccd88de47ec887 /src/video_core/buffer_cache
parentMerge pull request #9199 from liamwhite/service-oops (diff)
downloadyuzu-cb971ad654256f2de89119a7f9e2a98bb312241f.tar.gz
yuzu-cb971ad654256f2de89119a7f9e2a98bb312241f.tar.xz
yuzu-cb971ad654256f2de89119a7f9e2a98bb312241f.zip
video_core: Reimplement inline index buffer binding
Diffstat (limited to 'src/video_core/buffer_cache')
-rw-r--r--src/video_core/buffer_cache/buffer_cache.h33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h
index 2ba33543c..599551013 100644
--- a/src/video_core/buffer_cache/buffer_cache.h
+++ b/src/video_core/buffer_cache/buffer_cache.h
@@ -992,7 +992,20 @@ void BufferCache<P>::BindHostIndexBuffer() {
992 TouchBuffer(buffer, index_buffer.buffer_id); 992 TouchBuffer(buffer, index_buffer.buffer_id);
993 const u32 offset = buffer.Offset(index_buffer.cpu_addr); 993 const u32 offset = buffer.Offset(index_buffer.cpu_addr);
994 const u32 size = index_buffer.size; 994 const u32 size = index_buffer.size;
995 SynchronizeBuffer(buffer, index_buffer.cpu_addr, size); 995 if (maxwell3d->inline_index_draw_indexes.size()) {
996 if constexpr (USE_MEMORY_MAPS) {
997 auto upload_staging = runtime.UploadStagingBuffer(size);
998 std::array<BufferCopy, 1> copies{
999 {BufferCopy{.src_offset = upload_staging.offset, .dst_offset = 0, .size = size}}};
1000 std::memcpy(upload_staging.mapped_span.data(),
1001 maxwell3d->inline_index_draw_indexes.data(), size);
1002 runtime.CopyBuffer(buffer, upload_staging.buffer, copies);
1003 } else {
1004 buffer.ImmediateUpload(0, maxwell3d->inline_index_draw_indexes);
1005 }
1006 } else {
1007 SynchronizeBuffer(buffer, index_buffer.cpu_addr, size);
1008 }
996 if constexpr (HAS_FULL_INDEX_AND_PRIMITIVE_SUPPORT) { 1009 if constexpr (HAS_FULL_INDEX_AND_PRIMITIVE_SUPPORT) {
997 const u32 new_offset = offset + maxwell3d->regs.index_buffer.first * 1010 const u32 new_offset = offset + maxwell3d->regs.index_buffer.first *
998 maxwell3d->regs.index_buffer.FormatSizeInBytes(); 1011 maxwell3d->regs.index_buffer.FormatSizeInBytes();
@@ -1275,7 +1288,15 @@ void BufferCache<P>::UpdateIndexBuffer() {
1275 } 1288 }
1276 flags[Dirty::IndexBuffer] = false; 1289 flags[Dirty::IndexBuffer] = false;
1277 last_index_count = index_array.count; 1290 last_index_count = index_array.count;
1278 1291 if (maxwell3d->inline_index_draw_indexes.size()) {
1292 auto inline_index_size = static_cast<u32>(maxwell3d->inline_index_draw_indexes.size());
1293 index_buffer = Binding{
1294 .cpu_addr = 0,
1295 .size = inline_index_size,
1296 .buffer_id = CreateBuffer(0, inline_index_size),
1297 };
1298 return;
1299 }
1279 const GPUVAddr gpu_addr_begin = index_array.StartAddress(); 1300 const GPUVAddr gpu_addr_begin = index_array.StartAddress();
1280 const GPUVAddr gpu_addr_end = index_array.EndAddress(); 1301 const GPUVAddr gpu_addr_end = index_array.EndAddress();
1281 const std::optional<VAddr> cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr_begin); 1302 const std::optional<VAddr> cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr_begin);
@@ -1491,6 +1512,14 @@ typename BufferCache<P>::OverlapResult BufferCache<P>::ResolveOverlaps(VAddr cpu
1491 VAddr end = cpu_addr + wanted_size; 1512 VAddr end = cpu_addr + wanted_size;
1492 int stream_score = 0; 1513 int stream_score = 0;
1493 bool has_stream_leap = false; 1514 bool has_stream_leap = false;
1515 if (begin == 0) {
1516 return OverlapResult{
1517 .ids = std::move(overlap_ids),
1518 .begin = begin,
1519 .end = end,
1520 .has_stream_leap = has_stream_leap,
1521 };
1522 }
1494 for (; cpu_addr >> YUZU_PAGEBITS < Common::DivCeil(end, YUZU_PAGESIZE); 1523 for (; cpu_addr >> YUZU_PAGEBITS < Common::DivCeil(end, YUZU_PAGESIZE);
1495 cpu_addr += YUZU_PAGESIZE) { 1524 cpu_addr += YUZU_PAGESIZE) {
1496 const BufferId overlap_id = page_table[cpu_addr >> YUZU_PAGEBITS]; 1525 const BufferId overlap_id = page_table[cpu_addr >> YUZU_PAGEBITS];