mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 01:15:39 +00:00
Move struct validation from Validator to Resolver
* Moved Validator::ValidateConstructedType, which only validated structs, to Resolver as ValidateStructure. * Moved relevant tests to new files, and also updated all failing tests to validate Source location. * Fixed other tests that broke now that we're validating structs. Bug: tint:642 Change-Id: Iefc08ef548f52d8c3798d814d2183c56d1236c2d Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45160 Commit-Queue: Antonio Maiorano <amaiorano@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
e072465d83
commit
9970ec63ca
@@ -222,6 +222,17 @@ class InspectorHelper : public ProgramBuilder {
|
||||
return struct_type;
|
||||
}
|
||||
|
||||
/// Returns true if the struct with `member_types` requires a block decoration
|
||||
/// @param member_types a vector of member types
|
||||
/// @returns true if block decoration is required
|
||||
bool StructRequiresBlockDecoration(
|
||||
std::vector<type::Type*> member_types) const {
|
||||
// Structure needs a [[block]] attribute if the last member is a
|
||||
// dynamically-sized array.
|
||||
return member_types.back()->Is<type::Array>(
|
||||
[](auto&& a) { return a->IsRuntimeArray(); });
|
||||
}
|
||||
|
||||
/// Generates types appropriate for using in a storage buffer
|
||||
/// @param name name for the type
|
||||
/// @param member_types a vector of member types
|
||||
@@ -231,7 +242,8 @@ class InspectorHelper : public ProgramBuilder {
|
||||
std::tuple<type::Struct*, type::AccessControl*> MakeStorageBufferTypes(
|
||||
const std::string& name,
|
||||
std::vector<type::Type*> member_types) {
|
||||
auto* struct_type = MakeStructType(name, member_types, false);
|
||||
bool is_block = StructRequiresBlockDecoration(member_types);
|
||||
auto* struct_type = MakeStructType(name, member_types, is_block);
|
||||
auto* access_type = create<type::AccessControl>(
|
||||
ast::AccessControl::kReadWrite, struct_type);
|
||||
return {struct_type, std::move(access_type)};
|
||||
@@ -246,7 +258,8 @@ class InspectorHelper : public ProgramBuilder {
|
||||
std::tuple<type::Struct*, type::AccessControl*>
|
||||
MakeReadOnlyStorageBufferTypes(const std::string& name,
|
||||
std::vector<type::Type*> member_types) {
|
||||
auto* struct_type = MakeStructType(name, member_types, false);
|
||||
bool is_block = StructRequiresBlockDecoration(member_types);
|
||||
auto* struct_type = MakeStructType(name, member_types, is_block);
|
||||
auto* access_type =
|
||||
create<type::AccessControl>(ast::AccessControl::kReadOnly, struct_type);
|
||||
return {struct_type, std::move(access_type)};
|
||||
|
||||
Reference in New Issue
Block a user