-
Notifications
You must be signed in to change notification settings - Fork 345
Vertex inputs: push model with int-keyed object
#186
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
Conversation
| sequence<GPUVertexInputDescriptor> inputs; | ||
| // This object has keys of 0..15 and values of type GPUVertexBufferDescriptor. | ||
| // (It's not possible in WebIDL to describe a dictionary with keys "0" through "15".) | ||
| object vertexBuffers; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@heycam Is this really not possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is not possible. (There is an escaping prefix _ for identifiers but the characters following must still look like a normal identifier, and this is only used for escaping existing keywords.)
I think it's odd for a Web API to have array-index-like members like this. What's the downside of using sequence<GPUVertexInputDescriptor> here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at the alternatives doc.
If by sequence<GPUVertexInputDescriptor> you mean WITH the index parameter, that is option 2. The additional indirection was opposed by some in favor of the relatively more straightforward-looking keys-as-indices.
If you mean WITHOUT the index parameter, that's option 3 and the sequence must be sparse - that is, sequence<GPUVertexBufferDescriptor?> (since afaik WebIDL doesn't really have sparse arrays).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All that said, I'm currently not that strongly in favor of any of these proposals over any of the others. It is up for discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for that pointer. Do you think authors will tend to pass an Array object (with holes or explicit undefined values) or a plain object with index-like keys, if the IDL used object? One of the points made about option 3 is that it obscures the index of each descriptor but even with the object and in-prose handling of reading things off the object, the author could still pass an Array object and have it work. Unless the prose explicitly checked for an Array and threw an exception I suppose.
If requiring the index to be specified is not a hard requirement, then I think using sequence<GPUVertexBufferDescriptor?> is the most straightforward thing.
Another option would be to use a dictionary with names that aren't array-index-like, e.g.
dictionary GPUVertexInputBuffers {
optional GPUVertexBufferDescriptor v0;
optional GPUVertexBufferDescriptor v1;
...
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the input. I envisioned primarily using object syntax and passing raw objects to the API. We could allow or disallow arrays.
Your last suggestion looks like Option 5 (the last one in the PR I linked). It is definitely possible, but I think applications will sometimes want to e.g. have a for loop over slots 2-5, which would be harder and slower with the valid identifier names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you mean WITHOUT the index parameter, that's option 3 and the sequence must be sparse - that is, sequence<GPUVertexBufferDescriptor?> (since afaik WebIDL doesn't really have sparse arrays).
There is no need for it to be sparse, no need for ?. If no vertex attributes are using a buffer at some index, the corresponding GPUVertexBufferDescriptor would just have an empty list of attributes.
object vertexBuffers; doesn't look appealing at all to me
|
See also: #151 |
kvark
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all good, minus the object vertexBuffers bit :)
|
Discussed in the 4 March 2019 meeting |
3e8b17f to
e6507ca
Compare
|
Updated: VertexBufferState -> VertexInput, and rebased. |
kvark
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Status: still don't understand why we need to go with the object hack here.
|
Sorry, didn't reevaluate the alternatives yet. |
|
Assuming GPUVertexBufferDescriptor has defaults: dictionary GPUVertexBufferDescriptor {
u64 stride = 0;
GPUInputStepMode stepMode = "vertex";
sequence<GPUVertexAttributeDescriptor> attributes = [];
};things still look kind of ugly in cases when there are holes: const vertexBuffers = [vb0, {}, {}, {}, {}, {}, {}, vb7];WDYT? |
|
I can't stress this enough - this isn't the case to optimize usability for. Users who want many different vertex buffers mixed and matched in their pipelines can find ways for this to be sound, i.e. var vertexBuffers = Array(MAX_VERTEX_BUFFERS).fill({});
vertexBuffers[0] = vb0;
vertexBuffers[7] = vb7; |
|
Another issue is that this does not work for other sequences in the API. So we need to come up with something for those, too.
(not 100% sure everything on this list has the problem) |
|
@kainino0x vertex buffers are different from the all the states you mentioned in that they are bound in ranges (e.g. we can bind all the vertex buffers from slot 1 to slot 4 in one command). Stuff like
dictionary GPUPipelineLayoutDescriptor {
sequence<GPUBindGroupLayout?> bindGroupLayouts;
};
|
|
Ok, I think I agree with you about bindGroupLayouts and colorStates/colorAttachments. The GPUBindGroupDescriptor and GPUBindGroupLayoutDescriptor, though, currently use the dictionary GPUBindGroupBinding {
required GPUBindingResource resource;
};
dictionary GPUBindGroupDescriptor {
GPUBindGroupLayout layout;
sequence<GPUBindGroupBinding?> bindings;
};dictionary GPUBindGroupBinding {
GPUBindingResource resource = null;
};
dictionary GPUBindGroupDescriptor {
GPUBindGroupLayout layout;
sequence<GPUBindGroupBinding> bindings;
};Or even: dictionary GPUBindGroupBinding {
required GPUBindingResource resource;
};
dictionary GPUBindGroupDescriptor {
GPUBindGroupLayout layout;
object bindings;
};(😛) |
|
@kainino0x we need to talk about the order of bindings in a bind group. As it stands right now, they are defined individually (in There is a case to be made about sequential binding IDs for the following reason:
|
|
Discussed at 25 March teleconference |
|
TODO(me): Agreed to update this to Option 3 (here). |
objectobject
|
@kvark since I've closed this, would you mind posting your last comment as an issue or PR? |
|
@kainino0x moved to #251 |
…PublicParamsPaths (gpuweb#186) * only checkForDuplicateCases during crawl(); slightly speed up comparePublicParamsPaths * use Set * un-delete error message * expand tests, go back to n^2 (instead of Set) to pass tests * more testing, rename method * nit
(with attributes inside the vertex buffer descriptor)
For alternatives, examples, and a little analysis, see here (this one is OPTION 4).