这是indexloc提供的服务,不要输入任何密码
Skip to content

WGSL: function parameters act like const declarations, not var declarations #1171

@dneto0

Description

@dneto0

Example:

fn f(a: f32) -> f32 {
    // This should treat 'a' as if it were a const declaration, where its value is taken to be the argument value provided
    // at runtime by the caller.
    // In particular, you assign to 'a'.
  var b : f32 = a;  //  this is fine
  a = 12.0;  /// this should be invalid.
  return a;
}

One reason this is required is that we need to support formal arguments that are pointers. But a pointer is not storable, and so it can't go into a 'var'. But a const can hold a pointer value.

Metadata

Metadata

Assignees

Labels

wgslWebGPU Shading Language Issueswgsl resolvedResolved - waiting for a change to the WGSL specification

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions