Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

kvark
Copy link
Contributor

@kvark kvark commented Jun 20, 2019

This is required to have the bind groups backed by Metal indirect argument buffers. We want MTLArgumentEncoder to be associated with GPUBindGroupLayout, and its construction requires textureType to be known.
cc @litherum @JusSn


Preview | Diff

Copy link
Contributor

@Kangz Kangz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, though that's a bit unfortunate because it makes the BindGroupLayout even more complicated. On the plus side we can validate compatibility the declaration of the texture in the ShaderModule better which might helpl avoid some undefined behavior.

@kvark
Copy link
Contributor Author

kvark commented Jun 21, 2019

@Kangz I'm not worried about complexity here. The users need to know what kind of resources they are going to bind. What I'm not sure about is if any ISV wants to actually use the same bind group layout with different texture types. Could be something to add to our list of questions for ISVs.

@RafaelCintron would you want to have a look as well?

@RafaelCintron
Copy link
Contributor

Q: Why does needing to know the texture type for Metal mean we need to require the dimensions of the texture in WebGPU?

@kvark
Copy link
Contributor Author

kvark commented Jun 24, 2019

@RafaelCintron Good question! Short answer is: because not knowing the dimensions at this point (bind group layout creation) in WebGPU would make Metal implementation use of argument buffers infeasible, if possible at all...

I think it would be a good thing to design our API in such a way that effective translation is provided to native. In general, binding resources in Metal shows up high on the CPU profiles I've seen, and argument buffers largely solve this.

@grorg
Copy link
Contributor

grorg commented Jun 24, 2019

Discussed at 25 Jun 2019 teleconference

@kvark
Copy link
Contributor Author

kvark commented Jun 24, 2019

We also need a flag for multi-sampling

spec/index.bs Outdated
required GPUBindingType type;
// For texture bindings only, we need to know the dimensions at the
// bind group creation time and validate the created bind groups accordingly.
GPUTextureViewDimension? textureDimension;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the ? needed? I think it can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not needed for buffer type bindings

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but since it's not required, it should be optional by default. I don't think the extra ? is needed because that just makes it optional AND nullable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have problems with this elsewhere in the file too, actually.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, that was not quite right. The WebIDL spec explicitly allows nullable enumerations inside dictionaries. I'm not sure exactly what the difference is between:

GPUTextureViewDimension? textureDimension = null;

and

GPUTextureViewDimension textureDimension;

except that the first will convert undefined to null, and the second will not. The second will also not allow null, I think.

That said, I think one of those two should be used, rather than what we have now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't GPUTextureViewDimension? default to null?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand (as in very little) in WebIDL GPUTetureViewDimension? textureDimension would default to being undefined. Basically this is a Rust Option<Option<GPUTextureViewDimension>> and not Option<GPUTextureDimension>.

Either of Kai's suggestions would work to be an Option<GPUTextureViewDimension> so I hae a slight preference for the shorter GPUTextureViewDimension textureDimension.

Alternatively, we could maybe make it default to 2D?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarification! Removed ? now.
I don't want to default to 2D for now, since our bind group descriptor doesn't default either (although, texture descriptor does)

@kvark
Copy link
Contributor Author

kvark commented Jun 24, 2019

Updated now, please have another look!

Copy link
Contributor

@Kangz Kangz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with the details of textureDimension's type figured.

@kdashg kdashg merged commit 3c15af0 into master Jul 1, 2019
@kainino0x kainino0x deleted the kvark-bind-type branch July 1, 2019 19:45
Kangz pushed a commit to Kangz/gpuweb that referenced this pull request Jul 9, 2019
* Provide texture dimension in GPUBindGroupLayoutBinding

* Add multisample flag to GPUBindGroupLayoutBinding

* Remove question mark from texture dimension
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants