Remove push constants.

Push constants won't be supported by WebGPU. This CL removes them from
Tint.

For the SPIR-V reader case, this means the push constant will cause a
unknown storage class error.

Bug: tint:19
Change-Id: I10b09ce589b6b370fc828af0cd56e6213c5bc694
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21180
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
dan sinclair 2020-05-06 21:48:23 +00:00
parent 506fe795b6
commit a4e6858b94
14 changed files with 0 additions and 44 deletions

View File

@ -51,10 +51,6 @@ std::ostream& operator<<(std::ostream& out, StorageClass sc) {
out << "image";
break;
}
case StorageClass::kPushConstant: {
out << "push_constant";
break;
}
case StorageClass::kPrivate: {
out << "private";
break;

View File

@ -30,7 +30,6 @@ enum class StorageClass {
kUniformConstant,
kStorageBuffer,
kImage,
kPushConstant,
kPrivate,
kFunction
};

View File

@ -54,8 +54,6 @@ ast::StorageClass EnumConverter::ToStorageClass(SpvStorageClass sc) {
return ast::StorageClass::kStorageBuffer;
case SpvStorageClassImage:
return ast::StorageClass::kImage;
case SpvStorageClassPushConstant:
return ast::StorageClass::kPushConstant;
case SpvStorageClassPrivate:
return ast::StorageClass::kPrivate;
case SpvStorageClassFunction:

View File

@ -150,8 +150,6 @@ INSTANTIATE_TEST_SUITE_P(
StorageClassCase{SpvStorageClassStorageBuffer, true,
ast::StorageClass::kStorageBuffer},
StorageClassCase{SpvStorageClassImage, true, ast::StorageClass::kImage},
StorageClassCase{SpvStorageClassPushConstant, true,
ast::StorageClass::kPushConstant},
StorageClassCase{SpvStorageClassPrivate, true,
ast::StorageClass::kPrivate},
StorageClassCase{SpvStorageClassFunction, true,

View File

@ -628,22 +628,6 @@ TEST_F(SpvParserTest, ConvertType_PointerImage) {
EXPECT_TRUE(p->error().empty());
}
TEST_F(SpvParserTest, ConvertType_PointerPushConstant) {
auto* p = parser(test::Assemble(R"(
%float = OpTypeFloat 32
%3 = OpTypePointer PushConstant %float
)"));
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
EXPECT_TRUE(type->IsPointer());
auto* ptr_ty = type->AsPointer();
EXPECT_NE(ptr_ty, nullptr);
EXPECT_TRUE(ptr_ty->type()->IsF32());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kPushConstant);
EXPECT_TRUE(p->error().empty());
}
TEST_F(SpvParserTest, ConvertType_PointerPrivate) {
auto* p = parser(test::Assemble(R"(
%float = OpTypeFloat 32

View File

@ -602,8 +602,6 @@ Token Lexer::check_keyword(const Source& source, const std::string& str) {
return {Token::Type::kPrivate, source, "private"};
if (str == "ptr")
return {Token::Type::kPtr, source, "ptr"};
if (str == "push_constant")
return {Token::Type::kPushConstant, source, "push_constant"};
if (str == "return")
return {Token::Type::kReturn, source, "return"};
if (str == "set")

View File

@ -476,7 +476,6 @@ INSTANTIATE_TEST_SUITE_P(
TokenData{"position", Token::Type::kPosition},
TokenData{"private", Token::Type::kPrivate},
TokenData{"ptr", Token::Type::kPtr},
TokenData{"push_constant", Token::Type::kPushConstant},
TokenData{"return", Token::Type::kReturn},
TokenData{"set", Token::Type::kSet},
TokenData{"storage_buffer", Token::Type::kStorageBuffer},

View File

@ -927,7 +927,6 @@ ast::type::Type* ParserImpl::type_decl_matrix(Token t) {
// | UNIFORM_CONSTANT
// | STORAGE_BUFFER
// | IMAGE
// | PUSH_CONSTANT
// | PRIVATE
// | FUNCTION
ast::StorageClass ParserImpl::storage_class() {
@ -960,10 +959,6 @@ ast::StorageClass ParserImpl::storage_class() {
next(); // consume the peek
return ast::StorageClass::kImage;
}
if (t.IsPushConstant()) {
next(); // consume the peek
return ast::StorageClass::kPushConstant;
}
if (t.IsPrivate()) {
next(); // consume the peek
return ast::StorageClass::kPrivate;

View File

@ -73,7 +73,6 @@ INSTANTIATE_TEST_SUITE_P(
ast::StorageClass::kUniformConstant},
StorageClassData{"storage_buffer", ast::StorageClass::kStorageBuffer},
StorageClassData{"image", ast::StorageClass::kImage},
StorageClassData{"push_constant", ast::StorageClass::kPushConstant},
StorageClassData{"private", ast::StorageClass::kPrivate},
StorageClassData{"function", ast::StorageClass::kFunction}));

View File

@ -74,7 +74,6 @@ INSTANTIATE_TEST_SUITE_P(
VariableStorageData{"storage_buffer",
ast::StorageClass::kStorageBuffer},
VariableStorageData{"image", ast::StorageClass::kImage},
VariableStorageData{"push_constant", ast::StorageClass::kPushConstant},
VariableStorageData{"private", ast::StorageClass::kPrivate},
VariableStorageData{"function", ast::StorageClass::kFunction}));

View File

@ -241,8 +241,6 @@ std::string Token::TypeToName(Type type) {
return "private";
case Token::Type::kPtr:
return "ptr";
case Token::Type::kPushConstant:
return "push_constant";
case Token::Type::kRegardless:
return "regardless";
case Token::Type::kReturn:

View File

@ -252,8 +252,6 @@ class Token {
kPrivate,
/// A 'ptr'
kPtr,
/// A 'push_constant'
kPushConstant,
/// A 'regardless'
kRegardless,
/// A 'return'
@ -565,8 +563,6 @@ class Token {
bool IsPrivate() const { return type_ == Type::kPrivate; }
/// @returns true if token is a 'ptr'
bool IsPtr() const { return type_ == Type::kPtr; }
/// @returns true if token is a 'push_constant'
bool IsPushConstant() const { return type_ == Type::kPushConstant; }
/// @returns true if token is a 'return'
bool IsReturn() const { return type_ == Type::kReturn; }
/// @returns true if token is a 'set'

View File

@ -1611,8 +1611,6 @@ SpvStorageClass Builder::ConvertStorageClass(ast::StorageClass klass) const {
return SpvStorageClassStorageBuffer;
case ast::StorageClass::kImage:
return SpvStorageClassImage;
case ast::StorageClass::kPushConstant:
return SpvStorageClassPushConstant;
case ast::StorageClass::kPrivate:
return SpvStorageClassPrivate;
case ast::StorageClass::kFunction:

View File

@ -498,7 +498,6 @@ INSTANTIATE_TEST_SUITE_P(
PtrData{ast::StorageClass::kStorageBuffer,
SpvStorageClassStorageBuffer},
PtrData{ast::StorageClass::kImage, SpvStorageClassImage},
PtrData{ast::StorageClass::kPushConstant, SpvStorageClassPushConstant},
PtrData{ast::StorageClass::kPrivate, SpvStorageClassPrivate},
PtrData{ast::StorageClass::kFunction, SpvStorageClassFunction}));