X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=external%2Fvulkancts%2Fmodules%2Fvulkan%2Fapi%2FvktApiCopiesAndBlittingTests.cpp;h=c08e6bdabef38910f655f6649a09607f54e29c67;hb=cd69acfb3a5d9a4a32c4067ad869bc9eda1fca04;hp=e2c905c3bc0caffafaaa169723c3716aae87758d;hpb=b958b3fab2b2560cd3ee5072d1e2f4cc484f27fc;p=platform%2Fupstream%2FVK-GL-CTS.git diff --git a/external/vulkancts/modules/vulkan/api/vktApiCopiesAndBlittingTests.cpp b/external/vulkancts/modules/vulkan/api/vktApiCopiesAndBlittingTests.cpp index e2c905c..c08e6bd 100644 --- a/external/vulkancts/modules/vulkan/api/vktApiCopiesAndBlittingTests.cpp +++ b/external/vulkancts/modules/vulkan/api/vktApiCopiesAndBlittingTests.cpp @@ -45,6 +45,8 @@ #include "vktTestGroupUtil.hpp" #include "vkTypeUtil.hpp" +#include + namespace vkt { @@ -63,12 +65,28 @@ enum MirrorMode MIRROR_MODE_LAST }; -} - -using namespace vk; +enum AllocationKind +{ + ALLOCATION_KIND_SUBALLOCATED, + ALLOCATION_KIND_DEDICATED, +}; -namespace +template +class BinaryCompare { +public: + bool operator() (const Type& a, const Type& b) const + { + return deMemCmp(&a, &b, sizeof(Type)) < 0; + } +}; + +typedef std::set > FormatSet; + +FormatSet dedicatedAllocationImageToImageFormatsToTestSet; +FormatSet dedicatedAllocationBlittingFormatsToTestSet; + +using namespace vk; VkImageAspectFlags getAspectFlags (tcu::TextureFormat format) { @@ -128,8 +146,71 @@ struct TestParams VkFilter filter; VkSampleCountFlagBits samples; }; + + AllocationKind allocationKind; }; +de::MovePtr allocateBuffer (const InstanceInterface& vki, + const DeviceInterface& vkd, + const VkPhysicalDevice& physDevice, + const VkDevice device, + const VkBuffer& buffer, + const MemoryRequirement requirement, + Allocator& allocator, + AllocationKind allocationKind) +{ + switch (allocationKind) + { + case ALLOCATION_KIND_SUBALLOCATED: + { + const VkMemoryRequirements memoryRequirements = getBufferMemoryRequirements(vkd, device, buffer); + + return allocator.allocate(memoryRequirements, requirement); + } + + case ALLOCATION_KIND_DEDICATED: + { + return allocateDedicated(vki, vkd, physDevice, device, buffer, requirement); + } + + default: + { + TCU_THROW(InternalError, "Invalid allocation kind"); + } + } +} + +de::MovePtr allocateImage (const InstanceInterface& vki, + const DeviceInterface& vkd, + const VkPhysicalDevice& physDevice, + const VkDevice device, + const VkImage& image, + const MemoryRequirement requirement, + Allocator& allocator, + AllocationKind allocationKind) +{ + switch (allocationKind) + { + case ALLOCATION_KIND_SUBALLOCATED: + { + const VkMemoryRequirements memoryRequirements = getImageMemoryRequirements(vkd, device, image); + + return allocator.allocate(memoryRequirements, requirement); + } + + case ALLOCATION_KIND_DEDICATED: + { + return allocateDedicated(vki, vkd, physDevice, device, image, requirement); + } + + default: + { + TCU_THROW(InternalError, "Invalid allocation kind"); + } + } +} + + inline deUint32 getArraySize(const ImageParms& parms) { return (parms.imageType == VK_IMAGE_TYPE_2D) ? parms.extent.depth : 1u; @@ -231,6 +312,14 @@ CopiesAndBlittingTestInstance::CopiesAndBlittingTestInstance (Context& context, const VkDevice vkDevice = context.getDevice(); const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex(); + if (m_params.allocationKind == ALLOCATION_KIND_DEDICATED) + { + const std::string extensionName("VK_KHR_dedicated_allocation"); + + if (!de::contains(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), extensionName)) + TCU_THROW(NotSupportedError, std::string(extensionName + " is not supported").c_str()); + } + // Create command pool m_cmdPool = createCommandPool(vk, vkDevice, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, queueFamilyIndex); @@ -331,7 +420,9 @@ void CopiesAndBlittingTestInstance::uploadBuffer (tcu::ConstPixelBufferAccess bu void CopiesAndBlittingTestInstance::uploadImageAspect (const tcu::ConstPixelBufferAccess& imageAccess, const VkImage& image, const ImageParms& parms) { + const InstanceInterface& vki = m_context.getInstanceInterface(); const DeviceInterface& vk = m_context.getDeviceInterface(); + const VkPhysicalDevice vkPhysDevice = m_context.getPhysicalDevice(); const VkDevice vkDevice = m_context.getDevice(); const VkQueue queue = m_context.getUniversalQueue(); const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex(); @@ -357,7 +448,7 @@ void CopiesAndBlittingTestInstance::uploadImageAspect (const tcu::ConstPixelBuff }; buffer = createBuffer(vk, vkDevice, &bufferParams); - bufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *buffer), MemoryRequirement::HostVisible); + bufferAlloc = allocateBuffer(vki, vk, vkPhysDevice, vkDevice, *buffer, MemoryRequirement::HostVisible, memAlloc, m_params.allocationKind); VK_CHECK(vk.bindBufferMemory(vkDevice, *buffer, bufferAlloc->getMemory(), bufferAlloc->getOffset())); } @@ -526,7 +617,9 @@ void CopiesAndBlittingTestInstance::readImageAspect (vk::VkImage image, const tcu::PixelBufferAccess& dst, const ImageParms& imageParms) { + const InstanceInterface& vki = m_context.getInstanceInterface(); const DeviceInterface& vk = m_context.getDeviceInterface(); + const VkPhysicalDevice physDevice = m_context.getPhysicalDevice(); const VkDevice device = m_context.getDevice(); const VkQueue queue = m_context.getUniversalQueue(); Allocator& allocator = m_context.getDefaultAllocator(); @@ -552,7 +645,7 @@ void CopiesAndBlittingTestInstance::readImageAspect (vk::VkImage image, }; buffer = createBuffer(vk, device, &bufferParams); - bufferAlloc = allocator.allocate(getBufferMemoryRequirements(vk, device, *buffer), MemoryRequirement::HostVisible); + bufferAlloc = allocateBuffer(vki, vk, physDevice, device, *buffer, MemoryRequirement::HostVisible, allocator, m_params.allocationKind); VK_CHECK(vk.bindBufferMemory(device, *buffer, bufferAlloc->getMemory(), bufferAlloc->getOffset())); deMemset(bufferAlloc->getHostPtr(), 0, static_cast(pixelDataSize)); @@ -724,7 +817,9 @@ private: CopyImageToImage::CopyImageToImage (Context& context, TestParams params) : CopiesAndBlittingTestInstance(context, params) { + const InstanceInterface& vki = context.getInstanceInterface(); const DeviceInterface& vk = context.getDeviceInterface(); + const VkPhysicalDevice vkPhysDevice = context.getPhysicalDevice(); const VkDevice vkDevice = context.getDevice(); const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex(); Allocator& memAlloc = context.getDefaultAllocator(); @@ -778,7 +873,7 @@ CopyImageToImage::CopyImageToImage (Context& context, TestParams params) }; m_source = createImage(vk, vkDevice, &sourceImageParams); - m_sourceImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::Any); + m_sourceImageAlloc = allocateImage(vki, vk, vkPhysDevice, vkDevice, *m_source, MemoryRequirement::Any, memAlloc, m_params.allocationKind); VK_CHECK(vk.bindImageMemory(vkDevice, *m_source, m_sourceImageAlloc->getMemory(), m_sourceImageAlloc->getOffset())); } @@ -805,7 +900,7 @@ CopyImageToImage::CopyImageToImage (Context& context, TestParams params) }; m_destination = createImage(vk, vkDevice, &destinationImageParams); - m_destinationImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::Any); + m_destinationImageAlloc = allocateImage(vki, vk, vkPhysDevice, vkDevice, *m_destination, MemoryRequirement::Any, memAlloc, m_params.allocationKind); VK_CHECK(vk.bindImageMemory(vkDevice, *m_destination, m_destinationImageAlloc->getMemory(), m_destinationImageAlloc->getOffset())); } } @@ -949,6 +1044,31 @@ tcu::TestStatus CopyImageToImage::checkTestResult (tcu::ConstPixelBufferAccess r if (!tcu::floatThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparison", m_expectedTextureLevel->getAccess(), result, fThreshold, tcu::COMPARE_LOG_RESULT)) return tcu::TestStatus::fail("CopiesAndBlitting test"); } + else if (isSnormFormat(mapTextureFormat(result.getFormat()))) + { + // There may be an ambiguity between two possible binary representations of 1.0. + // Get rid of that by expanding the data to floats and re-normalizing again. + + tcu::TextureLevel resultSnorm (result.getFormat(), result.getWidth(), result.getHeight(), result.getDepth()); + { + tcu::TextureLevel resultFloat (tcu::TextureFormat(resultSnorm.getFormat().order, tcu::TextureFormat::FLOAT), resultSnorm.getWidth(), resultSnorm.getHeight(), resultSnorm.getDepth()); + + tcu::copy(resultFloat.getAccess(), result); + tcu::copy(resultSnorm, resultFloat.getAccess()); + } + + tcu::TextureLevel expectedSnorm (m_expectedTextureLevel->getFormat(), m_expectedTextureLevel->getWidth(), m_expectedTextureLevel->getHeight(), m_expectedTextureLevel->getDepth()); + + { + tcu::TextureLevel expectedFloat (tcu::TextureFormat(expectedSnorm.getFormat().order, tcu::TextureFormat::FLOAT), expectedSnorm.getWidth(), expectedSnorm.getHeight(), expectedSnorm.getDepth()); + + tcu::copy(expectedFloat.getAccess(), m_expectedTextureLevel->getAccess()); + tcu::copy(expectedSnorm, expectedFloat.getAccess()); + } + + if (!tcu::intThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparison", expectedSnorm.getAccess(), resultSnorm.getAccess(), uThreshold, tcu::COMPARE_LOG_RESULT)) + return tcu::TestStatus::fail("CopiesAndBlitting test"); + } else { if (!tcu::intThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparison", m_expectedTextureLevel->getAccess(), result, uThreshold, tcu::COMPARE_LOG_RESULT)) @@ -1042,7 +1162,9 @@ private: CopyBufferToBuffer::CopyBufferToBuffer (Context& context, TestParams params) : CopiesAndBlittingTestInstance (context, params) { + const InstanceInterface& vki = context.getInstanceInterface(); const DeviceInterface& vk = context.getDeviceInterface(); + const VkPhysicalDevice vkPhysDevice = context.getPhysicalDevice(); const VkDevice vkDevice = context.getDevice(); const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex(); Allocator& memAlloc = context.getDefaultAllocator(); @@ -1062,7 +1184,7 @@ CopyBufferToBuffer::CopyBufferToBuffer (Context& context, TestParams params) }; m_source = createBuffer(vk, vkDevice, &sourceBufferParams); - m_sourceBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::HostVisible); + m_sourceBufferAlloc = allocateBuffer(vki, vk, vkPhysDevice, vkDevice, *m_source, MemoryRequirement::HostVisible, memAlloc, m_params.allocationKind); VK_CHECK(vk.bindBufferMemory(vkDevice, *m_source, m_sourceBufferAlloc->getMemory(), m_sourceBufferAlloc->getOffset())); } @@ -1081,7 +1203,7 @@ CopyBufferToBuffer::CopyBufferToBuffer (Context& context, TestParams params) }; m_destination = createBuffer(vk, vkDevice, &destinationBufferParams); - m_destinationBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::HostVisible); + m_destinationBufferAlloc = allocateBuffer(vki, vk, vkPhysDevice, vkDevice, *m_destination, MemoryRequirement::HostVisible, memAlloc, m_params.allocationKind); VK_CHECK(vk.bindBufferMemory(vkDevice, *m_destination, m_destinationBufferAlloc->getMemory(), m_destinationBufferAlloc->getOffset())); } } @@ -1211,7 +1333,9 @@ CopyImageToBuffer::CopyImageToBuffer (Context& context, TestParams testParams) , m_textureFormat(mapVkFormat(testParams.src.image.format)) , m_bufferSize(m_params.dst.buffer.size * tcu::getPixelSize(m_textureFormat)) { + const InstanceInterface& vki = context.getInstanceInterface(); const DeviceInterface& vk = context.getDeviceInterface(); + const VkPhysicalDevice vkPhysDevice = context.getPhysicalDevice(); const VkDevice vkDevice = context.getDevice(); const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex(); Allocator& memAlloc = context.getDefaultAllocator(); @@ -1239,7 +1363,7 @@ CopyImageToBuffer::CopyImageToBuffer (Context& context, TestParams testParams) }; m_source = createImage(vk, vkDevice, &sourceImageParams); - m_sourceImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::Any); + m_sourceImageAlloc = allocateImage(vki, vk, vkPhysDevice, vkDevice, *m_source, MemoryRequirement::Any, memAlloc, m_params.allocationKind); VK_CHECK(vk.bindImageMemory(vkDevice, *m_source, m_sourceImageAlloc->getMemory(), m_sourceImageAlloc->getOffset())); } @@ -1258,7 +1382,7 @@ CopyImageToBuffer::CopyImageToBuffer (Context& context, TestParams testParams) }; m_destination = createBuffer(vk, vkDevice, &destinationBufferParams); - m_destinationBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::HostVisible); + m_destinationBufferAlloc = allocateBuffer(vki, vk, vkPhysDevice, vkDevice, *m_destination, MemoryRequirement::HostVisible, memAlloc, m_params.allocationKind); VK_CHECK(vk.bindBufferMemory(vkDevice, *m_destination, m_destinationBufferAlloc->getMemory(), m_destinationBufferAlloc->getOffset())); } } @@ -1417,7 +1541,9 @@ CopyBufferToImage::CopyBufferToImage (Context& context, TestParams testParams) , m_textureFormat(mapVkFormat(testParams.dst.image.format)) , m_bufferSize(m_params.src.buffer.size * tcu::getPixelSize(m_textureFormat)) { + const InstanceInterface& vki = context.getInstanceInterface(); const DeviceInterface& vk = context.getDeviceInterface(); + const VkPhysicalDevice vkPhysDevice = context.getPhysicalDevice(); const VkDevice vkDevice = context.getDevice(); const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex(); Allocator& memAlloc = context.getDefaultAllocator(); @@ -1437,7 +1563,7 @@ CopyBufferToImage::CopyBufferToImage (Context& context, TestParams testParams) }; m_source = createBuffer(vk, vkDevice, &sourceBufferParams); - m_sourceBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::HostVisible); + m_sourceBufferAlloc = allocateBuffer(vki, vk, vkPhysDevice, vkDevice, *m_source, MemoryRequirement::HostVisible, memAlloc, m_params.allocationKind); VK_CHECK(vk.bindBufferMemory(vkDevice, *m_source, m_sourceBufferAlloc->getMemory(), m_sourceBufferAlloc->getOffset())); } @@ -1464,7 +1590,7 @@ CopyBufferToImage::CopyBufferToImage (Context& context, TestParams testParams) }; m_destination = createImage(vk, vkDevice, &destinationImageParams); - m_destinationImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::Any); + m_destinationImageAlloc = allocateImage(vki, vk, vkPhysDevice, vkDevice, *m_destination, MemoryRequirement::Any, memAlloc, m_params.allocationKind); VK_CHECK(vk.bindImageMemory(vkDevice, *m_destination, m_destinationImageAlloc->getMemory(), m_destinationImageAlloc->getOffset())); } } @@ -1614,7 +1740,9 @@ private: BlittingImages::BlittingImages (Context& context, TestParams params) : CopiesAndBlittingTestInstance(context, params) { + const InstanceInterface& vki = context.getInstanceInterface(); const DeviceInterface& vk = context.getDeviceInterface(); + const VkPhysicalDevice vkPhysDevice = context.getPhysicalDevice(); const VkDevice vkDevice = context.getDevice(); const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex(); Allocator& memAlloc = context.getDefaultAllocator(); @@ -1683,7 +1811,7 @@ BlittingImages::BlittingImages (Context& context, TestParams params) }; m_source = createImage(vk, vkDevice, &sourceImageParams); - m_sourceImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::Any); + m_sourceImageAlloc = allocateImage(vki, vk, vkPhysDevice, vkDevice, *m_source, MemoryRequirement::Any, memAlloc, m_params.allocationKind); VK_CHECK(vk.bindImageMemory(vkDevice, *m_source, m_sourceImageAlloc->getMemory(), m_sourceImageAlloc->getOffset())); } @@ -1710,7 +1838,7 @@ BlittingImages::BlittingImages (Context& context, TestParams params) }; m_destination = createImage(vk, vkDevice, &destinationImageParams); - m_destinationImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::Any); + m_destinationImageAlloc = allocateImage(vki, vk, vkPhysDevice, vkDevice, *m_destination, MemoryRequirement::Any, memAlloc, m_params.allocationKind); VK_CHECK(vk.bindImageMemory(vkDevice, *m_destination, m_destinationImageAlloc->getMemory(), m_destinationImageAlloc->getOffset())); } } @@ -1793,8 +1921,8 @@ tcu::TestStatus BlittingImages::iterate (void) VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo)); vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 0, (const VkBufferMemoryBarrier*)DE_NULL, 1, &srcImageBarrier); + vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 0, (const VkBufferMemoryBarrier*)DE_NULL, 1, &dstImageBarrier); vk.cmdBlitImage(*m_cmdBuffer, m_source.get(), m_params.src.image.operationLayout, m_destination.get(), m_params.dst.image.operationLayout, (deUint32)m_params.regions.size(), ®ions[0], m_params.filter); - vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 0, (const VkBufferMemoryBarrier*)DE_NULL, 1, &dstImageBarrier); VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer)); submitCommandsAndWait(vk, vkDevice, queue, *m_cmdBuffer); @@ -2491,7 +2619,9 @@ ResolveImageToImage::ResolveImageToImage (Context& context, TestParams params, c if (!(context.getDeviceProperties().limits.framebufferColorSampleCounts & rasterizationSamples)) throw tcu::NotSupportedError("Unsupported number of rasterization samples"); + const InstanceInterface& vki = context.getInstanceInterface(); const DeviceInterface& vk = context.getDeviceInterface(); + const VkPhysicalDevice vkPhysDevice = context.getPhysicalDevice(); const VkDevice vkDevice = context.getDevice(); const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex(); Allocator& memAlloc = m_context.getDefaultAllocator(); @@ -2550,7 +2680,7 @@ ResolveImageToImage::ResolveImageToImage (Context& context, TestParams params, c m_multisampledImage = createImage(vk, vkDevice, &colorImageParams); // Allocate and bind color image memory. - m_multisampledImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_multisampledImage), MemoryRequirement::Any); + m_multisampledImageAlloc = allocateImage(vki, vk, vkPhysDevice, vkDevice, *m_multisampledImage, MemoryRequirement::Any, memAlloc, m_params.allocationKind); VK_CHECK(vk.bindImageMemory(vkDevice, *m_multisampledImage, m_multisampledImageAlloc->getMemory(), m_multisampledImageAlloc->getOffset())); switch (m_options) @@ -2560,7 +2690,7 @@ ResolveImageToImage::ResolveImageToImage (Context& context, TestParams params, c colorImageParams.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; m_multisampledCopyImage = createImage(vk, vkDevice, &colorImageParams); // Allocate and bind color image memory. - m_multisampledCopyImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_multisampledCopyImage), MemoryRequirement::Any); + m_multisampledCopyImageAlloc = allocateImage(vki, vk, vkPhysDevice, vkDevice, *m_multisampledCopyImage, MemoryRequirement::Any, memAlloc, m_params.allocationKind); VK_CHECK(vk.bindImageMemory(vkDevice, *m_multisampledCopyImage, m_multisampledCopyImageAlloc->getMemory(), m_multisampledCopyImageAlloc->getOffset())); break; } @@ -2571,7 +2701,7 @@ ResolveImageToImage::ResolveImageToImage (Context& context, TestParams params, c colorImageParams.arrayLayers = getArraySize(m_params.dst.image); m_multisampledCopyImage = createImage(vk, vkDevice, &colorImageParams); // Allocate and bind color image memory. - m_multisampledCopyImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_multisampledCopyImage), MemoryRequirement::Any); + m_multisampledCopyImageAlloc = allocateImage(vki, vk, vkPhysDevice, vkDevice, *m_multisampledCopyImage, MemoryRequirement::Any, memAlloc, m_params.allocationKind); VK_CHECK(vk.bindImageMemory(vkDevice, *m_multisampledCopyImage, m_multisampledCopyImageAlloc->getMemory(), m_multisampledCopyImageAlloc->getOffset())); break; } @@ -2604,7 +2734,7 @@ ResolveImageToImage::ResolveImageToImage (Context& context, TestParams params, c }; m_destination = createImage(vk, vkDevice, &destinationImageParams); - m_destinationImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::Any); + m_destinationImageAlloc = allocateImage(vki, vk, vkPhysDevice, vkDevice, *m_destination, MemoryRequirement::Any, memAlloc, m_params.allocationKind); VK_CHECK(vk.bindImageMemory(vkDevice, *m_destination, m_destinationImageAlloc->getMemory(), m_destinationImageAlloc->getOffset())); } @@ -2725,8 +2855,7 @@ ResolveImageToImage::ResolveImageToImage (Context& context, TestParams params, c }; vertexBuffer = createBuffer(vk, vkDevice, &vertexBufferParams); - vertexBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *vertexBuffer), MemoryRequirement::HostVisible); - + vertexBufferAlloc = allocateBuffer(vki, vk, vkPhysDevice, vkDevice, *vertexBuffer, MemoryRequirement::HostVisible, memAlloc, m_params.allocationKind); VK_CHECK(vk.bindBufferMemory(vkDevice, *vertexBuffer, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset())); // Load vertices into vertex buffer. @@ -3005,20 +3134,20 @@ tcu::TestStatus ResolveImageToImage::iterate (void) const tcu::TextureFormat dstTcuFormat = mapVkFormat(m_params.dst.image.format); // upload the destination image - m_destinationTextureLevel = de::MovePtr(new tcu::TextureLevel(dstTcuFormat, - (int)m_params.dst.image.extent.width, - (int)m_params.dst.image.extent.height, - (int)m_params.dst.image.extent.depth)); - generateBuffer(m_destinationTextureLevel->getAccess(), m_params.dst.image.extent.width, m_params.dst.image.extent.height, m_params.dst.image.extent.depth); - uploadImage(m_destinationTextureLevel->getAccess(), m_destination.get(), m_params.dst.image); + m_destinationTextureLevel = de::MovePtr(new tcu::TextureLevel(dstTcuFormat, + (int)m_params.dst.image.extent.width, + (int)m_params.dst.image.extent.height, + (int)m_params.dst.image.extent.depth)); + generateBuffer(m_destinationTextureLevel->getAccess(), m_params.dst.image.extent.width, m_params.dst.image.extent.height, m_params.dst.image.extent.depth); + uploadImage(m_destinationTextureLevel->getAccess(), m_destination.get(), m_params.dst.image); - m_sourceTextureLevel = de::MovePtr(new tcu::TextureLevel(srcTcuFormat, - (int)m_params.src.image.extent.width, - (int)m_params.src.image.extent.height, - (int)m_params.dst.image.extent.depth)); + m_sourceTextureLevel = de::MovePtr(new tcu::TextureLevel(srcTcuFormat, + (int)m_params.src.image.extent.width, + (int)m_params.src.image.extent.height, + (int)m_params.dst.image.extent.depth)); - generateBuffer(m_sourceTextureLevel->getAccess(), m_params.src.image.extent.width, m_params.src.image.extent.height, m_params.dst.image.extent.depth, FILL_MODE_MULTISAMPLE); - generateExpectedResult(); + generateBuffer(m_sourceTextureLevel->getAccess(), m_params.src.image.extent.width, m_params.src.image.extent.height, m_params.dst.image.extent.depth, FILL_MODE_MULTISAMPLE); + generateExpectedResult(); switch (m_options) { @@ -3191,7 +3320,7 @@ void ResolveImageToImage::copyMSImageToMSImage (void) const VkImageMemoryBarrier imageBarriers[] = { - //// source image + // source image { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType; DE_NULL, // const void* pNext; @@ -3353,7 +3482,7 @@ const VkImageSubresourceLayers defaultSourceLayer = 1u, // uint32_t layerCount; }; -void addImageToImageSimpleTests (tcu::TestCaseGroup* group) +void addImageToImageSimpleTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { tcu::TestContext& testCtx = group->getTestContext(); @@ -3367,6 +3496,7 @@ void addImageToImageSimpleTests (tcu::TestCaseGroup* group) params.dst.image.format = VK_FORMAT_R8G8B8A8_UINT; params.dst.image.extent = defaultExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; { const VkImageCopy testCopy = @@ -3397,6 +3527,7 @@ void addImageToImageSimpleTests (tcu::TestCaseGroup* group) params.dst.image.format = VK_FORMAT_R32_UINT; params.dst.image.extent = defaultExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; { const VkImageCopy testCopy = @@ -3427,6 +3558,7 @@ void addImageToImageSimpleTests (tcu::TestCaseGroup* group) params.dst.image.format = VK_FORMAT_R8G8B8A8_UINT; params.dst.image.extent = defaultExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; { const VkImageCopy testCopy = @@ -3457,6 +3589,7 @@ void addImageToImageSimpleTests (tcu::TestCaseGroup* group) params.dst.image.format = VK_FORMAT_D32_SFLOAT; params.dst.image.extent = defaultExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; { const VkImageSubresourceLayers sourceLayer = @@ -3494,6 +3627,7 @@ void addImageToImageSimpleTests (tcu::TestCaseGroup* group) params.dst.image.format = VK_FORMAT_S8_UINT; params.dst.image.extent = defaultExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; { const VkImageSubresourceLayers sourceLayer = @@ -3553,12 +3687,27 @@ void addImageToImageAllFormatsColorSrcFormatDstFormatTests (tcu::TestCaseGroup* getImageLayoutCaseName(params.dst.image.operationLayout); const std::string description = "From layout " + getImageLayoutCaseName(params.src.image.operationLayout) + " to " + getImageLayoutCaseName(params.dst.image.operationLayout); - group->addChild(new CopyImageToImageTestCase(group->getTestContext(), testName, description, params)); } } } +bool isAllowedImageToImageAllFormatsColorSrcFormatTests(CopyColorTestParams& testParams) +{ + bool result = true; + + if (testParams.params.allocationKind == ALLOCATION_KIND_DEDICATED) + { + DE_ASSERT(!dedicatedAllocationImageToImageFormatsToTestSet.empty()); + + result = + de::contains(dedicatedAllocationImageToImageFormatsToTestSet, testParams.params.dst.image.format) || + de::contains(dedicatedAllocationImageToImageFormatsToTestSet, testParams.params.src.image.format); + } + + return result; +} + void addImageToImageAllFormatsColorSrcFormatTests (tcu::TestCaseGroup* group, CopyColorTestParams testParams) { for (int dstFormatIndex = 0; testParams.compatibleFormats[dstFormatIndex] != VK_FORMAT_UNDEFINED; ++dstFormatIndex) @@ -3567,6 +3716,9 @@ void addImageToImageAllFormatsColorSrcFormatTests (tcu::TestCaseGroup* group, Co if (!isSupportedByFramework(testParams.params.dst.image.format)) continue; + if (!isAllowedImageToImageAllFormatsColorSrcFormatTests(testParams)) + continue; + const std::string description = "Copy to destination format " + getFormatCaseName(testParams.params.dst.image.format); addTestGroup(group, getFormatCaseName(testParams.params.dst.image.format), description, addImageToImageAllFormatsColorSrcFormatDstFormatTests, testParams.params); } @@ -3758,13 +3910,57 @@ const VkFormat* colorImageFormatsToTest[] = compatibleFormats256Bit, }; -void addImageToImageAllFormatsColorTests (tcu::TestCaseGroup* group) +const VkFormat dedicatedAllocationImageToImageFormatsToTest[] = +{ + // From compatibleFormats8Bit + VK_FORMAT_R4G4_UNORM_PACK8, + VK_FORMAT_R8_SRGB, + + // From compatibleFormats16Bit + VK_FORMAT_R4G4B4A4_UNORM_PACK16, + VK_FORMAT_R16_SFLOAT, + + // From compatibleFormats24Bit + VK_FORMAT_R8G8B8_UNORM, + VK_FORMAT_B8G8R8_SRGB, + + // From compatibleFormats32Bit + VK_FORMAT_R8G8B8A8_UNORM, + VK_FORMAT_R32_SFLOAT, + + // From compatibleFormats48Bit + VK_FORMAT_R16G16B16_UNORM, + VK_FORMAT_R16G16B16_SFLOAT, + + // From compatibleFormats64Bit + VK_FORMAT_R16G16B16A16_UNORM, + VK_FORMAT_R64_SFLOAT, + + // From compatibleFormats96Bit + VK_FORMAT_R32G32B32_UINT, + VK_FORMAT_R32G32B32_SFLOAT, + + // From compatibleFormats128Bit + VK_FORMAT_R32G32B32A32_UINT, + VK_FORMAT_R64G64_SFLOAT, + + // From compatibleFormats192Bit + VK_FORMAT_R64G64B64_UINT, + VK_FORMAT_R64G64B64_SFLOAT, + + // From compatibleFormats256Bit + VK_FORMAT_R64G64B64A64_UINT, + VK_FORMAT_R64G64B64A64_SFLOAT, +}; + +void addImageToImageAllFormatsColorTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { TestParams params; params.src.image.imageType = VK_IMAGE_TYPE_2D; params.src.image.extent = defaultExtent; params.dst.image.imageType = VK_IMAGE_TYPE_2D; params.dst.image.extent = defaultExtent; + params.allocationKind = allocationKind; for (deInt32 i = 0; i < defaultSize; i += defaultFourthSize) { @@ -3783,6 +3979,13 @@ void addImageToImageAllFormatsColorTests (tcu::TestCaseGroup* group) params.regions.push_back(imageCopy); } + if (allocationKind == ALLOCATION_KIND_DEDICATED) + { + const int numOfColorImageFormatsToTestFilter = DE_LENGTH_OF_ARRAY(colorImageFormatsToTest); + for (int compatibleFormatsIndex = 0; compatibleFormatsIndex < numOfColorImageFormatsToTestFilter; ++compatibleFormatsIndex) + dedicatedAllocationImageToImageFormatsToTestSet.insert(dedicatedAllocationImageToImageFormatsToTest[compatibleFormatsIndex]); + } + const int numOfColorImageFormatsToTest = DE_LENGTH_OF_ARRAY(colorImageFormatsToTest); for (int compatibleFormatsIndex = 0; compatibleFormatsIndex < numOfColorImageFormatsToTest; ++compatibleFormatsIndex) { @@ -3794,8 +3997,8 @@ void addImageToImageAllFormatsColorTests (tcu::TestCaseGroup* group) continue; CopyColorTestParams testParams; - testParams.params = params; - testParams.compatibleFormats = compatibleFormats; + testParams.params = params; + testParams.compatibleFormats = compatibleFormats; const std::string description = "Copy from source format " + getFormatCaseName(params.src.image.format); addTestGroup(group, getFormatCaseName(params.src.image.format), description, addImageToImageAllFormatsColorSrcFormatTests, testParams); @@ -3832,7 +4035,7 @@ void addImageToImageAllFormatsDepthStencilFormatsTests (tcu::TestCaseGroup* grou } } -void addImageToImageAllFormatsDepthStencilTests (tcu::TestCaseGroup* group) +void addImageToImageAllFormatsDepthStencilTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { const VkFormat depthAndStencilFormats[] = { @@ -3854,6 +4057,7 @@ void addImageToImageAllFormatsDepthStencilTests (tcu::TestCaseGroup* group) params.dst.image.extent = defaultExtent; params.src.image.format = depthAndStencilFormats[compatibleFormatsIndex]; params.dst.image.format = params.src.image.format; + params.allocationKind = allocationKind; const VkImageSubresourceLayers defaultDepthSourceLayer = { VK_IMAGE_ASPECT_DEPTH_BIT, 0u, 0u, 1u }; const VkImageSubresourceLayers defaultStencilSourceLayer = { VK_IMAGE_ASPECT_STENCIL_BIT, 0u, 0u, 1u }; @@ -3901,13 +4105,13 @@ void addImageToImageAllFormatsDepthStencilTests (tcu::TestCaseGroup* group) } } -void addImageToImageAllFormatsTests (tcu::TestCaseGroup* group) +void addImageToImageAllFormatsTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { - addTestGroup(group, "color", "Copy image to image with color formats", addImageToImageAllFormatsColorTests); - addTestGroup(group, "depth_stencil", "Copy image to image with depth/stencil formats", addImageToImageAllFormatsDepthStencilTests); + addTestGroup(group, "color", "Copy image to image with color formats", addImageToImageAllFormatsColorTests, allocationKind); + addTestGroup(group, "depth_stencil", "Copy image to image with depth/stencil formats", addImageToImageAllFormatsDepthStencilTests, allocationKind); } -void addImageToImage3dImagesTests (tcu::TestCaseGroup* group) +void addImageToImage3dImagesTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { tcu::TestContext& testCtx = group->getTestContext(); @@ -3924,6 +4128,7 @@ void addImageToImage3dImagesTests (tcu::TestCaseGroup* group) params3DTo2D.dst.image.extent = defaultHalfExtent; params3DTo2D.dst.image.extent.depth = slicesLayers; params3DTo2D.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params3DTo2D.allocationKind = allocationKind; for (deUint32 slicesLayersNdx = 0; slicesLayersNdx < slicesLayers; ++slicesLayersNdx) { @@ -3973,6 +4178,7 @@ void addImageToImage3dImagesTests (tcu::TestCaseGroup* group) params2DTo3D.dst.image.extent = defaultHalfExtent; params2DTo3D.dst.image.extent.depth = slicesLayers; params2DTo3D.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params2DTo3D.allocationKind = allocationKind; for (deUint32 slicesLayersNdx = 0; slicesLayersNdx < slicesLayers; ++slicesLayersNdx) { @@ -4023,6 +4229,7 @@ void addImageToImage3dImagesTests (tcu::TestCaseGroup* group) params3DTo2D.dst.image.extent = defaultHalfExtent; params3DTo2D.dst.image.extent.depth = slicesLayers; params3DTo2D.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params3DTo2D.allocationKind = allocationKind; { const VkImageSubresourceLayers sourceLayer = @@ -4071,6 +4278,7 @@ void addImageToImage3dImagesTests (tcu::TestCaseGroup* group) params2DTo3D.dst.image.extent = defaultHalfExtent; params2DTo3D.dst.image.extent.depth = slicesLayers; params2DTo3D.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params2DTo3D.allocationKind = allocationKind; { const VkImageSubresourceLayers sourceLayer = @@ -4120,6 +4328,7 @@ void addImageToImage3dImagesTests (tcu::TestCaseGroup* group) params3DTo2D.dst.image.extent = defaultHalfExtent; params3DTo2D.dst.image.extent.depth = slicesLayers; params3DTo2D.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params3DTo2D.allocationKind = allocationKind; const deUint32 regionWidth = defaultHalfExtent.width / slicesLayers -1; const deUint32 regionHeight = defaultHalfExtent.height / slicesLayers -1 ; @@ -4176,6 +4385,7 @@ void addImageToImage3dImagesTests (tcu::TestCaseGroup* group) params2DTo3D.dst.image.extent = defaultHalfExtent; params2DTo3D.dst.image.extent.depth = slicesLayers; params2DTo3D.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params2DTo3D.allocationKind = allocationKind; const deUint32 regionWidth = defaultHalfExtent.width / slicesLayers -1; const deUint32 regionHeight = defaultHalfExtent.height / slicesLayers -1 ; @@ -4221,14 +4431,14 @@ void addImageToImage3dImagesTests (tcu::TestCaseGroup* group) } } -void addImageToImageTests (tcu::TestCaseGroup* group) +void addImageToImageTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { - addTestGroup(group, "simple_tests", "Copy from image to image simple tests", addImageToImageSimpleTests); - addTestGroup(group, "all_formats", "Copy from image to image with all compatible formats", addImageToImageAllFormatsTests); - addTestGroup(group, "3d_images", "Coping operations on 3d images", addImageToImage3dImagesTests); + addTestGroup(group, "simple_tests", "Copy from image to image simple tests", addImageToImageSimpleTests, allocationKind); + addTestGroup(group, "all_formats", "Copy from image to image with all compatible formats", addImageToImageAllFormatsTests, allocationKind); + addTestGroup(group, "3d_images", "Coping operations on 3d images", addImageToImage3dImagesTests, allocationKind); } -void addImageToBufferTests (tcu::TestCaseGroup* group) +void addImageToBufferTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { tcu::TestContext& testCtx = group->getTestContext(); @@ -4239,6 +4449,7 @@ void addImageToBufferTests (tcu::TestCaseGroup* group) params.src.image.extent = defaultExtent; params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; params.dst.buffer.size = defaultSize * defaultSize; + params.allocationKind = allocationKind; const VkBufferImageCopy bufferImageCopy = { @@ -4264,6 +4475,7 @@ void addImageToBufferTests (tcu::TestCaseGroup* group) params.src.image.extent = defaultExtent; params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; params.dst.buffer.size = defaultSize * defaultSize; + params.allocationKind = allocationKind; const VkBufferImageCopy bufferImageCopy = { @@ -4289,6 +4501,7 @@ void addImageToBufferTests (tcu::TestCaseGroup* group) params.src.image.extent = defaultExtent; params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; params.dst.buffer.size = defaultSize * defaultSize; + params.allocationKind = allocationKind; const int pixelSize = tcu::getPixelSize(mapVkFormat(params.src.image.format)); const VkDeviceSize bufferSize = pixelSize * params.dst.buffer.size; @@ -4321,7 +4534,7 @@ void addImageToBufferTests (tcu::TestCaseGroup* group) } } -void addBufferToImageTests (tcu::TestCaseGroup* group) +void addBufferToImageTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { tcu::TestContext& testCtx = group->getTestContext(); @@ -4332,6 +4545,7 @@ void addBufferToImageTests (tcu::TestCaseGroup* group) params.dst.image.format = VK_FORMAT_R8G8B8A8_UINT; params.dst.image.extent = defaultExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; const VkBufferImageCopy bufferImageCopy = { @@ -4357,6 +4571,7 @@ void addBufferToImageTests (tcu::TestCaseGroup* group) params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM; params.dst.image.extent = defaultExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; CopyRegion region; deUint32 divisor = 1; @@ -4385,6 +4600,7 @@ void addBufferToImageTests (tcu::TestCaseGroup* group) params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM; params.dst.image.extent = defaultExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; const VkBufferImageCopy bufferImageCopy = { @@ -4404,7 +4620,7 @@ void addBufferToImageTests (tcu::TestCaseGroup* group) } } -void addBufferToBufferTests (tcu::TestCaseGroup* group) +void addBufferToBufferTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { tcu::TestContext& testCtx = group->getTestContext(); @@ -4412,6 +4628,7 @@ void addBufferToBufferTests (tcu::TestCaseGroup* group) TestParams params; params.src.buffer.size = defaultSize; params.dst.buffer.size = defaultSize; + params.allocationKind = allocationKind; const VkBufferCopy bufferCopy = { @@ -4431,6 +4648,7 @@ void addBufferToBufferTests (tcu::TestCaseGroup* group) TestParams params; params.src.buffer.size = defaultFourthSize; params.dst.buffer.size = defaultFourthSize; + params.allocationKind = allocationKind; const VkBufferCopy bufferCopy = { @@ -4451,6 +4669,7 @@ void addBufferToBufferTests (tcu::TestCaseGroup* group) TestParams params; params.src.buffer.size = size; params.dst.buffer.size = size * (size + 1); + params.allocationKind = allocationKind; // Copy region with size 1..size for (unsigned int i = 1; i <= size; i++) @@ -4471,7 +4690,7 @@ void addBufferToBufferTests (tcu::TestCaseGroup* group) } } -void addBlittingImageSimpleWholeTests (tcu::TestCaseGroup* group) +void addBlittingImageSimpleWholeTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { tcu::TestContext& testCtx = group->getTestContext(); TestParams params; @@ -4482,6 +4701,7 @@ void addBlittingImageSimpleWholeTests (tcu::TestCaseGroup* group) params.dst.image.imageType = VK_IMAGE_TYPE_2D; params.dst.image.extent = defaultExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; { const VkImageBlit imageBlit = @@ -4539,7 +4759,7 @@ void addBlittingImageSimpleWholeTests (tcu::TestCaseGroup* group) } } -void addBlittingImageSimpleMirrorXYTests (tcu::TestCaseGroup* group) +void addBlittingImageSimpleMirrorXYTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { tcu::TestContext& testCtx = group->getTestContext(); TestParams params; @@ -4550,6 +4770,7 @@ void addBlittingImageSimpleMirrorXYTests (tcu::TestCaseGroup* group) params.dst.image.imageType = VK_IMAGE_TYPE_2D; params.dst.image.extent = defaultExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; { const VkImageBlit imageBlit = @@ -4607,7 +4828,7 @@ void addBlittingImageSimpleMirrorXYTests (tcu::TestCaseGroup* group) } } -void addBlittingImageSimpleMirrorXTests (tcu::TestCaseGroup* group) +void addBlittingImageSimpleMirrorXTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { tcu::TestContext& testCtx = group->getTestContext(); TestParams params; @@ -4618,6 +4839,7 @@ void addBlittingImageSimpleMirrorXTests (tcu::TestCaseGroup* group) params.dst.image.imageType = VK_IMAGE_TYPE_2D; params.dst.image.extent = defaultExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; { const VkImageBlit imageBlit = @@ -4675,7 +4897,7 @@ void addBlittingImageSimpleMirrorXTests (tcu::TestCaseGroup* group) } } -void addBlittingImageSimpleMirrorYTests (tcu::TestCaseGroup* group) +void addBlittingImageSimpleMirrorYTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { tcu::TestContext& testCtx = group->getTestContext(); TestParams params; @@ -4686,6 +4908,7 @@ void addBlittingImageSimpleMirrorYTests (tcu::TestCaseGroup* group) params.dst.image.imageType = VK_IMAGE_TYPE_2D; params.dst.image.extent = defaultExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; { const VkImageBlit imageBlit = @@ -4743,7 +4966,7 @@ void addBlittingImageSimpleMirrorYTests (tcu::TestCaseGroup* group) } } -void addBlittingImageSimpleMirrorSubregionsTests (tcu::TestCaseGroup* group) +void addBlittingImageSimpleMirrorSubregionsTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { tcu::TestContext& testCtx = group->getTestContext(); TestParams params; @@ -4754,6 +4977,7 @@ void addBlittingImageSimpleMirrorSubregionsTests (tcu::TestCaseGroup* group) params.dst.image.imageType = VK_IMAGE_TYPE_2D; params.dst.image.extent = defaultExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; // No mirroring. { @@ -4878,7 +5102,7 @@ void addBlittingImageSimpleMirrorSubregionsTests (tcu::TestCaseGroup* group) } } -void addBlittingImageSimpleScalingWhole1Tests (tcu::TestCaseGroup* group) +void addBlittingImageSimpleScalingWhole1Tests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { tcu::TestContext& testCtx = group->getTestContext(); TestParams params; @@ -4889,6 +5113,7 @@ void addBlittingImageSimpleScalingWhole1Tests (tcu::TestCaseGroup* group) params.dst.image.imageType = VK_IMAGE_TYPE_2D; params.dst.image.extent = defaultHalfExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; { const VkImageBlit imageBlit = @@ -4946,7 +5171,7 @@ void addBlittingImageSimpleScalingWhole1Tests (tcu::TestCaseGroup* group) } } -void addBlittingImageSimpleScalingWhole2Tests (tcu::TestCaseGroup* group) +void addBlittingImageSimpleScalingWhole2Tests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { tcu::TestContext& testCtx = group->getTestContext(); TestParams params; @@ -4957,6 +5182,7 @@ void addBlittingImageSimpleScalingWhole2Tests (tcu::TestCaseGroup* group) params.dst.image.imageType = VK_IMAGE_TYPE_2D; params.dst.image.extent = defaultExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; { const VkImageBlit imageBlit = @@ -5014,7 +5240,7 @@ void addBlittingImageSimpleScalingWhole2Tests (tcu::TestCaseGroup* group) } } -void addBlittingImageSimpleScalingAndOffsetTests (tcu::TestCaseGroup* group) +void addBlittingImageSimpleScalingAndOffsetTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { tcu::TestContext& testCtx = group->getTestContext(); TestParams params; @@ -5025,6 +5251,7 @@ void addBlittingImageSimpleScalingAndOffsetTests (tcu::TestCaseGroup* group) params.dst.image.imageType = VK_IMAGE_TYPE_2D; params.dst.image.extent = defaultExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; { const VkImageBlit imageBlit = @@ -5082,7 +5309,7 @@ void addBlittingImageSimpleScalingAndOffsetTests (tcu::TestCaseGroup* group) } } -void addBlittingImageSimpleWithoutScalingPartialTests (tcu::TestCaseGroup* group) +void addBlittingImageSimpleWithoutScalingPartialTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { tcu::TestContext& testCtx = group->getTestContext(); TestParams params; @@ -5093,6 +5320,7 @@ void addBlittingImageSimpleWithoutScalingPartialTests (tcu::TestCaseGroup* group params.dst.image.imageType = VK_IMAGE_TYPE_2D; params.dst.image.extent = defaultExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; { CopyRegion region; @@ -5153,18 +5381,19 @@ void addBlittingImageSimpleWithoutScalingPartialTests (tcu::TestCaseGroup* group } } -void addBlittingImageSimpleTests (tcu::TestCaseGroup* group) -{ - addTestGroup(group, "whole", "Blit without scaling (whole)", addBlittingImageSimpleWholeTests); - addTestGroup(group, "mirror_xy", "Flipping x and y coordinates (whole)", addBlittingImageSimpleMirrorXYTests); - addTestGroup(group, "mirror_x", "Flipping x coordinates (whole)", addBlittingImageSimpleMirrorXTests); - addTestGroup(group, "mirror_y", "Flipping y coordinates (whole)", addBlittingImageSimpleMirrorYTests); - addTestGroup(group, "mirror_subregions", "Mirroring subregions in image (no flip, y flip, x flip, xy flip)", addBlittingImageSimpleMirrorSubregionsTests); - addTestGroup(group, "scaling_whole1", "Blit with scaling (whole, src extent bigger)", addBlittingImageSimpleScalingWhole1Tests); - addTestGroup(group, "scaling_whole2", "Blit with scaling (whole, dst extent bigger)", addBlittingImageSimpleScalingWhole2Tests); - addTestGroup(group, "scaling_and_offset", "Blit with scaling and offset (whole, dst extent bigger)", addBlittingImageSimpleScalingAndOffsetTests); - addTestGroup(group, "without_scaling_partial", "Blit without scaling (partial)", addBlittingImageSimpleWithoutScalingPartialTests); +void addBlittingImageSimpleTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) +{ + addTestGroup(group, "whole", "Blit without scaling (whole)", addBlittingImageSimpleWholeTests, allocationKind); + addTestGroup(group, "mirror_xy", "Flipping x and y coordinates (whole)", addBlittingImageSimpleMirrorXYTests, allocationKind); + addTestGroup(group, "mirror_x", "Flipping x coordinates (whole)", addBlittingImageSimpleMirrorXTests, allocationKind); + addTestGroup(group, "mirror_y", "Flipping y coordinates (whole)", addBlittingImageSimpleMirrorYTests, allocationKind); + addTestGroup(group, "mirror_subregions", "Mirroring subregions in image (no flip, y flip, x flip, xy flip)", addBlittingImageSimpleMirrorSubregionsTests, allocationKind); + addTestGroup(group, "scaling_whole1", "Blit with scaling (whole, src extent bigger)", addBlittingImageSimpleScalingWhole1Tests, allocationKind); + addTestGroup(group, "scaling_whole2", "Blit with scaling (whole, dst extent bigger)", addBlittingImageSimpleScalingWhole2Tests, allocationKind); + addTestGroup(group, "scaling_and_offset", "Blit with scaling and offset (whole, dst extent bigger)", addBlittingImageSimpleScalingAndOffsetTests, allocationKind); + addTestGroup(group, "without_scaling_partial", "Blit without scaling (partial)", addBlittingImageSimpleWithoutScalingPartialTests, allocationKind); } + struct BlitColorTestParams { TestParams params; @@ -5172,6 +5401,23 @@ struct BlitColorTestParams bool onlyNearest; }; +bool isAllowedBlittingAllFormatsColorSrcFormatTests(const BlitColorTestParams& testParams) +{ + bool result = true; + + if (testParams.params.allocationKind == ALLOCATION_KIND_DEDICATED) + { + DE_ASSERT(!dedicatedAllocationBlittingFormatsToTestSet.empty()); + + result = + de::contains(dedicatedAllocationBlittingFormatsToTestSet, testParams.params.dst.image.format) || + de::contains(dedicatedAllocationBlittingFormatsToTestSet, testParams.params.src.image.format); + } + + return result; +} + + void addBlittingImageAllFormatsColorSrcFormatDstFormatTests (tcu::TestCaseGroup* group, BlitColorTestParams testParams) { tcu::TestContext& testCtx = group->getTestContext(); @@ -5218,6 +5464,9 @@ void addBlittingImageAllFormatsColorSrcFormatTests (tcu::TestCaseGroup* group, B if (!isSupportedByFramework(testParams.params.dst.image.format)) continue; + if (!isAllowedBlittingAllFormatsColorSrcFormatTests(testParams)) + continue; + const std::string description = "Blit destination format " + getFormatCaseName(testParams.params.dst.image.format); addTestGroup(group, getFormatCaseName(testParams.params.dst.image.format), description, addBlittingImageAllFormatsColorSrcFormatDstFormatTests, testParams); } @@ -5421,7 +5670,26 @@ const VkFormat compatibleFormatsSrgb[] = VK_FORMAT_UNDEFINED }; -void addBlittingImageAllFormatsColorTests (tcu::TestCaseGroup* group) +const VkFormat dedicatedAllocationBlittingFormatsToTest[] = +{ + // compatibleFormatsUInts + VK_FORMAT_R8_UINT, + VK_FORMAT_R64G64B64A64_UINT, + + // compatibleFormatsSInts + VK_FORMAT_R8_SINT, + VK_FORMAT_R64G64B64A64_SINT, + + // compatibleFormatsFloats + VK_FORMAT_R4G4_UNORM_PACK8, + VK_FORMAT_E5B9G9R9_UFLOAT_PACK32, + + // compatibleFormatsSrgb + VK_FORMAT_R8_SRGB, + VK_FORMAT_A8B8G8R8_SRGB_PACK32, +}; + +void addBlittingImageAllFormatsColorTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { const struct { const VkFormat* compatibleFormats; @@ -5441,6 +5709,7 @@ void addBlittingImageAllFormatsColorTests (tcu::TestCaseGroup* group) params.src.image.extent = defaultExtent; params.dst.image.imageType = VK_IMAGE_TYPE_2D; params.dst.image.extent = defaultExtent; + params.allocationKind = allocationKind; CopyRegion region; for (int i = 0, j = 1; (i + defaultFourthSize / j < defaultSize) && (defaultFourthSize > j); i += defaultFourthSize / j++) @@ -5482,6 +5751,13 @@ void addBlittingImageAllFormatsColorTests (tcu::TestCaseGroup* group) params.regions.push_back(region); } + if (allocationKind == ALLOCATION_KIND_DEDICATED) + { + const int numOfColorImageFormatsToTestFilter = DE_LENGTH_OF_ARRAY(dedicatedAllocationBlittingFormatsToTest); + for (int compatibleFormatsIndex = 0; compatibleFormatsIndex < numOfColorImageFormatsToTestFilter; ++compatibleFormatsIndex) + dedicatedAllocationBlittingFormatsToTestSet.insert(dedicatedAllocationBlittingFormatsToTest[compatibleFormatsIndex]); + } + for (int compatibleFormatsIndex = 0; compatibleFormatsIndex < numOfColorImageFormatsToTest; ++compatibleFormatsIndex) { const VkFormat* compatibleFormats = colorImageFormatsToTestBlit[compatibleFormatsIndex].compatibleFormats; @@ -5535,7 +5811,7 @@ void addBlittingImageAllFormatsDepthStencilFormatsTests (tcu::TestCaseGroup* gro } } -void addBlittingImageAllFormatsDepthStencilTests (tcu::TestCaseGroup* group) +void addBlittingImageAllFormatsDepthStencilTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { const VkFormat depthAndStencilFormats[] = { @@ -5560,6 +5836,7 @@ void addBlittingImageAllFormatsDepthStencilTests (tcu::TestCaseGroup* group) params.dst.image.extent = defaultExtent; params.dst.image.imageType = VK_IMAGE_TYPE_2D; params.dst.image.format = params.src.image.format; + params.allocationKind = allocationKind; CopyRegion region; for (int i = 0, j = 1; (i + defaultFourthSize / j < defaultSize) && (defaultFourthSize > j); i += defaultFourthSize / j++) @@ -5635,16 +5912,16 @@ void addBlittingImageAllFormatsDepthStencilTests (tcu::TestCaseGroup* group) } } -void addBlittingImageAllFormatsTests (tcu::TestCaseGroup* group) +void addBlittingImageAllFormatsTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { - addTestGroup(group, "color", "Blitting image with color formats", addBlittingImageAllFormatsColorTests); - addTestGroup(group, "depth_stencil", "Blitting image with depth/stencil formats", addBlittingImageAllFormatsDepthStencilTests); + addTestGroup(group, "color", "Blitting image with color formats", addBlittingImageAllFormatsColorTests, allocationKind); + addTestGroup(group, "depth_stencil", "Blitting image with depth/stencil formats", addBlittingImageAllFormatsDepthStencilTests, allocationKind); } -void addBlittingImageTests (tcu::TestCaseGroup* group) +void addBlittingImageTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { - addTestGroup(group, "simple_tests", "Blitting image simple tests", addBlittingImageSimpleTests); - addTestGroup(group, "all_formats", "Blitting image with all compatible formats", addBlittingImageAllFormatsTests); + addTestGroup(group, "simple_tests", "Blitting image simple tests", addBlittingImageSimpleTests, allocationKind); + addTestGroup(group, "all_formats", "Blitting image with all compatible formats", addBlittingImageAllFormatsTests, allocationKind); } const VkSampleCountFlagBits samples[] = @@ -5658,7 +5935,7 @@ const VkSampleCountFlagBits samples[] = }; const VkExtent3D resolveExtent = {256u, 256u, 1}; -void addResolveImageWholeTests (tcu::TestCaseGroup* group) +void addResolveImageWholeTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { TestParams params; params.src.image.imageType = VK_IMAGE_TYPE_2D; @@ -5669,6 +5946,7 @@ void addResolveImageWholeTests (tcu::TestCaseGroup* group) params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM; params.dst.image.extent = resolveExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; { const VkImageSubresourceLayers sourceLayer = @@ -5700,7 +5978,7 @@ void addResolveImageWholeTests (tcu::TestCaseGroup* group) } } -void addResolveImagePartialTests (tcu::TestCaseGroup* group) +void addResolveImagePartialTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { TestParams params; params.src.image.imageType = VK_IMAGE_TYPE_2D; @@ -5711,6 +5989,7 @@ void addResolveImagePartialTests (tcu::TestCaseGroup* group) params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM; params.dst.image.extent = resolveExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; { const VkImageSubresourceLayers sourceLayer = @@ -5742,7 +6021,7 @@ void addResolveImagePartialTests (tcu::TestCaseGroup* group) } } -void addResolveImageWithRegionsTests (tcu::TestCaseGroup* group) +void addResolveImageWithRegionsTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { TestParams params; params.src.image.imageType = VK_IMAGE_TYPE_2D; @@ -5753,6 +6032,7 @@ void addResolveImageWithRegionsTests (tcu::TestCaseGroup* group) params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM; params.dst.image.extent = resolveExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; { const VkImageSubresourceLayers sourceLayer = @@ -5788,7 +6068,7 @@ void addResolveImageWithRegionsTests (tcu::TestCaseGroup* group) } } -void addResolveImageWholeCopyBeforeResolvingTests (tcu::TestCaseGroup* group) +void addResolveImageWholeCopyBeforeResolvingTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { TestParams params; params.src.image.imageType = VK_IMAGE_TYPE_2D; @@ -5799,6 +6079,7 @@ void addResolveImageWholeCopyBeforeResolvingTests (tcu::TestCaseGroup* group) params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM; params.dst.image.extent = defaultExtent; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; { const VkImageSubresourceLayers sourceLayer = @@ -5831,7 +6112,7 @@ void addResolveImageWholeCopyBeforeResolvingTests (tcu::TestCaseGroup* group) } } -void addResolveImageWholeArrayImageTests (tcu::TestCaseGroup* group) +void addResolveImageWholeArrayImageTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { TestParams params; params.src.image.imageType = VK_IMAGE_TYPE_2D; @@ -5843,6 +6124,7 @@ void addResolveImageWholeArrayImageTests (tcu::TestCaseGroup* group) params.dst.image.extent = defaultExtent; params.dst.image.extent.depth = 5u; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; for (deUint32 layerNdx=0; layerNdx < params.dst.image.extent.depth; ++layerNdx) { @@ -5876,7 +6158,7 @@ void addResolveImageWholeArrayImageTests (tcu::TestCaseGroup* group) } } -void addResolveImageDiffImageSizeTests (tcu::TestCaseGroup* group) +void addResolveImageDiffImageSizeTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) { tcu::TestContext& testCtx = group->getTestContext(); TestParams params; @@ -5886,6 +6168,7 @@ void addResolveImageDiffImageSizeTests (tcu::TestCaseGroup* group) params.dst.image.imageType = VK_IMAGE_TYPE_2D; params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM; params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + params.allocationKind = allocationKind; { const VkImageSubresourceLayers sourceLayer = @@ -5949,14 +6232,34 @@ void addResolveImageDiffImageSizeTests (tcu::TestCaseGroup* group) } } -void addResolveImageTests (tcu::TestCaseGroup* group) +void addResolveImageTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) +{ + addTestGroup(group, "whole", "Resolve from image to image (whole)", addResolveImageWholeTests, allocationKind); + addTestGroup(group, "partial", "Resolve from image to image (partial)", addResolveImagePartialTests, allocationKind); + addTestGroup(group, "with_regions", "Resolve from image to image (with regions)", addResolveImageWithRegionsTests, allocationKind); + addTestGroup(group, "whole_copy_before_resolving", "Resolve from image to image (whole copy before resolving)", addResolveImageWholeCopyBeforeResolvingTests, allocationKind); + addTestGroup(group, "whole_array_image", "Resolve from image to image (whole array image)", addResolveImageWholeArrayImageTests, allocationKind); + addTestGroup(group, "diff_image_size", "Resolve from image to image of different size", addResolveImageDiffImageSizeTests, allocationKind); +} + +void addCopiesAndBlittingTests (tcu::TestCaseGroup* group, AllocationKind allocationKind) +{ + addTestGroup(group, "image_to_image", "Copy from image to image", addImageToImageTests, allocationKind); + addTestGroup(group, "image_to_buffer", "Copy from image to buffer", addImageToBufferTests, allocationKind); + addTestGroup(group, "buffer_to_image", "Copy from buffer to image", addBufferToImageTests, allocationKind); + addTestGroup(group, "buffer_to_buffer", "Copy from buffer to buffer", addBufferToBufferTests, allocationKind); + addTestGroup(group, "blit_image", "Blitting image", addBlittingImageTests, allocationKind); + addTestGroup(group, "resolve_image", "Resolve image", addResolveImageTests, allocationKind); +} + +void addCoreCopiesAndBlittingTests (tcu::TestCaseGroup* group) +{ + addCopiesAndBlittingTests(group, ALLOCATION_KIND_SUBALLOCATED); +} + +void addDedicatedAllocationCopiesAndBlittingTests (tcu::TestCaseGroup* group) { - addTestGroup(group, "whole", "Resolve from image to image (whole)", addResolveImageWholeTests); - addTestGroup(group, "partial", "Resolve from image to image (partial)", addResolveImagePartialTests); - addTestGroup(group, "with_regions", "Resolve from image to image (with regions)", addResolveImageWithRegionsTests); - addTestGroup(group, "whole_copy_before_resolving", "Resolve from image to image (whole copy before resolving)", addResolveImageWholeCopyBeforeResolvingTests); - addTestGroup(group, "whole_array_image", "Resolve from image to image (whole array image)", addResolveImageWholeArrayImageTests); - addTestGroup(group, "diff_image_size", "Resolve from image to image of different size", addResolveImageDiffImageSizeTests); + addCopiesAndBlittingTests(group, ALLOCATION_KIND_DEDICATED); } } // anonymous @@ -5965,12 +6268,8 @@ tcu::TestCaseGroup* createCopiesAndBlittingTests (tcu::TestContext& testCtx) { de::MovePtr copiesAndBlittingTests(new tcu::TestCaseGroup(testCtx, "copy_and_blit", "Copies And Blitting Tests")); - addTestGroup(copiesAndBlittingTests.get(), "image_to_image", "Copy from image to image", addImageToImageTests); - addTestGroup(copiesAndBlittingTests.get(), "image_to_buffer", "Copy from image to buffer", addImageToBufferTests); - addTestGroup(copiesAndBlittingTests.get(), "buffer_to_image", "Copy from buffer to image", addBufferToImageTests); - addTestGroup(copiesAndBlittingTests.get(), "buffer_to_buffer", "Copy from buffer to buffer", addBufferToBufferTests); - addTestGroup(copiesAndBlittingTests.get(), "blit_image", "Blitting image", addBlittingImageTests); - addTestGroup(copiesAndBlittingTests.get(), "resolve_image", "Resolve image", addResolveImageTests); + copiesAndBlittingTests->addChild(createTestGroup(testCtx, "core", "Core Copies And Blitting Tests", addCoreCopiesAndBlittingTests)); + copiesAndBlittingTests->addChild(createTestGroup(testCtx, "dedicated_allocation", "Copies And Blitting Tests For Dedicated Memory Allocation", addDedicatedAllocationCopiesAndBlittingTests)); return copiesAndBlittingTests.release(); }