validator_decoration_test: Handle new size / align decorations
Bug: tint:626 Change-Id: Ibaaff85d4cd2e0a0bce05006d2bf74ca884a8db0 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44783 Auto-Submit: Ben Clayton <bclayton@google.com> Commit-Queue: James Price <jrprice@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
parent
935927d0f6
commit
7d80c2783a
|
@ -20,7 +20,9 @@
|
||||||
#include "src/ast/location_decoration.h"
|
#include "src/ast/location_decoration.h"
|
||||||
#include "src/ast/stage_decoration.h"
|
#include "src/ast/stage_decoration.h"
|
||||||
#include "src/ast/struct_block_decoration.h"
|
#include "src/ast/struct_block_decoration.h"
|
||||||
|
#include "src/ast/struct_member_align_decoration.h"
|
||||||
#include "src/ast/struct_member_offset_decoration.h"
|
#include "src/ast/struct_member_offset_decoration.h"
|
||||||
|
#include "src/ast/struct_member_size_decoration.h"
|
||||||
#include "src/ast/workgroup_decoration.h"
|
#include "src/ast/workgroup_decoration.h"
|
||||||
#include "src/validator/validator_test_helper.h"
|
#include "src/validator/validator_test_helper.h"
|
||||||
|
|
||||||
|
@ -29,15 +31,17 @@ namespace {
|
||||||
|
|
||||||
enum class DecorationKind {
|
enum class DecorationKind {
|
||||||
kAccess,
|
kAccess,
|
||||||
|
kAlign,
|
||||||
kBinding,
|
kBinding,
|
||||||
kBuiltin,
|
kBuiltin,
|
||||||
kConstantId,
|
kConstantId,
|
||||||
kGroup,
|
kGroup,
|
||||||
kLocation,
|
kLocation,
|
||||||
|
kOffset,
|
||||||
|
kSize,
|
||||||
kStage,
|
kStage,
|
||||||
kStride,
|
kStride,
|
||||||
kStructBlock,
|
kStructBlock,
|
||||||
kStructMemberOffset,
|
|
||||||
kWorkgroup,
|
kWorkgroup,
|
||||||
};
|
};
|
||||||
struct DecorationTestParams {
|
struct DecorationTestParams {
|
||||||
|
@ -54,26 +58,30 @@ ast::Decoration* createDecoration(ProgramBuilder& builder,
|
||||||
case DecorationKind::kAccess:
|
case DecorationKind::kAccess:
|
||||||
return builder.create<ast::AccessDecoration>(
|
return builder.create<ast::AccessDecoration>(
|
||||||
ast::AccessControl::kReadOnly);
|
ast::AccessControl::kReadOnly);
|
||||||
case DecorationKind::kLocation:
|
case DecorationKind::kAlign:
|
||||||
return builder.create<ast::LocationDecoration>(1);
|
return builder.create<ast::StructMemberAlignDecoration>(4u);
|
||||||
case DecorationKind::kBinding:
|
case DecorationKind::kBinding:
|
||||||
return builder.create<ast::BindingDecoration>(1);
|
return builder.create<ast::BindingDecoration>(1);
|
||||||
case DecorationKind::kGroup:
|
|
||||||
return builder.create<ast::GroupDecoration>(1u);
|
|
||||||
case DecorationKind::kBuiltin:
|
case DecorationKind::kBuiltin:
|
||||||
return builder.create<ast::BuiltinDecoration>(ast::Builtin::kPosition);
|
return builder.create<ast::BuiltinDecoration>(ast::Builtin::kPosition);
|
||||||
case DecorationKind::kWorkgroup:
|
|
||||||
return builder.create<ast::WorkgroupDecoration>(1u, 1u, 1u);
|
|
||||||
case DecorationKind::kStage:
|
|
||||||
return builder.create<ast::StageDecoration>(ast::PipelineStage::kCompute);
|
|
||||||
case DecorationKind::kStructBlock:
|
|
||||||
return builder.create<ast::StructBlockDecoration>();
|
|
||||||
case DecorationKind::kStride:
|
|
||||||
return builder.create<ast::StrideDecoration>(4u);
|
|
||||||
case DecorationKind::kStructMemberOffset:
|
|
||||||
return builder.create<ast::StructMemberOffsetDecoration>(4u);
|
|
||||||
case DecorationKind::kConstantId:
|
case DecorationKind::kConstantId:
|
||||||
return builder.create<ast::ConstantIdDecoration>(0u);
|
return builder.create<ast::ConstantIdDecoration>(0u);
|
||||||
|
case DecorationKind::kGroup:
|
||||||
|
return builder.create<ast::GroupDecoration>(1u);
|
||||||
|
case DecorationKind::kLocation:
|
||||||
|
return builder.create<ast::LocationDecoration>(1);
|
||||||
|
case DecorationKind::kOffset:
|
||||||
|
return builder.create<ast::StructMemberOffsetDecoration>(4u);
|
||||||
|
case DecorationKind::kSize:
|
||||||
|
return builder.create<ast::StructMemberSizeDecoration>(4u);
|
||||||
|
case DecorationKind::kStage:
|
||||||
|
return builder.create<ast::StageDecoration>(ast::PipelineStage::kCompute);
|
||||||
|
case DecorationKind::kStride:
|
||||||
|
return builder.create<ast::StrideDecoration>(4u);
|
||||||
|
case DecorationKind::kStructBlock:
|
||||||
|
return builder.create<ast::StructBlockDecoration>();
|
||||||
|
case DecorationKind::kWorkgroup:
|
||||||
|
return builder.create<ast::WorkgroupDecoration>(1u, 1u, 1u);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -103,16 +111,17 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
ValidatorTest,
|
ValidatorTest,
|
||||||
ArrayDecorationTest,
|
ArrayDecorationTest,
|
||||||
testing::Values(DecorationTestParams{DecorationKind::kAccess, false},
|
testing::Values(DecorationTestParams{DecorationKind::kAccess, false},
|
||||||
|
DecorationTestParams{DecorationKind::kAlign, false},
|
||||||
DecorationTestParams{DecorationKind::kBinding, false},
|
DecorationTestParams{DecorationKind::kBinding, false},
|
||||||
DecorationTestParams{DecorationKind::kBuiltin, false},
|
DecorationTestParams{DecorationKind::kBuiltin, false},
|
||||||
DecorationTestParams{DecorationKind::kConstantId, false},
|
DecorationTestParams{DecorationKind::kConstantId, false},
|
||||||
DecorationTestParams{DecorationKind::kGroup, false},
|
DecorationTestParams{DecorationKind::kGroup, false},
|
||||||
DecorationTestParams{DecorationKind::kLocation, false},
|
DecorationTestParams{DecorationKind::kLocation, false},
|
||||||
|
DecorationTestParams{DecorationKind::kOffset, false},
|
||||||
|
DecorationTestParams{DecorationKind::kSize, false},
|
||||||
DecorationTestParams{DecorationKind::kStage, false},
|
DecorationTestParams{DecorationKind::kStage, false},
|
||||||
DecorationTestParams{DecorationKind::kStride, true},
|
DecorationTestParams{DecorationKind::kStride, true},
|
||||||
DecorationTestParams{DecorationKind::kStructBlock, false},
|
DecorationTestParams{DecorationKind::kStructBlock, false},
|
||||||
DecorationTestParams{DecorationKind::kStructMemberOffset,
|
|
||||||
false},
|
|
||||||
DecorationTestParams{DecorationKind::kWorkgroup, false}));
|
DecorationTestParams{DecorationKind::kWorkgroup, false}));
|
||||||
|
|
||||||
using FunctionDecorationTest = ValidatorDecorationsTestWithParams;
|
using FunctionDecorationTest = ValidatorDecorationsTestWithParams;
|
||||||
|
@ -137,16 +146,17 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
ValidatorTest,
|
ValidatorTest,
|
||||||
FunctionDecorationTest,
|
FunctionDecorationTest,
|
||||||
testing::Values(DecorationTestParams{DecorationKind::kAccess, false},
|
testing::Values(DecorationTestParams{DecorationKind::kAccess, false},
|
||||||
|
DecorationTestParams{DecorationKind::kAlign, false},
|
||||||
DecorationTestParams{DecorationKind::kBinding, false},
|
DecorationTestParams{DecorationKind::kBinding, false},
|
||||||
DecorationTestParams{DecorationKind::kBuiltin, false},
|
DecorationTestParams{DecorationKind::kBuiltin, false},
|
||||||
DecorationTestParams{DecorationKind::kConstantId, false},
|
DecorationTestParams{DecorationKind::kConstantId, false},
|
||||||
DecorationTestParams{DecorationKind::kGroup, false},
|
DecorationTestParams{DecorationKind::kGroup, false},
|
||||||
DecorationTestParams{DecorationKind::kLocation, false},
|
DecorationTestParams{DecorationKind::kLocation, false},
|
||||||
|
DecorationTestParams{DecorationKind::kOffset, false},
|
||||||
|
DecorationTestParams{DecorationKind::kSize, false},
|
||||||
// Skip kStage as we always apply it in this test
|
// Skip kStage as we always apply it in this test
|
||||||
DecorationTestParams{DecorationKind::kStride, false},
|
DecorationTestParams{DecorationKind::kStride, false},
|
||||||
DecorationTestParams{DecorationKind::kStructBlock, false},
|
DecorationTestParams{DecorationKind::kStructBlock, false},
|
||||||
DecorationTestParams{DecorationKind::kStructMemberOffset,
|
|
||||||
false},
|
|
||||||
DecorationTestParams{DecorationKind::kWorkgroup, true}));
|
DecorationTestParams{DecorationKind::kWorkgroup, true}));
|
||||||
|
|
||||||
using FunctionReturnTypeDecorationTest = ValidatorDecorationsTestWithParams;
|
using FunctionReturnTypeDecorationTest = ValidatorDecorationsTestWithParams;
|
||||||
|
@ -172,16 +182,17 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
ValidatorTest,
|
ValidatorTest,
|
||||||
FunctionReturnTypeDecorationTest,
|
FunctionReturnTypeDecorationTest,
|
||||||
testing::Values(DecorationTestParams{DecorationKind::kAccess, false},
|
testing::Values(DecorationTestParams{DecorationKind::kAccess, false},
|
||||||
|
DecorationTestParams{DecorationKind::kAlign, false},
|
||||||
DecorationTestParams{DecorationKind::kBinding, false},
|
DecorationTestParams{DecorationKind::kBinding, false},
|
||||||
DecorationTestParams{DecorationKind::kBuiltin, true},
|
DecorationTestParams{DecorationKind::kBuiltin, true},
|
||||||
DecorationTestParams{DecorationKind::kConstantId, false},
|
DecorationTestParams{DecorationKind::kConstantId, false},
|
||||||
DecorationTestParams{DecorationKind::kGroup, false},
|
DecorationTestParams{DecorationKind::kGroup, false},
|
||||||
DecorationTestParams{DecorationKind::kLocation, true},
|
DecorationTestParams{DecorationKind::kLocation, true},
|
||||||
|
DecorationTestParams{DecorationKind::kOffset, false},
|
||||||
|
DecorationTestParams{DecorationKind::kSize, false},
|
||||||
DecorationTestParams{DecorationKind::kStage, false},
|
DecorationTestParams{DecorationKind::kStage, false},
|
||||||
DecorationTestParams{DecorationKind::kStride, false},
|
DecorationTestParams{DecorationKind::kStride, false},
|
||||||
DecorationTestParams{DecorationKind::kStructBlock, false},
|
DecorationTestParams{DecorationKind::kStructBlock, false},
|
||||||
DecorationTestParams{DecorationKind::kStructMemberOffset,
|
|
||||||
false},
|
|
||||||
DecorationTestParams{DecorationKind::kWorkgroup, false}));
|
DecorationTestParams{DecorationKind::kWorkgroup, false}));
|
||||||
|
|
||||||
using StructDecorationTest = ValidatorDecorationsTestWithParams;
|
using StructDecorationTest = ValidatorDecorationsTestWithParams;
|
||||||
|
@ -206,16 +217,17 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
ValidatorTest,
|
ValidatorTest,
|
||||||
StructDecorationTest,
|
StructDecorationTest,
|
||||||
testing::Values(DecorationTestParams{DecorationKind::kAccess, false},
|
testing::Values(DecorationTestParams{DecorationKind::kAccess, false},
|
||||||
|
DecorationTestParams{DecorationKind::kAlign, false},
|
||||||
DecorationTestParams{DecorationKind::kBinding, false},
|
DecorationTestParams{DecorationKind::kBinding, false},
|
||||||
DecorationTestParams{DecorationKind::kBuiltin, false},
|
DecorationTestParams{DecorationKind::kBuiltin, false},
|
||||||
DecorationTestParams{DecorationKind::kConstantId, false},
|
DecorationTestParams{DecorationKind::kConstantId, false},
|
||||||
DecorationTestParams{DecorationKind::kGroup, false},
|
DecorationTestParams{DecorationKind::kGroup, false},
|
||||||
DecorationTestParams{DecorationKind::kLocation, false},
|
DecorationTestParams{DecorationKind::kLocation, false},
|
||||||
|
DecorationTestParams{DecorationKind::kOffset, false},
|
||||||
|
DecorationTestParams{DecorationKind::kSize, false},
|
||||||
DecorationTestParams{DecorationKind::kStage, false},
|
DecorationTestParams{DecorationKind::kStage, false},
|
||||||
DecorationTestParams{DecorationKind::kStride, false},
|
DecorationTestParams{DecorationKind::kStride, false},
|
||||||
DecorationTestParams{DecorationKind::kStructBlock, true},
|
DecorationTestParams{DecorationKind::kStructBlock, true},
|
||||||
DecorationTestParams{DecorationKind::kStructMemberOffset,
|
|
||||||
false},
|
|
||||||
DecorationTestParams{DecorationKind::kWorkgroup, false}));
|
DecorationTestParams{DecorationKind::kWorkgroup, false}));
|
||||||
|
|
||||||
using StructMemberDecorations = ValidatorDecorationsTestWithParams;
|
using StructMemberDecorations = ValidatorDecorationsTestWithParams;
|
||||||
|
@ -241,16 +253,17 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
ValidatorTest,
|
ValidatorTest,
|
||||||
StructMemberDecorations,
|
StructMemberDecorations,
|
||||||
testing::Values(DecorationTestParams{DecorationKind::kAccess, false},
|
testing::Values(DecorationTestParams{DecorationKind::kAccess, false},
|
||||||
|
DecorationTestParams{DecorationKind::kAlign, true},
|
||||||
DecorationTestParams{DecorationKind::kBinding, false},
|
DecorationTestParams{DecorationKind::kBinding, false},
|
||||||
DecorationTestParams{DecorationKind::kBuiltin, true},
|
DecorationTestParams{DecorationKind::kBuiltin, true},
|
||||||
DecorationTestParams{DecorationKind::kConstantId, false},
|
DecorationTestParams{DecorationKind::kConstantId, false},
|
||||||
DecorationTestParams{DecorationKind::kGroup, false},
|
DecorationTestParams{DecorationKind::kGroup, false},
|
||||||
DecorationTestParams{DecorationKind::kLocation, true},
|
DecorationTestParams{DecorationKind::kLocation, true},
|
||||||
|
DecorationTestParams{DecorationKind::kOffset, true},
|
||||||
|
DecorationTestParams{DecorationKind::kSize, true},
|
||||||
DecorationTestParams{DecorationKind::kStage, false},
|
DecorationTestParams{DecorationKind::kStage, false},
|
||||||
DecorationTestParams{DecorationKind::kStride, false},
|
DecorationTestParams{DecorationKind::kStride, false},
|
||||||
DecorationTestParams{DecorationKind::kStructBlock, false},
|
DecorationTestParams{DecorationKind::kStructBlock, false},
|
||||||
DecorationTestParams{DecorationKind::kStructMemberOffset,
|
|
||||||
true},
|
|
||||||
DecorationTestParams{DecorationKind::kWorkgroup, false}));
|
DecorationTestParams{DecorationKind::kWorkgroup, false}));
|
||||||
|
|
||||||
using VariableDecorationTest = ValidatorDecorationsTestWithParams;
|
using VariableDecorationTest = ValidatorDecorationsTestWithParams;
|
||||||
|
@ -273,16 +286,17 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
ValidatorTest,
|
ValidatorTest,
|
||||||
VariableDecorationTest,
|
VariableDecorationTest,
|
||||||
testing::Values(DecorationTestParams{DecorationKind::kAccess, false},
|
testing::Values(DecorationTestParams{DecorationKind::kAccess, false},
|
||||||
|
DecorationTestParams{DecorationKind::kAlign, false},
|
||||||
DecorationTestParams{DecorationKind::kBinding, true},
|
DecorationTestParams{DecorationKind::kBinding, true},
|
||||||
DecorationTestParams{DecorationKind::kBuiltin, true},
|
DecorationTestParams{DecorationKind::kBuiltin, true},
|
||||||
DecorationTestParams{DecorationKind::kConstantId, true},
|
DecorationTestParams{DecorationKind::kConstantId, true},
|
||||||
DecorationTestParams{DecorationKind::kGroup, true},
|
DecorationTestParams{DecorationKind::kGroup, true},
|
||||||
DecorationTestParams{DecorationKind::kLocation, true},
|
DecorationTestParams{DecorationKind::kLocation, true},
|
||||||
|
DecorationTestParams{DecorationKind::kOffset, false},
|
||||||
|
DecorationTestParams{DecorationKind::kSize, false},
|
||||||
DecorationTestParams{DecorationKind::kStage, false},
|
DecorationTestParams{DecorationKind::kStage, false},
|
||||||
DecorationTestParams{DecorationKind::kStride, false},
|
DecorationTestParams{DecorationKind::kStride, false},
|
||||||
DecorationTestParams{DecorationKind::kStructBlock, false},
|
DecorationTestParams{DecorationKind::kStructBlock, false},
|
||||||
DecorationTestParams{DecorationKind::kStructMemberOffset,
|
|
||||||
false},
|
|
||||||
DecorationTestParams{DecorationKind::kWorkgroup, false}));
|
DecorationTestParams{DecorationKind::kWorkgroup, false}));
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -23,7 +23,9 @@
|
||||||
#include "src/ast/stage_decoration.h"
|
#include "src/ast/stage_decoration.h"
|
||||||
#include "src/ast/stride_decoration.h"
|
#include "src/ast/stride_decoration.h"
|
||||||
#include "src/ast/struct_block_decoration.h"
|
#include "src/ast/struct_block_decoration.h"
|
||||||
|
#include "src/ast/struct_member_align_decoration.h"
|
||||||
#include "src/ast/struct_member_offset_decoration.h"
|
#include "src/ast/struct_member_offset_decoration.h"
|
||||||
|
#include "src/ast/struct_member_size_decoration.h"
|
||||||
#include "src/ast/uint_literal.h"
|
#include "src/ast/uint_literal.h"
|
||||||
#include "src/ast/workgroup_decoration.h"
|
#include "src/ast/workgroup_decoration.h"
|
||||||
#include "src/semantic/call.h"
|
#include "src/semantic/call.h"
|
||||||
|
@ -127,7 +129,9 @@ bool ValidatorImpl::ValidateConstructedType(const type::Type* type) {
|
||||||
for (auto* deco : member->decorations()) {
|
for (auto* deco : member->decorations()) {
|
||||||
if (!(deco->Is<ast::BuiltinDecoration>() ||
|
if (!(deco->Is<ast::BuiltinDecoration>() ||
|
||||||
deco->Is<ast::LocationDecoration>() ||
|
deco->Is<ast::LocationDecoration>() ||
|
||||||
deco->Is<ast::StructMemberOffsetDecoration>())) {
|
deco->Is<ast::StructMemberOffsetDecoration>() ||
|
||||||
|
deco->Is<ast::StructMemberSizeDecoration>() ||
|
||||||
|
deco->Is<ast::StructMemberAlignDecoration>())) {
|
||||||
add_error(deco->source(),
|
add_error(deco->source(),
|
||||||
"decoration is not valid for structure members");
|
"decoration is not valid for structure members");
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue