1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2014 The Android Open Source Project
6 * Copyright (c) 2016 The Khronos Group Inc.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 * \brief Tessellation Limits Tests
23 *//*--------------------------------------------------------------------*/
25 #include "vktTessellationLimitsTests.hpp"
26 #include "vktTestCaseUtil.hpp"
28 #include "tcuTestLog.hpp"
31 #include "vkQueryUtil.hpp"
33 #include "deUniquePtr.hpp"
37 namespace tessellation
45 enum TessellationLimits
47 LIMIT_MAX_TESSELLATION_GENERATION_LEVEL,
48 LIMIT_MAX_TESSELLATION_PATCH_SIZE,
49 LIMIT_MAX_TESSELLATION_CONTROL_PER_VERTEX_INPUT_COMPONENTS,
50 LIMIT_MAX_TESSELLATION_CONTROL_PER_VERTEX_OUTPUT_COMPONENTS,
51 LIMIT_MAX_TESSELLATION_CONTROL_PER_PATCH_OUTPUT_COMPONENTS,
52 LIMIT_MAX_TESSELLATION_CONTROL_TOTAL_OUTPUT_COMPONENTS,
53 LIMIT_MAX_TESSELLATION_EVALUATION_INPUT_COMPONENTS,
54 LIMIT_MAX_TESSELLATION_EVALUATION_OUTPUT_COMPONENTS,
57 struct LimitsCaseDefinition
59 TessellationLimits limitType;
60 deUint32 minimum; //!< Implementation must provide at least this value
63 tcu::TestStatus expectGreaterOrEqual(tcu::TestLog& log, const deUint32 expected, const deUint32 actual)
65 log << tcu::TestLog::Message << "Expected: " << expected << ", got: " << actual << tcu::TestLog::EndMessage;
67 if (actual >= expected)
68 return tcu::TestStatus::pass("OK");
70 return tcu::TestStatus::fail("Value doesn't meet minimal spec requirements");
73 tcu::TestStatus deviceLimitsTestCase(Context& context, const LimitsCaseDefinition caseDef)
75 const InstanceInterface& vki = context.getInstanceInterface();
76 const VkPhysicalDevice physDevice = context.getPhysicalDevice();
77 const VkPhysicalDeviceFeatures features = getPhysicalDeviceFeatures(vki, physDevice);
79 if (!features.tessellationShader)
80 throw tcu::NotSupportedError("Tessellation shader not supported");
82 const VkPhysicalDeviceProperties properties = getPhysicalDeviceProperties(vki, physDevice);
83 tcu::TestLog& log = context.getTestContext().getLog();
85 switch (caseDef.limitType)
87 case LIMIT_MAX_TESSELLATION_GENERATION_LEVEL:
88 return expectGreaterOrEqual(log, caseDef.minimum, properties.limits.maxTessellationGenerationLevel);
89 case LIMIT_MAX_TESSELLATION_PATCH_SIZE:
90 return expectGreaterOrEqual(log, caseDef.minimum, properties.limits.maxTessellationPatchSize);
91 case LIMIT_MAX_TESSELLATION_CONTROL_PER_VERTEX_INPUT_COMPONENTS:
92 return expectGreaterOrEqual(log, caseDef.minimum, properties.limits.maxTessellationControlPerVertexInputComponents);
93 case LIMIT_MAX_TESSELLATION_CONTROL_PER_VERTEX_OUTPUT_COMPONENTS:
94 return expectGreaterOrEqual(log, caseDef.minimum, properties.limits.maxTessellationControlPerVertexOutputComponents);
95 case LIMIT_MAX_TESSELLATION_CONTROL_PER_PATCH_OUTPUT_COMPONENTS:
96 return expectGreaterOrEqual(log, caseDef.minimum, properties.limits.maxTessellationControlPerPatchOutputComponents);
97 case LIMIT_MAX_TESSELLATION_CONTROL_TOTAL_OUTPUT_COMPONENTS:
98 return expectGreaterOrEqual(log, caseDef.minimum, properties.limits.maxTessellationControlTotalOutputComponents);
99 case LIMIT_MAX_TESSELLATION_EVALUATION_INPUT_COMPONENTS:
100 return expectGreaterOrEqual(log, caseDef.minimum, properties.limits.maxTessellationEvaluationInputComponents);
101 case LIMIT_MAX_TESSELLATION_EVALUATION_OUTPUT_COMPONENTS:
102 return expectGreaterOrEqual(log, caseDef.minimum, properties.limits.maxTessellationEvaluationOutputComponents);
105 // Control should never get here.
106 DE_FATAL("Internal test error");
107 return tcu::TestStatus::fail("Test error");
112 //! These tests correspond roughly to dEQP-GLES31.functional.tessellation.state_query.*
113 tcu::TestCaseGroup* createLimitsTests (tcu::TestContext& testCtx)
115 de::MovePtr<tcu::TestCaseGroup> group (new tcu::TestCaseGroup(testCtx, "limits", "Tessellation limits tests"));
119 std::string caseName;
120 LimitsCaseDefinition caseDef;
123 { "max_tessellation_generation_level", { LIMIT_MAX_TESSELLATION_GENERATION_LEVEL, 64 } },
124 { "max_tessellation_patch_size", { LIMIT_MAX_TESSELLATION_PATCH_SIZE, 32 } },
125 { "max_tessellation_control_per_vertex_input_components", { LIMIT_MAX_TESSELLATION_CONTROL_PER_VERTEX_INPUT_COMPONENTS, 64 } },
126 { "max_tessellation_control_per_vertex_output_components", { LIMIT_MAX_TESSELLATION_CONTROL_PER_VERTEX_OUTPUT_COMPONENTS, 64 } },
127 { "max_tessellation_control_per_patch_output_components", { LIMIT_MAX_TESSELLATION_CONTROL_PER_PATCH_OUTPUT_COMPONENTS, 120 } },
128 { "max_tessellation_control_total_output_components", { LIMIT_MAX_TESSELLATION_CONTROL_TOTAL_OUTPUT_COMPONENTS, 2048 } },
129 { "max_tessellation_evaluation_input_components", { LIMIT_MAX_TESSELLATION_EVALUATION_INPUT_COMPONENTS, 64 } },
130 { "max_tessellation_evaluation_output_components", { LIMIT_MAX_TESSELLATION_EVALUATION_OUTPUT_COMPONENTS, 64 } },
133 for (int i = 0; i < DE_LENGTH_OF_ARRAY(cases); ++i)
134 addFunctionCase<LimitsCaseDefinition>(group.get(), cases[i].caseName, "", deviceLimitsTestCase, cases[i].caseDef);
136 return group.release();