wgpu/naga/tests/in/wgsl/cross.wgsl
Jim Blandy f0ff173f82
[naga] Implement constant evaluation for the cross builtin. (#7404)
Add support for `naga::ir::MathFunction::Cross` to
`naga::proc::constant_evaluator`.

In the tests:

- Change `naga/tests/in/wgsl/cross.wgsl` to use more interesting
  argument values. Rather than passing the same vector twice, which
  yields a cross product of zero, pass in the x and y unit vectors,
  whose cross product is the z unit vector. Update snapshot output.

- Replace `validation::bad_cross_builtin_args` with a new test,
  `builtin_cross_product_args`, that is written more in the style of
  the other tests in this module, and does not depend on the WGSL
  front end. Because this PR changes the behavior of the constant
  evaluator, this test stopped behaving as expected.

- In `wgsl_errors::check`, move a `panic!` out of a closure so that
  the `#[track_caller]` attribute works properly.
2025-03-24 10:55:22 +01:00

5 lines
188 B
WebGPU Shading Language

// NOTE: invalid combinations are tested in the `validation::bad_cross_builtin_args` test.
@compute @workgroup_size(1) fn main() {
let a = cross(vec3(1., 0., 0.), vec3(0., 1., 0.));
}