Skip to content

What binding numbers are used by an external texture binding? #1721

Closed

Description

@kainino0x

#1666 (review)

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.

Activity

  1. kainino0x commented on May 11, 2021

    @kainino0x
    ContributorAuthor

    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?

  2. shaoboyan commented on May 11, 2021

    @shaoboyan
    Contributor

    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.

  3. kainino0x commented on May 11, 2021

    @kainino0x
    ContributorAuthor

    ah, I forgot that was written down. I think that addresses it, yes. We should briefly discuss to get confirmation from other implementations

  4. dneto0 commented on May 12, 2021

    @dneto0
    Contributor

    Ok, that makes sense to me.

    Spelling out division of responsibilities:

    • 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.

  5. Kangz commented on May 17, 2021

    @Kangz
    Contributor

    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.

  6. added this to the MVP milestone on May 17, 2021
  7. kvark commented on May 17, 2021

    @kvark
    Contributor

    Filed #1733 as promised on the call

  8. kvark commented on May 31, 2021

    @kvark
    Contributor

    Our current position is - ready to accept this if #1783 is accepted, as a suitable path forward for us.

  9. kainino0x commented on Jun 7, 2021

    @kainino0x
    ContributorAuthor

    resolution: #1783 accepted, external textures take only one binding.

    The latter is already consistent with the spec as written, so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions