Fixup various warnings in Tint which were accidentally suppressed.

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>
This commit is contained in:
dan sinclair
2022-06-29 14:38:15 +00:00
committed by Dawn LUCI CQ
parent ad10eb59d1
commit 3a2a279714
88 changed files with 577 additions and 513 deletions

View File

@@ -225,19 +225,21 @@ struct CombineSamplers::State {
// Replace all texture builtin calls.
if (auto* builtin = call->Target()->As<sem::Builtin>()) {
const auto& signature = builtin->Signature();
int sampler_index = signature.IndexOf(sem::ParameterUsage::kSampler);
int texture_index = signature.IndexOf(sem::ParameterUsage::kTexture);
auto sampler_index = signature.IndexOf(sem::ParameterUsage::kSampler);
auto texture_index = signature.IndexOf(sem::ParameterUsage::kTexture);
if (texture_index == -1) {
return nullptr;
}
const sem::Expression* texture = call->Arguments()[texture_index];
const sem::Expression* texture =
call->Arguments()[static_cast<size_t>(texture_index)];
// We don't want to combine storage textures with anything, since
// they never have associated samplers in GLSL.
if (texture->Type()->UnwrapRef()->Is<sem::StorageTexture>()) {
return nullptr;
}
const sem::Expression* sampler =
sampler_index != -1 ? call->Arguments()[sampler_index] : nullptr;
sampler_index != -1 ? call->Arguments()[static_cast<size_t>(sampler_index)]
: nullptr;
auto* texture_var = texture->As<sem::VariableUser>()->Variable();
auto* sampler_var =
sampler ? sampler->As<sem::VariableUser>()->Variable() : nullptr;

View File

@@ -377,10 +377,10 @@ struct DecomposeMemoryAccess::State {
auto* lhs_lit = tint::As<OffsetLiteral>(lhs);
auto* rhs_lit = tint::As<OffsetLiteral>(rhs);
if (lhs_lit && lhs_lit->literal == 0) {
return offsets_.Create<OffsetLiteral>(0);
return offsets_.Create<OffsetLiteral>(0u);
}
if (rhs_lit && rhs_lit->literal == 0) {
return offsets_.Create<OffsetLiteral>(0);
return offsets_.Create<OffsetLiteral>(0u);
}
if (lhs_lit && lhs_lit->literal == 1) {
return rhs;
@@ -831,7 +831,7 @@ void DecomposeMemoryAccess::Run(CloneContext& ctx, const DataMap&, DataMap&) con
if (swizzle->Indices().size() == 1) {
if (auto access = state.TakeAccess(accessor->structure)) {
auto* vec_ty = access.type->As<sem::Vector>();
auto* offset = state.Mul(vec_ty->type()->Size(), swizzle->Indices()[0]);
auto* offset = state.Mul(vec_ty->type()->Size(), swizzle->Indices()[0u]);
state.AddAccess(accessor, {
access.var,
state.Add(access.offset, offset),

View File

@@ -71,8 +71,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformMatrix) {
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
b.create<ast::StructMemberOffsetAttribute>(16),
b.create<ast::StrideAttribute>(32),
b.create<ast::StructMemberOffsetAttribute>(16u),
b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
@@ -127,8 +127,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformColumn) {
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
b.create<ast::StructMemberOffsetAttribute>(16),
b.create<ast::StrideAttribute>(32),
b.create<ast::StructMemberOffsetAttribute>(16u),
b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
@@ -180,8 +180,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformMatrix_DefaultStride) {
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
b.create<ast::StructMemberOffsetAttribute>(16),
b.create<ast::StrideAttribute>(8),
b.create<ast::StructMemberOffsetAttribute>(16u),
b.create<ast::StrideAttribute>(8u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
@@ -233,8 +233,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageMatrix) {
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
b.create<ast::StructMemberOffsetAttribute>(8),
b.create<ast::StrideAttribute>(32),
b.create<ast::StructMemberOffsetAttribute>(8u),
b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
@@ -290,8 +290,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageColumn) {
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
b.create<ast::StructMemberOffsetAttribute>(16),
b.create<ast::StrideAttribute>(32),
b.create<ast::StructMemberOffsetAttribute>(16u),
b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
@@ -344,8 +344,8 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageMatrix) {
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
b.create<ast::StructMemberOffsetAttribute>(8),
b.create<ast::StrideAttribute>(32),
b.create<ast::StructMemberOffsetAttribute>(8u),
b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
@@ -402,8 +402,8 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageColumn) {
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
b.create<ast::StructMemberOffsetAttribute>(8),
b.create<ast::StrideAttribute>(32),
b.create<ast::StructMemberOffsetAttribute>(8u),
b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
@@ -461,8 +461,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadWriteViaPointerLets) {
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
b.create<ast::StructMemberOffsetAttribute>(8),
b.create<ast::StrideAttribute>(32),
b.create<ast::StructMemberOffsetAttribute>(8u),
b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
@@ -532,8 +532,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadPrivateMatrix) {
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
b.create<ast::StructMemberOffsetAttribute>(8),
b.create<ast::StrideAttribute>(32),
b.create<ast::StructMemberOffsetAttribute>(8u),
b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
@@ -585,8 +585,8 @@ TEST_F(DecomposeStridedMatrixTest, WritePrivateMatrix) {
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
b.create<ast::StructMemberOffsetAttribute>(8),
b.create<ast::StrideAttribute>(32),
b.create<ast::StructMemberOffsetAttribute>(8u),
b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});

View File

@@ -223,9 +223,9 @@ struct Robustness::State {
auto array_idx = signature.IndexOf(sem::ParameterUsage::kArrayIndex);
auto level_idx = signature.IndexOf(sem::ParameterUsage::kLevel);
auto* texture_arg = expr->args[texture_idx];
auto* coords_arg = expr->args[coords_idx];
auto* coords_ty = builtin->Parameters()[coords_idx]->Type();
auto* texture_arg = expr->args[static_cast<size_t>(texture_idx)];
auto* coords_arg = expr->args[static_cast<size_t>(coords_idx)];
auto* coords_ty = builtin->Parameters()[static_cast<size_t>(coords_idx)]->Type();
// If the level is provided, then we need to clamp this. As the level is
// used by textureDimensions() and the texture[Load|Store]() calls, we need
@@ -235,7 +235,7 @@ struct Robustness::State {
std::function<const ast::Expression*()> level_arg;
if (level_idx >= 0) {
level_arg = [&] {
auto* arg = expr->args[level_idx];
auto* arg = expr->args[static_cast<size_t>(level_idx)];
auto* num_levels = b.Call("textureNumLevels", ctx.Clone(texture_arg));
auto* zero = b.Expr(0_i);
auto* max = ctx.dst->Sub(num_levels, 1_i);
@@ -258,7 +258,7 @@ struct Robustness::State {
// Clamp the array_index argument, if provided
if (array_idx >= 0) {
auto* arg = expr->args[array_idx];
auto* arg = expr->args[static_cast<size_t>(array_idx)];
auto* num_layers = b.Call("textureNumLayers", ctx.Clone(texture_arg));
auto* zero = b.Expr(0_i);
auto* max = ctx.dst->Sub(num_layers, 1_i);
@@ -268,7 +268,7 @@ struct Robustness::State {
// Clamp the level argument, if provided
if (level_idx >= 0) {
auto* arg = expr->args[level_idx];
auto* arg = expr->args[static_cast<size_t>(level_idx)];
ctx.Replace(arg, level_arg ? level_arg() : ctx.dst->Expr(0_i));
}