Skip to content

[editorial] Consistency of built-in function overloads #4488

@alan-baker

Description

@alan-baker

The spec is not entirely consistent with how parameterizations of built-in functions are presented. For example, the value constructors for mat2x2 have some of the following overloads:

@const @must_use fn mat2x2<T>(e : mat2x2<S>) -> mat2x2<T> 
@const @must_use fn mat2x2(e : mat2x2<S>) -> mat2x2<S>

// T is f32 or f16
// S is AbstractFloat, f32, or f16

@const @must_use fn mat2x2<T>(v1 : vec2<T>, v2 : vec2<T>) -> mat2x2<T> 
@const @must_use fn mat2x2(v1 : vec2<T>, v2 : vec2<T>) -> mat2x2<T>

// T is AbstractFloat, f32, or f16

In the first overloads S being AbstractFloat is superfluous since automatic type concretization would occur.

In the second set, mat2x2<AbstractFloat> cannot be typed in WGSL.

The spec should be consistent about how built-in functions are presented. We should answer the following questions:

  1. Should only required built-in function parameterization be listed? My preference would be yes.
  2. For abstract types, should we eliminate overloads that cannot be typed? Note that mat2x2<AbstractFloat> is required for parameter type rules.

After deciding those questions (and any others that might arise) we should do a pass over the spec to make it consistent.

cc @dj2 @dneto0

Metadata

Metadata

Assignees

No one assigned

    Labels

    copyeditingPure editorial stuff (copyediting, *.bs file syntax, etc.)wgslWebGPU Shading Language Issues

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions