mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-12 15:09:23 +00:00
When enabling the SPIR-V reader or SPIR-V writer we were suppressing -Wnewline-eof, -Wold-style-cast, -Wsign-conversion, and -Wweak-vtables for the `libtint` cmake target and anything that depended on that target. Because we'd build all readers/ writers by default this caused us to never hit those warnings. A recent change to the cmake build sets the Tint backend based on the Dawn backend. So, there is a much higher chance of not building the SPIR-V support if you're on a Mac or Windows machine. This CL removes the suppression of the warnings, adds specific pragmas into the SPIR-V reader code which imports the SPIRV-Tools headers and fixes up the warnings which were then firing due to checking for the new warnings. Change-Id: I0d0be6aa3d0b692e939ce8ff924dfb82c82792fc Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94901 Reviewed-by: Ben Clayton <bclayton@google.com> Auto-Submit: Dan Sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com>
67 lines
2.5 KiB
C++
67 lines
2.5 KiB
C++
// 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/tint/resolver/resolver.h"
|
|
#include "src/tint/resolver/resolver_test_helper.h"
|
|
#include "src/tint/sem/atomic.h"
|
|
#include "src/tint/sem/reference.h"
|
|
|
|
#include "gmock/gmock.h"
|
|
|
|
namespace tint::resolver {
|
|
namespace {
|
|
|
|
struct ResolverAtomicTest : public resolver::TestHelper, public testing::Test {};
|
|
|
|
TEST_F(ResolverAtomicTest, GlobalWorkgroupI32) {
|
|
auto* g = GlobalVar("a", ty.atomic(Source{{12, 34}}, ty.i32()), ast::StorageClass::kWorkgroup);
|
|
|
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
|
ASSERT_TRUE(TypeOf(g)->Is<sem::Reference>());
|
|
auto* atomic = TypeOf(g)->UnwrapRef()->As<sem::Atomic>();
|
|
ASSERT_NE(atomic, nullptr);
|
|
EXPECT_TRUE(atomic->Type()->Is<sem::I32>());
|
|
}
|
|
|
|
TEST_F(ResolverAtomicTest, GlobalWorkgroupU32) {
|
|
auto* g = GlobalVar("a", ty.atomic(Source{{12, 34}}, ty.u32()), ast::StorageClass::kWorkgroup);
|
|
|
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
|
ASSERT_TRUE(TypeOf(g)->Is<sem::Reference>());
|
|
auto* atomic = TypeOf(g)->UnwrapRef()->As<sem::Atomic>();
|
|
ASSERT_NE(atomic, nullptr);
|
|
EXPECT_TRUE(atomic->Type()->Is<sem::U32>());
|
|
}
|
|
|
|
TEST_F(ResolverAtomicTest, GlobalStorageStruct) {
|
|
auto* s = Structure("s", {Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))});
|
|
auto* g = GlobalVar("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
|
|
ast::AttributeList{
|
|
create<ast::BindingAttribute>(0u),
|
|
create<ast::GroupAttribute>(0u),
|
|
});
|
|
|
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
|
ASSERT_TRUE(TypeOf(g)->Is<sem::Reference>());
|
|
auto* str = TypeOf(g)->UnwrapRef()->As<sem::Struct>();
|
|
ASSERT_NE(str, nullptr);
|
|
ASSERT_EQ(str->Members().size(), 1u);
|
|
auto* atomic = str->Members()[0]->Type()->As<sem::Atomic>();
|
|
ASSERT_NE(atomic, nullptr);
|
|
ASSERT_TRUE(atomic->Type()->Is<sem::I32>());
|
|
}
|
|
|
|
} // namespace
|
|
} // namespace tint::resolver
|