From 612f324e786692f4efcd4217800a56d99f3598e5 Mon Sep 17 00:00:00 2001 From: PixelyIon Date: Tue, 16 Nov 2021 15:28:05 +0530 Subject: [PATCH] Implement Maxwell3D Vertex Buffer Instance Rate Implements the `isVertexInputRatePerInstance` register array which controls if the vertex input rate is either per-vertex or per-instance. This works in conjunction with the vertex attribute divisor for per-instance attribute repetition of attributes. --- .../gpu/interconnect/graphics_context.h | 4 +++ .../skyline/soc/gm20b/engines/maxwell_3d.cpp | 27 ++++++++++--------- .../skyline/soc/gm20b/engines/maxwell_3d.h | 2 ++ 3 files changed, 21 insertions(+), 12 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 92d730f8..73ea4173 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h @@ -784,6 +784,10 @@ namespace skyline::gpu::interconnect { vertexBindings[index].stride = stride; } + void SetVertexBufferInputRate(u32 index, bool isPerInstance) { + vertexBindings[index].inputRate = isPerInstance ? vk::VertexInputRate::eInstance : vk::VertexInputRate::eVertex; + } + void SetVertexBufferIovaHigh(u32 index, u32 high) { vertexBindingIovas[index].high = high; } 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 95a5915f..9ef02b5c 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 @@ -324,18 +324,21 @@ namespace skyline::soc::gm20b::engine::maxwell3d { context.SetBlendLogicOpType(type); }) - #define VERTEX_BUFFER_CALLBACKS(z, index, data) \ - MAXWELL3D_ARRAY_STRUCT_CASE(vertexBuffers, index, config, { \ - context.SetVertexBufferStride(index, config.stride); \ - }) \ - MAXWELL3D_ARRAY_STRUCT_STRUCT_CASE(vertexBuffers, index, iova, high, { \ - context.SetVertexBufferIovaHigh(index, high); \ - }) \ - MAXWELL3D_ARRAY_STRUCT_STRUCT_CASE(vertexBuffers, index, iova, low, { \ - context.SetVertexBufferIovaLow(index, low); \ - }) \ - MAXWELL3D_ARRAY_STRUCT_CASE(vertexBuffers, index, divisor, { \ - context.SetVertexBufferDivisor(index, divisor); \ + #define VERTEX_BUFFER_CALLBACKS(z, index, data) \ + MAXWELL3D_ARRAY_STRUCT_CASE(vertexBuffers, index, config, { \ + context.SetVertexBufferStride(index, config.stride); \ + }) \ + MAXWELL3D_ARRAY_STRUCT_STRUCT_CASE(vertexBuffers, index, iova, high, { \ + context.SetVertexBufferIovaHigh(index, high); \ + }) \ + MAXWELL3D_ARRAY_STRUCT_STRUCT_CASE(vertexBuffers, index, iova, low, { \ + context.SetVertexBufferIovaLow(index, low); \ + }) \ + MAXWELL3D_ARRAY_STRUCT_CASE(vertexBuffers, index, divisor, { \ + context.SetVertexBufferDivisor(index, divisor); \ + }) \ + MAXWELL3D_ARRAY_CASE(isVertexInputRatePerInstance, index, { \ + context.SetVertexBufferInputRate(index, isVertexInputRatePerInstance); \ }) 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 95337903..3b15399c 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 @@ -206,6 +206,8 @@ namespace skyline::soc::gm20b::engine::maxwell3d { Register<0x61F, float> depthBiasClamp; + Register<0x620, std::array> isVertexInputRatePerInstance; //!< A per-VBO boolean denoting if the vertex input rate should be per vertex or per instance + Register<0x646, u32> cullFaceEnable; Register<0x647, type::FrontFace> frontFace; Register<0x648, type::CullFace> cullFace;