mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-14 19:31:25 +00:00
tint: Change all ProgramBuilder literals to 'i' or 'u' suffix
Unsuffixed integer literals are currently treated as i32, but will shortly become AbstractInteger. To keep tests behaving identically to how they are currently, change all test literals to using either 'i' or 'u' suffixes. Bug: tint:1504 Change-Id: Ic373d18ce1c718a16b6905568aec89da3641d36b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88845 Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
8b9d1e0800
commit
0ce9ab042e
@ -345,6 +345,7 @@ libtint_source_set("libtint_core_all_src") {
|
||||
"debug.h",
|
||||
"demangler.cc",
|
||||
"demangler.h",
|
||||
"number.h",
|
||||
"diagnostic/diagnostic.cc",
|
||||
"diagnostic/diagnostic.h",
|
||||
"diagnostic/formatter.cc",
|
||||
|
@ -232,6 +232,7 @@ set(TINT_LIB_SRCS
|
||||
clone_context.h
|
||||
demangler.cc
|
||||
demangler.h
|
||||
number.h
|
||||
inspector/entry_point.cc
|
||||
inspector/entry_point.h
|
||||
inspector/inspector.cc
|
||||
@ -1043,6 +1044,7 @@ if(TINT_BUILD_TESTS)
|
||||
transform/decompose_memory_access_test.cc
|
||||
transform/decompose_strided_array_test.cc
|
||||
transform/decompose_strided_matrix_test.cc
|
||||
transform/expand_compound_assignment_test.cc
|
||||
transform/first_index_offset_test.cc
|
||||
transform/fold_constants_test.cc
|
||||
transform/fold_trivial_single_use_lets_test.cc
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
#include "src/tint/ast/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::ast {
|
||||
namespace {
|
||||
|
||||
@ -23,7 +25,7 @@ using AstArrayTest = TestHelper;
|
||||
|
||||
TEST_F(AstArrayTest, CreateSizedArray) {
|
||||
auto* u32 = create<U32>();
|
||||
auto* count = Expr(3);
|
||||
auto* count = Expr(3_u);
|
||||
auto* arr = create<Array>(u32, count, AttributeList{});
|
||||
EXPECT_EQ(arr->type, u32);
|
||||
EXPECT_EQ(arr->count, count);
|
||||
@ -48,7 +50,7 @@ TEST_F(AstArrayTest, FriendlyName_RuntimeSized) {
|
||||
|
||||
TEST_F(AstArrayTest, FriendlyName_LiteralSized) {
|
||||
auto* i32 = create<I32>();
|
||||
auto* arr = create<Array>(i32, Expr(5), AttributeList{});
|
||||
auto* arr = create<Array>(i32, Expr(5_u), AttributeList{});
|
||||
EXPECT_EQ(arr->FriendlyName(Symbols()), "array<i32, 5>");
|
||||
}
|
||||
|
||||
@ -60,7 +62,7 @@ TEST_F(AstArrayTest, FriendlyName_ConstantSized) {
|
||||
|
||||
TEST_F(AstArrayTest, FriendlyName_WithStride) {
|
||||
auto* i32 = create<I32>();
|
||||
auto* arr = create<Array>(i32, Expr(5), AttributeList{create<StrideAttribute>(32)});
|
||||
auto* arr = create<Array>(i32, Expr(5_u), AttributeList{create<StrideAttribute>(32)});
|
||||
EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(32) array<i32, 5>");
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include "gtest/gtest-spi.h"
|
||||
#include "src/tint/ast/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::ast {
|
||||
namespace {
|
||||
|
||||
@ -53,7 +55,7 @@ TEST_F(AssignmentStatementTest, Assert_Null_LHS) {
|
||||
EXPECT_FATAL_FAILURE(
|
||||
{
|
||||
ProgramBuilder b;
|
||||
b.create<AssignmentStatement>(nullptr, b.Expr(1));
|
||||
b.create<AssignmentStatement>(nullptr, b.Expr(1_i));
|
||||
},
|
||||
"internal compiler error");
|
||||
}
|
||||
@ -62,7 +64,7 @@ TEST_F(AssignmentStatementTest, Assert_Null_RHS) {
|
||||
EXPECT_FATAL_FAILURE(
|
||||
{
|
||||
ProgramBuilder b;
|
||||
b.create<AssignmentStatement>(b.Expr(1), nullptr);
|
||||
b.create<AssignmentStatement>(b.Expr(1_i), nullptr);
|
||||
},
|
||||
"internal compiler error");
|
||||
}
|
||||
|
@ -18,11 +18,9 @@
|
||||
#include "src/tint/sem/multisampled_texture.h"
|
||||
#include "src/tint/sem/sampled_texture.h"
|
||||
|
||||
namespace tint::ast::builtin::test {
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
using u32 = ProgramBuilder::u32;
|
||||
using i32 = ProgramBuilder::i32;
|
||||
using f32 = ProgramBuilder::f32;
|
||||
namespace tint::ast::builtin::test {
|
||||
|
||||
TextureOverloadCase::TextureOverloadCase(ValidTextureOverload o,
|
||||
const char* desc,
|
||||
@ -214,7 +212,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
ast::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureDimensions",
|
||||
[](ProgramBuilder* b) { return b->ExprList("texture", 1); },
|
||||
[](ProgramBuilder* b) { return b->ExprList("texture", 1_i); },
|
||||
},
|
||||
{
|
||||
ValidTextureOverload::kDimensions2dArray,
|
||||
@ -235,7 +233,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
ast::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureDimensions",
|
||||
[](ProgramBuilder* b) { return b->ExprList("texture", 1); },
|
||||
[](ProgramBuilder* b) { return b->ExprList("texture", 1_i); },
|
||||
},
|
||||
{
|
||||
ValidTextureOverload::kDimensions3d,
|
||||
@ -256,7 +254,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
ast::TextureDimension::k3d,
|
||||
TextureDataType::kF32,
|
||||
"textureDimensions",
|
||||
[](ProgramBuilder* b) { return b->ExprList("texture", 1); },
|
||||
[](ProgramBuilder* b) { return b->ExprList("texture", 1_i); },
|
||||
},
|
||||
{
|
||||
ValidTextureOverload::kDimensionsCube,
|
||||
@ -277,7 +275,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
ast::TextureDimension::kCube,
|
||||
TextureDataType::kF32,
|
||||
"textureDimensions",
|
||||
[](ProgramBuilder* b) { return b->ExprList("texture", 1); },
|
||||
[](ProgramBuilder* b) { return b->ExprList("texture", 1_i); },
|
||||
},
|
||||
{
|
||||
ValidTextureOverload::kDimensionsCubeArray,
|
||||
@ -298,7 +296,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
ast::TextureDimension::kCubeArray,
|
||||
TextureDataType::kF32,
|
||||
"textureDimensions",
|
||||
[](ProgramBuilder* b) { return b->ExprList("texture", 1); },
|
||||
[](ProgramBuilder* b) { return b->ExprList("texture", 1_i); },
|
||||
},
|
||||
{
|
||||
ValidTextureOverload::kDimensionsMultisampled2d,
|
||||
@ -329,7 +327,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
ast::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureDimensions",
|
||||
[](ProgramBuilder* b) { return b->ExprList("texture", 1); },
|
||||
[](ProgramBuilder* b) { return b->ExprList("texture", 1_i); },
|
||||
},
|
||||
{
|
||||
ValidTextureOverload::kDimensionsDepth2dArray,
|
||||
@ -350,7 +348,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
ast::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureDimensions",
|
||||
[](ProgramBuilder* b) { return b->ExprList("texture", 1); },
|
||||
[](ProgramBuilder* b) { return b->ExprList("texture", 1_i); },
|
||||
},
|
||||
{
|
||||
ValidTextureOverload::kDimensionsDepthCube,
|
||||
@ -371,7 +369,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
ast::TextureDimension::kCube,
|
||||
TextureDataType::kF32,
|
||||
"textureDimensions",
|
||||
[](ProgramBuilder* b) { return b->ExprList("texture", 1); },
|
||||
[](ProgramBuilder* b) { return b->ExprList("texture", 1_i); },
|
||||
},
|
||||
{
|
||||
ValidTextureOverload::kDimensionsDepthCubeArray,
|
||||
@ -392,7 +390,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
ast::TextureDimension::kCubeArray,
|
||||
TextureDataType::kF32,
|
||||
"textureDimensions",
|
||||
[](ProgramBuilder* b) { return b->ExprList("texture", 1); },
|
||||
[](ProgramBuilder* b) { return b->ExprList("texture", 1_i); },
|
||||
},
|
||||
{
|
||||
ValidTextureOverload::kDimensionsDepthMultisampled2d,
|
||||
@ -460,7 +458,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureGather",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList(0, // component
|
||||
return b->ExprList(0_i, // component
|
||||
"texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f)); // coords
|
||||
@ -479,11 +477,11 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureGather",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList(0, // component
|
||||
"texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
b->vec2<i32>(3, 4)); // offset
|
||||
return b->ExprList(0_i, // component
|
||||
"texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
b->vec2<i32>(3_i, 4_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -499,11 +497,11 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureGather",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList(0, // component
|
||||
return b->ExprList(0_i, // component
|
||||
"texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3); // array index
|
||||
3_i); // array index
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -520,12 +518,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureGather",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList(0, // component
|
||||
"texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3, // array_index
|
||||
b->vec2<i32>(4, 5)); // offset
|
||||
return b->ExprList(0_i, // component
|
||||
"texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3_i, // array_index
|
||||
b->vec2<i32>(4_i, 5_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -540,7 +538,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureGather",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList(0, // component
|
||||
return b->ExprList(0_i, // component
|
||||
"texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f)); // coords
|
||||
@ -559,11 +557,11 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureGather",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList(0, // component
|
||||
return b->ExprList(0_i, // component
|
||||
"texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
4); // array_index
|
||||
4_i); // array_index
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -594,10 +592,10 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureGather",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
b->vec2<i32>(3, 4)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
b->vec2<i32>(3_i, 4_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -615,7 +613,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3); // array_index
|
||||
3_i); // array_index
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -631,11 +629,11 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureGather",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3, // array_index
|
||||
b->vec2<i32>(4, 5)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3_i, // array_index
|
||||
b->vec2<i32>(4_i, 5_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -669,7 +667,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
4); // array_index
|
||||
4_i); // array_index
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -703,11 +701,11 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureGatherCompare",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3.f, // depth_ref
|
||||
b->vec2<i32>(4, 5)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3.f, // depth_ref
|
||||
b->vec2<i32>(4_i, 5_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -726,7 +724,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3, // array_index
|
||||
3_i, // array_index
|
||||
4.f); // depth_ref
|
||||
},
|
||||
},
|
||||
@ -744,12 +742,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureGatherCompare",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3, // array_index
|
||||
4.f, // depth_ref
|
||||
b->vec2<i32>(5, 6)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3_i, // array_index
|
||||
4.f, // depth_ref
|
||||
b->vec2<i32>(5_i, 6_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -786,7 +784,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
4, // array_index
|
||||
4_i, // array_index
|
||||
5.f); // depth_ref
|
||||
},
|
||||
},
|
||||
@ -984,10 +982,10 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
b->vec2<i32>(3, 4)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
b->vec2<i32>(3_i, 4_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1005,7 +1003,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3); // array_index
|
||||
3_i); // array_index
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1021,11 +1019,11 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3, // array_index
|
||||
b->vec2<i32>(4, 5)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3_i, // array_index
|
||||
b->vec2<i32>(4_i, 5_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1056,10 +1054,10 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
b->vec3<i32>(4, 5, 6)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
b->vec3<i32>(4_i, 5_i, 6_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1093,7 +1091,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
4); // array_index
|
||||
4_i); // array_index
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1124,10 +1122,10 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
b->vec2<i32>(3, 4)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
b->vec2<i32>(3_i, 4_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1145,7 +1143,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3); // array_index
|
||||
3_i); // array_index
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1161,11 +1159,11 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3, // array_index
|
||||
b->vec2<i32>(4, 5)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3_i, // array_index
|
||||
b->vec2<i32>(4_i, 5_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1199,7 +1197,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
4); // array_index
|
||||
4_i); // array_index
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1233,11 +1231,11 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureSampleBias",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3.f, // bias
|
||||
b->vec2<i32>(4, 5)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3.f, // bias
|
||||
b->vec2<i32>(4_i, 5_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1256,7 +1254,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
4, // array_index
|
||||
4_i, // array_index
|
||||
3.f); // bias
|
||||
},
|
||||
},
|
||||
@ -1274,12 +1272,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureSampleBias",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3, // array_index
|
||||
4.f, // bias
|
||||
b->vec2<i32>(5, 6)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3_i, // array_index
|
||||
4.f, // bias
|
||||
b->vec2<i32>(5_i, 6_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1313,11 +1311,11 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureSampleBias",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
4.f, // bias
|
||||
b->vec3<i32>(5, 6, 7)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
4.f, // bias
|
||||
b->vec3<i32>(5_i, 6_i, 7_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1354,7 +1352,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
3, // array_index
|
||||
3_i, // array_index
|
||||
4.f); // bias
|
||||
},
|
||||
},
|
||||
@ -1389,11 +1387,11 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureSampleLevel",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3.f, // level
|
||||
b->vec2<i32>(4, 5)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3.f, // level
|
||||
b->vec2<i32>(4_i, 5_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1412,7 +1410,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3, // array_index
|
||||
3_i, // array_index
|
||||
4.f); // level
|
||||
},
|
||||
},
|
||||
@ -1430,12 +1428,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureSampleLevel",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3, // array_index
|
||||
4.f, // level
|
||||
b->vec2<i32>(5, 6)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3_i, // array_index
|
||||
4.f, // level
|
||||
b->vec2<i32>(5_i, 6_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1469,11 +1467,11 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureSampleLevel",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
4.f, // level
|
||||
b->vec3<i32>(5, 6, 7)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
4.f, // level
|
||||
b->vec3<i32>(5_i, 6_i, 7_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1510,7 +1508,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
4, // array_index
|
||||
4_i, // array_index
|
||||
5.f); // level
|
||||
},
|
||||
},
|
||||
@ -1529,7 +1527,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3); // level
|
||||
3_i); // level
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1545,11 +1543,11 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureSampleLevel",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3, // level
|
||||
b->vec2<i32>(4, 5)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3_i, // level
|
||||
b->vec2<i32>(4_i, 5_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1568,8 +1566,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3, // array_index
|
||||
4); // level
|
||||
3_i, // array_index
|
||||
4_i); // level
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1586,12 +1584,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureSampleLevel",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3, // array_index
|
||||
4, // level
|
||||
b->vec2<i32>(5, 6)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3_i, // array_index
|
||||
4_i, // level
|
||||
b->vec2<i32>(5_i, 6_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1609,7 +1607,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
4); // level
|
||||
4_i); // level
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1628,8 +1626,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
4, // array_index
|
||||
5); // level
|
||||
4_i, // array_index
|
||||
5_i); // level
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1666,12 +1664,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureSampleGrad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
b->vec2<f32>(3.f, 4.f), // ddx
|
||||
b->vec2<f32>(5.f, 6.f), // ddy
|
||||
b->vec2<i32>(7, 7)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
b->vec2<f32>(3.f, 4.f), // ddx
|
||||
b->vec2<f32>(5.f, 6.f), // ddy
|
||||
b->vec2<i32>(7_i, 7_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1691,7 +1689,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3, // array_index
|
||||
3_i, // array_index
|
||||
b->vec2<f32>(4.f, 5.f), // ddx
|
||||
b->vec2<f32>(6.f, 7.f)); // ddy
|
||||
},
|
||||
@ -1711,13 +1709,13 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureSampleGrad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3, // array_index
|
||||
b->vec2<f32>(4.f, 5.f), // ddx
|
||||
b->vec2<f32>(6.f, 7.f), // ddy
|
||||
b->vec2<i32>(6, 7)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3_i, // array_index
|
||||
b->vec2<f32>(4.f, 5.f), // ddx
|
||||
b->vec2<f32>(6.f, 7.f), // ddy
|
||||
b->vec2<i32>(6_i, 7_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1754,12 +1752,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureSampleGrad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
b->vec3<f32>(4.f, 5.f, 6.f), // ddx
|
||||
b->vec3<f32>(7.f, 8.f, 9.f), // ddy
|
||||
b->vec3<i32>(0, 1, 2)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
b->vec3<f32>(4.f, 5.f, 6.f), // ddx
|
||||
b->vec3<f32>(7.f, 8.f, 9.f), // ddy
|
||||
b->vec3<i32>(0_i, 1_i, 2_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1799,7 +1797,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
4, // array_index
|
||||
4_i, // array_index
|
||||
b->vec3<f32>(5.f, 6.f, 7.f), // ddx
|
||||
b->vec3<f32>(8.f, 9.f, 10.f)); // ddy
|
||||
},
|
||||
@ -1835,11 +1833,11 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureSampleCompare",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3.f, // depth_ref
|
||||
b->vec2<i32>(4, 5)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
3.f, // depth_ref
|
||||
b->vec2<i32>(4_i, 5_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1858,7 +1856,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
4, // array_index
|
||||
4_i, // array_index
|
||||
3.f); // depth_ref
|
||||
},
|
||||
},
|
||||
@ -1876,12 +1874,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureSampleCompare",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
4, // array_index
|
||||
3.f, // depth_ref
|
||||
b->vec2<i32>(5, 6)); // offset
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
4_i, // array_index
|
||||
3.f, // depth_ref
|
||||
b->vec2<i32>(5_i, 6_i)); // offset
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1918,7 +1916,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
4, // array_index
|
||||
4_i, // array_index
|
||||
5.f); // depth_ref
|
||||
},
|
||||
},
|
||||
@ -1933,8 +1931,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
"textureLoad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
1, // coords
|
||||
3); // level
|
||||
1_i, // coords
|
||||
3_i); // level
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1948,8 +1946,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
"textureLoad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
1, // coords
|
||||
3); // level
|
||||
1_i, // coords
|
||||
3_i); // level
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1963,8 +1961,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
"textureLoad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
1, // coords
|
||||
3); // level
|
||||
1_i, // coords
|
||||
3_i); // level
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1977,9 +1975,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureLoad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1, 2), // coords
|
||||
3); // level
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1_i, 2_i), // coords
|
||||
3_i); // level
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1992,9 +1990,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kU32,
|
||||
"textureLoad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1, 2), // coords
|
||||
3); // level
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1_i, 2_i), // coords
|
||||
3_i); // level
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -2007,9 +2005,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kI32,
|
||||
"textureLoad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1, 2), // coords
|
||||
3); // level
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1_i, 2_i), // coords
|
||||
3_i); // level
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -2023,10 +2021,10 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureLoad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1, 2), // coords
|
||||
3, // array_index
|
||||
4); // level
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1_i, 2_i), // coords
|
||||
3_i, // array_index
|
||||
4_i); // level
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -2040,10 +2038,10 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kU32,
|
||||
"textureLoad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1, 2), // coords
|
||||
3, // array_index
|
||||
4); // level
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1_i, 2_i), // coords
|
||||
3_i, // array_index
|
||||
4_i); // level
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -2057,10 +2055,10 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kI32,
|
||||
"textureLoad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1, 2), // coords
|
||||
3, // array_index
|
||||
4); // level
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1_i, 2_i), // coords
|
||||
3_i, // array_index
|
||||
4_i); // level
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -2073,9 +2071,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureLoad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
b->vec3<i32>(1, 2, 3), // coords
|
||||
4); // level
|
||||
return b->ExprList("texture", // t
|
||||
b->vec3<i32>(1_i, 2_i, 3_i), // coords
|
||||
4_i); // level
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -2088,9 +2086,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kU32,
|
||||
"textureLoad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
b->vec3<i32>(1, 2, 3), // coords
|
||||
4); // level
|
||||
return b->ExprList("texture", // t
|
||||
b->vec3<i32>(1_i, 2_i, 3_i), // coords
|
||||
4_i); // level
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -2103,9 +2101,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kI32,
|
||||
"textureLoad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
b->vec3<i32>(1, 2, 3), // coords
|
||||
4); // level
|
||||
return b->ExprList("texture", // t
|
||||
b->vec3<i32>(1_i, 2_i, 3_i), // coords
|
||||
4_i); // level
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -2118,9 +2116,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureLoad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1, 2), // coords
|
||||
3); // sample_index
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1_i, 2_i), // coords
|
||||
3_i); // sample_index
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -2133,9 +2131,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kU32,
|
||||
"textureLoad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1, 2), // coords
|
||||
3); // sample_index
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1_i, 2_i), // coords
|
||||
3_i); // sample_index
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -2148,9 +2146,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kI32,
|
||||
"textureLoad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1, 2), // coords
|
||||
3); // sample_index
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1_i, 2_i), // coords
|
||||
3_i); // sample_index
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -2163,9 +2161,9 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureLoad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1, 2), // coords
|
||||
3); // level
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1_i, 2_i), // coords
|
||||
3_i); // level
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -2179,10 +2177,10 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
TextureDataType::kF32,
|
||||
"textureLoad",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1, 2), // coords
|
||||
3, // array_index
|
||||
4); // level
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1_i, 2_i), // coords
|
||||
3_i, // array_index
|
||||
4_i); // level
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -2197,7 +2195,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
"textureStore",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
1, // coords
|
||||
1_i, // coords
|
||||
b->vec4<f32>(2.f, 3.f, 4.f, 5.f)); // value
|
||||
},
|
||||
},
|
||||
@ -2213,7 +2211,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
"textureStore",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1, 2), // coords
|
||||
b->vec2<i32>(1_i, 2_i), // coords
|
||||
b->vec4<f32>(3.f, 4.f, 5.f, 6.f)); // value
|
||||
},
|
||||
},
|
||||
@ -2230,8 +2228,8 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
"textureStore",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
b->vec2<i32>(1, 2), // coords
|
||||
3, // array_index
|
||||
b->vec2<i32>(1_i, 2_i), // coords
|
||||
3_i, // array_index
|
||||
b->vec4<f32>(4.f, 5.f, 6.f, 7.f)); // value
|
||||
},
|
||||
},
|
||||
@ -2247,7 +2245,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
"textureStore",
|
||||
[](ProgramBuilder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
b->vec3<i32>(1, 2, 3), // coords
|
||||
b->vec3<i32>(1_i, 2_i, 3_i), // coords
|
||||
b->vec4<f32>(4.f, 5.f, 6.f, 7.f)); // value
|
||||
},
|
||||
},
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "src/tint/ast/if_statement.h"
|
||||
#include "src/tint/ast/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::ast {
|
||||
namespace {
|
||||
|
||||
@ -26,7 +28,7 @@ using CaseStatementTest = TestHelper;
|
||||
|
||||
TEST_F(CaseStatementTest, Creation_i32) {
|
||||
CaseSelectorList b;
|
||||
auto* selector = Expr(2);
|
||||
auto* selector = Expr(2_i);
|
||||
b.push_back(selector);
|
||||
|
||||
auto* discard = create<DiscardStatement>();
|
||||
@ -41,7 +43,7 @@ TEST_F(CaseStatementTest, Creation_i32) {
|
||||
|
||||
TEST_F(CaseStatementTest, Creation_u32) {
|
||||
CaseSelectorList b;
|
||||
auto* selector = Expr(2u);
|
||||
auto* selector = Expr(2_u);
|
||||
b.push_back(selector);
|
||||
|
||||
auto* discard = create<DiscardStatement>();
|
||||
@ -56,7 +58,7 @@ TEST_F(CaseStatementTest, Creation_u32) {
|
||||
|
||||
TEST_F(CaseStatementTest, Creation_WithSource) {
|
||||
CaseSelectorList b;
|
||||
b.push_back(Expr(2));
|
||||
b.push_back(Expr(2_i));
|
||||
|
||||
auto* body = create<BlockStatement>(StatementList{
|
||||
create<DiscardStatement>(),
|
||||
@ -77,7 +79,7 @@ TEST_F(CaseStatementTest, IsDefault_WithoutSelectors) {
|
||||
|
||||
TEST_F(CaseStatementTest, IsDefault_WithSelectors) {
|
||||
CaseSelectorList b;
|
||||
b.push_back(Expr(2));
|
||||
b.push_back(Expr(2_i));
|
||||
|
||||
auto* c = create<CaseStatement>(b, create<BlockStatement>(StatementList{}));
|
||||
EXPECT_FALSE(c->IsDefault());
|
||||
@ -123,7 +125,7 @@ TEST_F(CaseStatementTest, Assert_DifferentProgramID_Selector) {
|
||||
{
|
||||
ProgramBuilder b1;
|
||||
ProgramBuilder b2;
|
||||
b1.create<CaseStatement>(CaseSelectorList{b2.Expr(2)},
|
||||
b1.create<CaseStatement>(CaseSelectorList{b2.Expr(2_i)},
|
||||
b1.create<BlockStatement>(StatementList{}));
|
||||
},
|
||||
"internal compiler error");
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include "gtest/gtest-spi.h"
|
||||
#include "src/tint/ast/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::ast {
|
||||
namespace {
|
||||
|
||||
@ -57,7 +59,7 @@ TEST_F(CompoundAssignmentStatementTest, Assert_Null_LHS) {
|
||||
EXPECT_FATAL_FAILURE(
|
||||
{
|
||||
ProgramBuilder b;
|
||||
b.create<CompoundAssignmentStatement>(nullptr, b.Expr(1), BinaryOp::kAdd);
|
||||
b.create<CompoundAssignmentStatement>(nullptr, b.Expr(1_i), BinaryOp::kAdd);
|
||||
},
|
||||
"internal compiler error");
|
||||
}
|
||||
@ -66,7 +68,7 @@ TEST_F(CompoundAssignmentStatementTest, Assert_Null_RHS) {
|
||||
EXPECT_FATAL_FAILURE(
|
||||
{
|
||||
ProgramBuilder b;
|
||||
b.create<CompoundAssignmentStatement>(b.Expr(1), nullptr, BinaryOp::kAdd);
|
||||
b.create<CompoundAssignmentStatement>(b.Expr(1_i), nullptr, BinaryOp::kAdd);
|
||||
},
|
||||
"internal compiler error");
|
||||
}
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include "src/tint/ast/binary_expression.h"
|
||||
#include "src/tint/ast/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::ast {
|
||||
namespace {
|
||||
|
||||
@ -23,8 +25,8 @@ using ForLoopStatementTest = TestHelper;
|
||||
|
||||
TEST_F(ForLoopStatementTest, Creation) {
|
||||
auto* init = Decl(Var("i", ty.u32()));
|
||||
auto* cond = create<BinaryExpression>(BinaryOp::kLessThan, Expr("i"), Expr(5u));
|
||||
auto* cont = Assign("i", Add("i", 1));
|
||||
auto* cond = create<BinaryExpression>(BinaryOp::kLessThan, Expr("i"), Expr(5_u));
|
||||
auto* cont = Assign("i", Add("i", 1_u));
|
||||
auto* body = Block(Return());
|
||||
auto* l = For(init, cond, cont, body);
|
||||
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "src/tint/ast/test_helper.h"
|
||||
#include "src/tint/ast/workgroup_attribute.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::ast {
|
||||
namespace {
|
||||
|
||||
@ -105,7 +107,7 @@ TEST_F(FunctionTest, Assert_DifferentProgramID_Attr) {
|
||||
ProgramBuilder b2;
|
||||
b1.Func("func", VariableList{}, b1.ty.void_(), StatementList{},
|
||||
AttributeList{
|
||||
b2.WorkgroupSize(2, 4, 6),
|
||||
b2.WorkgroupSize(2_i, 4_i, 6_i),
|
||||
});
|
||||
},
|
||||
"internal compiler error");
|
||||
@ -118,7 +120,7 @@ TEST_F(FunctionTest, Assert_DifferentProgramID_ReturnAttr) {
|
||||
ProgramBuilder b2;
|
||||
b1.Func("func", VariableList{}, b1.ty.void_(), StatementList{}, AttributeList{},
|
||||
AttributeList{
|
||||
b2.WorkgroupSize(2, 4, 6),
|
||||
b2.WorkgroupSize(2_i, 4_i, 6_i),
|
||||
});
|
||||
},
|
||||
"internal compiler error");
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include "gtest/gtest-spi.h"
|
||||
#include "src/tint/ast/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::ast {
|
||||
namespace {
|
||||
|
||||
@ -24,7 +26,7 @@ using SwitchStatementTest = TestHelper;
|
||||
|
||||
TEST_F(SwitchStatementTest, Creation) {
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(Expr(1));
|
||||
lit.push_back(Expr(1_u));
|
||||
|
||||
auto* ident = Expr("ident");
|
||||
CaseStatementList body;
|
||||
@ -49,7 +51,7 @@ TEST_F(SwitchStatementTest, Creation_WithSource) {
|
||||
|
||||
TEST_F(SwitchStatementTest, IsSwitch) {
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(Expr(2));
|
||||
lit.push_back(Expr(2_i));
|
||||
|
||||
auto* ident = Expr("ident");
|
||||
CaseStatementList body;
|
||||
@ -64,7 +66,7 @@ TEST_F(SwitchStatementTest, Assert_Null_Condition) {
|
||||
{
|
||||
ProgramBuilder b;
|
||||
CaseStatementList cases;
|
||||
cases.push_back(b.create<CaseStatement>(CaseSelectorList{b.Expr(1)}, b.Block()));
|
||||
cases.push_back(b.create<CaseStatement>(CaseSelectorList{b.Expr(1_i)}, b.Block()));
|
||||
b.create<SwitchStatement>(nullptr, cases);
|
||||
},
|
||||
"internal compiler error");
|
||||
@ -87,7 +89,7 @@ TEST_F(SwitchStatementTest, Assert_DifferentProgramID_Condition) {
|
||||
b1.create<SwitchStatement>(b2.Expr(true), CaseStatementList{
|
||||
b1.create<CaseStatement>(
|
||||
CaseSelectorList{
|
||||
b1.Expr(1),
|
||||
b1.Expr(1_i),
|
||||
},
|
||||
b1.Block()),
|
||||
});
|
||||
@ -103,7 +105,7 @@ TEST_F(SwitchStatementTest, Assert_DifferentProgramID_CaseStatement) {
|
||||
b1.create<SwitchStatement>(b1.Expr(true), CaseStatementList{
|
||||
b2.create<CaseStatement>(
|
||||
CaseSelectorList{
|
||||
b2.Expr(1),
|
||||
b2.Expr(1_i),
|
||||
},
|
||||
b2.Block()),
|
||||
});
|
||||
|
@ -16,15 +16,17 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/ast/test_helper.h"
|
||||
|
||||
using ::testing::ElementsAre;
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::ast {
|
||||
namespace {
|
||||
|
||||
using ::testing::ElementsAre;
|
||||
|
||||
using TraverseExpressionsTest = TestHelper;
|
||||
|
||||
TEST_F(TraverseExpressionsTest, DescendIndexAccessor) {
|
||||
std::vector<const ast::Expression*> e = {Expr(1), Expr(1), Expr(1), Expr(1)};
|
||||
std::vector<const ast::Expression*> e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)};
|
||||
std::vector<const ast::Expression*> i = {IndexAccessor(e[0], e[1]), IndexAccessor(e[2], e[3])};
|
||||
auto* root = IndexAccessor(i[0], i[1]);
|
||||
{
|
||||
@ -48,7 +50,7 @@ TEST_F(TraverseExpressionsTest, DescendIndexAccessor) {
|
||||
}
|
||||
|
||||
TEST_F(TraverseExpressionsTest, DescendBinaryExpression) {
|
||||
std::vector<const ast::Expression*> e = {Expr(1), Expr(1), Expr(1), Expr(1)};
|
||||
std::vector<const ast::Expression*> e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)};
|
||||
std::vector<const ast::Expression*> i = {Add(e[0], e[1]), Sub(e[2], e[3])};
|
||||
auto* root = Mul(i[0], i[1]);
|
||||
{
|
||||
@ -72,7 +74,7 @@ TEST_F(TraverseExpressionsTest, DescendBinaryExpression) {
|
||||
}
|
||||
|
||||
TEST_F(TraverseExpressionsTest, DescendBitcastExpression) {
|
||||
auto* e = Expr(1);
|
||||
auto* e = Expr(1_i);
|
||||
auto* b0 = Bitcast<i32>(e);
|
||||
auto* b1 = Bitcast<i32>(b0);
|
||||
auto* b2 = Bitcast<i32>(b1);
|
||||
@ -98,7 +100,7 @@ TEST_F(TraverseExpressionsTest, DescendBitcastExpression) {
|
||||
}
|
||||
|
||||
TEST_F(TraverseExpressionsTest, DescendCallExpression) {
|
||||
std::vector<const ast::Expression*> e = {Expr(1), Expr(1), Expr(1), Expr(1)};
|
||||
std::vector<const ast::Expression*> e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)};
|
||||
std::vector<const ast::Expression*> c = {Call("a", e[0], e[1]), Call("b", e[2], e[3])};
|
||||
auto* root = Call("c", c[0], c[1]);
|
||||
{
|
||||
@ -124,7 +126,7 @@ TEST_F(TraverseExpressionsTest, DescendCallExpression) {
|
||||
// TODO(crbug.com/tint/1257): Test ignores member accessor 'member' field.
|
||||
// Replace with the test below when fixed.
|
||||
TEST_F(TraverseExpressionsTest, DescendMemberIndexExpression) {
|
||||
auto* e = Expr(1);
|
||||
auto* e = Expr(1_i);
|
||||
auto* m = MemberAccessor(e, Expr("a"));
|
||||
auto* root = MemberAccessor(m, Expr("b"));
|
||||
{
|
||||
@ -149,7 +151,7 @@ TEST_F(TraverseExpressionsTest, DescendMemberIndexExpression) {
|
||||
|
||||
// TODO(crbug.com/tint/1257): The correct test for DescendMemberIndexExpression.
|
||||
TEST_F(TraverseExpressionsTest, DISABLED_DescendMemberIndexExpression) {
|
||||
auto* e = Expr(1);
|
||||
auto* e = Expr(1_i);
|
||||
std::vector<const ast::IdentifierExpression*> i = {Expr("a"), Expr("b")};
|
||||
auto* m = MemberAccessor(e, i[0]);
|
||||
auto* root = MemberAccessor(m, i[1]);
|
||||
@ -174,7 +176,7 @@ TEST_F(TraverseExpressionsTest, DISABLED_DescendMemberIndexExpression) {
|
||||
}
|
||||
|
||||
TEST_F(TraverseExpressionsTest, DescendUnaryExpression) {
|
||||
auto* e = Expr(1);
|
||||
auto* e = Expr(1_i);
|
||||
auto* u0 = AddressOf(e);
|
||||
auto* u1 = Deref(u0);
|
||||
auto* u2 = AddressOf(u1);
|
||||
@ -200,7 +202,7 @@ TEST_F(TraverseExpressionsTest, DescendUnaryExpression) {
|
||||
}
|
||||
|
||||
TEST_F(TraverseExpressionsTest, Skip) {
|
||||
std::vector<const ast::Expression*> e = {Expr(1), Expr(1), Expr(1), Expr(1)};
|
||||
std::vector<const ast::Expression*> e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)};
|
||||
std::vector<const ast::Expression*> i = {IndexAccessor(e[0], e[1]), IndexAccessor(e[2], e[3])};
|
||||
auto* root = IndexAccessor(i[0], i[1]);
|
||||
std::vector<const ast::Expression*> order;
|
||||
@ -213,7 +215,7 @@ TEST_F(TraverseExpressionsTest, Skip) {
|
||||
}
|
||||
|
||||
TEST_F(TraverseExpressionsTest, Stop) {
|
||||
std::vector<const ast::Expression*> e = {Expr(1), Expr(1), Expr(1), Expr(1)};
|
||||
std::vector<const ast::Expression*> e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)};
|
||||
std::vector<const ast::Expression*> i = {IndexAccessor(e[0], e[1]), IndexAccessor(e[2], e[3])};
|
||||
auto* root = IndexAccessor(i[0], i[1]);
|
||||
std::vector<const ast::Expression*> order;
|
||||
|
@ -17,13 +17,15 @@
|
||||
#include "src/tint/ast/stage_attribute.h"
|
||||
#include "src/tint/ast/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::ast {
|
||||
namespace {
|
||||
|
||||
using WorkgroupAttributeTest = TestHelper;
|
||||
|
||||
TEST_F(WorkgroupAttributeTest, Creation_1param) {
|
||||
auto* d = WorkgroupSize(2);
|
||||
auto* d = WorkgroupSize(2_i);
|
||||
auto values = d->Values();
|
||||
|
||||
ASSERT_TRUE(values[0]->Is<ast::IntLiteralExpression>());
|
||||
@ -33,7 +35,7 @@ TEST_F(WorkgroupAttributeTest, Creation_1param) {
|
||||
EXPECT_EQ(values[2], nullptr);
|
||||
}
|
||||
TEST_F(WorkgroupAttributeTest, Creation_2param) {
|
||||
auto* d = WorkgroupSize(2, 4);
|
||||
auto* d = WorkgroupSize(2_i, 4_i);
|
||||
auto values = d->Values();
|
||||
|
||||
ASSERT_TRUE(values[0]->Is<ast::IntLiteralExpression>());
|
||||
@ -46,7 +48,7 @@ TEST_F(WorkgroupAttributeTest, Creation_2param) {
|
||||
}
|
||||
|
||||
TEST_F(WorkgroupAttributeTest, Creation_3param) {
|
||||
auto* d = WorkgroupSize(2, 4, 6);
|
||||
auto* d = WorkgroupSize(2_i, 4_i, 6_i);
|
||||
auto values = d->Values();
|
||||
|
||||
ASSERT_TRUE(values[0]->Is<ast::IntLiteralExpression>());
|
||||
@ -60,7 +62,7 @@ TEST_F(WorkgroupAttributeTest, Creation_3param) {
|
||||
}
|
||||
|
||||
TEST_F(WorkgroupAttributeTest, Creation_WithIdentifier) {
|
||||
auto* d = WorkgroupSize(2, 4, "depth");
|
||||
auto* d = WorkgroupSize(2_i, 4_i, "depth");
|
||||
auto values = d->Values();
|
||||
|
||||
ASSERT_TRUE(values[0]->Is<ast::IntLiteralExpression>());
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include "src/tint/sem/variable.h"
|
||||
#include "tint/tint.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::inspector {
|
||||
namespace {
|
||||
|
||||
@ -175,7 +177,7 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPoints) {
|
||||
});
|
||||
|
||||
MakeEmptyBodyFunction(
|
||||
"bar", ast::AttributeList{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
"bar", ast::AttributeList{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
// TODO(dsinclair): Update to run the namer transform when available.
|
||||
|
||||
@ -197,7 +199,8 @@ TEST_F(InspectorGetEntryPointTest, MixFunctionsAndEntryPoints) {
|
||||
MakeEmptyBodyFunction("func", {});
|
||||
|
||||
MakeCallerBodyFunction(
|
||||
"foo", {"func"}, ast::AttributeList{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
"foo", {"func"},
|
||||
ast::AttributeList{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
MakeCallerBodyFunction("bar", {"func"},
|
||||
ast::AttributeList{
|
||||
@ -221,8 +224,8 @@ TEST_F(InspectorGetEntryPointTest, MixFunctionsAndEntryPoints) {
|
||||
}
|
||||
|
||||
TEST_F(InspectorGetEntryPointTest, DefaultWorkgroupSize) {
|
||||
MakeEmptyBodyFunction(
|
||||
"foo", ast::AttributeList{Stage(ast::PipelineStage::kCompute), WorkgroupSize(8, 2, 1)});
|
||||
MakeEmptyBodyFunction("foo", ast::AttributeList{Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(8_i, 2_i, 1_i)});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
|
||||
@ -238,7 +241,8 @@ TEST_F(InspectorGetEntryPointTest, DefaultWorkgroupSize) {
|
||||
}
|
||||
|
||||
TEST_F(InspectorGetEntryPointTest, NonDefaultWorkgroupSize) {
|
||||
MakeEmptyBodyFunction("foo", {Stage(ast::PipelineStage::kCompute), WorkgroupSize(8, 2, 1)});
|
||||
MakeEmptyBodyFunction("foo",
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(8_i, 2_i, 1_i)});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
|
||||
@ -529,7 +533,7 @@ TEST_F(InspectorGetEntryPointTest, MixInOutVariablesAndStruct) {
|
||||
|
||||
TEST_F(InspectorGetEntryPointTest, OverridableConstantUnreferenced) {
|
||||
AddOverridableConstantWithoutID("foo", ty.f32(), nullptr);
|
||||
MakeEmptyBodyFunction("ep_func", {Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
MakeEmptyBodyFunction("ep_func", {Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
|
||||
@ -542,7 +546,7 @@ TEST_F(InspectorGetEntryPointTest, OverridableConstantUnreferenced) {
|
||||
TEST_F(InspectorGetEntryPointTest, OverridableConstantReferencedByEntryPoint) {
|
||||
AddOverridableConstantWithoutID("foo", ty.f32(), nullptr);
|
||||
MakePlainGlobalReferenceBodyFunction("ep_func", "foo", ty.f32(),
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
|
||||
@ -557,7 +561,7 @@ TEST_F(InspectorGetEntryPointTest, OverridableConstantReferencedByCallee) {
|
||||
AddOverridableConstantWithoutID("foo", ty.f32(), nullptr);
|
||||
MakePlainGlobalReferenceBodyFunction("callee_func", "foo", ty.f32(), {});
|
||||
MakeCallerBodyFunction("ep_func", {"callee_func"},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
|
||||
@ -573,7 +577,7 @@ TEST_F(InspectorGetEntryPointTest, OverridableConstantSomeReferenced) {
|
||||
AddOverridableConstantWithID("bar", 2, ty.f32(), nullptr);
|
||||
MakePlainGlobalReferenceBodyFunction("callee_func", "foo", ty.f32(), {});
|
||||
MakeCallerBodyFunction("ep_func", {"callee_func"},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
|
||||
@ -597,7 +601,7 @@ TEST_F(InspectorGetEntryPointTest, OverridableConstantTypes) {
|
||||
MakePlainGlobalReferenceBodyFunction("i32_func", "i32_var", ty.i32(), {});
|
||||
|
||||
MakeCallerBodyFunction("ep_func", {"bool_func", "float_func", "u32_func", "i32_func"},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
|
||||
@ -621,7 +625,7 @@ TEST_F(InspectorGetEntryPointTest, OverridableConstantTypes) {
|
||||
TEST_F(InspectorGetEntryPointTest, OverridableConstantInitialized) {
|
||||
AddOverridableConstantWithoutID("foo", ty.f32(), Expr(0.0f));
|
||||
MakePlainGlobalReferenceBodyFunction("ep_func", "foo", ty.f32(),
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
|
||||
@ -636,7 +640,7 @@ TEST_F(InspectorGetEntryPointTest, OverridableConstantInitialized) {
|
||||
TEST_F(InspectorGetEntryPointTest, OverridableConstantUninitialized) {
|
||||
AddOverridableConstantWithoutID("foo", ty.f32(), nullptr);
|
||||
MakePlainGlobalReferenceBodyFunction("ep_func", "foo", ty.f32(),
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
|
||||
@ -657,7 +661,7 @@ TEST_F(InspectorGetEntryPointTest, OverridableConstantNumericIDSpecified) {
|
||||
MakePlainGlobalReferenceBodyFunction("id_func", "foo_id", ty.f32(), {});
|
||||
|
||||
MakeCallerBodyFunction("ep_func", {"no_id_func", "id_func"},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
|
||||
@ -848,7 +852,7 @@ TEST_F(InspectorGetEntryPointTest, SampleIndexStructReferenced) {
|
||||
TEST_F(InspectorGetEntryPointTest, NumWorkgroupsSimpleReferenced) {
|
||||
auto* in_var = Param("in_var", ty.vec3<u32>(), {Builtin(ast::Builtin::kNumWorkgroups)});
|
||||
Func("ep_func", {in_var}, ty.void_(), {Return()},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)}, {});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)}, {});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
|
||||
@ -866,7 +870,7 @@ TEST_F(InspectorGetEntryPointTest, NumWorkgroupsStructReferenced) {
|
||||
auto* in_var = Param("in_var", ty.type_name("in_struct"), {});
|
||||
|
||||
Func("ep_func", {in_var}, ty.void_(), {Return()},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)}, {});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)}, {});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
|
||||
@ -970,7 +974,7 @@ TEST_F(InspectorGetConstantIDsTest, Bool) {
|
||||
|
||||
TEST_F(InspectorGetConstantIDsTest, U32) {
|
||||
AddOverridableConstantWithID("foo", 1, ty.u32(), nullptr);
|
||||
AddOverridableConstantWithID("bar", 20, ty.u32(), Expr(42u));
|
||||
AddOverridableConstantWithID("bar", 20, ty.u32(), Expr(42_u));
|
||||
|
||||
Inspector& inspector = Build();
|
||||
|
||||
@ -987,8 +991,8 @@ TEST_F(InspectorGetConstantIDsTest, U32) {
|
||||
|
||||
TEST_F(InspectorGetConstantIDsTest, I32) {
|
||||
AddOverridableConstantWithID("foo", 1, ty.i32(), nullptr);
|
||||
AddOverridableConstantWithID("bar", 20, ty.i32(), Expr(-42));
|
||||
AddOverridableConstantWithID("baz", 300, ty.i32(), Expr(42));
|
||||
AddOverridableConstantWithID("bar", 20, ty.i32(), Expr(i32(-42)));
|
||||
AddOverridableConstantWithID("baz", 300, ty.i32(), Expr(42_i));
|
||||
|
||||
Inspector& inspector = Build();
|
||||
|
||||
@ -1071,7 +1075,7 @@ TEST_F(InspectorGetConstantNameToIdMapTest, WithAndWithoutIds) {
|
||||
|
||||
TEST_F(InspectorGetStorageSizeTest, Empty) {
|
||||
MakeEmptyBodyFunction(
|
||||
"ep_func", ast::AttributeList{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
"ep_func", ast::AttributeList{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
Inspector& inspector = Build();
|
||||
EXPECT_EQ(0u, inspector.GetStorageSize("ep_func"));
|
||||
}
|
||||
@ -1086,7 +1090,7 @@ TEST_F(InspectorGetStorageSizeTest, Simple_NonStruct) {
|
||||
Decl(Let("sb", nullptr, Expr("sb_var"))),
|
||||
Decl(Let("rosb", nullptr, Expr("rosb_var"))),
|
||||
},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
|
||||
@ -1109,7 +1113,7 @@ TEST_F(InspectorGetStorageSizeTest, Simple_Struct) {
|
||||
MakeCallerBodyFunction("ep_func", {"ub_func", "sb_func", "rosb_func"},
|
||||
ast::AttributeList{
|
||||
Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(1),
|
||||
WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
@ -1123,7 +1127,7 @@ TEST_F(InspectorGetStorageSizeTest, NonStructVec3) {
|
||||
{
|
||||
Decl(Let("ub", nullptr, Expr("ub_var"))),
|
||||
},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
|
||||
@ -1137,7 +1141,7 @@ TEST_F(InspectorGetStorageSizeTest, StructVec3) {
|
||||
{
|
||||
Decl(Let("ub", nullptr, Expr("ub_var"))),
|
||||
},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
|
||||
@ -1441,7 +1445,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) {
|
||||
// with elem stride of 16, and that is 16-byte aligned within the struct)
|
||||
auto* foo_struct_type = Structure(
|
||||
"foo_type", {Member("0i32", ty.i32()),
|
||||
Member("b", ty.array(ty.u32(), 4, /*stride*/ 16), {MemberAlign(16)})});
|
||||
Member("b", ty.array(ty.u32(), 4_u, /*stride*/ 16), {MemberAlign(16)})});
|
||||
|
||||
AddUniformBuffer("foo_ub", ty.Of(foo_struct_type), 0, 0);
|
||||
|
||||
@ -2741,7 +2745,7 @@ fn direct(@location(0) fragUV: vec2<f32>,
|
||||
|
||||
TEST_F(InspectorGetWorkgroupStorageSizeTest, Empty) {
|
||||
MakeEmptyBodyFunction(
|
||||
"ep_func", ast::AttributeList{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
"ep_func", ast::AttributeList{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
Inspector& inspector = Build();
|
||||
EXPECT_EQ(0u, inspector.GetWorkgroupStorageSize("ep_func"));
|
||||
}
|
||||
@ -2753,7 +2757,7 @@ TEST_F(InspectorGetWorkgroupStorageSizeTest, Simple) {
|
||||
MakeCallerBodyFunction("ep_func", {"f32_func"},
|
||||
ast::AttributeList{
|
||||
Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(1),
|
||||
WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
@ -2764,7 +2768,7 @@ TEST_F(InspectorGetWorkgroupStorageSizeTest, CompoundTypes) {
|
||||
// This struct should occupy 68 bytes. 4 from the i32 field, and another 64
|
||||
// from the 4-element array with 16-byte stride.
|
||||
auto* wg_struct_type =
|
||||
MakeStructType("WgStruct", {ty.i32(), ty.array(ty.i32(), 4, /*stride=*/16)});
|
||||
MakeStructType("WgStruct", {ty.i32(), ty.array(ty.i32(), 4_u, /*stride=*/16)});
|
||||
AddWorkgroupStorage("wg_struct_var", ty.Of(wg_struct_type));
|
||||
MakeStructVariableReferenceBodyFunction("wg_struct_func", "wg_struct_var", {{0, ty.i32()}});
|
||||
|
||||
@ -2775,7 +2779,7 @@ TEST_F(InspectorGetWorkgroupStorageSizeTest, CompoundTypes) {
|
||||
MakeCallerBodyFunction("ep_func", {"wg_struct_func", "f32_func"},
|
||||
ast::AttributeList{
|
||||
Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(1),
|
||||
WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
@ -2791,7 +2795,7 @@ TEST_F(InspectorGetWorkgroupStorageSizeTest, AlignmentPadding) {
|
||||
MakeCallerBodyFunction("ep_func", {"wg_func"},
|
||||
ast::AttributeList{
|
||||
Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(1),
|
||||
WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
@ -2812,7 +2816,7 @@ TEST_F(InspectorGetWorkgroupStorageSizeTest, StructAlignment) {
|
||||
MakeCallerBodyFunction("ep_func", {"wg_struct_func"},
|
||||
ast::AttributeList{
|
||||
Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(1),
|
||||
WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
|
86
src/tint/number.h
Normal file
86
src/tint/number.h
Normal file
@ -0,0 +1,86 @@
|
||||
// Copyright 2021 The Tint Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef SRC_TINT_NUMBER_H_
|
||||
#define SRC_TINT_NUMBER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace tint {
|
||||
|
||||
/// Number wraps a integer or floating point number, enforcing explicit casting.
|
||||
template <typename T>
|
||||
struct Number {
|
||||
/// Constructor. The value is zero-initialized.
|
||||
Number() = default;
|
||||
|
||||
/// Constructor.
|
||||
/// @param v the value to initialize this Number to
|
||||
explicit Number(T v) : value(v) {}
|
||||
|
||||
/// Conversion operator
|
||||
/// @returns the value as T
|
||||
operator T() const { return value; }
|
||||
|
||||
/// Assignment operator
|
||||
/// @param v the new value
|
||||
/// @returns this Number so calls can be chained
|
||||
Number& operator=(T v) {
|
||||
value = v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// The number value
|
||||
T value = {};
|
||||
};
|
||||
|
||||
template <typename A, typename B>
|
||||
bool operator==(Number<A> a, Number<B> b) {
|
||||
return a.value == b.value;
|
||||
}
|
||||
|
||||
template <typename A, typename B>
|
||||
bool operator==(Number<A> a, B b) {
|
||||
return a.value == b;
|
||||
}
|
||||
|
||||
template <typename A, typename B>
|
||||
bool operator==(A a, Number<B> b) {
|
||||
return a == b.value;
|
||||
}
|
||||
|
||||
/// `i32` is a type alias to `Number<int32_t>`.
|
||||
using i32 = Number<int32_t>;
|
||||
/// `u32` is a type alias to `Number<uint32_t>`.
|
||||
using u32 = Number<uint32_t>;
|
||||
/// `f32` is a type alias to `float`
|
||||
using f32 = float;
|
||||
|
||||
} // namespace tint
|
||||
|
||||
namespace tint::number_suffixes {
|
||||
|
||||
/// Literal suffix for i32 literals
|
||||
inline i32 operator"" _i(unsigned long long int value) { // NOLINT
|
||||
return i32(static_cast<int32_t>(value));
|
||||
}
|
||||
|
||||
/// Literal suffix for u32 literals
|
||||
inline u32 operator"" _u(unsigned long long int value) { // NOLINT
|
||||
return u32(static_cast<uint32_t>(value));
|
||||
}
|
||||
|
||||
} // namespace tint::number_suffixes
|
||||
|
||||
#endif // SRC_TINT_NUMBER_H_
|
@ -22,6 +22,8 @@
|
||||
#include "src/tint/sem/expression.h"
|
||||
#include "src/tint/sem/variable.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint {
|
||||
|
||||
ProgramBuilder::VarOptionals::~VarOptionals() = default;
|
||||
@ -126,7 +128,7 @@ const ast::Statement* ProgramBuilder::WrapInStatement(const ast::Statement* stmt
|
||||
const ast::Function* ProgramBuilder::WrapInFunction(const ast::StatementList stmts) {
|
||||
return Func(
|
||||
"test_function", {}, ty.void_(), std::move(stmts),
|
||||
{create<ast::StageAttribute>(ast::PipelineStage::kCompute), WorkgroupSize(1, 1, 1)});
|
||||
{create<ast::StageAttribute>(ast::PipelineStage::kCompute), WorkgroupSize(1_i, 1_i, 1_i)});
|
||||
}
|
||||
|
||||
} // namespace tint
|
||||
|
@ -75,6 +75,7 @@
|
||||
#include "src/tint/ast/vector.h"
|
||||
#include "src/tint/ast/void.h"
|
||||
#include "src/tint/ast/workgroup_attribute.h"
|
||||
#include "src/tint/number.h"
|
||||
#include "src/tint/program.h"
|
||||
#include "src/tint/program_id.h"
|
||||
#include "src/tint/sem/array.h"
|
||||
@ -153,23 +154,6 @@ class ProgramBuilder {
|
||||
/// SemNodeAllocator is an alias to BlockAllocator<sem::Node>
|
||||
using SemNodeAllocator = utils::BlockAllocator<sem::Node>;
|
||||
|
||||
/// `i32` is a type alias to `int`.
|
||||
/// Useful for passing to template methods such as `vec2<i32>()` to imitate
|
||||
/// WGSL syntax.
|
||||
/// Note: this is intentionally not aliased to uint32_t as we want integer
|
||||
/// literals passed to the builder to match WGSL's integer literal types.
|
||||
using i32 = decltype(1);
|
||||
/// `u32` is a type alias to `unsigned int`.
|
||||
/// Useful for passing to template methods such as `vec2<u32>()` to imitate
|
||||
/// WGSL syntax.
|
||||
/// Note: this is intentionally not aliased to uint32_t as we want integer
|
||||
/// literals passed to the builder to match WGSL's integer literal types.
|
||||
using u32 = decltype(1u);
|
||||
/// `f32` is a type alias to `float`
|
||||
/// Useful for passing to template methods such as `vec2<f32>()` to imitate
|
||||
/// WGSL syntax.
|
||||
using f32 = float;
|
||||
|
||||
/// Constructor
|
||||
ProgramBuilder();
|
||||
|
||||
@ -672,7 +656,7 @@ class ProgramBuilder {
|
||||
/// @return the tint AST type for an array of size `N` of type `T`
|
||||
template <typename T, int N>
|
||||
const ast::Array* array() const {
|
||||
return array(Of<T>(), builder->Expr(N));
|
||||
return array(Of<T>(), builder->Expr(tint::u32(N)));
|
||||
}
|
||||
|
||||
/// @param stride the array stride
|
||||
@ -686,7 +670,7 @@ class ProgramBuilder {
|
||||
/// @return the tint AST type for an array of size `N` of type `T`
|
||||
template <typename T, int N>
|
||||
const ast::Array* array(uint32_t stride) const {
|
||||
return array(Of<T>(), builder->Expr(N), stride);
|
||||
return array(Of<T>(), builder->Expr(tint::u32(N)), stride);
|
||||
}
|
||||
|
||||
/// Creates a type name
|
||||
@ -1015,28 +999,28 @@ class ProgramBuilder {
|
||||
|
||||
/// @param source the source information
|
||||
/// @param value the integer value
|
||||
/// @return a Scalar constructor for the given value
|
||||
/// @return a 'i'-suffixed IntLiteralExpression for the given value
|
||||
const ast::IntLiteralExpression* Expr(const Source& source, i32 value) {
|
||||
return create<ast::IntLiteralExpression>(source, value,
|
||||
ast::IntLiteralExpression::Suffix::kNone);
|
||||
ast::IntLiteralExpression::Suffix::kI);
|
||||
}
|
||||
|
||||
/// @param value the integer value
|
||||
/// @return a Scalar constructor for the given value
|
||||
/// @return a 'i'-suffixed IntLiteralExpression for the given value
|
||||
const ast::IntLiteralExpression* Expr(i32 value) {
|
||||
return create<ast::IntLiteralExpression>(value, ast::IntLiteralExpression::Suffix::kNone);
|
||||
return create<ast::IntLiteralExpression>(value, ast::IntLiteralExpression::Suffix::kI);
|
||||
}
|
||||
|
||||
/// @param source the source information
|
||||
/// @param value the unsigned int value
|
||||
/// @return a Scalar constructor for the given value
|
||||
/// @return a 'u'-suffixed IntLiteralExpression for the given value
|
||||
const ast::IntLiteralExpression* Expr(const Source& source, u32 value) {
|
||||
return create<ast::IntLiteralExpression>(source, value,
|
||||
ast::IntLiteralExpression::Suffix::kU);
|
||||
}
|
||||
|
||||
/// @param value the unsigned int value
|
||||
/// @return a Scalar constructor for the given value
|
||||
/// @return a 'u'-suffixed IntLiteralExpression for the given value
|
||||
const ast::IntLiteralExpression* Expr(u32 value) {
|
||||
return create<ast::IntLiteralExpression>(value, ast::IntLiteralExpression::Suffix::kU);
|
||||
}
|
||||
@ -2643,15 +2627,15 @@ class ProgramBuilder {
|
||||
//! @cond Doxygen_Suppress
|
||||
// Various template specializations for ProgramBuilder::TypesBuilder::CToAST.
|
||||
template <>
|
||||
struct ProgramBuilder::TypesBuilder::CToAST<ProgramBuilder::i32> {
|
||||
struct ProgramBuilder::TypesBuilder::CToAST<i32> {
|
||||
static const ast::Type* get(const ProgramBuilder::TypesBuilder* t) { return t->i32(); }
|
||||
};
|
||||
template <>
|
||||
struct ProgramBuilder::TypesBuilder::CToAST<ProgramBuilder::u32> {
|
||||
struct ProgramBuilder::TypesBuilder::CToAST<u32> {
|
||||
static const ast::Type* get(const ProgramBuilder::TypesBuilder* t) { return t->u32(); }
|
||||
};
|
||||
template <>
|
||||
struct ProgramBuilder::TypesBuilder::CToAST<ProgramBuilder::f32> {
|
||||
struct ProgramBuilder::TypesBuilder::CToAST<f32> {
|
||||
static const ast::Type* get(const ProgramBuilder::TypesBuilder* t) { return t->f32(); }
|
||||
};
|
||||
template <>
|
||||
|
@ -1026,11 +1026,11 @@ bool FunctionEmitter::EmitPipelineInput(std::string var_name,
|
||||
Switch(
|
||||
current_type,
|
||||
[&](const Matrix* matrix_type) {
|
||||
store_dest = builder_.IndexAccessor(store_dest, builder_.Expr(index));
|
||||
store_dest = builder_.IndexAccessor(store_dest, builder_.Expr(i32(index)));
|
||||
current_type = ty_.Vector(matrix_type->type, matrix_type->rows);
|
||||
},
|
||||
[&](const Array* array_type) {
|
||||
store_dest = builder_.IndexAccessor(store_dest, builder_.Expr(index));
|
||||
store_dest = builder_.IndexAccessor(store_dest, builder_.Expr(i32(index)));
|
||||
current_type = array_type->type->UnwrapAlias();
|
||||
},
|
||||
[&](const Struct* struct_type) {
|
||||
@ -1169,11 +1169,13 @@ bool FunctionEmitter::EmitPipelineOutput(std::string var_name,
|
||||
Switch(
|
||||
current_type,
|
||||
[&](const Matrix* matrix_type) {
|
||||
load_source = builder_.IndexAccessor(load_source, builder_.Expr(index));
|
||||
load_source =
|
||||
builder_.IndexAccessor(load_source, builder_.Expr(i32(index)));
|
||||
current_type = ty_.Vector(matrix_type->type, matrix_type->rows);
|
||||
},
|
||||
[&](const Array* array_type) {
|
||||
load_source = builder_.IndexAccessor(load_source, builder_.Expr(index));
|
||||
load_source =
|
||||
builder_.IndexAccessor(load_source, builder_.Expr(i32(index)));
|
||||
current_type = array_type->type->UnwrapAlias();
|
||||
},
|
||||
[&](const Struct* struct_type) {
|
||||
@ -1356,9 +1358,9 @@ bool FunctionEmitter::EmitEntryPointAsWrapper() {
|
||||
if (ep_info_->stage == ast::PipelineStage::kCompute) {
|
||||
auto& size = ep_info_->workgroup_size;
|
||||
if (size.x != 0 && size.y != 0 && size.z != 0) {
|
||||
const ast::Expression* x = builder_.Expr(static_cast<int>(size.x));
|
||||
const ast::Expression* y = size.y ? builder_.Expr(static_cast<int>(size.y)) : nullptr;
|
||||
const ast::Expression* z = size.z ? builder_.Expr(static_cast<int>(size.z)) : nullptr;
|
||||
const ast::Expression* x = builder_.Expr(i32(size.x));
|
||||
const ast::Expression* y = size.y ? builder_.Expr(i32(size.y)) : nullptr;
|
||||
const ast::Expression* z = size.z ? builder_.Expr(i32(size.z)) : nullptr;
|
||||
fn_attrs.emplace_back(create<ast::WorkgroupAttribute>(Source{}, x, y, z));
|
||||
}
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ TEST_F(SpvParserTest, EmitFunctions_Function_EntryPoint_GLCompute) {
|
||||
Program program = p->program();
|
||||
const auto program_ast = test::ToString(program);
|
||||
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||
@stage(compute) @workgroup_size(1, 1, 1)
|
||||
@stage(compute) @workgroup_size(1i, 1i, 1i)
|
||||
fn main() {
|
||||
)"));
|
||||
}
|
||||
@ -208,7 +208,7 @@ OpFunctionEnd)";
|
||||
Program program = p->program();
|
||||
const auto program_ast = test::ToString(program);
|
||||
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||
@stage(compute) @workgroup_size(2, 4, 8)
|
||||
@stage(compute) @workgroup_size(2i, 4i, 8i)
|
||||
fn comp_main() {
|
||||
)")) << program_ast;
|
||||
}
|
||||
@ -233,7 +233,7 @@ OpFunctionEnd)";
|
||||
Program program = p->program();
|
||||
const auto program_ast = test::ToString(program);
|
||||
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||
@stage(compute) @workgroup_size(3, 5, 7)
|
||||
@stage(compute) @workgroup_size(3i, 5i, 7i)
|
||||
fn comp_main() {
|
||||
)")) << program_ast;
|
||||
}
|
||||
@ -262,7 +262,7 @@ OpFunctionEnd)";
|
||||
Program program = p->program();
|
||||
const auto program_ast = test::ToString(program);
|
||||
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||
@stage(compute) @workgroup_size(3, 5, 7)
|
||||
@stage(compute) @workgroup_size(3i, 5i, 7i)
|
||||
fn comp_main() {
|
||||
)")) << program_ast;
|
||||
}
|
||||
@ -290,7 +290,7 @@ OpFunctionEnd)";
|
||||
Program program = p->program();
|
||||
const auto program_ast = test::ToString(program);
|
||||
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||
@stage(compute) @workgroup_size(3, 5, 7)
|
||||
@stage(compute) @workgroup_size(3i, 5i, 7i)
|
||||
fn comp_main() {
|
||||
)")) << program_ast;
|
||||
}
|
||||
@ -323,7 +323,7 @@ OpFunctionEnd)";
|
||||
Program program = p->program();
|
||||
const auto program_ast = test::ToString(program);
|
||||
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||
@stage(compute) @workgroup_size(3, 5, 7)
|
||||
@stage(compute) @workgroup_size(3i, 5i, 7i)
|
||||
fn comp_main() {
|
||||
)")) << program_ast;
|
||||
}
|
||||
|
@ -1991,7 +1991,7 @@ fn main_1() {
|
||||
|
||||
@stage(fragment)
|
||||
fn main(@builtin(sample_mask) x_1_param : u32) {
|
||||
x_1[0] = x_1_param;
|
||||
x_1[0i] = x_1_param;
|
||||
main_1();
|
||||
}
|
||||
)";
|
||||
@ -2023,7 +2023,7 @@ fn main_1() {
|
||||
|
||||
@stage(fragment)
|
||||
fn main(@builtin(sample_mask) x_1_param : u32) {
|
||||
x_1[0] = x_1_param;
|
||||
x_1[0i] = x_1_param;
|
||||
main_1();
|
||||
}
|
||||
)";
|
||||
@ -2055,7 +2055,7 @@ fn main_1() {
|
||||
|
||||
@stage(fragment)
|
||||
fn main(@builtin(sample_mask) x_1_param : u32) {
|
||||
x_1[0] = x_1_param;
|
||||
x_1[0i] = x_1_param;
|
||||
main_1();
|
||||
}
|
||||
)";
|
||||
@ -2086,7 +2086,7 @@ fn main_1() {
|
||||
|
||||
@stage(fragment)
|
||||
fn main(@builtin(sample_mask) x_1_param : u32) {
|
||||
x_1[0] = bitcast<i32>(x_1_param);
|
||||
x_1[0i] = bitcast<i32>(x_1_param);
|
||||
main_1();
|
||||
}
|
||||
)";
|
||||
@ -2118,7 +2118,7 @@ fn main_1() {
|
||||
|
||||
@stage(fragment)
|
||||
fn main(@builtin(sample_mask) x_1_param : u32) {
|
||||
x_1[0] = bitcast<i32>(x_1_param);
|
||||
x_1[0i] = bitcast<i32>(x_1_param);
|
||||
main_1();
|
||||
}
|
||||
)";
|
||||
@ -2150,7 +2150,7 @@ fn main_1() {
|
||||
|
||||
@stage(fragment)
|
||||
fn main(@builtin(sample_mask) x_1_param : u32) {
|
||||
x_1[0] = bitcast<i32>(x_1_param);
|
||||
x_1[0i] = bitcast<i32>(x_1_param);
|
||||
main_1();
|
||||
}
|
||||
)";
|
||||
@ -2205,7 +2205,7 @@ struct main_out {
|
||||
@stage(fragment)
|
||||
fn main() -> main_out {
|
||||
main_1();
|
||||
return main_out(x_1[0]);
|
||||
return main_out(x_1[0i]);
|
||||
}
|
||||
)";
|
||||
EXPECT_EQ(module_str, expected);
|
||||
@ -2242,7 +2242,7 @@ struct main_out {
|
||||
@stage(fragment)
|
||||
fn main() -> main_out {
|
||||
main_1();
|
||||
return main_out(x_1[0]);
|
||||
return main_out(x_1[0i]);
|
||||
}
|
||||
)";
|
||||
EXPECT_EQ(module_str, expected);
|
||||
@ -2279,7 +2279,7 @@ struct main_out {
|
||||
@stage(fragment)
|
||||
fn main() -> main_out {
|
||||
main_1();
|
||||
return main_out(x_1[0]);
|
||||
return main_out(x_1[0i]);
|
||||
}
|
||||
)";
|
||||
EXPECT_EQ(module_str, expected);
|
||||
@ -2315,7 +2315,7 @@ struct main_out {
|
||||
@stage(fragment)
|
||||
fn main() -> main_out {
|
||||
main_1();
|
||||
return main_out(bitcast<u32>(x_1[0]));
|
||||
return main_out(bitcast<u32>(x_1[0i]));
|
||||
}
|
||||
)";
|
||||
EXPECT_EQ(module_str, expected);
|
||||
@ -2352,7 +2352,7 @@ struct main_out {
|
||||
@stage(fragment)
|
||||
fn main() -> main_out {
|
||||
main_1();
|
||||
return main_out(bitcast<u32>(x_1[0]));
|
||||
return main_out(bitcast<u32>(x_1[0i]));
|
||||
}
|
||||
)";
|
||||
EXPECT_EQ(module_str, expected);
|
||||
@ -2389,7 +2389,7 @@ struct main_out {
|
||||
@stage(fragment)
|
||||
fn main() -> main_out {
|
||||
main_1();
|
||||
return main_out(bitcast<u32>(x_1[0]));
|
||||
return main_out(bitcast<u32>(x_1[0i]));
|
||||
}
|
||||
)";
|
||||
EXPECT_EQ(module_str, expected);
|
||||
@ -2427,7 +2427,7 @@ fn main_1() {
|
||||
|
||||
@stage(fragment)
|
||||
fn main(@builtin(sample_mask) x_1_param : u32) {
|
||||
x_1[0] = x_1_param;
|
||||
x_1[0i] = x_1_param;
|
||||
main_1();
|
||||
}
|
||||
)";
|
||||
@ -2472,7 +2472,7 @@ struct main_out {
|
||||
@stage(fragment)
|
||||
fn main() -> main_out {
|
||||
main_1();
|
||||
return main_out(x_1[0]);
|
||||
return main_out(x_1[0i]);
|
||||
}
|
||||
)";
|
||||
EXPECT_EQ(module_str, expected);
|
||||
@ -3149,7 +3149,7 @@ fn main_1() {
|
||||
return;
|
||||
}
|
||||
|
||||
@stage(compute) @workgroup_size(1, 1, 1)
|
||||
@stage(compute) @workgroup_size(1i, 1i, 1i)
|
||||
fn main(@builtin(${wgsl_builtin}) x_1_param : ${unsigned_wgsl_type}) {
|
||||
x_1 = ${assignment_value};
|
||||
main_1();
|
||||
@ -3195,7 +3195,7 @@ fn main_1() {
|
||||
return;
|
||||
}
|
||||
|
||||
@stage(compute) @workgroup_size(1, 1, 1)
|
||||
@stage(compute) @workgroup_size(1i, 1i, 1i)
|
||||
fn main(@builtin(${wgsl_builtin}) x_1_param : ${unsigned_wgsl_type}) {
|
||||
x_1 = ${assignment_value};
|
||||
main_1();
|
||||
@ -3240,7 +3240,7 @@ fn main_1() {
|
||||
return;
|
||||
}
|
||||
|
||||
@stage(compute) @workgroup_size(1, 1, 1)
|
||||
@stage(compute) @workgroup_size(1i, 1i, 1i)
|
||||
fn main(@builtin(${wgsl_builtin}) x_1_param : ${unsigned_wgsl_type}) {
|
||||
x_1 = ${assignment_value};
|
||||
main_1();
|
||||
@ -3694,7 +3694,7 @@ fn main_1() {
|
||||
|
||||
@stage(fragment)
|
||||
fn main(@builtin(sample_mask) x_1_param : u32) {
|
||||
x_1[0] = x_1_param;
|
||||
x_1[0i] = x_1_param;
|
||||
main_1();
|
||||
}
|
||||
)";
|
||||
@ -3732,7 +3732,7 @@ fn main_1() {
|
||||
|
||||
@stage(fragment)
|
||||
fn main(@builtin(sample_mask) x_1_param : u32) {
|
||||
x_1[0] = bitcast<i32>(x_1_param);
|
||||
x_1[0i] = bitcast<i32>(x_1_param);
|
||||
main_1();
|
||||
}
|
||||
)";
|
||||
@ -3779,7 +3779,7 @@ struct main_out {
|
||||
@stage(fragment)
|
||||
fn main() -> main_out {
|
||||
main_1();
|
||||
return main_out(x_1[0]);
|
||||
return main_out(x_1[0i]);
|
||||
}
|
||||
)";
|
||||
EXPECT_EQ(got, expected) << got;
|
||||
@ -3825,7 +3825,7 @@ struct main_out {
|
||||
@stage(fragment)
|
||||
fn main() -> main_out {
|
||||
main_1();
|
||||
return main_out(bitcast<u32>(x_1[0]));
|
||||
return main_out(bitcast<u32>(x_1[0i]));
|
||||
}
|
||||
)";
|
||||
EXPECT_EQ(got, expected) << got;
|
||||
@ -4027,9 +4027,9 @@ struct main_out {
|
||||
|
||||
@stage(vertex)
|
||||
fn main(@location(4) x_1_param : f32, @location(5) x_1_param_1 : f32, @location(6) x_1_param_2 : f32) -> main_out {
|
||||
x_1[0] = x_1_param;
|
||||
x_1[1] = x_1_param_1;
|
||||
x_1[2] = x_1_param_2;
|
||||
x_1[0i] = x_1_param;
|
||||
x_1[1i] = x_1_param_1;
|
||||
x_1[2i] = x_1_param_2;
|
||||
main_1();
|
||||
return main_out(x_2);
|
||||
}
|
||||
@ -4085,8 +4085,8 @@ struct main_out {
|
||||
|
||||
@stage(vertex)
|
||||
fn main(@location(9) x_1_param : vec4<f32>, @location(10) x_1_param_1 : vec4<f32>) -> main_out {
|
||||
x_1[0] = x_1_param;
|
||||
x_1[1] = x_1_param_1;
|
||||
x_1[0i] = x_1_param;
|
||||
x_1[1i] = x_1_param_1;
|
||||
main_1();
|
||||
return main_out(x_2);
|
||||
}
|
||||
@ -4211,10 +4211,10 @@ struct main_out {
|
||||
|
||||
@stage(vertex)
|
||||
fn main(@location(7) x_1_param : vec4<f32>, @location(8) x_1_param_1 : vec4<f32>, @location(9) x_1_param_2 : vec4<f32>, @location(10) x_1_param_3 : vec4<f32>) -> main_out {
|
||||
x_1[0][0] = x_1_param;
|
||||
x_1[0][1] = x_1_param_1;
|
||||
x_1[1][0] = x_1_param_2;
|
||||
x_1[1][1] = x_1_param_3;
|
||||
x_1[0i][0i] = x_1_param;
|
||||
x_1[0i][1i] = x_1_param_1;
|
||||
x_1[1i][0i] = x_1_param_2;
|
||||
x_1[1i][1i] = x_1_param_3;
|
||||
main_1();
|
||||
return main_out(x_2);
|
||||
}
|
||||
@ -4279,7 +4279,7 @@ struct main_out {
|
||||
@stage(vertex)
|
||||
fn main() -> main_out {
|
||||
main_1();
|
||||
return main_out(x_1[0], x_1[1], x_1[2], x_2);
|
||||
return main_out(x_1[0i], x_1[1i], x_1[2i], x_2);
|
||||
}
|
||||
)";
|
||||
EXPECT_EQ(got, expected) << got;
|
||||
@ -4338,7 +4338,7 @@ struct main_out {
|
||||
@stage(vertex)
|
||||
fn main() -> main_out {
|
||||
main_1();
|
||||
return main_out(x_1[0], x_1[1], x_2);
|
||||
return main_out(x_1[0i], x_1[1i], x_2);
|
||||
}
|
||||
)";
|
||||
EXPECT_EQ(got, expected) << got;
|
||||
@ -4705,8 +4705,8 @@ fn main_1() {
|
||||
|
||||
@stage(fragment)
|
||||
fn main(@location(1) @interpolate(flat) x_1_param : f32, @location(2) @interpolate(flat) x_1_param_1 : f32, @location(5) @interpolate(flat) x_2_param : f32, @location(6) @interpolate(flat) x_2_param_1 : f32) {
|
||||
x_1[0] = x_1_param;
|
||||
x_1[1] = x_1_param_1;
|
||||
x_1[0i] = x_1_param;
|
||||
x_1[1i] = x_1_param_1;
|
||||
x_2.field0 = x_2_param;
|
||||
x_2.field1 = x_2_param_1;
|
||||
main_1();
|
||||
|
@ -196,7 +196,7 @@ Array::Array(const Array&) = default;
|
||||
|
||||
const ast::Type* Array::Build(ProgramBuilder& b) const {
|
||||
if (size > 0) {
|
||||
return b.ty.array(type->Build(b), size, stride);
|
||||
return b.ty.array(type->Build(b), u32(size), stride);
|
||||
} else {
|
||||
return b.ty.array(type->Build(b), nullptr, stride);
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/sem/reference.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -43,8 +45,8 @@ TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic_Ref) {
|
||||
|
||||
TEST_F(ResolverIndexAccessorTest, Matrix_BothDimensions_Dynamic_Ref) {
|
||||
Global("my_var", ty.mat4x4<f32>(), ast::StorageClass::kPrivate);
|
||||
auto* idx = Var("idx", ty.u32(), Expr(3u));
|
||||
auto* idy = Var("idy", ty.u32(), Expr(2u));
|
||||
auto* idx = Var("idx", ty.u32(), Expr(3_u));
|
||||
auto* idy = Var("idy", ty.u32(), Expr(2_u));
|
||||
auto* acc = IndexAccessor(IndexAccessor("my_var", idx), idy);
|
||||
WrapInFunction(Decl(idx), Decl(idy), acc);
|
||||
|
||||
@ -63,7 +65,7 @@ TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic) {
|
||||
|
||||
TEST_F(ResolverIndexAccessorTest, Matrix_XDimension_Dynamic) {
|
||||
GlobalConst("my_var", ty.mat4x4<f32>(), Construct(ty.mat4x4<f32>()));
|
||||
auto* idx = Var("idx", ty.u32(), Expr(3u));
|
||||
auto* idx = Var("idx", ty.u32(), Expr(3_u));
|
||||
auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, idx));
|
||||
WrapInFunction(Decl(idx), acc);
|
||||
|
||||
@ -73,8 +75,8 @@ TEST_F(ResolverIndexAccessorTest, Matrix_XDimension_Dynamic) {
|
||||
|
||||
TEST_F(ResolverIndexAccessorTest, Matrix_BothDimension_Dynamic) {
|
||||
GlobalConst("my_var", ty.mat4x4<f32>(), Construct(ty.mat4x4<f32>()));
|
||||
auto* idx = Var("idy", ty.u32(), Expr(2u));
|
||||
auto* acc = IndexAccessor(IndexAccessor("my_var", Expr(Source{{12, 34}}, idx)), 1);
|
||||
auto* idx = Var("idy", ty.u32(), Expr(2_u));
|
||||
auto* acc = IndexAccessor(IndexAccessor("my_var", Expr(Source{{12, 34}}, idx)), 1_i);
|
||||
WrapInFunction(Decl(idx), acc);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve());
|
||||
@ -84,7 +86,7 @@ TEST_F(ResolverIndexAccessorTest, Matrix_BothDimension_Dynamic) {
|
||||
TEST_F(ResolverIndexAccessorTest, Matrix) {
|
||||
Global("my_var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
|
||||
|
||||
auto* acc = IndexAccessor("my_var", 2);
|
||||
auto* acc = IndexAccessor("my_var", 2_i);
|
||||
WrapInFunction(acc);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -100,7 +102,7 @@ TEST_F(ResolverIndexAccessorTest, Matrix) {
|
||||
TEST_F(ResolverIndexAccessorTest, Matrix_BothDimensions) {
|
||||
Global("my_var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
|
||||
|
||||
auto* acc = IndexAccessor(IndexAccessor("my_var", 2), 1);
|
||||
auto* acc = IndexAccessor(IndexAccessor("my_var", 2_i), 1_i);
|
||||
WrapInFunction(acc);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -123,7 +125,7 @@ TEST_F(ResolverIndexAccessorTest, Vector_F32) {
|
||||
|
||||
TEST_F(ResolverIndexAccessorTest, Vector_Dynamic_Ref) {
|
||||
Global("my_var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
|
||||
auto* idx = Var("idx", ty.i32(), Expr(2));
|
||||
auto* idx = Var("idx", ty.i32(), Expr(2_i));
|
||||
auto* acc = IndexAccessor("my_var", idx);
|
||||
WrapInFunction(Decl(idx), acc);
|
||||
|
||||
@ -132,7 +134,7 @@ TEST_F(ResolverIndexAccessorTest, Vector_Dynamic_Ref) {
|
||||
|
||||
TEST_F(ResolverIndexAccessorTest, Vector_Dynamic) {
|
||||
GlobalConst("my_var", ty.vec3<f32>(), Construct(ty.vec3<f32>()));
|
||||
auto* idx = Var("idx", ty.i32(), Expr(2));
|
||||
auto* idx = Var("idx", ty.i32(), Expr(2_i));
|
||||
auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, idx));
|
||||
WrapInFunction(Decl(idx), acc);
|
||||
|
||||
@ -142,7 +144,7 @@ TEST_F(ResolverIndexAccessorTest, Vector_Dynamic) {
|
||||
TEST_F(ResolverIndexAccessorTest, Vector) {
|
||||
Global("my_var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
|
||||
|
||||
auto* acc = IndexAccessor("my_var", 2);
|
||||
auto* acc = IndexAccessor("my_var", 2_i);
|
||||
WrapInFunction(acc);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -155,7 +157,7 @@ TEST_F(ResolverIndexAccessorTest, Vector) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverIndexAccessorTest, Array) {
|
||||
auto* idx = Expr(2);
|
||||
auto* idx = Expr(2_i);
|
||||
Global("my_var", ty.array<f32, 3>(), ast::StorageClass::kPrivate);
|
||||
|
||||
auto* acc = IndexAccessor("my_var", idx);
|
||||
@ -175,7 +177,7 @@ TEST_F(ResolverIndexAccessorTest, Alias_Array) {
|
||||
|
||||
Global("my_var", ty.Of(aary), ast::StorageClass::kPrivate);
|
||||
|
||||
auto* acc = IndexAccessor("my_var", 2);
|
||||
auto* acc = IndexAccessor("my_var", 2_i);
|
||||
WrapInFunction(acc);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -190,7 +192,7 @@ TEST_F(ResolverIndexAccessorTest, Alias_Array) {
|
||||
TEST_F(ResolverIndexAccessorTest, Array_Constant) {
|
||||
GlobalConst("my_var", ty.array<f32, 3>(), array<f32, 3>());
|
||||
|
||||
auto* acc = IndexAccessor("my_var", 2);
|
||||
auto* acc = IndexAccessor("my_var", 2_i);
|
||||
WrapInFunction(acc);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -235,9 +237,9 @@ TEST_F(ResolverIndexAccessorTest, Array_Literal_F32) {
|
||||
|
||||
TEST_F(ResolverIndexAccessorTest, Array_Literal_I32) {
|
||||
// let a : array<f32, 3>;
|
||||
// var f : f32 = a[2];
|
||||
// var f : f32 = a[2i];
|
||||
auto* a = Let("a", ty.array<f32, 3>(), array<f32, 3>());
|
||||
auto* f = Var("a_2", ty.f32(), IndexAccessor("a", 2));
|
||||
auto* f = Var("a_2", ty.f32(), IndexAccessor("a", 2_i));
|
||||
Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
{
|
||||
Decl(a),
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/sem/storage_texture.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -34,7 +36,7 @@ TEST_F(ResolverAssignmentValidationTest, ReadOnlyBuffer) {
|
||||
create<ast::GroupAttribute>(0),
|
||||
});
|
||||
|
||||
WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("a", "m"), 1));
|
||||
WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("a", "m"), 1_i));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -44,11 +46,11 @@ TEST_F(ResolverAssignmentValidationTest, ReadOnlyBuffer) {
|
||||
|
||||
TEST_F(ResolverAssignmentValidationTest, AssignIncompatibleTypes) {
|
||||
// {
|
||||
// var a : i32 = 2;
|
||||
// var a : i32 = 2i;
|
||||
// a = 2.3;
|
||||
// }
|
||||
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
||||
|
||||
auto* assign = Assign(Source{{12, 34}}, "a", 2.3f);
|
||||
WrapInFunction(var, assign);
|
||||
@ -61,14 +63,14 @@ TEST_F(ResolverAssignmentValidationTest, AssignIncompatibleTypes) {
|
||||
TEST_F(ResolverAssignmentValidationTest, AssignArraysWithDifferentSizeExpressions_Pass) {
|
||||
// let len = 4u;
|
||||
// {
|
||||
// var a : array<f32, 4>;
|
||||
// var a : array<f32, 4u>;
|
||||
// var b : array<f32, len>;
|
||||
// a = b;
|
||||
// }
|
||||
|
||||
GlobalConst("len", nullptr, Expr(4u));
|
||||
GlobalConst("len", nullptr, Expr(4_u));
|
||||
|
||||
auto* a = Var("a", ty.array(ty.f32(), 4));
|
||||
auto* a = Var("a", ty.array(ty.f32(), 4_u));
|
||||
auto* b = Var("b", ty.array(ty.f32(), "len"));
|
||||
|
||||
auto* assign = Assign(Source{{12, 34}}, "a", "b");
|
||||
@ -80,14 +82,14 @@ TEST_F(ResolverAssignmentValidationTest, AssignArraysWithDifferentSizeExpression
|
||||
TEST_F(ResolverAssignmentValidationTest, AssignArraysWithDifferentSizeExpressions_Fail) {
|
||||
// let len = 5u;
|
||||
// {
|
||||
// var a : array<f32, 4>;
|
||||
// var a : array<f32, 4u>;
|
||||
// var b : array<f32, len>;
|
||||
// a = b;
|
||||
// }
|
||||
|
||||
GlobalConst("len", nullptr, Expr(5u));
|
||||
GlobalConst("len", nullptr, Expr(5_u));
|
||||
|
||||
auto* a = Var("a", ty.array(ty.f32(), 4));
|
||||
auto* a = Var("a", ty.array(ty.f32(), 4_u));
|
||||
auto* b = Var("b", ty.array(ty.f32(), "len"));
|
||||
|
||||
auto* assign = Assign(Source{{12, 34}}, "a", "b");
|
||||
@ -100,22 +102,22 @@ TEST_F(ResolverAssignmentValidationTest, AssignArraysWithDifferentSizeExpression
|
||||
|
||||
TEST_F(ResolverAssignmentValidationTest, AssignCompatibleTypesInBlockStatement_Pass) {
|
||||
// {
|
||||
// var a : i32 = 2;
|
||||
// a = 2
|
||||
// var a : i32 = 2i;
|
||||
// a = 2i
|
||||
// }
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
WrapInFunction(var, Assign("a", 2));
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
||||
WrapInFunction(var, Assign("a", 2_i));
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
|
||||
TEST_F(ResolverAssignmentValidationTest, AssignIncompatibleTypesInBlockStatement_Fail) {
|
||||
// {
|
||||
// var a : i32 = 2;
|
||||
// var a : i32 = 2i;
|
||||
// a = 2.3;
|
||||
// }
|
||||
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
||||
WrapInFunction(var, Assign(Source{{12, 34}}, "a", 2.3f));
|
||||
|
||||
ASSERT_FALSE(r()->Resolve());
|
||||
@ -126,12 +128,12 @@ TEST_F(ResolverAssignmentValidationTest, AssignIncompatibleTypesInBlockStatement
|
||||
TEST_F(ResolverAssignmentValidationTest, AssignIncompatibleTypesInNestedBlockStatement_Fail) {
|
||||
// {
|
||||
// {
|
||||
// var a : i32 = 2;
|
||||
// var a : i32 = 2i;
|
||||
// a = 2.3;
|
||||
// }
|
||||
// }
|
||||
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
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* outer_block = Block(inner_block);
|
||||
WrapInFunction(outer_block);
|
||||
@ -142,42 +144,42 @@ TEST_F(ResolverAssignmentValidationTest, AssignIncompatibleTypesInNestedBlockSta
|
||||
}
|
||||
|
||||
TEST_F(ResolverAssignmentValidationTest, AssignToScalar_Fail) {
|
||||
// var my_var : i32 = 2;
|
||||
// var my_var : i32 = 2i;
|
||||
// 1 = my_var;
|
||||
|
||||
auto* var = Var("my_var", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
WrapInFunction(var, Assign(Expr(Source{{12, 34}}, 1), "my_var"));
|
||||
auto* var = Var("my_var", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
||||
WrapInFunction(var, Assign(Expr(Source{{12, 34}}, 1_i), "my_var"));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: cannot assign to value of type 'i32'");
|
||||
}
|
||||
|
||||
TEST_F(ResolverAssignmentValidationTest, AssignCompatibleTypes_Pass) {
|
||||
// var a : i32 = 2;
|
||||
// a = 2
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
WrapInFunction(var, Assign(Source{{12, 34}}, "a", 2));
|
||||
// var a : i32 = 2i;
|
||||
// a = 2i
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
||||
WrapInFunction(var, Assign(Source{{12, 34}}, "a", 2_i));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
|
||||
TEST_F(ResolverAssignmentValidationTest, AssignCompatibleTypesThroughAlias_Pass) {
|
||||
// alias myint = i32;
|
||||
// var a : myint = 2;
|
||||
// var a : myint = 2i;
|
||||
// a = 2
|
||||
auto* myint = Alias("myint", ty.i32());
|
||||
auto* var = Var("a", ty.Of(myint), ast::StorageClass::kNone, Expr(2));
|
||||
WrapInFunction(var, Assign(Source{{12, 34}}, "a", 2));
|
||||
auto* var = Var("a", ty.Of(myint), ast::StorageClass::kNone, Expr(2_i));
|
||||
WrapInFunction(var, Assign(Source{{12, 34}}, "a", 2_i));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
|
||||
TEST_F(ResolverAssignmentValidationTest, AssignCompatibleTypesInferRHSLoad_Pass) {
|
||||
// var a : i32 = 2;
|
||||
// var b : i32 = 3;
|
||||
// var a : i32 = 2i;
|
||||
// var b : i32 = 3i;
|
||||
// a = b;
|
||||
auto* var_a = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
auto* var_b = Var("b", ty.i32(), ast::StorageClass::kNone, Expr(3));
|
||||
auto* var_a = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
||||
auto* var_b = Var("b", ty.i32(), ast::StorageClass::kNone, Expr(3_i));
|
||||
WrapInFunction(var_a, var_b, Assign(Source{{12, 34}}, "a", "b"));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -186,22 +188,22 @@ TEST_F(ResolverAssignmentValidationTest, AssignCompatibleTypesInferRHSLoad_Pass)
|
||||
TEST_F(ResolverAssignmentValidationTest, AssignThroughPointer_Pass) {
|
||||
// var a : i32;
|
||||
// let b : ptr<function,i32> = &a;
|
||||
// *b = 2;
|
||||
// *b = 2i;
|
||||
const auto func = ast::StorageClass::kFunction;
|
||||
auto* var_a = Var("a", ty.i32(), func, Expr(2));
|
||||
auto* var_b = Let("b", ty.pointer<int>(func), AddressOf(Expr("a")));
|
||||
WrapInFunction(var_a, var_b, Assign(Source{{12, 34}}, Deref("b"), 2));
|
||||
auto* var_a = Var("a", ty.i32(), func, Expr(2_i));
|
||||
auto* var_b = Let("b", ty.pointer<i32>(func), AddressOf(Expr("a")));
|
||||
WrapInFunction(var_a, var_b, Assign(Source{{12, 34}}, Deref("b"), 2_i));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
|
||||
TEST_F(ResolverAssignmentValidationTest, AssignToConstant_Fail) {
|
||||
// {
|
||||
// let a : i32 = 2;
|
||||
// a = 2
|
||||
// let a : i32 = 2i;
|
||||
// a = 2i
|
||||
// }
|
||||
auto* var = Let("a", ty.i32(), Expr(2));
|
||||
WrapInFunction(var, Assign(Expr(Source{{12, 34}}, "a"), 2));
|
||||
auto* var = Let("a", ty.i32(), Expr(2_i));
|
||||
WrapInFunction(var, Assign(Expr(Source{{12, 34}}, "a"), 2_i));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: cannot assign to const\nnote: 'a' is declared here:");
|
||||
@ -324,7 +326,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_Pass) {
|
||||
// @group(0) @binding(3) var<storage, read_write> s : S;
|
||||
// var<workgroup> wg : array<f32, 10>
|
||||
// fn f() {
|
||||
// _ = 1;
|
||||
// _ = 1i;
|
||||
// _ = 2u;
|
||||
// _ = 3.0;
|
||||
// _ = vec2<bool>();
|
||||
@ -336,7 +338,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_Pass) {
|
||||
// _ = u;
|
||||
// _ = u.i;
|
||||
// _ = wg;
|
||||
// _ = wg[3];
|
||||
// _ = wg[3i];
|
||||
// }
|
||||
auto* S = Structure("S", {
|
||||
Member("i", ty.i32()),
|
||||
@ -349,9 +351,9 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_Pass) {
|
||||
Global("s", ty.Of(S), ast::StorageClass::kStorage, GroupAndBinding(0, 3));
|
||||
Global("wg", ty.array<f32, 10>(), ast::StorageClass::kWorkgroup);
|
||||
|
||||
WrapInFunction(Assign(Phony(), 1), //
|
||||
Assign(Phony(), 2), //
|
||||
Assign(Phony(), 3), //
|
||||
WrapInFunction(Assign(Phony(), 1_i), //
|
||||
Assign(Phony(), 2_u), //
|
||||
Assign(Phony(), 3.f), //
|
||||
Assign(Phony(), vec2<bool>()), //
|
||||
Assign(Phony(), "tex"), //
|
||||
Assign(Phony(), "smp"), //
|
||||
@ -361,7 +363,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_Pass) {
|
||||
Assign(Phony(), "u"), //
|
||||
Assign(Phony(), MemberAccessor("u", "i")), //
|
||||
Assign(Phony(), "wg"), //
|
||||
Assign(Phony(), IndexAccessor("wg", 3)));
|
||||
Assign(Phony(), IndexAccessor("wg", 3_i)));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -131,10 +133,10 @@ TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_ArrayOfStruct) {
|
||||
// struct S{
|
||||
// m: atomic<u32>;
|
||||
// };
|
||||
// var<private> v: array<S, 5>;
|
||||
// var<private> v: array<S, 5u>;
|
||||
|
||||
auto* s = Structure("S", {Member("m", ty.atomic<u32>())});
|
||||
Global(Source{{56, 78}}, "v", ty.array(ty.Of(s), 5), ast::StorageClass::kPrivate);
|
||||
Global(Source{{56, 78}}, "v", ty.array(ty.Of(s), 5_u), ast::StorageClass::kPrivate);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -144,16 +146,16 @@ TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_ArrayOfStruct) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_ArrayOfStructOfArray) {
|
||||
// type AtomicArray = array<atomic<i32>, 5>;
|
||||
// type AtomicArray = array<atomic<i32>, 5u>;
|
||||
// struct S{
|
||||
// m: AtomicArray;
|
||||
// };
|
||||
// var<private> v: array<S, 5>;
|
||||
// var<private> v: array<S, 5u>;
|
||||
|
||||
auto* atomic_array =
|
||||
Alias(Source{{12, 34}}, "AtomicArray", ty.atomic(Source{{12, 34}}, ty.i32()));
|
||||
auto* s = Structure("S", {Member("m", ty.Of(atomic_array))});
|
||||
Global(Source{{56, 78}}, "v", ty.array(ty.Of(s), 5), ast::StorageClass::kPrivate);
|
||||
Global(Source{{56, 78}}, "v", ty.array(ty.Of(s), 5_u), ast::StorageClass::kPrivate);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -163,14 +165,14 @@ TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_ArrayOfStructOfArray) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_Complex) {
|
||||
// type AtomicArray = array<atomic<i32>, 5>;
|
||||
// type AtomicArray = array<atomic<i32>, 5u>;
|
||||
// struct S6 { x: array<i32, 4>; };
|
||||
// struct S5 { x: S6;
|
||||
// y: AtomicArray;
|
||||
// z: array<atomic<u32>, 8>; };
|
||||
// z: array<atomic<u32>, 8u>; };
|
||||
// struct S4 { x: S6;
|
||||
// y: S5;
|
||||
// z: array<atomic<i32>, 4>; };
|
||||
// z: array<atomic<i32>, 4u>; };
|
||||
// struct S3 { x: S4; };
|
||||
// struct S2 { x: S3; };
|
||||
// struct S1 { x: S2; };
|
||||
@ -179,9 +181,9 @@ TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_Complex) {
|
||||
|
||||
auto* atomic_array =
|
||||
Alias(Source{{12, 34}}, "AtomicArray", ty.atomic(Source{{12, 34}}, ty.i32()));
|
||||
auto* array_i32_4 = ty.array(ty.i32(), 4);
|
||||
auto* array_atomic_u32_8 = ty.array(ty.atomic(ty.u32()), 8);
|
||||
auto* array_atomic_i32_4 = ty.array(ty.atomic(ty.i32()), 4);
|
||||
auto* array_i32_4 = ty.array(ty.i32(), 4_u);
|
||||
auto* array_atomic_u32_8 = ty.array(ty.atomic(ty.u32()), 8_u);
|
||||
auto* array_atomic_i32_4 = ty.array(ty.atomic(ty.i32()), 4_u);
|
||||
|
||||
auto* s6 = Structure("S6", {Member("x", array_i32_4)});
|
||||
auto* s5 = Structure("S5", {Member("x", ty.Of(s6)), //
|
||||
@ -263,13 +265,13 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_StructOfStructOfArray) {
|
||||
|
||||
TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_Complex) {
|
||||
// type AtomicArray = array<atomic<i32>, 5>;
|
||||
// struct S6 { x: array<i32, 4>; };
|
||||
// struct S6 { x: array<i32, 4u>; };
|
||||
// struct S5 { x: S6;
|
||||
// y: AtomicArray;
|
||||
// z: array<atomic<u32>, 8>; };
|
||||
// z: array<atomic<u32>, 8u>; };
|
||||
// struct S4 { x: S6;
|
||||
// y: S5;
|
||||
// z: array<atomic<i32>, 4>; };
|
||||
// z: array<atomic<i32>, 4u>; };
|
||||
// struct S3 { x: S4; };
|
||||
// struct S2 { x: S3; };
|
||||
// struct S1 { x: S2; };
|
||||
@ -278,9 +280,9 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_Complex) {
|
||||
|
||||
auto* atomic_array =
|
||||
Alias(Source{{12, 34}}, "AtomicArray", ty.atomic(Source{{12, 34}}, ty.i32()));
|
||||
auto* array_i32_4 = ty.array(ty.i32(), 4);
|
||||
auto* array_atomic_u32_8 = ty.array(ty.atomic(ty.u32()), 8);
|
||||
auto* array_atomic_i32_4 = ty.array(ty.atomic(ty.i32()), 4);
|
||||
auto* array_i32_4 = ty.array(ty.i32(), 4_u);
|
||||
auto* array_atomic_u32_8 = ty.array(ty.atomic(ty.u32()), 8_u);
|
||||
auto* array_atomic_i32_4 = ty.array(ty.atomic(ty.i32()), 4_u);
|
||||
|
||||
auto* s6 = Structure("S6", {Member("x", array_i32_4)});
|
||||
auto* s5 = Structure("S5", {Member("x", ty.Of(s6)), //
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
|
||||
// Helpers and typedefs
|
||||
@ -44,9 +46,6 @@ template <typename T>
|
||||
using alias2 = builder::alias2<T>;
|
||||
template <typename T>
|
||||
using alias3 = builder::alias3<T>;
|
||||
using f32 = builder::f32;
|
||||
using i32 = builder::i32;
|
||||
using u32 = builder::u32;
|
||||
|
||||
namespace AttributeTests {
|
||||
namespace {
|
||||
@ -115,10 +114,10 @@ static ast::AttributeList createAttributes(const Source& source,
|
||||
case AttributeKind::kStride:
|
||||
return {builder.create<ast::StrideAttribute>(source, 4u)};
|
||||
case AttributeKind::kWorkgroup:
|
||||
return {builder.create<ast::WorkgroupAttribute>(source, builder.Expr(1))};
|
||||
return {builder.create<ast::WorkgroupAttribute>(source, builder.Expr(1_i))};
|
||||
case AttributeKind::kBindingAndGroup:
|
||||
return {builder.create<ast::BindingAttribute>(source, 1u),
|
||||
builder.create<ast::GroupAttribute>(source, 1u)};
|
||||
return {builder.create<ast::BindingAttribute>(source, 1_u),
|
||||
builder.create<ast::GroupAttribute>(source, 1_u)};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@ -198,7 +197,7 @@ TEST_P(ComputeShaderParameterAttributeTest, IsValid) {
|
||||
auto& params = GetParam();
|
||||
auto* p = Param("a", ty.vec4<f32>(), createAttributes(Source{{12, 34}}, *this, params.kind));
|
||||
Func("main", ast::VariableList{p}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
if (params.should_pass) {
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -318,7 +317,7 @@ using ComputeShaderReturnTypeAttributeTest = TestWithParams;
|
||||
TEST_P(ComputeShaderReturnTypeAttributeTest, IsValid) {
|
||||
auto& params = GetParam();
|
||||
Func("main", ast::VariableList{}, ty.vec4<f32>(), {Return(Construct(ty.vec4<f32>(), 1.f))},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)},
|
||||
createAttributes(Source{{12, 34}}, *this, params.kind));
|
||||
|
||||
if (params.should_pass) {
|
||||
@ -493,7 +492,7 @@ TEST_F(EntryPointReturnTypeAttributeTest, DuplicateAttribute) {
|
||||
}
|
||||
|
||||
TEST_F(EntryPointReturnTypeAttributeTest, DuplicateInternalAttribute) {
|
||||
Func("f", {}, ty.i32(), {Return(1)}, {Stage(ast::PipelineStage::kFragment)},
|
||||
Func("f", {}, ty.i32(), {Return(1_i)}, {Stage(ast::PipelineStage::kFragment)},
|
||||
ast::AttributeList{
|
||||
Disable(ast::DisabledValidation::kBindingPointCollision),
|
||||
Disable(ast::DisabledValidation::kEntryPointParameter),
|
||||
@ -794,7 +793,7 @@ TEST_P(ArrayStrideTest, All) {
|
||||
<< ", should_pass: " << params.should_pass;
|
||||
SCOPED_TRACE(ss.str());
|
||||
|
||||
auto* arr = ty.array(Source{{12, 34}}, el_ty, 4, params.stride);
|
||||
auto* arr = ty.array(Source{{12, 34}}, el_ty, 4_u, params.stride);
|
||||
|
||||
Global("myarray", arr, ast::StorageClass::kPrivate);
|
||||
|
||||
@ -873,10 +872,10 @@ INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
|
||||
ParamsFor<mat4x4<f32>>((default_mat4x4.align - 1) * 7, false)));
|
||||
|
||||
TEST_F(ArrayStrideTest, DuplicateAttribute) {
|
||||
auto* arr = ty.array(Source{{12, 34}}, ty.i32(), 4,
|
||||
auto* arr = ty.array(Source{{12, 34}}, ty.i32(), 4_u,
|
||||
{
|
||||
create<ast::StrideAttribute>(Source{{12, 34}}, 4),
|
||||
create<ast::StrideAttribute>(Source{{56, 78}}, 4),
|
||||
create<ast::StrideAttribute>(Source{{12, 34}}, 4_i),
|
||||
create<ast::StrideAttribute>(Source{{56, 78}}, 4_i),
|
||||
});
|
||||
|
||||
Global("myarray", arr, ast::StorageClass::kPrivate);
|
||||
@ -968,9 +967,9 @@ TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByEntryPoint) {
|
||||
Func("F", {}, ty.void_(),
|
||||
{
|
||||
Decl(Var("a", ty.vec4<f32>(), ast::StorageClass::kNone,
|
||||
Call("textureLoad", "A", vec2<i32>(1, 2), 0))),
|
||||
Call("textureLoad", "A", vec2<i32>(1_i, 2_i), 0_i))),
|
||||
Decl(Var("b", ty.vec4<f32>(), ast::StorageClass::kNone,
|
||||
Call("textureLoad", "B", vec2<i32>(1, 2), 0))),
|
||||
Call("textureLoad", "B", vec2<i32>(1_i, 2_i), 0_i))),
|
||||
},
|
||||
{Stage(ast::PipelineStage::kFragment)});
|
||||
|
||||
@ -998,13 +997,13 @@ TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByDifferentEntryPoints) {
|
||||
Func("F_A", {}, ty.void_(),
|
||||
{
|
||||
Decl(Var("a", ty.vec4<f32>(), ast::StorageClass::kNone,
|
||||
Call("textureLoad", "A", vec2<i32>(1, 2), 0))),
|
||||
Call("textureLoad", "A", vec2<i32>(1_i, 2_i), 0_i))),
|
||||
},
|
||||
{Stage(ast::PipelineStage::kFragment)});
|
||||
Func("F_B", {}, ty.void_(),
|
||||
{
|
||||
Decl(Var("b", ty.vec4<f32>(), ast::StorageClass::kNone,
|
||||
Call("textureLoad", "B", vec2<i32>(1, 2), 0))),
|
||||
Call("textureLoad", "B", vec2<i32>(1_i, 2_i), 0_i))),
|
||||
},
|
||||
{Stage(ast::PipelineStage::kFragment)});
|
||||
|
||||
@ -1065,7 +1064,7 @@ using WorkgroupAttribute = ResolverTest;
|
||||
TEST_F(WorkgroupAttribute, ComputeShaderPass) {
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute),
|
||||
create<ast::WorkgroupAttribute>(Source{{12, 34}}, Expr(1))});
|
||||
create<ast::WorkgroupAttribute>(Source{{12, 34}}, Expr(1_i))});
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
@ -1080,7 +1079,8 @@ TEST_F(WorkgroupAttribute, Missing) {
|
||||
}
|
||||
|
||||
TEST_F(WorkgroupAttribute, NotAnEntryPoint) {
|
||||
Func("main", {}, ty.void_(), {}, {create<ast::WorkgroupAttribute>(Source{{12, 34}}, Expr(1))});
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{create<ast::WorkgroupAttribute>(Source{{12, 34}}, Expr(1_i))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -1091,7 +1091,7 @@ TEST_F(WorkgroupAttribute, NotAnEntryPoint) {
|
||||
TEST_F(WorkgroupAttribute, NotAComputeShader) {
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kFragment),
|
||||
create<ast::WorkgroupAttribute>(Source{{12, 34}}, Expr(1))});
|
||||
create<ast::WorkgroupAttribute>(Source{{12, 34}}, Expr(1_i))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -1103,8 +1103,8 @@ TEST_F(WorkgroupAttribute, DuplicateAttribute) {
|
||||
Func(Source{{12, 34}}, "main", {}, ty.void_(), {},
|
||||
{
|
||||
Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(Source{{12, 34}}, 1, nullptr, nullptr),
|
||||
WorkgroupSize(Source{{56, 78}}, 2, nullptr, nullptr),
|
||||
WorkgroupSize(Source{{12, 34}}, 1_i, nullptr, nullptr),
|
||||
WorkgroupSize(Source{{56, 78}}, 2_i, nullptr, nullptr),
|
||||
});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -34,24 +34,24 @@ struct Type {
|
||||
};
|
||||
|
||||
static constexpr Type kNumericScalars[] = {
|
||||
Type::Create<builder::f32>(),
|
||||
Type::Create<builder::i32>(),
|
||||
Type::Create<builder::u32>(),
|
||||
Type::Create<f32>(),
|
||||
Type::Create<i32>(),
|
||||
Type::Create<u32>(),
|
||||
};
|
||||
static constexpr Type kVec2NumericScalars[] = {
|
||||
Type::Create<builder::vec2<builder::f32>>(),
|
||||
Type::Create<builder::vec2<builder::i32>>(),
|
||||
Type::Create<builder::vec2<builder::u32>>(),
|
||||
Type::Create<builder::vec2<f32>>(),
|
||||
Type::Create<builder::vec2<i32>>(),
|
||||
Type::Create<builder::vec2<u32>>(),
|
||||
};
|
||||
static constexpr Type kVec3NumericScalars[] = {
|
||||
Type::Create<builder::vec3<builder::f32>>(),
|
||||
Type::Create<builder::vec3<builder::i32>>(),
|
||||
Type::Create<builder::vec3<builder::u32>>(),
|
||||
Type::Create<builder::vec3<f32>>(),
|
||||
Type::Create<builder::vec3<i32>>(),
|
||||
Type::Create<builder::vec3<u32>>(),
|
||||
};
|
||||
static constexpr Type kVec4NumericScalars[] = {
|
||||
Type::Create<builder::vec4<builder::f32>>(),
|
||||
Type::Create<builder::vec4<builder::i32>>(),
|
||||
Type::Create<builder::vec4<builder::u32>>(),
|
||||
Type::Create<builder::vec4<f32>>(),
|
||||
Type::Create<builder::vec4<i32>>(),
|
||||
Type::Create<builder::vec4<u32>>(),
|
||||
};
|
||||
static constexpr Type kInvalid[] = {
|
||||
// A non-exhaustive selection of uncastable types
|
||||
@ -59,16 +59,16 @@ static constexpr Type kInvalid[] = {
|
||||
Type::Create<builder::vec2<bool>>(),
|
||||
Type::Create<builder::vec3<bool>>(),
|
||||
Type::Create<builder::vec4<bool>>(),
|
||||
Type::Create<builder::array<2, builder::i32>>(),
|
||||
Type::Create<builder::array<3, builder::u32>>(),
|
||||
Type::Create<builder::array<4, builder::f32>>(),
|
||||
Type::Create<builder::array<2, i32>>(),
|
||||
Type::Create<builder::array<3, u32>>(),
|
||||
Type::Create<builder::array<4, f32>>(),
|
||||
Type::Create<builder::array<5, bool>>(),
|
||||
Type::Create<builder::mat2x2<builder::f32>>(),
|
||||
Type::Create<builder::mat3x3<builder::f32>>(),
|
||||
Type::Create<builder::mat4x4<builder::f32>>(),
|
||||
Type::Create<builder::ptr<builder::i32>>(),
|
||||
Type::Create<builder::ptr<builder::array<2, builder::i32>>>(),
|
||||
Type::Create<builder::ptr<builder::mat2x2<builder::f32>>>(),
|
||||
Type::Create<builder::mat2x2<f32>>(),
|
||||
Type::Create<builder::mat3x3<f32>>(),
|
||||
Type::Create<builder::mat4x4<f32>>(),
|
||||
Type::Create<builder::ptr<i32>>(),
|
||||
Type::Create<builder::ptr<builder::array<2, i32>>>(),
|
||||
Type::Create<builder::ptr<builder::mat2x2<f32>>>(),
|
||||
};
|
||||
|
||||
using ResolverBitcastValidationTest = ResolverTestWithParam<std::tuple<Type, Type>>;
|
||||
|
@ -39,6 +39,8 @@
|
||||
using ::testing::ElementsAre;
|
||||
using ::testing::HasSubstr;
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -331,7 +333,7 @@ TEST_F(ResolverBuiltinTest, Select_Error_NoParams) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBuiltinTest, Select_Error_SelectorInt) {
|
||||
auto* expr = Call("select", 1, 1, 1);
|
||||
auto* expr = Call("select", 1_i, 1_i, 1_i);
|
||||
WrapInFunction(expr);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -456,8 +458,8 @@ TEST_P(ResolverBuiltinTest_DataPacking, Error_IncorrectParamType) {
|
||||
bool pack4 =
|
||||
param.builtin == BuiltinType::kPack4x8snorm || param.builtin == BuiltinType::kPack4x8unorm;
|
||||
|
||||
auto* call =
|
||||
pack4 ? Call(param.name, vec4<i32>(1, 2, 3, 4)) : Call(param.name, vec2<i32>(1, 2));
|
||||
auto* call = pack4 ? Call(param.name, vec4<i32>(1_i, 2_i, 3_i, 4_i))
|
||||
: Call(param.name, vec2<i32>(1_i, 2_i));
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -507,7 +509,7 @@ TEST_P(ResolverBuiltinTest_DataUnpacking, InferType) {
|
||||
bool pack4 = param.builtin == BuiltinType::kUnpack4x8snorm ||
|
||||
param.builtin == BuiltinType::kUnpack4x8unorm;
|
||||
|
||||
auto* call = Call(param.name, 1u);
|
||||
auto* call = Call(param.name, 1_u);
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -573,7 +575,7 @@ TEST_P(ResolverBuiltinTest_SingleParam, Error_NoParams) {
|
||||
TEST_P(ResolverBuiltinTest_SingleParam, Error_TooManyParams) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* call = Call(param.name, 1, 2, 3);
|
||||
auto* call = Call(param.name, 1_i, 2_i, 3_i);
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -630,7 +632,7 @@ TEST_F(ResolverBuiltinDataTest, ArrayLength_Vector) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBuiltinDataTest, ArrayLength_Error_ArraySized) {
|
||||
Global("arr", ty.array<int, 4>(), ast::StorageClass::kPrivate);
|
||||
Global("arr", ty.array<i32, 4>(), ast::StorageClass::kPrivate);
|
||||
auto* call = Call("arrayLength", AddressOf("arr"));
|
||||
WrapInFunction(call);
|
||||
|
||||
@ -732,7 +734,7 @@ TEST_F(ResolverBuiltinDataTest, FrexpVector) {
|
||||
|
||||
TEST_F(ResolverBuiltinDataTest, Frexp_Error_FirstParamInt) {
|
||||
Global("v", ty.i32(), ast::StorageClass::kWorkgroup);
|
||||
auto* call = Call("frexp", 1, AddressOf("v"));
|
||||
auto* call = Call("frexp", 1_i, AddressOf("v"));
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -763,7 +765,7 @@ TEST_F(ResolverBuiltinDataTest, Frexp_Error_SecondParamFloatPtr) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBuiltinDataTest, Frexp_Error_SecondParamNotAPointer) {
|
||||
auto* call = Call("frexp", 1.0f, 1);
|
||||
auto* call = Call("frexp", 1.0f, 1_i);
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -856,7 +858,7 @@ TEST_F(ResolverBuiltinDataTest, ModfVector) {
|
||||
|
||||
TEST_F(ResolverBuiltinDataTest, Modf_Error_FirstParamInt) {
|
||||
Global("whole", ty.f32(), ast::StorageClass::kWorkgroup);
|
||||
auto* call = Call("modf", 1, AddressOf("whole"));
|
||||
auto* call = Call("modf", 1_i, AddressOf("whole"));
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -945,7 +947,7 @@ TEST_P(ResolverBuiltinTest_SingleParam_FloatOrInt, Float_Vector) {
|
||||
TEST_P(ResolverBuiltinTest_SingleParam_FloatOrInt, Sint_Scalar) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* call = Call(param.name, -1);
|
||||
auto* call = Call(param.name, i32(-1));
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -957,7 +959,7 @@ TEST_P(ResolverBuiltinTest_SingleParam_FloatOrInt, Sint_Scalar) {
|
||||
TEST_P(ResolverBuiltinTest_SingleParam_FloatOrInt, Sint_Vector) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* call = Call(param.name, vec3<i32>(1, 1, 3));
|
||||
auto* call = Call(param.name, vec3<i32>(1_i, 1_i, 3_i));
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -970,7 +972,7 @@ TEST_P(ResolverBuiltinTest_SingleParam_FloatOrInt, Sint_Vector) {
|
||||
TEST_P(ResolverBuiltinTest_SingleParam_FloatOrInt, Uint_Scalar) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* call = Call(param.name, 1u);
|
||||
auto* call = Call(param.name, 1_u);
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -982,7 +984,7 @@ TEST_P(ResolverBuiltinTest_SingleParam_FloatOrInt, Uint_Scalar) {
|
||||
TEST_P(ResolverBuiltinTest_SingleParam_FloatOrInt, Uint_Vector) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* call = Call(param.name, vec3<u32>(1u, 1u, 3u));
|
||||
auto* call = Call(param.name, vec3<u32>(1_u, 1_u, 3_u));
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -1061,7 +1063,7 @@ TEST_P(ResolverBuiltinTest_TwoParam, Vector) {
|
||||
TEST_P(ResolverBuiltinTest_TwoParam, Error_NoTooManyParams) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* call = Call(param.name, 1, 2, 3);
|
||||
auto* call = Call(param.name, 1_i, 2_i, 3_i);
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -1152,7 +1154,7 @@ TEST_F(ResolverBuiltinTest, Cross_Error_Scalar) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBuiltinTest, Cross_Error_Vec3Int) {
|
||||
auto* call = Call("cross", vec3<i32>(1, 2, 3), vec3<i32>(1, 2, 3));
|
||||
auto* call = Call("cross", vec3<i32>(1_i, 2_i, 3_i), vec3<i32>(1_i, 2_i, 3_i));
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -1295,7 +1297,7 @@ TEST_P(ResolverBuiltinTest_ThreeParam_FloatOrInt, Float_Vector) {
|
||||
TEST_P(ResolverBuiltinTest_ThreeParam_FloatOrInt, Sint_Scalar) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* call = Call(param.name, 1, 1, 1);
|
||||
auto* call = Call(param.name, 1_i, 1_i, 1_i);
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -1307,7 +1309,8 @@ TEST_P(ResolverBuiltinTest_ThreeParam_FloatOrInt, Sint_Scalar) {
|
||||
TEST_P(ResolverBuiltinTest_ThreeParam_FloatOrInt, Sint_Vector) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* call = Call(param.name, vec3<i32>(1, 1, 3), vec3<i32>(1, 1, 3), vec3<i32>(1, 1, 3));
|
||||
auto* call = Call(param.name, vec3<i32>(1_i, 1_i, 3_i), vec3<i32>(1_i, 1_i, 3_i),
|
||||
vec3<i32>(1_i, 1_i, 3_i));
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -1320,7 +1323,7 @@ TEST_P(ResolverBuiltinTest_ThreeParam_FloatOrInt, Sint_Vector) {
|
||||
TEST_P(ResolverBuiltinTest_ThreeParam_FloatOrInt, Uint_Scalar) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* call = Call(param.name, 1u, 1u, 1u);
|
||||
auto* call = Call(param.name, 1_u, 1_u, 1_u);
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -1332,8 +1335,8 @@ TEST_P(ResolverBuiltinTest_ThreeParam_FloatOrInt, Uint_Scalar) {
|
||||
TEST_P(ResolverBuiltinTest_ThreeParam_FloatOrInt, Uint_Vector) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* call =
|
||||
Call(param.name, vec3<u32>(1u, 1u, 3u), vec3<u32>(1u, 1u, 3u), vec3<u32>(1u, 1u, 3u));
|
||||
auto* call = Call(param.name, vec3<u32>(1_u, 1_u, 3_u), vec3<u32>(1_u, 1_u, 3_u),
|
||||
vec3<u32>(1_u, 1_u, 3_u));
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -1369,7 +1372,7 @@ using ResolverBuiltinTest_Int_SingleParam = ResolverTestWithParam<BuiltinData>;
|
||||
TEST_P(ResolverBuiltinTest_Int_SingleParam, Scalar) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* call = Call(param.name, 1);
|
||||
auto* call = Call(param.name, 1_i);
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -1381,7 +1384,7 @@ TEST_P(ResolverBuiltinTest_Int_SingleParam, Scalar) {
|
||||
TEST_P(ResolverBuiltinTest_Int_SingleParam, Vector) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* call = Call(param.name, vec3<i32>(1, 1, 3));
|
||||
auto* call = Call(param.name, vec3<i32>(1_i, 1_i, 3_i));
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -1416,7 +1419,7 @@ using ResolverBuiltinTest_FloatOrInt_TwoParam = ResolverTestWithParam<BuiltinDat
|
||||
TEST_P(ResolverBuiltinTest_FloatOrInt_TwoParam, Scalar_Signed) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* call = Call(param.name, 1, 1);
|
||||
auto* call = Call(param.name, 1_i, 1_i);
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -1428,7 +1431,7 @@ TEST_P(ResolverBuiltinTest_FloatOrInt_TwoParam, Scalar_Signed) {
|
||||
TEST_P(ResolverBuiltinTest_FloatOrInt_TwoParam, Scalar_Unsigned) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* call = Call(param.name, 1u, 1u);
|
||||
auto* call = Call(param.name, 1_u, 1_u);
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -1452,7 +1455,7 @@ TEST_P(ResolverBuiltinTest_FloatOrInt_TwoParam, Scalar_Float) {
|
||||
TEST_P(ResolverBuiltinTest_FloatOrInt_TwoParam, Vector_Signed) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* call = Call(param.name, vec3<i32>(1, 1, 3), vec3<i32>(1, 1, 3));
|
||||
auto* call = Call(param.name, vec3<i32>(1_i, 1_i, 3_i), vec3<i32>(1_i, 1_i, 3_i));
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -1465,7 +1468,7 @@ TEST_P(ResolverBuiltinTest_FloatOrInt_TwoParam, Vector_Signed) {
|
||||
TEST_P(ResolverBuiltinTest_FloatOrInt_TwoParam, Vector_Unsigned) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* call = Call(param.name, vec3<u32>(1u, 1u, 3u), vec3<u32>(1u, 1u, 3u));
|
||||
auto* call = Call(param.name, vec3<u32>(1_u, 1_u, 3_u), vec3<u32>(1_u, 1_u, 3_u));
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "src/tint/ast/builtin_texture_helper_test.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -37,7 +39,7 @@ TEST_F(ResolverBuiltinValidationTest, InvalidPipelineStageDirect) {
|
||||
auto* dpdx =
|
||||
create<ast::CallExpression>(Source{{3, 4}}, Expr("dpdx"), ast::ExpressionList{Expr(1.0f)});
|
||||
Func(Source{{1, 2}}, "func", ast::VariableList{}, ty.void_(), {CallStmt(dpdx)},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "3:4 error: built-in cannot be used by compute pipeline stage");
|
||||
@ -58,7 +60,7 @@ TEST_F(ResolverBuiltinValidationTest, InvalidPipelineStageIndirect) {
|
||||
Func(Source{{5, 6}}, "f2", {}, ty.void_(), {CallStmt(Call("f1"))});
|
||||
|
||||
Func(Source{{7, 8}}, "main", {}, ty.void_(), {CallStmt(Call("f2"))},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -78,7 +80,7 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsFunction) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalLet) {
|
||||
GlobalConst(Source{{12, 34}}, "mix", ty.i32(), Expr(1));
|
||||
GlobalConst(Source{{12, 34}}, "mix", ty.i32(), Expr(1_i));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -86,7 +88,7 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalLet) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalVar) {
|
||||
Global(Source{{12, 34}}, "mix", ty.i32(), Expr(1), ast::StorageClass::kPrivate);
|
||||
Global(Source{{12, 34}}, "mix", ty.i32(), Expr(1_i), ast::StorageClass::kPrivate);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -115,9 +117,6 @@ using TextureOverloadCase = ast::builtin::test::TextureOverloadCase;
|
||||
using ValidTextureOverload = ast::builtin::test::ValidTextureOverload;
|
||||
using TextureKind = ast::builtin::test::TextureKind;
|
||||
using TextureDataType = ast::builtin::test::TextureDataType;
|
||||
using u32 = ProgramBuilder::u32;
|
||||
using i32 = ProgramBuilder::i32;
|
||||
using f32 = ProgramBuilder::f32;
|
||||
|
||||
static std::vector<TextureOverloadCase> TextureCases(
|
||||
std::unordered_set<ValidTextureOverload> overloads) {
|
||||
@ -160,17 +159,18 @@ class Constexpr {
|
||||
const ast::Expression* operator()(Source src, ProgramBuilder& b) {
|
||||
switch (kind) {
|
||||
case Kind::kScalar:
|
||||
return b.Expr(src, values[0]);
|
||||
return b.Expr(src, i32(values[0]));
|
||||
case Kind::kVec2:
|
||||
return b.Construct(src, b.ty.vec2<i32>(), values[0], values[1]);
|
||||
return b.Construct(src, b.ty.vec2<i32>(), i32(values[0]), i32(values[1]));
|
||||
case Kind::kVec3:
|
||||
return b.Construct(src, b.ty.vec3<i32>(), values[0], values[1], values[2]);
|
||||
return b.Construct(src, b.ty.vec3<i32>(), i32(values[0]), i32(values[1]),
|
||||
i32(values[2]));
|
||||
case Kind::kVec3_Scalar_Vec2:
|
||||
return b.Construct(src, b.ty.vec3<i32>(), values[0],
|
||||
b.vec2<i32>(values[1], values[2]));
|
||||
return b.Construct(src, b.ty.vec3<i32>(), i32(values[0]),
|
||||
b.vec2<i32>(i32(values[1]), i32(values[2])));
|
||||
case Kind::kVec3_Vec2_Scalar:
|
||||
return b.Construct(src, b.ty.vec3<i32>(), b.vec2<i32>(values[0], values[1]),
|
||||
values[2]);
|
||||
return b.Construct(src, b.ty.vec3<i32>(),
|
||||
b.vec2<i32>(i32(values[0]), i32(values[1])), i32(values[2]));
|
||||
case Kind::kEmptyVec2:
|
||||
return b.Construct(src, b.ty.vec2<i32>());
|
||||
case Kind::kEmptyVec3:
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "src/tint/ast/call_statement.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -26,9 +28,6 @@ template <typename T>
|
||||
using vec3 = builder::vec3<T>;
|
||||
template <typename T>
|
||||
using vec4 = builder::vec4<T>;
|
||||
using f32 = builder::f32;
|
||||
using i32 = builder::i32;
|
||||
using u32 = builder::u32;
|
||||
|
||||
class ResolverBuiltinsValidationTest : public resolver::TestHelper, public testing::Test {};
|
||||
namespace StageTest {
|
||||
@ -106,7 +105,7 @@ TEST_P(ResolverBuiltinsStageTest, All_input) {
|
||||
break;
|
||||
case ast::PipelineStage::kCompute:
|
||||
Func("main", {input}, ty.void_(), {},
|
||||
ast::AttributeList{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
ast::AttributeList{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -243,7 +242,7 @@ TEST_F(ResolverBuiltinsValidationTest, SampleMaskNotU32_Struct_Fail) {
|
||||
TEST_F(ResolverBuiltinsValidationTest, SampleMaskNotU32_ReturnType_Fail) {
|
||||
// @stage(fragment)
|
||||
// fn main() -> @builtin(sample_mask) i32 { return 1; }
|
||||
Func("main", {}, ty.i32(), {Return(1)}, {Stage(ast::PipelineStage::kFragment)},
|
||||
Func("main", {}, ty.i32(), {Return(1_i)}, {Stage(ast::PipelineStage::kFragment)},
|
||||
{Builtin(Source{{12, 34}}, ast::Builtin::kSampleMask)});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -414,7 +413,7 @@ TEST_F(ResolverBuiltinsValidationTest, ComputeBuiltin_Pass) {
|
||||
|
||||
Func("main", ast::VariableList{li_id, li_index, gi, wi, nwgs}, ty.void_(), {},
|
||||
ast::AttributeList{Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(Expr(Source{Source::Location{12, 34}}, 2))});
|
||||
WorkgroupSize(Expr(Source{Source::Location{12, 34}}, 2_i))});
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
@ -424,7 +423,7 @@ TEST_F(ResolverBuiltinsValidationTest, ComputeBuiltin_WorkGroupIdNotVec3U32) {
|
||||
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kWorkgroupId)});
|
||||
Func("main", ast::VariableList{wi}, ty.void_(), {},
|
||||
ast::AttributeList{Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(Expr(Source{Source::Location{12, 34}}, 2))});
|
||||
WorkgroupSize(Expr(Source{Source::Location{12, 34}}, 2_i))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -437,7 +436,7 @@ TEST_F(ResolverBuiltinsValidationTest, ComputeBuiltin_NumWorkgroupsNotVec3U32) {
|
||||
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kNumWorkgroups)});
|
||||
Func("main", ast::VariableList{nwgs}, ty.void_(), {},
|
||||
ast::AttributeList{Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(Expr(Source{Source::Location{12, 34}}, 2))});
|
||||
WorkgroupSize(Expr(Source{Source::Location{12, 34}}, 2_i))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -451,7 +450,7 @@ TEST_F(ResolverBuiltinsValidationTest, ComputeBuiltin_GlobalInvocationNotVec3U32
|
||||
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kGlobalInvocationId)});
|
||||
Func("main", ast::VariableList{gi}, ty.void_(), {},
|
||||
ast::AttributeList{Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(Expr(Source{Source::Location{12, 34}}, 2))});
|
||||
WorkgroupSize(Expr(Source{Source::Location{12, 34}}, 2_i))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -465,7 +464,7 @@ TEST_F(ResolverBuiltinsValidationTest, ComputeBuiltin_LocalInvocationIndexNotU32
|
||||
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kLocalInvocationIndex)});
|
||||
Func("main", ast::VariableList{li_index}, ty.void_(), {},
|
||||
ast::AttributeList{Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(Expr(Source{Source::Location{12, 34}}, 2))});
|
||||
WorkgroupSize(Expr(Source{Source::Location{12, 34}}, 2_i))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -479,7 +478,7 @@ TEST_F(ResolverBuiltinsValidationTest, ComputeBuiltin_LocalInvocationNotVec3U32)
|
||||
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kLocalInvocationId)});
|
||||
Func("main", ast::VariableList{li_id}, ty.void_(), {},
|
||||
ast::AttributeList{Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(Expr(Source{Source::Location{12, 34}}, 2))});
|
||||
WorkgroupSize(Expr(Source{Source::Location{12, 34}}, 2_i))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -791,7 +790,7 @@ TEST_F(ResolverBuiltinsValidationTest, Select_Float_Scalar) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBuiltinsValidationTest, Select_Integer_Scalar) {
|
||||
auto* builtin = Call("select", Expr(1), Expr(1), Expr(true));
|
||||
auto* builtin = Call("select", Expr(1_i), Expr(1_i), Expr(true));
|
||||
WrapInFunction(builtin);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -813,7 +812,8 @@ TEST_F(ResolverBuiltinsValidationTest, Select_Float_Vec2) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBuiltinsValidationTest, Select_Integer_Vec2) {
|
||||
auto* builtin = Call("select", vec2<int>(1, 1), vec2<int>(1, 1), vec2<bool>(true, true));
|
||||
auto* builtin =
|
||||
Call("select", vec2<i32>(1_i, 1_i), vec2<i32>(1_i, 1_i), vec2<bool>(true, true));
|
||||
WrapInFunction(builtin);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -950,7 +950,7 @@ TEST_P(IntegerAllMatching, ScalarUnsigned) {
|
||||
|
||||
ast::ExpressionList params;
|
||||
for (uint32_t i = 0; i < num_params; ++i) {
|
||||
params.push_back(Construct<uint32_t>(1));
|
||||
params.push_back(Construct<u32>(1_i));
|
||||
}
|
||||
auto* builtin = Call(name, params);
|
||||
WrapInFunction(builtin);
|
||||
@ -965,7 +965,7 @@ TEST_P(IntegerAllMatching, Vec2Unsigned) {
|
||||
|
||||
ast::ExpressionList params;
|
||||
for (uint32_t i = 0; i < num_params; ++i) {
|
||||
params.push_back(vec2<uint32_t>(1u, 1u));
|
||||
params.push_back(vec2<u32>(1_u, 1_u));
|
||||
}
|
||||
auto* builtin = Call(name, params);
|
||||
WrapInFunction(builtin);
|
||||
@ -980,7 +980,7 @@ TEST_P(IntegerAllMatching, Vec3Unsigned) {
|
||||
|
||||
ast::ExpressionList params;
|
||||
for (uint32_t i = 0; i < num_params; ++i) {
|
||||
params.push_back(vec3<uint32_t>(1u, 1u, 1u));
|
||||
params.push_back(vec3<u32>(1_u, 1_u, 1_u));
|
||||
}
|
||||
auto* builtin = Call(name, params);
|
||||
WrapInFunction(builtin);
|
||||
@ -995,7 +995,7 @@ TEST_P(IntegerAllMatching, Vec4Unsigned) {
|
||||
|
||||
ast::ExpressionList params;
|
||||
for (uint32_t i = 0; i < num_params; ++i) {
|
||||
params.push_back(vec4<uint32_t>(1u, 1u, 1u, 1u));
|
||||
params.push_back(vec4<u32>(1_u, 1_u, 1_u, 1_u));
|
||||
}
|
||||
auto* builtin = Call(name, params);
|
||||
WrapInFunction(builtin);
|
||||
@ -1010,7 +1010,7 @@ TEST_P(IntegerAllMatching, ScalarSigned) {
|
||||
|
||||
ast::ExpressionList params;
|
||||
for (uint32_t i = 0; i < num_params; ++i) {
|
||||
params.push_back(Construct<int32_t>(1));
|
||||
params.push_back(Construct<i32>(1_i));
|
||||
}
|
||||
auto* builtin = Call(name, params);
|
||||
WrapInFunction(builtin);
|
||||
@ -1025,7 +1025,7 @@ TEST_P(IntegerAllMatching, Vec2Signed) {
|
||||
|
||||
ast::ExpressionList params;
|
||||
for (uint32_t i = 0; i < num_params; ++i) {
|
||||
params.push_back(vec2<int32_t>(1, 1));
|
||||
params.push_back(vec2<i32>(1_i, 1_i));
|
||||
}
|
||||
auto* builtin = Call(name, params);
|
||||
WrapInFunction(builtin);
|
||||
@ -1040,7 +1040,7 @@ TEST_P(IntegerAllMatching, Vec3Signed) {
|
||||
|
||||
ast::ExpressionList params;
|
||||
for (uint32_t i = 0; i < num_params; ++i) {
|
||||
params.push_back(vec3<int32_t>(1, 1, 1));
|
||||
params.push_back(vec3<i32>(1_i, 1_i, 1_i));
|
||||
}
|
||||
auto* builtin = Call(name, params);
|
||||
WrapInFunction(builtin);
|
||||
@ -1055,7 +1055,7 @@ TEST_P(IntegerAllMatching, Vec4Signed) {
|
||||
|
||||
ast::ExpressionList params;
|
||||
for (uint32_t i = 0; i < num_params; ++i) {
|
||||
params.push_back(vec4<int32_t>(1, 1, 1, 1));
|
||||
params.push_back(vec4<i32>(1_i, 1_i, 1_i, 1_i));
|
||||
}
|
||||
auto* builtin = Call(name, params);
|
||||
WrapInFunction(builtin);
|
||||
|
@ -51,9 +51,6 @@ template <typename T>
|
||||
using alias2 = builder::alias2<T>;
|
||||
template <typename T>
|
||||
using alias3 = builder::alias3<T>;
|
||||
using f32 = builder::f32;
|
||||
using i32 = builder::i32;
|
||||
using u32 = builder::u32;
|
||||
|
||||
using ResolverCallTest = ResolverTest;
|
||||
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "src/tint/ast/call_statement.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -25,7 +27,7 @@ using ResolverCallValidationTest = ResolverTest;
|
||||
|
||||
TEST_F(ResolverCallValidationTest, TooFewArgs) {
|
||||
Func("foo", {Param(Sym(), ty.i32()), Param(Sym(), ty.f32())}, ty.void_(), {Return()});
|
||||
auto* call = Call(Source{{12, 34}}, "foo", 1);
|
||||
auto* call = Call(Source{{12, 34}}, "foo", 1_i);
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -34,7 +36,7 @@ TEST_F(ResolverCallValidationTest, TooFewArgs) {
|
||||
|
||||
TEST_F(ResolverCallValidationTest, TooManyArgs) {
|
||||
Func("foo", {Param(Sym(), ty.i32()), Param(Sym(), ty.f32())}, ty.void_(), {Return()});
|
||||
auto* call = Call(Source{{12, 34}}, "foo", 1, 1.0f, 1.0f);
|
||||
auto* call = Call(Source{{12, 34}}, "foo", 1_i, 1.0f, 1.0f);
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -70,14 +72,14 @@ TEST_F(ResolverCallValidationTest, UnusedRetval) {
|
||||
TEST_F(ResolverCallValidationTest, PointerArgument_VariableIdentExpr) {
|
||||
// fn foo(p: ptr<function, i32>) {}
|
||||
// fn main() {
|
||||
// var z: i32 = 1;
|
||||
// var z: i32 = 1i;
|
||||
// foo(&z);
|
||||
// }
|
||||
auto* param = Param("p", ty.pointer<i32>(ast::StorageClass::kFunction));
|
||||
Func("foo", {param}, ty.void_(), {});
|
||||
Func("main", {}, ty.void_(),
|
||||
{
|
||||
Decl(Var("z", ty.i32(), Expr(1))),
|
||||
Decl(Var("z", ty.i32(), Expr(1_i))),
|
||||
CallStmt(Call("foo", AddressOf(Source{{12, 34}}, Expr("z")))),
|
||||
});
|
||||
|
||||
@ -87,14 +89,14 @@ TEST_F(ResolverCallValidationTest, PointerArgument_VariableIdentExpr) {
|
||||
TEST_F(ResolverCallValidationTest, PointerArgument_ConstIdentExpr) {
|
||||
// fn foo(p: ptr<function, i32>) {}
|
||||
// fn main() {
|
||||
// let z: i32 = 1;
|
||||
// let z: i32 = 1i;
|
||||
// foo(&z);
|
||||
// }
|
||||
auto* param = Param("p", ty.pointer<i32>(ast::StorageClass::kFunction));
|
||||
Func("foo", {param}, ty.void_(), {});
|
||||
Func("main", {}, ty.void_(),
|
||||
{
|
||||
Decl(Let("z", ty.i32(), Expr(1))),
|
||||
Decl(Let("z", ty.i32(), Expr(1_i))),
|
||||
CallStmt(Call("foo", AddressOf(Expr(Source{{12, 34}}, "z")))),
|
||||
});
|
||||
|
||||
@ -171,7 +173,7 @@ TEST_F(ResolverCallValidationTest, PointerArgument_FunctionParamWithMain) {
|
||||
ast::StatementList{CallStmt(Call("foo", Expr("p")))});
|
||||
Func("main", ast::VariableList{}, ty.void_(),
|
||||
{
|
||||
Decl(Var("v", ty.i32(), Expr(1))),
|
||||
Decl(Var("v", ty.i32(), Expr(1_i))),
|
||||
CallStmt(Call("foo", AddressOf(Expr("v")))),
|
||||
},
|
||||
{
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/sem/storage_texture.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -26,8 +28,8 @@ using ResolverCompoundAssignmentValidationTest = ResolverTest;
|
||||
TEST_F(ResolverCompoundAssignmentValidationTest, CompatibleTypes) {
|
||||
// var a : i32 = 2;
|
||||
// a += 2
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
WrapInFunction(var, CompoundAssign(Source{{12, 34}}, "a", 2, ast::BinaryOp::kAdd));
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
||||
WrapInFunction(var, CompoundAssign(Source{{12, 34}}, "a", 2_i, ast::BinaryOp::kAdd));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
@ -37,8 +39,8 @@ TEST_F(ResolverCompoundAssignmentValidationTest, CompatibleTypesThroughAlias) {
|
||||
// var a : myint = 2;
|
||||
// a += 2
|
||||
auto* myint = Alias("myint", ty.i32());
|
||||
auto* var = Var("a", ty.Of(myint), ast::StorageClass::kNone, Expr(2));
|
||||
WrapInFunction(var, CompoundAssign(Source{{12, 34}}, "a", 2, ast::BinaryOp::kAdd));
|
||||
auto* var = Var("a", ty.Of(myint), ast::StorageClass::kNone, Expr(2_i));
|
||||
WrapInFunction(var, CompoundAssign(Source{{12, 34}}, "a", 2_i, ast::BinaryOp::kAdd));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
@ -48,10 +50,10 @@ TEST_F(ResolverCompoundAssignmentValidationTest, CompatibleTypesAssignThroughPoi
|
||||
// let b : ptr<function,i32> = &a;
|
||||
// *b += 2;
|
||||
const auto func = ast::StorageClass::kFunction;
|
||||
auto* var_a = Var("a", ty.i32(), func, Expr(2));
|
||||
auto* var_b = Let("b", ty.pointer<int>(func), AddressOf(Expr("a")));
|
||||
auto* var_a = Var("a", ty.i32(), func, Expr(2_i));
|
||||
auto* var_b = Let("b", ty.pointer<i32>(func), AddressOf(Expr("a")));
|
||||
WrapInFunction(var_a, var_b,
|
||||
CompoundAssign(Source{{12, 34}}, Deref("b"), 2, ast::BinaryOp::kAdd));
|
||||
CompoundAssign(Source{{12, 34}}, Deref("b"), 2_i, ast::BinaryOp::kAdd));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
@ -62,7 +64,7 @@ TEST_F(ResolverCompoundAssignmentValidationTest, IncompatibleTypes) {
|
||||
// a += 2.3;
|
||||
// }
|
||||
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
||||
|
||||
auto* assign = CompoundAssign(Source{{12, 34}}, "a", 2.3f, ast::BinaryOp::kAdd);
|
||||
WrapInFunction(var, assign);
|
||||
@ -217,9 +219,9 @@ TEST_F(ResolverCompoundAssignmentValidationTest, MatrixVector_Fail) {
|
||||
|
||||
TEST_F(ResolverCompoundAssignmentValidationTest, Phony) {
|
||||
// {
|
||||
// _ += 1;
|
||||
// _ += 1i;
|
||||
// }
|
||||
WrapInFunction(CompoundAssign(Source{{56, 78}}, Phony(), 1, ast::BinaryOp::kAdd));
|
||||
WrapInFunction(CompoundAssign(Source{{56, 78}}, Phony(), 1_i, ast::BinaryOp::kAdd));
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"56:78 error: compound assignment operand types are invalid: void "
|
||||
@ -229,11 +231,11 @@ TEST_F(ResolverCompoundAssignmentValidationTest, Phony) {
|
||||
TEST_F(ResolverCompoundAssignmentValidationTest, ReadOnlyBuffer) {
|
||||
// @group(0) @binding(0) var<storage,read> a : i32;
|
||||
// {
|
||||
// a += 1;
|
||||
// a += 1i;
|
||||
// }
|
||||
Global(Source{{12, 34}}, "a", ty.i32(), ast::StorageClass::kStorage, ast::Access::kRead,
|
||||
GroupAndBinding(0, 0));
|
||||
WrapInFunction(CompoundAssign(Source{{56, 78}}, "a", 1, ast::BinaryOp::kAdd));
|
||||
WrapInFunction(CompoundAssign(Source{{56, 78}}, "a", 1_i, ast::BinaryOp::kAdd));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -242,10 +244,10 @@ TEST_F(ResolverCompoundAssignmentValidationTest, ReadOnlyBuffer) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverCompoundAssignmentValidationTest, LhsConstant) {
|
||||
// let a = 1;
|
||||
// a += 1;
|
||||
auto* a = Let(Source{{12, 34}}, "a", nullptr, Expr(1));
|
||||
WrapInFunction(a, CompoundAssign(Expr(Source{{56, 78}}, "a"), 1, ast::BinaryOp::kAdd));
|
||||
// let a = 1i;
|
||||
// a += 1i;
|
||||
auto* a = Let(Source{{12, 34}}, "a", nullptr, Expr(1_i));
|
||||
WrapInFunction(a, CompoundAssign(Expr(Source{{56, 78}}, "a"), 1_i, ast::BinaryOp::kAdd));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), R"(56:78 error: cannot assign to const
|
||||
@ -253,8 +255,8 @@ TEST_F(ResolverCompoundAssignmentValidationTest, LhsConstant) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverCompoundAssignmentValidationTest, LhsLiteral) {
|
||||
// 1 += 1;
|
||||
WrapInFunction(CompoundAssign(Expr(Source{{56, 78}}, 1), 1, ast::BinaryOp::kAdd));
|
||||
// 1i += 1i;
|
||||
WrapInFunction(CompoundAssign(Expr(Source{{56, 78}}, 1_i), 1_i, ast::BinaryOp::kAdd));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "56:78 error: cannot assign to value of type 'i32'");
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include "src/tint/sem/loop_statement.h"
|
||||
#include "src/tint/sem/switch_statement.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -87,7 +89,7 @@ TEST_F(ResolverCompoundStatementTest, Loop) {
|
||||
// }
|
||||
// }
|
||||
auto* brk = Break();
|
||||
auto* stmt = Ignore(1);
|
||||
auto* stmt = Ignore(1_i);
|
||||
auto* loop = Loop(Block(brk), Block(stmt));
|
||||
auto* f = Func("F", {}, ty.void_(), {loop});
|
||||
|
||||
@ -150,7 +152,7 @@ TEST_F(ResolverCompoundStatementTest, ForLoop) {
|
||||
// }
|
||||
auto* init = Decl(Var("i", ty.u32()));
|
||||
auto* cond = Expr(true);
|
||||
auto* cont = Assign("i", Add("i", 1u));
|
||||
auto* cont = Assign("i", Add("i", 1_u));
|
||||
auto* stmt = Return();
|
||||
auto* body = Block(stmt);
|
||||
auto* for_ = For(init, cond, cont, body);
|
||||
@ -220,10 +222,10 @@ TEST_F(ResolverCompoundStatementTest, If) {
|
||||
// }
|
||||
|
||||
auto* cond_a = Expr(true);
|
||||
auto* stmt_a = Ignore(1);
|
||||
auto* stmt_a = Ignore(1_i);
|
||||
auto* cond_b = Expr(true);
|
||||
auto* stmt_b = Ignore(1);
|
||||
auto* stmt_c = Ignore(1);
|
||||
auto* stmt_b = Ignore(1_i);
|
||||
auto* stmt_c = Ignore(1_i);
|
||||
auto* if_stmt = If(cond_a, Block(stmt_a), Else(If(cond_b, Block(stmt_b), Else(Block(stmt_c)))));
|
||||
WrapInFunction(if_stmt);
|
||||
|
||||
@ -293,10 +295,10 @@ TEST_F(ResolverCompoundStatementTest, If) {
|
||||
TEST_F(ResolverCompoundStatementTest, Switch) {
|
||||
// fn F() {
|
||||
// switch (expr) {
|
||||
// case 1: {
|
||||
// case 1i: {
|
||||
// stmt_a;
|
||||
// }
|
||||
// case 2: {
|
||||
// case 2i: {
|
||||
// stmt_b;
|
||||
// }
|
||||
// default: {
|
||||
@ -305,11 +307,11 @@ TEST_F(ResolverCompoundStatementTest, Switch) {
|
||||
// }
|
||||
// }
|
||||
|
||||
auto* expr = Expr(5);
|
||||
auto* stmt_a = Ignore(1);
|
||||
auto* stmt_b = Ignore(1);
|
||||
auto* stmt_c = Ignore(1);
|
||||
auto* swi = Switch(expr, Case(Expr(1), Block(stmt_a)), Case(Expr(2), Block(stmt_b)),
|
||||
auto* expr = Expr(5_i);
|
||||
auto* stmt_a = Ignore(1_i);
|
||||
auto* stmt_b = Ignore(1_i);
|
||||
auto* stmt_c = Ignore(1_i);
|
||||
auto* swi = Switch(expr, Case(Expr(1_i), Block(stmt_a)), Case(Expr(2_i), Block(stmt_b)),
|
||||
DefaultCase(Block(stmt_c)));
|
||||
WrapInFunction(swi);
|
||||
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "src/tint/ast/switch_statement.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -46,11 +48,11 @@ TEST_F(ResolverControlBlockValidationTest, SwitchWithoutDefault_Fail) {
|
||||
// switch (a) {
|
||||
// case 1: {}
|
||||
// }
|
||||
auto* var = Var("a", ty.i32(), Expr(2));
|
||||
auto* var = Var("a", ty.i32(), Expr(2_i));
|
||||
|
||||
auto* block = Block(Decl(var), //
|
||||
Switch(Source{{12, 34}}, "a", //
|
||||
Case(Expr(1))));
|
||||
Case(Expr(1_i))));
|
||||
|
||||
WrapInFunction(block);
|
||||
|
||||
@ -65,12 +67,12 @@ TEST_F(ResolverControlBlockValidationTest, SwitchWithTwoDefault_Fail) {
|
||||
// case 1: {}
|
||||
// default: {}
|
||||
// }
|
||||
auto* var = Var("a", ty.i32(), Expr(2));
|
||||
auto* var = Var("a", ty.i32(), Expr(2_i));
|
||||
|
||||
auto* block = Block(Decl(var), //
|
||||
Switch("a", //
|
||||
DefaultCase(), //
|
||||
Case(Expr(1)), //
|
||||
auto* block = Block(Decl(var), //
|
||||
Switch("a", //
|
||||
DefaultCase(), //
|
||||
Case(Expr(1_i)), //
|
||||
DefaultCase(Source{{12, 34}})));
|
||||
|
||||
WrapInFunction(block);
|
||||
@ -88,7 +90,7 @@ TEST_F(ResolverControlBlockValidationTest, UnreachableCode_Loop_continue) {
|
||||
// }
|
||||
auto* decl_z = Decl(Var("z", ty.i32()));
|
||||
auto* cont = Continue();
|
||||
auto* assign_z = Assign(Source{{12, 34}}, "z", 1);
|
||||
auto* assign_z = Assign(Source{{12, 34}}, "z", 1_i);
|
||||
WrapInFunction(Loop(Block(If(false, Block(Break())), decl_z, cont, assign_z)));
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -107,7 +109,7 @@ TEST_F(ResolverControlBlockValidationTest, UnreachableCode_Loop_continue_InBlock
|
||||
// }
|
||||
auto* decl_z = Decl(Var("z", ty.i32()));
|
||||
auto* cont = Continue();
|
||||
auto* assign_z = Assign(Source{{12, 34}}, "z", 1);
|
||||
auto* assign_z = Assign(Source{{12, 34}}, "z", 1_i);
|
||||
WrapInFunction(
|
||||
Loop(Block(If(false, Block(Break())), decl_z, Block(Block(Block(cont))), assign_z)));
|
||||
|
||||
@ -126,7 +128,7 @@ TEST_F(ResolverControlBlockValidationTest, UnreachableCode_ForLoop_continue) {
|
||||
// }
|
||||
auto* decl_z = Decl(Var("z", ty.i32()));
|
||||
auto* cont = Continue();
|
||||
auto* assign_z = Assign(Source{{12, 34}}, "z", 1);
|
||||
auto* assign_z = Assign(Source{{12, 34}}, "z", 1_i);
|
||||
WrapInFunction(For(nullptr, false, nullptr, //
|
||||
Block(decl_z, cont, assign_z)));
|
||||
|
||||
@ -145,7 +147,7 @@ TEST_F(ResolverControlBlockValidationTest, UnreachableCode_ForLoop_continue_InBl
|
||||
// }
|
||||
auto* decl_z = Decl(Var("z", ty.i32()));
|
||||
auto* cont = Continue();
|
||||
auto* assign_z = Assign(Source{{12, 34}}, "z", 1);
|
||||
auto* assign_z = Assign(Source{{12, 34}}, "z", 1_i);
|
||||
WrapInFunction(
|
||||
For(nullptr, false, nullptr, Block(decl_z, Block(Block(Block(cont))), assign_z)));
|
||||
|
||||
@ -157,19 +159,19 @@ TEST_F(ResolverControlBlockValidationTest, UnreachableCode_ForLoop_continue_InBl
|
||||
}
|
||||
|
||||
TEST_F(ResolverControlBlockValidationTest, UnreachableCode_break) {
|
||||
// switch (1) {
|
||||
// case 1: {
|
||||
// switch (1i) {
|
||||
// case 1i: {
|
||||
// var z: i32;
|
||||
// break;
|
||||
// z = 1;
|
||||
// z = 1i;
|
||||
// default: {}
|
||||
// }
|
||||
auto* decl_z = Decl(Var("z", ty.i32()));
|
||||
auto* brk = Break();
|
||||
auto* assign_z = Assign(Source{{12, 34}}, "z", 1);
|
||||
WrapInFunction( //
|
||||
Block(Switch(1, //
|
||||
Case(Expr(1), Block(decl_z, brk, assign_z)), //
|
||||
auto* assign_z = Assign(Source{{12, 34}}, "z", 1_i);
|
||||
WrapInFunction( //
|
||||
Block(Switch(1_i, //
|
||||
Case(Expr(1_i), Block(decl_z, brk, assign_z)), //
|
||||
DefaultCase())));
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -181,18 +183,18 @@ TEST_F(ResolverControlBlockValidationTest, UnreachableCode_break) {
|
||||
|
||||
TEST_F(ResolverControlBlockValidationTest, UnreachableCode_break_InBlocks) {
|
||||
// loop {
|
||||
// switch (1) {
|
||||
// case 1: { {{{break;}}} var a : u32 = 2;}
|
||||
// switch (1i) {
|
||||
// case 1i: { {{{break;}}} var a : u32 = 2;}
|
||||
// default: {}
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
auto* decl_z = Decl(Var("z", ty.i32()));
|
||||
auto* brk = Break();
|
||||
auto* assign_z = Assign(Source{{12, 34}}, "z", 1);
|
||||
auto* assign_z = Assign(Source{{12, 34}}, "z", 1_i);
|
||||
WrapInFunction(
|
||||
Loop(Block(Switch(1, //
|
||||
Case(Expr(1), Block(decl_z, Block(Block(Block(brk))), assign_z)),
|
||||
Loop(Block(Switch(1_i, //
|
||||
Case(Expr(1_i), Block(decl_z, Block(Block(Block(brk))), assign_z)),
|
||||
DefaultCase()), //
|
||||
Break())));
|
||||
|
||||
@ -206,13 +208,13 @@ TEST_F(ResolverControlBlockValidationTest, UnreachableCode_break_InBlocks) {
|
||||
TEST_F(ResolverControlBlockValidationTest, SwitchConditionTypeMustMatchSelectorType2_Fail) {
|
||||
// var a : u32 = 2;
|
||||
// switch (a) {
|
||||
// case 1: {}
|
||||
// case 1i: {}
|
||||
// default: {}
|
||||
// }
|
||||
auto* var = Var("a", ty.i32(), Expr(2));
|
||||
auto* var = Var("a", ty.i32(), Expr(2_i));
|
||||
|
||||
auto* block = Block(Decl(var), Switch("a", //
|
||||
Case(Source{{12, 34}}, {Expr(1u)}), //
|
||||
auto* block = Block(Decl(var), Switch("a", //
|
||||
Case(Source{{12, 34}}, {Expr(1_u)}), //
|
||||
DefaultCase()));
|
||||
WrapInFunction(block);
|
||||
|
||||
@ -225,14 +227,14 @@ TEST_F(ResolverControlBlockValidationTest, SwitchConditionTypeMustMatchSelectorT
|
||||
TEST_F(ResolverControlBlockValidationTest, SwitchConditionTypeMustMatchSelectorType_Fail) {
|
||||
// var a : u32 = 2;
|
||||
// switch (a) {
|
||||
// case -1: {}
|
||||
// case -1i: {}
|
||||
// default: {}
|
||||
// }
|
||||
auto* var = Var("a", ty.u32(), Expr(2u));
|
||||
auto* var = Var("a", ty.u32(), Expr(2_u));
|
||||
|
||||
auto* block = Block(Decl(var), //
|
||||
Switch("a", //
|
||||
Case(Source{{12, 34}}, {Expr(-1)}), //
|
||||
auto* block = Block(Decl(var), //
|
||||
Switch("a", //
|
||||
Case(Source{{12, 34}}, {Expr(i32(-1))}), //
|
||||
DefaultCase()));
|
||||
WrapInFunction(block);
|
||||
|
||||
@ -249,15 +251,15 @@ TEST_F(ResolverControlBlockValidationTest, NonUniqueCaseSelectorValueUint_Fail)
|
||||
// case 2u, 3u, 2u: {}
|
||||
// default: {}
|
||||
// }
|
||||
auto* var = Var("a", ty.u32(), Expr(3u));
|
||||
auto* var = Var("a", ty.u32(), Expr(3_u));
|
||||
|
||||
auto* block = Block(Decl(var), //
|
||||
Switch("a", //
|
||||
Case(Expr(0u)),
|
||||
Case(Expr(0_u)),
|
||||
Case({
|
||||
Expr(Source{{12, 34}}, 2u),
|
||||
Expr(3u),
|
||||
Expr(Source{{56, 78}}, 2u),
|
||||
Expr(Source{{12, 34}}, 2_u),
|
||||
Expr(3_u),
|
||||
Expr(Source{{56, 78}}, 2_u),
|
||||
}),
|
||||
DefaultCase()));
|
||||
WrapInFunction(block);
|
||||
@ -275,16 +277,16 @@ TEST_F(ResolverControlBlockValidationTest, NonUniqueCaseSelectorValueSint_Fail)
|
||||
// case 0,1,2,-10: {}
|
||||
// default: {}
|
||||
// }
|
||||
auto* var = Var("a", ty.i32(), Expr(2));
|
||||
auto* var = Var("a", ty.i32(), Expr(2_i));
|
||||
|
||||
auto* block = Block(Decl(var), //
|
||||
Switch("a", //
|
||||
Case(Expr(Source{{12, 34}}, -10)),
|
||||
Case(Expr(Source{{12, 34}}, i32(-10))),
|
||||
Case({
|
||||
Expr(0),
|
||||
Expr(1),
|
||||
Expr(2),
|
||||
Expr(Source{{56, 78}}, -10),
|
||||
Expr(0_i),
|
||||
Expr(1_i),
|
||||
Expr(2_i),
|
||||
Expr(Source{{56, 78}}, i32(-10)),
|
||||
}),
|
||||
DefaultCase()));
|
||||
WrapInFunction(block);
|
||||
@ -300,7 +302,7 @@ TEST_F(ResolverControlBlockValidationTest, LastClauseLastStatementIsFallthrough_
|
||||
// switch (a) {
|
||||
// default: { fallthrough; }
|
||||
// }
|
||||
auto* var = Var("a", ty.i32(), Expr(2));
|
||||
auto* var = Var("a", ty.i32(), Expr(2_i));
|
||||
auto* fallthrough = create<ast::FallthroughStatement>(Source{{12, 34}});
|
||||
auto* block = Block(Decl(var), //
|
||||
Switch("a", //
|
||||
@ -319,12 +321,12 @@ TEST_F(ResolverControlBlockValidationTest, SwitchCase_Pass) {
|
||||
// default: {}
|
||||
// case 5: {}
|
||||
// }
|
||||
auto* var = Var("a", ty.i32(), Expr(2));
|
||||
auto* var = Var("a", ty.i32(), Expr(2_i));
|
||||
|
||||
auto* block = Block(Decl(var), //
|
||||
Switch("a", //
|
||||
DefaultCase(Source{{12, 34}}), //
|
||||
Case(Expr(5))));
|
||||
Case(Expr(5_i))));
|
||||
WrapInFunction(block);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -338,7 +340,7 @@ TEST_F(ResolverControlBlockValidationTest, SwitchCaseAlias_Pass) {
|
||||
// }
|
||||
|
||||
auto* my_int = Alias("MyInt", ty.u32());
|
||||
auto* var = Var("a", ty.Of(my_int), Expr(2u));
|
||||
auto* var = Var("a", ty.Of(my_int), Expr(2_u));
|
||||
auto* block = Block(Decl(var), //
|
||||
Switch("a", DefaultCase(Source{{12, 34}})));
|
||||
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "src/tint/resolver/dependency_graph.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -425,7 +427,7 @@ const ast::Node* SymbolTestHelper::Add(SymbolDeclKind kind, Symbol symbol, Sourc
|
||||
case SymbolDeclKind::GlobalVar:
|
||||
return b.Global(source, symbol, b.ty.i32(), ast::StorageClass::kPrivate);
|
||||
case SymbolDeclKind::GlobalConst:
|
||||
return b.GlobalConst(source, symbol, b.ty.i32(), b.Expr(1));
|
||||
return b.GlobalConst(source, symbol, b.ty.i32(), b.Expr(1_i));
|
||||
case SymbolDeclKind::Alias:
|
||||
return b.Alias(source, symbol, b.ty.i32());
|
||||
case SymbolDeclKind::Struct:
|
||||
@ -443,7 +445,7 @@ const ast::Node* SymbolTestHelper::Add(SymbolDeclKind kind, Symbol symbol, Sourc
|
||||
return node;
|
||||
}
|
||||
case SymbolDeclKind::LocalLet: {
|
||||
auto* node = b.Let(source, symbol, b.ty.i32(), b.Expr(1));
|
||||
auto* node = b.Let(source, symbol, b.ty.i32(), b.Expr(1_i));
|
||||
statements.emplace_back(b.Decl(node));
|
||||
return node;
|
||||
}
|
||||
@ -453,7 +455,7 @@ const ast::Node* SymbolTestHelper::Add(SymbolDeclKind kind, Symbol symbol, Sourc
|
||||
return node;
|
||||
}
|
||||
case SymbolDeclKind::NestedLocalLet: {
|
||||
auto* node = b.Let(source, symbol, b.ty.i32(), b.Expr(1));
|
||||
auto* node = b.Let(source, symbol, b.ty.i32(), b.Expr(1_i));
|
||||
nested_statements.emplace_back(b.Decl(node));
|
||||
return node;
|
||||
}
|
||||
@ -471,7 +473,7 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
|
||||
}
|
||||
case SymbolUseKind::GlobalVarArrayElemType: {
|
||||
auto* node = b.ty.type_name(source, symbol);
|
||||
b.Global(b.Sym(), b.ty.array(node, 4), ast::StorageClass::kPrivate);
|
||||
b.Global(b.Sym(), b.ty.array(node, 4_i), ast::StorageClass::kPrivate);
|
||||
return node;
|
||||
}
|
||||
case SymbolUseKind::GlobalVarArraySizeValue: {
|
||||
@ -506,27 +508,27 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
|
||||
}
|
||||
case SymbolUseKind::GlobalLetType: {
|
||||
auto* node = b.ty.type_name(source, symbol);
|
||||
b.GlobalConst(b.Sym(), node, b.Expr(1));
|
||||
b.GlobalConst(b.Sym(), node, b.Expr(1_i));
|
||||
return node;
|
||||
}
|
||||
case SymbolUseKind::GlobalLetArrayElemType: {
|
||||
auto* node = b.ty.type_name(source, symbol);
|
||||
b.GlobalConst(b.Sym(), b.ty.array(node, 4), b.Expr(1));
|
||||
b.GlobalConst(b.Sym(), b.ty.array(node, 4_i), b.Expr(1_i));
|
||||
return node;
|
||||
}
|
||||
case SymbolUseKind::GlobalLetArraySizeValue: {
|
||||
auto* node = b.Expr(source, symbol);
|
||||
b.GlobalConst(b.Sym(), b.ty.array(b.ty.i32(), node), b.Expr(1));
|
||||
b.GlobalConst(b.Sym(), b.ty.array(b.ty.i32(), node), b.Expr(1_i));
|
||||
return node;
|
||||
}
|
||||
case SymbolUseKind::GlobalLetVectorElemType: {
|
||||
auto* node = b.ty.type_name(source, symbol);
|
||||
b.GlobalConst(b.Sym(), b.ty.vec3(node), b.Expr(1));
|
||||
b.GlobalConst(b.Sym(), b.ty.vec3(node), b.Expr(1_i));
|
||||
return node;
|
||||
}
|
||||
case SymbolUseKind::GlobalLetMatrixElemType: {
|
||||
auto* node = b.ty.type_name(source, symbol);
|
||||
b.GlobalConst(b.Sym(), b.ty.mat3x4(node), b.Expr(1));
|
||||
b.GlobalConst(b.Sym(), b.ty.mat3x4(node), b.Expr(1_i));
|
||||
return node;
|
||||
}
|
||||
case SymbolUseKind::GlobalLetValue: {
|
||||
@ -561,13 +563,13 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
|
||||
}
|
||||
case SymbolUseKind::LocalVarArrayElemType: {
|
||||
auto* node = b.ty.type_name(source, symbol);
|
||||
statements.emplace_back(b.Decl(b.Var(b.Sym(), b.ty.array(node, 4), b.Expr(1))));
|
||||
statements.emplace_back(b.Decl(b.Var(b.Sym(), b.ty.array(node, 4_u), b.Expr(1_i))));
|
||||
return node;
|
||||
}
|
||||
case SymbolUseKind::LocalVarArraySizeValue: {
|
||||
auto* node = b.Expr(source, symbol);
|
||||
statements.emplace_back(
|
||||
b.Decl(b.Var(b.Sym(), b.ty.array(b.ty.i32(), node), b.Expr(1))));
|
||||
b.Decl(b.Var(b.Sym(), b.ty.array(b.ty.i32(), node), b.Expr(1_i))));
|
||||
return node;
|
||||
}
|
||||
case SymbolUseKind::LocalVarVectorElemType: {
|
||||
@ -587,7 +589,7 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
|
||||
}
|
||||
case SymbolUseKind::LocalLetType: {
|
||||
auto* node = b.ty.type_name(source, symbol);
|
||||
statements.emplace_back(b.Decl(b.Let(b.Sym(), node, b.Expr(1))));
|
||||
statements.emplace_back(b.Decl(b.Let(b.Sym(), node, b.Expr(1_i))));
|
||||
return node;
|
||||
}
|
||||
case SymbolUseKind::LocalLetValue: {
|
||||
@ -607,7 +609,7 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
|
||||
}
|
||||
case SymbolUseKind::NestedLocalLetType: {
|
||||
auto* node = b.ty.type_name(source, symbol);
|
||||
nested_statements.emplace_back(b.Decl(b.Let(b.Sym(), node, b.Expr(1))));
|
||||
nested_statements.emplace_back(b.Decl(b.Let(b.Sym(), node, b.Expr(1_i))));
|
||||
return node;
|
||||
}
|
||||
case SymbolUseKind::NestedLocalLetValue: {
|
||||
@ -617,7 +619,7 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
|
||||
}
|
||||
case SymbolUseKind::WorkgroupSizeValue: {
|
||||
auto* node = b.Expr(source, symbol);
|
||||
func_attrs.emplace_back(b.WorkgroupSize(1, node, 2));
|
||||
func_attrs.emplace_back(b.WorkgroupSize(1_i, node, 2_i));
|
||||
return node;
|
||||
}
|
||||
}
|
||||
@ -767,27 +769,27 @@ using ResolverDependencyGraphDeclSelfUse = ResolverDependencyGraphTest;
|
||||
|
||||
TEST_F(ResolverDependencyGraphDeclSelfUse, GlobalVar) {
|
||||
const Symbol symbol = Sym("SYMBOL");
|
||||
Global(symbol, ty.i32(), Mul(Expr(Source{{12, 34}}, symbol), 123));
|
||||
Global(symbol, ty.i32(), Mul(Expr(Source{{12, 34}}, symbol), 123_i));
|
||||
Build(R"(error: cyclic dependency found: 'SYMBOL' -> 'SYMBOL'
|
||||
12:34 note: var 'SYMBOL' references var 'SYMBOL' here)");
|
||||
}
|
||||
|
||||
TEST_F(ResolverDependencyGraphDeclSelfUse, GlobalConst) {
|
||||
const Symbol symbol = Sym("SYMBOL");
|
||||
GlobalConst(symbol, ty.i32(), Mul(Expr(Source{{12, 34}}, symbol), 123));
|
||||
GlobalConst(symbol, ty.i32(), Mul(Expr(Source{{12, 34}}, symbol), 123_i));
|
||||
Build(R"(error: cyclic dependency found: 'SYMBOL' -> 'SYMBOL'
|
||||
12:34 note: let 'SYMBOL' references let 'SYMBOL' here)");
|
||||
}
|
||||
|
||||
TEST_F(ResolverDependencyGraphDeclSelfUse, LocalVar) {
|
||||
const Symbol symbol = Sym("SYMBOL");
|
||||
WrapInFunction(Decl(Var(symbol, ty.i32(), Mul(Expr(Source{{12, 34}}, symbol), 123))));
|
||||
WrapInFunction(Decl(Var(symbol, ty.i32(), Mul(Expr(Source{{12, 34}}, symbol), 123_i))));
|
||||
Build("12:34 error: unknown identifier: 'SYMBOL'");
|
||||
}
|
||||
|
||||
TEST_F(ResolverDependencyGraphDeclSelfUse, LocalLet) {
|
||||
const Symbol symbol = Sym("SYMBOL");
|
||||
WrapInFunction(Decl(Let(symbol, ty.i32(), Mul(Expr(Source{{12, 34}}, symbol), 123))));
|
||||
WrapInFunction(Decl(Let(symbol, ty.i32(), Mul(Expr(Source{{12, 34}}, symbol), 123_i))));
|
||||
Build("12:34 error: unknown identifier: 'SYMBOL'");
|
||||
}
|
||||
|
||||
@ -1229,9 +1231,9 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) {
|
||||
Loop(Block(Assign(V, V)), //
|
||||
Block(Assign(V, V))), //
|
||||
Switch(V, //
|
||||
Case(Expr(1), //
|
||||
Case(Expr(1_i), //
|
||||
Block(Assign(V, V))), //
|
||||
Case(Expr(2), //
|
||||
Case(Expr(2_i), //
|
||||
Block(Fallthrough())), //
|
||||
DefaultCase(Block(Assign(V, V)))), //
|
||||
Return(V), //
|
||||
@ -1270,10 +1272,10 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) {
|
||||
|
||||
TEST_F(ResolverDependencyGraphTraversalTest, InferredType) {
|
||||
// Check that the nullptr of the var / let type doesn't make things explode
|
||||
Global("a", nullptr, Expr(1));
|
||||
GlobalConst("b", nullptr, Expr(1));
|
||||
WrapInFunction(Var("c", nullptr, Expr(1)), //
|
||||
Let("d", nullptr, Expr(1)));
|
||||
Global("a", nullptr, Expr(1_i));
|
||||
GlobalConst("b", nullptr, Expr(1_i));
|
||||
WrapInFunction(Var("c", nullptr, Expr(1_i)), //
|
||||
Let("d", nullptr, Expr(1_i)));
|
||||
Build();
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -41,9 +43,6 @@ template <typename T>
|
||||
using mat4x4 = builder::mat4x4<T>;
|
||||
template <typename T>
|
||||
using alias = builder::alias<T>;
|
||||
using f32 = builder::f32;
|
||||
using i32 = builder::i32;
|
||||
using u32 = builder::u32;
|
||||
|
||||
class ResolverEntryPointValidationTest : public TestHelper, public testing::Test {};
|
||||
|
||||
@ -648,9 +647,9 @@ TEST_F(LocationAttributeTests, ReturnType_Struct_RuntimeArray) {
|
||||
}
|
||||
|
||||
TEST_F(LocationAttributeTests, ComputeShaderLocation_Input) {
|
||||
Func("main", {}, ty.i32(), {Return(Expr(1))},
|
||||
Func("main", {}, ty.i32(), {Return(Expr(1_i))},
|
||||
{Stage(ast::PipelineStage::kCompute),
|
||||
create<ast::WorkgroupAttribute>(Source{{12, 34}}, Expr(1))},
|
||||
create<ast::WorkgroupAttribute>(Source{{12, 34}}, Expr(1_i))},
|
||||
ast::AttributeList{Location(Source{{12, 34}}, 1)});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -661,7 +660,7 @@ TEST_F(LocationAttributeTests, ComputeShaderLocation_Output) {
|
||||
auto* input = Param("input", ty.i32(), ast::AttributeList{Location(Source{{12, 34}}, 0u)});
|
||||
Func("main", {input}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute),
|
||||
create<ast::WorkgroupAttribute>(Source{{12, 34}}, Expr(1))});
|
||||
create<ast::WorkgroupAttribute>(Source{{12, 34}}, Expr(1_i))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: attribute is not valid for compute shader inputs");
|
||||
@ -673,7 +672,7 @@ TEST_F(LocationAttributeTests, ComputeShaderLocationStructMember_Output) {
|
||||
Func(Source{{56, 78}}, "main", {}, ty.Of(s),
|
||||
ast::StatementList{Return(Expr(Construct(ty.Of(s))))},
|
||||
{Stage(ast::PipelineStage::kCompute),
|
||||
create<ast::WorkgroupAttribute>(Source{{12, 34}}, Expr(1))});
|
||||
create<ast::WorkgroupAttribute>(Source{{12, 34}}, Expr(1_i))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -687,7 +686,7 @@ TEST_F(LocationAttributeTests, ComputeShaderLocationStructMember_Input) {
|
||||
auto* input = Param("input", ty.Of(s));
|
||||
Func(Source{{56, 78}}, "main", {input}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute),
|
||||
create<ast::WorkgroupAttribute>(Source{{12, 34}}, Expr(1))});
|
||||
create<ast::WorkgroupAttribute>(Source{{12, 34}}, Expr(1_i))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -45,10 +47,10 @@ TEST_F(ResolverFunctionValidationTest, ParameterMayShadowGlobal) {
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, LocalConflictsWithParameter) {
|
||||
// fn func(common_name : f32) {
|
||||
// let common_name = 1;
|
||||
// let common_name = 1i;
|
||||
// }
|
||||
Func("func", {Param(Source{{12, 34}}, "common_name", ty.f32())}, ty.void_(),
|
||||
{Decl(Let(Source{{56, 78}}, "common_name", nullptr, Expr(1)))});
|
||||
{Decl(Let(Source{{56, 78}}, "common_name", nullptr, Expr(1_i)))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), R"(56:78 error: redeclaration of 'common_name'
|
||||
@ -58,18 +60,18 @@ TEST_F(ResolverFunctionValidationTest, LocalConflictsWithParameter) {
|
||||
TEST_F(ResolverFunctionValidationTest, NestedLocalMayShadowParameter) {
|
||||
// fn func(common_name : f32) {
|
||||
// {
|
||||
// let common_name = 1;
|
||||
// let common_name = 1i;
|
||||
// }
|
||||
// }
|
||||
Func("func", {Param(Source{{12, 34}}, "common_name", ty.f32())}, ty.void_(),
|
||||
{Block(Decl(Let(Source{{56, 78}}, "common_name", nullptr, Expr(1))))});
|
||||
{Block(Decl(Let(Source{{56, 78}}, "common_name", nullptr, Expr(1_i))))});
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, VoidFunctionEndWithoutReturnStatement_Pass) {
|
||||
// fn func { var a:i32 = 2; }
|
||||
auto* var = Var("a", ty.i32(), Expr(2));
|
||||
// fn func { var a:i32 = 2i; }
|
||||
auto* var = Var("a", ty.i32(), Expr(2_i));
|
||||
|
||||
Func(Source{{12, 34}}, "func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
@ -81,11 +83,11 @@ TEST_F(ResolverFunctionValidationTest, VoidFunctionEndWithoutReturnStatement_Pas
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, FunctionUsingSameVariableName_Pass) {
|
||||
// fn func() -> i32 {
|
||||
// var func:i32 = 0;
|
||||
// var func:i32 = 0i;
|
||||
// return func;
|
||||
// }
|
||||
|
||||
auto* var = Var("func", ty.i32(), Expr(0));
|
||||
auto* var = Var("func", ty.i32(), Expr(0_i));
|
||||
Func("func", ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{
|
||||
Decl(var),
|
||||
@ -97,10 +99,10 @@ TEST_F(ResolverFunctionValidationTest, FunctionUsingSameVariableName_Pass) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, FunctionNameSameAsFunctionScopeVariableName_Pass) {
|
||||
// fn a() -> void { var b:i32 = 0; }
|
||||
// fn a() -> void { var b:i32 = 0i; }
|
||||
// fn b() -> i32 { return 2; }
|
||||
|
||||
auto* var = Var("b", ty.i32(), Expr(0));
|
||||
auto* var = Var("b", ty.i32(), Expr(0_i));
|
||||
Func("a", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
Decl(var),
|
||||
@ -109,7 +111,7 @@ TEST_F(ResolverFunctionValidationTest, FunctionNameSameAsFunctionScopeVariableNa
|
||||
|
||||
Func(Source{{12, 34}}, "b", ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{
|
||||
Return(2),
|
||||
Return(2_i),
|
||||
},
|
||||
ast::AttributeList{});
|
||||
|
||||
@ -120,12 +122,12 @@ TEST_F(ResolverFunctionValidationTest, UnreachableCode_return) {
|
||||
// fn func() -> {
|
||||
// var a : i32;
|
||||
// return;
|
||||
// a = 2;
|
||||
// a = 2i;
|
||||
//}
|
||||
|
||||
auto* decl_a = Decl(Var("a", ty.i32()));
|
||||
auto* ret = Return();
|
||||
auto* assign_a = Assign(Source{{12, 34}}, "a", 2);
|
||||
auto* assign_a = Assign(Source{{12, 34}}, "a", 2_i);
|
||||
|
||||
Func("func", ast::VariableList{}, ty.void_(), {decl_a, ret, assign_a});
|
||||
|
||||
@ -141,12 +143,12 @@ TEST_F(ResolverFunctionValidationTest, UnreachableCode_return_InBlocks) {
|
||||
// fn func() -> {
|
||||
// var a : i32;
|
||||
// {{{return;}}}
|
||||
// a = 2;
|
||||
// a = 2i;
|
||||
//}
|
||||
|
||||
auto* decl_a = Decl(Var("a", ty.i32()));
|
||||
auto* ret = Return();
|
||||
auto* assign_a = Assign(Source{{12, 34}}, "a", 2);
|
||||
auto* assign_a = Assign(Source{{12, 34}}, "a", 2_i);
|
||||
|
||||
Func("func", ast::VariableList{}, ty.void_(), {decl_a, Block(Block(Block(ret))), assign_a});
|
||||
|
||||
@ -161,12 +163,12 @@ TEST_F(ResolverFunctionValidationTest, UnreachableCode_discard) {
|
||||
// fn func() -> {
|
||||
// var a : i32;
|
||||
// discard;
|
||||
// a = 2;
|
||||
// a = 2i;
|
||||
//}
|
||||
|
||||
auto* decl_a = Decl(Var("a", ty.i32()));
|
||||
auto* discard = Discard();
|
||||
auto* assign_a = Assign(Source{{12, 34}}, "a", 2);
|
||||
auto* assign_a = Assign(Source{{12, 34}}, "a", 2_i);
|
||||
|
||||
Func("func", ast::VariableList{}, ty.void_(), {decl_a, discard, assign_a});
|
||||
|
||||
@ -181,12 +183,12 @@ TEST_F(ResolverFunctionValidationTest, UnreachableCode_discard_InBlocks) {
|
||||
// fn func() -> {
|
||||
// var a : i32;
|
||||
// {{{discard;}}}
|
||||
// a = 2;
|
||||
// a = 2i;
|
||||
//}
|
||||
|
||||
auto* decl_a = Decl(Var("a", ty.i32()));
|
||||
auto* discard = Discard();
|
||||
auto* assign_a = Assign(Source{{12, 34}}, "a", 2);
|
||||
auto* assign_a = Assign(Source{{12, 34}}, "a", 2_i);
|
||||
|
||||
Func("func", ast::VariableList{}, ty.void_(), {decl_a, Block(Block(Block(discard))), assign_a});
|
||||
|
||||
@ -198,9 +200,9 @@ TEST_F(ResolverFunctionValidationTest, UnreachableCode_discard_InBlocks) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, FunctionEndWithoutReturnStatement_Fail) {
|
||||
// fn func() -> int { var a:i32 = 2; }
|
||||
// fn func() -> int { var a:i32 = 2i; }
|
||||
|
||||
auto* var = Var("a", ty.i32(), Expr(2));
|
||||
auto* var = Var("a", ty.i32(), Expr(2_i));
|
||||
|
||||
Func(Source{{12, 34}}, "func", ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{
|
||||
@ -242,10 +244,10 @@ TEST_F(ResolverFunctionValidationTest, FunctionTypeMustMatchReturnStatementType_
|
||||
}
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, FunctionTypeMustMatchReturnStatementType_fail) {
|
||||
// fn func { return 2; }
|
||||
// fn func { return 2i; }
|
||||
Func("func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
Return(Source{{12, 34}}, Expr(2)),
|
||||
Return(Source{{12, 34}}, Expr(2_i)),
|
||||
},
|
||||
ast::AttributeList{});
|
||||
|
||||
@ -294,10 +296,10 @@ TEST_F(ResolverFunctionValidationTest, FunctionTypeMustMatchReturnStatementTypeF
|
||||
}
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) {
|
||||
// fn func() -> f32 { return 2; }
|
||||
// fn func() -> f32 { return 2i; }
|
||||
Func("func", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
Return(Source{{12, 34}}, Expr(2)),
|
||||
Return(Source{{12, 34}}, Expr(2_i)),
|
||||
},
|
||||
ast::AttributeList{});
|
||||
|
||||
@ -322,11 +324,11 @@ TEST_F(ResolverFunctionValidationTest, FunctionTypeMustMatchReturnStatementTypeF
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, FunctionTypeMustMatchReturnStatementTypeF32Alias_fail) {
|
||||
// type myf32 = f32;
|
||||
// fn func() -> myf32 { return 2; }
|
||||
// fn func() -> myf32 { return 2u; }
|
||||
auto* myf32 = Alias("myf32", ty.f32());
|
||||
Func("func", ast::VariableList{}, ty.Of(myf32),
|
||||
ast::StatementList{
|
||||
Return(Source{{12, 34}}, Expr(2u)),
|
||||
Return(Source{{12, 34}}, Expr(2_u)),
|
||||
},
|
||||
ast::AttributeList{});
|
||||
|
||||
@ -340,7 +342,7 @@ TEST_F(ResolverFunctionValidationTest, CannotCallEntryPoint) {
|
||||
// @stage(compute) @workgroup_size(1) fn entrypoint() {}
|
||||
// fn func() { return entrypoint(); }
|
||||
Func("entrypoint", ast::VariableList{}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
Func("func", ast::VariableList{}, ty.void_(),
|
||||
{
|
||||
@ -412,7 +414,7 @@ TEST_F(ResolverFunctionValidationTest, FunctionConstInitWithParam) {
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, FunctionParamsConst) {
|
||||
Func("foo", {Param(Sym("arg"), ty.i32())}, ty.void_(),
|
||||
{Assign(Expr(Source{{12, 34}}, "arg"), Expr(1)), Return()});
|
||||
{Assign(Expr(Source{{12, 34}}, "arg"), Expr(1_i)), Return()});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -425,11 +427,11 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_GoodType_ConstU32) {
|
||||
// let x = 8u;
|
||||
// @stage(compute) @workgroup_size(x, y, 16u)
|
||||
// fn main() {}
|
||||
auto* x = GlobalConst("x", ty.u32(), Expr(4u));
|
||||
auto* y = GlobalConst("y", ty.u32(), Expr(8u));
|
||||
auto* func =
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr("x"), Expr("y"), Expr(16u))});
|
||||
auto* x = GlobalConst("x", ty.u32(), Expr(4_u));
|
||||
auto* y = GlobalConst("y", ty.u32(), Expr(8_u));
|
||||
auto* func = Func(
|
||||
"main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr("x"), Expr("y"), Expr(16_u))});
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
||||
@ -451,18 +453,18 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_GoodType_U32) {
|
||||
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(Source{{12, 34}}, Expr(1u), Expr(2u), Expr(3u))});
|
||||
WorkgroupSize(Source{{12, 34}}, Expr(1_u), Expr(2_u), Expr(3_u))});
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_MismatchTypeU32) {
|
||||
// @stage(compute) @workgroup_size(1u, 2u, 3)
|
||||
// @stage(compute) @workgroup_size(1u, 2u, 3_i)
|
||||
// fn main() {}
|
||||
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(Expr(1u), Expr(2u), Expr(Source{{12, 34}}, 3))});
|
||||
WorkgroupSize(Expr(1_u), Expr(2_u), Expr(Source{{12, 34}}, 3_i))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -471,12 +473,12 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_MismatchTypeU32) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_MismatchTypeI32) {
|
||||
// @stage(compute) @workgroup_size(1, 2u, 3)
|
||||
// @stage(compute) @workgroup_size(1_i, 2u, 3_i)
|
||||
// fn main() {}
|
||||
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(Expr(1), Expr(Source{{12, 34}}, 2u), Expr(3))});
|
||||
WorkgroupSize(Expr(1_i), Expr(Source{{12, 34}}, 2_u), Expr(3_i))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -486,12 +488,12 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_MismatchTypeI32) {
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_TypeMismatch) {
|
||||
// let x = 64u;
|
||||
// @stage(compute) @workgroup_size(1, x)
|
||||
// @stage(compute) @workgroup_size(1i, x)
|
||||
// fn main() {}
|
||||
GlobalConst("x", ty.u32(), Expr(64u));
|
||||
Func(
|
||||
"main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(1), Expr(Source{{12, 34}}, "x"))});
|
||||
GlobalConst("x", ty.u32(), Expr(64_u));
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(Expr(1_i), Expr(Source{{12, 34}}, "x"))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -501,11 +503,11 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_TypeMismatch) {
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_TypeMismatch2) {
|
||||
// let x = 64u;
|
||||
// let y = 32;
|
||||
// let y = 32i;
|
||||
// @stage(compute) @workgroup_size(x, y)
|
||||
// fn main() {}
|
||||
GlobalConst("x", ty.u32(), Expr(64u));
|
||||
GlobalConst("y", ty.i32(), Expr(32));
|
||||
GlobalConst("x", ty.u32(), Expr(64_u));
|
||||
GlobalConst("y", ty.i32(), Expr(32_i));
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(Expr("x"), Expr(Source{{12, 34}}, "y"))});
|
||||
@ -518,13 +520,13 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_TypeMismatch2) {
|
||||
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Mismatch_ConstU32) {
|
||||
// let x = 4u;
|
||||
// let x = 8u;
|
||||
// @stage(compute) @workgroup_size(x, y, 16
|
||||
// @stage(compute) @workgroup_size(x, y, 16i)
|
||||
// fn main() {}
|
||||
GlobalConst("x", ty.u32(), Expr(4u));
|
||||
GlobalConst("y", ty.u32(), Expr(8u));
|
||||
GlobalConst("x", ty.u32(), Expr(4_u));
|
||||
GlobalConst("y", ty.u32(), Expr(8_u));
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(Expr("x"), Expr("y"), Expr(Source{{12, 34}}, 16))});
|
||||
WorkgroupSize(Expr("x"), Expr("y"), Expr(Source{{12, 34}}, 16_i))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -546,22 +548,22 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Literal_BadType) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Literal_Negative) {
|
||||
// @stage(compute) @workgroup_size(-2)
|
||||
// @stage(compute) @workgroup_size(-2i)
|
||||
// fn main() {}
|
||||
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, -2))});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, i32(-2)))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: workgroup_size argument must be at least 1");
|
||||
}
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Literal_Zero) {
|
||||
// @stage(compute) @workgroup_size(0)
|
||||
// @stage(compute) @workgroup_size(0i)
|
||||
// fn main() {}
|
||||
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, 0))});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, 0_i))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: workgroup_size argument must be at least 1");
|
||||
@ -582,10 +584,10 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_BadType) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_Negative) {
|
||||
// let x = -2;
|
||||
// let x = -2i;
|
||||
// @stage(compute) @workgroup_size(x)
|
||||
// fn main() {}
|
||||
GlobalConst("x", ty.i32(), Expr(-2));
|
||||
GlobalConst("x", ty.i32(), Expr(i32(-2)));
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, "x"))});
|
||||
|
||||
@ -594,10 +596,10 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_Negative) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_Zero) {
|
||||
// let x = 0;
|
||||
// let x = 0i;
|
||||
// @stage(compute) @workgroup_size(x)
|
||||
// fn main() {}
|
||||
GlobalConst("x", ty.i32(), Expr(0));
|
||||
GlobalConst("x", ty.i32(), Expr(0_i));
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, "x"))});
|
||||
|
||||
@ -618,10 +620,10 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_NestedZeroValueConstr
|
||||
}
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_NonConst) {
|
||||
// var<private> x = 0;
|
||||
// var<private> x = 64i;
|
||||
// @stage(compute) @workgroup_size(x)
|
||||
// fn main() {}
|
||||
Global("x", ty.i32(), ast::StorageClass::kPrivate, Expr(64));
|
||||
Global("x", ty.i32(), ast::StorageClass::kPrivate, Expr(64_i));
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, "x"))});
|
||||
|
||||
@ -636,7 +638,7 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_InvalidExpr) {
|
||||
// fn main() {}
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(Construct(Source{{12, 34}}, ty.i32(), 1))});
|
||||
WorkgroupSize(Construct(Source{{12, 34}}, ty.i32(), 1_i))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -661,7 +663,7 @@ TEST_F(ResolverFunctionValidationTest, ReturnIsConstructible_AtomicInt) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, ReturnIsConstructible_ArrayOfAtomic) {
|
||||
auto* ret_type = ty.array(Source{{12, 34}}, ty.atomic(ty.i32()), 10);
|
||||
auto* ret_type = ty.array(Source{{12, 34}}, ty.atomic(ty.i32()), 10_u);
|
||||
Func("f", {}, ret_type, {});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -25,7 +27,7 @@ using ResolverIncrementDecrementValidationTest = ResolverTest;
|
||||
TEST_F(ResolverIncrementDecrementValidationTest, Increment_Signed) {
|
||||
// var a : i32 = 2;
|
||||
// a++;
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
||||
WrapInFunction(var, Increment(Source{{12, 34}}, "a"));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -34,7 +36,7 @@ TEST_F(ResolverIncrementDecrementValidationTest, Increment_Signed) {
|
||||
TEST_F(ResolverIncrementDecrementValidationTest, Decrement_Signed) {
|
||||
// var a : i32 = 2;
|
||||
// a--;
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
||||
WrapInFunction(var, Decrement(Source{{12, 34}}, "a"));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -43,7 +45,7 @@ TEST_F(ResolverIncrementDecrementValidationTest, Decrement_Signed) {
|
||||
TEST_F(ResolverIncrementDecrementValidationTest, Increment_Unsigned) {
|
||||
// var a : u32 = 2u;
|
||||
// a++;
|
||||
auto* var = Var("a", ty.u32(), ast::StorageClass::kNone, Expr(2u));
|
||||
auto* var = Var("a", ty.u32(), ast::StorageClass::kNone, Expr(2_u));
|
||||
WrapInFunction(var, Increment(Source{{12, 34}}, "a"));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -52,7 +54,7 @@ TEST_F(ResolverIncrementDecrementValidationTest, Increment_Unsigned) {
|
||||
TEST_F(ResolverIncrementDecrementValidationTest, Decrement_Unsigned) {
|
||||
// var a : u32 = 2u;
|
||||
// a--;
|
||||
auto* var = Var("a", ty.u32(), ast::StorageClass::kNone, Expr(2u));
|
||||
auto* var = Var("a", ty.u32(), ast::StorageClass::kNone, Expr(2_u));
|
||||
WrapInFunction(var, Decrement(Source{{12, 34}}, "a"));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -63,26 +65,26 @@ TEST_F(ResolverIncrementDecrementValidationTest, ThroughPointer) {
|
||||
// let b : ptr<function,i32> = &a;
|
||||
// *b++;
|
||||
auto* var_a = Var("a", ty.i32(), ast::StorageClass::kFunction);
|
||||
auto* var_b = Let("b", ty.pointer<int>(ast::StorageClass::kFunction), AddressOf(Expr("a")));
|
||||
auto* var_b = Let("b", ty.pointer<i32>(ast::StorageClass::kFunction), AddressOf(Expr("a")));
|
||||
WrapInFunction(var_a, var_b, Increment(Source{{12, 34}}, Deref("b")));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
|
||||
TEST_F(ResolverIncrementDecrementValidationTest, ThroughArray) {
|
||||
// var a : array<i32, 4>;
|
||||
// a[1]++;
|
||||
auto* var_a = Var("a", ty.array(ty.i32(), 4), ast::StorageClass::kNone);
|
||||
WrapInFunction(var_a, Increment(Source{{12, 34}}, IndexAccessor("a", 1)));
|
||||
// var a : array<i32, 4_u>;
|
||||
// a[1i]++;
|
||||
auto* var_a = Var("a", ty.array(ty.i32(), 4_u), ast::StorageClass::kNone);
|
||||
WrapInFunction(var_a, Increment(Source{{12, 34}}, IndexAccessor("a", 1_i)));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
|
||||
TEST_F(ResolverIncrementDecrementValidationTest, ThroughVector_Index) {
|
||||
// var a : vec4<i32>;
|
||||
// a.y++;
|
||||
// a[1i]++;
|
||||
auto* var_a = Var("a", ty.vec4(ty.i32()), ast::StorageClass::kNone);
|
||||
WrapInFunction(var_a, Increment(Source{{12, 34}}, IndexAccessor("a", 1)));
|
||||
WrapInFunction(var_a, Increment(Source{{12, 34}}, IndexAccessor("a", 1_i)));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
@ -136,7 +138,7 @@ TEST_F(ResolverIncrementDecrementValidationTest, Atomic) {
|
||||
|
||||
TEST_F(ResolverIncrementDecrementValidationTest, Literal) {
|
||||
// 1++;
|
||||
WrapInFunction(Increment(Expr(Source{{56, 78}}, 1)));
|
||||
WrapInFunction(Increment(Expr(Source{{56, 78}}, 1_i)));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "56:78 error: cannot modify value of type 'i32'");
|
||||
@ -145,7 +147,7 @@ TEST_F(ResolverIncrementDecrementValidationTest, Literal) {
|
||||
TEST_F(ResolverIncrementDecrementValidationTest, Constant) {
|
||||
// let a = 1;
|
||||
// a++;
|
||||
auto* a = Let(Source{{12, 34}}, "a", nullptr, Expr(1));
|
||||
auto* a = Let(Source{{12, 34}}, "a", nullptr, Expr(1_i));
|
||||
WrapInFunction(a, Increment(Expr(Source{{56, 78}}, "a")));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -173,7 +175,7 @@ TEST_F(ResolverIncrementDecrementValidationTest, ReturnValue) {
|
||||
// {
|
||||
// a++;
|
||||
// }
|
||||
Func("func", {}, ty.i32(), {Return(0)});
|
||||
Func("func", {}, ty.i32(), {Return(0_i)});
|
||||
WrapInFunction(Increment(Call(Source{{56, 78}}, "func")));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -205,7 +207,7 @@ TEST_F(ResolverIncrementDecrementValidationTest, InForLoopInit) {
|
||||
// for (a++; ; ) {
|
||||
// break;
|
||||
// }
|
||||
auto* a = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
auto* a = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
||||
auto* loop = For(Increment(Source{{56, 78}}, "a"), nullptr, nullptr, Block(Break()));
|
||||
WrapInFunction(a, loop);
|
||||
|
||||
@ -217,7 +219,7 @@ TEST_F(ResolverIncrementDecrementValidationTest, InForLoopCont) {
|
||||
// for (; ; a++) {
|
||||
// break;
|
||||
// }
|
||||
auto* a = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
auto* a = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
||||
auto* loop = For(nullptr, nullptr, Increment(Source{{56, 78}}, "a"), Block(Break()));
|
||||
WrapInFunction(a, loop);
|
||||
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -37,9 +39,6 @@ template <typename T>
|
||||
using mat4x4 = builder::mat4x4<T>;
|
||||
template <typename T>
|
||||
using alias = builder::alias<T>;
|
||||
using f32 = builder::f32;
|
||||
using i32 = builder::i32;
|
||||
using u32 = builder::u32;
|
||||
|
||||
struct ResolverInferredTypeTest : public resolver::TestHelper, public testing::Test {};
|
||||
|
||||
@ -133,7 +132,7 @@ TEST_P(ResolverInferredTypeParamTest, LocalVar_Pass) {
|
||||
INSTANTIATE_TEST_SUITE_P(ResolverTest, ResolverInferredTypeParamTest, testing::ValuesIn(all_cases));
|
||||
|
||||
TEST_F(ResolverInferredTypeTest, InferArray_Pass) {
|
||||
auto* type = ty.array(ty.u32(), 10);
|
||||
auto* type = ty.array(ty.u32(), 10_u);
|
||||
auto* expected_type = create<sem::Array>(create<sem::U32>(), 10u, 4u, 4u * 10u, 4u, 4u);
|
||||
|
||||
auto* ctor_expr = Construct(type);
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -27,7 +29,7 @@ struct ResolverPtrRefValidationTest : public resolver::TestHelper, public testin
|
||||
TEST_F(ResolverPtrRefValidationTest, AddressOfLiteral) {
|
||||
// &1
|
||||
|
||||
auto* expr = AddressOf(Expr(Source{{12, 34}}, 1));
|
||||
auto* expr = AddressOf(Expr(Source{{12, 34}}, 1_i));
|
||||
|
||||
WrapInFunction(expr);
|
||||
|
||||
@ -39,7 +41,7 @@ TEST_F(ResolverPtrRefValidationTest, AddressOfLiteral) {
|
||||
TEST_F(ResolverPtrRefValidationTest, AddressOfLet) {
|
||||
// let l : i32 = 1;
|
||||
// &l
|
||||
auto* l = Let("l", ty.i32(), Expr(1));
|
||||
auto* l = Let("l", ty.i32(), Expr(1_i));
|
||||
auto* expr = AddressOf(Expr(Source{{12, 34}}, "l"));
|
||||
|
||||
WrapInFunction(l, expr);
|
||||
@ -77,9 +79,9 @@ TEST_F(ResolverPtrRefValidationTest, AddressOfVectorComponent_MemberAccessor) {
|
||||
|
||||
TEST_F(ResolverPtrRefValidationTest, AddressOfVectorComponent_IndexAccessor) {
|
||||
// var v : vec4<i32>;
|
||||
// &v[2]
|
||||
// &v[2i]
|
||||
auto* v = Var("v", ty.vec4<i32>());
|
||||
auto* expr = AddressOf(IndexAccessor(Source{{12, 34}}, "v", 2));
|
||||
auto* expr = AddressOf(IndexAccessor(Source{{12, 34}}, "v", 2_i));
|
||||
|
||||
WrapInFunction(v, expr);
|
||||
|
||||
@ -104,7 +106,7 @@ TEST_F(ResolverPtrRefValidationTest, IndirectOfAddressOfHandle) {
|
||||
TEST_F(ResolverPtrRefValidationTest, DerefOfLiteral) {
|
||||
// *1
|
||||
|
||||
auto* expr = Deref(Expr(Source{{12, 34}}, 1));
|
||||
auto* expr = Deref(Expr(Source{{12, 34}}, 1_i));
|
||||
|
||||
WrapInFunction(expr);
|
||||
|
||||
@ -114,8 +116,8 @@ TEST_F(ResolverPtrRefValidationTest, DerefOfLiteral) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverPtrRefValidationTest, DerefOfVar) {
|
||||
// var v : i32 = 1;
|
||||
// *1
|
||||
// var v : i32;
|
||||
// *v
|
||||
auto* v = Var("v", ty.i32());
|
||||
auto* expr = Deref(Expr(Source{{12, 34}}, "v"));
|
||||
|
||||
@ -128,14 +130,14 @@ TEST_F(ResolverPtrRefValidationTest, DerefOfVar) {
|
||||
|
||||
TEST_F(ResolverPtrRefValidationTest, InferredPtrAccessMismatch) {
|
||||
// struct Inner {
|
||||
// arr: array<i32, 4>;
|
||||
// arr: array<i32, 4u>;
|
||||
// }
|
||||
// struct S {
|
||||
// inner: Inner;
|
||||
// }
|
||||
// @group(0) @binding(0) var<storage, read_write> s : S;
|
||||
// fn f() {
|
||||
// let p : pointer<storage, i32> = &s.inner.arr[2];
|
||||
// let p : pointer<storage, i32> = &s.inner.arr[2i];
|
||||
// }
|
||||
auto* inner = Structure("Inner", {Member("arr", ty.array<i32, 4>())});
|
||||
auto* buf = Structure("S", {Member("inner", ty.Of(inner))});
|
||||
@ -145,7 +147,7 @@ TEST_F(ResolverPtrRefValidationTest, InferredPtrAccessMismatch) {
|
||||
create<ast::GroupAttribute>(0),
|
||||
});
|
||||
|
||||
auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 4);
|
||||
auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 2_i);
|
||||
auto* ptr =
|
||||
Let(Source{{12, 34}}, "p", ty.pointer<i32>(ast::StorageClass::kStorage), AddressOf(expr));
|
||||
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "src/tint/sem/for_loop_statement.h"
|
||||
#include "src/tint/sem/if_statement.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -32,13 +34,13 @@ class ResolverBehaviorTest : public ResolverTest {
|
||||
Func("DiscardOrNext", {}, ty.i32(),
|
||||
{
|
||||
If(true, Block(Discard())),
|
||||
Return(1),
|
||||
Return(1_i),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(ResolverBehaviorTest, ExprBinaryOp_LHS) {
|
||||
auto* stmt = Decl(Var("lhs", ty.i32(), Add(Call("DiscardOrNext"), 1)));
|
||||
auto* stmt = Decl(Var("lhs", ty.i32(), Add(Call("DiscardOrNext"), 1_i)));
|
||||
WrapInFunction(stmt);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -48,7 +50,7 @@ TEST_F(ResolverBehaviorTest, ExprBinaryOp_LHS) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBehaviorTest, ExprBinaryOp_RHS) {
|
||||
auto* stmt = Decl(Var("lhs", ty.i32(), Add(1, Call("DiscardOrNext"))));
|
||||
auto* stmt = Decl(Var("lhs", ty.i32(), Add(1_i, Call("DiscardOrNext"))));
|
||||
WrapInFunction(stmt);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -74,7 +76,7 @@ TEST_F(ResolverBehaviorTest, ExprIndex_Arr) {
|
||||
Return(Construct(ty.array<i32, 4>())),
|
||||
});
|
||||
|
||||
auto* stmt = Decl(Var("lhs", ty.i32(), IndexAccessor(Call("ArrayDiscardOrNext"), 1)));
|
||||
auto* stmt = Decl(Var("lhs", ty.i32(), IndexAccessor(Call("ArrayDiscardOrNext"), 1_i)));
|
||||
WrapInFunction(stmt);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -119,7 +121,7 @@ TEST_F(ResolverBehaviorTest, StmtAssign) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBehaviorTest, StmtAssign_LHSDiscardOrNext) {
|
||||
auto* stmt = Assign(IndexAccessor("lhs", Call("DiscardOrNext")), 1);
|
||||
auto* stmt = Assign(IndexAccessor("lhs", Call("DiscardOrNext")), 1_i);
|
||||
WrapInFunction(Decl(Var("lhs", ty.array<i32, 4>())), //
|
||||
stmt);
|
||||
|
||||
@ -302,7 +304,7 @@ TEST_F(ResolverBehaviorTest, StmtForLoopEmpty_CondTrue) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBehaviorTest, StmtForLoopEmpty_CondCallFuncMayDiscard) {
|
||||
auto* stmt = For(nullptr, Equal(Call("DiscardOrNext"), 1), nullptr, Block());
|
||||
auto* stmt = For(nullptr, Equal(Call("DiscardOrNext"), 1_i), nullptr, Block());
|
||||
WrapInFunction(stmt);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -352,7 +354,7 @@ TEST_F(ResolverBehaviorTest, StmtIfTrue_ThenDiscard_ElseDiscard) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBehaviorTest, StmtIfCallFuncMayDiscard_ThenEmptyBlock) {
|
||||
auto* stmt = If(Equal(Call("DiscardOrNext"), 1), Block());
|
||||
auto* stmt = If(Equal(Call("DiscardOrNext"), 1_i), Block());
|
||||
WrapInFunction(stmt);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -363,7 +365,7 @@ TEST_F(ResolverBehaviorTest, StmtIfCallFuncMayDiscard_ThenEmptyBlock) {
|
||||
|
||||
TEST_F(ResolverBehaviorTest, StmtIfTrue_ThenEmptyBlock_ElseCallFuncMayDiscard) {
|
||||
auto* stmt = If(true, Block(), //
|
||||
Else(If(Equal(Call("DiscardOrNext"), 1), Block())));
|
||||
Else(If(Equal(Call("DiscardOrNext"), 1_i), Block())));
|
||||
WrapInFunction(stmt);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -373,7 +375,7 @@ TEST_F(ResolverBehaviorTest, StmtIfTrue_ThenEmptyBlock_ElseCallFuncMayDiscard) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBehaviorTest, StmtLetDecl) {
|
||||
auto* stmt = Decl(Let("v", ty.i32(), Expr(1)));
|
||||
auto* stmt = Decl(Let("v", ty.i32(), Expr(1_i)));
|
||||
WrapInFunction(stmt);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -477,7 +479,7 @@ TEST_F(ResolverBehaviorTest, StmtReturn_DiscardOrNext) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBehaviorTest, StmtSwitch_CondTrue_DefaultEmpty) {
|
||||
auto* stmt = Switch(1, DefaultCase(Block()));
|
||||
auto* stmt = Switch(1_i, DefaultCase(Block()));
|
||||
WrapInFunction(stmt);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -487,7 +489,7 @@ TEST_F(ResolverBehaviorTest, StmtSwitch_CondTrue_DefaultEmpty) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBehaviorTest, StmtSwitch_CondLiteral_DefaultEmpty) {
|
||||
auto* stmt = Switch(1, DefaultCase(Block()));
|
||||
auto* stmt = Switch(1_i, DefaultCase(Block()));
|
||||
WrapInFunction(stmt);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -497,7 +499,7 @@ TEST_F(ResolverBehaviorTest, StmtSwitch_CondLiteral_DefaultEmpty) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBehaviorTest, StmtSwitch_CondLiteral_DefaultDiscard) {
|
||||
auto* stmt = Switch(1, DefaultCase(Block(Discard())));
|
||||
auto* stmt = Switch(1_i, DefaultCase(Block(Discard())));
|
||||
WrapInFunction(stmt);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -507,7 +509,7 @@ TEST_F(ResolverBehaviorTest, StmtSwitch_CondLiteral_DefaultDiscard) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBehaviorTest, StmtSwitch_CondLiteral_DefaultReturn) {
|
||||
auto* stmt = Switch(1, DefaultCase(Block(Return())));
|
||||
auto* stmt = Switch(1_i, DefaultCase(Block(Return())));
|
||||
WrapInFunction(stmt);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -517,7 +519,7 @@ TEST_F(ResolverBehaviorTest, StmtSwitch_CondLiteral_DefaultReturn) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBehaviorTest, StmtSwitch_CondLiteral_Case0Empty_DefaultEmpty) {
|
||||
auto* stmt = Switch(1, Case(Expr(0), Block()), DefaultCase(Block()));
|
||||
auto* stmt = Switch(1_i, Case(Expr(0_i), Block()), DefaultCase(Block()));
|
||||
WrapInFunction(stmt);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -527,7 +529,7 @@ TEST_F(ResolverBehaviorTest, StmtSwitch_CondLiteral_Case0Empty_DefaultEmpty) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBehaviorTest, StmtSwitch_CondLiteral_Case0Empty_DefaultDiscard) {
|
||||
auto* stmt = Switch(1, Case(Expr(0), Block()), DefaultCase(Block(Discard())));
|
||||
auto* stmt = Switch(1_i, Case(Expr(0_i), Block()), DefaultCase(Block(Discard())));
|
||||
WrapInFunction(stmt);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -537,7 +539,7 @@ TEST_F(ResolverBehaviorTest, StmtSwitch_CondLiteral_Case0Empty_DefaultDiscard) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBehaviorTest, StmtSwitch_CondLiteral_Case0Empty_DefaultReturn) {
|
||||
auto* stmt = Switch(1, Case(Expr(0), Block()), DefaultCase(Block(Return())));
|
||||
auto* stmt = Switch(1_i, Case(Expr(0_i), Block()), DefaultCase(Block(Return())));
|
||||
WrapInFunction(stmt);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -547,7 +549,7 @@ TEST_F(ResolverBehaviorTest, StmtSwitch_CondLiteral_Case0Empty_DefaultReturn) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBehaviorTest, StmtSwitch_CondLiteral_Case0Discard_DefaultEmpty) {
|
||||
auto* stmt = Switch(1, Case(Expr(0), Block(Discard())), DefaultCase(Block()));
|
||||
auto* stmt = Switch(1_i, Case(Expr(0_i), Block(Discard())), DefaultCase(Block()));
|
||||
WrapInFunction(stmt);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -557,7 +559,7 @@ TEST_F(ResolverBehaviorTest, StmtSwitch_CondLiteral_Case0Discard_DefaultEmpty) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverBehaviorTest, StmtSwitch_CondLiteral_Case0Discard_DefaultDiscard) {
|
||||
auto* stmt = Switch(1, Case(Expr(0), Block(Discard())), DefaultCase(Block(Discard())));
|
||||
auto* stmt = Switch(1_i, Case(Expr(0_i), Block(Discard())), DefaultCase(Block(Discard())));
|
||||
WrapInFunction(stmt);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -567,7 +569,7 @@ TEST_F(ResolverBehaviorTest, StmtSwitch_CondLiteral_Case0Discard_DefaultDiscard)
|
||||
}
|
||||
|
||||
TEST_F(ResolverBehaviorTest, StmtSwitch_CondLiteral_Case0Discard_DefaultReturn) {
|
||||
auto* stmt = Switch(1, Case(Expr(0), Block(Discard())), DefaultCase(Block(Return())));
|
||||
auto* stmt = Switch(1_i, Case(Expr(0_i), Block(Discard())), DefaultCase(Block(Return())));
|
||||
WrapInFunction(stmt);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -577,9 +579,9 @@ TEST_F(ResolverBehaviorTest, StmtSwitch_CondLiteral_Case0Discard_DefaultReturn)
|
||||
}
|
||||
|
||||
TEST_F(ResolverBehaviorTest, StmtSwitch_CondLiteral_Case0Discard_Case1Return_DefaultEmpty) {
|
||||
auto* stmt = Switch(1, //
|
||||
Case(Expr(0), Block(Discard())), //
|
||||
Case(Expr(1), Block(Return())), //
|
||||
auto* stmt = Switch(1_i, //
|
||||
Case(Expr(0_i), Block(Discard())), //
|
||||
Case(Expr(1_i), Block(Return())), //
|
||||
DefaultCase(Block()));
|
||||
WrapInFunction(stmt);
|
||||
|
||||
|
@ -18,14 +18,9 @@
|
||||
#include "src/tint/sem/type_constructor.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
using i32 = ProgramBuilder::i32;
|
||||
using u32 = ProgramBuilder::u32;
|
||||
using f32 = ProgramBuilder::f32;
|
||||
|
||||
} // namespace
|
||||
|
||||
sem::Constant Resolver::EvaluateConstantValue(const ast::Expression* expr, const sem::Type* type) {
|
||||
if (auto* e = expr->As<ast::LiteralExpression>()) {
|
||||
@ -43,9 +38,9 @@ sem::Constant Resolver::EvaluateConstantValue(const ast::LiteralExpression* lite
|
||||
literal,
|
||||
[&](const ast::IntLiteralExpression* lit) {
|
||||
if (lit->suffix == ast::IntLiteralExpression::Suffix::kU) {
|
||||
return sem::Constant{type, {static_cast<uint32_t>(lit->value)}};
|
||||
return sem::Constant{type, {u32(static_cast<uint32_t>(lit->value))}};
|
||||
}
|
||||
return sem::Constant{type, {static_cast<int32_t>(lit->value)}};
|
||||
return sem::Constant{type, {i32(static_cast<int32_t>(lit->value))}};
|
||||
},
|
||||
[&](const ast::FloatLiteralExpression* lit) {
|
||||
return sem::Constant{type, {lit->value}};
|
||||
@ -70,10 +65,10 @@ sem::Constant Resolver::EvaluateConstantValue(const ast::CallExpression* call,
|
||||
// For zero value init, return 0s
|
||||
if (call->args.empty()) {
|
||||
if (elem_type->Is<sem::I32>()) {
|
||||
return sem::Constant(type, sem::Constant::Scalars(result_size, 0));
|
||||
return sem::Constant(type, sem::Constant::Scalars(result_size, 0_i));
|
||||
}
|
||||
if (elem_type->Is<sem::U32>()) {
|
||||
return sem::Constant(type, sem::Constant::Scalars(result_size, 0u));
|
||||
return sem::Constant(type, sem::Constant::Scalars(result_size, 0_u));
|
||||
}
|
||||
if (elem_type->Is<sem::F32>()) {
|
||||
return sem::Constant(type, sem::Constant::Scalars(result_size, 0.f));
|
||||
@ -113,16 +108,34 @@ sem::Constant Resolver::ConstantCast(const sem::Constant& value,
|
||||
|
||||
sem::Constant::Scalars elems;
|
||||
for (size_t i = 0; i < value.Elements().size(); ++i) {
|
||||
if (target_elem_type->Is<sem::I32>()) {
|
||||
elems.emplace_back(value.WithScalarAt(i, [](auto&& s) { return static_cast<i32>(s); }));
|
||||
} else if (target_elem_type->Is<sem::U32>()) {
|
||||
elems.emplace_back(value.WithScalarAt(i, [](auto&& s) { return static_cast<u32>(s); }));
|
||||
} else if (target_elem_type->Is<sem::F32>()) {
|
||||
elems.emplace_back(value.WithScalarAt(i, [](auto&& s) { return static_cast<f32>(s); }));
|
||||
} else if (target_elem_type->Is<sem::Bool>()) {
|
||||
elems.emplace_back(
|
||||
value.WithScalarAt(i, [](auto&& s) { return static_cast<bool>(s); }));
|
||||
}
|
||||
elems.emplace_back(Switch<sem::Constant::Scalar>(
|
||||
target_elem_type,
|
||||
[&](const sem::I32*) {
|
||||
return value.WithScalarAt(i, [](auto&& s) { //
|
||||
return i32(static_cast<int32_t>(s));
|
||||
});
|
||||
},
|
||||
[&](const sem::U32*) {
|
||||
return value.WithScalarAt(i, [](auto&& s) { //
|
||||
return u32(static_cast<uint32_t>(s));
|
||||
});
|
||||
},
|
||||
[&](const sem::F32*) {
|
||||
return value.WithScalarAt(i, [](auto&& s) { //
|
||||
return static_cast<f32>(s);
|
||||
});
|
||||
},
|
||||
[&](const sem::Bool*) {
|
||||
return value.WithScalarAt(i, [](auto&& s) { //
|
||||
return static_cast<bool>(s);
|
||||
});
|
||||
},
|
||||
[&](Default) {
|
||||
diag::List diags;
|
||||
TINT_UNREACHABLE(Semantic, diags)
|
||||
<< "invalid element type " << target_elem_type->TypeInfo().name;
|
||||
return sem::Constant::Scalar(false);
|
||||
}));
|
||||
}
|
||||
|
||||
auto* target_type =
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/sem/expression.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -26,7 +28,7 @@ using Scalar = sem::Constant::Scalar;
|
||||
using ResolverConstantsTest = ResolverTest;
|
||||
|
||||
TEST_F(ResolverConstantsTest, Scalar_i32) {
|
||||
auto* expr = Expr(99);
|
||||
auto* expr = Expr(99_i);
|
||||
WrapInFunction(expr);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -41,7 +43,7 @@ TEST_F(ResolverConstantsTest, Scalar_i32) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverConstantsTest, Scalar_u32) {
|
||||
auto* expr = Expr(99u);
|
||||
auto* expr = Expr(99_u);
|
||||
WrapInFunction(expr);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -162,7 +164,7 @@ TEST_F(ResolverConstantsTest, Vec3_ZeroInit_bool) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverConstantsTest, Vec3_Splat_i32) {
|
||||
auto* expr = vec3<i32>(99);
|
||||
auto* expr = vec3<i32>(99_i);
|
||||
WrapInFunction(expr);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -181,7 +183,7 @@ TEST_F(ResolverConstantsTest, Vec3_Splat_i32) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverConstantsTest, Vec3_Splat_u32) {
|
||||
auto* expr = vec3<u32>(99u);
|
||||
auto* expr = vec3<u32>(99_u);
|
||||
WrapInFunction(expr);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -238,7 +240,7 @@ TEST_F(ResolverConstantsTest, Vec3_Splat_bool) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverConstantsTest, Vec3_FullConstruct_i32) {
|
||||
auto* expr = vec3<i32>(1, 2, 3);
|
||||
auto* expr = vec3<i32>(1_i, 2_i, 3_i);
|
||||
WrapInFunction(expr);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -257,7 +259,7 @@ TEST_F(ResolverConstantsTest, Vec3_FullConstruct_i32) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverConstantsTest, Vec3_FullConstruct_u32) {
|
||||
auto* expr = vec3<u32>(1u, 2u, 3u);
|
||||
auto* expr = vec3<u32>(1_u, 2_u, 3_u);
|
||||
WrapInFunction(expr);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -314,7 +316,7 @@ TEST_F(ResolverConstantsTest, Vec3_FullConstruct_bool) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverConstantsTest, Vec3_MixConstruct_i32) {
|
||||
auto* expr = vec3<i32>(1, vec2<i32>(2, 3));
|
||||
auto* expr = vec3<i32>(1_i, vec2<i32>(2_i, 3_i));
|
||||
WrapInFunction(expr);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -333,7 +335,7 @@ TEST_F(ResolverConstantsTest, Vec3_MixConstruct_i32) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverConstantsTest, Vec3_MixConstruct_u32) {
|
||||
auto* expr = vec3<u32>(vec2<u32>(1u, 2u), 3u);
|
||||
auto* expr = vec3<u32>(vec2<u32>(1_u, 2_u), 3_u);
|
||||
WrapInFunction(expr);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -409,7 +411,7 @@ TEST_F(ResolverConstantsTest, Vec3_Cast_f32_to_32) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverConstantsTest, Vec3_Cast_u32_to_f32) {
|
||||
auto* expr = vec3<f32>(vec3<u32>(10u, 20u, 30u));
|
||||
auto* expr = vec3<f32>(vec3<u32>(10_u, 20_u, 30_u));
|
||||
WrapInFunction(expr);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
@ -47,6 +47,8 @@
|
||||
using ::testing::ElementsAre;
|
||||
using ::testing::HasSubstr;
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -81,9 +83,6 @@ template <typename T>
|
||||
using alias2 = builder::alias2<T>;
|
||||
template <typename T>
|
||||
using alias3 = builder::alias3<T>;
|
||||
using f32 = builder::f32;
|
||||
using i32 = builder::i32;
|
||||
using u32 = builder::u32;
|
||||
using Op = ast::BinaryOp;
|
||||
|
||||
TEST_F(ResolverTest, Stmt_Assign) {
|
||||
@ -113,7 +112,7 @@ TEST_F(ResolverTest, Stmt_Case) {
|
||||
auto* assign = Assign(lhs, rhs);
|
||||
auto* block = Block(assign);
|
||||
ast::CaseSelectorList lit;
|
||||
lit.push_back(Expr(3));
|
||||
lit.push_back(Expr(3_i));
|
||||
auto* cse = create<ast::CaseStatement>(lit, block);
|
||||
auto* cond_var = Var("c", ty.i32());
|
||||
auto* sw = Switch(cond_var, cse, DefaultCase());
|
||||
@ -223,7 +222,7 @@ TEST_F(ResolverTest, Stmt_Loop) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, Stmt_Return) {
|
||||
auto* cond = Expr(2);
|
||||
auto* cond = Expr(2_i);
|
||||
|
||||
auto* ret = Return(cond);
|
||||
Func("test", {}, ty.i32(), {ret}, {});
|
||||
@ -246,7 +245,7 @@ TEST_F(ResolverTest, Stmt_Switch) {
|
||||
auto* lhs = Expr("v");
|
||||
auto* rhs = Expr(2.3f);
|
||||
auto* case_block = Block(Assign(lhs, rhs));
|
||||
auto* stmt = Switch(Expr(2), Case(Expr(3), case_block), DefaultCase());
|
||||
auto* stmt = Switch(Expr(2_i), Case(Expr(3_i), case_block), DefaultCase());
|
||||
WrapInFunction(v, stmt);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -279,7 +278,7 @@ TEST_F(ResolverTest, Stmt_Call) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, Stmt_VariableDecl) {
|
||||
auto* var = Var("my_var", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
auto* var = Var("my_var", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
||||
auto* init = var->constructor;
|
||||
|
||||
auto* decl = Decl(var);
|
||||
@ -293,7 +292,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl) {
|
||||
|
||||
TEST_F(ResolverTest, Stmt_VariableDecl_Alias) {
|
||||
auto* my_int = Alias("MyInt", ty.i32());
|
||||
auto* var = Var("my_var", ty.Of(my_int), ast::StorageClass::kNone, Expr(2));
|
||||
auto* var = Var("my_var", ty.Of(my_int), ast::StorageClass::kNone, Expr(2_i));
|
||||
auto* init = var->constructor;
|
||||
|
||||
auto* decl = Decl(var);
|
||||
@ -306,7 +305,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_Alias) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScope) {
|
||||
auto* init = Expr(2);
|
||||
auto* init = Expr(2_i);
|
||||
Global("my_var", ty.i32(), ast::StorageClass::kPrivate, init);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -329,7 +328,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_OuterScopeAfterInnerScope) {
|
||||
ast::VariableList params;
|
||||
|
||||
// Declare i32 "foo" inside a block
|
||||
auto* foo_i32 = Var("foo", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
auto* foo_i32 = Var("foo", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
||||
auto* foo_i32_init = foo_i32->constructor;
|
||||
auto* foo_i32_decl = Decl(foo_i32);
|
||||
|
||||
@ -385,7 +384,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScopeAfterFunctionScope) {
|
||||
ast::VariableList params;
|
||||
|
||||
// Declare i32 "foo" inside a function
|
||||
auto* fn_i32 = Var("foo", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
auto* fn_i32 = Var("foo", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
|
||||
auto* fn_i32_init = fn_i32->constructor;
|
||||
auto* fn_i32_decl = Decl(fn_i32);
|
||||
Func("func_i32", params, ty.void_(), {fn_i32_decl}, ast::AttributeList{});
|
||||
@ -419,7 +418,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScopeAfterFunctionScope) {
|
||||
|
||||
TEST_F(ResolverTest, ArraySize_UnsignedLiteral) {
|
||||
// var<private> a : array<f32, 10u>;
|
||||
auto* a = Global("a", ty.array(ty.f32(), Expr(10u)), ast::StorageClass::kPrivate);
|
||||
auto* a = Global("a", ty.array(ty.f32(), Expr(10_u)), ast::StorageClass::kPrivate);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
||||
@ -431,8 +430,8 @@ TEST_F(ResolverTest, ArraySize_UnsignedLiteral) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, ArraySize_SignedLiteral) {
|
||||
// var<private> a : array<f32, 10>;
|
||||
auto* a = Global("a", ty.array(ty.f32(), Expr(10)), ast::StorageClass::kPrivate);
|
||||
// var<private> a : array<f32, 10i>;
|
||||
auto* a = Global("a", ty.array(ty.f32(), Expr(10_i)), ast::StorageClass::kPrivate);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
||||
@ -445,8 +444,8 @@ TEST_F(ResolverTest, ArraySize_SignedLiteral) {
|
||||
|
||||
TEST_F(ResolverTest, ArraySize_UnsignedConstant) {
|
||||
// let size = 0u;
|
||||
// var<private> a : array<f32, 10u>;
|
||||
GlobalConst("size", nullptr, Expr(10u));
|
||||
// var<private> a : array<f32, size>;
|
||||
GlobalConst("size", nullptr, Expr(10_u));
|
||||
auto* a = Global("a", ty.array(ty.f32(), Expr("size")), ast::StorageClass::kPrivate);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -460,8 +459,8 @@ TEST_F(ResolverTest, ArraySize_UnsignedConstant) {
|
||||
|
||||
TEST_F(ResolverTest, ArraySize_SignedConstant) {
|
||||
// let size = 0;
|
||||
// var<private> a : array<f32, 10>;
|
||||
GlobalConst("size", nullptr, Expr(10));
|
||||
// var<private> a : array<f32, size>;
|
||||
GlobalConst("size", nullptr, Expr(10_i));
|
||||
auto* a = Global("a", ty.array(ty.f32(), Expr("size")), ast::StorageClass::kPrivate);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -650,7 +649,7 @@ TEST_F(ResolverTest, Expr_Identifier_FunctionVariable_Const) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, IndexAccessor_Dynamic_Ref_F32) {
|
||||
// var a : array<bool, 10> = 0;
|
||||
// var a : array<bool, 10u> = 0;
|
||||
// var idx : f32 = f32();
|
||||
// var f : f32 = a[idx];
|
||||
auto* a = Var("a", ty.array<bool, 10>(), array<bool, 10>());
|
||||
@ -926,7 +925,7 @@ TEST_F(ResolverTest, Function_WorkgroupSize_Literals) {
|
||||
// @stage(compute) @workgroup_size(8, 2, 3)
|
||||
// fn main() {}
|
||||
auto* func = Func("main", ast::VariableList{}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(8, 2, 3)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(8_i, 2_i, 3_i)});
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
||||
@ -942,14 +941,14 @@ TEST_F(ResolverTest, Function_WorkgroupSize_Literals) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, Function_WorkgroupSize_Consts) {
|
||||
// let width = 16;
|
||||
// let height = 8;
|
||||
// let depth = 2;
|
||||
// let width = 16i;
|
||||
// let height = 8i;
|
||||
// let depth = 2i;
|
||||
// @stage(compute) @workgroup_size(width, height, depth)
|
||||
// fn main() {}
|
||||
GlobalConst("width", ty.i32(), Expr(16));
|
||||
GlobalConst("height", ty.i32(), Expr(8));
|
||||
GlobalConst("depth", ty.i32(), Expr(2));
|
||||
GlobalConst("width", ty.i32(), Expr(16_i));
|
||||
GlobalConst("height", ty.i32(), Expr(8_i));
|
||||
GlobalConst("depth", ty.i32(), Expr(2_i));
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize("width", "height", "depth")});
|
||||
@ -968,14 +967,14 @@ TEST_F(ResolverTest, Function_WorkgroupSize_Consts) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, Function_WorkgroupSize_Consts_NestedInitializer) {
|
||||
// let width = i32(i32(i32(8)));
|
||||
// let height = i32(i32(i32(4)));
|
||||
// let width = i32(i32(i32(8i)));
|
||||
// let height = i32(i32(i32(4i)));
|
||||
// @stage(compute) @workgroup_size(width, height)
|
||||
// fn main() {}
|
||||
GlobalConst("width", ty.i32(),
|
||||
Construct(ty.i32(), Construct(ty.i32(), Construct(ty.i32(), 8))));
|
||||
Construct(ty.i32(), Construct(ty.i32(), Construct(ty.i32(), 8_i))));
|
||||
GlobalConst("height", ty.i32(),
|
||||
Construct(ty.i32(), Construct(ty.i32(), Construct(ty.i32(), 4))));
|
||||
Construct(ty.i32(), Construct(ty.i32(), Construct(ty.i32(), 4_i))));
|
||||
auto* func = Func("main", ast::VariableList{}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize("width", "height")});
|
||||
|
||||
@ -993,14 +992,14 @@ TEST_F(ResolverTest, Function_WorkgroupSize_Consts_NestedInitializer) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, Function_WorkgroupSize_OverridableConsts) {
|
||||
// @id(0) override width = 16;
|
||||
// @id(1) override height = 8;
|
||||
// @id(2) override depth = 2;
|
||||
// @id(0) override width = 16i;
|
||||
// @id(1) override height = 8i;
|
||||
// @id(2) override depth = 2i;
|
||||
// @stage(compute) @workgroup_size(width, height, depth)
|
||||
// fn main() {}
|
||||
auto* width = Override("width", ty.i32(), Expr(16), {Id(0)});
|
||||
auto* height = Override("height", ty.i32(), Expr(8), {Id(1)});
|
||||
auto* depth = Override("depth", ty.i32(), Expr(2), {Id(2)});
|
||||
auto* width = Override("width", ty.i32(), Expr(16_i), {Id(0)});
|
||||
auto* height = Override("height", ty.i32(), Expr(8_i), {Id(1)});
|
||||
auto* depth = Override("depth", ty.i32(), Expr(2_i), {Id(2)});
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize("width", "height", "depth")});
|
||||
@ -1045,14 +1044,14 @@ TEST_F(ResolverTest, Function_WorkgroupSize_OverridableConsts_NoInit) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, Function_WorkgroupSize_Mixed) {
|
||||
// @id(1) override height = 2;
|
||||
// let depth = 3;
|
||||
// @id(1) override height = 2i;
|
||||
// let depth = 3i;
|
||||
// @stage(compute) @workgroup_size(8, height, depth)
|
||||
// fn main() {}
|
||||
auto* height = Override("height", ty.i32(), Expr(2), {Id(0)});
|
||||
GlobalConst("depth", ty.i32(), Expr(3));
|
||||
auto* height = Override("height", ty.i32(), Expr(2_i), {Id(0)});
|
||||
GlobalConst("depth", ty.i32(), Expr(3_i));
|
||||
auto* func = Func("main", ast::VariableList{}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(8, "height", "depth")});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(8_i, "height", "depth")});
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
||||
@ -1149,7 +1148,7 @@ TEST_F(ResolverTest, Expr_Accessor_MultiLevel) {
|
||||
// vec4<f32> foo
|
||||
// }
|
||||
// struct A {
|
||||
// array<b, 3> mem
|
||||
// array<b, 3u> mem
|
||||
// }
|
||||
// var c : A
|
||||
// c.mem[0].foo.yx
|
||||
@ -1161,11 +1160,11 @@ TEST_F(ResolverTest, Expr_Accessor_MultiLevel) {
|
||||
//
|
||||
|
||||
auto* stB = Structure("B", {Member("foo", ty.vec4<f32>())});
|
||||
auto* stA = Structure("A", {Member("mem", ty.array(ty.Of(stB), 3))});
|
||||
auto* stA = Structure("A", {Member("mem", ty.array(ty.Of(stB), 3_i))});
|
||||
Global("c", ty.Of(stA), ast::StorageClass::kPrivate);
|
||||
|
||||
auto* mem =
|
||||
MemberAccessor(MemberAccessor(IndexAccessor(MemberAccessor("c", "mem"), 0), "foo"), "yx");
|
||||
MemberAccessor(MemberAccessor(IndexAccessor(MemberAccessor("c", "mem"), 0_i), "foo"), "yx");
|
||||
WrapInFunction(mem);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -1820,13 +1819,13 @@ TEST_F(ResolverTest, Function_EntryPoints_StageAttribute) {
|
||||
Assign("call_a", Call("a")),
|
||||
Assign("call_b", Call("b")),
|
||||
},
|
||||
ast::AttributeList{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
ast::AttributeList{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
auto* ep_2 = Func("ep_2", params, ty.void_(),
|
||||
{
|
||||
Assign("call_c", Call("c")),
|
||||
},
|
||||
ast::AttributeList{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
ast::AttributeList{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
||||
@ -1903,7 +1902,7 @@ TEST_F(ResolverTest, Function_EntryPoints_LinearTime) {
|
||||
CallStmt(Call(fn_a(0))),
|
||||
CallStmt(Call(fn_b(0))),
|
||||
},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
@ -1930,7 +1929,7 @@ TEST_F(ResolverTest, ASTNodeReachedTwice) {
|
||||
EXPECT_FATAL_FAILURE(
|
||||
{
|
||||
ProgramBuilder b;
|
||||
auto* expr = b.Expr(1);
|
||||
auto* expr = b.Expr(1_i);
|
||||
b.Global("a", b.ty.i32(), ast::StorageClass::kPrivate, expr);
|
||||
b.Global("b", b.ty.i32(), ast::StorageClass::kPrivate, expr);
|
||||
Resolver(&b).Resolve();
|
||||
|
@ -119,10 +119,6 @@ class ResolverTestWithParam : public TestHelper, public testing::TestWithParam<T
|
||||
|
||||
namespace builder {
|
||||
|
||||
using i32 = ProgramBuilder::i32;
|
||||
using u32 = ProgramBuilder::u32;
|
||||
using f32 = ProgramBuilder::f32;
|
||||
|
||||
template <uint32_t N, typename T>
|
||||
struct vec {};
|
||||
|
||||
@ -409,7 +405,7 @@ struct DataType<array<N, T>> {
|
||||
/// @param b the ProgramBuilder
|
||||
/// @return a new AST array type
|
||||
static inline const ast::Type* AST(ProgramBuilder& b) {
|
||||
return b.ty.array(DataType<T>::AST(b), N);
|
||||
return b.ty.array(DataType<T>::AST(b), u32(N));
|
||||
}
|
||||
/// @param b the ProgramBuilder
|
||||
/// @return the semantic array type
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "src/tint/sem/expression.h"
|
||||
#include "src/tint/sem/member_accessor_expression.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -52,7 +54,7 @@ struct SideEffectsTest : ResolverTest {
|
||||
|
||||
TEST_F(SideEffectsTest, Phony) {
|
||||
auto* expr = Phony();
|
||||
auto* body = Assign(expr, 1);
|
||||
auto* body = Assign(expr, 1_i);
|
||||
WrapInFunction(body);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -62,7 +64,7 @@ TEST_F(SideEffectsTest, Phony) {
|
||||
}
|
||||
|
||||
TEST_F(SideEffectsTest, Literal) {
|
||||
auto* expr = Expr(1);
|
||||
auto* expr = Expr(1_i);
|
||||
WrapInFunction(expr);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -111,7 +113,7 @@ TEST_F(SideEffectsTest, Call_Builtin_NoSE_WithSEArg) {
|
||||
|
||||
TEST_F(SideEffectsTest, Call_Builtin_SE) {
|
||||
Global("a", ty.atomic(ty.i32()), ast::StorageClass::kWorkgroup);
|
||||
auto* expr = Call("atomicAdd", AddressOf("a"), 1);
|
||||
auto* expr = Call("atomicAdd", AddressOf("a"), 1_i);
|
||||
WrapInFunction(expr);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -122,7 +124,7 @@ TEST_F(SideEffectsTest, Call_Builtin_SE) {
|
||||
}
|
||||
|
||||
TEST_F(SideEffectsTest, Call_Function) {
|
||||
Func("f", {}, ty.i32(), {Return(1)});
|
||||
Func("f", {}, ty.i32(), {Return(1_i)});
|
||||
auto* expr = Call("f");
|
||||
WrapInFunction(expr);
|
||||
|
||||
@ -313,7 +315,7 @@ TEST_F(SideEffectsTest, Unary_SE) {
|
||||
|
||||
TEST_F(SideEffectsTest, IndexAccessor_NoSE) {
|
||||
auto* var = Decl(Var("a", ty.array<i32, 10>()));
|
||||
auto* expr = IndexAccessor("a", 0);
|
||||
auto* expr = IndexAccessor("a", 0_i);
|
||||
WrapInFunction(var, expr);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -324,7 +326,7 @@ TEST_F(SideEffectsTest, IndexAccessor_NoSE) {
|
||||
|
||||
TEST_F(SideEffectsTest, IndexAccessor_ObjSE) {
|
||||
MakeSideEffectFunc("se", [&] { return ty.array<i32, 10>(); });
|
||||
auto* expr = IndexAccessor(Call("se"), 0);
|
||||
auto* expr = IndexAccessor(Call("se"), 0_i);
|
||||
WrapInFunction(expr);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/sem/member_accessor_expression.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -190,12 +192,12 @@ TEST_F(ResolverSourceVariableTest, LetCopyVar) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverSourceVariableTest, ThroughIndexAccessor) {
|
||||
// var<private> a : array<f32, 4>;
|
||||
// var<private> a : array<f32, 4u>;
|
||||
// {
|
||||
// a[2]
|
||||
// a[2i]
|
||||
// }
|
||||
auto* a = Global("a", ty.array(ty.f32(), 4), ast::StorageClass::kPrivate);
|
||||
auto* expr = IndexAccessor(a, 2);
|
||||
auto* a = Global("a", ty.array(ty.f32(), 4_u), ast::StorageClass::kPrivate);
|
||||
auto* expr = IndexAccessor(a, 2_i);
|
||||
WrapInFunction(expr);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -140,7 +142,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
||||
|
||||
// Detect unaligned array member for uniform buffers
|
||||
TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_UnalignedMember_Array) {
|
||||
// type Inner = @stride(16) array<f32, 10>;
|
||||
// type Inner = @stride(16) array<f32, 10u>;
|
||||
//
|
||||
// struct Outer {
|
||||
// scalar : f32;
|
||||
@ -149,7 +151,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_UnalignedMember_A
|
||||
//
|
||||
// @group(0) @binding(0)
|
||||
// var<uniform> a : Outer;
|
||||
Alias("Inner", ty.array(ty.f32(), 10, 16));
|
||||
Alias("Inner", ty.array(ty.f32(), 10_u, 16));
|
||||
|
||||
Structure(Source{{12, 34}}, "Outer",
|
||||
{
|
||||
@ -173,7 +175,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_UnalignedMember_A
|
||||
}
|
||||
|
||||
TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_UnalignedMember_Array_SuggestedFix) {
|
||||
// type Inner = @stride(16) array<f32, 10>;
|
||||
// type Inner = @stride(16) array<f32, 10u>;
|
||||
//
|
||||
// struct Outer {
|
||||
// scalar : f32;
|
||||
@ -182,7 +184,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_UnalignedMember_A
|
||||
//
|
||||
// @group(0) @binding(0)
|
||||
// var<uniform> a : Outer;
|
||||
Alias("Inner", ty.array(ty.f32(), 10, 16));
|
||||
Alias("Inner", ty.array(ty.f32(), 10_u, 16));
|
||||
|
||||
Structure(Source{{12, 34}}, "Outer",
|
||||
{
|
||||
@ -347,7 +349,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_Vec3MemberOffset_
|
||||
|
||||
// Detect array stride must be a multiple of 16 bytes for uniform buffers
|
||||
TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStride_Scalar) {
|
||||
// type Inner = array<f32, 10>;
|
||||
// type Inner = array<f32, 10u>;
|
||||
//
|
||||
// struct Outer {
|
||||
// inner : Inner;
|
||||
@ -357,7 +359,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid
|
||||
// @group(0) @binding(0)
|
||||
// var<uniform> a : Outer;
|
||||
|
||||
Alias("Inner", ty.array(ty.f32(), 10));
|
||||
Alias("Inner", ty.array(ty.f32(), 10_u));
|
||||
|
||||
Structure(Source{{12, 34}}, "Outer",
|
||||
{
|
||||
@ -381,7 +383,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid
|
||||
}
|
||||
|
||||
TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStride_Vector) {
|
||||
// type Inner = array<vec2<f32>, 10>;
|
||||
// type Inner = array<vec2<f32>, 10u>;
|
||||
//
|
||||
// struct Outer {
|
||||
// inner : Inner;
|
||||
@ -391,7 +393,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid
|
||||
// @group(0) @binding(0)
|
||||
// var<uniform> a : Outer;
|
||||
|
||||
Alias("Inner", ty.array(ty.vec2<f32>(), 10));
|
||||
Alias("Inner", ty.array(ty.vec2<f32>(), 10_u));
|
||||
|
||||
Structure(Source{{12, 34}}, "Outer",
|
||||
{
|
||||
@ -420,7 +422,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid
|
||||
// a : f32;
|
||||
// b : i32;
|
||||
// }
|
||||
// type Inner = array<ArrayElem, 10>;
|
||||
// type Inner = array<ArrayElem, 10u>;
|
||||
//
|
||||
// struct Outer {
|
||||
// inner : Inner;
|
||||
@ -434,7 +436,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid
|
||||
Member("a", ty.f32()),
|
||||
Member("b", ty.i32()),
|
||||
});
|
||||
Alias("Inner", ty.array(ty.Of(array_elem), 10));
|
||||
Alias("Inner", ty.array(ty.Of(array_elem), 10_u));
|
||||
|
||||
Structure(Source{{12, 34}}, "Outer",
|
||||
{
|
||||
@ -459,8 +461,8 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid
|
||||
|
||||
TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStride_TopLevelArray) {
|
||||
// @group(0) @binding(0)
|
||||
// var<uniform> a : array<f32, 4>;
|
||||
Global(Source{{78, 90}}, "a", ty.array(Source{{34, 56}}, ty.f32(), 4),
|
||||
// var<uniform> a : array<f32, 4u>;
|
||||
Global(Source{{78, 90}}, "a", ty.array(Source{{34, 56}}, ty.f32(), 4_u),
|
||||
ast::StorageClass::kUniform, GroupAndBinding(0, 0));
|
||||
|
||||
ASSERT_FALSE(r()->Resolve());
|
||||
@ -471,15 +473,15 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid
|
||||
|
||||
TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStride_NestedArray) {
|
||||
// struct Outer {
|
||||
// inner : array<array<f32, 4>, 4>
|
||||
// inner : array<array<f32, 4u>, 4u>
|
||||
// };
|
||||
//
|
||||
// @group(0) @binding(0)
|
||||
// var<uniform> a : array<Outer, 4>;
|
||||
// var<uniform> a : array<Outer, 4u>;
|
||||
|
||||
Structure(Source{{12, 34}}, "Outer",
|
||||
{
|
||||
Member("inner", ty.array(Source{{34, 56}}, ty.array(ty.f32(), 4), 4)),
|
||||
Member("inner", ty.array(Source{{34, 56}}, ty.array(ty.f32(), 4_u), 4_u)),
|
||||
});
|
||||
|
||||
Global(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
|
||||
@ -497,7 +499,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid
|
||||
}
|
||||
|
||||
TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStride_SuggestedFix) {
|
||||
// type Inner = @stride(16) array<f32, 10>;
|
||||
// type Inner = @stride(16) array<f32, 10u>;
|
||||
//
|
||||
// struct Outer {
|
||||
// inner : Inner;
|
||||
@ -507,7 +509,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid
|
||||
// @group(0) @binding(0)
|
||||
// var<uniform> a : Outer;
|
||||
|
||||
Alias("Inner", ty.array(ty.f32(), 10, 16));
|
||||
Alias("Inner", ty.array(ty.f32(), 10_u, 16));
|
||||
|
||||
Structure(Source{{12, 34}}, "Outer",
|
||||
{
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/sem/struct.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -137,9 +139,9 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferVector) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverStorageClassValidationTest, StorageBufferArray) {
|
||||
// var<storage, read> g : array<S, 3>;
|
||||
// var<storage, read> g : array<S, 3u>;
|
||||
auto* s = Structure("S", {Member("a", ty.f32())});
|
||||
auto* a = ty.array(ty.Of(s), 3);
|
||||
auto* a = ty.array(ty.Of(s), 3_u);
|
||||
Global(Source{{56, 78}}, "g", a, ast::StorageClass::kStorage, ast::Access::kRead,
|
||||
ast::AttributeList{
|
||||
create<ast::BindingAttribute>(0),
|
||||
@ -285,9 +287,9 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferArray) {
|
||||
// struct S {
|
||||
// @size(16) f : f32;
|
||||
// }
|
||||
// var<uniform> g : array<S, 3>;
|
||||
// var<uniform> g : array<S, 3u>;
|
||||
auto* s = Structure("S", {Member("a", ty.f32(), {MemberSize(16)})});
|
||||
auto* a = ty.array(ty.Of(s), 3);
|
||||
auto* a = ty.array(ty.Of(s), 3_u);
|
||||
Global(Source{{56, 78}}, "g", a, ast::StorageClass::kUniform,
|
||||
ast::AttributeList{
|
||||
create<ast::BindingAttribute>(0),
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/sem/struct.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -164,7 +166,7 @@ TEST_F(ResolverStructLayoutTest, ExplicitStrideArrayRuntimeSized) {
|
||||
|
||||
TEST_F(ResolverStructLayoutTest, ImplicitStrideArrayOfExplicitStrideArray) {
|
||||
auto* inner = ty.array<i32, 2>(/*stride*/ 16); // size: 32
|
||||
auto* outer = ty.array(inner, 12); // size: 12 * 32
|
||||
auto* outer = ty.array(inner, 12_u); // size: 12 * 32
|
||||
auto* s = Structure("S", {
|
||||
Member("c", outer),
|
||||
});
|
||||
@ -187,8 +189,8 @@ TEST_F(ResolverStructLayoutTest, ImplicitStrideArrayOfStructure) {
|
||||
Member("a", ty.vec2<i32>()),
|
||||
Member("b", ty.vec3<i32>()),
|
||||
Member("c", ty.vec4<i32>()),
|
||||
}); // size: 48
|
||||
auto* outer = ty.array(ty.Of(inner), 12); // size: 12 * 48
|
||||
}); // size: 48
|
||||
auto* outer = ty.array(ty.Of(inner), 12_u); // size: 12 * 48
|
||||
auto* s = Structure("S", {
|
||||
Member("c", outer),
|
||||
});
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -120,7 +122,7 @@ TEST_F(ResolverPipelineStageUseTest, StructUsedAsComputeShaderParam) {
|
||||
Structure("S", {Member("a", ty.u32(), {Builtin(ast::Builtin::kLocalInvocationIndex)})});
|
||||
|
||||
Func("main", {Param("param", ty.Of(s))}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -97,7 +99,7 @@ TEST_F(ResolverStorageClassUseTest, StructReachableViaGlobalStruct) {
|
||||
|
||||
TEST_F(ResolverStorageClassUseTest, StructReachableViaGlobalArray) {
|
||||
auto* s = Structure("S", {Member("a", ty.f32())});
|
||||
auto* a = ty.array(ty.Of(s), 3);
|
||||
auto* a = ty.array(ty.Of(s), 3_u);
|
||||
Global("g", a, ast::StorageClass::kPrivate);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -145,7 +147,7 @@ TEST_F(ResolverStorageClassUseTest, StructReachableViaLocalStruct) {
|
||||
|
||||
TEST_F(ResolverStorageClassUseTest, StructReachableViaLocalArray) {
|
||||
auto* s = Structure("S", {Member("a", ty.f32())});
|
||||
auto* a = ty.array(ty.Of(s), 3);
|
||||
auto* a = ty.array(ty.Of(s), 3_u);
|
||||
WrapInFunction(Var("g", a));
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "src/tint/sem/type_constructor.h"
|
||||
#include "src/tint/sem/type_conversion.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -31,14 +33,11 @@ using builder::alias3;
|
||||
using builder::CreatePtrs;
|
||||
using builder::CreatePtrsFor;
|
||||
using builder::DataType;
|
||||
using builder::f32;
|
||||
using builder::i32;
|
||||
using builder::mat2x2;
|
||||
using builder::mat2x3;
|
||||
using builder::mat3x2;
|
||||
using builder::mat3x3;
|
||||
using builder::mat4x4;
|
||||
using builder::u32;
|
||||
using builder::vec2;
|
||||
using builder::vec3;
|
||||
using builder::vec4;
|
||||
@ -60,7 +59,7 @@ constexpr Params ParamsFor() {
|
||||
TEST_F(ResolverTypeConstructorValidationTest, InferTypeTest_Simple) {
|
||||
// var a = 1;
|
||||
// var b = a;
|
||||
auto* a = Var("a", nullptr, ast::StorageClass::kNone, Expr(1));
|
||||
auto* a = Var("a", nullptr, ast::StorageClass::kNone, Expr(1_i));
|
||||
auto* b = Var("b", nullptr, ast::StorageClass::kNone, Expr("a"));
|
||||
auto* a_ident = Expr("a");
|
||||
auto* b_ident = Expr("b");
|
||||
@ -428,7 +427,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ConversionConstructorInvalid_Inval
|
||||
namespace ArrayConstructor {
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Array_ZeroValue_Pass) {
|
||||
// array<u32, 10>();
|
||||
// array<u32, 10u>();
|
||||
auto* tc = array<u32, 10>();
|
||||
WrapInFunction(tc);
|
||||
|
||||
@ -444,8 +443,8 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Array_ZeroValue_P
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Array_type_match) {
|
||||
// array<u32, 3>(0u, 10u. 20u);
|
||||
auto* tc = array<u32, 3>(Expr(0u), Expr(10u), Expr(20u));
|
||||
// array<u32, 3u>(0u, 10u. 20u);
|
||||
auto* tc = array<u32, 3>(Expr(0_u), Expr(10_u), Expr(20_u));
|
||||
WrapInFunction(tc);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -463,8 +462,8 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Array_type_match)
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Array_type_Mismatch_U32F32) {
|
||||
// array<u32, 3>(0u, 1.0f, 20u);
|
||||
auto* tc = array<u32, 3>(Expr(0u), Expr(Source{{12, 34}}, 1.0f), Expr(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));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -475,8 +474,8 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Array_type_Mismat
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Array_ScalarArgumentTypeMismatch_F32I32) {
|
||||
// array<f32, 1>(1);
|
||||
auto* tc = array<f32, 1>(Expr(Source{{12, 34}}, 1));
|
||||
// array<f32, 1u>(1i);
|
||||
auto* tc = array<f32, 1>(Expr(Source{{12, 34}}, 1_i));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -487,8 +486,9 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Array_ScalarArgumentTypeMismatch_U32I32) {
|
||||
// array<u32, 6>(1, 0u, 0u, 0u, 0u, 0u);
|
||||
auto* tc = array<u32, 1>(Expr(Source{{12, 34}}, 1), Expr(0u), Expr(0u), Expr(0u), Expr(0u));
|
||||
// array<u32, 1u>(1i, 0u, 0u, 0u, 0u, 0u);
|
||||
auto* tc =
|
||||
array<u32, 1>(Expr(Source{{12, 34}}, 1_i), Expr(0_u), Expr(0_u), Expr(0_u), Expr(0_u));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -499,8 +499,8 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Array_ScalarArgumentTypeMismatch_Vec2) {
|
||||
// array<i32, 3>(1, vec2<i32>());
|
||||
auto* tc = array<i32, 3>(Expr(1), Construct(Source{{12, 34}}, ty.vec2<i32>()));
|
||||
// array<i32, 3u>(1i, vec2<i32>());
|
||||
auto* tc = array<i32, 3>(Expr(1_i), Construct(Source{{12, 34}}, ty.vec2<i32>()));
|
||||
WrapInFunction(tc);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -510,11 +510,11 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_ArrayOfVector_SubElemTypeMismatch_I32U32) {
|
||||
// array<vec3<i32>, 2>(vec3<i32>(), vec3<u32>());
|
||||
// array<vec3<i32>, 2u>(vec3<i32>(), vec3<u32>());
|
||||
auto* e0 = vec3<i32>();
|
||||
SetSource(Source::Location({12, 34}));
|
||||
auto* e1 = vec3<u32>();
|
||||
auto* t = Construct(ty.array(ty.vec3<i32>(), 2), e0, e1);
|
||||
auto* t = Construct(ty.array(ty.vec3<i32>(), 2_i), e0, e1);
|
||||
WrapInFunction(t);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -525,11 +525,11 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_ArrayOfVector_SubElemTypeMismatch_I32Bool) {
|
||||
// array<vec3<i32>, 2>(vec3<i32>(), vec3<bool>(true, true, false));
|
||||
// array<vec3<i32>, 2u>(vec3<i32>(), vec3<bool>(true, true, false));
|
||||
SetSource(Source::Location({12, 34}));
|
||||
auto* e0 = vec3<bool>(true, true, false);
|
||||
auto* e1 = vec3<i32>();
|
||||
auto* t = Construct(ty.array(ty.vec3<i32>(), 2), e0, e1);
|
||||
auto* t = Construct(ty.array(ty.vec3<i32>(), 2_i), e0, e1);
|
||||
WrapInFunction(t);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -539,11 +539,11 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_ArrayOfArray_SubElemSizeMismatch) {
|
||||
// array<array<i32, 2>, 2>(array<i32, 3>(), array<i32, 2>());
|
||||
// array<array<i32, 2u>, 2u>(array<i32, 3u>(), array<i32, 2u>());
|
||||
SetSource(Source::Location({12, 34}));
|
||||
auto* e0 = array<i32, 3>();
|
||||
auto* e1 = array<i32, 2>();
|
||||
auto* t = Construct(ty.array(ty.array<i32, 2>(), 2), e0, e1);
|
||||
auto* t = Construct(ty.array(ty.array<i32, 2>(), 2_i), e0, e1);
|
||||
WrapInFunction(t);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -553,11 +553,11 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_ArrayOfArray_SubE
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_ArrayOfArray_SubElemTypeMismatch) {
|
||||
// array<array<i32, 2>, 2>(array<i32, 2>(), array<u32, 2>());
|
||||
// array<array<i32, 2u>, 2u>(array<i32, 2u>(), array<u32, 2u>());
|
||||
auto* e0 = array<i32, 2>();
|
||||
SetSource(Source::Location({12, 34}));
|
||||
auto* e1 = array<u32, 2>();
|
||||
auto* t = Construct(ty.array(ty.array<i32, 2>(), 2), e0, e1);
|
||||
auto* t = Construct(ty.array(ty.array<i32, 2>(), 2_i), e0, e1);
|
||||
WrapInFunction(t);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -567,9 +567,9 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_ArrayOfArray_SubE
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Array_TooFewElements) {
|
||||
// array<i32, 4>(1, 2, 3);
|
||||
// array<i32, 4u>(1i, 2i, 3i);
|
||||
SetSource(Source::Location({12, 34}));
|
||||
auto* tc = array<i32, 4>(Expr(1), Expr(2), Expr(3));
|
||||
auto* tc = array<i32, 4>(Expr(1_i), Expr(2_i), Expr(3_i));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -579,9 +579,9 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Array_TooFewEleme
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Array_TooManyElements) {
|
||||
// array<i32, 4>(1, 2, 3, 4, 5);
|
||||
// array<i32, 4u>(1i, 2i, 3i, 4i, 5i);
|
||||
SetSource(Source::Location({12, 34}));
|
||||
auto* tc = array<i32, 4>(Expr(1), Expr(2), Expr(3), Expr(4), Expr(5));
|
||||
auto* tc = array<i32, 4>(Expr(1_i), Expr(2_i), Expr(3_i), Expr(4_i), Expr(5_i));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -592,8 +592,8 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Array_TooManyElem
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Array_Runtime) {
|
||||
// array<i32>(1);
|
||||
auto* tc = array(ty.i32(), nullptr, Expr(Source{{12, 34}}, 1));
|
||||
// array<i32>(1i);
|
||||
auto* tc = array(ty.i32(), nullptr, Expr(Source{{12, 34}}, 1_i));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -614,7 +614,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Array_RuntimeZero
|
||||
namespace ScalarConstructor {
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Construct_i32_Success) {
|
||||
auto* expr = Construct<i32>(Expr(123));
|
||||
auto* expr = Construct<i32>(Expr(123_i));
|
||||
WrapInFunction(expr);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -632,7 +632,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Construct_i32_Success) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Construct_u32_Success) {
|
||||
auto* expr = Construct<u32>(Expr(123u));
|
||||
auto* expr = Construct<u32>(Expr(123_u));
|
||||
WrapInFunction(expr);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -686,7 +686,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Convert_f32_to_i32_Success) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Convert_i32_to_u32_Success) {
|
||||
auto* expr = Construct<u32>(123);
|
||||
auto* expr = Construct<u32>(123_i);
|
||||
WrapInFunction(expr);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -704,7 +704,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Convert_i32_to_u32_Success) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Convert_u32_to_f32_Success) {
|
||||
auto* expr = Construct<f32>(123u);
|
||||
auto* expr = Construct<f32>(123_u);
|
||||
WrapInFunction(expr);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -727,7 +727,7 @@ namespace VectorConstructor {
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec2F32_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec2<f32>(Expr(Source{{12, 34}}, 1), 1.0f);
|
||||
auto* tc = vec2<f32>(Expr(Source{{12, 34}}, 1_i), 1.0f);
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -738,7 +738,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec2U32_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec2<u32>(1u, Expr(Source{{12, 34}}, 1));
|
||||
auto* tc = vec2<u32>(1_u, Expr(Source{{12, 34}}, 1_i));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -749,7 +749,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec2I32_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec2<i32>(Expr(Source{{12, 34}}, 1u), 1);
|
||||
auto* tc = vec2<i32>(Expr(Source{{12, 34}}, 1_u), 1_i);
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -760,7 +760,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec2Bool_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec2<bool>(true, Expr(Source{{12, 34}}, 1));
|
||||
auto* tc = vec2<bool>(true, Expr(Source{{12, 34}}, 1_i));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -865,7 +865,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec2F32_Success_S
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec2U32_Success_Scalar) {
|
||||
auto* tc = vec2<u32>(1u, 1u);
|
||||
auto* tc = vec2<u32>(1_u, 1_u);
|
||||
WrapInFunction(tc);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -886,7 +886,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec2U32_Success_S
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec2I32_Success_Scalar) {
|
||||
auto* tc = vec2<i32>(1, 1);
|
||||
auto* tc = vec2<i32>(1_i, 1_i);
|
||||
WrapInFunction(tc);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -969,7 +969,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec2_Success_Vec2
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec3F32_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec3<f32>(1.0f, 1.0f, Expr(Source{{12, 34}}, 1));
|
||||
auto* tc = vec3<f32>(1.0f, 1.0f, Expr(Source{{12, 34}}, 1_i));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -980,7 +980,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec3U32_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec3<u32>(1u, Expr(Source{{12, 34}}, 1), 1u);
|
||||
auto* tc = vec3<u32>(1_u, Expr(Source{{12, 34}}, 1_i), 1_u);
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -991,7 +991,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec3I32_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec3<i32>(1, Expr(Source{{12, 34}}, 1u), 1);
|
||||
auto* tc = vec3<i32>(1_i, Expr(Source{{12, 34}}, 1_u), 1_i);
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -1002,7 +1002,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec3Bool_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec3<bool>(true, Expr(Source{{12, 34}}, 1), false);
|
||||
auto* tc = vec3<bool>(true, Expr(Source{{12, 34}}, 1_i), false);
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -1124,7 +1124,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3F32_Success_S
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3U32_Success_Scalar) {
|
||||
auto* tc = vec3<u32>(1u, 1u, 1u);
|
||||
auto* tc = vec3<u32>(1_u, 1_u, 1_u);
|
||||
WrapInFunction(tc);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -1146,7 +1146,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3U32_Success_S
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3I32_Success_Scalar) {
|
||||
auto* tc = vec3<i32>(1, 1, 1);
|
||||
auto* tc = vec3<i32>(1_i, 1_i, 1_i);
|
||||
WrapInFunction(tc);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -1273,7 +1273,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Success_Vec3
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec4F32_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec4<f32>(1.0f, 1.0f, Expr(Source{{12, 34}}, 1), 1.0f);
|
||||
auto* tc = vec4<f32>(1.0f, 1.0f, Expr(Source{{12, 34}}, 1_i), 1.0f);
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -1284,7 +1284,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec4U32_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec4<u32>(1u, 1u, Expr(Source{{12, 34}}, 1), 1u);
|
||||
auto* tc = vec4<u32>(1_u, 1_u, Expr(Source{{12, 34}}, 1_i), 1_u);
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -1295,7 +1295,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec4I32_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec4<i32>(1, 1, Expr(Source{{12, 34}}, 1u), 1);
|
||||
auto* tc = vec4<i32>(1_i, 1_i, Expr(Source{{12, 34}}, 1_u), 1_i);
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -1306,7 +1306,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec4Bool_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec4<bool>(true, false, Expr(Source{{12, 34}}, 1), true);
|
||||
auto* tc = vec4<bool>(true, false, Expr(Source{{12, 34}}, 1_i), true);
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -1457,7 +1457,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4F32_Success_S
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4U32_Success_Scalar) {
|
||||
auto* tc = vec4<u32>(1u, 1u, 1u, 1u);
|
||||
auto* tc = vec4<u32>(1_u, 1_u, 1_u, 1_u);
|
||||
WrapInFunction(tc);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -1469,7 +1469,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4U32_Success_S
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4I32_Success_Scalar) {
|
||||
auto* tc = vec4<i32>(1, 1, 1, 1);
|
||||
auto* tc = vec4<i32>(1_i, 1_i, 1_i, 1_i);
|
||||
WrapInFunction(tc);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
@ -1641,7 +1641,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vector_ElementTyp
|
||||
|
||||
// vec2<Float32>(1.0f, 1u)
|
||||
auto* vec_type = ty.vec(ty.Of(f32_alias), 2);
|
||||
auto* tc = Construct(Source{{12, 34}}, vec_type, 1.0f, Expr(Source{{12, 40}}, 1u));
|
||||
auto* tc = Construct(Source{{12, 34}}, vec_type, 1.0f, Expr(Source{{12, 40}}, 1_u));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -1690,8 +1690,8 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, InferVec2ElementTypeFromScalars) {
|
||||
auto* vec2_bool = Construct(create<ast::Vector>(nullptr, 2), Expr(true), Expr(false));
|
||||
auto* vec2_i32 = Construct(create<ast::Vector>(nullptr, 2), Expr(1), Expr(2));
|
||||
auto* vec2_u32 = Construct(create<ast::Vector>(nullptr, 2), Expr(1u), Expr(2u));
|
||||
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_f32 = Construct(create<ast::Vector>(nullptr, 2), Expr(1.0f), Expr(2.0f));
|
||||
WrapInFunction(vec2_bool, vec2_i32, vec2_u32, vec2_f32);
|
||||
|
||||
@ -1717,8 +1717,8 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec2ElementTypeFromScalars) {
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, InferVec2ElementTypeFromVec2) {
|
||||
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, 2));
|
||||
auto* vec2_u32 = Construct(create<ast::Vector>(nullptr, 2), vec2<u32>(1u, 2u));
|
||||
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_f32 = Construct(create<ast::Vector>(nullptr, 2), vec2<f32>(1.0f, 2.0f));
|
||||
WrapInFunction(vec2_bool, vec2_i32, vec2_u32, vec2_f32);
|
||||
|
||||
@ -1745,8 +1745,8 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec2ElementTypeFromVec2) {
|
||||
TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromScalars) {
|
||||
auto* vec3_bool =
|
||||
Construct(create<ast::Vector>(nullptr, 3), Expr(true), Expr(false), Expr(true));
|
||||
auto* vec3_i32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1), Expr(2), Expr(3));
|
||||
auto* vec3_u32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1u), Expr(2u), Expr(3u));
|
||||
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_f32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1.0f), Expr(2.0f), Expr(3.0f));
|
||||
WrapInFunction(vec3_bool, vec3_i32, vec3_u32, vec3_f32);
|
||||
|
||||
@ -1772,8 +1772,8 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromScalars) {
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromVec3) {
|
||||
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, 2, 3));
|
||||
auto* vec3_u32 = Construct(create<ast::Vector>(nullptr, 3), vec3<u32>(1u, 2u, 3u));
|
||||
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_f32 = Construct(create<ast::Vector>(nullptr, 3), vec3<f32>(1.0f, 2.0f, 3.0f));
|
||||
WrapInFunction(vec3_bool, vec3_i32, vec3_u32, vec3_f32);
|
||||
|
||||
@ -1800,8 +1800,8 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromVec3) {
|
||||
TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromScalarAndVec2) {
|
||||
auto* vec3_bool =
|
||||
Construct(create<ast::Vector>(nullptr, 3), Expr(true), vec2<bool>(false, true));
|
||||
auto* vec3_i32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1), vec2<i32>(2, 3));
|
||||
auto* vec3_u32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1u), vec2<u32>(2u, 3u));
|
||||
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_f32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1.0f), vec2<f32>(2.0f, 3.0f));
|
||||
WrapInFunction(vec3_bool, vec3_i32, vec3_u32, vec3_f32);
|
||||
|
||||
@ -1828,9 +1828,10 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromScalarAndV
|
||||
TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromScalars) {
|
||||
auto* vec4_bool = Construct(create<ast::Vector>(nullptr, 4), Expr(true), Expr(false),
|
||||
Expr(true), Expr(false));
|
||||
auto* vec4_i32 = Construct(create<ast::Vector>(nullptr, 4), Expr(1), Expr(2), Expr(3), Expr(4));
|
||||
auto* vec4_i32 =
|
||||
Construct(create<ast::Vector>(nullptr, 4), Expr(1_i), Expr(2_i), Expr(3_i), Expr(4_i));
|
||||
auto* vec4_u32 =
|
||||
Construct(create<ast::Vector>(nullptr, 4), Expr(1u), Expr(2u), Expr(3u), Expr(4u));
|
||||
Construct(create<ast::Vector>(nullptr, 4), Expr(1_u), Expr(2_u), Expr(3_u), Expr(4_u));
|
||||
auto* vec4_f32 =
|
||||
Construct(create<ast::Vector>(nullptr, 4), Expr(1.0f), Expr(2.0f), Expr(3.0f), Expr(4.0f));
|
||||
WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32);
|
||||
@ -1858,8 +1859,8 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromScalars) {
|
||||
TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromVec4) {
|
||||
auto* vec4_bool =
|
||||
Construct(create<ast::Vector>(nullptr, 4), vec4<bool>(true, false, true, false));
|
||||
auto* vec4_i32 = Construct(create<ast::Vector>(nullptr, 4), vec4<i32>(1, 2, 3, 4));
|
||||
auto* vec4_u32 = Construct(create<ast::Vector>(nullptr, 4), vec4<u32>(1u, 2u, 3u, 4u));
|
||||
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_f32 = Construct(create<ast::Vector>(nullptr, 4), vec4<f32>(1.0f, 2.0f, 3.0f, 4.0f));
|
||||
WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32);
|
||||
|
||||
@ -1886,8 +1887,10 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromVec4) {
|
||||
TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromScalarAndVec3) {
|
||||
auto* vec4_bool =
|
||||
Construct(create<ast::Vector>(nullptr, 4), Expr(true), vec3<bool>(false, true, false));
|
||||
auto* vec4_i32 = Construct(create<ast::Vector>(nullptr, 4), Expr(1), vec3<i32>(2, 3, 4));
|
||||
auto* vec4_u32 = Construct(create<ast::Vector>(nullptr, 4), Expr(1u), vec3<u32>(2u, 3u, 4u));
|
||||
auto* vec4_i32 =
|
||||
Construct(create<ast::Vector>(nullptr, 4), Expr(1_i), vec3<i32>(2_i, 3_i, 4_i));
|
||||
auto* vec4_u32 =
|
||||
Construct(create<ast::Vector>(nullptr, 4), Expr(1_u), vec3<u32>(2_u, 3_u, 4_u));
|
||||
auto* vec4_f32 =
|
||||
Construct(create<ast::Vector>(nullptr, 4), Expr(1.0f), vec3<f32>(2.0f, 3.0f, 4.0f));
|
||||
WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32);
|
||||
@ -1915,9 +1918,10 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromScalarAndV
|
||||
TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromVec2AndVec2) {
|
||||
auto* vec4_bool = Construct(create<ast::Vector>(nullptr, 4), vec2<bool>(true, false),
|
||||
vec2<bool>(true, false));
|
||||
auto* vec4_i32 = Construct(create<ast::Vector>(nullptr, 4), vec2<i32>(1, 2), vec2<i32>(3, 4));
|
||||
auto* vec4_i32 =
|
||||
Construct(create<ast::Vector>(nullptr, 4), vec2<i32>(1_i, 2_i), vec2<i32>(3_i, 4_i));
|
||||
auto* vec4_u32 =
|
||||
Construct(create<ast::Vector>(nullptr, 4), vec2<u32>(1u, 2u), vec2<u32>(3u, 4u));
|
||||
Construct(create<ast::Vector>(nullptr, 4), vec2<u32>(1_u, 2_u), vec2<u32>(3_u, 4_u));
|
||||
auto* vec4_f32 =
|
||||
Construct(create<ast::Vector>(nullptr, 4), vec2<f32>(1.0f, 2.0f), vec2<f32>(3.0f, 4.0f));
|
||||
WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32);
|
||||
@ -1951,8 +1955,8 @@ TEST_F(ResolverTypeConstructorValidationTest, CannotInferVectorElementTypeWithou
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec2ElementTypeFromScalarsMismatch) {
|
||||
WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 2),
|
||||
Expr(Source{{1, 2}}, 1), //
|
||||
Expr(Source{{1, 3}}, 2u)));
|
||||
Expr(Source{{1, 2}}, 1_i), //
|
||||
Expr(Source{{1, 3}}, 2_u)));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
@ -1964,9 +1968,9 @@ TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec2ElementTypeFromScal
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec3ElementTypeFromScalarsMismatch) {
|
||||
WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 3),
|
||||
Expr(Source{{1, 2}}, 1), //
|
||||
Expr(Source{{1, 3}}, 2u), //
|
||||
Expr(Source{{1, 4}}, 3)));
|
||||
Expr(Source{{1, 2}}, 1_i), //
|
||||
Expr(Source{{1, 3}}, 2_u), //
|
||||
Expr(Source{{1, 4}}, 3_i)));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
@ -1979,7 +1983,7 @@ TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec3ElementTypeFromScal
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec3ElementTypeFromScalarAndVec2Mismatch) {
|
||||
WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 3),
|
||||
Expr(Source{{1, 2}}, 1), //
|
||||
Expr(Source{{1, 2}}, 1_i), //
|
||||
Construct(Source{{1, 3}}, ty.vec2<f32>(), 2.0f, 3.0f)));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -1992,10 +1996,10 @@ TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec3ElementTypeFromScal
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromScalarsMismatch) {
|
||||
WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 4),
|
||||
Expr(Source{{1, 2}}, 1), //
|
||||
Expr(Source{{1, 3}}, 2), //
|
||||
Expr(Source{{1, 2}}, 1_i), //
|
||||
Expr(Source{{1, 3}}, 2_i), //
|
||||
Expr(Source{{1, 4}}, 3.0f), //
|
||||
Expr(Source{{1, 5}}, 4)));
|
||||
Expr(Source{{1, 5}}, 4_i)));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
@ -2009,8 +2013,8 @@ TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromScal
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromScalarAndVec3Mismatch) {
|
||||
WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 4),
|
||||
Expr(Source{{1, 2}}, 1), //
|
||||
Construct(Source{{1, 3}}, ty.vec3<u32>(), 2u, 3u, 4u)));
|
||||
Expr(Source{{1, 2}}, 1_i), //
|
||||
Construct(Source{{1, 3}}, ty.vec3<u32>(), 2_u, 3_u, 4_u)));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
@ -2022,8 +2026,8 @@ TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromScal
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromVec2AndVec2Mismatch) {
|
||||
WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 4),
|
||||
Construct(Source{{1, 2}}, ty.vec2<i32>(), 3, 4), //
|
||||
Construct(Source{{1, 3}}, ty.vec2<u32>(), 3u, 4u)));
|
||||
Construct(Source{{1, 2}}, ty.vec2<i32>(), 3_i, 4_i), //
|
||||
Construct(Source{{1, 3}}, ty.vec2<u32>(), 3_u, 4_u)));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
@ -2179,7 +2183,7 @@ TEST_P(MatrixConstructorTest, Expr_ElementConstructor_Error_InvalidArgumentType)
|
||||
std::stringstream args_tys;
|
||||
ast::ExpressionList args;
|
||||
for (uint32_t i = 1; i <= param.columns; i++) {
|
||||
args.push_back(Expr(Source{{12, i}}, 1u));
|
||||
args.push_back(Expr(Source{{12, i}}, 1_u));
|
||||
if (i > 1) {
|
||||
args_tys << ", ";
|
||||
}
|
||||
@ -2527,12 +2531,9 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeConstructorValidationTest,
|
||||
namespace StructConstructor {
|
||||
using builder::CreatePtrs;
|
||||
using builder::CreatePtrsFor;
|
||||
using builder::f32;
|
||||
using builder::i32;
|
||||
using builder::mat2x2;
|
||||
using builder::mat3x3;
|
||||
using builder::mat4x4;
|
||||
using builder::u32;
|
||||
using builder::vec2;
|
||||
using builder::vec3;
|
||||
using builder::vec4;
|
||||
@ -2659,7 +2660,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Struct_Nested) {
|
||||
auto* m2 = Member("m2", ty.i32());
|
||||
auto* s = Structure("s", {m0, m1, m2});
|
||||
|
||||
auto* tc = Construct(Source{{12, 34}}, ty.Of(s), 1, 1, 1);
|
||||
auto* tc = Construct(Source{{12, 34}}, ty.Of(s), 1_i, 1_i, 1_i);
|
||||
WrapInFunction(tc);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -2695,7 +2696,8 @@ TEST_F(ResolverTypeConstructorValidationTest, NonConstructibleType_Atomic) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, NonConstructibleType_AtomicArray) {
|
||||
WrapInFunction(Assign(Phony(), Construct(Source{{12, 34}}, ty.array(ty.atomic(ty.i32()), 4))));
|
||||
WrapInFunction(
|
||||
Assign(Phony(), Construct(Source{{12, 34}}, ty.array(ty.atomic(ty.i32()), 4_i))));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array constructor has non-constructible element type");
|
||||
@ -2725,7 +2727,7 @@ TEST_F(ResolverTypeConstructorValidationTest, TypeConstructorAsStatement) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, TypeConversionAsStatement) {
|
||||
WrapInFunction(CallStmt(Construct(Source{{12, 34}}, ty.f32(), 1)));
|
||||
WrapInFunction(CallStmt(Construct(Source{{12, 34}}, ty.f32(), 1_i)));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: type cast evaluated but not used");
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -50,9 +52,6 @@ template <typename T>
|
||||
using alias2 = builder::alias2<T>;
|
||||
template <typename T>
|
||||
using alias3 = builder::alias3<T>;
|
||||
using f32 = builder::f32;
|
||||
using i32 = builder::i32;
|
||||
using u32 = builder::u32;
|
||||
|
||||
class ResolverTypeValidationTest : public resolver::TestHelper, public testing::Test {};
|
||||
|
||||
@ -63,7 +62,7 @@ TEST_F(ResolverTypeValidationTest, VariableDeclNoConstructor_Pass) {
|
||||
// }
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, nullptr);
|
||||
auto* lhs = Expr("a");
|
||||
auto* rhs = Expr(2);
|
||||
auto* rhs = Expr(2_i);
|
||||
|
||||
auto* body = Block(Decl(var), Assign(Source{Source::Location{12, 34}}, lhs, rhs));
|
||||
|
||||
@ -191,49 +190,49 @@ TEST_F(ResolverTypeValidationTest, RedeclaredIdentifierDifferentFunctions_Pass)
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedLiteral_Pass) {
|
||||
// var<private> a : array<f32, 4u>;
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 4u)), ast::StorageClass::kPrivate);
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 4_u)), ast::StorageClass::kPrivate);
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_SignedLiteral_Pass) {
|
||||
// var<private> a : array<f32, 4>;
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 4)), ast::StorageClass::kPrivate);
|
||||
// var<private> a : array<f32, 4i>;
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 4_i)), ast::StorageClass::kPrivate);
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedConstant_Pass) {
|
||||
// let size = 4u;
|
||||
// var<private> a : array<f32, size>;
|
||||
GlobalConst("size", nullptr, Expr(4u));
|
||||
GlobalConst("size", nullptr, Expr(4_u));
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_SignedConstant_Pass) {
|
||||
// let size = 4;
|
||||
// let size = 4i;
|
||||
// var<private> a : array<f32, size>;
|
||||
GlobalConst("size", nullptr, Expr(4));
|
||||
GlobalConst("size", nullptr, Expr(4_i));
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedLiteral_Zero) {
|
||||
// var<private> a : array<f32, 0u>;
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0u)), ast::StorageClass::kPrivate);
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0_u)), ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size must be at least 1");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_SignedLiteral_Zero) {
|
||||
// var<private> a : array<f32, 0>;
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0)), ast::StorageClass::kPrivate);
|
||||
// var<private> a : array<f32, 0i>;
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0_i)), ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size must be at least 1");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_SignedLiteral_Negative) {
|
||||
// var<private> a : array<f32, -10>;
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, -10)), ast::StorageClass::kPrivate);
|
||||
// var<private> a : array<f32, -10i>;
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, i32(-10))), ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size must be at least 1");
|
||||
}
|
||||
@ -241,25 +240,25 @@ TEST_F(ResolverTypeValidationTest, ArraySize_SignedLiteral_Negative) {
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedConstant_Zero) {
|
||||
// let size = 0u;
|
||||
// var<private> a : array<f32, size>;
|
||||
GlobalConst("size", nullptr, Expr(0u));
|
||||
GlobalConst("size", nullptr, Expr(0_u));
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size must be at least 1");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_SignedConstant_Zero) {
|
||||
// let size = 0;
|
||||
// let size = 0i;
|
||||
// var<private> a : array<f32, size>;
|
||||
GlobalConst("size", nullptr, Expr(0));
|
||||
GlobalConst("size", nullptr, Expr(0_i));
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size must be at least 1");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_SignedConstant_Negative) {
|
||||
// let size = -10;
|
||||
// let size = -10i;
|
||||
// var<private> a : array<f32, size>;
|
||||
GlobalConst("size", nullptr, Expr(-10));
|
||||
GlobalConst("size", nullptr, Expr(i32(-10)));
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size must be at least 1");
|
||||
@ -274,7 +273,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_FloatLiteral) {
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_IVecLiteral) {
|
||||
// var<private> a : array<f32, vec2<i32>(10, 10)>;
|
||||
Global("a", ty.array(ty.f32(), Construct(Source{{12, 34}}, ty.vec2<i32>(), 10, 10)),
|
||||
Global("a", ty.array(ty.f32(), Construct(Source{{12, 34}}, ty.vec2<i32>(), 10_i, 10_i)),
|
||||
ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size must be integer scalar");
|
||||
@ -292,15 +291,15 @@ TEST_F(ResolverTypeValidationTest, ArraySize_FloatConstant) {
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_IVecConstant) {
|
||||
// let size = vec2<i32>(100, 100);
|
||||
// var<private> a : array<f32, size>;
|
||||
GlobalConst("size", nullptr, Construct(ty.vec2<i32>(), 100, 100));
|
||||
GlobalConst("size", nullptr, Construct(ty.vec2<i32>(), 100_i, 100_i));
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size must be integer scalar");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_TooBig_ImplicitStride) {
|
||||
// var<private> a : array<f32, 0x40000000>;
|
||||
Global("a", ty.array(Source{{12, 34}}, ty.f32(), 0x40000000), ast::StorageClass::kPrivate);
|
||||
// var<private> a : array<f32, 0x40000000u>;
|
||||
Global("a", ty.array(Source{{12, 34}}, ty.f32(), 0x40000000_u), ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: array size in bytes must not exceed 0xffffffff, but "
|
||||
@ -308,8 +307,8 @@ TEST_F(ResolverTypeValidationTest, ArraySize_TooBig_ImplicitStride) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_TooBig_ExplicitStride) {
|
||||
// var<private> a : @stride(8) array<f32, 0x20000000>;
|
||||
Global("a", ty.array(Source{{12, 34}}, ty.f32(), 0x20000000, 8), ast::StorageClass::kPrivate);
|
||||
// var<private> a : @stride(8) array<f32, 0x20000000u>;
|
||||
Global("a", ty.array(Source{{12, 34}}, ty.f32(), 0x20000000_u, 8), ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: array size in bytes must not exceed 0xffffffff, but "
|
||||
@ -317,18 +316,18 @@ TEST_F(ResolverTypeValidationTest, ArraySize_TooBig_ExplicitStride) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_OverridableConstant) {
|
||||
// override size = 10;
|
||||
// override size = 10i;
|
||||
// var<private> a : array<f32, size>;
|
||||
Override("size", nullptr, Expr(10));
|
||||
Override("size", nullptr, Expr(10_i));
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size expression must not be pipeline-overridable");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_ModuleVar) {
|
||||
// var<private> size : i32 = 10;
|
||||
// var<private> size : i32 = 10i;
|
||||
// var<private> a : array<f32, size>;
|
||||
Global("size", ty.i32(), Expr(10), ast::StorageClass::kPrivate);
|
||||
Global("size", ty.i32(), Expr(10_i), ast::StorageClass::kPrivate);
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size identifier must be a module-scope constant");
|
||||
@ -339,7 +338,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_FunctionConstant) {
|
||||
// let size = 10;
|
||||
// var a : array<f32, size>;
|
||||
// }
|
||||
auto* size = Let("size", nullptr, Expr(10));
|
||||
auto* size = Let("size", nullptr, Expr(10_i));
|
||||
auto* a = Var("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")));
|
||||
WrapInFunction(Block(Decl(size), Decl(a)));
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -347,10 +346,9 @@ TEST_F(ResolverTypeValidationTest, ArraySize_FunctionConstant) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_InvalidExpr) {
|
||||
// var a : array<f32, i32(4)>;
|
||||
auto* size = Let("size", nullptr, Expr(10));
|
||||
auto* a = Var("a", ty.array(ty.f32(), Construct(Source{{12, 34}}, ty.i32(), 4)));
|
||||
WrapInFunction(Block(Decl(size), Decl(a)));
|
||||
// var a : array<f32, i32(4i)>;
|
||||
auto* a = Var("a", ty.array(ty.f32(), Construct(Source{{12, 34}}, ty.i32(), 4_i)));
|
||||
WrapInFunction(Block(Decl(a)));
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: array size expression must be either a literal or a "
|
||||
@ -457,10 +455,10 @@ TEST_F(ResolverTypeValidationTest, RuntimeArrayIsLast_Pass) {
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, RuntimeArrayInArray) {
|
||||
// struct Foo {
|
||||
// rt : array<array<f32>, 4>;
|
||||
// rt : array<array<f32>, 4u>;
|
||||
// };
|
||||
|
||||
Structure("Foo", {Member("rt", ty.array(Source{{12, 34}}, ty.array<f32>(), 4))});
|
||||
Structure("Foo", {Member("rt", ty.array(Source{{12, 34}}, ty.array<f32>(), 4_u))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve()) << r()->error();
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -475,7 +473,7 @@ TEST_F(ResolverTypeValidationTest, RuntimeArrayInStructInArray) {
|
||||
// var<private> a : array<Foo, 4>;
|
||||
|
||||
auto* foo = Structure("Foo", {Member("rt", ty.array<f32>())});
|
||||
Global("v", ty.array(Source{{12, 34}}, ty.Of(foo), 4), ast::StorageClass::kPrivate);
|
||||
Global("v", ty.array(Source{{12, 34}}, ty.Of(foo), 4_u), ast::StorageClass::kPrivate);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve()) << r()->error();
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -624,7 +622,7 @@ TEST_F(ResolverTypeValidationTest, AliasRuntimeArrayIsLast_Pass) {
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArrayOfNonStorableType) {
|
||||
auto* tex_ty = ty.sampled_texture(ast::TextureDimension::k2d, ty.f32());
|
||||
Global("arr", ty.array(Source{{12, 34}}, tex_ty, 4), ast::StorageClass::kPrivate);
|
||||
Global("arr", ty.array(Source{{12, 34}}, tex_ty, 4_i), ast::StorageClass::kPrivate);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
|
@ -41,6 +41,8 @@
|
||||
using ::testing::ElementsAre;
|
||||
using ::testing::HasSubstr;
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -169,7 +171,7 @@ TEST_F(ResolverValidationTest, AssignmentStmt_InvalidLHS_BuiltinFunctionName) {
|
||||
// normalize = 2;
|
||||
|
||||
auto* lhs = Expr(Source{{12, 34}}, "normalize");
|
||||
auto* rhs = Expr(2);
|
||||
auto* rhs = Expr(2_i);
|
||||
auto* assign = Assign(lhs, rhs);
|
||||
WrapInFunction(assign);
|
||||
|
||||
@ -181,7 +183,7 @@ TEST_F(ResolverValidationTest, UsingUndefinedVariable_Fail) {
|
||||
// b = 2;
|
||||
|
||||
auto* lhs = Expr(Source{{12, 34}}, "b");
|
||||
auto* rhs = Expr(2);
|
||||
auto* rhs = Expr(2_i);
|
||||
auto* assign = Assign(lhs, rhs);
|
||||
WrapInFunction(assign);
|
||||
|
||||
@ -195,7 +197,7 @@ TEST_F(ResolverValidationTest, UsingUndefinedVariableInBlockStatement_Fail) {
|
||||
// }
|
||||
|
||||
auto* lhs = Expr(Source{{12, 34}}, "b");
|
||||
auto* rhs = Expr(2);
|
||||
auto* rhs = Expr(2_i);
|
||||
|
||||
auto* body = Block(Assign(lhs, rhs));
|
||||
WrapInFunction(body);
|
||||
@ -444,7 +446,7 @@ TEST_F(ResolverValidationTest,
|
||||
|
||||
auto error_loc = Source{{12, 34}};
|
||||
auto* body = Block(Continue(), Decl(error_loc, Var("z", ty.i32(), ast::StorageClass::kNone)));
|
||||
auto* continuing = Block(Assign(Expr("z"), 2));
|
||||
auto* continuing = Block(Assign(Expr("z"), 2_i));
|
||||
auto* loop_stmt = Loop(body, continuing);
|
||||
WrapInFunction(loop_stmt);
|
||||
|
||||
@ -464,14 +466,14 @@ TEST_F(ResolverValidationTest, Stmt_Loop_ContinueInLoopBodyAfterDecl_UsageInCont
|
||||
// continue; // Ok
|
||||
//
|
||||
// continuing {
|
||||
// z = 2;
|
||||
// z = 2i;
|
||||
// }
|
||||
// }
|
||||
|
||||
auto* body =
|
||||
Block(If(false, Block(Break())), //
|
||||
Decl(Var("z", ty.i32(), ast::StorageClass::kNone)), Block(Block(Block(Continue()))));
|
||||
auto* continuing = Block(Assign(Expr("z"), 2));
|
||||
auto* continuing = Block(Assign(Expr("z"), 2_i));
|
||||
auto* loop_stmt = Loop(body, continuing);
|
||||
WrapInFunction(loop_stmt);
|
||||
|
||||
@ -485,7 +487,7 @@ TEST_F(ResolverValidationTest, Stmt_Loop_ContinueInLoopBodySubscopeBeforeDecl_Us
|
||||
// }
|
||||
// var z : i32;
|
||||
// continuing {
|
||||
// z = 2;
|
||||
// z = 2i;
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -494,7 +496,7 @@ TEST_F(ResolverValidationTest, Stmt_Loop_ContinueInLoopBodySubscopeBeforeDecl_Us
|
||||
auto ref_loc = Source{{90, 12}};
|
||||
auto* body = Block(If(Expr(true), Block(Continue(cont_loc))),
|
||||
Decl(Var(decl_loc, "z", ty.i32(), ast::StorageClass::kNone)));
|
||||
auto* continuing = Block(Assign(Expr(ref_loc, "z"), 2));
|
||||
auto* continuing = Block(Assign(Expr(ref_loc, "z"), 2_i));
|
||||
auto* loop_stmt = Loop(body, continuing);
|
||||
WrapInFunction(loop_stmt);
|
||||
|
||||
@ -514,7 +516,7 @@ TEST_F(ResolverValidationTest,
|
||||
// var z : i32;
|
||||
// continuing {
|
||||
// if (true) {
|
||||
// z = 2; // Must fail even if z is in a sub-scope
|
||||
// z = 2i; // Must fail even if z is in a sub-scope
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@ -525,7 +527,7 @@ TEST_F(ResolverValidationTest,
|
||||
auto* body = Block(If(Expr(true), Block(Continue(cont_loc))),
|
||||
Decl(Var(decl_loc, "z", ty.i32(), ast::StorageClass::kNone)));
|
||||
|
||||
auto* continuing = Block(If(Expr(true), Block(Assign(Expr(ref_loc, "z"), 2))));
|
||||
auto* continuing = Block(If(Expr(true), Block(Assign(Expr(ref_loc, "z"), 2_i))));
|
||||
auto* loop_stmt = Loop(body, continuing);
|
||||
WrapInFunction(loop_stmt);
|
||||
|
||||
@ -545,7 +547,7 @@ TEST_F(ResolverValidationTest, Stmt_Loop_ContinueInLoopBodySubscopeBeforeDecl_Us
|
||||
// continuing {
|
||||
// // Must fail even if z is used in an expression that isn't
|
||||
// // directly contained inside a block.
|
||||
// if (z < 2) {
|
||||
// if (z < 2i) {
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@ -556,7 +558,7 @@ TEST_F(ResolverValidationTest, Stmt_Loop_ContinueInLoopBodySubscopeBeforeDecl_Us
|
||||
auto* body = Block(If(Expr(true), Block(Continue(cont_loc))),
|
||||
Decl(Var(decl_loc, "z", ty.i32(), ast::StorageClass::kNone)));
|
||||
auto* compare =
|
||||
create<ast::BinaryExpression>(ast::BinaryOp::kLessThan, Expr(ref_loc, "z"), Expr(2));
|
||||
create<ast::BinaryExpression>(ast::BinaryOp::kLessThan, Expr(ref_loc, "z"), Expr(2_i));
|
||||
auto* continuing = Block(If(compare, Block()));
|
||||
auto* loop_stmt = Loop(body, continuing);
|
||||
WrapInFunction(loop_stmt);
|
||||
@ -577,7 +579,7 @@ TEST_F(ResolverValidationTest,
|
||||
// var z : i32;
|
||||
// continuing {
|
||||
// loop {
|
||||
// z = 2; // Must fail even if z is in a sub-scope
|
||||
// z = 2i; // Must fail even if z is in a sub-scope
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@ -588,7 +590,7 @@ TEST_F(ResolverValidationTest,
|
||||
auto* body = Block(If(Expr(true), Block(Continue(cont_loc))),
|
||||
Decl(Var(decl_loc, "z", ty.i32(), ast::StorageClass::kNone)));
|
||||
|
||||
auto* continuing = Block(Loop(Block(Assign(Expr(ref_loc, "z"), 2))));
|
||||
auto* continuing = Block(Loop(Block(Assign(Expr(ref_loc, "z"), 2_i))));
|
||||
auto* loop_stmt = Loop(body, continuing);
|
||||
WrapInFunction(loop_stmt);
|
||||
|
||||
@ -608,7 +610,7 @@ TEST_F(ResolverValidationTest, Stmt_Loop_ContinueInNestedLoopBodyBeforeDecl_Usag
|
||||
// var z : i32;
|
||||
// break;
|
||||
// continuing {
|
||||
// z = 2;
|
||||
// z = 2i;
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -618,7 +620,7 @@ TEST_F(ResolverValidationTest, Stmt_Loop_ContinueInNestedLoopBodyBeforeDecl_Usag
|
||||
auto* body = Block(inner_loop, //
|
||||
Decl(Var("z", ty.i32(), ast::StorageClass::kNone)), //
|
||||
Break());
|
||||
auto* continuing = Block(Assign("z", 2));
|
||||
auto* continuing = Block(Assign("z", 2_i));
|
||||
auto* loop_stmt = Loop(body, continuing);
|
||||
WrapInFunction(loop_stmt);
|
||||
|
||||
@ -636,7 +638,7 @@ TEST_F(ResolverValidationTest,
|
||||
// break;
|
||||
// continuing {
|
||||
// if (true) {
|
||||
// z = 2;
|
||||
// z = 2i;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@ -646,7 +648,7 @@ TEST_F(ResolverValidationTest,
|
||||
auto* body = Block(inner_loop, //
|
||||
Decl(Var("z", ty.i32(), ast::StorageClass::kNone)), //
|
||||
Break());
|
||||
auto* continuing = Block(If(Expr(true), Block(Assign("z", 2))));
|
||||
auto* continuing = Block(If(Expr(true), Block(Assign("z", 2_i))));
|
||||
auto* loop_stmt = Loop(body, continuing);
|
||||
WrapInFunction(loop_stmt);
|
||||
|
||||
@ -663,7 +665,7 @@ TEST_F(ResolverValidationTest, Stmt_Loop_ContinueInNestedLoopBodyBeforeDecl_Usag
|
||||
// break;
|
||||
// continuing {
|
||||
// loop {
|
||||
// z = 2;
|
||||
// z = 2i;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
@ -674,7 +676,7 @@ TEST_F(ResolverValidationTest, Stmt_Loop_ContinueInNestedLoopBodyBeforeDecl_Usag
|
||||
auto* body = Block(inner_loop, //
|
||||
Decl(Var("z", ty.i32(), ast::StorageClass::kNone)), //
|
||||
Break());
|
||||
auto* continuing = Block(Loop(Block(Assign("z", 2), //
|
||||
auto* continuing = Block(Loop(Block(Assign("z", 2_i), //
|
||||
Break())));
|
||||
auto* loop_stmt = Loop(body, continuing);
|
||||
WrapInFunction(loop_stmt);
|
||||
@ -688,7 +690,7 @@ TEST_F(ResolverTest, Stmt_Loop_ContinueInLoopBodyAfterDecl_UsageInContinuing) {
|
||||
// if (true) { continue; }
|
||||
// break;
|
||||
// continuing {
|
||||
// z = 2;
|
||||
// z = 2i;
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -696,7 +698,7 @@ TEST_F(ResolverTest, Stmt_Loop_ContinueInLoopBodyAfterDecl_UsageInContinuing) {
|
||||
auto* body =
|
||||
Block(Decl(Var("z", ty.i32(), ast::StorageClass::kNone)), If(true, Block(Continue())), //
|
||||
Break());
|
||||
auto* continuing = Block(Assign(Expr(error_loc, "z"), 2));
|
||||
auto* continuing = Block(Assign(Expr(error_loc, "z"), 2_i));
|
||||
auto* loop_stmt = Loop(body, continuing);
|
||||
WrapInFunction(loop_stmt);
|
||||
|
||||
@ -988,8 +990,8 @@ TEST_F(ResolverValidationTest, Stmt_BreakInLoop) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverValidationTest, Stmt_BreakInSwitch) {
|
||||
WrapInFunction(Loop(Block(Switch(Expr(1), //
|
||||
Case(Expr(1), //
|
||||
WrapInFunction(Loop(Block(Switch(Expr(1_i), //
|
||||
Case(Expr(1_i), //
|
||||
Block(Break())), //
|
||||
DefaultCase()), //
|
||||
Break()))); //
|
||||
@ -1051,7 +1053,7 @@ TEST_F(ResolverValidationTest, Stmt_BreakInIfInIfInContinuing) {
|
||||
TEST_F(ResolverValidationTest, Stmt_BreakInIfTrueMultipleStmtsInContinuing) {
|
||||
auto* cont = Block( // continuing {
|
||||
If(true, Block(Source{{56, 78}}, // if(true) {
|
||||
Assign(Phony(), 1), // _ = 1;
|
||||
Assign(Phony(), 1_i), // _ = 1i;
|
||||
Break(Source{{12, 34}})))); // break;
|
||||
// }
|
||||
// }
|
||||
@ -1068,7 +1070,7 @@ TEST_F(ResolverValidationTest, Stmt_BreakInIfElseMultipleStmtsInContinuing) {
|
||||
auto* cont = Block( // continuing {
|
||||
If(true, Block(), // if(true) {
|
||||
Else(Block(Source{{56, 78}}, // } else {
|
||||
Assign(Phony(), 1), // _ = 1;
|
||||
Assign(Phony(), 1_i), // _ = 1i;
|
||||
Break(Source{{12, 34}}))))); // break;
|
||||
// }
|
||||
// }
|
||||
@ -1098,13 +1100,13 @@ TEST_F(ResolverValidationTest, Stmt_BreakInIfElseIfInContinuing) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverValidationTest, Stmt_BreakInIfNonEmptyElseInContinuing) {
|
||||
auto* cont = Block( // continuing {
|
||||
If(true, // if(true) {
|
||||
Block(Break(Source{{12, 34}})), // break;
|
||||
Else(Block(Source{{56, 78}}, // } else {
|
||||
Assign(Phony(), 1))))); // _ = 1;
|
||||
// }
|
||||
// }
|
||||
auto* cont = Block( // continuing {
|
||||
If(true, // if(true) {
|
||||
Block(Break(Source{{12, 34}})), // break;
|
||||
Else(Block(Source{{56, 78}}, // } else {
|
||||
Assign(Phony(), 1_i))))); // _ = 1i;
|
||||
// }
|
||||
// }
|
||||
WrapInFunction(Loop(Block(), cont));
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -1115,13 +1117,13 @@ TEST_F(ResolverValidationTest, Stmt_BreakInIfNonEmptyElseInContinuing) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverValidationTest, Stmt_BreakInIfElseNonEmptyTrueInContinuing) {
|
||||
auto* cont = Block( // continuing {
|
||||
If(true, // if(true) {
|
||||
Block(Source{{56, 78}}, Assign(Phony(), 1)), // _ = 1;
|
||||
Else(Block( // } else {
|
||||
Break(Source{{12, 34}}))))); // break;
|
||||
// }
|
||||
// }
|
||||
auto* cont = Block( // continuing {
|
||||
If(true, // if(true) {
|
||||
Block(Source{{56, 78}}, Assign(Phony(), 1_i)), // _ = 1i;
|
||||
Else(Block( // } else {
|
||||
Break(Source{{12, 34}}))))); // break;
|
||||
// }
|
||||
// }
|
||||
WrapInFunction(Loop(Block(), cont));
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -1136,7 +1138,7 @@ TEST_F(ResolverValidationTest, Stmt_BreakInIfInContinuingNotLast) {
|
||||
If(Source{{56, 78}}, true, // if(true) {
|
||||
Block(Break(Source{{12, 34}}))), // break;
|
||||
// }
|
||||
Assign(Phony(), 1)); // _ = 1;
|
||||
Assign(Phony(), 1_i)); // _ = 1i;
|
||||
// }
|
||||
WrapInFunction(Loop(Block(), cont));
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -95,12 +97,12 @@ TEST_F(ResolverVarLetTest, VarDeclWithConstructor) {
|
||||
auto* S = Structure("S", {Member("i", ty.i32())});
|
||||
auto* A = Alias("A", ty.Of(S));
|
||||
|
||||
auto* i_c = Expr(1);
|
||||
auto* u_c = Expr(1u);
|
||||
auto* i_c = Expr(1_i);
|
||||
auto* u_c = Expr(1_u);
|
||||
auto* f_c = Expr(1.f);
|
||||
auto* b_c = Expr(true);
|
||||
auto* s_c = Construct(ty.Of(S), Expr(1));
|
||||
auto* a_c = Construct(ty.Of(A), Expr(1));
|
||||
auto* s_c = Construct(ty.Of(S), Expr(1_i));
|
||||
auto* a_c = Construct(ty.Of(A), Expr(1_i));
|
||||
|
||||
auto* i = Var("i", ty.i32(), ast::StorageClass::kNone, i_c);
|
||||
auto* u = Var("u", ty.u32(), ast::StorageClass::kNone, u_c);
|
||||
@ -148,7 +150,7 @@ TEST_F(ResolverVarLetTest, LetDecl) {
|
||||
// struct S { i : i32; }
|
||||
// fn F(){
|
||||
// var v : i32;
|
||||
// let i : i32 = 1;
|
||||
// let i : i32 = 1i;
|
||||
// let u : u32 = 1u;
|
||||
// let f : f32 = 1.;
|
||||
// let b : bool = true;
|
||||
@ -161,12 +163,12 @@ TEST_F(ResolverVarLetTest, LetDecl) {
|
||||
auto* A = Alias("A", ty.Of(S));
|
||||
auto* v = Var("v", ty.i32(), ast::StorageClass::kNone);
|
||||
|
||||
auto* i_c = Expr(1);
|
||||
auto* u_c = Expr(1u);
|
||||
auto* i_c = Expr(1_i);
|
||||
auto* u_c = Expr(1_u);
|
||||
auto* f_c = Expr(1.f);
|
||||
auto* b_c = Expr(true);
|
||||
auto* s_c = Construct(ty.Of(S), Expr(1));
|
||||
auto* a_c = Construct(ty.Of(A), Expr(1));
|
||||
auto* s_c = Construct(ty.Of(S), Expr(1_i));
|
||||
auto* a_c = Construct(ty.Of(A), Expr(1_i));
|
||||
auto* p_c = AddressOf(v);
|
||||
|
||||
auto* i = Let("i", ty.i32(), i_c);
|
||||
@ -278,7 +280,7 @@ TEST_F(ResolverVarLetTest, LetInheritsAccessFromOriginatingVariable) {
|
||||
// }
|
||||
// @group(0) @binding(0) var<storage, read_write> s : S;
|
||||
// fn f() {
|
||||
// let p = &s.inner.arr[2];
|
||||
// let p = &s.inner.arr[4];
|
||||
// }
|
||||
auto* inner = Structure("Inner", {Member("arr", ty.array<i32, 4>())});
|
||||
auto* buf = Structure("S", {Member("inner", ty.Of(inner))});
|
||||
@ -288,7 +290,7 @@ TEST_F(ResolverVarLetTest, LetInheritsAccessFromOriginatingVariable) {
|
||||
create<ast::GroupAttribute>(0),
|
||||
});
|
||||
|
||||
auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 4);
|
||||
auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 4_i);
|
||||
auto* ptr = Let("p", nullptr, AddressOf(expr));
|
||||
|
||||
WrapInFunction(ptr);
|
||||
@ -444,7 +446,7 @@ TEST_F(ResolverVarLetTest, LocalShadowsGlobalLet) {
|
||||
// let a = (a == 321);
|
||||
// }
|
||||
|
||||
auto* g = GlobalConst("a", ty.i32(), Expr(1));
|
||||
auto* g = GlobalConst("a", ty.i32(), Expr(1_i));
|
||||
auto* v = Var("a", nullptr, Expr("a"));
|
||||
auto* l = Let("a", nullptr, Expr("a"));
|
||||
Func("X", {}, ty.void_(), {Decl(v)});
|
||||
@ -483,7 +485,7 @@ TEST_F(ResolverVarLetTest, LocalShadowsLocalVar) {
|
||||
// }
|
||||
// }
|
||||
|
||||
auto* s = Var("a", ty.i32(), Expr(1));
|
||||
auto* s = Var("a", ty.i32(), Expr(1_i));
|
||||
auto* v = Var("a", nullptr, Expr("a"));
|
||||
auto* l = Let("a", nullptr, Expr("a"));
|
||||
Func("X", {}, ty.void_(), {Decl(s), Block(Decl(v)), Block(Decl(l))});
|
||||
@ -522,7 +524,7 @@ TEST_F(ResolverVarLetTest, LocalShadowsLocalLet) {
|
||||
// }
|
||||
// }
|
||||
|
||||
auto* s = Let("a", ty.i32(), Expr(1));
|
||||
auto* s = Let("a", ty.i32(), Expr(1_i));
|
||||
auto* v = Var("a", nullptr, Expr("a"));
|
||||
auto* l = Let("a", nullptr, Expr("a"));
|
||||
Func("X", {}, ty.void_(), {Decl(s), Block(Decl(v)), Block(Decl(l))});
|
||||
@ -633,7 +635,7 @@ TEST_F(ResolverVarLetTest, ParamShadowsGlobalLet) {
|
||||
// fn F(a : bool) {
|
||||
// }
|
||||
|
||||
auto* g = GlobalConst("a", ty.i32(), Expr(1));
|
||||
auto* g = GlobalConst("a", ty.i32(), Expr(1_i));
|
||||
auto* p = Param("a", ty.bool_());
|
||||
Func("F", {p}, ty.void_(), {});
|
||||
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
@ -86,7 +88,7 @@ TEST_F(ResolverVarLetValidationTest, LetTypeNotConstructible) {
|
||||
|
||||
TEST_F(ResolverVarLetValidationTest, LetConstructorWrongType) {
|
||||
// var v : i32 = 2u
|
||||
WrapInFunction(Let(Source{{3, 3}}, "v", ty.i32(), Expr(2u)));
|
||||
WrapInFunction(Let(Source{{3, 3}}, "v", ty.i32(), Expr(2_u)));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -95,7 +97,7 @@ TEST_F(ResolverVarLetValidationTest, LetConstructorWrongType) {
|
||||
|
||||
TEST_F(ResolverVarLetValidationTest, VarConstructorWrongType) {
|
||||
// var v : i32 = 2u
|
||||
WrapInFunction(Var(Source{{3, 3}}, "v", ty.i32(), ast::StorageClass::kNone, Expr(2u)));
|
||||
WrapInFunction(Var(Source{{3, 3}}, "v", ty.i32(), ast::StorageClass::kNone, Expr(2_u)));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -104,7 +106,7 @@ TEST_F(ResolverVarLetValidationTest, VarConstructorWrongType) {
|
||||
|
||||
TEST_F(ResolverVarLetValidationTest, LetConstructorWrongTypeViaAlias) {
|
||||
auto* a = Alias("I32", ty.i32());
|
||||
WrapInFunction(Let(Source{{3, 3}}, "v", ty.Of(a), Expr(2u)));
|
||||
WrapInFunction(Let(Source{{3, 3}}, "v", ty.Of(a), Expr(2_u)));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -113,7 +115,7 @@ TEST_F(ResolverVarLetValidationTest, LetConstructorWrongTypeViaAlias) {
|
||||
|
||||
TEST_F(ResolverVarLetValidationTest, VarConstructorWrongTypeViaAlias) {
|
||||
auto* a = Alias("I32", ty.i32());
|
||||
WrapInFunction(Var(Source{{3, 3}}, "v", ty.Of(a), ast::StorageClass::kNone, Expr(2u)));
|
||||
WrapInFunction(Var(Source{{3, 3}}, "v", ty.Of(a), ast::StorageClass::kNone, Expr(2_u)));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
@ -139,7 +141,7 @@ TEST_F(ResolverVarLetValidationTest, LocalLetRedeclared) {
|
||||
// let l : f32 = 1.;
|
||||
// let l : i32 = 0;
|
||||
auto* l1 = Let("l", ty.f32(), Expr(1.f));
|
||||
auto* l2 = Let(Source{{12, 34}}, "l", ty.i32(), Expr(0));
|
||||
auto* l2 = Let(Source{{12, 34}}, "l", ty.i32(), Expr(0_i));
|
||||
WrapInFunction(l1, l2);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
@ -204,7 +206,7 @@ TEST_F(ResolverVarLetValidationTest, InferredPtrStorageAccessMismatch) {
|
||||
// }
|
||||
// @group(0) @binding(0) var<storage> s : S;
|
||||
// fn f() {
|
||||
// let p : pointer<storage, i32, read_write> = &s.inner.arr[2];
|
||||
// let p : pointer<storage, i32, read_write> = &s.inner.arr[2i];
|
||||
// }
|
||||
auto* inner = Structure("Inner", {Member("arr", ty.array<i32, 4>())});
|
||||
auto* buf = Structure("S", {Member("inner", ty.Of(inner))});
|
||||
@ -214,7 +216,7 @@ TEST_F(ResolverVarLetValidationTest, InferredPtrStorageAccessMismatch) {
|
||||
create<ast::GroupAttribute>(0),
|
||||
});
|
||||
|
||||
auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 4);
|
||||
auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 2_i);
|
||||
auto* ptr =
|
||||
Let(Source{{12, 34}}, "p",
|
||||
ty.pointer<i32>(ast::StorageClass::kStorage, ast::Access::kReadWrite), AddressOf(expr));
|
||||
|
@ -63,9 +63,9 @@ bool Constant::AnyZero() const {
|
||||
for (size_t i = 0; i < Elements().size(); ++i) {
|
||||
if (WithScalarAt(i, [&](auto&& s) {
|
||||
// Use std::equal_to to work around -Wfloat-equal warnings
|
||||
auto equals_to = std::equal_to<std::remove_reference_t<decltype(s)>>{};
|
||||
|
||||
if (equals_to(s, 0)) {
|
||||
using T = std::remove_reference_t<decltype(s)>;
|
||||
auto equal_to = std::equal_to<T>{};
|
||||
if (equal_to(s, T(0))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -25,34 +25,30 @@ namespace tint::sem {
|
||||
/// A Constant is compile-time known expression value, expressed as a flattened
|
||||
/// list of scalar values. Value may be of a scalar or vector type.
|
||||
class Constant {
|
||||
using i32 = ProgramBuilder::i32;
|
||||
using u32 = ProgramBuilder::u32;
|
||||
using f32 = ProgramBuilder::f32;
|
||||
|
||||
public:
|
||||
/// Scalar holds a single constant scalar value, as a union of an i32, u32,
|
||||
/// f32 or boolean.
|
||||
union Scalar {
|
||||
/// The scalar value as a i32
|
||||
int32_t i32;
|
||||
tint::i32 i32;
|
||||
/// The scalar value as a u32
|
||||
uint32_t u32;
|
||||
tint::u32 u32;
|
||||
/// The scalar value as a f32
|
||||
float f32;
|
||||
tint::f32 f32;
|
||||
/// The scalar value as a bool
|
||||
bool bool_;
|
||||
|
||||
/// Constructs the scalar with the i32 value `v`
|
||||
/// @param v the value of the Scalar
|
||||
Scalar(ProgramBuilder::i32 v) : i32(v) {} // NOLINT
|
||||
Scalar(tint::i32 v) : i32(v) {} // NOLINT
|
||||
|
||||
/// Constructs the scalar with the u32 value `v`
|
||||
/// @param v the value of the Scalar
|
||||
Scalar(ProgramBuilder::u32 v) : u32(v) {} // NOLINT
|
||||
Scalar(tint::u32 v) : u32(v) {} // NOLINT
|
||||
|
||||
/// Constructs the scalar with the f32 value `v`
|
||||
/// @param v the value of the Scalar
|
||||
Scalar(ProgramBuilder::f32 v) : f32(v) {} // NOLINT
|
||||
Scalar(tint::f32 v) : f32(v) {} // NOLINT
|
||||
|
||||
/// Constructs the scalar with the bool value `v`
|
||||
/// @param v the value of the Scalar
|
||||
@ -106,22 +102,18 @@ class Constant {
|
||||
/// @return the value returned by func.
|
||||
template <typename Func>
|
||||
auto WithScalarAt(size_t index, Func&& func) const {
|
||||
auto* elem_type = ElementType();
|
||||
if (elem_type->Is<I32>()) {
|
||||
return func(elems_[index].i32);
|
||||
}
|
||||
if (elem_type->Is<U32>()) {
|
||||
return func(elems_[index].u32);
|
||||
}
|
||||
if (elem_type->Is<F32>()) {
|
||||
return func(elems_[index].f32);
|
||||
}
|
||||
if (elem_type->Is<Bool>()) {
|
||||
return func(elems_[index].bool_);
|
||||
}
|
||||
diag::List diags;
|
||||
TINT_UNREACHABLE(Semantic, diags) << "invalid scalar type " << type_->TypeInfo().name;
|
||||
return func(~0);
|
||||
return Switch(
|
||||
ElementType(), //
|
||||
[&](const I32*) { return func(elems_[index].i32); },
|
||||
[&](const U32*) { return func(elems_[index].u32); },
|
||||
[&](const F32*) { return func(elems_[index].f32); },
|
||||
[&](const Bool*) { return func(elems_[index].bool_); },
|
||||
[&](Default) {
|
||||
diag::List diags;
|
||||
TINT_UNREACHABLE(Semantic, diags)
|
||||
<< "invalid scalar type " << type_->TypeInfo().name;
|
||||
return func(u32(0u));
|
||||
});
|
||||
}
|
||||
|
||||
/// @param index the index of the scalar value
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::AddEmptyEntryPoint);
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
|
||||
AddEmptyEntryPoint::AddEmptyEntryPoint() = default;
|
||||
@ -37,7 +39,7 @@ bool AddEmptyEntryPoint::ShouldRun(const Program* program, const DataMap&) const
|
||||
|
||||
void AddEmptyEntryPoint::Run(CloneContext& ctx, const DataMap&, DataMap&) const {
|
||||
ctx.dst->Func(ctx.dst->Symbols().New("unused_entry_point"), {}, ctx.dst->ty.void_(), {},
|
||||
{ctx.dst->Stage(ast::PipelineStage::kCompute), ctx.dst->WorkgroupSize(1)});
|
||||
{ctx.dst->Stage(ast::PipelineStage::kCompute), ctx.dst->WorkgroupSize(1_i)});
|
||||
ctx.Clone();
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ TEST_F(AddEmptyEntryPointTest, EmptyModule) {
|
||||
auto* src = R"()";
|
||||
|
||||
auto* expect = R"(
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn unused_entry_point() {
|
||||
}
|
||||
)";
|
||||
@ -70,7 +70,7 @@ TEST_F(AddEmptyEntryPointTest, NameClash) {
|
||||
auto* src = R"(var<private> unused_entry_point : f32;)";
|
||||
|
||||
auto* expect = R"(
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn unused_entry_point_1() {
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ void ArrayLengthFromUniform::Run(CloneContext& ctx, const DataMap& inputs, DataM
|
||||
ctx.dst->Sym(),
|
||||
{ctx.dst->Member(kBufferSizeMemberName,
|
||||
ctx.dst->ty.array(ctx.dst->ty.vec4(ctx.dst->ty.u32()),
|
||||
(max_buffer_size_index / 4) + 1))});
|
||||
u32((max_buffer_size_index / 4) + 1)))});
|
||||
buffer_size_ubo = ctx.dst->Global(
|
||||
ctx.dst->Sym(), ctx.dst->ty.Of(buffer_size_struct), ast::StorageClass::kUniform,
|
||||
ast::AttributeList{
|
||||
@ -154,50 +154,50 @@ void ArrayLengthFromUniform::Run(CloneContext& ctx, const DataMap& inputs, DataM
|
||||
|
||||
std::unordered_set<uint32_t> used_size_indices;
|
||||
|
||||
IterateArrayLengthOnStorageVar(
|
||||
ctx, [&](const ast::CallExpression* call_expr, const sem::VariableUser* storage_buffer_sem,
|
||||
const sem::GlobalVariable* var) {
|
||||
auto binding = var->BindingPoint();
|
||||
auto idx_itr = cfg->bindpoint_to_size_index.find(binding);
|
||||
if (idx_itr == cfg->bindpoint_to_size_index.end()) {
|
||||
return;
|
||||
}
|
||||
IterateArrayLengthOnStorageVar(ctx, [&](const ast::CallExpression* call_expr,
|
||||
const sem::VariableUser* storage_buffer_sem,
|
||||
const sem::GlobalVariable* var) {
|
||||
auto binding = var->BindingPoint();
|
||||
auto idx_itr = cfg->bindpoint_to_size_index.find(binding);
|
||||
if (idx_itr == cfg->bindpoint_to_size_index.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t size_index = idx_itr->second;
|
||||
used_size_indices.insert(size_index);
|
||||
uint32_t size_index = idx_itr->second;
|
||||
used_size_indices.insert(size_index);
|
||||
|
||||
// Load the total storage buffer size from the UBO.
|
||||
uint32_t array_index = size_index / 4;
|
||||
auto* vec_expr = ctx.dst->IndexAccessor(
|
||||
ctx.dst->MemberAccessor(get_ubo()->symbol, kBufferSizeMemberName), array_index);
|
||||
uint32_t vec_index = size_index % 4;
|
||||
auto* total_storage_buffer_size = ctx.dst->IndexAccessor(vec_expr, vec_index);
|
||||
// Load the total storage buffer size from the UBO.
|
||||
uint32_t array_index = size_index / 4;
|
||||
auto* vec_expr = ctx.dst->IndexAccessor(
|
||||
ctx.dst->MemberAccessor(get_ubo()->symbol, kBufferSizeMemberName), u32(array_index));
|
||||
uint32_t vec_index = size_index % 4;
|
||||
auto* total_storage_buffer_size = ctx.dst->IndexAccessor(vec_expr, u32(vec_index));
|
||||
|
||||
// Calculate actual array length
|
||||
// total_storage_buffer_size - array_offset
|
||||
// array_length = ----------------------------------------
|
||||
// array_stride
|
||||
const ast::Expression* total_size = total_storage_buffer_size;
|
||||
auto* storage_buffer_type = storage_buffer_sem->Type()->UnwrapRef();
|
||||
const sem::Array* array_type = nullptr;
|
||||
if (auto* str = storage_buffer_type->As<sem::Struct>()) {
|
||||
// The variable is a struct, so subtract the byte offset of the array
|
||||
// member.
|
||||
auto* array_member_sem = str->Members().back();
|
||||
array_type = array_member_sem->Type()->As<sem::Array>();
|
||||
total_size = ctx.dst->Sub(total_storage_buffer_size, array_member_sem->Offset());
|
||||
} else if (auto* arr = storage_buffer_type->As<sem::Array>()) {
|
||||
array_type = arr;
|
||||
} else {
|
||||
TINT_ICE(Transform, ctx.dst->Diagnostics())
|
||||
<< "expected form of arrayLength argument to be &array_var or "
|
||||
"&struct_var.array_member";
|
||||
return;
|
||||
}
|
||||
auto* array_length = ctx.dst->Div(total_size, array_type->Stride());
|
||||
// Calculate actual array length
|
||||
// total_storage_buffer_size - array_offset
|
||||
// array_length = ----------------------------------------
|
||||
// array_stride
|
||||
const ast::Expression* total_size = total_storage_buffer_size;
|
||||
auto* storage_buffer_type = storage_buffer_sem->Type()->UnwrapRef();
|
||||
const sem::Array* array_type = nullptr;
|
||||
if (auto* str = storage_buffer_type->As<sem::Struct>()) {
|
||||
// The variable is a struct, so subtract the byte offset of the array
|
||||
// member.
|
||||
auto* array_member_sem = str->Members().back();
|
||||
array_type = array_member_sem->Type()->As<sem::Array>();
|
||||
total_size = ctx.dst->Sub(total_storage_buffer_size, u32(array_member_sem->Offset()));
|
||||
} else if (auto* arr = storage_buffer_type->As<sem::Array>()) {
|
||||
array_type = arr;
|
||||
} else {
|
||||
TINT_ICE(Transform, ctx.dst->Diagnostics())
|
||||
<< "expected form of arrayLength argument to be &array_var or "
|
||||
"&struct_var.array_member";
|
||||
return;
|
||||
}
|
||||
auto* array_length = ctx.dst->Div(total_size, u32(array_type->Stride()));
|
||||
|
||||
ctx.Replace(call_expr, array_length);
|
||||
});
|
||||
ctx.Replace(call_expr, array_length);
|
||||
});
|
||||
|
||||
ctx.Clone();
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include "src/tint/sem/call.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::BuiltinPolyfill);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::BuiltinPolyfill::Config);
|
||||
|
||||
@ -57,7 +59,7 @@ struct BuiltinPolyfill::State {
|
||||
return b.ty.vec<u32>(width);
|
||||
};
|
||||
auto V = [&](uint32_t value) -> const ast::Expression* {
|
||||
return ScalarOrVector(width, value);
|
||||
return ScalarOrVector(width, u32(value));
|
||||
};
|
||||
b.Func(
|
||||
name, {b.Param("v", T(ty))}, T(ty),
|
||||
@ -112,7 +114,7 @@ struct BuiltinPolyfill::State {
|
||||
return b.ty.vec<u32>(width);
|
||||
};
|
||||
auto V = [&](uint32_t value) -> const ast::Expression* {
|
||||
return ScalarOrVector(width, value);
|
||||
return ScalarOrVector(width, u32(value));
|
||||
};
|
||||
auto B = [&](const ast::Expression* value) -> const ast::Expression* {
|
||||
if (width == 1) {
|
||||
@ -175,13 +177,13 @@ struct BuiltinPolyfill::State {
|
||||
};
|
||||
|
||||
ast::StatementList body = {
|
||||
b.Decl(b.Let("s", nullptr, b.Call("min", "offset", W))),
|
||||
b.Decl(b.Let("e", nullptr, b.Call("min", W, b.Add("s", "count")))),
|
||||
b.Decl(b.Let("s", nullptr, b.Call("min", "offset", u32(W)))),
|
||||
b.Decl(b.Let("e", nullptr, b.Call("min", u32(W), b.Add("s", "count")))),
|
||||
};
|
||||
|
||||
switch (polyfill.extract_bits) {
|
||||
case Level::kFull:
|
||||
body.emplace_back(b.Decl(b.Let("shl", nullptr, b.Sub(W, "e"))));
|
||||
body.emplace_back(b.Decl(b.Let("shl", nullptr, b.Sub(u32(W), "e"))));
|
||||
body.emplace_back(b.Decl(b.Let("shr", nullptr, b.Add("shl", "s"))));
|
||||
body.emplace_back(
|
||||
b.Return(b.Shr(b.Shl("v", vecN_u32(b.Expr("shl"))), vecN_u32(b.Expr("shr")))));
|
||||
@ -221,7 +223,7 @@ struct BuiltinPolyfill::State {
|
||||
return b.ty.vec<u32>(width);
|
||||
};
|
||||
auto V = [&](uint32_t value) -> const ast::Expression* {
|
||||
return ScalarOrVector(width, value);
|
||||
return ScalarOrVector(width, u32(value));
|
||||
};
|
||||
auto B = [&](const ast::Expression* value) -> const ast::Expression* {
|
||||
if (width == 1) {
|
||||
@ -238,7 +240,7 @@ struct BuiltinPolyfill::State {
|
||||
x = b.Call("select", //
|
||||
b.Construct(U(), "v"), //
|
||||
b.Construct(U(), b.Complement("v")), //
|
||||
b.LessThan("v", ScalarOrVector(width, 0)));
|
||||
b.LessThan("v", ScalarOrVector(width, 0_i)));
|
||||
}
|
||||
|
||||
b.Func(
|
||||
@ -295,7 +297,7 @@ struct BuiltinPolyfill::State {
|
||||
return b.ty.vec<u32>(width);
|
||||
};
|
||||
auto V = [&](uint32_t value) -> const ast::Expression* {
|
||||
return ScalarOrVector(width, value);
|
||||
return ScalarOrVector(width, u32(value));
|
||||
};
|
||||
auto B = [&](const ast::Expression* value) -> const ast::Expression* {
|
||||
if (width == 1) {
|
||||
@ -368,15 +370,16 @@ struct BuiltinPolyfill::State {
|
||||
};
|
||||
|
||||
ast::StatementList body = {
|
||||
b.Decl(b.Let("s", nullptr, b.Call("min", "offset", W))),
|
||||
b.Decl(b.Let("e", nullptr, b.Call("min", W, b.Add("s", "count")))),
|
||||
b.Decl(b.Let("s", nullptr, b.Call("min", "offset", u32(W)))),
|
||||
b.Decl(b.Let("e", nullptr, b.Call("min", u32(W), b.Add("s", "count")))),
|
||||
};
|
||||
|
||||
switch (polyfill.insert_bits) {
|
||||
case Level::kFull:
|
||||
// let mask = ((1 << s) - 1) ^ ((1 << e) - 1)
|
||||
body.emplace_back(b.Decl(b.Let(
|
||||
"mask", nullptr, b.Xor(b.Sub(b.Shl(1u, "s"), 1u), b.Sub(b.Shl(1u, "e"), 1u)))));
|
||||
body.emplace_back(
|
||||
b.Decl(b.Let("mask", nullptr,
|
||||
b.Xor(b.Sub(b.Shl(1_u, "s"), 1_u), b.Sub(b.Shl(1_u, "e"), 1_u)))));
|
||||
// return ((n << s) & mask) | (v & ~mask)
|
||||
body.emplace_back(b.Return(b.Or(b.And(b.Shl("n", U("s")), V("mask")),
|
||||
b.And("v", V(b.Complement("mask"))))));
|
||||
@ -403,10 +406,6 @@ struct BuiltinPolyfill::State {
|
||||
}
|
||||
|
||||
private:
|
||||
/// Aliases
|
||||
using u32 = ProgramBuilder::u32;
|
||||
using i32 = ProgramBuilder::i32;
|
||||
|
||||
/// @returns the AST type for the given sem type
|
||||
const ast::Type* T(const sem::Type* ty) const { return CreateASTTypeFor(ctx, ty); }
|
||||
|
||||
|
@ -604,7 +604,7 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn tint_first_leading_bit(v : i32) -> i32 {
|
||||
var x = select(u32(v), u32(~(v)), (v < 0));
|
||||
var x = select(u32(v), u32(~(v)), (v < 0i));
|
||||
let b16 = select(0u, 16u, bool((x & 4294901760u)));
|
||||
x = (x >> b16);
|
||||
let b8 = select(0u, 8u, bool((x & 65280u)));
|
||||
@ -670,7 +670,7 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn tint_first_leading_bit(v : vec3<i32>) -> vec3<i32> {
|
||||
var x = select(vec3<u32>(v), vec3<u32>(~(v)), (v < vec3<i32>(0)));
|
||||
var x = select(vec3<u32>(v), vec3<u32>(~(v)), (v < vec3<i32>(0i)));
|
||||
let b16 = select(vec3<u32>(0u), vec3<u32>(16u), vec3<bool>((x & vec3<u32>(4294901760u))));
|
||||
x = (x >> b16);
|
||||
let b8 = select(vec3<u32>(0u), vec3<u32>(8u), vec3<bool>((x & vec3<u32>(65280u))));
|
||||
|
@ -33,6 +33,8 @@
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::CalculateArrayLength);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::CalculateArrayLength::BufferSizeIntrinsic);
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
|
||||
namespace {
|
||||
@ -168,7 +170,7 @@ void CalculateArrayLength::Run(CloneContext& ctx, const DataMap&, DataMap&) cons
|
||||
// RWByteAddressBuffer.GetDimensions()
|
||||
auto* buffer_size_result = ctx.dst->Decl(
|
||||
ctx.dst->Var(ctx.dst->Sym(), ctx.dst->ty.u32(),
|
||||
ast::StorageClass::kNone, ctx.dst->Expr(0u)));
|
||||
ast::StorageClass::kNone, ctx.dst->Expr(0_u)));
|
||||
|
||||
// Call storage_buffer.GetDimensions(&buffer_size_result)
|
||||
auto* call_get_dims = ctx.dst->CallStmt(ctx.dst->Call(
|
||||
@ -192,7 +194,8 @@ void CalculateArrayLength::Run(CloneContext& ctx, const DataMap&, DataMap&) cons
|
||||
// the array member.
|
||||
auto* array_member_sem = str->Members().back();
|
||||
array_type = array_member_sem->Type()->As<sem::Array>();
|
||||
total_size = ctx.dst->Sub(total_size, array_member_sem->Offset());
|
||||
total_size =
|
||||
ctx.dst->Sub(total_size, u32(array_member_sem->Offset()));
|
||||
} else if (auto* arr = storage_buffer_type->As<sem::Array>()) {
|
||||
array_type = arr;
|
||||
} else {
|
||||
@ -202,8 +205,9 @@ void CalculateArrayLength::Run(CloneContext& ctx, const DataMap&, DataMap&) cons
|
||||
return name;
|
||||
}
|
||||
uint32_t array_stride = array_type->Size();
|
||||
auto* array_length_var = ctx.dst->Decl(ctx.dst->Let(
|
||||
name, ctx.dst->ty.u32(), ctx.dst->Div(total_size, array_stride)));
|
||||
auto* array_length_var = ctx.dst->Decl(
|
||||
ctx.dst->Let(name, ctx.dst->ty.u32(),
|
||||
ctx.dst->Div(total_size, u32(array_stride))));
|
||||
|
||||
// Insert the array length calculations at the top of the block
|
||||
ctx.InsertBefore(block->statements, block->statements[0],
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "src/tint/sem/function.h"
|
||||
#include "src/tint/transform/unshadow.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::CanonicalizeEntryPointIO);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::CanonicalizeEntryPointIO::Config);
|
||||
|
||||
@ -190,8 +192,8 @@ struct CanonicalizeEntryPointIO::State {
|
||||
} else if (builtin->builtin == ast::Builtin::kSampleMask) {
|
||||
// Vulkan requires the type of a SampleMask builtin to be an array.
|
||||
// Declare it as array<u32, 1> and then load the first element.
|
||||
ast_type = ctx.dst->ty.array(ast_type, 1);
|
||||
value = ctx.dst->IndexAccessor(value, 0);
|
||||
ast_type = ctx.dst->ty.array(ast_type, 1_u);
|
||||
value = ctx.dst->IndexAccessor(value, 0_i);
|
||||
}
|
||||
}
|
||||
ctx.dst->Global(symbol, ast_type, ast::StorageClass::kInput, std::move(attributes));
|
||||
@ -356,7 +358,7 @@ struct CanonicalizeEntryPointIO::State {
|
||||
for (auto& outval : wrapper_output_values) {
|
||||
if (HasSampleMask(outval.attributes)) {
|
||||
// Combine the authored sample mask with the fixed mask.
|
||||
outval.value = ctx.dst->And(outval.value, cfg.fixed_sample_mask);
|
||||
outval.value = ctx.dst->And(outval.value, u32(cfg.fixed_sample_mask));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -365,7 +367,7 @@ struct CanonicalizeEntryPointIO::State {
|
||||
// using the fixed sample mask.
|
||||
AddOutput("fixed_sample_mask", ctx.dst->create<sem::U32>(),
|
||||
{ctx.dst->Builtin(ast::Builtin::kSampleMask)},
|
||||
ctx.dst->Expr(cfg.fixed_sample_mask));
|
||||
ctx.dst->Expr(u32(cfg.fixed_sample_mask)));
|
||||
}
|
||||
|
||||
/// Add a point size builtin to the wrapper function output.
|
||||
@ -458,8 +460,8 @@ struct CanonicalizeEntryPointIO::State {
|
||||
if (HasSampleMask(attributes)) {
|
||||
// Vulkan requires the type of a SampleMask builtin to be an array.
|
||||
// Declare it as array<u32, 1> and then store to the first element.
|
||||
type = ctx.dst->ty.array(type, 1);
|
||||
lhs = ctx.dst->IndexAccessor(lhs, 0);
|
||||
type = ctx.dst->ty.array(type, 1_u);
|
||||
lhs = ctx.dst->IndexAccessor(lhs, 0_i);
|
||||
}
|
||||
ctx.dst->Global(name, type, ast::StorageClass::kOutput, std::move(attributes));
|
||||
wrapper_body.push_back(ctx.dst->Assign(lhs, outval.value));
|
||||
@ -668,9 +670,9 @@ struct CanonicalizeEntryPointIO::State {
|
||||
case ast::Builtin::kSampleMask:
|
||||
// gl_SampleMask is an array of i32. Retrieve the first element and
|
||||
// bitcast it to u32.
|
||||
value = ctx.dst->IndexAccessor(value, 0);
|
||||
value = ctx.dst->IndexAccessor(value, 0_i);
|
||||
value = ctx.dst->Bitcast(ast_type, value);
|
||||
ast_type = ctx.dst->ty.array(ctx.dst->ty.i32(), 1);
|
||||
ast_type = ctx.dst->ty.array(ctx.dst->ty.i32(), 1_u);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -678,7 +678,7 @@ fn frag_main() -> FragOutput {
|
||||
|
||||
@builtin(frag_depth) @internal(disable_validation__ignore_storage_class) var<out> depth_1 : f32;
|
||||
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<out> mask_1 : array<u32, 1>;
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<out> mask_1 : array<u32, 1u>;
|
||||
|
||||
struct FragOutput {
|
||||
color : vec4<f32>,
|
||||
@ -699,7 +699,7 @@ fn frag_main() {
|
||||
let inner_result = frag_main_inner();
|
||||
color_1 = inner_result.color;
|
||||
depth_1 = inner_result.depth;
|
||||
mask_1[0] = inner_result.mask;
|
||||
mask_1[0i] = inner_result.mask;
|
||||
}
|
||||
)";
|
||||
|
||||
@ -733,7 +733,7 @@ struct FragOutput {
|
||||
|
||||
@builtin(frag_depth) @internal(disable_validation__ignore_storage_class) var<out> depth_1 : f32;
|
||||
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<out> mask_1 : array<u32, 1>;
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<out> mask_1 : array<u32, 1u>;
|
||||
|
||||
fn frag_main_inner() -> FragOutput {
|
||||
var output : FragOutput;
|
||||
@ -748,7 +748,7 @@ fn frag_main() {
|
||||
let inner_result = frag_main_inner();
|
||||
color_1 = inner_result.color;
|
||||
depth_1 = inner_result.depth;
|
||||
mask_1[0] = inner_result.mask;
|
||||
mask_1[0i] = inner_result.mask;
|
||||
}
|
||||
|
||||
struct FragOutput {
|
||||
@ -3870,9 +3870,9 @@ fn main(@builtin(sample_index) sample_index : u32,
|
||||
auto* expect = R"(
|
||||
@builtin(sample_index) @internal(disable_validation__ignore_storage_class) var<in> sample_index_1 : u32;
|
||||
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<in> mask_in_1 : array<u32, 1>;
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<in> mask_in_1 : array<u32, 1u>;
|
||||
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<out> value : array<u32, 1>;
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<out> value : array<u32, 1u>;
|
||||
|
||||
fn main_inner(sample_index : u32, mask_in : u32) -> u32 {
|
||||
return mask_in;
|
||||
@ -3880,8 +3880,8 @@ fn main_inner(sample_index : u32, mask_in : u32) -> u32 {
|
||||
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let inner_result = main_inner(sample_index_1, mask_in_1[0]);
|
||||
value[0] = inner_result;
|
||||
let inner_result = main_inner(sample_index_1, mask_in_1[0i]);
|
||||
value[0i] = inner_result;
|
||||
}
|
||||
)";
|
||||
|
||||
@ -3905,9 +3905,9 @@ fn fragment_main(@builtin(sample_index) sample_index : u32,
|
||||
auto* expect = R"(
|
||||
@builtin(sample_index) @internal(disable_validation__ignore_storage_class) var<in> gl_SampleID : i32;
|
||||
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<in> gl_SampleMaskIn : array<i32, 1>;
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<in> gl_SampleMaskIn : array<i32, 1u>;
|
||||
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<out> gl_SampleMask : array<i32, 1>;
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<out> gl_SampleMask : array<i32, 1u>;
|
||||
|
||||
fn fragment_main(sample_index : u32, mask_in : u32) -> u32 {
|
||||
return mask_in;
|
||||
@ -3915,8 +3915,8 @@ fn fragment_main(sample_index : u32, mask_in : u32) -> u32 {
|
||||
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let inner_result = fragment_main(bitcast<u32>(gl_SampleID), bitcast<u32>(gl_SampleMaskIn[0]));
|
||||
gl_SampleMask[0] = bitcast<i32>(inner_result);
|
||||
let inner_result = fragment_main(bitcast<u32>(gl_SampleID), bitcast<u32>(gl_SampleMaskIn[0i]));
|
||||
gl_SampleMask[0i] = bitcast<i32>(inner_result);
|
||||
}
|
||||
)";
|
||||
|
||||
|
@ -38,6 +38,8 @@
|
||||
#include "src/tint/utils/hash.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::DecomposeMemoryAccess);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::DecomposeMemoryAccess::Intrinsic);
|
||||
|
||||
@ -63,7 +65,7 @@ struct OffsetExpr : Offset {
|
||||
auto* type = ctx.src->Sem().Get(expr)->Type()->UnwrapRef();
|
||||
auto* res = ctx.Clone(expr);
|
||||
if (!type->Is<sem::U32>()) {
|
||||
res = ctx.dst->Construct<ProgramBuilder::u32>(res);
|
||||
res = ctx.dst->Construct<u32>(res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@ -77,7 +79,7 @@ struct OffsetLiteral : Castable<OffsetLiteral, Offset> {
|
||||
explicit OffsetLiteral(uint32_t lit) : literal(lit) {}
|
||||
|
||||
const ast::Expression* Build(CloneContext& ctx) const override {
|
||||
return ctx.dst->Expr(literal);
|
||||
return ctx.dst->Expr(u32(literal));
|
||||
}
|
||||
};
|
||||
|
||||
@ -467,13 +469,13 @@ struct DecomposeMemoryAccess::State {
|
||||
// }
|
||||
auto load = LoadFunc(buf_ty, arr_ty->ElemType()->UnwrapRef(), var_user);
|
||||
auto* arr = b.Var(b.Symbols().New("arr"), CreateASTTypeFor(ctx, arr_ty));
|
||||
auto* i = b.Var(b.Symbols().New("i"), nullptr, b.Expr(0u));
|
||||
auto* i = b.Var(b.Symbols().New("i"), nullptr, b.Expr(0_u));
|
||||
auto* for_init = b.Decl(i);
|
||||
auto* for_cond = b.create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kLessThan, b.Expr(i), b.Expr(arr_ty->Count()));
|
||||
auto* for_cont = b.Assign(i, b.Add(i, 1u));
|
||||
ast::BinaryOp::kLessThan, b.Expr(i), b.Expr(u32(arr_ty->Count())));
|
||||
auto* for_cont = b.Assign(i, b.Add(i, 1_u));
|
||||
auto* arr_el = b.IndexAccessor(arr, i);
|
||||
auto* el_offset = b.Add(b.Expr("offset"), b.Mul(i, arr_ty->Stride()));
|
||||
auto* el_offset = b.Add(b.Expr("offset"), b.Mul(i, u32(arr_ty->Stride())));
|
||||
auto* el_val = b.Call(load, "buffer", el_offset);
|
||||
auto* for_loop =
|
||||
b.For(for_init, for_cond, for_cont, b.Block(b.Assign(arr_el, el_val)));
|
||||
@ -490,12 +492,12 @@ struct DecomposeMemoryAccess::State {
|
||||
auto* vec_ty = mat_ty->ColumnType();
|
||||
Symbol load = LoadFunc(buf_ty, vec_ty, var_user);
|
||||
for (uint32_t i = 0; i < mat_ty->columns(); i++) {
|
||||
auto* offset = b.Add("offset", i * mat_ty->ColumnStride());
|
||||
auto* offset = b.Add("offset", u32(i * mat_ty->ColumnStride()));
|
||||
values.emplace_back(b.Call(load, "buffer", offset));
|
||||
}
|
||||
} else if (auto* str = el_ty->As<sem::Struct>()) {
|
||||
for (auto* member : str->Members()) {
|
||||
auto* offset = b.Add("offset", member->Offset());
|
||||
auto* offset = b.Add("offset", u32(member->Offset()));
|
||||
Symbol load = LoadFunc(buf_ty, member->Type()->UnwrapRef(), var_user);
|
||||
values.emplace_back(b.Call(load, "buffer", offset));
|
||||
}
|
||||
@ -561,13 +563,13 @@ struct DecomposeMemoryAccess::State {
|
||||
// }
|
||||
auto* array = b.Var(b.Symbols().New("array"), nullptr, b.Expr("value"));
|
||||
auto store = StoreFunc(buf_ty, arr_ty->ElemType()->UnwrapRef(), var_user);
|
||||
auto* i = b.Var(b.Symbols().New("i"), nullptr, b.Expr(0u));
|
||||
auto* i = b.Var(b.Symbols().New("i"), nullptr, b.Expr(0_u));
|
||||
auto* for_init = b.Decl(i);
|
||||
auto* for_cond = b.create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kLessThan, b.Expr(i), b.Expr(arr_ty->Count()));
|
||||
auto* for_cont = b.Assign(i, b.Add(i, 1u));
|
||||
ast::BinaryOp::kLessThan, b.Expr(i), b.Expr(u32(arr_ty->Count())));
|
||||
auto* for_cont = b.Assign(i, b.Add(i, 1_u));
|
||||
auto* arr_el = b.IndexAccessor(array, i);
|
||||
auto* el_offset = b.Add(b.Expr("offset"), b.Mul(i, arr_ty->Stride()));
|
||||
auto* el_offset = b.Add(b.Expr("offset"), b.Mul(i, u32(arr_ty->Stride())));
|
||||
auto* store_stmt = b.CallStmt(b.Call(store, "buffer", el_offset, arr_el));
|
||||
auto* for_loop = b.For(for_init, for_cond, for_cont, b.Block(store_stmt));
|
||||
|
||||
@ -576,14 +578,14 @@ struct DecomposeMemoryAccess::State {
|
||||
auto* vec_ty = mat_ty->ColumnType();
|
||||
Symbol store = StoreFunc(buf_ty, vec_ty, var_user);
|
||||
for (uint32_t i = 0; i < mat_ty->columns(); i++) {
|
||||
auto* offset = b.Add("offset", i * mat_ty->ColumnStride());
|
||||
auto* access = b.IndexAccessor("value", i);
|
||||
auto* offset = b.Add("offset", u32(i * mat_ty->ColumnStride()));
|
||||
auto* access = b.IndexAccessor("value", u32(i));
|
||||
auto* call = b.Call(store, "buffer", offset, access);
|
||||
body.emplace_back(b.CallStmt(call));
|
||||
}
|
||||
} else if (auto* str = el_ty->As<sem::Struct>()) {
|
||||
for (auto* member : str->Members()) {
|
||||
auto* offset = b.Add("offset", member->Offset());
|
||||
auto* offset = b.Add("offset", u32(member->Offset()));
|
||||
auto* access =
|
||||
b.MemberAccessor("value", ctx.Clone(member->Declaration()->symbol));
|
||||
Symbol store = StoreFunc(buf_ty, member->Type()->UnwrapRef(), var_user);
|
||||
|
@ -23,11 +23,12 @@
|
||||
#include "src/tint/transform/test_helper.h"
|
||||
#include "src/tint/transform/unshadow.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
namespace {
|
||||
|
||||
using DecomposeStridedArrayTest = TransformTest;
|
||||
using f32 = ProgramBuilder::f32;
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, ShouldRunEmptyModule) {
|
||||
ProgramBuilder b;
|
||||
@ -35,26 +36,26 @@ TEST_F(DecomposeStridedArrayTest, ShouldRunEmptyModule) {
|
||||
}
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, ShouldRunNonStridedArray) {
|
||||
// var<private> arr : array<f32, 4>
|
||||
// var<private> arr : array<f32, 4u>
|
||||
|
||||
ProgramBuilder b;
|
||||
b.Global("arr", b.ty.array<f32, 4>(), ast::StorageClass::kPrivate);
|
||||
b.Global("arr", b.ty.array<f32, 4u>(), ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(ShouldRun<DecomposeStridedArray>(Program(std::move(b))));
|
||||
}
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, ShouldRunDefaultStridedArray) {
|
||||
// var<private> arr : @stride(4) array<f32, 4>
|
||||
// var<private> arr : @stride(4) array<f32, 4u>
|
||||
|
||||
ProgramBuilder b;
|
||||
b.Global("arr", b.ty.array<f32, 4>(4), ast::StorageClass::kPrivate);
|
||||
b.Global("arr", b.ty.array<f32, 4u>(4), ast::StorageClass::kPrivate);
|
||||
EXPECT_TRUE(ShouldRun<DecomposeStridedArray>(Program(std::move(b))));
|
||||
}
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, ShouldRunExplicitStridedArray) {
|
||||
// var<private> arr : @stride(16) array<f32, 4>
|
||||
// var<private> arr : @stride(16) array<f32, 4u>
|
||||
|
||||
ProgramBuilder b;
|
||||
b.Global("arr", b.ty.array<f32, 4>(16), ast::StorageClass::kPrivate);
|
||||
b.Global("arr", b.ty.array<f32, 4u>(16), ast::StorageClass::kPrivate);
|
||||
EXPECT_TRUE(ShouldRun<DecomposeStridedArray>(Program(std::move(b))));
|
||||
}
|
||||
|
||||
@ -68,33 +69,33 @@ TEST_F(DecomposeStridedArrayTest, Empty) {
|
||||
}
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, PrivateDefaultStridedArray) {
|
||||
// var<private> arr : @stride(4) array<f32, 4>
|
||||
// var<private> arr : @stride(4) array<f32, 4u>
|
||||
//
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let a : @stride(4) array<f32, 4> = a;
|
||||
// let a : @stride(4) array<f32, 4u> = a;
|
||||
// let b : f32 = arr[1];
|
||||
// }
|
||||
|
||||
ProgramBuilder b;
|
||||
b.Global("arr", b.ty.array<f32, 4>(4), ast::StorageClass::kPrivate);
|
||||
b.Global("arr", b.ty.array<f32, 4u>(4), ast::StorageClass::kPrivate);
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4>(4), b.Expr("arr"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor("arr", 1))),
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4u>(4), b.Expr("arr"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor("arr", 1_i))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
var<private> arr : array<f32, 4>;
|
||||
var<private> arr : array<f32, 4u>;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let a : array<f32, 4> = arr;
|
||||
let b : f32 = arr[1];
|
||||
let a : array<f32, 4u> = arr;
|
||||
let b : f32 = arr[1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -104,24 +105,24 @@ fn f() {
|
||||
}
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, PrivateStridedArray) {
|
||||
// var<private> arr : @stride(32) array<f32, 4>
|
||||
// var<private> arr : @stride(32) array<f32, 4u>
|
||||
//
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let a : @stride(32) array<f32, 4> = a;
|
||||
// let a : @stride(32) array<f32, 4u> = a;
|
||||
// let b : f32 = arr[1];
|
||||
// }
|
||||
|
||||
ProgramBuilder b;
|
||||
b.Global("arr", b.ty.array<f32, 4>(32), ast::StorageClass::kPrivate);
|
||||
b.Global("arr", b.ty.array<f32, 4u>(32), ast::StorageClass::kPrivate);
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4>(32), b.Expr("arr"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor("arr", 1))),
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4u>(32), b.Expr("arr"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor("arr", 1_i))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@ -130,12 +131,12 @@ struct strided_arr {
|
||||
el : f32,
|
||||
}
|
||||
|
||||
var<private> arr : array<strided_arr, 4>;
|
||||
var<private> arr : array<strided_arr, 4u>;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let a : array<strided_arr, 4> = arr;
|
||||
let b : f32 = arr[1].el;
|
||||
let a : array<strided_arr, 4u> = arr;
|
||||
let b : f32 = arr[1i].el;
|
||||
}
|
||||
)";
|
||||
|
||||
@ -146,26 +147,26 @@ fn f() {
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, ReadUniformStridedArray) {
|
||||
// struct S {
|
||||
// a : @stride(32) array<f32, 4>,
|
||||
// a : @stride(32) array<f32, 4u>,
|
||||
// };
|
||||
// @group(0) @binding(0) var<uniform> s : S;
|
||||
//
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let a : @stride(32) array<f32, 4> = s.a;
|
||||
// let a : @stride(32) array<f32, 4u> = s.a;
|
||||
// let b : f32 = s.a[1];
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4>(32))});
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4u>(32))});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4>(32), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1))),
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4u>(32), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@ -175,15 +176,15 @@ struct strided_arr {
|
||||
}
|
||||
|
||||
struct S {
|
||||
a : array<strided_arr, 4>,
|
||||
a : array<strided_arr, 4u>,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<uniform> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let a : array<strided_arr, 4> = s.a;
|
||||
let b : f32 = s.a[1].el;
|
||||
let a : array<strided_arr, 4u> = s.a;
|
||||
let b : f32 = s.a[1i].el;
|
||||
}
|
||||
)";
|
||||
|
||||
@ -194,41 +195,42 @@ fn f() {
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, ReadUniformDefaultStridedArray) {
|
||||
// struct S {
|
||||
// a : @stride(16) array<vec4<f32>, 4>,
|
||||
// a : @stride(16) array<vec4<f32>, 4u>,
|
||||
// };
|
||||
// @group(0) @binding(0) var<uniform> s : S;
|
||||
//
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let a : @stride(16) array<vec4<f32>, 4> = s.a;
|
||||
// let a : @stride(16) array<vec4<f32>, 4u> = s.a;
|
||||
// let b : f32 = s.a[1][2];
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array(b.ty.vec4<f32>(), 4, 16))});
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array(b.ty.vec4<f32>(), 4_u, 16))});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("a", b.ty.array(b.ty.vec4<f32>(), 4, 16), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(),
|
||||
b.IndexAccessor(b.IndexAccessor(b.MemberAccessor("s", "a"), 1), 2))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
});
|
||||
b.Func(
|
||||
"f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("a", b.ty.array(b.ty.vec4<f32>(), 4_u, 16), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(),
|
||||
b.IndexAccessor(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 2_i))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect =
|
||||
R"(
|
||||
struct S {
|
||||
a : array<vec4<f32>, 4>,
|
||||
a : array<vec4<f32>, 4u>,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<uniform> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let a : array<vec4<f32>, 4> = s.a;
|
||||
let b : f32 = s.a[1][2];
|
||||
let a : array<vec4<f32>, 4u> = s.a;
|
||||
let b : f32 = s.a[1i][2i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -239,26 +241,26 @@ fn f() {
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, ReadStorageStridedArray) {
|
||||
// struct S {
|
||||
// a : @stride(32) array<f32, 4>,
|
||||
// a : @stride(32) array<f32, 4u>,
|
||||
// };
|
||||
// @group(0) @binding(0) var<storage> s : S;
|
||||
//
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let a : @stride(32) array<f32, 4> = s.a;
|
||||
// let a : @stride(32) array<f32, 4u> = s.a;
|
||||
// let b : f32 = s.a[1];
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4>(32))});
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4u>(32))});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4>(32), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1))),
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4u>(32), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@ -268,15 +270,15 @@ struct strided_arr {
|
||||
}
|
||||
|
||||
struct S {
|
||||
a : array<strided_arr, 4>,
|
||||
a : array<strided_arr, 4u>,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<storage> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let a : array<strided_arr, 4> = s.a;
|
||||
let b : f32 = s.a[1].el;
|
||||
let a : array<strided_arr, 4u> = s.a;
|
||||
let b : f32 = s.a[1i].el;
|
||||
}
|
||||
)";
|
||||
|
||||
@ -287,39 +289,39 @@ fn f() {
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, ReadStorageDefaultStridedArray) {
|
||||
// struct S {
|
||||
// a : @stride(4) array<f32, 4>,
|
||||
// a : @stride(4) array<f32, 4u>,
|
||||
// };
|
||||
// @group(0) @binding(0) var<storage> s : S;
|
||||
//
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let a : @stride(4) array<f32, 4> = s.a;
|
||||
// let a : @stride(4) array<f32, 4u> = s.a;
|
||||
// let b : f32 = s.a[1];
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4>(4))});
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4u>(4))});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4>(4), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1))),
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4u>(4), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
struct S {
|
||||
a : array<f32, 4>,
|
||||
a : array<f32, 4u>,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<storage> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let a : array<f32, 4> = s.a;
|
||||
let b : f32 = s.a[1];
|
||||
let a : array<f32, 4u> = s.a;
|
||||
let b : f32 = s.a[1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -330,30 +332,30 @@ fn f() {
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, WriteStorageStridedArray) {
|
||||
// struct S {
|
||||
// a : @stride(32) array<f32, 4>,
|
||||
// a : @stride(32) array<f32, 4u>,
|
||||
// };
|
||||
// @group(0) @binding(0) var<storage, read_write> s : S;
|
||||
//
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// s.a = @stride(32) array<f32, 4>();
|
||||
// s.a = @stride(32) array<f32, 4>(1.0, 2.0, 3.0, 4.0);
|
||||
// s.a[1] = 5.0;
|
||||
// s.a = @stride(32) array<f32, 4u>();
|
||||
// s.a = @stride(32) array<f32, 4u>(1.0, 2.0, 3.0, 4.0);
|
||||
// s.a[1i] = 5.0;
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4>(32))});
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4u>(32))});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
|
||||
b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.array<f32, 4>(32))),
|
||||
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, 4>(32), 1.0f, 2.0f, 3.0f, 4.0f)),
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1), 5.0f),
|
||||
b.Construct(b.ty.array<f32, 4u>(32), 1.0f, 2.0f, 3.0f, 4.0f)),
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5.0f),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect =
|
||||
@ -364,16 +366,16 @@ struct strided_arr {
|
||||
}
|
||||
|
||||
struct S {
|
||||
a : array<strided_arr, 4>,
|
||||
a : array<strided_arr, 4u>,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
s.a = array<strided_arr, 4>();
|
||||
s.a = array<strided_arr, 4>(strided_arr(1.0), strided_arr(2.0), strided_arr(3.0), strided_arr(4.0));
|
||||
s.a[1].el = 5.0;
|
||||
s.a = array<strided_arr, 4u>();
|
||||
s.a = array<strided_arr, 4u>(strided_arr(1.0), strided_arr(2.0), strided_arr(3.0), strided_arr(4.0));
|
||||
s.a[1i].el = 5.0;
|
||||
}
|
||||
)";
|
||||
|
||||
@ -384,45 +386,45 @@ fn f() {
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, WriteStorageDefaultStridedArray) {
|
||||
// struct S {
|
||||
// a : @stride(4) array<f32, 4>,
|
||||
// a : @stride(4) array<f32, 4u>,
|
||||
// };
|
||||
// @group(0) @binding(0) var<storage, read_write> s : S;
|
||||
//
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// s.a = @stride(4) array<f32, 4>();
|
||||
// s.a = @stride(4) array<f32, 4>(1.0, 2.0, 3.0, 4.0);
|
||||
// s.a = @stride(4) array<f32, 4u>();
|
||||
// s.a = @stride(4) array<f32, 4u>(1.0, 2.0, 3.0, 4.0);
|
||||
// s.a[1] = 5.0;
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4>(4))});
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4u>(4))});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
|
||||
b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.array<f32, 4>(4))),
|
||||
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, 4>(4), 1.0f, 2.0f, 3.0f, 4.0f)),
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1), 5.0f),
|
||||
b.Construct(b.ty.array<f32, 4u>(4), 1.0f, 2.0f, 3.0f, 4.0f)),
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5.0f),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect =
|
||||
R"(
|
||||
struct S {
|
||||
a : array<f32, 4>,
|
||||
a : array<f32, 4u>,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
s.a = array<f32, 4>();
|
||||
s.a = array<f32, 4>(1.0, 2.0, 3.0, 4.0);
|
||||
s.a[1] = 5.0;
|
||||
s.a = array<f32, 4u>();
|
||||
s.a = array<f32, 4u>(1.0, 2.0, 3.0, 4.0);
|
||||
s.a[1i] = 5.0;
|
||||
}
|
||||
)";
|
||||
|
||||
@ -433,7 +435,7 @@ fn f() {
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, ReadWriteViaPointerLets) {
|
||||
// struct S {
|
||||
// a : @stride(32) array<f32, 4>,
|
||||
// a : @stride(32) array<f32, 4u>,
|
||||
// };
|
||||
// @group(0) @binding(0) var<storage, read_write> s : S;
|
||||
//
|
||||
@ -443,11 +445,11 @@ TEST_F(DecomposeStridedArrayTest, ReadWriteViaPointerLets) {
|
||||
// let b = &*&*(a);
|
||||
// let c = *b;
|
||||
// let d = (*b)[1];
|
||||
// (*b) = @stride(32) array<f32, 4>(1.0, 2.0, 3.0, 4.0);
|
||||
// (*b) = @stride(32) array<f32, 4u>(1.0, 2.0, 3.0, 4.0);
|
||||
// (*b)[1] = 5.0;
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4>(32))});
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4u>(32))});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
|
||||
b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
@ -455,13 +457,13 @@ TEST_F(DecomposeStridedArrayTest, ReadWriteViaPointerLets) {
|
||||
b.Decl(b.Let("a", nullptr, b.AddressOf(b.MemberAccessor("s", "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("d", nullptr, b.IndexAccessor(b.Deref("b"), 1))),
|
||||
b.Assign(b.Deref("b"), b.Construct(b.ty.array<f32, 4>(32), 1.0f, 2.0f, 3.0f, 4.0f)),
|
||||
b.Assign(b.IndexAccessor(b.Deref("b"), 1), 5.0f),
|
||||
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.IndexAccessor(b.Deref("b"), 1_i), 5.0f),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect =
|
||||
@ -472,17 +474,17 @@ struct strided_arr {
|
||||
}
|
||||
|
||||
struct S {
|
||||
a : array<strided_arr, 4>,
|
||||
a : array<strided_arr, 4u>,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let c = s.a;
|
||||
let d = s.a[1].el;
|
||||
s.a = array<strided_arr, 4>(strided_arr(1.0), strided_arr(2.0), strided_arr(3.0), strided_arr(4.0));
|
||||
s.a[1].el = 5.0;
|
||||
let d = s.a[1i].el;
|
||||
s.a = array<strided_arr, 4u>(strided_arr(1.0), strided_arr(2.0), strided_arr(3.0), strided_arr(4.0));
|
||||
s.a[1i].el = 5.0;
|
||||
}
|
||||
)";
|
||||
|
||||
@ -492,7 +494,7 @@ fn f() {
|
||||
}
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, PrivateAliasedStridedArray) {
|
||||
// type ARR = @stride(32) array<f32, 4>;
|
||||
// type ARR = @stride(32) array<f32, 4u>;
|
||||
// struct S {
|
||||
// a : ARR,
|
||||
// };
|
||||
@ -507,22 +509,22 @@ TEST_F(DecomposeStridedArrayTest, PrivateAliasedStridedArray) {
|
||||
// s.a[1] = 5.0;
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
b.Alias("ARR", b.ty.array<f32, 4>(32));
|
||||
b.Alias("ARR", b.ty.array<f32, 4u>(32));
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.type_name("ARR"))});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
|
||||
b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("a", b.ty.type_name("ARR"), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1))),
|
||||
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"), 1.0f, 2.0f, 3.0f, 4.0f)),
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1), 5.0f),
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5.0f),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@ -531,7 +533,7 @@ struct strided_arr {
|
||||
el : f32,
|
||||
}
|
||||
|
||||
type ARR = array<strided_arr, 4>;
|
||||
type ARR = array<strided_arr, 4u>;
|
||||
|
||||
struct S {
|
||||
a : ARR,
|
||||
@ -539,13 +541,13 @@ struct S {
|
||||
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let a : ARR = s.a;
|
||||
let b : f32 = s.a[1].el;
|
||||
let b : f32 = s.a[1i].el;
|
||||
s.a = ARR();
|
||||
s.a = ARR(strided_arr(1.0), strided_arr(2.0), strided_arr(3.0), strided_arr(4.0));
|
||||
s.a[1].el = 5.0;
|
||||
s.a[1i].el = 5.0;
|
||||
}
|
||||
)";
|
||||
|
||||
@ -555,8 +557,8 @@ fn f() {
|
||||
}
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) {
|
||||
// type ARR_A = @stride(8) array<f32, 2>;
|
||||
// type ARR_B = @stride(128) array<@stride(16) array<ARR_A, 3>, 4>;
|
||||
// type ARR_A = @stride(8) array<f32, 2u>;
|
||||
// type ARR_B = @stride(128) array<@stride(16) array<ARR_A, 3u>, 4u>;
|
||||
// struct S {
|
||||
// a : ARR_B,
|
||||
// };
|
||||
@ -565,7 +567,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) {
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let a : ARR_B = s.a;
|
||||
// let b : array<@stride(8) array<f32, 2>, 3> = s.a[3];
|
||||
// let b : array<@stride(8) array<f32, 2u>, 3u> = s.a[3];
|
||||
// let c = s.a[3][2];
|
||||
// let d = s.a[3][2][1];
|
||||
// s.a = ARR_B();
|
||||
@ -575,46 +577,46 @@ TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) {
|
||||
ProgramBuilder b;
|
||||
b.Alias("ARR_A", b.ty.array<f32, 2>(8));
|
||||
b.Alias("ARR_B",
|
||||
b.ty.array( //
|
||||
b.ty.array(b.ty.type_name("ARR_A"), 3, 16), //
|
||||
4, 128));
|
||||
b.ty.array( //
|
||||
b.ty.array(b.ty.type_name("ARR_A"), 3_u, 16), //
|
||||
4_u, 128));
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.type_name("ARR_B"))});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
|
||||
b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("a", b.ty.type_name("ARR_B"), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.array(b.ty.type_name("ARR_A"), 3, 16),
|
||||
b.Decl(b.Let("b", b.ty.array(b.ty.type_name("ARR_A"), 3_u, 16),
|
||||
b.IndexAccessor( //
|
||||
b.MemberAccessor("s", "a"), //
|
||||
3))),
|
||||
3_i))),
|
||||
b.Decl(b.Let("c", b.ty.type_name("ARR_A"),
|
||||
b.IndexAccessor( //
|
||||
b.IndexAccessor( //
|
||||
b.MemberAccessor("s", "a"), //
|
||||
3),
|
||||
2))),
|
||||
3_i),
|
||||
2_i))),
|
||||
b.Decl(b.Let("d", b.ty.f32(),
|
||||
b.IndexAccessor( //
|
||||
b.IndexAccessor( //
|
||||
b.IndexAccessor( //
|
||||
b.MemberAccessor("s", "a"), //
|
||||
3),
|
||||
2),
|
||||
1))),
|
||||
3_i),
|
||||
2_i),
|
||||
1_i))),
|
||||
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.type_name("ARR_B"))),
|
||||
b.Assign(b.IndexAccessor( //
|
||||
b.IndexAccessor( //
|
||||
b.IndexAccessor( //
|
||||
b.MemberAccessor("s", "a"), //
|
||||
3),
|
||||
2),
|
||||
1),
|
||||
3_i),
|
||||
2_i),
|
||||
1_i),
|
||||
5.0f),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect =
|
||||
@ -624,14 +626,14 @@ struct strided_arr {
|
||||
el : f32,
|
||||
}
|
||||
|
||||
type ARR_A = array<strided_arr, 2>;
|
||||
type ARR_A = array<strided_arr, 2u>;
|
||||
|
||||
struct strided_arr_1 {
|
||||
@size(128)
|
||||
el : array<ARR_A, 3>,
|
||||
el : array<ARR_A, 3u>,
|
||||
}
|
||||
|
||||
type ARR_B = array<strided_arr_1, 4>;
|
||||
type ARR_B = array<strided_arr_1, 4u>;
|
||||
|
||||
struct S {
|
||||
a : ARR_B,
|
||||
@ -639,14 +641,14 @@ struct S {
|
||||
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let a : ARR_B = s.a;
|
||||
let b : array<ARR_A, 3> = s.a[3].el;
|
||||
let c : ARR_A = s.a[3].el[2];
|
||||
let d : f32 = s.a[3].el[2][1].el;
|
||||
let b : array<ARR_A, 3u> = s.a[3i].el;
|
||||
let c : ARR_A = s.a[3i].el[2i];
|
||||
let d : f32 = s.a[3i].el[2i][1i].el;
|
||||
s.a = ARR_B();
|
||||
s.a[3].el[2][1].el = 5.0;
|
||||
s.a[3i].el[2i][1i].el = 5.0;
|
||||
}
|
||||
)";
|
||||
|
||||
|
@ -40,8 +40,7 @@ struct MatrixInfo {
|
||||
/// @returns a new ast::Array that holds an vector column for each row of the
|
||||
/// matrix.
|
||||
const ast::Array* array(ProgramBuilder* b) const {
|
||||
return b->ty.array(b->ty.vec<ProgramBuilder::f32>(matrix->rows()), matrix->columns(),
|
||||
stride);
|
||||
return b->ty.array(b->ty.vec<f32>(matrix->rows()), u32(matrix->columns()), stride);
|
||||
}
|
||||
|
||||
/// Equality operator
|
||||
@ -172,7 +171,7 @@ void DecomposeStridedMatrix::Run(CloneContext& ctx, const DataMap&, DataMap&) co
|
||||
auto mat = ctx.dst->Sym("m");
|
||||
ast::ExpressionList columns(info.matrix->columns());
|
||||
for (uint32_t i = 0; i < static_cast<uint32_t>(columns.size()); i++) {
|
||||
columns[i] = ctx.dst->IndexAccessor(mat, i);
|
||||
columns[i] = ctx.dst->IndexAccessor(mat, u32(i));
|
||||
}
|
||||
ctx.dst->Func(name,
|
||||
{
|
||||
@ -213,7 +212,7 @@ void DecomposeStridedMatrix::Run(CloneContext& ctx, const DataMap&, DataMap&) co
|
||||
auto arr = ctx.dst->Sym("arr");
|
||||
ast::ExpressionList columns(info.matrix->columns());
|
||||
for (uint32_t i = 0; i < static_cast<uint32_t>(columns.size()); i++) {
|
||||
columns[i] = ctx.dst->IndexAccessor(arr, i);
|
||||
columns[i] = ctx.dst->IndexAccessor(arr, u32(i));
|
||||
}
|
||||
ctx.dst->Func(name,
|
||||
{
|
||||
|
@ -24,11 +24,12 @@
|
||||
#include "src/tint/transform/test_helper.h"
|
||||
#include "src/tint/transform/unshadow.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
namespace {
|
||||
|
||||
using DecomposeStridedMatrixTest = TransformTest;
|
||||
using f32 = ProgramBuilder::f32;
|
||||
|
||||
TEST_F(DecomposeStridedMatrixTest, ShouldRunEmptyModule) {
|
||||
auto* src = R"()";
|
||||
@ -82,7 +83,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformMatrix) {
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@ -98,7 +99,7 @@ fn arr_to_mat2x2_stride_32(arr : @stride(32) array<vec2<f32>, 2u>) -> mat2x2<f32
|
||||
return mat2x2<f32>(arr[0u], arr[1u]);
|
||||
}
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let x : mat2x2<f32> = arr_to_mat2x2_stride_32(s.m);
|
||||
}
|
||||
@ -132,14 +133,15 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformColumn) {
|
||||
}),
|
||||
});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("x", b.ty.vec2<f32>(), b.IndexAccessor(b.MemberAccessor("s", "m"), 1))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
});
|
||||
b.Func(
|
||||
"f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("x", b.ty.vec2<f32>(), b.IndexAccessor(b.MemberAccessor("s", "m"), 1_i))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
struct S {
|
||||
@ -150,9 +152,9 @@ struct S {
|
||||
|
||||
@group(0) @binding(0) var<uniform> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let x : vec2<f32> = s.m[1];
|
||||
let x : vec2<f32> = s.m[1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -190,7 +192,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformMatrix_DefaultStride) {
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@ -203,7 +205,7 @@ struct S {
|
||||
|
||||
@group(0) @binding(0) var<uniform> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let x : mat2x2<f32> = s.m;
|
||||
}
|
||||
@ -244,7 +246,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageMatrix) {
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@ -260,7 +262,7 @@ fn arr_to_mat2x2_stride_32(arr : @stride(32) array<vec2<f32>, 2u>) -> mat2x2<f32
|
||||
return mat2x2<f32>(arr[0u], arr[1u]);
|
||||
}
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let x : mat2x2<f32> = arr_to_mat2x2_stride_32(s.m);
|
||||
}
|
||||
@ -295,14 +297,15 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageColumn) {
|
||||
});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
|
||||
b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("x", b.ty.vec2<f32>(), b.IndexAccessor(b.MemberAccessor("s", "m"), 1))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
});
|
||||
b.Func(
|
||||
"f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("x", b.ty.vec2<f32>(), b.IndexAccessor(b.MemberAccessor("s", "m"), 1_i))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
struct S {
|
||||
@ -313,9 +316,9 @@ struct S {
|
||||
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let x : vec2<f32> = s.m[1];
|
||||
let x : vec2<f32> = s.m[1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -355,7 +358,7 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageMatrix) {
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@ -371,7 +374,7 @@ fn mat2x2_stride_32_to_arr(m : mat2x2<f32>) -> @stride(32) array<vec2<f32>, 2u>
|
||||
return @stride(32) array<vec2<f32>, 2u>(m[0u], m[1u]);
|
||||
}
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
s.m = mat2x2_stride_32_to_arr(mat2x2<f32>(vec2<f32>(1.0, 2.0), vec2<f32>(3.0, 4.0)));
|
||||
}
|
||||
@ -408,11 +411,11 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageColumn) {
|
||||
b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "m"), 1), b.vec2<f32>(1.0f, 2.0f)),
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "m"), 1_i), b.vec2<f32>(1.0f, 2.0f)),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@ -424,9 +427,9 @@ struct S {
|
||||
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
s.m[1] = vec2<f32>(1.0, 2.0);
|
||||
s.m[1i] = vec2<f32>(1.0, 2.0);
|
||||
}
|
||||
)";
|
||||
|
||||
@ -471,14 +474,14 @@ TEST_F(DecomposeStridedMatrixTest, ReadWriteViaPointerLets) {
|
||||
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("x", nullptr, b.Deref("b"))),
|
||||
b.Decl(b.Let("y", nullptr, b.IndexAccessor(b.Deref("b"), 1))),
|
||||
b.Decl(b.Let("z", nullptr, b.IndexAccessor("x", 1))),
|
||||
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.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), b.vec2<f32>(5.0f, 6.0f)),
|
||||
b.Assign(b.IndexAccessor(b.Deref("b"), 1_i), b.vec2<f32>(5.0f, 6.0f)),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@ -498,13 +501,13 @@ fn mat2x2_stride_32_to_arr(m : mat2x2<f32>) -> @stride(32) array<vec2<f32>, 2u>
|
||||
return @stride(32) array<vec2<f32>, 2u>(m[0u], m[1u]);
|
||||
}
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let x = arr_to_mat2x2_stride_32(s.m);
|
||||
let y = s.m[1];
|
||||
let z = x[1];
|
||||
let y = s.m[1i];
|
||||
let z = x[1i];
|
||||
s.m = mat2x2_stride_32_to_arr(mat2x2<f32>(vec2<f32>(1.0, 2.0), vec2<f32>(3.0, 4.0)));
|
||||
s.m[1] = vec2<f32>(5.0, 6.0);
|
||||
s.m[1i] = vec2<f32>(5.0, 6.0);
|
||||
}
|
||||
)";
|
||||
|
||||
@ -542,7 +545,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadPrivateMatrix) {
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@ -555,7 +558,7 @@ struct S {
|
||||
|
||||
var<private> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let x : mat2x2<f32> = s.m;
|
||||
}
|
||||
@ -596,7 +599,7 @@ TEST_F(DecomposeStridedMatrixTest, WritePrivateMatrix) {
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@ -609,7 +612,7 @@ struct S {
|
||||
|
||||
var<private> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
s.m = mat2x2<f32>(vec2<f32>(1.0, 2.0), vec2<f32>(3.0, 4.0));
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::ExpandCompoundAssignment);
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
|
||||
ExpandCompoundAssignment::ExpandCompoundAssignment() = default;
|
||||
@ -172,8 +174,8 @@ void ExpandCompoundAssignment::Run(CloneContext& ctx, const DataMap&, DataMap&)
|
||||
auto* sem_lhs = ctx.src->Sem().Get(inc_dec->lhs);
|
||||
const ast::IntLiteralExpression* one =
|
||||
sem_lhs->Type()->UnwrapRef()->is_signed_integer_scalar()
|
||||
? ctx.dst->Expr(1)->As<ast::IntLiteralExpression>()
|
||||
: ctx.dst->Expr(1u)->As<ast::IntLiteralExpression>();
|
||||
? ctx.dst->Expr(1_i)->As<ast::IntLiteralExpression>()
|
||||
: ctx.dst->Expr(1_u)->As<ast::IntLiteralExpression>();
|
||||
auto op = inc_dec->increment ? ast::BinaryOp::kAdd : ast::BinaryOp::kSubtract;
|
||||
state.Expand(inc_dec, inc_dec->lhs, one, op);
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ fn main() {
|
||||
auto* expect = R"(
|
||||
fn main() {
|
||||
var v : i32;
|
||||
v = (v + 1);
|
||||
v = (v + 1i);
|
||||
}
|
||||
)";
|
||||
|
||||
@ -513,7 +513,7 @@ fn main() {
|
||||
auto* expect = R"(
|
||||
fn main() {
|
||||
var v : i32;
|
||||
v = (v - 1);
|
||||
v = (v - 1i);
|
||||
}
|
||||
)";
|
||||
|
||||
@ -556,7 +556,7 @@ fn main() {
|
||||
var v : i32;
|
||||
let p = &(v);
|
||||
let tint_symbol = &(*(p));
|
||||
*(tint_symbol) = (*(tint_symbol) + 1);
|
||||
*(tint_symbol) = (*(tint_symbol) + 1i);
|
||||
}
|
||||
)";
|
||||
|
||||
@ -584,7 +584,7 @@ struct S {
|
||||
|
||||
fn main() {
|
||||
var s : S;
|
||||
s.m = (s.m + 1);
|
||||
s.m = (s.m + 1i);
|
||||
}
|
||||
)";
|
||||
|
||||
@ -617,7 +617,7 @@ fn idx() -> i32 {
|
||||
|
||||
fn main() {
|
||||
let tint_symbol = &(a[idx()]);
|
||||
*(tint_symbol) = (*(tint_symbol) + 1);
|
||||
*(tint_symbol) = (*(tint_symbol) + 1i);
|
||||
}
|
||||
)";
|
||||
|
||||
@ -651,7 +651,7 @@ fn idx() -> i32 {
|
||||
fn main() {
|
||||
let tint_symbol = &(v);
|
||||
let tint_symbol_1 = idx();
|
||||
(*(tint_symbol))[tint_symbol_1] = ((*(tint_symbol))[tint_symbol_1] + 1);
|
||||
(*(tint_symbol))[tint_symbol_1] = ((*(tint_symbol))[tint_symbol_1] + 1i);
|
||||
}
|
||||
)";
|
||||
|
||||
@ -671,7 +671,7 @@ fn main() {
|
||||
auto* expect = R"(
|
||||
fn main() {
|
||||
var v : vec4<i32>;
|
||||
v.y = (v.y + 1);
|
||||
v.y = (v.y + 1i);
|
||||
}
|
||||
)";
|
||||
|
||||
@ -727,7 +727,7 @@ fn main() {
|
||||
continuing {
|
||||
let tint_symbol = &(a[idx1()]);
|
||||
let tint_symbol_1 = idx2();
|
||||
(*(tint_symbol))[tint_symbol_1] = ((*(tint_symbol))[tint_symbol_1] + 1);
|
||||
(*(tint_symbol))[tint_symbol_1] = ((*(tint_symbol))[tint_symbol_1] + 1i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ fn f() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
var<private> a : i32 = 123;
|
||||
var<private> a : i32 = 123i;
|
||||
|
||||
var<private> b : u32 = 123u;
|
||||
|
||||
@ -66,7 +66,7 @@ fn f() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
var<private> a : i32 = 123;
|
||||
var<private> a : i32 = 123i;
|
||||
|
||||
var<private> b : u32 = 123u;
|
||||
|
||||
@ -95,7 +95,7 @@ fn f() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
var<private> a : i32 = 123;
|
||||
var<private> a : i32 = 123i;
|
||||
|
||||
var<private> b : u32 = 123u;
|
||||
|
||||
@ -124,7 +124,7 @@ fn f() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
var<private> a : vec3<i32> = vec3<i32>(123);
|
||||
var<private> a : vec3<i32> = vec3<i32>(123i);
|
||||
|
||||
var<private> b : vec3<u32> = vec3<u32>(123u);
|
||||
|
||||
@ -153,7 +153,7 @@ fn f() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
var<private> a : vec3<i32> = vec3<i32>(123);
|
||||
var<private> a : vec3<i32> = vec3<i32>(123i);
|
||||
|
||||
var<private> b : vec3<u32> = vec3<u32>(123u);
|
||||
|
||||
@ -182,7 +182,7 @@ fn f() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
var<private> a : vec3<i32> = vec3<i32>(123);
|
||||
var<private> a : vec3<i32> = vec3<i32>(123i);
|
||||
|
||||
var<private> b : vec3<u32> = vec3<u32>(123u);
|
||||
|
||||
@ -212,13 +212,13 @@ fn f() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
var<private> a : vec4<i32> = vec4<i32>(1, 2, 3, 4);
|
||||
var<private> a : vec4<i32> = vec4<i32>(1i, 2i, 3i, 4i);
|
||||
|
||||
var<private> b : vec4<i32> = vec4<i32>(1, 2, 4, 5);
|
||||
var<private> b : vec4<i32> = vec4<i32>(1i, 2i, 4i, 5i);
|
||||
|
||||
var<private> c : vec4<i32> = vec4<i32>(1, 2, 3, 4);
|
||||
var<private> c : vec4<i32> = vec4<i32>(1i, 2i, 3i, 4i);
|
||||
|
||||
var<private> d : vec4<i32> = vec4<i32>(1, 2, 3, 4);
|
||||
var<private> d : vec4<i32> = vec4<i32>(1i, 2i, 3i, 4i);
|
||||
|
||||
var<private> e : vec4<bool> = vec4<bool>(false, true, false, true);
|
||||
|
||||
@ -243,7 +243,7 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var a : i32 = 123;
|
||||
var a : i32 = 123i;
|
||||
var b : u32 = 123u;
|
||||
var c : f32 = 123.0;
|
||||
var d : bool = true;
|
||||
@ -267,7 +267,7 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var a : i32 = 123;
|
||||
var a : i32 = 123i;
|
||||
var b : u32 = 123u;
|
||||
var c : f32 = 123.0;
|
||||
var d : bool = true;
|
||||
@ -291,7 +291,7 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var a : i32 = 123;
|
||||
var a : i32 = 123i;
|
||||
var b : u32 = 123u;
|
||||
var c : f32 = 123.0;
|
||||
var d : bool = true;
|
||||
@ -306,7 +306,7 @@ fn f() {
|
||||
TEST_F(FoldConstantsTest, Function_Vector_NoConversion) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
var a : vec3<i32> = vec3<i32>(123);
|
||||
var a : vec3<i32> = vec3<i32>(123i);
|
||||
var b : vec3<u32> = vec3<u32>(123u);
|
||||
var c : vec3<f32> = vec3<f32>(123.0);
|
||||
var d : vec3<bool> = vec3<bool>(true);
|
||||
@ -315,7 +315,7 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var a : vec3<i32> = vec3<i32>(123);
|
||||
var a : vec3<i32> = vec3<i32>(123i);
|
||||
var b : vec3<u32> = vec3<u32>(123u);
|
||||
var c : vec3<f32> = vec3<f32>(123.0);
|
||||
var d : vec3<bool> = vec3<bool>(true);
|
||||
@ -339,7 +339,7 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var a : vec3<i32> = vec3<i32>(123);
|
||||
var a : vec3<i32> = vec3<i32>(123i);
|
||||
var b : vec3<u32> = vec3<u32>(123u);
|
||||
var c : vec3<f32> = vec3<f32>(123.0);
|
||||
var d : vec3<bool> = vec3<bool>(true);
|
||||
@ -363,7 +363,7 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var a : vec3<i32> = vec3<i32>(123);
|
||||
var a : vec3<i32> = vec3<i32>(123i);
|
||||
var b : vec3<u32> = vec3<u32>(123u);
|
||||
var c : vec3<f32> = vec3<f32>(123.0);
|
||||
var d : vec3<bool> = vec3<bool>(true);
|
||||
@ -388,10 +388,10 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var a : vec4<i32> = vec4<i32>(1, 2, 3, 4);
|
||||
var b : vec4<i32> = vec4<i32>(1, 2, 4, 5);
|
||||
var c : vec4<i32> = vec4<i32>(1, 2, 3, 4);
|
||||
var d : vec4<i32> = vec4<i32>(1, 2, 3, 4);
|
||||
var a : vec4<i32> = vec4<i32>(1i, 2i, 3i, 4i);
|
||||
var b : vec4<i32> = vec4<i32>(1i, 2i, 4i, 5i);
|
||||
var c : vec4<i32> = vec4<i32>(1i, 2i, 3i, 4i);
|
||||
var d : vec4<i32> = vec4<i32>(1i, 2i, 3i, 4i);
|
||||
var e : vec4<bool> = vec4<bool>(false, true, false, true);
|
||||
}
|
||||
)";
|
||||
|
@ -26,6 +26,8 @@
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::MultiplanarExternalTexture);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::MultiplanarExternalTexture::NewBindingPoints);
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
namespace {
|
||||
|
||||
@ -261,7 +263,6 @@ struct MultiplanarExternalTexture::State {
|
||||
/// Creates the gammaCorrection function if needed and returns a call
|
||||
/// expression to it.
|
||||
void createGammaCorrectionFn() {
|
||||
using f32 = ProgramBuilder::f32;
|
||||
ast::VariableList varList = {b.Param("v", b.ty.vec3<f32>()),
|
||||
b.Param("params", b.ty.type_name(gamma_transfer_struct_sym))};
|
||||
|
||||
@ -298,7 +299,6 @@ struct MultiplanarExternalTexture::State {
|
||||
/// @param call_type determines which function body to generate
|
||||
/// @returns a statement list that makes of the body of the chosen function
|
||||
ast::StatementList createTexFnExtStatementList(sem::BuiltinType call_type) {
|
||||
using f32 = ProgramBuilder::f32;
|
||||
const ast::CallExpression* single_plane_call = nullptr;
|
||||
const ast::CallExpression* plane_0_call = nullptr;
|
||||
const ast::CallExpression* plane_1_call = nullptr;
|
||||
@ -311,11 +311,11 @@ struct MultiplanarExternalTexture::State {
|
||||
plane_1_call = b.Call("textureSampleLevel", "plane1", "smp", "coord", 0.0f);
|
||||
} else if (call_type == sem::BuiltinType::kTextureLoad) {
|
||||
// textureLoad(plane0, coords.xy, 0);
|
||||
single_plane_call = b.Call("textureLoad", "plane0", "coord", 0);
|
||||
single_plane_call = b.Call("textureLoad", "plane0", "coord", 0_i);
|
||||
// textureLoad(plane0, coords.xy, 0);
|
||||
plane_0_call = b.Call("textureLoad", "plane0", "coord", 0);
|
||||
plane_0_call = b.Call("textureLoad", "plane0", "coord", 0_i);
|
||||
// textureLoad(plane1, coords.xy, 0);
|
||||
plane_1_call = b.Call("textureLoad", "plane1", "coord", 0);
|
||||
plane_1_call = b.Call("textureLoad", "plane1", "coord", 0_i);
|
||||
} else {
|
||||
TINT_ICE(Transform, b.Diagnostics()) << "unhandled builtin: " << call_type;
|
||||
}
|
||||
@ -325,7 +325,7 @@ struct MultiplanarExternalTexture::State {
|
||||
b.Decl(b.Var("color", b.ty.vec3(b.ty.f32()))),
|
||||
// if ((params.numPlanes == 1u))
|
||||
b.If(b.create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kEqual, b.MemberAccessor("params", "numPlanes"), b.Expr(1u)),
|
||||
ast::BinaryOp::kEqual, b.MemberAccessor("params", "numPlanes"), b.Expr(1_u)),
|
||||
b.Block(
|
||||
// color = textureLoad(plane0, coord, 0).rgb;
|
||||
b.Assign("color", b.MemberAccessor(single_plane_call, "rgb"))),
|
||||
|
@ -392,9 +392,9 @@ fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
color = textureLoad(plane0, coord, 0i).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0i).r, textureLoad(plane1, coord, 0i).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
@ -460,9 +460,9 @@ fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
color = textureLoad(plane0, coord, 0i).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0i).r, textureLoad(plane1, coord, 0i).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
@ -549,9 +549,9 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
color = textureLoad(plane0, coord, 0i).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0i).r, textureLoad(plane1, coord, 0i).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
@ -632,9 +632,9 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
color = textureLoad(plane0, coord, 0i).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0i).r, textureLoad(plane1, coord, 0i).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
|
@ -28,6 +28,8 @@
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::Robustness);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::Robustness::Config);
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
|
||||
/// State holds the current transform state
|
||||
@ -59,7 +61,6 @@ struct Robustness::State {
|
||||
auto* ret_unwrapped = ret_type->UnwrapRef();
|
||||
|
||||
ProgramBuilder& b = *ctx.dst;
|
||||
using u32 = ProgramBuilder::u32;
|
||||
|
||||
struct Value {
|
||||
const ast::Expression* expr = nullptr; // If null, then is a constant
|
||||
@ -103,7 +104,7 @@ struct Robustness::State {
|
||||
limit.is_signed = false; // Like size, limit is always unsigned.
|
||||
if (size.expr) {
|
||||
// Dynamic size
|
||||
limit.expr = b.Sub(size.expr, 1u);
|
||||
limit.expr = b.Sub(size.expr, 1_u);
|
||||
} else {
|
||||
// Constant size
|
||||
limit.u32 = size.u32 - 1u;
|
||||
@ -158,10 +159,10 @@ struct Robustness::State {
|
||||
|
||||
// Convert idx and limit to expressions, so we can emit `min(idx, limit)`.
|
||||
if (!idx.expr) {
|
||||
idx.expr = b.Expr(idx.u32);
|
||||
idx.expr = b.Expr(u32(idx.u32));
|
||||
}
|
||||
if (!limit.expr) {
|
||||
limit.expr = b.Expr(limit.u32);
|
||||
limit.expr = b.Expr(u32(limit.u32));
|
||||
}
|
||||
|
||||
// Perform the clamp with `min(idx, limit)`
|
||||
@ -182,8 +183,8 @@ struct Robustness::State {
|
||||
|
||||
// Convert idx to an expression, so we can emit the new accessor.
|
||||
if (!idx.expr) {
|
||||
idx.expr = idx.is_signed ? static_cast<const ast::Expression*>(b.Expr(idx.i32))
|
||||
: static_cast<const ast::Expression*>(b.Expr(idx.u32));
|
||||
idx.expr = idx.is_signed ? static_cast<const ast::Expression*>(b.Expr(i32(idx.i32)))
|
||||
: static_cast<const ast::Expression*>(b.Expr(u32(idx.u32)));
|
||||
}
|
||||
|
||||
// Clone arguments outside of create() call to have deterministic ordering
|
||||
@ -236,8 +237,8 @@ struct Robustness::State {
|
||||
level_arg = [&] {
|
||||
auto* arg = expr->args[level_idx];
|
||||
auto* num_levels = b.Call("textureNumLevels", ctx.Clone(texture_arg));
|
||||
auto* zero = b.Expr(0);
|
||||
auto* max = ctx.dst->Sub(num_levels, 1);
|
||||
auto* zero = b.Expr(0_i);
|
||||
auto* max = ctx.dst->Sub(num_levels, 1_i);
|
||||
auto* clamped = b.Call("clamp", ctx.Clone(arg), zero, max);
|
||||
return clamped;
|
||||
};
|
||||
@ -250,7 +251,7 @@ struct Robustness::State {
|
||||
: b.Call("textureDimensions", ctx.Clone(texture_arg));
|
||||
auto* zero = b.Construct(CreateASTTypeFor(ctx, coords_ty));
|
||||
auto* max =
|
||||
ctx.dst->Sub(texture_dims, b.Construct(CreateASTTypeFor(ctx, coords_ty), 1));
|
||||
ctx.dst->Sub(texture_dims, b.Construct(CreateASTTypeFor(ctx, coords_ty), 1_i));
|
||||
auto* clamped_coords = b.Call("clamp", ctx.Clone(coords_arg), zero, max);
|
||||
ctx.Replace(coords_arg, clamped_coords);
|
||||
}
|
||||
@ -259,8 +260,8 @@ struct Robustness::State {
|
||||
if (array_idx >= 0) {
|
||||
auto* arg = expr->args[array_idx];
|
||||
auto* num_layers = b.Call("textureNumLayers", ctx.Clone(texture_arg));
|
||||
auto* zero = b.Expr(0);
|
||||
auto* max = ctx.dst->Sub(num_layers, 1);
|
||||
auto* zero = b.Expr(0_i);
|
||||
auto* max = ctx.dst->Sub(num_layers, 1_i);
|
||||
auto* clamped = b.Call("clamp", ctx.Clone(arg), zero, max);
|
||||
ctx.Replace(arg, clamped);
|
||||
}
|
||||
@ -268,7 +269,7 @@ struct Robustness::State {
|
||||
// Clamp the level argument, if provided
|
||||
if (level_idx >= 0) {
|
||||
auto* arg = expr->args[level_idx];
|
||||
ctx.Replace(arg, level_arg ? level_arg() : ctx.dst->Expr(0));
|
||||
ctx.Replace(arg, level_arg ? level_arg() : ctx.dst->Expr(0_i));
|
||||
}
|
||||
|
||||
return nullptr; // Clone, which will use the argument replacements above.
|
||||
|
@ -138,7 +138,7 @@ TEST_F(RobustnessTest, Array_Idx_Scalar) {
|
||||
var<private> a : array<f32, 3>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[1];
|
||||
var b : f32 = a[1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -146,7 +146,7 @@ fn f() {
|
||||
var<private> a : array<f32, 3>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[1];
|
||||
var b : f32 = a[1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -158,7 +158,7 @@ fn f() {
|
||||
TEST_F(RobustnessTest, Array_Idx_Scalar_OutOfOrder) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[1];
|
||||
var b : f32 = a[1i];
|
||||
}
|
||||
|
||||
var<private> a : array<f32, 3>;
|
||||
@ -166,7 +166,7 @@ var<private> a : array<f32, 3>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[1];
|
||||
var b : f32 = a[1i];
|
||||
}
|
||||
|
||||
var<private> a : array<f32, 3>;
|
||||
@ -242,7 +242,7 @@ fn f() {
|
||||
var<private> a : array<f32, 3>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[0];
|
||||
var b : f32 = a[0i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -262,7 +262,7 @@ var<private> a : array<f32, 3>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[0];
|
||||
var b : f32 = a[0i];
|
||||
}
|
||||
|
||||
var<private> a : array<f32, 3>;
|
||||
@ -286,7 +286,7 @@ fn f() {
|
||||
var<private> a : array<f32, 3>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[2];
|
||||
var b : f32 = a[2i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -306,7 +306,7 @@ var<private> a : array<f32, 3>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[2];
|
||||
var b : f32 = a[2i];
|
||||
}
|
||||
|
||||
var<private> a : array<f32, 3>;
|
||||
@ -402,7 +402,7 @@ TEST_F(RobustnessTest, Vector_Idx_Scalar) {
|
||||
var<private> a : vec3<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[1];
|
||||
var b : f32 = a[1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -410,7 +410,7 @@ fn f() {
|
||||
var<private> a : vec3<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[1];
|
||||
var b : f32 = a[1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -422,7 +422,7 @@ fn f() {
|
||||
TEST_F(RobustnessTest, Vector_Idx_Scalar_OutOfOrder) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[1];
|
||||
var b : f32 = a[1i];
|
||||
}
|
||||
|
||||
var<private> a : vec3<f32>;
|
||||
@ -430,7 +430,7 @@ var<private> a : vec3<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[1];
|
||||
var b : f32 = a[1i];
|
||||
}
|
||||
|
||||
var<private> a : vec3<f32>;
|
||||
@ -506,7 +506,7 @@ fn f() {
|
||||
var<private> a : vec3<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a.xy[1];
|
||||
var b : f32 = a.xy[1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -526,7 +526,7 @@ var<private> a : vec3<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a.xy[1];
|
||||
var b : f32 = a.xy[1i];
|
||||
}
|
||||
|
||||
var<private> a : vec3<f32>;
|
||||
@ -654,7 +654,7 @@ fn f() {
|
||||
var<private> a : vec3<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[0];
|
||||
var b : f32 = a[0i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -674,7 +674,7 @@ var<private> a : vec3<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[0];
|
||||
var b : f32 = a[0i];
|
||||
}
|
||||
|
||||
var<private> a : vec3<f32>;
|
||||
@ -698,7 +698,7 @@ fn f() {
|
||||
var<private> a : vec3<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[2];
|
||||
var b : f32 = a[2i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -718,7 +718,7 @@ var<private> a : vec3<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[2];
|
||||
var b : f32 = a[2i];
|
||||
}
|
||||
|
||||
var<private> a : vec3<f32>;
|
||||
@ -734,7 +734,7 @@ TEST_F(RobustnessTest, Matrix_Idx_Scalar) {
|
||||
var<private> a : mat3x2<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[2][1];
|
||||
var b : f32 = a[2i][1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -742,7 +742,7 @@ fn f() {
|
||||
var<private> a : mat3x2<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[2][1];
|
||||
var b : f32 = a[2i][1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -754,7 +754,7 @@ fn f() {
|
||||
TEST_F(RobustnessTest, Matrix_Idx_Scalar_OutOfOrder) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[2][1];
|
||||
var b : f32 = a[2i][1i];
|
||||
}
|
||||
|
||||
var<private> a : mat3x2<f32>;
|
||||
@ -762,7 +762,7 @@ var<private> a : mat3x2<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[2][1];
|
||||
var b : f32 = a[2i][1i];
|
||||
}
|
||||
|
||||
var<private> a : mat3x2<f32>;
|
||||
@ -790,7 +790,7 @@ var<private> a : mat3x2<f32>;
|
||||
var<private> c : i32;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[min(u32(((c + 2) - 3)), 2u)][1];
|
||||
var b : f32 = a[min(u32(((c + 2) - 3)), 2u)][1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -812,7 +812,7 @@ var<private> a : mat3x2<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[min(u32(((c + 2) - 3)), 2u)][1];
|
||||
var b : f32 = a[min(u32(((c + 2) - 3)), 2u)][1i];
|
||||
}
|
||||
|
||||
var<private> c : i32;
|
||||
@ -842,7 +842,7 @@ var<private> a : mat3x2<f32>;
|
||||
var<private> c : i32;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[1][min(u32(((c + 2) - 3)), 1u)];
|
||||
var b : f32 = a[1i][min(u32(((c + 2) - 3)), 1u)];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -864,7 +864,7 @@ var<private> a : mat3x2<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[1][min(u32(((c + 2) - 3)), 1u)];
|
||||
var b : f32 = a[1i][min(u32(((c + 2) - 3)), 1u)];
|
||||
}
|
||||
|
||||
var<private> c : i32;
|
||||
@ -890,7 +890,7 @@ fn f() {
|
||||
var<private> a : mat3x2<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[0][1];
|
||||
var b : f32 = a[0i][1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -910,7 +910,7 @@ var<private> a : mat3x2<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[0][1];
|
||||
var b : f32 = a[0i][1i];
|
||||
}
|
||||
|
||||
var<private> a : mat3x2<f32>;
|
||||
@ -934,7 +934,7 @@ fn f() {
|
||||
var<private> a : mat3x2<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[2][0];
|
||||
var b : f32 = a[2i][0i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -954,7 +954,7 @@ var<private> a : mat3x2<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[2][0];
|
||||
var b : f32 = a[2i][0i];
|
||||
}
|
||||
|
||||
var<private> a : mat3x2<f32>;
|
||||
@ -978,7 +978,7 @@ fn f() {
|
||||
var<private> a : mat3x2<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[2][1];
|
||||
var b : f32 = a[2i][1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -998,7 +998,7 @@ var<private> a : mat3x2<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[2][1];
|
||||
var b : f32 = a[2i][1i];
|
||||
}
|
||||
|
||||
var<private> a : mat3x2<f32>;
|
||||
@ -1022,7 +1022,7 @@ fn f() {
|
||||
var<private> a : mat3x2<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[2][1];
|
||||
var b : f32 = a[2i][1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@ -1042,7 +1042,7 @@ var<private> a : mat3x2<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[2][1];
|
||||
var b : f32 = a[2i][1i];
|
||||
}
|
||||
|
||||
var<private> a : mat3x2<f32>;
|
||||
@ -1202,14 +1202,14 @@ fn f() {
|
||||
var array_idx : i32;
|
||||
var level_idx : i32;
|
||||
var sample_idx : i32;
|
||||
textureLoad(tex_1d, clamp(1, i32(), (textureDimensions(tex_1d, clamp(level_idx, 0, (textureNumLevels(tex_1d) - 1))) - i32(1))), clamp(level_idx, 0, (textureNumLevels(tex_1d) - 1)));
|
||||
textureLoad(tex_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d, clamp(level_idx, 0, (textureNumLevels(tex_2d) - 1))) - vec2<i32>(1))), clamp(level_idx, 0, (textureNumLevels(tex_2d) - 1)));
|
||||
textureLoad(tex_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d_arr, clamp(level_idx, 0, (textureNumLevels(tex_2d_arr) - 1))) - vec2<i32>(1))), clamp(array_idx, 0, (textureNumLayers(tex_2d_arr) - 1)), clamp(level_idx, 0, (textureNumLevels(tex_2d_arr) - 1)));
|
||||
textureLoad(tex_3d, clamp(vec3<i32>(1, 2, 3), vec3<i32>(), (textureDimensions(tex_3d, clamp(level_idx, 0, (textureNumLevels(tex_3d) - 1))) - vec3<i32>(1))), clamp(level_idx, 0, (textureNumLevels(tex_3d) - 1)));
|
||||
textureLoad(tex_ms_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_ms_2d) - vec2<i32>(1))), sample_idx);
|
||||
textureLoad(tex_depth_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d, clamp(level_idx, 0, (textureNumLevels(tex_depth_2d) - 1))) - vec2<i32>(1))), clamp(level_idx, 0, (textureNumLevels(tex_depth_2d) - 1)));
|
||||
textureLoad(tex_depth_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d_arr, clamp(level_idx, 0, (textureNumLevels(tex_depth_2d_arr) - 1))) - vec2<i32>(1))), clamp(array_idx, 0, (textureNumLayers(tex_depth_2d_arr) - 1)), clamp(level_idx, 0, (textureNumLevels(tex_depth_2d_arr) - 1)));
|
||||
textureLoad(tex_external, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_external) - vec2<i32>(1))));
|
||||
textureLoad(tex_1d, clamp(1, i32(), (textureDimensions(tex_1d, clamp(level_idx, 0i, (textureNumLevels(tex_1d) - 1i))) - i32(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_1d) - 1i)));
|
||||
textureLoad(tex_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d, clamp(level_idx, 0i, (textureNumLevels(tex_2d) - 1i))) - vec2<i32>(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_2d) - 1i)));
|
||||
textureLoad(tex_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d_arr, clamp(level_idx, 0i, (textureNumLevels(tex_2d_arr) - 1i))) - vec2<i32>(1i))), clamp(array_idx, 0i, (textureNumLayers(tex_2d_arr) - 1i)), clamp(level_idx, 0i, (textureNumLevels(tex_2d_arr) - 1i)));
|
||||
textureLoad(tex_3d, clamp(vec3<i32>(1, 2, 3), vec3<i32>(), (textureDimensions(tex_3d, clamp(level_idx, 0i, (textureNumLevels(tex_3d) - 1i))) - vec3<i32>(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_3d) - 1i)));
|
||||
textureLoad(tex_ms_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_ms_2d) - vec2<i32>(1i))), sample_idx);
|
||||
textureLoad(tex_depth_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d, clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d) - 1i))) - vec2<i32>(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d) - 1i)));
|
||||
textureLoad(tex_depth_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d_arr, clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d_arr) - 1i))) - vec2<i32>(1i))), clamp(array_idx, 0i, (textureNumLayers(tex_depth_2d_arr) - 1i)), clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d_arr) - 1i)));
|
||||
textureLoad(tex_external, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_external) - vec2<i32>(1i))));
|
||||
}
|
||||
)";
|
||||
|
||||
@ -1252,14 +1252,14 @@ fn f() {
|
||||
var array_idx : i32;
|
||||
var level_idx : i32;
|
||||
var sample_idx : i32;
|
||||
textureLoad(tex_1d, clamp(1, i32(), (textureDimensions(tex_1d, clamp(level_idx, 0, (textureNumLevels(tex_1d) - 1))) - i32(1))), clamp(level_idx, 0, (textureNumLevels(tex_1d) - 1)));
|
||||
textureLoad(tex_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d, clamp(level_idx, 0, (textureNumLevels(tex_2d) - 1))) - vec2<i32>(1))), clamp(level_idx, 0, (textureNumLevels(tex_2d) - 1)));
|
||||
textureLoad(tex_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d_arr, clamp(level_idx, 0, (textureNumLevels(tex_2d_arr) - 1))) - vec2<i32>(1))), clamp(array_idx, 0, (textureNumLayers(tex_2d_arr) - 1)), clamp(level_idx, 0, (textureNumLevels(tex_2d_arr) - 1)));
|
||||
textureLoad(tex_3d, clamp(vec3<i32>(1, 2, 3), vec3<i32>(), (textureDimensions(tex_3d, clamp(level_idx, 0, (textureNumLevels(tex_3d) - 1))) - vec3<i32>(1))), clamp(level_idx, 0, (textureNumLevels(tex_3d) - 1)));
|
||||
textureLoad(tex_ms_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_ms_2d) - vec2<i32>(1))), sample_idx);
|
||||
textureLoad(tex_depth_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d, clamp(level_idx, 0, (textureNumLevels(tex_depth_2d) - 1))) - vec2<i32>(1))), clamp(level_idx, 0, (textureNumLevels(tex_depth_2d) - 1)));
|
||||
textureLoad(tex_depth_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d_arr, clamp(level_idx, 0, (textureNumLevels(tex_depth_2d_arr) - 1))) - vec2<i32>(1))), clamp(array_idx, 0, (textureNumLayers(tex_depth_2d_arr) - 1)), clamp(level_idx, 0, (textureNumLevels(tex_depth_2d_arr) - 1)));
|
||||
textureLoad(tex_external, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_external) - vec2<i32>(1))));
|
||||
textureLoad(tex_1d, clamp(1, i32(), (textureDimensions(tex_1d, clamp(level_idx, 0i, (textureNumLevels(tex_1d) - 1i))) - i32(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_1d) - 1i)));
|
||||
textureLoad(tex_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d, clamp(level_idx, 0i, (textureNumLevels(tex_2d) - 1i))) - vec2<i32>(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_2d) - 1i)));
|
||||
textureLoad(tex_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d_arr, clamp(level_idx, 0i, (textureNumLevels(tex_2d_arr) - 1i))) - vec2<i32>(1i))), clamp(array_idx, 0i, (textureNumLayers(tex_2d_arr) - 1i)), clamp(level_idx, 0i, (textureNumLevels(tex_2d_arr) - 1i)));
|
||||
textureLoad(tex_3d, clamp(vec3<i32>(1, 2, 3), vec3<i32>(), (textureDimensions(tex_3d, clamp(level_idx, 0i, (textureNumLevels(tex_3d) - 1i))) - vec3<i32>(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_3d) - 1i)));
|
||||
textureLoad(tex_ms_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_ms_2d) - vec2<i32>(1i))), sample_idx);
|
||||
textureLoad(tex_depth_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d, clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d) - 1i))) - vec2<i32>(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d) - 1i)));
|
||||
textureLoad(tex_depth_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d_arr, clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d_arr) - 1i))) - vec2<i32>(1i))), clamp(array_idx, 0i, (textureNumLayers(tex_depth_2d_arr) - 1i)), clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d_arr) - 1i)));
|
||||
textureLoad(tex_external, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_external) - vec2<i32>(1i))));
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var tex_1d : texture_1d<f32>;
|
||||
@ -1313,10 +1313,10 @@ fn f() {
|
||||
@group(0) @binding(3) var tex3d : texture_storage_3d<rgba8sint, write>;
|
||||
|
||||
fn f() {
|
||||
textureStore(tex1d, clamp(10, i32(), (textureDimensions(tex1d) - i32(1))), vec4<i32>());
|
||||
textureStore(tex2d, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d) - vec2<i32>(1))), vec4<i32>());
|
||||
textureStore(tex2d_arr, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d_arr) - vec2<i32>(1))), clamp(50, 0, (textureNumLayers(tex2d_arr) - 1)), vec4<i32>());
|
||||
textureStore(tex3d, clamp(vec3<i32>(10, 20, 30), vec3<i32>(), (textureDimensions(tex3d) - vec3<i32>(1))), vec4<i32>());
|
||||
textureStore(tex1d, clamp(10, i32(), (textureDimensions(tex1d) - i32(1i))), vec4<i32>());
|
||||
textureStore(tex2d, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d) - vec2<i32>(1i))), vec4<i32>());
|
||||
textureStore(tex2d_arr, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d_arr) - vec2<i32>(1i))), clamp(50, 0i, (textureNumLayers(tex2d_arr) - 1i)), vec4<i32>());
|
||||
textureStore(tex3d, clamp(vec3<i32>(10, 20, 30), vec3<i32>(), (textureDimensions(tex3d) - vec3<i32>(1i))), vec4<i32>());
|
||||
}
|
||||
)";
|
||||
|
||||
@ -1347,10 +1347,10 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
textureStore(tex1d, clamp(10, i32(), (textureDimensions(tex1d) - i32(1))), vec4<i32>());
|
||||
textureStore(tex2d, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d) - vec2<i32>(1))), vec4<i32>());
|
||||
textureStore(tex2d_arr, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d_arr) - vec2<i32>(1))), clamp(50, 0, (textureNumLayers(tex2d_arr) - 1)), vec4<i32>());
|
||||
textureStore(tex3d, clamp(vec3<i32>(10, 20, 30), vec3<i32>(), (textureDimensions(tex3d) - vec3<i32>(1))), vec4<i32>());
|
||||
textureStore(tex1d, clamp(10, i32(), (textureDimensions(tex1d) - i32(1i))), vec4<i32>());
|
||||
textureStore(tex2d, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d) - vec2<i32>(1i))), vec4<i32>());
|
||||
textureStore(tex2d_arr, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d_arr) - vec2<i32>(1i))), clamp(50, 0i, (textureNumLayers(tex2d_arr) - 1i)), vec4<i32>());
|
||||
textureStore(tex3d, clamp(vec3<i32>(10, 20, 30), vec3<i32>(), (textureDimensions(tex3d) - vec3<i32>(1i))), vec4<i32>());
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var tex1d : texture_storage_1d<rgba8sint, write>;
|
||||
@ -1498,21 +1498,21 @@ struct U {
|
||||
@group(1) @binding(0) var<uniform> u : U;
|
||||
|
||||
fn f() {
|
||||
var i32_sa1 : f32 = s.a[3];
|
||||
var i32_sa2 : f32 = s.a[1];
|
||||
var i32_sa3 : f32 = s.a[0];
|
||||
var i32_sa4 : f32 = s.a[0];
|
||||
var i32_sa5 : f32 = s.a[0];
|
||||
var i32_sa1 : f32 = s.a[3i];
|
||||
var i32_sa2 : f32 = s.a[1i];
|
||||
var i32_sa3 : f32 = s.a[0i];
|
||||
var i32_sa4 : f32 = s.a[0i];
|
||||
var i32_sa5 : f32 = s.a[0i];
|
||||
var i32_sb1 : f32 = s.b[min(4u, (arrayLength(&(s.b)) - 1u))];
|
||||
var i32_sb2 : f32 = s.b[min(1u, (arrayLength(&(s.b)) - 1u))];
|
||||
var i32_sb3 : f32 = s.b[min(0u, (arrayLength(&(s.b)) - 1u))];
|
||||
var i32_sb4 : f32 = s.b[min(0u, (arrayLength(&(s.b)) - 1u))];
|
||||
var i32_sb5 : f32 = s.b[min(0u, (arrayLength(&(s.b)) - 1u))];
|
||||
var i32_ua1 : f32 = u.a[3].x;
|
||||
var i32_ua2 : f32 = u.a[1].x;
|
||||
var i32_ua3 : f32 = u.a[0].x;
|
||||
var i32_ua4 : f32 = u.a[0].x;
|
||||
var i32_ua5 : f32 = u.a[0].x;
|
||||
var i32_ua1 : f32 = u.a[3i].x;
|
||||
var i32_ua2 : f32 = u.a[1i].x;
|
||||
var i32_ua3 : f32 = u.a[0i].x;
|
||||
var i32_ua4 : f32 = u.a[0i].x;
|
||||
var i32_ua5 : f32 = u.a[0i].x;
|
||||
var u32_sa1 : f32 = s.a[0u];
|
||||
var u32_sa2 : f32 = s.a[1u];
|
||||
var u32_sa3 : f32 = s.a[3u];
|
||||
@ -1571,11 +1571,11 @@ fn f() {
|
||||
var i32_sb3 : f32 = s.b[0];
|
||||
var i32_sb4 : f32 = s.b[-1];
|
||||
var i32_sb5 : f32 = s.b[-4];
|
||||
var i32_ua1 : f32 = u.a[3].x;
|
||||
var i32_ua2 : f32 = u.a[1].x;
|
||||
var i32_ua3 : f32 = u.a[0].x;
|
||||
var i32_ua4 : f32 = u.a[0].x;
|
||||
var i32_ua5 : f32 = u.a[0].x;
|
||||
var i32_ua1 : f32 = u.a[3i].x;
|
||||
var i32_ua2 : f32 = u.a[1i].x;
|
||||
var i32_ua3 : f32 = u.a[0i].x;
|
||||
var i32_ua4 : f32 = u.a[0i].x;
|
||||
var i32_ua5 : f32 = u.a[0i].x;
|
||||
var u32_sa1 : f32 = s.a[0u];
|
||||
var u32_sa2 : f32 = s.a[1u];
|
||||
var u32_sa3 : f32 = s.a[3u];
|
||||
@ -1626,11 +1626,11 @@ struct U {
|
||||
@group(1) @binding(0) var<uniform> u : U;
|
||||
|
||||
fn f() {
|
||||
var i32_sa1 : f32 = s.a[3];
|
||||
var i32_sa2 : f32 = s.a[1];
|
||||
var i32_sa3 : f32 = s.a[0];
|
||||
var i32_sa4 : f32 = s.a[0];
|
||||
var i32_sa5 : f32 = s.a[0];
|
||||
var i32_sa1 : f32 = s.a[3i];
|
||||
var i32_sa2 : f32 = s.a[1i];
|
||||
var i32_sa3 : f32 = s.a[0i];
|
||||
var i32_sa4 : f32 = s.a[0i];
|
||||
var i32_sa5 : f32 = s.a[0i];
|
||||
var i32_sb1 : f32 = s.b[min(4u, (arrayLength(&(s.b)) - 1u))];
|
||||
var i32_sb2 : f32 = s.b[min(1u, (arrayLength(&(s.b)) - 1u))];
|
||||
var i32_sb3 : f32 = s.b[min(0u, (arrayLength(&(s.b)) - 1u))];
|
||||
|
@ -110,7 +110,7 @@ const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const sem::Type*
|
||||
if (a->IsRuntimeSized()) {
|
||||
return ctx.dst->ty.array(el, nullptr, std::move(attrs));
|
||||
} else {
|
||||
return ctx.dst->ty.array(el, a->Count(), std::move(attrs));
|
||||
return ctx.dst->ty.array(el, u32(a->Count()), std::move(attrs));
|
||||
}
|
||||
}
|
||||
if (auto* s = ty->As<sem::Struct>()) {
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "src/tint/transform/test_helper.h"
|
||||
#include "src/tint/transform/utils/get_insertion_point.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
namespace {
|
||||
|
||||
@ -27,10 +29,10 @@ using GetInsertionPointTest = ::testing::Test;
|
||||
|
||||
TEST_F(GetInsertionPointTest, Block) {
|
||||
// fn f() {
|
||||
// var a = 1;
|
||||
// var a = 1i;
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* expr = b.Expr(1);
|
||||
auto* expr = b.Expr(1_i);
|
||||
auto* var = b.Decl(b.Var("a", nullptr, expr));
|
||||
auto* block = b.Block(var);
|
||||
b.Func("f", {}, b.ty.void_(), {block});
|
||||
@ -48,11 +50,11 @@ TEST_F(GetInsertionPointTest, Block) {
|
||||
|
||||
TEST_F(GetInsertionPointTest, ForLoopInit) {
|
||||
// fn f() {
|
||||
// for(var a = 1; true; ) {
|
||||
// for(var a = 1i; true; ) {
|
||||
// }
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* expr = b.Expr(1);
|
||||
auto* expr = b.Expr(1_i);
|
||||
auto* var = b.Decl(b.Var("a", nullptr, expr));
|
||||
auto* fl = b.For(var, b.Expr(true), {}, b.Block());
|
||||
auto* func_block = b.Block(fl);
|
||||
@ -70,11 +72,11 @@ TEST_F(GetInsertionPointTest, ForLoopInit) {
|
||||
|
||||
TEST_F(GetInsertionPointTest, ForLoopCont_Invalid) {
|
||||
// fn f() {
|
||||
// for(; true; var a = 1) {
|
||||
// for(; true; var a = 1i) {
|
||||
// }
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* expr = b.Expr(1);
|
||||
auto* expr = b.Expr(1_i);
|
||||
auto* var = b.Decl(b.Var("a", nullptr, expr));
|
||||
auto* s = b.For({}, b.Expr(true), var, b.Block());
|
||||
b.Func("f", {}, b.ty.void_(), {s});
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include "src/tint/transform/test_helper.h"
|
||||
#include "src/tint/transform/utils/hoist_to_decl_before.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
namespace {
|
||||
|
||||
@ -31,7 +33,7 @@ TEST_F(HoistToDeclBeforeTest, VarInit) {
|
||||
// var a = 1;
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* expr = b.Expr(1);
|
||||
auto* expr = b.Expr(1_i);
|
||||
auto* var = b.Decl(b.Var("a", nullptr, expr));
|
||||
b.Func("f", {}, b.ty.void_(), {var});
|
||||
|
||||
@ -49,7 +51,7 @@ TEST_F(HoistToDeclBeforeTest, VarInit) {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
let tint_symbol = 1;
|
||||
let tint_symbol = 1i;
|
||||
var a = tint_symbol;
|
||||
}
|
||||
)";
|
||||
@ -59,11 +61,11 @@ fn f() {
|
||||
|
||||
TEST_F(HoistToDeclBeforeTest, ForLoopInit) {
|
||||
// fn f() {
|
||||
// for(var a = 1; true; ) {
|
||||
// for(var a = 1i; true; ) {
|
||||
// }
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* expr = b.Expr(1);
|
||||
auto* expr = b.Expr(1_i);
|
||||
auto* s = b.For(b.Decl(b.Var("a", nullptr, expr)), b.Expr(true), {}, b.Block());
|
||||
b.Func("f", {}, b.ty.void_(), {s});
|
||||
|
||||
@ -81,7 +83,7 @@ TEST_F(HoistToDeclBeforeTest, ForLoopInit) {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
let tint_symbol = 1;
|
||||
let tint_symbol = 1i;
|
||||
for(var a = tint_symbol; true; ) {
|
||||
}
|
||||
}
|
||||
@ -133,11 +135,11 @@ fn f() {
|
||||
|
||||
TEST_F(HoistToDeclBeforeTest, ForLoopCont) {
|
||||
// fn f() {
|
||||
// for(; true; var a = 1) {
|
||||
// for(; true; var a = 1i) {
|
||||
// }
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* expr = b.Expr(1);
|
||||
auto* expr = b.Expr(1_i);
|
||||
auto* s = b.For({}, b.Expr(true), b.Decl(b.Var("a", nullptr, expr)), b.Block());
|
||||
b.Func("f", {}, b.ty.void_(), {s});
|
||||
|
||||
@ -163,7 +165,7 @@ fn f() {
|
||||
}
|
||||
|
||||
continuing {
|
||||
let tint_symbol = 1;
|
||||
let tint_symbol = 1i;
|
||||
var a = tint_symbol;
|
||||
}
|
||||
}
|
||||
@ -223,8 +225,8 @@ TEST_F(HoistToDeclBeforeTest, Array1D) {
|
||||
// var b = a[0];
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* var1 = b.Decl(b.Var("a", b.ty.array<ProgramBuilder::i32, 10>()));
|
||||
auto* expr = b.IndexAccessor("a", 0);
|
||||
auto* var1 = b.Decl(b.Var("a", b.ty.array<i32, 10>()));
|
||||
auto* expr = b.IndexAccessor("a", 0_i);
|
||||
auto* var2 = b.Decl(b.Var("b", nullptr, expr));
|
||||
b.Func("f", {}, b.ty.void_(), {var1, var2});
|
||||
|
||||
@ -242,8 +244,8 @@ TEST_F(HoistToDeclBeforeTest, Array1D) {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var a : array<i32, 10>;
|
||||
let tint_symbol = a[0];
|
||||
var a : array<i32, 10u>;
|
||||
let tint_symbol = a[0i];
|
||||
var b = tint_symbol;
|
||||
}
|
||||
)";
|
||||
@ -258,8 +260,8 @@ TEST_F(HoistToDeclBeforeTest, Array2D) {
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
|
||||
auto* var1 = b.Decl(b.Var("a", b.ty.array(b.ty.array<ProgramBuilder::i32, 10>(), 10)));
|
||||
auto* expr = b.IndexAccessor(b.IndexAccessor("a", 0), 0);
|
||||
auto* var1 = b.Decl(b.Var("a", b.ty.array(b.ty.array<i32, 10>(), 10_i)));
|
||||
auto* expr = b.IndexAccessor(b.IndexAccessor("a", 0_i), 0_i);
|
||||
auto* var2 = b.Decl(b.Var("b", nullptr, expr));
|
||||
b.Func("f", {}, b.ty.void_(), {var1, var2});
|
||||
|
||||
@ -277,8 +279,8 @@ TEST_F(HoistToDeclBeforeTest, Array2D) {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var a : array<array<i32, 10>, 10>;
|
||||
let tint_symbol = a[0][0];
|
||||
var a : array<array<i32, 10u>, 10i>;
|
||||
let tint_symbol = a[0i][0i];
|
||||
var b = tint_symbol;
|
||||
}
|
||||
)";
|
||||
@ -328,11 +330,11 @@ fn f() {
|
||||
|
||||
TEST_F(HoistToDeclBeforeTest, Prepare_ForLoopCont) {
|
||||
// fn f() {
|
||||
// for(; true; var a = 1) {
|
||||
// for(; true; var a = 1i) {
|
||||
// }
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* expr = b.Expr(1);
|
||||
auto* expr = b.Expr(1_i);
|
||||
auto* s = b.For({}, b.Expr(true), b.Decl(b.Var("a", nullptr, expr)), b.Block());
|
||||
b.Func("f", {}, b.ty.void_(), {s});
|
||||
|
||||
@ -358,7 +360,7 @@ fn f() {
|
||||
}
|
||||
|
||||
continuing {
|
||||
var a = 1;
|
||||
var a = 1i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -414,11 +416,11 @@ TEST_F(HoistToDeclBeforeTest, InsertBefore_Block) {
|
||||
// fn foo() {
|
||||
// }
|
||||
// fn f() {
|
||||
// var a = 1;
|
||||
// var a = 1i;
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
b.Func("foo", {}, b.ty.void_(), {});
|
||||
auto* var = b.Decl(b.Var("a", nullptr, b.Expr(1)));
|
||||
auto* var = b.Decl(b.Var("a", nullptr, b.Expr(1_i)));
|
||||
b.Func("f", {}, b.ty.void_(), {var});
|
||||
|
||||
Program original(std::move(b));
|
||||
@ -440,7 +442,7 @@ fn foo() {
|
||||
|
||||
fn f() {
|
||||
foo();
|
||||
var a = 1;
|
||||
var a = 1i;
|
||||
}
|
||||
)";
|
||||
|
||||
@ -451,12 +453,12 @@ TEST_F(HoistToDeclBeforeTest, InsertBefore_ForLoopInit) {
|
||||
// fn foo() {
|
||||
// }
|
||||
// fn f() {
|
||||
// for(var a = 1; true;) {
|
||||
// for(var a = 1i; true;) {
|
||||
// }
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
b.Func("foo", {}, b.ty.void_(), {});
|
||||
auto* var = b.Decl(b.Var("a", nullptr, b.Expr(1)));
|
||||
auto* var = b.Decl(b.Var("a", nullptr, b.Expr(1_i)));
|
||||
auto* s = b.For(var, b.Expr(true), {}, b.Block());
|
||||
b.Func("f", {}, b.ty.void_(), {s});
|
||||
|
||||
@ -479,7 +481,7 @@ fn foo() {
|
||||
|
||||
fn f() {
|
||||
foo();
|
||||
for(var a = 1; true; ) {
|
||||
for(var a = 1i; true; ) {
|
||||
}
|
||||
}
|
||||
)";
|
||||
@ -491,14 +493,14 @@ TEST_F(HoistToDeclBeforeTest, InsertBefore_ForLoopCont) {
|
||||
// fn foo() {
|
||||
// }
|
||||
// fn f() {
|
||||
// var a = 1;
|
||||
// for(; true; a+=1) {
|
||||
// var a = 1i;
|
||||
// for(; true; a+=1i) {
|
||||
// }
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
b.Func("foo", {}, b.ty.void_(), {});
|
||||
auto* var = b.Decl(b.Var("a", nullptr, b.Expr(1)));
|
||||
auto* cont = b.CompoundAssign("a", b.Expr(1), ast::BinaryOp::kAdd);
|
||||
auto* var = b.Decl(b.Var("a", nullptr, b.Expr(1_i)));
|
||||
auto* cont = b.CompoundAssign("a", b.Expr(1_i), ast::BinaryOp::kAdd);
|
||||
auto* s = b.For({}, b.Expr(true), cont, b.Block());
|
||||
b.Func("f", {}, b.ty.void_(), {var, s});
|
||||
|
||||
@ -520,7 +522,7 @@ fn foo() {
|
||||
}
|
||||
|
||||
fn f() {
|
||||
var a = 1;
|
||||
var a = 1i;
|
||||
loop {
|
||||
if (!(true)) {
|
||||
break;
|
||||
@ -530,7 +532,7 @@ fn f() {
|
||||
|
||||
continuing {
|
||||
foo();
|
||||
a += 1;
|
||||
a += 1i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,8 @@
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::VertexPulling);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::VertexPulling::Config);
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
|
||||
namespace {
|
||||
@ -250,11 +252,11 @@ struct State {
|
||||
void AddVertexStorageBuffers() {
|
||||
// Creating the struct type
|
||||
static const char kStructName[] = "TintVertexData";
|
||||
auto* struct_type = ctx.dst->Structure(
|
||||
ctx.dst->Symbols().New(kStructName),
|
||||
{
|
||||
ctx.dst->Member(GetStructBufferName(), ctx.dst->ty.array<ProgramBuilder::u32>()),
|
||||
});
|
||||
auto* struct_type =
|
||||
ctx.dst->Structure(ctx.dst->Symbols().New(kStructName),
|
||||
{
|
||||
ctx.dst->Member(GetStructBufferName(), ctx.dst->ty.array<u32>()),
|
||||
});
|
||||
for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) {
|
||||
// The decorated variable with struct type
|
||||
ctx.dst->Global(GetVertexBufferName(i), ctx.dst->ty.Of(struct_type),
|
||||
@ -297,7 +299,7 @@ struct State {
|
||||
|
||||
auto* attribute_offset = index_expr;
|
||||
if (buffer_layout.array_stride != 4) {
|
||||
attribute_offset = ctx.dst->Mul(index_expr, buffer_layout.array_stride / 4u);
|
||||
attribute_offset = ctx.dst->Mul(index_expr, u32(buffer_layout.array_stride / 4u));
|
||||
}
|
||||
|
||||
// let pulling_offset_n = <attribute_offset>
|
||||
@ -359,13 +361,13 @@ struct State {
|
||||
case BaseType::kI32:
|
||||
ty = ctx.dst->ty.i32();
|
||||
for (uint32_t i = fmt_dt.width; i < var_dt.width; i++) {
|
||||
values.emplace_back(ctx.dst->Expr((i == 3) ? 1 : 0));
|
||||
values.emplace_back(ctx.dst->Expr(i32((i == 3) ? 1 : 0)));
|
||||
}
|
||||
break;
|
||||
case BaseType::kU32:
|
||||
ty = ctx.dst->ty.u32();
|
||||
for (uint32_t i = fmt_dt.width; i < var_dt.width; i++) {
|
||||
values.emplace_back(ctx.dst->Expr((i == 3) ? 1u : 0u));
|
||||
values.emplace_back(ctx.dst->Expr(u32((i == 3) ? 1u : 0u)));
|
||||
}
|
||||
break;
|
||||
case BaseType::kF32:
|
||||
@ -403,10 +405,6 @@ struct State {
|
||||
uint32_t offset,
|
||||
uint32_t buffer,
|
||||
VertexFormat format) {
|
||||
using u32 = ProgramBuilder::u32;
|
||||
using i32 = ProgramBuilder::i32;
|
||||
using f32 = ProgramBuilder::f32;
|
||||
|
||||
// Returns a u32 loaded from buffer_base + offset.
|
||||
auto load_u32 = [&] {
|
||||
return LoadPrimitive(array_base, offset, buffer, VertexFormat::kUint32);
|
||||
@ -433,17 +431,17 @@ struct State {
|
||||
LoadPrimitive(array_base, low_u32_offset, buffer, VertexFormat::kUint32);
|
||||
switch (offset & 3) {
|
||||
case 0:
|
||||
return ctx.dst->Shl(low_u32, 16u);
|
||||
return ctx.dst->Shl(low_u32, 16_u);
|
||||
case 1:
|
||||
return ctx.dst->And(ctx.dst->Shl(low_u32, 8u), 0xffff0000u);
|
||||
return ctx.dst->And(ctx.dst->Shl(low_u32, 8_u), 0xffff0000_u);
|
||||
case 2:
|
||||
return ctx.dst->And(low_u32, 0xffff0000u);
|
||||
return ctx.dst->And(low_u32, 0xffff0000_u);
|
||||
default: { // 3:
|
||||
auto* high_u32 = LoadPrimitive(array_base, low_u32_offset + 4, buffer,
|
||||
VertexFormat::kUint32);
|
||||
auto* shr = ctx.dst->Shr(low_u32, 8u);
|
||||
auto* shl = ctx.dst->Shl(high_u32, 24u);
|
||||
return ctx.dst->And(ctx.dst->Or(shl, shr), 0xffff0000u);
|
||||
auto* shr = ctx.dst->Shr(low_u32, 8_u);
|
||||
auto* shl = ctx.dst->Shl(high_u32, 24_u);
|
||||
return ctx.dst->And(ctx.dst->Or(shl, shr), 0xffff0000_u);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -456,17 +454,17 @@ struct State {
|
||||
LoadPrimitive(array_base, low_u32_offset, buffer, VertexFormat::kUint32);
|
||||
switch (offset & 3) {
|
||||
case 0:
|
||||
return ctx.dst->And(low_u32, 0xffffu);
|
||||
return ctx.dst->And(low_u32, 0xffff_u);
|
||||
case 1:
|
||||
return ctx.dst->And(ctx.dst->Shr(low_u32, 8u), 0xffffu);
|
||||
return ctx.dst->And(ctx.dst->Shr(low_u32, 8_u), 0xffff_u);
|
||||
case 2:
|
||||
return ctx.dst->Shr(low_u32, 16u);
|
||||
return ctx.dst->Shr(low_u32, 16_u);
|
||||
default: { // 3:
|
||||
auto* high_u32 = LoadPrimitive(array_base, low_u32_offset + 4, buffer,
|
||||
VertexFormat::kUint32);
|
||||
auto* shr = ctx.dst->Shr(low_u32, 24u);
|
||||
auto* shl = ctx.dst->Shl(high_u32, 8u);
|
||||
return ctx.dst->And(ctx.dst->Or(shl, shr), 0xffffu);
|
||||
auto* shr = ctx.dst->Shr(low_u32, 24_u);
|
||||
auto* shl = ctx.dst->Shl(high_u32, 8_u);
|
||||
return ctx.dst->And(ctx.dst->Or(shl, shr), 0xffff_u);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -517,25 +515,25 @@ struct State {
|
||||
// yyxx0000, yyxx0000
|
||||
auto* u16s = ctx.dst->vec2<u32>(load_u16_h());
|
||||
// xx000000, yyxx0000
|
||||
auto* shl = ctx.dst->Shl(u16s, ctx.dst->vec2<u32>(8u, 0u));
|
||||
auto* shl = ctx.dst->Shl(u16s, ctx.dst->vec2<u32>(8_u, 0_u));
|
||||
// 000000xx, 000000yy
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec2<u32>(24u));
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec2<u32>(24_u));
|
||||
}
|
||||
case VertexFormat::kUint8x4: {
|
||||
// wwzzyyxx, wwzzyyxx, wwzzyyxx, wwzzyyxx
|
||||
auto* u32s = ctx.dst->vec4<u32>(load_u32());
|
||||
// xx000000, yyxx0000, zzyyxx00, wwzzyyxx
|
||||
auto* shl = ctx.dst->Shl(u32s, ctx.dst->vec4<u32>(24u, 16u, 8u, 0u));
|
||||
auto* shl = ctx.dst->Shl(u32s, ctx.dst->vec4<u32>(24_u, 16_u, 8_u, 0_u));
|
||||
// 000000xx, 000000yy, 000000zz, 000000ww
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec4<u32>(24u));
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec4<u32>(24_u));
|
||||
}
|
||||
case VertexFormat::kUint16x2: {
|
||||
// yyyyxxxx, yyyyxxxx
|
||||
auto* u32s = ctx.dst->vec2<u32>(load_u32());
|
||||
// xxxx0000, yyyyxxxx
|
||||
auto* shl = ctx.dst->Shl(u32s, ctx.dst->vec2<u32>(16u, 0u));
|
||||
auto* shl = ctx.dst->Shl(u32s, ctx.dst->vec2<u32>(16_u, 0_u));
|
||||
// 0000xxxx, 0000yyyy
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec2<u32>(16u));
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec2<u32>(16_u));
|
||||
}
|
||||
case VertexFormat::kUint16x4: {
|
||||
// yyyyxxxx, wwwwzzzz
|
||||
@ -543,33 +541,33 @@ struct State {
|
||||
// yyyyxxxx, yyyyxxxx, wwwwzzzz, wwwwzzzz
|
||||
auto* xxyy = ctx.dst->MemberAccessor(u32s, "xxyy");
|
||||
// xxxx0000, yyyyxxxx, zzzz0000, wwwwzzzz
|
||||
auto* shl = ctx.dst->Shl(xxyy, ctx.dst->vec4<u32>(16u, 0u, 16u, 0u));
|
||||
auto* shl = ctx.dst->Shl(xxyy, ctx.dst->vec4<u32>(16_u, 0_u, 16_u, 0_u));
|
||||
// 0000xxxx, 0000yyyy, 0000zzzz, 0000wwww
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec4<u32>(16u));
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec4<u32>(16_u));
|
||||
}
|
||||
case VertexFormat::kSint8x2: {
|
||||
// yyxx0000, yyxx0000
|
||||
auto* i16s = ctx.dst->vec2<i32>(load_i16_h());
|
||||
// xx000000, yyxx0000
|
||||
auto* shl = ctx.dst->Shl(i16s, ctx.dst->vec2<u32>(8u, 0u));
|
||||
auto* shl = ctx.dst->Shl(i16s, ctx.dst->vec2<u32>(8_u, 0_u));
|
||||
// ssssssxx, ssssssyy
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec2<u32>(24u));
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec2<u32>(24_u));
|
||||
}
|
||||
case VertexFormat::kSint8x4: {
|
||||
// wwzzyyxx, wwzzyyxx, wwzzyyxx, wwzzyyxx
|
||||
auto* i32s = ctx.dst->vec4<i32>(load_i32());
|
||||
// xx000000, yyxx0000, zzyyxx00, wwzzyyxx
|
||||
auto* shl = ctx.dst->Shl(i32s, ctx.dst->vec4<u32>(24u, 16u, 8u, 0u));
|
||||
auto* shl = ctx.dst->Shl(i32s, ctx.dst->vec4<u32>(24_u, 16_u, 8_u, 0_u));
|
||||
// ssssssxx, ssssssyy, sssssszz, ssssssww
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec4<u32>(24u));
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec4<u32>(24_u));
|
||||
}
|
||||
case VertexFormat::kSint16x2: {
|
||||
// yyyyxxxx, yyyyxxxx
|
||||
auto* i32s = ctx.dst->vec2<i32>(load_i32());
|
||||
// xxxx0000, yyyyxxxx
|
||||
auto* shl = ctx.dst->Shl(i32s, ctx.dst->vec2<u32>(16u, 0u));
|
||||
auto* shl = ctx.dst->Shl(i32s, ctx.dst->vec2<u32>(16_u, 0_u));
|
||||
// ssssxxxx, ssssyyyy
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec2<u32>(16u));
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec2<u32>(16_u));
|
||||
}
|
||||
case VertexFormat::kSint16x4: {
|
||||
// yyyyxxxx, wwwwzzzz
|
||||
@ -577,9 +575,9 @@ struct State {
|
||||
// yyyyxxxx, yyyyxxxx, wwwwzzzz, wwwwzzzz
|
||||
auto* xxyy = ctx.dst->MemberAccessor(i32s, "xxyy");
|
||||
// xxxx0000, yyyyxxxx, zzzz0000, wwwwzzzz
|
||||
auto* shl = ctx.dst->Shl(xxyy, ctx.dst->vec4<u32>(16u, 0u, 16u, 0u));
|
||||
auto* shl = ctx.dst->Shl(xxyy, ctx.dst->vec4<u32>(16_u, 0_u, 16_u, 0_u));
|
||||
// ssssxxxx, ssssyyyy, sssszzzz, sssswwww
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec4<u32>(16u));
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec4<u32>(16_u));
|
||||
}
|
||||
case VertexFormat::kUnorm8x2:
|
||||
return ctx.dst->MemberAccessor(ctx.dst->Call("unpack4x8unorm", load_u16_l()), "xy");
|
||||
@ -623,17 +621,17 @@ struct State {
|
||||
uint32_t offset,
|
||||
uint32_t buffer,
|
||||
VertexFormat format) {
|
||||
const ast::Expression* u32 = nullptr;
|
||||
const ast::Expression* u = nullptr;
|
||||
if ((offset & 3) == 0) {
|
||||
// Aligned load.
|
||||
|
||||
const ast ::Expression* index = nullptr;
|
||||
if (offset > 0) {
|
||||
index = ctx.dst->Add(array_base, offset / 4);
|
||||
index = ctx.dst->Add(array_base, u32(offset / 4));
|
||||
} else {
|
||||
index = ctx.dst->Expr(array_base);
|
||||
}
|
||||
u32 = ctx.dst->IndexAccessor(
|
||||
u = ctx.dst->IndexAccessor(
|
||||
ctx.dst->MemberAccessor(GetVertexBufferName(buffer), GetStructBufferName()), index);
|
||||
|
||||
} else {
|
||||
@ -645,18 +643,18 @@ struct State {
|
||||
|
||||
uint32_t shift = 8u * (offset & 3u);
|
||||
|
||||
auto* low_shr = ctx.dst->Shr(low, shift);
|
||||
auto* high_shl = ctx.dst->Shl(high, 32u - shift);
|
||||
u32 = ctx.dst->Or(low_shr, high_shl);
|
||||
auto* low_shr = ctx.dst->Shr(low, u32(shift));
|
||||
auto* high_shl = ctx.dst->Shl(high, u32(32u - shift));
|
||||
u = ctx.dst->Or(low_shr, high_shl);
|
||||
}
|
||||
|
||||
switch (format) {
|
||||
case VertexFormat::kUint32:
|
||||
return u32;
|
||||
return u;
|
||||
case VertexFormat::kSint32:
|
||||
return ctx.dst->Bitcast(ctx.dst->ty.i32(), u32);
|
||||
return ctx.dst->Bitcast(ctx.dst->ty.i32(), u);
|
||||
case VertexFormat::kFloat32:
|
||||
return ctx.dst->Bitcast(ctx.dst->ty.f32(), u32);
|
||||
return ctx.dst->Bitcast(ctx.dst->ty.f32(), u);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1178,7 +1178,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi
|
||||
snorm8x4 = unpack4x8snorm(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]).x;
|
||||
uint16x2 = vec3<u32>(((vec2<u32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]) << vec2<u32>(16u, 0u)) >> vec2<u32>(16u)), 0u);
|
||||
uint16x4 = (((vec2<u32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)], tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)]).xxyy << vec4<u32>(16u, 0u, 16u, 0u)) >> vec4<u32>(16u))).xy;
|
||||
sint16x2 = vec4<i32>(((vec2<i32>(bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)])) << vec2<u32>(16u, 0u)) >> vec2<u32>(16u)), 0, 1);
|
||||
sint16x2 = vec4<i32>(((vec2<i32>(bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)])) << vec2<u32>(16u, 0u)) >> vec2<u32>(16u)), 0i, 1i);
|
||||
sint16x4 = (((vec2<i32>(bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]), bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)])).xxyy << vec4<u32>(16u, 0u, 16u, 0u)) >> vec4<u32>(16u))).x;
|
||||
unorm16x2 = vec3<f32>(unpack2x16unorm(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]), 0.0);
|
||||
unorm16x4 = vec4<f32>(unpack2x16unorm(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]), unpack2x16unorm(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)])).x;
|
||||
@ -1194,8 +1194,8 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi
|
||||
uint32x2 = vec4<u32>(vec2<u32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)], tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)]), 0u, 1u);
|
||||
uint32x3 = vec4<u32>(vec3<u32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)], tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)], tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 18u)]), 1u);
|
||||
uint32x4 = vec4<u32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)], tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)], tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 18u)], tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 19u)]).xy;
|
||||
sint32 = vec4<i32>(bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]), 0, 0, 1);
|
||||
sint32x2 = vec3<i32>(vec2<i32>(bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]), bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)])), 0);
|
||||
sint32 = vec4<i32>(bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]), 0i, 0i, 1i);
|
||||
sint32x2 = vec3<i32>(vec2<i32>(bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]), bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)])), 0i);
|
||||
sint32x3 = vec3<i32>(bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]), bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)]), bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 18u)])).x;
|
||||
sint32x4 = vec4<i32>(bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]), bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)]), bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 18u)]), bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 19u)])).xy;
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ WrapArraysInStructs::WrappedArrayInfo WrapArraysInStructs::WrapArray(
|
||||
if (!array->IsStrideImplicit()) {
|
||||
attrs.emplace_back(c.dst->create<ast::StrideAttribute>(array->Stride()));
|
||||
}
|
||||
return c.dst->ty.array(el_type(c), array->Count(), std::move(attrs));
|
||||
return c.dst->ty.array(el_type(c), u32(array->Count()), std::move(attrs));
|
||||
};
|
||||
|
||||
// Structure() will create and append the ast::Struct to the
|
||||
|
@ -208,10 +208,10 @@ struct ZeroInitWorkgroupMemory::State {
|
||||
auto idx = b.Symbols().New("idx");
|
||||
auto* init = b.Decl(b.Var(idx, b.ty.u32(), local_index()));
|
||||
auto* cond = b.create<ast::BinaryExpression>(ast::BinaryOp::kLessThan, b.Expr(idx),
|
||||
b.Expr(num_iterations));
|
||||
auto* cont =
|
||||
b.Assign(idx, b.Add(idx, workgroup_size_const ? b.Expr(workgroup_size_const)
|
||||
: workgroup_size_expr()));
|
||||
b.Expr(u32(num_iterations)));
|
||||
auto* cont = b.Assign(
|
||||
idx, b.Add(idx, workgroup_size_const ? b.Expr(u32(workgroup_size_const))
|
||||
: workgroup_size_expr()));
|
||||
|
||||
auto block =
|
||||
DeclareArrayIndices(num_iterations, array_indices, [&] { return b.Expr(idx); });
|
||||
@ -227,8 +227,8 @@ struct ZeroInitWorkgroupMemory::State {
|
||||
// if (local_index < num_iterations) {
|
||||
// ...
|
||||
// }
|
||||
auto* cond = b.create<ast::BinaryExpression>(ast::BinaryOp::kLessThan,
|
||||
local_index(), b.Expr(num_iterations));
|
||||
auto* cond = b.create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kLessThan, local_index(), b.Expr(u32(num_iterations)));
|
||||
auto block = DeclareArrayIndices(num_iterations, array_indices,
|
||||
[&] { return b.Expr(local_index()); });
|
||||
for (auto& s : stmts) {
|
||||
@ -337,9 +337,9 @@ struct ZeroInitWorkgroupMemory::State {
|
||||
auto name = array_index_names.at(index);
|
||||
auto* mod = (num_iterations > index.modulo)
|
||||
? b.create<ast::BinaryExpression>(ast::BinaryOp::kModulo, iteration(),
|
||||
b.Expr(index.modulo))
|
||||
b.Expr(u32(index.modulo)))
|
||||
: iteration();
|
||||
auto* div = (index.division != 1u) ? b.Div(mod, index.division) : mod;
|
||||
auto* div = (index.division != 1u) ? b.Div(mod, u32(index.division)) : mod;
|
||||
auto* decl = b.Decl(b.Let(name, b.ty.u32(), div));
|
||||
stmts.emplace_back(decl);
|
||||
}
|
||||
@ -371,7 +371,7 @@ struct ZeroInitWorkgroupMemory::State {
|
||||
workgroup_size_expr = [this, expr, size = workgroup_size_expr] {
|
||||
auto* e = ctx.Clone(expr);
|
||||
if (ctx.src->TypeOf(expr)->UnwrapRef()->Is<sem::I32>()) {
|
||||
e = b.Construct<ProgramBuilder::u32>(e);
|
||||
e = b.Construct<u32>(e);
|
||||
}
|
||||
return size ? b.Mul(size(), e) : e;
|
||||
};
|
||||
@ -381,8 +381,8 @@ struct ZeroInitWorkgroupMemory::State {
|
||||
// Fold workgroup_size_const in to workgroup_size_expr
|
||||
workgroup_size_expr = [this, is_signed, const_size = workgroup_size_const,
|
||||
expr_size = workgroup_size_expr] {
|
||||
return is_signed ? b.Mul(expr_size(), static_cast<int32_t>(const_size))
|
||||
: b.Mul(expr_size(), const_size);
|
||||
return is_signed ? b.Mul(expr_size(), i32(const_size))
|
||||
: b.Mul(expr_size(), u32(const_size));
|
||||
};
|
||||
}
|
||||
// Indicate that workgroup_size_expr should be used instead of the
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include "src/tint/sem/type_conversion.h"
|
||||
#include "src/tint/utils/transform.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer {
|
||||
namespace {
|
||||
|
||||
@ -45,9 +47,9 @@ VectorConstructorInfo AsVectorConstructor(const sem::Expression* expr) {
|
||||
const sem::Expression* Zero(ProgramBuilder& b, const sem::Type* ty, const sem::Statement* stmt) {
|
||||
const ast::Expression* expr = nullptr;
|
||||
if (ty->Is<sem::I32>()) {
|
||||
expr = b.Expr(0);
|
||||
expr = b.Expr(0_i);
|
||||
} else if (ty->Is<sem::U32>()) {
|
||||
expr = b.Expr(0u);
|
||||
expr = b.Expr(0_u);
|
||||
} else if (ty->Is<sem::F32>()) {
|
||||
expr = b.Expr(0.0f);
|
||||
} else if (ty->Is<sem::Bool>()) {
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer {
|
||||
namespace {
|
||||
|
||||
@ -26,9 +28,9 @@ class AppendVectorTest : public ::testing::Test, public ProgramBuilder {};
|
||||
|
||||
// AppendVector(vec2<i32>(1, 2), 3) -> vec3<i32>(1, 2, 3)
|
||||
TEST_F(AppendVectorTest, Vec2i32_i32) {
|
||||
auto* scalar_1 = Expr(1);
|
||||
auto* scalar_2 = Expr(2);
|
||||
auto* scalar_3 = Expr(3);
|
||||
auto* scalar_1 = Expr(1_i);
|
||||
auto* scalar_2 = Expr(2_i);
|
||||
auto* scalar_3 = Expr(3_i);
|
||||
auto* vec_12 = vec2<i32>(scalar_1, scalar_2);
|
||||
WrapInFunction(vec_12, scalar_3);
|
||||
|
||||
@ -66,9 +68,9 @@ TEST_F(AppendVectorTest, Vec2i32_i32) {
|
||||
|
||||
// AppendVector(vec2<i32>(1, 2), 3u) -> vec3<i32>(1, 2, i32(3u))
|
||||
TEST_F(AppendVectorTest, Vec2i32_u32) {
|
||||
auto* scalar_1 = Expr(1);
|
||||
auto* scalar_2 = Expr(2);
|
||||
auto* scalar_3 = Expr(3u);
|
||||
auto* scalar_1 = Expr(1_i);
|
||||
auto* scalar_2 = Expr(2_i);
|
||||
auto* scalar_3 = Expr(3_u);
|
||||
auto* vec_12 = vec2<i32>(scalar_1, scalar_2);
|
||||
WrapInFunction(vec_12, scalar_3);
|
||||
|
||||
@ -111,9 +113,9 @@ TEST_F(AppendVectorTest, Vec2i32_u32) {
|
||||
// AppendVector(vec2<i32>(vec2<u32>(1u, 2u)), 3u) ->
|
||||
// vec3<i32>(vec2<i32>(vec2<u32>(1u, 2u)), i32(3u))
|
||||
TEST_F(AppendVectorTest, Vec2i32FromVec2u32_u32) {
|
||||
auto* scalar_1 = Expr(1u);
|
||||
auto* scalar_2 = Expr(2u);
|
||||
auto* scalar_3 = Expr(3u);
|
||||
auto* scalar_1 = Expr(1_u);
|
||||
auto* scalar_2 = Expr(2_u);
|
||||
auto* scalar_3 = Expr(3_u);
|
||||
auto* uvec_12 = vec2<u32>(scalar_1, scalar_2);
|
||||
auto* vec_12 = vec2<i32>(uvec_12);
|
||||
WrapInFunction(vec_12, scalar_3);
|
||||
@ -160,8 +162,8 @@ TEST_F(AppendVectorTest, Vec2i32FromVec2u32_u32) {
|
||||
|
||||
// AppendVector(vec2<i32>(1, 2), 3.0f) -> vec3<i32>(1, 2, i32(3.0f))
|
||||
TEST_F(AppendVectorTest, Vec2i32_f32) {
|
||||
auto* scalar_1 = Expr(1);
|
||||
auto* scalar_2 = Expr(2);
|
||||
auto* scalar_1 = Expr(1_i);
|
||||
auto* scalar_2 = Expr(2_i);
|
||||
auto* scalar_3 = Expr(3.0f);
|
||||
auto* vec_12 = vec2<i32>(scalar_1, scalar_2);
|
||||
WrapInFunction(vec_12, scalar_3);
|
||||
@ -204,10 +206,10 @@ TEST_F(AppendVectorTest, Vec2i32_f32) {
|
||||
|
||||
// AppendVector(vec3<i32>(1, 2, 3), 4) -> vec4<i32>(1, 2, 3, 4)
|
||||
TEST_F(AppendVectorTest, Vec3i32_i32) {
|
||||
auto* scalar_1 = Expr(1);
|
||||
auto* scalar_2 = Expr(2);
|
||||
auto* scalar_3 = Expr(3);
|
||||
auto* scalar_4 = Expr(4);
|
||||
auto* scalar_1 = Expr(1_i);
|
||||
auto* scalar_2 = Expr(2_i);
|
||||
auto* scalar_3 = Expr(3_i);
|
||||
auto* scalar_4 = Expr(4_i);
|
||||
auto* vec_123 = vec3<i32>(scalar_1, scalar_2, scalar_3);
|
||||
WrapInFunction(vec_123, scalar_4);
|
||||
|
||||
@ -250,7 +252,7 @@ TEST_F(AppendVectorTest, Vec3i32_i32) {
|
||||
TEST_F(AppendVectorTest, Vec2i32Var_i32) {
|
||||
Global("vec_12", ty.vec2<i32>(), ast::StorageClass::kPrivate);
|
||||
auto* vec_12 = Expr("vec_12");
|
||||
auto* scalar_3 = Expr(3);
|
||||
auto* scalar_3 = Expr(3_i);
|
||||
WrapInFunction(vec_12, scalar_3);
|
||||
|
||||
resolver::Resolver resolver(this);
|
||||
@ -285,8 +287,8 @@ TEST_F(AppendVectorTest, Vec2i32Var_i32) {
|
||||
// AppendVector(1, 2, scalar_3) -> vec3<i32>(1, 2, scalar_3)
|
||||
TEST_F(AppendVectorTest, Vec2i32_i32Var) {
|
||||
Global("scalar_3", ty.i32(), ast::StorageClass::kPrivate);
|
||||
auto* scalar_1 = Expr(1);
|
||||
auto* scalar_2 = Expr(2);
|
||||
auto* scalar_1 = Expr(1_i);
|
||||
auto* scalar_2 = Expr(2_i);
|
||||
auto* scalar_3 = Expr("scalar_3");
|
||||
auto* vec_12 = vec2<i32>(scalar_1, scalar_2);
|
||||
WrapInFunction(vec_12, scalar_3);
|
||||
@ -440,7 +442,7 @@ TEST_F(AppendVectorTest, Vec2boolVar_boolVar) {
|
||||
|
||||
// AppendVector(vec3<i32>(), 4) -> vec3<bool>(0, 0, 0, 4)
|
||||
TEST_F(AppendVectorTest, ZeroVec3i32_i32) {
|
||||
auto* scalar = Expr(4);
|
||||
auto* scalar = Expr(4_i);
|
||||
auto* vec000 = vec3<i32>();
|
||||
WrapInFunction(vec000, scalar);
|
||||
|
||||
|
@ -14,6 +14,8 @@
|
||||
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
@ -21,7 +23,7 @@ using GlslGeneratorImplTest_Expression = TestHelper;
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Expression, IndexAccessor) {
|
||||
Global("ary", ty.array<i32, 10>(), ast::StorageClass::kPrivate);
|
||||
auto* expr = IndexAccessor("ary", 5);
|
||||
auto* expr = IndexAccessor("ary", 5_i);
|
||||
WrapInFunction(expr);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include "src/tint/ast/variable_decl_statement.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
@ -329,11 +331,11 @@ if (!tint_tmp) {
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Binary, If_WithLogical) {
|
||||
// if (a && b) {
|
||||
// return 1;
|
||||
// return 1i;
|
||||
// } else if (b || c) {
|
||||
// return 2;
|
||||
// return 2i;
|
||||
// } else {
|
||||
// return 3;
|
||||
// return 3i;
|
||||
// }
|
||||
|
||||
Global("a", ty.bool_(), ast::StorageClass::kPrivate);
|
||||
@ -342,9 +344,9 @@ TEST_F(GlslGeneratorImplTest_Binary, If_WithLogical) {
|
||||
|
||||
auto* expr =
|
||||
If(create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr("a"), Expr("b")),
|
||||
Block(Return(1)),
|
||||
Block(Return(1_i)),
|
||||
Else(If(create<ast::BinaryExpression>(ast::BinaryOp::kLogicalOr, Expr("b"), Expr("c")),
|
||||
Block(Return(2)), Else(Block(Return(3))))));
|
||||
Block(Return(2_i)), Else(Block(Return(3_i))))));
|
||||
Func("func", {}, ty.i32(), {WrapInStatement(expr)});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -14,13 +14,15 @@
|
||||
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
using GlslGeneratorImplTest_Bitcast = TestHelper;
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Float) {
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.f32(), Expr(1));
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.f32(), Expr(1_i));
|
||||
WrapInFunction(bitcast);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
@ -31,7 +33,7 @@ TEST_F(GlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Float) {
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Int) {
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.i32(), Expr(1u));
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.i32(), Expr(1_u));
|
||||
WrapInFunction(bitcast);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
@ -42,7 +44,7 @@ TEST_F(GlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Int) {
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Uint) {
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.u32(), Expr(1));
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.u32(), Expr(1_i));
|
||||
WrapInFunction(bitcast);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -18,13 +18,15 @@
|
||||
#include "src/tint/sem/call.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
using ::testing::HasSubstr;
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
using BuiltinType = sem::BuiltinType;
|
||||
|
||||
using ::testing::HasSubstr;
|
||||
|
||||
using GlslGeneratorImplTest_Builtin = TestHelper;
|
||||
|
||||
enum class ParamType {
|
||||
@ -267,7 +269,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Select_Scalar) {
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Builtin, Select_Vector) {
|
||||
auto* call = Call("select", vec2<i32>(1, 2), vec2<i32>(3, 4), vec2<bool>(true, false));
|
||||
auto* call = Call("select", vec2<i32>(1_i, 2_i), vec2<i32>(3_i, 4_i), vec2<bool>(true, false));
|
||||
WrapInFunction(CallStmt(call));
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
@ -766,7 +768,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, StorageBarrier) {
|
||||
Func("main", {}, ty.void_(), {CallStmt(Call("storageBarrier"))},
|
||||
{
|
||||
Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(1),
|
||||
WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
@ -786,7 +788,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, WorkgroupBarrier) {
|
||||
Func("main", {}, ty.void_(), {CallStmt(Call("workgroupBarrier"))},
|
||||
{
|
||||
Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(1),
|
||||
WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -15,13 +15,15 @@
|
||||
#include "src/tint/ast/fallthrough_statement.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
using GlslGeneratorImplTest_Case = TestHelper;
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Case, Emit_Case) {
|
||||
auto* s = Switch(1, Case(Expr(5), Block(create<ast::BreakStatement>())), DefaultCase());
|
||||
auto* s = Switch(1_i, Case(Expr(5_i), Block(create<ast::BreakStatement>())), DefaultCase());
|
||||
WrapInFunction(s);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
@ -36,7 +38,7 @@ TEST_F(GlslGeneratorImplTest_Case, Emit_Case) {
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) {
|
||||
auto* s = Switch(1, Case(Expr(5), Block()), DefaultCase());
|
||||
auto* s = Switch(1_i, Case(Expr(5_i), Block()), DefaultCase());
|
||||
WrapInFunction(s);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
@ -51,7 +53,8 @@ TEST_F(GlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) {
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Case, Emit_Case_WithFallthrough) {
|
||||
auto* s = Switch(1, Case(Expr(5), Block(create<ast::FallthroughStatement>())), DefaultCase());
|
||||
auto* s =
|
||||
Switch(1_i, Case(Expr(5_i), Block(create<ast::FallthroughStatement>())), DefaultCase());
|
||||
WrapInFunction(s);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
@ -66,8 +69,8 @@ TEST_F(GlslGeneratorImplTest_Case, Emit_Case_WithFallthrough) {
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Case, Emit_Case_MultipleSelectors) {
|
||||
auto* s =
|
||||
Switch(1, Case({Expr(5), Expr(6)}, Block(create<ast::BreakStatement>())), DefaultCase());
|
||||
auto* s = Switch(1_i, Case({Expr(5_i), Expr(6_i)}, Block(create<ast::BreakStatement>())),
|
||||
DefaultCase());
|
||||
WrapInFunction(s);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
@ -83,7 +86,7 @@ TEST_F(GlslGeneratorImplTest_Case, Emit_Case_MultipleSelectors) {
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Case, Emit_Case_Default) {
|
||||
auto* s = Switch(1, DefaultCase(Block(create<ast::BreakStatement>())));
|
||||
auto* s = Switch(1_i, DefaultCase(Block(create<ast::BreakStatement>())));
|
||||
WrapInFunction(s);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -14,13 +14,15 @@
|
||||
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
using GlslGeneratorImplTest_Cast = TestHelper;
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Cast, EmitExpression_Cast_Scalar) {
|
||||
auto* cast = Construct<f32>(1);
|
||||
auto* cast = Construct<f32>(1_i);
|
||||
WrapInFunction(cast);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
@ -31,7 +33,7 @@ TEST_F(GlslGeneratorImplTest_Cast, EmitExpression_Cast_Scalar) {
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Cast, EmitExpression_Cast_Vector) {
|
||||
auto* cast = vec3<f32>(vec3<i32>(1, 2, 3));
|
||||
auto* cast = vec3<f32>(vec3<i32>(1_i, 2_i, 3_i));
|
||||
WrapInFunction(cast);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
@ -32,7 +34,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Bool) {
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Int) {
|
||||
WrapInFunction(Expr(-12345));
|
||||
WrapInFunction(Expr(i32(-12345)));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
@ -41,7 +43,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Int) {
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_UInt) {
|
||||
WrapInFunction(Expr(56779u));
|
||||
WrapInFunction(Expr(56779_u));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
@ -51,7 +53,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_UInt) {
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Float) {
|
||||
// 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();
|
||||
|
||||
@ -78,7 +80,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Bool) {
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Int) {
|
||||
WrapInFunction(Construct<i32>(-12345));
|
||||
WrapInFunction(Construct<i32>(i32(-12345)));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
@ -87,7 +89,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Int) {
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Uint) {
|
||||
WrapInFunction(Construct<u32>(12345u));
|
||||
WrapInFunction(Construct<u32>(12345_u));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
@ -132,7 +134,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_SingleScalar_
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_SingleScalar_Int) {
|
||||
WrapInFunction(vec3<i32>(2));
|
||||
WrapInFunction(vec3<i32>(2_i));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
@ -141,7 +143,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_SingleScalar_
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_SingleScalar_UInt) {
|
||||
WrapInFunction(vec3<u32>(2u));
|
||||
WrapInFunction(vec3<u32>(2_u));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
@ -170,7 +172,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Mat_Empty) {
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Array) {
|
||||
WrapInFunction(Construct(ty.array(ty.vec3<f32>(), 3), 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)));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
@ -182,7 +184,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Array) {
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Array_Empty) {
|
||||
WrapInFunction(Construct(ty.array(ty.vec3<f32>(), 3)));
|
||||
WrapInFunction(Construct(ty.array(ty.vec3<f32>(), 3_u)));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
@ -198,7 +200,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Struct) {
|
||||
Member("c", ty.vec3<i32>()),
|
||||
});
|
||||
|
||||
WrapInFunction(Construct(ty.Of(str), 1, 2.0f, vec3<i32>(3, 4, 5)));
|
||||
WrapInFunction(Construct(ty.Of(str), 1_i, 2.0f, vec3<i32>(3_i, 4_i, 5_i)));
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
using ::testing::HasSubstr;
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
@ -739,7 +741,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute) {
|
||||
{
|
||||
Return(),
|
||||
},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
@ -757,7 +759,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute_WithWor
|
||||
Func("main", ast::VariableList{}, ty.void_(), {},
|
||||
{
|
||||
Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(2, 4, 6),
|
||||
WorkgroupSize(2_i, 4_i, 6_i),
|
||||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
@ -773,9 +775,9 @@ void main() {
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute_WithWorkgroup_Const) {
|
||||
GlobalConst("width", ty.i32(), Construct(ty.i32(), 2));
|
||||
GlobalConst("height", ty.i32(), Construct(ty.i32(), 3));
|
||||
GlobalConst("depth", ty.i32(), Construct(ty.i32(), 4));
|
||||
GlobalConst("width", ty.i32(), Construct(ty.i32(), 2_i));
|
||||
GlobalConst("height", ty.i32(), Construct(ty.i32(), 3_i));
|
||||
GlobalConst("depth", ty.i32(), Construct(ty.i32(), 4_i));
|
||||
Func("main", ast::VariableList{}, ty.void_(), {},
|
||||
{
|
||||
Stage(ast::PipelineStage::kCompute),
|
||||
@ -799,9 +801,9 @@ void main() {
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Function,
|
||||
Emit_Attribute_EntryPoint_Compute_WithWorkgroup_OverridableConst) {
|
||||
Override("width", ty.i32(), Construct(ty.i32(), 2), {Id(7u)});
|
||||
Override("height", ty.i32(), Construct(ty.i32(), 3), {Id(8u)});
|
||||
Override("depth", ty.i32(), Construct(ty.i32(), 4), {Id(9u)});
|
||||
Override("width", ty.i32(), Construct(ty.i32(), 2_i), {Id(7u)});
|
||||
Override("height", ty.i32(), Construct(ty.i32(), 3_i), {Id(8u)});
|
||||
Override("depth", ty.i32(), Construct(ty.i32(), 4_i), {Id(9u)});
|
||||
Func("main", ast::VariableList{}, ty.void_(), {},
|
||||
{
|
||||
Stage(ast::PipelineStage::kCompute),
|
||||
@ -903,7 +905,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module
|
||||
Decl(var),
|
||||
Return(),
|
||||
},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
}
|
||||
|
||||
{
|
||||
@ -914,7 +916,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module
|
||||
Decl(var),
|
||||
Return(),
|
||||
},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
|
||||
}
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
@ -14,6 +14,8 @@
|
||||
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
@ -72,7 +74,7 @@ using GlslImportData_SingleIntParamTest = TestParamHelper<GlslImportData>;
|
||||
TEST_P(GlslImportData_SingleIntParamTest, IntScalar) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* expr = Call(param.name, Expr(1));
|
||||
auto* expr = Call(param.name, Expr(1_i));
|
||||
WrapInFunction(expr);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
@ -177,7 +179,7 @@ using GlslImportData_DualParam_Int_Test = TestParamHelper<GlslImportData>;
|
||||
TEST_P(GlslImportData_DualParam_Int_Test, IntScalar) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* expr = Call(param.name, 1, 2);
|
||||
auto* expr = Call(param.name, 1_i, 2_i);
|
||||
WrapInFunction(expr);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
@ -240,7 +242,7 @@ using GlslImportData_TripleParam_Int_Test = TestParamHelper<GlslImportData>;
|
||||
TEST_P(GlslImportData_TripleParam_Int_Test, IntScalar) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* expr = Call(param.name, 1, 2, 3);
|
||||
auto* expr = Call(param.name, 1_i, 2_i, 3_i);
|
||||
WrapInFunction(expr);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "src/tint/ast/variable_decl_statement.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
@ -261,12 +263,12 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCond) {
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCont) {
|
||||
// for(; ; i = i + 1) {
|
||||
// for(; ; i = i + 1i) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
auto* v = Decl(Var("i", ty.i32()));
|
||||
auto* f = For(nullptr, nullptr, Assign("i", Add("i", 1)), //
|
||||
auto* f = For(nullptr, nullptr, Assign("i", Add("i", 1_i)), //
|
||||
Block(Return()));
|
||||
WrapInFunction(v, f);
|
||||
|
||||
@ -314,11 +316,11 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCont) {
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInitCondCont) {
|
||||
// for(var i : i32; true; i = i + 1) {
|
||||
// for(var i : i32; true; i = ii + 1) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
auto* f = For(Decl(Var("i", ty.i32())), true, Assign("i", Add("i", 1)), Block(Return()));
|
||||
auto* f = For(Decl(Var("i", ty.i32())), true, Assign("i", Add("i", 1_i)), Block(Return()));
|
||||
WrapInFunction(f);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include "src/tint/ast/stage_attribute.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
@ -81,10 +83,6 @@ inline const ast::Type* ty_mat4x4(const ProgramBuilder::TypesBuilder& ty) {
|
||||
return ty.mat4x4<T>();
|
||||
}
|
||||
|
||||
using i32 = ProgramBuilder::i32;
|
||||
using u32 = ProgramBuilder::u32;
|
||||
using f32 = ProgramBuilder::f32;
|
||||
|
||||
template <typename BASE>
|
||||
class GlslGeneratorImplTest_MemberAccessorBase : public BASE {
|
||||
public:
|
||||
@ -310,7 +308,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_Matrix_Single_El
|
||||
// a : mat4x3<f32>;
|
||||
// };
|
||||
// var<storage> data : Data;
|
||||
// data.a[2][1];
|
||||
// data.a[2i][1i];
|
||||
|
||||
SetupStorageBuffer({
|
||||
Member("z", ty.f32()),
|
||||
@ -319,7 +317,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_Matrix_Single_El
|
||||
|
||||
SetupFunction({
|
||||
Decl(Var("x", nullptr, ast::StorageClass::kNone,
|
||||
IndexAccessor(IndexAccessor(MemberAccessor("data", "a"), 2), 1))),
|
||||
IndexAccessor(IndexAccessor(MemberAccessor("data", "a"), 2_i), 1_i))),
|
||||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
@ -365,7 +363,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor,
|
||||
|
||||
SetupFunction({
|
||||
Decl(Var("x", nullptr, ast::StorageClass::kNone,
|
||||
IndexAccessor(MemberAccessor("data", "a"), 2))),
|
||||
IndexAccessor(MemberAccessor("data", "a"), 2_i))),
|
||||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
@ -399,10 +397,10 @@ void main() {
|
||||
TEST_F(GlslGeneratorImplTest_MemberAccessor,
|
||||
EmitExpression_IndexAccessor_StorageBuffer_Load_Int_FromArray_ExprIdx) {
|
||||
// struct Data {
|
||||
// a : array<i32, 5>;
|
||||
// a : array<i32, 5u>;
|
||||
// };
|
||||
// var<storage> data : Data;
|
||||
// data.a[(2 + 4) - 3];
|
||||
// data.a[(2i + 4i) - 3i];
|
||||
|
||||
SetupStorageBuffer({
|
||||
Member("z", ty.f32()),
|
||||
@ -411,7 +409,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor,
|
||||
|
||||
SetupFunction({
|
||||
Decl(Var("x", nullptr, ast::StorageClass::kNone,
|
||||
IndexAccessor(MemberAccessor("data", "a"), Sub(Add(2, Expr(4)), Expr(3))))),
|
||||
IndexAccessor(MemberAccessor("data", "a"), Sub(Add(2_i, 4_i), 3_i)))),
|
||||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
@ -444,10 +442,10 @@ void main() {
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_ToArray) {
|
||||
// struct Data {
|
||||
// a : array<i32, 5>;
|
||||
// a : array<i32, 5u>;
|
||||
// };
|
||||
// var<storage> data : Data;
|
||||
// data.a[2] = 2;
|
||||
// data.a[2i] = 2i;
|
||||
|
||||
SetupStorageBuffer({
|
||||
Member("z", ty.f32()),
|
||||
@ -455,7 +453,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_ToArray) {
|
||||
});
|
||||
|
||||
SetupFunction({
|
||||
Assign(IndexAccessor(MemberAccessor("data", "a"), 2), 2),
|
||||
Assign(IndexAccessor(MemberAccessor("data", "a"), 2_i), 2_i),
|
||||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
@ -492,11 +490,11 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel) {
|
||||
// b : vec3<f32>;
|
||||
// };
|
||||
// struct Data {
|
||||
// var c : array<Inner, 4>;
|
||||
// var c : array<Inner, 4u>;
|
||||
// };
|
||||
//
|
||||
// var<storage> data : Pre;
|
||||
// data.c[2].b
|
||||
// data.c[2i].b
|
||||
|
||||
auto* inner = Structure("Inner", {
|
||||
Member("a", ty.vec3<f32>()),
|
||||
@ -504,12 +502,12 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel) {
|
||||
});
|
||||
|
||||
SetupStorageBuffer({
|
||||
Member("c", ty.array(ty.Of(inner), 4, 32)),
|
||||
Member("c", ty.array(ty.Of(inner), 4_u, 32)),
|
||||
});
|
||||
|
||||
SetupFunction({
|
||||
Decl(Var("x", nullptr, ast::StorageClass::kNone,
|
||||
MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2), "b"))),
|
||||
MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"))),
|
||||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
@ -549,11 +547,11 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel_Swizz
|
||||
// b : vec3<f32>;
|
||||
// };
|
||||
// struct Data {
|
||||
// var c : array<Inner, 4>;
|
||||
// var c : array<Inner, 4u>;
|
||||
// };
|
||||
//
|
||||
// var<storage> data : Pre;
|
||||
// data.c[2].b.xy
|
||||
// data.c[2i].b.xy
|
||||
|
||||
auto* inner = Structure("Inner", {
|
||||
Member("a", ty.vec3<f32>()),
|
||||
@ -561,13 +559,13 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel_Swizz
|
||||
});
|
||||
|
||||
SetupStorageBuffer({
|
||||
Member("c", ty.array(ty.Of(inner), 4, 32)),
|
||||
Member("c", ty.array(ty.Of(inner), 4_u, 32)),
|
||||
});
|
||||
|
||||
SetupFunction({
|
||||
Decl(Var("x", nullptr, ast::StorageClass::kNone,
|
||||
MemberAccessor(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2), "b"),
|
||||
"xy"))),
|
||||
MemberAccessor(
|
||||
MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"), "xy"))),
|
||||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
@ -608,11 +606,11 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor,
|
||||
// b : vec3<f32>;
|
||||
// };
|
||||
// struct Data {
|
||||
// var c : array<Inner, 4>;
|
||||
// var c : array<Inner, 4u>;
|
||||
// };
|
||||
//
|
||||
// var<storage> data : Pre;
|
||||
// data.c[2].b.g
|
||||
// data.c[2i].b.g
|
||||
|
||||
auto* inner = Structure("Inner", {
|
||||
Member("a", ty.vec3<f32>()),
|
||||
@ -620,13 +618,13 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor,
|
||||
});
|
||||
|
||||
SetupStorageBuffer({
|
||||
Member("c", ty.array(ty.Of(inner), 4, 32)),
|
||||
Member("c", ty.array(ty.Of(inner), 4_u, 32)),
|
||||
});
|
||||
|
||||
SetupFunction({
|
||||
Decl(Var("x", nullptr, ast::StorageClass::kNone,
|
||||
MemberAccessor(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2), "b"),
|
||||
"g"))),
|
||||
MemberAccessor(
|
||||
MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"), "g"))),
|
||||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
@ -666,11 +664,11 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel_Index
|
||||
// b : vec3<f32>;
|
||||
// };
|
||||
// struct Data {
|
||||
// var c : array<Inner, 4>;
|
||||
// var c : array<Inner, 4u>;
|
||||
// };
|
||||
//
|
||||
// var<storage> data : Pre;
|
||||
// data.c[2].b[1]
|
||||
// data.c[2i].b[1i]
|
||||
|
||||
auto* inner = Structure("Inner", {
|
||||
Member("a", ty.vec3<f32>()),
|
||||
@ -678,13 +676,13 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel_Index
|
||||
});
|
||||
|
||||
SetupStorageBuffer({
|
||||
Member("c", ty.array(ty.Of(inner), 4, 32)),
|
||||
Member("c", ty.array(ty.Of(inner), 4_u, 32)),
|
||||
});
|
||||
|
||||
SetupFunction({
|
||||
Decl(Var(
|
||||
"x", nullptr, ast::StorageClass::kNone,
|
||||
IndexAccessor(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2), "b"), 1))),
|
||||
Decl(Var("x", nullptr, ast::StorageClass::kNone,
|
||||
IndexAccessor(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"),
|
||||
1_i))),
|
||||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
@ -724,11 +722,11 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_MultiLevel) {
|
||||
// b : vec3<f32>;
|
||||
// };
|
||||
// struct Data {
|
||||
// var c : array<Inner, 4>;
|
||||
// var c : array<Inner, 4u>;
|
||||
// };
|
||||
//
|
||||
// var<storage> data : Pre;
|
||||
// data.c[2].b = vec3<f32>(1.f, 2.f, 3.f);
|
||||
// data.c[2i].b = vec3<f32>(1.f, 2.f, 3.f);
|
||||
|
||||
auto* inner = Structure("Inner", {
|
||||
Member("a", ty.vec3<f32>()),
|
||||
@ -736,11 +734,11 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_MultiLevel) {
|
||||
});
|
||||
|
||||
SetupStorageBuffer({
|
||||
Member("c", ty.array(ty.Of(inner), 4, 32)),
|
||||
Member("c", ty.array(ty.Of(inner), 4_u, 32)),
|
||||
});
|
||||
|
||||
SetupFunction({
|
||||
Assign(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2), "b"),
|
||||
Assign(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"),
|
||||
vec3<f32>(1.f, 2.f, 3.f)),
|
||||
});
|
||||
|
||||
@ -781,11 +779,11 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_Swizzle_SingleL
|
||||
// b : vec3<f32>;
|
||||
// };
|
||||
// struct Data {
|
||||
// var c : array<Inner, 4>;
|
||||
// var c : array<Inner, 4u>;
|
||||
// };
|
||||
//
|
||||
// var<storage> data : Pre;
|
||||
// data.c[2].b.y = 1.f;
|
||||
// data.c[2i].b.y = 1.f;
|
||||
|
||||
auto* inner = Structure("Inner", {
|
||||
Member("a", ty.vec3<i32>()),
|
||||
@ -793,13 +791,13 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_Swizzle_SingleL
|
||||
});
|
||||
|
||||
SetupStorageBuffer({
|
||||
Member("c", ty.array(ty.Of(inner), 4, 32)),
|
||||
Member("c", ty.array(ty.Of(inner), 4_u, 32)),
|
||||
});
|
||||
|
||||
SetupFunction({
|
||||
Assign(
|
||||
MemberAccessor(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2), "b"), "y"),
|
||||
Expr(1.f)),
|
||||
Assign(MemberAccessor(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"),
|
||||
"y"),
|
||||
Expr(1.f)),
|
||||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
@ -14,6 +14,8 @@
|
||||
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
@ -32,7 +34,7 @@ TEST_F(GlslGeneratorImplTest_Return, Emit_Return) {
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Return, Emit_ReturnWithValue) {
|
||||
auto* r = Return(123);
|
||||
auto* r = Return(123_i);
|
||||
Func("f", {}, ty.i32(), {r});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include "src/tint/ast/variable_decl_statement.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
@ -153,8 +155,8 @@ void main() {
|
||||
}
|
||||
|
||||
TEST_F(GlslSanitizerTest, PromoteArrayInitializerToConstVar) {
|
||||
auto* array_init = array<i32, 4>(1, 2, 3, 4);
|
||||
auto* array_index = IndexAccessor(array_init, 3);
|
||||
auto* array_init = array<i32, 4>(1_i, 2_i, 3_i, 4_i);
|
||||
auto* array_index = IndexAccessor(array_init, 3_i);
|
||||
auto* pos = Var("pos", ty.i32(), ast::StorageClass::kNone, array_index);
|
||||
|
||||
Func("main", ast::VariableList{}, ty.void_(),
|
||||
@ -192,7 +194,7 @@ TEST_F(GlslSanitizerTest, PromoteStructInitializerToConstVar) {
|
||||
Member("b", ty.vec3<f32>()),
|
||||
Member("c", ty.i32()),
|
||||
});
|
||||
auto* struct_init = Construct(ty.Of(str), 1, vec3<f32>(2.f, 3.f, 4.f), 4);
|
||||
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* pos = Var("pos", ty.vec3<f32>(), ast::StorageClass::kNone, struct_access);
|
||||
|
||||
@ -271,18 +273,18 @@ void main() {
|
||||
}
|
||||
|
||||
TEST_F(GlslSanitizerTest, InlinePtrLetsComplexChain) {
|
||||
// var a : array<mat4x4<f32>, 4>;
|
||||
// let ap : ptr<function, array<mat4x4<f32>, 4>> = &a;
|
||||
// let mp : ptr<function, mat4x4<f32>> = &(*ap)[3];
|
||||
// let vp : ptr<function, vec4<f32>> = &(*mp)[2];
|
||||
// var a : array<mat4x4<f32>, 4u>;
|
||||
// let ap : ptr<function, array<mat4x4<f32>, 4u>> = &a;
|
||||
// let mp : ptr<function, mat4x4<f32>> = &(*ap)[3i];
|
||||
// let vp : ptr<function, vec4<f32>> = &(*mp)[2i];
|
||||
// let v : vec4<f32> = *vp;
|
||||
auto* a = Var("a", ty.array(ty.mat4x4<f32>(), 4));
|
||||
auto* ap = Let("ap", ty.pointer(ty.array(ty.mat4x4<f32>(), 4), ast::StorageClass::kFunction),
|
||||
auto* a = Var("a", ty.array(ty.mat4x4<f32>(), 4_u));
|
||||
auto* ap = Let("ap", ty.pointer(ty.array(ty.mat4x4<f32>(), 4_u), ast::StorageClass::kFunction),
|
||||
AddressOf(a));
|
||||
auto* mp = Let("mp", ty.pointer(ty.mat4x4<f32>(), ast::StorageClass::kFunction),
|
||||
AddressOf(IndexAccessor(Deref(ap), 3)));
|
||||
AddressOf(IndexAccessor(Deref(ap), 3_i)));
|
||||
auto* vp = Let("vp", ty.pointer(ty.vec4<f32>(), ast::StorageClass::kFunction),
|
||||
AddressOf(IndexAccessor(Deref(mp), 2)));
|
||||
AddressOf(IndexAccessor(Deref(mp), 2_i)));
|
||||
auto* v = Var("v", ty.vec4<f32>(), ast::StorageClass::kNone, Deref(vp));
|
||||
|
||||
Func("main", ast::VariableList{}, ty.void_(),
|
||||
|
@ -14,6 +14,8 @@
|
||||
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
@ -26,7 +28,7 @@ TEST_F(GlslGeneratorImplTest_Switch, Emit_Switch) {
|
||||
auto* def = create<ast::CaseStatement>(ast::CaseSelectorList{}, def_body);
|
||||
|
||||
ast::CaseSelectorList case_val;
|
||||
case_val.push_back(Expr(5));
|
||||
case_val.push_back(Expr(5_i));
|
||||
|
||||
auto* case_body = Block(create<ast::BreakStatement>());
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user