include_directories(..)
-set(DEQP_VK_IMAGE_SRCS
+set(DEQP_VK_SPARSE_RESOURCES_SRCS
+ vktSparseResourcesBase.cpp
+ vktSparseResourcesBase.hpp
+ vktSparseResourcesBufferMemoryAliasing.cpp
+ vktSparseResourcesBufferMemoryAliasing.hpp
+ vktSparseResourcesBufferSparseBinding.cpp
+ vktSparseResourcesBufferSparseBinding.hpp
+ vktSparseResourcesBufferSparseResidency.cpp
+ vktSparseResourcesBufferSparseResidency.hpp
+ vktSparseResourcesImageMemoryAliasing.cpp
+ vktSparseResourcesImageMemoryAliasing.hpp
+ vktSparseResourcesImageSparseBinding.cpp
+ vktSparseResourcesImageSparseBinding.hpp
+ vktSparseResourcesImageSparseResidency.cpp
+ vktSparseResourcesImageSparseResidency.hpp
+ vktSparseResourcesMipmapSparseResidency.cpp
+ vktSparseResourcesMipmapSparseResidency.hpp
vktSparseResourcesShaderIntrinsics.cpp
vktSparseResourcesShaderIntrinsics.hpp
vktSparseResourcesShaderIntrinsicsBase.cpp
vktSparseResourcesShaderIntrinsicsSampled.hpp
vktSparseResourcesShaderIntrinsicsStorage.cpp
vktSparseResourcesShaderIntrinsicsStorage.hpp
- vktSparseResourcesImageMemoryAliasing.cpp
- vktSparseResourcesImageMemoryAliasing.hpp
- vktSparseResourcesBufferMemoryAliasing.cpp
- vktSparseResourcesBufferMemoryAliasing.hpp
- vktSparseResourcesMipmapSparseResidency.cpp
- vktSparseResourcesMipmapSparseResidency.hpp
- vktSparseResourcesImageSparseResidency.cpp
- vktSparseResourcesImageSparseResidency.hpp
- vktSparseResourcesBufferSparseResidency.cpp
- vktSparseResourcesBufferSparseResidency.hpp
- vktSparseResourcesImageSparseBinding.cpp
- vktSparseResourcesImageSparseBinding.hpp
- vktSparseResourcesBufferSparseBinding.cpp
- vktSparseResourcesBufferSparseBinding.hpp
- vktSparseResourcesBase.cpp
- vktSparseResourcesBase.hpp
vktSparseResourcesTests.cpp
vktSparseResourcesTests.hpp
vktSparseResourcesTestsUtil.cpp
vktSparseResourcesTestsUtil.hpp
)
-set(DEQP_VK_IMAGE_LIBS
+set(DEQP_VK_SPARSE_RESOURCES_LIBS
tcutil
vkutil
)
-add_library(deqp-vk-sparse-resources STATIC ${DEQP_VK_IMAGE_SRCS})
-target_link_libraries(deqp-vk-sparse-resources ${DEQP_VK_IMAGE_LIBS})
+add_library(deqp-vk-sparse-resources STATIC ${DEQP_VK_SPARSE_RESOURCES_SRCS})
+target_link_libraries(deqp-vk-sparse-resources ${DEQP_VK_SPARSE_RESOURCES_LIBS})
*//*--------------------------------------------------------------------*/
#include "vktSparseResourcesBase.hpp"
-#include "vktSparseResourcesTestsUtil.hpp"
+#include "vkMemUtil.hpp"
#include "vkRefUtil.hpp"
+#include "vkTypeUtil.hpp"
#include "vkQueryUtil.hpp"
using namespace vk;
{
namespace sparse
{
+namespace
+{
struct QueueFamilyQueuesCount
{
deUint32 queueCount;
};
-SparseResourcesBaseInstance::SparseResourcesBaseInstance (Context &context)
- : TestInstance(context)
+static const deUint32 NO_MATCH_FOUND = ~0u;
+
+deUint32 findMatchingQueueFamilyIndex (const std::vector<vk::VkQueueFamilyProperties>& queueFamilyProperties,
+ const VkQueueFlags queueFlags,
+ const deUint32 startIndex)
{
+ for (deUint32 queueNdx = startIndex; queueNdx < queueFamilyProperties.size(); ++queueNdx)
+ {
+ if ((queueFamilyProperties[queueNdx].queueFlags & queueFlags) == queueFlags)
+ return queueNdx;
+ }
+
+ return NO_MATCH_FOUND;
}
+} // anonymous
+
void SparseResourcesBaseInstance::createDeviceSupportingQueues(const QueueRequirementsVec& queueRequirements)
{
+ typedef std::map<vk::VkQueueFlags, std::vector<Queue> > QueuesMap;
+ typedef std::map<deUint32, QueueFamilyQueuesCount> SelectedQueuesMap;
+ typedef std::map<deUint32, std::vector<float> > QueuePrioritiesMap;
+
const InstanceInterface& instance = m_context.getInstanceInterface();
const DeviceInterface& deviceInterface = m_context.getDeviceInterface();
const VkPhysicalDevice physicalDevice = m_context.getPhysicalDevice();
if (queueFamilyPropertiesCount == 0u)
TCU_THROW(ResourceError, "Device reports an empty set of queue family properties");
- typedef std::map<deUint32, QueueFamilyQueuesCount> SelectedQueuesMap;
- typedef std::map<deUint32, std::vector<float> > QueuePrioritiesMap;
-
SelectedQueuesMap selectedQueueFamilies;
QueuePrioritiesMap queuePriorities;
for (deUint32 queueReqNdx = 0; queueReqNdx < queueRequirements.size(); ++queueReqNdx)
{
- const QueueRequirements queueRequirement = queueRequirements[queueReqNdx];
+ const QueueRequirements& queueRequirement = queueRequirements[queueReqNdx];
deUint32 queueFamilyIndex = 0u;
deUint32 queuesFoundCount = 0u;
+
do
{
queueFamilyIndex = findMatchingQueueFamilyIndex(queueFamilyProperties, queueRequirement.queueFlags, queueFamilyIndex);
for (SelectedQueuesMap::iterator queueFamilyIter = selectedQueueFamilies.begin(); queueFamilyIter != selectedQueueFamilies.end(); ++queueFamilyIter)
{
- VkDeviceQueueCreateInfo queueInfo;
- deMemset(&queueInfo, 0, sizeof(queueInfo));
-
for (deUint32 queueNdx = 0; queueNdx < queueFamilyIter->second.queueCount; ++queueNdx)
- {
queuePriorities[queueFamilyIter->first].push_back(1.0f);
- }
- queueInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
- queueInfo.pNext = DE_NULL;
- queueInfo.flags = (VkDeviceQueueCreateFlags)0u;
- queueInfo.queueFamilyIndex = queueFamilyIter->first;
- queueInfo.queueCount = queueFamilyIter->second.queueCount;
- queueInfo.pQueuePriorities = &queuePriorities[queueFamilyIter->first][0];
+ const VkDeviceQueueCreateInfo queueInfo =
+ {
+ VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // VkStructureType sType;
+ DE_NULL, // const void* pNext;
+ (VkDeviceQueueCreateFlags)0u, // VkDeviceQueueCreateFlags flags;
+ queueFamilyIter->first, // uint32_t queueFamilyIndex;
+ queueFamilyIter->second.queueCount, // uint32_t queueCount;
+ &queuePriorities[queueFamilyIter->first][0], // const float* pQueuePriorities;
+ };
queueInfos.push_back(queueInfo);
}
- VkDeviceCreateInfo deviceInfo;
- deMemset(&deviceInfo, 0, sizeof(deviceInfo));
-
- VkPhysicalDeviceFeatures deviceFeatures;
- instance.getPhysicalDeviceFeatures(physicalDevice, &deviceFeatures);
-
- deviceInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
- deviceInfo.pNext = DE_NULL;
- deviceInfo.enabledExtensionCount = 0u;
- deviceInfo.ppEnabledExtensionNames = DE_NULL;
- deviceInfo.enabledLayerCount = 0u;
- deviceInfo.ppEnabledLayerNames = DE_NULL;
- deviceInfo.pEnabledFeatures = &deviceFeatures;
- deviceInfo.queueCreateInfoCount = (deUint32)selectedQueueFamilies.size();
- deviceInfo.pQueueCreateInfos = &queueInfos[0];
+ const VkPhysicalDeviceFeatures deviceFeatures = getPhysicalDeviceFeatures(instance, physicalDevice);
+ const VkDeviceCreateInfo deviceInfo =
+ {
+ VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // VkStructureType sType;
+ DE_NULL, // const void* pNext;
+ (VkDeviceCreateFlags)0, // VkDeviceCreateFlags flags;
+ static_cast<deUint32>(queueInfos.size()), // uint32_t queueCreateInfoCount;
+ &queueInfos[0], // const VkDeviceQueueCreateInfo* pQueueCreateInfos;
+ 0u, // uint32_t enabledLayerCount;
+ DE_NULL, // const char* const* ppEnabledLayerNames;
+ 0u, // uint32_t enabledExtensionCount;
+ DE_NULL, // const char* const* ppEnabledExtensionNames;
+ &deviceFeatures, // const VkPhysicalDeviceFeatures* pEnabledFeatures;
+ };
- m_logicalDevice = vk::createDevice(instance, physicalDevice, &deviceInfo);
+ m_logicalDevice = createDevice(instance, physicalDevice, &deviceInfo);
+ m_allocator = de::MovePtr<Allocator>(new SimpleAllocator(deviceInterface, *m_logicalDevice, getPhysicalDeviceMemoryProperties(instance, physicalDevice)));
for (QueuesMap::iterator queuesIter = m_queues.begin(); queuesIter != m_queues.end(); ++queuesIter)
{
}
}
-const Queue& SparseResourcesBaseInstance::getQueue (const VkQueueFlags queueFlags, const deUint32 queueIndex)
-{
- return m_queues[queueFlags][queueIndex];
-}
-
-deUint32 SparseResourcesBaseInstance::findMatchingMemoryType (const InstanceInterface& instance,
- const VkPhysicalDevice physicalDevice,
- const VkMemoryRequirements& objectMemoryRequirements,
- const MemoryRequirement& memoryRequirement) const
-{
- const VkPhysicalDeviceMemoryProperties deviceMemoryProperties = getPhysicalDeviceMemoryProperties(instance, physicalDevice);
-
- for (deUint32 memoryTypeNdx = 0; memoryTypeNdx < deviceMemoryProperties.memoryTypeCount; ++memoryTypeNdx)
- {
- if ((objectMemoryRequirements.memoryTypeBits & (1u << memoryTypeNdx)) != 0 &&
- memoryRequirement.matchesHeap(deviceMemoryProperties.memoryTypes[memoryTypeNdx].propertyFlags))
- {
- return memoryTypeNdx;
- }
- }
-
- return NO_MATCH_FOUND;
-}
-
-bool SparseResourcesBaseInstance::checkSparseSupportForImageType (const InstanceInterface& instance,
- const VkPhysicalDevice physicalDevice,
- const ImageType imageType) const
+const Queue& SparseResourcesBaseInstance::getQueue (const VkQueueFlags queueFlags, const deUint32 queueIndex) const
{
- const VkPhysicalDeviceFeatures deviceFeatures = getPhysicalDeviceFeatures(instance, physicalDevice);
-
- if (!deviceFeatures.sparseBinding)
- return false;
-
- switch (mapImageType(imageType))
- {
- case VK_IMAGE_TYPE_2D:
- return deviceFeatures.sparseResidencyImage2D == VK_TRUE;
- case VK_IMAGE_TYPE_3D:
- return deviceFeatures.sparseResidencyImage3D == VK_TRUE;
- default:
- DE_ASSERT(0);
- return false;
- };
-}
-
-bool SparseResourcesBaseInstance::checkSparseSupportForImageFormat (const InstanceInterface& instance,
- const VkPhysicalDevice physicalDevice,
- const VkImageCreateInfo& imageInfo) const
-{
- const std::vector<VkSparseImageFormatProperties> sparseImageFormatPropVec = getPhysicalDeviceSparseImageFormatProperties(
- instance, physicalDevice, imageInfo.format, imageInfo.imageType, imageInfo.samples, imageInfo.usage, imageInfo.tiling);
-
- return sparseImageFormatPropVec.size() > 0u;
-}
-
-bool SparseResourcesBaseInstance::checkImageFormatFeatureSupport (const vk::InstanceInterface& instance,
- const vk::VkPhysicalDevice physicalDevice,
- const vk::VkFormat format,
- const vk::VkFormatFeatureFlags featureFlags) const
-{
- const VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(instance, physicalDevice, format);
-
- return (formatProperties.optimalTilingFeatures & featureFlags) == featureFlags;
-}
-
-deUint32 SparseResourcesBaseInstance::getSparseAspectRequirementsIndex (const std::vector<VkSparseImageMemoryRequirements>& requirements,
- const VkImageAspectFlags aspectFlags) const
-{
- for (deUint32 memoryReqNdx = 0; memoryReqNdx < requirements.size(); ++memoryReqNdx)
- {
- if (requirements[memoryReqNdx].formatProperties.aspectMask & aspectFlags)
- {
- return memoryReqNdx;
- }
- }
-
- return NO_MATCH_FOUND;
-}
-
-deUint32 SparseResourcesBaseInstance::findMatchingQueueFamilyIndex (const QueueFamilyPropertiesVec& queueFamilyProperties,
- const VkQueueFlags queueFlags,
- const deUint32 startIndex) const
-{
- for (deUint32 queueNdx = startIndex; queueNdx < queueFamilyProperties.size(); ++queueNdx)
- {
- if ((queueFamilyProperties[queueNdx].queueFlags & queueFlags) == queueFlags)
- {
- return queueNdx;
- }
- }
-
- return NO_MATCH_FOUND;
+ return m_queues.find(queueFlags)->second[queueIndex];
}
} // sparse
* \brief Sparse Resources Base Instance
*//*--------------------------------------------------------------------*/
-#include "tcuDefs.hpp"
-#include "tcuTestCase.hpp"
-#include "vktTestCaseUtil.hpp"
-#include "vktSparseResourcesTestsUtil.hpp"
-
#include "vkDefs.hpp"
-#include "vkMemUtil.hpp"
-#include "vkPlatform.hpp"
+#include "vktTestCase.hpp"
#include "vkRef.hpp"
-#include "vkTypeUtil.hpp"
-
-#include "deSharedPtr.hpp"
#include "deUniquePtr.hpp"
-#include "deStringUtil.hpp"
#include <map>
#include <vector>
namespace sparse
{
-enum
-{
- NO_MATCH_FOUND = ~((deUint32)0)
-};
-
struct Queue
{
vk::VkQueue queueHandle;
deUint32 queueCount;
};
-typedef std::vector<QueueRequirements> QueueRequirementsVec;
-
class SparseResourcesBaseInstance : public TestInstance
{
public:
- SparseResourcesBaseInstance (Context &context);
+ SparseResourcesBaseInstance (Context &context) : TestInstance(context) {}
protected:
+ typedef std::vector<QueueRequirements> QueueRequirementsVec;
- typedef std::map<vk::VkQueueFlags, std::vector<Queue> > QueuesMap;
- typedef std::vector<vk::VkQueueFamilyProperties> QueueFamilyPropertiesVec;
- typedef vk::Move<vk::VkDevice> DevicePtr;
- typedef de::SharedPtr< vk::Unique<vk::VkDeviceMemory> > DeviceMemoryUniquePtr;
-
- void createDeviceSupportingQueues (const QueueRequirementsVec& queueRequirements);
-
- const Queue& getQueue (const vk::VkQueueFlags queueFlags,
- const deUint32 queueIndex);
-
- deUint32 findMatchingMemoryType (const vk::InstanceInterface& instance,
- const vk::VkPhysicalDevice physicalDevice,
- const vk::VkMemoryRequirements& objectMemoryRequirements,
- const vk::MemoryRequirement& memoryRequirement) const;
-
- bool checkSparseSupportForImageType (const vk::InstanceInterface& instance,
- const vk::VkPhysicalDevice physicalDevice,
- const ImageType imageType) const;
-
- bool checkSparseSupportForImageFormat (const vk::InstanceInterface& instance,
- const vk::VkPhysicalDevice physicalDevice,
- const vk::VkImageCreateInfo& imageInfo) const;
-
- bool checkImageFormatFeatureSupport (const vk::InstanceInterface& instance,
- const vk::VkPhysicalDevice physicalDevice,
- const vk::VkFormat format,
- const vk::VkFormatFeatureFlags featureFlags) const;
-
- deUint32 getSparseAspectRequirementsIndex (const std::vector<vk::VkSparseImageMemoryRequirements>&requirements,
- const vk::VkImageAspectFlags aspectFlags) const;
-
- DevicePtr m_logicalDevice;
+ void createDeviceSupportingQueues (const QueueRequirementsVec& queueRequirements);
+ const Queue& getQueue (const vk::VkQueueFlags queueFlags, const deUint32 queueIndex) const;
+ vk::VkDevice getDevice (void) const { return *m_logicalDevice; }
+ vk::Allocator& getAllocator (void) { return *m_allocator; }
private:
-
- deUint32 findMatchingQueueFamilyIndex (const QueueFamilyPropertiesVec& queueFamilyProperties,
- const vk::VkQueueFlags queueFlags,
- const deUint32 startIndex) const;
- QueuesMap m_queues;
+ std::map<vk::VkQueueFlags, std::vector<Queue> > m_queues;
+ vk::Move<vk::VkDevice> m_logicalDevice;
+ de::MovePtr<vk::Allocator> m_allocator;
};
} // sparse
createDeviceSupportingQueues(queueRequirements);
}
- const de::UniquePtr<Allocator> allocator(new SimpleAllocator(deviceInterface, *m_logicalDevice, getPhysicalDeviceMemoryProperties(instance, physicalDevice)));
-
const Queue& sparseQueue = getQueue(VK_QUEUE_SPARSE_BINDING_BIT, 0);
const Queue& computeQueue = getQueue(VK_QUEUE_COMPUTE_BIT, 0);
}
// Create sparse buffers
- const Unique<VkBuffer> sparseBufferWrite(createBuffer(deviceInterface, *m_logicalDevice, &bufferCreateInfo));
- const Unique<VkBuffer> sparseBufferRead (createBuffer(deviceInterface, *m_logicalDevice, &bufferCreateInfo));
+ const Unique<VkBuffer> sparseBufferWrite(createBuffer(deviceInterface, getDevice(), &bufferCreateInfo));
+ const Unique<VkBuffer> sparseBufferRead (createBuffer(deviceInterface, getDevice(), &bufferCreateInfo));
// Create sparse buffers memory bind semaphore
- const Unique<VkSemaphore> bufferMemoryBindSemaphore(makeSemaphore(deviceInterface, *m_logicalDevice));
+ const Unique<VkSemaphore> bufferMemoryBindSemaphore(makeSemaphore(deviceInterface, getDevice()));
- const VkMemoryRequirements bufferMemRequirements = getBufferMemoryRequirements(deviceInterface, *m_logicalDevice, *sparseBufferWrite);
+ const VkMemoryRequirements bufferMemRequirements = getBufferMemoryRequirements(deviceInterface, getDevice(), *sparseBufferWrite);
if (bufferMemRequirements.size > getPhysicalDeviceProperties(instance, physicalDevice).limits.sparseAddressSpaceSize)
TCU_THROW(NotSupportedError, "Required memory size for sparse resources exceeds device limits");
if (memoryType == NO_MATCH_FOUND)
return tcu::TestStatus::fail("No matching memory type found");
- const VkSparseMemoryBind sparseMemoryBind = makeSparseMemoryBind(deviceInterface, *m_logicalDevice, bufferMemRequirements.size, memoryType, 0u);
+ const VkSparseMemoryBind sparseMemoryBind = makeSparseMemoryBind(deviceInterface, getDevice(), bufferMemRequirements.size, memoryType, 0u);
- Move<VkDeviceMemory> deviceMemoryPtr(check<VkDeviceMemory>(sparseMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, *m_logicalDevice, DE_NULL));
+ Move<VkDeviceMemory> deviceMemoryPtr(check<VkDeviceMemory>(sparseMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, getDevice(), DE_NULL));
{
const VkSparseBufferMemoryBindInfo sparseBufferMemoryBindInfo[2] =
}
// Create output buffer
- const VkBufferCreateInfo outputBufferCreateInfo = makeBufferCreateInfo(m_bufferSizeInBytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT);
- de::UniquePtr<Buffer> outputBuffer(new Buffer(deviceInterface, *m_logicalDevice, *allocator, outputBufferCreateInfo, MemoryRequirement::HostVisible));
+ const VkBufferCreateInfo outputBufferCreateInfo = makeBufferCreateInfo(m_bufferSizeInBytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT);
+ const Unique<VkBuffer> outputBuffer (createBuffer(deviceInterface, getDevice(), &outputBufferCreateInfo));
+ const de::UniquePtr<Allocation> outputBufferAlloc (bindBuffer(deviceInterface, getDevice(), getAllocator(), *outputBuffer, MemoryRequirement::HostVisible));
// Create command buffer for compute and data transfer oparations
- const Unique<VkCommandPool> commandPool(makeCommandPool(deviceInterface, *m_logicalDevice, computeQueue.queueFamilyIndex));
- const Unique<VkCommandBuffer> commandBuffer(makeCommandBuffer(deviceInterface, *m_logicalDevice, *commandPool));
+ const Unique<VkCommandPool> commandPool(makeCommandPool(deviceInterface, getDevice(), computeQueue.queueFamilyIndex));
+ const Unique<VkCommandBuffer> commandBuffer(makeCommandBuffer(deviceInterface, getDevice(), *commandPool));
// Start recording commands
beginCommandBuffer(deviceInterface, *commandBuffer);
const Unique<VkDescriptorSetLayout> descriptorSetLayout(
DescriptorSetLayoutBuilder()
.addSingleBinding(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_SHADER_STAGE_COMPUTE_BIT)
- .build(deviceInterface, *m_logicalDevice));
+ .build(deviceInterface, getDevice()));
// Create compute pipeline
- const Unique<VkShaderModule> shaderModule(createShaderModule(deviceInterface, *m_logicalDevice, m_context.getBinaryCollection().get("comp"), DE_NULL));
- const Unique<VkPipelineLayout> pipelineLayout(makePipelineLayout(deviceInterface, *m_logicalDevice, *descriptorSetLayout));
- const Unique<VkPipeline> computePipeline(makeComputePipeline(deviceInterface, *m_logicalDevice, *pipelineLayout, *shaderModule));
+ const Unique<VkShaderModule> shaderModule(createShaderModule(deviceInterface, getDevice(), m_context.getBinaryCollection().get("comp"), DE_NULL));
+ const Unique<VkPipelineLayout> pipelineLayout(makePipelineLayout(deviceInterface, getDevice(), *descriptorSetLayout));
+ const Unique<VkPipeline> computePipeline(makeComputePipeline(deviceInterface, getDevice(), *pipelineLayout, *shaderModule));
deviceInterface.cmdBindPipeline(*commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *computePipeline);
const Unique<VkDescriptorPool> descriptorPool(
DescriptorPoolBuilder()
.addType(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1u)
- .build(deviceInterface, *m_logicalDevice, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 1u));
+ .build(deviceInterface, getDevice(), VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 1u));
- const Unique<VkDescriptorSet> descriptorSet(makeDescriptorSet(deviceInterface, *m_logicalDevice, *descriptorPool, *descriptorSetLayout));
+ const Unique<VkDescriptorSet> descriptorSet(makeDescriptorSet(deviceInterface, getDevice(), *descriptorPool, *descriptorSetLayout));
{
const VkDescriptorBufferInfo sparseBufferInfo = makeDescriptorBufferInfo(*sparseBufferWrite, 0u, m_bufferSizeInBytes);
DescriptorSetUpdateBuilder()
.writeSingle(*descriptorSet, DescriptorSetUpdateBuilder::Location::binding(0u), VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, &sparseBufferInfo)
- .update(deviceInterface, *m_logicalDevice);
+ .update(deviceInterface, getDevice());
}
deviceInterface.cmdBindDescriptorSets(*commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *pipelineLayout, 0u, 1u, &descriptorSet.get(), 0u, DE_NULL);
{
const VkBufferCopy bufferCopy = makeBufferCopy(0u, 0u, m_bufferSizeInBytes);
- deviceInterface.cmdCopyBuffer(*commandBuffer, *sparseBufferRead, outputBuffer->get(), 1u, &bufferCopy);
+ deviceInterface.cmdCopyBuffer(*commandBuffer, *sparseBufferRead, *outputBuffer, 1u, &bufferCopy);
}
{
const VkBufferMemoryBarrier outputBufferHostBarrier
= makeBufferMemoryBarrier( VK_ACCESS_TRANSFER_WRITE_BIT,
VK_ACCESS_HOST_READ_BIT,
- outputBuffer->get(),
+ *outputBuffer,
0ull,
m_bufferSizeInBytes);
const VkPipelineStageFlags waitStageBits[] = { VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT };
// Submit commands for execution and wait for completion
- submitCommandsAndWait(deviceInterface, *m_logicalDevice, computeQueue.queueHandle, *commandBuffer, 1u, &bufferMemoryBindSemaphore.get(), waitStageBits);
+ submitCommandsAndWait(deviceInterface, getDevice(), computeQueue.queueHandle, *commandBuffer, 1u, &bufferMemoryBindSemaphore.get(), waitStageBits);
// Retrieve data from output buffer to host memory
- const Allocation& allocation = outputBuffer->getAllocation();
- invalidateMappedMemoryRange(deviceInterface, *m_logicalDevice, allocation.getMemory(), allocation.getOffset(), m_bufferSizeInBytes);
+ invalidateMappedMemoryRange(deviceInterface, getDevice(), outputBufferAlloc->getMemory(), outputBufferAlloc->getOffset(), m_bufferSizeInBytes);
- const deUint8* outputData = static_cast<const deUint8*>(allocation.getHostPtr());
+ const deUint8* outputData = static_cast<const deUint8*>(outputBufferAlloc->getHostPtr());
// Wait for sparse queue to become idle
deviceInterface.queueWaitIdle(sparseQueue.queueHandle);
createDeviceSupportingQueues(queueRequirements);
}
- const de::UniquePtr<Allocator> allocator(new SimpleAllocator(deviceInterface, *m_logicalDevice, getPhysicalDeviceMemoryProperties(instance, physicalDevice)));
-
const Queue& sparseQueue = getQueue(VK_QUEUE_SPARSE_BINDING_BIT, 0);
const Queue& computeQueue = getQueue(VK_QUEUE_COMPUTE_BIT, 0);
}
// Create sparse buffer
- const Unique<VkBuffer> sparseBuffer(createBuffer(deviceInterface, *m_logicalDevice, &bufferCreateInfo));
+ const Unique<VkBuffer> sparseBuffer(createBuffer(deviceInterface, getDevice(), &bufferCreateInfo));
// Create sparse buffer memory bind semaphore
- const Unique<VkSemaphore> bufferMemoryBindSemaphore(makeSemaphore(deviceInterface, *m_logicalDevice));
+ const Unique<VkSemaphore> bufferMemoryBindSemaphore(makeSemaphore(deviceInterface, getDevice()));
- const VkMemoryRequirements bufferMemRequirement = getBufferMemoryRequirements(deviceInterface, *m_logicalDevice, *sparseBuffer);
+ const VkMemoryRequirements bufferMemRequirement = getBufferMemoryRequirements(deviceInterface, getDevice(), *sparseBuffer);
if (bufferMemRequirement.size > getPhysicalDeviceProperties(instance, physicalDevice).limits.sparseAddressSpaceSize)
TCU_THROW(NotSupportedError, "Required memory size for sparse resources exceeds device limits");
DE_ASSERT((bufferMemRequirement.size % bufferMemRequirement.alignment) == 0);
- std::vector<DeviceMemoryUniquePtr> deviceMemUniquePtrVec;
+ std::vector<DeviceMemorySp> deviceMemUniquePtrVec;
{
std::vector<VkSparseMemoryBind> sparseMemoryBinds;
for (deUint32 sparseBindNdx = 0; sparseBindNdx < numSparseBinds; ++sparseBindNdx)
{
- const VkSparseMemoryBind sparseMemoryBind = makeSparseMemoryBind(deviceInterface, *m_logicalDevice, bufferMemRequirement.alignment, memoryType, bufferMemRequirement.alignment * sparseBindNdx);
+ const VkSparseMemoryBind sparseMemoryBind = makeSparseMemoryBind(deviceInterface, getDevice(), bufferMemRequirement.alignment, memoryType, bufferMemRequirement.alignment * sparseBindNdx);
- deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(sparseMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, *m_logicalDevice, DE_NULL))));
+ deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(sparseMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, getDevice(), DE_NULL))));
sparseMemoryBinds.push_back(sparseMemoryBind);
}
}
// Create command buffer for transfer oparations
- const Unique<VkCommandPool> commandPool(makeCommandPool(deviceInterface, *m_logicalDevice, computeQueue.queueFamilyIndex));
- const Unique<VkCommandBuffer> commandBuffer(makeCommandBuffer(deviceInterface, *m_logicalDevice, *commandPool));
+ const Unique<VkCommandPool> commandPool(makeCommandPool(deviceInterface, getDevice(), computeQueue.queueFamilyIndex));
+ const Unique<VkCommandBuffer> commandBuffer(makeCommandBuffer(deviceInterface, getDevice(), *commandPool));
// Start recording transfer commands
beginCommandBuffer(deviceInterface, *commandBuffer);
- const VkBufferCreateInfo inputBufferCreateInfo = makeBufferCreateInfo(m_bufferSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
- const de::UniquePtr<Buffer> inputBuffer(new Buffer(deviceInterface, *m_logicalDevice, *allocator, inputBufferCreateInfo, MemoryRequirement::HostVisible));
+ const VkBufferCreateInfo inputBufferCreateInfo = makeBufferCreateInfo(m_bufferSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
+ const Unique<VkBuffer> inputBuffer (createBuffer(deviceInterface, getDevice(), &inputBufferCreateInfo));
+ const de::UniquePtr<Allocation> inputBufferAlloc (bindBuffer(deviceInterface, getDevice(), getAllocator(), *inputBuffer, MemoryRequirement::HostVisible));
std::vector<deUint8> referenceData;
referenceData.resize(m_bufferSize);
referenceData[valueNdx] = static_cast<deUint8>((valueNdx % bufferMemRequirement.alignment) + 1u);
}
- deMemcpy(inputBuffer->getAllocation().getHostPtr(), &referenceData[0], m_bufferSize);
+ deMemcpy(inputBufferAlloc->getHostPtr(), &referenceData[0], m_bufferSize);
- flushMappedMemoryRange(deviceInterface, *m_logicalDevice, inputBuffer->getAllocation().getMemory(), inputBuffer->getAllocation().getOffset(), m_bufferSize);
+ flushMappedMemoryRange(deviceInterface, getDevice(), inputBufferAlloc->getMemory(), inputBufferAlloc->getOffset(), m_bufferSize);
{
const VkBufferMemoryBarrier inputBufferBarrier
= makeBufferMemoryBarrier( VK_ACCESS_HOST_WRITE_BIT,
VK_ACCESS_TRANSFER_READ_BIT,
- inputBuffer->get(),
+ *inputBuffer,
0u,
m_bufferSize);
{
const VkBufferCopy bufferCopy = makeBufferCopy(0u, 0u, m_bufferSize);
- deviceInterface.cmdCopyBuffer(*commandBuffer, inputBuffer->get(), *sparseBuffer, 1u, &bufferCopy);
+ deviceInterface.cmdCopyBuffer(*commandBuffer, *inputBuffer, *sparseBuffer, 1u, &bufferCopy);
}
{
deviceInterface.cmdPipelineBarrier(*commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0u, 0u, DE_NULL, 1u, &sparseBufferBarrier, 0u, DE_NULL);
}
- const VkBufferCreateInfo outputBufferCreateInfo = makeBufferCreateInfo(m_bufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT);
- const de::UniquePtr<Buffer> outputBuffer(new Buffer(deviceInterface, *m_logicalDevice, *allocator, outputBufferCreateInfo, MemoryRequirement::HostVisible));
+ const VkBufferCreateInfo outputBufferCreateInfo = makeBufferCreateInfo(m_bufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT);
+ const Unique<VkBuffer> outputBuffer (createBuffer(deviceInterface, getDevice(), &outputBufferCreateInfo));
+ const de::UniquePtr<Allocation> outputBufferAlloc (bindBuffer(deviceInterface, getDevice(), getAllocator(), *outputBuffer, MemoryRequirement::HostVisible));
{
const VkBufferCopy bufferCopy = makeBufferCopy(0u, 0u, m_bufferSize);
- deviceInterface.cmdCopyBuffer(*commandBuffer, *sparseBuffer, outputBuffer->get(), 1u, &bufferCopy);
+ deviceInterface.cmdCopyBuffer(*commandBuffer, *sparseBuffer, *outputBuffer, 1u, &bufferCopy);
}
{
const VkBufferMemoryBarrier outputBufferBarrier
= makeBufferMemoryBarrier( VK_ACCESS_TRANSFER_WRITE_BIT,
VK_ACCESS_HOST_READ_BIT,
- outputBuffer->get(),
+ *outputBuffer,
0u,
m_bufferSize);
const VkPipelineStageFlags waitStageBits[] = { VK_PIPELINE_STAGE_TRANSFER_BIT };
// Submit transfer commands for execution and wait for completion
- submitCommandsAndWait(deviceInterface, *m_logicalDevice, computeQueue.queueHandle, *commandBuffer, 1u, &bufferMemoryBindSemaphore.get(), waitStageBits);
+ submitCommandsAndWait(deviceInterface, getDevice(), computeQueue.queueHandle, *commandBuffer, 1u, &bufferMemoryBindSemaphore.get(), waitStageBits);
// Retrieve data from output buffer to host memory
- const Allocation& allocation = outputBuffer->getAllocation();
- invalidateMappedMemoryRange(deviceInterface, *m_logicalDevice, allocation.getMemory(), allocation.getOffset(), m_bufferSize);
+ invalidateMappedMemoryRange(deviceInterface, getDevice(), outputBufferAlloc->getMemory(), outputBufferAlloc->getOffset(), m_bufferSize);
- const deUint8* outputData = static_cast<const deUint8*>(allocation.getHostPtr());
+ const deUint8* outputData = static_cast<const deUint8*>(outputBufferAlloc->getHostPtr());
// Wait for sparse queue to become idle
deviceInterface.queueWaitIdle(sparseQueue.queueHandle);
createDeviceSupportingQueues(queueRequirements);
}
- const de::UniquePtr<Allocator> allocator(new SimpleAllocator(deviceInterface, *m_logicalDevice, getPhysicalDeviceMemoryProperties(instance, physicalDevice)));
-
const Queue& sparseQueue = getQueue(VK_QUEUE_SPARSE_BINDING_BIT, 0);
const Queue& computeQueue = getQueue(VK_QUEUE_COMPUTE_BIT, 0);
}
// Create sparse buffer
- const Unique<VkBuffer> sparseBuffer(createBuffer(deviceInterface, *m_logicalDevice, &bufferCreateInfo));
+ const Unique<VkBuffer> sparseBuffer(createBuffer(deviceInterface, getDevice(), &bufferCreateInfo));
// Create sparse buffer memory bind semaphore
- const Unique<VkSemaphore> bufferMemoryBindSemaphore(makeSemaphore(deviceInterface, *m_logicalDevice));
+ const Unique<VkSemaphore> bufferMemoryBindSemaphore(makeSemaphore(deviceInterface, getDevice()));
- const VkMemoryRequirements bufferMemRequirements = getBufferMemoryRequirements(deviceInterface, *m_logicalDevice, *sparseBuffer);
+ const VkMemoryRequirements bufferMemRequirements = getBufferMemoryRequirements(deviceInterface, getDevice(), *sparseBuffer);
if (bufferMemRequirements.size > physicalDeviceProperties.limits.sparseAddressSpaceSize)
TCU_THROW(NotSupportedError, "Required memory size for sparse resources exceeds device limits");
DE_ASSERT((bufferMemRequirements.size % bufferMemRequirements.alignment) == 0);
- const deUint32 numSparseSlots = static_cast<deUint32>(bufferMemRequirements.size / bufferMemRequirements.alignment);
- std::vector<DeviceMemoryUniquePtr> deviceMemUniquePtrVec;
+ const deUint32 numSparseSlots = static_cast<deUint32>(bufferMemRequirements.size / bufferMemRequirements.alignment);
+ std::vector<DeviceMemorySp> deviceMemUniquePtrVec;
{
std::vector<VkSparseMemoryBind> sparseMemoryBinds;
for (deUint32 sparseBindNdx = 0; sparseBindNdx < numSparseSlots; sparseBindNdx += 2)
{
- const VkSparseMemoryBind sparseMemoryBind = makeSparseMemoryBind(deviceInterface, *m_logicalDevice, bufferMemRequirements.alignment, memoryType, bufferMemRequirements.alignment * sparseBindNdx);
+ const VkSparseMemoryBind sparseMemoryBind = makeSparseMemoryBind(deviceInterface, getDevice(), bufferMemRequirements.alignment, memoryType, bufferMemRequirements.alignment * sparseBindNdx);
- deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(sparseMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, *m_logicalDevice, DE_NULL))));
+ deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(sparseMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, getDevice(), DE_NULL))));
sparseMemoryBinds.push_back(sparseMemoryBind);
}
}
// Create input buffer
- const VkBufferCreateInfo inputBufferCreateInfo = makeBufferCreateInfo(m_bufferSize, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
- de::UniquePtr<Buffer> inputBuffer(new Buffer(deviceInterface, *m_logicalDevice, *allocator, inputBufferCreateInfo, MemoryRequirement::HostVisible));
+ const VkBufferCreateInfo inputBufferCreateInfo = makeBufferCreateInfo(m_bufferSize, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
+ const Unique<VkBuffer> inputBuffer (createBuffer(deviceInterface, getDevice(), &inputBufferCreateInfo));
+ const de::UniquePtr<Allocation> inputBufferAlloc (bindBuffer(deviceInterface, getDevice(), getAllocator(), *inputBuffer, MemoryRequirement::HostVisible));
+
std::vector<deUint8> referenceData;
referenceData.resize(m_bufferSize);
referenceData[valueNdx] = static_cast<deUint8>((valueNdx % bufferMemRequirements.alignment) + 1u);
}
- deMemcpy(inputBuffer->getAllocation().getHostPtr(), &referenceData[0], m_bufferSize);
+ deMemcpy(inputBufferAlloc->getHostPtr(), &referenceData[0], m_bufferSize);
- flushMappedMemoryRange(deviceInterface, *m_logicalDevice, inputBuffer->getAllocation().getMemory(), inputBuffer->getAllocation().getOffset(), m_bufferSize);
+ flushMappedMemoryRange(deviceInterface, getDevice(), inputBufferAlloc->getMemory(), inputBufferAlloc->getOffset(), m_bufferSize);
// Create output buffer
- const VkBufferCreateInfo outputBufferCreateInfo = makeBufferCreateInfo(m_bufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT);
- de::UniquePtr<Buffer> outputBuffer(new Buffer(deviceInterface, *m_logicalDevice, *allocator, outputBufferCreateInfo, MemoryRequirement::HostVisible));
+ const VkBufferCreateInfo outputBufferCreateInfo = makeBufferCreateInfo(m_bufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT);
+ const Unique<VkBuffer> outputBuffer (createBuffer(deviceInterface, getDevice(), &outputBufferCreateInfo));
+ const de::UniquePtr<Allocation> outputBufferAlloc (bindBuffer(deviceInterface, getDevice(), getAllocator(), *outputBuffer, MemoryRequirement::HostVisible));
// Create command buffer for compute and data transfer oparations
- const Unique<VkCommandPool> commandPool(makeCommandPool(deviceInterface, *m_logicalDevice, computeQueue.queueFamilyIndex));
- const Unique<VkCommandBuffer> commandBuffer(makeCommandBuffer(deviceInterface, *m_logicalDevice, *commandPool));
+ const Unique<VkCommandPool> commandPool(makeCommandPool(deviceInterface, getDevice(), computeQueue.queueFamilyIndex));
+ const Unique<VkCommandBuffer> commandBuffer(makeCommandBuffer(deviceInterface, getDevice(), *commandPool));
// Start recording compute and transfer commands
beginCommandBuffer(deviceInterface, *commandBuffer);
DescriptorSetLayoutBuilder()
.addSingleBinding(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_SHADER_STAGE_COMPUTE_BIT)
.addSingleBinding(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_SHADER_STAGE_COMPUTE_BIT)
- .build(deviceInterface, *m_logicalDevice));
+ .build(deviceInterface, getDevice()));
// Create compute pipeline
- const Unique<VkShaderModule> shaderModule(createShaderModule(deviceInterface, *m_logicalDevice, m_context.getBinaryCollection().get("comp"), DE_NULL));
- const Unique<VkPipelineLayout> pipelineLayout(makePipelineLayout(deviceInterface, *m_logicalDevice, *descriptorSetLayout));
- const Unique<VkPipeline> computePipeline(makeComputePipeline(deviceInterface, *m_logicalDevice, *pipelineLayout, *shaderModule));
+ const Unique<VkShaderModule> shaderModule(createShaderModule(deviceInterface, getDevice(), m_context.getBinaryCollection().get("comp"), DE_NULL));
+ const Unique<VkPipelineLayout> pipelineLayout(makePipelineLayout(deviceInterface, getDevice(), *descriptorSetLayout));
+ const Unique<VkPipeline> computePipeline(makeComputePipeline(deviceInterface, getDevice(), *pipelineLayout, *shaderModule));
deviceInterface.cmdBindPipeline(*commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *computePipeline);
const Unique<VkDescriptorPool> descriptorPool(
DescriptorPoolBuilder()
.addType(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 2u)
- .build(deviceInterface, *m_logicalDevice, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 1u));
+ .build(deviceInterface, getDevice(), VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 1u));
- const Unique<VkDescriptorSet> descriptorSet(makeDescriptorSet(deviceInterface, *m_logicalDevice, *descriptorPool, *descriptorSetLayout));
+ const Unique<VkDescriptorSet> descriptorSet(makeDescriptorSet(deviceInterface, getDevice(), *descriptorPool, *descriptorSetLayout));
{
- const VkDescriptorBufferInfo inputBufferInfo = makeDescriptorBufferInfo(inputBuffer->get(), 0ull, m_bufferSize);
+ const VkDescriptorBufferInfo inputBufferInfo = makeDescriptorBufferInfo(*inputBuffer, 0ull, m_bufferSize);
const VkDescriptorBufferInfo sparseBufferInfo = makeDescriptorBufferInfo(*sparseBuffer, 0ull, m_bufferSize);
DescriptorSetUpdateBuilder()
.writeSingle(*descriptorSet, DescriptorSetUpdateBuilder::Location::binding(0u), VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, &inputBufferInfo)
.writeSingle(*descriptorSet, DescriptorSetUpdateBuilder::Location::binding(1u), VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, &sparseBufferInfo)
- .update(deviceInterface, *m_logicalDevice);
+ .update(deviceInterface, getDevice());
}
deviceInterface.cmdBindDescriptorSets(*commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *pipelineLayout, 0u, 1u, &descriptorSet.get(), 0u, DE_NULL);
const VkBufferMemoryBarrier inputBufferBarrier
= makeBufferMemoryBarrier( VK_ACCESS_HOST_WRITE_BIT,
VK_ACCESS_SHADER_READ_BIT,
- inputBuffer->get(),
+ *inputBuffer,
0ull,
m_bufferSize);
{
const VkBufferCopy bufferCopy = makeBufferCopy(0u, 0u, m_bufferSize);
- deviceInterface.cmdCopyBuffer(*commandBuffer, *sparseBuffer, outputBuffer->get(), 1u, &bufferCopy);
+ deviceInterface.cmdCopyBuffer(*commandBuffer, *sparseBuffer, *outputBuffer, 1u, &bufferCopy);
}
{
const VkBufferMemoryBarrier outputBufferBarrier
= makeBufferMemoryBarrier( VK_ACCESS_TRANSFER_WRITE_BIT,
VK_ACCESS_HOST_READ_BIT,
- outputBuffer->get(),
+ *outputBuffer,
0ull,
m_bufferSize);
const VkPipelineStageFlags waitStageBits[] = { VK_PIPELINE_STAGE_TRANSFER_BIT };
// Submit transfer commands for execution and wait for completion
- submitCommandsAndWait(deviceInterface, *m_logicalDevice, computeQueue.queueHandle, *commandBuffer, 1u, &bufferMemoryBindSemaphore.get(), waitStageBits);
+ submitCommandsAndWait(deviceInterface, getDevice(), computeQueue.queueHandle, *commandBuffer, 1u, &bufferMemoryBindSemaphore.get(), waitStageBits);
// Retrieve data from output buffer to host memory
- const Allocation& allocation = outputBuffer->getAllocation();
- invalidateMappedMemoryRange(deviceInterface, *m_logicalDevice, allocation.getMemory(), allocation.getOffset(), m_bufferSize);
+ invalidateMappedMemoryRange(deviceInterface, getDevice(), outputBufferAlloc->getMemory(), outputBufferAlloc->getOffset(), m_bufferSize);
- const deUint8* outputData = static_cast<const deUint8*>(allocation.getHostPtr());
+ const deUint8* outputData = static_cast<const deUint8*>(outputBufferAlloc->getHostPtr());
// Wait for sparse queue to become idle
deviceInterface.queueWaitIdle(sparseQueue.queueHandle);
const deUint32 maxWorkGroupInvocations = 128u;
VkImageCreateInfo imageSparseInfo;
VkSparseImageMemoryRequirements aspectRequirements;
- std::vector<DeviceMemoryUniquePtr> deviceMemUniquePtrVec;
+ std::vector<DeviceMemorySp> deviceMemUniquePtrVec;
// Check if image size does not exceed device limits
if (!isImageSizeSupported(instance, physicalDevice, m_imageType, m_imageSize))
const Queue& sparseQueue = getQueue(VK_QUEUE_SPARSE_BINDING_BIT, 0);
const Queue& computeQueue = getQueue(VK_QUEUE_COMPUTE_BIT, 0);
- const de::UniquePtr<Allocator> allocator(new SimpleAllocator(deviceInterface, *m_logicalDevice, getPhysicalDeviceMemoryProperties(instance, physicalDevice)));
-
// Create sparse image
- const Unique<VkImage> imageRead(createImage(deviceInterface, *m_logicalDevice, &imageSparseInfo));
- const Unique<VkImage> imageWrite(createImage(deviceInterface, *m_logicalDevice, &imageSparseInfo));
+ const Unique<VkImage> imageRead(createImage(deviceInterface, getDevice(), &imageSparseInfo));
+ const Unique<VkImage> imageWrite(createImage(deviceInterface, getDevice(), &imageSparseInfo));
// Create semaphores to synchronize sparse binding operations with other operations on the sparse images
- const Unique<VkSemaphore> memoryBindSemaphoreTransfer(makeSemaphore(deviceInterface, *m_logicalDevice));
- const Unique<VkSemaphore> memoryBindSemaphoreCompute(makeSemaphore(deviceInterface, *m_logicalDevice));
+ const Unique<VkSemaphore> memoryBindSemaphoreTransfer(makeSemaphore(deviceInterface, getDevice()));
+ const Unique<VkSemaphore> memoryBindSemaphoreCompute(makeSemaphore(deviceInterface, getDevice()));
const VkSemaphore imageMemoryBindSemaphores[] = { memoryBindSemaphoreTransfer.get(), memoryBindSemaphoreCompute.get() };
std::vector<VkSparseMemoryBind> imageWriteMipTailBinds;
// Get sparse image general memory requirements
- const VkMemoryRequirements imageMemoryRequirements = getImageMemoryRequirements(deviceInterface, *m_logicalDevice, *imageRead);
+ const VkMemoryRequirements imageMemoryRequirements = getImageMemoryRequirements(deviceInterface, getDevice(), *imageRead);
// Check if required image memory size does not exceed device limits
if (imageMemoryRequirements.size > getPhysicalDeviceProperties(instance, physicalDevice).limits.sparseAddressSpaceSize)
DE_ASSERT((imageMemoryRequirements.size % imageMemoryRequirements.alignment) == 0);
// Get sparse image sparse memory requirements
- const std::vector<VkSparseImageMemoryRequirements> sparseMemoryRequirements = getImageSparseMemoryRequirements(deviceInterface, *m_logicalDevice, *imageRead);
+ const std::vector<VkSparseImageMemoryRequirements> sparseMemoryRequirements = getImageSparseMemoryRequirements(deviceInterface, getDevice(), *imageRead);
DE_ASSERT(sparseMemoryRequirements.size() != 0);
const deUint32 numSparseBlocks = sparseBlocks.x() * sparseBlocks.y() * sparseBlocks.z();
const VkImageSubresource subresource = { aspectMask, mipLevelNdx, layerNdx };
- const VkSparseImageMemoryBind imageMemoryBind = makeSparseImageMemoryBind(deviceInterface, *m_logicalDevice,
+ const VkSparseImageMemoryBind imageMemoryBind = makeSparseImageMemoryBind(deviceInterface, getDevice(),
imageMemoryRequirements.alignment * numSparseBlocks, memoryType, subresource, makeOffset3D(0u, 0u, 0u), mipExtent);
- deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, *m_logicalDevice, DE_NULL))));
+ deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, getDevice(), DE_NULL))));
imageResidencyMemoryBinds.push_back(imageMemoryBind);
}
if (!(aspectRequirements.formatProperties.flags & VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT) && aspectRequirements.imageMipTailFirstLod < imageSparseInfo.mipLevels)
{
- const VkSparseMemoryBind imageReadMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, *m_logicalDevice,
+ const VkSparseMemoryBind imageReadMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, getDevice(),
aspectRequirements.imageMipTailSize, memoryType, aspectRequirements.imageMipTailOffset + layerNdx * aspectRequirements.imageMipTailStride);
- deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageReadMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, *m_logicalDevice, DE_NULL))));
+ deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageReadMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, getDevice(), DE_NULL))));
imageReadMipTailBinds.push_back(imageReadMipTailMemoryBind);
- const VkSparseMemoryBind imageWriteMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, *m_logicalDevice,
+ const VkSparseMemoryBind imageWriteMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, getDevice(),
aspectRequirements.imageMipTailSize, memoryType, aspectRequirements.imageMipTailOffset + layerNdx * aspectRequirements.imageMipTailStride);
- deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageWriteMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, *m_logicalDevice, DE_NULL))));
+ deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageWriteMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, getDevice(), DE_NULL))));
imageWriteMipTailBinds.push_back(imageWriteMipTailMemoryBind);
}
if ((aspectRequirements.formatProperties.flags & VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT) && aspectRequirements.imageMipTailFirstLod < imageSparseInfo.mipLevels)
{
- const VkSparseMemoryBind imageReadMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, *m_logicalDevice,
+ const VkSparseMemoryBind imageReadMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, getDevice(),
aspectRequirements.imageMipTailSize, memoryType, aspectRequirements.imageMipTailOffset);
- deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageReadMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, *m_logicalDevice, DE_NULL))));
+ deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageReadMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, getDevice(), DE_NULL))));
imageReadMipTailBinds.push_back(imageReadMipTailMemoryBind);
- const VkSparseMemoryBind imageWriteMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, *m_logicalDevice,
+ const VkSparseMemoryBind imageWriteMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, getDevice(),
aspectRequirements.imageMipTailSize, memoryType, aspectRequirements.imageMipTailOffset);
- deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageWriteMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, *m_logicalDevice, DE_NULL))));
+ deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageWriteMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, getDevice(), DE_NULL))));
imageWriteMipTailBinds.push_back(imageWriteMipTailMemoryBind);
}
}
// Create command buffer for compute and transfer oparations
- const Unique<VkCommandPool> commandPool (makeCommandPool(deviceInterface, *m_logicalDevice, computeQueue.queueFamilyIndex));
- const Unique<VkCommandBuffer> commandBuffer(makeCommandBuffer(deviceInterface, *m_logicalDevice, *commandPool));
+ const Unique<VkCommandPool> commandPool (makeCommandPool(deviceInterface, getDevice(), computeQueue.queueFamilyIndex));
+ const Unique<VkCommandBuffer> commandBuffer(makeCommandBuffer(deviceInterface, getDevice(), *commandPool));
std::vector<VkBufferImageCopy> bufferImageCopy(imageSparseInfo.mipLevels);
for (deUint32 mipLevelNdx = 0u; mipLevelNdx < imageSparseInfo.mipLevels; ++mipLevelNdx)
{
bufferImageCopy[mipLevelNdx] = makeBufferImageCopy(mipLevelExtents(imageSparseInfo.extent, mipLevelNdx), imageSparseInfo.arrayLayers, mipLevelNdx, bufferOffset);
- bufferOffset += getImageMipLevelSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_format, mipLevelNdx, MEM_ALIGN_BUFFERIMAGECOPY_OFFSET);
+ bufferOffset += getImageMipLevelSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_format, mipLevelNdx, BUFFER_IMAGE_COPY_OFFSET_GRANULARITY);
}
}
// Start recording commands
beginCommandBuffer(deviceInterface, *commandBuffer);
- const deUint32 imageSizeInBytes = getImageSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_format, imageSparseInfo.mipLevels, MEM_ALIGN_BUFFERIMAGECOPY_OFFSET);
- const VkBufferCreateInfo inputBufferCreateInfo = makeBufferCreateInfo(imageSizeInBytes, VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
-
- const de::UniquePtr<Buffer> inputBuffer(new Buffer(deviceInterface, *m_logicalDevice, *allocator, inputBufferCreateInfo, MemoryRequirement::HostVisible));
+ const deUint32 imageSizeInBytes = getImageSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_format, imageSparseInfo.mipLevels, BUFFER_IMAGE_COPY_OFFSET_GRANULARITY);
+ const VkBufferCreateInfo inputBufferCreateInfo = makeBufferCreateInfo(imageSizeInBytes, VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
+ const Unique<VkBuffer> inputBuffer (createBuffer(deviceInterface, getDevice(), &inputBufferCreateInfo));
+ const de::UniquePtr<Allocation> inputBufferAlloc (bindBuffer(deviceInterface, getDevice(), getAllocator(), *inputBuffer, MemoryRequirement::HostVisible));
std::vector<deUint8> referenceData(imageSizeInBytes);
deMemset(&referenceData[bufferOffset], mipLevelNdx + 1u, mipLevelSizeInBytes);
}
- deMemcpy(inputBuffer->getAllocation().getHostPtr(), &referenceData[0], imageSizeInBytes);
+ deMemcpy(inputBufferAlloc->getHostPtr(), &referenceData[0], imageSizeInBytes);
- flushMappedMemoryRange(deviceInterface, *m_logicalDevice, inputBuffer->getAllocation().getMemory(), inputBuffer->getAllocation().getOffset(), imageSizeInBytes);
+ flushMappedMemoryRange(deviceInterface, getDevice(), inputBufferAlloc->getMemory(), inputBufferAlloc->getOffset(), imageSizeInBytes);
{
const VkBufferMemoryBarrier inputBufferBarrier = makeBufferMemoryBarrier
(
VK_ACCESS_HOST_WRITE_BIT,
VK_ACCESS_TRANSFER_READ_BIT,
- inputBuffer->get(),
+ *inputBuffer,
0u,
imageSizeInBytes
);
deviceInterface.cmdPipelineBarrier(*commandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0u, 0u, DE_NULL, 0u, DE_NULL, 1u, &imageSparseTransferDstBarrier);
}
- deviceInterface.cmdCopyBufferToImage(*commandBuffer, inputBuffer->get(), *imageRead, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, static_cast<deUint32>(bufferImageCopy.size()), &bufferImageCopy[0]);
+ deviceInterface.cmdCopyBufferToImage(*commandBuffer, *inputBuffer, *imageRead, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, static_cast<deUint32>(bufferImageCopy.size()), &bufferImageCopy[0]);
{
const VkImageMemoryBarrier imageSparseTransferSrcBarrier = makeImageMemoryBarrier
const Unique<VkDescriptorSetLayout> descriptorSetLayout(
DescriptorSetLayoutBuilder()
.addSingleBinding(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, VK_SHADER_STAGE_COMPUTE_BIT)
- .build(deviceInterface, *m_logicalDevice));
+ .build(deviceInterface, getDevice()));
- Unique<VkPipelineLayout> pipelineLayout(makePipelineLayout(deviceInterface, *m_logicalDevice, *descriptorSetLayout));
+ Unique<VkPipelineLayout> pipelineLayout(makePipelineLayout(deviceInterface, getDevice(), *descriptorSetLayout));
Unique<VkDescriptorPool> descriptorPool(
DescriptorPoolBuilder()
.addType(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, imageSparseInfo.mipLevels)
- .build(deviceInterface, *m_logicalDevice, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, imageSparseInfo.mipLevels));
+ .build(deviceInterface, getDevice(), VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, imageSparseInfo.mipLevels));
typedef de::SharedPtr< Unique<VkImageView> > SharedVkImageView;
std::vector<SharedVkImageView> imageViews;
name << "comp" << mipLevelNdx;
// Create and bind compute pipeline
- Unique<VkShaderModule> shaderModule(createShaderModule(deviceInterface, *m_logicalDevice, m_context.getBinaryCollection().get(name.str()), DE_NULL));
+ Unique<VkShaderModule> shaderModule(createShaderModule(deviceInterface, getDevice(), m_context.getBinaryCollection().get(name.str()), DE_NULL));
- computePipelines[mipLevelNdx] = makeVkSharedPtr(makeComputePipeline(deviceInterface, *m_logicalDevice, *pipelineLayout, *shaderModule));
+ computePipelines[mipLevelNdx] = makeVkSharedPtr(makeComputePipeline(deviceInterface, getDevice(), *pipelineLayout, *shaderModule));
VkPipeline computePipeline = **computePipelines[mipLevelNdx];
deviceInterface.cmdBindPipeline(*commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, computePipeline);
// Create and bind descriptor set
- descriptorSets[mipLevelNdx] = makeVkSharedPtr(makeDescriptorSet(deviceInterface, *m_logicalDevice, *descriptorPool, *descriptorSetLayout));
+ descriptorSets[mipLevelNdx] = makeVkSharedPtr(makeDescriptorSet(deviceInterface, getDevice(), *descriptorPool, *descriptorSetLayout));
VkDescriptorSet descriptorSet = **descriptorSets[mipLevelNdx];
// Select which mipmap level to bind
const VkImageSubresourceRange subresourceRange = makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, mipLevelNdx, 1u, 0u, imageSparseInfo.arrayLayers);
- imageViews[mipLevelNdx] = makeVkSharedPtr(makeImageView(deviceInterface, *m_logicalDevice, *imageWrite, mapImageViewType(m_imageType), imageSparseInfo.format, subresourceRange));
+ imageViews[mipLevelNdx] = makeVkSharedPtr(makeImageView(deviceInterface, getDevice(), *imageWrite, mapImageViewType(m_imageType), imageSparseInfo.format, subresourceRange));
VkImageView imageView = **imageViews[mipLevelNdx];
const VkDescriptorImageInfo sparseImageInfo = makeDescriptorImageInfo(DE_NULL, imageView, VK_IMAGE_LAYOUT_GENERAL);
DescriptorSetUpdateBuilder()
.writeSingle(descriptorSet, DescriptorSetUpdateBuilder::Location::binding(0u), VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, &sparseImageInfo)
- .update(deviceInterface, *m_logicalDevice);
+ .update(deviceInterface, getDevice());
deviceInterface.cmdBindDescriptorSets(*commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *pipelineLayout, 0u, 1u, &descriptorSet, 0u, DE_NULL);
deviceInterface.cmdPipelineBarrier(*commandBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0u, 1u, &memoryBarrier, 0u, DE_NULL, 0u, DE_NULL);
}
- const VkBufferCreateInfo outputBufferCreateInfo = makeBufferCreateInfo(imageSizeInBytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT);
- const de::UniquePtr<Buffer> outputBuffer (new Buffer(deviceInterface, *m_logicalDevice, *allocator, outputBufferCreateInfo, MemoryRequirement::HostVisible));
+ const VkBufferCreateInfo outputBufferCreateInfo = makeBufferCreateInfo(imageSizeInBytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT);
+ const Unique<VkBuffer> outputBuffer (createBuffer(deviceInterface, getDevice(), &outputBufferCreateInfo));
+ const de::UniquePtr<Allocation> outputBufferAlloc (bindBuffer(deviceInterface, getDevice(), getAllocator(), *outputBuffer, MemoryRequirement::HostVisible));
- deviceInterface.cmdCopyImageToBuffer(*commandBuffer, *imageRead, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, outputBuffer->get(), static_cast<deUint32>(bufferImageCopy.size()), &bufferImageCopy[0]);
+ deviceInterface.cmdCopyImageToBuffer(*commandBuffer, *imageRead, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *outputBuffer, static_cast<deUint32>(bufferImageCopy.size()), &bufferImageCopy[0]);
{
const VkBufferMemoryBarrier outputBufferBarrier = makeBufferMemoryBarrier
(
VK_ACCESS_TRANSFER_WRITE_BIT,
VK_ACCESS_HOST_READ_BIT,
- outputBuffer->get(),
+ *outputBuffer,
0u,
imageSizeInBytes
);
const VkPipelineStageFlags stageBits[] = { VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT };
// Submit commands for execution and wait for completion
- submitCommandsAndWait(deviceInterface, *m_logicalDevice, computeQueue.queueHandle, *commandBuffer, 2u, imageMemoryBindSemaphores, stageBits);
+ submitCommandsAndWait(deviceInterface, getDevice(), computeQueue.queueHandle, *commandBuffer, 2u, imageMemoryBindSemaphores, stageBits);
// Retrieve data from buffer to host memory
- const Allocation& allocation = outputBuffer->getAllocation();
- invalidateMappedMemoryRange(deviceInterface, *m_logicalDevice, allocation.getMemory(), allocation.getOffset(), imageSizeInBytes);
+ invalidateMappedMemoryRange(deviceInterface, getDevice(), outputBufferAlloc->getMemory(), outputBufferAlloc->getOffset(), imageSizeInBytes);
- const deUint8* outputData = static_cast<const deUint8*>(allocation.getHostPtr());
+ const deUint8* outputData = static_cast<const deUint8*>(outputBufferAlloc->getHostPtr());
// Wait for sparse queue to become idle
deviceInterface.queueWaitIdle(sparseQueue.queueHandle);
tcu::TestStatus ImageSparseBindingInstance::iterate (void)
{
- const InstanceInterface& instance = m_context.getInstanceInterface();
- const DeviceInterface& deviceInterface = m_context.getDeviceInterface();
- const VkPhysicalDevice physicalDevice = m_context.getPhysicalDevice();
- VkImageCreateInfo imageSparseInfo;
- std::vector<DeviceMemoryUniquePtr> deviceMemUniquePtrVec;
+ const InstanceInterface& instance = m_context.getInstanceInterface();
+ const DeviceInterface& deviceInterface = m_context.getDeviceInterface();
+ const VkPhysicalDevice physicalDevice = m_context.getPhysicalDevice();
+ VkImageCreateInfo imageSparseInfo;
+ std::vector<DeviceMemorySp> deviceMemUniquePtrVec;
// Check if image size does not exceed device limits
if (!isImageSizeSupported(instance, physicalDevice, m_imageType, m_imageSize))
createDeviceSupportingQueues(queueRequirements);
}
- const de::UniquePtr<Allocator> allocator(new SimpleAllocator(deviceInterface, *m_logicalDevice, getPhysicalDeviceMemoryProperties(instance, physicalDevice)));
-
const Queue& sparseQueue = getQueue(VK_QUEUE_SPARSE_BINDING_BIT, 0);
const Queue& computeQueue = getQueue(VK_QUEUE_COMPUTE_BIT, 0);
}
// Create sparse image
- const Unique<VkImage> imageSparse(createImage(deviceInterface, *m_logicalDevice, &imageSparseInfo));
+ const Unique<VkImage> imageSparse(createImage(deviceInterface, getDevice(), &imageSparseInfo));
// Create sparse image memory bind semaphore
- const Unique<VkSemaphore> imageMemoryBindSemaphore(makeSemaphore(deviceInterface, *m_logicalDevice));
+ const Unique<VkSemaphore> imageMemoryBindSemaphore(makeSemaphore(deviceInterface, getDevice()));
// Get sparse image general memory requirements
- const VkMemoryRequirements imageSparseMemRequirements = getImageMemoryRequirements(deviceInterface, *m_logicalDevice, *imageSparse);
+ const VkMemoryRequirements imageSparseMemRequirements = getImageMemoryRequirements(deviceInterface, getDevice(), *imageSparse);
// Check if required image memory size does not exceed device limits
if (imageSparseMemRequirements.size > getPhysicalDeviceProperties(instance, physicalDevice).limits.sparseAddressSpaceSize)
for (deUint32 sparseBindNdx = 0; sparseBindNdx < numSparseBinds; ++sparseBindNdx)
{
- const VkSparseMemoryBind sparseMemoryBind = makeSparseMemoryBind(deviceInterface, *m_logicalDevice,
+ const VkSparseMemoryBind sparseMemoryBind = makeSparseMemoryBind(deviceInterface, getDevice(),
imageSparseMemRequirements.alignment, memoryType, imageSparseMemRequirements.alignment * sparseBindNdx);
- deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(sparseMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, *m_logicalDevice, DE_NULL))));
+ deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(sparseMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, getDevice(), DE_NULL))));
sparseMemoryBinds.push_back(sparseMemoryBind);
}
}
// Create command buffer for compute and transfer oparations
- const Unique<VkCommandPool> commandPool(makeCommandPool(deviceInterface, *m_logicalDevice, computeQueue.queueFamilyIndex));
- const Unique<VkCommandBuffer> commandBuffer(makeCommandBuffer(deviceInterface, *m_logicalDevice, *commandPool));
+ const Unique<VkCommandPool> commandPool(makeCommandPool(deviceInterface, getDevice(), computeQueue.queueFamilyIndex));
+ const Unique<VkCommandBuffer> commandBuffer(makeCommandBuffer(deviceInterface, getDevice(), *commandPool));
std::vector<VkBufferImageCopy> bufferImageCopy(imageSparseInfo.mipLevels);
for (deUint32 mipmapNdx = 0; mipmapNdx < imageSparseInfo.mipLevels; mipmapNdx++)
{
bufferImageCopy[mipmapNdx] = makeBufferImageCopy(mipLevelExtents(imageSparseInfo.extent, mipmapNdx), imageSparseInfo.arrayLayers, mipmapNdx, static_cast<VkDeviceSize>(bufferOffset));
- bufferOffset += getImageMipLevelSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_format, mipmapNdx, MEM_ALIGN_BUFFERIMAGECOPY_OFFSET);
+ bufferOffset += getImageMipLevelSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_format, mipmapNdx, BUFFER_IMAGE_COPY_OFFSET_GRANULARITY);
}
}
// Start recording commands
beginCommandBuffer(deviceInterface, *commandBuffer);
- const deUint32 imageSizeInBytes = getImageSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_format, imageSparseInfo.mipLevels, MEM_ALIGN_BUFFERIMAGECOPY_OFFSET);
- const VkBufferCreateInfo inputBufferCreateInfo = makeBufferCreateInfo(imageSizeInBytes, VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
-
- const de::UniquePtr<Buffer> inputBuffer(new Buffer(deviceInterface, *m_logicalDevice, *allocator, inputBufferCreateInfo, MemoryRequirement::HostVisible));
+ const deUint32 imageSizeInBytes = getImageSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_format, imageSparseInfo.mipLevels, BUFFER_IMAGE_COPY_OFFSET_GRANULARITY);
+ const VkBufferCreateInfo inputBufferCreateInfo = makeBufferCreateInfo(imageSizeInBytes, VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
+ const Unique<VkBuffer> inputBuffer (createBuffer(deviceInterface, getDevice(), &inputBufferCreateInfo));
+ const de::UniquePtr<Allocation> inputBufferAlloc (bindBuffer(deviceInterface, getDevice(), getAllocator(), *inputBuffer, MemoryRequirement::HostVisible));
std::vector<deUint8> referenceData(imageSizeInBytes);
referenceData[valueNdx] = static_cast<deUint8>((valueNdx % imageSparseMemRequirements.alignment) + 1u);
}
- deMemcpy(inputBuffer->getAllocation().getHostPtr(), &referenceData[0], imageSizeInBytes);
+ deMemcpy(inputBufferAlloc->getHostPtr(), &referenceData[0], imageSizeInBytes);
- flushMappedMemoryRange(deviceInterface, *m_logicalDevice, inputBuffer->getAllocation().getMemory(), inputBuffer->getAllocation().getOffset(), imageSizeInBytes);
+ flushMappedMemoryRange(deviceInterface, getDevice(), inputBufferAlloc->getMemory(), inputBufferAlloc->getOffset(), imageSizeInBytes);
{
const VkBufferMemoryBarrier inputBufferBarrier = makeBufferMemoryBarrier
(
VK_ACCESS_HOST_WRITE_BIT,
VK_ACCESS_TRANSFER_READ_BIT,
- inputBuffer->get(),
+ *inputBuffer,
0u,
imageSizeInBytes
);
deviceInterface.cmdPipelineBarrier(*commandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0u, 0u, DE_NULL, 0u, DE_NULL, 1u, &imageSparseTransferDstBarrier);
}
- deviceInterface.cmdCopyBufferToImage(*commandBuffer, inputBuffer->get(), *imageSparse, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, static_cast<deUint32>(bufferImageCopy.size()), &bufferImageCopy[0]);
+ deviceInterface.cmdCopyBufferToImage(*commandBuffer, *inputBuffer, *imageSparse, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, static_cast<deUint32>(bufferImageCopy.size()), &bufferImageCopy[0]);
{
const VkImageMemoryBarrier imageSparseTransferSrcBarrier = makeImageMemoryBarrier
deviceInterface.cmdPipelineBarrier(*commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0u, 0u, DE_NULL, 0u, DE_NULL, 1u, &imageSparseTransferSrcBarrier);
}
- const VkBufferCreateInfo outputBufferCreateInfo = makeBufferCreateInfo(imageSizeInBytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT);
- const de::UniquePtr<Buffer> outputBuffer(new Buffer(deviceInterface, *m_logicalDevice, *allocator, outputBufferCreateInfo, MemoryRequirement::HostVisible));
+ const VkBufferCreateInfo outputBufferCreateInfo = makeBufferCreateInfo(imageSizeInBytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT);
+ const Unique<VkBuffer> outputBuffer (createBuffer(deviceInterface, getDevice(), &outputBufferCreateInfo));
+ const de::UniquePtr<Allocation> outputBufferAlloc (bindBuffer(deviceInterface, getDevice(), getAllocator(), *outputBuffer, MemoryRequirement::HostVisible));
- deviceInterface.cmdCopyImageToBuffer(*commandBuffer, *imageSparse, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, outputBuffer->get(), static_cast<deUint32>(bufferImageCopy.size()), &bufferImageCopy[0]);
+ deviceInterface.cmdCopyImageToBuffer(*commandBuffer, *imageSparse, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *outputBuffer, static_cast<deUint32>(bufferImageCopy.size()), &bufferImageCopy[0]);
{
const VkBufferMemoryBarrier outputBufferBarrier = makeBufferMemoryBarrier
(
VK_ACCESS_TRANSFER_WRITE_BIT,
VK_ACCESS_HOST_READ_BIT,
- outputBuffer->get(),
+ *outputBuffer,
0u,
imageSizeInBytes
);
const VkPipelineStageFlags stageBits[] = { VK_PIPELINE_STAGE_TRANSFER_BIT };
// Submit commands for execution and wait for completion
- submitCommandsAndWait(deviceInterface, *m_logicalDevice, computeQueue.queueHandle, *commandBuffer, 1u, &imageMemoryBindSemaphore.get(), stageBits);
+ submitCommandsAndWait(deviceInterface, getDevice(), computeQueue.queueHandle, *commandBuffer, 1u, &imageMemoryBindSemaphore.get(), stageBits);
// Retrieve data from buffer to host memory
- const Allocation& allocation = outputBuffer->getAllocation();
- invalidateMappedMemoryRange(deviceInterface, *m_logicalDevice, allocation.getMemory(), allocation.getOffset(), imageSizeInBytes);
+ invalidateMappedMemoryRange(deviceInterface, getDevice(), outputBufferAlloc->getMemory(), outputBufferAlloc->getOffset(), imageSizeInBytes);
- const deUint8* outputData = static_cast<const deUint8*>(allocation.getHostPtr());
+ const deUint8* outputData = static_cast<const deUint8*>(outputBufferAlloc->getHostPtr());
// Wait for sparse queue to become idle
deviceInterface.queueWaitIdle(sparseQueue.queueHandle);
VkImageCreateInfo imageCreateInfo;
VkSparseImageMemoryRequirements aspectRequirements;
VkExtent3D imageGranularity;
- std::vector<DeviceMemoryUniquePtr> deviceMemUniquePtrVec;
+ std::vector<DeviceMemorySp> deviceMemUniquePtrVec;
// Check if image size does not exceed device limits
if (!isImageSizeSupported(instance, physicalDevice, m_imageType, m_imageSize))
createDeviceSupportingQueues(queueRequirements);
}
- const de::UniquePtr<Allocator> allocator(new SimpleAllocator(deviceInterface, *m_logicalDevice, getPhysicalDeviceMemoryProperties(instance, physicalDevice)));
-
const Queue& sparseQueue = getQueue(VK_QUEUE_SPARSE_BINDING_BIT, 0);
const Queue& computeQueue = getQueue(VK_QUEUE_COMPUTE_BIT, 0);
// Create sparse image
- const Unique<VkImage> sparseImage(createImage(deviceInterface, *m_logicalDevice, &imageCreateInfo));
+ const Unique<VkImage> sparseImage(createImage(deviceInterface, getDevice(), &imageCreateInfo));
// Create sparse image memory bind semaphore
- const Unique<VkSemaphore> imageMemoryBindSemaphore(makeSemaphore(deviceInterface, *m_logicalDevice));
+ const Unique<VkSemaphore> imageMemoryBindSemaphore(makeSemaphore(deviceInterface, getDevice()));
{
// Get image general memory requirements
- const VkMemoryRequirements imageMemoryRequirements = getImageMemoryRequirements(deviceInterface, *m_logicalDevice, *sparseImage);
+ const VkMemoryRequirements imageMemoryRequirements = getImageMemoryRequirements(deviceInterface, getDevice(), *sparseImage);
if (imageMemoryRequirements.size > physicalDeviceProperties.limits.sparseAddressSpaceSize)
TCU_THROW(NotSupportedError, "Required memory size for sparse resource exceeds device limits");
DE_ASSERT((imageMemoryRequirements.size % imageMemoryRequirements.alignment) == 0);
// Get sparse image sparse memory requirements
- const std::vector<VkSparseImageMemoryRequirements> sparseMemoryRequirements = getImageSparseMemoryRequirements(deviceInterface, *m_logicalDevice, *sparseImage);
+ const std::vector<VkSparseImageMemoryRequirements> sparseMemoryRequirements = getImageSparseMemoryRequirements(deviceInterface, getDevice(), *sparseImage);
DE_ASSERT(sparseMemoryRequirements.size() != 0);
extent.height = (y == numSparseBinds.y() - 1) ? lastBlockExtent.y() : imageGranularity.height;
extent.depth = (z == numSparseBinds.z() - 1) ? lastBlockExtent.z() : imageGranularity.depth;
- const VkSparseImageMemoryBind imageMemoryBind = makeSparseImageMemoryBind(deviceInterface, *m_logicalDevice,
+ const VkSparseImageMemoryBind imageMemoryBind = makeSparseImageMemoryBind(deviceInterface, getDevice(),
imageMemoryRequirements.alignment, memoryType, subresource, offset, extent);
- deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, *m_logicalDevice, DE_NULL))));
+ deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, getDevice(), DE_NULL))));
imageResidencyMemoryBinds.push_back(imageMemoryBind);
}
if (!(aspectRequirements.formatProperties.flags & VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT) && aspectRequirements.imageMipTailFirstLod < imageCreateInfo.mipLevels)
{
- const VkSparseMemoryBind imageMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, *m_logicalDevice,
+ const VkSparseMemoryBind imageMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, getDevice(),
aspectRequirements.imageMipTailSize, memoryType, aspectRequirements.imageMipTailOffset + layerNdx * aspectRequirements.imageMipTailStride);
- deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, *m_logicalDevice, DE_NULL))));
+ deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, getDevice(), DE_NULL))));
imageMipTailMemoryBinds.push_back(imageMipTailMemoryBind);
}
if ((aspectRequirements.formatProperties.flags & VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT) && aspectRequirements.imageMipTailFirstLod < imageCreateInfo.mipLevels)
{
- const VkSparseMemoryBind imageMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, *m_logicalDevice,
+ const VkSparseMemoryBind imageMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, getDevice(),
aspectRequirements.imageMipTailSize, memoryType, aspectRequirements.imageMipTailOffset);
- deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, *m_logicalDevice, DE_NULL))));
+ deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, getDevice(), DE_NULL))));
imageMipTailMemoryBinds.push_back(imageMipTailMemoryBind);
}
}
// Create command buffer for compute and transfer oparations
- const Unique<VkCommandPool> commandPool(makeCommandPool(deviceInterface, *m_logicalDevice, computeQueue.queueFamilyIndex));
- const Unique<VkCommandBuffer> commandBuffer(makeCommandBuffer(deviceInterface, *m_logicalDevice, *commandPool));
+ const Unique<VkCommandPool> commandPool(makeCommandPool(deviceInterface, getDevice(), computeQueue.queueFamilyIndex));
+ const Unique<VkCommandBuffer> commandBuffer(makeCommandBuffer(deviceInterface, getDevice(), *commandPool));
// Start recording commands
beginCommandBuffer(deviceInterface, *commandBuffer);
const Unique<VkDescriptorSetLayout> descriptorSetLayout(
DescriptorSetLayoutBuilder()
.addSingleBinding(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, VK_SHADER_STAGE_COMPUTE_BIT)
- .build(deviceInterface, *m_logicalDevice));
+ .build(deviceInterface, getDevice()));
// Create and bind compute pipeline
- const Unique<VkShaderModule> shaderModule(createShaderModule(deviceInterface, *m_logicalDevice, m_context.getBinaryCollection().get("comp"), DE_NULL));
- const Unique<VkPipelineLayout> pipelineLayout(makePipelineLayout(deviceInterface, *m_logicalDevice, *descriptorSetLayout));
- const Unique<VkPipeline> computePipeline(makeComputePipeline(deviceInterface, *m_logicalDevice, *pipelineLayout, *shaderModule));
+ const Unique<VkShaderModule> shaderModule(createShaderModule(deviceInterface, getDevice(), m_context.getBinaryCollection().get("comp"), DE_NULL));
+ const Unique<VkPipelineLayout> pipelineLayout(makePipelineLayout(deviceInterface, getDevice(), *descriptorSetLayout));
+ const Unique<VkPipeline> computePipeline(makeComputePipeline(deviceInterface, getDevice(), *pipelineLayout, *shaderModule));
deviceInterface.cmdBindPipeline(*commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *computePipeline);
const Unique<VkDescriptorPool> descriptorPool(
DescriptorPoolBuilder()
.addType(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1u)
- .build(deviceInterface, *m_logicalDevice, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 1u));
+ .build(deviceInterface, getDevice(), VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 1u));
- const Unique<VkDescriptorSet> descriptorSet(makeDescriptorSet(deviceInterface, *m_logicalDevice, *descriptorPool, *descriptorSetLayout));
+ const Unique<VkDescriptorSet> descriptorSet(makeDescriptorSet(deviceInterface, getDevice(), *descriptorPool, *descriptorSetLayout));
const VkImageSubresourceRange subresourceRange = makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, getNumLayers(m_imageType, m_imageSize));
- const Unique<VkImageView> imageView(makeImageView(deviceInterface, *m_logicalDevice, *sparseImage, mapImageViewType(m_imageType), mapTextureFormat(m_format), subresourceRange));
+ const Unique<VkImageView> imageView(makeImageView(deviceInterface, getDevice(), *sparseImage, mapImageViewType(m_imageType), mapTextureFormat(m_format), subresourceRange));
const VkDescriptorImageInfo sparseImageInfo = makeDescriptorImageInfo(DE_NULL, *imageView, VK_IMAGE_LAYOUT_GENERAL);
DescriptorSetUpdateBuilder()
.writeSingle(*descriptorSet, DescriptorSetUpdateBuilder::Location::binding(0u), VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, &sparseImageInfo)
- .update(deviceInterface, *m_logicalDevice);
+ .update(deviceInterface, getDevice());
deviceInterface.cmdBindDescriptorSets(*commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *pipelineLayout, 0u, 1u, &descriptorSet.get(), 0u, DE_NULL);
deviceInterface.cmdPipelineBarrier(*commandBuffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0u, 0u, DE_NULL, 0u, DE_NULL, 1u, &sparseImageTrasferBarrier);
}
- const deUint32 imageSizeInBytes = getNumPixels(m_imageType, m_imageSize) * tcu::getPixelSize(m_format);
- const VkBufferCreateInfo outputBufferCreateInfo = makeBufferCreateInfo(imageSizeInBytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT);
-
- const de::UniquePtr<Buffer> outputBuffer(new Buffer(deviceInterface, *m_logicalDevice, *allocator, outputBufferCreateInfo, MemoryRequirement::HostVisible));
+ const deUint32 imageSizeInBytes = getNumPixels(m_imageType, m_imageSize) * tcu::getPixelSize(m_format);
+ const VkBufferCreateInfo outputBufferCreateInfo = makeBufferCreateInfo(imageSizeInBytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT);
+ const Unique<VkBuffer> outputBuffer (createBuffer(deviceInterface, getDevice(), &outputBufferCreateInfo));
+ const de::UniquePtr<Allocation> outputBufferAlloc (bindBuffer(deviceInterface, getDevice(), getAllocator(), *outputBuffer, MemoryRequirement::HostVisible));
{
const VkBufferImageCopy bufferImageCopy = makeBufferImageCopy(imageCreateInfo.extent, imageCreateInfo.arrayLayers);
- deviceInterface.cmdCopyImageToBuffer(*commandBuffer, *sparseImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, outputBuffer->get(), 1u, &bufferImageCopy);
+ deviceInterface.cmdCopyImageToBuffer(*commandBuffer, *sparseImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *outputBuffer, 1u, &bufferImageCopy);
}
{
(
VK_ACCESS_TRANSFER_WRITE_BIT,
VK_ACCESS_HOST_READ_BIT,
- outputBuffer->get(),
+ *outputBuffer,
0u,
imageSizeInBytes
);
const VkPipelineStageFlags stageBits[] = { VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT };
// Submit commands for execution and wait for completion
- submitCommandsAndWait(deviceInterface, *m_logicalDevice, computeQueue.queueHandle, *commandBuffer, 1u, &imageMemoryBindSemaphore.get(), stageBits);
+ submitCommandsAndWait(deviceInterface, getDevice(), computeQueue.queueHandle, *commandBuffer, 1u, &imageMemoryBindSemaphore.get(), stageBits);
// Retrieve data from buffer to host memory
- const Allocation& allocation = outputBuffer->getAllocation();
- invalidateMappedMemoryRange(deviceInterface, *m_logicalDevice, allocation.getMemory(), allocation.getOffset(), imageSizeInBytes);
+ invalidateMappedMemoryRange(deviceInterface, getDevice(), outputBufferAlloc->getMemory(), outputBufferAlloc->getOffset(), imageSizeInBytes);
- const deUint8* outputData = static_cast<const deUint8*>(allocation.getHostPtr());
+ const deUint8* outputData = static_cast<const deUint8*>(outputBufferAlloc->getHostPtr());
const tcu::ConstPixelBufferAccess pixelBuffer = tcu::ConstPixelBufferAccess(m_format, gridSize.x(), gridSize.y(), gridSize.z(), outputData);
// Wait for sparse queue to become idle
tcu::TestStatus MipmapSparseResidencyInstance::iterate (void)
{
- const InstanceInterface& instance = m_context.getInstanceInterface();
- const DeviceInterface& deviceInterface = m_context.getDeviceInterface();
- const VkPhysicalDevice physicalDevice = m_context.getPhysicalDevice();
- VkImageCreateInfo imageSparseInfo;
- std::vector<DeviceMemoryUniquePtr> deviceMemUniquePtrVec;
+ const InstanceInterface& instance = m_context.getInstanceInterface();
+ const DeviceInterface& deviceInterface = m_context.getDeviceInterface();
+ const VkPhysicalDevice physicalDevice = m_context.getPhysicalDevice();
+ VkImageCreateInfo imageSparseInfo;
+ std::vector<DeviceMemorySp> deviceMemUniquePtrVec;
// Check if image size does not exceed device limits
if (!isImageSizeSupported(instance, physicalDevice, m_imageType, m_imageSize))
createDeviceSupportingQueues(queueRequirements);
}
- const de::UniquePtr<Allocator> allocator(new SimpleAllocator(deviceInterface, *m_logicalDevice, getPhysicalDeviceMemoryProperties(instance, physicalDevice)));
-
const Queue& sparseQueue = getQueue(VK_QUEUE_SPARSE_BINDING_BIT, 0);
const Queue& computeQueue = getQueue(VK_QUEUE_COMPUTE_BIT, 0);
// Create sparse image
- const Unique<VkImage> imageSparse(createImage(deviceInterface, *m_logicalDevice, &imageSparseInfo));
+ const Unique<VkImage> imageSparse(createImage(deviceInterface, getDevice(), &imageSparseInfo));
// Create sparse image memory bind semaphore
- const Unique<VkSemaphore> imageMemoryBindSemaphore(makeSemaphore(deviceInterface, *m_logicalDevice));
+ const Unique<VkSemaphore> imageMemoryBindSemaphore(makeSemaphore(deviceInterface, getDevice()));
{
// Get sparse image general memory requirements
- const VkMemoryRequirements imageMemoryRequirements = getImageMemoryRequirements(deviceInterface, *m_logicalDevice, *imageSparse);
+ const VkMemoryRequirements imageMemoryRequirements = getImageMemoryRequirements(deviceInterface, getDevice(), *imageSparse);
// Check if required image memory size does not exceed device limits
if (imageMemoryRequirements.size > getPhysicalDeviceProperties(instance, physicalDevice).limits.sparseAddressSpaceSize)
DE_ASSERT((imageMemoryRequirements.size % imageMemoryRequirements.alignment) == 0);
// Get sparse image sparse memory requirements
- const std::vector<VkSparseImageMemoryRequirements> sparseMemoryRequirements = getImageSparseMemoryRequirements(deviceInterface, *m_logicalDevice, *imageSparse);
+ const std::vector<VkSparseImageMemoryRequirements> sparseMemoryRequirements = getImageSparseMemoryRequirements(deviceInterface, getDevice(), *imageSparse);
DE_ASSERT(sparseMemoryRequirements.size() != 0);
const deUint32 numSparseBlocks = sparseBlocks.x() * sparseBlocks.y() * sparseBlocks.z();
const VkImageSubresource subresource = { aspectMask, mipLevelNdx, layerNdx };
- const VkSparseImageMemoryBind imageMemoryBind = makeSparseImageMemoryBind(deviceInterface, *m_logicalDevice,
+ const VkSparseImageMemoryBind imageMemoryBind = makeSparseImageMemoryBind(deviceInterface, getDevice(),
imageMemoryRequirements.alignment * numSparseBlocks, memoryType, subresource, makeOffset3D(0u, 0u, 0u), mipExtent);
- deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, *m_logicalDevice, DE_NULL))));
+ deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, getDevice(), DE_NULL))));
imageResidencyMemoryBinds.push_back(imageMemoryBind);
}
if (!(aspectRequirements.formatProperties.flags & VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT) && aspectRequirements.imageMipTailFirstLod < imageSparseInfo.mipLevels)
{
- const VkSparseMemoryBind imageMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, *m_logicalDevice,
+ const VkSparseMemoryBind imageMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, getDevice(),
aspectRequirements.imageMipTailSize, memoryType, aspectRequirements.imageMipTailOffset + layerNdx * aspectRequirements.imageMipTailStride);
- deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, *m_logicalDevice, DE_NULL))));
+ deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, getDevice(), DE_NULL))));
imageMipTailMemoryBinds.push_back(imageMipTailMemoryBind);
}
if ((aspectRequirements.formatProperties.flags & VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT) && aspectRequirements.imageMipTailFirstLod < imageSparseInfo.mipLevels)
{
- const VkSparseMemoryBind imageMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, *m_logicalDevice,
+ const VkSparseMemoryBind imageMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, getDevice(),
aspectRequirements.imageMipTailSize, memoryType, aspectRequirements.imageMipTailOffset);
- deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, *m_logicalDevice, DE_NULL))));
+ deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, getDevice(), DE_NULL))));
imageMipTailMemoryBinds.push_back(imageMipTailMemoryBind);
}
}
// Create command buffer for compute and transfer oparations
- const Unique<VkCommandPool> commandPool(makeCommandPool(deviceInterface, *m_logicalDevice, computeQueue.queueFamilyIndex));
- const Unique<VkCommandBuffer> commandBuffer(makeCommandBuffer(deviceInterface, *m_logicalDevice, *commandPool));
+ const Unique<VkCommandPool> commandPool(makeCommandPool(deviceInterface, getDevice(), computeQueue.queueFamilyIndex));
+ const Unique<VkCommandBuffer> commandBuffer(makeCommandBuffer(deviceInterface, getDevice(), *commandPool));
std::vector <VkBufferImageCopy> bufferImageCopy(imageSparseInfo.mipLevels);
for (deUint32 mipmapNdx = 0; mipmapNdx < imageSparseInfo.mipLevels; mipmapNdx++)
{
bufferImageCopy[mipmapNdx] = makeBufferImageCopy(mipLevelExtents(imageSparseInfo.extent, mipmapNdx), imageSparseInfo.arrayLayers, mipmapNdx, static_cast<VkDeviceSize>(bufferOffset));
- bufferOffset += getImageMipLevelSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_format, mipmapNdx, MEM_ALIGN_BUFFERIMAGECOPY_OFFSET);
+ bufferOffset += getImageMipLevelSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_format, mipmapNdx, BUFFER_IMAGE_COPY_OFFSET_GRANULARITY);
}
}
// Start recording commands
beginCommandBuffer(deviceInterface, *commandBuffer);
- const deUint32 imageSizeInBytes = getImageSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_format, imageSparseInfo.mipLevels, MEM_ALIGN_BUFFERIMAGECOPY_OFFSET);
- const VkBufferCreateInfo inputBufferCreateInfo = makeBufferCreateInfo(imageSizeInBytes, VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
-
- const de::UniquePtr<Buffer> inputBuffer(new Buffer(deviceInterface, *m_logicalDevice, *allocator, inputBufferCreateInfo, MemoryRequirement::HostVisible));
+ const deUint32 imageSizeInBytes = getImageSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_format, imageSparseInfo.mipLevels, BUFFER_IMAGE_COPY_OFFSET_GRANULARITY);
+ const VkBufferCreateInfo inputBufferCreateInfo = makeBufferCreateInfo(imageSizeInBytes, VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
+ const Unique<VkBuffer> inputBuffer (createBuffer(deviceInterface, getDevice(), &inputBufferCreateInfo));
+ const de::UniquePtr<Allocation> inputBufferAlloc (bindBuffer(deviceInterface, getDevice(), getAllocator(), *inputBuffer, MemoryRequirement::HostVisible));
std::vector<deUint8> referenceData(imageSizeInBytes);
- const VkMemoryRequirements imageMemoryRequirements = getImageMemoryRequirements(deviceInterface, *m_logicalDevice, *imageSparse);
+ const VkMemoryRequirements imageMemoryRequirements = getImageMemoryRequirements(deviceInterface, getDevice(), *imageSparse);
for (deUint32 valueNdx = 0; valueNdx < imageSizeInBytes; ++valueNdx)
{
referenceData[valueNdx] = static_cast<deUint8>((valueNdx % imageMemoryRequirements.alignment) + 1u);
}
- deMemcpy(inputBuffer->getAllocation().getHostPtr(), &referenceData[0], imageSizeInBytes);
+ deMemcpy(inputBufferAlloc->getHostPtr(), &referenceData[0], imageSizeInBytes);
- flushMappedMemoryRange(deviceInterface, *m_logicalDevice, inputBuffer->getAllocation().getMemory(), inputBuffer->getAllocation().getOffset(), imageSizeInBytes);
+ flushMappedMemoryRange(deviceInterface, getDevice(), inputBufferAlloc->getMemory(), inputBufferAlloc->getOffset(), imageSizeInBytes);
{
const VkBufferMemoryBarrier inputBufferBarrier = makeBufferMemoryBarrier
(
VK_ACCESS_HOST_WRITE_BIT,
VK_ACCESS_TRANSFER_READ_BIT,
- inputBuffer->get(),
+ *inputBuffer,
0u,
imageSizeInBytes
);
deviceInterface.cmdPipelineBarrier(*commandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0u, 0u, DE_NULL, 0u, DE_NULL, 1u, &imageSparseTransferDstBarrier);
}
- deviceInterface.cmdCopyBufferToImage(*commandBuffer, inputBuffer->get(), *imageSparse, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, static_cast<deUint32>(bufferImageCopy.size()), &bufferImageCopy[0]);
+ deviceInterface.cmdCopyBufferToImage(*commandBuffer, *inputBuffer, *imageSparse, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, static_cast<deUint32>(bufferImageCopy.size()), &bufferImageCopy[0]);
{
const VkImageMemoryBarrier imageSparseTransferSrcBarrier = makeImageMemoryBarrier
deviceInterface.cmdPipelineBarrier(*commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0u, 0u, DE_NULL, 0u, DE_NULL, 1u, &imageSparseTransferSrcBarrier);
}
- const VkBufferCreateInfo outputBufferCreateInfo = makeBufferCreateInfo(imageSizeInBytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT);
- const de::UniquePtr<Buffer> outputBuffer(new Buffer(deviceInterface, *m_logicalDevice, *allocator, outputBufferCreateInfo, MemoryRequirement::HostVisible));
+ const VkBufferCreateInfo outputBufferCreateInfo = makeBufferCreateInfo(imageSizeInBytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT);
+ const Unique<VkBuffer> outputBuffer (createBuffer(deviceInterface, getDevice(), &outputBufferCreateInfo));
+ const de::UniquePtr<Allocation> outputBufferAlloc (bindBuffer(deviceInterface, getDevice(), getAllocator(), *outputBuffer, MemoryRequirement::HostVisible));
- deviceInterface.cmdCopyImageToBuffer(*commandBuffer, *imageSparse, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, outputBuffer->get(), static_cast<deUint32>(bufferImageCopy.size()), &bufferImageCopy[0]);
+ deviceInterface.cmdCopyImageToBuffer(*commandBuffer, *imageSparse, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *outputBuffer, static_cast<deUint32>(bufferImageCopy.size()), &bufferImageCopy[0]);
{
const VkBufferMemoryBarrier outputBufferBarrier = makeBufferMemoryBarrier
(
VK_ACCESS_TRANSFER_WRITE_BIT,
VK_ACCESS_HOST_READ_BIT,
- outputBuffer->get(),
+ *outputBuffer,
0u,
imageSizeInBytes
);
const VkPipelineStageFlags stageBits[] = { VK_PIPELINE_STAGE_TRANSFER_BIT };
// Submit commands for execution and wait for completion
- submitCommandsAndWait(deviceInterface, *m_logicalDevice, computeQueue.queueHandle, *commandBuffer, 1u, &imageMemoryBindSemaphore.get(), stageBits);
+ submitCommandsAndWait(deviceInterface, getDevice(), computeQueue.queueHandle, *commandBuffer, 1u, &imageMemoryBindSemaphore.get(), stageBits);
// Retrieve data from buffer to host memory
- const Allocation& allocation = outputBuffer->getAllocation();
- invalidateMappedMemoryRange(deviceInterface, *m_logicalDevice, allocation.getMemory(), allocation.getOffset(), imageSizeInBytes);
+ invalidateMappedMemoryRange(deviceInterface, getDevice(), outputBufferAlloc->getMemory(), outputBufferAlloc->getOffset(), imageSizeInBytes);
- const deUint8* outputData = static_cast<const deUint8*>(allocation.getHostPtr());
+ const deUint8* outputData = static_cast<const deUint8*>(outputBufferAlloc->getHostPtr());
// Wait for sparse queue to become idle
deviceInterface.queueWaitIdle(sparseQueue.queueHandle);
VkImageCreateInfo imageResidencyInfo;
VkSparseImageMemoryRequirements aspectRequirements;
std::vector <deUint32> residencyReferenceData;
- std::vector<DeviceMemoryUniquePtr> deviceMemUniquePtrVec;
+ std::vector<DeviceMemorySp> deviceMemUniquePtrVec;
// Check if image size does not exceed device limits
if (!isImageSizeSupported(instance, physicalDevice, m_imageType, m_imageSize))
const Queue& sparseQueue = getQueue(VK_QUEUE_SPARSE_BINDING_BIT, 0);
const Queue& extractQueue = getQueue(getQueueFlags(), 0);
- // Create memory allocator for logical device
- const de::UniquePtr<Allocator> allocator(new SimpleAllocator(deviceInterface, *m_logicalDevice, getPhysicalDeviceMemoryProperties(instance, physicalDevice)));
-
// Create sparse image
- const Unique<VkImage> imageSparse(createImage(deviceInterface, *m_logicalDevice, &imageSparseInfo));
+ const Unique<VkImage> imageSparse(createImage(deviceInterface, getDevice(), &imageSparseInfo));
// Create sparse image memory bind semaphore
- const Unique<VkSemaphore> memoryBindSemaphore(makeSemaphore(deviceInterface, *m_logicalDevice));
+ const Unique<VkSemaphore> memoryBindSemaphore(makeSemaphore(deviceInterface, getDevice()));
- const deUint32 imageSparseSizeInBytes = getImageSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_format, imageSparseInfo.mipLevels, MEM_ALIGN_BUFFERIMAGECOPY_OFFSET);
+ const deUint32 imageSparseSizeInBytes = getImageSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_format, imageSparseInfo.mipLevels, BUFFER_IMAGE_COPY_OFFSET_GRANULARITY);
const deUint32 imageSizeInPixels = getImageSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_format, imageSparseInfo.mipLevels) / tcu::getPixelSize(m_format);
residencyReferenceData.assign(imageSizeInPixels, MEMORY_BLOCK_NOT_BOUND_VALUE);
{
// Get sparse image general memory requirements
- const VkMemoryRequirements imageMemoryRequirements = getImageMemoryRequirements(deviceInterface, *m_logicalDevice, *imageSparse);
+ const VkMemoryRequirements imageMemoryRequirements = getImageMemoryRequirements(deviceInterface, getDevice(), *imageSparse);
// Check if required image memory size does not exceed device limits
if (imageMemoryRequirements.size > getPhysicalDeviceProperties(instance, physicalDevice).limits.sparseAddressSpaceSize)
DE_ASSERT((imageMemoryRequirements.size % imageMemoryRequirements.alignment) == 0);
// Get sparse image sparse memory requirements
- const std::vector<VkSparseImageMemoryRequirements> sparseMemoryRequirements = getImageSparseMemoryRequirements(deviceInterface, *m_logicalDevice, *imageSparse);
+ const std::vector<VkSparseImageMemoryRequirements> sparseMemoryRequirements = getImageSparseMemoryRequirements(deviceInterface, getDevice(), *imageSparse);
DE_ASSERT(sparseMemoryRequirements.size() != 0);
const deUint32 numSparseBlocks = sparseBlocks.x() * sparseBlocks.y() * sparseBlocks.z();
const VkImageSubresource subresource = { aspectMask, mipLevelNdx, layerNdx };
- const VkSparseImageMemoryBind imageMemoryBind = makeSparseImageMemoryBind(deviceInterface, *m_logicalDevice,
+ const VkSparseImageMemoryBind imageMemoryBind = makeSparseImageMemoryBind(deviceInterface, getDevice(),
imageMemoryRequirements.alignment * numSparseBlocks, memoryType, subresource, makeOffset3D(0u, 0u, 0u), mipExtent);
- deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, *m_logicalDevice, DE_NULL))));
+ deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, getDevice(), DE_NULL))));
imageResidencyMemoryBinds.push_back(imageMemoryBind);
}
{
if (aspectRequirements.formatProperties.flags & VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT)
{
- const VkSparseMemoryBind imageMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, *m_logicalDevice,
+ const VkSparseMemoryBind imageMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, getDevice(),
aspectRequirements.imageMipTailSize, memoryType, aspectRequirements.imageMipTailOffset);
- deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, *m_logicalDevice, DE_NULL))));
+ deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, getDevice(), DE_NULL))));
imageMipTailBinds.push_back(imageMipTailMemoryBind);
}
{
for (deUint32 layerNdx = 0; layerNdx < imageSparseInfo.arrayLayers; ++layerNdx)
{
- const VkSparseMemoryBind imageMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, *m_logicalDevice,
+ const VkSparseMemoryBind imageMipTailMemoryBind = makeSparseMemoryBind(deviceInterface, getDevice(),
aspectRequirements.imageMipTailSize, memoryType, aspectRequirements.imageMipTailOffset + layerNdx * aspectRequirements.imageMipTailStride);
- deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, *m_logicalDevice, DE_NULL))));
+ deviceMemUniquePtrVec.push_back(makeVkSharedPtr(Move<VkDeviceMemory>(check<VkDeviceMemory>(imageMipTailMemoryBind.memory), Deleter<VkDeviceMemory>(deviceInterface, getDevice(), DE_NULL))));
imageMipTailBinds.push_back(imageMipTailMemoryBind);
}
imageTexelsInfo.flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
}
- const de::UniquePtr<Image> imageTexels(new Image(deviceInterface, *m_logicalDevice, *allocator, imageTexelsInfo, MemoryRequirement::Any));
+ const Unique<VkImage> imageTexels (createImage(deviceInterface, getDevice(), &imageTexelsInfo));
+ const de::UniquePtr<Allocation> imageTexelsAlloc (bindImage(deviceInterface, getDevice(), getAllocator(), *imageTexels, MemoryRequirement::Any));
// Create image to store residency info copied from sparse image
imageResidencyInfo = imageTexelsInfo;
imageResidencyInfo.format = mapTextureFormat(m_residencyFormat);
- const de::UniquePtr<Image> imageResidency(new Image(deviceInterface, *m_logicalDevice, *allocator, imageResidencyInfo, MemoryRequirement::Any));
+ const Unique<VkImage> imageResidency (createImage(deviceInterface, getDevice(), &imageResidencyInfo));
+ const de::UniquePtr<Allocation> imageResidencyAlloc (bindImage(deviceInterface, getDevice(), getAllocator(), *imageResidency, MemoryRequirement::Any));
// Create command buffer for compute and transfer oparations
- const Unique<VkCommandPool> commandPool(makeCommandPool(deviceInterface, *m_logicalDevice, extractQueue.queueFamilyIndex));
- const Unique<VkCommandBuffer> commandBuffer(makeCommandBuffer(deviceInterface, *m_logicalDevice, *commandPool));
+ const Unique<VkCommandPool> commandPool(makeCommandPool(deviceInterface, getDevice(), extractQueue.queueFamilyIndex));
+ const Unique<VkCommandBuffer> commandBuffer(makeCommandBuffer(deviceInterface, getDevice(), *commandPool));
std::vector <VkBufferImageCopy> bufferImageSparseCopy(imageSparseInfo.mipLevels);
for (deUint32 mipLevelNdx = 0u; mipLevelNdx < imageSparseInfo.mipLevels; ++mipLevelNdx)
{
bufferImageSparseCopy[mipLevelNdx] = makeBufferImageCopy(mipLevelExtents(imageSparseInfo.extent, mipLevelNdx), imageSparseInfo.arrayLayers, mipLevelNdx, static_cast<VkDeviceSize>(bufferOffset));
- bufferOffset += getImageMipLevelSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_format, mipLevelNdx, MEM_ALIGN_BUFFERIMAGECOPY_OFFSET);
+ bufferOffset += getImageMipLevelSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_format, mipLevelNdx, BUFFER_IMAGE_COPY_OFFSET_GRANULARITY);
}
}
beginCommandBuffer(deviceInterface, *commandBuffer);
// Create input buffer
- const VkBufferCreateInfo inputBufferCreateInfo = makeBufferCreateInfo(imageSparseSizeInBytes, VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
- const de::UniquePtr<Buffer> inputBuffer(new Buffer(deviceInterface, *m_logicalDevice, *allocator, inputBufferCreateInfo, MemoryRequirement::HostVisible));
+ const VkBufferCreateInfo inputBufferCreateInfo = makeBufferCreateInfo(imageSparseSizeInBytes, VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
+ const Unique<VkBuffer> inputBuffer (createBuffer(deviceInterface, getDevice(), &inputBufferCreateInfo));
+ const de::UniquePtr<Allocation> inputBufferAlloc (bindBuffer(deviceInterface, getDevice(), getAllocator(), *inputBuffer, MemoryRequirement::HostVisible));
// Fill input buffer with reference data
std::vector<deUint8> referenceData(imageSparseSizeInBytes);
}
}
- deMemcpy(inputBuffer->getAllocation().getHostPtr(), &referenceData[0], imageSparseSizeInBytes);
- flushMappedMemoryRange(deviceInterface, *m_logicalDevice, inputBuffer->getAllocation().getMemory(), inputBuffer->getAllocation().getOffset(), imageSparseSizeInBytes);
+ deMemcpy(inputBufferAlloc->getHostPtr(), &referenceData[0], imageSparseSizeInBytes);
+ flushMappedMemoryRange(deviceInterface, getDevice(), inputBufferAlloc->getMemory(), inputBufferAlloc->getOffset(), imageSparseSizeInBytes);
{
// Prepare input buffer for data transfer operation
(
VK_ACCESS_HOST_WRITE_BIT,
VK_ACCESS_TRANSFER_READ_BIT,
- inputBuffer->get(),
+ *inputBuffer,
0u,
imageSparseSizeInBytes
);
}
// Copy reference data from input buffer to sparse image
- deviceInterface.cmdCopyBufferToImage(*commandBuffer, inputBuffer->get(), *imageSparse, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, static_cast<deUint32>(bufferImageSparseCopy.size()), &bufferImageSparseCopy[0]);
+ deviceInterface.cmdCopyBufferToImage(*commandBuffer, *inputBuffer, *imageSparse, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, static_cast<deUint32>(bufferImageSparseCopy.size()), &bufferImageSparseCopy[0]);
- recordCommands(*allocator, *commandBuffer, imageSparseInfo, *imageSparse, imageTexels->get(), imageResidency->get());
+ recordCommands(*commandBuffer, imageSparseInfo, *imageSparse, *imageTexels, *imageResidency);
- const VkBufferCreateInfo bufferTexelsInfo = makeBufferCreateInfo(imageSparseSizeInBytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT);
- const de::UniquePtr<Buffer> bufferTexels(new Buffer(deviceInterface, *m_logicalDevice, *allocator, bufferTexelsInfo, MemoryRequirement::HostVisible));
+ const VkBufferCreateInfo bufferTexelsCreateInfo = makeBufferCreateInfo(imageSparseSizeInBytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT);
+ const Unique<VkBuffer> bufferTexels (createBuffer(deviceInterface, getDevice(), &bufferTexelsCreateInfo));
+ const de::UniquePtr<Allocation> bufferTexelsAlloc (bindBuffer(deviceInterface, getDevice(), getAllocator(), *bufferTexels, MemoryRequirement::HostVisible));
// Copy data from texels image to buffer
- deviceInterface.cmdCopyImageToBuffer(*commandBuffer, imageTexels->get(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, bufferTexels->get(), static_cast<deUint32>(bufferImageSparseCopy.size()), &bufferImageSparseCopy[0]);
+ deviceInterface.cmdCopyImageToBuffer(*commandBuffer, *imageTexels, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *bufferTexels, static_cast<deUint32>(bufferImageSparseCopy.size()), &bufferImageSparseCopy[0]);
- const deUint32 imageResidencySizeInBytes = getImageSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_residencyFormat, imageSparseInfo.mipLevels, MEM_ALIGN_BUFFERIMAGECOPY_OFFSET);
+ const deUint32 imageResidencySizeInBytes = getImageSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_residencyFormat, imageSparseInfo.mipLevels, BUFFER_IMAGE_COPY_OFFSET_GRANULARITY);
- const VkBufferCreateInfo bufferResidencyInfo = makeBufferCreateInfo(imageResidencySizeInBytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT);
- const de::UniquePtr<Buffer> bufferResidency(new Buffer(deviceInterface, *m_logicalDevice, *allocator, bufferResidencyInfo, MemoryRequirement::HostVisible));
+ const VkBufferCreateInfo bufferResidencyCreateInfo = makeBufferCreateInfo(imageResidencySizeInBytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT);
+ const Unique<VkBuffer> bufferResidency (createBuffer(deviceInterface, getDevice(), &bufferResidencyCreateInfo));
+ const de::UniquePtr<Allocation> bufferResidencyAlloc (bindBuffer(deviceInterface, getDevice(), getAllocator(), *bufferResidency, MemoryRequirement::HostVisible));
// Copy data from residency image to buffer
std::vector <VkBufferImageCopy> bufferImageResidencyCopy(imageSparseInfo.mipLevels);
for (deUint32 mipLevelNdx = 0u; mipLevelNdx < imageSparseInfo.mipLevels; ++mipLevelNdx)
{
bufferImageResidencyCopy[mipLevelNdx] = makeBufferImageCopy(mipLevelExtents(imageSparseInfo.extent, mipLevelNdx), imageSparseInfo.arrayLayers, mipLevelNdx, static_cast<VkDeviceSize>(bufferOffset));
- bufferOffset += getImageMipLevelSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_residencyFormat, mipLevelNdx, MEM_ALIGN_BUFFERIMAGECOPY_OFFSET);
+ bufferOffset += getImageMipLevelSizeInBytes(imageSparseInfo.extent, imageSparseInfo.arrayLayers, m_residencyFormat, mipLevelNdx, BUFFER_IMAGE_COPY_OFFSET_GRANULARITY);
}
}
- deviceInterface.cmdCopyImageToBuffer(*commandBuffer, imageResidency->get(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, bufferResidency->get(), static_cast<deUint32>(bufferImageResidencyCopy.size()), &bufferImageResidencyCopy[0]);
+ deviceInterface.cmdCopyImageToBuffer(*commandBuffer, *imageResidency, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *bufferResidency, static_cast<deUint32>(bufferImageResidencyCopy.size()), &bufferImageResidencyCopy[0]);
{
VkBufferMemoryBarrier bufferOutputHostReadBarriers[2];
(
VK_ACCESS_TRANSFER_WRITE_BIT,
VK_ACCESS_HOST_READ_BIT,
- bufferTexels->get(),
+ *bufferTexels,
0u,
imageSparseSizeInBytes
);
(
VK_ACCESS_TRANSFER_WRITE_BIT,
VK_ACCESS_HOST_READ_BIT,
- bufferResidency->get(),
+ *bufferResidency,
0u,
imageResidencySizeInBytes
);
const VkPipelineStageFlags stageBits[] = { VK_PIPELINE_STAGE_TRANSFER_BIT };
// Submit commands for execution and wait for completion
- submitCommandsAndWait(deviceInterface, *m_logicalDevice, extractQueue.queueHandle, *commandBuffer, 1u, &memoryBindSemaphore.get(), stageBits);
+ submitCommandsAndWait(deviceInterface, getDevice(), extractQueue.queueHandle, *commandBuffer, 1u, &memoryBindSemaphore.get(), stageBits);
// Wait for sparse queue to become idle
deviceInterface.queueWaitIdle(sparseQueue.queueHandle);
// Retrieve data from residency buffer to host memory
- const Allocation& bufferResidencyAllocation = bufferResidency->getAllocation();
- invalidateMappedMemoryRange(deviceInterface, *m_logicalDevice, bufferResidencyAllocation.getMemory(), bufferResidencyAllocation.getOffset(), imageResidencySizeInBytes);
+ invalidateMappedMemoryRange(deviceInterface, getDevice(), bufferResidencyAlloc->getMemory(), bufferResidencyAlloc->getOffset(), imageResidencySizeInBytes);
- const deUint32* bufferResidencyData = static_cast<const deUint32*>(bufferResidencyAllocation.getHostPtr());
+ const deUint32* bufferResidencyData = static_cast<const deUint32*>(bufferResidencyAlloc->getHostPtr());
deUint32 pixelOffsetNotAligned = 0u;
for (deUint32 mipmapNdx = 0; mipmapNdx < imageSparseInfo.mipLevels; ++mipmapNdx)
}
// Retrieve data from texels buffer to host memory
- const Allocation& bufferTexelsAllocation = bufferTexels->getAllocation();
- invalidateMappedMemoryRange(deviceInterface, *m_logicalDevice, bufferTexelsAllocation.getMemory(), bufferTexelsAllocation.getOffset(), imageSparseSizeInBytes);
+ invalidateMappedMemoryRange(deviceInterface, getDevice(), bufferTexelsAlloc->getMemory(), bufferTexelsAlloc->getOffset(), imageSparseSizeInBytes);
- const deUint8* bufferTexelsData = static_cast<const deUint8*>(bufferTexelsAllocation.getHostPtr());
+ const deUint8* bufferTexelsData = static_cast<const deUint8*>(bufferTexelsAlloc->getHostPtr());
for (deUint32 mipmapNdx = 0; mipmapNdx < imageSparseInfo.mipLevels; ++mipmapNdx)
{
virtual vk::VkQueueFlags getQueueFlags (void) const = 0;
- virtual void recordCommands (vk::Allocator& allocator,
- const vk::VkCommandBuffer commandBuffer,
+ virtual void recordCommands (const vk::VkCommandBuffer commandBuffer,
const vk::VkImageCreateInfo& imageSparseInfo,
const vk::VkImage imageSparse,
const vk::VkImage imageTexels,
{
namespace sparse
{
+namespace
+{
+
+Move<VkPipeline> makeGraphicsPipeline (const DeviceInterface& vk,
+ const VkDevice device,
+ const VkPipelineLayout pipelineLayout,
+ const VkRenderPass renderPass,
+ const VkShaderModule vertexModule,
+ const VkShaderModule fragmentModule,
+ const VkShaderModule geometryModule)
+{
+ const VkFormat vertexFormatPosition = VK_FORMAT_R32G32_SFLOAT;
+ const VkFormat vertexFormatTexCoord = VK_FORMAT_R32G32_SFLOAT;
+ const deUint32 vertexSizePosition = tcu::getPixelSize(mapVkFormat(vertexFormatPosition));
+ const deUint32 vertexSizeTexCoord = tcu::getPixelSize(mapVkFormat(vertexFormatTexCoord));
+ const deUint32 vertexBufferOffsetPosition = 0u;
+ const deUint32 vertexBufferOffsetTexCoord = vertexSizePosition;
+ const deUint32 vertexDataStride = vertexSizePosition + vertexSizeTexCoord;
+
+ const VkVertexInputBindingDescription vertexBinding =
+ {
+ 0u, // deUint32 binding;
+ vertexDataStride, // deUint32 stride;
+ VK_VERTEX_INPUT_RATE_VERTEX // VkVertexInputRate inputRate;
+ };
+
+ const VkVertexInputAttributeDescription vertexInputAttributeDescriptions[] =
+ {
+ // position
+ {
+ 0u, // deUint32 location;
+ 0u, // deUint32 binding;
+ vertexFormatPosition, // VkFormat format;
+ vertexBufferOffsetPosition, // deUint32 offset;
+ },
+ // texture coordinates
+ {
+ 1u, // deUint32 location;
+ 0u, // deUint32 binding;
+ vertexFormatTexCoord, // VkFormat format;
+ vertexBufferOffsetTexCoord, // deUint32 offset;
+ },
+ };
+
+ const VkPipelineVertexInputStateCreateInfo vertexInputStateInfo =
+ {
+ VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // VkStructureType sType;
+ DE_NULL, // const void* pNext;
+ (VkPipelineVertexInputStateCreateFlags)0, // VkPipelineVertexInputStateCreateFlags flags;
+ 1u, // uint32_t vertexBindingDescriptionCount;
+ &vertexBinding, // const VkVertexInputBindingDescription* pVertexBindingDescriptions;
+ DE_LENGTH_OF_ARRAY(vertexInputAttributeDescriptions), // uint32_t vertexAttributeDescriptionCount;
+ vertexInputAttributeDescriptions, // const VkVertexInputAttributeDescription* pVertexAttributeDescriptions;
+ };
+
+ const VkPipelineInputAssemblyStateCreateInfo pipelineInputAssemblyStateInfo =
+ {
+ VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // VkStructureType sType;
+ DE_NULL, // const void* pNext;
+ (VkPipelineInputAssemblyStateCreateFlags)0, // VkPipelineInputAssemblyStateCreateFlags flags;
+ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, // VkPrimitiveTopology topology;
+ VK_FALSE, // VkBool32 primitiveRestartEnable;
+ };
+
+ const VkPipelineViewportStateCreateInfo pipelineViewportStateInfo =
+ {
+ VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // VkStructureType sType;
+ DE_NULL, // const void* pNext;
+ (VkPipelineViewportStateCreateFlags)0, // VkPipelineViewportStateCreateFlags flags;
+ 1u, // uint32_t viewportCount;
+ DE_NULL, // dynamic state // const VkViewport* pViewports;
+ 1u, // uint32_t scissorCount;
+ DE_NULL, // dynamic state // const VkRect2D* pScissors;
+ };
+
+ const VkPipelineRasterizationStateCreateInfo pipelineRasterizationStateInfo =
+ {
+ VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // VkStructureType sType;
+ DE_NULL, // const void* pNext;
+ (VkPipelineRasterizationStateCreateFlags)0, // VkPipelineRasterizationStateCreateFlags flags;
+ VK_FALSE, // VkBool32 depthClampEnable;
+ VK_FALSE, // VkBool32 rasterizerDiscardEnable;
+ VK_POLYGON_MODE_FILL, // VkPolygonMode polygonMode;
+ VK_CULL_MODE_NONE, // VkCullModeFlags cullMode;
+ VK_FRONT_FACE_COUNTER_CLOCKWISE, // VkFrontFace frontFace;
+ VK_FALSE, // VkBool32 depthBiasEnable;
+ 0.0f, // float depthBiasConstantFactor;
+ 0.0f, // float depthBiasClamp;
+ 0.0f, // float depthBiasSlopeFactor;
+ 1.0f, // float lineWidth;
+ };
+
+ const VkPipelineMultisampleStateCreateInfo pipelineMultisampleStateInfo =
+ {
+ VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // VkStructureType sType;
+ DE_NULL, // const void* pNext;
+ (VkPipelineMultisampleStateCreateFlags)0, // VkPipelineMultisampleStateCreateFlags flags;
+ VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits rasterizationSamples;
+ VK_FALSE, // VkBool32 sampleShadingEnable;
+ 0.0f, // float minSampleShading;
+ DE_NULL, // const VkSampleMask* pSampleMask;
+ VK_FALSE, // VkBool32 alphaToCoverageEnable;
+ VK_FALSE // VkBool32 alphaToOneEnable;
+ };
+
+ const VkStencilOpState stencilOpState = makeStencilOpState(
+ VK_STENCIL_OP_KEEP, // stencil fail
+ VK_STENCIL_OP_KEEP, // depth & stencil pass
+ VK_STENCIL_OP_KEEP, // depth only fail
+ VK_COMPARE_OP_ALWAYS, // compare op
+ 0u, // compare mask
+ 0u, // write mask
+ 0u); // reference
+
+ VkPipelineDepthStencilStateCreateInfo pipelineDepthStencilStateInfo =
+ {
+ VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // VkStructureType sType;
+ DE_NULL, // const void* pNext;
+ (VkPipelineDepthStencilStateCreateFlags)0, // VkPipelineDepthStencilStateCreateFlags flags;
+ VK_FALSE, // VkBool32 depthTestEnable;
+ VK_FALSE, // VkBool32 depthWriteEnable;
+ VK_COMPARE_OP_LESS, // VkCompareOp depthCompareOp;
+ VK_FALSE, // VkBool32 depthBoundsTestEnable;
+ VK_FALSE, // VkBool32 stencilTestEnable;
+ stencilOpState, // VkStencilOpState front;
+ stencilOpState, // VkStencilOpState back;
+ 0.0f, // float minDepthBounds;
+ 1.0f, // float maxDepthBounds;
+ };
+
+ const VkColorComponentFlags colorComponentsAll = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
+ const VkPipelineColorBlendAttachmentState defaultColorBlendAttachmentState =
+ {
+ VK_FALSE, // VkBool32 blendEnable;
+ VK_BLEND_FACTOR_ONE, // VkBlendFactor srcColorBlendFactor;
+ VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstColorBlendFactor;
+ VK_BLEND_OP_ADD, // VkBlendOp colorBlendOp;
+ VK_BLEND_FACTOR_ONE, // VkBlendFactor srcAlphaBlendFactor;
+ VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstAlphaBlendFactor;
+ VK_BLEND_OP_ADD, // VkBlendOp alphaBlendOp;
+ colorComponentsAll, // VkColorComponentFlags colorWriteMask;
+ };
+
+ const VkPipelineColorBlendAttachmentState colorBlendAttachmentStates[] =
+ {
+ defaultColorBlendAttachmentState,
+ defaultColorBlendAttachmentState,
+ };
+
+ const VkPipelineColorBlendStateCreateInfo pipelineColorBlendStateInfo =
+ {
+ VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // VkStructureType sType;
+ DE_NULL, // const void* pNext;
+ (VkPipelineColorBlendStateCreateFlags)0, // VkPipelineColorBlendStateCreateFlags flags;
+ VK_FALSE, // VkBool32 logicOpEnable;
+ VK_LOGIC_OP_COPY, // VkLogicOp logicOp;
+ DE_LENGTH_OF_ARRAY(colorBlendAttachmentStates), // deUint32 attachmentCount;
+ colorBlendAttachmentStates, // const VkPipelineColorBlendAttachmentState* pAttachments;
+ { 0.0f, 0.0f, 0.0f, 0.0f }, // float blendConstants[4];
+ };
+
+ const VkDynamicState dynamicStates[] =
+ {
+ VK_DYNAMIC_STATE_VIEWPORT,
+ VK_DYNAMIC_STATE_SCISSOR,
+ };
+
+ const VkPipelineDynamicStateCreateInfo dynamicStateCreateInfo =
+ {
+ VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, // VkStructureType sType;
+ DE_NULL, // const void* pNext;
+ (VkPipelineDynamicStateCreateFlags)0, // VkPipelineDynamicStateCreateFlags flags;
+ DE_LENGTH_OF_ARRAY(dynamicStates), // deUint32 dynamicStateCount;
+ dynamicStates, // const VkDynamicState* pDynamicStates;
+ };
+
+ const VkPipelineShaderStageCreateInfo pShaderStages[] =
+ {
+ {
+ VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
+ DE_NULL, // const void* pNext;
+ (VkPipelineShaderStageCreateFlags)0, // VkPipelineShaderStageCreateFlags flags;
+ VK_SHADER_STAGE_VERTEX_BIT, // VkShaderStageFlagBits stage;
+ vertexModule, // VkShaderModule module;
+ "main", // const char* pName;
+ DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
+ },
+ {
+ VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
+ DE_NULL, // const void* pNext;
+ (VkPipelineShaderStageCreateFlags)0, // VkPipelineShaderStageCreateFlags flags;
+ VK_SHADER_STAGE_FRAGMENT_BIT, // VkShaderStageFlagBits stage;
+ fragmentModule, // VkShaderModule module;
+ "main", // const char* pName;
+ DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
+ },
+ {
+ VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
+ DE_NULL, // const void* pNext;
+ (VkPipelineShaderStageCreateFlags)0, // VkPipelineShaderStageCreateFlags flags;
+ VK_SHADER_STAGE_GEOMETRY_BIT, // VkShaderStageFlagBits stage;
+ geometryModule, // VkShaderModule module;
+ "main", // const char* pName;
+ DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
+ },
+ };
+
+ const deUint32 numActiveShaderStages = DE_LENGTH_OF_ARRAY(pShaderStages) - (geometryModule == DE_NULL ? 1u : 0u);
+
+ const VkGraphicsPipelineCreateInfo graphicsPipelineInfo =
+ {
+ VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // VkStructureType sType;
+ DE_NULL, // const void* pNext;
+ (VkPipelineCreateFlags)0, // VkPipelineCreateFlags flags;
+ numActiveShaderStages, // deUint32 stageCount;
+ pShaderStages, // const VkPipelineShaderStageCreateInfo* pStages;
+ &vertexInputStateInfo, // const VkPipelineVertexInputStateCreateInfo* pVertexInputState;
+ &pipelineInputAssemblyStateInfo, // const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState;
+ DE_NULL, // const VkPipelineTessellationStateCreateInfo* pTessellationState;
+ &pipelineViewportStateInfo, // const VkPipelineViewportStateCreateInfo* pViewportState;
+ &pipelineRasterizationStateInfo, // const VkPipelineRasterizationStateCreateInfo* pRasterizationState;
+ &pipelineMultisampleStateInfo, // const VkPipelineMultisampleStateCreateInfo* pMultisampleState;
+ &pipelineDepthStencilStateInfo, // const VkPipelineDepthStencilStateCreateInfo* pDepthStencilState;
+ &pipelineColorBlendStateInfo, // const VkPipelineColorBlendStateCreateInfo* pColorBlendState;
+ &dynamicStateCreateInfo, // const VkPipelineDynamicStateCreateInfo* pDynamicState;
+ pipelineLayout, // VkPipelineLayout layout;
+ renderPass, // VkRenderPass renderPass;
+ 0u, // deUint32 subpass;
+ DE_NULL, // VkPipeline basePipelineHandle;
+ 0, // deInt32 basePipelineIndex;
+ };
+
+ return createGraphicsPipeline(vk, device, DE_NULL, &graphicsPipelineInfo);
+}
+
+} // anonymous
void SparseShaderIntrinsicsCaseSampledBase::initPrograms (vk::SourceCollections& programCollection) const
{
VkQueueFlags getQueueFlags (void) const;
- void recordCommands (vk::Allocator& allocator,
- const VkCommandBuffer commandBuffer,
+ void recordCommands (const VkCommandBuffer commandBuffer,
const VkImageCreateInfo& imageSparseInfo,
const VkImage imageSparse,
const VkImage imageTexels,
virtual VkImageSubresourceRange sampledImageRangeToBind(const VkImageCreateInfo& imageSparseInfo, const deUint32 mipLevel) const = 0;
private:
+ typedef de::SharedPtr< vk::Unique<vk::VkFramebuffer> > VkFramebufferSp;
- typedef de::SharedPtr< vk::Unique<vk::VkFramebuffer> > SharedVkFramebuffer;
-
- de::SharedPtr<Buffer> vertexBuffer;
- std::vector<SharedVkFramebuffer> framebuffers;
- Move<VkRenderPass> renderPass;
- Move<VkSampler> sampler;
+ Move<VkBuffer> m_vertexBuffer;
+ de::MovePtr<Allocation> m_vertexBufferAlloc;
+ std::vector<VkFramebufferSp> m_framebuffers;
+ Move<VkRenderPass> m_renderPass;
+ Move<VkSampler> m_sampler;
};
VkImageUsageFlags SparseShaderIntrinsicsInstanceSampledBase::imageSparseUsageFlags (void) const
return VK_QUEUE_GRAPHICS_BIT;
}
-void SparseShaderIntrinsicsInstanceSampledBase::recordCommands (vk::Allocator& allocator,
- const VkCommandBuffer commandBuffer,
+void SparseShaderIntrinsicsInstanceSampledBase::recordCommands (const VkCommandBuffer commandBuffer,
const VkImageCreateInfo& imageSparseInfo,
const VkImage imageSparse,
const VkImage imageTexels,
vertexData.push_back(tcu::Vec2( 1.0f, 1.0f));
vertexData.push_back(tcu::Vec2( 1.0f, 1.0f));
- const VkFormat vertexFormatPosition = VK_FORMAT_R32G32_SFLOAT;
- const VkFormat vertexFormatTexCoord = VK_FORMAT_R32G32_SFLOAT;
+ const VkDeviceSize vertexDataSizeInBytes = sizeInBytes(vertexData);
+ const VkBufferCreateInfo vertexBufferCreateInfo = makeBufferCreateInfo(vertexDataSizeInBytes, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
- const deUint32 vertexSizePosition = tcu::getPixelSize(mapVkFormat(vertexFormatPosition));
- const deUint32 vertexSizeTexCoord = tcu::getPixelSize(mapVkFormat(vertexFormatTexCoord));
+ m_vertexBuffer = createBuffer(deviceInterface, getDevice(), &vertexBufferCreateInfo);
+ m_vertexBufferAlloc = bindBuffer(deviceInterface, getDevice(), getAllocator(), *m_vertexBuffer, MemoryRequirement::HostVisible);
- const VkDeviceSize vertexBufferStartOffset = 0ull;
- const deUint32 vertexBufferOffsetPosition = 0ull;
- const deUint32 vertexBufferOffsetTexCoord = vertexSizePosition;
-
- const deUint32 vertexDataStride = vertexSizePosition + vertexSizeTexCoord;
- const VkDeviceSize vertexDataSizeInBytes = sizeInBytes(vertexData);
-
- vertexBuffer = de::SharedPtr<Buffer>(new Buffer(deviceInterface, *m_logicalDevice, allocator, makeBufferCreateInfo(vertexDataSizeInBytes, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT), MemoryRequirement::HostVisible));
- const Allocation& vertexBufferAllocation = vertexBuffer->getAllocation();
-
- deMemcpy(vertexBufferAllocation.getHostPtr(), &vertexData[0], static_cast<std::size_t>(vertexDataSizeInBytes));
- flushMappedMemoryRange(deviceInterface, *m_logicalDevice, vertexBufferAllocation.getMemory(), vertexBufferAllocation.getOffset(), vertexDataSizeInBytes);
+ deMemcpy(m_vertexBufferAlloc->getHostPtr(), &vertexData[0], static_cast<std::size_t>(vertexDataSizeInBytes));
+ flushMappedMemoryRange(deviceInterface, getDevice(), m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset(), vertexDataSizeInBytes);
// Create render pass
const VkAttachmentDescription texelsAttachmentDescription =
DE_NULL // const VkSubpassDependency* pDependencies;
};
- renderPass = createRenderPass(deviceInterface, *m_logicalDevice, &renderPassInfo);
+ m_renderPass = createRenderPass(deviceInterface, getDevice(), &renderPassInfo);
// Create descriptor set layout
DescriptorSetLayoutBuilder descriptorLayerBuilder;
descriptorLayerBuilder.addSingleBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_SHADER_STAGE_FRAGMENT_BIT);
- const Unique<VkDescriptorSetLayout> descriptorSetLayout(descriptorLayerBuilder.build(deviceInterface, *m_logicalDevice));
+ const Unique<VkDescriptorSetLayout> descriptorSetLayout(descriptorLayerBuilder.build(deviceInterface, getDevice()));
// Create descriptor pool
DescriptorPoolBuilder descriptorPoolBuilder;
descriptorPoolBuilder.addType(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, imageSparseInfo.mipLevels);
- descriptorPool = descriptorPoolBuilder.build(deviceInterface, *m_logicalDevice, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, imageSparseInfo.mipLevels);
+ descriptorPool = descriptorPoolBuilder.build(deviceInterface, getDevice(), VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, imageSparseInfo.mipLevels);
// Create sampler object
const tcu::Sampler samplerObject(tcu::Sampler::REPEAT_GL, tcu::Sampler::REPEAT_GL, tcu::Sampler::REPEAT_GL, tcu::Sampler::NEAREST_MIPMAP_NEAREST, tcu::Sampler::NEAREST);
const VkSamplerCreateInfo samplerCreateInfo = mapSampler(samplerObject, m_format);
- sampler = createSampler(deviceInterface, *m_logicalDevice, &samplerCreateInfo);
+ m_sampler = createSampler(deviceInterface, getDevice(), &samplerCreateInfo);
struct PushConstants
{
&lodConstantRange, // const VkPushConstantRange* pPushConstantRanges;
};
- const Unique<VkPipelineLayout> pipelineLayout(createPipelineLayout(deviceInterface, *m_logicalDevice, &pipelineLayoutParams));
+ const Unique<VkPipelineLayout> pipelineLayout(createPipelineLayout(deviceInterface, getDevice(), &pipelineLayoutParams));
// Create graphics pipeline
- const VkVertexInputBindingDescription vertexBinding =
{
- 0u, // deUint32 binding;
- vertexDataStride, // deUint32 stride;
- VK_VERTEX_INPUT_RATE_VERTEX // VkVertexInputRate inputRate;
- };
-
- const VkVertexInputAttributeDescription vertexAttributePosition =
- {
- 0u, // deUint32 location;
- 0u, // deUint32 binding;
- vertexFormatPosition, // VkFormat format;
- vertexBufferOffsetPosition, // deUint32 offset;
- };
-
- const VkVertexInputAttributeDescription vertexAttributeTexCoord =
- {
- 1u, // deUint32 location;
- 0u, // deUint32 binding;
- vertexFormatTexCoord, // VkFormat format;
- vertexBufferOffsetTexCoord, // deUint32 offset;
- };
-
- {
- GraphicsPipelineBuilder graphicPipelineBuilder;
-
- graphicPipelineBuilder.addVertexBinding(vertexBinding);
- graphicPipelineBuilder.addVertexAttribute(vertexAttributePosition);
- graphicPipelineBuilder.addVertexAttribute(vertexAttributeTexCoord);
- graphicPipelineBuilder.setPrimitiveTopology(vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP);
- graphicPipelineBuilder.addDynamicState(VK_DYNAMIC_STATE_VIEWPORT);
- graphicPipelineBuilder.addDynamicState(VK_DYNAMIC_STATE_SCISSOR);
- graphicPipelineBuilder.setAttachmentsCount(2u);
- graphicPipelineBuilder.setShader(deviceInterface, *m_logicalDevice, VK_SHADER_STAGE_VERTEX_BIT, m_context.getBinaryCollection().get("vertex_shader"), DE_NULL);
- graphicPipelineBuilder.setShader(deviceInterface, *m_logicalDevice, VK_SHADER_STAGE_FRAGMENT_BIT, m_context.getBinaryCollection().get("fragment_shader"), DE_NULL);
+ Move<VkShaderModule> vertexModule = createShaderModule(deviceInterface, getDevice(), m_context.getBinaryCollection().get("vertex_shader"), (VkShaderModuleCreateFlags)0);
+ Move<VkShaderModule> fragmentModule = createShaderModule(deviceInterface, getDevice(), m_context.getBinaryCollection().get("fragment_shader"), (VkShaderModuleCreateFlags)0);
+ Move<VkShaderModule> geometryModule;
if (imageSparseInfo.arrayLayers > 1u)
{
requireFeatures(instance, physicalDevice, FEATURE_GEOMETRY_SHADER);
- graphicPipelineBuilder.setShader(deviceInterface, *m_logicalDevice, VK_SHADER_STAGE_GEOMETRY_BIT, m_context.getBinaryCollection().get("geometry_shader"), DE_NULL);
+ geometryModule = createShaderModule(deviceInterface, getDevice(), m_context.getBinaryCollection().get("geometry_shader"), (VkShaderModuleCreateFlags)0);
}
- pipelines.push_back(makeVkSharedPtr(graphicPipelineBuilder.build(deviceInterface, *m_logicalDevice, *pipelineLayout, *renderPass)));
+ pipelines.push_back(makeVkSharedPtr(makeGraphicsPipeline(
+ deviceInterface, getDevice(), *pipelineLayout, *m_renderPass, *vertexModule, *fragmentModule, *geometryModule)));
}
const VkPipeline graphicsPipeline = **pipelines[0];
imageSparseViews.resize(imageSparseInfo.mipLevels);
imageTexelsViews.resize(imageSparseInfo.mipLevels);
imageResidencyViews.resize(imageSparseInfo.mipLevels);
- framebuffers.resize(imageSparseInfo.mipLevels);
+ m_framebuffers.resize(imageSparseInfo.mipLevels);
descriptorSets.resize(imageSparseInfo.mipLevels);
std::vector<VkClearValue> clearValues;
const VkImageSubresourceRange mipLevelRange = makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, mipLevelNdx, 1u, 0u, imageSparseInfo.arrayLayers);
// Create color attachments image views
- imageTexelsViews[mipLevelNdx] = makeVkSharedPtr(makeImageView(deviceInterface, *m_logicalDevice, imageTexels, mapImageViewType(m_imageType), imageSparseInfo.format, mipLevelRange));
- imageResidencyViews[mipLevelNdx] = makeVkSharedPtr(makeImageView(deviceInterface, *m_logicalDevice, imageResidency, mapImageViewType(m_imageType), mapTextureFormat(m_residencyFormat), mipLevelRange));
+ imageTexelsViews[mipLevelNdx] = makeVkSharedPtr(makeImageView(deviceInterface, getDevice(), imageTexels, mapImageViewType(m_imageType), imageSparseInfo.format, mipLevelRange));
+ imageResidencyViews[mipLevelNdx] = makeVkSharedPtr(makeImageView(deviceInterface, getDevice(), imageResidency, mapImageViewType(m_imageType), mapTextureFormat(m_residencyFormat), mipLevelRange));
const VkImageView attachmentsViews[] = { **imageTexelsViews[mipLevelNdx], **imageResidencyViews[mipLevelNdx] };
VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType;
DE_NULL, // const void* pNext;
(VkFramebufferCreateFlags)0, // VkFramebufferCreateFlags flags;
- *renderPass, // VkRenderPass renderPass;
+ *m_renderPass, // VkRenderPass renderPass;
2u, // uint32_t attachmentCount;
attachmentsViews, // const VkImageView* pAttachments;
mipLevelSize.width, // uint32_t width;
imageSparseInfo.arrayLayers, // uint32_t layers;
};
- framebuffers[mipLevelNdx] = makeVkSharedPtr(createFramebuffer(deviceInterface, *m_logicalDevice, &framebufferInfo));
+ m_framebuffers[mipLevelNdx] = makeVkSharedPtr(createFramebuffer(deviceInterface, getDevice(), &framebufferInfo));
// Create descriptor set
- descriptorSets[mipLevelNdx] = makeVkSharedPtr(makeDescriptorSet(deviceInterface, *m_logicalDevice, *descriptorPool, *descriptorSetLayout));
+ descriptorSets[mipLevelNdx] = makeVkSharedPtr(makeDescriptorSet(deviceInterface, getDevice(), *descriptorPool, *descriptorSetLayout));
const VkDescriptorSet descriptorSet = **descriptorSets[mipLevelNdx];
// Update descriptor set
const VkImageSubresourceRange sparseImageSubresourceRange = sampledImageRangeToBind(imageSparseInfo, mipLevelNdx);
- imageSparseViews[mipLevelNdx] = makeVkSharedPtr(makeImageView(deviceInterface, *m_logicalDevice, imageSparse, mapImageViewType(m_imageType), imageSparseInfo.format, sparseImageSubresourceRange));
+ imageSparseViews[mipLevelNdx] = makeVkSharedPtr(makeImageView(deviceInterface, getDevice(), imageSparse, mapImageViewType(m_imageType), imageSparseInfo.format, sparseImageSubresourceRange));
- const VkDescriptorImageInfo imageSparseDescInfo = makeDescriptorImageInfo(*sampler, **imageSparseViews[mipLevelNdx], VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
+ const VkDescriptorImageInfo imageSparseDescInfo = makeDescriptorImageInfo(*m_sampler, **imageSparseViews[mipLevelNdx], VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
DescriptorSetUpdateBuilder descriptorUpdateBuilder;
descriptorUpdateBuilder.writeSingle(descriptorSet, DescriptorSetUpdateBuilder::Location::binding(BINDING_IMAGE_SPARSE), VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, &imageSparseDescInfo);
- descriptorUpdateBuilder.update(deviceInterface, *m_logicalDevice);
+ descriptorUpdateBuilder.update(deviceInterface, getDevice());
// Begin render pass
- beginRenderPass(deviceInterface, commandBuffer, *renderPass, **framebuffers[mipLevelNdx], renderArea, clearValues);
+ {
+ const VkRenderPassBeginInfo renderPassBeginInfo =
+ {
+ VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // VkStructureType sType;
+ DE_NULL, // const void* pNext;
+ *m_renderPass, // VkRenderPass renderPass;
+ **m_framebuffers[mipLevelNdx], // VkFramebuffer framebuffer;
+ renderArea, // VkRect2D renderArea;
+ static_cast<deUint32>(clearValues.size()), // deUint32 clearValueCount;
+ &clearValues[0], // const VkClearValue* pClearValues;
+ };
+
+ deviceInterface.cmdBeginRenderPass(commandBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
+ }
// Bind graphics pipeline
deviceInterface.cmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, graphicsPipeline);
deviceInterface.cmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *pipelineLayout, 0u, 1u, &descriptorSet, 0u, DE_NULL);
// Bind vertex buffer
- deviceInterface.cmdBindVertexBuffers(commandBuffer, 0u, 1u, &vertexBuffer->get(), &vertexBufferStartOffset);
+ {
+ const VkDeviceSize offset = 0ull;
+ deviceInterface.cmdBindVertexBuffers(commandBuffer, 0u, 1u, &m_vertexBuffer.get(), &offset);
+ }
// Bind Viewport
deviceInterface.cmdSetViewport(commandBuffer, 0u, 1u, &viewport);
deviceInterface.cmdDraw(commandBuffer, 4u, 1u, 0u, 0u);
// End render pass
- endRenderPass(deviceInterface, commandBuffer);
+ deviceInterface.cmdEndRenderPass(commandBuffer);
}
{
const tcu::TextureFormat& format)
: SparseShaderIntrinsicsInstanceSampledBase(context, function, imageType, imageSize, format) {}
- VkImageSubresourceRange sampledImageRangeToBind(const VkImageCreateInfo& imageSparseInfo, const deUint32 mipLevel) const;
+ VkImageSubresourceRange sampledImageRangeToBind (const VkImageCreateInfo& imageSparseInfo,
+ const deUint32 mipLevel) const
+ {
+ DE_UNREF(mipLevel);
+ return makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, imageSparseInfo.mipLevels, 0u, imageSparseInfo.arrayLayers);
+ }
};
-VkImageSubresourceRange SparseShaderIntrinsicsInstanceSampledExplicit::sampledImageRangeToBind (const VkImageCreateInfo& imageSparseInfo, const deUint32 mipLevel) const
-{
- DE_UNREF(mipLevel);
-
- return makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, imageSparseInfo.mipLevels, 0u, imageSparseInfo.arrayLayers);
-}
-
TestInstance* SparseShaderIntrinsicsCaseSampledExplicit::createInstance (Context& context) const
{
return new SparseShaderIntrinsicsInstanceSampledExplicit(context, m_function, m_imageType, m_imageSize, m_format);
const tcu::TextureFormat& format)
: SparseShaderIntrinsicsInstanceSampledBase(context, function, imageType, imageSize, format) {}
- VkImageSubresourceRange sampledImageRangeToBind(const VkImageCreateInfo& imageSparseInfo, const deUint32 mipLevel) const;
+ VkImageSubresourceRange sampledImageRangeToBind (const VkImageCreateInfo& imageSparseInfo,
+ const deUint32 mipLevel) const
+ {
+ return makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, mipLevel, 1u, 0u, imageSparseInfo.arrayLayers);
+ }
};
-VkImageSubresourceRange SparseShaderIntrinsicsInstanceSampledImplicit::sampledImageRangeToBind (const VkImageCreateInfo& imageSparseInfo, const deUint32 mipLevel) const
-{
- return makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, mipLevel, 1u, 0u, imageSparseInfo.arrayLayers);
-}
-
TestInstance* SparseShaderIntrinsicsCaseSampledImplicit::createInstance (Context& context) const
{
return new SparseShaderIntrinsicsInstanceSampledImplicit(context, m_function, m_imageType, m_imageSize, m_format);
const ImageType imageType,
const tcu::UVec3& imageSize,
const tcu::TextureFormat& format)
- : SparseShaderIntrinsicsCaseBase(testCtx, name, function, imageType, imageSize, format) {}
+ : SparseShaderIntrinsicsCaseBase (testCtx, name, function, imageType, imageSize, format) {}
void initPrograms (vk::SourceCollections& programCollection) const;
const ImageType imageType,
const tcu::UVec3& imageSize,
const tcu::TextureFormat& format)
- : SparseShaderIntrinsicsCaseSampledBase(testCtx, name, function, imageType, imageSize, format) {}
+ : SparseShaderIntrinsicsCaseSampledBase (testCtx, name, function, imageType, imageSize, format) {}
- TestInstance* createInstance (Context& context) const;
+ TestInstance* createInstance (Context& context) const;
};
class SparseCaseOpImageSparseSampleExplicitLod : public SparseShaderIntrinsicsCaseSampledExplicit
const ImageType imageType,
const tcu::UVec3& imageSize,
const tcu::TextureFormat& format)
- : SparseShaderIntrinsicsCaseSampledExplicit(testCtx, name, function, imageType, imageSize, format) {}
+ : SparseShaderIntrinsicsCaseSampledExplicit (testCtx, name, function, imageType, imageSize, format) {}
- std::string sparseImageOpString(const std::string& resultVariable, const std::string& resultType, const std::string& image, const std::string& coord, const std::string& miplevel) const;
+ std::string sparseImageOpString (const std::string& resultVariable,
+ const std::string& resultType,
+ const std::string& image,
+ const std::string& coord,
+ const std::string& miplevel) const;
};
class SparseShaderIntrinsicsCaseSampledImplicit : public SparseShaderIntrinsicsCaseSampledBase
const ImageType imageType,
const tcu::UVec3& imageSize,
const tcu::TextureFormat& format)
- : SparseShaderIntrinsicsCaseSampledBase(testCtx, name, function, imageType, imageSize, format) {}
+ : SparseShaderIntrinsicsCaseSampledBase (testCtx, name, function, imageType, imageSize, format) {}
- TestInstance* createInstance (Context& context) const;
+ TestInstance* createInstance (Context& context) const;
};
class SparseCaseOpImageSparseSampleImplicitLod : public SparseShaderIntrinsicsCaseSampledImplicit
const ImageType imageType,
const tcu::UVec3& imageSize,
const tcu::TextureFormat& format)
- : SparseShaderIntrinsicsCaseSampledImplicit(testCtx, name, function, imageType, imageSize, format) {}
+ : SparseShaderIntrinsicsCaseSampledImplicit (testCtx, name, function, imageType, imageSize, format) {}
- std::string sparseImageOpString(const std::string& resultVariable, const std::string& resultType, const std::string& image, const std::string& coord, const std::string& miplevel) const;
+ std::string sparseImageOpString (const std::string& resultVariable,
+ const std::string& resultType,
+ const std::string& image,
+ const std::string& coord,
+ const std::string& miplevel) const;
};
class SparseCaseOpImageSparseGather : public SparseShaderIntrinsicsCaseSampledImplicit
{
public:
- SparseCaseOpImageSparseGather (tcu::TestContext& testCtx,
- const std::string& name,
- const SpirVFunction function,
- const ImageType imageType,
- const tcu::UVec3& imageSize,
- const tcu::TextureFormat& format)
- : SparseShaderIntrinsicsCaseSampledImplicit(testCtx, name, function, imageType, imageSize, format) {}
-
- std::string sparseImageOpString(const std::string& resultVariable, const std::string& resultType, const std::string& image, const std::string& coord, const std::string& miplevel) const;
+ SparseCaseOpImageSparseGather (tcu::TestContext& testCtx,
+ const std::string& name,
+ const SpirVFunction function,
+ const ImageType imageType,
+ const tcu::UVec3& imageSize,
+ const tcu::TextureFormat& format)
+ : SparseShaderIntrinsicsCaseSampledImplicit (testCtx, name, function, imageType, imageSize, format) {}
+
+ std::string sparseImageOpString (const std::string& resultVariable,
+ const std::string& resultType,
+ const std::string& image,
+ const std::string& coord,
+ const std::string& miplevel) const;
};
} // sparse
VkQueueFlags getQueueFlags (void) const;
- void recordCommands (vk::Allocator& allocator,
- const VkCommandBuffer commandBuffer,
+ void recordCommands (const VkCommandBuffer commandBuffer,
const VkImageCreateInfo& imageSparseInfo,
const VkImage imageSparse,
const VkImage imageTexels,
return VK_QUEUE_COMPUTE_BIT;
}
-void SparseShaderIntrinsicsInstanceStorage::recordCommands (vk::Allocator& allocator,
- const VkCommandBuffer commandBuffer,
+void SparseShaderIntrinsicsInstanceStorage::recordCommands (const VkCommandBuffer commandBuffer,
const VkImageCreateInfo& imageSparseInfo,
const VkImage imageSparse,
const VkImage imageTexels,
const DeviceInterface& deviceInterface = m_context.getDeviceInterface();
const VkPhysicalDevice physicalDevice = m_context.getPhysicalDevice();
- DE_UNREF(allocator);
-
// Check if device supports image format for storage image
if (!checkImageFormatFeatureSupport(instance, physicalDevice, imageSparseInfo.format, VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT))
TCU_THROW(NotSupportedError, "Device does not support image format for storage image");
descriptorLayerBuilder.addSingleBinding(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, VK_SHADER_STAGE_COMPUTE_BIT);
descriptorLayerBuilder.addSingleBinding(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, VK_SHADER_STAGE_COMPUTE_BIT);
- const Unique<VkDescriptorSetLayout> descriptorSetLayout(descriptorLayerBuilder.build(deviceInterface, *m_logicalDevice));
+ const Unique<VkDescriptorSetLayout> descriptorSetLayout(descriptorLayerBuilder.build(deviceInterface, getDevice()));
// Create pipeline layout
- const Unique<VkPipelineLayout> pipelineLayout(makePipelineLayout(deviceInterface, *m_logicalDevice, *descriptorSetLayout));
+ const Unique<VkPipelineLayout> pipelineLayout(makePipelineLayout(deviceInterface, getDevice(), *descriptorSetLayout));
// Create descriptor pool
DescriptorPoolBuilder descriptorPoolBuilder;
descriptorPoolBuilder.addType(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, imageSparseInfo.mipLevels);
descriptorPoolBuilder.addType(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, imageSparseInfo.mipLevels);
- descriptorPool = descriptorPoolBuilder.build(deviceInterface, *m_logicalDevice, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, imageSparseInfo.mipLevels);
+ descriptorPool = descriptorPoolBuilder.build(deviceInterface, getDevice(), VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, imageSparseInfo.mipLevels);
const VkImageSubresourceRange fullImageSubresourceRange = makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, imageSparseInfo.mipLevels, 0u, imageSparseInfo.arrayLayers);
{ 6u, 5u * (deUint32)sizeof(deUint32), sizeof(deUint32) }, // WorkGroupSize.z
};
- Unique<VkShaderModule> shaderModule(createShaderModule(deviceInterface, *m_logicalDevice, m_context.getBinaryCollection().get("compute"), 0u));
+ Unique<VkShaderModule> shaderModule(createShaderModule(deviceInterface, getDevice(), m_context.getBinaryCollection().get("compute"), 0u));
for (deUint32 mipLevelNdx = 0u; mipLevelNdx < imageSparseInfo.mipLevels; ++mipLevelNdx)
{
};
// Create and bind compute pipeline
- pipelines[mipLevelNdx] = makeVkSharedPtr(makeComputePipeline(deviceInterface, *m_logicalDevice, *pipelineLayout, *shaderModule, &specializationInfo));
+ pipelines[mipLevelNdx] = makeVkSharedPtr(makeComputePipeline(deviceInterface, getDevice(), *pipelineLayout, *shaderModule, &specializationInfo));
const VkPipeline computePipeline = **pipelines[mipLevelNdx];
deviceInterface.cmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, computePipeline);
// Create descriptor set
- descriptorSets[mipLevelNdx] = makeVkSharedPtr(makeDescriptorSet(deviceInterface, *m_logicalDevice, *descriptorPool, *descriptorSetLayout));
+ descriptorSets[mipLevelNdx] = makeVkSharedPtr(makeDescriptorSet(deviceInterface, getDevice(), *descriptorPool, *descriptorSetLayout));
const VkDescriptorSet descriptorSet = **descriptorSets[mipLevelNdx];
// Bind resources
const VkImageSubresourceRange mipLevelRange = makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, mipLevelNdx, 1u, 0u, imageSparseInfo.arrayLayers);
- imageSparseViews[mipLevelNdx] = makeVkSharedPtr(makeImageView(deviceInterface, *m_logicalDevice, imageSparse, mapImageViewType(m_imageType), imageSparseInfo.format, mipLevelRange));
+ imageSparseViews[mipLevelNdx] = makeVkSharedPtr(makeImageView(deviceInterface, getDevice(), imageSparse, mapImageViewType(m_imageType), imageSparseInfo.format, mipLevelRange));
const VkDescriptorImageInfo imageSparseDescInfo = makeDescriptorImageInfo(DE_NULL, **imageSparseViews[mipLevelNdx], VK_IMAGE_LAYOUT_GENERAL);
- imageTexelsViews[mipLevelNdx] = makeVkSharedPtr(makeImageView(deviceInterface, *m_logicalDevice, imageTexels, mapImageViewType(m_imageType), imageSparseInfo.format, mipLevelRange));
+ imageTexelsViews[mipLevelNdx] = makeVkSharedPtr(makeImageView(deviceInterface, getDevice(), imageTexels, mapImageViewType(m_imageType), imageSparseInfo.format, mipLevelRange));
const VkDescriptorImageInfo imageTexelsDescInfo = makeDescriptorImageInfo(DE_NULL, **imageTexelsViews[mipLevelNdx], VK_IMAGE_LAYOUT_GENERAL);
- imageResidencyViews[mipLevelNdx] = makeVkSharedPtr(makeImageView(deviceInterface, *m_logicalDevice, imageResidency, mapImageViewType(m_imageType), mapTextureFormat(m_residencyFormat), mipLevelRange));
+ imageResidencyViews[mipLevelNdx] = makeVkSharedPtr(makeImageView(deviceInterface, getDevice(), imageResidency, mapImageViewType(m_imageType), mapTextureFormat(m_residencyFormat), mipLevelRange));
const VkDescriptorImageInfo imageResidencyDescInfo = makeDescriptorImageInfo(DE_NULL, **imageResidencyViews[mipLevelNdx], VK_IMAGE_LAYOUT_GENERAL);
DescriptorSetUpdateBuilder descriptorUpdateBuilder;
descriptorUpdateBuilder.writeSingle(descriptorSet, DescriptorSetUpdateBuilder::Location::binding(BINDING_IMAGE_TEXELS), VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, &imageTexelsDescInfo);
descriptorUpdateBuilder.writeSingle(descriptorSet, DescriptorSetUpdateBuilder::Location::binding(BINDING_IMAGE_RESIDENCY), VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, &imageResidencyDescInfo);
- descriptorUpdateBuilder.update(deviceInterface, *m_logicalDevice);
+ descriptorUpdateBuilder.update(deviceInterface, getDevice());
deviceInterface.cmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *pipelineLayout, 0u, 1u, &descriptorSet, 0u, DE_NULL);
class SparseShaderIntrinsicsInstanceFetch : public SparseShaderIntrinsicsInstanceStorage
{
public:
- SparseShaderIntrinsicsInstanceFetch (Context& context,
- const SpirVFunction function,
- const ImageType imageType,
- const tcu::UVec3& imageSize,
- const tcu::TextureFormat& format)
- : SparseShaderIntrinsicsInstanceStorage(context, function, imageType, imageSize, format) {}
-
- VkImageUsageFlags imageSparseUsageFlags (void) const;
- VkDescriptorType imageSparseDescType (void) const;
+ SparseShaderIntrinsicsInstanceFetch (Context& context,
+ const SpirVFunction function,
+ const ImageType imageType,
+ const tcu::UVec3& imageSize,
+ const tcu::TextureFormat& format)
+ : SparseShaderIntrinsicsInstanceStorage (context, function, imageType, imageSize, format) {}
+
+ VkImageUsageFlags imageSparseUsageFlags (void) const { return VK_IMAGE_USAGE_SAMPLED_BIT; }
+ VkDescriptorType imageSparseDescType (void) const { return VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; }
};
-VkImageUsageFlags SparseShaderIntrinsicsInstanceFetch::imageSparseUsageFlags (void) const
-{
- return VK_IMAGE_USAGE_SAMPLED_BIT;
-}
-
-VkDescriptorType SparseShaderIntrinsicsInstanceFetch::imageSparseDescType (void) const
-{
- return VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
-}
-
TestInstance* SparseCaseOpImageSparseFetch::createInstance (Context& context) const
{
return new SparseShaderIntrinsicsInstanceFetch(context, m_function, m_imageType, m_imageSize, m_format);
class SparseShaderIntrinsicsInstanceRead : public SparseShaderIntrinsicsInstanceStorage
{
public:
- SparseShaderIntrinsicsInstanceRead (Context& context,
- const SpirVFunction function,
- const ImageType imageType,
- const tcu::UVec3& imageSize,
- const tcu::TextureFormat& format)
- : SparseShaderIntrinsicsInstanceStorage(context, function, imageType, imageSize, format) {}
-
- VkImageUsageFlags imageSparseUsageFlags (void) const;
- VkDescriptorType imageSparseDescType (void) const;
+ SparseShaderIntrinsicsInstanceRead (Context& context,
+ const SpirVFunction function,
+ const ImageType imageType,
+ const tcu::UVec3& imageSize,
+ const tcu::TextureFormat& format)
+ : SparseShaderIntrinsicsInstanceStorage (context, function, imageType, imageSize, format) {}
+
+ VkImageUsageFlags imageSparseUsageFlags (void) const { return VK_IMAGE_USAGE_STORAGE_BIT; }
+ VkDescriptorType imageSparseDescType (void) const { return VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; }
};
-VkImageUsageFlags SparseShaderIntrinsicsInstanceRead::imageSparseUsageFlags (void) const
-{
- return VK_IMAGE_USAGE_STORAGE_BIT;
-}
-
-VkDescriptorType SparseShaderIntrinsicsInstanceRead::imageSparseDescType (void) const
-{
- return VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
-}
-
TestInstance* SparseCaseOpImageSparseRead::createInstance (Context& context) const
{
return new SparseShaderIntrinsicsInstanceRead(context, m_function, m_imageType, m_imageSize, m_format);
const ImageType imageType,
const tcu::UVec3& imageSize,
const tcu::TextureFormat& format)
- : SparseShaderIntrinsicsCaseBase(testCtx, name, function, imageType, imageSize, format) {}
+ : SparseShaderIntrinsicsCaseBase (testCtx, name, function, imageType, imageSize, format) {}
void initPrograms (vk::SourceCollections& programCollection) const;
- virtual std::string sparseImageTypeDecl(const std::string& imageType,
- const std::string& componentType) const = 0;
+ virtual std::string sparseImageTypeDecl (const std::string& imageType,
+ const std::string& componentType) const = 0;
- virtual std::string sparseImageOpString (const std::string& resultVariable,
+ virtual std::string sparseImageOpString (const std::string& resultVariable,
const std::string& resultType,
const std::string& image,
const std::string& coord,
class SparseCaseOpImageSparseFetch : public SparseShaderIntrinsicsCaseStorage
{
public:
- SparseCaseOpImageSparseFetch (tcu::TestContext& testCtx,
- const std::string& name,
- const SpirVFunction function,
- const ImageType imageType,
- const tcu::UVec3& imageSize,
- const tcu::TextureFormat& format)
- : SparseShaderIntrinsicsCaseStorage(testCtx, name, function, imageType, imageSize, format) {}
+ SparseCaseOpImageSparseFetch (tcu::TestContext& testCtx,
+ const std::string& name,
+ const SpirVFunction function,
+ const ImageType imageType,
+ const tcu::UVec3& imageSize,
+ const tcu::TextureFormat& format)
+ : SparseShaderIntrinsicsCaseStorage (testCtx, name, function, imageType, imageSize, format) {}
- TestInstance* createInstance(Context& context) const;
+ TestInstance* createInstance (Context& context) const;
- std::string sparseImageTypeDecl(const std::string& imageType, const std::string& componentType) const;
+ std::string sparseImageTypeDecl (const std::string& imageType,
+ const std::string& componentType) const;
- std::string sparseImageOpString(const std::string& resultVariable, const std::string& resultType, const std::string& image, const std::string& coord, const std::string& mipLevel) const;
+ std::string sparseImageOpString (const std::string& resultVariable,
+ const std::string& resultType,
+ const std::string& image,
+ const std::string& coord,
+ const std::string& mipLevel) const;
};
class SparseCaseOpImageSparseRead : public SparseShaderIntrinsicsCaseStorage
{
public:
- SparseCaseOpImageSparseRead (tcu::TestContext& testCtx,
- const std::string& name,
- const SpirVFunction function,
- const ImageType imageType,
- const tcu::UVec3& imageSize,
- const tcu::TextureFormat& format)
- : SparseShaderIntrinsicsCaseStorage(testCtx, name, function, imageType, imageSize, format) {}
+ SparseCaseOpImageSparseRead (tcu::TestContext& testCtx,
+ const std::string& name,
+ const SpirVFunction function,
+ const ImageType imageType,
+ const tcu::UVec3& imageSize,
+ const tcu::TextureFormat& format)
+ : SparseShaderIntrinsicsCaseStorage (testCtx, name, function, imageType, imageSize, format) {}
- TestInstance* createInstance(Context& context) const;
+ TestInstance* createInstance (Context& context) const;
- std::string sparseImageTypeDecl(const std::string& imageType, const std::string& componentType) const;
+ std::string sparseImageTypeDecl (const std::string& imageType,
+ const std::string& componentType) const;
- std::string sparseImageOpString(const std::string& resultVariable, const std::string& resultType, const std::string& image, const std::string& coord, const std::string& mipLevel) const;
+ std::string sparseImageOpString (const std::string& resultVariable,
+ const std::string& resultType,
+ const std::string& image,
+ const std::string& coord,
+ const std::string& mipLevel) const;
};
} // sparse
{
de::MovePtr<tcu::TestCaseGroup> sparseTests (new tcu::TestCaseGroup(testCtx, "sparse_resources", "Sparse Resources Tests"));
- sparseTests->addChild(createBufferSparseBindingTests(testCtx));
- sparseTests->addChild(createImageSparseBindingTests(testCtx));
- sparseTests->addChild(createBufferSparseResidencyTests(testCtx));
- sparseTests->addChild(createImageSparseResidencyTests(testCtx));
- sparseTests->addChild(createMipmapSparseResidencyTests(testCtx));
- sparseTests->addChild(createBufferSparseMemoryAliasingTests(testCtx));
- sparseTests->addChild(createImageSparseMemoryAliasingTests(testCtx));
+ sparseTests->addChild(createBufferSparseBindingTests (testCtx));
+ sparseTests->addChild(createImageSparseBindingTests (testCtx));
+ sparseTests->addChild(createBufferSparseResidencyTests (testCtx));
+ sparseTests->addChild(createImageSparseResidencyTests (testCtx));
+ sparseTests->addChild(createMipmapSparseResidencyTests (testCtx));
+ sparseTests->addChild(createBufferSparseMemoryAliasingTests (testCtx));
+ sparseTests->addChild(createImageSparseMemoryAliasingTests (testCtx));
sparseTests->addChild(createSparseResourcesShaderIntrinsicsTests(testCtx));
return sparseTests.release();
namespace sparse
{
-Buffer::Buffer (const DeviceInterface& vk,
- const VkDevice device,
- Allocator& allocator,
- const VkBufferCreateInfo& bufferCreateInfo,
- const MemoryRequirement memoryRequirement)
- : m_buffer (createBuffer(vk, device, &bufferCreateInfo))
- , m_allocation (allocator.allocate(getBufferMemoryRequirements(vk, device, *m_buffer), memoryRequirement))
-{
- VK_CHECK(vk.bindBufferMemory(device, *m_buffer, m_allocation->getMemory(), m_allocation->getOffset()));
-}
-
-Image::Image (const DeviceInterface& vk,
- const VkDevice device,
- Allocator& allocator,
- const VkImageCreateInfo& imageCreateInfo,
- const MemoryRequirement memoryRequirement)
- : m_image (createImage(vk, device, &imageCreateInfo))
- , m_allocation (allocator.allocate(getImageMemoryRequirements(vk, device, *m_image), memoryRequirement))
-{
- VK_CHECK(vk.bindImageMemory(device, *m_image, m_allocation->getMemory(), m_allocation->getOffset()));
-}
-
tcu::UVec3 getShaderGridSize (const ImageType imageType, const tcu::UVec3& imageSize, const deUint32 mipLevel)
{
const deUint32 mipLevelX = std::max(imageSize.x() >> mipLevel, 1u);
return createSemaphore(vk, device, &semaphoreCreateInfo);
}
+Move<VkFence> makeFence (const DeviceInterface& vk, const VkDevice device, const VkFenceCreateFlags flags)
+{
+ const VkFenceCreateInfo fenceCreateInfo =
+ {
+ VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, // VkStructureType sType;
+ DE_NULL, // const void* pNext;
+ flags, // VkFenceCreateFlags flags;
+ };
+ return createFence(vk, device, &fenceCreateInfo);
+}
+
VkBufferMemoryBarrier makeBufferMemoryBarrier (const VkAccessFlags srcAccessMask,
const VkAccessFlags dstAccessMask,
const VkBuffer buffer,
return barrier;
}
-VkImageMemoryBarrier makeImageMemoryBarrier (const vk::VkAccessFlags srcAccessMask,
- const vk::VkAccessFlags dstAccessMask,
- const vk::VkImageLayout oldLayout,
- const vk::VkImageLayout newLayout,
- const deUint32 srcQueueFamilyIndex,
- const deUint32 destQueueFamilyIndex,
- const vk::VkImage image,
- const vk::VkImageSubresourceRange subresourceRange)
+VkImageMemoryBarrier makeImageMemoryBarrier (const VkAccessFlags srcAccessMask,
+ const VkAccessFlags dstAccessMask,
+ const VkImageLayout oldLayout,
+ const VkImageLayout newLayout,
+ const deUint32 srcQueueFamilyIndex,
+ const deUint32 destQueueFamilyIndex,
+ const VkImage image,
+ const VkImageSubresourceRange subresourceRange)
{
const VkImageMemoryBarrier barrier =
{
return barrier;
}
-vk::VkMemoryBarrier makeMemoryBarrier (const vk::VkAccessFlags srcAccessMask,
- const vk::VkAccessFlags dstAccessMask)
+VkMemoryBarrier makeMemoryBarrier (const VkAccessFlags srcAccessMask,
+ const VkAccessFlags dstAccessMask)
{
const VkMemoryBarrier barrier =
{
return barrier;
}
+de::MovePtr<Allocation> bindImage (const DeviceInterface& vk, const VkDevice device, Allocator& allocator, const VkImage image, const MemoryRequirement requirement)
+{
+ de::MovePtr<Allocation> alloc = allocator.allocate(getImageMemoryRequirements(vk, device, image), requirement);
+ VK_CHECK(vk.bindImageMemory(device, image, alloc->getMemory(), alloc->getOffset()));
+ return alloc;
+}
+
+de::MovePtr<Allocation> bindBuffer (const DeviceInterface& vk, const VkDevice device, Allocator& allocator, const VkBuffer buffer, const MemoryRequirement requirement)
+{
+ de::MovePtr<Allocation> alloc(allocator.allocate(getBufferMemoryRequirements(vk, device, buffer), requirement));
+ VK_CHECK(vk.bindBufferMemory(device, buffer, alloc->getMemory(), alloc->getOffset()));
+ return alloc;
+}
+
void beginCommandBuffer (const DeviceInterface& vk, const VkCommandBuffer commandBuffer)
{
const VkCommandBufferBeginInfo commandBufBeginParams =
return imageMemoryBind;
}
-VkSparseMemoryBind makeSparseMemoryBind (const vk::DeviceInterface& vk,
- const vk::VkDevice device,
- const vk::VkDeviceSize allocationSize,
- const deUint32 memoryType,
- const vk::VkDeviceSize resourceOffset)
+VkSparseMemoryBind makeSparseMemoryBind (const DeviceInterface& vk,
+ const VkDevice device,
+ const VkDeviceSize allocationSize,
+ const deUint32 memoryType,
+ const VkDeviceSize resourceOffset)
{
const VkMemoryAllocateInfo allocInfo =
{
return memoryBind;
}
-void beginRenderPass (const DeviceInterface& vk,
- const VkCommandBuffer commandBuffer,
- const VkRenderPass renderPass,
- const VkFramebuffer framebuffer,
- const VkRect2D& renderArea,
- const std::vector<VkClearValue>& clearValues)
+void requireFeatures (const InstanceInterface& vki, const VkPhysicalDevice physDevice, const FeatureFlags flags)
{
+ const VkPhysicalDeviceFeatures features = getPhysicalDeviceFeatures(vki, physDevice);
- const VkRenderPassBeginInfo renderPassBeginInfo = {
- VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- renderPass, // VkRenderPass renderPass;
- framebuffer, // VkFramebuffer framebuffer;
- renderArea, // VkRect2D renderArea;
- static_cast<deUint32>(clearValues.size()), // deUint32 clearValueCount;
- &clearValues[0], // const VkClearValue* pClearValues;
- };
+ if (((flags & FEATURE_TESSELLATION_SHADER) != 0) && !features.tessellationShader)
+ throw tcu::NotSupportedError("Tessellation shader not supported");
- vk.cmdBeginRenderPass(commandBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
-}
+ if (((flags & FEATURE_GEOMETRY_SHADER) != 0) && !features.geometryShader)
+ throw tcu::NotSupportedError("Geometry shader not supported");
-void beginRenderPassWithRasterizationDisabled (const DeviceInterface& vk,
- const VkCommandBuffer commandBuffer,
- const VkRenderPass renderPass,
- const VkFramebuffer framebuffer)
-{
- const VkRect2D renderArea = {{ 0, 0 }, { 0, 0 }};
-
- const VkRenderPassBeginInfo renderPassBeginInfo = {
- VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- renderPass, // VkRenderPass renderPass;
- framebuffer, // VkFramebuffer framebuffer;
- renderArea, // VkRect2D renderArea;
- 0u, // uint32_t clearValueCount;
- DE_NULL, // const VkClearValue* pClearValues;
- };
+ if (((flags & FEATURE_SHADER_FLOAT_64) != 0) && !features.shaderFloat64)
+ throw tcu::NotSupportedError("Double-precision floats not supported");
- vk.cmdBeginRenderPass(commandBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
-}
+ if (((flags & FEATURE_VERTEX_PIPELINE_STORES_AND_ATOMICS) != 0) && !features.vertexPipelineStoresAndAtomics)
+ throw tcu::NotSupportedError("SSBO and image writes not supported in vertex pipeline");
-void endRenderPass (const DeviceInterface& vk,
- const VkCommandBuffer commandBuffer)
-{
- vk.cmdEndRenderPass(commandBuffer);
+ if (((flags & FEATURE_FRAGMENT_STORES_AND_ATOMICS) != 0) && !features.fragmentStoresAndAtomics)
+ throw tcu::NotSupportedError("SSBO and image writes not supported in fragment shader");
+
+ if (((flags & FEATURE_SHADER_TESSELLATION_AND_GEOMETRY_POINT_SIZE) != 0) && !features.shaderTessellationAndGeometryPointSize)
+ throw tcu::NotSupportedError("Tessellation and geometry shaders don't support PointSize built-in");
}
-Move<VkRenderPass> makeRenderPass (const DeviceInterface& vk,
- const VkDevice device,
- const VkFormat colorFormat)
+deUint32 findMatchingMemoryType (const InstanceInterface& instance,
+ const VkPhysicalDevice physicalDevice,
+ const VkMemoryRequirements& objectMemoryRequirements,
+ const MemoryRequirement& memoryRequirement)
{
- const VkAttachmentDescription colorAttachmentDescription =
- {
- (VkAttachmentDescriptionFlags)0, // VkAttachmentDescriptionFlags flags;
- colorFormat, // VkFormat format;
- VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
- VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp;
- VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
- VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp;
- VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp;
- VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout;
- VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout;
- };
-
- const VkAttachmentReference colorAttachmentReference =
- {
- 0u, // deUint32 attachment;
- VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout layout;
- };
+ const VkPhysicalDeviceMemoryProperties deviceMemoryProperties = getPhysicalDeviceMemoryProperties(instance, physicalDevice);
- const VkAttachmentReference depthAttachmentReference =
+ for (deUint32 memoryTypeNdx = 0; memoryTypeNdx < deviceMemoryProperties.memoryTypeCount; ++memoryTypeNdx)
{
- VK_ATTACHMENT_UNUSED, // deUint32 attachment;
- VK_IMAGE_LAYOUT_UNDEFINED // VkImageLayout layout;
- };
-
- const VkSubpassDescription subpassDescription =
- {
- (VkSubpassDescriptionFlags)0, // VkSubpassDescriptionFlags flags;
- VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint;
- 0u, // deUint32 inputAttachmentCount;
- DE_NULL, // const VkAttachmentReference* pInputAttachments;
- 1u, // deUint32 colorAttachmentCount;
- &colorAttachmentReference, // const VkAttachmentReference* pColorAttachments;
- DE_NULL, // const VkAttachmentReference* pResolveAttachments;
- &depthAttachmentReference, // const VkAttachmentReference* pDepthStencilAttachment;
- 0u, // deUint32 preserveAttachmentCount;
- DE_NULL // const deUint32* pPreserveAttachments;
- };
-
- const VkRenderPassCreateInfo renderPassInfo =
- {
- VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- (VkRenderPassCreateFlags)0, // VkRenderPassCreateFlags flags;
- 1u, // deUint32 attachmentCount;
- &colorAttachmentDescription, // const VkAttachmentDescription* pAttachments;
- 1u, // deUint32 subpassCount;
- &subpassDescription, // const VkSubpassDescription* pSubpasses;
- 0u, // deUint32 dependencyCount;
- DE_NULL // const VkSubpassDependency* pDependencies;
- };
+ if ((objectMemoryRequirements.memoryTypeBits & (1u << memoryTypeNdx)) != 0 &&
+ memoryRequirement.matchesHeap(deviceMemoryProperties.memoryTypes[memoryTypeNdx].propertyFlags))
+ {
+ return memoryTypeNdx;
+ }
+ }
- return createRenderPass(vk, device, &renderPassInfo);
+ return NO_MATCH_FOUND;
}
-Move<VkRenderPass> makeRenderPassWithoutAttachments (const DeviceInterface& vk,
- const VkDevice device)
+bool checkSparseSupportForImageType (const InstanceInterface& instance,
+ const VkPhysicalDevice physicalDevice,
+ const ImageType imageType)
{
- const VkAttachmentReference unusedAttachment =
- {
- VK_ATTACHMENT_UNUSED, // deUint32 attachment;
- VK_IMAGE_LAYOUT_UNDEFINED // VkImageLayout layout;
- };
+ const VkPhysicalDeviceFeatures deviceFeatures = getPhysicalDeviceFeatures(instance, physicalDevice);
- const VkSubpassDescription subpassDescription =
- {
- (VkSubpassDescriptionFlags)0, // VkSubpassDescriptionFlags flags;
- VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint;
- 0u, // deUint32 inputAttachmentCount;
- DE_NULL, // const VkAttachmentReference* pInputAttachments;
- 0u, // deUint32 colorAttachmentCount;
- DE_NULL, // const VkAttachmentReference* pColorAttachments;
- DE_NULL, // const VkAttachmentReference* pResolveAttachments;
- &unusedAttachment, // const VkAttachmentReference* pDepthStencilAttachment;
- 0u, // deUint32 preserveAttachmentCount;
- DE_NULL // const deUint32* pPreserveAttachments;
- };
+ if (!deviceFeatures.sparseBinding)
+ return false;
- const VkRenderPassCreateInfo renderPassInfo =
+ switch (mapImageType(imageType))
{
- VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- (VkRenderPassCreateFlags)0, // VkRenderPassCreateFlags flags;
- 0u, // deUint32 attachmentCount;
- DE_NULL, // const VkAttachmentDescription* pAttachments;
- 1u, // deUint32 subpassCount;
- &subpassDescription, // const VkSubpassDescription* pSubpasses;
- 0u, // deUint32 dependencyCount;
- DE_NULL // const VkSubpassDependency* pDependencies;
+ case VK_IMAGE_TYPE_2D:
+ return deviceFeatures.sparseResidencyImage2D == VK_TRUE;
+ case VK_IMAGE_TYPE_3D:
+ return deviceFeatures.sparseResidencyImage3D == VK_TRUE;
+ default:
+ DE_ASSERT(0);
+ return false;
};
-
- return createRenderPass(vk, device, &renderPassInfo);
}
-Move<VkFramebuffer> makeFramebuffer (const DeviceInterface& vk,
- const VkDevice device,
- const VkRenderPass renderPass,
- const VkImageView colorAttachment,
- const deUint32 width,
- const deUint32 height,
- const deUint32 layers)
+bool checkSparseSupportForImageFormat (const InstanceInterface& instance,
+ const VkPhysicalDevice physicalDevice,
+ const VkImageCreateInfo& imageInfo)
{
- const VkFramebufferCreateInfo framebufferInfo = {
- VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- (VkFramebufferCreateFlags)0, // VkFramebufferCreateFlags flags;
- renderPass, // VkRenderPass renderPass;
- 1u, // uint32_t attachmentCount;
- &colorAttachment, // const VkImageView* pAttachments;
- width, // uint32_t width;
- height, // uint32_t height;
- layers, // uint32_t layers;
- };
+ const std::vector<VkSparseImageFormatProperties> sparseImageFormatPropVec = getPhysicalDeviceSparseImageFormatProperties(
+ instance, physicalDevice, imageInfo.format, imageInfo.imageType, imageInfo.samples, imageInfo.usage, imageInfo.tiling);
- return createFramebuffer(vk, device, &framebufferInfo);
+ return sparseImageFormatPropVec.size() > 0u;
}
-Move<VkFramebuffer> makeFramebufferWithoutAttachments (const DeviceInterface& vk,
- const VkDevice device,
- const VkRenderPass renderPass)
+bool checkImageFormatFeatureSupport (const InstanceInterface& instance,
+ const VkPhysicalDevice physicalDevice,
+ const VkFormat format,
+ const VkFormatFeatureFlags featureFlags)
{
- const VkFramebufferCreateInfo framebufferInfo = {
- VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- (VkFramebufferCreateFlags)0, // VkFramebufferCreateFlags flags;
- renderPass, // VkRenderPass renderPass;
- 0u, // uint32_t attachmentCount;
- DE_NULL, // const VkImageView* pAttachments;
- 0u, // uint32_t width;
- 0u, // uint32_t height;
- 0u, // uint32_t layers;
- };
+ const VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(instance, physicalDevice, format);
- return createFramebuffer(vk, device, &framebufferInfo);
+ return (formatProperties.optimalTilingFeatures & featureFlags) == featureFlags;
}
-GraphicsPipelineBuilder& GraphicsPipelineBuilder::setShader (const DeviceInterface& vk,
- const VkDevice device,
- const VkShaderStageFlagBits stage,
- const ProgramBinary& binary,
- const VkSpecializationInfo* specInfo)
+deUint32 getSparseAspectRequirementsIndex (const std::vector<VkSparseImageMemoryRequirements>& requirements,
+ const VkImageAspectFlags aspectFlags)
{
- VkShaderModule module;
- switch (stage)
+ for (deUint32 memoryReqNdx = 0; memoryReqNdx < requirements.size(); ++memoryReqNdx)
{
- case (VK_SHADER_STAGE_VERTEX_BIT):
- DE_ASSERT(m_vertexShaderModule.get() == DE_NULL);
- m_vertexShaderModule = createShaderModule(vk, device, binary, (VkShaderModuleCreateFlags)0);
- module = *m_vertexShaderModule;
- break;
-
- case (VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT):
- DE_ASSERT(m_tessControlShaderModule.get() == DE_NULL);
- m_tessControlShaderModule = createShaderModule(vk, device, binary, (VkShaderModuleCreateFlags)0);
- module = *m_tessControlShaderModule;
- break;
-
- case (VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT):
- DE_ASSERT(m_tessEvaluationShaderModule.get() == DE_NULL);
- m_tessEvaluationShaderModule = createShaderModule(vk, device, binary, (VkShaderModuleCreateFlags)0);
- module = *m_tessEvaluationShaderModule;
- break;
-
- case (VK_SHADER_STAGE_GEOMETRY_BIT):
- DE_ASSERT(m_geometryShaderModule.get() == DE_NULL);
- m_geometryShaderModule = createShaderModule(vk, device, binary, (VkShaderModuleCreateFlags)0);
- module = *m_geometryShaderModule;
- break;
-
- case (VK_SHADER_STAGE_FRAGMENT_BIT):
- DE_ASSERT(m_fragmentShaderModule.get() == DE_NULL);
- m_fragmentShaderModule = createShaderModule(vk, device, binary, (VkShaderModuleCreateFlags)0);
- module = *m_fragmentShaderModule;
- break;
-
- default:
- DE_FATAL("Invalid shader stage");
- return *this;
+ if (requirements[memoryReqNdx].formatProperties.aspectMask & aspectFlags)
+ return memoryReqNdx;
}
- const VkPipelineShaderStageCreateInfo pipelineShaderStageInfo =
- {
- VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- (VkPipelineShaderStageCreateFlags)0, // VkPipelineShaderStageCreateFlags flags;
- stage, // VkShaderStageFlagBits stage;
- module, // VkShaderModule module;
- "main", // const char* pName;
- specInfo, // const VkSpecializationInfo* pSpecializationInfo;
- };
-
- m_shaderStageFlags |= stage;
- m_shaderStages.push_back(pipelineShaderStageInfo);
-
- return *this;
-}
-
-template<typename T>
-inline const T* dataPointer (const std::vector<T>& vec)
-{
- return (vec.size() != 0 ? &vec[0] : DE_NULL);
-}
-
-Move<VkPipeline> GraphicsPipelineBuilder::build (const DeviceInterface& vk,
- const VkDevice device,
- const VkPipelineLayout pipelineLayout,
- const VkRenderPass renderPass)
-{
- const VkPipelineVertexInputStateCreateInfo vertexInputStateInfo =
- {
- VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- (VkPipelineVertexInputStateCreateFlags)0, // VkPipelineVertexInputStateCreateFlags flags;
- static_cast<deUint32>(m_vertexInputBindings.size()), // uint32_t vertexBindingDescriptionCount;
- dataPointer(m_vertexInputBindings), // const VkVertexInputBindingDescription* pVertexBindingDescriptions;
- static_cast<deUint32>(m_vertexInputAttributes.size()), // uint32_t vertexAttributeDescriptionCount;
- dataPointer(m_vertexInputAttributes), // const VkVertexInputAttributeDescription* pVertexAttributeDescriptions;
- };
-
- const bool isTessellationEnabled = (m_shaderStageFlags & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) != 0;
-
- const VkPipelineInputAssemblyStateCreateInfo pipelineInputAssemblyStateInfo =
- {
- VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- (VkPipelineInputAssemblyStateCreateFlags)0, // VkPipelineInputAssemblyStateCreateFlags flags;
- isTessellationEnabled ? VK_PRIMITIVE_TOPOLOGY_PATCH_LIST : m_primitiveTopology, // VkPrimitiveTopology topology;
- VK_FALSE, // VkBool32 primitiveRestartEnable;
- };
-
- const VkPipelineTessellationStateCreateInfo pipelineTessellationStateInfo =
- {
- VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- (VkPipelineTessellationStateCreateFlags)0, // VkPipelineTessellationStateCreateFlags flags;
- m_patchControlPoints, // uint32_t patchControlPoints;
- };
-
- const VkViewport viewport = makeViewport
- (
- 0.0f, 0.0f,
- static_cast<float>(m_renderSize.x()), static_cast<float>(m_renderSize.y()),
- 0.0f, 1.0f
- );
-
- const VkRect2D scissor =
- {
- makeOffset2D(0, 0),
- makeExtent2D(m_renderSize.x(), m_renderSize.y()),
- };
-
- const VkPipelineViewportStateCreateInfo pipelineViewportStateInfo =
- {
- VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- (VkPipelineViewportStateCreateFlags)0, // VkPipelineViewportStateCreateFlags flags;
- 1u, // uint32_t viewportCount;
- &viewport, // const VkViewport* pViewports;
- 1u, // uint32_t scissorCount;
- &scissor, // const VkRect2D* pScissors;
- };
-
- const bool isRasterizationDisabled = ((m_shaderStageFlags & VK_SHADER_STAGE_FRAGMENT_BIT) == 0);
-
- const VkPipelineRasterizationStateCreateInfo pipelineRasterizationStateInfo =
- {
- VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- (VkPipelineRasterizationStateCreateFlags)0, // VkPipelineRasterizationStateCreateFlags flags;
- VK_FALSE, // VkBool32 depthClampEnable;
- isRasterizationDisabled, // VkBool32 rasterizerDiscardEnable;
- VK_POLYGON_MODE_FILL, // VkPolygonMode polygonMode;
- m_cullModeFlags, // VkCullModeFlags cullMode;
- m_frontFace, // VkFrontFace frontFace;
- VK_FALSE, // VkBool32 depthBiasEnable;
- 0.0f, // float depthBiasConstantFactor;
- 0.0f, // float depthBiasClamp;
- 0.0f, // float depthBiasSlopeFactor;
- 1.0f, // float lineWidth;
- };
-
- const VkPipelineMultisampleStateCreateInfo pipelineMultisampleStateInfo =
- {
- VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- (VkPipelineMultisampleStateCreateFlags)0, // VkPipelineMultisampleStateCreateFlags flags;
- VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits rasterizationSamples;
- VK_FALSE, // VkBool32 sampleShadingEnable;
- 0.0f, // float minSampleShading;
- DE_NULL, // const VkSampleMask* pSampleMask;
- VK_FALSE, // VkBool32 alphaToCoverageEnable;
- VK_FALSE, // VkBool32 alphaToOneEnable;
- };
-
- const VkStencilOpState stencilOpState = makeStencilOpState
- (
- VK_STENCIL_OP_KEEP, // stencil fail
- VK_STENCIL_OP_KEEP, // depth & stencil pass
- VK_STENCIL_OP_KEEP, // depth only fail
- VK_COMPARE_OP_NEVER, // compare op
- 0u, // compare mask
- 0u, // write mask
- 0u // reference
- );
-
- const VkPipelineDepthStencilStateCreateInfo pipelineDepthStencilStateInfo =
- {
- VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- (VkPipelineDepthStencilStateCreateFlags)0, // VkPipelineDepthStencilStateCreateFlags flags;
- VK_FALSE, // VkBool32 depthTestEnable;
- VK_FALSE, // VkBool32 depthWriteEnable;
- VK_COMPARE_OP_LESS, // VkCompareOp depthCompareOp;
- VK_FALSE, // VkBool32 depthBoundsTestEnable;
- VK_FALSE, // VkBool32 stencilTestEnable;
- stencilOpState, // VkStencilOpState front;
- stencilOpState, // VkStencilOpState back;
- 0.0f, // float minDepthBounds;
- 1.0f, // float maxDepthBounds;
- };
-
- const VkColorComponentFlags colorComponentsAll = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
-
- std::vector<VkPipelineColorBlendAttachmentState> colorBlendAttachmentsStates;
-
- for (deUint32 attachmentNdx = 0; attachmentNdx < m_attachmentsCount; ++attachmentNdx)
- {
- const VkPipelineColorBlendAttachmentState colorBlendAttachmentState =
- {
- m_blendEnable, // VkBool32 blendEnable;
- VK_BLEND_FACTOR_SRC_ALPHA, // VkBlendFactor srcColorBlendFactor;
- VK_BLEND_FACTOR_ONE, // VkBlendFactor dstColorBlendFactor;
- VK_BLEND_OP_ADD, // VkBlendOp colorBlendOp;
- VK_BLEND_FACTOR_SRC_ALPHA, // VkBlendFactor srcAlphaBlendFactor;
- VK_BLEND_FACTOR_ONE, // VkBlendFactor dstAlphaBlendFactor;
- VK_BLEND_OP_ADD, // VkBlendOp alphaBlendOp;
- colorComponentsAll, // VkColorComponentFlags colorWriteMask;
- };
-
- colorBlendAttachmentsStates.push_back(colorBlendAttachmentState);
- }
-
- const VkPipelineColorBlendStateCreateInfo pipelineColorBlendStateInfo =
- {
- VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- (VkPipelineColorBlendStateCreateFlags)0, // VkPipelineColorBlendStateCreateFlags flags;
- VK_FALSE, // VkBool32 logicOpEnable;
- VK_LOGIC_OP_COPY, // VkLogicOp logicOp;
- static_cast<deUint32>(colorBlendAttachmentsStates.size()), // deUint32 attachmentCount;
- dataPointer(colorBlendAttachmentsStates), // const VkPipelineColorBlendAttachmentState* pAttachments;
- { 0.0f, 0.0f, 0.0f, 0.0f }, // float blendConstants[4];
- };
-
- const bool hasDynamicState = static_cast<deUint32>(m_dynamicStates.size()) > 0u;
-
- const VkPipelineDynamicStateCreateInfo dynamicStateCreateInfo =
- {
- VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- (VkPipelineDynamicStateCreateFlags)0, // VkPipelineDynamicStateCreateFlags flags;
- static_cast<deUint32>(m_dynamicStates.size()), // deUint32 dynamicStateCount;
- dataPointer(m_dynamicStates), // const VkDynamicState* pDynamicStates;
- };
-
- const VkGraphicsPipelineCreateInfo graphicsPipelineInfo =
- {
- VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- (VkPipelineCreateFlags)0, // VkPipelineCreateFlags flags;
- static_cast<deUint32>(m_shaderStages.size()), // deUint32 stageCount;
- dataPointer(m_shaderStages), // const VkPipelineShaderStageCreateInfo* pStages;
- &vertexInputStateInfo, // const VkPipelineVertexInputStateCreateInfo* pVertexInputState;
- &pipelineInputAssemblyStateInfo, // const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState;
- (isTessellationEnabled ? &pipelineTessellationStateInfo : DE_NULL), // const VkPipelineTessellationStateCreateInfo* pTessellationState;
- (isRasterizationDisabled ? DE_NULL : &pipelineViewportStateInfo), // const VkPipelineViewportStateCreateInfo* pViewportState;
- &pipelineRasterizationStateInfo, // const VkPipelineRasterizationStateCreateInfo* pRasterizationState;
- (isRasterizationDisabled ? DE_NULL : &pipelineMultisampleStateInfo), // const VkPipelineMultisampleStateCreateInfo* pMultisampleState;
- (isRasterizationDisabled ? DE_NULL : &pipelineDepthStencilStateInfo), // const VkPipelineDepthStencilStateCreateInfo* pDepthStencilState;
- (isRasterizationDisabled ? DE_NULL : &pipelineColorBlendStateInfo), // const VkPipelineColorBlendStateCreateInfo* pColorBlendState;
- (hasDynamicState ? &dynamicStateCreateInfo : DE_NULL), // const VkPipelineDynamicStateCreateInfo* pDynamicState;
- pipelineLayout, // VkPipelineLayout layout;
- renderPass, // VkRenderPass renderPass;
- 0u, // deUint32 subpass;
- DE_NULL, // VkPipeline basePipelineHandle;
- 0u, // deInt32 basePipelineIndex;
- };
-
- return createGraphicsPipeline(vk, device, DE_NULL, &graphicsPipelineInfo);
-}
-
-void requireFeatures (const InstanceInterface& vki, const VkPhysicalDevice physDevice, const FeatureFlags flags)
-{
- const VkPhysicalDeviceFeatures features = getPhysicalDeviceFeatures(vki, physDevice);
-
- if (((flags & FEATURE_TESSELLATION_SHADER) != 0) && !features.tessellationShader)
- throw tcu::NotSupportedError("Tessellation shader not supported");
-
- if (((flags & FEATURE_GEOMETRY_SHADER) != 0) && !features.geometryShader)
- throw tcu::NotSupportedError("Geometry shader not supported");
-
- if (((flags & FEATURE_SHADER_FLOAT_64) != 0) && !features.shaderFloat64)
- throw tcu::NotSupportedError("Double-precision floats not supported");
-
- if (((flags & FEATURE_VERTEX_PIPELINE_STORES_AND_ATOMICS) != 0) && !features.vertexPipelineStoresAndAtomics)
- throw tcu::NotSupportedError("SSBO and image writes not supported in vertex pipeline");
-
- if (((flags & FEATURE_FRAGMENT_STORES_AND_ATOMICS) != 0) && !features.fragmentStoresAndAtomics)
- throw tcu::NotSupportedError("SSBO and image writes not supported in fragment shader");
-
- if (((flags & FEATURE_SHADER_TESSELLATION_AND_GEOMETRY_POINT_SIZE) != 0) && !features.shaderTessellationAndGeometryPointSize)
- throw tcu::NotSupportedError("Tessellation and geometry shaders don't support PointSize built-in");
+ return NO_MATCH_FOUND;
}
} // sparse
#include "vkMemUtil.hpp"
#include "vkRef.hpp"
#include "vkRefUtil.hpp"
-#include "vkPrograms.hpp"
-#include "vkTypeUtil.hpp"
+#include "vkMemUtil.hpp"
#include "vkImageUtil.hpp"
#include "deSharedPtr.hpp"
+#include "deUniquePtr.hpp"
namespace vkt
{
namespace sparse
{
+typedef de::SharedPtr<vk::Unique<vk::VkDeviceMemory> > DeviceMemorySp;
+
enum ImageType
{
IMAGE_TYPE_1D = 0,
IMAGE_TYPE_LAST
};
-enum MemoryAlignment
+enum FeatureFlagBits
{
- MEM_ALIGN_BUFFERIMAGECOPY_OFFSET = 4u
+ FEATURE_TESSELLATION_SHADER = 1u << 0,
+ FEATURE_GEOMETRY_SHADER = 1u << 1,
+ FEATURE_SHADER_FLOAT_64 = 1u << 2,
+ FEATURE_VERTEX_PIPELINE_STORES_AND_ATOMICS = 1u << 3,
+ FEATURE_FRAGMENT_STORES_AND_ATOMICS = 1u << 4,
+ FEATURE_SHADER_TESSELLATION_AND_GEOMETRY_POINT_SIZE = 1u << 5,
};
+typedef deUint32 FeatureFlags;
-class Buffer
+enum
{
-public:
- Buffer (const vk::DeviceInterface& deviceInterface,
- const vk::VkDevice device,
- vk::Allocator& allocator,
- const vk::VkBufferCreateInfo& bufferCreateInfo,
- const vk::MemoryRequirement memoryRequirement);
-
- const vk::VkBuffer& get (void) const { return *m_buffer; }
- const vk::VkBuffer& operator* (void) const { return get(); }
- vk::Allocation& getAllocation (void) const { return *m_allocation; }
-
-private:
- vk::Unique<vk::VkBuffer> m_buffer;
- de::UniquePtr<vk::Allocation> m_allocation;
-
- Buffer (const Buffer&);
- Buffer& operator= (const Buffer&);
+ BUFFER_IMAGE_COPY_OFFSET_GRANULARITY = 4u,
+ NO_MATCH_FOUND = ~((deUint32)0), //!< no matching index
};
-class Image
-{
-public:
- Image (const vk::DeviceInterface& deviceInterface,
- const vk::VkDevice device,
- vk::Allocator& allocator,
- const vk::VkImageCreateInfo& imageCreateInfo,
- const vk::MemoryRequirement memoryRequirement);
-
- const vk::VkImage& get (void) const { return *m_image; }
- const vk::VkImage& operator* (void) const { return get(); }
- vk::Allocation& getAllocation (void) const { return *m_allocation; }
-
-private:
- vk::Unique<vk::VkImage> m_image;
- de::UniquePtr<vk::Allocation> m_allocation;
-
- Image (const Image&);
- Image& operator= (const Image&);
-};
+vk::VkImageType mapImageType (const ImageType imageType);
-class GraphicsPipelineBuilder
-{
-public:
- GraphicsPipelineBuilder (void) : m_renderSize (0, 0)
- , m_shaderStageFlags (0u)
- , m_cullModeFlags (vk::VK_CULL_MODE_NONE)
- , m_frontFace (vk::VK_FRONT_FACE_COUNTER_CLOCKWISE)
- , m_patchControlPoints (1u)
- , m_attachmentsCount (1u)
- , m_blendEnable (false)
- , m_primitiveTopology (vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST) {}
-
- GraphicsPipelineBuilder& setRenderSize (const tcu::IVec2& size) { m_renderSize = size; return *this; }
- GraphicsPipelineBuilder& setShader (const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkShaderStageFlagBits stage, const vk::ProgramBinary& binary, const vk::VkSpecializationInfo* specInfo);
- GraphicsPipelineBuilder& setPatchControlPoints (const deUint32 controlPoints) { m_patchControlPoints = controlPoints; return *this; }
- GraphicsPipelineBuilder& setAttachmentsCount (const deUint32 attachmentsCount) { m_attachmentsCount = attachmentsCount; return *this; }
- GraphicsPipelineBuilder& setCullModeFlags (const vk::VkCullModeFlags cullModeFlags) { m_cullModeFlags = cullModeFlags; return *this; }
- GraphicsPipelineBuilder& setFrontFace (const vk::VkFrontFace frontFace) { m_frontFace = frontFace; return *this; }
- GraphicsPipelineBuilder& setBlend (const bool enable) { m_blendEnable = enable; return *this; }
-
- //! Applies only to pipelines without tessellation shaders.
- GraphicsPipelineBuilder& setPrimitiveTopology (const vk::VkPrimitiveTopology topology) { m_primitiveTopology = topology; return *this; }
-
- GraphicsPipelineBuilder& addVertexBinding (const vk::VkVertexInputBindingDescription vertexBinding) { m_vertexInputBindings.push_back(vertexBinding); return *this; }
- GraphicsPipelineBuilder& addVertexAttribute (const vk::VkVertexInputAttributeDescription vertexAttribute) { m_vertexInputAttributes.push_back(vertexAttribute); return *this; }
- GraphicsPipelineBuilder& addDynamicState (const vk::VkDynamicState dynamicState) { m_dynamicStates.push_back(dynamicState); return *this; }
-
- vk::Move<vk::VkPipeline> build (const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkPipelineLayout pipelineLayout, const vk::VkRenderPass renderPass);
-
-private:
- tcu::IVec2 m_renderSize;
- vk::Move<vk::VkShaderModule> m_vertexShaderModule;
- vk::Move<vk::VkShaderModule> m_fragmentShaderModule;
- vk::Move<vk::VkShaderModule> m_geometryShaderModule;
- vk::Move<vk::VkShaderModule> m_tessControlShaderModule;
- vk::Move<vk::VkShaderModule> m_tessEvaluationShaderModule;
- std::vector<vk::VkPipelineShaderStageCreateInfo> m_shaderStages;
- std::vector<vk::VkVertexInputBindingDescription> m_vertexInputBindings;
- std::vector<vk::VkVertexInputAttributeDescription> m_vertexInputAttributes;
- std::vector<vk::VkDynamicState> m_dynamicStates;
- vk::VkShaderStageFlags m_shaderStageFlags;
- vk::VkCullModeFlags m_cullModeFlags;
- vk::VkFrontFace m_frontFace;
- deUint32 m_patchControlPoints;
- deUint32 m_attachmentsCount;
- bool m_blendEnable;
- vk::VkPrimitiveTopology m_primitiveTopology;
-
- GraphicsPipelineBuilder (const GraphicsPipelineBuilder&);
- GraphicsPipelineBuilder& operator= (const GraphicsPipelineBuilder&);
-};
+vk::VkImageViewType mapImageViewType (const ImageType imageType);
-enum FeatureFlagBits
-{
- FEATURE_TESSELLATION_SHADER = 1u << 0,
- FEATURE_GEOMETRY_SHADER = 1u << 1,
- FEATURE_SHADER_FLOAT_64 = 1u << 2,
- FEATURE_VERTEX_PIPELINE_STORES_AND_ATOMICS = 1u << 3,
- FEATURE_FRAGMENT_STORES_AND_ATOMICS = 1u << 4,
- FEATURE_SHADER_TESSELLATION_AND_GEOMETRY_POINT_SIZE = 1u << 5,
-};
-typedef deUint32 FeatureFlags;
+std::string getImageTypeName (const ImageType imageType);
+
+std::string getShaderImageType (const tcu::TextureFormat& format,
+ const ImageType imageType);
+
+std::string getShaderImageDataType (const tcu::TextureFormat& format);
+
+std::string getShaderImageFormatQualifier (const tcu::TextureFormat& format);
+
+std::string getShaderImageCoordinates (const ImageType imageType,
+ const std::string& x,
+ const std::string& xy,
+ const std::string& xyz);
-// Image helper functions
-vk::VkImageType mapImageType (const ImageType imageType);
-vk::VkImageViewType mapImageViewType (const ImageType imageType);
-std::string getImageTypeName (const ImageType imageType);
-std::string getShaderImageType (const tcu::TextureFormat& format,
- const ImageType imageType);
-std::string getShaderImageDataType (const tcu::TextureFormat& format);
-std::string getShaderImageFormatQualifier (const tcu::TextureFormat& format);
-std::string getShaderImageCoordinates (const ImageType imageType,
- const std::string& x,
- const std::string& xy,
- const std::string& xyz);
//!< Size used for addresing image in a compute shader
-tcu::UVec3 getShaderGridSize (const ImageType imageType,
- const tcu::UVec3& imageSize,
- const deUint32 mipLevel = 0);
+tcu::UVec3 getShaderGridSize (const ImageType imageType,
+ const tcu::UVec3& imageSize,
+ const deUint32 mipLevel = 0);
+
//!< Size of a single image layer
-tcu::UVec3 getLayerSize (const ImageType imageType,
- const tcu::UVec3& imageSize);
+tcu::UVec3 getLayerSize (const ImageType imageType,
+ const tcu::UVec3& imageSize);
+
//!< Number of array layers (for array and cube types)
-deUint32 getNumLayers (const ImageType imageType,
- const tcu::UVec3& imageSize);
+deUint32 getNumLayers (const ImageType imageType,
+ const tcu::UVec3& imageSize);
+
//!< Number of texels in an image
-deUint32 getNumPixels (const ImageType imageType,
- const tcu::UVec3& imageSize);
+deUint32 getNumPixels (const ImageType imageType,
+ const tcu::UVec3& imageSize);
+
//!< Coordinate dimension used for addressing (e.g. 3 (x,y,z) for 2d array)
-deUint32 getDimensions (const ImageType imageType);
+deUint32 getDimensions (const ImageType imageType);
+
//!< Coordinate dimension used for addressing a single layer (e.g. 2 (x,y) for 2d array)
-deUint32 getLayerDimensions (const ImageType imageType);
+deUint32 getLayerDimensions (const ImageType imageType);
+
//!< Helper function for checking if requested image size does not exceed device limits
-bool isImageSizeSupported (const vk::InstanceInterface& instance,
- const vk::VkPhysicalDevice physicalDevice,
- const ImageType imageType,
- const tcu::UVec3& imageSize);
-
-vk::VkExtent3D mipLevelExtents (const vk::VkExtent3D& baseExtents,
- const deUint32 mipLevel);
-
-tcu::UVec3 mipLevelExtents (const tcu::UVec3& baseExtents,
- const deUint32 mipLevel);
-
-deUint32 getImageMaxMipLevels (const vk::VkImageFormatProperties& imageFormatProperties,
- const vk::VkExtent3D& extent);
-
-deUint32 getImageMipLevelSizeInBytes (const vk::VkExtent3D& baseExtents,
- const deUint32 layersCount,
- const tcu::TextureFormat& format,
- const deUint32 mipmapLevel,
- const deUint32 mipmapMemoryAlignment = 1u);
-
-deUint32 getImageSizeInBytes (const vk::VkExtent3D& baseExtents,
- const deUint32 layersCount,
- const tcu::TextureFormat& format,
- const deUint32 mipmapLevelsCount = 1u,
- const deUint32 mipmapMemoryAlignment = 1u);
-
-vk::Move<vk::VkCommandPool> makeCommandPool (const vk::DeviceInterface& vk,
- const vk::VkDevice device,
- const deUint32 queueFamilyIndex);
-
-vk::Move<vk::VkCommandBuffer> makeCommandBuffer (const vk::DeviceInterface& vk,
- const vk::VkDevice device,
- const vk::VkCommandPool commandPool);
-
-vk::Move<vk::VkPipelineLayout> makePipelineLayout (const vk::DeviceInterface& vk,
- const vk::VkDevice device,
- const vk::VkDescriptorSetLayout descriptorSetLayout);
-
-vk::Move<vk::VkPipeline> makeComputePipeline (const vk::DeviceInterface& vk,
- const vk::VkDevice device,
- const vk::VkPipelineLayout pipelineLayout,
- const vk::VkShaderModule shaderModule,
- const vk::VkSpecializationInfo* specializationInfo = 0);
-
-vk::Move<vk::VkBufferView> makeBufferView (const vk::DeviceInterface& vk,
- const vk::VkDevice device,
- const vk::VkBuffer buffer,
- const vk::VkFormat format,
- const vk::VkDeviceSize offset,
- const vk::VkDeviceSize size);
-
-vk::Move<vk::VkImageView> makeImageView (const vk::DeviceInterface& vk,
- const vk::VkDevice device,
- const vk::VkImage image,
- const vk::VkImageViewType imageViewType,
- const vk::VkFormat format,
- const vk::VkImageSubresourceRange subresourceRange);
-
-vk::Move<vk::VkDescriptorSet> makeDescriptorSet (const vk::DeviceInterface& vk,
- const vk::VkDevice device,
- const vk::VkDescriptorPool descriptorPool,
- const vk::VkDescriptorSetLayout setLayout);
-
-vk::Move<vk::VkSemaphore> makeSemaphore (const vk::DeviceInterface& vk,
- const vk::VkDevice device);
-
-vk::VkBufferCreateInfo makeBufferCreateInfo (const vk::VkDeviceSize bufferSize,
- const vk::VkBufferUsageFlags usage);
-
-vk::VkBufferImageCopy makeBufferImageCopy (const vk::VkExtent3D extent,
- const deUint32 layersCount,
- const deUint32 mipmapLevel = 0u,
- const vk::VkDeviceSize bufferOffset = 0ull);
-
-vk::VkBufferMemoryBarrier makeBufferMemoryBarrier (const vk::VkAccessFlags srcAccessMask,
- const vk::VkAccessFlags dstAccessMask,
- const vk::VkBuffer buffer,
- const vk::VkDeviceSize offset,
- const vk::VkDeviceSize bufferSizeBytes);
-
-vk::VkImageMemoryBarrier makeImageMemoryBarrier (const vk::VkAccessFlags srcAccessMask,
- const vk::VkAccessFlags dstAccessMask,
- const vk::VkImageLayout oldLayout,
- const vk::VkImageLayout newLayout,
- const vk::VkImage image,
- const vk::VkImageSubresourceRange subresourceRange);
-
-vk::VkImageMemoryBarrier makeImageMemoryBarrier (const vk::VkAccessFlags srcAccessMask,
- const vk::VkAccessFlags dstAccessMask,
- const vk::VkImageLayout oldLayout,
- const vk::VkImageLayout newLayout,
- const deUint32 srcQueueFamilyIndex,
- const deUint32 destQueueFamilyIndex,
- const vk::VkImage image,
- const vk::VkImageSubresourceRange subresourceRange);
-
-vk::VkMemoryBarrier makeMemoryBarrier (const vk::VkAccessFlags srcAccessMask,
- const vk::VkAccessFlags dstAccessMask);
-
-void beginCommandBuffer (const vk::DeviceInterface& vk,
- const vk::VkCommandBuffer cmdBuffer);
-
-void endCommandBuffer (const vk::DeviceInterface& vk,
- const vk::VkCommandBuffer cmdBuffer);
-
-void submitCommands (const vk::DeviceInterface& vk,
- const vk::VkQueue queue,
- const vk::VkCommandBuffer cmdBuffer,
- const deUint32 waitSemaphoreCount = 0,
- const vk::VkSemaphore* pWaitSemaphores = DE_NULL,
- const vk::VkPipelineStageFlags* pWaitDstStageMask = DE_NULL,
- const deUint32 signalSemaphoreCount = 0,
- const vk::VkSemaphore* pSignalSemaphores = DE_NULL);
-
-void submitCommandsAndWait (const vk::DeviceInterface& vk,
- const vk::VkDevice device,
- const vk::VkQueue queue,
- const vk::VkCommandBuffer cmdBuffer,
- const deUint32 waitSemaphoreCount = 0,
- const vk::VkSemaphore* pWaitSemaphores = DE_NULL,
- const vk::VkPipelineStageFlags* pWaitDstStageMask = DE_NULL,
- const deUint32 signalSemaphoreCount = 0,
- const vk::VkSemaphore* pSignalSemaphores = DE_NULL);
-
-vk::VkSparseImageMemoryBind makeSparseImageMemoryBind (const vk::DeviceInterface& vk,
- const vk::VkDevice device,
- const vk::VkDeviceSize allocationSize,
- const deUint32 memoryType,
- const vk::VkImageSubresource& subresource,
- const vk::VkOffset3D& offset,
- const vk::VkExtent3D& extent);
-
-vk::VkSparseMemoryBind makeSparseMemoryBind (const vk::DeviceInterface& vk,
- const vk::VkDevice device,
- const vk::VkDeviceSize allocationSize,
- const deUint32 memoryType,
- const vk::VkDeviceSize resourceOffset);
-
-vk::Move<vk::VkRenderPass> makeRenderPass (const vk::DeviceInterface& vk,
- const vk::VkDevice device,
- const vk::VkFormat colorFormat);
-
-vk::Move<vk::VkRenderPass> makeRenderPassWithoutAttachments(const vk::DeviceInterface& vk,
- const vk::VkDevice device);
-
-vk::Move<vk::VkFramebuffer> makeFramebuffer (const vk::DeviceInterface& vk,
- const vk::VkDevice device,
- const vk::VkRenderPass renderPass,
- const vk::VkImageView colorAttachment,
- const deUint32 width,
- const deUint32 height,
- const deUint32 layers);
-
-vk::Move<vk::VkFramebuffer> makeFramebufferWithoutAttachments (const vk::DeviceInterface& vk,
- const vk::VkDevice device,
- const vk::VkRenderPass renderPass);
-
-void beginRenderPass (const vk::DeviceInterface& vk,
- const vk::VkCommandBuffer commandBuffer,
- const vk::VkRenderPass renderPass,
- const vk::VkFramebuffer framebuffer,
- const vk::VkRect2D& renderArea,
- const std::vector<vk::VkClearValue>& clearValues);
-
-void beginRenderPassWithRasterizationDisabled(const vk::DeviceInterface& vk,
- const vk::VkCommandBuffer commandBuffer,
- const vk::VkRenderPass renderPass,
- const vk::VkFramebuffer framebuffer);
-
-void endRenderPass (const vk::DeviceInterface& vk,
- const vk::VkCommandBuffer commandBuffer);
-
-void requireFeatures (const vk::InstanceInterface& vki,
- const vk::VkPhysicalDevice physicalDevice,
- const FeatureFlags flags);
+bool isImageSizeSupported (const vk::InstanceInterface& instance,
+ const vk::VkPhysicalDevice physicalDevice,
+ const ImageType imageType,
+ const tcu::UVec3& imageSize);
+
+vk::VkExtent3D mipLevelExtents (const vk::VkExtent3D& baseExtents,
+ const deUint32 mipLevel);
+
+tcu::UVec3 mipLevelExtents (const tcu::UVec3& baseExtents,
+ const deUint32 mipLevel);
+
+deUint32 getImageMaxMipLevels (const vk::VkImageFormatProperties& imageFormatProperties,
+ const vk::VkExtent3D& extent);
+
+deUint32 getImageMipLevelSizeInBytes (const vk::VkExtent3D& baseExtents,
+ const deUint32 layersCount,
+ const tcu::TextureFormat& format,
+ const deUint32 mipmapLevel,
+ const deUint32 mipmapMemoryAlignment = 1u);
+
+deUint32 getImageSizeInBytes (const vk::VkExtent3D& baseExtents,
+ const deUint32 layersCount,
+ const tcu::TextureFormat& format,
+ const deUint32 mipmapLevelsCount = 1u,
+ const deUint32 mipmapMemoryAlignment = 1u);
+
+vk::Move<vk::VkCommandPool> makeCommandPool (const vk::DeviceInterface& vk,
+ const vk::VkDevice device,
+ const deUint32 queueFamilyIndex);
+
+vk::Move<vk::VkCommandBuffer> makeCommandBuffer (const vk::DeviceInterface& vk,
+ const vk::VkDevice device,
+ const vk::VkCommandPool commandPool);
+
+vk::Move<vk::VkPipelineLayout> makePipelineLayout (const vk::DeviceInterface& vk,
+ const vk::VkDevice device,
+ const vk::VkDescriptorSetLayout descriptorSetLayout);
+
+vk::Move<vk::VkPipeline> makeComputePipeline (const vk::DeviceInterface& vk,
+ const vk::VkDevice device,
+ const vk::VkPipelineLayout pipelineLayout,
+ const vk::VkShaderModule shaderModule,
+ const vk::VkSpecializationInfo* specializationInfo = 0);
+
+vk::Move<vk::VkBufferView> makeBufferView (const vk::DeviceInterface& vk,
+ const vk::VkDevice device,
+ const vk::VkBuffer buffer,
+ const vk::VkFormat format,
+ const vk::VkDeviceSize offset,
+ const vk::VkDeviceSize size);
+
+vk::Move<vk::VkImageView> makeImageView (const vk::DeviceInterface& vk,
+ const vk::VkDevice device,
+ const vk::VkImage image,
+ const vk::VkImageViewType imageViewType,
+ const vk::VkFormat format,
+ const vk::VkImageSubresourceRange subresourceRange);
+
+vk::Move<vk::VkDescriptorSet> makeDescriptorSet (const vk::DeviceInterface& vk,
+ const vk::VkDevice device,
+ const vk::VkDescriptorPool descriptorPool,
+ const vk::VkDescriptorSetLayout setLayout);
+
+vk::Move<vk::VkSemaphore> makeSemaphore (const vk::DeviceInterface& vk,
+ const vk::VkDevice device);
+
+vk::Move<vk::VkFence> makeFence (const vk::DeviceInterface& vk,
+ const vk::VkDevice device,
+ const vk::VkFenceCreateFlags flags = 0u);
+
+de::MovePtr<vk::Allocation> bindImage (const vk::DeviceInterface& vk,
+ const vk::VkDevice device,
+ vk::Allocator& allocator,
+ const vk::VkImage image,
+ const vk::MemoryRequirement requirement);
+
+de::MovePtr<vk::Allocation> bindBuffer (const vk::DeviceInterface& vk,
+ const vk::VkDevice device,
+ vk::Allocator& allocator,
+ const vk::VkBuffer buffer,
+ const vk::MemoryRequirement requirement);
+
+vk::VkBufferCreateInfo makeBufferCreateInfo (const vk::VkDeviceSize bufferSize,
+ const vk::VkBufferUsageFlags usage);
+
+vk::VkBufferImageCopy makeBufferImageCopy (const vk::VkExtent3D extent,
+ const deUint32 layersCount,
+ const deUint32 mipmapLevel = 0u,
+ const vk::VkDeviceSize bufferOffset = 0ull);
+
+vk::VkBufferMemoryBarrier makeBufferMemoryBarrier (const vk::VkAccessFlags srcAccessMask,
+ const vk::VkAccessFlags dstAccessMask,
+ const vk::VkBuffer buffer,
+ const vk::VkDeviceSize offset,
+ const vk::VkDeviceSize bufferSizeBytes);
+
+vk::VkImageMemoryBarrier makeImageMemoryBarrier (const vk::VkAccessFlags srcAccessMask,
+ const vk::VkAccessFlags dstAccessMask,
+ const vk::VkImageLayout oldLayout,
+ const vk::VkImageLayout newLayout,
+ const vk::VkImage image,
+ const vk::VkImageSubresourceRange subresourceRange);
+
+vk::VkImageMemoryBarrier makeImageMemoryBarrier (const vk::VkAccessFlags srcAccessMask,
+ const vk::VkAccessFlags dstAccessMask,
+ const vk::VkImageLayout oldLayout,
+ const vk::VkImageLayout newLayout,
+ const deUint32 srcQueueFamilyIndex,
+ const deUint32 destQueueFamilyIndex,
+ const vk::VkImage image,
+ const vk::VkImageSubresourceRange subresourceRange);
+
+vk::VkMemoryBarrier makeMemoryBarrier (const vk::VkAccessFlags srcAccessMask,
+ const vk::VkAccessFlags dstAccessMask);
+
+vk::VkSparseImageMemoryBind makeSparseImageMemoryBind (const vk::DeviceInterface& vk,
+ const vk::VkDevice device,
+ const vk::VkDeviceSize allocationSize,
+ const deUint32 memoryType,
+ const vk::VkImageSubresource& subresource,
+ const vk::VkOffset3D& offset,
+ const vk::VkExtent3D& extent);
+
+vk::VkSparseMemoryBind makeSparseMemoryBind (const vk::DeviceInterface& vk,
+ const vk::VkDevice device,
+ const vk::VkDeviceSize allocationSize,
+ const deUint32 memoryType,
+ const vk::VkDeviceSize resourceOffset);
+
+void beginCommandBuffer (const vk::DeviceInterface& vk,
+ const vk::VkCommandBuffer cmdBuffer);
+
+void endCommandBuffer (const vk::DeviceInterface& vk,
+ const vk::VkCommandBuffer cmdBuffer);
+
+void submitCommands (const vk::DeviceInterface& vk,
+ const vk::VkQueue queue,
+ const vk::VkCommandBuffer cmdBuffer,
+ const deUint32 waitSemaphoreCount = 0,
+ const vk::VkSemaphore* pWaitSemaphores = DE_NULL,
+ const vk::VkPipelineStageFlags* pWaitDstStageMask = DE_NULL,
+ const deUint32 signalSemaphoreCount = 0,
+ const vk::VkSemaphore* pSignalSemaphores = DE_NULL);
+
+void submitCommandsAndWait (const vk::DeviceInterface& vk,
+ const vk::VkDevice device,
+ const vk::VkQueue queue,
+ const vk::VkCommandBuffer cmdBuffer,
+ const deUint32 waitSemaphoreCount = 0,
+ const vk::VkSemaphore* pWaitSemaphores = DE_NULL,
+ const vk::VkPipelineStageFlags* pWaitDstStageMask = DE_NULL,
+ const deUint32 signalSemaphoreCount = 0,
+ const vk::VkSemaphore* pSignalSemaphores = DE_NULL);
+
+void requireFeatures (const vk::InstanceInterface& vki,
+ const vk::VkPhysicalDevice physicalDevice,
+ const FeatureFlags flags);
+
+deUint32 findMatchingMemoryType (const vk::InstanceInterface& instance,
+ const vk::VkPhysicalDevice physicalDevice,
+ const vk::VkMemoryRequirements& objectMemoryRequirements,
+ const vk::MemoryRequirement& memoryRequirement);
+
+bool checkSparseSupportForImageType (const vk::InstanceInterface& instance,
+ const vk::VkPhysicalDevice physicalDevice,
+ const ImageType imageType);
+
+bool checkSparseSupportForImageFormat (const vk::InstanceInterface& instance,
+ const vk::VkPhysicalDevice physicalDevice,
+ const vk::VkImageCreateInfo& imageInfo);
+
+bool checkImageFormatFeatureSupport (const vk::InstanceInterface& instance,
+ const vk::VkPhysicalDevice physicalDevice,
+ const vk::VkFormat format,
+ const vk::VkFormatFeatureFlags featureFlags);
+
+deUint32 getSparseAspectRequirementsIndex (const std::vector<vk::VkSparseImageMemoryRequirements>& requirements,
+ const vk::VkImageAspectFlags aspectFlags);
template<typename T>
-inline de::SharedPtr<vk::Unique<T> > makeVkSharedPtr (vk::Move<T> vkMove)
+inline de::SharedPtr<vk::Unique<T> > makeVkSharedPtr (vk::Move<T> vkMove)
{
return de::SharedPtr<vk::Unique<T> >(new vk::Unique<T>(vkMove));
}
template<typename T>
-inline std::size_t sizeInBytes(const std::vector<T>& vec)
+inline std::size_t sizeInBytes (const std::vector<T>& vec)
{
return vec.size() * sizeof(vec[0]);
}
+template<typename T>
+inline const T* getDataOrNullptr (const std::vector<T>& vec, const std::size_t index = 0u)
+{
+ return (index < vec.size() ? &vec[index] : DE_NULL);
+}
+
} // sparse
} // vkt