mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
add constructors test file
This commit is contained in:
2
tests/in/constructors.param.ron
Normal file
2
tests/in/constructors.param.ron
Normal file
@@ -0,0 +1,2 @@
|
||||
(
|
||||
)
|
||||
67
tests/in/constructors.wgsl
Normal file
67
tests/in/constructors.wgsl
Normal file
@@ -0,0 +1,67 @@
|
||||
struct Foo {
|
||||
a: vec4<f32>,
|
||||
b: i32,
|
||||
}
|
||||
|
||||
// const const1 = vec3<f32>(0.0); // TODO: this is now a splat and we need to const eval it
|
||||
const const2 = vec3(0.0, 1.0, 2.0);
|
||||
const const3 = mat2x2<f32>(0.0, 1.0, 2.0, 3.0);
|
||||
const const4 = array<mat2x2<f32>, 1>(mat2x2<f32>(0.0, 1.0, 2.0, 3.0));
|
||||
|
||||
// zero value constructors
|
||||
const cz0 = bool();
|
||||
const cz1 = i32();
|
||||
const cz2 = u32();
|
||||
const cz3 = f32();
|
||||
const cz4 = vec2<u32>();
|
||||
const cz5 = mat2x2<f32>();
|
||||
const cz6 = array<Foo, 3>();
|
||||
const cz7 = Foo();
|
||||
|
||||
// constructors that infer their type from their parameters
|
||||
// TODO: these also contain splats
|
||||
// const cp1 = vec2(0u);
|
||||
// const cp2 = mat2x2(vec2(0.), vec2(0.));
|
||||
const cp3 = array(0, 1, 2, 3);
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main() {
|
||||
var foo: Foo;
|
||||
foo = Foo(vec4<f32>(1.0), 1);
|
||||
|
||||
let m0 = mat2x2<f32>(
|
||||
1.0, 0.0,
|
||||
0.0, 1.0,
|
||||
);
|
||||
let m1 = mat4x4<f32>(
|
||||
1.0, 0.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0,
|
||||
);
|
||||
|
||||
// zero value constructors
|
||||
let zvc0 = bool();
|
||||
let zvc1 = i32();
|
||||
let zvc2 = u32();
|
||||
let zvc3 = f32();
|
||||
let zvc4 = vec2<u32>();
|
||||
let zvc5 = mat2x2<f32>();
|
||||
let zvc6 = array<Foo, 3>();
|
||||
let zvc7 = Foo();
|
||||
|
||||
// constructors that infer their type from their parameters
|
||||
let cit0 = vec2(0u);
|
||||
let cit1 = mat2x2(vec2(0.), vec2(0.));
|
||||
let cit2 = array(0, 1, 2, 3);
|
||||
|
||||
// identity constructors
|
||||
let ic0 = bool(bool());
|
||||
let ic1 = i32(i32());
|
||||
let ic2 = u32(u32());
|
||||
let ic3 = f32(f32());
|
||||
let ic4 = vec2<u32>(vec2<u32>());
|
||||
let ic5 = mat2x3<f32>(mat2x3<f32>());
|
||||
let ic6 = vec2(vec2<u32>());
|
||||
let ic7 = mat2x3(mat2x3<f32>());
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
//TODO: support splatting constructors for globals?
|
||||
const v_f32_one = vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
||||
const v_f32_zero = vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
const v_f32_half = vec4<f32>(0.5, 0.5, 0.5, 0.5);
|
||||
@@ -41,54 +40,6 @@ fn bool_cast(x: vec3<f32>) -> vec3<f32> {
|
||||
return vec3<f32>(y);
|
||||
}
|
||||
|
||||
struct Foo {
|
||||
a: vec4<f32>,
|
||||
b: i32,
|
||||
}
|
||||
|
||||
fn constructors() -> f32 {
|
||||
var foo: Foo;
|
||||
foo = Foo(vec4<f32>(1.0), 1);
|
||||
|
||||
let m0 = mat2x2<f32>(
|
||||
1.0, 0.0,
|
||||
0.0, 1.0,
|
||||
);
|
||||
let m1 = mat4x4<f32>(
|
||||
1.0, 0.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0,
|
||||
);
|
||||
|
||||
// zero value constructors
|
||||
let zvc0 = bool();
|
||||
let zvc1 = i32();
|
||||
let zvc2 = u32();
|
||||
let zvc3 = f32();
|
||||
let zvc4 = vec2<u32>();
|
||||
let zvc5 = mat2x2<f32>();
|
||||
let zvc6 = array<Foo, 3>();
|
||||
let zvc7 = Foo();
|
||||
|
||||
// constructors that infer their type from their parameters
|
||||
let cit0 = vec2(0u);
|
||||
let cit1 = mat2x2(vec2(0.), vec2(0.));
|
||||
let cit2 = array(0, 1, 2, 3);
|
||||
|
||||
// identity constructors
|
||||
let ic0 = bool(bool());
|
||||
let ic1 = i32(i32());
|
||||
let ic2 = u32(u32());
|
||||
let ic3 = f32(f32());
|
||||
let ic4 = vec2<u32>(vec2<u32>());
|
||||
let ic5 = mat2x3<f32>(mat2x3<f32>());
|
||||
let ic6 = vec2(vec2<u32>());
|
||||
let ic7 = mat2x3(mat2x3<f32>());
|
||||
|
||||
return foo.a.x;
|
||||
}
|
||||
|
||||
fn logical() {
|
||||
// unary
|
||||
let neg0 = !true;
|
||||
@@ -306,7 +257,6 @@ fn main() {
|
||||
builtins();
|
||||
splat();
|
||||
bool_cast(v_f32_one.xyz);
|
||||
constructors();
|
||||
|
||||
logical();
|
||||
arithmetic();
|
||||
|
||||
43
tests/out/glsl/constructors.main.Compute.glsl
Normal file
43
tests/out/glsl/constructors.main.Compute.glsl
Normal file
@@ -0,0 +1,43 @@
|
||||
#version 310 es
|
||||
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
struct Foo {
|
||||
vec4 a;
|
||||
int b;
|
||||
};
|
||||
const vec3 const2_ = vec3(0.0, 1.0, 2.0);
|
||||
const mat2x2 const3_ = mat2x2(vec2(0.0, 1.0), vec2(2.0, 3.0));
|
||||
const mat2x2 const4_[1] = mat2x2[1](mat2x2(vec2(0.0, 1.0), vec2(2.0, 3.0)));
|
||||
const bool cz0_ = false;
|
||||
const int cz1_ = 0;
|
||||
const uint cz2_ = 0u;
|
||||
const float cz3_ = 0.0;
|
||||
const uvec2 cz4_ = uvec2(0u);
|
||||
const mat2x2 cz5_ = mat2x2(0.0);
|
||||
const Foo cz6_[3] = Foo[3](Foo(vec4(0.0), 0), Foo(vec4(0.0), 0), Foo(vec4(0.0), 0));
|
||||
const Foo cz7_ = Foo(vec4(0.0), 0);
|
||||
const int cp3_[4] = int[4](0, 1, 2, 3);
|
||||
|
||||
|
||||
void main() {
|
||||
Foo foo = Foo(vec4(0.0), 0);
|
||||
foo = Foo(vec4(1.0), 1);
|
||||
mat2x2 m0_ = mat2x2(vec2(1.0, 0.0), vec2(0.0, 1.0));
|
||||
mat4x4 m1_ = mat4x4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0));
|
||||
uvec2 cit0_ = uvec2(0u);
|
||||
mat2x2 cit1_ = mat2x2(vec2(0.0), vec2(0.0));
|
||||
int cit2_[4] = int[4](0, 1, 2, 3);
|
||||
bool ic0_ = bool(false);
|
||||
int ic1_ = int(0);
|
||||
uint ic2_ = uint(0u);
|
||||
float ic3_ = float(0.0);
|
||||
uvec2 ic4_ = uvec2(uvec2(0u));
|
||||
mat2x3 ic5_ = mat2x3(mat2x3(0.0));
|
||||
uvec2 ic6_ = uvec2(0u);
|
||||
mat2x3 ic7_ = mat2x3(0.0);
|
||||
}
|
||||
|
||||
@@ -5,10 +5,6 @@ precision highp int;
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
struct Foo {
|
||||
vec4 a;
|
||||
int b;
|
||||
};
|
||||
const vec4 v_f32_one = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
const vec4 v_f32_zero = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
const vec4 v_f32_half = vec4(0.5, 0.5, 0.5, 0.5);
|
||||
@@ -51,26 +47,6 @@ vec3 bool_cast(vec3 x) {
|
||||
return vec3(y);
|
||||
}
|
||||
|
||||
float constructors() {
|
||||
Foo foo = Foo(vec4(0.0), 0);
|
||||
foo = Foo(vec4(1.0), 1);
|
||||
mat2x2 m0_ = mat2x2(vec2(1.0, 0.0), vec2(0.0, 1.0));
|
||||
mat4x4 m1_1 = mat4x4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0));
|
||||
uvec2 cit0_ = uvec2(0u);
|
||||
mat2x2 cit1_ = mat2x2(vec2(0.0), vec2(0.0));
|
||||
int cit2_[4] = int[4](0, 1, 2, 3);
|
||||
bool ic0_ = bool(false);
|
||||
int ic1_ = int(0);
|
||||
uint ic2_ = uint(0u);
|
||||
float ic3_ = float(0.0);
|
||||
uvec2 ic4_ = uvec2(uvec2(0u));
|
||||
mat2x3 ic5_ = mat2x3(mat2x3(0.0));
|
||||
uvec2 ic6_ = uvec2(0u);
|
||||
mat2x3 ic7_ = mat2x3(0.0);
|
||||
float _e71 = foo.a.x;
|
||||
return _e71;
|
||||
}
|
||||
|
||||
void logical() {
|
||||
bool neg0_ = !(true);
|
||||
bvec2 neg1_ = not(bvec2(true));
|
||||
@@ -274,7 +250,6 @@ void main() {
|
||||
vec4 _e0 = builtins();
|
||||
vec4 _e1 = splat();
|
||||
vec3 _e4 = bool_cast(v_f32_one.xyz);
|
||||
float _e5 = constructors();
|
||||
logical();
|
||||
arithmetic();
|
||||
bit();
|
||||
|
||||
60
tests/out/hlsl/constructors.hlsl
Normal file
60
tests/out/hlsl/constructors.hlsl
Normal file
@@ -0,0 +1,60 @@
|
||||
struct Foo {
|
||||
float4 a;
|
||||
int b;
|
||||
int _end_pad_0;
|
||||
int _end_pad_1;
|
||||
int _end_pad_2;
|
||||
};
|
||||
|
||||
typedef float2x2 ret_Constructarray1_float2x2_[1];
|
||||
ret_Constructarray1_float2x2_ Constructarray1_float2x2_(float2x2 arg0) {
|
||||
float2x2 ret[1] = { arg0 };
|
||||
return ret;
|
||||
}
|
||||
|
||||
typedef int ret_Constructarray4_int_[4];
|
||||
ret_Constructarray4_int_ Constructarray4_int_(int arg0, int arg1, int arg2, int arg3) {
|
||||
int ret[4] = { arg0, arg1, arg2, arg3 };
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const float3 const2_ = float3(0.0, 1.0, 2.0);
|
||||
static const float2x2 const3_ = float2x2(float2(0.0, 1.0), float2(2.0, 3.0));
|
||||
static const float2x2 const4_[1] = Constructarray1_float2x2_(float2x2(float2(0.0, 1.0), float2(2.0, 3.0)));
|
||||
static const bool cz0_ = (bool)0;
|
||||
static const int cz1_ = (int)0;
|
||||
static const uint cz2_ = (uint)0;
|
||||
static const float cz3_ = (float)0;
|
||||
static const uint2 cz4_ = (uint2)0;
|
||||
static const float2x2 cz5_ = (float2x2)0;
|
||||
static const Foo cz6_[3] = (Foo[3])0;
|
||||
static const Foo cz7_ = (Foo)0;
|
||||
static const int cp3_[4] = Constructarray4_int_(0, 1, 2, 3);
|
||||
|
||||
Foo ConstructFoo(float4 arg0, int arg1) {
|
||||
Foo ret = (Foo)0;
|
||||
ret.a = arg0;
|
||||
ret.b = arg1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main()
|
||||
{
|
||||
Foo foo = (Foo)0;
|
||||
|
||||
foo = ConstructFoo((1.0).xxxx, 1);
|
||||
float2x2 m0_ = float2x2(float2(1.0, 0.0), float2(0.0, 1.0));
|
||||
float4x4 m1_ = float4x4(float4(1.0, 0.0, 0.0, 0.0), float4(0.0, 1.0, 0.0, 0.0), float4(0.0, 0.0, 1.0, 0.0), float4(0.0, 0.0, 0.0, 1.0));
|
||||
uint2 cit0_ = (0u).xx;
|
||||
float2x2 cit1_ = float2x2((0.0).xx, (0.0).xx);
|
||||
int cit2_[4] = Constructarray4_int_(0, 1, 2, 3);
|
||||
bool ic0_ = bool((bool)0);
|
||||
int ic1_ = int((int)0);
|
||||
uint ic2_ = uint((uint)0);
|
||||
float ic3_ = float((float)0);
|
||||
uint2 ic4_ = uint2((uint2)0);
|
||||
float2x3 ic5_ = float2x3((float2x3)0);
|
||||
uint2 ic6_ = asuint((uint2)0);
|
||||
float2x3 ic7_ = asfloat((float2x3)0);
|
||||
}
|
||||
3
tests/out/hlsl/constructors.hlsl.config
Normal file
3
tests/out/hlsl/constructors.hlsl.config
Normal file
@@ -0,0 +1,3 @@
|
||||
vertex=()
|
||||
fragment=()
|
||||
compute=(main:cs_5_1 )
|
||||
12
tests/out/hlsl/constructors.ron
Normal file
12
tests/out/hlsl/constructors.ron
Normal file
@@ -0,0 +1,12 @@
|
||||
(
|
||||
vertex:[
|
||||
],
|
||||
fragment:[
|
||||
],
|
||||
compute:[
|
||||
(
|
||||
entry_point:"main",
|
||||
target_profile:"cs_5_1",
|
||||
),
|
||||
],
|
||||
)
|
||||
@@ -1,11 +1,3 @@
|
||||
struct Foo {
|
||||
float4 a;
|
||||
int b;
|
||||
int _end_pad_0;
|
||||
int _end_pad_1;
|
||||
int _end_pad_2;
|
||||
};
|
||||
|
||||
static const float4 v_f32_one = float4(1.0, 1.0, 1.0, 1.0);
|
||||
static const float4 v_f32_zero = float4(0.0, 0.0, 0.0, 0.0);
|
||||
static const float4 v_f32_half = float4(0.5, 0.5, 0.5, 0.5);
|
||||
@@ -52,41 +44,6 @@ float3 bool_cast(float3 x)
|
||||
return float3(y);
|
||||
}
|
||||
|
||||
Foo ConstructFoo(float4 arg0, int arg1) {
|
||||
Foo ret = (Foo)0;
|
||||
ret.a = arg0;
|
||||
ret.b = arg1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
typedef int ret_Constructarray4_int_[4];
|
||||
ret_Constructarray4_int_ Constructarray4_int_(int arg0, int arg1, int arg2, int arg3) {
|
||||
int ret[4] = { arg0, arg1, arg2, arg3 };
|
||||
return ret;
|
||||
}
|
||||
|
||||
float constructors()
|
||||
{
|
||||
Foo foo = (Foo)0;
|
||||
|
||||
foo = ConstructFoo((1.0).xxxx, 1);
|
||||
float2x2 m0_ = float2x2(float2(1.0, 0.0), float2(0.0, 1.0));
|
||||
float4x4 m1_1 = float4x4(float4(1.0, 0.0, 0.0, 0.0), float4(0.0, 1.0, 0.0, 0.0), float4(0.0, 0.0, 1.0, 0.0), float4(0.0, 0.0, 0.0, 1.0));
|
||||
uint2 cit0_ = (0u).xx;
|
||||
float2x2 cit1_ = float2x2((0.0).xx, (0.0).xx);
|
||||
int cit2_[4] = Constructarray4_int_(0, 1, 2, 3);
|
||||
bool ic0_ = bool((bool)0);
|
||||
int ic1_ = int((int)0);
|
||||
uint ic2_ = uint((uint)0);
|
||||
float ic3_ = float((float)0);
|
||||
uint2 ic4_ = uint2((uint2)0);
|
||||
float2x3 ic5_ = float2x3((float2x3)0);
|
||||
uint2 ic6_ = asuint((uint2)0);
|
||||
float2x3 ic7_ = asfloat((float2x3)0);
|
||||
float _expr71 = foo.a.x;
|
||||
return _expr71;
|
||||
}
|
||||
|
||||
void logical()
|
||||
{
|
||||
bool neg0_ = !(true);
|
||||
@@ -299,7 +256,6 @@ void main()
|
||||
const float4 _e0 = builtins();
|
||||
const float4 _e1 = splat();
|
||||
const float3 _e4 = bool_cast(v_f32_one.xyz);
|
||||
const float _e5 = constructors();
|
||||
logical();
|
||||
arithmetic();
|
||||
bit();
|
||||
|
||||
50
tests/out/msl/constructors.msl
Normal file
50
tests/out/msl/constructors.msl
Normal file
@@ -0,0 +1,50 @@
|
||||
// language: metal2.0
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using metal::uint;
|
||||
|
||||
struct Foo {
|
||||
metal::float4 a;
|
||||
int b;
|
||||
};
|
||||
struct type_5 {
|
||||
metal::float2x2 inner[1];
|
||||
};
|
||||
struct type_10 {
|
||||
Foo inner[3];
|
||||
};
|
||||
struct type_11 {
|
||||
int inner[4];
|
||||
};
|
||||
constant metal::float3 const2_ = metal::float3(0.0, 1.0, 2.0);
|
||||
constant metal::float2x2 const3_ = metal::float2x2(metal::float2(0.0, 1.0), metal::float2(2.0, 3.0));
|
||||
constant type_5 const4_ = type_5 {metal::float2x2(metal::float2(0.0, 1.0), metal::float2(2.0, 3.0))};
|
||||
constant bool cz0_ = bool {};
|
||||
constant int cz1_ = int {};
|
||||
constant uint cz2_ = uint {};
|
||||
constant float cz3_ = float {};
|
||||
constant metal::uint2 cz4_ = metal::uint2 {};
|
||||
constant metal::float2x2 cz5_ = metal::float2x2 {};
|
||||
constant type_10 cz6_ = type_10 {};
|
||||
constant Foo cz7_ = Foo {};
|
||||
constant type_11 cp3_ = type_11 {0, 1, 2, 3};
|
||||
|
||||
kernel void main_(
|
||||
) {
|
||||
Foo foo = {};
|
||||
foo = Foo {metal::float4(1.0), 1};
|
||||
metal::float2x2 m0_ = metal::float2x2(metal::float2(1.0, 0.0), metal::float2(0.0, 1.0));
|
||||
metal::float4x4 m1_ = metal::float4x4(metal::float4(1.0, 0.0, 0.0, 0.0), metal::float4(0.0, 1.0, 0.0, 0.0), metal::float4(0.0, 0.0, 1.0, 0.0), metal::float4(0.0, 0.0, 0.0, 1.0));
|
||||
metal::uint2 cit0_ = metal::uint2(0u);
|
||||
metal::float2x2 cit1_ = metal::float2x2(metal::float2(0.0), metal::float2(0.0));
|
||||
type_11 cit2_ = type_11 {0, 1, 2, 3};
|
||||
bool ic0_ = static_cast<bool>(bool {});
|
||||
int ic1_ = static_cast<int>(int {});
|
||||
uint ic2_ = static_cast<uint>(uint {});
|
||||
float ic3_ = static_cast<float>(float {});
|
||||
metal::uint2 ic4_ = static_cast<metal::uint2>(metal::uint2 {});
|
||||
metal::float2x3 ic5_ = metal::float2x3(metal::float2x3 {});
|
||||
metal::uint2 ic6_ = as_type<metal::uint2>(metal::uint2 {});
|
||||
metal::float2x3 ic7_ = metal::float2x3(metal::float2x3 {});
|
||||
}
|
||||
@@ -4,16 +4,6 @@
|
||||
|
||||
using metal::uint;
|
||||
|
||||
struct Foo {
|
||||
metal::float4 a;
|
||||
int b;
|
||||
};
|
||||
struct type_13 {
|
||||
Foo inner[3];
|
||||
};
|
||||
struct type_14 {
|
||||
int inner[4];
|
||||
};
|
||||
constant metal::float4 v_f32_one = metal::float4(1.0, 1.0, 1.0, 1.0);
|
||||
constant metal::float4 v_f32_zero = metal::float4(0.0, 0.0, 0.0, 0.0);
|
||||
constant metal::float4 v_f32_half = metal::float4(0.5, 0.5, 0.5, 0.5);
|
||||
@@ -60,27 +50,6 @@ metal::float3 bool_cast(
|
||||
return static_cast<metal::float3>(y);
|
||||
}
|
||||
|
||||
float constructors(
|
||||
) {
|
||||
Foo foo = {};
|
||||
foo = Foo {metal::float4(1.0), 1};
|
||||
metal::float2x2 m0_ = metal::float2x2(metal::float2(1.0, 0.0), metal::float2(0.0, 1.0));
|
||||
metal::float4x4 m1_1 = metal::float4x4(metal::float4(1.0, 0.0, 0.0, 0.0), metal::float4(0.0, 1.0, 0.0, 0.0), metal::float4(0.0, 0.0, 1.0, 0.0), metal::float4(0.0, 0.0, 0.0, 1.0));
|
||||
metal::uint2 cit0_ = metal::uint2(0u);
|
||||
metal::float2x2 cit1_ = metal::float2x2(metal::float2(0.0), metal::float2(0.0));
|
||||
type_14 cit2_ = type_14 {0, 1, 2, 3};
|
||||
bool ic0_ = static_cast<bool>(bool {});
|
||||
int ic1_ = static_cast<int>(int {});
|
||||
uint ic2_ = static_cast<uint>(uint {});
|
||||
float ic3_ = static_cast<float>(float {});
|
||||
metal::uint2 ic4_ = static_cast<metal::uint2>(metal::uint2 {});
|
||||
metal::float2x3 ic5_ = metal::float2x3(metal::float2x3 {});
|
||||
metal::uint2 ic6_ = as_type<metal::uint2>(metal::uint2 {});
|
||||
metal::float2x3 ic7_ = metal::float2x3(metal::float2x3 {});
|
||||
float _e71 = foo.a.x;
|
||||
return _e71;
|
||||
}
|
||||
|
||||
void logical(
|
||||
) {
|
||||
bool neg0_ = !(true);
|
||||
@@ -291,7 +260,6 @@ kernel void main_(
|
||||
metal::float4 _e0 = builtins();
|
||||
metal::float4 _e1 = splat();
|
||||
metal::float3 _e4 = bool_cast(v_f32_one.xyz);
|
||||
float _e5 = constructors();
|
||||
logical();
|
||||
arithmetic();
|
||||
bit();
|
||||
|
||||
100
tests/out/spv/constructors.spvasm
Normal file
100
tests/out/spv/constructors.spvasm
Normal file
@@ -0,0 +1,100 @@
|
||||
; SPIR-V
|
||||
; Version: 1.1
|
||||
; Generator: rspirv
|
||||
; Bound: 90
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %47 "main"
|
||||
OpExecutionMode %47 LocalSize 1 1 1
|
||||
OpMemberDecorate %6 0 Offset 0
|
||||
OpMemberDecorate %6 1 Offset 16
|
||||
OpDecorate %10 ArrayStride 16
|
||||
OpDecorate %15 ArrayStride 32
|
||||
OpDecorate %17 ArrayStride 4
|
||||
%2 = OpTypeVoid
|
||||
%4 = OpTypeFloat 32
|
||||
%3 = OpTypeVector %4 4
|
||||
%5 = OpTypeInt 32 1
|
||||
%6 = OpTypeStruct %3 %5
|
||||
%7 = OpTypeVector %4 3
|
||||
%9 = OpTypeVector %4 2
|
||||
%8 = OpTypeMatrix %9 2
|
||||
%12 = OpTypeInt 32 0
|
||||
%11 = OpConstant %12 1
|
||||
%10 = OpTypeArray %8 %11
|
||||
%13 = OpTypeBool
|
||||
%14 = OpTypeVector %12 2
|
||||
%16 = OpConstant %12 3
|
||||
%15 = OpTypeArray %6 %16
|
||||
%18 = OpConstant %12 4
|
||||
%17 = OpTypeArray %5 %18
|
||||
%19 = OpTypeMatrix %3 4
|
||||
%20 = OpTypeMatrix %7 2
|
||||
%21 = OpConstant %4 0.0
|
||||
%22 = OpConstant %4 1.0
|
||||
%23 = OpConstant %4 2.0
|
||||
%24 = OpConstantComposite %7 %21 %22 %23
|
||||
%25 = OpConstant %4 3.0
|
||||
%26 = OpConstantComposite %9 %21 %22
|
||||
%27 = OpConstantComposite %9 %23 %25
|
||||
%28 = OpConstantComposite %8 %26 %27
|
||||
%29 = OpConstant %5 1
|
||||
%30 = OpConstantComposite %10 %28
|
||||
%31 = OpConstantNull %13
|
||||
%32 = OpConstantNull %5
|
||||
%33 = OpConstantNull %12
|
||||
%34 = OpConstantNull %4
|
||||
%35 = OpConstantNull %14
|
||||
%36 = OpConstantNull %8
|
||||
%37 = OpConstant %5 3
|
||||
%38 = OpConstantNull %15
|
||||
%39 = OpConstantNull %6
|
||||
%40 = OpConstant %5 0
|
||||
%41 = OpConstant %5 2
|
||||
%42 = OpConstantComposite %17 %40 %29 %41 %37
|
||||
%44 = OpTypePointer Function %6
|
||||
%45 = OpConstantNull %6
|
||||
%48 = OpTypeFunction %2
|
||||
%49 = OpConstantNull %13
|
||||
%50 = OpConstantNull %5
|
||||
%51 = OpConstantNull %12
|
||||
%52 = OpConstantNull %4
|
||||
%53 = OpConstantNull %14
|
||||
%54 = OpConstantNull %8
|
||||
%55 = OpConstantNull %15
|
||||
%56 = OpConstantNull %6
|
||||
%57 = OpConstant %12 0
|
||||
%58 = OpConstantNull %13
|
||||
%59 = OpConstantNull %5
|
||||
%60 = OpConstantNull %12
|
||||
%61 = OpConstantNull %4
|
||||
%62 = OpConstantNull %14
|
||||
%63 = OpConstantNull %20
|
||||
%64 = OpConstantNull %14
|
||||
%65 = OpConstantNull %20
|
||||
%47 = OpFunction %2 None %48
|
||||
%46 = OpLabel
|
||||
%43 = OpVariable %44 Function %45
|
||||
OpBranch %66
|
||||
%66 = OpLabel
|
||||
%67 = OpCompositeConstruct %3 %22 %22 %22 %22
|
||||
%68 = OpCompositeConstruct %6 %67 %29
|
||||
OpStore %43 %68
|
||||
%69 = OpCompositeConstruct %9 %22 %21
|
||||
%70 = OpCompositeConstruct %9 %21 %22
|
||||
%71 = OpCompositeConstruct %8 %69 %70
|
||||
%72 = OpCompositeConstruct %3 %22 %21 %21 %21
|
||||
%73 = OpCompositeConstruct %3 %21 %22 %21 %21
|
||||
%74 = OpCompositeConstruct %3 %21 %21 %22 %21
|
||||
%75 = OpCompositeConstruct %3 %21 %21 %21 %22
|
||||
%76 = OpCompositeConstruct %19 %72 %73 %74 %75
|
||||
%77 = OpCompositeConstruct %14 %57 %57
|
||||
%78 = OpCompositeConstruct %9 %21 %21
|
||||
%79 = OpCompositeConstruct %9 %21 %21
|
||||
%80 = OpCompositeConstruct %8 %78 %79
|
||||
%81 = OpCompositeConstruct %17 %40 %29 %41 %37
|
||||
%87 = OpCopyObject %20 %63
|
||||
%89 = OpCopyObject %20 %65
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
File diff suppressed because it is too large
Load Diff
37
tests/out/wgsl/constructors.wgsl
Normal file
37
tests/out/wgsl/constructors.wgsl
Normal file
@@ -0,0 +1,37 @@
|
||||
struct Foo {
|
||||
a: vec4<f32>,
|
||||
b: i32,
|
||||
}
|
||||
|
||||
const const2_: vec3<f32> = vec3<f32>(0.0, 1.0, 2.0);
|
||||
const const3_: mat2x2<f32> = mat2x2<f32>(vec2<f32>(0.0, 1.0), vec2<f32>(2.0, 3.0));
|
||||
const const4_: array<mat2x2<f32>, 1> = array<mat2x2<f32>, 1>(mat2x2<f32>(vec2<f32>(0.0, 1.0), vec2<f32>(2.0, 3.0)));
|
||||
const cz0_: bool = bool();
|
||||
const cz1_: i32 = i32();
|
||||
const cz2_: u32 = u32();
|
||||
const cz3_: f32 = f32();
|
||||
const cz4_: vec2<u32> = vec2<u32>();
|
||||
const cz5_: mat2x2<f32> = mat2x2<f32>();
|
||||
const cz6_: array<Foo, 3> = array<Foo, 3>();
|
||||
const cz7_: Foo = Foo();
|
||||
const cp3_: array<i32, 4> = array<i32, 4>(0, 1, 2, 3);
|
||||
|
||||
@compute @workgroup_size(1, 1, 1)
|
||||
fn main() {
|
||||
var foo: Foo;
|
||||
|
||||
foo = Foo(vec4<f32>(1.0), 1);
|
||||
let m0_ = mat2x2<f32>(vec2<f32>(1.0, 0.0), vec2<f32>(0.0, 1.0));
|
||||
let m1_ = mat4x4<f32>(vec4<f32>(1.0, 0.0, 0.0, 0.0), vec4<f32>(0.0, 1.0, 0.0, 0.0), vec4<f32>(0.0, 0.0, 1.0, 0.0), vec4<f32>(0.0, 0.0, 0.0, 1.0));
|
||||
let cit0_ = vec2<u32>(0u);
|
||||
let cit1_ = mat2x2<f32>(vec2<f32>(0.0), vec2<f32>(0.0));
|
||||
let cit2_ = array<i32, 4>(0, 1, 2, 3);
|
||||
let ic0_ = bool(bool());
|
||||
let ic1_ = i32(i32());
|
||||
let ic2_ = u32(u32());
|
||||
let ic3_ = f32(f32());
|
||||
let ic4_ = vec2<u32>(vec2<u32>());
|
||||
let ic5_ = mat2x3<f32>(mat2x3<f32>());
|
||||
let ic6_ = bitcast<vec2<u32>>(vec2<u32>());
|
||||
let ic7_ = mat2x3<f32>(mat2x3<f32>());
|
||||
}
|
||||
@@ -1,8 +1,3 @@
|
||||
struct Foo {
|
||||
a: vec4<f32>,
|
||||
b: i32,
|
||||
}
|
||||
|
||||
const v_f32_one: vec4<f32> = vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
||||
const v_f32_zero: vec4<f32> = vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
const v_f32_half: vec4<f32> = vec4<f32>(0.5, 0.5, 0.5, 0.5);
|
||||
@@ -45,27 +40,6 @@ fn bool_cast(x: vec3<f32>) -> vec3<f32> {
|
||||
return vec3<f32>(y);
|
||||
}
|
||||
|
||||
fn constructors() -> f32 {
|
||||
var foo: Foo;
|
||||
|
||||
foo = Foo(vec4<f32>(1.0), 1);
|
||||
let m0_ = mat2x2<f32>(vec2<f32>(1.0, 0.0), vec2<f32>(0.0, 1.0));
|
||||
let m1_1 = mat4x4<f32>(vec4<f32>(1.0, 0.0, 0.0, 0.0), vec4<f32>(0.0, 1.0, 0.0, 0.0), vec4<f32>(0.0, 0.0, 1.0, 0.0), vec4<f32>(0.0, 0.0, 0.0, 1.0));
|
||||
let cit0_ = vec2<u32>(0u);
|
||||
let cit1_ = mat2x2<f32>(vec2<f32>(0.0), vec2<f32>(0.0));
|
||||
let cit2_ = array<i32, 4>(0, 1, 2, 3);
|
||||
let ic0_ = bool(bool());
|
||||
let ic1_ = i32(i32());
|
||||
let ic2_ = u32(u32());
|
||||
let ic3_ = f32(f32());
|
||||
let ic4_ = vec2<u32>(vec2<u32>());
|
||||
let ic5_ = mat2x3<f32>(mat2x3<f32>());
|
||||
let ic6_ = bitcast<vec2<u32>>(vec2<u32>());
|
||||
let ic7_ = mat2x3<f32>(mat2x3<f32>());
|
||||
let _e71 = foo.a.x;
|
||||
return _e71;
|
||||
}
|
||||
|
||||
fn logical() {
|
||||
let neg0_ = !(true);
|
||||
let neg1_ = !(vec2<bool>(true));
|
||||
@@ -271,7 +245,6 @@ fn main() {
|
||||
let _e0 = builtins();
|
||||
let _e1 = splat();
|
||||
let _e4 = bool_cast(v_f32_one.xyz);
|
||||
let _e5 = constructors();
|
||||
logical();
|
||||
arithmetic();
|
||||
bit();
|
||||
|
||||
@@ -607,6 +607,10 @@ fn convert_wgsl() {
|
||||
("invariant", Targets::GLSL),
|
||||
("ray-query", Targets::SPIRV | Targets::METAL),
|
||||
("hlsl-keyword", Targets::HLSL),
|
||||
(
|
||||
"constructors",
|
||||
Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL,
|
||||
),
|
||||
];
|
||||
|
||||
for &(name, targets) in inputs.iter() {
|
||||
|
||||
Reference in New Issue
Block a user