Various fixes for synchronization tests:
- Tests were not querying the available queueCount in the queue family properties.
- Tests were using the "universal" queue family index when the device created in createTestDevice() could be using queries belonging to a different family index.
- 3D image view was being used with a 2D image.
- Command buffer Deleter was not holding any reference to the command pool.
- Fences tests:
* Fence status VK_NOT_READY was expected between queueSubmit() and waitForFences(). Status could be VK_SUCCESS if the work finishes before waitForFences().
* It seems that the first waitForFences() was intended for multiple fences, but it was waiting for one of the fences only.
* Added check for default status of fence[1] (unsignaled).
- Code style:
* DE_NULL was being used as a boolean parameter in createFences()
* Use VkResult names instead of error codes in the error messages.
* Fixed some typos and indentation.
diff --git a/external/vulkancts/modules/vulkan/vktSynchronization.cpp b/external/vulkancts/modules/vulkan/vktSynchronization.cpp
index 695d17b..9d99d4a 100644
--- a/external/vulkancts/modules/vulkan/vktSynchronization.cpp
+++ b/external/vulkancts/modules/vulkan/vktSynchronization.cpp
@@ -88,22 +88,32 @@
"}\n");
}
-Move<VkDevice> createTestDevice (const InstanceInterface& vki, VkPhysicalDevice physicalDevice)
+Move<VkDevice> createTestDevice (const InstanceInterface& vki, VkPhysicalDevice physicalDevice, deUint32 *outQueueFamilyIndex)
{
VkDeviceQueueCreateInfo queueInfo;
VkDeviceCreateInfo deviceInfo;
size_t queueNdx;
const float queuePriority = 1.0f;
+ const deUint32 queueCount = 2u;
const vector<VkQueueFamilyProperties> queueProps = getPhysicalDeviceQueueFamilyProperties(vki, physicalDevice);
const VkPhysicalDeviceFeatures physicalDeviceFeatures = getPhysicalDeviceFeatures(vki, physicalDevice);
for (queueNdx = 0; queueNdx < queueProps.size(); queueNdx++)
{
- if ((queueProps[queueNdx].queueFlags & VK_QUEUE_GRAPHICS_BIT) == VK_QUEUE_GRAPHICS_BIT)
+ if ((queueProps[queueNdx].queueFlags & VK_QUEUE_GRAPHICS_BIT) == VK_QUEUE_GRAPHICS_BIT && (queueProps[queueNdx].queueCount >= queueCount))
break;
}
+ if (queueNdx >= queueProps.size())
+ {
+ // No queue family index found
+ std::ostringstream msg;
+ msg << "Cannot create device with " << queueCount << " graphics queues";
+
+ throw tcu::NotSupportedError(msg.str());
+ }
+
deMemset(&queueInfo, 0, sizeof(queueInfo));
deMemset(&deviceInfo, 0, sizeof(deviceInfo));
@@ -111,7 +121,7 @@
queueInfo.pNext = DE_NULL;
queueInfo.flags = (VkDeviceQueueCreateFlags)0u;
queueInfo.queueFamilyIndex = (deUint32)queueNdx;
- queueInfo.queueCount = 2u;
+ queueInfo.queueCount = queueCount;
queueInfo.pQueuePriorities = &queuePriority;
deviceInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
@@ -124,6 +134,8 @@
deviceInfo.ppEnabledLayerNames = DE_NULL;
deviceInfo.pEnabledFeatures = &physicalDeviceFeatures;
+ *outQueueFamilyIndex = queueInfo.queueFamilyIndex;
+
return createDevice(vki, physicalDevice, &deviceInfo);
};
@@ -321,7 +333,7 @@
imageViewCreateInfo.pNext = DE_NULL;
imageViewCreateInfo.flags = 0;
imageViewCreateInfo.image = image.image.get();
- imageViewCreateInfo.viewType = VK_IMAGE_VIEW_TYPE_3D;
+ imageViewCreateInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
imageViewCreateInfo.format = imageParameters.format;
imageViewCreateInfo.components = componentMap;
imageViewCreateInfo.subresourceRange = subresourceRange;
@@ -505,7 +517,7 @@
commandBufferInfo.commandBufferCount = 1;
VK_CHECK(deviceInterface.allocateCommandBuffers(device, &commandBufferInfo, &commandBuffer));
- *commandBufferRef = vk::Move<VkCommandBuffer>(vk::check<VkCommandBuffer>(commandBuffer), Deleter<VkCommandBuffer>(deviceInterface, device, DE_NULL));
+ *commandBufferRef = vk::Move<VkCommandBuffer>(vk::check<VkCommandBuffer>(commandBuffer), Deleter<VkCommandBuffer>(deviceInterface, device, commandPool));
}
void createFences (const DeviceInterface& deviceInterface, VkDevice device, bool signaled, deUint32 numFences, VkFence* fence)
@@ -670,7 +682,7 @@
, setEvent (DE_FALSE)
, waitEvent (DE_FALSE)
{
- createFences(context.getDeviceInterface(), device, DE_NULL, DE_LENGTH_OF_ARRAY(fences), fences);
+ createFences(context.getDeviceInterface(), device, false, DE_LENGTH_OF_ARRAY(fences), fences);
}
~TestContext()
@@ -986,7 +998,7 @@
bufferBarriers.resize(0);
imageBarriers.resize(0);
- transferInfo.context = &testContext.context;
+ transferInfo.context = &testContext.context;
transferInfo.commandBuffer = renderInfo.commandBuffer;
transferInfo.width = testContext.renderDimension.x();
transferInfo.height = testContext.renderDimension.y();
@@ -1034,14 +1046,12 @@
{
TestLog& log = context.getTestContext().getLog();
const DeviceInterface& deviceInterface = context.getDeviceInterface();
- const InstanceInterface& instanceInterface = context.getInstanceInterface();
- const VkPhysicalDevice physicalDevice = context.getPhysicalDevice();
const VkQueue queue = context.getUniversalQueue();
const deUint32 queueFamilyIdx = context.getUniversalQueueFamilyIndex();
- vk::Move<VkDevice> device = createTestDevice(instanceInterface, physicalDevice);
+ VkDevice device = context.getDevice();
VkResult testStatus;
VkResult fenceStatus;
- TestContext testContext(context, device.get());
+ TestContext testContext(context, device);
VkSubmitInfo submitInfo;
VkMappedMemoryRange range;
void* resultImage;
@@ -1058,29 +1068,38 @@
testContext.renderDimension = tcu::IVec2(256, 256);
testContext.renderSize = sizeof(deUint32) * testContext.renderDimension.x() * testContext.renderDimension.y();
- createCommandBuffer(testContext.context, device.get(), queueFamilyIdx, &testContext.cmdBuffer);
+ createCommandBuffer(testContext.context, device, queueFamilyIdx, &testContext.cmdBuffer);
generateWork(testContext);
initSubmitInfo(&submitInfo, 1);
submitInfo.pCommandBuffers = &testContext.cmdBuffer.get();
- VK_CHECK(deviceInterface.queueSubmit(queue, 1, &submitInfo, testContext.fences[0]));
-
- fenceStatus = deviceInterface.getFenceStatus(device.get(), testContext.fences[0]);
+ // Default status is unsignaled
+ fenceStatus = deviceInterface.getFenceStatus(device, testContext.fences[0]);
if (fenceStatus != VK_NOT_READY)
{
- log << TestLog::Message << "testSynchronizationPrimitives fence should be reset but status is " << fenceStatus << TestLog::EndMessage;
+ log << TestLog::Message << "testSynchronizationPrimitives fence 0 should be reset but status is " << getResultName(fenceStatus) << TestLog::EndMessage;
+ return tcu::TestStatus::fail("Fence in incorrect state");
+ }
+ fenceStatus = deviceInterface.getFenceStatus(device, testContext.fences[1]);
+ if (fenceStatus != VK_NOT_READY)
+ {
+ log << TestLog::Message << "testSynchronizationPrimitives fence 1 should be reset but status is " << getResultName(fenceStatus) << TestLog::EndMessage;
return tcu::TestStatus::fail("Fence in incorrect state");
}
- testStatus = deviceInterface.waitForFences(device.get(), 1, &testContext.fences[0], DE_TRUE, DEFAULT_TIMEOUT);
+ VK_CHECK(deviceInterface.queueSubmit(queue, 1, &submitInfo, testContext.fences[0]));
+
+ // Wait for both fences
+ testStatus = deviceInterface.waitForFences(device, 2, &testContext.fences[0], DE_TRUE, DEFAULT_TIMEOUT);
if (testStatus != VK_TIMEOUT)
{
log << TestLog::Message << "testSynchPrimitives failed to wait for all fences" << TestLog::EndMessage;
return tcu::TestStatus::fail("Failed to wait for mulitple fences");
}
- testStatus = deviceInterface.waitForFences(device.get(),
+ // Wait until timeout (no work has been submited to testContext.fences[1])
+ testStatus = deviceInterface.waitForFences(device,
1,
&testContext.fences[1],
DE_TRUE,
@@ -1092,17 +1111,20 @@
return tcu::TestStatus::fail("failed to wait for single fence");
}
- testStatus = deviceInterface.waitForFences(device.get(), 1, &testContext.fences[0], DE_TRUE, DEFAULT_TIMEOUT);
+ // Wait for testContext.fences[0], assuming that the work can be completed
+ // in the default time + the time given so far since the queueSubmit
+ testStatus = deviceInterface.waitForFences(device, 1, &testContext.fences[0], DE_TRUE, DEFAULT_TIMEOUT);
if (testStatus != VK_SUCCESS)
{
log << TestLog::Message << "testSynchPrimitives failed to wait for a set fence" << TestLog::EndMessage;
return tcu::TestStatus::fail("failed to wait for a set fence");
}
- fenceStatus = deviceInterface.getFenceStatus(device.get(), testContext.fences[0]);
+ // Check that the fence is signaled after the wait
+ fenceStatus = deviceInterface.getFenceStatus(device, testContext.fences[0]);
if (fenceStatus != VK_SUCCESS)
{
- log << TestLog::Message << "testSynchronizationPrimitives fence should be signaled but status is " << fenceStatus << TestLog::EndMessage;
+ log << TestLog::Message << "testSynchronizationPrimitives fence should be signaled but status is " << getResultName(fenceStatus) << TestLog::EndMessage;
return tcu::TestStatus::fail("Fence in incorrect state");
}
@@ -1111,7 +1133,7 @@
range.memory = testContext.renderReadBuffer->getMemory();
range.offset = 0;
range.size = testContext.renderSize;
- VK_CHECK(deviceInterface.invalidateMappedMemoryRanges(device.get(), 1, &range));
+ VK_CHECK(deviceInterface.invalidateMappedMemoryRanges(device, 1, &range));
resultImage = testContext.renderReadBuffer->getHostPtr();
log << TestLog::Image( "result",
@@ -1123,7 +1145,7 @@
1,
resultImage));
- return TestStatus::pass("synchornization-fences passed");
+ return TestStatus::pass("synchronization-fences passed");
}
vk::refdetails::Checked<VkSemaphore> createSemaphore (const DeviceInterface& deviceInterface, const VkDevice& device, const VkAllocationCallbacks* allocationCallbacks)
@@ -1145,9 +1167,9 @@
const DeviceInterface& deviceInterface = context.getDeviceInterface();
const InstanceInterface& instanceInterface = context.getInstanceInterface();
const VkPhysicalDevice physicalDevice = context.getPhysicalDevice();
- vk::Move<VkDevice> device = createTestDevice(instanceInterface, physicalDevice);
+ deUint32 queueFamilyIdx;
+ vk::Move<VkDevice> device = createTestDevice(instanceInterface, physicalDevice, &queueFamilyIdx);
VkQueue queue[2];
- const deUint32 queueFamilyIdx = context.getUniversalQueueFamilyIndex();
VkResult testStatus;
TestContext testContext1(context, device.get());
TestContext testContext2(context, device.get());
@@ -1173,15 +1195,15 @@
tcu::Vec4( 0.0f, +0.5f, 0.0f, 1.0f)
};
- testContext1.vertices = vertices1;
- testContext1.numVertices = DE_LENGTH_OF_ARRAY(vertices1);
- testContext1.renderDimension = tcu::IVec2(256, 256);
- testContext1.renderSize = sizeof(deUint32) * testContext1.renderDimension.x() * testContext1.renderDimension.y();
+ testContext1.vertices = vertices1;
+ testContext1.numVertices = DE_LENGTH_OF_ARRAY(vertices1);
+ testContext1.renderDimension = tcu::IVec2(256, 256);
+ testContext1.renderSize = sizeof(deUint32) * testContext1.renderDimension.x() * testContext1.renderDimension.y();
- testContext2.vertices = vertices2;
- testContext2.numVertices = DE_LENGTH_OF_ARRAY(vertices2);
- testContext2.renderDimension = tcu::IVec2(256, 256);
- testContext2.renderSize = sizeof(deUint32) * testContext2.renderDimension.x() * testContext2.renderDimension.y();
+ testContext2.vertices = vertices2;
+ testContext2.numVertices = DE_LENGTH_OF_ARRAY(vertices2);
+ testContext2.renderDimension = tcu::IVec2(256, 256);
+ testContext2.renderSize = sizeof(deUint32) * testContext2.renderDimension.x() * testContext2.renderDimension.y();
createCommandBuffer(testContext1.context, device.get(), queueFamilyIdx, &testContext1.cmdBuffer);
generateWork(testContext1);
@@ -1194,13 +1216,13 @@
// The difference between the two submit infos is that each will use a unique cmd buffer,
// and one will signal a semaphore but not wait on a semaphore, the other will wait on the
// semaphore but not signal a semaphore
- submitInfo[0].pCommandBuffers = &testContext1.cmdBuffer.get();
- submitInfo[1].pCommandBuffers = &testContext2.cmdBuffer.get();
+ submitInfo[0].pCommandBuffers = &testContext1.cmdBuffer.get();
+ submitInfo[1].pCommandBuffers = &testContext2.cmdBuffer.get();
- submitInfo[0].signalSemaphoreCount = 1;
- submitInfo[0].pSignalSemaphores = &semaphore.get();
- submitInfo[1].waitSemaphoreCount = 1;
- submitInfo[1].pWaitSemaphores = &semaphore.get();
+ submitInfo[0].signalSemaphoreCount = 1;
+ submitInfo[0].pSignalSemaphores = &semaphore.get();
+ submitInfo[1].waitSemaphoreCount = 1;
+ submitInfo[1].pWaitSemaphores = &semaphore.get();
VK_CHECK(deviceInterface.queueSubmit(queue[0], 1, &submitInfo[0], testContext1.fences[0]));
@@ -1276,9 +1298,9 @@
const DeviceInterface& deviceInterface = context.getDeviceInterface();
const InstanceInterface& instanceInterface = context.getInstanceInterface();
const VkPhysicalDevice physicalDevice = context.getPhysicalDevice();
- vk::Move<VkDevice> device = createTestDevice(instanceInterface, physicalDevice);
+ deUint32 queueFamilyIdx;
+ vk::Move<VkDevice> device = createTestDevice(instanceInterface, physicalDevice, &queueFamilyIdx);
VkQueue queue[2];
- const deUint32 queueFamilyIdx = context.getUniversalQueueFamilyIndex();
VkResult testStatus;
VkResult eventStatus;
TestContext testContext1(context, device.get());
@@ -1332,7 +1354,7 @@
eventStatus = deviceInterface.getEventStatus(device.get(), event.get());
if (eventStatus != VK_EVENT_RESET)
{
- log << TestLog::Message << "testSynchronizationPrimitives event should be reset but status is " << eventStatus << TestLog::EndMessage;
+ log << TestLog::Message << "testSynchronizationPrimitives event should be reset but status is " << getResultName(eventStatus) << TestLog::EndMessage;
return tcu::TestStatus::fail("Event in incorrect status");
}