cb9b42675cfc2771f4789fd4deb5e340e97321bf
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / synchronization / vktSynchronizationBasicEventTests.cpp
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 Synchronization event basic tests
22  *//*--------------------------------------------------------------------*/
23
24 #include "vktSynchronizationBasicEventTests.hpp"
25 #include "vktTestCaseUtil.hpp"
26 #include "vktSynchronizationUtil.hpp"
27
28 #include "vkDefs.hpp"
29 #include "vkPlatform.hpp"
30
31 #include "vkRef.hpp"
32
33 namespace vkt
34 {
35 namespace synchronization
36 {
37 namespace
38 {
39
40 using namespace vk;
41 #define SHORT_FENCE_WAIT        1000ull
42 #define LONG_FENCE_WAIT         ~0ull
43
44 tcu::TestStatus hostResetSetEventCase (Context& context)
45 {
46         const DeviceInterface&          vk                      = context.getDeviceInterface();
47         const VkDevice                          device          = context.getDevice();
48         const VkEventCreateInfo         eventInfo       =
49                                                                                         {
50                                                                                                 VK_STRUCTURE_TYPE_EVENT_CREATE_INFO,
51                                                                                                 DE_NULL,
52                                                                                                 0
53                                                                                         };
54         VkEvent                                         event;
55         Move<VkEvent>                           ptrEvent;
56
57         if (VK_SUCCESS != vk.createEvent(device, &eventInfo, DE_NULL, &event))
58                 return tcu::TestStatus::fail("Couldn't create event");
59
60         ptrEvent = Move<VkEvent>(check<VkEvent>(event), Deleter<VkEvent>(vk, device, DE_NULL));
61
62         if (VK_EVENT_RESET != vk.getEventStatus(device, event))
63                 return tcu::TestStatus::fail("Created event should be in unsignaled state");
64
65         if (VK_SUCCESS != vk.setEvent(device, event))
66                 return tcu::TestStatus::fail("Couldn't set event");
67
68         if (VK_EVENT_SET != vk.getEventStatus(device, event))
69                 return tcu::TestStatus::fail("Event should be in signaled state after set");
70
71         if (VK_SUCCESS != vk.resetEvent(device, event))
72                 return tcu::TestStatus::fail("Couldn't reset event");
73
74         if (VK_EVENT_RESET != vk.getEventStatus(device, event))
75                 return tcu::TestStatus::fail("Event should be in unsignaled state after reset");
76
77         return tcu::TestStatus::pass("Tests set and reset event on host pass");
78 }
79
80 tcu::TestStatus deviceResetSetEventCase (Context& context)
81 {
82         const DeviceInterface&                  vk                                      = context.getDeviceInterface();
83         const VkDevice                                  device                          = context.getDevice();
84         const VkQueue                                   queue                           = context.getUniversalQueue();
85         const deUint32                                  queueFamilyIndex        = context.getUniversalQueueFamilyIndex();
86         const Unique<VkCommandPool>             cmdPool                         (makeCommandPool(vk, device, queueFamilyIndex));
87         const Unique<VkCommandBuffer>   cmdBuffer                       (makeCommandBuffer(vk, device, *cmdPool));
88         const VkSubmitInfo                              submitInfo                      =
89                                                                                                                 {
90                                                                                                                         VK_STRUCTURE_TYPE_SUBMIT_INFO,  // VkStructureType                              sType;
91                                                                                                                         DE_NULL,                                                // const void*                                  pNext;
92                                                                                                                         0u,                                                             // deUint32                                             waitSemaphoreCount;
93                                                                                                                         DE_NULL,                                                // const VkSemaphore*                   pWaitSemaphores;
94                                                                                                                         DE_NULL,                                                // const VkPipelineStageFlags*  pWaitDstStageMask;
95                                                                                                                         1u,                                                             // deUint32                                             commandBufferCount;
96                                                                                                                         &cmdBuffer.get(),                               // const VkCommandBuffer*               pCommandBuffers;
97                                                                                                                         0u,                                                             // deUint32                                             signalSemaphoreCount;
98                                                                                                                         DE_NULL,                                                // const VkSemaphore*                   pSignalSemaphores;
99                                                                                                                 };
100         const VkEventCreateInfo                 eventInfo                       =
101                                                                                                                 {
102                                                                                                                         VK_STRUCTURE_TYPE_EVENT_CREATE_INFO,
103                                                                                                                         DE_NULL,
104                                                                                                                         0
105                                                                                                                 };
106         const Unique<VkEvent>                   event                           (createEvent(vk, device, &eventInfo, DE_NULL));
107
108         beginCommandBuffer(vk, *cmdBuffer);
109         vk.cmdSetEvent(*cmdBuffer, *event, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT);
110         endCommandBuffer(vk, *cmdBuffer);
111
112         VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, DE_NULL));
113         VK_CHECK(vk.queueWaitIdle(queue));
114
115         if (VK_EVENT_SET != vk.getEventStatus(device, *event))
116                 return tcu::TestStatus::fail("Event should be in signaled state after set");
117
118         beginCommandBuffer(vk, *cmdBuffer);
119         vk.cmdResetEvent(*cmdBuffer, *event, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT);
120         endCommandBuffer(vk, *cmdBuffer);
121
122         VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, DE_NULL));
123         VK_CHECK(vk.queueWaitIdle(queue));
124
125         if (VK_EVENT_RESET != vk.getEventStatus(device, *event))
126                 return tcu::TestStatus::fail("Event should be in unsignaled state after set");
127
128         return tcu::TestStatus::pass("Device set and reset event tests pass");
129 }
130
131 tcu::TestStatus deviceWaitForEventCase (Context& context)
132 {
133         const DeviceInterface&                  vk                                      = context.getDeviceInterface();
134         const VkDevice                                  device                          = context.getDevice();
135         const VkQueue                                   queue                           = context.getUniversalQueue();
136         const deUint32                                  queueFamilyIndex        = context.getUniversalQueueFamilyIndex();
137         const VkFenceCreateInfo                 fenceInfo                       =
138                                                                                                                 {
139                                                                                                                         VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, // VkStructureType         sType;
140                                                                                                                         DE_NULL,                                                         // const void*                 pNext;
141                                                                                                                         0u,                                                                      // VkFenceCreateFlags  flags;
142                                                                                                                 };
143         const Unique<VkFence>                   fence                           (createFence(vk, device, &fenceInfo));
144         const Unique<VkCommandPool>             cmdPool                         (makeCommandPool(vk, device, queueFamilyIndex));
145         const Unique<VkCommandBuffer>   cmdBuffer                       (makeCommandBuffer(vk, device, *cmdPool));
146         const VkSubmitInfo                              submitInfo                      =
147                                                                                                                 {
148                                                                                                                         VK_STRUCTURE_TYPE_SUBMIT_INFO,  // VkStructureType                              sType;
149                                                                                                                         DE_NULL,                                                // const void*                                  pNext;
150                                                                                                                         0u,                                                             // deUint32                                             waitSemaphoreCount;
151                                                                                                                         DE_NULL,                                                // const VkSemaphore*                   pWaitSemaphores;
152                                                                                                                         DE_NULL,                                                // const VkPipelineStageFlags*  pWaitDstStageMask;
153                                                                                                                         1u,                                                             // deUint32                                             commandBufferCount;
154                                                                                                                         &cmdBuffer.get(),                               // const VkCommandBuffer*               pCommandBuffers;
155                                                                                                                         0u,                                                             // deUint32                                             signalSemaphoreCount;
156                                                                                                                         DE_NULL,                                                // const VkSemaphore*                   pSignalSemaphores;
157                                                                                                                 };
158         const VkEventCreateInfo                 eventInfo                       =
159                                                                                                                 {
160                                                                                                                         VK_STRUCTURE_TYPE_EVENT_CREATE_INFO,
161                                                                                                                         DE_NULL,
162                                                                                                                         0
163                                                                                                                 };
164         const Unique<VkEvent>                   event                           (createEvent(vk, device, &eventInfo, DE_NULL));
165
166         beginCommandBuffer(vk, *cmdBuffer);
167         vk.cmdWaitEvents(*cmdBuffer, 1u, &event.get(), VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0u, DE_NULL, 0u, DE_NULL, 0u, DE_NULL);
168         endCommandBuffer(vk, *cmdBuffer);
169
170         VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, *fence));
171         if (VK_TIMEOUT != vk.waitForFences(device, 1u, &fence.get(), DE_TRUE, SHORT_FENCE_WAIT))
172                 return tcu::TestStatus::fail("Queue should not end execution");
173
174         if (VK_SUCCESS != vk.setEvent(device, *event))
175                 return tcu::TestStatus::fail("Couldn't set event");
176
177         if (VK_SUCCESS != vk.waitForFences(device, 1u, &fence.get(), DE_TRUE, LONG_FENCE_WAIT))
178                 return tcu::TestStatus::fail("Queue should end execution");
179
180         return tcu::TestStatus::pass("Device wait for event tests pass");
181 }
182
183 tcu::TestStatus singleSubmissionCase (Context& context)
184 {
185         enum {SET=0, WAIT, COUNT};
186         const DeviceInterface&                  vk                                      = context.getDeviceInterface();
187         const VkDevice                                  device                          = context.getDevice();
188         const VkQueue                                   queue                           = context.getUniversalQueue();
189         const deUint32                                  queueFamilyIndex        = context.getUniversalQueueFamilyIndex();
190         const VkFenceCreateInfo                 fenceInfo                       =
191                                                                                                                 {
192                                                                                                                         VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, // VkStructureType         sType;
193                                                                                                                         DE_NULL,                                                         // const void*                 pNext;
194                                                                                                                         0u,                                                                      // VkFenceCreateFlags  flags;
195                                                                                                                 };
196         const Unique<VkFence>                   fence                           (createFence(vk, device, &fenceInfo));
197         const Unique<VkCommandPool>             cmdPool                         (makeCommandPool(vk, device, queueFamilyIndex));
198         const Move<VkCommandBuffer>             ptrCmdBuffer[COUNT]     = {makeCommandBuffer(vk, device, *cmdPool), makeCommandBuffer(vk, device, *cmdPool)};
199         VkCommandBuffer                                 cmdBuffers[COUNT]       = {*ptrCmdBuffer[SET], *ptrCmdBuffer[WAIT]};
200         const VkSubmitInfo                              submitInfo                      =
201                                                                                                                 {
202                                                                                                                         VK_STRUCTURE_TYPE_SUBMIT_INFO,  // VkStructureType                              sType;
203                                                                                                                         DE_NULL,                                                // const void*                                  pNext;
204                                                                                                                         0u,                                                             // deUint32                                             waitSemaphoreCount;
205                                                                                                                         DE_NULL,                                                // const VkSemaphore*                   pWaitSemaphores;
206                                                                                                                         DE_NULL,                                                // const VkPipelineStageFlags*  pWaitDstStageMask;
207                                                                                                                         2u,                                                             // deUint32                                             commandBufferCount;
208                                                                                                                         cmdBuffers,                                             // const VkCommandBuffer*               pCommandBuffers;
209                                                                                                                         0u,                                                             // deUint32                                             signalSemaphoreCount;
210                                                                                                                         DE_NULL,                                                // const VkSemaphore*                   pSignalSemaphores;
211                                                                                                                 };
212         const VkEventCreateInfo                 eventInfo                       =
213                                                                                                                 {
214                                                                                                                         VK_STRUCTURE_TYPE_EVENT_CREATE_INFO,
215                                                                                                                         DE_NULL,
216                                                                                                                         0
217                                                                                                                 };
218         const Unique<VkEvent>                   event                           (createEvent(vk, device, &eventInfo, DE_NULL));
219
220         beginCommandBuffer(vk, cmdBuffers[SET]);
221         vk.cmdSetEvent(cmdBuffers[SET], *event, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT);
222         endCommandBuffer(vk, cmdBuffers[SET]);
223
224         beginCommandBuffer(vk, cmdBuffers[WAIT]);
225         vk.cmdWaitEvents(cmdBuffers[WAIT], 1u, &event.get(),VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0u, DE_NULL, 0u, DE_NULL, 0u, DE_NULL);
226         endCommandBuffer(vk, cmdBuffers[WAIT]);
227
228         VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, *fence));
229         if (VK_SUCCESS != vk.waitForFences(device, 1u, &fence.get(), DE_TRUE, LONG_FENCE_WAIT))
230                 return tcu::TestStatus::fail("Queue should end execution");
231
232         return tcu::TestStatus::pass("Wait and set even on device single submission tests pass");
233 }
234
235 tcu::TestStatus multiSubmissionCase (Context& context)
236 {
237         enum {SET=0, WAIT, COUNT};
238         const DeviceInterface&                  vk                                      = context.getDeviceInterface();
239         const VkDevice                                  device                          = context.getDevice();
240         const VkQueue                                   queue                           = context.getUniversalQueue();
241         const deUint32                                  queueFamilyIndex        = context.getUniversalQueueFamilyIndex();
242         const VkFenceCreateInfo                 fenceInfo                       =
243                                                                                                                 {
244                                                                                                                         VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, // VkStructureType         sType;
245                                                                                                                         DE_NULL,                                                         // const void*                 pNext;
246                                                                                                                         0u,                                                                      // VkFenceCreateFlags  flags;
247                                                                                                                 };
248         const Move<VkFence>                             ptrFence[COUNT]         = {createFence(vk, device, &fenceInfo), createFence(vk, device, &fenceInfo)};
249         VkFence                                                 fence[COUNT]            = {*ptrFence[SET], *ptrFence[WAIT]};
250         const Unique<VkCommandPool>             cmdPool                         (makeCommandPool(vk, device, queueFamilyIndex));
251         const Move<VkCommandBuffer>             ptrCmdBuffer[COUNT]     = {makeCommandBuffer(vk, device, *cmdPool), makeCommandBuffer(vk, device, *cmdPool)};
252         VkCommandBuffer                                 cmdBuffers[COUNT]       = {*ptrCmdBuffer[SET], *ptrCmdBuffer[WAIT]};
253         const VkSubmitInfo                              submitInfo[COUNT]       =
254                                                                                                                 {
255                                                                                                                         {
256                                                                                                                                 VK_STRUCTURE_TYPE_SUBMIT_INFO,  // VkStructureType                              sType;
257                                                                                                                                 DE_NULL,                                                // const void*                                  pNext;
258                                                                                                                                 0u,                                                             // deUint32                                             waitSemaphoreCount;
259                                                                                                                                 DE_NULL,                                                // const VkSemaphore*                   pWaitSemaphores;
260                                                                                                                                 DE_NULL,                                                // const VkPipelineStageFlags*  pWaitDstStageMask;
261                                                                                                                                 1u,                                                             // deUint32                                             commandBufferCount;
262                                                                                                                                 &cmdBuffers[SET],                               // const VkCommandBuffer*               pCommandBuffers;
263                                                                                                                                 0u,                                                             // deUint32                                             signalSemaphoreCount;
264                                                                                                                                 DE_NULL,                                                // const VkSemaphore*                   pSignalSemaphores;
265                                                                                                                         },
266                                                                                                                         {
267                                                                                                                                 VK_STRUCTURE_TYPE_SUBMIT_INFO,  // VkStructureType                              sType;
268                                                                                                                                 DE_NULL,                                                // const void*                                  pNext;
269                                                                                                                                 0u,                                                             // deUint32                                             waitSemaphoreCount;
270                                                                                                                                 DE_NULL,                                                // const VkSemaphore*                   pWaitSemaphores;
271                                                                                                                                 DE_NULL,                                                // const VkPipelineStageFlags*  pWaitDstStageMask;
272                                                                                                                                 1u,                                                             // deUint32                                             commandBufferCount;
273                                                                                                                                 &cmdBuffers[WAIT],                              // const VkCommandBuffer*               pCommandBuffers;
274                                                                                                                                 0u,                                                             // deUint32                                             signalSemaphoreCount;
275                                                                                                                                 DE_NULL,                                                // const VkSemaphore*                   pSignalSemaphores;
276                                                                                                                         }
277                                                                                                                 };
278         const VkEventCreateInfo                 eventInfo                       =
279                                                                                                                 {
280                                                                                                                         VK_STRUCTURE_TYPE_EVENT_CREATE_INFO,
281                                                                                                                         DE_NULL,
282                                                                                                                         0
283                                                                                                                 };
284         const Unique<VkEvent>                   event                           (createEvent(vk, device, &eventInfo, DE_NULL));
285
286         beginCommandBuffer(vk, cmdBuffers[SET]);
287         vk.cmdSetEvent(cmdBuffers[SET], *event, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT);
288         endCommandBuffer(vk, cmdBuffers[SET]);
289
290         beginCommandBuffer(vk, cmdBuffers[WAIT]);
291         vk.cmdWaitEvents(cmdBuffers[WAIT], 1u, &event.get(), VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0u, DE_NULL, 0u, DE_NULL, 0u, DE_NULL);
292         endCommandBuffer(vk, cmdBuffers[WAIT]);
293
294         VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo[SET], fence[SET]));
295         VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo[WAIT], fence[WAIT]));
296
297         if (VK_SUCCESS != vk.waitForFences(device, 2u, fence, DE_TRUE, LONG_FENCE_WAIT))
298                 return tcu::TestStatus::fail("Queue should end execution");
299
300         return tcu::TestStatus::pass("Wait and set even on device multi submission tests pass");
301 }
302
303 tcu::TestStatus secondaryCommandBufferCase (Context& context)
304 {
305         enum {SET=0, WAIT, COUNT};
306         const DeviceInterface&                                  vk                                              = context.getDeviceInterface();
307         const VkDevice                                                  device                                  = context.getDevice();
308         const VkQueue                                                   queue                                   = context.getUniversalQueue();
309         const deUint32                                                  queueFamilyIndex                = context.getUniversalQueueFamilyIndex();
310         const VkFenceCreateInfo                                 fenceInfo                               =
311                                                                                                                                         {
312                                                                                                                                                 VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, // VkStructureType         sType;
313                                                                                                                                                 DE_NULL,                                                         // const void*                 pNext;
314                                                                                                                                                 0u,                                                                      // VkFenceCreateFlags  flags;
315                                                                                                                                         };
316         const Unique<VkFence>                                   fence                                   (createFence(vk, device, &fenceInfo));
317         const Unique<VkCommandPool>                             cmdPool                                 (makeCommandPool(vk, device, queueFamilyIndex));
318         const Move<VkCommandBuffer>                             primaryCmdBuffer                (makeCommandBuffer(vk, device, *cmdPool));
319         const VkCommandBufferAllocateInfo               cmdBufferInfo                   =
320                                                                                                                                         {
321                                                                                                                                                 VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,         // VkStructureType              sType;
322                                                                                                                                                 DE_NULL,                                                                                        // const void*                  pNext;
323                                                                                                                                                 *cmdPool,                                                                                       // VkCommandPool                commandPool;
324                                                                                                                                                 VK_COMMAND_BUFFER_LEVEL_SECONDARY,                                      // VkCommandBufferLevel level;
325                                                                                                                                                 1u,                                                                                                     // deUint32                             commandBufferCount;
326                                                                                                                                         };
327         const Move<VkCommandBuffer>                             prtCmdBuffers[COUNT]    = {allocateCommandBuffer (vk, device, &cmdBufferInfo), allocateCommandBuffer (vk, device, &cmdBufferInfo)};
328         VkCommandBuffer                                                 secondaryCmdBuffers[]   = {*prtCmdBuffers[SET], *prtCmdBuffers[WAIT]};
329         const VkSubmitInfo                                              submitInfo                              =
330                                                                                                                                         {
331                                                                                                                                                 VK_STRUCTURE_TYPE_SUBMIT_INFO,  // VkStructureType                              sType;
332                                                                                                                                                 DE_NULL,                                                // const void*                                  pNext;
333                                                                                                                                                 0u,                                                             // deUint32                                             waitSemaphoreCount;
334                                                                                                                                                 DE_NULL,                                                // const VkSemaphore*                   pWaitSemaphores;
335                                                                                                                                                 DE_NULL,                                                // const VkPipelineStageFlags*  pWaitDstStageMask;
336                                                                                                                                                 1u,                                                             // deUint32                                             commandBufferCount;
337                                                                                                                                                 &primaryCmdBuffer.get(),                // const VkCommandBuffer*               pCommandBuffers;
338                                                                                                                                                 0u,                                                             // deUint32                                             signalSemaphoreCount;
339                                                                                                                                                 DE_NULL,                                                // const VkSemaphore*                   pSignalSemaphores;
340                                                                                                                                         };
341         const VkEventCreateInfo                                 eventInfo                               =
342                                                                                                                                         {
343                                                                                                                                                 VK_STRUCTURE_TYPE_EVENT_CREATE_INFO,
344                                                                                                                                                 DE_NULL,
345                                                                                                                                                 0
346                                                                                                                                         };
347         const Unique<VkEvent>                                   event                                   (createEvent(vk, device, &eventInfo, DE_NULL));
348
349         const VkCommandBufferInheritanceInfo    secCmdBufInheritInfo    =
350                                                                                                                                         {
351                                                                                                                                                 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO,      //VkStructureType                                       sType;
352                                                                                                                                                 DE_NULL,                                                                                        //const void*                                           pNext;
353                                                                                                                                                 DE_NULL,                                                                                        //VkRenderPass                                  renderPass;
354                                                                                                                                                 0u,                                                                                                     //deUint32                                              subpass;
355                                                                                                                                                 DE_NULL,                                                                                        //VkFramebuffer                                 framebuffer;
356                                                                                                                                                 VK_FALSE,                                                                                       //VkBool32                                              occlusionQueryEnable;
357                                                                                                                                                 (VkQueryControlFlags)0u,                                                        //VkQueryControlFlags                           queryFlags;
358                                                                                                                                                 (VkQueryPipelineStatisticFlags)0u,                                      //VkQueryPipelineStatisticFlags pipelineStatistics;
359                                                                                                                                         };
360         const VkCommandBufferBeginInfo                  cmdBufferBeginInfo              =
361                                                                                                                                         {
362                                                                                                                                                 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,    // VkStructureType                          sType;
363                                                                                                                                                 DE_NULL,                                                                                // const void*                              pNext;
364                                                                                                                                                 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,    // VkCommandBufferUsageFlags                flags;
365                                                                                                                                                 &secCmdBufInheritInfo,                                                  // const VkCommandBufferInheritanceInfo*    pInheritanceInfo;
366                                                                                                                                         };
367
368         VK_CHECK(vk.beginCommandBuffer(secondaryCmdBuffers[SET], &cmdBufferBeginInfo));
369         vk.cmdSetEvent(secondaryCmdBuffers[SET], *event, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT);
370         endCommandBuffer(vk, secondaryCmdBuffers[SET]);
371
372         VK_CHECK(vk.beginCommandBuffer(secondaryCmdBuffers[WAIT], &cmdBufferBeginInfo));
373         vk.cmdWaitEvents(secondaryCmdBuffers[WAIT], 1u, &event.get(),VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0u, DE_NULL, 0u, DE_NULL, 0u, DE_NULL);
374         endCommandBuffer(vk, secondaryCmdBuffers[WAIT]);
375
376         beginCommandBuffer(vk, *primaryCmdBuffer);
377         vk.cmdExecuteCommands(*primaryCmdBuffer, 2u, secondaryCmdBuffers);
378         endCommandBuffer(vk, *primaryCmdBuffer);
379
380         VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, *fence));
381         if (VK_SUCCESS != vk.waitForFences(device, 1u, &fence.get(), DE_TRUE, LONG_FENCE_WAIT))
382                 return tcu::TestStatus::fail("Queue should end execution");
383
384         return tcu::TestStatus::pass("Wait and set even on device using secondary command buffers tests pass");
385 }
386
387 } // anonymous
388
389 tcu::TestCaseGroup* createBasicEventTests (tcu::TestContext& testCtx)
390 {
391         de::MovePtr<tcu::TestCaseGroup> basicTests(new tcu::TestCaseGroup(testCtx, "event", "Basic event tests"));
392         addFunctionCase(basicTests.get(), "host_set_reset",   "Basic event tests set and reset on host", hostResetSetEventCase);
393         addFunctionCase(basicTests.get(), "device_set_reset", "Basic event tests set and reset on device", deviceResetSetEventCase);
394         addFunctionCase(basicTests.get(), "host_set_device_wait", "Wait for event on device test", deviceWaitForEventCase);
395         addFunctionCase(basicTests.get(), "single_submit_multi_command_buffer", "Wait and set event single submission on device", singleSubmissionCase);
396         addFunctionCase(basicTests.get(), "multi_submit_multi_command_buffer", "Wait and set event mutli submission on device", multiSubmissionCase);
397         addFunctionCase(basicTests.get(), "multi_secondary_command_buffer", "Event used on secondary command buffer ", secondaryCommandBufferCase);
398
399         return basicTests.release();
400 }
401
402 } // synchronization
403 } // vkt