-tcu::TestStatus testEvents (Context& context)
-{
- TestLog& log = context.getTestContext().getLog();
- const DeviceInterface& deviceInterface = context.getDeviceInterface();
- VkDevice device = context.getDevice();
- const deUint32 queueFamilyIdx = context.getUniversalQueueFamilyIndex();
- Allocator& allocator = context.getDefaultAllocator();
- VkQueue queue = context.getUniversalQueue();
- VkResult testStatus;
- VkResult eventStatus;
- TestContext testContext (deviceInterface, device, queueFamilyIdx, context.getBinaryCollection(), allocator);
- Unique<VkEvent> event (createEvent(deviceInterface, device));
- VkSubmitInfo submitInfo;
- void* resultImage;
-
- const tcu::Vec4 vertices1[] =
- {
- tcu::Vec4( 0.5f, 0.5f, 0.0f, 1.0f),
- tcu::Vec4(-0.5f, 0.5f, 0.0f, 1.0f),
- tcu::Vec4( 0.0f, -0.5f, 0.0f, 1.0f)
- };
-
- testContext.vertices = vertices1;
- testContext.numVertices = DE_LENGTH_OF_ARRAY(vertices1);
- testContext.renderDimension = tcu::IVec2(256, 256);
- testContext.waitEvent = true;
- testContext.event = event.get();
- testContext.renderSize = sizeof(deUint32) * testContext.renderDimension.x() * testContext.renderDimension.y();
-
- createCommandBuffer(deviceInterface, device, queueFamilyIdx, &testContext.cmdBuffer, &testContext.commandPool);
- generateWork(testContext);
-
- initSubmitInfo(&submitInfo, 1);
- submitInfo.pCommandBuffers = &testContext.cmdBuffer.get();
-
- // 6.3 An event is initially in the unsignaled state
- eventStatus = deviceInterface.getEventStatus(device, event.get());
- if (eventStatus != VK_EVENT_RESET)
- {
- log << TestLog::Message << "testSynchronizationPrimitives event should be reset but status is " << getResultName(eventStatus) << TestLog::EndMessage;
- return tcu::TestStatus::fail("Event in incorrect status");
- }
-
- // The recorded command buffer should wait at the top of the graphics pipe for an event signaled by the host and so should not
- // make forward progress as long as the event is not signaled
- VK_CHECK(deviceInterface.queueSubmit(queue, 1, &submitInfo, testContext.fences[0]));
-
- testStatus = deviceInterface.waitForFences(device, 1, &testContext.fences[0], true, 10000000);
- if (testStatus != VK_TIMEOUT)
- {
- log << TestLog::Message << "testSynchronizationPrimitives failed to wait for set event from host." << TestLog::EndMessage;
- return tcu::TestStatus::fail("failed to wait for event set from host");
- }
-
- // Should allow the recorded command buffer to finally make progress
- VK_CHECK(deviceInterface.setEvent(device, event.get()));
- eventStatus = deviceInterface.getEventStatus(device, event.get());
- if (eventStatus != VK_EVENT_SET)
- {
- log << TestLog::Message << "testEvents failed to transition event to signaled state via setEvent call from host" << TestLog::EndMessage;
- return tcu::TestStatus::fail("failed to signal event from host");
- }
-
- testStatus = deviceInterface.waitForFences(device, 1, &testContext.fences[0], true, ~(0ull));
- if (testStatus != VK_SUCCESS)
- {
- log << TestLog::Message << "testSynchronizationPrimitives failed to proceed after set event from host." << TestLog::EndMessage;
- return tcu::TestStatus::fail("failed to proceed after event set from host");
- }
-
- invalidateAlloc(deviceInterface, device, *testContext.renderReadBuffer);
- resultImage = testContext.renderReadBuffer->getHostPtr();
-
- log << TestLog::Image( "result",
- "result",
- tcu::ConstPixelBufferAccess(tcu::TextureFormat(
- tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8),
- testContext.renderDimension.x(),
- testContext.renderDimension.y(),
- 1,
- resultImage));
-
- return tcu::TestStatus::pass("synchronization-events passed");
-}
-