diff --git a/src/modules/graphics/metal/Shader.mm b/src/modules/graphics/metal/Shader.mm index e2859dd55..b481236c0 100644 --- a/src/modules/graphics/metal/Shader.mm +++ b/src/modules/graphics/metal/Shader.mm @@ -948,7 +948,7 @@ id Shader::getCachedRenderPipeline(const RenderPipelineK const auto &attrib = attributes.attribs[i]; int metalBufferIndex = firstVertexBufferBinding + attrib.bufferIndex; - vertdesc.attributes[i].format = getMTLVertexFormat(attrib.format); + vertdesc.attributes[i].format = getMTLVertexFormat(attrib.getFormat()); vertdesc.attributes[i].offset = attrib.offsetFromVertex; vertdesc.attributes[i].bufferIndex = metalBufferIndex; diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp index 68446af0a..845030f8d 100644 --- a/src/modules/graphics/opengl/OpenGL.cpp +++ b/src/modules/graphics/opengl/OpenGL.cpp @@ -870,7 +870,7 @@ void OpenGL::setVertexAttributes(const VertexAttributes &attributes, const Buffe int components = 0; GLboolean normalized = GL_FALSE; bool intformat = false; - GLenum gltype = getGLVertexDataType(attrib.format, components, normalized, intformat); + GLenum gltype = getGLVertexDataType(attrib.getFormat(), components, normalized, intformat); const void *offsetpointer = reinterpret_cast(bufferinfo.offset + attrib.offsetFromVertex); diff --git a/src/modules/graphics/vertex.cpp b/src/modules/graphics/vertex.cpp index bc757014b..b2e5f098e 100644 --- a/src/modules/graphics/vertex.cpp +++ b/src/modules/graphics/vertex.cpp @@ -26,6 +26,8 @@ namespace love namespace graphics { +static_assert(sizeof(VertexAttributeInfo) == 4, "Unexpected sizeof(VertexAttributeInfo)"); + static_assert(sizeof(Color32) == 4, "sizeof(Color32) incorrect!"); static_assert(sizeof(STf_RGBAub) == sizeof(float)*2 + sizeof(Color32), "sizeof(STf_RGBAub) incorrect!"); static_assert(sizeof(STPf_RGBAub) == sizeof(float)*3 + sizeof(Color32), "sizeof(STPf_RGBAub) incorrect!"); @@ -336,7 +338,7 @@ bool VertexAttributes::operator == (const VertexAttributes &other) const { const auto &a = attribs[i]; const auto &b = other.attribs[i]; - if (a.bufferIndex != b.bufferIndex || a.format != b.format || a.offsetFromVertex != b.offsetFromVertex) + if (a.bufferIndex != b.bufferIndex || a.packedFormat != b.packedFormat || a.offsetFromVertex != b.offsetFromVertex) return false; if (bufferLayouts[a.bufferIndex].stride != other.bufferLayouts[a.bufferIndex].stride) diff --git a/src/modules/graphics/vertex.h b/src/modules/graphics/vertex.h index 10ee45599..7669c407d 100644 --- a/src/modules/graphics/vertex.h +++ b/src/modules/graphics/vertex.h @@ -298,9 +298,12 @@ struct BufferBindings struct VertexAttributeInfo { - uint8 bufferIndex; - DataFormat format : 8; uint16 offsetFromVertex; + uint8 packedFormat; + uint8 bufferIndex; + + void setFormat(DataFormat format) { packedFormat = (uint8)format; } + DataFormat getFormat() const { return (DataFormat)packedFormat; } }; struct VertexBufferLayout @@ -335,7 +338,7 @@ struct VertexAttributes enableBits |= (1u << index); attribs[index].bufferIndex = bufferindex; - attribs[index].format = format; + attribs[index].setFormat(format); attribs[index].offsetFromVertex = offsetfromvertex; } diff --git a/src/modules/graphics/vulkan/Graphics.cpp b/src/modules/graphics/vulkan/Graphics.cpp index 7687d8bb6..f8b3509ab 100644 --- a/src/modules/graphics/vulkan/Graphics.cpp +++ b/src/modules/graphics/vulkan/Graphics.cpp @@ -2273,7 +2273,7 @@ void Graphics::createVulkanVertexFormat( attributeDescription.location = i; attributeDescription.binding = bufferBinding; attributeDescription.offset = attrib.offsetFromVertex; - attributeDescription.format = Vulkan::getVulkanVertexFormat(attrib.format); + attributeDescription.format = Vulkan::getVulkanVertexFormat(attrib.getFormat()); attributeDescriptions.push_back(attributeDescription); }