Improve Windows vulkan draw performance by reducing the size of a struct.

This commit is contained in:
Sasha Szpakowski
2024-03-10 14:33:29 -03:00
parent b12ecf49d8
commit ec9fb6eb28
5 changed files with 12 additions and 7 deletions
+1 -1
View File
@@ -948,7 +948,7 @@ id<MTLRenderPipelineState> 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;
+1 -1
View File
@@ -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<void*>(bufferinfo.offset + attrib.offsetFromVertex);
+3 -1
View File
@@ -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)
+6 -3
View File
@@ -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;
}
+1 -1
View File
@@ -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);
}