2016-01-07 18:44:22 +00:00
|
|
|
// Copyright (c) 2015-2016 The Khronos Group Inc.
|
2015-09-14 21:07:11 +00:00
|
|
|
//
|
2016-09-01 19:33:59 +00:00
|
|
|
// 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
|
2015-09-14 21:07:11 +00:00
|
|
|
//
|
2016-09-01 19:33:59 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2015-09-14 21:07:11 +00:00
|
|
|
//
|
2016-09-01 19:33:59 +00:00
|
|
|
// 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.
|
2015-09-14 21:07:11 +00:00
|
|
|
|
|
|
|
// Assembler tests for instructions in the "Group Instrucions" section of the
|
|
|
|
// SPIR-V spec.
|
|
|
|
|
2018-08-03 19:06:09 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2015-09-14 21:07:11 +00:00
|
|
|
|
|
|
|
#include "gmock/gmock.h"
|
2018-08-03 19:06:09 +00:00
|
|
|
#include "test/test_fixture.h"
|
|
|
|
#include "test/unit_spirv.h"
|
2015-09-14 21:07:11 +00:00
|
|
|
|
2018-07-11 13:24:49 +00:00
|
|
|
namespace spvtools {
|
2015-09-14 21:07:11 +00:00
|
|
|
namespace {
|
|
|
|
|
2015-10-01 20:58:17 +00:00
|
|
|
using spvtest::EnumCase;
|
2015-09-14 21:07:11 +00:00
|
|
|
using spvtest::MakeInstruction;
|
|
|
|
using ::testing::Eq;
|
|
|
|
|
|
|
|
// Test GroupOperation enum
|
|
|
|
|
2015-09-21 15:36:44 +00:00
|
|
|
using GroupOperationTest = spvtest::TextToBinaryTestBase<
|
2022-11-04 21:27:10 +00:00
|
|
|
::testing::TestWithParam<EnumCase<spv::GroupOperation>>>;
|
2015-09-14 21:07:11 +00:00
|
|
|
|
|
|
|
TEST_P(GroupOperationTest, AnyGroupOperation) {
|
2015-10-13 16:46:13 +00:00
|
|
|
const std::string input =
|
2015-09-21 21:16:45 +00:00
|
|
|
"%result = OpGroupIAdd %type %scope " + GetParam().name() + " %x";
|
2022-11-04 21:27:10 +00:00
|
|
|
EXPECT_THAT(CompiledInstructions(input),
|
|
|
|
Eq(MakeInstruction(spv::Op::OpGroupIAdd,
|
|
|
|
{1, 2, 3, (uint32_t)GetParam().value(), 4})));
|
2015-09-14 21:07:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// clang-format off
|
2022-11-04 21:27:10 +00:00
|
|
|
#define CASE(NAME) { spv::GroupOperation::NAME, #NAME}
|
2019-01-29 23:56:52 +00:00
|
|
|
INSTANTIATE_TEST_SUITE_P(TextToBinaryGroupOperation, GroupOperationTest,
|
2022-11-04 21:27:10 +00:00
|
|
|
::testing::ValuesIn(std::vector<EnumCase<spv::GroupOperation>>{
|
2015-09-14 21:07:11 +00:00
|
|
|
CASE(Reduce),
|
|
|
|
CASE(InclusiveScan),
|
|
|
|
CASE(ExclusiveScan),
|
2019-01-29 23:56:52 +00:00
|
|
|
}));
|
2015-09-14 21:07:11 +00:00
|
|
|
#undef CASE
|
|
|
|
// clang-format on
|
|
|
|
|
2015-10-13 20:32:38 +00:00
|
|
|
TEST_F(GroupOperationTest, WrongGroupOperation) {
|
|
|
|
EXPECT_THAT(CompileFailure("%r = OpGroupUMin %t %e xxyyzz %x"),
|
|
|
|
Eq("Invalid group operation 'xxyyzz'."));
|
|
|
|
}
|
|
|
|
|
2015-11-11 17:32:21 +00:00
|
|
|
// TODO(dneto): OpGroupAsyncCopy
|
|
|
|
// TODO(dneto): OpGroupWaitEvents
|
2015-09-14 21:07:11 +00:00
|
|
|
// TODO(dneto): OpGroupAll
|
|
|
|
// TODO(dneto): OpGroupAny
|
|
|
|
// TODO(dneto): OpGroupBroadcast
|
|
|
|
// TODO(dneto): OpGroupIAdd
|
|
|
|
// TODO(dneto): OpGroupFAdd
|
|
|
|
// TODO(dneto): OpGroupFMin
|
|
|
|
// TODO(dneto): OpGroupUMin
|
|
|
|
// TODO(dneto): OpGroupSMin
|
|
|
|
// TODO(dneto): OpGroupFMax
|
|
|
|
// TODO(dneto): OpGroupUMax
|
|
|
|
// TODO(dneto): OpGroupSMax
|
|
|
|
|
2018-07-11 13:24:49 +00:00
|
|
|
} // namespace
|
|
|
|
} // namespace spvtools
|