1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2015 The Khronos Group Inc.
6 * Copyright (c) 2015 ARM Ltd.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 * \brief Timestamp Tests
23 *//*--------------------------------------------------------------------*/
25 #include "vktPipelineTimestampTests.hpp"
26 #include "vktPipelineClearUtil.hpp"
27 #include "vktPipelineImageUtil.hpp"
28 #include "vktPipelineVertexUtil.hpp"
29 #include "vktPipelineReferenceRenderer.hpp"
30 #include "vktTestCase.hpp"
31 #include "vktTestCaseUtil.hpp"
32 #include "vkImageUtil.hpp"
33 #include "vkMemUtil.hpp"
34 #include "vkPrograms.hpp"
35 #include "vkBuilderUtil.hpp"
36 #include "vkQueryUtil.hpp"
38 #include "vkRefUtil.hpp"
39 #include "tcuImageCompare.hpp"
40 #include "deUniquePtr.hpp"
41 #include "deStringUtil.hpp"
43 #include "vkTypeUtil.hpp"
59 typedef std::vector<VkPipelineStageFlagBits> StageFlagVector;
62 #define GEN_DESC_STRING(name,postfix) \
64 for (std::string::size_type ndx = 0; ndx<strlen(#name); ++ndx) \
65 if(isDescription && #name[ndx] == '_') \
68 desc << std::tolower(#name[ndx],loc); \
70 desc << " " << #postfix; \
72 desc << "_" << #postfix; \
73 } while (deGetFalse())
75 std::string getPipelineStageFlagStr (const VkPipelineStageFlagBits stage,
78 std::ostringstream desc;
82 #define STAGE_CASE(p) \
83 case VK_PIPELINE_STAGE_##p##_BIT: \
85 GEN_DESC_STRING(p, stage); \
88 STAGE_CASE(TOP_OF_PIPE);
89 STAGE_CASE(DRAW_INDIRECT);
90 STAGE_CASE(VERTEX_INPUT);
91 STAGE_CASE(VERTEX_SHADER);
92 STAGE_CASE(TESSELLATION_CONTROL_SHADER);
93 STAGE_CASE(TESSELLATION_EVALUATION_SHADER);
94 STAGE_CASE(GEOMETRY_SHADER);
95 STAGE_CASE(FRAGMENT_SHADER);
96 STAGE_CASE(EARLY_FRAGMENT_TESTS);
97 STAGE_CASE(LATE_FRAGMENT_TESTS);
98 STAGE_CASE(COLOR_ATTACHMENT_OUTPUT);
99 STAGE_CASE(COMPUTE_SHADER);
100 STAGE_CASE(TRANSFER);
102 STAGE_CASE(ALL_GRAPHICS);
103 STAGE_CASE(ALL_COMMANDS);
106 desc << "unknown stage!";
107 DE_FATAL("Unknown Stage!");
116 TRANSFER_METHOD_COPY_BUFFER = 0,
117 TRANSFER_METHOD_COPY_IMAGE,
118 TRANSFER_METHOD_BLIT_IMAGE,
119 TRANSFER_METHOD_COPY_BUFFER_TO_IMAGE,
120 TRANSFER_METHOD_COPY_IMAGE_TO_BUFFER,
121 TRANSFER_METHOD_UPDATE_BUFFER,
122 TRANSFER_METHOD_FILL_BUFFER,
123 TRANSFER_METHOD_CLEAR_COLOR_IMAGE,
124 TRANSFER_METHOD_CLEAR_DEPTH_STENCIL_IMAGE,
125 TRANSFER_METHOD_RESOLVE_IMAGE,
126 TRANSFER_METHOD_COPY_QUERY_POOL_RESULTS,
130 std::string getTransferMethodStr(const TransferMethod method,
133 std::ostringstream desc;
137 #define METHOD_CASE(p) \
138 case TRANSFER_METHOD_##p: \
140 GEN_DESC_STRING(p, method); \
143 METHOD_CASE(COPY_BUFFER)
144 METHOD_CASE(COPY_IMAGE)
145 METHOD_CASE(BLIT_IMAGE)
146 METHOD_CASE(COPY_BUFFER_TO_IMAGE)
147 METHOD_CASE(COPY_IMAGE_TO_BUFFER)
148 METHOD_CASE(UPDATE_BUFFER)
149 METHOD_CASE(FILL_BUFFER)
150 METHOD_CASE(CLEAR_COLOR_IMAGE)
151 METHOD_CASE(CLEAR_DEPTH_STENCIL_IMAGE)
152 METHOD_CASE(RESOLVE_IMAGE)
153 METHOD_CASE(COPY_QUERY_POOL_RESULTS)
156 desc << "unknown method!";
157 DE_FATAL("Unknown method!");
165 class TimestampTestParam
168 TimestampTestParam (const VkPipelineStageFlagBits* stages,
169 const deUint32 stageCount,
170 const bool inRenderPass);
171 ~TimestampTestParam (void);
172 virtual const std::string generateTestName (void) const;
173 virtual const std::string generateTestDescription (void) const;
174 StageFlagVector getStageVector (void) const { return m_stageVec; }
175 bool getInRenderPass (void) const { return m_inRenderPass; }
176 void toggleInRenderPass (void) { m_inRenderPass = !m_inRenderPass; }
178 StageFlagVector m_stageVec;
182 TimestampTestParam::TimestampTestParam(const VkPipelineStageFlagBits* stages,
183 const deUint32 stageCount,
184 const bool inRenderPass)
185 : m_inRenderPass(inRenderPass)
187 for (deUint32 ndx = 0; ndx < stageCount; ndx++)
189 m_stageVec.push_back(stages[ndx]);
193 TimestampTestParam::~TimestampTestParam(void)
197 const std::string TimestampTestParam::generateTestName(void) const
199 std::string result("");
201 for (StageFlagVector::const_iterator it = m_stageVec.begin(); it != m_stageVec.end(); it++)
203 if(*it != VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT)
205 result += getPipelineStageFlagStr(*it, false) + '_';
209 result += "in_render_pass";
211 result += "out_of_render_pass";
216 const std::string TimestampTestParam::generateTestDescription(void) const
218 std::string result("Record timestamp after ");
220 for (StageFlagVector::const_iterator it = m_stageVec.begin(); it != m_stageVec.end(); it++)
222 if(*it != VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT)
224 result += getPipelineStageFlagStr(*it, true) + ' ';
228 result += " in the renderpass";
230 result += " out of the render pass";
235 class TransferTimestampTestParam : public TimestampTestParam
238 TransferTimestampTestParam (const VkPipelineStageFlagBits* stages,
239 const deUint32 stageCount,
240 const bool inRenderPass,
241 const deUint32 methodNdx);
242 ~TransferTimestampTestParam (void) { }
243 const std::string generateTestName (void) const;
244 const std::string generateTestDescription (void) const;
245 TransferMethod getMethod (void) const { return m_method; }
247 TransferMethod m_method;
250 TransferTimestampTestParam::TransferTimestampTestParam(const VkPipelineStageFlagBits* stages,
251 const deUint32 stageCount,
252 const bool inRenderPass,
253 const deUint32 methodNdx)
254 : TimestampTestParam(stages, stageCount, inRenderPass)
256 DE_ASSERT(methodNdx < (deUint32)TRANSFER_METHOD_LAST);
258 m_method = (TransferMethod)methodNdx;
261 const std::string TransferTimestampTestParam::generateTestName(void) const
263 std::string result("");
265 for (StageFlagVector::const_iterator it = m_stageVec.begin(); it != m_stageVec.end(); it++)
267 if(*it != VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT)
269 result += getPipelineStageFlagStr(*it, false) + '_';
273 result += "with_" + getTransferMethodStr(m_method, false);
279 const std::string TransferTimestampTestParam::generateTestDescription(void) const
281 std::string result("");
283 for (StageFlagVector::const_iterator it = m_stageVec.begin(); it != m_stageVec.end(); it++)
285 if(*it != VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT)
287 result += getPipelineStageFlagStr(*it, true) + ' ';
291 result += "with " + getTransferMethodStr(m_method, true);
297 class SimpleGraphicsPipelineBuilder
300 SimpleGraphicsPipelineBuilder (Context& context);
301 ~SimpleGraphicsPipelineBuilder (void) { }
302 void bindShaderStage (VkShaderStageFlagBits stage,
303 const char* source_name,
304 const char* entry_name);
305 void enableTessellationStage (deUint32 patchControlPoints);
306 Move<VkPipeline> buildPipeline (tcu::UVec2 renderSize,
307 VkRenderPass renderPass);
311 VK_MAX_SHADER_STAGES = 6,
316 Move<VkShaderModule> m_shaderModules[VK_MAX_SHADER_STAGES];
317 deUint32 m_shaderStageCount;
318 VkPipelineShaderStageCreateInfo m_shaderStageInfo[VK_MAX_SHADER_STAGES];
320 deUint32 m_patchControlPoints;
322 Move<VkPipelineLayout> m_pipelineLayout;
323 Move<VkPipeline> m_graphicsPipelines;
327 SimpleGraphicsPipelineBuilder::SimpleGraphicsPipelineBuilder(Context& context)
330 m_patchControlPoints = 0;
331 m_shaderStageCount = 0;
334 void SimpleGraphicsPipelineBuilder::bindShaderStage(VkShaderStageFlagBits stage,
335 const char* source_name,
336 const char* entry_name)
338 const DeviceInterface& vk = m_context.getDeviceInterface();
339 const VkDevice vkDevice = m_context.getDevice();
341 // Create shader module
342 deUint32* pCode = (deUint32*)m_context.getBinaryCollection().get(source_name).getBinary();
343 deUint32 codeSize = (deUint32)m_context.getBinaryCollection().get(source_name).getSize();
345 const VkShaderModuleCreateInfo moduleCreateInfo =
347 VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, // VkStructureType sType;
348 DE_NULL, // const void* pNext;
349 0u, // VkShaderModuleCreateFlags flags;
350 codeSize, // deUintptr codeSize;
351 pCode, // const deUint32* pCode;
354 m_shaderModules[m_shaderStageCount] = createShaderModule(vk, vkDevice, &moduleCreateInfo);
356 // Prepare shader stage info
357 m_shaderStageInfo[m_shaderStageCount].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
358 m_shaderStageInfo[m_shaderStageCount].pNext = DE_NULL;
359 m_shaderStageInfo[m_shaderStageCount].flags = 0u;
360 m_shaderStageInfo[m_shaderStageCount].stage = stage;
361 m_shaderStageInfo[m_shaderStageCount].module = *m_shaderModules[m_shaderStageCount];
362 m_shaderStageInfo[m_shaderStageCount].pName = entry_name;
363 m_shaderStageInfo[m_shaderStageCount].pSpecializationInfo = DE_NULL;
365 m_shaderStageCount++;
368 Move<VkPipeline> SimpleGraphicsPipelineBuilder::buildPipeline(tcu::UVec2 renderSize, VkRenderPass renderPass)
370 const DeviceInterface& vk = m_context.getDeviceInterface();
371 const VkDevice vkDevice = m_context.getDevice();
373 // Create pipeline layout
375 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
377 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // VkStructureType sType;
378 DE_NULL, // const void* pNext;
379 0u, // VkPipelineLayoutCreateFlags flags;
380 0u, // deUint32 setLayoutCount;
381 DE_NULL, // const VkDescriptorSetLayout* pSetLayouts;
382 0u, // deUint32 pushConstantRangeCount;
383 DE_NULL // const VkPushConstantRange* pPushConstantRanges;
386 m_pipelineLayout = createPipelineLayout(vk, vkDevice, &pipelineLayoutParams);
390 const VkVertexInputBindingDescription vertexInputBindingDescription =
392 0u, // deUint32 binding;
393 sizeof(Vertex4RGBA), // deUint32 strideInBytes;
394 VK_VERTEX_INPUT_RATE_VERTEX, // VkVertexInputRate inputRate;
397 const VkVertexInputAttributeDescription vertexInputAttributeDescriptions[2] =
400 0u, // deUint32 location;
401 0u, // deUint32 binding;
402 VK_FORMAT_R32G32B32A32_SFLOAT, // VkFormat format;
403 0u // deUint32 offsetInBytes;
406 1u, // deUint32 location;
407 0u, // deUint32 binding;
408 VK_FORMAT_R32G32B32A32_SFLOAT, // VkFormat format;
409 DE_OFFSET_OF(Vertex4RGBA, color), // deUint32 offsetInBytes;
413 const VkPipelineVertexInputStateCreateInfo vertexInputStateParams =
415 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // VkStructureType sType;
416 DE_NULL, // const void* pNext;
417 0u, // VkPipelineVertexInputStateCreateFlags flags;
418 1u, // deUint32 vertexBindingDescriptionCount;
419 &vertexInputBindingDescription, // const VkVertexInputBindingDescription* pVertexBindingDescriptions;
420 2u, // deUint32 vertexAttributeDescriptionCount;
421 vertexInputAttributeDescriptions, // const VkVertexInputAttributeDescription* pVertexAttributeDescriptions;
424 VkPrimitiveTopology primitiveTopology = (m_patchControlPoints > 0) ? VK_PRIMITIVE_TOPOLOGY_PATCH_LIST : VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
425 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateParams =
427 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // VkStructureType sType;
428 DE_NULL, // const void* pNext;
429 0u, // VkPipelineInputAssemblyStateCreateFlags flags;
430 primitiveTopology, // VkPrimitiveTopology topology;
431 VK_FALSE, // VkBool32 primitiveRestartEnable;
434 const VkViewport viewport =
436 0.0f, // float originX;
437 0.0f, // float originY;
438 (float)renderSize.x(), // float width;
439 (float)renderSize.y(), // float height;
440 0.0f, // float minDepth;
441 1.0f // float maxDepth;
443 const VkRect2D scissor =
445 { 0u, 0u }, // VkOffset2D offset;
446 { renderSize.x(), renderSize.y() } // VkExtent2D extent;
448 const VkPipelineViewportStateCreateInfo viewportStateParams =
450 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // VkStructureType sType;
451 DE_NULL, // const void* pNext;
452 0u, // VkPipelineViewportStateCreateFlags flags;
453 1u, // deUint32 viewportCount;
454 &viewport, // const VkViewport* pViewports;
455 1u, // deUint32 scissorCount;
456 &scissor // const VkRect2D* pScissors;
459 const VkPipelineRasterizationStateCreateInfo rasterStateParams =
461 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // VkStructureType sType;
462 DE_NULL, // const void* pNext;
463 0u, // VkPipelineRasterizationStateCreateFlags flags;
464 VK_FALSE, // VkBool32 depthClampEnable;
465 VK_FALSE, // VkBool32 rasterizerDiscardEnable;
466 VK_POLYGON_MODE_FILL, // VkPolygonMode polygonMode;
467 VK_CULL_MODE_NONE, // VkCullModeFlags cullMode;
468 VK_FRONT_FACE_COUNTER_CLOCKWISE, // VkFrontFace frontFace;
469 VK_FALSE, // VkBool32 depthBiasEnable;
470 0.0f, // float depthBiasConstantFactor;
471 0.0f, // float depthBiasClamp;
472 0.0f, // float depthBiasSlopeFactor;
473 1.0f, // float lineWidth;
476 const VkPipelineColorBlendAttachmentState colorBlendAttachmentState =
478 VK_FALSE, // VkBool32 blendEnable;
479 VK_BLEND_FACTOR_ONE, // VkBlendFactor srcColorBlendFactor;
480 VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstColorBlendFactor;
481 VK_BLEND_OP_ADD, // VkBlendOp colorBlendOp;
482 VK_BLEND_FACTOR_ONE, // VkBlendFactor srcAlphaBlendFactor;
483 VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstAlphaBlendFactor;
484 VK_BLEND_OP_ADD, // VkBlendOp alphaBlendOp;
485 VK_COLOR_COMPONENT_R_BIT |
486 VK_COLOR_COMPONENT_G_BIT |
487 VK_COLOR_COMPONENT_B_BIT |
488 VK_COLOR_COMPONENT_A_BIT // VkColorComponentFlags colorWriteMask;
491 const VkPipelineColorBlendStateCreateInfo colorBlendStateParams =
493 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // VkStructureType sType;
494 DE_NULL, // const void* pNext;
495 0u, // VkPipelineColorBlendStateCreateFlags flags;
496 VK_FALSE, // VkBool32 logicOpEnable;
497 VK_LOGIC_OP_COPY, // VkLogicOp logicOp;
498 1u, // deUint32 attachmentCount;
499 &colorBlendAttachmentState, // const VkPipelineColorBlendAttachmentState* pAttachments;
500 { 0.0f, 0.0f, 0.0f, 0.0f }, // float blendConst[4];
503 const VkPipelineMultisampleStateCreateInfo multisampleStateParams =
505 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // VkStructureType sType;
506 DE_NULL, // const void* pNext;
507 0u, // VkPipelineMultisampleStateCreateFlags flags;
508 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits rasterizationSamples;
509 VK_FALSE, // VkBool32 sampleShadingEnable;
510 0.0f, // float minSampleShading;
511 DE_NULL, // const VkSampleMask* pSampleMask;
512 VK_FALSE, // VkBool32 alphaToCoverageEnable;
513 VK_FALSE, // VkBool32 alphaToOneEnable;
516 VkPipelineDepthStencilStateCreateInfo depthStencilStateParams =
518 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // VkStructureType sType;
519 DE_NULL, // const void* pNext;
520 0u, // VkPipelineDepthStencilStateCreateFlags flags;
521 VK_TRUE, // VkBool32 depthTestEnable;
522 VK_TRUE, // VkBool32 depthWriteEnable;
523 VK_COMPARE_OP_LESS_OR_EQUAL, // VkCompareOp depthCompareOp;
524 VK_FALSE, // VkBool32 depthBoundsTestEnable;
525 VK_FALSE, // VkBool32 stencilTestEnable;
526 // VkStencilOpState front;
528 VK_STENCIL_OP_KEEP, // VkStencilOp failOp;
529 VK_STENCIL_OP_KEEP, // VkStencilOp passOp;
530 VK_STENCIL_OP_KEEP, // VkStencilOp depthFailOp;
531 VK_COMPARE_OP_NEVER, // VkCompareOp compareOp;
532 0u, // deUint32 compareMask;
533 0u, // deUint32 writeMask;
534 0u, // deUint32 reference;
536 // VkStencilOpState back;
538 VK_STENCIL_OP_KEEP, // VkStencilOp failOp;
539 VK_STENCIL_OP_KEEP, // VkStencilOp passOp;
540 VK_STENCIL_OP_KEEP, // VkStencilOp depthFailOp;
541 VK_COMPARE_OP_NEVER, // VkCompareOp compareOp;
542 0u, // deUint32 compareMask;
543 0u, // deUint32 writeMask;
544 0u, // deUint32 reference;
546 0.0f, // float minDepthBounds;
547 1.0f, // float maxDepthBounds;
550 const VkPipelineTessellationStateCreateInfo* pTessCreateInfo = DE_NULL;
551 const VkPipelineTessellationStateCreateInfo tessStateCreateInfo =
553 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, // VkStructureType sType;
554 DE_NULL, // const void* pNext;
555 0u, // VkPipelineTessellationStateCreateFlags flags;
556 m_patchControlPoints, // deUint32 patchControlPoints;
559 if (m_patchControlPoints > 0)
560 pTessCreateInfo = &tessStateCreateInfo;
562 const VkGraphicsPipelineCreateInfo graphicsPipelineParams =
564 VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // VkStructureType sType;
565 DE_NULL, // const void* pNext;
566 0u, // VkPipelineCreateFlags flags;
567 m_shaderStageCount, // deUint32 stageCount;
568 m_shaderStageInfo, // const VkPipelineShaderStageCreateInfo* pStages;
569 &vertexInputStateParams, // const VkPipelineVertexInputStateCreateInfo* pVertexInputState;
570 &inputAssemblyStateParams, // const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState;
571 pTessCreateInfo, // const VkPipelineTessellationStateCreateInfo* pTessellationState;
572 &viewportStateParams, // const VkPipelineViewportStateCreateInfo* pViewportState;
573 &rasterStateParams, // const VkPipelineRasterizationStateCreateInfo* pRasterState;
574 &multisampleStateParams, // const VkPipelineMultisampleStateCreateInfo* pMultisampleState;
575 &depthStencilStateParams, // const VkPipelineDepthStencilStateCreateInfo* pDepthStencilState;
576 &colorBlendStateParams, // const VkPipelineColorBlendStateCreateInfo* pColorBlendState;
577 (const VkPipelineDynamicStateCreateInfo*)DE_NULL, // const VkPipelineDynamicStateCreateInfo* pDynamicState;
578 *m_pipelineLayout, // VkPipelineLayout layout;
579 renderPass, // VkRenderPass renderPass;
580 0u, // deUint32 subpass;
581 0u, // VkPipeline basePipelineHandle;
582 0, // deInt32 basePipelineIndex;
585 return createGraphicsPipeline(vk, vkDevice, DE_NULL, &graphicsPipelineParams);
588 void SimpleGraphicsPipelineBuilder::enableTessellationStage(deUint32 patchControlPoints)
590 m_patchControlPoints = patchControlPoints;
593 template <class Test>
594 vkt::TestCase* newTestCase(tcu::TestContext& testContext,
595 TimestampTestParam* testParam)
597 return new Test(testContext,
598 testParam->generateTestName().c_str(),
599 testParam->generateTestDescription().c_str(),
604 class TimestampTest : public vkt::TestCase
612 TimestampTest(tcu::TestContext& testContext,
613 const std::string& name,
614 const std::string& description,
615 const TimestampTestParam* param)
616 : vkt::TestCase (testContext, name, description)
617 , m_stages (param->getStageVector())
618 , m_inRenderPass (param->getInRenderPass())
620 virtual ~TimestampTest (void) { }
621 virtual void initPrograms (SourceCollections& programCollection) const;
622 virtual TestInstance* createInstance (Context& context) const;
624 const StageFlagVector m_stages;
625 const bool m_inRenderPass;
628 class TimestampTestInstance : public vkt::TestInstance
631 TimestampTestInstance (Context& context,
632 const StageFlagVector& stages,
633 const bool inRenderPass);
634 virtual ~TimestampTestInstance (void);
635 virtual tcu::TestStatus iterate (void);
637 virtual tcu::TestStatus verifyTimestamp (void);
638 virtual void configCommandBuffer (void);
639 Move<VkBuffer> createBufferAndBindMemory (VkDeviceSize size,
640 VkBufferUsageFlags usage,
641 de::MovePtr<Allocation>* pAlloc);
642 Move<VkImage> createImage2DAndBindMemory (VkFormat format,
645 VkImageUsageFlags usage,
646 VkSampleCountFlagBits sampleCount,
647 de::MovePtr<Allocation>* pAlloc);
649 const StageFlagVector m_stages;
652 Move<VkCommandPool> m_cmdPool;
653 Move<VkCommandBuffer> m_cmdBuffer;
654 Move<VkFence> m_fence;
655 Move<VkQueryPool> m_queryPool;
656 deUint64* m_timestampValues;
659 void TimestampTest::initPrograms(SourceCollections& programCollection) const
661 vkt::TestCase::initPrograms(programCollection);
664 TestInstance* TimestampTest::createInstance(Context& context) const
666 return new TimestampTestInstance(context,m_stages,m_inRenderPass);
669 TimestampTestInstance::TimestampTestInstance(Context& context,
670 const StageFlagVector& stages,
671 const bool inRenderPass)
672 : TestInstance (context)
674 , m_inRenderPass(inRenderPass)
676 const DeviceInterface& vk = context.getDeviceInterface();
677 const VkDevice vkDevice = context.getDevice();
678 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
680 // Check support for timestamp queries
682 const std::vector<VkQueueFamilyProperties> queueProperties = vk::getPhysicalDeviceQueueFamilyProperties(m_context.getInstanceInterface(), m_context.getPhysicalDevice());
684 DE_ASSERT(queueFamilyIndex < (deUint32)queueProperties.size());
686 if (!queueProperties[queueFamilyIndex].timestampValidBits)
687 throw tcu::NotSupportedError("Universal queue does not support timestamps");
692 const VkQueryPoolCreateInfo queryPoolParams =
694 VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO, // VkStructureType sType;
695 DE_NULL, // const void* pNext;
696 0u, // VkQueryPoolCreateFlags flags;
697 VK_QUERY_TYPE_TIMESTAMP, // VkQueryType queryType;
698 TimestampTest::ENTRY_COUNT, // deUint32 entryCount;
699 0u, // VkQueryPipelineStatisticFlags pipelineStatistics;
702 m_queryPool = createQueryPool(vk, vkDevice, &queryPoolParams);
705 // Create command pool
706 m_cmdPool = createCommandPool(vk, vkDevice, VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, queueFamilyIndex);
708 // Create command buffer
709 m_cmdBuffer = allocateCommandBuffer(vk, vkDevice, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
713 const VkFenceCreateInfo fenceParams =
715 VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, // VkStructureType sType;
716 DE_NULL, // const void* pNext;
717 0u, // VkFenceCreateFlags flags;
720 m_fence = createFence(vk, vkDevice, &fenceParams);
723 // alloc timestamp values
724 m_timestampValues = new deUint64[m_stages.size()];
727 TimestampTestInstance::~TimestampTestInstance(void)
729 if(m_timestampValues)
731 delete[] m_timestampValues;
732 m_timestampValues = NULL;
736 void TimestampTestInstance::configCommandBuffer(void)
738 const DeviceInterface& vk = m_context.getDeviceInterface();
740 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
742 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
743 DE_NULL, // const void* pNext;
744 0u, // VkCommandBufferUsageFlags flags;
745 (const VkCommandBufferInheritanceInfo*)DE_NULL,
748 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
750 vk.cmdResetQueryPool(*m_cmdBuffer, *m_queryPool, 0u, TimestampTest::ENTRY_COUNT);
752 deUint32 timestampEntry = 0;
753 for (StageFlagVector::const_iterator it = m_stages.begin(); it != m_stages.end(); it++)
755 vk.cmdWriteTimestamp(*m_cmdBuffer, *it, *m_queryPool, timestampEntry++);
758 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
761 tcu::TestStatus TimestampTestInstance::iterate(void)
763 const DeviceInterface& vk = m_context.getDeviceInterface();
764 const VkDevice vkDevice = m_context.getDevice();
765 const VkQueue queue = m_context.getUniversalQueue();
767 configCommandBuffer();
769 VK_CHECK(vk.resetFences(vkDevice, 1u, &m_fence.get()));
771 const VkSubmitInfo submitInfo =
773 VK_STRUCTURE_TYPE_SUBMIT_INFO, // VkStructureType sType;
774 DE_NULL, // const void* pNext;
775 0u, // deUint32 waitSemaphoreCount;
776 DE_NULL, // const VkSemaphore* pWaitSemaphores;
777 (const VkPipelineStageFlags*)DE_NULL,
778 1u, // deUint32 commandBufferCount;
779 &m_cmdBuffer.get(), // const VkCommandBuffer* pCommandBuffers;
780 0u, // deUint32 signalSemaphoreCount;
781 DE_NULL, // const VkSemaphore* pSignalSemaphores;
783 VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, *m_fence));
785 VK_CHECK(vk.waitForFences(vkDevice, 1u, &m_fence.get(), true, ~(0ull) /* infinity*/));
787 // Generate the timestamp mask
788 deUint64 timestampMask;
789 const std::vector<VkQueueFamilyProperties> queueProperties = vk::getPhysicalDeviceQueueFamilyProperties(m_context.getInstanceInterface(), m_context.getPhysicalDevice());
790 if(queueProperties[0].timestampValidBits == 0)
792 return tcu::TestStatus::fail("Device does not support timestamp!");
794 else if(queueProperties[0].timestampValidBits == 64)
796 timestampMask = 0xFFFFFFFFFFFFFFFF;
800 timestampMask = ((deUint64)1 << queueProperties[0].timestampValidBits) - 1;
803 // Get timestamp value from query pool
804 deUint32 stageSize = (deUint32)m_stages.size();
806 vk.getQueryPoolResults(vkDevice, *m_queryPool, 0u, stageSize, sizeof(deUint64) * stageSize, (void*)m_timestampValues, sizeof(deUint64), VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT);
808 for (deUint32 ndx = 0; ndx < stageSize; ndx++)
810 m_timestampValues[ndx] &= timestampMask;
813 return verifyTimestamp();
816 tcu::TestStatus TimestampTestInstance::verifyTimestamp(void)
818 for (deUint32 first = 0; first < m_stages.size(); first++)
820 for (deUint32 second = 0; second < first; second++)
822 if(m_timestampValues[first] < m_timestampValues[second])
824 return tcu::TestStatus::fail("Latter stage timestamp is smaller than the former stage timestamp.");
829 return tcu::TestStatus::pass("Timestamp increases steadily.");
832 Move<VkBuffer> TimestampTestInstance::createBufferAndBindMemory(VkDeviceSize size, VkBufferUsageFlags usage, de::MovePtr<Allocation>* pAlloc)
834 const DeviceInterface& vk = m_context.getDeviceInterface();
835 const VkDevice vkDevice = m_context.getDevice();
836 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
837 SimpleAllocator memAlloc (vk, vkDevice, getPhysicalDeviceMemoryProperties(m_context.getInstanceInterface(), m_context.getPhysicalDevice()));
839 const VkBufferCreateInfo vertexBufferParams =
841 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
842 DE_NULL, // const void* pNext;
843 0u, // VkBufferCreateFlags flags;
844 size, // VkDeviceSize size;
845 usage, // VkBufferUsageFlags usage;
846 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
847 1u, // deUint32 queueFamilyCount;
848 &queueFamilyIndex // const deUint32* pQueueFamilyIndices;
851 Move<VkBuffer> vertexBuffer = createBuffer(vk, vkDevice, &vertexBufferParams);
852 de::MovePtr<Allocation> vertexBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *vertexBuffer), MemoryRequirement::HostVisible);
854 VK_CHECK(vk.bindBufferMemory(vkDevice, *vertexBuffer, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset()));
857 *pAlloc = vertexBufferAlloc;
862 Move<VkImage> TimestampTestInstance::createImage2DAndBindMemory(VkFormat format,
865 VkImageUsageFlags usage,
866 VkSampleCountFlagBits sampleCount,
867 de::details::MovePtr<Allocation>* pAlloc)
869 const DeviceInterface& vk = m_context.getDeviceInterface();
870 const VkDevice vkDevice = m_context.getDevice();
871 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
872 SimpleAllocator memAlloc (vk, vkDevice, getPhysicalDeviceMemoryProperties(m_context.getInstanceInterface(), m_context.getPhysicalDevice()));
874 // Optimal tiling feature check
875 VkFormatProperties formatProperty;
876 m_context.getInstanceInterface().getPhysicalDeviceFormatProperties(m_context.getPhysicalDevice(), format, &formatProperty);
877 if((usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) && !(formatProperty.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
879 // Remove color attachment usage if the optimal tiling feature does not support it
880 usage &= ~VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
882 if((usage & VK_IMAGE_USAGE_STORAGE_BIT) && !(formatProperty.optimalTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT))
884 // Remove storage usage if the optimal tiling feature does not support it
885 usage &= ~VK_IMAGE_USAGE_STORAGE_BIT;
888 const VkImageCreateInfo colorImageParams =
890 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
891 DE_NULL, // const void* pNext;
892 0u, // VkImageCreateFlags flags;
893 VK_IMAGE_TYPE_2D, // VkImageType imageType;
894 format, // VkFormat format;
895 { width, height, 1u }, // VkExtent3D extent;
896 1u, // deUint32 mipLevels;
897 1u, // deUint32 arraySize;
898 sampleCount, // deUint32 samples;
899 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
900 usage, // VkImageUsageFlags usage;
901 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
902 1u, // deUint32 queueFamilyCount;
903 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
904 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
907 Move<VkImage> image = createImage(vk, vkDevice, &colorImageParams);
909 // Allocate and bind image memory
910 de::MovePtr<Allocation> colorImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *image), MemoryRequirement::Any);
911 VK_CHECK(vk.bindImageMemory(vkDevice, *image, colorImageAlloc->getMemory(), colorImageAlloc->getOffset()));
914 *pAlloc = colorImageAlloc;
919 class BasicGraphicsTest : public TimestampTest
922 BasicGraphicsTest(tcu::TestContext& testContext,
923 const std::string& name,
924 const std::string& description,
925 const TimestampTestParam* param)
926 : TimestampTest (testContext, name, description, param)
928 virtual ~BasicGraphicsTest (void) { }
929 virtual void initPrograms (SourceCollections& programCollection) const;
930 virtual TestInstance* createInstance (Context& context) const;
933 class BasicGraphicsTestInstance : public TimestampTestInstance
938 VK_MAX_SHADER_STAGES = 6,
940 BasicGraphicsTestInstance (Context& context,
941 const StageFlagVector stages,
942 const bool inRenderPass);
943 virtual ~BasicGraphicsTestInstance (void);
945 virtual void configCommandBuffer (void);
946 virtual void buildVertexBuffer (void);
947 virtual void buildRenderPass (VkFormat colorFormat,
948 VkFormat depthFormat);
949 virtual void buildFrameBuffer (tcu::UVec2 renderSize,
950 VkFormat colorFormat,
951 VkFormat depthFormat);
953 const tcu::UVec2 m_renderSize;
954 const VkFormat m_colorFormat;
955 const VkFormat m_depthFormat;
957 Move<VkImage> m_colorImage;
958 de::MovePtr<Allocation> m_colorImageAlloc;
959 Move<VkImage> m_depthImage;
960 de::MovePtr<Allocation> m_depthImageAlloc;
961 Move<VkImageView> m_colorAttachmentView;
962 Move<VkImageView> m_depthAttachmentView;
963 Move<VkRenderPass> m_renderPass;
964 Move<VkFramebuffer> m_framebuffer;
965 VkImageMemoryBarrier m_imageLayoutBarriers[2];
967 de::MovePtr<Allocation> m_vertexBufferAlloc;
968 Move<VkBuffer> m_vertexBuffer;
969 std::vector<Vertex4RGBA> m_vertices;
971 SimpleGraphicsPipelineBuilder m_pipelineBuilder;
972 Move<VkPipeline> m_graphicsPipelines;
975 void BasicGraphicsTest::initPrograms (SourceCollections& programCollection) const
977 programCollection.glslSources.add("color_vert") << glu::VertexSource(
979 "layout(location = 0) in vec4 position;\n"
980 "layout(location = 1) in vec4 color;\n"
981 "layout(location = 0) out highp vec4 vtxColor;\n"
984 " gl_Position = position;\n"
985 " vtxColor = color;\n"
988 programCollection.glslSources.add("color_frag") << glu::FragmentSource(
990 "layout(location = 0) in highp vec4 vtxColor;\n"
991 "layout(location = 0) out highp vec4 fragColor;\n"
994 " fragColor = vtxColor;\n"
998 TestInstance* BasicGraphicsTest::createInstance(Context& context) const
1000 return new BasicGraphicsTestInstance(context,m_stages,m_inRenderPass);
1003 void BasicGraphicsTestInstance::buildVertexBuffer(void)
1005 const DeviceInterface& vk = m_context.getDeviceInterface();
1006 const VkDevice vkDevice = m_context.getDevice();
1008 // Create vertex buffer
1010 m_vertexBuffer = createBufferAndBindMemory(1024u, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, &m_vertexBufferAlloc);
1012 m_vertices = createOverlappingQuads();
1013 // Load vertices into vertex buffer
1014 deMemcpy(m_vertexBufferAlloc->getHostPtr(), m_vertices.data(), m_vertices.size() * sizeof(Vertex4RGBA));
1015 flushMappedMemoryRange(vk, vkDevice, m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset(), 1024u);
1019 void BasicGraphicsTestInstance::buildRenderPass(VkFormat colorFormat, VkFormat depthFormat)
1021 const DeviceInterface& vk = m_context.getDeviceInterface();
1022 const VkDevice vkDevice = m_context.getDevice();
1024 // Create render pass
1026 const VkAttachmentDescription colorAttachmentDescription =
1028 0u, // VkAttachmentDescriptionFlags flags;
1029 colorFormat, // VkFormat format;
1030 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
1031 VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp;
1032 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
1033 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp;
1034 VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp;
1035 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout;
1036 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout finalLayout;
1039 const VkAttachmentDescription depthAttachmentDescription =
1041 0u, // VkAttachmentDescriptionFlags flags;
1042 depthFormat, // VkFormat format;
1043 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
1044 VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp;
1045 VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp storeOp;
1046 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp;
1047 VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp;
1048 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout;
1049 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // VkImageLayout finalLayout;
1052 const VkAttachmentDescription attachments[2] =
1054 colorAttachmentDescription,
1055 depthAttachmentDescription
1058 const VkAttachmentReference colorAttachmentReference =
1060 0u, // deUint32 attachment;
1061 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout layout;
1064 const VkAttachmentReference depthAttachmentReference =
1066 1u, // deUint32 attachment;
1067 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL // VkImageLayout layout;
1070 const VkSubpassDescription subpassDescription =
1072 0u, // VkSubpassDescriptionFlags flags;
1073 VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint;
1074 0u, // deUint32 inputAttachmentCount;
1075 DE_NULL, // const VkAttachmentReference* pInputAttachments;
1076 1u, // deUint32 colorAttachmentCount;
1077 &colorAttachmentReference, // const VkAttachmentReference* pColorAttachments;
1078 DE_NULL, // const VkAttachmentReference* pResolveAttachments;
1079 &depthAttachmentReference, // const VkAttachmentReference* pDepthStencilAttachment;
1080 0u, // deUint32 preserveAttachmentCount;
1081 DE_NULL // const VkAttachmentReference* pPreserveAttachments;
1084 const VkRenderPassCreateInfo renderPassParams =
1086 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType;
1087 DE_NULL, // const void* pNext;
1088 0u, // VkRenderPassCreateFlags flags;
1089 2u, // deUint32 attachmentCount;
1090 attachments, // const VkAttachmentDescription* pAttachments;
1091 1u, // deUint32 subpassCount;
1092 &subpassDescription, // const VkSubpassDescription* pSubpasses;
1093 0u, // deUint32 dependencyCount;
1094 DE_NULL // const VkSubpassDependency* pDependencies;
1097 m_renderPass = createRenderPass(vk, vkDevice, &renderPassParams);
1102 void BasicGraphicsTestInstance::buildFrameBuffer(tcu::UVec2 renderSize, VkFormat colorFormat, VkFormat depthFormat)
1104 const DeviceInterface& vk = m_context.getDeviceInterface();
1105 const VkDevice vkDevice = m_context.getDevice();
1106 const VkComponentMapping ComponentMappingRGBA = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A};
1108 // Create color image
1110 m_colorImage = createImage2DAndBindMemory(colorFormat,
1113 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
1114 VK_SAMPLE_COUNT_1_BIT,
1115 &m_colorImageAlloc);
1118 // Create depth image
1120 m_depthImage = createImage2DAndBindMemory(depthFormat,
1123 VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
1124 VK_SAMPLE_COUNT_1_BIT,
1125 &m_depthImageAlloc);
1128 // Set up image layout transition barriers
1130 const VkImageMemoryBarrier colorImageBarrier =
1132 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
1133 DE_NULL, // const void* pNext;
1134 0u, // VkAccessFlags srcAccessMask;
1135 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags dstAccessMask;
1136 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
1137 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout newLayout;
1138 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1139 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1140 *m_colorImage, // VkImage image;
1141 { VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u }, // VkImageSubresourceRange subresourceRange;
1143 const VkImageMemoryBarrier depthImageBarrier =
1145 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
1146 DE_NULL, // const void* pNext;
1147 0u, // VkAccessFlags srcAccessMask;
1148 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, // VkAccessFlags dstAccessMask;
1149 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
1150 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // VkImageLayout newLayout;
1151 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1152 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1153 *m_depthImage, // VkImage image;
1154 { VK_IMAGE_ASPECT_DEPTH_BIT, 0u, 1u, 0u, 1u }, // VkImageSubresourceRange subresourceRange;
1157 m_imageLayoutBarriers[0] = colorImageBarrier;
1158 m_imageLayoutBarriers[1] = depthImageBarrier;
1161 // Create color attachment view
1163 const VkImageViewCreateInfo colorAttachmentViewParams =
1165 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // VkStructureType sType;
1166 DE_NULL, // const void* pNext;
1167 0u, // VkImageViewCreateFlags flags;
1168 *m_colorImage, // VkImage image;
1169 VK_IMAGE_VIEW_TYPE_2D, // VkImageViewType viewType;
1170 colorFormat, // VkFormat format;
1171 ComponentMappingRGBA, // VkComponentMapping components;
1172 { VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u }, // VkImageSubresourceRange subresourceRange;
1175 m_colorAttachmentView = createImageView(vk, vkDevice, &colorAttachmentViewParams);
1178 // Create depth attachment view
1180 const VkImageViewCreateInfo depthAttachmentViewParams =
1182 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // VkStructureType sType;
1183 DE_NULL, // const void* pNext;
1184 0u, // VkImageViewCreateFlags flags;
1185 *m_depthImage, // VkImage image;
1186 VK_IMAGE_VIEW_TYPE_2D, // VkImageViewType viewType;
1187 depthFormat, // VkFormat format;
1188 ComponentMappingRGBA, // VkComponentMapping components;
1189 { VK_IMAGE_ASPECT_DEPTH_BIT, 0u, 1u, 0u, 1u }, // VkImageSubresourceRange subresourceRange;
1192 m_depthAttachmentView = createImageView(vk, vkDevice, &depthAttachmentViewParams);
1195 // Create framebuffer
1197 const VkImageView attachmentBindInfos[2] =
1199 *m_colorAttachmentView,
1200 *m_depthAttachmentView,
1203 const VkFramebufferCreateInfo framebufferParams =
1205 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType;
1206 DE_NULL, // const void* pNext;
1207 0u, // VkFramebufferCreateFlags flags;
1208 *m_renderPass, // VkRenderPass renderPass;
1209 2u, // deUint32 attachmentCount;
1210 attachmentBindInfos, // const VkImageView* pAttachments;
1211 (deUint32)renderSize.x(), // deUint32 width;
1212 (deUint32)renderSize.y(), // deUint32 height;
1213 1u, // deUint32 layers;
1216 m_framebuffer = createFramebuffer(vk, vkDevice, &framebufferParams);
1221 BasicGraphicsTestInstance::BasicGraphicsTestInstance(Context& context,
1222 const StageFlagVector stages,
1223 const bool inRenderPass)
1224 : TimestampTestInstance (context,stages,inRenderPass)
1225 , m_renderSize (32, 32)
1226 , m_colorFormat (VK_FORMAT_R8G8B8A8_UNORM)
1227 , m_depthFormat (VK_FORMAT_D16_UNORM)
1228 , m_pipelineBuilder (context)
1230 buildVertexBuffer();
1232 buildRenderPass(m_colorFormat, m_depthFormat);
1234 buildFrameBuffer(m_renderSize, m_colorFormat, m_depthFormat);
1236 m_pipelineBuilder.bindShaderStage(VK_SHADER_STAGE_VERTEX_BIT, "color_vert", "main");
1237 m_pipelineBuilder.bindShaderStage(VK_SHADER_STAGE_FRAGMENT_BIT, "color_frag", "main");
1239 m_graphicsPipelines = m_pipelineBuilder.buildPipeline(m_renderSize, *m_renderPass);
1243 BasicGraphicsTestInstance::~BasicGraphicsTestInstance(void)
1247 void BasicGraphicsTestInstance::configCommandBuffer(void)
1249 const DeviceInterface& vk = m_context.getDeviceInterface();
1251 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
1253 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
1254 DE_NULL, // const void* pNext;
1255 0u, // VkCommandBufferUsageFlags flags;
1256 (const VkCommandBufferInheritanceInfo*)DE_NULL,
1259 const VkClearValue attachmentClearValues[2] =
1261 defaultClearValue(m_colorFormat),
1262 defaultClearValue(m_depthFormat),
1265 const VkRenderPassBeginInfo renderPassBeginInfo =
1267 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // VkStructureType sType;
1268 DE_NULL, // const void* pNext;
1269 *m_renderPass, // VkRenderPass renderPass;
1270 *m_framebuffer, // VkFramebuffer framebuffer;
1271 { { 0u, 0u }, { m_renderSize.x(), m_renderSize.y() } }, // VkRect2D renderArea;
1272 2u, // deUint32 clearValueCount;
1273 attachmentClearValues // const VkClearValue* pClearValues;
1276 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
1278 vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, (VkDependencyFlags)0,
1279 0u, DE_NULL, 0u, DE_NULL, DE_LENGTH_OF_ARRAY(m_imageLayoutBarriers), m_imageLayoutBarriers);
1281 vk.cmdResetQueryPool(*m_cmdBuffer, *m_queryPool, 0u, TimestampTest::ENTRY_COUNT);
1283 vk.cmdBeginRenderPass(*m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
1285 vk.cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_graphicsPipelines);
1286 VkDeviceSize offsets = 0u;
1287 vk.cmdBindVertexBuffers(*m_cmdBuffer, 0u, 1u, &m_vertexBuffer.get(), &offsets);
1288 vk.cmdDraw(*m_cmdBuffer, (deUint32)m_vertices.size(), 1u, 0u, 0u);
1292 deUint32 timestampEntry = 0u;
1293 for (StageFlagVector::const_iterator it = m_stages.begin(); it != m_stages.end(); it++)
1295 vk.cmdWriteTimestamp(*m_cmdBuffer, *it, *m_queryPool, timestampEntry++);
1299 vk.cmdEndRenderPass(*m_cmdBuffer);
1303 deUint32 timestampEntry = 0u;
1304 for (StageFlagVector::const_iterator it = m_stages.begin(); it != m_stages.end(); it++)
1306 vk.cmdWriteTimestamp(*m_cmdBuffer, *it, *m_queryPool, timestampEntry++);
1310 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1313 class AdvGraphicsTest : public BasicGraphicsTest
1316 AdvGraphicsTest (tcu::TestContext& testContext,
1317 const std::string& name,
1318 const std::string& description,
1319 const TimestampTestParam* param)
1320 : BasicGraphicsTest(testContext, name, description, param)
1322 virtual ~AdvGraphicsTest (void) { }
1323 virtual void initPrograms (SourceCollections& programCollection) const;
1324 virtual TestInstance* createInstance (Context& context) const;
1327 class AdvGraphicsTestInstance : public BasicGraphicsTestInstance
1330 AdvGraphicsTestInstance (Context& context,
1331 const StageFlagVector stages,
1332 const bool inRenderPass);
1333 virtual ~AdvGraphicsTestInstance (void);
1334 virtual void configCommandBuffer (void);
1336 virtual void featureSupportCheck (void);
1338 VkPhysicalDeviceFeatures m_features;
1339 deUint32 m_draw_count;
1340 de::MovePtr<Allocation> m_indirectBufferAlloc;
1341 Move<VkBuffer> m_indirectBuffer;
1344 void AdvGraphicsTest::initPrograms(SourceCollections& programCollection) const
1346 BasicGraphicsTest::initPrograms(programCollection);
1348 programCollection.glslSources.add("dummy_geo") << glu::GeometrySource(
1350 "#extension GL_EXT_geometry_shader : enable\n"
1351 "layout(triangles) in;\n"
1352 "layout(triangle_strip, max_vertices = 3) out;\n"
1353 "layout(location = 0) in highp vec4 in_vtxColor[];\n"
1354 "layout(location = 0) out highp vec4 vtxColor;\n"
1355 "void main (void)\n"
1357 " for(int ndx=0; ndx<3; ndx++)\n"
1359 " gl_Position = gl_in[ndx].gl_Position;\n"
1360 " vtxColor = in_vtxColor[ndx];\n"
1363 " EndPrimitive();\n"
1366 programCollection.glslSources.add("basic_tcs") << glu::TessellationControlSource(
1368 "#extension GL_EXT_tessellation_shader : enable\n"
1369 "layout(vertices = 3) out;\n"
1370 "layout(location = 0) in highp vec4 color[];\n"
1371 "layout(location = 0) out highp vec4 vtxColor[];\n"
1374 " gl_TessLevelOuter[0] = 4.0;\n"
1375 " gl_TessLevelOuter[1] = 4.0;\n"
1376 " gl_TessLevelOuter[2] = 4.0;\n"
1377 " gl_TessLevelInner[0] = 4.0;\n"
1378 " gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
1379 " vtxColor[gl_InvocationID] = color[gl_InvocationID];\n"
1382 programCollection.glslSources.add("basic_tes") << glu::TessellationEvaluationSource(
1384 "#extension GL_EXT_tessellation_shader : enable\n"
1385 "layout(triangles, fractional_even_spacing, ccw) in;\n"
1386 "layout(location = 0) in highp vec4 colors[];\n"
1387 "layout(location = 0) out highp vec4 vtxColor;\n"
1390 " float u = gl_TessCoord.x;\n"
1391 " float v = gl_TessCoord.y;\n"
1392 " float w = gl_TessCoord.z;\n"
1393 " vec4 pos = vec4(0);\n"
1394 " vec4 color = vec4(0);\n"
1395 " pos.xyz += u * gl_in[0].gl_Position.xyz;\n"
1396 " color.xyz += u * colors[0].xyz;\n"
1397 " pos.xyz += v * gl_in[1].gl_Position.xyz;\n"
1398 " color.xyz += v * colors[1].xyz;\n"
1399 " pos.xyz += w * gl_in[2].gl_Position.xyz;\n"
1400 " color.xyz += w * colors[2].xyz;\n"
1403 " gl_Position = pos;\n"
1404 " vtxColor = color;\n"
1408 TestInstance* AdvGraphicsTest::createInstance(Context& context) const
1410 return new AdvGraphicsTestInstance(context,m_stages,m_inRenderPass);
1413 void AdvGraphicsTestInstance::featureSupportCheck(void)
1415 for (StageFlagVector::const_iterator it = m_stages.begin(); it != m_stages.end(); it++)
1419 case VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT:
1420 if (m_features.geometryShader == VK_FALSE)
1422 TCU_THROW(NotSupportedError, "Geometry Shader Not Supported");
1425 case VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT:
1426 case VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT:
1427 if (m_features.tessellationShader == VK_FALSE)
1429 TCU_THROW(NotSupportedError, "Tessellation Not Supported");
1432 case VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT:
1439 AdvGraphicsTestInstance::AdvGraphicsTestInstance(Context& context,
1440 const StageFlagVector stages,
1441 const bool inRenderPass)
1442 : BasicGraphicsTestInstance(context, stages, inRenderPass)
1444 m_features = m_context.getDeviceFeatures();
1446 // If necessary feature is not supported, throw error and fail current test
1447 featureSupportCheck();
1449 if(m_features.geometryShader == VK_TRUE)
1451 m_pipelineBuilder.bindShaderStage(VK_SHADER_STAGE_GEOMETRY_BIT, "dummy_geo", "main");
1454 if(m_features.tessellationShader == VK_TRUE)
1456 m_pipelineBuilder.bindShaderStage(VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, "basic_tcs", "main");
1457 m_pipelineBuilder.bindShaderStage(VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, "basic_tes", "main");
1458 m_pipelineBuilder.enableTessellationStage(3);
1461 m_graphicsPipelines = m_pipelineBuilder.buildPipeline(m_renderSize, *m_renderPass);
1463 // Prepare the indirect draw buffer
1464 const DeviceInterface& vk = m_context.getDeviceInterface();
1465 const VkDevice vkDevice = m_context.getDevice();
1467 if(m_features.multiDrawIndirect == VK_TRUE)
1475 m_indirectBuffer = createBufferAndBindMemory(32u, VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT, &m_indirectBufferAlloc);
1477 const VkDrawIndirectCommand indirectCmds[] =
1480 12u, // deUint32 vertexCount;
1481 1u, // deUint32 instanceCount;
1482 0u, // deUint32 firstVertex;
1483 0u, // deUint32 firstInstance;
1486 12u, // deUint32 vertexCount;
1487 1u, // deUint32 instanceCount;
1488 11u, // deUint32 firstVertex;
1489 0u, // deUint32 firstInstance;
1492 // Load data into indirect draw buffer
1493 deMemcpy(m_indirectBufferAlloc->getHostPtr(), indirectCmds, m_draw_count * sizeof(VkDrawIndirectCommand));
1494 flushMappedMemoryRange(vk, vkDevice, m_indirectBufferAlloc->getMemory(), m_indirectBufferAlloc->getOffset(), 32u);
1498 AdvGraphicsTestInstance::~AdvGraphicsTestInstance(void)
1502 void AdvGraphicsTestInstance::configCommandBuffer(void)
1504 const DeviceInterface& vk = m_context.getDeviceInterface();
1506 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
1508 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
1509 DE_NULL, // const void* pNext;
1510 0u, // VkCommandBufferUsageFlags flags;
1511 (const VkCommandBufferInheritanceInfo*)DE_NULL,
1514 const VkClearValue attachmentClearValues[2] =
1516 defaultClearValue(m_colorFormat),
1517 defaultClearValue(m_depthFormat),
1520 const VkRenderPassBeginInfo renderPassBeginInfo =
1522 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // VkStructureType sType;
1523 DE_NULL, // const void* pNext;
1524 *m_renderPass, // VkRenderPass renderPass;
1525 *m_framebuffer, // VkFramebuffer framebuffer;
1526 { { 0u, 0u }, { m_renderSize.x(), m_renderSize.y() } }, // VkRect2D renderArea;
1527 2u, // deUint32 clearValueCount;
1528 attachmentClearValues // const VkClearValue* pClearValues;
1531 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
1533 vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, (VkDependencyFlags)0,
1534 0u, DE_NULL, 0u, DE_NULL, DE_LENGTH_OF_ARRAY(m_imageLayoutBarriers), m_imageLayoutBarriers);
1536 vk.cmdResetQueryPool(*m_cmdBuffer, *m_queryPool, 0u, TimestampTest::ENTRY_COUNT);
1538 vk.cmdBeginRenderPass(*m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
1540 vk.cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_graphicsPipelines);
1542 VkDeviceSize offsets = 0u;
1543 vk.cmdBindVertexBuffers(*m_cmdBuffer, 0u, 1u, &m_vertexBuffer.get(), &offsets);
1545 vk.cmdDrawIndirect(*m_cmdBuffer, *m_indirectBuffer, 0u, m_draw_count, sizeof(VkDrawIndirectCommand));
1549 deUint32 timestampEntry = 0u;
1550 for (StageFlagVector::const_iterator it = m_stages.begin(); it != m_stages.end(); it++)
1552 vk.cmdWriteTimestamp(*m_cmdBuffer, *it, *m_queryPool, timestampEntry++);
1556 vk.cmdEndRenderPass(*m_cmdBuffer);
1560 deUint32 timestampEntry = 0u;
1561 for (StageFlagVector::const_iterator it = m_stages.begin(); it != m_stages.end(); it++)
1563 vk.cmdWriteTimestamp(*m_cmdBuffer, *it, *m_queryPool, timestampEntry++);
1567 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1571 class BasicComputeTest : public TimestampTest
1574 BasicComputeTest (tcu::TestContext& testContext,
1575 const std::string& name,
1576 const std::string& description,
1577 const TimestampTestParam* param)
1578 : TimestampTest(testContext, name, description, param)
1580 virtual ~BasicComputeTest (void) { }
1581 virtual void initPrograms (SourceCollections& programCollection) const;
1582 virtual TestInstance* createInstance (Context& context) const;
1585 class BasicComputeTestInstance : public TimestampTestInstance
1588 BasicComputeTestInstance (Context& context,
1589 const StageFlagVector stages,
1590 const bool inRenderPass);
1591 virtual ~BasicComputeTestInstance (void);
1592 virtual void configCommandBuffer (void);
1594 de::MovePtr<Allocation> m_inputBufAlloc;
1595 Move<VkBuffer> m_inputBuf;
1596 de::MovePtr<Allocation> m_outputBufAlloc;
1597 Move<VkBuffer> m_outputBuf;
1599 Move<VkDescriptorPool> m_descriptorPool;
1600 Move<VkDescriptorSet> m_descriptorSet;
1601 Move<VkDescriptorSetLayout> m_descriptorSetLayout;
1603 Move<VkPipelineLayout> m_pipelineLayout;
1604 Move<VkShaderModule> m_computeShaderModule;
1605 Move<VkPipeline> m_computePipelines;
1608 void BasicComputeTest::initPrograms(SourceCollections& programCollection) const
1610 TimestampTest::initPrograms(programCollection);
1612 programCollection.glslSources.add("basic_compute") << glu::ComputeSource(
1614 "layout(local_size_x = 128) in;\n"
1615 "layout(std430) buffer;\n"
1616 "layout(binding = 0) readonly buffer Input0\n"
1618 " vec4 elements[];\n"
1620 "layout(binding = 1) writeonly buffer Output\n"
1622 " vec4 elements[];\n"
1626 " uint ident = gl_GlobalInvocationID.x;\n"
1627 " output_data.elements[ident] = input_data0.elements[ident] * input_data0.elements[ident];\n"
1631 TestInstance* BasicComputeTest::createInstance(Context& context) const
1633 return new BasicComputeTestInstance(context,m_stages,m_inRenderPass);
1636 BasicComputeTestInstance::BasicComputeTestInstance(Context& context,
1637 const StageFlagVector stages,
1638 const bool inRenderPass)
1639 : TimestampTestInstance(context, stages, inRenderPass)
1641 const DeviceInterface& vk = context.getDeviceInterface();
1642 const VkDevice vkDevice = context.getDevice();
1644 // Create buffer object, allocate storage, and generate input data
1645 const VkDeviceSize size = sizeof(tcu::Vec4) * 128u * 128u;
1646 m_inputBuf = createBufferAndBindMemory(size, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, &m_inputBufAlloc);
1647 // Load vertices into buffer
1648 tcu::Vec4* pVec = reinterpret_cast<tcu::Vec4*>(m_inputBufAlloc->getHostPtr());
1649 for (deUint32 ndx = 0u; ndx < (128u * 128u); ndx++)
1651 for (deUint32 component = 0u; component < 4u; component++)
1653 pVec[ndx][component]= (float)(ndx * (component + 1u));
1656 flushMappedMemoryRange(vk, vkDevice, m_inputBufAlloc->getMemory(), m_inputBufAlloc->getOffset(), size);
1658 m_outputBuf = createBufferAndBindMemory(size, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, &m_outputBufAlloc);
1660 std::vector<VkDescriptorBufferInfo> descriptorInfos;
1661 descriptorInfos.push_back(makeDescriptorBufferInfo(*m_inputBuf, 0u, size));
1662 descriptorInfos.push_back(makeDescriptorBufferInfo(*m_outputBuf, 0u, size));
1664 // Create descriptor set layout
1665 DescriptorSetLayoutBuilder descLayoutBuilder;
1667 for (deUint32 bindingNdx = 0u; bindingNdx < 2u; bindingNdx++)
1669 descLayoutBuilder.addSingleBinding(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_SHADER_STAGE_COMPUTE_BIT);
1672 m_descriptorSetLayout = descLayoutBuilder.build(vk, vkDevice);
1674 // Create descriptor pool
1675 m_descriptorPool = DescriptorPoolBuilder().addType(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 2).build(vk, vkDevice, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 1u);
1677 // Create descriptor set
1678 const VkDescriptorSetAllocateInfo descriptorSetAllocInfo =
1680 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, // VkStructureType sType;
1681 DE_NULL, // const void* pNext;
1682 *m_descriptorPool, // VkDescriptorPool descriptorPool;
1683 1u, // deUint32 setLayoutCount;
1684 &m_descriptorSetLayout.get(), // const VkDescriptorSetLayout* pSetLayouts;
1686 m_descriptorSet = allocateDescriptorSet(vk, vkDevice, &descriptorSetAllocInfo);
1688 DescriptorSetUpdateBuilder builder;
1689 for (deUint32 descriptorNdx = 0u; descriptorNdx < 2u; descriptorNdx++)
1691 builder.writeSingle(*m_descriptorSet, DescriptorSetUpdateBuilder::Location::binding(descriptorNdx), VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, &descriptorInfos[descriptorNdx]);
1693 builder.update(vk, vkDevice);
1695 // Create compute pipeline layout
1696 const VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo =
1698 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // VkStructureType sType;
1699 DE_NULL, // const void* pNext;
1700 0u, // VkPipelineLayoutCreateFlags flags;
1701 1u, // deUint32 setLayoutCount;
1702 &m_descriptorSetLayout.get(), // const VkDescriptorSetLayout* pSetLayouts;
1703 0u, // deUint32 pushConstantRangeCount;
1704 DE_NULL, // const VkPushConstantRange* pPushConstantRanges;
1707 m_pipelineLayout = createPipelineLayout(vk, vkDevice, &pipelineLayoutCreateInfo);
1709 // Create compute shader
1710 VkShaderModuleCreateInfo shaderModuleCreateInfo =
1712 VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, // VkStructureType sType;
1713 DE_NULL, // const void* pNext;
1714 0u, // VkShaderModuleCreateFlags flags;
1715 m_context.getBinaryCollection().get("basic_compute").getSize(), // deUintptr codeSize;
1716 (deUint32*)m_context.getBinaryCollection().get("basic_compute").getBinary(), // const deUint32* pCode;
1720 m_computeShaderModule = createShaderModule(vk, vkDevice, &shaderModuleCreateInfo);
1722 // Create compute pipeline
1723 const VkPipelineShaderStageCreateInfo stageCreateInfo =
1725 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
1726 DE_NULL, // const void* pNext;
1727 0u, // VkPipelineShaderStageCreateFlags flags;
1728 VK_SHADER_STAGE_COMPUTE_BIT, // VkShaderStageFlagBits stage;
1729 *m_computeShaderModule, // VkShaderModule module;
1730 "main", // const char* pName;
1731 DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
1734 const VkComputePipelineCreateInfo pipelineCreateInfo =
1736 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, // VkStructureType sType;
1737 DE_NULL, // const void* pNext;
1738 0u, // VkPipelineCreateFlags flags;
1739 stageCreateInfo, // VkPipelineShaderStageCreateInfo stage;
1740 *m_pipelineLayout, // VkPipelineLayout layout;
1741 (VkPipeline)0, // VkPipeline basePipelineHandle;
1742 0u, // deInt32 basePipelineIndex;
1745 m_computePipelines = createComputePipeline(vk, vkDevice, (VkPipelineCache)0u, &pipelineCreateInfo);
1749 BasicComputeTestInstance::~BasicComputeTestInstance(void)
1753 void BasicComputeTestInstance::configCommandBuffer(void)
1755 const DeviceInterface& vk = m_context.getDeviceInterface();
1757 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
1759 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
1760 DE_NULL, // const void* pNext;
1761 0u, // VkCmdBufferOptimizeFlags flags;
1762 (const VkCommandBufferInheritanceInfo*)DE_NULL,
1766 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
1768 vk.cmdResetQueryPool(*m_cmdBuffer, *m_queryPool, 0u, TimestampTest::ENTRY_COUNT);
1770 vk.cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *m_computePipelines);
1771 vk.cmdBindDescriptorSets(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *m_pipelineLayout, 0u, 1u, &m_descriptorSet.get(), 0u, DE_NULL);
1772 vk.cmdDispatch(*m_cmdBuffer, 128u, 1u, 1u);
1774 deUint32 timestampEntry = 0u;
1775 for (StageFlagVector::const_iterator it = m_stages.begin(); it != m_stages.end(); it++)
1777 vk.cmdWriteTimestamp(*m_cmdBuffer, *it, *m_queryPool, timestampEntry++);
1780 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1785 class TransferTest : public TimestampTest
1788 TransferTest (tcu::TestContext& testContext,
1789 const std::string& name,
1790 const std::string& description,
1791 const TimestampTestParam* param);
1792 virtual ~TransferTest (void) { }
1793 virtual void initPrograms (SourceCollections& programCollection) const;
1794 virtual TestInstance* createInstance (Context& context) const;
1796 TransferMethod m_method;
1799 class TransferTestInstance : public TimestampTestInstance
1802 TransferTestInstance (Context& context,
1803 const StageFlagVector stages,
1804 const bool inRenderPass,
1805 const TransferMethod method);
1806 virtual ~TransferTestInstance (void);
1807 virtual void configCommandBuffer (void);
1808 virtual void initialImageTransition (VkCommandBuffer cmdBuffer,
1810 VkImageSubresourceRange subRange,
1811 VkImageLayout layout);
1813 TransferMethod m_method;
1815 VkDeviceSize m_bufSize;
1816 Move<VkBuffer> m_srcBuffer;
1817 Move<VkBuffer> m_dstBuffer;
1818 de::MovePtr<Allocation> m_srcBufferAlloc;
1819 de::MovePtr<Allocation> m_dstBufferAlloc;
1821 VkFormat m_imageFormat;
1822 deInt32 m_imageWidth;
1823 deInt32 m_imageHeight;
1824 VkDeviceSize m_imageSize;
1825 Move<VkImage> m_srcImage;
1826 Move<VkImage> m_dstImage;
1827 Move<VkImage> m_depthImage;
1828 Move<VkImage> m_msImage;
1829 de::MovePtr<Allocation> m_srcImageAlloc;
1830 de::MovePtr<Allocation> m_dstImageAlloc;
1831 de::MovePtr<Allocation> m_depthImageAlloc;
1832 de::MovePtr<Allocation> m_msImageAlloc;
1835 TransferTest::TransferTest(tcu::TestContext& testContext,
1836 const std::string& name,
1837 const std::string& description,
1838 const TimestampTestParam* param)
1839 : TimestampTest(testContext, name, description, param)
1841 const TransferTimestampTestParam* transferParam = dynamic_cast<const TransferTimestampTestParam*>(param);
1842 m_method = transferParam->getMethod();
1845 void TransferTest::initPrograms(SourceCollections& programCollection) const
1847 TimestampTest::initPrograms(programCollection);
1850 TestInstance* TransferTest::createInstance(Context& context) const
1852 return new TransferTestInstance(context, m_stages, m_inRenderPass, m_method);
1855 TransferTestInstance::TransferTestInstance(Context& context,
1856 const StageFlagVector stages,
1857 const bool inRenderPass,
1858 const TransferMethod method)
1859 : TimestampTestInstance(context, stages, inRenderPass)
1862 , m_imageFormat(VK_FORMAT_R8G8B8A8_UNORM)
1867 const DeviceInterface& vk = context.getDeviceInterface();
1868 const VkDevice vkDevice = context.getDevice();
1870 // Create src buffer
1871 m_srcBuffer = createBufferAndBindMemory(m_bufSize, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT, &m_srcBufferAlloc);
1873 // Init the source buffer memory
1874 char* pBuf = reinterpret_cast<char*>(m_srcBufferAlloc->getHostPtr());
1875 memset(pBuf, 0xFF, sizeof(char)*(size_t)m_bufSize);
1876 flushMappedMemoryRange(vk, vkDevice, m_srcBufferAlloc->getMemory(), m_srcBufferAlloc->getOffset(), m_bufSize);
1878 // Create dst buffer
1879 m_dstBuffer = createBufferAndBindMemory(m_bufSize, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, &m_dstBufferAlloc);
1881 // Create src/dst/depth image
1882 m_srcImage = createImage2DAndBindMemory(m_imageFormat, m_imageWidth, m_imageHeight,
1883 VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
1884 VK_SAMPLE_COUNT_1_BIT,
1886 m_dstImage = createImage2DAndBindMemory(m_imageFormat, m_imageWidth, m_imageHeight,
1887 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
1888 VK_SAMPLE_COUNT_1_BIT,
1890 m_depthImage = createImage2DAndBindMemory(VK_FORMAT_D16_UNORM, m_imageWidth, m_imageHeight,
1891 VK_IMAGE_USAGE_TRANSFER_DST_BIT,
1892 VK_SAMPLE_COUNT_1_BIT,
1893 &m_depthImageAlloc);
1894 m_msImage = createImage2DAndBindMemory(m_imageFormat, m_imageWidth, m_imageHeight,
1895 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
1896 VK_SAMPLE_COUNT_4_BIT,
1900 TransferTestInstance::~TransferTestInstance(void)
1904 void TransferTestInstance::configCommandBuffer(void)
1906 const DeviceInterface& vk = m_context.getDeviceInterface();
1908 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
1910 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
1911 DE_NULL, // const void* pNext;
1912 0u, // VkCmdBufferOptimizeFlags flags;
1913 (const VkCommandBufferInheritanceInfo*)DE_NULL,
1916 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
1918 // Initialize buffer/image
1919 vk.cmdFillBuffer(*m_cmdBuffer, *m_dstBuffer, 0u, m_bufSize, 0x0);
1921 const VkClearColorValue srcClearValue =
1923 {1.0f, 1.0f, 1.0f, 1.0f}
1925 const VkClearColorValue dstClearValue =
1927 {0.0f, 0.0f, 0.0f, 0.0f}
1929 const struct VkImageSubresourceRange subRangeColor =
1931 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
1932 0u, // deUint32 baseMipLevel;
1933 1u, // deUint32 mipLevels;
1934 0u, // deUint32 baseArrayLayer;
1935 1u, // deUint32 arraySize;
1937 const struct VkImageSubresourceRange subRangeDepth =
1939 VK_IMAGE_ASPECT_DEPTH_BIT, // VkImageAspectFlags aspectMask;
1940 0u, // deUint32 baseMipLevel;
1941 1u, // deUint32 mipLevels;
1942 0u, // deUint32 baseArrayLayer;
1943 1u, // deUint32 arraySize;
1946 initialImageTransition(*m_cmdBuffer, *m_srcImage, subRangeColor, VK_IMAGE_LAYOUT_GENERAL);
1947 initialImageTransition(*m_cmdBuffer, *m_dstImage, subRangeColor, VK_IMAGE_LAYOUT_GENERAL);
1949 vk.cmdClearColorImage(*m_cmdBuffer, *m_srcImage, VK_IMAGE_LAYOUT_GENERAL, &srcClearValue, 1u, &subRangeColor);
1950 vk.cmdClearColorImage(*m_cmdBuffer, *m_dstImage, VK_IMAGE_LAYOUT_GENERAL, &dstClearValue, 1u, &subRangeColor);
1952 vk.cmdResetQueryPool(*m_cmdBuffer, *m_queryPool, 0u, TimestampTest::ENTRY_COUNT);
1955 const VkImageSubresourceLayers imgSubResCopy =
1957 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
1958 0u, // deUint32 mipLevel;
1959 0u, // deUint32 baseArrayLayer;
1960 1u, // deUint32 layerCount;
1963 const VkOffset3D nullOffset = {0u, 0u, 0u};
1964 const VkExtent3D imageExtent = {(deUint32)m_imageWidth, (deUint32)m_imageHeight, 1u};
1965 const VkOffset3D imageOffset = {(int)m_imageWidth, (int)m_imageHeight, 1};
1968 case TRANSFER_METHOD_COPY_BUFFER:
1970 const VkBufferCopy copyBufRegion =
1972 0u, // VkDeviceSize srcOffset;
1973 0u, // VkDeviceSize destOffset;
1974 512u, // VkDeviceSize copySize;
1976 vk.cmdCopyBuffer(*m_cmdBuffer, *m_srcBuffer, *m_dstBuffer, 1u, ©BufRegion);
1979 case TRANSFER_METHOD_COPY_IMAGE:
1981 const VkImageCopy copyImageRegion =
1983 imgSubResCopy, // VkImageSubresourceCopy srcSubresource;
1984 nullOffset, // VkOffset3D srcOffset;
1985 imgSubResCopy, // VkImageSubresourceCopy destSubresource;
1986 nullOffset, // VkOffset3D destOffset;
1987 imageExtent, // VkExtent3D extent;
1990 vk.cmdCopyImage(*m_cmdBuffer, *m_srcImage, VK_IMAGE_LAYOUT_GENERAL, *m_dstImage, VK_IMAGE_LAYOUT_GENERAL, 1u, ©ImageRegion);
1993 case TRANSFER_METHOD_COPY_BUFFER_TO_IMAGE:
1995 const VkBufferImageCopy bufImageCopy =
1997 0u, // VkDeviceSize bufferOffset;
1998 (deUint32)m_imageWidth, // deUint32 bufferRowLength;
1999 (deUint32)m_imageHeight, // deUint32 bufferImageHeight;
2000 imgSubResCopy, // VkImageSubresourceCopy imageSubresource;
2001 nullOffset, // VkOffset3D imageOffset;
2002 imageExtent, // VkExtent3D imageExtent;
2004 vk.cmdCopyBufferToImage(*m_cmdBuffer, *m_srcBuffer, *m_dstImage, VK_IMAGE_LAYOUT_GENERAL, 1u, &bufImageCopy);
2007 case TRANSFER_METHOD_COPY_IMAGE_TO_BUFFER:
2009 const VkBufferImageCopy imgBufferCopy =
2011 0u, // VkDeviceSize bufferOffset;
2012 (deUint32)m_imageWidth, // deUint32 bufferRowLength;
2013 (deUint32)m_imageHeight, // deUint32 bufferImageHeight;
2014 imgSubResCopy, // VkImageSubresourceCopy imageSubresource;
2015 nullOffset, // VkOffset3D imageOffset;
2016 imageExtent, // VkExtent3D imageExtent;
2018 vk.cmdCopyImageToBuffer(*m_cmdBuffer, *m_srcImage, VK_IMAGE_LAYOUT_GENERAL, *m_dstBuffer, 1u, &imgBufferCopy);
2021 case TRANSFER_METHOD_BLIT_IMAGE:
2023 const VkImageBlit imageBlt =
2025 imgSubResCopy, // VkImageSubresourceCopy srcSubresource;
2030 imgSubResCopy, // VkImageSubresourceCopy destSubresource;
2036 vk.cmdBlitImage(*m_cmdBuffer, *m_srcImage, VK_IMAGE_LAYOUT_GENERAL, *m_dstImage, VK_IMAGE_LAYOUT_GENERAL, 1u, &imageBlt, VK_FILTER_NEAREST);
2039 case TRANSFER_METHOD_CLEAR_COLOR_IMAGE:
2041 vk.cmdClearColorImage(*m_cmdBuffer, *m_dstImage, VK_IMAGE_LAYOUT_GENERAL, &srcClearValue, 1u, &subRangeColor);
2044 case TRANSFER_METHOD_CLEAR_DEPTH_STENCIL_IMAGE:
2046 initialImageTransition(*m_cmdBuffer, *m_depthImage, subRangeDepth, VK_IMAGE_LAYOUT_GENERAL);
2047 const VkClearDepthStencilValue clearDSValue =
2049 1.0f, // float depth;
2050 0u, // deUint32 stencil;
2052 vk.cmdClearDepthStencilImage(*m_cmdBuffer, *m_depthImage, VK_IMAGE_LAYOUT_GENERAL, &clearDSValue, 1u, &subRangeDepth);
2055 case TRANSFER_METHOD_FILL_BUFFER:
2057 vk.cmdFillBuffer(*m_cmdBuffer, *m_dstBuffer, 0u, m_bufSize, 0x0);
2060 case TRANSFER_METHOD_UPDATE_BUFFER:
2062 const deUint32 data[] =
2064 0xdeadbeef, 0xabcdef00, 0x12345678
2066 vk.cmdUpdateBuffer(*m_cmdBuffer, *m_dstBuffer, 0x10, sizeof(data), data);
2069 case TRANSFER_METHOD_COPY_QUERY_POOL_RESULTS:
2071 vk.cmdWriteTimestamp(*m_cmdBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, *m_queryPool, 0u);
2072 vk.cmdCopyQueryPoolResults(*m_cmdBuffer, *m_queryPool, 0u, 1u, *m_dstBuffer, 0u, 8u, VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT);
2073 vk.cmdResetQueryPool(*m_cmdBuffer, *m_queryPool, 0u, 1u);
2076 case TRANSFER_METHOD_RESOLVE_IMAGE:
2078 const VkImageResolve imageResolve =
2080 imgSubResCopy, // VkImageSubresourceLayers srcSubresource;
2081 nullOffset, // VkOffset3D srcOffset;
2082 imgSubResCopy, // VkImageSubresourceLayers destSubresource;
2083 nullOffset, // VkOffset3D destOffset;
2084 imageExtent, // VkExtent3D extent;
2086 initialImageTransition(*m_cmdBuffer, *m_msImage, subRangeColor, VK_IMAGE_LAYOUT_GENERAL);
2087 vk.cmdClearColorImage(*m_cmdBuffer, *m_msImage, VK_IMAGE_LAYOUT_GENERAL, &srcClearValue, 1u, &subRangeColor);
2088 vk.cmdResolveImage(*m_cmdBuffer, *m_msImage, VK_IMAGE_LAYOUT_GENERAL, *m_dstImage, VK_IMAGE_LAYOUT_GENERAL, 1u, &imageResolve);
2092 DE_FATAL("Unknown Transfer Method!");
2096 deUint32 timestampEntry = 0u;
2097 for (StageFlagVector::const_iterator it = m_stages.begin(); it != m_stages.end(); it++)
2099 vk.cmdWriteTimestamp(*m_cmdBuffer, *it, *m_queryPool, timestampEntry++);
2102 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
2105 void TransferTestInstance::initialImageTransition (VkCommandBuffer cmdBuffer, VkImage image, VkImageSubresourceRange subRange, VkImageLayout layout)
2107 const DeviceInterface& vk = m_context.getDeviceInterface();
2108 const VkImageMemoryBarrier imageMemBarrier =
2110 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
2111 DE_NULL, // const void* pNext;
2112 0u, // VkAccessFlags srcAccessMask;
2113 0u, // VkAccessFlags dstAccessMask;
2114 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
2115 layout, // VkImageLayout newLayout;
2116 VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex;
2117 VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex;
2118 image, // VkImage image;
2119 subRange // VkImageSubresourceRange subresourceRange;
2122 vk.cmdPipelineBarrier(cmdBuffer, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0, DE_NULL, 0, DE_NULL, 1, &imageMemBarrier);
2127 tcu::TestCaseGroup* createTimestampTests (tcu::TestContext& testCtx)
2129 de::MovePtr<tcu::TestCaseGroup> timestampTests (new tcu::TestCaseGroup(testCtx, "timestamp", "timestamp tests"));
2131 // Basic Graphics Tests
2133 de::MovePtr<tcu::TestCaseGroup> basicGraphicsTests (new tcu::TestCaseGroup(testCtx, "basic_graphics_tests", "Record timestamp in different pipeline stages of basic graphics tests"));
2135 const VkPipelineStageFlagBits basicGraphicsStages0[][2] =
2137 {VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_VERTEX_INPUT_BIT},
2138 {VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT},
2139 {VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT},
2140 {VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT},
2141 {VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT},
2142 {VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT},
2143 {VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT},
2144 {VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT},
2146 for (deUint32 stageNdx = 0u; stageNdx < DE_LENGTH_OF_ARRAY(basicGraphicsStages0); stageNdx++)
2148 TimestampTestParam param(basicGraphicsStages0[stageNdx], 2u, true);
2149 basicGraphicsTests->addChild(newTestCase<BasicGraphicsTest>(testCtx, ¶m));
2150 param.toggleInRenderPass();
2151 basicGraphicsTests->addChild(newTestCase<BasicGraphicsTest>(testCtx, ¶m));
2154 const VkPipelineStageFlagBits basicGraphicsStages1[][3] =
2156 {VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT},
2157 {VK_PIPELINE_STAGE_VERTEX_INPUT_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT},
2159 for (deUint32 stageNdx = 0u; stageNdx < DE_LENGTH_OF_ARRAY(basicGraphicsStages1); stageNdx++)
2161 TimestampTestParam param(basicGraphicsStages1[stageNdx], 3u, true);
2162 basicGraphicsTests->addChild(newTestCase<BasicGraphicsTest>(testCtx, ¶m));
2163 param.toggleInRenderPass();
2164 basicGraphicsTests->addChild(newTestCase<BasicGraphicsTest>(testCtx, ¶m));
2167 timestampTests->addChild(basicGraphicsTests.release());
2170 // Advanced Graphics Tests
2172 de::MovePtr<tcu::TestCaseGroup> advGraphicsTests (new tcu::TestCaseGroup(testCtx, "advanced_graphics_tests", "Record timestamp in different pipeline stages of advanced graphics tests"));
2174 const VkPipelineStageFlagBits advGraphicsStages[][2] =
2176 {VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT},
2177 {VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT},
2178 {VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT},
2179 {VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT},
2181 for (deUint32 stageNdx = 0u; stageNdx < DE_LENGTH_OF_ARRAY(advGraphicsStages); stageNdx++)
2183 TimestampTestParam param(advGraphicsStages[stageNdx], 2u, true);
2184 advGraphicsTests->addChild(newTestCase<AdvGraphicsTest>(testCtx, ¶m));
2185 param.toggleInRenderPass();
2186 advGraphicsTests->addChild(newTestCase<AdvGraphicsTest>(testCtx, ¶m));
2189 timestampTests->addChild(advGraphicsTests.release());
2192 // Basic Compute Tests
2194 de::MovePtr<tcu::TestCaseGroup> basicComputeTests (new tcu::TestCaseGroup(testCtx, "basic_compute_tests", "Record timestamp for computer stages"));
2196 const VkPipelineStageFlagBits basicComputeStages[][2] =
2198 {VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT},
2199 {VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT},
2201 for (deUint32 stageNdx = 0u; stageNdx < DE_LENGTH_OF_ARRAY(basicComputeStages); stageNdx++)
2203 TimestampTestParam param(basicComputeStages[stageNdx], 2u, false);
2204 basicComputeTests->addChild(newTestCase<BasicComputeTest>(testCtx, ¶m));
2207 timestampTests->addChild(basicComputeTests.release());
2212 de::MovePtr<tcu::TestCaseGroup> transferTests (new tcu::TestCaseGroup(testCtx, "transfer_tests", "Record timestamp for transfer stages"));
2214 const VkPipelineStageFlagBits transferStages[][2] =
2216 {VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT},
2217 {VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_HOST_BIT},
2219 for (deUint32 stageNdx = 0u; stageNdx < DE_LENGTH_OF_ARRAY(transferStages); stageNdx++)
2221 for (deUint32 method = 0u; method < TRANSFER_METHOD_LAST; method++)
2223 TransferTimestampTestParam param(transferStages[stageNdx], 2u, false, method);
2224 transferTests->addChild(newTestCase<TransferTest>(testCtx, ¶m));
2228 timestampTests->addChild(transferTests.release());
2233 de::MovePtr<tcu::TestCaseGroup> miscTests (new tcu::TestCaseGroup(testCtx, "misc_tests", "Misc tests that can not be categorized to other group."));
2235 const VkPipelineStageFlagBits miscStages[] = {VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT};
2236 TimestampTestParam param(miscStages, 1u, false);
2237 miscTests->addChild(new TimestampTest(testCtx,
2239 "Only write timestamp command in the commmand buffer",
2242 timestampTests->addChild(miscTests.release());
2245 return timestampTests.release();