From 898930563759e5b9c54e93f8bd34405c353faec9 Mon Sep 17 00:00:00 2001 From: PixelyIon Date: Tue, 7 Dec 2021 02:06:00 +0530 Subject: [PATCH] Implement Host Vertex Buffer Translation Uses the buffer cache to retrieve an equivalent host vertex buffer for a corresponding guest vertex buffer. --- .../skyline/gpu/interconnect/graphics_context.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h b/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h index 28b4c7ec..11b8df99 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h @@ -1060,6 +1060,22 @@ namespace skyline::gpu::interconnect { } } + BufferView *GetVertexBuffer(size_t index) { + auto &vertexBuffer{vertexBuffers.at(index)}; + if (vertexBuffer.disabled || vertexBuffer.start > vertexBuffer.end) + return nullptr; + else if (vertexBuffer.view) + return &*vertexBuffer.view; + + if (vertexBuffer.guest.mappings.empty()) { + auto mappings{channelCtx.asCtx->gmmu.TranslateRange(vertexBuffer.start, (vertexBuffer.end + 1) - vertexBuffer.start)}; + vertexBuffer.guest.mappings.assign(mappings.begin(), mappings.end()); + } + + vertexBuffer.view = gpu.buffer.FindOrCreate(vertexBuffer.guest); + return vertexBuffer.view.get(); + } + /* Input Assembly */ private: vk::PipelineInputAssemblyStateCreateInfo inputAssemblyState{};