tint: Deprecated module-scope 'let' for 'const'

Enable the parsing of 'const'.
Warn on use of module-scope 'let', and automatically replace with 'const'.

Fixed: tint:1580
Change-Id: I214aabca80686dc6b60ae21a7a57fbfb4898ea83
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93786
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Ben Clayton 2022-06-29 00:55:36 +00:00 committed by Dawn LUCI CQ
parent 03f88e6f49
commit c64ca23d94
224 changed files with 1443 additions and 2495 deletions

View File

@ -10,6 +10,8 @@
### Breaking changes
* The `smoothStep()` builtin has been removed (use `smoothstep` instead). [tint:1483](crbug.com/tint/1483)
* Module-scope `let` has been replaced with module-scope `const`. [tint:1580](crbug.com/tint/1584)
* Note: Module-scope `const` does not support structure types. Use `var<private>` if you need a module-scope structure type.
### Deprecated Features

View File

@ -37,8 +37,8 @@ struct S1 {
m1 : array<u32, 6>,
};
let c0 : i32 = 10;
let c1 : bool = true;
const c0 : i32 = 10;
const c1 : bool = true;
type t0 = array<vec4<f32>>;
type t1 = array<vec4<f32>>;
@ -71,6 +71,8 @@ fn f1(p0 : f32, p1 : i32) -> f32 {
var l4 : S1;
var l5 : u32 = l4.m1[5];
let l6 : ptr<private, u32> = &g0;
const l7 = 123;
const l8 : i32 = 123;
loop {
l0 = (p1 + 2);
if (((l0 % 4) == 0)) {
@ -104,7 +106,7 @@ fn main() {
f1(1.0, 2);
}
let declaration_order_check_0 : i32 = 1;
const declaration_order_check_0 : i32 = 1;
type declaration_order_check_1 = f32;
@ -112,7 +114,7 @@ fn declaration_order_check_2() {}
type declaration_order_check_3 = f32;
let declaration_order_check_4 : i32 = 1;
const declaration_order_check_4 : i32 = 1;
)");

View File

@ -1525,41 +1525,6 @@ class ProgramBuilder {
return var;
}
/// @param name the variable name
/// @param type the variable type
/// @param constructor constructor expression
/// @param attributes optional variable attributes
/// @returns an `ast::Let` constructed by calling Let() with the arguments of `args`, which is
/// automatically registered as a global variable with the ast::Module.
template <typename NAME>
const ast::Let* GlobalLet(NAME&& name,
const ast::Type* type,
const ast::Expression* constructor,
ast::AttributeList attributes = {}) {
auto* var = Let(std::forward<NAME>(name), type, constructor, std::move(attributes));
AST().AddGlobalVariable(var);
return var;
}
/// @param source the variable source
/// @param name the variable name
/// @param type the variable type
/// @param constructor constructor expression
/// @param attributes optional variable attributes
/// @returns a const `ast::Let` constructed by calling Var() with the
/// arguments of `args`, which is automatically registered as a global
/// variable with the ast::Module.
template <typename NAME>
const ast::Let* GlobalLet(const Source& source,
NAME&& name,
const ast::Type* type,
const ast::Expression* constructor,
ast::AttributeList attributes = {}) {
auto* var = Let(source, std::forward<NAME>(name), type, constructor, std::move(attributes));
AST().AddGlobalVariable(var);
return var;
}
/// @param name the variable name
/// @param type the variable type
/// @param constructor optional constructor expression

View File

@ -47,9 +47,6 @@
namespace tint::reader::wgsl {
namespace {
// TODO(crbug.com/tint/1580): Remove when 'const' is fully implemented.
bool const_enabled = false;
template <typename T>
using Expect = ParserImpl::Expect<T>;
@ -248,11 +245,6 @@ ParserImpl::ParserImpl(Source::File const* file) : lexer_(std::make_unique<Lexer
ParserImpl::~ParserImpl() = default;
// TODO(crbug.com/tint/1580): Remove when 'const' is fully implemented.
void ParserImpl::EnableConst() {
const_enabled = true;
}
ParserImpl::Failure::Errored ParserImpl::add_error(const Source& source,
std::string_view err,
std::string_view use) {
@ -579,11 +571,12 @@ Maybe<const ast::Variable*> ParserImpl::global_constant_decl(ast::AttributeList&
bool is_const = false;
bool is_overridable = false;
const char* use = nullptr;
if (match(Token::Type::kLet)) {
use = "'let' declaration";
} else if (const_enabled && match(Token::Type::kConst)) {
Source source;
if (match(Token::Type::kConst)) {
use = "'const' declaration";
is_const = true;
} else if (match(Token::Type::kLet, &source)) {
use = "'let' declaration";
deprecated(source, "module-scope 'let' has been replaced with 'const'");
} else if (match(Token::Type::kOverride)) {
use = "'override' declaration";
is_overridable = true;
@ -632,11 +625,11 @@ Maybe<const ast::Variable*> ParserImpl::global_constant_decl(ast::AttributeList&
initializer, // constructor
std::move(attrs)); // attributes
}
return create<ast::Let>(decl->source, // source
builder_.Symbols().Register(decl->name), // symbol
decl->type, // type
initializer, // constructor
std::move(attrs)); // attributes
return create<ast::Const>(decl->source, // source
builder_.Symbols().Register(decl->name), // symbol
decl->type, // type
initializer, // constructor
std::move(attrs)); // attributes
}
// variable_decl

View File

@ -72,11 +72,6 @@ class ParserImpl {
};
public:
/// A temporary bodge to enable unit-testing of 'const' variable types while still under active
/// development.
// TODO(crbug.com/tint/1580): Remove when 'const' is fully implemented.
static void EnableConst();
/// Expect is the return type of the parser methods that are expected to
/// return a parsed value of type T, unless there was an parse error.
/// In the case of a parse error the called method will have called

View File

@ -456,11 +456,12 @@ fn f(a:i32)->i32{return a;@size(1)}
}
TEST_F(ParserImplErrorTest, FunctionMissingOpenLine) {
EXPECT(R"(let bar : vec2<f32> = vec2<f32>(1., 2.);
EXPECT(
R"(const bar : vec2<f32> = vec2<f32>(1., 2.);
var a : f32 = bar[0];
return;
})",
R"(test.wgsl:3:3 error: statement found outside of function body
R"(test.wgsl:3:3 error: statement found outside of function body
return;
^^^^^^
)");
@ -550,32 +551,52 @@ const i : vec2<i32> = vec2<i32>(1, 2;
}
TEST_F(ParserImplErrorTest, GlobalDeclLetInvalidIdentifier) {
EXPECT("let ^ : i32 = 1;",
R"(test.wgsl:1:5 error: expected identifier for 'let' declaration
EXPECT(
"let ^ : i32 = 1;",
R"(test.wgsl:1:1 warning: use of deprecated language feature: module-scope 'let' has been replaced with 'const'
let ^ : i32 = 1;
^^^
test.wgsl:1:5 error: expected identifier for 'let' declaration
let ^ : i32 = 1;
^
)");
}
TEST_F(ParserImplErrorTest, GlobalDeclLetMissingSemicolon) {
EXPECT("let i : i32 = 1",
R"(test.wgsl:1:16 error: expected ';' for 'let' declaration
EXPECT(
"let i : i32 = 1",
R"(test.wgsl:1:1 warning: use of deprecated language feature: module-scope 'let' has been replaced with 'const'
let i : i32 = 1
^^^
test.wgsl:1:16 error: expected ';' for 'const' declaration
let i : i32 = 1
^
)");
}
TEST_F(ParserImplErrorTest, GlobalDeclLetMissingLParen) {
EXPECT("let i : vec2<i32> = vec2<i32>;",
R"(test.wgsl:1:30 error: expected '(' for type constructor
EXPECT(
"let i : vec2<i32> = vec2<i32>;",
R"(test.wgsl:1:1 warning: use of deprecated language feature: module-scope 'let' has been replaced with 'const'
let i : vec2<i32> = vec2<i32>;
^^^
test.wgsl:1:30 error: expected '(' for type constructor
let i : vec2<i32> = vec2<i32>;
^
)");
}
TEST_F(ParserImplErrorTest, GlobalDeclLetMissingRParen) {
EXPECT("let i : vec2<i32> = vec2<i32>(1., 2.;",
R"(test.wgsl:1:37 error: expected ')' for type constructor
EXPECT(
"let i : vec2<i32> = vec2<i32>(1., 2.;",
R"(test.wgsl:1:1 warning: use of deprecated language feature: module-scope 'let' has been replaced with 'const'
let i : vec2<i32> = vec2<i32>(1., 2.;
^^^
test.wgsl:1:37 error: expected ')' for type constructor
let i : vec2<i32> = vec2<i32>(1., 2.;
^
)");
@ -583,50 +604,37 @@ let i : vec2<i32> = vec2<i32>(1., 2.;
TEST_F(ParserImplErrorTest, GlobalDeclLetBadConstLiteral) {
EXPECT("let i : vec2<i32> = vec2<i32>(!);",
R"(test.wgsl:1:32 error: unable to parse right side of ! expression
R"(test.wgsl:1:1 warning: use of deprecated language feature: module-scope 'let' has been replaced with 'const'
let i : vec2<i32> = vec2<i32>(!);
^^^
test.wgsl:1:32 error: unable to parse right side of ! expression
let i : vec2<i32> = vec2<i32>(!);
^
)");
}
TEST_F(ParserImplErrorTest, GlobalDeclLetExprMaxDepth) {
uint32_t kMaxDepth = 128;
std::stringstream src;
std::stringstream mkr;
src << "let i : i32 = ";
mkr << " ";
for (size_t i = 0; i < kMaxDepth + 8; i++) {
src << "f32(";
if (i < kMaxDepth) {
mkr << " ";
} else if (i == kMaxDepth) {
mkr << "^^^";
}
}
src << "1.0";
for (size_t i = 0; i < 200; i++) {
src << ")";
}
src << ";";
std::stringstream err;
err << "test.wgsl:1:527 error: maximum parser recursive depth reached\n"
<< src.str() << "\n"
<< mkr.str() << "\n";
EXPECT(src.str().c_str(), err.str().c_str());
}
TEST_F(ParserImplErrorTest, GlobalDeclLetExprMissingLParen) {
EXPECT("let i : vec2<i32> = vec2<i32> 1, 2);",
R"(test.wgsl:1:31 error: expected '(' for type constructor
EXPECT(
"let i : vec2<i32> = vec2<i32> 1, 2);",
R"(test.wgsl:1:1 warning: use of deprecated language feature: module-scope 'let' has been replaced with 'const'
let i : vec2<i32> = vec2<i32> 1, 2);
^^^
test.wgsl:1:31 error: expected '(' for type constructor
let i : vec2<i32> = vec2<i32> 1, 2);
^
)");
}
TEST_F(ParserImplErrorTest, GlobalDeclLetExprMissingRParen) {
EXPECT("let i : vec2<i32> = vec2<i32>(1, 2;",
R"(test.wgsl:1:35 error: expected ')' for type constructor
EXPECT(
"let i : vec2<i32> = vec2<i32>(1, 2;",
R"(test.wgsl:1:1 warning: use of deprecated language feature: module-scope 'let' has been replaced with 'const'
let i : vec2<i32> = vec2<i32>(1, 2;
^^^
test.wgsl:1:35 error: expected ')' for type constructor
let i : vec2<i32> = vec2<i32>(1, 2;
^
)");

View File

@ -27,20 +27,20 @@ TEST_F(ParserImplTest, GlobalLetDecl) {
EXPECT_FALSE(p->has_error()) << p->error();
EXPECT_TRUE(e.matched);
EXPECT_FALSE(e.errored);
auto* let = e.value->As<ast::Let>();
ASSERT_NE(let, nullptr);
auto* const_ = e.value->As<ast::Const>();
ASSERT_NE(const_, nullptr);
EXPECT_EQ(let->symbol, p->builder().Symbols().Get("a"));
ASSERT_NE(let->type, nullptr);
EXPECT_TRUE(let->type->Is<ast::F32>());
EXPECT_EQ(const_->symbol, p->builder().Symbols().Get("a"));
ASSERT_NE(const_->type, nullptr);
EXPECT_TRUE(const_->type->Is<ast::F32>());
EXPECT_EQ(let->source.range.begin.line, 1u);
EXPECT_EQ(let->source.range.begin.column, 5u);
EXPECT_EQ(let->source.range.end.line, 1u);
EXPECT_EQ(let->source.range.end.column, 6u);
EXPECT_EQ(const_->source.range.begin.line, 1u);
EXPECT_EQ(const_->source.range.begin.column, 5u);
EXPECT_EQ(const_->source.range.end.line, 1u);
EXPECT_EQ(const_->source.range.end.column, 6u);
ASSERT_NE(let->constructor, nullptr);
EXPECT_TRUE(let->constructor->Is<ast::LiteralExpression>());
ASSERT_NE(const_->constructor, nullptr);
EXPECT_TRUE(const_->constructor->Is<ast::LiteralExpression>());
}
TEST_F(ParserImplTest, GlobalLetDecl_Inferred) {
@ -52,19 +52,19 @@ TEST_F(ParserImplTest, GlobalLetDecl_Inferred) {
EXPECT_FALSE(p->has_error()) << p->error();
EXPECT_TRUE(e.matched);
EXPECT_FALSE(e.errored);
auto* let = e.value->As<ast::Let>();
ASSERT_NE(let, nullptr);
auto* const_ = e.value->As<ast::Const>();
ASSERT_NE(const_, nullptr);
EXPECT_EQ(let->symbol, p->builder().Symbols().Get("a"));
EXPECT_EQ(let->type, nullptr);
EXPECT_EQ(const_->symbol, p->builder().Symbols().Get("a"));
EXPECT_EQ(const_->type, nullptr);
EXPECT_EQ(let->source.range.begin.line, 1u);
EXPECT_EQ(let->source.range.begin.column, 5u);
EXPECT_EQ(let->source.range.end.line, 1u);
EXPECT_EQ(let->source.range.end.column, 6u);
EXPECT_EQ(const_->source.range.begin.line, 1u);
EXPECT_EQ(const_->source.range.begin.column, 5u);
EXPECT_EQ(const_->source.range.end.line, 1u);
EXPECT_EQ(const_->source.range.end.column, 6u);
ASSERT_NE(let->constructor, nullptr);
EXPECT_TRUE(let->constructor->Is<ast::LiteralExpression>());
ASSERT_NE(const_->constructor, nullptr);
EXPECT_TRUE(const_->constructor->Is<ast::LiteralExpression>());
}
TEST_F(ParserImplTest, GlobalLetDecl_InvalidExpression) {
@ -77,7 +77,10 @@ TEST_F(ParserImplTest, GlobalLetDecl_InvalidExpression) {
EXPECT_TRUE(e.errored);
EXPECT_FALSE(e.matched);
EXPECT_EQ(e.value, nullptr);
EXPECT_EQ(p->error(), "1:15: missing initializer for 'let' declaration");
EXPECT_EQ(
p->error(),
R"(1:1: use of deprecated language feature: module-scope 'let' has been replaced with 'const'
1:15: missing initializer for 'let' declaration)");
}
TEST_F(ParserImplTest, GlobalLetDecl_MissingExpression) {
@ -90,7 +93,10 @@ TEST_F(ParserImplTest, GlobalLetDecl_MissingExpression) {
EXPECT_TRUE(e.errored);
EXPECT_FALSE(e.matched);
EXPECT_EQ(e.value, nullptr);
EXPECT_EQ(p->error(), "1:14: missing initializer for 'let' declaration");
EXPECT_EQ(
p->error(),
R"(1:1: use of deprecated language feature: module-scope 'let' has been replaced with 'const'
1:14: missing initializer for 'let' declaration)");
}
TEST_F(ParserImplTest, GlobalConstDecl) {

View File

@ -72,21 +72,30 @@ TEST_F(ParserImplTest, GlobalDecl_GlobalLet_MissingInitializer) {
auto p = parser("let a : vec2<i32>;");
p->global_decl();
ASSERT_TRUE(p->has_error());
EXPECT_EQ(p->error(), "1:18: expected '=' for 'let' declaration");
EXPECT_EQ(
p->error(),
R"(1:1: use of deprecated language feature: module-scope 'let' has been replaced with 'const'
1:18: expected '=' for 'let' declaration)");
}
TEST_F(ParserImplTest, GlobalDecl_GlobalLet_Invalid) {
auto p = parser("let a : vec2<i32> 1.0;");
p->global_decl();
ASSERT_TRUE(p->has_error());
EXPECT_EQ(p->error(), "1:19: expected '=' for 'let' declaration");
EXPECT_EQ(
p->error(),
R"(1:1: use of deprecated language feature: module-scope 'let' has been replaced with 'const'
1:19: expected '=' for 'let' declaration)");
}
TEST_F(ParserImplTest, GlobalDecl_GlobalLet_MissingSemicolon) {
auto p = parser("let a : vec2<i32> = vec2<i32>(1, 2)");
p->global_decl();
ASSERT_TRUE(p->has_error());
EXPECT_EQ(p->error(), "1:36: expected ';' for 'let' declaration");
EXPECT_EQ(
p->error(),
R"(1:1: use of deprecated language feature: module-scope 'let' has been replaced with 'const'
1:36: expected ';' for 'const' declaration)");
}
TEST_F(ParserImplTest, GlobalDecl_GlobalConst) {

View File

@ -25,13 +25,6 @@ TEST_P(ParserImplReservedKeywordTest, Function) {
EXPECT_TRUE(p->has_error());
EXPECT_EQ(p->error(), "1:4: '" + name + "' is a reserved keyword");
}
TEST_P(ParserImplReservedKeywordTest, ModuleLet) {
auto name = GetParam();
auto p = parser("let " + name + " : i32 = 1;");
EXPECT_FALSE(p->Parse());
EXPECT_TRUE(p->has_error());
EXPECT_EQ(p->error(), "1:5: '" + name + "' is a reserved keyword");
}
TEST_P(ParserImplReservedKeywordTest, ModuleConst) {
auto name = GetParam();
auto p = parser("const " + name + " : i32 = 1;");

View File

@ -79,17 +79,6 @@ TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic) {
EXPECT_EQ(idx_sem->Object()->Declaration(), acc->object);
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic_Let) {
GlobalLet("my_let", ty.mat2x3<f32>(), Construct(ty.mat2x3<f32>()));
auto* idx = Var("idx", ty.i32(), Construct(ty.i32()));
auto* acc = IndexAccessor("my_let", Expr(Source{{12, 34}}, idx));
WrapInFunction(Decl(idx), acc);
EXPECT_TRUE(r()->Resolve());
EXPECT_EQ(r()->error(), "");
}
TEST_F(ResolverIndexAccessorTest, Matrix_XDimension_Dynamic) {
GlobalConst("my_const", ty.mat4x4<f32>(), Construct(ty.mat4x4<f32>()));
auto* idx = Var("idx", ty.u32(), Expr(3_u));
@ -100,22 +89,6 @@ TEST_F(ResolverIndexAccessorTest, Matrix_XDimension_Dynamic) {
EXPECT_EQ(r()->error(), "");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverIndexAccessorTest, Matrix_XDimension_Dynamic_Let) {
GlobalLet("my_let", ty.mat4x4<f32>(), Construct(ty.mat4x4<f32>()));
auto* idx = Var("idx", ty.u32(), Expr(3_u));
auto* acc = IndexAccessor("my_let", Expr(Source{{12, 34}}, idx));
WrapInFunction(Decl(idx), acc);
EXPECT_TRUE(r()->Resolve());
EXPECT_EQ(r()->error(), "");
auto idx_sem = Sem().Get(acc);
ASSERT_NE(idx_sem, nullptr);
EXPECT_EQ(idx_sem->Index()->Declaration(), acc->index);
EXPECT_EQ(idx_sem->Object()->Declaration(), acc->object);
}
TEST_F(ResolverIndexAccessorTest, Matrix_BothDimension_Dynamic) {
GlobalConst("my_const", ty.mat4x4<f32>(), Construct(ty.mat4x4<f32>()));
auto* idx = Var("idy", ty.u32(), Expr(2_u));
@ -126,22 +99,6 @@ TEST_F(ResolverIndexAccessorTest, Matrix_BothDimension_Dynamic) {
EXPECT_EQ(r()->error(), "");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverIndexAccessorTest, Matrix_BothDimension_Dynamic_Let) {
GlobalLet("my_let", ty.mat4x4<f32>(), Construct(ty.mat4x4<f32>()));
auto* idx = Var("idy", ty.u32(), Expr(2_u));
auto* acc = IndexAccessor(IndexAccessor("my_let", Expr(Source{{12, 34}}, idx)), 1_i);
WrapInFunction(Decl(idx), acc);
EXPECT_TRUE(r()->Resolve());
EXPECT_EQ(r()->error(), "");
auto idx_sem = Sem().Get(acc);
ASSERT_NE(idx_sem, nullptr);
EXPECT_EQ(idx_sem->Index()->Declaration(), acc->index);
EXPECT_EQ(idx_sem->Object()->Declaration(), acc->object);
}
TEST_F(ResolverIndexAccessorTest, Matrix) {
GlobalVar("my_var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
@ -215,21 +172,6 @@ TEST_F(ResolverIndexAccessorTest, Vector_Dynamic) {
EXPECT_TRUE(r()->Resolve());
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverIndexAccessorTest, Vector_Dynamic_Let) {
GlobalLet("my_let", ty.vec3<f32>(), Construct(ty.vec3<f32>()));
auto* idx = Var("idx", ty.i32(), Expr(2_i));
auto* acc = IndexAccessor("my_let", Expr(Source{{12, 34}}, idx));
WrapInFunction(Decl(idx), acc);
EXPECT_TRUE(r()->Resolve());
auto idx_sem = Sem().Get(acc);
ASSERT_NE(idx_sem, nullptr);
EXPECT_EQ(idx_sem->Index()->Declaration(), acc->index);
EXPECT_EQ(idx_sem->Object()->Declaration(), acc->object);
}
TEST_F(ResolverIndexAccessorTest, Vector) {
GlobalVar("my_var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
@ -332,24 +274,6 @@ TEST_F(ResolverIndexAccessorTest, Array_Constant) {
EXPECT_TRUE(TypeOf(acc)->Is<sem::F32>());
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverIndexAccessorTest, Array_Let) {
GlobalLet("my_let", ty.array<f32, 3>(), array<f32, 3>());
auto* acc = IndexAccessor("my_let", 2_i);
WrapInFunction(acc);
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(acc), nullptr);
EXPECT_TRUE(TypeOf(acc)->Is<sem::F32>());
auto idx_sem = Sem().Get(acc);
ASSERT_NE(idx_sem, nullptr);
EXPECT_EQ(idx_sem->Index()->Declaration(), acc->index);
EXPECT_EQ(idx_sem->Object()->Declaration(), acc->object);
}
TEST_F(ResolverIndexAccessorTest, Array_Dynamic_I32) {
// let a : array<f32, 3> = 0;
// var idx : i32 = 0;

View File

@ -79,26 +79,6 @@ TEST_F(ResolverAssignmentValidationTest, AssignArraysWithDifferentSizeExpression
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverAssignmentValidationTest, AssignArraysWithDifferentSizeExpressions_Let_Pass) {
// let len = 4u;
// {
// var a : array<f32, 4u>;
// var b : array<f32, len>;
// a = b;
// }
GlobalLet("len", nullptr, Expr(4_u));
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");
WrapInFunction(a, b, assign);
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverAssignmentValidationTest, AssignArraysWithDifferentSizeExpressions_Fail) {
// const len = 5u;
// {
@ -120,28 +100,6 @@ TEST_F(ResolverAssignmentValidationTest, AssignArraysWithDifferentSizeExpression
EXPECT_EQ(r()->error(), "12:34 error: cannot assign 'array<f32, 5>' to 'array<f32, 4>'");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverAssignmentValidationTest, AssignArraysWithDifferentSizeExpressions_Let_Fail) {
// let len = 5u;
// {
// var a : array<f32, 4u>;
// var b : array<f32, len>;
// a = b;
// }
GlobalLet("len", nullptr, Expr(5_u));
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");
WrapInFunction(a, b, assign);
ASSERT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: cannot assign 'array<f32, 5>' to 'array<f32, 4>'");
}
TEST_F(ResolverAssignmentValidationTest, AssignCompatibleTypesInBlockStatement_Pass) {
// {
// var a : i32 = 2i;

View File

@ -787,23 +787,6 @@ TEST_P(ConstantAttributeTest, IsValid) {
"12:34 error: attribute is not valid for module-scope 'const' declaration");
}
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_P(ConstantAttributeTest, IsValid_Let) {
auto& params = GetParam();
GlobalLet("a", ty.f32(), Expr(1.23_f), createAttributes(Source{{12, 34}}, *this, params.kind));
WrapInFunction();
if (params.should_pass) {
EXPECT_TRUE(r()->Resolve()) << r()->error();
} else {
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
"12:34 error: attribute is not valid for module-scope 'let' declaration");
}
}
INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
ConstantAttributeTest,
testing::Values(TestParams{AttributeKind::kAlign, false},
@ -836,22 +819,6 @@ TEST_F(ConstantAttributeTest, DuplicateAttribute) {
12:34 note: first attribute declared here)");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ConstantAttributeTest, DuplicateAttribute_Let) {
GlobalLet("a", ty.f32(), Expr(1.23_f),
ast::AttributeList{
create<ast::IdAttribute>(Source{{12, 34}}, 0),
create<ast::IdAttribute>(Source{{56, 78}}, 1),
});
WrapInFunction();
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
R"(56:78 error: duplicate id attribute
12:34 note: first attribute declared here)");
}
using OverrideAttributeTest = TestWithParams;
TEST_P(OverrideAttributeTest, IsValid) {
auto& params = GetParam();

View File

@ -93,15 +93,6 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalConst) {
R"(12:34 error: 'mix' is a builtin and cannot be redeclared as a 'const')");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalLet) {
GlobalLet(Source{{12, 34}}, "mix", ty.i32(), Expr(1_i));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
R"(12:34 error: 'mix' is a builtin and cannot be redeclared as a 'let')");
}
TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalVar) {
GlobalVar(Source{{12, 34}}, "mix", ty.i32(), Expr(1_i), ast::StorageClass::kPrivate);
@ -307,40 +298,6 @@ TEST_P(BuiltinTextureConstExprArgValidationTest, GlobalConst) {
err << "12:34 error: the " << param.name << " argument must be a const_expression";
EXPECT_EQ(r()->error(), err.str());
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_P(BuiltinTextureConstExprArgValidationTest, GlobalLet) {
auto& p = GetParam();
auto overload = std::get<0>(p);
auto param = std::get<1>(p);
auto expr = std::get<2>(p);
// Build the global texture and sampler variables
overload.BuildTextureVariable(this);
overload.BuildSamplerVariable(this);
// Build the module-scope let 'G' with the offset value
GlobalLet("G", nullptr, expr({}, *this));
auto args = overload.args(this);
auto*& arg_to_replace = (param.position == Position::kFirst) ? args.front() : args.back();
// Make the expression to be replaced, reachable. This keeps the resolver
// happy.
WrapInFunction(arg_to_replace);
arg_to_replace = Expr(Source{{12, 34}}, "G");
// Call the builtin with the constexpr argument replaced
Func("func", {}, ty.void_(), {CallStmt(Call(overload.function, args))},
{Stage(ast::PipelineStage::kFragment)});
EXPECT_FALSE(r()->Resolve());
std::stringstream err;
err << "12:34 error: the " << param.name << " argument must be a const_expression";
EXPECT_EQ(r()->error(), err.str());
}
INSTANTIATE_TEST_SUITE_P(
Offset2D,
BuiltinTextureConstExprArgValidationTest,

View File

@ -54,7 +54,6 @@ using ResolverDependencyGraphTest = ResolverDependencyGraphTestWithParam<::testi
/// kinds of symbol declarations.
enum class SymbolDeclKind {
GlobalVar,
GlobalLet,
GlobalConst,
Alias,
Struct,
@ -67,10 +66,10 @@ enum class SymbolDeclKind {
};
static constexpr SymbolDeclKind kAllSymbolDeclKinds[] = {
SymbolDeclKind::GlobalVar, SymbolDeclKind::GlobalLet, SymbolDeclKind::GlobalConst,
SymbolDeclKind::Alias, SymbolDeclKind::Struct, SymbolDeclKind::Function,
SymbolDeclKind::Parameter, SymbolDeclKind::LocalVar, SymbolDeclKind::LocalLet,
SymbolDeclKind::NestedLocalVar, SymbolDeclKind::NestedLocalLet,
SymbolDeclKind::GlobalVar, SymbolDeclKind::GlobalConst, SymbolDeclKind::Alias,
SymbolDeclKind::Struct, SymbolDeclKind::Function, SymbolDeclKind::Parameter,
SymbolDeclKind::LocalVar, SymbolDeclKind::LocalLet, SymbolDeclKind::NestedLocalVar,
SymbolDeclKind::NestedLocalLet,
};
static constexpr SymbolDeclKind kTypeDeclKinds[] = {
@ -79,14 +78,14 @@ static constexpr SymbolDeclKind kTypeDeclKinds[] = {
};
static constexpr SymbolDeclKind kValueDeclKinds[] = {
SymbolDeclKind::GlobalVar, SymbolDeclKind::GlobalLet, SymbolDeclKind::GlobalConst,
SymbolDeclKind::Parameter, SymbolDeclKind::LocalVar, SymbolDeclKind::LocalLet,
SymbolDeclKind::NestedLocalVar, SymbolDeclKind::NestedLocalLet,
SymbolDeclKind::GlobalVar, SymbolDeclKind::GlobalConst, SymbolDeclKind::Parameter,
SymbolDeclKind::LocalVar, SymbolDeclKind::LocalLet, SymbolDeclKind::NestedLocalVar,
SymbolDeclKind::NestedLocalLet,
};
static constexpr SymbolDeclKind kGlobalDeclKinds[] = {
SymbolDeclKind::GlobalVar, SymbolDeclKind::GlobalLet, SymbolDeclKind::GlobalConst,
SymbolDeclKind::Alias, SymbolDeclKind::Struct, SymbolDeclKind::Function,
SymbolDeclKind::GlobalVar, SymbolDeclKind::GlobalConst, SymbolDeclKind::Alias,
SymbolDeclKind::Struct, SymbolDeclKind::Function,
};
static constexpr SymbolDeclKind kLocalDeclKinds[] = {
@ -96,7 +95,6 @@ static constexpr SymbolDeclKind kLocalDeclKinds[] = {
static constexpr SymbolDeclKind kGlobalValueDeclKinds[] = {
SymbolDeclKind::GlobalVar,
SymbolDeclKind::GlobalLet,
SymbolDeclKind::GlobalConst,
};
@ -115,12 +113,6 @@ enum class SymbolUseKind {
GlobalVarSampledTexElemType,
GlobalVarMultisampledTexElemType,
GlobalVarValue,
GlobalLetType,
GlobalLetArrayElemType,
GlobalLetArraySizeValue,
GlobalLetVectorElemType,
GlobalLetMatrixElemType,
GlobalLetValue,
GlobalConstType,
GlobalConstArrayElemType,
GlobalConstArraySizeValue,
@ -154,11 +146,6 @@ static constexpr SymbolUseKind kTypeUseKinds[] = {
SymbolUseKind::GlobalVarMatrixElemType,
SymbolUseKind::GlobalVarSampledTexElemType,
SymbolUseKind::GlobalVarMultisampledTexElemType,
SymbolUseKind::GlobalLetType,
SymbolUseKind::GlobalLetArrayElemType,
SymbolUseKind::GlobalLetArraySizeValue,
SymbolUseKind::GlobalLetVectorElemType,
SymbolUseKind::GlobalLetMatrixElemType,
SymbolUseKind::GlobalConstType,
SymbolUseKind::GlobalConstArrayElemType,
SymbolUseKind::GlobalConstArraySizeValue,
@ -178,10 +165,10 @@ static constexpr SymbolUseKind kTypeUseKinds[] = {
};
static constexpr SymbolUseKind kValueUseKinds[] = {
SymbolUseKind::GlobalVarValue, SymbolUseKind::GlobalLetValue,
SymbolUseKind::GlobalConstValue, SymbolUseKind::LocalVarValue,
SymbolUseKind::LocalLetValue, SymbolUseKind::NestedLocalVarValue,
SymbolUseKind::NestedLocalLetValue, SymbolUseKind::WorkgroupSizeValue,
SymbolUseKind::GlobalVarValue, SymbolUseKind::GlobalConstValue,
SymbolUseKind::LocalVarValue, SymbolUseKind::LocalLetValue,
SymbolUseKind::NestedLocalVarValue, SymbolUseKind::NestedLocalLetValue,
SymbolUseKind::WorkgroupSizeValue,
};
static constexpr SymbolUseKind kFuncUseKinds[] = {
@ -194,8 +181,6 @@ std::ostream& operator<<(std::ostream& out, SymbolDeclKind kind) {
switch (kind) {
case SymbolDeclKind::GlobalVar:
return out << "global var";
case SymbolDeclKind::GlobalLet:
return out << "global let";
case SymbolDeclKind::GlobalConst:
return out << "global const";
case SymbolDeclKind::Alias:
@ -238,18 +223,6 @@ std::ostream& operator<<(std::ostream& out, SymbolUseKind kind) {
return out << "global var sampled_texture element type";
case SymbolUseKind::GlobalVarMultisampledTexElemType:
return out << "global var multisampled_texture element type";
case SymbolUseKind::GlobalLetType:
return out << "global let type";
case SymbolUseKind::GlobalLetValue:
return out << "global let value";
case SymbolUseKind::GlobalLetArrayElemType:
return out << "global let array element type";
case SymbolUseKind::GlobalLetArraySizeValue:
return out << "global let array size value";
case SymbolUseKind::GlobalLetVectorElemType:
return out << "global let vector element type";
case SymbolUseKind::GlobalLetMatrixElemType:
return out << "global let matrix element type";
case SymbolUseKind::GlobalConstType:
return out << "global const type";
case SymbolUseKind::GlobalConstValue:
@ -309,10 +282,6 @@ std::string DiagString(SymbolUseKind kind) {
case SymbolUseKind::GlobalVarMatrixElemType:
case SymbolUseKind::GlobalVarSampledTexElemType:
case SymbolUseKind::GlobalVarMultisampledTexElemType:
case SymbolUseKind::GlobalLetType:
case SymbolUseKind::GlobalLetArrayElemType:
case SymbolUseKind::GlobalLetVectorElemType:
case SymbolUseKind::GlobalLetMatrixElemType:
case SymbolUseKind::GlobalConstType:
case SymbolUseKind::GlobalConstArrayElemType:
case SymbolUseKind::GlobalConstVectorElemType:
@ -330,8 +299,6 @@ std::string DiagString(SymbolUseKind kind) {
return "type";
case SymbolUseKind::GlobalVarValue:
case SymbolUseKind::GlobalVarArraySizeValue:
case SymbolUseKind::GlobalLetValue:
case SymbolUseKind::GlobalLetArraySizeValue:
case SymbolUseKind::GlobalConstValue:
case SymbolUseKind::GlobalConstArraySizeValue:
case SymbolUseKind::LocalVarValue:
@ -353,7 +320,6 @@ std::string DiagString(SymbolUseKind kind) {
int ScopeDepth(SymbolDeclKind kind) {
switch (kind) {
case SymbolDeclKind::GlobalVar:
case SymbolDeclKind::GlobalLet:
case SymbolDeclKind::GlobalConst:
case SymbolDeclKind::Alias:
case SymbolDeclKind::Struct:
@ -383,12 +349,6 @@ int ScopeDepth(SymbolUseKind kind) {
case SymbolUseKind::GlobalVarMatrixElemType:
case SymbolUseKind::GlobalVarSampledTexElemType:
case SymbolUseKind::GlobalVarMultisampledTexElemType:
case SymbolUseKind::GlobalLetType:
case SymbolUseKind::GlobalLetValue:
case SymbolUseKind::GlobalLetArrayElemType:
case SymbolUseKind::GlobalLetArraySizeValue:
case SymbolUseKind::GlobalLetVectorElemType:
case SymbolUseKind::GlobalLetMatrixElemType:
case SymbolUseKind::GlobalConstType:
case SymbolUseKind::GlobalConstValue:
case SymbolUseKind::GlobalConstArrayElemType:
@ -466,8 +426,6 @@ const ast::Node* SymbolTestHelper::Add(SymbolDeclKind kind, Symbol symbol, Sourc
switch (kind) {
case SymbolDeclKind::GlobalVar:
return b.GlobalVar(source, symbol, b.ty.i32(), ast::StorageClass::kPrivate);
case SymbolDeclKind::GlobalLet:
return b.GlobalLet(source, symbol, b.ty.i32(), b.Expr(1_i));
case SymbolDeclKind::GlobalConst:
return b.GlobalConst(source, symbol, b.ty.i32(), b.Expr(1_i));
case SymbolDeclKind::Alias:
@ -548,36 +506,6 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
b.GlobalVar(b.Sym(), b.ty.i32(), ast::StorageClass::kPrivate, node);
return node;
}
case SymbolUseKind::GlobalLetType: {
auto* node = b.ty.type_name(source, symbol);
b.GlobalLet(b.Sym(), node, b.Expr(1_i));
return node;
}
case SymbolUseKind::GlobalLetArrayElemType: {
auto* node = b.ty.type_name(source, symbol);
b.GlobalLet(b.Sym(), b.ty.array(node, 4_i), b.Expr(1_i));
return node;
}
case SymbolUseKind::GlobalLetArraySizeValue: {
auto* node = b.Expr(source, symbol);
b.GlobalLet(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.GlobalLet(b.Sym(), b.ty.vec3(node), b.Expr(1_i));
return node;
}
case SymbolUseKind::GlobalLetMatrixElemType: {
auto* node = b.ty.type_name(source, symbol);
b.GlobalLet(b.Sym(), b.ty.mat3x4(node), b.Expr(1_i));
return node;
}
case SymbolUseKind::GlobalLetValue: {
auto* node = b.Expr(source, symbol);
b.GlobalLet(b.Sym(), b.ty.i32(), node);
return node;
}
case SymbolUseKind::GlobalConstType: {
auto* node = b.ty.type_name(source, symbol);
b.GlobalConst(b.Sym(), node, b.Expr(1_i));
@ -849,14 +777,6 @@ TEST_F(ResolverDependencyGraphDeclSelfUse, GlobalVar) {
12:34 note: var 'SYMBOL' references var 'SYMBOL' here)");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverDependencyGraphDeclSelfUse, GlobalLet) {
const Symbol symbol = Sym("SYMBOL");
GlobalLet(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, GlobalConst) {
const Symbol symbol = Sym("SYMBOL");
GlobalConst(symbol, ty.i32(), Mul(Expr(Source{{12, 34}}, symbol), 123_i));
@ -998,18 +918,6 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, GlobalConst_Direct) {
56:78 note: const 'V' references const 'V' here)");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverDependencyGraphCyclicRefTest, GlobalLet_Direct) {
// let V : i32 = V;
GlobalLet(Source{{12, 34}}, "V", ty.i32(), Expr(Source{{56, 78}}, "V"));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
R"(12:34 error: cyclic dependency found: 'V' -> 'V'
56:78 note: let 'V' references let 'V' here)");
}
TEST_F(ResolverDependencyGraphCyclicRefTest, GlobalVar_Indirect) {
// 1: var<private> Y : i32 = Z;
// 2: var<private> X : i32 = Y;
@ -1044,32 +952,13 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, GlobalConst_Indirect) {
2:10 note: const 'X' references const 'Y' here)");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverDependencyGraphCyclicRefTest, GlobalLet_Indirect) {
// 1: let Y : i32 = Z;
// 2: let X : i32 = Y;
// 3: let Z : i32 = X;
GlobalLet(Source{{1, 1}}, "Y", ty.i32(), Expr(Source{{1, 10}}, "Z"));
GlobalLet(Source{{2, 1}}, "X", ty.i32(), Expr(Source{{2, 10}}, "Y"));
GlobalLet(Source{{3, 1}}, "Z", ty.i32(), Expr(Source{{3, 10}}, "X"));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
R"(1:1 error: cyclic dependency found: 'Y' -> 'Z' -> 'X' -> 'Y'
1:10 note: let 'Y' references let 'Z' here
3:10 note: let 'Z' references let 'X' here
2:10 note: let 'X' references let 'Y' here)");
}
TEST_F(ResolverDependencyGraphCyclicRefTest, Mixed_RecursiveDependencies) {
// 1: fn F() -> R { return Z; }
// 2: type A = S;
// 3: struct S { a : A };
// 4: var Z = L;
// 5: type R = A;
// 6: const C : S = Z;
// 7: let L : S = C;
// 6: const L : S = Z;
Func(Source{{1, 1}}, "F", {}, ty.type_name(Source{{1, 5}}, "R"),
{Return(Expr(Source{{1, 10}}, "Z"))});
@ -1077,18 +966,16 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, Mixed_RecursiveDependencies) {
Structure(Source{{3, 1}}, "S", {Member("a", ty.type_name(Source{{3, 10}}, "A"))});
GlobalVar(Source{{4, 1}}, "Z", nullptr, Expr(Source{{4, 10}}, "L"));
Alias(Source{{5, 1}}, "R", ty.type_name(Source{{5, 10}}, "A"));
GlobalConst(Source{{6, 1}}, "C", ty.type_name(Source{{5, 5}}, "S"), Expr(Source{{5, 10}}, "Z"));
GlobalLet(Source{{7, 1}}, "L", ty.type_name(Source{{5, 5}}, "S"), Expr(Source{{5, 10}}, "C"));
GlobalConst(Source{{6, 1}}, "L", ty.type_name(Source{{5, 5}}, "S"), Expr(Source{{5, 10}}, "Z"));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
R"(2:1 error: cyclic dependency found: 'A' -> 'S' -> 'A'
2:10 note: alias 'A' references struct 'S' here
3:10 note: struct 'S' references alias 'A' here
4:1 error: cyclic dependency found: 'Z' -> 'L' -> 'C' -> 'Z'
4:10 note: var 'Z' references let 'L' here
5:10 note: let 'L' references const 'C' here
5:10 note: const 'C' references var 'Z' here)");
4:1 error: cyclic dependency found: 'Z' -> 'L' -> 'Z'
4:10 note: var 'Z' references const 'L' here
5:10 note: const 'L' references var 'Z' here)");
}
} // namespace recursive_tests
@ -1339,7 +1226,6 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) {
Structure(Sym(), {Member(Sym(), T)});
GlobalVar(Sym(), T, V);
GlobalConst(Sym(), T, V);
GlobalLet(Sym(), T, V);
Func(Sym(), //
{Param(Sym(), T)}, //
T, // Return type
@ -1408,9 +1294,8 @@ TEST_F(ResolverDependencyGraphTraversalTest, InferredType) {
// Check that the nullptr of the var / const / let type doesn't make things explode
GlobalVar("a", nullptr, Expr(1_i));
GlobalConst("b", nullptr, Expr(1_i));
GlobalLet("c", nullptr, Expr(1_i));
WrapInFunction(Var("d", nullptr, Expr(1_i)), //
Let("e", nullptr, Expr(1_i)));
WrapInFunction(Var("c", nullptr, Expr(1_i)), //
Let("d", nullptr, Expr(1_i)));
Build();
}

View File

@ -451,31 +451,6 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_GoodType_ConstU32) {
EXPECT_TRUE(sem_func->DirectlyReferencedGlobals().contains(sem_y));
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_GoodType_LetU32) {
// let x = 4u;
// let x = 8u;
// @compute @workgroup_size(x, y, 16u)
// fn main() {}
auto* x = GlobalLet("x", ty.u32(), Expr(4_u));
auto* y = GlobalLet("y", ty.u32(), Expr(8_u));
auto* func = Func("main", {}, ty.void_(), {},
{Stage(ast::PipelineStage::kCompute), WorkgroupSize("x", "y", 16_u)});
ASSERT_TRUE(r()->Resolve()) << r()->error();
auto* sem_func = Sem().Get(func);
auto* sem_x = Sem().Get<sem::GlobalVariable>(x);
auto* sem_y = Sem().Get<sem::GlobalVariable>(y);
ASSERT_NE(sem_func, nullptr);
ASSERT_NE(sem_x, nullptr);
ASSERT_NE(sem_y, nullptr);
EXPECT_TRUE(sem_func->DirectlyReferencedGlobals().contains(sem_x));
EXPECT_TRUE(sem_func->DirectlyReferencedGlobals().contains(sem_y));
}
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_GoodType_I32) {
// @compute @workgroup_size(1i, 2i, 3i)
// fn main() {}
@ -553,20 +528,6 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_TypeMismatch) {
"12:34 error: workgroup_size arguments must be of the same type, either i32 or u32");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Let_TypeMismatch) {
// let x = 64u;
// @compute @workgroup_size(1i, x)
// fn main() {}
GlobalLet("x", ty.u32(), Expr(64_u));
Func("main", {}, ty.void_(), {},
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Source{{12, 34}}, 1_i, "x")});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
"12:34 error: workgroup_size arguments must be of the same type, either i32 or u32");
}
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_TypeMismatch2) {
// const x = 64u;
// const y = 32i;
@ -582,22 +543,6 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_TypeMismatch2) {
"12:34 error: workgroup_size arguments must be of the same type, either i32 or u32");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Let_TypeMismatch2) {
// let x = 64u;
// let y = 32i;
// @compute @workgroup_size(x, y)
// fn main() {}
GlobalLet("x", ty.u32(), Expr(64_u));
GlobalLet("y", ty.i32(), Expr(32_i));
Func("main", {}, ty.void_(), {},
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Source{{12, 34}}, "x", "y")});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
"12:34 error: workgroup_size arguments must be of the same type, either i32 or u32");
}
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Mismatch_ConstU32) {
// const x = 4u;
// const x = 8u;
@ -613,22 +558,6 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Mismatch_ConstU32) {
"12:34 error: workgroup_size arguments must be of the same type, either i32 or u32");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Mismatch_LetU32) {
// let x = 4u;
// let x = 8u;
// @compute @workgroup_size(x, y, 16i)
// fn main() {}
GlobalLet("x", ty.u32(), Expr(4_u));
GlobalLet("y", ty.u32(), Expr(8_u));
Func("main", {}, ty.void_(), {},
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Source{{12, 34}}, "x", "y", 16_i)});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
"12:34 error: workgroup_size arguments must be of the same type, either i32 or u32");
}
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Literal_BadType) {
// @compute @workgroup_size(64.0)
// fn main() {}
@ -678,21 +607,6 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_BadType) {
"overridable of type abstract-integer, i32 or u32");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Let_BadType) {
// let x = 64.0;
// @compute @workgroup_size(x)
// fn main() {}
GlobalLet("x", ty.f32(), Expr(64_f));
Func("main", {}, ty.void_(), {},
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, "x"))});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
"12:34 error: workgroup_size argument must be either a literal, constant, or "
"overridable of type abstract-integer, i32 or u32");
}
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_Negative) {
// const x = -2i;
// @compute @workgroup_size(x)
@ -705,19 +619,6 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_Negative) {
EXPECT_EQ(r()->error(), "12:34 error: workgroup_size argument must be at least 1");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Let_Negative) {
// let x = -2i;
// @compute @workgroup_size(x)
// fn main() {}
GlobalLet("x", ty.i32(), Expr(-2_i));
Func("main", {}, ty.void_(), {},
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, "x"))});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: workgroup_size argument must be at least 1");
}
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_Zero) {
// const x = 0i;
// @compute @workgroup_size(x)
@ -730,19 +631,6 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_Zero) {
EXPECT_EQ(r()->error(), "12:34 error: workgroup_size argument must be at least 1");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Let_Zero) {
// let x = 0i;
// @compute @workgroup_size(x)
// fn main() {}
GlobalLet("x", ty.i32(), Expr(0_i));
Func("main", {}, ty.void_(), {},
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, "x"))});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: workgroup_size argument must be at least 1");
}
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_NestedZeroValueConstructor) {
// const x = i32(i32(i32()));
// @compute @workgroup_size(x)
@ -755,19 +643,6 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_NestedZeroValueConstr
EXPECT_EQ(r()->error(), "12:34 error: workgroup_size argument must be at least 1");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Let_NestedZeroValueConstructor) {
// let x = i32(i32(i32()));
// @compute @workgroup_size(x)
// fn main() {}
GlobalLet("x", ty.i32(), Construct(ty.i32(), Construct(ty.i32(), Construct(ty.i32()))));
Func("main", {}, ty.void_(), {},
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, "x"))});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: workgroup_size argument must be at least 1");
}
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_NonConst) {
// var<private> x = 64i;
// @compute @workgroup_size(x)

View File

@ -89,21 +89,6 @@ TEST_P(ResolverInferredTypeParamTest, GlobalConst_Pass) {
EXPECT_EQ(TypeOf(a), expected_type);
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_P(ResolverInferredTypeParamTest, GlobalLet_Pass) {
auto& params = GetParam();
auto* expected_type = params.create_expected_type(*this);
// let a = <type constructor>;
auto* ctor_expr = params.create_value(*this, 0);
auto* var = GlobalLet("a", nullptr, ctor_expr);
WrapInFunction();
EXPECT_TRUE(r()->Resolve()) << r()->error();
EXPECT_EQ(TypeOf(var), expected_type);
}
TEST_P(ResolverInferredTypeParamTest, GlobalVar_Pass) {
auto& params = GetParam();

View File

@ -365,13 +365,13 @@ sem::Variable* Resolver::Let(const ast::Let* v, bool is_global) {
sem::Variable* sem = nullptr;
if (is_global) {
sem = builder_->create<sem::GlobalVariable>(
v, ty, ast::StorageClass::kNone, ast::Access::kUndefined,
rhs ? rhs->ConstantValue() : sem::Constant{}, sem::BindingPoint{});
sem = builder_->create<sem::GlobalVariable>(v, ty, ast::StorageClass::kNone,
ast::Access::kUndefined, sem::Constant{},
sem::BindingPoint{});
} else {
sem = builder_->create<sem::LocalVariable>(v, ty, ast::StorageClass::kNone,
ast::Access::kUndefined, current_statement_,
rhs ? rhs->ConstantValue() : sem::Constant{});
sem::Constant{});
}
sem->SetConstructor(rhs);
@ -467,16 +467,6 @@ sem::Variable* Resolver::Const(const ast::Const* c, bool is_global) {
return nullptr;
}
// TODO(crbug.com/tint/1580): Temporary seatbelt to used to ensure that a `let` cannot be used
// to initialize a 'const'. Once we fully implement `const`, and remove constant evaluation from
// 'let', this can be removed.
if (auto* user = rhs->UnwrapMaterialize()->As<sem::VariableUser>();
user && user->Variable()->Is<sem::LocalVariable>() &&
user->Variable()->Declaration()->Is<ast::Let>()) {
AddError("'const' initializer must be constant expression", c->constructor->source);
return nullptr;
}
if (!validator_.VariableInitializer(c, ast::StorageClass::kNone, ty, rhs)) {
return nullptr;
}
@ -931,7 +921,7 @@ bool Resolver::WorkgroupSize(const ast::Function* func) {
if (auto* user = args[i]->As<sem::VariableUser>()) {
// We have an variable of a module-scope constant.
auto* decl = user->Variable()->Declaration();
if (!decl->IsAnyOf<ast::Let, ast::Const, ast::Override>()) {
if (!decl->IsAnyOf<ast::Const, ast::Override>()) {
AddError(kErrBadExpr, values[i]->source);
return false;
}
@ -1313,6 +1303,12 @@ const sem::Expression* Resolver::Materialize(const sem::Expression* expr,
return nullptr;
}
auto expr_val = EvaluateConstantValue(decl, expr->Type());
if (!expr_val) {
TINT_ICE(Resolver, builder_->Diagnostics())
<< decl->source << "EvaluateConstantValue(" << decl->TypeInfo().name
<< ") returned invalid value";
return nullptr;
}
auto materialized_val = ConvertValue(std::move(expr_val), target_ty, decl->source);
if (!materialized_val) {
return nullptr;
@ -2229,17 +2225,6 @@ sem::Array* Resolver::Array(const ast::Array* arr) {
return nullptr;
}
// TODO(crbug.com/tint/1580): Temporary seatbelt to used to ensure that a function-scope
// `let` cannot be used to propagate a constant expression to an array size. Once we
// implement `const`, this can be removed.
if (auto* user = count_sem->UnwrapMaterialize()->As<sem::VariableUser>();
user && user->Variable()->Is<sem::LocalVariable>() &&
user->Variable()->Declaration()->Is<ast::Let>()) {
AddError("array size must evaluate to a constant integer expression",
count_expr->source);
return nullptr;
}
auto count_val = count_sem->ConstantValue();
if (!count_val) {
AddError("array size must evaluate to a constant integer expression",

View File

@ -463,22 +463,6 @@ TEST_F(ResolverTest, ArraySize_UnsignedConst) {
EXPECT_EQ(ary->Count(), 10u);
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverTest, ArraySize_UnsignedLet) {
// let size = 10u;
// var<private> a : array<f32, size>;
GlobalLet("size", nullptr, Expr(10_u));
auto* a = GlobalVar("a", ty.array(ty.f32(), Expr("size")), ast::StorageClass::kPrivate);
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(a), nullptr);
auto* ref = TypeOf(a)->As<sem::Reference>();
ASSERT_NE(ref, nullptr);
auto* ary = ref->StoreType()->As<sem::Array>();
EXPECT_EQ(ary->Count(), 10u);
}
TEST_F(ResolverTest, ArraySize_SignedConst) {
// const size = 0;
// var<private> a : array<f32, size>;
@ -494,22 +478,6 @@ TEST_F(ResolverTest, ArraySize_SignedConst) {
EXPECT_EQ(ary->Count(), 10u);
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverTest, ArraySize_SignedLet) {
// let size = 0;
// var<private> a : array<f32, size>;
GlobalLet("size", nullptr, Expr(10_i));
auto* a = GlobalVar("a", ty.array(ty.f32(), Expr("size")), ast::StorageClass::kPrivate);
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(a), nullptr);
auto* ref = TypeOf(a)->As<sem::Reference>();
ASSERT_NE(ref, nullptr);
auto* ary = ref->StoreType()->As<sem::Array>();
EXPECT_EQ(ary->Count(), 10u);
}
TEST_F(ResolverTest, Expr_Bitcast) {
GlobalVar("name", ty.f32(), ast::StorageClass::kPrivate);
@ -662,22 +630,6 @@ TEST_F(ResolverTest, Expr_Identifier_GlobalConst) {
EXPECT_EQ(VarOf(ident)->Declaration(), my_var);
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverTest, Expr_Identifier_GlobalLet) {
auto* my_var = GlobalLet("my_var", ty.f32(), Construct(ty.f32()));
auto* ident = Expr("my_var");
WrapInFunction(ident);
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(ident), nullptr);
EXPECT_TRUE(TypeOf(ident)->Is<sem::F32>());
EXPECT_TRUE(CheckVarUsers(my_var, {ident}));
ASSERT_NE(VarOf(ident), nullptr);
EXPECT_EQ(VarOf(ident)->Declaration(), my_var);
}
TEST_F(ResolverTest, Expr_Identifier_FunctionVariable_Const) {
auto* my_var_a = Expr("my_var");
auto* var = Let("my_var", ty.f32(), Construct(ty.f32()));
@ -1023,35 +975,6 @@ TEST_F(ResolverTest, Function_WorkgroupSize_ViaConst) {
EXPECT_EQ(func_sem->WorkgroupSize()[2].overridable_const, nullptr);
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverTest, Function_WorkgroupSize_ViaLet) {
// let width = 16i;
// let height = 8i;
// let depth = 2i;
// @compute @workgroup_size(width, height, depth)
// fn main() {}
GlobalLet("width", ty.i32(), Expr(16_i));
GlobalLet("height", ty.i32(), Expr(8_i));
GlobalLet("depth", ty.i32(), Expr(2_i));
auto* func = Func("main", {}, ty.void_(), {},
{
Stage(ast::PipelineStage::kCompute),
WorkgroupSize("width", "height", "depth"),
});
EXPECT_TRUE(r()->Resolve()) << r()->error();
auto* func_sem = Sem().Get(func);
ASSERT_NE(func_sem, nullptr);
EXPECT_EQ(func_sem->WorkgroupSize()[0].value, 16u);
EXPECT_EQ(func_sem->WorkgroupSize()[1].value, 8u);
EXPECT_EQ(func_sem->WorkgroupSize()[2].value, 2u);
EXPECT_EQ(func_sem->WorkgroupSize()[0].overridable_const, nullptr);
EXPECT_EQ(func_sem->WorkgroupSize()[1].overridable_const, nullptr);
EXPECT_EQ(func_sem->WorkgroupSize()[2].overridable_const, nullptr);
}
TEST_F(ResolverTest, Function_WorkgroupSize_ViaConst_NestedInitializer) {
// const width = i32(i32(i32(8i)));
// const height = i32(i32(i32(4i)));
@ -1080,35 +1003,6 @@ TEST_F(ResolverTest, Function_WorkgroupSize_ViaConst_NestedInitializer) {
EXPECT_EQ(func_sem->WorkgroupSize()[2].overridable_const, nullptr);
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverTest, Function_WorkgroupSize_ViaLet_NestedInitializer) {
// let width = i32(i32(i32(8i)));
// let height = i32(i32(i32(4i)));
// @compute @workgroup_size(width, height)
// fn main() {}
GlobalLet("width", ty.i32(),
Construct(ty.i32(), Construct(ty.i32(), Construct(ty.i32(), 8_i))));
GlobalLet("height", ty.i32(),
Construct(ty.i32(), Construct(ty.i32(), Construct(ty.i32(), 4_i))));
auto* func = Func("main", {}, ty.void_(), {},
{
Stage(ast::PipelineStage::kCompute),
WorkgroupSize("width", "height"),
});
EXPECT_TRUE(r()->Resolve()) << r()->error();
auto* func_sem = Sem().Get(func);
ASSERT_NE(func_sem, nullptr);
EXPECT_EQ(func_sem->WorkgroupSize()[0].value, 8u);
EXPECT_EQ(func_sem->WorkgroupSize()[1].value, 4u);
EXPECT_EQ(func_sem->WorkgroupSize()[2].value, 1u);
EXPECT_EQ(func_sem->WorkgroupSize()[0].overridable_const, nullptr);
EXPECT_EQ(func_sem->WorkgroupSize()[1].overridable_const, nullptr);
EXPECT_EQ(func_sem->WorkgroupSize()[2].overridable_const, nullptr);
}
TEST_F(ResolverTest, Function_WorkgroupSize_OverridableConsts) {
// @id(0) override width = 16i;
// @id(1) override height = 8i;
@ -1191,33 +1085,6 @@ TEST_F(ResolverTest, Function_WorkgroupSize_Mixed) {
EXPECT_EQ(func_sem->WorkgroupSize()[2].overridable_const, nullptr);
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverTest, Function_WorkgroupSize_Mixed_Let) {
// @id(1) override height = 2i;
// let depth = 3i;
// @compute @workgroup_size(8, height, depth)
// fn main() {}
auto* height = Override("height", ty.i32(), Expr(2_i), {Id(0)});
GlobalConst("depth", ty.i32(), Expr(3_i));
auto* func = Func("main", {}, ty.void_(), {},
{
Stage(ast::PipelineStage::kCompute),
WorkgroupSize(8_i, "height", "depth"),
});
EXPECT_TRUE(r()->Resolve()) << r()->error();
auto* func_sem = Sem().Get(func);
ASSERT_NE(func_sem, nullptr);
EXPECT_EQ(func_sem->WorkgroupSize()[0].value, 8u);
EXPECT_EQ(func_sem->WorkgroupSize()[1].value, 2u);
EXPECT_EQ(func_sem->WorkgroupSize()[2].value, 3u);
EXPECT_EQ(func_sem->WorkgroupSize()[0].overridable_const, nullptr);
EXPECT_EQ(func_sem->WorkgroupSize()[1].overridable_const, height);
EXPECT_EQ(func_sem->WorkgroupSize()[2].overridable_const, nullptr);
}
TEST_F(ResolverTest, Expr_MemberAccessor_Struct) {
auto* st =
Structure("S", {Member("first_member", ty.i32()), Member("second_member", ty.f32())});

View File

@ -103,18 +103,6 @@ TEST_F(ResolverSourceVariableTest, GlobalConst) {
EXPECT_EQ(Sem().Get(expr)->SourceVariable(), sem_a);
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverSourceVariableTest, GlobalLet) {
auto* a = GlobalLet("a", ty.f32(), Expr(1_f));
auto* expr = Expr(a);
WrapInFunction(expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
auto* sem_a = Sem().Get(a);
EXPECT_EQ(Sem().Get(expr)->SourceVariable(), sem_a);
}
TEST_F(ResolverSourceVariableTest, FunctionVar) {
auto* a = Var("a", ty.f32(), ast::StorageClass::kNone);
auto* expr = Expr(a);

View File

@ -94,13 +94,6 @@ TEST_F(ResolverTypeValidationTest, GlobalConstNoStorageClass_Pass) {
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverTypeValidationTest, GlobalLetNoStorageClass_Pass) {
// let global_let: f32;
GlobalLet(Source{{12, 34}}, "global_let", ty.f32(), Construct(ty.f32()));
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverTypeValidationTest, GlobalVariableUnique_Pass) {
// var global_var0 : f32 = 0.1;
// var global_var1 : i32 = 0;
@ -211,15 +204,6 @@ TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedConst_Pass) {
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedLet_Pass) {
// let size = 4u;
// var<private> a : array<f32, size>;
GlobalLet("size", nullptr, Expr(4_u));
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverTypeValidationTest, ArraySize_SignedConst_Pass) {
// const size = 4i;
// var<private> a : array<f32, size>;
@ -228,15 +212,6 @@ TEST_F(ResolverTypeValidationTest, ArraySize_SignedConst_Pass) {
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverTypeValidationTest, ArraySize_SignedLet_Pass) {
// let size = 4i;
// var<private> a : array<f32, size>;
GlobalLet("size", nullptr, Expr(4_i));
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverTypeValidationTest, ArraySize_AIntLiteral_Zero) {
// var<private> a : array<f32, 0>;
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0_a)), ast::StorageClass::kPrivate);
@ -274,16 +249,6 @@ TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedConst_Zero) {
EXPECT_EQ(r()->error(), "12:34 error: array size (0) must be greater than 0");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedLet_Zero) {
// let size = 0u;
// var<private> a : array<f32, size>;
GlobalLet("size", nullptr, Expr(0_u));
GlobalVar("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 (0) must be greater than 0");
}
TEST_F(ResolverTypeValidationTest, ArraySize_SignedConst_Zero) {
// const size = 0i;
// var<private> a : array<f32, size>;
@ -293,16 +258,6 @@ TEST_F(ResolverTypeValidationTest, ArraySize_SignedConst_Zero) {
EXPECT_EQ(r()->error(), "12:34 error: array size (0) must be greater than 0");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverTypeValidationTest, ArraySize_SignedLet_Zero) {
// let size = 0i;
// var<private> a : array<f32, size>;
GlobalLet("size", nullptr, Expr(0_i));
GlobalVar("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 (0) must be greater than 0");
}
TEST_F(ResolverTypeValidationTest, ArraySize_SignedConst_Negative) {
// const size = -10i;
// var<private> a : array<f32, size>;
@ -312,16 +267,6 @@ TEST_F(ResolverTypeValidationTest, ArraySize_SignedConst_Negative) {
EXPECT_EQ(r()->error(), "12:34 error: array size (-10) must be greater than 0");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverTypeValidationTest, ArraySize_SignedLet_Negative) {
// let size = -10i;
// var<private> a : array<f32, size>;
GlobalLet("size", nullptr, Expr(-10_i));
GlobalVar("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 (-10) must be greater than 0");
}
TEST_F(ResolverTypeValidationTest, ArraySize_FloatLiteral) {
// var<private> a : array<f32, 10.0>;
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 10_f)), ast::StorageClass::kPrivate);
@ -352,18 +297,6 @@ TEST_F(ResolverTypeValidationTest, ArraySize_FloatConst) {
"'f32'");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverTypeValidationTest, ArraySize_FloatLet) {
// let size = 10.0;
// var<private> a : array<f32, size>;
GlobalLet("size", nullptr, Expr(10_f));
GlobalVar("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 evaluate to a constant integer expression, but is type "
"'f32'");
}
TEST_F(ResolverTypeValidationTest, ArraySize_IVecConst) {
// const size = vec2<i32>(100, 100);
// var<private> a : array<f32, size>;
@ -375,18 +308,6 @@ TEST_F(ResolverTypeValidationTest, ArraySize_IVecConst) {
"'vec2<i32>'");
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverTypeValidationTest, ArraySize_IVecLet) {
// let size = vec2<i32>(100, 100);
// var<private> a : array<f32, size>;
GlobalLet("size", nullptr, Construct(ty.vec2<i32>(), 100_i, 100_i));
GlobalVar("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 evaluate to a constant integer expression, but is type "
"'vec2<i32>'");
}
TEST_F(ResolverTypeValidationTest, ArraySize_TooBig_ImplicitStride) {
// var<private> a : array<f32, 0x40000000u>;
GlobalVar("a", ty.array(Source{{12, 34}}, ty.f32(), 0x40000000_u), ast::StorageClass::kPrivate);

View File

@ -84,7 +84,7 @@ class BasicTest : public UniformityAnalysisTestBase,
kTrue,
kFalse,
kLiteral,
kModuleLet,
kModuleConst,
kPipelineOverridable,
kFuncLetUniformRhs,
kFuncVarUniform,
@ -137,8 +137,8 @@ class BasicTest : public UniformityAnalysisTestBase,
return "false";
case kLiteral:
return "7 == 7";
case kModuleLet:
return "module_let == 0";
case kModuleConst:
return "module_const == 0";
case kPipelineOverridable:
return "pipeline_overridable == 0";
case kFuncLetUniformRhs:
@ -231,7 +231,7 @@ class BasicTest : public UniformityAnalysisTestBase,
CASE(kTrue);
CASE(kFalse);
CASE(kLiteral);
CASE(kModuleLet);
CASE(kModuleConst);
CASE(kPipelineOverridable);
CASE(kFuncLetUniformRhs);
CASE(kFuncVarUniform);
@ -290,7 +290,7 @@ var<workgroup> w : i32;
@group(1) @binding(2) var s : sampler;
@group(1) @binding(3) var sc : sampler_comparison;
let module_let : i32 = 42;
const module_const : i32 = 42;
@id(42) override pipeline_overridable : i32;
fn user_no_restriction() {}

View File

@ -277,30 +277,6 @@ TEST_F(ResolverVariableTest, LocalVar_ShadowsGlobalConst) {
EXPECT_EQ(user_v->Variable(), global);
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverVariableTest, LocalVar_ShadowsGlobalLet) {
// let a : i32 = 1i;
//
// fn X() {
// var a = (a == 123);
// }
auto* g = GlobalLet("a", ty.i32(), Expr(1_i));
auto* v = Var("a", nullptr, Expr("a"));
Func("F", {}, ty.void_(), {Decl(v)});
ASSERT_TRUE(r()->Resolve()) << r()->error();
auto* global = Sem().Get(g);
auto* local = Sem().Get<sem::LocalVariable>(v);
ASSERT_NE(local, nullptr);
EXPECT_EQ(local->Shadows(), global);
auto* user_v = Sem().Get<sem::VariableUser>(local->Declaration()->constructor);
ASSERT_NE(user_v, nullptr);
EXPECT_EQ(user_v->Variable(), global);
}
TEST_F(ResolverVariableTest, LocalVar_ShadowsLocalVar) {
// fn F() {
// var a : i32 = 1i; // x
@ -618,30 +594,6 @@ TEST_F(ResolverVariableTest, LocalLet_ShadowsGlobalConst) {
EXPECT_EQ(user->Variable(), global);
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverVariableTest, LocalLet_ShadowsGlobalLet) {
// let a : i32 = 1i;
//
// fn F() {
// let a = a;
// }
auto* g = GlobalLet("a", ty.i32(), Expr(1_i));
auto* l = Let("a", nullptr, Expr("a"));
Func("F", {}, ty.void_(), {Decl(l)});
ASSERT_TRUE(r()->Resolve()) << r()->error();
auto* global = Sem().Get(g);
auto* local = Sem().Get<sem::LocalVariable>(l);
ASSERT_NE(local, nullptr);
EXPECT_EQ(local->Shadows(), global);
auto* user = Sem().Get<sem::VariableUser>(local->Declaration()->constructor);
ASSERT_NE(user, nullptr);
EXPECT_EQ(user->Variable(), global);
}
TEST_F(ResolverVariableTest, LocalLet_ShadowsLocalVar) {
// fn F() {
// var a : i32 = 1i;
@ -848,26 +800,6 @@ TEST_F(ResolverVariableTest, LocalConst_ShadowsGlobalConst) {
EXPECT_EQ(user->Variable(), global);
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverVariableTest, LocalConst_ShadowsGlobalLet) {
// let a : i32 = 1i;
//
// fn F() {
// const a = 1i;
// }
auto* g = GlobalLet("a", ty.i32(), Expr(1_i));
auto* c = Const("a", nullptr, Expr("a"));
Func("F", {}, ty.void_(), {Decl(c)});
ASSERT_TRUE(r()->Resolve()) << r()->error();
auto* global = Sem().Get(g);
auto* local = Sem().Get<sem::LocalVariable>(c);
ASSERT_NE(local, nullptr);
EXPECT_EQ(local->Shadows(), global);
}
TEST_F(ResolverVariableTest, LocalConst_ShadowsLocalVar) {
// fn F() {
// var a = 1i;
@ -1368,28 +1300,6 @@ TEST_F(ResolverVariableTest, Param_ShadowsGlobalConst) {
EXPECT_EQ(param->Shadows(), global);
}
// TODO(crbug.com/tint/1580): Remove when module-scope 'let' is removed
TEST_F(ResolverVariableTest, Param_ShadowsGlobalLet) {
// let a : i32 = 1i;
//
// fn F(a : bool) {
// }
auto* g = GlobalLet("a", ty.i32(), Expr(1_i));
auto* p = Param("a", ty.bool_());
Func("F", {p}, ty.void_(), {});
ASSERT_TRUE(r()->Resolve()) << r()->error();
auto* global = Sem().Get(g);
auto* param = Sem().Get<sem::Parameter>(p);
ASSERT_NE(global, nullptr);
ASSERT_NE(param, nullptr);
EXPECT_EQ(param->Shadows(), global);
}
TEST_F(ResolverVariableTest, Param_ShadowsAlias) {
// type a = i32;
//

View File

@ -15,11 +15,6 @@
#include "gmock/gmock.h"
#include "src/tint/program.h"
// TODO(crbug.com/tint/1580): Remove when 'const' is fully implemented.
#if TINT_BUILD_WGSL_READER
#include "src/tint/reader/wgsl/parser_impl.h"
#endif
#if TINT_BUILD_SPV_READER
#include "src/tint/reader/spirv/parser_impl_test_helper.h"
#endif
@ -59,11 +54,6 @@ struct Flags {
int main(int argc, char** argv) {
testing::InitGoogleMock(&argc, argv);
// TODO(crbug.com/tint/1580): Remove when 'const' is fully implemented.
#if TINT_BUILD_WGSL_READER
tint::reader::wgsl::ParserImpl::EnableConst();
#endif
#if TINT_BUILD_WGSL_WRITER
tint::Program::printer = [](const tint::Program* program) {
auto result = tint::writer::wgsl::Generate(program, {});

View File

@ -151,7 +151,7 @@ fn f() {
)";
auto* expect = R"(
let N = 16u;
const N = 16u;
fn f() {
var i : u32 = 0u;

View File

@ -1099,20 +1099,16 @@ struct S1 {
TEST_F(PromoteInitializersToLetTest, NoChangeOnVarDecl) {
auto* src = R"(
struct S {
a : i32,
b : f32,
c : i32,
}
type F = f32;
fn f() {
var local_arr = array<f32, 4u>(0.0, 1.0, 2.0, 3.0);
var local_str = S(1, 2.0, 3);
var local_str = F(3.0);
}
let module_arr : array<f32, 4u> = array<f32, 4u>(0.0, 1.0, 2.0, 3.0);
const module_arr : array<f32, 4u> = array<f32, 4u>(0.0, 1.0, 2.0, 3.0);
let module_str : S = S(1, 2.0, 3);
const module_str : F = F(2.0);
)";
auto* expect = src;
@ -1127,18 +1123,14 @@ TEST_F(PromoteInitializersToLetTest, NoChangeOnVarDecl_OutOfOrder) {
auto* src = R"(
fn f() {
var local_arr = array<f32, 4u>(0.0, 1.0, 2.0, 3.0);
var local_str = S(1, 2.0, 3);
var local_str = F(3.0);
}
let module_str : S = S(1, 2.0, 3);
const module_str : F = F(2.0);
struct S {
a : i32,
b : f32,
c : i32,
}
type F = f32;
let module_arr : array<f32, 4u> = array<f32, 4u>(0.0, 1.0, 2.0, 3.0);
const module_arr : array<f32, 4u> = array<f32, 4u>(0.0, 1.0, 2.0, 3.0);
)";
auto* expect = src;

View File

@ -21,7 +21,7 @@ namespace {
using RobustnessTest = TransformTest;
TEST_F(RobustnessTest, Array_Idx_Clamp) {
TEST_F(RobustnessTest, Array_Let_Idx_Clamp) {
auto* src = R"(
var<private> a : array<f32, 3>;
@ -35,7 +35,7 @@ fn f() {
auto* expect = R"(
var<private> a : array<f32, 3>;
let c : u32 = 1u;
const c : u32 = 1u;
fn f() {
let b : f32 = a[1u];
@ -47,7 +47,33 @@ fn f() {
EXPECT_EQ(expect, str(got));
}
TEST_F(RobustnessTest, Array_Idx_Clamp_OutOfOrder) {
TEST_F(RobustnessTest, Array_Const_Idx_Clamp) {
auto* src = R"(
var<private> a : array<f32, 3>;
const c : u32 = 1u;
fn f() {
let b : f32 = a[c];
}
)";
auto* expect = R"(
var<private> a : array<f32, 3>;
const c : u32 = 1u;
fn f() {
let b : f32 = a[1u];
}
)";
auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got));
}
TEST_F(RobustnessTest, Array_Let_Idx_Clamp_OutOfOrder) {
auto* src = R"(
fn f() {
let b : f32 = a[c];
@ -63,7 +89,33 @@ fn f() {
let b : f32 = a[1u];
}
let c : u32 = 1u;
const c : u32 = 1u;
var<private> a : array<f32, 3>;
)";
auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got));
}
TEST_F(RobustnessTest, Array_Const_Idx_Clamp_OutOfOrder) {
auto* src = R"(
fn f() {
let b : f32 = a[c];
}
const c : u32 = 1u;
var<private> a : array<f32, 3>;
)";
auto* expect = R"(
fn f() {
let b : f32 = a[1u];
}
const c : u32 = 1u;
var<private> a : array<f32, 3>;
)";
@ -1392,7 +1444,7 @@ struct S {
@group(0) @binding(0) var<storage, read> s : S;
let c : u32 = 1u;
const c : u32 = 1u;
fn f() {
let b : f32 = s.b[c];
@ -1409,7 +1461,7 @@ struct S {
@group(0) @binding(0) var<storage, read> s : S;
let c : u32 = 1u;
const c : u32 = 1u;
fn f() {
let b : f32 = s.b[min(1u, (arrayLength(&(s.b)) - 1u))];

View File

@ -186,13 +186,13 @@ fn comp_main1() {
TEST_F(SingleEntryPointTest, GlobalConstants) {
auto* src = R"(
let a : f32 = 1.0;
const a : f32 = 1.0;
let b : f32 = 1.0;
const b : f32 = 1.0;
let c : f32 = 1.0;
const c : f32 = 1.0;
let d : f32 = 1.0;
const d : f32 = 1.0;
@vertex
fn vert_main() -> @builtin(position) vec4<f32> {
@ -217,7 +217,7 @@ fn comp_main2() {
)";
auto* expect = R"(
let c : f32 = 1.0;
const c : f32 = 1.0;
@compute @workgroup_size(1)
fn comp_main1() {
@ -238,6 +238,32 @@ TEST_F(SingleEntryPointTest, WorkgroupSizeLetPreserved) {
auto* src = R"(
let size : i32 = 1;
@compute @workgroup_size(size)
fn main() {
}
)";
auto* expect = R"(
const size : i32 = 1;
@compute @workgroup_size(size)
fn main() {
}
)";
SingleEntryPoint::Config cfg("main");
DataMap data;
data.Add<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(src, data);
EXPECT_EQ(expect, str(got));
}
TEST_F(SingleEntryPointTest, WorkgroupSizeConstPreserved) {
auto* src = R"(
const size : i32 = 1;
@compute @workgroup_size(size)
fn main() {
}

View File

@ -402,7 +402,7 @@ fn Z() {
)";
auto* expect = R"(
let a : i32 = 1;
const a : i32 = 1;
fn X() {
var a_1 = (a == 123);
@ -452,7 +452,7 @@ fn Z() {
const a_3 = 321;
}
let a : i32 = 1;
const a : i32 = 1;
)";
auto got = Run<Unshadow>(src);
@ -473,7 +473,7 @@ fn Y() {
}
fn Z() {
const a = a;
const a = 321;
}
)";
@ -489,7 +489,7 @@ fn Y() {
}
fn Z() {
const a_3 = a;
const a_3 = 321;
}
)";
@ -741,7 +741,7 @@ fn F(a : bool) {
)";
auto* expect = R"(
let a : i32 = 1;
const a : i32 = 1;
fn F(a_1 : bool) {
}
@ -764,7 +764,7 @@ let a : i32 = 1;
fn F(a_1 : bool) {
}
let a : i32 = 1;
const a : i32 = 1;
)";
auto got = Run<Unshadow>(src);

View File

@ -484,7 +484,8 @@ TEST_F(VarForDynamicIndexTest, ArrayIndexConstantLet) {
fn f() {
let p = array<i32, 4>(1, 2, 3, 4);
let c = 1;
let x = p[c];
var var_for_index = p;
let x = var_for_index[c];
}
)";
@ -501,7 +502,8 @@ TEST_F(VarForDynamicIndexTest, MatrixIndexConstantLet) {
fn f() {
let p = mat2x2(1.0, 2.0, 3.0, 4.0);
let c = 1;
let x = p[c];
var var_for_index = p;
let x = var_for_index[c];
}
)";

View File

@ -1771,14 +1771,8 @@ bool GeneratorImpl::EmitDiscard(const ast::DiscardStatement*) {
bool GeneratorImpl::EmitExpression(std::ostream& out, const ast::Expression* expr) {
if (auto* sem = builder_.Sem().Get(expr)) {
if (auto* user = sem->As<sem::VariableUser>();
!user || !user->Variable()->Declaration()->Is<ast::Let>()) {
// Disable constant inlining if the constant expression is from a 'let' declaration.
// TODO(crbug.com/tint/1580): Once 'const' is implemented, 'let' will no longer resolve
// to a shader-creation time constant value, and this can be removed.
if (auto constant = sem->ConstantValue()) {
return EmitConstant(out, constant);
}
if (auto constant = sem->ConstantValue()) {
return EmitConstant(out, constant);
}
}
return Switch(

View File

@ -805,31 +805,6 @@ void main() {
)");
}
TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute_WithWorkgroup_Let) {
GlobalLet("width", ty.i32(), Construct(ty.i32(), 2_i));
GlobalLet("height", ty.i32(), Construct(ty.i32(), 3_i));
GlobalLet("depth", ty.i32(), Construct(ty.i32(), 4_i));
Func("main", {}, ty.void_(), {},
{
Stage(ast::PipelineStage::kCompute),
WorkgroupSize("width", "height", "depth"),
});
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
EXPECT_EQ(gen.result(), R"(#version 310 es
const int width = 2;
const int height = 3;
const int depth = 4;
layout(local_size_x = 2, local_size_y = 3, local_size_z = 4) in;
void main() {
return;
}
)");
}
TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute_WithWorkgroup_Const) {
GlobalConst("width", ty.i32(), Construct(ty.i32(), 2_i));
GlobalConst("height", ty.i32(), Construct(ty.i32(), 3_i));

View File

@ -2614,14 +2614,8 @@ bool GeneratorImpl::EmitDiscard(const ast::DiscardStatement*) {
bool GeneratorImpl::EmitExpression(std::ostream& out, const ast::Expression* expr) {
if (auto* sem = builder_.Sem().Get(expr)) {
if (auto* user = sem->As<sem::VariableUser>();
!user || !user->Variable()->Declaration()->Is<ast::Let>()) {
// Disable constant inlining if the constant expression is from a 'let' declaration.
// TODO(crbug.com/tint/1580): Once 'const' is implemented, 'let' will no longer resolve
// to a shader-creation time constant value, and this can be removed.
if (auto constant = sem->ConstantValue()) {
return EmitConstant(out, constant);
}
if (auto constant = sem->ConstantValue()) {
return EmitConstant(out, constant);
}
}
return Switch(
@ -2852,7 +2846,6 @@ bool GeneratorImpl::EmitGlobalVariable(const ast::Variable* global) {
return false;
}
},
[&](const ast::Let* let) { return EmitProgramConstVariable(let); },
[&](const ast::Override* override) { return EmitOverride(override); },
[&](const ast::Const*) {
return true; // Constants are embedded at their use
@ -4057,25 +4050,6 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) {
return true;
}
bool GeneratorImpl::EmitProgramConstVariable(const ast::Let* let) {
auto* sem = builder_.Sem().Get(let);
auto* type = sem->Type();
auto out = line();
out << "static const ";
if (!EmitTypeAndName(out, type, ast::StorageClass::kNone, ast::Access::kUndefined,
builder_.Symbols().NameFor(let->symbol))) {
return false;
}
out << " = ";
if (!EmitExpression(out, let->constructor)) {
return false;
}
out << ";";
return true;
}
bool GeneratorImpl::EmitOverride(const ast::Override* override) {
auto* sem = builder_.Sem().Get(override);
auto* type = sem->Type();

View File

@ -460,10 +460,6 @@ class GeneratorImpl : public TextGenerator {
/// @param let the variable to generate
/// @returns true if the variable was emitted
bool EmitLet(const ast::Let* let);
/// Handles generating a module-scope 'let' declaration
/// @param let the 'let' to emit
/// @returns true if the variable was emitted
bool EmitProgramConstVariable(const ast::Let* let);
/// Handles generating a module-scope 'override' declaration
/// @param override the 'override' to emit
/// @returns true if the variable was emitted

View File

@ -54,11 +54,15 @@ TEST_F(HlslGeneratorImplTest_Assign, Emit_Vector_Assign_LetIndex) {
ASSERT_TRUE(gen.Generate());
EXPECT_EQ(gen.result(),
R"(void fn() {
R"(void set_float3(inout float3 vec, int idx, float val) {
vec = (idx.xxx == int3(0, 1, 2)) ? val.xxx : vec;
}
void fn() {
float3 lhs = float3(0.0f, 0.0f, 0.0f);
float rhs = 0.0f;
const uint index = 0u;
lhs[index] = rhs;
set_float3(lhs, index, rhs);
}
)");
}
@ -123,11 +127,20 @@ TEST_F(HlslGeneratorImplTest_Assign, Emit_Matrix_Assign_Vector_LetIndex) {
ASSERT_TRUE(gen.Generate());
EXPECT_EQ(gen.result(),
R"(void fn() {
R"(void set_vector_float4x2(inout float4x2 mat, int col, float2 val) {
switch (col) {
case 0: mat[0] = val; break;
case 1: mat[1] = val; break;
case 2: mat[2] = val; break;
case 3: mat[3] = val; break;
}
}
void fn() {
float4x2 lhs = float4x2(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
float2 rhs = float2(0.0f, 0.0f);
const uint index = 0u;
lhs[index] = rhs;
set_vector_float4x2(lhs, index, rhs);
}
)");
}
@ -197,11 +210,28 @@ TEST_F(HlslGeneratorImplTest_Assign, Emit_Matrix_Assign_Scalar_LetIndex) {
ASSERT_TRUE(gen.Generate());
EXPECT_EQ(gen.result(),
R"(void fn() {
R"(void set_scalar_float4x2(inout float4x2 mat, int col, int row, float val) {
switch (col) {
case 0:
mat[0] = (row.xx == int2(0, 1)) ? val.xx : mat[0];
break;
case 1:
mat[1] = (row.xx == int2(0, 1)) ? val.xx : mat[1];
break;
case 2:
mat[2] = (row.xx == int2(0, 1)) ? val.xx : mat[2];
break;
case 3:
mat[3] = (row.xx == int2(0, 1)) ? val.xx : mat[3];
break;
}
}
void fn() {
float4x2 lhs = float4x2(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
float rhs = 0.0f;
const uint index = 0u;
lhs[index][index] = rhs;
set_scalar_float4x2(lhs, index, index, rhs);
}
)");
}

View File

@ -705,30 +705,6 @@ void main() {
)");
}
TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute_WithWorkgroup_Let) {
GlobalLet("width", ty.i32(), Construct(ty.i32(), 2_i));
GlobalLet("height", ty.i32(), Construct(ty.i32(), 3_i));
GlobalLet("depth", ty.i32(), Construct(ty.i32(), 4_i));
Func("main", {}, ty.void_(), {},
{
Stage(ast::PipelineStage::kCompute),
WorkgroupSize("width", "height", "depth"),
});
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
EXPECT_EQ(gen.result(), R"(static const int width = 2;
static const int height = 3;
static const int depth = 4;
[numthreads(2, 3, 4)]
void main() {
return;
}
)");
}
TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute_WithWorkgroup_Const) {
GlobalConst("width", ty.i32(), Construct(ty.i32(), 2_i));
GlobalConst("height", ty.i32(), Construct(ty.i32(), 3_i));

View File

@ -22,16 +22,6 @@ namespace {
using HlslGeneratorImplTest_ModuleConstant = TestHelper;
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_GlobalLet) {
auto* var = Let("pos", ty.array<f32, 3>(), array<f32, 3>(1_f, 2_f, 3_f));
WrapInFunction(Decl(var));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitProgramConstVariable(var)) << gen.error();
EXPECT_EQ(gen.result(), "static const float pos[3] = {1.0f, 2.0f, 3.0f};\n");
}
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_AInt) {
auto* var = GlobalConst("G", nullptr, Expr(1_a));
Func("f", {}, ty.void_(), {Decl(Let("l", nullptr, Expr(var)))});

View File

@ -253,10 +253,6 @@ bool GeneratorImpl::Generate() {
[&](const ast::Alias*) {
return true; // folded away by the writer
},
[&](const ast::Let* let) {
TINT_DEFER(line());
return EmitProgramConstVariable(let);
},
[&](const ast::Const*) {
return true; // Constants are embedded at their use
},
@ -3030,28 +3026,6 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) {
return true;
}
bool GeneratorImpl::EmitProgramConstVariable(const ast::Let* let) {
auto* global = program_->Sem().Get<sem::GlobalVariable>(let);
auto* type = global->Type();
auto out = line();
out << "constant ";
if (!EmitType(out, type, program_->Symbols().NameFor(let->symbol))) {
return false;
}
out << " " << program_->Symbols().NameFor(let->symbol);
if (let->constructor != nullptr) {
out << " = ";
if (!EmitExpression(out, let->constructor)) {
return false;
}
}
out << ";";
return true;
}
bool GeneratorImpl::EmitOverride(const ast::Override* override) {
auto* global = program_->Sem().Get<sem::GlobalVariable>(override);
auto* type = global->Type();

View File

@ -368,10 +368,6 @@ class GeneratorImpl : public TextGenerator {
/// @param let the variable to generate
/// @returns true if the variable was emitted
bool EmitLet(const ast::Let* let);
/// Handles generating a module-scope 'let' declaration
/// @param let the 'let' to emit
/// @returns true if the variable was emitted
bool EmitProgramConstVariable(const ast::Let* let);
/// Handles generating a module-scope 'override' declaration
/// @param override the 'override' to emit
/// @returns true if the variable was emitted

View File

@ -22,16 +22,6 @@ namespace {
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, Emit_GlobalLet) {
auto* var = GlobalLet("pos", ty.array<f32, 3>(), array<f32, 3>(1_f, 2_f, 3_f));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitProgramConstVariable(var)) << gen.error();
EXPECT_EQ(gen.result(),
"constant tint_array<float, 3> pos = tint_array<float, 3>{1.0f, 2.0f, 3.0f};\n");
}
TEST_F(MslGeneratorImplTest, Emit_GlobalConst_AInt) {
auto* var = GlobalConst("G", nullptr, Expr(1_a));
Func("f", {}, ty.void_(), {Decl(Let("l", nullptr, Expr(var)))});

View File

@ -771,15 +771,7 @@ bool Builder::GenerateGlobalVariable(const ast::Variable* v) {
uint32_t init_id = 0;
if (auto* ctor = v->constructor) {
if (!v->Is<ast::Override>()) {
auto* ctor_sem = builder_.Sem().Get(ctor);
if (auto constant = ctor_sem->ConstantValue()) {
init_id = GenerateConstantIfNeeded(std::move(constant));
}
}
if (init_id == 0) {
init_id = GenerateConstructorExpression(v, v->constructor);
}
init_id = GenerateConstructorExpression(v, ctor);
if (init_id == 0) {
return false;
}
@ -817,7 +809,7 @@ bool Builder::GenerateGlobalVariable(const ast::Variable* v) {
}
}
if (v->IsAnyOf<ast::Let, ast::Override>()) {
if (v->Is<ast::Override>()) {
push_debug(spv::Op::OpName,
{Operand(init_id), Operand(builder_.Symbols().NameFor(v->symbol))});

View File

@ -42,12 +42,13 @@ TEST_F(BuilderTest, Let_IndexAccessor_Vector) {
%8 = OpConstant %6 2
%9 = OpConstant %6 3
%10 = OpConstantComposite %5 %7 %8 %9
%12 = OpTypePointer Function %6
%13 = OpConstantNull %6
%13 = OpTypePointer Function %6
%14 = OpConstantNull %6
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].variables()), R"(%11 = OpVariable %12 Function %13
EXPECT_EQ(DumpInstructions(b.functions()[0].variables()), R"(%12 = OpVariable %13 Function %14
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"(OpStore %11 %8
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"(%11 = OpCompositeExtract %6 %10 1
OpStore %12 %11
OpReturn
)");
@ -303,13 +304,18 @@ TEST_F(BuilderTest, Let_IndexAccessor_Array_MultiLevel) {
%16 = OpConstant %7 6
%17 = OpConstantComposite %6 %14 %15 %16
%18 = OpConstantComposite %5 %13 %17
%20 = OpTypePointer Function %7
%21 = OpConstantNull %7
%19 = OpTypeInt 32 1
%20 = OpConstant %19 1
%22 = OpConstant %19 2
%25 = OpTypePointer Function %7
%26 = OpConstantNull %7
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].variables()), R"(%19 = OpVariable %20 Function %21
EXPECT_EQ(DumpInstructions(b.functions()[0].variables()), R"(%24 = OpVariable %25 Function %26
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
R"(OpStore %19 %16
R"(%21 = OpCompositeExtract %6 %18 1
%23 = OpCompositeExtract %7 %21 2
OpStore %24 %23
OpReturn
)");
@ -601,12 +607,16 @@ TEST_F(BuilderTest, Let_IndexAccessor_Nested_Array_f32) {
%14 = OpConstantComposite %6 %13 %13
%15 = OpConstantComposite %6 %11 %13
%16 = OpConstantComposite %5 %12 %14 %15
%18 = OpTypePointer Function %7
%17 = OpConstant %8 1
%19 = OpConstantNull %8
%22 = OpTypePointer Function %7
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].variables()), R"(%17 = OpVariable %18 Function %10
EXPECT_EQ(DumpInstructions(b.functions()[0].variables()), R"(%21 = OpVariable %22 Function %10
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
R"(OpStore %17 %13
R"(%18 = OpCompositeExtract %6 %16 1
%20 = OpCompositeExtract %7 %18 0
OpStore %21 %20
OpReturn
)");
@ -756,12 +766,15 @@ TEST_F(BuilderTest, Let_IndexAccessor_Matrix) {
%12 = OpConstant %7 4
%13 = OpConstantComposite %6 %11 %12
%14 = OpConstantComposite %5 %10 %13
%16 = OpTypePointer Function %6
%17 = OpConstantNull %6
%15 = OpTypeInt 32 1
%16 = OpConstant %15 1
%19 = OpTypePointer Function %6
%20 = OpConstantNull %6
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].variables()), R"(%15 = OpVariable %16 Function %17
EXPECT_EQ(DumpInstructions(b.functions()[0].variables()), R"(%18 = OpVariable %19 Function %20
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"(OpStore %15 %13
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"(%17 = OpCompositeExtract %6 %14 1
OpStore %18 %17
OpReturn
)");

View File

@ -1073,21 +1073,6 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec4) {
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalLet_F32_With_F32) {
auto* ctor = Construct<f32>(2_f);
GlobalLet("g", ty.f32(), ctor);
spirv::Builder& b = SanitizeAndBuild();
ASSERT_TRUE(b.Build());
EXPECT_EQ(DumpInstructions(b.types()), R"(%1 = OpTypeFloat 32
%2 = OpConstant %1 2
%4 = OpTypeVoid
%3 = OpTypeFunction %4
)");
Validate(b);
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_F32_With_F32) {
auto* ctor = Construct<f32>(2_f);
GlobalConst("g", ty.f32(), ctor);
@ -1126,21 +1111,6 @@ TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_F32_With_F32) {
Validate(b);
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalLet_U32_With_F32) {
auto* ctor = Construct<u32>(1.5_f);
GlobalLet("g", ty.u32(), ctor);
spirv::Builder& b = SanitizeAndBuild();
ASSERT_TRUE(b.Build());
EXPECT_EQ(DumpInstructions(b.types()), R"(%1 = OpTypeInt 32 0
%2 = OpConstant %1 1
%4 = OpTypeVoid
%3 = OpTypeFunction %4
)");
Validate(b);
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_U32_With_F32) {
auto* ctor = Construct<u32>(1.5_f);
GlobalConst("g", ty.u32(), ctor);
@ -1179,22 +1149,6 @@ TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_U32_With_F32) {
Validate(b);
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalLet_Vec2_With_F32) {
auto* cast = vec2<f32>(2_f);
auto* g = GlobalLet("g", ty.vec2<f32>(), cast);
spirv::Builder& b = Build();
b.push_function(Function{});
EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u);
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 2
%3 = OpConstant %2 2
%4 = OpConstantComposite %1 %3 %3
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec2_With_F32) {
auto* cast = vec2<f32>(2_f);
GlobalConst("g", ty.vec2<f32>(), cast);
@ -1234,24 +1188,6 @@ TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec2_With_F32) {
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalLet_Vec2_With_Vec2) {
auto* cast = vec2<f32>(vec2<f32>(2_f, 2_f));
GlobalLet("a", ty.vec2<f32>(), cast);
spirv::Builder& b = SanitizeAndBuild();
ASSERT_TRUE(b.Build());
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 2
%3 = OpConstant %2 2
%4 = OpConstantComposite %1 %3 %3
%6 = OpTypeVoid
%5 = OpTypeFunction %6
)");
Validate(b);
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec2_With_Vec2) {
auto* cast = vec2<f32>(vec2<f32>(2_f, 2_f));
GlobalConst("g", ty.vec2<f32>(), cast);
@ -1295,24 +1231,6 @@ TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec2_With_Vec2) {
Validate(b);
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalLet_Vec3_With_Vec3) {
auto* cast = vec3<f32>(vec3<f32>(2_f, 2_f, 2_f));
GlobalLet("a", ty.vec3<f32>(), cast);
spirv::Builder& b = SanitizeAndBuild();
ASSERT_TRUE(b.Build());
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 3
%3 = OpConstant %2 2
%4 = OpConstantComposite %1 %3 %3 %3
%6 = OpTypeVoid
%5 = OpTypeFunction %6
)");
Validate(b);
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec3_With_Vec3) {
auto* cast = vec3<f32>(vec3<f32>(2_f, 2_f, 2_f));
GlobalConst("g", ty.vec3<f32>(), cast);
@ -1356,24 +1274,6 @@ TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec3_With_Vec3) {
Validate(b);
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalLet_Vec4_With_Vec4) {
auto* cast = vec4<f32>(vec4<f32>(2_f, 2_f, 2_f, 2_f));
GlobalLet("a", ty.vec4<f32>(), cast);
spirv::Builder& b = SanitizeAndBuild();
ASSERT_TRUE(b.Build());
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 4
%3 = OpConstant %2 2
%4 = OpConstantComposite %1 %3 %3 %3 %3
%6 = OpTypeVoid
%5 = OpTypeFunction %6
)");
Validate(b);
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_With_Vec4) {
auto* cast = vec4<f32>(vec4<f32>(2_f, 2_f, 2_f, 2_f));
GlobalConst("g", ty.vec4<f32>(), cast);
@ -1416,22 +1316,6 @@ TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_With_Vec4) {
Validate(b);
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalLet_Vec3_With_F32) {
auto* cast = vec3<f32>(2_f);
auto* g = GlobalLet("g", ty.vec3<f32>(), cast);
spirv::Builder& b = Build();
b.push_function(Function{});
EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u);
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 3
%3 = OpConstant %2 2
%4 = OpConstantComposite %1 %3 %3 %3
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec3_With_F32) {
auto* cast = vec3<f32>(2_f);
GlobalConst("g", ty.vec3<f32>(), cast);
@ -1471,22 +1355,6 @@ TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec3_With_F32) {
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalLet_Vec3_With_F32_Vec2) {
auto* cast = vec3<f32>(2_f, vec2<f32>(2_f, 2_f));
auto* g = GlobalLet("g", ty.vec3<f32>(), cast);
spirv::Builder& b = Build();
b.push_function(Function{});
EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u);
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 3
%3 = OpConstant %2 2
%4 = OpConstantComposite %1 %3 %3 %3
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec3_With_F32_Vec2) {
auto* cast = vec3<f32>(2_f, vec2<f32>(2_f, 2_f));
GlobalConst("g", ty.vec3<f32>(), cast);
@ -1526,22 +1394,6 @@ TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec3_With_F32_Vec2) {
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalLet_Vec3_With_Vec2_F32) {
auto* cast = vec3<f32>(vec2<f32>(2_f, 2_f), 2_f);
auto* g = GlobalLet("g", ty.vec3<f32>(), cast);
spirv::Builder& b = Build();
b.push_function(Function{});
EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u);
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 3
%3 = OpConstant %2 2
%4 = OpConstantComposite %1 %3 %3 %3
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec3_With_Vec2_F32) {
auto* cast = vec3<f32>(vec2<f32>(2_f, 2_f), 2_f);
GlobalConst("g", ty.vec3<f32>(), cast);
@ -1581,22 +1433,6 @@ TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec3_With_Vec2_F32) {
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalLet_Vec4_With_F32) {
auto* cast = vec4<f32>(2_f);
auto* g = GlobalLet("g", ty.vec4<f32>(), cast);
spirv::Builder& b = Build();
b.push_function(Function{});
EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u);
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 4
%3 = OpConstant %2 2
%4 = OpConstantComposite %1 %3 %3 %3 %3
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_With_F32) {
auto* cast = vec4<f32>(2_f);
GlobalConst("g", ty.vec4<f32>(), cast);
@ -1636,22 +1472,6 @@ TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_With_F32) {
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalLet_Vec4_With_F32_F32_Vec2) {
auto* cast = vec4<f32>(2_f, 2_f, vec2<f32>(2_f, 2_f));
auto* g = GlobalLet("g", ty.vec4<f32>(), cast);
spirv::Builder& b = Build();
b.push_function(Function{});
EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u);
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 4
%3 = OpConstant %2 2
%4 = OpConstantComposite %1 %3 %3 %3 %3
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_With_F32_F32_Vec2) {
auto* cast = vec4<f32>(2_f, 2_f, vec2<f32>(2_f, 2_f));
GlobalConst("g", ty.vec4<f32>(), cast);
@ -1691,22 +1511,6 @@ TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_With_F32_F32_Vec2) {
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalLet_Vec4_With_F32_Vec2_F32) {
auto* cast = vec4<f32>(2_f, vec2<f32>(2_f, 2_f), 2_f);
auto* g = GlobalLet("g", ty.vec4<f32>(), cast);
spirv::Builder& b = Build();
b.push_function(Function{});
EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u);
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 4
%3 = OpConstant %2 2
%4 = OpConstantComposite %1 %3 %3 %3 %3
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_With_F32_Vec2_F32) {
auto* cast = vec4<f32>(2_f, vec2<f32>(2_f, 2_f), 2_f);
GlobalConst("g", ty.vec4<f32>(), cast);
@ -1746,22 +1550,6 @@ TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_With_F32_Vec2_F32) {
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalLet_Vec4_With_Vec2_F32_F32) {
auto* cast = vec4<f32>(vec2<f32>(2_f, 2_f), 2_f, 2_f);
auto* g = GlobalLet("g", ty.vec4<f32>(), cast);
spirv::Builder& b = Build();
b.push_function(Function{});
EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u);
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 4
%3 = OpConstant %2 2
%4 = OpConstantComposite %1 %3 %3 %3 %3
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_With_Vec2_F32_F32) {
auto* cast = vec4<f32>(vec2<f32>(2_f, 2_f), 2_f, 2_f);
GlobalConst("g", ty.vec4<f32>(), cast);
@ -1801,22 +1589,6 @@ TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_With_Vec2_F32_F32) {
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalLet_Vec4_With_Vec2_Vec2) {
auto* cast = vec4<f32>(vec2<f32>(2_f, 2_f), vec2<f32>(2_f, 2_f));
auto* g = GlobalLet("g", ty.vec4<f32>(), cast);
spirv::Builder& b = Build();
b.push_function(Function{});
EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u);
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 4
%3 = OpConstant %2 2
%4 = OpConstantComposite %1 %3 %3 %3 %3
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_With_Vec2_Vec2) {
auto* cast = vec4<f32>(vec2<f32>(2_f, 2_f), vec2<f32>(2_f, 2_f));
GlobalConst("g", ty.vec4<f32>(), cast);
@ -1856,22 +1628,6 @@ TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_With_Vec2_Vec2) {
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalLet_Vec4_With_F32_Vec3) {
auto* cast = vec4<f32>(2_f, vec3<f32>(2_f, 2_f, 2_f));
auto* g = GlobalLet("g", ty.vec4<f32>(), cast);
spirv::Builder& b = Build();
b.push_function(Function{});
EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u);
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 4
%3 = OpConstant %2 2
%4 = OpConstantComposite %1 %3 %3 %3 %3
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_With_F32_Vec3) {
auto* cast = vec4<f32>(2_f, vec3<f32>(2_f, 2_f, 2_f));
GlobalConst("g", ty.vec4<f32>(), cast);
@ -1911,22 +1667,6 @@ TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_With_F32_Vec3) {
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalLet_Vec4_With_Vec3_F32) {
auto* cast = vec4<f32>(vec3<f32>(2_f, 2_f, 2_f), 2_f);
auto* g = GlobalLet("g", ty.vec4<f32>(), cast);
spirv::Builder& b = Build();
b.push_function(Function{});
EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u);
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 4
%3 = OpConstant %2 2
%4 = OpConstantComposite %1 %3 %3 %3 %3
)");
}
TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_With_Vec3_F32) {
auto* cast = vec4<f32>(vec3<f32>(2_f, 2_f, 2_f), 2_f);
GlobalConst("g", ty.vec4<f32>(), cast);

View File

@ -131,24 +131,6 @@ TEST_F(BuilderTest, Decoration_ExecutionMode_WorkgroupSize_Literals) {
)");
}
TEST_F(BuilderTest, Decoration_ExecutionMode_WorkgroupSize_Let) {
GlobalLet("width", ty.i32(), Construct(ty.i32(), 2_i));
GlobalLet("height", ty.i32(), Construct(ty.i32(), 3_i));
GlobalLet("depth", ty.i32(), Construct(ty.i32(), 4_i));
auto* func = Func("main", {}, ty.void_(), {},
{
WorkgroupSize("width", "height", "depth"),
Stage(ast::PipelineStage::kCompute),
});
spirv::Builder& b = Build();
ASSERT_TRUE(b.GenerateExecutionModes(func, 3)) << b.error();
EXPECT_EQ(DumpInstructions(b.execution_modes()),
R"(OpExecutionMode %3 LocalSize 2 3 4
)");
}
TEST_F(BuilderTest, Decoration_ExecutionMode_WorkgroupSize_Const) {
GlobalConst("width", ty.i32(), Construct(ty.i32(), 2_i));
GlobalConst("height", ty.i32(), Construct(ty.i32(), 3_i));
@ -197,33 +179,6 @@ OpDecorate %3 BuiltIn WorkgroupSize
)");
}
TEST_F(BuilderTest, Decoration_ExecutionMode_WorkgroupSize_LiteralAndLet) {
Override("height", ty.i32(), Construct(ty.i32(), 2_i), {Id(7u)});
GlobalLet("depth", ty.i32(), Construct(ty.i32(), 3_i));
auto* func = Func("main", {}, ty.void_(), {},
{
WorkgroupSize(4_i, "height", "depth"),
Stage(ast::PipelineStage::kCompute),
});
spirv::Builder& b = Build();
ASSERT_TRUE(b.GenerateExecutionModes(func, 3)) << b.error();
EXPECT_EQ(DumpInstructions(b.execution_modes()), "");
EXPECT_EQ(DumpInstructions(b.types()),
R"(%2 = OpTypeInt 32 0
%1 = OpTypeVector %2 3
%4 = OpConstant %2 4
%5 = OpSpecConstant %2 2
%6 = OpConstant %2 3
%3 = OpSpecConstantComposite %1 %4 %5 %6
)");
EXPECT_EQ(DumpInstructions(b.annots()),
R"(OpDecorate %5 SpecId 7
OpDecorate %3 BuiltIn WorkgroupSize
)");
}
TEST_F(BuilderTest, Decoration_ExecutionMode_WorkgroupSize_LiteralAndConst) {
Override("height", ty.i32(), Construct(ty.i32(), 2_i), {Id(7u)});
GlobalConst("depth", ty.i32(), Construct(ty.i32(), 3_i));

View File

@ -61,26 +61,6 @@ TEST_F(BuilderTest, GlobalVar_WithConstructor) {
)");
}
TEST_F(BuilderTest, GlobalLet) {
auto* init = vec3<f32>(1_f, 1_f, 3_f);
auto* v = GlobalLet("l", ty.vec3<f32>(), init);
spirv::Builder& b = Build();
EXPECT_TRUE(b.GenerateGlobalVariable(v)) << b.error();
ASSERT_FALSE(b.has_error()) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %5 "l"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 3
%3 = OpConstant %2 1
%4 = OpConstant %2 3
%5 = OpConstantComposite %1 %3 %3 %4
)");
}
TEST_F(BuilderTest, GlobalConst) {
// const c = 42;
// var v = c;
@ -106,25 +86,6 @@ TEST_F(BuilderTest, GlobalConst) {
Validate(b);
}
TEST_F(BuilderTest, GlobalLet_Vec_Constructor) {
auto* init = vec3<f32>(1_f, 2_f, 3_f);
auto* v = GlobalLet("l", ty.vec3<f32>(), init);
spirv::Builder& b = Build();
EXPECT_TRUE(b.GenerateGlobalVariable(v)) << b.error();
ASSERT_FALSE(b.has_error()) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 3
%3 = OpConstant %2 1
%4 = OpConstant %2 2
%5 = OpConstant %2 3
%6 = OpConstantComposite %1 %3 %4 %5
)");
}
TEST_F(BuilderTest, GlobalConst_Vec_Constructor) {
// const c = vec3<f32>(1f, 2f, 3f);
// var v = c;
@ -212,25 +173,6 @@ TEST_F(BuilderTest, GlobalConst_Vec_AFloat_Constructor) {
Validate(b);
}
TEST_F(BuilderTest, GlobalLet_Nested_Vec_Constructor) {
auto* init = vec3<f32>(vec2<f32>(1_f, 2_f), 3_f);
auto* v = GlobalLet("l", ty.vec3<f32>(), init);
spirv::Builder& b = Build();
EXPECT_TRUE(b.GenerateGlobalVariable(v)) << b.error();
ASSERT_FALSE(b.has_error()) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 3
%3 = OpConstant %2 1
%4 = OpConstant %2 2
%5 = OpConstant %2 3
%6 = OpConstantComposite %1 %3 %4 %5
)");
}
TEST_F(BuilderTest, GlobalConst_Nested_Vec_Constructor) {
// const c = vec3<f32>(vec2<f32>(1f, 2f), 3f));
// var v = c;

View File

@ -78,7 +78,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_WithAttribute_WorkgroupSize) {
}
TEST_F(WgslGeneratorImplTest, Emit_Function_WithAttribute_WorkgroupSize_WithIdent) {
GlobalLet("height", ty.i32(), Expr(2_i));
GlobalConst("height", ty.i32(), Expr(2_i));
auto* func = Func("my_func", {}, ty.void_(), {Return()},
{
Stage(ast::PipelineStage::kCompute),

View File

@ -131,21 +131,6 @@ TEST_F(WgslGeneratorImplTest, Emit_Global_Texture) {
EXPECT_EQ(gen.result(), " @group(0) @binding(0) var t : texture_1d<f32>;\n");
}
TEST_F(WgslGeneratorImplTest, Emit_GlobalLet) {
GlobalLet("explicit", ty.f32(), Expr(1_f));
GlobalLet("inferred", nullptr, Expr(1_f));
GeneratorImpl& gen = Build();
gen.increment_indent();
ASSERT_TRUE(gen.Generate()) << gen.error();
EXPECT_EQ(gen.result(), R"( let explicit : f32 = 1.0f;
let inferred = 1.0f;
)");
}
TEST_F(WgslGeneratorImplTest, Emit_GlobalConst) {
GlobalConst("explicit", ty.f32(), Expr(1_f));
GlobalConst("inferred", nullptr, Expr(1_f));

View File

@ -2,8 +2,8 @@
void tint_symbol() {
mat3 m = mat3(vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f), vec3(7.0f, 8.0f, 9.0f));
vec3 v = vec3(4.0f, 5.0f, 6.0f);
float f = 5.0f;
vec3 v = m[1];
float f = v[1];
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -1,7 +1,7 @@
[numthreads(1, 1, 1)]
void main() {
const float3x3 m = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f));
const float3 v = float3(4.0f, 5.0f, 6.0f);
const float f = 5.0f;
const float3 v = m[1];
const float f = v[1];
return;
}

View File

@ -3,8 +3,8 @@
using namespace metal;
kernel void tint_symbol() {
float3x3 const m = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f));
float3 const v = float3(4.0f, 5.0f, 6.0f);
float const f = 5.0f;
float3 const v = m[1];
float const f = v[1];
return;
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 21
; Bound: 25
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -26,7 +26,11 @@
%float_9 = OpConstant %float 9
%19 = OpConstantComposite %v3float %float_7 %float_8 %float_9
%20 = OpConstantComposite %mat3v3float %11 %15 %19
%int = OpTypeInt 32 1
%int_1 = OpConstant %int 1
%main = OpFunction %void None %1
%4 = OpLabel
%23 = OpCompositeExtract %v3float %20 1
%24 = OpCompositeExtract %float %23 1
OpReturn
OpFunctionEnd

View File

@ -1,5 +1,5 @@
let slen = 4;
let ulen = 4u;
const slen = 4;
const ulen = 4u;
@fragment
fn main() {

View File

@ -1,8 +1,6 @@
#version 310 es
precision mediump float;
const int slen = 4;
const uint ulen = 4u;
void tint_symbol() {
float signed_literal[4] = float[4](0.0f, 0.0f, 0.0f, 0.0f);
float unsigned_literal[4] = float[4](0.0f, 0.0f, 0.0f, 0.0f);

View File

@ -1,6 +1,3 @@
static const int slen = 4;
static const uint ulen = 4u;
void main() {
float signed_literal[4] = (float[4])0;
float unsigned_literal[4] = (float[4])0;

View File

@ -14,10 +14,6 @@ struct tint_array {
T elements[N];
};
constant int slen = 4;
constant uint ulen = 4u;
fragment void tint_symbol() {
tint_array<float, 4> signed_literal = {};
tint_array<float, 4> unsigned_literal = {};

View File

@ -1,39 +1,35 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 19
; Bound: 17
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main"
OpExecutionMode %main OriginUpperLeft
OpName %slen "slen"
OpName %ulen "ulen"
OpName %main "main"
OpName %signed_literal "signed_literal"
OpName %unsigned_literal "unsigned_literal"
OpName %signed_constant "signed_constant"
OpName %unsigned_constant "unsigned_constant"
OpDecorate %_arr_float_ulen ArrayStride 4
%int = OpTypeInt 32 1
%slen = OpConstant %int 4
%uint = OpTypeInt 32 0
%ulen = OpConstant %uint 4
OpDecorate %_arr_float_uint_4 ArrayStride 4
%void = OpTypeVoid
%5 = OpTypeFunction %void
%1 = OpTypeFunction %void
%float = OpTypeFloat 32
%_arr_float_ulen = OpTypeArray %float %ulen
%_ptr_Function__arr_float_ulen = OpTypePointer Function %_arr_float_ulen
%13 = OpConstantNull %_arr_float_ulen
%main = OpFunction %void None %5
%8 = OpLabel
%signed_literal = OpVariable %_ptr_Function__arr_float_ulen Function %13
%unsigned_literal = OpVariable %_ptr_Function__arr_float_ulen Function %13
%signed_constant = OpVariable %_ptr_Function__arr_float_ulen Function %13
%unsigned_constant = OpVariable %_ptr_Function__arr_float_ulen Function %13
%17 = OpLoad %_arr_float_ulen %unsigned_constant
OpStore %signed_literal %17
%18 = OpLoad %_arr_float_ulen %unsigned_literal
OpStore %signed_constant %18
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
%_arr_float_uint_4 = OpTypeArray %float %uint_4
%_ptr_Function__arr_float_uint_4 = OpTypePointer Function %_arr_float_uint_4
%11 = OpConstantNull %_arr_float_uint_4
%main = OpFunction %void None %1
%4 = OpLabel
%signed_literal = OpVariable %_ptr_Function__arr_float_uint_4 Function %11
%unsigned_literal = OpVariable %_ptr_Function__arr_float_uint_4 Function %11
%signed_constant = OpVariable %_ptr_Function__arr_float_uint_4 Function %11
%unsigned_constant = OpVariable %_ptr_Function__arr_float_uint_4 Function %11
%15 = OpLoad %_arr_float_uint_4 %unsigned_constant
OpStore %signed_literal %15
%16 = OpLoad %_arr_float_uint_4 %unsigned_literal
OpStore %signed_constant %16
OpReturn
OpFunctionEnd

View File

@ -1,6 +1,6 @@
let slen = 4;
const slen = 4;
let ulen = 4u;
const ulen = 4u;
@fragment
fn main() {

View File

@ -4,35 +4,35 @@ void tint_symbol() {
int x = 42;
int empty[4] = int[4](0, 0, 0, 0);
int nonempty[4] = int[4](1, 2, 3, 4);
int nonempty_with_expr[4] = int[4](1, x, (x + 1), 4);
int nonempty_with_expr[4] = int[4](1, x, (x + 1), nonempty[3]);
int nested_empty[2][3][4] = int[2][3][4](int[3][4](int[4](0, 0, 0, 0), int[4](0, 0, 0, 0), int[4](0, 0, 0, 0)), int[3][4](int[4](0, 0, 0, 0), int[4](0, 0, 0, 0), int[4](0, 0, 0, 0)));
int tint_symbol_1[4] = int[4](1, 2, 3, 4);
int tint_symbol_2[4] = int[4](5, 6, 7, 8);
int tint_symbol_3[4] = int[4](9, 10, 11, 12);
int tint_symbol_4[3][4] = int[3][4](int[4](1, 2, 3, 4), int[4](5, 6, 7, 8), int[4](9, 10, 11, 12));
int tint_symbol_4[3][4] = int[3][4](tint_symbol_1, tint_symbol_2, tint_symbol_3);
int tint_symbol_5[4] = int[4](13, 14, 15, 16);
int tint_symbol_6[4] = int[4](17, 18, 19, 20);
int tint_symbol_7[4] = int[4](21, 22, 23, 24);
int tint_symbol_8[3][4] = int[3][4](int[4](13, 14, 15, 16), int[4](17, 18, 19, 20), int[4](21, 22, 23, 24));
int nested_nonempty[2][3][4] = int[2][3][4](int[3][4](int[4](1, 2, 3, 4), int[4](5, 6, 7, 8), int[4](9, 10, 11, 12)), int[3][4](int[4](13, 14, 15, 16), int[4](17, 18, 19, 20), int[4](21, 22, 23, 24)));
int tint_symbol_8[3][4] = int[3][4](tint_symbol_5, tint_symbol_6, tint_symbol_7);
int nested_nonempty[2][3][4] = int[2][3][4](tint_symbol_4, tint_symbol_8);
int tint_symbol_9[4] = int[4](1, 2, x, (x + 1));
int tint_symbol_10[4] = int[4](5, 6, 3, (4 + 1));
int tint_symbol_10[4] = int[4](5, 6, nonempty[2], (nonempty[3] + 1));
int tint_symbol_11[3][4] = int[3][4](tint_symbol_9, tint_symbol_10, nonempty);
int nested_nonempty_with_expr[2][3][4] = int[2][3][4](tint_symbol_11, int[3][4](int[4](13, 14, 15, 16), int[4](17, 18, 19, 20), int[4](21, 22, 23, 24)));
int nested_nonempty_with_expr[2][3][4] = int[2][3][4](tint_symbol_11, nested_nonempty[1]);
int tint_symbol_12[4] = int[4](0, 0, 0, 0);
int subexpr_empty = 0;
int subexpr_empty = tint_symbol_12[1];
int tint_symbol_13[4] = int[4](1, 2, 3, 4);
int subexpr_nonempty = 3;
int tint_symbol_14[4] = int[4](1, x, (x + 1), 4);
int subexpr_nonempty = tint_symbol_13[2];
int tint_symbol_14[4] = int[4](1, x, (x + 1), nonempty[3]);
int subexpr_nonempty_with_expr = tint_symbol_14[2];
int tint_symbol_15[2][4] = int[2][4](int[4](0, 0, 0, 0), int[4](0, 0, 0, 0));
int subexpr_nested_empty[4] = int[4](0, 0, 0, 0);
int subexpr_nested_empty[4] = tint_symbol_15[1];
int tint_symbol_16[4] = int[4](1, 2, 3, 4);
int tint_symbol_17[4] = int[4](5, 6, 7, 8);
int tint_symbol_18[2][4] = int[2][4](int[4](1, 2, 3, 4), int[4](5, 6, 7, 8));
int subexpr_nested_nonempty[4] = int[4](5, 6, 7, 8);
int tint_symbol_19[4] = int[4](1, x, (x + 1), 4);
int tint_symbol_20[2][4] = int[2][4](tint_symbol_19, int[4](21, 22, 23, 24));
int tint_symbol_18[2][4] = int[2][4](tint_symbol_16, tint_symbol_17);
int subexpr_nested_nonempty[4] = tint_symbol_18[1];
int tint_symbol_19[4] = int[4](1, x, (x + 1), nonempty[3]);
int tint_symbol_20[2][4] = int[2][4](tint_symbol_19, nested_nonempty[1][2]);
int subexpr_nested_nonempty_with_expr[4] = tint_symbol_20[1];
}

View File

@ -3,35 +3,35 @@ void main() {
const int x = 42;
const int empty[4] = (int[4])0;
const int nonempty[4] = {1, 2, 3, 4};
const int nonempty_with_expr[4] = {1, x, (x + 1), 4};
const int nonempty_with_expr[4] = {1, x, (x + 1), nonempty[3]};
const int nested_empty[2][3][4] = (int[2][3][4])0;
const int tint_symbol[4] = {1, 2, 3, 4};
const int tint_symbol_1[4] = {5, 6, 7, 8};
const int tint_symbol_2[4] = {9, 10, 11, 12};
const int tint_symbol_3[3][4] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
const int tint_symbol_3[3][4] = {tint_symbol, tint_symbol_1, tint_symbol_2};
const int tint_symbol_4[4] = {13, 14, 15, 16};
const int tint_symbol_5[4] = {17, 18, 19, 20};
const int tint_symbol_6[4] = {21, 22, 23, 24};
const int tint_symbol_7[3][4] = {{13, 14, 15, 16}, {17, 18, 19, 20}, {21, 22, 23, 24}};
const int nested_nonempty[2][3][4] = {{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}, {{13, 14, 15, 16}, {17, 18, 19, 20}, {21, 22, 23, 24}}};
const int tint_symbol_7[3][4] = {tint_symbol_4, tint_symbol_5, tint_symbol_6};
const int nested_nonempty[2][3][4] = {tint_symbol_3, tint_symbol_7};
const int tint_symbol_8[4] = {1, 2, x, (x + 1)};
const int tint_symbol_9[4] = {5, 6, 3, (4 + 1)};
const int tint_symbol_9[4] = {5, 6, nonempty[2], (nonempty[3] + 1)};
const int tint_symbol_10[3][4] = {tint_symbol_8, tint_symbol_9, nonempty};
const int nested_nonempty_with_expr[2][3][4] = {tint_symbol_10, {{13, 14, 15, 16}, {17, 18, 19, 20}, {21, 22, 23, 24}}};
const int nested_nonempty_with_expr[2][3][4] = {tint_symbol_10, nested_nonempty[1]};
const int tint_symbol_11[4] = (int[4])0;
const int subexpr_empty = 0;
const int subexpr_empty = tint_symbol_11[1];
const int tint_symbol_12[4] = {1, 2, 3, 4};
const int subexpr_nonempty = 3;
const int tint_symbol_13[4] = {1, x, (x + 1), 4};
const int subexpr_nonempty = tint_symbol_12[2];
const int tint_symbol_13[4] = {1, x, (x + 1), nonempty[3]};
const int subexpr_nonempty_with_expr = tint_symbol_13[2];
const int tint_symbol_14[2][4] = (int[2][4])0;
const int subexpr_nested_empty[4] = (int[4])0;
const int subexpr_nested_empty[4] = tint_symbol_14[1];
const int tint_symbol_15[4] = {1, 2, 3, 4};
const int tint_symbol_16[4] = {5, 6, 7, 8};
const int tint_symbol_17[2][4] = {{1, 2, 3, 4}, {5, 6, 7, 8}};
const int subexpr_nested_nonempty[4] = {5, 6, 7, 8};
const int tint_symbol_18[4] = {1, x, (x + 1), 4};
const int tint_symbol_19[2][4] = {tint_symbol_18, {21, 22, 23, 24}};
const int tint_symbol_17[2][4] = {tint_symbol_15, tint_symbol_16};
const int subexpr_nested_nonempty[4] = tint_symbol_17[1];
const int tint_symbol_18[4] = {1, x, (x + 1), nonempty[3]};
const int tint_symbol_19[2][4] = {tint_symbol_18, nested_nonempty[1][2]};
const int subexpr_nested_nonempty_with_expr[4] = tint_symbol_19[1];
return;
}

View File

@ -18,35 +18,35 @@ kernel void tint_symbol() {
int const x = 42;
tint_array<int, 4> const empty = tint_array<int, 4>{};
tint_array<int, 4> const nonempty = tint_array<int, 4>{1, 2, 3, 4};
tint_array<int, 4> const nonempty_with_expr = tint_array<int, 4>{1, x, as_type<int>((as_type<uint>(x) + as_type<uint>(1))), 4};
tint_array<int, 4> const nonempty_with_expr = tint_array<int, 4>{1, x, as_type<int>((as_type<uint>(x) + as_type<uint>(1))), nonempty[3]};
tint_array<tint_array<tint_array<int, 4>, 3>, 2> const nested_empty = tint_array<tint_array<tint_array<int, 4>, 3>, 2>{};
tint_array<int, 4> const tint_symbol_1 = tint_array<int, 4>{1, 2, 3, 4};
tint_array<int, 4> const tint_symbol_2 = tint_array<int, 4>{5, 6, 7, 8};
tint_array<int, 4> const tint_symbol_3 = tint_array<int, 4>{9, 10, 11, 12};
tint_array<tint_array<int, 4>, 3> const tint_symbol_4 = tint_array<tint_array<int, 4>, 3>{tint_array<int, 4>{1, 2, 3, 4}, tint_array<int, 4>{5, 6, 7, 8}, tint_array<int, 4>{9, 10, 11, 12}};
tint_array<tint_array<int, 4>, 3> const tint_symbol_4 = tint_array<tint_array<int, 4>, 3>{tint_symbol_1, tint_symbol_2, tint_symbol_3};
tint_array<int, 4> const tint_symbol_5 = tint_array<int, 4>{13, 14, 15, 16};
tint_array<int, 4> const tint_symbol_6 = tint_array<int, 4>{17, 18, 19, 20};
tint_array<int, 4> const tint_symbol_7 = tint_array<int, 4>{21, 22, 23, 24};
tint_array<tint_array<int, 4>, 3> const tint_symbol_8 = tint_array<tint_array<int, 4>, 3>{tint_array<int, 4>{13, 14, 15, 16}, tint_array<int, 4>{17, 18, 19, 20}, tint_array<int, 4>{21, 22, 23, 24}};
tint_array<tint_array<tint_array<int, 4>, 3>, 2> const nested_nonempty = tint_array<tint_array<tint_array<int, 4>, 3>, 2>{tint_array<tint_array<int, 4>, 3>{tint_array<int, 4>{1, 2, 3, 4}, tint_array<int, 4>{5, 6, 7, 8}, tint_array<int, 4>{9, 10, 11, 12}}, tint_array<tint_array<int, 4>, 3>{tint_array<int, 4>{13, 14, 15, 16}, tint_array<int, 4>{17, 18, 19, 20}, tint_array<int, 4>{21, 22, 23, 24}}};
tint_array<tint_array<int, 4>, 3> const tint_symbol_8 = tint_array<tint_array<int, 4>, 3>{tint_symbol_5, tint_symbol_6, tint_symbol_7};
tint_array<tint_array<tint_array<int, 4>, 3>, 2> const nested_nonempty = tint_array<tint_array<tint_array<int, 4>, 3>, 2>{tint_symbol_4, tint_symbol_8};
tint_array<int, 4> const tint_symbol_9 = tint_array<int, 4>{1, 2, x, as_type<int>((as_type<uint>(x) + as_type<uint>(1)))};
tint_array<int, 4> const tint_symbol_10 = tint_array<int, 4>{5, 6, 3, as_type<int>((as_type<uint>(4) + as_type<uint>(1)))};
tint_array<int, 4> const tint_symbol_10 = tint_array<int, 4>{5, 6, nonempty[2], as_type<int>((as_type<uint>(nonempty[3]) + as_type<uint>(1)))};
tint_array<tint_array<int, 4>, 3> const tint_symbol_11 = tint_array<tint_array<int, 4>, 3>{tint_symbol_9, tint_symbol_10, nonempty};
tint_array<tint_array<tint_array<int, 4>, 3>, 2> const nested_nonempty_with_expr = tint_array<tint_array<tint_array<int, 4>, 3>, 2>{tint_symbol_11, tint_array<tint_array<int, 4>, 3>{tint_array<int, 4>{13, 14, 15, 16}, tint_array<int, 4>{17, 18, 19, 20}, tint_array<int, 4>{21, 22, 23, 24}}};
tint_array<tint_array<tint_array<int, 4>, 3>, 2> const nested_nonempty_with_expr = tint_array<tint_array<tint_array<int, 4>, 3>, 2>{tint_symbol_11, nested_nonempty[1]};
tint_array<int, 4> const tint_symbol_12 = tint_array<int, 4>{};
int const subexpr_empty = 0;
int const subexpr_empty = tint_symbol_12[1];
tint_array<int, 4> const tint_symbol_13 = tint_array<int, 4>{1, 2, 3, 4};
int const subexpr_nonempty = 3;
tint_array<int, 4> const tint_symbol_14 = tint_array<int, 4>{1, x, as_type<int>((as_type<uint>(x) + as_type<uint>(1))), 4};
int const subexpr_nonempty = tint_symbol_13[2];
tint_array<int, 4> const tint_symbol_14 = tint_array<int, 4>{1, x, as_type<int>((as_type<uint>(x) + as_type<uint>(1))), nonempty[3]};
int const subexpr_nonempty_with_expr = tint_symbol_14[2];
tint_array<tint_array<int, 4>, 2> const tint_symbol_15 = tint_array<tint_array<int, 4>, 2>{};
tint_array<int, 4> const subexpr_nested_empty = tint_array<int, 4>{};
tint_array<int, 4> const subexpr_nested_empty = tint_symbol_15[1];
tint_array<int, 4> const tint_symbol_16 = tint_array<int, 4>{1, 2, 3, 4};
tint_array<int, 4> const tint_symbol_17 = tint_array<int, 4>{5, 6, 7, 8};
tint_array<tint_array<int, 4>, 2> const tint_symbol_18 = tint_array<tint_array<int, 4>, 2>{tint_array<int, 4>{1, 2, 3, 4}, tint_array<int, 4>{5, 6, 7, 8}};
tint_array<int, 4> const subexpr_nested_nonempty = tint_array<int, 4>{5, 6, 7, 8};
tint_array<int, 4> const tint_symbol_19 = tint_array<int, 4>{1, x, as_type<int>((as_type<uint>(x) + as_type<uint>(1))), 4};
tint_array<tint_array<int, 4>, 2> const tint_symbol_20 = tint_array<tint_array<int, 4>, 2>{tint_symbol_19, tint_array<int, 4>{21, 22, 23, 24}};
tint_array<tint_array<int, 4>, 2> const tint_symbol_18 = tint_array<tint_array<int, 4>, 2>{tint_symbol_16, tint_symbol_17};
tint_array<int, 4> const subexpr_nested_nonempty = tint_symbol_18[1];
tint_array<int, 4> const tint_symbol_19 = tint_array<int, 4>{1, x, as_type<int>((as_type<uint>(x) + as_type<uint>(1))), nonempty[3]};
tint_array<tint_array<int, 4>, 2> const tint_symbol_20 = tint_array<tint_array<int, 4>, 2>{tint_symbol_19, nested_nonempty[1][2]};
tint_array<int, 4> const subexpr_nested_nonempty_with_expr = tint_symbol_20[1];
return;
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 66
; Bound: 74
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -29,53 +29,61 @@
%_arr__arr_int_uint_4_uint_3 = OpTypeArray %_arr_int_uint_4 %uint_3
%uint_2 = OpConstant %uint 2
%_arr__arr__arr_int_uint_4_uint_3_uint_2 = OpTypeArray %_arr__arr_int_uint_4_uint_3 %uint_2
%22 = OpConstantNull %_arr__arr__arr_int_uint_4_uint_3_uint_2
%23 = OpConstantNull %_arr__arr__arr_int_uint_4_uint_3_uint_2
%int_5 = OpConstant %int 5
%int_6 = OpConstant %int 6
%int_7 = OpConstant %int 7
%int_8 = OpConstant %int 8
%27 = OpConstantComposite %_arr_int_uint_4 %int_5 %int_6 %int_7 %int_8
%28 = OpConstantComposite %_arr_int_uint_4 %int_5 %int_6 %int_7 %int_8
%int_9 = OpConstant %int 9
%int_10 = OpConstant %int 10
%int_11 = OpConstant %int 11
%int_12 = OpConstant %int 12
%32 = OpConstantComposite %_arr_int_uint_4 %int_9 %int_10 %int_11 %int_12
%33 = OpConstantComposite %_arr__arr_int_uint_4_uint_3 %15 %27 %32
%33 = OpConstantComposite %_arr_int_uint_4 %int_9 %int_10 %int_11 %int_12
%34 = OpConstantComposite %_arr__arr_int_uint_4_uint_3 %15 %28 %33
%int_13 = OpConstant %int 13
%int_14 = OpConstant %int 14
%int_15 = OpConstant %int 15
%int_16 = OpConstant %int 16
%38 = OpConstantComposite %_arr_int_uint_4 %int_13 %int_14 %int_15 %int_16
%39 = OpConstantComposite %_arr_int_uint_4 %int_13 %int_14 %int_15 %int_16
%int_17 = OpConstant %int 17
%int_18 = OpConstant %int 18
%int_19 = OpConstant %int 19
%int_20 = OpConstant %int 20
%43 = OpConstantComposite %_arr_int_uint_4 %int_17 %int_18 %int_19 %int_20
%44 = OpConstantComposite %_arr_int_uint_4 %int_17 %int_18 %int_19 %int_20
%int_21 = OpConstant %int 21
%int_22 = OpConstant %int 22
%int_23 = OpConstant %int 23
%int_24 = OpConstant %int 24
%48 = OpConstantComposite %_arr_int_uint_4 %int_21 %int_22 %int_23 %int_24
%49 = OpConstantComposite %_arr__arr_int_uint_4_uint_3 %38 %43 %48
%50 = OpConstantComposite %_arr__arr__arr_int_uint_4_uint_3_uint_2 %33 %49
%57 = OpConstantNull %int
%49 = OpConstantComposite %_arr_int_uint_4 %int_21 %int_22 %int_23 %int_24
%50 = OpConstantComposite %_arr__arr_int_uint_4_uint_3 %39 %44 %49
%51 = OpConstantComposite %_arr__arr__arr_int_uint_4_uint_3_uint_2 %34 %50
%61 = OpConstantNull %int
%_arr__arr_int_uint_4_uint_2 = OpTypeArray %_arr_int_uint_4 %uint_2
%main = OpFunction %void None %1
%4 = OpLabel
%16 = OpIAdd %int %int_42 %int_1
%17 = OpCompositeConstruct %_arr_int_uint_4 %int_1 %int_42 %16 %int_4
%51 = OpIAdd %int %int_42 %int_1
%52 = OpCompositeConstruct %_arr_int_uint_4 %int_1 %int_2 %int_42 %51
%53 = OpIAdd %int %int_4 %int_1
%54 = OpCompositeConstruct %_arr_int_uint_4 %int_5 %int_6 %int_3 %53
%55 = OpCompositeConstruct %_arr__arr_int_uint_4_uint_3 %52 %54 %15
%56 = OpCompositeConstruct %_arr__arr__arr_int_uint_4_uint_3_uint_2 %55 %49
%58 = OpIAdd %int %int_42 %int_1
%59 = OpCompositeConstruct %_arr_int_uint_4 %int_1 %int_42 %58 %int_4
%60 = OpCompositeExtract %int %59 2
%17 = OpCompositeExtract %int %15 3
%18 = OpCompositeConstruct %_arr_int_uint_4 %int_1 %int_42 %16 %17
%52 = OpIAdd %int %int_42 %int_1
%53 = OpCompositeConstruct %_arr_int_uint_4 %int_1 %int_2 %int_42 %52
%54 = OpCompositeExtract %int %15 2
%55 = OpCompositeExtract %int %15 3
%56 = OpIAdd %int %55 %int_1
%57 = OpCompositeConstruct %_arr_int_uint_4 %int_5 %int_6 %54 %56
%58 = OpCompositeConstruct %_arr__arr_int_uint_4_uint_3 %53 %57 %15
%59 = OpCompositeExtract %_arr__arr_int_uint_4_uint_3 %51 1
%60 = OpCompositeConstruct %_arr__arr__arr_int_uint_4_uint_3_uint_2 %58 %59
%62 = OpIAdd %int %int_42 %int_1
%63 = OpCompositeConstruct %_arr_int_uint_4 %int_1 %int_42 %62 %int_4
%64 = OpCompositeConstruct %_arr__arr_int_uint_4_uint_2 %63 %48
%65 = OpCompositeExtract %_arr_int_uint_4 %64 1
%63 = OpCompositeExtract %int %15 3
%64 = OpCompositeConstruct %_arr_int_uint_4 %int_1 %int_42 %62 %63
%65 = OpCompositeExtract %int %64 2
%67 = OpIAdd %int %int_42 %int_1
%68 = OpCompositeExtract %int %15 3
%69 = OpCompositeConstruct %_arr_int_uint_4 %int_1 %int_42 %67 %68
%70 = OpCompositeExtract %_arr__arr_int_uint_4_uint_3 %51 1
%71 = OpCompositeExtract %_arr_int_uint_4 %70 2
%72 = OpCompositeConstruct %_arr__arr_int_uint_4_uint_2 %69 %71
%73 = OpCompositeExtract %_arr_int_uint_4 %72 1
OpReturn
OpFunctionEnd

View File

@ -1,4 +1,4 @@
let bloomDir = vec2(0.0, 1.0);
const bloomDir = vec2(0.0, 1.0);
var<private> offsets : array<f32, 3> = array<f32, 3>(0.0, 1.384615421, 3.230769157);

View File

@ -53,7 +53,7 @@ struct GlobalLights {
@group(0) @binding(3) var<storage, read> globalLights : GlobalLights;
let tileCount = vec3(32u, 18u, 48u);
const tileCount = vec3(32u, 18u, 48u);
fn linearDepth(depthSample : f32) -> f32 {
return ((camera.zFar * camera.zNear) / fma(depthSample, (camera.zNear - camera.zFar), camera.zFar));

View File

@ -21,9 +21,9 @@ struct FragmentInput {
fragNorm : vec3<f32>,
}
let albedo : vec3<f32> = vec3<f32>(0.899999976, 0.899999976, 0.899999976);
const albedo : vec3<f32> = vec3<f32>(0.899999976, 0.899999976, 0.899999976);
let ambientFactor : f32 = 0.200000003;
const ambientFactor : f32 = 0.200000003;
@fragment
fn main(input : FragmentInput) -> @location(0) vec4<f32> {

View File

@ -1,4 +1,4 @@
let GAMMA = 2.200000048;
const GAMMA = 2.200000048;
fn linearTosRGB(linear : vec3<f32>) -> vec3<f32> {
let INV_GAMMA = (1.0 / GAMMA);
@ -53,7 +53,7 @@ struct GlobalLights {
@binding(2) @group(0) var<storage, read> globalLights : GlobalLights;
let tileCount = vec3(32u, 18u, 48u);
const tileCount = vec3(32u, 18u, 48u);
fn linearDepth(depthSample : f32) -> f32 {
return ((camera.zFar * camera.zNear) / fma(depthSample, (camera.zNear - camera.zFar), camera.zFar));
@ -85,7 +85,7 @@ struct LightShadowTable {
var<private> shadowSampleOffsets : array<vec2<f32>, 16> = array<vec2<f32>, 16>(vec2(-1.5, -1.5), vec2(-1.5, -0.5), vec2(-1.5, 0.5), vec2(-1.5, 1.5), vec2(-0.5, -1.5), vec2(-0.5, -0.5), vec2(-0.5, 0.5), vec2(-0.5, 1.5), vec2(0.5, -1.5), vec2(0.5, -0.5), vec2(0.5, 0.5), vec2(0.5, 1.5), vec2(1.5, -1.5), vec2(1.5, -0.5), vec2(1.5, 0.5), vec2(1.5, 1.5));
let shadowSampleCount = 16u;
const shadowSampleCount = 16u;
struct ShadowProperties {
viewport : vec4<f32>,
@ -249,13 +249,13 @@ fn GetSurfaceInfo(input : VertexOutput) -> SurfaceInfo {
return surface;
}
let PI = 3.141592741;
const PI = 3.141592741;
let LightType_Point = 0u;
const LightType_Point = 0u;
let LightType_Spot = 1u;
const LightType_Spot = 1u;
let LightType_Directional = 2u;
const LightType_Directional = 2u;
struct PuctualLight {
lightType : u32,

View File

@ -1,2 +1,2 @@
let
const
H=1;

View File

@ -4,4 +4,3 @@ layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void unused_entry_point() {
return;
}
const int H = 1;

View File

@ -3,4 +3,3 @@ void unused_entry_point() {
return;
}
static const int H = 1;

View File

@ -1,5 +1,3 @@
#include <metal_stdlib>
using namespace metal;
constant int H = 1;

View File

@ -1,19 +1,16 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 7
; Bound: 5
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %H "H"
OpName %unused_entry_point "unused_entry_point"
%int = OpTypeInt 32 1
%H = OpConstant %int 1
%void = OpTypeVoid
%3 = OpTypeFunction %void
%unused_entry_point = OpFunction %void None %3
%6 = OpLabel
%1 = OpTypeFunction %void
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd

View File

@ -1 +1 @@
let H = 1;
const H = 1;

View File

@ -84,7 +84,7 @@ void tint_symbol_2(uvec3 GlobalInvocationID) {
for(int x_1 = 0; (x_1 < TILE_COUNT_X); x_1 = (x_1 + 1)) {
ivec2 tilePixel0Idx = ivec2((x_1 * TILE_SIZE), (y_1 * TILE_SIZE));
vec2 floorCoord = (((2.0f * vec2(tilePixel0Idx)) / uniforms.fullScreenSize.xy) - vec2(1.0f));
vec2 ceilCoord = (((2.0f * vec2((tilePixel0Idx + ivec2(16)))) / uniforms.fullScreenSize.xy) - vec2(1.0f));
vec2 ceilCoord = (((2.0f * vec2((tilePixel0Idx + ivec2(TILE_SIZE)))) / uniforms.fullScreenSize.xy) - vec2(1.0f));
vec2 viewFloorCoord = vec2((((-(viewNear) * floorCoord.x) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * floorCoord.y) - (M[2][1] * viewNear)) / M[1][1]));
vec2 viewCeilCoord = vec2((((-(viewNear) * ceilCoord.x) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * ceilCoord.y) - (M[2][1] * viewNear)) / M[1][1]));
frustumPlanes[0] = vec4(1.0f, 0.0f, (-(viewFloorCoord.x) / viewNear), 0.0f);

View File

@ -58,7 +58,7 @@ void main_inner(uint3 GlobalInvocationID) {
[loop] for(int x_1 = 0; (x_1 < TILE_COUNT_X); x_1 = (x_1 + 1)) {
int2 tilePixel0Idx = int2((x_1 * TILE_SIZE), (y_1 * TILE_SIZE));
float2 floorCoord = (((2.0f * float2(tilePixel0Idx)) / asfloat(uniforms[10]).xy) - (1.0f).xx);
float2 ceilCoord = (((2.0f * float2((tilePixel0Idx + (16).xx))) / asfloat(uniforms[10]).xy) - (1.0f).xx);
float2 ceilCoord = (((2.0f * float2((tilePixel0Idx + int2((TILE_SIZE).xx)))) / asfloat(uniforms[10]).xy) - (1.0f).xx);
float2 viewFloorCoord = float2((((-(viewNear) * floorCoord.x) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * floorCoord.y) - (M[2][1] * viewNear)) / M[1][1]));
float2 viewCeilCoord = float2((((-(viewNear) * ceilCoord.x) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * ceilCoord.y) - (M[2][1] * viewNear)) / M[1][1]));
frustumPlanes[0] = float4(1.0f, 0.0f, (-(viewFloorCoord.x) / viewNear), 0.0f);

View File

@ -88,7 +88,7 @@ void tint_symbol_inner(uint3 GlobalInvocationID, const constant Config* const ti
for(int x_1 = 0; (x_1 < TILE_COUNT_X); x_1 = as_type<int>((as_type<uint>(x_1) + as_type<uint>(1)))) {
int2 tilePixel0Idx = int2(as_type<int>((as_type<uint>(x_1) * as_type<uint>(TILE_SIZE))), as_type<int>((as_type<uint>(y_1) * as_type<uint>(TILE_SIZE))));
float2 floorCoord = (((2.0f * float2(tilePixel0Idx)) / float4((*(tint_symbol_3)).fullScreenSize).xy) - float2(1.0f));
float2 ceilCoord = (((2.0f * float2(as_type<int2>((as_type<uint2>(tilePixel0Idx) + as_type<uint2>(int2(16)))))) / float4((*(tint_symbol_3)).fullScreenSize).xy) - float2(1.0f));
float2 ceilCoord = (((2.0f * float2(as_type<int2>((as_type<uint2>(tilePixel0Idx) + as_type<uint2>(int2(TILE_SIZE)))))) / float4((*(tint_symbol_3)).fullScreenSize).xy) - float2(1.0f));
float2 viewFloorCoord = float2((((-(viewNear) * floorCoord[0]) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * floorCoord[1]) - (M[2][1] * viewNear)) / M[1][1]));
float2 viewCeilCoord = float2((((-(viewNear) * ceilCoord[0]) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * ceilCoord[1]) - (M[2][1] * viewNear)) / M[1][1]));
frustumPlanes[0] = float4(1.0f, 0.0f, (-(viewFloorCoord[0]) / viewNear), 0.0f);

View File

@ -175,7 +175,6 @@
%207 = OpConstantComposite %v2float %float_1 %float_1
%_ptr_Function_v2float = OpTypePointer Function %v2float
%211 = OpConstantNull %v2float
%214 = OpConstantComposite %v2int %int_16 %int_16
%int_1 = OpConstant %int 1
%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint
%_ptr_StorageBuffer_uint_0 = OpTypePointer StorageBuffer %uint
@ -358,6 +357,7 @@
%208 = OpFSub %v2float %206 %207
OpStore %floorCoord %208
%213 = OpLoad %v2int %tilePixel0Idx
%214 = OpCompositeConstruct %v2int %int_16 %int_16
%215 = OpIAdd %v2int %213 %214
%212 = OpConvertSToF %v2float %215
%216 = OpVectorTimesScalar %v2float %212 %float_2

View File

@ -6,7 +6,7 @@ void unused_entry_point() {
}
void f() {
mat4 m = mat4(vec4(1.0f), vec4(1.0f), vec4(1.0f), vec4(1.0f));
vec4 v1 = vec4(1.0f);
float a = 1.0f;
vec4 v1 = m[0];
float a = v1[0];
}

View File

@ -5,6 +5,6 @@ void unused_entry_point() {
void f() {
const float4x4 m = float4x4((1.0f).xxxx, (1.0f).xxxx, (1.0f).xxxx, (1.0f).xxxx);
const float4 v1 = (1.0f).xxxx;
const float a = 1.0f;
const float4 v1 = m[0];
const float a = v1[0];
}

View File

@ -3,7 +3,7 @@
using namespace metal;
void f() {
float4x4 const m = float4x4(float4(1.0f), float4(1.0f), float4(1.0f), float4(1.0f));
float4 const v1 = float4(1.0f);
float const a = 1.0f;
float4 const v1 = m[0];
float const a = v1[0];
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 13
; Bound: 17
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -17,11 +17,15 @@
%float_1 = OpConstant %float 1
%11 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%12 = OpConstantComposite %mat4v4float %11 %11 %11 %11
%int = OpTypeInt 32 1
%14 = OpConstantNull %int
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %void None %1
%6 = OpLabel
%15 = OpCompositeExtract %v4float %12 0
%16 = OpCompositeExtract %float %15 0
OpReturn
OpFunctionEnd

View File

@ -2,7 +2,7 @@
values : array<f32>,
};
let width : u32 = 128u;
const width : u32 = 128u;
@group(0) @binding(0) var tex : texture_depth_2d;
@group(0) @binding(1) var<storage, read_write> result : Result;

View File

@ -1,12 +1,11 @@
#version 310 es
const uint width = 128u;
layout(binding = 1, std430) buffer Result_1 {
float values[];
} result;
uniform highp sampler2D tex_1;
void tint_symbol(uvec3 GlobalInvocationId) {
result.values[((GlobalInvocationId.y * width) + GlobalInvocationId.x)] = texelFetch(tex_1, ivec2(int(GlobalInvocationId.x), int(GlobalInvocationId.y)), 0).x;
result.values[((GlobalInvocationId.y * 128u) + GlobalInvocationId.x)] = texelFetch(tex_1, ivec2(int(GlobalInvocationId.x), int(GlobalInvocationId.y)), 0).x;
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -1,5 +1,3 @@
static const uint width = 128u;
Texture2D tex : register(t0, space0);
RWByteAddressBuffer result : register(u1, space0);
@ -8,7 +6,7 @@ struct tint_symbol_1 {
};
void main_inner(uint3 GlobalInvocationId) {
result.Store((4u * ((GlobalInvocationId.y * width) + GlobalInvocationId.x)), asuint(tex.Load(int3(int(GlobalInvocationId.x), int(GlobalInvocationId.y), 0)).x));
result.Store((4u * ((GlobalInvocationId.y * 128u) + GlobalInvocationId.x)), asuint(tex.Load(int3(int(GlobalInvocationId.x), int(GlobalInvocationId.y), 0)).x));
}
[numthreads(1, 1, 1)]

View File

@ -18,10 +18,8 @@ struct Result {
/* 0x0000 */ tint_array<float, 1> values;
};
constant uint width = 128u;
void tint_symbol_inner(uint3 GlobalInvocationId, device Result* const tint_symbol_1, depth2d<float, access::sample> tint_symbol_2) {
(*(tint_symbol_1)).values[((GlobalInvocationId[1] * width) + GlobalInvocationId[0])] = tint_symbol_2.read(uint2(int2(int(GlobalInvocationId[0]), int(GlobalInvocationId[1]))), 0);
(*(tint_symbol_1)).values[((GlobalInvocationId[1] * 128u) + GlobalInvocationId[0])] = tint_symbol_2.read(uint2(int2(int(GlobalInvocationId[0]), int(GlobalInvocationId[1]))), 0);
}
kernel void tint_symbol(device Result* tint_symbol_3 [[buffer(0)]], depth2d<float, access::sample> tint_symbol_4 [[texture(0)]], uint3 GlobalInvocationId [[thread_position_in_grid]]) {

View File

@ -8,7 +8,6 @@
OpEntryPoint GLCompute %main "main" %GlobalInvocationId_1
OpExecutionMode %main LocalSize 1 1 1
OpName %GlobalInvocationId_1 "GlobalInvocationId_1"
OpName %width "width"
OpName %tex "tex"
OpName %Result "Result"
OpMemberName %Result 0 "values"
@ -28,33 +27,33 @@
%v3uint = OpTypeVector %uint 3
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
%GlobalInvocationId_1 = OpVariable %_ptr_Input_v3uint Input
%width = OpConstant %uint 128
%float = OpTypeFloat 32
%8 = OpTypeImage %float 2D 0 0 0 1 Unknown
%_ptr_UniformConstant_8 = OpTypePointer UniformConstant %8
%tex = OpVariable %_ptr_UniformConstant_8 UniformConstant
%7 = OpTypeImage %float 2D 0 0 0 1 Unknown
%_ptr_UniformConstant_7 = OpTypePointer UniformConstant %7
%tex = OpVariable %_ptr_UniformConstant_7 UniformConstant
%_runtimearr_float = OpTypeRuntimeArray %float
%Result = OpTypeStruct %_runtimearr_float
%_ptr_StorageBuffer_Result = OpTypePointer StorageBuffer %Result
%result = OpVariable %_ptr_StorageBuffer_Result StorageBuffer
%void = OpTypeVoid
%14 = OpTypeFunction %void %v3uint
%13 = OpTypeFunction %void %v3uint
%uint_0 = OpConstant %uint 0
%uint_128 = OpConstant %uint 128
%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float
%v4float = OpTypeVector %float 4
%int = OpTypeInt 32 1
%v2int = OpTypeVector %int 2
%37 = OpConstantNull %int
%38 = OpTypeFunction %void
%main_inner = OpFunction %void None %14
%main_inner = OpFunction %void None %13
%GlobalInvocationId = OpFunctionParameter %v3uint
%18 = OpLabel
%20 = OpCompositeExtract %uint %GlobalInvocationId 1
%21 = OpIMul %uint %20 %width
%17 = OpLabel
%19 = OpCompositeExtract %uint %GlobalInvocationId 1
%21 = OpIMul %uint %19 %uint_128
%22 = OpCompositeExtract %uint %GlobalInvocationId 0
%23 = OpIAdd %uint %21 %22
%25 = OpAccessChain %_ptr_StorageBuffer_float %result %uint_0 %23
%29 = OpLoad %8 %tex
%29 = OpLoad %7 %tex
%33 = OpCompositeExtract %uint %GlobalInvocationId 0
%32 = OpBitcast %int %33
%35 = OpCompositeExtract %uint %GlobalInvocationId 1

View File

@ -2,7 +2,7 @@ struct Result {
values : array<f32>,
}
let width : u32 = 128u;
const width : u32 = 128u;
@group(0) @binding(0) var tex : texture_depth_2d;

View File

@ -38,11 +38,11 @@ fn mm_write(row : u32, col : u32, value : f32) {
}
}
let RowPerThread : u32 = 4u;
let ColPerThread : u32 = 4u;
let TileAOuter : u32 = 64u;
let TileBOuter : u32 = 64u;
let TileInner : u32 = 64u;
const RowPerThread : u32 = 4u;
const ColPerThread : u32 = 4u;
const TileAOuter : u32 = 64u;
const TileBOuter : u32 = 64u;
const TileInner : u32 = 64u;
var<workgroup> mm_Asub : array<array<f32, 64>, 64>;
var<workgroup> mm_Bsub : array<array<f32, 64>, 64>;
@compute @workgroup_size(16, 16, 1)

View File

@ -56,9 +56,6 @@ void mm_write(uint row, uint col, float value) {
}
}
const uint RowPerThread = 4u;
const uint ColPerThread = 4u;
const uint TileInner = 64u;
shared float mm_Asub[64][64];
shared float mm_Bsub[64][64];
void tint_symbol(uvec3 local_id, uvec3 global_id, uint local_invocation_index) {
@ -71,32 +68,32 @@ void tint_symbol(uvec3 local_id, uvec3 global_id, uint local_invocation_index) {
}
}
barrier();
uint tileRow = (local_id.y * RowPerThread);
uint tileCol = (local_id.x * ColPerThread);
uint globalRow = (global_id.y * RowPerThread);
uint globalCol = (global_id.x * ColPerThread);
uint numTiles = (((uniforms.dimInner - 1u) / TileInner) + 1u);
uint tileRow = (local_id.y * 4u);
uint tileCol = (local_id.x * 4u);
uint globalRow = (global_id.y * 4u);
uint globalCol = (global_id.x * 4u);
uint numTiles = (((uniforms.dimInner - 1u) / 64u) + 1u);
float acc[16] = float[16](0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
float ACached = 0.0f;
float BCached[4] = float[4](0.0f, 0.0f, 0.0f, 0.0f);
{
for(uint index = 0u; (index < (RowPerThread * ColPerThread)); index = (index + 1u)) {
for(uint index = 0u; (index < (4u * 4u)); index = (index + 1u)) {
acc[index] = 0.0f;
}
}
uint ColPerThreadA = (TileInner / 16u);
uint ColPerThreadA = (64u / 16u);
uint tileColA = (local_id.x * ColPerThreadA);
uint RowPerThreadB = (TileInner / 16u);
uint RowPerThreadB = (64u / 16u);
uint tileRowB = (local_id.y * RowPerThreadB);
{
for(uint t = 0u; (t < numTiles); t = (t + 1u)) {
{
for(uint innerRow = 0u; (innerRow < RowPerThread); innerRow = (innerRow + 1u)) {
for(uint innerRow = 0u; (innerRow < 4u); innerRow = (innerRow + 1u)) {
{
for(uint innerCol = 0u; (innerCol < ColPerThreadA); innerCol = (innerCol + 1u)) {
uint inputRow = (tileRow + innerRow);
uint inputCol = (tileColA + innerCol);
float tint_symbol_1 = mm_readA((globalRow + innerRow), ((t * TileInner) + inputCol));
float tint_symbol_1 = mm_readA((globalRow + innerRow), ((t * 64u) + inputCol));
mm_Asub[inputRow][inputCol] = tint_symbol_1;
}
}
@ -105,10 +102,10 @@ void tint_symbol(uvec3 local_id, uvec3 global_id, uint local_invocation_index) {
{
for(uint innerRow = 0u; (innerRow < RowPerThreadB); innerRow = (innerRow + 1u)) {
{
for(uint innerCol = 0u; (innerCol < ColPerThread); innerCol = (innerCol + 1u)) {
for(uint innerCol = 0u; (innerCol < 4u); innerCol = (innerCol + 1u)) {
uint inputRow = (tileRowB + innerRow);
uint inputCol = (tileCol + innerCol);
float tint_symbol_2 = mm_readB(((t * TileInner) + inputRow), (globalCol + innerCol));
float tint_symbol_2 = mm_readB(((t * 64u) + inputRow), (globalCol + innerCol));
mm_Bsub[innerCol][inputCol] = tint_symbol_2;
}
}
@ -116,18 +113,18 @@ void tint_symbol(uvec3 local_id, uvec3 global_id, uint local_invocation_index) {
}
barrier();
{
for(uint k = 0u; (k < TileInner); k = (k + 1u)) {
for(uint k = 0u; (k < 64u); k = (k + 1u)) {
{
for(uint inner = 0u; (inner < ColPerThread); inner = (inner + 1u)) {
for(uint inner = 0u; (inner < 4u); inner = (inner + 1u)) {
BCached[inner] = mm_Bsub[k][(tileCol + inner)];
}
}
{
for(uint innerRow = 0u; (innerRow < RowPerThread); innerRow = (innerRow + 1u)) {
for(uint innerRow = 0u; (innerRow < 4u); innerRow = (innerRow + 1u)) {
ACached = mm_Asub[(tileRow + innerRow)][k];
{
for(uint innerCol = 0u; (innerCol < ColPerThread); innerCol = (innerCol + 1u)) {
uint index = ((innerRow * ColPerThread) + innerCol);
for(uint innerCol = 0u; (innerCol < 4u); innerCol = (innerCol + 1u)) {
uint index = ((innerRow * 4u) + innerCol);
acc[index] = (acc[index] + (ACached * BCached[innerCol]));
}
}
@ -139,10 +136,10 @@ void tint_symbol(uvec3 local_id, uvec3 global_id, uint local_invocation_index) {
}
}
{
for(uint innerRow = 0u; (innerRow < RowPerThread); innerRow = (innerRow + 1u)) {
for(uint innerRow = 0u; (innerRow < 4u); innerRow = (innerRow + 1u)) {
{
for(uint innerCol = 0u; (innerCol < ColPerThread); innerCol = (innerCol + 1u)) {
uint index = ((innerRow * ColPerThread) + innerCol);
for(uint innerCol = 0u; (innerCol < 4u); innerCol = (innerCol + 1u)) {
uint index = ((innerRow * 4u) + innerCol);
mm_write((globalRow + innerRow), (globalCol + innerCol), acc[index]);
}
}

View File

@ -40,12 +40,6 @@ void mm_write(uint row, uint col, float value) {
}
}
static const uint RowPerThread = 4u;
static const uint ColPerThread = 4u;
static const uint TileAOuter = 64u;
static const uint TileBOuter = 64u;
static const uint TileInner = 64u;
groupshared float mm_Asub[64][64];
groupshared float mm_Bsub[64][64];
@ -65,32 +59,32 @@ void main_inner(uint3 local_id, uint3 global_id, uint local_invocation_index) {
}
}
GroupMemoryBarrierWithGroupSync();
const uint tileRow = (local_id.y * RowPerThread);
const uint tileCol = (local_id.x * ColPerThread);
const uint globalRow = (global_id.y * RowPerThread);
const uint globalCol = (global_id.x * ColPerThread);
const uint numTiles = (((uniforms[0].y - 1u) / TileInner) + 1u);
const uint tileRow = (local_id.y * 4u);
const uint tileCol = (local_id.x * 4u);
const uint globalRow = (global_id.y * 4u);
const uint globalCol = (global_id.x * 4u);
const uint numTiles = (((uniforms[0].y - 1u) / 64u) + 1u);
float acc[16] = (float[16])0;
float ACached = 0.0f;
float BCached[4] = (float[4])0;
{
[loop] for(uint index = 0u; (index < (RowPerThread * ColPerThread)); index = (index + 1u)) {
[loop] for(uint index = 0u; (index < (4u * 4u)); index = (index + 1u)) {
acc[index] = 0.0f;
}
}
const uint ColPerThreadA = (TileInner / 16u);
const uint ColPerThreadA = (64u / 16u);
const uint tileColA = (local_id.x * ColPerThreadA);
const uint RowPerThreadB = (TileInner / 16u);
const uint RowPerThreadB = (64u / 16u);
const uint tileRowB = (local_id.y * RowPerThreadB);
{
[loop] for(uint t = 0u; (t < numTiles); t = (t + 1u)) {
{
[loop] for(uint innerRow = 0u; (innerRow < RowPerThread); innerRow = (innerRow + 1u)) {
[loop] for(uint innerRow = 0u; (innerRow < 4u); innerRow = (innerRow + 1u)) {
{
[loop] for(uint innerCol = 0u; (innerCol < ColPerThreadA); innerCol = (innerCol + 1u)) {
const uint inputRow = (tileRow + innerRow);
const uint inputCol = (tileColA + innerCol);
const float tint_symbol_2 = mm_readA((globalRow + innerRow), ((t * TileInner) + inputCol));
const float tint_symbol_2 = mm_readA((globalRow + innerRow), ((t * 64u) + inputCol));
mm_Asub[inputRow][inputCol] = tint_symbol_2;
}
}
@ -99,10 +93,10 @@ void main_inner(uint3 local_id, uint3 global_id, uint local_invocation_index) {
{
[loop] for(uint innerRow = 0u; (innerRow < RowPerThreadB); innerRow = (innerRow + 1u)) {
{
[loop] for(uint innerCol = 0u; (innerCol < ColPerThread); innerCol = (innerCol + 1u)) {
[loop] for(uint innerCol = 0u; (innerCol < 4u); innerCol = (innerCol + 1u)) {
const uint inputRow = (tileRowB + innerRow);
const uint inputCol = (tileCol + innerCol);
const float tint_symbol_3 = mm_readB(((t * TileInner) + inputRow), (globalCol + innerCol));
const float tint_symbol_3 = mm_readB(((t * 64u) + inputRow), (globalCol + innerCol));
mm_Bsub[innerCol][inputCol] = tint_symbol_3;
}
}
@ -110,18 +104,18 @@ void main_inner(uint3 local_id, uint3 global_id, uint local_invocation_index) {
}
GroupMemoryBarrierWithGroupSync();
{
[loop] for(uint k = 0u; (k < TileInner); k = (k + 1u)) {
[loop] for(uint k = 0u; (k < 64u); k = (k + 1u)) {
{
[loop] for(uint inner = 0u; (inner < ColPerThread); inner = (inner + 1u)) {
[loop] for(uint inner = 0u; (inner < 4u); inner = (inner + 1u)) {
BCached[inner] = mm_Bsub[k][(tileCol + inner)];
}
}
{
[loop] for(uint innerRow = 0u; (innerRow < RowPerThread); innerRow = (innerRow + 1u)) {
[loop] for(uint innerRow = 0u; (innerRow < 4u); innerRow = (innerRow + 1u)) {
ACached = mm_Asub[(tileRow + innerRow)][k];
{
[loop] for(uint innerCol = 0u; (innerCol < ColPerThread); innerCol = (innerCol + 1u)) {
const uint index = ((innerRow * ColPerThread) + innerCol);
[loop] for(uint innerCol = 0u; (innerCol < 4u); innerCol = (innerCol + 1u)) {
const uint index = ((innerRow * 4u) + innerCol);
acc[index] = (acc[index] + (ACached * BCached[innerCol]));
}
}
@ -133,10 +127,10 @@ void main_inner(uint3 local_id, uint3 global_id, uint local_invocation_index) {
}
}
{
[loop] for(uint innerRow = 0u; (innerRow < RowPerThread); innerRow = (innerRow + 1u)) {
[loop] for(uint innerRow = 0u; (innerRow < 4u); innerRow = (innerRow + 1u)) {
{
[loop] for(uint innerCol = 0u; (innerCol < ColPerThread); innerCol = (innerCol + 1u)) {
const uint index = ((innerRow * ColPerThread) + innerCol);
[loop] for(uint innerCol = 0u; (innerCol < 4u); innerCol = (innerCol + 1u)) {
const uint index = ((innerRow * 4u) + innerCol);
mm_write((globalRow + innerRow), (globalCol + innerCol), acc[index]);
}
}

View File

@ -47,16 +47,6 @@ void mm_write(uint row, uint col, float value, const constant Uniforms* const ti
}
}
constant uint RowPerThread = 4u;
constant uint ColPerThread = 4u;
constant uint TileAOuter = 64u;
constant uint TileBOuter = 64u;
constant uint TileInner = 64u;
void tint_symbol_inner(uint3 local_id, uint3 global_id, uint local_invocation_index, threadgroup tint_array<tint_array<float, 64>, 64>* const tint_symbol_9, threadgroup tint_array<tint_array<float, 64>, 64>* const tint_symbol_10, const constant Uniforms* const tint_symbol_11, const device Matrix* const tint_symbol_12, const device Matrix* const tint_symbol_13, device Matrix* const tint_symbol_14) {
for(uint idx = local_invocation_index; (idx < 4096u); idx = (idx + 256u)) {
uint const i = (idx / 64u);
@ -65,56 +55,56 @@ void tint_symbol_inner(uint3 local_id, uint3 global_id, uint local_invocation_in
(*(tint_symbol_10))[i][i_1] = 0.0f;
}
threadgroup_barrier(mem_flags::mem_threadgroup);
uint const tileRow = (local_id[1] * RowPerThread);
uint const tileCol = (local_id[0] * ColPerThread);
uint const globalRow = (global_id[1] * RowPerThread);
uint const globalCol = (global_id[0] * ColPerThread);
uint const numTiles = ((((*(tint_symbol_11)).dimInner - 1u) / TileInner) + 1u);
uint const tileRow = (local_id[1] * 4u);
uint const tileCol = (local_id[0] * 4u);
uint const globalRow = (global_id[1] * 4u);
uint const globalCol = (global_id[0] * 4u);
uint const numTiles = ((((*(tint_symbol_11)).dimInner - 1u) / 64u) + 1u);
tint_array<float, 16> acc = {};
float ACached = 0.0f;
tint_array<float, 4> BCached = {};
for(uint index = 0u; (index < (RowPerThread * ColPerThread)); index = (index + 1u)) {
for(uint index = 0u; (index < (4u * 4u)); index = (index + 1u)) {
acc[index] = 0.0f;
}
uint const ColPerThreadA = (TileInner / 16u);
uint const ColPerThreadA = (64u / 16u);
uint const tileColA = (local_id[0] * ColPerThreadA);
uint const RowPerThreadB = (TileInner / 16u);
uint const RowPerThreadB = (64u / 16u);
uint const tileRowB = (local_id[1] * RowPerThreadB);
for(uint t = 0u; (t < numTiles); t = (t + 1u)) {
for(uint innerRow = 0u; (innerRow < RowPerThread); innerRow = (innerRow + 1u)) {
for(uint innerRow = 0u; (innerRow < 4u); innerRow = (innerRow + 1u)) {
for(uint innerCol = 0u; (innerCol < ColPerThreadA); innerCol = (innerCol + 1u)) {
uint const inputRow = (tileRow + innerRow);
uint const inputCol = (tileColA + innerCol);
float const tint_symbol_1 = mm_readA((globalRow + innerRow), ((t * TileInner) + inputCol), tint_symbol_11, tint_symbol_12);
float const tint_symbol_1 = mm_readA((globalRow + innerRow), ((t * 64u) + inputCol), tint_symbol_11, tint_symbol_12);
(*(tint_symbol_9))[inputRow][inputCol] = tint_symbol_1;
}
}
for(uint innerRow = 0u; (innerRow < RowPerThreadB); innerRow = (innerRow + 1u)) {
for(uint innerCol = 0u; (innerCol < ColPerThread); innerCol = (innerCol + 1u)) {
for(uint innerCol = 0u; (innerCol < 4u); innerCol = (innerCol + 1u)) {
uint const inputRow = (tileRowB + innerRow);
uint const inputCol = (tileCol + innerCol);
float const tint_symbol_2 = mm_readB(((t * TileInner) + inputRow), (globalCol + innerCol), tint_symbol_11, tint_symbol_13);
float const tint_symbol_2 = mm_readB(((t * 64u) + inputRow), (globalCol + innerCol), tint_symbol_11, tint_symbol_13);
(*(tint_symbol_10))[innerCol][inputCol] = tint_symbol_2;
}
}
threadgroup_barrier(mem_flags::mem_threadgroup);
for(uint k = 0u; (k < TileInner); k = (k + 1u)) {
for(uint inner = 0u; (inner < ColPerThread); inner = (inner + 1u)) {
for(uint k = 0u; (k < 64u); k = (k + 1u)) {
for(uint inner = 0u; (inner < 4u); inner = (inner + 1u)) {
BCached[inner] = (*(tint_symbol_10))[k][(tileCol + inner)];
}
for(uint innerRow = 0u; (innerRow < RowPerThread); innerRow = (innerRow + 1u)) {
for(uint innerRow = 0u; (innerRow < 4u); innerRow = (innerRow + 1u)) {
ACached = (*(tint_symbol_9))[(tileRow + innerRow)][k];
for(uint innerCol = 0u; (innerCol < ColPerThread); innerCol = (innerCol + 1u)) {
uint const index = ((innerRow * ColPerThread) + innerCol);
for(uint innerCol = 0u; (innerCol < 4u); innerCol = (innerCol + 1u)) {
uint const index = ((innerRow * 4u) + innerCol);
acc[index] = (acc[index] + (ACached * BCached[innerCol]));
}
}
}
threadgroup_barrier(mem_flags::mem_threadgroup);
}
for(uint innerRow = 0u; (innerRow < RowPerThread); innerRow = (innerRow + 1u)) {
for(uint innerCol = 0u; (innerCol < ColPerThread); innerCol = (innerCol + 1u)) {
uint const index = ((innerRow * ColPerThread) + innerCol);
for(uint innerRow = 0u; (innerRow < 4u); innerRow = (innerRow + 1u)) {
for(uint innerCol = 0u; (innerCol < 4u); innerCol = (innerCol + 1u)) {
uint const index = ((innerRow * 4u) + innerCol);
mm_write((globalRow + innerRow), (globalCol + innerCol), acc[index], tint_symbol_11, tint_symbol_14);
}
}

View File

@ -20,11 +20,6 @@
OpMemberName %Uniforms 1 "dimInner"
OpMemberName %Uniforms 2 "dimBOuter"
OpName %uniforms "uniforms"
OpName %RowPerThread "RowPerThread"
OpName %RowPerThread "ColPerThread"
OpName %TileAOuter "TileAOuter"
OpName %TileAOuter "TileBOuter"
OpName %TileAOuter "TileInner"
OpName %mm_Asub "mm_Asub"
OpName %mm_Bsub "mm_Bsub"
OpName %mm_readA "mm_readA"
@ -80,10 +75,10 @@
OpDecorate %uniforms NonWritable
OpDecorate %uniforms DescriptorSet 0
OpDecorate %uniforms Binding 3
OpDecorate %_arr_float_TileAOuter ArrayStride 4
OpDecorate %_arr__arr_float_TileAOuter_TileAOuter ArrayStride 256
OpDecorate %_arr_float_uint_64 ArrayStride 4
OpDecorate %_arr__arr_float_uint_64_uint_64 ArrayStride 256
OpDecorate %_arr_float_uint_16 ArrayStride 4
OpDecorate %_arr_float_RowPerThread ArrayStride 4
OpDecorate %_arr_float_uint_4 ArrayStride 4
%uint = OpTypeInt 32 0
%v3uint = OpTypeVector %uint 3
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
@ -101,199 +96,199 @@
%Uniforms = OpTypeStruct %uint %uint %uint
%_ptr_Uniform_Uniforms = OpTypePointer Uniform %Uniforms
%uniforms = OpVariable %_ptr_Uniform_Uniforms Uniform
%RowPerThread = OpConstant %uint 4
%TileAOuter = OpConstant %uint 64
%_arr_float_TileAOuter = OpTypeArray %float %TileAOuter
%_arr__arr_float_TileAOuter_TileAOuter = OpTypeArray %_arr_float_TileAOuter %TileAOuter
%_ptr_Workgroup__arr__arr_float_TileAOuter_TileAOuter = OpTypePointer Workgroup %_arr__arr_float_TileAOuter_TileAOuter
%mm_Asub = OpVariable %_ptr_Workgroup__arr__arr_float_TileAOuter_TileAOuter Workgroup
%mm_Bsub = OpVariable %_ptr_Workgroup__arr__arr_float_TileAOuter_TileAOuter Workgroup
%25 = OpTypeFunction %float %uint %uint
%uint_64 = OpConstant %uint 64
%_arr_float_uint_64 = OpTypeArray %float %uint_64
%_arr__arr_float_uint_64_uint_64 = OpTypeArray %_arr_float_uint_64 %uint_64
%_ptr_Workgroup__arr__arr_float_uint_64_uint_64 = OpTypePointer Workgroup %_arr__arr_float_uint_64_uint_64
%mm_Asub = OpVariable %_ptr_Workgroup__arr__arr_float_uint_64_uint_64 Workgroup
%mm_Bsub = OpVariable %_ptr_Workgroup__arr__arr_float_uint_64_uint_64 Workgroup
%24 = OpTypeFunction %float %uint %uint
%uint_0 = OpConstant %uint 0
%_ptr_Uniform_uint = OpTypePointer Uniform %uint
%bool = OpTypeBool
%uint_1 = OpConstant %uint 1
%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float
%52 = OpConstantNull %float
%51 = OpConstantNull %float
%uint_2 = OpConstant %uint 2
%void = OpTypeVoid
%75 = OpTypeFunction %void %uint %uint %float
%98 = OpTypeFunction %void %v3uint %v3uint %uint
%74 = OpTypeFunction %void %uint %uint %float
%97 = OpTypeFunction %void %v3uint %v3uint %uint
%_ptr_Function_uint = OpTypePointer Function %uint
%106 = OpConstantNull %uint
%105 = OpConstantNull %uint
%uint_4096 = OpConstant %uint 4096
%_ptr_Workgroup_float = OpTypePointer Workgroup %float
%uint_256 = OpConstant %uint 256
%uint_264 = OpConstant %uint 264
%uint_4 = OpConstant %uint 4
%uint_16 = OpConstant %uint 16
%_arr_float_uint_16 = OpTypeArray %float %uint_16
%_ptr_Function__arr_float_uint_16 = OpTypePointer Function %_arr_float_uint_16
%146 = OpConstantNull %_arr_float_uint_16
%_ptr_Function_float = OpTypePointer Function %float
%_arr_float_RowPerThread = OpTypeArray %float %RowPerThread
%_ptr_Function__arr_float_RowPerThread = OpTypePointer Function %_arr_float_RowPerThread
%152 = OpConstantNull %_arr_float_RowPerThread
%_arr_float_uint_4 = OpTypeArray %float %uint_4
%_ptr_Function__arr_float_uint_4 = OpTypePointer Function %_arr_float_uint_4
%152 = OpConstantNull %_arr_float_uint_4
%367 = OpTypeFunction %void
%mm_readA = OpFunction %float None %25
%mm_readA = OpFunction %float None %24
%row = OpFunctionParameter %uint
%col = OpFunctionParameter %uint
%29 = OpLabel
%32 = OpAccessChain %_ptr_Uniform_uint %uniforms %uint_0
%33 = OpLoad %uint %32
%34 = OpULessThan %bool %row %33
OpSelectionMerge %36 None
OpBranchConditional %34 %37 %36
%37 = OpLabel
%39 = OpAccessChain %_ptr_Uniform_uint %uniforms %uint_1
%40 = OpLoad %uint %39
%41 = OpULessThan %bool %col %40
OpBranch %36
%28 = OpLabel
%31 = OpAccessChain %_ptr_Uniform_uint %uniforms %uint_0
%32 = OpLoad %uint %31
%33 = OpULessThan %bool %row %32
OpSelectionMerge %35 None
OpBranchConditional %33 %36 %35
%36 = OpLabel
%42 = OpPhi %bool %34 %29 %41 %37
OpSelectionMerge %43 None
OpBranchConditional %42 %44 %43
%44 = OpLabel
%45 = OpAccessChain %_ptr_Uniform_uint %uniforms %uint_1
%46 = OpLoad %uint %45
%47 = OpIMul %uint %row %46
%48 = OpIAdd %uint %47 %col
%50 = OpAccessChain %_ptr_StorageBuffer_float %firstMatrix %uint_0 %48
%51 = OpLoad %float %50
OpReturnValue %51
%38 = OpAccessChain %_ptr_Uniform_uint %uniforms %uint_1
%39 = OpLoad %uint %38
%40 = OpULessThan %bool %col %39
OpBranch %35
%35 = OpLabel
%41 = OpPhi %bool %33 %28 %40 %36
OpSelectionMerge %42 None
OpBranchConditional %41 %43 %42
%43 = OpLabel
OpReturnValue %52
%44 = OpAccessChain %_ptr_Uniform_uint %uniforms %uint_1
%45 = OpLoad %uint %44
%46 = OpIMul %uint %row %45
%47 = OpIAdd %uint %46 %col
%49 = OpAccessChain %_ptr_StorageBuffer_float %firstMatrix %uint_0 %47
%50 = OpLoad %float %49
OpReturnValue %50
%42 = OpLabel
OpReturnValue %51
OpFunctionEnd
%mm_readB = OpFunction %float None %25
%mm_readB = OpFunction %float None %24
%row_0 = OpFunctionParameter %uint
%col_0 = OpFunctionParameter %uint
%56 = OpLabel
%57 = OpAccessChain %_ptr_Uniform_uint %uniforms %uint_1
%58 = OpLoad %uint %57
%59 = OpULessThan %bool %row_0 %58
OpSelectionMerge %60 None
OpBranchConditional %59 %61 %60
%61 = OpLabel
%63 = OpAccessChain %_ptr_Uniform_uint %uniforms %uint_2
%64 = OpLoad %uint %63
%65 = OpULessThan %bool %col_0 %64
OpBranch %60
%55 = OpLabel
%56 = OpAccessChain %_ptr_Uniform_uint %uniforms %uint_1
%57 = OpLoad %uint %56
%58 = OpULessThan %bool %row_0 %57
OpSelectionMerge %59 None
OpBranchConditional %58 %60 %59
%60 = OpLabel
%66 = OpPhi %bool %59 %56 %65 %61
OpSelectionMerge %67 None
OpBranchConditional %66 %68 %67
%68 = OpLabel
%69 = OpAccessChain %_ptr_Uniform_uint %uniforms %uint_2
%70 = OpLoad %uint %69
%71 = OpIMul %uint %row_0 %70
%72 = OpIAdd %uint %71 %col_0
%73 = OpAccessChain %_ptr_StorageBuffer_float %secondMatrix %uint_0 %72
%74 = OpLoad %float %73
OpReturnValue %74
%62 = OpAccessChain %_ptr_Uniform_uint %uniforms %uint_2
%63 = OpLoad %uint %62
%64 = OpULessThan %bool %col_0 %63
OpBranch %59
%59 = OpLabel
%65 = OpPhi %bool %58 %55 %64 %60
OpSelectionMerge %66 None
OpBranchConditional %65 %67 %66
%67 = OpLabel
OpReturnValue %52
%68 = OpAccessChain %_ptr_Uniform_uint %uniforms %uint_2
%69 = OpLoad %uint %68
%70 = OpIMul %uint %row_0 %69
%71 = OpIAdd %uint %70 %col_0
%72 = OpAccessChain %_ptr_StorageBuffer_float %secondMatrix %uint_0 %71
%73 = OpLoad %float %72
OpReturnValue %73
%66 = OpLabel
OpReturnValue %51
OpFunctionEnd
%mm_write = OpFunction %void None %75
%mm_write = OpFunction %void None %74
%row_1 = OpFunctionParameter %uint
%col_1 = OpFunctionParameter %uint
%value = OpFunctionParameter %float
%81 = OpLabel
%82 = OpAccessChain %_ptr_Uniform_uint %uniforms %uint_0
%83 = OpLoad %uint %82
%84 = OpULessThan %bool %row_1 %83
OpSelectionMerge %85 None
OpBranchConditional %84 %86 %85
%86 = OpLabel
%87 = OpAccessChain %_ptr_Uniform_uint %uniforms %uint_2
%88 = OpLoad %uint %87
%89 = OpULessThan %bool %col_1 %88
OpBranch %85
%80 = OpLabel
%81 = OpAccessChain %_ptr_Uniform_uint %uniforms %uint_0
%82 = OpLoad %uint %81
%83 = OpULessThan %bool %row_1 %82
OpSelectionMerge %84 None
OpBranchConditional %83 %85 %84
%85 = OpLabel
%90 = OpPhi %bool %84 %81 %89 %86
OpSelectionMerge %91 None
OpBranchConditional %90 %92 %91
%92 = OpLabel
%93 = OpAccessChain %_ptr_Uniform_uint %uniforms %uint_2
%94 = OpLoad %uint %93
%95 = OpIMul %uint %row_1 %94
%96 = OpIAdd %uint %col_1 %95
%97 = OpAccessChain %_ptr_StorageBuffer_float %resultMatrix %uint_0 %96
OpStore %97 %value
OpBranch %91
%86 = OpAccessChain %_ptr_Uniform_uint %uniforms %uint_2
%87 = OpLoad %uint %86
%88 = OpULessThan %bool %col_1 %87
OpBranch %84
%84 = OpLabel
%89 = OpPhi %bool %83 %80 %88 %85
OpSelectionMerge %90 None
OpBranchConditional %89 %91 %90
%91 = OpLabel
%92 = OpAccessChain %_ptr_Uniform_uint %uniforms %uint_2
%93 = OpLoad %uint %92
%94 = OpIMul %uint %row_1 %93
%95 = OpIAdd %uint %col_1 %94
%96 = OpAccessChain %_ptr_StorageBuffer_float %resultMatrix %uint_0 %95
OpStore %96 %value
OpBranch %90
%90 = OpLabel
OpReturn
OpFunctionEnd
%main_inner = OpFunction %void None %98
%main_inner = OpFunction %void None %97
%local_id = OpFunctionParameter %v3uint
%global_id = OpFunctionParameter %v3uint
%local_invocation_index = OpFunctionParameter %uint
%103 = OpLabel
%idx = OpVariable %_ptr_Function_uint Function %106
%102 = OpLabel
%idx = OpVariable %_ptr_Function_uint Function %105
%acc = OpVariable %_ptr_Function__arr_float_uint_16 Function %146
%ACached = OpVariable %_ptr_Function_float Function %52
%BCached = OpVariable %_ptr_Function__arr_float_RowPerThread Function %152
%index = OpVariable %_ptr_Function_uint Function %106
%t = OpVariable %_ptr_Function_uint Function %106
%innerRow = OpVariable %_ptr_Function_uint Function %106
%innerCol = OpVariable %_ptr_Function_uint Function %106
%innerRow_0 = OpVariable %_ptr_Function_uint Function %106
%innerCol_0 = OpVariable %_ptr_Function_uint Function %106
%k = OpVariable %_ptr_Function_uint Function %106
%inner = OpVariable %_ptr_Function_uint Function %106
%innerRow_1 = OpVariable %_ptr_Function_uint Function %106
%innerCol_1 = OpVariable %_ptr_Function_uint Function %106
%innerRow_2 = OpVariable %_ptr_Function_uint Function %106
%innerCol_2 = OpVariable %_ptr_Function_uint Function %106
%ACached = OpVariable %_ptr_Function_float Function %51
%BCached = OpVariable %_ptr_Function__arr_float_uint_4 Function %152
%index = OpVariable %_ptr_Function_uint Function %105
%t = OpVariable %_ptr_Function_uint Function %105
%innerRow = OpVariable %_ptr_Function_uint Function %105
%innerCol = OpVariable %_ptr_Function_uint Function %105
%innerRow_0 = OpVariable %_ptr_Function_uint Function %105
%innerCol_0 = OpVariable %_ptr_Function_uint Function %105
%k = OpVariable %_ptr_Function_uint Function %105
%inner = OpVariable %_ptr_Function_uint Function %105
%innerRow_1 = OpVariable %_ptr_Function_uint Function %105
%innerCol_1 = OpVariable %_ptr_Function_uint Function %105
%innerRow_2 = OpVariable %_ptr_Function_uint Function %105
%innerCol_2 = OpVariable %_ptr_Function_uint Function %105
OpStore %idx %local_invocation_index
OpBranch %107
%107 = OpLabel
OpLoopMerge %108 %109 None
OpBranch %110
%110 = OpLabel
%112 = OpLoad %uint %idx
%114 = OpULessThan %bool %112 %uint_4096
%111 = OpLogicalNot %bool %114
OpSelectionMerge %115 None
OpBranchConditional %111 %116 %115
%116 = OpLabel
OpBranch %108
%115 = OpLabel
%117 = OpLoad %uint %idx
%118 = OpUDiv %uint %117 %TileAOuter
%119 = OpLoad %uint %idx
%120 = OpUMod %uint %119 %TileAOuter
%122 = OpAccessChain %_ptr_Workgroup_float %mm_Asub %118 %120
OpStore %122 %52
%123 = OpAccessChain %_ptr_Workgroup_float %mm_Bsub %118 %120
OpStore %123 %52
OpBranch %106
%106 = OpLabel
OpLoopMerge %107 %108 None
OpBranch %109
%109 = OpLabel
%124 = OpLoad %uint %idx
%126 = OpIAdd %uint %124 %uint_256
OpStore %idx %126
%111 = OpLoad %uint %idx
%113 = OpULessThan %bool %111 %uint_4096
%110 = OpLogicalNot %bool %113
OpSelectionMerge %114 None
OpBranchConditional %110 %115 %114
%115 = OpLabel
OpBranch %107
%114 = OpLabel
%116 = OpLoad %uint %idx
%117 = OpUDiv %uint %116 %uint_64
%118 = OpLoad %uint %idx
%119 = OpUMod %uint %118 %uint_64
%121 = OpAccessChain %_ptr_Workgroup_float %mm_Asub %117 %119
OpStore %121 %51
%122 = OpAccessChain %_ptr_Workgroup_float %mm_Bsub %117 %119
OpStore %122 %51
OpBranch %108
%108 = OpLabel
%123 = OpLoad %uint %idx
%125 = OpIAdd %uint %123 %uint_256
OpStore %idx %125
OpBranch %106
%107 = OpLabel
OpControlBarrier %uint_2 %uint_2 %uint_264
%129 = OpCompositeExtract %uint %local_id 1
%130 = OpIMul %uint %129 %RowPerThread
%128 = OpCompositeExtract %uint %local_id 1
%130 = OpIMul %uint %128 %uint_4
%131 = OpCompositeExtract %uint %local_id 0
%132 = OpIMul %uint %131 %RowPerThread
%132 = OpIMul %uint %131 %uint_4
%133 = OpCompositeExtract %uint %global_id 1
%134 = OpIMul %uint %133 %RowPerThread
%134 = OpIMul %uint %133 %uint_4
%135 = OpCompositeExtract %uint %global_id 0
%136 = OpIMul %uint %135 %RowPerThread
%136 = OpIMul %uint %135 %uint_4
%137 = OpAccessChain %_ptr_Uniform_uint %uniforms %uint_1
%138 = OpLoad %uint %137
%139 = OpISub %uint %138 %uint_1
%140 = OpUDiv %uint %139 %TileAOuter
%140 = OpUDiv %uint %139 %uint_64
%141 = OpIAdd %uint %140 %uint_1
OpStore %index %106
OpStore %index %105
OpBranch %154
%154 = OpLabel
OpLoopMerge %155 %156 None
OpBranch %157
%157 = OpLabel
%159 = OpLoad %uint %index
%160 = OpIMul %uint %RowPerThread %RowPerThread
%160 = OpIMul %uint %uint_4 %uint_4
%161 = OpULessThan %bool %159 %160
%158 = OpLogicalNot %bool %161
OpSelectionMerge %162 None
@ -303,7 +298,7 @@
%162 = OpLabel
%164 = OpLoad %uint %index
%165 = OpAccessChain %_ptr_Function_float %acc %164
OpStore %165 %52
OpStore %165 %51
OpBranch %156
%156 = OpLabel
%166 = OpLoad %uint %index
@ -311,13 +306,13 @@
OpStore %index %167
OpBranch %154
%155 = OpLabel
%168 = OpUDiv %uint %TileAOuter %uint_16
%168 = OpUDiv %uint %uint_64 %uint_16
%169 = OpCompositeExtract %uint %local_id 0
%170 = OpIMul %uint %169 %168
%171 = OpUDiv %uint %TileAOuter %uint_16
%171 = OpUDiv %uint %uint_64 %uint_16
%172 = OpCompositeExtract %uint %local_id 1
%173 = OpIMul %uint %172 %171
OpStore %t %106
OpStore %t %105
OpBranch %175
%175 = OpLabel
OpLoopMerge %176 %177 None
@ -331,21 +326,21 @@
%183 = OpLabel
OpBranch %176
%182 = OpLabel
OpStore %innerRow %106
OpStore %innerRow %105
OpBranch %185
%185 = OpLabel
OpLoopMerge %186 %187 None
OpBranch %188
%188 = OpLabel
%190 = OpLoad %uint %innerRow
%191 = OpULessThan %bool %190 %RowPerThread
%191 = OpULessThan %bool %190 %uint_4
%189 = OpLogicalNot %bool %191
OpSelectionMerge %192 None
OpBranchConditional %189 %193 %192
%193 = OpLabel
OpBranch %186
%192 = OpLabel
OpStore %innerCol %106
OpStore %innerCol %105
OpBranch %195
%195 = OpLabel
OpLoopMerge %196 %197 None
@ -366,7 +361,7 @@
%209 = OpLoad %uint %innerRow
%210 = OpIAdd %uint %134 %209
%211 = OpLoad %uint %t
%212 = OpIMul %uint %211 %TileAOuter
%212 = OpIMul %uint %211 %uint_64
%213 = OpIAdd %uint %212 %207
%208 = OpFunctionCall %float %mm_readA %210 %213
%214 = OpAccessChain %_ptr_Workgroup_float %mm_Asub %205 %207
@ -385,7 +380,7 @@
OpStore %innerRow %218
OpBranch %185
%186 = OpLabel
OpStore %innerRow_0 %106
OpStore %innerRow_0 %105
OpBranch %220
%220 = OpLabel
OpLoopMerge %221 %222 None
@ -399,14 +394,14 @@
%228 = OpLabel
OpBranch %221
%227 = OpLabel
OpStore %innerCol_0 %106
OpStore %innerCol_0 %105
OpBranch %230
%230 = OpLabel
OpLoopMerge %231 %232 None
OpBranch %233
%233 = OpLabel
%235 = OpLoad %uint %innerCol_0
%236 = OpULessThan %bool %235 %RowPerThread
%236 = OpULessThan %bool %235 %uint_4
%234 = OpLogicalNot %bool %236
OpSelectionMerge %237 None
OpBranchConditional %234 %238 %237
@ -418,7 +413,7 @@
%241 = OpLoad %uint %innerCol_0
%242 = OpIAdd %uint %132 %241
%244 = OpLoad %uint %t
%245 = OpIMul %uint %244 %TileAOuter
%245 = OpIMul %uint %244 %uint_64
%246 = OpIAdd %uint %245 %240
%247 = OpLoad %uint %innerCol_0
%248 = OpIAdd %uint %136 %247
@ -441,28 +436,28 @@
OpBranch %220
%221 = OpLabel
OpControlBarrier %uint_2 %uint_2 %uint_264
OpStore %k %106
OpStore %k %105
OpBranch %257
%257 = OpLabel
OpLoopMerge %258 %259 None
OpBranch %260
%260 = OpLabel
%262 = OpLoad %uint %k
%263 = OpULessThan %bool %262 %TileAOuter
%263 = OpULessThan %bool %262 %uint_64
%261 = OpLogicalNot %bool %263
OpSelectionMerge %264 None
OpBranchConditional %261 %265 %264
%265 = OpLabel
OpBranch %258
%264 = OpLabel
OpStore %inner %106
OpStore %inner %105
OpBranch %267
%267 = OpLabel
OpLoopMerge %268 %269 None
OpBranch %270
%270 = OpLabel
%272 = OpLoad %uint %inner
%273 = OpULessThan %bool %272 %RowPerThread
%273 = OpULessThan %bool %272 %uint_4
%271 = OpLogicalNot %bool %273
OpSelectionMerge %274 None
OpBranchConditional %271 %275 %274
@ -484,14 +479,14 @@
OpStore %inner %284
OpBranch %267
%268 = OpLabel
OpStore %innerRow_1 %106
OpStore %innerRow_1 %105
OpBranch %286
%286 = OpLabel
OpLoopMerge %287 %288 None
OpBranch %289
%289 = OpLabel
%291 = OpLoad %uint %innerRow_1
%292 = OpULessThan %bool %291 %RowPerThread
%292 = OpULessThan %bool %291 %uint_4
%290 = OpLogicalNot %bool %292
OpSelectionMerge %293 None
OpBranchConditional %290 %294 %293
@ -504,14 +499,14 @@
%298 = OpAccessChain %_ptr_Workgroup_float %mm_Asub %296 %297
%299 = OpLoad %float %298
OpStore %ACached %299
OpStore %innerCol_1 %106
OpStore %innerCol_1 %105
OpBranch %301
%301 = OpLabel
OpLoopMerge %302 %303 None
OpBranch %304
%304 = OpLabel
%306 = OpLoad %uint %innerCol_1
%307 = OpULessThan %bool %306 %RowPerThread
%307 = OpULessThan %bool %306 %uint_4
%305 = OpLogicalNot %bool %307
OpSelectionMerge %308 None
OpBranchConditional %305 %309 %308
@ -519,7 +514,7 @@
OpBranch %302
%308 = OpLabel
%310 = OpLoad %uint %innerRow_1
%311 = OpIMul %uint %310 %RowPerThread
%311 = OpIMul %uint %310 %uint_4
%312 = OpLoad %uint %innerCol_1
%313 = OpIAdd %uint %311 %312
%314 = OpAccessChain %_ptr_Function_float %acc %313
@ -561,28 +556,28 @@
OpStore %t %331
OpBranch %175
%176 = OpLabel
OpStore %innerRow_2 %106
OpStore %innerRow_2 %105
OpBranch %333
%333 = OpLabel
OpLoopMerge %334 %335 None
OpBranch %336
%336 = OpLabel
%338 = OpLoad %uint %innerRow_2
%339 = OpULessThan %bool %338 %RowPerThread
%339 = OpULessThan %bool %338 %uint_4
%337 = OpLogicalNot %bool %339
OpSelectionMerge %340 None
OpBranchConditional %337 %341 %340
%341 = OpLabel
OpBranch %334
%340 = OpLabel
OpStore %innerCol_2 %106
OpStore %innerCol_2 %105
OpBranch %343
%343 = OpLabel
OpLoopMerge %344 %345 None
OpBranch %346
%346 = OpLabel
%348 = OpLoad %uint %innerCol_2
%349 = OpULessThan %bool %348 %RowPerThread
%349 = OpULessThan %bool %348 %uint_4
%347 = OpLogicalNot %bool %349
OpSelectionMerge %350 None
OpBranchConditional %347 %351 %350
@ -590,7 +585,7 @@
OpBranch %344
%350 = OpLabel
%352 = OpLoad %uint %innerRow_2
%353 = OpIMul %uint %352 %RowPerThread
%353 = OpIMul %uint %352 %uint_4
%354 = OpLoad %uint %innerCol_2
%355 = OpIAdd %uint %353 %354
%357 = OpLoad %uint %innerRow_2

View File

@ -39,15 +39,15 @@ fn mm_write(row : u32, col : u32, value : f32) {
}
}
let RowPerThread : u32 = 4u;
const RowPerThread : u32 = 4u;
let ColPerThread : u32 = 4u;
const ColPerThread : u32 = 4u;
let TileAOuter : u32 = 64u;
const TileAOuter : u32 = 64u;
let TileBOuter : u32 = 64u;
const TileBOuter : u32 = 64u;
let TileInner : u32 = 64u;
const TileInner : u32 = 64u;
var<workgroup> mm_Asub : array<array<f32, 64>, 64>;

View File

@ -0,0 +1,27 @@
type MyArray = array<f32, 10>;
// Global consts
const c1 = 1;
const c2 = 1u;
const c3 = 1.0;
const c4 = vec3<i32>(1, 1, 1);
const c5 = vec3<u32>(1u, 1u, 1u);
const c6 = vec3<f32>(1.0, 1.0, 1.0);
const c7 = mat3x3<f32>(vec3<f32>(1.0, 1.0, 1.0), vec3<f32>(1.0, 1.0, 1.0), vec3<f32>(1.0, 1.0, 1.0));
const c9 = MyArray();
@fragment
fn main() -> @location(0) vec4<f32> {
var v1 = c1;
var v2 = c2;
var v3 = c3;
var v4 = c4;
var v5 = c5;
var v6 = c6;
var v7 = c7;
var v9 = c9;
return vec4<f32>(0.0,0.0,0.0,0.0);
}

View File

@ -0,0 +1,21 @@
#version 310 es
precision mediump float;
layout(location = 0) out vec4 value;
vec4 tint_symbol() {
int v1 = 1;
uint v2 = 1u;
float v3 = 1.0f;
ivec3 v4 = ivec3(1);
uvec3 v5 = uvec3(1u);
vec3 v6 = vec3(1.0f);
mat3 v7 = mat3(vec3(1.0f), vec3(1.0f), vec3(1.0f));
float v9[10] = float[10](0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
return vec4(0.0f);
}
void main() {
vec4 inner_result = tint_symbol();
value = inner_result;
return;
}

View File

@ -0,0 +1,22 @@
struct tint_symbol {
float4 value : SV_Target0;
};
float4 main_inner() {
int v1 = 1;
uint v2 = 1u;
float v3 = 1.0f;
int3 v4 = (1).xxx;
uint3 v5 = (1u).xxx;
float3 v6 = (1.0f).xxx;
float3x3 v7 = float3x3((1.0f).xxx, (1.0f).xxx, (1.0f).xxx);
float v9[10] = (float[10])0;
return (0.0f).xxxx;
}
tint_symbol main() {
const float4 inner_result = main_inner();
tint_symbol wrapper_result = (tint_symbol)0;
wrapper_result.value = inner_result;
return wrapper_result;
}

View File

@ -14,33 +14,19 @@ struct tint_array {
T elements[N];
};
struct MyStruct {
float f1;
};
constant int v1 = 1;
constant uint v2 = 1u;
constant float v3 = 1.0f;
constant int3 v4 = int3(1);
constant uint3 v5 = uint3(1u);
constant float3 v6 = float3(1.0f);
constant float3x3 v7 = float3x3(float3(1.0f), float3(1.0f), float3(1.0f));
constant MyStruct v8 = {};
constant tint_array<float, 10> v9 = tint_array<float, 10>{};
struct tint_symbol_1 {
float4 value [[color(0)]];
};
float4 tint_symbol_inner() {
int v1 = 1;
uint v2 = 1u;
float v3 = 1.0f;
int3 v4 = int3(1);
uint3 v5 = uint3(1u);
float3 v6 = float3(1.0f);
float3x3 v7 = float3x3(float3(1.0f), float3(1.0f), float3(1.0f));
tint_array<float, 10> v9 = tint_array<float, 10>{};
return float4(0.0f);
}

View File

@ -0,0 +1,87 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 53
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %value
OpExecutionMode %main OriginUpperLeft
OpName %value "value"
OpName %main_inner "main_inner"
OpName %v1 "v1"
OpName %v2 "v2"
OpName %v3 "v3"
OpName %v4 "v4"
OpName %v5 "v5"
OpName %v6 "v6"
OpName %v7 "v7"
OpName %v9 "v9"
OpName %main "main"
OpDecorate %value Location 0
OpDecorate %_arr_float_uint_10 ArrayStride 4
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%5 = OpConstantNull %v4float
%value = OpVariable %_ptr_Output_v4float Output %5
%6 = OpTypeFunction %v4float
%int = OpTypeInt 32 1
%int_1 = OpConstant %int 1
%_ptr_Function_int = OpTypePointer Function %int
%13 = OpConstantNull %int
%uint = OpTypeInt 32 0
%uint_1 = OpConstant %uint 1
%_ptr_Function_uint = OpTypePointer Function %uint
%18 = OpConstantNull %uint
%float_1 = OpConstant %float 1
%_ptr_Function_float = OpTypePointer Function %float
%22 = OpConstantNull %float
%v3int = OpTypeVector %int 3
%24 = OpConstantComposite %v3int %int_1 %int_1 %int_1
%_ptr_Function_v3int = OpTypePointer Function %v3int
%27 = OpConstantNull %v3int
%v3uint = OpTypeVector %uint 3
%29 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1
%_ptr_Function_v3uint = OpTypePointer Function %v3uint
%32 = OpConstantNull %v3uint
%v3float = OpTypeVector %float 3
%34 = OpConstantComposite %v3float %float_1 %float_1 %float_1
%_ptr_Function_v3float = OpTypePointer Function %v3float
%37 = OpConstantNull %v3float
%mat3v3float = OpTypeMatrix %v3float 3
%39 = OpConstantComposite %mat3v3float %34 %34 %34
%_ptr_Function_mat3v3float = OpTypePointer Function %mat3v3float
%42 = OpConstantNull %mat3v3float
%uint_10 = OpConstant %uint 10
%_arr_float_uint_10 = OpTypeArray %float %uint_10
%45 = OpConstantNull %_arr_float_uint_10
%_ptr_Function__arr_float_uint_10 = OpTypePointer Function %_arr_float_uint_10
%void = OpTypeVoid
%48 = OpTypeFunction %void
%main_inner = OpFunction %v4float None %6
%8 = OpLabel
%v1 = OpVariable %_ptr_Function_int Function %13
%v2 = OpVariable %_ptr_Function_uint Function %18
%v3 = OpVariable %_ptr_Function_float Function %22
%v4 = OpVariable %_ptr_Function_v3int Function %27
%v5 = OpVariable %_ptr_Function_v3uint Function %32
%v6 = OpVariable %_ptr_Function_v3float Function %37
%v7 = OpVariable %_ptr_Function_mat3v3float Function %42
%v9 = OpVariable %_ptr_Function__arr_float_uint_10 Function %45
OpStore %v1 %int_1
OpStore %v2 %uint_1
OpStore %v3 %float_1
OpStore %v4 %24
OpStore %v5 %29
OpStore %v6 %34
OpStore %v7 %39
OpStore %v9 %45
OpReturnValue %5
OpFunctionEnd
%main = OpFunction %void None %48
%51 = OpLabel
%52 = OpFunctionCall %v4float %main_inner
OpStore %value %52
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,30 @@
type MyArray = array<f32, 10>;
const c1 = 1;
const c2 = 1u;
const c3 = 1.0;
const c4 = vec3<i32>(1, 1, 1);
const c5 = vec3<u32>(1u, 1u, 1u);
const c6 = vec3<f32>(1.0, 1.0, 1.0);
const c7 = mat3x3<f32>(vec3<f32>(1.0, 1.0, 1.0), vec3<f32>(1.0, 1.0, 1.0), vec3<f32>(1.0, 1.0, 1.0));
const c9 = MyArray();
@fragment
fn main() -> @location(0) vec4<f32> {
var v1 = c1;
var v2 = c2;
var v3 = c3;
var v4 = c4;
var v5 = c5;
var v6 = c6;
var v7 = c7;
var v9 = c9;
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
}

View File

@ -0,0 +1,21 @@
type MyArray = array<f32, 10>;
// Function-scope consts
fn const_decls() {
const v1 = 1;
const v2 = 1u;
const v3 = 1.0;
const v4 = vec3<i32>(1, 1, 1);
const v5 = vec3<u32>(1u, 1u, 1u);
const v6 = vec3<f32>(1.0, 1.0, 1.0);
const v7 = mat3x3<f32>(v6, v6, v6);
const v8 = MyArray();
}
@fragment
fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0,0.0,0.0,0.0);
}

View File

@ -2,10 +2,6 @@
precision mediump float;
layout(location = 0) out vec4 value;
struct MyStruct {
float f1;
};
vec4 tint_symbol() {
return vec4(0.0f);
}

View File

@ -0,0 +1,17 @@
void const_decls() {
}
struct tint_symbol {
float4 value : SV_Target0;
};
float4 main_inner() {
return (0.0f).xxxx;
}
tint_symbol main() {
const float4 inner_result = main_inner();
tint_symbol wrapper_result = (tint_symbol)0;
wrapper_result.value = inner_result;
return wrapper_result;
}

View File

@ -0,0 +1,21 @@
#include <metal_stdlib>
using namespace metal;
void const_decls() {
}
struct tint_symbol_1 {
float4 value [[color(0)]];
};
float4 tint_symbol_inner() {
return float4(0.0f);
}
fragment tint_symbol_1 tint_symbol() {
float4 const inner_result = tint_symbol_inner();
tint_symbol_1 wrapper_result = {};
wrapper_result.value = inner_result;
return wrapper_result;
}

Some files were not shown because too many files have changed in this diff Show More