Refactor "SetVertexBufferArray" to "SetVertexBuffers" #170
LukasBanana
started this conversation in
Ideas
Replies: 1 comment
-
The |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The idea is to get rid of all
...Array
interfaces as well asSet...Array
functions in theCommandBuffer
interface. Instead, the newResourceHeap
interface should be used, which complies with the new rendering APIs. TheSetVertexBufferArray
function should be refactored to the following:For all renderers (except OpenGL) this can be trivially implemented by using an uninitialized local C-style array that is passed to the native renderer API like this:
This works analogous to the
SetViewports
andSetScissors
functions.For OpenGL, however, this requires a little more effort. The idea is to convert the
GLVertexArrayObject
member variable inGLVertexBuffer
into shared pointer. Then all vertex buffers used in a call toSetVertexBuffers
refer to the same VAO. When these buffers are used in theSetVertexBuffers
function for the first time, this VAO is created 'on the fly'. When they are used together once more, this VAO can be reused. This allows to dynamically change the vertex buffers without letting the client programmer manage aBufferArray
object.Caveat:
To make a buffer usable for multiple sets of vertex buffers, each
GLVertexBuffer
must hold a container of shared pointers. Otherwise, some VAOs could be created and deleted every frame :-(So either each
GLVertexBuffer
needs this list, which must be iterated for each buffer used in theSetVertexBuffers
function, or some sort of hash map must be involved to quickly find the correct VAO for a set of buffers.Alternative 1:
Get rid of all
...Array
interfaces except ofBufferArray
(but only for vertex buffer arrays).Alternative 2:
Both
SetVertexBufferArray
andSetVertexBuffers
are supported. The former one is supported for optimization purposes and the latter one is supported for flexibility purposes.Update (12/07/2018):
Maybe the GL_ARB_vertex_attrib_binding extension can help here.
Beta Was this translation helpful? Give feedback.
All reactions