mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Improve Windows vulkan draw performance by reducing the size of a struct.
This commit is contained in:
@@ -948,7 +948,7 @@ id<MTLRenderPipelineState> Shader::getCachedRenderPipeline(const RenderPipelineK
|
|||||||
const auto &attrib = attributes.attribs[i];
|
const auto &attrib = attributes.attribs[i];
|
||||||
int metalBufferIndex = firstVertexBufferBinding + attrib.bufferIndex;
|
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].offset = attrib.offsetFromVertex;
|
||||||
vertdesc.attributes[i].bufferIndex = metalBufferIndex;
|
vertdesc.attributes[i].bufferIndex = metalBufferIndex;
|
||||||
|
|
||||||
|
|||||||
@@ -870,7 +870,7 @@ void OpenGL::setVertexAttributes(const VertexAttributes &attributes, const Buffe
|
|||||||
int components = 0;
|
int components = 0;
|
||||||
GLboolean normalized = GL_FALSE;
|
GLboolean normalized = GL_FALSE;
|
||||||
bool intformat = 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);
|
const void *offsetpointer = reinterpret_cast<void*>(bufferinfo.offset + attrib.offsetFromVertex);
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ namespace love
|
|||||||
namespace graphics
|
namespace graphics
|
||||||
{
|
{
|
||||||
|
|
||||||
|
static_assert(sizeof(VertexAttributeInfo) == 4, "Unexpected sizeof(VertexAttributeInfo)");
|
||||||
|
|
||||||
static_assert(sizeof(Color32) == 4, "sizeof(Color32) incorrect!");
|
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(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!");
|
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 &a = attribs[i];
|
||||||
const auto &b = other.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;
|
return false;
|
||||||
|
|
||||||
if (bufferLayouts[a.bufferIndex].stride != other.bufferLayouts[a.bufferIndex].stride)
|
if (bufferLayouts[a.bufferIndex].stride != other.bufferLayouts[a.bufferIndex].stride)
|
||||||
|
|||||||
@@ -298,9 +298,12 @@ struct BufferBindings
|
|||||||
|
|
||||||
struct VertexAttributeInfo
|
struct VertexAttributeInfo
|
||||||
{
|
{
|
||||||
uint8 bufferIndex;
|
|
||||||
DataFormat format : 8;
|
|
||||||
uint16 offsetFromVertex;
|
uint16 offsetFromVertex;
|
||||||
|
uint8 packedFormat;
|
||||||
|
uint8 bufferIndex;
|
||||||
|
|
||||||
|
void setFormat(DataFormat format) { packedFormat = (uint8)format; }
|
||||||
|
DataFormat getFormat() const { return (DataFormat)packedFormat; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VertexBufferLayout
|
struct VertexBufferLayout
|
||||||
@@ -335,7 +338,7 @@ struct VertexAttributes
|
|||||||
enableBits |= (1u << index);
|
enableBits |= (1u << index);
|
||||||
|
|
||||||
attribs[index].bufferIndex = bufferindex;
|
attribs[index].bufferIndex = bufferindex;
|
||||||
attribs[index].format = format;
|
attribs[index].setFormat(format);
|
||||||
attribs[index].offsetFromVertex = offsetfromvertex;
|
attribs[index].offsetFromVertex = offsetfromvertex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2273,7 +2273,7 @@ void Graphics::createVulkanVertexFormat(
|
|||||||
attributeDescription.location = i;
|
attributeDescription.location = i;
|
||||||
attributeDescription.binding = bufferBinding;
|
attributeDescription.binding = bufferBinding;
|
||||||
attributeDescription.offset = attrib.offsetFromVertex;
|
attributeDescription.offset = attrib.offsetFromVertex;
|
||||||
attributeDescription.format = Vulkan::getVulkanVertexFormat(attrib.format);
|
attributeDescription.format = Vulkan::getVulkanVertexFormat(attrib.getFormat());
|
||||||
|
|
||||||
attributeDescriptions.push_back(attributeDescription);
|
attributeDescriptions.push_back(attributeDescription);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user