tint: Replace all ProgramBuilder float literals with '_f' suffix
Unsuffixed float literals are currently treated as f32, but will shortly become AbstractFloat. To keep tests behaving identically to how they are currently, change all float literals to explicitly use the f32 '_f' suffix. Bug: tint:1504 Change-Id: I2a00725ee1b34a6efbe15ac4ba438c00c4416dd8 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89402 Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
a439e7b89c
commit
0a3cda9911
|
@ -461,7 +461,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
return b->ExprList(0_i, // component
|
return b->ExprList(0_i, // component
|
||||||
"texture", // t
|
"texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f)); // coords
|
b->vec2<f32>(1_f, 2_f)); // coords
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -480,7 +480,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
return b->ExprList(0_i, // component
|
return b->ExprList(0_i, // component
|
||||||
"texture", // t
|
"texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
b->vec2<i32>(3_i, 4_i)); // offset
|
b->vec2<i32>(3_i, 4_i)); // offset
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -500,7 +500,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
return b->ExprList(0_i, // component
|
return b->ExprList(0_i, // component
|
||||||
"texture", // t
|
"texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3_i); // array index
|
3_i); // array index
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -521,7 +521,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
return b->ExprList(0_i, // component
|
return b->ExprList(0_i, // component
|
||||||
"texture", // t
|
"texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3_i, // array_index
|
3_i, // array_index
|
||||||
b->vec2<i32>(4_i, 5_i)); // offset
|
b->vec2<i32>(4_i, 5_i)); // offset
|
||||||
},
|
},
|
||||||
|
@ -541,7 +541,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
return b->ExprList(0_i, // component
|
return b->ExprList(0_i, // component
|
||||||
"texture", // t
|
"texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f)); // coords
|
b->vec3<f32>(1_f, 2_f, 3_f)); // coords
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -560,7 +560,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
return b->ExprList(0_i, // component
|
return b->ExprList(0_i, // component
|
||||||
"texture", // t
|
"texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
4_i); // array_index
|
4_i); // array_index
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -577,7 +577,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f)); // coords
|
b->vec2<f32>(1_f, 2_f)); // coords
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -594,7 +594,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
b->vec2<i32>(3_i, 4_i)); // offset
|
b->vec2<i32>(3_i, 4_i)); // offset
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -612,7 +612,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3_i); // array_index
|
3_i); // array_index
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -631,7 +631,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3_i, // array_index
|
3_i, // array_index
|
||||||
b->vec2<i32>(4_i, 5_i)); // offset
|
b->vec2<i32>(4_i, 5_i)); // offset
|
||||||
},
|
},
|
||||||
|
@ -649,7 +649,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f)); // coords
|
b->vec3<f32>(1_f, 2_f, 3_f)); // coords
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -666,7 +666,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
4_i); // array_index
|
4_i); // array_index
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -684,8 +684,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3.f); // depth_ref
|
3_f); // depth_ref
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -703,8 +703,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3.f, // depth_ref
|
3_f, // depth_ref
|
||||||
b->vec2<i32>(4_i, 5_i)); // offset
|
b->vec2<i32>(4_i, 5_i)); // offset
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -723,9 +723,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3_i, // array_index
|
3_i, // array_index
|
||||||
4.f); // depth_ref
|
4_f); // depth_ref
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -744,9 +744,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3_i, // array_index
|
3_i, // array_index
|
||||||
4.f, // depth_ref
|
4_f, // depth_ref
|
||||||
b->vec2<i32>(5_i, 6_i)); // offset
|
b->vec2<i32>(5_i, 6_i)); // offset
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -764,8 +764,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
4.f); // depth_ref
|
4_f); // depth_ref
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -783,9 +783,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
4_i, // array_index
|
4_i, // array_index
|
||||||
5.f); // depth_ref
|
5_f); // depth_ref
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -951,7 +951,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
1.0f); // coords
|
1_f); // coords
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -967,7 +967,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f)); // coords
|
b->vec2<f32>(1_f, 2_f)); // coords
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -984,7 +984,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
b->vec2<i32>(3_i, 4_i)); // offset
|
b->vec2<i32>(3_i, 4_i)); // offset
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1002,7 +1002,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3_i); // array_index
|
3_i); // array_index
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1021,7 +1021,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3_i, // array_index
|
3_i, // array_index
|
||||||
b->vec2<i32>(4_i, 5_i)); // offset
|
b->vec2<i32>(4_i, 5_i)); // offset
|
||||||
},
|
},
|
||||||
|
@ -1039,7 +1039,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f)); // coords
|
b->vec3<f32>(1_f, 2_f, 3_f)); // coords
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1056,7 +1056,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
b->vec3<i32>(4_i, 5_i, 6_i)); // offset
|
b->vec3<i32>(4_i, 5_i, 6_i)); // offset
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1073,7 +1073,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f)); // coords
|
b->vec3<f32>(1_f, 2_f, 3_f)); // coords
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1090,7 +1090,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
4_i); // array_index
|
4_i); // array_index
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1107,7 +1107,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f)); // coords
|
b->vec2<f32>(1_f, 2_f)); // coords
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1124,7 +1124,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
b->vec2<i32>(3_i, 4_i)); // offset
|
b->vec2<i32>(3_i, 4_i)); // offset
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1142,7 +1142,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3_i); // array_index
|
3_i); // array_index
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1161,7 +1161,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3_i, // array_index
|
3_i, // array_index
|
||||||
b->vec2<i32>(4_i, 5_i)); // offset
|
b->vec2<i32>(4_i, 5_i)); // offset
|
||||||
},
|
},
|
||||||
|
@ -1179,7 +1179,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f)); // coords
|
b->vec3<f32>(1_f, 2_f, 3_f)); // coords
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1196,7 +1196,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
4_i); // array_index
|
4_i); // array_index
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1214,8 +1214,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3.f); // bias
|
3_f); // bias
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1233,8 +1233,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3.f, // bias
|
3_f, // bias
|
||||||
b->vec2<i32>(4_i, 5_i)); // offset
|
b->vec2<i32>(4_i, 5_i)); // offset
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1253,9 +1253,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
4_i, // array_index
|
4_i, // array_index
|
||||||
3.f); // bias
|
3_f); // bias
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1274,9 +1274,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3_i, // array_index
|
3_i, // array_index
|
||||||
4.f, // bias
|
4_f, // bias
|
||||||
b->vec2<i32>(5_i, 6_i)); // offset
|
b->vec2<i32>(5_i, 6_i)); // offset
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1294,8 +1294,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
4.f); // bias
|
4_f); // bias
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1313,8 +1313,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
4.f, // bias
|
4_f, // bias
|
||||||
b->vec3<i32>(5_i, 6_i, 7_i)); // offset
|
b->vec3<i32>(5_i, 6_i, 7_i)); // offset
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1332,8 +1332,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
4.f); // bias
|
4_f); // bias
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1351,9 +1351,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
3_i, // array_index
|
3_i, // array_index
|
||||||
4.f); // bias
|
4_f); // bias
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1370,8 +1370,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3.f); // level
|
3_f); // level
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1389,8 +1389,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3.f, // level
|
3_f, // level
|
||||||
b->vec2<i32>(4_i, 5_i)); // offset
|
b->vec2<i32>(4_i, 5_i)); // offset
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1409,9 +1409,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3_i, // array_index
|
3_i, // array_index
|
||||||
4.f); // level
|
4_f); // level
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1430,9 +1430,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3_i, // array_index
|
3_i, // array_index
|
||||||
4.f, // level
|
4_f, // level
|
||||||
b->vec2<i32>(5_i, 6_i)); // offset
|
b->vec2<i32>(5_i, 6_i)); // offset
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1450,8 +1450,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
4.f); // level
|
4_f); // level
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1469,8 +1469,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
4.f, // level
|
4_f, // level
|
||||||
b->vec3<i32>(5_i, 6_i, 7_i)); // offset
|
b->vec3<i32>(5_i, 6_i, 7_i)); // offset
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1488,8 +1488,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
4.f); // level
|
4_f); // level
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1507,9 +1507,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
4_i, // array_index
|
4_i, // array_index
|
||||||
5.f); // level
|
5_f); // level
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1526,7 +1526,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3_i); // level
|
3_i); // level
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1545,7 +1545,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3_i, // level
|
3_i, // level
|
||||||
b->vec2<i32>(4_i, 5_i)); // offset
|
b->vec2<i32>(4_i, 5_i)); // offset
|
||||||
},
|
},
|
||||||
|
@ -1565,7 +1565,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3_i, // array_index
|
3_i, // array_index
|
||||||
4_i); // level
|
4_i); // level
|
||||||
},
|
},
|
||||||
|
@ -1586,7 +1586,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3_i, // array_index
|
3_i, // array_index
|
||||||
4_i, // level
|
4_i, // level
|
||||||
b->vec2<i32>(5_i, 6_i)); // offset
|
b->vec2<i32>(5_i, 6_i)); // offset
|
||||||
|
@ -1606,7 +1606,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
4_i); // level
|
4_i); // level
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1625,7 +1625,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
4_i, // array_index
|
4_i, // array_index
|
||||||
5_i); // level
|
5_i); // level
|
||||||
},
|
},
|
||||||
|
@ -1643,11 +1643,11 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureSampleGrad",
|
"textureSampleGrad",
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.0f, 2.0f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
b->vec2<f32>(3.0f, 4.0f), // ddx
|
b->vec2<f32>(3_f, 4_f), // ddx
|
||||||
b->vec2<f32>(5.0f, 6.0f)); // ddy
|
b->vec2<f32>(5_f, 6_f)); // ddy
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1666,9 +1666,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
b->vec2<f32>(3.f, 4.f), // ddx
|
b->vec2<f32>(3_f, 4_f), // ddx
|
||||||
b->vec2<f32>(5.f, 6.f), // ddy
|
b->vec2<f32>(5_f, 6_f), // ddy
|
||||||
b->vec2<i32>(7_i, 7_i)); // offset
|
b->vec2<i32>(7_i, 7_i)); // offset
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1688,10 +1688,10 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3_i, // array_index
|
3_i, // array_index
|
||||||
b->vec2<f32>(4.f, 5.f), // ddx
|
b->vec2<f32>(4_f, 5_f), // ddx
|
||||||
b->vec2<f32>(6.f, 7.f)); // ddy
|
b->vec2<f32>(6_f, 7_f)); // ddy
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1711,10 +1711,10 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3_i, // array_index
|
3_i, // array_index
|
||||||
b->vec2<f32>(4.f, 5.f), // ddx
|
b->vec2<f32>(4_f, 5_f), // ddx
|
||||||
b->vec2<f32>(6.f, 7.f), // ddy
|
b->vec2<f32>(6_f, 7_f), // ddy
|
||||||
b->vec2<i32>(6_i, 7_i)); // offset
|
b->vec2<i32>(6_i, 7_i)); // offset
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1733,9 +1733,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
b->vec3<f32>(4.f, 5.f, 6.f), // ddx
|
b->vec3<f32>(4_f, 5_f, 6_f), // ddx
|
||||||
b->vec3<f32>(7.f, 8.f, 9.f)); // ddy
|
b->vec3<f32>(7_f, 8_f, 9_f)); // ddy
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1754,9 +1754,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
b->vec3<f32>(4.f, 5.f, 6.f), // ddx
|
b->vec3<f32>(4_f, 5_f, 6_f), // ddx
|
||||||
b->vec3<f32>(7.f, 8.f, 9.f), // ddy
|
b->vec3<f32>(7_f, 8_f, 9_f), // ddy
|
||||||
b->vec3<i32>(0_i, 1_i, 2_i)); // offset
|
b->vec3<i32>(0_i, 1_i, 2_i)); // offset
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1775,9 +1775,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
b->vec3<f32>(4.f, 5.f, 6.f), // ddx
|
b->vec3<f32>(4_f, 5_f, 6_f), // ddx
|
||||||
b->vec3<f32>(7.f, 8.f, 9.f)); // ddy
|
b->vec3<f32>(7_f, 8_f, 9_f)); // ddy
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1796,10 +1796,10 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
4_i, // array_index
|
4_i, // array_index
|
||||||
b->vec3<f32>(5.f, 6.f, 7.f), // ddx
|
b->vec3<f32>(5_f, 6_f, 7_f), // ddx
|
||||||
b->vec3<f32>(8.f, 9.f, 10.f)); // ddy
|
b->vec3<f32>(8_f, 9_f, 10_f)); // ddy
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1816,8 +1816,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3.f); // depth_ref
|
3_f); // depth_ref
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1835,8 +1835,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
3.f, // depth_ref
|
3_f, // depth_ref
|
||||||
b->vec2<i32>(4_i, 5_i)); // offset
|
b->vec2<i32>(4_i, 5_i)); // offset
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1855,9 +1855,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
4_i, // array_index
|
4_i, // array_index
|
||||||
3.f); // depth_ref
|
3_f); // depth_ref
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1876,9 +1876,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec2<f32>(1.f, 2.f), // coords
|
b->vec2<f32>(1_f, 2_f), // coords
|
||||||
4_i, // array_index
|
4_i, // array_index
|
||||||
3.f, // depth_ref
|
3_f, // depth_ref
|
||||||
b->vec2<i32>(5_i, 6_i)); // offset
|
b->vec2<i32>(5_i, 6_i)); // offset
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1896,8 +1896,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
4.f); // depth_ref
|
4_f); // depth_ref
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1915,9 +1915,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
"sampler", // s
|
"sampler", // s
|
||||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
b->vec3<f32>(1_f, 2_f, 3_f), // coords
|
||||||
4_i, // array_index
|
4_i, // array_index
|
||||||
5.f); // depth_ref
|
5_f); // depth_ref
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -2196,7 +2196,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
1_i, // coords
|
1_i, // coords
|
||||||
b->vec4<f32>(2.f, 3.f, 4.f, 5.f)); // value
|
b->vec4<f32>(2_f, 3_f, 4_f, 5_f)); // value
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -2212,7 +2212,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
b->vec2<i32>(1_i, 2_i), // coords
|
b->vec2<i32>(1_i, 2_i), // coords
|
||||||
b->vec4<f32>(3.f, 4.f, 5.f, 6.f)); // value
|
b->vec4<f32>(3_f, 4_f, 5_f, 6_f)); // value
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -2230,7 +2230,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
b->vec2<i32>(1_i, 2_i), // coords
|
b->vec2<i32>(1_i, 2_i), // coords
|
||||||
3_i, // array_index
|
3_i, // array_index
|
||||||
b->vec4<f32>(4.f, 5.f, 6.f, 7.f)); // value
|
b->vec4<f32>(4_f, 5_f, 6_f, 7_f)); // value
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -2246,7 +2246,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
[](ProgramBuilder* b) {
|
[](ProgramBuilder* b) {
|
||||||
return b->ExprList("texture", // t
|
return b->ExprList("texture", // t
|
||||||
b->vec3<i32>(1_i, 2_i, 3_i), // coords
|
b->vec3<i32>(1_i, 2_i, 3_i), // coords
|
||||||
b->vec4<f32>(4.f, 5.f, 6.f, 7.f)); // value
|
b->vec4<f32>(4_f, 5_f, 6_f, 7_f)); // value
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
#include "src/tint/ast/id_attribute.h"
|
#include "src/tint/ast/id_attribute.h"
|
||||||
#include "src/tint/ast/test_helper.h"
|
#include "src/tint/ast/test_helper.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -84,7 +86,7 @@ TEST_F(VariableTest, Assert_DifferentProgramID_Constructor) {
|
||||||
{
|
{
|
||||||
ProgramBuilder b1;
|
ProgramBuilder b1;
|
||||||
ProgramBuilder b2;
|
ProgramBuilder b2;
|
||||||
b1.Var("x", b1.ty.f32(), StorageClass::kNone, b2.Expr(1.2f));
|
b1.Var("x", b1.ty.f32(), StorageClass::kNone, b2.Expr(1.2_f));
|
||||||
},
|
},
|
||||||
"internal compiler error");
|
"internal compiler error");
|
||||||
}
|
}
|
||||||
|
|
|
@ -623,7 +623,7 @@ TEST_F(InspectorGetEntryPointTest, OverridableConstantTypes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetEntryPointTest, OverridableConstantInitialized) {
|
TEST_F(InspectorGetEntryPointTest, OverridableConstantInitialized) {
|
||||||
AddOverridableConstantWithoutID("foo", ty.f32(), Expr(0.0f));
|
AddOverridableConstantWithoutID("foo", ty.f32(), Expr(0_f));
|
||||||
MakePlainGlobalReferenceBodyFunction("ep_func", "foo", ty.f32(),
|
MakePlainGlobalReferenceBodyFunction("ep_func", "foo", ty.f32(),
|
||||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||||
|
|
||||||
|
@ -1013,9 +1013,9 @@ TEST_F(InspectorGetConstantIDsTest, I32) {
|
||||||
|
|
||||||
TEST_F(InspectorGetConstantIDsTest, Float) {
|
TEST_F(InspectorGetConstantIDsTest, Float) {
|
||||||
AddOverridableConstantWithID("foo", 1, ty.f32(), nullptr);
|
AddOverridableConstantWithID("foo", 1, ty.f32(), nullptr);
|
||||||
AddOverridableConstantWithID("bar", 20, ty.f32(), Expr(0.0f));
|
AddOverridableConstantWithID("bar", 20, ty.f32(), Expr(0_f));
|
||||||
AddOverridableConstantWithID("baz", 300, ty.f32(), Expr(-10.0f));
|
AddOverridableConstantWithID("baz", 300, ty.f32(), Expr(-10_f));
|
||||||
AddOverridableConstantWithID("x", 4000, ty.f32(), Expr(15.0f));
|
AddOverridableConstantWithID("x", 4000, ty.f32(), Expr(15_f));
|
||||||
|
|
||||||
Inspector& inspector = Build();
|
Inspector& inspector = Build();
|
||||||
|
|
||||||
|
|
|
@ -989,21 +989,6 @@ class ProgramBuilder {
|
||||||
return create<ast::BoolLiteralExpression>(value);
|
return create<ast::BoolLiteralExpression>(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @param source the source information
|
|
||||||
/// @param value the float value
|
|
||||||
/// @return a unsuffixed FloatLiteralExpression for the float value
|
|
||||||
const ast::FloatLiteralExpression* Expr(const Source& source, float value) {
|
|
||||||
return create<ast::FloatLiteralExpression>(source, static_cast<double>(value),
|
|
||||||
ast::FloatLiteralExpression::Suffix::kNone);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @param value the float value
|
|
||||||
/// @return a unsuffixed FloatLiteralExpression for the float value
|
|
||||||
const ast::FloatLiteralExpression* Expr(float value) {
|
|
||||||
return create<ast::FloatLiteralExpression>(static_cast<double>(value),
|
|
||||||
ast::FloatLiteralExpression::Suffix::kNone);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @param source the source information
|
/// @param source the source information
|
||||||
/// @param value the float value
|
/// @param value the float value
|
||||||
/// @return a 'f'-suffixed FloatLiteralExpression for the f32 value
|
/// @return a 'f'-suffixed FloatLiteralExpression for the f32 value
|
||||||
|
|
|
@ -137,6 +137,8 @@
|
||||||
// constructs
|
// constructs
|
||||||
//
|
//
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::reader::spirv {
|
namespace tint::reader::spirv {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -3929,7 +3931,7 @@ TypedExpression FunctionEmitter::EmitGlslStd450ExtInst(const spvtools::opt::Inst
|
||||||
case GLSLstd450Normalize:
|
case GLSLstd450Normalize:
|
||||||
// WGSL does not have scalar form of the normalize builtin.
|
// WGSL does not have scalar form of the normalize builtin.
|
||||||
// The answer would be 1 anyway, so return that directly.
|
// The answer would be 1 anyway, so return that directly.
|
||||||
return {ty_.F32(), builder_.Expr(1.0f)};
|
return {ty_.F32(), builder_.Expr(1_f)};
|
||||||
|
|
||||||
case GLSLstd450FaceForward: {
|
case GLSLstd450FaceForward: {
|
||||||
// If dot(Nref, Incident) < 0, the result is Normal, otherwise -Normal.
|
// If dot(Nref, Incident) < 0, the result is Normal, otherwise -Normal.
|
||||||
|
@ -3952,7 +3954,7 @@ TypedExpression FunctionEmitter::EmitGlslStd450ExtInst(const spvtools::opt::Inst
|
||||||
create<ast::BinaryExpression>(
|
create<ast::BinaryExpression>(
|
||||||
Source{}, ast::BinaryOp::kLessThan,
|
Source{}, ast::BinaryOp::kLessThan,
|
||||||
builder_.Mul({}, incident.expr, nref.expr),
|
builder_.Mul({}, incident.expr, nref.expr),
|
||||||
builder_.Expr(0.0f))})};
|
builder_.Expr(0_f))})};
|
||||||
}
|
}
|
||||||
|
|
||||||
case GLSLstd450Reflect: {
|
case GLSLstd450Reflect: {
|
||||||
|
@ -3961,12 +3963,12 @@ TypedExpression FunctionEmitter::EmitGlslStd450ExtInst(const spvtools::opt::Inst
|
||||||
auto normal = MakeOperand(inst, 3);
|
auto normal = MakeOperand(inst, 3);
|
||||||
TINT_ASSERT(Reader, incident.type->Is<F32>());
|
TINT_ASSERT(Reader, incident.type->Is<F32>());
|
||||||
TINT_ASSERT(Reader, normal.type->Is<F32>());
|
TINT_ASSERT(Reader, normal.type->Is<F32>());
|
||||||
return {ty_.F32(),
|
return {
|
||||||
builder_.Sub(
|
ty_.F32(),
|
||||||
incident.expr,
|
builder_.Sub(
|
||||||
builder_.Mul(2.0f,
|
incident.expr,
|
||||||
builder_.Mul(normal.expr,
|
builder_.Mul(2_f, builder_.Mul(normal.expr,
|
||||||
builder_.Mul(normal.expr, incident.expr))))};
|
builder_.Mul(normal.expr, incident.expr))))};
|
||||||
}
|
}
|
||||||
|
|
||||||
case GLSLstd450Refract: {
|
case GLSLstd450Refract: {
|
||||||
|
@ -3987,8 +3989,8 @@ TypedExpression FunctionEmitter::EmitGlslStd450ExtInst(const spvtools::opt::Inst
|
||||||
builder_.Call(
|
builder_.Call(
|
||||||
Source{}, "refract",
|
Source{}, "refract",
|
||||||
ast::ExpressionList{
|
ast::ExpressionList{
|
||||||
builder_.vec2<tint::f32>(incident.expr, 0.0f),
|
builder_.vec2<tint::f32>(incident.expr, 0_f),
|
||||||
builder_.vec2<tint::f32>(normal.expr, 0.0f), eta.expr}),
|
builder_.vec2<tint::f32>(normal.expr, 0_f), eta.expr}),
|
||||||
"x")};
|
"x")};
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -27,7 +27,7 @@ using ResolverIndexAccessorTest = ResolverTest;
|
||||||
|
|
||||||
TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic_F32) {
|
TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic_F32) {
|
||||||
Global("my_var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
|
Global("my_var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
|
||||||
auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, 1.0f));
|
auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, 1_f));
|
||||||
WrapInFunction(acc);
|
WrapInFunction(acc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -116,7 +116,7 @@ TEST_F(ResolverIndexAccessorTest, Matrix_BothDimensions) {
|
||||||
|
|
||||||
TEST_F(ResolverIndexAccessorTest, Vector_F32) {
|
TEST_F(ResolverIndexAccessorTest, Vector_F32) {
|
||||||
Global("my_var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
|
Global("my_var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
|
||||||
auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, 2.0f));
|
auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, 2_f));
|
||||||
WrapInFunction(acc);
|
WrapInFunction(acc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -224,7 +224,7 @@ TEST_F(ResolverIndexAccessorTest, Array_Literal_F32) {
|
||||||
// let a : array<f32, 3>;
|
// let a : array<f32, 3>;
|
||||||
// var f : f32 = a[2.0f];
|
// var f : f32 = a[2.0f];
|
||||||
auto* a = Let("a", ty.array<f32, 3>(), array<f32, 3>());
|
auto* a = Let("a", ty.array<f32, 3>(), array<f32, 3>());
|
||||||
auto* f = Var("a_2", ty.f32(), IndexAccessor("a", Expr(Source{{12, 34}}, 2.0f)));
|
auto* f = Var("a_2", ty.f32(), IndexAccessor("a", Expr(Source{{12, 34}}, 2_f)));
|
||||||
Func("my_func", ast::VariableList{}, ty.void_(),
|
Func("my_func", ast::VariableList{}, ty.void_(),
|
||||||
{
|
{
|
||||||
Decl(a),
|
Decl(a),
|
||||||
|
|
|
@ -52,7 +52,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignIncompatibleTypes) {
|
||||||
|
|
||||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
||||||
|
|
||||||
auto* assign = Assign(Source{{12, 34}}, "a", 2.3f);
|
auto* assign = Assign(Source{{12, 34}}, "a", 2.3_f);
|
||||||
WrapInFunction(var, assign);
|
WrapInFunction(var, assign);
|
||||||
|
|
||||||
ASSERT_FALSE(r()->Resolve());
|
ASSERT_FALSE(r()->Resolve());
|
||||||
|
@ -118,7 +118,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignIncompatibleTypesInBlockStatement
|
||||||
// }
|
// }
|
||||||
|
|
||||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
||||||
WrapInFunction(var, Assign(Source{{12, 34}}, "a", 2.3f));
|
WrapInFunction(var, Assign(Source{{12, 34}}, "a", 2.3_f));
|
||||||
|
|
||||||
ASSERT_FALSE(r()->Resolve());
|
ASSERT_FALSE(r()->Resolve());
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignIncompatibleTypesInNestedBlockSta
|
||||||
// }
|
// }
|
||||||
|
|
||||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
||||||
auto* inner_block = Block(Decl(var), Assign(Source{{12, 34}}, "a", 2.3f));
|
auto* inner_block = Block(Decl(var), Assign(Source{{12, 34}}, "a", 2.3_f));
|
||||||
auto* outer_block = Block(inner_block);
|
auto* outer_block = Block(inner_block);
|
||||||
WrapInFunction(outer_block);
|
WrapInFunction(outer_block);
|
||||||
|
|
||||||
|
@ -353,7 +353,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_Pass) {
|
||||||
|
|
||||||
WrapInFunction(Assign(Phony(), 1_i), //
|
WrapInFunction(Assign(Phony(), 1_i), //
|
||||||
Assign(Phony(), 2_u), //
|
Assign(Phony(), 2_u), //
|
||||||
Assign(Phony(), 3.f), //
|
Assign(Phony(), 3_f), //
|
||||||
Assign(Phony(), vec2<bool>()), //
|
Assign(Phony(), vec2<bool>()), //
|
||||||
Assign(Phony(), "tex"), //
|
Assign(Phony(), "tex"), //
|
||||||
Assign(Phony(), "smp"), //
|
Assign(Phony(), "smp"), //
|
||||||
|
|
|
@ -161,7 +161,7 @@ using FunctionReturnTypeAttributeTest = TestWithParams;
|
||||||
TEST_P(FunctionReturnTypeAttributeTest, IsValid) {
|
TEST_P(FunctionReturnTypeAttributeTest, IsValid) {
|
||||||
auto& params = GetParam();
|
auto& params = GetParam();
|
||||||
|
|
||||||
Func("main", ast::VariableList{}, ty.f32(), ast::StatementList{Return(1.f)}, {},
|
Func("main", ast::VariableList{}, ty.f32(), ast::StatementList{Return(1_f)}, {},
|
||||||
createAttributes({}, *this, params.kind));
|
createAttributes({}, *this, params.kind));
|
||||||
|
|
||||||
if (params.should_pass) {
|
if (params.should_pass) {
|
||||||
|
@ -316,7 +316,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
|
||||||
using ComputeShaderReturnTypeAttributeTest = TestWithParams;
|
using ComputeShaderReturnTypeAttributeTest = TestWithParams;
|
||||||
TEST_P(ComputeShaderReturnTypeAttributeTest, IsValid) {
|
TEST_P(ComputeShaderReturnTypeAttributeTest, IsValid) {
|
||||||
auto& params = GetParam();
|
auto& params = GetParam();
|
||||||
Func("main", ast::VariableList{}, ty.vec4<f32>(), {Return(Construct(ty.vec4<f32>(), 1.f))},
|
Func("main", ast::VariableList{}, ty.vec4<f32>(), {Return(Construct(ty.vec4<f32>(), 1_f))},
|
||||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)},
|
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)},
|
||||||
createAttributes(Source{{12, 34}}, *this, params.kind));
|
createAttributes(Source{{12, 34}}, *this, params.kind));
|
||||||
|
|
||||||
|
@ -450,7 +450,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
|
||||||
|
|
||||||
using EntryPointParameterAttributeTest = TestWithParams;
|
using EntryPointParameterAttributeTest = TestWithParams;
|
||||||
TEST_F(EntryPointParameterAttributeTest, DuplicateAttribute) {
|
TEST_F(EntryPointParameterAttributeTest, DuplicateAttribute) {
|
||||||
Func("main", ast::VariableList{}, ty.f32(), ast::StatementList{Return(1.f)},
|
Func("main", ast::VariableList{}, ty.f32(), ast::StatementList{Return(1_f)},
|
||||||
{Stage(ast::PipelineStage::kFragment)},
|
{Stage(ast::PipelineStage::kFragment)},
|
||||||
{
|
{
|
||||||
Location(Source{{12, 34}}, 2),
|
Location(Source{{12, 34}}, 2),
|
||||||
|
@ -478,7 +478,7 @@ TEST_F(EntryPointParameterAttributeTest, DuplicateInternalAttribute) {
|
||||||
|
|
||||||
using EntryPointReturnTypeAttributeTest = ResolverTest;
|
using EntryPointReturnTypeAttributeTest = ResolverTest;
|
||||||
TEST_F(EntryPointReturnTypeAttributeTest, DuplicateAttribute) {
|
TEST_F(EntryPointReturnTypeAttributeTest, DuplicateAttribute) {
|
||||||
Func("main", ast::VariableList{}, ty.f32(), ast::StatementList{Return(1.f)},
|
Func("main", ast::VariableList{}, ty.f32(), ast::StatementList{Return(1_f)},
|
||||||
ast::AttributeList{Stage(ast::PipelineStage::kFragment)},
|
ast::AttributeList{Stage(ast::PipelineStage::kFragment)},
|
||||||
ast::AttributeList{
|
ast::AttributeList{
|
||||||
Location(Source{{12, 34}}, 2),
|
Location(Source{{12, 34}}, 2),
|
||||||
|
@ -721,7 +721,8 @@ using ConstantAttributeTest = TestWithParams;
|
||||||
TEST_P(ConstantAttributeTest, IsValid) {
|
TEST_P(ConstantAttributeTest, IsValid) {
|
||||||
auto& params = GetParam();
|
auto& params = GetParam();
|
||||||
|
|
||||||
GlobalConst("a", ty.f32(), Expr(1.23f), createAttributes(Source{{12, 34}}, *this, params.kind));
|
GlobalConst("a", ty.f32(), Expr(1.23_f),
|
||||||
|
createAttributes(Source{{12, 34}}, *this, params.kind));
|
||||||
|
|
||||||
WrapInFunction();
|
WrapInFunction();
|
||||||
|
|
||||||
|
@ -750,7 +751,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
|
||||||
TestParams{AttributeKind::kBindingAndGroup, false}));
|
TestParams{AttributeKind::kBindingAndGroup, false}));
|
||||||
|
|
||||||
TEST_F(ConstantAttributeTest, DuplicateAttribute) {
|
TEST_F(ConstantAttributeTest, DuplicateAttribute) {
|
||||||
GlobalConst("a", ty.f32(), Expr(1.23f),
|
GlobalConst("a", ty.f32(), Expr(1.23_f),
|
||||||
ast::AttributeList{
|
ast::AttributeList{
|
||||||
create<ast::IdAttribute>(Source{{12, 34}}, 0),
|
create<ast::IdAttribute>(Source{{12, 34}}, 0),
|
||||||
create<ast::IdAttribute>(Source{{56, 78}}, 1),
|
create<ast::IdAttribute>(Source{{56, 78}}, 1),
|
||||||
|
|
|
@ -287,7 +287,7 @@ TEST_F(ResolverBuiltinTest, Dot_Vec4) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Dot_Error_Scalar) {
|
TEST_F(ResolverBuiltinTest, Dot_Error_Scalar) {
|
||||||
auto* expr = Call("dot", 1.0f, 1.0f);
|
auto* expr = Call("dot", 1_f, 1_f);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -349,8 +349,8 @@ TEST_F(ResolverBuiltinTest, Select_Error_SelectorInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Select_Error_Matrix) {
|
TEST_F(ResolverBuiltinTest, Select_Error_Matrix) {
|
||||||
auto* expr = Call("select", mat2x2<f32>(vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f)),
|
auto* expr = Call("select", mat2x2<f32>(vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f)),
|
||||||
mat2x2<f32>(vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f)), Expr(true));
|
mat2x2<f32>(vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f)), Expr(true));
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -366,7 +366,7 @@ TEST_F(ResolverBuiltinTest, Select_Error_Matrix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Select_Error_MismatchTypes) {
|
TEST_F(ResolverBuiltinTest, Select_Error_MismatchTypes) {
|
||||||
auto* expr = Call("select", 1.0f, vec2<f32>(2.0f, 3.0f), Expr(true));
|
auto* expr = Call("select", 1_f, vec2<f32>(2_f, 3_f), Expr(true));
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -382,7 +382,7 @@ TEST_F(ResolverBuiltinTest, Select_Error_MismatchTypes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Select_Error_MismatchVectorSize) {
|
TEST_F(ResolverBuiltinTest, Select_Error_MismatchVectorSize) {
|
||||||
auto* expr = Call("select", vec2<f32>(1.0f, 2.0f), vec3<f32>(3.0f, 4.0f, 5.0f), Expr(true));
|
auto* expr = Call("select", vec2<f32>(1_f, 2_f), vec3<f32>(3_f, 4_f, 5_f), Expr(true));
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -422,7 +422,7 @@ TEST_P(ResolverBuiltinTest_Barrier, InferType) {
|
||||||
TEST_P(ResolverBuiltinTest_Barrier, Error_TooManyParams) {
|
TEST_P(ResolverBuiltinTest_Barrier, Error_TooManyParams) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* call = Call(param.name, vec4<f32>(1.f, 2.f, 3.f, 4.f), 1.0f);
|
auto* call = Call(param.name, vec4<f32>(1_f, 2_f, 3_f, 4_f), 1_f);
|
||||||
WrapInFunction(CallStmt(call));
|
WrapInFunction(CallStmt(call));
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -443,8 +443,8 @@ TEST_P(ResolverBuiltinTest_DataPacking, InferType) {
|
||||||
bool pack4 =
|
bool pack4 =
|
||||||
param.builtin == BuiltinType::kPack4x8snorm || param.builtin == BuiltinType::kPack4x8unorm;
|
param.builtin == BuiltinType::kPack4x8snorm || param.builtin == BuiltinType::kPack4x8unorm;
|
||||||
|
|
||||||
auto* call = pack4 ? Call(param.name, vec4<f32>(1.f, 2.f, 3.f, 4.f))
|
auto* call = pack4 ? Call(param.name, vec4<f32>(1_f, 2_f, 3_f, 4_f))
|
||||||
: Call(param.name, vec2<f32>(1.f, 2.f));
|
: Call(param.name, vec2<f32>(1_f, 2_f));
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -484,8 +484,8 @@ TEST_P(ResolverBuiltinTest_DataPacking, Error_TooManyParams) {
|
||||||
bool pack4 =
|
bool pack4 =
|
||||||
param.builtin == BuiltinType::kPack4x8snorm || param.builtin == BuiltinType::kPack4x8unorm;
|
param.builtin == BuiltinType::kPack4x8snorm || param.builtin == BuiltinType::kPack4x8unorm;
|
||||||
|
|
||||||
auto* call = pack4 ? Call(param.name, vec4<f32>(1.f, 2.f, 3.f, 4.f), 1.0f)
|
auto* call = pack4 ? Call(param.name, vec4<f32>(1_f, 2_f, 3_f, 4_f), 1_f)
|
||||||
: Call(param.name, vec2<f32>(1.f, 2.f), 1.0f);
|
: Call(param.name, vec2<f32>(1_f, 2_f), 1_f);
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -535,7 +535,7 @@ using ResolverBuiltinTest_SingleParam = ResolverTestWithParam<BuiltinData>;
|
||||||
TEST_P(ResolverBuiltinTest_SingleParam, Scalar) {
|
TEST_P(ResolverBuiltinTest_SingleParam, Scalar) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* call = Call(param.name, 1.f);
|
auto* call = Call(param.name, 1_f);
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -547,7 +547,7 @@ TEST_P(ResolverBuiltinTest_SingleParam, Scalar) {
|
||||||
TEST_P(ResolverBuiltinTest_SingleParam, Vector) {
|
TEST_P(ResolverBuiltinTest_SingleParam, Vector) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* call = Call(param.name, vec3<f32>(1.0f, 1.0f, 3.0f));
|
auto* call = Call(param.name, vec3<f32>(1_f, 1_f, 3_f));
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -647,7 +647,7 @@ TEST_F(ResolverBuiltinDataTest, ArrayLength_Error_ArraySized) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinDataTest, Normalize_Vector) {
|
TEST_F(ResolverBuiltinDataTest, Normalize_Vector) {
|
||||||
auto* call = Call("normalize", vec3<f32>(1.0f, 1.0f, 3.0f));
|
auto* call = Call("normalize", vec3<f32>(1_f, 1_f, 3_f));
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -671,7 +671,7 @@ TEST_F(ResolverBuiltinDataTest, Normalize_Error_NoParams) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinDataTest, FrexpScalar) {
|
TEST_F(ResolverBuiltinDataTest, FrexpScalar) {
|
||||||
auto* call = Call("frexp", 1.0f);
|
auto* call = Call("frexp", 1_f);
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -750,7 +750,7 @@ TEST_F(ResolverBuiltinDataTest, Frexp_Error_FirstParamInt) {
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinDataTest, Frexp_Error_SecondParamFloatPtr) {
|
TEST_F(ResolverBuiltinDataTest, Frexp_Error_SecondParamFloatPtr) {
|
||||||
Global("v", ty.f32(), ast::StorageClass::kWorkgroup);
|
Global("v", ty.f32(), ast::StorageClass::kWorkgroup);
|
||||||
auto* call = Call("frexp", 1.0f, AddressOf("v"));
|
auto* call = Call("frexp", 1_f, AddressOf("v"));
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -765,7 +765,7 @@ TEST_F(ResolverBuiltinDataTest, Frexp_Error_SecondParamFloatPtr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinDataTest, Frexp_Error_SecondParamNotAPointer) {
|
TEST_F(ResolverBuiltinDataTest, Frexp_Error_SecondParamNotAPointer) {
|
||||||
auto* call = Call("frexp", 1.0f, 1_i);
|
auto* call = Call("frexp", 1_f, 1_i);
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -780,7 +780,7 @@ TEST_F(ResolverBuiltinDataTest, Frexp_Error_SecondParamNotAPointer) {
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinDataTest, Frexp_Error_VectorSizesDontMatch) {
|
TEST_F(ResolverBuiltinDataTest, Frexp_Error_VectorSizesDontMatch) {
|
||||||
Global("v", ty.vec4<i32>(), ast::StorageClass::kWorkgroup);
|
Global("v", ty.vec4<i32>(), ast::StorageClass::kWorkgroup);
|
||||||
auto* call = Call("frexp", vec2<f32>(1.0f, 2.0f), AddressOf("v"));
|
auto* call = Call("frexp", vec2<f32>(1_f, 2_f), AddressOf("v"));
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -795,7 +795,7 @@ TEST_F(ResolverBuiltinDataTest, Frexp_Error_VectorSizesDontMatch) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinDataTest, ModfScalar) {
|
TEST_F(ResolverBuiltinDataTest, ModfScalar) {
|
||||||
auto* call = Call("modf", 1.0f);
|
auto* call = Call("modf", 1_f);
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -874,7 +874,7 @@ TEST_F(ResolverBuiltinDataTest, Modf_Error_FirstParamInt) {
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinDataTest, Modf_Error_SecondParamIntPtr) {
|
TEST_F(ResolverBuiltinDataTest, Modf_Error_SecondParamIntPtr) {
|
||||||
Global("whole", ty.i32(), ast::StorageClass::kWorkgroup);
|
Global("whole", ty.i32(), ast::StorageClass::kWorkgroup);
|
||||||
auto* call = Call("modf", 1.0f, AddressOf("whole"));
|
auto* call = Call("modf", 1_f, AddressOf("whole"));
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -889,7 +889,7 @@ TEST_F(ResolverBuiltinDataTest, Modf_Error_SecondParamIntPtr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinDataTest, Modf_Error_SecondParamNotAPointer) {
|
TEST_F(ResolverBuiltinDataTest, Modf_Error_SecondParamNotAPointer) {
|
||||||
auto* call = Call("modf", 1.0f, 1.0f);
|
auto* call = Call("modf", 1_f, 1_f);
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -904,7 +904,7 @@ TEST_F(ResolverBuiltinDataTest, Modf_Error_SecondParamNotAPointer) {
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinDataTest, Modf_Error_VectorSizesDontMatch) {
|
TEST_F(ResolverBuiltinDataTest, Modf_Error_VectorSizesDontMatch) {
|
||||||
Global("whole", ty.vec4<f32>(), ast::StorageClass::kWorkgroup);
|
Global("whole", ty.vec4<f32>(), ast::StorageClass::kWorkgroup);
|
||||||
auto* call = Call("modf", vec2<f32>(1.0f, 2.0f), AddressOf("whole"));
|
auto* call = Call("modf", vec2<f32>(1_f, 2_f), AddressOf("whole"));
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -922,7 +922,7 @@ using ResolverBuiltinTest_SingleParam_FloatOrInt = ResolverTestWithParam<Builtin
|
||||||
TEST_P(ResolverBuiltinTest_SingleParam_FloatOrInt, Float_Scalar) {
|
TEST_P(ResolverBuiltinTest_SingleParam_FloatOrInt, Float_Scalar) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* call = Call(param.name, 1.f);
|
auto* call = Call(param.name, 1_f);
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -934,7 +934,7 @@ TEST_P(ResolverBuiltinTest_SingleParam_FloatOrInt, Float_Scalar) {
|
||||||
TEST_P(ResolverBuiltinTest_SingleParam_FloatOrInt, Float_Vector) {
|
TEST_P(ResolverBuiltinTest_SingleParam_FloatOrInt, Float_Vector) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* call = Call(param.name, vec3<f32>(1.0f, 1.0f, 3.0f));
|
auto* call = Call(param.name, vec3<f32>(1_f, 1_f, 3_f));
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1015,7 +1015,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverTest,
|
||||||
testing::Values(BuiltinData{"abs", BuiltinType::kAbs}));
|
testing::Values(BuiltinData{"abs", BuiltinType::kAbs}));
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Length_Scalar) {
|
TEST_F(ResolverBuiltinTest, Length_Scalar) {
|
||||||
auto* call = Call("length", 1.f);
|
auto* call = Call("length", 1_f);
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1025,7 +1025,7 @@ TEST_F(ResolverBuiltinTest, Length_Scalar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Length_FloatVector) {
|
TEST_F(ResolverBuiltinTest, Length_FloatVector) {
|
||||||
auto* call = Call("length", vec3<f32>(1.0f, 1.0f, 3.0f));
|
auto* call = Call("length", vec3<f32>(1_f, 1_f, 3_f));
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1038,7 +1038,7 @@ using ResolverBuiltinTest_TwoParam = ResolverTestWithParam<BuiltinData>;
|
||||||
TEST_P(ResolverBuiltinTest_TwoParam, Scalar) {
|
TEST_P(ResolverBuiltinTest_TwoParam, Scalar) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* call = Call(param.name, 1.f, 1.f);
|
auto* call = Call(param.name, 1_f, 1_f);
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1050,7 +1050,7 @@ TEST_P(ResolverBuiltinTest_TwoParam, Scalar) {
|
||||||
TEST_P(ResolverBuiltinTest_TwoParam, Vector) {
|
TEST_P(ResolverBuiltinTest_TwoParam, Vector) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* call = Call(param.name, vec3<f32>(1.0f, 1.0f, 3.0f), vec3<f32>(1.0f, 1.0f, 3.0f));
|
auto* call = Call(param.name, vec3<f32>(1_f, 1_f, 3_f), vec3<f32>(1_f, 1_f, 3_f));
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1097,7 +1097,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverTest,
|
||||||
BuiltinData{"step", BuiltinType::kStep}));
|
BuiltinData{"step", BuiltinType::kStep}));
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Distance_Scalar) {
|
TEST_F(ResolverBuiltinTest, Distance_Scalar) {
|
||||||
auto* call = Call("distance", 1.f, 1.f);
|
auto* call = Call("distance", 1_f, 1_f);
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1107,7 +1107,7 @@ TEST_F(ResolverBuiltinTest, Distance_Scalar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Distance_Vector) {
|
TEST_F(ResolverBuiltinTest, Distance_Vector) {
|
||||||
auto* call = Call("distance", vec3<f32>(1.0f, 1.0f, 3.0f), vec3<f32>(1.0f, 1.0f, 3.0f));
|
auto* call = Call("distance", vec3<f32>(1_f, 1_f, 3_f), vec3<f32>(1_f, 1_f, 3_f));
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1117,7 +1117,7 @@ TEST_F(ResolverBuiltinTest, Distance_Vector) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Cross) {
|
TEST_F(ResolverBuiltinTest, Cross) {
|
||||||
auto* call = Call("cross", vec3<f32>(1.0f, 2.0f, 3.0f), vec3<f32>(1.0f, 2.0f, 3.0f));
|
auto* call = Call("cross", vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(1_f, 2_f, 3_f));
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1141,7 +1141,7 @@ TEST_F(ResolverBuiltinTest, Cross_Error_NoArgs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Cross_Error_Scalar) {
|
TEST_F(ResolverBuiltinTest, Cross_Error_Scalar) {
|
||||||
auto* call = Call("cross", 1.0f, 1.0f);
|
auto* call = Call("cross", 1_f, 1_f);
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1168,8 +1168,7 @@ TEST_F(ResolverBuiltinTest, Cross_Error_Vec3Int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Cross_Error_Vec4) {
|
TEST_F(ResolverBuiltinTest, Cross_Error_Vec4) {
|
||||||
auto* call =
|
auto* call = Call("cross", vec4<f32>(1_f, 2_f, 3_f, 4_f), vec4<f32>(1_f, 2_f, 3_f, 4_f));
|
||||||
Call("cross", vec4<f32>(1.0f, 2.0f, 3.0f, 4.0f), vec4<f32>(1.0f, 2.0f, 3.0f, 4.0f));
|
|
||||||
|
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
|
@ -1184,8 +1183,8 @@ TEST_F(ResolverBuiltinTest, Cross_Error_Vec4) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Cross_Error_TooManyParams) {
|
TEST_F(ResolverBuiltinTest, Cross_Error_TooManyParams) {
|
||||||
auto* call = Call("cross", vec3<f32>(1.0f, 2.0f, 3.0f), vec3<f32>(1.0f, 2.0f, 3.0f),
|
auto* call =
|
||||||
vec3<f32>(1.0f, 2.0f, 3.0f));
|
Call("cross", vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(1_f, 2_f, 3_f));
|
||||||
|
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
|
@ -1199,7 +1198,7 @@ TEST_F(ResolverBuiltinTest, Cross_Error_TooManyParams) {
|
||||||
)");
|
)");
|
||||||
}
|
}
|
||||||
TEST_F(ResolverBuiltinTest, Normalize) {
|
TEST_F(ResolverBuiltinTest, Normalize) {
|
||||||
auto* call = Call("normalize", vec3<f32>(1.0f, 1.0f, 3.0f));
|
auto* call = Call("normalize", vec3<f32>(1_f, 1_f, 3_f));
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1226,7 +1225,7 @@ using ResolverBuiltinTest_ThreeParam = ResolverTestWithParam<BuiltinData>;
|
||||||
TEST_P(ResolverBuiltinTest_ThreeParam, Scalar) {
|
TEST_P(ResolverBuiltinTest_ThreeParam, Scalar) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* call = Call(param.name, 1.f, 1.f, 1.f);
|
auto* call = Call(param.name, 1_f, 1_f, 1_f);
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1238,8 +1237,8 @@ TEST_P(ResolverBuiltinTest_ThreeParam, Scalar) {
|
||||||
TEST_P(ResolverBuiltinTest_ThreeParam, Vector) {
|
TEST_P(ResolverBuiltinTest_ThreeParam, Vector) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* call = Call(param.name, vec3<f32>(1.0f, 1.0f, 3.0f), vec3<f32>(1.0f, 1.0f, 3.0f),
|
auto* call = Call(param.name, vec3<f32>(1_f, 1_f, 3_f), vec3<f32>(1_f, 1_f, 3_f),
|
||||||
vec3<f32>(1.0f, 1.0f, 3.0f));
|
vec3<f32>(1_f, 1_f, 3_f));
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1271,7 +1270,7 @@ using ResolverBuiltinTest_ThreeParam_FloatOrInt = ResolverTestWithParam<BuiltinD
|
||||||
TEST_P(ResolverBuiltinTest_ThreeParam_FloatOrInt, Float_Scalar) {
|
TEST_P(ResolverBuiltinTest_ThreeParam_FloatOrInt, Float_Scalar) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* call = Call(param.name, 1.f, 1.f, 1.f);
|
auto* call = Call(param.name, 1_f, 1_f, 1_f);
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1283,8 +1282,8 @@ TEST_P(ResolverBuiltinTest_ThreeParam_FloatOrInt, Float_Scalar) {
|
||||||
TEST_P(ResolverBuiltinTest_ThreeParam_FloatOrInt, Float_Vector) {
|
TEST_P(ResolverBuiltinTest_ThreeParam_FloatOrInt, Float_Vector) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* call = Call(param.name, vec3<f32>(1.0f, 1.0f, 3.0f), vec3<f32>(1.0f, 1.0f, 3.0f),
|
auto* call = Call(param.name, vec3<f32>(1_f, 1_f, 3_f), vec3<f32>(1_f, 1_f, 3_f),
|
||||||
vec3<f32>(1.0f, 1.0f, 3.0f));
|
vec3<f32>(1_f, 1_f, 3_f));
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1443,7 +1442,7 @@ TEST_P(ResolverBuiltinTest_FloatOrInt_TwoParam, Scalar_Unsigned) {
|
||||||
TEST_P(ResolverBuiltinTest_FloatOrInt_TwoParam, Scalar_Float) {
|
TEST_P(ResolverBuiltinTest_FloatOrInt_TwoParam, Scalar_Float) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* call = Call(param.name, 1.0f, 1.0f);
|
auto* call = Call(param.name, 1_f, 1_f);
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1481,7 +1480,7 @@ TEST_P(ResolverBuiltinTest_FloatOrInt_TwoParam, Vector_Unsigned) {
|
||||||
TEST_P(ResolverBuiltinTest_FloatOrInt_TwoParam, Vector_Float) {
|
TEST_P(ResolverBuiltinTest_FloatOrInt_TwoParam, Vector_Float) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* call = Call(param.name, vec3<f32>(1.f, 1.f, 3.f), vec3<f32>(1.f, 1.f, 3.f));
|
auto* call = Call(param.name, vec3<f32>(1_f, 1_f, 3_f), vec3<f32>(1_f, 1_f, 3_f));
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
|
@ -37,7 +37,7 @@ TEST_F(ResolverBuiltinValidationTest, InvalidPipelineStageDirect) {
|
||||||
// @stage(compute) @workgroup_size(1) fn func { return dpdx(1.0); }
|
// @stage(compute) @workgroup_size(1) fn func { return dpdx(1.0); }
|
||||||
|
|
||||||
auto* dpdx =
|
auto* dpdx =
|
||||||
create<ast::CallExpression>(Source{{3, 4}}, Expr("dpdx"), ast::ExpressionList{Expr(1.0f)});
|
create<ast::CallExpression>(Source{{3, 4}}, Expr("dpdx"), ast::ExpressionList{Expr(1_f)});
|
||||||
Func(Source{{1, 2}}, "func", ast::VariableList{}, ty.void_(), {CallStmt(dpdx)},
|
Func(Source{{1, 2}}, "func", ast::VariableList{}, ty.void_(), {CallStmt(dpdx)},
|
||||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ TEST_F(ResolverBuiltinValidationTest, InvalidPipelineStageIndirect) {
|
||||||
// @stage(compute) @workgroup_size(1) fn main { return f2(); }
|
// @stage(compute) @workgroup_size(1) fn main { return f2(); }
|
||||||
|
|
||||||
auto* dpdx =
|
auto* dpdx =
|
||||||
create<ast::CallExpression>(Source{{3, 4}}, Expr("dpdx"), ast::ExpressionList{Expr(1.0f)});
|
create<ast::CallExpression>(Source{{3, 4}}, Expr("dpdx"), ast::ExpressionList{Expr(1_f)});
|
||||||
Func(Source{{1, 2}}, "f0", {}, ty.void_(), {CallStmt(dpdx)});
|
Func(Source{{1, 2}}, "f0", {}, ty.void_(), {CallStmt(dpdx)});
|
||||||
|
|
||||||
Func(Source{{3, 4}}, "f1", {}, ty.void_(), {CallStmt(Call("f0"))});
|
Func(Source{{3, 4}}, "f1", {}, ty.void_(), {CallStmt(Call("f0"))});
|
||||||
|
|
|
@ -132,7 +132,7 @@ TEST_F(ResolverBuiltinsValidationTest, FragDepthIsInput_Fail) {
|
||||||
// ) -> @location(0) f32 { return 1.0; }
|
// ) -> @location(0) f32 { return 1.0; }
|
||||||
auto* fd = Param("fd", ty.f32(),
|
auto* fd = Param("fd", ty.f32(),
|
||||||
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kFragDepth)});
|
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kFragDepth)});
|
||||||
Func("fs_main", ast::VariableList{fd}, ty.f32(), {Return(1.0f)},
|
Func("fs_main", ast::VariableList{fd}, ty.f32(), {Return(1_f)},
|
||||||
ast::AttributeList{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
ast::AttributeList{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
EXPECT_EQ(r()->error(),
|
EXPECT_EQ(r()->error(),
|
||||||
|
@ -152,7 +152,7 @@ TEST_F(ResolverBuiltinsValidationTest, FragDepthIsInputStruct_Fail) {
|
||||||
{Member("frag_depth", ty.f32(),
|
{Member("frag_depth", ty.f32(),
|
||||||
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kFragDepth)})});
|
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kFragDepth)})});
|
||||||
|
|
||||||
Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1.0f)},
|
Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1_f)},
|
||||||
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
EXPECT_EQ(r()->error(),
|
EXPECT_EQ(r()->error(),
|
||||||
|
@ -187,7 +187,7 @@ TEST_F(ResolverBuiltinsValidationTest, PositionNotF32_Struct_Fail) {
|
||||||
auto* m = Member("position", ty.vec4<u32>(),
|
auto* m = Member("position", ty.vec4<u32>(),
|
||||||
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kPosition)});
|
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kPosition)});
|
||||||
auto* s = Structure("MyInputs", {m});
|
auto* s = Structure("MyInputs", {m});
|
||||||
Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1.0f)},
|
Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1_f)},
|
||||||
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -197,7 +197,7 @@ TEST_F(ResolverBuiltinsValidationTest, PositionNotF32_Struct_Fail) {
|
||||||
TEST_F(ResolverBuiltinsValidationTest, PositionNotF32_ReturnType_Fail) {
|
TEST_F(ResolverBuiltinsValidationTest, PositionNotF32_ReturnType_Fail) {
|
||||||
// @stage(vertex)
|
// @stage(vertex)
|
||||||
// fn main() -> @builtin(position) f32 { return 1.0; }
|
// fn main() -> @builtin(position) f32 { return 1.0; }
|
||||||
Func("main", {}, ty.f32(), {Return(1.0f)}, {Stage(ast::PipelineStage::kVertex)},
|
Func("main", {}, ty.f32(), {Return(1_f)}, {Stage(ast::PipelineStage::kVertex)},
|
||||||
{Builtin(Source{{12, 34}}, ast::Builtin::kPosition)});
|
{Builtin(Source{{12, 34}}, ast::Builtin::kPosition)});
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -214,7 +214,7 @@ TEST_F(ResolverBuiltinsValidationTest, FragDepthNotF32_Struct_Fail) {
|
||||||
auto* m = Member("frag_depth", ty.i32(),
|
auto* m = Member("frag_depth", ty.i32(),
|
||||||
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kFragDepth)});
|
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kFragDepth)});
|
||||||
auto* s = Structure("MyInputs", {m});
|
auto* s = Structure("MyInputs", {m});
|
||||||
Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1.0f)},
|
Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1_f)},
|
||||||
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -232,7 +232,7 @@ TEST_F(ResolverBuiltinsValidationTest, SampleMaskNotU32_Struct_Fail) {
|
||||||
"MyInputs",
|
"MyInputs",
|
||||||
{Member("m", ty.f32(),
|
{Member("m", ty.f32(),
|
||||||
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kSampleMask)})});
|
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kSampleMask)})});
|
||||||
Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1.0f)},
|
Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1_f)},
|
||||||
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -256,7 +256,7 @@ TEST_F(ResolverBuiltinsValidationTest, SampleMaskIsNotU32_Fail) {
|
||||||
// ) -> @location(0) f32 { return 1.0; }
|
// ) -> @location(0) f32 { return 1.0; }
|
||||||
auto* arg = Param("arg", ty.bool_(),
|
auto* arg = Param("arg", ty.bool_(),
|
||||||
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kSampleMask)});
|
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kSampleMask)});
|
||||||
Func("fs_main", ast::VariableList{arg}, ty.f32(), {Return(1.0f)},
|
Func("fs_main", ast::VariableList{arg}, ty.f32(), {Return(1_f)},
|
||||||
ast::AttributeList{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
ast::AttributeList{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
EXPECT_EQ(r()->error(), "12:34 error: store type of builtin(sample_mask) must be 'u32'");
|
EXPECT_EQ(r()->error(), "12:34 error: store type of builtin(sample_mask) must be 'u32'");
|
||||||
|
@ -273,7 +273,7 @@ TEST_F(ResolverBuiltinsValidationTest, SampleIndexIsNotU32_Struct_Fail) {
|
||||||
"MyInputs",
|
"MyInputs",
|
||||||
{Member("m", ty.f32(),
|
{Member("m", ty.f32(),
|
||||||
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kSampleIndex)})});
|
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kSampleIndex)})});
|
||||||
Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1.0f)},
|
Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1_f)},
|
||||||
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -287,7 +287,7 @@ TEST_F(ResolverBuiltinsValidationTest, SampleIndexIsNotU32_Fail) {
|
||||||
// ) -> @location(0) f32 { return 1.0; }
|
// ) -> @location(0) f32 { return 1.0; }
|
||||||
auto* arg = Param("arg", ty.bool_(),
|
auto* arg = Param("arg", ty.bool_(),
|
||||||
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kSampleIndex)});
|
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kSampleIndex)});
|
||||||
Func("fs_main", ast::VariableList{arg}, ty.f32(), {Return(1.0f)},
|
Func("fs_main", ast::VariableList{arg}, ty.f32(), {Return(1_f)},
|
||||||
ast::AttributeList{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
ast::AttributeList{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
EXPECT_EQ(r()->error(), "12:34 error: store type of builtin(sample_index) must be 'u32'");
|
EXPECT_EQ(r()->error(), "12:34 error: store type of builtin(sample_index) must be 'u32'");
|
||||||
|
@ -300,7 +300,7 @@ TEST_F(ResolverBuiltinsValidationTest, PositionIsNotF32_Fail) {
|
||||||
// ) -> @location(0) f32 { return 1.0; }
|
// ) -> @location(0) f32 { return 1.0; }
|
||||||
auto* p = Param("p", ty.vec3<f32>(),
|
auto* p = Param("p", ty.vec3<f32>(),
|
||||||
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kPosition)});
|
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kPosition)});
|
||||||
Func("fs_main", ast::VariableList{p}, ty.f32(), {Return(1.0f)},
|
Func("fs_main", ast::VariableList{p}, ty.f32(), {Return(1_f)},
|
||||||
ast::AttributeList{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
ast::AttributeList{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
EXPECT_EQ(r()->error(), "12:34 error: store type of builtin(position) must be 'vec4<f32>'");
|
EXPECT_EQ(r()->error(), "12:34 error: store type of builtin(position) must be 'vec4<f32>'");
|
||||||
|
@ -503,7 +503,7 @@ TEST_F(ResolverBuiltinsValidationTest, FragmentBuiltinStruct_Pass) {
|
||||||
ast::AttributeList{Builtin(ast::Builtin::kFrontFacing)}),
|
ast::AttributeList{Builtin(ast::Builtin::kFrontFacing)}),
|
||||||
Member("sample_index", ty.u32(), ast::AttributeList{Builtin(ast::Builtin::kSampleIndex)}),
|
Member("sample_index", ty.u32(), ast::AttributeList{Builtin(ast::Builtin::kSampleIndex)}),
|
||||||
Member("sample_mask", ty.u32(), ast::AttributeList{Builtin(ast::Builtin::kSampleMask)})});
|
Member("sample_mask", ty.u32(), ast::AttributeList{Builtin(ast::Builtin::kSampleMask)})});
|
||||||
Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1.0f)},
|
Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1_f)},
|
||||||
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
@ -517,7 +517,7 @@ TEST_F(ResolverBuiltinsValidationTest, FrontFacingParamIsNotBool_Fail) {
|
||||||
auto* is_front =
|
auto* is_front =
|
||||||
Param("is_front", ty.i32(),
|
Param("is_front", ty.i32(),
|
||||||
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kFrontFacing)});
|
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kFrontFacing)});
|
||||||
Func("fs_main", ast::VariableList{is_front}, ty.f32(), {Return(1.0f)},
|
Func("fs_main", ast::VariableList{is_front}, ty.f32(), {Return(1_f)},
|
||||||
ast::AttributeList{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
ast::AttributeList{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -535,7 +535,7 @@ TEST_F(ResolverBuiltinsValidationTest, FrontFacingMemberIsNotBool_Fail) {
|
||||||
"MyInputs",
|
"MyInputs",
|
||||||
{Member("pos", ty.f32(),
|
{Member("pos", ty.f32(),
|
||||||
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kFrontFacing)})});
|
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kFrontFacing)})});
|
||||||
Func("fragShader", {Param("is_front", ty.Of(s))}, ty.f32(), {Return(1.0f)},
|
Func("fragShader", {Param("is_front", ty.Of(s))}, ty.f32(), {Return(1_f)},
|
||||||
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -543,90 +543,88 @@ TEST_F(ResolverBuiltinsValidationTest, FrontFacingMemberIsNotBool_Fail) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Length_Float_Scalar) {
|
TEST_F(ResolverBuiltinsValidationTest, Length_Float_Scalar) {
|
||||||
auto* builtin = Call("length", 1.0f);
|
auto* builtin = Call("length", 1_f);
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Length_Float_Vec2) {
|
TEST_F(ResolverBuiltinsValidationTest, Length_Float_Vec2) {
|
||||||
auto* builtin = Call("length", vec2<f32>(1.0f, 1.0f));
|
auto* builtin = Call("length", vec2<f32>(1_f, 1_f));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Length_Float_Vec3) {
|
TEST_F(ResolverBuiltinsValidationTest, Length_Float_Vec3) {
|
||||||
auto* builtin = Call("length", vec3<f32>(1.0f, 1.0f, 1.0f));
|
auto* builtin = Call("length", vec3<f32>(1_f, 1_f, 1_f));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Length_Float_Vec4) {
|
TEST_F(ResolverBuiltinsValidationTest, Length_Float_Vec4) {
|
||||||
auto* builtin = Call("length", vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f));
|
auto* builtin = Call("length", vec4<f32>(1_f, 1_f, 1_f, 1_f));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Distance_Float_Scalar) {
|
TEST_F(ResolverBuiltinsValidationTest, Distance_Float_Scalar) {
|
||||||
auto* builtin = Call("distance", 1.0f, 1.0f);
|
auto* builtin = Call("distance", 1_f, 1_f);
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Distance_Float_Vec2) {
|
TEST_F(ResolverBuiltinsValidationTest, Distance_Float_Vec2) {
|
||||||
auto* builtin = Call("distance", vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f));
|
auto* builtin = Call("distance", vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Distance_Float_Vec3) {
|
TEST_F(ResolverBuiltinsValidationTest, Distance_Float_Vec3) {
|
||||||
auto* builtin = Call("distance", vec3<f32>(1.0f, 1.0f, 1.0f), vec3<f32>(1.0f, 1.0f, 1.0f));
|
auto* builtin = Call("distance", vec3<f32>(1_f, 1_f, 1_f), vec3<f32>(1_f, 1_f, 1_f));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Distance_Float_Vec4) {
|
TEST_F(ResolverBuiltinsValidationTest, Distance_Float_Vec4) {
|
||||||
auto* builtin =
|
auto* builtin = Call("distance", vec4<f32>(1_f, 1_f, 1_f, 1_f), vec4<f32>(1_f, 1_f, 1_f, 1_f));
|
||||||
Call("distance", vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f), vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f));
|
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Determinant_Mat2x2) {
|
TEST_F(ResolverBuiltinsValidationTest, Determinant_Mat2x2) {
|
||||||
auto* builtin = Call("determinant", mat2x2<f32>(vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f)));
|
auto* builtin = Call("determinant", mat2x2<f32>(vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f)));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Determinant_Mat3x3) {
|
TEST_F(ResolverBuiltinsValidationTest, Determinant_Mat3x3) {
|
||||||
auto* builtin =
|
auto* builtin = Call(
|
||||||
Call("determinant", mat3x3<f32>(vec3<f32>(1.0f, 1.0f, 1.0f), vec3<f32>(1.0f, 1.0f, 1.0f),
|
"determinant",
|
||||||
vec3<f32>(1.0f, 1.0f, 1.0f)));
|
mat3x3<f32>(vec3<f32>(1_f, 1_f, 1_f), vec3<f32>(1_f, 1_f, 1_f), vec3<f32>(1_f, 1_f, 1_f)));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Determinant_Mat4x4) {
|
TEST_F(ResolverBuiltinsValidationTest, Determinant_Mat4x4) {
|
||||||
auto* builtin =
|
auto* builtin = Call("determinant",
|
||||||
Call("determinant",
|
mat4x4<f32>(vec4<f32>(1_f, 1_f, 1_f, 1_f), vec4<f32>(1_f, 1_f, 1_f, 1_f),
|
||||||
mat4x4<f32>(vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f), vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f),
|
vec4<f32>(1_f, 1_f, 1_f, 1_f), vec4<f32>(1_f, 1_f, 1_f, 1_f)));
|
||||||
vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f), vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f)));
|
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Frexp_Scalar) {
|
TEST_F(ResolverBuiltinsValidationTest, Frexp_Scalar) {
|
||||||
auto* builtin = Call("frexp", 1.0f);
|
auto* builtin = Call("frexp", 1_f);
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -639,7 +637,7 @@ TEST_F(ResolverBuiltinsValidationTest, Frexp_Scalar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec2) {
|
TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec2) {
|
||||||
auto* builtin = Call("frexp", vec2<f32>(1.0f, 1.0f));
|
auto* builtin = Call("frexp", vec2<f32>(1_f, 1_f));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -656,7 +654,7 @@ TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec3) {
|
TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec3) {
|
||||||
auto* builtin = Call("frexp", vec3<f32>(1.0f, 1.0f, 1.0f));
|
auto* builtin = Call("frexp", vec3<f32>(1_f, 1_f, 1_f));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -673,7 +671,7 @@ TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec3) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec4) {
|
TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec4) {
|
||||||
auto* builtin = Call("frexp", vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f));
|
auto* builtin = Call("frexp", vec4<f32>(1_f, 1_f, 1_f, 1_f));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -690,7 +688,7 @@ TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec4) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Modf_Scalar) {
|
TEST_F(ResolverBuiltinsValidationTest, Modf_Scalar) {
|
||||||
auto* builtin = Call("modf", 1.0f);
|
auto* builtin = Call("modf", 1_f);
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -703,7 +701,7 @@ TEST_F(ResolverBuiltinsValidationTest, Modf_Scalar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Modf_Vec2) {
|
TEST_F(ResolverBuiltinsValidationTest, Modf_Vec2) {
|
||||||
auto* builtin = Call("modf", vec2<f32>(1.0f, 1.0f));
|
auto* builtin = Call("modf", vec2<f32>(1_f, 1_f));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -720,7 +718,7 @@ TEST_F(ResolverBuiltinsValidationTest, Modf_Vec2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Modf_Vec3) {
|
TEST_F(ResolverBuiltinsValidationTest, Modf_Vec3) {
|
||||||
auto* builtin = Call("modf", vec3<f32>(1.0f, 1.0f, 1.0f));
|
auto* builtin = Call("modf", vec3<f32>(1_f, 1_f, 1_f));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -737,7 +735,7 @@ TEST_F(ResolverBuiltinsValidationTest, Modf_Vec3) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Modf_Vec4) {
|
TEST_F(ResolverBuiltinsValidationTest, Modf_Vec4) {
|
||||||
auto* builtin = Call("modf", vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f));
|
auto* builtin = Call("modf", vec4<f32>(1_f, 1_f, 1_f, 1_f));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -754,36 +752,35 @@ TEST_F(ResolverBuiltinsValidationTest, Modf_Vec4) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Cross_Float_Vec3) {
|
TEST_F(ResolverBuiltinsValidationTest, Cross_Float_Vec3) {
|
||||||
auto* builtin = Call("cross", vec3<f32>(1.0f, 1.0f, 1.0f), vec3<f32>(1.0f, 1.0f, 1.0f));
|
auto* builtin = Call("cross", vec3<f32>(1_f, 1_f, 1_f), vec3<f32>(1_f, 1_f, 1_f));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Dot_Float_Vec2) {
|
TEST_F(ResolverBuiltinsValidationTest, Dot_Float_Vec2) {
|
||||||
auto* builtin = Call("dot", vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f));
|
auto* builtin = Call("dot", vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Dot_Float_Vec3) {
|
TEST_F(ResolverBuiltinsValidationTest, Dot_Float_Vec3) {
|
||||||
auto* builtin = Call("dot", vec3<f32>(1.0f, 1.0f, 1.0f), vec3<f32>(1.0f, 1.0f, 1.0f));
|
auto* builtin = Call("dot", vec3<f32>(1_f, 1_f, 1_f), vec3<f32>(1_f, 1_f, 1_f));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Dot_Float_Vec4) {
|
TEST_F(ResolverBuiltinsValidationTest, Dot_Float_Vec4) {
|
||||||
auto* builtin =
|
auto* builtin = Call("dot", vec4<f32>(1_f, 1_f, 1_f, 1_f), vec4<f32>(1_f, 1_f, 1_f, 1_f));
|
||||||
Call("dot", vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f), vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f));
|
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Select_Float_Scalar) {
|
TEST_F(ResolverBuiltinsValidationTest, Select_Float_Scalar) {
|
||||||
auto* builtin = Call("select", Expr(1.0f), Expr(1.0f), Expr(true));
|
auto* builtin = Call("select", Expr(1_f), Expr(1_f), Expr(true));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -805,7 +802,7 @@ TEST_F(ResolverBuiltinsValidationTest, Select_Boolean_Scalar) {
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Select_Float_Vec2) {
|
TEST_F(ResolverBuiltinsValidationTest, Select_Float_Vec2) {
|
||||||
auto* builtin =
|
auto* builtin =
|
||||||
Call("select", vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f), vec2<bool>(true, true));
|
Call("select", vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f), vec2<bool>(true, true));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -840,7 +837,7 @@ TEST_P(FloatAllMatching, Scalar) {
|
||||||
|
|
||||||
ast::ExpressionList params;
|
ast::ExpressionList params;
|
||||||
for (uint32_t i = 0; i < num_params; ++i) {
|
for (uint32_t i = 0; i < num_params; ++i) {
|
||||||
params.push_back(Expr(1.0f));
|
params.push_back(Expr(1_f));
|
||||||
}
|
}
|
||||||
auto* builtin = Call(name, params);
|
auto* builtin = Call(name, params);
|
||||||
Func("func", {}, ty.void_(), {CallStmt(builtin)},
|
Func("func", {}, ty.void_(), {CallStmt(builtin)},
|
||||||
|
@ -856,7 +853,7 @@ TEST_P(FloatAllMatching, Vec2) {
|
||||||
|
|
||||||
ast::ExpressionList params;
|
ast::ExpressionList params;
|
||||||
for (uint32_t i = 0; i < num_params; ++i) {
|
for (uint32_t i = 0; i < num_params; ++i) {
|
||||||
params.push_back(vec2<f32>(1.0f, 1.0f));
|
params.push_back(vec2<f32>(1_f, 1_f));
|
||||||
}
|
}
|
||||||
auto* builtin = Call(name, params);
|
auto* builtin = Call(name, params);
|
||||||
Func("func", {}, ty.void_(), {CallStmt(builtin)},
|
Func("func", {}, ty.void_(), {CallStmt(builtin)},
|
||||||
|
@ -872,7 +869,7 @@ TEST_P(FloatAllMatching, Vec3) {
|
||||||
|
|
||||||
ast::ExpressionList params;
|
ast::ExpressionList params;
|
||||||
for (uint32_t i = 0; i < num_params; ++i) {
|
for (uint32_t i = 0; i < num_params; ++i) {
|
||||||
params.push_back(vec3<f32>(1.0f, 1.0f, 1.0f));
|
params.push_back(vec3<f32>(1_f, 1_f, 1_f));
|
||||||
}
|
}
|
||||||
auto* builtin = Call(name, params);
|
auto* builtin = Call(name, params);
|
||||||
Func("func", {}, ty.void_(), {CallStmt(builtin)},
|
Func("func", {}, ty.void_(), {CallStmt(builtin)},
|
||||||
|
@ -888,7 +885,7 @@ TEST_P(FloatAllMatching, Vec4) {
|
||||||
|
|
||||||
ast::ExpressionList params;
|
ast::ExpressionList params;
|
||||||
for (uint32_t i = 0; i < num_params; ++i) {
|
for (uint32_t i = 0; i < num_params; ++i) {
|
||||||
params.push_back(vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f));
|
params.push_back(vec4<f32>(1_f, 1_f, 1_f, 1_f));
|
||||||
}
|
}
|
||||||
auto* builtin = Call(name, params);
|
auto* builtin = Call(name, params);
|
||||||
Func("func", {}, ty.void_(), {CallStmt(builtin)},
|
Func("func", {}, ty.void_(), {CallStmt(builtin)},
|
||||||
|
@ -1126,7 +1123,7 @@ using DataPacking4x8 = ResolverBuiltinsValidationTestWithParams<std::string>;
|
||||||
|
|
||||||
TEST_P(DataPacking4x8, Float_Vec4) {
|
TEST_P(DataPacking4x8, Float_Vec4) {
|
||||||
auto name = GetParam();
|
auto name = GetParam();
|
||||||
auto* builtin = Call(name, vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f));
|
auto* builtin = Call(name, vec4<f32>(1_f, 1_f, 1_f, 1_f));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
@ -1139,7 +1136,7 @@ using DataPacking2x16 = ResolverBuiltinsValidationTestWithParams<std::string>;
|
||||||
|
|
||||||
TEST_P(DataPacking2x16, Float_Vec2) {
|
TEST_P(DataPacking2x16, Float_Vec2) {
|
||||||
auto name = GetParam();
|
auto name = GetParam();
|
||||||
auto* builtin = Call(name, vec2<f32>(1.0f, 1.0f));
|
auto* builtin = Call(name, vec2<f32>(1_f, 1_f));
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#include "src/tint/ast/call_statement.h"
|
#include "src/tint/ast/call_statement.h"
|
||||||
#include "src/tint/resolver/resolver_test_helper.h"
|
#include "src/tint/resolver/resolver_test_helper.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::resolver {
|
namespace tint::resolver {
|
||||||
namespace {
|
namespace {
|
||||||
// Helpers and typedefs
|
// Helpers and typedefs
|
||||||
|
@ -86,7 +88,7 @@ TEST_F(ResolverCallTest, Valid) {
|
||||||
args.push_back(p.create_value(*this, 0));
|
args.push_back(p.create_value(*this, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* func = Func("foo", std::move(params), ty.f32(), {Return(1.23f)});
|
auto* func = Func("foo", std::move(params), ty.f32(), {Return(1.23_f)});
|
||||||
auto* call_expr = Call("foo", std::move(args));
|
auto* call_expr = Call("foo", std::move(args));
|
||||||
WrapInFunction(call_expr);
|
WrapInFunction(call_expr);
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ TEST_F(ResolverCallValidationTest, TooFewArgs) {
|
||||||
|
|
||||||
TEST_F(ResolverCallValidationTest, TooManyArgs) {
|
TEST_F(ResolverCallValidationTest, TooManyArgs) {
|
||||||
Func("foo", {Param(Sym(), ty.i32()), Param(Sym(), ty.f32())}, ty.void_(), {Return()});
|
Func("foo", {Param(Sym(), ty.i32()), Param(Sym(), ty.f32())}, ty.void_(), {Return()});
|
||||||
auto* call = Call(Source{{12, 34}}, "foo", 1_i, 1.0f, 1.0f);
|
auto* call = Call(Source{{12, 34}}, "foo", 1_i, 1_f, 1_f);
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -45,7 +45,7 @@ TEST_F(ResolverCallValidationTest, TooManyArgs) {
|
||||||
|
|
||||||
TEST_F(ResolverCallValidationTest, MismatchedArgs) {
|
TEST_F(ResolverCallValidationTest, MismatchedArgs) {
|
||||||
Func("foo", {Param(Sym(), ty.i32()), Param(Sym(), ty.f32())}, ty.void_(), {Return()});
|
Func("foo", {Param(Sym(), ty.i32()), Param(Sym(), ty.f32())}, ty.void_(), {Return()});
|
||||||
auto* call = Call("foo", Expr(Source{{12, 34}}, true), 1.0f);
|
auto* call = Call("foo", Expr(Source{{12, 34}}, true), 1_f);
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -58,7 +58,7 @@ TEST_F(ResolverCallValidationTest, UnusedRetval) {
|
||||||
// fn func() -> f32 { return 1.0; }
|
// fn func() -> f32 { return 1.0; }
|
||||||
// fn main() {func(); return; }
|
// fn main() {func(); return; }
|
||||||
|
|
||||||
Func("func", {}, ty.f32(), {Return(Expr(1.0f))}, {});
|
Func("func", {}, ty.f32(), {Return(Expr(1_f))}, {});
|
||||||
|
|
||||||
Func("main", {}, ty.void_(),
|
Func("main", {}, ty.void_(),
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,7 +68,7 @@ TEST_F(ResolverCompoundAssignmentValidationTest, IncompatibleTypes) {
|
||||||
|
|
||||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
||||||
|
|
||||||
auto* assign = CompoundAssign(Source{{12, 34}}, "a", 2.3f, ast::BinaryOp::kAdd);
|
auto* assign = CompoundAssign(Source{{12, 34}}, "a", 2.3_f, ast::BinaryOp::kAdd);
|
||||||
WrapInFunction(var, assign);
|
WrapInFunction(var, assign);
|
||||||
|
|
||||||
ASSERT_FALSE(r()->Resolve());
|
ASSERT_FALSE(r()->Resolve());
|
||||||
|
@ -83,9 +83,9 @@ TEST_F(ResolverCompoundAssignmentValidationTest, IncompatibleOp) {
|
||||||
// a |= 2.0;
|
// a |= 2.0;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(1.f));
|
auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(1_f));
|
||||||
|
|
||||||
auto* assign = CompoundAssign(Source{{12, 34}}, "a", 2.0f, ast::BinaryOp::kOr);
|
auto* assign = CompoundAssign(Source{{12, 34}}, "a", 2_f, ast::BinaryOp::kOr);
|
||||||
WrapInFunction(var, assign);
|
WrapInFunction(var, assign);
|
||||||
|
|
||||||
ASSERT_FALSE(r()->Resolve());
|
ASSERT_FALSE(r()->Resolve());
|
||||||
|
@ -102,7 +102,7 @@ TEST_F(ResolverCompoundAssignmentValidationTest, VectorScalar_Pass) {
|
||||||
|
|
||||||
auto* var = Var("a", ty.vec4<f32>(), ast::StorageClass::kNone);
|
auto* var = Var("a", ty.vec4<f32>(), ast::StorageClass::kNone);
|
||||||
|
|
||||||
auto* assign = CompoundAssign(Source{{12, 34}}, "a", 1.f, ast::BinaryOp::kAdd);
|
auto* assign = CompoundAssign(Source{{12, 34}}, "a", 1_f, ast::BinaryOp::kAdd);
|
||||||
WrapInFunction(var, assign);
|
WrapInFunction(var, assign);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -132,7 +132,7 @@ TEST_F(ResolverCompoundAssignmentValidationTest, MatrixScalar_Pass) {
|
||||||
|
|
||||||
auto* var = Var("a", ty.mat4x4<f32>(), ast::StorageClass::kNone);
|
auto* var = Var("a", ty.mat4x4<f32>(), ast::StorageClass::kNone);
|
||||||
|
|
||||||
auto* assign = CompoundAssign(Source{{12, 34}}, "a", 2.f, ast::BinaryOp::kMultiply);
|
auto* assign = CompoundAssign(Source{{12, 34}}, "a", 2_f, ast::BinaryOp::kMultiply);
|
||||||
WrapInFunction(var, assign);
|
WrapInFunction(var, assign);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
|
@ -30,7 +30,7 @@ TEST_F(ResolverControlBlockValidationTest, SwitchSelectorExpressionNoneIntegerTy
|
||||||
// switch (a) {
|
// switch (a) {
|
||||||
// default: {}
|
// default: {}
|
||||||
// }
|
// }
|
||||||
auto* var = Var("a", ty.f32(), Expr(3.14f));
|
auto* var = Var("a", ty.f32(), Expr(3.14_f));
|
||||||
|
|
||||||
auto* block = Block(Decl(var), Switch(Expr(Source{{12, 34}}, "a"), //
|
auto* block = Block(Decl(var), Switch(Expr(Source{{12, 34}}, "a"), //
|
||||||
DefaultCase()));
|
DefaultCase()));
|
||||||
|
|
|
@ -717,9 +717,10 @@ TEST_F(ResolverDependencyGraphUsedBeforeDeclTest, VarUsed) {
|
||||||
// }
|
// }
|
||||||
// var G: f32 = 2.1;
|
// var G: f32 = 2.1;
|
||||||
|
|
||||||
Func("F", ast::VariableList{}, ty.void_(), {Block(Assign(Expr(Source{{12, 34}}, "G"), 3.14f))});
|
Func("F", ast::VariableList{}, ty.void_(),
|
||||||
|
{Block(Assign(Expr(Source{{12, 34}}, "G"), 3.14_f))});
|
||||||
|
|
||||||
Global(Source{{56, 78}}, "G", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1f));
|
Global(Source{{56, 78}}, "G", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1_f));
|
||||||
|
|
||||||
Build();
|
Build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ class ResolverEntryPointValidationTest : public TestHelper, public testing::Test
|
||||||
TEST_F(ResolverEntryPointValidationTest, ReturnTypeAttribute_Location) {
|
TEST_F(ResolverEntryPointValidationTest, ReturnTypeAttribute_Location) {
|
||||||
// @stage(fragment)
|
// @stage(fragment)
|
||||||
// fn main() -> @location(0) f32 { return 1.0; }
|
// fn main() -> @location(0) f32 { return 1.0; }
|
||||||
Func(Source{{12, 34}}, "main", {}, ty.f32(), {Return(1.0f)},
|
Func(Source{{12, 34}}, "main", {}, ty.f32(), {Return(1_f)},
|
||||||
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
|
@ -288,7 +288,7 @@ TEST_F(ResolverFunctionValidationTest, FunctionTypeMustMatchReturnStatementTypeF
|
||||||
// fn func() -> f32 { return 2.0; }
|
// fn func() -> f32 { return 2.0; }
|
||||||
Func("func", ast::VariableList{}, ty.f32(),
|
Func("func", ast::VariableList{}, ty.f32(),
|
||||||
ast::StatementList{
|
ast::StatementList{
|
||||||
Return(Source{{12, 34}}, Expr(2.f)),
|
Return(Source{{12, 34}}, Expr(2_f)),
|
||||||
},
|
},
|
||||||
ast::AttributeList{});
|
ast::AttributeList{});
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ TEST_F(ResolverFunctionValidationTest, FunctionTypeMustMatchReturnStatementTypeF
|
||||||
auto* myf32 = Alias("myf32", ty.f32());
|
auto* myf32 = Alias("myf32", ty.f32());
|
||||||
Func("func", ast::VariableList{}, ty.Of(myf32),
|
Func("func", ast::VariableList{}, ty.Of(myf32),
|
||||||
ast::StatementList{
|
ast::StatementList{
|
||||||
Return(Source{{12, 34}}, Expr(2.f)),
|
Return(Source{{12, 34}}, Expr(2_f)),
|
||||||
},
|
},
|
||||||
ast::AttributeList{});
|
ast::AttributeList{});
|
||||||
|
|
||||||
|
@ -539,7 +539,7 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Literal_BadType) {
|
||||||
// fn main() {}
|
// fn main() {}
|
||||||
|
|
||||||
Func("main", {}, ty.void_(), {},
|
Func("main", {}, ty.void_(), {},
|
||||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, 64.f))});
|
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, 64_f))});
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
EXPECT_EQ(r()->error(),
|
EXPECT_EQ(r()->error(),
|
||||||
|
@ -573,7 +573,7 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_BadType) {
|
||||||
// let x = 64.0;
|
// let x = 64.0;
|
||||||
// @stage(compute) @workgroup_size(x)
|
// @stage(compute) @workgroup_size(x)
|
||||||
// fn main() {}
|
// fn main() {}
|
||||||
GlobalConst("x", ty.f32(), Expr(64.f));
|
GlobalConst("x", ty.f32(), Expr(64_f));
|
||||||
Func("main", {}, ty.void_(), {},
|
Func("main", {}, ty.void_(), {},
|
||||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, "x"))});
|
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, "x"))});
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ TEST_F(ResolverIncrementDecrementValidationTest, ThroughVector_Member) {
|
||||||
TEST_F(ResolverIncrementDecrementValidationTest, Float) {
|
TEST_F(ResolverIncrementDecrementValidationTest, Float) {
|
||||||
// var a : f32 = 2.0;
|
// var a : f32 = 2.0;
|
||||||
// a++;
|
// a++;
|
||||||
auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2.f));
|
auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2_f));
|
||||||
auto* inc = Increment(Expr(Source{{12, 34}}, "a"));
|
auto* inc = Increment(Expr(Source{{12, 34}}, "a"));
|
||||||
WrapInFunction(var, inc);
|
WrapInFunction(var, inc);
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
#include "src/tint/resolver/resolver_test_helper.h"
|
#include "src/tint/resolver/resolver_test_helper.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::resolver {
|
namespace tint::resolver {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -36,7 +38,7 @@ class ResolverPipelineOverridableConstantTest : public ResolverTest {
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(ResolverPipelineOverridableConstantTest, NonOverridable) {
|
TEST_F(ResolverPipelineOverridableConstantTest, NonOverridable) {
|
||||||
auto* a = GlobalConst("a", ty.f32(), Expr(1.f));
|
auto* a = GlobalConst("a", ty.f32(), Expr(1_f));
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
|
@ -48,7 +50,7 @@ TEST_F(ResolverPipelineOverridableConstantTest, NonOverridable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverPipelineOverridableConstantTest, WithId) {
|
TEST_F(ResolverPipelineOverridableConstantTest, WithId) {
|
||||||
auto* a = Override("a", ty.f32(), Expr(1.f), {Id(7u)});
|
auto* a = Override("a", ty.f32(), Expr(1_f), {Id(7u)});
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
|
@ -56,7 +58,7 @@ TEST_F(ResolverPipelineOverridableConstantTest, WithId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverPipelineOverridableConstantTest, WithoutId) {
|
TEST_F(ResolverPipelineOverridableConstantTest, WithoutId) {
|
||||||
auto* a = Override("a", ty.f32(), Expr(1.f));
|
auto* a = Override("a", ty.f32(), Expr(1_f));
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
|
@ -65,12 +67,12 @@ TEST_F(ResolverPipelineOverridableConstantTest, WithoutId) {
|
||||||
|
|
||||||
TEST_F(ResolverPipelineOverridableConstantTest, WithAndWithoutIds) {
|
TEST_F(ResolverPipelineOverridableConstantTest, WithAndWithoutIds) {
|
||||||
std::vector<ast::Variable*> variables;
|
std::vector<ast::Variable*> variables;
|
||||||
auto* a = Override("a", ty.f32(), Expr(1.f));
|
auto* a = Override("a", ty.f32(), Expr(1_f));
|
||||||
auto* b = Override("b", ty.f32(), Expr(1.f));
|
auto* b = Override("b", ty.f32(), Expr(1_f));
|
||||||
auto* c = Override("c", ty.f32(), Expr(1.f), {Id(2u)});
|
auto* c = Override("c", ty.f32(), Expr(1_f), {Id(2u)});
|
||||||
auto* d = Override("d", ty.f32(), Expr(1.f), {Id(4u)});
|
auto* d = Override("d", ty.f32(), Expr(1_f), {Id(4u)});
|
||||||
auto* e = Override("e", ty.f32(), Expr(1.f));
|
auto* e = Override("e", ty.f32(), Expr(1_f));
|
||||||
auto* f = Override("f", ty.f32(), Expr(1.f), {Id(1u)});
|
auto* f = Override("f", ty.f32(), Expr(1_f), {Id(1u)});
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
|
@ -84,8 +86,8 @@ TEST_F(ResolverPipelineOverridableConstantTest, WithAndWithoutIds) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverPipelineOverridableConstantTest, DuplicateIds) {
|
TEST_F(ResolverPipelineOverridableConstantTest, DuplicateIds) {
|
||||||
Override("a", ty.f32(), Expr(1.f), {Id(Source{{12, 34}}, 7u)});
|
Override("a", ty.f32(), Expr(1_f), {Id(Source{{12, 34}}, 7u)});
|
||||||
Override("b", ty.f32(), Expr(1.f), {Id(Source{{56, 78}}, 7u)});
|
Override("b", ty.f32(), Expr(1_f), {Id(Source{{56, 78}}, 7u)});
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
|
||||||
|
@ -94,7 +96,7 @@ TEST_F(ResolverPipelineOverridableConstantTest, DuplicateIds) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverPipelineOverridableConstantTest, IdTooLarge) {
|
TEST_F(ResolverPipelineOverridableConstantTest, IdTooLarge) {
|
||||||
Override("a", ty.f32(), Expr(1.f), {Id(Source{{12, 34}}, 65536u)});
|
Override("a", ty.f32(), Expr(1_f), {Id(Source{{12, 34}}, 65536u)});
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ sem::Constant Resolver::EvaluateConstantValue(const ast::CallExpression* call,
|
||||||
return sem::Constant(type, sem::Constant::Scalars(result_size, 0_u));
|
return sem::Constant(type, sem::Constant::Scalars(result_size, 0_u));
|
||||||
}
|
}
|
||||||
if (elem_type->Is<sem::F32>()) {
|
if (elem_type->Is<sem::F32>()) {
|
||||||
return sem::Constant(type, sem::Constant::Scalars(result_size, 0._f));
|
return sem::Constant(type, sem::Constant::Scalars(result_size, 0_f));
|
||||||
}
|
}
|
||||||
if (elem_type->Is<sem::Bool>()) {
|
if (elem_type->Is<sem::Bool>()) {
|
||||||
return sem::Constant(type, sem::Constant::Scalars(result_size, false));
|
return sem::Constant(type, sem::Constant::Scalars(result_size, false));
|
||||||
|
|
|
@ -58,7 +58,7 @@ TEST_F(ResolverConstantsTest, Scalar_u32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverConstantsTest, Scalar_f32) {
|
TEST_F(ResolverConstantsTest, Scalar_f32) {
|
||||||
auto* expr = Expr(9.9f);
|
auto* expr = Expr(9.9_f);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -202,7 +202,7 @@ TEST_F(ResolverConstantsTest, Vec3_Splat_u32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverConstantsTest, Vec3_Splat_f32) {
|
TEST_F(ResolverConstantsTest, Vec3_Splat_f32) {
|
||||||
auto* expr = vec3<f32>(9.9f);
|
auto* expr = vec3<f32>(9.9_f);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -278,7 +278,7 @@ TEST_F(ResolverConstantsTest, Vec3_FullConstruct_u32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverConstantsTest, Vec3_FullConstruct_f32) {
|
TEST_F(ResolverConstantsTest, Vec3_FullConstruct_f32) {
|
||||||
auto* expr = vec3<f32>(1.f, 2.f, 3.f);
|
auto* expr = vec3<f32>(1_f, 2_f, 3_f);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -354,7 +354,7 @@ TEST_F(ResolverConstantsTest, Vec3_MixConstruct_u32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverConstantsTest, Vec3_MixConstruct_f32) {
|
TEST_F(ResolverConstantsTest, Vec3_MixConstruct_f32) {
|
||||||
auto* expr = vec3<f32>(1.f, vec2<f32>(2.f, 3.f));
|
auto* expr = vec3<f32>(1_f, vec2<f32>(2_f, 3_f));
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -392,7 +392,7 @@ TEST_F(ResolverConstantsTest, Vec3_MixConstruct_bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverConstantsTest, Vec3_Cast_f32_to_32) {
|
TEST_F(ResolverConstantsTest, Vec3_Cast_f32_to_32) {
|
||||||
auto* expr = vec3<i32>(vec3<f32>(1.1f, 2.2f, 3.3f));
|
auto* expr = vec3<i32>(vec3<f32>(1.1_f, 2.2_f, 3.3_f));
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
|
@ -88,7 +88,7 @@ using Op = ast::BinaryOp;
|
||||||
TEST_F(ResolverTest, Stmt_Assign) {
|
TEST_F(ResolverTest, Stmt_Assign) {
|
||||||
auto* v = Var("v", ty.f32());
|
auto* v = Var("v", ty.f32());
|
||||||
auto* lhs = Expr("v");
|
auto* lhs = Expr("v");
|
||||||
auto* rhs = Expr(2.3f);
|
auto* rhs = Expr(2.3_f);
|
||||||
|
|
||||||
auto* assign = Assign(lhs, rhs);
|
auto* assign = Assign(lhs, rhs);
|
||||||
WrapInFunction(v, assign);
|
WrapInFunction(v, assign);
|
||||||
|
@ -107,7 +107,7 @@ TEST_F(ResolverTest, Stmt_Assign) {
|
||||||
TEST_F(ResolverTest, Stmt_Case) {
|
TEST_F(ResolverTest, Stmt_Case) {
|
||||||
auto* v = Var("v", ty.f32());
|
auto* v = Var("v", ty.f32());
|
||||||
auto* lhs = Expr("v");
|
auto* lhs = Expr("v");
|
||||||
auto* rhs = Expr(2.3f);
|
auto* rhs = Expr(2.3_f);
|
||||||
|
|
||||||
auto* assign = Assign(lhs, rhs);
|
auto* assign = Assign(lhs, rhs);
|
||||||
auto* block = Block(assign);
|
auto* block = Block(assign);
|
||||||
|
@ -132,7 +132,7 @@ TEST_F(ResolverTest, Stmt_Case) {
|
||||||
TEST_F(ResolverTest, Stmt_Block) {
|
TEST_F(ResolverTest, Stmt_Block) {
|
||||||
auto* v = Var("v", ty.f32());
|
auto* v = Var("v", ty.f32());
|
||||||
auto* lhs = Expr("v");
|
auto* lhs = Expr("v");
|
||||||
auto* rhs = Expr(2.3f);
|
auto* rhs = Expr(2.3_f);
|
||||||
|
|
||||||
auto* assign = Assign(lhs, rhs);
|
auto* assign = Assign(lhs, rhs);
|
||||||
auto* block = Block(assign);
|
auto* block = Block(assign);
|
||||||
|
@ -154,7 +154,7 @@ TEST_F(ResolverTest, Stmt_Block) {
|
||||||
TEST_F(ResolverTest, Stmt_If) {
|
TEST_F(ResolverTest, Stmt_If) {
|
||||||
auto* v = Var("v", ty.f32());
|
auto* v = Var("v", ty.f32());
|
||||||
auto* else_lhs = Expr("v");
|
auto* else_lhs = Expr("v");
|
||||||
auto* else_rhs = Expr(2.3f);
|
auto* else_rhs = Expr(2.3_f);
|
||||||
|
|
||||||
auto* else_body = Block(Assign(else_lhs, else_rhs));
|
auto* else_body = Block(Assign(else_lhs, else_rhs));
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ TEST_F(ResolverTest, Stmt_If) {
|
||||||
auto* else_stmt = If(else_cond, else_body);
|
auto* else_stmt = If(else_cond, else_body);
|
||||||
|
|
||||||
auto* lhs = Expr("v");
|
auto* lhs = Expr("v");
|
||||||
auto* rhs = Expr(2.3f);
|
auto* rhs = Expr(2.3_f);
|
||||||
|
|
||||||
auto* assign = Assign(lhs, rhs);
|
auto* assign = Assign(lhs, rhs);
|
||||||
auto* body = Block(assign);
|
auto* body = Block(assign);
|
||||||
|
@ -195,11 +195,11 @@ TEST_F(ResolverTest, Stmt_If) {
|
||||||
TEST_F(ResolverTest, Stmt_Loop) {
|
TEST_F(ResolverTest, Stmt_Loop) {
|
||||||
auto* v = Var("v", ty.f32());
|
auto* v = Var("v", ty.f32());
|
||||||
auto* body_lhs = Expr("v");
|
auto* body_lhs = Expr("v");
|
||||||
auto* body_rhs = Expr(2.3f);
|
auto* body_rhs = Expr(2.3_f);
|
||||||
|
|
||||||
auto* body = Block(Assign(body_lhs, body_rhs), Break());
|
auto* body = Block(Assign(body_lhs, body_rhs), Break());
|
||||||
auto* continuing_lhs = Expr("v");
|
auto* continuing_lhs = Expr("v");
|
||||||
auto* continuing_rhs = Expr(2.3f);
|
auto* continuing_rhs = Expr(2.3_f);
|
||||||
|
|
||||||
auto* continuing = Block(Assign(continuing_lhs, continuing_rhs));
|
auto* continuing = Block(Assign(continuing_lhs, continuing_rhs));
|
||||||
auto* stmt = Loop(body, continuing);
|
auto* stmt = Loop(body, continuing);
|
||||||
|
@ -243,7 +243,7 @@ TEST_F(ResolverTest, Stmt_Return_WithoutValue) {
|
||||||
TEST_F(ResolverTest, Stmt_Switch) {
|
TEST_F(ResolverTest, Stmt_Switch) {
|
||||||
auto* v = Var("v", ty.f32());
|
auto* v = Var("v", ty.f32());
|
||||||
auto* lhs = Expr("v");
|
auto* lhs = Expr("v");
|
||||||
auto* rhs = Expr(2.3f);
|
auto* rhs = Expr(2.3_f);
|
||||||
auto* case_block = Block(Assign(lhs, rhs));
|
auto* case_block = Block(Assign(lhs, rhs));
|
||||||
auto* stmt = Switch(Expr(2_i), Case(Expr(3_i), case_block), DefaultCase());
|
auto* stmt = Switch(Expr(2_i), Case(Expr(3_i), case_block), DefaultCase());
|
||||||
WrapInFunction(v, stmt);
|
WrapInFunction(v, stmt);
|
||||||
|
@ -340,7 +340,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_OuterScopeAfterInnerScope) {
|
||||||
auto* inner = Block(foo_i32_decl, bar_i32_decl);
|
auto* inner = Block(foo_i32_decl, bar_i32_decl);
|
||||||
|
|
||||||
// Declare f32 "foo" at function scope
|
// Declare f32 "foo" at function scope
|
||||||
auto* foo_f32 = Var("foo", ty.f32(), ast::StorageClass::kNone, Expr(2.f));
|
auto* foo_f32 = Var("foo", ty.f32(), ast::StorageClass::kNone, Expr(2_f));
|
||||||
auto* foo_f32_init = foo_f32->constructor;
|
auto* foo_f32_init = foo_f32->constructor;
|
||||||
auto* foo_f32_decl = Decl(foo_f32);
|
auto* foo_f32_decl = Decl(foo_f32);
|
||||||
|
|
||||||
|
@ -390,7 +390,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScopeAfterFunctionScope) {
|
||||||
Func("func_i32", params, ty.void_(), {fn_i32_decl}, ast::AttributeList{});
|
Func("func_i32", params, ty.void_(), {fn_i32_decl}, ast::AttributeList{});
|
||||||
|
|
||||||
// Declare f32 "foo" at module scope
|
// Declare f32 "foo" at module scope
|
||||||
auto* mod_f32 = Var("foo", ty.f32(), ast::StorageClass::kPrivate, Expr(2.f));
|
auto* mod_f32 = Var("foo", ty.f32(), ast::StorageClass::kPrivate, Expr(2_f));
|
||||||
auto* mod_init = mod_f32->constructor;
|
auto* mod_init = mod_f32->constructor;
|
||||||
AST().AddGlobalVariable(mod_f32);
|
AST().AddGlobalVariable(mod_f32);
|
||||||
|
|
||||||
|
@ -486,7 +486,7 @@ TEST_F(ResolverTest, Expr_Bitcast) {
|
||||||
|
|
||||||
TEST_F(ResolverTest, Expr_Call) {
|
TEST_F(ResolverTest, Expr_Call) {
|
||||||
ast::VariableList params;
|
ast::VariableList params;
|
||||||
Func("my_func", params, ty.f32(), {Return(0.0f)}, ast::AttributeList{});
|
Func("my_func", params, ty.f32(), {Return(0_f)}, ast::AttributeList{});
|
||||||
|
|
||||||
auto* call = Call("my_func");
|
auto* call = Call("my_func");
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
@ -499,7 +499,7 @@ TEST_F(ResolverTest, Expr_Call) {
|
||||||
|
|
||||||
TEST_F(ResolverTest, Expr_Call_InBinaryOp) {
|
TEST_F(ResolverTest, Expr_Call_InBinaryOp) {
|
||||||
ast::VariableList params;
|
ast::VariableList params;
|
||||||
Func("func", params, ty.f32(), {Return(0.0f)}, ast::AttributeList{});
|
Func("func", params, ty.f32(), {Return(0_f)}, ast::AttributeList{});
|
||||||
|
|
||||||
auto* expr = Add(Call("func"), Call("func"));
|
auto* expr = Add(Call("func"), Call("func"));
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
@ -513,10 +513,10 @@ TEST_F(ResolverTest, Expr_Call_InBinaryOp) {
|
||||||
TEST_F(ResolverTest, Expr_Call_WithParams) {
|
TEST_F(ResolverTest, Expr_Call_WithParams) {
|
||||||
Func("my_func", {Param(Sym(), ty.f32())}, ty.f32(),
|
Func("my_func", {Param(Sym(), ty.f32())}, ty.f32(),
|
||||||
{
|
{
|
||||||
Return(1.2f),
|
Return(1.2_f),
|
||||||
});
|
});
|
||||||
|
|
||||||
auto* param = Expr(2.4f);
|
auto* param = Expr(2.4_f);
|
||||||
|
|
||||||
auto* call = Call("my_func", param);
|
auto* call = Call("my_func", param);
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
@ -528,7 +528,7 @@ TEST_F(ResolverTest, Expr_Call_WithParams) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Expr_Call_Builtin) {
|
TEST_F(ResolverTest, Expr_Call_Builtin) {
|
||||||
auto* call = Call("round", 2.4f);
|
auto* call = Call("round", 2.4_f);
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -550,7 +550,7 @@ TEST_F(ResolverTest, Expr_Cast) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Expr_Constructor_Scalar) {
|
TEST_F(ResolverTest, Expr_Constructor_Scalar) {
|
||||||
auto* s = Expr(1.0f);
|
auto* s = Expr(1_f);
|
||||||
WrapInFunction(s);
|
WrapInFunction(s);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -560,7 +560,7 @@ TEST_F(ResolverTest, Expr_Constructor_Scalar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Expr_Constructor_Type_Vec2) {
|
TEST_F(ResolverTest, Expr_Constructor_Type_Vec2) {
|
||||||
auto* tc = vec2<f32>(1.0f, 1.0f);
|
auto* tc = vec2<f32>(1_f, 1_f);
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -572,7 +572,7 @@ TEST_F(ResolverTest, Expr_Constructor_Type_Vec2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Expr_Constructor_Type_Vec3) {
|
TEST_F(ResolverTest, Expr_Constructor_Type_Vec3) {
|
||||||
auto* tc = vec3<f32>(1.0f, 1.0f, 1.0f);
|
auto* tc = vec3<f32>(1_f, 1_f, 1_f);
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -584,7 +584,7 @@ TEST_F(ResolverTest, Expr_Constructor_Type_Vec3) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Expr_Constructor_Type_Vec4) {
|
TEST_F(ResolverTest, Expr_Constructor_Type_Vec4) {
|
||||||
auto* tc = vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f);
|
auto* tc = vec4<f32>(1_f, 1_f, 1_f, 1_f);
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -703,7 +703,7 @@ TEST_F(ResolverTest, Expr_Identifier_Function_Ptr) {
|
||||||
auto* p = Expr("p");
|
auto* p = Expr("p");
|
||||||
auto* v_decl = Decl(Var("v", ty.f32()));
|
auto* v_decl = Decl(Var("v", ty.f32()));
|
||||||
auto* p_decl = Decl(Let("p", ty.pointer<f32>(ast::StorageClass::kFunction), AddressOf(v)));
|
auto* p_decl = Decl(Let("p", ty.pointer<f32>(ast::StorageClass::kFunction), AddressOf(v)));
|
||||||
auto* assign = Assign(Deref(p), 1.23f);
|
auto* assign = Assign(Deref(p), 1.23_f);
|
||||||
Func("my_func", ast::VariableList{}, ty.void_(),
|
Func("my_func", ast::VariableList{}, ty.void_(),
|
||||||
{
|
{
|
||||||
v_decl,
|
v_decl,
|
||||||
|
@ -725,7 +725,7 @@ TEST_F(ResolverTest, Expr_Identifier_Function_Ptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Expr_Call_Function) {
|
TEST_F(ResolverTest, Expr_Call_Function) {
|
||||||
Func("my_func", ast::VariableList{}, ty.f32(), {Return(0.0f)}, ast::AttributeList{});
|
Func("my_func", ast::VariableList{}, ty.f32(), {Return(0_f)}, ast::AttributeList{});
|
||||||
|
|
||||||
auto* call = Call("my_func");
|
auto* call = Call("my_func");
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
@ -815,7 +815,7 @@ TEST_F(ResolverTest, Function_RegisterInputOutputVariables_SubFunction) {
|
||||||
|
|
||||||
Func("my_func", ast::VariableList{}, ty.f32(),
|
Func("my_func", ast::VariableList{}, ty.f32(),
|
||||||
{Assign("wg_var", "wg_var"), Assign("sb_var", "sb_var"), Assign("priv_var", "priv_var"),
|
{Assign("wg_var", "wg_var"), Assign("sb_var", "sb_var"), Assign("priv_var", "priv_var"),
|
||||||
Return(0.0f)},
|
Return(0_f)},
|
||||||
ast::AttributeList{});
|
ast::AttributeList{});
|
||||||
|
|
||||||
auto* func2 = Func("func", ast::VariableList{}, ty.void_(),
|
auto* func2 = Func("func", ast::VariableList{}, ty.void_(),
|
||||||
|
@ -841,7 +841,7 @@ TEST_F(ResolverTest, Function_NotRegisterFunctionVariable) {
|
||||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_(),
|
auto* func = Func("my_func", ast::VariableList{}, ty.void_(),
|
||||||
{
|
{
|
||||||
Decl(Var("var", ty.f32())),
|
Decl(Var("var", ty.f32())),
|
||||||
Assign("var", 1.f),
|
Assign("var", 1_f),
|
||||||
});
|
});
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1795,11 +1795,11 @@ TEST_F(ResolverTest, Function_EntryPoints_StageAttribute) {
|
||||||
Global("call_c", ty.f32(), ast::StorageClass::kPrivate);
|
Global("call_c", ty.f32(), ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
ast::VariableList params;
|
ast::VariableList params;
|
||||||
auto* func_b = Func("b", params, ty.f32(), {Return(0.0f)}, ast::AttributeList{});
|
auto* func_b = Func("b", params, ty.f32(), {Return(0_f)}, ast::AttributeList{});
|
||||||
auto* func_c = Func("c", params, ty.f32(), {Assign("second", Call("b")), Return(0.0f)},
|
auto* func_c = Func("c", params, ty.f32(), {Assign("second", Call("b")), Return(0_f)},
|
||||||
ast::AttributeList{});
|
ast::AttributeList{});
|
||||||
|
|
||||||
auto* func_a = Func("a", params, ty.f32(), {Assign("first", Call("c")), Return(0.0f)},
|
auto* func_a = Func("a", params, ty.f32(), {Assign("first", Call("c")), Return(0_f)},
|
||||||
ast::AttributeList{});
|
ast::AttributeList{});
|
||||||
|
|
||||||
auto* ep_1 = Func("ep_1", params, ty.void_(),
|
auto* ep_1 = Func("ep_1", params, ty.void_(),
|
||||||
|
@ -1959,7 +1959,7 @@ TEST_F(ResolverTest, TextureSampler_TextureSample) {
|
||||||
Global("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 1));
|
Global("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 1));
|
||||||
Global("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 2));
|
Global("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 2));
|
||||||
|
|
||||||
auto* call = CallStmt(Call("textureSample", "t", "s", vec2<f32>(1.0f, 2.0f)));
|
auto* call = CallStmt(Call("textureSample", "t", "s", vec2<f32>(1_f, 2_f)));
|
||||||
const ast::Function* f =
|
const ast::Function* f =
|
||||||
Func("test_function", {}, ty.void_(), {call}, {Stage(ast::PipelineStage::kFragment)});
|
Func("test_function", {}, ty.void_(), {call}, {Stage(ast::PipelineStage::kFragment)});
|
||||||
|
|
||||||
|
@ -1976,7 +1976,7 @@ TEST_F(ResolverTest, TextureSampler_TextureSampleInFunction) {
|
||||||
Global("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 1));
|
Global("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 1));
|
||||||
Global("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 2));
|
Global("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 2));
|
||||||
|
|
||||||
auto* inner_call = CallStmt(Call("textureSample", "t", "s", vec2<f32>(1.0f, 2.0f)));
|
auto* inner_call = CallStmt(Call("textureSample", "t", "s", vec2<f32>(1_f, 2_f)));
|
||||||
const ast::Function* inner_func = Func("inner_func", {}, ty.void_(), {inner_call});
|
const ast::Function* inner_func = Func("inner_func", {}, ty.void_(), {inner_call});
|
||||||
auto* outer_call = CallStmt(Call("inner_func"));
|
auto* outer_call = CallStmt(Call("inner_func"));
|
||||||
const ast::Function* outer_func =
|
const ast::Function* outer_func =
|
||||||
|
@ -1999,9 +1999,9 @@ TEST_F(ResolverTest, TextureSampler_TextureSampleFunctionDiamondSameVariables) {
|
||||||
Global("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 1));
|
Global("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 1));
|
||||||
Global("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 2));
|
Global("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 2));
|
||||||
|
|
||||||
auto* inner_call_1 = CallStmt(Call("textureSample", "t", "s", vec2<f32>(1.0f, 2.0f)));
|
auto* inner_call_1 = CallStmt(Call("textureSample", "t", "s", vec2<f32>(1_f, 2_f)));
|
||||||
const ast::Function* inner_func_1 = Func("inner_func_1", {}, ty.void_(), {inner_call_1});
|
const ast::Function* inner_func_1 = Func("inner_func_1", {}, ty.void_(), {inner_call_1});
|
||||||
auto* inner_call_2 = CallStmt(Call("textureSample", "t", "s", vec2<f32>(3.0f, 4.0f)));
|
auto* inner_call_2 = CallStmt(Call("textureSample", "t", "s", vec2<f32>(3_f, 4_f)));
|
||||||
const ast::Function* inner_func_2 = Func("inner_func_2", {}, ty.void_(), {inner_call_2});
|
const ast::Function* inner_func_2 = Func("inner_func_2", {}, ty.void_(), {inner_call_2});
|
||||||
auto* outer_call_1 = CallStmt(Call("inner_func_1"));
|
auto* outer_call_1 = CallStmt(Call("inner_func_1"));
|
||||||
auto* outer_call_2 = CallStmt(Call("inner_func_2"));
|
auto* outer_call_2 = CallStmt(Call("inner_func_2"));
|
||||||
|
@ -2032,9 +2032,9 @@ TEST_F(ResolverTest, TextureSampler_TextureSampleFunctionDiamondDifferentVariabl
|
||||||
Global("t2", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 2));
|
Global("t2", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 2));
|
||||||
Global("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 3));
|
Global("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 3));
|
||||||
|
|
||||||
auto* inner_call_1 = CallStmt(Call("textureSample", "t1", "s", vec2<f32>(1.0f, 2.0f)));
|
auto* inner_call_1 = CallStmt(Call("textureSample", "t1", "s", vec2<f32>(1_f, 2_f)));
|
||||||
const ast::Function* inner_func_1 = Func("inner_func_1", {}, ty.void_(), {inner_call_1});
|
const ast::Function* inner_func_1 = Func("inner_func_1", {}, ty.void_(), {inner_call_1});
|
||||||
auto* inner_call_2 = CallStmt(Call("textureSample", "t2", "s", vec2<f32>(3.0f, 4.0f)));
|
auto* inner_call_2 = CallStmt(Call("textureSample", "t2", "s", vec2<f32>(3_f, 4_f)));
|
||||||
const ast::Function* inner_func_2 = Func("inner_func_2", {}, ty.void_(), {inner_call_2});
|
const ast::Function* inner_func_2 = Func("inner_func_2", {}, ty.void_(), {inner_call_2});
|
||||||
auto* outer_call_1 = CallStmt(Call("inner_func_1"));
|
auto* outer_call_1 = CallStmt(Call("inner_func_1"));
|
||||||
auto* outer_call_2 = CallStmt(Call("inner_func_2"));
|
auto* outer_call_2 = CallStmt(Call("inner_func_2"));
|
||||||
|
|
|
@ -81,7 +81,7 @@ TEST_F(ResolverSourceVariableTest, GlobalTextureVar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverSourceVariableTest, GlobalOverride) {
|
TEST_F(ResolverSourceVariableTest, GlobalOverride) {
|
||||||
auto* a = Override("a", ty.f32(), Expr(1.f));
|
auto* a = Override("a", ty.f32(), Expr(1_f));
|
||||||
auto* expr = Expr(a);
|
auto* expr = Expr(a);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ TEST_F(ResolverSourceVariableTest, GlobalOverride) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverSourceVariableTest, GlobalConst) {
|
TEST_F(ResolverSourceVariableTest, GlobalConst) {
|
||||||
auto* a = GlobalConst("a", ty.f32(), Expr(1.f));
|
auto* a = GlobalConst("a", ty.f32(), Expr(1_f));
|
||||||
auto* expr = Expr(a);
|
auto* expr = Expr(a);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ TEST_F(ResolverSourceVariableTest, FunctionVar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverSourceVariableTest, FunctionLet) {
|
TEST_F(ResolverSourceVariableTest, FunctionLet) {
|
||||||
auto* a = Let("a", ty.f32(), Expr(1.f));
|
auto* a = Let("a", ty.f32(), Expr(1_f));
|
||||||
auto* expr = Expr(a);
|
auto* expr = Expr(a);
|
||||||
WrapInFunction(a, expr);
|
WrapInFunction(a, expr);
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ TEST_F(ResolverSourceVariableTest, ThroughPointers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverSourceVariableTest, Literal) {
|
TEST_F(ResolverSourceVariableTest, Literal) {
|
||||||
auto* expr = Expr(1.f);
|
auto* expr = Expr(1_f);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -259,7 +259,7 @@ TEST_F(ResolverSourceVariableTest, Literal) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverSourceVariableTest, FunctionReturnValue) {
|
TEST_F(ResolverSourceVariableTest, FunctionReturnValue) {
|
||||||
auto* expr = Call("min", 1.f, 2.f);
|
auto* expr = Call("min", 1_f, 2_f);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -269,7 +269,7 @@ TEST_F(ResolverSourceVariableTest, FunctionReturnValue) {
|
||||||
|
|
||||||
TEST_F(ResolverSourceVariableTest, BinaryExpression) {
|
TEST_F(ResolverSourceVariableTest, BinaryExpression) {
|
||||||
auto* a = Var("a", ty.f32(), ast::StorageClass::kNone);
|
auto* a = Var("a", ty.f32(), ast::StorageClass::kNone);
|
||||||
auto* expr = Add(a, Expr(1.f));
|
auto* expr = Add(a, Expr(1_f));
|
||||||
WrapInFunction(a, expr);
|
WrapInFunction(a, expr);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
|
@ -53,7 +53,7 @@ TEST_F(ResolverPipelineStageUseTest, StructUsedAsNonEntryPointParam) {
|
||||||
TEST_F(ResolverPipelineStageUseTest, StructUsedAsNonEntryPointReturnType) {
|
TEST_F(ResolverPipelineStageUseTest, StructUsedAsNonEntryPointReturnType) {
|
||||||
auto* s = Structure("S", {Member("a", ty.f32(), {Location(0)})});
|
auto* s = Structure("S", {Member("a", ty.f32(), {Location(0)})});
|
||||||
|
|
||||||
Func("foo", {}, ty.Of(s), {Return(Construct(ty.Of(s), Expr(0.f)))}, {});
|
Func("foo", {}, ty.Of(s), {Return(Construct(ty.Of(s), Expr(0_f)))}, {});
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ TEST_F(ResolverPipelineStageUseTest, StructUsedAsFragmentShaderParam) {
|
||||||
TEST_F(ResolverPipelineStageUseTest, StructUsedAsFragmentShaderReturnType) {
|
TEST_F(ResolverPipelineStageUseTest, StructUsedAsFragmentShaderReturnType) {
|
||||||
auto* s = Structure("S", {Member("a", ty.f32(), {Location(0)})});
|
auto* s = Structure("S", {Member("a", ty.f32(), {Location(0)})});
|
||||||
|
|
||||||
Func("main", {}, ty.Of(s), {Return(Construct(ty.Of(s), Expr(0.f)))},
|
Func("main", {}, ty.Of(s), {Return(Construct(ty.Of(s), Expr(0_f)))},
|
||||||
{Stage(ast::PipelineStage::kFragment)});
|
{Stage(ast::PipelineStage::kFragment)});
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -169,7 +169,7 @@ TEST_F(ResolverPipelineStageUseTest, StructUsedAsShaderReturnTypeViaAlias) {
|
||||||
auto* s = Structure("S", {Member("a", ty.f32(), {Location(0)})});
|
auto* s = Structure("S", {Member("a", ty.f32(), {Location(0)})});
|
||||||
auto* s_alias = Alias("S_alias", ty.Of(s));
|
auto* s_alias = Alias("S_alias", ty.Of(s));
|
||||||
|
|
||||||
Func("main", {}, ty.Of(s_alias), {Return(Construct(ty.Of(s_alias), Expr(0.f)))},
|
Func("main", {}, ty.Of(s_alias), {Return(Construct(ty.Of(s_alias), Expr(0_f)))},
|
||||||
{Stage(ast::PipelineStage::kFragment)});
|
{Stage(ast::PipelineStage::kFragment)});
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
|
@ -404,7 +404,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeConstructorValidationTest,
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, ConversionConstructorInvalid_TooManyInitializers) {
|
TEST_F(ResolverTypeConstructorValidationTest, ConversionConstructorInvalid_TooManyInitializers) {
|
||||||
auto* a = Var("a", ty.f32(), ast::StorageClass::kNone,
|
auto* a = Var("a", ty.f32(), ast::StorageClass::kNone,
|
||||||
Construct(Source{{12, 34}}, ty.f32(), Expr(1.0f), Expr(2.0f)));
|
Construct(Source{{12, 34}}, ty.f32(), Expr(1_f), Expr(2_f)));
|
||||||
WrapInFunction(a);
|
WrapInFunction(a);
|
||||||
|
|
||||||
ASSERT_FALSE(r()->Resolve());
|
ASSERT_FALSE(r()->Resolve());
|
||||||
|
@ -463,7 +463,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Array_type_match)
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Array_type_Mismatch_U32F32) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Array_type_Mismatch_U32F32) {
|
||||||
// array<u32, 3u>(0u, 1.0f, 20u);
|
// array<u32, 3u>(0u, 1.0f, 20u);
|
||||||
auto* tc = array<u32, 3>(Expr(0_u), Expr(Source{{12, 34}}, 1.0f), Expr(20_u));
|
auto* tc = array<u32, 3>(Expr(0_u), Expr(Source{{12, 34}}, 1_f), Expr(20_u));
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -650,7 +650,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Construct_u32_Success) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Construct_f32_Success) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Construct_f32_Success) {
|
||||||
auto* expr = Construct<f32>(Expr(1.23f));
|
auto* expr = Construct<f32>(Expr(1.23_f));
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -668,7 +668,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Construct_f32_Success) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Convert_f32_to_i32_Success) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Convert_f32_to_i32_Success) {
|
||||||
auto* expr = Construct<i32>(1.23f);
|
auto* expr = Construct<i32>(1.23_f);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -727,7 +727,7 @@ namespace VectorConstructor {
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest,
|
TEST_F(ResolverTypeConstructorValidationTest,
|
||||||
Expr_Constructor_Vec2F32_Error_ScalarArgumentTypeMismatch) {
|
Expr_Constructor_Vec2F32_Error_ScalarArgumentTypeMismatch) {
|
||||||
auto* tc = vec2<f32>(Expr(Source{{12, 34}}, 1_i), 1.0f);
|
auto* tc = vec2<f32>(Expr(Source{{12, 34}}, 1_i), 1_f);
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -788,8 +788,8 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec2_Error_TooManyArgumentsScalar) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec2_Error_TooManyArgumentsScalar) {
|
||||||
auto* tc = vec2<f32>(Expr(Source{{12, 34}}, 1.0f), Expr(Source{{12, 40}}, 1.0f),
|
auto* tc = vec2<f32>(Expr(Source{{12, 34}}, 1_f), Expr(Source{{12, 40}}, 1_f),
|
||||||
Expr(Source{{12, 46}}, 1.0f));
|
Expr(Source{{12, 46}}, 1_f));
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -807,7 +807,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec2_Error_TooMan
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest,
|
TEST_F(ResolverTypeConstructorValidationTest,
|
||||||
Expr_Constructor_Vec2_Error_TooManyArgumentsVectorAndScalar) {
|
Expr_Constructor_Vec2_Error_TooManyArgumentsVectorAndScalar) {
|
||||||
auto* tc = vec2<f32>(Construct(Source{{12, 34}}, ty.vec2<f32>()), Expr(Source{{12, 40}}, 1.0f));
|
auto* tc = vec2<f32>(Construct(Source{{12, 34}}, ty.vec2<f32>()), Expr(Source{{12, 40}}, 1_f));
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -844,7 +844,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec2_Success_Zero
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec2F32_Success_Scalar) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec2F32_Success_Scalar) {
|
||||||
auto* tc = vec2<f32>(1.0f, 1.0f);
|
auto* tc = vec2<f32>(1_f, 1_f);
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -969,7 +969,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec2_Success_Vec2
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest,
|
TEST_F(ResolverTypeConstructorValidationTest,
|
||||||
Expr_Constructor_Vec3F32_Error_ScalarArgumentTypeMismatch) {
|
Expr_Constructor_Vec3F32_Error_ScalarArgumentTypeMismatch) {
|
||||||
auto* tc = vec3<f32>(1.0f, 1.0f, Expr(Source{{12, 34}}, 1_i));
|
auto* tc = vec3<f32>(1_f, 1_f, Expr(Source{{12, 34}}, 1_i));
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1021,7 +1021,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Error_TooFewArgumentsScalar) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Error_TooFewArgumentsScalar) {
|
||||||
auto* tc = vec3<f32>(Expr(Source{{12, 34}}, 1.0f), Expr(Source{{12, 40}}, 1.0f));
|
auto* tc = vec3<f32>(Expr(Source{{12, 34}}, 1_f), Expr(Source{{12, 40}}, 1_f));
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1029,8 +1029,8 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Error_TooFew
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Error_TooManyArgumentsScalar) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Error_TooManyArgumentsScalar) {
|
||||||
auto* tc = vec3<f32>(Expr(Source{{12, 34}}, 1.0f), Expr(Source{{12, 40}}, 1.0f),
|
auto* tc = vec3<f32>(Expr(Source{{12, 34}}, 1_f), Expr(Source{{12, 40}}, 1_f),
|
||||||
Expr(Source{{12, 46}}, 1.0f), Expr(Source{{12, 52}}, 1.0f));
|
Expr(Source{{12, 46}}, 1_f), Expr(Source{{12, 52}}, 1_f));
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1056,8 +1056,8 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Error_TooMan
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest,
|
TEST_F(ResolverTypeConstructorValidationTest,
|
||||||
Expr_Constructor_Vec3_Error_TooManyArgumentsVec2AndScalar) {
|
Expr_Constructor_Vec3_Error_TooManyArgumentsVec2AndScalar) {
|
||||||
auto* tc = vec3<f32>(Construct(Source{{12, 34}}, ty.vec2<f32>()), Expr(Source{{12, 40}}, 1.0f),
|
auto* tc = vec3<f32>(Construct(Source{{12, 34}}, ty.vec2<f32>()), Expr(Source{{12, 40}}, 1_f),
|
||||||
Expr(Source{{12, 46}}, 1.0f));
|
Expr(Source{{12, 46}}, 1_f));
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1065,7 +1065,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Error_TooManyArgumentsVec3) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Error_TooManyArgumentsVec3) {
|
||||||
auto* tc = vec3<f32>(Construct(Source{{12, 34}}, ty.vec3<f32>()), Expr(Source{{12, 40}}, 1.0f));
|
auto* tc = vec3<f32>(Construct(Source{{12, 34}}, ty.vec3<f32>()), Expr(Source{{12, 40}}, 1_f));
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1102,7 +1102,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Success_Zero
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3F32_Success_Scalar) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3F32_Success_Scalar) {
|
||||||
auto* tc = vec3<f32>(1.0f, 1.0f, 1.0f);
|
auto* tc = vec3<f32>(1_f, 1_f, 1_f);
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1190,7 +1190,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3Bool_Success_
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Success_Vec2AndScalar) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Success_Vec2AndScalar) {
|
||||||
auto* tc = vec3<f32>(vec2<f32>(), 1.0f);
|
auto* tc = vec3<f32>(vec2<f32>(), 1_f);
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1211,7 +1211,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Success_Vec2
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Success_ScalarAndVec2) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Success_ScalarAndVec2) {
|
||||||
auto* tc = vec3<f32>(1.0f, vec2<f32>());
|
auto* tc = vec3<f32>(1_f, vec2<f32>());
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1273,7 +1273,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Success_Vec3
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest,
|
TEST_F(ResolverTypeConstructorValidationTest,
|
||||||
Expr_Constructor_Vec4F32_Error_ScalarArgumentTypeMismatch) {
|
Expr_Constructor_Vec4F32_Error_ScalarArgumentTypeMismatch) {
|
||||||
auto* tc = vec4<f32>(1.0f, 1.0f, Expr(Source{{12, 34}}, 1_i), 1.0f);
|
auto* tc = vec4<f32>(1_f, 1_f, Expr(Source{{12, 34}}, 1_i), 1_f);
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1316,8 +1316,8 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Error_TooFewArgumentsScalar) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Error_TooFewArgumentsScalar) {
|
||||||
auto* tc = vec4<f32>(Expr(Source{{12, 34}}, 1.0f), Expr(Source{{12, 40}}, 1.0f),
|
auto* tc = vec4<f32>(Expr(Source{{12, 34}}, 1_f), Expr(Source{{12, 40}}, 1_f),
|
||||||
Expr(Source{{12, 46}}, 1.0f));
|
Expr(Source{{12, 46}}, 1_f));
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1325,9 +1325,9 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Error_TooFew
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Error_TooManyArgumentsScalar) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Error_TooManyArgumentsScalar) {
|
||||||
auto* tc = vec4<f32>(Expr(Source{{12, 34}}, 1.0f), Expr(Source{{12, 40}}, 1.0f),
|
auto* tc = vec4<f32>(Expr(Source{{12, 34}}, 1_f), Expr(Source{{12, 40}}, 1_f),
|
||||||
Expr(Source{{12, 46}}, 1.0f), Expr(Source{{12, 52}}, 1.0f),
|
Expr(Source{{12, 46}}, 1_f), Expr(Source{{12, 52}}, 1_f),
|
||||||
Expr(Source{{12, 58}}, 1.0f));
|
Expr(Source{{12, 58}}, 1_f));
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1336,7 +1336,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Error_TooMan
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest,
|
TEST_F(ResolverTypeConstructorValidationTest,
|
||||||
Expr_Constructor_Vec4_Error_TooFewArgumentsVec2AndScalar) {
|
Expr_Constructor_Vec4_Error_TooFewArgumentsVec2AndScalar) {
|
||||||
auto* tc = vec4<f32>(Construct(Source{{12, 34}}, ty.vec2<f32>()), Expr(Source{{12, 40}}, 1.0f));
|
auto* tc = vec4<f32>(Construct(Source{{12, 34}}, ty.vec2<f32>()), Expr(Source{{12, 40}}, 1_f));
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1345,8 +1345,8 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest,
|
TEST_F(ResolverTypeConstructorValidationTest,
|
||||||
Expr_Constructor_Vec4_Error_TooManyArgumentsVec2AndScalars) {
|
Expr_Constructor_Vec4_Error_TooManyArgumentsVec2AndScalars) {
|
||||||
auto* tc = vec4<f32>(Construct(Source{{12, 34}}, ty.vec2<f32>()), Expr(Source{{12, 40}}, 1.0f),
|
auto* tc = vec4<f32>(Construct(Source{{12, 34}}, ty.vec2<f32>()), Expr(Source{{12, 40}}, 1_f),
|
||||||
Expr(Source{{12, 46}}, 1.0f), Expr(Source{{12, 52}}, 1.0f));
|
Expr(Source{{12, 46}}, 1_f), Expr(Source{{12, 52}}, 1_f));
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1356,7 +1356,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||||
TEST_F(ResolverTypeConstructorValidationTest,
|
TEST_F(ResolverTypeConstructorValidationTest,
|
||||||
Expr_Constructor_Vec4_Error_TooManyArgumentsVec2Vec2Scalar) {
|
Expr_Constructor_Vec4_Error_TooManyArgumentsVec2Vec2Scalar) {
|
||||||
auto* tc = vec4<f32>(Construct(Source{{12, 34}}, ty.vec2<f32>()),
|
auto* tc = vec4<f32>(Construct(Source{{12, 34}}, ty.vec2<f32>()),
|
||||||
Construct(Source{{12, 40}}, ty.vec2<f32>()), Expr(Source{{12, 46}}, 1.0f));
|
Construct(Source{{12, 40}}, ty.vec2<f32>()), Expr(Source{{12, 46}}, 1_f));
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1384,8 +1384,8 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Error_TooFew
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest,
|
TEST_F(ResolverTypeConstructorValidationTest,
|
||||||
Expr_Constructor_Vec4_Error_TooManyArgumentsVec3AndScalars) {
|
Expr_Constructor_Vec4_Error_TooManyArgumentsVec3AndScalars) {
|
||||||
auto* tc = vec4<f32>(Construct(Source{{12, 34}}, ty.vec3<f32>()), Expr(Source{{12, 40}}, 1.0f),
|
auto* tc = vec4<f32>(Construct(Source{{12, 34}}, ty.vec3<f32>()), Expr(Source{{12, 40}}, 1_f),
|
||||||
Expr(Source{{12, 46}}, 1.0f));
|
Expr(Source{{12, 46}}, 1_f));
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1445,7 +1445,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_Zero
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4F32_Success_Scalar) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4F32_Success_Scalar) {
|
||||||
auto* tc = vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f);
|
auto* tc = vec4<f32>(1_f, 1_f, 1_f, 1_f);
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1493,7 +1493,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4Bool_Success_
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_Vec2ScalarScalar) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_Vec2ScalarScalar) {
|
||||||
auto* tc = vec4<f32>(vec2<f32>(), 1.0f, 1.0f);
|
auto* tc = vec4<f32>(vec2<f32>(), 1_f, 1_f);
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1505,7 +1505,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_Vec2
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_ScalarVec2Scalar) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_ScalarVec2Scalar) {
|
||||||
auto* tc = vec4<f32>(1.0f, vec2<f32>(), 1.0f);
|
auto* tc = vec4<f32>(1_f, vec2<f32>(), 1_f);
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1517,7 +1517,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_Scal
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_ScalarScalarVec2) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_ScalarScalarVec2) {
|
||||||
auto* tc = vec4<f32>(1.0f, 1.0f, vec2<f32>());
|
auto* tc = vec4<f32>(1_f, 1_f, vec2<f32>());
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1541,7 +1541,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_Vec2
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_Vec3AndScalar) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_Vec3AndScalar) {
|
||||||
auto* tc = vec4<f32>(vec3<f32>(), 1.0f);
|
auto* tc = vec4<f32>(vec3<f32>(), 1_f);
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1553,7 +1553,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_Vec3
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_ScalarAndVec3) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_ScalarAndVec3) {
|
||||||
auto* tc = vec4<f32>(1.0f, vec3<f32>());
|
auto* tc = vec4<f32>(1_f, vec3<f32>());
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1590,10 +1590,9 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_Vec4
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest,
|
TEST_F(ResolverTypeConstructorValidationTest,
|
||||||
Expr_Constructor_NestedVectorConstructors_InnerError) {
|
Expr_Constructor_NestedVectorConstructors_InnerError) {
|
||||||
auto* tc =
|
auto* tc = vec4<f32>(
|
||||||
vec4<f32>(vec4<f32>(1.0f, 1.0f,
|
vec4<f32>(1_f, 1_f, vec3<f32>(Expr(Source{{12, 34}}, 1_f), Expr(Source{{12, 34}}, 1_f))),
|
||||||
vec3<f32>(Expr(Source{{12, 34}}, 1.0f), Expr(Source{{12, 34}}, 1.0f))),
|
1_f);
|
||||||
1.0f);
|
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1601,7 +1600,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_NestedVectorConstructors_Success) {
|
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_NestedVectorConstructors_Success) {
|
||||||
auto* tc = vec4<f32>(vec3<f32>(vec2<f32>(1.0f, 1.0f), 1.0f), 1.0f);
|
auto* tc = vec4<f32>(vec3<f32>(vec2<f32>(1_f, 1_f), 1_f), 1_f);
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1641,7 +1640,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vector_ElementTyp
|
||||||
|
|
||||||
// vec2<Float32>(1.0f, 1u)
|
// vec2<Float32>(1.0f, 1u)
|
||||||
auto* vec_type = ty.vec(ty.Of(f32_alias), 2);
|
auto* vec_type = ty.vec(ty.Of(f32_alias), 2);
|
||||||
auto* tc = Construct(Source{{12, 34}}, vec_type, 1.0f, Expr(Source{{12, 40}}, 1_u));
|
auto* tc = Construct(Source{{12, 34}}, vec_type, 1_f, Expr(Source{{12, 40}}, 1_u));
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1655,7 +1654,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vector_ElementTyp
|
||||||
|
|
||||||
// vec2<Float32>(1.0f, 1.0f)
|
// vec2<Float32>(1.0f, 1.0f)
|
||||||
auto* vec_type = ty.vec(ty.Of(f32_alias), 2);
|
auto* vec_type = ty.vec(ty.Of(f32_alias), 2);
|
||||||
auto* tc = Construct(Source{{12, 34}}, vec_type, 1.0f, 1.0f);
|
auto* tc = Construct(Source{{12, 34}}, vec_type, 1_f, 1_f);
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1667,7 +1666,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||||
|
|
||||||
// vec3<u32>(vec<Float32>(), 1.0f)
|
// vec3<u32>(vec<Float32>(), 1.0f)
|
||||||
auto* vec_type = ty.vec(ty.Of(f32_alias), 2);
|
auto* vec_type = ty.vec(ty.Of(f32_alias), 2);
|
||||||
auto* tc = vec3<u32>(Construct(Source{{12, 34}}, vec_type), 1.0f);
|
auto* tc = vec3<u32>(Construct(Source{{12, 34}}, vec_type), 1_f);
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1682,7 +1681,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||||
|
|
||||||
// vec3<f32>(vec<Float32>(), 1.0f)
|
// vec3<f32>(vec<Float32>(), 1.0f)
|
||||||
auto* vec_type = ty.vec(ty.Of(f32_alias), 2);
|
auto* vec_type = ty.vec(ty.Of(f32_alias), 2);
|
||||||
auto* tc = vec3<f32>(Construct(Source{{12, 34}}, vec_type), 1.0f);
|
auto* tc = vec3<f32>(Construct(Source{{12, 34}}, vec_type), 1_f);
|
||||||
WrapInFunction(tc);
|
WrapInFunction(tc);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1692,7 +1691,7 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec2ElementTypeFromScalars) {
|
||||||
auto* vec2_bool = Construct(create<ast::Vector>(nullptr, 2), Expr(true), Expr(false));
|
auto* vec2_bool = Construct(create<ast::Vector>(nullptr, 2), Expr(true), Expr(false));
|
||||||
auto* vec2_i32 = Construct(create<ast::Vector>(nullptr, 2), Expr(1_i), Expr(2_i));
|
auto* vec2_i32 = Construct(create<ast::Vector>(nullptr, 2), Expr(1_i), Expr(2_i));
|
||||||
auto* vec2_u32 = Construct(create<ast::Vector>(nullptr, 2), Expr(1_u), Expr(2_u));
|
auto* vec2_u32 = Construct(create<ast::Vector>(nullptr, 2), Expr(1_u), Expr(2_u));
|
||||||
auto* vec2_f32 = Construct(create<ast::Vector>(nullptr, 2), Expr(1.0f), Expr(2.0f));
|
auto* vec2_f32 = Construct(create<ast::Vector>(nullptr, 2), Expr(1_f), Expr(2_f));
|
||||||
WrapInFunction(vec2_bool, vec2_i32, vec2_u32, vec2_f32);
|
WrapInFunction(vec2_bool, vec2_i32, vec2_u32, vec2_f32);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1719,7 +1718,7 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec2ElementTypeFromVec2) {
|
||||||
auto* vec2_bool = Construct(create<ast::Vector>(nullptr, 2), vec2<bool>(true, false));
|
auto* vec2_bool = Construct(create<ast::Vector>(nullptr, 2), vec2<bool>(true, false));
|
||||||
auto* vec2_i32 = Construct(create<ast::Vector>(nullptr, 2), vec2<i32>(1_i, 2_i));
|
auto* vec2_i32 = Construct(create<ast::Vector>(nullptr, 2), vec2<i32>(1_i, 2_i));
|
||||||
auto* vec2_u32 = Construct(create<ast::Vector>(nullptr, 2), vec2<u32>(1_u, 2_u));
|
auto* vec2_u32 = Construct(create<ast::Vector>(nullptr, 2), vec2<u32>(1_u, 2_u));
|
||||||
auto* vec2_f32 = Construct(create<ast::Vector>(nullptr, 2), vec2<f32>(1.0f, 2.0f));
|
auto* vec2_f32 = Construct(create<ast::Vector>(nullptr, 2), vec2<f32>(1_f, 2_f));
|
||||||
WrapInFunction(vec2_bool, vec2_i32, vec2_u32, vec2_f32);
|
WrapInFunction(vec2_bool, vec2_i32, vec2_u32, vec2_f32);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1747,7 +1746,7 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromScalars) {
|
||||||
Construct(create<ast::Vector>(nullptr, 3), Expr(true), Expr(false), Expr(true));
|
Construct(create<ast::Vector>(nullptr, 3), Expr(true), Expr(false), Expr(true));
|
||||||
auto* vec3_i32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_i), Expr(2_i), Expr(3_i));
|
auto* vec3_i32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_i), Expr(2_i), Expr(3_i));
|
||||||
auto* vec3_u32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_u), Expr(2_u), Expr(3_u));
|
auto* vec3_u32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_u), Expr(2_u), Expr(3_u));
|
||||||
auto* vec3_f32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1.0f), Expr(2.0f), Expr(3.0f));
|
auto* vec3_f32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_f), Expr(2_f), Expr(3_f));
|
||||||
WrapInFunction(vec3_bool, vec3_i32, vec3_u32, vec3_f32);
|
WrapInFunction(vec3_bool, vec3_i32, vec3_u32, vec3_f32);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1774,7 +1773,7 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromVec3) {
|
||||||
auto* vec3_bool = Construct(create<ast::Vector>(nullptr, 3), vec3<bool>(true, false, true));
|
auto* vec3_bool = Construct(create<ast::Vector>(nullptr, 3), vec3<bool>(true, false, true));
|
||||||
auto* vec3_i32 = Construct(create<ast::Vector>(nullptr, 3), vec3<i32>(1_i, 2_i, 3_i));
|
auto* vec3_i32 = Construct(create<ast::Vector>(nullptr, 3), vec3<i32>(1_i, 2_i, 3_i));
|
||||||
auto* vec3_u32 = Construct(create<ast::Vector>(nullptr, 3), vec3<u32>(1_u, 2_u, 3_u));
|
auto* vec3_u32 = Construct(create<ast::Vector>(nullptr, 3), vec3<u32>(1_u, 2_u, 3_u));
|
||||||
auto* vec3_f32 = Construct(create<ast::Vector>(nullptr, 3), vec3<f32>(1.0f, 2.0f, 3.0f));
|
auto* vec3_f32 = Construct(create<ast::Vector>(nullptr, 3), vec3<f32>(1_f, 2_f, 3_f));
|
||||||
WrapInFunction(vec3_bool, vec3_i32, vec3_u32, vec3_f32);
|
WrapInFunction(vec3_bool, vec3_i32, vec3_u32, vec3_f32);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1802,7 +1801,7 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromScalarAndV
|
||||||
Construct(create<ast::Vector>(nullptr, 3), Expr(true), vec2<bool>(false, true));
|
Construct(create<ast::Vector>(nullptr, 3), Expr(true), vec2<bool>(false, true));
|
||||||
auto* vec3_i32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_i), vec2<i32>(2_i, 3_i));
|
auto* vec3_i32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_i), vec2<i32>(2_i, 3_i));
|
||||||
auto* vec3_u32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_u), vec2<u32>(2_u, 3_u));
|
auto* vec3_u32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_u), vec2<u32>(2_u, 3_u));
|
||||||
auto* vec3_f32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1.0f), vec2<f32>(2.0f, 3.0f));
|
auto* vec3_f32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_f), vec2<f32>(2_f, 3_f));
|
||||||
WrapInFunction(vec3_bool, vec3_i32, vec3_u32, vec3_f32);
|
WrapInFunction(vec3_bool, vec3_i32, vec3_u32, vec3_f32);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1833,7 +1832,7 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromScalars) {
|
||||||
auto* vec4_u32 =
|
auto* vec4_u32 =
|
||||||
Construct(create<ast::Vector>(nullptr, 4), Expr(1_u), Expr(2_u), Expr(3_u), Expr(4_u));
|
Construct(create<ast::Vector>(nullptr, 4), Expr(1_u), Expr(2_u), Expr(3_u), Expr(4_u));
|
||||||
auto* vec4_f32 =
|
auto* vec4_f32 =
|
||||||
Construct(create<ast::Vector>(nullptr, 4), Expr(1.0f), Expr(2.0f), Expr(3.0f), Expr(4.0f));
|
Construct(create<ast::Vector>(nullptr, 4), Expr(1_f), Expr(2_f), Expr(3_f), Expr(4_f));
|
||||||
WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32);
|
WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1861,7 +1860,7 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromVec4) {
|
||||||
Construct(create<ast::Vector>(nullptr, 4), vec4<bool>(true, false, true, false));
|
Construct(create<ast::Vector>(nullptr, 4), vec4<bool>(true, false, true, false));
|
||||||
auto* vec4_i32 = Construct(create<ast::Vector>(nullptr, 4), vec4<i32>(1_i, 2_i, 3_i, 4_i));
|
auto* vec4_i32 = Construct(create<ast::Vector>(nullptr, 4), vec4<i32>(1_i, 2_i, 3_i, 4_i));
|
||||||
auto* vec4_u32 = Construct(create<ast::Vector>(nullptr, 4), vec4<u32>(1_u, 2_u, 3_u, 4_u));
|
auto* vec4_u32 = Construct(create<ast::Vector>(nullptr, 4), vec4<u32>(1_u, 2_u, 3_u, 4_u));
|
||||||
auto* vec4_f32 = Construct(create<ast::Vector>(nullptr, 4), vec4<f32>(1.0f, 2.0f, 3.0f, 4.0f));
|
auto* vec4_f32 = Construct(create<ast::Vector>(nullptr, 4), vec4<f32>(1_f, 2_f, 3_f, 4_f));
|
||||||
WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32);
|
WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1892,7 +1891,7 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromScalarAndV
|
||||||
auto* vec4_u32 =
|
auto* vec4_u32 =
|
||||||
Construct(create<ast::Vector>(nullptr, 4), Expr(1_u), vec3<u32>(2_u, 3_u, 4_u));
|
Construct(create<ast::Vector>(nullptr, 4), Expr(1_u), vec3<u32>(2_u, 3_u, 4_u));
|
||||||
auto* vec4_f32 =
|
auto* vec4_f32 =
|
||||||
Construct(create<ast::Vector>(nullptr, 4), Expr(1.0f), vec3<f32>(2.0f, 3.0f, 4.0f));
|
Construct(create<ast::Vector>(nullptr, 4), Expr(1_f), vec3<f32>(2_f, 3_f, 4_f));
|
||||||
WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32);
|
WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1923,7 +1922,7 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromVec2AndVec
|
||||||
auto* vec4_u32 =
|
auto* vec4_u32 =
|
||||||
Construct(create<ast::Vector>(nullptr, 4), vec2<u32>(1_u, 2_u), vec2<u32>(3_u, 4_u));
|
Construct(create<ast::Vector>(nullptr, 4), vec2<u32>(1_u, 2_u), vec2<u32>(3_u, 4_u));
|
||||||
auto* vec4_f32 =
|
auto* vec4_f32 =
|
||||||
Construct(create<ast::Vector>(nullptr, 4), vec2<f32>(1.0f, 2.0f), vec2<f32>(3.0f, 4.0f));
|
Construct(create<ast::Vector>(nullptr, 4), vec2<f32>(1_f, 2_f), vec2<f32>(3_f, 4_f));
|
||||||
WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32);
|
WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32);
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
@ -1984,7 +1983,7 @@ TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec3ElementTypeFromScal
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec3ElementTypeFromScalarAndVec2Mismatch) {
|
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec3ElementTypeFromScalarAndVec2Mismatch) {
|
||||||
WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 3),
|
WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 3),
|
||||||
Expr(Source{{1, 2}}, 1_i), //
|
Expr(Source{{1, 2}}, 1_i), //
|
||||||
Construct(Source{{1, 3}}, ty.vec2<f32>(), 2.0f, 3.0f)));
|
Construct(Source{{1, 3}}, ty.vec2<f32>(), 2_f, 3_f)));
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
|
@ -1996,9 +1995,9 @@ TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec3ElementTypeFromScal
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromScalarsMismatch) {
|
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromScalarsMismatch) {
|
||||||
WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 4),
|
WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 4),
|
||||||
Expr(Source{{1, 2}}, 1_i), //
|
Expr(Source{{1, 2}}, 1_i), //
|
||||||
Expr(Source{{1, 3}}, 2_i), //
|
Expr(Source{{1, 3}}, 2_i), //
|
||||||
Expr(Source{{1, 4}}, 3.0f), //
|
Expr(Source{{1, 4}}, 3_f), //
|
||||||
Expr(Source{{1, 5}}, 4_i)));
|
Expr(Source{{1, 5}}, 4_i)));
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -2720,7 +2719,7 @@ TEST_F(ResolverTypeConstructorValidationTest, NonConstructibleType_Sampler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeConstructorValidationTest, TypeConstructorAsStatement) {
|
TEST_F(ResolverTypeConstructorValidationTest, TypeConstructorAsStatement) {
|
||||||
WrapInFunction(CallStmt(Construct(Source{{12, 34}}, ty.vec2<f32>(), 1.f, 2.f)));
|
WrapInFunction(CallStmt(Construct(Source{{12, 34}}, ty.vec2<f32>(), 1_f, 2_f)));
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
EXPECT_EQ(r()->error(), "12:34 error: type constructor evaluated but not used");
|
EXPECT_EQ(r()->error(), "12:34 error: type constructor evaluated but not used");
|
||||||
|
|
|
@ -91,7 +91,7 @@ TEST_F(ResolverTypeValidationTest, GlobalConstantWithStorageClass_Fail) {
|
||||||
// const<private> global_var: f32;
|
// const<private> global_var: f32;
|
||||||
AST().AddGlobalVariable(create<ast::Variable>(
|
AST().AddGlobalVariable(create<ast::Variable>(
|
||||||
Source{{12, 34}}, Symbols().Register("global_var"), ast::StorageClass::kPrivate,
|
Source{{12, 34}}, Symbols().Register("global_var"), ast::StorageClass::kPrivate,
|
||||||
ast::Access::kUndefined, ty.f32(), true, false, Expr(1.23f), ast::AttributeList{}));
|
ast::Access::kUndefined, ty.f32(), true, false, Expr(1.23_f), ast::AttributeList{}));
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
EXPECT_EQ(r()->error(), "12:34 error: global constants shouldn't have a storage class");
|
EXPECT_EQ(r()->error(), "12:34 error: global constants shouldn't have a storage class");
|
||||||
|
@ -108,9 +108,9 @@ TEST_F(ResolverTypeValidationTest, GlobalVariableUnique_Pass) {
|
||||||
// var global_var0 : f32 = 0.1;
|
// var global_var0 : f32 = 0.1;
|
||||||
// var global_var1 : i32 = 0;
|
// var global_var1 : i32 = 0;
|
||||||
|
|
||||||
Global("global_var0", ty.f32(), ast::StorageClass::kPrivate, Expr(0.1f));
|
Global("global_var0", ty.f32(), ast::StorageClass::kPrivate, Expr(0.1_f));
|
||||||
|
|
||||||
Global(Source{{12, 34}}, "global_var1", ty.f32(), ast::StorageClass::kPrivate, Expr(1.0f));
|
Global(Source{{12, 34}}, "global_var1", ty.f32(), ast::StorageClass::kPrivate, Expr(1_f));
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
@ -121,11 +121,11 @@ TEST_F(ResolverTypeValidationTest, GlobalVariableFunctionVariableNotUnique_Pass)
|
||||||
// }
|
// }
|
||||||
// var a: f32 = 2.1;
|
// var a: f32 = 2.1;
|
||||||
|
|
||||||
auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2.0f));
|
auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2_f));
|
||||||
|
|
||||||
Func("my_func", ast::VariableList{}, ty.void_(), {Decl(var)});
|
Func("my_func", ast::VariableList{}, ty.void_(), {Decl(var)});
|
||||||
|
|
||||||
Global("a", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1f));
|
Global("a", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1_f));
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
@ -135,12 +135,12 @@ TEST_F(ResolverTypeValidationTest, RedeclaredIdentifierInnerScope_Pass) {
|
||||||
// if (true) { var a : f32 = 2.0; }
|
// if (true) { var a : f32 = 2.0; }
|
||||||
// var a : f32 = 3.14;
|
// var a : f32 = 3.14;
|
||||||
// }
|
// }
|
||||||
auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2.0f));
|
auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2_f));
|
||||||
|
|
||||||
auto* cond = Expr(true);
|
auto* cond = Expr(true);
|
||||||
auto* body = Block(Decl(var));
|
auto* body = Block(Decl(var));
|
||||||
|
|
||||||
auto* var_a_float = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(3.1f));
|
auto* var_a_float = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(3.1_f));
|
||||||
|
|
||||||
auto* outer_body = Block(If(cond, body), Decl(Source{{12, 34}}, var_a_float));
|
auto* outer_body = Block(If(cond, body), Decl(Source{{12, 34}}, var_a_float));
|
||||||
|
|
||||||
|
@ -168,9 +168,9 @@ TEST_F(ResolverTypeValidationTest, RedeclaredIdentifierInnerScopeBlock_Pass) {
|
||||||
TEST_F(ResolverTypeValidationTest, RedeclaredIdentifierDifferentFunctions_Pass) {
|
TEST_F(ResolverTypeValidationTest, RedeclaredIdentifierDifferentFunctions_Pass) {
|
||||||
// func0 { var a : f32 = 2.0; return; }
|
// func0 { var a : f32 = 2.0; return; }
|
||||||
// func1 { var a : f32 = 3.0; return; }
|
// func1 { var a : f32 = 3.0; return; }
|
||||||
auto* var0 = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2.0f));
|
auto* var0 = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2_f));
|
||||||
|
|
||||||
auto* var1 = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(1.0f));
|
auto* var1 = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(1_f));
|
||||||
|
|
||||||
Func("func0", ast::VariableList{}, ty.void_(),
|
Func("func0", ast::VariableList{}, ty.void_(),
|
||||||
ast::StatementList{
|
ast::StatementList{
|
||||||
|
@ -266,7 +266,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_SignedConstant_Negative) {
|
||||||
|
|
||||||
TEST_F(ResolverTypeValidationTest, ArraySize_FloatLiteral) {
|
TEST_F(ResolverTypeValidationTest, ArraySize_FloatLiteral) {
|
||||||
// var<private> a : array<f32, 10.0>;
|
// var<private> a : array<f32, 10.0>;
|
||||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 10.f)), ast::StorageClass::kPrivate);
|
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 10_f)), ast::StorageClass::kPrivate);
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
EXPECT_EQ(r()->error(), "12:34 error: array size must be integer scalar");
|
EXPECT_EQ(r()->error(), "12:34 error: array size must be integer scalar");
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_IVecLiteral) {
|
||||||
TEST_F(ResolverTypeValidationTest, ArraySize_FloatConstant) {
|
TEST_F(ResolverTypeValidationTest, ArraySize_FloatConstant) {
|
||||||
// let size = 10.0;
|
// let size = 10.0;
|
||||||
// var<private> a : array<f32, size>;
|
// var<private> a : array<f32, size>;
|
||||||
GlobalConst("size", nullptr, Expr(10.f));
|
GlobalConst("size", nullptr, Expr(10_f));
|
||||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
|
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
EXPECT_EQ(r()->error(), "12:34 error: array size must be integer scalar");
|
EXPECT_EQ(r()->error(), "12:34 error: array size must be integer scalar");
|
||||||
|
|
|
@ -116,7 +116,7 @@ TEST_F(ResolverValidationTest, UnhandledStmt) {
|
||||||
TEST_F(ResolverValidationTest, Stmt_If_NonBool) {
|
TEST_F(ResolverValidationTest, Stmt_If_NonBool) {
|
||||||
// if (1.23f) {}
|
// if (1.23f) {}
|
||||||
|
|
||||||
WrapInFunction(If(Expr(Source{{12, 34}}, 1.23f), Block()));
|
WrapInFunction(If(Expr(Source{{12, 34}}, 1.23_f), Block()));
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ TEST_F(ResolverValidationTest, Stmt_If_NonBool) {
|
||||||
TEST_F(ResolverValidationTest, Stmt_ElseIf_NonBool) {
|
TEST_F(ResolverValidationTest, Stmt_ElseIf_NonBool) {
|
||||||
// else if (1.23f) {}
|
// else if (1.23f) {}
|
||||||
|
|
||||||
WrapInFunction(If(Expr(true), Block(), Else(If(Expr(Source{{12, 34}}, 1.23f), Block()))));
|
WrapInFunction(If(Expr(true), Block(), Else(If(Expr(Source{{12, 34}}, 1.23_f), Block()))));
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
|
||||||
|
@ -213,11 +213,11 @@ TEST_F(ResolverValidationTest, UsingUndefinedVariableGlobalVariable_Pass) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Global("global_var", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1f));
|
Global("global_var", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1_f));
|
||||||
|
|
||||||
Func("my_func", ast::VariableList{}, ty.void_(),
|
Func("my_func", ast::VariableList{}, ty.void_(),
|
||||||
{
|
{
|
||||||
Assign(Expr(Source{{12, 34}}, "global_var"), 3.14f),
|
Assign(Expr(Source{{12, 34}}, "global_var"), 3.14_f),
|
||||||
Return(),
|
Return(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -229,14 +229,14 @@ TEST_F(ResolverValidationTest, UsingUndefinedVariableInnerScope_Fail) {
|
||||||
// if (true) { var a : f32 = 2.0; }
|
// if (true) { var a : f32 = 2.0; }
|
||||||
// a = 3.14;
|
// a = 3.14;
|
||||||
// }
|
// }
|
||||||
auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2.0f));
|
auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2_f));
|
||||||
|
|
||||||
auto* cond = Expr(true);
|
auto* cond = Expr(true);
|
||||||
auto* body = Block(Decl(var));
|
auto* body = Block(Decl(var));
|
||||||
|
|
||||||
SetSource(Source{{12, 34}});
|
SetSource(Source{{12, 34}});
|
||||||
auto* lhs = Expr(Source{{12, 34}}, "a");
|
auto* lhs = Expr(Source{{12, 34}}, "a");
|
||||||
auto* rhs = Expr(3.14f);
|
auto* rhs = Expr(3.14_f);
|
||||||
|
|
||||||
auto* outer_body = Block(If(cond, body), Assign(lhs, rhs));
|
auto* outer_body = Block(If(cond, body), Assign(lhs, rhs));
|
||||||
|
|
||||||
|
@ -251,10 +251,10 @@ TEST_F(ResolverValidationTest, UsingUndefinedVariableOuterScope_Pass) {
|
||||||
// var a : f32 = 2.0;
|
// var a : f32 = 2.0;
|
||||||
// if (true) { a = 3.14; }
|
// if (true) { a = 3.14; }
|
||||||
// }
|
// }
|
||||||
auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2.0f));
|
auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2_f));
|
||||||
|
|
||||||
auto* lhs = Expr(Source{{12, 34}}, "a");
|
auto* lhs = Expr(Source{{12, 34}}, "a");
|
||||||
auto* rhs = Expr(3.14f);
|
auto* rhs = Expr(3.14_f);
|
||||||
|
|
||||||
auto* cond = Expr(true);
|
auto* cond = Expr(true);
|
||||||
auto* body = Block(Assign(lhs, rhs));
|
auto* body = Block(Assign(lhs, rhs));
|
||||||
|
@ -271,11 +271,11 @@ TEST_F(ResolverValidationTest, UsingUndefinedVariableDifferentScope_Fail) {
|
||||||
// { var a : f32 = 2.0; }
|
// { var a : f32 = 2.0; }
|
||||||
// { a = 3.14; }
|
// { a = 3.14; }
|
||||||
// }
|
// }
|
||||||
auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2.0f));
|
auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2_f));
|
||||||
auto* first_body = Block(Decl(var));
|
auto* first_body = Block(Decl(var));
|
||||||
|
|
||||||
auto* lhs = Expr(Source{{12, 34}}, "a");
|
auto* lhs = Expr(Source{{12, 34}}, "a");
|
||||||
auto* rhs = Expr(3.14f);
|
auto* rhs = Expr(3.14_f);
|
||||||
auto* second_body = Block(Assign(lhs, rhs));
|
auto* second_body = Block(Assign(lhs, rhs));
|
||||||
|
|
||||||
auto* outer_body = Block(first_body, second_body);
|
auto* outer_body = Block(first_body, second_body);
|
||||||
|
@ -966,7 +966,7 @@ TEST_F(ResolverTest, Stmt_ForLoop_CondIsNotBool) {
|
||||||
// for (; 1.0f; ) {
|
// for (; 1.0f; ) {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
WrapInFunction(For(nullptr, Expr(Source{{12, 34}}, 1.0f), nullptr, Block()));
|
WrapInFunction(For(nullptr, Expr(Source{{12, 34}}, 1_f), nullptr, Block()));
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
EXPECT_EQ(r()->error(), "12:34 error: for-loop condition must be bool, got f32");
|
EXPECT_EQ(r()->error(), "12:34 error: for-loop condition must be bool, got f32");
|
||||||
|
|
|
@ -99,7 +99,7 @@ TEST_F(ResolverVarLetTest, VarDeclWithConstructor) {
|
||||||
|
|
||||||
auto* i_c = Expr(1_i);
|
auto* i_c = Expr(1_i);
|
||||||
auto* u_c = Expr(1_u);
|
auto* u_c = Expr(1_u);
|
||||||
auto* f_c = Expr(1.f);
|
auto* f_c = Expr(1_f);
|
||||||
auto* b_c = Expr(true);
|
auto* b_c = Expr(true);
|
||||||
auto* s_c = Construct(ty.Of(S), Expr(1_i));
|
auto* s_c = Construct(ty.Of(S), Expr(1_i));
|
||||||
auto* a_c = Construct(ty.Of(A), Expr(1_i));
|
auto* a_c = Construct(ty.Of(A), Expr(1_i));
|
||||||
|
@ -165,7 +165,7 @@ TEST_F(ResolverVarLetTest, LetDecl) {
|
||||||
|
|
||||||
auto* i_c = Expr(1_i);
|
auto* i_c = Expr(1_i);
|
||||||
auto* u_c = Expr(1_u);
|
auto* u_c = Expr(1_u);
|
||||||
auto* f_c = Expr(1.f);
|
auto* f_c = Expr(1_f);
|
||||||
auto* b_c = Expr(true);
|
auto* b_c = Expr(true);
|
||||||
auto* s_c = Construct(ty.Of(S), Expr(1_i));
|
auto* s_c = Construct(ty.Of(S), Expr(1_i));
|
||||||
auto* a_c = Construct(ty.Of(A), Expr(1_i));
|
auto* a_c = Construct(ty.Of(A), Expr(1_i));
|
||||||
|
|
|
@ -140,7 +140,7 @@ TEST_F(ResolverVarLetValidationTest, LetOfPtrConstructedWithRef) {
|
||||||
TEST_F(ResolverVarLetValidationTest, LocalLetRedeclared) {
|
TEST_F(ResolverVarLetValidationTest, LocalLetRedeclared) {
|
||||||
// let l : f32 = 1.;
|
// let l : f32 = 1.;
|
||||||
// let l : i32 = 0;
|
// let l : i32 = 0;
|
||||||
auto* l1 = Let("l", ty.f32(), Expr(1.f));
|
auto* l1 = Let("l", ty.f32(), Expr(1_f));
|
||||||
auto* l2 = Let(Source{{12, 34}}, "l", ty.i32(), Expr(0_i));
|
auto* l2 = Let(Source{{12, 34}}, "l", ty.i32(), Expr(0_i));
|
||||||
WrapInFunction(l1, l2);
|
WrapInFunction(l1, l2);
|
||||||
|
|
||||||
|
@ -156,9 +156,9 @@ TEST_F(ResolverVarLetValidationTest, GlobalVarRedeclaredAsLocal) {
|
||||||
// return 0;
|
// return 0;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Global("v", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1f));
|
Global("v", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1_f));
|
||||||
|
|
||||||
WrapInFunction(Var(Source{{12, 34}}, "v", ty.f32(), ast::StorageClass::kNone, Expr(2.0f)));
|
WrapInFunction(Var(Source{{12, 34}}, "v", ty.f32(), ast::StorageClass::kNone, Expr(2_f)));
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
}
|
}
|
||||||
|
@ -183,9 +183,9 @@ TEST_F(ResolverVarLetValidationTest, VarRedeclaredInIfBlock) {
|
||||||
// var v : f32 = 3.14;
|
// var v : f32 = 3.14;
|
||||||
// if (true) { var v : f32 = 2.0; }
|
// if (true) { var v : f32 = 2.0; }
|
||||||
// }
|
// }
|
||||||
auto* var_a_float = Var("v", ty.f32(), ast::StorageClass::kNone, Expr(3.1f));
|
auto* var_a_float = Var("v", ty.f32(), ast::StorageClass::kNone, Expr(3.1_f));
|
||||||
|
|
||||||
auto* var = Var(Source{{12, 34}}, "v", ty.f32(), ast::StorageClass::kNone, Expr(2.0f));
|
auto* var = Var(Source{{12, 34}}, "v", ty.f32(), ast::StorageClass::kNone, Expr(2_f));
|
||||||
|
|
||||||
auto* cond = Expr(true);
|
auto* cond = Expr(true);
|
||||||
auto* body = Block(Decl(var));
|
auto* body = Block(Decl(var));
|
||||||
|
@ -274,7 +274,7 @@ TEST_F(ResolverVarLetValidationTest, NonConstructibleType_InferredType) {
|
||||||
|
|
||||||
TEST_F(ResolverVarLetValidationTest, InvalidStorageClassForInitializer) {
|
TEST_F(ResolverVarLetValidationTest, InvalidStorageClassForInitializer) {
|
||||||
// var<workgroup> v : f32 = 1.23;
|
// var<workgroup> v : f32 = 1.23;
|
||||||
Global(Source{{12, 34}}, "v", ty.f32(), ast::StorageClass::kWorkgroup, Expr(1.23f));
|
Global(Source{{12, 34}}, "v", ty.f32(), ast::StorageClass::kWorkgroup, Expr(1.23_f));
|
||||||
|
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
EXPECT_EQ(r()->error(),
|
EXPECT_EQ(r()->error(),
|
||||||
|
|
|
@ -374,7 +374,7 @@ struct CanonicalizeEntryPointIO::State {
|
||||||
void AddVertexPointSize() {
|
void AddVertexPointSize() {
|
||||||
// Create a new output value and assign it a literal 1.0 value.
|
// Create a new output value and assign it a literal 1.0 value.
|
||||||
AddOutput("vertex_point_size", ctx.dst->create<sem::F32>(),
|
AddOutput("vertex_point_size", ctx.dst->create<sem::F32>(),
|
||||||
{ctx.dst->Builtin(ast::Builtin::kPointSize)}, ctx.dst->Expr(1.f));
|
{ctx.dst->Builtin(ast::Builtin::kPointSize)}, ctx.dst->Expr(1_f));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create an expression for gl_Position.[component]
|
/// Create an expression for gl_Position.[component]
|
||||||
|
@ -580,7 +580,7 @@ struct CanonicalizeEntryPointIO::State {
|
||||||
ctx.dst->create<ast::UnaryOpExpression>(ast::UnaryOp::kNegation, GLPosition("y"));
|
ctx.dst->create<ast::UnaryOpExpression>(ast::UnaryOp::kNegation, GLPosition("y"));
|
||||||
wrapper_body.push_back(ctx.dst->Assign(pos_y, negate_pos_y));
|
wrapper_body.push_back(ctx.dst->Assign(pos_y, negate_pos_y));
|
||||||
|
|
||||||
auto* two_z = ctx.dst->Mul(ctx.dst->Expr(2.0f), GLPosition("z"));
|
auto* two_z = ctx.dst->Mul(ctx.dst->Expr(2_f), GLPosition("z"));
|
||||||
auto* fixed_z = ctx.dst->Sub(two_z, GLPosition("w"));
|
auto* fixed_z = ctx.dst->Sub(two_z, GLPosition("w"));
|
||||||
wrapper_body.push_back(ctx.dst->Assign(GLPosition("z"), fixed_z));
|
wrapper_body.push_back(ctx.dst->Assign(GLPosition("z"), fixed_z));
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,8 +350,8 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageStridedArray) {
|
||||||
{
|
{
|
||||||
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.array<f32, 4u>(32))),
|
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.array<f32, 4u>(32))),
|
||||||
b.Assign(b.MemberAccessor("s", "a"),
|
b.Assign(b.MemberAccessor("s", "a"),
|
||||||
b.Construct(b.ty.array<f32, 4u>(32), 1.0f, 2.0f, 3.0f, 4.0f)),
|
b.Construct(b.ty.array<f32, 4u>(32), 1_f, 2_f, 3_f, 4_f)),
|
||||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5.0f),
|
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5_f),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
b.Stage(ast::PipelineStage::kCompute),
|
b.Stage(ast::PipelineStage::kCompute),
|
||||||
|
@ -404,8 +404,8 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageDefaultStridedArray) {
|
||||||
{
|
{
|
||||||
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.array<f32, 4u>(4))),
|
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.array<f32, 4u>(4))),
|
||||||
b.Assign(b.MemberAccessor("s", "a"),
|
b.Assign(b.MemberAccessor("s", "a"),
|
||||||
b.Construct(b.ty.array<f32, 4u>(4), 1.0f, 2.0f, 3.0f, 4.0f)),
|
b.Construct(b.ty.array<f32, 4u>(4), 1_f, 2_f, 3_f, 4_f)),
|
||||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5.0f),
|
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5_f),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
b.Stage(ast::PipelineStage::kCompute),
|
b.Stage(ast::PipelineStage::kCompute),
|
||||||
|
@ -458,8 +458,8 @@ TEST_F(DecomposeStridedArrayTest, ReadWriteViaPointerLets) {
|
||||||
b.Decl(b.Let("b", nullptr, b.AddressOf(b.Deref(b.AddressOf(b.Deref("a")))))),
|
b.Decl(b.Let("b", nullptr, b.AddressOf(b.Deref(b.AddressOf(b.Deref("a")))))),
|
||||||
b.Decl(b.Let("c", nullptr, b.Deref("b"))),
|
b.Decl(b.Let("c", nullptr, b.Deref("b"))),
|
||||||
b.Decl(b.Let("d", nullptr, b.IndexAccessor(b.Deref("b"), 1_i))),
|
b.Decl(b.Let("d", nullptr, b.IndexAccessor(b.Deref("b"), 1_i))),
|
||||||
b.Assign(b.Deref("b"), b.Construct(b.ty.array<f32, 4u>(32), 1.0f, 2.0f, 3.0f, 4.0f)),
|
b.Assign(b.Deref("b"), b.Construct(b.ty.array<f32, 4u>(32), 1_f, 2_f, 3_f, 4_f)),
|
||||||
b.Assign(b.IndexAccessor(b.Deref("b"), 1_i), 5.0f),
|
b.Assign(b.IndexAccessor(b.Deref("b"), 1_i), 5_f),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
b.Stage(ast::PipelineStage::kCompute),
|
b.Stage(ast::PipelineStage::kCompute),
|
||||||
|
@ -519,8 +519,8 @@ TEST_F(DecomposeStridedArrayTest, PrivateAliasedStridedArray) {
|
||||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i))),
|
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i))),
|
||||||
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.type_name("ARR"))),
|
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.type_name("ARR"))),
|
||||||
b.Assign(b.MemberAccessor("s", "a"),
|
b.Assign(b.MemberAccessor("s", "a"),
|
||||||
b.Construct(b.ty.type_name("ARR"), 1.0f, 2.0f, 3.0f, 4.0f)),
|
b.Construct(b.ty.type_name("ARR"), 1_f, 2_f, 3_f, 4_f)),
|
||||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5.0f),
|
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5_f),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
b.Stage(ast::PipelineStage::kCompute),
|
b.Stage(ast::PipelineStage::kCompute),
|
||||||
|
@ -612,7 +612,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) {
|
||||||
3_i),
|
3_i),
|
||||||
2_i),
|
2_i),
|
||||||
1_i),
|
1_i),
|
||||||
5.0f),
|
5_f),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
b.Stage(ast::PipelineStage::kCompute),
|
b.Stage(ast::PipelineStage::kCompute),
|
||||||
|
|
|
@ -354,7 +354,7 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageMatrix) {
|
||||||
b.Func("f", {}, b.ty.void_(),
|
b.Func("f", {}, b.ty.void_(),
|
||||||
{
|
{
|
||||||
b.Assign(b.MemberAccessor("s", "m"),
|
b.Assign(b.MemberAccessor("s", "m"),
|
||||||
b.mat2x2<f32>(b.vec2<f32>(1.0f, 2.0f), b.vec2<f32>(3.0f, 4.0f))),
|
b.mat2x2<f32>(b.vec2<f32>(1_f, 2_f), b.vec2<f32>(3_f, 4_f))),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
b.Stage(ast::PipelineStage::kCompute),
|
b.Stage(ast::PipelineStage::kCompute),
|
||||||
|
@ -411,7 +411,7 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageColumn) {
|
||||||
b.GroupAndBinding(0, 0));
|
b.GroupAndBinding(0, 0));
|
||||||
b.Func("f", {}, b.ty.void_(),
|
b.Func("f", {}, b.ty.void_(),
|
||||||
{
|
{
|
||||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "m"), 1_i), b.vec2<f32>(1.0f, 2.0f)),
|
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "m"), 1_i), b.vec2<f32>(1_f, 2_f)),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
b.Stage(ast::PipelineStage::kCompute),
|
b.Stage(ast::PipelineStage::kCompute),
|
||||||
|
@ -468,21 +468,20 @@ TEST_F(DecomposeStridedMatrixTest, ReadWriteViaPointerLets) {
|
||||||
});
|
});
|
||||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
|
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
|
||||||
b.GroupAndBinding(0, 0));
|
b.GroupAndBinding(0, 0));
|
||||||
b.Func(
|
b.Func("f", {}, b.ty.void_(),
|
||||||
"f", {}, b.ty.void_(),
|
{
|
||||||
{
|
b.Decl(b.Let("a", nullptr, b.AddressOf(b.MemberAccessor("s", "m")))),
|
||||||
b.Decl(b.Let("a", nullptr, b.AddressOf(b.MemberAccessor("s", "m")))),
|
b.Decl(b.Let("b", nullptr, b.AddressOf(b.Deref(b.AddressOf(b.Deref("a")))))),
|
||||||
b.Decl(b.Let("b", nullptr, b.AddressOf(b.Deref(b.AddressOf(b.Deref("a")))))),
|
b.Decl(b.Let("x", nullptr, b.Deref("b"))),
|
||||||
b.Decl(b.Let("x", nullptr, b.Deref("b"))),
|
b.Decl(b.Let("y", nullptr, b.IndexAccessor(b.Deref("b"), 1_i))),
|
||||||
b.Decl(b.Let("y", nullptr, b.IndexAccessor(b.Deref("b"), 1_i))),
|
b.Decl(b.Let("z", nullptr, b.IndexAccessor("x", 1_i))),
|
||||||
b.Decl(b.Let("z", nullptr, b.IndexAccessor("x", 1_i))),
|
b.Assign(b.Deref("b"), b.mat2x2<f32>(b.vec2<f32>(1_f, 2_f), b.vec2<f32>(3_f, 4_f))),
|
||||||
b.Assign(b.Deref("b"), b.mat2x2<f32>(b.vec2<f32>(1.0f, 2.0f), b.vec2<f32>(3.0f, 4.0f))),
|
b.Assign(b.IndexAccessor(b.Deref("b"), 1_i), b.vec2<f32>(5_f, 6_f)),
|
||||||
b.Assign(b.IndexAccessor(b.Deref("b"), 1_i), b.vec2<f32>(5.0f, 6.0f)),
|
},
|
||||||
},
|
{
|
||||||
{
|
b.Stage(ast::PipelineStage::kCompute),
|
||||||
b.Stage(ast::PipelineStage::kCompute),
|
b.WorkgroupSize(1_i),
|
||||||
b.WorkgroupSize(1_i),
|
});
|
||||||
});
|
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct S {
|
struct S {
|
||||||
|
@ -595,7 +594,7 @@ TEST_F(DecomposeStridedMatrixTest, WritePrivateMatrix) {
|
||||||
b.Func("f", {}, b.ty.void_(),
|
b.Func("f", {}, b.ty.void_(),
|
||||||
{
|
{
|
||||||
b.Assign(b.MemberAccessor("s", "m"),
|
b.Assign(b.MemberAccessor("s", "m"),
|
||||||
b.mat2x2<f32>(b.vec2<f32>(1.0f, 2.0f), b.vec2<f32>(3.0f, 4.0f))),
|
b.mat2x2<f32>(b.vec2<f32>(1_f, 2_f), b.vec2<f32>(3_f, 4_f))),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
b.Stage(ast::PipelineStage::kCompute),
|
b.Stage(ast::PipelineStage::kCompute),
|
||||||
|
|
|
@ -304,11 +304,11 @@ struct MultiplanarExternalTexture::State {
|
||||||
const ast::CallExpression* plane_1_call = nullptr;
|
const ast::CallExpression* plane_1_call = nullptr;
|
||||||
if (call_type == sem::BuiltinType::kTextureSampleLevel) {
|
if (call_type == sem::BuiltinType::kTextureSampleLevel) {
|
||||||
// textureSampleLevel(plane0, smp, coord.xy, 0.0);
|
// textureSampleLevel(plane0, smp, coord.xy, 0.0);
|
||||||
single_plane_call = b.Call("textureSampleLevel", "plane0", "smp", "coord", 0.0f);
|
single_plane_call = b.Call("textureSampleLevel", "plane0", "smp", "coord", 0_f);
|
||||||
// textureSampleLevel(plane0, smp, coord.xy, 0.0);
|
// textureSampleLevel(plane0, smp, coord.xy, 0.0);
|
||||||
plane_0_call = b.Call("textureSampleLevel", "plane0", "smp", "coord", 0.0f);
|
plane_0_call = b.Call("textureSampleLevel", "plane0", "smp", "coord", 0_f);
|
||||||
// textureSampleLevel(plane1, smp, coord.xy, 0.0);
|
// textureSampleLevel(plane1, smp, coord.xy, 0.0);
|
||||||
plane_1_call = b.Call("textureSampleLevel", "plane1", "smp", "coord", 0.0f);
|
plane_1_call = b.Call("textureSampleLevel", "plane1", "smp", "coord", 0_f);
|
||||||
} else if (call_type == sem::BuiltinType::kTextureLoad) {
|
} else if (call_type == sem::BuiltinType::kTextureLoad) {
|
||||||
// textureLoad(plane0, coords.xy, 0);
|
// textureLoad(plane0, coords.xy, 0);
|
||||||
single_plane_call = b.Call("textureLoad", "plane0", "coord", 0_i);
|
single_plane_call = b.Call("textureLoad", "plane0", "coord", 0_i);
|
||||||
|
@ -334,7 +334,7 @@ struct MultiplanarExternalTexture::State {
|
||||||
// params.yuvToRgbConversionMatrix;
|
// params.yuvToRgbConversionMatrix;
|
||||||
b.Assign("color",
|
b.Assign("color",
|
||||||
b.Mul(b.vec4<f32>(b.MemberAccessor(plane_0_call, "r"),
|
b.Mul(b.vec4<f32>(b.MemberAccessor(plane_0_call, "r"),
|
||||||
b.MemberAccessor(plane_1_call, "rg"), 1.0f),
|
b.MemberAccessor(plane_1_call, "rg"), 1_f),
|
||||||
b.MemberAccessor("params", "yuvToRgbConversionMatrix")))))),
|
b.MemberAccessor("params", "yuvToRgbConversionMatrix")))))),
|
||||||
// color = gammaConversion(color, gammaDecodeParams);
|
// color = gammaConversion(color, gammaDecodeParams);
|
||||||
b.Assign("color", b.Call("gammaCorrection", "color",
|
b.Assign("color", b.Call("gammaCorrection", "color",
|
||||||
|
@ -344,8 +344,8 @@ struct MultiplanarExternalTexture::State {
|
||||||
// color = gammaConversion(color, gammaEncodeParams);
|
// color = gammaConversion(color, gammaEncodeParams);
|
||||||
b.Assign("color", b.Call("gammaCorrection", "color",
|
b.Assign("color", b.Call("gammaCorrection", "color",
|
||||||
b.MemberAccessor("params", "gammaEncodeParams"))),
|
b.MemberAccessor("params", "gammaEncodeParams"))),
|
||||||
// return vec4<f32>(color, 1.0f);
|
// return vec4<f32>(color, 1.f);
|
||||||
b.Return(b.vec4<f32>("color", 1.0f))};
|
b.Return(b.vec4<f32>("color", 1_f))};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates the textureSampleExternal function if needed and returns a call
|
/// Creates the textureSampleExternal function if needed and returns a call
|
||||||
|
|
|
@ -361,19 +361,19 @@ struct State {
|
||||||
case BaseType::kI32:
|
case BaseType::kI32:
|
||||||
ty = ctx.dst->ty.i32();
|
ty = ctx.dst->ty.i32();
|
||||||
for (uint32_t i = fmt_dt.width; i < var_dt.width; i++) {
|
for (uint32_t i = fmt_dt.width; i < var_dt.width; i++) {
|
||||||
values.emplace_back(ctx.dst->Expr(i32((i == 3) ? 1 : 0)));
|
values.emplace_back(ctx.dst->Expr((i == 3) ? 1_i : 0_i));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BaseType::kU32:
|
case BaseType::kU32:
|
||||||
ty = ctx.dst->ty.u32();
|
ty = ctx.dst->ty.u32();
|
||||||
for (uint32_t i = fmt_dt.width; i < var_dt.width; i++) {
|
for (uint32_t i = fmt_dt.width; i < var_dt.width; i++) {
|
||||||
values.emplace_back(ctx.dst->Expr(u32((i == 3) ? 1u : 0u)));
|
values.emplace_back(ctx.dst->Expr((i == 3) ? 1_u : 0_u));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BaseType::kF32:
|
case BaseType::kF32:
|
||||||
ty = ctx.dst->ty.f32();
|
ty = ctx.dst->ty.f32();
|
||||||
for (uint32_t i = fmt_dt.width; i < var_dt.width; i++) {
|
for (uint32_t i = fmt_dt.width; i < var_dt.width; i++) {
|
||||||
values.emplace_back(ctx.dst->Expr((i == 3) ? 1.f : 0.f));
|
values.emplace_back(ctx.dst->Expr((i == 3) ? 1_f : 0_f));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -51,7 +51,7 @@ const sem::Expression* Zero(ProgramBuilder& b, const sem::Type* ty, const sem::S
|
||||||
} else if (ty->Is<sem::U32>()) {
|
} else if (ty->Is<sem::U32>()) {
|
||||||
expr = b.Expr(0_u);
|
expr = b.Expr(0_u);
|
||||||
} else if (ty->Is<sem::F32>()) {
|
} else if (ty->Is<sem::F32>()) {
|
||||||
expr = b.Expr(0.0f);
|
expr = b.Expr(0_f);
|
||||||
} else if (ty->Is<sem::Bool>()) {
|
} else if (ty->Is<sem::Bool>()) {
|
||||||
expr = b.Expr(false);
|
expr = b.Expr(false);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -164,7 +164,7 @@ TEST_F(AppendVectorTest, Vec2i32FromVec2u32_u32) {
|
||||||
TEST_F(AppendVectorTest, Vec2i32_f32) {
|
TEST_F(AppendVectorTest, Vec2i32_f32) {
|
||||||
auto* scalar_1 = Expr(1_i);
|
auto* scalar_1 = Expr(1_i);
|
||||||
auto* scalar_2 = Expr(2_i);
|
auto* scalar_2 = Expr(2_i);
|
||||||
auto* scalar_3 = Expr(3.0f);
|
auto* scalar_3 = Expr(3_f);
|
||||||
auto* vec_12 = vec2<i32>(scalar_1, scalar_2);
|
auto* vec_12 = vec2<i32>(scalar_1, scalar_2);
|
||||||
WrapInFunction(vec_12, scalar_3);
|
WrapInFunction(vec_12, scalar_3);
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,8 @@
|
||||||
#include "src/tint/writer/float_to_string.h"
|
#include "src/tint/writer/float_to_string.h"
|
||||||
#include "src/tint/writer/generate_external_texture_bindings.h"
|
#include "src/tint/writer/generate_external_texture_bindings.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool IsRelational(tint::ast::BinaryOp op) {
|
bool IsRelational(tint::ast::BinaryOp op) {
|
||||||
|
@ -1296,7 +1298,7 @@ bool GeneratorImpl::EmitBarrierCall(std::ostream& out, const sem::Builtin* built
|
||||||
}
|
}
|
||||||
|
|
||||||
const ast::Expression* GeneratorImpl::CreateF32Zero(const sem::Statement* stmt) {
|
const ast::Expression* GeneratorImpl::CreateF32Zero(const sem::Statement* stmt) {
|
||||||
auto* zero = builder_.Expr(0.0f);
|
auto* zero = builder_.Expr(0_f);
|
||||||
auto* f32 = builder_.create<sem::F32>();
|
auto* f32 = builder_.create<sem::F32>();
|
||||||
auto* sem_zero = builder_.create<sem::Expression>(zero, f32, stmt, sem::Constant{},
|
auto* sem_zero = builder_.create<sem::Expression>(zero, f32, stmt, sem::Constant{},
|
||||||
/* has_side_effects */ false);
|
/* has_side_effects */ false);
|
||||||
|
|
|
@ -123,8 +123,8 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
BinaryData{"(left % right)", ast::BinaryOp::kModulo}));
|
BinaryData{"(left % right)", ast::BinaryOp::kModulo}));
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorScalar) {
|
TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorScalar) {
|
||||||
auto* lhs = vec3<f32>(1.f, 1.f, 1.f);
|
auto* lhs = vec3<f32>(1_f, 1_f, 1_f);
|
||||||
auto* rhs = Expr(1.f);
|
auto* rhs = Expr(1_f);
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
||||||
|
|
||||||
|
@ -140,8 +140,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorScalar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarVector) {
|
TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarVector) {
|
||||||
auto* lhs = Expr(1.f);
|
auto* lhs = Expr(1_f);
|
||||||
auto* rhs = vec3<f32>(1.f, 1.f, 1.f);
|
auto* rhs = vec3<f32>(1_f, 1_f, 1_f);
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarVector) {
|
||||||
TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixScalar) {
|
TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixScalar) {
|
||||||
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
|
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
|
||||||
auto* lhs = Expr("mat");
|
auto* lhs = Expr("mat");
|
||||||
auto* rhs = Expr(1.f);
|
auto* rhs = Expr(1_f);
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
@ -173,7 +173,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixScalar) {
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) {
|
TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) {
|
||||||
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
|
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
|
||||||
auto* lhs = Expr(1.f);
|
auto* lhs = Expr(1_f);
|
||||||
auto* rhs = Expr("mat");
|
auto* rhs = Expr("mat");
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
||||||
|
@ -189,7 +189,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) {
|
||||||
TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixVector) {
|
TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixVector) {
|
||||||
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
|
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
|
||||||
auto* lhs = Expr("mat");
|
auto* lhs = Expr("mat");
|
||||||
auto* rhs = vec3<f32>(1.f, 1.f, 1.f);
|
auto* rhs = vec3<f32>(1_f, 1_f, 1_f);
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
@ -203,7 +203,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixVector) {
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorMatrix) {
|
TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorMatrix) {
|
||||||
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
|
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
|
||||||
auto* lhs = vec3<f32>(1.f, 1.f, 1.f);
|
auto* lhs = vec3<f32>(1_f, 1_f, 1_f);
|
||||||
auto* rhs = Expr("mat");
|
auto* rhs = Expr("mat");
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
||||||
|
|
|
@ -258,7 +258,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Builtin_Call) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Builtin, Select_Scalar) {
|
TEST_F(GlslGeneratorImplTest_Builtin, Select_Scalar) {
|
||||||
auto* call = Call("select", 1.0f, 2.0f, true);
|
auto* call = Call("select", 1_f, 2_f, true);
|
||||||
WrapInFunction(CallStmt(call));
|
WrapInFunction(CallStmt(call));
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Select_Vector) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Builtin, Modf_Scalar) {
|
TEST_F(GlslGeneratorImplTest_Builtin, Modf_Scalar) {
|
||||||
auto* call = Call("modf", 1.0f);
|
auto* call = Call("modf", 1_f);
|
||||||
WrapInFunction(CallStmt(call));
|
WrapInFunction(CallStmt(call));
|
||||||
|
|
||||||
GeneratorImpl& gen = SanitizeAndBuild();
|
GeneratorImpl& gen = SanitizeAndBuild();
|
||||||
|
@ -346,7 +346,7 @@ void main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Builtin, Frexp_Scalar_i32) {
|
TEST_F(GlslGeneratorImplTest_Builtin, Frexp_Scalar_i32) {
|
||||||
auto* call = Call("frexp", 1.0f);
|
auto* call = Call("frexp", 1_f);
|
||||||
WrapInFunction(CallStmt(call));
|
WrapInFunction(CallStmt(call));
|
||||||
|
|
||||||
GeneratorImpl& gen = SanitizeAndBuild();
|
GeneratorImpl& gen = SanitizeAndBuild();
|
||||||
|
|
|
@ -15,13 +15,15 @@
|
||||||
#include "src/tint/ast/call_statement.h"
|
#include "src/tint/ast/call_statement.h"
|
||||||
#include "src/tint/writer/glsl/test_helper.h"
|
#include "src/tint/writer/glsl/test_helper.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::writer::glsl {
|
namespace tint::writer::glsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using GlslGeneratorImplTest_Call = TestHelper;
|
using GlslGeneratorImplTest_Call = TestHelper;
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) {
|
TEST_F(GlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) {
|
||||||
Func("my_func", {}, ty.f32(), {Return(1.23f)});
|
Func("my_func", {}, ty.f32(), {Return(1.23_f)});
|
||||||
|
|
||||||
auto* call = Call("my_func");
|
auto* call = Call("my_func");
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
@ -39,7 +41,7 @@ TEST_F(GlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) {
|
||||||
Param(Sym(), ty.f32()),
|
Param(Sym(), ty.f32()),
|
||||||
Param(Sym(), ty.f32()),
|
Param(Sym(), ty.f32()),
|
||||||
},
|
},
|
||||||
ty.f32(), {Return(1.23f)});
|
ty.f32(), {Return(1.23_f)});
|
||||||
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
|
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
|
||||||
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
|
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Float) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Float) {
|
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Float) {
|
||||||
WrapInFunction(Construct<f32>(-1.2e-5f));
|
WrapInFunction(Construct<f32>(-1.2e-5_f));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Uint) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec) {
|
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec) {
|
||||||
WrapInFunction(vec3<f32>(1.f, 2.f, 3.f));
|
WrapInFunction(vec3<f32>(1_f, 2_f, 3_f));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_Empty) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_SingleScalar_Float) {
|
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_SingleScalar_Float) {
|
||||||
WrapInFunction(vec3<f32>(2.0f));
|
WrapInFunction(vec3<f32>(2_f));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_SingleScalar_
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Mat) {
|
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Mat) {
|
||||||
WrapInFunction(mat2x3<f32>(vec3<f32>(1.f, 2.f, 3.f), vec3<f32>(3.f, 4.f, 5.f)));
|
WrapInFunction(mat2x3<f32>(vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(3_f, 4_f, 5_f)));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -172,8 +172,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Mat_Empty) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Array) {
|
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Array) {
|
||||||
WrapInFunction(Construct(ty.array(ty.vec3<f32>(), 3_u), vec3<f32>(1.f, 2.f, 3.f),
|
WrapInFunction(Construct(ty.array(ty.vec3<f32>(), 3_u), vec3<f32>(1_f, 2_f, 3_f),
|
||||||
vec3<f32>(4.f, 5.f, 6.f), vec3<f32>(7.f, 8.f, 9.f)));
|
vec3<f32>(4_f, 5_f, 6_f), vec3<f32>(7_f, 8_f, 9_f)));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Struct) {
|
||||||
Member("c", ty.vec3<i32>()),
|
Member("c", ty.vec3<i32>()),
|
||||||
});
|
});
|
||||||
|
|
||||||
WrapInFunction(Construct(ty.Of(str), 1_i, 2.0f, vec3<i32>(3_i, 4_i, 5_i)));
|
WrapInFunction(Construct(ty.Of(str), 1_i, 2_f, vec3<i32>(3_i, 4_i, 5_i)));
|
||||||
|
|
||||||
GeneratorImpl& gen = SanitizeAndBuild();
|
GeneratorImpl& gen = SanitizeAndBuild();
|
||||||
|
|
||||||
|
|
|
@ -193,8 +193,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_SharedStruct_Di
|
||||||
});
|
});
|
||||||
|
|
||||||
Func("vert_main", {}, ty.Of(interface_struct),
|
Func("vert_main", {}, ty.Of(interface_struct),
|
||||||
{Return(Construct(ty.Of(interface_struct), Construct(ty.vec4<f32>()), Expr(0.5f),
|
{Return(Construct(ty.Of(interface_struct), Construct(ty.vec4<f32>()), Expr(0.5_f),
|
||||||
Expr(0.25f)))},
|
Expr(0.25_f)))},
|
||||||
{Stage(ast::PipelineStage::kVertex)});
|
{Stage(ast::PipelineStage::kVertex)});
|
||||||
|
|
||||||
Func("frag_main", {Param("inputs", ty.Of(interface_struct))}, ty.void_(),
|
Func("frag_main", {Param("inputs", ty.Of(interface_struct))}, ty.void_(),
|
||||||
|
@ -271,17 +271,17 @@ TEST_F(GlslGeneratorImplTest_Function,
|
||||||
|
|
||||||
Func("foo", {Param("x", ty.f32())}, ty.Of(vertex_output_struct),
|
Func("foo", {Param("x", ty.f32())}, ty.Of(vertex_output_struct),
|
||||||
{Return(Construct(ty.Of(vertex_output_struct),
|
{Return(Construct(ty.Of(vertex_output_struct),
|
||||||
Construct(ty.vec4<f32>(), "x", "x", "x", Expr(1.f))))},
|
Construct(ty.vec4<f32>(), "x", "x", "x", Expr(1_f))))},
|
||||||
{});
|
{});
|
||||||
|
|
||||||
Func("vert_main1", {}, ty.Of(vertex_output_struct),
|
Func("vert_main1", {}, ty.Of(vertex_output_struct),
|
||||||
{Return(Construct(ty.Of(vertex_output_struct),
|
{Return(Construct(ty.Of(vertex_output_struct),
|
||||||
Expr(Call("foo", Expr(0.5f)))))},
|
Expr(Call("foo", Expr(0.5_f)))))},
|
||||||
{Stage(ast::PipelineStage::kVertex)});
|
{Stage(ast::PipelineStage::kVertex)});
|
||||||
|
|
||||||
Func("vert_main2", {}, ty.Of(vertex_output_struct),
|
Func("vert_main2", {}, ty.Of(vertex_output_struct),
|
||||||
{Return(Construct(ty.Of(vertex_output_struct),
|
{Return(Construct(ty.Of(vertex_output_struct),
|
||||||
Expr(Call("foo", Expr(0.25f)))))},
|
Expr(Call("foo", Expr(0.25_f)))))},
|
||||||
{Stage(ast::PipelineStage::kVertex)});
|
{Stage(ast::PipelineStage::kVertex)});
|
||||||
|
|
||||||
GeneratorImpl& gen = SanitizeAndBuild();
|
GeneratorImpl& gen = SanitizeAndBuild();
|
||||||
|
@ -336,7 +336,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) {
|
||||||
Return(MemberAccessor(MemberAccessor(ubo, "coord"), "x")),
|
Return(MemberAccessor(MemberAccessor(ubo, "coord"), "x")),
|
||||||
});
|
});
|
||||||
|
|
||||||
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1.0f));
|
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1_f));
|
||||||
|
|
||||||
Func("frag_main", {}, ty.void_(),
|
Func("frag_main", {}, ty.void_(),
|
||||||
{
|
{
|
||||||
|
@ -529,7 +529,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage
|
||||||
|
|
||||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||||
{
|
{
|
||||||
Assign(MemberAccessor("coord", "b"), Expr(2.0f)),
|
Assign(MemberAccessor("coord", "b"), Expr(2_f)),
|
||||||
Return(),
|
Return(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -577,7 +577,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf
|
||||||
|
|
||||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||||
{
|
{
|
||||||
Assign(MemberAccessor("coord", "b"), Expr(2.0f)),
|
Assign(MemberAccessor("coord", "b"), Expr(2_f)),
|
||||||
Return(),
|
Return(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -624,7 +624,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_
|
||||||
Return(MemberAccessor("coord", "x")),
|
Return(MemberAccessor("coord", "x")),
|
||||||
});
|
});
|
||||||
|
|
||||||
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1.0f));
|
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1_f));
|
||||||
|
|
||||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||||
{
|
{
|
||||||
|
@ -673,7 +673,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_
|
||||||
Return(MemberAccessor("coord", "x")),
|
Return(MemberAccessor("coord", "x")),
|
||||||
});
|
});
|
||||||
|
|
||||||
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1.0f));
|
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1_f));
|
||||||
|
|
||||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,7 +35,7 @@ TEST_P(GlslImportData_SingleParamTest, FloatScalar) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* ident = Expr(param.name);
|
auto* ident = Expr(param.name);
|
||||||
auto* expr = Call(ident, 1.f);
|
auto* expr = Call(ident, 1_f);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -92,7 +92,7 @@ TEST_P(GlslImportData_SingleVectorParamTest, FloatVector) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* ident = Expr(param.name);
|
auto* ident = Expr(param.name);
|
||||||
auto* expr = Call(ident, vec3<f32>(1.f, 2.f, 3.f));
|
auto* expr = Call(ident, vec3<f32>(1_f, 2_f, 3_f));
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -132,7 +132,7 @@ using GlslImportData_DualParam_ScalarTest = TestParamHelper<GlslImportData>;
|
||||||
TEST_P(GlslImportData_DualParam_ScalarTest, Float) {
|
TEST_P(GlslImportData_DualParam_ScalarTest, Float) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* expr = Call(param.name, 1.f, 2.f);
|
auto* expr = Call(param.name, 1_f, 2_f);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -154,7 +154,7 @@ using GlslImportData_DualParam_VectorTest = TestParamHelper<GlslImportData>;
|
||||||
TEST_P(GlslImportData_DualParam_VectorTest, Float) {
|
TEST_P(GlslImportData_DualParam_VectorTest, Float) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* expr = Call(param.name, vec3<f32>(1.f, 2.f, 3.f), vec3<f32>(4.f, 5.f, 6.f));
|
auto* expr = Call(param.name, vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(4_f, 5_f, 6_f));
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -197,7 +197,7 @@ using GlslImportData_TripleParam_ScalarTest = TestParamHelper<GlslImportData>;
|
||||||
TEST_P(GlslImportData_TripleParam_ScalarTest, Float) {
|
TEST_P(GlslImportData_TripleParam_ScalarTest, Float) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* expr = Call(param.name, 1.f, 2.f, 3.f);
|
auto* expr = Call(param.name, 1_f, 2_f, 3_f);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -216,8 +216,8 @@ using GlslImportData_TripleParam_VectorTest = TestParamHelper<GlslImportData>;
|
||||||
TEST_P(GlslImportData_TripleParam_VectorTest, Float) {
|
TEST_P(GlslImportData_TripleParam_VectorTest, Float) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* expr = Call(param.name, vec3<f32>(1.f, 2.f, 3.f), vec3<f32>(4.f, 5.f, 6.f),
|
auto* expr = Call(param.name, vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(4_f, 5_f, 6_f),
|
||||||
vec3<f32>(7.f, 8.f, 9.f));
|
vec3<f32>(7_f, 8_f, 9_f));
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
|
@ -114,8 +114,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) {
|
||||||
|
|
||||||
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
|
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4f))), //
|
auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4_f))), //
|
||||||
Decl(Var("other", ty.f32())), //
|
Decl(Var("other", ty.f32())), //
|
||||||
Break());
|
Break());
|
||||||
auto* continuing = Block(Assign("lhs", "rhs"));
|
auto* continuing = Block(Assign("lhs", "rhs"));
|
||||||
auto* outer = Loop(body, continuing);
|
auto* outer = Loop(body, continuing);
|
||||||
|
|
|
@ -739,7 +739,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_MultiLevel) {
|
||||||
|
|
||||||
SetupFunction({
|
SetupFunction({
|
||||||
Assign(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"),
|
Assign(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"),
|
||||||
vec3<f32>(1.f, 2.f, 3.f)),
|
vec3<f32>(1_f, 2_f, 3_f)),
|
||||||
});
|
});
|
||||||
|
|
||||||
GeneratorImpl& gen = SanitizeAndBuild();
|
GeneratorImpl& gen = SanitizeAndBuild();
|
||||||
|
@ -797,7 +797,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_Swizzle_SingleL
|
||||||
SetupFunction({
|
SetupFunction({
|
||||||
Assign(MemberAccessor(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"),
|
Assign(MemberAccessor(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"),
|
||||||
"y"),
|
"y"),
|
||||||
Expr(1.f)),
|
Expr(1_f)),
|
||||||
});
|
});
|
||||||
|
|
||||||
GeneratorImpl& gen = SanitizeAndBuild();
|
GeneratorImpl& gen = SanitizeAndBuild();
|
||||||
|
@ -833,7 +833,7 @@ void main() {
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_MemberAccessor, Swizzle_xyz) {
|
TEST_F(GlslGeneratorImplTest_MemberAccessor, Swizzle_xyz) {
|
||||||
auto* var =
|
auto* var =
|
||||||
Var("my_vec", ty.vec4<f32>(), ast::StorageClass::kNone, vec4<f32>(1.f, 2.f, 3.f, 4.f));
|
Var("my_vec", ty.vec4<f32>(), ast::StorageClass::kNone, vec4<f32>(1_f, 2_f, 3_f, 4_f));
|
||||||
auto* expr = MemberAccessor("my_vec", "xyz");
|
auto* expr = MemberAccessor("my_vec", "xyz");
|
||||||
WrapInFunction(var, expr);
|
WrapInFunction(var, expr);
|
||||||
|
|
||||||
|
@ -844,7 +844,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, Swizzle_xyz) {
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_MemberAccessor, Swizzle_gbr) {
|
TEST_F(GlslGeneratorImplTest_MemberAccessor, Swizzle_gbr) {
|
||||||
auto* var =
|
auto* var =
|
||||||
Var("my_vec", ty.vec4<f32>(), ast::StorageClass::kNone, vec4<f32>(1.f, 2.f, 3.f, 4.f));
|
Var("my_vec", ty.vec4<f32>(), ast::StorageClass::kNone, vec4<f32>(1_f, 2_f, 3_f, 4_f));
|
||||||
auto* expr = MemberAccessor("my_vec", "gbr");
|
auto* expr = MemberAccessor("my_vec", "gbr");
|
||||||
WrapInFunction(var, expr);
|
WrapInFunction(var, expr);
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,15 @@
|
||||||
#include "src/tint/ast/id_attribute.h"
|
#include "src/tint/ast/id_attribute.h"
|
||||||
#include "src/tint/writer/glsl/test_helper.h"
|
#include "src/tint/writer/glsl/test_helper.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::writer::glsl {
|
namespace tint::writer::glsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using GlslGeneratorImplTest_ModuleConstant = TestHelper;
|
using GlslGeneratorImplTest_ModuleConstant = TestHelper;
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) {
|
TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) {
|
||||||
auto* var = Let("pos", ty.array<f32, 3>(), array<f32, 3>(1.f, 2.f, 3.f));
|
auto* var = Let("pos", ty.array<f32, 3>(), array<f32, 3>(1_f, 2_f, 3_f));
|
||||||
WrapInFunction(Decl(var));
|
WrapInFunction(Decl(var));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -31,7 +33,7 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant) {
|
TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant) {
|
||||||
auto* var = Override("pos", ty.f32(), Expr(3.0f),
|
auto* var = Override("pos", ty.f32(), Expr(3_f),
|
||||||
ast::AttributeList{
|
ast::AttributeList{
|
||||||
Id(23),
|
Id(23),
|
||||||
});
|
});
|
||||||
|
@ -63,11 +65,11 @@ const float pos = WGSL_SPEC_CONSTANT_23;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant_NoId) {
|
TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant_NoId) {
|
||||||
auto* a = Override("a", ty.f32(), Expr(3.0f),
|
auto* a = Override("a", ty.f32(), Expr(3_f),
|
||||||
ast::AttributeList{
|
ast::AttributeList{
|
||||||
Id(0),
|
Id(0),
|
||||||
});
|
});
|
||||||
auto* b = Override("b", ty.f32(), Expr(2.0f));
|
auto* b = Override("b", ty.f32(), Expr(2_f));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ TEST_F(GlslSanitizerTest, PromoteStructInitializerToConstVar) {
|
||||||
Member("b", ty.vec3<f32>()),
|
Member("b", ty.vec3<f32>()),
|
||||||
Member("c", ty.i32()),
|
Member("c", ty.i32()),
|
||||||
});
|
});
|
||||||
auto* struct_init = Construct(ty.Of(str), 1_i, vec3<f32>(2.f, 3.f, 4.f), 4_i);
|
auto* struct_init = Construct(ty.Of(str), 1_i, vec3<f32>(2_f, 3_f, 4_f), 4_i);
|
||||||
auto* struct_access = MemberAccessor(struct_init, "b");
|
auto* struct_access = MemberAccessor(struct_init, "b");
|
||||||
auto* pos = Var("pos", ty.vec3<f32>(), ast::StorageClass::kNone, struct_access);
|
auto* pos = Var("pos", ty.vec3<f32>(), ast::StorageClass::kNone, struct_access);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ using GlslGeneratorImplTest_WorkgroupVar = TestHelper;
|
||||||
TEST_F(GlslGeneratorImplTest_WorkgroupVar, Basic) {
|
TEST_F(GlslGeneratorImplTest_WorkgroupVar, Basic) {
|
||||||
Global("wg", ty.f32(), ast::StorageClass::kWorkgroup);
|
Global("wg", ty.f32(), ast::StorageClass::kWorkgroup);
|
||||||
|
|
||||||
Func("main", {}, ty.void_(), {Assign("wg", 1.2f)},
|
Func("main", {}, ty.void_(), {Assign("wg", 1.2_f)},
|
||||||
{
|
{
|
||||||
Stage(ast::PipelineStage::kCompute),
|
Stage(ast::PipelineStage::kCompute),
|
||||||
WorkgroupSize(1_i),
|
WorkgroupSize(1_i),
|
||||||
|
@ -45,7 +45,7 @@ TEST_F(GlslGeneratorImplTest_WorkgroupVar, Aliased) {
|
||||||
|
|
||||||
Global("wg", ty.Of(alias), ast::StorageClass::kWorkgroup);
|
Global("wg", ty.Of(alias), ast::StorageClass::kWorkgroup);
|
||||||
|
|
||||||
Func("main", {}, ty.void_(), {Assign("wg", 1.2f)},
|
Func("main", {}, ty.void_(), {Assign("wg", 1.2_f)},
|
||||||
{
|
{
|
||||||
Stage(ast::PipelineStage::kCompute),
|
Stage(ast::PipelineStage::kCompute),
|
||||||
WorkgroupSize(1_i),
|
WorkgroupSize(1_i),
|
||||||
|
|
|
@ -141,8 +141,8 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
BinaryData::Types::Float}));
|
BinaryData::Types::Float}));
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorScalar) {
|
TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorScalar) {
|
||||||
auto* lhs = vec3<f32>(1.f, 1.f, 1.f);
|
auto* lhs = vec3<f32>(1_f, 1_f, 1_f);
|
||||||
auto* rhs = Expr(1.f);
|
auto* rhs = Expr(1_f);
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
||||||
|
|
||||||
|
@ -158,8 +158,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorScalar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarVector) {
|
TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarVector) {
|
||||||
auto* lhs = Expr(1.f);
|
auto* lhs = Expr(1_f);
|
||||||
auto* rhs = vec3<f32>(1.f, 1.f, 1.f);
|
auto* rhs = vec3<f32>(1_f, 1_f, 1_f);
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarVector) {
|
||||||
TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar) {
|
TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar) {
|
||||||
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
|
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
|
||||||
auto* lhs = Expr("mat");
|
auto* lhs = Expr("mat");
|
||||||
auto* rhs = Expr(1.f);
|
auto* rhs = Expr(1_f);
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
@ -191,7 +191,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar) {
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) {
|
TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) {
|
||||||
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
|
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
|
||||||
auto* lhs = Expr(1.f);
|
auto* lhs = Expr(1_f);
|
||||||
auto* rhs = Expr("mat");
|
auto* rhs = Expr("mat");
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
||||||
|
@ -207,7 +207,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) {
|
||||||
TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector) {
|
TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector) {
|
||||||
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
|
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
|
||||||
auto* lhs = Expr("mat");
|
auto* lhs = Expr("mat");
|
||||||
auto* rhs = vec3<f32>(1.f, 1.f, 1.f);
|
auto* rhs = vec3<f32>(1_f, 1_f, 1_f);
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
@ -221,7 +221,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector) {
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorMatrix) {
|
TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorMatrix) {
|
||||||
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
|
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
|
||||||
auto* lhs = vec3<f32>(1.f, 1.f, 1.f);
|
auto* lhs = vec3<f32>(1_f, 1_f, 1_f);
|
||||||
auto* rhs = Expr("mat");
|
auto* rhs = Expr("mat");
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
||||||
|
|
|
@ -257,7 +257,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Builtin_Call) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Builtin, Select_Scalar) {
|
TEST_F(HlslGeneratorImplTest_Builtin, Select_Scalar) {
|
||||||
auto* call = Call("select", 1.0f, 2.0f, true);
|
auto* call = Call("select", 1_f, 2_f, true);
|
||||||
WrapInFunction(CallStmt(call));
|
WrapInFunction(CallStmt(call));
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Select_Vector) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Builtin, Modf_Scalar) {
|
TEST_F(HlslGeneratorImplTest_Builtin, Modf_Scalar) {
|
||||||
auto* call = Call("modf", 1.0f);
|
auto* call = Call("modf", 1_f);
|
||||||
WrapInFunction(CallStmt(call));
|
WrapInFunction(CallStmt(call));
|
||||||
|
|
||||||
GeneratorImpl& gen = SanitizeAndBuild();
|
GeneratorImpl& gen = SanitizeAndBuild();
|
||||||
|
@ -331,7 +331,7 @@ void test_function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Builtin, Frexp_Scalar_i32) {
|
TEST_F(HlslGeneratorImplTest_Builtin, Frexp_Scalar_i32) {
|
||||||
auto* call = Call("frexp", 1.0f);
|
auto* call = Call("frexp", 1_f);
|
||||||
WrapInFunction(CallStmt(call));
|
WrapInFunction(CallStmt(call));
|
||||||
|
|
||||||
GeneratorImpl& gen = SanitizeAndBuild();
|
GeneratorImpl& gen = SanitizeAndBuild();
|
||||||
|
|
|
@ -15,13 +15,15 @@
|
||||||
#include "src/tint/ast/call_statement.h"
|
#include "src/tint/ast/call_statement.h"
|
||||||
#include "src/tint/writer/hlsl/test_helper.h"
|
#include "src/tint/writer/hlsl/test_helper.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::writer::hlsl {
|
namespace tint::writer::hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using HlslGeneratorImplTest_Call = TestHelper;
|
using HlslGeneratorImplTest_Call = TestHelper;
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) {
|
TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) {
|
||||||
Func("my_func", {}, ty.f32(), {Return(1.23f)});
|
Func("my_func", {}, ty.f32(), {Return(1.23_f)});
|
||||||
|
|
||||||
auto* call = Call("my_func");
|
auto* call = Call("my_func");
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
@ -39,7 +41,7 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) {
|
||||||
Param(Sym(), ty.f32()),
|
Param(Sym(), ty.f32()),
|
||||||
Param(Sym(), ty.f32()),
|
Param(Sym(), ty.f32()),
|
||||||
},
|
},
|
||||||
ty.f32(), {Return(1.23f)});
|
ty.f32(), {Return(1.23_f)});
|
||||||
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
|
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
|
||||||
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
|
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Float) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Float) {
|
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Float) {
|
||||||
WrapInFunction(Construct<f32>(-1.2e-5f));
|
WrapInFunction(Construct<f32>(-1.2e-5_f));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Uint) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec) {
|
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec) {
|
||||||
WrapInFunction(vec3<f32>(1.f, 2.f, 3.f));
|
WrapInFunction(vec3<f32>(1_f, 2_f, 3_f));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_Empty) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_SingleScalar_Float_Literal) {
|
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_SingleScalar_Float_Literal) {
|
||||||
WrapInFunction(vec3<f32>(2.0f));
|
WrapInFunction(vec3<f32>(2_f));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_SingleScalar_
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_SingleScalar_Float_Var) {
|
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_SingleScalar_Float_Var) {
|
||||||
auto* var = Var("v", nullptr, Expr(2.0f));
|
auto* var = Var("v", nullptr, Expr(2_f));
|
||||||
auto* cast = vec3<f32>(var);
|
auto* cast = vec3<f32>(var);
|
||||||
WrapInFunction(var, cast);
|
WrapInFunction(var, cast);
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_SingleScalar_
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Mat) {
|
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Mat) {
|
||||||
WrapInFunction(mat2x3<f32>(vec3<f32>(1.f, 2.f, 3.f), vec3<f32>(3.f, 4.f, 5.f)));
|
WrapInFunction(mat2x3<f32>(vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(3_f, 4_f, 5_f)));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -197,8 +197,8 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Mat_Empty) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Array) {
|
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Array) {
|
||||||
WrapInFunction(Construct(ty.array(ty.vec3<f32>(), 3_u), vec3<f32>(1.f, 2.f, 3.f),
|
WrapInFunction(Construct(ty.array(ty.vec3<f32>(), 3_u), vec3<f32>(1_f, 2_f, 3_f),
|
||||||
vec3<f32>(4.f, 5.f, 6.f), vec3<f32>(7.f, 8.f, 9.f)));
|
vec3<f32>(4_f, 5_f, 6_f), vec3<f32>(7_f, 8_f, 9_f)));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Struct) {
|
||||||
Member("c", ty.vec3<i32>()),
|
Member("c", ty.vec3<i32>()),
|
||||||
});
|
});
|
||||||
|
|
||||||
WrapInFunction(Construct(ty.Of(str), 1_i, 2.0f, vec3<i32>(3_i, 4_i, 5_i)));
|
WrapInFunction(Construct(ty.Of(str), 1_i, 2_f, vec3<i32>(3_i, 4_i, 5_i)));
|
||||||
|
|
||||||
GeneratorImpl& gen = SanitizeAndBuild();
|
GeneratorImpl& gen = SanitizeAndBuild();
|
||||||
|
|
||||||
|
|
|
@ -192,8 +192,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_SharedStruct_Di
|
||||||
});
|
});
|
||||||
|
|
||||||
Func("vert_main", {}, ty.Of(interface_struct),
|
Func("vert_main", {}, ty.Of(interface_struct),
|
||||||
{Return(Construct(ty.Of(interface_struct), Construct(ty.vec4<f32>()), Expr(0.5f),
|
{Return(Construct(ty.Of(interface_struct), Construct(ty.vec4<f32>()), Expr(0.5_f),
|
||||||
Expr(0.25f)))},
|
Expr(0.25_f)))},
|
||||||
{Stage(ast::PipelineStage::kVertex)});
|
{Stage(ast::PipelineStage::kVertex)});
|
||||||
|
|
||||||
Func("frag_main", {Param("inputs", ty.Of(interface_struct))}, ty.void_(),
|
Func("frag_main", {Param("inputs", ty.Of(interface_struct))}, ty.void_(),
|
||||||
|
@ -270,13 +270,13 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_SharedStruct_He
|
||||||
|
|
||||||
Func("foo", {Param("x", ty.f32())}, ty.Of(vertex_output_struct),
|
Func("foo", {Param("x", ty.f32())}, ty.Of(vertex_output_struct),
|
||||||
{Return(Construct(ty.Of(vertex_output_struct),
|
{Return(Construct(ty.Of(vertex_output_struct),
|
||||||
Construct(ty.vec4<f32>(), "x", "x", "x", Expr(1.f))))},
|
Construct(ty.vec4<f32>(), "x", "x", "x", Expr(1_f))))},
|
||||||
{});
|
{});
|
||||||
|
|
||||||
Func("vert_main1", {}, ty.Of(vertex_output_struct), {Return(Call("foo", Expr(0.5f)))},
|
Func("vert_main1", {}, ty.Of(vertex_output_struct), {Return(Call("foo", Expr(0.5_f)))},
|
||||||
{Stage(ast::PipelineStage::kVertex)});
|
{Stage(ast::PipelineStage::kVertex)});
|
||||||
|
|
||||||
Func("vert_main2", {}, ty.Of(vertex_output_struct), {Return(Call("foo", Expr(0.25f)))},
|
Func("vert_main2", {}, ty.Of(vertex_output_struct), {Return(Call("foo", Expr(0.25_f)))},
|
||||||
{Stage(ast::PipelineStage::kVertex)});
|
{Stage(ast::PipelineStage::kVertex)});
|
||||||
|
|
||||||
GeneratorImpl& gen = SanitizeAndBuild();
|
GeneratorImpl& gen = SanitizeAndBuild();
|
||||||
|
@ -340,7 +340,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) {
|
||||||
Return(MemberAccessor(MemberAccessor(ubo, "coord"), "x")),
|
Return(MemberAccessor(MemberAccessor(ubo, "coord"), "x")),
|
||||||
});
|
});
|
||||||
|
|
||||||
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1.0f));
|
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1_f));
|
||||||
|
|
||||||
Func("frag_main", {}, ty.void_(),
|
Func("frag_main", {}, ty.void_(),
|
||||||
{
|
{
|
||||||
|
@ -490,7 +490,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage
|
||||||
|
|
||||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||||
{
|
{
|
||||||
Assign(MemberAccessor("coord", "b"), Expr(2.0f)),
|
Assign(MemberAccessor("coord", "b"), Expr(2_f)),
|
||||||
Return(),
|
Return(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -524,7 +524,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf
|
||||||
|
|
||||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||||
{
|
{
|
||||||
Assign(MemberAccessor("coord", "b"), Expr(2.0f)),
|
Assign(MemberAccessor("coord", "b"), Expr(2_f)),
|
||||||
Return(),
|
Return(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -557,7 +557,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_
|
||||||
Return(MemberAccessor("coord", "x")),
|
Return(MemberAccessor("coord", "x")),
|
||||||
});
|
});
|
||||||
|
|
||||||
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1.0f));
|
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1_f));
|
||||||
|
|
||||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||||
{
|
{
|
||||||
|
@ -599,7 +599,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_
|
||||||
Return(MemberAccessor("coord", "x")),
|
Return(MemberAccessor("coord", "x")),
|
||||||
});
|
});
|
||||||
|
|
||||||
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1.0f));
|
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1_f));
|
||||||
|
|
||||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,7 +35,7 @@ TEST_P(HlslImportData_SingleParamTest, FloatScalar) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* ident = Expr(param.name);
|
auto* ident = Expr(param.name);
|
||||||
auto* expr = Call(ident, 1.f);
|
auto* expr = Call(ident, 1_f);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -92,7 +92,7 @@ TEST_P(HlslImportData_SingleVectorParamTest, FloatVector) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* ident = Expr(param.name);
|
auto* ident = Expr(param.name);
|
||||||
auto* expr = Call(ident, vec3<f32>(1.f, 2.f, 3.f));
|
auto* expr = Call(ident, vec3<f32>(1_f, 2_f, 3_f));
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -132,7 +132,7 @@ using HlslImportData_DualParam_ScalarTest = TestParamHelper<HlslImportData>;
|
||||||
TEST_P(HlslImportData_DualParam_ScalarTest, Float) {
|
TEST_P(HlslImportData_DualParam_ScalarTest, Float) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* expr = Call(param.name, 1.f, 2.f);
|
auto* expr = Call(param.name, 1_f, 2_f);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -154,7 +154,7 @@ using HlslImportData_DualParam_VectorTest = TestParamHelper<HlslImportData>;
|
||||||
TEST_P(HlslImportData_DualParam_VectorTest, Float) {
|
TEST_P(HlslImportData_DualParam_VectorTest, Float) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* expr = Call(param.name, vec3<f32>(1.f, 2.f, 3.f), vec3<f32>(4.f, 5.f, 6.f));
|
auto* expr = Call(param.name, vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(4_f, 5_f, 6_f));
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -197,7 +197,7 @@ using HlslImportData_TripleParam_ScalarTest = TestParamHelper<HlslImportData>;
|
||||||
TEST_P(HlslImportData_TripleParam_ScalarTest, Float) {
|
TEST_P(HlslImportData_TripleParam_ScalarTest, Float) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* expr = Call(param.name, 1.f, 2.f, 3.f);
|
auto* expr = Call(param.name, 1_f, 2_f, 3_f);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -217,8 +217,8 @@ using HlslImportData_TripleParam_VectorTest = TestParamHelper<HlslImportData>;
|
||||||
TEST_P(HlslImportData_TripleParam_VectorTest, Float) {
|
TEST_P(HlslImportData_TripleParam_VectorTest, Float) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* expr = Call(param.name, vec3<f32>(1.f, 2.f, 3.f), vec3<f32>(4.f, 5.f, 6.f),
|
auto* expr = Call(param.name, vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(4_f, 5_f, 6_f),
|
||||||
vec3<f32>(7.f, 8.f, 9.f));
|
vec3<f32>(7_f, 8_f, 9_f));
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
|
@ -114,8 +114,8 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) {
|
||||||
|
|
||||||
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
|
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4f))), //
|
auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4_f))), //
|
||||||
Decl(Var("other", ty.f32())), //
|
Decl(Var("other", ty.f32())), //
|
||||||
Break());
|
Break());
|
||||||
|
|
||||||
auto* continuing = Block(Assign("lhs", "rhs"));
|
auto* continuing = Block(Assign("lhs", "rhs"));
|
||||||
|
|
|
@ -644,7 +644,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_MultiLevel) {
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// var<storage> data : Pre;
|
// var<storage> data : Pre;
|
||||||
// data.c[2].b = vec3<f32>(1.f, 2.f, 3.f);
|
// data.c[2].b = vec3<f32>(1_f, 2_f, 3_f);
|
||||||
|
|
||||||
auto* inner = Structure("Inner", {
|
auto* inner = Structure("Inner", {
|
||||||
Member("a", ty.vec3<f32>()),
|
Member("a", ty.vec3<f32>()),
|
||||||
|
@ -657,7 +657,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_MultiLevel) {
|
||||||
|
|
||||||
SetupFunction({
|
SetupFunction({
|
||||||
Assign(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"),
|
Assign(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"),
|
||||||
vec3<f32>(1.f, 2.f, 3.f)),
|
vec3<f32>(1_f, 2_f, 3_f)),
|
||||||
});
|
});
|
||||||
|
|
||||||
GeneratorImpl& gen = SanitizeAndBuild();
|
GeneratorImpl& gen = SanitizeAndBuild();
|
||||||
|
@ -698,7 +698,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_Swizzle_SingleL
|
||||||
SetupFunction({
|
SetupFunction({
|
||||||
Assign(MemberAccessor(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"),
|
Assign(MemberAccessor(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"),
|
||||||
"y"),
|
"y"),
|
||||||
Expr(1.f)),
|
Expr(1_f)),
|
||||||
});
|
});
|
||||||
|
|
||||||
GeneratorImpl& gen = SanitizeAndBuild();
|
GeneratorImpl& gen = SanitizeAndBuild();
|
||||||
|
@ -717,7 +717,7 @@ void main() {
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_MemberAccessor, Swizzle_xyz) {
|
TEST_F(HlslGeneratorImplTest_MemberAccessor, Swizzle_xyz) {
|
||||||
auto* var =
|
auto* var =
|
||||||
Var("my_vec", ty.vec4<f32>(), ast::StorageClass::kNone, vec4<f32>(1.f, 2.f, 3.f, 4.f));
|
Var("my_vec", ty.vec4<f32>(), ast::StorageClass::kNone, vec4<f32>(1_f, 2_f, 3_f, 4_f));
|
||||||
auto* expr = MemberAccessor("my_vec", "xyz");
|
auto* expr = MemberAccessor("my_vec", "xyz");
|
||||||
WrapInFunction(var, expr);
|
WrapInFunction(var, expr);
|
||||||
|
|
||||||
|
@ -728,7 +728,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, Swizzle_xyz) {
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_MemberAccessor, Swizzle_gbr) {
|
TEST_F(HlslGeneratorImplTest_MemberAccessor, Swizzle_gbr) {
|
||||||
auto* var =
|
auto* var =
|
||||||
Var("my_vec", ty.vec4<f32>(), ast::StorageClass::kNone, vec4<f32>(1.f, 2.f, 3.f, 4.f));
|
Var("my_vec", ty.vec4<f32>(), ast::StorageClass::kNone, vec4<f32>(1_f, 2_f, 3_f, 4_f));
|
||||||
auto* expr = MemberAccessor("my_vec", "gbr");
|
auto* expr = MemberAccessor("my_vec", "gbr");
|
||||||
WrapInFunction(var, expr);
|
WrapInFunction(var, expr);
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,15 @@
|
||||||
#include "src/tint/ast/id_attribute.h"
|
#include "src/tint/ast/id_attribute.h"
|
||||||
#include "src/tint/writer/hlsl/test_helper.h"
|
#include "src/tint/writer/hlsl/test_helper.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::writer::hlsl {
|
namespace tint::writer::hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using HlslGeneratorImplTest_ModuleConstant = TestHelper;
|
using HlslGeneratorImplTest_ModuleConstant = TestHelper;
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) {
|
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) {
|
||||||
auto* var = Let("pos", ty.array<f32, 3>(), array<f32, 3>(1.f, 2.f, 3.f));
|
auto* var = Let("pos", ty.array<f32, 3>(), array<f32, 3>(1_f, 2_f, 3_f));
|
||||||
WrapInFunction(Decl(var));
|
WrapInFunction(Decl(var));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -31,7 +33,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant) {
|
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant) {
|
||||||
auto* var = Override("pos", ty.f32(), Expr(3.0f),
|
auto* var = Override("pos", ty.f32(), Expr(3_f),
|
||||||
ast::AttributeList{
|
ast::AttributeList{
|
||||||
Id(23),
|
Id(23),
|
||||||
});
|
});
|
||||||
|
@ -63,11 +65,11 @@ static const float pos = WGSL_SPEC_CONSTANT_23;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant_NoId) {
|
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant_NoId) {
|
||||||
auto* a = Override("a", ty.f32(), Expr(3.0f),
|
auto* a = Override("a", ty.f32(), Expr(3_f),
|
||||||
ast::AttributeList{
|
ast::AttributeList{
|
||||||
Id(0),
|
Id(0),
|
||||||
});
|
});
|
||||||
auto* b = Override("b", ty.f32(), Expr(2.0f));
|
auto* b = Override("b", ty.f32(), Expr(2_f));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,7 @@ TEST_F(HlslSanitizerTest, PromoteStructInitializerToConstVar) {
|
||||||
Member("b", ty.vec3<f32>()),
|
Member("b", ty.vec3<f32>()),
|
||||||
Member("c", ty.i32()),
|
Member("c", ty.i32()),
|
||||||
});
|
});
|
||||||
auto* struct_init = Construct(ty.Of(str), 1_i, vec3<f32>(2.f, 3.f, 4.f), 4_i);
|
auto* struct_init = Construct(ty.Of(str), 1_i, vec3<f32>(2_f, 3_f, 4_f), 4_i);
|
||||||
auto* struct_access = MemberAccessor(struct_init, "b");
|
auto* struct_access = MemberAccessor(struct_init, "b");
|
||||||
auto* pos = Var("pos", ty.vec3<f32>(), ast::StorageClass::kNone, struct_access);
|
auto* pos = Var("pos", ty.vec3<f32>(), ast::StorageClass::kNone, struct_access);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ using HlslGeneratorImplTest_WorkgroupVar = TestHelper;
|
||||||
TEST_F(HlslGeneratorImplTest_WorkgroupVar, Basic) {
|
TEST_F(HlslGeneratorImplTest_WorkgroupVar, Basic) {
|
||||||
Global("wg", ty.f32(), ast::StorageClass::kWorkgroup);
|
Global("wg", ty.f32(), ast::StorageClass::kWorkgroup);
|
||||||
|
|
||||||
Func("main", {}, ty.void_(), {Assign("wg", 1.2f)},
|
Func("main", {}, ty.void_(), {Assign("wg", 1.2_f)},
|
||||||
{
|
{
|
||||||
Stage(ast::PipelineStage::kCompute),
|
Stage(ast::PipelineStage::kCompute),
|
||||||
WorkgroupSize(1_i),
|
WorkgroupSize(1_i),
|
||||||
|
@ -45,7 +45,7 @@ TEST_F(HlslGeneratorImplTest_WorkgroupVar, Aliased) {
|
||||||
|
|
||||||
Global("wg", ty.Of(alias), ast::StorageClass::kWorkgroup);
|
Global("wg", ty.Of(alias), ast::StorageClass::kWorkgroup);
|
||||||
|
|
||||||
Func("main", {}, ty.void_(), {Assign("wg", 1.2f)},
|
Func("main", {}, ty.void_(), {Assign("wg", 1.2_f)},
|
||||||
{
|
{
|
||||||
Stage(ast::PipelineStage::kCompute),
|
Stage(ast::PipelineStage::kCompute),
|
||||||
WorkgroupSize(1_i),
|
WorkgroupSize(1_i),
|
||||||
|
|
|
@ -15,13 +15,15 @@
|
||||||
#include "src/tint/ast/call_statement.h"
|
#include "src/tint/ast/call_statement.h"
|
||||||
#include "src/tint/writer/msl/test_helper.h"
|
#include "src/tint/writer/msl/test_helper.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::writer::msl {
|
namespace tint::writer::msl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using MslGeneratorImplTest = TestHelper;
|
using MslGeneratorImplTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithoutParams) {
|
TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithoutParams) {
|
||||||
Func("my_func", {}, ty.f32(), {Return(1.23f)});
|
Func("my_func", {}, ty.f32(), {Return(1.23_f)});
|
||||||
|
|
||||||
auto* call = Call("my_func");
|
auto* call = Call("my_func");
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
@ -39,7 +41,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithParams) {
|
||||||
Param(Sym(), ty.f32()),
|
Param(Sym(), ty.f32()),
|
||||||
Param(Sym(), ty.f32()),
|
Param(Sym(), ty.f32()),
|
||||||
},
|
},
|
||||||
ty.f32(), {Return(1.23f)});
|
ty.f32(), {Return(1.23_f)});
|
||||||
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
|
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
|
||||||
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
|
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_UInt) {
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, EmitConstructor_Float) {
|
TEST_F(MslGeneratorImplTest, EmitConstructor_Float) {
|
||||||
// Use a number close to 1<<30 but whose decimal representation ends in 0.
|
// Use a number close to 1<<30 but whose decimal representation ends in 0.
|
||||||
WrapInFunction(Expr(static_cast<float>((1 << 30) - 4)));
|
WrapInFunction(Expr(f32((1 << 30) - 4)));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Float) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Float) {
|
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Float) {
|
||||||
WrapInFunction(Construct<f32>(-1.2e-5f));
|
WrapInFunction(Construct<f32>(-1.2e-5_f));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Uint) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Vec) {
|
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Vec) {
|
||||||
WrapInFunction(vec3<f32>(1.f, 2.f, 3.f));
|
WrapInFunction(vec3<f32>(1_f, 2_f, 3_f));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -116,8 +116,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Vec_Empty) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Mat) {
|
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Mat) {
|
||||||
WrapInFunction(
|
WrapInFunction(Construct(ty.mat2x3<f32>(), vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(3_f, 4_f, 5_f)));
|
||||||
Construct(ty.mat2x3<f32>(), vec3<f32>(1.0f, 2.0f, 3.0f), vec3<f32>(3.0f, 4.0f, 5.0f)));
|
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -139,8 +138,8 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Mat_Empty) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Array) {
|
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Array) {
|
||||||
WrapInFunction(Construct(ty.array(ty.vec3<f32>(), 3_u), vec3<f32>(1.0f, 2.0f, 3.0f),
|
WrapInFunction(Construct(ty.array(ty.vec3<f32>(), 3_u), vec3<f32>(1_f, 2_f, 3_f),
|
||||||
vec3<f32>(4.0f, 5.0f, 6.0f), vec3<f32>(7.0f, 8.0f, 9.0f)));
|
vec3<f32>(4_f, 5_f, 6_f), vec3<f32>(7_f, 8_f, 9_f)));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -156,7 +155,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Struct) {
|
||||||
Member("c", ty.vec3<i32>()),
|
Member("c", ty.vec3<i32>()),
|
||||||
});
|
});
|
||||||
|
|
||||||
WrapInFunction(Construct(ty.Of(str), 1_i, 2.0f, vec3<i32>(3_i, 4_i, 5_i)));
|
WrapInFunction(Construct(ty.Of(str), 1_i, 2_f, vec3<i32>(3_i, 4_i, 5_i)));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,7 @@ TEST_F(MslGeneratorImplTest, Emit_Attribute_EntryPoint_SharedStruct_DifferentSta
|
||||||
});
|
});
|
||||||
|
|
||||||
Func("vert_main", {}, ty.Of(interface_struct),
|
Func("vert_main", {}, ty.Of(interface_struct),
|
||||||
{Return(Construct(ty.Of(interface_struct), Expr(0.5f), Expr(0.25f),
|
{Return(Construct(ty.Of(interface_struct), Expr(0.5_f), Expr(0.25_f),
|
||||||
Construct(ty.vec4<f32>())))},
|
Construct(ty.vec4<f32>())))},
|
||||||
{Stage(ast::PipelineStage::kVertex)});
|
{Stage(ast::PipelineStage::kVertex)});
|
||||||
|
|
||||||
|
@ -257,13 +257,13 @@ TEST_F(MslGeneratorImplTest, Emit_Attribute_EntryPoint_SharedStruct_HelperFuncti
|
||||||
|
|
||||||
Func("foo", {Param("x", ty.f32())}, ty.Of(vertex_output_struct),
|
Func("foo", {Param("x", ty.f32())}, ty.Of(vertex_output_struct),
|
||||||
{Return(Construct(ty.Of(vertex_output_struct),
|
{Return(Construct(ty.Of(vertex_output_struct),
|
||||||
Construct(ty.vec4<f32>(), "x", "x", "x", Expr(1.f))))},
|
Construct(ty.vec4<f32>(), "x", "x", "x", Expr(1_f))))},
|
||||||
{});
|
{});
|
||||||
|
|
||||||
Func("vert_main1", {}, ty.Of(vertex_output_struct), {Return(Expr(Call("foo", Expr(0.5f))))},
|
Func("vert_main1", {}, ty.Of(vertex_output_struct), {Return(Expr(Call("foo", Expr(0.5_f))))},
|
||||||
{Stage(ast::PipelineStage::kVertex)});
|
{Stage(ast::PipelineStage::kVertex)});
|
||||||
|
|
||||||
Func("vert_main2", {}, ty.Of(vertex_output_struct), {Return(Expr(Call("foo", Expr(0.25f))))},
|
Func("vert_main2", {}, ty.Of(vertex_output_struct), {Return(Expr(Call("foo", Expr(0.25_f))))},
|
||||||
{Stage(ast::PipelineStage::kVertex)});
|
{Stage(ast::PipelineStage::kVertex)});
|
||||||
|
|
||||||
GeneratorImpl& gen = SanitizeAndBuild();
|
GeneratorImpl& gen = SanitizeAndBuild();
|
||||||
|
@ -415,7 +415,7 @@ TEST_F(MslGeneratorImplTest, Emit_Attribute_Called_By_EntryPoint_With_Uniform) {
|
||||||
Return(MemberAccessor(MemberAccessor(ubo, "coord"), "x")),
|
Return(MemberAccessor(MemberAccessor(ubo, "coord"), "x")),
|
||||||
});
|
});
|
||||||
|
|
||||||
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1.0f));
|
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1_f));
|
||||||
|
|
||||||
Func("frag_main", {}, ty.void_(),
|
Func("frag_main", {}, ty.void_(),
|
||||||
{
|
{
|
||||||
|
@ -467,7 +467,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_Called_By_EntryPoint_With_RW
|
||||||
|
|
||||||
Func("sub_func", params, ty.f32(), body, {});
|
Func("sub_func", params, ty.f32(), body, {});
|
||||||
|
|
||||||
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1.0f));
|
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1_f));
|
||||||
|
|
||||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||||
ast::StatementList{
|
ast::StatementList{
|
||||||
|
@ -520,7 +520,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_Called_By_EntryPoint_With_RO
|
||||||
|
|
||||||
Func("sub_func", params, ty.f32(), body, {});
|
Func("sub_func", params, ty.f32(), body, {});
|
||||||
|
|
||||||
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1.0f));
|
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1_f));
|
||||||
|
|
||||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||||
ast::StatementList{
|
ast::StatementList{
|
||||||
|
|
|
@ -33,7 +33,7 @@ inline std::ostream& operator<<(std::ostream& out, MslImportData data) {
|
||||||
using MslImportData_SingleParamTest = TestParamHelper<MslImportData>;
|
using MslImportData_SingleParamTest = TestParamHelper<MslImportData>;
|
||||||
TEST_P(MslImportData_SingleParamTest, FloatScalar) {
|
TEST_P(MslImportData_SingleParamTest, FloatScalar) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
auto* call = Call(param.name, 1.f);
|
auto* call = Call(param.name, 1_f);
|
||||||
|
|
||||||
// The resolver will set the builtin data for the ident
|
// The resolver will set the builtin data for the ident
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
@ -87,7 +87,7 @@ TEST_F(MslGeneratorImplTest, MslImportData_SingleParamTest_IntScalar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, MslImportData_SingleParamTest_ScalarLength) {
|
TEST_F(MslGeneratorImplTest, MslImportData_SingleParamTest_ScalarLength) {
|
||||||
auto* expr = Call("length", 2.f);
|
auto* expr = Call("length", 2_f);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -100,7 +100,7 @@ TEST_F(MslGeneratorImplTest, MslImportData_SingleParamTest_ScalarLength) {
|
||||||
using MslImportData_DualParam_ScalarTest = TestParamHelper<MslImportData>;
|
using MslImportData_DualParam_ScalarTest = TestParamHelper<MslImportData>;
|
||||||
TEST_P(MslImportData_DualParam_ScalarTest, Float) {
|
TEST_P(MslImportData_DualParam_ScalarTest, Float) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
auto* expr = Call(param.name, 1.0f, 2.0f);
|
auto* expr = Call(param.name, 1_f, 2_f);
|
||||||
|
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest,
|
||||||
MslImportData{"step", "step"}));
|
MslImportData{"step", "step"}));
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, MslImportData_DualParam_ScalarDistance) {
|
TEST_F(MslGeneratorImplTest, MslImportData_DualParam_ScalarDistance) {
|
||||||
auto* expr = Call("distance", 2.f, 3.f);
|
auto* expr = Call("distance", 2_f, 3_f);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -133,7 +133,7 @@ using MslImportData_DualParam_VectorTest = TestParamHelper<MslImportData>;
|
||||||
TEST_P(MslImportData_DualParam_VectorTest, Float) {
|
TEST_P(MslImportData_DualParam_VectorTest, Float) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* expr = Call(param.name, vec3<f32>(1.f, 2.f, 3.f), vec3<f32>(4.f, 5.f, 6.f));
|
auto* expr = Call(param.name, vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(4_f, 5_f, 6_f));
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -175,7 +175,7 @@ using MslImportData_TripleParam_ScalarTest = TestParamHelper<MslImportData>;
|
||||||
TEST_P(MslImportData_TripleParam_ScalarTest, Float) {
|
TEST_P(MslImportData_TripleParam_ScalarTest, Float) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* expr = Call(param.name, 1.f, 2.f, 3.f);
|
auto* expr = Call(param.name, 1_f, 2_f, 3_f);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -195,8 +195,8 @@ using MslImportData_TripleParam_VectorTest = TestParamHelper<MslImportData>;
|
||||||
TEST_P(MslImportData_TripleParam_VectorTest, Float) {
|
TEST_P(MslImportData_TripleParam_VectorTest, Float) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* expr = Call(param.name, vec3<f32>(1.f, 2.f, 3.f), vec3<f32>(4.f, 5.f, 6.f),
|
auto* expr = Call(param.name, vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(4_f, 5_f, 6_f),
|
||||||
vec3<f32>(7.f, 8.f, 9.f));
|
vec3<f32>(7_f, 8_f, 9_f));
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
|
@ -109,8 +109,8 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithVarUsedInContinuing) {
|
||||||
|
|
||||||
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
|
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4f))), //
|
auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4_f))), //
|
||||||
Decl(Var("other", ty.f32())), //
|
Decl(Var("other", ty.f32())), //
|
||||||
Break());
|
Break());
|
||||||
|
|
||||||
auto* continuing = Block(Assign("lhs", "rhs"));
|
auto* continuing = Block(Assign("lhs", "rhs"));
|
||||||
|
|
|
@ -15,13 +15,15 @@
|
||||||
#include "src/tint/ast/id_attribute.h"
|
#include "src/tint/ast/id_attribute.h"
|
||||||
#include "src/tint/writer/msl/test_helper.h"
|
#include "src/tint/writer/msl/test_helper.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::writer::msl {
|
namespace tint::writer::msl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using MslGeneratorImplTest = TestHelper;
|
using MslGeneratorImplTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, Emit_ModuleConstant) {
|
TEST_F(MslGeneratorImplTest, Emit_ModuleConstant) {
|
||||||
auto* var = GlobalConst("pos", ty.array<f32, 3>(), array<f32, 3>(1.f, 2.f, 3.f));
|
auto* var = GlobalConst("pos", ty.array<f32, 3>(), array<f32, 3>(1_f, 2_f, 3_f));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -30,7 +32,7 @@ TEST_F(MslGeneratorImplTest, Emit_ModuleConstant) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, Emit_SpecConstant) {
|
TEST_F(MslGeneratorImplTest, Emit_SpecConstant) {
|
||||||
auto* var = Override("pos", ty.f32(), Expr(3.f),
|
auto* var = Override("pos", ty.f32(), Expr(3_f),
|
||||||
ast::AttributeList{
|
ast::AttributeList{
|
||||||
Id(23),
|
Id(23),
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#include "src/tint/ast/variable_decl_statement.h"
|
#include "src/tint/ast/variable_decl_statement.h"
|
||||||
#include "src/tint/writer/msl/test_helper.h"
|
#include "src/tint/writer/msl/test_helper.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::writer::msl {
|
namespace tint::writer::msl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -122,7 +124,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Private) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_Private) {
|
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_Private) {
|
||||||
GlobalConst("initializer", ty.f32(), Expr(0.f));
|
GlobalConst("initializer", ty.f32(), Expr(0_f));
|
||||||
Global("a", ty.f32(), ast::StorageClass::kPrivate, Expr("initializer"));
|
Global("a", ty.f32(), ast::StorageClass::kPrivate, Expr("initializer"));
|
||||||
|
|
||||||
WrapInFunction(Expr("a"));
|
WrapInFunction(Expr("a"));
|
||||||
|
|
|
@ -312,7 +312,7 @@ TEST_F(BuilderTest, MemberAccessor_NonPointer) {
|
||||||
Member("b", ty.f32()),
|
Member("b", ty.f32()),
|
||||||
});
|
});
|
||||||
|
|
||||||
auto* var = Let("ident", ty.Of(s), Construct(ty.Of(s), 0.f, 0.f));
|
auto* var = Let("ident", ty.Of(s), Construct(ty.Of(s), 0_f, 0_f));
|
||||||
|
|
||||||
auto* expr = MemberAccessor("ident", "b");
|
auto* expr = MemberAccessor("ident", "b");
|
||||||
WrapInFunction(var, expr);
|
WrapInFunction(var, expr);
|
||||||
|
@ -353,7 +353,7 @@ TEST_F(BuilderTest, MemberAccessor_Nested_NonPointer) {
|
||||||
auto* s_type = Structure("my_struct", {Member("inner", ty.Of(inner_struct))});
|
auto* s_type = Structure("my_struct", {Member("inner", ty.Of(inner_struct))});
|
||||||
|
|
||||||
auto* var = Let("ident", ty.Of(s_type),
|
auto* var = Let("ident", ty.Of(s_type),
|
||||||
Construct(ty.Of(s_type), Construct(ty.Of(inner_struct), 0.f, 0.f)));
|
Construct(ty.Of(s_type), Construct(ty.Of(inner_struct), 0_f, 0_f)));
|
||||||
auto* expr = MemberAccessor(MemberAccessor("ident", "inner"), "b");
|
auto* expr = MemberAccessor(MemberAccessor("ident", "inner"), "b");
|
||||||
WrapInFunction(var, expr);
|
WrapInFunction(var, expr);
|
||||||
|
|
||||||
|
@ -443,7 +443,7 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_LHS) {
|
||||||
auto* s_type = Structure("my_struct", {Member("inner", ty.Of(inner_struct))});
|
auto* s_type = Structure("my_struct", {Member("inner", ty.Of(inner_struct))});
|
||||||
|
|
||||||
auto* var = Var("ident", ty.Of(s_type));
|
auto* var = Var("ident", ty.Of(s_type));
|
||||||
auto* expr = Assign(MemberAccessor(MemberAccessor("ident", "inner"), "a"), Expr(2.0f));
|
auto* expr = Assign(MemberAccessor(MemberAccessor("ident", "inner"), "a"), Expr(2_f));
|
||||||
WrapInFunction(var, expr);
|
WrapInFunction(var, expr);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -753,8 +753,8 @@ TEST_F(BuilderTest, IndexAccessor_Of_Vec) {
|
||||||
// pos[1u]
|
// pos[1u]
|
||||||
|
|
||||||
auto* var = Let("pos", ty.array(ty.vec2<f32>(), 3_u),
|
auto* var = Let("pos", ty.array(ty.vec2<f32>(), 3_u),
|
||||||
Construct(ty.array(ty.vec2<f32>(), 3_u), vec2<f32>(0.0f, 0.5f),
|
Construct(ty.array(ty.vec2<f32>(), 3_u), vec2<f32>(0_f, 0.5_f),
|
||||||
vec2<f32>(-0.5f, -0.5f), vec2<f32>(0.5f, -0.5f)));
|
vec2<f32>(-0.5_f, -0.5_f), vec2<f32>(0.5_f, -0.5_f)));
|
||||||
|
|
||||||
auto* expr = IndexAccessor("pos", 1_u);
|
auto* expr = IndexAccessor("pos", 1_u);
|
||||||
WrapInFunction(var, expr);
|
WrapInFunction(var, expr);
|
||||||
|
@ -796,8 +796,8 @@ TEST_F(BuilderTest, IndexAccessor_Of_Array_Of_f32) {
|
||||||
// pos[2u][1u]
|
// pos[2u][1u]
|
||||||
|
|
||||||
auto* var = Let("pos", ty.array(ty.vec2<f32>(), 3_u),
|
auto* var = Let("pos", ty.array(ty.vec2<f32>(), 3_u),
|
||||||
Construct(ty.array(ty.vec2<f32>(), 3_u), vec2<f32>(0.0f, 0.5f),
|
Construct(ty.array(ty.vec2<f32>(), 3_u), vec2<f32>(0_f, 0.5_f),
|
||||||
vec2<f32>(-0.5f, -0.5f), vec2<f32>(0.5f, -0.5f)));
|
vec2<f32>(-0.5_f, -0.5_f), vec2<f32>(0.5_f, -0.5_f)));
|
||||||
|
|
||||||
auto* expr = IndexAccessor(IndexAccessor("pos", 2_u), 1_u);
|
auto* expr = IndexAccessor(IndexAccessor("pos", 2_u), 1_u);
|
||||||
WrapInFunction(var, expr);
|
WrapInFunction(var, expr);
|
||||||
|
@ -837,7 +837,7 @@ TEST_F(BuilderTest, IndexAccessor_Vec_Literal) {
|
||||||
// let pos : vec2<f32> = vec2<f32>(0.0, 0.5);
|
// let pos : vec2<f32> = vec2<f32>(0.0, 0.5);
|
||||||
// pos[1]
|
// pos[1]
|
||||||
|
|
||||||
auto* var = Let("pos", ty.vec2<f32>(), vec2<f32>(0.0f, 0.5f));
|
auto* var = Let("pos", ty.vec2<f32>(), vec2<f32>(0_f, 0.5_f));
|
||||||
|
|
||||||
auto* expr = IndexAccessor("pos", 1_u);
|
auto* expr = IndexAccessor("pos", 1_u);
|
||||||
WrapInFunction(var, expr);
|
WrapInFunction(var, expr);
|
||||||
|
@ -867,7 +867,7 @@ TEST_F(BuilderTest, IndexAccessor_Vec_Dynamic) {
|
||||||
// idx : i32
|
// idx : i32
|
||||||
// pos[idx]
|
// pos[idx]
|
||||||
|
|
||||||
auto* var = Let("pos", ty.vec2<f32>(), vec2<f32>(0.0f, 0.5f));
|
auto* var = Let("pos", ty.vec2<f32>(), vec2<f32>(0_f, 0.5_f));
|
||||||
auto* idx = Var("idx", ty.i32());
|
auto* idx = Var("idx", ty.i32());
|
||||||
auto* expr = IndexAccessor("pos", idx);
|
auto* expr = IndexAccessor("pos", idx);
|
||||||
|
|
||||||
|
@ -902,7 +902,7 @@ TEST_F(BuilderTest, IndexAccessor_Array_Literal) {
|
||||||
// let a : array<f32, 3u>;
|
// let a : array<f32, 3u>;
|
||||||
// a[2i]
|
// a[2i]
|
||||||
|
|
||||||
auto* var = Let("a", ty.array<f32, 3>(), Construct(ty.array<f32, 3>(), 0.0f, 0.5f, 1.0f));
|
auto* var = Let("a", ty.array<f32, 3>(), Construct(ty.array<f32, 3>(), 0_f, 0.5_f, 1_f));
|
||||||
auto* expr = IndexAccessor("a", 2_i);
|
auto* expr = IndexAccessor("a", 2_i);
|
||||||
WrapInFunction(var, expr);
|
WrapInFunction(var, expr);
|
||||||
|
|
||||||
|
@ -937,7 +937,7 @@ TEST_F(BuilderTest, IndexAccessor_Array_Dynamic) {
|
||||||
// idx : i32
|
// idx : i32
|
||||||
// a[idx]
|
// a[idx]
|
||||||
|
|
||||||
auto* var = Let("a", ty.array<f32, 3>(), Construct(ty.array<f32, 3>(), 0.0f, 0.5f, 1.0f));
|
auto* var = Let("a", ty.array<f32, 3>(), Construct(ty.array<f32, 3>(), 0_f, 0.5_f, 1_f));
|
||||||
|
|
||||||
auto* idx = Var("idx", ty.i32());
|
auto* idx = Var("idx", ty.i32());
|
||||||
auto* expr = IndexAccessor("a", idx);
|
auto* expr = IndexAccessor("a", idx);
|
||||||
|
@ -986,8 +986,8 @@ TEST_F(BuilderTest, IndexAccessor_Matrix_Dynamic) {
|
||||||
// a[idx]
|
// a[idx]
|
||||||
|
|
||||||
auto* var = Let("a", ty.mat2x2<f32>(),
|
auto* var = Let("a", ty.mat2x2<f32>(),
|
||||||
Construct(ty.mat2x2<f32>(), Construct(ty.vec2<f32>(), 1.f, 2.f),
|
Construct(ty.mat2x2<f32>(), Construct(ty.vec2<f32>(), 1_f, 2_f),
|
||||||
Construct(ty.vec2<f32>(), 3.f, 4.f)));
|
Construct(ty.vec2<f32>(), 3_f, 4_f)));
|
||||||
|
|
||||||
auto* idx = Var("idx", ty.i32());
|
auto* idx = Var("idx", ty.i32());
|
||||||
auto* expr = IndexAccessor("a", idx);
|
auto* expr = IndexAccessor("a", idx);
|
||||||
|
|
|
@ -25,7 +25,7 @@ using BuilderTest = TestHelper;
|
||||||
TEST_F(BuilderTest, Assign_Var) {
|
TEST_F(BuilderTest, Assign_Var) {
|
||||||
auto* v = Global("var", ty.f32(), ast::StorageClass::kPrivate);
|
auto* v = Global("var", ty.f32(), ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
auto* assign = Assign("var", 1.f);
|
auto* assign = Assign("var", 1_f);
|
||||||
|
|
||||||
WrapInFunction(assign);
|
WrapInFunction(assign);
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ TEST_F(BuilderTest, Assign_Var) {
|
||||||
TEST_F(BuilderTest, Assign_Var_OutsideFunction_IsError) {
|
TEST_F(BuilderTest, Assign_Var_OutsideFunction_IsError) {
|
||||||
auto* v = Global("var", ty.f32(), ast::StorageClass::kPrivate);
|
auto* v = Global("var", ty.f32(), ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
auto* assign = Assign("var", Expr(1.f));
|
auto* assign = Assign("var", Expr(1_f));
|
||||||
|
|
||||||
WrapInFunction(assign);
|
WrapInFunction(assign);
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ TEST_F(BuilderTest, Assign_Var_ZeroConstructor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest, Assign_Var_Complex_ConstructorWithExtract) {
|
TEST_F(BuilderTest, Assign_Var_Complex_ConstructorWithExtract) {
|
||||||
auto* init = vec3<f32>(vec2<f32>(1.f, 2.f), 3.f);
|
auto* init = vec3<f32>(vec2<f32>(1_f, 2_f), 3_f);
|
||||||
|
|
||||||
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
|
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ OpStore %1 %13
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest, Assign_Var_Complex_Constructor) {
|
TEST_F(BuilderTest, Assign_Var_Complex_Constructor) {
|
||||||
auto* init = vec3<f32>(1.f, 2.f, 3.f);
|
auto* init = vec3<f32>(1_f, 2_f, 3_f);
|
||||||
|
|
||||||
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
|
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ TEST_F(BuilderTest, Assign_StructMember) {
|
||||||
|
|
||||||
auto* v = Var("ident", ty.Of(s));
|
auto* v = Var("ident", ty.Of(s));
|
||||||
|
|
||||||
auto* assign = Assign(MemberAccessor("ident", "b"), Expr(4.f));
|
auto* assign = Assign(MemberAccessor("ident", "b"), Expr(4_f));
|
||||||
|
|
||||||
WrapInFunction(v, assign);
|
WrapInFunction(v, assign);
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ OpStore %8 %9
|
||||||
TEST_F(BuilderTest, Assign_Vector) {
|
TEST_F(BuilderTest, Assign_Vector) {
|
||||||
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
|
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
auto* val = vec3<f32>(1.f, 1.f, 3.f);
|
auto* val = vec3<f32>(1_f, 1_f, 3_f);
|
||||||
auto* assign = Assign("var", val);
|
auto* assign = Assign("var", val);
|
||||||
|
|
||||||
WrapInFunction(assign);
|
WrapInFunction(assign);
|
||||||
|
@ -249,7 +249,7 @@ TEST_F(BuilderTest, Assign_Vector_MemberByName) {
|
||||||
|
|
||||||
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
|
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
auto* assign = Assign(MemberAccessor("var", "y"), Expr(1.f));
|
auto* assign = Assign(MemberAccessor("var", "y"), Expr(1_f));
|
||||||
|
|
||||||
WrapInFunction(assign);
|
WrapInFunction(assign);
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ TEST_F(BuilderTest, Assign_Vector_MemberByIndex) {
|
||||||
|
|
||||||
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
|
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
auto* assign = Assign(IndexAccessor("var", 1_i), Expr(1.f));
|
auto* assign = Assign(IndexAccessor("var", 1_i), Expr(1_f));
|
||||||
|
|
||||||
WrapInFunction(assign);
|
WrapInFunction(assign);
|
||||||
|
|
||||||
|
|
|
@ -195,8 +195,8 @@ using BinaryArithFloatTest = TestParamHelper<BinaryData>;
|
||||||
TEST_P(BinaryArithFloatTest, Scalar) {
|
TEST_P(BinaryArithFloatTest, Scalar) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* lhs = Expr(3.2f);
|
auto* lhs = Expr(3.2_f);
|
||||||
auto* rhs = Expr(4.5f);
|
auto* rhs = Expr(4.5_f);
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(param.op, lhs, rhs);
|
auto* expr = create<ast::BinaryExpression>(param.op, lhs, rhs);
|
||||||
|
|
||||||
|
@ -218,8 +218,8 @@ TEST_P(BinaryArithFloatTest, Scalar) {
|
||||||
TEST_P(BinaryArithFloatTest, Vector) {
|
TEST_P(BinaryArithFloatTest, Vector) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* lhs = vec3<f32>(1.f, 1.f, 1.f);
|
auto* lhs = vec3<f32>(1_f, 1_f, 1_f);
|
||||||
auto* rhs = vec3<f32>(1.f, 1.f, 1.f);
|
auto* rhs = vec3<f32>(1_f, 1_f, 1_f);
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(param.op, lhs, rhs);
|
auto* expr = create<ast::BinaryExpression>(param.op, lhs, rhs);
|
||||||
|
|
||||||
|
@ -426,8 +426,8 @@ using BinaryCompareFloatTest = TestParamHelper<BinaryData>;
|
||||||
TEST_P(BinaryCompareFloatTest, Scalar) {
|
TEST_P(BinaryCompareFloatTest, Scalar) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* lhs = Expr(3.2f);
|
auto* lhs = Expr(3.2_f);
|
||||||
auto* rhs = Expr(4.5f);
|
auto* rhs = Expr(4.5_f);
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(param.op, lhs, rhs);
|
auto* expr = create<ast::BinaryExpression>(param.op, lhs, rhs);
|
||||||
|
|
||||||
|
@ -450,8 +450,8 @@ TEST_P(BinaryCompareFloatTest, Scalar) {
|
||||||
TEST_P(BinaryCompareFloatTest, Vector) {
|
TEST_P(BinaryCompareFloatTest, Vector) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
auto* lhs = vec3<f32>(1.f, 1.f, 1.f);
|
auto* lhs = vec3<f32>(1_f, 1_f, 1_f);
|
||||||
auto* rhs = vec3<f32>(1.f, 1.f, 1.f);
|
auto* rhs = vec3<f32>(1_f, 1_f, 1_f);
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(param.op, lhs, rhs);
|
auto* expr = create<ast::BinaryExpression>(param.op, lhs, rhs);
|
||||||
|
|
||||||
|
@ -483,8 +483,8 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
BinaryData{ast::BinaryOp::kNotEqual, "OpFOrdNotEqual"}));
|
BinaryData{ast::BinaryOp::kNotEqual, "OpFOrdNotEqual"}));
|
||||||
|
|
||||||
TEST_F(BuilderTest, Binary_Multiply_VectorScalar) {
|
TEST_F(BuilderTest, Binary_Multiply_VectorScalar) {
|
||||||
auto* lhs = vec3<f32>(1.f, 1.f, 1.f);
|
auto* lhs = vec3<f32>(1_f, 1_f, 1_f);
|
||||||
auto* rhs = Expr(1.f);
|
auto* rhs = Expr(1_f);
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
||||||
|
|
||||||
|
@ -506,8 +506,8 @@ TEST_F(BuilderTest, Binary_Multiply_VectorScalar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest, Binary_Multiply_ScalarVector) {
|
TEST_F(BuilderTest, Binary_Multiply_ScalarVector) {
|
||||||
auto* lhs = Expr(1.f);
|
auto* lhs = Expr(1_f);
|
||||||
auto* rhs = vec3<f32>(1.f, 1.f, 1.f);
|
auto* rhs = vec3<f32>(1_f, 1_f, 1_f);
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
|
||||||
|
|
||||||
|
@ -531,7 +531,7 @@ TEST_F(BuilderTest, Binary_Multiply_ScalarVector) {
|
||||||
TEST_F(BuilderTest, Binary_Multiply_MatrixScalar) {
|
TEST_F(BuilderTest, Binary_Multiply_MatrixScalar) {
|
||||||
auto* var = Var("mat", ty.mat3x3<f32>());
|
auto* var = Var("mat", ty.mat3x3<f32>());
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, Expr("mat"), Expr(1.f));
|
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, Expr("mat"), Expr(1_f));
|
||||||
|
|
||||||
WrapInFunction(var, expr);
|
WrapInFunction(var, expr);
|
||||||
|
|
||||||
|
@ -558,7 +558,7 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixScalar) {
|
||||||
TEST_F(BuilderTest, Binary_Multiply_ScalarMatrix) {
|
TEST_F(BuilderTest, Binary_Multiply_ScalarMatrix) {
|
||||||
auto* var = Var("mat", ty.mat3x3<f32>());
|
auto* var = Var("mat", ty.mat3x3<f32>());
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, Expr(1.f), Expr("mat"));
|
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, Expr(1_f), Expr("mat"));
|
||||||
|
|
||||||
WrapInFunction(var, expr);
|
WrapInFunction(var, expr);
|
||||||
|
|
||||||
|
@ -584,7 +584,7 @@ TEST_F(BuilderTest, Binary_Multiply_ScalarMatrix) {
|
||||||
|
|
||||||
TEST_F(BuilderTest, Binary_Multiply_MatrixVector) {
|
TEST_F(BuilderTest, Binary_Multiply_MatrixVector) {
|
||||||
auto* var = Var("mat", ty.mat3x3<f32>());
|
auto* var = Var("mat", ty.mat3x3<f32>());
|
||||||
auto* rhs = vec3<f32>(1.f, 1.f, 1.f);
|
auto* rhs = vec3<f32>(1_f, 1_f, 1_f);
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, Expr("mat"), rhs);
|
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, Expr("mat"), rhs);
|
||||||
|
|
||||||
|
@ -613,7 +613,7 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixVector) {
|
||||||
|
|
||||||
TEST_F(BuilderTest, Binary_Multiply_VectorMatrix) {
|
TEST_F(BuilderTest, Binary_Multiply_VectorMatrix) {
|
||||||
auto* var = Var("mat", ty.mat3x3<f32>());
|
auto* var = Var("mat", ty.mat3x3<f32>());
|
||||||
auto* lhs = vec3<f32>(1.f, 1.f, 1.f);
|
auto* lhs = vec3<f32>(1_f, 1_f, 1_f);
|
||||||
|
|
||||||
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, Expr("mat"));
|
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, Expr("mat"));
|
||||||
|
|
||||||
|
@ -899,7 +899,7 @@ enum class Type { f32, i32, u32 };
|
||||||
static const ast::Expression* MakeVectorExpr(ProgramBuilder* builder, Type type) {
|
static const ast::Expression* MakeVectorExpr(ProgramBuilder* builder, Type type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Type::f32:
|
case Type::f32:
|
||||||
return builder->vec3<f32>(1.f, 1.f, 1.f);
|
return builder->vec3<f32>(1_f, 1_f, 1_f);
|
||||||
case Type::i32:
|
case Type::i32:
|
||||||
return builder->vec3<i32>(1_i, 1_i, 1_i);
|
return builder->vec3<i32>(1_i, 1_i, 1_i);
|
||||||
case Type::u32:
|
case Type::u32:
|
||||||
|
@ -910,7 +910,7 @@ static const ast::Expression* MakeVectorExpr(ProgramBuilder* builder, Type type)
|
||||||
static const ast::Expression* MakeScalarExpr(ProgramBuilder* builder, Type type) {
|
static const ast::Expression* MakeScalarExpr(ProgramBuilder* builder, Type type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Type::f32:
|
case Type::f32:
|
||||||
return builder->Expr(1.f);
|
return builder->Expr(1_f);
|
||||||
case Type::i32:
|
case Type::i32:
|
||||||
return builder->Expr(1_i);
|
return builder->Expr(1_i);
|
||||||
case Type::u32:
|
case Type::u32:
|
||||||
|
|
|
@ -15,13 +15,15 @@
|
||||||
#include "src/tint/writer/spirv/spv_dump.h"
|
#include "src/tint/writer/spirv/spv_dump.h"
|
||||||
#include "src/tint/writer/spirv/test_helper.h"
|
#include "src/tint/writer/spirv/test_helper.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::writer::spirv {
|
namespace tint::writer::spirv {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using BuilderTest = TestHelper;
|
using BuilderTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(BuilderTest, Bitcast) {
|
TEST_F(BuilderTest, Bitcast) {
|
||||||
auto* bitcast = create<ast::BitcastExpression>(ty.u32(), Expr(2.4f));
|
auto* bitcast = create<ast::BitcastExpression>(ty.u32(), Expr(2.4_f));
|
||||||
|
|
||||||
WrapInFunction(bitcast);
|
WrapInFunction(bitcast);
|
||||||
|
|
||||||
|
@ -40,7 +42,7 @@ TEST_F(BuilderTest, Bitcast) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest, Bitcast_DuplicateType) {
|
TEST_F(BuilderTest, Bitcast_DuplicateType) {
|
||||||
auto* bitcast = create<ast::BitcastExpression>(ty.f32(), Expr(2.4f));
|
auto* bitcast = create<ast::BitcastExpression>(ty.f32(), Expr(2.4_f));
|
||||||
|
|
||||||
WrapInFunction(bitcast);
|
WrapInFunction(bitcast);
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
#include "src/tint/writer/spirv/spv_dump.h"
|
#include "src/tint/writer/spirv/spv_dump.h"
|
||||||
#include "src/tint/writer/spirv/test_helper.h"
|
#include "src/tint/writer/spirv/test_helper.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::writer::spirv {
|
namespace tint::writer::spirv {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -23,9 +25,9 @@ using BuilderTest = TestHelper;
|
||||||
TEST_F(BuilderTest, Block) {
|
TEST_F(BuilderTest, Block) {
|
||||||
// Note, this test uses shadow variables which aren't allowed in WGSL but
|
// Note, this test uses shadow variables which aren't allowed in WGSL but
|
||||||
// serves to prove the block code is pushing new scopes as needed.
|
// serves to prove the block code is pushing new scopes as needed.
|
||||||
auto* inner = Block(Decl(Var("var", ty.f32(), ast::StorageClass::kNone)), Assign("var", 2.f));
|
auto* inner = Block(Decl(Var("var", ty.f32(), ast::StorageClass::kNone)), Assign("var", 2_f));
|
||||||
auto* outer = Block(Decl(Var("var", ty.f32(), ast::StorageClass::kNone)), Assign("var", 1.f),
|
auto* outer = Block(Decl(Var("var", ty.f32(), ast::StorageClass::kNone)), Assign("var", 1_f),
|
||||||
inner, Assign("var", 3.f));
|
inner, Assign("var", 3_f));
|
||||||
|
|
||||||
WrapInFunction(outer);
|
WrapInFunction(outer);
|
||||||
|
|
||||||
|
|
|
@ -463,8 +463,8 @@ TEST_F(BuiltinBuilderTest, Call_TextureSampleCompare_Twice) {
|
||||||
create<ast::GroupAttribute>(0),
|
create<ast::GroupAttribute>(0),
|
||||||
});
|
});
|
||||||
|
|
||||||
auto* expr1 = Call("textureSampleCompare", "texture", "sampler", vec2<f32>(1.0f, 2.0f), 2.0f);
|
auto* expr1 = Call("textureSampleCompare", "texture", "sampler", vec2<f32>(1_f, 2_f), 2_f);
|
||||||
auto* expr2 = Call("textureSampleCompare", "texture", "sampler", vec2<f32>(1.0f, 2.0f), 2.0f);
|
auto* expr2 = Call("textureSampleCompare", "texture", "sampler", vec2<f32>(1_f, 2_f), 2_f);
|
||||||
|
|
||||||
Func("f1", {}, ty.void_(), {CallStmt(expr1)}, {});
|
Func("f1", {}, ty.void_(), {CallStmt(expr1)}, {});
|
||||||
Func("f2", {}, ty.void_(), {CallStmt(expr2)}, {});
|
Func("f2", {}, ty.void_(), {CallStmt(expr2)}, {});
|
||||||
|
@ -539,7 +539,7 @@ OpFunctionEnd
|
||||||
using Builtin_Builtin_SingleParam_Float_Test = BuiltinBuilderTestWithParam<BuiltinData>;
|
using Builtin_Builtin_SingleParam_Float_Test = BuiltinBuilderTestWithParam<BuiltinData>;
|
||||||
TEST_P(Builtin_Builtin_SingleParam_Float_Test, Call_Scalar) {
|
TEST_P(Builtin_Builtin_SingleParam_Float_Test, Call_Scalar) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
auto* expr = Call(param.name, 1.0f);
|
auto* expr = Call(param.name, 1_f);
|
||||||
auto* func = Func("a_func", {}, ty.void_(),
|
auto* func = Func("a_func", {}, ty.void_(),
|
||||||
{
|
{
|
||||||
Assign(Phony(), expr),
|
Assign(Phony(), expr),
|
||||||
|
@ -566,7 +566,7 @@ OpFunctionEnd
|
||||||
|
|
||||||
TEST_P(Builtin_Builtin_SingleParam_Float_Test, Call_Vector) {
|
TEST_P(Builtin_Builtin_SingleParam_Float_Test, Call_Vector) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
auto* expr = Call(param.name, vec2<f32>(1.0f, 1.0f));
|
auto* expr = Call(param.name, vec2<f32>(1_f, 1_f));
|
||||||
auto* func = Func("a_func", {}, ty.void_(),
|
auto* func = Func("a_func", {}, ty.void_(),
|
||||||
{
|
{
|
||||||
Assign(Phony(), expr),
|
Assign(Phony(), expr),
|
||||||
|
@ -620,7 +620,7 @@ INSTANTIATE_TEST_SUITE_P(BuiltinBuilderTest,
|
||||||
BuiltinData{"trunc", "Trunc"}));
|
BuiltinData{"trunc", "Trunc"}));
|
||||||
|
|
||||||
TEST_F(BuiltinBuilderTest, Call_Length_Scalar) {
|
TEST_F(BuiltinBuilderTest, Call_Length_Scalar) {
|
||||||
auto* expr = Call("length", 1.0f);
|
auto* expr = Call("length", 1_f);
|
||||||
auto* func = Func("a_func", {}, ty.void_(),
|
auto* func = Func("a_func", {}, ty.void_(),
|
||||||
{
|
{
|
||||||
Assign(Phony(), expr),
|
Assign(Phony(), expr),
|
||||||
|
@ -645,7 +645,7 @@ OpFunctionEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuiltinBuilderTest, Call_Length_Vector) {
|
TEST_F(BuiltinBuilderTest, Call_Length_Vector) {
|
||||||
auto* expr = Call("length", vec2<f32>(1.0f, 1.0f));
|
auto* expr = Call("length", vec2<f32>(1_f, 1_f));
|
||||||
auto* func = Func("a_func", {}, ty.void_(),
|
auto* func = Func("a_func", {}, ty.void_(),
|
||||||
{
|
{
|
||||||
Assign(Phony(), expr),
|
Assign(Phony(), expr),
|
||||||
|
@ -672,7 +672,7 @@ OpFunctionEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuiltinBuilderTest, Call_Normalize) {
|
TEST_F(BuiltinBuilderTest, Call_Normalize) {
|
||||||
auto* expr = Call("normalize", vec2<f32>(1.0f, 1.0f));
|
auto* expr = Call("normalize", vec2<f32>(1_f, 1_f));
|
||||||
auto* func = Func("a_func", {}, ty.void_(),
|
auto* func = Func("a_func", {}, ty.void_(),
|
||||||
{
|
{
|
||||||
Assign(Phony(), expr),
|
Assign(Phony(), expr),
|
||||||
|
@ -701,7 +701,7 @@ OpFunctionEnd
|
||||||
using Builtin_Builtin_DualParam_Float_Test = BuiltinBuilderTestWithParam<BuiltinData>;
|
using Builtin_Builtin_DualParam_Float_Test = BuiltinBuilderTestWithParam<BuiltinData>;
|
||||||
TEST_P(Builtin_Builtin_DualParam_Float_Test, Call_Scalar) {
|
TEST_P(Builtin_Builtin_DualParam_Float_Test, Call_Scalar) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
auto* expr = Call(param.name, 1.0f, 1.0f);
|
auto* expr = Call(param.name, 1_f, 1_f);
|
||||||
auto* func = Func("a_func", {}, ty.void_(),
|
auto* func = Func("a_func", {}, ty.void_(),
|
||||||
{
|
{
|
||||||
Assign(Phony(), expr),
|
Assign(Phony(), expr),
|
||||||
|
@ -728,7 +728,7 @@ OpFunctionEnd
|
||||||
|
|
||||||
TEST_P(Builtin_Builtin_DualParam_Float_Test, Call_Vector) {
|
TEST_P(Builtin_Builtin_DualParam_Float_Test, Call_Vector) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
auto* expr = Call(param.name, vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f));
|
auto* expr = Call(param.name, vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f));
|
||||||
auto* func = Func("a_func", {}, ty.void_(),
|
auto* func = Func("a_func", {}, ty.void_(),
|
||||||
{
|
{
|
||||||
Assign(Phony(), expr),
|
Assign(Phony(), expr),
|
||||||
|
@ -763,7 +763,7 @@ INSTANTIATE_TEST_SUITE_P(BuiltinBuilderTest,
|
||||||
BuiltinData{"step", "Step"}));
|
BuiltinData{"step", "Step"}));
|
||||||
|
|
||||||
TEST_F(BuiltinBuilderTest, Call_Reflect_Vector) {
|
TEST_F(BuiltinBuilderTest, Call_Reflect_Vector) {
|
||||||
auto* expr = Call("reflect", vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f));
|
auto* expr = Call("reflect", vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f));
|
||||||
auto* func = Func("a_func", {}, ty.void_(),
|
auto* func = Func("a_func", {}, ty.void_(),
|
||||||
{
|
{
|
||||||
Assign(Phony(), expr),
|
Assign(Phony(), expr),
|
||||||
|
@ -790,7 +790,7 @@ OpFunctionEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuiltinBuilderTest, Call_Distance_Scalar) {
|
TEST_F(BuiltinBuilderTest, Call_Distance_Scalar) {
|
||||||
auto* expr = Call("distance", 1.0f, 1.0f);
|
auto* expr = Call("distance", 1_f, 1_f);
|
||||||
auto* func = Func("a_func", {}, ty.void_(),
|
auto* func = Func("a_func", {}, ty.void_(),
|
||||||
{
|
{
|
||||||
Assign(Phony(), expr),
|
Assign(Phony(), expr),
|
||||||
|
@ -815,7 +815,7 @@ OpFunctionEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuiltinBuilderTest, Call_Distance_Vector) {
|
TEST_F(BuiltinBuilderTest, Call_Distance_Vector) {
|
||||||
auto* expr = Call("distance", vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f));
|
auto* expr = Call("distance", vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f));
|
||||||
auto* func = Func("a_func", {}, ty.void_(),
|
auto* func = Func("a_func", {}, ty.void_(),
|
||||||
{
|
{
|
||||||
Assign(Phony(), expr),
|
Assign(Phony(), expr),
|
||||||
|
@ -842,7 +842,7 @@ OpFunctionEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuiltinBuilderTest, Call_Cross) {
|
TEST_F(BuiltinBuilderTest, Call_Cross) {
|
||||||
auto* expr = Call("cross", vec3<f32>(1.0f, 1.0f, 1.0f), vec3<f32>(1.0f, 1.0f, 1.0f));
|
auto* expr = Call("cross", vec3<f32>(1_f, 1_f, 1_f), vec3<f32>(1_f, 1_f, 1_f));
|
||||||
auto* func = Func("a_func", {}, ty.void_(),
|
auto* func = Func("a_func", {}, ty.void_(),
|
||||||
{
|
{
|
||||||
Assign(Phony(), expr),
|
Assign(Phony(), expr),
|
||||||
|
@ -871,7 +871,7 @@ OpFunctionEnd
|
||||||
using Builtin_Builtin_ThreeParam_Float_Test = BuiltinBuilderTestWithParam<BuiltinData>;
|
using Builtin_Builtin_ThreeParam_Float_Test = BuiltinBuilderTestWithParam<BuiltinData>;
|
||||||
TEST_P(Builtin_Builtin_ThreeParam_Float_Test, Call_Scalar) {
|
TEST_P(Builtin_Builtin_ThreeParam_Float_Test, Call_Scalar) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
auto* expr = Call(param.name, 1.0f, 1.0f, 1.0f);
|
auto* expr = Call(param.name, 1_f, 1_f, 1_f);
|
||||||
auto* func = Func("a_func", {}, ty.void_(),
|
auto* func = Func("a_func", {}, ty.void_(),
|
||||||
{
|
{
|
||||||
Assign(Phony(), expr),
|
Assign(Phony(), expr),
|
||||||
|
@ -898,8 +898,7 @@ OpFunctionEnd
|
||||||
|
|
||||||
TEST_P(Builtin_Builtin_ThreeParam_Float_Test, Call_Vector) {
|
TEST_P(Builtin_Builtin_ThreeParam_Float_Test, Call_Vector) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
auto* expr =
|
auto* expr = Call(param.name, vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f));
|
||||||
Call(param.name, vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f));
|
|
||||||
auto* func = Func("a_func", {}, ty.void_(),
|
auto* func = Func("a_func", {}, ty.void_(),
|
||||||
{
|
{
|
||||||
Assign(Phony(), expr),
|
Assign(Phony(), expr),
|
||||||
|
@ -934,8 +933,7 @@ INSTANTIATE_TEST_SUITE_P(BuiltinBuilderTest,
|
||||||
BuiltinData{"smoothstep", "SmoothStep"}));
|
BuiltinData{"smoothstep", "SmoothStep"}));
|
||||||
|
|
||||||
TEST_F(BuiltinBuilderTest, Call_FaceForward_Vector) {
|
TEST_F(BuiltinBuilderTest, Call_FaceForward_Vector) {
|
||||||
auto* expr =
|
auto* expr = Call("faceForward", vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f));
|
||||||
Call("faceForward", vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f));
|
|
||||||
auto* func = Func("a_func", {}, ty.void_(),
|
auto* func = Func("a_func", {}, ty.void_(),
|
||||||
{
|
{
|
||||||
Assign(Phony(), expr),
|
Assign(Phony(), expr),
|
||||||
|
@ -1312,7 +1310,7 @@ INSTANTIATE_TEST_SUITE_P(BuiltinBuilderTest,
|
||||||
testing::Values(BuiltinData{"clamp", "UClamp"}));
|
testing::Values(BuiltinData{"clamp", "UClamp"}));
|
||||||
|
|
||||||
TEST_F(BuiltinBuilderTest, Call_Modf) {
|
TEST_F(BuiltinBuilderTest, Call_Modf) {
|
||||||
auto* expr = Call("modf", vec2<f32>(1.0f, 2.0f));
|
auto* expr = Call("modf", vec2<f32>(1_f, 2_f));
|
||||||
Func("a_func", {}, ty.void_(), {CallStmt(expr)}, {Stage(ast::PipelineStage::kFragment)});
|
Func("a_func", {}, ty.void_(), {CallStmt(expr)}, {Stage(ast::PipelineStage::kFragment)});
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -1350,7 +1348,7 @@ OpFunctionEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuiltinBuilderTest, Call_Frexp) {
|
TEST_F(BuiltinBuilderTest, Call_Frexp) {
|
||||||
auto* expr = Call("frexp", vec2<f32>(1.0f, 2.0f));
|
auto* expr = Call("frexp", vec2<f32>(1_f, 2_f));
|
||||||
Func("a_func", {}, ty.void_(), {CallStmt(expr)}, {Stage(ast::PipelineStage::kFragment)});
|
Func("a_func", {}, ty.void_(), {CallStmt(expr)}, {Stage(ast::PipelineStage::kFragment)});
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -2104,8 +2102,8 @@ TEST_P(Builtin_Builtin_DataPacking_Test, Binary) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
bool pack4 = param.name == "pack4x8snorm" || param.name == "pack4x8unorm";
|
bool pack4 = param.name == "pack4x8snorm" || param.name == "pack4x8unorm";
|
||||||
auto* call = pack4 ? Call(param.name, vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f))
|
auto* call = pack4 ? Call(param.name, vec4<f32>(1_f, 1_f, 1_f, 1_f))
|
||||||
: Call(param.name, vec2<f32>(1.0f, 1.0f));
|
: Call(param.name, vec2<f32>(1_f, 1_f));
|
||||||
auto* func = Func("a_func", {}, ty.void_(), {CallStmt(call)});
|
auto* func = Func("a_func", {}, ty.void_(), {CallStmt(call)});
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
#include "src/tint/writer/spirv/spv_dump.h"
|
#include "src/tint/writer/spirv/spv_dump.h"
|
||||||
#include "src/tint/writer/spirv/test_helper.h"
|
#include "src/tint/writer/spirv/test_helper.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::writer::spirv {
|
namespace tint::writer::spirv {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -28,7 +30,7 @@ TEST_F(BuilderTest, Expression_Call) {
|
||||||
func_params.push_back(Param("b", ty.f32()));
|
func_params.push_back(Param("b", ty.f32()));
|
||||||
|
|
||||||
auto* a_func = Func("a_func", func_params, ty.f32(), {Return(Add("a", "b"))});
|
auto* a_func = Func("a_func", func_params, ty.f32(), {Return(Add("a", "b"))});
|
||||||
auto* func = Func("main", {}, ty.void_(), {Assign(Phony(), Call("a_func", 1.f, 1.f))});
|
auto* func = Func("main", {}, ty.void_(), {Assign(Phony(), Call("a_func", 1_f, 1_f))});
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -66,7 +68,7 @@ TEST_F(BuilderTest, Statement_Call) {
|
||||||
|
|
||||||
auto* a_func = Func("a_func", func_params, ty.f32(), {Return(Add("a", "b"))});
|
auto* a_func = Func("a_func", func_params, ty.f32(), {Return(Add("a", "b"))});
|
||||||
|
|
||||||
auto* func = Func("main", {}, ty.void_(), {CallStmt(Call("a_func", 1.f, 1.f))});
|
auto* func = Func("main", {}, ty.void_(), {CallStmt(Call("a_func", 1_f, 1_f))});
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace {
|
||||||
using SpvBuilderConstructorTest = TestHelper;
|
using SpvBuilderConstructorTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Const) {
|
TEST_F(SpvBuilderConstructorTest, Const) {
|
||||||
auto* c = Expr(42.2f);
|
auto* c = Expr(42.2_f);
|
||||||
auto* g = Global("g", ty.f32(), c, ast::StorageClass::kPrivate);
|
auto* g = Global("g", ty.f32(), c, ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -50,7 +50,7 @@ TEST_F(SpvBuilderConstructorTest, Type_WithCasts_OutsideFunction_IsError) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type) {
|
TEST_F(SpvBuilderConstructorTest, Type) {
|
||||||
auto* t = vec3<f32>(1.0f, 1.0f, 3.0f);
|
auto* t = vec3<f32>(1_f, 1_f, 3_f);
|
||||||
WrapInFunction(t);
|
WrapInFunction(t);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -94,7 +94,7 @@ TEST_F(SpvBuilderConstructorTest, Type_WithAlias) {
|
||||||
// cast<Int>(2.3f)
|
// cast<Int>(2.3f)
|
||||||
|
|
||||||
auto* alias = Alias("Int", ty.i32());
|
auto* alias = Alias("Int", ty.i32());
|
||||||
auto* cast = Construct(ty.Of(alias), 2.3f);
|
auto* cast = Construct(ty.Of(alias), 2.3_f);
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -114,7 +114,7 @@ TEST_F(SpvBuilderConstructorTest, Type_WithAlias) {
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_IdentifierExpression_Param) {
|
TEST_F(SpvBuilderConstructorTest, Type_IdentifierExpression_Param) {
|
||||||
auto* var = Var("ident", ty.f32());
|
auto* var = Var("ident", ty.f32());
|
||||||
|
|
||||||
auto* t = vec2<f32>(1.0f, "ident");
|
auto* t = vec2<f32>(1_f, "ident");
|
||||||
WrapInFunction(var, t);
|
WrapInFunction(var, t);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -213,7 +213,7 @@ TEST_F(SpvBuilderConstructorTest, Type_U32_With_U32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_F32_With_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_F32_With_F32) {
|
||||||
auto* cast = Construct<f32>(2.0f);
|
auto* cast = Construct<f32>(2_f);
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -269,7 +269,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_Bool_Var) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_F32_Literal) {
|
TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_F32_Literal) {
|
||||||
auto* cast = vec2<f32>(2.0f);
|
auto* cast = vec2<f32>(2_f);
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -286,7 +286,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_F32_Literal) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_F32_Var) {
|
TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_F32_Var) {
|
||||||
auto* var = Var("v", nullptr, Expr(2.0f));
|
auto* var = Var("v", nullptr, Expr(2_f));
|
||||||
auto* cast = vec2<f32>(var);
|
auto* cast = vec2<f32>(var);
|
||||||
WrapInFunction(var, cast);
|
WrapInFunction(var, cast);
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_F32_Var) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_F32_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_F32_F32) {
|
||||||
auto* cast = vec2<f32>(2.0f, 2.0f);
|
auto* cast = vec2<f32>(2_f, 2_f);
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -325,7 +325,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_F32_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_Vec2) {
|
TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_Vec2) {
|
||||||
auto* value = vec2<f32>(2.0f, 2.0f);
|
auto* value = vec2<f32>(2_f, 2_f);
|
||||||
auto* cast = vec2<f32>(value);
|
auto* cast = vec2<f32>(value);
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_Vec2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F32) {
|
||||||
auto* cast = vec3<f32>(2.0f);
|
auto* cast = vec3<f32>(2_f);
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -375,7 +375,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_Bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F32_F32_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F32_F32_F32) {
|
||||||
auto* cast = vec3<f32>(2.0f, 2.0f, 2.0f);
|
auto* cast = vec3<f32>(2_f, 2_f, 2_f);
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -391,7 +391,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F32_F32_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F32_Vec2) {
|
TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F32_Vec2) {
|
||||||
auto* cast = vec3<f32>(2.0f, vec2<f32>(2.0f, 2.0f));
|
auto* cast = vec3<f32>(2_f, vec2<f32>(2_f, 2_f));
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -413,7 +413,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F32_Vec2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_Vec2_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_Vec2_F32) {
|
||||||
auto* cast = vec3<f32>(vec2<f32>(2.0f, 2.0f), 2.0f);
|
auto* cast = vec3<f32>(vec2<f32>(2_f, 2_f), 2_f);
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -435,7 +435,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_Vec2_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_Vec3) {
|
TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_Vec3) {
|
||||||
auto* value = vec3<f32>(2.0f, 2.0f, 2.0f);
|
auto* value = vec3<f32>(2_f, 2_f, 2_f);
|
||||||
auto* cast = vec3<f32>(value);
|
auto* cast = vec3<f32>(value);
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
|
@ -469,7 +469,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32) {
|
||||||
auto* cast = vec4<f32>(2.0f);
|
auto* cast = vec4<f32>(2_f);
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -485,7 +485,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_F32_F32_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_F32_F32_F32) {
|
||||||
auto* cast = vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f);
|
auto* cast = vec4<f32>(2_f, 2_f, 2_f, 2_f);
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -501,7 +501,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_F32_F32_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_F32_Vec2) {
|
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_F32_Vec2) {
|
||||||
auto* cast = vec4<f32>(2.0f, 2.0f, vec2<f32>(2.0f, 2.0f));
|
auto* cast = vec4<f32>(2_f, 2_f, vec2<f32>(2_f, 2_f));
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -523,7 +523,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_F32_Vec2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_Vec2_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_Vec2_F32) {
|
||||||
auto* cast = vec4<f32>(2.0f, vec2<f32>(2.0f, 2.0f), 2.0f);
|
auto* cast = vec4<f32>(2_f, vec2<f32>(2_f, 2_f), 2_f);
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -545,7 +545,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_Vec2_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec2_F32_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec2_F32_F32) {
|
||||||
auto* cast = vec4<f32>(vec2<f32>(2.0f, 2.0f), 2.0f, 2.0f);
|
auto* cast = vec4<f32>(vec2<f32>(2_f, 2_f), 2_f, 2_f);
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -567,7 +567,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec2_F32_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec2_Vec2) {
|
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec2_Vec2) {
|
||||||
auto* cast = vec4<f32>(vec2<f32>(2.0f, 2.0f), vec2<f32>(2.0f, 2.0f));
|
auto* cast = vec4<f32>(vec2<f32>(2_f, 2_f), vec2<f32>(2_f, 2_f));
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -591,7 +591,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec2_Vec2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_Vec3) {
|
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_Vec3) {
|
||||||
auto* cast = vec4<f32>(2.0f, vec3<f32>(2.0f, 2.0f, 2.0f));
|
auto* cast = vec4<f32>(2_f, vec3<f32>(2_f, 2_f, 2_f));
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -614,7 +614,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_Vec3) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec3_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec3_F32) {
|
||||||
auto* cast = vec4<f32>(vec3<f32>(2.0f, 2.0f, 2.0f), 2.0f);
|
auto* cast = vec4<f32>(vec3<f32>(2_f, 2_f, 2_f), 2_f);
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -637,7 +637,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec3_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec4) {
|
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec4) {
|
||||||
auto* value = vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f);
|
auto* value = vec4<f32>(2_f, 2_f, 2_f, 2_f);
|
||||||
auto* cast = vec4<f32>(value);
|
auto* cast = vec4<f32>(value);
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
|
@ -655,7 +655,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec4) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_F32_With_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_F32_With_F32) {
|
||||||
auto* ctor = Construct<f32>(2.0f);
|
auto* ctor = Construct<f32>(2_f);
|
||||||
GlobalConst("g", ty.f32(), ctor);
|
GlobalConst("g", ty.f32(), ctor);
|
||||||
|
|
||||||
spirv::Builder& b = SanitizeAndBuild();
|
spirv::Builder& b = SanitizeAndBuild();
|
||||||
|
@ -670,7 +670,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_F32_With_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_U32_With_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_U32_With_F32) {
|
||||||
auto* ctor = Construct<u32>(1.5f);
|
auto* ctor = Construct<u32>(1.5_f);
|
||||||
GlobalConst("g", ty.u32(), ctor);
|
GlobalConst("g", ty.u32(), ctor);
|
||||||
|
|
||||||
spirv::Builder& b = SanitizeAndBuild();
|
spirv::Builder& b = SanitizeAndBuild();
|
||||||
|
@ -685,7 +685,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_U32_With_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec2_With_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec2_With_F32) {
|
||||||
auto* cast = vec2<f32>(2.0f);
|
auto* cast = vec2<f32>(2_f);
|
||||||
auto* g = Global("g", ty.vec2<f32>(), cast, ast::StorageClass::kPrivate);
|
auto* g = Global("g", ty.vec2<f32>(), cast, ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -701,7 +701,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec2_With_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec2_With_Vec2) {
|
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec2_With_Vec2) {
|
||||||
auto* cast = vec2<f32>(vec2<f32>(2.0f, 2.0f));
|
auto* cast = vec2<f32>(vec2<f32>(2_f, 2_f));
|
||||||
GlobalConst("a", ty.vec2<f32>(), cast);
|
GlobalConst("a", ty.vec2<f32>(), cast);
|
||||||
|
|
||||||
spirv::Builder& b = SanitizeAndBuild();
|
spirv::Builder& b = SanitizeAndBuild();
|
||||||
|
@ -719,7 +719,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec2_With_Vec2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_Vec3) {
|
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_Vec3) {
|
||||||
auto* cast = vec3<f32>(vec3<f32>(2.0f, 2.0f, 2.0f));
|
auto* cast = vec3<f32>(vec3<f32>(2_f, 2_f, 2_f));
|
||||||
GlobalConst("a", ty.vec3<f32>(), cast);
|
GlobalConst("a", ty.vec3<f32>(), cast);
|
||||||
|
|
||||||
spirv::Builder& b = SanitizeAndBuild();
|
spirv::Builder& b = SanitizeAndBuild();
|
||||||
|
@ -737,7 +737,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_Vec3) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec4) {
|
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec4) {
|
||||||
auto* cast = vec4<f32>(vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f));
|
auto* cast = vec4<f32>(vec4<f32>(2_f, 2_f, 2_f, 2_f));
|
||||||
GlobalConst("a", ty.vec4<f32>(), cast);
|
GlobalConst("a", ty.vec4<f32>(), cast);
|
||||||
|
|
||||||
spirv::Builder& b = SanitizeAndBuild();
|
spirv::Builder& b = SanitizeAndBuild();
|
||||||
|
@ -755,7 +755,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec4) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_F32) {
|
||||||
auto* cast = vec3<f32>(2.0f);
|
auto* cast = vec3<f32>(2_f);
|
||||||
auto* g = Global("g", ty.vec3<f32>(), cast, ast::StorageClass::kPrivate);
|
auto* g = Global("g", ty.vec3<f32>(), cast, ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -771,7 +771,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_F32_Vec2) {
|
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_F32_Vec2) {
|
||||||
auto* cast = vec3<f32>(2.0f, vec2<f32>(2.0f, 2.0f));
|
auto* cast = vec3<f32>(2_f, vec2<f32>(2_f, 2_f));
|
||||||
auto* g = Global("g", ty.vec3<f32>(), cast, ast::StorageClass::kPrivate);
|
auto* g = Global("g", ty.vec3<f32>(), cast, ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -794,7 +794,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_F32_Vec2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_Vec2_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_Vec2_F32) {
|
||||||
auto* cast = vec3<f32>(vec2<f32>(2.0f, 2.0f), 2.0f);
|
auto* cast = vec3<f32>(vec2<f32>(2_f, 2_f), 2_f);
|
||||||
auto* g = Global("g", ty.vec3<f32>(), cast, ast::StorageClass::kPrivate);
|
auto* g = Global("g", ty.vec3<f32>(), cast, ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -817,7 +817,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_Vec2_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32) {
|
||||||
auto* cast = vec4<f32>(2.0f);
|
auto* cast = vec4<f32>(2_f);
|
||||||
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
|
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -833,7 +833,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32_F32_Vec2) {
|
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32_F32_Vec2) {
|
||||||
auto* cast = vec4<f32>(2.0f, 2.0f, vec2<f32>(2.0f, 2.0f));
|
auto* cast = vec4<f32>(2_f, 2_f, vec2<f32>(2_f, 2_f));
|
||||||
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
|
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -856,7 +856,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32_F32_Vec2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32_Vec2_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32_Vec2_F32) {
|
||||||
auto* cast = vec4<f32>(2.0f, vec2<f32>(2.0f, 2.0f), 2.0f);
|
auto* cast = vec4<f32>(2_f, vec2<f32>(2_f, 2_f), 2_f);
|
||||||
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
|
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -879,7 +879,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32_Vec2_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec2_F32_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec2_F32_F32) {
|
||||||
auto* cast = vec4<f32>(vec2<f32>(2.0f, 2.0f), 2.0f, 2.0f);
|
auto* cast = vec4<f32>(vec2<f32>(2_f, 2_f), 2_f, 2_f);
|
||||||
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
|
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -902,7 +902,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec2_F32_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec2_Vec2) {
|
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec2_Vec2) {
|
||||||
auto* cast = vec4<f32>(vec2<f32>(2.0f, 2.0f), vec2<f32>(2.0f, 2.0f));
|
auto* cast = vec4<f32>(vec2<f32>(2_f, 2_f), vec2<f32>(2_f, 2_f));
|
||||||
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
|
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -927,7 +927,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec2_Vec2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32_Vec3) {
|
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32_Vec3) {
|
||||||
auto* cast = vec4<f32>(2.0f, vec3<f32>(2.0f, 2.0f, 2.0f));
|
auto* cast = vec4<f32>(2_f, vec3<f32>(2_f, 2_f, 2_f));
|
||||||
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
|
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -952,7 +952,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32_Vec3) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec3_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec3_F32) {
|
||||||
auto* cast = vec4<f32>(vec3<f32>(2.0f, 2.0f, 2.0f), 2.0f);
|
auto* cast = vec4<f32>(vec3<f32>(2_f, 2_f, 2_f), 2_f);
|
||||||
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
|
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -977,7 +977,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec3_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Mat2x2_With_Vec2_Vec2) {
|
TEST_F(SpvBuilderConstructorTest, Type_Mat2x2_With_Vec2_Vec2) {
|
||||||
auto* cast = mat2x2<f32>(vec2<f32>(2.0f, 2.0f), vec2<f32>(2.0f, 2.0f));
|
auto* cast = mat2x2<f32>(vec2<f32>(2_f, 2_f), vec2<f32>(2_f, 2_f));
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -995,7 +995,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Mat2x2_With_Vec2_Vec2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Mat3x2_With_Vec2_Vec2_Vec2) {
|
TEST_F(SpvBuilderConstructorTest, Type_Mat3x2_With_Vec2_Vec2_Vec2) {
|
||||||
auto* cast = mat3x2<f32>(vec2<f32>(2.0f, 2.0f), vec2<f32>(2.0f, 2.0f), vec2<f32>(2.0f, 2.0f));
|
auto* cast = mat3x2<f32>(vec2<f32>(2_f, 2_f), vec2<f32>(2_f, 2_f), vec2<f32>(2_f, 2_f));
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -1013,8 +1013,8 @@ TEST_F(SpvBuilderConstructorTest, Type_Mat3x2_With_Vec2_Vec2_Vec2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Mat4x2_With_Vec2_Vec2_Vec2_Vec2) {
|
TEST_F(SpvBuilderConstructorTest, Type_Mat4x2_With_Vec2_Vec2_Vec2_Vec2) {
|
||||||
auto* cast = mat4x2<f32>(vec2<f32>(2.0f, 2.0f), vec2<f32>(2.0f, 2.0f), vec2<f32>(2.0f, 2.0f),
|
auto* cast = mat4x2<f32>(vec2<f32>(2_f, 2_f), vec2<f32>(2_f, 2_f), vec2<f32>(2_f, 2_f),
|
||||||
vec2<f32>(2.0f, 2.0f));
|
vec2<f32>(2_f, 2_f));
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -1032,7 +1032,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Mat4x2_With_Vec2_Vec2_Vec2_Vec2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Mat2x3_With_Vec3_Vec3) {
|
TEST_F(SpvBuilderConstructorTest, Type_Mat2x3_With_Vec3_Vec3) {
|
||||||
auto* cast = mat2x3<f32>(vec3<f32>(2.0f, 2.0f, 2.0f), vec3<f32>(2.0f, 2.0f, 2.0f));
|
auto* cast = mat2x3<f32>(vec3<f32>(2_f, 2_f, 2_f), vec3<f32>(2_f, 2_f, 2_f));
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -1050,8 +1050,8 @@ TEST_F(SpvBuilderConstructorTest, Type_Mat2x3_With_Vec3_Vec3) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Mat3x3_With_Vec3_Vec3_Vec3) {
|
TEST_F(SpvBuilderConstructorTest, Type_Mat3x3_With_Vec3_Vec3_Vec3) {
|
||||||
auto* cast = mat3x3<f32>(vec3<f32>(2.0f, 2.0f, 2.0f), vec3<f32>(2.0f, 2.0f, 2.0f),
|
auto* cast =
|
||||||
vec3<f32>(2.0f, 2.0f, 2.0f));
|
mat3x3<f32>(vec3<f32>(2_f, 2_f, 2_f), vec3<f32>(2_f, 2_f, 2_f), vec3<f32>(2_f, 2_f, 2_f));
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -1069,8 +1069,8 @@ TEST_F(SpvBuilderConstructorTest, Type_Mat3x3_With_Vec3_Vec3_Vec3) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Mat4x3_With_Vec3_Vec3_Vec3_Vec3) {
|
TEST_F(SpvBuilderConstructorTest, Type_Mat4x3_With_Vec3_Vec3_Vec3_Vec3) {
|
||||||
auto* cast = mat4x3<f32>(vec3<f32>(2.0f, 2.0f, 2.0f), vec3<f32>(2.0f, 2.0f, 2.0f),
|
auto* cast = mat4x3<f32>(vec3<f32>(2_f, 2_f, 2_f), vec3<f32>(2_f, 2_f, 2_f),
|
||||||
vec3<f32>(2.0f, 2.0f, 2.0f), vec3<f32>(2.0f, 2.0f, 2.0f));
|
vec3<f32>(2_f, 2_f, 2_f), vec3<f32>(2_f, 2_f, 2_f));
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -1088,7 +1088,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Mat4x3_With_Vec3_Vec3_Vec3_Vec3) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Mat2x4_With_Vec4_Vec4) {
|
TEST_F(SpvBuilderConstructorTest, Type_Mat2x4_With_Vec4_Vec4) {
|
||||||
auto* cast = mat2x4<f32>(vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f), vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f));
|
auto* cast = mat2x4<f32>(vec4<f32>(2_f, 2_f, 2_f, 2_f), vec4<f32>(2_f, 2_f, 2_f, 2_f));
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -1106,8 +1106,8 @@ TEST_F(SpvBuilderConstructorTest, Type_Mat2x4_With_Vec4_Vec4) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Mat3x4_With_Vec4_Vec4_Vec4) {
|
TEST_F(SpvBuilderConstructorTest, Type_Mat3x4_With_Vec4_Vec4_Vec4) {
|
||||||
auto* cast = mat3x4<f32>(vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f), vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f),
|
auto* cast = mat3x4<f32>(vec4<f32>(2_f, 2_f, 2_f, 2_f), vec4<f32>(2_f, 2_f, 2_f, 2_f),
|
||||||
vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f));
|
vec4<f32>(2_f, 2_f, 2_f, 2_f));
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -1125,8 +1125,8 @@ TEST_F(SpvBuilderConstructorTest, Type_Mat3x4_With_Vec4_Vec4_Vec4) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Mat4x4_With_Vec4_Vec4_Vec4_Vec4) {
|
TEST_F(SpvBuilderConstructorTest, Type_Mat4x4_With_Vec4_Vec4_Vec4_Vec4) {
|
||||||
auto* cast = mat4x4<f32>(vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f), vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f),
|
auto* cast = mat4x4<f32>(vec4<f32>(2_f, 2_f, 2_f, 2_f), vec4<f32>(2_f, 2_f, 2_f, 2_f),
|
||||||
vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f), vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f));
|
vec4<f32>(2_f, 2_f, 2_f, 2_f), vec4<f32>(2_f, 2_f, 2_f, 2_f));
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -1144,7 +1144,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Mat4x4_With_Vec4_Vec4_Vec4_Vec4) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Array_5_F32) {
|
TEST_F(SpvBuilderConstructorTest, Type_Array_5_F32) {
|
||||||
auto* cast = array<f32, 5>(2.0f, 2.0f, 2.0f, 2.0f, 2.0f);
|
auto* cast = array<f32, 5>(2_f, 2_f, 2_f, 2_f, 2_f);
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -1162,8 +1162,8 @@ TEST_F(SpvBuilderConstructorTest, Type_Array_5_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Array_2_Vec3) {
|
TEST_F(SpvBuilderConstructorTest, Type_Array_2_Vec3) {
|
||||||
auto* first = vec3<f32>(1.f, 2.f, 3.f);
|
auto* first = vec3<f32>(1_f, 2_f, 3_f);
|
||||||
auto* second = vec3<f32>(1.f, 2.f, 3.f);
|
auto* second = vec3<f32>(1_f, 2_f, 3_f);
|
||||||
auto* t = Construct(ty.array(ty.vec3<f32>(), 2_u), first, second);
|
auto* t = Construct(ty.array(ty.vec3<f32>(), 2_u), first, second);
|
||||||
WrapInFunction(t);
|
WrapInFunction(t);
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -1184,8 +1184,8 @@ TEST_F(SpvBuilderConstructorTest, Type_Array_2_Vec3) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, CommonInitializer_TwoVectors) {
|
TEST_F(SpvBuilderConstructorTest, CommonInitializer_TwoVectors) {
|
||||||
auto* v1 = vec3<f32>(2.0f, 2.0f, 2.0f);
|
auto* v1 = vec3<f32>(2_f, 2_f, 2_f);
|
||||||
auto* v2 = vec3<f32>(2.0f, 2.0f, 2.0f);
|
auto* v2 = vec3<f32>(2_f, 2_f, 2_f);
|
||||||
ast::StatementList stmts = {
|
ast::StatementList stmts = {
|
||||||
WrapInStatement(v1),
|
WrapInStatement(v1),
|
||||||
WrapInStatement(v2),
|
WrapInStatement(v2),
|
||||||
|
@ -1206,8 +1206,8 @@ TEST_F(SpvBuilderConstructorTest, CommonInitializer_TwoVectors) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, CommonInitializer_TwoArrays) {
|
TEST_F(SpvBuilderConstructorTest, CommonInitializer_TwoArrays) {
|
||||||
auto* a1 = array<f32, 3>(2.0f, 2.0f, 2.0f);
|
auto* a1 = array<f32, 3>(2_f, 2_f, 2_f);
|
||||||
auto* a2 = array<f32, 3>(2.0f, 2.0f, 2.0f);
|
auto* a2 = array<f32, 3>(2_f, 2_f, 2_f);
|
||||||
ast::StatementList stmts = {
|
ast::StatementList stmts = {
|
||||||
WrapInStatement(a1),
|
WrapInStatement(a1),
|
||||||
WrapInStatement(a2),
|
WrapInStatement(a2),
|
||||||
|
@ -1233,8 +1233,8 @@ TEST_F(SpvBuilderConstructorTest, CommonInitializer_Array_VecArray) {
|
||||||
// Test that initializers of different types with the same values produce
|
// Test that initializers of different types with the same values produce
|
||||||
// different OpConstantComposite instructions.
|
// different OpConstantComposite instructions.
|
||||||
// crbug.com/tint/777
|
// crbug.com/tint/777
|
||||||
auto* a1 = array<f32, 2>(1.0f, 2.0f);
|
auto* a1 = array<f32, 2>(1_f, 2_f);
|
||||||
auto* a2 = vec2<f32>(1.0f, 2.0f);
|
auto* a2 = vec2<f32>(1_f, 2_f);
|
||||||
ast::StatementList stmts = {
|
ast::StatementList stmts = {
|
||||||
WrapInStatement(a1),
|
WrapInStatement(a1),
|
||||||
WrapInStatement(a2),
|
WrapInStatement(a2),
|
||||||
|
@ -1264,7 +1264,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Struct) {
|
||||||
Member("b", ty.vec3<f32>()),
|
Member("b", ty.vec3<f32>()),
|
||||||
});
|
});
|
||||||
|
|
||||||
auto* t = Construct(ty.Of(s), 2.0f, vec3<f32>(2.0f, 2.0f, 2.0f));
|
auto* t = Construct(ty.Of(s), 2_f, vec3<f32>(2_f, 2_f, 2_f));
|
||||||
WrapInFunction(t);
|
WrapInFunction(t);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -1463,7 +1463,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_I32_To_U32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Convert_F32_To_I32) {
|
TEST_F(SpvBuilderConstructorTest, Type_Convert_F32_To_I32) {
|
||||||
auto* cast = Construct<i32>(2.4f);
|
auto* cast = Construct<i32>(2.4_f);
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -1481,7 +1481,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_F32_To_I32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, Type_Convert_F32_To_U32) {
|
TEST_F(SpvBuilderConstructorTest, Type_Convert_F32_To_U32) {
|
||||||
auto* cast = Construct<u32>(2.4f);
|
auto* cast = Construct<u32>(2.4_f);
|
||||||
WrapInFunction(cast);
|
WrapInFunction(cast);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -1692,7 +1692,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_U32_to_F32) {
|
||||||
|
|
||||||
TEST_F(SpvBuilderConstructorTest, IsConstructorConst_GlobalVectorWithAllConstConstructors) {
|
TEST_F(SpvBuilderConstructorTest, IsConstructorConst_GlobalVectorWithAllConstConstructors) {
|
||||||
// vec3<f32>(1.0, 2.0, 3.0) -> true
|
// vec3<f32>(1.0, 2.0, 3.0) -> true
|
||||||
auto* t = vec3<f32>(1.f, 2.f, 3.f);
|
auto* t = vec3<f32>(1_f, 2_f, 3_f);
|
||||||
WrapInFunction(t);
|
WrapInFunction(t);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -1704,8 +1704,8 @@ TEST_F(SpvBuilderConstructorTest, IsConstructorConst_GlobalVectorWithAllConstCon
|
||||||
TEST_F(SpvBuilderConstructorTest, IsConstructorConst_GlobalArrayWithAllConstConstructors) {
|
TEST_F(SpvBuilderConstructorTest, IsConstructorConst_GlobalArrayWithAllConstConstructors) {
|
||||||
// array<vec3<f32>, 2u>(vec3<f32>(1.0, 2.0, 3.0), vec3<f32>(1.0, 2.0, 3.0))
|
// array<vec3<f32>, 2u>(vec3<f32>(1.0, 2.0, 3.0), vec3<f32>(1.0, 2.0, 3.0))
|
||||||
// -> true
|
// -> true
|
||||||
auto* t = Construct(ty.array(ty.vec3<f32>(), 2_u), vec3<f32>(1.f, 2.f, 3.f),
|
auto* t = Construct(ty.array(ty.vec3<f32>(), 2_u), vec3<f32>(1_f, 2_f, 3_f),
|
||||||
vec3<f32>(1.f, 2.f, 3.f));
|
vec3<f32>(1_f, 2_f, 3_f));
|
||||||
WrapInFunction(t);
|
WrapInFunction(t);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -1717,7 +1717,7 @@ TEST_F(SpvBuilderConstructorTest, IsConstructorConst_GlobalArrayWithAllConstCons
|
||||||
TEST_F(SpvBuilderConstructorTest, IsConstructorConst_GlobalVectorWithMatchingTypeConstructors) {
|
TEST_F(SpvBuilderConstructorTest, IsConstructorConst_GlobalVectorWithMatchingTypeConstructors) {
|
||||||
// vec2<f32>(f32(1.0), f32(2.0)) -> false
|
// vec2<f32>(f32(1.0), f32(2.0)) -> false
|
||||||
|
|
||||||
auto* t = vec2<f32>(Construct<f32>(1.f), Construct<f32>(2.f));
|
auto* t = vec2<f32>(Construct<f32>(1_f), Construct<f32>(2_f));
|
||||||
WrapInFunction(t);
|
WrapInFunction(t);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -1741,7 +1741,7 @@ TEST_F(SpvBuilderConstructorTest, IsConstructorConst_GlobalWithTypeConversionCon
|
||||||
TEST_F(SpvBuilderConstructorTest, IsConstructorConst_VectorWithAllConstConstructors) {
|
TEST_F(SpvBuilderConstructorTest, IsConstructorConst_VectorWithAllConstConstructors) {
|
||||||
// vec3<f32>(1.0, 2.0, 3.0) -> true
|
// vec3<f32>(1.0, 2.0, 3.0) -> true
|
||||||
|
|
||||||
auto* t = vec3<f32>(1.f, 2.f, 3.f);
|
auto* t = vec3<f32>(1_f, 2_f, 3_f);
|
||||||
WrapInFunction(t);
|
WrapInFunction(t);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -1770,8 +1770,8 @@ TEST_F(SpvBuilderConstructorTest, IsConstructorConst_ArrayWithAllConstConstructo
|
||||||
// array<vec3<f32>, 2u>(vec3<f32>(1.0, 2.0, 3.0), vec3<f32>(1.0, 2.0, 3.0))
|
// array<vec3<f32>, 2u>(vec3<f32>(1.0, 2.0, 3.0), vec3<f32>(1.0, 2.0, 3.0))
|
||||||
// -> true
|
// -> true
|
||||||
|
|
||||||
auto* first = vec3<f32>(1.f, 2.f, 3.f);
|
auto* first = vec3<f32>(1_f, 2_f, 3_f);
|
||||||
auto* second = vec3<f32>(1.f, 2.f, 3.f);
|
auto* second = vec3<f32>(1_f, 2_f, 3_f);
|
||||||
|
|
||||||
auto* t = Construct(ty.array(ty.vec3<f32>(), 2_u), first, second);
|
auto* t = Construct(ty.array(ty.vec3<f32>(), 2_u), first, second);
|
||||||
WrapInFunction(t);
|
WrapInFunction(t);
|
||||||
|
@ -1810,7 +1810,7 @@ TEST_F(SpvBuilderConstructorTest, IsConstructorConst_Struct) {
|
||||||
Member("b", ty.vec3<f32>()),
|
Member("b", ty.vec3<f32>()),
|
||||||
});
|
});
|
||||||
|
|
||||||
auto* t = Construct(ty.Of(s), 2.f, vec3<f32>(2.f, 2.f, 2.f));
|
auto* t = Construct(ty.Of(s), 2_f, vec3<f32>(2_f, 2_f, 2_f));
|
||||||
WrapInFunction(t);
|
WrapInFunction(t);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -1843,8 +1843,8 @@ TEST_F(SpvBuilderConstructorTest, ConstantCompositeScoping) {
|
||||||
// }
|
// }
|
||||||
// let y = vec3<f32>(1.0, 2.0, 3.0); // Reuses the ID 'x'
|
// let y = vec3<f32>(1.0, 2.0, 3.0); // Reuses the ID 'x'
|
||||||
|
|
||||||
WrapInFunction(If(true, Block(Decl(Let("x", nullptr, vec3<f32>(1.f, 2.f, 3.f))))),
|
WrapInFunction(If(true, Block(Decl(Let("x", nullptr, vec3<f32>(1_f, 2_f, 3_f))))),
|
||||||
Decl(Let("y", nullptr, vec3<f32>(1.f, 2.f, 3.f))));
|
Decl(Let("y", nullptr, vec3<f32>(1_f, 2_f, 3_f))));
|
||||||
|
|
||||||
spirv::Builder& b = SanitizeAndBuild();
|
spirv::Builder& b = SanitizeAndBuild();
|
||||||
ASSERT_TRUE(b.Build());
|
ASSERT_TRUE(b.Build());
|
||||||
|
@ -1887,9 +1887,9 @@ TEST_F(SpvBuilderConstructorTest, CompositeConstructScoping) {
|
||||||
// }
|
// }
|
||||||
// let y = vec3<f32>(one, 2.0, 3.0); // Mustn't reuse the ID 'x'
|
// let y = vec3<f32>(one, 2.0, 3.0); // Mustn't reuse the ID 'x'
|
||||||
|
|
||||||
WrapInFunction(Decl(Var("one", nullptr, Expr(1.f))),
|
WrapInFunction(Decl(Var("one", nullptr, Expr(1_f))),
|
||||||
If(true, Block(Decl(Let("x", nullptr, vec3<f32>("one", 2.f, 3.f))))),
|
If(true, Block(Decl(Let("x", nullptr, vec3<f32>("one", 2_f, 3_f))))),
|
||||||
Decl(Let("y", nullptr, vec3<f32>("one", 2.f, 3.f))));
|
Decl(Let("y", nullptr, vec3<f32>("one", 2_f, 3_f))));
|
||||||
|
|
||||||
spirv::Builder& b = SanitizeAndBuild();
|
spirv::Builder& b = SanitizeAndBuild();
|
||||||
ASSERT_TRUE(b.Build());
|
ASSERT_TRUE(b.Build());
|
||||||
|
|
|
@ -118,8 +118,8 @@ TEST_F(BuilderTest, EntryPoint_ReturnValue) {
|
||||||
create<ast::BinaryExpression>(ast::BinaryOp::kGreaterThan, Expr("loc_in"), Expr(10_u));
|
create<ast::BinaryExpression>(ast::BinaryOp::kGreaterThan, Expr("loc_in"), Expr(10_u));
|
||||||
Func("frag_main", ast::VariableList{loc_in}, ty.f32(),
|
Func("frag_main", ast::VariableList{loc_in}, ty.f32(),
|
||||||
ast::StatementList{
|
ast::StatementList{
|
||||||
If(cond, Block(Return(0.5f))),
|
If(cond, Block(Return(0.5_f))),
|
||||||
Return(1.0f),
|
Return(1_f),
|
||||||
},
|
},
|
||||||
ast::AttributeList{
|
ast::AttributeList{
|
||||||
Stage(ast::PipelineStage::kFragment),
|
Stage(ast::PipelineStage::kFragment),
|
||||||
|
@ -204,7 +204,7 @@ TEST_F(BuilderTest, EntryPoint_SharedStruct) {
|
||||||
Member("pos", ty.vec4<f32>(), ast::AttributeList{Builtin(ast::Builtin::kPosition)}),
|
Member("pos", ty.vec4<f32>(), ast::AttributeList{Builtin(ast::Builtin::kPosition)}),
|
||||||
});
|
});
|
||||||
|
|
||||||
auto* vert_retval = Construct(ty.Of(interface), 42.f, Construct(ty.vec4<f32>()));
|
auto* vert_retval = Construct(ty.Of(interface), 42_f, Construct(ty.vec4<f32>()));
|
||||||
Func("vert_main", ast::VariableList{}, ty.Of(interface), {Return(vert_retval)},
|
Func("vert_main", ast::VariableList{}, ty.Of(interface), {Return(vert_retval)},
|
||||||
{Stage(ast::PipelineStage::kVertex)});
|
{Stage(ast::PipelineStage::kVertex)});
|
||||||
|
|
||||||
|
|
|
@ -244,7 +244,7 @@ OpFunctionEnd
|
||||||
TEST_F(BuilderTest, Decoration_ExecutionMode_FragDepth) {
|
TEST_F(BuilderTest, Decoration_ExecutionMode_FragDepth) {
|
||||||
Func("main", ast::VariableList{}, ty.f32(),
|
Func("main", ast::VariableList{}, ty.f32(),
|
||||||
ast::StatementList{
|
ast::StatementList{
|
||||||
Return(Expr(1.f)),
|
Return(Expr(1_f)),
|
||||||
},
|
},
|
||||||
ast::AttributeList{Stage(ast::PipelineStage::kFragment)},
|
ast::AttributeList{Stage(ast::PipelineStage::kFragment)},
|
||||||
ast::AttributeList{
|
ast::AttributeList{
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
#include "src/tint/writer/spirv/spv_dump.h"
|
#include "src/tint/writer/spirv/spv_dump.h"
|
||||||
#include "src/tint/writer/spirv/test_helper.h"
|
#include "src/tint/writer/spirv/test_helper.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::writer::spirv {
|
namespace tint::writer::spirv {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -42,7 +44,7 @@ TEST_F(BuilderTest, FunctionVar_NoStorageClass) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest, FunctionVar_WithConstantConstructor) {
|
TEST_F(BuilderTest, FunctionVar_WithConstantConstructor) {
|
||||||
auto* init = vec3<f32>(1.f, 1.f, 3.f);
|
auto* init = vec3<f32>(1_f, 1_f, 3_f);
|
||||||
auto* v = Var("var", ty.vec3<f32>(), ast::StorageClass::kFunction, init);
|
auto* v = Var("var", ty.vec3<f32>(), ast::StorageClass::kFunction, init);
|
||||||
WrapInFunction(v);
|
WrapInFunction(v);
|
||||||
|
|
||||||
|
@ -71,7 +73,7 @@ TEST_F(BuilderTest, FunctionVar_WithConstantConstructor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructor) {
|
TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructor) {
|
||||||
auto* init = vec2<f32>(1.f, Add(3.f, 3.f));
|
auto* init = vec2<f32>(1_f, Add(3_f, 3_f));
|
||||||
|
|
||||||
auto* v = Var("var", ty.vec2<f32>(), ast::StorageClass::kNone, init);
|
auto* v = Var("var", ty.vec2<f32>(), ast::StorageClass::kNone, init);
|
||||||
WrapInFunction(v);
|
WrapInFunction(v);
|
||||||
|
@ -105,7 +107,7 @@ TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructorLoadedFromVar) {
|
||||||
// var v : f32 = 1.0;
|
// var v : f32 = 1.0;
|
||||||
// var v2 : f32 = v; // Should generate the load and store automatically.
|
// var v2 : f32 = v; // Should generate the load and store automatically.
|
||||||
|
|
||||||
auto* v = Var("v", ty.f32(), ast::StorageClass::kNone, Expr(1.f));
|
auto* v = Var("v", ty.f32(), ast::StorageClass::kNone, Expr(1_f));
|
||||||
|
|
||||||
auto* v2 = Var("v2", ty.f32(), ast::StorageClass::kNone, Expr("v"));
|
auto* v2 = Var("v2", ty.f32(), ast::StorageClass::kNone, Expr("v"));
|
||||||
WrapInFunction(v, v2);
|
WrapInFunction(v, v2);
|
||||||
|
@ -140,7 +142,7 @@ TEST_F(BuilderTest, FunctionVar_ConstWithVarInitializer) {
|
||||||
// var v : f32 = 1.0;
|
// var v : f32 = 1.0;
|
||||||
// let v2 : f32 = v; // Should generate the load
|
// let v2 : f32 = v; // Should generate the load
|
||||||
|
|
||||||
auto* v = Var("v", ty.f32(), ast::StorageClass::kNone, Expr(1.f));
|
auto* v = Var("v", ty.f32(), ast::StorageClass::kNone, Expr(1_f));
|
||||||
|
|
||||||
auto* v2 = Var("v2", ty.f32(), ast::StorageClass::kNone, Expr("v"));
|
auto* v2 = Var("v2", ty.f32(), ast::StorageClass::kNone, Expr("v"));
|
||||||
WrapInFunction(v, v2);
|
WrapInFunction(v, v2);
|
||||||
|
@ -172,7 +174,7 @@ OpStore %7 %6
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest, FunctionVar_Const) {
|
TEST_F(BuilderTest, FunctionVar_Const) {
|
||||||
auto* init = vec3<f32>(1.f, 1.f, 3.f);
|
auto* init = vec3<f32>(1_f, 1_f, 3_f);
|
||||||
|
|
||||||
auto* v = Let("var", ty.vec3<f32>(), init);
|
auto* v = Let("var", ty.vec3<f32>(), init);
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
#include "src/tint/writer/spirv/spv_dump.h"
|
#include "src/tint/writer/spirv/spv_dump.h"
|
||||||
#include "src/tint/writer/spirv/test_helper.h"
|
#include "src/tint/writer/spirv/test_helper.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::writer::spirv {
|
namespace tint::writer::spirv {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -38,7 +40,7 @@ TEST_F(BuilderTest, GlobalVar_WithStorageClass) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest, GlobalVar_WithConstructor) {
|
TEST_F(BuilderTest, GlobalVar_WithConstructor) {
|
||||||
auto* init = vec3<f32>(1.f, 1.f, 3.f);
|
auto* init = vec3<f32>(1_f, 1_f, 3_f);
|
||||||
|
|
||||||
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate, init);
|
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate, init);
|
||||||
|
|
||||||
|
@ -60,7 +62,7 @@ TEST_F(BuilderTest, GlobalVar_WithConstructor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest, GlobalVar_Const) {
|
TEST_F(BuilderTest, GlobalVar_Const) {
|
||||||
auto* init = vec3<f32>(1.f, 1.f, 3.f);
|
auto* init = vec3<f32>(1_f, 1_f, 3_f);
|
||||||
|
|
||||||
auto* v = GlobalConst("var", ty.vec3<f32>(), init);
|
auto* v = GlobalConst("var", ty.vec3<f32>(), init);
|
||||||
|
|
||||||
|
@ -80,7 +82,7 @@ TEST_F(BuilderTest, GlobalVar_Const) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest, GlobalVar_Complex_Constructor) {
|
TEST_F(BuilderTest, GlobalVar_Complex_Constructor) {
|
||||||
auto* init = vec3<f32>(ast::ExpressionList{Expr(1.f), Expr(2.f), Expr(3.f)});
|
auto* init = vec3<f32>(1_f, 2_f, 3_f);
|
||||||
|
|
||||||
auto* v = GlobalConst("var", ty.vec3<f32>(), init);
|
auto* v = GlobalConst("var", ty.vec3<f32>(), init);
|
||||||
|
|
||||||
|
@ -99,7 +101,7 @@ TEST_F(BuilderTest, GlobalVar_Complex_Constructor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest, GlobalVar_Complex_ConstructorWithExtract) {
|
TEST_F(BuilderTest, GlobalVar_Complex_ConstructorWithExtract) {
|
||||||
auto* init = vec3<f32>(vec2<f32>(1.f, 2.f), 3.f);
|
auto* init = vec3<f32>(vec2<f32>(1_f, 2_f), 3_f);
|
||||||
|
|
||||||
auto* v = GlobalConst("var", ty.vec3<f32>(), init);
|
auto* v = GlobalConst("var", ty.vec3<f32>(), init);
|
||||||
|
|
||||||
|
@ -201,7 +203,7 @@ TEST_F(BuilderTest, GlobalVar_Override_Bool_NoConstructor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest, GlobalVar_Override_Scalar) {
|
TEST_F(BuilderTest, GlobalVar_Override_Scalar) {
|
||||||
auto* v = Override("var", ty.f32(), Expr(2.f),
|
auto* v = Override("var", ty.f32(), Expr(2_f),
|
||||||
ast::AttributeList{
|
ast::AttributeList{
|
||||||
Id(0),
|
Id(0),
|
||||||
});
|
});
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace {
|
||||||
using BuilderTest = TestHelper;
|
using BuilderTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(BuilderTest, IdentifierExpression_GlobalConst) {
|
TEST_F(BuilderTest, IdentifierExpression_GlobalConst) {
|
||||||
auto* init = vec3<f32>(1.f, 1.f, 3.f);
|
auto* init = vec3<f32>(1_f, 1_f, 3_f);
|
||||||
|
|
||||||
auto* v = GlobalConst("var", ty.vec3<f32>(), init);
|
auto* v = GlobalConst("var", ty.vec3<f32>(), init);
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ TEST_F(BuilderTest, IdentifierExpression_GlobalVar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest, IdentifierExpression_FunctionConst) {
|
TEST_F(BuilderTest, IdentifierExpression_FunctionConst) {
|
||||||
auto* init = vec3<f32>(1.f, 1.f, 3.f);
|
auto* init = vec3<f32>(1_f, 1_f, 3_f);
|
||||||
|
|
||||||
auto* v = Let("var", ty.vec3<f32>(), init);
|
auto* v = Let("var", ty.vec3<f32>(), init);
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
#include "src/tint/writer/spirv/spv_dump.h"
|
#include "src/tint/writer/spirv/spv_dump.h"
|
||||||
#include "src/tint/writer/spirv/test_helper.h"
|
#include "src/tint/writer/spirv/test_helper.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::writer::spirv {
|
namespace tint::writer::spirv {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -35,7 +37,7 @@ TEST_F(BuilderTest, Return) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest, Return_WithValue) {
|
TEST_F(BuilderTest, Return_WithValue) {
|
||||||
auto* val = vec3<f32>(1.f, 1.f, 3.f);
|
auto* val = vec3<f32>(1_f, 1_f, 3_f);
|
||||||
|
|
||||||
auto* ret = Return(val);
|
auto* ret = Return(val);
|
||||||
Func("test", {}, ty.vec3<f32>(), {ret}, {});
|
Func("test", {}, ty.vec3<f32>(), {ret}, {});
|
||||||
|
|
|
@ -39,7 +39,7 @@ TEST_F(BuilderTest, UnaryOp_Negation_Integer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest, UnaryOp_Negation_Float) {
|
TEST_F(BuilderTest, UnaryOp_Negation_Float) {
|
||||||
auto* expr = create<ast::UnaryOpExpression>(ast::UnaryOp::kNegation, Expr(1.f));
|
auto* expr = create<ast::UnaryOpExpression>(ast::UnaryOp::kNegation, Expr(1_f));
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
|
@ -15,13 +15,15 @@
|
||||||
#include "src/tint/ast/call_statement.h"
|
#include "src/tint/ast/call_statement.h"
|
||||||
#include "src/tint/writer/wgsl/test_helper.h"
|
#include "src/tint/writer/wgsl/test_helper.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::writer::wgsl {
|
namespace tint::writer::wgsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using WgslGeneratorImplTest = TestHelper;
|
using WgslGeneratorImplTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(WgslGeneratorImplTest, EmitExpression_Call_WithoutParams) {
|
TEST_F(WgslGeneratorImplTest, EmitExpression_Call_WithoutParams) {
|
||||||
Func("my_func", {}, ty.f32(), {Return(1.23f)});
|
Func("my_func", {}, ty.f32(), {Return(1.23_f)});
|
||||||
|
|
||||||
auto* call = Call("my_func");
|
auto* call = Call("my_func");
|
||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
|
@ -39,7 +41,7 @@ TEST_F(WgslGeneratorImplTest, EmitExpression_Call_WithParams) {
|
||||||
Param(Sym(), ty.f32()),
|
Param(Sym(), ty.f32()),
|
||||||
Param(Sym(), ty.f32()),
|
Param(Sym(), ty.f32()),
|
||||||
},
|
},
|
||||||
ty.f32(), {Return(1.23f)});
|
ty.f32(), {Return(1.23_f)});
|
||||||
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
|
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
|
||||||
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
|
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Float) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Float) {
|
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Float) {
|
||||||
WrapInFunction(Construct<f32>(Expr(-1.2e-5f)));
|
WrapInFunction(Construct<f32>(Expr(-1.2e-5_f)));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Uint) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Vec) {
|
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Vec) {
|
||||||
WrapInFunction(vec3<f32>(1.f, 2.f, 3.f));
|
WrapInFunction(vec3<f32>(1_f, 2_f, 3_f));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Vec) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Mat) {
|
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Mat) {
|
||||||
WrapInFunction(mat2x3<f32>(vec3<f32>(1.f, 2.f, 3.f), vec3<f32>(3.f, 4.f, 5.f)));
|
WrapInFunction(mat2x3<f32>(vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(3_f, 4_f, 5_f)));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -117,8 +117,8 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Mat) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Array) {
|
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Array) {
|
||||||
WrapInFunction(Construct(ty.array(ty.vec3<f32>(), 3_u), vec3<f32>(1.0f, 2.0f, 3.0f),
|
WrapInFunction(Construct(ty.array(ty.vec3<f32>(), 3_u), vec3<f32>(1_f, 2_f, 3_f),
|
||||||
vec3<f32>(4.0f, 5.0f, 6.0f), vec3<f32>(7.0f, 8.0f, 9.0f)));
|
vec3<f32>(4_f, 5_f, 6_f), vec3<f32>(7_f, 8_f, 9_f)));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_EntryPoint_Parameters) {
|
||||||
TEST_F(WgslGeneratorImplTest, Emit_Function_EntryPoint_ReturnValue) {
|
TEST_F(WgslGeneratorImplTest, Emit_Function_EntryPoint_ReturnValue) {
|
||||||
auto* func = Func("frag_main", ast::VariableList{}, ty.f32(),
|
auto* func = Func("frag_main", ast::VariableList{}, ty.f32(),
|
||||||
ast::StatementList{
|
ast::StatementList{
|
||||||
Return(1.f),
|
Return(1_f),
|
||||||
},
|
},
|
||||||
ast::AttributeList{
|
ast::AttributeList{
|
||||||
Stage(ast::PipelineStage::kFragment),
|
Stage(ast::PipelineStage::kFragment),
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
#include "src/tint/writer/wgsl/test_helper.h"
|
#include "src/tint/writer/wgsl/test_helper.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::writer::wgsl {
|
namespace tint::writer::wgsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -23,7 +25,7 @@ namespace {
|
||||||
// - 0 sign if sign is 0, 1 otherwise
|
// - 0 sign if sign is 0, 1 otherwise
|
||||||
// - 'exponent_bits' is placed in the exponent space.
|
// - 'exponent_bits' is placed in the exponent space.
|
||||||
// So, the exponent bias must already be included.
|
// So, the exponent bias must already be included.
|
||||||
float MakeFloat(int sign, int biased_exponent, int mantissa) {
|
f32 MakeFloat(int sign, int biased_exponent, int mantissa) {
|
||||||
const uint32_t sign_bit = sign ? 0x80000000u : 0u;
|
const uint32_t sign_bit = sign ? 0x80000000u : 0u;
|
||||||
// The binary32 exponent is 8 bits, just below the sign.
|
// The binary32 exponent is 8 bits, just below the sign.
|
||||||
const uint32_t exponent_bits = (biased_exponent & 0xffu) << 23;
|
const uint32_t exponent_bits = (biased_exponent & 0xffu) << 23;
|
||||||
|
@ -35,11 +37,11 @@ float MakeFloat(int sign, int biased_exponent, int mantissa) {
|
||||||
static_assert(sizeof(result) == sizeof(bits),
|
static_assert(sizeof(result) == sizeof(bits),
|
||||||
"expected float and uint32_t to be the same size");
|
"expected float and uint32_t to be the same size");
|
||||||
std::memcpy(&result, &bits, sizeof(bits));
|
std::memcpy(&result, &bits, sizeof(bits));
|
||||||
return result;
|
return f32(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FloatData {
|
struct FloatData {
|
||||||
float value;
|
f32 value;
|
||||||
std::string expected;
|
std::string expected;
|
||||||
};
|
};
|
||||||
inline std::ostream& operator<<(std::ostream& out, FloatData data) {
|
inline std::ostream& operator<<(std::ostream& out, FloatData data) {
|
||||||
|
@ -62,15 +64,15 @@ TEST_P(WgslGenerator_FloatLiteralTest, Emit) {
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(Zero,
|
INSTANTIATE_TEST_SUITE_P(Zero,
|
||||||
WgslGenerator_FloatLiteralTest,
|
WgslGenerator_FloatLiteralTest,
|
||||||
::testing::ValuesIn(std::vector<FloatData>{{0.0f, "0.0"},
|
::testing::ValuesIn(std::vector<FloatData>{{0_f, "0.0"},
|
||||||
{MakeFloat(0, 0, 0), "0.0"},
|
{MakeFloat(0, 0, 0), "0.0"},
|
||||||
{MakeFloat(1, 0, 0), "-0.0"}}));
|
{MakeFloat(1, 0, 0), "-0.0"}}));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(Normal,
|
INSTANTIATE_TEST_SUITE_P(Normal,
|
||||||
WgslGenerator_FloatLiteralTest,
|
WgslGenerator_FloatLiteralTest,
|
||||||
::testing::ValuesIn(std::vector<FloatData>{{1.0f, "1.0"},
|
::testing::ValuesIn(std::vector<FloatData>{{1_f, "1.0"},
|
||||||
{-1.0f, "-1.0"},
|
{-1_f, "-1.0"},
|
||||||
{101.375, "101.375"}}));
|
{101.375_f, "101.375"}}));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(Subnormal,
|
INSTANTIATE_TEST_SUITE_P(Subnormal,
|
||||||
WgslGenerator_FloatLiteralTest,
|
WgslGenerator_FloatLiteralTest,
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
#include "src/tint/writer/wgsl/test_helper.h"
|
#include "src/tint/writer/wgsl/test_helper.h"
|
||||||
|
|
||||||
|
using namespace tint::number_suffixes; // NOLINT
|
||||||
|
|
||||||
namespace tint::writer::wgsl {
|
namespace tint::writer::wgsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -99,7 +101,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WgslGeneratorImplTest, EmitVariable_Constructor) {
|
TEST_F(WgslGeneratorImplTest, EmitVariable_Constructor) {
|
||||||
auto* v = Global("a", ty.f32(), ast::StorageClass::kPrivate, Expr(1.0f));
|
auto* v = Global("a", ty.f32(), ast::StorageClass::kPrivate, Expr(1_f));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -109,7 +111,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Constructor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WgslGeneratorImplTest, EmitVariable_Const) {
|
TEST_F(WgslGeneratorImplTest, EmitVariable_Const) {
|
||||||
auto* v = Let("a", ty.f32(), Expr(1.0f));
|
auto* v = Let("a", ty.f32(), Expr(1_f));
|
||||||
WrapInFunction(Decl(v));
|
WrapInFunction(Decl(v));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
Loading…
Reference in New Issue