From 9f2b20443b71668f3e173b1392c49a92a3e0cb53 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Thu, 29 Sep 2022 20:55:08 +0100 Subject: [PATCH] Implement Maxwell3D draws --- .../interconnect/maxwell_3d/maxwell_3d.cpp | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp index f094fd40..e22596ce 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp @@ -240,16 +240,31 @@ namespace skyline::gpu::interconnect::maxwell3d { builder.SetDescriptorSetWithUpdate(descUpdateInfo, activeDescriptorSet, oldSet); } + auto stateUpdater{builder.Build()}; + + struct DrawParams { + u32 count; + u32 first; + u32 instanceCount; + u32 vertexOffset; + u32 firstInstance; + bool indexed; + }; + auto *drawParams{ctx.executor.allocator->EmplaceUntracked(DrawParams{count, first, instanceCount, vertexOffset, firstInstance, indexed})}; + const auto &surfaceClip{clearEngineRegisters.surfaceClip}; vk::Rect2D scissor{ {surfaceClip.horizontal.x, surfaceClip.vertical.y}, {surfaceClip.horizontal.width, surfaceClip.vertical.height} }; - auto stateUpdater{builder.Build()}; - ctx.executor.AddSubpass([stateUpdater](vk::raii::CommandBuffer &commandBuffer, const std::shared_ptr &, GPU &gpu, vk::RenderPass, u32) { + ctx.executor.AddSubpass([stateUpdater, drawParams](vk::raii::CommandBuffer &commandBuffer, const std::shared_ptr &, GPU &gpu, vk::RenderPass, u32) { stateUpdater.RecordAll(gpu, commandBuffer); - }, scissor, {}, activeState.GetColorAttachments(), activeState.GetDepthAttachment()); + if (drawParams->indexed) + commandBuffer.drawIndexed(drawParams->count, drawParams->instanceCount, drawParams->first, static_cast(drawParams->vertexOffset), drawParams->firstInstance); + else + commandBuffer.draw(drawParams->count, drawParams->instanceCount, drawParams->first, drawParams->firstInstance); + }, scissor, {}, activeState.GetColorAttachments(), activeState.GetDepthAttachment(), !ctx.gpu.traits.quirks.relaxedRenderPassCompatibility); constantBuffers.ResetQuickBind(); }