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

Skip to content

Conversation

@dneto0
Copy link
Contributor

@dneto0 dneto0 commented Jul 28, 2025

Add language extension 'swizzle_assignment'

Example:

var v:vec4u;
v.yz = vec2(1,2);

Issue: #737

@dneto0 dneto0 force-pushed the swizzle-assignment branch from fe9ba88 to d7c5282 Compare July 28, 2025 22:48
@github-actions
Copy link
Contributor

github-actions bot commented Jul 28, 2025

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

@dneto0 dneto0 force-pushed the swizzle-assignment branch from d7c5282 to c984105 Compare July 29, 2025 14:26
@dneto0 dneto0 added this to the Milestone 3+ milestone Jul 29, 2025
@dneto0 dneto0 force-pushed the swizzle-assignment branch 2 times, most recently from abeafa1 to 9aa6e7f Compare July 29, 2025 14:55
@Kangz
Copy link
Contributor

Kangz commented Aug 19, 2025

GPU Web WG 2025-07-30 Atlantic-time
  • (Revised)
  • DN: people have wanted swizzle assignment for a long time. We can give them what they want. Can show them what will work and what won't.
  • DN: subtle: order of operations in e.g. compound assignment. Eval of RHS can modify memory you're evaluating on the LHS. Have already spoken with Oguz and Alan about it.
    • JP: This happens today in assignment to component of a vector.

Add language extension 'swizzle_assignment'

Example:

   var v:vec4u;
   v.yz = vec2(1,2);

Issue: gpuweb#737
3. Evaluate |e2|.

4. Compute |update| by performing the specified binary operation on |viewed_contents| and |e2|.
* For example, if the swizzle assignment is `v += w` then the specified operation is addition.
Copy link
Member

Choose a reason for hiding this comment

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

This isn't actually a swizzle assignment. Should this be v.wx += w to make clearer it's a swizzle assign?

@mwyrzykowski mwyrzykowski self-requested a review October 2, 2025 15:12
Copy link
Contributor Author

@dneto0 dneto0 left a comment

Choose a reason for hiding this comment

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

There is an interaction with 15.2.5 Function Scope Variable Value Analysis, where a swizzle view should sometimes be considered a full reference. It would be if the root variable is of vector type, because a swizzle assignment is deemed to be overwriting the entire vector.

@jimblandy
Copy link
Contributor

@dneto0 I gather that, since this is a draft, it's not ready for committee discussion?

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.

5 participants