• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2019 Google LLC
6  * Copyright (c) 2019 The Khronos Group Inc.
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 Test new features in SPIR-V 1.4.
23  *//*--------------------------------------------------------------------*/
24 
25 #include <string>
26 #include <vector>
27 #include <amber/amber.h>
28 
29 #include "tcuDefs.hpp"
30 
31 #include "vkDefs.hpp"
32 #include "vktTestGroupUtil.hpp"
33 #include "vktAmberTestCase.hpp"
34 #include "vktSpvAsmSpirvVersion1p4Tests.hpp"
35 #include "vktTestGroupUtil.hpp"
36 
37 namespace vkt
38 {
39 namespace SpirVAssembly
40 {
41 namespace
42 {
43 
44 struct Case
45 {
Casevkt::SpirVAssembly::__anond4b1a7910111::Case46 	Case(const char* b, const char* d) : basename(b), description(d), requirements() { }
Casevkt::SpirVAssembly::__anond4b1a7910111::Case47 	Case(const char* b, const char* d, const std::vector<std::string>& e) : basename(b), description(d), requirements(e) { }
48 	const char *basename;
49 	const char *description;
50 	// Additional Vulkan requirements, if any.
51 	std::vector<std::string> requirements;
52 };
53 struct CaseGroup
54 {
CaseGroupvkt::SpirVAssembly::__anond4b1a7910111::CaseGroup55 	CaseGroup(const char* the_data_dir, const char* the_subdir) : data_dir(the_data_dir), subdir(the_subdir) { }
addvkt::SpirVAssembly::__anond4b1a7910111::CaseGroup56 	void add(const char* basename, const char* description)
57 	{
58 		cases.push_back(Case(basename, description));
59 	}
addvkt::SpirVAssembly::__anond4b1a7910111::CaseGroup60 	void add(const char* basename, const char* description, const std::vector<std::string>& requirements)
61 	{
62 		cases.push_back(Case(basename, description, requirements));
63 	}
64 
65 	const char* data_dir;
66 	const char* subdir;
67 	std::vector<Case> cases;
68 };
69 
70 
addTestsForAmberFiles(tcu::TestCaseGroup * tests,CaseGroup group)71 void addTestsForAmberFiles (tcu::TestCaseGroup* tests, CaseGroup group)
72 {
73 	tcu::TestContext& testCtx = tests->getTestContext();
74 	const std::string data_dir(group.data_dir);
75 	const std::string subdir(group.subdir);
76 	const std::string category = data_dir + "/" + subdir;
77 	std::vector<Case> cases(group.cases);
78 	vk::SpirVAsmBuildOptions asm_options(VK_MAKE_VERSION(1, 1, 0), vk::SPIRV_VERSION_1_4);
79 	asm_options.supports_VK_KHR_spirv_1_4 = true;
80 
81 	for (unsigned i = 0; i < cases.size() ; ++i)
82 	{
83 
84 		const std::string file = std::string(cases[i].basename) + ".amber";
85 		cts_amber::AmberTestCase *testCase = cts_amber::createAmberTestCase(testCtx,
86 																			cases[i].basename,
87 																			cases[i].description,
88 																			category.c_str(),
89 																			file);
90 		DE_ASSERT(testCase != DE_NULL);
91 		// Add Vulkan extension requirements.
92 		// VK_KHR_spirv_1_4 requires Vulkan 1.1, which includes many common extensions.
93 		// So for, example, these tests never have to request VK_KHR_storage_buffer_storage_class,
94 		// or VK_KHR_variable_pointers since those extensions were promoted to core features
95 		// in Vulkan 1.1.  Note that feature bits may still be optional.
96 		testCase->addRequirement("VK_KHR_spirv_1_4");
97 		// The tests often use StorageBuffer storage class.
98 		// We do not have to request VK_KHR_storage_buffer_storage_class because that extension
99 		// is about enabling use of SPV_KHR_storage_buffer_storage_class.  But SPIR-V 1.4 allows
100 		// use of StorageBuffer storage class without any further declarations of extensions
101 		// or capabilities.  This will also hold for tests that use features introduced by
102 		// extensions folded into SPIR-V 1.4 or earlier, and which don't require extra capabilities
103 		// to be enabled by Vulkan.  Other examples are functionality in SPV_GOOGLE_decorate_string,
104 		// SPV_GOOGLE_hlsl_functionality1, and SPV_KHR_no_integer_wrap_decoration.
105 		const std::vector<std::string>& reqmts = cases[i].requirements;
106 		for (size_t r = 0; r < reqmts.size() ; ++r)
107 		{
108 			testCase->addRequirement(reqmts[r]);
109 		}
110 
111 		testCase->setSpirVAsmBuildOptions(asm_options);
112 		tests->addChild(testCase);
113 	}
114 }
115 
116 } // anonymous
117 
createSpirvVersion1p4Group(tcu::TestContext & testCtx)118 tcu::TestCaseGroup* createSpirvVersion1p4Group (tcu::TestContext& testCtx)
119 {
120 	de::MovePtr<tcu::TestCaseGroup> spirv1p4Tests(new tcu::TestCaseGroup(testCtx, "spirv1p4", "SPIR-V 1.4 new features"));
121 
122 	// Location of the Amber script files under the data/vulkan/amber source tree.
123 	const char* data_dir = "spirv_assembly/instruction/spirv1p4";
124 
125 	// Set up features used for various tests.
126 	std::vector<std::string> Geom;
127 	Geom.push_back("Features.geometryShader");
128 
129 	std::vector<std::string> Tess;
130 	Tess.push_back("Features.tessellationShader");
131 
132 	std::vector<std::string> Varptr_ssbo;
133 	Varptr_ssbo.push_back("VariablePointerFeatures.variablePointersStorageBuffer");
134 
135 	std::vector<std::string> Varptr_full = Varptr_ssbo;
136 	Varptr_full.push_back("VariablePointerFeatures.variablePointers");
137 
138 	std::vector<std::string> Int16;
139 	Int16.push_back("Features.shaderInt16");
140 
141 	std::vector<std::string> Int16_storage = Int16;
142 	Int16_storage.push_back("VK_KHR_16bit_storage");
143 	Int16_storage.push_back("Storage16BitFeatures.storageBuffer16BitAccess");
144 
145 	std::vector<std::string> Int64;
146 	Int64.push_back("Features.shaderInt64");
147 
148 	// Define test groups
149 
150 	CaseGroup group(data_dir, "opcopylogical");
151 	group.add("different_matrix_layout","different matrix layout");
152 	group.add("different_matrix_strides","different matrix strides");
153 	group.add("nested_arrays_different_inner_stride","nested_arrays_different_inner_stride");
154 	group.add("nested_arrays_different_outer_stride","nested_arrays_different_inner_stride");
155 	group.add("nested_arrays_different_strides","nested_arrays_different_strides");
156 	group.add("same_array_two_ids","same array two ids");
157 	group.add("same_struct_two_ids","same struct two ids");
158 	group.add("ssbo_to_ubo","ssbo_to_ubo");
159 	group.add("two_arrays_different_stride_1","two_arrays_different_stride_1");
160 	group.add("two_arrays_different_stride_2","two_arrays_different_stride_2");
161 	group.add("ubo_to_ssbo","ubo_to_ssbo");
162 	spirv1p4Tests->addChild(createTestGroup(testCtx, "opcopylogical", "OpCopyLogical", addTestsForAmberFiles, group));
163 
164 	group = CaseGroup(data_dir, "opptrdiff");
165 	group.add("ssbo_comparisons_diff", "pointer diff within an SSBO", Varptr_ssbo);
166 	group.add("variable_pointers_vars_ssbo_2_diff", "pointer diff in SSBO with full VariablePointers", Varptr_ssbo);
167 	group.add("variable_pointers_vars_ssbo_diff", "pointer diff in SSBO, stored in private var", Varptr_ssbo);
168 	group.add("variable_pointers_vars_wg_diff", "pointer diff in workgroup storage, stored in private var", Varptr_full);
169 	group.add("wg_comparisons_diff", "pointer diff in workgroup storage", Varptr_full);
170 	spirv1p4Tests->addChild(createTestGroup(testCtx, "opptrdiff", "OpPtrDiff", addTestsForAmberFiles, group));
171 
172 	group = CaseGroup(data_dir, "opptrequal");
173 	group.add("different_ssbos_equal", "ptr equal against different SSBO variables", Varptr_full);
174 	group.add("different_wgs_equal", "ptr equal against different WG variables", Varptr_full);
175 	group.add("null_comparisons_ssbo_equal", "ptr equal null in SSBO", Varptr_ssbo);
176 	group.add("null_comparisons_wg_equal", "ptr equal null in Workgrop", Varptr_full);
177 	group.add("ssbo_comparisons_equal", "ptr equal in SSBO", Varptr_ssbo);
178 	group.add("variable_pointers_ssbo_2_equal", "ptr equal in SSBO, store pointers in Function var", Varptr_full);
179 	group.add("variable_pointers_ssbo_equal", "ptr equal in SSBO", Varptr_ssbo);
180 	group.add("variable_pointers_vars_ssbo_equal", "ptr equal in SSBO, store pointers in Private var ", Varptr_ssbo);
181 	group.add("variable_pointers_vars_wg_equal", "ptr equal in Workgrop, store pointers in Private var", Varptr_full);
182 	group.add("variable_pointers_wg_equal", "ptr equal in Workgrop", Varptr_full);
183 	group.add("wg_comparisons_equal", "ptr equal in Workgrop", Varptr_full);
184 	spirv1p4Tests->addChild(createTestGroup(testCtx, "opptrequal", "OpPtrEqual", addTestsForAmberFiles, group));
185 
186 	group = CaseGroup(data_dir, "opptrnotequal");
187 	group.add("different_ssbos_not_equal", "ptr not equal against different SSBO variables", Varptr_full);
188 	group.add("different_wgs_not_equal", "ptr not equal against different WG variables", Varptr_full);
189 	group.add("null_comparisons_ssbo_not_equal", "ptr not equal null SSBO", Varptr_ssbo);
190 	group.add("null_comparisons_wg_not_equal", "ptr not equal null SSBO", Varptr_full);
191 	group.add("ssbo_comparisons_not_equal", "ptr not equal SSBO", Varptr_ssbo);
192 	group.add("variable_pointers_ssbo_2_not_equal", "ptr not equal SSBO, store pointer in Function var", Varptr_full);
193 	group.add("variable_pointers_ssbo_not_equal", "ptr not equal SSBO, pointer from function return", Varptr_ssbo);
194 	group.add("variable_pointers_vars_ssbo_not_equal", "ptr not equal SSBO, store pointer in Private var", Varptr_ssbo);
195 	group.add("variable_pointers_vars_wg_not_equal", "ptr not equal Workgroup, store pointer in Private var", Varptr_full);
196 	group.add("variable_pointers_wg_not_equal", "ptr not equal Workgroup", Varptr_full);
197 	group.add("wg_comparisons_not_equal", "ptr not equal Workgroup", Varptr_full);
198 	spirv1p4Tests->addChild(createTestGroup(testCtx, "opptrnotequal", "OpPtrNotEqual", addTestsForAmberFiles, group));
199 
200 	group = CaseGroup(data_dir, "opcopymemory");
201 	group.add("different_alignments", "different alignments");
202 	group.add("no_source_access_operands", "no source access operands");
203 	group.add("no_target_access_operands", "no target access operands");
204 	spirv1p4Tests->addChild(createTestGroup(testCtx, "opcopymemory", "OpCopyMemory 2 memory access operands", addTestsForAmberFiles, group));
205 
206 	group = CaseGroup(data_dir, "uniformid");
207 	group.add("partially_active_uniform_id","workgroup uniform load result at consumption, in nonuniform control flow");
208 	group.add("subgroup_cfg_uniform_id","subgroup uniform compare result inside control flow"); // Assumes subgroup size <= LocalSize of 8
209 	group.add("subgroup_uniform","subgroup uniform load result"); // Assumes subgroup size <= LocalSize 8
210 	group.add("workgroup_cfg_uniform_id","workgroup uniform compare result");
211 	group.add("workgroup_uniform","workgroup uniform load result");
212 	spirv1p4Tests->addChild(createTestGroup(testCtx, "uniformid", "UniformId decoration", addTestsForAmberFiles, group));
213 
214 	group = CaseGroup(data_dir, "nonwritable");
215 	group.add("function_2_nonwritable", "NonWritable decorates Function variables");
216 	group.add("function_nonwritable", "NonWritable decorates 2 Function variables");
217 	group.add("non_main_function_nonwritable", "NonWritable decorates Function variable in non-entrypoint function");
218 	group.add("private_2_nonwritable", "NonWritable decorates Private variables");
219 	group.add("private_nonwritable", "NonWritable decorates 2 Private variables");
220 	spirv1p4Tests->addChild(createTestGroup(testCtx, "nonwritable", "NonWritable decoration", addTestsForAmberFiles, group));
221 
222 	group = CaseGroup(data_dir, "entrypoint");
223 	group.add("comp_pc_entry_point", "push constant on compute shader entry point");
224 	group.add("comp_ssbo_entry_point", "SSBO on compute shader entry point");
225 	group.add("comp_ubo_entry_point", "UBO on compute shader entry point");
226 	group.add("comp_workgroup_entry_point", "Workgroup var on compute shader entry point");
227 	group.add("frag_pc_entry_point", "push constant on fragment shader entry point");
228 	group.add("frag_ssbo_entry_point", "SSBO on fragment shader entry point");
229 	group.add("frag_ubo_entry_point", "UBO on fragment shader entry point");
230 	group.add("geom_pc_entry_point", "push constant on geometry shader entry point", Geom);
231 	group.add("geom_ssbo_entry_point", "SSBO on geometry shader entry point", Geom);
232 	group.add("geom_ubo_entry_point", "UBO on geometry shader entry point", Geom);
233 	group.add("tess_con_pc_entry_point", "push constant on tess control shader entry point", Tess);
234 	group.add("tess_con_ssbo_entry_point", "SSBO on tess control shader entry point", Tess);
235 	group.add("tess_con_ubo_entry_point", "UBO on tess control shader entry point", Tess);
236 	group.add("tess_eval_pc_entry_point", "push constant on tess eval shader entry point", Tess);
237 	group.add("tess_eval_ssbo_entry_point", "SSBO on tess eval shader entry point", Tess);
238 	group.add("tess_eval_ubo_entry_point", "UBO on tess eval shader entry point", Tess);
239 	group.add("vert_pc_entry_point", "push constant on vertex shader entry point");
240 	group.add("vert_ssbo_entry_point", "SSBO on vertex shader entry point");
241 	group.add("vert_ubo_entry_point", "UBO on vertex shader entry point");
242 	spirv1p4Tests->addChild(createTestGroup(testCtx, "entrypoint", "EntryPoint lists all module-scope variables", addTestsForAmberFiles, group));
243 
244 	group = CaseGroup(data_dir, "hlsl_functionality1");
245 	group.add("counter_buffer", "CounterBuffer decoration");
246 	group.add("decorate_string", "OpDecorateString");
247 	group.add("member_decorate_string", "OpMemberDecorateString");
248 	spirv1p4Tests->addChild(createTestGroup(testCtx, "hlsl_functionality1", "Features in SPV_GOOGLE_hlsl_functionality1 in SPIR-V 1.4", addTestsForAmberFiles, group));
249 
250 	group = CaseGroup(data_dir, "loop_control");
251 	group.add("iteration_multiple", "Loop control IterationMultiple");
252 	group.add("max_iterations", "Loop control IterationMultiple");
253 	group.add("min_iterations", "Loop control MinIterations");
254 	group.add("partial_count", "Loop control PartialCount");
255 	group.add("peel_count", "Loop control PeelCount");
256 	spirv1p4Tests->addChild(createTestGroup(testCtx, "loop_control", "SPIR-V 1.4 loop controls", addTestsForAmberFiles, group));
257 
258 	group = CaseGroup(data_dir, "opselect");
259 	group.add("array_select", "OpSelect arrays, new in SPIR-V 1.4");
260 	group.add("array_stride_select", "OpSelect arrays with non-standard strides, new in SPIR-V 1.4");
261 	group.add("nested_array_select", "OpSelect structs with nested arrays, new in SPIR-V 1.4");
262 	group.add("nested_struct_select", "OpSelect structs with nested structs, new in SPIR-V 1.4");
263 	group.add("scalar_select", "OpSelect scalars, verify SPIR-V 1.0");
264 	group.add("ssbo_pointers_2_select", "OpSelect SSBO pointers to different buffers, verify SPIR-V 1.0", Varptr_full);
265 	group.add("ssbo_pointers_select", "OpSelect SSBO pointers to same buffer, verify SPIR-V 1.0", Varptr_ssbo);
266 	group.add("struct_select", "OpSelect structs, new in SPIR-V 1.4");
267 	group.add("vector_element_select", "OpSelect vector with vector selector, verify SPIR-V 1.0");
268 	group.add("vector_select", "OpSelect vector with scalar selector, new in SPIR-V 1.4");
269 	group.add("wg_pointers_2_select", "OpSelect Workgroup pointers to different buffers, verify SPIR-V 1.0", Varptr_full);
270 	group.add("wg_pointers_select", "OpSelect Workgroup pointers to same buffer, verify SPIR-V 1.0", Varptr_full);
271 	spirv1p4Tests->addChild(createTestGroup(testCtx, "opselect", "SPIR-V 1.4 OpSelect more cases", addTestsForAmberFiles, group));
272 
273 	group = CaseGroup(data_dir, "uconvert");
274 	group.add("spec_const_opt_extend_16_64_bit","uconvert small to int64", Int64);
275 	group.add("spec_const_opt_extend_16","uconvert from int16", Int16);
276 	group.add("spec_const_opt_extend_251658240_64_bits","uconvert large to int64", Int64);
277 	group.add("spec_const_opt_extend_61440", "uconvert large from int16", Int16);
278 	group.add("spec_const_opt_truncate_16_64_bit", "uconvert from int64", Int64);
279 	group.add("spec_const_opt_truncate_16", "uconvert small to int16", Int16_storage);
280 	group.add("spec_const_opt_truncate_983040", "uconvert large to int16", Int16_storage);
281 	group.add("spec_const_opt_zero_extend_n4096", "uconvert negative from int16", Int16);
282 	spirv1p4Tests->addChild(createTestGroup(testCtx, "uconvert", "SPIR-V 1.4 UConvert in OpSpecConstantOp", addTestsForAmberFiles, group));
283 
284 	group = CaseGroup(data_dir, "wrap");
285 	group.add("no_signed_wrap", "Accept NoSignedWrap decoration");
286 	group.add("no_unsigned_wrap", "Accept NoUnsignedWrap decoration");
287 	spirv1p4Tests->addChild(createTestGroup(testCtx, "wrap", "SPIR-V 1.4 integer wrap decorations", addTestsForAmberFiles, group));
288 
289 	return spirv1p4Tests.release();
290 }
291 
292 } // SpirVAssembly
293 } // vkt
294