1 /*------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2015 The Khronos Group Inc.
6  * Copyright (c) 2015 Imagination Technologies Ltd.
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 Vertex Input Tests
23  *//*--------------------------------------------------------------------*/
24 
25 #include "vktPipelineVertexInputTests.hpp"
26 #include "vktTestGroupUtil.hpp"
27 #include "vktPipelineClearUtil.hpp"
28 #include "vktPipelineImageUtil.hpp"
29 #include "vktPipelineVertexUtil.hpp"
30 #include "vktPipelineReferenceRenderer.hpp"
31 #include "vktTestCase.hpp"
32 #include "vktTestCaseUtil.hpp"
33 #include "vkImageUtil.hpp"
34 #include "vkMemUtil.hpp"
35 #include "vkPrograms.hpp"
36 #include "vkQueryUtil.hpp"
37 #include "vkRef.hpp"
38 #include "vkRefUtil.hpp"
39 #include "vkTypeUtil.hpp"
40 #include "vkCmdUtil.hpp"
41 #include "vkObjUtil.hpp"
42 #include "tcuFloat.hpp"
43 #include "tcuImageCompare.hpp"
44 #include "deFloat16.h"
45 #include "deMemory.h"
46 #include "deRandom.hpp"
47 #include "deStringUtil.hpp"
48 #include "deUniquePtr.hpp"
49 
50 #include <sstream>
51 #include <vector>
52 
53 namespace vkt
54 {
55 namespace pipeline
56 {
57 
58 using namespace vk;
59 
60 namespace
61 {
62 
isSupportedVertexFormat(Context & context,VkFormat format)63 bool isSupportedVertexFormat (Context& context, VkFormat format)
64 {
65 	if (isVertexFormatDouble(format) && !context.getDeviceFeatures().shaderFloat64)
66 		return false;
67 
68 	VkFormatProperties  formatProps;
69 	deMemset(&formatProps, 0, sizeof(VkFormatProperties));
70 	context.getInstanceInterface().getPhysicalDeviceFormatProperties(context.getPhysicalDevice(), format, &formatProps);
71 
72 	return (formatProps.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) != 0u;
73 }
74 
getRepresentableDifferenceUnorm(VkFormat format)75 float getRepresentableDifferenceUnorm (VkFormat format)
76 {
77 	DE_ASSERT(isVertexFormatUnorm(format) || isVertexFormatSRGB(format));
78 
79 	return 1.0f / float((1 << (getVertexFormatComponentSize(format) * 8)) - 1);
80 }
81 
getRepresentableDifferenceUnormPacked(VkFormat format,deUint32 componentNdx)82 float getRepresentableDifferenceUnormPacked(VkFormat format, deUint32 componentNdx)
83 {
84 	DE_ASSERT((isVertexFormatUnorm(format) || isVertexFormatSRGB(format)) && isVertexFormatPacked(format));
85 
86 	return 1.0f / float((1 << (getPackedVertexFormatComponentWidth(format, componentNdx))) - 1);
87 }
88 
getRepresentableDifferenceSnorm(VkFormat format)89 float getRepresentableDifferenceSnorm (VkFormat format)
90 {
91 	DE_ASSERT(isVertexFormatSnorm(format));
92 
93 	return 1.0f / float((1 << (getVertexFormatComponentSize(format) * 8 - 1)) - 1);
94 }
95 
getRepresentableDifferenceSnormPacked(VkFormat format,deUint32 componentNdx)96 float getRepresentableDifferenceSnormPacked(VkFormat format, deUint32 componentNdx)
97 {
98 	DE_ASSERT(isVertexFormatSnorm(format) && isVertexFormatPacked(format));
99 
100 	return 1.0f / float((1 << (getPackedVertexFormatComponentWidth(format, componentNdx) - 1)) - 1);
101 }
102 
getNextMultipleOffset(deUint32 divisor,deUint32 value)103 deUint32 getNextMultipleOffset (deUint32 divisor, deUint32 value)
104 {
105 	if (value % divisor == 0)
106 		return 0;
107 	else
108 		return divisor - (value % divisor);
109 }
110 
111 class VertexInputTest : public vkt::TestCase
112 {
113 public:
114 	enum GlslType
115 	{
116 		GLSL_TYPE_INT,
117 		GLSL_TYPE_IVEC2,
118 		GLSL_TYPE_IVEC3,
119 		GLSL_TYPE_IVEC4,
120 
121 		GLSL_TYPE_UINT,
122 		GLSL_TYPE_UVEC2,
123 		GLSL_TYPE_UVEC3,
124 		GLSL_TYPE_UVEC4,
125 
126 		GLSL_TYPE_FLOAT,
127 		GLSL_TYPE_VEC2,
128 		GLSL_TYPE_VEC3,
129 		GLSL_TYPE_VEC4,
130 		GLSL_TYPE_MAT2,
131 		GLSL_TYPE_MAT3,
132 		GLSL_TYPE_MAT4,
133 
134 		GLSL_TYPE_DOUBLE,
135 		GLSL_TYPE_DVEC2,
136 		GLSL_TYPE_DVEC3,
137 		GLSL_TYPE_DVEC4,
138 		GLSL_TYPE_DMAT2,
139 		GLSL_TYPE_DMAT3,
140 		GLSL_TYPE_DMAT4,
141 
142 		GLSL_TYPE_COUNT
143 	};
144 
145 	enum GlslBasicType
146 	{
147 		GLSL_BASIC_TYPE_INT,
148 		GLSL_BASIC_TYPE_UINT,
149 		GLSL_BASIC_TYPE_FLOAT,
150 		GLSL_BASIC_TYPE_DOUBLE
151 	};
152 
153 	enum BindingMapping
154 	{
155 		BINDING_MAPPING_ONE_TO_ONE,		//!< Vertex input bindings will not contain data for more than one attribute.
156 		BINDING_MAPPING_ONE_TO_MANY		//!< Vertex input bindings can contain data for more than one attribute.
157 	};
158 
159 	enum AttributeLayout
160 	{
161 		ATTRIBUTE_LAYOUT_INTERLEAVED,	//!< Attribute data is bundled together as if in a structure: [pos 0][color 0][pos 1][color 1]...
162 		ATTRIBUTE_LAYOUT_SEQUENTIAL		//!< Data for each attribute is laid out separately: [pos 0][pos 1]...[color 0][color 1]...
163 										//   Sequential only makes a difference if ONE_TO_MANY mapping is used (more than one attribute in a binding).
164 	};
165 
166 	enum LayoutSkip
167 	{
168 		LAYOUT_SKIP_ENABLED,	//!< Skip one location slot after each attribute
169 		LAYOUT_SKIP_DISABLED	//!< Consume locations sequentially
170 	};
171 
172 	enum LayoutOrder
173 	{
174 		LAYOUT_ORDER_IN_ORDER,		//!< Assign locations in order
175 		LAYOUT_ORDER_OUT_OF_ORDER	//!< Assign locations out of order
176 	};
177 
178 	struct AttributeInfo
179 	{
180 		GlslType				glslType;
181 		VkFormat				vkType;
182 		VkVertexInputRate		inputRate;
183 	};
184 
185 	struct GlslTypeDescription
186 	{
187 		const char*		name;
188 		int				vertexInputComponentCount;
189 		int				vertexInputCount;
190 		GlslBasicType	basicType;
191 	};
192 
193 	static const GlslTypeDescription		s_glslTypeDescriptions[GLSL_TYPE_COUNT];
194 
195 											VertexInputTest				(tcu::TestContext&					testContext,
196 																		 const std::string&					name,
197 																		 const std::string&					description,
198 																		 const std::vector<AttributeInfo>&	attributeInfos,
199 																		 BindingMapping						bindingMapping,
200 																		 AttributeLayout					attributeLayout,
201 																		 LayoutSkip							layoutSkip = LAYOUT_SKIP_DISABLED,
202 																		 LayoutOrder						layoutOrder = LAYOUT_ORDER_IN_ORDER);
203 
~VertexInputTest(void)204 	virtual									~VertexInputTest			(void) {}
205 	virtual void							initPrograms				(SourceCollections& programCollection) const;
206 	virtual void							checkSupport				(Context& context) const;
207 	virtual TestInstance*					createInstance				(Context& context) const;
208 	static bool								isCompatibleType			(VkFormat format, GlslType glslType);
209 
210 private:
211 	AttributeInfo							getAttributeInfo			(size_t attributeNdx) const;
212 	size_t									getNumAttributes			(void) const;
213 	std::string								getGlslInputDeclarations	(void) const;
214 	std::string								getGlslVertexCheck			(void) const;
215 	std::string								getGlslAttributeConditions	(const AttributeInfo& attributeInfo, const std::string attributeIndex) const;
216 	static tcu::Vec4						getFormatThreshold			(VkFormat format);
217 
218 	const std::vector<AttributeInfo>		m_attributeInfos;
219 	const BindingMapping					m_bindingMapping;
220 	const AttributeLayout					m_attributeLayout;
221 	const LayoutSkip						m_layoutSkip;
222 	mutable std::vector<deUint32>			m_locations;
223 	const bool								m_queryMaxAttributes;
224 	bool									m_usesDoubleType;
225 	mutable size_t							m_maxAttributes;
226 };
227 
228 class VertexInputInstance : public vkt::TestInstance
229 {
230 public:
231 	struct VertexInputAttributeDescription
232 	{
233 		VertexInputTest::GlslType			glslType;
234 		int									vertexInputIndex;
235 		VkVertexInputAttributeDescription	vkDescription;
236 	};
237 
238 	typedef	std::vector<VertexInputAttributeDescription>	AttributeDescriptionList;
239 
240 											VertexInputInstance			(Context&												context,
241 																		 const AttributeDescriptionList&						attributeDescriptions,
242 																		 const std::vector<VkVertexInputBindingDescription>&	bindingDescriptions,
243 																		 const std::vector<VkDeviceSize>&						bindingOffsets);
244 
245 	virtual									~VertexInputInstance		(void);
246 	virtual tcu::TestStatus					iterate						(void);
247 
248 
249 	static void								writeVertexInputData		(deUint8* destPtr, const VkVertexInputBindingDescription& bindingDescription, const VkDeviceSize bindingOffset, const AttributeDescriptionList& attributes);
250 	static void								writeVertexInputValue		(deUint8* destPtr, const VertexInputAttributeDescription& attributes, int indexId);
251 
252 private:
253 	tcu::TestStatus							verifyImage					(void);
254 
255 private:
256 	std::vector<VkBuffer>					m_vertexBuffers;
257 	std::vector<Allocation*>				m_vertexBufferAllocs;
258 
259 	const tcu::UVec2						m_renderSize;
260 	const VkFormat							m_colorFormat;
261 
262 	Move<VkImage>							m_colorImage;
263 	de::MovePtr<Allocation>					m_colorImageAlloc;
264 	Move<VkImage>							m_depthImage;
265 	Move<VkImageView>						m_colorAttachmentView;
266 	Move<VkRenderPass>						m_renderPass;
267 	Move<VkFramebuffer>						m_framebuffer;
268 
269 	Move<VkShaderModule>					m_vertexShaderModule;
270 	Move<VkShaderModule>					m_fragmentShaderModule;
271 
272 	Move<VkPipelineLayout>					m_pipelineLayout;
273 	Move<VkPipeline>						m_graphicsPipeline;
274 
275 	Move<VkCommandPool>						m_cmdPool;
276 	Move<VkCommandBuffer>					m_cmdBuffer;
277 };
278 
279 const VertexInputTest::GlslTypeDescription VertexInputTest::s_glslTypeDescriptions[GLSL_TYPE_COUNT] =
280 {
281 	{ "int",	1, 1, GLSL_BASIC_TYPE_INT },
282 	{ "ivec2",	2, 1, GLSL_BASIC_TYPE_INT },
283 	{ "ivec3",	3, 1, GLSL_BASIC_TYPE_INT },
284 	{ "ivec4",	4, 1, GLSL_BASIC_TYPE_INT },
285 
286 	{ "uint",	1, 1, GLSL_BASIC_TYPE_UINT },
287 	{ "uvec2",	2, 1, GLSL_BASIC_TYPE_UINT },
288 	{ "uvec3",	3, 1, GLSL_BASIC_TYPE_UINT },
289 	{ "uvec4",	4, 1, GLSL_BASIC_TYPE_UINT },
290 
291 	{ "float",	1, 1, GLSL_BASIC_TYPE_FLOAT },
292 	{ "vec2",	2, 1, GLSL_BASIC_TYPE_FLOAT },
293 	{ "vec3",	3, 1, GLSL_BASIC_TYPE_FLOAT },
294 	{ "vec4",	4, 1, GLSL_BASIC_TYPE_FLOAT },
295 	{ "mat2",	2, 2, GLSL_BASIC_TYPE_FLOAT },
296 	{ "mat3",	3, 3, GLSL_BASIC_TYPE_FLOAT },
297 	{ "mat4",	4, 4, GLSL_BASIC_TYPE_FLOAT },
298 
299 	{ "double",	1, 1, GLSL_BASIC_TYPE_DOUBLE },
300 	{ "dvec2",	2, 1, GLSL_BASIC_TYPE_DOUBLE },
301 	{ "dvec3",	3, 1, GLSL_BASIC_TYPE_DOUBLE },
302 	{ "dvec4",	4, 1, GLSL_BASIC_TYPE_DOUBLE },
303 	{ "dmat2",	2, 2, GLSL_BASIC_TYPE_DOUBLE },
304 	{ "dmat3",	3, 3, GLSL_BASIC_TYPE_DOUBLE },
305 	{ "dmat4",	4, 4, GLSL_BASIC_TYPE_DOUBLE }
306 };
307 
getAttributeBinding(const VertexInputTest::BindingMapping bindingMapping,const VkVertexInputRate firstInputRate,const VkVertexInputRate inputRate,const deUint32 attributeNdx)308 deUint32 getAttributeBinding (const VertexInputTest::BindingMapping bindingMapping, const VkVertexInputRate firstInputRate, const VkVertexInputRate inputRate, const deUint32 attributeNdx)
309 {
310 	if (bindingMapping == VertexInputTest::BINDING_MAPPING_ONE_TO_ONE)
311 	{
312 		// Each attribute uses a unique binding
313 		return attributeNdx;
314 	}
315 	else // bindingMapping == BINDING_MAPPING_ONE_TO_MANY
316 	{
317 		// Alternate between two bindings
318 		return deUint32(firstInputRate + inputRate) % 2u;
319 	}
320 }
321 
322 //! Number of locations used up by an attribute.
getConsumedLocations(const VertexInputTest::AttributeInfo & attributeInfo)323 deUint32 getConsumedLocations (const VertexInputTest::AttributeInfo& attributeInfo)
324 {
325 	// double formats with more than 2 components will take 2 locations
326 	const VertexInputTest::GlslType type = attributeInfo.glslType;
327 	if ((type == VertexInputTest::GLSL_TYPE_DMAT2 || type == VertexInputTest::GLSL_TYPE_DMAT3 || type == VertexInputTest::GLSL_TYPE_DMAT4) &&
328 		(attributeInfo.vkType == VK_FORMAT_R64G64B64_SFLOAT || attributeInfo.vkType == VK_FORMAT_R64G64B64A64_SFLOAT))
329 	{
330 		return 2u;
331 	}
332 	else
333 		return 1u;
334 }
335 
VertexInputTest(tcu::TestContext & testContext,const std::string & name,const std::string & description,const std::vector<AttributeInfo> & attributeInfos,BindingMapping bindingMapping,AttributeLayout attributeLayout,LayoutSkip layoutSkip,LayoutOrder layoutOrder)336 VertexInputTest::VertexInputTest (tcu::TestContext&						testContext,
337 								  const std::string&					name,
338 								  const std::string&					description,
339 								  const std::vector<AttributeInfo>&		attributeInfos,
340 								  BindingMapping						bindingMapping,
341 								  AttributeLayout						attributeLayout,
342 								  LayoutSkip							layoutSkip,
343 								  LayoutOrder							layoutOrder)
344 
345 	: vkt::TestCase			(testContext, name, description)
346 	, m_attributeInfos		(attributeInfos)
347 	, m_bindingMapping		(bindingMapping)
348 	, m_attributeLayout		(attributeLayout)
349 	, m_layoutSkip			(layoutSkip)
350 	, m_queryMaxAttributes	(attributeInfos.size() == 0)
351 	, m_maxAttributes		(16)
352 {
353 	DE_ASSERT(m_attributeLayout == ATTRIBUTE_LAYOUT_INTERLEAVED || m_bindingMapping == BINDING_MAPPING_ONE_TO_MANY);
354 
355 	m_usesDoubleType = false;
356 
357 	for (size_t attributeNdx = 0; attributeNdx < m_attributeInfos.size(); attributeNdx++)
358 	{
359 		if (s_glslTypeDescriptions[m_attributeInfos[attributeNdx].glslType].basicType == GLSL_BASIC_TYPE_DOUBLE)
360 		{
361 			m_usesDoubleType = true;
362 			break;
363 		}
364 	}
365 
366 	// Determine number of location slots required for each attribute
367 	deUint32				attributeLocation		= 0;
368 	std::vector<deUint32>	locationSlotsNeeded;
369 	const size_t			numAttributes			= getNumAttributes();
370 
371 	for (size_t attributeNdx = 0; attributeNdx < numAttributes; ++attributeNdx)
372 	{
373 		const AttributeInfo&		attributeInfo			= getAttributeInfo(attributeNdx);
374 		const GlslTypeDescription&	glslTypeDescription		= s_glslTypeDescriptions[attributeInfo.glslType];
375 		const deUint32				prevAttributeLocation	= attributeLocation;
376 
377 		attributeLocation += glslTypeDescription.vertexInputCount * getConsumedLocations(attributeInfo);
378 
379 		if (m_layoutSkip == LAYOUT_SKIP_ENABLED)
380 			attributeLocation++;
381 
382 		locationSlotsNeeded.push_back(attributeLocation - prevAttributeLocation);
383 	}
384 
385 	if (layoutOrder == LAYOUT_ORDER_IN_ORDER)
386 	{
387 		deUint32 loc = 0;
388 
389 		// Assign locations in order
390 		for (size_t attributeNdx = 0; attributeNdx < numAttributes; ++attributeNdx)
391 		{
392 			m_locations.push_back(loc);
393 			loc += locationSlotsNeeded[attributeNdx];
394 		}
395 	}
396 	else
397 	{
398 		// Assign locations out of order
399 		std::vector<deUint32>	indices;
400 		std::vector<deUint32>	slots;
401 		deUint32				slot	= 0;
402 
403 		// Mix the location slots: first all even and then all odd attributes.
404 		for (deUint32 attributeNdx = 0; attributeNdx < numAttributes; ++attributeNdx)
405 			if (attributeNdx % 2 == 0)
406 				indices.push_back(attributeNdx);
407 		for (deUint32 attributeNdx = 0; attributeNdx < numAttributes; ++attributeNdx)
408 			if (attributeNdx % 2 != 0)
409 				indices.push_back(attributeNdx);
410 
411 		for (size_t i = 0; i < indices.size(); i++)
412 		{
413 			slots.push_back(slot);
414 			slot += locationSlotsNeeded[indices[i]];
415 		}
416 
417 		for (size_t attributeNdx = 0; attributeNdx < numAttributes; ++attributeNdx)
418 		{
419 			deUint32 slotIdx = 0;
420 			for (deUint32 i = 0; i < (deUint32)indices.size(); i++)
421 				if (attributeNdx == indices[i])
422 					slotIdx = i;
423 			m_locations.push_back(slots[slotIdx]);
424 		}
425 	}
426 }
427 
getAttributeInfo(size_t attributeNdx) const428 VertexInputTest::AttributeInfo VertexInputTest::getAttributeInfo (size_t attributeNdx) const
429 {
430 	if (m_queryMaxAttributes)
431 	{
432 		AttributeInfo attributeInfo =
433 		{
434 			GLSL_TYPE_VEC4,
435 			VK_FORMAT_R8G8B8A8_SNORM,
436 			(attributeNdx % 2 == 0) ? VK_VERTEX_INPUT_RATE_VERTEX : VK_VERTEX_INPUT_RATE_INSTANCE
437 		};
438 
439 		return attributeInfo;
440 	}
441 	else
442 	{
443 		return m_attributeInfos.at(attributeNdx);
444 	}
445 }
446 
getNumAttributes(void) const447 size_t VertexInputTest::getNumAttributes (void) const
448 {
449 	if (m_queryMaxAttributes)
450 		return m_maxAttributes;
451 	else
452 		return m_attributeInfos.size();
453 }
454 
checkSupport(Context & context) const455 void VertexInputTest::checkSupport (Context& context) const
456 {
457 	const deUint32 maxAttributes = context.getDeviceProperties().limits.maxVertexInputAttributes;
458 
459 	if (m_attributeInfos.size() > maxAttributes)
460 		TCU_THROW(NotSupportedError, "Unsupported number of vertex input attributes, maxVertexInputAttributes: " + de::toString(maxAttributes));
461 }
462 
createInstance(Context & context) const463 TestInstance* VertexInputTest::createInstance (Context& context) const
464 {
465 	typedef VertexInputInstance::VertexInputAttributeDescription VertexInputAttributeDescription;
466 
467 	// Check upfront for maximum number of vertex input attributes
468 	{
469 		const InstanceInterface&		vki				= context.getInstanceInterface();
470 		const VkPhysicalDevice			physDevice		= context.getPhysicalDevice();
471 		const VkPhysicalDeviceLimits	limits			= getPhysicalDeviceProperties(vki, physDevice).limits;
472 
473 		const deUint32					maxAttributes	= limits.maxVertexInputAttributes;
474 
475 		// Use VkPhysicalDeviceLimits::maxVertexInputAttributes
476 		if (m_queryMaxAttributes)
477 		{
478 			m_maxAttributes = maxAttributes;
479 			m_locations.clear();
480 			for (deUint32 i = 0; i < maxAttributes; i++)
481 				m_locations.push_back(i);
482 		}
483 	}
484 
485 	// Create enough binding descriptions with random offsets
486 	std::vector<VkVertexInputBindingDescription>	bindingDescriptions;
487 	std::vector<VkDeviceSize>						bindingOffsets;
488 	const size_t									numAttributes		= getNumAttributes();
489 	const size_t									numBindings			= (m_bindingMapping == BINDING_MAPPING_ONE_TO_ONE) ? numAttributes : ((numAttributes > 1) ? 2 : 1);
490 	const VkVertexInputRate							firstInputrate		= getAttributeInfo(0).inputRate;
491 
492 	for (size_t bindingNdx = 0; bindingNdx < numBindings; ++bindingNdx)
493 	{
494 		// Bindings alternate between STEP_RATE_VERTEX and STEP_RATE_INSTANCE
495 		const VkVertexInputRate						inputRate			= ((firstInputrate + bindingNdx) % 2 == 0) ? VK_VERTEX_INPUT_RATE_VERTEX : VK_VERTEX_INPUT_RATE_INSTANCE;
496 
497 		// Stride will be updated when creating the attribute descriptions
498 		const VkVertexInputBindingDescription		bindingDescription	=
499 		{
500 			static_cast<deUint32>(bindingNdx),		// deUint32				binding;
501 			0u,										// deUint32				stride;
502 			inputRate								// VkVertexInputRate	inputRate;
503 		};
504 
505 		bindingDescriptions.push_back(bindingDescription);
506 		bindingOffsets.push_back(4 * bindingNdx);
507 	}
508 
509 	std::vector<VertexInputAttributeDescription>	attributeDescriptions;
510 	std::vector<deUint32>							attributeOffsets		(bindingDescriptions.size(), 0);
511 	std::vector<deUint32>							attributeMaxSizes		(bindingDescriptions.size(), 0);	// max component or vector size, depending on which layout we are using
512 
513 	// To place the attributes sequentially we need to know the largest attribute and use its size in stride and offset calculations.
514 	if (m_attributeLayout == ATTRIBUTE_LAYOUT_SEQUENTIAL)
515 		for (size_t attributeNdx = 0; attributeNdx < numAttributes; ++attributeNdx)
516 		{
517 			const AttributeInfo&	attributeInfo			= getAttributeInfo(attributeNdx);
518 			const deUint32			attributeBinding		= getAttributeBinding(m_bindingMapping, firstInputrate, attributeInfo.inputRate, static_cast<deUint32>(attributeNdx));
519 			const deUint32			inputSize				= getVertexFormatSize(attributeInfo.vkType);
520 
521 			attributeMaxSizes[attributeBinding]				= de::max(attributeMaxSizes[attributeBinding], inputSize);
522 		}
523 
524 	// Create attribute descriptions, assign them to bindings and update stride.
525 	for (size_t attributeNdx = 0; attributeNdx < numAttributes; ++attributeNdx)
526 	{
527 		const AttributeInfo&		attributeInfo			= getAttributeInfo(attributeNdx);
528 		const GlslTypeDescription&	glslTypeDescription		= s_glslTypeDescriptions[attributeInfo.glslType];
529 		const deUint32				inputSize				= getVertexFormatSize(attributeInfo.vkType);
530 		const deUint32				attributeBinding		= getAttributeBinding(m_bindingMapping, firstInputrate, attributeInfo.inputRate, static_cast<deUint32>(attributeNdx));
531 		const deUint32				vertexCount				= (attributeInfo.inputRate == VK_VERTEX_INPUT_RATE_VERTEX) ? (4 * 2) : 2;
532 
533 		VertexInputAttributeDescription attributeDescription =
534 		{
535 			attributeInfo.glslType,							// GlslType		glslType;
536 			0,												// int			vertexInputIndex;
537 			{
538 				0u,											// uint32_t    location;
539 				attributeBinding,							// uint32_t    binding;
540 				attributeInfo.vkType,						// VkFormat    format;
541 				0u,											// uint32_t    offset;
542 			},
543 		};
544 
545 		// Matrix types add each column as a separate attribute.
546 		for (int descNdx = 0; descNdx < glslTypeDescription.vertexInputCount; ++descNdx)
547 		{
548 			attributeDescription.vertexInputIndex		= descNdx;
549 			attributeDescription.vkDescription.location	= m_locations[attributeNdx] + getConsumedLocations(attributeInfo) * descNdx;
550 
551 			if (m_attributeLayout == ATTRIBUTE_LAYOUT_INTERLEAVED)
552 			{
553 				const deUint32	offsetToComponentAlignment		 = getNextMultipleOffset(getVertexFormatSize(attributeInfo.vkType),
554 																						 (deUint32)bindingOffsets[attributeBinding] + attributeOffsets[attributeBinding]);
555 
556 				attributeOffsets[attributeBinding]				+= offsetToComponentAlignment;
557 
558 				attributeDescription.vkDescription.offset		 = attributeOffsets[attributeBinding];
559 				attributeDescriptions.push_back(attributeDescription);
560 
561 				bindingDescriptions[attributeBinding].stride	+= offsetToComponentAlignment + inputSize;
562 				attributeOffsets[attributeBinding]				+= inputSize;
563 				attributeMaxSizes[attributeBinding]				 = de::max(attributeMaxSizes[attributeBinding], getVertexFormatSize(attributeInfo.vkType));
564 			}
565 			else // m_attributeLayout == ATTRIBUTE_LAYOUT_SEQUENTIAL
566 			{
567 				attributeDescription.vkDescription.offset		 = attributeOffsets[attributeBinding];
568 				attributeDescriptions.push_back(attributeDescription);
569 
570 				attributeOffsets[attributeBinding]				+= vertexCount * attributeMaxSizes[attributeBinding];
571 			}
572 		}
573 
574 		if (m_attributeLayout == ATTRIBUTE_LAYOUT_SEQUENTIAL)
575 			bindingDescriptions[attributeBinding].stride = attributeMaxSizes[attributeBinding];
576 	}
577 
578 	// Make sure the stride results in aligned access
579 	for (size_t bindingNdx = 0; bindingNdx < bindingDescriptions.size(); ++bindingNdx)
580 	{
581 		if (attributeMaxSizes[bindingNdx] > 0)
582 			bindingDescriptions[bindingNdx].stride += getNextMultipleOffset(attributeMaxSizes[bindingNdx], bindingDescriptions[bindingNdx].stride);
583 	}
584 
585 	// Check upfront for maximum number of vertex input bindings
586 	{
587 		const InstanceInterface&		vki				= context.getInstanceInterface();
588 		const VkPhysicalDevice			physDevice		= context.getPhysicalDevice();
589 		const VkPhysicalDeviceLimits	limits			= getPhysicalDeviceProperties(vki, physDevice).limits;
590 
591 		const deUint32					maxBindings		= limits.maxVertexInputBindings;
592 
593 		if (bindingDescriptions.size() > maxBindings)
594 		{
595 			const std::string notSupportedStr = "Unsupported number of vertex input bindings, maxVertexInputBindings: " + de::toString(maxBindings);
596 			TCU_THROW(NotSupportedError, notSupportedStr.c_str());
597 		}
598 	}
599 
600 	return new VertexInputInstance(context, attributeDescriptions, bindingDescriptions, bindingOffsets);
601 }
602 
initPrograms(SourceCollections & programCollection) const603 void VertexInputTest::initPrograms (SourceCollections& programCollection) const
604 {
605 	std::ostringstream vertexSrc;
606 
607 	vertexSrc << "#version 440\n"
608 			  << "layout(constant_id = 0) const int numAttributes = " << m_maxAttributes << ";\n"
609 			  << getGlslInputDeclarations()
610 			  << "layout(location = 0) out highp vec4 vtxColor;\n"
611 			  << "out gl_PerVertex {\n"
612 			  << "  vec4 gl_Position;\n"
613 			  << "};\n";
614 
615 	// NOTE: double abs(double x) undefined in glslang ??
616 	if (m_usesDoubleType)
617 		vertexSrc << "double abs (double x) { if (x < 0.0LF) return -x; else return x; }\n";
618 
619 	vertexSrc << "void main (void)\n"
620 			  << "{\n"
621 			  << getGlslVertexCheck()
622 			  << "}\n";
623 
624 	programCollection.glslSources.add("attribute_test_vert") << glu::VertexSource(vertexSrc.str());
625 
626 	programCollection.glslSources.add("attribute_test_frag") << glu::FragmentSource(
627 		"#version 440\n"
628 		"layout(location = 0) in highp vec4 vtxColor;\n"
629 		"layout(location = 0) out highp vec4 fragColor;\n"
630 		"void main (void)\n"
631 		"{\n"
632 		"	fragColor = vtxColor;\n"
633 		"}\n");
634 }
635 
getGlslInputDeclarations(void) const636 std::string VertexInputTest::getGlslInputDeclarations (void) const
637 {
638 	std::ostringstream	glslInputs;
639 
640 	if (m_queryMaxAttributes)
641 	{
642 		const GlslTypeDescription& glslTypeDesc = s_glslTypeDescriptions[GLSL_TYPE_VEC4];
643 		glslInputs << "layout(location = 0) in " << glslTypeDesc.name << " attr[numAttributes];\n";
644 	}
645 	else
646 	{
647 		for (size_t attributeNdx = 0; attributeNdx < m_attributeInfos.size(); attributeNdx++)
648 		{
649 			const GlslTypeDescription& glslTypeDesc = s_glslTypeDescriptions[m_attributeInfos[attributeNdx].glslType];
650 
651 			glslInputs << "layout(location = " << m_locations[attributeNdx] << ") in " << glslTypeDesc.name << " attr" << attributeNdx << ";\n";
652 		}
653 	}
654 
655 	return glslInputs.str();
656 }
657 
getGlslVertexCheck(void) const658 std::string VertexInputTest::getGlslVertexCheck (void) const
659 {
660 	std::ostringstream	glslCode;
661 	int					totalInputComponentCount	= 0;
662 
663 	glslCode << "	int okCount = 0;\n";
664 
665 	if (m_queryMaxAttributes)
666 	{
667 		const AttributeInfo attributeInfo = getAttributeInfo(0);
668 
669 		glslCode << "	for (int checkNdx = 0; checkNdx < numAttributes; checkNdx++)\n"
670 				 <<	"	{\n"
671 				 << "		uint index = (checkNdx % 2 == 0) ? gl_VertexIndex : gl_InstanceIndex;\n";
672 
673 		glslCode << getGlslAttributeConditions(attributeInfo, "checkNdx")
674 				 << "	}\n";
675 
676 			const int vertexInputCount	= VertexInputTest::s_glslTypeDescriptions[attributeInfo.glslType].vertexInputCount;
677 			totalInputComponentCount	+= vertexInputCount * VertexInputTest::s_glslTypeDescriptions[attributeInfo.glslType].vertexInputComponentCount;
678 
679 		glslCode <<
680 			"	if (okCount == " << totalInputComponentCount << " * numAttributes)\n"
681 			"	{\n"
682 			"		if (gl_InstanceIndex == 0)\n"
683 			"			vtxColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
684 			"		else\n"
685 			"			vtxColor = vec4(0.0, 0.0, 1.0, 1.0);\n"
686 			"	}\n"
687 			"	else\n"
688 			"	{\n"
689 			"		vtxColor = vec4(okCount / float(" << totalInputComponentCount << " * numAttributes), 0.0f, 0.0f, 1.0);\n" <<
690 			"	}\n\n"
691 			"	if (gl_InstanceIndex == 0)\n"
692 			"	{\n"
693 			"		if (gl_VertexIndex == 0) gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);\n"
694 			"		else if (gl_VertexIndex == 1) gl_Position = vec4(0.0, -1.0, 0.0, 1.0);\n"
695 			"		else if (gl_VertexIndex == 2) gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);\n"
696 			"		else if (gl_VertexIndex == 3) gl_Position = vec4(0.0, 1.0, 0.0, 1.0);\n"
697 			"		else gl_Position = vec4(0.0);\n"
698 			"	}\n"
699 			"	else\n"
700 			"	{\n"
701 			"		if (gl_VertexIndex == 0) gl_Position = vec4(0.0, -1.0, 0.0, 1.0);\n"
702 			"		else if (gl_VertexIndex == 1) gl_Position = vec4(1.0, -1.0, 0.0, 1.0);\n"
703 			"		else if (gl_VertexIndex == 2) gl_Position = vec4(0.0, 1.0, 0.0, 1.0);\n"
704 			"		else if (gl_VertexIndex == 3) gl_Position = vec4(1.0, 1.0, 0.0, 1.0);\n"
705 			"		else gl_Position = vec4(0.0);\n"
706 			"	}\n";
707 	}
708 	else
709 	{
710 		for (size_t attributeNdx = 0; attributeNdx < m_attributeInfos.size(); attributeNdx++)
711 		{
712 			glslCode << getGlslAttributeConditions(m_attributeInfos[attributeNdx], de::toString(attributeNdx));
713 
714 			const int vertexInputCount	= VertexInputTest::s_glslTypeDescriptions[m_attributeInfos[attributeNdx].glslType].vertexInputCount;
715 			totalInputComponentCount	+= vertexInputCount * VertexInputTest::s_glslTypeDescriptions[m_attributeInfos[attributeNdx].glslType].vertexInputComponentCount;
716 		}
717 
718 		glslCode <<
719 			"	if (okCount == " << totalInputComponentCount << ")\n"
720 			"	{\n"
721 			"		if (gl_InstanceIndex == 0)\n"
722 			"			vtxColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
723 			"		else\n"
724 			"			vtxColor = vec4(0.0, 0.0, 1.0, 1.0);\n"
725 			"	}\n"
726 			"	else\n"
727 			"	{\n"
728 			"		vtxColor = vec4(okCount / float(" << totalInputComponentCount << "), 0.0f, 0.0f, 1.0);\n" <<
729 			"	}\n\n"
730 			"	if (gl_InstanceIndex == 0)\n"
731 			"	{\n"
732 			"		if (gl_VertexIndex == 0) gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);\n"
733 			"		else if (gl_VertexIndex == 1) gl_Position = vec4(0.0, -1.0, 0.0, 1.0);\n"
734 			"		else if (gl_VertexIndex == 2) gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);\n"
735 			"		else if (gl_VertexIndex == 3) gl_Position = vec4(0.0, 1.0, 0.0, 1.0);\n"
736 			"		else gl_Position = vec4(0.0);\n"
737 			"	}\n"
738 			"	else\n"
739 			"	{\n"
740 			"		if (gl_VertexIndex == 0) gl_Position = vec4(0.0, -1.0, 0.0, 1.0);\n"
741 			"		else if (gl_VertexIndex == 1) gl_Position = vec4(1.0, -1.0, 0.0, 1.0);\n"
742 			"		else if (gl_VertexIndex == 2) gl_Position = vec4(0.0, 1.0, 0.0, 1.0);\n"
743 			"		else if (gl_VertexIndex == 3) gl_Position = vec4(1.0, 1.0, 0.0, 1.0);\n"
744 			"		else gl_Position = vec4(0.0);\n"
745 			"	}\n";
746 	}
747 	return glslCode.str();
748 }
749 
getGlslAttributeConditions(const AttributeInfo & attributeInfo,const std::string attributeIndex) const750 std::string VertexInputTest::getGlslAttributeConditions (const AttributeInfo& attributeInfo, const std::string attributeIndex) const
751 {
752 	std::ostringstream	glslCode;
753 	std::ostringstream	attributeVar;
754 	const int			componentCount		= VertexInputTest::s_glslTypeDescriptions[attributeInfo.glslType].vertexInputComponentCount;
755 	const int			vertexInputCount	= VertexInputTest::s_glslTypeDescriptions[attributeInfo.glslType].vertexInputCount;
756 	const deUint32		totalComponentCount	= componentCount * vertexInputCount;
757 	const tcu::Vec4		threshold			= getFormatThreshold(attributeInfo.vkType);
758 	const std::string	indexStr			= m_queryMaxAttributes ? "[" + attributeIndex + "]" : attributeIndex;
759 	const std::string	indentStr			= m_queryMaxAttributes ? "\t\t" : "\t";
760 	deUint32			componentIndex		= 0;
761 	deUint32			orderNdx;
762 	std::string			indexId;
763 
764 	const deUint32		BGROrder[]			= { 2, 1, 0, 3 };
765 	const deUint32		ABGROrder[]			= { 3, 2, 1, 0 };
766 	const deUint32		ARGBOrder[]			= { 1, 2, 3, 0 };
767 
768 	if (m_queryMaxAttributes)
769 		indexId	= "index";
770 	else
771 		indexId	= (attributeInfo.inputRate == VK_VERTEX_INPUT_RATE_VERTEX) ? "gl_VertexIndex" : "gl_InstanceIndex";
772 
773 	attributeVar << "attr" << indexStr;
774 
775 	glslCode << std::fixed;
776 
777 	for (int columnNdx = 0; columnNdx< vertexInputCount; columnNdx++)
778 	{
779 		for (int rowNdx = 0; rowNdx < componentCount; rowNdx++)
780 		{
781 			if (isVertexFormatComponentOrderABGR(attributeInfo.vkType))
782 				orderNdx = ABGROrder[rowNdx];
783 			else if (isVertexFormatComponentOrderARGB(attributeInfo.vkType))
784 				orderNdx = ARGBOrder[rowNdx];
785 			else
786 				orderNdx = BGROrder[rowNdx];
787 
788 			std::string accessStr;
789 			{
790 				// Build string representing the access to the attribute component
791 				std::ostringstream accessStream;
792 				accessStream << attributeVar.str();
793 
794 				if (vertexInputCount == 1)
795 				{
796 					if (componentCount > 1)
797 						accessStream << "[" << rowNdx << "]";
798 				}
799 				else
800 				{
801 					accessStream << "[" << columnNdx << "][" << rowNdx << "]";
802 				}
803 
804 				accessStr = accessStream.str();
805 			}
806 
807 			if (isVertexFormatSint(attributeInfo.vkType))
808 			{
809 				if (isVertexFormatPacked(attributeInfo.vkType))
810 				{
811 					const deInt32 maxIntValue = (1 << (getPackedVertexFormatComponentWidth(attributeInfo.vkType, orderNdx) - 1)) - 1;
812 					const deInt32 minIntValue = -maxIntValue;
813 
814 					glslCode << indentStr << "if (" << accessStr << " == clamp(-(" << totalComponentCount << " * " << indexId << " + " << componentIndex << "), " << minIntValue << ", " << maxIntValue << "))\n";
815 				}
816 				else
817 					glslCode << indentStr << "if (" << accessStr << " == -(" << totalComponentCount << " * " << indexId << " + " << componentIndex << "))\n";
818 			}
819 			else if (isVertexFormatUint(attributeInfo.vkType))
820 			{
821 				if (isVertexFormatPacked(attributeInfo.vkType))
822 				{
823 					const deUint32 maxUintValue = (1 << getPackedVertexFormatComponentWidth(attributeInfo.vkType, orderNdx)) - 1;
824 
825 					glslCode << indentStr << "if (" << accessStr << " == clamp(uint(" << totalComponentCount << " * " << indexId << " + " << componentIndex << "), 0, " << maxUintValue << "))\n";
826 				}
827 				else
828 					glslCode << indentStr << "if (" << accessStr << " == uint(" << totalComponentCount << " * " << indexId << " + " << componentIndex << "))\n";
829 			}
830 			else if (isVertexFormatSfloat(attributeInfo.vkType))
831 			{
832 				if (VertexInputTest::s_glslTypeDescriptions[attributeInfo.glslType].basicType == VertexInputTest::GLSL_BASIC_TYPE_DOUBLE)
833 				{
834 					glslCode << indentStr << "if (abs(" << accessStr << " + double(0.01 * (" << totalComponentCount << ".0 * float(" << indexId << ") + " << componentIndex << ".0))) < double(" << threshold[rowNdx] << "))\n";
835 				}
836 				else
837 				{
838 					glslCode << indentStr << "if (abs(" << accessStr << " + (0.01 * (" << totalComponentCount << ".0 * float(" << indexId << ") + " << componentIndex << ".0))) < " << threshold[rowNdx] << ")\n";
839 				}
840 			}
841 			else if (isVertexFormatSscaled(attributeInfo.vkType))
842 			{
843 				if (isVertexFormatPacked(attributeInfo.vkType))
844 				{
845 					const float maxScaledValue = float((1 << (getPackedVertexFormatComponentWidth(attributeInfo.vkType, orderNdx) - 1)) - 1);
846 					const float minScaledValue = -maxScaledValue - 1.0f;
847 
848 					glslCode << indentStr << "if (abs(" << accessStr << " + clamp(" << totalComponentCount << ".0 * float(" << indexId << ") + " << componentIndex << ".0, " << minScaledValue << ", " << maxScaledValue << ")) < " << threshold[orderNdx] << ")\n";
849 				}
850 				else
851 					glslCode << indentStr << "if (abs(" << accessStr << " + (" << totalComponentCount << ".0 * float(" << indexId << ") + " << componentIndex << ".0)) < " << threshold[rowNdx] << ")\n";
852 			}
853 			else if (isVertexFormatUscaled(attributeInfo.vkType))
854 			{
855 				if (isVertexFormatPacked(attributeInfo.vkType))
856 				{
857 					const float maxScaledValue = float((1 << getPackedVertexFormatComponentWidth(attributeInfo.vkType, orderNdx)) - 1);
858 
859 					glslCode << indentStr << "if (abs(" << accessStr << " - clamp(" << totalComponentCount << ".0 * float(" << indexId << ") + " << componentIndex << ".0, 0, " << maxScaledValue << ")) < " << threshold[orderNdx] << ")\n";
860 				}
861 				else
862 					glslCode << indentStr << "if (abs(" << accessStr << " - (" << totalComponentCount << ".0 * float(" << indexId << ") + " << componentIndex << ".0)) < " << threshold[rowNdx] << ")\n";
863 			}
864 			else if (isVertexFormatSnorm(attributeInfo.vkType))
865 			{
866 				const float representableDiff = isVertexFormatPacked(attributeInfo.vkType) ? getRepresentableDifferenceSnormPacked(attributeInfo.vkType, orderNdx) : getRepresentableDifferenceSnorm(attributeInfo.vkType);
867 
868 				if(isVertexFormatPacked(attributeInfo.vkType))
869 					glslCode << indentStr << "if (abs(" << accessStr << " - clamp((-1.0 + " << representableDiff << " * (" << totalComponentCount << ".0 * float(" << indexId << ") + " << componentIndex << ".0)), -1.0, 1.0)) < " << threshold[orderNdx] << ")\n";
870 				else
871 					glslCode << indentStr << "if (abs(" << accessStr << " - (-1.0 + " << representableDiff << " * (" << totalComponentCount << ".0 * float(" << indexId << ") + " << componentIndex << ".0))) < " << threshold[rowNdx] << ")\n";
872 			}
873 			else if (isVertexFormatUnorm(attributeInfo.vkType) || isVertexFormatSRGB(attributeInfo.vkType))
874 			{
875 				const float representableDiff = isVertexFormatPacked(attributeInfo.vkType) ? getRepresentableDifferenceUnormPacked(attributeInfo.vkType, orderNdx) : getRepresentableDifferenceUnorm(attributeInfo.vkType);
876 
877 				if (isVertexFormatPacked(attributeInfo.vkType))
878 					glslCode << indentStr << "if (abs(" << accessStr << " - " << "clamp((" << representableDiff << " * (" << totalComponentCount << ".0 * float(" << indexId << ") + " << componentIndex << ".0)), 0.0, 1.0)) < " << threshold[orderNdx] << ")\n";
879 				else
880 					glslCode << indentStr << "if (abs(" << accessStr << " - " << "(" << representableDiff << " * (" << totalComponentCount << ".0 * float(" << indexId << ") + " << componentIndex << ".0))) < " << threshold[rowNdx] << ")\n";
881 			}
882 			else
883 			{
884 				DE_ASSERT(false);
885 			}
886 
887 			glslCode << indentStr << "\tokCount++;\n\n";
888 
889 			componentIndex++;
890 		}
891 	}
892 	return glslCode.str();
893 }
894 
getFormatThreshold(VkFormat format)895 tcu::Vec4 VertexInputTest::getFormatThreshold (VkFormat format)
896 {
897 	using tcu::Vec4;
898 
899 	switch (format)
900 	{
901 		case VK_FORMAT_R32_SFLOAT:
902 		case VK_FORMAT_R32G32_SFLOAT:
903 		case VK_FORMAT_R32G32B32_SFLOAT:
904 		case VK_FORMAT_R32G32B32A32_SFLOAT:
905 		case VK_FORMAT_R64_SFLOAT:
906 		case VK_FORMAT_R64G64_SFLOAT:
907 		case VK_FORMAT_R64G64B64_SFLOAT:
908 		case VK_FORMAT_R64G64B64A64_SFLOAT:
909 			return Vec4(0.00001f);
910 
911 		default:
912 			break;
913 	}
914 
915 	if (isVertexFormatSnorm(format))
916 	{
917 		return (isVertexFormatPacked(format) ? Vec4(1.5f * getRepresentableDifferenceSnormPacked(format, 0),
918 													1.5f * getRepresentableDifferenceSnormPacked(format, 1),
919 													1.5f * getRepresentableDifferenceSnormPacked(format, 2),
920 													1.5f * getRepresentableDifferenceSnormPacked(format, 3))
921 													: Vec4(1.5f * getRepresentableDifferenceSnorm(format)));
922 	}
923 	else if (isVertexFormatUnorm(format))
924 	{
925 		return (isVertexFormatPacked(format) ? Vec4(1.5f * getRepresentableDifferenceUnormPacked(format, 0),
926 													1.5f * getRepresentableDifferenceUnormPacked(format, 1),
927 													1.5f * getRepresentableDifferenceUnormPacked(format, 2),
928 													1.5f * getRepresentableDifferenceUnormPacked(format, 3))
929 													: Vec4(1.5f * getRepresentableDifferenceUnorm(format)));
930 	}
931 
932 	return Vec4(0.001f);
933 }
934 
VertexInputInstance(Context & context,const AttributeDescriptionList & attributeDescriptions,const std::vector<VkVertexInputBindingDescription> & bindingDescriptions,const std::vector<VkDeviceSize> & bindingOffsets)935 VertexInputInstance::VertexInputInstance (Context&												context,
936 										  const AttributeDescriptionList&						attributeDescriptions,
937 										  const std::vector<VkVertexInputBindingDescription>&	bindingDescriptions,
938 										  const std::vector<VkDeviceSize>&						bindingOffsets)
939 	: vkt::TestInstance			(context)
940 	, m_renderSize				(16, 16)
941 	, m_colorFormat				(VK_FORMAT_R8G8B8A8_UNORM)
942 {
943 	DE_ASSERT(bindingDescriptions.size() == bindingOffsets.size());
944 
945 	const DeviceInterface&		vk						= context.getDeviceInterface();
946 	const VkDevice				vkDevice				= context.getDevice();
947 	const deUint32				queueFamilyIndex		= context.getUniversalQueueFamilyIndex();
948 	SimpleAllocator				memAlloc				(vk, vkDevice, getPhysicalDeviceMemoryProperties(context.getInstanceInterface(), context.getPhysicalDevice()));
949 	const VkComponentMapping	componentMappingRGBA	= { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A };
950 
951 	// Check upfront for unsupported features
952 	for (size_t attributeNdx = 0; attributeNdx < attributeDescriptions.size(); attributeNdx++)
953 	{
954 		const VkVertexInputAttributeDescription& attributeDescription = attributeDescriptions[attributeNdx].vkDescription;
955 		if (!isSupportedVertexFormat(context, attributeDescription.format))
956 		{
957 			throw tcu::NotSupportedError(std::string("Unsupported format for vertex input: ") + getFormatName(attributeDescription.format));
958 		}
959 	}
960 
961 	// Create color image
962 	{
963 		const VkImageCreateInfo colorImageParams =
964 		{
965 			VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,										// VkStructureType			sType;
966 			DE_NULL,																	// const void*				pNext;
967 			0u,																			// VkImageCreateFlags		flags;
968 			VK_IMAGE_TYPE_2D,															// VkImageType				imageType;
969 			m_colorFormat,																// VkFormat					format;
970 			{ m_renderSize.x(), m_renderSize.y(), 1u },									// VkExtent3D				extent;
971 			1u,																			// deUint32					mipLevels;
972 			1u,																			// deUint32					arrayLayers;
973 			VK_SAMPLE_COUNT_1_BIT,														// VkSampleCountFlagBits	samples;
974 			VK_IMAGE_TILING_OPTIMAL,													// VkImageTiling			tiling;
975 			VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT,		// VkImageUsageFlags		usage;
976 			VK_SHARING_MODE_EXCLUSIVE,													// VkSharingMode			sharingMode;
977 			1u,																			// deUint32					queueFamilyIndexCount;
978 			&queueFamilyIndex,															// const deUint32*			pQueueFamilyIndices;
979 			VK_IMAGE_LAYOUT_UNDEFINED,													// VkImageLayout			initialLayout;
980 		};
981 
982 		m_colorImage			= createImage(vk, vkDevice, &colorImageParams);
983 
984 		// Allocate and bind color image memory
985 		m_colorImageAlloc		= memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_colorImage), MemoryRequirement::Any);
986 		VK_CHECK(vk.bindImageMemory(vkDevice, *m_colorImage, m_colorImageAlloc->getMemory(), m_colorImageAlloc->getOffset()));
987 	}
988 
989 	// Create color attachment view
990 	{
991 		const VkImageViewCreateInfo colorAttachmentViewParams =
992 		{
993 			VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,		// VkStructureType			sType;
994 			DE_NULL,										// const void*				pNext;
995 			0u,												// VkImageViewCreateFlags	flags;
996 			*m_colorImage,									// VkImage					image;
997 			VK_IMAGE_VIEW_TYPE_2D,							// VkImageViewType			viewType;
998 			m_colorFormat,									// VkFormat					format;
999 			componentMappingRGBA,							// VkComponentMapping		components;
1000 			{ VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u },  // VkImageSubresourceRange	subresourceRange;
1001 		};
1002 
1003 		m_colorAttachmentView = createImageView(vk, vkDevice, &colorAttachmentViewParams);
1004 	}
1005 
1006 	// Create render pass
1007 	m_renderPass = makeRenderPass(vk, vkDevice, m_colorFormat);
1008 
1009 	// Create framebuffer
1010 	{
1011 		const VkFramebufferCreateInfo framebufferParams =
1012 		{
1013 			VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,			// VkStructureType			sType;
1014 			DE_NULL,											// const void*				pNext;
1015 			0u,													// VkFramebufferCreateFlags	flags;
1016 			*m_renderPass,										// VkRenderPass				renderPass;
1017 			1u,													// deUint32					attachmentCount;
1018 			&m_colorAttachmentView.get(),						// const VkImageView*		pAttachments;
1019 			(deUint32)m_renderSize.x(),							// deUint32					width;
1020 			(deUint32)m_renderSize.y(),							// deUint32					height;
1021 			1u													// deUint32					layers;
1022 		};
1023 
1024 		m_framebuffer = createFramebuffer(vk, vkDevice, &framebufferParams);
1025 	}
1026 
1027 	// Create pipeline layout
1028 	{
1029 		const VkPipelineLayoutCreateInfo pipelineLayoutParams =
1030 		{
1031 			VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,		// VkStructureType					sType;
1032 			DE_NULL,											// const void*						pNext;
1033 			0u,													// VkPipelineLayoutCreateFlags		flags;
1034 			0u,													// deUint32							setLayoutCount;
1035 			DE_NULL,											// const VkDescriptorSetLayout*		pSetLayouts;
1036 			0u,													// deUint32							pushConstantRangeCount;
1037 			DE_NULL												// const VkPushConstantRange*		pPushConstantRanges;
1038 		};
1039 
1040 		m_pipelineLayout = createPipelineLayout(vk, vkDevice, &pipelineLayoutParams);
1041 	}
1042 
1043 	m_vertexShaderModule	= createShaderModule(vk, vkDevice, m_context.getBinaryCollection().get("attribute_test_vert"), 0);
1044 	m_fragmentShaderModule	= createShaderModule(vk, vkDevice, m_context.getBinaryCollection().get("attribute_test_frag"), 0);
1045 
1046 	// Create specialization constant
1047 	deUint32 specializationData = static_cast<deUint32>(attributeDescriptions.size());
1048 
1049 	const VkSpecializationMapEntry specializationMapEntry =
1050 	{
1051 		0,														// uint32_t							constantID
1052 		0,														// uint32_t							offset
1053 		sizeof(specializationData),								// uint32_t							size
1054 	};
1055 
1056 	const VkSpecializationInfo specializationInfo =
1057 	{
1058 		1,														// uint32_t							mapEntryCount
1059 		&specializationMapEntry,								// const void*						pMapEntries
1060 		sizeof(specializationData),								// size_t							dataSize
1061 		&specializationData										// const void*						pData
1062 	};
1063 
1064 	// Create pipeline
1065 	{
1066 		const VkPipelineShaderStageCreateInfo shaderStageParams[2] =
1067 		{
1068 			{
1069 				VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,		// VkStructureType						sType;
1070 				DE_NULL,													// const void*							pNext;
1071 				0u,															// VkPipelineShaderStageCreateFlags		flags;
1072 				VK_SHADER_STAGE_VERTEX_BIT,									// VkShaderStageFlagBits				stage;
1073 				*m_vertexShaderModule,										// VkShaderModule						module;
1074 				"main",														// const char*							pName;
1075 				&specializationInfo											// const VkSpecializationInfo*			pSpecializationInfo;
1076 			},
1077 			{
1078 				VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,		// VkStructureType						sType;
1079 				DE_NULL,													// const void*							pNext;
1080 				0u,															// VkPipelineShaderStageCreateFlags		flags;
1081 				VK_SHADER_STAGE_FRAGMENT_BIT,								// VkShaderStageFlagBits				stage;
1082 				*m_fragmentShaderModule,									// VkShaderModule						module;
1083 				"main",														// const char*							pName;
1084 				DE_NULL														// const VkSpecializationInfo*			pSpecializationInfo;
1085 			}
1086 		};
1087 
1088 		// Create vertex attribute array and check if their VK formats are supported
1089 		std::vector<VkVertexInputAttributeDescription> vkAttributeDescriptions;
1090 		for (size_t attributeNdx = 0; attributeNdx < attributeDescriptions.size(); attributeNdx++)
1091 		{
1092 			const VkVertexInputAttributeDescription& attributeDescription = attributeDescriptions[attributeNdx].vkDescription;
1093 			vkAttributeDescriptions.push_back(attributeDescription);
1094 		}
1095 
1096 		const VkPipelineVertexInputStateCreateInfo	vertexInputStateParams	=
1097 		{
1098 			VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,		// VkStructureType							sType;
1099 			DE_NULL,														// const void*								pNext;
1100 			0u,																// VkPipelineVertexInputStateCreateFlags	flags;
1101 			(deUint32)bindingDescriptions.size(),							// deUint32									vertexBindingDescriptionCount;
1102 			bindingDescriptions.data(),										// const VkVertexInputBindingDescription*	pVertexBindingDescriptions;
1103 			(deUint32)vkAttributeDescriptions.size(),						// deUint32									vertexAttributeDescriptionCount;
1104 			vkAttributeDescriptions.data()									// const VkVertexInputAttributeDescription*	pVertexAttributeDescriptions;
1105 		};
1106 
1107 		const VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateParams =
1108 		{
1109 			VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,	// VkStructureType							sType;
1110 			DE_NULL,														// const void*								pNext;
1111 			0u,																// VkPipelineInputAssemblyStateCreateFlags	flags;
1112 			VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,							// VkPrimitiveTopology						topology;
1113 			false															// VkBool32									primitiveRestartEnable;
1114 		};
1115 
1116 		const VkViewport	viewport	= makeViewport(m_renderSize);
1117 		const VkRect2D		scissor		= makeRect2D(m_renderSize);
1118 
1119 		const VkPipelineViewportStateCreateInfo viewportStateParams =
1120 		{
1121 			VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,			// VkStructureType						sType;
1122 			DE_NULL,														// const void*							pNext;
1123 			0u,																// VkPipelineViewportStateCreateFlags	flags;
1124 			1u,																// deUint32								viewportCount;
1125 			&viewport,														// const VkViewport*					pViewports;
1126 			1u,																// deUint32								scissorCount;
1127 			&scissor														// const VkRect2D*						pScissors;
1128 		};
1129 
1130 		const VkPipelineRasterizationStateCreateInfo rasterStateParams =
1131 		{
1132 			VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,		// VkStructureType							sType;
1133 			DE_NULL,														// const void*								pNext;
1134 			0u,																// VkPipelineRasterizationStateCreateFlags	flags;
1135 			false,															// VkBool32									depthClampEnable;
1136 			false,															// VkBool32									rasterizerDiscardEnable;
1137 			VK_POLYGON_MODE_FILL,											// VkPolygonMode							polygonMode;
1138 			VK_CULL_MODE_NONE,												// VkCullModeFlags							cullMode;
1139 			VK_FRONT_FACE_COUNTER_CLOCKWISE,								// VkFrontFace								frontFace;
1140 			VK_FALSE,														// VkBool32									depthBiasEnable;
1141 			0.0f,															// float									depthBiasConstantFactor;
1142 			0.0f,															// float									depthBiasClamp;
1143 			0.0f,															// float									depthBiasSlopeFactor;
1144 			1.0f,															// float									lineWidth;
1145 		};
1146 
1147 		const VkPipelineColorBlendAttachmentState colorBlendAttachmentState =
1148 		{
1149 			false,																		// VkBool32					blendEnable;
1150 			VK_BLEND_FACTOR_ONE,														// VkBlendFactor			srcColorBlendFactor;
1151 			VK_BLEND_FACTOR_ZERO,														// VkBlendFactor			dstColorBlendFactor;
1152 			VK_BLEND_OP_ADD,															// VkBlendOp				colorBlendOp;
1153 			VK_BLEND_FACTOR_ONE,														// VkBlendFactor			srcAlphaBlendFactor;
1154 			VK_BLEND_FACTOR_ZERO,														// VkBlendFactor			dstAlphaBlendFactor;
1155 			VK_BLEND_OP_ADD,															// VkBlendOp				alphaBlendOp;
1156 			VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |						// VkColorComponentFlags	colorWriteMask;
1157 				VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT
1158 		};
1159 
1160 		const VkPipelineColorBlendStateCreateInfo colorBlendStateParams =
1161 		{
1162 			VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,	// VkStructureType								sType;
1163 			DE_NULL,													// const void*									pNext;
1164 			0u,															// VkPipelineColorBlendStateCreateFlags			flags;
1165 			false,														// VkBool32										logicOpEnable;
1166 			VK_LOGIC_OP_COPY,											// VkLogicOp									logicOp;
1167 			1u,															// deUint32										attachmentCount;
1168 			&colorBlendAttachmentState,									// const VkPipelineColorBlendAttachmentState*	pAttachments;
1169 			{ 0.0f, 0.0f, 0.0f, 0.0f },									// float										blendConstants[4];
1170 		};
1171 
1172 		const VkPipelineMultisampleStateCreateInfo	multisampleStateParams	=
1173 		{
1174 			VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,	// VkStructureType							sType;
1175 			DE_NULL,													// const void*								pNext;
1176 			0u,															// VkPipelineMultisampleStateCreateFlags	flags;
1177 			VK_SAMPLE_COUNT_1_BIT,										// VkSampleCountFlagBits					rasterizationSamples;
1178 			false,														// VkBool32									sampleShadingEnable;
1179 			0.0f,														// float									minSampleShading;
1180 			DE_NULL,													// const VkSampleMask*						pSampleMask;
1181 			false,														// VkBool32									alphaToCoverageEnable;
1182 			false														// VkBool32									alphaToOneEnable;
1183 		};
1184 
1185 		VkPipelineDepthStencilStateCreateInfo depthStencilStateParams =
1186 		{
1187 			VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,	// VkStructureType							sType;
1188 			DE_NULL,													// const void*								pNext;
1189 			0u,															// VkPipelineDepthStencilStateCreateFlags	flags;
1190 			false,														// VkBool32									depthTestEnable;
1191 			false,														// VkBool32									depthWriteEnable;
1192 			VK_COMPARE_OP_LESS,											// VkCompareOp								depthCompareOp;
1193 			false,														// VkBool32									depthBoundsTestEnable;
1194 			false,														// VkBool32									stencilTestEnable;
1195 			// VkStencilOpState	front;
1196 			{
1197 				VK_STENCIL_OP_KEEP,		// VkStencilOp	failOp;
1198 				VK_STENCIL_OP_KEEP,		// VkStencilOp	passOp;
1199 				VK_STENCIL_OP_KEEP,		// VkStencilOp	depthFailOp;
1200 				VK_COMPARE_OP_NEVER,	// VkCompareOp	compareOp;
1201 				0u,						// deUint32		compareMask;
1202 				0u,						// deUint32		writeMask;
1203 				0u,						// deUint32		reference;
1204 			},
1205 			// VkStencilOpState	back;
1206 			{
1207 				VK_STENCIL_OP_KEEP,		// VkStencilOp	failOp;
1208 				VK_STENCIL_OP_KEEP,		// VkStencilOp	passOp;
1209 				VK_STENCIL_OP_KEEP,		// VkStencilOp	depthFailOp;
1210 				VK_COMPARE_OP_NEVER,	// VkCompareOp	compareOp;
1211 				0u,						// deUint32		compareMask;
1212 				0u,						// deUint32		writeMask;
1213 				0u,						// deUint32		reference;
1214 			},
1215 			0.0f,														// float			minDepthBounds;
1216 			1.0f,														// float			maxDepthBounds;
1217 		};
1218 
1219 		const VkGraphicsPipelineCreateInfo graphicsPipelineParams =
1220 		{
1221 			VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,	// VkStructureType									sType;
1222 			DE_NULL,											// const void*										pNext;
1223 			0u,													// VkPipelineCreateFlags							flags;
1224 			2u,													// deUint32											stageCount;
1225 			shaderStageParams,									// const VkPipelineShaderStageCreateInfo*			pStages;
1226 			&vertexInputStateParams,							// const VkPipelineVertexInputStateCreateInfo*		pVertexInputState;
1227 			&inputAssemblyStateParams,							// const VkPipelineInputAssemblyStateCreateInfo*	pInputAssemblyState;
1228 			DE_NULL,											// const VkPipelineTessellationStateCreateInfo*		pTessellationState;
1229 			&viewportStateParams,								// const VkPipelineViewportStateCreateInfo*			pViewportState;
1230 			&rasterStateParams,									// const VkPipelineRasterizationStateCreateInfo*	pRasterizationState;
1231 			&multisampleStateParams,							// const VkPipelineMultisampleStateCreateInfo*		pMultisampleState;
1232 			&depthStencilStateParams,							// const VkPipelineDepthStencilStateCreateInfo*		pDepthStencilState;
1233 			&colorBlendStateParams,								// const VkPipelineColorBlendStateCreateInfo*		pColorBlendState;
1234 			(const VkPipelineDynamicStateCreateInfo*)DE_NULL,	// const VkPipelineDynamicStateCreateInfo*			pDynamicState;
1235 			*m_pipelineLayout,									// VkPipelineLayout									layout;
1236 			*m_renderPass,										// VkRenderPass										renderPass;
1237 			0u,													// deUint32											subpass;
1238 			0u,													// VkPipeline										basePipelineHandle;
1239 			0u													// deInt32											basePipelineIndex;
1240 		};
1241 
1242 		m_graphicsPipeline	= createGraphicsPipeline(vk, vkDevice, DE_NULL, &graphicsPipelineParams);
1243 	}
1244 
1245 	// Create vertex buffer
1246 	{
1247 		// calculate buffer size
1248 		// 32 is maximal attribute size (4*sizeof(double)),
1249 		// 8 maximal vertex count used in writeVertexInputData
1250 		VkDeviceSize bufferSize = 32 * 8 * attributeDescriptions.size();
1251 
1252 		const VkBufferCreateInfo vertexBufferParams =
1253 		{
1254 			VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,		// VkStructureType		sType;
1255 			DE_NULL,									// const void*			pNext;
1256 			0u,											// VkBufferCreateFlags	flags;
1257 			bufferSize,									// VkDeviceSize			size;
1258 			VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,			// VkBufferUsageFlags	usage;
1259 			VK_SHARING_MODE_EXCLUSIVE,					// VkSharingMode		sharingMode;
1260 			1u,											// deUint32				queueFamilyIndexCount;
1261 			&queueFamilyIndex							// const deUint32*		pQueueFamilyIndices;
1262 		};
1263 
1264 		// Upload data for each vertex input binding
1265 		for (deUint32 bindingNdx = 0; bindingNdx < bindingDescriptions.size(); bindingNdx++)
1266 		{
1267 			Move<VkBuffer>			vertexBuffer		= createBuffer(vk, vkDevice, &vertexBufferParams);
1268 			de::MovePtr<Allocation>	vertexBufferAlloc	= memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *vertexBuffer), MemoryRequirement::HostVisible);
1269 
1270 			VK_CHECK(vk.bindBufferMemory(vkDevice, *vertexBuffer, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset()));
1271 
1272 			writeVertexInputData((deUint8*)vertexBufferAlloc->getHostPtr(), bindingDescriptions[bindingNdx], bindingOffsets[bindingNdx], attributeDescriptions);
1273 			flushAlloc(vk, vkDevice, *vertexBufferAlloc);
1274 
1275 			m_vertexBuffers.push_back(vertexBuffer.disown());
1276 			m_vertexBufferAllocs.push_back(vertexBufferAlloc.release());
1277 		}
1278 	}
1279 
1280 	// Create command pool
1281 	m_cmdPool = createCommandPool(vk, vkDevice, VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, queueFamilyIndex);
1282 
1283 	// Create command buffer
1284 	{
1285 		const VkClearValue attachmentClearValue = defaultClearValue(m_colorFormat);
1286 
1287 		const VkImageMemoryBarrier attachmentLayoutBarrier =
1288 		{
1289 			VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,			// VkStructureType			sType;
1290 			DE_NULL,										// const void*				pNext;
1291 			0u,												// VkAccessFlags			srcAccessMask;
1292 			VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,			// VkAccessFlags			dstAccessMask;
1293 			VK_IMAGE_LAYOUT_UNDEFINED,						// VkImageLayout			oldLayout;
1294 			VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,		// VkImageLayout			newLayout;
1295 			VK_QUEUE_FAMILY_IGNORED,						// deUint32					srcQueueFamilyIndex;
1296 			VK_QUEUE_FAMILY_IGNORED,						// deUint32					dstQueueFamilyIndex;
1297 			*m_colorImage,									// VkImage					image;
1298 			{ VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u },	// VkImageSubresourceRange	subresourceRange;
1299 		};
1300 
1301 		m_cmdBuffer = allocateCommandBuffer(vk, vkDevice, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
1302 
1303 		beginCommandBuffer(vk, *m_cmdBuffer, 0u);
1304 
1305 		vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, (VkDependencyFlags)0,
1306 			0u, DE_NULL, 0u, DE_NULL, 1u, &attachmentLayoutBarrier);
1307 
1308 		beginRenderPass(vk, *m_cmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, m_renderSize.x(), m_renderSize.y()), attachmentClearValue);
1309 
1310 		vk.cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_graphicsPipeline);
1311 
1312 		std::vector<VkBuffer> vertexBuffers;
1313 		for (size_t bufferNdx = 0; bufferNdx < m_vertexBuffers.size(); bufferNdx++)
1314 			vertexBuffers.push_back(m_vertexBuffers[bufferNdx]);
1315 
1316 		if (vertexBuffers.size() <= 1)
1317 		{
1318 			// One vertex buffer
1319 			vk.cmdBindVertexBuffers(*m_cmdBuffer, 0, (deUint32)vertexBuffers.size(), vertexBuffers.data(), bindingOffsets.data());
1320 		}
1321 		else
1322 		{
1323 			// Smoke-test vkCmdBindVertexBuffers(..., startBinding, ... )
1324 
1325 			const deUint32 firstHalfLength = (deUint32)vertexBuffers.size() / 2;
1326 			const deUint32 secondHalfLength = firstHalfLength + (deUint32)(vertexBuffers.size() % 2);
1327 
1328 			// Bind first half of vertex buffers
1329 			vk.cmdBindVertexBuffers(*m_cmdBuffer, 0, firstHalfLength, vertexBuffers.data(), bindingOffsets.data());
1330 
1331 			// Bind second half of vertex buffers
1332 			vk.cmdBindVertexBuffers(*m_cmdBuffer, firstHalfLength, secondHalfLength,
1333 									vertexBuffers.data() + firstHalfLength,
1334 									bindingOffsets.data() + firstHalfLength);
1335 		}
1336 
1337 		vk.cmdDraw(*m_cmdBuffer, 4, 2, 0, 0);
1338 
1339 		endRenderPass(vk, *m_cmdBuffer);
1340 		endCommandBuffer(vk, *m_cmdBuffer);
1341 	}
1342 }
1343 
~VertexInputInstance(void)1344 VertexInputInstance::~VertexInputInstance (void)
1345 {
1346 	const DeviceInterface&		vk			= m_context.getDeviceInterface();
1347 	const VkDevice				vkDevice	= m_context.getDevice();
1348 
1349 	for (size_t bufferNdx = 0; bufferNdx < m_vertexBuffers.size(); bufferNdx++)
1350 		vk.destroyBuffer(vkDevice, m_vertexBuffers[bufferNdx], DE_NULL);
1351 
1352 	for (size_t allocNdx = 0; allocNdx < m_vertexBufferAllocs.size(); allocNdx++)
1353 		delete m_vertexBufferAllocs[allocNdx];
1354 }
1355 
writeVertexInputData(deUint8 * destPtr,const VkVertexInputBindingDescription & bindingDescription,const VkDeviceSize bindingOffset,const AttributeDescriptionList & attributes)1356 void VertexInputInstance::writeVertexInputData(deUint8* destPtr, const VkVertexInputBindingDescription& bindingDescription, const VkDeviceSize bindingOffset, const AttributeDescriptionList& attributes)
1357 {
1358 	const deUint32 vertexCount = (bindingDescription.inputRate == VK_VERTEX_INPUT_RATE_VERTEX) ? (4 * 2) : 2;
1359 
1360 	deUint8* destOffsetPtr = ((deUint8 *)destPtr) + bindingOffset;
1361 	for (deUint32 vertexNdx = 0; vertexNdx < vertexCount; vertexNdx++)
1362 	{
1363 		for (size_t attributeNdx = 0; attributeNdx < attributes.size(); attributeNdx++)
1364 		{
1365 			const VertexInputAttributeDescription& attribDesc = attributes[attributeNdx];
1366 
1367 			// Only write vertex input data to bindings referenced by attribute descriptions
1368 			if (attribDesc.vkDescription.binding == bindingDescription.binding)
1369 			{
1370 				writeVertexInputValue(destOffsetPtr + attribDesc.vkDescription.offset, attribDesc, vertexNdx);
1371 			}
1372 		}
1373 		destOffsetPtr += bindingDescription.stride;
1374 	}
1375 }
1376 
writeVertexInputValueSint(deUint8 * destPtr,VkFormat format,int componentNdx,deInt32 value)1377 void writeVertexInputValueSint (deUint8* destPtr, VkFormat format, int componentNdx, deInt32 value)
1378 {
1379 	const deUint32	componentSize	= getVertexFormatComponentSize(format);
1380 	deUint8*		destFormatPtr	= ((deUint8*)destPtr) + componentSize * componentNdx;
1381 
1382 	switch (componentSize)
1383 	{
1384 		case 1:
1385 			*((deInt8*)destFormatPtr) = (deInt8)value;
1386 			break;
1387 
1388 		case 2:
1389 			*((deInt16*)destFormatPtr) = (deInt16)value;
1390 			break;
1391 
1392 		case 4:
1393 			*((deInt32*)destFormatPtr) = (deInt32)value;
1394 			break;
1395 
1396 		default:
1397 			DE_ASSERT(false);
1398 	}
1399 }
1400 
writeVertexInputValueIntPacked(deUint8 * destPtr,deUint32 & packedFormat,deUint32 & componentOffset,VkFormat format,deUint32 componentNdx,deUint32 value)1401 void writeVertexInputValueIntPacked(deUint8* destPtr, deUint32& packedFormat, deUint32& componentOffset, VkFormat format, deUint32 componentNdx, deUint32 value)
1402 {
1403 	const deUint32	componentWidth	= getPackedVertexFormatComponentWidth(format, componentNdx);
1404 	const deUint32	componentCount	= getVertexFormatComponentCount(format);
1405 	const deUint32	usedBits		= ~(deUint32)0 >> ((getVertexFormatSize(format) * 8) - componentWidth);
1406 
1407 	componentOffset -= componentWidth;
1408 	packedFormat |= (((deUint32)value & usedBits) << componentOffset);
1409 
1410 	if (componentNdx == componentCount - 1)
1411 		*((deUint32*)destPtr) = (deUint32)packedFormat;
1412 }
1413 
writeVertexInputValueUint(deUint8 * destPtr,VkFormat format,int componentNdx,deUint32 value)1414 void writeVertexInputValueUint (deUint8* destPtr, VkFormat format, int componentNdx, deUint32 value)
1415 {
1416 	const deUint32	componentSize	= getVertexFormatComponentSize(format);
1417 	deUint8*		destFormatPtr	= ((deUint8*)destPtr) + componentSize * componentNdx;
1418 
1419 	switch (componentSize)
1420 	{
1421 		case 1:
1422 			*((deUint8 *)destFormatPtr) = (deUint8)value;
1423 			break;
1424 
1425 		case 2:
1426 			*((deUint16 *)destFormatPtr) = (deUint16)value;
1427 			break;
1428 
1429 		case 4:
1430 			*((deUint32 *)destFormatPtr) = (deUint32)value;
1431 			break;
1432 
1433 		default:
1434 			DE_ASSERT(false);
1435 	}
1436 }
1437 
writeVertexInputValueSfloat(deUint8 * destPtr,VkFormat format,int componentNdx,float value)1438 void writeVertexInputValueSfloat (deUint8* destPtr, VkFormat format, int componentNdx, float value)
1439 {
1440 	const deUint32	componentSize	= getVertexFormatComponentSize(format);
1441 	deUint8*		destFormatPtr	= ((deUint8*)destPtr) + componentSize * componentNdx;
1442 
1443 	switch (componentSize)
1444 	{
1445 		case 2:
1446 		{
1447 			deFloat16 f16 = deFloat32To16(value);
1448 			deMemcpy(destFormatPtr, &f16, sizeof(f16));
1449 			break;
1450 		}
1451 
1452 		case 4:
1453 			deMemcpy(destFormatPtr, &value, sizeof(value));
1454 			break;
1455 
1456 		default:
1457 			DE_ASSERT(false);
1458 	}
1459 }
1460 
writeVertexInputValue(deUint8 * destPtr,const VertexInputAttributeDescription & attribute,int indexId)1461 void VertexInputInstance::writeVertexInputValue (deUint8* destPtr, const VertexInputAttributeDescription& attribute, int indexId)
1462 {
1463 	const int		vertexInputCount	= VertexInputTest::s_glslTypeDescriptions[attribute.glslType].vertexInputCount;
1464 	const int		componentCount		= VertexInputTest::s_glslTypeDescriptions[attribute.glslType].vertexInputComponentCount;
1465 	const deUint32	totalComponentCount	= componentCount * vertexInputCount;
1466 	const deUint32	vertexInputIndex	= indexId * totalComponentCount + attribute.vertexInputIndex * componentCount;
1467 	const bool		hasBGROrder			= isVertexFormatComponentOrderBGR(attribute.vkDescription.format);
1468 	const bool		hasABGROrder		= isVertexFormatComponentOrderABGR(attribute.vkDescription.format);
1469 	const bool		hasARGBOrder		= isVertexFormatComponentOrderARGB(attribute.vkDescription.format);
1470 	deUint32		componentOffset		= getVertexFormatSize(attribute.vkDescription.format) * 8;
1471 	deUint32		packedFormat32		= 0;
1472 	deUint32		swizzledNdx;
1473 
1474 	const deUint32	BGRSwizzle[]		= { 2, 1, 0, 3 };
1475 	const deUint32	ABGRSwizzle[]		= { 3, 2, 1, 0 };
1476 	const deUint32	ARGBSwizzle[]		= { 3, 0, 1, 2 };
1477 
1478 	for (int componentNdx = 0; componentNdx < componentCount; componentNdx++)
1479 	{
1480 		if (hasABGROrder)
1481 			swizzledNdx = ABGRSwizzle[componentNdx];
1482 		else if (hasARGBOrder)
1483 			swizzledNdx = ARGBSwizzle[componentNdx];
1484 		else if (hasBGROrder)
1485 			swizzledNdx = BGRSwizzle[componentNdx];
1486 		else
1487 			swizzledNdx = componentNdx;
1488 
1489 		const deInt32	maxIntValue		= isVertexFormatPacked(attribute.vkDescription.format) ? (1 << (getPackedVertexFormatComponentWidth(attribute.vkDescription.format, componentNdx) - 1)) - 1 : (1 << (getVertexFormatComponentSize(attribute.vkDescription.format) * 8 - 1)) - 1;
1490 		const deUint32	maxUintValue	= isVertexFormatPacked(attribute.vkDescription.format) ? ((1 << getPackedVertexFormatComponentWidth(attribute.vkDescription.format, componentNdx)) - 1) : (1 << (getVertexFormatComponentSize(attribute.vkDescription.format) * 8 )) - 1;
1491 		const deInt32	minIntValue		= -maxIntValue;
1492 		const deUint32	minUintValue	= 0;
1493 
1494 		switch (attribute.glslType)
1495 		{
1496 			case VertexInputTest::GLSL_TYPE_INT:
1497 			case VertexInputTest::GLSL_TYPE_IVEC2:
1498 			case VertexInputTest::GLSL_TYPE_IVEC3:
1499 			case VertexInputTest::GLSL_TYPE_IVEC4:
1500 			{
1501 				if (isVertexFormatPacked(attribute.vkDescription.format))
1502 					writeVertexInputValueIntPacked(destPtr, packedFormat32, componentOffset, attribute.vkDescription.format, componentNdx, deClamp32(-(deInt32)(vertexInputIndex + swizzledNdx), minIntValue, maxIntValue));
1503 				else
1504 					writeVertexInputValueSint(destPtr, attribute.vkDescription.format, componentNdx, -(deInt32)(vertexInputIndex + swizzledNdx));
1505 
1506 				break;
1507 			}
1508 			case VertexInputTest::GLSL_TYPE_UINT:
1509 			case VertexInputTest::GLSL_TYPE_UVEC2:
1510 			case VertexInputTest::GLSL_TYPE_UVEC3:
1511 			case VertexInputTest::GLSL_TYPE_UVEC4:
1512 			{
1513 				if (isVertexFormatPacked(attribute.vkDescription.format))
1514 					writeVertexInputValueIntPacked(destPtr, packedFormat32, componentOffset, attribute.vkDescription.format, componentNdx, deClamp32(vertexInputIndex + swizzledNdx, minUintValue, maxUintValue));
1515 				else
1516 					writeVertexInputValueUint(destPtr, attribute.vkDescription.format, componentNdx, vertexInputIndex + swizzledNdx);
1517 
1518 				break;
1519 			}
1520 			case VertexInputTest::GLSL_TYPE_FLOAT:
1521 			case VertexInputTest::GLSL_TYPE_VEC2:
1522 			case VertexInputTest::GLSL_TYPE_VEC3:
1523 			case VertexInputTest::GLSL_TYPE_VEC4:
1524 			case VertexInputTest::GLSL_TYPE_MAT2:
1525 			case VertexInputTest::GLSL_TYPE_MAT3:
1526 			case VertexInputTest::GLSL_TYPE_MAT4:
1527 			{
1528 				if (isVertexFormatSfloat(attribute.vkDescription.format))
1529 				{
1530 					writeVertexInputValueSfloat(destPtr, attribute.vkDescription.format, componentNdx, -(0.01f * (float)(vertexInputIndex + swizzledNdx)));
1531 				}
1532 				else if (isVertexFormatSscaled(attribute.vkDescription.format))
1533 				{
1534 					if (isVertexFormatPacked(attribute.vkDescription.format))
1535 						writeVertexInputValueIntPacked(destPtr, packedFormat32, componentOffset, attribute.vkDescription.format, componentNdx, deClamp32(-(deInt32)(vertexInputIndex + swizzledNdx), minIntValue, maxIntValue));
1536 					else
1537 						writeVertexInputValueSint(destPtr, attribute.vkDescription.format, componentNdx, -(deInt32)(vertexInputIndex + swizzledNdx));
1538 				}
1539 				else if (isVertexFormatUscaled(attribute.vkDescription.format) || isVertexFormatUnorm(attribute.vkDescription.format) || isVertexFormatSRGB(attribute.vkDescription.format))
1540 				{
1541 					if (isVertexFormatPacked(attribute.vkDescription.format))
1542 						writeVertexInputValueIntPacked(destPtr, packedFormat32, componentOffset, attribute.vkDescription.format, componentNdx, deClamp32(vertexInputIndex + swizzledNdx, minUintValue, maxUintValue));
1543 					else
1544 						writeVertexInputValueUint(destPtr, attribute.vkDescription.format, componentNdx, vertexInputIndex + swizzledNdx);
1545 				}
1546 				else if (isVertexFormatSnorm(attribute.vkDescription.format))
1547 				{
1548 					if (isVertexFormatPacked(attribute.vkDescription.format))
1549 						writeVertexInputValueIntPacked(destPtr, packedFormat32, componentOffset, attribute.vkDescription.format, componentNdx, deClamp32(minIntValue + (vertexInputIndex + swizzledNdx), minIntValue, maxIntValue));
1550 					else
1551 						writeVertexInputValueSint(destPtr, attribute.vkDescription.format, componentNdx, minIntValue + (vertexInputIndex + swizzledNdx));
1552 				}
1553 				else
1554 					DE_ASSERT(false);
1555 				break;
1556 			}
1557 			case VertexInputTest::GLSL_TYPE_DOUBLE:
1558 			case VertexInputTest::GLSL_TYPE_DVEC2:
1559 			case VertexInputTest::GLSL_TYPE_DVEC3:
1560 			case VertexInputTest::GLSL_TYPE_DVEC4:
1561 			case VertexInputTest::GLSL_TYPE_DMAT2:
1562 			case VertexInputTest::GLSL_TYPE_DMAT3:
1563 			case VertexInputTest::GLSL_TYPE_DMAT4:
1564 				*(reinterpret_cast<double *>(destPtr) + componentNdx) = -0.01 * (vertexInputIndex + swizzledNdx);
1565 
1566 				break;
1567 
1568 			default:
1569 				DE_ASSERT(false);
1570 		}
1571 	}
1572 }
1573 
iterate(void)1574 tcu::TestStatus VertexInputInstance::iterate (void)
1575 {
1576 	const DeviceInterface&		vk			= m_context.getDeviceInterface();
1577 	const VkDevice				vkDevice	= m_context.getDevice();
1578 	const VkQueue				queue		= m_context.getUniversalQueue();
1579 
1580 	submitCommandsAndWait(vk, vkDevice, queue, m_cmdBuffer.get());
1581 
1582 	return verifyImage();
1583 }
1584 
isCompatibleType(VkFormat format,GlslType glslType)1585 bool VertexInputTest::isCompatibleType (VkFormat format, GlslType glslType)
1586 {
1587 	const GlslTypeDescription glslTypeDesc = s_glslTypeDescriptions[glslType];
1588 
1589 	if ((deUint32)s_glslTypeDescriptions[glslType].vertexInputComponentCount == getVertexFormatComponentCount(format))
1590 	{
1591 		switch (glslTypeDesc.basicType)
1592 		{
1593 			case GLSL_BASIC_TYPE_INT:
1594 				return isVertexFormatSint(format);
1595 
1596 			case GLSL_BASIC_TYPE_UINT:
1597 				return isVertexFormatUint(format);
1598 
1599 			case GLSL_BASIC_TYPE_FLOAT:
1600 				return (isVertexFormatPacked(format) ? (getVertexFormatSize(format) <= 4) : getVertexFormatComponentSize(format) <= 4) && (isVertexFormatSfloat(format) ||
1601 					isVertexFormatSnorm(format) || isVertexFormatUnorm(format) || isVertexFormatSscaled(format) || isVertexFormatUscaled(format) || isVertexFormatSRGB(format));
1602 
1603 			case GLSL_BASIC_TYPE_DOUBLE:
1604 				return isVertexFormatSfloat(format) && getVertexFormatComponentSize(format) == 8;
1605 
1606 			default:
1607 				DE_ASSERT(false);
1608 				return false;
1609 		}
1610 	}
1611 	else
1612 		return false;
1613 }
1614 
verifyImage(void)1615 tcu::TestStatus VertexInputInstance::verifyImage (void)
1616 {
1617 	bool							compareOk			= false;
1618 	const tcu::TextureFormat		tcuColorFormat		= mapVkFormat(m_colorFormat);
1619 	tcu::TextureLevel				reference			(tcuColorFormat, m_renderSize.x(), m_renderSize.y());
1620 	const tcu::PixelBufferAccess	refRedSubregion		(tcu::getSubregion(reference.getAccess(),
1621 																		   deRoundFloatToInt32((float)m_renderSize.x() * 0.0f),
1622 																		   deRoundFloatToInt32((float)m_renderSize.y() * 0.0f),
1623 																		   deRoundFloatToInt32((float)m_renderSize.x() * 0.5f),
1624 																		   deRoundFloatToInt32((float)m_renderSize.y() * 1.0f)));
1625 	const tcu::PixelBufferAccess	refBlueSubregion	(tcu::getSubregion(reference.getAccess(),
1626 																		   deRoundFloatToInt32((float)m_renderSize.x() * 0.5f),
1627 																		   deRoundFloatToInt32((float)m_renderSize.y() * 0.0f),
1628 																		   deRoundFloatToInt32((float)m_renderSize.x() * 0.5f),
1629 																		   deRoundFloatToInt32((float)m_renderSize.y() * 1.0f)));
1630 
1631 	// Create reference image
1632 	tcu::clear(reference.getAccess(), defaultClearColor(tcuColorFormat));
1633 	tcu::clear(refRedSubregion, tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f));
1634 	tcu::clear(refBlueSubregion, tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
1635 
1636 	// Compare result with reference image
1637 	{
1638 		const DeviceInterface&			vk					= m_context.getDeviceInterface();
1639 		const VkDevice					vkDevice			= m_context.getDevice();
1640 		const VkQueue					queue				= m_context.getUniversalQueue();
1641 		const deUint32					queueFamilyIndex	= m_context.getUniversalQueueFamilyIndex();
1642 		SimpleAllocator					allocator			(vk, vkDevice, getPhysicalDeviceMemoryProperties(m_context.getInstanceInterface(), m_context.getPhysicalDevice()));
1643 		de::MovePtr<tcu::TextureLevel>	result				= readColorAttachment(vk, vkDevice, queue, queueFamilyIndex, allocator, *m_colorImage, m_colorFormat, m_renderSize);
1644 
1645 		compareOk = tcu::intThresholdPositionDeviationCompare(m_context.getTestContext().getLog(),
1646 															  "IntImageCompare",
1647 															  "Image comparison",
1648 															  reference.getAccess(),
1649 															  result->getAccess(),
1650 															  tcu::UVec4(2, 2, 2, 2),
1651 															  tcu::IVec3(1, 1, 0),
1652 															  true,
1653 															  tcu::COMPARE_LOG_RESULT);
1654 	}
1655 
1656 	if (compareOk)
1657 		return tcu::TestStatus::pass("Result image matches reference");
1658 	else
1659 		return tcu::TestStatus::fail("Image mismatch");
1660 }
1661 
getAttributeInfoCaseName(const VertexInputTest::AttributeInfo & attributeInfo)1662 std::string getAttributeInfoCaseName (const VertexInputTest::AttributeInfo& attributeInfo)
1663 {
1664 	std::ostringstream	caseName;
1665 	const std::string	formatName	= getFormatName(attributeInfo.vkType);
1666 
1667 	caseName << "as_" << de::toLower(formatName.substr(10)) << "_rate_";
1668 
1669 	if (attributeInfo.inputRate == VK_VERTEX_INPUT_RATE_VERTEX)
1670 		caseName <<  "vertex";
1671 	else
1672 		caseName <<  "instance";
1673 
1674 	return caseName.str();
1675 }
1676 
getAttributeInfoDescription(const VertexInputTest::AttributeInfo & attributeInfo)1677 std::string getAttributeInfoDescription (const VertexInputTest::AttributeInfo& attributeInfo)
1678 {
1679 	std::ostringstream caseDesc;
1680 
1681 	caseDesc << std::string(VertexInputTest::s_glslTypeDescriptions[attributeInfo.glslType].name) << " from type " << getFormatName(attributeInfo.vkType) <<  " with ";
1682 
1683 	if (attributeInfo.inputRate == VK_VERTEX_INPUT_RATE_VERTEX)
1684 		caseDesc <<  "vertex input rate ";
1685 	else
1686 		caseDesc <<  "instance input rate ";
1687 
1688 	return caseDesc.str();
1689 }
1690 
getAttributeInfosDescription(const std::vector<VertexInputTest::AttributeInfo> & attributeInfos)1691 std::string getAttributeInfosDescription (const std::vector<VertexInputTest::AttributeInfo>& attributeInfos)
1692 {
1693 	std::ostringstream caseDesc;
1694 
1695 	caseDesc << "Uses vertex attributes:\n";
1696 
1697 	for (size_t attributeNdx = 0; attributeNdx < attributeInfos.size(); attributeNdx++)
1698 		caseDesc << "\t- " << getAttributeInfoDescription (attributeInfos[attributeNdx]) << "\n";
1699 
1700 	return caseDesc.str();
1701 }
1702 
1703 struct CompatibleFormats
1704 {
1705 	VertexInputTest::GlslType	glslType;
1706 	std::vector<VkFormat>		compatibleVkFormats;
1707 };
1708 
createSingleAttributeCases(tcu::TestCaseGroup * singleAttributeTests,VertexInputTest::GlslType glslType)1709 void createSingleAttributeCases (tcu::TestCaseGroup* singleAttributeTests, VertexInputTest::GlslType glslType)
1710 {
1711 	const VkFormat vertexFormats[] =
1712 	{
1713 		// Required, unpacked
1714 		VK_FORMAT_R8_UNORM,
1715 		VK_FORMAT_R8_SNORM,
1716 		VK_FORMAT_R8_UINT,
1717 		VK_FORMAT_R8_SINT,
1718 		VK_FORMAT_R8G8_UNORM,
1719 		VK_FORMAT_R8G8_SNORM,
1720 		VK_FORMAT_R8G8_UINT,
1721 		VK_FORMAT_R8G8_SINT,
1722 		VK_FORMAT_R8G8B8A8_UNORM,
1723 		VK_FORMAT_R8G8B8A8_SNORM,
1724 		VK_FORMAT_R8G8B8A8_UINT,
1725 		VK_FORMAT_R8G8B8A8_SINT,
1726 		VK_FORMAT_B8G8R8A8_UNORM,
1727 		VK_FORMAT_R16_UNORM,
1728 		VK_FORMAT_R16_SNORM,
1729 		VK_FORMAT_R16_UINT,
1730 		VK_FORMAT_R16_SINT,
1731 		VK_FORMAT_R16_SFLOAT,
1732 		VK_FORMAT_R16G16_UNORM,
1733 		VK_FORMAT_R16G16_SNORM,
1734 		VK_FORMAT_R16G16_UINT,
1735 		VK_FORMAT_R16G16_SINT,
1736 		VK_FORMAT_R16G16_SFLOAT,
1737 		VK_FORMAT_R16G16B16A16_UNORM,
1738 		VK_FORMAT_R16G16B16A16_SNORM,
1739 		VK_FORMAT_R16G16B16A16_UINT,
1740 		VK_FORMAT_R16G16B16A16_SINT,
1741 		VK_FORMAT_R16G16B16A16_SFLOAT,
1742 		VK_FORMAT_R32_UINT,
1743 		VK_FORMAT_R32_SINT,
1744 		VK_FORMAT_R32_SFLOAT,
1745 		VK_FORMAT_R32G32_UINT,
1746 		VK_FORMAT_R32G32_SINT,
1747 		VK_FORMAT_R32G32_SFLOAT,
1748 		VK_FORMAT_R32G32B32_UINT,
1749 		VK_FORMAT_R32G32B32_SINT,
1750 		VK_FORMAT_R32G32B32_SFLOAT,
1751 		VK_FORMAT_R32G32B32A32_UINT,
1752 		VK_FORMAT_R32G32B32A32_SINT,
1753 		VK_FORMAT_R32G32B32A32_SFLOAT,
1754 
1755 		// Scaled formats
1756 		VK_FORMAT_R8G8_USCALED,
1757 		VK_FORMAT_R8G8_SSCALED,
1758 		VK_FORMAT_R16_USCALED,
1759 		VK_FORMAT_R16_SSCALED,
1760 		VK_FORMAT_R8G8B8_USCALED,
1761 		VK_FORMAT_R8G8B8_SSCALED,
1762 		VK_FORMAT_B8G8R8_USCALED,
1763 		VK_FORMAT_B8G8R8_SSCALED,
1764 		VK_FORMAT_R8G8B8A8_USCALED,
1765 		VK_FORMAT_R8G8B8A8_SSCALED,
1766 		VK_FORMAT_B8G8R8A8_USCALED,
1767 		VK_FORMAT_B8G8R8A8_SSCALED,
1768 		VK_FORMAT_R16G16_USCALED,
1769 		VK_FORMAT_R16G16_SSCALED,
1770 		VK_FORMAT_R16G16B16_USCALED,
1771 		VK_FORMAT_R16G16B16_SSCALED,
1772 		VK_FORMAT_R16G16B16A16_USCALED,
1773 		VK_FORMAT_R16G16B16A16_SSCALED,
1774 
1775 		// SRGB formats
1776 		VK_FORMAT_R8_SRGB,
1777 		VK_FORMAT_R8G8_SRGB,
1778 		VK_FORMAT_R8G8B8_SRGB,
1779 		VK_FORMAT_B8G8R8_SRGB,
1780 		VK_FORMAT_R8G8B8A8_SRGB,
1781 		VK_FORMAT_B8G8R8A8_SRGB,
1782 
1783 		// Double formats
1784 		VK_FORMAT_R64_SFLOAT,
1785 		VK_FORMAT_R64G64_SFLOAT,
1786 		VK_FORMAT_R64G64B64_SFLOAT,
1787 		VK_FORMAT_R64G64B64A64_SFLOAT,
1788 
1789 		// Packed formats
1790 		VK_FORMAT_A2R10G10B10_USCALED_PACK32,
1791 		VK_FORMAT_A2R10G10B10_SSCALED_PACK32,
1792 		VK_FORMAT_A2R10G10B10_UINT_PACK32,
1793 		VK_FORMAT_A2R10G10B10_SINT_PACK32,
1794 		VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1795 		VK_FORMAT_A8B8G8R8_SNORM_PACK32,
1796 		VK_FORMAT_A2R10G10B10_UNORM_PACK32,
1797 		VK_FORMAT_A2R10G10B10_SNORM_PACK32,
1798 		VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1799 		VK_FORMAT_A2B10G10R10_SNORM_PACK32
1800 	};
1801 
1802 	for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(vertexFormats); formatNdx++)
1803 	{
1804 		if (VertexInputTest::isCompatibleType(vertexFormats[formatNdx], glslType))
1805 		{
1806 			// Create test case for RATE_VERTEX
1807 			VertexInputTest::AttributeInfo attributeInfo;
1808 			attributeInfo.vkType = vertexFormats[formatNdx];
1809 			attributeInfo.glslType = glslType;
1810 			attributeInfo.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
1811 
1812 			singleAttributeTests->addChild(new VertexInputTest(singleAttributeTests->getTestContext(),
1813 															   getAttributeInfoCaseName(attributeInfo),
1814 															   getAttributeInfoDescription(attributeInfo),
1815 															   std::vector<VertexInputTest::AttributeInfo>(1, attributeInfo),
1816 															   VertexInputTest::BINDING_MAPPING_ONE_TO_ONE,
1817 															   VertexInputTest::ATTRIBUTE_LAYOUT_INTERLEAVED));
1818 
1819 			// Create test case for RATE_INSTANCE
1820 			attributeInfo.inputRate	= VK_VERTEX_INPUT_RATE_INSTANCE;
1821 
1822 			singleAttributeTests->addChild(new VertexInputTest(singleAttributeTests->getTestContext(),
1823 															   getAttributeInfoCaseName(attributeInfo),
1824 															   getAttributeInfoDescription(attributeInfo),
1825 															   std::vector<VertexInputTest::AttributeInfo>(1, attributeInfo),
1826 															   VertexInputTest::BINDING_MAPPING_ONE_TO_ONE,
1827 															   VertexInputTest::ATTRIBUTE_LAYOUT_INTERLEAVED));
1828 		}
1829 	}
1830 }
1831 
createSingleAttributeTests(tcu::TestCaseGroup * singleAttributeTests)1832 void createSingleAttributeTests (tcu::TestCaseGroup* singleAttributeTests)
1833 {
1834 	for (int glslTypeNdx = 0; glslTypeNdx < VertexInputTest::GLSL_TYPE_COUNT; glslTypeNdx++)
1835 	{
1836 		VertexInputTest::GlslType glslType = (VertexInputTest::GlslType)glslTypeNdx;
1837 		addTestGroup(singleAttributeTests, VertexInputTest::s_glslTypeDescriptions[glslType].name, "", createSingleAttributeCases, glslType);
1838 	}
1839 }
1840 
1841 // Create all unique GlslType combinations recursively
createMultipleAttributeCases(deUint32 depth,deUint32 firstNdx,CompatibleFormats * compatibleFormats,de::Random & randomFunc,tcu::TestCaseGroup & testGroup,VertexInputTest::BindingMapping bindingMapping,VertexInputTest::AttributeLayout attributeLayout,VertexInputTest::LayoutSkip layoutSkip,VertexInputTest::LayoutOrder layoutOrder,const std::vector<VertexInputTest::AttributeInfo> & attributeInfos=std::vector<VertexInputTest::AttributeInfo> (0))1842 void createMultipleAttributeCases (deUint32 depth, deUint32 firstNdx, CompatibleFormats* compatibleFormats, de::Random& randomFunc, tcu::TestCaseGroup& testGroup, VertexInputTest::BindingMapping bindingMapping, VertexInputTest::AttributeLayout attributeLayout, VertexInputTest::LayoutSkip layoutSkip, VertexInputTest::LayoutOrder layoutOrder, const std::vector<VertexInputTest::AttributeInfo>& attributeInfos = std::vector<VertexInputTest::AttributeInfo>(0))
1843 {
1844 	tcu::TestContext& testCtx = testGroup.getTestContext();
1845 
1846 	// Exclude double values, which are not included in vertexFormats
1847 	for (deUint32 currentNdx = firstNdx; currentNdx < VertexInputTest::GLSL_TYPE_DOUBLE - depth; currentNdx++)
1848 	{
1849 		std::vector <VertexInputTest::AttributeInfo> newAttributeInfos = attributeInfos;
1850 
1851 		{
1852 			VertexInputTest::AttributeInfo attributeInfo;
1853 			attributeInfo.glslType	= (VertexInputTest::GlslType)currentNdx;
1854 			attributeInfo.inputRate	= (depth % 2 == 0) ? VK_VERTEX_INPUT_RATE_VERTEX : VK_VERTEX_INPUT_RATE_INSTANCE;
1855 			attributeInfo.vkType	= VK_FORMAT_UNDEFINED;
1856 
1857 			newAttributeInfos.push_back(attributeInfo);
1858 		}
1859 
1860 		// Add test case
1861 		if (depth == 0)
1862 		{
1863 			// Select a random compatible format for each attribute
1864 			for (size_t i = 0; i < newAttributeInfos.size(); i++)
1865 			{
1866 				const std::vector<VkFormat>& formats = compatibleFormats[newAttributeInfos[i].glslType].compatibleVkFormats;
1867 				newAttributeInfos[i].vkType = formats[randomFunc.getUint32() % formats.size()];
1868 			}
1869 
1870 			const std::string caseName = VertexInputTest::s_glslTypeDescriptions[currentNdx].name;
1871 			const std::string caseDesc = getAttributeInfosDescription(newAttributeInfos);
1872 
1873 			testGroup.addChild(new VertexInputTest(testCtx, caseName, caseDesc, newAttributeInfos, bindingMapping, attributeLayout, layoutSkip, layoutOrder));
1874 		}
1875 		// Add test group
1876 		else
1877 		{
1878 			const std::string				name			= VertexInputTest::s_glslTypeDescriptions[currentNdx].name;
1879 			de::MovePtr<tcu::TestCaseGroup>	newTestGroup	(new tcu::TestCaseGroup(testCtx, name.c_str(), ""));
1880 
1881 			createMultipleAttributeCases(depth - 1u, currentNdx + 1u, compatibleFormats, randomFunc, *newTestGroup, bindingMapping, attributeLayout, layoutSkip, layoutOrder, newAttributeInfos);
1882 			testGroup.addChild(newTestGroup.release());
1883 		}
1884 	}
1885 }
1886 
createMultipleAttributeTests(tcu::TestCaseGroup * multipleAttributeTests)1887 void createMultipleAttributeTests (tcu::TestCaseGroup* multipleAttributeTests)
1888 {
1889 	// Required vertex formats, unpacked
1890 	const VkFormat vertexFormats[] =
1891 	{
1892 		VK_FORMAT_R8_UNORM,
1893 		VK_FORMAT_R8_SNORM,
1894 		VK_FORMAT_R8_UINT,
1895 		VK_FORMAT_R8_SINT,
1896 		VK_FORMAT_R8G8_UNORM,
1897 		VK_FORMAT_R8G8_SNORM,
1898 		VK_FORMAT_R8G8_UINT,
1899 		VK_FORMAT_R8G8_SINT,
1900 		VK_FORMAT_R8G8B8A8_UNORM,
1901 		VK_FORMAT_R8G8B8A8_SNORM,
1902 		VK_FORMAT_R8G8B8A8_UINT,
1903 		VK_FORMAT_R8G8B8A8_SINT,
1904 		VK_FORMAT_B8G8R8A8_UNORM,
1905 		VK_FORMAT_R16_UNORM,
1906 		VK_FORMAT_R16_SNORM,
1907 		VK_FORMAT_R16_UINT,
1908 		VK_FORMAT_R16_SINT,
1909 		VK_FORMAT_R16_SFLOAT,
1910 		VK_FORMAT_R16G16_UNORM,
1911 		VK_FORMAT_R16G16_SNORM,
1912 		VK_FORMAT_R16G16_UINT,
1913 		VK_FORMAT_R16G16_SINT,
1914 		VK_FORMAT_R16G16_SFLOAT,
1915 		VK_FORMAT_R16G16B16A16_UNORM,
1916 		VK_FORMAT_R16G16B16A16_SNORM,
1917 		VK_FORMAT_R16G16B16A16_UINT,
1918 		VK_FORMAT_R16G16B16A16_SINT,
1919 		VK_FORMAT_R16G16B16A16_SFLOAT,
1920 		VK_FORMAT_R32_UINT,
1921 		VK_FORMAT_R32_SINT,
1922 		VK_FORMAT_R32_SFLOAT,
1923 		VK_FORMAT_R32G32_UINT,
1924 		VK_FORMAT_R32G32_SINT,
1925 		VK_FORMAT_R32G32_SFLOAT,
1926 		VK_FORMAT_R32G32B32_UINT,
1927 		VK_FORMAT_R32G32B32_SINT,
1928 		VK_FORMAT_R32G32B32_SFLOAT,
1929 		VK_FORMAT_R32G32B32A32_UINT,
1930 		VK_FORMAT_R32G32B32A32_SINT,
1931 		VK_FORMAT_R32G32B32A32_SFLOAT
1932 	};
1933 
1934 	const VertexInputTest::LayoutSkip layoutSkips[] =
1935 	{
1936 		VertexInputTest::LAYOUT_SKIP_DISABLED,
1937 		VertexInputTest::LAYOUT_SKIP_ENABLED
1938 	};
1939 
1940 	const VertexInputTest::LayoutOrder layoutOrders[] =
1941 	{
1942 		VertexInputTest::LAYOUT_ORDER_IN_ORDER,
1943 		VertexInputTest::LAYOUT_ORDER_OUT_OF_ORDER
1944 	};
1945 
1946 	// Find compatible VK formats for each GLSL vertex type
1947 	CompatibleFormats compatibleFormats[VertexInputTest::GLSL_TYPE_COUNT];
1948 	{
1949 		for (int glslTypeNdx = 0; glslTypeNdx < VertexInputTest::GLSL_TYPE_COUNT; glslTypeNdx++)
1950 		{
1951 			for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(vertexFormats); formatNdx++)
1952 			{
1953 				if (VertexInputTest::isCompatibleType(vertexFormats[formatNdx], (VertexInputTest::GlslType)glslTypeNdx))
1954 					compatibleFormats[glslTypeNdx].compatibleVkFormats.push_back(vertexFormats[formatNdx]);
1955 			}
1956 		}
1957 	}
1958 
1959 	de::Random                      randomFunc(102030);
1960 	tcu::TestContext&				testCtx = multipleAttributeTests->getTestContext();
1961 
1962 	for (deUint32 layoutSkipNdx = 0; layoutSkipNdx < DE_LENGTH_OF_ARRAY(layoutSkips); layoutSkipNdx++)
1963 	for (deUint32 layoutOrderNdx = 0; layoutOrderNdx < DE_LENGTH_OF_ARRAY(layoutOrders); layoutOrderNdx++)
1964 	{
1965 		const VertexInputTest::LayoutSkip	layoutSkip	= layoutSkips[layoutSkipNdx];
1966 		const VertexInputTest::LayoutOrder	layoutOrder	= layoutOrders[layoutOrderNdx];
1967 		de::MovePtr<tcu::TestCaseGroup> oneToOneAttributeTests(new tcu::TestCaseGroup(testCtx, "attributes", ""));
1968 		de::MovePtr<tcu::TestCaseGroup> oneToManyAttributeTests(new tcu::TestCaseGroup(testCtx, "attributes", ""));
1969 		de::MovePtr<tcu::TestCaseGroup> oneToManySequentialAttributeTests(new tcu::TestCaseGroup(testCtx, "attributes_sequential", ""));
1970 
1971 		if (layoutSkip == VertexInputTest::LAYOUT_SKIP_ENABLED && layoutOrder == VertexInputTest::LAYOUT_ORDER_OUT_OF_ORDER)
1972 			continue;
1973 
1974 		createMultipleAttributeCases(2u, 0u, compatibleFormats, randomFunc, *oneToOneAttributeTests,			VertexInputTest::BINDING_MAPPING_ONE_TO_ONE,	VertexInputTest::ATTRIBUTE_LAYOUT_INTERLEAVED, layoutSkip, layoutOrder);
1975 		createMultipleAttributeCases(2u, 0u, compatibleFormats, randomFunc, *oneToManyAttributeTests,			VertexInputTest::BINDING_MAPPING_ONE_TO_MANY,	VertexInputTest::ATTRIBUTE_LAYOUT_INTERLEAVED, layoutSkip, layoutOrder);
1976 		createMultipleAttributeCases(2u, 0u, compatibleFormats, randomFunc, *oneToManySequentialAttributeTests,	VertexInputTest::BINDING_MAPPING_ONE_TO_MANY,	VertexInputTest::ATTRIBUTE_LAYOUT_SEQUENTIAL, layoutSkip, layoutOrder);
1977 
1978 		if (layoutSkip == VertexInputTest::LAYOUT_SKIP_ENABLED)
1979 		{
1980 			de::MovePtr<tcu::TestCaseGroup> layoutSkipTests(new tcu::TestCaseGroup(testCtx, "layout_skip", "Skip one layout after each attribute"));
1981 
1982 			de::MovePtr<tcu::TestCaseGroup> bindingOneToOneTests(new tcu::TestCaseGroup(testCtx, "binding_one_to_one", "Each attribute uses a unique binding"));
1983 			bindingOneToOneTests->addChild(oneToOneAttributeTests.release());
1984 			layoutSkipTests->addChild(bindingOneToOneTests.release());
1985 
1986 			de::MovePtr<tcu::TestCaseGroup> bindingOneToManyTests(new tcu::TestCaseGroup(testCtx, "binding_one_to_many", "Attributes share the same binding"));
1987 			bindingOneToManyTests->addChild(oneToManyAttributeTests.release());
1988 			bindingOneToManyTests->addChild(oneToManySequentialAttributeTests.release());
1989 			layoutSkipTests->addChild(bindingOneToManyTests.release());
1990 			multipleAttributeTests->addChild(layoutSkipTests.release());
1991 		}
1992 		else if (layoutOrder == VertexInputTest::LAYOUT_ORDER_OUT_OF_ORDER)
1993 		{
1994 			de::MovePtr<tcu::TestCaseGroup> layoutOutOfOrderTests(new tcu::TestCaseGroup(testCtx, "out_of_order", "Layout slots out of order"));
1995 
1996 			de::MovePtr<tcu::TestCaseGroup> bindingOneToOneTests(new tcu::TestCaseGroup(testCtx, "binding_one_to_one", "Each attribute uses a unique binding"));
1997 			bindingOneToOneTests->addChild(oneToOneAttributeTests.release());
1998 			layoutOutOfOrderTests->addChild(bindingOneToOneTests.release());
1999 
2000 			de::MovePtr<tcu::TestCaseGroup> bindingOneToManyTests(new tcu::TestCaseGroup(testCtx, "binding_one_to_many", "Attributes share the same binding"));
2001 			bindingOneToManyTests->addChild(oneToManyAttributeTests.release());
2002 			bindingOneToManyTests->addChild(oneToManySequentialAttributeTests.release());
2003 			layoutOutOfOrderTests->addChild(bindingOneToManyTests.release());
2004 			multipleAttributeTests->addChild(layoutOutOfOrderTests.release());
2005 		}
2006 		else
2007 		{
2008 			de::MovePtr<tcu::TestCaseGroup> bindingOneToOneTests(new tcu::TestCaseGroup(testCtx, "binding_one_to_one", "Each attribute uses a unique binding"));
2009 			bindingOneToOneTests->addChild(oneToOneAttributeTests.release());
2010 			multipleAttributeTests->addChild(bindingOneToOneTests.release());
2011 
2012 			de::MovePtr<tcu::TestCaseGroup> bindingOneToManyTests(new tcu::TestCaseGroup(testCtx, "binding_one_to_many", "Attributes share the same binding"));
2013 			bindingOneToManyTests->addChild(oneToManyAttributeTests.release());
2014 			bindingOneToManyTests->addChild(oneToManySequentialAttributeTests.release());
2015 			multipleAttributeTests->addChild(bindingOneToManyTests.release());
2016 		}
2017 	}
2018 }
2019 
createMaxAttributeTests(tcu::TestCaseGroup * maxAttributeTests)2020 void createMaxAttributeTests (tcu::TestCaseGroup* maxAttributeTests)
2021 {
2022 	// Required vertex formats, unpacked
2023 	const VkFormat					vertexFormats[]		=
2024 	{
2025 		VK_FORMAT_R8_UNORM,
2026 		VK_FORMAT_R8_SNORM,
2027 		VK_FORMAT_R8_UINT,
2028 		VK_FORMAT_R8_SINT,
2029 		VK_FORMAT_R8G8_UNORM,
2030 		VK_FORMAT_R8G8_SNORM,
2031 		VK_FORMAT_R8G8_UINT,
2032 		VK_FORMAT_R8G8_SINT,
2033 		VK_FORMAT_R8G8B8A8_UNORM,
2034 		VK_FORMAT_R8G8B8A8_SNORM,
2035 		VK_FORMAT_R8G8B8A8_UINT,
2036 		VK_FORMAT_R8G8B8A8_SINT,
2037 		VK_FORMAT_B8G8R8A8_UNORM,
2038 		VK_FORMAT_R16_UNORM,
2039 		VK_FORMAT_R16_SNORM,
2040 		VK_FORMAT_R16_UINT,
2041 		VK_FORMAT_R16_SINT,
2042 		VK_FORMAT_R16_SFLOAT,
2043 		VK_FORMAT_R16G16_UNORM,
2044 		VK_FORMAT_R16G16_SNORM,
2045 		VK_FORMAT_R16G16_UINT,
2046 		VK_FORMAT_R16G16_SINT,
2047 		VK_FORMAT_R16G16_SFLOAT,
2048 		VK_FORMAT_R16G16B16A16_UNORM,
2049 		VK_FORMAT_R16G16B16A16_SNORM,
2050 		VK_FORMAT_R16G16B16A16_UINT,
2051 		VK_FORMAT_R16G16B16A16_SINT,
2052 		VK_FORMAT_R16G16B16A16_SFLOAT,
2053 		VK_FORMAT_R32_UINT,
2054 		VK_FORMAT_R32_SINT,
2055 		VK_FORMAT_R32_SFLOAT,
2056 		VK_FORMAT_R32G32_UINT,
2057 		VK_FORMAT_R32G32_SINT,
2058 		VK_FORMAT_R32G32_SFLOAT,
2059 		VK_FORMAT_R32G32B32_UINT,
2060 		VK_FORMAT_R32G32B32_SINT,
2061 		VK_FORMAT_R32G32B32_SFLOAT,
2062 		VK_FORMAT_R32G32B32A32_UINT,
2063 		VK_FORMAT_R32G32B32A32_SINT,
2064 		VK_FORMAT_R32G32B32A32_SFLOAT
2065 	};
2066 
2067 	// VkPhysicalDeviceLimits::maxVertexInputAttributes is used when attributeCount is 0
2068 	const deUint32					attributeCount[]	= { 16, 32, 64, 128, 0 };
2069 	tcu::TestContext&				testCtx				(maxAttributeTests->getTestContext());
2070 	de::Random						randomFunc			(132030);
2071 
2072 	// Find compatible VK formats for each GLSL vertex type
2073 	CompatibleFormats compatibleFormats[VertexInputTest::GLSL_TYPE_COUNT];
2074 	{
2075 		for (int glslTypeNdx = 0; glslTypeNdx < VertexInputTest::GLSL_TYPE_COUNT; glslTypeNdx++)
2076 		{
2077 			for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(vertexFormats); formatNdx++)
2078 			{
2079 				if (VertexInputTest::isCompatibleType(vertexFormats[formatNdx], (VertexInputTest::GlslType)glslTypeNdx))
2080 					compatibleFormats[glslTypeNdx].compatibleVkFormats.push_back(vertexFormats[formatNdx]);
2081 			}
2082 		}
2083 	}
2084 
2085 	for (deUint32 attributeCountNdx = 0; attributeCountNdx < DE_LENGTH_OF_ARRAY(attributeCount); attributeCountNdx++)
2086 	{
2087 		const std::string							groupName = (attributeCount[attributeCountNdx] == 0 ? "query_max" : de::toString(attributeCount[attributeCountNdx])) + "_attributes";
2088 		const std::string							groupDesc = de::toString(attributeCount[attributeCountNdx]) + " vertex input attributes";
2089 
2090 		de::MovePtr<tcu::TestCaseGroup>				numAttributeTests(new tcu::TestCaseGroup(testCtx, groupName.c_str(), groupDesc.c_str()));
2091 		de::MovePtr<tcu::TestCaseGroup>				bindingOneToOneTests(new tcu::TestCaseGroup(testCtx, "binding_one_to_one", "Each attribute uses a unique binding"));
2092 		de::MovePtr<tcu::TestCaseGroup>				bindingOneToManyTests(new tcu::TestCaseGroup(testCtx, "binding_one_to_many", "Attributes share the same binding"));
2093 
2094 		std::vector<VertexInputTest::AttributeInfo>	attributeInfos(attributeCount[attributeCountNdx]);
2095 
2096 		for (deUint32 attributeNdx = 0; attributeNdx < attributeCount[attributeCountNdx]; attributeNdx++)
2097 		{
2098 			// Use random glslTypes, each consuming one attribute location
2099 			const VertexInputTest::GlslType	glslType	= (VertexInputTest::GlslType)(randomFunc.getUint32() % VertexInputTest::GLSL_TYPE_MAT2);
2100 			const std::vector<VkFormat>&	formats		= compatibleFormats[glslType].compatibleVkFormats;
2101 			const VkFormat					format		= formats[randomFunc.getUint32() % formats.size()];
2102 
2103 			attributeInfos[attributeNdx].glslType		= glslType;
2104 			attributeInfos[attributeNdx].inputRate		= ((attributeCountNdx + attributeNdx) % 2 == 0) ? VK_VERTEX_INPUT_RATE_VERTEX : VK_VERTEX_INPUT_RATE_INSTANCE;
2105 			attributeInfos[attributeNdx].vkType			= format;
2106 		}
2107 
2108 		bindingOneToOneTests->addChild(new VertexInputTest(testCtx, "interleaved", "Interleaved attribute layout", attributeInfos, VertexInputTest::BINDING_MAPPING_ONE_TO_ONE, VertexInputTest::ATTRIBUTE_LAYOUT_INTERLEAVED));
2109 		bindingOneToManyTests->addChild(new VertexInputTest(testCtx, "interleaved", "Interleaved attribute layout", attributeInfos, VertexInputTest::BINDING_MAPPING_ONE_TO_MANY, VertexInputTest::ATTRIBUTE_LAYOUT_INTERLEAVED));
2110 		bindingOneToManyTests->addChild(new VertexInputTest(testCtx, "sequential", "Sequential attribute layout", attributeInfos, VertexInputTest::BINDING_MAPPING_ONE_TO_MANY, VertexInputTest::ATTRIBUTE_LAYOUT_SEQUENTIAL));
2111 
2112 		numAttributeTests->addChild(bindingOneToOneTests.release());
2113 		numAttributeTests->addChild(bindingOneToManyTests.release());
2114 		maxAttributeTests->addChild(numAttributeTests.release());
2115 	}
2116 }
2117 
2118 } // anonymous
2119 
createVertexInputTests(tcu::TestCaseGroup * vertexInputTests)2120 void createVertexInputTests (tcu::TestCaseGroup* vertexInputTests)
2121 {
2122 	addTestGroup(vertexInputTests, "single_attribute", "Uses one attribute", createSingleAttributeTests);
2123 	addTestGroup(vertexInputTests, "multiple_attributes", "Uses more than one attribute", createMultipleAttributeTests);
2124 	addTestGroup(vertexInputTests, "max_attributes", "Implementations can use as many vertex input attributes as they advertise", createMaxAttributeTests);
2125 }
2126 
2127 } // pipeline
2128 } // vkt
2129