text_to_binary.reserved_sampling_test.cpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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(
  27. CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0),
  28. Eq(MakeInstruction(SpvOpImageSparseSampleProjImplicitLod, {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(SpvOpImageSparseSampleProjExplicitLod,
  35. {1, 2, 3, 4, SpvImageOperandsLodMask, 5})));
  36. }
  37. TEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjDrefImplicitLod) {
  38. std::string input =
  39. "%2 = OpImageSparseSampleProjDrefImplicitLod %1 %3 %4 %5\n";
  40. EXPECT_THAT(CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0),
  41. Eq(MakeInstruction(SpvOpImageSparseSampleProjDrefImplicitLod,
  42. {1, 2, 3, 4, 5})));
  43. }
  44. TEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjDrefExplicitLod) {
  45. std::string input =
  46. "%2 = OpImageSparseSampleProjDrefExplicitLod %1 %3 %4 %5 Lod %6\n";
  47. EXPECT_THAT(CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0),
  48. Eq(MakeInstruction(SpvOpImageSparseSampleProjDrefExplicitLod,
  49. {1, 2, 3, 4, 5, SpvImageOperandsLodMask, 6})));
  50. }
  51. } // namespace
  52. } // namespace spvtools