1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
4 *
5 * Copyright (c) 2022 The Khronos Group Inc.
6 * Copyright (c) 2022 Google LLC
7 *
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
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
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.
19 *
20 *//*!
21 * \file
22 * \brief Shader invocations tests
23 *//*--------------------------------------------------------------------*/
24
25 #include "vktDrawShaderInvocationTests.hpp"
26 #include "vktTestGroupUtil.hpp"
27 #include "amber/vktAmberTestCase.hpp"
28
29 #include "tcuTestCase.hpp"
30
31 using namespace vk;
32
33 namespace vkt
34 {
35 namespace Draw
36 {
37 namespace
38 {
39
40 enum TestType
41 {
42 EXT,
43 CORE,
44 CORE_MEM_MODEL,
45 };
46
checkSupport(Context & context,TestType type)47 void checkSupport(Context& context, TestType type)
48 {
49 if ((context.getSubgroupProperties().supportedOperations & VK_SUBGROUP_FEATURE_QUAD_BIT) == 0u)
50 TCU_THROW(NotSupportedError, "Device does not support subgroup quad operations");
51
52 #ifndef CTS_USES_VULKANSC
53 if (!context.getShaderDemoteToHelperInvocationFeatures().shaderDemoteToHelperInvocation)
54 TCU_THROW(NotSupportedError, "demoteToHelperInvocation not supported.");
55 #else
56 if (!context.getShaderDemoteToHelperInvocationFeaturesEXT().shaderDemoteToHelperInvocation)
57 TCU_THROW(NotSupportedError, "demoteToHelperInvocation not supported.");
58 #endif
59
60 // EXT test requires that the extension be supported, because OpIsHelperInvocationEXT was not promoted to core.
61 if (type == EXT && !context.isDeviceFunctionalitySupported("VK_EXT_shader_demote_to_helper_invocation"))
62 TCU_THROW(NotSupportedError, "VK_EXT_shader_demote_to_helper_invocation not supported.");
63
64 // CORE and CORE_MEM_MODEL tests require SPIR-V 1.6, but this is checked automatically.
65
66 if (type == CORE_MEM_MODEL && !context.getVulkanMemoryModelFeatures().vulkanMemoryModel)
67 TCU_THROW(NotSupportedError, "Vulkan memory model not supported.");
68
69 }
70
checkExtTestSupport(Context & context,std::string testName)71 void checkExtTestSupport (Context& context, std::string testName) { DE_UNREF(testName); checkSupport(context, EXT); }
checkCoreTestSupport(Context & context,std::string testName)72 void checkCoreTestSupport (Context& context, std::string testName) { DE_UNREF(testName); checkSupport(context, CORE); }
checkMemModelTestSupport(Context & context,std::string testName)73 void checkMemModelTestSupport (Context& context, std::string testName) { DE_UNREF(testName); checkSupport(context, CORE_MEM_MODEL); }
74
createTests(tcu::TestCaseGroup * testGroup)75 void createTests(tcu::TestCaseGroup* testGroup)
76 {
77 tcu::TestContext& testCtx = testGroup->getTestContext();
78 static const char dataDir[] = "draw/shader_invocation";
79
80 struct caseDef {
81 const char *name;
82 const char *file;
83 std::function<void(Context&, std::string)> supportFunc;
84 } cases[] =
85 {
86 { "helper_invocation", "helper_invocation.amber", checkExtTestSupport },
87 { "helper_invocation_volatile", "helper_invocation_volatile.amber", checkCoreTestSupport },
88 { "helper_invocation_volatile_mem_model", "helper_invocation_volatile_mem_model.amber", checkMemModelTestSupport },
89 };
90
91 for (unsigned i=0; i<sizeof(cases) / sizeof(caseDef); i++)
92 {
93 cts_amber::AmberTestCase* testCase = cts_amber::createAmberTestCase(testCtx, cases[i].name, dataDir, cases[i].file);
94 testCase->setCheckSupportCallback(cases[i].supportFunc);
95 testGroup->addChild(testCase);
96 }
97 }
98
99 } // anonymous
100
createShaderInvocationTests(tcu::TestContext & testCtx)101 tcu::TestCaseGroup* createShaderInvocationTests(tcu::TestContext& testCtx)
102 {
103 return createTestGroup(testCtx, "shader_invocation", createTests);
104 }
105
106 } // DrawTests
107 } // vkt
108