mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 10:49:14 +00:00
[ast] Unify the access control types.
This CL merges the StorageAccess enum with the AccessControl enum. The enum is moved up to src/ast and placed in its own file for clarity. Change-Id: I95a905a399b5d2e046ea1ea429b35f2064510c2d Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31242 Commit-Queue: David Neto <dneto@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
4dd5665502
commit
c55fc39acb
@@ -653,8 +653,8 @@ ast::type::Type* ParserImpl::texture_sampler_types() {
|
||||
}
|
||||
|
||||
ast::type::TextureDimension storage_dim;
|
||||
ast::type::StorageAccess storage_access;
|
||||
std::tie(storage_dim, storage_access) = storage_texture_type();
|
||||
ast::AccessControl access;
|
||||
std::tie(storage_dim, access) = storage_texture_type();
|
||||
if (storage_dim != ast::type::TextureDimension::kNone) {
|
||||
auto t = next();
|
||||
if (!t.IsLessThan()) {
|
||||
@@ -677,7 +677,7 @@ ast::type::Type* ParserImpl::texture_sampler_types() {
|
||||
}
|
||||
|
||||
return ctx_.type_mgr().Get(std::make_unique<ast::type::StorageTextureType>(
|
||||
storage_dim, storage_access, format));
|
||||
storage_dim, access, format));
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@@ -764,54 +764,54 @@ ast::type::TextureDimension ParserImpl::multisampled_texture_type() {
|
||||
// | TEXTURE_WO_2D
|
||||
// | TEXTURE_WO_2D_ARRAY
|
||||
// | TEXTURE_WO_3D
|
||||
std::pair<ast::type::TextureDimension, ast::type::StorageAccess>
|
||||
std::pair<ast::type::TextureDimension, ast::AccessControl>
|
||||
ParserImpl::storage_texture_type() {
|
||||
auto t = peek();
|
||||
if (t.IsTextureStorageReadonly1d()) {
|
||||
next(); // Consume the peek
|
||||
return {ast::type::TextureDimension::k1d, ast::type::StorageAccess::kRead};
|
||||
return {ast::type::TextureDimension::k1d, ast::AccessControl::kReadOnly};
|
||||
}
|
||||
if (t.IsTextureStorageReadonly1dArray()) {
|
||||
next(); // Consume the peek
|
||||
return {ast::type::TextureDimension::k1dArray,
|
||||
ast::type::StorageAccess::kRead};
|
||||
ast::AccessControl::kReadOnly};
|
||||
}
|
||||
if (t.IsTextureStorageReadonly2d()) {
|
||||
next(); // Consume the peek
|
||||
return {ast::type::TextureDimension::k2d, ast::type::StorageAccess::kRead};
|
||||
return {ast::type::TextureDimension::k2d, ast::AccessControl::kReadOnly};
|
||||
}
|
||||
if (t.IsTextureStorageReadonly2dArray()) {
|
||||
next(); // Consume the peek
|
||||
return {ast::type::TextureDimension::k2dArray,
|
||||
ast::type::StorageAccess::kRead};
|
||||
ast::AccessControl::kReadOnly};
|
||||
}
|
||||
if (t.IsTextureStorageReadonly3d()) {
|
||||
next(); // Consume the peek
|
||||
return {ast::type::TextureDimension::k3d, ast::type::StorageAccess::kRead};
|
||||
return {ast::type::TextureDimension::k3d, ast::AccessControl::kReadOnly};
|
||||
}
|
||||
if (t.IsTextureStorageWriteonly1d()) {
|
||||
next(); // Consume the peek
|
||||
return {ast::type::TextureDimension::k1d, ast::type::StorageAccess::kWrite};
|
||||
return {ast::type::TextureDimension::k1d, ast::AccessControl::kWriteOnly};
|
||||
}
|
||||
if (t.IsTextureStorageWriteonly1dArray()) {
|
||||
next(); // Consume the peek
|
||||
return {ast::type::TextureDimension::k1dArray,
|
||||
ast::type::StorageAccess::kWrite};
|
||||
ast::AccessControl::kWriteOnly};
|
||||
}
|
||||
if (t.IsTextureStorageWriteonly2d()) {
|
||||
next(); // Consume the peek
|
||||
return {ast::type::TextureDimension::k2d, ast::type::StorageAccess::kWrite};
|
||||
return {ast::type::TextureDimension::k2d, ast::AccessControl::kWriteOnly};
|
||||
}
|
||||
if (t.IsTextureStorageWriteonly2dArray()) {
|
||||
next(); // Consume the peek
|
||||
return {ast::type::TextureDimension::k2dArray,
|
||||
ast::type::StorageAccess::kWrite};
|
||||
ast::AccessControl::kWriteOnly};
|
||||
}
|
||||
if (t.IsTextureStorageWriteonly3d()) {
|
||||
next(); // Consume the peek
|
||||
return {ast::type::TextureDimension::k3d, ast::type::StorageAccess::kWrite};
|
||||
return {ast::type::TextureDimension::k3d, ast::AccessControl::kWriteOnly};
|
||||
}
|
||||
return {ast::type::TextureDimension::kNone, ast::type::StorageAccess::kRead};
|
||||
return {ast::type::TextureDimension::kNone, ast::AccessControl::kReadOnly};
|
||||
}
|
||||
|
||||
// depth_texture_type
|
||||
|
||||
@@ -208,7 +208,7 @@ class ParserImpl {
|
||||
/// Parses a `storage_texture_type` grammar element
|
||||
/// @returns returns the storage texture dimension and the storage access.
|
||||
/// Returns kNone and kRead if none matched.
|
||||
std::pair<ast::type::TextureDimension, ast::type::StorageAccess>
|
||||
std::pair<ast::type::TextureDimension, ast::AccessControl>
|
||||
storage_texture_type();
|
||||
/// Parses a `depth_texture_type` grammar element
|
||||
/// @returns the parsed Type or nullptr if none matched.
|
||||
|
||||
@@ -26,7 +26,7 @@ TEST_F(ParserImplTest, StorageTextureType_Invalid) {
|
||||
auto* p = parser("abc");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_EQ(t.first, ast::type::TextureDimension::kNone);
|
||||
EXPECT_EQ(t.second, ast::type::StorageAccess::kRead);
|
||||
EXPECT_EQ(t.second, ast::AccessControl::kReadOnly);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ TEST_F(ParserImplTest, StorageTextureType_Readonly1d) {
|
||||
auto* p = parser("texture_ro_1d");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_EQ(t.first, ast::type::TextureDimension::k1d);
|
||||
EXPECT_EQ(t.second, ast::type::StorageAccess::kRead);
|
||||
EXPECT_EQ(t.second, ast::AccessControl::kReadOnly);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ TEST_F(ParserImplTest, StorageTextureType_Readonly1dArray) {
|
||||
auto* p = parser("texture_ro_1d_array");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_EQ(t.first, ast::type::TextureDimension::k1dArray);
|
||||
EXPECT_EQ(t.second, ast::type::StorageAccess::kRead);
|
||||
EXPECT_EQ(t.second, ast::AccessControl::kReadOnly);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ TEST_F(ParserImplTest, StorageTextureType_Readonly2d) {
|
||||
auto* p = parser("texture_ro_2d");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_EQ(t.first, ast::type::TextureDimension::k2d);
|
||||
EXPECT_EQ(t.second, ast::type::StorageAccess::kRead);
|
||||
EXPECT_EQ(t.second, ast::AccessControl::kReadOnly);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ TEST_F(ParserImplTest, StorageTextureType_Readonly2dArray) {
|
||||
auto* p = parser("texture_ro_2d_array");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_EQ(t.first, ast::type::TextureDimension::k2dArray);
|
||||
EXPECT_EQ(t.second, ast::type::StorageAccess::kRead);
|
||||
EXPECT_EQ(t.second, ast::AccessControl::kReadOnly);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ TEST_F(ParserImplTest, StorageTextureType_Readonly3d) {
|
||||
auto* p = parser("texture_ro_3d");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_EQ(t.first, ast::type::TextureDimension::k3d);
|
||||
EXPECT_EQ(t.second, ast::type::StorageAccess::kRead);
|
||||
EXPECT_EQ(t.second, ast::AccessControl::kReadOnly);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ TEST_F(ParserImplTest, StorageTextureType_Writeonly1d) {
|
||||
auto* p = parser("texture_wo_1d");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_EQ(t.first, ast::type::TextureDimension::k1d);
|
||||
EXPECT_EQ(t.second, ast::type::StorageAccess::kWrite);
|
||||
EXPECT_EQ(t.second, ast::AccessControl::kWriteOnly);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ TEST_F(ParserImplTest, StorageTextureType_Writeonly1dArray) {
|
||||
auto* p = parser("texture_wo_1d_array");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_EQ(t.first, ast::type::TextureDimension::k1dArray);
|
||||
EXPECT_EQ(t.second, ast::type::StorageAccess::kWrite);
|
||||
EXPECT_EQ(t.second, ast::AccessControl::kWriteOnly);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ TEST_F(ParserImplTest, StorageTextureType_Writeonly2d) {
|
||||
auto* p = parser("texture_wo_2d");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_EQ(t.first, ast::type::TextureDimension::k2d);
|
||||
EXPECT_EQ(t.second, ast::type::StorageAccess::kWrite);
|
||||
EXPECT_EQ(t.second, ast::AccessControl::kWriteOnly);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ TEST_F(ParserImplTest, StorageTextureType_Writeonly2dArray) {
|
||||
auto* p = parser("texture_wo_2d_array");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_EQ(t.first, ast::type::TextureDimension::k2dArray);
|
||||
EXPECT_EQ(t.second, ast::type::StorageAccess::kWrite);
|
||||
EXPECT_EQ(t.second, ast::AccessControl::kWriteOnly);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ TEST_F(ParserImplTest, StorageTextureType_Writeonly3d) {
|
||||
auto* p = parser("texture_wo_3d");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_EQ(t.first, ast::type::TextureDimension::k3d);
|
||||
EXPECT_EQ(t.second, ast::type::StorageAccess::kWrite);
|
||||
EXPECT_EQ(t.second, ast::AccessControl::kWriteOnly);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dR8Unorm) {
|
||||
EXPECT_EQ(t->AsTexture()->AsStorage()->image_format(),
|
||||
ast::type::ImageFormat::kR8Unorm);
|
||||
EXPECT_EQ(t->AsTexture()->AsStorage()->access(),
|
||||
ast::type::StorageAccess::kRead);
|
||||
ast::AccessControl::kReadOnly);
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::k1d);
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) {
|
||||
EXPECT_EQ(t->AsTexture()->AsStorage()->image_format(),
|
||||
ast::type::ImageFormat::kR16Float);
|
||||
EXPECT_EQ(t->AsTexture()->AsStorage()->access(),
|
||||
ast::type::StorageAccess::kWrite);
|
||||
ast::AccessControl::kWriteOnly);
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::k2d);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user