Restructure some internal vertex buffer binding code to be closer to how graphics APIs actually behave.

This commit is contained in:
Alex Szpakowski
2019-08-25 16:50:15 -03:00
parent 932068e777
commit 55d4dc0f9e
12 changed files with 117 additions and 92 deletions
+4 -3
View File
@@ -332,7 +332,7 @@ void SpriteBatch::draw(Graphics *gfx, const Matrix4 &m)
array_buf->unmap();
Attributes attributes;
Buffers buffers;
BufferBindings buffers;
{
buffers.set(0, array_buf, 0);
@@ -374,9 +374,10 @@ void SpriteBatch::draw(Graphics *gfx, const Matrix4 &m)
uint16 offset = (uint16) mesh->getAttributeOffset(it.second.index);
uint16 stride = (uint16) mesh->getVertexStride();
attributes.set(attributeindex, format.type, format.components, offset, stride, activebuffers);
attributes.set(attributeindex, format.type, (uint8) format.components, offset, activebuffers);
attributes.setBufferLayout(activebuffers, stride);
// TODO: Ideally we want to reuse buffers with the same stride+step.
// TODO: We should reuse buffer bindings with the same buffer+stride+step.
buffers.set(activebuffers, mesh->vertexBuffer, 0);
activebuffers++;
}