-
Notifications
You must be signed in to change notification settings - Fork 353
Immutable sampler support #356
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
spec/index.bs
Outdated
| // For "sampler" binding type, if the actual sampler object is provided here, | ||
| // it becomes a part of the layout: an "immutable" sampler object, in a sense that | ||
| // no bind group binding call can affect it. | ||
| GPUSampler immutableSampler; |
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.
Would it make sense for this to be a GPUSamplerDescriptor instead? It doesn't match what Vulkan does but is closer to what D3D12 and Metal do where the sampler descriptor is embedded in the shading language source.
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.
You mean, having a flag there saying that a sampler is immutable? That's not going to be known at pipeline creation time, so I don't see how this would help. Please clarify.
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.
I think Kangz means providing the creation descriptor instead of the platform object to the BindGroupLayout. I'm not sure I like that as much, but I see the appeal of it.
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.
Oh I see. Thanks for clarification! I think that would make sense to do.
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.
this change is now in
|
I don’t think “the mapping is trivial” is sufficient to justify an addition to a Web API. We already have a way of supplying samplers to shaders; I’d like to see some performance numbers that justify this addition before we approve it. Just like indirect draw arguments, sampler comparison functions are present on all hardware we’re targeting for WebGPU. We should just require support for them. |
|
@litherum "the mapping is trivial" is not by itself sufficient to justify the addition. I agree. We are weighting many factors here. One of them is how difficult it is to map to the native APIs. We know the answer to this one. Another factor, as you mentioned, is what does it give us in terms of performance. I haven't done the benchmarks, but I could find this reference from AMD in 2016, see slide 14:
I imagine the same reasoning can be applied to Metal, since it supports constexpr samplers in MSL?
Is there a place where you have those hardware requirements specified? IIRC, indirect arguments on iOS require 9.0, which covers a much wider range of devices than "MTLFeatureSet_iOS_GPUFamily3_v1". For example, iPhone4S can run iOS 9.0, but |
I'm trying to dig up some info on this from the d3d perspective. |
c585541 to
327f77a
Compare
|
Rebased over #365. |
|
This was discussed at the 15 July 2019 teleconference. |
Here's what I heard back: "They are simply a massive convenience. You can define your samplers directly in your shader and not have any external code have to worry about anything." |
|
Thanks @damyanp ! |
|
Those things (immutable samplers) are a tad faster on Android IIRC Also easier to implement on an OpenGL backend, OpenGL 4.5 and below has no mutable samplers that you can combine in a shader, the combining happens on the API side. Full mutable (a shader |
An immutable sampler is one that is a part of the pipeline layout definition, not affected by any bind group binding. The benefits of specifying a sampler as immutable are:
GPUPipelineLayout. They are represented by the static sampler concept.If the
immutableSamplerfield ofGPUBindGroupLayoutBindingis not nil, and the binding type is "sampler", then this binding is not expected to be provided inGPUBindGroupDescriptorcorresponding to the creation of a bind group with this layout.Preview | Diff