Rename Attributes struct to VertexAttributes

This commit is contained in:
Alex Szpakowski
2020-01-13 20:44:39 -04:00
parent ee5304ba53
commit 1bc2b947fc
12 changed files with 27 additions and 27 deletions
+1 -1
View File
@@ -1133,7 +1133,7 @@ void Graphics::flushStreamDraws()
if (sbstate.vertexCount == 0 && sbstate.indexCount == 0)
return;
Attributes attributes;
VertexAttributes attributes;
BufferBindings buffers;
size_t usedsizes[3] = {0, 0, 0};
+5 -5
View File
@@ -212,7 +212,7 @@ public:
{
PrimitiveType primitiveType = PRIMITIVE_TRIANGLES;
const Attributes *attributes;
const VertexAttributes *attributes;
const BufferBindings *buffers;
int vertexStart = 0;
@@ -224,7 +224,7 @@ public:
// TODO: This should be moved out to a state transition API?
CullMode cullMode = CULL_NONE;
DrawCommand(const Attributes *attribs, const BufferBindings *buffers)
DrawCommand(const VertexAttributes *attribs, const BufferBindings *buffers)
: attributes(attribs)
, buffers(buffers)
{}
@@ -234,7 +234,7 @@ public:
{
PrimitiveType primitiveType = PRIMITIVE_TRIANGLES;
const Attributes *attributes;
const VertexAttributes *attributes;
const BufferBindings *buffers;
int indexCount = 0;
@@ -249,7 +249,7 @@ public:
// TODO: This should be moved out to a state transition API?
CullMode cullMode = CULL_NONE;
DrawIndexedCommand(const Attributes *attribs, const BufferBindings *buffers, Resource *indexbuffer)
DrawIndexedCommand(const VertexAttributes *attribs, const BufferBindings *buffers, Resource *indexbuffer)
: attributes(attribs)
, buffers(buffers)
, indexBuffer(indexbuffer)
@@ -833,7 +833,7 @@ public:
virtual void draw(const DrawCommand &cmd) = 0;
virtual void draw(const DrawIndexedCommand &cmd) = 0;
virtual void drawQuads(int start, int count, const Attributes &attributes, const BufferBindings &buffers, Texture *texture) = 0;
virtual void drawQuads(int start, int count, const VertexAttributes &attributes, const BufferBindings &buffers, Texture *texture) = 0;
void flushStreamDraws();
StreamVertexData requestStreamDraw(const StreamDrawCommand &command);
+3 -3
View File
@@ -328,8 +328,8 @@ void Mesh::attachAttribute(const std::string &name, Mesh *mesh, const std::strin
auto it = attachedAttributes.find(name);
if (it != attachedAttributes.end())
oldattrib = it->second;
else if (attachedAttributes.size() + 1 > Attributes::MAX)
throw love::Exception("A maximum of %d attributes can be attached at once.", Attributes::MAX);
else if (attachedAttributes.size() + 1 > VertexAttributes::MAX)
throw love::Exception("A maximum of %d attributes can be attached at once.", VertexAttributes::MAX);
newattrib.mesh = mesh;
newattrib.enabled = oldattrib.mesh ? oldattrib.enabled : true;
@@ -580,7 +580,7 @@ void Mesh::drawInstanced(Graphics *gfx, const Matrix4 &m, int instancecount)
if (Shader::current && texture.get())
Shader::current->checkMainTexture(texture);
Attributes attributes;
VertexAttributes attributes;
BufferBindings buffers;
int activebuffers = 0;
+1 -1
View File
@@ -744,7 +744,7 @@ private:
bool relativeRotation;
const Attributes vertexAttributes;
const VertexAttributes vertexAttributes;
Buffer *buffer;
static StringMap<AreaSpreadDistribution, DISTRIBUTION_MAX_ENUM>::Entry distributionsEntries[];
+1 -1
View File
@@ -315,7 +315,7 @@ void SpriteBatch::draw(Graphics *gfx, const Matrix4 &m)
// Make sure the buffer isn't mapped when we draw (sends data to GPU if needed.)
array_buf->unmap();
Attributes attributes;
VertexAttributes attributes;
BufferBindings buffers;
{
+1 -1
View File
@@ -85,7 +85,7 @@ private:
StrongRef<Font> font;
Attributes vertexAttributes;
VertexAttributes vertexAttributes;
BufferBindings vertexBuffers;
Buffer *vertex_buffer;
+3 -3
View File
@@ -385,13 +385,13 @@ void Graphics::draw(const DrawIndexedCommand &cmd)
++drawCalls;
}
static inline void advanceVertexOffsets(const Attributes &attributes, BufferBindings &buffers, int vertexcount)
static inline void advanceVertexOffsets(const VertexAttributes &attributes, BufferBindings &buffers, int vertexcount)
{
// TODO: Figure out a better way to avoid touching the same buffer multiple
// times, if multiple attributes share the buffer.
uint32 touchedbuffers = 0;
for (unsigned int i = 0; i < Attributes::MAX; i++)
for (unsigned int i = 0; i < VertexAttributes::MAX; i++)
{
if (!attributes.isEnabled(i))
continue;
@@ -408,7 +408,7 @@ static inline void advanceVertexOffsets(const Attributes &attributes, BufferBind
}
}
void Graphics::drawQuads(int start, int count, const Attributes &attributes, const BufferBindings &buffers, love::graphics::Texture *texture)
void Graphics::drawQuads(int start, int count, const VertexAttributes &attributes, const BufferBindings &buffers, love::graphics::Texture *texture)
{
const int MAX_VERTICES_PER_DRAW = LOVE_UINT16_MAX;
const int MAX_QUADS_PER_DRAW = MAX_VERTICES_PER_DRAW / 4;
+1 -1
View File
@@ -74,7 +74,7 @@ public:
void draw(const DrawCommand &cmd) override;
void draw(const DrawIndexedCommand &cmd) override;
void drawQuads(int start, int count, const Attributes &attributes, const BufferBindings &buffers, Texture *texture) override;
void drawQuads(int start, int count, const VertexAttributes &attributes, const BufferBindings &buffers, Texture *texture) override;
void clear(OptionalColorf color, OptionalInt stencil, OptionalDouble depth) override;
void clear(const std::vector<OptionalColorf> &colors, OptionalInt stencil, OptionalDouble depth) override;
+2 -2
View File
@@ -186,7 +186,7 @@ void OpenGL::setupContext()
state.enabledAttribArrays = (uint32) ((1ull << uint32(maxvertexattribs)) - 1);
state.instancedAttribArrays = 0;
setVertexAttributes(Attributes(), BufferBindings());
setVertexAttributes(VertexAttributes(), BufferBindings());
// Get the current viewport.
glGetIntegerv(GL_VIEWPORT, (GLint *) &state.viewport.x);
@@ -713,7 +713,7 @@ void OpenGL::deleteBuffer(GLuint buffer)
}
}
void OpenGL::setVertexAttributes(const Attributes &attributes, const BufferBindings &buffers)
void OpenGL::setVertexAttributes(const VertexAttributes &attributes, const BufferBindings &buffers)
{
uint32 enablediff = attributes.enableBits ^ state.enabledAttribArrays;
uint32 instanceattribbits = 0;
+1 -1
View File
@@ -238,7 +238,7 @@ public:
/**
* Set all vertex attribute state.
**/
void setVertexAttributes(const Attributes &attributes, const BufferBindings &buffers);
void setVertexAttributes(const VertexAttributes &attributes, const BufferBindings &buffers);
/**
* Wrapper for glCullFace which eliminates redundant state setting.
+1 -1
View File
@@ -236,7 +236,7 @@ void fillIndices(TriangleIndexMode mode, uint32 vertexStart, uint32 vertexCount,
fillIndicesT(mode, vertexStart, vertexCount, indices);
}
void Attributes::setCommonFormat(CommonFormat format, uint8 bufferindex)
void VertexAttributes::setCommonFormat(CommonFormat format, uint8 bufferindex)
{
setBufferLayout(bufferindex, (uint16) getFormatStride(format));
+7 -7
View File
@@ -230,7 +230,7 @@ struct BufferBindings
void clear() { useBits = 0; }
};
struct AttributeInfo
struct VertexAttributeInfo
{
uint8 bufferIndex;
DataType type : 4;
@@ -238,23 +238,23 @@ struct AttributeInfo
uint16 offsetFromVertex;
};
struct BufferLayout
struct VertexBufferLayout
{
uint16 stride;
};
struct Attributes
struct VertexAttributes
{
static const uint32 MAX = 32;
uint32 enableBits = 0; // indexed by attribute
uint32 instanceBits = 0; // indexed by buffer
AttributeInfo attribs[MAX];
BufferLayout bufferLayouts[BufferBindings::MAX];
VertexAttributeInfo attribs[MAX];
VertexBufferLayout bufferLayouts[BufferBindings::MAX];
Attributes() {}
Attributes(CommonFormat format, uint8 bufferindex)
VertexAttributes() {}
VertexAttributes(CommonFormat format, uint8 bufferindex)
{
setCommonFormat(format, bufferindex);
}