2018-03-14 17:06:18 +00:00
|
|
|
// Copyright (c) 2017 Google Inc.
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
// Validation tests for illegal instructions
|
|
|
|
|
2018-08-03 19:06:09 +00:00
|
|
|
#include <string>
|
2018-03-14 17:06:18 +00:00
|
|
|
|
|
|
|
#include "gmock/gmock.h"
|
2018-08-03 19:06:09 +00:00
|
|
|
#include "test/test_fixture.h"
|
|
|
|
#include "test/unit_spirv.h"
|
2018-03-14 17:06:18 +00:00
|
|
|
|
2018-07-11 13:24:49 +00:00
|
|
|
namespace spvtools {
|
2018-03-14 17:06:18 +00:00
|
|
|
namespace {
|
|
|
|
|
2018-06-19 13:54:33 +00:00
|
|
|
using ::spvtest::MakeInstruction;
|
2018-03-14 17:06:18 +00:00
|
|
|
using ::testing::Eq;
|
|
|
|
|
2018-06-19 13:54:33 +00:00
|
|
|
using ReservedSamplingInstTest = RoundTripTest;
|
2018-03-14 17:06:18 +00:00
|
|
|
|
|
|
|
TEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjImplicitLod) {
|
2018-06-19 13:54:33 +00:00
|
|
|
std::string input = "%2 = OpImageSparseSampleProjImplicitLod %1 %3 %4\n";
|
2022-11-04 21:27:10 +00:00
|
|
|
EXPECT_THAT(CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0),
|
|
|
|
Eq(MakeInstruction(spv::Op::OpImageSparseSampleProjImplicitLod,
|
|
|
|
{1, 2, 3, 4})));
|
2018-03-14 17:06:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjExplicitLod) {
|
2018-06-19 13:54:33 +00:00
|
|
|
std::string input =
|
|
|
|
"%2 = OpImageSparseSampleProjExplicitLod %1 %3 %4 Lod %5\n";
|
|
|
|
EXPECT_THAT(CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0),
|
2022-11-04 21:27:10 +00:00
|
|
|
Eq(MakeInstruction(
|
|
|
|
spv::Op::OpImageSparseSampleProjExplicitLod,
|
|
|
|
{1, 2, 3, 4, (uint32_t)spv::ImageOperandsMask::Lod, 5})));
|
2018-03-14 17:06:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjDrefImplicitLod) {
|
2018-06-19 13:54:33 +00:00
|
|
|
std::string input =
|
|
|
|
"%2 = OpImageSparseSampleProjDrefImplicitLod %1 %3 %4 %5\n";
|
2022-11-04 21:27:10 +00:00
|
|
|
EXPECT_THAT(
|
|
|
|
CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0),
|
|
|
|
Eq(MakeInstruction(spv::Op::OpImageSparseSampleProjDrefImplicitLod,
|
|
|
|
{1, 2, 3, 4, 5})));
|
2018-03-14 17:06:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjDrefExplicitLod) {
|
2018-06-19 13:54:33 +00:00
|
|
|
std::string input =
|
|
|
|
"%2 = OpImageSparseSampleProjDrefExplicitLod %1 %3 %4 %5 Lod %6\n";
|
|
|
|
EXPECT_THAT(CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0),
|
2022-11-04 21:27:10 +00:00
|
|
|
Eq(MakeInstruction(
|
|
|
|
spv::Op::OpImageSparseSampleProjDrefExplicitLod,
|
|
|
|
{1, 2, 3, 4, 5, (uint32_t)spv::ImageOperandsMask::Lod, 6})));
|
2018-03-14 17:06:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
2018-07-11 13:24:49 +00:00
|
|
|
} // namespace spvtools
|