VK_KHR_dedicated_allocation: Extend pipeline.image
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / pipeline / vktPipelineImageUtil.cpp
index c273cb8..0bc6922 100644 (file)
@@ -238,40 +238,11 @@ de::MovePtr<tcu::TextureLevel> readColorAttachment (const vk::DeviceInterface&    v
        }
 
        // Create command pool and buffer
-       {
-               const VkCommandPoolCreateInfo cmdPoolParams =
-               {
-                       VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,             // VkStructureType              sType;
-                       DE_NULL,                                                                                // const void*                  pNext;
-                       VK_COMMAND_POOL_CREATE_TRANSIENT_BIT,                   // VkCmdPoolCreateFlags flags;
-                       queueFamilyIndex,                                                               // deUint32                             queueFamilyIndex;
-               };
-
-               cmdPool = createCommandPool(vk, device, &cmdPoolParams);
-
-               const VkCommandBufferAllocateInfo cmdBufferAllocateInfo =
-               {
-                       VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // VkStructureType                      sType;
-                       DE_NULL,                                                                                // const void*                          pNext;
-                       *cmdPool,                                                                               // VkCommandPool                        commandPool;
-                       VK_COMMAND_BUFFER_LEVEL_PRIMARY,                                // VkCommandBufferLevel         level;
-                       1u                                                                                              // deUint32                                     bufferCount;
-               };
-
-               cmdBuffer = allocateCommandBuffer(vk, device, &cmdBufferAllocateInfo);
-       }
+       cmdPool         = createCommandPool(vk, device, VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, queueFamilyIndex);
+       cmdBuffer       = allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
 
        // Create fence
-       {
-               const VkFenceCreateInfo fenceParams =
-               {
-                       VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,            // VkStructureType              sType;
-                       DE_NULL,                                                                        // const void*                  pNext;
-                       0u                                                                                      // VkFenceCreateFlags   flags;
-               };
-
-               fence = createFence(vk, device, &fenceParams);
-       }
+       fence = createFence(vk, device);
 
        // Barriers for copying image to buffer
 
@@ -351,7 +322,7 @@ de::MovePtr<tcu::TextureLevel> readColorAttachment (const vk::DeviceInterface&      v
        VK_CHECK(vk.waitForFences(device, 1, &fence.get(), 0, ~(0ull) /* infinity */));
 
        // Read buffer data
-       invalidateMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), pixelDataSize);
+       invalidateMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), VK_WHOLE_SIZE);
        tcu::copy(*resultLevel, tcu::ConstPixelBufferAccess(resultLevel->getFormat(), resultLevel->getSize(), bufferAlloc->getHostPtr()));
 
        return resultLevel;
@@ -400,14 +371,12 @@ void uploadTestTextureInternal (const DeviceInterface&                    vk,
        // Calculate buffer size
        bufferSize =  (srcTexture.isCompressed())? srcTexture.getCompressedSize(): srcTexture.getSize();
 
-       // Stencil texture should be provided if (and only if) the image has combined DS format
-       DE_ASSERT(tcu::isCombinedDepthStencilType(format.type) == (srcStencilTexture != DE_NULL));
+       // Stencil-only texture should be provided if (and only if) the image has a combined DS format
+       DE_ASSERT((tcu::hasDepthComponent(format.order) && tcu::hasStencilComponent(format.order)) == (srcStencilTexture != DE_NULL));
 
        if (srcStencilTexture != DE_NULL)
        {
-               const deInt32 stencilAlignment = deMin32(4, srcTexture.getTextureFormat().getPixelSize());
-
-               stencilOffset   = static_cast<deUint32>(deAlign32(static_cast<deInt32>(bufferSize), stencilAlignment));
+               stencilOffset   = static_cast<deUint32>(deAlign32(static_cast<deInt32>(bufferSize), 4));
                bufferSize              = stencilOffset + srcStencilTexture->getSize();
        }
 
@@ -431,40 +400,11 @@ void uploadTestTextureInternal (const DeviceInterface&                    vk,
        }
 
        // Create command pool and buffer
-       {
-               const VkCommandPoolCreateInfo cmdPoolParams =
-               {
-                       VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,             // VkStructureType                      sType;
-                       DE_NULL,                                                                                // const void*                          pNext;
-                       VK_COMMAND_POOL_CREATE_TRANSIENT_BIT,                   // VkCommandPoolCreateFlags     flags;
-                       queueFamilyIndex,                                                               // deUint32                                     queueFamilyIndex;
-               };
-
-               cmdPool = createCommandPool(vk, device, &cmdPoolParams);
-
-               const VkCommandBufferAllocateInfo cmdBufferAllocateInfo =
-               {
-                       VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // VkStructureType                      sType;
-                       DE_NULL,                                                                                // const void*                          pNext;
-                       *cmdPool,                                                                               // VkCommandPool                        commandPool;
-                       VK_COMMAND_BUFFER_LEVEL_PRIMARY,                                // VkCommandBufferLevel         level;
-                       1u,                                                                                             // deUint32                                     bufferCount;
-               };
-
-               cmdBuffer = allocateCommandBuffer(vk, device, &cmdBufferAllocateInfo);
-       }
+       cmdPool         = createCommandPool(vk, device, VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, queueFamilyIndex);
+       cmdBuffer       = allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
 
        // Create fence
-       {
-               const VkFenceCreateInfo fenceParams =
-               {
-                       VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,            // VkStructureType              sType;
-                       DE_NULL,                                                                        // const void*                  pNext;
-                       0u                                                                                      // VkFenceCreateFlags   flags;
-               };
-
-               fence = createFence(vk, device, &fenceParams);
-       }
+       fence = createFence(vk, device);
 
        // Barriers for copying buffer to image
        const VkBufferMemoryBarrier preBufferBarrier =
@@ -549,7 +489,7 @@ void uploadTestTextureInternal (const DeviceInterface&                      vk,
                }
        }
 
-       flushMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), bufferSize);
+       flushMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), VK_WHOLE_SIZE);
 
        // Copy buffer to image
        VK_CHECK(vk.beginCommandBuffer(*cmdBuffer, &cmdBufferBeginInfo));
@@ -604,16 +544,15 @@ void uploadTestTexture (const DeviceInterface&                    vk,
                                break;
                        default:
                                DE_ASSERT(0);
+                               break;
                        }
                        srcDepthTexture = srcTexture.copy(format);
                }
 
                if (tcu::hasStencilComponent(srcTexture.getTextureFormat().order))
-               {
                        srcStencilTexture = srcTexture.copy(tcu::getEffectiveDepthStencilTextureFormat(srcTexture.getTextureFormat(), tcu::Sampler::MODE_STENCIL));
-               }
 
-               uploadTestTextureInternal(vk, device, queue, queueFamilyIndex, allocator, srcTexture, srcDepthTexture.get(), srcTexture.getTextureFormat(), destImage);
+               uploadTestTextureInternal(vk, device, queue, queueFamilyIndex, allocator, *srcDepthTexture, srcStencilTexture.get(), srcTexture.getTextureFormat(), destImage);
        }
        else
                uploadTestTextureInternal(vk, device, queue, queueFamilyIndex, allocator, srcTexture, DE_NULL, srcTexture.getTextureFormat(), destImage);