blob: 42e4e2aeb18d7191cbc9baae0ea2c5a40ce0dde5 [file] [log] [blame]
Lei Zhang1ef6b192018-03-14 13:06:18 -04001// 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 sinclaireda2cfb2018-08-03 15:06:09 -040017#include <string>
Lei Zhang1ef6b192018-03-14 13:06:18 -040018
19#include "gmock/gmock.h"
dan sinclaireda2cfb2018-08-03 15:06:09 -040020#include "test/test_fixture.h"
21#include "test/unit_spirv.h"
Lei Zhang1ef6b192018-03-14 13:06:18 -040022
dan sinclair2cce2c52018-07-11 09:24:49 -040023namespace spvtools {
Lei Zhang1ef6b192018-03-14 13:06:18 -040024namespace {
25
David Neto8d65c892018-06-19 09:54:33 -040026using ::spvtest::MakeInstruction;
Lei Zhang1ef6b192018-03-14 13:06:18 -040027using ::testing::Eq;
28
David Neto8d65c892018-06-19 09:54:33 -040029using ReservedSamplingInstTest = RoundTripTest;
Lei Zhang1ef6b192018-03-14 13:06:18 -040030
31TEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjImplicitLod) {
David Neto8d65c892018-06-19 09:54:33 -040032 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 Zhang1ef6b192018-03-14 13:06:18 -040036}
37
38TEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjExplicitLod) {
David Neto8d65c892018-06-19 09:54:33 -040039 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 Zhang1ef6b192018-03-14 13:06:18 -040044}
45
46TEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjDrefImplicitLod) {
David Neto8d65c892018-06-19 09:54:33 -040047 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 Zhang1ef6b192018-03-14 13:06:18 -040052}
53
54TEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjDrefExplicitLod) {
David Neto8d65c892018-06-19 09:54:33 -040055 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 Zhang1ef6b192018-03-14 13:06:18 -040060}
61
62} // namespace
dan sinclair2cce2c52018-07-11 09:24:49 -040063} // namespace spvtools