s/sharable/shareable
Fixed: tint:660 Change-Id: I5b98597acb771f6b07a16a85d85d8ae5249e495d Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45283 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
722b5a2d18
commit
25eef8d2cf
|
@ -468,9 +468,9 @@ if(${TINT_BUILD_TESTS})
|
|||
intrinsic_table_test.cc
|
||||
program_test.cc
|
||||
resolver/decoration_validation_test.cc
|
||||
resolver/host_sharable_validation_test.cc
|
||||
resolver/host_shareable_validation_test.cc
|
||||
resolver/intrinsic_test.cc
|
||||
resolver/is_host_sharable_test.cc
|
||||
resolver/is_host_shareable_test.cc
|
||||
resolver/is_storeable_test.cc
|
||||
resolver/resolver_test_helper.cc
|
||||
resolver/resolver_test_helper.h
|
||||
|
|
|
@ -34,9 +34,9 @@ enum class StorageClass {
|
|||
kFunction
|
||||
};
|
||||
|
||||
/// @returns true if the StorageClass is host-sharable
|
||||
/// @returns true if the StorageClass is host-shareable
|
||||
/// @see https://gpuweb.github.io/gpuweb/wgsl.html#host-shareable
|
||||
inline bool IsHostSharable(StorageClass sc) {
|
||||
inline bool IsHostShareable(StorageClass sc) {
|
||||
return sc == ast::StorageClass::kUniform || sc == ast::StorageClass::kStorage;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,20 +23,20 @@ namespace tint {
|
|||
namespace resolver {
|
||||
namespace {
|
||||
|
||||
using ResolverHostSharableValidationTest = ResolverTest;
|
||||
using ResolverHostShareableValidationTest = ResolverTest;
|
||||
|
||||
TEST_F(ResolverHostSharableValidationTest, Bool) {
|
||||
TEST_F(ResolverHostShareableValidationTest, Bool) {
|
||||
Global(Source{{56, 78}}, "g", ty.bool_(), ast::StorageClass::kStorage);
|
||||
|
||||
ASSERT_FALSE(r()->Resolve());
|
||||
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(56:78 error: Type 'bool' cannot be used in storage class 'storage' as it is non-host-sharable
|
||||
R"(56:78 error: Type 'bool' cannot be used in storage class 'storage' as it is non-host-shareable
|
||||
56:78 note: while instantiating variable g)");
|
||||
}
|
||||
|
||||
TEST_F(ResolverHostSharableValidationTest, Pointer) {
|
||||
TEST_F(ResolverHostShareableValidationTest, Pointer) {
|
||||
Global(Source{{56, 78}}, "g", ty.pointer<i32>(ast::StorageClass::kNone),
|
||||
ast::StorageClass::kStorage);
|
||||
|
||||
|
@ -44,11 +44,11 @@ TEST_F(ResolverHostSharableValidationTest, Pointer) {
|
|||
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(56:78 error: Type 'ptr<i32>' cannot be used in storage class 'storage' as it is non-host-sharable
|
||||
R"(56:78 error: Type 'ptr<i32>' cannot be used in storage class 'storage' as it is non-host-shareable
|
||||
56:78 note: while instantiating variable g)");
|
||||
}
|
||||
|
||||
TEST_F(ResolverHostSharableValidationTest, BoolMember) {
|
||||
TEST_F(ResolverHostShareableValidationTest, BoolMember) {
|
||||
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.bool_())});
|
||||
Global(Source{{56, 78}}, "g", s, ast::StorageClass::kStorage);
|
||||
|
||||
|
@ -56,12 +56,12 @@ TEST_F(ResolverHostSharableValidationTest, BoolMember) {
|
|||
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(56:78 error: Type 'bool' cannot be used in storage class 'storage' as it is non-host-sharable
|
||||
R"(56:78 error: Type 'bool' cannot be used in storage class 'storage' as it is non-host-shareable
|
||||
12:34 note: while analysing structure member S.x
|
||||
56:78 note: while instantiating variable g)");
|
||||
}
|
||||
|
||||
TEST_F(ResolverHostSharableValidationTest, BoolVectorMember) {
|
||||
TEST_F(ResolverHostShareableValidationTest, BoolVectorMember) {
|
||||
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.vec3<bool>())});
|
||||
Global(Source{{56, 78}}, "g", s, ast::StorageClass::kStorage);
|
||||
|
||||
|
@ -69,12 +69,12 @@ TEST_F(ResolverHostSharableValidationTest, BoolVectorMember) {
|
|||
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(56:78 error: Type 'vec3<bool>' cannot be used in storage class 'storage' as it is non-host-sharable
|
||||
R"(56:78 error: Type 'vec3<bool>' cannot be used in storage class 'storage' as it is non-host-shareable
|
||||
12:34 note: while analysing structure member S.x
|
||||
56:78 note: while instantiating variable g)");
|
||||
}
|
||||
|
||||
TEST_F(ResolverHostSharableValidationTest, Aliases) {
|
||||
TEST_F(ResolverHostShareableValidationTest, Aliases) {
|
||||
auto* a1 = ty.alias("a1", ty.bool_());
|
||||
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", a1)});
|
||||
auto* a2 = ty.alias("a2", s);
|
||||
|
@ -84,12 +84,12 @@ TEST_F(ResolverHostSharableValidationTest, Aliases) {
|
|||
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(56:78 error: Type 'bool' cannot be used in storage class 'storage' as it is non-host-sharable
|
||||
R"(56:78 error: Type 'bool' cannot be used in storage class 'storage' as it is non-host-shareable
|
||||
12:34 note: while analysing structure member S.x
|
||||
56:78 note: while instantiating variable g)");
|
||||
}
|
||||
|
||||
TEST_F(ResolverHostSharableValidationTest, AccessControl) {
|
||||
TEST_F(ResolverHostShareableValidationTest, AccessControl) {
|
||||
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.bool_())});
|
||||
auto* a = create<type::AccessControl>(ast::AccessControl::kReadOnly, s);
|
||||
Global(Source{{56, 78}}, "g", a, ast::StorageClass::kStorage);
|
||||
|
@ -98,12 +98,12 @@ TEST_F(ResolverHostSharableValidationTest, AccessControl) {
|
|||
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(56:78 error: Type 'bool' cannot be used in storage class 'storage' as it is non-host-sharable
|
||||
R"(56:78 error: Type 'bool' cannot be used in storage class 'storage' as it is non-host-shareable
|
||||
12:34 note: while analysing structure member S.x
|
||||
56:78 note: while instantiating variable g)");
|
||||
}
|
||||
|
||||
TEST_F(ResolverHostSharableValidationTest, NestedStructures) {
|
||||
TEST_F(ResolverHostShareableValidationTest, NestedStructures) {
|
||||
auto* i1 = Structure("I1", {Member(Source{{1, 2}}, "x", ty.bool_())});
|
||||
auto* i2 = Structure("I2", {Member(Source{{3, 4}}, "y", i1)});
|
||||
auto* i3 = Structure("I3", {Member(Source{{5, 6}}, "z", i2)});
|
||||
|
@ -115,7 +115,7 @@ TEST_F(ResolverHostSharableValidationTest, NestedStructures) {
|
|||
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(9:10 error: Type 'bool' cannot be used in storage class 'storage' as it is non-host-sharable
|
||||
R"(9:10 error: Type 'bool' cannot be used in storage class 'storage' as it is non-host-shareable
|
||||
1:2 note: while analysing structure member I1.x
|
||||
3:4 note: while analysing structure member I2.y
|
||||
5:6 note: while analysing structure member I3.z
|
||||
|
@ -123,7 +123,7 @@ TEST_F(ResolverHostSharableValidationTest, NestedStructures) {
|
|||
9:10 note: while instantiating variable g)");
|
||||
}
|
||||
|
||||
TEST_F(ResolverHostSharableValidationTest, NoError) {
|
||||
TEST_F(ResolverHostShareableValidationTest, NoError) {
|
||||
auto* i1 =
|
||||
Structure("I1", {
|
||||
Member(Source{{1, 1}}, "x1", ty.f32()),
|
|
@ -1,150 +0,0 @@
|
|||
// Copyright 2021 The Tint Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/resolver/resolver.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/resolver/resolver_test_helper.h"
|
||||
#include "src/type/access_control_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace resolver {
|
||||
namespace {
|
||||
|
||||
using ResolverIsHostSharable = ResolverTest;
|
||||
|
||||
TEST_F(ResolverIsHostSharable, Void) {
|
||||
EXPECT_FALSE(r()->IsHostSharable(ty.void_()));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostSharable, Bool) {
|
||||
EXPECT_FALSE(r()->IsHostSharable(ty.bool_()));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostSharable, NumericScalar) {
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.i32()));
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.u32()));
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.f32()));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostSharable, NumericVector) {
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.vec2<i32>()));
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.vec3<i32>()));
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.vec4<i32>()));
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.vec2<u32>()));
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.vec3<u32>()));
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.vec4<u32>()));
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.vec2<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.vec3<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.vec4<f32>()));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostSharable, BoolVector) {
|
||||
EXPECT_FALSE(r()->IsHostSharable(ty.vec2<bool>()));
|
||||
EXPECT_FALSE(r()->IsHostSharable(ty.vec3<bool>()));
|
||||
EXPECT_FALSE(r()->IsHostSharable(ty.vec4<bool>()));
|
||||
EXPECT_FALSE(r()->IsHostSharable(ty.vec2<bool>()));
|
||||
EXPECT_FALSE(r()->IsHostSharable(ty.vec3<bool>()));
|
||||
EXPECT_FALSE(r()->IsHostSharable(ty.vec4<bool>()));
|
||||
EXPECT_FALSE(r()->IsHostSharable(ty.vec2<bool>()));
|
||||
EXPECT_FALSE(r()->IsHostSharable(ty.vec3<bool>()));
|
||||
EXPECT_FALSE(r()->IsHostSharable(ty.vec4<bool>()));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostSharable, Matrix) {
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.mat2x2<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.mat2x3<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.mat2x4<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.mat3x2<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.mat3x3<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.mat3x4<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.mat4x2<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.mat4x3<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.mat4x4<f32>()));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostSharable, Pointer) {
|
||||
EXPECT_FALSE(
|
||||
r()->IsHostSharable(ty.pointer<i32>(ast::StorageClass::kPrivate)));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostSharable, AliasVoid) {
|
||||
EXPECT_FALSE(r()->IsHostSharable(ty.alias("a", ty.void_())));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostSharable, AliasI32) {
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.alias("a", ty.i32())));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostSharable, AccessControlVoid) {
|
||||
EXPECT_FALSE(r()->IsHostSharable(
|
||||
create<type::AccessControl>(ast::AccessControl::kReadOnly, ty.void_())));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostSharable, AccessControlI32) {
|
||||
EXPECT_TRUE(r()->IsHostSharable(
|
||||
create<type::AccessControl>(ast::AccessControl::kReadOnly, ty.i32())));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostSharable, ArraySizedOfHostSharable) {
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.array(ty.i32(), 5)));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostSharable, ArrayUnsizedOfHostSharable) {
|
||||
EXPECT_TRUE(r()->IsHostSharable(ty.array<i32>()));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostSharable, Struct_AllMembersHostSharable) {
|
||||
EXPECT_TRUE(r()->IsHostSharable(Structure("S", {
|
||||
Member("a", ty.i32()),
|
||||
Member("b", ty.f32()),
|
||||
})));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostSharable, Struct_SomeMembersNonHostSharable) {
|
||||
auto* ptr_ty = ty.pointer<i32>(ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->IsHostSharable(Structure("S", {
|
||||
Member("a", ty.i32()),
|
||||
Member("b", ptr_ty),
|
||||
})));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostSharable, Struct_NestedHostSharable) {
|
||||
auto* host_sharable = Structure("S", {
|
||||
Member("a", ty.i32()),
|
||||
Member("b", ty.f32()),
|
||||
});
|
||||
EXPECT_TRUE(r()->IsHostSharable(Structure("S", {
|
||||
Member("a", ty.i32()),
|
||||
Member("b", host_sharable),
|
||||
})));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostSharable, Struct_NestedNonHostSharable) {
|
||||
auto* ptr_ty = ty.pointer<i32>(ast::StorageClass::kPrivate);
|
||||
auto* non_host_sharable =
|
||||
Structure("non_host_sharable", {
|
||||
Member("a", ty.i32()),
|
||||
Member("b", ptr_ty),
|
||||
});
|
||||
EXPECT_FALSE(
|
||||
r()->IsHostSharable(Structure("S", {
|
||||
Member("a", ty.i32()),
|
||||
Member("b", non_host_sharable),
|
||||
})));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace resolver
|
||||
} // namespace tint
|
|
@ -0,0 +1,151 @@
|
|||
// Copyright 2021 The Tint Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/resolver/resolver.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/resolver/resolver_test_helper.h"
|
||||
#include "src/type/access_control_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace resolver {
|
||||
namespace {
|
||||
|
||||
using ResolverIsHostShareable = ResolverTest;
|
||||
|
||||
TEST_F(ResolverIsHostShareable, Void) {
|
||||
EXPECT_FALSE(r()->IsHostShareable(ty.void_()));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, Bool) {
|
||||
EXPECT_FALSE(r()->IsHostShareable(ty.bool_()));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, NumericScalar) {
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.i32()));
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.u32()));
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.f32()));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, NumericVector) {
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.vec2<i32>()));
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.vec3<i32>()));
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.vec4<i32>()));
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.vec2<u32>()));
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.vec3<u32>()));
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.vec4<u32>()));
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.vec2<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.vec3<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.vec4<f32>()));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, BoolVector) {
|
||||
EXPECT_FALSE(r()->IsHostShareable(ty.vec2<bool>()));
|
||||
EXPECT_FALSE(r()->IsHostShareable(ty.vec3<bool>()));
|
||||
EXPECT_FALSE(r()->IsHostShareable(ty.vec4<bool>()));
|
||||
EXPECT_FALSE(r()->IsHostShareable(ty.vec2<bool>()));
|
||||
EXPECT_FALSE(r()->IsHostShareable(ty.vec3<bool>()));
|
||||
EXPECT_FALSE(r()->IsHostShareable(ty.vec4<bool>()));
|
||||
EXPECT_FALSE(r()->IsHostShareable(ty.vec2<bool>()));
|
||||
EXPECT_FALSE(r()->IsHostShareable(ty.vec3<bool>()));
|
||||
EXPECT_FALSE(r()->IsHostShareable(ty.vec4<bool>()));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, Matrix) {
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.mat2x2<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.mat2x3<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.mat2x4<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.mat3x2<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.mat3x3<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.mat3x4<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.mat4x2<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.mat4x3<f32>()));
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.mat4x4<f32>()));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, Pointer) {
|
||||
EXPECT_FALSE(
|
||||
r()->IsHostShareable(ty.pointer<i32>(ast::StorageClass::kPrivate)));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, AliasVoid) {
|
||||
EXPECT_FALSE(r()->IsHostShareable(ty.alias("a", ty.void_())));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, AliasI32) {
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.alias("a", ty.i32())));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, AccessControlVoid) {
|
||||
EXPECT_FALSE(r()->IsHostShareable(
|
||||
create<type::AccessControl>(ast::AccessControl::kReadOnly, ty.void_())));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, AccessControlI32) {
|
||||
EXPECT_TRUE(r()->IsHostShareable(
|
||||
create<type::AccessControl>(ast::AccessControl::kReadOnly, ty.i32())));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, ArraySizedOfHostShareable) {
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.array(ty.i32(), 5)));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, ArrayUnsizedOfHostShareable) {
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.array<i32>()));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, Struct_AllMembersHostShareable) {
|
||||
EXPECT_TRUE(r()->IsHostShareable(Structure("S", {
|
||||
Member("a", ty.i32()),
|
||||
Member("b", ty.f32()),
|
||||
})));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, Struct_SomeMembersNonHostShareable) {
|
||||
auto* ptr_ty = ty.pointer<i32>(ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->IsHostShareable(Structure("S", {
|
||||
Member("a", ty.i32()),
|
||||
Member("b", ptr_ty),
|
||||
})));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, Struct_NestedHostShareable) {
|
||||
auto* host_shareable = Structure("S", {
|
||||
Member("a", ty.i32()),
|
||||
Member("b", ty.f32()),
|
||||
});
|
||||
EXPECT_TRUE(
|
||||
r()->IsHostShareable(Structure("S", {
|
||||
Member("a", ty.i32()),
|
||||
Member("b", host_shareable),
|
||||
})));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, Struct_NestedNonHostShareable) {
|
||||
auto* ptr_ty = ty.pointer<i32>(ast::StorageClass::kPrivate);
|
||||
auto* non_host_shareable =
|
||||
Structure("non_host_shareable", {
|
||||
Member("a", ty.i32()),
|
||||
Member("b", ptr_ty),
|
||||
});
|
||||
EXPECT_FALSE(
|
||||
r()->IsHostShareable(Structure("S", {
|
||||
Member("a", ty.i32()),
|
||||
Member("b", non_host_shareable),
|
||||
})));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace resolver
|
||||
} // namespace tint
|
|
@ -132,23 +132,23 @@ bool Resolver::IsStorable(type::Type* type) {
|
|||
}
|
||||
|
||||
// https://gpuweb.github.io/gpuweb/wgsl.html#host-shareable-types
|
||||
bool Resolver::IsHostSharable(type::Type* type) {
|
||||
bool Resolver::IsHostShareable(type::Type* type) {
|
||||
type = type->UnwrapIfNeeded();
|
||||
if (type->IsAnyOf<type::I32, type::U32, type::F32>()) {
|
||||
return true;
|
||||
}
|
||||
if (auto* vec = type->As<type::Vector>()) {
|
||||
return IsHostSharable(vec->type());
|
||||
return IsHostShareable(vec->type());
|
||||
}
|
||||
if (auto* mat = type->As<type::Matrix>()) {
|
||||
return IsHostSharable(mat->type());
|
||||
return IsHostShareable(mat->type());
|
||||
}
|
||||
if (auto* arr = type->As<type::Array>()) {
|
||||
return IsHostSharable(arr->type());
|
||||
return IsHostShareable(arr->type());
|
||||
}
|
||||
if (auto* str = type->As<type::Struct>()) {
|
||||
for (auto* member : str->impl()->members()) {
|
||||
if (!IsHostSharable(member->type())) {
|
||||
if (!IsHostShareable(member->type())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1335,7 +1335,7 @@ bool Resolver::DefaultAlignAndSize(type::Type* ty,
|
|||
|
||||
ty = ty->UnwrapAliasIfNeeded();
|
||||
if (ty->is_scalar()) {
|
||||
// Note: Also captures booleans, but these are not host-sharable.
|
||||
// Note: Also captures booleans, but these are not host-shareable.
|
||||
align = 4;
|
||||
size = 4;
|
||||
return true;
|
||||
|
@ -1622,11 +1622,11 @@ bool Resolver::ApplyStorageClassUsageToType(ast::StorageClass sc,
|
|||
return ApplyStorageClassUsageToType(sc, arr->type(), usage);
|
||||
}
|
||||
|
||||
if (ast::IsHostSharable(sc) && !IsHostSharable(ty)) {
|
||||
if (ast::IsHostShareable(sc) && !IsHostShareable(ty)) {
|
||||
std::stringstream err;
|
||||
err << "Type '" << ty->FriendlyName(builder_->Symbols())
|
||||
<< "' cannot be used in storage class '" << sc
|
||||
<< "' as it is non-host-sharable";
|
||||
<< "' as it is non-host-shareable";
|
||||
diagnostics_.add_error(err.str(), usage);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -74,8 +74,8 @@ class Resolver {
|
|||
static bool IsStorable(type::Type* type);
|
||||
|
||||
/// @param type the given type
|
||||
/// @returns true if the given type is host-sharable
|
||||
static bool IsHostSharable(type::Type* type);
|
||||
/// @returns true if the given type is host-shareable
|
||||
static bool IsHostShareable(type::Type* type);
|
||||
|
||||
private:
|
||||
/// Structure holding semantic information about a variable.
|
||||
|
|
|
@ -95,10 +95,10 @@ class Struct : public Castable<Struct, Node> {
|
|||
}
|
||||
|
||||
/// @returns true iff this structure has been used by storage class that's
|
||||
/// host-sharable.
|
||||
bool IsHostSharable() const {
|
||||
/// host-shareable.
|
||||
bool IsHostShareable() const {
|
||||
for (auto sc : storage_class_usage_) {
|
||||
if (ast::IsHostSharable(sc)) {
|
||||
if (ast::IsHostShareable(sc)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2009,7 +2009,7 @@ bool GeneratorImpl::EmitStructType(const type::Struct* str) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool is_host_sharable = sem_str->IsHostSharable();
|
||||
bool is_host_shareable = sem_str->IsHostShareable();
|
||||
|
||||
// Emits a `/* 0xnnnn */` byte offset comment for a struct member.
|
||||
auto add_byte_offset_comment = [&](uint32_t offset) {
|
||||
|
@ -2039,7 +2039,7 @@ bool GeneratorImpl::EmitStructType(const type::Struct* str) {
|
|||
|
||||
auto wgsl_offset = sem_mem->Offset();
|
||||
|
||||
if (is_host_sharable) {
|
||||
if (is_host_shareable) {
|
||||
if (wgsl_offset < msl_offset) {
|
||||
// Unimplementable layout
|
||||
TINT_ICE(diagnostics_)
|
||||
|
@ -2084,7 +2084,7 @@ bool GeneratorImpl::EmitStructType(const type::Struct* str) {
|
|||
|
||||
out_ << ";" << std::endl;
|
||||
|
||||
if (is_host_sharable) {
|
||||
if (is_host_shareable) {
|
||||
// Calculate new MSL offset
|
||||
auto size_align = MslPackedTypeSizeAndAlign(ty);
|
||||
if (msl_offset % size_align.align) {
|
||||
|
@ -2097,7 +2097,7 @@ bool GeneratorImpl::EmitStructType(const type::Struct* str) {
|
|||
}
|
||||
}
|
||||
|
||||
if (is_host_sharable && sem_str->Size() != msl_offset) {
|
||||
if (is_host_shareable && sem_str->Size() != msl_offset) {
|
||||
make_indent();
|
||||
add_byte_offset_comment(msl_offset);
|
||||
add_padding(sem_str->Size() - msl_offset);
|
||||
|
|
|
@ -170,9 +170,9 @@ source_set("tint_unittests_core_src") {
|
|||
"../src/program_builder_test.cc",
|
||||
"../src/program_test.cc",
|
||||
"../src/resolver/decoration_validation_test.cc",
|
||||
"../src/resolver/host_sharable_validation_test.cc",
|
||||
"../src/resolver/host_shareable_validation_test.cc",
|
||||
"../src/resolver/intrinsic_test.cc",
|
||||
"../src/resolver/is_host_sharable_test.cc",
|
||||
"../src/resolver/is_host_shareable_test.cc",
|
||||
"../src/resolver/is_storeable_test.cc",
|
||||
"../src/resolver/resolver_test.cc",
|
||||
"../src/resolver/resolver_test_helper.cc",
|
||||
|
|
Loading…
Reference in New Issue