X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=external%2Fvulkancts%2Fmodules%2Fvulkan%2Fimage%2FvktImageMismatchedFormatsTests.cpp;h=a99eb51d44e9439e2f29d5b662c47ba844e4c7fe;hb=88edcad8679adbd1ad7924be6e94cfcb5c8082fc;hp=ec29a43f2270c07fdac2a24913281a51e3b69bb8;hpb=2a6c2dd6497d39e8df5feb05c0083c13d809672b;p=platform%2Fupstream%2FVK-GL-CTS.git diff --git a/external/vulkancts/modules/vulkan/image/vktImageMismatchedFormatsTests.cpp b/external/vulkancts/modules/vulkan/image/vktImageMismatchedFormatsTests.cpp index ec29a43..a99eb51 100644 --- a/external/vulkancts/modules/vulkan/image/vktImageMismatchedFormatsTests.cpp +++ b/external/vulkancts/modules/vulkan/image/vktImageMismatchedFormatsTests.cpp @@ -190,6 +190,31 @@ enum class TestType WRITE }; +void fillImageCreateInfo (VkImageCreateInfo& imageCreateInfo, TestType testType, VkFormat format) +{ + const VkImageCreateFlags imageFlags = ((testType == TestType::SPARSE_READ) ? (VK_IMAGE_CREATE_SPARSE_BINDING_BIT | VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) : 0u); + const VkImageCreateInfo createInfo = + { + VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + imageFlags, // VkImageCreateFlags flags; + VK_IMAGE_TYPE_2D, // VkImageType imageType; + format, // VkFormat format; + makeExtent3D(8, 8, 1), // VkExtent3D extent; + 1u, // deUint32 mipLevels; + 1u, // deUint32 arrayLayers; + VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; + VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling; + VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage; + VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode; + 0u, // deUint32 queueFamilyIndexCount; + nullptr, // const deUint32* pQueueFamilyIndices; + VK_IMAGE_LAYOUT_UNDEFINED // VkImageLayout initialLayout; + }; + + imageCreateInfo = createInfo; +} + class MismatchedFormatTest : public TestCase { public: @@ -225,17 +250,34 @@ MismatchedFormatTest::MismatchedFormatTest (tcu::TestContext& testCtx, void MismatchedFormatTest::checkSupport (Context& context) const { + const auto& vki = context.getInstanceInterface(); + const auto physicalDevice = context.getPhysicalDevice(); + +#ifndef CTS_USES_VULKANSC if (m_type == TestType::SPARSE_READ) { context.requireDeviceCoreFeature(DEVICE_CORE_FEATURE_SPARSE_BINDING); - if (!getPhysicalDeviceFeatures(context.getInstanceInterface(), context.getPhysicalDevice()).sparseResidencyBuffer) - { + if (!getPhysicalDeviceFeatures(vki, physicalDevice).sparseResidencyBuffer) TCU_THROW(NotSupportedError, "Sparse partially resident buffers not supported"); + + // Check sparse operations support before creating the image. + VkImageCreateInfo imageCreateInfo; + fillImageCreateInfo(imageCreateInfo, m_type, m_format); + + if (!checkSparseImageFormatSupport(physicalDevice, vki, imageCreateInfo)) + { + TCU_THROW(NotSupportedError, "The image format does not support sparse operations."); + } + + if (!getPhysicalDeviceFeatures(context.getInstanceInterface(), context.getPhysicalDevice()).shaderResourceResidency) + { + TCU_THROW(NotSupportedError, "Shader resource residency not supported"); } } +#endif // CTS_USES_VULKANSC - VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), m_format); + VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(vki, physicalDevice, m_format); if ((formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) == 0) { @@ -335,6 +377,11 @@ tcu::TestStatus MismatchedFormatTestInstance::iterate (void) const VkDevice device = m_context.getDevice(); const VkQueue queue = m_context.getUniversalQueue(); const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex(); + auto& allocator = m_context.getDefaultAllocator(); +#ifndef CTS_USES_VULKANSC + const auto physicalDevice = m_context.getPhysicalDevice(); + const auto& instance = m_context.getInstanceInterface(); +#endif // CTS_USES_VULKANSC Move shaderModule = createShaderModule(vk, device, m_context.getBinaryCollection().get("comp"), 0); @@ -350,28 +397,11 @@ tcu::TestStatus MismatchedFormatTestInstance::iterate (void) Move pipeline = makeComputePipeline(vk, device, *pipelineLayout, *shaderModule); - VkImageCreateFlags imageFlag = m_type == TestType::SPARSE_READ ? (VK_IMAGE_CREATE_SPARSE_BINDING_BIT | VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) : 0u; - - const VkImageCreateInfo imageCreateInfo = - { - VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType; - DE_NULL, // const void* pNext; - imageFlag, // VkImageCreateFlags flags; - VK_IMAGE_TYPE_2D, // VkImageType imageType; - m_format, // VkFormat format; - makeExtent3D(8, 8, 1), // VkExtent3D extent; - 1u, // deUint32 mipLevels; - 1u, // deUint32 arrayLayers; - VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; - VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling; - VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage; - VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode; - 0u, // deUint32 queueFamilyIndexCount; - DE_NULL, // const deUint32* pQueueFamilyIndices; - VK_IMAGE_LAYOUT_UNDEFINED // VkImageLayout initialLayout; - }; + VkImageCreateInfo imageCreateInfo; + fillImageCreateInfo(imageCreateInfo, m_type, m_format); vk::Move storageImage = createImage(vk, device, &imageCreateInfo); + const auto tcuFormat = mapVkFormat(m_format); de::MovePtr storageAllocation; vk::Move bindSemaphore; @@ -379,19 +409,21 @@ tcu::TestStatus MismatchedFormatTestInstance::iterate (void) if (m_type == TestType::SPARSE_READ) { - bindSemaphore = createSemaphore(m_context.getDeviceInterface(), m_context.getDevice()); - - allocateAndBindSparseImage( vk, device, m_context.getPhysicalDevice(), m_context.getInstanceInterface(), + bindSemaphore = createSemaphore(vk, device); +#ifndef CTS_USES_VULKANSC + allocateAndBindSparseImage( vk, device, physicalDevice, instance, imageCreateInfo, *bindSemaphore, m_context.getSparseQueue(), - m_context.getDefaultAllocator(), allocations, mapVkFormat(m_format), *storageImage ); + allocator, allocations, tcuFormat, *storageImage ); +#endif // CTS_USES_VULKANSC } else { - storageAllocation = m_context.getDefaultAllocator().allocate(getImageMemoryRequirements(vk, device, *storageImage), MemoryRequirement::Any); + storageAllocation = allocator.allocate(getImageMemoryRequirements(vk, device, *storageImage), MemoryRequirement::Any); VK_CHECK(vk.bindImageMemory(device, *storageImage, storageAllocation->getMemory(), storageAllocation->getOffset())); } - Move storageImageView = makeImageView(vk, device, *storageImage, VK_IMAGE_VIEW_TYPE_2D, m_format, makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u)); + const auto subresourceRange = makeImageSubresourceRange(getImageAspectFlags(tcuFormat), 0u, 1u, 0u, 1u); + Move storageImageView = makeImageView(vk, device, *storageImage, VK_IMAGE_VIEW_TYPE_2D, m_format, subresourceRange); VkDescriptorImageInfo storageImageInfo = makeDescriptorImageInfo(DE_NULL, *storageImageView, VK_IMAGE_LAYOUT_GENERAL); DescriptorSetUpdateBuilder builder; @@ -402,13 +434,17 @@ tcu::TestStatus MismatchedFormatTestInstance::iterate (void) Move cmdPool = createCommandPool(vk, device, VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, queueFamilyIndex); Move cmdBuffer = allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY); + const auto layoutBarrier = makeImageMemoryBarrier(0u, (VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT), VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL, *storageImage, subresourceRange); + beginCommandBuffer(vk, *cmdBuffer); + vk.cmdPipelineBarrier(*cmdBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0u, 0u, nullptr, 0u, nullptr, 1u, &layoutBarrier); vk.cmdBindPipeline(*cmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *pipeline); vk.cmdBindDescriptorSets(*cmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *pipelineLayout, 0u, 1u, &descriptorSet.get(), 0u, DE_NULL); vk.cmdDispatch(*cmdBuffer, 8, 8, 1); endCommandBuffer(vk, *cmdBuffer); - submitCommandsAndWait(vk, device, queue, *cmdBuffer); + const VkPipelineStageFlags stageBits[] = { VK_PIPELINE_STAGE_TRANSFER_BIT }; + submitCommandsAndWait(vk, device, queue, *cmdBuffer, false, 1u, 1u, &bindSemaphore.get(), stageBits); return tcu::TestStatus::pass("Passed"); } @@ -425,7 +461,9 @@ tcu::TestCaseGroup* createImageMismatchedFormatsTests (tcu::TestContext& testCtx de::MovePtr testGroup(new tcu::TestCaseGroup(testCtx, "mismatched_formats", "Test image load/store operations on mismatched formats")); de::MovePtr testGroupOpRead(new tcu::TestCaseGroup(testCtx, "image_read", "perform OpImageRead")); de::MovePtr testGroupOpWrite(new tcu::TestCaseGroup(testCtx, "image_write", "perform OpImageWrite")); +#ifndef CTS_USES_VULKANSC de::MovePtr testGroupOpSparseRead(new tcu::TestCaseGroup(testCtx, "sparse_image_read", "perform OpSparseImageRead")); +#endif // CTS_USES_VULKANSC for (VkFormat format = VK_FORMAT_R4G4_UNORM_PACK8; format < VK_CORE_FORMAT_LAST; format = static_cast(format+1)) { @@ -445,17 +483,20 @@ tcu::TestCaseGroup* createImageMismatchedFormatsTests (tcu::TestContext& testCtx testGroupOpWrite->addChild(new MismatchedFormatTest(testCtx, testName, "", TestType::WRITE, format, spirvFormat) ); - +#ifndef CTS_USES_VULKANSC testGroupOpSparseRead->addChild(new MismatchedFormatTest( testCtx, testName, "", TestType::SPARSE_READ, format, spirvFormat) ); +#endif // CTS_USES_VULKANSC } } } testGroup->addChild(testGroupOpRead.release()); testGroup->addChild(testGroupOpWrite.release()); +#ifndef CTS_USES_VULKANSC testGroup->addChild(testGroupOpSparseRead.release()); +#endif // CTS_USES_VULKANSC return testGroup.release(); }