From c2a6da64311c35670e7cbf4c8f1700263537fe7f Mon Sep 17 00:00:00 2001 From: PixelyIon Date: Tue, 16 Nov 2021 16:12:30 +0530 Subject: [PATCH] Implement Maxwell3D Vertex Buffer Limit Sets the end of VBOs based on the `vertexArrayLimits` register array which provides an IOVA to the end of the VBO. --- .../gpu/interconnect/graphics_context.h | 21 ++++++++++++++----- .../skyline/soc/gm20b/engines/maxwell_3d.cpp | 10 +++++++-- .../skyline/soc/gm20b/engines/maxwell_3d.h | 2 ++ 3 files changed, 26 insertions(+), 7 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 73ea4173..37ccb322 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h @@ -766,7 +766,10 @@ namespace skyline::gpu::interconnect { /* Vertex Buffers */ private: - std::array vertexBindingIovas{}; + struct VertexBuffer { + IOVA start{}, end{}; //!< IOVAs covering a contiguous region in GPU AS with the vertex buffer + }; + std::array vertexBuffers{}; std::array vertexBindings{}; std::array vertexBindingDivisors{}; vk::StructureChain vertexState{ @@ -788,12 +791,20 @@ namespace skyline::gpu::interconnect { vertexBindings[index].inputRate = isPerInstance ? vk::VertexInputRate::eInstance : vk::VertexInputRate::eVertex; } - void SetVertexBufferIovaHigh(u32 index, u32 high) { - vertexBindingIovas[index].high = high; + void SetVertexBufferStartIovaHigh(u32 index, u32 high) { + vertexBuffers[index].start.high = high; } - void SetVertexBufferIovaLow(u32 index, u32 low) { - vertexBindingIovas[index].low = low; + void SetVertexBufferStartIovaLow(u32 index, u32 low) { + vertexBuffers[index].start.low = low; + } + + void SetVertexBufferEndIovaHigh(u32 index, u32 high) { + vertexBuffers[index].end.high = high; + } + + void SetVertexBufferEndIovaLow(u32 index, u32 low) { + vertexBuffers[index].end.low = low; } void SetVertexBufferDivisor(u32 index, u32 divisor) { diff --git a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp index 7c950fe7..270dca15 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp +++ b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp @@ -329,16 +329,22 @@ namespace skyline::soc::gm20b::engine::maxwell3d { context.SetVertexBufferStride(index, config.stride); \ }) \ MAXWELL3D_ARRAY_STRUCT_STRUCT_CASE(vertexBuffers, index, iova, high, { \ - context.SetVertexBufferIovaHigh(index, high); \ + context.SetVertexBufferStartIovaHigh(index, high); \ }) \ MAXWELL3D_ARRAY_STRUCT_STRUCT_CASE(vertexBuffers, index, iova, low, { \ - context.SetVertexBufferIovaLow(index, low); \ + context.SetVertexBufferStartIovaLow(index, low); \ }) \ MAXWELL3D_ARRAY_STRUCT_CASE(vertexBuffers, index, divisor, { \ context.SetVertexBufferDivisor(index, divisor); \ }) \ MAXWELL3D_ARRAY_CASE(isVertexInputRatePerInstance, index, { \ context.SetVertexBufferInputRate(index, isVertexInputRatePerInstance); \ + }) \ + MAXWELL3D_ARRAY_STRUCT_CASE(vertexBufferLimits, index, high, { \ + context.SetVertexBufferEndIovaHigh(index, high); \ + }) \ + MAXWELL3D_ARRAY_STRUCT_CASE(vertexBufferLimits, index, low, { \ + context.SetVertexBufferEndIovaLow(index, low); \ }) BOOST_PP_REPEAT(16, VERTEX_BUFFER_CALLBACKS, 0) diff --git a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.h b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.h index 3b15399c..42f41f88 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.h +++ b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.h @@ -258,6 +258,8 @@ namespace skyline::soc::gm20b::engine::maxwell3d { }; Register<0x780, std::array> independentBlend; + Register<0x7C0, std::array> vertexBufferLimits; //!< A per-VBO IOVA denoting the end of the vertex buffer + Register<0x800, std::array> setProgram; Register<0x8C0, u32[0x20]> firmwareCall;