test(wgsl): check that vec3 args. are accepted in cross built-in

This commit is contained in:
Erich Gubler 2024-08-27 14:19:46 -04:00
parent aadca17885
commit 327b92e92b
8 changed files with 75 additions and 0 deletions

3
naga/tests/in/cross.wgsl Normal file
View File

@ -0,0 +1,3 @@
@compute @workgroup_size(1) fn main() {
let a = cross(vec3(0., 1., 2.), vec3(0., 1., 2.));
}

View File

@ -0,0 +1,12 @@
#version 310 es
precision highp float;
precision highp int;
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main() {
vec3 a = cross(vec3(0.0, 1.0, 2.0), vec3(0.0, 1.0, 2.0));
}

View File

@ -0,0 +1,5 @@
[numthreads(1, 1, 1)]
void main()
{
float3 a = cross(float3(0.0, 1.0, 2.0), float3(0.0, 1.0, 2.0));
}

View File

@ -0,0 +1,12 @@
(
vertex:[
],
fragment:[
],
compute:[
(
entry_point:"main",
target_profile:"cs_5_1",
),
],
)

View File

@ -0,0 +1,11 @@
// language: metal1.0
#include <metal_stdlib>
#include <simd/simd.h>
using metal::uint;
kernel void main_(
) {
metal::float3 a = metal::cross(metal::float3(0.0, 1.0, 2.0), metal::float3(0.0, 1.0, 2.0));
}

View File

@ -0,0 +1,24 @@
; SPIR-V
; Version: 1.1
; Generator: rspirv
; Bound: 14
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %6 "main"
OpExecutionMode %6 LocalSize 1 1 1
%2 = OpTypeVoid
%4 = OpTypeFloat 32
%3 = OpTypeVector %4 3
%7 = OpTypeFunction %2
%8 = OpConstant %4 0.0
%9 = OpConstant %4 1.0
%10 = OpConstant %4 2.0
%11 = OpConstantComposite %3 %8 %9 %10
%6 = OpFunction %2 None %7
%5 = OpLabel
OpBranch %12
%12 = OpLabel
%13 = OpExtInst %3 %1 Cross %11 %11
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,4 @@
@compute @workgroup_size(1, 1, 1)
fn main() {
let a = cross(vec3<f32>(0f, 1f, 2f), vec3<f32>(0f, 1f, 2f));
}

View File

@ -910,6 +910,10 @@ fn convert_wgsl() {
Targets::IR | Targets::SPIRV | Targets::METAL,
),
("vertex-pulling-transform", Targets::METAL),
(
"cross",
Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL,
),
];
for &(name, targets) in inputs.iter() {