1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
4 *
5 * Copyright (c) 2016 The Khronos Group Inc.
6 *
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
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
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.
18 *
19 *//*!
20 * \file
21 * \brief Vulkan Statistics Query Tests
22 *//*--------------------------------------------------------------------*/
23
24 #include "vktQueryPoolStatisticsTests.hpp"
25 #include "vktTestCase.hpp"
26
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"
35
36 #include "deMath.h"
37
38 #include "tcuTestLog.hpp"
39 #include "tcuResource.hpp"
40 #include "tcuImageCompare.hpp"
41 #include "vkImageUtil.hpp"
42 #include "tcuCommandLine.hpp"
43 #include "tcuRGBA.hpp"
44 #include "tcuStringTemplate.hpp"
45
46 namespace vkt
47 {
48 namespace QueryPool
49 {
50 namespace
51 {
52
53 using namespace vk;
54 using namespace Draw;
55
56 //Test parameters
57 enum
58 {
59 WIDTH = 64,
60 HEIGHT = 64
61 };
62
inputTypeToGLString(const VkPrimitiveTopology & inputType)63 std::string inputTypeToGLString (const VkPrimitiveTopology& inputType)
64 {
65 switch (inputType)
66 {
67 case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
68 return "points";
69 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
70 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
71 return "lines";
72 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
73 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
74 return "lines_adjacency";
75 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
76 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
77 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
78 return "triangles";
79 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
80 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
81 return "triangles_adjacency";
82 default:
83 DE_ASSERT(DE_FALSE);
84 return "error";
85 }
86 }
87
outputTypeToGLString(const VkPrimitiveTopology & outputType)88 std::string outputTypeToGLString (const VkPrimitiveTopology& outputType)
89 {
90 switch (outputType)
91 {
92 case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
93 return "points";
94 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
95 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
96 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
97 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
98 return "line_strip";
99 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
100 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
101 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
102 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
103 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
104 return "triangle_strip";
105 default:
106 DE_ASSERT(DE_FALSE);
107 return "error";
108 }
109 }
110
beginSecondaryCommandBuffer(const DeviceInterface & vk,const VkCommandBuffer commandBuffer,const VkQueryPipelineStatisticFlags queryFlags,const VkRenderPass renderPass=(VkRenderPass)0u,const VkFramebuffer framebuffer=(VkFramebuffer)0u,const VkCommandBufferUsageFlags bufferUsageFlags=VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)111 void beginSecondaryCommandBuffer (const DeviceInterface& vk,
112 const VkCommandBuffer commandBuffer,
113 const VkQueryPipelineStatisticFlags queryFlags,
114 const VkRenderPass renderPass = (VkRenderPass)0u,
115 const VkFramebuffer framebuffer = (VkFramebuffer)0u,
116 const VkCommandBufferUsageFlags bufferUsageFlags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)
117 {
118 const VkCommandBufferInheritanceInfo secCmdBufInheritInfo =
119 {
120 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO,
121 DE_NULL,
122 renderPass, // renderPass
123 0u, // subpass
124 framebuffer, // framebuffer
125 VK_FALSE, // occlusionQueryEnable
126 (VkQueryControlFlags)0u, // queryFlags
127 queryFlags, // pipelineStatistics
128 };
129
130 const VkCommandBufferBeginInfo info =
131 {
132 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
133 DE_NULL, // const void* pNext;
134 bufferUsageFlags, // VkCommandBufferUsageFlags flags;
135 &secCmdBufInheritInfo, // const VkCommandBufferInheritanceInfo* pInheritanceInfo;
136 };
137 VK_CHECK(vk.beginCommandBuffer(commandBuffer, &info));
138 }
139
makeQueryPool(const DeviceInterface & vk,const VkDevice device,VkQueryPipelineStatisticFlags statisticFlags)140 Move<VkQueryPool> makeQueryPool (const DeviceInterface& vk, const VkDevice device, VkQueryPipelineStatisticFlags statisticFlags)
141 {
142 const VkQueryPoolCreateInfo queryPoolCreateInfo =
143 {
144 VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO, // VkStructureType sType
145 DE_NULL, // const void* pNext
146 (VkQueryPoolCreateFlags)0, // VkQueryPoolCreateFlags flags
147 VK_QUERY_TYPE_PIPELINE_STATISTICS , // VkQueryType queryType
148 1u, // deUint32 entryCount
149 statisticFlags, // VkQueryPipelineStatisticFlags pipelineStatistics
150 };
151 return createQueryPool(vk, device, &queryPoolCreateInfo);
152 }
153
makePipelineLayout(const DeviceInterface & vk,const VkDevice device,const VkDescriptorSetLayout * descriptorSetLayout)154 Move<VkPipelineLayout> makePipelineLayout (const DeviceInterface& vk, const VkDevice device, const VkDescriptorSetLayout* descriptorSetLayout)
155 {
156 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
157 {
158 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // VkStructureType sType;
159 DE_NULL, // const void* pNext;
160 0u, // VkPipelineLayoutCreateFlags flags;
161 1u, // deUint32 setLayoutCount;
162 descriptorSetLayout, // const VkDescriptorSetLayout* pSetLayouts;
163 0u, // deUint32 pushConstantRangeCount;
164 DE_NULL, // const VkPushConstantRange* pPushConstantRanges;
165 };
166 return (createPipelineLayout(vk, device, &pipelineLayoutParams));
167 }
168
clearBuffer(const DeviceInterface & vk,const VkDevice device,const de::SharedPtr<Buffer> buffer,const VkDeviceSize bufferSizeBytes)169 void clearBuffer (const DeviceInterface& vk, const VkDevice device, const de::SharedPtr<Buffer> buffer, const VkDeviceSize bufferSizeBytes)
170 {
171 const std::vector<deUint8> data ((size_t)bufferSizeBytes, 0u);
172 const Allocation& allocation = buffer->getBoundMemory();
173 void* allocationData = allocation.getHostPtr();
174 invalidateMappedMemoryRange(vk, device, allocation.getMemory(), allocation.getOffset(), bufferSizeBytes);
175 deMemcpy(allocationData, &data[0], (size_t)bufferSizeBytes);
176 }
177
178 class StatisticQueryTestInstance : public TestInstance
179 {
180 public:
181 StatisticQueryTestInstance (Context& context);
182 protected:
183 virtual void checkExtensions (void);
184 };
185
StatisticQueryTestInstance(Context & context)186 StatisticQueryTestInstance::StatisticQueryTestInstance (Context& context)
187 : TestInstance (context)
188 {
189 }
190
checkExtensions(void)191 void StatisticQueryTestInstance::checkExtensions (void)
192 {
193 if (!m_context.getDeviceFeatures().pipelineStatisticsQuery)
194 throw tcu::NotSupportedError("Pipeline statistics queries are not supported");
195 }
196
197 class ComputeInvocationsTestInstance : public StatisticQueryTestInstance
198 {
199 public:
200 struct ParametersCompute
201 {
202 tcu::UVec3 localSize;
203 tcu::UVec3 groupSize;
204 std::string shaderName;
205 };
206 ComputeInvocationsTestInstance (Context& context, const std::vector<ParametersCompute>& parameters);
207 tcu::TestStatus iterate (void);
208 protected:
209 virtual tcu::TestStatus executeTest (const VkCommandPool& cmdPool,
210 const VkPipelineLayout pipelineLayout,
211 const VkDescriptorSet& descriptorSet,
212 const de::SharedPtr<Buffer> buffer,
213 const VkDeviceSize bufferSizeBytes);
getComputeExecution(const ParametersCompute & parm) const214 deUint32 getComputeExecution (const ParametersCompute& parm) const
215 {
216 return parm.localSize.x() * parm.localSize.y() *parm.localSize.z() * parm.groupSize.x() * parm.groupSize.y() * parm.groupSize.z();
217 }
218 const std::vector<ParametersCompute>& m_parameters;
219 };
220
ComputeInvocationsTestInstance(Context & context,const std::vector<ParametersCompute> & parameters)221 ComputeInvocationsTestInstance::ComputeInvocationsTestInstance (Context& context, const std::vector<ParametersCompute>& parameters)
222 : StatisticQueryTestInstance (context)
223 , m_parameters (parameters)
224 {
225 }
226
iterate(void)227 tcu::TestStatus ComputeInvocationsTestInstance::iterate (void)
228 {
229 checkExtensions();
230 const DeviceInterface& vk = m_context.getDeviceInterface();
231 const VkDevice device = m_context.getDevice();
232 deUint32 maxSize = 0u;
233
234 for(size_t parametersNdx = 0; parametersNdx < m_parameters.size(); ++parametersNdx)
235 maxSize = deMaxu32(maxSize, getComputeExecution(m_parameters[parametersNdx]));
236
237 const VkDeviceSize bufferSizeBytes = static_cast<VkDeviceSize>(deAlignSize(static_cast<size_t>(sizeof(deUint32) * maxSize),
238 static_cast<size_t>(m_context.getDeviceProperties().limits.nonCoherentAtomSize)));
239 de::SharedPtr<Buffer> buffer = Buffer::createAndAlloc(vk, device, BufferCreateInfo(bufferSizeBytes, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT),
240 m_context.getDefaultAllocator(), MemoryRequirement::HostVisible);
241
242 const Unique<VkDescriptorSetLayout> descriptorSetLayout (DescriptorSetLayoutBuilder()
243 .addSingleBinding(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_SHADER_STAGE_COMPUTE_BIT)
244 .build(vk, device));
245
246 const Unique<VkPipelineLayout> pipelineLayout (makePipelineLayout(vk, device, &(*descriptorSetLayout)));
247
248 const Unique<VkDescriptorPool> descriptorPool (DescriptorPoolBuilder()
249 .addType(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER)
250 .build(vk, device, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 1u));
251
252 const VkDescriptorSetAllocateInfo allocateParams =
253 {
254 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, // VkStructureType sType;
255 DE_NULL, // const void* pNext;
256 *descriptorPool, // VkDescriptorPool descriptorPool;
257 1u, // deUint32 setLayoutCount;
258 &(*descriptorSetLayout), // const VkDescriptorSetLayout* pSetLayouts;
259 };
260
261 const Unique<VkDescriptorSet> descriptorSet (allocateDescriptorSet(vk, device, &allocateParams));
262 const VkDescriptorBufferInfo descriptorInfo =
263 {
264 buffer->object(), //VkBuffer buffer;
265 0ull, //VkDeviceSize offset;
266 bufferSizeBytes, //VkDeviceSize range;
267 };
268
269 DescriptorSetUpdateBuilder()
270 .writeSingle(*descriptorSet, DescriptorSetUpdateBuilder::Location::binding(0u), VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, &descriptorInfo)
271 .update(vk, device);
272
273 const CmdPoolCreateInfo cmdPoolCreateInfo (m_context.getUniversalQueueFamilyIndex());
274 const Unique<VkCommandPool> cmdPool (createCommandPool(vk, device, &cmdPoolCreateInfo));
275
276 return executeTest (*cmdPool, *pipelineLayout, *descriptorSet, buffer, bufferSizeBytes);
277 }
278
executeTest(const VkCommandPool & cmdPool,const VkPipelineLayout pipelineLayout,const VkDescriptorSet & descriptorSet,const de::SharedPtr<Buffer> buffer,const VkDeviceSize bufferSizeBytes)279 tcu::TestStatus ComputeInvocationsTestInstance::executeTest (const VkCommandPool& cmdPool,
280 const VkPipelineLayout pipelineLayout,
281 const VkDescriptorSet& descriptorSet,
282 const de::SharedPtr<Buffer> buffer,
283 const VkDeviceSize bufferSizeBytes)
284 {
285 const DeviceInterface& vk = m_context.getDeviceInterface();
286 const VkDevice device = m_context.getDevice();
287 const VkQueue queue = m_context.getUniversalQueue();
288 const VkBufferMemoryBarrier computeFinishBarrier =
289 {
290 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
291 DE_NULL, // const void* pNext;
292 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags srcAccessMask;
293 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
294 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
295 VK_QUEUE_FAMILY_IGNORED, // deUint32 destQueueFamilyIndex;
296 buffer->object(), // VkBuffer buffer;
297 0ull, // VkDeviceSize offset;
298 bufferSizeBytes, // VkDeviceSize size;
299 };
300
301 for(size_t parametersNdx = 0u; parametersNdx < m_parameters.size(); ++parametersNdx)
302 {
303 clearBuffer(vk, device, buffer, bufferSizeBytes);
304 const Unique<VkShaderModule> shaderModule (createShaderModule(vk, device,
305 m_context.getBinaryCollection().get(m_parameters[parametersNdx].shaderName), (VkShaderModuleCreateFlags)0u));
306
307 const VkPipelineShaderStageCreateInfo pipelineShaderStageParams =
308 {
309 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
310 DE_NULL, // const void* pNext;
311 (VkPipelineShaderStageCreateFlags)0u, // VkPipelineShaderStageCreateFlags flags;
312 VK_SHADER_STAGE_COMPUTE_BIT, // VkShaderStageFlagBits stage;
313 *shaderModule, // VkShaderModule module;
314 "main", // const char* pName;
315 DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
316 };
317
318 const VkComputePipelineCreateInfo pipelineCreateInfo =
319 {
320 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, // VkStructureType sType;
321 DE_NULL, // const void* pNext;
322 (VkPipelineCreateFlags)0u, // VkPipelineCreateFlags flags;
323 pipelineShaderStageParams, // VkPipelineShaderStageCreateInfo stage;
324 pipelineLayout, // VkPipelineLayout layout;
325 DE_NULL, // VkPipeline basePipelineHandle;
326 0, // deInt32 basePipelineIndex;
327 };
328 const Unique<VkPipeline> pipeline(createComputePipeline(vk, device, DE_NULL , &pipelineCreateInfo));
329
330 const Unique<VkCommandBuffer> cmdBuffer (allocateCommandBuffer(vk, device, cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
331 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT));
332
333 beginCommandBuffer(vk, *cmdBuffer);
334 vk.cmdResetQueryPool(*cmdBuffer, *queryPool, 0u, 1u);
335
336 vk.cmdBindPipeline(*cmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *pipeline);
337 vk.cmdBindDescriptorSets(*cmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipelineLayout, 0u, 1u, &descriptorSet, 0u, DE_NULL);
338
339 vk.cmdBeginQuery(*cmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
340 vk.cmdDispatch(*cmdBuffer, m_parameters[parametersNdx].groupSize.x(), m_parameters[parametersNdx].groupSize.y(), m_parameters[parametersNdx].groupSize.z());
341 vk.cmdEndQuery(*cmdBuffer, *queryPool, 0u);
342
343 vk.cmdPipelineBarrier(*cmdBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_HOST_BIT,
344 (VkDependencyFlags)0u, 0u, (const VkMemoryBarrier*)DE_NULL, 1u, &computeFinishBarrier, 0u, (const VkImageMemoryBarrier*)DE_NULL);
345 endCommandBuffer(vk, *cmdBuffer);
346
347 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Compute shader invocations: " << getComputeExecution(m_parameters[parametersNdx]) << tcu::TestLog::EndMessage;
348
349 // Wait for completion
350 submitCommandsAndWait(vk, device, queue, *cmdBuffer);
351
352 // Validate the results
353 const Allocation& bufferAllocation = buffer->getBoundMemory();
354 invalidateMappedMemoryRange(vk, device, bufferAllocation.getMemory(), bufferAllocation.getOffset(), bufferSizeBytes);
355
356 {
357 deUint64 data = 0u;
358 VK_CHECK(vk.getQueryPoolResults(device, *queryPool, 0u, 1u, sizeof(deUint64), &data, 0u, VK_QUERY_RESULT_64_BIT));
359 if (getComputeExecution(m_parameters[parametersNdx]) != data)
360 return tcu::TestStatus::fail("QueryPoolResults incorrect");
361 }
362
363 const deUint32* bufferPtr = static_cast<deUint32*>(bufferAllocation.getHostPtr());
364 for (deUint32 ndx = 0u; ndx < getComputeExecution(m_parameters[parametersNdx]); ++ndx)
365 {
366 if (bufferPtr[ndx] != ndx)
367 return tcu::TestStatus::fail("Compute shader didn't write data to the buffer");
368 }
369 }
370 return tcu::TestStatus::pass("Pass");
371 }
372
373 class ComputeInvocationsSecondaryTestInstance : public ComputeInvocationsTestInstance
374 {
375 public:
376 ComputeInvocationsSecondaryTestInstance (Context& context, const std::vector<ParametersCompute>& parameters);
377 protected:
378 tcu::TestStatus executeTest (const VkCommandPool& cmdPool,
379 const VkPipelineLayout pipelineLayout,
380 const VkDescriptorSet& descriptorSet,
381 const de::SharedPtr<Buffer> buffer,
382 const VkDeviceSize bufferSizeBytes);
383 virtual tcu::TestStatus checkResult (const de::SharedPtr<Buffer> buffer,
384 const VkDeviceSize bufferSizeBytes,
385 const VkQueryPool queryPool);
386 };
387
ComputeInvocationsSecondaryTestInstance(Context & context,const std::vector<ParametersCompute> & parameters)388 ComputeInvocationsSecondaryTestInstance::ComputeInvocationsSecondaryTestInstance (Context& context, const std::vector<ParametersCompute>& parameters)
389 : ComputeInvocationsTestInstance (context, parameters)
390 {
391 }
392
executeTest(const VkCommandPool & cmdPool,const VkPipelineLayout pipelineLayout,const VkDescriptorSet & descriptorSet,const de::SharedPtr<Buffer> buffer,const VkDeviceSize bufferSizeBytes)393 tcu::TestStatus ComputeInvocationsSecondaryTestInstance::executeTest (const VkCommandPool& cmdPool,
394 const VkPipelineLayout pipelineLayout,
395 const VkDescriptorSet& descriptorSet,
396 const de::SharedPtr<Buffer> buffer,
397 const VkDeviceSize bufferSizeBytes)
398 {
399 typedef de::SharedPtr<Unique<VkShaderModule> > VkShaderModuleSp;
400 typedef de::SharedPtr<Unique<VkPipeline> > VkPipelineSp;
401
402 const DeviceInterface& vk = m_context.getDeviceInterface();
403 const VkDevice device = m_context.getDevice();
404 const VkQueue queue = m_context.getUniversalQueue();
405
406 const VkBufferMemoryBarrier computeShaderWriteBarrier =
407 {
408 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
409 DE_NULL, // const void* pNext;
410 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags srcAccessMask;
411 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags dstAccessMask;
412 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
413 VK_QUEUE_FAMILY_IGNORED, // deUint32 destQueueFamilyIndex;
414 buffer->object(), // VkBuffer buffer;
415 0ull, // VkDeviceSize offset;
416 bufferSizeBytes, // VkDeviceSize size;
417 };
418
419 const VkBufferMemoryBarrier computeFinishBarrier =
420 {
421 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
422 DE_NULL, // const void* pNext;
423 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags srcAccessMask;
424 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
425 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
426 VK_QUEUE_FAMILY_IGNORED, // deUint32 destQueueFamilyIndex;
427 buffer->object(), // VkBuffer buffer;
428 0ull, // VkDeviceSize offset;
429 bufferSizeBytes, // VkDeviceSize size;
430 };
431
432 std::vector<VkShaderModuleSp> shaderModule;
433 std::vector<VkPipelineSp> pipeline;
434 for(size_t parametersNdx = 0; parametersNdx < m_parameters.size(); ++parametersNdx)
435 {
436 shaderModule.push_back(VkShaderModuleSp(new Unique<VkShaderModule>(createShaderModule(vk, device, m_context.getBinaryCollection().get(m_parameters[parametersNdx].shaderName), (VkShaderModuleCreateFlags)0u))));
437 const VkPipelineShaderStageCreateInfo pipelineShaderStageParams =
438 {
439 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
440 DE_NULL, // const void* pNext;
441 0u, // VkPipelineShaderStageCreateFlags flags;
442 VK_SHADER_STAGE_COMPUTE_BIT, // VkShaderStageFlagBits stage;
443 shaderModule.back().get()->get(), // VkShaderModule module;
444 "main", // const char* pName;
445 DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
446 };
447
448 const VkComputePipelineCreateInfo pipelineCreateInfo =
449 {
450 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, // VkStructureType sType;
451 DE_NULL, // const void* pNext;
452 0u, // VkPipelineCreateFlags flags;
453 pipelineShaderStageParams, // VkPipelineShaderStageCreateInfo stage;
454 pipelineLayout, // VkPipelineLayout layout;
455 DE_NULL, // VkPipeline basePipelineHandle;
456 0, // deInt32 basePipelineIndex;
457 };
458 pipeline.push_back(VkPipelineSp(new Unique<VkPipeline>(createComputePipeline(vk, device, DE_NULL , &pipelineCreateInfo))));
459 }
460
461 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
462 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
463
464 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT));
465
466 clearBuffer(vk, device, buffer, bufferSizeBytes);
467 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT);
468 vk.cmdBindDescriptorSets(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipelineLayout, 0u, 1u, &descriptorSet, 0u, DE_NULL);
469 vk.cmdResetQueryPool(*secondaryCmdBuffer, *queryPool, 0u, 1u);
470 vk.cmdBeginQuery(*secondaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
471 for(size_t parametersNdx = 0; parametersNdx < m_parameters.size(); ++parametersNdx)
472 {
473 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline[parametersNdx].get()->get());
474 vk.cmdDispatch(*secondaryCmdBuffer, m_parameters[parametersNdx].groupSize.x(), m_parameters[parametersNdx].groupSize.y(), m_parameters[parametersNdx].groupSize.z());
475
476 vk.cmdPipelineBarrier(*secondaryCmdBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
477 (VkDependencyFlags)0u, 0u, (const VkMemoryBarrier*)DE_NULL, 1u, &computeShaderWriteBarrier, 0u, (const VkImageMemoryBarrier*)DE_NULL);
478 }
479 vk.cmdEndQuery(*secondaryCmdBuffer, *queryPool, 0u);
480 endCommandBuffer(vk, *secondaryCmdBuffer);
481
482 beginCommandBuffer(vk, *primaryCmdBuffer);
483 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
484
485 vk.cmdPipelineBarrier(*primaryCmdBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_HOST_BIT,
486 (VkDependencyFlags)0u, 0u, (const VkMemoryBarrier*)DE_NULL, 1u, &computeFinishBarrier, 0u, (const VkImageMemoryBarrier*)DE_NULL);
487
488 endCommandBuffer(vk, *primaryCmdBuffer);
489
490 // Wait for completion
491 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
492 return checkResult(buffer, bufferSizeBytes, *queryPool);
493 }
494
checkResult(const de::SharedPtr<Buffer> buffer,const VkDeviceSize bufferSizeBytes,const VkQueryPool queryPool)495 tcu::TestStatus ComputeInvocationsSecondaryTestInstance::checkResult (const de::SharedPtr<Buffer> buffer, const VkDeviceSize bufferSizeBytes, const VkQueryPool queryPool)
496 {
497 const DeviceInterface& vk = m_context.getDeviceInterface();
498 const VkDevice device = m_context.getDevice();
499 {
500 deUint64 result = 0u;
501 deUint64 expected = 0u;
502 for(size_t parametersNdx = 0; parametersNdx < m_parameters.size(); ++parametersNdx)
503 expected += getComputeExecution(m_parameters[parametersNdx]);
504 VK_CHECK(vk.getQueryPoolResults(device, queryPool, 0u, 1u, sizeof(deUint64), &result, 0u, VK_QUERY_RESULT_64_BIT));
505 if (expected != result)
506 return tcu::TestStatus::fail("QueryPoolResults incorrect");
507 }
508
509 {
510 // Validate the results
511 const Allocation& bufferAllocation = buffer->getBoundMemory();
512 invalidateMappedMemoryRange(vk, device, bufferAllocation.getMemory(), bufferAllocation.getOffset(), bufferSizeBytes);
513 const deUint32* bufferPtr = static_cast<deUint32*>(bufferAllocation.getHostPtr());
514 deUint32 minSize = ~0u;
515 for(size_t parametersNdx = 0; parametersNdx < m_parameters.size(); ++parametersNdx)
516 minSize = deMinu32(minSize, getComputeExecution(m_parameters[parametersNdx]));
517 for (deUint32 ndx = 0u; ndx < minSize; ++ndx)
518 {
519 if (bufferPtr[ndx] != ndx * m_parameters.size())
520 return tcu::TestStatus::fail("Compute shader didn't write data to the buffer");
521 }
522 }
523 return tcu::TestStatus::pass("Pass");
524 }
525
526 class ComputeInvocationsSecondaryInheritedTestInstance : public ComputeInvocationsSecondaryTestInstance
527 {
528 public:
529 ComputeInvocationsSecondaryInheritedTestInstance (Context& context, const std::vector<ParametersCompute>& parameters);
530 protected:
531 virtual void checkExtensions (void);
532 tcu::TestStatus executeTest (const VkCommandPool& cmdPool,
533 const VkPipelineLayout pipelineLayout,
534 const VkDescriptorSet& descriptorSet,
535 const de::SharedPtr<Buffer> buffer,
536 const VkDeviceSize bufferSizeBytes);
537 };
538
ComputeInvocationsSecondaryInheritedTestInstance(Context & context,const std::vector<ParametersCompute> & parameters)539 ComputeInvocationsSecondaryInheritedTestInstance::ComputeInvocationsSecondaryInheritedTestInstance (Context& context, const std::vector<ParametersCompute>& parameters)
540 : ComputeInvocationsSecondaryTestInstance (context, parameters)
541 {
542 }
543
checkExtensions(void)544 void ComputeInvocationsSecondaryInheritedTestInstance::checkExtensions (void)
545 {
546 StatisticQueryTestInstance::checkExtensions();
547 if (!m_context.getDeviceFeatures().inheritedQueries)
548 throw tcu::NotSupportedError("Inherited queries are not supported");
549 }
550
executeTest(const VkCommandPool & cmdPool,const VkPipelineLayout pipelineLayout,const VkDescriptorSet & descriptorSet,const de::SharedPtr<Buffer> buffer,const VkDeviceSize bufferSizeBytes)551 tcu::TestStatus ComputeInvocationsSecondaryInheritedTestInstance::executeTest (const VkCommandPool& cmdPool,
552 const VkPipelineLayout pipelineLayout,
553 const VkDescriptorSet& descriptorSet,
554 const de::SharedPtr<Buffer> buffer,
555 const VkDeviceSize bufferSizeBytes)
556 {
557 typedef de::SharedPtr<Unique<VkShaderModule> > VkShaderModuleSp;
558 typedef de::SharedPtr<Unique<VkPipeline> > VkPipelineSp;
559
560 const DeviceInterface& vk = m_context.getDeviceInterface();
561 const VkDevice device = m_context.getDevice();
562 const VkQueue queue = m_context.getUniversalQueue();
563
564 const VkBufferMemoryBarrier computeShaderWriteBarrier =
565 {
566 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
567 DE_NULL, // const void* pNext;
568 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags srcAccessMask;
569 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags dstAccessMask;
570 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
571 VK_QUEUE_FAMILY_IGNORED, // deUint32 destQueueFamilyIndex;
572 buffer->object(), // VkBuffer buffer;
573 0ull, // VkDeviceSize offset;
574 bufferSizeBytes, // VkDeviceSize size;
575 };
576
577 const VkBufferMemoryBarrier computeFinishBarrier =
578 {
579 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
580 DE_NULL, // const void* pNext;
581 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, // VkAccessFlags srcAccessMask;
582 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
583 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
584 VK_QUEUE_FAMILY_IGNORED, // deUint32 destQueueFamilyIndex;
585 buffer->object(), // VkBuffer buffer;
586 0ull, // VkDeviceSize offset;
587 bufferSizeBytes, // VkDeviceSize size;
588 };
589
590 std::vector<VkShaderModuleSp> shaderModule;
591 std::vector<VkPipelineSp> pipeline;
592 for(size_t parametersNdx = 0u; parametersNdx < m_parameters.size(); ++parametersNdx)
593 {
594 shaderModule.push_back(VkShaderModuleSp(new Unique<VkShaderModule>(createShaderModule(vk, device, m_context.getBinaryCollection().get(m_parameters[parametersNdx].shaderName), (VkShaderModuleCreateFlags)0u))));
595 const VkPipelineShaderStageCreateInfo pipelineShaderStageParams =
596 {
597 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
598 DE_NULL, // const void* pNext;
599 0u, // VkPipelineShaderStageCreateFlags flags;
600 VK_SHADER_STAGE_COMPUTE_BIT, // VkShaderStageFlagBits stage;
601 shaderModule.back().get()->get(), // VkShaderModule module;
602 "main", // const char* pName;
603 DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
604 };
605
606 const VkComputePipelineCreateInfo pipelineCreateInfo =
607 {
608 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, // VkStructureType sType;
609 DE_NULL, // const void* pNext;
610 0u, // VkPipelineCreateFlags flags;
611 pipelineShaderStageParams, // VkPipelineShaderStageCreateInfo stage;
612 pipelineLayout, // VkPipelineLayout layout;
613 DE_NULL, // VkPipeline basePipelineHandle;
614 0, // deInt32 basePipelineIndex;
615 };
616 pipeline.push_back(VkPipelineSp(new Unique<VkPipeline>(createComputePipeline(vk, device, DE_NULL , &pipelineCreateInfo))));
617 }
618
619 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
620 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
621
622 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT));
623
624 clearBuffer(vk, device, buffer, bufferSizeBytes);
625 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT);
626 vk.cmdBindDescriptorSets(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipelineLayout, 0u, 1u, &descriptorSet, 0u, DE_NULL);
627 for(size_t parametersNdx = 1; parametersNdx < m_parameters.size(); ++parametersNdx)
628 {
629 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline[parametersNdx].get()->get());
630 vk.cmdDispatch(*secondaryCmdBuffer, m_parameters[parametersNdx].groupSize.x(), m_parameters[parametersNdx].groupSize.y(), m_parameters[parametersNdx].groupSize.z());
631
632 vk.cmdPipelineBarrier(*secondaryCmdBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
633 (VkDependencyFlags)0u, 0u, (const VkMemoryBarrier*)DE_NULL, 1u, &computeShaderWriteBarrier, 0u, (const VkImageMemoryBarrier*)DE_NULL);
634 }
635 endCommandBuffer(vk, *secondaryCmdBuffer);
636
637 beginCommandBuffer(vk, *primaryCmdBuffer);
638 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
639 vk.cmdBindDescriptorSets(*primaryCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipelineLayout, 0u, 1u, &descriptorSet, 0u, DE_NULL);
640 vk.cmdBindPipeline(*primaryCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline[0].get()->get());
641
642 vk.cmdBeginQuery(*primaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
643 vk.cmdDispatch(*primaryCmdBuffer, m_parameters[0].groupSize.x(), m_parameters[0].groupSize.y(), m_parameters[0].groupSize.z());
644
645 vk.cmdPipelineBarrier(*primaryCmdBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
646 (VkDependencyFlags)0u, 0u, (const VkMemoryBarrier*)DE_NULL, 1u, &computeShaderWriteBarrier, 0u, (const VkImageMemoryBarrier*)DE_NULL);
647
648 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
649
650 vk.cmdPipelineBarrier(*primaryCmdBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_HOST_BIT,
651 (VkDependencyFlags)0u, 0u, (const VkMemoryBarrier*)DE_NULL, 1u, &computeFinishBarrier, 0u, (const VkImageMemoryBarrier*)DE_NULL);
652
653 vk.cmdEndQuery(*primaryCmdBuffer, *queryPool, 0u);
654 endCommandBuffer(vk, *primaryCmdBuffer);
655
656 // Wait for completion
657 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
658 return checkResult(buffer, bufferSizeBytes, *queryPool);
659 }
660
661 class GraphicBasicTestInstance : public StatisticQueryTestInstance
662 {
663 public:
664 struct VertexData
665 {
VertexDatavkt::QueryPool::__anon340515a00111::GraphicBasicTestInstance::VertexData666 VertexData (const tcu::Vec4 position_, const tcu::Vec4 color_)
667 : position (position_)
668 , color (color_)
669 {}
670 tcu::Vec4 position;
671 tcu::Vec4 color;
672 };
673 struct ParametersGraphic
674 {
ParametersGraphicvkt::QueryPool::__anon340515a00111::GraphicBasicTestInstance::ParametersGraphic675 ParametersGraphic (const VkQueryPipelineStatisticFlags queryStatisticFlags_, const VkPrimitiveTopology primitiveTopology_)
676 : queryStatisticFlags (queryStatisticFlags_)
677 , primitiveTopology (primitiveTopology_)
678 {}
679 VkQueryPipelineStatisticFlags queryStatisticFlags;
680 VkPrimitiveTopology primitiveTopology;
681 };
682 GraphicBasicTestInstance (vkt::Context& context,
683 const std::vector<VertexData>& data,
684 const ParametersGraphic& parametersGraphic);
685 tcu::TestStatus iterate (void);
686 protected:
687 de::SharedPtr<Buffer> creatAndFillVertexBuffer (void);
688 virtual void createPipeline (void) = 0;
689 void creatColorAttachmentAndRenderPass (void);
690 bool checkImage (void);
691 virtual tcu::TestStatus executeTest (void) = 0;
692 virtual tcu::TestStatus checkResult (VkQueryPool queryPool) = 0;
693 virtual void draw (VkCommandBuffer cmdBuffer) = 0;
694
695 const VkFormat m_colorAttachmentFormat;
696 de::SharedPtr<Image> m_colorAttachmentImage;
697 de::SharedPtr<Image> m_depthImage;
698 Move<VkImageView> m_attachmentView;
699 Move<VkImageView> m_depthiew;
700 Move<VkRenderPass> m_renderPass;
701 Move<VkFramebuffer> m_framebuffer;
702 Move<VkPipeline> m_pipeline;
703 Move<VkPipelineLayout> m_pipelineLayout;
704 const std::vector<VertexData>& m_data;
705 const ParametersGraphic& m_parametersGraphic;
706 };
707
GraphicBasicTestInstance(vkt::Context & context,const std::vector<VertexData> & data,const ParametersGraphic & parametersGraphic)708 GraphicBasicTestInstance::GraphicBasicTestInstance (vkt::Context& context,
709 const std::vector<VertexData>& data,
710 const ParametersGraphic& parametersGraphic)
711 : StatisticQueryTestInstance (context)
712 , m_colorAttachmentFormat (VK_FORMAT_R8G8B8A8_UNORM)
713 , m_data (data)
714 , m_parametersGraphic (parametersGraphic)
715 {
716 }
717
iterate(void)718 tcu::TestStatus GraphicBasicTestInstance::iterate (void)
719 {
720 checkExtensions();
721 creatColorAttachmentAndRenderPass();
722 createPipeline();
723 return executeTest();
724 }
725
creatAndFillVertexBuffer(void)726 de::SharedPtr<Buffer> GraphicBasicTestInstance::creatAndFillVertexBuffer (void)
727 {
728 const DeviceInterface& vk = m_context.getDeviceInterface();
729 const VkDevice device = m_context.getDevice();
730
731 const VkDeviceSize dataSize = static_cast<VkDeviceSize>(deAlignSize(static_cast<size_t>( m_data.size() * sizeof(VertexData)),
732 static_cast<size_t>(m_context.getDeviceProperties().limits.nonCoherentAtomSize)));
733
734 de::SharedPtr<Buffer> vertexBuffer = Buffer::createAndAlloc(vk, device, BufferCreateInfo(dataSize,
735 VK_BUFFER_USAGE_VERTEX_BUFFER_BIT), m_context.getDefaultAllocator(), MemoryRequirement::HostVisible);
736
737 deUint8* ptr = reinterpret_cast<deUint8*>(vertexBuffer->getBoundMemory().getHostPtr());
738 deMemcpy(ptr, &m_data[0], static_cast<size_t>( m_data.size() * sizeof(VertexData)));
739
740 flushMappedMemoryRange(vk, device, vertexBuffer->getBoundMemory().getMemory(), vertexBuffer->getBoundMemory().getOffset(), dataSize);
741 return vertexBuffer;
742 }
743
creatColorAttachmentAndRenderPass(void)744 void GraphicBasicTestInstance::creatColorAttachmentAndRenderPass (void)
745 {
746 const DeviceInterface& vk = m_context.getDeviceInterface();
747 const VkDevice device = m_context.getDevice();
748
749 {
750 VkExtent3D imageExtent =
751 {
752 WIDTH, // width;
753 HEIGHT, // height;
754 1u // depth;
755 };
756
757 const ImageCreateInfo colorImageCreateInfo (VK_IMAGE_TYPE_2D, m_colorAttachmentFormat, imageExtent, 1, 1, VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_TILING_OPTIMAL,
758 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT);
759
760 m_colorAttachmentImage = Image::createAndAlloc(vk, device, colorImageCreateInfo, m_context.getDefaultAllocator(), m_context.getUniversalQueueFamilyIndex());
761
762 const ImageViewCreateInfo attachmentViewInfo (m_colorAttachmentImage->object(), VK_IMAGE_VIEW_TYPE_2D, m_colorAttachmentFormat);
763 m_attachmentView = createImageView(vk, device, &attachmentViewInfo);
764
765 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,
766 vk::VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
767
768 m_depthImage = Image::createAndAlloc(vk, device, depthImageCreateInfo, m_context.getDefaultAllocator(), m_context.getUniversalQueueFamilyIndex());
769
770 // Construct a depth view from depth image
771 const ImageViewCreateInfo depthViewInfo (m_depthImage->object(), vk::VK_IMAGE_VIEW_TYPE_2D, VK_FORMAT_D16_UNORM);
772 m_depthiew = vk::createImageView(vk, device, &depthViewInfo);
773 }
774
775 {
776 // Renderpass and Framebuffer
777 RenderPassCreateInfo renderPassCreateInfo;
778 renderPassCreateInfo.addAttachment(AttachmentDescription(m_colorAttachmentFormat, // format
779 VK_SAMPLE_COUNT_1_BIT, // samples
780 VK_ATTACHMENT_LOAD_OP_CLEAR, // loadOp
781 VK_ATTACHMENT_STORE_OP_STORE , // storeOp
782 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // stencilLoadOp
783 VK_ATTACHMENT_STORE_OP_STORE , // stencilLoadOp
784 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // initialLauout
785 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)); // finalLayout
786
787 renderPassCreateInfo.addAttachment(AttachmentDescription(VK_FORMAT_D16_UNORM, // format
788 vk::VK_SAMPLE_COUNT_1_BIT, // samples
789 vk::VK_ATTACHMENT_LOAD_OP_CLEAR, // loadOp
790 vk::VK_ATTACHMENT_STORE_OP_DONT_CARE, // storeOp
791 vk::VK_ATTACHMENT_LOAD_OP_DONT_CARE, // stencilLoadOp
792 vk::VK_ATTACHMENT_STORE_OP_DONT_CARE, // stencilLoadOp
793 vk::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // initialLauout
794 vk::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)); // finalLayout
795
796 const VkAttachmentReference colorAttachmentReference =
797 {
798 0u, // attachment
799 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // layout
800 };
801
802 const VkAttachmentReference depthAttachmentReference =
803 {
804 1u, // attachment
805 vk::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL // layout
806 };
807
808 const VkSubpassDescription subpass =
809 {
810 (VkSubpassDescriptionFlags) 0, //VkSubpassDescriptionFlags flags;
811 VK_PIPELINE_BIND_POINT_GRAPHICS, //VkPipelineBindPoint pipelineBindPoint;
812 0u, //deUint32 inputAttachmentCount;
813 DE_NULL, //const VkAttachmentReference* pInputAttachments;
814 1u, //deUint32 colorAttachmentCount;
815 &colorAttachmentReference, //const VkAttachmentReference* pColorAttachments;
816 DE_NULL, //const VkAttachmentReference* pResolveAttachments;
817 &depthAttachmentReference, //const VkAttachmentReference* pDepthStencilAttachment;
818 0u, //deUint32 preserveAttachmentCount;
819 DE_NULL, //const deUint32* pPreserveAttachments;
820 };
821
822 renderPassCreateInfo.addSubpass(subpass);
823 m_renderPass = createRenderPass(vk, device, &renderPassCreateInfo);
824
825 std::vector<vk::VkImageView> attachments(2);
826 attachments[0] = *m_attachmentView;
827 attachments[1] = *m_depthiew;
828
829 FramebufferCreateInfo framebufferCreateInfo(*m_renderPass, attachments, WIDTH, HEIGHT, 1);
830 m_framebuffer = createFramebuffer(vk, device, &framebufferCreateInfo);
831 }
832 }
833
checkImage(void)834 bool GraphicBasicTestInstance::checkImage (void)
835 {
836 const VkQueue queue = m_context.getUniversalQueue();
837 const VkOffset3D zeroOffset = { 0, 0, 0 };
838 const tcu::ConstPixelBufferAccess renderedFrame = m_colorAttachmentImage->readSurface(queue, m_context.getDefaultAllocator(),
839 VK_IMAGE_LAYOUT_GENERAL, zeroOffset, WIDTH, HEIGHT, VK_IMAGE_ASPECT_COLOR_BIT);
840 int colorNdx = 0;
841 tcu::Texture2D referenceFrame (mapVkFormat(m_colorAttachmentFormat), WIDTH, HEIGHT);
842 referenceFrame.allocLevel(0);
843
844 for (int y = 0; y < HEIGHT/2; ++y)
845 for (int x = 0; x < WIDTH/2; ++x)
846 referenceFrame.getLevel(0).setPixel(m_data[colorNdx].color, x, y);
847
848 colorNdx += 4;
849 for (int y = HEIGHT/2; y < HEIGHT; ++y)
850 for (int x = 0; x < WIDTH/2; ++x)
851 referenceFrame.getLevel(0).setPixel(m_data[colorNdx].color, x, y);
852
853 colorNdx += 4;
854 for (int y = 0; y < HEIGHT/2; ++y)
855 for (int x = WIDTH/2; x < WIDTH; ++x)
856 referenceFrame.getLevel(0).setPixel(m_data[colorNdx].color, x, y);
857
858 colorNdx += 4;
859 for (int y = HEIGHT/2; y < HEIGHT; ++y)
860 for (int x = WIDTH/2; x < WIDTH; ++x)
861 referenceFrame.getLevel(0).setPixel(m_data[colorNdx].color, x, y);
862
863 return tcu::floatThresholdCompare(m_context.getTestContext().getLog(), "Result", "Image comparison result", referenceFrame.getLevel(0), renderedFrame, tcu::Vec4(0.01f), tcu::COMPARE_LOG_ON_ERROR);
864 }
865
866 class VertexShaderTestInstance : public GraphicBasicTestInstance
867 {
868 public:
869 VertexShaderTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
870 protected:
871 virtual void createPipeline (void);
872 virtual tcu::TestStatus executeTest (void);
873 virtual tcu::TestStatus checkResult (VkQueryPool queryPool);
874 void draw (VkCommandBuffer cmdBuffer);
875 };
876
VertexShaderTestInstance(vkt::Context & context,const std::vector<VertexData> & data,const ParametersGraphic & parametersGraphic)877 VertexShaderTestInstance::VertexShaderTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
878 : GraphicBasicTestInstance (context, data, parametersGraphic)
879 {
880 }
881
createPipeline(void)882 void VertexShaderTestInstance::createPipeline (void)
883 {
884 const DeviceInterface& vk = m_context.getDeviceInterface();
885 const VkDevice device = m_context.getDevice();
886
887 // Pipeline
888 Unique<VkShaderModule> vs(createShaderModule(vk, device, m_context.getBinaryCollection().get("vertex"), 0));
889 Unique<VkShaderModule> fs(createShaderModule(vk, device, m_context.getBinaryCollection().get("fragment"), 0));
890
891 const PipelineCreateInfo::ColorBlendState::Attachment attachmentState;
892
893 const PipelineLayoutCreateInfo pipelineLayoutCreateInfo;
894 m_pipelineLayout = createPipelineLayout(vk, device, &pipelineLayoutCreateInfo);
895
896 const VkVertexInputBindingDescription vertexInputBindingDescription =
897 {
898 0, // binding;
899 static_cast<deUint32>(sizeof(VertexData)), // stride;
900 VK_VERTEX_INPUT_RATE_VERTEX // inputRate
901 };
902
903 const VkVertexInputAttributeDescription vertexInputAttributeDescriptions[] =
904 {
905 {
906 0u,
907 0u,
908 VK_FORMAT_R32G32B32A32_SFLOAT,
909 0u
910 }, // VertexElementData::position
911 {
912 1u,
913 0u,
914 VK_FORMAT_R32G32B32A32_SFLOAT,
915 static_cast<deUint32>(sizeof(tcu::Vec4))
916 }, // VertexElementData::color
917 };
918
919 const VkPipelineVertexInputStateCreateInfo vf_info =
920 { // sType;
921 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // pNext;
922 NULL, // flags;
923 0u, // vertexBindingDescriptionCount;
924 1u, // pVertexBindingDescriptions;
925 &vertexInputBindingDescription, // vertexAttributeDescriptionCount;
926 2u, // pVertexAttributeDescriptions;
927 vertexInputAttributeDescriptions
928 };
929
930 PipelineCreateInfo pipelineCreateInfo(*m_pipelineLayout, *m_renderPass, 0, (VkPipelineCreateFlags)0);
931 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*vs, "main", VK_SHADER_STAGE_VERTEX_BIT));
932 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*fs, "main", VK_SHADER_STAGE_FRAGMENT_BIT));
933 pipelineCreateInfo.addState(PipelineCreateInfo::DepthStencilState());
934 pipelineCreateInfo.addState(PipelineCreateInfo::InputAssemblerState(m_parametersGraphic.primitiveTopology));
935 pipelineCreateInfo.addState(PipelineCreateInfo::ColorBlendState(1, &attachmentState));
936
937 const VkViewport viewport = makeViewport(WIDTH, HEIGHT);
938 const VkRect2D scissor = makeRect2D(WIDTH, HEIGHT);
939 pipelineCreateInfo.addState(PipelineCreateInfo::ViewportState(1u, std::vector<VkViewport>(1, viewport), std::vector<VkRect2D>(1, scissor)));
940 pipelineCreateInfo.addState(PipelineCreateInfo::DepthStencilState());
941 pipelineCreateInfo.addState(PipelineCreateInfo::RasterizerState());
942 pipelineCreateInfo.addState(PipelineCreateInfo::MultiSampleState());
943 pipelineCreateInfo.addState(vf_info);
944 m_pipeline = createGraphicsPipeline(vk, device, DE_NULL, &pipelineCreateInfo);
945 }
946
executeTest(void)947 tcu::TestStatus VertexShaderTestInstance::executeTest (void)
948 {
949 const DeviceInterface& vk = m_context.getDeviceInterface();
950 const VkDevice device = m_context.getDevice();
951 const VkQueue queue = m_context.getUniversalQueue();
952 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
953
954 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
955 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
956 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
957
958 const VkDeviceSize vertexBufferOffset = 0u;
959 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
960 const VkBuffer vertexBuffer = vertexBufferSp->object();
961
962 const Unique<VkCommandBuffer> cmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
963
964 beginCommandBuffer(vk, *cmdBuffer);
965 {
966 std::vector<VkClearValue> renderPassClearValues (2);
967 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
968
969 initialTransitionColor2DImage(vk, *cmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
970 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
971 initialTransitionDepth2DImage(vk, *cmdBuffer, m_depthImage->object(), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
972 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
973
974 vk.cmdResetQueryPool(*cmdBuffer, *queryPool, 0u, 1u);
975
976 beginRenderPass(vk, *cmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, WIDTH, HEIGHT), (deUint32)renderPassClearValues.size(), &renderPassClearValues[0]);
977
978 vk.cmdBeginQuery(*cmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
979 vk.cmdBindVertexBuffers(*cmdBuffer, 0, 1, &vertexBuffer, &vertexBufferOffset);
980 vk.cmdBindPipeline(*cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
981 draw(*cmdBuffer);
982 vk.cmdEndQuery(*cmdBuffer, *queryPool, 0u);
983
984 endRenderPass(vk, *cmdBuffer);
985
986 transition2DImage(vk, *cmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
987 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
988 }
989 endCommandBuffer(vk, *cmdBuffer);
990
991 // Wait for completion
992 submitCommandsAndWait(vk, device, queue, *cmdBuffer);
993 return checkResult (*queryPool);
994 }
995
checkResult(VkQueryPool queryPool)996 tcu::TestStatus VertexShaderTestInstance::checkResult (VkQueryPool queryPool)
997 {
998 const DeviceInterface& vk = m_context.getDeviceInterface();
999 const VkDevice device = m_context.getDevice();
1000 deUint64 result = 0u;
1001 deUint64 expectedMin = 0u;
1002
1003 switch(m_parametersGraphic.queryStatisticFlags)
1004 {
1005 case VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT:
1006 expectedMin = 16u;
1007 break;
1008 case VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT:
1009 expectedMin = m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST ? 15u :
1010 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY ? 8u :
1011 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY ? 14u :
1012 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY ? 6u :
1013 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY ? 8u :
1014 16u;
1015 break;
1016 case VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT:
1017 expectedMin = m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST ? 16u :
1018 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST ? 8u :
1019 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP ? 15u :
1020 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST ? 5u :
1021 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ? 8u :
1022 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN ? 14u :
1023 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY ? 4u :
1024 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY ? 13u :
1025 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY ? 2u :
1026 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY ? 6u :
1027 0u;
1028 break;
1029 case VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT:
1030 expectedMin = m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST ? 9u :
1031 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST ? 192u :
1032 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP ? 448u :
1033 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST ? 2016u :
1034 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ? 4096u :
1035 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN ? 10208u :
1036 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY ? 128u :
1037 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY ? 416u :
1038 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY ? 992u :
1039 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY ? 3072u :
1040 0u;
1041 break;
1042 default:
1043 DE_ASSERT(0);
1044 break;
1045 }
1046
1047 VK_CHECK(vk.getQueryPoolResults(device, queryPool, 0u, 1u, sizeof(deUint64), &result, 0u, VK_QUERY_RESULT_64_BIT));
1048 if (result < expectedMin)
1049 return tcu::TestStatus::fail("QueryPoolResults incorrect");
1050
1051 if (m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP && !checkImage())
1052 return tcu::TestStatus::fail("Result image doesn't match expected image.");
1053
1054 return tcu::TestStatus::pass("Pass");
1055 }
1056
draw(VkCommandBuffer cmdBuffer)1057 void VertexShaderTestInstance::draw (VkCommandBuffer cmdBuffer)
1058 {
1059 const DeviceInterface& vk = m_context.getDeviceInterface();
1060 switch(m_parametersGraphic.primitiveTopology)
1061 {
1062 case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
1063 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
1064 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
1065 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
1066 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
1067 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
1068 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
1069 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
1070 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
1071 vk.cmdDraw(cmdBuffer, 16u, 1u, 0u, 0u);
1072 break;
1073 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
1074 vk.cmdDraw(cmdBuffer, 4u, 1u, 0u, 0u);
1075 vk.cmdDraw(cmdBuffer, 4u, 1u, 4u, 1u);
1076 vk.cmdDraw(cmdBuffer, 4u, 1u, 8u, 2u);
1077 vk.cmdDraw(cmdBuffer, 4u, 1u, 12u, 3u);
1078 break;
1079 default:
1080 DE_ASSERT(0);
1081 break;
1082 }
1083 }
1084
1085 class VertexShaderSecondaryTestInstance : public VertexShaderTestInstance
1086 {
1087 public:
1088 VertexShaderSecondaryTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1089 protected:
1090 virtual tcu::TestStatus executeTest (void);
1091 };
1092
VertexShaderSecondaryTestInstance(vkt::Context & context,const std::vector<VertexData> & data,const ParametersGraphic & parametersGraphic)1093 VertexShaderSecondaryTestInstance::VertexShaderSecondaryTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1094 : VertexShaderTestInstance (context, data, parametersGraphic)
1095 {
1096 }
1097
executeTest(void)1098 tcu::TestStatus VertexShaderSecondaryTestInstance::executeTest (void)
1099 {
1100 const DeviceInterface& vk = m_context.getDeviceInterface();
1101 const VkDevice device = m_context.getDevice();
1102 const VkQueue queue = m_context.getUniversalQueue();
1103 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1104
1105 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1106 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1107 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1108
1109 const VkDeviceSize vertexBufferOffset = 0u;
1110 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1111 const VkBuffer vertexBuffer = vertexBufferSp->object();
1112
1113 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1114 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
1115
1116 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, m_parametersGraphic.queryStatisticFlags, *m_renderPass, *m_framebuffer, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT);
1117 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1118 vk.cmdBeginQuery(*secondaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1119 vk.cmdBindVertexBuffers(*secondaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1120 draw(*secondaryCmdBuffer);
1121 vk.cmdEndQuery(*secondaryCmdBuffer, *queryPool, 0u);
1122 endCommandBuffer(vk, *secondaryCmdBuffer);
1123
1124 beginCommandBuffer(vk, *primaryCmdBuffer);
1125 {
1126 std::vector<VkClearValue> renderPassClearValues (2);
1127 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1128
1129 initialTransitionColor2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1130 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
1131 initialTransitionDepth2DImage(vk, *primaryCmdBuffer, m_depthImage->object(), vk::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1132 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
1134 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
1135
1136 beginRenderPass(vk, *primaryCmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, WIDTH, HEIGHT), (deUint32)renderPassClearValues.size(), &renderPassClearValues[0], VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
1137 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
1138 endRenderPass(vk, *primaryCmdBuffer);
1139 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
1140 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1141 }
1142 endCommandBuffer(vk, *primaryCmdBuffer);
1143
1144 // Wait for completion
1145 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
1146 return checkResult (*queryPool);
1147 }
1148
1149 class VertexShaderSecondaryInheritedTestInstance : public VertexShaderTestInstance
1150 {
1151 public:
1152 VertexShaderSecondaryInheritedTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1153 protected:
1154 void checkExtensions (void);
1155 virtual tcu::TestStatus executeTest (void);
1156 };
1157
VertexShaderSecondaryInheritedTestInstance(vkt::Context & context,const std::vector<VertexData> & data,const ParametersGraphic & parametersGraphic)1158 VertexShaderSecondaryInheritedTestInstance::VertexShaderSecondaryInheritedTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1159 : VertexShaderTestInstance (context, data, parametersGraphic)
1160 {
1161 }
1162
checkExtensions(void)1163 void VertexShaderSecondaryInheritedTestInstance::checkExtensions (void)
1164 {
1165 StatisticQueryTestInstance::checkExtensions();
1166 if (!m_context.getDeviceFeatures().inheritedQueries)
1167 throw tcu::NotSupportedError("Inherited queries are not supported");
1168 }
1169
executeTest(void)1170 tcu::TestStatus VertexShaderSecondaryInheritedTestInstance::executeTest (void)
1171 {
1172 const DeviceInterface& vk = m_context.getDeviceInterface();
1173 const VkDevice device = m_context.getDevice();
1174 const VkQueue queue = m_context.getUniversalQueue();
1175 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1176
1177 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1178 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1179 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1180
1181 const VkDeviceSize vertexBufferOffset = 0u;
1182 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1183 const VkBuffer vertexBuffer = vertexBufferSp->object();
1184
1185 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1186 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
1187
1188 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, m_parametersGraphic.queryStatisticFlags, *m_renderPass, *m_framebuffer, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT);
1189 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1190 vk.cmdBindVertexBuffers(*secondaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1191 draw(*secondaryCmdBuffer);
1192 endCommandBuffer(vk, *secondaryCmdBuffer);
1193
1194 beginCommandBuffer(vk, *primaryCmdBuffer);
1195 {
1196 std::vector<VkClearValue> renderPassClearValues (2);
1197 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1198
1199 initialTransitionColor2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1200 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
1201 initialTransitionDepth2DImage(vk, *primaryCmdBuffer, m_depthImage->object(), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1202 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
1203
1204 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
1205 vk.cmdBeginQuery(*primaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1206
1207 beginRenderPass(vk, *primaryCmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, WIDTH, HEIGHT), (deUint32)renderPassClearValues.size(), &renderPassClearValues[0], VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
1208 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
1209 endRenderPass(vk, *primaryCmdBuffer);
1210 vk.cmdEndQuery(*primaryCmdBuffer, *queryPool, 0u);
1211 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
1212 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1213 }
1214 endCommandBuffer(vk, *primaryCmdBuffer);
1215
1216 // Wait for completion
1217 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
1218 return checkResult (*queryPool);
1219 }
1220
1221 class GeometryShaderTestInstance : public GraphicBasicTestInstance
1222 {
1223 public:
1224 GeometryShaderTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1225 protected:
1226 virtual void checkExtensions (void);
1227 virtual void createPipeline (void);
1228 virtual tcu::TestStatus executeTest (void);
1229 tcu::TestStatus checkResult (VkQueryPool queryPool);
1230 void draw (VkCommandBuffer cmdBuffer);
1231 };
1232
GeometryShaderTestInstance(vkt::Context & context,const std::vector<VertexData> & data,const ParametersGraphic & parametersGraphic)1233 GeometryShaderTestInstance::GeometryShaderTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1234 : GraphicBasicTestInstance (context, data, parametersGraphic)
1235 {
1236 }
1237
checkExtensions(void)1238 void GeometryShaderTestInstance::checkExtensions (void)
1239 {
1240 StatisticQueryTestInstance::checkExtensions();
1241 if (!m_context.getDeviceFeatures().geometryShader)
1242 throw tcu::NotSupportedError("Geometry shader are not supported");
1243 }
1244
createPipeline(void)1245 void GeometryShaderTestInstance::createPipeline (void)
1246 {
1247 const DeviceInterface& vk = m_context.getDeviceInterface();
1248 const VkDevice device = m_context.getDevice();
1249 const VkBool32 useGeomPointSize = m_context.getDeviceFeatures().shaderTessellationAndGeometryPointSize && (m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST);
1250
1251 // Pipeline
1252 Unique<VkShaderModule> vs(createShaderModule(vk, device, m_context.getBinaryCollection().get("vertex"), (VkShaderModuleCreateFlags)0));
1253 Unique<VkShaderModule> gs(createShaderModule(vk, device, m_context.getBinaryCollection().get(useGeomPointSize ? "geometry_point_size" : "geometry"), (VkShaderModuleCreateFlags)0));
1254 Unique<VkShaderModule> fs(createShaderModule(vk, device, m_context.getBinaryCollection().get("fragment"), (VkShaderModuleCreateFlags)0));
1255
1256 const PipelineCreateInfo::ColorBlendState::Attachment attachmentState;
1257
1258 const PipelineLayoutCreateInfo pipelineLayoutCreateInfo;
1259 m_pipelineLayout = createPipelineLayout(vk, device, &pipelineLayoutCreateInfo);
1260
1261 const VkVertexInputBindingDescription vertexInputBindingDescription =
1262 {
1263 0u, // binding;
1264 static_cast<deUint32>(sizeof(VertexData)), // stride;
1265 VK_VERTEX_INPUT_RATE_VERTEX // inputRate
1266 };
1267
1268 const VkVertexInputAttributeDescription vertexInputAttributeDescriptions[] =
1269 {
1270 {
1271 0u,
1272 0u,
1273 VK_FORMAT_R32G32B32A32_SFLOAT,
1274 0u
1275 }, // VertexElementData::position
1276 {
1277 1u,
1278 0u,
1279 VK_FORMAT_R32G32B32A32_SFLOAT,
1280 static_cast<deUint32>(sizeof(tcu::Vec4))
1281 }, // VertexElementData::color
1282 };
1283
1284 const VkPipelineVertexInputStateCreateInfo vf_info =
1285 { // sType;
1286 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // pNext;
1287 NULL, // flags;
1288 0u, // vertexBindingDescriptionCount;
1289 1, // pVertexBindingDescriptions;
1290 &vertexInputBindingDescription, // vertexAttributeDescriptionCount;
1291 2, // pVertexAttributeDescriptions;
1292 vertexInputAttributeDescriptions
1293 };
1294
1295 PipelineCreateInfo pipelineCreateInfo(*m_pipelineLayout, *m_renderPass, 0, (VkPipelineCreateFlags)0);
1296 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*vs, "main", VK_SHADER_STAGE_VERTEX_BIT));
1297 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*gs, "main", VK_SHADER_STAGE_GEOMETRY_BIT));
1298 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*fs, "main", VK_SHADER_STAGE_FRAGMENT_BIT));
1299 pipelineCreateInfo.addState(PipelineCreateInfo::InputAssemblerState(m_parametersGraphic.primitiveTopology));
1300 pipelineCreateInfo.addState(PipelineCreateInfo::ColorBlendState(1, &attachmentState));
1301
1302 const VkViewport viewport = makeViewport(WIDTH, HEIGHT);
1303 const VkRect2D scissor = makeRect2D(WIDTH, HEIGHT);
1304
1305 pipelineCreateInfo.addState(PipelineCreateInfo::ViewportState(1, std::vector<VkViewport>(1, viewport), std::vector<VkRect2D>(1, scissor)));
1306
1307 if (m_context.getDeviceFeatures().depthBounds)
1308 pipelineCreateInfo.addState(PipelineCreateInfo::DepthStencilState(true, true, VK_COMPARE_OP_GREATER_OR_EQUAL, true));
1309 else
1310 pipelineCreateInfo.addState(PipelineCreateInfo::DepthStencilState());
1311
1312 pipelineCreateInfo.addState(PipelineCreateInfo::RasterizerState(false));
1313 pipelineCreateInfo.addState(PipelineCreateInfo::MultiSampleState());
1314 pipelineCreateInfo.addState(vf_info);
1315 m_pipeline = createGraphicsPipeline(vk, device, DE_NULL, &pipelineCreateInfo);
1316 }
1317
executeTest(void)1318 tcu::TestStatus GeometryShaderTestInstance::executeTest (void)
1319 {
1320 const DeviceInterface& vk = m_context.getDeviceInterface();
1321 const VkDevice device = m_context.getDevice();
1322 const VkQueue queue = m_context.getUniversalQueue();
1323 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1324
1325 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1326 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1327 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1328
1329 const VkDeviceSize vertexBufferOffset = 0u;
1330 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1331 const VkBuffer vertexBuffer = vertexBufferSp->object();
1332
1333 const Unique<VkCommandBuffer> cmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1334
1335 beginCommandBuffer(vk, *cmdBuffer);
1336 {
1337 std::vector<VkClearValue> renderPassClearValues (2);
1338 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1339
1340 initialTransitionColor2DImage(vk, *cmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1341 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
1342 initialTransitionDepth2DImage(vk, *cmdBuffer, m_depthImage->object(), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1343 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
1344
1345 vk.cmdResetQueryPool(*cmdBuffer, *queryPool, 0u, 1u);
1346
1347 beginRenderPass(vk, *cmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, WIDTH, HEIGHT), (deUint32)renderPassClearValues.size(), &renderPassClearValues[0]);
1348
1349 vk.cmdBeginQuery(*cmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1350 vk.cmdBindVertexBuffers(*cmdBuffer, 0, 1, &vertexBuffer, &vertexBufferOffset);
1351 vk.cmdBindPipeline(*cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1352
1353 draw(*cmdBuffer);
1354
1355 vk.cmdEndQuery(*cmdBuffer, *queryPool, 0u);
1356
1357 endRenderPass(vk, *cmdBuffer);
1358
1359 transition2DImage(vk, *cmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
1360 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1361 }
1362 endCommandBuffer(vk, *cmdBuffer);
1363
1364 // Wait for completion
1365 submitCommandsAndWait(vk, device, queue, *cmdBuffer);
1366 return checkResult(*queryPool);
1367 }
1368
checkResult(VkQueryPool queryPool)1369 tcu::TestStatus GeometryShaderTestInstance::checkResult (VkQueryPool queryPool)
1370 {
1371 const DeviceInterface& vk = m_context.getDeviceInterface();
1372 const VkDevice device = m_context.getDevice();
1373 deUint64 result = 0u;
1374 deUint64 expectedMin = 0u;
1375
1376 switch(m_parametersGraphic.queryStatisticFlags)
1377 {
1378 case VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT:
1379 expectedMin = m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST ? 16u :
1380 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST ? 8u :
1381 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP ? 15u :
1382 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST ? 4u :
1383 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ? 4u :
1384 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN ? 14u :
1385 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY ? 4u :
1386 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY ? 13u :
1387 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY ? 2u :
1388 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY ? 6u :
1389 0u;
1390 break;
1391 case VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT:
1392 case VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT:
1393 case VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT:
1394 expectedMin = m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST ? 112u :
1395 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST ? 32u :
1396 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP ? 60u :
1397 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST ? 8u :
1398 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ? 8u :
1399 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN ? 28u :
1400 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY ? 16u :
1401 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY ? 52u :
1402 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY ? 4u :
1403 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY ? 12u :
1404 0u;
1405 break;
1406 default:
1407 DE_ASSERT(0);
1408 break;
1409 }
1410
1411 VK_CHECK(vk.getQueryPoolResults(device, queryPool, 0u, 1u, sizeof(deUint64), &result, 0u, VK_QUERY_RESULT_64_BIT));
1412 if (result < expectedMin)
1413 return tcu::TestStatus::fail("QueryPoolResults incorrect");
1414
1415 if ( (m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST || m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ) && !checkImage())
1416 return tcu::TestStatus::fail("Result image doesn't match expected image.");
1417
1418 return tcu::TestStatus::pass("Pass");
1419 }
1420
draw(VkCommandBuffer cmdBuffer)1421 void GeometryShaderTestInstance::draw (VkCommandBuffer cmdBuffer)
1422 {
1423 const DeviceInterface& vk = m_context.getDeviceInterface();
1424 if (m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ||
1425 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST)
1426 {
1427 vk.cmdDraw(cmdBuffer, 3u, 1u, 0u, 1u);
1428 vk.cmdDraw(cmdBuffer, 3u, 1u, 4u, 1u);
1429 vk.cmdDraw(cmdBuffer, 3u, 1u, 8u, 2u);
1430 vk.cmdDraw(cmdBuffer, 3u, 1u, 12u, 3u);
1431 }
1432 else
1433 {
1434 vk.cmdDraw(cmdBuffer, 16u, 1u, 0u, 0u);
1435 }
1436 }
1437
1438 class GeometryShaderSecondaryTestInstance : public GeometryShaderTestInstance
1439 {
1440 public:
1441 GeometryShaderSecondaryTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1442 protected:
1443 virtual tcu::TestStatus executeTest (void);
1444 };
1445
GeometryShaderSecondaryTestInstance(vkt::Context & context,const std::vector<VertexData> & data,const ParametersGraphic & parametersGraphic)1446 GeometryShaderSecondaryTestInstance::GeometryShaderSecondaryTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1447 : GeometryShaderTestInstance (context, data, parametersGraphic)
1448 {
1449 }
1450
executeTest(void)1451 tcu::TestStatus GeometryShaderSecondaryTestInstance::executeTest (void)
1452 {
1453 const DeviceInterface& vk = m_context.getDeviceInterface();
1454 const VkDevice device = m_context.getDevice();
1455 const VkQueue queue = m_context.getUniversalQueue();
1456 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1457
1458 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1459 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1460 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1461
1462 const VkDeviceSize vertexBufferOffset = 0;
1463 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1464 const VkBuffer vertexBuffer = vertexBufferSp->object();
1465
1466 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1467 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
1468
1469 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, m_parametersGraphic.queryStatisticFlags, *m_renderPass, *m_framebuffer, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT);
1470 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1471 vk.cmdBeginQuery(*secondaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1472 vk.cmdBindVertexBuffers(*secondaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1473 draw(*secondaryCmdBuffer);
1474 vk.cmdEndQuery(*secondaryCmdBuffer, *queryPool, 0u);
1475 endCommandBuffer(vk, *secondaryCmdBuffer);
1476
1477 beginCommandBuffer(vk, *primaryCmdBuffer);
1478 {
1479 std::vector<VkClearValue> renderPassClearValues (2);
1480 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1481
1482 initialTransitionColor2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1483 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
1484 initialTransitionDepth2DImage(vk, *primaryCmdBuffer, m_depthImage->object(), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1485 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
1486
1487 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
1488 beginRenderPass(vk, *primaryCmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, WIDTH, HEIGHT), (deUint32)renderPassClearValues.size(), &renderPassClearValues[0], VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
1489 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
1490 endRenderPass(vk, *primaryCmdBuffer);
1491
1492 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
1493 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1494 }
1495 endCommandBuffer(vk, *primaryCmdBuffer);
1496
1497 // Wait for completion
1498 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
1499 return checkResult(*queryPool);
1500 }
1501
1502 class GeometryShaderSecondaryInheritedTestInstance : public GeometryShaderTestInstance
1503 {
1504 public:
1505 GeometryShaderSecondaryInheritedTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1506 protected:
1507 void checkExtensions (void);
1508 virtual tcu::TestStatus executeTest (void);
1509 };
1510
GeometryShaderSecondaryInheritedTestInstance(vkt::Context & context,const std::vector<VertexData> & data,const ParametersGraphic & parametersGraphic)1511 GeometryShaderSecondaryInheritedTestInstance::GeometryShaderSecondaryInheritedTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1512 : GeometryShaderTestInstance (context, data, parametersGraphic)
1513 {
1514 }
1515
checkExtensions(void)1516 void GeometryShaderSecondaryInheritedTestInstance::checkExtensions (void)
1517 {
1518 GeometryShaderTestInstance::checkExtensions();
1519 if (!m_context.getDeviceFeatures().inheritedQueries)
1520 throw tcu::NotSupportedError("Inherited queries are not supported");
1521 }
1522
executeTest(void)1523 tcu::TestStatus GeometryShaderSecondaryInheritedTestInstance::executeTest (void)
1524 {
1525 const DeviceInterface& vk = m_context.getDeviceInterface();
1526 const VkDevice device = m_context.getDevice();
1527 const VkQueue queue = m_context.getUniversalQueue();
1528 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1529
1530 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1531 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1532 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1533
1534 const VkDeviceSize vertexBufferOffset = 0u;
1535 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1536 const VkBuffer vertexBuffer = vertexBufferSp->object();
1537
1538 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1539 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
1540
1541 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, m_parametersGraphic.queryStatisticFlags, *m_renderPass, *m_framebuffer, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT);
1542 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1543 vk.cmdBindVertexBuffers(*secondaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1544 draw(*secondaryCmdBuffer);
1545 endCommandBuffer(vk, *secondaryCmdBuffer);
1546
1547 beginCommandBuffer(vk, *primaryCmdBuffer);
1548 {
1549 std::vector<VkClearValue> renderPassClearValues (2);
1550 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1551
1552 initialTransitionColor2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1553 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
1554 initialTransitionDepth2DImage(vk, *primaryCmdBuffer, m_depthImage->object(), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1555 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
1556
1557 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
1558 vk.cmdBeginQuery(*primaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1559 beginRenderPass(vk, *primaryCmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, WIDTH, HEIGHT), (deUint32)renderPassClearValues.size(), &renderPassClearValues[0], VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
1560 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
1561 endRenderPass(vk, *primaryCmdBuffer);
1562 vk.cmdEndQuery(*primaryCmdBuffer, *queryPool, 0u);
1563
1564 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
1565 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1566 }
1567 endCommandBuffer(vk, *primaryCmdBuffer);
1568
1569 // Wait for completion
1570 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
1571 return checkResult(*queryPool);
1572 }
1573
1574 class TessellationShaderTestInstance : public GraphicBasicTestInstance
1575 {
1576 public:
1577 TessellationShaderTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1578 protected:
1579 virtual void checkExtensions (void);
1580 virtual void createPipeline (void);
1581 virtual tcu::TestStatus executeTest (void);
1582 virtual tcu::TestStatus checkResult (VkQueryPool queryPool);
1583 void draw (VkCommandBuffer cmdBuffer);
1584 };
1585
TessellationShaderTestInstance(vkt::Context & context,const std::vector<VertexData> & data,const ParametersGraphic & parametersGraphic)1586 TessellationShaderTestInstance::TessellationShaderTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1587 : GraphicBasicTestInstance (context, data, parametersGraphic)
1588 {
1589 }
1590
checkExtensions(void)1591 void TessellationShaderTestInstance::checkExtensions (void)
1592 {
1593 StatisticQueryTestInstance::checkExtensions();
1594 if (!m_context.getDeviceFeatures().tessellationShader)
1595 throw tcu::NotSupportedError("Tessellation shader are not supported");
1596 }
1597
1598
createPipeline(void)1599 void TessellationShaderTestInstance::createPipeline (void)
1600 {
1601 const DeviceInterface& vk = m_context.getDeviceInterface();
1602 const VkDevice device = m_context.getDevice();
1603
1604 // Pipeline
1605 Unique<VkShaderModule> vs(createShaderModule(vk, device, m_context.getBinaryCollection().get("vertex"), (VkShaderModuleCreateFlags)0));
1606 Unique<VkShaderModule> tc(createShaderModule(vk, device, m_context.getBinaryCollection().get("tessellation_control"), (VkShaderModuleCreateFlags)0));
1607 Unique<VkShaderModule> te(createShaderModule(vk, device, m_context.getBinaryCollection().get("tessellation_evaluation"), (VkShaderModuleCreateFlags)0));
1608 Unique<VkShaderModule> fs(createShaderModule(vk, device, m_context.getBinaryCollection().get("fragment"), (VkShaderModuleCreateFlags)0));
1609
1610 const PipelineCreateInfo::ColorBlendState::Attachment attachmentState;
1611
1612 const PipelineLayoutCreateInfo pipelineLayoutCreateInfo;
1613 m_pipelineLayout = createPipelineLayout(vk, device, &pipelineLayoutCreateInfo);
1614
1615 const VkVertexInputBindingDescription vertexInputBindingDescription =
1616 {
1617 0u, // binding;
1618 static_cast<deUint32>(sizeof(VertexData)), // stride;
1619 VK_VERTEX_INPUT_RATE_VERTEX // inputRate
1620 };
1621
1622 const VkVertexInputAttributeDescription vertexInputAttributeDescriptions[] =
1623 {
1624 {
1625 0u,
1626 0u,
1627 VK_FORMAT_R32G32B32A32_SFLOAT,
1628 0u
1629 }, // VertexElementData::position
1630 {
1631 1u,
1632 0u,
1633 VK_FORMAT_R32G32B32A32_SFLOAT,
1634 static_cast<deUint32>(sizeof(tcu::Vec4))
1635 }, // VertexElementData::color
1636 };
1637
1638 const VkPipelineVertexInputStateCreateInfo vf_info =
1639 { // sType;
1640 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // pNext;
1641 NULL, // flags;
1642 0u, // vertexBindingDescriptionCount;
1643 1u, // pVertexBindingDescriptions;
1644 &vertexInputBindingDescription, // vertexAttributeDescriptionCount;
1645 2u, // pVertexAttributeDescriptions;
1646 vertexInputAttributeDescriptions
1647 };
1648
1649 PipelineCreateInfo pipelineCreateInfo(*m_pipelineLayout, *m_renderPass, 0, (VkPipelineCreateFlags)0);
1650 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*vs, "main", VK_SHADER_STAGE_VERTEX_BIT));
1651 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*tc, "main", VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT));
1652 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*te, "main", VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT));
1653 pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*fs, "main", VK_SHADER_STAGE_FRAGMENT_BIT));
1654 pipelineCreateInfo.addState (PipelineCreateInfo::TessellationState(4));
1655 pipelineCreateInfo.addState(PipelineCreateInfo::InputAssemblerState(VK_PRIMITIVE_TOPOLOGY_PATCH_LIST));
1656 pipelineCreateInfo.addState(PipelineCreateInfo::ColorBlendState(1, &attachmentState));
1657
1658 const VkViewport viewport = makeViewport(WIDTH, HEIGHT);
1659 const VkRect2D scissor = makeRect2D(WIDTH, HEIGHT);
1660
1661 pipelineCreateInfo.addState(PipelineCreateInfo::ViewportState(1, std::vector<VkViewport>(1, viewport), std::vector<VkRect2D>(1, scissor)));
1662 pipelineCreateInfo.addState(PipelineCreateInfo::DepthStencilState());
1663 pipelineCreateInfo.addState(PipelineCreateInfo::RasterizerState());
1664 pipelineCreateInfo.addState(PipelineCreateInfo::MultiSampleState());
1665 pipelineCreateInfo.addState(vf_info);
1666 m_pipeline = createGraphicsPipeline(vk, device, DE_NULL, &pipelineCreateInfo);
1667 }
1668
executeTest(void)1669 tcu::TestStatus TessellationShaderTestInstance::executeTest (void)
1670 {
1671 const DeviceInterface& vk = m_context.getDeviceInterface();
1672 const VkDevice device = m_context.getDevice();
1673 const VkQueue queue = m_context.getUniversalQueue();
1674 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1675
1676 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1677 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1678 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1679
1680 const VkDeviceSize vertexBufferOffset = 0u;
1681 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1682 const VkBuffer vertexBuffer = vertexBufferSp->object();
1683
1684 const Unique<VkCommandBuffer> cmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1685
1686 beginCommandBuffer(vk, *cmdBuffer);
1687 {
1688 std::vector<VkClearValue> renderPassClearValues (2);
1689 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1690
1691 initialTransitionColor2DImage(vk, *cmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1692 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
1693 initialTransitionDepth2DImage(vk, *cmdBuffer, m_depthImage->object(), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1694 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
1695
1696 vk.cmdResetQueryPool(*cmdBuffer, *queryPool, 0u, 1u);
1697
1698 beginRenderPass(vk, *cmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, WIDTH, HEIGHT), (deUint32)renderPassClearValues.size(), &renderPassClearValues[0]);
1699
1700 vk.cmdBeginQuery(*cmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1701 vk.cmdBindVertexBuffers(*cmdBuffer, 0, 1, &vertexBuffer, &vertexBufferOffset);
1702 vk.cmdBindPipeline(*cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1703
1704 draw(*cmdBuffer);
1705
1706 vk.cmdEndQuery(*cmdBuffer, *queryPool, 0u);
1707
1708 endRenderPass(vk, *cmdBuffer);
1709
1710 transition2DImage(vk, *cmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
1711 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1712 }
1713 endCommandBuffer(vk, *cmdBuffer);
1714
1715 // Wait for completion
1716 submitCommandsAndWait(vk, device, queue, *cmdBuffer);
1717 return checkResult (*queryPool);
1718 }
1719
checkResult(VkQueryPool queryPool)1720 tcu::TestStatus TessellationShaderTestInstance::checkResult (VkQueryPool queryPool)
1721 {
1722 const DeviceInterface& vk = m_context.getDeviceInterface();
1723 const VkDevice device = m_context.getDevice();
1724 deUint64 result = 0u;
1725 deUint64 expectedMin = 0u;
1726
1727 switch(m_parametersGraphic.queryStatisticFlags)
1728 {
1729 case VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT:
1730 expectedMin = 4u;
1731 break;
1732 case VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT:
1733 expectedMin = 100u;
1734 break;
1735 default:
1736 DE_ASSERT(0);
1737 break;
1738 }
1739 VK_CHECK(vk.getQueryPoolResults(device, queryPool, 0u, 1u, sizeof(deUint64), &result, 0u, VK_QUERY_RESULT_64_BIT));
1740 if (result < expectedMin)
1741 return tcu::TestStatus::fail("QueryPoolResults incorrect");
1742
1743 if (!checkImage())
1744 return tcu::TestStatus::fail("Result image doesn't match expected image.");
1745
1746 return tcu::TestStatus::pass("Pass");
1747 }
1748
draw(VkCommandBuffer cmdBuffer)1749 void TessellationShaderTestInstance::draw (VkCommandBuffer cmdBuffer)
1750 {
1751 const DeviceInterface& vk = m_context.getDeviceInterface();
1752 vk.cmdDraw(cmdBuffer, static_cast<deUint32>(m_data.size()), 1u, 0u, 0u);
1753 }
1754
1755 class TessellationShaderSecondrayTestInstance : public TessellationShaderTestInstance
1756 {
1757 public:
1758 TessellationShaderSecondrayTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1759 protected:
1760 virtual tcu::TestStatus executeTest (void);
1761 };
1762
TessellationShaderSecondrayTestInstance(vkt::Context & context,const std::vector<VertexData> & data,const ParametersGraphic & parametersGraphic)1763 TessellationShaderSecondrayTestInstance::TessellationShaderSecondrayTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1764 : TessellationShaderTestInstance (context, data, parametersGraphic)
1765 {
1766 }
1767
executeTest(void)1768 tcu::TestStatus TessellationShaderSecondrayTestInstance::executeTest (void)
1769 {
1770 const DeviceInterface& vk = m_context.getDeviceInterface();
1771 const VkDevice device = m_context.getDevice();
1772 const VkQueue queue = m_context.getUniversalQueue();
1773 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1774
1775 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1776 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1777 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1778
1779 const VkDeviceSize vertexBufferOffset = 0u;
1780 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1781 const VkBuffer vertexBuffer = vertexBufferSp->object();
1782
1783 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1784 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
1785
1786 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, m_parametersGraphic.queryStatisticFlags, *m_renderPass, *m_framebuffer, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT);
1787 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1788 vk.cmdBeginQuery(*secondaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1789 vk.cmdBindVertexBuffers(*secondaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1790 draw(*secondaryCmdBuffer);
1791 vk.cmdEndQuery(*secondaryCmdBuffer, *queryPool, 0u);
1792 endCommandBuffer(vk, *secondaryCmdBuffer);
1793
1794 beginCommandBuffer(vk, *primaryCmdBuffer);
1795 {
1796 std::vector<VkClearValue> renderPassClearValues (2);
1797 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1798
1799 initialTransitionColor2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1800 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
1801 initialTransitionDepth2DImage(vk, *primaryCmdBuffer, m_depthImage->object(), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1802 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
1803
1804 vk.cmdBindVertexBuffers(*primaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1805 vk.cmdBindPipeline(*primaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1806 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
1807
1808 beginRenderPass(vk, *primaryCmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, WIDTH, HEIGHT), (deUint32)renderPassClearValues.size(), &renderPassClearValues[0], VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
1809 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
1810 endRenderPass(vk, *primaryCmdBuffer);
1811
1812 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
1813 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1814 }
1815 endCommandBuffer(vk, *primaryCmdBuffer);
1816
1817 // Wait for completion
1818 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
1819 return checkResult (*queryPool);
1820 }
1821
1822 class TessellationShaderSecondrayInheritedTestInstance : public TessellationShaderTestInstance
1823 {
1824 public:
1825 TessellationShaderSecondrayInheritedTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic);
1826 protected:
1827 virtual void checkExtensions (void);
1828 virtual tcu::TestStatus executeTest (void);
1829 };
1830
TessellationShaderSecondrayInheritedTestInstance(vkt::Context & context,const std::vector<VertexData> & data,const ParametersGraphic & parametersGraphic)1831 TessellationShaderSecondrayInheritedTestInstance::TessellationShaderSecondrayInheritedTestInstance (vkt::Context& context, const std::vector<VertexData>& data, const ParametersGraphic& parametersGraphic)
1832 : TessellationShaderTestInstance (context, data, parametersGraphic)
1833 {
1834 }
1835
checkExtensions(void)1836 void TessellationShaderSecondrayInheritedTestInstance::checkExtensions (void)
1837 {
1838 TessellationShaderTestInstance::checkExtensions();
1839 if (!m_context.getDeviceFeatures().inheritedQueries)
1840 throw tcu::NotSupportedError("Inherited queries are not supported");
1841 }
1842
executeTest(void)1843 tcu::TestStatus TessellationShaderSecondrayInheritedTestInstance::executeTest (void)
1844 {
1845 const DeviceInterface& vk = m_context.getDeviceInterface();
1846 const VkDevice device = m_context.getDevice();
1847 const VkQueue queue = m_context.getUniversalQueue();
1848 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
1849
1850 const CmdPoolCreateInfo cmdPoolCreateInfo (queueFamilyIndex);
1851 const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, &cmdPoolCreateInfo);
1852 const Unique<VkQueryPool> queryPool (makeQueryPool(vk, device, m_parametersGraphic.queryStatisticFlags));
1853
1854 const VkDeviceSize vertexBufferOffset = 0u;
1855 const de::SharedPtr<Buffer> vertexBufferSp = creatAndFillVertexBuffer();
1856 const VkBuffer vertexBuffer = vertexBufferSp->object();
1857
1858 const Unique<VkCommandBuffer> primaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1859 const Unique<VkCommandBuffer> secondaryCmdBuffer (allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY));
1860
1861 beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, m_parametersGraphic.queryStatisticFlags, *m_renderPass, *m_framebuffer, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT);
1862 vk.cmdBindPipeline(*secondaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1863 vk.cmdBindVertexBuffers(*secondaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1864 draw(*secondaryCmdBuffer);
1865 endCommandBuffer(vk, *secondaryCmdBuffer);
1866
1867 beginCommandBuffer(vk, *primaryCmdBuffer);
1868 {
1869 std::vector<VkClearValue> renderPassClearValues (2);
1870 deMemset(&renderPassClearValues[0], 0, static_cast<int>(renderPassClearValues.size()) * sizeof(VkClearValue));
1871
1872 initialTransitionColor2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1873 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
1874 initialTransitionDepth2DImage(vk, *primaryCmdBuffer, m_depthImage->object(), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1875 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
1876
1877 vk.cmdBindVertexBuffers(*primaryCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1878 vk.cmdBindPipeline(*primaryCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
1879 vk.cmdResetQueryPool(*primaryCmdBuffer, *queryPool, 0u, 1u);
1880 vk.cmdBeginQuery(*primaryCmdBuffer, *queryPool, 0u, (VkQueryControlFlags)0u);
1881
1882 beginRenderPass(vk, *primaryCmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, WIDTH, HEIGHT), (deUint32)renderPassClearValues.size(), &renderPassClearValues[0], VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
1883 vk.cmdExecuteCommands(*primaryCmdBuffer, 1u, &secondaryCmdBuffer.get());
1884 endRenderPass(vk, *primaryCmdBuffer);
1885 vk.cmdEndQuery(*primaryCmdBuffer, *queryPool, 0u);
1886
1887 transition2DImage(vk, *primaryCmdBuffer, m_colorAttachmentImage->object(), VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
1888 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1889 }
1890 endCommandBuffer(vk, *primaryCmdBuffer);
1891
1892 // Wait for completion
1893 submitCommandsAndWait(vk, device, queue, *primaryCmdBuffer);
1894 return checkResult (*queryPool);
1895 }
1896
1897 template<class Instance>
1898 class QueryPoolStatisticsTest : public TestCase
1899 {
1900 public:
QueryPoolStatisticsTest(tcu::TestContext & context,const char * name,const char * description)1901 QueryPoolStatisticsTest (tcu::TestContext &context, const char *name, const char *description)
1902 : TestCase (context, name, description)
1903 {
1904 const tcu::UVec3 localSize[] =
1905 {
1906 tcu::UVec3 (2u, 2u, 2u),
1907 tcu::UVec3 (1u, 1u, 1u),
1908 tcu::UVec3 (WIDTH/(7u*3u), 7u, 3u),
1909 };
1910
1911 const tcu::UVec3 groupSize[] =
1912 {
1913 tcu::UVec3 (2u, 2u, 2u),
1914 tcu::UVec3 (WIDTH/(7u*3u), 7u, 3u),
1915 tcu::UVec3 (1u, 1u, 1u),
1916 };
1917
1918 DE_ASSERT(DE_LENGTH_OF_ARRAY(localSize) == DE_LENGTH_OF_ARRAY(groupSize));
1919
1920 for(int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(localSize); ++shaderNdx)
1921 {
1922 std::ostringstream shaderName;
1923 shaderName<< "compute_" << shaderNdx;
1924 const ComputeInvocationsTestInstance::ParametersCompute prameters =
1925 {
1926 localSize[shaderNdx],
1927 groupSize[shaderNdx],
1928 shaderName.str(),
1929 };
1930 m_parameters.push_back(prameters);
1931 }
1932 }
1933
createInstance(vkt::Context & context) const1934 vkt::TestInstance* createInstance (vkt::Context& context) const
1935 {
1936 return new Instance(context, m_parameters);
1937 }
1938
initPrograms(SourceCollections & sourceCollections) const1939 void initPrograms(SourceCollections& sourceCollections) const
1940 {
1941 std::ostringstream source;
1942 source << "layout(binding = 0) writeonly buffer Output {\n"
1943 << " uint values[];\n"
1944 << "} sb_out;\n\n"
1945 << "void main (void) {\n"
1946 << " uvec3 indexUvec3 = uvec3 (gl_GlobalInvocationID.x,\n"
1947 << " gl_GlobalInvocationID.y * gl_NumWorkGroups.x * gl_WorkGroupSize.x,\n"
1948 << " gl_GlobalInvocationID.z * gl_NumWorkGroups.x * gl_NumWorkGroups.y * gl_WorkGroupSize.x * gl_WorkGroupSize.y);\n"
1949 << " uint index = indexUvec3.x + indexUvec3.y + indexUvec3.z;\n"
1950 << " sb_out.values[index] += index;\n"
1951 << "}\n";
1952
1953 for(size_t shaderNdx = 0; shaderNdx < m_parameters.size(); ++shaderNdx)
1954 {
1955 std::ostringstream src;
1956 src << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
1957 << "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"
1958 << source.str();
1959 sourceCollections.glslSources.add(m_parameters[shaderNdx].shaderName) << glu::ComputeSource(src.str());
1960 }
1961 }
1962 private:
1963 std::vector<ComputeInvocationsTestInstance::ParametersCompute> m_parameters;
1964 };
1965
1966 template<class Instance>
1967 class QueryPoolGraphicStatisticsTest : public TestCase
1968 {
1969 public:
QueryPoolGraphicStatisticsTest(tcu::TestContext & context,const char * name,const char * description,const GraphicBasicTestInstance::ParametersGraphic parametersGraphic)1970 QueryPoolGraphicStatisticsTest (tcu::TestContext &context, const char *name, const char *description, const GraphicBasicTestInstance::ParametersGraphic parametersGraphic)
1971 : TestCase (context, name, description)
1972 , m_parametersGraphic (parametersGraphic)
1973 {
1974 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4(-1.0f,-1.0f, 1.0f, 1.0f), tcu::RGBA::red().toVec()));
1975 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4(-1.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::red().toVec()));
1976 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f,-1.0f, 1.0f, 1.0f), tcu::RGBA::red().toVec()));
1977 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::red().toVec()));
1978
1979 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4(-1.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::green().toVec()));
1980 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4(-1.0f, 1.0f, 1.0f, 1.0f), tcu::RGBA::green().toVec()));
1981 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f, 0.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::green().toVec()));
1983
1984 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f,-1.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec()));
1985 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec()));
1986 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 1.0f,-1.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec()));
1987 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 1.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec()));
1988
1989 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::gray().toVec()));
1990 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 0.0f, 1.0f, 1.0f, 1.0f), tcu::RGBA::gray().toVec()));
1991 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 1.0f, 0.0f, 1.0f, 1.0f), tcu::RGBA::gray().toVec()));
1992 m_data.push_back(GraphicBasicTestInstance::VertexData(tcu::Vec4( 1.0f, 1.0f, 1.0f, 1.0f), tcu::RGBA::gray().toVec()));
1993 }
1994
createInstance(vkt::Context & context) const1995 vkt::TestInstance* createInstance (vkt::Context& context) const
1996 {
1997 return new Instance(context, m_data, m_parametersGraphic);
1998 }
1999
initPrograms(SourceCollections & sourceCollections) const2000 void initPrograms(SourceCollections& sourceCollections) const
2001 {
2002 { // Vertex Shader
2003 std::ostringstream source;
2004 source << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
2005 << "layout(location = 0) in highp vec4 in_position;\n"
2006 << "layout(location = 1) in vec4 in_color;\n"
2007 << "layout(location = 0) out vec4 out_color;\n"
2008 << "void main (void)\n"
2009 << "{\n"
2010 << " gl_Position = in_position;\n"
2011 << " out_color = in_color;\n"
2012 << "}\n";
2013 sourceCollections.glslSources.add("vertex") << glu::VertexSource(source.str());
2014 }
2015
2016 if (m_parametersGraphic.queryStatisticFlags & (VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT|
2017 VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT))
2018 {// Tessellation control & evaluation
2019 std::ostringstream source_tc;
2020 source_tc << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450) << "\n"
2021 << "#extension GL_EXT_tessellation_shader : require\n"
2022 << "layout(vertices = 4) out;\n"
2023 << "layout(location = 0) in vec4 in_color[];\n"
2024 << "layout(location = 0) out vec4 out_color[];\n"
2025 << "\n"
2026 << "void main (void)\n"
2027 << "{\n"
2028 << " if( gl_InvocationID == 0 )\n"
2029 << " {\n"
2030 << " gl_TessLevelInner[0] = 4.0f;\n"
2031 << " gl_TessLevelInner[1] = 4.0f;\n"
2032 << " gl_TessLevelOuter[0] = 4.0f;\n"
2033 << " gl_TessLevelOuter[1] = 4.0f;\n"
2034 << " gl_TessLevelOuter[2] = 4.0f;\n"
2035 << " gl_TessLevelOuter[3] = 4.0f;\n"
2036 << " }\n"
2037 << " out_color[gl_InvocationID] = in_color[gl_InvocationID];\n"
2038 << " gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
2039 << "}\n";
2040 sourceCollections.glslSources.add("tessellation_control") << glu::TessellationControlSource(source_tc.str());
2041
2042 std::ostringstream source_te;
2043 source_te << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450) << "\n"
2044 << "#extension GL_EXT_tessellation_shader : require\n"
2045 << "layout( quads, equal_spacing, ccw ) in;\n"
2046 << "layout(location = 0) in vec4 in_color[];\n"
2047 << "layout(location = 0) out vec4 out_color;\n"
2048 << "void main (void)\n"
2049 << "{\n"
2050 << " const float u = gl_TessCoord.x;\n"
2051 << " const float v = gl_TessCoord.y;\n"
2052 << " const float w = gl_TessCoord.z;\n"
2053 << " 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"
2054 << " out_color = in_color[0];\n"
2055 << "}\n";
2056 sourceCollections.glslSources.add("tessellation_evaluation") << glu::TessellationEvaluationSource(source_te.str());
2057 }
2058
2059 if(m_parametersGraphic.queryStatisticFlags & (VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT | VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT |
2060 VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT | VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT))
2061 { // Geometry Shader
2062 const bool isTopologyPointSize = m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST;
2063 std::ostringstream source;
2064 source << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
2065 << "layout("<<inputTypeToGLString(m_parametersGraphic.primitiveTopology)<<") in;\n"
2066 << "layout("<<outputTypeToGLString (m_parametersGraphic.primitiveTopology)<<", max_vertices = 16) out;\n"
2067 << "layout(location = 0) in vec4 in_color[];\n"
2068 << "layout(location = 0) out vec4 out_color;\n"
2069 << "void main (void)\n"
2070 << "{\n"
2071 << " out_color = in_color[0];\n"
2072 << (isTopologyPointSize ? "${pointSize}" : "" )
2073 << " gl_Position = gl_in[0].gl_Position;\n"
2074 << " EmitVertex();\n"
2075 << " EndPrimitive();\n"
2076 << "\n"
2077 << " out_color = in_color[0];\n"
2078 << (isTopologyPointSize ? "${pointSize}" : "")
2079 << " gl_Position = vec4(1.0, 1.0, 1.0, 1.0);\n"
2080 << " EmitVertex();\n"
2081 << " out_color = in_color[0];\n"
2082 << (isTopologyPointSize ? "${pointSize}" : "")
2083 << " gl_Position = vec4(-1.0, -1.0, 1.0, 1.0);\n"
2084 << " EmitVertex();\n"
2085 << " EndPrimitive();\n"
2086 << "\n";
2087 if (m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ||
2088 m_parametersGraphic.primitiveTopology == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST)
2089 {
2090 source << "\n"
2091 << " out_color = in_color[0];\n"
2092 << " gl_Position = gl_in[0].gl_Position;\n"
2093 << " EmitVertex();\n"
2094 << " out_color = in_color[0];\n"
2095 << " gl_Position = gl_in[1].gl_Position;\n"
2096 << " EmitVertex();\n"
2097 << " out_color = in_color[0];\n"
2098 << " gl_Position = gl_in[2].gl_Position;\n"
2099 << " EmitVertex();\n"
2100 << " out_color = in_color[0];\n"
2101 << " gl_Position = vec4(gl_in[2].gl_Position.x, gl_in[1].gl_Position.y, 1.0, 1.0);\n"
2102 << " EmitVertex();\n"
2103 << " EndPrimitive();\n";
2104 }
2105 else
2106 {
2107 source << " out_color = in_color[0];\n"
2108 << (isTopologyPointSize ? "${pointSize}" : "")
2109 << " gl_Position = vec4(1.0, 1.0, 1.0, 1.0);\n"
2110 << " EmitVertex();\n"
2111 << " out_color = in_color[0];\n"
2112 << (isTopologyPointSize ? "${pointSize}" : "")
2113 << " gl_Position = vec4(1.0, -1.0, 1.0, 1.0);\n"
2114 << " EmitVertex();\n"
2115 << " out_color = in_color[0];\n"
2116 << (isTopologyPointSize ? "${pointSize}" : "")
2117 << " gl_Position = vec4(-1.0, 1.0, 1.0, 1.0);\n"
2118 << " EmitVertex();\n"
2119 << " out_color = in_color[0];\n"
2120 << (isTopologyPointSize ? "${pointSize}" : "")
2121 << " gl_Position = vec4(-1.0, -1.0, 1.0, 1.0);\n"
2122 << " EmitVertex();\n"
2123 << " EndPrimitive();\n";
2124 }
2125 source << "}\n";
2126
2127 if (isTopologyPointSize)
2128 {
2129 // Add geometry shader codes with and without gl_PointSize if the primitive topology is VK_PRIMITIVE_TOPOLOGY_POINT_LIST
2130
2131 tcu::StringTemplate sourceTemplate(source.str());
2132
2133 std::map<std::string, std::string> pointSize;
2134 std::map<std::string, std::string> noPointSize;
2135
2136 pointSize["pointSize"] = " gl_PointSize = gl_in[0].gl_PointSize;\n";
2137 noPointSize["pointSize"] = "";
2138
2139 sourceCollections.glslSources.add("geometry") << glu::GeometrySource(sourceTemplate.specialize(noPointSize));
2140 sourceCollections.glslSources.add("geometry_point_size") << glu::GeometrySource(sourceTemplate.specialize(pointSize));
2141 }
2142 else
2143 {
2144 sourceCollections.glslSources.add("geometry") << glu::GeometrySource(source.str());
2145 }
2146 }
2147
2148 { // Fragment Shader
2149 std::ostringstream source;
2150 source << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
2151 << "layout(location = 0) in vec4 in_color;\n"
2152 << "layout(location = 0) out vec4 out_color;\n"
2153 << "void main()\n"
2154 <<"{\n"
2155 << " out_color = in_color;\n"
2156 << "}\n";
2157 sourceCollections.glslSources.add("fragment") << glu::FragmentSource(source.str());
2158 }
2159 }
2160 private:
2161 std::vector<GraphicBasicTestInstance::VertexData> m_data;
2162 const GraphicBasicTestInstance::ParametersGraphic m_parametersGraphic;
2163 };
2164 } //anonymous
2165
QueryPoolStatisticsTests(tcu::TestContext & testCtx)2166 QueryPoolStatisticsTests::QueryPoolStatisticsTests (tcu::TestContext &testCtx)
2167 : TestCaseGroup(testCtx, "statistics_query", "Tests for statistics queries")
2168 {
2169 }
2170
init(void)2171 void QueryPoolStatisticsTests::init (void)
2172 {
2173 std::string topology_name [VK_PRIMITIVE_TOPOLOGY_LAST] =
2174 {
2175 "point_list",
2176 "line_list",
2177 "line_strip",
2178 "triangle_list",
2179 "triangle_strip",
2180 "triangle_fan",
2181 "line_list_with_adjacency",
2182 "line_strip_with_adjacency",
2183 "triangle_list_with_adjacency",
2184 "triangle_strip_with_adjacency",
2185 "patch_list"
2186 };
2187
2188 de::MovePtr<TestCaseGroup> computeShaderInvocationsGroup (new TestCaseGroup(m_testCtx, "compute_shader_invocations", "Query pipeline statistic compute shader invocations"));
2189 de::MovePtr<TestCaseGroup> inputAssemblyVertices (new TestCaseGroup(m_testCtx, "input_assembly_vertices", "Query pipeline statistic input assembly vertices"));
2190 de::MovePtr<TestCaseGroup> inputAssemblyPrimitives (new TestCaseGroup(m_testCtx, "input_assembly_primitives", "Query pipeline statistic input assembly primitives"));
2191 de::MovePtr<TestCaseGroup> vertexShaderInvocations (new TestCaseGroup(m_testCtx, "vertex_shader_invocations", "Query pipeline statistic vertex shader invocation"));
2192 de::MovePtr<TestCaseGroup> fragmentShaderInvocations (new TestCaseGroup(m_testCtx, "fragment_shader_invocations", "Query pipeline statistic fragment shader invocation"));
2193 de::MovePtr<TestCaseGroup> geometryShaderInvocations (new TestCaseGroup(m_testCtx, "geometry_shader_invocations", "Query pipeline statistic geometry shader invocation"));
2194 de::MovePtr<TestCaseGroup> geometryShaderPrimitives (new TestCaseGroup(m_testCtx, "geometry_shader_primitives", "Query pipeline statistic geometry shader primitives"));
2195 de::MovePtr<TestCaseGroup> clippingInvocations (new TestCaseGroup(m_testCtx, "clipping_invocations", "Query pipeline statistic clipping invocations"));
2196 de::MovePtr<TestCaseGroup> clippingPrimitives (new TestCaseGroup(m_testCtx, "clipping_primitives", "Query pipeline statistic clipping primitives"));
2197 de::MovePtr<TestCaseGroup> tesControlPatches (new TestCaseGroup(m_testCtx, "tes_control_patches", "Query pipeline statistic tessellation control shader patches"));
2198 de::MovePtr<TestCaseGroup> tesEvaluationShaderInvocations (new TestCaseGroup(m_testCtx, "tes_evaluation_shader_invocations", "Query pipeline statistic tessellation evaluation shader invocations"));
2199
2200 computeShaderInvocationsGroup->addChild(new QueryPoolStatisticsTest<ComputeInvocationsTestInstance> (m_testCtx, "primary", ""));
2201 computeShaderInvocationsGroup->addChild(new QueryPoolStatisticsTest<ComputeInvocationsSecondaryTestInstance> (m_testCtx, "secondary", ""));
2202 computeShaderInvocationsGroup->addChild(new QueryPoolStatisticsTest<ComputeInvocationsSecondaryInheritedTestInstance> (m_testCtx, "secondary_inherited", ""));
2203
2204 //VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT
2205 inputAssemblyVertices->addChild(new QueryPoolGraphicStatisticsTest<VertexShaderTestInstance> (m_testCtx, "primary", "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP)));
2206 inputAssemblyVertices->addChild(new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryTestInstance> (m_testCtx, "secondary", "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP)));
2207 inputAssemblyVertices->addChild(new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryInheritedTestInstance> (m_testCtx, "secondary_inherited", "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP)));
2208
2209 //VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT
2210 {
2211 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2212 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2213 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2214 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2215 {
2216 primary->addChild (new QueryPoolGraphicStatisticsTest<VertexShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2217 secondary->addChild (new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2218 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2219 }
2220 inputAssemblyPrimitives->addChild(primary.release());
2221 inputAssemblyPrimitives->addChild(secondary.release());
2222 inputAssemblyPrimitives->addChild(secondaryInherited.release());
2223 }
2224
2225 //VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT
2226 {
2227 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2228 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2229 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2230 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2231 {
2232 primary->addChild (new QueryPoolGraphicStatisticsTest<VertexShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2233 secondary->addChild (new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2234 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2235 }
2236 vertexShaderInvocations->addChild(primary.release());
2237 vertexShaderInvocations->addChild(secondary.release());
2238 vertexShaderInvocations->addChild(secondaryInherited.release());
2239 }
2240
2241 //VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT
2242 {
2243 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2244 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2245 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2246 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2247 {
2248 primary->addChild (new QueryPoolGraphicStatisticsTest<VertexShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2249 secondary->addChild (new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2250 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<VertexShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2251 }
2252 fragmentShaderInvocations->addChild(primary.release());
2253 fragmentShaderInvocations->addChild(secondary.release());
2254 fragmentShaderInvocations->addChild(secondaryInherited.release());
2255 }
2256
2257 //VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT
2258 {
2259 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2260 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2261 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2262 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2263 {
2264 primary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2265 secondary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2266 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2267 }
2268 geometryShaderInvocations->addChild(primary.release());
2269 geometryShaderInvocations->addChild(secondary.release());
2270 geometryShaderInvocations->addChild(secondaryInherited.release());
2271 }
2272
2273 //VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT
2274 {
2275 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2276 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2277 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2278 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2279 {
2280 primary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2281 secondary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2282 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2283 }
2284 geometryShaderPrimitives->addChild(primary.release());
2285 geometryShaderPrimitives->addChild(secondary.release());
2286 geometryShaderPrimitives->addChild(secondaryInherited.release());
2287 }
2288
2289 //VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT
2290 {
2291 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2292 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2293 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2294 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2295 {
2296 primary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2297 secondary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2298 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT, (VkPrimitiveTopology)topologyNdx)));
2299 }
2300 clippingInvocations->addChild(primary.release());
2301 clippingInvocations->addChild(secondary.release());
2302 clippingInvocations->addChild(secondaryInherited.release());
2303 }
2304
2305 //VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT
2306 {
2307 de::MovePtr<TestCaseGroup> primary (new TestCaseGroup(m_testCtx, "primary", ""));
2308 de::MovePtr<TestCaseGroup> secondary (new TestCaseGroup(m_testCtx, "secondary", ""));
2309 de::MovePtr<TestCaseGroup> secondaryInherited (new TestCaseGroup(m_testCtx, "secondary_inherited",""));
2310 for (int topologyNdx = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; topologyNdx < VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; ++topologyNdx)
2311 {
2312 primary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2313 secondary->addChild (new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2314 secondaryInherited->addChild(new QueryPoolGraphicStatisticsTest<GeometryShaderSecondaryInheritedTestInstance> (m_testCtx, topology_name[topologyNdx].c_str(), "", GraphicBasicTestInstance::ParametersGraphic(VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT, (VkPrimitiveTopology)topologyNdx)));
2315 }
2316 clippingPrimitives->addChild(primary.release());
2317 clippingPrimitives->addChild(secondary.release());
2318 clippingPrimitives->addChild(secondaryInherited.release());
2319 }
2320
2321 //VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT
2322 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)));
2323 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)));
2324 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)));
2325
2326 //VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT
2327 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)));
2328 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)));
2329 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)));
2330
2331 addChild(computeShaderInvocationsGroup.release());
2332 addChild(inputAssemblyVertices.release());
2333 addChild(inputAssemblyPrimitives.release());
2334 addChild(vertexShaderInvocations.release());
2335 addChild(fragmentShaderInvocations.release());
2336 addChild(geometryShaderInvocations.release());
2337 addChild(geometryShaderPrimitives.release());
2338 addChild(clippingInvocations.release());
2339 addChild(clippingPrimitives.release());
2340 addChild(tesControlPatches.release());
2341 addChild(tesEvaluationShaderInvocations.release());
2342 }
2343
2344 } //QueryPool
2345 } //vkt
2346