1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2015 The Khronos Group Inc.
6 * Copyright (c) 2015 Imagination Technologies Ltd.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and/or associated documentation files (the
10 * "Materials"), to deal in the Materials without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Materials, and to
13 * permit persons to whom the Materials are furnished to do so, subject to
14 * the following conditions:
16 * The above copyright notice(s) and this permission notice shall be included
17 * in all copies or substantial portions of the Materials.
19 * The Materials are Confidential Information as defined by the
20 * Khronos Membership Agreement until designated non-confidential by Khronos,
21 * at which point this condition clause shall be removed.
23 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
27 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
28 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
29 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
33 * \brief Vertex Input Tests
34 *//*--------------------------------------------------------------------*/
36 #include "vktPipelineVertexInputTests.hpp"
37 #include "vktPipelineCombinationsIterator.hpp"
38 #include "vktPipelineClearUtil.hpp"
39 #include "vktPipelineImageUtil.hpp"
40 #include "vktPipelineVertexUtil.hpp"
41 #include "vktPipelineReferenceRenderer.hpp"
42 #include "vktTestCase.hpp"
43 #include "vktTestCaseUtil.hpp"
44 #include "vkImageUtil.hpp"
45 #include "vkMemUtil.hpp"
46 #include "vkPrograms.hpp"
47 #include "vkQueryUtil.hpp"
49 #include "vkRefUtil.hpp"
50 #include "tcuFloat.hpp"
51 #include "tcuImageCompare.hpp"
52 #include "deFloat16.h"
54 #include "deStringUtil.hpp"
55 #include "deUniquePtr.hpp"
70 bool isSupportedVertexFormat (const InstanceInterface& instanceInterface, VkPhysicalDevice device, VkFormat format)
72 VkFormatProperties formatProps;
73 deMemset(&formatProps, 0, sizeof(VkFormatProperties));
74 instanceInterface.getPhysicalDeviceFormatProperties(device, format, &formatProps);
76 return (formatProps.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) != 0u;
79 float getRepresentableDifferenceUnorm (VkFormat format)
81 DE_ASSERT(isVertexFormatUnorm(format) || isVertexFormatSRGB(format));
83 return 1.0f / float((1 << (getVertexFormatComponentSize(format) * 8)) - 1);
86 float getRepresentableDifferenceSnorm (VkFormat format)
88 DE_ASSERT(isVertexFormatSnorm(format));
90 return 1.0f / float((1 << (getVertexFormatComponentSize(format) * 8 - 1)) - 1);
93 class VertexInputTest : public vkt::TestCase
130 GLSL_BASIC_TYPE_UINT,
131 GLSL_BASIC_TYPE_FLOAT,
132 GLSL_BASIC_TYPE_DOUBLE
137 BINDING_MAPPING_ONE_TO_ONE, // Vertex input bindings will not contain data for more than one attribute.
138 BINDING_MAPPING_ONE_TO_MANY // Vertex input bindings can contain data for more than one attribute.
145 VkVertexInputRate inputRate;
148 struct GlslTypeDescription
151 int vertexInputComponentCount;
152 int vertexInputCount;
153 GlslBasicType basicType;
156 static const GlslTypeDescription s_glslTypeDescriptions[GLSL_TYPE_COUNT];
158 VertexInputTest (tcu::TestContext& testContext,
159 const std::string& name,
160 const std::string& description,
161 const std::vector<AttributeInfo>& attributeInfos,
162 BindingMapping bindingMapping);
164 virtual ~VertexInputTest (void) {}
165 virtual void initPrograms (SourceCollections& programCollection) const;
166 virtual TestInstance* createInstance (Context& context) const;
167 static bool isCompatibleType (VkFormat format, GlslType glslType);
170 std::string getGlslInputDeclarations (void) const;
171 std::string getGlslVertexCheck (void) const;
172 std::string getGlslAttributeConditions (const AttributeInfo& attributeInfo, deUint32 attributeIndex) const;
173 static tcu::Vec4 getFormatThreshold (VkFormat format);
175 const std::vector<AttributeInfo> m_attributeInfos;
176 const BindingMapping m_bindingMapping;
179 class GlslTypeCombinationsIterator : public CombinationsIterator< std::vector<VertexInputTest::GlslType> >
182 GlslTypeCombinationsIterator (deUint32 numValues, deUint32 combinationSize);
183 virtual ~GlslTypeCombinationsIterator (void) {}
186 virtual std::vector<VertexInputTest::GlslType> getCombinationValue (const std::vector<deUint32>& combination);
189 std::vector<VertexInputTest::GlslType> m_combinationValue;
192 class VertexInputInstance : public vkt::TestInstance
195 struct VertexInputAttributeDescription
197 VertexInputTest::GlslType glslType;
198 int vertexInputIndex;
199 VkVertexInputAttributeDescription vkDescription;
202 typedef std::vector<VertexInputAttributeDescription> AttributeDescriptionList;
204 VertexInputInstance (Context& context,
205 const AttributeDescriptionList& attributeDescriptions,
206 const std::vector<VkVertexInputBindingDescription>& bindingDescriptions,
207 const std::vector<VkDeviceSize>& bindingOffsets);
209 virtual ~VertexInputInstance (void);
210 virtual tcu::TestStatus iterate (void);
213 static void writeVertexInputData (deUint8* destPtr, const VkVertexInputBindingDescription& bindingDescription, const VkDeviceSize bindingOffset, const AttributeDescriptionList& attributes);
214 static void writeVertexInputValue (deUint8* destPtr, const VertexInputAttributeDescription& attributes, int indexId);
217 tcu::TestStatus verifyImage (void);
220 std::vector<VkBuffer> m_vertexBuffers;
221 std::vector<Allocation*> m_vertexBufferAllocs;
223 const tcu::IVec2 m_renderSize;
224 const VkFormat m_colorFormat;
226 Move<VkImage> m_colorImage;
227 de::MovePtr<Allocation> m_colorImageAlloc;
228 Move<VkImage> m_depthImage;
229 Move<VkImageView> m_colorAttachmentView;
230 Move<VkRenderPass> m_renderPass;
231 Move<VkFramebuffer> m_framebuffer;
233 Move<VkShaderModule> m_vertexShaderModule;
234 Move<VkShaderModule> m_fragmentShaderModule;
236 Move<VkPipelineLayout> m_pipelineLayout;
237 Move<VkPipeline> m_graphicsPipeline;
239 Move<VkCommandPool> m_cmdPool;
240 Move<VkCommandBuffer> m_cmdBuffer;
242 Move<VkFence> m_fence;
245 const VertexInputTest::GlslTypeDescription VertexInputTest::s_glslTypeDescriptions[GLSL_TYPE_COUNT] =
247 { "int", 1, 1, GLSL_BASIC_TYPE_INT },
248 { "ivec2", 2, 1, GLSL_BASIC_TYPE_INT },
249 { "ivec3", 3, 1, GLSL_BASIC_TYPE_INT },
250 { "ivec4", 4, 1, GLSL_BASIC_TYPE_INT },
252 { "uint", 1, 1, GLSL_BASIC_TYPE_UINT },
253 { "uvec2", 2, 1, GLSL_BASIC_TYPE_UINT },
254 { "uvec3", 3, 1, GLSL_BASIC_TYPE_UINT },
255 { "uvec4", 4, 1, GLSL_BASIC_TYPE_UINT },
257 { "float", 1, 1, GLSL_BASIC_TYPE_FLOAT },
258 { "vec2", 2, 1, GLSL_BASIC_TYPE_FLOAT },
259 { "vec3", 3, 1, GLSL_BASIC_TYPE_FLOAT },
260 { "vec4", 4, 1, GLSL_BASIC_TYPE_FLOAT },
261 { "mat2", 2, 2, GLSL_BASIC_TYPE_FLOAT },
262 { "mat3", 3, 3, GLSL_BASIC_TYPE_FLOAT },
263 { "mat4", 4, 4, GLSL_BASIC_TYPE_FLOAT },
265 { "double", 1, 1, GLSL_BASIC_TYPE_DOUBLE },
266 { "dvec2", 2, 1, GLSL_BASIC_TYPE_DOUBLE },
267 { "dvec3", 3, 1, GLSL_BASIC_TYPE_DOUBLE },
268 { "dvec4", 4, 1, GLSL_BASIC_TYPE_DOUBLE },
269 { "dmat2", 2, 2, GLSL_BASIC_TYPE_DOUBLE },
270 { "dmat3", 3, 3, GLSL_BASIC_TYPE_DOUBLE },
271 { "dmat4", 4, 4, GLSL_BASIC_TYPE_DOUBLE }
275 VertexInputTest::VertexInputTest (tcu::TestContext& testContext,
276 const std::string& name,
277 const std::string& description,
278 const std::vector<AttributeInfo>& attributeInfos,
279 BindingMapping bindingMapping)
281 : vkt::TestCase (testContext, name, description)
282 , m_attributeInfos (attributeInfos)
283 , m_bindingMapping (bindingMapping)
287 TestInstance* VertexInputTest::createInstance (Context& context) const
289 // Create enough binding descriptions with random offsets
290 std::vector<VkVertexInputBindingDescription> bindingDescriptions;
291 std::vector<VkDeviceSize> bindingOffsets;
293 for (size_t bindingNdx = 0; bindingNdx < m_attributeInfos.size() * 2; bindingNdx++)
295 // Use STEP_RATE_VERTEX in even bindings and STEP_RATE_INSTANCE in odd bindings
296 const VkVertexInputRate inputRate = (bindingNdx % 2 == 0) ? VK_VERTEX_INPUT_RATE_VERTEX : VK_VERTEX_INPUT_RATE_INSTANCE;
298 // .strideInBytes will be updated when creating the attribute descriptions
299 const VkVertexInputBindingDescription bindingDescription =
301 (deUint32)bindingNdx, // deUint32 binding;
302 0, // deUint32 stride;
303 inputRate // VkVertexInputRate inputRate;
306 bindingDescriptions.push_back(bindingDescription);
307 bindingOffsets.push_back(4 * bindingNdx);
310 // Create attribute descriptions, assign them to bindings and update .strideInBytes
311 std::vector<VertexInputInstance::VertexInputAttributeDescription> attributeDescriptions;
312 deUint32 attributeLocation = 0;
313 std::vector<deUint32> attributeOffsets (bindingDescriptions.size(), 0);
315 for (size_t attributeNdx = 0; attributeNdx < m_attributeInfos.size(); attributeNdx++)
317 const AttributeInfo& attributeInfo = m_attributeInfos[attributeNdx];
318 const GlslTypeDescription& glslTypeDescription = s_glslTypeDescriptions[attributeInfo.glslType];
319 const deUint32 inputSize = getVertexFormatSize(attributeInfo.vkType);
320 deUint32 attributeBinding;
322 if (m_bindingMapping == BINDING_MAPPING_ONE_TO_ONE)
324 if (attributeInfo.inputRate == VK_VERTEX_INPUT_RATE_VERTEX)
326 attributeBinding = (deUint32)attributeNdx * 2; // Odd binding number
328 else // attributeInfo.inputRate == VK_VERTEX_INPUT_STEP_RATE_INSTANCE
330 attributeBinding = (deUint32)attributeNdx * 2 + 1; // Even binding number
333 else // m_bindingMapping == BINDING_MAPPING_ONE_TO_MANY
335 if (attributeInfo.inputRate == VK_VERTEX_INPUT_RATE_VERTEX)
337 attributeBinding = 0;
339 else // attributeInfo.inputRate == VK_VERTEX_INPUT_STEP_RATE_INSTANCE
341 attributeBinding = 1;
345 for (int descNdx = 0; descNdx < glslTypeDescription.vertexInputCount; descNdx++)
347 const VertexInputInstance::VertexInputAttributeDescription attributeDescription =
349 attributeInfo.glslType, // GlslType glslType;
350 descNdx, // int index;
352 attributeLocation, // deUint32 location;
353 attributeBinding, // deUint32 binding;
354 attributeInfo.vkType, // VkFormat format;
355 attributeOffsets[attributeBinding], // deUint32 offset;
359 bindingDescriptions[attributeBinding].stride += inputSize;
360 attributeOffsets[attributeBinding] += inputSize;
364 attributeDescriptions.push_back(attributeDescription);
368 return new VertexInputInstance(context, attributeDescriptions, bindingDescriptions, bindingOffsets);
371 void VertexInputTest::initPrograms (SourceCollections& programCollection) const
373 std::ostringstream vertexSrc;
375 vertexSrc << "#version 440\n"
376 << getGlslInputDeclarations()
377 << "layout(location = 0) out highp vec4 vtxColor;\n"
378 << "out gl_PerVertex {\n"
379 << " vec4 gl_Position;\n"
381 << "double abs (double x) { if (x < 0.0LF) return -x; else return x; }\n" // NOTE: Currently undefined in glslang ??
382 << "void main (void)\n"
384 << getGlslVertexCheck()
387 programCollection.glslSources.add("attribute_test_vert") << glu::VertexSource(vertexSrc.str());
389 programCollection.glslSources.add("attribute_test_frag") << glu::FragmentSource(
391 "layout(location = 0) in highp vec4 vtxColor;\n"
392 "layout(location = 0) out highp vec4 fragColor;\n"
395 " fragColor = vtxColor;\n"
399 std::string VertexInputTest::getGlslInputDeclarations (void) const
401 std::ostringstream glslInputs;
402 deUint32 location = 0;
404 for (size_t attributeNdx = 0; attributeNdx < m_attributeInfos.size(); attributeNdx++)
406 const GlslTypeDescription& glslTypeDesc = s_glslTypeDescriptions[m_attributeInfos[attributeNdx].glslType];
408 glslInputs << "layout(location = " << location << ") in highp " << glslTypeDesc.name << " attr" << attributeNdx << ";\n";
409 location += glslTypeDesc.vertexInputCount;
412 return glslInputs.str();
415 std::string VertexInputTest::getGlslVertexCheck (void) const
417 std::ostringstream glslCode;
418 int totalInputComponentCount = 0;
421 glslCode << " int okCount = 0;\n";
423 for (size_t attributeNdx = 0; attributeNdx < m_attributeInfos.size(); attributeNdx++)
425 glslCode << getGlslAttributeConditions(m_attributeInfos[attributeNdx], (deUint32)attributeNdx);
427 const int vertexInputCount = VertexInputTest::s_glslTypeDescriptions[m_attributeInfos[attributeNdx].glslType].vertexInputCount;
428 totalInputComponentCount += vertexInputCount * VertexInputTest::s_glslTypeDescriptions[m_attributeInfos[attributeNdx].glslType].vertexInputComponentCount;
432 " if (okCount == " << totalInputComponentCount << ")\n"
434 " if (gl_InstanceID == 0)\n"
435 " vtxColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
437 " vtxColor = vec4(0.0, 0.0, 1.0, 1.0);\n"
441 " vtxColor = vec4(okCount / float(" << totalInputComponentCount << "), 0.0f, 0.0f, 1.0);\n" <<
443 " if (gl_InstanceID == 0)\n"
445 " if (gl_VertexID == 0) gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);\n"
446 " else if (gl_VertexID == 1) gl_Position = vec4(0.0, -1.0, 0.0, 1.0);\n"
447 " else if (gl_VertexID == 2) gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);\n"
448 " else if (gl_VertexID == 3) gl_Position = vec4(0.0, 1.0, 0.0, 1.0);\n"
449 " else gl_Position = vec4(0.0);\n"
453 " if (gl_VertexID == 0) gl_Position = vec4(0.0, -1.0, 0.0, 1.0);\n"
454 " else if (gl_VertexID == 1) gl_Position = vec4(1.0, -1.0, 0.0, 1.0);\n"
455 " else if (gl_VertexID == 2) gl_Position = vec4(0.0, 1.0, 0.0, 1.0);\n"
456 " else if (gl_VertexID == 3) gl_Position = vec4(1.0, 1.0, 0.0, 1.0);\n"
457 " else gl_Position = vec4(0.0);\n"
460 return glslCode.str();
463 std::string VertexInputTest::getGlslAttributeConditions (const AttributeInfo& attributeInfo, deUint32 attributeIndex) const
465 std::ostringstream glslCode;
466 std::ostringstream attributeVar;
467 const std::string indexId = (attributeInfo.inputRate == VK_VERTEX_INPUT_RATE_VERTEX) ? "gl_VertexID" : "gl_InstanceID";
468 const int componentCount = VertexInputTest::s_glslTypeDescriptions[attributeInfo.glslType].vertexInputComponentCount;
469 const int vertexInputCount = VertexInputTest::s_glslTypeDescriptions[attributeInfo.glslType].vertexInputCount;
470 const deUint32 totalComponentCount = componentCount * vertexInputCount;
471 const tcu::Vec4 threshold = getFormatThreshold(attributeInfo.vkType);
472 deUint32 componentIndex = 0;
474 attributeVar << "attr" << attributeIndex;
476 glslCode << std::fixed;
478 for (int columnNdx = 0; columnNdx< vertexInputCount; columnNdx++)
480 for (int rowNdx = 0; rowNdx < componentCount; rowNdx++)
482 std::string accessStr;
484 // Build string representing the access to the attribute component
485 std::ostringstream accessStream;
486 accessStream << attributeVar.str();
488 if (vertexInputCount == 1)
490 if (componentCount > 1)
491 accessStream << "[" << rowNdx << "]";
495 accessStream << "[" << columnNdx << "][" << rowNdx << "]";
498 accessStr = accessStream.str();
501 if (isVertexFormatSint(attributeInfo.vkType))
503 glslCode << "\tif (" << accessStr << " == -(" << totalComponentCount << " * " << indexId << " + " << componentIndex << "))\n";
505 else if (isVertexFormatUint(attributeInfo.vkType))
507 glslCode << "\tif (" << accessStr << " == uint(" << totalComponentCount << " * " << indexId << " + " << componentIndex << "))\n";
509 else if (isVertexFormatSfloat(attributeInfo.vkType))
511 if (VertexInputTest::s_glslTypeDescriptions[attributeInfo.glslType].basicType == VertexInputTest::GLSL_BASIC_TYPE_DOUBLE)
513 glslCode << "\tif (abs(" << accessStr << " + double(0.01 * (" << totalComponentCount << ".0 * float(" << indexId << ") + " << componentIndex << ".0))) < double(" << threshold[rowNdx] << "))\n";
517 glslCode << "\tif (abs(" << accessStr << " + (0.01 * (" << totalComponentCount << ".0 * float(" << indexId << ") + " << componentIndex << ".0))) < " << threshold[rowNdx] << ")\n";
520 else if (isVertexFormatSscaled(attributeInfo.vkType))
522 glslCode << "\tif (abs(" << accessStr << " + (" << totalComponentCount << ".0 * float(" << indexId << ") + " << componentIndex << ".0)) < " << threshold[rowNdx] << ")\n";
524 else if (isVertexFormatUscaled(attributeInfo.vkType))
526 glslCode << "\t if (abs(" << accessStr << " - (" << totalComponentCount << ".0 * float(" << indexId << ") + " << componentIndex << ".0)) < " << threshold[rowNdx] << ")\n";
528 else if (isVertexFormatSnorm(attributeInfo.vkType))
530 const float representableDiff = getRepresentableDifferenceSnorm(attributeInfo.vkType);
532 glslCode << "\tif (abs(" << accessStr << " - (-1.0 + " << representableDiff << " * (" << totalComponentCount << ".0 * float(" << indexId << ") + " << componentIndex << ".0))) < " << threshold[rowNdx] << ")\n";
534 else if (isVertexFormatUnorm(attributeInfo.vkType) || isVertexFormatSRGB(attributeInfo.vkType))
536 const float representableDiff = getRepresentableDifferenceUnorm(attributeInfo.vkType);
538 glslCode << "\tif (abs(" << accessStr << " - " << "(" << representableDiff << " * (" << totalComponentCount << ".0 * float(" << indexId << ") + " << componentIndex << ".0))) < " << threshold[rowNdx] << ")\n";
545 glslCode << "\t\tokCount++;\n\n";
550 return glslCode.str();
553 tcu::Vec4 VertexInputTest::getFormatThreshold (VkFormat format)
559 case VK_FORMAT_R32_SFLOAT:
560 case VK_FORMAT_R32G32_SFLOAT:
561 case VK_FORMAT_R32G32B32_SFLOAT:
562 case VK_FORMAT_R32G32B32A32_SFLOAT:
563 case VK_FORMAT_R64_SFLOAT:
564 case VK_FORMAT_R64G64_SFLOAT:
565 case VK_FORMAT_R64G64B64_SFLOAT:
566 case VK_FORMAT_R64G64B64A64_SFLOAT:
567 return Vec4(0.00001f);
573 if (isVertexFormatSnorm(format))
575 return Vec4(1.5f * getRepresentableDifferenceSnorm(format));
577 else if (isVertexFormatUnorm(format))
579 return Vec4(1.5f * getRepresentableDifferenceUnorm(format));
585 GlslTypeCombinationsIterator::GlslTypeCombinationsIterator (deUint32 numValues, deUint32 combinationSize)
586 : CombinationsIterator< std::vector<VertexInputTest::GlslType> > (numValues, combinationSize)
587 , m_combinationValue (std::vector<VertexInputTest::GlslType>(combinationSize))
589 DE_ASSERT(numValues <= VertexInputTest::GLSL_TYPE_COUNT);
592 std::vector<VertexInputTest::GlslType> GlslTypeCombinationsIterator::getCombinationValue (const std::vector<deUint32>& combination)
594 for (size_t combinationItemNdx = 0; combinationItemNdx < combination.size(); combinationItemNdx++)
595 m_combinationValue[combinationItemNdx] = (VertexInputTest::GlslType)combination[combinationItemNdx];
597 return m_combinationValue;
600 VertexInputInstance::VertexInputInstance (Context& context,
601 const AttributeDescriptionList& attributeDescriptions,
602 const std::vector<VkVertexInputBindingDescription>& bindingDescriptions,
603 const std::vector<VkDeviceSize>& bindingOffsets)
604 : vkt::TestInstance (context)
605 , m_renderSize (16, 16)
606 , m_colorFormat (VK_FORMAT_R8G8B8A8_UNORM)
608 DE_ASSERT(bindingDescriptions.size() == bindingOffsets.size());
610 const DeviceInterface& vk = context.getDeviceInterface();
611 const VkDevice vkDevice = context.getDevice();
612 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
613 SimpleAllocator memAlloc (vk, vkDevice, getPhysicalDeviceMemoryProperties(context.getInstanceInterface(), context.getPhysicalDevice()));
614 const VkComponentMapping componentMappingRGBA = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A };
616 // Create color image
618 const VkImageCreateInfo colorImageParams =
620 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
621 DE_NULL, // const void* pNext;
622 0u, // VkImageCreateFlags flags;
623 VK_IMAGE_TYPE_2D, // VkImageType imageType;
624 m_colorFormat, // VkFormat format;
625 { m_renderSize.x(), m_renderSize.y(), 1u }, // VkExtent3D extent;
626 1u, // deUint32 mipLevels;
627 1u, // deUint32 arrayLayers;
628 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
629 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
630 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, // VkImageUsageFlags usage;
631 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
632 1u, // deUint32 queueFamilyIndexCount;
633 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
634 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
637 m_colorImage = createImage(vk, vkDevice, &colorImageParams);
639 // Allocate and bind color image memory
640 m_colorImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_colorImage), MemoryRequirement::Any);
641 VK_CHECK(vk.bindImageMemory(vkDevice, *m_colorImage, m_colorImageAlloc->getMemory(), m_colorImageAlloc->getOffset()));
644 // Create color attachment view
646 const VkImageViewCreateInfo colorAttachmentViewParams =
648 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // VkStructureType sType;
649 DE_NULL, // const void* pNext;
650 0u, // VkImageViewCreateFlags flags;
651 *m_colorImage, // VkImage image;
652 VK_IMAGE_VIEW_TYPE_2D, // VkImageViewType viewType;
653 m_colorFormat, // VkFormat format;
654 componentMappingRGBA, // VkComponentMapping components;
655 { VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u }, // VkImageSubresourceRange subresourceRange;
658 m_colorAttachmentView = createImageView(vk, vkDevice, &colorAttachmentViewParams);
661 // Create render pass
663 const VkAttachmentDescription colorAttachmentDescription =
665 0u, // VkAttachmentDescriptionFlags flags;
666 m_colorFormat, // VkFormat format;
667 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
668 VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp;
669 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
670 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp;
671 VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp;
672 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout;
673 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout;
676 const VkAttachmentReference colorAttachmentReference =
678 0u, // deUint32 attachment;
679 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout layout;
682 const VkSubpassDescription subpassDescription =
684 0u, // VkSubpassDescriptionFlags flags;
685 VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint;
686 0u, // deUint32 inputAttachmentCount;
687 DE_NULL, // const VkAttachmentReference* pInputAttachments;
688 1u, // deUint32 colorAttachmentCount;
689 &colorAttachmentReference, // const VkAttachmentReference* pColorAttachments;
690 DE_NULL, // const VkAttachmentReference* pResolveAttachments;
691 DE_NULL, // const VkAttachmentReference* pDepthStencilAttachment;
692 0u, // deUint32 preserveAttachmentCount;
693 DE_NULL // const VkAttachmentReference* pPreserveAttachments;
696 const VkRenderPassCreateInfo renderPassParams =
698 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType;
699 DE_NULL, // const void* pNext;
700 0u, // VkRenderPassCreateFlags flags;
701 1u, // deUint32 attachmentCount;
702 &colorAttachmentDescription, // const VkAttachmentDescription* pAttachments;
703 1u, // deUint32 subpassCount;
704 &subpassDescription, // const VkSubpassDescription* pSubpasses;
705 0u, // deUint32 dependencyCount;
706 DE_NULL // const VkSubpassDependency* pDependencies;
709 m_renderPass = createRenderPass(vk, vkDevice, &renderPassParams);
712 // Create framebuffer
714 const VkFramebufferCreateInfo framebufferParams =
716 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType;
717 DE_NULL, // const void* pNext;
718 0u, // VkFramebufferCreateFlags flags;
719 *m_renderPass, // VkRenderPass renderPass;
720 1u, // deUint32 attachmentCount;
721 &m_colorAttachmentView.get(), // const VkImageView* pAttachments;
722 (deUint32)m_renderSize.x(), // deUint32 width;
723 (deUint32)m_renderSize.y(), // deUint32 height;
724 1u // deUint32 layers;
727 m_framebuffer = createFramebuffer(vk, vkDevice, &framebufferParams);
730 // Create pipeline layout
732 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
734 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // VkStructureType sType;
735 DE_NULL, // const void* pNext;
736 0u, // VkPipelineLayoutCreateFlags flags;
737 0u, // deUint32 setLayoutCount;
738 DE_NULL, // const VkDescriptorSetLayout* pSetLayouts;
739 0u, // deUint32 pushConstantRangeCount;
740 DE_NULL // const VkPushConstantRange* pPushConstantRanges;
743 m_pipelineLayout = createPipelineLayout(vk, vkDevice, &pipelineLayoutParams);
746 m_vertexShaderModule = createShaderModule(vk, vkDevice, m_context.getBinaryCollection().get("attribute_test_vert"), 0);
747 m_fragmentShaderModule = createShaderModule(vk, vkDevice, m_context.getBinaryCollection().get("attribute_test_frag"), 0);
752 const VkPipelineShaderStageCreateInfo shaderStageParams[2] =
755 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
756 DE_NULL, // const void* pNext;
757 0u, // VkPipelineShaderStageCreateFlags flags;
758 VK_SHADER_STAGE_VERTEX_BIT, // VkShaderStageFlagBits stage;
759 *m_vertexShaderModule, // VkShaderModule module;
760 "main", // const char* pName;
761 DE_NULL // const VkSpecializationInfo* pSpecializationInfo;
764 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
765 DE_NULL, // const void* pNext;
766 0u, // VkPipelineShaderStageCreateFlags flags;
767 VK_SHADER_STAGE_FRAGMENT_BIT, // VkShaderStageFlagBits stage;
768 *m_fragmentShaderModule, // VkShaderModule module;
769 "main", // const char* pName;
770 DE_NULL // const VkSpecializationInfo* pSpecializationInfo;
774 // Create vertex attribute array and check if their VK formats are supported
775 std::vector<VkVertexInputAttributeDescription> vkAttributeDescriptions;
776 for (size_t attributeNdx = 0; attributeNdx < attributeDescriptions.size(); attributeNdx++)
778 const VkVertexInputAttributeDescription& attributeDescription = attributeDescriptions[attributeNdx].vkDescription;
780 if (!isSupportedVertexFormat(context.getInstanceInterface(), context.getPhysicalDevice(), attributeDescription.format))
781 throw tcu::NotSupportedError(std::string("Unsupported format for vertex input: ") + getFormatName(attributeDescription.format));
783 vkAttributeDescriptions.push_back(attributeDescription);
786 const VkPipelineVertexInputStateCreateInfo vertexInputStateParams =
788 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // VkStructureType sType;
789 DE_NULL, // const void* pNext;
790 0u, // VkPipelineVertexInputStateCreateFlags flags;
791 (deUint32)bindingDescriptions.size(), // deUint32 vertexBindingDescriptionCount;
792 bindingDescriptions.data(), // const VkVertexInputBindingDescription* pVertexBindingDescriptions;
793 (deUint32)vkAttributeDescriptions.size(), // deUint32 vertexAttributeDescriptionCount;
794 vkAttributeDescriptions.data() // const VkVertexInputAttributeDescription* pVertexAttributeDescriptions;
797 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateParams =
799 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // VkStructureType sType;
800 DE_NULL, // const void* pNext;
801 0u, // VkPipelineInputAssemblyStateCreateFlags flags;
802 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, // VkPrimitiveTopology topology;
803 false // VkBool32 primitiveRestartEnable;
806 const VkViewport viewport =
810 (float)m_renderSize.x(), // float width;
811 (float)m_renderSize.y(), // float height;
812 0.0f, // float minDepth;
813 1.0f // float maxDepth;
816 const VkRect2D scissor = { { 0, 0 }, { m_renderSize.x(), m_renderSize.y() } };
818 const VkPipelineViewportStateCreateInfo viewportStateParams =
820 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // VkStructureType sType;
821 DE_NULL, // const void* pNext;
822 0u, // VkPipelineViewportStateCreateFlags flags;
823 1u, // deUint32 viewportCount;
824 &viewport, // const VkViewport* pViewports;
825 1u, // deUint32 scissorCount;
826 &scissor // const VkRect2D* pScissors;
829 const VkPipelineRasterizationStateCreateInfo rasterStateParams =
831 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // VkStructureType sType;
832 DE_NULL, // const void* pNext;
833 0u, // VkPipelineRasterizationStateCreateFlags flags;
834 false, // VkBool32 depthClampEnable;
835 false, // VkBool32 rasterizerDiscardEnable;
836 VK_POLYGON_MODE_FILL, // VkPolygonMode polygonMode;
837 VK_CULL_MODE_NONE, // VkCullModeFlags cullMode;
838 VK_FRONT_FACE_COUNTER_CLOCKWISE, // VkFrontFace frontFace;
839 VK_FALSE, // VkBool32 depthBiasEnable;
840 0.0f, // float depthBiasConstantFactor;
841 0.0f, // float depthBiasClamp;
842 0.0f, // float depthBiasSlopeFactor;
843 1.0f, // float lineWidth;
846 const VkPipelineColorBlendAttachmentState colorBlendAttachmentState =
848 false, // VkBool32 blendEnable;
849 VK_BLEND_FACTOR_ONE, // VkBlendFactor srcColorBlendFactor;
850 VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstColorBlendFactor;
851 VK_BLEND_OP_ADD, // VkBlendOp colorBlendOp;
852 VK_BLEND_FACTOR_ONE, // VkBlendFactor srcAlphaBlendFactor;
853 VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstAlphaBlendFactor;
854 VK_BLEND_OP_ADD, // VkBlendOp alphaBlendOp;
855 VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | // VkColorComponentFlags colorWriteMask;
856 VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT
859 const VkPipelineColorBlendStateCreateInfo colorBlendStateParams =
861 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // VkStructureType sType;
862 DE_NULL, // const void* pNext;
863 0u, // VkPipelineColorBlendStateCreateFlags flags;
864 false, // VkBool32 logicOpEnable;
865 VK_LOGIC_OP_COPY, // VkLogicOp logicOp;
866 1u, // deUint32 attachmentCount;
867 &colorBlendAttachmentState, // const VkPipelineColorBlendAttachmentState* pAttachments;
868 { 0.0f, 0.0f, 0.0f, 0.0f }, // float blendConstants[4];
871 const VkPipelineMultisampleStateCreateInfo multisampleStateParams =
873 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // VkStructureType sType;
874 DE_NULL, // const void* pNext;
875 0u, // VkPipelineMultisampleStateCreateFlags flags;
876 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits rasterizationSamples;
877 false, // VkBool32 sampleShadingEnable;
878 0.0f, // float minSampleShading;
879 DE_NULL, // const VkSampleMask* pSampleMask;
880 false, // VkBool32 alphaToCoverageEnable;
881 false // VkBool32 alphaToOneEnable;
884 const VkPipelineDynamicStateCreateInfo dynamicStateParams =
886 VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, // VkStructureType sType;
887 DE_NULL, // const void* pNext;
888 0u, // VkPipelineDynamicStateCreateFlags flags;
889 0u, // deUint32 dynamicStateCount;
890 DE_NULL // const VkDynamicState* pDynamicStates;
893 VkPipelineDepthStencilStateCreateInfo depthStencilStateParams =
895 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // VkStructureType sType;
896 DE_NULL, // const void* pNext;
897 0u, // VkPipelineDepthStencilStateCreateFlags flags;
898 false, // VkBool32 depthTestEnable;
899 false, // VkBool32 depthWriteEnable;
900 VK_COMPARE_OP_LESS, // VkCompareOp depthCompareOp;
901 false, // VkBool32 depthBoundsTestEnable;
902 false, // VkBool32 stencilTestEnable;
903 // VkStencilOpState front;
905 VK_STENCIL_OP_KEEP, // VkStencilOp failOp;
906 VK_STENCIL_OP_KEEP, // VkStencilOp passOp;
907 VK_STENCIL_OP_KEEP, // VkStencilOp depthFailOp;
908 VK_COMPARE_OP_NEVER, // VkCompareOp compareOp;
909 0u, // deUint32 compareMask;
910 0u, // deUint32 writeMask;
911 0u, // deUint32 reference;
913 // VkStencilOpState back;
915 VK_STENCIL_OP_KEEP, // VkStencilOp failOp;
916 VK_STENCIL_OP_KEEP, // VkStencilOp passOp;
917 VK_STENCIL_OP_KEEP, // VkStencilOp depthFailOp;
918 VK_COMPARE_OP_NEVER, // VkCompareOp compareOp;
919 0u, // deUint32 compareMask;
920 0u, // deUint32 writeMask;
921 0u, // deUint32 reference;
923 -1.0f, // float minDepthBounds;
924 +1.0f, // float maxDepthBounds;
927 const VkGraphicsPipelineCreateInfo graphicsPipelineParams =
929 VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // VkStructureType sType;
930 DE_NULL, // const void* pNext;
931 0u, // VkPipelineCreateFlags flags;
932 2u, // deUint32 stageCount;
933 shaderStageParams, // const VkPipelineShaderStageCreateInfo* pStages;
934 &vertexInputStateParams, // const VkPipelineVertexInputStateCreateInfo* pVertexInputState;
935 &inputAssemblyStateParams, // const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState;
936 DE_NULL, // const VkPipelineTessellationStateCreateInfo* pTessellationState;
937 &viewportStateParams, // const VkPipelineViewportStateCreateInfo* pViewportState;
938 &rasterStateParams, // const VkPipelineRasterizationStateCreateInfo* pRasterizationState;
939 &multisampleStateParams, // const VkPipelineMultisampleStateCreateInfo* pMultisampleState;
940 &depthStencilStateParams, // const VkPipelineDepthStencilStateCreateInfo* pDepthStencilState;
941 &colorBlendStateParams, // const VkPipelineColorBlendStateCreateInfo* pColorBlendState;
942 &dynamicStateParams, // const VkPipelineDynamicStateCreateInfo* pDynamicState;
943 *m_pipelineLayout, // VkPipelineLayout layout;
944 *m_renderPass, // VkRenderPass renderPass;
945 0u, // deUint32 subpass;
946 0u, // VkPipeline basePipelineHandle;
947 0u // deInt32 basePipelineIndex;
950 m_graphicsPipeline = createGraphicsPipeline(vk, vkDevice, DE_NULL, &graphicsPipelineParams);
953 // Create vertex buffer
955 const VkBufferCreateInfo vertexBufferParams =
957 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
958 DE_NULL, // const void* pNext;
959 0u, // VkBufferCreateFlags flags;
960 4096u, // VkDeviceSize size;
961 VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, // VkBufferUsageFlags usage;
962 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
963 1u, // deUint32 queueFamilyIndexCount;
964 &queueFamilyIndex // const deUint32* pQueueFamilyIndices;
967 // Upload data for each vertex input binding
968 for (deUint32 bindingNdx = 0; bindingNdx < bindingDescriptions.size(); bindingNdx++)
970 Move<VkBuffer> vertexBuffer = createBuffer(vk, vkDevice, &vertexBufferParams);
971 de::MovePtr<Allocation> vertexBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *vertexBuffer), MemoryRequirement::HostVisible);
973 VK_CHECK(vk.bindBufferMemory(vkDevice, *vertexBuffer, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset()));
975 writeVertexInputData((deUint8*)vertexBufferAlloc->getHostPtr(), bindingDescriptions[bindingNdx], bindingOffsets[bindingNdx], attributeDescriptions);
976 flushMappedMemoryRange(vk, vkDevice, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset(), vertexBufferParams.size);
978 m_vertexBuffers.push_back(vertexBuffer.disown());
979 m_vertexBufferAllocs.push_back(vertexBufferAlloc.release());
983 // Create command pool
985 const VkCommandPoolCreateInfo cmdPoolParams =
987 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // VkStructureType sType;
988 DE_NULL, // const void* pNext;
989 VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, // VkCommandPoolCreateFlags flags;
990 queueFamilyIndex, // deUint32 queueFamilyIndex;
993 m_cmdPool = createCommandPool(vk, vkDevice, &cmdPoolParams);
996 // Create command buffer
998 const VkCommandBufferAllocateInfo cmdBufferAllocateInfo =
1000 VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // VkStructureType sType;
1001 DE_NULL, // const void* pNext;
1002 *m_cmdPool, // VkCommandPool commandPool;
1003 VK_COMMAND_BUFFER_LEVEL_PRIMARY, // VkCommandBufferLevel level;
1004 1u // deUint32 bufferCount;
1007 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
1009 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
1010 DE_NULL, // const void* pNext;
1011 0u, // VkCommandBufferUsageFlags flags;
1012 DE_NULL, // VkRenderPass renderPass;
1013 0u, // deUint32 subpass;
1014 DE_NULL, // VkFramebuffer framebuffer;
1015 false, // VkBool32 occlusionQueryEnable;
1016 0u, // VkQueryControlFlags queryFlags;
1017 0u // VkQueryPipelineStatisticFlags pipelineStatistics;
1020 const VkClearValue attachmentClearValue = defaultClearValue(m_colorFormat);
1022 const VkRenderPassBeginInfo renderPassBeginInfo =
1024 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // VkStructureType sType;
1025 DE_NULL, // const void* pNext;
1026 *m_renderPass, // VkRenderPass renderPass;
1027 *m_framebuffer, // VkFramebuffer framebuffer;
1028 { { 0, 0 }, { m_renderSize.x(), m_renderSize.y() } }, // VkRect2D renderArea;
1029 1u, // deUint32 clearValueCount;
1030 &attachmentClearValue // const VkClearValue* pClearValues;
1033 m_cmdBuffer = allocateCommandBuffer(vk, vkDevice, &cmdBufferAllocateInfo);
1035 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
1036 vk.cmdBeginRenderPass(*m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
1038 vk.cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_graphicsPipeline);
1040 std::vector<VkBuffer> vertexBuffers;
1041 for (size_t bufferNdx = 0; bufferNdx < m_vertexBuffers.size(); bufferNdx++)
1042 vertexBuffers.push_back(m_vertexBuffers[bufferNdx]);
1044 if (vertexBuffers.size() <= 1)
1046 // One vertex buffer
1047 vk.cmdBindVertexBuffers(*m_cmdBuffer, 0, (deUint32)vertexBuffers.size(), vertexBuffers.data(), bindingOffsets.data());
1051 // Smoke-test vkCmdBindVertexBuffers(..., startBinding, ... )
1053 const deUint32 firstHalfLength = (deUint32)vertexBuffers.size() / 2;
1054 const deUint32 secondHalfLength = firstHalfLength + (deUint32)(vertexBuffers.size() % 2);
1056 // Bind first half of vertex buffers
1057 vk.cmdBindVertexBuffers(*m_cmdBuffer, 0, firstHalfLength, vertexBuffers.data(), bindingOffsets.data());
1059 // Bind second half of vertex buffers
1060 vk.cmdBindVertexBuffers(*m_cmdBuffer, firstHalfLength, secondHalfLength,
1061 vertexBuffers.data() + firstHalfLength,
1062 bindingOffsets.data() + firstHalfLength);
1065 vk.cmdDraw(*m_cmdBuffer, 4, 2, 0, 0);
1067 vk.cmdEndRenderPass(*m_cmdBuffer);
1068 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1073 const VkFenceCreateInfo fenceParams =
1075 VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, // VkStructureType sType;
1076 DE_NULL, // const void* pNext;
1077 0u // VkFenceCreateFlags flags;
1080 m_fence = createFence(vk, vkDevice, &fenceParams);
1084 VertexInputInstance::~VertexInputInstance (void)
1086 const DeviceInterface& vk = m_context.getDeviceInterface();
1087 const VkDevice vkDevice = m_context.getDevice();
1089 for (size_t bufferNdx = 0; bufferNdx < m_vertexBuffers.size(); bufferNdx++)
1090 vk.destroyBuffer(vkDevice, m_vertexBuffers[bufferNdx], DE_NULL);
1092 for (size_t allocNdx = 0; allocNdx < m_vertexBufferAllocs.size(); allocNdx++)
1093 delete m_vertexBufferAllocs[allocNdx];
1096 void VertexInputInstance::writeVertexInputData(deUint8* destPtr, const VkVertexInputBindingDescription& bindingDescription, const VkDeviceSize bindingOffset, const AttributeDescriptionList& attributes)
1098 const deUint32 vertexCount = (bindingDescription.inputRate == VK_VERTEX_INPUT_RATE_VERTEX) ? (4 * 2) : 2;
1100 deUint8* destOffsetPtr = ((deUint8 *)destPtr) + bindingOffset;
1101 for (deUint32 vertexNdx = 0; vertexNdx < vertexCount; vertexNdx++)
1103 deUint32 vertexInputOffset = 0;
1104 for (size_t attributeNdx = 0; attributeNdx < attributes.size(); attributeNdx++)
1106 const VertexInputAttributeDescription& attribDesc = attributes[attributeNdx];
1108 // Only write vertex input data to bindings referenced by attribute descriptions
1109 if (attribDesc.vkDescription.binding == bindingDescription.binding)
1111 writeVertexInputValue(destOffsetPtr + vertexInputOffset, attribDesc, vertexNdx);
1112 vertexInputOffset += getVertexFormatSize(attribDesc.vkDescription.format);
1115 DE_ASSERT(vertexInputOffset <= bindingDescription.stride);
1116 destOffsetPtr += bindingDescription.stride;
1120 void writeVertexInputValueSint (deUint8* destPtr, VkFormat format, int componentNdx, deInt32 value)
1122 const deUint32 componentSize = getVertexFormatComponentSize(format);
1123 deUint8* destFormatPtr = ((deUint8*)destPtr) + componentSize * componentNdx;
1125 switch (componentSize)
1128 *((deInt8*)destFormatPtr) = (deInt8)value;
1132 *((deInt16*)destFormatPtr) = (deInt16)value;
1136 *((deInt32*)destFormatPtr) = (deInt32)value;
1144 void writeVertexInputValueUint (deUint8* destPtr, VkFormat format, int componentNdx, deUint32 value)
1146 const deUint32 componentSize = getVertexFormatComponentSize(format);
1147 deUint8* destFormatPtr = ((deUint8*)destPtr) + componentSize * componentNdx;
1149 switch (componentSize)
1152 *((deUint8 *)destFormatPtr) = (deUint8)value;
1156 *((deUint16 *)destFormatPtr) = (deUint16)value;
1160 *((deUint32 *)destFormatPtr) = (deUint32)value;
1168 void writeVertexInputValueSfloat (deUint8* destPtr, VkFormat format, int componentNdx, float value)
1170 const deUint32 componentSize = getVertexFormatComponentSize(format);
1171 deUint8* destFormatPtr = ((deUint8*)destPtr) + componentSize * componentNdx;
1173 switch (componentSize)
1176 *((deFloat16*)destFormatPtr) = deFloat32To16(value);
1180 *((float*)destFormatPtr) = value;
1188 void VertexInputInstance::writeVertexInputValue (deUint8* destPtr, const VertexInputAttributeDescription& attribute, int indexId)
1190 const int vertexInputCount = VertexInputTest::s_glslTypeDescriptions[attribute.glslType].vertexInputCount;
1191 const int componentCount = VertexInputTest::s_glslTypeDescriptions[attribute.glslType].vertexInputComponentCount;
1192 const deUint32 totalComponentCount = componentCount * vertexInputCount;
1193 const deUint32 vertexInputIndex = indexId * totalComponentCount + attribute.vertexInputIndex * componentCount;
1194 const bool hasBGROrder = isVertexFormatComponentOrderBGR(attribute.vkDescription.format);
1197 for (int componentNdx = 0; componentNdx < componentCount; componentNdx++)
1201 if (componentNdx == 0)
1203 else if (componentNdx == 2)
1206 swizzledNdx = componentNdx;
1209 swizzledNdx = componentNdx;
1211 switch (attribute.glslType)
1213 case VertexInputTest::GLSL_TYPE_INT:
1214 case VertexInputTest::GLSL_TYPE_IVEC2:
1215 case VertexInputTest::GLSL_TYPE_IVEC3:
1216 case VertexInputTest::GLSL_TYPE_IVEC4:
1217 writeVertexInputValueSint(destPtr, attribute.vkDescription.format, componentNdx, -(deInt32)(vertexInputIndex + swizzledNdx));
1220 case VertexInputTest::GLSL_TYPE_UINT:
1221 case VertexInputTest::GLSL_TYPE_UVEC2:
1222 case VertexInputTest::GLSL_TYPE_UVEC3:
1223 case VertexInputTest::GLSL_TYPE_UVEC4:
1224 writeVertexInputValueUint(destPtr, attribute.vkDescription.format, componentNdx, vertexInputIndex + swizzledNdx);
1227 case VertexInputTest::GLSL_TYPE_FLOAT:
1228 case VertexInputTest::GLSL_TYPE_VEC2:
1229 case VertexInputTest::GLSL_TYPE_VEC3:
1230 case VertexInputTest::GLSL_TYPE_VEC4:
1231 case VertexInputTest::GLSL_TYPE_MAT2:
1232 case VertexInputTest::GLSL_TYPE_MAT3:
1233 case VertexInputTest::GLSL_TYPE_MAT4:
1234 if (isVertexFormatSfloat(attribute.vkDescription.format))
1236 writeVertexInputValueSfloat(destPtr, attribute.vkDescription.format, componentNdx, -(0.01f * (float)(vertexInputIndex + swizzledNdx)));
1238 else if (isVertexFormatSscaled(attribute.vkDescription.format))
1240 writeVertexInputValueSint(destPtr, attribute.vkDescription.format, componentNdx, -(deInt32)(vertexInputIndex + swizzledNdx));
1242 else if (isVertexFormatUscaled(attribute.vkDescription.format) || isVertexFormatUnorm(attribute.vkDescription.format) || isVertexFormatSRGB(attribute.vkDescription.format))
1244 writeVertexInputValueUint(destPtr, attribute.vkDescription.format, componentNdx, vertexInputIndex + swizzledNdx);
1246 else if (isVertexFormatSnorm(attribute.vkDescription.format))
1248 const deInt32 minIntValue = -((1 << (getVertexFormatComponentSize(attribute.vkDescription.format) * 8 - 1))) + 1;
1249 writeVertexInputValueSint(destPtr, attribute.vkDescription.format, componentNdx, minIntValue + (vertexInputIndex + swizzledNdx));
1255 case VertexInputTest::GLSL_TYPE_DOUBLE:
1256 case VertexInputTest::GLSL_TYPE_DVEC2:
1257 case VertexInputTest::GLSL_TYPE_DVEC3:
1258 case VertexInputTest::GLSL_TYPE_DVEC4:
1259 case VertexInputTest::GLSL_TYPE_DMAT2:
1260 case VertexInputTest::GLSL_TYPE_DMAT3:
1261 case VertexInputTest::GLSL_TYPE_DMAT4:
1262 *(reinterpret_cast<double *>(destPtr) + componentNdx) = -0.01 * (vertexInputIndex + swizzledNdx);
1272 tcu::TestStatus VertexInputInstance::iterate (void)
1274 const DeviceInterface& vk = m_context.getDeviceInterface();
1275 const VkDevice vkDevice = m_context.getDevice();
1276 const VkQueue queue = m_context.getUniversalQueue();
1277 const VkSubmitInfo submitInfo =
1279 VK_STRUCTURE_TYPE_SUBMIT_INFO, // VkStructureType sType;
1280 DE_NULL, // const void* pNext;
1281 0u, // deUint32 waitSemaphoreCount;
1282 DE_NULL, // const VkSemaphore* pWaitSemaphores;
1283 1u, // deUint32 commandBufferCount;
1284 &m_cmdBuffer.get(), // const VkCommandBuffer* pCommandBuffers;
1285 0u, // deUint32 signalSemaphoreCount;
1286 DE_NULL // const VkSemaphore* pSignalSemaphores;
1289 VK_CHECK(vk.resetFences(vkDevice, 1, &m_fence.get()));
1290 VK_CHECK(vk.queueSubmit(queue, 1, &submitInfo, *m_fence));
1291 VK_CHECK(vk.waitForFences(vkDevice, 1, &m_fence.get(), true, ~(0ull) /* infinity*/));
1293 return verifyImage();
1296 bool VertexInputTest::isCompatibleType (VkFormat format, GlslType glslType)
1298 const GlslTypeDescription glslTypeDesc = s_glslTypeDescriptions[glslType];
1300 if ((deUint32)s_glslTypeDescriptions[glslType].vertexInputComponentCount == getVertexFormatComponentCount(format))
1302 switch (glslTypeDesc.basicType)
1304 case GLSL_BASIC_TYPE_INT:
1305 return isVertexFormatSint(format);
1307 case GLSL_BASIC_TYPE_UINT:
1308 return isVertexFormatUint(format);
1310 case GLSL_BASIC_TYPE_FLOAT:
1311 return getVertexFormatComponentSize(format) <= 4 && (isVertexFormatSfloat(format) || isVertexFormatSnorm(format) || isVertexFormatUnorm(format) || isVertexFormatSscaled(format) || isVertexFormatUscaled(format) || isVertexFormatSRGB(format));
1313 case GLSL_BASIC_TYPE_DOUBLE:
1314 return isVertexFormatSfloat(format) && getVertexFormatComponentSize(format) == 8;
1325 tcu::TestStatus VertexInputInstance::verifyImage (void)
1327 bool compareOk = false;
1328 const tcu::TextureFormat tcuColorFormat = mapVkFormat(m_colorFormat);
1329 tcu::TextureLevel reference (tcuColorFormat, m_renderSize.x(), m_renderSize.y());
1330 const tcu::PixelBufferAccess refRedSubregion (tcu::getSubregion(reference.getAccess(),
1331 deRoundFloatToInt32((float)m_renderSize.x() * 0.0f),
1332 deRoundFloatToInt32((float)m_renderSize.y() * 0.0f),
1333 deRoundFloatToInt32((float)m_renderSize.x() * 0.5f),
1334 deRoundFloatToInt32((float)m_renderSize.y() * 1.0f)));
1335 const tcu::PixelBufferAccess refBlueSubregion (tcu::getSubregion(reference.getAccess(),
1336 deRoundFloatToInt32((float)m_renderSize.x() * 0.5f),
1337 deRoundFloatToInt32((float)m_renderSize.y() * 0.0f),
1338 deRoundFloatToInt32((float)m_renderSize.x() * 0.5f),
1339 deRoundFloatToInt32((float)m_renderSize.y() * 1.0f)));
1341 // Create reference image
1342 tcu::clear(reference.getAccess(), defaultClearColor(tcuColorFormat));
1343 tcu::clear(refRedSubregion, tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f));
1344 tcu::clear(refBlueSubregion, tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
1346 // Compare result with reference image
1348 const DeviceInterface& vk = m_context.getDeviceInterface();
1349 const VkDevice vkDevice = m_context.getDevice();
1350 const VkQueue queue = m_context.getUniversalQueue();
1351 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1352 SimpleAllocator allocator (vk, vkDevice, getPhysicalDeviceMemoryProperties(m_context.getInstanceInterface(), m_context.getPhysicalDevice()));
1353 de::MovePtr<tcu::TextureLevel> result = readColorAttachment(vk, vkDevice, queue, queueFamilyIndex, allocator, *m_colorImage, m_colorFormat, m_renderSize);
1355 compareOk = tcu::intThresholdPositionDeviationCompare(m_context.getTestContext().getLog(),
1358 reference.getAccess(),
1359 result->getAccess(),
1360 tcu::UVec4(2, 2, 2, 2),
1361 tcu::IVec3(1, 1, 0),
1363 tcu::COMPARE_LOG_RESULT);
1367 return tcu::TestStatus::pass("Result image matches reference");
1369 return tcu::TestStatus::fail("Image mismatch");
1372 std::string getAttributeInfoCaseName (const VertexInputTest::AttributeInfo& attributeInfo)
1374 std::ostringstream caseName;
1375 const std::string formatName = getFormatName(attributeInfo.vkType);
1377 caseName << VertexInputTest::s_glslTypeDescriptions[attributeInfo.glslType].name << "_as_" << de::toLower(formatName.substr(10)) << "_rate_";
1379 if (attributeInfo.inputRate == VK_VERTEX_INPUT_RATE_VERTEX)
1380 caseName << "vertex";
1382 caseName << "instance";
1384 return caseName.str();
1387 std::string getAttributeInfosCaseName (const std::vector<VertexInputTest::AttributeInfo>& attributeInfos)
1389 std::ostringstream caseName;
1391 for (size_t attributeNdx = 0; attributeNdx < attributeInfos.size(); attributeNdx++)
1393 caseName << getAttributeInfoCaseName(attributeInfos[attributeNdx]);
1395 if (attributeNdx < attributeInfos.size() - 1)
1399 return caseName.str();
1402 std::string getAttributeInfoDescription (const VertexInputTest::AttributeInfo& attributeInfo)
1404 std::ostringstream caseDesc;
1406 caseDesc << std::string(VertexInputTest::s_glslTypeDescriptions[attributeInfo.glslType].name) << " from type " << getFormatName(attributeInfo.vkType) << " with ";
1408 if (attributeInfo.inputRate == VK_VERTEX_INPUT_RATE_VERTEX)
1409 caseDesc << "vertex input rate ";
1411 caseDesc << "instance input rate ";
1413 return caseDesc.str();
1416 std::string getAttributeInfosDescription (const std::vector<VertexInputTest::AttributeInfo>& attributeInfos)
1418 std::ostringstream caseDesc;
1420 caseDesc << "Uses vertex attributes:\n";
1422 for (size_t attributeNdx = 0; attributeNdx < attributeInfos.size(); attributeNdx++)
1423 caseDesc << "\t- " << getAttributeInfoDescription (attributeInfos[attributeNdx]) << "\n";
1425 return caseDesc.str();
1428 struct CompatibleFormats
1430 VertexInputTest::GlslType glslType;
1431 std::vector<VkFormat> compatibleVkFormats;
1434 de::MovePtr<tcu::TestCaseGroup> createSingleAttributeTests (tcu::TestContext& testCtx)
1436 const VkFormat vertexFormats[] =
1438 // Required, unpacked
1443 VK_FORMAT_R8G8_UNORM,
1444 VK_FORMAT_R8G8_SNORM,
1445 VK_FORMAT_R8G8_UINT,
1446 VK_FORMAT_R8G8_SINT,
1447 VK_FORMAT_R8G8B8A8_UNORM,
1448 VK_FORMAT_R8G8B8A8_SNORM,
1449 VK_FORMAT_R8G8B8A8_UINT,
1450 VK_FORMAT_R8G8B8A8_SINT,
1451 VK_FORMAT_B8G8R8A8_UNORM,
1452 VK_FORMAT_R16_UNORM,
1453 VK_FORMAT_R16_SNORM,
1456 VK_FORMAT_R16_SFLOAT,
1457 VK_FORMAT_R16G16_UNORM,
1458 VK_FORMAT_R16G16_SNORM,
1459 VK_FORMAT_R16G16_UINT,
1460 VK_FORMAT_R16G16_SINT,
1461 VK_FORMAT_R16G16_SFLOAT,
1462 VK_FORMAT_R16G16B16A16_UNORM,
1463 VK_FORMAT_R16G16B16A16_SNORM,
1464 VK_FORMAT_R16G16B16A16_UINT,
1465 VK_FORMAT_R16G16B16A16_SINT,
1466 VK_FORMAT_R16G16B16A16_SFLOAT,
1469 VK_FORMAT_R32_SFLOAT,
1470 VK_FORMAT_R32G32_UINT,
1471 VK_FORMAT_R32G32_SINT,
1472 VK_FORMAT_R32G32_SFLOAT,
1473 VK_FORMAT_R32G32B32_UINT,
1474 VK_FORMAT_R32G32B32_SINT,
1475 VK_FORMAT_R32G32B32_SFLOAT,
1476 VK_FORMAT_R32G32B32A32_UINT,
1477 VK_FORMAT_R32G32B32A32_SINT,
1478 VK_FORMAT_R32G32B32A32_SFLOAT,
1481 VK_FORMAT_R8G8_USCALED,
1482 VK_FORMAT_R8G8_SSCALED,
1483 VK_FORMAT_R16_USCALED,
1484 VK_FORMAT_R16_SSCALED,
1485 VK_FORMAT_R8G8B8_USCALED,
1486 VK_FORMAT_R8G8B8_SSCALED,
1487 VK_FORMAT_B8G8R8_USCALED,
1488 VK_FORMAT_B8G8R8_SSCALED,
1489 VK_FORMAT_R8G8B8A8_USCALED,
1490 VK_FORMAT_R8G8B8A8_SSCALED,
1491 VK_FORMAT_B8G8R8A8_USCALED,
1492 VK_FORMAT_B8G8R8A8_SSCALED,
1493 VK_FORMAT_R16G16_USCALED,
1494 VK_FORMAT_R16G16_SSCALED,
1495 VK_FORMAT_R16G16B16_USCALED,
1496 VK_FORMAT_R16G16B16_SSCALED,
1497 VK_FORMAT_R16G16B16A16_USCALED,
1498 VK_FORMAT_R16G16B16A16_SSCALED,
1502 VK_FORMAT_R8G8_SRGB,
1503 VK_FORMAT_R8G8B8_SRGB,
1504 VK_FORMAT_B8G8R8_SRGB,
1505 VK_FORMAT_R8G8B8A8_SRGB,
1506 VK_FORMAT_B8G8R8A8_SRGB,
1509 VK_FORMAT_R64_SFLOAT,
1510 VK_FORMAT_R64G64_SFLOAT,
1511 VK_FORMAT_R64G64B64_SFLOAT,
1512 VK_FORMAT_R64G64B64A64_SFLOAT,
1515 de::MovePtr<tcu::TestCaseGroup> singleAttributeTests (new tcu::TestCaseGroup(testCtx, "single_attribute", "Uses one attribute"));
1517 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(vertexFormats); formatNdx++)
1519 for (int glslTypeNdx = 0; glslTypeNdx < VertexInputTest::GLSL_TYPE_COUNT; glslTypeNdx++)
1521 if (VertexInputTest::isCompatibleType(vertexFormats[formatNdx], (VertexInputTest::GlslType)glslTypeNdx))
1523 // Create test case for RATE_VERTEX
1524 VertexInputTest::AttributeInfo attributeInfo;
1525 attributeInfo.vkType = vertexFormats[formatNdx];
1526 attributeInfo.glslType = (VertexInputTest::GlslType)glslTypeNdx;
1527 attributeInfo.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
1529 singleAttributeTests->addChild(new VertexInputTest(testCtx,
1530 getAttributeInfoCaseName(attributeInfo),
1531 getAttributeInfoDescription(attributeInfo),
1532 std::vector<VertexInputTest::AttributeInfo>(1, attributeInfo),
1533 VertexInputTest::BINDING_MAPPING_ONE_TO_ONE));
1535 // Create test case for RATE_INSTANCE
1536 attributeInfo.inputRate = VK_VERTEX_INPUT_RATE_INSTANCE;
1538 singleAttributeTests->addChild(new VertexInputTest(testCtx,
1539 getAttributeInfoCaseName(attributeInfo),
1540 getAttributeInfoDescription(attributeInfo),
1541 std::vector<VertexInputTest::AttributeInfo>(1, attributeInfo),
1542 VertexInputTest::BINDING_MAPPING_ONE_TO_ONE));
1547 return singleAttributeTests;
1550 de::MovePtr<tcu::TestCaseGroup> createMultipleAttributeTests (tcu::TestContext& testCtx)
1552 // Required vertex formats, unpacked
1553 const VkFormat vertexFormats[] =
1559 VK_FORMAT_R8G8_UNORM,
1560 VK_FORMAT_R8G8_SNORM,
1561 VK_FORMAT_R8G8_UINT,
1562 VK_FORMAT_R8G8_SINT,
1563 VK_FORMAT_R8G8B8A8_UNORM,
1564 VK_FORMAT_R8G8B8A8_SNORM,
1565 VK_FORMAT_R8G8B8A8_UINT,
1566 VK_FORMAT_R8G8B8A8_SINT,
1567 VK_FORMAT_B8G8R8A8_UNORM,
1568 VK_FORMAT_R16_UNORM,
1569 VK_FORMAT_R16_SNORM,
1572 VK_FORMAT_R16_SFLOAT,
1573 VK_FORMAT_R16G16_UNORM,
1574 VK_FORMAT_R16G16_SNORM,
1575 VK_FORMAT_R16G16_UINT,
1576 VK_FORMAT_R16G16_SINT,
1577 VK_FORMAT_R16G16_SFLOAT,
1578 VK_FORMAT_R16G16B16A16_UNORM,
1579 VK_FORMAT_R16G16B16A16_SNORM,
1580 VK_FORMAT_R16G16B16A16_UINT,
1581 VK_FORMAT_R16G16B16A16_SINT,
1582 VK_FORMAT_R16G16B16A16_SFLOAT,
1585 VK_FORMAT_R32_SFLOAT,
1586 VK_FORMAT_R32G32_UINT,
1587 VK_FORMAT_R32G32_SINT,
1588 VK_FORMAT_R32G32_SFLOAT,
1589 VK_FORMAT_R32G32B32_UINT,
1590 VK_FORMAT_R32G32B32_SINT,
1591 VK_FORMAT_R32G32B32_SFLOAT,
1592 VK_FORMAT_R32G32B32A32_UINT,
1593 VK_FORMAT_R32G32B32A32_SINT,
1594 VK_FORMAT_R32G32B32A32_SFLOAT
1597 de::MovePtr<tcu::TestCaseGroup> multipleAttributeTests (new tcu::TestCaseGroup(testCtx, "multiple_attributes", "Uses more than one attribute"));
1599 // Find compatible VK formats for each GLSL vertex type
1600 CompatibleFormats compatibleFormats[VertexInputTest::GLSL_TYPE_COUNT];
1602 for (int glslTypeNdx = 0; glslTypeNdx < VertexInputTest::GLSL_TYPE_COUNT; glslTypeNdx++)
1604 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(vertexFormats); formatNdx++)
1606 if (VertexInputTest::isCompatibleType(vertexFormats[formatNdx], (VertexInputTest::GlslType)glslTypeNdx))
1607 compatibleFormats[glslTypeNdx].compatibleVkFormats.push_back(vertexFormats[formatNdx]);
1612 de::Random randomFunc (102030);
1613 GlslTypeCombinationsIterator glslTypeCombinationsItr (VertexInputTest::GLSL_TYPE_DOUBLE, 3); // Exclude double values, which are not included in vertexFormats
1614 de::MovePtr<tcu::TestCaseGroup> oneToOneAttributeTests (new tcu::TestCaseGroup(testCtx, "attributes", ""));
1615 de::MovePtr<tcu::TestCaseGroup> oneToManyAttributeTests (new tcu::TestCaseGroup(testCtx, "attributes", ""));
1617 while (glslTypeCombinationsItr.hasNext())
1619 const std::vector<VertexInputTest::GlslType> glslTypes = glslTypeCombinationsItr.next();
1620 std::vector<VertexInputTest::AttributeInfo> attributeInfos (glslTypes.size());
1622 for (size_t attributeNdx = 0; attributeNdx < attributeInfos.size(); attributeNdx++)
1624 DE_ASSERT(!compatibleFormats[glslTypes[attributeNdx]].compatibleVkFormats.empty());
1626 // Select a random compatible format
1627 const std::vector<VkFormat>& formats = compatibleFormats[glslTypes[attributeNdx]].compatibleVkFormats;
1628 const VkFormat format = formats[randomFunc.getUint32() % formats.size()];
1630 attributeInfos[attributeNdx].glslType = glslTypes[attributeNdx];
1631 attributeInfos[attributeNdx].inputRate = (attributeNdx % 2 == 0) ? VK_VERTEX_INPUT_RATE_VERTEX : VK_VERTEX_INPUT_RATE_INSTANCE;
1632 attributeInfos[attributeNdx].vkType = format;
1635 const std::string caseName = getAttributeInfosCaseName(attributeInfos);
1636 const std::string caseDesc = getAttributeInfosDescription(attributeInfos);
1638 oneToOneAttributeTests->addChild(new VertexInputTest(testCtx, caseName, caseDesc, attributeInfos, VertexInputTest::BINDING_MAPPING_ONE_TO_ONE));
1639 oneToManyAttributeTests->addChild(new VertexInputTest(testCtx, caseName, caseDesc, attributeInfos, VertexInputTest::BINDING_MAPPING_ONE_TO_MANY));
1642 de::MovePtr<tcu::TestCaseGroup> bindingOneToOneTests (new tcu::TestCaseGroup(testCtx, "binding_one_to_one", "Each attribute uses a unique binding"));
1643 bindingOneToOneTests->addChild(oneToOneAttributeTests.release());
1644 multipleAttributeTests->addChild(bindingOneToOneTests.release());
1646 de::MovePtr<tcu::TestCaseGroup> bindingOneToManyTests (new tcu::TestCaseGroup(testCtx, "binding_one_to_many", "Attributes share the same binding"));
1647 bindingOneToManyTests->addChild(oneToManyAttributeTests.release());
1648 multipleAttributeTests->addChild(bindingOneToManyTests.release());
1650 return multipleAttributeTests;
1655 tcu::TestCaseGroup* createVertexInputTests (tcu::TestContext& testCtx)
1657 de::MovePtr<tcu::TestCaseGroup> vertexInputTests (new tcu::TestCaseGroup(testCtx, "vertex_input", ""));
1659 vertexInputTests->addChild(createSingleAttributeTests(testCtx).release());
1660 vertexInputTests->addChild(createMultipleAttributeTests(testCtx).release());
1662 return vertexInputTests.release();