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"
33 #include "vkTypeUtil.hpp"
34 #include "vkCmdUtil.hpp"
38 #include "tcuTestLog.hpp"
39 #include "tcuResource.hpp"
40 #include "tcuImageCompare.hpp"
41 #include "vkImageUtil.hpp"
42 #include "tcuCommandLine.hpp"
43 #include "tcuRGBA.hpp"
62 std::string inputTypeToGLString (const VkPrimitiveTopology& inputType)
66 case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
68 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
69 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
71 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
72 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
73 return "lines_adjacency";
74 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
75 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
76 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
78 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
79 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
80 return "triangles_adjacency";
87 std::string outputTypeToGLString (const VkPrimitiveTopology& outputType)
91 case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
93 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
94 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
95 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
96 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
98 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
99 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
100 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
101 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
102 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
103 return "triangle_strip";
110 void beginSecondaryCommandBuffer (const DeviceInterface& vk,
111 const VkCommandBuffer commandBuffer,
112 const VkQueryPipelineStatisticFlags queryFlags,
113 const VkRenderPass renderPass = (VkRenderPass)0u,
114 const VkFramebuffer framebuffer = (VkFramebuffer)0u,
115 const VkCommandBufferUsageFlags bufferUsageFlags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)
117 const VkCommandBufferInheritanceInfo secCmdBufInheritInfo =
119 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO,
121 renderPass, // renderPass
123 framebuffer, // framebuffer
124 VK_FALSE, // occlusionQueryEnable
125 (VkQueryControlFlags)0u, // queryFlags
126 queryFlags, // pipelineStatistics
129 const VkCommandBufferBeginInfo info =
131 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
132 DE_NULL, // const void* pNext;
133 bufferUsageFlags, // VkCommandBufferUsageFlags flags;
134 &secCmdBufInheritInfo, // const VkCommandBufferInheritanceInfo* pInheritanceInfo;
136 VK_CHECK(vk.beginCommandBuffer(commandBuffer, &info));
139 Move<VkQueryPool> makeQueryPool (const DeviceInterface& vk, const VkDevice device, VkQueryPipelineStatisticFlags statisticFlags)
141 const VkQueryPoolCreateInfo queryPoolCreateInfo =
143 VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO, // VkStructureType sType
144 DE_NULL, // const void* pNext
145 (VkQueryPoolCreateFlags)0, // VkQueryPoolCreateFlags flags
146 VK_QUERY_TYPE_PIPELINE_STATISTICS , // VkQueryType queryType
147 1u, // deUint32 entryCount
148 statisticFlags, // VkQueryPipelineStatisticFlags pipelineStatistics
150 return createQueryPool(vk, device, &queryPoolCreateInfo);
153 Move<VkPipelineLayout> makePipelineLayout (const DeviceInterface& vk, const VkDevice device, const VkDescriptorSetLayout* descriptorSetLayout)
155 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
157 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // VkStructureType sType;
158 DE_NULL, // const void* pNext;
159 0u, // VkPipelineLayoutCreateFlags flags;
160 1u, // deUint32 setLayoutCount;
161 descriptorSetLayout, // const VkDescriptorSetLayout* pSetLayouts;
162 0u, // deUint32 pushConstantRangeCount;
163 DE_NULL, // const VkPushConstantRange* pPushConstantRanges;
165 return (createPipelineLayout(vk, device, &pipelineLayoutParams));
168 void clearBuffer (const DeviceInterface& vk, const VkDevice device, const de::SharedPtr<Buffer> buffer, const VkDeviceSize bufferSizeBytes)
170 const std::vector<deUint8> data ((size_t)bufferSizeBytes, 0u);
171 const Allocation& allocation = buffer->getBoundMemory();
172 void* allocationData = allocation.getHostPtr();
173 invalidateMappedMemoryRange(vk, device, allocation.getMemory(), allocation.getOffset(), bufferSizeBytes);
174 deMemcpy(allocationData, &data[0], (size_t)bufferSizeBytes);
177 class StatisticQueryTestInstance : public TestInstance
180 StatisticQueryTestInstance (Context& context);
182 virtual void checkExtensions (void);
185 StatisticQueryTestInstance::StatisticQueryTestInstance (Context& context)
186 : TestInstance (context)
190 void StatisticQueryTestInstance::checkExtensions (void)
192 if (!m_context.getDeviceFeatures().pipelineStatisticsQuery)
193 throw tcu::NotSupportedError("Pipeline statistics queries are not supported");
196 class ComputeInvocationsTestInstance : public StatisticQueryTestInstance
199 struct ParametersCompute
201 tcu::UVec3 localSize;
202 tcu::UVec3 groupSize;
203 std::string shaderName;
205 ComputeInvocationsTestInstance (Context& context, const std::vector<ParametersCompute>& parameters);
206 tcu::TestStatus iterate (void);
208 virtual tcu::TestStatus executeTest (const VkCommandPool& cmdPool,
209 const VkPipelineLayout pipelineLayout,
210 const VkDescriptorSet& descriptorSet,
211 const de::SharedPtr<Buffer> buffer,
212 const VkDeviceSize bufferSizeBytes);
213 deUint32 getComputeExecution (const ParametersCompute& parm) const
215 return parm.localSize.x() * parm.localSize.y() *parm.localSize.z() * parm.groupSize.x() * parm.groupSize.y() * parm.groupSize.z();
217 const std::vector<ParametersCompute>& m_parameters;
220 ComputeInvocationsTestInstance::ComputeInvocationsTestInstance (Context& context, const std::vector<ParametersCompute>& parameters)
221 : StatisticQueryTestInstance (context)
222 , m_parameters (parameters)
226 tcu::TestStatus ComputeInvocationsTestInstance::iterate (void)
229 const DeviceInterface& vk = m_context.getDeviceInterface();
230 const VkDevice device = m_context.getDevice();
231 deUint32 maxSize = 0u;
233 for(size_t parametersNdx = 0; parametersNdx < m_parameters.size(); ++parametersNdx)
234 maxSize = deMaxu32(maxSize, getComputeExecution(m_parameters[parametersNdx]));
236 const VkDeviceSize bufferSizeBytes = static_cast<VkDeviceSize>(deAlignSize(static_cast<size_t>(sizeof(deUint32) * maxSize),
237 static_cast<size_t>(m_context.getDeviceProperties().limits.nonCoherentAtomSize)));
238 de::SharedPtr<Buffer> buffer = Buffer::createAndAlloc(vk, device, BufferCreateInfo(bufferSizeBytes, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT),
239 m_context.getDefaultAllocator(), MemoryRequirement::HostVisible);
241 const Unique<VkDescriptorSetLayout> descriptorSetLayout (DescriptorSetLayoutBuilder()
242 .addSingleBinding(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_SHADER_STAGE_COMPUTE_BIT)
245 const Unique<VkPipelineLayout> pipelineLayout (makePipelineLayout(vk, device, &(*descriptorSetLayout)));
247 const Unique<VkDescriptorPool> descriptorPool (DescriptorPoolBuilder()
248 .addType(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER)
249 .build(vk, device, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 1u));
251 const VkDescriptorSetAllocateInfo allocateParams =
253 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, // VkStructureType sType;
254 DE_NULL, // const void* pNext;
255 *descriptorPool, // VkDescriptorPool descriptorPool;
256 1u, // deUint32 setLayoutCount;
257 &(*descriptorSetLayout), // const VkDescriptorSetLayout* pSetLayouts;
260 const Unique<VkDescriptorSet> descriptorSet (allocateDescriptorSet(vk, device, &allocateParams));
261 const VkDescriptorBufferInfo descriptorInfo =
263 buffer->object(), //VkBuffer buffer;
264 0ull, //VkDeviceSize offset;
265 bufferSizeBytes, //VkDeviceSize range;
268 DescriptorSetUpdateBuilder()
269 .writeSingle(*descriptorSet, DescriptorSetUpdateBuilder::Location::binding(0u), VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, &descriptorInfo)
272 const CmdPoolCreateInfo cmdPoolCreateInfo (m_context.getUniversalQueueFamilyIndex());
273 const Unique<VkCommandPool> cmdPool (createCommandPool(vk, device, &cmdPoolCreateInfo));
275 return executeTest (*cmdPool, *pipelineLayout, *descriptorSet, buffer, bufferSizeBytes);
278 tcu::TestStatus ComputeInvocationsTestInstance::executeTest (const VkCommandPool& cmdPool,
279 const VkPipelineLayout pipelineLayout,
280 const VkDescriptorSet& descriptorSet,
281 const de::SharedPtr<Buffer> buffer,
282 const VkDeviceSize bufferSizeBytes)
284 const DeviceInterface& vk = m_context.getDeviceInterface();
285 const VkDevice device = m_context.getDevice();
286 const VkQueue queue = m_context.getUniversalQueue();
287 const VkBufferMemoryBarrier computeFinishBarrier =
289 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
290 DE_NULL, // const void* pNext;
291 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags srcAccessMask;
292 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
293 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
294 VK_QUEUE_FAMILY_IGNORED, // deUint32 destQueueFamilyIndex;
295 buffer->object(), // VkBuffer buffer;
296 0ull, // VkDeviceSize offset;
297 bufferSizeBytes, // VkDeviceSize size;
300 for(size_t parametersNdx = 0u; parametersNdx < m_parameters.size(); ++parametersNdx)
302 clearBuffer(vk, device, buffer, bufferSizeBytes);
303 const Unique<VkShaderModule> shaderModule (createShaderModule(vk, device,
304 m_context.getBinaryCollection().get(m_parameters[parametersNdx].shaderName), (VkShaderModuleCreateFlags)0u));
306 const VkPipelineShaderStageCreateInfo pipelineShaderStageParams =
308 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
309 DE_NULL, // const void* pNext;
310 (VkPipelineShaderStageCreateFlags)0u, // VkPipelineShaderStageCreateFlags flags;
311 VK_SHADER_STAGE_COMPUTE_BIT, // VkShaderStageFlagBits stage;
312 *shaderModule, // VkShaderModule module;
313 "main", // const char* pName;
314 DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
317 const VkComputePipelineCreateInfo pipelineCreateInfo =
319 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, // VkStructureType sType;
320 DE_NULL, // const void* pNext;
321 (VkPipelineCreateFlags)0u, // VkPipelineCreateFlags flags;
322 pipelineShaderStageParams, // VkPipelineShaderStageCreateInfo stage;
323 pipelineLayout, // VkPipelineLayout layout;
324 DE_NULL, // VkPipeline basePipelineHandle;
325 0, // deInt32 basePipelineIndex;
327 const Unique<VkPipeline> pipeline(createComputePipeline(vk, device, DE_NULL , &pipelineCreateInfo));
329 const Unique<VkCommandBuffer> cmdBuffer (allocateCommandBuffer(vk, device, cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
330 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT));
332 beginCommandBuffer(vk, *cmdBuffer);
333 vk.cmdResetQueryPool(*cmdBuffer, *queryPool, 0u, 1u);
335 vk.cmdBindPipeline(*cmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *pipeline);
336 vk.cmdBindDescriptorSets(*cmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipelineLayout, 0u, 1u, &descriptorSet, 0u, DE_NULL);
338 vk.cmdBeginQuery(*cmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
339 vk.cmdDispatch(*cmdBuffer, m_parameters[parametersNdx].groupSize.x(), m_parameters[parametersNdx].groupSize.y(), m_parameters[parametersNdx].groupSize.z());
340 vk.cmdEndQuery(*cmdBuffer, *queryPool, 0u);
342 vk.cmdPipelineBarrier(*cmdBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_HOST_BIT,
343 (VkDependencyFlags)0u, 0u, (const VkMemoryBarrier*)DE_NULL, 1u, &computeFinishBarrier, 0u, (const VkImageMemoryBarrier*)DE_NULL);
344 endCommandBuffer(vk, *cmdBuffer);
346 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Compute shader invocations: " << getComputeExecution(m_parameters[parametersNdx]) << tcu::TestLog::EndMessage;
348 // Wait for completion
349 submitCommandsAndWait(vk, device, queue, *cmdBuffer);
351 // Validate the results
352 const Allocation& bufferAllocation = buffer->getBoundMemory();
353 invalidateMappedMemoryRange(vk, device, bufferAllocation.getMemory(), bufferAllocation.getOffset(), bufferSizeBytes);
357 VK_CHECK(vk.getQueryPoolResults(device, *queryPool, 0u, 1u, sizeof(deUint64), &data, 0u, VK_QUERY_RESULT_64_BIT));
358 if (getComputeExecution(m_parameters[parametersNdx]) != data)
359 return tcu::TestStatus::fail("QueryPoolResults incorrect");
362 const deUint32* bufferPtr = static_cast<deUint32*>(bufferAllocation.getHostPtr());
363 for (deUint32 ndx = 0u; ndx < getComputeExecution(m_parameters[parametersNdx]); ++ndx)
365 if (bufferPtr[ndx] != ndx)
366 return tcu::TestStatus::fail("Compute shader didn't write data to the buffer");
369 return tcu::TestStatus::pass("Pass");
372 class ComputeInvocationsSecondaryTestInstance : public ComputeInvocationsTestInstance
375 ComputeInvocationsSecondaryTestInstance (Context& context, const std::vector<ParametersCompute>& parameters);
377 tcu::TestStatus executeTest (const VkCommandPool& cmdPool,
378 const VkPipelineLayout pipelineLayout,
379 const VkDescriptorSet& descriptorSet,
380 const de::SharedPtr<Buffer> buffer,
381 const VkDeviceSize bufferSizeBytes);
382 virtual tcu::TestStatus checkResult (const de::SharedPtr<Buffer> buffer,
383 const VkDeviceSize bufferSizeBytes,
384 const VkQueryPool queryPool);
387 ComputeInvocationsSecondaryTestInstance::ComputeInvocationsSecondaryTestInstance (Context& context, const std::vector<ParametersCompute>& parameters)
388 : ComputeInvocationsTestInstance (context, parameters)
392 tcu::TestStatus ComputeInvocationsSecondaryTestInstance::executeTest (const VkCommandPool& cmdPool,
393 const VkPipelineLayout pipelineLayout,
394 const VkDescriptorSet& descriptorSet,
395 const de::SharedPtr<Buffer> buffer,
396 const VkDeviceSize bufferSizeBytes)
398 typedef de::SharedPtr<Unique<VkShaderModule> > VkShaderModuleSp;
399 typedef de::SharedPtr<Unique<VkPipeline> > VkPipelineSp;
401 const DeviceInterface& vk = m_context.getDeviceInterface();
402 const VkDevice device = m_context.getDevice();
403 const VkQueue queue = m_context.getUniversalQueue();
405 const VkBufferMemoryBarrier computeShaderWriteBarrier =
407 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
408 DE_NULL, // const void* pNext;
409 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags srcAccessMask;
410 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags dstAccessMask;
411 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
412 VK_QUEUE_FAMILY_IGNORED, // deUint32 destQueueFamilyIndex;
413 buffer->object(), // VkBuffer buffer;
414 0ull, // VkDeviceSize offset;
415 bufferSizeBytes, // VkDeviceSize size;
418 const VkBufferMemoryBarrier computeFinishBarrier =
420 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
421 DE_NULL, // const void* pNext;
422 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags srcAccessMask;
423 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
424 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
425 VK_QUEUE_FAMILY_IGNORED, // deUint32 destQueueFamilyIndex;
426 buffer->object(), // VkBuffer buffer;
427 0ull, // VkDeviceSize offset;
428 bufferSizeBytes, // VkDeviceSize size;
431 std::vector<VkShaderModuleSp> shaderModule;
432 std::vector<VkPipelineSp> pipeline;
433 for(size_t parametersNdx = 0; parametersNdx < m_parameters.size(); ++parametersNdx)
435 shaderModule.push_back(VkShaderModuleSp(new Unique<VkShaderModule>(createShaderModule(vk, device, m_context.getBinaryCollection().get(m_parameters[parametersNdx].shaderName), (VkShaderModuleCreateFlags)0u))));
436 const VkPipelineShaderStageCreateInfo pipelineShaderStageParams =
438 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
439 DE_NULL, // const void* pNext;
440 0u, // VkPipelineShaderStageCreateFlags flags;
441 VK_SHADER_STAGE_COMPUTE_BIT, // VkShaderStageFlagBits stage;
442 shaderModule.back().get()->get(), // VkShaderModule module;
443 "main", // const char* pName;
444 DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
447 const VkComputePipelineCreateInfo pipelineCreateInfo =
449 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, // VkStructureType sType;
450 DE_NULL, // const void* pNext;
451 0u, // VkPipelineCreateFlags flags;
452 pipelineShaderStageParams, // VkPipelineShaderStageCreateInfo stage;
453 pipelineLayout, // VkPipelineLayout layout;
454 DE_NULL, // VkPipeline basePipelineHandle;
455 0, // deInt32 basePipelineIndex;
457 pipeline.push_back(VkPipelineSp(new Unique<VkPipeline>(createComputePipeline(vk, device, DE_NULL , &pipelineCreateInfo))));
460 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
461 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
463 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT));
465 clearBuffer(vk, device, buffer, bufferSizeBytes);
466 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT);
467 vk.cmdBindDescriptorSets(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipelineLayout, 0u, 1u, &descriptorSet, 0u, DE_NULL);
468 vk.cmdResetQueryPool(*secondaryCmdBuffer, *queryPool, 0u, 1u);
469 vk.cmdBeginQuery(*secondaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
470 for(size_t parametersNdx = 0; parametersNdx < m_parameters.size(); ++parametersNdx)
472 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline[parametersNdx].get()->get());
473 vk.cmdDispatch(*secondaryCmdBuffer, m_parameters[parametersNdx].groupSize.x(), m_parameters[parametersNdx].groupSize.y(), m_parameters[parametersNdx].groupSize.z());
475 vk.cmdPipelineBarrier(*secondaryCmdBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
476 (VkDependencyFlags)0u, 0u, (const VkMemoryBarrier*)DE_NULL, 1u, &computeShaderWriteBarrier, 0u, (const VkImageMemoryBarrier*)DE_NULL);
478 vk.cmdEndQuery(*secondaryCmdBuffer, *queryPool, 0u);
479 endCommandBuffer(vk, *secondaryCmdBuffer);
481 beginCommandBuffer(vk, *primaryCmdBuffer);
482 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
484 vk.cmdPipelineBarrier(*primaryCmdBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_HOST_BIT,
485 (VkDependencyFlags)0u, 0u, (const VkMemoryBarrier*)DE_NULL, 1u, &computeFinishBarrier, 0u, (const VkImageMemoryBarrier*)DE_NULL);
487 endCommandBuffer(vk, *primaryCmdBuffer);
489 // Wait for completion
490 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
491 return checkResult(buffer, bufferSizeBytes, *queryPool);
494 tcu::TestStatus ComputeInvocationsSecondaryTestInstance::checkResult (const de::SharedPtr<Buffer> buffer, const VkDeviceSize bufferSizeBytes, const VkQueryPool queryPool)
496 const DeviceInterface& vk = m_context.getDeviceInterface();
497 const VkDevice device = m_context.getDevice();
499 deUint64 result = 0u;
500 deUint64 expected = 0u;
501 for(size_t parametersNdx = 0; parametersNdx < m_parameters.size(); ++parametersNdx)
502 expected += getComputeExecution(m_parameters[parametersNdx]);
503 VK_CHECK(vk.getQueryPoolResults(device, queryPool, 0u, 1u, sizeof(deUint64), &result, 0u, VK_QUERY_RESULT_64_BIT));
504 if (expected != result)
505 return tcu::TestStatus::fail("QueryPoolResults incorrect");
509 // Validate the results
510 const Allocation& bufferAllocation = buffer->getBoundMemory();
511 invalidateMappedMemoryRange(vk, device, bufferAllocation.getMemory(), bufferAllocation.getOffset(), bufferSizeBytes);
512 const deUint32* bufferPtr = static_cast<deUint32*>(bufferAllocation.getHostPtr());
513 deUint32 minSize = ~0u;
514 for(size_t parametersNdx = 0; parametersNdx < m_parameters.size(); ++parametersNdx)
515 minSize = deMinu32(minSize, getComputeExecution(m_parameters[parametersNdx]));
516 for (deUint32 ndx = 0u; ndx < minSize; ++ndx)
518 if (bufferPtr[ndx] != ndx * m_parameters.size())
519 return tcu::TestStatus::fail("Compute shader didn't write data to the buffer");
522 return tcu::TestStatus::pass("Pass");
525 class ComputeInvocationsSecondaryInheritedTestInstance : public ComputeInvocationsSecondaryTestInstance
528 ComputeInvocationsSecondaryInheritedTestInstance (Context& context, const std::vector<ParametersCompute>& parameters);
530 virtual void checkExtensions (void);
531 tcu::TestStatus executeTest (const VkCommandPool& cmdPool,
532 const VkPipelineLayout pipelineLayout,
533 const VkDescriptorSet& descriptorSet,
534 const de::SharedPtr<Buffer> buffer,
535 const VkDeviceSize bufferSizeBytes);
538 ComputeInvocationsSecondaryInheritedTestInstance::ComputeInvocationsSecondaryInheritedTestInstance (Context& context, const std::vector<ParametersCompute>& parameters)
539 : ComputeInvocationsSecondaryTestInstance (context, parameters)
543 void ComputeInvocationsSecondaryInheritedTestInstance::checkExtensions (void)
545 StatisticQueryTestInstance::checkExtensions();
546 if (!m_context.getDeviceFeatures().inheritedQueries)
547 throw tcu::NotSupportedError("Inherited queries are not supported");
550 tcu::TestStatus ComputeInvocationsSecondaryInheritedTestInstance::executeTest (const VkCommandPool& cmdPool,
551 const VkPipelineLayout pipelineLayout,
552 const VkDescriptorSet& descriptorSet,
553 const de::SharedPtr<Buffer> buffer,
554 const VkDeviceSize bufferSizeBytes)
556 typedef de::SharedPtr<Unique<VkShaderModule> > VkShaderModuleSp;
557 typedef de::SharedPtr<Unique<VkPipeline> > VkPipelineSp;
559 const DeviceInterface& vk = m_context.getDeviceInterface();
560 const VkDevice device = m_context.getDevice();
561 const VkQueue queue = m_context.getUniversalQueue();
563 const VkBufferMemoryBarrier computeShaderWriteBarrier =
565 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
566 DE_NULL, // const void* pNext;
567 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags srcAccessMask;
568 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags dstAccessMask;
569 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
570 VK_QUEUE_FAMILY_IGNORED, // deUint32 destQueueFamilyIndex;
571 buffer->object(), // VkBuffer buffer;
572 0ull, // VkDeviceSize offset;
573 bufferSizeBytes, // VkDeviceSize size;
576 const VkBufferMemoryBarrier computeFinishBarrier =
578 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
579 DE_NULL, // const void* pNext;
580 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags srcAccessMask;
581 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
582 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
583 VK_QUEUE_FAMILY_IGNORED, // deUint32 destQueueFamilyIndex;
584 buffer->object(), // VkBuffer buffer;
585 0ull, // VkDeviceSize offset;
586 bufferSizeBytes, // VkDeviceSize size;
589 std::vector<VkShaderModuleSp> shaderModule;
590 std::vector<VkPipelineSp> pipeline;
591 for(size_t parametersNdx = 0u; parametersNdx < m_parameters.size(); ++parametersNdx)
593 shaderModule.push_back(VkShaderModuleSp(new Unique<VkShaderModule>(createShaderModule(vk, device, m_context.getBinaryCollection().get(m_parameters[parametersNdx].shaderName), (VkShaderModuleCreateFlags)0u))));
594 const VkPipelineShaderStageCreateInfo pipelineShaderStageParams =
596 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
597 DE_NULL, // const void* pNext;
598 0u, // VkPipelineShaderStageCreateFlags flags;
599 VK_SHADER_STAGE_COMPUTE_BIT, // VkShaderStageFlagBits stage;
600 shaderModule.back().get()->get(), // VkShaderModule module;
601 "main", // const char* pName;
602 DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
605 const VkComputePipelineCreateInfo pipelineCreateInfo =
607 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, // VkStructureType sType;
608 DE_NULL, // const void* pNext;
609 0u, // VkPipelineCreateFlags flags;
610 pipelineShaderStageParams, // VkPipelineShaderStageCreateInfo stage;
611 pipelineLayout, // VkPipelineLayout layout;
612 DE_NULL, // VkPipeline basePipelineHandle;
613 0, // deInt32 basePipelineIndex;
615 pipeline.push_back(VkPipelineSp(new Unique<VkPipeline>(createComputePipeline(vk, device, DE_NULL , &pipelineCreateInfo))));
618 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
619 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
621 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT));
623 clearBuffer(vk, device, buffer, bufferSizeBytes);
624 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT);
625 vk.cmdBindDescriptorSets(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipelineLayout, 0u, 1u, &descriptorSet, 0u, DE_NULL);
626 for(size_t parametersNdx = 1; parametersNdx < m_parameters.size(); ++parametersNdx)
628 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline[parametersNdx].get()->get());
629 vk.cmdDispatch(*secondaryCmdBuffer, m_parameters[parametersNdx].groupSize.x(), m_parameters[parametersNdx].groupSize.y(), m_parameters[parametersNdx].groupSize.z());
631 vk.cmdPipelineBarrier(*secondaryCmdBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
632 (VkDependencyFlags)0u, 0u, (const VkMemoryBarrier*)DE_NULL, 1u, &computeShaderWriteBarrier, 0u, (const VkImageMemoryBarrier*)DE_NULL);
634 endCommandBuffer(vk, *secondaryCmdBuffer);
636 beginCommandBuffer(vk, *primaryCmdBuffer);
637 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
638 vk.cmdBindDescriptorSets(*primaryCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipelineLayout, 0u, 1u, &descriptorSet, 0u, DE_NULL);
639 vk.cmdBindPipeline(*primaryCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline[0].get()->get());
641 vk.cmdBeginQuery(*primaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
642 vk.cmdDispatch(*primaryCmdBuffer, m_parameters[0].groupSize.x(), m_parameters[0].groupSize.y(), m_parameters[0].groupSize.z());
644 vk.cmdPipelineBarrier(*primaryCmdBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
645 (VkDependencyFlags)0u, 0u, (const VkMemoryBarrier*)DE_NULL, 1u, &computeShaderWriteBarrier, 0u, (const VkImageMemoryBarrier*)DE_NULL);
647 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
649 vk.cmdPipelineBarrier(*primaryCmdBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_HOST_BIT,
650 (VkDependencyFlags)0u, 0u, (const VkMemoryBarrier*)DE_NULL, 1u, &computeFinishBarrier, 0u, (const VkImageMemoryBarrier*)DE_NULL);
652 vk.cmdEndQuery(*primaryCmdBuffer, *queryPool, 0u);
653 endCommandBuffer(vk, *primaryCmdBuffer);
655 // Wait for completion
656 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
657 return checkResult(buffer, bufferSizeBytes, *queryPool);
660 class GraphicBasicTestInstance : public StatisticQueryTestInstance
665 VertexData (const tcu::Vec4 position_, const tcu::Vec4 color_)
666 : position (position_)
672 struct ParametersGraphic
674 ParametersGraphic (const VkQueryPipelineStatisticFlags queryStatisticFlags_, const VkPrimitiveTopology primitiveTopology_)
675 : queryStatisticFlags (queryStatisticFlags_)
676 , primitiveTopology (primitiveTopology_)
678 VkQueryPipelineStatisticFlags queryStatisticFlags;
679 VkPrimitiveTopology primitiveTopology;
681 GraphicBasicTestInstance (vkt::Context& context,
682 const std::vector<VertexData>& data,
683 const ParametersGraphic& parametersGraphic);
684 tcu::TestStatus iterate (void);
686 de::SharedPtr<Buffer> creatAndFillVertexBuffer (void);
687 virtual void createPipeline (void) = 0;
688 void creatColorAttachmentAndRenderPass (void);
689 bool checkImage (void);
690 virtual tcu::TestStatus executeTest (void) = 0;
691 virtual tcu::TestStatus checkResult (VkQueryPool queryPool) = 0;
692 virtual void draw (VkCommandBuffer cmdBuffer) = 0;
694 const VkFormat m_colorAttachmentFormat;
695 de::SharedPtr<Image> m_colorAttachmentImage;
696 de::SharedPtr<Image> m_depthImage;
697 Move<VkImageView> m_attachmentView;
698 Move<VkImageView> m_depthiew;
699 Move<VkRenderPass> m_renderPass;
700 Move<VkFramebuffer> m_framebuffer;
701 Move<VkPipeline> m_pipeline;
702 Move<VkPipelineLayout> m_pipelineLayout;
703 const std::vector<VertexData>& m_data;
704 const ParametersGraphic& m_parametersGraphic;
707 GraphicBasicTestInstance::GraphicBasicTestInstance (vkt::Context& context,
708 const std::vector<VertexData>& data,
709 const ParametersGraphic& parametersGraphic)
710 : StatisticQueryTestInstance (context)
711 , m_colorAttachmentFormat (VK_FORMAT_R8G8B8A8_UNORM)
713 , m_parametersGraphic (parametersGraphic)
717 tcu::TestStatus GraphicBasicTestInstance::iterate (void)
720 creatColorAttachmentAndRenderPass();
722 return executeTest();
725 de::SharedPtr<Buffer> GraphicBasicTestInstance::creatAndFillVertexBuffer (void)
727 const DeviceInterface& vk = m_context.getDeviceInterface();
728 const VkDevice device = m_context.getDevice();
730 const VkDeviceSize dataSize = static_cast<VkDeviceSize>(deAlignSize(static_cast<size_t>( m_data.size() * sizeof(VertexData)),
731 static_cast<size_t>(m_context.getDeviceProperties().limits.nonCoherentAtomSize)));
733 de::SharedPtr<Buffer> vertexBuffer = Buffer::createAndAlloc(vk, device, BufferCreateInfo(dataSize,
734 VK_BUFFER_USAGE_VERTEX_BUFFER_BIT), m_context.getDefaultAllocator(), MemoryRequirement::HostVisible);
736 deUint8* ptr = reinterpret_cast<deUint8*>(vertexBuffer->getBoundMemory().getHostPtr());
737 deMemcpy(ptr, &m_data[0], static_cast<size_t>( m_data.size() * sizeof(VertexData)));
739 flushMappedMemoryRange(vk, device, vertexBuffer->getBoundMemory().getMemory(), vertexBuffer->getBoundMemory().getOffset(), dataSize);
743 void GraphicBasicTestInstance::creatColorAttachmentAndRenderPass (void)
745 const DeviceInterface& vk = m_context.getDeviceInterface();
746 const VkDevice device = m_context.getDevice();
749 VkExtent3D imageExtent =
756 const ImageCreateInfo colorImageCreateInfo (VK_IMAGE_TYPE_2D, m_colorAttachmentFormat, imageExtent, 1, 1, VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_TILING_OPTIMAL,
757 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT);
759 m_colorAttachmentImage = Image::createAndAlloc(vk, device, colorImageCreateInfo, m_context.getDefaultAllocator(), m_context.getUniversalQueueFamilyIndex());
761 const ImageViewCreateInfo attachmentViewInfo (m_colorAttachmentImage->object(), VK_IMAGE_VIEW_TYPE_2D, m_colorAttachmentFormat);
762 m_attachmentView = createImageView(vk, device, &attachmentViewInfo);
764 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,
765 vk::VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
767 m_depthImage = Image::createAndAlloc(vk, device, depthImageCreateInfo, m_context.getDefaultAllocator(), m_context.getUniversalQueueFamilyIndex());
769 // Construct a depth view from depth image
770 const ImageViewCreateInfo depthViewInfo (m_depthImage->object(), vk::VK_IMAGE_VIEW_TYPE_2D, VK_FORMAT_D16_UNORM);
771 m_depthiew = vk::createImageView(vk, device, &depthViewInfo);
775 // Renderpass and Framebuffer
776 RenderPassCreateInfo renderPassCreateInfo;
777 renderPassCreateInfo.addAttachment(AttachmentDescription(m_colorAttachmentFormat, // format
778 VK_SAMPLE_COUNT_1_BIT, // samples
779 VK_ATTACHMENT_LOAD_OP_CLEAR, // loadOp
780 VK_ATTACHMENT_STORE_OP_STORE , // storeOp
781 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // stencilLoadOp
782 VK_ATTACHMENT_STORE_OP_STORE , // stencilLoadOp
783 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // initialLauout
784 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)); // finalLayout
786 renderPassCreateInfo.addAttachment(AttachmentDescription(VK_FORMAT_D16_UNORM, // format
787 vk::VK_SAMPLE_COUNT_1_BIT, // samples
788 vk::VK_ATTACHMENT_LOAD_OP_CLEAR, // loadOp
789 vk::VK_ATTACHMENT_STORE_OP_DONT_CARE, // storeOp
790 vk::VK_ATTACHMENT_LOAD_OP_DONT_CARE, // stencilLoadOp
791 vk::VK_ATTACHMENT_STORE_OP_DONT_CARE, // stencilLoadOp
792 vk::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // initialLauout
793 vk::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)); // finalLayout
795 const VkAttachmentReference colorAttachmentReference =
798 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // layout
801 const VkAttachmentReference depthAttachmentReference =
804 vk::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL // layout
807 const VkSubpassDescription subpass =
809 (VkSubpassDescriptionFlags) 0, //VkSubpassDescriptionFlags flags;
810 VK_PIPELINE_BIND_POINT_GRAPHICS, //VkPipelineBindPoint pipelineBindPoint;
811 0u, //deUint32 inputAttachmentCount;
812 DE_NULL, //const VkAttachmentReference* pInputAttachments;
813 1u, //deUint32 colorAttachmentCount;
814 &colorAttachmentReference, //const VkAttachmentReference* pColorAttachments;
815 DE_NULL, //const VkAttachmentReference* pResolveAttachments;
816 &depthAttachmentReference, //const VkAttachmentReference* pDepthStencilAttachment;
817 0u, //deUint32 preserveAttachmentCount;
818 DE_NULL, //const deUint32* pPreserveAttachments;
821 renderPassCreateInfo.addSubpass(subpass);
822 m_renderPass = createRenderPass(vk, device, &renderPassCreateInfo);
824 std::vector<vk::VkImageView> attachments(2);
825 attachments[0] = *m_attachmentView;
826 attachments[1] = *m_depthiew;
828 FramebufferCreateInfo framebufferCreateInfo(*m_renderPass, attachments, WIDTH, HEIGHT, 1);
829 m_framebuffer = createFramebuffer(vk, device, &framebufferCreateInfo);
833 bool GraphicBasicTestInstance::checkImage (void)
835 const VkQueue queue = m_context.getUniversalQueue();
836 const VkOffset3D zeroOffset = { 0, 0, 0 };
837 const tcu::ConstPixelBufferAccess renderedFrame = m_colorAttachmentImage->readSurface(queue, m_context.getDefaultAllocator(),
838 VK_IMAGE_LAYOUT_GENERAL, zeroOffset, WIDTH, HEIGHT, VK_IMAGE_ASPECT_COLOR_BIT);
840 tcu::Texture2D referenceFrame (mapVkFormat(m_colorAttachmentFormat), WIDTH, HEIGHT);
841 referenceFrame.allocLevel(0);
843 for (int y = 0; y < HEIGHT/2; ++y)
844 for (int x = 0; x < WIDTH/2; ++x)
845 referenceFrame.getLevel(0).setPixel(m_data[colorNdx].color, x, y);
848 for (int y = HEIGHT/2; y < HEIGHT; ++y)
849 for (int x = 0; x < WIDTH/2; ++x)
850 referenceFrame.getLevel(0).setPixel(m_data[colorNdx].color, x, y);
853 for (int y = 0; y < HEIGHT/2; ++y)
854 for (int x = WIDTH/2; x < WIDTH; ++x)
855 referenceFrame.getLevel(0).setPixel(m_data[colorNdx].color, x, y);
858 for (int y = HEIGHT/2; y < HEIGHT; ++y)
859 for (int x = WIDTH/2; x < WIDTH; ++x)
860 referenceFrame.getLevel(0).setPixel(m_data[colorNdx].color, x, y);
862 return tcu::floatThresholdCompare(m_context.getTestContext().getLog(), "Result", "Image comparison result", referenceFrame.getLevel(0), renderedFrame, tcu::Vec4(0.01f), tcu::COMPARE_LOG_ON_ERROR);
865 class VertexShaderTestInstance : public GraphicBasicTestInstance
868 VertexShaderTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
870 virtual void createPipeline (void);
871 virtual tcu::TestStatus executeTest (void);
872 virtual tcu::TestStatus checkResult (VkQueryPool queryPool);
873 void draw (VkCommandBuffer cmdBuffer);
876 VertexShaderTestInstance::VertexShaderTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
877 : GraphicBasicTestInstance (context, data, parametersGraphic)
881 void VertexShaderTestInstance::createPipeline (void)
883 const DeviceInterface& vk = m_context.getDeviceInterface();
884 const VkDevice device = m_context.getDevice();
887 Unique<VkShaderModule> vs(createShaderModule(vk, device, m_context.getBinaryCollection().get("vertex"), 0));
888 Unique<VkShaderModule> fs(createShaderModule(vk, device, m_context.getBinaryCollection().get("fragment"), 0));
890 const PipelineCreateInfo::ColorBlendState::Attachment attachmentState;
892 const PipelineLayoutCreateInfo pipelineLayoutCreateInfo;
893 m_pipelineLayout = createPipelineLayout(vk, device, &pipelineLayoutCreateInfo);
895 const VkVertexInputBindingDescription vertexInputBindingDescription =
898 static_cast<deUint32>(sizeof(VertexData)), // stride;
899 VK_VERTEX_INPUT_RATE_VERTEX // inputRate
902 const VkVertexInputAttributeDescription vertexInputAttributeDescriptions[] =
907 VK_FORMAT_R32G32B32A32_SFLOAT,
909 }, // VertexElementData::position
913 VK_FORMAT_R32G32B32A32_SFLOAT,
914 static_cast<deUint32>(sizeof(tcu::Vec4))
915 }, // VertexElementData::color
918 const VkPipelineVertexInputStateCreateInfo vf_info =
920 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // pNext;
922 0u, // vertexBindingDescriptionCount;
923 1u, // pVertexBindingDescriptions;
924 &vertexInputBindingDescription, // vertexAttributeDescriptionCount;
925 2u, // pVertexAttributeDescriptions;
926 vertexInputAttributeDescriptions
929 PipelineCreateInfo pipelineCreateInfo(*m_pipelineLayout, *m_renderPass, 0, (VkPipelineCreateFlags)0);
930 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*vs, "main", VK_SHADER_STAGE_VERTEX_BIT));
931 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*fs, "main", VK_SHADER_STAGE_FRAGMENT_BIT));
932 pipelineCreateInfo.addState(PipelineCreateInfo::DepthStencilState());
933 pipelineCreateInfo.addState(PipelineCreateInfo::InputAssemblerState(m_parametersGraphic.primitiveTopology));
934 pipelineCreateInfo.addState(PipelineCreateInfo::ColorBlendState(1, &attachmentState));
936 const VkViewport viewport = makeViewport(WIDTH, HEIGHT);
937 const VkRect2D scissor = makeRect2D(WIDTH, HEIGHT);
938 pipelineCreateInfo.addState(PipelineCreateInfo::ViewportState(1u, std::vector<VkViewport>(1, viewport), std::vector<VkRect2D>(1, scissor)));
939 pipelineCreateInfo.addState(PipelineCreateInfo::DepthStencilState());
940 pipelineCreateInfo.addState(PipelineCreateInfo::RasterizerState());
941 pipelineCreateInfo.addState(PipelineCreateInfo::MultiSampleState());
942 pipelineCreateInfo.addState(vf_info);
943 m_pipeline = createGraphicsPipeline(vk, device, DE_NULL, &pipelineCreateInfo);
946 tcu::TestStatus VertexShaderTestInstance::executeTest (void)
948 const DeviceInterface& vk = m_context.getDeviceInterface();
949 const VkDevice device = m_context.getDevice();
950 const VkQueue queue = m_context.getUniversalQueue();
951 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
953 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
954 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
955 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
957 const VkDeviceSize vertexBufferOffset = 0u;
958 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
959 const VkBuffer vertexBuffer = vertexBufferSp->object();
961 const Unique<VkCommandBuffer> cmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
963 beginCommandBuffer(vk, *cmdBuffer);
965 std::vector<VkClearValue> renderPassClearValues (2);
966 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
968 initialTransitionColor2DImage(vk, *cmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
969 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
970 initialTransitionDepth2DImage(vk, *cmdBuffer, m_depthImage->object(), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
971 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
973 vk.cmdResetQueryPool(*cmdBuffer, *queryPool, 0u, 1u);
975 beginRenderPass(vk, *cmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, WIDTH, HEIGHT), (deUint32)renderPassClearValues.size(), &renderPassClearValues[0]);
977 vk.cmdBeginQuery(*cmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
978 vk.cmdBindVertexBuffers(*cmdBuffer, 0, 1, &vertexBuffer, &vertexBufferOffset);
979 vk.cmdBindPipeline(*cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
981 vk.cmdEndQuery(*cmdBuffer, *queryPool, 0u);
983 endRenderPass(vk, *cmdBuffer);
985 transition2DImage(vk, *cmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
986 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
988 endCommandBuffer(vk, *cmdBuffer);
990 // Wait for completion
991 submitCommandsAndWait(vk, device, queue, *cmdBuffer);
992 return checkResult (*queryPool);
995 tcu::TestStatus VertexShaderTestInstance::checkResult (VkQueryPool queryPool)
997 const DeviceInterface& vk = m_context.getDeviceInterface();
998 const VkDevice device = m_context.getDevice();
999 deUint64 result = 0u;
1000 deUint64 expectedMin = 0u;
1002 switch(m_parametersGraphic.queryStatisticFlags)
1004 case VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT:
1007 case VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT:
1008 expectedMin = m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST ? 15u :
1009 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY ? 8u :
1010 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY ? 14u :
1011 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY ? 6u :
1012 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY ? 8u :
1015 case VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT:
1016 expectedMin = m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST ? 16u :
1017 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST ? 8u :
1018 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP ? 15u :
1019 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST ? 5u :
1020 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ? 8u :
1021 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN ? 14u :
1022 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY ? 4u :
1023 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY ? 13u :
1024 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY ? 2u :
1025 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY ? 6u :
1028 case VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT:
1029 expectedMin = m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST ? 9u :
1030 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST ? 192u :
1031 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP ? 448u :
1032 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST ? 2016u :
1033 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ? 4096u :
1034 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN ? 10208u :
1035 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY ? 128u :
1036 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY ? 416u :
1037 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY ? 992u :
1038 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY ? 3072u :
1046 VK_CHECK(vk.getQueryPoolResults(device, queryPool, 0u, 1u, sizeof(deUint64), &result, 0u, VK_QUERY_RESULT_64_BIT));
1047 if (result < expectedMin)
1048 return tcu::TestStatus::fail("QueryPoolResults incorrect");
1050 if (m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP && !checkImage())
1051 return tcu::TestStatus::fail("Result image doesn't match expected image.");
1053 return tcu::TestStatus::pass("Pass");
1056 void VertexShaderTestInstance::draw (VkCommandBuffer cmdBuffer)
1058 const DeviceInterface& vk = m_context.getDeviceInterface();
1059 switch(m_parametersGraphic.primitiveTopology)
1061 case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
1062 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
1063 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
1064 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
1065 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
1066 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
1067 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
1068 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
1069 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
1070 vk.cmdDraw(cmdBuffer, 16u, 1u, 0u, 0u);
1072 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
1073 vk.cmdDraw(cmdBuffer, 4u, 1u, 0u, 0u);
1074 vk.cmdDraw(cmdBuffer, 4u, 1u, 4u, 1u);
1075 vk.cmdDraw(cmdBuffer, 4u, 1u, 8u, 2u);
1076 vk.cmdDraw(cmdBuffer, 4u, 1u, 12u, 3u);
1084 class VertexShaderSecondaryTestInstance : public VertexShaderTestInstance
1087 VertexShaderSecondaryTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1089 virtual tcu::TestStatus executeTest (void);
1092 VertexShaderSecondaryTestInstance::VertexShaderSecondaryTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1093 : VertexShaderTestInstance (context, data, parametersGraphic)
1097 tcu::TestStatus VertexShaderSecondaryTestInstance::executeTest (void)
1099 const DeviceInterface& vk = m_context.getDeviceInterface();
1100 const VkDevice device = m_context.getDevice();
1101 const VkQueue queue = m_context.getUniversalQueue();
1102 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1104 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1105 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1106 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1108 const VkDeviceSize vertexBufferOffset = 0u;
1109 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1110 const VkBuffer vertexBuffer = vertexBufferSp->object();
1112 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1113 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
1115 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, m_parametersGraphic.queryStatisticFlags, *m_renderPass, *m_framebuffer, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT);
1116 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1117 vk.cmdBeginQuery(*secondaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1118 vk.cmdBindVertexBuffers(*secondaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1119 draw(*secondaryCmdBuffer);
1120 vk.cmdEndQuery(*secondaryCmdBuffer, *queryPool, 0u);
1121 endCommandBuffer(vk, *secondaryCmdBuffer);
1123 beginCommandBuffer(vk, *primaryCmdBuffer);
1125 std::vector<VkClearValue> renderPassClearValues (2);
1126 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1128 initialTransitionColor2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1129 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
1130 initialTransitionDepth2DImage(vk, *primaryCmdBuffer, m_depthImage->object(), vk::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1131 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
1133 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
1135 beginRenderPass(vk, *primaryCmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, WIDTH, HEIGHT), (deUint32)renderPassClearValues.size(), &renderPassClearValues[0], VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
1136 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
1137 endRenderPass(vk, *primaryCmdBuffer);
1138 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
1139 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1141 endCommandBuffer(vk, *primaryCmdBuffer);
1143 // Wait for completion
1144 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
1145 return checkResult (*queryPool);
1148 class VertexShaderSecondaryInheritedTestInstance : public VertexShaderTestInstance
1151 VertexShaderSecondaryInheritedTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1153 void checkExtensions (void);
1154 virtual tcu::TestStatus executeTest (void);
1157 VertexShaderSecondaryInheritedTestInstance::VertexShaderSecondaryInheritedTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1158 : VertexShaderTestInstance (context, data, parametersGraphic)
1162 void VertexShaderSecondaryInheritedTestInstance::checkExtensions (void)
1164 StatisticQueryTestInstance::checkExtensions();
1165 if (!m_context.getDeviceFeatures().inheritedQueries)
1166 throw tcu::NotSupportedError("Inherited queries are not supported");
1169 tcu::TestStatus VertexShaderSecondaryInheritedTestInstance::executeTest (void)
1171 const DeviceInterface& vk = m_context.getDeviceInterface();
1172 const VkDevice device = m_context.getDevice();
1173 const VkQueue queue = m_context.getUniversalQueue();
1174 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1176 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1177 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1178 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1180 const VkDeviceSize vertexBufferOffset = 0u;
1181 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1182 const VkBuffer vertexBuffer = vertexBufferSp->object();
1184 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1185 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
1187 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, m_parametersGraphic.queryStatisticFlags, *m_renderPass, *m_framebuffer, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT);
1188 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1189 vk.cmdBindVertexBuffers(*secondaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1190 draw(*secondaryCmdBuffer);
1191 endCommandBuffer(vk, *secondaryCmdBuffer);
1193 beginCommandBuffer(vk, *primaryCmdBuffer);
1195 std::vector<VkClearValue> renderPassClearValues (2);
1196 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1198 initialTransitionColor2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1199 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
1200 initialTransitionDepth2DImage(vk, *primaryCmdBuffer, m_depthImage->object(), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1201 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
1203 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
1204 vk.cmdBeginQuery(*primaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1206 beginRenderPass(vk, *primaryCmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, WIDTH, HEIGHT), (deUint32)renderPassClearValues.size(), &renderPassClearValues[0], VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
1207 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
1208 endRenderPass(vk, *primaryCmdBuffer);
1209 vk.cmdEndQuery(*primaryCmdBuffer, *queryPool, 0u);
1210 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
1211 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1213 endCommandBuffer(vk, *primaryCmdBuffer);
1215 // Wait for completion
1216 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
1217 return checkResult (*queryPool);
1220 class GeometryShaderTestInstance : public GraphicBasicTestInstance
1223 GeometryShaderTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1225 virtual void checkExtensions (void);
1226 virtual void createPipeline (void);
1227 virtual tcu::TestStatus executeTest (void);
1228 tcu::TestStatus checkResult (VkQueryPool queryPool);
1229 void draw (VkCommandBuffer cmdBuffer);
1232 GeometryShaderTestInstance::GeometryShaderTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1233 : GraphicBasicTestInstance (context, data, parametersGraphic)
1237 void GeometryShaderTestInstance::checkExtensions (void)
1239 StatisticQueryTestInstance::checkExtensions();
1240 if (!m_context.getDeviceFeatures().geometryShader)
1241 throw tcu::NotSupportedError("Geometry shader are not supported");
1244 void GeometryShaderTestInstance::createPipeline (void)
1246 const DeviceInterface& vk = m_context.getDeviceInterface();
1247 const VkDevice device = m_context.getDevice();
1250 Unique<VkShaderModule> vs(createShaderModule(vk, device, m_context.getBinaryCollection().get("vertex"), (VkShaderModuleCreateFlags)0));
1251 Unique<VkShaderModule> gs(createShaderModule(vk, device, m_context.getBinaryCollection().get("geometry"), (VkShaderModuleCreateFlags)0));
1252 Unique<VkShaderModule> fs(createShaderModule(vk, device, m_context.getBinaryCollection().get("fragment"), (VkShaderModuleCreateFlags)0));
1254 const PipelineCreateInfo::ColorBlendState::Attachment attachmentState;
1256 const PipelineLayoutCreateInfo pipelineLayoutCreateInfo;
1257 m_pipelineLayout = createPipelineLayout(vk, device, &pipelineLayoutCreateInfo);
1259 const VkVertexInputBindingDescription vertexInputBindingDescription =
1262 static_cast<deUint32>(sizeof(VertexData)), // stride;
1263 VK_VERTEX_INPUT_RATE_VERTEX // inputRate
1266 const VkVertexInputAttributeDescription vertexInputAttributeDescriptions[] =
1271 VK_FORMAT_R32G32B32A32_SFLOAT,
1273 }, // VertexElementData::position
1277 VK_FORMAT_R32G32B32A32_SFLOAT,
1278 static_cast<deUint32>(sizeof(tcu::Vec4))
1279 }, // VertexElementData::color
1282 const VkPipelineVertexInputStateCreateInfo vf_info =
1284 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // pNext;
1286 0u, // vertexBindingDescriptionCount;
1287 1, // pVertexBindingDescriptions;
1288 &vertexInputBindingDescription, // vertexAttributeDescriptionCount;
1289 2, // pVertexAttributeDescriptions;
1290 vertexInputAttributeDescriptions
1293 PipelineCreateInfo pipelineCreateInfo(*m_pipelineLayout, *m_renderPass, 0, (VkPipelineCreateFlags)0);
1294 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*vs, "main", VK_SHADER_STAGE_VERTEX_BIT));
1295 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*gs, "main", VK_SHADER_STAGE_GEOMETRY_BIT));
1296 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*fs, "main", VK_SHADER_STAGE_FRAGMENT_BIT));
1297 pipelineCreateInfo.addState(PipelineCreateInfo::InputAssemblerState(m_parametersGraphic.primitiveTopology));
1298 pipelineCreateInfo.addState(PipelineCreateInfo::ColorBlendState(1, &attachmentState));
1300 const VkViewport viewport = makeViewport(WIDTH, HEIGHT);
1301 const VkRect2D scissor = makeRect2D(WIDTH, HEIGHT);
1303 pipelineCreateInfo.addState(PipelineCreateInfo::ViewportState(1, std::vector<VkViewport>(1, viewport), std::vector<VkRect2D>(1, scissor)));
1305 if (m_context.getDeviceFeatures().depthBounds)
1306 pipelineCreateInfo.addState(PipelineCreateInfo::DepthStencilState(true, true, VK_COMPARE_OP_GREATER_OR_EQUAL, true));
1308 pipelineCreateInfo.addState(PipelineCreateInfo::DepthStencilState());
1310 pipelineCreateInfo.addState(PipelineCreateInfo::RasterizerState(false));
1311 pipelineCreateInfo.addState(PipelineCreateInfo::MultiSampleState());
1312 pipelineCreateInfo.addState(vf_info);
1313 m_pipeline = createGraphicsPipeline(vk, device, DE_NULL, &pipelineCreateInfo);
1316 tcu::TestStatus GeometryShaderTestInstance::executeTest (void)
1318 const DeviceInterface& vk = m_context.getDeviceInterface();
1319 const VkDevice device = m_context.getDevice();
1320 const VkQueue queue = m_context.getUniversalQueue();
1321 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1323 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1324 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1325 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1327 const VkDeviceSize vertexBufferOffset = 0u;
1328 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1329 const VkBuffer vertexBuffer = vertexBufferSp->object();
1331 const Unique<VkCommandBuffer> cmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1333 beginCommandBuffer(vk, *cmdBuffer);
1335 std::vector<VkClearValue> renderPassClearValues (2);
1336 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1338 initialTransitionColor2DImage(vk, *cmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1339 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
1340 initialTransitionDepth2DImage(vk, *cmdBuffer, m_depthImage->object(), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1341 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
1343 vk.cmdResetQueryPool(*cmdBuffer, *queryPool, 0u, 1u);
1345 beginRenderPass(vk, *cmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, WIDTH, HEIGHT), (deUint32)renderPassClearValues.size(), &renderPassClearValues[0]);
1347 vk.cmdBeginQuery(*cmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1348 vk.cmdBindVertexBuffers(*cmdBuffer, 0, 1, &vertexBuffer, &vertexBufferOffset);
1349 vk.cmdBindPipeline(*cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1353 vk.cmdEndQuery(*cmdBuffer, *queryPool, 0u);
1355 endRenderPass(vk, *cmdBuffer);
1357 transition2DImage(vk, *cmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
1358 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1360 endCommandBuffer(vk, *cmdBuffer);
1362 // Wait for completion
1363 submitCommandsAndWait(vk, device, queue, *cmdBuffer);
1364 return checkResult(*queryPool);
1367 tcu::TestStatus GeometryShaderTestInstance::checkResult (VkQueryPool queryPool)
1369 const DeviceInterface& vk = m_context.getDeviceInterface();
1370 const VkDevice device = m_context.getDevice();
1371 deUint64 result = 0u;
1372 deUint64 expectedMin = 0u;
1374 switch(m_parametersGraphic.queryStatisticFlags)
1376 case VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT:
1377 expectedMin = m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST ? 16u :
1378 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST ? 8u :
1379 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP ? 15u :
1380 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST ? 4u :
1381 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ? 4u :
1382 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN ? 14u :
1383 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY ? 4u :
1384 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY ? 13u :
1385 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY ? 2u :
1386 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY ? 6u :
1389 case VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT:
1390 case VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT:
1391 case VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT:
1392 expectedMin = m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST ? 112u :
1393 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST ? 32u :
1394 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP ? 60u :
1395 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST ? 8u :
1396 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ? 8u :
1397 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN ? 28u :
1398 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY ? 16u :
1399 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY ? 52u :
1400 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY ? 4u :
1401 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY ? 12u :
1409 VK_CHECK(vk.getQueryPoolResults(device, queryPool, 0u, 1u, sizeof(deUint64), &result, 0u, VK_QUERY_RESULT_64_BIT));
1410 if (result < expectedMin)
1411 return tcu::TestStatus::fail("QueryPoolResults incorrect");
1413 if ( (m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST || m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ) && !checkImage())
1414 return tcu::TestStatus::fail("Result image doesn't match expected image.");
1416 return tcu::TestStatus::pass("Pass");
1419 void GeometryShaderTestInstance::draw (VkCommandBuffer cmdBuffer)
1421 const DeviceInterface& vk = m_context.getDeviceInterface();
1422 if (m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ||
1423 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST)
1425 vk.cmdDraw(cmdBuffer, 3u, 1u, 0u, 1u);
1426 vk.cmdDraw(cmdBuffer, 3u, 1u, 4u, 1u);
1427 vk.cmdDraw(cmdBuffer, 3u, 1u, 8u, 2u);
1428 vk.cmdDraw(cmdBuffer, 3u, 1u, 12u, 3u);
1432 vk.cmdDraw(cmdBuffer, 16u, 1u, 0u, 0u);
1436 class GeometryShaderSecondaryTestInstance : public GeometryShaderTestInstance
1439 GeometryShaderSecondaryTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1441 virtual tcu::TestStatus executeTest (void);
1444 GeometryShaderSecondaryTestInstance::GeometryShaderSecondaryTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1445 : GeometryShaderTestInstance (context, data, parametersGraphic)
1449 tcu::TestStatus GeometryShaderSecondaryTestInstance::executeTest (void)
1451 const DeviceInterface& vk = m_context.getDeviceInterface();
1452 const VkDevice device = m_context.getDevice();
1453 const VkQueue queue = m_context.getUniversalQueue();
1454 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1456 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1457 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1458 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1460 const VkDeviceSize vertexBufferOffset = 0;
1461 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1462 const VkBuffer vertexBuffer = vertexBufferSp->object();
1464 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1465 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
1467 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, m_parametersGraphic.queryStatisticFlags, *m_renderPass, *m_framebuffer, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT);
1468 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1469 vk.cmdBeginQuery(*secondaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1470 vk.cmdBindVertexBuffers(*secondaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1471 draw(*secondaryCmdBuffer);
1472 vk.cmdEndQuery(*secondaryCmdBuffer, *queryPool, 0u);
1473 endCommandBuffer(vk, *secondaryCmdBuffer);
1475 beginCommandBuffer(vk, *primaryCmdBuffer);
1477 std::vector<VkClearValue> renderPassClearValues (2);
1478 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1480 initialTransitionColor2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1481 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
1482 initialTransitionDepth2DImage(vk, *primaryCmdBuffer, m_depthImage->object(), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1483 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
1485 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
1486 beginRenderPass(vk, *primaryCmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, WIDTH, HEIGHT), (deUint32)renderPassClearValues.size(), &renderPassClearValues[0], VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
1487 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
1488 endRenderPass(vk, *primaryCmdBuffer);
1490 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
1491 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1493 endCommandBuffer(vk, *primaryCmdBuffer);
1495 // Wait for completion
1496 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
1497 return checkResult(*queryPool);
1500 class GeometryShaderSecondaryInheritedTestInstance : public GeometryShaderTestInstance
1503 GeometryShaderSecondaryInheritedTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1505 void checkExtensions (void);
1506 virtual tcu::TestStatus executeTest (void);
1509 GeometryShaderSecondaryInheritedTestInstance::GeometryShaderSecondaryInheritedTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1510 : GeometryShaderTestInstance (context, data, parametersGraphic)
1514 void GeometryShaderSecondaryInheritedTestInstance::checkExtensions (void)
1516 GeometryShaderTestInstance::checkExtensions();
1517 if (!m_context.getDeviceFeatures().inheritedQueries)
1518 throw tcu::NotSupportedError("Inherited queries are not supported");
1521 tcu::TestStatus GeometryShaderSecondaryInheritedTestInstance::executeTest (void)
1523 const DeviceInterface& vk = m_context.getDeviceInterface();
1524 const VkDevice device = m_context.getDevice();
1525 const VkQueue queue = m_context.getUniversalQueue();
1526 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1528 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1529 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1530 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1532 const VkDeviceSize vertexBufferOffset = 0u;
1533 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1534 const VkBuffer vertexBuffer = vertexBufferSp->object();
1536 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1537 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
1539 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, m_parametersGraphic.queryStatisticFlags, *m_renderPass, *m_framebuffer, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT);
1540 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1541 vk.cmdBindVertexBuffers(*secondaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1542 draw(*secondaryCmdBuffer);
1543 endCommandBuffer(vk, *secondaryCmdBuffer);
1545 beginCommandBuffer(vk, *primaryCmdBuffer);
1547 std::vector<VkClearValue> renderPassClearValues (2);
1548 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1550 initialTransitionColor2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1551 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
1552 initialTransitionDepth2DImage(vk, *primaryCmdBuffer, m_depthImage->object(), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1553 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
1555 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
1556 vk.cmdBeginQuery(*primaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1557 beginRenderPass(vk, *primaryCmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, WIDTH, HEIGHT), (deUint32)renderPassClearValues.size(), &renderPassClearValues[0], VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
1558 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
1559 endRenderPass(vk, *primaryCmdBuffer);
1560 vk.cmdEndQuery(*primaryCmdBuffer, *queryPool, 0u);
1562 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
1563 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1565 endCommandBuffer(vk, *primaryCmdBuffer);
1567 // Wait for completion
1568 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
1569 return checkResult(*queryPool);
1572 class TessellationShaderTestInstance : public GraphicBasicTestInstance
1575 TessellationShaderTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1577 virtual void checkExtensions (void);
1578 virtual void createPipeline (void);
1579 virtual tcu::TestStatus executeTest (void);
1580 virtual tcu::TestStatus checkResult (VkQueryPool queryPool);
1581 void draw (VkCommandBuffer cmdBuffer);
1584 TessellationShaderTestInstance::TessellationShaderTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1585 : GraphicBasicTestInstance (context, data, parametersGraphic)
1589 void TessellationShaderTestInstance::checkExtensions (void)
1591 StatisticQueryTestInstance::checkExtensions();
1592 if (!m_context.getDeviceFeatures().tessellationShader)
1593 throw tcu::NotSupportedError("Tessellation shader are not supported");
1597 void TessellationShaderTestInstance::createPipeline (void)
1599 const DeviceInterface& vk = m_context.getDeviceInterface();
1600 const VkDevice device = m_context.getDevice();
1603 Unique<VkShaderModule> vs(createShaderModule(vk, device, m_context.getBinaryCollection().get("vertex"), (VkShaderModuleCreateFlags)0));
1604 Unique<VkShaderModule> tc(createShaderModule(vk, device, m_context.getBinaryCollection().get("tessellation_control"), (VkShaderModuleCreateFlags)0));
1605 Unique<VkShaderModule> te(createShaderModule(vk, device, m_context.getBinaryCollection().get("tessellation_evaluation"), (VkShaderModuleCreateFlags)0));
1606 Unique<VkShaderModule> fs(createShaderModule(vk, device, m_context.getBinaryCollection().get("fragment"), (VkShaderModuleCreateFlags)0));
1608 const PipelineCreateInfo::ColorBlendState::Attachment attachmentState;
1610 const PipelineLayoutCreateInfo pipelineLayoutCreateInfo;
1611 m_pipelineLayout = createPipelineLayout(vk, device, &pipelineLayoutCreateInfo);
1613 const VkVertexInputBindingDescription vertexInputBindingDescription =
1616 static_cast<deUint32>(sizeof(VertexData)), // stride;
1617 VK_VERTEX_INPUT_RATE_VERTEX // inputRate
1620 const VkVertexInputAttributeDescription vertexInputAttributeDescriptions[] =
1625 VK_FORMAT_R32G32B32A32_SFLOAT,
1627 }, // VertexElementData::position
1631 VK_FORMAT_R32G32B32A32_SFLOAT,
1632 static_cast<deUint32>(sizeof(tcu::Vec4))
1633 }, // VertexElementData::color
1636 const VkPipelineVertexInputStateCreateInfo vf_info =
1638 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // pNext;
1640 0u, // vertexBindingDescriptionCount;
1641 1u, // pVertexBindingDescriptions;
1642 &vertexInputBindingDescription, // vertexAttributeDescriptionCount;
1643 2u, // pVertexAttributeDescriptions;
1644 vertexInputAttributeDescriptions
1647 PipelineCreateInfo pipelineCreateInfo(*m_pipelineLayout, *m_renderPass, 0, (VkPipelineCreateFlags)0);
1648 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*vs, "main", VK_SHADER_STAGE_VERTEX_BIT));
1649 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*tc, "main", VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT));
1650 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*te, "main", VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT));
1651 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*fs, "main", VK_SHADER_STAGE_FRAGMENT_BIT));
1652 pipelineCreateInfo.addState (PipelineCreateInfo::TessellationState(4));
1653 pipelineCreateInfo.addState(PipelineCreateInfo::InputAssemblerState(VK_PRIMITIVE_TOPOLOGY_PATCH_LIST));
1654 pipelineCreateInfo.addState(PipelineCreateInfo::ColorBlendState(1, &attachmentState));
1656 const VkViewport viewport = makeViewport(WIDTH, HEIGHT);
1657 const VkRect2D scissor = makeRect2D(WIDTH, HEIGHT);
1659 pipelineCreateInfo.addState(PipelineCreateInfo::ViewportState(1, std::vector<VkViewport>(1, viewport), std::vector<VkRect2D>(1, scissor)));
1660 pipelineCreateInfo.addState(PipelineCreateInfo::DepthStencilState());
1661 pipelineCreateInfo.addState(PipelineCreateInfo::RasterizerState());
1662 pipelineCreateInfo.addState(PipelineCreateInfo::MultiSampleState());
1663 pipelineCreateInfo.addState(vf_info);
1664 m_pipeline = createGraphicsPipeline(vk, device, DE_NULL, &pipelineCreateInfo);
1667 tcu::TestStatus TessellationShaderTestInstance::executeTest (void)
1669 const DeviceInterface& vk = m_context.getDeviceInterface();
1670 const VkDevice device = m_context.getDevice();
1671 const VkQueue queue = m_context.getUniversalQueue();
1672 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1674 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1675 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1676 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1678 const VkDeviceSize vertexBufferOffset = 0u;
1679 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1680 const VkBuffer vertexBuffer = vertexBufferSp->object();
1682 const Unique<VkCommandBuffer> cmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1684 beginCommandBuffer(vk, *cmdBuffer);
1686 std::vector<VkClearValue> renderPassClearValues (2);
1687 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1689 initialTransitionColor2DImage(vk, *cmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1690 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
1691 initialTransitionDepth2DImage(vk, *cmdBuffer, m_depthImage->object(), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1692 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
1694 vk.cmdResetQueryPool(*cmdBuffer, *queryPool, 0u, 1u);
1696 beginRenderPass(vk, *cmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, WIDTH, HEIGHT), (deUint32)renderPassClearValues.size(), &renderPassClearValues[0]);
1698 vk.cmdBeginQuery(*cmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1699 vk.cmdBindVertexBuffers(*cmdBuffer, 0, 1, &vertexBuffer, &vertexBufferOffset);
1700 vk.cmdBindPipeline(*cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1704 vk.cmdEndQuery(*cmdBuffer, *queryPool, 0u);
1706 endRenderPass(vk, *cmdBuffer);
1708 transition2DImage(vk, *cmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
1709 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1711 endCommandBuffer(vk, *cmdBuffer);
1713 // Wait for completion
1714 submitCommandsAndWait(vk, device, queue, *cmdBuffer);
1715 return checkResult (*queryPool);
1718 tcu::TestStatus TessellationShaderTestInstance::checkResult (VkQueryPool queryPool)
1720 const DeviceInterface& vk = m_context.getDeviceInterface();
1721 const VkDevice device = m_context.getDevice();
1722 deUint64 result = 0u;
1723 deUint64 expectedMin = 0u;
1725 switch(m_parametersGraphic.queryStatisticFlags)
1727 case VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT:
1730 case VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT:
1737 VK_CHECK(vk.getQueryPoolResults(device, queryPool, 0u, 1u, sizeof(deUint64), &result, 0u, VK_QUERY_RESULT_64_BIT));
1738 if (result < expectedMin)
1739 return tcu::TestStatus::fail("QueryPoolResults incorrect");
1742 return tcu::TestStatus::fail("Result image doesn't match expected image.");
1744 return tcu::TestStatus::pass("Pass");
1747 void TessellationShaderTestInstance::draw (VkCommandBuffer cmdBuffer)
1749 const DeviceInterface& vk = m_context.getDeviceInterface();
1750 vk.cmdDraw(cmdBuffer, static_cast<deUint32>(m_data.size()), 1u, 0u, 0u);
1753 class TessellationShaderSecondrayTestInstance : public TessellationShaderTestInstance
1756 TessellationShaderSecondrayTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1758 virtual tcu::TestStatus executeTest (void);
1761 TessellationShaderSecondrayTestInstance::TessellationShaderSecondrayTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1762 : TessellationShaderTestInstance (context, data, parametersGraphic)
1766 tcu::TestStatus TessellationShaderSecondrayTestInstance::executeTest (void)
1768 const DeviceInterface& vk = m_context.getDeviceInterface();
1769 const VkDevice device = m_context.getDevice();
1770 const VkQueue queue = m_context.getUniversalQueue();
1771 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1773 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1774 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1775 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1777 const VkDeviceSize vertexBufferOffset = 0u;
1778 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1779 const VkBuffer vertexBuffer = vertexBufferSp->object();
1781 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1782 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
1784 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, m_parametersGraphic.queryStatisticFlags, *m_renderPass, *m_framebuffer, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT);
1785 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1786 vk.cmdBeginQuery(*secondaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1787 vk.cmdBindVertexBuffers(*secondaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1788 draw(*secondaryCmdBuffer);
1789 vk.cmdEndQuery(*secondaryCmdBuffer, *queryPool, 0u);
1790 endCommandBuffer(vk, *secondaryCmdBuffer);
1792 beginCommandBuffer(vk, *primaryCmdBuffer);
1794 std::vector<VkClearValue> renderPassClearValues (2);
1795 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1797 initialTransitionColor2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1798 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
1799 initialTransitionDepth2DImage(vk, *primaryCmdBuffer, m_depthImage->object(), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1800 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
1802 vk.cmdBindVertexBuffers(*primaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1803 vk.cmdBindPipeline(*primaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1804 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
1806 beginRenderPass(vk, *primaryCmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, WIDTH, HEIGHT), (deUint32)renderPassClearValues.size(), &renderPassClearValues[0], VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
1807 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
1808 endRenderPass(vk, *primaryCmdBuffer);
1810 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
1811 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1813 endCommandBuffer(vk, *primaryCmdBuffer);
1815 // Wait for completion
1816 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
1817 return checkResult (*queryPool);
1820 class TessellationShaderSecondrayInheritedTestInstance : public TessellationShaderTestInstance
1823 TessellationShaderSecondrayInheritedTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1825 virtual void checkExtensions (void);
1826 virtual tcu::TestStatus executeTest (void);
1829 TessellationShaderSecondrayInheritedTestInstance::TessellationShaderSecondrayInheritedTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1830 : TessellationShaderTestInstance (context, data, parametersGraphic)
1834 void TessellationShaderSecondrayInheritedTestInstance::checkExtensions (void)
1836 TessellationShaderTestInstance::checkExtensions();
1837 if (!m_context.getDeviceFeatures().inheritedQueries)
1838 throw tcu::NotSupportedError("Inherited queries are not supported");
1841 tcu::TestStatus TessellationShaderSecondrayInheritedTestInstance::executeTest (void)
1843 const DeviceInterface& vk = m_context.getDeviceInterface();
1844 const VkDevice device = m_context.getDevice();
1845 const VkQueue queue = m_context.getUniversalQueue();
1846 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1848 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1849 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1850 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1852 const VkDeviceSize vertexBufferOffset = 0u;
1853 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1854 const VkBuffer vertexBuffer = vertexBufferSp->object();
1856 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1857 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
1859 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, m_parametersGraphic.queryStatisticFlags, *m_renderPass, *m_framebuffer, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT);
1860 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1861 vk.cmdBindVertexBuffers(*secondaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1862 draw(*secondaryCmdBuffer);
1863 endCommandBuffer(vk, *secondaryCmdBuffer);
1865 beginCommandBuffer(vk, *primaryCmdBuffer);
1867 std::vector<VkClearValue> renderPassClearValues (2);
1868 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1870 initialTransitionColor2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1871 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
1872 initialTransitionDepth2DImage(vk, *primaryCmdBuffer, m_depthImage->object(), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1873 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
1875 vk.cmdBindVertexBuffers(*primaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1876 vk.cmdBindPipeline(*primaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1877 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
1878 vk.cmdBeginQuery(*primaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1880 beginRenderPass(vk, *primaryCmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, WIDTH, HEIGHT), (deUint32)renderPassClearValues.size(), &renderPassClearValues[0], VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
1881 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
1882 endRenderPass(vk, *primaryCmdBuffer);
1883 vk.cmdEndQuery(*primaryCmdBuffer, *queryPool, 0u);
1885 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
1886 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1888 endCommandBuffer(vk, *primaryCmdBuffer);
1890 // Wait for completion
1891 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
1892 return checkResult (*queryPool);
1895 template<class Instance>
1896 class QueryPoolStatisticsTest : public TestCase
1899 QueryPoolStatisticsTest (tcu::TestContext &context, const char *name, const char *description)
1900 : TestCase (context, name, description)
1902 const tcu::UVec3 localSize[] =
1904 tcu::UVec3 (2u, 2u, 2u),
1905 tcu::UVec3 (1u, 1u, 1u),
1906 tcu::UVec3 (WIDTH/(7u*3u), 7u, 3u),
1909 const tcu::UVec3 groupSize[] =
1911 tcu::UVec3 (2u, 2u, 2u),
1912 tcu::UVec3 (WIDTH/(7u*3u), 7u, 3u),
1913 tcu::UVec3 (1u, 1u, 1u),
1916 DE_ASSERT(DE_LENGTH_OF_ARRAY(localSize) == DE_LENGTH_OF_ARRAY(groupSize));
1918 for(int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(localSize); ++shaderNdx)
1920 std::ostringstream shaderName;
1921 shaderName<< "compute_" << shaderNdx;
1922 const ComputeInvocationsTestInstance::ParametersCompute prameters =
1924 localSize[shaderNdx],
1925 groupSize[shaderNdx],
1928 m_parameters.push_back(prameters);
1932 vkt::TestInstance* createInstance (vkt::Context& context) const
1934 return new Instance(context, m_parameters);
1937 void initPrograms(SourceCollections& sourceCollections) const
1939 std::ostringstream source;
1940 source << "layout(binding = 0) writeonly buffer Output {\n"
1941 << " uint values[];\n"
1943 << "void main (void) {\n"
1944 << " uvec3 indexUvec3 = uvec3 (gl_GlobalInvocationID.x,\n"
1945 << " gl_GlobalInvocationID.y * gl_NumWorkGroups.x * gl_WorkGroupSize.x,\n"
1946 << " gl_GlobalInvocationID.z * gl_NumWorkGroups.x * gl_NumWorkGroups.y * gl_WorkGroupSize.x * gl_WorkGroupSize.y);\n"
1947 << " uint index = indexUvec3.x + indexUvec3.y + indexUvec3.z;\n"
1948 << " sb_out.values[index] += index;\n"
1951 for(size_t shaderNdx = 0; shaderNdx < m_parameters.size(); ++shaderNdx)
1953 std::ostringstream src;
1954 src << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
1955 << "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"
1957 sourceCollections.glslSources.add(m_parameters[shaderNdx].shaderName) << glu::ComputeSource(src.str());
1961 std::vector<ComputeInvocationsTestInstance::ParametersCompute> m_parameters;
1964 template<class Instance>
1965 class QueryPoolGraphicStatisticsTest : public TestCase
1968 QueryPoolGraphicStatisticsTest (tcu::TestContext &context, const char *name, const char *description, const GraphicBasicTestInstance::ParametersGraphic parametersGraphic)
1969 : TestCase (context, name, description)
1970 , m_parametersGraphic (parametersGraphic)
1972 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4(-1.0f,-1.0f, 1.0f, 1.0f), tcu::RGBA::red().toVec()));
1973 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4(-1.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::red().toVec()));
1974 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f,-1.0f, 1.0f, 1.0f), tcu::RGBA::red().toVec()));
1975 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::red().toVec()));
1977 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4(-1.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::green().toVec()));
1978 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4(-1.0f, 1.0f, 1.0f, 1.0f), tcu::RGBA::green().toVec()));
1979 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::green().toVec()));
1980 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f, 1.0f, 1.0f, 1.0f), tcu::RGBA::green().toVec()));
1982 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f,-1.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec()));
1983 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec()));
1984 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 1.0f,-1.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec()));
1985 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 1.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec()));
1987 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::gray().toVec()));
1988 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f, 1.0f, 1.0f, 1.0f), tcu::RGBA::gray().toVec()));
1989 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 1.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::gray().toVec()));
1990 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 1.0f, 1.0f, 1.0f, 1.0f), tcu::RGBA::gray().toVec()));
1993 vkt::TestInstance* createInstance (vkt::Context& context) const
1995 return new Instance(context, m_data, m_parametersGraphic);
1998 void initPrograms(SourceCollections& sourceCollections) const
2001 std::ostringstream source;
2002 source << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
2003 << "layout(location = 0) in highp vec4 in_position;\n"
2004 << "layout(location = 1) in vec4 in_color;\n"
2005 << "layout(location = 0) out vec4 out_color;\n"
2006 << "void main (void)\n"
2008 << " gl_Position = in_position;\n"
2009 << " out_color = in_color;\n"
2011 sourceCollections.glslSources.add("vertex") << glu::VertexSource(source.str());
2014 if (m_parametersGraphic.queryStatisticFlags & (VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT|
2015 VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT))
2016 {// Tessellation control & evaluation
2017 std::ostringstream source_tc;
2018 source_tc << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450) << "\n"
2019 << "#extension GL_EXT_tessellation_shader : require\n"
2020 << "layout(vertices = 4) out;\n"
2021 << "layout(location = 0) in vec4 in_color[];\n"
2022 << "layout(location = 0) out vec4 out_color[];\n"
2024 << "void main (void)\n"
2026 << " if( gl_InvocationID == 0 )\n"
2028 << " gl_TessLevelInner[0] = 4.0f;\n"
2029 << " gl_TessLevelInner[1] = 4.0f;\n"
2030 << " gl_TessLevelOuter[0] = 4.0f;\n"
2031 << " gl_TessLevelOuter[1] = 4.0f;\n"
2032 << " gl_TessLevelOuter[2] = 4.0f;\n"
2033 << " gl_TessLevelOuter[3] = 4.0f;\n"
2035 << " out_color[gl_InvocationID] = in_color[gl_InvocationID];\n"
2036 << " gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
2038 sourceCollections.glslSources.add("tessellation_control") << glu::TessellationControlSource(source_tc.str());
2040 std::ostringstream source_te;
2041 source_te << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450) << "\n"
2042 << "#extension GL_EXT_tessellation_shader : require\n"
2043 << "layout( quads, equal_spacing, ccw ) in;\n"
2044 << "layout(location = 0) in vec4 in_color[];\n"
2045 << "layout(location = 0) out vec4 out_color;\n"
2046 << "void main (void)\n"
2048 << " const float u = gl_TessCoord.x;\n"
2049 << " const float v = gl_TessCoord.y;\n"
2050 << " const float w = gl_TessCoord.z;\n"
2051 << " 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"
2052 << " out_color = in_color[0];\n"
2054 sourceCollections.glslSources.add("tessellation_evaluation") << glu::TessellationEvaluationSource(source_te.str());
2057 if(m_parametersGraphic.queryStatisticFlags & (VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT | VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT |
2058 VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT | VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT))
2059 { // Geometry Shader
2060 std::ostringstream source;
2061 source << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
2062 << "layout("<<inputTypeToGLString(m_parametersGraphic.primitiveTopology)<<") in;\n"
2063 << "layout("<<outputTypeToGLString (m_parametersGraphic.primitiveTopology)<<", max_vertices = 16) out;\n"
2064 << "layout(location = 0) in vec4 in_color[];\n"
2065 << "layout(location = 0) out vec4 out_color;\n"
2066 << "void main (void)\n"
2068 << " out_color = in_color[0];\n"
2069 << " gl_Position = gl_in[0].gl_Position;\n"
2070 << " EmitVertex();\n"
2071 << " EndPrimitive();\n"
2073 << " out_color = in_color[0];\n"
2074 << " gl_Position = vec4(1.0, 1.0, 1.0, 1.0);\n"
2075 << " EmitVertex();\n"
2076 << " out_color = in_color[0];\n"
2077 << " gl_Position = vec4(-1.0, -1.0, 1.0, 1.0);\n"
2078 << " EmitVertex();\n"
2079 << " EndPrimitive();\n"
2081 if (m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ||
2082 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST)
2085 << " out_color = in_color[0];\n"
2086 << " gl_Position = gl_in[0].gl_Position;\n"
2087 << " EmitVertex();\n"
2088 << " out_color = in_color[0];\n"
2089 << " gl_Position = gl_in[1].gl_Position;\n"
2090 << " EmitVertex();\n"
2091 << " out_color = in_color[0];\n"
2092 << " gl_Position = gl_in[2].gl_Position;\n"
2093 << " EmitVertex();\n"
2094 << " out_color = in_color[0];\n"
2095 << " gl_Position = vec4(gl_in[2].gl_Position.x, gl_in[1].gl_Position.y, 1.0, 1.0);\n"
2096 << " EmitVertex();\n"
2097 << " EndPrimitive();\n";
2101 source << " out_color = in_color[0];\n"
2102 << " gl_Position = vec4(1.0, 1.0, 1.0, 1.0);\n"
2103 << " EmitVertex();\n"
2104 << " out_color = in_color[0];\n"
2105 << " gl_Position = vec4(1.0, -1.0, 1.0, 1.0);\n"
2106 << " EmitVertex();\n"
2107 << " out_color = in_color[0];\n"
2108 << " gl_Position = vec4(-1.0, 1.0, 1.0, 1.0);\n"
2109 << " EmitVertex();\n"
2110 << " out_color = in_color[0];\n"
2111 << " gl_Position = vec4(-1.0, -1.0, 1.0, 1.0);\n"
2112 << " EmitVertex();\n"
2113 << " EndPrimitive();\n";
2116 sourceCollections.glslSources.add("geometry") << glu::GeometrySource(source.str());
2119 { // Fragment Shader
2120 std::ostringstream source;
2121 source << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
2122 << "layout(location = 0) in vec4 in_color;\n"
2123 << "layout(location = 0) out vec4 out_color;\n"
2126 << " out_color = in_color;\n"
2128 sourceCollections.glslSources.add("fragment") << glu::FragmentSource(source.str());
2132 std::vector<GraphicBasicTestInstance::VertexData> m_data;
2133 const GraphicBasicTestInstance::ParametersGraphic m_parametersGraphic;
2137 QueryPoolStatisticsTests::QueryPoolStatisticsTests (tcu::TestContext &testCtx)
2138 : TestCaseGroup(testCtx, "statistics_query", "Tests for statistics queries")
2142 void QueryPoolStatisticsTests::init (void)
2144 std::string topology_name [VK_PRIMITIVE_TOPOLOGY_LAST] =
2152 "line_list_with_adjacency",
2153 "line_strip_with_adjacency",
2154 "triangle_list_with_adjacency",
2155 "triangle_strip_with_adjacency",
2159 de::MovePtr<TestCaseGroup> computeShaderInvocationsGroup (new TestCaseGroup(m_testCtx, "compute_shader_invocations", "Query pipeline statistic compute shader invocations"));
2160 de::MovePtr<TestCaseGroup> inputAssemblyVertices (new TestCaseGroup(m_testCtx, "input_assembly_vertices", "Query pipeline statistic input assembly vertices"));
2161 de::MovePtr<TestCaseGroup> inputAssemblyPrimitives (new TestCaseGroup(m_testCtx, "input_assembly_primitives", "Query pipeline statistic input assembly primitives"));
2162 de::MovePtr<TestCaseGroup> vertexShaderInvocations (new TestCaseGroup(m_testCtx, "vertex_shader_invocations", "Query pipeline statistic vertex shader invocation"));
2163 de::MovePtr<TestCaseGroup> fragmentShaderInvocations (new TestCaseGroup(m_testCtx, "fragment_shader_invocations", "Query pipeline statistic fragment shader invocation"));
2164 de::MovePtr<TestCaseGroup> geometryShaderInvocations (new TestCaseGroup(m_testCtx, "geometry_shader_invocations", "Query pipeline statistic geometry shader invocation"));
2165 de::MovePtr<TestCaseGroup> geometryShaderPrimitives (new TestCaseGroup(m_testCtx, "geometry_shader_primitives", "Query pipeline statistic geometry shader primitives"));
2166 de::MovePtr<TestCaseGroup> clippingInvocations (new TestCaseGroup(m_testCtx, "clipping_invocations", "Query pipeline statistic clipping invocations"));
2167 de::MovePtr<TestCaseGroup> clippingPrimitives (new TestCaseGroup(m_testCtx, "clipping_primitives", "Query pipeline statistic clipping primitives"));
2168 de::MovePtr<TestCaseGroup> tesControlPatches (new TestCaseGroup(m_testCtx, "tes_control_patches", "Query pipeline statistic tessellation control shader patches"));
2169 de::MovePtr<TestCaseGroup> tesEvaluationShaderInvocations (new TestCaseGroup(m_testCtx, "tes_evaluation_shader_invocations", "Query pipeline statistic tessellation evaluation shader invocations"));
2171 computeShaderInvocationsGroup->addChild(new QueryPoolStatisticsTest<ComputeInvocationsTestInstance> (m_testCtx, "primary", ""));
2172 computeShaderInvocationsGroup->addChild(new QueryPoolStatisticsTest<ComputeInvocationsSecondaryTestInstance> (m_testCtx, "secondary", ""));
2173 computeShaderInvocationsGroup->addChild(new QueryPoolStatisticsTest<ComputeInvocationsSecondaryInheritedTestInstance> (m_testCtx, "secondary_inherited", ""));
2175 //VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT
2176 inputAssemblyVertices->addChild(new QueryPoolGraphicStatisticsTest<VertexShaderTestInstance> (m_testCtx, "primary", "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP)));
2177 inputAssemblyVertices->addChild(new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryTestInstance> (m_testCtx, "secondary", "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP)));
2178 inputAssemblyVertices->addChild(new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryInheritedTestInstance> (m_testCtx, "secondary_inherited", "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP)));
2180 //VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT
2182 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2183 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2184 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2185 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2187 primary->addChild (new QueryPoolGraphicStatisticsTest<VertexShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2188 secondary->addChild (new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2189 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2191 inputAssemblyPrimitives->addChild(primary.release());
2192 inputAssemblyPrimitives->addChild(secondary.release());
2193 inputAssemblyPrimitives->addChild(secondaryInherited.release());
2196 //VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT
2198 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2199 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2200 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2201 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2203 primary->addChild (new QueryPoolGraphicStatisticsTest<VertexShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2204 secondary->addChild (new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2205 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2207 vertexShaderInvocations->addChild(primary.release());
2208 vertexShaderInvocations->addChild(secondary.release());
2209 vertexShaderInvocations->addChild(secondaryInherited.release());
2212 //VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT
2214 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2215 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2216 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2217 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2219 primary->addChild (new QueryPoolGraphicStatisticsTest<VertexShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2220 secondary->addChild (new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2221 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2223 fragmentShaderInvocations->addChild(primary.release());
2224 fragmentShaderInvocations->addChild(secondary.release());
2225 fragmentShaderInvocations->addChild(secondaryInherited.release());
2228 //VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT
2230 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2231 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2232 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2233 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2235 primary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2236 secondary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2237 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2239 geometryShaderInvocations->addChild(primary.release());
2240 geometryShaderInvocations->addChild(secondary.release());
2241 geometryShaderInvocations->addChild(secondaryInherited.release());
2244 //VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT
2246 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2247 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2248 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2249 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2251 primary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2252 secondary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2253 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2255 geometryShaderPrimitives->addChild(primary.release());
2256 geometryShaderPrimitives->addChild(secondary.release());
2257 geometryShaderPrimitives->addChild(secondaryInherited.release());
2260 //VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT
2262 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2263 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2264 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2265 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2267 primary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2268 secondary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2269 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2271 clippingInvocations->addChild(primary.release());
2272 clippingInvocations->addChild(secondary.release());
2273 clippingInvocations->addChild(secondaryInherited.release());
2276 //VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT
2278 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2279 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2280 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2281 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2283 primary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2284 secondary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2285 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2287 clippingPrimitives->addChild(primary.release());
2288 clippingPrimitives->addChild(secondary.release());
2289 clippingPrimitives->addChild(secondaryInherited.release());
2292 //VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT
2293 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)));
2294 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)));
2295 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)));
2297 //VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT
2298 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)));
2299 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)));
2300 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)));
2302 addChild(computeShaderInvocationsGroup.release());
2303 addChild(inputAssemblyVertices.release());
2304 addChild(inputAssemblyPrimitives.release());
2305 addChild(vertexShaderInvocations.release());
2306 addChild(fragmentShaderInvocations.release());
2307 addChild(geometryShaderInvocations.release());
2308 addChild(geometryShaderPrimitives.release());
2309 addChild(clippingInvocations.release());
2310 addChild(clippingPrimitives.release());
2311 addChild(tesControlPatches.release());
2312 addChild(tesEvaluationShaderInvocations.release());