mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-28 09:15:28 +03:00
Allow providing an index type to calculate quad conversion buffer size
This commit is contained in:
parent
7709dc8cf6
commit
8fc3bc75f4
@ -5,6 +5,9 @@
|
|||||||
|
|
||||||
#include <common/base.h>
|
#include <common/base.h>
|
||||||
|
|
||||||
|
#include <vulkan/vulkan.hpp>
|
||||||
|
#include <vulkan/vulkan_enums.hpp>
|
||||||
|
|
||||||
namespace skyline::gpu::interconnect::conversion::quads {
|
namespace skyline::gpu::interconnect::conversion::quads {
|
||||||
constexpr u32 EmittedIndexCount{6}; //!< The number of indices needed to draw a quad with two triangles
|
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
|
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
|
* @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<typename T>
|
constexpr size_t GetRequiredBufferSize(u32 count, vk::IndexType type) {
|
||||||
constexpr size_t GetRequiredBufferSize(u32 count) {
|
return GetIndexCount(count) * [&]() -> size_t {
|
||||||
return GetIndexCount(count) * sizeof(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;
|
||||||
|
}
|
||||||
|
}();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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
|
* @result A tuple containing a view over the index buffer, the index type and the index count
|
||||||
*/
|
*/
|
||||||
std::tuple<BufferView, vk::IndexType, u32> GetQuadListConversionBuffer(u32 count) {
|
std::tuple<BufferView, vk::IndexType, u32> GetQuadListConversionBuffer(u32 count) {
|
||||||
vk::DeviceSize size{conversion::quads::GetRequiredBufferSize<u32>(count)};
|
vk::DeviceSize size{conversion::quads::GetRequiredBufferSize(count, vk::IndexType::eUint32)};
|
||||||
if (!quadListConversionBuffer || quadListConversionBuffer->GetBackingSpan().size_bytes() < size) {
|
if (!quadListConversionBuffer || quadListConversionBuffer->GetBackingSpan().size_bytes() < size) {
|
||||||
quadListConversionBuffer = std::make_shared<Buffer>(gpu, size);
|
quadListConversionBuffer = std::make_shared<Buffer>(gpu, size);
|
||||||
conversion::quads::GenerateQuadListConversionBuffer(quadListConversionBuffer->GetBackingSpan().cast<u32>().data(), count);
|
conversion::quads::GenerateQuadListConversionBuffer(quadListConversionBuffer->GetBackingSpan().cast<u32>().data(), count);
|
||||||
|
Loading…
Reference in New Issue
Block a user