-
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
Accessor alignment requirements #802
Comments
Relaxing is OK with me as long as JavaScript typed array alignment requirements are met such that views can be created without having to copy subsets of the buffer. That was the original intent; I may have made it to restrictive. CC @lexaknyazev |
From offline discussion:
|
So I assume that the alignment requirements will be relaxed in this point for 1.1. This may make things simpler. And this may come in handy, because I think that obeying the alignment constraints of glTF 1.0 is surprisingly tricky. I'm currently working on this, and my gut feeling is that I overlooked something obvious or simply got lost somehow. But here's an example, to illustrate what I'm currently struggling with. Imagine the configuration shown in this image: (This configuration is not valid, as shown below) To summarize: The accessors:
The buffer views:
All this should be combined into a single So the buffer will start with the
But how? Adding 4 to the Of course, it can be solved. One could generously spread padding bytes here and there and everywhere, based on the smallest common multiple of all alignment requirements, to trivially make sure that all constraints are obeyed. But when I thought about how to compute an optimal structure, with as few padding bytes as possible, this started feeling like a somewhat non-trivial constraint satisfaction problem. (I don't want to suggest that it may be NP complete, but it wouldn't surprise me if it was). Am I overlooking something obvious here? |
Probably not. It is difficult. One reasonable strategy is to make sure that the This may cause some bytes to be wasted. But computing the optimal alignment (maybe even considering reorderings of the |
As @pjcozzi said, that wasn't intended restriction. Let's just integrate requirements from post above. |
Sure, that was my assumption. The part below the ---line--- was rather an approach to dissect the implications of the original spec. For example, the models
are not compliant to the original specification in this regard. But this may not be sooo important, because the validator did not check it, and the existing loaders will not unnecessarily insist on this part of the spec. They should not have a reason to do this, and thus, it is unlikely that they reject one of the above models as being invalid. |
Alignment reqs updated via lexaknyazev@2113534. |
The spec has been updated, so I guess this can be closed. |
The alignment constraints for accessors currently say:
where "the size of the accessor's attribute type" is defined to be the size of the full type, (e.g. for a 3D
float
vector, it's 3*4 bytes.According to the discussion at KhronosGroup/glTF-Validator#10 , it may not be necessary to require the alignment to be the size of the full type. It might be sufficient to have an alignment that matches the size of the component type (e.g. 4 for a 3D
float
vector).If and only if nobody can imagine a reason to keep the alignment requirement in its current form, it could be relaxed (always keeping in mind that it can afterwards never be changed back).
The text was updated successfully, but these errors were encountered: