mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 08:27:05 +00:00
Post migration to castable cleanup
Change-Id: I5c47b1736bd850548cb1c9c7a6f69242d8626173 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34460 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
782f6a5e3e
commit
1b6a8ce165
@@ -104,25 +104,26 @@ Function::referenced_uniform_variables() const {
|
||||
std::vector<std::pair<Variable*, Function::BindingInfo>> ret;
|
||||
|
||||
for (auto* var : referenced_module_variables()) {
|
||||
if (!var->Is<DecoratedVariable>() ||
|
||||
var->storage_class() != StorageClass::kUniform) {
|
||||
if (var->storage_class() != StorageClass::kUniform) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BindingDecoration* binding = nullptr;
|
||||
SetDecoration* set = nullptr;
|
||||
for (auto* deco : var->As<DecoratedVariable>()->decorations()) {
|
||||
if (auto* b = deco->As<BindingDecoration>()) {
|
||||
binding = b;
|
||||
} else if (auto* s = deco->As<SetDecoration>()) {
|
||||
set = s;
|
||||
if (auto* decorated = var->As<DecoratedVariable>()) {
|
||||
BindingDecoration* binding = nullptr;
|
||||
SetDecoration* set = nullptr;
|
||||
for (auto* deco : decorated->decorations()) {
|
||||
if (auto* b = deco->As<BindingDecoration>()) {
|
||||
binding = b;
|
||||
} else if (auto* s = deco->As<SetDecoration>()) {
|
||||
set = s;
|
||||
}
|
||||
}
|
||||
if (binding == nullptr || set == nullptr) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (binding == nullptr || set == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ret.push_back({var, BindingInfo{binding, set}});
|
||||
ret.push_back({var, BindingInfo{binding, set}});
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -132,25 +133,26 @@ Function::referenced_storagebuffer_variables() const {
|
||||
std::vector<std::pair<Variable*, Function::BindingInfo>> ret;
|
||||
|
||||
for (auto* var : referenced_module_variables()) {
|
||||
if (!var->Is<DecoratedVariable>() ||
|
||||
var->storage_class() != StorageClass::kStorageBuffer) {
|
||||
if (var->storage_class() != StorageClass::kStorageBuffer) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BindingDecoration* binding = nullptr;
|
||||
SetDecoration* set = nullptr;
|
||||
for (auto* deco : var->As<DecoratedVariable>()->decorations()) {
|
||||
if (auto* b = deco->As<BindingDecoration>()) {
|
||||
binding = b;
|
||||
} else if (auto* s = deco->As<SetDecoration>()) {
|
||||
set = s;
|
||||
if (auto* decorated = var->As<DecoratedVariable>()) {
|
||||
BindingDecoration* binding = nullptr;
|
||||
SetDecoration* set = nullptr;
|
||||
for (auto* deco : decorated->decorations()) {
|
||||
if (auto* b = deco->As<BindingDecoration>()) {
|
||||
binding = b;
|
||||
} else if (auto* s = deco->As<SetDecoration>()) {
|
||||
set = s;
|
||||
}
|
||||
}
|
||||
if (binding == nullptr || set == nullptr) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (binding == nullptr || set == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ret.push_back({var, BindingInfo{binding, set}});
|
||||
ret.push_back({var, BindingInfo{binding, set}});
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -160,13 +162,12 @@ Function::referenced_builtin_variables() const {
|
||||
std::vector<std::pair<Variable*, BuiltinDecoration*>> ret;
|
||||
|
||||
for (auto* var : referenced_module_variables()) {
|
||||
if (!var->Is<DecoratedVariable>()) {
|
||||
continue;
|
||||
}
|
||||
for (auto* deco : var->As<DecoratedVariable>()->decorations()) {
|
||||
if (auto* builtin = deco->As<BuiltinDecoration>()) {
|
||||
ret.push_back({var, builtin});
|
||||
break;
|
||||
if (auto* decorated = var->As<DecoratedVariable>()) {
|
||||
for (auto* deco : decorated->decorations()) {
|
||||
if (auto* builtin = deco->As<BuiltinDecoration>()) {
|
||||
ret.push_back({var, builtin});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -292,25 +293,28 @@ Function::ReferencedSamplerVariablesImpl(type::SamplerKind kind) const {
|
||||
|
||||
for (auto* var : referenced_module_variables()) {
|
||||
auto* unwrapped_type = var->type()->UnwrapIfNeeded();
|
||||
if (!var->Is<DecoratedVariable>() || !unwrapped_type->Is<type::Sampler>() ||
|
||||
unwrapped_type->As<type::Sampler>()->kind() != kind) {
|
||||
auto* sampler = unwrapped_type->As<type::Sampler>();
|
||||
if (sampler == nullptr || sampler->kind() != kind) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BindingDecoration* binding = nullptr;
|
||||
SetDecoration* set = nullptr;
|
||||
for (auto* deco : var->As<DecoratedVariable>()->decorations()) {
|
||||
if (auto* b = deco->As<BindingDecoration>()) {
|
||||
binding = b;
|
||||
} else if (auto* s = deco->As<SetDecoration>()) {
|
||||
set = s;
|
||||
if (auto* decorated = var->As<DecoratedVariable>()) {
|
||||
BindingDecoration* binding = nullptr;
|
||||
SetDecoration* set = nullptr;
|
||||
for (auto* deco : decorated->decorations()) {
|
||||
if (auto* b = deco->As<BindingDecoration>()) {
|
||||
binding = b;
|
||||
}
|
||||
if (auto* s = deco->As<SetDecoration>()) {
|
||||
set = s;
|
||||
}
|
||||
}
|
||||
if (binding == nullptr || set == nullptr) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (binding == nullptr || set == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ret.push_back({var, BindingInfo{binding, set}});
|
||||
ret.push_back({var, BindingInfo{binding, set}});
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -321,29 +325,34 @@ Function::ReferencedSampledTextureVariablesImpl(bool multisampled) const {
|
||||
|
||||
for (auto* var : referenced_module_variables()) {
|
||||
auto* unwrapped_type = var->type()->UnwrapIfNeeded();
|
||||
if (!var->Is<DecoratedVariable>() || !unwrapped_type->Is<type::Texture>()) {
|
||||
auto* texture = unwrapped_type->As<type::Texture>();
|
||||
if (texture == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((multisampled && !unwrapped_type->Is<type::MultisampledTexture>()) ||
|
||||
(!multisampled && !unwrapped_type->Is<type::SampledTexture>())) {
|
||||
auto is_multisampled = texture->Is<type::MultisampledTexture>();
|
||||
auto is_sampled = texture->Is<type::SampledTexture>();
|
||||
|
||||
if ((multisampled && !is_multisampled) || (!multisampled && !is_sampled)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BindingDecoration* binding = nullptr;
|
||||
SetDecoration* set = nullptr;
|
||||
for (auto* deco : var->As<DecoratedVariable>()->decorations()) {
|
||||
if (auto* b = deco->As<BindingDecoration>()) {
|
||||
binding = b;
|
||||
} else if (auto* s = deco->As<SetDecoration>()) {
|
||||
set = s;
|
||||
if (auto* decorated = var->As<DecoratedVariable>()) {
|
||||
BindingDecoration* binding = nullptr;
|
||||
SetDecoration* set = nullptr;
|
||||
for (auto* deco : decorated->decorations()) {
|
||||
if (auto* b = deco->As<BindingDecoration>()) {
|
||||
binding = b;
|
||||
} else if (auto* s = deco->As<SetDecoration>()) {
|
||||
set = s;
|
||||
}
|
||||
}
|
||||
if (binding == nullptr || set == nullptr) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (binding == nullptr || set == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ret.push_back({var, BindingInfo{binding, set}});
|
||||
ret.push_back({var, BindingInfo{binding, set}});
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -74,17 +74,16 @@ bool Module::IsValid() const {
|
||||
if (ty == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (ty->Is<type::Alias>()) {
|
||||
auto* alias = ty->As<type::Alias>();
|
||||
if (auto* alias = ty->As<type::Alias>()) {
|
||||
if (alias->type() == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (alias->type()->Is<type::Struct>() &&
|
||||
alias->type()->As<type::Struct>()->name().empty()) {
|
||||
return false;
|
||||
if (auto* str = alias->type()->As<type::Struct>()) {
|
||||
if (str->name().empty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (ty->Is<type::Struct>()) {
|
||||
auto* str = ty->As<type::Struct>();
|
||||
} else if (auto* str = ty->As<type::Struct>()) {
|
||||
if (str->name().empty()) {
|
||||
return false;
|
||||
}
|
||||
@@ -109,14 +108,12 @@ std::string Module::to_str() const {
|
||||
for (size_t i = 0; i < indent; ++i) {
|
||||
out << " ";
|
||||
}
|
||||
if (ty->Is<type::Alias>()) {
|
||||
auto* alias = ty->As<type::Alias>();
|
||||
if (auto* alias = ty->As<type::Alias>()) {
|
||||
out << alias->name() << " -> " << alias->type()->type_name() << std::endl;
|
||||
if (alias->type()->Is<type::Struct>()) {
|
||||
alias->type()->As<type::Struct>()->impl()->to_str(out, indent);
|
||||
if (auto* str = alias->type()->As<type::Struct>()) {
|
||||
str->impl()->to_str(out, indent);
|
||||
}
|
||||
} else if (ty->Is<type::Struct>()) {
|
||||
auto* str = ty->As<type::Struct>();
|
||||
} else if (auto* str = ty->As<type::Struct>()) {
|
||||
out << str->name() << " ";
|
||||
str->impl()->to_str(out, indent);
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ TEST_F(StorageTextureTest, F32) {
|
||||
ASSERT_TRUE(td.Determine()) << td.error();
|
||||
ASSERT_TRUE(s->Is<Texture>());
|
||||
ASSERT_TRUE(s->Is<StorageTexture>());
|
||||
EXPECT_TRUE(s->As<Texture>()->As<StorageTexture>()->type()->Is<F32>());
|
||||
EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<F32>());
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTest, U32) {
|
||||
@@ -130,7 +130,7 @@ TEST_F(StorageTextureTest, I32) {
|
||||
ASSERT_TRUE(td.Determine()) << td.error();
|
||||
ASSERT_TRUE(s->Is<Texture>());
|
||||
ASSERT_TRUE(s->Is<StorageTexture>());
|
||||
EXPECT_TRUE(s->As<Texture>()->As<StorageTexture>()->type()->Is<I32>());
|
||||
EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<I32>());
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTest, MinBufferBindingSize) {
|
||||
|
||||
@@ -42,8 +42,8 @@ Type::Type(Type&&) = default;
|
||||
Type::~Type() = default;
|
||||
|
||||
Type* Type::UnwrapPtrIfNeeded() {
|
||||
if (Is<Pointer>()) {
|
||||
return As<Pointer>()->type();
|
||||
if (auto* ptr = As<type::Pointer>()) {
|
||||
return ptr->type();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -51,10 +51,10 @@ Type* Type::UnwrapPtrIfNeeded() {
|
||||
Type* Type::UnwrapIfNeeded() {
|
||||
auto* where = this;
|
||||
while (true) {
|
||||
if (where->Is<Alias>()) {
|
||||
where = where->As<Alias>()->type();
|
||||
} else if (where->Is<AccessControl>()) {
|
||||
where = where->As<AccessControl>()->type();
|
||||
if (auto* alias = where->As<type::Alias>()) {
|
||||
where = alias->type();
|
||||
} else if (auto* access = where->As<type::AccessControl>()) {
|
||||
where = access->type();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user