text_to_binary.reserved_sampling_test.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. // Validation tests for illegal instructions
  15. #include <string>
  16. #include "gmock/gmock.h"
  17. #include "test/test_fixture.h"
  18. #include "test/unit_spirv.h"
  19. namespace spvtools {
  20. namespace {
  21. using ::spvtest::MakeInstruction;
  22. using ::testing::Eq;
  23. using ReservedSamplingInstTest = RoundTripTest;
  24. TEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjImplicitLod) {
  25. std::string input = "%2 = OpImageSparseSampleProjImplicitLod %1 %3 %4\n";
  26. EXPECT_THAT(CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0),
  27. Eq(MakeInstruction(spv::Op::OpImageSparseSampleProjImplicitLod,
  28. {1, 2, 3, 4})));
  29. }
  30. TEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjExplicitLod) {
  31. std::string input =
  32. "%2 = OpImageSparseSampleProjExplicitLod %1 %3 %4 Lod %5\n";
  33. EXPECT_THAT(CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0),
  34. Eq(MakeInstruction(
  35. spv::Op::OpImageSparseSampleProjExplicitLod,
  36. {1, 2, 3, 4, (uint32_t)spv::ImageOperandsMask::Lod, 5})));
  37. }
  38. TEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjDrefImplicitLod) {
  39. std::string input =
  40. "%2 = OpImageSparseSampleProjDrefImplicitLod %1 %3 %4 %5\n";
  41. EXPECT_THAT(
  42. CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0),
  43. Eq(MakeInstruction(spv::Op::OpImageSparseSampleProjDrefImplicitLod,
  44. {1, 2, 3, 4, 5})));
  45. }
  46. TEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjDrefExplicitLod) {
  47. std::string input =
  48. "%2 = OpImageSparseSampleProjDrefExplicitLod %1 %3 %4 %5 Lod %6\n";
  49. EXPECT_THAT(CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0),
  50. Eq(MakeInstruction(
  51. spv::Op::OpImageSparseSampleProjDrefExplicitLod,
  52. {1, 2, 3, 4, 5, (uint32_t)spv::ImageOperandsMask::Lod, 6})));
  53. }
  54. } // namespace
  55. } // namespace spvtools