From f37db5affc6a5e84f3aa0f8e09eeb11e146e4032 Mon Sep 17 00:00:00 2001 From: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com> Date: Thu, 5 Oct 2023 19:14:52 +0200 Subject: [PATCH] [wgsl] remove `outerProduct` (#2535) --- src/back/wgsl/writer.rs | 3 +-- src/front/wgsl/parse/conv.rs | 1 - tests/in/glsl/math-functions.frag | 3 ++- tests/out/wgsl/math-functions.frag.wgsl | 24 ++++++++++-------------- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/back/wgsl/writer.rs b/src/back/wgsl/writer.rs index 428a413374..8f6b4074a3 100644 --- a/src/back/wgsl/writer.rs +++ b/src/back/wgsl/writer.rs @@ -1529,7 +1529,6 @@ impl Writer { Mf::Pow => Function::Regular("pow"), // geometry Mf::Dot => Function::Regular("dot"), - Mf::Outer => Function::Regular("outerProduct"), Mf::Cross => Function::Regular("cross"), Mf::Distance => Function::Regular("distance"), Mf::Length => Function::Regular("length"), @@ -1568,7 +1567,7 @@ impl Writer { Mf::Unpack2x16snorm => Function::Regular("unpack2x16snorm"), Mf::Unpack2x16unorm => Function::Regular("unpack2x16unorm"), Mf::Unpack2x16float => Function::Regular("unpack2x16float"), - Mf::Inverse => { + Mf::Inverse | Mf::Outer => { return Err(Error::UnsupportedMathFunction(fun)); } }; diff --git a/src/front/wgsl/parse/conv.rs b/src/front/wgsl/parse/conv.rs index 3b14d0aee3..fea60dc09b 100644 --- a/src/front/wgsl/parse/conv.rs +++ b/src/front/wgsl/parse/conv.rs @@ -180,7 +180,6 @@ pub fn map_standard_fun(word: &str) -> Option { "pow" => Mf::Pow, // geometry "dot" => Mf::Dot, - "outerProduct" => Mf::Outer, "cross" => Mf::Cross, "distance" => Mf::Distance, "length" => Mf::Length, diff --git a/tests/in/glsl/math-functions.frag b/tests/in/glsl/math-functions.frag index 3c12d82d2c..1006bda838 100644 --- a/tests/in/glsl/math-functions.frag +++ b/tests/in/glsl/math-functions.frag @@ -44,7 +44,8 @@ void main() { vec4 minOut = min(a, b); vec4 reflectOut = reflect(a, b); vec3 crossOut = cross(a.xyz, b.xyz); - mat4 outerProductOut = outerProduct(a, b); + // TODO: support outerProduct function in wgsl output + // mat4 outerProductOut = outerProduct(a, b); float distanceOut = distance(a, b); vec4 stepOut = step(a, b); // TODO: support out params in wgsl output diff --git a/tests/out/wgsl/math-functions.frag.wgsl b/tests/out/wgsl/math-functions.frag.wgsl index 37e42868a4..0bcc5f5334 100644 --- a/tests/out/wgsl/math-functions.frag.wgsl +++ b/tests/out/wgsl/math-functions.frag.wgsl @@ -39,7 +39,6 @@ fn main_1() { var minOut: vec4; var reflectOut: vec4; var crossOut: vec3; - var outerProductOut: mat4x4; var distanceOut: f32; var stepOut: vec4; var ldexpOut: f32; @@ -146,22 +145,19 @@ fn main_1() { crossOut = cross(_e205.xyz, _e207.xyz); let _e213 = a; let _e214 = b; - outerProductOut = outerProduct(_e213, _e214); + distanceOut = distance(_e213, _e214); let _e219 = a; let _e220 = b; - distanceOut = distance(_e219, _e220); - let _e225 = a; - let _e226 = b; - stepOut = step(_e225, _e226); - let _e229 = a; + stepOut = step(_e219, _e220); + let _e223 = a; + let _e226 = a; + let _e228 = i; + ldexpOut = ldexp(_e226.x, _e228); let _e232 = a; - let _e234 = i; - ldexpOut = ldexp(_e232.x, _e234); - let _e238 = a; - rad = radians(_e238); - let _e241 = a; - let _e243 = a; - deg = degrees(_e243.x); + rad = radians(_e232); + let _e235 = a; + let _e237 = a; + deg = degrees(_e237.x); smoothStepScalar = smoothstep(0.0, 1.0, 0.5); smoothStepVector = smoothstep(vec4(0.0), vec4(1.0), vec4(0.5)); smoothStepMixed = smoothstep(vec4(0.0), vec4(1.0), vec4(0.5));