Some more refactoring in GLVertexBuffer
Review Request #110366 - Created May 8, 2013 and submitted
This is the next part of my optimization branch. It does some more refactoring and adds a new setData() overload, which isn't used yet. There should be no functional changes. I'm not 100% sure about the new setAttribLayout() API. I suspect we may need a real GLAttribLayout class if we start using vertex array objects in the future. commit 682b73bf1169254c5cf015cee0ffe4ba0753a7a4 Author: Fredrik Höglund <firstname.lastname@example.org> Date: Thu Sep 27 17:26:19 2012 +0200 kwin: Add a new setData() method in GLVertexBuffer This overload makes it possible to upload data of an arbitrary size and type into the buffer object. The intent is for this method to be used to upload interleaved vertex data. This commit also adds setVertexCount() and setAttribLayout(). The rationale for decoupling attribute specification from data uploading is that the attribute formats and layout change less frequently than the vertex data. The vertex count is also specified using a separate function to enable the caller to upload data for multiple draw calls at the same time. commit 24201f76ddef80713d502476250de1f572d552e5 Author: Fredrik Höglund <email@example.com> Date: Thu Sep 27 17:21:33 2012 +0200 kwin: Change the way attrib formats are stored in GLVertexBuffer Store the formats as an array in GLVertexBufferPrivate. This simplifies the code for enabling the generic vertex arrays, and also makes it easier to add new arrays. commit 0b084f234516c1b54360cf8391d9253bfcd7f484 Author: Fredrik Höglund <firstname.lastname@example.org> Date: Fri Mar 15 13:25:39 2013 +0100 kwin: Add convenience classes for working with bitfields commit 86f48cfe2a220d28109d8f9f4426ac4ab8e15762 Author: Fredrik Höglund <email@example.com> Date: Wed Mar 20 20:06:18 2013 +0100 kwin: Add a Color uniform in GLShader And use it in GLVertexBufferPrivate::bindArrays(). Also store the color as a QVector4D in GLVertexBufferPrivate. commit bdfc62a865601b4723228a9f479460157a7ab2ce Author: Fredrik Höglund <firstname.lastname@example.org> Date: Wed Sep 26 22:34:12 2012 +0200 kwin: Do some more refactoring in GLVertexBuffer Consolidate the code for binding and unbinding the vertex arrays into two new methods called bindArrays() and unbindArrays() respectively. This patch also removes the three paint implementations, since the only difference between them is the code that sets up the arrays. The actual painting code is moved into GLVertexBuffer::render(), which uses the new methods to bind and unbind the arrays.
I have only read the code, and found no real issues.
, VertexAttributeCount Maybe we will need normals for lighting effects in the distant future :) Can this enum be renamed to VertexAttributeType or something? There are VertexAttribute, VertexAttrib and GLVertexAttrib which do different things.
Perhaps GLVertexAttrib should be used instead of this? That one would have a redundant index member, but there would be fewer structs with similar names. I think it would also make setAttribLayout() implementation a bit smaller.
&& index < VertexAttributeCount ?