1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2016 The Khronos Group Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief Vulkan Statistics Query Tests
22 *//*--------------------------------------------------------------------*/
24 #include "vktQueryPoolStatisticsTests.hpp"
25 #include "vktTestCase.hpp"
27 #include "vktDrawImageObjectUtil.hpp"
28 #include "vktDrawBufferObjectUtil.hpp"
29 #include "vktDrawCreateInfoUtil.hpp"
30 #include "vkBuilderUtil.hpp"
31 #include "vkRefUtil.hpp"
32 #include "vkPrograms.hpp"
36 #include "tcuTestLog.hpp"
37 #include "tcuResource.hpp"
38 #include "tcuImageCompare.hpp"
39 #include "vkImageUtil.hpp"
40 #include "tcuCommandLine.hpp"
41 #include "tcuRGBA.hpp"
60 std::string inputTypeToGLString (const VkPrimitiveTopology& inputType)
64 case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
66 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
67 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
69 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
70 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
71 return "lines_adjacency";
72 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
73 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
74 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
76 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
77 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
78 return "triangles_adjacency";
85 std::string outputTypeToGLString (const VkPrimitiveTopology& outputType)
89 case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
91 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
92 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
93 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
94 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
96 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
97 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
98 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
99 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
100 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
101 return "triangle_strip";
108 void beginCommandBuffer (const DeviceInterface& vk, const VkCommandBuffer commandBuffer)
110 const VkCommandBufferBeginInfo info =
112 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
113 DE_NULL, // const void* pNext;
114 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
115 DE_NULL, // const VkCommandBufferInheritanceInfo* pInheritanceInfo;
117 VK_CHECK(vk.beginCommandBuffer(commandBuffer, &info));
120 void beginSecondaryCommandBuffer (const DeviceInterface& vk,
121 const VkCommandBuffer commandBuffer,
122 const VkQueryPipelineStatisticFlags queryFlags,
123 const VkRenderPass renderPass = (VkRenderPass)0u,
124 const VkFramebuffer framebuffer = (VkFramebuffer)0u,
125 const VkCommandBufferUsageFlags bufferUsageFlags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)
127 const VkCommandBufferInheritanceInfo secCmdBufInheritInfo =
129 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO,
131 renderPass, // renderPass
133 framebuffer, // framebuffer
134 VK_FALSE, // occlusionQueryEnable
135 (VkQueryControlFlags)0u, // queryFlags
136 queryFlags, // pipelineStatistics
139 const VkCommandBufferBeginInfo info =
141 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
142 DE_NULL, // const void* pNext;
143 bufferUsageFlags, // VkCommandBufferUsageFlags flags;
144 &secCmdBufInheritInfo, // const VkCommandBufferInheritanceInfo* pInheritanceInfo;
146 VK_CHECK(vk.beginCommandBuffer(commandBuffer, &info));
149 void submitCommandsAndWait (const DeviceInterface& vk,
150 const VkDevice device,
152 const VkCommandBuffer commandBuffer)
154 const VkFenceCreateInfo fenceInfo =
156 VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, // VkStructureType sType;
157 DE_NULL, // const void* pNext;
158 (VkFenceCreateFlags)0, // VkFenceCreateFlags flags;
160 const Unique<VkFence> fence (createFence(vk, device, &fenceInfo));
162 const VkSubmitInfo submitInfo =
164 VK_STRUCTURE_TYPE_SUBMIT_INFO, // VkStructureType sType;
165 DE_NULL, // const void* pNext;
166 0u, // uint32_t waitSemaphoreCount;
167 DE_NULL, // const VkSemaphore* pWaitSemaphores;
168 DE_NULL, // const VkPipelineStageFlags* pWaitDstStageMask;
169 1u, // uint32_t commandBufferCount;
170 &commandBuffer, // const VkCommandBuffer* pCommandBuffers;
171 0u, // uint32_t signalSemaphoreCount;
172 DE_NULL, // const VkSemaphore* pSignalSemaphores;
174 VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, *fence));
175 VK_CHECK(vk.waitForFences(device, 1u, &fence.get(), DE_TRUE, ~0ull));
178 Move<VkQueryPool> makeQueryPool (const DeviceInterface& vk, const VkDevice device, VkQueryPipelineStatisticFlags statisticFlags)
180 const VkQueryPoolCreateInfo queryPoolCreateInfo =
182 VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO, // VkStructureType sType
183 DE_NULL, // const void* pNext
184 (VkQueryPoolCreateFlags)0, // VkQueryPoolCreateFlags flags
185 VK_QUERY_TYPE_PIPELINE_STATISTICS , // VkQueryType queryType
186 1u, // deUint32 entryCount
187 statisticFlags, // VkQueryPipelineStatisticFlags pipelineStatistics
189 return createQueryPool(vk, device, &queryPoolCreateInfo);
192 Move<VkPipelineLayout> makePipelineLayout (const DeviceInterface& vk, const VkDevice device, const VkDescriptorSetLayout* descriptorSetLayout)
194 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
196 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // VkStructureType sType;
197 DE_NULL, // const void* pNext;
198 0u, // VkPipelineLayoutCreateFlags flags;
199 1u, // deUint32 setLayoutCount;
200 descriptorSetLayout, // const VkDescriptorSetLayout* pSetLayouts;
201 0u, // deUint32 pushConstantRangeCount;
202 DE_NULL, // const VkPushConstantRange* pPushConstantRanges;
204 return (createPipelineLayout(vk, device, &pipelineLayoutParams));
207 void clearBuffer (const DeviceInterface& vk, const VkDevice device, const de::SharedPtr<Buffer> buffer, const VkDeviceSize bufferSizeBytes)
209 const std::vector<deUint8> data ((size_t)bufferSizeBytes, 0u);
210 const Allocation& allocation = buffer->getBoundMemory();
211 void* allocationData = allocation.getHostPtr();
212 invalidateMappedMemoryRange(vk, device, allocation.getMemory(), allocation.getOffset(), bufferSizeBytes);
213 deMemcpy(allocationData, &data[0], (size_t)bufferSizeBytes);
216 class StatisticQueryTestInstance : public TestInstance
219 StatisticQueryTestInstance (Context& context);
221 virtual void checkExtensions (void);
224 StatisticQueryTestInstance::StatisticQueryTestInstance (Context& context)
225 : TestInstance (context)
229 void StatisticQueryTestInstance::checkExtensions (void)
231 if (!m_context.getDeviceFeatures().pipelineStatisticsQuery)
232 throw tcu::NotSupportedError("Pipeline statistics queries are not supported");
235 class ComputeInvocationsTestInstance : public StatisticQueryTestInstance
238 struct ParametersCompute
240 tcu::UVec3 localSize;
241 tcu::UVec3 groupSize;
242 std::string shaderName;
244 ComputeInvocationsTestInstance (Context& context, const std::vector<ParametersCompute>& parameters);
245 tcu::TestStatus iterate (void);
247 virtual tcu::TestStatus executeTest (const VkCommandPool& cmdPool,
248 const VkPipelineLayout pipelineLayout,
249 const VkDescriptorSet& descriptorSet,
250 const de::SharedPtr<Buffer> buffer,
251 const VkDeviceSize bufferSizeBytes);
252 deUint32 getComputeExecution (const ParametersCompute& parm) const
254 return parm.localSize.x() * parm.localSize.y() *parm.localSize.z() * parm.groupSize.x() * parm.groupSize.y() * parm.groupSize.z();
256 const std::vector<ParametersCompute>& m_parameters;
259 ComputeInvocationsTestInstance::ComputeInvocationsTestInstance (Context& context, const std::vector<ParametersCompute>& parameters)
260 : StatisticQueryTestInstance (context)
261 , m_parameters (parameters)
265 tcu::TestStatus ComputeInvocationsTestInstance::iterate (void)
268 const DeviceInterface& vk = m_context.getDeviceInterface();
269 const VkDevice device = m_context.getDevice();
270 deUint32 maxSize = 0u;
272 for(size_t parametersNdx = 0; parametersNdx < m_parameters.size(); ++parametersNdx)
273 maxSize = deMaxu32(maxSize, getComputeExecution(m_parameters[parametersNdx]));
275 const VkDeviceSize bufferSizeBytes = static_cast<VkDeviceSize>(deAlignSize(static_cast<size_t>(sizeof(deUint32) * maxSize),
276 static_cast<size_t>(m_context.getDeviceProperties().limits.nonCoherentAtomSize)));
277 de::SharedPtr<Buffer> buffer = Buffer::createAndAlloc(vk, device, BufferCreateInfo(bufferSizeBytes, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT),
278 m_context.getDefaultAllocator(), MemoryRequirement::HostVisible);
280 const Unique<VkDescriptorSetLayout> descriptorSetLayout (DescriptorSetLayoutBuilder()
281 .addSingleBinding(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_SHADER_STAGE_COMPUTE_BIT)
284 const Unique<VkPipelineLayout> pipelineLayout (makePipelineLayout(vk, device, &(*descriptorSetLayout)));
286 const Unique<VkDescriptorPool> descriptorPool (DescriptorPoolBuilder()
287 .addType(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER)
288 .build(vk, device, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 1u));
290 const VkDescriptorSetAllocateInfo allocateParams =
292 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, // VkStructureType sType;
293 DE_NULL, // const void* pNext;
294 *descriptorPool, // VkDescriptorPool descriptorPool;
295 1u, // deUint32 setLayoutCount;
296 &(*descriptorSetLayout), // const VkDescriptorSetLayout* pSetLayouts;
299 const Unique<VkDescriptorSet> descriptorSet (allocateDescriptorSet(vk, device, &allocateParams));
300 const VkDescriptorBufferInfo descriptorInfo =
302 buffer->object(), //VkBuffer buffer;
303 0ull, //VkDeviceSize offset;
304 bufferSizeBytes, //VkDeviceSize range;
307 DescriptorSetUpdateBuilder()
308 .writeSingle(*descriptorSet, DescriptorSetUpdateBuilder::Location::binding(0u), VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, &descriptorInfo)
311 const CmdPoolCreateInfo cmdPoolCreateInfo (m_context.getUniversalQueueFamilyIndex());
312 const Unique<VkCommandPool> cmdPool (createCommandPool(vk, device, &cmdPoolCreateInfo));
314 return executeTest (*cmdPool, *pipelineLayout, *descriptorSet, buffer, bufferSizeBytes);
317 tcu::TestStatus ComputeInvocationsTestInstance::executeTest (const VkCommandPool& cmdPool,
318 const VkPipelineLayout pipelineLayout,
319 const VkDescriptorSet& descriptorSet,
320 const de::SharedPtr<Buffer> buffer,
321 const VkDeviceSize bufferSizeBytes)
323 const DeviceInterface& vk = m_context.getDeviceInterface();
324 const VkDevice device = m_context.getDevice();
325 const VkQueue queue = m_context.getUniversalQueue();
326 const VkBufferMemoryBarrier computeFinishBarrier =
328 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
329 DE_NULL, // const void* pNext;
330 VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags srcAccessMask;
331 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
332 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
333 VK_QUEUE_FAMILY_IGNORED, // deUint32 destQueueFamilyIndex;
334 buffer->object(), // VkBuffer buffer;
335 0ull, // VkDeviceSize offset;
336 bufferSizeBytes, // VkDeviceSize size;
339 for(size_t parametersNdx = 0u; parametersNdx < m_parameters.size(); ++parametersNdx)
341 clearBuffer(vk, device, buffer, bufferSizeBytes);
342 const Unique<VkShaderModule> shaderModule (createShaderModule(vk, device,
343 m_context.getBinaryCollection().get(m_parameters[parametersNdx].shaderName), (VkShaderModuleCreateFlags)0u));
345 const VkPipelineShaderStageCreateInfo pipelineShaderStageParams =
347 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
348 DE_NULL, // const void* pNext;
349 (VkPipelineShaderStageCreateFlags)0u, // VkPipelineShaderStageCreateFlags flags;
350 VK_SHADER_STAGE_COMPUTE_BIT, // VkShaderStageFlagBits stage;
351 *shaderModule, // VkShaderModule module;
352 "main", // const char* pName;
353 DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
356 const VkComputePipelineCreateInfo pipelineCreateInfo =
358 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, // VkStructureType sType;
359 DE_NULL, // const void* pNext;
360 (VkPipelineCreateFlags)0u, // VkPipelineCreateFlags flags;
361 pipelineShaderStageParams, // VkPipelineShaderStageCreateInfo stage;
362 pipelineLayout, // VkPipelineLayout layout;
363 DE_NULL, // VkPipeline basePipelineHandle;
364 0, // deInt32 basePipelineIndex;
366 const Unique<VkPipeline> pipeline(createComputePipeline(vk, device, DE_NULL , &pipelineCreateInfo));
368 const Unique<VkCommandBuffer> cmdBuffer (allocateCommandBuffer(vk, device, cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
369 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT));
371 beginCommandBuffer(vk, *cmdBuffer);
372 vk.cmdResetQueryPool(*cmdBuffer, *queryPool, 0u, 1u);
374 vk.cmdBindPipeline(*cmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *pipeline);
375 vk.cmdBindDescriptorSets(*cmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipelineLayout, 0u, 1u, &descriptorSet, 0u, DE_NULL);
377 vk.cmdBeginQuery(*cmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
378 vk.cmdDispatch(*cmdBuffer, m_parameters[parametersNdx].groupSize.x(), m_parameters[parametersNdx].groupSize.y(), m_parameters[parametersNdx].groupSize.z());
379 vk.cmdEndQuery(*cmdBuffer, *queryPool, 0u);
381 vk.cmdPipelineBarrier(*cmdBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_HOST_BIT,
382 (VkDependencyFlags)0u, 0u, (const VkMemoryBarrier*)DE_NULL, 1u, &computeFinishBarrier, 0u, (const VkImageMemoryBarrier*)DE_NULL);
383 VK_CHECK(vk.endCommandBuffer(*cmdBuffer));
385 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Compute shader invocations: " << getComputeExecution(m_parameters[parametersNdx]) << tcu::TestLog::EndMessage;
387 // Wait for completion
388 submitCommandsAndWait(vk, device, queue, *cmdBuffer);
390 // Validate the results
391 const Allocation& bufferAllocation = buffer->getBoundMemory();
392 invalidateMappedMemoryRange(vk, device, bufferAllocation.getMemory(), bufferAllocation.getOffset(), bufferSizeBytes);
396 VK_CHECK(vk.getQueryPoolResults(device, *queryPool, 0u, 1u, sizeof(deUint64), &data, 0u, VK_QUERY_RESULT_64_BIT));
397 if (getComputeExecution(m_parameters[parametersNdx]) != data)
398 return tcu::TestStatus::fail("QueryPoolResults incorrect");
401 const deUint32* bufferPtr = static_cast<deUint32*>(bufferAllocation.getHostPtr());
402 for (deUint32 ndx = 0u; ndx < getComputeExecution(m_parameters[parametersNdx]); ++ndx)
404 if (bufferPtr[ndx] != ndx)
405 return tcu::TestStatus::fail("Compute shader didn't write data to the buffer");
408 return tcu::TestStatus::pass("Pass");
411 class ComputeInvocationsSecondaryTestInstance : public ComputeInvocationsTestInstance
414 ComputeInvocationsSecondaryTestInstance (Context& context, const std::vector<ParametersCompute>& parameters);
416 tcu::TestStatus executeTest (const VkCommandPool& cmdPool,
417 const VkPipelineLayout pipelineLayout,
418 const VkDescriptorSet& descriptorSet,
419 const de::SharedPtr<Buffer> buffer,
420 const VkDeviceSize bufferSizeBytes);
421 virtual tcu::TestStatus checkResult (const de::SharedPtr<Buffer> buffer,
422 const VkDeviceSize bufferSizeBytes,
423 const VkQueryPool queryPool);
426 ComputeInvocationsSecondaryTestInstance::ComputeInvocationsSecondaryTestInstance (Context& context, const std::vector<ParametersCompute>& parameters)
427 : ComputeInvocationsTestInstance (context, parameters)
431 tcu::TestStatus ComputeInvocationsSecondaryTestInstance::executeTest (const VkCommandPool& cmdPool,
432 const VkPipelineLayout pipelineLayout,
433 const VkDescriptorSet& descriptorSet,
434 const de::SharedPtr<Buffer> buffer,
435 const VkDeviceSize bufferSizeBytes)
437 typedef de::SharedPtr<Unique<VkShaderModule> > VkShaderModuleSp;
438 typedef de::SharedPtr<Unique<VkPipeline> > VkPipelineSp;
440 const DeviceInterface& vk = m_context.getDeviceInterface();
441 const VkDevice device = m_context.getDevice();
442 const VkQueue queue = m_context.getUniversalQueue();
444 const VkBufferMemoryBarrier computeShaderWriteBarrier =
446 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
447 DE_NULL, // const void* pNext;
448 VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags srcAccessMask;
449 VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags dstAccessMask;
450 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
451 VK_QUEUE_FAMILY_IGNORED, // deUint32 destQueueFamilyIndex;
452 buffer->object(), // VkBuffer buffer;
453 0ull, // VkDeviceSize offset;
454 bufferSizeBytes, // VkDeviceSize size;
457 const VkBufferMemoryBarrier computeFinishBarrier =
459 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
460 DE_NULL, // const void* pNext;
461 VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags srcAccessMask;
462 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
463 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
464 VK_QUEUE_FAMILY_IGNORED, // deUint32 destQueueFamilyIndex;
465 buffer->object(), // VkBuffer buffer;
466 0ull, // VkDeviceSize offset;
467 bufferSizeBytes, // VkDeviceSize size;
470 std::vector<VkShaderModuleSp> shaderModule;
471 std::vector<VkPipelineSp> pipeline;
472 for(size_t parametersNdx = 0; parametersNdx < m_parameters.size(); ++parametersNdx)
474 shaderModule.push_back(VkShaderModuleSp(new Unique<VkShaderModule>(createShaderModule(vk, device, m_context.getBinaryCollection().get(m_parameters[parametersNdx].shaderName), (VkShaderModuleCreateFlags)0u))));
475 const VkPipelineShaderStageCreateInfo pipelineShaderStageParams =
477 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
478 DE_NULL, // const void* pNext;
479 0u, // VkPipelineShaderStageCreateFlags flags;
480 VK_SHADER_STAGE_COMPUTE_BIT, // VkShaderStageFlagBits stage;
481 shaderModule.back().get()->get(), // VkShaderModule module;
482 "main", // const char* pName;
483 DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
486 const VkComputePipelineCreateInfo pipelineCreateInfo =
488 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, // VkStructureType sType;
489 DE_NULL, // const void* pNext;
490 0u, // VkPipelineCreateFlags flags;
491 pipelineShaderStageParams, // VkPipelineShaderStageCreateInfo stage;
492 pipelineLayout, // VkPipelineLayout layout;
493 DE_NULL, // VkPipeline basePipelineHandle;
494 0, // deInt32 basePipelineIndex;
496 pipeline.push_back(VkPipelineSp(new Unique<VkPipeline>(createComputePipeline(vk, device, DE_NULL , &pipelineCreateInfo))));
499 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
500 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
502 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT));
504 clearBuffer(vk, device, buffer, bufferSizeBytes);
505 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT);
506 vk.cmdBindDescriptorSets(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipelineLayout, 0u, 1u, &descriptorSet, 0u, DE_NULL);
507 vk.cmdResetQueryPool(*secondaryCmdBuffer, *queryPool, 0u, 1u);
508 vk.cmdBeginQuery(*secondaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
509 for(size_t parametersNdx = 0; parametersNdx < m_parameters.size(); ++parametersNdx)
511 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline[parametersNdx].get()->get());
512 vk.cmdDispatch(*secondaryCmdBuffer, m_parameters[parametersNdx].groupSize.x(), m_parameters[parametersNdx].groupSize.y(), m_parameters[parametersNdx].groupSize.z());
514 vk.cmdPipelineBarrier(*secondaryCmdBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
515 (VkDependencyFlags)0u, 0u, (const VkMemoryBarrier*)DE_NULL, 1u, &computeShaderWriteBarrier, 0u, (const VkImageMemoryBarrier*)DE_NULL);
517 vk.cmdEndQuery(*secondaryCmdBuffer, *queryPool, 0u);
518 VK_CHECK(vk.endCommandBuffer(*secondaryCmdBuffer));
520 beginCommandBuffer(vk, *primaryCmdBuffer);
521 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
523 vk.cmdPipelineBarrier(*primaryCmdBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_HOST_BIT,
524 (VkDependencyFlags)0u, 0u, (const VkMemoryBarrier*)DE_NULL, 1u, &computeFinishBarrier, 0u, (const VkImageMemoryBarrier*)DE_NULL);
526 VK_CHECK(vk.endCommandBuffer(*primaryCmdBuffer));
528 // Wait for completion
529 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
530 return checkResult(buffer, bufferSizeBytes, *queryPool);
533 tcu::TestStatus ComputeInvocationsSecondaryTestInstance::checkResult (const de::SharedPtr<Buffer> buffer, const VkDeviceSize bufferSizeBytes, const VkQueryPool queryPool)
535 const DeviceInterface& vk = m_context.getDeviceInterface();
536 const VkDevice device = m_context.getDevice();
538 deUint64 result = 0u;
539 deUint64 expected = 0u;
540 for(size_t parametersNdx = 0; parametersNdx < m_parameters.size(); ++parametersNdx)
541 expected += getComputeExecution(m_parameters[parametersNdx]);
542 VK_CHECK(vk.getQueryPoolResults(device, queryPool, 0u, 1u, sizeof(deUint64), &result, 0u, VK_QUERY_RESULT_64_BIT));
543 if (expected != result)
544 return tcu::TestStatus::fail("QueryPoolResults incorrect");
548 // Validate the results
549 const Allocation& bufferAllocation = buffer->getBoundMemory();
550 invalidateMappedMemoryRange(vk, device, bufferAllocation.getMemory(), bufferAllocation.getOffset(), bufferSizeBytes);
551 const deUint32* bufferPtr = static_cast<deUint32*>(bufferAllocation.getHostPtr());
552 deUint32 minSize = ~0u;
553 for(size_t parametersNdx = 0; parametersNdx < m_parameters.size(); ++parametersNdx)
554 minSize = deMinu32(minSize, getComputeExecution(m_parameters[parametersNdx]));
555 for (deUint32 ndx = 0u; ndx < minSize; ++ndx)
557 if (bufferPtr[ndx] != ndx * m_parameters.size())
558 return tcu::TestStatus::fail("Compute shader didn't write data to the buffer");
561 return tcu::TestStatus::pass("Pass");
564 class ComputeInvocationsSecondaryInheritedTestInstance : public ComputeInvocationsSecondaryTestInstance
567 ComputeInvocationsSecondaryInheritedTestInstance (Context& context, const std::vector<ParametersCompute>& parameters);
569 virtual void checkExtensions (void);
570 tcu::TestStatus executeTest (const VkCommandPool& cmdPool,
571 const VkPipelineLayout pipelineLayout,
572 const VkDescriptorSet& descriptorSet,
573 const de::SharedPtr<Buffer> buffer,
574 const VkDeviceSize bufferSizeBytes);
577 ComputeInvocationsSecondaryInheritedTestInstance::ComputeInvocationsSecondaryInheritedTestInstance (Context& context, const std::vector<ParametersCompute>& parameters)
578 : ComputeInvocationsSecondaryTestInstance (context, parameters)
582 void ComputeInvocationsSecondaryInheritedTestInstance::checkExtensions (void)
584 StatisticQueryTestInstance::checkExtensions();
585 if (!m_context.getDeviceFeatures().inheritedQueries)
586 throw tcu::NotSupportedError("Inherited queries are not supported");
589 tcu::TestStatus ComputeInvocationsSecondaryInheritedTestInstance::executeTest (const VkCommandPool& cmdPool,
590 const VkPipelineLayout pipelineLayout,
591 const VkDescriptorSet& descriptorSet,
592 const de::SharedPtr<Buffer> buffer,
593 const VkDeviceSize bufferSizeBytes)
595 typedef de::SharedPtr<Unique<VkShaderModule> > VkShaderModuleSp;
596 typedef de::SharedPtr<Unique<VkPipeline> > VkPipelineSp;
598 const DeviceInterface& vk = m_context.getDeviceInterface();
599 const VkDevice device = m_context.getDevice();
600 const VkQueue queue = m_context.getUniversalQueue();
602 const VkBufferMemoryBarrier computeShaderWriteBarrier =
604 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
605 DE_NULL, // const void* pNext;
606 VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags srcAccessMask;
607 VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags dstAccessMask;
608 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
609 VK_QUEUE_FAMILY_IGNORED, // deUint32 destQueueFamilyIndex;
610 buffer->object(), // VkBuffer buffer;
611 0ull, // VkDeviceSize offset;
612 bufferSizeBytes, // VkDeviceSize size;
615 const VkBufferMemoryBarrier computeFinishBarrier =
617 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
618 DE_NULL, // const void* pNext;
619 VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags srcAccessMask;
620 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
621 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
622 VK_QUEUE_FAMILY_IGNORED, // deUint32 destQueueFamilyIndex;
623 buffer->object(), // VkBuffer buffer;
624 0ull, // VkDeviceSize offset;
625 bufferSizeBytes, // VkDeviceSize size;
628 std::vector<VkShaderModuleSp> shaderModule;
629 std::vector<VkPipelineSp> pipeline;
630 for(size_t parametersNdx = 0u; parametersNdx < m_parameters.size(); ++parametersNdx)
632 shaderModule.push_back(VkShaderModuleSp(new Unique<VkShaderModule>(createShaderModule(vk, device, m_context.getBinaryCollection().get(m_parameters[parametersNdx].shaderName), (VkShaderModuleCreateFlags)0u))));
633 const VkPipelineShaderStageCreateInfo pipelineShaderStageParams =
635 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
636 DE_NULL, // const void* pNext;
637 0u, // VkPipelineShaderStageCreateFlags flags;
638 VK_SHADER_STAGE_COMPUTE_BIT, // VkShaderStageFlagBits stage;
639 shaderModule.back().get()->get(), // VkShaderModule module;
640 "main", // const char* pName;
641 DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
644 const VkComputePipelineCreateInfo pipelineCreateInfo =
646 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, // VkStructureType sType;
647 DE_NULL, // const void* pNext;
648 0u, // VkPipelineCreateFlags flags;
649 pipelineShaderStageParams, // VkPipelineShaderStageCreateInfo stage;
650 pipelineLayout, // VkPipelineLayout layout;
651 DE_NULL, // VkPipeline basePipelineHandle;
652 0, // deInt32 basePipelineIndex;
654 pipeline.push_back(VkPipelineSp(new Unique<VkPipeline>(createComputePipeline(vk, device, DE_NULL , &pipelineCreateInfo))));
657 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
658 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
660 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT));
662 clearBuffer(vk, device, buffer, bufferSizeBytes);
663 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT);
664 vk.cmdBindDescriptorSets(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipelineLayout, 0u, 1u, &descriptorSet, 0u, DE_NULL);
665 for(size_t parametersNdx = 1; parametersNdx < m_parameters.size(); ++parametersNdx)
667 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline[parametersNdx].get()->get());
668 vk.cmdDispatch(*secondaryCmdBuffer, m_parameters[parametersNdx].groupSize.x(), m_parameters[parametersNdx].groupSize.y(), m_parameters[parametersNdx].groupSize.z());
670 vk.cmdPipelineBarrier(*secondaryCmdBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
671 (VkDependencyFlags)0u, 0u, (const VkMemoryBarrier*)DE_NULL, 1u, &computeShaderWriteBarrier, 0u, (const VkImageMemoryBarrier*)DE_NULL);
673 VK_CHECK(vk.endCommandBuffer(*secondaryCmdBuffer));
675 beginCommandBuffer(vk, *primaryCmdBuffer);
676 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
677 vk.cmdBindDescriptorSets(*primaryCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipelineLayout, 0u, 1u, &descriptorSet, 0u, DE_NULL);
678 vk.cmdBindPipeline(*primaryCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline[0].get()->get());
680 vk.cmdBeginQuery(*primaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
681 vk.cmdDispatch(*primaryCmdBuffer, m_parameters[0].groupSize.x(), m_parameters[0].groupSize.y(), m_parameters[0].groupSize.z());
683 vk.cmdPipelineBarrier(*primaryCmdBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
684 (VkDependencyFlags)0u, 0u, (const VkMemoryBarrier*)DE_NULL, 1u, &computeShaderWriteBarrier, 0u, (const VkImageMemoryBarrier*)DE_NULL);
686 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
688 vk.cmdPipelineBarrier(*primaryCmdBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_HOST_BIT,
689 (VkDependencyFlags)0u, 0u, (const VkMemoryBarrier*)DE_NULL, 1u, &computeFinishBarrier, 0u, (const VkImageMemoryBarrier*)DE_NULL);
691 vk.cmdEndQuery(*primaryCmdBuffer, *queryPool, 0u);
692 VK_CHECK(vk.endCommandBuffer(*primaryCmdBuffer));
694 // Wait for completion
695 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
696 return checkResult(buffer, bufferSizeBytes, *queryPool);
699 class GraphicBasicTestInstance : public StatisticQueryTestInstance
704 VertexData (const tcu::Vec4 position_, const tcu::Vec4 color_)
705 : position (position_)
711 struct ParametersGraphic
713 ParametersGraphic (const VkQueryPipelineStatisticFlags queryStatisticFlags_, const VkPrimitiveTopology primitiveTopology_)
714 : queryStatisticFlags (queryStatisticFlags_)
715 , primitiveTopology (primitiveTopology_)
717 VkQueryPipelineStatisticFlags queryStatisticFlags;
718 VkPrimitiveTopology primitiveTopology;
720 GraphicBasicTestInstance (vkt::Context& context,
721 const std::vector<VertexData>& data,
722 const ParametersGraphic& parametersGraphic);
723 tcu::TestStatus iterate (void);
725 de::SharedPtr<Buffer> creatAndFillVertexBuffer (void);
726 virtual void createPipeline (void) = 0;
727 void creatColorAttachmentAndRenderPass (void);
728 bool checkImage (void);
729 virtual tcu::TestStatus executeTest (void) = 0;
730 virtual tcu::TestStatus checkResult (VkQueryPool queryPool) = 0;
731 virtual void draw (VkCommandBuffer cmdBuffer) = 0;
733 const VkFormat m_colorAttachmentFormat;
734 de::SharedPtr<Image> m_colorAttachmentImage;
735 de::SharedPtr<Image> m_depthImage;
736 Move<VkImageView> m_attachmentView;
737 Move<VkImageView> m_depthiew;
738 Move<VkRenderPass> m_renderPass;
739 Move<VkFramebuffer> m_framebuffer;
740 Move<VkPipeline> m_pipeline;
741 Move<VkPipelineLayout> m_pipelineLayout;
742 const std::vector<VertexData>& m_data;
743 const ParametersGraphic& m_parametersGraphic;
746 GraphicBasicTestInstance::GraphicBasicTestInstance (vkt::Context& context,
747 const std::vector<VertexData>& data,
748 const ParametersGraphic& parametersGraphic)
749 : StatisticQueryTestInstance (context)
750 , m_colorAttachmentFormat (VK_FORMAT_R8G8B8A8_UNORM)
752 , m_parametersGraphic (parametersGraphic)
756 tcu::TestStatus GraphicBasicTestInstance::iterate (void)
759 creatColorAttachmentAndRenderPass();
761 return executeTest();
764 de::SharedPtr<Buffer> GraphicBasicTestInstance::creatAndFillVertexBuffer (void)
766 const DeviceInterface& vk = m_context.getDeviceInterface();
767 const VkDevice device = m_context.getDevice();
769 const VkDeviceSize dataSize = static_cast<VkDeviceSize>(deAlignSize(static_cast<size_t>( m_data.size() * sizeof(VertexData)),
770 static_cast<size_t>(m_context.getDeviceProperties().limits.nonCoherentAtomSize)));
772 de::SharedPtr<Buffer> vertexBuffer = Buffer::createAndAlloc(vk, device, BufferCreateInfo(dataSize,
773 VK_BUFFER_USAGE_VERTEX_BUFFER_BIT), m_context.getDefaultAllocator(), MemoryRequirement::HostVisible);
775 deUint8* ptr = reinterpret_cast<deUint8*>(vertexBuffer->getBoundMemory().getHostPtr());
776 deMemcpy(ptr, &m_data[0], static_cast<size_t>( m_data.size() * sizeof(VertexData)));
778 flushMappedMemoryRange(vk, device, vertexBuffer->getBoundMemory().getMemory(), vertexBuffer->getBoundMemory().getOffset(), dataSize);
782 void GraphicBasicTestInstance::creatColorAttachmentAndRenderPass (void)
784 const DeviceInterface& vk = m_context.getDeviceInterface();
785 const VkDevice device = m_context.getDevice();
788 VkExtent3D imageExtent =
795 const ImageCreateInfo colorImageCreateInfo (VK_IMAGE_TYPE_2D, m_colorAttachmentFormat, imageExtent, 1, 1, VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_TILING_OPTIMAL,
796 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT);
798 m_colorAttachmentImage = Image::createAndAlloc(vk, device, colorImageCreateInfo, m_context.getDefaultAllocator());
800 const ImageViewCreateInfo attachmentViewInfo (m_colorAttachmentImage->object(), VK_IMAGE_VIEW_TYPE_2D, m_colorAttachmentFormat);
801 m_attachmentView = createImageView(vk, device, &attachmentViewInfo);
803 ImageCreateInfo depthImageCreateInfo (vk::VK_IMAGE_TYPE_2D, VK_FORMAT_D16_UNORM, imageExtent, 1, 1, vk::VK_SAMPLE_COUNT_1_BIT, vk::VK_IMAGE_TILING_OPTIMAL,
804 vk::VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
806 m_depthImage = Image::createAndAlloc(vk, device, depthImageCreateInfo, m_context.getDefaultAllocator());
808 // Construct a depth view from depth image
809 const ImageViewCreateInfo depthViewInfo (m_depthImage->object(), vk::VK_IMAGE_VIEW_TYPE_2D, VK_FORMAT_D16_UNORM);
810 m_depthiew = vk::createImageView(vk, device, &depthViewInfo);
814 // Renderpass and Framebuffer
815 RenderPassCreateInfo renderPassCreateInfo;
816 renderPassCreateInfo.addAttachment(AttachmentDescription(m_colorAttachmentFormat, // format
817 VK_SAMPLE_COUNT_1_BIT, // samples
818 VK_ATTACHMENT_LOAD_OP_CLEAR, // loadOp
819 VK_ATTACHMENT_STORE_OP_STORE , // storeOp
820 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // stencilLoadOp
821 VK_ATTACHMENT_STORE_OP_STORE , // stencilLoadOp
822 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // initialLauout
823 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)); // finalLayout
825 renderPassCreateInfo.addAttachment(AttachmentDescription(VK_FORMAT_D16_UNORM, // format
826 vk::VK_SAMPLE_COUNT_1_BIT, // samples
827 vk::VK_ATTACHMENT_LOAD_OP_CLEAR, // loadOp
828 vk::VK_ATTACHMENT_STORE_OP_DONT_CARE, // storeOp
829 vk::VK_ATTACHMENT_LOAD_OP_DONT_CARE, // stencilLoadOp
830 vk::VK_ATTACHMENT_STORE_OP_DONT_CARE, // stencilLoadOp
831 vk::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // initialLauout
832 vk::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)); // finalLayout
834 const VkAttachmentReference colorAttachmentReference =
837 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // layout
840 const VkAttachmentReference depthAttachmentReference =
843 vk::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL // layout
846 const VkSubpassDescription subpass =
848 (VkSubpassDescriptionFlags) 0, //VkSubpassDescriptionFlags flags;
849 VK_PIPELINE_BIND_POINT_GRAPHICS, //VkPipelineBindPoint pipelineBindPoint;
850 0u, //deUint32 inputAttachmentCount;
851 DE_NULL, //const VkAttachmentReference* pInputAttachments;
852 1u, //deUint32 colorAttachmentCount;
853 &colorAttachmentReference, //const VkAttachmentReference* pColorAttachments;
854 DE_NULL, //const VkAttachmentReference* pResolveAttachments;
855 &depthAttachmentReference, //const VkAttachmentReference* pDepthStencilAttachment;
856 0u, //deUint32 preserveAttachmentCount;
857 DE_NULL, //const deUint32* pPreserveAttachments;
860 renderPassCreateInfo.addSubpass(subpass);
861 m_renderPass = createRenderPass(vk, device, &renderPassCreateInfo);
863 std::vector<vk::VkImageView> attachments(2);
864 attachments[0] = *m_attachmentView;
865 attachments[1] = *m_depthiew;
867 FramebufferCreateInfo framebufferCreateInfo(*m_renderPass, attachments, WIDTH, HEIGHT, 1);
868 m_framebuffer = createFramebuffer(vk, device, &framebufferCreateInfo);
872 bool GraphicBasicTestInstance::checkImage (void)
874 const VkQueue queue = m_context.getUniversalQueue();
875 const VkOffset3D zeroOffset = { 0, 0, 0 };
876 const tcu::ConstPixelBufferAccess renderedFrame = m_colorAttachmentImage->readSurface(queue, m_context.getDefaultAllocator(),
877 VK_IMAGE_LAYOUT_GENERAL, zeroOffset, WIDTH, HEIGHT, VK_IMAGE_ASPECT_COLOR_BIT);
879 tcu::Texture2D referenceFrame (mapVkFormat(m_colorAttachmentFormat), WIDTH, HEIGHT);
880 referenceFrame.allocLevel(0);
882 for (int y = 0; y < HEIGHT/2; ++y)
883 for (int x = 0; x < WIDTH/2; ++x)
884 referenceFrame.getLevel(0).setPixel(m_data[colorNdx].color, x, y);
887 for (int y = HEIGHT/2; y < HEIGHT; ++y)
888 for (int x = 0; x < WIDTH/2; ++x)
889 referenceFrame.getLevel(0).setPixel(m_data[colorNdx].color, x, y);
892 for (int y = 0; y < HEIGHT/2; ++y)
893 for (int x = WIDTH/2; x < WIDTH; ++x)
894 referenceFrame.getLevel(0).setPixel(m_data[colorNdx].color, x, y);
897 for (int y = HEIGHT/2; y < HEIGHT; ++y)
898 for (int x = WIDTH/2; x < WIDTH; ++x)
899 referenceFrame.getLevel(0).setPixel(m_data[colorNdx].color, x, y);
901 return tcu::floatThresholdCompare(m_context.getTestContext().getLog(), "Result", "Image comparison result", referenceFrame.getLevel(0), renderedFrame, tcu::Vec4(0.01f), tcu::COMPARE_LOG_ON_ERROR);
904 class VertexShaderTestInstance : public GraphicBasicTestInstance
907 VertexShaderTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
909 virtual void createPipeline (void);
910 virtual tcu::TestStatus executeTest (void);
911 virtual tcu::TestStatus checkResult (VkQueryPool queryPool);
912 void draw (VkCommandBuffer cmdBuffer);
915 VertexShaderTestInstance::VertexShaderTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
916 : GraphicBasicTestInstance (context, data, parametersGraphic)
920 void VertexShaderTestInstance::createPipeline (void)
922 const DeviceInterface& vk = m_context.getDeviceInterface();
923 const VkDevice device = m_context.getDevice();
926 Unique<VkShaderModule> vs(createShaderModule(vk, device, m_context.getBinaryCollection().get("vertex"), 0));
927 Unique<VkShaderModule> fs(createShaderModule(vk, device, m_context.getBinaryCollection().get("fragment"), 0));
929 const PipelineCreateInfo::ColorBlendState::Attachment attachmentState;
931 const PipelineLayoutCreateInfo pipelineLayoutCreateInfo;
932 m_pipelineLayout = createPipelineLayout(vk, device, &pipelineLayoutCreateInfo);
934 const VkVertexInputBindingDescription vertexInputBindingDescription =
937 static_cast<deUint32>(sizeof(VertexData)), // stride;
938 VK_VERTEX_INPUT_RATE_VERTEX // inputRate
941 const VkVertexInputAttributeDescription vertexInputAttributeDescriptions[] =
946 VK_FORMAT_R32G32B32A32_SFLOAT,
948 }, // VertexElementData::position
952 VK_FORMAT_R32G32B32A32_SFLOAT,
953 static_cast<deUint32>(sizeof(tcu::Vec4))
954 }, // VertexElementData::color
957 const VkPipelineVertexInputStateCreateInfo vf_info =
959 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // pNext;
961 0u, // vertexBindingDescriptionCount;
962 1u, // pVertexBindingDescriptions;
963 &vertexInputBindingDescription, // vertexAttributeDescriptionCount;
964 2u, // pVertexAttributeDescriptions;
965 vertexInputAttributeDescriptions
968 PipelineCreateInfo pipelineCreateInfo(*m_pipelineLayout, *m_renderPass, 0, (VkPipelineCreateFlags)0);
969 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*vs, "main", VK_SHADER_STAGE_VERTEX_BIT));
970 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*fs, "main", VK_SHADER_STAGE_FRAGMENT_BIT));
971 pipelineCreateInfo.addState(PipelineCreateInfo::DepthStencilState());
972 pipelineCreateInfo.addState(PipelineCreateInfo::InputAssemblerState(m_parametersGraphic.primitiveTopology));
973 pipelineCreateInfo.addState(PipelineCreateInfo::ColorBlendState(1, &attachmentState));
975 const VkViewport viewport =
979 WIDTH, // float width;
980 HEIGHT, // float height;
981 0.0f, // float minDepth;
982 1.0f // float maxDepth;
985 const VkRect2D scissor =
990 }, // VkOffset2D offset;
992 WIDTH, // deInt32 width;
993 HEIGHT, // deInt32 height
994 }, // VkExtent2D extent;
996 pipelineCreateInfo.addState(PipelineCreateInfo::ViewportState(1u, std::vector<VkViewport>(1, viewport), std::vector<VkRect2D>(1, scissor)));
997 pipelineCreateInfo.addState(PipelineCreateInfo::DepthStencilState());
998 pipelineCreateInfo.addState(PipelineCreateInfo::RasterizerState());
999 pipelineCreateInfo.addState(PipelineCreateInfo::MultiSampleState());
1000 pipelineCreateInfo.addState(vf_info);
1001 m_pipeline = createGraphicsPipeline(vk, device, DE_NULL, &pipelineCreateInfo);
1004 tcu::TestStatus VertexShaderTestInstance::executeTest (void)
1006 const DeviceInterface& vk = m_context.getDeviceInterface();
1007 const VkDevice device = m_context.getDevice();
1008 const VkQueue queue = m_context.getUniversalQueue();
1009 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1011 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1012 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1013 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1015 const VkDeviceSize vertexBufferOffset = 0u;
1016 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1017 const VkBuffer vertexBuffer = vertexBufferSp->object();
1019 const Unique<VkCommandBuffer> cmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1021 beginCommandBuffer(vk, *cmdBuffer);
1023 const VkRect2D renderArea = { { 0, 0 }, { WIDTH, HEIGHT } };
1024 std::vector<VkClearValue> renderPassClearValues (2);
1025 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1026 const RenderPassBeginInfo renderPassBegin (*m_renderPass, *m_framebuffer, renderArea, renderPassClearValues);
1028 transition2DImage(vk, *cmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1029 transition2DImage(vk, *cmdBuffer, m_depthImage->object(), VK_IMAGE_ASPECT_DEPTH_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT);
1031 vk.cmdResetQueryPool(*cmdBuffer, *queryPool, 0u, 1u);
1033 vk.cmdBeginRenderPass(*cmdBuffer, &renderPassBegin, VK_SUBPASS_CONTENTS_INLINE);
1035 vk.cmdBeginQuery(*cmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1036 vk.cmdBindVertexBuffers(*cmdBuffer, 0, 1, &vertexBuffer, &vertexBufferOffset);
1037 vk.cmdBindPipeline(*cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1039 vk.cmdEndQuery(*cmdBuffer, *queryPool, 0u);
1041 vk.cmdEndRenderPass(*cmdBuffer);
1043 transition2DImage(vk, *cmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL, 0u, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1045 vk.endCommandBuffer(*cmdBuffer);
1047 // Wait for completion
1048 submitCommandsAndWait(vk, device, queue, *cmdBuffer);
1049 return checkResult (*queryPool);
1052 tcu::TestStatus VertexShaderTestInstance::checkResult (VkQueryPool queryPool)
1054 const DeviceInterface& vk = m_context.getDeviceInterface();
1055 const VkDevice device = m_context.getDevice();
1056 deUint64 result = 0u;
1057 deUint64 expectedMin = 0u;
1058 deUint64 expectedMax = 0u;
1059 switch(m_parametersGraphic.queryStatisticFlags)
1061 case VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT:
1062 expectedMax = expectedMin = 16u;
1064 case VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT:
1065 expectedMin = m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST ? 15u :
1066 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY ? 8u :
1067 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY ? 14u :
1068 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY ? 6u :
1069 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY ? 8u :
1071 expectedMax = m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY ? 12u : 16u;
1073 case VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT:
1074 expectedMax = expectedMin = m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST ? 16u :
1075 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST ? 8u :
1076 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP ? 15u :
1077 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST ? 5u :
1078 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ? 8u :
1079 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN ? 14u :
1080 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY ? 4u :
1081 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY ? 13u :
1082 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY ? 2u :
1083 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY ? 6u :
1086 case VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT:
1087 expectedMin = m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST ? 9u :
1088 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST ? 192u :
1089 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP ? 448u :
1090 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST ? 2016u :
1091 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ? 4096u :
1092 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN ? 10208u :
1093 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY ? 128u :
1094 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY ? 416u :
1095 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY ? 992u :
1096 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY ? 3072u :
1098 expectedMax = 4u * expectedMin;
1105 VK_CHECK(vk.getQueryPoolResults(device, queryPool, 0u, 1u, sizeof(deUint64), &result, 0u, VK_QUERY_RESULT_64_BIT));
1106 if (result < expectedMin || result > expectedMax)
1107 return tcu::TestStatus::fail("QueryPoolResults incorrect");
1109 if (m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP && !checkImage())
1110 return tcu::TestStatus::fail("Result image doesn't match expected image.");
1112 return tcu::TestStatus::pass("Pass");
1115 void VertexShaderTestInstance::draw (VkCommandBuffer cmdBuffer)
1117 const DeviceInterface& vk = m_context.getDeviceInterface();
1118 switch(m_parametersGraphic.primitiveTopology)
1120 case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
1121 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
1122 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
1123 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
1124 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
1125 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
1126 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
1127 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
1128 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
1129 vk.cmdDraw(cmdBuffer, 16u, 1u, 0u, 0u);
1131 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
1132 vk.cmdDraw(cmdBuffer, 4u, 1u, 0u, 0u);
1133 vk.cmdDraw(cmdBuffer, 4u, 1u, 4u, 1u);
1134 vk.cmdDraw(cmdBuffer, 4u, 1u, 8u, 2u);
1135 vk.cmdDraw(cmdBuffer, 4u, 1u, 12u, 3u);
1143 class VertexShaderSecondaryTestInstance : public VertexShaderTestInstance
1146 VertexShaderSecondaryTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1148 virtual tcu::TestStatus executeTest (void);
1151 VertexShaderSecondaryTestInstance::VertexShaderSecondaryTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1152 : VertexShaderTestInstance (context, data, parametersGraphic)
1156 tcu::TestStatus VertexShaderSecondaryTestInstance::executeTest (void)
1158 const DeviceInterface& vk = m_context.getDeviceInterface();
1159 const VkDevice device = m_context.getDevice();
1160 const VkQueue queue = m_context.getUniversalQueue();
1161 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1163 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1164 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1165 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1167 const VkDeviceSize vertexBufferOffset = 0u;
1168 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1169 const VkBuffer vertexBuffer = vertexBufferSp->object();
1171 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1172 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
1174 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, m_parametersGraphic.queryStatisticFlags, *m_renderPass, *m_framebuffer, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT);
1175 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1176 vk.cmdBeginQuery(*secondaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1177 vk.cmdBindVertexBuffers(*secondaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1178 draw(*secondaryCmdBuffer);
1179 vk.cmdEndQuery(*secondaryCmdBuffer, *queryPool, 0u);
1180 vk.endCommandBuffer(*secondaryCmdBuffer);
1182 beginCommandBuffer(vk, *primaryCmdBuffer);
1184 const VkRect2D renderArea = { { 0, 0 }, { WIDTH, HEIGHT } };
1185 std::vector<VkClearValue> renderPassClearValues (2);
1186 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1187 const RenderPassBeginInfo renderPassBegin (*m_renderPass, *m_framebuffer, renderArea, renderPassClearValues);
1189 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1190 transition2DImage(vk, *primaryCmdBuffer, m_depthImage->object(), VK_IMAGE_ASPECT_DEPTH_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT);
1192 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
1194 vk.cmdBeginRenderPass(*primaryCmdBuffer, &renderPassBegin, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
1195 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
1196 vk.cmdEndRenderPass(*primaryCmdBuffer);
1197 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL, 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1199 vk.endCommandBuffer(*primaryCmdBuffer);
1201 // Wait for completion
1202 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
1203 return checkResult (*queryPool);
1206 class VertexShaderSecondaryInheritedTestInstance : public VertexShaderTestInstance
1209 VertexShaderSecondaryInheritedTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1211 void checkExtensions (void);
1212 virtual tcu::TestStatus executeTest (void);
1215 VertexShaderSecondaryInheritedTestInstance::VertexShaderSecondaryInheritedTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1216 : VertexShaderTestInstance (context, data, parametersGraphic)
1220 void VertexShaderSecondaryInheritedTestInstance::checkExtensions (void)
1222 StatisticQueryTestInstance::checkExtensions();
1223 if (!m_context.getDeviceFeatures().inheritedQueries)
1224 throw tcu::NotSupportedError("Inherited queries are not supported");
1227 tcu::TestStatus VertexShaderSecondaryInheritedTestInstance::executeTest (void)
1229 const DeviceInterface& vk = m_context.getDeviceInterface();
1230 const VkDevice device = m_context.getDevice();
1231 const VkQueue queue = m_context.getUniversalQueue();
1232 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1234 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1235 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1236 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1238 const VkDeviceSize vertexBufferOffset = 0u;
1239 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1240 const VkBuffer vertexBuffer = vertexBufferSp->object();
1242 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1243 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
1245 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, m_parametersGraphic.queryStatisticFlags, *m_renderPass, *m_framebuffer, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT);
1246 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1247 vk.cmdBindVertexBuffers(*secondaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1248 draw(*secondaryCmdBuffer);
1249 vk.endCommandBuffer(*secondaryCmdBuffer);
1251 beginCommandBuffer(vk, *primaryCmdBuffer);
1253 const VkRect2D renderArea = { { 0, 0 }, { WIDTH, HEIGHT } };
1254 std::vector<VkClearValue> renderPassClearValues (2);
1255 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1256 const RenderPassBeginInfo renderPassBegin (*m_renderPass, *m_framebuffer, renderArea, renderPassClearValues);
1258 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1259 transition2DImage(vk, *primaryCmdBuffer, m_depthImage->object(), VK_IMAGE_ASPECT_DEPTH_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT);
1261 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
1262 vk.cmdBeginQuery(*primaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1264 vk.cmdBeginRenderPass(*primaryCmdBuffer, &renderPassBegin, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
1265 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
1266 vk.cmdEndRenderPass(*primaryCmdBuffer);
1267 vk.cmdEndQuery(*primaryCmdBuffer, *queryPool, 0u);
1268 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL, 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1270 vk.endCommandBuffer(*primaryCmdBuffer);
1272 // Wait for completion
1273 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
1274 return checkResult (*queryPool);
1277 class GeometryShaderTestInstance : public GraphicBasicTestInstance
1280 GeometryShaderTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1282 virtual void checkExtensions (void);
1283 virtual void createPipeline (void);
1284 virtual tcu::TestStatus executeTest (void);
1285 tcu::TestStatus checkResult (VkQueryPool queryPool);
1286 void draw (VkCommandBuffer cmdBuffer);
1289 GeometryShaderTestInstance::GeometryShaderTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1290 : GraphicBasicTestInstance (context, data, parametersGraphic)
1294 void GeometryShaderTestInstance::checkExtensions (void)
1296 StatisticQueryTestInstance::checkExtensions();
1297 if (!m_context.getDeviceFeatures().geometryShader)
1298 throw tcu::NotSupportedError("Geometry shader are not supported");
1301 void GeometryShaderTestInstance::createPipeline (void)
1303 const DeviceInterface& vk = m_context.getDeviceInterface();
1304 const VkDevice device = m_context.getDevice();
1307 Unique<VkShaderModule> vs(createShaderModule(vk, device, m_context.getBinaryCollection().get("vertex"), (VkShaderModuleCreateFlags)0));
1308 Unique<VkShaderModule> gs(createShaderModule(vk, device, m_context.getBinaryCollection().get("geometry"), (VkShaderModuleCreateFlags)0));
1309 Unique<VkShaderModule> fs(createShaderModule(vk, device, m_context.getBinaryCollection().get("fragment"), (VkShaderModuleCreateFlags)0));
1311 const PipelineCreateInfo::ColorBlendState::Attachment attachmentState;
1313 const PipelineLayoutCreateInfo pipelineLayoutCreateInfo;
1314 m_pipelineLayout = createPipelineLayout(vk, device, &pipelineLayoutCreateInfo);
1316 const VkVertexInputBindingDescription vertexInputBindingDescription =
1319 static_cast<deUint32>(sizeof(VertexData)), // stride;
1320 VK_VERTEX_INPUT_RATE_VERTEX // inputRate
1323 const VkVertexInputAttributeDescription vertexInputAttributeDescriptions[] =
1328 VK_FORMAT_R32G32B32A32_SFLOAT,
1330 }, // VertexElementData::position
1334 VK_FORMAT_R32G32B32A32_SFLOAT,
1335 static_cast<deUint32>(sizeof(tcu::Vec4))
1336 }, // VertexElementData::color
1339 const VkPipelineVertexInputStateCreateInfo vf_info =
1341 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // pNext;
1343 0u, // vertexBindingDescriptionCount;
1344 1, // pVertexBindingDescriptions;
1345 &vertexInputBindingDescription, // vertexAttributeDescriptionCount;
1346 2, // pVertexAttributeDescriptions;
1347 vertexInputAttributeDescriptions
1350 PipelineCreateInfo pipelineCreateInfo(*m_pipelineLayout, *m_renderPass, 0, (VkPipelineCreateFlags)0);
1351 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*vs, "main", VK_SHADER_STAGE_VERTEX_BIT));
1352 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*gs, "main", VK_SHADER_STAGE_GEOMETRY_BIT));
1353 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*fs, "main", VK_SHADER_STAGE_FRAGMENT_BIT));
1354 pipelineCreateInfo.addState(PipelineCreateInfo::InputAssemblerState(m_parametersGraphic.primitiveTopology));
1355 pipelineCreateInfo.addState(PipelineCreateInfo::ColorBlendState(1, &attachmentState));
1357 const VkViewport viewport =
1361 WIDTH, // float width;
1362 HEIGHT, // float height;
1363 0.0f, // float minDepth;
1364 1.0f // float maxDepth;
1367 const VkRect2D scissor =
1372 }, // VkOffset2D offset;
1374 WIDTH, // deInt32 width;
1375 HEIGHT, // deInt32 height
1376 }, // VkExtent2D extent;
1378 pipelineCreateInfo.addState(PipelineCreateInfo::ViewportState(1, std::vector<VkViewport>(1, viewport), std::vector<VkRect2D>(1, scissor)));
1380 if (m_context.getDeviceFeatures().depthBounds)
1381 pipelineCreateInfo.addState(PipelineCreateInfo::DepthStencilState(true, true, VK_COMPARE_OP_GREATER_OR_EQUAL, true));
1383 pipelineCreateInfo.addState(PipelineCreateInfo::DepthStencilState());
1385 pipelineCreateInfo.addState(PipelineCreateInfo::RasterizerState(false));
1386 pipelineCreateInfo.addState(PipelineCreateInfo::MultiSampleState());
1387 pipelineCreateInfo.addState(vf_info);
1388 m_pipeline = createGraphicsPipeline(vk, device, DE_NULL, &pipelineCreateInfo);
1391 tcu::TestStatus GeometryShaderTestInstance::executeTest (void)
1393 const DeviceInterface& vk = m_context.getDeviceInterface();
1394 const VkDevice device = m_context.getDevice();
1395 const VkQueue queue = m_context.getUniversalQueue();
1396 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1398 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1399 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1400 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1402 const VkDeviceSize vertexBufferOffset = 0u;
1403 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1404 const VkBuffer vertexBuffer = vertexBufferSp->object();
1406 const Unique<VkCommandBuffer> cmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1408 beginCommandBuffer(vk, *cmdBuffer);
1410 const VkRect2D renderArea = { { 0, 0 }, { WIDTH, HEIGHT } };
1411 std::vector<VkClearValue> renderPassClearValues (2);
1412 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1413 const RenderPassBeginInfo renderPassBegin (*m_renderPass, *m_framebuffer, renderArea, renderPassClearValues);
1415 transition2DImage(vk, *cmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1416 transition2DImage(vk, *cmdBuffer, m_depthImage->object(), VK_IMAGE_ASPECT_DEPTH_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT);
1418 vk.cmdResetQueryPool(*cmdBuffer, *queryPool, 0u, 1u);
1420 vk.cmdBeginRenderPass(*cmdBuffer, &renderPassBegin, VK_SUBPASS_CONTENTS_INLINE);
1422 vk.cmdBeginQuery(*cmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1423 vk.cmdBindVertexBuffers(*cmdBuffer, 0, 1, &vertexBuffer, &vertexBufferOffset);
1424 vk.cmdBindPipeline(*cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1428 vk.cmdEndQuery(*cmdBuffer, *queryPool, 0u);
1430 vk.cmdEndRenderPass(*cmdBuffer);
1432 transition2DImage(vk, *cmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL, 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1434 vk.endCommandBuffer(*cmdBuffer);
1436 // Wait for completion
1437 submitCommandsAndWait(vk, device, queue, *cmdBuffer);
1438 return checkResult(*queryPool);
1441 tcu::TestStatus GeometryShaderTestInstance::checkResult (VkQueryPool queryPool)
1443 const DeviceInterface& vk = m_context.getDeviceInterface();
1444 const VkDevice device = m_context.getDevice();
1445 deUint64 result = 0u;
1446 deUint64 expected = 0u;
1448 switch(m_parametersGraphic.queryStatisticFlags)
1450 case VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT:
1451 expected = m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST ? 16u :
1452 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST ? 8u :
1453 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP ? 15u :
1454 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST ? 4u :
1455 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ? 4u :
1456 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN ? 14u :
1457 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY ? 4u :
1458 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY ? 13u :
1459 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY ? 2u :
1460 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY ? 6u :
1463 case VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT:
1464 case VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT:
1465 case VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT:
1466 expected = m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST ? 112u :
1467 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST ? 32u :
1468 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP ? 60u :
1469 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST ? 8u :
1470 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ? 8u :
1471 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN ? 28u :
1472 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY ? 16u :
1473 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY ? 52u :
1474 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY ? 4u :
1475 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY ? 12u :
1482 VK_CHECK(vk.getQueryPoolResults(device, queryPool, 0u, 1u, sizeof(deUint64), &result, 0u, VK_QUERY_RESULT_64_BIT));
1483 if (expected != result)
1484 return tcu::TestStatus::fail("QueryPoolResults incorrect");
1486 if ( (m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST || m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ) && !checkImage())
1487 return tcu::TestStatus::fail("Result image doesn't match expected image.");
1489 return tcu::TestStatus::pass("Pass");
1492 void GeometryShaderTestInstance::draw (VkCommandBuffer cmdBuffer)
1494 const DeviceInterface& vk = m_context.getDeviceInterface();
1495 if (m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ||
1496 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST)
1498 vk.cmdDraw(cmdBuffer, 3u, 1u, 0u, 1u);
1499 vk.cmdDraw(cmdBuffer, 3u, 1u, 4u, 1u);
1500 vk.cmdDraw(cmdBuffer, 3u, 1u, 8u, 2u);
1501 vk.cmdDraw(cmdBuffer, 3u, 1u, 12u, 3u);
1505 vk.cmdDraw(cmdBuffer, 16u, 1u, 0u, 0u);
1509 class GeometryShaderSecondaryTestInstance : public GeometryShaderTestInstance
1512 GeometryShaderSecondaryTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1514 virtual tcu::TestStatus executeTest (void);
1517 GeometryShaderSecondaryTestInstance::GeometryShaderSecondaryTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1518 : GeometryShaderTestInstance (context, data, parametersGraphic)
1522 tcu::TestStatus GeometryShaderSecondaryTestInstance::executeTest (void)
1524 const DeviceInterface& vk = m_context.getDeviceInterface();
1525 const VkDevice device = m_context.getDevice();
1526 const VkQueue queue = m_context.getUniversalQueue();
1527 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1529 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1530 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1531 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1533 const VkDeviceSize vertexBufferOffset = 0;
1534 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1535 const VkBuffer vertexBuffer = vertexBufferSp->object();
1537 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1538 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
1540 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, m_parametersGraphic.queryStatisticFlags, *m_renderPass, *m_framebuffer, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT);
1541 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1542 vk.cmdBeginQuery(*secondaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1543 vk.cmdBindVertexBuffers(*secondaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1544 draw(*secondaryCmdBuffer);
1545 vk.cmdEndQuery(*secondaryCmdBuffer, *queryPool, 0u);
1546 vk.endCommandBuffer(*secondaryCmdBuffer);
1548 beginCommandBuffer(vk, *primaryCmdBuffer);
1550 const VkRect2D renderArea = { { 0, 0 }, { WIDTH, HEIGHT } };
1551 std::vector<VkClearValue> renderPassClearValues (2);
1552 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1553 const RenderPassBeginInfo renderPassBegin (*m_renderPass, *m_framebuffer, renderArea, renderPassClearValues);
1555 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1556 transition2DImage(vk, *primaryCmdBuffer, m_depthImage->object(), VK_IMAGE_ASPECT_DEPTH_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT);
1558 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
1559 vk.cmdBeginRenderPass(*primaryCmdBuffer, &renderPassBegin, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
1560 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
1561 vk.cmdEndRenderPass(*primaryCmdBuffer);
1563 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL, 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1565 vk.endCommandBuffer(*primaryCmdBuffer);
1567 // Wait for completion
1568 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
1569 return checkResult(*queryPool);
1572 class GeometryShaderSecondaryInheritedTestInstance : public GeometryShaderTestInstance
1575 GeometryShaderSecondaryInheritedTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1577 void checkExtensions (void);
1578 virtual tcu::TestStatus executeTest (void);
1581 GeometryShaderSecondaryInheritedTestInstance::GeometryShaderSecondaryInheritedTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1582 : GeometryShaderTestInstance (context, data, parametersGraphic)
1586 void GeometryShaderSecondaryInheritedTestInstance::checkExtensions (void)
1588 GeometryShaderTestInstance::checkExtensions();
1589 if (!m_context.getDeviceFeatures().inheritedQueries)
1590 throw tcu::NotSupportedError("Inherited queries are not supported");
1593 tcu::TestStatus GeometryShaderSecondaryInheritedTestInstance::executeTest (void)
1595 const DeviceInterface& vk = m_context.getDeviceInterface();
1596 const VkDevice device = m_context.getDevice();
1597 const VkQueue queue = m_context.getUniversalQueue();
1598 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1600 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1601 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1602 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1604 const VkDeviceSize vertexBufferOffset = 0u;
1605 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1606 const VkBuffer vertexBuffer = vertexBufferSp->object();
1608 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1609 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
1611 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, m_parametersGraphic.queryStatisticFlags, *m_renderPass, *m_framebuffer, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT);
1612 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1613 vk.cmdBindVertexBuffers(*secondaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1614 draw(*secondaryCmdBuffer);
1615 vk.endCommandBuffer(*secondaryCmdBuffer);
1617 beginCommandBuffer(vk, *primaryCmdBuffer);
1619 const VkRect2D renderArea = { { 0, 0 }, { WIDTH, HEIGHT } };
1620 std::vector<VkClearValue> renderPassClearValues (2);
1621 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1622 const RenderPassBeginInfo renderPassBegin (*m_renderPass, *m_framebuffer, renderArea, renderPassClearValues);
1624 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1625 transition2DImage(vk, *primaryCmdBuffer, m_depthImage->object(), VK_IMAGE_ASPECT_DEPTH_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT);
1627 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
1628 vk.cmdBeginQuery(*primaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1629 vk.cmdBeginRenderPass(*primaryCmdBuffer, &renderPassBegin, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
1630 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
1631 vk.cmdEndRenderPass(*primaryCmdBuffer);
1632 vk.cmdEndQuery(*primaryCmdBuffer, *queryPool, 0u);
1634 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL, 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1636 vk.endCommandBuffer(*primaryCmdBuffer);
1638 // Wait for completion
1639 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
1640 return checkResult(*queryPool);
1643 class TessellationShaderTestInstance : public GraphicBasicTestInstance
1646 TessellationShaderTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1648 virtual void checkExtensions (void);
1649 virtual void createPipeline (void);
1650 virtual tcu::TestStatus executeTest (void);
1651 virtual tcu::TestStatus checkResult (VkQueryPool queryPool);
1652 void draw (VkCommandBuffer cmdBuffer);
1655 TessellationShaderTestInstance::TessellationShaderTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1656 : GraphicBasicTestInstance (context, data, parametersGraphic)
1660 void TessellationShaderTestInstance::checkExtensions (void)
1662 StatisticQueryTestInstance::checkExtensions();
1663 if (!m_context.getDeviceFeatures().tessellationShader)
1664 throw tcu::NotSupportedError("Tessellation shader are not supported");
1668 void TessellationShaderTestInstance::createPipeline (void)
1670 const DeviceInterface& vk = m_context.getDeviceInterface();
1671 const VkDevice device = m_context.getDevice();
1674 Unique<VkShaderModule> vs(createShaderModule(vk, device, m_context.getBinaryCollection().get("vertex"), (VkShaderModuleCreateFlags)0));
1675 Unique<VkShaderModule> tc(createShaderModule(vk, device, m_context.getBinaryCollection().get("tessellation_control"), (VkShaderModuleCreateFlags)0));
1676 Unique<VkShaderModule> te(createShaderModule(vk, device, m_context.getBinaryCollection().get("tessellation_evaluation"), (VkShaderModuleCreateFlags)0));
1677 Unique<VkShaderModule> fs(createShaderModule(vk, device, m_context.getBinaryCollection().get("fragment"), (VkShaderModuleCreateFlags)0));
1679 const PipelineCreateInfo::ColorBlendState::Attachment attachmentState;
1681 const PipelineLayoutCreateInfo pipelineLayoutCreateInfo;
1682 m_pipelineLayout = createPipelineLayout(vk, device, &pipelineLayoutCreateInfo);
1684 const VkVertexInputBindingDescription vertexInputBindingDescription =
1687 static_cast<deUint32>(sizeof(VertexData)), // stride;
1688 VK_VERTEX_INPUT_RATE_VERTEX // inputRate
1691 const VkVertexInputAttributeDescription vertexInputAttributeDescriptions[] =
1696 VK_FORMAT_R32G32B32A32_SFLOAT,
1698 }, // VertexElementData::position
1702 VK_FORMAT_R32G32B32A32_SFLOAT,
1703 static_cast<deUint32>(sizeof(tcu::Vec4))
1704 }, // VertexElementData::color
1707 const VkPipelineVertexInputStateCreateInfo vf_info =
1709 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // pNext;
1711 0u, // vertexBindingDescriptionCount;
1712 1u, // pVertexBindingDescriptions;
1713 &vertexInputBindingDescription, // vertexAttributeDescriptionCount;
1714 2u, // pVertexAttributeDescriptions;
1715 vertexInputAttributeDescriptions
1718 PipelineCreateInfo pipelineCreateInfo(*m_pipelineLayout, *m_renderPass, 0, (VkPipelineCreateFlags)0);
1719 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*vs, "main", VK_SHADER_STAGE_VERTEX_BIT));
1720 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*tc, "main", VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT));
1721 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*te, "main", VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT));
1722 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*fs, "main", VK_SHADER_STAGE_FRAGMENT_BIT));
1723 pipelineCreateInfo.addState (PipelineCreateInfo::TessellationState(4));
1724 pipelineCreateInfo.addState(PipelineCreateInfo::InputAssemblerState(VK_PRIMITIVE_TOPOLOGY_PATCH_LIST));
1725 pipelineCreateInfo.addState(PipelineCreateInfo::ColorBlendState(1, &attachmentState));
1727 const VkViewport viewport =
1731 WIDTH, // float width;
1732 HEIGHT, // float height;
1733 0.0f, // float minDepth;
1734 1.0f // float maxDepth;
1737 const VkRect2D scissor =
1742 }, // VkOffset2D offset;
1744 WIDTH, // deInt32 width;
1745 HEIGHT, // deInt32 height
1746 }, // VkExtent2D extent;
1748 pipelineCreateInfo.addState(PipelineCreateInfo::ViewportState(1, std::vector<VkViewport>(1, viewport), std::vector<VkRect2D>(1, scissor)));
1749 pipelineCreateInfo.addState(PipelineCreateInfo::DepthStencilState());
1750 pipelineCreateInfo.addState(PipelineCreateInfo::RasterizerState());
1751 pipelineCreateInfo.addState(PipelineCreateInfo::MultiSampleState());
1752 pipelineCreateInfo.addState(vf_info);
1753 m_pipeline = createGraphicsPipeline(vk, device, DE_NULL, &pipelineCreateInfo);
1756 tcu::TestStatus TessellationShaderTestInstance::executeTest (void)
1758 const DeviceInterface& vk = m_context.getDeviceInterface();
1759 const VkDevice device = m_context.getDevice();
1760 const VkQueue queue = m_context.getUniversalQueue();
1761 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1763 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1764 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1765 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1767 const VkDeviceSize vertexBufferOffset = 0u;
1768 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1769 const VkBuffer vertexBuffer = vertexBufferSp->object();
1771 const Unique<VkCommandBuffer> cmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1773 beginCommandBuffer(vk, *cmdBuffer);
1775 const VkRect2D renderArea = { { 0, 0 }, { WIDTH, HEIGHT } };
1776 std::vector<VkClearValue> renderPassClearValues (2);
1777 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1778 const RenderPassBeginInfo renderPassBegin (*m_renderPass, *m_framebuffer, renderArea, renderPassClearValues);
1780 transition2DImage(vk, *cmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1781 transition2DImage(vk, *cmdBuffer, m_depthImage->object(), VK_IMAGE_ASPECT_DEPTH_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT);
1783 vk.cmdResetQueryPool(*cmdBuffer, *queryPool, 0u, 1u);
1785 vk.cmdBeginRenderPass(*cmdBuffer, &renderPassBegin, VK_SUBPASS_CONTENTS_INLINE);
1787 vk.cmdBeginQuery(*cmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1788 vk.cmdBindVertexBuffers(*cmdBuffer, 0, 1, &vertexBuffer, &vertexBufferOffset);
1789 vk.cmdBindPipeline(*cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1793 vk.cmdEndQuery(*cmdBuffer, *queryPool, 0u);
1795 vk.cmdEndRenderPass(*cmdBuffer);
1797 transition2DImage(vk, *cmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL, 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1799 vk.endCommandBuffer(*cmdBuffer);
1801 // Wait for completion
1802 submitCommandsAndWait(vk, device, queue, *cmdBuffer);
1803 return checkResult (*queryPool);
1806 tcu::TestStatus TessellationShaderTestInstance::checkResult (VkQueryPool queryPool)
1808 const DeviceInterface& vk = m_context.getDeviceInterface();
1809 const VkDevice device = m_context.getDevice();
1810 deUint64 result = 0u;
1811 deUint64 expectedMin = 0u;
1812 deUint64 expectedMax = 0u;
1813 switch(m_parametersGraphic.queryStatisticFlags)
1815 case VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT:
1817 expectedMax = expectedMin * 4u;
1819 case VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT:
1821 expectedMax = expectedMin * 4u;
1827 VK_CHECK(vk.getQueryPoolResults(device, queryPool, 0u, 1u, sizeof(deUint64), &result, 0u, VK_QUERY_RESULT_64_BIT));
1828 if (result < expectedMin || result > expectedMax)
1829 return tcu::TestStatus::fail("QueryPoolResults incorrect");
1832 return tcu::TestStatus::fail("Result image doesn't match expected image.");
1834 return tcu::TestStatus::pass("Pass");
1837 void TessellationShaderTestInstance::draw (VkCommandBuffer cmdBuffer)
1839 const DeviceInterface& vk = m_context.getDeviceInterface();
1840 vk.cmdDraw(cmdBuffer, static_cast<deUint32>(m_data.size()), 1u, 0u, 0u);
1843 class TessellationShaderSecondrayTestInstance : public TessellationShaderTestInstance
1846 TessellationShaderSecondrayTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1848 virtual tcu::TestStatus executeTest (void);
1851 TessellationShaderSecondrayTestInstance::TessellationShaderSecondrayTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1852 : TessellationShaderTestInstance (context, data, parametersGraphic)
1856 tcu::TestStatus TessellationShaderSecondrayTestInstance::executeTest (void)
1858 const DeviceInterface& vk = m_context.getDeviceInterface();
1859 const VkDevice device = m_context.getDevice();
1860 const VkQueue queue = m_context.getUniversalQueue();
1861 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1863 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1864 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1865 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1867 const VkDeviceSize vertexBufferOffset = 0u;
1868 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1869 const VkBuffer vertexBuffer = vertexBufferSp->object();
1871 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1872 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
1874 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, m_parametersGraphic.queryStatisticFlags, *m_renderPass, *m_framebuffer, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT);
1875 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1876 vk.cmdBeginQuery(*secondaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1877 vk.cmdBindVertexBuffers(*secondaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1878 draw(*secondaryCmdBuffer);
1879 vk.cmdEndQuery(*secondaryCmdBuffer, *queryPool, 0u);
1880 vk.endCommandBuffer(*secondaryCmdBuffer);
1882 beginCommandBuffer(vk, *primaryCmdBuffer);
1884 const VkRect2D renderArea = { { 0, 0 }, { WIDTH, HEIGHT } };
1885 std::vector<VkClearValue> renderPassClearValues (2);
1886 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1887 const RenderPassBeginInfo renderPassBegin (*m_renderPass, *m_framebuffer, renderArea, renderPassClearValues);
1889 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1890 transition2DImage(vk, *primaryCmdBuffer, m_depthImage->object(), VK_IMAGE_ASPECT_DEPTH_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT);
1892 vk.cmdBindVertexBuffers(*primaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1893 vk.cmdBindPipeline(*primaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1894 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
1896 vk.cmdBeginRenderPass(*primaryCmdBuffer, &renderPassBegin, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
1897 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
1898 vk.cmdEndRenderPass(*primaryCmdBuffer);
1900 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL, 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1902 vk.endCommandBuffer(*primaryCmdBuffer);
1904 // Wait for completion
1905 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
1906 return checkResult (*queryPool);
1909 class TessellationShaderSecondrayInheritedTestInstance : public TessellationShaderTestInstance
1912 TessellationShaderSecondrayInheritedTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1914 virtual void checkExtensions (void);
1915 virtual tcu::TestStatus executeTest (void);
1918 TessellationShaderSecondrayInheritedTestInstance::TessellationShaderSecondrayInheritedTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1919 : TessellationShaderTestInstance (context, data, parametersGraphic)
1923 void TessellationShaderSecondrayInheritedTestInstance::checkExtensions (void)
1925 TessellationShaderTestInstance::checkExtensions();
1926 if (!m_context.getDeviceFeatures().inheritedQueries)
1927 throw tcu::NotSupportedError("Inherited queries are not supported");
1930 tcu::TestStatus TessellationShaderSecondrayInheritedTestInstance::executeTest (void)
1932 const DeviceInterface& vk = m_context.getDeviceInterface();
1933 const VkDevice device = m_context.getDevice();
1934 const VkQueue queue = m_context.getUniversalQueue();
1935 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1937 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1938 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1939 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1941 const VkDeviceSize vertexBufferOffset = 0u;
1942 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1943 const VkBuffer vertexBuffer = vertexBufferSp->object();
1945 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1946 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
1948 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, m_parametersGraphic.queryStatisticFlags, *m_renderPass, *m_framebuffer, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT);
1949 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1950 vk.cmdBindVertexBuffers(*secondaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1951 draw(*secondaryCmdBuffer);
1952 vk.endCommandBuffer(*secondaryCmdBuffer);
1954 beginCommandBuffer(vk, *primaryCmdBuffer);
1956 const VkRect2D renderArea = { { 0, 0 }, { WIDTH, HEIGHT } };
1957 std::vector<VkClearValue> renderPassClearValues (2);
1958 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1959 const RenderPassBeginInfo renderPassBegin (*m_renderPass, *m_framebuffer, renderArea, renderPassClearValues);
1961 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1962 transition2DImage(vk, *primaryCmdBuffer, m_depthImage->object(), VK_IMAGE_ASPECT_DEPTH_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT);
1964 vk.cmdBindVertexBuffers(*primaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1965 vk.cmdBindPipeline(*primaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1966 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
1967 vk.cmdBeginQuery(*primaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1969 vk.cmdBeginRenderPass(*primaryCmdBuffer, &renderPassBegin, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
1970 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
1971 vk.cmdEndRenderPass(*primaryCmdBuffer);
1972 vk.cmdEndQuery(*primaryCmdBuffer, *queryPool, 0u);
1974 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL, 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1976 vk.endCommandBuffer(*primaryCmdBuffer);
1978 // Wait for completion
1979 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
1980 return checkResult (*queryPool);
1983 template<class Instance>
1984 class QueryPoolStatisticsTest : public TestCase
1987 QueryPoolStatisticsTest (tcu::TestContext &context, const char *name, const char *description)
1988 : TestCase (context, name, description)
1990 const tcu::UVec3 localSize[] =
1992 tcu::UVec3 (2u, 2u, 2u),
1993 tcu::UVec3 (1u, 1u, 1u),
1994 tcu::UVec3 (WIDTH/(7u*3u), 7u, 3u),
1997 const tcu::UVec3 groupSize[] =
1999 tcu::UVec3 (2u, 2u, 2u),
2000 tcu::UVec3 (WIDTH/(7u*3u), 7u, 3u),
2001 tcu::UVec3 (1u, 1u, 1u),
2004 DE_ASSERT(DE_LENGTH_OF_ARRAY(localSize) == DE_LENGTH_OF_ARRAY(groupSize));
2006 for(int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(localSize); ++shaderNdx)
2008 std::ostringstream shaderName;
2009 shaderName<< "compute_" << shaderNdx;
2010 const ComputeInvocationsTestInstance::ParametersCompute prameters =
2012 localSize[shaderNdx],
2013 groupSize[shaderNdx],
2016 m_parameters.push_back(prameters);
2020 vkt::TestInstance* createInstance (vkt::Context& context) const
2022 return new Instance(context, m_parameters);
2025 void initPrograms(SourceCollections& sourceCollections) const
2027 std::ostringstream source;
2028 source << "layout(binding = 0) writeonly buffer Output {\n"
2029 << " uint values[];\n"
2031 << "void main (void) {\n"
2032 << " uvec3 indexUvec3 = uvec3 (gl_GlobalInvocationID.x,\n"
2033 << " gl_GlobalInvocationID.y * gl_NumWorkGroups.x * gl_WorkGroupSize.x,\n"
2034 << " gl_GlobalInvocationID.z * gl_NumWorkGroups.x * gl_NumWorkGroups.y * gl_WorkGroupSize.x * gl_WorkGroupSize.y);\n"
2035 << " uint index = indexUvec3.x + indexUvec3.y + indexUvec3.z;\n"
2036 << " sb_out.values[index] += index;\n"
2039 for(size_t shaderNdx = 0; shaderNdx < m_parameters.size(); ++shaderNdx)
2041 std::ostringstream src;
2042 src << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
2043 << "layout (local_size_x = " << m_parameters[shaderNdx].localSize.x() << ", local_size_y = " << m_parameters[shaderNdx].localSize.y() << ", local_size_z = " << m_parameters[shaderNdx].localSize.z() << ") in;\n"
2045 sourceCollections.glslSources.add(m_parameters[shaderNdx].shaderName) << glu::ComputeSource(src.str());
2049 std::vector<ComputeInvocationsTestInstance::ParametersCompute> m_parameters;
2052 template<class Instance>
2053 class QueryPoolGraphicStatisticsTest : public TestCase
2056 QueryPoolGraphicStatisticsTest (tcu::TestContext &context, const char *name, const char *description, const GraphicBasicTestInstance::ParametersGraphic parametersGraphic)
2057 : TestCase (context, name, description)
2058 , m_parametersGraphic (parametersGraphic)
2060 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4(-1.0f,-1.0f, 1.0f, 1.0f), tcu::RGBA::red().toVec()));
2061 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4(-1.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::red().toVec()));
2062 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f,-1.0f, 1.0f, 1.0f), tcu::RGBA::red().toVec()));
2063 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::red().toVec()));
2065 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4(-1.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::green().toVec()));
2066 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4(-1.0f, 1.0f, 1.0f, 1.0f), tcu::RGBA::green().toVec()));
2067 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::green().toVec()));
2068 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f, 1.0f, 1.0f, 1.0f), tcu::RGBA::green().toVec()));
2070 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f,-1.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec()));
2071 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec()));
2072 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 1.0f,-1.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec()));
2073 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 1.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec()));
2075 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::gray().toVec()));
2076 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f, 1.0f, 1.0f, 1.0f), tcu::RGBA::gray().toVec()));
2077 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 1.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::gray().toVec()));
2078 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 1.0f, 1.0f, 1.0f, 1.0f), tcu::RGBA::gray().toVec()));
2081 vkt::TestInstance* createInstance (vkt::Context& context) const
2083 return new Instance(context, m_data, m_parametersGraphic);
2086 void initPrograms(SourceCollections& sourceCollections) const
2089 std::ostringstream source;
2090 source << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
2091 << "layout(location = 0) in highp vec4 in_position;\n"
2092 << "layout(location = 1) in vec4 in_color;\n"
2093 << "layout(location = 0) out vec4 out_color;\n"
2094 << "void main (void)\n"
2096 << " gl_Position = in_position;\n"
2097 << " out_color = in_color;\n"
2099 sourceCollections.glslSources.add("vertex") << glu::VertexSource(source.str());
2102 if (m_parametersGraphic.queryStatisticFlags & (VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT|
2103 VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT))
2104 {// Tessellation control & evaluation
2105 std::ostringstream source_tc;
2106 source_tc << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450) << "\n"
2107 << "#extension GL_EXT_tessellation_shader : require\n"
2108 << "layout(vertices = 4) out;\n"
2109 << "layout(location = 0) in vec4 in_color[];\n"
2110 << "layout(location = 0) out vec4 out_color[];\n"
2112 << "void main (void)\n"
2114 << " if( gl_InvocationID == 0 )\n"
2116 << " gl_TessLevelInner[0] = 4.0f;\n"
2117 << " gl_TessLevelInner[1] = 4.0f;\n"
2118 << " gl_TessLevelOuter[0] = 4.0f;\n"
2119 << " gl_TessLevelOuter[1] = 4.0f;\n"
2120 << " gl_TessLevelOuter[2] = 4.0f;\n"
2121 << " gl_TessLevelOuter[3] = 4.0f;\n"
2123 << " out_color[gl_InvocationID] = in_color[gl_InvocationID];\n"
2124 << " gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
2126 sourceCollections.glslSources.add("tessellation_control") << glu::TessellationControlSource(source_tc.str());
2128 std::ostringstream source_te;
2129 source_te << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450) << "\n"
2130 << "#extension GL_EXT_tessellation_shader : require\n"
2131 << "layout( quads, equal_spacing, ccw ) in;\n"
2132 << "layout(location = 0) in vec4 in_color[];\n"
2133 << "layout(location = 0) out vec4 out_color;\n"
2134 << "void main (void)\n"
2136 << " const float u = gl_TessCoord.x;\n"
2137 << " const float v = gl_TessCoord.y;\n"
2138 << " const float w = gl_TessCoord.z;\n"
2139 << " gl_Position = (1 - u) * (1 - v) * gl_in[0].gl_Position +(1 - u) * v * gl_in[1].gl_Position + u * (1 - v) * gl_in[2].gl_Position + u * v * gl_in[3].gl_Position;\n"
2140 << " out_color = in_color[0];\n"
2142 sourceCollections.glslSources.add("tessellation_evaluation") << glu::TessellationEvaluationSource(source_te.str());
2145 if(m_parametersGraphic.queryStatisticFlags & (VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT | VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT |
2146 VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT | VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT))
2147 { // Geometry Shader
2148 std::ostringstream source;
2149 source << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
2150 << "layout("<<inputTypeToGLString(m_parametersGraphic.primitiveTopology)<<") in;\n"
2151 << "layout("<<outputTypeToGLString (m_parametersGraphic.primitiveTopology)<<", max_vertices = 16) out;\n"
2152 << "layout(location = 0) in vec4 in_color[];\n"
2153 << "layout(location = 0) out vec4 out_color;\n"
2154 << "void main (void)\n"
2156 << " out_color = in_color[0];\n"
2157 << " gl_Position = gl_in[0].gl_Position;\n"
2158 << " EmitVertex();\n"
2159 << " EndPrimitive();\n"
2161 << " out_color = in_color[0];\n"
2162 << " gl_Position = vec4(1.0, 1.0, 1.0, 1.0);\n"
2163 << " EmitVertex();\n"
2164 << " out_color = in_color[0];\n"
2165 << " gl_Position = vec4(-1.0, -1.0, 1.0, 1.0);\n"
2166 << " EmitVertex();\n"
2167 << " EndPrimitive();\n"
2169 if (m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ||
2170 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST)
2173 << " out_color = in_color[0];\n"
2174 << " gl_Position = gl_in[0].gl_Position;\n"
2175 << " EmitVertex();\n"
2176 << " out_color = in_color[0];\n"
2177 << " gl_Position = gl_in[1].gl_Position;\n"
2178 << " EmitVertex();\n"
2179 << " out_color = in_color[0];\n"
2180 << " gl_Position = gl_in[2].gl_Position;\n"
2181 << " EmitVertex();\n"
2182 << " out_color = in_color[0];\n"
2183 << " gl_Position = vec4(gl_in[2].gl_Position.x, gl_in[1].gl_Position.y, 1.0, 1.0);\n"
2184 << " EmitVertex();\n"
2185 << " EndPrimitive();\n";
2189 source << " out_color = in_color[0];\n"
2190 << " gl_Position = vec4(1.0, 1.0, 1.0, 1.0);\n"
2191 << " EmitVertex();\n"
2192 << " out_color = in_color[0];\n"
2193 << " gl_Position = vec4(1.0, -1.0, 1.0, 1.0);\n"
2194 << " EmitVertex();\n"
2195 << " out_color = in_color[0];\n"
2196 << " gl_Position = vec4(-1.0, 1.0, 1.0, 1.0);\n"
2197 << " EmitVertex();\n"
2198 << " out_color = in_color[0];\n"
2199 << " gl_Position = vec4(-1.0, -1.0, 1.0, 1.0);\n"
2200 << " EmitVertex();\n"
2201 << " EndPrimitive();\n";
2204 sourceCollections.glslSources.add("geometry") << glu::GeometrySource(source.str());
2207 { // Fragment Shader
2208 std::ostringstream source;
2209 source << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
2210 << "layout(location = 0) in vec4 in_color;\n"
2211 << "layout(location = 0) out vec4 out_color;\n"
2214 << " out_color = in_color;\n"
2216 sourceCollections.glslSources.add("fragment") << glu::FragmentSource(source.str());
2220 std::vector<GraphicBasicTestInstance::VertexData> m_data;
2221 const GraphicBasicTestInstance::ParametersGraphic m_parametersGraphic;
2225 QueryPoolStatisticsTests::QueryPoolStatisticsTests (tcu::TestContext &testCtx)
2226 : TestCaseGroup(testCtx, "statistics_query", "Tests for statistics queries")
2230 void QueryPoolStatisticsTests::init (void)
2232 std::string topology_name [VK_PRIMITIVE_TOPOLOGY_LAST] =
2240 "line_list_with_adjacency",
2241 "line_strip_with_adjacency",
2242 "triangle_list_with_adjacency",
2243 "triangle_strip_with_adjacency",
2247 de::MovePtr<TestCaseGroup> computeShaderInvocationsGroup (new TestCaseGroup(m_testCtx, "compute_shader_invocations", "Query pipeline statistic compute shader invocations"));
2248 de::MovePtr<TestCaseGroup> inputAssemblyVertices (new TestCaseGroup(m_testCtx, "input_assembly_vertices", "Query pipeline statistic input assembly vertices"));
2249 de::MovePtr<TestCaseGroup> inputAssemblyPrimitives (new TestCaseGroup(m_testCtx, "input_assembly_primitives", "Query pipeline statistic input assembly primitives"));
2250 de::MovePtr<TestCaseGroup> vertexShaderInvocations (new TestCaseGroup(m_testCtx, "vertex_shader_invocations", "Query pipeline statistic vertex shader invocation"));
2251 de::MovePtr<TestCaseGroup> fragmentShaderInvocations (new TestCaseGroup(m_testCtx, "fragment_shader_invocations", "Query pipeline statistic fragment shader invocation"));
2252 de::MovePtr<TestCaseGroup> geometryShaderInvocations (new TestCaseGroup(m_testCtx, "geometry_shader_invocations", "Query pipeline statistic geometry shader invocation"));
2253 de::MovePtr<TestCaseGroup> geometryShaderPrimitives (new TestCaseGroup(m_testCtx, "geometry_shader_primitives", "Query pipeline statistic geometry shader primitives"));
2254 de::MovePtr<TestCaseGroup> clippingInvocations (new TestCaseGroup(m_testCtx, "clipping_invocations", "Query pipeline statistic clipping invocations"));
2255 de::MovePtr<TestCaseGroup> clippingPrimitives (new TestCaseGroup(m_testCtx, "clipping_primitives", "Query pipeline statistic clipping primitives"));
2256 de::MovePtr<TestCaseGroup> tesControlPatches (new TestCaseGroup(m_testCtx, "tes_control_patches", "Query pipeline statistic tessellation control shader patches"));
2257 de::MovePtr<TestCaseGroup> tesEvaluationShaderInvocations (new TestCaseGroup(m_testCtx, "tes_evaluation_shader_invocations", "Query pipeline statistic tessellation evaluation shader invocations"));
2259 computeShaderInvocationsGroup->addChild(new QueryPoolStatisticsTest<ComputeInvocationsTestInstance> (m_testCtx, "primary", ""));
2260 computeShaderInvocationsGroup->addChild(new QueryPoolStatisticsTest<ComputeInvocationsSecondaryTestInstance> (m_testCtx, "secondary", ""));
2261 computeShaderInvocationsGroup->addChild(new QueryPoolStatisticsTest<ComputeInvocationsSecondaryInheritedTestInstance> (m_testCtx, "secondary_inherited", ""));
2263 //VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT
2264 inputAssemblyVertices->addChild(new QueryPoolGraphicStatisticsTest<VertexShaderTestInstance> (m_testCtx, "primary", "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP)));
2265 inputAssemblyVertices->addChild(new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryTestInstance> (m_testCtx, "secondary", "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP)));
2266 inputAssemblyVertices->addChild(new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryInheritedTestInstance> (m_testCtx, "secondary_inherited", "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP)));
2268 //VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT
2270 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2271 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2272 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2273 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2275 primary->addChild (new QueryPoolGraphicStatisticsTest<VertexShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2276 secondary->addChild (new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2277 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2279 inputAssemblyPrimitives->addChild(primary.release());
2280 inputAssemblyPrimitives->addChild(secondary.release());
2281 inputAssemblyPrimitives->addChild(secondaryInherited.release());
2284 //VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT
2286 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2287 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2288 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2289 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2291 primary->addChild (new QueryPoolGraphicStatisticsTest<VertexShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2292 secondary->addChild (new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2293 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2295 vertexShaderInvocations->addChild(primary.release());
2296 vertexShaderInvocations->addChild(secondary.release());
2297 vertexShaderInvocations->addChild(secondaryInherited.release());
2300 //VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT
2302 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2303 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2304 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2305 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2307 primary->addChild (new QueryPoolGraphicStatisticsTest<VertexShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2308 secondary->addChild (new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2309 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2311 fragmentShaderInvocations->addChild(primary.release());
2312 fragmentShaderInvocations->addChild(secondary.release());
2313 fragmentShaderInvocations->addChild(secondaryInherited.release());
2316 //VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT
2318 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2319 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2320 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2321 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2323 primary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2324 secondary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2325 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2327 geometryShaderInvocations->addChild(primary.release());
2328 geometryShaderInvocations->addChild(secondary.release());
2329 geometryShaderInvocations->addChild(secondaryInherited.release());
2332 //VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT
2334 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2335 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2336 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2337 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2339 primary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2340 secondary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2341 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2343 geometryShaderPrimitives->addChild(primary.release());
2344 geometryShaderPrimitives->addChild(secondary.release());
2345 geometryShaderPrimitives->addChild(secondaryInherited.release());
2348 //VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT
2350 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2351 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2352 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2353 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2355 primary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2356 secondary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2357 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2359 clippingInvocations->addChild(primary.release());
2360 clippingInvocations->addChild(secondary.release());
2361 clippingInvocations->addChild(secondaryInherited.release());
2364 //VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT
2366 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2367 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2368 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2369 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2371 primary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2372 secondary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2373 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2375 clippingPrimitives->addChild(primary.release());
2376 clippingPrimitives->addChild(secondary.release());
2377 clippingPrimitives->addChild(secondaryInherited.release());
2380 //VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT
2381 tesControlPatches->addChild(new QueryPoolGraphicStatisticsTest<TessellationShaderTestInstance> (m_testCtx, "tes_control_patches", "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP)));
2382 tesControlPatches->addChild(new QueryPoolGraphicStatisticsTest<TessellationShaderSecondrayTestInstance> (m_testCtx, "tes_control_patches_secondary", "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP)));
2383 tesControlPatches->addChild(new QueryPoolGraphicStatisticsTest<TessellationShaderSecondrayInheritedTestInstance>(m_testCtx, "tes_control_patches_secondary_inherited", "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP)));
2385 //VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT
2386 tesEvaluationShaderInvocations->addChild(new QueryPoolGraphicStatisticsTest<TessellationShaderTestInstance> (m_testCtx, "tes_evaluation_shader_invocations", "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP)));
2387 tesEvaluationShaderInvocations->addChild(new QueryPoolGraphicStatisticsTest<TessellationShaderSecondrayTestInstance> (m_testCtx, "tes_evaluation_shader_invocations_secondary", "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP)));
2388 tesEvaluationShaderInvocations->addChild(new QueryPoolGraphicStatisticsTest<TessellationShaderSecondrayInheritedTestInstance>(m_testCtx, "tes_evaluation_shader_invocations_secondary_inherited", "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP)));
2390 addChild(computeShaderInvocationsGroup.release());
2391 addChild(inputAssemblyVertices.release());
2392 addChild(inputAssemblyPrimitives.release());
2393 addChild(vertexShaderInvocations.release());
2394 addChild(fragmentShaderInvocations.release());
2395 addChild(geometryShaderInvocations.release());
2396 addChild(geometryShaderPrimitives.release());
2397 addChild(clippingInvocations.release());
2398 addChild(clippingPrimitives.release());
2399 addChild(tesControlPatches.release());
2400 addChild(tesEvaluationShaderInvocations.release());