Add new mesh data formats: int32, uint32, [u]int8, [u]int16, snorm8, and snorm16.

Integer formats for vertex attributes are only supported in glsl3 shaders. They use ivec/uvec types in glsl.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2020-01-11 22:24:38 -04:00
parent 5c009d4bb9
commit 23bc1a7aae
9 changed files with 193 additions and 69 deletions
+8 -3
View File
@@ -73,7 +73,7 @@ Mesh::Mesh(graphics::Graphics *gfx, const std::vector<AttribFormat> &vertexforma
, rangeCount(-1)
{
setupAttachedAttributes();
calculateAttributeSizes();
calculateAttributeSizes(gfx);
vertexCount = datasize / vertexStride;
indexDataType = vertex::getIndexDataTypeFromMax(vertexCount);
@@ -103,7 +103,7 @@ Mesh::Mesh(graphics::Graphics *gfx, const std::vector<AttribFormat> &vertexforma
throw love::Exception("Invalid number of vertices (%d).", vertexcount);
setupAttachedAttributes();
calculateAttributeSizes();
calculateAttributeSizes(gfx);
size_t buffersize = vertexCount * vertexStride;
@@ -143,8 +143,10 @@ void Mesh::setupAttachedAttributes()
}
}
void Mesh::calculateAttributeSizes()
void Mesh::calculateAttributeSizes(Graphics *gfx)
{
bool supportsGLSL3 = gfx->getCapabilities().features[Graphics::FEATURE_GLSL3];
size_t stride = 0;
for (const AttribFormat &format : vertexFormat)
@@ -158,6 +160,9 @@ void Mesh::calculateAttributeSizes()
if (size % 4 != 0)
throw love::Exception("Vertex attributes must have enough components to be a multiple of 32 bits.");
if (vertex::isDataTypeInteger(format.type) && !supportsGLSL3)
throw love::Exception("Integer vertex attribute data types require GLSL 3 support.");
// Total size in bytes of each attribute in a single vertex.
attributeSizes.push_back(size);
stride += size;