Skip to content

Function database is missing some abstract overloads #7405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jimblandy opened this issue Mar 24, 2025 · 2 comments
Open

Function database is missing some abstract overloads #7405

jimblandy opened this issue Mar 24, 2025 · 2 comments
Labels
area: naga front-end lang: WGSL WebGPU Shading Language naga Shader Translator

Comments

@jimblandy
Copy link
Member

The overload database for MathFunction operations implemented in #6833 does not include AbstractFloat overloads for the following functions:

  • Outer
  • Cross
  • Distance
  • Length
  • Normalize
  • FaceForward
  • Reflect
  • Refract
  • Ldexp
  • Modf
  • Mix
  • Frexp

This is because permitting abstract arguments to these functions causes the WGSL front end to leave their arguments as abstract-typed values, rather than converting them to concrete types. This would be correct, except that the constant evaluator does not implement these functions, which means we have an unevaluated, abstract-typed expression left in the arena, which the constant evaluator doesn't like.

As a workaround, #6833 omits the abstract-typed overloads of these functions, causing the WGSL front end to apply automatic conversions that turn them into concrete values, which the backends can just emit runtime code for.

jimblandy added a commit to jimblandy/wgpu that referenced this issue Mar 24, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Mar 24, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
@jimblandy
Copy link
Member Author

#6833 adds a new few constants/functions that the non-spec-compliant overload sets all depend on. These items' doc strings all refer to this issue by number, #7405. The fix for this bug should delete those constants/functions, which will cause a compile-time error if the corresponding functions' overload sets are not fixed accordingly.

jimblandy added a commit to jimblandy/wgpu that referenced this issue Mar 24, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Mar 24, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Mar 24, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Mar 24, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Mar 24, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Mar 24, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Mar 24, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Mar 24, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Mar 24, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Mar 24, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Mar 24, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Mar 25, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Mar 25, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Mar 27, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Mar 28, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
@teoxoy
Copy link
Member

teoxoy commented Mar 31, 2025

Related: #4507

jimblandy added a commit to jimblandy/wgpu that referenced this issue Mar 31, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Apr 1, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Apr 1, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Apr 2, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Apr 2, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
cwfitzgerald pushed a commit that referenced this issue Apr 2, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around #7405, avoid offering abstract-typed overloads of some
functions.

This addresses #6443 for `MathFunction`, although that issue covers
other categories of operations as well.
Vecvec pushed a commit to Vecvec/wgpu that referenced this issue Apr 11, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
@cwfitzgerald cwfitzgerald added type: bug Something isn't working naga Shader Translator area: naga front-end lang: WGSL WebGPU Shading Language and removed type: bug Something isn't working labels Apr 16, 2025
jimblandy added a commit to jimblandy/wgpu that referenced this issue Apr 18, 2025
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide two implementations
of `OverloadSet`:

- `List` is flexible but verbose.

- `Regular` is concise but more restrictive.

Some snapshot output is affected because `TypeResolution::Handle`
values turn into `TypeResolution::Value`, since the function database
constructs the return type directly.

To work around gfx-rs#7405, avoid offering abstract-typed overloads of some
functions.

This addresses gfx-rs#6443 for `MathFunction`, although that issue covers
other categories of operations as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga front-end lang: WGSL WebGPU Shading Language naga Shader Translator
Projects
Status: Todo
Development

No branches or pull requests

3 participants