1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2015-2016 The Khronos Group Inc.
6 * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 * \brief Vulkan Copies And Blitting Tests
23 *//*--------------------------------------------------------------------*/
25 #include "vktApiCopiesAndBlittingTests.hpp"
27 #include "deStringUtil.hpp"
28 #include "deUniquePtr.hpp"
31 #include "tcuImageCompare.hpp"
32 #include "tcuTexture.hpp"
33 #include "tcuTextureUtil.hpp"
34 #include "tcuVectorType.hpp"
35 #include "tcuVectorUtil.hpp"
37 #include "vkImageUtil.hpp"
38 #include "vkMemUtil.hpp"
39 #include "vkPrograms.hpp"
40 #include "vkQueryUtil.hpp"
41 #include "vkRefUtil.hpp"
42 #include "vktTestCase.hpp"
43 #include "vktTestCaseUtil.hpp"
44 #include "vkTypeUtil.hpp"
57 MIRROR_MODE_X = (1<<0),
58 MIRROR_MODE_Y = (1<<1),
59 MIRROR_MODE_XY = MIRROR_MODE_X | MIRROR_MODE_Y,
71 VkImageAspectFlags getAspectFlags (tcu::TextureFormat format)
73 VkImageAspectFlags aspectFlag = 0;
74 aspectFlag |= (tcu::hasDepthComponent(format.order)? VK_IMAGE_ASPECT_DEPTH_BIT : 0);
75 aspectFlag |= (tcu::hasStencilComponent(format.order)? VK_IMAGE_ASPECT_STENCIL_BIT : 0);
78 aspectFlag = VK_IMAGE_ASPECT_COLOR_BIT;
83 // This is effectively same as vk::isFloatFormat(mapTextureFormat(format))
84 // except that it supports some formats that are not mappable to VkFormat.
85 // When we are checking combined depth and stencil formats, each aspect is
86 // checked separately, and in some cases we construct PBA with a format that
87 // is not mappable to VkFormat.
88 bool isFloatFormat (tcu::TextureFormat format)
90 return tcu::getTextureChannelClass(format.type) == tcu::TEXTURECHANNELCLASS_FLOATING_POINT;
95 VkBufferCopy bufferCopy;
96 VkImageCopy imageCopy;
97 VkBufferImageCopy bufferImageCopy;
98 VkImageBlit imageBlit;
99 VkImageResolve imageResolve;
104 VkImageType imageType;
121 std::vector<CopyRegion> regions;
126 VkSampleCountFlagBits samples;
130 inline deUint32 getArraySize(const ImageParms& parms)
132 return (parms.imageType == VK_IMAGE_TYPE_2D) ? parms.extent.depth : 1u;
135 inline VkExtent3D getExtent3D(const ImageParms& parms)
137 const VkExtent3D extent =
141 (parms.imageType == VK_IMAGE_TYPE_2D) ? 1u : parms.extent.depth
146 const tcu::TextureFormat mapCombinedToDepthTransferFormat (const tcu::TextureFormat& combinedFormat)
148 tcu::TextureFormat format;
149 switch (combinedFormat.type)
151 case tcu::TextureFormat::UNSIGNED_INT_16_8_8:
152 format = tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::UNORM_INT16);
154 case tcu::TextureFormat::UNSIGNED_INT_24_8_REV:
155 format = tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::UNSIGNED_INT_24_8_REV);
157 case tcu::TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV:
158 format = tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::FLOAT);
167 class CopiesAndBlittingTestInstance : public vkt::TestInstance
170 CopiesAndBlittingTestInstance (Context& context,
171 TestParams testParams);
172 virtual tcu::TestStatus iterate (void) = 0;
176 FILL_MODE_GRADIENT = 0,
179 FILL_MODE_MULTISAMPLE,
185 const TestParams m_params;
187 Move<VkCommandPool> m_cmdPool;
188 Move<VkCommandBuffer> m_cmdBuffer;
189 Move<VkFence> m_fence;
190 de::MovePtr<tcu::TextureLevel> m_sourceTextureLevel;
191 de::MovePtr<tcu::TextureLevel> m_destinationTextureLevel;
192 de::MovePtr<tcu::TextureLevel> m_expectedTextureLevel;
194 VkCommandBufferBeginInfo m_cmdBufferBeginInfo;
196 void generateBuffer (tcu::PixelBufferAccess buffer, int width, int height, int depth = 1, FillMode = FILL_MODE_GRADIENT);
197 virtual void generateExpectedResult (void);
198 void uploadBuffer (tcu::ConstPixelBufferAccess bufferAccess, const Allocation& bufferAlloc);
199 void uploadImage (const tcu::ConstPixelBufferAccess& src, VkImage dst, const ImageParms& parms);
200 virtual tcu::TestStatus checkTestResult (tcu::ConstPixelBufferAccess result);
201 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region) = 0;
202 deUint32 calculateSize (tcu::ConstPixelBufferAccess src) const
204 return src.getWidth() * src.getHeight() * src.getDepth() * tcu::getPixelSize(src.getFormat());
207 de::MovePtr<tcu::TextureLevel> readImage (vk::VkImage image,
208 const ImageParms& imageParms);
209 void submitCommandsAndWait (const DeviceInterface& vk,
210 const VkDevice device,
212 const VkCommandBuffer& cmdBuffer);
215 void uploadImageAspect (const tcu::ConstPixelBufferAccess& src,
217 const ImageParms& parms);
218 void readImageAspect (vk::VkImage src,
219 const tcu::PixelBufferAccess& dst,
220 const ImageParms& parms);
223 CopiesAndBlittingTestInstance::CopiesAndBlittingTestInstance (Context& context, TestParams testParams)
224 : vkt::TestInstance (context)
225 , m_params (testParams)
227 const DeviceInterface& vk = context.getDeviceInterface();
228 const VkDevice vkDevice = context.getDevice();
229 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
231 // Create command pool
233 const VkCommandPoolCreateInfo cmdPoolParams =
235 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // VkStructureType sType;
236 DE_NULL, // const void* pNext;
237 VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,// VkCmdPoolCreateFlags flags;
238 queueFamilyIndex, // deUint32 queueFamilyIndex;
241 m_cmdPool = createCommandPool(vk, vkDevice, &cmdPoolParams);
244 // Create command buffer
246 const VkCommandBufferAllocateInfo cmdBufferAllocateInfo =
248 VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // VkStructureType sType;
249 DE_NULL, // const void* pNext;
250 *m_cmdPool, // VkCommandPool commandPool;
251 VK_COMMAND_BUFFER_LEVEL_PRIMARY, // VkCommandBufferLevel level;
252 1u // deUint32 bufferCount;
255 m_cmdBuffer = allocateCommandBuffer(vk, vkDevice, &cmdBufferAllocateInfo);
260 const VkFenceCreateInfo fenceParams =
262 VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, // VkStructureType sType;
263 DE_NULL, // const void* pNext;
264 0u // VkFenceCreateFlags flags;
267 m_fence = createFence(vk, vkDevice, &fenceParams);
271 void CopiesAndBlittingTestInstance::generateBuffer (tcu::PixelBufferAccess buffer, int width, int height, int depth, FillMode mode)
273 if (mode == FILL_MODE_GRADIENT)
275 tcu::fillWithComponentGradients(buffer, tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
279 const tcu::Vec4 redColor (1.0, 0.0, 0.0, 1.0);
280 const tcu::Vec4 greenColor (0.0, 1.0, 0.0, 1.0);
281 const tcu::Vec4 blueColor (0.0, 0.0, 1.0, 1.0);
282 const tcu::Vec4 whiteColor (1.0, 1.0, 1.0, 1.0);
284 for (int z = 0; z < depth; z++)
286 for (int y = 0; y < height; y++)
288 for (int x = 0; x < width; x++)
292 case FILL_MODE_WHITE:
293 if (tcu::isCombinedDepthStencilType(buffer.getFormat().type))
295 buffer.setPixDepth(1.0f, x, y, z);
296 if (tcu::hasStencilComponent(buffer.getFormat().order))
297 buffer.setPixStencil(255, x, y, z);
300 buffer.setPixel(whiteColor, x, y, z);
303 if (tcu::isCombinedDepthStencilType(buffer.getFormat().type))
305 buffer.setPixDepth(redColor[x % 4], x, y, z);
306 if (tcu::hasStencilComponent(buffer.getFormat().order))
307 buffer.setPixStencil(255 * (int)redColor[y % 4], x, y, z);
310 buffer.setPixel(redColor, x, y, z);
312 case FILL_MODE_MULTISAMPLE:
313 buffer.setPixel((x == y) ? tcu::Vec4(0.0, 0.5, 0.5, 1.0) : ((x > y) ? greenColor : blueColor), x, y, z);
323 void CopiesAndBlittingTestInstance::uploadBuffer (tcu::ConstPixelBufferAccess bufferAccess, const Allocation& bufferAlloc)
325 const DeviceInterface& vk = m_context.getDeviceInterface();
326 const VkDevice vkDevice = m_context.getDevice();
327 const deUint32 bufferSize = calculateSize(bufferAccess);
330 deMemcpy(bufferAlloc.getHostPtr(), bufferAccess.getDataPtr(), bufferSize);
331 flushMappedMemoryRange(vk, vkDevice, bufferAlloc.getMemory(), bufferAlloc.getOffset(), bufferSize);
334 void CopiesAndBlittingTestInstance::uploadImageAspect (const tcu::ConstPixelBufferAccess& imageAccess, const VkImage& image, const ImageParms& parms)
336 const DeviceInterface& vk = m_context.getDeviceInterface();
337 const VkDevice vkDevice = m_context.getDevice();
338 const VkQueue queue = m_context.getUniversalQueue();
339 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
340 Allocator& memAlloc = m_context.getDefaultAllocator();
342 Move<VkBuffer> buffer;
343 const deUint32 bufferSize = calculateSize(imageAccess);
344 de::MovePtr<Allocation> bufferAlloc;
345 const deUint32 arraySize = getArraySize(parms);
346 const VkExtent3D imageExtent = getExtent3D(parms);
348 // Create source buffer
350 const VkBufferCreateInfo bufferParams =
352 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
353 DE_NULL, // const void* pNext;
354 0u, // VkBufferCreateFlags flags;
355 bufferSize, // VkDeviceSize size;
356 VK_BUFFER_USAGE_TRANSFER_SRC_BIT, // VkBufferUsageFlags usage;
357 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
358 1u, // deUint32 queueFamilyIndexCount;
359 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
362 buffer = createBuffer(vk, vkDevice, &bufferParams);
363 bufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *buffer), MemoryRequirement::HostVisible);
364 VK_CHECK(vk.bindBufferMemory(vkDevice, *buffer, bufferAlloc->getMemory(), bufferAlloc->getOffset()));
367 // Barriers for copying buffer to image
368 const VkBufferMemoryBarrier preBufferBarrier =
370 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
371 DE_NULL, // const void* pNext;
372 VK_ACCESS_HOST_WRITE_BIT, // VkAccessFlags srcAccessMask;
373 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
374 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
375 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
376 *buffer, // VkBuffer buffer;
377 0u, // VkDeviceSize offset;
378 bufferSize // VkDeviceSize size;
381 const VkImageAspectFlags formatAspect = getAspectFlags(mapVkFormat(parms.format));
382 const bool skipPreImageBarrier = formatAspect == (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT) &&
383 getAspectFlags(imageAccess.getFormat()) == VK_IMAGE_ASPECT_STENCIL_BIT;
384 const VkImageMemoryBarrier preImageBarrier =
386 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
387 DE_NULL, // const void* pNext;
388 0u, // VkAccessFlags srcAccessMask;
389 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
390 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
391 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
392 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
393 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
394 image, // VkImage image;
395 { // VkImageSubresourceRange subresourceRange;
396 formatAspect, // VkImageAspectFlags aspect;
397 0u, // deUint32 baseMipLevel;
398 1u, // deUint32 mipLevels;
399 0u, // deUint32 baseArraySlice;
400 arraySize, // deUint32 arraySize;
404 const VkImageMemoryBarrier postImageBarrier =
406 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
407 DE_NULL, // const void* pNext;
408 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
409 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
410 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
411 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
412 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
413 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
414 image, // VkImage image;
415 { // VkImageSubresourceRange subresourceRange;
416 formatAspect, // VkImageAspectFlags aspect;
417 0u, // deUint32 baseMipLevel;
418 1u, // deUint32 mipLevels;
419 0u, // deUint32 baseArraySlice;
420 arraySize, // deUint32 arraySize;
424 const VkBufferImageCopy copyRegion =
426 0u, // VkDeviceSize bufferOffset;
427 (deUint32)imageAccess.getWidth(), // deUint32 bufferRowLength;
428 (deUint32)imageAccess.getHeight(), // deUint32 bufferImageHeight;
430 getAspectFlags(imageAccess.getFormat()), // VkImageAspectFlags aspect;
431 0u, // deUint32 mipLevel;
432 0u, // deUint32 baseArrayLayer;
433 arraySize, // deUint32 layerCount;
434 }, // VkImageSubresourceLayers imageSubresource;
435 { 0, 0, 0 }, // VkOffset3D imageOffset;
436 imageExtent // VkExtent3D imageExtent;
440 deMemcpy(bufferAlloc->getHostPtr(), imageAccess.getDataPtr(), bufferSize);
441 flushMappedMemoryRange(vk, vkDevice, bufferAlloc->getMemory(), bufferAlloc->getOffset(), bufferSize);
443 // Copy buffer to image
444 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
446 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
447 DE_NULL, // const void* pNext;
448 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
449 (const VkCommandBufferInheritanceInfo*)DE_NULL,
452 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
453 vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL,
454 1, &preBufferBarrier, (skipPreImageBarrier ? 0 : 1), (skipPreImageBarrier ? DE_NULL : &preImageBarrier));
455 vk.cmdCopyBufferToImage(*m_cmdBuffer, *buffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1u, ©Region);
456 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, &postImageBarrier);
457 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
459 submitCommandsAndWait(vk, vkDevice, queue, *m_cmdBuffer);
462 void CopiesAndBlittingTestInstance::uploadImage (const tcu::ConstPixelBufferAccess& src, VkImage dst, const ImageParms& parms)
464 if (tcu::isCombinedDepthStencilType(src.getFormat().type))
466 if (tcu::hasDepthComponent(src.getFormat().order))
468 tcu::TextureLevel depthTexture (mapCombinedToDepthTransferFormat(src.getFormat()), src.getWidth(), src.getHeight(), src.getDepth());
469 tcu::copy(depthTexture.getAccess(), tcu::getEffectiveDepthStencilAccess(src, tcu::Sampler::MODE_DEPTH));
470 uploadImageAspect(depthTexture.getAccess(), dst, parms);
473 if (tcu::hasStencilComponent(src.getFormat().order))
475 tcu::TextureLevel stencilTexture (tcu::getEffectiveDepthStencilTextureFormat(src.getFormat(), tcu::Sampler::MODE_STENCIL), src.getWidth(), src.getHeight(), src.getDepth());
476 tcu::copy(stencilTexture.getAccess(), tcu::getEffectiveDepthStencilAccess(src, tcu::Sampler::MODE_STENCIL));
477 uploadImageAspect(stencilTexture.getAccess(), dst, parms);
481 uploadImageAspect(src, dst, parms);
484 tcu::TestStatus CopiesAndBlittingTestInstance::checkTestResult (tcu::ConstPixelBufferAccess result)
486 const tcu::ConstPixelBufferAccess expected = m_expectedTextureLevel->getAccess();
488 if (isFloatFormat(result.getFormat()))
490 const tcu::Vec4 threshold (0.0f);
491 if (!tcu::floatThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparsion", expected, result, threshold, tcu::COMPARE_LOG_RESULT))
492 return tcu::TestStatus::fail("CopiesAndBlitting test");
496 const tcu::UVec4 threshold (0u);
497 if (!tcu::intThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparsion", expected, result, threshold, tcu::COMPARE_LOG_RESULT))
498 return tcu::TestStatus::fail("CopiesAndBlitting test");
501 return tcu::TestStatus::pass("CopiesAndBlitting test");
504 void CopiesAndBlittingTestInstance::generateExpectedResult (void)
506 const tcu::ConstPixelBufferAccess src = m_sourceTextureLevel->getAccess();
507 const tcu::ConstPixelBufferAccess dst = m_destinationTextureLevel->getAccess();
509 m_expectedTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(dst.getFormat(), dst.getWidth(), dst.getHeight(), dst.getDepth()));
510 tcu::copy(m_expectedTextureLevel->getAccess(), dst);
512 for (deUint32 i = 0; i < m_params.regions.size(); i++)
513 copyRegionToTextureLevel(src, m_expectedTextureLevel->getAccess(), m_params.regions[i]);
516 class CopiesAndBlittingTestCase : public vkt::TestCase
519 CopiesAndBlittingTestCase (tcu::TestContext& testCtx,
520 const std::string& name,
521 const std::string& description)
522 : vkt::TestCase (testCtx, name, description)
525 virtual TestInstance* createInstance (Context& context) const = 0;
528 void CopiesAndBlittingTestInstance::readImageAspect (vk::VkImage image,
529 const tcu::PixelBufferAccess& dst,
530 const ImageParms& imageParms)
532 const DeviceInterface& vk = m_context.getDeviceInterface();
533 const VkDevice device = m_context.getDevice();
534 const VkQueue queue = m_context.getUniversalQueue();
535 Allocator& allocator = m_context.getDefaultAllocator();
537 Move<VkBuffer> buffer;
538 de::MovePtr<Allocation> bufferAlloc;
539 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
540 const VkDeviceSize pixelDataSize = calculateSize(dst);
541 const VkExtent3D imageExtent = getExtent3D(imageParms);
543 // Create destination buffer
545 const VkBufferCreateInfo bufferParams =
547 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
548 DE_NULL, // const void* pNext;
549 0u, // VkBufferCreateFlags flags;
550 pixelDataSize, // VkDeviceSize size;
551 VK_BUFFER_USAGE_TRANSFER_DST_BIT, // VkBufferUsageFlags usage;
552 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
553 1u, // deUint32 queueFamilyIndexCount;
554 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
557 buffer = createBuffer(vk, device, &bufferParams);
558 bufferAlloc = allocator.allocate(getBufferMemoryRequirements(vk, device, *buffer), MemoryRequirement::HostVisible);
559 VK_CHECK(vk.bindBufferMemory(device, *buffer, bufferAlloc->getMemory(), bufferAlloc->getOffset()));
561 deMemset(bufferAlloc->getHostPtr(), 0, static_cast<size_t>(pixelDataSize));
562 flushMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), pixelDataSize);
565 // Barriers for copying image to buffer
566 const VkImageAspectFlags formatAspect = getAspectFlags(mapVkFormat(imageParms.format));
567 const VkImageMemoryBarrier imageBarrier =
569 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
570 DE_NULL, // const void* pNext;
571 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
572 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
573 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
574 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // VkImageLayout newLayout;
575 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
576 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
577 image, // VkImage image;
578 { // VkImageSubresourceRange subresourceRange;
579 formatAspect, // VkImageAspectFlags aspectMask;
580 0u, // deUint32 baseMipLevel;
581 1u, // deUint32 mipLevels;
582 0u, // deUint32 baseArraySlice;
583 getArraySize(imageParms)// deUint32 arraySize;
587 const VkBufferMemoryBarrier bufferBarrier =
589 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
590 DE_NULL, // const void* pNext;
591 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
592 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
593 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
594 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
595 *buffer, // VkBuffer buffer;
596 0u, // VkDeviceSize offset;
597 pixelDataSize // VkDeviceSize size;
600 const VkImageMemoryBarrier postImageBarrier =
602 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
603 DE_NULL, // const void* pNext;
604 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags srcAccessMask;
605 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
606 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // VkImageLayout oldLayout;
607 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
608 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
609 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
610 image, // VkImage image;
612 formatAspect, // VkImageAspectFlags aspectMask;
613 0u, // deUint32 baseMipLevel;
614 1u, // deUint32 mipLevels;
615 0u, // deUint32 baseArraySlice;
616 getArraySize(imageParms) // deUint32 arraySize;
617 } // VkImageSubresourceRange subresourceRange;
620 // Copy image to buffer
621 const VkImageAspectFlags aspect = getAspectFlags(dst.getFormat());
622 const VkBufferImageCopy copyRegion =
624 0u, // VkDeviceSize bufferOffset;
625 (deUint32)dst.getWidth(), // deUint32 bufferRowLength;
626 (deUint32)dst.getHeight(), // deUint32 bufferImageHeight;
628 aspect, // VkImageAspectFlags aspect;
629 0u, // deUint32 mipLevel;
630 0u, // deUint32 baseArrayLayer;
631 getArraySize(imageParms), // deUint32 layerCount;
632 }, // VkImageSubresourceLayers imageSubresource;
633 { 0, 0, 0 }, // VkOffset3D imageOffset;
634 imageExtent // VkExtent3D imageExtent;
637 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
639 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
640 DE_NULL, // const void* pNext;
641 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
642 (const VkCommandBufferInheritanceInfo*)DE_NULL,
645 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
646 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, &imageBarrier);
647 vk.cmdCopyImageToBuffer(*m_cmdBuffer, image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *buffer, 1u, ©Region);
648 vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_HOST_BIT|VK_PIPELINE_STAGE_TRANSFER_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 1, &bufferBarrier, 1, &postImageBarrier);
649 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
651 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer);
654 invalidateMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), pixelDataSize);
655 tcu::copy(dst, tcu::ConstPixelBufferAccess(dst.getFormat(), dst.getSize(), bufferAlloc->getHostPtr()));
658 void CopiesAndBlittingTestInstance::submitCommandsAndWait (const DeviceInterface& vk, const VkDevice device, const VkQueue queue, const VkCommandBuffer& cmdBuffer)
660 const VkSubmitInfo submitInfo =
662 VK_STRUCTURE_TYPE_SUBMIT_INFO, // VkStructureType sType;
663 DE_NULL, // const void* pNext;
664 0u, // deUint32 waitSemaphoreCount;
665 DE_NULL, // const VkSemaphore* pWaitSemaphores;
666 (const VkPipelineStageFlags*)DE_NULL,
667 1u, // deUint32 commandBufferCount;
668 &cmdBuffer, // const VkCommandBuffer* pCommandBuffers;
669 0u, // deUint32 signalSemaphoreCount;
670 DE_NULL // const VkSemaphore* pSignalSemaphores;
673 VK_CHECK(vk.resetFences(device, 1, &m_fence.get()));
674 VK_CHECK(vk.queueSubmit(queue, 1, &submitInfo, *m_fence));
675 VK_CHECK(vk.waitForFences(device, 1, &m_fence.get(), true, ~(0ull) /* infinity */));
678 de::MovePtr<tcu::TextureLevel> CopiesAndBlittingTestInstance::readImage (vk::VkImage image,
679 const ImageParms& parms)
681 const tcu::TextureFormat imageFormat = mapVkFormat(parms.format);
682 de::MovePtr<tcu::TextureLevel> resultLevel (new tcu::TextureLevel(imageFormat, parms.extent.width, parms.extent.height, parms.extent.depth));
684 if (tcu::isCombinedDepthStencilType(imageFormat.type))
686 if (tcu::hasDepthComponent(imageFormat.order))
688 tcu::TextureLevel depthTexture (mapCombinedToDepthTransferFormat(imageFormat), parms.extent.width, parms.extent.height, parms.extent.depth);
689 readImageAspect(image, depthTexture.getAccess(), parms);
690 tcu::copy(tcu::getEffectiveDepthStencilAccess(resultLevel->getAccess(), tcu::Sampler::MODE_DEPTH), depthTexture.getAccess());
693 if (tcu::hasStencilComponent(imageFormat.order))
695 tcu::TextureLevel stencilTexture (tcu::getEffectiveDepthStencilTextureFormat(imageFormat, tcu::Sampler::MODE_STENCIL), parms.extent.width, parms.extent.height, parms.extent.depth);
696 readImageAspect(image, stencilTexture.getAccess(), parms);
697 tcu::copy(tcu::getEffectiveDepthStencilAccess(resultLevel->getAccess(), tcu::Sampler::MODE_STENCIL), stencilTexture.getAccess());
701 readImageAspect(image, resultLevel->getAccess(), parms);
706 // Copy from image to image.
708 class CopyImageToImage : public CopiesAndBlittingTestInstance
711 CopyImageToImage (Context& context,
713 virtual tcu::TestStatus iterate (void);
716 virtual tcu::TestStatus checkTestResult (tcu::ConstPixelBufferAccess result);
719 Move<VkImage> m_source;
720 de::MovePtr<Allocation> m_sourceImageAlloc;
721 Move<VkImage> m_destination;
722 de::MovePtr<Allocation> m_destinationImageAlloc;
724 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region);
727 CopyImageToImage::CopyImageToImage (Context& context, TestParams params)
728 : CopiesAndBlittingTestInstance(context, params)
730 const DeviceInterface& vk = context.getDeviceInterface();
731 const VkDevice vkDevice = context.getDevice();
732 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
733 Allocator& memAlloc = context.getDefaultAllocator();
735 VkImageFormatProperties properties;
736 if ((context.getInstanceInterface().getPhysicalDeviceImageFormatProperties (context.getPhysicalDevice(),
737 m_params.src.image.format,
739 VK_IMAGE_TILING_OPTIMAL,
740 VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
742 &properties) == VK_ERROR_FORMAT_NOT_SUPPORTED) ||
743 (context.getInstanceInterface().getPhysicalDeviceImageFormatProperties (context.getPhysicalDevice(),
744 m_params.dst.image.format,
746 VK_IMAGE_TILING_OPTIMAL,
747 VK_IMAGE_USAGE_TRANSFER_DST_BIT,
749 &properties) == VK_ERROR_FORMAT_NOT_SUPPORTED))
751 TCU_THROW(NotSupportedError, "Format not supported");
754 // Create source image
756 const VkImageCreateInfo sourceImageParams =
758 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
759 DE_NULL, // const void* pNext;
760 0u, // VkImageCreateFlags flags;
761 VK_IMAGE_TYPE_2D, // VkImageType imageType;
762 m_params.src.image.format, // VkFormat format;
763 m_params.src.image.extent, // VkExtent3D extent;
764 1u, // deUint32 mipLevels;
765 1u, // deUint32 arraySize;
766 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
767 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
768 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
769 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
770 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
771 1u, // deUint32 queueFamilyCount;
772 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
773 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
776 m_source = createImage(vk, vkDevice, &sourceImageParams);
777 m_sourceImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::Any);
778 VK_CHECK(vk.bindImageMemory(vkDevice, *m_source, m_sourceImageAlloc->getMemory(), m_sourceImageAlloc->getOffset()));
781 // Create destination image
783 const VkImageCreateInfo destinationImageParams =
785 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
786 DE_NULL, // const void* pNext;
787 0u, // VkImageCreateFlags flags;
788 VK_IMAGE_TYPE_2D, // VkImageType imageType;
789 m_params.dst.image.format, // VkFormat format;
790 m_params.dst.image.extent, // VkExtent3D extent;
791 1u, // deUint32 mipLevels;
792 1u, // deUint32 arraySize;
793 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
794 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
795 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
796 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
797 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
798 1u, // deUint32 queueFamilyCount;
799 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
800 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
803 m_destination = createImage(vk, vkDevice, &destinationImageParams);
804 m_destinationImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::Any);
805 VK_CHECK(vk.bindImageMemory(vkDevice, *m_destination, m_destinationImageAlloc->getMemory(), m_destinationImageAlloc->getOffset()));
809 tcu::TestStatus CopyImageToImage::iterate (void)
811 const tcu::TextureFormat srcTcuFormat = mapVkFormat(m_params.src.image.format);
812 const tcu::TextureFormat dstTcuFormat = mapVkFormat(m_params.dst.image.format);
813 m_sourceTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(srcTcuFormat,
814 m_params.src.image.extent.width,
815 m_params.src.image.extent.height,
816 m_params.src.image.extent.depth));
817 generateBuffer(m_sourceTextureLevel->getAccess(), m_params.src.image.extent.width, m_params.src.image.extent.height, m_params.src.image.extent.depth, FILL_MODE_RED);
818 m_destinationTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(dstTcuFormat,
819 (int)m_params.dst.image.extent.width,
820 (int)m_params.dst.image.extent.height,
821 (int)m_params.dst.image.extent.depth));
822 generateBuffer(m_destinationTextureLevel->getAccess(), m_params.dst.image.extent.width, m_params.dst.image.extent.height, m_params.dst.image.extent.depth, FILL_MODE_GRADIENT);
823 generateExpectedResult();
825 uploadImage(m_sourceTextureLevel->getAccess(), m_source.get(), m_params.src.image);
826 uploadImage(m_destinationTextureLevel->getAccess(), m_destination.get(), m_params.dst.image);
828 const DeviceInterface& vk = m_context.getDeviceInterface();
829 const VkDevice vkDevice = m_context.getDevice();
830 const VkQueue queue = m_context.getUniversalQueue();
832 std::vector<VkImageCopy> imageCopies;
833 for (deUint32 i = 0; i < m_params.regions.size(); i++)
834 imageCopies.push_back(m_params.regions[i].imageCopy);
836 const VkImageMemoryBarrier imageBarriers[] =
840 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
841 DE_NULL, // const void* pNext;
842 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
843 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
844 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
845 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // VkImageLayout newLayout;
846 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
847 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
848 m_source.get(), // VkImage image;
849 { // VkImageSubresourceRange subresourceRange;
850 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
851 0u, // deUint32 baseMipLevel;
852 1u, // deUint32 mipLevels;
853 0u, // deUint32 baseArraySlice;
854 1u // deUint32 arraySize;
859 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
860 DE_NULL, // const void* pNext;
861 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
862 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
863 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
864 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
865 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
866 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
867 m_destination.get(), // VkImage image;
868 { // VkImageSubresourceRange subresourceRange;
869 getAspectFlags(dstTcuFormat), // VkImageAspectFlags aspectMask;
870 0u, // deUint32 baseMipLevel;
871 1u, // deUint32 mipLevels;
872 0u, // deUint32 baseArraySlice;
873 1u // deUint32 arraySize;
878 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
880 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
881 DE_NULL, // const void* pNext;
882 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
883 (const VkCommandBufferInheritanceInfo*)DE_NULL,
886 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
887 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, DE_LENGTH_OF_ARRAY(imageBarriers), imageBarriers);
888 vk.cmdCopyImage(*m_cmdBuffer, m_source.get(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, m_destination.get(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (deUint32)m_params.regions.size(), imageCopies.data());
889 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
891 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
893 de::MovePtr<tcu::TextureLevel> resultTextureLevel = readImage(*m_destination, m_params.dst.image);
895 return checkTestResult(resultTextureLevel->getAccess());
898 tcu::TestStatus CopyImageToImage::checkTestResult (tcu::ConstPixelBufferAccess result)
900 const tcu::Vec4 fThreshold (0.0f);
901 const tcu::UVec4 uThreshold (0u);
903 if (tcu::isCombinedDepthStencilType(result.getFormat().type))
905 if (tcu::hasDepthComponent(result.getFormat().order))
907 const tcu::Sampler::DepthStencilMode mode = tcu::Sampler::MODE_DEPTH;
908 const tcu::ConstPixelBufferAccess depthResult = tcu::getEffectiveDepthStencilAccess(result, mode);
909 const tcu::ConstPixelBufferAccess expectedResult = tcu::getEffectiveDepthStencilAccess(m_expectedTextureLevel->getAccess(), mode);
911 if (isFloatFormat(result.getFormat()))
913 if (!tcu::floatThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparsion", expectedResult, depthResult, fThreshold, tcu::COMPARE_LOG_RESULT))
914 return tcu::TestStatus::fail("CopiesAndBlitting test");
918 if (!tcu::intThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparsion", expectedResult, depthResult, uThreshold, tcu::COMPARE_LOG_RESULT))
919 return tcu::TestStatus::fail("CopiesAndBlitting test");
923 if (tcu::hasStencilComponent(result.getFormat().order))
925 const tcu::Sampler::DepthStencilMode mode = tcu::Sampler::MODE_STENCIL;
926 const tcu::ConstPixelBufferAccess stencilResult = tcu::getEffectiveDepthStencilAccess(result, mode);
927 const tcu::ConstPixelBufferAccess expectedResult = tcu::getEffectiveDepthStencilAccess(m_expectedTextureLevel->getAccess(), mode);
929 if (isFloatFormat(result.getFormat()))
931 if (!tcu::floatThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparsion", expectedResult, stencilResult, fThreshold, tcu::COMPARE_LOG_RESULT))
932 return tcu::TestStatus::fail("CopiesAndBlitting test");
936 if (!tcu::intThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparsion", expectedResult, stencilResult, uThreshold, tcu::COMPARE_LOG_RESULT))
937 return tcu::TestStatus::fail("CopiesAndBlitting test");
943 if (isFloatFormat(result.getFormat()))
945 if (!tcu::floatThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparsion", m_expectedTextureLevel->getAccess(), result, fThreshold, tcu::COMPARE_LOG_RESULT))
946 return tcu::TestStatus::fail("CopiesAndBlitting test");
950 if (!tcu::intThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparsion", m_expectedTextureLevel->getAccess(), result, uThreshold, tcu::COMPARE_LOG_RESULT))
951 return tcu::TestStatus::fail("CopiesAndBlitting test");
955 return tcu::TestStatus::pass("CopiesAndBlitting test");
958 void CopyImageToImage::copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region)
960 const VkOffset3D srcOffset = region.imageCopy.srcOffset;
961 const VkOffset3D dstOffset = region.imageCopy.dstOffset;
962 const VkExtent3D extent = region.imageCopy.extent;
964 if (tcu::isCombinedDepthStencilType(src.getFormat().type))
966 DE_ASSERT(src.getFormat() == dst.getFormat());
969 if (tcu::hasDepthComponent(src.getFormat().order))
971 const tcu::ConstPixelBufferAccess srcSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(src, srcOffset.x, srcOffset.y, srcOffset.z, extent.width, extent.height, extent.depth), tcu::Sampler::MODE_DEPTH);
972 const tcu::PixelBufferAccess dstSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(dst, dstOffset.x, dstOffset.y, dstOffset.z, extent.width, extent.height, extent.depth), tcu::Sampler::MODE_DEPTH);
973 tcu::copy(dstSubRegion, srcSubRegion);
977 if (tcu::hasStencilComponent(src.getFormat().order))
979 const tcu::ConstPixelBufferAccess srcSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(src, srcOffset.x, srcOffset.y, srcOffset.z, extent.width, extent.height, extent.depth), tcu::Sampler::MODE_STENCIL);
980 const tcu::PixelBufferAccess dstSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(dst, dstOffset.x, dstOffset.y, dstOffset.z, extent.width, extent.height, extent.depth), tcu::Sampler::MODE_STENCIL);
981 tcu::copy(dstSubRegion, srcSubRegion);
986 const tcu::ConstPixelBufferAccess srcSubRegion = tcu::getSubregion(src, srcOffset.x, srcOffset.y, srcOffset.z, extent.width, extent.height, extent.depth);
987 // CopyImage acts like a memcpy. Replace the destination format with the srcformat to use a memcpy.
988 const tcu::PixelBufferAccess dstWithSrcFormat (srcSubRegion.getFormat(), dst.getSize(), dst.getDataPtr());
989 const tcu::PixelBufferAccess dstSubRegion = tcu::getSubregion(dstWithSrcFormat, dstOffset.x, dstOffset.y, dstOffset.z, extent.width, extent.height, extent.depth);
991 tcu::copy(dstSubRegion, srcSubRegion);
995 class CopyImageToImageTestCase : public vkt::TestCase
998 CopyImageToImageTestCase (tcu::TestContext& testCtx,
999 const std::string& name,
1000 const std::string& description,
1001 const TestParams params)
1002 : vkt::TestCase (testCtx, name, description)
1006 virtual TestInstance* createInstance (Context& context) const
1008 return new CopyImageToImage(context, m_params);
1011 TestParams m_params;
1014 // Copy from buffer to buffer.
1016 class CopyBufferToBuffer : public CopiesAndBlittingTestInstance
1019 CopyBufferToBuffer (Context& context, TestParams params);
1020 virtual tcu::TestStatus iterate (void);
1022 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess, tcu::PixelBufferAccess, CopyRegion);
1023 Move<VkBuffer> m_source;
1024 de::MovePtr<Allocation> m_sourceBufferAlloc;
1025 Move<VkBuffer> m_destination;
1026 de::MovePtr<Allocation> m_destinationBufferAlloc;
1029 CopyBufferToBuffer::CopyBufferToBuffer (Context& context, TestParams params)
1030 : CopiesAndBlittingTestInstance (context, params)
1032 const DeviceInterface& vk = context.getDeviceInterface();
1033 const VkDevice vkDevice = context.getDevice();
1034 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
1035 Allocator& memAlloc = context.getDefaultAllocator();
1037 // Create source buffer
1039 const VkBufferCreateInfo sourceBufferParams =
1041 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
1042 DE_NULL, // const void* pNext;
1043 0u, // VkBufferCreateFlags flags;
1044 m_params.src.buffer.size, // VkDeviceSize size;
1045 VK_BUFFER_USAGE_TRANSFER_SRC_BIT, // VkBufferUsageFlags usage;
1046 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1047 1u, // deUint32 queueFamilyIndexCount;
1048 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1051 m_source = createBuffer(vk, vkDevice, &sourceBufferParams);
1052 m_sourceBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::HostVisible);
1053 VK_CHECK(vk.bindBufferMemory(vkDevice, *m_source, m_sourceBufferAlloc->getMemory(), m_sourceBufferAlloc->getOffset()));
1056 // Create destination buffer
1058 const VkBufferCreateInfo destinationBufferParams =
1060 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
1061 DE_NULL, // const void* pNext;
1062 0u, // VkBufferCreateFlags flags;
1063 m_params.dst.buffer.size, // VkDeviceSize size;
1064 VK_BUFFER_USAGE_TRANSFER_DST_BIT, // VkBufferUsageFlags usage;
1065 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1066 1u, // deUint32 queueFamilyIndexCount;
1067 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1070 m_destination = createBuffer(vk, vkDevice, &destinationBufferParams);
1071 m_destinationBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::HostVisible);
1072 VK_CHECK(vk.bindBufferMemory(vkDevice, *m_destination, m_destinationBufferAlloc->getMemory(), m_destinationBufferAlloc->getOffset()));
1076 tcu::TestStatus CopyBufferToBuffer::iterate (void)
1078 const int srcLevelWidth = (int)(m_params.src.buffer.size/4); // Here the format is VK_FORMAT_R32_UINT, we need to divide the buffer size by 4
1079 m_sourceTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(mapVkFormat(VK_FORMAT_R32_UINT), srcLevelWidth, 1));
1080 generateBuffer(m_sourceTextureLevel->getAccess(), srcLevelWidth, 1, 1, FILL_MODE_RED);
1082 const int dstLevelWidth = (int)(m_params.dst.buffer.size/4);
1083 m_destinationTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(mapVkFormat(VK_FORMAT_R32_UINT), dstLevelWidth, 1));
1084 generateBuffer(m_destinationTextureLevel->getAccess(), dstLevelWidth, 1, 1, FILL_MODE_WHITE);
1086 generateExpectedResult();
1088 uploadBuffer(m_sourceTextureLevel->getAccess(), *m_sourceBufferAlloc);
1089 uploadBuffer(m_destinationTextureLevel->getAccess(), *m_destinationBufferAlloc);
1091 const DeviceInterface& vk = m_context.getDeviceInterface();
1092 const VkDevice vkDevice = m_context.getDevice();
1093 const VkQueue queue = m_context.getUniversalQueue();
1095 const VkBufferMemoryBarrier srcBufferBarrier =
1097 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
1098 DE_NULL, // const void* pNext;
1099 VK_ACCESS_HOST_WRITE_BIT, // VkAccessFlags srcAccessMask;
1100 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
1101 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1102 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1103 *m_source, // VkBuffer buffer;
1104 0u, // VkDeviceSize offset;
1105 m_params.src.buffer.size // VkDeviceSize size;
1108 const VkBufferMemoryBarrier dstBufferBarrier =
1110 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
1111 DE_NULL, // const void* pNext;
1112 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
1113 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
1114 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1115 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1116 *m_destination, // VkBuffer buffer;
1117 0u, // VkDeviceSize offset;
1118 m_params.dst.buffer.size // VkDeviceSize size;
1121 std::vector<VkBufferCopy> bufferCopies;
1122 for (deUint32 i = 0; i < m_params.regions.size(); i++)
1123 bufferCopies.push_back(m_params.regions[i].bufferCopy);
1125 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
1127 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
1128 DE_NULL, // const void* pNext;
1129 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
1130 (const VkCommandBufferInheritanceInfo*)DE_NULL,
1133 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
1134 vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 1, &srcBufferBarrier, 0, (const VkImageMemoryBarrier*)DE_NULL);
1135 vk.cmdCopyBuffer(*m_cmdBuffer, m_source.get(), m_destination.get(), (deUint32)m_params.regions.size(), &bufferCopies[0]);
1136 vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 1, &dstBufferBarrier, 0, (const VkImageMemoryBarrier*)DE_NULL);
1137 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1139 const VkSubmitInfo submitInfo =
1141 VK_STRUCTURE_TYPE_SUBMIT_INFO, // VkStructureType sType;
1142 DE_NULL, // const void* pNext;
1143 0u, // deUint32 waitSemaphoreCount;
1144 DE_NULL, // const VkSemaphore* pWaitSemaphores;
1145 (const VkPipelineStageFlags*)DE_NULL,
1146 1u, // deUint32 commandBufferCount;
1147 &m_cmdBuffer.get(), // const VkCommandBuffer* pCommandBuffers;
1148 0u, // deUint32 signalSemaphoreCount;
1149 DE_NULL // const VkSemaphore* pSignalSemaphores;
1152 VK_CHECK(vk.resetFences(vkDevice, 1, &m_fence.get()));
1153 VK_CHECK(vk.queueSubmit(queue, 1, &submitInfo, *m_fence));
1154 VK_CHECK(vk.waitForFences(vkDevice, 1, &m_fence.get(), true, ~(0ull) /* infinity */));
1157 de::MovePtr<tcu::TextureLevel> resultLevel (new tcu::TextureLevel(mapVkFormat(VK_FORMAT_R32_UINT), dstLevelWidth, 1));
1158 invalidateMappedMemoryRange(vk, vkDevice, m_destinationBufferAlloc->getMemory(), m_destinationBufferAlloc->getOffset(), m_params.dst.buffer.size);
1159 tcu::copy(*resultLevel, tcu::ConstPixelBufferAccess(resultLevel->getFormat(), resultLevel->getSize(), m_destinationBufferAlloc->getHostPtr()));
1161 return checkTestResult(resultLevel->getAccess());
1164 void CopyBufferToBuffer::copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region)
1166 deMemcpy((deUint8*) dst.getDataPtr() + region.bufferCopy.dstOffset,
1167 (deUint8*) src.getDataPtr() + region.bufferCopy.srcOffset,
1168 (size_t)region.bufferCopy.size);
1171 class BufferToBufferTestCase : public vkt::TestCase
1174 BufferToBufferTestCase (tcu::TestContext& testCtx,
1175 const std::string& name,
1176 const std::string& description,
1177 const TestParams params)
1178 : vkt::TestCase (testCtx, name, description)
1182 virtual TestInstance* createInstance (Context& context) const
1184 return new CopyBufferToBuffer(context, m_params);
1187 TestParams m_params;
1190 // Copy from image to buffer.
1192 class CopyImageToBuffer : public CopiesAndBlittingTestInstance
1195 CopyImageToBuffer (Context& context,
1196 TestParams testParams);
1197 virtual tcu::TestStatus iterate (void);
1199 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region);
1201 tcu::TextureFormat m_textureFormat;
1202 VkDeviceSize m_bufferSize;
1204 Move<VkImage> m_source;
1205 de::MovePtr<Allocation> m_sourceImageAlloc;
1206 Move<VkBuffer> m_destination;
1207 de::MovePtr<Allocation> m_destinationBufferAlloc;
1210 CopyImageToBuffer::CopyImageToBuffer (Context& context, TestParams testParams)
1211 : CopiesAndBlittingTestInstance(context, testParams)
1212 , m_textureFormat(mapVkFormat(testParams.src.image.format))
1213 , m_bufferSize(m_params.dst.buffer.size * tcu::getPixelSize(m_textureFormat))
1215 const DeviceInterface& vk = context.getDeviceInterface();
1216 const VkDevice vkDevice = context.getDevice();
1217 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
1218 Allocator& memAlloc = context.getDefaultAllocator();
1220 // Create source image
1222 const VkImageCreateInfo sourceImageParams =
1224 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
1225 DE_NULL, // const void* pNext;
1226 0u, // VkImageCreateFlags flags;
1227 VK_IMAGE_TYPE_2D, // VkImageType imageType;
1228 m_params.src.image.format, // VkFormat format;
1229 m_params.src.image.extent, // VkExtent3D extent;
1230 1u, // deUint32 mipLevels;
1231 1u, // deUint32 arraySize;
1232 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
1233 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
1234 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1235 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
1236 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1237 1u, // deUint32 queueFamilyCount;
1238 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1239 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
1242 m_source = createImage(vk, vkDevice, &sourceImageParams);
1243 m_sourceImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::Any);
1244 VK_CHECK(vk.bindImageMemory(vkDevice, *m_source, m_sourceImageAlloc->getMemory(), m_sourceImageAlloc->getOffset()));
1247 // Create destination buffer
1249 const VkBufferCreateInfo destinationBufferParams =
1251 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
1252 DE_NULL, // const void* pNext;
1253 0u, // VkBufferCreateFlags flags;
1254 m_bufferSize, // VkDeviceSize size;
1255 VK_BUFFER_USAGE_TRANSFER_DST_BIT, // VkBufferUsageFlags usage;
1256 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1257 1u, // deUint32 queueFamilyIndexCount;
1258 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1261 m_destination = createBuffer(vk, vkDevice, &destinationBufferParams);
1262 m_destinationBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::HostVisible);
1263 VK_CHECK(vk.bindBufferMemory(vkDevice, *m_destination, m_destinationBufferAlloc->getMemory(), m_destinationBufferAlloc->getOffset()));
1267 tcu::TestStatus CopyImageToBuffer::iterate (void)
1269 m_sourceTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(m_textureFormat,
1270 m_params.src.image.extent.width,
1271 m_params.src.image.extent.height,
1272 m_params.src.image.extent.depth));
1273 generateBuffer(m_sourceTextureLevel->getAccess(), m_params.src.image.extent.width, m_params.src.image.extent.height, m_params.src.image.extent.depth);
1274 m_destinationTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(m_textureFormat, (int)m_params.dst.buffer.size, 1));
1275 generateBuffer(m_destinationTextureLevel->getAccess(), (int)m_params.dst.buffer.size, 1, 1);
1277 generateExpectedResult();
1279 uploadImage(m_sourceTextureLevel->getAccess(), *m_source, m_params.src.image);
1280 uploadBuffer(m_destinationTextureLevel->getAccess(), *m_destinationBufferAlloc);
1282 const DeviceInterface& vk = m_context.getDeviceInterface();
1283 const VkDevice vkDevice = m_context.getDevice();
1284 const VkQueue queue = m_context.getUniversalQueue();
1286 // Barriers for copying image to buffer
1287 const VkImageMemoryBarrier imageBarrier =
1289 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
1290 DE_NULL, // const void* pNext;
1291 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
1292 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
1293 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
1294 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // VkImageLayout newLayout;
1295 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1296 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1297 *m_source, // VkImage image;
1298 { // VkImageSubresourceRange subresourceRange;
1299 getAspectFlags(m_textureFormat), // VkImageAspectFlags aspectMask;
1300 0u, // deUint32 baseMipLevel;
1301 1u, // deUint32 mipLevels;
1302 0u, // deUint32 baseArraySlice;
1303 1u // deUint32 arraySize;
1307 const VkBufferMemoryBarrier bufferBarrier =
1309 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
1310 DE_NULL, // const void* pNext;
1311 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
1312 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
1313 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1314 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1315 *m_destination, // VkBuffer buffer;
1316 0u, // VkDeviceSize offset;
1317 m_bufferSize // VkDeviceSize size;
1320 // Copy from image to buffer
1321 std::vector<VkBufferImageCopy> bufferImageCopies;
1322 for (deUint32 i = 0; i < m_params.regions.size(); i++)
1323 bufferImageCopies.push_back(m_params.regions[i].bufferImageCopy);
1325 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
1327 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
1328 DE_NULL, // const void* pNext;
1329 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
1330 (const VkCommandBufferInheritanceInfo*)DE_NULL,
1333 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
1334 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, &imageBarrier);
1335 vk.cmdCopyImageToBuffer(*m_cmdBuffer, m_source.get(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, m_destination.get(), (deUint32)m_params.regions.size(), &bufferImageCopies[0]);
1336 vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 1, &bufferBarrier, 0, (const VkImageMemoryBarrier*)DE_NULL);
1337 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1339 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
1342 de::MovePtr<tcu::TextureLevel> resultLevel (new tcu::TextureLevel(m_textureFormat, (int)m_params.dst.buffer.size, 1));
1343 invalidateMappedMemoryRange(vk, vkDevice, m_destinationBufferAlloc->getMemory(), m_destinationBufferAlloc->getOffset(), m_bufferSize);
1344 tcu::copy(*resultLevel, tcu::ConstPixelBufferAccess(resultLevel->getFormat(), resultLevel->getSize(), m_destinationBufferAlloc->getHostPtr()));
1346 return checkTestResult(resultLevel->getAccess());
1349 class CopyImageToBufferTestCase : public vkt::TestCase
1352 CopyImageToBufferTestCase (tcu::TestContext& testCtx,
1353 const std::string& name,
1354 const std::string& description,
1355 const TestParams params)
1356 : vkt::TestCase (testCtx, name, description)
1360 virtual TestInstance* createInstance (Context& context) const
1362 return new CopyImageToBuffer(context, m_params);
1365 TestParams m_params;
1368 void CopyImageToBuffer::copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region)
1370 deUint32 rowLength = region.bufferImageCopy.bufferRowLength;
1372 rowLength = region.bufferImageCopy.imageExtent.width;
1374 deUint32 imageHeight = region.bufferImageCopy.bufferImageHeight;
1376 imageHeight = region.bufferImageCopy.imageExtent.height;
1378 const int texelSize = src.getFormat().getPixelSize();
1379 const VkExtent3D extent = region.bufferImageCopy.imageExtent;
1380 const VkOffset3D srcOffset = region.bufferImageCopy.imageOffset;
1381 const int texelOffset = (int) region.bufferImageCopy.bufferOffset / texelSize;
1383 for (deUint32 z = 0; z < extent.depth; z++)
1385 for (deUint32 y = 0; y < extent.height; y++)
1387 int texelIndex = texelOffset + (z * imageHeight + y) * rowLength;
1388 const tcu::ConstPixelBufferAccess srcSubRegion = tcu::getSubregion(src, srcOffset.x, srcOffset.y + y, srcOffset.z + z,
1389 region.bufferImageCopy.imageExtent.width, 1, 1);
1390 const tcu::PixelBufferAccess dstSubRegion = tcu::getSubregion(dst, texelIndex, 0, region.bufferImageCopy.imageExtent.width, 1);
1391 tcu::copy(dstSubRegion, srcSubRegion);
1396 // Copy from buffer to image.
1398 class CopyBufferToImage : public CopiesAndBlittingTestInstance
1401 CopyBufferToImage (Context& context,
1402 TestParams testParams);
1403 virtual tcu::TestStatus iterate (void);
1405 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region);
1407 tcu::TextureFormat m_textureFormat;
1408 VkDeviceSize m_bufferSize;
1410 Move<VkBuffer> m_source;
1411 de::MovePtr<Allocation> m_sourceBufferAlloc;
1412 Move<VkImage> m_destination;
1413 de::MovePtr<Allocation> m_destinationImageAlloc;
1416 CopyBufferToImage::CopyBufferToImage (Context& context, TestParams testParams)
1417 : CopiesAndBlittingTestInstance(context, testParams)
1418 , m_textureFormat(mapVkFormat(testParams.dst.image.format))
1419 , m_bufferSize(m_params.src.buffer.size * tcu::getPixelSize(m_textureFormat))
1421 const DeviceInterface& vk = context.getDeviceInterface();
1422 const VkDevice vkDevice = context.getDevice();
1423 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
1424 Allocator& memAlloc = context.getDefaultAllocator();
1426 // Create source buffer
1428 const VkBufferCreateInfo sourceBufferParams =
1430 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
1431 DE_NULL, // const void* pNext;
1432 0u, // VkBufferCreateFlags flags;
1433 m_bufferSize, // VkDeviceSize size;
1434 VK_BUFFER_USAGE_TRANSFER_SRC_BIT, // VkBufferUsageFlags usage;
1435 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1436 1u, // deUint32 queueFamilyIndexCount;
1437 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1440 m_source = createBuffer(vk, vkDevice, &sourceBufferParams);
1441 m_sourceBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::HostVisible);
1442 VK_CHECK(vk.bindBufferMemory(vkDevice, *m_source, m_sourceBufferAlloc->getMemory(), m_sourceBufferAlloc->getOffset()));
1445 // Create destination image
1447 const VkImageCreateInfo destinationImageParams =
1449 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
1450 DE_NULL, // const void* pNext;
1451 0u, // VkImageCreateFlags flags;
1452 VK_IMAGE_TYPE_2D, // VkImageType imageType;
1453 m_params.dst.image.format, // VkFormat format;
1454 m_params.dst.image.extent, // VkExtent3D extent;
1455 1u, // deUint32 mipLevels;
1456 1u, // deUint32 arraySize;
1457 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
1458 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
1459 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1460 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
1461 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1462 1u, // deUint32 queueFamilyCount;
1463 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1464 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
1467 m_destination = createImage(vk, vkDevice, &destinationImageParams);
1468 m_destinationImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::Any);
1469 VK_CHECK(vk.bindImageMemory(vkDevice, *m_destination, m_destinationImageAlloc->getMemory(), m_destinationImageAlloc->getOffset()));
1473 tcu::TestStatus CopyBufferToImage::iterate (void)
1475 m_sourceTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(m_textureFormat, (int)m_params.src.buffer.size, 1));
1476 generateBuffer(m_sourceTextureLevel->getAccess(), (int)m_params.src.buffer.size, 1, 1);
1477 m_destinationTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(m_textureFormat,
1478 m_params.dst.image.extent.width,
1479 m_params.dst.image.extent.height,
1480 m_params.dst.image.extent.depth));
1482 generateBuffer(m_destinationTextureLevel->getAccess(), m_params.dst.image.extent.width, m_params.dst.image.extent.height, m_params.dst.image.extent.depth);
1484 generateExpectedResult();
1486 uploadBuffer(m_sourceTextureLevel->getAccess(), *m_sourceBufferAlloc);
1487 uploadImage(m_destinationTextureLevel->getAccess(), *m_destination, m_params.dst.image);
1489 const DeviceInterface& vk = m_context.getDeviceInterface();
1490 const VkDevice vkDevice = m_context.getDevice();
1491 const VkQueue queue = m_context.getUniversalQueue();
1493 const VkImageMemoryBarrier imageBarrier =
1495 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
1496 DE_NULL, // const void* pNext;
1497 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
1498 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
1499 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
1500 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
1501 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1502 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1503 *m_destination, // VkImage image;
1504 { // VkImageSubresourceRange subresourceRange;
1505 getAspectFlags(m_textureFormat), // VkImageAspectFlags aspectMask;
1506 0u, // deUint32 baseMipLevel;
1507 1u, // deUint32 mipLevels;
1508 0u, // deUint32 baseArraySlice;
1509 1u // deUint32 arraySize;
1513 // Copy from buffer to image
1514 std::vector<VkBufferImageCopy> bufferImageCopies;
1515 for (deUint32 i = 0; i < m_params.regions.size(); i++)
1516 bufferImageCopies.push_back(m_params.regions[i].bufferImageCopy);
1518 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
1520 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
1521 DE_NULL, // const void* pNext;
1522 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
1523 (const VkCommandBufferInheritanceInfo*)DE_NULL,
1526 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
1527 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, &imageBarrier);
1528 vk.cmdCopyBufferToImage(*m_cmdBuffer, m_source.get(), m_destination.get(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (deUint32)m_params.regions.size(), bufferImageCopies.data());
1529 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1531 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
1533 de::MovePtr<tcu::TextureLevel> resultLevel = readImage(*m_destination, m_params.dst.image);
1535 return checkTestResult(resultLevel->getAccess());
1538 class CopyBufferToImageTestCase : public vkt::TestCase
1541 CopyBufferToImageTestCase (tcu::TestContext& testCtx,
1542 const std::string& name,
1543 const std::string& description,
1544 const TestParams params)
1545 : vkt::TestCase (testCtx, name, description)
1549 virtual ~CopyBufferToImageTestCase (void) {}
1551 virtual TestInstance* createInstance (Context& context) const
1553 return new CopyBufferToImage(context, m_params);
1556 TestParams m_params;
1559 void CopyBufferToImage::copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region)
1561 deUint32 rowLength = region.bufferImageCopy.bufferRowLength;
1563 rowLength = region.bufferImageCopy.imageExtent.width;
1565 deUint32 imageHeight = region.bufferImageCopy.bufferImageHeight;
1567 imageHeight = region.bufferImageCopy.imageExtent.height;
1569 const int texelSize = dst.getFormat().getPixelSize();
1570 const VkExtent3D extent = region.bufferImageCopy.imageExtent;
1571 const VkOffset3D dstOffset = region.bufferImageCopy.imageOffset;
1572 const int texelOffset = (int) region.bufferImageCopy.bufferOffset / texelSize;
1574 for (deUint32 z = 0; z < extent.depth; z++)
1576 for (deUint32 y = 0; y < extent.height; y++)
1578 int texelIndex = texelOffset + (z * imageHeight + y) * rowLength;
1579 const tcu::ConstPixelBufferAccess srcSubRegion = tcu::getSubregion(src, texelIndex, 0, region.bufferImageCopy.imageExtent.width, 1);
1580 const tcu::PixelBufferAccess dstSubRegion = tcu::getSubregion(dst, dstOffset.x, dstOffset.y + y, dstOffset.z + z,
1581 region.bufferImageCopy.imageExtent.width, 1, 1);
1582 tcu::copy(dstSubRegion, srcSubRegion);
1587 // Copy from image to image with scaling.
1589 class BlittingImages : public CopiesAndBlittingTestInstance
1592 BlittingImages (Context& context,
1594 virtual tcu::TestStatus iterate (void);
1596 virtual tcu::TestStatus checkTestResult (tcu::ConstPixelBufferAccess result);
1597 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region);
1598 virtual void generateExpectedResult (void);
1600 bool checkClampedAndUnclampedResult (const tcu::ConstPixelBufferAccess& result,
1601 const tcu::ConstPixelBufferAccess& clampedReference,
1602 const tcu::ConstPixelBufferAccess& unclampedReference,
1603 VkImageAspectFlagBits aspect);
1604 Move<VkImage> m_source;
1605 de::MovePtr<Allocation> m_sourceImageAlloc;
1606 Move<VkImage> m_destination;
1607 de::MovePtr<Allocation> m_destinationImageAlloc;
1609 de::MovePtr<tcu::TextureLevel> m_unclampedExpectedTextureLevel;
1612 BlittingImages::BlittingImages (Context& context, TestParams params)
1613 : CopiesAndBlittingTestInstance(context, params)
1615 const DeviceInterface& vk = context.getDeviceInterface();
1616 const VkDevice vkDevice = context.getDevice();
1617 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
1618 Allocator& memAlloc = context.getDefaultAllocator();
1620 VkImageFormatProperties properties;
1621 if ((context.getInstanceInterface().getPhysicalDeviceImageFormatProperties (context.getPhysicalDevice(),
1622 m_params.src.image.format,
1624 VK_IMAGE_TILING_OPTIMAL,
1625 VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
1627 &properties) == VK_ERROR_FORMAT_NOT_SUPPORTED) ||
1628 (context.getInstanceInterface().getPhysicalDeviceImageFormatProperties (context.getPhysicalDevice(),
1629 m_params.dst.image.format,
1631 VK_IMAGE_TILING_OPTIMAL,
1632 VK_IMAGE_USAGE_TRANSFER_DST_BIT,
1634 &properties) == VK_ERROR_FORMAT_NOT_SUPPORTED))
1636 TCU_THROW(NotSupportedError, "Format not supported");
1639 VkFormatProperties srcFormatProperties;
1640 context.getInstanceInterface().getPhysicalDeviceFormatProperties(context.getPhysicalDevice(), m_params.src.image.format, &srcFormatProperties);
1641 if (!(srcFormatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_SRC_BIT))
1643 TCU_THROW(NotSupportedError, "Format feature blit source not supported");
1646 VkFormatProperties dstFormatProperties;
1647 context.getInstanceInterface().getPhysicalDeviceFormatProperties(context.getPhysicalDevice(), m_params.dst.image.format, &dstFormatProperties);
1648 if (!(dstFormatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_DST_BIT))
1650 TCU_THROW(NotSupportedError, "Format feature blit destination not supported");
1653 if (m_params.filter == VK_FILTER_LINEAR)
1655 if (!(srcFormatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT))
1656 TCU_THROW(NotSupportedError, "Source format feature sampled image filter linear not supported");
1657 if (!(dstFormatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT))
1658 TCU_THROW(NotSupportedError, "Destination format feature sampled image filter linear not supported");
1661 // Create source image
1663 const VkImageCreateInfo sourceImageParams =
1665 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
1666 DE_NULL, // const void* pNext;
1667 0u, // VkImageCreateFlags flags;
1668 VK_IMAGE_TYPE_2D, // VkImageType imageType;
1669 m_params.src.image.format, // VkFormat format;
1670 m_params.src.image.extent, // VkExtent3D extent;
1671 1u, // deUint32 mipLevels;
1672 1u, // deUint32 arraySize;
1673 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
1674 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
1675 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1676 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
1677 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1678 1u, // deUint32 queueFamilyCount;
1679 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1680 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
1683 m_source = createImage(vk, vkDevice, &sourceImageParams);
1684 m_sourceImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::Any);
1685 VK_CHECK(vk.bindImageMemory(vkDevice, *m_source, m_sourceImageAlloc->getMemory(), m_sourceImageAlloc->getOffset()));
1688 // Create destination image
1690 const VkImageCreateInfo destinationImageParams =
1692 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
1693 DE_NULL, // const void* pNext;
1694 0u, // VkImageCreateFlags flags;
1695 VK_IMAGE_TYPE_2D, // VkImageType imageType;
1696 m_params.dst.image.format, // VkFormat format;
1697 m_params.dst.image.extent, // VkExtent3D extent;
1698 1u, // deUint32 mipLevels;
1699 1u, // deUint32 arraySize;
1700 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
1701 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
1702 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1703 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
1704 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1705 1u, // deUint32 queueFamilyCount;
1706 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1707 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
1710 m_destination = createImage(vk, vkDevice, &destinationImageParams);
1711 m_destinationImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::Any);
1712 VK_CHECK(vk.bindImageMemory(vkDevice, *m_destination, m_destinationImageAlloc->getMemory(), m_destinationImageAlloc->getOffset()));
1716 tcu::TestStatus BlittingImages::iterate (void)
1718 const tcu::TextureFormat srcTcuFormat = mapVkFormat(m_params.src.image.format);
1719 const tcu::TextureFormat dstTcuFormat = mapVkFormat(m_params.dst.image.format);
1720 m_sourceTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(srcTcuFormat,
1721 m_params.src.image.extent.width,
1722 m_params.src.image.extent.height,
1723 m_params.src.image.extent.depth));
1724 generateBuffer(m_sourceTextureLevel->getAccess(), m_params.src.image.extent.width, m_params.src.image.extent.height, m_params.src.image.extent.depth, FILL_MODE_GRADIENT);
1725 m_destinationTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(dstTcuFormat,
1726 (int)m_params.dst.image.extent.width,
1727 (int)m_params.dst.image.extent.height,
1728 (int)m_params.dst.image.extent.depth));
1729 generateBuffer(m_destinationTextureLevel->getAccess(), m_params.dst.image.extent.width, m_params.dst.image.extent.height, m_params.dst.image.extent.depth, FILL_MODE_WHITE);
1730 generateExpectedResult();
1732 uploadImage(m_sourceTextureLevel->getAccess(), m_source.get(), m_params.src.image);
1733 uploadImage(m_destinationTextureLevel->getAccess(), m_destination.get(), m_params.dst.image);
1735 const DeviceInterface& vk = m_context.getDeviceInterface();
1736 const VkDevice vkDevice = m_context.getDevice();
1737 const VkQueue queue = m_context.getUniversalQueue();
1739 std::vector<VkImageBlit> regions;
1740 for (deUint32 i = 0; i < m_params.regions.size(); i++)
1741 regions.push_back(m_params.regions[i].imageBlit);
1743 // Barriers for copying image to buffer
1744 const VkImageMemoryBarrier srcImageBarrier =
1746 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
1747 DE_NULL, // const void* pNext;
1748 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
1749 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
1750 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
1751 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // VkImageLayout newLayout;
1752 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1753 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1754 m_source.get(), // VkImage image;
1755 { // VkImageSubresourceRange subresourceRange;
1756 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
1757 0u, // deUint32 baseMipLevel;
1758 1u, // deUint32 mipLevels;
1759 0u, // deUint32 baseArraySlice;
1760 1u // deUint32 arraySize;
1764 const VkImageMemoryBarrier dstImageBarrier =
1766 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
1767 DE_NULL, // const void* pNext;
1768 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
1769 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
1770 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
1771 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
1772 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1773 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1774 m_destination.get(), // VkImage image;
1775 { // VkImageSubresourceRange subresourceRange;
1776 getAspectFlags(dstTcuFormat), // VkImageAspectFlags aspectMask;
1777 0u, // deUint32 baseMipLevel;
1778 1u, // deUint32 mipLevels;
1779 0u, // deUint32 baseArraySlice;
1780 1u // deUint32 arraySize;
1784 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
1786 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
1787 DE_NULL, // const void* pNext;
1788 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
1789 (const VkCommandBufferInheritanceInfo*)DE_NULL,
1792 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
1793 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);
1794 vk.cmdBlitImage(*m_cmdBuffer, m_source.get(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, m_destination.get(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (deUint32)m_params.regions.size(), ®ions[0], m_params.filter);
1795 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);
1796 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1798 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
1800 de::MovePtr<tcu::TextureLevel> resultTextureLevel = readImage(*m_destination, m_params.dst.image);
1802 return checkTestResult(resultTextureLevel->getAccess());
1805 static float calculateFloatConversionError (int srcBits)
1809 const int clampedBits = de::clamp<int>(srcBits, 0, 32);
1810 const float srcMaxValue = de::max((float)(1ULL<<clampedBits) - 1.0f, 1.0f);
1811 const float error = 1.0f / srcMaxValue;
1813 return de::clamp<float>(error, 0.0f, 1.0f);
1819 tcu::Vec4 getFormatThreshold (const tcu::TextureFormat& format)
1821 tcu::Vec4 threshold(0.01f);
1823 switch (format.type)
1825 case tcu::TextureFormat::HALF_FLOAT:
1826 threshold = tcu::Vec4(0.005f);
1829 case tcu::TextureFormat::FLOAT:
1830 case tcu::TextureFormat::FLOAT64:
1831 threshold = tcu::Vec4(0.001f);
1834 case tcu::TextureFormat::UNSIGNED_INT_11F_11F_10F_REV:
1835 threshold = tcu::Vec4(0.02f, 0.02f, 0.0625f, 1.0f);
1838 case tcu::TextureFormat::UNSIGNED_INT_999_E5_REV:
1839 threshold = tcu::Vec4(0.05f, 0.05f, 0.05f, 1.0f);
1843 const tcu::IVec4 bits = tcu::getTextureFormatMantissaBitDepth(format);
1844 threshold = tcu::Vec4(calculateFloatConversionError(bits.x()),
1845 calculateFloatConversionError(bits.y()),
1846 calculateFloatConversionError(bits.z()),
1847 calculateFloatConversionError(bits.w()));
1850 // Return value matching the channel order specified by the format
1851 if (format.order == tcu::TextureFormat::BGR || format.order == tcu::TextureFormat::BGRA)
1852 return threshold.swizzle(2, 1, 0, 3);
1857 tcu::TextureFormat getFormatAspect (VkFormat format, VkImageAspectFlagBits aspect)
1859 const tcu::TextureFormat baseFormat = mapVkFormat(format);
1861 if (isCombinedDepthStencilType(baseFormat.type))
1863 if (aspect == VK_IMAGE_ASPECT_DEPTH_BIT)
1864 return getEffectiveDepthStencilTextureFormat(baseFormat, tcu::Sampler::MODE_DEPTH);
1865 else if (aspect == VK_IMAGE_ASPECT_STENCIL_BIT)
1866 return getEffectiveDepthStencilTextureFormat(baseFormat, tcu::Sampler::MODE_STENCIL);
1868 DE_FATAL("Invalid aspect");
1874 bool BlittingImages::checkClampedAndUnclampedResult (const tcu::ConstPixelBufferAccess& result,
1875 const tcu::ConstPixelBufferAccess& clampedExpected,
1876 const tcu::ConstPixelBufferAccess& unclampedExpected,
1877 VkImageAspectFlagBits aspect)
1879 tcu::TestLog& log (m_context.getTestContext().getLog());
1880 const bool isLinear = m_params.filter == VK_FILTER_LINEAR;
1881 const tcu::TextureFormat srcFormat = getFormatAspect(m_params.src.image.format, aspect);
1882 const tcu::TextureFormat dstFormat = result.getFormat();
1885 DE_ASSERT(dstFormat == getFormatAspect(m_params.dst.image.format, aspect));
1888 log << tcu::TestLog::Section("ClampedSourceImage", "Region with clamped edges on source image.");
1890 if (isFloatFormat(dstFormat))
1892 const bool srcIsSRGB = tcu::isSRGB(srcFormat);
1893 const tcu::Vec4 srcMaxDiff = getFormatThreshold(srcFormat) * tcu::Vec4(srcIsSRGB ? 2.0f : 1.0f);
1894 const tcu::Vec4 dstMaxDiff = getFormatThreshold(dstFormat);
1895 const tcu::Vec4 threshold = tcu::max(srcMaxDiff, dstMaxDiff);
1897 isOk = tcu::floatThresholdCompare(log, "Compare", "Result comparsion", clampedExpected, result, threshold, tcu::COMPARE_LOG_RESULT);
1900 log << tcu::TestLog::EndSection;
1902 if (!isOk && isLinear)
1904 log << tcu::TestLog::Section("NonClampedSourceImage", "Region with non-clamped edges on source image.");
1905 isOk = tcu::floatThresholdCompare(log, "Compare", "Result comparsion", unclampedExpected, result, threshold, tcu::COMPARE_LOG_RESULT);
1906 log << tcu::TestLog::EndSection;
1911 tcu::UVec4 threshold;
1912 // Calculate threshold depending on channel width of destination format.
1913 const tcu::IVec4 bitDepth = tcu::getTextureFormatBitDepth(dstFormat);
1914 for (deUint32 i = 0; i < 4; ++i)
1915 threshold[i] = de::max( (0x1 << bitDepth[i]) / 256, 1);
1917 isOk = tcu::intThresholdCompare(log, "Compare", "Result comparsion", clampedExpected, result, threshold, tcu::COMPARE_LOG_RESULT);
1920 log << tcu::TestLog::EndSection;
1922 if (!isOk && isLinear)
1924 log << tcu::TestLog::Section("NonClampedSourceImage", "Region with non-clamped edges on source image.");
1925 isOk = tcu::intThresholdCompare(log, "Compare", "Result comparsion", unclampedExpected, result, threshold, tcu::COMPARE_LOG_RESULT);
1926 log << tcu::TestLog::EndSection;
1932 tcu::TestStatus BlittingImages::checkTestResult (tcu::ConstPixelBufferAccess result)
1934 DE_ASSERT(m_params.filter == VK_FILTER_NEAREST || m_params.filter == VK_FILTER_LINEAR);
1936 if (tcu::isCombinedDepthStencilType(result.getFormat().type))
1938 if (tcu::hasDepthComponent(result.getFormat().order))
1940 const tcu::Sampler::DepthStencilMode mode = tcu::Sampler::MODE_DEPTH;
1941 const tcu::ConstPixelBufferAccess depthResult = tcu::getEffectiveDepthStencilAccess(result, mode);
1942 const tcu::ConstPixelBufferAccess clampedExpected = tcu::getEffectiveDepthStencilAccess(m_expectedTextureLevel->getAccess(), mode);
1943 const tcu::ConstPixelBufferAccess unclampedExpected = m_params.filter == VK_FILTER_LINEAR ? tcu::getEffectiveDepthStencilAccess(m_unclampedExpectedTextureLevel->getAccess(), mode) : tcu::ConstPixelBufferAccess();
1945 if (!checkClampedAndUnclampedResult(depthResult, clampedExpected, unclampedExpected, VK_IMAGE_ASPECT_DEPTH_BIT))
1947 return tcu::TestStatus::fail("CopiesAndBlitting test");
1951 if (tcu::hasStencilComponent(result.getFormat().order))
1953 const tcu::Sampler::DepthStencilMode mode = tcu::Sampler::MODE_STENCIL;
1954 const tcu::ConstPixelBufferAccess stencilResult = tcu::getEffectiveDepthStencilAccess(result, mode);
1955 const tcu::ConstPixelBufferAccess clampedExpected = tcu::getEffectiveDepthStencilAccess(m_expectedTextureLevel->getAccess(), mode);
1956 const tcu::ConstPixelBufferAccess unclampedExpected = m_params.filter == VK_FILTER_LINEAR ? tcu::getEffectiveDepthStencilAccess(m_unclampedExpectedTextureLevel->getAccess(), mode) : tcu::ConstPixelBufferAccess();
1958 if (!checkClampedAndUnclampedResult(stencilResult, clampedExpected, unclampedExpected, VK_IMAGE_ASPECT_STENCIL_BIT))
1960 return tcu::TestStatus::fail("CopiesAndBlitting test");
1966 if (!checkClampedAndUnclampedResult(result, m_expectedTextureLevel->getAccess(), m_params.filter == VK_FILTER_LINEAR ? m_unclampedExpectedTextureLevel->getAccess() : tcu::ConstPixelBufferAccess(), VK_IMAGE_ASPECT_COLOR_BIT))
1968 return tcu::TestStatus::fail("CopiesAndBlitting test");
1972 return tcu::TestStatus::pass("CopiesAndBlitting test");
1975 tcu::Vec4 linearToSRGBIfNeeded (const tcu::TextureFormat& format, const tcu::Vec4& color)
1977 return isSRGB(format) ? linearToSRGB(color) : color;
1980 void scaleFromWholeSrcBuffer (const tcu::PixelBufferAccess& dst, const tcu::ConstPixelBufferAccess& src, const VkOffset3D regionOffset, const VkOffset3D regionExtent, tcu::Sampler::FilterMode filter)
1982 DE_ASSERT(filter == tcu::Sampler::LINEAR);
1983 DE_ASSERT(dst.getDepth() == 1 && src.getDepth() == 1);
1985 tcu::Sampler sampler(tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::CLAMP_TO_EDGE,
1986 filter, filter, 0.0f, false);
1988 float sX = (float)regionExtent.x / (float)dst.getWidth();
1989 float sY = (float)regionExtent.y / (float)dst.getHeight();
1991 for (int y = 0; y < dst.getHeight(); y++)
1992 for (int x = 0; x < dst.getWidth(); x++)
1993 dst.setPixel(linearToSRGBIfNeeded(dst.getFormat(), src.sample2D(sampler, filter, (float)regionOffset.x + ((float)x+0.5f)*sX, (float)regionOffset.y + ((float)y+0.5f)*sY, 0)), x, y);
1996 void blit (const tcu::PixelBufferAccess& dst, const tcu::ConstPixelBufferAccess& src, const tcu::Sampler::FilterMode filter, const MirrorMode mirrorMode)
1998 DE_ASSERT(filter == tcu::Sampler::NEAREST || filter == tcu::Sampler::LINEAR);
2000 tcu::Sampler sampler(tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::CLAMP_TO_EDGE,
2001 filter, filter, 0.0f, false);
2003 const float sX = (float)src.getWidth() / (float)dst.getWidth();
2004 const float sY = (float)src.getHeight() / (float)dst.getHeight();
2005 const float sZ = (float)src.getDepth() / (float)dst.getDepth();
2007 tcu::Mat2 rotMatrix;
2008 rotMatrix(0,0) = (mirrorMode & MIRROR_MODE_X) ? -1.0f : 1.0f;
2009 rotMatrix(0,1) = 0.0f;
2010 rotMatrix(1,0) = 0.0f;
2011 rotMatrix(1,1) = (mirrorMode & MIRROR_MODE_Y) ? -1.0f : 1.0f;
2013 const int xOffset = (mirrorMode & MIRROR_MODE_X) ? dst.getWidth() - 1 : 0;
2014 const int yOffset = (mirrorMode & MIRROR_MODE_Y) ? dst.getHeight() - 1 : 0;
2016 if (dst.getDepth() == 1 && src.getDepth() == 1)
2018 for (int y = 0; y < dst.getHeight(); ++y)
2019 for (int x = 0; x < dst.getWidth(); ++x)
2021 const tcu::Vec2 xy = rotMatrix * tcu::Vec2((float)x,(float)y);
2022 dst.setPixel(linearToSRGBIfNeeded(dst.getFormat(), src.sample2D(sampler, filter, ((float)x+0.5f)*sX, ((float)y+0.5f)*sY, 0)), (int)round(xy[0]) + xOffset, (int)round(xy[1]) + yOffset);
2027 for (int z = 0; z < dst.getDepth(); ++z)
2028 for (int y = 0; y < dst.getHeight(); ++y)
2029 for (int x = 0; x < dst.getWidth(); ++x)
2031 const tcu::Vec2 xy = rotMatrix * tcu::Vec2((float)x,(float)y);
2032 dst.setPixel(linearToSRGBIfNeeded(dst.getFormat(), src.sample3D(sampler, filter, ((float)x+0.5f)*sX, ((float)y+0.5f)*sY, ((float)z+0.5f)*sZ)), (int)round(xy[0]) + xOffset, (int)round(xy[1]) + yOffset, z);
2037 void flipCoordinates (CopyRegion& region, const MirrorMode mirrorMode)
2039 const VkOffset3D dstOffset0 = region.imageBlit.dstOffsets[0];
2040 const VkOffset3D dstOffset1 = region.imageBlit.dstOffsets[1];
2041 const VkOffset3D srcOffset0 = region.imageBlit.srcOffsets[0];
2042 const VkOffset3D srcOffset1 = region.imageBlit.srcOffsets[1];
2044 if (mirrorMode > MIRROR_MODE_NONE && mirrorMode < MIRROR_MODE_LAST)
2047 region.imageBlit.srcOffsets[0].x = std::min(srcOffset0.x, srcOffset1.x);
2048 region.imageBlit.srcOffsets[0].y = std::min(srcOffset0.y, srcOffset1.y);
2050 region.imageBlit.srcOffsets[1].x = std::max(srcOffset0.x, srcOffset1.x);
2051 region.imageBlit.srcOffsets[1].y = std::max(srcOffset0.y, srcOffset1.y);
2054 region.imageBlit.dstOffsets[0].x = std::min(dstOffset0.x, dstOffset1.x);
2055 region.imageBlit.dstOffsets[0].y = std::min(dstOffset0.y, dstOffset1.y);
2057 region.imageBlit.dstOffsets[1].x = std::max(dstOffset0.x, dstOffset1.x);
2058 region.imageBlit.dstOffsets[1].y = std::max(dstOffset0.y, dstOffset1.y);
2062 MirrorMode getMirrorMode(const VkOffset3D x1, const VkOffset3D x2)
2064 if (x1.x >= x2.x && x1.y >= x2.y)
2066 return MIRROR_MODE_XY;
2068 else if (x1.x <= x2.x && x1.y <= x2.y)
2070 return MIRROR_MODE_NONE;
2072 else if (x1.x <= x2.x && x1.y >= x2.y)
2074 return MIRROR_MODE_Y;
2076 else if (x1.x >= x2.x && x1.y <= x2.y)
2078 return MIRROR_MODE_X;
2080 return MIRROR_MODE_LAST;
2083 MirrorMode getMirrorMode(const VkOffset3D s1, const VkOffset3D s2, const VkOffset3D d1, const VkOffset3D d2)
2085 const MirrorMode source = getMirrorMode(s1, s2);
2086 const MirrorMode destination = getMirrorMode(d1, d2);
2088 if (source == destination)
2090 return MIRROR_MODE_NONE;
2092 else if ((source == MIRROR_MODE_XY && destination == MIRROR_MODE_X) || (destination == MIRROR_MODE_XY && source == MIRROR_MODE_X) ||
2093 (source == MIRROR_MODE_Y && destination == MIRROR_MODE_NONE) || (destination == MIRROR_MODE_Y && source == MIRROR_MODE_NONE))
2095 return MIRROR_MODE_Y;
2097 else if ((source == MIRROR_MODE_XY && destination == MIRROR_MODE_Y) || (destination == MIRROR_MODE_XY && source == MIRROR_MODE_Y) ||
2098 (source == MIRROR_MODE_X && destination == MIRROR_MODE_NONE) || (destination == MIRROR_MODE_X && source == MIRROR_MODE_NONE))
2100 return MIRROR_MODE_X;
2102 else if ((source == MIRROR_MODE_XY && destination == MIRROR_MODE_NONE) || (destination == MIRROR_MODE_XY && source == MIRROR_MODE_NONE))
2104 return MIRROR_MODE_XY;
2106 return MIRROR_MODE_LAST;
2109 void BlittingImages::copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region)
2111 const MirrorMode mirrorMode = getMirrorMode(region.imageBlit.srcOffsets[0],
2112 region.imageBlit.srcOffsets[1],
2113 region.imageBlit.dstOffsets[0],
2114 region.imageBlit.dstOffsets[1]);
2116 flipCoordinates(region, mirrorMode);
2118 const VkOffset3D srcOffset = region.imageBlit.srcOffsets[0];
2119 const VkOffset3D srcExtent =
2121 region.imageBlit.srcOffsets[1].x - srcOffset.x,
2122 region.imageBlit.srcOffsets[1].y - srcOffset.y,
2123 region.imageBlit.srcOffsets[1].z - srcOffset.z
2125 const VkOffset3D dstOffset = region.imageBlit.dstOffsets[0];
2126 const VkOffset3D dstExtent =
2128 region.imageBlit.dstOffsets[1].x - dstOffset.x,
2129 region.imageBlit.dstOffsets[1].y - dstOffset.y,
2130 region.imageBlit.dstOffsets[1].z - dstOffset.z
2132 const tcu::Sampler::FilterMode filter = (m_params.filter == VK_FILTER_LINEAR) ? tcu::Sampler::LINEAR : tcu::Sampler::NEAREST;
2134 if (tcu::isCombinedDepthStencilType(src.getFormat().type))
2136 DE_ASSERT(src.getFormat() == dst.getFormat());
2138 if (tcu::hasDepthComponent(src.getFormat().order))
2140 const tcu::ConstPixelBufferAccess srcSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(src, srcOffset.x, srcOffset.y, srcExtent.x, srcExtent.y), tcu::Sampler::MODE_DEPTH);
2141 const tcu::PixelBufferAccess dstSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(dst, dstOffset.x, dstOffset.y, dstExtent.x, dstExtent.y), tcu::Sampler::MODE_DEPTH);
2142 tcu::scale(dstSubRegion, srcSubRegion, filter);
2144 if (filter == tcu::Sampler::LINEAR)
2146 const tcu::ConstPixelBufferAccess depthSrc = getEffectiveDepthStencilAccess(src, tcu::Sampler::MODE_DEPTH);
2147 const tcu::PixelBufferAccess unclampedSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(m_unclampedExpectedTextureLevel->getAccess(), dstOffset.x, dstOffset.y, dstExtent.x, dstExtent.y), tcu::Sampler::MODE_DEPTH);
2148 scaleFromWholeSrcBuffer(unclampedSubRegion, depthSrc, srcOffset, srcExtent, filter);
2153 if (tcu::hasStencilComponent(src.getFormat().order))
2155 const tcu::ConstPixelBufferAccess srcSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(src, srcOffset.x, srcOffset.y, srcExtent.x, srcExtent.y), tcu::Sampler::MODE_STENCIL);
2156 const tcu::PixelBufferAccess dstSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(dst, dstOffset.x, dstOffset.y, dstExtent.x, dstExtent.y), tcu::Sampler::MODE_STENCIL);
2157 blit(dstSubRegion, srcSubRegion, filter, mirrorMode);
2159 if (filter == tcu::Sampler::LINEAR)
2161 const tcu::ConstPixelBufferAccess stencilSrc = getEffectiveDepthStencilAccess(src, tcu::Sampler::MODE_STENCIL);
2162 const tcu::PixelBufferAccess unclampedSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(m_unclampedExpectedTextureLevel->getAccess(), dstOffset.x, dstOffset.y, dstExtent.x, dstExtent.y), tcu::Sampler::MODE_STENCIL);
2163 scaleFromWholeSrcBuffer(unclampedSubRegion, stencilSrc, srcOffset, srcExtent, filter);
2169 const tcu::ConstPixelBufferAccess srcSubRegion = tcu::getSubregion(src, srcOffset.x, srcOffset.y, srcExtent.x, srcExtent.y);
2170 const tcu::PixelBufferAccess dstSubRegion = tcu::getSubregion(dst, dstOffset.x, dstOffset.y, dstExtent.x, dstExtent.y);
2171 blit(dstSubRegion, srcSubRegion, filter, mirrorMode);
2173 if (filter == tcu::Sampler::LINEAR)
2175 const tcu::PixelBufferAccess unclampedSubRegion = tcu::getSubregion(m_unclampedExpectedTextureLevel->getAccess(), dstOffset.x, dstOffset.y, dstExtent.x, dstExtent.y);
2176 scaleFromWholeSrcBuffer(unclampedSubRegion, src, srcOffset, srcExtent, filter);
2181 void BlittingImages::generateExpectedResult (void)
2183 const tcu::ConstPixelBufferAccess src = m_sourceTextureLevel->getAccess();
2184 const tcu::ConstPixelBufferAccess dst = m_destinationTextureLevel->getAccess();
2186 m_expectedTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(dst.getFormat(), dst.getWidth(), dst.getHeight(), dst.getDepth()));
2187 tcu::copy(m_expectedTextureLevel->getAccess(), dst);
2189 if (m_params.filter == VK_FILTER_LINEAR)
2191 m_unclampedExpectedTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(dst.getFormat(), dst.getWidth(), dst.getHeight(), dst.getDepth()));
2192 tcu::copy(m_unclampedExpectedTextureLevel->getAccess(), dst);
2195 for (deUint32 i = 0; i < m_params.regions.size(); i++)
2197 CopyRegion region = m_params.regions[i];
2198 copyRegionToTextureLevel(src, m_expectedTextureLevel->getAccess(), region);
2202 class BlittingTestCase : public vkt::TestCase
2205 BlittingTestCase (tcu::TestContext& testCtx,
2206 const std::string& name,
2207 const std::string& description,
2208 const TestParams params)
2209 : vkt::TestCase (testCtx, name, description)
2213 virtual TestInstance* createInstance (Context& context) const
2215 return new BlittingImages(context, m_params);
2218 TestParams m_params;
2221 // Resolve image to image.
2223 enum ResolveImageToImageOptions{NO_OPTIONAL_OPERATION, COPY_MS_IMAGE_TO_MS_IMAGE, COPY_MS_IMAGE_TO_ARRAY_MS_IMAGE};
2224 class ResolveImageToImage : public CopiesAndBlittingTestInstance
2227 ResolveImageToImage (Context& context,
2229 const ResolveImageToImageOptions options);
2230 virtual tcu::TestStatus iterate (void);
2232 virtual tcu::TestStatus checkTestResult (tcu::ConstPixelBufferAccess result);
2233 void copyMSImageToMSImage (void);
2235 Move<VkImage> m_multisampledImage;
2236 de::MovePtr<Allocation> m_multisampledImageAlloc;
2238 Move<VkImage> m_destination;
2239 de::MovePtr<Allocation> m_destinationImageAlloc;
2241 Move<VkImage> m_multisampledCopyImage;
2242 de::MovePtr<Allocation> m_multisampledCopyImageAlloc;
2244 const ResolveImageToImageOptions m_options;
2246 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src,
2247 tcu::PixelBufferAccess dst,
2251 ResolveImageToImage::ResolveImageToImage (Context& context, TestParams params, const ResolveImageToImageOptions options)
2252 : CopiesAndBlittingTestInstance (context, params)
2253 , m_options (options)
2255 const VkSampleCountFlagBits rasterizationSamples = m_params.samples;
2257 if (!(context.getDeviceProperties().limits.framebufferColorSampleCounts & rasterizationSamples))
2258 throw tcu::NotSupportedError("Unsupported number of rasterization samples");
2260 const DeviceInterface& vk = context.getDeviceInterface();
2261 const VkDevice vkDevice = context.getDevice();
2262 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
2263 Allocator& memAlloc = m_context.getDefaultAllocator();
2265 const VkComponentMapping componentMappingRGBA = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A };
2266 Move<VkRenderPass> renderPass;
2268 Move<VkShaderModule> vertexShaderModule = createShaderModule(vk, vkDevice, m_context.getBinaryCollection().get("vert"), 0);
2269 Move<VkShaderModule> fragmentShaderModule = createShaderModule(vk, vkDevice, m_context.getBinaryCollection().get("frag"), 0);
2270 std::vector<tcu::Vec4> vertices;
2272 Move<VkBuffer> vertexBuffer;
2273 de::MovePtr<Allocation> vertexBufferAlloc;
2275 Move<VkPipelineLayout> pipelineLayout;
2276 Move<VkPipeline> graphicsPipeline;
2278 VkImageFormatProperties properties;
2279 if ((context.getInstanceInterface().getPhysicalDeviceImageFormatProperties (context.getPhysicalDevice(),
2280 m_params.src.image.format,
2281 m_params.src.image.imageType,
2282 VK_IMAGE_TILING_OPTIMAL,
2283 VK_IMAGE_USAGE_TRANSFER_SRC_BIT, 0,
2284 &properties) == VK_ERROR_FORMAT_NOT_SUPPORTED) ||
2285 (context.getInstanceInterface().getPhysicalDeviceImageFormatProperties (context.getPhysicalDevice(),
2286 m_params.dst.image.format,
2287 m_params.dst.image.imageType,
2288 VK_IMAGE_TILING_OPTIMAL,
2289 VK_IMAGE_USAGE_TRANSFER_DST_BIT, 0,
2290 &properties) == VK_ERROR_FORMAT_NOT_SUPPORTED))
2292 TCU_THROW(NotSupportedError, "Format not supported");
2295 // Create color image.
2297 VkImageCreateInfo colorImageParams =
2299 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
2300 DE_NULL, // const void* pNext;
2301 0u, // VkImageCreateFlags flags;
2302 m_params.src.image.imageType, // VkImageType imageType;
2303 m_params.src.image.format, // VkFormat format;
2304 getExtent3D(m_params.src.image), // VkExtent3D extent;
2305 1u, // deUint32 mipLevels;
2306 getArraySize(m_params.src.image), // deUint32 arrayLayers;
2307 rasterizationSamples, // VkSampleCountFlagBits samples;
2308 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
2309 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, // VkImageUsageFlags usage;
2310 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
2311 1u, // deUint32 queueFamilyIndexCount;
2312 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
2313 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
2316 m_multisampledImage = createImage(vk, vkDevice, &colorImageParams);
2318 // Allocate and bind color image memory.
2319 m_multisampledImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_multisampledImage), MemoryRequirement::Any);
2320 VK_CHECK(vk.bindImageMemory(vkDevice, *m_multisampledImage, m_multisampledImageAlloc->getMemory(), m_multisampledImageAlloc->getOffset()));
2324 case COPY_MS_IMAGE_TO_MS_IMAGE:
2326 colorImageParams.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
2327 m_multisampledCopyImage = createImage(vk, vkDevice, &colorImageParams);
2328 // Allocate and bind color image memory.
2329 m_multisampledCopyImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_multisampledCopyImage), MemoryRequirement::Any);
2330 VK_CHECK(vk.bindImageMemory(vkDevice, *m_multisampledCopyImage, m_multisampledCopyImageAlloc->getMemory(), m_multisampledCopyImageAlloc->getOffset()));
2334 case COPY_MS_IMAGE_TO_ARRAY_MS_IMAGE:
2336 colorImageParams.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
2337 colorImageParams.arrayLayers = getArraySize(m_params.dst.image);
2338 m_multisampledCopyImage = createImage(vk, vkDevice, &colorImageParams);
2339 // Allocate and bind color image memory.
2340 m_multisampledCopyImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_multisampledCopyImage), MemoryRequirement::Any);
2341 VK_CHECK(vk.bindImageMemory(vkDevice, *m_multisampledCopyImage, m_multisampledCopyImageAlloc->getMemory(), m_multisampledCopyImageAlloc->getOffset()));
2350 // Create destination image.
2352 const VkImageCreateInfo destinationImageParams =
2354 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
2355 DE_NULL, // const void* pNext;
2356 0u, // VkImageCreateFlags flags;
2357 m_params.dst.image.imageType, // VkImageType imageType;
2358 m_params.dst.image.format, // VkFormat format;
2359 getExtent3D(m_params.dst.image), // VkExtent3D extent;
2360 1u, // deUint32 mipLevels;
2361 getArraySize(m_params.dst.image), // deUint32 arraySize;
2362 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
2363 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
2364 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
2365 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
2366 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
2367 1u, // deUint32 queueFamilyCount;
2368 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
2369 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
2372 m_destination = createImage(vk, vkDevice, &destinationImageParams);
2373 m_destinationImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::Any);
2374 VK_CHECK(vk.bindImageMemory(vkDevice, *m_destination, m_destinationImageAlloc->getMemory(), m_destinationImageAlloc->getOffset()));
2377 // Barriers for copying image to buffer
2378 VkImageMemoryBarrier srcImageBarrier =
2380 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
2381 DE_NULL, // const void* pNext;
2382 0u, // VkAccessFlags srcAccessMask;
2383 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags dstAccessMask;
2384 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
2385 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout newLayout;
2386 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
2387 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
2388 m_multisampledImage.get(), // VkImage image;
2389 { // VkImageSubresourceRange subresourceRange;
2390 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
2391 0u, // deUint32 baseMipLevel;
2392 1u, // deUint32 mipLevels;
2393 0u, // deUint32 baseArraySlice;
2394 getArraySize(m_params.src.image) // deUint32 arraySize;
2398 // Create render pass.
2400 const VkAttachmentDescription attachmentDescriptions[1] =
2403 0u, // VkAttachmentDescriptionFlags flags;
2404 m_params.src.image.format, // VkFormat format;
2405 rasterizationSamples, // VkSampleCountFlagBits samples;
2406 VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp;
2407 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
2408 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp;
2409 VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp;
2410 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout;
2411 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout;
2415 const VkAttachmentReference colorAttachmentReference =
2417 0u, // deUint32 attachment;
2418 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout layout;
2421 const VkSubpassDescription subpassDescription =
2423 0u, // VkSubpassDescriptionFlags flags;
2424 VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint;
2425 0u, // deUint32 inputAttachmentCount;
2426 DE_NULL, // const VkAttachmentReference* pInputAttachments;
2427 1u, // deUint32 colorAttachmentCount;
2428 &colorAttachmentReference, // const VkAttachmentReference* pColorAttachments;
2429 DE_NULL, // const VkAttachmentReference* pResolveAttachments;
2430 DE_NULL, // const VkAttachmentReference* pDepthStencilAttachment;
2431 0u, // deUint32 preserveAttachmentCount;
2432 DE_NULL // const VkAttachmentReference* pPreserveAttachments;
2435 const VkRenderPassCreateInfo renderPassParams =
2437 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType;
2438 DE_NULL, // const void* pNext;
2439 0u, // VkRenderPassCreateFlags flags;
2440 1u, // deUint32 attachmentCount;
2441 attachmentDescriptions, // const VkAttachmentDescription* pAttachments;
2442 1u, // deUint32 subpassCount;
2443 &subpassDescription, // const VkSubpassDescription* pSubpasses;
2444 0u, // deUint32 dependencyCount;
2445 DE_NULL // const VkSubpassDependency* pDependencies;
2448 renderPass = createRenderPass(vk, vkDevice, &renderPassParams);
2451 // Create pipeline layout
2453 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
2455 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // VkStructureType sType;
2456 DE_NULL, // const void* pNext;
2457 0u, // VkPipelineLayoutCreateFlags flags;
2458 0u, // deUint32 setLayoutCount;
2459 DE_NULL, // const VkDescriptorSetLayout* pSetLayouts;
2460 0u, // deUint32 pushConstantRangeCount;
2461 DE_NULL // const VkPushConstantRange* pPushConstantRanges;
2464 pipelineLayout = createPipelineLayout(vk, vkDevice, &pipelineLayoutParams);
2468 const tcu::Vec4 a (-1.0, -1.0, 0.0, 1.0);
2469 const tcu::Vec4 b (1.0, -1.0, 0.0, 1.0);
2470 const tcu::Vec4 c (1.0, 1.0, 0.0, 1.0);
2472 vertices.push_back(a);
2473 vertices.push_back(c);
2474 vertices.push_back(b);
2477 // Create vertex buffer.
2479 const VkDeviceSize vertexDataSize = vertices.size() * sizeof(tcu::Vec4);
2480 const VkBufferCreateInfo vertexBufferParams =
2482 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
2483 DE_NULL, // const void* pNext;
2484 0u, // VkBufferCreateFlags flags;
2485 vertexDataSize, // VkDeviceSize size;
2486 VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, // VkBufferUsageFlags usage;
2487 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
2488 1u, // deUint32 queueFamilyIndexCount;
2489 &queueFamilyIndex // const deUint32* pQueueFamilyIndices;
2492 vertexBuffer = createBuffer(vk, vkDevice, &vertexBufferParams);
2493 vertexBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *vertexBuffer), MemoryRequirement::HostVisible);
2495 VK_CHECK(vk.bindBufferMemory(vkDevice, *vertexBuffer, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset()));
2497 // Load vertices into vertex buffer.
2498 deMemcpy(vertexBufferAlloc->getHostPtr(), vertices.data(), (size_t)vertexDataSize);
2499 flushMappedMemoryRange(vk, vkDevice, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset(), vertexDataSize);
2503 Move<VkFramebuffer> framebuffer;
2504 Move<VkImageView> sourceAttachmentView;
2505 const VkExtent3D extent3D = getExtent3D(m_params.src.image);
2507 // Create color attachment view.
2509 const VkImageViewCreateInfo colorAttachmentViewParams =
2511 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // VkStructureType sType;
2512 DE_NULL, // const void* pNext;
2513 0u, // VkImageViewCreateFlags flags;
2514 *m_multisampledImage, // VkImage image;
2515 VK_IMAGE_VIEW_TYPE_2D, // VkImageViewType viewType;
2516 m_params.src.image.format, // VkFormat format;
2517 componentMappingRGBA, // VkComponentMapping components;
2518 { VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u } // VkImageSubresourceRange subresourceRange;
2520 sourceAttachmentView = createImageView(vk, vkDevice, &colorAttachmentViewParams);
2523 // Create framebuffer
2525 const VkImageView attachments[1] =
2527 *sourceAttachmentView,
2530 const VkFramebufferCreateInfo framebufferParams =
2532 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType;
2533 DE_NULL, // const void* pNext;
2534 0u, // VkFramebufferCreateFlags flags;
2535 *renderPass, // VkRenderPass renderPass;
2536 1u, // deUint32 attachmentCount;
2537 attachments, // const VkImageView* pAttachments;
2538 extent3D.width, // deUint32 width;
2539 extent3D.height, // deUint32 height;
2540 1u // deUint32 layers;
2543 framebuffer = createFramebuffer(vk, vkDevice, &framebufferParams);
2548 const VkPipelineShaderStageCreateInfo shaderStageParams[2] =
2551 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
2552 DE_NULL, // const void* pNext;
2553 0u, // VkPipelineShaderStageCreateFlags flags;
2554 VK_SHADER_STAGE_VERTEX_BIT, // VkShaderStageFlagBits stage;
2555 *vertexShaderModule, // VkShaderModule module;
2556 "main", // const char* pName;
2557 DE_NULL // const VkSpecializationInfo* pSpecializationInfo;
2560 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
2561 DE_NULL, // const void* pNext;
2562 0u, // VkPipelineShaderStageCreateFlags flags;
2563 VK_SHADER_STAGE_FRAGMENT_BIT, // VkShaderStageFlagBits stage;
2564 *fragmentShaderModule, // VkShaderModule module;
2565 "main", // const char* pName;
2566 DE_NULL // const VkSpecializationInfo* pSpecializationInfo;
2570 const VkVertexInputBindingDescription vertexInputBindingDescription =
2572 0u, // deUint32 binding;
2573 sizeof(tcu::Vec4), // deUint32 stride;
2574 VK_VERTEX_INPUT_RATE_VERTEX // VkVertexInputRate inputRate;
2577 const VkVertexInputAttributeDescription vertexInputAttributeDescriptions[1] =
2580 0u, // deUint32 location;
2581 0u, // deUint32 binding;
2582 VK_FORMAT_R32G32B32A32_SFLOAT, // VkFormat format;
2583 0u // deUint32 offset;
2587 const VkPipelineVertexInputStateCreateInfo vertexInputStateParams =
2589 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // VkStructureType sType;
2590 DE_NULL, // const void* pNext;
2591 0u, // VkPipelineVertexInputStateCreateFlags flags;
2592 1u, // deUint32 vertexBindingDescriptionCount;
2593 &vertexInputBindingDescription, // const VkVertexInputBindingDescription* pVertexBindingDescriptions;
2594 1u, // deUint32 vertexAttributeDescriptionCount;
2595 vertexInputAttributeDescriptions // const VkVertexInputAttributeDescription* pVertexAttributeDescriptions;
2598 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateParams =
2600 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // VkStructureType sType;
2601 DE_NULL, // const void* pNext;
2602 0u, // VkPipelineInputAssemblyStateCreateFlags flags;
2603 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, // VkPrimitiveTopology topology;
2604 false // VkBool32 primitiveRestartEnable;
2607 const VkViewport viewport =
2611 (float)extent3D.width, // float width;
2612 (float)extent3D.height, // float height;
2613 0.0f, // float minDepth;
2614 1.0f // float maxDepth;
2617 const VkRect2D scissor =
2619 { 0, 0 }, // VkOffset2D offset;
2620 { extent3D.width, extent3D.height } // VkExtent2D extent;
2623 const VkPipelineViewportStateCreateInfo viewportStateParams =
2625 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // VkStructureType sType;
2626 DE_NULL, // const void* pNext;
2627 0u, // VkPipelineViewportStateCreateFlags flags;
2628 1u, // deUint32 viewportCount;
2629 &viewport, // const VkViewport* pViewports;
2630 1u, // deUint32 scissorCount;
2631 &scissor // const VkRect2D* pScissors;
2634 const VkPipelineRasterizationStateCreateInfo rasterStateParams =
2636 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // VkStructureType sType;
2637 DE_NULL, // const void* pNext;
2638 0u, // VkPipelineRasterizationStateCreateFlags flags;
2639 false, // VkBool32 depthClampEnable;
2640 false, // VkBool32 rasterizerDiscardEnable;
2641 VK_POLYGON_MODE_FILL, // VkPolygonMode polygonMode;
2642 VK_CULL_MODE_NONE, // VkCullModeFlags cullMode;
2643 VK_FRONT_FACE_COUNTER_CLOCKWISE, // VkFrontFace frontFace;
2644 VK_FALSE, // VkBool32 depthBiasEnable;
2645 0.0f, // float depthBiasConstantFactor;
2646 0.0f, // float depthBiasClamp;
2647 0.0f, // float depthBiasSlopeFactor;
2648 1.0f // float lineWidth;
2651 const VkPipelineMultisampleStateCreateInfo multisampleStateParams =
2653 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // VkStructureType sType;
2654 DE_NULL, // const void* pNext;
2655 0u, // VkPipelineMultisampleStateCreateFlags flags;
2656 rasterizationSamples, // VkSampleCountFlagBits rasterizationSamples;
2657 VK_FALSE, // VkBool32 sampleShadingEnable;
2658 0.0f, // float minSampleShading;
2659 DE_NULL, // const VkSampleMask* pSampleMask;
2660 VK_FALSE, // VkBool32 alphaToCoverageEnable;
2661 VK_FALSE // VkBool32 alphaToOneEnable;
2664 const VkPipelineColorBlendAttachmentState colorBlendAttachmentState =
2666 false, // VkBool32 blendEnable;
2667 VK_BLEND_FACTOR_ONE, // VkBlend srcBlendColor;
2668 VK_BLEND_FACTOR_ZERO, // VkBlend destBlendColor;
2669 VK_BLEND_OP_ADD, // VkBlendOp blendOpColor;
2670 VK_BLEND_FACTOR_ONE, // VkBlend srcBlendAlpha;
2671 VK_BLEND_FACTOR_ZERO, // VkBlend destBlendAlpha;
2672 VK_BLEND_OP_ADD, // VkBlendOp blendOpAlpha;
2673 (VK_COLOR_COMPONENT_R_BIT |
2674 VK_COLOR_COMPONENT_G_BIT |
2675 VK_COLOR_COMPONENT_B_BIT |
2676 VK_COLOR_COMPONENT_A_BIT) // VkChannelFlags channelWriteMask;
2679 const VkPipelineColorBlendStateCreateInfo colorBlendStateParams =
2681 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // VkStructureType sType;
2682 DE_NULL, // const void* pNext;
2683 0u, // VkPipelineColorBlendStateCreateFlags flags;
2684 false, // VkBool32 logicOpEnable;
2685 VK_LOGIC_OP_COPY, // VkLogicOp logicOp;
2686 1u, // deUint32 attachmentCount;
2687 &colorBlendAttachmentState, // const VkPipelineColorBlendAttachmentState* pAttachments;
2688 { 0.0f, 0.0f, 0.0f, 0.0f } // float blendConstants[4];
2691 const VkGraphicsPipelineCreateInfo graphicsPipelineParams =
2693 VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // VkStructureType sType;
2694 DE_NULL, // const void* pNext;
2695 0u, // VkPipelineCreateFlags flags;
2696 2u, // deUint32 stageCount;
2697 shaderStageParams, // const VkPipelineShaderStageCreateInfo* pStages;
2698 &vertexInputStateParams, // const VkPipelineVertexInputStateCreateInfo* pVertexInputState;
2699 &inputAssemblyStateParams, // const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState;
2700 DE_NULL, // const VkPipelineTessellationStateCreateInfo* pTessellationState;
2701 &viewportStateParams, // const VkPipelineViewportStateCreateInfo* pViewportState;
2702 &rasterStateParams, // const VkPipelineRasterizationStateCreateInfo* pRasterizationState;
2703 &multisampleStateParams, // const VkPipelineMultisampleStateCreateInfo* pMultisampleState;
2704 DE_NULL, // const VkPipelineDepthStencilStateCreateInfo* pDepthStencilState;
2705 &colorBlendStateParams, // const VkPipelineColorBlendStateCreateInfo* pColorBlendState;
2706 DE_NULL, // const VkPipelineDynamicStateCreateInfo* pDynamicState;
2707 *pipelineLayout, // VkPipelineLayout layout;
2708 *renderPass, // VkRenderPass renderPass;
2709 0u, // deUint32 subpass;
2710 0u, // VkPipeline basePipelineHandle;
2711 0u // deInt32 basePipelineIndex;
2714 graphicsPipeline = createGraphicsPipeline(vk, vkDevice, DE_NULL, &graphicsPipelineParams);
2717 // Create command buffer
2719 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
2721 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
2722 DE_NULL, // const void* pNext;
2723 0u, // VkCommandBufferUsageFlags flags;
2724 (const VkCommandBufferInheritanceInfo*)DE_NULL,
2727 const VkClearValue clearValues[1] =
2729 makeClearValueColorF32(0.0f, 0.0f, 1.0f, 1.0f),
2732 const VkRenderPassBeginInfo renderPassBeginInfo =
2734 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // VkStructureType sType;
2735 DE_NULL, // const void* pNext;
2736 *renderPass, // VkRenderPass renderPass;
2737 *framebuffer, // VkFramebuffer framebuffer;
2740 { extent3D.width, extent3D.height }
2741 }, // VkRect2D renderArea;
2742 1u, // deUint32 clearValueCount;
2743 clearValues // const VkClearValue* pClearValues;
2746 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
2747 vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 0, (const VkBufferMemoryBarrier*)DE_NULL, 1, &srcImageBarrier);
2748 vk.cmdBeginRenderPass(*m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
2749 const VkDeviceSize vertexBufferOffset = 0u;
2751 vk.cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *graphicsPipeline);
2752 vk.cmdBindVertexBuffers(*m_cmdBuffer, 0, 1, &vertexBuffer.get(), &vertexBufferOffset);
2753 vk.cmdDraw(*m_cmdBuffer, (deUint32)vertices.size(), 1, 0, 0);
2755 vk.cmdEndRenderPass(*m_cmdBuffer);
2756 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
2761 const VkQueue queue = m_context.getUniversalQueue();
2762 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
2767 tcu::TestStatus ResolveImageToImage::iterate (void)
2769 const tcu::TextureFormat srcTcuFormat = mapVkFormat(m_params.src.image.format);
2770 const tcu::TextureFormat dstTcuFormat = mapVkFormat(m_params.dst.image.format);
2772 // upload the destination image
2773 m_destinationTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(dstTcuFormat,
2774 (int)m_params.dst.image.extent.width,
2775 (int)m_params.dst.image.extent.height,
2776 (int)m_params.dst.image.extent.depth));
2777 generateBuffer(m_destinationTextureLevel->getAccess(), m_params.dst.image.extent.width, m_params.dst.image.extent.height, m_params.dst.image.extent.depth);
2778 uploadImage(m_destinationTextureLevel->getAccess(), m_destination.get(), m_params.dst.image);
2780 m_sourceTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(srcTcuFormat,
2781 (int)m_params.src.image.extent.width,
2782 (int)m_params.src.image.extent.height,
2783 (int)m_params.dst.image.extent.depth));
2785 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);
2786 generateExpectedResult();
2790 case COPY_MS_IMAGE_TO_MS_IMAGE:
2791 case COPY_MS_IMAGE_TO_ARRAY_MS_IMAGE:
2792 copyMSImageToMSImage();
2798 const DeviceInterface& vk = m_context.getDeviceInterface();
2799 const VkDevice vkDevice = m_context.getDevice();
2800 const VkQueue queue = m_context.getUniversalQueue();
2802 std::vector<VkImageResolve> imageResolves;
2803 for (deUint32 i = 0; i < m_params.regions.size(); i++)
2804 imageResolves.push_back(m_params.regions[i].imageResolve);
2806 const VkImageMemoryBarrier imageBarriers[] =
2810 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
2811 DE_NULL, // const void* pNext;
2812 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags srcAccessMask;
2813 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
2814 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout;
2815 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // VkImageLayout newLayout;
2816 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
2817 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
2818 m_multisampledImage.get(), // VkImage image;
2819 { // VkImageSubresourceRange subresourceRange;
2820 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
2821 0u, // deUint32 baseMipLevel;
2822 1u, // deUint32 mipLevels;
2823 0u, // deUint32 baseArraySlice;
2824 getArraySize(m_params.dst.image) // deUint32 arraySize;
2827 // destination image
2829 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
2830 DE_NULL, // const void* pNext;
2831 0u, // VkAccessFlags srcAccessMask;
2832 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
2833 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
2834 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
2835 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
2836 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
2837 m_destination.get(), // VkImage image;
2838 { // VkImageSubresourceRange subresourceRange;
2839 getAspectFlags(dstTcuFormat), // VkImageAspectFlags aspectMask;
2840 0u, // deUint32 baseMipLevel;
2841 1u, // deUint32 mipLevels;
2842 0u, // deUint32 baseArraySlice;
2843 getArraySize(m_params.dst.image) // deUint32 arraySize;
2848 const VkImageMemoryBarrier postImageBarrier =
2850 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
2851 DE_NULL, // const void* pNext;
2852 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
2853 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
2854 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
2855 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
2856 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
2857 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
2858 m_destination.get(), // VkImage image;
2859 { // VkImageSubresourceRange subresourceRange;
2860 getAspectFlags(dstTcuFormat), // VkImageAspectFlags aspectMask;
2861 0u, // deUint32 baseMipLevel;
2862 1u, // deUint32 mipLevels;
2863 0u, // deUint32 baseArraySlice;
2864 getArraySize(m_params.dst.image)// deUint32 arraySize;
2868 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
2870 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
2871 DE_NULL, // const void* pNext;
2872 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
2873 (const VkCommandBufferInheritanceInfo*)DE_NULL,
2876 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
2877 vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 0, (const VkBufferMemoryBarrier*)DE_NULL, DE_LENGTH_OF_ARRAY(imageBarriers), imageBarriers);
2878 vk.cmdResolveImage(*m_cmdBuffer, m_multisampledImage.get(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, m_destination.get(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (deUint32)m_params.regions.size(), imageResolves.data());
2879 vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_HOST_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 0, (const VkBufferMemoryBarrier*)DE_NULL, 1, &postImageBarrier);
2880 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
2882 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
2884 // check the result of resolving image
2886 de::MovePtr<tcu::TextureLevel> resultTextureLevel = readImage(*m_destination, m_params.dst.image);
2888 if (QP_TEST_RESULT_PASS != checkTestResult(resultTextureLevel->getAccess()).getCode())
2889 return tcu::TestStatus::fail("CopiesAndBlitting test");
2891 return tcu::TestStatus::pass("CopiesAndBlitting test");
2894 tcu::TestStatus ResolveImageToImage::checkTestResult (tcu::ConstPixelBufferAccess result)
2896 const tcu::ConstPixelBufferAccess expected = m_expectedTextureLevel->getAccess();
2897 const float fuzzyThreshold = 0.01f;
2899 for (int arrayLayerNdx = 0; arrayLayerNdx < (int)getArraySize(m_params.dst.image); ++arrayLayerNdx)
2901 const tcu::ConstPixelBufferAccess expectedSub = getSubregion (expected, 0, 0, arrayLayerNdx, expected.getWidth(), expected.getHeight(), 1u);
2902 const tcu::ConstPixelBufferAccess resultSub = getSubregion (result, 0, 0, arrayLayerNdx, result.getWidth(), result.getHeight(), 1u);
2903 if (!tcu::fuzzyCompare(m_context.getTestContext().getLog(), "Compare", "Result comparsion", expectedSub, resultSub, fuzzyThreshold, tcu::COMPARE_LOG_RESULT))
2904 return tcu::TestStatus::fail("CopiesAndBlitting test");
2907 return tcu::TestStatus::pass("CopiesAndBlitting test");
2910 void ResolveImageToImage::copyRegionToTextureLevel(tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region)
2912 VkOffset3D srcOffset = region.imageResolve.srcOffset;
2913 srcOffset.z = region.imageResolve.srcSubresource.baseArrayLayer;
2914 VkOffset3D dstOffset = region.imageResolve.dstOffset;
2915 dstOffset.z = region.imageResolve.dstSubresource.baseArrayLayer;
2916 VkExtent3D extent = region.imageResolve.extent;
2918 const tcu::ConstPixelBufferAccess srcSubRegion = getSubregion (src, srcOffset.x, srcOffset.y, srcOffset.z, extent.width, extent.height, extent.depth);
2919 // CopyImage acts like a memcpy. Replace the destination format with the srcformat to use a memcpy.
2920 const tcu::PixelBufferAccess dstWithSrcFormat (srcSubRegion.getFormat(), dst.getSize(), dst.getDataPtr());
2921 const tcu::PixelBufferAccess dstSubRegion = getSubregion (dstWithSrcFormat, dstOffset.x, dstOffset.y, dstOffset.z, extent.width, extent.height, extent.depth);
2923 tcu::copy(dstSubRegion, srcSubRegion);
2926 void ResolveImageToImage::copyMSImageToMSImage (void)
2928 const DeviceInterface& vk = m_context.getDeviceInterface();
2929 const VkDevice vkDevice = m_context.getDevice();
2930 const VkQueue queue = m_context.getUniversalQueue();
2931 const tcu::TextureFormat srcTcuFormat = mapVkFormat(m_params.src.image.format);
2932 std::vector<VkImageCopy> imageCopies;
2934 for (deUint32 layerNdx = 0; layerNdx < getArraySize(m_params.dst.image); ++layerNdx)
2936 const VkImageSubresourceLayers sourceSubresourceLayers =
2938 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
2939 0u, // uint32_t mipLevel;
2940 0u, // uint32_t baseArrayLayer;
2941 1u // uint32_t layerCount;
2944 const VkImageSubresourceLayers destinationSubresourceLayers =
2946 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;//getAspectFlags(dstTcuFormat)
2947 0u, // uint32_t mipLevel;
2948 layerNdx, // uint32_t baseArrayLayer;
2949 1u // uint32_t layerCount;
2952 const VkImageCopy imageCopy =
2954 sourceSubresourceLayers, // VkImageSubresourceLayers srcSubresource;
2955 {0, 0, 0}, // VkOffset3D srcOffset;
2956 destinationSubresourceLayers, // VkImageSubresourceLayers dstSubresource;
2957 {0, 0, 0}, // VkOffset3D dstOffset;
2958 getExtent3D(m_params.src.image), // VkExtent3D extent;
2960 imageCopies.push_back(imageCopy);
2963 const VkImageMemoryBarrier imageBarriers[] =
2967 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
2968 DE_NULL, // const void* pNext;
2969 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags srcAccessMask;
2970 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
2971 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout;
2972 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // VkImageLayout newLayout;
2973 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
2974 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
2975 m_multisampledImage.get(), // VkImage image;
2976 { // VkImageSubresourceRange subresourceRange;
2977 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
2978 0u, // deUint32 baseMipLevel;
2979 1u, // deUint32 mipLevels;
2980 0u, // deUint32 baseArraySlice;
2981 getArraySize(m_params.src.image) // deUint32 arraySize;
2984 // destination image
2986 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
2987 DE_NULL, // const void* pNext;
2988 0, // VkAccessFlags srcAccessMask;
2989 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
2990 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
2991 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
2992 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
2993 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
2994 m_multisampledCopyImage.get(), // VkImage image;
2995 { // VkImageSubresourceRange subresourceRange;
2996 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
2997 0u, // deUint32 baseMipLevel;
2998 1u, // deUint32 mipLevels;
2999 0u, // deUint32 baseArraySlice;
3000 getArraySize(m_params.dst.image) // deUint32 arraySize;
3005 const VkImageMemoryBarrier postImageBarriers =
3008 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
3009 DE_NULL, // const void* pNext;
3010 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
3011 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags dstAccessMask;
3012 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
3013 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout newLayout;
3014 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
3015 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
3016 m_multisampledCopyImage.get(), // VkImage image;
3017 { // VkImageSubresourceRange subresourceRange;
3018 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
3019 0u, // deUint32 baseMipLevel;
3020 1u, // deUint32 mipLevels;
3021 0u, // deUint32 baseArraySlice;
3022 getArraySize(m_params.dst.image) // deUint32 arraySize;
3026 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
3028 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
3029 DE_NULL, // const void* pNext;
3030 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
3031 (const VkCommandBufferInheritanceInfo*)DE_NULL,
3034 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
3035 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, DE_LENGTH_OF_ARRAY(imageBarriers), imageBarriers);
3036 vk.cmdCopyImage(*m_cmdBuffer, m_multisampledImage.get(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, m_multisampledCopyImage.get(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (deUint32)imageCopies.size(), imageCopies.data());
3037 vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 0, (const VkBufferMemoryBarrier*)DE_NULL, 1u, &postImageBarriers);
3038 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
3040 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
3042 m_multisampledImage = m_multisampledCopyImage;
3045 class ResolveImageToImageTestCase : public vkt::TestCase
3048 ResolveImageToImageTestCase (tcu::TestContext& testCtx,
3049 const std::string& name,
3050 const std::string& description,
3051 const TestParams params,
3052 const ResolveImageToImageOptions options = NO_OPTIONAL_OPERATION)
3053 : vkt::TestCase (testCtx, name, description)
3055 , m_options (options)
3057 virtual void initPrograms (SourceCollections& programCollection) const;
3059 virtual TestInstance* createInstance (Context& context) const
3061 return new ResolveImageToImage(context, m_params, m_options);
3064 TestParams m_params;
3065 const ResolveImageToImageOptions m_options;
3068 void ResolveImageToImageTestCase::initPrograms (SourceCollections& programCollection) const
3070 programCollection.glslSources.add("vert") << glu::VertexSource(
3072 "layout (location = 0) in highp vec4 a_position;\n"
3075 " gl_Position = a_position;\n"
3078 programCollection.glslSources.add("frag") << glu::FragmentSource(
3080 "layout (location = 0) out highp vec4 o_color;\n"
3083 " o_color = vec4(0.0, 1.0, 0.0, 1.0);\n"
3087 std::string getSampleCountCaseName (VkSampleCountFlagBits sampleFlag)
3089 return de::toLower(de::toString(getSampleCountFlagsStr(sampleFlag)).substr(16));
3092 std::string getFormatCaseName (VkFormat format)
3094 return de::toLower(de::toString(getFormatStr(format)).substr(10));
3097 void addCopyImageTestsAllFormats (tcu::TestCaseGroup* testCaseGroup,
3098 tcu::TestContext& testCtx,
3101 const VkFormat compatibleFormats8Bit[] =
3103 VK_FORMAT_R4G4_UNORM_PACK8,
3106 VK_FORMAT_R8_USCALED,
3107 VK_FORMAT_R8_SSCALED,
3114 const VkFormat compatibleFormats16Bit[] =
3116 VK_FORMAT_R4G4B4A4_UNORM_PACK16,
3117 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
3118 VK_FORMAT_R5G6B5_UNORM_PACK16,
3119 VK_FORMAT_B5G6R5_UNORM_PACK16,
3120 VK_FORMAT_R5G5B5A1_UNORM_PACK16,
3121 VK_FORMAT_B5G5R5A1_UNORM_PACK16,
3122 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
3123 VK_FORMAT_R8G8_UNORM,
3124 VK_FORMAT_R8G8_SNORM,
3125 VK_FORMAT_R8G8_USCALED,
3126 VK_FORMAT_R8G8_SSCALED,
3127 VK_FORMAT_R8G8_UINT,
3128 VK_FORMAT_R8G8_SINT,
3129 VK_FORMAT_R8G8_SRGB,
3130 VK_FORMAT_R16_UNORM,
3131 VK_FORMAT_R16_SNORM,
3132 VK_FORMAT_R16_USCALED,
3133 VK_FORMAT_R16_SSCALED,
3136 VK_FORMAT_R16_SFLOAT,
3140 const VkFormat compatibleFormats24Bit[] =
3142 VK_FORMAT_R8G8B8_UNORM,
3143 VK_FORMAT_R8G8B8_SNORM,
3144 VK_FORMAT_R8G8B8_USCALED,
3145 VK_FORMAT_R8G8B8_SSCALED,
3146 VK_FORMAT_R8G8B8_UINT,
3147 VK_FORMAT_R8G8B8_SINT,
3148 VK_FORMAT_R8G8B8_SRGB,
3149 VK_FORMAT_B8G8R8_UNORM,
3150 VK_FORMAT_B8G8R8_SNORM,
3151 VK_FORMAT_B8G8R8_USCALED,
3152 VK_FORMAT_B8G8R8_SSCALED,
3153 VK_FORMAT_B8G8R8_UINT,
3154 VK_FORMAT_B8G8R8_SINT,
3155 VK_FORMAT_B8G8R8_SRGB,
3159 const VkFormat compatibleFormats32Bit[] =
3161 VK_FORMAT_R8G8B8A8_UNORM,
3162 VK_FORMAT_R8G8B8A8_SNORM,
3163 VK_FORMAT_R8G8B8A8_USCALED,
3164 VK_FORMAT_R8G8B8A8_SSCALED,
3165 VK_FORMAT_R8G8B8A8_UINT,
3166 VK_FORMAT_R8G8B8A8_SINT,
3167 VK_FORMAT_R8G8B8A8_SRGB,
3168 VK_FORMAT_B8G8R8A8_UNORM,
3169 VK_FORMAT_B8G8R8A8_SNORM,
3170 VK_FORMAT_B8G8R8A8_USCALED,
3171 VK_FORMAT_B8G8R8A8_SSCALED,
3172 VK_FORMAT_B8G8R8A8_UINT,
3173 VK_FORMAT_B8G8R8A8_SINT,
3174 VK_FORMAT_B8G8R8A8_SRGB,
3175 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
3176 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
3177 VK_FORMAT_A8B8G8R8_USCALED_PACK32,
3178 VK_FORMAT_A8B8G8R8_SSCALED_PACK32,
3179 VK_FORMAT_A8B8G8R8_UINT_PACK32,
3180 VK_FORMAT_A8B8G8R8_SINT_PACK32,
3181 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
3182 VK_FORMAT_A2R10G10B10_UNORM_PACK32,
3183 VK_FORMAT_A2R10G10B10_SNORM_PACK32,
3184 VK_FORMAT_A2R10G10B10_USCALED_PACK32,
3185 VK_FORMAT_A2R10G10B10_SSCALED_PACK32,
3186 VK_FORMAT_A2R10G10B10_UINT_PACK32,
3187 VK_FORMAT_A2R10G10B10_SINT_PACK32,
3188 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
3189 VK_FORMAT_A2B10G10R10_SNORM_PACK32,
3190 VK_FORMAT_A2B10G10R10_USCALED_PACK32,
3191 VK_FORMAT_A2B10G10R10_SSCALED_PACK32,
3192 VK_FORMAT_A2B10G10R10_UINT_PACK32,
3193 VK_FORMAT_A2B10G10R10_SINT_PACK32,
3194 VK_FORMAT_R16G16_UNORM,
3195 VK_FORMAT_R16G16_SNORM,
3196 VK_FORMAT_R16G16_USCALED,
3197 VK_FORMAT_R16G16_SSCALED,
3198 VK_FORMAT_R16G16_UINT,
3199 VK_FORMAT_R16G16_SINT,
3200 VK_FORMAT_R16G16_SFLOAT,
3203 VK_FORMAT_R32_SFLOAT,
3207 const VkFormat compatibleFormats48Bit[] =
3209 VK_FORMAT_R16G16B16_UNORM,
3210 VK_FORMAT_R16G16B16_SNORM,
3211 VK_FORMAT_R16G16B16_USCALED,
3212 VK_FORMAT_R16G16B16_SSCALED,
3213 VK_FORMAT_R16G16B16_UINT,
3214 VK_FORMAT_R16G16B16_SINT,
3215 VK_FORMAT_R16G16B16_SFLOAT,
3219 const VkFormat compatibleFormats64Bit[] =
3221 VK_FORMAT_R16G16B16A16_UNORM,
3222 VK_FORMAT_R16G16B16A16_SNORM,
3223 VK_FORMAT_R16G16B16A16_USCALED,
3224 VK_FORMAT_R16G16B16A16_SSCALED,
3225 VK_FORMAT_R16G16B16A16_UINT,
3226 VK_FORMAT_R16G16B16A16_SINT,
3227 VK_FORMAT_R16G16B16A16_SFLOAT,
3228 VK_FORMAT_R32G32_UINT,
3229 VK_FORMAT_R32G32_SINT,
3230 VK_FORMAT_R32G32_SFLOAT,
3233 VK_FORMAT_R64_SFLOAT,
3237 const VkFormat compatibleFormats96Bit[] =
3239 VK_FORMAT_R32G32B32_UINT,
3240 VK_FORMAT_R32G32B32_SINT,
3241 VK_FORMAT_R32G32B32_SFLOAT,
3245 const VkFormat compatibleFormats128Bit[] =
3247 VK_FORMAT_R32G32B32A32_UINT,
3248 VK_FORMAT_R32G32B32A32_SINT,
3249 VK_FORMAT_R32G32B32A32_SFLOAT,
3250 VK_FORMAT_R64G64_UINT,
3251 VK_FORMAT_R64G64_SINT,
3252 VK_FORMAT_R64G64_SFLOAT,
3256 const VkFormat compatibleFormats192Bit[] =
3258 VK_FORMAT_R64G64B64_UINT,
3259 VK_FORMAT_R64G64B64_SINT,
3260 VK_FORMAT_R64G64B64_SFLOAT,
3264 const VkFormat compatibleFormats256Bit[] =
3266 VK_FORMAT_R64G64B64A64_UINT,
3267 VK_FORMAT_R64G64B64A64_SINT,
3268 VK_FORMAT_R64G64B64A64_SFLOAT,
3273 const VkFormat* colorImageFormatsToTest[] =
3275 compatibleFormats8Bit,
3276 compatibleFormats16Bit,
3277 compatibleFormats24Bit,
3278 compatibleFormats32Bit,
3279 compatibleFormats48Bit,
3280 compatibleFormats64Bit,
3281 compatibleFormats96Bit,
3282 compatibleFormats128Bit,
3283 compatibleFormats192Bit,
3284 compatibleFormats256Bit,
3286 const size_t numOfColorImageFormatsToTest = DE_LENGTH_OF_ARRAY(colorImageFormatsToTest);
3288 for (size_t compatibleFormatsIndex = 0; compatibleFormatsIndex < numOfColorImageFormatsToTest; ++compatibleFormatsIndex)
3290 const VkFormat* compatibleFormats = colorImageFormatsToTest[compatibleFormatsIndex];
3291 for (size_t srcFormatIndex = 0; compatibleFormats[srcFormatIndex] != VK_FORMAT_UNDEFINED; ++srcFormatIndex)
3293 params.src.image.format = compatibleFormats[srcFormatIndex];
3294 for (size_t dstFormatIndex = 0; compatibleFormats[dstFormatIndex] != VK_FORMAT_UNDEFINED; ++dstFormatIndex)
3296 params.dst.image.format = compatibleFormats[dstFormatIndex];
3298 if (!isSupportedByFramework(params.src.image.format) || !isSupportedByFramework(params.dst.image.format))
3301 std::ostringstream testName;
3302 testName << getFormatCaseName(params.src.image.format) << "_" << getFormatCaseName(params.dst.image.format);
3303 std::ostringstream description;
3304 description << "Copy from src " << params.src.image.format << " to dst " << params.dst.image.format;
3306 testCaseGroup->addChild(new CopyImageToImageTestCase(testCtx, testName.str(), description.str(), params));
3312 void addBlittingTestsAllFormats (tcu::TestCaseGroup* testCaseGroup,
3313 tcu::TestContext& testCtx,
3316 // Test Image formats.
3317 const VkFormat compatibleFormatsUInts[] =
3320 VK_FORMAT_R8G8_UINT,
3321 VK_FORMAT_R8G8B8_UINT,
3322 VK_FORMAT_B8G8R8_UINT,
3323 VK_FORMAT_R8G8B8A8_UINT,
3324 VK_FORMAT_B8G8R8A8_UINT,
3325 VK_FORMAT_A8B8G8R8_UINT_PACK32,
3326 VK_FORMAT_A2R10G10B10_UINT_PACK32,
3327 VK_FORMAT_A2B10G10R10_UINT_PACK32,
3329 VK_FORMAT_R16G16_UINT,
3330 VK_FORMAT_R16G16B16_UINT,
3331 VK_FORMAT_R16G16B16A16_UINT,
3333 VK_FORMAT_R32G32_UINT,
3334 VK_FORMAT_R32G32B32_UINT,
3335 VK_FORMAT_R32G32B32A32_UINT,
3337 VK_FORMAT_R64G64_UINT,
3338 VK_FORMAT_R64G64B64_UINT,
3339 VK_FORMAT_R64G64B64A64_UINT,
3343 const VkFormat compatibleFormatsSInts[] =
3346 VK_FORMAT_R8G8_SINT,
3347 VK_FORMAT_R8G8B8_SINT,
3348 VK_FORMAT_B8G8R8_SINT,
3349 VK_FORMAT_R8G8B8A8_SINT,
3350 VK_FORMAT_B8G8R8A8_SINT,
3351 VK_FORMAT_A8B8G8R8_SINT_PACK32,
3352 VK_FORMAT_A2R10G10B10_SINT_PACK32,
3353 VK_FORMAT_A2B10G10R10_SINT_PACK32,
3355 VK_FORMAT_R16G16_SINT,
3356 VK_FORMAT_R16G16B16_SINT,
3357 VK_FORMAT_R16G16B16A16_SINT,
3359 VK_FORMAT_R32G32_SINT,
3360 VK_FORMAT_R32G32B32_SINT,
3361 VK_FORMAT_R32G32B32A32_SINT,
3363 VK_FORMAT_R64G64_SINT,
3364 VK_FORMAT_R64G64B64_SINT,
3365 VK_FORMAT_R64G64B64A64_SINT,
3369 const VkFormat compatibleFormatsFloats[] =
3371 VK_FORMAT_R4G4_UNORM_PACK8,
3372 VK_FORMAT_R4G4B4A4_UNORM_PACK16,
3373 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
3374 VK_FORMAT_R5G6B5_UNORM_PACK16,
3375 VK_FORMAT_B5G6R5_UNORM_PACK16,
3376 VK_FORMAT_R5G5B5A1_UNORM_PACK16,
3377 VK_FORMAT_B5G5R5A1_UNORM_PACK16,
3378 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
3381 VK_FORMAT_R8_USCALED,
3382 VK_FORMAT_R8_SSCALED,
3383 VK_FORMAT_R8G8_UNORM,
3384 VK_FORMAT_R8G8_SNORM,
3385 VK_FORMAT_R8G8_USCALED,
3386 VK_FORMAT_R8G8_SSCALED,
3387 VK_FORMAT_R8G8B8_UNORM,
3388 VK_FORMAT_R8G8B8_SNORM,
3389 VK_FORMAT_R8G8B8_USCALED,
3390 VK_FORMAT_R8G8B8_SSCALED,
3391 VK_FORMAT_B8G8R8_UNORM,
3392 VK_FORMAT_B8G8R8_SNORM,
3393 VK_FORMAT_B8G8R8_USCALED,
3394 VK_FORMAT_B8G8R8_SSCALED,
3395 VK_FORMAT_R8G8B8A8_UNORM,
3396 VK_FORMAT_R8G8B8A8_SNORM,
3397 VK_FORMAT_R8G8B8A8_USCALED,
3398 VK_FORMAT_R8G8B8A8_SSCALED,
3399 VK_FORMAT_B8G8R8A8_UNORM,
3400 VK_FORMAT_B8G8R8A8_SNORM,
3401 VK_FORMAT_B8G8R8A8_USCALED,
3402 VK_FORMAT_B8G8R8A8_SSCALED,
3403 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
3404 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
3405 VK_FORMAT_A8B8G8R8_USCALED_PACK32,
3406 VK_FORMAT_A8B8G8R8_SSCALED_PACK32,
3407 VK_FORMAT_A2R10G10B10_UNORM_PACK32,
3408 VK_FORMAT_A2R10G10B10_SNORM_PACK32,
3409 VK_FORMAT_A2R10G10B10_USCALED_PACK32,
3410 VK_FORMAT_A2R10G10B10_SSCALED_PACK32,
3411 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
3412 VK_FORMAT_A2B10G10R10_SNORM_PACK32,
3413 VK_FORMAT_A2B10G10R10_USCALED_PACK32,
3414 VK_FORMAT_A2B10G10R10_SSCALED_PACK32,
3415 VK_FORMAT_R16_UNORM,
3416 VK_FORMAT_R16_SNORM,
3417 VK_FORMAT_R16_USCALED,
3418 VK_FORMAT_R16_SSCALED,
3419 VK_FORMAT_R16_SFLOAT,
3420 VK_FORMAT_R16G16_UNORM,
3421 VK_FORMAT_R16G16_SNORM,
3422 VK_FORMAT_R16G16_USCALED,
3423 VK_FORMAT_R16G16_SSCALED,
3424 VK_FORMAT_R16G16_SFLOAT,
3425 VK_FORMAT_R16G16B16_UNORM,
3426 VK_FORMAT_R16G16B16_SNORM,
3427 VK_FORMAT_R16G16B16_USCALED,
3428 VK_FORMAT_R16G16B16_SSCALED,
3429 VK_FORMAT_R16G16B16_SFLOAT,
3430 VK_FORMAT_R16G16B16A16_UNORM,
3431 VK_FORMAT_R16G16B16A16_SNORM,
3432 VK_FORMAT_R16G16B16A16_USCALED,
3433 VK_FORMAT_R16G16B16A16_SSCALED,
3434 VK_FORMAT_R16G16B16A16_SFLOAT,
3435 VK_FORMAT_R32_SFLOAT,
3436 VK_FORMAT_R32G32_SFLOAT,
3437 VK_FORMAT_R32G32B32_SFLOAT,
3438 VK_FORMAT_R32G32B32A32_SFLOAT,
3439 VK_FORMAT_R64_SFLOAT,
3440 VK_FORMAT_R64G64_SFLOAT,
3441 VK_FORMAT_R64G64B64_SFLOAT,
3442 VK_FORMAT_R64G64B64A64_SFLOAT,
3443 // VK_FORMAT_B10G11R11_UFLOAT_PACK32,
3444 // VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
3445 // VK_FORMAT_BC1_RGB_UNORM_BLOCK,
3446 // VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
3447 // VK_FORMAT_BC2_UNORM_BLOCK,
3448 // VK_FORMAT_BC3_UNORM_BLOCK,
3449 // VK_FORMAT_BC4_UNORM_BLOCK,
3450 // VK_FORMAT_BC4_SNORM_BLOCK,
3451 // VK_FORMAT_BC5_UNORM_BLOCK,
3452 // VK_FORMAT_BC5_SNORM_BLOCK,
3453 // VK_FORMAT_BC6H_UFLOAT_BLOCK,
3454 // VK_FORMAT_BC6H_SFLOAT_BLOCK,
3455 // VK_FORMAT_BC7_UNORM_BLOCK,
3456 // VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
3457 // VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,
3458 // VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,
3459 // VK_FORMAT_EAC_R11_UNORM_BLOCK,
3460 // VK_FORMAT_EAC_R11_SNORM_BLOCK,
3461 // VK_FORMAT_EAC_R11G11_UNORM_BLOCK,
3462 // VK_FORMAT_EAC_R11G11_SNORM_BLOCK,
3463 // VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
3464 // VK_FORMAT_ASTC_5x4_UNORM_BLOCK,
3465 // VK_FORMAT_ASTC_5x5_UNORM_BLOCK,
3466 // VK_FORMAT_ASTC_6x5_UNORM_BLOCK,
3467 // VK_FORMAT_ASTC_6x6_UNORM_BLOCK,
3468 // VK_FORMAT_ASTC_8x5_UNORM_BLOCK,
3469 // VK_FORMAT_ASTC_8x6_UNORM_BLOCK,
3470 // VK_FORMAT_ASTC_8x8_UNORM_BLOCK,
3471 // VK_FORMAT_ASTC_10x5_UNORM_BLOCK,
3472 // VK_FORMAT_ASTC_10x6_UNORM_BLOCK,
3473 // VK_FORMAT_ASTC_10x8_UNORM_BLOCK,
3474 // VK_FORMAT_ASTC_10x10_UNORM_BLOCK,
3475 // VK_FORMAT_ASTC_12x10_UNORM_BLOCK,
3476 // VK_FORMAT_ASTC_12x12_UNORM_BLOCK,
3480 const VkFormat compatibleFormatsSrgb[] =
3483 VK_FORMAT_R8G8_SRGB,
3484 VK_FORMAT_R8G8B8_SRGB,
3485 VK_FORMAT_B8G8R8_SRGB,
3486 VK_FORMAT_R8G8B8A8_SRGB,
3487 VK_FORMAT_B8G8R8A8_SRGB,
3488 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
3489 // VK_FORMAT_BC1_RGB_SRGB_BLOCK,
3490 // VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
3491 // VK_FORMAT_BC2_SRGB_BLOCK,
3492 // VK_FORMAT_BC3_SRGB_BLOCK,
3493 // VK_FORMAT_BC7_SRGB_BLOCK,
3494 // VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
3495 // VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
3496 // VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
3497 // VK_FORMAT_ASTC_4x4_SRGB_BLOCK,
3498 // VK_FORMAT_ASTC_5x4_SRGB_BLOCK,
3499 // VK_FORMAT_ASTC_5x5_SRGB_BLOCK,
3500 // VK_FORMAT_ASTC_6x5_SRGB_BLOCK,
3501 // VK_FORMAT_ASTC_6x6_SRGB_BLOCK,
3502 // VK_FORMAT_ASTC_8x5_SRGB_BLOCK,
3503 // VK_FORMAT_ASTC_8x6_SRGB_BLOCK,
3504 // VK_FORMAT_ASTC_8x8_SRGB_BLOCK,
3505 // VK_FORMAT_ASTC_10x5_SRGB_BLOCK,
3506 // VK_FORMAT_ASTC_10x6_SRGB_BLOCK,
3507 // VK_FORMAT_ASTC_10x8_SRGB_BLOCK,
3508 // VK_FORMAT_ASTC_10x10_SRGB_BLOCK,
3509 // VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
3510 // VK_FORMAT_ASTC_12x12_SRGB_BLOCK,
3516 const VkFormat* compatibleFormats;
3517 const bool onlyNearest;
3518 } colorImageFormatsToTest[] =
3520 { compatibleFormatsUInts, true },
3521 { compatibleFormatsSInts, true },
3522 { compatibleFormatsFloats, false },
3523 { compatibleFormatsSrgb, false },
3525 const size_t numOfColorImageFormatsToTest = DE_LENGTH_OF_ARRAY(colorImageFormatsToTest);
3527 for (size_t compatibleFormatsIndex = 0; compatibleFormatsIndex < numOfColorImageFormatsToTest; ++compatibleFormatsIndex)
3529 const VkFormat* compatibleFormats = colorImageFormatsToTest[compatibleFormatsIndex].compatibleFormats;
3530 const bool onlyNearest = colorImageFormatsToTest[compatibleFormatsIndex].onlyNearest;
3531 for (size_t srcFormatIndex = 0; compatibleFormats[srcFormatIndex] != VK_FORMAT_UNDEFINED; ++srcFormatIndex)
3533 params.src.image.format = compatibleFormats[srcFormatIndex];
3534 for (size_t dstFormatIndex = 0; compatibleFormats[dstFormatIndex] != VK_FORMAT_UNDEFINED; ++dstFormatIndex)
3536 params.dst.image.format = compatibleFormats[dstFormatIndex];
3538 if (!isSupportedByFramework(params.src.image.format) || !isSupportedByFramework(params.dst.image.format))
3541 std::ostringstream testName;
3542 testName << getFormatCaseName(params.src.image.format) << "_" << getFormatCaseName(params.dst.image.format);
3543 std::ostringstream description;
3544 description << "Blit image from src " << params.src.image.format << " to dst " << params.dst.image.format;
3546 params.filter = VK_FILTER_NEAREST;
3547 testCaseGroup->addChild(new BlittingTestCase(testCtx, testName.str() + "_nearest", description.str(), params));
3551 params.filter = VK_FILTER_LINEAR;
3552 testCaseGroup->addChild(new BlittingTestCase(testCtx, testName.str() + "_linear", description.str(), params));
3561 tcu::TestCaseGroup* createCopiesAndBlittingTests (tcu::TestContext& testCtx)
3563 de::MovePtr<tcu::TestCaseGroup> copiesAndBlittingTests (new tcu::TestCaseGroup(testCtx, "copy_and_blit", "Copies And Blitting Tests"));
3565 de::MovePtr<tcu::TestCaseGroup> imageToImageTests (new tcu::TestCaseGroup(testCtx, "image_to_image", "Copy from image to image"));
3566 de::MovePtr<tcu::TestCaseGroup> imgToImgSimpleTests (new tcu::TestCaseGroup(testCtx, "simple_tests", "Copy from image to image simple tests"));
3567 de::MovePtr<tcu::TestCaseGroup> imgToImgAllFormatsTests (new tcu::TestCaseGroup(testCtx, "all_formats", "Copy from image to image with all compatible formats"));
3569 de::MovePtr<tcu::TestCaseGroup> imageToBufferTests (new tcu::TestCaseGroup(testCtx, "image_to_buffer", "Copy from image to buffer"));
3570 de::MovePtr<tcu::TestCaseGroup> bufferToImageTests (new tcu::TestCaseGroup(testCtx, "buffer_to_image", "Copy from buffer to image"));
3571 de::MovePtr<tcu::TestCaseGroup> bufferToBufferTests (new tcu::TestCaseGroup(testCtx, "buffer_to_buffer", "Copy from buffer to buffer"));
3573 de::MovePtr<tcu::TestCaseGroup> blittingImageTests (new tcu::TestCaseGroup(testCtx, "blit_image", "Blitting image"));
3574 de::MovePtr<tcu::TestCaseGroup> blitImgSimpleTests (new tcu::TestCaseGroup(testCtx, "simple_tests", "Blitting image simple tests"));
3575 de::MovePtr<tcu::TestCaseGroup> blitImgAllFormatsTests (new tcu::TestCaseGroup(testCtx, "all_formats", "Blitting image with all compatible formats"));
3577 de::MovePtr<tcu::TestCaseGroup> resolveImageTests (new tcu::TestCaseGroup(testCtx, "resolve_image", "Resolve image"));
3579 const deInt32 defaultSize = 64;
3580 const deInt32 defaultHalfSize = defaultSize / 2;
3581 const deInt32 defaultFourthSize = defaultSize / 4;
3582 const VkExtent3D defaultExtent = {defaultSize, defaultSize, 1};
3583 const VkExtent3D defaultHalfExtent = {defaultHalfSize, defaultHalfSize, 1};
3585 const VkImageSubresourceLayers defaultSourceLayer =
3587 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
3588 0u, // uint32_t mipLevel;
3589 0u, // uint32_t baseArrayLayer;
3590 1u, // uint32_t layerCount;
3593 const VkFormat depthAndStencilFormats[] =
3595 VK_FORMAT_D16_UNORM,
3596 VK_FORMAT_X8_D24_UNORM_PACK32,
3597 VK_FORMAT_D32_SFLOAT,
3599 VK_FORMAT_D16_UNORM_S8_UINT,
3600 VK_FORMAT_D24_UNORM_S8_UINT,
3601 VK_FORMAT_D32_SFLOAT_S8_UINT,
3604 // Copy image to image testcases.
3607 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3608 params.src.image.format = VK_FORMAT_R8G8B8A8_UINT;
3609 params.src.image.extent = defaultExtent;
3610 params.dst.image.format = VK_FORMAT_R8G8B8A8_UINT;
3611 params.dst.image.extent = defaultExtent;
3614 const VkImageCopy testCopy =
3616 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
3617 {0, 0, 0}, // VkOffset3D srcOffset;
3618 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
3619 {0, 0, 0}, // VkOffset3D dstOffset;
3620 defaultExtent, // VkExtent3D extent;
3623 CopyRegion imageCopy;
3624 imageCopy.imageCopy = testCopy;
3626 params.regions.push_back(imageCopy);
3629 imgToImgSimpleTests->addChild(new CopyImageToImageTestCase(testCtx, "whole_image", "Whole image", params));
3634 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3635 params.src.image.format = VK_FORMAT_R8G8B8A8_UINT;
3636 params.src.image.extent = defaultExtent;
3637 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3638 params.dst.image.format = VK_FORMAT_R32_UINT;
3639 params.dst.image.extent = defaultExtent;
3642 const VkImageCopy testCopy =
3644 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
3645 {0, 0, 0}, // VkOffset3D srcOffset;
3646 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
3647 {0, 0, 0}, // VkOffset3D dstOffset;
3648 defaultExtent, // VkExtent3D extent;
3651 CopyRegion imageCopy;
3652 imageCopy.imageCopy = testCopy;
3654 params.regions.push_back(imageCopy);
3657 imgToImgSimpleTests->addChild(new CopyImageToImageTestCase(testCtx, "whole_image_diff_fromat", "Whole image with different format", params));
3662 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3663 params.src.image.format = VK_FORMAT_R8G8B8A8_UINT;
3664 params.src.image.extent = defaultExtent;
3665 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3666 params.dst.image.format = VK_FORMAT_R8G8B8A8_UINT;
3667 params.dst.image.extent = defaultExtent;
3670 const VkImageCopy testCopy =
3672 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
3673 {0, 0, 0}, // VkOffset3D srcOffset;
3674 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
3675 {defaultFourthSize, defaultFourthSize / 2, 0}, // VkOffset3D dstOffset;
3676 {defaultFourthSize / 2, defaultFourthSize / 2, 1}, // VkExtent3D extent;
3679 CopyRegion imageCopy;
3680 imageCopy.imageCopy = testCopy;
3682 params.regions.push_back(imageCopy);
3685 imgToImgSimpleTests->addChild(new CopyImageToImageTestCase(testCtx, "partial_image", "Partial image", params));
3690 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3691 params.src.image.format = VK_FORMAT_D32_SFLOAT;
3692 params.src.image.extent = defaultExtent;
3693 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3694 params.dst.image.format = VK_FORMAT_D32_SFLOAT;
3695 params.dst.image.extent = defaultExtent;
3698 const VkImageSubresourceLayers sourceLayer =
3700 VK_IMAGE_ASPECT_DEPTH_BIT, // VkImageAspectFlags aspectMask;
3701 0u, // uint32_t mipLevel;
3702 0u, // uint32_t baseArrayLayer;
3703 1u // uint32_t layerCount;
3705 const VkImageCopy testCopy =
3707 sourceLayer, // VkImageSubresourceLayers srcSubresource;
3708 {0, 0, 0}, // VkOffset3D srcOffset;
3709 sourceLayer, // VkImageSubresourceLayers dstSubresource;
3710 {defaultFourthSize, defaultFourthSize / 2, 0}, // VkOffset3D dstOffset;
3711 {defaultFourthSize / 2, defaultFourthSize / 2, 1}, // VkExtent3D extent;
3714 CopyRegion imageCopy;
3715 imageCopy.imageCopy = testCopy;
3717 params.regions.push_back(imageCopy);
3720 imgToImgSimpleTests->addChild(new CopyImageToImageTestCase(testCtx, "depth", "With depth", params));
3725 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3726 params.src.image.format = VK_FORMAT_S8_UINT;
3727 params.src.image.extent = defaultExtent;
3728 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3729 params.dst.image.format = VK_FORMAT_S8_UINT;
3730 params.dst.image.extent = defaultExtent;
3733 const VkImageSubresourceLayers sourceLayer =
3735 VK_IMAGE_ASPECT_STENCIL_BIT, // VkImageAspectFlags aspectMask;
3736 0u, // uint32_t mipLevel;
3737 0u, // uint32_t baseArrayLayer;
3738 1u // uint32_t layerCount;
3740 const VkImageCopy testCopy =
3742 sourceLayer, // VkImageSubresourceLayers srcSubresource;
3743 {0, 0, 0}, // VkOffset3D srcOffset;
3744 sourceLayer, // VkImageSubresourceLayers dstSubresource;
3745 {defaultFourthSize, defaultFourthSize / 2, 0}, // VkOffset3D dstOffset;
3746 {defaultFourthSize / 2, defaultFourthSize / 2, 1}, // VkExtent3D extent;
3749 CopyRegion imageCopy;
3750 imageCopy.imageCopy = testCopy;
3752 params.regions.push_back(imageCopy);
3755 imgToImgSimpleTests->addChild(new CopyImageToImageTestCase(testCtx, "stencil", "With stencil", params));
3759 // Test Color formats.
3762 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3763 params.src.image.extent = defaultExtent;
3764 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3765 params.dst.image.extent = defaultExtent;
3767 for (deInt32 i = 0; i < defaultSize; i += defaultFourthSize)
3769 const VkImageCopy testCopy =
3771 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
3772 {0, 0, 0}, // VkOffset3D srcOffset;
3773 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
3774 {i, defaultSize - i - defaultFourthSize, 0}, // VkOffset3D dstOffset;
3775 {defaultFourthSize, defaultFourthSize, 1}, // VkExtent3D extent;
3778 CopyRegion imageCopy;
3779 imageCopy.imageCopy = testCopy;
3781 params.regions.push_back(imageCopy);
3784 addCopyImageTestsAllFormats(imgToImgAllFormatsTests.get(), testCtx, params);
3787 // Test Depth and Stencil formats.
3789 const std::string description ("Copy image to image with depth/stencil formats ");
3790 const std::string testName ("depth_stencil");
3792 for (size_t compatibleFormatsIndex = 0; compatibleFormatsIndex < DE_LENGTH_OF_ARRAY(depthAndStencilFormats); ++compatibleFormatsIndex)
3796 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3797 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3798 params.src.image.extent = defaultExtent;
3799 params.dst.image.extent = defaultExtent;
3800 params.src.image.format = depthAndStencilFormats[compatibleFormatsIndex];
3801 params.dst.image.format = params.src.image.format;
3802 std::ostringstream oss;
3803 oss << testName << "_" << getFormatCaseName(params.src.image.format) << "_" << getFormatCaseName(params.dst.image.format);
3805 const VkImageSubresourceLayers defaultDepthSourceLayer = { VK_IMAGE_ASPECT_DEPTH_BIT, 0u, 0u, 1u };
3806 const VkImageSubresourceLayers defaultStencilSourceLayer = { VK_IMAGE_ASPECT_STENCIL_BIT, 0u, 0u, 1u };
3808 for (deInt32 i = 0; i < defaultSize; i += defaultFourthSize)
3810 CopyRegion copyRegion;
3811 const VkOffset3D srcOffset = {0, 0, 0};
3812 const VkOffset3D dstOffset = {i, defaultSize - i - defaultFourthSize, 0};
3813 const VkExtent3D extent = {defaultFourthSize, defaultFourthSize, 1};
3815 if (tcu::hasDepthComponent(mapVkFormat(params.src.image.format).order))
3817 const VkImageCopy testCopy =
3819 defaultDepthSourceLayer, // VkImageSubresourceLayers srcSubresource;
3820 srcOffset, // VkOffset3D srcOffset;
3821 defaultDepthSourceLayer, // VkImageSubresourceLayers dstSubresource;
3822 dstOffset, // VkOffset3D dstOffset;
3823 extent, // VkExtent3D extent;
3826 copyRegion.imageCopy = testCopy;
3827 params.regions.push_back(copyRegion);
3829 if (tcu::hasStencilComponent(mapVkFormat(params.src.image.format).order))
3831 const VkImageCopy testCopy =
3833 defaultStencilSourceLayer, // VkImageSubresourceLayers srcSubresource;
3834 srcOffset, // VkOffset3D srcOffset;
3835 defaultStencilSourceLayer, // VkImageSubresourceLayers dstSubresource;
3836 dstOffset, // VkOffset3D dstOffset;
3837 extent, // VkExtent3D extent;
3840 copyRegion.imageCopy = testCopy;
3841 params.regions.push_back(copyRegion);
3845 imgToImgAllFormatsTests->addChild(new CopyImageToImageTestCase(testCtx, oss.str(), description, params));
3849 imageToImageTests->addChild(imgToImgSimpleTests.release());
3850 imageToImageTests->addChild(imgToImgAllFormatsTests.release());
3852 // Copy image to buffer testcases.
3855 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3856 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
3857 params.src.image.extent = defaultExtent;
3858 params.dst.buffer.size = defaultSize * defaultSize;
3860 const VkBufferImageCopy bufferImageCopy =
3862 0u, // VkDeviceSize bufferOffset;
3863 0u, // uint32_t bufferRowLength;
3864 0u, // uint32_t bufferImageHeight;
3865 defaultSourceLayer, // VkImageSubresourceLayers imageSubresource;
3866 {0, 0, 0}, // VkOffset3D imageOffset;
3867 defaultExtent // VkExtent3D imageExtent;
3869 CopyRegion copyRegion;
3870 copyRegion.bufferImageCopy = bufferImageCopy;
3872 params.regions.push_back(copyRegion);
3874 imageToBufferTests->addChild(new CopyImageToBufferTestCase(testCtx, "whole", "Copy from image to buffer", params));
3879 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3880 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
3881 params.src.image.extent = defaultExtent;
3882 params.dst.buffer.size = defaultSize * defaultSize;
3884 const VkBufferImageCopy bufferImageCopy =
3886 defaultSize * defaultHalfSize, // VkDeviceSize bufferOffset;
3887 0u, // uint32_t bufferRowLength;
3888 0u, // uint32_t bufferImageHeight;
3889 defaultSourceLayer, // VkImageSubresourceLayers imageSubresource;
3890 {defaultFourthSize, defaultFourthSize, 0}, // VkOffset3D imageOffset;
3891 defaultHalfExtent // VkExtent3D imageExtent;
3893 CopyRegion copyRegion;
3894 copyRegion.bufferImageCopy = bufferImageCopy;
3896 params.regions.push_back(copyRegion);
3898 imageToBufferTests->addChild(new CopyImageToBufferTestCase(testCtx, "buffer_offset", "Copy from image to buffer with buffer offset", params));
3903 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3904 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
3905 params.src.image.extent = defaultExtent;
3906 params.dst.buffer.size = defaultSize * defaultSize;
3908 const int pixelSize = tcu::getPixelSize(mapVkFormat(params.src.image.format));
3909 const VkDeviceSize bufferSize = pixelSize * params.dst.buffer.size;
3910 const VkDeviceSize offsetSize = pixelSize * defaultFourthSize * defaultFourthSize;
3911 deUint32 divisor = 1;
3912 for (VkDeviceSize offset = 0; offset < bufferSize - offsetSize; offset += offsetSize, ++divisor)
3914 const deUint32 bufferRowLength = defaultFourthSize;
3915 const deUint32 bufferImageHeight = defaultFourthSize;
3916 const VkExtent3D imageExtent = {defaultFourthSize / divisor, defaultFourthSize, 1};
3917 DE_ASSERT(!bufferRowLength || bufferRowLength >= imageExtent.width);
3918 DE_ASSERT(!bufferImageHeight || bufferImageHeight >= imageExtent.height);
3919 DE_ASSERT(imageExtent.width * imageExtent.height *imageExtent.depth <= offsetSize);
3922 const VkBufferImageCopy bufferImageCopy =
3924 offset, // VkDeviceSize bufferOffset;
3925 bufferRowLength, // uint32_t bufferRowLength;
3926 bufferImageHeight, // uint32_t bufferImageHeight;
3927 defaultSourceLayer, // VkImageSubresourceLayers imageSubresource;
3928 {0, 0, 0}, // VkOffset3D imageOffset;
3929 imageExtent // VkExtent3D imageExtent;
3931 region.bufferImageCopy = bufferImageCopy;
3932 params.regions.push_back(region);
3935 imageToBufferTests->addChild(new CopyImageToBufferTestCase(testCtx, "regions", "Copy from image to buffer with multiple regions", params));
3938 // Copy buffer to image testcases.
3941 params.src.buffer.size = defaultSize * defaultSize;
3942 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3943 params.dst.image.format = VK_FORMAT_R8G8B8A8_UINT;
3944 params.dst.image.extent = defaultExtent;
3946 const VkBufferImageCopy bufferImageCopy =
3948 0u, // VkDeviceSize bufferOffset;
3949 0u, // uint32_t bufferRowLength;
3950 0u, // uint32_t bufferImageHeight;
3951 defaultSourceLayer, // VkImageSubresourceLayers imageSubresource;
3952 {0, 0, 0}, // VkOffset3D imageOffset;
3953 defaultExtent // VkExtent3D imageExtent;
3955 CopyRegion copyRegion;
3956 copyRegion.bufferImageCopy = bufferImageCopy;
3958 params.regions.push_back(copyRegion);
3960 bufferToImageTests->addChild(new CopyBufferToImageTestCase(testCtx, "whole", "Copy from buffer to image", params));
3965 params.src.buffer.size = defaultSize * defaultSize;
3966 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3967 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
3968 params.dst.image.extent = defaultExtent;
3971 deUint32 divisor = 1;
3972 for (int offset = 0; (offset + defaultFourthSize / divisor < defaultSize) && (defaultFourthSize > divisor); offset += defaultFourthSize / divisor++)
3974 const VkBufferImageCopy bufferImageCopy =
3976 0u, // VkDeviceSize bufferOffset;
3977 0u, // uint32_t bufferRowLength;
3978 0u, // uint32_t bufferImageHeight;
3979 defaultSourceLayer, // VkImageSubresourceLayers imageSubresource;
3980 {offset, defaultHalfSize, 0}, // VkOffset3D imageOffset;
3981 {defaultFourthSize / divisor, defaultFourthSize / divisor, 1} // VkExtent3D imageExtent;
3983 region.bufferImageCopy = bufferImageCopy;
3984 params.regions.push_back(region);
3987 bufferToImageTests->addChild(new CopyBufferToImageTestCase(testCtx, "regions", "Copy from buffer to image with multiple regions", params));
3992 params.src.buffer.size = defaultSize * defaultSize;
3993 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3994 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
3995 params.dst.image.extent = defaultExtent;
3997 const VkBufferImageCopy bufferImageCopy =
3999 defaultFourthSize, // VkDeviceSize bufferOffset;
4000 defaultHalfSize + defaultFourthSize, // uint32_t bufferRowLength;
4001 defaultHalfSize + defaultFourthSize, // uint32_t bufferImageHeight;
4002 defaultSourceLayer, // VkImageSubresourceLayers imageSubresource;
4003 {defaultFourthSize, defaultFourthSize, 0}, // VkOffset3D imageOffset;
4004 defaultHalfExtent // VkExtent3D imageExtent;
4006 CopyRegion copyRegion;
4007 copyRegion.bufferImageCopy = bufferImageCopy;
4009 params.regions.push_back(copyRegion);
4011 bufferToImageTests->addChild(new CopyBufferToImageTestCase(testCtx, "buffer_offset", "Copy from buffer to image with buffer offset", params));
4014 // Copy buffer to buffer testcases.
4017 params.src.buffer.size = defaultSize;
4018 params.dst.buffer.size = defaultSize;
4020 const VkBufferCopy bufferCopy =
4022 0u, // VkDeviceSize srcOffset;
4023 0u, // VkDeviceSize dstOffset;
4024 defaultSize, // VkDeviceSize size;
4027 CopyRegion copyRegion;
4028 copyRegion.bufferCopy = bufferCopy;
4029 params.regions.push_back(copyRegion);
4031 bufferToBufferTests->addChild(new BufferToBufferTestCase(testCtx, "whole", "Whole buffer", params));
4036 params.src.buffer.size = defaultFourthSize;
4037 params.dst.buffer.size = defaultFourthSize;
4039 const VkBufferCopy bufferCopy =
4041 12u, // VkDeviceSize srcOffset;
4042 4u, // VkDeviceSize dstOffset;
4043 1u, // VkDeviceSize size;
4046 CopyRegion copyRegion;
4047 copyRegion.bufferCopy = bufferCopy;
4048 params.regions.push_back(copyRegion);
4050 bufferToBufferTests->addChild(new BufferToBufferTestCase(testCtx, "partial", "Partial", params));
4054 const deUint32 size = 16;
4056 params.src.buffer.size = size;
4057 params.dst.buffer.size = size * (size + 1);
4059 // Copy region with size 1..size
4060 for (unsigned int i = 1; i <= size; i++)
4062 const VkBufferCopy bufferCopy =
4064 0, // VkDeviceSize srcOffset;
4065 i * size, // VkDeviceSize dstOffset;
4066 i, // VkDeviceSize size;
4069 CopyRegion copyRegion;
4070 copyRegion.bufferCopy = bufferCopy;
4071 params.regions.push_back(copyRegion);
4074 bufferToBufferTests->addChild(new BufferToBufferTestCase(testCtx, "regions", "Multiple regions", params));
4077 // Blitting testcases.
4079 const std::string description ("Blit without scaling (whole)");
4080 const std::string testName ("whole");
4083 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4084 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4085 params.src.image.extent = defaultExtent;
4086 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4087 params.dst.image.extent = defaultExtent;
4090 const VkImageBlit imageBlit =
4092 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4095 {defaultSize, defaultSize, 1}
4096 }, // VkOffset3D srcOffsets[2];
4098 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4101 {defaultSize, defaultSize, 1}
4102 } // VkOffset3D dstOffset[2];
4106 region.imageBlit = imageBlit;
4107 params.regions.push_back(region);
4110 // Filter is VK_FILTER_NEAREST.
4112 params.filter = VK_FILTER_NEAREST;
4114 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4115 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_nearest", description, params));
4117 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4118 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4119 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4121 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4122 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4123 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4126 // Filter is VK_FILTER_LINEAR.
4128 params.filter = VK_FILTER_LINEAR;
4130 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4131 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_linear", description + " (VK_FILTER_LINEAR)", params));
4133 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4134 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)" + " (VK_FILTER_LINEAR)");
4135 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4137 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4138 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)" + " (VK_FILTER_LINEAR)");
4139 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4144 const std::string description ("Flipping x and y coordinates (whole)");
4145 const std::string testName ("mirror_xy");
4148 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4149 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4150 params.src.image.extent = defaultExtent;
4151 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4152 params.dst.image.extent = defaultExtent;
4155 const VkImageBlit imageBlit =
4157 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4160 {defaultSize, defaultSize, 1}
4161 }, // VkOffset3D srcOffsets[2];
4163 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4165 {defaultSize, defaultSize, 0},
4167 } // VkOffset3D dstOffset[2];
4171 region.imageBlit = imageBlit;
4172 params.regions.push_back(region);
4175 // Filter is VK_FILTER_NEAREST.
4177 params.filter = VK_FILTER_NEAREST;
4179 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4180 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_nearest", description, params));
4182 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4183 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4184 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4186 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4187 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4188 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4191 // Filter is VK_FILTER_LINEAR.
4193 params.filter = VK_FILTER_LINEAR;
4195 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4196 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_linear", description + " (VK_FILTER_LINEAR)", params));
4198 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4199 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)" + " (VK_FILTER_LINEAR)");
4200 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4202 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4203 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)" + " (VK_FILTER_LINEAR)");
4204 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4209 const std::string description ("Flipping x coordinates (whole)");
4210 const std::string testName ("mirror_x");
4213 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4214 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4215 params.src.image.extent = defaultExtent;
4216 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4217 params.dst.image.extent = defaultExtent;
4220 const VkImageBlit imageBlit =
4222 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4225 {defaultSize, defaultSize, 1}
4226 }, // VkOffset3D srcOffsets[2];
4228 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4230 {defaultSize, 0, 0},
4232 } // VkOffset3D dstOffset[2];
4236 region.imageBlit = imageBlit;
4237 params.regions.push_back(region);
4240 // Filter is VK_FILTER_NEAREST.
4242 params.filter = VK_FILTER_NEAREST;
4244 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4245 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_nearest", description, params));
4247 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4248 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4249 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4251 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4252 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4253 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4256 // Filter is VK_FILTER_LINEAR.
4258 params.filter = VK_FILTER_LINEAR;
4260 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4261 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_linear", description + " (VK_FILTER_LINEAR)", params));
4263 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4264 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)" + " (VK_FILTER_LINEAR)");
4265 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4267 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4268 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)" + " (VK_FILTER_LINEAR)");
4269 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4274 const std::string description ("Flipping Y coordinates (whole)");
4275 const std::string testName ("mirror_y");
4278 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4279 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4280 params.src.image.extent = defaultExtent;
4281 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4282 params.dst.image.extent = defaultExtent;
4285 const VkImageBlit imageBlit =
4287 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4290 {defaultSize, defaultSize, 1}
4291 }, // VkOffset3D srcOffsets[2];
4293 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4295 {0, defaultSize, 0},
4297 } // VkOffset3D dstOffset[2];
4301 region.imageBlit = imageBlit;
4302 params.regions.push_back(region);
4305 // Filter is VK_FILTER_NEAREST.
4307 params.filter = VK_FILTER_NEAREST;
4309 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4310 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_nearest", description, params));
4312 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4313 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4314 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4316 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4317 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4318 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4321 // Filter is VK_FILTER_LINEAR.
4323 params.filter = VK_FILTER_LINEAR;
4325 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4326 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_linear", description + " (VK_FILTER_LINEAR)", params));
4328 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4329 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)" + " (VK_FILTER_LINEAR)");
4330 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4332 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4333 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)" + " (VK_FILTER_LINEAR)");
4334 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4339 const std::string description ("Mirroring subregions in image (no flip ,y flip ,x flip, xy flip)");
4340 const std::string testName ("mirror_subregions");
4343 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4344 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4345 params.src.image.extent = defaultExtent;
4346 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4347 params.dst.image.extent = defaultExtent;
4351 const VkImageBlit imageBlit =
4353 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4356 {defaultHalfSize, defaultHalfSize, 1}
4357 }, // VkOffset3D srcOffsets[2];
4359 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4362 {defaultHalfSize, defaultHalfSize, 1}
4363 } // VkOffset3D dstOffset[2];
4367 region.imageBlit = imageBlit;
4368 params.regions.push_back(region);
4371 // Flipping y coordinates.
4373 const VkImageBlit imageBlit =
4375 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4377 {defaultHalfSize, 0, 0},
4378 {defaultSize, defaultHalfSize, 1}
4379 }, // VkOffset3D srcOffsets[2];
4381 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4383 {defaultHalfSize, defaultHalfSize, 0},
4385 } // VkOffset3D dstOffset[2];
4389 region.imageBlit = imageBlit;
4390 params.regions.push_back(region);
4393 // Flipping x coordinates.
4395 const VkImageBlit imageBlit =
4397 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4399 {0, defaultHalfSize, 0},
4400 {defaultHalfSize, defaultSize, 1}
4401 }, // VkOffset3D srcOffsets[2];
4403 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4405 {defaultHalfSize, defaultHalfSize, 0},
4407 } // VkOffset3D dstOffset[2];
4411 region.imageBlit = imageBlit;
4412 params.regions.push_back(region);
4415 // Flipping x and y coordinates.
4417 const VkImageBlit imageBlit =
4419 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4421 {defaultHalfSize, defaultHalfSize, 0},
4422 {defaultSize, defaultSize, 1}
4423 }, // VkOffset3D srcOffsets[2];
4425 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4427 {defaultSize, defaultSize, 0},
4428 {defaultHalfSize, defaultHalfSize, 1}
4429 } // VkOffset3D dstOffset[2];
4433 region.imageBlit = imageBlit;
4434 params.regions.push_back(region);
4437 // Filter is VK_FILTER_NEAREST.
4439 params.filter = VK_FILTER_NEAREST;
4441 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4442 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_nearest", description, params));
4444 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4445 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4446 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4448 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4449 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4450 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4453 // Filter is VK_FILTER_LINEAR.
4455 params.filter = VK_FILTER_LINEAR;
4457 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4458 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_linear", description + " (VK_FILTER_LINEAR)", params));
4460 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4461 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)" + " (VK_FILTER_LINEAR)");
4462 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4464 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4465 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)" + " (VK_FILTER_LINEAR)");
4466 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4471 const std::string description ("Blit with scaling (whole, src extent bigger)");
4472 const std::string testName ("scaling_whole1");
4475 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4476 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4477 params.src.image.extent = defaultExtent;
4478 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4479 params.dst.image.extent = defaultHalfExtent;
4482 const VkImageBlit imageBlit =
4484 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4487 {defaultSize, defaultSize, 1}
4488 }, // VkOffset3D srcOffsets[2];
4490 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4493 {defaultHalfSize, defaultHalfSize, 1}
4494 } // VkOffset3D dstOffset[2];
4498 region.imageBlit = imageBlit;
4499 params.regions.push_back(region);
4502 // Filter is VK_FILTER_NEAREST.
4504 params.filter = VK_FILTER_NEAREST;
4506 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4507 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_nearest", description, params));
4509 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4510 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4511 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4513 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4514 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4515 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4518 // Filter is VK_FILTER_LINEAR.
4520 params.filter = VK_FILTER_LINEAR;
4522 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4523 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_linear", description + " (VK_FILTER_LINEAR)", params));
4525 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4526 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)" + " (VK_FILTER_LINEAR)");
4527 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4529 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4530 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)" + " (VK_FILTER_LINEAR)");
4531 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4536 const std::string description ("Blit with scaling (whole, dst extent bigger)");
4537 const std::string testName ("scaling_whole2");
4540 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4541 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4542 params.src.image.extent = defaultHalfExtent;
4543 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4544 params.dst.image.extent = defaultExtent;
4547 const VkImageBlit imageBlit =
4549 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4552 {defaultHalfSize, defaultHalfSize, 1}
4553 }, // VkOffset3D srcOffsets[2];
4555 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4558 {defaultSize, defaultSize, 1}
4559 } // VkOffset3D dstOffset[2];
4563 region.imageBlit = imageBlit;
4564 params.regions.push_back(region);
4567 // Filter is VK_FILTER_NEAREST.
4569 params.filter = VK_FILTER_NEAREST;
4571 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4572 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_nearest", description, params));
4574 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4575 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4576 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4578 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4579 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4580 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4583 // Filter is VK_FILTER_LINEAR.
4585 params.filter = VK_FILTER_LINEAR;
4587 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4588 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_linear", description + " (VK_FILTER_LINEAR)", params));
4590 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4591 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)" + " (VK_FILTER_LINEAR)");
4592 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4594 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4595 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)" + " (VK_FILTER_LINEAR)");
4596 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4601 const std::string description ("Blit with scaling and offset (whole, dst extent bigger)");
4602 const std::string testName ("scaling_and_offset");
4605 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4606 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4607 params.src.image.extent = defaultExtent;
4608 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4609 params.dst.image.extent = defaultExtent;
4612 const VkImageBlit imageBlit =
4614 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4616 {defaultFourthSize, defaultFourthSize, 0},
4617 {defaultFourthSize*3, defaultFourthSize*3, 1}
4618 }, // VkOffset3D srcOffsets[2];
4620 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4623 {defaultSize, defaultSize, 1}
4624 } // VkOffset3D dstOffset[2];
4628 region.imageBlit = imageBlit;
4629 params.regions.push_back(region);
4632 // Filter is VK_FILTER_NEAREST.
4634 params.filter = VK_FILTER_NEAREST;
4636 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4637 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_nearest", description, params));
4639 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4640 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4641 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4643 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4644 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4645 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4648 // Filter is VK_FILTER_LINEAR.
4650 params.filter = VK_FILTER_LINEAR;
4652 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4653 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_linear", description + " (VK_FILTER_LINEAR)", params));
4655 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4656 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)" + " (VK_FILTER_LINEAR)");
4657 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4659 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4660 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)" + " (VK_FILTER_LINEAR)");
4661 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4666 const std::string description ("Blit without scaling (partial)");
4667 const std::string testName ("without_scaling_partial");
4670 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4671 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4672 params.src.image.extent = defaultExtent;
4673 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4674 params.dst.image.extent = defaultExtent;
4678 for (int i = 0; i < defaultSize; i += defaultFourthSize)
4680 const VkImageBlit imageBlit =
4682 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4684 {defaultSize - defaultFourthSize - i, defaultSize - defaultFourthSize - i, 0},
4685 {defaultSize - i, defaultSize - i, 1}
4686 }, // VkOffset3D srcOffsets[2];
4688 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4691 {i + defaultFourthSize, i + defaultFourthSize, 1}
4692 } // VkOffset3D dstOffset[2];
4694 region.imageBlit = imageBlit;
4695 params.regions.push_back(region);
4699 // Filter is VK_FILTER_NEAREST.
4701 params.filter = VK_FILTER_NEAREST;
4703 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4704 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_nearest", description, params));
4706 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4707 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4708 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4710 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4711 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4712 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4715 // Filter is VK_FILTER_LINEAR.
4717 params.filter = VK_FILTER_LINEAR;
4719 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4720 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_linear", description + " (VK_FILTER_LINEAR)", params));
4722 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4723 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)" + " (VK_FILTER_LINEAR)");
4724 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4726 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4727 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)" + " (VK_FILTER_LINEAR)");
4728 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4733 const std::string description ("Blit with scaling (partial)");
4734 const std::string testName ("scaling_partial");
4736 // Test Color formats.
4739 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4740 params.src.image.extent = defaultExtent;
4741 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4742 params.dst.image.extent = defaultExtent;
4745 for (int i = 0, j = 1; (i + defaultFourthSize / j < defaultSize) && (defaultFourthSize > j); i += defaultFourthSize / j++)
4747 const VkImageBlit imageBlit =
4749 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4752 {defaultSize, defaultSize, 1}
4753 }, // VkOffset3D srcOffsets[2];
4755 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4758 {i + defaultFourthSize / j, defaultFourthSize / j, 1}
4759 } // VkOffset3D dstOffset[2];
4761 region.imageBlit = imageBlit;
4762 params.regions.push_back(region);
4764 for (int i = 0; i < defaultSize; i += defaultFourthSize)
4766 const VkImageBlit imageBlit =
4768 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4771 {i + defaultFourthSize, i + defaultFourthSize, 1}
4772 }, // VkOffset3D srcOffsets[2];
4774 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4776 {i, defaultSize / 2, 0},
4777 {i + defaultFourthSize, defaultSize / 2 + defaultFourthSize, 1}
4778 } // VkOffset3D dstOffset[2];
4780 region.imageBlit = imageBlit;
4781 params.regions.push_back(region);
4784 addBlittingTestsAllFormats(blitImgAllFormatsTests.get(), testCtx, params);
4787 // Test Depth and Stencil formats.
4789 for (size_t compatibleFormatsIndex = 0; compatibleFormatsIndex < DE_LENGTH_OF_ARRAY(depthAndStencilFormats); ++compatibleFormatsIndex)
4793 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4794 params.src.image.extent = defaultExtent;
4795 params.dst.image.extent = defaultExtent;
4796 params.src.image.format = depthAndStencilFormats[compatibleFormatsIndex];
4797 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4798 params.dst.image.format = params.src.image.format;
4799 std::ostringstream oss;
4800 oss << testName << "_" << getFormatCaseName(params.src.image.format) << "_" << getFormatCaseName(params.dst.image.format);
4802 const VkImageSubresourceLayers defaultDepthSourceLayer = { VK_IMAGE_ASPECT_DEPTH_BIT, 0u, 0u, 1u };
4803 const VkImageSubresourceLayers defaultStencilSourceLayer = { VK_IMAGE_ASPECT_STENCIL_BIT, 0u, 0u, 1u };
4806 for (int i = 0, j = 1; (i + defaultFourthSize / j < defaultSize) && (defaultFourthSize > j); i += defaultFourthSize / j++)
4808 const VkOffset3D srcOffset0 = {0, 0, 0};
4809 const VkOffset3D srcOffset1 = {defaultSize, defaultSize, 1};
4810 const VkOffset3D dstOffset0 = {i, 0, 0};
4811 const VkOffset3D dstOffset1 = {i + defaultFourthSize / j, defaultFourthSize / j, 1};
4813 if (tcu::hasDepthComponent(mapVkFormat(params.src.image.format).order))
4815 const VkImageBlit imageBlit =
4817 defaultDepthSourceLayer, // VkImageSubresourceLayers srcSubresource;
4818 { srcOffset0 , srcOffset1 }, // VkOffset3D srcOffsets[2];
4819 defaultDepthSourceLayer, // VkImageSubresourceLayers dstSubresource;
4820 { dstOffset0 , dstOffset1 }, // VkOffset3D dstOffset[2];
4822 region.imageBlit = imageBlit;
4823 params.regions.push_back(region);
4825 if (tcu::hasStencilComponent(mapVkFormat(params.src.image.format).order))
4827 const VkImageBlit imageBlit =
4829 defaultStencilSourceLayer, // VkImageSubresourceLayers srcSubresource;
4830 { srcOffset0 , srcOffset1 }, // VkOffset3D srcOffsets[2];
4831 defaultStencilSourceLayer, // VkImageSubresourceLayers dstSubresource;
4832 { dstOffset0 , dstOffset1 }, // VkOffset3D dstOffset[2];
4834 region.imageBlit = imageBlit;
4835 params.regions.push_back(region);
4838 for (int i = 0; i < defaultSize; i += defaultFourthSize)
4840 const VkOffset3D srcOffset0 = {i, i, 0};
4841 const VkOffset3D srcOffset1 = {i + defaultFourthSize, i + defaultFourthSize, 1};
4842 const VkOffset3D dstOffset0 = {i, defaultSize / 2, 0};
4843 const VkOffset3D dstOffset1 = {i + defaultFourthSize, defaultSize / 2 + defaultFourthSize, 1};
4845 if (tcu::hasDepthComponent(mapVkFormat(params.src.image.format).order))
4847 const VkImageBlit imageBlit =
4849 defaultDepthSourceLayer, // VkImageSubresourceLayers srcSubresource;
4850 { srcOffset0, srcOffset1 }, // VkOffset3D srcOffsets[2];
4851 defaultDepthSourceLayer, // VkImageSubresourceLayers dstSubresource;
4852 { dstOffset0, dstOffset1 } // VkOffset3D dstOffset[2];
4854 region.imageBlit = imageBlit;
4855 params.regions.push_back(region);
4857 if (tcu::hasStencilComponent(mapVkFormat(params.src.image.format).order))
4859 const VkImageBlit imageBlit =
4861 defaultStencilSourceLayer, // VkImageSubresourceLayers srcSubresource;
4862 { srcOffset0, srcOffset1 }, // VkOffset3D srcOffsets[2];
4863 defaultStencilSourceLayer, // VkImageSubresourceLayers dstSubresource;
4864 { dstOffset0, dstOffset1 } // VkOffset3D dstOffset[2];
4866 region.imageBlit = imageBlit;
4867 params.regions.push_back(region);
4871 params.filter = VK_FILTER_NEAREST;
4872 blitImgAllFormatsTests->addChild(new BlittingTestCase(testCtx, oss.str() + "_nearest", description, params));
4876 blittingImageTests->addChild(blitImgSimpleTests.release());
4877 blittingImageTests->addChild(blitImgAllFormatsTests.release());
4879 // Resolve image to image testcases.
4880 const VkSampleCountFlagBits samples[] =
4882 VK_SAMPLE_COUNT_2_BIT,
4883 VK_SAMPLE_COUNT_4_BIT,
4884 VK_SAMPLE_COUNT_8_BIT,
4885 VK_SAMPLE_COUNT_16_BIT,
4886 VK_SAMPLE_COUNT_32_BIT,
4887 VK_SAMPLE_COUNT_64_BIT
4889 const VkExtent3D resolveExtent = {256u, 256u, 1};
4892 const std::string description ("Resolve from image to image");
4893 const std::string testName ("whole");
4896 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4897 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4898 params.src.image.extent = resolveExtent;
4899 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4900 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4901 params.dst.image.extent = resolveExtent;
4904 const VkImageSubresourceLayers sourceLayer =
4906 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
4907 0u, // uint32_t mipLevel;
4908 0u, // uint32_t baseArrayLayer;
4909 1u // uint32_t layerCount;
4911 const VkImageResolve testResolve =
4913 sourceLayer, // VkImageSubresourceLayers srcSubresource;
4914 {0, 0, 0}, // VkOffset3D srcOffset;
4915 sourceLayer, // VkImageSubresourceLayers dstSubresource;
4916 {0, 0, 0}, // VkOffset3D dstOffset;
4917 resolveExtent, // VkExtent3D extent;
4920 CopyRegion imageResolve;
4921 imageResolve.imageResolve = testResolve;
4922 params.regions.push_back(imageResolve);
4925 for (int samplesIndex = 0; samplesIndex < DE_LENGTH_OF_ARRAY(samples); ++samplesIndex)
4927 params.samples = samples[samplesIndex];
4928 std::ostringstream caseName;
4929 caseName << testName << "_" << getSampleCountCaseName(samples[samplesIndex]);
4930 resolveImageTests->addChild(new ResolveImageToImageTestCase(testCtx, caseName.str(), description, params));
4935 const std::string description ("Resolve from image to image");
4936 const std::string testName ("partial");
4939 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4940 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4941 params.src.image.extent = resolveExtent;
4942 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4943 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4944 params.dst.image.extent = resolveExtent;
4947 const VkImageSubresourceLayers sourceLayer =
4949 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
4950 0u, // uint32_t mipLevel;
4951 0u, // uint32_t baseArrayLayer;
4952 1u // uint32_t layerCount;
4954 const VkImageResolve testResolve =
4956 sourceLayer, // VkImageSubresourceLayers srcSubresource;
4957 {0, 0, 0}, // VkOffset3D srcOffset;
4958 sourceLayer, // VkImageSubresourceLayers dstSubresource;
4959 {64u, 64u, 0}, // VkOffset3D dstOffset;
4960 {128u, 128u, 1u}, // VkExtent3D extent;
4963 CopyRegion imageResolve;
4964 imageResolve.imageResolve = testResolve;
4965 params.regions.push_back(imageResolve);
4968 for (int samplesIndex = 0; samplesIndex < DE_LENGTH_OF_ARRAY(samples); ++samplesIndex)
4970 params.samples = samples[samplesIndex];
4971 std::ostringstream caseName;
4972 caseName << testName << "_" << getSampleCountCaseName(samples[samplesIndex]);
4973 resolveImageTests->addChild(new ResolveImageToImageTestCase(testCtx, caseName.str(), description, params));
4978 const std::string description ("Resolve from image to image");
4979 const std::string testName ("with_regions");
4982 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4983 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4984 params.src.image.extent = resolveExtent;
4985 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4986 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4987 params.dst.image.extent = resolveExtent;
4990 const VkImageSubresourceLayers sourceLayer =
4992 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
4993 0u, // uint32_t mipLevel;
4994 0u, // uint32_t baseArrayLayer;
4995 1u // uint32_t layerCount;
4998 for (int i = 0; i < 256; i += 64)
5000 const VkImageResolve testResolve =
5002 sourceLayer, // VkImageSubresourceLayers srcSubresource;
5003 {i, i, 0}, // VkOffset3D srcOffset;
5004 sourceLayer, // VkImageSubresourceLayers dstSubresource;
5005 {i, 0, 0}, // VkOffset3D dstOffset;
5006 {64u, 64u, 1u}, // VkExtent3D extent;
5009 CopyRegion imageResolve;
5010 imageResolve.imageResolve = testResolve;
5011 params.regions.push_back(imageResolve);
5015 for (int samplesIndex = 0; samplesIndex < DE_LENGTH_OF_ARRAY(samples); ++samplesIndex)
5017 params.samples = samples[samplesIndex];
5018 std::ostringstream caseName;
5019 caseName << testName << "_" << getSampleCountCaseName(samples[samplesIndex]);
5020 resolveImageTests->addChild(new ResolveImageToImageTestCase(testCtx, caseName.str(), description, params));
5025 const std::string description ("Resolve from image to image");
5026 const std::string testName ("whole_copy_before_resolving");
5029 params.src.image.imageType = VK_IMAGE_TYPE_2D;
5030 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5031 params.src.image.extent = defaultExtent;
5032 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
5033 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5034 params.dst.image.extent = defaultExtent;
5037 const VkImageSubresourceLayers sourceLayer =
5039 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
5040 0u, // uint32_t mipLevel;
5041 0u, // uint32_t baseArrayLayer;
5042 1u // uint32_t layerCount;
5045 const VkImageResolve testResolve =
5047 sourceLayer, // VkImageSubresourceLayers srcSubresource;
5048 {0, 0, 0}, // VkOffset3D srcOffset;
5049 sourceLayer, // VkImageSubresourceLayers dstSubresource;
5050 {0, 0, 0}, // VkOffset3D dstOffset;
5051 defaultExtent, // VkExtent3D extent;
5054 CopyRegion imageResolve;
5055 imageResolve.imageResolve = testResolve;
5056 params.regions.push_back(imageResolve);
5059 for (int samplesIndex = 0; samplesIndex < DE_LENGTH_OF_ARRAY(samples); ++samplesIndex)
5061 params.samples = samples[samplesIndex];
5062 std::ostringstream caseName;
5063 caseName << testName << "_" << getSampleCountCaseName(samples[samplesIndex]);
5064 resolveImageTests->addChild(new ResolveImageToImageTestCase(testCtx, caseName.str(), description, params, COPY_MS_IMAGE_TO_MS_IMAGE));
5069 const std::string description ("Resolve from image to image");
5070 const std::string testName ("whole_array_image");
5073 params.src.image.imageType = VK_IMAGE_TYPE_2D;
5074 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5075 params.src.image.extent = defaultExtent;
5076 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
5077 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5078 params.dst.image.extent = defaultExtent;
5079 params.dst.image.extent.depth = 5u;
5081 for (deUint32 layerNdx=0; layerNdx < params.dst.image.extent.depth; ++layerNdx)
5083 const VkImageSubresourceLayers sourceLayer =
5085 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
5086 0u, // uint32_t mipLevel;
5087 layerNdx, // uint32_t baseArrayLayer;
5088 1u // uint32_t layerCount;
5091 const VkImageResolve testResolve =
5093 sourceLayer, // VkImageSubresourceLayers srcSubresource;
5094 {0, 0, 0}, // VkOffset3D srcOffset;
5095 sourceLayer, // VkImageSubresourceLayers dstSubresource;
5096 {0, 0, 0}, // VkOffset3D dstOffset;
5097 defaultExtent, // VkExtent3D extent;
5100 CopyRegion imageResolve;
5101 imageResolve.imageResolve = testResolve;
5102 params.regions.push_back(imageResolve);
5105 for (int samplesIndex = 0; samplesIndex < DE_LENGTH_OF_ARRAY(samples); ++samplesIndex)
5107 params.samples = samples[samplesIndex];
5108 std::ostringstream caseName;
5109 caseName << testName << "_" << getSampleCountCaseName(samples[samplesIndex]);
5110 resolveImageTests->addChild(new ResolveImageToImageTestCase(testCtx, caseName.str(), description, params, COPY_MS_IMAGE_TO_ARRAY_MS_IMAGE));
5114 copiesAndBlittingTests->addChild(imageToImageTests.release());
5115 copiesAndBlittingTests->addChild(imageToBufferTests.release());
5116 copiesAndBlittingTests->addChild(bufferToImageTests.release());
5117 copiesAndBlittingTests->addChild(bufferToBufferTests.release());
5118 copiesAndBlittingTests->addChild(blittingImageTests.release());
5119 copiesAndBlittingTests->addChild(resolveImageTests.release());
5121 return copiesAndBlittingTests.release();