diff --git a/app/src/main/cpp/skyline/gpu/interconnect/conversion/quads.h b/app/src/main/cpp/skyline/gpu/interconnect/conversion/quads.h index 4556f11c..186f5507 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/conversion/quads.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/conversion/quads.h @@ -5,6 +5,9 @@ #include +#include +#include + namespace skyline::gpu::interconnect::conversion::quads { constexpr u32 EmittedIndexCount{6}; //!< The number of indices needed to draw a quad with two triangles constexpr u32 QuadVertexCount{4}; //!< The amount of vertices a quad is composed of @@ -18,11 +21,21 @@ namespace skyline::gpu::interconnect::conversion::quads { /** * @return The minimum size (in bytes) required to store the quad index buffer of the given type after conversion - * @tparam T The type of an element in the index buffer + * @param type The type of an element in the index buffer */ - template - constexpr size_t GetRequiredBufferSize(u32 count) { - return GetIndexCount(count) * sizeof(T); + constexpr size_t GetRequiredBufferSize(u32 count, vk::IndexType type) { + return GetIndexCount(count) * [&]() -> size_t { + switch (type) { + case vk::IndexType::eUint32: + return sizeof(u32); + case vk::IndexType::eUint16: + return sizeof(u16); + case vk::IndexType::eUint8EXT: + return sizeof(u8); + default: + return 0; + } + }(); } /** 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 424fe2bb..99cd1530 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h @@ -1688,7 +1688,7 @@ namespace skyline::gpu::interconnect { * @result A tuple containing a view over the index buffer, the index type and the index count */ std::tuple GetQuadListConversionBuffer(u32 count) { - vk::DeviceSize size{conversion::quads::GetRequiredBufferSize(count)}; + vk::DeviceSize size{conversion::quads::GetRequiredBufferSize(count, vk::IndexType::eUint32)}; if (!quadListConversionBuffer || quadListConversionBuffer->GetBackingSpan().size_bytes() < size) { quadListConversionBuffer = std::make_shared(gpu, size); conversion::quads::GenerateQuadListConversionBuffer(quadListConversionBuffer->GetBackingSpan().cast().data(), count);