diff --git a/app/src/main/cpp/skyline/gpu/interconnect/inline2memory.cpp b/app/src/main/cpp/skyline/gpu/interconnect/inline2memory.cpp index a8432b7b..d7f1c14b 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/inline2memory.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/inline2memory.cpp @@ -15,24 +15,19 @@ namespace skyline::gpu::interconnect { channelCtx{channelCtx}, executor{channelCtx.executor} {} - void Inline2Memory::Upload(IOVA dst, span src) { - auto dstMappings{channelCtx.asCtx->gmmu.TranslateRange(dst, src.size_bytes())}; - - if (dstMappings.size() > 1) - Logger::Warn("Split mapping are unsupported for DMA copies"); - - auto dstBuf{gpu.buffer.FindOrCreate(dstMappings.front(), executor.tag, [this](std::shared_ptr buffer, ContextLock &&lock) { + void Inline2Memory::UploadSingleMapping(span dst, span src) { + auto dstBuf{gpu.buffer.FindOrCreate(dst, executor.tag, [this](std::shared_ptr buffer, ContextLock &&lock) { executor.AttachLockedBuffer(buffer, std::move(lock)); })}; ContextLock dstBufLock{executor.tag, dstBuf}; - dstBuf.Write(src.cast(), 0, [&]() { + dstBuf.Write(src, 0, [&]() { executor.AttachLockedBufferView(dstBuf, std::move(dstBufLock)); // This will prevent any CPU accesses to backing for the duration of the usage dstBuf.GetBuffer()->BlockAllCpuBackingWrites(); - auto srcGpuAllocation{gpu.megaBufferAllocator.Push(executor.cycle, src.cast())}; + auto srcGpuAllocation{gpu.megaBufferAllocator.Push(executor.cycle, src)}; executor.AddOutsideRpCommand([srcGpuAllocation, dstBuf, src](vk::raii::CommandBuffer &commandBuffer, const std::shared_ptr &, GPU &) { vk::BufferCopy copyRegion{ .size = src.size_bytes(), @@ -47,4 +42,14 @@ namespace skyline::gpu::interconnect { }); }); } + + void Inline2Memory::Upload(IOVA dst, span src) { + auto dstMappings{channelCtx.asCtx->gmmu.TranslateRange(dst, src.size_bytes())}; + + size_t offset{}; + for (auto mapping : dstMappings) { + UploadSingleMapping(mapping, src.cast().subspan(offset, mapping.size())); + offset += mapping.size(); + } + } } diff --git a/app/src/main/cpp/skyline/gpu/interconnect/inline2memory.h b/app/src/main/cpp/skyline/gpu/interconnect/inline2memory.h index b24a4fee..91c71b8c 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/inline2memory.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/inline2memory.h @@ -28,6 +28,8 @@ namespace skyline::gpu::interconnect { soc::gm20b::ChannelContext &channelCtx; gpu::interconnect::CommandExecutor &executor; + void UploadSingleMapping(span dst, span src); + public: Inline2Memory(GPU &gpu, soc::gm20b::ChannelContext &channelCtx);