1fd4e5da5Sopenharmony_ci// Copyright (c) 2017 Google Inc. 2fd4e5da5Sopenharmony_ci// 3fd4e5da5Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License"); 4fd4e5da5Sopenharmony_ci// you may not use this file except in compliance with the License. 5fd4e5da5Sopenharmony_ci// You may obtain a copy of the License at 6fd4e5da5Sopenharmony_ci// 7fd4e5da5Sopenharmony_ci// http://www.apache.org/licenses/LICENSE-2.0 8fd4e5da5Sopenharmony_ci// 9fd4e5da5Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software 10fd4e5da5Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS, 11fd4e5da5Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12fd4e5da5Sopenharmony_ci// See the License for the specific language governing permissions and 13fd4e5da5Sopenharmony_ci// limitations under the License. 14fd4e5da5Sopenharmony_ci 15fd4e5da5Sopenharmony_ci// Validation tests for illegal instructions 16fd4e5da5Sopenharmony_ci 17fd4e5da5Sopenharmony_ci#include <string> 18fd4e5da5Sopenharmony_ci 19fd4e5da5Sopenharmony_ci#include "gmock/gmock.h" 20fd4e5da5Sopenharmony_ci#include "test/test_fixture.h" 21fd4e5da5Sopenharmony_ci#include "test/unit_spirv.h" 22fd4e5da5Sopenharmony_ci 23fd4e5da5Sopenharmony_cinamespace spvtools { 24fd4e5da5Sopenharmony_cinamespace { 25fd4e5da5Sopenharmony_ci 26fd4e5da5Sopenharmony_ciusing ::spvtest::MakeInstruction; 27fd4e5da5Sopenharmony_ciusing ::testing::Eq; 28fd4e5da5Sopenharmony_ci 29fd4e5da5Sopenharmony_ciusing ReservedSamplingInstTest = RoundTripTest; 30fd4e5da5Sopenharmony_ci 31fd4e5da5Sopenharmony_ciTEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjImplicitLod) { 32fd4e5da5Sopenharmony_ci std::string input = "%2 = OpImageSparseSampleProjImplicitLod %1 %3 %4\n"; 33fd4e5da5Sopenharmony_ci EXPECT_THAT(CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0), 34fd4e5da5Sopenharmony_ci Eq(MakeInstruction(spv::Op::OpImageSparseSampleProjImplicitLod, 35fd4e5da5Sopenharmony_ci {1, 2, 3, 4}))); 36fd4e5da5Sopenharmony_ci} 37fd4e5da5Sopenharmony_ci 38fd4e5da5Sopenharmony_ciTEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjExplicitLod) { 39fd4e5da5Sopenharmony_ci std::string input = 40fd4e5da5Sopenharmony_ci "%2 = OpImageSparseSampleProjExplicitLod %1 %3 %4 Lod %5\n"; 41fd4e5da5Sopenharmony_ci EXPECT_THAT(CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0), 42fd4e5da5Sopenharmony_ci Eq(MakeInstruction( 43fd4e5da5Sopenharmony_ci spv::Op::OpImageSparseSampleProjExplicitLod, 44fd4e5da5Sopenharmony_ci {1, 2, 3, 4, (uint32_t)spv::ImageOperandsMask::Lod, 5}))); 45fd4e5da5Sopenharmony_ci} 46fd4e5da5Sopenharmony_ci 47fd4e5da5Sopenharmony_ciTEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjDrefImplicitLod) { 48fd4e5da5Sopenharmony_ci std::string input = 49fd4e5da5Sopenharmony_ci "%2 = OpImageSparseSampleProjDrefImplicitLod %1 %3 %4 %5\n"; 50fd4e5da5Sopenharmony_ci EXPECT_THAT( 51fd4e5da5Sopenharmony_ci CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0), 52fd4e5da5Sopenharmony_ci Eq(MakeInstruction(spv::Op::OpImageSparseSampleProjDrefImplicitLod, 53fd4e5da5Sopenharmony_ci {1, 2, 3, 4, 5}))); 54fd4e5da5Sopenharmony_ci} 55fd4e5da5Sopenharmony_ci 56fd4e5da5Sopenharmony_ciTEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjDrefExplicitLod) { 57fd4e5da5Sopenharmony_ci std::string input = 58fd4e5da5Sopenharmony_ci "%2 = OpImageSparseSampleProjDrefExplicitLod %1 %3 %4 %5 Lod %6\n"; 59fd4e5da5Sopenharmony_ci EXPECT_THAT(CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0), 60fd4e5da5Sopenharmony_ci Eq(MakeInstruction( 61fd4e5da5Sopenharmony_ci spv::Op::OpImageSparseSampleProjDrefExplicitLod, 62fd4e5da5Sopenharmony_ci {1, 2, 3, 4, 5, (uint32_t)spv::ImageOperandsMask::Lod, 6}))); 63fd4e5da5Sopenharmony_ci} 64fd4e5da5Sopenharmony_ci 65fd4e5da5Sopenharmony_ci} // namespace 66fd4e5da5Sopenharmony_ci} // namespace spvtools 67