From bcaf7dfe1cecf6158ad5a0b4de6bc113144ae97b Mon Sep 17 00:00:00 2001 From: lynxnb Date: Wed, 20 Apr 2022 01:19:04 +0200 Subject: [PATCH] Make `GetVertexBuffer` return a pointer to the requested buffer This avoids a redundancy in the `Draw` function and makes code easier to read --- .../gpu/interconnect/graphics_context.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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 49aceaf9..60de2769 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h @@ -1726,19 +1726,19 @@ namespace skyline::gpu::interconnect { } } - BufferView GetVertexBuffer(size_t index) { + VertexBuffer *GetVertexBuffer(size_t index) { auto &vertexBuffer{vertexBuffers.at(index)}; if (vertexBuffer.start > vertexBuffer.end || vertexBuffer.start == 0 || vertexBuffer.end == 0) return nullptr; else if (vertexBuffer.view) - return vertexBuffer.view; + return &vertexBuffer; auto mappings{channelCtx.asCtx->gmmu.TranslateRange(vertexBuffer.start, (vertexBuffer.end + 1) - vertexBuffer.start)}; if (mappings.size() != 1) Logger::Warn("Multiple buffer mappings ({}) are not supported", mappings.size()); vertexBuffer.view = gpu.buffer.FindOrCreate(mappings.front(), executor.cycle); - return vertexBuffer.view; + return &vertexBuffer; } /* Input Assembly */ @@ -2619,12 +2619,12 @@ namespace skyline::gpu::interconnect { boost::container::static_vector vertexBindingDivisorsDescriptions{}; for (u32 index{}; index < maxwell3d::VertexBufferCount; index++) { - auto vertexBufferView{GetVertexBuffer(index)}; - if (vertexBufferView) { - auto &vertexBuffer{vertexBuffers[index]}; - vertexBindingDescriptions.push_back(vertexBuffer.bindingDescription); - if (vertexBuffer.bindingDescription.inputRate == vk::VertexInputRate::eInstance) - vertexBindingDivisorsDescriptions.push_back(vertexBuffer.bindingDivisorDescription); + auto vertexBuffer{GetVertexBuffer(index)}; + if (vertexBuffer) { + auto &vertexBufferView{vertexBuffer->view}; + vertexBindingDescriptions.push_back(vertexBuffer->bindingDescription); + if (vertexBuffer->bindingDescription.inputRate == vk::VertexInputRate::eInstance) + vertexBindingDivisorsDescriptions.push_back(vertexBuffer->bindingDivisorDescription); std::scoped_lock vertexBufferLock(vertexBufferView); vertexBufferView.RegisterUsage([handle = boundVertexBuffers->handles.data() + index, offset = boundVertexBuffers->offsets.data() + index](const Buffer::BufferViewStorage &view, const std::shared_ptr &buffer) {