KitFieldhouse / pika

A library for working with webgl with an eye towards data and plotting applications
0 stars 0 forks source link

To think about: should inputs within a vertex buffer be allowed to be appended individually from eachother? #7

Closed KitFieldhouse closed 2 hours ago

KitFieldhouse commented 2 hours ago

Right now, inside of a vertex buffer, all of the inputs inside the vertex buffer must have the exact same amount of data.

Of course, if the vertex buffer is used as the sole source of vertex data for a shader program and all of the inputs are used by this shader program, this has to be the case. However, thinking more generally, where we are thinking of inputs being arbitrarily mixed and matched from different Vertex Buffers as inputs to our programs, this restriction can seem a little arbitrary.

For instance, lets say we have two Vertex Buffers, one with inputs y and x and another with inputs z and w. It may be the case that we only have to shaders we will use in this program, one with inputs (y,z) and another with inputs (x,w). In this case, y and x should be able to be sized independently of each other.

Realistically, this is a bad way of storing vertex data, as data that will run together should usually be stored together, hopefully in the same exact Vertex Buffer, but it could be the case that there is some use for this that I can't think of off the top of my head.

But lets say we are sizing inputs independently and our vertex buffer has layout described by repeat('x','y'). Then, the question becomes what should we do when we want to size 'x' independent of 'y'. We could simply just leave holes in the spaces 'y' would have left, but in some ways this feels like breaking the layout we described to the API. By saying repeat('x', 'y'), we are telling the program that x and y will always occur together in alternating order, allowing one to be sized independent of the other breaks this relationship in a way that ruins the semantics of our layout descriptor.

So I think the way forward is to say that individual layout atoms can be sized independently of each other. This to me provides good balance between abstraction of input from its data store while still keeping the semantics of our layout descriptor in place.

KitFieldhouse commented 2 hours ago

Keeping this for a historical record in case I forget why I decided to go this route