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

Skip to content

Add buffer_view language feature - #6291

Merged
alan-baker merged 10 commits into
gpuweb:mainfrom
alan-baker:buffer-view-spec
Jul 14, 2026
Merged

Add buffer_view language feature#6291
alan-baker merged 10 commits into
gpuweb:mainfrom
alan-baker:buffer-view-spec

Conversation

@alan-baker

@alan-baker alan-baker commented Jun 11, 2026

Copy link
Copy Markdown
Contributor
  • API and WGSL changes to support buffer_view

Closes #5338

@alan-baker

Copy link
Copy Markdown
Contributor Author

CTS is here: gpuweb/cts#4652

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Previews, as seen when this build job started (a750fcb):
WebGPU webgpu.idl | Explainer | Correspondence Reference
WGSL grammar.js | wgsl.lalr.txt

Comment thread wgsl/index.bs
Comment thread wgsl/index.bs Outdated

@dneto0 dneto0 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.

very nice, careful work!

i have a bunch of refinements below, and also updates to other parts of the spec

14.4.5

"The storage and uniform address spaces have different buffer layout constraints which are described in this section."

Replace "buffer" with "memory" ?? Or delete "buffer" entirely?

14.4

"AlignOf(T) is the alignment of T", when T is not a a buffer type.

14.4 AccessibleBytes

AccessibleBytes(T) is not defined otherwise. (other than the listed cases)

14.4.1 Alignment and size.

"Each host-shareable or fixed footprint data type T has an alignment and size."

Suggest splitting cases, to make the exception clear:

Each host-shareable or fixed footprint type has a size.

Except for [=buffer=] types, each host-shareable or fixed footprint type has an alignment.

14.4.4 Internal layout of values.

"These layouts depend on the value’s type, and the align and size attributes on structure members."

Append. "These rule apply to non-opaque types as described below; values of [=buffer=] type do not
have an internal structure, and are not contrained by these rules."

interaction with "valid pointer"

bufferView, bufferArrayView built-ins yield invalid pointer if the original pointer is invalid.
Is that possible?

What does bufferLength return on an invalid pointer? (Is that even possible after type checking?)

6.5.8

"A pointer value is formed in one of the following ways"

  • add a case for bufferView

6.5.4

"a bufferView or bufferArrayView built-in function requires a larger size than the buffer’s memory view contains."

The "requires a larger size" is confusing?

This rule belongs in a new set of paragraphs for how to make an invalid pointer rather than invalid reference.

Suggest?:

An invalid pointer is formed by:

  • Applying the address-of operator (&) to an invalid memory reference.
  • Calling the bufferView or bufferArrayView built-in functions, but the memory view of
    the resulting pointer would otherwise include memory locations outside the memory view of the
    pointer argument.

Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
Comment thread wgsl/index.bs
Comment thread wgsl/index.bs Outdated
Comment thread wgsl/index.bs Outdated
Comment thread wgsl/index.bs
Comment thread wgsl/index.bs Outdated
Comment thread wgsl/index.bs Outdated
Comment thread wgsl/index.bs Outdated
Comment thread wgsl/index.bs Outdated
* API and WGSL changes to support buffer_view
@alan-baker

Copy link
Copy Markdown
Contributor Author

bufferView, bufferArrayView built-ins yield invalid pointer if the original pointer is invalid.
Is that possible?

Given the API validation around minimum binding size, I don't believe there can ever be an invalid buffer pointer.

@dneto0 dneto0 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.

LGTM. Thanks!

Two typos.

Comment thread wgsl/index.bs Outdated
Comment thread wgsl/index.bs
Comment thread wgsl/index.bs Outdated
Comment thread wgsl/index.bs
Comment thread wgsl/index.bs Outdated
@jimblandy

jimblandy commented Jun 23, 2026

Copy link
Copy Markdown
Contributor
minutes from WGSL committee meeting 2026-6-23

@jimblandy jimblandy moved this to Waiting for PR approval in JimB WGSL planning Jun 23, 2026
Comment thread spec/index.bs Outdated
Comment thread wgsl/index.bs
* Change API minimum buffer binding size calculation to only consider
  MinTypeSize (no offset or size included)
* Fix bufferArrayView example

@jimblandy jimblandy 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.

Looks good to me - thank you!

@jimblandy

Copy link
Copy Markdown
Contributor

Does this close #5338?

@alan-baker

Copy link
Copy Markdown
Contributor Author

Does this close #5338?

I believe so.

@jimblandy jimblandy moved this from Waiting for PR approval to Waiting on CTS in JimB WGSL planning Jul 13, 2026
@alan-baker
alan-baker merged commit 760104e into gpuweb:main Jul 14, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from Waiting on CTS to Done in JimB WGSL planning Jul 14, 2026
@alan-baker
alan-baker deleted the buffer-view-spec branch July 14, 2026 19:49
beckysiegel pushed a commit to chromium/chromium that referenced this pull request Jul 15, 2026
Spec: gpuweb/gpuweb#6291
CTS: gpuweb/cts#4652

Both were approved and landed.

Bug: 506523117
Change-Id: I7a6ad45f4b3a637eb4f7cf015c5729f4ac38f5ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8086445
Commit-Queue: Alan Baker <[email protected]>
Reviewed-by: Kai Ninomiya <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1662578}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

[buffer-view] Viewing the content of a storage buffer as different types.

5 participants