From e8e3712c3b81fc2a2882feafae0d1cbfaf5ff115 Mon Sep 17 00:00:00 2001 From: David Neto Date: Fri, 11 Sep 2015 13:55:57 -0400 Subject: [PATCH] Assembler test for OpExecutionMode --- test/TextToBinary.ModeSetting.cpp | 67 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/test/TextToBinary.ModeSetting.cpp b/test/TextToBinary.ModeSetting.cpp index ab5ebb6..803e3c2 100644 --- a/test/TextToBinary.ModeSetting.cpp +++ b/test/TextToBinary.ModeSetting.cpp @@ -120,6 +120,73 @@ INSTANTIATE_TEST_CASE_P(TextToBinaryEntryPoint, OpEntryPointTest, #undef CASE // clang-format on +// Test OpExecutionMode + +// A single test case for a simple OpExecutionMode. +// An execution mode has no operands, or just literal numbers as operands. +struct ExecutionModeCase { + const spv::ExecutionMode mode_value; + const std::string mode_name; + const std::vector operands; +}; + +using OpExecutionModeTest = test_fixture::TextToBinaryTestBase< + ::testing::TestWithParam>; + +TEST_P(OpExecutionModeTest, AnyExecutionMode) { + // This string should assemble, but should not validate. + std::stringstream input; + input << "OpExecutionMode %1 " << GetParam().mode_name; + for (auto operand : GetParam().operands) input << " " << operand; + std::vector expected_operands{1, GetParam().mode_value}; + expected_operands.insert(expected_operands.end(), GetParam().operands.begin(), + GetParam().operands.end()); + EXPECT_THAT(CompiledInstructions(input.str()), + Eq(MakeInstruction(spv::OpExecutionMode, expected_operands))); +} + +// clang-format off +#define CASE(NAME) spv::ExecutionMode##NAME, #NAME +INSTANTIATE_TEST_CASE_P(TextToBinaryExecutionMode, OpExecutionModeTest, + ::testing::ValuesIn(std::vector{ + // The operand literal values are arbitrarily chosen, + // but there are the right number of them. + {CASE(Invocations), {101}}, + {CASE(SpacingEqual), {}}, + {CASE(SpacingFractionalEven), {}}, + {CASE(SpacingFractionalOdd), {}}, + {CASE(VertexOrderCw), {}}, + {CASE(VertexOrderCcw), {}}, + {CASE(PixelCenterInteger), {}}, + {CASE(OriginUpperLeft), {}}, + {CASE(OriginLowerLeft), {}}, + {CASE(EarlyFragmentTests), {}}, + {CASE(PointMode), {}}, + {CASE(Xfb), {}}, + {CASE(DepthReplacing), {}}, + {CASE(DepthAny), {}}, + {CASE(DepthGreater), {}}, + {CASE(DepthLess), {}}, + {CASE(DepthUnchanged), {}}, + {CASE(LocalSize), {64,1,2}}, + {CASE(LocalSizeHint), {8,2,4}}, + {CASE(InputPoints), {}}, + {CASE(InputLines), {}}, + {CASE(InputLinesAdjacency), {}}, + {CASE(InputTriangles), {}}, + {CASE(InputTrianglesAdjacency), {}}, + {CASE(InputQuads), {}}, + {CASE(InputIsolines), {}}, + {CASE(OutputVertices), {21}}, + {CASE(OutputPoints), {}}, + {CASE(OutputLineStrip), {}}, + {CASE(OutputTriangleStrip), {}}, + {CASE(VecTypeHint), {96}}, + {CASE(ContractionOff), {}}, + })); +#undef CASE +// clang-format on + // Test OpCapability struct CapabilityCase { -- 2.7.4