: vkt::TestInstance (context)
, m_imageBackingMode (IMAGE_BACKING_MODE_REGULAR)
, m_quadGridSize (static_cast<deUint32>(GRID_SIZE_DEFAULT_FRAGMENT))
- , m_sparseContext (createSparseContext())
, m_memAlloc (getAllocator())
, m_clearColor (DEFAULT_CLEAR_COLOR)
, m_isVertexCase (false)
? static_cast<deUint32>(GRID_SIZE_DEFAULT_VERTEX)
: static_cast<deUint32>(GRID_SIZE_DEFAULT_FRAGMENT))
: gridSize)
- , m_sparseContext (createSparseContext())
, m_memAlloc (getAllocator())
, m_clearColor (DEFAULT_CLEAR_COLOR)
, m_isVertexCase (isVertexCase)
? static_cast<deUint32>(GRID_SIZE_DEFAULT_VERTEX)
: static_cast<deUint32>(GRID_SIZE_DEFAULT_FRAGMENT))
: gridSize)
- , m_sparseContext (createSparseContext())
, m_memAlloc (getAllocator())
, m_clearColor (DEFAULT_CLEAR_COLOR)
, m_isVertexCase (isVertexCase)
{
}
-static deUint32 findQueueFamilyIndexWithCaps (const InstanceInterface& vkInstance, VkPhysicalDevice physicalDevice, VkQueueFlags requiredCaps)
-{
- const std::vector<VkQueueFamilyProperties> queueProps = getPhysicalDeviceQueueFamilyProperties(vkInstance, physicalDevice);
-
- for (size_t queueNdx = 0; queueNdx < queueProps.size(); queueNdx++)
- {
- if ((queueProps[queueNdx].queueFlags & requiredCaps) == requiredCaps)
- return (deUint32)queueNdx;
- }
-
- TCU_THROW(NotSupportedError, "No matching queue found");
-}
-
-
-ShaderRenderCaseInstance::SparseContext::SparseContext (vkt::Context& context)
- : m_context (context)
- , m_queueFamilyIndex (findQueueFamilyIndexWithCaps(context.getInstanceInterface(), context.getPhysicalDevice(), VK_QUEUE_GRAPHICS_BIT|VK_QUEUE_SPARSE_BINDING_BIT))
- , m_device (createDevice())
- , m_deviceInterface (context.getInstanceInterface(), *m_device)
- , m_queue (getDeviceQueue(m_deviceInterface, *m_device, m_queueFamilyIndex, 0))
- , m_allocator (createAllocator())
-{
-}
-
-Move<VkDevice> ShaderRenderCaseInstance::SparseContext::createDevice () const
-{
- const InstanceInterface& vk = m_context.getInstanceInterface();
- const VkPhysicalDevice physicalDevice = m_context.getPhysicalDevice();
- const VkPhysicalDeviceFeatures deviceFeatures = getPhysicalDeviceFeatures(vk, physicalDevice);
-
- VkDeviceQueueCreateInfo queueInfo;
- VkDeviceCreateInfo deviceInfo;
- const float queuePriority = 1.0f;
-
- deMemset(&queueInfo, 0, sizeof(queueInfo));
- deMemset(&deviceInfo, 0, sizeof(deviceInfo));
-
- queueInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
- queueInfo.pNext = DE_NULL;
- queueInfo.flags = (VkDeviceQueueCreateFlags)0u;
- queueInfo.queueFamilyIndex = m_queueFamilyIndex;
- queueInfo.queueCount = 1u;
- queueInfo.pQueuePriorities = &queuePriority;
-
- deviceInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
- deviceInfo.pNext = DE_NULL;
- deviceInfo.queueCreateInfoCount = 1u;
- deviceInfo.pQueueCreateInfos = &queueInfo;
- deviceInfo.enabledExtensionCount = 0u;
- deviceInfo.ppEnabledExtensionNames = DE_NULL;
- deviceInfo.enabledLayerCount = 0u;
- deviceInfo.ppEnabledLayerNames = DE_NULL;
- deviceInfo.pEnabledFeatures = &deviceFeatures;
-
- return vk::createDevice(vk, physicalDevice, &deviceInfo);
-}
-
-vk::Allocator* ShaderRenderCaseInstance::SparseContext::createAllocator () const
-{
- const VkPhysicalDeviceMemoryProperties memoryProperties = getPhysicalDeviceMemoryProperties(m_context.getInstanceInterface(), m_context.getPhysicalDevice());
- return new SimpleAllocator(m_deviceInterface, *m_device, memoryProperties);
-}
-
-ShaderRenderCaseInstance::SparseContext* ShaderRenderCaseInstance::createSparseContext (void) const
-{
- if (m_imageBackingMode == IMAGE_BACKING_MODE_SPARSE)
- {
- return new SparseContext(m_context);
- }
-
- return DE_NULL;
-}
-
vk::Allocator& ShaderRenderCaseInstance::getAllocator (void) const
{
- if (m_imageBackingMode == IMAGE_BACKING_MODE_SPARSE)
- {
- return *m_sparseContext->m_allocator;
- }
-
return m_context.getDefaultAllocator();
}
VkDevice ShaderRenderCaseInstance::getDevice (void) const
{
- if (m_imageBackingMode == IMAGE_BACKING_MODE_SPARSE)
- return *m_sparseContext->m_device;
-
return m_context.getDevice();
}
deUint32 ShaderRenderCaseInstance::getUniversalQueueFamilyIndex (void) const
{
- if (m_imageBackingMode == IMAGE_BACKING_MODE_SPARSE)
- return m_sparseContext->m_queueFamilyIndex;
-
return m_context.getUniversalQueueFamilyIndex();
}
-const DeviceInterface& ShaderRenderCaseInstance::getDeviceInterface (void) const
+deUint32 ShaderRenderCaseInstance::getSparseQueueFamilyIndex (void) const
{
- if (m_imageBackingMode == IMAGE_BACKING_MODE_SPARSE)
- return m_sparseContext->m_deviceInterface;
+ return m_context.getSparseQueueFamilyIndex();
+}
+const DeviceInterface& ShaderRenderCaseInstance::getDeviceInterface (void) const
+{
return m_context.getDeviceInterface();
}
VkQueue ShaderRenderCaseInstance::getUniversalQueue (void) const
{
- if (m_imageBackingMode == IMAGE_BACKING_MODE_SPARSE)
- return m_sparseContext->m_queue;
-
return m_context.getUniversalQueue();
}
+VkQueue ShaderRenderCaseInstance::getSparseQueue (void) const
+{
+ return m_context.getSparseQueue();
+}
+
VkPhysicalDevice ShaderRenderCaseInstance::getPhysicalDevice (void) const
{
- // Same in sparse and regular case
return m_context.getPhysicalDevice();
}
const InstanceInterface& ShaderRenderCaseInstance::getInstanceInterface (void) const
{
- // Same in sparse and regular case
return m_context.getInstanceInterface();
}
const DeviceInterface& vk = getDeviceInterface();
const VkPhysicalDevice physicalDevice = getPhysicalDevice();
const VkQueue queue = getUniversalQueue();
+ const VkQueue sparseQueue = getSparseQueue();
const deUint32 queueFamilyIndex = getUniversalQueueFamilyIndex();
const InstanceInterface& instance = getInstanceInterface();
const VkPhysicalDeviceProperties deviceProperties = getPhysicalDeviceProperties(instance, physicalDevice);
bindSparseInfo.pImageOpaqueBinds = &imageMipTailBindInfo;
}
- VK_CHECK(vk.queueBindSparse(queue, 1u, &bindSparseInfo, DE_NULL));
+ VK_CHECK(vk.queueBindSparse(sparseQueue, 1u, &bindSparseInfo, DE_NULL));
}
Move<VkCommandPool> cmdPool;
{
VK_CHECK(vk.queueSubmit(queue, 1, &submitInfo, *fence));
VK_CHECK(vk.waitForFences(vkDevice, 1, &fence.get(), true, ~(0ull) /* infinity */));
+ VK_CHECK(vk.queueWaitIdle(sparseQueue));
}
catch (...)
{
const VkDevice vkDevice = getDevice();
const DeviceInterface& vk = getDeviceInterface();
const deUint32 queueFamilyIndex = getUniversalQueueFamilyIndex();
+ const deUint32 sparseFamilyIndex = (m_imageBackingMode == IMAGE_BACKING_MODE_SPARSE) ? getSparseQueueFamilyIndex() : queueFamilyIndex;
const bool isShadowSampler = refSampler.compare != tcu::Sampler::COMPAREMODE_NONE;
const VkImageAspectFlags aspectMask = isShadowSampler ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT;
const VkImageViewType imageViewType = textureTypeToImageViewType(textureType);
const VkImageType imageType = viewTypeToImageType(imageViewType);
+ const VkSharingMode sharingMode = (queueFamilyIndex != sparseFamilyIndex) ? VK_SHARING_MODE_CONCURRENT : VK_SHARING_MODE_EXCLUSIVE;
const VkFormat format = mapTextureFormat(texFormat);
const bool isCube = imageViewType == VK_IMAGE_VIEW_TYPE_CUBE || imageViewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY;
+
+ const deUint32 queueIndexCount = (queueFamilyIndex != sparseFamilyIndex) ? 2 : 1;
+ const deUint32 queueIndices[] =
+ {
+ queueFamilyIndex,
+ sparseFamilyIndex
+ };
+
VkImageCreateFlags imageCreateFlags = isCube ? (VkImageCreateFlags)VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT : (VkImageCreateFlags)0;
VkImageUsageFlags imageUsageFlags = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
Move<VkImage> vkTexture;
textureParams.samples, // VkSampleCountFlagBits samples;
VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
imageUsageFlags, // VkImageUsageFlags usage;
- VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
- 1u, // deUint32 queueFamilyIndexCount;
- &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
+ sharingMode, // VkSharingMode sharingMode;
+ queueIndexCount, // deUint32 queueFamilyIndexCount;
+ queueIndices, // const deUint32* pQueueFamilyIndices;
VK_IMAGE_LAYOUT_UNDEFINED // VkImageLayout initialLayout;
};