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