-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move byteStride from accessor to bufferView? #827
Comments
Related: #819 |
@sbtron do you have any input here? @kainino0x we can think through moving The other options that may be lower impact is that other profiles (right now glTF just has the WebGL project) provide a guarantee that, for example, all accessors pointed to by a primitive have the same |
At the first glance, such change is justifiable by API design (if I understood them correctly, see images below: one buffer for positions and other for normals and UVs). One of possible reasons to store different attributes in different buffers is to disable some of them on some passes (e.g., disable everything but positions on shadow pass). OpenGL (ES):Vulkan:Metal:However, glTF has other means for bufferViews and accessors.
Anyway, I can't see any cons to this change, so let's do it. |
@lexaknyazev this is kind of just pushing around the restrictions, right? Without changing anything, a profile could guarantee that, for example, all accessors pointed to by a primitive have the same byteStride. If we change this, we would have the restrictions you bulleted above, plus the extra implementation requirement to load animation and morphs (stride isn't just passed to an API for these like it is for vertices), unless we require those strides to also be zero (which again is all about just where we want the restriction to be). |
For attribute-related accessors, this change reduces redundancy (and possible errors). Having such restriction in the core reduces 2.0 implementations fragmentation (btw, we don't have any profile yet - maybe we don't need them).
Currently, I'm sure that their stride must be 0 anyway (because reading interleaved data on client isn't easy). So there's zero implementation cost here. |
If all bufferView strides except vertex attributes would have to be zero, I agree this becomes attractive. It would be OK with me, if everyone agrees. It could lead to more |
How? Case when several accessors use the same bufferView with different strides (e.g., sequence of separate meshes with different attribute layouts) must be discouraged from implementation's point of view. |
Current scenario of two accessors with different strides referencing the same bufferView. It's not a big deal, just pointing it out. |
…ot of the accessor.Thank you Alexey for pointing it out
…ot of the accessor.Thank you Alexey for pointing it out
Updated in #826 |
Just to get the implications of this right (mainly @lexaknyazev ) : Assuming one has
Is it right that it is not possible to create And if they end up in the same
in order to have the same |
Right. But that's also because of
Minimum stride of float VEC3 is 4 * 3 = 12 bytes. Minimum stride of float VEC2 is 4 * 2 = 8 bytes.
With stride of 4 * (3 + 2) = 20 bytes. |
Thanks for the clarification. The main issue here (for me, currently) is that the data layout of the texture coordinate data will change. Adjusting the |
Someone has to do it anyway: some APIs (e.g., Vulkan) don't allow loading GPU buffer with different strides. It's better to put the burden on export side. To avoid "post-processing", one could use a new bufferView for each accessor type (e.g., the first bufferView for all VEC3 attributes, the second for VEC2). |
Although I'm not an expert here, the structure of having multiple accessors that refer to the same buffer view probably has a reason. Most likely, it's related to some performance issues that could be caused by having to bind one VBO (buffer view) for each attribute (regardless of whether these performance concerns are actually justified). However, related to that, and still related to this issue: Right now, the So it is not possible to have two (I didn't find this case being mentioned in the spec, but maybe I overlooked it...) |
That field is defined only for vertex attributes (in GL sense). Indices accessors of different types are free to use the same bufferView. Could you open a PR with more consistent wording for all relevant places in the spec? |
According to #817 glTF 2.0 will target other graphics APIs. Apologies if this issue has been discussed, I couldn't find it.
In the newer graphics APIs (Metal, Vulkan, D3D12, D3D11, GL 4.3+, GL ES 3.1+), I think we need stride to be constant across multiple
accessor
s pointing at the samebufferView
. This is because stride is a per-input (per-buffer-binding) property while offsets are a per-attribute property.The current structure of glTF is difficult (and slow) to shoehorn into these new designs. Is there anything preventing byteStride from being moved to bufferView?
Here's how I think the glTF concepts map to API concepts:
Vulkan: stride; accessor.offset
Metal: stride; accessor.offset
D3D12: stride; accessor.offset
D3D11: offset+stride; accessor.offset
OpenGL ES 3.1+, OpenGL 4.3+: offset+stride; accessor.offset
The text was updated successfully, but these errors were encountered: