You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
What binding numbers are used by an external texture binding? #1721
The question in my mind is on the API side: if an external texture uses up multiple bindings, then how do I know what binding numbers are occupied? I presume they are in the same bindgroup.
I'm not precisely sure how to address this, but I think that in implementations we can hide the fact that multiple binding indices are used. IIRC in Dawn at least, we re-pack the bindings into a small range near 0 anyway, so this problem would disappear in that. However for the sake of alternate implementations we might want to reserve half of the binding index space for internal bindings, or something?
I remember we have a "sounds good" solution here, is it still true?
(From Corentin's comment)
The proposal details that a GPUVideoTexture bindings counts for 3 sampled texture bindings and one uniform buffer binding. The shifting of resources bindings around will be handled by the browser so you can use N+1 N+2 and N+3 in your shader. It's pretty easy for browsers to shift bindings numbers around when creating the GPUBindGroupLayout.
shader author uses external texture at binding N, and other resources at N+1, N+2 and so on.
browser knows that an external texture takes up K binding slots, and internally builds a remapping of binding slots from those in the shader source, to actual slots in the backend. It applies this mapping when translating shader source for the underlying API.
The key for me is that the mapping can be created very early: the shader source is handled at the same time that you know the target underlying device and hence its external-resource-binding needs. The shader for the underlying API is created once with the right info, and there's no need to patch it later.
Exactly. At the latest at pipeline creation (or with the layout info at shader module creation if you implementation is able to do that) you can do the remapping and never change the shader again.
Activity
kainino0x commentedon May 11, 2021
shaoboyan commentedon May 11, 2021
I remember we have a "sounds good" solution here, is it still true?
kainino0x commentedon May 11, 2021
ah, I forgot that was written down. I think that addresses it, yes. We should briefly discuss to get confirmation from other implementations
dneto0 commentedon May 12, 2021
Ok, that makes sense to me.
Spelling out division of responsibilities:
The key for me is that the mapping can be created very early: the shader source is handled at the same time that you know the target underlying device and hence its external-resource-binding needs. The shader for the underlying API is created once with the right info, and there's no need to patch it later.
Kangz commentedon May 17, 2021
Exactly. At the latest at pipeline creation (or with the layout info at shader module creation if you implementation is able to do that) you can do the remapping and never change the shader again.
kvark commentedon May 17, 2021
Filed #1733 as promised on the call
kvark commentedon May 31, 2021
Our current position is - ready to accept this if #1783 is accepted, as a suitable path forward for us.
kainino0x commentedon Jun 7, 2021
resolution: #1783 accepted, external textures take only one binding.
The latter is already consistent with the spec as written, so closing.
wgsl: Replace module-scope 'let' with 'const' (gpuweb#1721)