bindless.md: Replace pinning with automatic visibility by Kangz · Pull Request #6308 · gpuweb/gpuweb · GitHub
Skip to content

bindless.md: Replace pinning with automatic visibility#6308

Open
Kangz wants to merge 1 commit into
gpuweb:mainfrom
Kangz:replace-pinning
Open

bindless.md: Replace pinning with automatic visibility#6308
Kangz wants to merge 1 commit into
gpuweb:mainfrom
Kangz:replace-pinning

Conversation

@Kangz

@Kangz Kangz commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Fixes #5378

  • Removes texture.pin/unpin and all associated logic.
  • Adds pinning in the "Alternatives considered" section.
  • Move setResourceTable to GPUComputePassEncoder/GPURenderPassDescriptor so there are at most one resource table per usage scope.
  • Detail isShaderVisible, the validation performed by the shader when accessing a resource table slot, along with implementation notes.
  • Add setResourceUsage and a detailed explanation of the use for it.

Fixes gpuweb#5378

 - Removes texture.pin/unpin and all associated logic.
 - Adds pinning in the "Alternatives considered" section.
 - Move setResourceTable to
   GPUComputePassEncoder/GPURenderPassDescriptor so there are at most
   one resource table per usage scope.
 - Detail isShaderVisible, the validation performed by the shader when
   accessing a resource table slot, along with implementation notes.
 - Add setResourceUsage and a detailed explanation of the use for it.
@github-actions

Copy link
Copy Markdown
Contributor

@alan-baker alan-baker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some minor typos.

Comment thread proposals/bindless.md
When a resource is unpinned it can be used with any usages specified at creation, but when pinned only the single pinned usage is allowed.
This proposal contains WGSL-side validation for the accesses which is augmented to also check that resources are pinned in addition to being present and of the correct type.
This way unpinned resources are not accessible via resource tables, ensuring that correct validation and barriers are done when resources are pinned.
WebGPU's guarantees that there are no data races must be uphelp when resource tables are used, without resource tables, this is done via usage scope validation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
WebGPU's guarantees that there are no data races must be uphelp when resource tables are used, without resource tables, this is done via usage scope validation.
WebGPU's guarantees that there are no data races must be upheld when resource tables are used, without resource tables, this is done via usage scope validation.

Comment thread proposals/bindless.md
Other helper methods not exposed to the IDL are also defined (`isReadable`, `isWritable`).
However in practice shaders cannot call CPU functions and instead implementations will maintain per-slot metadata updated before each usage scope (that shaders will query for validation).

The validation prevents using a slot of the associated full resource has any subresource with a conflicting usage in the usage scope.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
The validation prevents using a slot of the associated full resource has any subresource with a conflicting usage in the usage scope.
The validation prevents using a slot if the associated full resource has any subresource with a conflicting usage in the usage scope.

Comment thread proposals/bindless.md
So we need to prevent data races, so authors need to explicitly choose which usage is accessible through the resource table.

Even if only readonly resources are in the resource table, they are useful to let the implementation know which resources are intended as accessible during an operation.
Otherwise implementation have to assume that any resource in the resource table can be accessed, causing pessimizing synchronization and memory barriers during execution.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Otherwise implementation have to assume that any resource in the resource table can be accessed, causing pessimizing synchronization and memory barriers during execution.
Otherwise implementations have to assume that any resource in the resource table can be accessed, causing pessimizing synchronization and memory barriers during execution.

Comment thread proposals/bindless.md
A new `GPUResourceTable` concept is added to WebGPU that represents a variable-size, sparse and (totally or partially) heterogenous set of bindings.
The resource table can be set in the `GPUCommandEncoder` state and used in shaders to retrieve the resource of a given type at a given index in the currently set `GPUResourceTable`.
Bindings in the `GPUResourceTable` can be updated over time as new resources become needed, or previous resources get no longer in use.
To efficiently implement the validation, memory barrier and other similar kind of tracking needed for `GPUResourceTable`, the mutable resources contained in them must be "pinned" to a certain usage which prevents other kinds of accesses to them.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This sentence mentions pinned still.

@jasmine-nominal

Copy link
Copy Markdown

Where is barrierAndMakeVisible defined in the proposal?

@Kangz

Kangz commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Where is barrierAndMakeVisible defined in the proposal?

It's not part of the proposal, it's pseudo code of what the implementation would do internally. I'll make that more clear.

@jasmine-nominal

Copy link
Copy Markdown
  • Is GPUResourceTableUsage.writable read_write? or just writable only?
  • How would end-users switch between a sampled usage and a storage texture usage of the same texture? GPUResourceTable.update with a new binding?

@Kangz

Kangz commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

TBD exactly what the GPUResourceTableUsage are, maybe writable should be storage_read_write instead, but the intent is definitely to allow for switching between sampled, and read-write storage usage using setResourceUsage.

@Kangz

Kangz commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

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.

[bindless] Stateless alternative to usage pinning?

3 participants