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"
30 #include "tcuImageCompare.hpp"
31 #include "tcuTexture.hpp"
32 #include "tcuTextureUtil.hpp"
33 #include "tcuVectorType.hpp"
34 #include "tcuVectorUtil.hpp"
35 #include "tcuTexLookupVerifier.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 "vktTestGroupUtil.hpp"
45 #include "vkTypeUtil.hpp"
58 MIRROR_MODE_X = (1<<0),
59 MIRROR_MODE_Y = (1<<1),
60 MIRROR_MODE_XY = MIRROR_MODE_X | MIRROR_MODE_Y,
72 VkImageAspectFlags getAspectFlags (tcu::TextureFormat format)
74 VkImageAspectFlags aspectFlag = 0;
75 aspectFlag |= (tcu::hasDepthComponent(format.order)? VK_IMAGE_ASPECT_DEPTH_BIT : 0);
76 aspectFlag |= (tcu::hasStencilComponent(format.order)? VK_IMAGE_ASPECT_STENCIL_BIT : 0);
79 aspectFlag = VK_IMAGE_ASPECT_COLOR_BIT;
84 // This is effectively same as vk::isFloatFormat(mapTextureFormat(format))
85 // except that it supports some formats that are not mappable to VkFormat.
86 // When we are checking combined depth and stencil formats, each aspect is
87 // checked separately, and in some cases we construct PBA with a format that
88 // is not mappable to VkFormat.
89 bool isFloatFormat (tcu::TextureFormat format)
91 return tcu::getTextureChannelClass(format.type) == tcu::TEXTURECHANNELCLASS_FLOATING_POINT;
96 VkBufferCopy bufferCopy;
97 VkImageCopy imageCopy;
98 VkBufferImageCopy bufferImageCopy;
99 VkImageBlit imageBlit;
100 VkImageResolve imageResolve;
105 VkImageType imageType;
108 VkImageLayout operationLayout;
123 std::vector<CopyRegion> regions;
128 VkSampleCountFlagBits samples;
132 inline deUint32 getArraySize(const ImageParms& parms)
134 return (parms.imageType == VK_IMAGE_TYPE_2D) ? parms.extent.depth : 1u;
137 inline VkExtent3D getExtent3D(const ImageParms& parms)
139 const VkExtent3D extent =
143 (parms.imageType == VK_IMAGE_TYPE_2D) ? 1u : parms.extent.depth
148 const tcu::TextureFormat mapCombinedToDepthTransferFormat (const tcu::TextureFormat& combinedFormat)
150 tcu::TextureFormat format;
151 switch (combinedFormat.type)
153 case tcu::TextureFormat::UNSIGNED_INT_16_8_8:
154 format = tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::UNORM_INT16);
156 case tcu::TextureFormat::UNSIGNED_INT_24_8_REV:
157 format = tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::UNSIGNED_INT_24_8_REV);
159 case tcu::TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV:
160 format = tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::FLOAT);
169 class CopiesAndBlittingTestInstance : public vkt::TestInstance
172 CopiesAndBlittingTestInstance (Context& context,
173 TestParams testParams);
174 virtual tcu::TestStatus iterate (void) = 0;
178 FILL_MODE_GRADIENT = 0,
181 FILL_MODE_MULTISAMPLE,
187 const TestParams m_params;
189 Move<VkCommandPool> m_cmdPool;
190 Move<VkCommandBuffer> m_cmdBuffer;
191 Move<VkFence> m_fence;
192 de::MovePtr<tcu::TextureLevel> m_sourceTextureLevel;
193 de::MovePtr<tcu::TextureLevel> m_destinationTextureLevel;
194 de::MovePtr<tcu::TextureLevel> m_expectedTextureLevel;
196 VkCommandBufferBeginInfo m_cmdBufferBeginInfo;
198 void generateBuffer (tcu::PixelBufferAccess buffer, int width, int height, int depth = 1, FillMode = FILL_MODE_GRADIENT);
199 virtual void generateExpectedResult (void);
200 void uploadBuffer (tcu::ConstPixelBufferAccess bufferAccess, const Allocation& bufferAlloc);
201 void uploadImage (const tcu::ConstPixelBufferAccess& src, VkImage dst, const ImageParms& parms);
202 virtual tcu::TestStatus checkTestResult (tcu::ConstPixelBufferAccess result);
203 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region) = 0;
204 deUint32 calculateSize (tcu::ConstPixelBufferAccess src) const
206 return src.getWidth() * src.getHeight() * src.getDepth() * tcu::getPixelSize(src.getFormat());
209 de::MovePtr<tcu::TextureLevel> readImage (vk::VkImage image,
210 const ImageParms& imageParms);
211 void submitCommandsAndWait (const DeviceInterface& vk,
212 const VkDevice device,
214 const VkCommandBuffer& cmdBuffer);
217 void uploadImageAspect (const tcu::ConstPixelBufferAccess& src,
219 const ImageParms& parms);
220 void readImageAspect (vk::VkImage src,
221 const tcu::PixelBufferAccess& dst,
222 const ImageParms& parms);
225 CopiesAndBlittingTestInstance::CopiesAndBlittingTestInstance (Context& context, TestParams testParams)
226 : vkt::TestInstance (context)
227 , m_params (testParams)
229 const DeviceInterface& vk = context.getDeviceInterface();
230 const VkDevice vkDevice = context.getDevice();
231 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
233 // Create command pool
234 m_cmdPool = createCommandPool(vk, vkDevice, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, queueFamilyIndex);
236 // Create command buffer
237 m_cmdBuffer = allocateCommandBuffer(vk, vkDevice, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
240 m_fence = createFence(vk, vkDevice);
243 void CopiesAndBlittingTestInstance::generateBuffer (tcu::PixelBufferAccess buffer, int width, int height, int depth, FillMode mode)
245 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(buffer.getFormat().type);
246 tcu::Vec4 maxValue (1.0f);
248 if (buffer.getFormat().order == tcu::TextureFormat::S)
250 // Stencil-only is stored in the first component. Stencil is always 8 bits.
251 maxValue.x() = 1 << 8;
253 else if (buffer.getFormat().order == tcu::TextureFormat::DS)
255 // In a combined format, fillWithComponentGradients expects stencil in the fourth component.
256 maxValue.w() = 1 << 8;
258 else if (channelClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER || channelClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER)
260 // The tcu::Vectors we use as pixels are 32-bit, so clamp to that.
261 const tcu::IVec4 bits = tcu::min(tcu::getTextureFormatBitDepth(buffer.getFormat()), tcu::IVec4(32));
262 const int signBit = (channelClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER ? 1 : 0);
264 for (int i = 0; i < 4; ++i)
267 maxValue[i] = static_cast<float>((1 << (bits[i] - signBit)) - 1);
271 if (mode == FILL_MODE_GRADIENT)
273 tcu::fillWithComponentGradients(buffer, tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), maxValue);
277 const tcu::Vec4 redColor (maxValue.x(), 0.0, 0.0, maxValue.w());
278 const tcu::Vec4 greenColor (0.0, maxValue.y(), 0.0, maxValue.w());
279 const tcu::Vec4 blueColor (0.0, 0.0, maxValue.z(), maxValue.w());
280 const tcu::Vec4 whiteColor (maxValue.x(), maxValue.y(), maxValue.z(), maxValue.w());
282 for (int z = 0; z < depth; ++z)
283 for (int y = 0; y < height; ++y)
284 for (int x = 0; x < width; ++x)
288 case FILL_MODE_WHITE:
289 if (tcu::isCombinedDepthStencilType(buffer.getFormat().type))
291 buffer.setPixDepth(1.0f, x, y, z);
292 if (tcu::hasStencilComponent(buffer.getFormat().order))
293 buffer.setPixStencil(255, x, y, z);
296 buffer.setPixel(whiteColor, x, y, z);
300 if (tcu::isCombinedDepthStencilType(buffer.getFormat().type))
302 buffer.setPixDepth(redColor[x % 4], x, y, z);
303 if (tcu::hasStencilComponent(buffer.getFormat().order))
304 buffer.setPixStencil(255 * (int)redColor[y % 4], x, y, z);
307 buffer.setPixel(redColor, x, y, z);
310 case FILL_MODE_MULTISAMPLE:
312 float xScaled = static_cast<float>(x) / static_cast<float>(width);
313 float yScaled = static_cast<float>(y) / static_cast<float>(height);
314 buffer.setPixel((xScaled == yScaled) ? tcu::Vec4(0.0, 0.5, 0.5, 1.0) : ((xScaled > yScaled) ? greenColor : blueColor), x, y, z);
324 void CopiesAndBlittingTestInstance::uploadBuffer (tcu::ConstPixelBufferAccess bufferAccess, const Allocation& bufferAlloc)
326 const DeviceInterface& vk = m_context.getDeviceInterface();
327 const VkDevice vkDevice = m_context.getDevice();
328 const deUint32 bufferSize = calculateSize(bufferAccess);
331 deMemcpy(bufferAlloc.getHostPtr(), bufferAccess.getDataPtr(), bufferSize);
332 flushMappedMemoryRange(vk, vkDevice, bufferAlloc.getMemory(), bufferAlloc.getOffset(), bufferSize);
335 void CopiesAndBlittingTestInstance::uploadImageAspect (const tcu::ConstPixelBufferAccess& imageAccess, const VkImage& image, const ImageParms& parms)
337 const DeviceInterface& vk = m_context.getDeviceInterface();
338 const VkDevice vkDevice = m_context.getDevice();
339 const VkQueue queue = m_context.getUniversalQueue();
340 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
341 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 comparison", 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 comparison", 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 imageParms.operationLayout, // 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 imageParms.operationLayout, // 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 if ((m_params.dst.image.imageType == VK_IMAGE_TYPE_3D && m_params.src.image.imageType == VK_IMAGE_TYPE_2D) ||
736 (m_params.dst.image.imageType == VK_IMAGE_TYPE_2D && m_params.src.image.imageType == VK_IMAGE_TYPE_3D))
738 if (std::find(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), "VK_KHR_maintenance1") == context.getDeviceExtensions().end())
739 TCU_THROW(NotSupportedError, "Extension VK_KHR_maintenance1 not supported");
742 VkImageFormatProperties properties;
743 if ((context.getInstanceInterface().getPhysicalDeviceImageFormatProperties (context.getPhysicalDevice(),
744 m_params.src.image.format,
745 m_params.src.image.imageType,
746 VK_IMAGE_TILING_OPTIMAL,
747 VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
749 &properties) == VK_ERROR_FORMAT_NOT_SUPPORTED) ||
750 (context.getInstanceInterface().getPhysicalDeviceImageFormatProperties (context.getPhysicalDevice(),
751 m_params.dst.image.format,
752 m_params.dst.image.imageType,
753 VK_IMAGE_TILING_OPTIMAL,
754 VK_IMAGE_USAGE_TRANSFER_DST_BIT,
756 &properties) == VK_ERROR_FORMAT_NOT_SUPPORTED))
758 TCU_THROW(NotSupportedError, "Format not supported");
761 // Create source image
763 const VkImageCreateInfo sourceImageParams =
765 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
766 DE_NULL, // const void* pNext;
767 0u, // VkImageCreateFlags flags;
768 m_params.src.image.imageType, // VkImageType imageType;
769 m_params.src.image.format, // VkFormat format;
770 getExtent3D(m_params.src.image), // VkExtent3D extent;
771 1u, // deUint32 mipLevels;
772 getArraySize(m_params.src.image), // deUint32 arraySize;
773 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
774 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
775 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
776 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
777 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
778 1u, // deUint32 queueFamilyCount;
779 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
780 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
783 m_source = createImage(vk, vkDevice, &sourceImageParams);
784 m_sourceImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::Any);
785 VK_CHECK(vk.bindImageMemory(vkDevice, *m_source, m_sourceImageAlloc->getMemory(), m_sourceImageAlloc->getOffset()));
788 // Create destination image
790 const VkImageCreateInfo destinationImageParams =
792 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
793 DE_NULL, // const void* pNext;
794 0u, // VkImageCreateFlags flags;
795 m_params.dst.image.imageType, // VkImageType imageType;
796 m_params.dst.image.format, // VkFormat format;
797 getExtent3D(m_params.dst.image), // VkExtent3D extent;
798 1u, // deUint32 mipLevels;
799 getArraySize(m_params.dst.image), // deUint32 arraySize;
800 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
801 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
802 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
803 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
804 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
805 1u, // deUint32 queueFamilyCount;
806 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
807 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
810 m_destination = createImage(vk, vkDevice, &destinationImageParams);
811 m_destinationImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::Any);
812 VK_CHECK(vk.bindImageMemory(vkDevice, *m_destination, m_destinationImageAlloc->getMemory(), m_destinationImageAlloc->getOffset()));
816 tcu::TestStatus CopyImageToImage::iterate (void)
818 const tcu::TextureFormat srcTcuFormat = mapVkFormat(m_params.src.image.format);
819 const tcu::TextureFormat dstTcuFormat = mapVkFormat(m_params.dst.image.format);
820 m_sourceTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(srcTcuFormat,
821 (int)m_params.src.image.extent.width,
822 (int)m_params.src.image.extent.height,
823 (int)m_params.src.image.extent.depth));
824 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);
825 m_destinationTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(dstTcuFormat,
826 (int)m_params.dst.image.extent.width,
827 (int)m_params.dst.image.extent.height,
828 (int)m_params.dst.image.extent.depth));
829 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);
830 generateExpectedResult();
832 uploadImage(m_sourceTextureLevel->getAccess(), m_source.get(), m_params.src.image);
833 uploadImage(m_destinationTextureLevel->getAccess(), m_destination.get(), m_params.dst.image);
835 const DeviceInterface& vk = m_context.getDeviceInterface();
836 const VkDevice vkDevice = m_context.getDevice();
837 const VkQueue queue = m_context.getUniversalQueue();
839 std::vector<VkImageCopy> imageCopies;
840 for (deUint32 i = 0; i < m_params.regions.size(); i++)
841 imageCopies.push_back(m_params.regions[i].imageCopy);
843 const VkImageMemoryBarrier imageBarriers[] =
847 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
848 DE_NULL, // const void* pNext;
849 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
850 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
851 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
852 m_params.src.image.operationLayout, // VkImageLayout newLayout;
853 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
854 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
855 m_source.get(), // VkImage image;
856 { // VkImageSubresourceRange subresourceRange;
857 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
858 0u, // deUint32 baseMipLevel;
859 1u, // deUint32 mipLevels;
860 0u, // deUint32 baseArraySlice;
861 getArraySize(m_params.src.image)// deUint32 arraySize;
866 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
867 DE_NULL, // const void* pNext;
868 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
869 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
870 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
871 m_params.dst.image.operationLayout, // VkImageLayout newLayout;
872 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
873 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
874 m_destination.get(), // VkImage image;
875 { // VkImageSubresourceRange subresourceRange;
876 getAspectFlags(dstTcuFormat), // VkImageAspectFlags aspectMask;
877 0u, // deUint32 baseMipLevel;
878 1u, // deUint32 mipLevels;
879 0u, // deUint32 baseArraySlice;
880 getArraySize(m_params.dst.image)// deUint32 arraySize;
885 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
887 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
888 DE_NULL, // const void* pNext;
889 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
890 (const VkCommandBufferInheritanceInfo*)DE_NULL,
893 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
894 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);
895 vk.cmdCopyImage(*m_cmdBuffer, m_source.get(), m_params.src.image.operationLayout, m_destination.get(), m_params.dst.image.operationLayout, (deUint32)m_params.regions.size(), imageCopies.data());
896 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
898 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
900 de::MovePtr<tcu::TextureLevel> resultTextureLevel = readImage(*m_destination, m_params.dst.image);
902 return checkTestResult(resultTextureLevel->getAccess());
905 tcu::TestStatus CopyImageToImage::checkTestResult (tcu::ConstPixelBufferAccess result)
907 const tcu::Vec4 fThreshold (0.0f);
908 const tcu::UVec4 uThreshold (0u);
910 if (tcu::isCombinedDepthStencilType(result.getFormat().type))
912 if (tcu::hasDepthComponent(result.getFormat().order))
914 const tcu::Sampler::DepthStencilMode mode = tcu::Sampler::MODE_DEPTH;
915 const tcu::ConstPixelBufferAccess depthResult = tcu::getEffectiveDepthStencilAccess(result, mode);
916 const tcu::ConstPixelBufferAccess expectedResult = tcu::getEffectiveDepthStencilAccess(m_expectedTextureLevel->getAccess(), mode);
918 if (isFloatFormat(result.getFormat()))
920 if (!tcu::floatThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparison", expectedResult, depthResult, fThreshold, tcu::COMPARE_LOG_RESULT))
921 return tcu::TestStatus::fail("CopiesAndBlitting test");
925 if (!tcu::intThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparison", expectedResult, depthResult, uThreshold, tcu::COMPARE_LOG_RESULT))
926 return tcu::TestStatus::fail("CopiesAndBlitting test");
930 if (tcu::hasStencilComponent(result.getFormat().order))
932 const tcu::Sampler::DepthStencilMode mode = tcu::Sampler::MODE_STENCIL;
933 const tcu::ConstPixelBufferAccess stencilResult = tcu::getEffectiveDepthStencilAccess(result, mode);
934 const tcu::ConstPixelBufferAccess expectedResult = tcu::getEffectiveDepthStencilAccess(m_expectedTextureLevel->getAccess(), mode);
936 if (isFloatFormat(result.getFormat()))
938 if (!tcu::floatThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparison", expectedResult, stencilResult, fThreshold, tcu::COMPARE_LOG_RESULT))
939 return tcu::TestStatus::fail("CopiesAndBlitting test");
943 if (!tcu::intThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparison", expectedResult, stencilResult, uThreshold, tcu::COMPARE_LOG_RESULT))
944 return tcu::TestStatus::fail("CopiesAndBlitting test");
950 if (isFloatFormat(result.getFormat()))
952 if (!tcu::floatThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparison", m_expectedTextureLevel->getAccess(), result, fThreshold, tcu::COMPARE_LOG_RESULT))
953 return tcu::TestStatus::fail("CopiesAndBlitting test");
957 if (!tcu::intThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparison", m_expectedTextureLevel->getAccess(), result, uThreshold, tcu::COMPARE_LOG_RESULT))
958 return tcu::TestStatus::fail("CopiesAndBlitting test");
962 return tcu::TestStatus::pass("CopiesAndBlitting test");
965 void CopyImageToImage::copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region)
967 VkOffset3D srcOffset = region.imageCopy.srcOffset;
968 VkOffset3D dstOffset = region.imageCopy.dstOffset;
969 VkExtent3D extent = region.imageCopy.extent;
971 if (m_params.src.image.imageType == VK_IMAGE_TYPE_3D && m_params.dst.image.imageType == VK_IMAGE_TYPE_2D)
972 dstOffset.z = srcOffset.z;
973 if (m_params.src.image.imageType == VK_IMAGE_TYPE_2D && m_params.dst.image.imageType == VK_IMAGE_TYPE_3D)
975 srcOffset.z = dstOffset.z;
976 extent.depth = std::max(region.imageCopy.extent.depth, region.imageCopy.srcSubresource.layerCount);
980 if (tcu::isCombinedDepthStencilType(src.getFormat().type))
982 DE_ASSERT(src.getFormat() == dst.getFormat());
985 if (tcu::hasDepthComponent(src.getFormat().order))
987 const tcu::ConstPixelBufferAccess srcSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(src, srcOffset.x, srcOffset.y, srcOffset.z, extent.width, extent.height, extent.depth), tcu::Sampler::MODE_DEPTH);
988 const tcu::PixelBufferAccess dstSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(dst, dstOffset.x, dstOffset.y, dstOffset.z, extent.width, extent.height, extent.depth), tcu::Sampler::MODE_DEPTH);
989 tcu::copy(dstSubRegion, srcSubRegion);
993 if (tcu::hasStencilComponent(src.getFormat().order))
995 const tcu::ConstPixelBufferAccess srcSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(src, srcOffset.x, srcOffset.y, srcOffset.z, extent.width, extent.height, extent.depth), tcu::Sampler::MODE_STENCIL);
996 const tcu::PixelBufferAccess dstSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(dst, dstOffset.x, dstOffset.y, dstOffset.z, extent.width, extent.height, extent.depth), tcu::Sampler::MODE_STENCIL);
997 tcu::copy(dstSubRegion, srcSubRegion);
1002 const tcu::ConstPixelBufferAccess srcSubRegion = tcu::getSubregion(src, srcOffset.x, srcOffset.y, srcOffset.z, extent.width, extent.height, extent.depth);
1003 // CopyImage acts like a memcpy. Replace the destination format with the srcformat to use a memcpy.
1004 const tcu::PixelBufferAccess dstWithSrcFormat (srcSubRegion.getFormat(), dst.getSize(), dst.getDataPtr());
1005 const tcu::PixelBufferAccess dstSubRegion = tcu::getSubregion(dstWithSrcFormat, dstOffset.x, dstOffset.y, dstOffset.z, extent.width, extent.height, extent.depth);
1007 tcu::copy(dstSubRegion, srcSubRegion);
1011 class CopyImageToImageTestCase : public vkt::TestCase
1014 CopyImageToImageTestCase (tcu::TestContext& testCtx,
1015 const std::string& name,
1016 const std::string& description,
1017 const TestParams params)
1018 : vkt::TestCase (testCtx, name, description)
1022 virtual TestInstance* createInstance (Context& context) const
1024 return new CopyImageToImage(context, m_params);
1027 TestParams m_params;
1030 // Copy from buffer to buffer.
1032 class CopyBufferToBuffer : public CopiesAndBlittingTestInstance
1035 CopyBufferToBuffer (Context& context, TestParams params);
1036 virtual tcu::TestStatus iterate (void);
1038 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess, tcu::PixelBufferAccess, CopyRegion);
1039 Move<VkBuffer> m_source;
1040 de::MovePtr<Allocation> m_sourceBufferAlloc;
1041 Move<VkBuffer> m_destination;
1042 de::MovePtr<Allocation> m_destinationBufferAlloc;
1045 CopyBufferToBuffer::CopyBufferToBuffer (Context& context, TestParams params)
1046 : CopiesAndBlittingTestInstance (context, params)
1048 const DeviceInterface& vk = context.getDeviceInterface();
1049 const VkDevice vkDevice = context.getDevice();
1050 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
1051 Allocator& memAlloc = context.getDefaultAllocator();
1053 // Create source buffer
1055 const VkBufferCreateInfo sourceBufferParams =
1057 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
1058 DE_NULL, // const void* pNext;
1059 0u, // VkBufferCreateFlags flags;
1060 m_params.src.buffer.size, // VkDeviceSize size;
1061 VK_BUFFER_USAGE_TRANSFER_SRC_BIT, // VkBufferUsageFlags usage;
1062 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1063 1u, // deUint32 queueFamilyIndexCount;
1064 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1067 m_source = createBuffer(vk, vkDevice, &sourceBufferParams);
1068 m_sourceBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::HostVisible);
1069 VK_CHECK(vk.bindBufferMemory(vkDevice, *m_source, m_sourceBufferAlloc->getMemory(), m_sourceBufferAlloc->getOffset()));
1072 // Create destination buffer
1074 const VkBufferCreateInfo destinationBufferParams =
1076 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
1077 DE_NULL, // const void* pNext;
1078 0u, // VkBufferCreateFlags flags;
1079 m_params.dst.buffer.size, // VkDeviceSize size;
1080 VK_BUFFER_USAGE_TRANSFER_DST_BIT, // VkBufferUsageFlags usage;
1081 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1082 1u, // deUint32 queueFamilyIndexCount;
1083 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1086 m_destination = createBuffer(vk, vkDevice, &destinationBufferParams);
1087 m_destinationBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::HostVisible);
1088 VK_CHECK(vk.bindBufferMemory(vkDevice, *m_destination, m_destinationBufferAlloc->getMemory(), m_destinationBufferAlloc->getOffset()));
1092 tcu::TestStatus CopyBufferToBuffer::iterate (void)
1094 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
1095 m_sourceTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(mapVkFormat(VK_FORMAT_R32_UINT), srcLevelWidth, 1));
1096 generateBuffer(m_sourceTextureLevel->getAccess(), srcLevelWidth, 1, 1, FILL_MODE_RED);
1098 const int dstLevelWidth = (int)(m_params.dst.buffer.size/4);
1099 m_destinationTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(mapVkFormat(VK_FORMAT_R32_UINT), dstLevelWidth, 1));
1100 generateBuffer(m_destinationTextureLevel->getAccess(), dstLevelWidth, 1, 1, FILL_MODE_WHITE);
1102 generateExpectedResult();
1104 uploadBuffer(m_sourceTextureLevel->getAccess(), *m_sourceBufferAlloc);
1105 uploadBuffer(m_destinationTextureLevel->getAccess(), *m_destinationBufferAlloc);
1107 const DeviceInterface& vk = m_context.getDeviceInterface();
1108 const VkDevice vkDevice = m_context.getDevice();
1109 const VkQueue queue = m_context.getUniversalQueue();
1111 const VkBufferMemoryBarrier srcBufferBarrier =
1113 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
1114 DE_NULL, // const void* pNext;
1115 VK_ACCESS_HOST_WRITE_BIT, // VkAccessFlags srcAccessMask;
1116 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
1117 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1118 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1119 *m_source, // VkBuffer buffer;
1120 0u, // VkDeviceSize offset;
1121 m_params.src.buffer.size // VkDeviceSize size;
1124 const VkBufferMemoryBarrier dstBufferBarrier =
1126 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
1127 DE_NULL, // const void* pNext;
1128 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
1129 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
1130 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1131 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1132 *m_destination, // VkBuffer buffer;
1133 0u, // VkDeviceSize offset;
1134 m_params.dst.buffer.size // VkDeviceSize size;
1137 std::vector<VkBufferCopy> bufferCopies;
1138 for (deUint32 i = 0; i < m_params.regions.size(); i++)
1139 bufferCopies.push_back(m_params.regions[i].bufferCopy);
1141 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
1143 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
1144 DE_NULL, // const void* pNext;
1145 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
1146 (const VkCommandBufferInheritanceInfo*)DE_NULL,
1149 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
1150 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);
1151 vk.cmdCopyBuffer(*m_cmdBuffer, m_source.get(), m_destination.get(), (deUint32)m_params.regions.size(), &bufferCopies[0]);
1152 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);
1153 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1154 submitCommandsAndWait(vk, vkDevice, queue, *m_cmdBuffer);
1159 de::MovePtr<tcu::TextureLevel> resultLevel (new tcu::TextureLevel(mapVkFormat(VK_FORMAT_R32_UINT), dstLevelWidth, 1));
1160 invalidateMappedMemoryRange(vk, vkDevice, m_destinationBufferAlloc->getMemory(), m_destinationBufferAlloc->getOffset(), m_params.dst.buffer.size);
1161 tcu::copy(*resultLevel, tcu::ConstPixelBufferAccess(resultLevel->getFormat(), resultLevel->getSize(), m_destinationBufferAlloc->getHostPtr()));
1163 return checkTestResult(resultLevel->getAccess());
1166 void CopyBufferToBuffer::copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region)
1168 deMemcpy((deUint8*) dst.getDataPtr() + region.bufferCopy.dstOffset,
1169 (deUint8*) src.getDataPtr() + region.bufferCopy.srcOffset,
1170 (size_t)region.bufferCopy.size);
1173 class BufferToBufferTestCase : public vkt::TestCase
1176 BufferToBufferTestCase (tcu::TestContext& testCtx,
1177 const std::string& name,
1178 const std::string& description,
1179 const TestParams params)
1180 : vkt::TestCase (testCtx, name, description)
1184 virtual TestInstance* createInstance (Context& context) const
1186 return new CopyBufferToBuffer(context, m_params);
1189 TestParams m_params;
1192 // Copy from image to buffer.
1194 class CopyImageToBuffer : public CopiesAndBlittingTestInstance
1197 CopyImageToBuffer (Context& context,
1198 TestParams testParams);
1199 virtual tcu::TestStatus iterate (void);
1201 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region);
1203 tcu::TextureFormat m_textureFormat;
1204 VkDeviceSize m_bufferSize;
1206 Move<VkImage> m_source;
1207 de::MovePtr<Allocation> m_sourceImageAlloc;
1208 Move<VkBuffer> m_destination;
1209 de::MovePtr<Allocation> m_destinationBufferAlloc;
1212 CopyImageToBuffer::CopyImageToBuffer (Context& context, TestParams testParams)
1213 : CopiesAndBlittingTestInstance(context, testParams)
1214 , m_textureFormat(mapVkFormat(testParams.src.image.format))
1215 , m_bufferSize(m_params.dst.buffer.size * tcu::getPixelSize(m_textureFormat))
1217 const DeviceInterface& vk = context.getDeviceInterface();
1218 const VkDevice vkDevice = context.getDevice();
1219 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
1220 Allocator& memAlloc = context.getDefaultAllocator();
1222 // Create source image
1224 const VkImageCreateInfo sourceImageParams =
1226 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
1227 DE_NULL, // const void* pNext;
1228 0u, // VkImageCreateFlags flags;
1229 m_params.src.image.imageType, // VkImageType imageType;
1230 m_params.src.image.format, // VkFormat format;
1231 getExtent3D(m_params.src.image), // VkExtent3D extent;
1232 1u, // deUint32 mipLevels;
1233 getArraySize(m_params.src.image), // deUint32 arraySize;
1234 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
1235 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
1236 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1237 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
1238 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1239 1u, // deUint32 queueFamilyCount;
1240 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1241 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
1244 m_source = createImage(vk, vkDevice, &sourceImageParams);
1245 m_sourceImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::Any);
1246 VK_CHECK(vk.bindImageMemory(vkDevice, *m_source, m_sourceImageAlloc->getMemory(), m_sourceImageAlloc->getOffset()));
1249 // Create destination buffer
1251 const VkBufferCreateInfo destinationBufferParams =
1253 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
1254 DE_NULL, // const void* pNext;
1255 0u, // VkBufferCreateFlags flags;
1256 m_bufferSize, // VkDeviceSize size;
1257 VK_BUFFER_USAGE_TRANSFER_DST_BIT, // VkBufferUsageFlags usage;
1258 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1259 1u, // deUint32 queueFamilyIndexCount;
1260 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1263 m_destination = createBuffer(vk, vkDevice, &destinationBufferParams);
1264 m_destinationBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::HostVisible);
1265 VK_CHECK(vk.bindBufferMemory(vkDevice, *m_destination, m_destinationBufferAlloc->getMemory(), m_destinationBufferAlloc->getOffset()));
1269 tcu::TestStatus CopyImageToBuffer::iterate (void)
1271 m_sourceTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(m_textureFormat,
1272 m_params.src.image.extent.width,
1273 m_params.src.image.extent.height,
1274 m_params.src.image.extent.depth));
1275 generateBuffer(m_sourceTextureLevel->getAccess(), m_params.src.image.extent.width, m_params.src.image.extent.height, m_params.src.image.extent.depth);
1276 m_destinationTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(m_textureFormat, (int)m_params.dst.buffer.size, 1));
1277 generateBuffer(m_destinationTextureLevel->getAccess(), (int)m_params.dst.buffer.size, 1, 1);
1279 generateExpectedResult();
1281 uploadImage(m_sourceTextureLevel->getAccess(), *m_source, m_params.src.image);
1282 uploadBuffer(m_destinationTextureLevel->getAccess(), *m_destinationBufferAlloc);
1284 const DeviceInterface& vk = m_context.getDeviceInterface();
1285 const VkDevice vkDevice = m_context.getDevice();
1286 const VkQueue queue = m_context.getUniversalQueue();
1288 // Barriers for copying image to buffer
1289 const VkImageMemoryBarrier imageBarrier =
1291 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
1292 DE_NULL, // const void* pNext;
1293 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
1294 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
1295 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
1296 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // VkImageLayout newLayout;
1297 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1298 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1299 *m_source, // VkImage image;
1300 { // VkImageSubresourceRange subresourceRange;
1301 getAspectFlags(m_textureFormat), // VkImageAspectFlags aspectMask;
1302 0u, // deUint32 baseMipLevel;
1303 1u, // deUint32 mipLevels;
1304 0u, // deUint32 baseArraySlice;
1305 1u // deUint32 arraySize;
1309 const VkBufferMemoryBarrier bufferBarrier =
1311 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
1312 DE_NULL, // const void* pNext;
1313 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
1314 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
1315 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1316 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1317 *m_destination, // VkBuffer buffer;
1318 0u, // VkDeviceSize offset;
1319 m_bufferSize // VkDeviceSize size;
1322 // Copy from image to buffer
1323 std::vector<VkBufferImageCopy> bufferImageCopies;
1324 for (deUint32 i = 0; i < m_params.regions.size(); i++)
1325 bufferImageCopies.push_back(m_params.regions[i].bufferImageCopy);
1327 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
1329 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
1330 DE_NULL, // const void* pNext;
1331 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
1332 (const VkCommandBufferInheritanceInfo*)DE_NULL,
1335 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
1336 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);
1337 vk.cmdCopyImageToBuffer(*m_cmdBuffer, m_source.get(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, m_destination.get(), (deUint32)m_params.regions.size(), &bufferImageCopies[0]);
1338 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);
1339 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1341 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
1344 de::MovePtr<tcu::TextureLevel> resultLevel (new tcu::TextureLevel(m_textureFormat, (int)m_params.dst.buffer.size, 1));
1345 invalidateMappedMemoryRange(vk, vkDevice, m_destinationBufferAlloc->getMemory(), m_destinationBufferAlloc->getOffset(), m_bufferSize);
1346 tcu::copy(*resultLevel, tcu::ConstPixelBufferAccess(resultLevel->getFormat(), resultLevel->getSize(), m_destinationBufferAlloc->getHostPtr()));
1348 return checkTestResult(resultLevel->getAccess());
1351 class CopyImageToBufferTestCase : public vkt::TestCase
1354 CopyImageToBufferTestCase (tcu::TestContext& testCtx,
1355 const std::string& name,
1356 const std::string& description,
1357 const TestParams params)
1358 : vkt::TestCase (testCtx, name, description)
1362 virtual TestInstance* createInstance (Context& context) const
1364 return new CopyImageToBuffer(context, m_params);
1367 TestParams m_params;
1370 void CopyImageToBuffer::copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region)
1372 deUint32 rowLength = region.bufferImageCopy.bufferRowLength;
1374 rowLength = region.bufferImageCopy.imageExtent.width;
1376 deUint32 imageHeight = region.bufferImageCopy.bufferImageHeight;
1378 imageHeight = region.bufferImageCopy.imageExtent.height;
1380 const int texelSize = src.getFormat().getPixelSize();
1381 const VkExtent3D extent = region.bufferImageCopy.imageExtent;
1382 const VkOffset3D srcOffset = region.bufferImageCopy.imageOffset;
1383 const int texelOffset = (int) region.bufferImageCopy.bufferOffset / texelSize;
1385 for (deUint32 z = 0; z < extent.depth; z++)
1387 for (deUint32 y = 0; y < extent.height; y++)
1389 int texelIndex = texelOffset + (z * imageHeight + y) * rowLength;
1390 const tcu::ConstPixelBufferAccess srcSubRegion = tcu::getSubregion(src, srcOffset.x, srcOffset.y + y, srcOffset.z + z,
1391 region.bufferImageCopy.imageExtent.width, 1, 1);
1392 const tcu::PixelBufferAccess dstSubRegion = tcu::getSubregion(dst, texelIndex, 0, region.bufferImageCopy.imageExtent.width, 1);
1393 tcu::copy(dstSubRegion, srcSubRegion);
1398 // Copy from buffer to image.
1400 class CopyBufferToImage : public CopiesAndBlittingTestInstance
1403 CopyBufferToImage (Context& context,
1404 TestParams testParams);
1405 virtual tcu::TestStatus iterate (void);
1407 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region);
1409 tcu::TextureFormat m_textureFormat;
1410 VkDeviceSize m_bufferSize;
1412 Move<VkBuffer> m_source;
1413 de::MovePtr<Allocation> m_sourceBufferAlloc;
1414 Move<VkImage> m_destination;
1415 de::MovePtr<Allocation> m_destinationImageAlloc;
1418 CopyBufferToImage::CopyBufferToImage (Context& context, TestParams testParams)
1419 : CopiesAndBlittingTestInstance(context, testParams)
1420 , m_textureFormat(mapVkFormat(testParams.dst.image.format))
1421 , m_bufferSize(m_params.src.buffer.size * tcu::getPixelSize(m_textureFormat))
1423 const DeviceInterface& vk = context.getDeviceInterface();
1424 const VkDevice vkDevice = context.getDevice();
1425 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
1426 Allocator& memAlloc = context.getDefaultAllocator();
1428 // Create source buffer
1430 const VkBufferCreateInfo sourceBufferParams =
1432 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
1433 DE_NULL, // const void* pNext;
1434 0u, // VkBufferCreateFlags flags;
1435 m_bufferSize, // VkDeviceSize size;
1436 VK_BUFFER_USAGE_TRANSFER_SRC_BIT, // VkBufferUsageFlags usage;
1437 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1438 1u, // deUint32 queueFamilyIndexCount;
1439 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1442 m_source = createBuffer(vk, vkDevice, &sourceBufferParams);
1443 m_sourceBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::HostVisible);
1444 VK_CHECK(vk.bindBufferMemory(vkDevice, *m_source, m_sourceBufferAlloc->getMemory(), m_sourceBufferAlloc->getOffset()));
1447 // Create destination image
1449 const VkImageCreateInfo destinationImageParams =
1451 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
1452 DE_NULL, // const void* pNext;
1453 0u, // VkImageCreateFlags flags;
1454 m_params.dst.image.imageType, // VkImageType imageType;
1455 m_params.dst.image.format, // VkFormat format;
1456 getExtent3D(m_params.dst.image), // VkExtent3D extent;
1457 1u, // deUint32 mipLevels;
1458 getArraySize(m_params.dst.image), // deUint32 arraySize;
1459 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
1460 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
1461 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1462 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
1463 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1464 1u, // deUint32 queueFamilyCount;
1465 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1466 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
1469 m_destination = createImage(vk, vkDevice, &destinationImageParams);
1470 m_destinationImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::Any);
1471 VK_CHECK(vk.bindImageMemory(vkDevice, *m_destination, m_destinationImageAlloc->getMemory(), m_destinationImageAlloc->getOffset()));
1475 tcu::TestStatus CopyBufferToImage::iterate (void)
1477 m_sourceTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(m_textureFormat, (int)m_params.src.buffer.size, 1));
1478 generateBuffer(m_sourceTextureLevel->getAccess(), (int)m_params.src.buffer.size, 1, 1);
1479 m_destinationTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(m_textureFormat,
1480 m_params.dst.image.extent.width,
1481 m_params.dst.image.extent.height,
1482 m_params.dst.image.extent.depth));
1484 generateBuffer(m_destinationTextureLevel->getAccess(), m_params.dst.image.extent.width, m_params.dst.image.extent.height, m_params.dst.image.extent.depth);
1486 generateExpectedResult();
1488 uploadBuffer(m_sourceTextureLevel->getAccess(), *m_sourceBufferAlloc);
1489 uploadImage(m_destinationTextureLevel->getAccess(), *m_destination, m_params.dst.image);
1491 const DeviceInterface& vk = m_context.getDeviceInterface();
1492 const VkDevice vkDevice = m_context.getDevice();
1493 const VkQueue queue = m_context.getUniversalQueue();
1495 const VkImageMemoryBarrier imageBarrier =
1497 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
1498 DE_NULL, // const void* pNext;
1499 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
1500 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
1501 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
1502 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
1503 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1504 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1505 *m_destination, // VkImage image;
1506 { // VkImageSubresourceRange subresourceRange;
1507 getAspectFlags(m_textureFormat), // VkImageAspectFlags aspectMask;
1508 0u, // deUint32 baseMipLevel;
1509 1u, // deUint32 mipLevels;
1510 0u, // deUint32 baseArraySlice;
1511 1u // deUint32 arraySize;
1515 // Copy from buffer to image
1516 std::vector<VkBufferImageCopy> bufferImageCopies;
1517 for (deUint32 i = 0; i < m_params.regions.size(); i++)
1518 bufferImageCopies.push_back(m_params.regions[i].bufferImageCopy);
1520 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
1522 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
1523 DE_NULL, // const void* pNext;
1524 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
1525 (const VkCommandBufferInheritanceInfo*)DE_NULL,
1528 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
1529 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);
1530 vk.cmdCopyBufferToImage(*m_cmdBuffer, m_source.get(), m_destination.get(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (deUint32)m_params.regions.size(), bufferImageCopies.data());
1531 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1533 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
1535 de::MovePtr<tcu::TextureLevel> resultLevel = readImage(*m_destination, m_params.dst.image);
1537 return checkTestResult(resultLevel->getAccess());
1540 class CopyBufferToImageTestCase : public vkt::TestCase
1543 CopyBufferToImageTestCase (tcu::TestContext& testCtx,
1544 const std::string& name,
1545 const std::string& description,
1546 const TestParams params)
1547 : vkt::TestCase (testCtx, name, description)
1551 virtual ~CopyBufferToImageTestCase (void) {}
1553 virtual TestInstance* createInstance (Context& context) const
1555 return new CopyBufferToImage(context, m_params);
1558 TestParams m_params;
1561 void CopyBufferToImage::copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region)
1563 deUint32 rowLength = region.bufferImageCopy.bufferRowLength;
1565 rowLength = region.bufferImageCopy.imageExtent.width;
1567 deUint32 imageHeight = region.bufferImageCopy.bufferImageHeight;
1569 imageHeight = region.bufferImageCopy.imageExtent.height;
1571 const int texelSize = dst.getFormat().getPixelSize();
1572 const VkExtent3D extent = region.bufferImageCopy.imageExtent;
1573 const VkOffset3D dstOffset = region.bufferImageCopy.imageOffset;
1574 const int texelOffset = (int) region.bufferImageCopy.bufferOffset / texelSize;
1576 for (deUint32 z = 0; z < extent.depth; z++)
1578 for (deUint32 y = 0; y < extent.height; y++)
1580 int texelIndex = texelOffset + (z * imageHeight + y) * rowLength;
1581 const tcu::ConstPixelBufferAccess srcSubRegion = tcu::getSubregion(src, texelIndex, 0, region.bufferImageCopy.imageExtent.width, 1);
1582 const tcu::PixelBufferAccess dstSubRegion = tcu::getSubregion(dst, dstOffset.x, dstOffset.y + y, dstOffset.z + z,
1583 region.bufferImageCopy.imageExtent.width, 1, 1);
1584 tcu::copy(dstSubRegion, srcSubRegion);
1589 // Copy from image to image with scaling.
1591 class BlittingImages : public CopiesAndBlittingTestInstance
1594 BlittingImages (Context& context,
1596 virtual tcu::TestStatus iterate (void);
1598 virtual tcu::TestStatus checkTestResult (tcu::ConstPixelBufferAccess result);
1599 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region);
1600 virtual void generateExpectedResult (void);
1602 bool checkLinearFilteredResult (const tcu::ConstPixelBufferAccess& result,
1603 const tcu::ConstPixelBufferAccess& clampedReference,
1604 const tcu::ConstPixelBufferAccess& unclampedReference,
1605 const tcu::TextureFormat& sourceFormat);
1606 bool checkNearestFilteredResult (const tcu::ConstPixelBufferAccess& result,
1607 const tcu::ConstPixelBufferAccess& source);
1609 Move<VkImage> m_source;
1610 de::MovePtr<Allocation> m_sourceImageAlloc;
1611 Move<VkImage> m_destination;
1612 de::MovePtr<Allocation> m_destinationImageAlloc;
1614 de::MovePtr<tcu::TextureLevel> m_unclampedExpectedTextureLevel;
1617 BlittingImages::BlittingImages (Context& context, TestParams params)
1618 : CopiesAndBlittingTestInstance(context, params)
1620 const DeviceInterface& vk = context.getDeviceInterface();
1621 const VkDevice vkDevice = context.getDevice();
1622 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
1623 Allocator& memAlloc = context.getDefaultAllocator();
1625 VkImageFormatProperties properties;
1626 if ((context.getInstanceInterface().getPhysicalDeviceImageFormatProperties (context.getPhysicalDevice(),
1627 m_params.src.image.format,
1629 VK_IMAGE_TILING_OPTIMAL,
1630 VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
1632 &properties) == VK_ERROR_FORMAT_NOT_SUPPORTED) ||
1633 (context.getInstanceInterface().getPhysicalDeviceImageFormatProperties (context.getPhysicalDevice(),
1634 m_params.dst.image.format,
1636 VK_IMAGE_TILING_OPTIMAL,
1637 VK_IMAGE_USAGE_TRANSFER_DST_BIT,
1639 &properties) == VK_ERROR_FORMAT_NOT_SUPPORTED))
1641 TCU_THROW(NotSupportedError, "Format not supported");
1644 VkFormatProperties srcFormatProperties;
1645 context.getInstanceInterface().getPhysicalDeviceFormatProperties(context.getPhysicalDevice(), m_params.src.image.format, &srcFormatProperties);
1646 if (!(srcFormatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_SRC_BIT))
1648 TCU_THROW(NotSupportedError, "Format feature blit source not supported");
1651 VkFormatProperties dstFormatProperties;
1652 context.getInstanceInterface().getPhysicalDeviceFormatProperties(context.getPhysicalDevice(), m_params.dst.image.format, &dstFormatProperties);
1653 if (!(dstFormatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_DST_BIT))
1655 TCU_THROW(NotSupportedError, "Format feature blit destination not supported");
1658 if (m_params.filter == VK_FILTER_LINEAR)
1660 if (!(srcFormatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT))
1661 TCU_THROW(NotSupportedError, "Source format feature sampled image filter linear not supported");
1662 if (!(dstFormatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT))
1663 TCU_THROW(NotSupportedError, "Destination format feature sampled image filter linear not supported");
1666 // Create source image
1668 const VkImageCreateInfo sourceImageParams =
1670 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
1671 DE_NULL, // const void* pNext;
1672 0u, // VkImageCreateFlags flags;
1673 m_params.src.image.imageType, // VkImageType imageType;
1674 m_params.src.image.format, // VkFormat format;
1675 getExtent3D(m_params.src.image), // VkExtent3D extent;
1676 1u, // deUint32 mipLevels;
1677 getArraySize(m_params.src.image), // deUint32 arraySize;
1678 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
1679 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
1680 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1681 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
1682 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1683 1u, // deUint32 queueFamilyCount;
1684 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1685 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
1688 m_source = createImage(vk, vkDevice, &sourceImageParams);
1689 m_sourceImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::Any);
1690 VK_CHECK(vk.bindImageMemory(vkDevice, *m_source, m_sourceImageAlloc->getMemory(), m_sourceImageAlloc->getOffset()));
1693 // Create destination image
1695 const VkImageCreateInfo destinationImageParams =
1697 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
1698 DE_NULL, // const void* pNext;
1699 0u, // VkImageCreateFlags flags;
1700 m_params.dst.image.imageType, // VkImageType imageType;
1701 m_params.dst.image.format, // VkFormat format;
1702 getExtent3D(m_params.dst.image), // VkExtent3D extent;
1703 1u, // deUint32 mipLevels;
1704 getArraySize(m_params.dst.image), // deUint32 arraySize;
1705 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
1706 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
1707 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1708 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
1709 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1710 1u, // deUint32 queueFamilyCount;
1711 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1712 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
1715 m_destination = createImage(vk, vkDevice, &destinationImageParams);
1716 m_destinationImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::Any);
1717 VK_CHECK(vk.bindImageMemory(vkDevice, *m_destination, m_destinationImageAlloc->getMemory(), m_destinationImageAlloc->getOffset()));
1721 tcu::TestStatus BlittingImages::iterate (void)
1723 const tcu::TextureFormat srcTcuFormat = mapVkFormat(m_params.src.image.format);
1724 const tcu::TextureFormat dstTcuFormat = mapVkFormat(m_params.dst.image.format);
1725 m_sourceTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(srcTcuFormat,
1726 m_params.src.image.extent.width,
1727 m_params.src.image.extent.height,
1728 m_params.src.image.extent.depth));
1729 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);
1730 m_destinationTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(dstTcuFormat,
1731 (int)m_params.dst.image.extent.width,
1732 (int)m_params.dst.image.extent.height,
1733 (int)m_params.dst.image.extent.depth));
1734 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);
1735 generateExpectedResult();
1737 uploadImage(m_sourceTextureLevel->getAccess(), m_source.get(), m_params.src.image);
1738 uploadImage(m_destinationTextureLevel->getAccess(), m_destination.get(), m_params.dst.image);
1740 const DeviceInterface& vk = m_context.getDeviceInterface();
1741 const VkDevice vkDevice = m_context.getDevice();
1742 const VkQueue queue = m_context.getUniversalQueue();
1744 std::vector<VkImageBlit> regions;
1745 for (deUint32 i = 0; i < m_params.regions.size(); i++)
1746 regions.push_back(m_params.regions[i].imageBlit);
1748 // Barriers for copying image to buffer
1749 const VkImageMemoryBarrier srcImageBarrier =
1751 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
1752 DE_NULL, // const void* pNext;
1753 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
1754 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
1755 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
1756 m_params.src.image.operationLayout, // VkImageLayout newLayout;
1757 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1758 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1759 m_source.get(), // VkImage image;
1760 { // VkImageSubresourceRange subresourceRange;
1761 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
1762 0u, // deUint32 baseMipLevel;
1763 1u, // deUint32 mipLevels;
1764 0u, // deUint32 baseArraySlice;
1765 1u // deUint32 arraySize;
1769 const VkImageMemoryBarrier dstImageBarrier =
1771 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
1772 DE_NULL, // const void* pNext;
1773 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
1774 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
1775 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
1776 m_params.dst.image.operationLayout, // VkImageLayout newLayout;
1777 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1778 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1779 m_destination.get(), // VkImage image;
1780 { // VkImageSubresourceRange subresourceRange;
1781 getAspectFlags(dstTcuFormat), // VkImageAspectFlags aspectMask;
1782 0u, // deUint32 baseMipLevel;
1783 1u, // deUint32 mipLevels;
1784 0u, // deUint32 baseArraySlice;
1785 1u // deUint32 arraySize;
1789 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
1791 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
1792 DE_NULL, // const void* pNext;
1793 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
1794 (const VkCommandBufferInheritanceInfo*)DE_NULL,
1797 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
1798 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);
1799 vk.cmdBlitImage(*m_cmdBuffer, m_source.get(), m_params.src.image.operationLayout, m_destination.get(), m_params.dst.image.operationLayout, (deUint32)m_params.regions.size(), ®ions[0], m_params.filter);
1800 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);
1801 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1802 submitCommandsAndWait(vk, vkDevice, queue, *m_cmdBuffer);
1804 de::MovePtr<tcu::TextureLevel> resultTextureLevel = readImage(*m_destination, m_params.dst.image);
1806 return checkTestResult(resultTextureLevel->getAccess());
1809 static float calculateFloatConversionError (int srcBits)
1813 const int clampedBits = de::clamp<int>(srcBits, 0, 32);
1814 const float srcMaxValue = de::max((float)(1ULL<<clampedBits) - 1.0f, 1.0f);
1815 const float error = 1.0f / srcMaxValue;
1817 return de::clamp<float>(error, 0.0f, 1.0f);
1823 tcu::Vec4 getFormatThreshold (const tcu::TextureFormat& format)
1825 tcu::Vec4 threshold(0.01f);
1827 switch (format.type)
1829 case tcu::TextureFormat::HALF_FLOAT:
1830 threshold = tcu::Vec4(0.005f);
1833 case tcu::TextureFormat::FLOAT:
1834 case tcu::TextureFormat::FLOAT64:
1835 threshold = tcu::Vec4(0.001f);
1838 case tcu::TextureFormat::UNSIGNED_INT_11F_11F_10F_REV:
1839 threshold = tcu::Vec4(0.02f, 0.02f, 0.0625f, 1.0f);
1842 case tcu::TextureFormat::UNSIGNED_INT_999_E5_REV:
1843 threshold = tcu::Vec4(0.05f, 0.05f, 0.05f, 1.0f);
1847 const tcu::IVec4 bits = tcu::getTextureFormatMantissaBitDepth(format);
1848 threshold = tcu::Vec4(calculateFloatConversionError(bits.x()),
1849 calculateFloatConversionError(bits.y()),
1850 calculateFloatConversionError(bits.z()),
1851 calculateFloatConversionError(bits.w()));
1854 // Return value matching the channel order specified by the format
1855 if (format.order == tcu::TextureFormat::BGR || format.order == tcu::TextureFormat::BGRA)
1856 return threshold.swizzle(2, 1, 0, 3);
1861 bool BlittingImages::checkLinearFilteredResult (const tcu::ConstPixelBufferAccess& result,
1862 const tcu::ConstPixelBufferAccess& clampedExpected,
1863 const tcu::ConstPixelBufferAccess& unclampedExpected,
1864 const tcu::TextureFormat& srcFormat)
1866 tcu::TestLog& log (m_context.getTestContext().getLog());
1867 const tcu::TextureFormat dstFormat = result.getFormat();
1870 log << tcu::TestLog::Section("ClampedSourceImage", "Region with clamped edges on source image.");
1872 if (isFloatFormat(dstFormat))
1874 const bool srcIsSRGB = tcu::isSRGB(srcFormat);
1875 const tcu::Vec4 srcMaxDiff = getFormatThreshold(srcFormat) * tcu::Vec4(srcIsSRGB ? 2.0f : 1.0f);
1876 const tcu::Vec4 dstMaxDiff = getFormatThreshold(dstFormat);
1877 const tcu::Vec4 threshold = tcu::max(srcMaxDiff, dstMaxDiff);
1879 isOk = tcu::floatThresholdCompare(log, "Compare", "Result comparsion", clampedExpected, result, threshold, tcu::COMPARE_LOG_RESULT);
1880 log << tcu::TestLog::EndSection;
1884 log << tcu::TestLog::Section("NonClampedSourceImage", "Region with non-clamped edges on source image.");
1885 isOk = tcu::floatThresholdCompare(log, "Compare", "Result comparsion", unclampedExpected, result, threshold, tcu::COMPARE_LOG_RESULT);
1886 log << tcu::TestLog::EndSection;
1891 tcu::UVec4 threshold;
1892 // Calculate threshold depending on channel width of destination format.
1893 const tcu::IVec4 bitDepth = tcu::getTextureFormatBitDepth(dstFormat);
1894 for (deUint32 i = 0; i < 4; ++i)
1895 threshold[i] = de::max( (0x1 << bitDepth[i]) / 256, 1);
1897 isOk = tcu::intThresholdCompare(log, "Compare", "Result comparsion", clampedExpected, result, threshold, tcu::COMPARE_LOG_RESULT);
1898 log << tcu::TestLog::EndSection;
1902 log << tcu::TestLog::Section("NonClampedSourceImage", "Region with non-clamped edges on source image.");
1903 isOk = tcu::intThresholdCompare(log, "Compare", "Result comparsion", unclampedExpected, result, threshold, tcu::COMPARE_LOG_RESULT);
1904 log << tcu::TestLog::EndSection;
1911 //! Utility to encapsulate coordinate computation and loops.
1912 struct CompareEachPixelInEachRegion
1914 virtual ~CompareEachPixelInEachRegion (void) {}
1915 virtual bool compare (const void* pUserData, const int x, const int y, const tcu::Vec2& srcNormCoord) const = 0;
1917 bool forEach (const void* pUserData,
1918 const std::vector<CopyRegion>& regions,
1919 const int sourceWidth,
1920 const int sourceHeight,
1921 const tcu::PixelBufferAccess& errorMask) const
1923 bool compareOk = true;
1925 for (std::vector<CopyRegion>::const_iterator regionIter = regions.begin(); regionIter != regions.end(); ++regionIter)
1927 const VkImageBlit& blit = regionIter->imageBlit;
1929 const int dx = deSign32(blit.dstOffsets[1].x - blit.dstOffsets[0].x);
1930 const int dy = deSign32(blit.dstOffsets[1].y - blit.dstOffsets[0].y);
1931 const float xScale = static_cast<float>(blit.srcOffsets[1].x - blit.srcOffsets[0].x) / static_cast<float>(blit.dstOffsets[1].x - blit.dstOffsets[0].x);
1932 const float yScale = static_cast<float>(blit.srcOffsets[1].y - blit.srcOffsets[0].y) / static_cast<float>(blit.dstOffsets[1].y - blit.dstOffsets[0].y);
1933 const float srcInvW = 1.0f / static_cast<float>(sourceWidth);
1934 const float srcInvH = 1.0f / static_cast<float>(sourceHeight);
1936 for (int y = blit.dstOffsets[0].y; y < blit.dstOffsets[1].y; y += dy)
1937 for (int x = blit.dstOffsets[0].x; x < blit.dstOffsets[1].x; x += dx)
1939 const tcu::Vec2 srcNormCoord
1941 (xScale * (static_cast<float>(x - blit.dstOffsets[0].x) + 0.5f) + static_cast<float>(blit.srcOffsets[0].x)) * srcInvW,
1942 (yScale * (static_cast<float>(y - blit.dstOffsets[0].y) + 0.5f) + static_cast<float>(blit.srcOffsets[0].y)) * srcInvH
1945 if (!compare(pUserData, x, y, srcNormCoord))
1947 errorMask.setPixel(tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), x, y);
1956 tcu::Vec4 getFloatOrFixedPointFormatThreshold (const tcu::TextureFormat& format)
1958 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
1959 const tcu::IVec4 bitDepth = tcu::getTextureFormatBitDepth(format);
1961 if (channelClass == tcu::TEXTURECHANNELCLASS_FLOATING_POINT)
1963 return getFormatThreshold(format);
1965 else if (channelClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT ||
1966 channelClass == tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT)
1968 const bool isSigned = (channelClass == tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT);
1969 const float range = isSigned ? 1.0f - (-1.0f)
1973 for (int i = 0; i < 4; ++i)
1975 if (bitDepth[i] == 0)
1978 v[i] = range / static_cast<float>((1 << bitDepth[i]) - 1);
1989 bool floatNearestBlitCompare (const tcu::ConstPixelBufferAccess& source,
1990 const tcu::ConstPixelBufferAccess& result,
1991 const tcu::PixelBufferAccess& errorMask,
1992 const std::vector<CopyRegion>& regions)
1994 const tcu::Sampler sampler (tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::NEAREST, tcu::Sampler::NEAREST);
1995 tcu::LookupPrecision precision;
1998 const tcu::IVec4 dstBitDepth = tcu::getTextureFormatBitDepth(result.getFormat());
1999 const tcu::Vec4 srcMaxDiff = getFloatOrFixedPointFormatThreshold(source.getFormat());
2000 const tcu::Vec4 dstMaxDiff = getFloatOrFixedPointFormatThreshold(result.getFormat());
2002 precision.colorMask = tcu::notEqual(dstBitDepth, tcu::IVec4(0));
2003 precision.colorThreshold = tcu::max(srcMaxDiff, dstMaxDiff);
2006 const struct Capture
2008 const tcu::ConstPixelBufferAccess& source;
2009 const tcu::ConstPixelBufferAccess& result;
2010 const tcu::Sampler& sampler;
2011 const tcu::LookupPrecision& precision;
2015 source, result, sampler, precision, tcu::isSRGB(result.getFormat())
2018 const struct Loop : CompareEachPixelInEachRegion
2022 bool compare (const void* pUserData, const int x, const int y, const tcu::Vec2& srcNormCoord) const
2024 const Capture& c = *static_cast<const Capture*>(pUserData);
2025 const tcu::TexLookupScaleMode lookupScaleDontCare = tcu::TEX_LOOKUP_SCALE_MINIFY;
2026 tcu::Vec4 dstColor = c.result.getPixel(x, y);
2028 // TexLookupVerifier performs a conversion to linear space, so we have to as well
2030 dstColor = tcu::sRGBToLinear(dstColor);
2032 return tcu::isLevel2DLookupResultValid(c.source, c.sampler, lookupScaleDontCare, c.precision, srcNormCoord, 0, dstColor);
2036 return loop.forEach(&capture, regions, source.getWidth(), source.getHeight(), errorMask);
2039 bool intNearestBlitCompare (const tcu::ConstPixelBufferAccess& source,
2040 const tcu::ConstPixelBufferAccess& result,
2041 const tcu::PixelBufferAccess& errorMask,
2042 const std::vector<CopyRegion>& regions)
2044 const tcu::Sampler sampler (tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::NEAREST, tcu::Sampler::NEAREST);
2045 tcu::IntLookupPrecision precision;
2048 const tcu::IVec4 srcBitDepth = tcu::getTextureFormatBitDepth(source.getFormat());
2049 const tcu::IVec4 dstBitDepth = tcu::getTextureFormatBitDepth(result.getFormat());
2051 for (deUint32 i = 0; i < 4; ++i) {
2052 precision.colorThreshold[i] = de::max(de::max(srcBitDepth[i] / 8, dstBitDepth[i] / 8), 1);
2053 precision.colorMask[i] = dstBitDepth[i] != 0;
2057 // Prepare a source image with a matching (converted) pixel format. Ideally, we would've used a wrapper that
2058 // does the conversion on the fly without wasting memory, but this approach is more straightforward.
2059 tcu::TextureLevel convertedSourceTexture (result.getFormat(), source.getWidth(), source.getHeight());
2060 const tcu::PixelBufferAccess convertedSource = convertedSourceTexture.getAccess();
2062 for (int y = 0; y < source.getHeight(); ++y)
2063 for (int x = 0; x < source.getWidth(); ++x)
2064 convertedSource.setPixel(source.getPixelInt(x, y), x, y); // will be clamped to max. representable value
2066 const struct Capture
2068 const tcu::ConstPixelBufferAccess& source;
2069 const tcu::ConstPixelBufferAccess& result;
2070 const tcu::Sampler& sampler;
2071 const tcu::IntLookupPrecision& precision;
2074 convertedSource, result, sampler, precision
2077 const struct Loop : CompareEachPixelInEachRegion
2081 bool compare (const void* pUserData, const int x, const int y, const tcu::Vec2& srcNormCoord) const
2083 const Capture& c = *static_cast<const Capture*>(pUserData);
2084 const tcu::TexLookupScaleMode lookupScaleDontCare = tcu::TEX_LOOKUP_SCALE_MINIFY;
2085 const tcu::IVec4 dstColor = c.result.getPixelInt(x, y);
2087 return tcu::isLevel2DLookupResultValid(c.source, c.sampler, lookupScaleDontCare, c.precision, srcNormCoord, 0, dstColor);
2091 return loop.forEach(&capture, regions, source.getWidth(), source.getHeight(), errorMask);
2094 bool BlittingImages::checkNearestFilteredResult (const tcu::ConstPixelBufferAccess& result,
2095 const tcu::ConstPixelBufferAccess& source)
2097 tcu::TestLog& log (m_context.getTestContext().getLog());
2098 const tcu::TextureFormat dstFormat = result.getFormat();
2099 const tcu::TextureChannelClass dstChannelClass = tcu::getTextureChannelClass(dstFormat.type);
2101 tcu::TextureLevel errorMaskStorage (tcu::TextureFormat(tcu::TextureFormat::RGB, tcu::TextureFormat::UNORM_INT8), result.getWidth(), result.getHeight());
2102 tcu::PixelBufferAccess errorMask = errorMaskStorage.getAccess();
2103 tcu::Vec4 pixelBias (0.0f, 0.0f, 0.0f, 0.0f);
2104 tcu::Vec4 pixelScale (1.0f, 1.0f, 1.0f, 1.0f);
2107 tcu::clear(errorMask, tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0));
2109 if (dstChannelClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER ||
2110 dstChannelClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER)
2112 ok = intNearestBlitCompare(source, result, errorMask, m_params.regions);
2115 ok = floatNearestBlitCompare(source, result, errorMask, m_params.regions);
2117 if (result.getFormat() != tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8))
2118 tcu::computePixelScaleBias(result, pixelScale, pixelBias);
2122 log << tcu::TestLog::ImageSet("Compare", "Result comparsion")
2123 << tcu::TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
2124 << tcu::TestLog::Image("ErrorMask", "Error mask", errorMask)
2125 << tcu::TestLog::EndImageSet;
2129 log << tcu::TestLog::ImageSet("Compare", "Result comparsion")
2130 << tcu::TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
2131 << tcu::TestLog::EndImageSet;
2137 tcu::TestStatus BlittingImages::checkTestResult (tcu::ConstPixelBufferAccess result)
2139 DE_ASSERT(m_params.filter == VK_FILTER_NEAREST || m_params.filter == VK_FILTER_LINEAR);
2140 const std::string failMessage("Result image is incorrect");
2142 if (m_params.filter == VK_FILTER_LINEAR)
2144 if (tcu::isCombinedDepthStencilType(result.getFormat().type))
2146 if (tcu::hasDepthComponent(result.getFormat().order))
2148 const tcu::Sampler::DepthStencilMode mode = tcu::Sampler::MODE_DEPTH;
2149 const tcu::ConstPixelBufferAccess depthResult = tcu::getEffectiveDepthStencilAccess(result, mode);
2150 const tcu::ConstPixelBufferAccess clampedExpected = tcu::getEffectiveDepthStencilAccess(m_expectedTextureLevel->getAccess(), mode);
2151 const tcu::ConstPixelBufferAccess unclampedExpected = tcu::getEffectiveDepthStencilAccess(m_unclampedExpectedTextureLevel->getAccess(), mode);
2152 const tcu::TextureFormat sourceFormat = tcu::getEffectiveDepthStencilTextureFormat(mapVkFormat(m_params.src.image.format), mode);
2154 if (!checkLinearFilteredResult(depthResult, clampedExpected, unclampedExpected, sourceFormat))
2155 return tcu::TestStatus::fail(failMessage);
2158 if (tcu::hasStencilComponent(result.getFormat().order))
2160 const tcu::Sampler::DepthStencilMode mode = tcu::Sampler::MODE_STENCIL;
2161 const tcu::ConstPixelBufferAccess stencilResult = tcu::getEffectiveDepthStencilAccess(result, mode);
2162 const tcu::ConstPixelBufferAccess clampedExpected = tcu::getEffectiveDepthStencilAccess(m_expectedTextureLevel->getAccess(), mode);
2163 const tcu::ConstPixelBufferAccess unclampedExpected = tcu::getEffectiveDepthStencilAccess(m_unclampedExpectedTextureLevel->getAccess(), mode);
2164 const tcu::TextureFormat sourceFormat = tcu::getEffectiveDepthStencilTextureFormat(mapVkFormat(m_params.src.image.format), mode);
2166 if (!checkLinearFilteredResult(stencilResult, clampedExpected, unclampedExpected, sourceFormat))
2167 return tcu::TestStatus::fail(failMessage);
2172 const tcu::TextureFormat sourceFormat = mapVkFormat(m_params.src.image.format);
2174 if (!checkLinearFilteredResult(result, m_expectedTextureLevel->getAccess(), m_unclampedExpectedTextureLevel->getAccess(), sourceFormat))
2175 return tcu::TestStatus::fail(failMessage);
2178 else // NEAREST filtering
2180 if (tcu::isCombinedDepthStencilType(result.getFormat().type))
2182 if (tcu::hasDepthComponent(result.getFormat().order))
2184 const tcu::Sampler::DepthStencilMode mode = tcu::Sampler::MODE_DEPTH;
2185 const tcu::ConstPixelBufferAccess depthResult = tcu::getEffectiveDepthStencilAccess(result, mode);
2186 const tcu::ConstPixelBufferAccess depthSource = tcu::getEffectiveDepthStencilAccess(m_sourceTextureLevel->getAccess(), mode);
2188 if (!checkNearestFilteredResult(depthResult, depthSource))
2189 return tcu::TestStatus::fail(failMessage);
2192 if (tcu::hasStencilComponent(result.getFormat().order))
2194 const tcu::Sampler::DepthStencilMode mode = tcu::Sampler::MODE_STENCIL;
2195 const tcu::ConstPixelBufferAccess stencilResult = tcu::getEffectiveDepthStencilAccess(result, mode);
2196 const tcu::ConstPixelBufferAccess stencilSource = tcu::getEffectiveDepthStencilAccess(m_sourceTextureLevel->getAccess(), mode);
2198 if (!checkNearestFilteredResult(stencilResult, stencilSource))
2199 return tcu::TestStatus::fail(failMessage);
2204 if (!checkNearestFilteredResult(result, m_sourceTextureLevel->getAccess()))
2205 return tcu::TestStatus::fail(failMessage);
2209 return tcu::TestStatus::pass("Pass");
2212 tcu::Vec4 linearToSRGBIfNeeded (const tcu::TextureFormat& format, const tcu::Vec4& color)
2214 return isSRGB(format) ? linearToSRGB(color) : color;
2217 void scaleFromWholeSrcBuffer (const tcu::PixelBufferAccess& dst, const tcu::ConstPixelBufferAccess& src, const VkOffset3D regionOffset, const VkOffset3D regionExtent, tcu::Sampler::FilterMode filter)
2219 DE_ASSERT(filter == tcu::Sampler::LINEAR);
2220 DE_ASSERT(dst.getDepth() == 1 && src.getDepth() == 1);
2222 tcu::Sampler sampler(tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::CLAMP_TO_EDGE,
2223 filter, filter, 0.0f, false);
2225 float sX = (float)regionExtent.x / (float)dst.getWidth();
2226 float sY = (float)regionExtent.y / (float)dst.getHeight();
2228 for (int y = 0; y < dst.getHeight(); y++)
2229 for (int x = 0; x < dst.getWidth(); x++)
2230 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);
2233 void blit (const tcu::PixelBufferAccess& dst, const tcu::ConstPixelBufferAccess& src, const tcu::Sampler::FilterMode filter, const MirrorMode mirrorMode)
2235 DE_ASSERT(filter == tcu::Sampler::NEAREST || filter == tcu::Sampler::LINEAR);
2237 tcu::Sampler sampler(tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::CLAMP_TO_EDGE,
2238 filter, filter, 0.0f, false);
2240 const float sX = (float)src.getWidth() / (float)dst.getWidth();
2241 const float sY = (float)src.getHeight() / (float)dst.getHeight();
2242 const float sZ = (float)src.getDepth() / (float)dst.getDepth();
2244 tcu::Mat2 rotMatrix;
2245 rotMatrix(0,0) = (mirrorMode & MIRROR_MODE_X) ? -1.0f : 1.0f;
2246 rotMatrix(0,1) = 0.0f;
2247 rotMatrix(1,0) = 0.0f;
2248 rotMatrix(1,1) = (mirrorMode & MIRROR_MODE_Y) ? -1.0f : 1.0f;
2250 const int xOffset = (mirrorMode & MIRROR_MODE_X) ? dst.getWidth() - 1 : 0;
2251 const int yOffset = (mirrorMode & MIRROR_MODE_Y) ? dst.getHeight() - 1 : 0;
2253 if (dst.getDepth() == 1 && src.getDepth() == 1)
2255 for (int y = 0; y < dst.getHeight(); ++y)
2256 for (int x = 0; x < dst.getWidth(); ++x)
2258 const tcu::Vec2 xy = rotMatrix * tcu::Vec2((float)x,(float)y);
2259 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);
2264 for (int z = 0; z < dst.getDepth(); ++z)
2265 for (int y = 0; y < dst.getHeight(); ++y)
2266 for (int x = 0; x < dst.getWidth(); ++x)
2268 const tcu::Vec2 xy = rotMatrix * tcu::Vec2((float)x,(float)y);
2269 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);
2274 void flipCoordinates (CopyRegion& region, const MirrorMode mirrorMode)
2276 const VkOffset3D dstOffset0 = region.imageBlit.dstOffsets[0];
2277 const VkOffset3D dstOffset1 = region.imageBlit.dstOffsets[1];
2278 const VkOffset3D srcOffset0 = region.imageBlit.srcOffsets[0];
2279 const VkOffset3D srcOffset1 = region.imageBlit.srcOffsets[1];
2281 if (mirrorMode > MIRROR_MODE_NONE && mirrorMode < MIRROR_MODE_LAST)
2284 region.imageBlit.srcOffsets[0].x = std::min(srcOffset0.x, srcOffset1.x);
2285 region.imageBlit.srcOffsets[0].y = std::min(srcOffset0.y, srcOffset1.y);
2287 region.imageBlit.srcOffsets[1].x = std::max(srcOffset0.x, srcOffset1.x);
2288 region.imageBlit.srcOffsets[1].y = std::max(srcOffset0.y, srcOffset1.y);
2291 region.imageBlit.dstOffsets[0].x = std::min(dstOffset0.x, dstOffset1.x);
2292 region.imageBlit.dstOffsets[0].y = std::min(dstOffset0.y, dstOffset1.y);
2294 region.imageBlit.dstOffsets[1].x = std::max(dstOffset0.x, dstOffset1.x);
2295 region.imageBlit.dstOffsets[1].y = std::max(dstOffset0.y, dstOffset1.y);
2299 MirrorMode getMirrorMode(const VkOffset3D x1, const VkOffset3D x2)
2301 if (x1.x >= x2.x && x1.y >= x2.y)
2303 return MIRROR_MODE_XY;
2305 else if (x1.x <= x2.x && x1.y <= x2.y)
2307 return MIRROR_MODE_NONE;
2309 else if (x1.x <= x2.x && x1.y >= x2.y)
2311 return MIRROR_MODE_Y;
2313 else if (x1.x >= x2.x && x1.y <= x2.y)
2315 return MIRROR_MODE_X;
2317 return MIRROR_MODE_LAST;
2320 MirrorMode getMirrorMode(const VkOffset3D s1, const VkOffset3D s2, const VkOffset3D d1, const VkOffset3D d2)
2322 const MirrorMode source = getMirrorMode(s1, s2);
2323 const MirrorMode destination = getMirrorMode(d1, d2);
2325 if (source == destination)
2327 return MIRROR_MODE_NONE;
2329 else if ((source == MIRROR_MODE_XY && destination == MIRROR_MODE_X) || (destination == MIRROR_MODE_XY && source == MIRROR_MODE_X) ||
2330 (source == MIRROR_MODE_Y && destination == MIRROR_MODE_NONE) || (destination == MIRROR_MODE_Y && source == MIRROR_MODE_NONE))
2332 return MIRROR_MODE_Y;
2334 else if ((source == MIRROR_MODE_XY && destination == MIRROR_MODE_Y) || (destination == MIRROR_MODE_XY && source == MIRROR_MODE_Y) ||
2335 (source == MIRROR_MODE_X && destination == MIRROR_MODE_NONE) || (destination == MIRROR_MODE_X && source == MIRROR_MODE_NONE))
2337 return MIRROR_MODE_X;
2339 else if ((source == MIRROR_MODE_XY && destination == MIRROR_MODE_NONE) || (destination == MIRROR_MODE_XY && source == MIRROR_MODE_NONE))
2341 return MIRROR_MODE_XY;
2343 return MIRROR_MODE_LAST;
2346 void BlittingImages::copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region)
2348 const MirrorMode mirrorMode = getMirrorMode(region.imageBlit.srcOffsets[0],
2349 region.imageBlit.srcOffsets[1],
2350 region.imageBlit.dstOffsets[0],
2351 region.imageBlit.dstOffsets[1]);
2353 flipCoordinates(region, mirrorMode);
2355 const VkOffset3D srcOffset = region.imageBlit.srcOffsets[0];
2356 const VkOffset3D srcExtent =
2358 region.imageBlit.srcOffsets[1].x - srcOffset.x,
2359 region.imageBlit.srcOffsets[1].y - srcOffset.y,
2360 region.imageBlit.srcOffsets[1].z - srcOffset.z
2362 const VkOffset3D dstOffset = region.imageBlit.dstOffsets[0];
2363 const VkOffset3D dstExtent =
2365 region.imageBlit.dstOffsets[1].x - dstOffset.x,
2366 region.imageBlit.dstOffsets[1].y - dstOffset.y,
2367 region.imageBlit.dstOffsets[1].z - dstOffset.z
2369 const tcu::Sampler::FilterMode filter = (m_params.filter == VK_FILTER_LINEAR) ? tcu::Sampler::LINEAR : tcu::Sampler::NEAREST;
2371 if (tcu::isCombinedDepthStencilType(src.getFormat().type))
2373 DE_ASSERT(src.getFormat() == dst.getFormat());
2375 if (tcu::hasDepthComponent(src.getFormat().order))
2377 const tcu::ConstPixelBufferAccess srcSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(src, srcOffset.x, srcOffset.y, srcExtent.x, srcExtent.y), tcu::Sampler::MODE_DEPTH);
2378 const tcu::PixelBufferAccess dstSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(dst, dstOffset.x, dstOffset.y, dstExtent.x, dstExtent.y), tcu::Sampler::MODE_DEPTH);
2379 tcu::scale(dstSubRegion, srcSubRegion, filter);
2381 if (filter == tcu::Sampler::LINEAR)
2383 const tcu::ConstPixelBufferAccess depthSrc = getEffectiveDepthStencilAccess(src, tcu::Sampler::MODE_DEPTH);
2384 const tcu::PixelBufferAccess unclampedSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(m_unclampedExpectedTextureLevel->getAccess(), dstOffset.x, dstOffset.y, dstExtent.x, dstExtent.y), tcu::Sampler::MODE_DEPTH);
2385 scaleFromWholeSrcBuffer(unclampedSubRegion, depthSrc, srcOffset, srcExtent, filter);
2390 if (tcu::hasStencilComponent(src.getFormat().order))
2392 const tcu::ConstPixelBufferAccess srcSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(src, srcOffset.x, srcOffset.y, srcExtent.x, srcExtent.y), tcu::Sampler::MODE_STENCIL);
2393 const tcu::PixelBufferAccess dstSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(dst, dstOffset.x, dstOffset.y, dstExtent.x, dstExtent.y), tcu::Sampler::MODE_STENCIL);
2394 blit(dstSubRegion, srcSubRegion, filter, mirrorMode);
2396 if (filter == tcu::Sampler::LINEAR)
2398 const tcu::ConstPixelBufferAccess stencilSrc = getEffectiveDepthStencilAccess(src, tcu::Sampler::MODE_STENCIL);
2399 const tcu::PixelBufferAccess unclampedSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(m_unclampedExpectedTextureLevel->getAccess(), dstOffset.x, dstOffset.y, dstExtent.x, dstExtent.y), tcu::Sampler::MODE_STENCIL);
2400 scaleFromWholeSrcBuffer(unclampedSubRegion, stencilSrc, srcOffset, srcExtent, filter);
2406 const tcu::ConstPixelBufferAccess srcSubRegion = tcu::getSubregion(src, srcOffset.x, srcOffset.y, srcExtent.x, srcExtent.y);
2407 const tcu::PixelBufferAccess dstSubRegion = tcu::getSubregion(dst, dstOffset.x, dstOffset.y, dstExtent.x, dstExtent.y);
2408 blit(dstSubRegion, srcSubRegion, filter, mirrorMode);
2410 if (filter == tcu::Sampler::LINEAR)
2412 const tcu::PixelBufferAccess unclampedSubRegion = tcu::getSubregion(m_unclampedExpectedTextureLevel->getAccess(), dstOffset.x, dstOffset.y, dstExtent.x, dstExtent.y);
2413 scaleFromWholeSrcBuffer(unclampedSubRegion, src, srcOffset, srcExtent, filter);
2418 void BlittingImages::generateExpectedResult (void)
2420 const tcu::ConstPixelBufferAccess src = m_sourceTextureLevel->getAccess();
2421 const tcu::ConstPixelBufferAccess dst = m_destinationTextureLevel->getAccess();
2423 m_expectedTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(dst.getFormat(), dst.getWidth(), dst.getHeight(), dst.getDepth()));
2424 tcu::copy(m_expectedTextureLevel->getAccess(), dst);
2426 if (m_params.filter == VK_FILTER_LINEAR)
2428 m_unclampedExpectedTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(dst.getFormat(), dst.getWidth(), dst.getHeight(), dst.getDepth()));
2429 tcu::copy(m_unclampedExpectedTextureLevel->getAccess(), dst);
2432 for (deUint32 i = 0; i < m_params.regions.size(); i++)
2434 CopyRegion region = m_params.regions[i];
2435 copyRegionToTextureLevel(src, m_expectedTextureLevel->getAccess(), region);
2439 class BlittingTestCase : public vkt::TestCase
2442 BlittingTestCase (tcu::TestContext& testCtx,
2443 const std::string& name,
2444 const std::string& description,
2445 const TestParams params)
2446 : vkt::TestCase (testCtx, name, description)
2450 virtual TestInstance* createInstance (Context& context) const
2452 return new BlittingImages(context, m_params);
2455 TestParams m_params;
2458 // Resolve image to image.
2460 enum ResolveImageToImageOptions{NO_OPTIONAL_OPERATION, COPY_MS_IMAGE_TO_MS_IMAGE, COPY_MS_IMAGE_TO_ARRAY_MS_IMAGE};
2461 class ResolveImageToImage : public CopiesAndBlittingTestInstance
2464 ResolveImageToImage (Context& context,
2466 const ResolveImageToImageOptions options);
2467 virtual tcu::TestStatus iterate (void);
2469 virtual tcu::TestStatus checkTestResult (tcu::ConstPixelBufferAccess result);
2470 void copyMSImageToMSImage (void);
2472 Move<VkImage> m_multisampledImage;
2473 de::MovePtr<Allocation> m_multisampledImageAlloc;
2475 Move<VkImage> m_destination;
2476 de::MovePtr<Allocation> m_destinationImageAlloc;
2478 Move<VkImage> m_multisampledCopyImage;
2479 de::MovePtr<Allocation> m_multisampledCopyImageAlloc;
2481 const ResolveImageToImageOptions m_options;
2483 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src,
2484 tcu::PixelBufferAccess dst,
2488 ResolveImageToImage::ResolveImageToImage (Context& context, TestParams params, const ResolveImageToImageOptions options)
2489 : CopiesAndBlittingTestInstance (context, params)
2490 , m_options (options)
2492 const VkSampleCountFlagBits rasterizationSamples = m_params.samples;
2494 if (!(context.getDeviceProperties().limits.framebufferColorSampleCounts & rasterizationSamples))
2495 throw tcu::NotSupportedError("Unsupported number of rasterization samples");
2497 const DeviceInterface& vk = context.getDeviceInterface();
2498 const VkDevice vkDevice = context.getDevice();
2499 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
2500 Allocator& memAlloc = m_context.getDefaultAllocator();
2502 const VkComponentMapping componentMappingRGBA = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A };
2503 Move<VkRenderPass> renderPass;
2505 Move<VkShaderModule> vertexShaderModule = createShaderModule(vk, vkDevice, m_context.getBinaryCollection().get("vert"), 0);
2506 Move<VkShaderModule> fragmentShaderModule = createShaderModule(vk, vkDevice, m_context.getBinaryCollection().get("frag"), 0);
2507 std::vector<tcu::Vec4> vertices;
2509 Move<VkBuffer> vertexBuffer;
2510 de::MovePtr<Allocation> vertexBufferAlloc;
2512 Move<VkPipelineLayout> pipelineLayout;
2513 Move<VkPipeline> graphicsPipeline;
2515 VkImageFormatProperties properties;
2516 if ((context.getInstanceInterface().getPhysicalDeviceImageFormatProperties (context.getPhysicalDevice(),
2517 m_params.src.image.format,
2518 m_params.src.image.imageType,
2519 VK_IMAGE_TILING_OPTIMAL,
2520 VK_IMAGE_USAGE_TRANSFER_SRC_BIT, 0,
2521 &properties) == VK_ERROR_FORMAT_NOT_SUPPORTED) ||
2522 (context.getInstanceInterface().getPhysicalDeviceImageFormatProperties (context.getPhysicalDevice(),
2523 m_params.dst.image.format,
2524 m_params.dst.image.imageType,
2525 VK_IMAGE_TILING_OPTIMAL,
2526 VK_IMAGE_USAGE_TRANSFER_DST_BIT, 0,
2527 &properties) == VK_ERROR_FORMAT_NOT_SUPPORTED))
2529 TCU_THROW(NotSupportedError, "Format not supported");
2532 // Create color image.
2534 VkImageCreateInfo colorImageParams =
2536 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
2537 DE_NULL, // const void* pNext;
2538 0u, // VkImageCreateFlags flags;
2539 m_params.src.image.imageType, // VkImageType imageType;
2540 m_params.src.image.format, // VkFormat format;
2541 getExtent3D(m_params.src.image), // VkExtent3D extent;
2542 1u, // deUint32 mipLevels;
2543 getArraySize(m_params.src.image), // deUint32 arrayLayers;
2544 rasterizationSamples, // VkSampleCountFlagBits samples;
2545 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
2546 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, // VkImageUsageFlags usage;
2547 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
2548 1u, // deUint32 queueFamilyIndexCount;
2549 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
2550 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
2553 m_multisampledImage = createImage(vk, vkDevice, &colorImageParams);
2555 // Allocate and bind color image memory.
2556 m_multisampledImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_multisampledImage), MemoryRequirement::Any);
2557 VK_CHECK(vk.bindImageMemory(vkDevice, *m_multisampledImage, m_multisampledImageAlloc->getMemory(), m_multisampledImageAlloc->getOffset()));
2561 case COPY_MS_IMAGE_TO_MS_IMAGE:
2563 colorImageParams.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
2564 m_multisampledCopyImage = createImage(vk, vkDevice, &colorImageParams);
2565 // Allocate and bind color image memory.
2566 m_multisampledCopyImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_multisampledCopyImage), MemoryRequirement::Any);
2567 VK_CHECK(vk.bindImageMemory(vkDevice, *m_multisampledCopyImage, m_multisampledCopyImageAlloc->getMemory(), m_multisampledCopyImageAlloc->getOffset()));
2571 case COPY_MS_IMAGE_TO_ARRAY_MS_IMAGE:
2573 colorImageParams.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
2574 colorImageParams.arrayLayers = getArraySize(m_params.dst.image);
2575 m_multisampledCopyImage = createImage(vk, vkDevice, &colorImageParams);
2576 // Allocate and bind color image memory.
2577 m_multisampledCopyImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_multisampledCopyImage), MemoryRequirement::Any);
2578 VK_CHECK(vk.bindImageMemory(vkDevice, *m_multisampledCopyImage, m_multisampledCopyImageAlloc->getMemory(), m_multisampledCopyImageAlloc->getOffset()));
2587 // Create destination image.
2589 const VkImageCreateInfo destinationImageParams =
2591 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
2592 DE_NULL, // const void* pNext;
2593 0u, // VkImageCreateFlags flags;
2594 m_params.dst.image.imageType, // VkImageType imageType;
2595 m_params.dst.image.format, // VkFormat format;
2596 getExtent3D(m_params.dst.image), // VkExtent3D extent;
2597 1u, // deUint32 mipLevels;
2598 getArraySize(m_params.dst.image), // deUint32 arraySize;
2599 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
2600 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
2601 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
2602 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
2603 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
2604 1u, // deUint32 queueFamilyCount;
2605 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
2606 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
2609 m_destination = createImage(vk, vkDevice, &destinationImageParams);
2610 m_destinationImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::Any);
2611 VK_CHECK(vk.bindImageMemory(vkDevice, *m_destination, m_destinationImageAlloc->getMemory(), m_destinationImageAlloc->getOffset()));
2614 // Barriers for copying image to buffer
2615 VkImageMemoryBarrier srcImageBarrier =
2617 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
2618 DE_NULL, // const void* pNext;
2619 0u, // VkAccessFlags srcAccessMask;
2620 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags dstAccessMask;
2621 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
2622 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout newLayout;
2623 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
2624 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
2625 m_multisampledImage.get(), // VkImage image;
2626 { // VkImageSubresourceRange subresourceRange;
2627 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
2628 0u, // deUint32 baseMipLevel;
2629 1u, // deUint32 mipLevels;
2630 0u, // deUint32 baseArraySlice;
2631 getArraySize(m_params.src.image) // deUint32 arraySize;
2635 // Create render pass.
2637 const VkAttachmentDescription attachmentDescriptions[1] =
2640 0u, // VkAttachmentDescriptionFlags flags;
2641 m_params.src.image.format, // VkFormat format;
2642 rasterizationSamples, // VkSampleCountFlagBits samples;
2643 VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp;
2644 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
2645 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp;
2646 VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp;
2647 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout;
2648 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout;
2652 const VkAttachmentReference colorAttachmentReference =
2654 0u, // deUint32 attachment;
2655 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout layout;
2658 const VkSubpassDescription subpassDescription =
2660 0u, // VkSubpassDescriptionFlags flags;
2661 VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint;
2662 0u, // deUint32 inputAttachmentCount;
2663 DE_NULL, // const VkAttachmentReference* pInputAttachments;
2664 1u, // deUint32 colorAttachmentCount;
2665 &colorAttachmentReference, // const VkAttachmentReference* pColorAttachments;
2666 DE_NULL, // const VkAttachmentReference* pResolveAttachments;
2667 DE_NULL, // const VkAttachmentReference* pDepthStencilAttachment;
2668 0u, // deUint32 preserveAttachmentCount;
2669 DE_NULL // const VkAttachmentReference* pPreserveAttachments;
2672 const VkRenderPassCreateInfo renderPassParams =
2674 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType;
2675 DE_NULL, // const void* pNext;
2676 0u, // VkRenderPassCreateFlags flags;
2677 1u, // deUint32 attachmentCount;
2678 attachmentDescriptions, // const VkAttachmentDescription* pAttachments;
2679 1u, // deUint32 subpassCount;
2680 &subpassDescription, // const VkSubpassDescription* pSubpasses;
2681 0u, // deUint32 dependencyCount;
2682 DE_NULL // const VkSubpassDependency* pDependencies;
2685 renderPass = createRenderPass(vk, vkDevice, &renderPassParams);
2688 // Create pipeline layout
2690 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
2692 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // VkStructureType sType;
2693 DE_NULL, // const void* pNext;
2694 0u, // VkPipelineLayoutCreateFlags flags;
2695 0u, // deUint32 setLayoutCount;
2696 DE_NULL, // const VkDescriptorSetLayout* pSetLayouts;
2697 0u, // deUint32 pushConstantRangeCount;
2698 DE_NULL // const VkPushConstantRange* pPushConstantRanges;
2701 pipelineLayout = createPipelineLayout(vk, vkDevice, &pipelineLayoutParams);
2704 // Create upper half triangle.
2706 const tcu::Vec4 a (-1.0, -1.0, 0.0, 1.0);
2707 const tcu::Vec4 b (1.0, -1.0, 0.0, 1.0);
2708 const tcu::Vec4 c (1.0, 1.0, 0.0, 1.0);
2710 vertices.push_back(a);
2711 vertices.push_back(c);
2712 vertices.push_back(b);
2715 // Create vertex buffer.
2717 const VkDeviceSize vertexDataSize = vertices.size() * sizeof(tcu::Vec4);
2718 const VkBufferCreateInfo vertexBufferParams =
2720 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
2721 DE_NULL, // const void* pNext;
2722 0u, // VkBufferCreateFlags flags;
2723 vertexDataSize, // VkDeviceSize size;
2724 VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, // VkBufferUsageFlags usage;
2725 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
2726 1u, // deUint32 queueFamilyIndexCount;
2727 &queueFamilyIndex // const deUint32* pQueueFamilyIndices;
2730 vertexBuffer = createBuffer(vk, vkDevice, &vertexBufferParams);
2731 vertexBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *vertexBuffer), MemoryRequirement::HostVisible);
2733 VK_CHECK(vk.bindBufferMemory(vkDevice, *vertexBuffer, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset()));
2735 // Load vertices into vertex buffer.
2736 deMemcpy(vertexBufferAlloc->getHostPtr(), vertices.data(), (size_t)vertexDataSize);
2737 flushMappedMemoryRange(vk, vkDevice, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset(), vertexDataSize);
2741 Move<VkFramebuffer> framebuffer;
2742 Move<VkImageView> sourceAttachmentView;
2744 // Create color attachment view.
2746 const VkImageViewCreateInfo colorAttachmentViewParams =
2748 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // VkStructureType sType;
2749 DE_NULL, // const void* pNext;
2750 0u, // VkImageViewCreateFlags flags;
2751 *m_multisampledImage, // VkImage image;
2752 VK_IMAGE_VIEW_TYPE_2D, // VkImageViewType viewType;
2753 m_params.src.image.format, // VkFormat format;
2754 componentMappingRGBA, // VkComponentMapping components;
2755 { VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u } // VkImageSubresourceRange subresourceRange;
2757 sourceAttachmentView = createImageView(vk, vkDevice, &colorAttachmentViewParams);
2760 // Create framebuffer
2762 const VkImageView attachments[1] =
2764 *sourceAttachmentView,
2767 const VkFramebufferCreateInfo framebufferParams =
2769 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType;
2770 DE_NULL, // const void* pNext;
2771 0u, // VkFramebufferCreateFlags flags;
2772 *renderPass, // VkRenderPass renderPass;
2773 1u, // deUint32 attachmentCount;
2774 attachments, // const VkImageView* pAttachments;
2775 m_params.src.image.extent.width, // deUint32 width;
2776 m_params.src.image.extent.height, // deUint32 height;
2777 1u // deUint32 layers;
2780 framebuffer = createFramebuffer(vk, vkDevice, &framebufferParams);
2785 const VkPipelineShaderStageCreateInfo shaderStageParams[2] =
2788 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
2789 DE_NULL, // const void* pNext;
2790 0u, // VkPipelineShaderStageCreateFlags flags;
2791 VK_SHADER_STAGE_VERTEX_BIT, // VkShaderStageFlagBits stage;
2792 *vertexShaderModule, // VkShaderModule module;
2793 "main", // const char* pName;
2794 DE_NULL // const VkSpecializationInfo* pSpecializationInfo;
2797 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
2798 DE_NULL, // const void* pNext;
2799 0u, // VkPipelineShaderStageCreateFlags flags;
2800 VK_SHADER_STAGE_FRAGMENT_BIT, // VkShaderStageFlagBits stage;
2801 *fragmentShaderModule, // VkShaderModule module;
2802 "main", // const char* pName;
2803 DE_NULL // const VkSpecializationInfo* pSpecializationInfo;
2807 const VkVertexInputBindingDescription vertexInputBindingDescription =
2809 0u, // deUint32 binding;
2810 sizeof(tcu::Vec4), // deUint32 stride;
2811 VK_VERTEX_INPUT_RATE_VERTEX // VkVertexInputRate inputRate;
2814 const VkVertexInputAttributeDescription vertexInputAttributeDescriptions[1] =
2817 0u, // deUint32 location;
2818 0u, // deUint32 binding;
2819 VK_FORMAT_R32G32B32A32_SFLOAT, // VkFormat format;
2820 0u // deUint32 offset;
2824 const VkPipelineVertexInputStateCreateInfo vertexInputStateParams =
2826 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // VkStructureType sType;
2827 DE_NULL, // const void* pNext;
2828 0u, // VkPipelineVertexInputStateCreateFlags flags;
2829 1u, // deUint32 vertexBindingDescriptionCount;
2830 &vertexInputBindingDescription, // const VkVertexInputBindingDescription* pVertexBindingDescriptions;
2831 1u, // deUint32 vertexAttributeDescriptionCount;
2832 vertexInputAttributeDescriptions // const VkVertexInputAttributeDescription* pVertexAttributeDescriptions;
2835 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateParams =
2837 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // VkStructureType sType;
2838 DE_NULL, // const void* pNext;
2839 0u, // VkPipelineInputAssemblyStateCreateFlags flags;
2840 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, // VkPrimitiveTopology topology;
2841 false // VkBool32 primitiveRestartEnable;
2844 const VkViewport viewport =
2848 (float)m_params.src.image.extent.width, // float width;
2849 (float)m_params.src.image.extent.height,// float height;
2850 0.0f, // float minDepth;
2851 1.0f // float maxDepth;
2854 const VkRect2D scissor =
2856 { 0, 0 }, // VkOffset2D offset;
2857 { m_params.src.image.extent.width, m_params.src.image.extent.height } // VkExtent2D extent;
2860 const VkPipelineViewportStateCreateInfo viewportStateParams =
2862 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // VkStructureType sType;
2863 DE_NULL, // const void* pNext;
2864 0u, // VkPipelineViewportStateCreateFlags flags;
2865 1u, // deUint32 viewportCount;
2866 &viewport, // const VkViewport* pViewports;
2867 1u, // deUint32 scissorCount;
2868 &scissor // const VkRect2D* pScissors;
2871 const VkPipelineRasterizationStateCreateInfo rasterStateParams =
2873 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // VkStructureType sType;
2874 DE_NULL, // const void* pNext;
2875 0u, // VkPipelineRasterizationStateCreateFlags flags;
2876 false, // VkBool32 depthClampEnable;
2877 false, // VkBool32 rasterizerDiscardEnable;
2878 VK_POLYGON_MODE_FILL, // VkPolygonMode polygonMode;
2879 VK_CULL_MODE_NONE, // VkCullModeFlags cullMode;
2880 VK_FRONT_FACE_COUNTER_CLOCKWISE, // VkFrontFace frontFace;
2881 VK_FALSE, // VkBool32 depthBiasEnable;
2882 0.0f, // float depthBiasConstantFactor;
2883 0.0f, // float depthBiasClamp;
2884 0.0f, // float depthBiasSlopeFactor;
2885 1.0f // float lineWidth;
2888 const VkPipelineMultisampleStateCreateInfo multisampleStateParams =
2890 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // VkStructureType sType;
2891 DE_NULL, // const void* pNext;
2892 0u, // VkPipelineMultisampleStateCreateFlags flags;
2893 rasterizationSamples, // VkSampleCountFlagBits rasterizationSamples;
2894 VK_FALSE, // VkBool32 sampleShadingEnable;
2895 0.0f, // float minSampleShading;
2896 DE_NULL, // const VkSampleMask* pSampleMask;
2897 VK_FALSE, // VkBool32 alphaToCoverageEnable;
2898 VK_FALSE // VkBool32 alphaToOneEnable;
2901 const VkPipelineColorBlendAttachmentState colorBlendAttachmentState =
2903 false, // VkBool32 blendEnable;
2904 VK_BLEND_FACTOR_ONE, // VkBlend srcBlendColor;
2905 VK_BLEND_FACTOR_ZERO, // VkBlend destBlendColor;
2906 VK_BLEND_OP_ADD, // VkBlendOp blendOpColor;
2907 VK_BLEND_FACTOR_ONE, // VkBlend srcBlendAlpha;
2908 VK_BLEND_FACTOR_ZERO, // VkBlend destBlendAlpha;
2909 VK_BLEND_OP_ADD, // VkBlendOp blendOpAlpha;
2910 (VK_COLOR_COMPONENT_R_BIT |
2911 VK_COLOR_COMPONENT_G_BIT |
2912 VK_COLOR_COMPONENT_B_BIT |
2913 VK_COLOR_COMPONENT_A_BIT) // VkChannelFlags channelWriteMask;
2916 const VkPipelineColorBlendStateCreateInfo colorBlendStateParams =
2918 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // VkStructureType sType;
2919 DE_NULL, // const void* pNext;
2920 0u, // VkPipelineColorBlendStateCreateFlags flags;
2921 false, // VkBool32 logicOpEnable;
2922 VK_LOGIC_OP_COPY, // VkLogicOp logicOp;
2923 1u, // deUint32 attachmentCount;
2924 &colorBlendAttachmentState, // const VkPipelineColorBlendAttachmentState* pAttachments;
2925 { 0.0f, 0.0f, 0.0f, 0.0f } // float blendConstants[4];
2928 const VkGraphicsPipelineCreateInfo graphicsPipelineParams =
2930 VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // VkStructureType sType;
2931 DE_NULL, // const void* pNext;
2932 0u, // VkPipelineCreateFlags flags;
2933 2u, // deUint32 stageCount;
2934 shaderStageParams, // const VkPipelineShaderStageCreateInfo* pStages;
2935 &vertexInputStateParams, // const VkPipelineVertexInputStateCreateInfo* pVertexInputState;
2936 &inputAssemblyStateParams, // const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState;
2937 DE_NULL, // const VkPipelineTessellationStateCreateInfo* pTessellationState;
2938 &viewportStateParams, // const VkPipelineViewportStateCreateInfo* pViewportState;
2939 &rasterStateParams, // const VkPipelineRasterizationStateCreateInfo* pRasterizationState;
2940 &multisampleStateParams, // const VkPipelineMultisampleStateCreateInfo* pMultisampleState;
2941 DE_NULL, // const VkPipelineDepthStencilStateCreateInfo* pDepthStencilState;
2942 &colorBlendStateParams, // const VkPipelineColorBlendStateCreateInfo* pColorBlendState;
2943 DE_NULL, // const VkPipelineDynamicStateCreateInfo* pDynamicState;
2944 *pipelineLayout, // VkPipelineLayout layout;
2945 *renderPass, // VkRenderPass renderPass;
2946 0u, // deUint32 subpass;
2947 0u, // VkPipeline basePipelineHandle;
2948 0u // deInt32 basePipelineIndex;
2951 graphicsPipeline = createGraphicsPipeline(vk, vkDevice, DE_NULL, &graphicsPipelineParams);
2954 // Create command buffer
2956 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
2958 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
2959 DE_NULL, // const void* pNext;
2960 0u, // VkCommandBufferUsageFlags flags;
2961 (const VkCommandBufferInheritanceInfo*)DE_NULL,
2964 const VkClearValue clearValues[1] =
2966 makeClearValueColorF32(0.0f, 0.0f, 1.0f, 1.0f),
2969 const VkRenderPassBeginInfo renderPassBeginInfo =
2971 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // VkStructureType sType;
2972 DE_NULL, // const void* pNext;
2973 *renderPass, // VkRenderPass renderPass;
2974 *framebuffer, // VkFramebuffer framebuffer;
2977 { m_params.src.image.extent.width, m_params.src.image.extent.height }
2978 }, // VkRect2D renderArea;
2979 1u, // deUint32 clearValueCount;
2980 clearValues // const VkClearValue* pClearValues;
2983 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
2984 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);
2985 vk.cmdBeginRenderPass(*m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
2987 const VkDeviceSize vertexBufferOffset = 0u;
2989 vk.cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *graphicsPipeline);
2990 vk.cmdBindVertexBuffers(*m_cmdBuffer, 0, 1, &vertexBuffer.get(), &vertexBufferOffset);
2991 vk.cmdDraw(*m_cmdBuffer, (deUint32)vertices.size(), 1, 0, 0);
2993 vk.cmdEndRenderPass(*m_cmdBuffer);
2994 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
2999 const VkQueue queue = m_context.getUniversalQueue();
3000 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
3005 tcu::TestStatus ResolveImageToImage::iterate (void)
3007 const tcu::TextureFormat srcTcuFormat = mapVkFormat(m_params.src.image.format);
3008 const tcu::TextureFormat dstTcuFormat = mapVkFormat(m_params.dst.image.format);
3010 // upload the destination image
3011 m_destinationTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(dstTcuFormat,
3012 (int)m_params.dst.image.extent.width,
3013 (int)m_params.dst.image.extent.height,
3014 (int)m_params.dst.image.extent.depth));
3015 generateBuffer(m_destinationTextureLevel->getAccess(), m_params.dst.image.extent.width, m_params.dst.image.extent.height, m_params.dst.image.extent.depth);
3016 uploadImage(m_destinationTextureLevel->getAccess(), m_destination.get(), m_params.dst.image);
3018 m_sourceTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(srcTcuFormat,
3019 (int)m_params.src.image.extent.width,
3020 (int)m_params.src.image.extent.height,
3021 (int)m_params.dst.image.extent.depth));
3023 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);
3024 generateExpectedResult();
3028 case COPY_MS_IMAGE_TO_MS_IMAGE:
3029 case COPY_MS_IMAGE_TO_ARRAY_MS_IMAGE:
3030 copyMSImageToMSImage();
3036 const DeviceInterface& vk = m_context.getDeviceInterface();
3037 const VkDevice vkDevice = m_context.getDevice();
3038 const VkQueue queue = m_context.getUniversalQueue();
3040 std::vector<VkImageResolve> imageResolves;
3041 for (deUint32 i = 0; i < m_params.regions.size(); i++)
3042 imageResolves.push_back(m_params.regions[i].imageResolve);
3044 const VkImageMemoryBarrier imageBarriers[] =
3048 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
3049 DE_NULL, // const void* pNext;
3050 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags srcAccessMask;
3051 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
3052 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout;
3053 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // VkImageLayout newLayout;
3054 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
3055 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
3056 m_multisampledImage.get(), // VkImage image;
3057 { // VkImageSubresourceRange subresourceRange;
3058 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
3059 0u, // deUint32 baseMipLevel;
3060 1u, // deUint32 mipLevels;
3061 0u, // deUint32 baseArraySlice;
3062 getArraySize(m_params.src.image) // deUint32 arraySize;
3065 // destination image
3067 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
3068 DE_NULL, // const void* pNext;
3069 0u, // VkAccessFlags srcAccessMask;
3070 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
3071 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
3072 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
3073 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
3074 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
3075 m_destination.get(), // VkImage image;
3076 { // VkImageSubresourceRange subresourceRange;
3077 getAspectFlags(dstTcuFormat), // VkImageAspectFlags aspectMask;
3078 0u, // deUint32 baseMipLevel;
3079 1u, // deUint32 mipLevels;
3080 0u, // deUint32 baseArraySlice;
3081 getArraySize(m_params.dst.image) // deUint32 arraySize;
3086 const VkImageMemoryBarrier postImageBarrier =
3088 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
3089 DE_NULL, // const void* pNext;
3090 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
3091 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
3092 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
3093 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
3094 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
3095 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
3096 m_destination.get(), // VkImage image;
3097 { // VkImageSubresourceRange subresourceRange;
3098 getAspectFlags(dstTcuFormat), // VkImageAspectFlags aspectMask;
3099 0u, // deUint32 baseMipLevel;
3100 1u, // deUint32 mipLevels;
3101 0u, // deUint32 baseArraySlice;
3102 getArraySize(m_params.dst.image) // deUint32 arraySize;
3106 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
3108 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
3109 DE_NULL, // const void* pNext;
3110 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
3111 (const VkCommandBufferInheritanceInfo*)DE_NULL,
3114 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
3115 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);
3116 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());
3117 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);
3118 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
3119 submitCommandsAndWait(vk, vkDevice, queue, *m_cmdBuffer);
3121 de::MovePtr<tcu::TextureLevel> resultTextureLevel = readImage(*m_destination, m_params.dst.image);
3123 return checkTestResult(resultTextureLevel->getAccess());
3126 tcu::TestStatus ResolveImageToImage::checkTestResult (tcu::ConstPixelBufferAccess result)
3128 const tcu::ConstPixelBufferAccess expected = m_expectedTextureLevel->getAccess();
3129 const float fuzzyThreshold = 0.01f;
3131 for (int arrayLayerNdx = 0; arrayLayerNdx < (int)getArraySize(m_params.dst.image); ++arrayLayerNdx)
3133 const tcu::ConstPixelBufferAccess expectedSub = getSubregion (expected, 0, 0, arrayLayerNdx, expected.getWidth(), expected.getHeight(), 1u);
3134 const tcu::ConstPixelBufferAccess resultSub = getSubregion (result, 0, 0, arrayLayerNdx, result.getWidth(), result.getHeight(), 1u);
3135 if (!tcu::fuzzyCompare(m_context.getTestContext().getLog(), "Compare", "Result comparsion", expectedSub, resultSub, fuzzyThreshold, tcu::COMPARE_LOG_RESULT))
3136 return tcu::TestStatus::fail("CopiesAndBlitting test");
3139 return tcu::TestStatus::pass("CopiesAndBlitting test");
3142 void ResolveImageToImage::copyRegionToTextureLevel(tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region)
3144 VkOffset3D srcOffset = region.imageResolve.srcOffset;
3145 srcOffset.z = region.imageResolve.srcSubresource.baseArrayLayer;
3146 VkOffset3D dstOffset = region.imageResolve.dstOffset;
3147 dstOffset.z = region.imageResolve.dstSubresource.baseArrayLayer;
3148 VkExtent3D extent = region.imageResolve.extent;
3150 const tcu::ConstPixelBufferAccess srcSubRegion = getSubregion (src, srcOffset.x, srcOffset.y, srcOffset.z, extent.width, extent.height, extent.depth);
3151 // CopyImage acts like a memcpy. Replace the destination format with the srcformat to use a memcpy.
3152 const tcu::PixelBufferAccess dstWithSrcFormat (srcSubRegion.getFormat(), dst.getSize(), dst.getDataPtr());
3153 const tcu::PixelBufferAccess dstSubRegion = getSubregion (dstWithSrcFormat, dstOffset.x, dstOffset.y, dstOffset.z, extent.width, extent.height, extent.depth);
3155 tcu::copy(dstSubRegion, srcSubRegion);
3158 void ResolveImageToImage::copyMSImageToMSImage (void)
3160 const DeviceInterface& vk = m_context.getDeviceInterface();
3161 const VkDevice vkDevice = m_context.getDevice();
3162 const VkQueue queue = m_context.getUniversalQueue();
3163 const tcu::TextureFormat srcTcuFormat = mapVkFormat(m_params.src.image.format);
3164 std::vector<VkImageCopy> imageCopies;
3166 for (deUint32 layerNdx = 0; layerNdx < getArraySize(m_params.dst.image); ++layerNdx)
3168 const VkImageSubresourceLayers sourceSubresourceLayers =
3170 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
3171 0u, // uint32_t mipLevel;
3172 0u, // uint32_t baseArrayLayer;
3173 1u // uint32_t layerCount;
3176 const VkImageSubresourceLayers destinationSubresourceLayers =
3178 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;//getAspectFlags(dstTcuFormat)
3179 0u, // uint32_t mipLevel;
3180 layerNdx, // uint32_t baseArrayLayer;
3181 1u // uint32_t layerCount;
3184 const VkImageCopy imageCopy =
3186 sourceSubresourceLayers, // VkImageSubresourceLayers srcSubresource;
3187 {0, 0, 0}, // VkOffset3D srcOffset;
3188 destinationSubresourceLayers, // VkImageSubresourceLayers dstSubresource;
3189 {0, 0, 0}, // VkOffset3D dstOffset;
3190 getExtent3D(m_params.src.image), // VkExtent3D extent;
3192 imageCopies.push_back(imageCopy);
3195 const VkImageMemoryBarrier imageBarriers[] =
3199 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
3200 DE_NULL, // const void* pNext;
3201 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags srcAccessMask;
3202 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
3203 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout;
3204 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // VkImageLayout newLayout;
3205 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
3206 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
3207 m_multisampledImage.get(), // VkImage image;
3208 { // VkImageSubresourceRange subresourceRange;
3209 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
3210 0u, // deUint32 baseMipLevel;
3211 1u, // deUint32 mipLevels;
3212 0u, // deUint32 baseArraySlice;
3213 getArraySize(m_params.src.image) // deUint32 arraySize;
3216 // destination image
3218 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
3219 DE_NULL, // const void* pNext;
3220 0, // VkAccessFlags srcAccessMask;
3221 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
3222 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
3223 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
3224 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
3225 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
3226 m_multisampledCopyImage.get(), // VkImage image;
3227 { // VkImageSubresourceRange subresourceRange;
3228 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
3229 0u, // deUint32 baseMipLevel;
3230 1u, // deUint32 mipLevels;
3231 0u, // deUint32 baseArraySlice;
3232 getArraySize(m_params.dst.image) // deUint32 arraySize;
3237 const VkImageMemoryBarrier postImageBarriers =
3240 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
3241 DE_NULL, // const void* pNext;
3242 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
3243 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags dstAccessMask;
3244 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
3245 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout newLayout;
3246 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
3247 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
3248 m_multisampledCopyImage.get(), // VkImage image;
3249 { // VkImageSubresourceRange subresourceRange;
3250 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
3251 0u, // deUint32 baseMipLevel;
3252 1u, // deUint32 mipLevels;
3253 0u, // deUint32 baseArraySlice;
3254 getArraySize(m_params.dst.image) // deUint32 arraySize;
3258 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
3260 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
3261 DE_NULL, // const void* pNext;
3262 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
3263 (const VkCommandBufferInheritanceInfo*)DE_NULL,
3266 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
3267 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);
3268 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());
3269 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);
3270 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
3272 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
3274 m_multisampledImage = m_multisampledCopyImage;
3277 class ResolveImageToImageTestCase : public vkt::TestCase
3280 ResolveImageToImageTestCase (tcu::TestContext& testCtx,
3281 const std::string& name,
3282 const std::string& description,
3283 const TestParams params,
3284 const ResolveImageToImageOptions options = NO_OPTIONAL_OPERATION)
3285 : vkt::TestCase (testCtx, name, description)
3287 , m_options (options)
3289 virtual void initPrograms (SourceCollections& programCollection) const;
3291 virtual TestInstance* createInstance (Context& context) const
3293 return new ResolveImageToImage(context, m_params, m_options);
3296 TestParams m_params;
3297 const ResolveImageToImageOptions m_options;
3300 void ResolveImageToImageTestCase::initPrograms (SourceCollections& programCollection) const
3302 programCollection.glslSources.add("vert") << glu::VertexSource(
3304 "layout (location = 0) in highp vec4 a_position;\n"
3307 " gl_Position = a_position;\n"
3311 programCollection.glslSources.add("frag") << glu::FragmentSource(
3313 "layout (location = 0) out highp vec4 o_color;\n"
3316 " o_color = vec4(0.0, 1.0, 0.0, 1.0);\n"
3320 std::string getSampleCountCaseName (VkSampleCountFlagBits sampleFlag)
3322 return de::toLower(de::toString(getSampleCountFlagsStr(sampleFlag)).substr(16));
3325 std::string getFormatCaseName (VkFormat format)
3327 return de::toLower(de::toString(getFormatStr(format)).substr(10));
3330 std::string getImageLayoutCaseName (VkImageLayout layout)
3334 case VK_IMAGE_LAYOUT_GENERAL:
3336 case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
3337 case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
3345 const deInt32 defaultSize = 64;
3346 const deInt32 defaultHalfSize = defaultSize / 2;
3347 const deInt32 defaultFourthSize = defaultSize / 4;
3348 const VkExtent3D defaultExtent = {defaultSize, defaultSize, 1};
3349 const VkExtent3D defaultHalfExtent = {defaultHalfSize, defaultHalfSize, 1};
3351 const VkImageSubresourceLayers defaultSourceLayer =
3353 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
3354 0u, // uint32_t mipLevel;
3355 0u, // uint32_t baseArrayLayer;
3356 1u, // uint32_t layerCount;
3359 void addImageToImageSimpleTests (tcu::TestCaseGroup* group)
3361 tcu::TestContext& testCtx = group->getTestContext();
3365 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3366 params.src.image.format = VK_FORMAT_R8G8B8A8_UINT;
3367 params.src.image.extent = defaultExtent;
3368 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
3369 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3370 params.dst.image.format = VK_FORMAT_R8G8B8A8_UINT;
3371 params.dst.image.extent = defaultExtent;
3372 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
3375 const VkImageCopy testCopy =
3377 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
3378 {0, 0, 0}, // VkOffset3D srcOffset;
3379 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
3380 {0, 0, 0}, // VkOffset3D dstOffset;
3381 defaultExtent, // VkExtent3D extent;
3384 CopyRegion imageCopy;
3385 imageCopy.imageCopy = testCopy;
3387 params.regions.push_back(imageCopy);
3390 group->addChild(new CopyImageToImageTestCase(testCtx, "whole_image", "Whole image", params));
3395 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3396 params.src.image.format = VK_FORMAT_R8G8B8A8_UINT;
3397 params.src.image.extent = defaultExtent;
3398 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
3399 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3400 params.dst.image.format = VK_FORMAT_R32_UINT;
3401 params.dst.image.extent = defaultExtent;
3402 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
3405 const VkImageCopy testCopy =
3407 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
3408 {0, 0, 0}, // VkOffset3D srcOffset;
3409 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
3410 {0, 0, 0}, // VkOffset3D dstOffset;
3411 defaultExtent, // VkExtent3D extent;
3414 CopyRegion imageCopy;
3415 imageCopy.imageCopy = testCopy;
3417 params.regions.push_back(imageCopy);
3420 group->addChild(new CopyImageToImageTestCase(testCtx, "whole_image_diff_fromat", "Whole image with different format", params));
3425 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3426 params.src.image.format = VK_FORMAT_R8G8B8A8_UINT;
3427 params.src.image.extent = defaultExtent;
3428 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
3429 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3430 params.dst.image.format = VK_FORMAT_R8G8B8A8_UINT;
3431 params.dst.image.extent = defaultExtent;
3432 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
3435 const VkImageCopy testCopy =
3437 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
3438 {0, 0, 0}, // VkOffset3D srcOffset;
3439 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
3440 {defaultFourthSize, defaultFourthSize / 2, 0}, // VkOffset3D dstOffset;
3441 {defaultFourthSize / 2, defaultFourthSize / 2, 1}, // VkExtent3D extent;
3444 CopyRegion imageCopy;
3445 imageCopy.imageCopy = testCopy;
3447 params.regions.push_back(imageCopy);
3450 group->addChild(new CopyImageToImageTestCase(testCtx, "partial_image", "Partial image", params));
3455 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3456 params.src.image.format = VK_FORMAT_D32_SFLOAT;
3457 params.src.image.extent = defaultExtent;
3458 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
3459 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3460 params.dst.image.format = VK_FORMAT_D32_SFLOAT;
3461 params.dst.image.extent = defaultExtent;
3462 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
3465 const VkImageSubresourceLayers sourceLayer =
3467 VK_IMAGE_ASPECT_DEPTH_BIT, // VkImageAspectFlags aspectMask;
3468 0u, // uint32_t mipLevel;
3469 0u, // uint32_t baseArrayLayer;
3470 1u // uint32_t layerCount;
3472 const VkImageCopy testCopy =
3474 sourceLayer, // VkImageSubresourceLayers srcSubresource;
3475 {0, 0, 0}, // VkOffset3D srcOffset;
3476 sourceLayer, // VkImageSubresourceLayers dstSubresource;
3477 {defaultFourthSize, defaultFourthSize / 2, 0}, // VkOffset3D dstOffset;
3478 {defaultFourthSize / 2, defaultFourthSize / 2, 1}, // VkExtent3D extent;
3481 CopyRegion imageCopy;
3482 imageCopy.imageCopy = testCopy;
3484 params.regions.push_back(imageCopy);
3487 group->addChild(new CopyImageToImageTestCase(testCtx, "depth", "With depth", params));
3492 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3493 params.src.image.format = VK_FORMAT_S8_UINT;
3494 params.src.image.extent = defaultExtent;
3495 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
3496 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3497 params.dst.image.format = VK_FORMAT_S8_UINT;
3498 params.dst.image.extent = defaultExtent;
3499 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
3502 const VkImageSubresourceLayers sourceLayer =
3504 VK_IMAGE_ASPECT_STENCIL_BIT, // VkImageAspectFlags aspectMask;
3505 0u, // uint32_t mipLevel;
3506 0u, // uint32_t baseArrayLayer;
3507 1u // uint32_t layerCount;
3509 const VkImageCopy testCopy =
3511 sourceLayer, // VkImageSubresourceLayers srcSubresource;
3512 {0, 0, 0}, // VkOffset3D srcOffset;
3513 sourceLayer, // VkImageSubresourceLayers dstSubresource;
3514 {defaultFourthSize, defaultFourthSize / 2, 0}, // VkOffset3D dstOffset;
3515 {defaultFourthSize / 2, defaultFourthSize / 2, 1}, // VkExtent3D extent;
3518 CopyRegion imageCopy;
3519 imageCopy.imageCopy = testCopy;
3521 params.regions.push_back(imageCopy);
3524 group->addChild(new CopyImageToImageTestCase(testCtx, "stencil", "With stencil", params));
3528 struct CopyColorTestParams
3531 const VkFormat* compatibleFormats;
3534 void addImageToImageAllFormatsColorSrcFormatDstFormatTests (tcu::TestCaseGroup* group, TestParams params)
3536 const VkImageLayout copySrcLayouts[] =
3538 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
3539 VK_IMAGE_LAYOUT_GENERAL
3541 const VkImageLayout copyDstLayouts[] =
3543 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
3544 VK_IMAGE_LAYOUT_GENERAL
3547 for (int srcLayoutNdx = 0u; srcLayoutNdx < DE_LENGTH_OF_ARRAY(copySrcLayouts); ++srcLayoutNdx)
3549 params.src.image.operationLayout = copySrcLayouts[srcLayoutNdx];
3551 for (int dstLayoutNdx = 0u; dstLayoutNdx < DE_LENGTH_OF_ARRAY(copyDstLayouts); ++dstLayoutNdx)
3553 params.dst.image.operationLayout = copyDstLayouts[dstLayoutNdx];
3555 const std::string testName = getImageLayoutCaseName(params.src.image.operationLayout) + "_" +
3556 getImageLayoutCaseName(params.dst.image.operationLayout);
3557 const std::string description = "From layout " + getImageLayoutCaseName(params.src.image.operationLayout) +
3558 " to " + getImageLayoutCaseName(params.dst.image.operationLayout);
3560 group->addChild(new CopyImageToImageTestCase(group->getTestContext(), testName, description, params));
3565 void addImageToImageAllFormatsColorSrcFormatTests (tcu::TestCaseGroup* group, CopyColorTestParams testParams)
3567 for (int dstFormatIndex = 0; testParams.compatibleFormats[dstFormatIndex] != VK_FORMAT_UNDEFINED; ++dstFormatIndex)
3569 testParams.params.dst.image.format = testParams.compatibleFormats[dstFormatIndex];
3570 if (!isSupportedByFramework(testParams.params.dst.image.format))
3573 const std::string description = "Copy to destination format " + getFormatCaseName(testParams.params.dst.image.format);
3574 addTestGroup(group, getFormatCaseName(testParams.params.dst.image.format), description, addImageToImageAllFormatsColorSrcFormatDstFormatTests, testParams.params);
3578 const VkFormat compatibleFormats8Bit[] =
3580 VK_FORMAT_R4G4_UNORM_PACK8,
3583 VK_FORMAT_R8_USCALED,
3584 VK_FORMAT_R8_SSCALED,
3591 const VkFormat compatibleFormats16Bit[] =
3593 VK_FORMAT_R4G4B4A4_UNORM_PACK16,
3594 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
3595 VK_FORMAT_R5G6B5_UNORM_PACK16,
3596 VK_FORMAT_B5G6R5_UNORM_PACK16,
3597 VK_FORMAT_R5G5B5A1_UNORM_PACK16,
3598 VK_FORMAT_B5G5R5A1_UNORM_PACK16,
3599 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
3600 VK_FORMAT_R8G8_UNORM,
3601 VK_FORMAT_R8G8_SNORM,
3602 VK_FORMAT_R8G8_USCALED,
3603 VK_FORMAT_R8G8_SSCALED,
3604 VK_FORMAT_R8G8_UINT,
3605 VK_FORMAT_R8G8_SINT,
3606 VK_FORMAT_R8G8_SRGB,
3607 VK_FORMAT_R16_UNORM,
3608 VK_FORMAT_R16_SNORM,
3609 VK_FORMAT_R16_USCALED,
3610 VK_FORMAT_R16_SSCALED,
3613 VK_FORMAT_R16_SFLOAT,
3617 const VkFormat compatibleFormats24Bit[] =
3619 VK_FORMAT_R8G8B8_UNORM,
3620 VK_FORMAT_R8G8B8_SNORM,
3621 VK_FORMAT_R8G8B8_USCALED,
3622 VK_FORMAT_R8G8B8_SSCALED,
3623 VK_FORMAT_R8G8B8_UINT,
3624 VK_FORMAT_R8G8B8_SINT,
3625 VK_FORMAT_R8G8B8_SRGB,
3626 VK_FORMAT_B8G8R8_UNORM,
3627 VK_FORMAT_B8G8R8_SNORM,
3628 VK_FORMAT_B8G8R8_USCALED,
3629 VK_FORMAT_B8G8R8_SSCALED,
3630 VK_FORMAT_B8G8R8_UINT,
3631 VK_FORMAT_B8G8R8_SINT,
3632 VK_FORMAT_B8G8R8_SRGB,
3636 const VkFormat compatibleFormats32Bit[] =
3638 VK_FORMAT_R8G8B8A8_UNORM,
3639 VK_FORMAT_R8G8B8A8_SNORM,
3640 VK_FORMAT_R8G8B8A8_USCALED,
3641 VK_FORMAT_R8G8B8A8_SSCALED,
3642 VK_FORMAT_R8G8B8A8_UINT,
3643 VK_FORMAT_R8G8B8A8_SINT,
3644 VK_FORMAT_R8G8B8A8_SRGB,
3645 VK_FORMAT_B8G8R8A8_UNORM,
3646 VK_FORMAT_B8G8R8A8_SNORM,
3647 VK_FORMAT_B8G8R8A8_USCALED,
3648 VK_FORMAT_B8G8R8A8_SSCALED,
3649 VK_FORMAT_B8G8R8A8_UINT,
3650 VK_FORMAT_B8G8R8A8_SINT,
3651 VK_FORMAT_B8G8R8A8_SRGB,
3652 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
3653 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
3654 VK_FORMAT_A8B8G8R8_USCALED_PACK32,
3655 VK_FORMAT_A8B8G8R8_SSCALED_PACK32,
3656 VK_FORMAT_A8B8G8R8_UINT_PACK32,
3657 VK_FORMAT_A8B8G8R8_SINT_PACK32,
3658 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
3659 VK_FORMAT_A2R10G10B10_UNORM_PACK32,
3660 VK_FORMAT_A2R10G10B10_SNORM_PACK32,
3661 VK_FORMAT_A2R10G10B10_USCALED_PACK32,
3662 VK_FORMAT_A2R10G10B10_SSCALED_PACK32,
3663 VK_FORMAT_A2R10G10B10_UINT_PACK32,
3664 VK_FORMAT_A2R10G10B10_SINT_PACK32,
3665 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
3666 VK_FORMAT_A2B10G10R10_SNORM_PACK32,
3667 VK_FORMAT_A2B10G10R10_USCALED_PACK32,
3668 VK_FORMAT_A2B10G10R10_SSCALED_PACK32,
3669 VK_FORMAT_A2B10G10R10_UINT_PACK32,
3670 VK_FORMAT_A2B10G10R10_SINT_PACK32,
3671 VK_FORMAT_R16G16_UNORM,
3672 VK_FORMAT_R16G16_SNORM,
3673 VK_FORMAT_R16G16_USCALED,
3674 VK_FORMAT_R16G16_SSCALED,
3675 VK_FORMAT_R16G16_UINT,
3676 VK_FORMAT_R16G16_SINT,
3677 VK_FORMAT_R16G16_SFLOAT,
3680 VK_FORMAT_R32_SFLOAT,
3684 const VkFormat compatibleFormats48Bit[] =
3686 VK_FORMAT_R16G16B16_UNORM,
3687 VK_FORMAT_R16G16B16_SNORM,
3688 VK_FORMAT_R16G16B16_USCALED,
3689 VK_FORMAT_R16G16B16_SSCALED,
3690 VK_FORMAT_R16G16B16_UINT,
3691 VK_FORMAT_R16G16B16_SINT,
3692 VK_FORMAT_R16G16B16_SFLOAT,
3696 const VkFormat compatibleFormats64Bit[] =
3698 VK_FORMAT_R16G16B16A16_UNORM,
3699 VK_FORMAT_R16G16B16A16_SNORM,
3700 VK_FORMAT_R16G16B16A16_USCALED,
3701 VK_FORMAT_R16G16B16A16_SSCALED,
3702 VK_FORMAT_R16G16B16A16_UINT,
3703 VK_FORMAT_R16G16B16A16_SINT,
3704 VK_FORMAT_R16G16B16A16_SFLOAT,
3705 VK_FORMAT_R32G32_UINT,
3706 VK_FORMAT_R32G32_SINT,
3707 VK_FORMAT_R32G32_SFLOAT,
3710 VK_FORMAT_R64_SFLOAT,
3714 const VkFormat compatibleFormats96Bit[] =
3716 VK_FORMAT_R32G32B32_UINT,
3717 VK_FORMAT_R32G32B32_SINT,
3718 VK_FORMAT_R32G32B32_SFLOAT,
3722 const VkFormat compatibleFormats128Bit[] =
3724 VK_FORMAT_R32G32B32A32_UINT,
3725 VK_FORMAT_R32G32B32A32_SINT,
3726 VK_FORMAT_R32G32B32A32_SFLOAT,
3727 VK_FORMAT_R64G64_UINT,
3728 VK_FORMAT_R64G64_SINT,
3729 VK_FORMAT_R64G64_SFLOAT,
3733 const VkFormat compatibleFormats192Bit[] =
3735 VK_FORMAT_R64G64B64_UINT,
3736 VK_FORMAT_R64G64B64_SINT,
3737 VK_FORMAT_R64G64B64_SFLOAT,
3741 const VkFormat compatibleFormats256Bit[] =
3743 VK_FORMAT_R64G64B64A64_UINT,
3744 VK_FORMAT_R64G64B64A64_SINT,
3745 VK_FORMAT_R64G64B64A64_SFLOAT,
3750 const VkFormat* colorImageFormatsToTest[] =
3752 compatibleFormats8Bit,
3753 compatibleFormats16Bit,
3754 compatibleFormats24Bit,
3755 compatibleFormats32Bit,
3756 compatibleFormats48Bit,
3757 compatibleFormats64Bit,
3758 compatibleFormats96Bit,
3759 compatibleFormats128Bit,
3760 compatibleFormats192Bit,
3761 compatibleFormats256Bit,
3764 void addImageToImageAllFormatsColorTests (tcu::TestCaseGroup* group)
3767 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3768 params.src.image.extent = defaultExtent;
3769 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3770 params.dst.image.extent = defaultExtent;
3772 for (deInt32 i = 0; i < defaultSize; i += defaultFourthSize)
3774 const VkImageCopy testCopy =
3776 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
3777 {0, 0, 0}, // VkOffset3D srcOffset;
3778 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
3779 {i, defaultSize - i - defaultFourthSize, 0}, // VkOffset3D dstOffset;
3780 {defaultFourthSize, defaultFourthSize, 1}, // VkExtent3D extent;
3783 CopyRegion imageCopy;
3784 imageCopy.imageCopy = testCopy;
3786 params.regions.push_back(imageCopy);
3789 const int numOfColorImageFormatsToTest = DE_LENGTH_OF_ARRAY(colorImageFormatsToTest);
3790 for (int compatibleFormatsIndex = 0; compatibleFormatsIndex < numOfColorImageFormatsToTest; ++compatibleFormatsIndex)
3792 const VkFormat* compatibleFormats = colorImageFormatsToTest[compatibleFormatsIndex];
3793 for (int srcFormatIndex = 0; compatibleFormats[srcFormatIndex] != VK_FORMAT_UNDEFINED; ++srcFormatIndex)
3795 params.src.image.format = compatibleFormats[srcFormatIndex];
3796 if (!isSupportedByFramework(params.src.image.format))
3799 CopyColorTestParams testParams;
3800 testParams.params = params;
3801 testParams.compatibleFormats = compatibleFormats;
3803 const std::string description = "Copy from source format " + getFormatCaseName(params.src.image.format);
3804 addTestGroup(group, getFormatCaseName(params.src.image.format), description, addImageToImageAllFormatsColorSrcFormatTests, testParams);
3809 void addImageToImageAllFormatsDepthStencilFormatsTests (tcu::TestCaseGroup* group, TestParams params)
3811 const VkImageLayout copySrcLayouts[] =
3813 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
3814 VK_IMAGE_LAYOUT_GENERAL
3816 const VkImageLayout copyDstLayouts[] =
3818 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
3819 VK_IMAGE_LAYOUT_GENERAL
3822 for (int srcLayoutNdx = 0u; srcLayoutNdx < DE_LENGTH_OF_ARRAY(copySrcLayouts); ++srcLayoutNdx)
3824 params.src.image.operationLayout = copySrcLayouts[srcLayoutNdx];
3825 for (int dstLayoutNdx = 0u; dstLayoutNdx < DE_LENGTH_OF_ARRAY(copyDstLayouts); ++dstLayoutNdx)
3827 params.dst.image.operationLayout = copyDstLayouts[dstLayoutNdx];
3829 const std::string testName = getImageLayoutCaseName(params.src.image.operationLayout) + "_" +
3830 getImageLayoutCaseName(params.dst.image.operationLayout);
3831 const std::string description = "From layout " + getImageLayoutCaseName(params.src.image.operationLayout) +
3832 " to " + getImageLayoutCaseName(params.dst.image.operationLayout);
3833 group->addChild(new CopyImageToImageTestCase(group->getTestContext(), testName, description, params));
3838 void addImageToImageAllFormatsDepthStencilTests (tcu::TestCaseGroup* group)
3840 const VkFormat depthAndStencilFormats[] =
3842 VK_FORMAT_D16_UNORM,
3843 VK_FORMAT_X8_D24_UNORM_PACK32,
3844 VK_FORMAT_D32_SFLOAT,
3846 VK_FORMAT_D16_UNORM_S8_UINT,
3847 VK_FORMAT_D24_UNORM_S8_UINT,
3848 VK_FORMAT_D32_SFLOAT_S8_UINT,
3851 for (int compatibleFormatsIndex = 0; compatibleFormatsIndex < DE_LENGTH_OF_ARRAY(depthAndStencilFormats); ++compatibleFormatsIndex)
3854 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3855 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3856 params.src.image.extent = defaultExtent;
3857 params.dst.image.extent = defaultExtent;
3858 params.src.image.format = depthAndStencilFormats[compatibleFormatsIndex];
3859 params.dst.image.format = params.src.image.format;
3861 const VkImageSubresourceLayers defaultDepthSourceLayer = { VK_IMAGE_ASPECT_DEPTH_BIT, 0u, 0u, 1u };
3862 const VkImageSubresourceLayers defaultStencilSourceLayer = { VK_IMAGE_ASPECT_STENCIL_BIT, 0u, 0u, 1u };
3864 for (deInt32 i = 0; i < defaultSize; i += defaultFourthSize)
3866 CopyRegion copyRegion;
3867 const VkOffset3D srcOffset = {0, 0, 0};
3868 const VkOffset3D dstOffset = {i, defaultSize - i - defaultFourthSize, 0};
3869 const VkExtent3D extent = {defaultFourthSize, defaultFourthSize, 1};
3871 if (tcu::hasDepthComponent(mapVkFormat(params.src.image.format).order))
3873 const VkImageCopy testCopy =
3875 defaultDepthSourceLayer, // VkImageSubresourceLayers srcSubresource;
3876 srcOffset, // VkOffset3D srcOffset;
3877 defaultDepthSourceLayer, // VkImageSubresourceLayers dstSubresource;
3878 dstOffset, // VkOffset3D dstOffset;
3879 extent, // VkExtent3D extent;
3882 copyRegion.imageCopy = testCopy;
3883 params.regions.push_back(copyRegion);
3885 if (tcu::hasStencilComponent(mapVkFormat(params.src.image.format).order))
3887 const VkImageCopy testCopy =
3889 defaultStencilSourceLayer, // VkImageSubresourceLayers srcSubresource;
3890 srcOffset, // VkOffset3D srcOffset;
3891 defaultStencilSourceLayer, // VkImageSubresourceLayers dstSubresource;
3892 dstOffset, // VkOffset3D dstOffset;
3893 extent, // VkExtent3D extent;
3896 copyRegion.imageCopy = testCopy;
3897 params.regions.push_back(copyRegion);
3901 const std::string testName = getFormatCaseName(params.src.image.format) + "_" + getFormatCaseName(params.dst.image.format);
3902 const std::string description = "Copy from " + getFormatCaseName(params.src.image.format) + " to " + getFormatCaseName(params.dst.image.format);
3903 addTestGroup(group, testName, description, addImageToImageAllFormatsDepthStencilFormatsTests, params);
3907 void addImageToImageAllFormatsTests (tcu::TestCaseGroup* group)
3909 addTestGroup(group, "color", "Copy image to image with color formats", addImageToImageAllFormatsColorTests);
3910 addTestGroup(group, "depth_stencil", "Copy image to image with depth/stencil formats", addImageToImageAllFormatsDepthStencilTests);
3913 void addImageToImage3dImagesTests (tcu::TestCaseGroup* group)
3915 tcu::TestContext& testCtx = group->getTestContext();
3918 TestParams params3DTo2D;
3919 const deUint32 slicesLayers = 16u;
3920 params3DTo2D.src.image.imageType = VK_IMAGE_TYPE_3D;
3921 params3DTo2D.src.image.format = VK_FORMAT_R8G8B8A8_UINT;
3922 params3DTo2D.src.image.extent = defaultHalfExtent;
3923 params3DTo2D.src.image.extent.depth = slicesLayers;
3924 params3DTo2D.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
3925 params3DTo2D.dst.image.imageType = VK_IMAGE_TYPE_2D;
3926 params3DTo2D.dst.image.format = VK_FORMAT_R8G8B8A8_UINT;
3927 params3DTo2D.dst.image.extent = defaultHalfExtent;
3928 params3DTo2D.dst.image.extent.depth = slicesLayers;
3929 params3DTo2D.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
3931 for (deUint32 slicesLayersNdx = 0; slicesLayersNdx < slicesLayers; ++slicesLayersNdx)
3933 const VkImageSubresourceLayers sourceLayer =
3935 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
3936 0u, // uint32_t mipLevel;
3937 0u, // uint32_t baseArrayLayer;
3938 1u // uint32_t layerCount;
3941 const VkImageSubresourceLayers destinationLayer =
3943 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
3944 0u, // uint32_t mipLevel;
3945 slicesLayersNdx, // uint32_t baseArrayLayer;
3946 1u // uint32_t layerCount;
3949 const VkImageCopy testCopy =
3951 sourceLayer, // VkImageSubresourceLayers srcSubresource;
3952 {0, 0, (deInt32)slicesLayersNdx}, // VkOffset3D srcOffset;
3953 destinationLayer, // VkImageSubresourceLayers dstSubresource;
3954 {0, 0, 0}, // VkOffset3D dstOffset;
3955 defaultHalfExtent, // VkExtent3D extent;
3958 CopyRegion imageCopy;
3959 imageCopy.imageCopy = testCopy;
3961 params3DTo2D.regions.push_back(imageCopy);
3963 group->addChild(new CopyImageToImageTestCase(testCtx, "3d_to_2d_by_slices", "copy 2d layers to 3d slices one by one", params3DTo2D));
3967 TestParams params2DTo3D;
3968 const deUint32 slicesLayers = 16u;
3969 params2DTo3D.src.image.imageType = VK_IMAGE_TYPE_2D;
3970 params2DTo3D.src.image.format = VK_FORMAT_R8G8B8A8_UINT;
3971 params2DTo3D.src.image.extent = defaultHalfExtent;
3972 params2DTo3D.src.image.extent.depth = slicesLayers;
3973 params2DTo3D.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
3974 params2DTo3D.dst.image.imageType = VK_IMAGE_TYPE_3D;
3975 params2DTo3D.dst.image.format = VK_FORMAT_R8G8B8A8_UINT;
3976 params2DTo3D.dst.image.extent = defaultHalfExtent;
3977 params2DTo3D.dst.image.extent.depth = slicesLayers;
3978 params2DTo3D.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
3980 for (deUint32 slicesLayersNdx = 0; slicesLayersNdx < slicesLayers; ++slicesLayersNdx)
3982 const VkImageSubresourceLayers sourceLayer =
3984 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
3985 0u, // uint32_t mipLevel;
3986 slicesLayersNdx, // uint32_t baseArrayLayer;
3987 1u // uint32_t layerCount;
3990 const VkImageSubresourceLayers destinationLayer =
3992 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
3993 0u, // uint32_t mipLevel;
3994 0u, // uint32_t baseArrayLayer;
3995 1u // uint32_t layerCount;
3998 const VkImageCopy testCopy =
4000 sourceLayer, // VkImageSubresourceLayers srcSubresource;
4001 {0, 0, 0}, // VkOffset3D srcOffset;
4002 destinationLayer, // VkImageSubresourceLayers dstSubresource;
4003 {0, 0, (deInt32)slicesLayersNdx}, // VkOffset3D dstOffset;
4004 defaultHalfExtent, // VkExtent3D extent;
4007 CopyRegion imageCopy;
4008 imageCopy.imageCopy = testCopy;
4010 params2DTo3D.regions.push_back(imageCopy);
4013 group->addChild(new CopyImageToImageTestCase(testCtx, "2d_to_3d_by_layers", "copy 3d slices to 2d layers one by one", params2DTo3D));
4017 TestParams params3DTo2D;
4018 const deUint32 slicesLayers = 16u;
4019 params3DTo2D.src.image.imageType = VK_IMAGE_TYPE_3D;
4020 params3DTo2D.src.image.format = VK_FORMAT_R8G8B8A8_UINT;
4021 params3DTo2D.src.image.extent = defaultHalfExtent;
4022 params3DTo2D.src.image.extent.depth = slicesLayers;
4023 params3DTo2D.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
4024 params3DTo2D.dst.image.imageType = VK_IMAGE_TYPE_2D;
4025 params3DTo2D.dst.image.format = VK_FORMAT_R8G8B8A8_UINT;
4026 params3DTo2D.dst.image.extent = defaultHalfExtent;
4027 params3DTo2D.dst.image.extent.depth = slicesLayers;
4028 params3DTo2D.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
4031 const VkImageSubresourceLayers sourceLayer =
4033 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
4034 0u, // uint32_t mipLevel;
4035 0u, // uint32_t baseArrayLayer;
4036 1u // uint32_t layerCount;
4039 const VkImageSubresourceLayers destinationLayer =
4041 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
4042 0u, // uint32_t mipLevel;
4043 0, // uint32_t baseArrayLayer;
4044 slicesLayers // uint32_t layerCount;
4047 const VkImageCopy testCopy =
4049 sourceLayer, // VkImageSubresourceLayers srcSubresource;
4050 {0, 0, 0}, // VkOffset3D srcOffset;
4051 destinationLayer, // VkImageSubresourceLayers dstSubresource;
4052 {0, 0, 0}, // VkOffset3D dstOffset;
4053 params3DTo2D.src.image.extent // VkExtent3D extent;
4056 CopyRegion imageCopy;
4057 imageCopy.imageCopy = testCopy;
4059 params3DTo2D.regions.push_back(imageCopy);
4061 group->addChild(new CopyImageToImageTestCase(testCtx, "3d_to_2d_whole", "copy 3d slices to 2d layers all at once", params3DTo2D));
4065 TestParams params2DTo3D;
4066 const deUint32 slicesLayers = 16u;
4067 params2DTo3D.src.image.imageType = VK_IMAGE_TYPE_2D;
4068 params2DTo3D.src.image.format = VK_FORMAT_R8G8B8A8_UINT;
4069 params2DTo3D.src.image.extent = defaultHalfExtent;
4070 params2DTo3D.src.image.extent.depth = slicesLayers;
4071 params2DTo3D.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
4072 params2DTo3D.dst.image.imageType = VK_IMAGE_TYPE_3D;
4073 params2DTo3D.dst.image.format = VK_FORMAT_R8G8B8A8_UINT;
4074 params2DTo3D.dst.image.extent = defaultHalfExtent;
4075 params2DTo3D.dst.image.extent.depth = slicesLayers;
4076 params2DTo3D.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
4079 const VkImageSubresourceLayers sourceLayer =
4081 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
4082 0u, // uint32_t mipLevel;
4083 0u, // uint32_t baseArrayLayer;
4084 slicesLayers // uint32_t layerCount;
4087 const VkImageSubresourceLayers destinationLayer =
4089 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
4090 0u, // uint32_t mipLevel;
4091 0u, // uint32_t baseArrayLayer;
4092 1u // uint32_t layerCount;
4095 const VkImageCopy testCopy =
4097 sourceLayer, // VkImageSubresourceLayers srcSubresource;
4098 {0, 0, 0}, // VkOffset3D srcOffset;
4099 destinationLayer, // VkImageSubresourceLayers dstSubresource;
4100 {0, 0, 0}, // VkOffset3D dstOffset;
4101 params2DTo3D.dst.image.extent, // VkExtent3D extent;
4104 CopyRegion imageCopy;
4105 imageCopy.imageCopy = testCopy;
4107 params2DTo3D.regions.push_back(imageCopy);
4110 group->addChild(new CopyImageToImageTestCase(testCtx, "2d_to_3d_whole", "copy 2d layers to 3d slices all at once", params2DTo3D));
4114 TestParams params3DTo2D;
4115 const deUint32 slicesLayers = 16u;
4116 params3DTo2D.src.image.imageType = VK_IMAGE_TYPE_3D;
4117 params3DTo2D.src.image.format = VK_FORMAT_R8G8B8A8_UINT;
4118 params3DTo2D.src.image.extent = defaultHalfExtent;
4119 params3DTo2D.src.image.extent.depth = slicesLayers;
4120 params3DTo2D.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
4121 params3DTo2D.dst.image.imageType = VK_IMAGE_TYPE_2D;
4122 params3DTo2D.dst.image.format = VK_FORMAT_R8G8B8A8_UINT;
4123 params3DTo2D.dst.image.extent = defaultHalfExtent;
4124 params3DTo2D.dst.image.extent.depth = slicesLayers;
4125 params3DTo2D.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
4127 const deUint32 regionWidth = defaultHalfExtent.width / slicesLayers -1;
4128 const deUint32 regionHeight = defaultHalfExtent.height / slicesLayers -1 ;
4130 for (deUint32 slicesLayersNdx = 0; slicesLayersNdx < slicesLayers; ++slicesLayersNdx)
4132 const VkImageSubresourceLayers sourceLayer =
4134 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
4135 0u, // uint32_t mipLevel;
4136 0u, // uint32_t baseArrayLayer;
4137 1u // uint32_t layerCount;
4140 const VkImageSubresourceLayers destinationLayer =
4142 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
4143 0u, // uint32_t mipLevel;
4144 slicesLayersNdx, // uint32_t baseArrayLayer;
4145 1u // uint32_t layerCount;
4149 const VkImageCopy testCopy =
4151 sourceLayer, // VkImageSubresourceLayers srcSubresource;
4152 {0, (deInt32)(regionHeight*slicesLayersNdx), (deInt32)slicesLayersNdx}, // VkOffset3D srcOffset;
4153 destinationLayer, // VkImageSubresourceLayers dstSubresource;
4154 {(deInt32)(regionWidth*slicesLayersNdx), 0, 0}, // VkOffset3D dstOffset;
4156 (defaultHalfExtent.width - regionWidth*slicesLayersNdx),
4157 (defaultHalfExtent.height - regionHeight*slicesLayersNdx),
4159 } // VkExtent3D extent;
4162 CopyRegion imageCopy;
4163 imageCopy.imageCopy = testCopy;
4164 params3DTo2D.regions.push_back(imageCopy);
4166 group->addChild(new CopyImageToImageTestCase(testCtx, "3d_to_2d_regions", "copy 3d slices regions to 2d layers", params3DTo2D));
4170 TestParams params2DTo3D;
4171 const deUint32 slicesLayers = 16u;
4172 params2DTo3D.src.image.imageType = VK_IMAGE_TYPE_2D;
4173 params2DTo3D.src.image.format = VK_FORMAT_R8G8B8A8_UINT;
4174 params2DTo3D.src.image.extent = defaultHalfExtent;
4175 params2DTo3D.src.image.extent.depth = slicesLayers;
4176 params2DTo3D.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
4177 params2DTo3D.dst.image.imageType = VK_IMAGE_TYPE_3D;
4178 params2DTo3D.dst.image.format = VK_FORMAT_R8G8B8A8_UINT;
4179 params2DTo3D.dst.image.extent = defaultHalfExtent;
4180 params2DTo3D.dst.image.extent.depth = slicesLayers;
4181 params2DTo3D.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
4183 const deUint32 regionWidth = defaultHalfExtent.width / slicesLayers -1;
4184 const deUint32 regionHeight = defaultHalfExtent.height / slicesLayers -1 ;
4186 for (deUint32 slicesLayersNdx = 0; slicesLayersNdx < slicesLayers; ++slicesLayersNdx)
4188 const VkImageSubresourceLayers sourceLayer =
4190 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
4191 0u, // uint32_t mipLevel;
4192 slicesLayersNdx, // uint32_t baseArrayLayer;
4193 1u // uint32_t layerCount;
4196 const VkImageSubresourceLayers destinationLayer =
4198 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
4199 0u, // uint32_t mipLevel;
4200 0u, // uint32_t baseArrayLayer;
4201 1u // uint32_t layerCount;
4204 const VkImageCopy testCopy =
4206 sourceLayer, // VkImageSubresourceLayers srcSubresource;
4207 {(deInt32)(regionWidth*slicesLayersNdx), 0, 0}, // VkOffset3D srcOffset;
4208 destinationLayer, // VkImageSubresourceLayers dstSubresource;
4209 {0, (deInt32)(regionHeight*slicesLayersNdx), (deInt32)(slicesLayersNdx)}, // VkOffset3D dstOffset;
4211 defaultHalfExtent.width - regionWidth*slicesLayersNdx,
4212 defaultHalfExtent.height - regionHeight*slicesLayersNdx,
4214 } // VkExtent3D extent;
4217 CopyRegion imageCopy;
4218 imageCopy.imageCopy = testCopy;
4220 params2DTo3D.regions.push_back(imageCopy);
4223 group->addChild(new CopyImageToImageTestCase(testCtx, "2d_to_3d_regions", "copy 2d layers regions to 3d slices", params2DTo3D));
4227 void addImageToImageTests (tcu::TestCaseGroup* group)
4229 addTestGroup(group, "simple_tests", "Copy from image to image simple tests", addImageToImageSimpleTests);
4230 addTestGroup(group, "all_formats", "Copy from image to image with all compatible formats", addImageToImageAllFormatsTests);
4231 addTestGroup(group, "3d_images", "Coping operations on 3d images", addImageToImage3dImagesTests);
4234 void addImageToBufferTests (tcu::TestCaseGroup* group)
4236 tcu::TestContext& testCtx = group->getTestContext();
4240 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4241 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4242 params.src.image.extent = defaultExtent;
4243 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
4244 params.dst.buffer.size = defaultSize * defaultSize;
4246 const VkBufferImageCopy bufferImageCopy =
4248 0u, // VkDeviceSize bufferOffset;
4249 0u, // uint32_t bufferRowLength;
4250 0u, // uint32_t bufferImageHeight;
4251 defaultSourceLayer, // VkImageSubresourceLayers imageSubresource;
4252 {0, 0, 0}, // VkOffset3D imageOffset;
4253 defaultExtent // VkExtent3D imageExtent;
4255 CopyRegion copyRegion;
4256 copyRegion.bufferImageCopy = bufferImageCopy;
4258 params.regions.push_back(copyRegion);
4260 group->addChild(new CopyImageToBufferTestCase(testCtx, "whole", "Copy from image to buffer", params));
4265 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4266 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4267 params.src.image.extent = defaultExtent;
4268 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
4269 params.dst.buffer.size = defaultSize * defaultSize;
4271 const VkBufferImageCopy bufferImageCopy =
4273 defaultSize * defaultHalfSize, // VkDeviceSize bufferOffset;
4274 0u, // uint32_t bufferRowLength;
4275 0u, // uint32_t bufferImageHeight;
4276 defaultSourceLayer, // VkImageSubresourceLayers imageSubresource;
4277 {defaultFourthSize, defaultFourthSize, 0}, // VkOffset3D imageOffset;
4278 defaultHalfExtent // VkExtent3D imageExtent;
4280 CopyRegion copyRegion;
4281 copyRegion.bufferImageCopy = bufferImageCopy;
4283 params.regions.push_back(copyRegion);
4285 group->addChild(new CopyImageToBufferTestCase(testCtx, "buffer_offset", "Copy from image to buffer with buffer offset", params));
4290 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4291 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4292 params.src.image.extent = defaultExtent;
4293 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
4294 params.dst.buffer.size = defaultSize * defaultSize;
4296 const int pixelSize = tcu::getPixelSize(mapVkFormat(params.src.image.format));
4297 const VkDeviceSize bufferSize = pixelSize * params.dst.buffer.size;
4298 const VkDeviceSize offsetSize = pixelSize * defaultFourthSize * defaultFourthSize;
4299 deUint32 divisor = 1;
4300 for (VkDeviceSize offset = 0; offset < bufferSize - offsetSize; offset += offsetSize, ++divisor)
4302 const deUint32 bufferRowLength = defaultFourthSize;
4303 const deUint32 bufferImageHeight = defaultFourthSize;
4304 const VkExtent3D imageExtent = {defaultFourthSize / divisor, defaultFourthSize, 1};
4305 DE_ASSERT(!bufferRowLength || bufferRowLength >= imageExtent.width);
4306 DE_ASSERT(!bufferImageHeight || bufferImageHeight >= imageExtent.height);
4307 DE_ASSERT(imageExtent.width * imageExtent.height *imageExtent.depth <= offsetSize);
4310 const VkBufferImageCopy bufferImageCopy =
4312 offset, // VkDeviceSize bufferOffset;
4313 bufferRowLength, // uint32_t bufferRowLength;
4314 bufferImageHeight, // uint32_t bufferImageHeight;
4315 defaultSourceLayer, // VkImageSubresourceLayers imageSubresource;
4316 {0, 0, 0}, // VkOffset3D imageOffset;
4317 imageExtent // VkExtent3D imageExtent;
4319 region.bufferImageCopy = bufferImageCopy;
4320 params.regions.push_back(region);
4323 group->addChild(new CopyImageToBufferTestCase(testCtx, "regions", "Copy from image to buffer with multiple regions", params));
4327 void addBufferToImageTests (tcu::TestCaseGroup* group)
4329 tcu::TestContext& testCtx = group->getTestContext();
4333 params.src.buffer.size = defaultSize * defaultSize;
4334 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4335 params.dst.image.format = VK_FORMAT_R8G8B8A8_UINT;
4336 params.dst.image.extent = defaultExtent;
4337 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
4339 const VkBufferImageCopy bufferImageCopy =
4341 0u, // VkDeviceSize bufferOffset;
4342 0u, // uint32_t bufferRowLength;
4343 0u, // uint32_t bufferImageHeight;
4344 defaultSourceLayer, // VkImageSubresourceLayers imageSubresource;
4345 {0, 0, 0}, // VkOffset3D imageOffset;
4346 defaultExtent // VkExtent3D imageExtent;
4348 CopyRegion copyRegion;
4349 copyRegion.bufferImageCopy = bufferImageCopy;
4351 params.regions.push_back(copyRegion);
4353 group->addChild(new CopyBufferToImageTestCase(testCtx, "whole", "Copy from buffer to image", params));
4358 params.src.buffer.size = defaultSize * defaultSize;
4359 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4360 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4361 params.dst.image.extent = defaultExtent;
4362 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
4365 deUint32 divisor = 1;
4366 for (int offset = 0; (offset + defaultFourthSize / divisor < defaultSize) && (defaultFourthSize > divisor); offset += defaultFourthSize / divisor++)
4368 const VkBufferImageCopy bufferImageCopy =
4370 0u, // VkDeviceSize bufferOffset;
4371 0u, // uint32_t bufferRowLength;
4372 0u, // uint32_t bufferImageHeight;
4373 defaultSourceLayer, // VkImageSubresourceLayers imageSubresource;
4374 {offset, defaultHalfSize, 0}, // VkOffset3D imageOffset;
4375 {defaultFourthSize / divisor, defaultFourthSize / divisor, 1} // VkExtent3D imageExtent;
4377 region.bufferImageCopy = bufferImageCopy;
4378 params.regions.push_back(region);
4381 group->addChild(new CopyBufferToImageTestCase(testCtx, "regions", "Copy from buffer to image with multiple regions", params));
4386 params.src.buffer.size = defaultSize * defaultSize;
4387 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4388 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4389 params.dst.image.extent = defaultExtent;
4390 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
4392 const VkBufferImageCopy bufferImageCopy =
4394 defaultFourthSize, // VkDeviceSize bufferOffset;
4395 defaultHalfSize + defaultFourthSize, // uint32_t bufferRowLength;
4396 defaultHalfSize + defaultFourthSize, // uint32_t bufferImageHeight;
4397 defaultSourceLayer, // VkImageSubresourceLayers imageSubresource;
4398 {defaultFourthSize, defaultFourthSize, 0}, // VkOffset3D imageOffset;
4399 defaultHalfExtent // VkExtent3D imageExtent;
4401 CopyRegion copyRegion;
4402 copyRegion.bufferImageCopy = bufferImageCopy;
4404 params.regions.push_back(copyRegion);
4406 group->addChild(new CopyBufferToImageTestCase(testCtx, "buffer_offset", "Copy from buffer to image with buffer offset", params));
4410 void addBufferToBufferTests (tcu::TestCaseGroup* group)
4412 tcu::TestContext& testCtx = group->getTestContext();
4416 params.src.buffer.size = defaultSize;
4417 params.dst.buffer.size = defaultSize;
4419 const VkBufferCopy bufferCopy =
4421 0u, // VkDeviceSize srcOffset;
4422 0u, // VkDeviceSize dstOffset;
4423 defaultSize, // VkDeviceSize size;
4426 CopyRegion copyRegion;
4427 copyRegion.bufferCopy = bufferCopy;
4428 params.regions.push_back(copyRegion);
4430 group->addChild(new BufferToBufferTestCase(testCtx, "whole", "Whole buffer", params));
4435 params.src.buffer.size = defaultFourthSize;
4436 params.dst.buffer.size = defaultFourthSize;
4438 const VkBufferCopy bufferCopy =
4440 12u, // VkDeviceSize srcOffset;
4441 4u, // VkDeviceSize dstOffset;
4442 1u, // VkDeviceSize size;
4445 CopyRegion copyRegion;
4446 copyRegion.bufferCopy = bufferCopy;
4447 params.regions.push_back(copyRegion);
4449 group->addChild(new BufferToBufferTestCase(testCtx, "partial", "Partial", params));
4453 const deUint32 size = 16;
4455 params.src.buffer.size = size;
4456 params.dst.buffer.size = size * (size + 1);
4458 // Copy region with size 1..size
4459 for (unsigned int i = 1; i <= size; i++)
4461 const VkBufferCopy bufferCopy =
4463 0, // VkDeviceSize srcOffset;
4464 i * size, // VkDeviceSize dstOffset;
4465 i, // VkDeviceSize size;
4468 CopyRegion copyRegion;
4469 copyRegion.bufferCopy = bufferCopy;
4470 params.regions.push_back(copyRegion);
4473 group->addChild(new BufferToBufferTestCase(testCtx, "regions", "Multiple regions", params));
4477 void addBlittingImageSimpleWholeTests (tcu::TestCaseGroup* group)
4479 tcu::TestContext& testCtx = group->getTestContext();
4481 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4482 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4483 params.src.image.extent = defaultExtent;
4484 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
4485 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4486 params.dst.image.extent = defaultExtent;
4487 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
4490 const VkImageBlit imageBlit =
4492 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4495 { defaultSize, defaultSize, 1 }
4496 }, // VkOffset3D srcOffsets[2];
4498 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4501 { defaultSize, defaultSize, 1 }
4502 } // VkOffset3D dstOffset[2];
4506 region.imageBlit = imageBlit;
4507 params.regions.push_back(region);
4510 // Filter is VK_FILTER_NEAREST.
4512 params.filter = VK_FILTER_NEAREST;
4513 const std::string description = "Nearest filter";
4515 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4516 group->addChild(new BlittingTestCase(testCtx, "nearest", description, params));
4518 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4519 const std::string descriptionOfRGBAToR32(description + " and different formats (R8G8B8A8 -> R32)");
4520 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4522 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4523 const std::string descriptionOfRGBAToBGRA(description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4524 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4527 // Filter is VK_FILTER_LINEAR.
4529 params.filter = VK_FILTER_LINEAR;
4530 const std::string description = "Linear filter";
4532 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4533 group->addChild(new BlittingTestCase(testCtx, "linear", description, params));
4535 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4536 const std::string descriptionOfRGBAToR32(description + " and different formats (R8G8B8A8 -> R32)");
4537 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4539 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4540 const std::string descriptionOfRGBAToBGRA(description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4541 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4545 void addBlittingImageSimpleMirrorXYTests (tcu::TestCaseGroup* group)
4547 tcu::TestContext& testCtx = group->getTestContext();
4549 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4550 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4551 params.src.image.extent = defaultExtent;
4552 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
4553 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4554 params.dst.image.extent = defaultExtent;
4555 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
4558 const VkImageBlit imageBlit =
4560 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4563 {defaultSize, defaultSize, 1}
4564 }, // VkOffset3D srcOffsets[2];
4566 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4568 {defaultSize, defaultSize, 0},
4570 } // VkOffset3D dstOffset[2];
4574 region.imageBlit = imageBlit;
4575 params.regions.push_back(region);
4578 // Filter is VK_FILTER_NEAREST.
4580 params.filter = VK_FILTER_NEAREST;
4581 const std::string description = "Nearest filter";
4583 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4584 group->addChild(new BlittingTestCase(testCtx, "nearest", description, params));
4586 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4587 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4588 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4590 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4591 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4592 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4595 // Filter is VK_FILTER_LINEAR.
4597 params.filter = VK_FILTER_LINEAR;
4598 const std::string description = "Linear filter";
4600 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4601 group->addChild(new BlittingTestCase(testCtx, "linear", description, params));
4603 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4604 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4605 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4607 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4608 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4609 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4613 void addBlittingImageSimpleMirrorXTests (tcu::TestCaseGroup* group)
4615 tcu::TestContext& testCtx = group->getTestContext();
4617 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4618 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4619 params.src.image.extent = defaultExtent;
4620 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
4621 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4622 params.dst.image.extent = defaultExtent;
4623 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
4626 const VkImageBlit imageBlit =
4628 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4631 {defaultSize, defaultSize, 1}
4632 }, // VkOffset3D srcOffsets[2];
4634 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4636 {defaultSize, 0, 0},
4638 } // VkOffset3D dstOffset[2];
4642 region.imageBlit = imageBlit;
4643 params.regions.push_back(region);
4646 // Filter is VK_FILTER_NEAREST.
4648 params.filter = VK_FILTER_NEAREST;
4649 const std::string description = "Nearest filter";
4651 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4652 group->addChild(new BlittingTestCase(testCtx, "nearest", description, params));
4654 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4655 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4656 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4658 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4659 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4660 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4663 // Filter is VK_FILTER_LINEAR.
4665 params.filter = VK_FILTER_LINEAR;
4666 const std::string description = "Linear filter";
4668 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4669 group->addChild(new BlittingTestCase(testCtx, "linear", description, params));
4671 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4672 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4673 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4675 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4676 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4677 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4681 void addBlittingImageSimpleMirrorYTests (tcu::TestCaseGroup* group)
4683 tcu::TestContext& testCtx = group->getTestContext();
4685 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4686 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4687 params.src.image.extent = defaultExtent;
4688 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
4689 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4690 params.dst.image.extent = defaultExtent;
4691 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
4694 const VkImageBlit imageBlit =
4696 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4699 {defaultSize, defaultSize, 1}
4700 }, // VkOffset3D srcOffsets[2];
4702 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4704 {0, defaultSize, 0},
4706 } // VkOffset3D dstOffset[2];
4710 region.imageBlit = imageBlit;
4711 params.regions.push_back(region);
4714 // Filter is VK_FILTER_NEAREST.
4716 params.filter = VK_FILTER_NEAREST;
4717 const std::string description = "Nearest filter";
4719 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4720 group->addChild(new BlittingTestCase(testCtx, "nearest", description, params));
4722 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4723 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4724 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4726 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4727 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4728 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4731 // Filter is VK_FILTER_LINEAR.
4733 params.filter = VK_FILTER_LINEAR;
4734 const std::string description = "Linear filter";
4736 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4737 group->addChild(new BlittingTestCase(testCtx, "linear", description, params));
4739 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4740 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4741 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4743 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4744 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4745 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4749 void addBlittingImageSimpleMirrorSubregionsTests (tcu::TestCaseGroup* group)
4751 tcu::TestContext& testCtx = group->getTestContext();
4753 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4754 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4755 params.src.image.extent = defaultExtent;
4756 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
4757 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4758 params.dst.image.extent = defaultExtent;
4759 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
4763 const VkImageBlit imageBlit =
4765 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4768 {defaultHalfSize, defaultHalfSize, 1}
4769 }, // VkOffset3D srcOffsets[2];
4771 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4774 {defaultHalfSize, defaultHalfSize, 1}
4775 } // VkOffset3D dstOffset[2];
4779 region.imageBlit = imageBlit;
4780 params.regions.push_back(region);
4783 // Flipping y coordinates.
4785 const VkImageBlit imageBlit =
4787 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4789 {defaultHalfSize, 0, 0},
4790 {defaultSize, defaultHalfSize, 1}
4791 }, // VkOffset3D srcOffsets[2];
4793 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4795 {defaultHalfSize, defaultHalfSize, 0},
4797 } // VkOffset3D dstOffset[2];
4801 region.imageBlit = imageBlit;
4802 params.regions.push_back(region);
4805 // Flipping x coordinates.
4807 const VkImageBlit imageBlit =
4809 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4811 {0, defaultHalfSize, 0},
4812 {defaultHalfSize, defaultSize, 1}
4813 }, // VkOffset3D srcOffsets[2];
4815 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4817 {defaultHalfSize, defaultHalfSize, 0},
4819 } // VkOffset3D dstOffset[2];
4823 region.imageBlit = imageBlit;
4824 params.regions.push_back(region);
4827 // Flipping x and y coordinates.
4829 const VkImageBlit imageBlit =
4831 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4833 {defaultHalfSize, defaultHalfSize, 0},
4834 {defaultSize, defaultSize, 1}
4835 }, // VkOffset3D srcOffsets[2];
4837 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4839 {defaultSize, defaultSize, 0},
4840 {defaultHalfSize, defaultHalfSize, 1}
4841 } // VkOffset3D dstOffset[2];
4845 region.imageBlit = imageBlit;
4846 params.regions.push_back(region);
4849 // Filter is VK_FILTER_NEAREST.
4851 params.filter = VK_FILTER_NEAREST;
4852 const std::string description = "Nearest filter";
4854 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4855 group->addChild(new BlittingTestCase(testCtx, "nearest", description, params));
4857 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4858 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4859 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4861 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4862 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4863 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4866 // Filter is VK_FILTER_LINEAR.
4868 params.filter = VK_FILTER_LINEAR;
4869 const std::string description = "Linear filter";
4871 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4872 group->addChild(new BlittingTestCase(testCtx, "linear", description, params));
4874 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4875 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4876 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4878 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4879 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4880 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4884 void addBlittingImageSimpleScalingWhole1Tests (tcu::TestCaseGroup* group)
4886 tcu::TestContext& testCtx = group->getTestContext();
4888 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4889 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4890 params.src.image.extent = defaultExtent;
4891 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
4892 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4893 params.dst.image.extent = defaultHalfExtent;
4894 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
4897 const VkImageBlit imageBlit =
4899 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4902 {defaultSize, defaultSize, 1}
4903 }, // VkOffset3D srcOffsets[2];
4905 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4908 {defaultHalfSize, defaultHalfSize, 1}
4909 } // VkOffset3D dstOffset[2];
4913 region.imageBlit = imageBlit;
4914 params.regions.push_back(region);
4917 // Filter is VK_FILTER_NEAREST.
4919 params.filter = VK_FILTER_NEAREST;
4920 const std::string description = "Nearest filter";
4922 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4923 group->addChild(new BlittingTestCase(testCtx, "nearest", description, params));
4925 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4926 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4927 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4929 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4930 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4931 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4934 // Filter is VK_FILTER_LINEAR.
4936 params.filter = VK_FILTER_LINEAR;
4937 const std::string description = "Linear filter";
4939 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4940 group->addChild(new BlittingTestCase(testCtx, "linear", description, params));
4942 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4943 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)" );
4944 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4946 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4947 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4948 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4952 void addBlittingImageSimpleScalingWhole2Tests (tcu::TestCaseGroup* group)
4954 tcu::TestContext& testCtx = group->getTestContext();
4956 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4957 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4958 params.src.image.extent = defaultHalfExtent;
4959 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
4960 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4961 params.dst.image.extent = defaultExtent;
4962 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
4965 const VkImageBlit imageBlit =
4967 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4970 {defaultHalfSize, defaultHalfSize, 1}
4971 }, // VkOffset3D srcOffsets[2];
4973 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4976 {defaultSize, defaultSize, 1}
4977 } // VkOffset3D dstOffset[2];
4981 region.imageBlit = imageBlit;
4982 params.regions.push_back(region);
4985 // Filter is VK_FILTER_NEAREST.
4987 params.filter = VK_FILTER_NEAREST;
4988 const std::string description = "Nearest filter";
4990 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4991 group->addChild(new BlittingTestCase(testCtx, "nearest", description, params));
4993 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4994 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4995 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4997 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4998 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4999 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
5002 // Filter is VK_FILTER_LINEAR.
5004 params.filter = VK_FILTER_LINEAR;
5005 const std::string description = "Linear filter";
5007 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5008 group->addChild(new BlittingTestCase(testCtx, "linear", description, params));
5010 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
5011 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
5012 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
5014 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
5015 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
5016 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
5020 void addBlittingImageSimpleScalingAndOffsetTests (tcu::TestCaseGroup* group)
5022 tcu::TestContext& testCtx = group->getTestContext();
5024 params.src.image.imageType = VK_IMAGE_TYPE_2D;
5025 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5026 params.src.image.extent = defaultExtent;
5027 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
5028 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
5029 params.dst.image.extent = defaultExtent;
5030 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
5033 const VkImageBlit imageBlit =
5035 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
5037 {defaultFourthSize, defaultFourthSize, 0},
5038 {defaultFourthSize*3, defaultFourthSize*3, 1}
5039 }, // VkOffset3D srcOffsets[2];
5041 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
5044 {defaultSize, defaultSize, 1}
5045 } // VkOffset3D dstOffset[2];
5049 region.imageBlit = imageBlit;
5050 params.regions.push_back(region);
5053 // Filter is VK_FILTER_NEAREST.
5055 params.filter = VK_FILTER_NEAREST;
5056 const std::string description = "Nearest filter";
5058 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5059 group->addChild(new BlittingTestCase(testCtx, "nearest", description, params));
5061 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
5062 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
5063 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
5065 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
5066 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
5067 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
5070 // Filter is VK_FILTER_LINEAR.
5072 params.filter = VK_FILTER_LINEAR;
5073 const std::string description = "Linear filter";
5075 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5076 group->addChild(new BlittingTestCase(testCtx, "linear", description, params));
5078 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
5079 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
5080 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
5082 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
5083 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
5084 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
5088 void addBlittingImageSimpleWithoutScalingPartialTests (tcu::TestCaseGroup* group)
5090 tcu::TestContext& testCtx = group->getTestContext();
5092 params.src.image.imageType = VK_IMAGE_TYPE_2D;
5093 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5094 params.src.image.extent = defaultExtent;
5095 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
5096 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
5097 params.dst.image.extent = defaultExtent;
5098 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
5102 for (int i = 0; i < defaultSize; i += defaultFourthSize)
5104 const VkImageBlit imageBlit =
5106 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
5108 {defaultSize - defaultFourthSize - i, defaultSize - defaultFourthSize - i, 0},
5109 {defaultSize - i, defaultSize - i, 1}
5110 }, // VkOffset3D srcOffsets[2];
5112 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
5115 {i + defaultFourthSize, i + defaultFourthSize, 1}
5116 } // VkOffset3D dstOffset[2];
5118 region.imageBlit = imageBlit;
5119 params.regions.push_back(region);
5123 // Filter is VK_FILTER_NEAREST.
5125 params.filter = VK_FILTER_NEAREST;
5126 const std::string description = "Nearest filter";
5128 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5129 group->addChild(new BlittingTestCase(testCtx, "nearest", description, params));
5132 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
5133 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
5134 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
5136 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
5137 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
5138 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
5141 // Filter is VK_FILTER_LINEAR.
5143 params.filter = VK_FILTER_LINEAR;
5144 const std::string description = "Linear filter";
5146 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5147 group->addChild(new BlittingTestCase(testCtx, "linear", description, params));
5149 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
5150 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
5151 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
5153 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
5154 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
5155 group->addChild(new BlittingTestCase(testCtx, getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
5159 void addBlittingImageSimpleTests (tcu::TestCaseGroup* group)
5161 addTestGroup(group, "whole", "Blit without scaling (whole)", addBlittingImageSimpleWholeTests);
5162 addTestGroup(group, "mirror_xy", "Flipping x and y coordinates (whole)", addBlittingImageSimpleMirrorXYTests);
5163 addTestGroup(group, "mirror_x", "Flipping x coordinates (whole)", addBlittingImageSimpleMirrorXTests);
5164 addTestGroup(group, "mirror_y", "Flipping y coordinates (whole)", addBlittingImageSimpleMirrorYTests);
5165 addTestGroup(group, "mirror_subregions", "Mirroring subregions in image (no flip, y flip, x flip, xy flip)", addBlittingImageSimpleMirrorSubregionsTests);
5166 addTestGroup(group, "scaling_whole1", "Blit with scaling (whole, src extent bigger)", addBlittingImageSimpleScalingWhole1Tests);
5167 addTestGroup(group, "scaling_whole2", "Blit with scaling (whole, dst extent bigger)", addBlittingImageSimpleScalingWhole2Tests);
5168 addTestGroup(group, "scaling_and_offset", "Blit with scaling and offset (whole, dst extent bigger)", addBlittingImageSimpleScalingAndOffsetTests);
5169 addTestGroup(group, "without_scaling_partial", "Blit without scaling (partial)", addBlittingImageSimpleWithoutScalingPartialTests);
5171 struct BlitColorTestParams
5174 const VkFormat* compatibleFormats;
5178 void addBlittingImageAllFormatsColorSrcFormatDstFormatTests (tcu::TestCaseGroup* group, BlitColorTestParams testParams)
5180 tcu::TestContext& testCtx = group->getTestContext();
5182 const VkImageLayout blitSrcLayouts[] =
5184 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5185 VK_IMAGE_LAYOUT_GENERAL
5187 const VkImageLayout blitDstLayouts[] =
5189 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
5190 VK_IMAGE_LAYOUT_GENERAL
5193 for (int srcLayoutNdx = 0u; srcLayoutNdx < DE_LENGTH_OF_ARRAY(blitSrcLayouts); ++srcLayoutNdx)
5195 testParams.params.src.image.operationLayout = blitSrcLayouts[srcLayoutNdx];
5196 for (int dstLayoutNdx = 0u; dstLayoutNdx < DE_LENGTH_OF_ARRAY(blitDstLayouts); ++dstLayoutNdx)
5198 testParams.params.dst.image.operationLayout = blitDstLayouts[dstLayoutNdx];
5200 testParams.params.filter = VK_FILTER_NEAREST;
5201 const std::string testName = getImageLayoutCaseName(testParams.params.src.image.operationLayout) + "_" +
5202 getImageLayoutCaseName(testParams.params.dst.image.operationLayout);
5203 const std::string description = "Blit from layout " + getImageLayoutCaseName(testParams.params.src.image.operationLayout) +
5204 " to " + getImageLayoutCaseName(testParams.params.dst.image.operationLayout);
5205 group->addChild(new BlittingTestCase(testCtx, testName + "_nearest", description, testParams.params));
5207 if (!testParams.onlyNearest)
5209 testParams.params.filter = VK_FILTER_LINEAR;
5210 group->addChild(new BlittingTestCase(testCtx, testName + "_linear", description, testParams.params));
5216 void addBlittingImageAllFormatsColorSrcFormatTests (tcu::TestCaseGroup* group, BlitColorTestParams testParams)
5218 for (int dstFormatIndex = 0; testParams.compatibleFormats[dstFormatIndex] != VK_FORMAT_UNDEFINED; ++dstFormatIndex)
5220 testParams.params.dst.image.format = testParams.compatibleFormats[dstFormatIndex];
5221 if (!isSupportedByFramework(testParams.params.dst.image.format))
5224 const std::string description = "Blit destination format " + getFormatCaseName(testParams.params.dst.image.format);
5225 addTestGroup(group, getFormatCaseName(testParams.params.dst.image.format), description, addBlittingImageAllFormatsColorSrcFormatDstFormatTests, testParams);
5229 const VkFormat compatibleFormatsUInts[] =
5232 VK_FORMAT_R8G8_UINT,
5233 VK_FORMAT_R8G8B8_UINT,
5234 VK_FORMAT_B8G8R8_UINT,
5235 VK_FORMAT_R8G8B8A8_UINT,
5236 VK_FORMAT_B8G8R8A8_UINT,
5237 VK_FORMAT_A8B8G8R8_UINT_PACK32,
5238 VK_FORMAT_A2R10G10B10_UINT_PACK32,
5239 VK_FORMAT_A2B10G10R10_UINT_PACK32,
5241 VK_FORMAT_R16G16_UINT,
5242 VK_FORMAT_R16G16B16_UINT,
5243 VK_FORMAT_R16G16B16A16_UINT,
5245 VK_FORMAT_R32G32_UINT,
5246 VK_FORMAT_R32G32B32_UINT,
5247 VK_FORMAT_R32G32B32A32_UINT,
5249 VK_FORMAT_R64G64_UINT,
5250 VK_FORMAT_R64G64B64_UINT,
5251 VK_FORMAT_R64G64B64A64_UINT,
5255 const VkFormat compatibleFormatsSInts[] =
5258 VK_FORMAT_R8G8_SINT,
5259 VK_FORMAT_R8G8B8_SINT,
5260 VK_FORMAT_B8G8R8_SINT,
5261 VK_FORMAT_R8G8B8A8_SINT,
5262 VK_FORMAT_B8G8R8A8_SINT,
5263 VK_FORMAT_A8B8G8R8_SINT_PACK32,
5264 VK_FORMAT_A2R10G10B10_SINT_PACK32,
5265 VK_FORMAT_A2B10G10R10_SINT_PACK32,
5267 VK_FORMAT_R16G16_SINT,
5268 VK_FORMAT_R16G16B16_SINT,
5269 VK_FORMAT_R16G16B16A16_SINT,
5271 VK_FORMAT_R32G32_SINT,
5272 VK_FORMAT_R32G32B32_SINT,
5273 VK_FORMAT_R32G32B32A32_SINT,
5275 VK_FORMAT_R64G64_SINT,
5276 VK_FORMAT_R64G64B64_SINT,
5277 VK_FORMAT_R64G64B64A64_SINT,
5281 const VkFormat compatibleFormatsFloats[] =
5283 VK_FORMAT_R4G4_UNORM_PACK8,
5284 VK_FORMAT_R4G4B4A4_UNORM_PACK16,
5285 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
5286 VK_FORMAT_R5G6B5_UNORM_PACK16,
5287 VK_FORMAT_B5G6R5_UNORM_PACK16,
5288 VK_FORMAT_R5G5B5A1_UNORM_PACK16,
5289 VK_FORMAT_B5G5R5A1_UNORM_PACK16,
5290 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
5293 VK_FORMAT_R8_USCALED,
5294 VK_FORMAT_R8_SSCALED,
5295 VK_FORMAT_R8G8_UNORM,
5296 VK_FORMAT_R8G8_SNORM,
5297 VK_FORMAT_R8G8_USCALED,
5298 VK_FORMAT_R8G8_SSCALED,
5299 VK_FORMAT_R8G8B8_UNORM,
5300 VK_FORMAT_R8G8B8_SNORM,
5301 VK_FORMAT_R8G8B8_USCALED,
5302 VK_FORMAT_R8G8B8_SSCALED,
5303 VK_FORMAT_B8G8R8_UNORM,
5304 VK_FORMAT_B8G8R8_SNORM,
5305 VK_FORMAT_B8G8R8_USCALED,
5306 VK_FORMAT_B8G8R8_SSCALED,
5307 VK_FORMAT_R8G8B8A8_UNORM,
5308 VK_FORMAT_R8G8B8A8_SNORM,
5309 VK_FORMAT_R8G8B8A8_USCALED,
5310 VK_FORMAT_R8G8B8A8_SSCALED,
5311 VK_FORMAT_B8G8R8A8_UNORM,
5312 VK_FORMAT_B8G8R8A8_SNORM,
5313 VK_FORMAT_B8G8R8A8_USCALED,
5314 VK_FORMAT_B8G8R8A8_SSCALED,
5315 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
5316 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
5317 VK_FORMAT_A8B8G8R8_USCALED_PACK32,
5318 VK_FORMAT_A8B8G8R8_SSCALED_PACK32,
5319 VK_FORMAT_A2R10G10B10_UNORM_PACK32,
5320 VK_FORMAT_A2R10G10B10_SNORM_PACK32,
5321 VK_FORMAT_A2R10G10B10_USCALED_PACK32,
5322 VK_FORMAT_A2R10G10B10_SSCALED_PACK32,
5323 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
5324 VK_FORMAT_A2B10G10R10_SNORM_PACK32,
5325 VK_FORMAT_A2B10G10R10_USCALED_PACK32,
5326 VK_FORMAT_A2B10G10R10_SSCALED_PACK32,
5327 VK_FORMAT_R16_UNORM,
5328 VK_FORMAT_R16_SNORM,
5329 VK_FORMAT_R16_USCALED,
5330 VK_FORMAT_R16_SSCALED,
5331 VK_FORMAT_R16_SFLOAT,
5332 VK_FORMAT_R16G16_UNORM,
5333 VK_FORMAT_R16G16_SNORM,
5334 VK_FORMAT_R16G16_USCALED,
5335 VK_FORMAT_R16G16_SSCALED,
5336 VK_FORMAT_R16G16_SFLOAT,
5337 VK_FORMAT_R16G16B16_UNORM,
5338 VK_FORMAT_R16G16B16_SNORM,
5339 VK_FORMAT_R16G16B16_USCALED,
5340 VK_FORMAT_R16G16B16_SSCALED,
5341 VK_FORMAT_R16G16B16_SFLOAT,
5342 VK_FORMAT_R16G16B16A16_UNORM,
5343 VK_FORMAT_R16G16B16A16_SNORM,
5344 VK_FORMAT_R16G16B16A16_USCALED,
5345 VK_FORMAT_R16G16B16A16_SSCALED,
5346 VK_FORMAT_R16G16B16A16_SFLOAT,
5347 VK_FORMAT_R32_SFLOAT,
5348 VK_FORMAT_R32G32_SFLOAT,
5349 VK_FORMAT_R32G32B32_SFLOAT,
5350 VK_FORMAT_R32G32B32A32_SFLOAT,
5351 VK_FORMAT_R64_SFLOAT,
5352 VK_FORMAT_R64G64_SFLOAT,
5353 VK_FORMAT_R64G64B64_SFLOAT,
5354 VK_FORMAT_R64G64B64A64_SFLOAT,
5355 VK_FORMAT_B10G11R11_UFLOAT_PACK32,
5356 VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
5357 // VK_FORMAT_BC1_RGB_UNORM_BLOCK,
5358 // VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
5359 // VK_FORMAT_BC2_UNORM_BLOCK,
5360 // VK_FORMAT_BC3_UNORM_BLOCK,
5361 // VK_FORMAT_BC4_UNORM_BLOCK,
5362 // VK_FORMAT_BC4_SNORM_BLOCK,
5363 // VK_FORMAT_BC5_UNORM_BLOCK,
5364 // VK_FORMAT_BC5_SNORM_BLOCK,
5365 // VK_FORMAT_BC6H_UFLOAT_BLOCK,
5366 // VK_FORMAT_BC6H_SFLOAT_BLOCK,
5367 // VK_FORMAT_BC7_UNORM_BLOCK,
5368 // VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
5369 // VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,
5370 // VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,
5371 // VK_FORMAT_EAC_R11_UNORM_BLOCK,
5372 // VK_FORMAT_EAC_R11_SNORM_BLOCK,
5373 // VK_FORMAT_EAC_R11G11_UNORM_BLOCK,
5374 // VK_FORMAT_EAC_R11G11_SNORM_BLOCK,
5375 // VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
5376 // VK_FORMAT_ASTC_5x4_UNORM_BLOCK,
5377 // VK_FORMAT_ASTC_5x5_UNORM_BLOCK,
5378 // VK_FORMAT_ASTC_6x5_UNORM_BLOCK,
5379 // VK_FORMAT_ASTC_6x6_UNORM_BLOCK,
5380 // VK_FORMAT_ASTC_8x5_UNORM_BLOCK,
5381 // VK_FORMAT_ASTC_8x6_UNORM_BLOCK,
5382 // VK_FORMAT_ASTC_8x8_UNORM_BLOCK,
5383 // VK_FORMAT_ASTC_10x5_UNORM_BLOCK,
5384 // VK_FORMAT_ASTC_10x6_UNORM_BLOCK,
5385 // VK_FORMAT_ASTC_10x8_UNORM_BLOCK,
5386 // VK_FORMAT_ASTC_10x10_UNORM_BLOCK,
5387 // VK_FORMAT_ASTC_12x10_UNORM_BLOCK,
5388 // VK_FORMAT_ASTC_12x12_UNORM_BLOCK,
5392 const VkFormat compatibleFormatsSrgb[] =
5395 VK_FORMAT_R8G8_SRGB,
5396 VK_FORMAT_R8G8B8_SRGB,
5397 VK_FORMAT_B8G8R8_SRGB,
5398 VK_FORMAT_R8G8B8A8_SRGB,
5399 VK_FORMAT_B8G8R8A8_SRGB,
5400 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
5401 // VK_FORMAT_BC1_RGB_SRGB_BLOCK,
5402 // VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
5403 // VK_FORMAT_BC2_SRGB_BLOCK,
5404 // VK_FORMAT_BC3_SRGB_BLOCK,
5405 // VK_FORMAT_BC7_SRGB_BLOCK,
5406 // VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
5407 // VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
5408 // VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
5409 // VK_FORMAT_ASTC_4x4_SRGB_BLOCK,
5410 // VK_FORMAT_ASTC_5x4_SRGB_BLOCK,
5411 // VK_FORMAT_ASTC_5x5_SRGB_BLOCK,
5412 // VK_FORMAT_ASTC_6x5_SRGB_BLOCK,
5413 // VK_FORMAT_ASTC_6x6_SRGB_BLOCK,
5414 // VK_FORMAT_ASTC_8x5_SRGB_BLOCK,
5415 // VK_FORMAT_ASTC_8x6_SRGB_BLOCK,
5416 // VK_FORMAT_ASTC_8x8_SRGB_BLOCK,
5417 // VK_FORMAT_ASTC_10x5_SRGB_BLOCK,
5418 // VK_FORMAT_ASTC_10x6_SRGB_BLOCK,
5419 // VK_FORMAT_ASTC_10x8_SRGB_BLOCK,
5420 // VK_FORMAT_ASTC_10x10_SRGB_BLOCK,
5421 // VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
5422 // VK_FORMAT_ASTC_12x12_SRGB_BLOCK,
5427 void addBlittingImageAllFormatsColorTests (tcu::TestCaseGroup* group)
5430 const VkFormat* compatibleFormats;
5431 const bool onlyNearest;
5432 } colorImageFormatsToTestBlit[] =
5434 { compatibleFormatsUInts, true },
5435 { compatibleFormatsSInts, true },
5436 { compatibleFormatsFloats, false },
5437 { compatibleFormatsSrgb, false },
5440 const int numOfColorImageFormatsToTest = DE_LENGTH_OF_ARRAY(colorImageFormatsToTestBlit);
5443 params.src.image.imageType = VK_IMAGE_TYPE_2D;
5444 params.src.image.extent = defaultExtent;
5445 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
5446 params.dst.image.extent = defaultExtent;
5449 for (int i = 0, j = 1; (i + defaultFourthSize / j < defaultSize) && (defaultFourthSize > j); i += defaultFourthSize / j++)
5451 const VkImageBlit imageBlit =
5453 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
5456 {defaultSize, defaultSize, 1}
5457 }, // VkOffset3D srcOffsets[2];
5459 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
5462 {i + defaultFourthSize / j, defaultFourthSize / j, 1}
5463 } // VkOffset3D dstOffset[2];
5465 region.imageBlit = imageBlit;
5466 params.regions.push_back(region);
5468 for (int i = 0; i < defaultSize; i += defaultFourthSize)
5470 const VkImageBlit imageBlit =
5472 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
5475 {i + defaultFourthSize, i + defaultFourthSize, 1}
5476 }, // VkOffset3D srcOffsets[2];
5478 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
5480 {i, defaultSize / 2, 0},
5481 {i + defaultFourthSize, defaultSize / 2 + defaultFourthSize, 1}
5482 } // VkOffset3D dstOffset[2];
5484 region.imageBlit = imageBlit;
5485 params.regions.push_back(region);
5488 for (int compatibleFormatsIndex = 0; compatibleFormatsIndex < numOfColorImageFormatsToTest; ++compatibleFormatsIndex)
5490 const VkFormat* compatibleFormats = colorImageFormatsToTestBlit[compatibleFormatsIndex].compatibleFormats;
5491 const bool onlyNearest = colorImageFormatsToTestBlit[compatibleFormatsIndex].onlyNearest;
5492 for (int srcFormatIndex = 0; compatibleFormats[srcFormatIndex] != VK_FORMAT_UNDEFINED; ++srcFormatIndex)
5494 params.src.image.format = compatibleFormats[srcFormatIndex];
5495 if (!isSupportedByFramework(params.src.image.format))
5498 BlitColorTestParams testParams;
5499 testParams.params = params;
5500 testParams.compatibleFormats = compatibleFormats;
5501 testParams.onlyNearest = onlyNearest;
5503 const std::string description = "Blit source format " + getFormatCaseName(params.src.image.format);
5504 addTestGroup(group, getFormatCaseName(params.src.image.format), description, addBlittingImageAllFormatsColorSrcFormatTests, testParams);
5509 void addBlittingImageAllFormatsDepthStencilFormatsTests (tcu::TestCaseGroup* group, TestParams params)
5511 const VkImageLayout blitSrcLayouts[] =
5513 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5514 VK_IMAGE_LAYOUT_GENERAL
5516 const VkImageLayout blitDstLayouts[] =
5518 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
5519 VK_IMAGE_LAYOUT_GENERAL
5522 for (int srcLayoutNdx = 0u; srcLayoutNdx < DE_LENGTH_OF_ARRAY(blitSrcLayouts); ++srcLayoutNdx)
5524 params.src.image.operationLayout = blitSrcLayouts[srcLayoutNdx];
5526 for (int dstLayoutNdx = 0u; dstLayoutNdx < DE_LENGTH_OF_ARRAY(blitDstLayouts); ++dstLayoutNdx)
5528 params.dst.image.operationLayout = blitDstLayouts[dstLayoutNdx];
5529 params.filter = VK_FILTER_NEAREST;
5531 const std::string testName = getImageLayoutCaseName(params.src.image.operationLayout) + "_" +
5532 getImageLayoutCaseName(params.dst.image.operationLayout);
5533 const std::string description = "Blit from " + getImageLayoutCaseName(params.src.image.operationLayout) +
5534 " to " + getImageLayoutCaseName(params.dst.image.operationLayout);
5536 group->addChild(new BlittingTestCase(group->getTestContext(), testName + "_nearest", description, params));
5541 void addBlittingImageAllFormatsDepthStencilTests (tcu::TestCaseGroup* group)
5543 const VkFormat depthAndStencilFormats[] =
5545 VK_FORMAT_D16_UNORM,
5546 VK_FORMAT_X8_D24_UNORM_PACK32,
5547 VK_FORMAT_D32_SFLOAT,
5549 VK_FORMAT_D16_UNORM_S8_UINT,
5550 VK_FORMAT_D24_UNORM_S8_UINT,
5551 VK_FORMAT_D32_SFLOAT_S8_UINT,
5554 const VkImageSubresourceLayers defaultDepthSourceLayer = { VK_IMAGE_ASPECT_DEPTH_BIT, 0u, 0u, 1u };
5555 const VkImageSubresourceLayers defaultStencilSourceLayer = { VK_IMAGE_ASPECT_STENCIL_BIT, 0u, 0u, 1u };
5557 for (int compatibleFormatsIndex = 0; compatibleFormatsIndex < DE_LENGTH_OF_ARRAY(depthAndStencilFormats); ++compatibleFormatsIndex)
5560 params.src.image.imageType = VK_IMAGE_TYPE_2D;
5561 params.src.image.extent = defaultExtent;
5562 params.src.image.format = depthAndStencilFormats[compatibleFormatsIndex];
5563 params.dst.image.extent = defaultExtent;
5564 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
5565 params.dst.image.format = params.src.image.format;
5568 for (int i = 0, j = 1; (i + defaultFourthSize / j < defaultSize) && (defaultFourthSize > j); i += defaultFourthSize / j++)
5570 const VkOffset3D srcOffset0 = {0, 0, 0};
5571 const VkOffset3D srcOffset1 = {defaultSize, defaultSize, 1};
5572 const VkOffset3D dstOffset0 = {i, 0, 0};
5573 const VkOffset3D dstOffset1 = {i + defaultFourthSize / j, defaultFourthSize / j, 1};
5575 if (tcu::hasDepthComponent(mapVkFormat(params.src.image.format).order))
5577 const VkImageBlit imageBlit =
5579 defaultDepthSourceLayer, // VkImageSubresourceLayers srcSubresource;
5580 { srcOffset0 , srcOffset1 }, // VkOffset3D srcOffsets[2];
5581 defaultDepthSourceLayer, // VkImageSubresourceLayers dstSubresource;
5582 { dstOffset0 , dstOffset1 }, // VkOffset3D dstOffset[2];
5584 region.imageBlit = imageBlit;
5585 params.regions.push_back(region);
5587 if (tcu::hasStencilComponent(mapVkFormat(params.src.image.format).order))
5589 const VkImageBlit imageBlit =
5591 defaultStencilSourceLayer, // VkImageSubresourceLayers srcSubresource;
5592 { srcOffset0 , srcOffset1 }, // VkOffset3D srcOffsets[2];
5593 defaultStencilSourceLayer, // VkImageSubresourceLayers dstSubresource;
5594 { dstOffset0 , dstOffset1 }, // VkOffset3D dstOffset[2];
5596 region.imageBlit = imageBlit;
5597 params.regions.push_back(region);
5600 for (int i = 0; i < defaultSize; i += defaultFourthSize)
5602 const VkOffset3D srcOffset0 = {i, i, 0};
5603 const VkOffset3D srcOffset1 = {i + defaultFourthSize, i + defaultFourthSize, 1};
5604 const VkOffset3D dstOffset0 = {i, defaultSize / 2, 0};
5605 const VkOffset3D dstOffset1 = {i + defaultFourthSize, defaultSize / 2 + defaultFourthSize, 1};
5607 if (tcu::hasDepthComponent(mapVkFormat(params.src.image.format).order))
5609 const VkImageBlit imageBlit =
5611 defaultDepthSourceLayer, // VkImageSubresourceLayers srcSubresource;
5612 { srcOffset0, srcOffset1 }, // VkOffset3D srcOffsets[2];
5613 defaultDepthSourceLayer, // VkImageSubresourceLayers dstSubresource;
5614 { dstOffset0, dstOffset1 } // VkOffset3D dstOffset[2];
5616 region.imageBlit = imageBlit;
5617 params.regions.push_back(region);
5619 if (tcu::hasStencilComponent(mapVkFormat(params.src.image.format).order))
5621 const VkImageBlit imageBlit =
5623 defaultStencilSourceLayer, // VkImageSubresourceLayers srcSubresource;
5624 { srcOffset0, srcOffset1 }, // VkOffset3D srcOffsets[2];
5625 defaultStencilSourceLayer, // VkImageSubresourceLayers dstSubresource;
5626 { dstOffset0, dstOffset1 } // VkOffset3D dstOffset[2];
5628 region.imageBlit = imageBlit;
5629 params.regions.push_back(region);
5633 const std::string testName = getFormatCaseName(params.src.image.format) + "_" +
5634 getFormatCaseName(params.dst.image.format);
5635 const std::string description = "Blit from " + getFormatCaseName(params.src.image.format) +
5636 " to " + getFormatCaseName(params.dst.image.format);
5637 addTestGroup(group, testName, description, addBlittingImageAllFormatsDepthStencilFormatsTests, params);
5641 void addBlittingImageAllFormatsTests (tcu::TestCaseGroup* group)
5643 addTestGroup(group, "color", "Blitting image with color formats", addBlittingImageAllFormatsColorTests);
5644 addTestGroup(group, "depth_stencil", "Blitting image with depth/stencil formats", addBlittingImageAllFormatsDepthStencilTests);
5647 void addBlittingImageTests (tcu::TestCaseGroup* group)
5649 addTestGroup(group, "simple_tests", "Blitting image simple tests", addBlittingImageSimpleTests);
5650 addTestGroup(group, "all_formats", "Blitting image with all compatible formats", addBlittingImageAllFormatsTests);
5653 const VkSampleCountFlagBits samples[] =
5655 VK_SAMPLE_COUNT_2_BIT,
5656 VK_SAMPLE_COUNT_4_BIT,
5657 VK_SAMPLE_COUNT_8_BIT,
5658 VK_SAMPLE_COUNT_16_BIT,
5659 VK_SAMPLE_COUNT_32_BIT,
5660 VK_SAMPLE_COUNT_64_BIT
5662 const VkExtent3D resolveExtent = {256u, 256u, 1};
5664 void addResolveImageWholeTests (tcu::TestCaseGroup* group)
5667 params.src.image.imageType = VK_IMAGE_TYPE_2D;
5668 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5669 params.src.image.extent = resolveExtent;
5670 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
5671 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
5672 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5673 params.dst.image.extent = resolveExtent;
5674 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
5677 const VkImageSubresourceLayers sourceLayer =
5679 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
5680 0u, // uint32_t mipLevel;
5681 0u, // uint32_t baseArrayLayer;
5682 1u // uint32_t layerCount;
5684 const VkImageResolve testResolve =
5686 sourceLayer, // VkImageSubresourceLayers srcSubresource;
5687 {0, 0, 0}, // VkOffset3D srcOffset;
5688 sourceLayer, // VkImageSubresourceLayers dstSubresource;
5689 {0, 0, 0}, // VkOffset3D dstOffset;
5690 resolveExtent, // VkExtent3D extent;
5693 CopyRegion imageResolve;
5694 imageResolve.imageResolve = testResolve;
5695 params.regions.push_back(imageResolve);
5698 for (int samplesIndex = 0; samplesIndex < DE_LENGTH_OF_ARRAY(samples); ++samplesIndex)
5700 params.samples = samples[samplesIndex];
5701 const std::string description = "With " + getSampleCountCaseName(samples[samplesIndex]);
5702 group->addChild(new ResolveImageToImageTestCase(group->getTestContext(), getSampleCountCaseName(samples[samplesIndex]), description, params));
5706 void addResolveImagePartialTests (tcu::TestCaseGroup* group)
5709 params.src.image.imageType = VK_IMAGE_TYPE_2D;
5710 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5711 params.src.image.extent = resolveExtent;
5712 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
5713 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
5714 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5715 params.dst.image.extent = resolveExtent;
5716 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
5719 const VkImageSubresourceLayers sourceLayer =
5721 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
5722 0u, // uint32_t mipLevel;
5723 0u, // uint32_t baseArrayLayer;
5724 1u // uint32_t layerCount;
5726 const VkImageResolve testResolve =
5728 sourceLayer, // VkImageSubresourceLayers srcSubresource;
5729 {0, 0, 0}, // VkOffset3D srcOffset;
5730 sourceLayer, // VkImageSubresourceLayers dstSubresource;
5731 {64u, 64u, 0}, // VkOffset3D dstOffset;
5732 {128u, 128u, 1u}, // VkExtent3D extent;
5735 CopyRegion imageResolve;
5736 imageResolve.imageResolve = testResolve;
5737 params.regions.push_back(imageResolve);
5740 for (int samplesIndex = 0; samplesIndex < DE_LENGTH_OF_ARRAY(samples); ++samplesIndex)
5742 params.samples = samples[samplesIndex];
5743 const std::string description = "With " + getSampleCountCaseName(samples[samplesIndex]);
5744 group->addChild(new ResolveImageToImageTestCase(group->getTestContext(), getSampleCountCaseName(samples[samplesIndex]), description, params));
5748 void addResolveImageWithRegionsTests (tcu::TestCaseGroup* group)
5751 params.src.image.imageType = VK_IMAGE_TYPE_2D;
5752 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5753 params.src.image.extent = resolveExtent;
5754 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
5755 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
5756 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5757 params.dst.image.extent = resolveExtent;
5758 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
5761 const VkImageSubresourceLayers sourceLayer =
5763 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
5764 0u, // uint32_t mipLevel;
5765 0u, // uint32_t baseArrayLayer;
5766 1u // uint32_t layerCount;
5769 for (int i = 0; i < 256; i += 64)
5771 const VkImageResolve testResolve =
5773 sourceLayer, // VkImageSubresourceLayers srcSubresource;
5774 {i, i, 0}, // VkOffset3D srcOffset;
5775 sourceLayer, // VkImageSubresourceLayers dstSubresource;
5776 {i, 0, 0}, // VkOffset3D dstOffset;
5777 {64u, 64u, 1u}, // VkExtent3D extent;
5780 CopyRegion imageResolve;
5781 imageResolve.imageResolve = testResolve;
5782 params.regions.push_back(imageResolve);
5786 for (int samplesIndex = 0; samplesIndex < DE_LENGTH_OF_ARRAY(samples); ++samplesIndex)
5788 params.samples = samples[samplesIndex];
5789 const std::string description = "With " + getSampleCountCaseName(samples[samplesIndex]);
5790 group->addChild(new ResolveImageToImageTestCase(group->getTestContext(), getSampleCountCaseName(samples[samplesIndex]), description, params));
5794 void addResolveImageWholeCopyBeforeResolvingTests (tcu::TestCaseGroup* group)
5797 params.src.image.imageType = VK_IMAGE_TYPE_2D;
5798 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5799 params.src.image.extent = defaultExtent;
5800 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
5801 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
5802 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5803 params.dst.image.extent = defaultExtent;
5804 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
5807 const VkImageSubresourceLayers sourceLayer =
5809 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
5810 0u, // uint32_t mipLevel;
5811 0u, // uint32_t baseArrayLayer;
5812 1u // uint32_t layerCount;
5815 const VkImageResolve testResolve =
5817 sourceLayer, // VkImageSubresourceLayers srcSubresource;
5818 {0, 0, 0}, // VkOffset3D srcOffset;
5819 sourceLayer, // VkImageSubresourceLayers dstSubresource;
5820 {0, 0, 0}, // VkOffset3D dstOffset;
5821 defaultExtent, // VkExtent3D extent;
5824 CopyRegion imageResolve;
5825 imageResolve.imageResolve = testResolve;
5826 params.regions.push_back(imageResolve);
5829 for (int samplesIndex = 0; samplesIndex < DE_LENGTH_OF_ARRAY(samples); ++samplesIndex)
5831 params.samples = samples[samplesIndex];
5832 const std::string description = "With " + getSampleCountCaseName(samples[samplesIndex]);
5833 group->addChild(new ResolveImageToImageTestCase(group->getTestContext(), getSampleCountCaseName(samples[samplesIndex]), description, params, COPY_MS_IMAGE_TO_MS_IMAGE));
5837 void addResolveImageWholeArrayImageTests (tcu::TestCaseGroup* group)
5840 params.src.image.imageType = VK_IMAGE_TYPE_2D;
5841 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5842 params.src.image.extent = defaultExtent;
5843 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
5844 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
5845 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5846 params.dst.image.extent = defaultExtent;
5847 params.dst.image.extent.depth = 5u;
5848 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
5850 for (deUint32 layerNdx=0; layerNdx < params.dst.image.extent.depth; ++layerNdx)
5852 const VkImageSubresourceLayers sourceLayer =
5854 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
5855 0u, // uint32_t mipLevel;
5856 layerNdx, // uint32_t baseArrayLayer;
5857 1u // uint32_t layerCount;
5860 const VkImageResolve testResolve =
5862 sourceLayer, // VkImageSubresourceLayers srcSubresource;
5863 {0, 0, 0}, // VkOffset3D srcOffset;
5864 sourceLayer, // VkImageSubresourceLayers dstSubresource;
5865 {0, 0, 0}, // VkOffset3D dstOffset;
5866 defaultExtent, // VkExtent3D extent;
5869 CopyRegion imageResolve;
5870 imageResolve.imageResolve = testResolve;
5871 params.regions.push_back(imageResolve);
5874 for (int samplesIndex = 0; samplesIndex < DE_LENGTH_OF_ARRAY(samples); ++samplesIndex)
5876 params.samples = samples[samplesIndex];
5877 const std::string description = "With " + getSampleCountCaseName(samples[samplesIndex]);
5878 group->addChild(new ResolveImageToImageTestCase(group->getTestContext(), getSampleCountCaseName(samples[samplesIndex]), description, params, COPY_MS_IMAGE_TO_ARRAY_MS_IMAGE));
5882 void addResolveImageDiffImageSizeTests (tcu::TestCaseGroup* group)
5884 tcu::TestContext& testCtx = group->getTestContext();
5886 params.src.image.imageType = VK_IMAGE_TYPE_2D;
5887 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5888 params.src.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
5889 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
5890 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
5891 params.dst.image.operationLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
5894 const VkImageSubresourceLayers sourceLayer =
5896 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
5897 0u, // uint32_t mipLevel;
5898 0u, // uint32_t baseArrayLayer;
5899 1u // uint32_t layerCount;
5901 const VkImageResolve testResolve =
5903 sourceLayer, // VkImageSubresourceLayers srcSubresource;
5904 {0, 0, 0}, // VkOffset3D srcOffset;
5905 sourceLayer, // VkImageSubresourceLayers dstSubresource;
5906 {0, 0, 0}, // VkOffset3D dstOffset;
5907 resolveExtent, // VkExtent3D extent;
5909 CopyRegion imageResolve;
5910 imageResolve.imageResolve = testResolve;
5911 params.regions.push_back(imageResolve);
5914 const VkExtent3D imageExtents[] =
5916 { resolveExtent.width + 10, resolveExtent.height, resolveExtent.depth },
5917 { resolveExtent.width, resolveExtent.height * 2, resolveExtent.depth },
5918 { resolveExtent.width, resolveExtent.height, resolveExtent.depth + 10 }
5921 for (int srcImageExtentIndex = 0; srcImageExtentIndex < DE_LENGTH_OF_ARRAY(imageExtents); ++srcImageExtentIndex)
5923 const VkExtent3D& srcImageSize = imageExtents[srcImageExtentIndex];
5924 params.src.image.extent = srcImageSize;
5925 params.dst.image.extent = resolveExtent;
5926 for (int samplesIndex = 0; samplesIndex < DE_LENGTH_OF_ARRAY(samples); ++samplesIndex)
5928 params.samples = samples[samplesIndex];
5929 std::ostringstream testName;
5930 testName << "src_" << srcImageSize.width << "_" << srcImageSize.height << "_" << srcImageSize.depth << "_" << getSampleCountCaseName(samples[samplesIndex]);
5931 std::ostringstream description;
5932 description << "With " << getSampleCountCaseName(samples[samplesIndex]) << " and source image size ("
5933 << srcImageSize.width << ", " << srcImageSize.height << ", " << srcImageSize.depth << ")";
5934 group->addChild(new ResolveImageToImageTestCase(testCtx, testName.str(), description.str(), params));
5937 for (int dstImageExtentIndex = 0; dstImageExtentIndex < DE_LENGTH_OF_ARRAY(imageExtents); ++dstImageExtentIndex)
5939 const VkExtent3D& dstImageSize = imageExtents[dstImageExtentIndex];
5940 params.src.image.extent = resolveExtent;
5941 params.dst.image.extent = dstImageSize;
5942 for (int samplesIndex = 0; samplesIndex < DE_LENGTH_OF_ARRAY(samples); ++samplesIndex)
5944 params.samples = samples[samplesIndex];
5945 std::ostringstream testName;
5946 testName << "dst_" << dstImageSize.width << "_" << dstImageSize.height << "_" << dstImageSize.depth << "_" << getSampleCountCaseName(samples[samplesIndex]);
5947 std::ostringstream description;
5948 description << "With " << getSampleCountCaseName(samples[samplesIndex]) << " and destination image size ("
5949 << dstImageSize.width << ", " << dstImageSize.height << ", " << dstImageSize.depth << ")";
5950 group->addChild(new ResolveImageToImageTestCase(testCtx, testName.str(), description.str(), params));
5955 void addResolveImageTests (tcu::TestCaseGroup* group)
5957 addTestGroup(group, "whole", "Resolve from image to image (whole)", addResolveImageWholeTests);
5958 addTestGroup(group, "partial", "Resolve from image to image (partial)", addResolveImagePartialTests);
5959 addTestGroup(group, "with_regions", "Resolve from image to image (with regions)", addResolveImageWithRegionsTests);
5960 addTestGroup(group, "whole_copy_before_resolving", "Resolve from image to image (whole copy before resolving)", addResolveImageWholeCopyBeforeResolvingTests);
5961 addTestGroup(group, "whole_array_image", "Resolve from image to image (whole array image)", addResolveImageWholeArrayImageTests);
5962 addTestGroup(group, "diff_image_size", "Resolve from image to image of different size", addResolveImageDiffImageSizeTests);
5967 tcu::TestCaseGroup* createCopiesAndBlittingTests (tcu::TestContext& testCtx)
5969 de::MovePtr<tcu::TestCaseGroup> copiesAndBlittingTests(new tcu::TestCaseGroup(testCtx, "copy_and_blit", "Copies And Blitting Tests"));
5971 addTestGroup(copiesAndBlittingTests.get(), "image_to_image", "Copy from image to image", addImageToImageTests);
5972 addTestGroup(copiesAndBlittingTests.get(), "image_to_buffer", "Copy from image to buffer", addImageToBufferTests);
5973 addTestGroup(copiesAndBlittingTests.get(), "buffer_to_image", "Copy from buffer to image", addBufferToImageTests);
5974 addTestGroup(copiesAndBlittingTests.get(), "buffer_to_buffer", "Copy from buffer to buffer", addBufferToBufferTests);
5975 addTestGroup(copiesAndBlittingTests.get(), "blit_image", "Blitting image", addBlittingImageTests);
5976 addTestGroup(copiesAndBlittingTests.get(), "resolve_image", "Resolve image", addResolveImageTests);
5978 return copiesAndBlittingTests.release();