1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2015-2016 The Khronos Group Inc.
6 * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 * \brief Vulkan Copies And Blitting Tests
23 *//*--------------------------------------------------------------------*/
25 #include "vktApiCopiesAndBlittingTests.hpp"
27 #include "deStringUtil.hpp"
28 #include "deUniquePtr.hpp"
31 #include "tcuImageCompare.hpp"
32 #include "tcuTexture.hpp"
33 #include "tcuTextureUtil.hpp"
34 #include "tcuVectorType.hpp"
35 #include "tcuVectorUtil.hpp"
37 #include "vkImageUtil.hpp"
38 #include "vkMemUtil.hpp"
39 #include "vkPrograms.hpp"
40 #include "vkQueryUtil.hpp"
41 #include "vkRefUtil.hpp"
42 #include "vktTestCase.hpp"
43 #include "vktTestCaseUtil.hpp"
44 #include "vkTypeUtil.hpp"
57 MIRROR_MODE_X = (1<<0),
58 MIRROR_MODE_Y = (1<<1),
59 MIRROR_MODE_XY = MIRROR_MODE_X | MIRROR_MODE_Y,
68 static VkImageAspectFlags getAspectFlags (tcu::TextureFormat format)
70 VkImageAspectFlags aspectFlag = 0;
71 aspectFlag |= (tcu::hasDepthComponent(format.order)? VK_IMAGE_ASPECT_DEPTH_BIT : 0);
72 aspectFlag |= (tcu::hasStencilComponent(format.order)? VK_IMAGE_ASPECT_STENCIL_BIT : 0);
75 aspectFlag = VK_IMAGE_ASPECT_COLOR_BIT;
85 VkBufferCopy bufferCopy;
86 VkImageCopy imageCopy;
87 VkBufferImageCopy bufferImageCopy;
88 VkImageBlit imageBlit;
89 VkImageResolve imageResolve;
94 VkImageType imageType;
111 std::vector<CopyRegion> regions;
116 VkSampleCountFlagBits samples;
120 inline deUint32 getArraySize(const ImageParms& parms)
122 return (parms.imageType == VK_IMAGE_TYPE_2D) ? parms.extent.depth : 1u;
125 inline VkExtent3D getExtent3D(const ImageParms& parms)
127 const VkExtent3D extent =
131 (parms.imageType == VK_IMAGE_TYPE_2D) ? 1u : parms.extent.depth
136 class CopiesAndBlittingTestInstance : public vkt::TestInstance
139 CopiesAndBlittingTestInstance (Context& context,
140 TestParams testParams);
141 virtual tcu::TestStatus iterate (void) = 0;
145 FILL_MODE_GRADIENT = 0,
148 FILL_MODE_MULTISAMPLE,
154 const TestParams m_params;
156 Move<VkCommandPool> m_cmdPool;
157 Move<VkCommandBuffer> m_cmdBuffer;
158 Move<VkFence> m_fence;
159 de::MovePtr<tcu::TextureLevel> m_sourceTextureLevel;
160 de::MovePtr<tcu::TextureLevel> m_destinationTextureLevel;
161 de::MovePtr<tcu::TextureLevel> m_expectedTextureLevel;
163 VkCommandBufferBeginInfo m_cmdBufferBeginInfo;
165 void generateBuffer (tcu::PixelBufferAccess buffer, int width, int height, int depth = 1, FillMode = FILL_MODE_GRADIENT);
166 virtual void generateExpectedResult (void);
167 void uploadBuffer (tcu::ConstPixelBufferAccess bufferAccess, const Allocation& bufferAlloc);
168 void uploadImage (tcu::ConstPixelBufferAccess imageAccess, const VkImage& image, const ImageParms& parms);
169 virtual tcu::TestStatus checkTestResult (tcu::ConstPixelBufferAccess result);
170 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region) = 0;
171 deUint32 calculateSize (tcu::ConstPixelBufferAccess src) const
173 return src.getWidth() * src.getHeight() * src.getDepth() * tcu::getPixelSize(src.getFormat());
176 de::MovePtr<tcu::TextureLevel> readImage (const vk::DeviceInterface& vk,
179 vk::Allocator& allocator,
181 const ImageParms& imageParms);
182 void submitCommandsAndWait (const DeviceInterface& vk,
183 const VkDevice device,
185 const VkCommandBuffer& cmdBuffer);
188 CopiesAndBlittingTestInstance::CopiesAndBlittingTestInstance (Context& context, TestParams testParams)
189 : vkt::TestInstance (context)
190 , m_params (testParams)
192 const DeviceInterface& vk = context.getDeviceInterface();
193 const VkDevice vkDevice = context.getDevice();
194 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
196 // Create command pool
198 const VkCommandPoolCreateInfo cmdPoolParams =
200 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // VkStructureType sType;
201 DE_NULL, // const void* pNext;
202 VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,// VkCmdPoolCreateFlags flags;
203 queueFamilyIndex, // deUint32 queueFamilyIndex;
206 m_cmdPool = createCommandPool(vk, vkDevice, &cmdPoolParams);
209 // Create command buffer
211 const VkCommandBufferAllocateInfo cmdBufferAllocateInfo =
213 VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // VkStructureType sType;
214 DE_NULL, // const void* pNext;
215 *m_cmdPool, // VkCommandPool commandPool;
216 VK_COMMAND_BUFFER_LEVEL_PRIMARY, // VkCommandBufferLevel level;
217 1u // deUint32 bufferCount;
220 m_cmdBuffer = allocateCommandBuffer(vk, vkDevice, &cmdBufferAllocateInfo);
225 const VkFenceCreateInfo fenceParams =
227 VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, // VkStructureType sType;
228 DE_NULL, // const void* pNext;
229 0u // VkFenceCreateFlags flags;
232 m_fence = createFence(vk, vkDevice, &fenceParams);
236 void CopiesAndBlittingTestInstance::generateBuffer (tcu::PixelBufferAccess buffer, int width, int height, int depth, FillMode mode)
238 if (mode == FILL_MODE_GRADIENT)
240 tcu::fillWithComponentGradients(buffer, tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
244 const tcu::Vec4 redColor (1.0, 0.0, 0.0, 1.0);
245 const tcu::Vec4 greenColor (0.0, 1.0, 0.0, 1.0);
246 const tcu::Vec4 blueColor (0.0, 0.0, 1.0, 1.0);
247 const tcu::Vec4 whiteColor (1.0, 1.0, 1.0, 1.0);
249 for (int z = 0; z < depth; z++)
251 for (int y = 0; y < height; y++)
253 for (int x = 0; x < width; x++)
257 case FILL_MODE_WHITE:
258 if (tcu::isCombinedDepthStencilType(buffer.getFormat().type))
260 buffer.setPixDepth(1.0f, x, y, z);
261 if (tcu::hasStencilComponent(buffer.getFormat().order))
262 buffer.setPixStencil(255, x, y, z);
265 buffer.setPixel(whiteColor, x, y, z);
268 DE_ASSERT(!tcu::isCombinedDepthStencilType(buffer.getFormat().type)); // combined types cannot be accessed directly
269 buffer.setPixel(redColor, x, y, z);
271 case FILL_MODE_MULTISAMPLE:
272 buffer.setPixel((x == y) ? tcu::Vec4(0.0, 0.5, 0.5, 1.0) : ((x > y) ? greenColor : blueColor), x, y, z);
282 void CopiesAndBlittingTestInstance::uploadBuffer (tcu::ConstPixelBufferAccess bufferAccess, const Allocation& bufferAlloc)
284 const DeviceInterface& vk = m_context.getDeviceInterface();
285 const VkDevice vkDevice = m_context.getDevice();
286 const deUint32 bufferSize = calculateSize(bufferAccess);
289 deMemcpy(bufferAlloc.getHostPtr(), bufferAccess.getDataPtr(), bufferSize);
290 flushMappedMemoryRange(vk, vkDevice, bufferAlloc.getMemory(), bufferAlloc.getOffset(), bufferSize);
293 void CopiesAndBlittingTestInstance::uploadImage (tcu::ConstPixelBufferAccess imageAccess, const VkImage& image, const ImageParms& parms)
295 const DeviceInterface& vk = m_context.getDeviceInterface();
296 const VkDevice vkDevice = m_context.getDevice();
297 const VkQueue queue = m_context.getUniversalQueue();
298 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
299 Allocator& memAlloc = m_context.getDefaultAllocator();
301 Move<VkBuffer> buffer;
302 const deUint32 bufferSize = calculateSize(imageAccess);
303 de::MovePtr<Allocation> bufferAlloc;
304 const deUint32 arraySize = getArraySize(parms);
305 const VkExtent3D imageExtent = getExtent3D(parms);
307 // Create source buffer
309 const VkBufferCreateInfo bufferParams =
311 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
312 DE_NULL, // const void* pNext;
313 0u, // VkBufferCreateFlags flags;
314 bufferSize, // VkDeviceSize size;
315 VK_BUFFER_USAGE_TRANSFER_SRC_BIT, // VkBufferUsageFlags usage;
316 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
317 1u, // deUint32 queueFamilyIndexCount;
318 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
321 buffer = createBuffer(vk, vkDevice, &bufferParams);
322 bufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *buffer), MemoryRequirement::HostVisible);
323 VK_CHECK(vk.bindBufferMemory(vkDevice, *buffer, bufferAlloc->getMemory(), bufferAlloc->getOffset()));
326 // Barriers for copying buffer to image
327 const VkBufferMemoryBarrier preBufferBarrier =
329 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
330 DE_NULL, // const void* pNext;
331 VK_ACCESS_HOST_WRITE_BIT, // VkAccessFlags srcAccessMask;
332 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
333 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
334 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
335 *buffer, // VkBuffer buffer;
336 0u, // VkDeviceSize offset;
337 bufferSize // VkDeviceSize size;
340 const VkImageAspectFlags aspect = getAspectFlags(imageAccess.getFormat());
341 const VkImageMemoryBarrier preImageBarrier =
343 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
344 DE_NULL, // const void* pNext;
345 0u, // VkAccessFlags srcAccessMask;
346 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
347 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
348 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
349 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
350 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
351 image, // VkImage image;
352 { // VkImageSubresourceRange subresourceRange;
353 aspect, // VkImageAspectFlags aspect;
354 0u, // deUint32 baseMipLevel;
355 1u, // deUint32 mipLevels;
356 0u, // deUint32 baseArraySlice;
357 arraySize, // deUint32 arraySize;
361 const VkImageMemoryBarrier postImageBarrier =
363 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
364 DE_NULL, // const void* pNext;
365 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
366 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
367 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
368 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
369 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
370 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
371 image, // VkImage image;
372 { // VkImageSubresourceRange subresourceRange;
373 aspect, // VkImageAspectFlags aspect;
374 0u, // deUint32 baseMipLevel;
375 1u, // deUint32 mipLevels;
376 0u, // deUint32 baseArraySlice;
377 arraySize, // deUint32 arraySize;
381 const deUint32 regionCount = tcu::isCombinedDepthStencilType(imageAccess.getFormat().type) ? 2u : 1u;
382 const VkImageAspectFlags firstRegionAspect = aspect & VK_IMAGE_ASPECT_DEPTH_BIT ? VkImageAspectFlags(VK_IMAGE_ASPECT_DEPTH_BIT) : aspect;
383 const VkBufferImageCopy copyRegion[] =
386 0u, // VkDeviceSize bufferOffset;
387 (deUint32)imageAccess.getWidth(), // deUint32 bufferRowLength;
388 (deUint32)imageAccess.getHeight(), // deUint32 bufferImageHeight;
389 { // VkImageSubresourceLayers imageSubresource;
390 firstRegionAspect, // VkImageAspectFlags aspect;
391 0u, // deUint32 mipLevel;
392 0u, // deUint32 baseArrayLayer;
393 arraySize, // deUint32 layerCount;
395 { 0, 0, 0 }, // VkOffset3D imageOffset;
396 imageExtent // VkExtent3D imageExtent;
399 0u, // VkDeviceSize bufferOffset;
400 (deUint32)imageAccess.getWidth(), // deUint32 bufferRowLength;
401 (deUint32)imageAccess.getHeight(), // deUint32 bufferImageHeight;
402 { // VkImageSubresourceLayers imageSubresource;
403 VK_IMAGE_ASPECT_STENCIL_BIT, // VkImageAspectFlags aspect;
404 0u, // deUint32 mipLevel;
405 0u, // deUint32 baseArrayLayer;
406 arraySize, // deUint32 layerCount;
408 { 0, 0, 0 }, // VkOffset3D imageOffset;
409 imageExtent // VkExtent3D imageExtent;
414 deMemcpy(bufferAlloc->getHostPtr(), imageAccess.getDataPtr(), bufferSize);
415 flushMappedMemoryRange(vk, vkDevice, bufferAlloc->getMemory(), bufferAlloc->getOffset(), bufferSize);
417 // Copy buffer to image
418 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
420 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
421 DE_NULL, // const void* pNext;
422 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
423 (const VkCommandBufferInheritanceInfo*)DE_NULL,
426 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
427 vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 1, &preBufferBarrier, 1, &preImageBarrier);
428 vk.cmdCopyBufferToImage(*m_cmdBuffer, *buffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, regionCount, copyRegion);
429 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);
430 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
432 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
435 tcu::TestStatus CopiesAndBlittingTestInstance::checkTestResult (tcu::ConstPixelBufferAccess result)
437 const tcu::ConstPixelBufferAccess expected = m_expectedTextureLevel->getAccess();
439 if (isFloatFormat(mapTextureFormat(result.getFormat())))
441 const tcu::Vec4 threshold (0.0f);
442 if (!tcu::floatThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparsion", expected, result, threshold, tcu::COMPARE_LOG_RESULT))
443 return tcu::TestStatus::fail("CopiesAndBlitting test");
447 const tcu::UVec4 threshold (0u);
448 if (!tcu::intThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparsion", expected, result, threshold, tcu::COMPARE_LOG_RESULT))
449 return tcu::TestStatus::fail("CopiesAndBlitting test");
452 return tcu::TestStatus::pass("CopiesAndBlitting test");
455 void CopiesAndBlittingTestInstance::generateExpectedResult (void)
457 const tcu::ConstPixelBufferAccess src = m_sourceTextureLevel->getAccess();
458 const tcu::ConstPixelBufferAccess dst = m_destinationTextureLevel->getAccess();
460 m_expectedTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(dst.getFormat(), dst.getWidth(), dst.getHeight(), dst.getDepth()));
461 tcu::copy(m_expectedTextureLevel->getAccess(), dst);
463 for (deUint32 i = 0; i < m_params.regions.size(); i++)
464 copyRegionToTextureLevel(src, m_expectedTextureLevel->getAccess(), m_params.regions[i]);
467 class CopiesAndBlittingTestCase : public vkt::TestCase
470 CopiesAndBlittingTestCase (tcu::TestContext& testCtx,
471 const std::string& name,
472 const std::string& description)
473 : vkt::TestCase (testCtx, name, description)
476 virtual TestInstance* createInstance (Context& context) const = 0;
479 de::MovePtr<tcu::TextureLevel> CopiesAndBlittingTestInstance::readImage (const vk::DeviceInterface& vk,
482 vk::Allocator& allocator,
484 const ImageParms& imageParms)
486 Move<VkBuffer> buffer;
487 de::MovePtr<Allocation> bufferAlloc;
488 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
489 const tcu::TextureFormat tcuFormat = mapVkFormat(imageParms.format);
490 const VkDeviceSize pixelDataSize = imageParms.extent.width * imageParms.extent.height * imageParms.extent.depth * tcu::getPixelSize(tcuFormat);
491 de::MovePtr<tcu::TextureLevel> resultLevel (new tcu::TextureLevel(tcuFormat,imageParms.extent.width, imageParms.extent.height, imageParms.extent.depth));
493 // Create destination buffer
495 const VkBufferCreateInfo bufferParams =
497 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
498 DE_NULL, // const void* pNext;
499 0u, // VkBufferCreateFlags flags;
500 pixelDataSize, // VkDeviceSize size;
501 VK_BUFFER_USAGE_TRANSFER_DST_BIT, // VkBufferUsageFlags usage;
502 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
503 1u, // deUint32 queueFamilyIndexCount;
504 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
507 buffer = createBuffer(vk, device, &bufferParams);
508 bufferAlloc = allocator.allocate(getBufferMemoryRequirements(vk, device, *buffer), MemoryRequirement::HostVisible);
509 VK_CHECK(vk.bindBufferMemory(device, *buffer, bufferAlloc->getMemory(), bufferAlloc->getOffset()));
511 deMemset(bufferAlloc->getHostPtr(), 0, static_cast<size_t>(pixelDataSize));
512 flushMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), pixelDataSize);
515 // Barriers for copying image to buffer
516 const VkImageAspectFlags aspect = getAspectFlags(tcuFormat);
517 const VkImageMemoryBarrier imageBarrier =
519 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
520 DE_NULL, // const void* pNext;
521 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
522 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
523 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
524 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // VkImageLayout newLayout;
525 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
526 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
527 image, // VkImage image;
528 { // VkImageSubresourceRange subresourceRange;
529 aspect, // VkImageAspectFlags aspectMask;
530 0u, // deUint32 baseMipLevel;
531 1u, // deUint32 mipLevels;
532 0u, // deUint32 baseArraySlice;
533 getArraySize(imageParms)// deUint32 arraySize;
537 const VkBufferMemoryBarrier bufferBarrier =
539 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
540 DE_NULL, // const void* pNext;
541 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
542 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
543 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
544 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
545 *buffer, // VkBuffer buffer;
546 0u, // VkDeviceSize offset;
547 pixelDataSize // VkDeviceSize size;
550 // Copy image to buffer
551 const deUint32 regionCount = tcu::isCombinedDepthStencilType(tcuFormat.type) ? 2u : 1u;
552 const VkImageAspectFlags firstRegionAspect = aspect & VK_IMAGE_ASPECT_DEPTH_BIT ? VkImageAspectFlags(VK_IMAGE_ASPECT_DEPTH_BIT) : aspect;
553 const VkBufferImageCopy copyRegion[] =
556 0u, // VkDeviceSize bufferOffset;
557 (deUint32)imageParms.extent.width, // deUint32 bufferRowLength;
558 (deUint32)imageParms.extent.height, // deUint32 bufferImageHeight;
559 { // VkImageSubresourceLayers imageSubresource;
560 firstRegionAspect, // VkImageAspectFlags aspect;
561 0u, // deUint32 mipLevel;
562 0u, // deUint32 baseArrayLayer;
563 getArraySize(imageParms), // deUint32 layerCount;
565 { 0, 0, 0 }, // VkOffset3D imageOffset;
566 getExtent3D(imageParms) // VkExtent3D imageExtent;
569 0u, // VkDeviceSize bufferOffset;
570 (deUint32)imageParms.extent.width, // deUint32 bufferRowLength;
571 (deUint32)imageParms.extent.height, // deUint32 bufferImageHeight;
572 { // VkImageSubresourceLayers imageSubresource;
573 VK_IMAGE_ASPECT_STENCIL_BIT, // VkImageAspectFlags aspect;
574 0u, // deUint32 mipLevel;
575 0u, // deUint32 baseArrayLayer;
576 getArraySize(imageParms), // deUint32 layerCount;
578 { 0, 0, 0 }, // VkOffset3D imageOffset;
579 getExtent3D(imageParms) // VkExtent3D imageExtent;
583 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
585 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
586 DE_NULL, // const void* pNext;
587 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
588 (const VkCommandBufferInheritanceInfo*)DE_NULL,
591 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
592 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);
593 vk.cmdCopyImageToBuffer(*m_cmdBuffer, image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *buffer, regionCount, copyRegion);
594 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);
595 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
597 submitCommandsAndWait (vk, device, queue, *m_cmdBuffer);
600 invalidateMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), pixelDataSize);
601 tcu::copy(*resultLevel, tcu::ConstPixelBufferAccess(resultLevel->getFormat(), resultLevel->getSize(), bufferAlloc->getHostPtr()));
606 void CopiesAndBlittingTestInstance::submitCommandsAndWait (const DeviceInterface& vk, const VkDevice device, const VkQueue queue, const VkCommandBuffer& cmdBuffer)
608 const VkSubmitInfo submitInfo =
610 VK_STRUCTURE_TYPE_SUBMIT_INFO, // VkStructureType sType;
611 DE_NULL, // const void* pNext;
612 0u, // deUint32 waitSemaphoreCount;
613 DE_NULL, // const VkSemaphore* pWaitSemaphores;
614 (const VkPipelineStageFlags*)DE_NULL,
615 1u, // deUint32 commandBufferCount;
616 &cmdBuffer, // const VkCommandBuffer* pCommandBuffers;
617 0u, // deUint32 signalSemaphoreCount;
618 DE_NULL // const VkSemaphore* pSignalSemaphores;
621 VK_CHECK(vk.resetFences(device, 1, &m_fence.get()));
622 VK_CHECK(vk.queueSubmit(queue, 1, &submitInfo, *m_fence));
623 VK_CHECK(vk.waitForFences(device, 1, &m_fence.get(), true, ~(0ull) /* infinity */));
626 // Copy from image to image.
628 class CopyImageToImage : public CopiesAndBlittingTestInstance
631 CopyImageToImage (Context& context,
633 virtual tcu::TestStatus iterate (void);
635 Move<VkImage> m_source;
636 de::MovePtr<Allocation> m_sourceImageAlloc;
637 Move<VkImage> m_destination;
638 de::MovePtr<Allocation> m_destinationImageAlloc;
640 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region);
643 CopyImageToImage::CopyImageToImage (Context& context, TestParams params)
644 : CopiesAndBlittingTestInstance(context, params)
646 const DeviceInterface& vk = context.getDeviceInterface();
647 const VkDevice vkDevice = context.getDevice();
648 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
649 Allocator& memAlloc = context.getDefaultAllocator();
651 VkImageFormatProperties properties;
652 if ((context.getInstanceInterface().getPhysicalDeviceImageFormatProperties (context.getPhysicalDevice(),
653 m_params.src.image.format,
655 VK_IMAGE_TILING_OPTIMAL,
656 VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
658 &properties) == VK_ERROR_FORMAT_NOT_SUPPORTED) ||
659 (context.getInstanceInterface().getPhysicalDeviceImageFormatProperties (context.getPhysicalDevice(),
660 m_params.dst.image.format,
662 VK_IMAGE_TILING_OPTIMAL,
663 VK_IMAGE_USAGE_TRANSFER_DST_BIT,
665 &properties) == VK_ERROR_FORMAT_NOT_SUPPORTED))
667 TCU_THROW(NotSupportedError, "Format not supported");
670 // Create source image
672 const VkImageCreateInfo sourceImageParams =
674 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
675 DE_NULL, // const void* pNext;
676 0u, // VkImageCreateFlags flags;
677 VK_IMAGE_TYPE_2D, // VkImageType imageType;
678 m_params.src.image.format, // VkFormat format;
679 m_params.src.image.extent, // VkExtent3D extent;
680 1u, // deUint32 mipLevels;
681 1u, // deUint32 arraySize;
682 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
683 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
684 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
685 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
686 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
687 1u, // deUint32 queueFamilyCount;
688 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
689 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
692 m_source = createImage(vk, vkDevice, &sourceImageParams);
693 m_sourceImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::Any);
694 VK_CHECK(vk.bindImageMemory(vkDevice, *m_source, m_sourceImageAlloc->getMemory(), m_sourceImageAlloc->getOffset()));
697 // Create destination image
699 const VkImageCreateInfo destinationImageParams =
701 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
702 DE_NULL, // const void* pNext;
703 0u, // VkImageCreateFlags flags;
704 VK_IMAGE_TYPE_2D, // VkImageType imageType;
705 m_params.dst.image.format, // VkFormat format;
706 m_params.dst.image.extent, // VkExtent3D extent;
707 1u, // deUint32 mipLevels;
708 1u, // deUint32 arraySize;
709 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
710 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
711 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
712 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
713 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
714 1u, // deUint32 queueFamilyCount;
715 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
716 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
719 m_destination = createImage(vk, vkDevice, &destinationImageParams);
720 m_destinationImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::Any);
721 VK_CHECK(vk.bindImageMemory(vkDevice, *m_destination, m_destinationImageAlloc->getMemory(), m_destinationImageAlloc->getOffset()));
725 tcu::TestStatus CopyImageToImage::iterate (void)
727 const tcu::TextureFormat srcTcuFormat = mapVkFormat(m_params.src.image.format);
728 const tcu::TextureFormat dstTcuFormat = mapVkFormat(m_params.dst.image.format);
729 m_sourceTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(srcTcuFormat,
730 m_params.src.image.extent.width,
731 m_params.src.image.extent.height,
732 m_params.src.image.extent.depth));
733 generateBuffer(m_sourceTextureLevel->getAccess(), m_params.src.image.extent.width, m_params.src.image.extent.height, m_params.src.image.extent.depth, FILL_MODE_WHITE);
734 m_destinationTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(dstTcuFormat,
735 (int)m_params.dst.image.extent.width,
736 (int)m_params.dst.image.extent.height,
737 (int)m_params.dst.image.extent.depth));
738 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);
739 generateExpectedResult();
741 uploadImage(m_sourceTextureLevel->getAccess(), m_source.get(), m_params.src.image);
742 uploadImage(m_destinationTextureLevel->getAccess(), m_destination.get(), m_params.dst.image);
744 const DeviceInterface& vk = m_context.getDeviceInterface();
745 const VkDevice vkDevice = m_context.getDevice();
746 const VkQueue queue = m_context.getUniversalQueue();
747 Allocator& memAlloc = m_context.getDefaultAllocator();
749 std::vector<VkImageCopy> imageCopies;
750 for (deUint32 i = 0; i < m_params.regions.size(); i++)
751 imageCopies.push_back(m_params.regions[i].imageCopy);
753 const VkImageMemoryBarrier imageBarriers[] =
757 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
758 DE_NULL, // const void* pNext;
759 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
760 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
761 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
762 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // VkImageLayout newLayout;
763 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
764 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
765 m_source.get(), // VkImage image;
766 { // VkImageSubresourceRange subresourceRange;
767 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
768 0u, // deUint32 baseMipLevel;
769 1u, // deUint32 mipLevels;
770 0u, // deUint32 baseArraySlice;
771 1u // deUint32 arraySize;
776 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
777 DE_NULL, // const void* pNext;
778 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
779 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
780 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
781 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
782 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
783 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
784 m_destination.get(), // VkImage image;
785 { // VkImageSubresourceRange subresourceRange;
786 getAspectFlags(dstTcuFormat), // VkImageAspectFlags aspectMask;
787 0u, // deUint32 baseMipLevel;
788 1u, // deUint32 mipLevels;
789 0u, // deUint32 baseArraySlice;
790 1u // deUint32 arraySize;
795 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
797 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
798 DE_NULL, // const void* pNext;
799 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
800 (const VkCommandBufferInheritanceInfo*)DE_NULL,
803 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
804 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);
805 vk.cmdCopyImage(*m_cmdBuffer, m_source.get(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, m_destination.get(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (deUint32)m_params.regions.size(), imageCopies.data());
806 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
808 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
810 de::MovePtr<tcu::TextureLevel> resultTextureLevel = readImage(vk, vkDevice, queue, memAlloc, *m_destination, m_params.dst.image);
812 return checkTestResult(resultTextureLevel->getAccess());
815 void CopyImageToImage::copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region)
817 VkOffset3D srcOffset = region.imageCopy.srcOffset;
818 VkOffset3D dstOffset = region.imageCopy.dstOffset;
819 VkExtent3D extent = region.imageCopy.extent;
821 if (tcu::isCombinedDepthStencilType(src.getFormat().type))
823 DE_ASSERT(src.getFormat() == dst.getFormat());
826 const tcu::ConstPixelBufferAccess srcSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(src, srcOffset.x, srcOffset.y, srcOffset.z, extent.width, extent.height, extent.depth), tcu::Sampler::MODE_DEPTH);
827 const tcu::PixelBufferAccess dstWithSrcFormat(srcSubRegion.getFormat(), dst.getSize(), dst.getDataPtr());
828 const tcu::PixelBufferAccess dstSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(dstWithSrcFormat, dstOffset.x, dstOffset.y, dstOffset.z, extent.width, extent.height, extent.depth), tcu::Sampler::MODE_DEPTH);
830 tcu::copy(dstSubRegion, srcSubRegion);
834 if (tcu::hasStencilComponent(src.getFormat().order))
836 const tcu::ConstPixelBufferAccess srcSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(src, srcOffset.x, srcOffset.y, srcOffset.z, extent.width, extent.height, extent.depth), tcu::Sampler::MODE_STENCIL);
837 const tcu::PixelBufferAccess dstWithSrcFormat(srcSubRegion.getFormat(), dst.getSize(), dst.getDataPtr());
838 const tcu::PixelBufferAccess dstSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(dstWithSrcFormat, dstOffset.x, dstOffset.y, dstOffset.z, extent.width, extent.height, extent.depth), tcu::Sampler::MODE_STENCIL);
840 tcu::copy(dstSubRegion, srcSubRegion);
845 const tcu::ConstPixelBufferAccess srcSubRegion = tcu::getSubregion(src, srcOffset.x, srcOffset.y, srcOffset.z, extent.width, extent.height, extent.depth);
846 // CopyImage acts like a memcpy. Replace the destination format with the srcformat to use a memcpy.
847 const tcu::PixelBufferAccess dstWithSrcFormat (srcSubRegion.getFormat(), dst.getSize(), dst.getDataPtr());
848 const tcu::PixelBufferAccess dstSubRegion = tcu::getSubregion(dstWithSrcFormat, dstOffset.x, dstOffset.y, dstOffset.z, extent.width, extent.height, extent.depth);
850 tcu::copy(dstSubRegion, srcSubRegion);
854 class CopyImageToImageTestCase : public vkt::TestCase
857 CopyImageToImageTestCase (tcu::TestContext& testCtx,
858 const std::string& name,
859 const std::string& description,
860 const TestParams params)
861 : vkt::TestCase (testCtx, name, description)
865 virtual TestInstance* createInstance (Context& context) const
867 return new CopyImageToImage(context, m_params);
873 // Copy from buffer to buffer.
875 class CopyBufferToBuffer : public CopiesAndBlittingTestInstance
878 CopyBufferToBuffer (Context& context, TestParams params);
879 virtual tcu::TestStatus iterate (void);
881 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess, tcu::PixelBufferAccess, CopyRegion);
882 Move<VkBuffer> m_source;
883 de::MovePtr<Allocation> m_sourceBufferAlloc;
884 Move<VkBuffer> m_destination;
885 de::MovePtr<Allocation> m_destinationBufferAlloc;
888 CopyBufferToBuffer::CopyBufferToBuffer (Context& context, TestParams params)
889 : CopiesAndBlittingTestInstance (context, params)
891 const DeviceInterface& vk = context.getDeviceInterface();
892 const VkDevice vkDevice = context.getDevice();
893 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
894 Allocator& memAlloc = context.getDefaultAllocator();
896 // Create source buffer
898 const VkBufferCreateInfo sourceBufferParams =
900 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
901 DE_NULL, // const void* pNext;
902 0u, // VkBufferCreateFlags flags;
903 m_params.src.buffer.size, // VkDeviceSize size;
904 VK_BUFFER_USAGE_TRANSFER_SRC_BIT, // VkBufferUsageFlags usage;
905 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
906 1u, // deUint32 queueFamilyIndexCount;
907 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
910 m_source = createBuffer(vk, vkDevice, &sourceBufferParams);
911 m_sourceBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::HostVisible);
912 VK_CHECK(vk.bindBufferMemory(vkDevice, *m_source, m_sourceBufferAlloc->getMemory(), m_sourceBufferAlloc->getOffset()));
915 // Create destination buffer
917 const VkBufferCreateInfo destinationBufferParams =
919 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
920 DE_NULL, // const void* pNext;
921 0u, // VkBufferCreateFlags flags;
922 m_params.dst.buffer.size, // VkDeviceSize size;
923 VK_BUFFER_USAGE_TRANSFER_DST_BIT, // VkBufferUsageFlags usage;
924 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
925 1u, // deUint32 queueFamilyIndexCount;
926 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
929 m_destination = createBuffer(vk, vkDevice, &destinationBufferParams);
930 m_destinationBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::HostVisible);
931 VK_CHECK(vk.bindBufferMemory(vkDevice, *m_destination, m_destinationBufferAlloc->getMemory(), m_destinationBufferAlloc->getOffset()));
935 tcu::TestStatus CopyBufferToBuffer::iterate (void)
937 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
938 m_sourceTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(mapVkFormat(VK_FORMAT_R32_UINT), srcLevelWidth, 1));
939 generateBuffer(m_sourceTextureLevel->getAccess(), srcLevelWidth, 1, 1, FILL_MODE_RED);
941 const int dstLevelWidth = (int)(m_params.dst.buffer.size/4);
942 m_destinationTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(mapVkFormat(VK_FORMAT_R32_UINT), dstLevelWidth, 1));
943 generateBuffer(m_destinationTextureLevel->getAccess(), dstLevelWidth, 1, 1, FILL_MODE_WHITE);
945 generateExpectedResult();
947 uploadBuffer(m_sourceTextureLevel->getAccess(), *m_sourceBufferAlloc);
948 uploadBuffer(m_destinationTextureLevel->getAccess(), *m_destinationBufferAlloc);
950 const DeviceInterface& vk = m_context.getDeviceInterface();
951 const VkDevice vkDevice = m_context.getDevice();
952 const VkQueue queue = m_context.getUniversalQueue();
954 const VkBufferMemoryBarrier srcBufferBarrier =
956 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
957 DE_NULL, // const void* pNext;
958 VK_ACCESS_HOST_WRITE_BIT, // VkAccessFlags srcAccessMask;
959 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
960 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
961 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
962 *m_source, // VkBuffer buffer;
963 0u, // VkDeviceSize offset;
964 m_params.src.buffer.size // VkDeviceSize size;
967 const VkBufferMemoryBarrier dstBufferBarrier =
969 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
970 DE_NULL, // const void* pNext;
971 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
972 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
973 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
974 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
975 *m_destination, // VkBuffer buffer;
976 0u, // VkDeviceSize offset;
977 m_params.dst.buffer.size // VkDeviceSize size;
980 std::vector<VkBufferCopy> bufferCopies;
981 for (deUint32 i = 0; i < m_params.regions.size(); i++)
982 bufferCopies.push_back(m_params.regions[i].bufferCopy);
984 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
986 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
987 DE_NULL, // const void* pNext;
988 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
989 (const VkCommandBufferInheritanceInfo*)DE_NULL,
992 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
993 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);
994 vk.cmdCopyBuffer(*m_cmdBuffer, m_source.get(), m_destination.get(), (deUint32)m_params.regions.size(), &bufferCopies[0]);
995 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);
996 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
998 const VkSubmitInfo submitInfo =
1000 VK_STRUCTURE_TYPE_SUBMIT_INFO, // VkStructureType sType;
1001 DE_NULL, // const void* pNext;
1002 0u, // deUint32 waitSemaphoreCount;
1003 DE_NULL, // const VkSemaphore* pWaitSemaphores;
1004 (const VkPipelineStageFlags*)DE_NULL,
1005 1u, // deUint32 commandBufferCount;
1006 &m_cmdBuffer.get(), // const VkCommandBuffer* pCommandBuffers;
1007 0u, // deUint32 signalSemaphoreCount;
1008 DE_NULL // const VkSemaphore* pSignalSemaphores;
1011 VK_CHECK(vk.resetFences(vkDevice, 1, &m_fence.get()));
1012 VK_CHECK(vk.queueSubmit(queue, 1, &submitInfo, *m_fence));
1013 VK_CHECK(vk.waitForFences(vkDevice, 1, &m_fence.get(), true, ~(0ull) /* infinity */));
1016 de::MovePtr<tcu::TextureLevel> resultLevel (new tcu::TextureLevel(mapVkFormat(VK_FORMAT_R32_UINT), dstLevelWidth, 1));
1017 invalidateMappedMemoryRange(vk, vkDevice, m_destinationBufferAlloc->getMemory(), m_destinationBufferAlloc->getOffset(), m_params.dst.buffer.size);
1018 tcu::copy(*resultLevel, tcu::ConstPixelBufferAccess(resultLevel->getFormat(), resultLevel->getSize(), m_destinationBufferAlloc->getHostPtr()));
1020 return checkTestResult(resultLevel->getAccess());
1023 void CopyBufferToBuffer::copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region)
1025 deMemcpy((deUint8*) dst.getDataPtr() + region.bufferCopy.dstOffset,
1026 (deUint8*) src.getDataPtr() + region.bufferCopy.srcOffset,
1027 (size_t)region.bufferCopy.size);
1030 class BufferToBufferTestCase : public vkt::TestCase
1033 BufferToBufferTestCase (tcu::TestContext& testCtx,
1034 const std::string& name,
1035 const std::string& description,
1036 const TestParams params)
1037 : vkt::TestCase (testCtx, name, description)
1041 virtual TestInstance* createInstance (Context& context) const
1043 return new CopyBufferToBuffer(context, m_params);
1046 TestParams m_params;
1049 // Copy from image to buffer.
1051 class CopyImageToBuffer : public CopiesAndBlittingTestInstance
1054 CopyImageToBuffer (Context& context,
1055 TestParams testParams);
1056 virtual tcu::TestStatus iterate (void);
1058 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region);
1060 tcu::TextureFormat m_textureFormat;
1061 VkDeviceSize m_bufferSize;
1063 Move<VkImage> m_source;
1064 de::MovePtr<Allocation> m_sourceImageAlloc;
1065 Move<VkBuffer> m_destination;
1066 de::MovePtr<Allocation> m_destinationBufferAlloc;
1069 CopyImageToBuffer::CopyImageToBuffer (Context& context, TestParams testParams)
1070 : CopiesAndBlittingTestInstance(context, testParams)
1071 , m_textureFormat(mapVkFormat(testParams.src.image.format))
1072 , m_bufferSize(m_params.dst.buffer.size * tcu::getPixelSize(m_textureFormat))
1074 const DeviceInterface& vk = context.getDeviceInterface();
1075 const VkDevice vkDevice = context.getDevice();
1076 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
1077 Allocator& memAlloc = context.getDefaultAllocator();
1079 // Create source image
1081 const VkImageCreateInfo sourceImageParams =
1083 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
1084 DE_NULL, // const void* pNext;
1085 0u, // VkImageCreateFlags flags;
1086 VK_IMAGE_TYPE_2D, // VkImageType imageType;
1087 m_params.src.image.format, // VkFormat format;
1088 m_params.src.image.extent, // VkExtent3D extent;
1089 1u, // deUint32 mipLevels;
1090 1u, // deUint32 arraySize;
1091 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
1092 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
1093 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1094 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
1095 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1096 1u, // deUint32 queueFamilyCount;
1097 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1098 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
1101 m_source = createImage(vk, vkDevice, &sourceImageParams);
1102 m_sourceImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::Any);
1103 VK_CHECK(vk.bindImageMemory(vkDevice, *m_source, m_sourceImageAlloc->getMemory(), m_sourceImageAlloc->getOffset()));
1106 // Create destination buffer
1108 const VkBufferCreateInfo destinationBufferParams =
1110 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
1111 DE_NULL, // const void* pNext;
1112 0u, // VkBufferCreateFlags flags;
1113 m_bufferSize, // VkDeviceSize size;
1114 VK_BUFFER_USAGE_TRANSFER_DST_BIT, // VkBufferUsageFlags usage;
1115 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1116 1u, // deUint32 queueFamilyIndexCount;
1117 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1120 m_destination = createBuffer(vk, vkDevice, &destinationBufferParams);
1121 m_destinationBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::HostVisible);
1122 VK_CHECK(vk.bindBufferMemory(vkDevice, *m_destination, m_destinationBufferAlloc->getMemory(), m_destinationBufferAlloc->getOffset()));
1126 tcu::TestStatus CopyImageToBuffer::iterate (void)
1128 m_sourceTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(m_textureFormat,
1129 m_params.src.image.extent.width,
1130 m_params.src.image.extent.height,
1131 m_params.src.image.extent.depth));
1132 generateBuffer(m_sourceTextureLevel->getAccess(), m_params.src.image.extent.width, m_params.src.image.extent.height, m_params.src.image.extent.depth);
1133 m_destinationTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(m_textureFormat, (int)m_params.dst.buffer.size, 1));
1134 generateBuffer(m_destinationTextureLevel->getAccess(), (int)m_params.dst.buffer.size, 1, 1);
1136 generateExpectedResult();
1138 uploadImage(m_sourceTextureLevel->getAccess(), *m_source, m_params.src.image);
1139 uploadBuffer(m_destinationTextureLevel->getAccess(), *m_destinationBufferAlloc);
1141 const DeviceInterface& vk = m_context.getDeviceInterface();
1142 const VkDevice vkDevice = m_context.getDevice();
1143 const VkQueue queue = m_context.getUniversalQueue();
1145 // Barriers for copying image to buffer
1146 const VkImageMemoryBarrier imageBarrier =
1148 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
1149 DE_NULL, // const void* pNext;
1150 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
1151 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
1152 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
1153 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // VkImageLayout newLayout;
1154 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1155 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1156 *m_source, // VkImage image;
1157 { // VkImageSubresourceRange subresourceRange;
1158 getAspectFlags(m_textureFormat), // VkImageAspectFlags aspectMask;
1159 0u, // deUint32 baseMipLevel;
1160 1u, // deUint32 mipLevels;
1161 0u, // deUint32 baseArraySlice;
1162 1u // deUint32 arraySize;
1166 const VkBufferMemoryBarrier bufferBarrier =
1168 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
1169 DE_NULL, // const void* pNext;
1170 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
1171 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
1172 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1173 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1174 *m_destination, // VkBuffer buffer;
1175 0u, // VkDeviceSize offset;
1176 m_bufferSize // VkDeviceSize size;
1179 // Copy from image to buffer
1180 std::vector<VkBufferImageCopy> bufferImageCopies;
1181 for (deUint32 i = 0; i < m_params.regions.size(); i++)
1182 bufferImageCopies.push_back(m_params.regions[i].bufferImageCopy);
1184 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
1186 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
1187 DE_NULL, // const void* pNext;
1188 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
1189 (const VkCommandBufferInheritanceInfo*)DE_NULL,
1192 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
1193 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);
1194 vk.cmdCopyImageToBuffer(*m_cmdBuffer, m_source.get(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, m_destination.get(), (deUint32)m_params.regions.size(), &bufferImageCopies[0]);
1195 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);
1196 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1198 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
1201 de::MovePtr<tcu::TextureLevel> resultLevel (new tcu::TextureLevel(m_textureFormat, (int)m_params.dst.buffer.size, 1));
1202 invalidateMappedMemoryRange(vk, vkDevice, m_destinationBufferAlloc->getMemory(), m_destinationBufferAlloc->getOffset(), m_bufferSize);
1203 tcu::copy(*resultLevel, tcu::ConstPixelBufferAccess(resultLevel->getFormat(), resultLevel->getSize(), m_destinationBufferAlloc->getHostPtr()));
1205 return checkTestResult(resultLevel->getAccess());
1208 class CopyImageToBufferTestCase : public vkt::TestCase
1211 CopyImageToBufferTestCase (tcu::TestContext& testCtx,
1212 const std::string& name,
1213 const std::string& description,
1214 const TestParams params)
1215 : vkt::TestCase (testCtx, name, description)
1219 virtual TestInstance* createInstance (Context& context) const
1221 return new CopyImageToBuffer(context, m_params);
1224 TestParams m_params;
1227 void CopyImageToBuffer::copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region)
1229 deUint32 rowLength = region.bufferImageCopy.bufferRowLength;
1231 rowLength = region.bufferImageCopy.imageExtent.width;
1233 deUint32 imageHeight = region.bufferImageCopy.bufferImageHeight;
1235 imageHeight = region.bufferImageCopy.imageExtent.height;
1237 const int texelSize = src.getFormat().getPixelSize();
1238 const VkExtent3D extent = region.bufferImageCopy.imageExtent;
1239 const VkOffset3D srcOffset = region.bufferImageCopy.imageOffset;
1240 const int texelOffset = (int) region.bufferImageCopy.bufferOffset / texelSize;
1242 for (deUint32 z = 0; z < extent.depth; z++)
1244 for (deUint32 y = 0; y < extent.height; y++)
1246 int texelIndex = texelOffset + (z * imageHeight + y) * rowLength;
1247 const tcu::ConstPixelBufferAccess srcSubRegion = tcu::getSubregion(src, srcOffset.x, srcOffset.y + y, srcOffset.z + z,
1248 region.bufferImageCopy.imageExtent.width, 1, 1);
1249 const tcu::PixelBufferAccess dstSubRegion = tcu::getSubregion(dst, texelIndex, 0, region.bufferImageCopy.imageExtent.width, 1);
1250 tcu::copy(dstSubRegion, srcSubRegion);
1255 // Copy from buffer to image.
1257 class CopyBufferToImage : public CopiesAndBlittingTestInstance
1260 CopyBufferToImage (Context& context,
1261 TestParams testParams);
1262 virtual tcu::TestStatus iterate (void);
1264 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region);
1266 tcu::TextureFormat m_textureFormat;
1267 VkDeviceSize m_bufferSize;
1269 Move<VkBuffer> m_source;
1270 de::MovePtr<Allocation> m_sourceBufferAlloc;
1271 Move<VkImage> m_destination;
1272 de::MovePtr<Allocation> m_destinationImageAlloc;
1275 CopyBufferToImage::CopyBufferToImage (Context& context, TestParams testParams)
1276 : CopiesAndBlittingTestInstance(context, testParams)
1277 , m_textureFormat(mapVkFormat(testParams.dst.image.format))
1278 , m_bufferSize(m_params.src.buffer.size * tcu::getPixelSize(m_textureFormat))
1280 const DeviceInterface& vk = context.getDeviceInterface();
1281 const VkDevice vkDevice = context.getDevice();
1282 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
1283 Allocator& memAlloc = context.getDefaultAllocator();
1285 // Create source buffer
1287 const VkBufferCreateInfo sourceBufferParams =
1289 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
1290 DE_NULL, // const void* pNext;
1291 0u, // VkBufferCreateFlags flags;
1292 m_bufferSize, // VkDeviceSize size;
1293 VK_BUFFER_USAGE_TRANSFER_SRC_BIT, // VkBufferUsageFlags usage;
1294 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1295 1u, // deUint32 queueFamilyIndexCount;
1296 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1299 m_source = createBuffer(vk, vkDevice, &sourceBufferParams);
1300 m_sourceBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::HostVisible);
1301 VK_CHECK(vk.bindBufferMemory(vkDevice, *m_source, m_sourceBufferAlloc->getMemory(), m_sourceBufferAlloc->getOffset()));
1304 // Create destination image
1306 const VkImageCreateInfo destinationImageParams =
1308 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
1309 DE_NULL, // const void* pNext;
1310 0u, // VkImageCreateFlags flags;
1311 VK_IMAGE_TYPE_2D, // VkImageType imageType;
1312 m_params.dst.image.format, // VkFormat format;
1313 m_params.dst.image.extent, // VkExtent3D extent;
1314 1u, // deUint32 mipLevels;
1315 1u, // deUint32 arraySize;
1316 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
1317 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
1318 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1319 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
1320 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1321 1u, // deUint32 queueFamilyCount;
1322 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1323 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
1326 m_destination = createImage(vk, vkDevice, &destinationImageParams);
1327 m_destinationImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::Any);
1328 VK_CHECK(vk.bindImageMemory(vkDevice, *m_destination, m_destinationImageAlloc->getMemory(), m_destinationImageAlloc->getOffset()));
1332 tcu::TestStatus CopyBufferToImage::iterate (void)
1334 m_sourceTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(m_textureFormat, (int)m_params.src.buffer.size, 1));
1335 generateBuffer(m_sourceTextureLevel->getAccess(), (int)m_params.src.buffer.size, 1, 1);
1336 m_destinationTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(m_textureFormat,
1337 m_params.dst.image.extent.width,
1338 m_params.dst.image.extent.height,
1339 m_params.dst.image.extent.depth));
1341 generateBuffer(m_destinationTextureLevel->getAccess(), m_params.dst.image.extent.width, m_params.dst.image.extent.height, m_params.dst.image.extent.depth);
1343 generateExpectedResult();
1345 uploadBuffer(m_sourceTextureLevel->getAccess(), *m_sourceBufferAlloc);
1346 uploadImage(m_destinationTextureLevel->getAccess(), *m_destination, m_params.dst.image);
1348 const DeviceInterface& vk = m_context.getDeviceInterface();
1349 const VkDevice vkDevice = m_context.getDevice();
1350 const VkQueue queue = m_context.getUniversalQueue();
1351 SimpleAllocator memAlloc (vk, vkDevice, getPhysicalDeviceMemoryProperties(m_context.getInstanceInterface(), m_context.getPhysicalDevice()));
1353 const VkImageMemoryBarrier imageBarrier =
1355 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
1356 DE_NULL, // const void* pNext;
1357 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
1358 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
1359 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
1360 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
1361 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1362 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1363 *m_destination, // VkImage image;
1364 { // VkImageSubresourceRange subresourceRange;
1365 getAspectFlags(m_textureFormat), // VkImageAspectFlags aspectMask;
1366 0u, // deUint32 baseMipLevel;
1367 1u, // deUint32 mipLevels;
1368 0u, // deUint32 baseArraySlice;
1369 1u // deUint32 arraySize;
1373 // Copy from buffer to image
1374 std::vector<VkBufferImageCopy> bufferImageCopies;
1375 for (deUint32 i = 0; i < m_params.regions.size(); i++)
1376 bufferImageCopies.push_back(m_params.regions[i].bufferImageCopy);
1378 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
1380 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
1381 DE_NULL, // const void* pNext;
1382 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
1383 (const VkCommandBufferInheritanceInfo*)DE_NULL,
1386 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
1387 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);
1388 vk.cmdCopyBufferToImage(*m_cmdBuffer, m_source.get(), m_destination.get(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (deUint32)m_params.regions.size(), bufferImageCopies.data());
1389 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1391 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
1393 de::MovePtr<tcu::TextureLevel> resultLevel = readImage(vk, vkDevice, queue, memAlloc, *m_destination, m_params.dst.image);
1395 return checkTestResult(resultLevel->getAccess());
1398 class CopyBufferToImageTestCase : public vkt::TestCase
1401 CopyBufferToImageTestCase (tcu::TestContext& testCtx,
1402 const std::string& name,
1403 const std::string& description,
1404 const TestParams params)
1405 : vkt::TestCase (testCtx, name, description)
1409 virtual ~CopyBufferToImageTestCase (void) {}
1411 virtual TestInstance* createInstance (Context& context) const
1413 return new CopyBufferToImage(context, m_params);
1416 TestParams m_params;
1419 void CopyBufferToImage::copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region)
1421 deUint32 rowLength = region.bufferImageCopy.bufferRowLength;
1423 rowLength = region.bufferImageCopy.imageExtent.width;
1425 deUint32 imageHeight = region.bufferImageCopy.bufferImageHeight;
1427 imageHeight = region.bufferImageCopy.imageExtent.height;
1429 const int texelSize = dst.getFormat().getPixelSize();
1430 const VkExtent3D extent = region.bufferImageCopy.imageExtent;
1431 const VkOffset3D dstOffset = region.bufferImageCopy.imageOffset;
1432 const int texelOffset = (int) region.bufferImageCopy.bufferOffset / texelSize;
1434 for (deUint32 z = 0; z < extent.depth; z++)
1436 for (deUint32 y = 0; y < extent.height; y++)
1438 int texelIndex = texelOffset + (z * imageHeight + y) * rowLength;
1439 const tcu::ConstPixelBufferAccess srcSubRegion = tcu::getSubregion(src, texelIndex, 0, region.bufferImageCopy.imageExtent.width, 1);
1440 const tcu::PixelBufferAccess dstSubRegion = tcu::getSubregion(dst, dstOffset.x, dstOffset.y + y, dstOffset.z + z,
1441 region.bufferImageCopy.imageExtent.width, 1, 1);
1442 tcu::copy(dstSubRegion, srcSubRegion);
1447 // Copy from image to image with scaling.
1449 class BlittingImages : public CopiesAndBlittingTestInstance
1452 BlittingImages (Context& context,
1454 virtual tcu::TestStatus iterate (void);
1456 virtual tcu::TestStatus checkTestResult (tcu::ConstPixelBufferAccess result);
1457 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region);
1458 virtual void generateExpectedResult (void);
1460 bool checkClampedAndUnclampedResult (const tcu::ConstPixelBufferAccess&, const tcu::ConstPixelBufferAccess&, const tcu::ConstPixelBufferAccess&);
1461 Move<VkImage> m_source;
1462 de::MovePtr<Allocation> m_sourceImageAlloc;
1463 Move<VkImage> m_destination;
1464 de::MovePtr<Allocation> m_destinationImageAlloc;
1466 de::MovePtr<tcu::TextureLevel> m_unclampedExpectedTextureLevel;
1469 BlittingImages::BlittingImages (Context& context, TestParams params)
1470 : CopiesAndBlittingTestInstance(context, params)
1472 const DeviceInterface& vk = context.getDeviceInterface();
1473 const VkDevice vkDevice = context.getDevice();
1474 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
1475 Allocator& memAlloc = context.getDefaultAllocator();
1477 VkImageFormatProperties properties;
1478 if ((context.getInstanceInterface().getPhysicalDeviceImageFormatProperties (context.getPhysicalDevice(),
1479 m_params.src.image.format,
1481 VK_IMAGE_TILING_OPTIMAL,
1482 VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
1484 &properties) == VK_ERROR_FORMAT_NOT_SUPPORTED) ||
1485 (context.getInstanceInterface().getPhysicalDeviceImageFormatProperties (context.getPhysicalDevice(),
1486 m_params.dst.image.format,
1488 VK_IMAGE_TILING_OPTIMAL,
1489 VK_IMAGE_USAGE_TRANSFER_DST_BIT,
1491 &properties) == VK_ERROR_FORMAT_NOT_SUPPORTED))
1493 TCU_THROW(NotSupportedError, "Format not supported");
1496 VkFormatProperties srcFormatProperties;
1497 context.getInstanceInterface().getPhysicalDeviceFormatProperties(context.getPhysicalDevice(), m_params.src.image.format, &srcFormatProperties);
1498 if (!(srcFormatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_SRC_BIT))
1500 TCU_THROW(NotSupportedError, "Format feature blit source not supported");
1503 VkFormatProperties dstFormatProperties;
1504 context.getInstanceInterface().getPhysicalDeviceFormatProperties(context.getPhysicalDevice(), m_params.dst.image.format, &dstFormatProperties);
1505 if (!(dstFormatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_DST_BIT))
1507 TCU_THROW(NotSupportedError, "Format feature blit destination not supported");
1510 if (m_params.filter == VK_FILTER_LINEAR)
1512 if (!(srcFormatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT))
1513 TCU_THROW(NotSupportedError, "Source format feature sampled image filter linear not supported");
1514 if (!(dstFormatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT))
1515 TCU_THROW(NotSupportedError, "Destination format feature sampled image filter linear not supported");
1518 // Create source image
1520 const VkImageCreateInfo sourceImageParams =
1522 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
1523 DE_NULL, // const void* pNext;
1524 0u, // VkImageCreateFlags flags;
1525 VK_IMAGE_TYPE_2D, // VkImageType imageType;
1526 m_params.src.image.format, // VkFormat format;
1527 m_params.src.image.extent, // VkExtent3D extent;
1528 1u, // deUint32 mipLevels;
1529 1u, // deUint32 arraySize;
1530 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
1531 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
1532 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1533 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
1534 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1535 1u, // deUint32 queueFamilyCount;
1536 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1537 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
1540 m_source = createImage(vk, vkDevice, &sourceImageParams);
1541 m_sourceImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_source), MemoryRequirement::Any);
1542 VK_CHECK(vk.bindImageMemory(vkDevice, *m_source, m_sourceImageAlloc->getMemory(), m_sourceImageAlloc->getOffset()));
1545 // Create destination image
1547 const VkImageCreateInfo destinationImageParams =
1549 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
1550 DE_NULL, // const void* pNext;
1551 0u, // VkImageCreateFlags flags;
1552 VK_IMAGE_TYPE_2D, // VkImageType imageType;
1553 m_params.dst.image.format, // VkFormat format;
1554 m_params.dst.image.extent, // VkExtent3D extent;
1555 1u, // deUint32 mipLevels;
1556 1u, // deUint32 arraySize;
1557 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
1558 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
1559 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1560 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
1561 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
1562 1u, // deUint32 queueFamilyCount;
1563 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
1564 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
1567 m_destination = createImage(vk, vkDevice, &destinationImageParams);
1568 m_destinationImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::Any);
1569 VK_CHECK(vk.bindImageMemory(vkDevice, *m_destination, m_destinationImageAlloc->getMemory(), m_destinationImageAlloc->getOffset()));
1573 tcu::TestStatus BlittingImages::iterate (void)
1575 const tcu::TextureFormat srcTcuFormat = mapVkFormat(m_params.src.image.format);
1576 const tcu::TextureFormat dstTcuFormat = mapVkFormat(m_params.dst.image.format);
1577 m_sourceTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(srcTcuFormat,
1578 m_params.src.image.extent.width,
1579 m_params.src.image.extent.height,
1580 m_params.src.image.extent.depth));
1581 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);
1582 m_destinationTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(dstTcuFormat,
1583 (int)m_params.dst.image.extent.width,
1584 (int)m_params.dst.image.extent.height,
1585 (int)m_params.dst.image.extent.depth));
1586 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);
1587 generateExpectedResult();
1589 uploadImage(m_sourceTextureLevel->getAccess(), m_source.get(), m_params.src.image);
1590 uploadImage(m_destinationTextureLevel->getAccess(), m_destination.get(), m_params.dst.image);
1592 const DeviceInterface& vk = m_context.getDeviceInterface();
1593 const VkDevice vkDevice = m_context.getDevice();
1594 const VkQueue queue = m_context.getUniversalQueue();
1595 Allocator& memAlloc = m_context.getDefaultAllocator();
1597 std::vector<VkImageBlit> regions;
1598 for (deUint32 i = 0; i < m_params.regions.size(); i++)
1599 regions.push_back(m_params.regions[i].imageBlit);
1601 // Barriers for copying image to buffer
1602 const VkImageMemoryBarrier srcImageBarrier =
1604 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
1605 DE_NULL, // const void* pNext;
1606 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
1607 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
1608 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
1609 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // VkImageLayout newLayout;
1610 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1611 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1612 m_source.get(), // VkImage image;
1613 { // VkImageSubresourceRange subresourceRange;
1614 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
1615 0u, // deUint32 baseMipLevel;
1616 1u, // deUint32 mipLevels;
1617 0u, // deUint32 baseArraySlice;
1618 1u // deUint32 arraySize;
1622 const VkImageMemoryBarrier dstImageBarrier =
1624 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
1625 DE_NULL, // const void* pNext;
1626 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
1627 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
1628 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
1629 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
1630 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
1631 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
1632 m_destination.get(), // VkImage image;
1633 { // VkImageSubresourceRange subresourceRange;
1634 getAspectFlags(dstTcuFormat), // VkImageAspectFlags aspectMask;
1635 0u, // deUint32 baseMipLevel;
1636 1u, // deUint32 mipLevels;
1637 0u, // deUint32 baseArraySlice;
1638 1u // deUint32 arraySize;
1642 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
1644 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
1645 DE_NULL, // const void* pNext;
1646 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
1647 (const VkCommandBufferInheritanceInfo*)DE_NULL,
1650 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
1651 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);
1652 vk.cmdBlitImage(*m_cmdBuffer, m_source.get(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, m_destination.get(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (deUint32)m_params.regions.size(), ®ions[0], m_params.filter);
1653 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);
1654 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1656 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
1658 de::MovePtr<tcu::TextureLevel> resultTextureLevel = readImage(vk, vkDevice, queue, memAlloc, *m_destination, m_params.dst.image);
1660 return checkTestResult(resultTextureLevel->getAccess());
1663 static float calculateFloatConversionError (int srcBits)
1667 const int clampedBits = de::clamp<int>(srcBits, 0, 32);
1668 const float srcMaxValue = de::max((float)(1ULL<<clampedBits) - 1.0f, 1.0f);
1669 const float error = 1.0f / srcMaxValue;
1671 return de::clamp<float>(error, 0.0f, 1.0f);
1677 tcu::Vec4 getFormatThreshold (const tcu::TextureFormat& format)
1679 tcu::Vec4 threshold(0.01f);
1681 switch (format.type)
1683 case tcu::TextureFormat::HALF_FLOAT:
1684 threshold = tcu::Vec4(0.005f);
1687 case tcu::TextureFormat::FLOAT:
1688 case tcu::TextureFormat::FLOAT64:
1689 threshold = tcu::Vec4(0.001f);
1692 case tcu::TextureFormat::UNSIGNED_INT_11F_11F_10F_REV:
1693 threshold = tcu::Vec4(0.02f, 0.02f, 0.0625f, 1.0f);
1696 case tcu::TextureFormat::UNSIGNED_INT_999_E5_REV:
1697 threshold = tcu::Vec4(0.05f, 0.05f, 0.05f, 1.0f);
1701 const tcu::IVec4 bits = tcu::getTextureFormatMantissaBitDepth(format);
1702 threshold = tcu::Vec4(calculateFloatConversionError(bits.x()),
1703 calculateFloatConversionError(bits.y()),
1704 calculateFloatConversionError(bits.z()),
1705 calculateFloatConversionError(bits.w()));
1708 // Return value matching the channel order specified by the format
1709 if (format.order == tcu::TextureFormat::BGR || format.order == tcu::TextureFormat::BGRA)
1710 return threshold.swizzle(2, 1, 0, 3);
1715 bool BlittingImages::checkClampedAndUnclampedResult(const tcu::ConstPixelBufferAccess& result,
1716 const tcu::ConstPixelBufferAccess& clampedExpected,
1717 const tcu::ConstPixelBufferAccess& unclampedExpected)
1719 tcu::TestLog& log (m_context.getTestContext().getLog());
1720 const bool isLinear = m_params.filter == VK_FILTER_LINEAR;
1721 const tcu::TextureFormat srcFormat = m_sourceTextureLevel->getFormat();
1722 const tcu::TextureFormat dstFormat = result.getFormat();
1726 log << tcu::TestLog::Section("ClampedSourceImage", "Region with clamped edges on source image.");
1728 if (isFloatFormat(mapTextureFormat(dstFormat)))
1730 const bool srcIsSRGB = tcu::isSRGB(srcFormat);
1731 const tcu::Vec4 srcMaxDiff = getFormatThreshold(srcFormat) * tcu::Vec4(srcIsSRGB ? 2.0f : 1.0f);
1732 const tcu::Vec4 dstMaxDiff = getFormatThreshold(dstFormat);
1733 const tcu::Vec4 threshold = tcu::max(srcMaxDiff, dstMaxDiff);
1735 isOk = tcu::floatThresholdCompare(log, "Compare", "Result comparsion", clampedExpected, result, threshold, tcu::COMPARE_LOG_RESULT);
1738 log << tcu::TestLog::EndSection;
1740 if (!isOk && isLinear)
1742 log << tcu::TestLog::Section("NonClampedSourceImage", "Region with non-clamped edges on source image.");
1743 isOk = tcu::floatThresholdCompare(log, "Compare", "Result comparsion", unclampedExpected, result, threshold, tcu::COMPARE_LOG_RESULT);
1744 log << tcu::TestLog::EndSection;
1749 tcu::UVec4 threshold;
1750 // Calculate threshold depending on channel width of destination format.
1751 const tcu::IVec4 bitDepth = tcu::getTextureFormatBitDepth(dstFormat);
1752 for (deUint32 i = 0; i < 4; ++i)
1753 threshold[i] = de::max( (0x1 << bitDepth[i]) / 256, 1);
1755 isOk = tcu::intThresholdCompare(log, "Compare", "Result comparsion", clampedExpected, result, threshold, tcu::COMPARE_LOG_RESULT);
1758 log << tcu::TestLog::EndSection;
1760 if (!isOk && isLinear)
1762 log << tcu::TestLog::Section("NonClampedSourceImage", "Region with non-clamped edges on source image.");
1763 isOk = tcu::intThresholdCompare(log, "Compare", "Result comparsion", unclampedExpected, result, threshold, tcu::COMPARE_LOG_RESULT);
1764 log << tcu::TestLog::EndSection;
1770 tcu::TestStatus BlittingImages::checkTestResult (tcu::ConstPixelBufferAccess result)
1772 DE_ASSERT(m_params.filter == VK_FILTER_NEAREST || m_params.filter == VK_FILTER_LINEAR);
1774 if (tcu::isCombinedDepthStencilType(result.getFormat().type))
1776 if (tcu::hasDepthComponent(result.getFormat().order))
1778 const tcu::Sampler::DepthStencilMode mode = tcu::Sampler::MODE_DEPTH;
1779 const tcu::ConstPixelBufferAccess depthResult = tcu::getEffectiveDepthStencilAccess(result, mode);
1780 const tcu::ConstPixelBufferAccess clampedExpected = tcu::getEffectiveDepthStencilAccess(m_expectedTextureLevel->getAccess(), mode);
1781 const tcu::ConstPixelBufferAccess unclampedExpected = m_params.filter == VK_FILTER_LINEAR ? tcu::getEffectiveDepthStencilAccess(m_unclampedExpectedTextureLevel->getAccess(), mode) : tcu::ConstPixelBufferAccess();
1783 if (!checkClampedAndUnclampedResult(depthResult, clampedExpected, unclampedExpected))
1785 return tcu::TestStatus::fail("CopiesAndBlitting test");
1789 if (tcu::hasStencilComponent(result.getFormat().order))
1791 const tcu::Sampler::DepthStencilMode mode = tcu::Sampler::MODE_STENCIL;
1792 const tcu::ConstPixelBufferAccess stencilResult = tcu::getEffectiveDepthStencilAccess(result, mode);
1793 const tcu::ConstPixelBufferAccess clampedExpected = tcu::getEffectiveDepthStencilAccess(m_expectedTextureLevel->getAccess(), mode);
1794 const tcu::ConstPixelBufferAccess unclampedExpected = m_params.filter == VK_FILTER_LINEAR ? tcu::getEffectiveDepthStencilAccess(m_unclampedExpectedTextureLevel->getAccess(), mode) : tcu::ConstPixelBufferAccess();
1796 if (!checkClampedAndUnclampedResult(stencilResult, clampedExpected, unclampedExpected))
1798 return tcu::TestStatus::fail("CopiesAndBlitting test");
1804 if (!checkClampedAndUnclampedResult(result, m_expectedTextureLevel->getAccess(), m_params.filter == VK_FILTER_LINEAR ? m_unclampedExpectedTextureLevel->getAccess() : tcu::ConstPixelBufferAccess()))
1806 return tcu::TestStatus::fail("CopiesAndBlitting test");
1810 return tcu::TestStatus::pass("CopiesAndBlitting test");
1813 tcu::Vec4 linearToSRGBIfNeeded (const tcu::TextureFormat& format, const tcu::Vec4& color)
1815 return isSRGB(format) ? linearToSRGB(color) : color;
1818 void scaleFromWholeSrcBuffer (const tcu::PixelBufferAccess& dst, const tcu::ConstPixelBufferAccess& src, const VkOffset3D regionOffset, const VkOffset3D regionExtent, tcu::Sampler::FilterMode filter)
1820 DE_ASSERT(filter == tcu::Sampler::LINEAR);
1821 DE_ASSERT(dst.getDepth() == 1 && src.getDepth() == 1);
1823 tcu::Sampler sampler(tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::CLAMP_TO_EDGE,
1824 filter, filter, 0.0f, false);
1826 float sX = (float)regionExtent.x / (float)dst.getWidth();
1827 float sY = (float)regionExtent.y / (float)dst.getHeight();
1829 for (int y = 0; y < dst.getHeight(); y++)
1830 for (int x = 0; x < dst.getWidth(); x++)
1831 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);
1834 void blit (const tcu::PixelBufferAccess& dst, const tcu::ConstPixelBufferAccess& src, const tcu::Sampler::FilterMode filter, const MirrorMode mirrorMode)
1836 DE_ASSERT(filter == tcu::Sampler::NEAREST || filter == tcu::Sampler::LINEAR);
1838 tcu::Sampler sampler(tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::CLAMP_TO_EDGE,
1839 filter, filter, 0.0f, false);
1841 const float sX = (float)src.getWidth() / (float)dst.getWidth();
1842 const float sY = (float)src.getHeight() / (float)dst.getHeight();
1843 const float sZ = (float)src.getDepth() / (float)dst.getDepth();
1845 tcu::Mat2 rotMatrix;
1846 rotMatrix(0,0) = (mirrorMode & MIRROR_MODE_X) ? -1.0f : 1.0f;
1847 rotMatrix(0,1) = 0.0f;
1848 rotMatrix(1,0) = 0.0f;
1849 rotMatrix(1,1) = (mirrorMode & MIRROR_MODE_Y) ? -1.0f : 1.0f;
1851 const int xOffset = (mirrorMode & MIRROR_MODE_X) ? dst.getWidth() - 1 : 0;
1852 const int yOffset = (mirrorMode & MIRROR_MODE_Y) ? dst.getHeight() - 1 : 0;
1854 if (dst.getDepth() == 1 && src.getDepth() == 1)
1856 for (int y = 0; y < dst.getHeight(); ++y)
1857 for (int x = 0; x < dst.getWidth(); ++x)
1859 const tcu::Vec2 xy = rotMatrix * tcu::Vec2((float)x,(float)y);
1860 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);
1865 for (int z = 0; z < dst.getDepth(); ++z)
1866 for (int y = 0; y < dst.getHeight(); ++y)
1867 for (int x = 0; x < dst.getWidth(); ++x)
1869 const tcu::Vec2 xy = rotMatrix * tcu::Vec2((float)x,(float)y);
1870 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);
1875 void flipCoordinates (CopyRegion& region, const MirrorMode mirrorMode)
1877 const VkOffset3D dstOffset0 = region.imageBlit.dstOffsets[0];
1878 const VkOffset3D dstOffset1 = region.imageBlit.dstOffsets[1];
1879 const VkOffset3D srcOffset0 = region.imageBlit.srcOffsets[0];
1880 const VkOffset3D srcOffset1 = region.imageBlit.srcOffsets[1];
1882 if (mirrorMode > MIRROR_MODE_NONE && mirrorMode < MIRROR_MODE_LAST)
1885 region.imageBlit.srcOffsets[0].x = std::min(srcOffset0.x, srcOffset1.x);
1886 region.imageBlit.srcOffsets[0].y = std::min(srcOffset0.y, srcOffset1.y);
1888 region.imageBlit.srcOffsets[1].x = std::max(srcOffset0.x, srcOffset1.x);
1889 region.imageBlit.srcOffsets[1].y = std::max(srcOffset0.y, srcOffset1.y);
1892 region.imageBlit.dstOffsets[0].x = std::min(dstOffset0.x, dstOffset1.x);
1893 region.imageBlit.dstOffsets[0].y = std::min(dstOffset0.y, dstOffset1.y);
1895 region.imageBlit.dstOffsets[1].x = std::max(dstOffset0.x, dstOffset1.x);
1896 region.imageBlit.dstOffsets[1].y = std::max(dstOffset0.y, dstOffset1.y);
1900 MirrorMode getMirrorMode(const VkOffset3D x1, const VkOffset3D x2)
1902 if (x1.x >= x2.x && x1.y >= x2.y)
1904 return MIRROR_MODE_XY;
1906 else if (x1.x <= x2.x && x1.y <= x2.y)
1908 return MIRROR_MODE_NONE;
1910 else if (x1.x <= x2.x && x1.y >= x2.y)
1912 return MIRROR_MODE_Y;
1914 else if (x1.x >= x2.x && x1.y <= x2.y)
1916 return MIRROR_MODE_X;
1918 return MIRROR_MODE_LAST;
1921 MirrorMode getMirrorMode(const VkOffset3D s1, const VkOffset3D s2, const VkOffset3D d1, const VkOffset3D d2)
1923 const MirrorMode source = getMirrorMode(s1, s2);
1924 const MirrorMode destination = getMirrorMode(d1, d2);
1926 if (source == destination)
1928 return MIRROR_MODE_NONE;
1930 else if ((source == MIRROR_MODE_XY && destination == MIRROR_MODE_X) || (destination == MIRROR_MODE_XY && source == MIRROR_MODE_X) ||
1931 (source == MIRROR_MODE_Y && destination == MIRROR_MODE_NONE) || (destination == MIRROR_MODE_Y && source == MIRROR_MODE_NONE))
1933 return MIRROR_MODE_Y;
1935 else if ((source == MIRROR_MODE_XY && destination == MIRROR_MODE_Y) || (destination == MIRROR_MODE_XY && source == MIRROR_MODE_Y) ||
1936 (source == MIRROR_MODE_X && destination == MIRROR_MODE_NONE) || (destination == MIRROR_MODE_X && source == MIRROR_MODE_NONE))
1938 return MIRROR_MODE_X;
1940 else if ((source == MIRROR_MODE_XY && destination == MIRROR_MODE_NONE) || (destination == MIRROR_MODE_XY && source == MIRROR_MODE_NONE))
1942 return MIRROR_MODE_XY;
1944 return MIRROR_MODE_LAST;
1947 void BlittingImages::copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region)
1949 const MirrorMode mirrorMode = getMirrorMode(region.imageBlit.srcOffsets[0],
1950 region.imageBlit.srcOffsets[1],
1951 region.imageBlit.dstOffsets[0],
1952 region.imageBlit.dstOffsets[1]);
1954 flipCoordinates(region, mirrorMode);
1956 const VkOffset3D srcOffset = region.imageBlit.srcOffsets[0];
1957 const VkOffset3D srcExtent =
1959 region.imageBlit.srcOffsets[1].x - srcOffset.x,
1960 region.imageBlit.srcOffsets[1].y - srcOffset.y,
1961 region.imageBlit.srcOffsets[1].z - srcOffset.z
1963 const VkOffset3D dstOffset = region.imageBlit.dstOffsets[0];
1964 const VkOffset3D dstExtent =
1966 region.imageBlit.dstOffsets[1].x - dstOffset.x,
1967 region.imageBlit.dstOffsets[1].y - dstOffset.y,
1968 region.imageBlit.dstOffsets[1].z - dstOffset.z
1970 const tcu::Sampler::FilterMode filter = (m_params.filter == VK_FILTER_LINEAR) ? tcu::Sampler::LINEAR : tcu::Sampler::NEAREST;
1972 if (tcu::isCombinedDepthStencilType(src.getFormat().type))
1974 DE_ASSERT(src.getFormat() == dst.getFormat());
1976 if (tcu::hasDepthComponent(src.getFormat().order))
1978 const tcu::ConstPixelBufferAccess srcSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(src, srcOffset.x, srcOffset.y, srcExtent.x, srcExtent.y), tcu::Sampler::MODE_DEPTH);
1979 const tcu::PixelBufferAccess dstSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(dst, dstOffset.x, dstOffset.y, dstExtent.x, dstExtent.y), tcu::Sampler::MODE_DEPTH);
1980 tcu::scale(dstSubRegion, srcSubRegion, filter);
1982 if (filter == tcu::Sampler::LINEAR)
1984 const tcu::ConstPixelBufferAccess depthSrc = getEffectiveDepthStencilAccess(src, tcu::Sampler::MODE_DEPTH);
1985 const tcu::PixelBufferAccess unclampedSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(m_unclampedExpectedTextureLevel->getAccess(), dstOffset.x, dstOffset.y, dstExtent.x, dstExtent.y), tcu::Sampler::MODE_DEPTH);
1986 scaleFromWholeSrcBuffer(unclampedSubRegion, depthSrc, srcOffset, srcExtent, filter);
1991 if (tcu::hasStencilComponent(src.getFormat().order))
1993 const tcu::ConstPixelBufferAccess srcSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(src, srcOffset.x, srcOffset.y, srcExtent.x, srcExtent.y), tcu::Sampler::MODE_STENCIL);
1994 const tcu::PixelBufferAccess dstSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(dst, dstOffset.x, dstOffset.y, dstExtent.x, dstExtent.y), tcu::Sampler::MODE_STENCIL);
1995 blit(dstSubRegion, srcSubRegion, filter, mirrorMode);
1997 if (filter == tcu::Sampler::LINEAR)
1999 const tcu::ConstPixelBufferAccess stencilSrc = getEffectiveDepthStencilAccess(src, tcu::Sampler::MODE_STENCIL);
2000 const tcu::PixelBufferAccess unclampedSubRegion = getEffectiveDepthStencilAccess(tcu::getSubregion(m_unclampedExpectedTextureLevel->getAccess(), dstOffset.x, dstOffset.y, dstExtent.x, dstExtent.y), tcu::Sampler::MODE_STENCIL);
2001 scaleFromWholeSrcBuffer(unclampedSubRegion, stencilSrc, srcOffset, srcExtent, filter);
2007 const tcu::ConstPixelBufferAccess srcSubRegion = tcu::getSubregion(src, srcOffset.x, srcOffset.y, srcExtent.x, srcExtent.y);
2008 const tcu::PixelBufferAccess dstSubRegion = tcu::getSubregion(dst, dstOffset.x, dstOffset.y, dstExtent.x, dstExtent.y);
2009 blit(dstSubRegion, srcSubRegion, filter, mirrorMode);
2011 if (filter == tcu::Sampler::LINEAR)
2013 const tcu::PixelBufferAccess unclampedSubRegion = tcu::getSubregion(m_unclampedExpectedTextureLevel->getAccess(), dstOffset.x, dstOffset.y, dstExtent.x, dstExtent.y);
2014 scaleFromWholeSrcBuffer(unclampedSubRegion, src, srcOffset, srcExtent, filter);
2019 void BlittingImages::generateExpectedResult (void)
2021 const tcu::ConstPixelBufferAccess src = m_sourceTextureLevel->getAccess();
2022 const tcu::ConstPixelBufferAccess dst = m_destinationTextureLevel->getAccess();
2024 m_expectedTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(dst.getFormat(), dst.getWidth(), dst.getHeight(), dst.getDepth()));
2025 tcu::copy(m_expectedTextureLevel->getAccess(), dst);
2027 if (m_params.filter == VK_FILTER_LINEAR)
2029 m_unclampedExpectedTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(dst.getFormat(), dst.getWidth(), dst.getHeight(), dst.getDepth()));
2030 tcu::copy(m_unclampedExpectedTextureLevel->getAccess(), dst);
2033 for (deUint32 i = 0; i < m_params.regions.size(); i++)
2035 CopyRegion region = m_params.regions[i];
2036 copyRegionToTextureLevel(src, m_expectedTextureLevel->getAccess(), region);
2040 class BlittingTestCase : public vkt::TestCase
2043 BlittingTestCase (tcu::TestContext& testCtx,
2044 const std::string& name,
2045 const std::string& description,
2046 const TestParams params)
2047 : vkt::TestCase (testCtx, name, description)
2051 virtual TestInstance* createInstance (Context& context) const
2053 return new BlittingImages(context, m_params);
2056 TestParams m_params;
2059 // Resolve image to image.
2061 enum ResolveImageToImageOptions{NO_OPTIONAL_OPERATION, COPY_MS_IMAGE_TO_MS_IMAGE, COPY_MS_IMAGE_TO_ARRAY_MS_IMAGE};
2062 class ResolveImageToImage : public CopiesAndBlittingTestInstance
2065 ResolveImageToImage (Context& context,
2067 const ResolveImageToImageOptions options);
2068 virtual tcu::TestStatus iterate (void);
2070 virtual tcu::TestStatus checkTestResult (tcu::ConstPixelBufferAccess result);
2071 void copyMSImageToMSImage (void);
2073 Move<VkImage> m_multisampledImage;
2074 de::MovePtr<Allocation> m_multisampledImageAlloc;
2076 Move<VkImage> m_destination;
2077 de::MovePtr<Allocation> m_destinationImageAlloc;
2079 Move<VkImage> m_multisampledCopyImage;
2080 de::MovePtr<Allocation> m_multisampledCopyImageAlloc;
2082 const ResolveImageToImageOptions m_options;
2084 virtual void copyRegionToTextureLevel (tcu::ConstPixelBufferAccess src,
2085 tcu::PixelBufferAccess dst,
2089 ResolveImageToImage::ResolveImageToImage (Context& context, TestParams params, const ResolveImageToImageOptions options)
2090 : CopiesAndBlittingTestInstance (context, params)
2091 , m_options (options)
2093 const VkSampleCountFlagBits rasterizationSamples = m_params.samples;
2095 if (!(context.getDeviceProperties().limits.framebufferColorSampleCounts & rasterizationSamples))
2096 throw tcu::NotSupportedError("Unsupported number of rasterization samples");
2098 const DeviceInterface& vk = context.getDeviceInterface();
2099 const VkDevice vkDevice = context.getDevice();
2100 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
2101 Allocator& memAlloc = m_context.getDefaultAllocator();
2103 const VkComponentMapping componentMappingRGBA = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A };
2104 Move<VkRenderPass> renderPass;
2106 Move<VkShaderModule> vertexShaderModule = createShaderModule(vk, vkDevice, m_context.getBinaryCollection().get("vert"), 0);
2107 Move<VkShaderModule> fragmentShaderModule = createShaderModule(vk, vkDevice, m_context.getBinaryCollection().get("frag"), 0);
2108 std::vector<tcu::Vec4> vertices;
2110 Move<VkBuffer> vertexBuffer;
2111 de::MovePtr<Allocation> vertexBufferAlloc;
2113 Move<VkPipelineLayout> pipelineLayout;
2114 Move<VkPipeline> graphicsPipeline;
2116 VkImageFormatProperties properties;
2117 if ((context.getInstanceInterface().getPhysicalDeviceImageFormatProperties (context.getPhysicalDevice(),
2118 m_params.src.image.format,
2119 m_params.src.image.imageType,
2120 VK_IMAGE_TILING_OPTIMAL,
2121 VK_IMAGE_USAGE_TRANSFER_SRC_BIT, 0,
2122 &properties) == VK_ERROR_FORMAT_NOT_SUPPORTED) ||
2123 (context.getInstanceInterface().getPhysicalDeviceImageFormatProperties (context.getPhysicalDevice(),
2124 m_params.dst.image.format,
2125 m_params.dst.image.imageType,
2126 VK_IMAGE_TILING_OPTIMAL,
2127 VK_IMAGE_USAGE_TRANSFER_DST_BIT, 0,
2128 &properties) == VK_ERROR_FORMAT_NOT_SUPPORTED))
2130 TCU_THROW(NotSupportedError, "Format not supported");
2133 // Create color image.
2135 VkImageCreateInfo colorImageParams =
2137 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
2138 DE_NULL, // const void* pNext;
2139 0u, // VkImageCreateFlags flags;
2140 m_params.src.image.imageType, // VkImageType imageType;
2141 m_params.src.image.format, // VkFormat format;
2142 getExtent3D(m_params.src.image), // VkExtent3D extent;
2143 1u, // deUint32 mipLevels;
2144 getArraySize(m_params.src.image), // deUint32 arrayLayers;
2145 rasterizationSamples, // VkSampleCountFlagBits samples;
2146 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
2147 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, // VkImageUsageFlags usage;
2148 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
2149 1u, // deUint32 queueFamilyIndexCount;
2150 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
2151 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
2154 m_multisampledImage = createImage(vk, vkDevice, &colorImageParams);
2156 // Allocate and bind color image memory.
2157 m_multisampledImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_multisampledImage), MemoryRequirement::Any);
2158 VK_CHECK(vk.bindImageMemory(vkDevice, *m_multisampledImage, m_multisampledImageAlloc->getMemory(), m_multisampledImageAlloc->getOffset()));
2162 case COPY_MS_IMAGE_TO_MS_IMAGE:
2164 colorImageParams.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
2165 m_multisampledCopyImage = createImage(vk, vkDevice, &colorImageParams);
2166 // Allocate and bind color image memory.
2167 m_multisampledCopyImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_multisampledCopyImage), MemoryRequirement::Any);
2168 VK_CHECK(vk.bindImageMemory(vkDevice, *m_multisampledCopyImage, m_multisampledCopyImageAlloc->getMemory(), m_multisampledCopyImageAlloc->getOffset()));
2172 case COPY_MS_IMAGE_TO_ARRAY_MS_IMAGE:
2174 colorImageParams.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
2175 colorImageParams.arrayLayers = getArraySize(m_params.dst.image);
2176 m_multisampledCopyImage = createImage(vk, vkDevice, &colorImageParams);
2177 // Allocate and bind color image memory.
2178 m_multisampledCopyImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_multisampledCopyImage), MemoryRequirement::Any);
2179 VK_CHECK(vk.bindImageMemory(vkDevice, *m_multisampledCopyImage, m_multisampledCopyImageAlloc->getMemory(), m_multisampledCopyImageAlloc->getOffset()));
2188 // Create destination image.
2190 const VkImageCreateInfo destinationImageParams =
2192 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
2193 DE_NULL, // const void* pNext;
2194 0u, // VkImageCreateFlags flags;
2195 m_params.dst.image.imageType, // VkImageType imageType;
2196 m_params.dst.image.format, // VkFormat format;
2197 getExtent3D(m_params.dst.image), // VkExtent3D extent;
2198 1u, // deUint32 mipLevels;
2199 getArraySize(m_params.dst.image), // deUint32 arraySize;
2200 VK_SAMPLE_COUNT_1_BIT, // deUint32 samples;
2201 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
2202 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
2203 VK_IMAGE_USAGE_TRANSFER_DST_BIT, // VkImageUsageFlags usage;
2204 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
2205 1u, // deUint32 queueFamilyCount;
2206 &queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
2207 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
2210 m_destination = createImage(vk, vkDevice, &destinationImageParams);
2211 m_destinationImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_destination), MemoryRequirement::Any);
2212 VK_CHECK(vk.bindImageMemory(vkDevice, *m_destination, m_destinationImageAlloc->getMemory(), m_destinationImageAlloc->getOffset()));
2215 // Barriers for copying image to buffer
2216 VkImageMemoryBarrier srcImageBarrier =
2218 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
2219 DE_NULL, // const void* pNext;
2220 0u, // VkAccessFlags srcAccessMask;
2221 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags dstAccessMask;
2222 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
2223 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout newLayout;
2224 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
2225 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
2226 m_multisampledImage.get(), // VkImage image;
2227 { // VkImageSubresourceRange subresourceRange;
2228 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
2229 0u, // deUint32 baseMipLevel;
2230 1u, // deUint32 mipLevels;
2231 0u, // deUint32 baseArraySlice;
2232 getArraySize(m_params.src.image) // deUint32 arraySize;
2236 // Create render pass.
2238 const VkAttachmentDescription attachmentDescriptions[1] =
2241 0u, // VkAttachmentDescriptionFlags flags;
2242 m_params.src.image.format, // VkFormat format;
2243 rasterizationSamples, // VkSampleCountFlagBits samples;
2244 VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp;
2245 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
2246 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp;
2247 VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp;
2248 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout;
2249 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout;
2253 const VkAttachmentReference colorAttachmentReference =
2255 0u, // deUint32 attachment;
2256 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout layout;
2259 const VkSubpassDescription subpassDescription =
2261 0u, // VkSubpassDescriptionFlags flags;
2262 VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint;
2263 0u, // deUint32 inputAttachmentCount;
2264 DE_NULL, // const VkAttachmentReference* pInputAttachments;
2265 1u, // deUint32 colorAttachmentCount;
2266 &colorAttachmentReference, // const VkAttachmentReference* pColorAttachments;
2267 DE_NULL, // const VkAttachmentReference* pResolveAttachments;
2268 DE_NULL, // const VkAttachmentReference* pDepthStencilAttachment;
2269 0u, // deUint32 preserveAttachmentCount;
2270 DE_NULL // const VkAttachmentReference* pPreserveAttachments;
2273 const VkRenderPassCreateInfo renderPassParams =
2275 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType;
2276 DE_NULL, // const void* pNext;
2277 0u, // VkRenderPassCreateFlags flags;
2278 1u, // deUint32 attachmentCount;
2279 attachmentDescriptions, // const VkAttachmentDescription* pAttachments;
2280 1u, // deUint32 subpassCount;
2281 &subpassDescription, // const VkSubpassDescription* pSubpasses;
2282 0u, // deUint32 dependencyCount;
2283 DE_NULL // const VkSubpassDependency* pDependencies;
2286 renderPass = createRenderPass(vk, vkDevice, &renderPassParams);
2289 // Create pipeline layout
2291 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
2293 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // VkStructureType sType;
2294 DE_NULL, // const void* pNext;
2295 0u, // VkPipelineLayoutCreateFlags flags;
2296 0u, // deUint32 setLayoutCount;
2297 DE_NULL, // const VkDescriptorSetLayout* pSetLayouts;
2298 0u, // deUint32 pushConstantRangeCount;
2299 DE_NULL // const VkPushConstantRange* pPushConstantRanges;
2302 pipelineLayout = createPipelineLayout(vk, vkDevice, &pipelineLayoutParams);
2306 const tcu::Vec4 a (-1.0, -1.0, 0.0, 1.0);
2307 const tcu::Vec4 b (1.0, -1.0, 0.0, 1.0);
2308 const tcu::Vec4 c (1.0, 1.0, 0.0, 1.0);
2310 vertices.push_back(a);
2311 vertices.push_back(c);
2312 vertices.push_back(b);
2315 // Create vertex buffer.
2317 const VkDeviceSize vertexDataSize = vertices.size() * sizeof(tcu::Vec4);
2318 const VkBufferCreateInfo vertexBufferParams =
2320 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
2321 DE_NULL, // const void* pNext;
2322 0u, // VkBufferCreateFlags flags;
2323 vertexDataSize, // VkDeviceSize size;
2324 VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, // VkBufferUsageFlags usage;
2325 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
2326 1u, // deUint32 queueFamilyIndexCount;
2327 &queueFamilyIndex // const deUint32* pQueueFamilyIndices;
2330 vertexBuffer = createBuffer(vk, vkDevice, &vertexBufferParams);
2331 vertexBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *vertexBuffer), MemoryRequirement::HostVisible);
2333 VK_CHECK(vk.bindBufferMemory(vkDevice, *vertexBuffer, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset()));
2335 // Load vertices into vertex buffer.
2336 deMemcpy(vertexBufferAlloc->getHostPtr(), vertices.data(), (size_t)vertexDataSize);
2337 flushMappedMemoryRange(vk, vkDevice, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset(), vertexDataSize);
2341 Move<VkFramebuffer> framebuffer;
2342 Move<VkImageView> sourceAttachmentView;
2343 const VkExtent3D extent3D = getExtent3D(m_params.src.image);
2345 // Create color attachment view.
2347 const VkImageViewCreateInfo colorAttachmentViewParams =
2349 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // VkStructureType sType;
2350 DE_NULL, // const void* pNext;
2351 0u, // VkImageViewCreateFlags flags;
2352 *m_multisampledImage, // VkImage image;
2353 VK_IMAGE_VIEW_TYPE_2D, // VkImageViewType viewType;
2354 m_params.src.image.format, // VkFormat format;
2355 componentMappingRGBA, // VkComponentMapping components;
2356 { VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u } // VkImageSubresourceRange subresourceRange;
2358 sourceAttachmentView = createImageView(vk, vkDevice, &colorAttachmentViewParams);
2361 // Create framebuffer
2363 const VkImageView attachments[1] =
2365 *sourceAttachmentView,
2368 const VkFramebufferCreateInfo framebufferParams =
2370 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType;
2371 DE_NULL, // const void* pNext;
2372 0u, // VkFramebufferCreateFlags flags;
2373 *renderPass, // VkRenderPass renderPass;
2374 1u, // deUint32 attachmentCount;
2375 attachments, // const VkImageView* pAttachments;
2376 extent3D.width, // deUint32 width;
2377 extent3D.height, // deUint32 height;
2378 1u // deUint32 layers;
2381 framebuffer = createFramebuffer(vk, vkDevice, &framebufferParams);
2386 const VkPipelineShaderStageCreateInfo shaderStageParams[2] =
2389 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
2390 DE_NULL, // const void* pNext;
2391 0u, // VkPipelineShaderStageCreateFlags flags;
2392 VK_SHADER_STAGE_VERTEX_BIT, // VkShaderStageFlagBits stage;
2393 *vertexShaderModule, // VkShaderModule module;
2394 "main", // const char* pName;
2395 DE_NULL // const VkSpecializationInfo* pSpecializationInfo;
2398 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
2399 DE_NULL, // const void* pNext;
2400 0u, // VkPipelineShaderStageCreateFlags flags;
2401 VK_SHADER_STAGE_FRAGMENT_BIT, // VkShaderStageFlagBits stage;
2402 *fragmentShaderModule, // VkShaderModule module;
2403 "main", // const char* pName;
2404 DE_NULL // const VkSpecializationInfo* pSpecializationInfo;
2408 const VkVertexInputBindingDescription vertexInputBindingDescription =
2410 0u, // deUint32 binding;
2411 sizeof(tcu::Vec4), // deUint32 stride;
2412 VK_VERTEX_INPUT_RATE_VERTEX // VkVertexInputRate inputRate;
2415 const VkVertexInputAttributeDescription vertexInputAttributeDescriptions[1] =
2418 0u, // deUint32 location;
2419 0u, // deUint32 binding;
2420 VK_FORMAT_R32G32B32A32_SFLOAT, // VkFormat format;
2421 0u // deUint32 offset;
2425 const VkPipelineVertexInputStateCreateInfo vertexInputStateParams =
2427 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // VkStructureType sType;
2428 DE_NULL, // const void* pNext;
2429 0u, // VkPipelineVertexInputStateCreateFlags flags;
2430 1u, // deUint32 vertexBindingDescriptionCount;
2431 &vertexInputBindingDescription, // const VkVertexInputBindingDescription* pVertexBindingDescriptions;
2432 1u, // deUint32 vertexAttributeDescriptionCount;
2433 vertexInputAttributeDescriptions // const VkVertexInputAttributeDescription* pVertexAttributeDescriptions;
2436 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateParams =
2438 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // VkStructureType sType;
2439 DE_NULL, // const void* pNext;
2440 0u, // VkPipelineInputAssemblyStateCreateFlags flags;
2441 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, // VkPrimitiveTopology topology;
2442 false // VkBool32 primitiveRestartEnable;
2445 const VkViewport viewport =
2449 (float)extent3D.width, // float width;
2450 (float)extent3D.height, // float height;
2451 0.0f, // float minDepth;
2452 1.0f // float maxDepth;
2455 const VkRect2D scissor =
2457 { 0, 0 }, // VkOffset2D offset;
2458 { extent3D.width, extent3D.height } // VkExtent2D extent;
2461 const VkPipelineViewportStateCreateInfo viewportStateParams =
2463 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // VkStructureType sType;
2464 DE_NULL, // const void* pNext;
2465 0u, // VkPipelineViewportStateCreateFlags flags;
2466 1u, // deUint32 viewportCount;
2467 &viewport, // const VkViewport* pViewports;
2468 1u, // deUint32 scissorCount;
2469 &scissor // const VkRect2D* pScissors;
2472 const VkPipelineRasterizationStateCreateInfo rasterStateParams =
2474 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // VkStructureType sType;
2475 DE_NULL, // const void* pNext;
2476 0u, // VkPipelineRasterizationStateCreateFlags flags;
2477 false, // VkBool32 depthClampEnable;
2478 false, // VkBool32 rasterizerDiscardEnable;
2479 VK_POLYGON_MODE_FILL, // VkPolygonMode polygonMode;
2480 VK_CULL_MODE_NONE, // VkCullModeFlags cullMode;
2481 VK_FRONT_FACE_COUNTER_CLOCKWISE, // VkFrontFace frontFace;
2482 VK_FALSE, // VkBool32 depthBiasEnable;
2483 0.0f, // float depthBiasConstantFactor;
2484 0.0f, // float depthBiasClamp;
2485 0.0f, // float depthBiasSlopeFactor;
2486 1.0f // float lineWidth;
2489 const VkPipelineMultisampleStateCreateInfo multisampleStateParams =
2491 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // VkStructureType sType;
2492 DE_NULL, // const void* pNext;
2493 0u, // VkPipelineMultisampleStateCreateFlags flags;
2494 rasterizationSamples, // VkSampleCountFlagBits rasterizationSamples;
2495 VK_FALSE, // VkBool32 sampleShadingEnable;
2496 0.0f, // float minSampleShading;
2497 DE_NULL, // const VkSampleMask* pSampleMask;
2498 VK_FALSE, // VkBool32 alphaToCoverageEnable;
2499 VK_FALSE // VkBool32 alphaToOneEnable;
2502 const VkPipelineColorBlendAttachmentState colorBlendAttachmentState =
2504 false, // VkBool32 blendEnable;
2505 VK_BLEND_FACTOR_ONE, // VkBlend srcBlendColor;
2506 VK_BLEND_FACTOR_ZERO, // VkBlend destBlendColor;
2507 VK_BLEND_OP_ADD, // VkBlendOp blendOpColor;
2508 VK_BLEND_FACTOR_ONE, // VkBlend srcBlendAlpha;
2509 VK_BLEND_FACTOR_ZERO, // VkBlend destBlendAlpha;
2510 VK_BLEND_OP_ADD, // VkBlendOp blendOpAlpha;
2511 (VK_COLOR_COMPONENT_R_BIT |
2512 VK_COLOR_COMPONENT_G_BIT |
2513 VK_COLOR_COMPONENT_B_BIT |
2514 VK_COLOR_COMPONENT_A_BIT) // VkChannelFlags channelWriteMask;
2517 const VkPipelineColorBlendStateCreateInfo colorBlendStateParams =
2519 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // VkStructureType sType;
2520 DE_NULL, // const void* pNext;
2521 0u, // VkPipelineColorBlendStateCreateFlags flags;
2522 false, // VkBool32 logicOpEnable;
2523 VK_LOGIC_OP_COPY, // VkLogicOp logicOp;
2524 1u, // deUint32 attachmentCount;
2525 &colorBlendAttachmentState, // const VkPipelineColorBlendAttachmentState* pAttachments;
2526 { 0.0f, 0.0f, 0.0f, 0.0f } // float blendConstants[4];
2529 const VkGraphicsPipelineCreateInfo graphicsPipelineParams =
2531 VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // VkStructureType sType;
2532 DE_NULL, // const void* pNext;
2533 0u, // VkPipelineCreateFlags flags;
2534 2u, // deUint32 stageCount;
2535 shaderStageParams, // const VkPipelineShaderStageCreateInfo* pStages;
2536 &vertexInputStateParams, // const VkPipelineVertexInputStateCreateInfo* pVertexInputState;
2537 &inputAssemblyStateParams, // const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState;
2538 DE_NULL, // const VkPipelineTessellationStateCreateInfo* pTessellationState;
2539 &viewportStateParams, // const VkPipelineViewportStateCreateInfo* pViewportState;
2540 &rasterStateParams, // const VkPipelineRasterizationStateCreateInfo* pRasterizationState;
2541 &multisampleStateParams, // const VkPipelineMultisampleStateCreateInfo* pMultisampleState;
2542 DE_NULL, // const VkPipelineDepthStencilStateCreateInfo* pDepthStencilState;
2543 &colorBlendStateParams, // const VkPipelineColorBlendStateCreateInfo* pColorBlendState;
2544 DE_NULL, // const VkPipelineDynamicStateCreateInfo* pDynamicState;
2545 *pipelineLayout, // VkPipelineLayout layout;
2546 *renderPass, // VkRenderPass renderPass;
2547 0u, // deUint32 subpass;
2548 0u, // VkPipeline basePipelineHandle;
2549 0u // deInt32 basePipelineIndex;
2552 graphicsPipeline = createGraphicsPipeline(vk, vkDevice, DE_NULL, &graphicsPipelineParams);
2555 // Create command buffer
2557 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
2559 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
2560 DE_NULL, // const void* pNext;
2561 0u, // VkCommandBufferUsageFlags flags;
2562 (const VkCommandBufferInheritanceInfo*)DE_NULL,
2565 const VkClearValue clearValues[1] =
2567 makeClearValueColorF32(0.0f, 0.0f, 1.0f, 1.0f),
2570 const VkRenderPassBeginInfo renderPassBeginInfo =
2572 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // VkStructureType sType;
2573 DE_NULL, // const void* pNext;
2574 *renderPass, // VkRenderPass renderPass;
2575 *framebuffer, // VkFramebuffer framebuffer;
2578 { extent3D.width, extent3D.height }
2579 }, // VkRect2D renderArea;
2580 1u, // deUint32 clearValueCount;
2581 clearValues // const VkClearValue* pClearValues;
2584 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
2585 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);
2586 vk.cmdBeginRenderPass(*m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
2587 const VkDeviceSize vertexBufferOffset = 0u;
2589 vk.cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *graphicsPipeline);
2590 vk.cmdBindVertexBuffers(*m_cmdBuffer, 0, 1, &vertexBuffer.get(), &vertexBufferOffset);
2591 vk.cmdDraw(*m_cmdBuffer, (deUint32)vertices.size(), 1, 0, 0);
2593 vk.cmdEndRenderPass(*m_cmdBuffer);
2594 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
2599 const VkQueue queue = m_context.getUniversalQueue();
2600 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
2605 tcu::TestStatus ResolveImageToImage::iterate (void)
2607 const tcu::TextureFormat srcTcuFormat = mapVkFormat(m_params.src.image.format);
2608 const tcu::TextureFormat dstTcuFormat = mapVkFormat(m_params.dst.image.format);
2610 // upload the destination image
2611 m_destinationTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(dstTcuFormat,
2612 (int)m_params.dst.image.extent.width,
2613 (int)m_params.dst.image.extent.height,
2614 (int)m_params.dst.image.extent.depth));
2615 generateBuffer(m_destinationTextureLevel->getAccess(), m_params.dst.image.extent.width, m_params.dst.image.extent.height, m_params.dst.image.extent.depth);
2616 uploadImage(m_destinationTextureLevel->getAccess(), m_destination.get(), m_params.dst.image);
2618 m_sourceTextureLevel = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(srcTcuFormat,
2619 (int)m_params.src.image.extent.width,
2620 (int)m_params.src.image.extent.height,
2621 (int)m_params.dst.image.extent.depth));
2623 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);
2624 generateExpectedResult();
2628 case COPY_MS_IMAGE_TO_MS_IMAGE:
2629 case COPY_MS_IMAGE_TO_ARRAY_MS_IMAGE:
2630 copyMSImageToMSImage();
2636 const DeviceInterface& vk = m_context.getDeviceInterface();
2637 const VkDevice vkDevice = m_context.getDevice();
2638 const VkQueue queue = m_context.getUniversalQueue();
2639 SimpleAllocator memAlloc (vk, vkDevice, getPhysicalDeviceMemoryProperties(m_context.getInstanceInterface(), m_context.getPhysicalDevice()));
2641 std::vector<VkImageResolve> imageResolves;
2642 for (deUint32 i = 0; i < m_params.regions.size(); i++)
2643 imageResolves.push_back(m_params.regions[i].imageResolve);
2645 const VkImageMemoryBarrier imageBarriers[] =
2649 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
2650 DE_NULL, // const void* pNext;
2651 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags srcAccessMask;
2652 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
2653 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout;
2654 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // VkImageLayout newLayout;
2655 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
2656 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
2657 m_multisampledImage.get(), // VkImage image;
2658 { // VkImageSubresourceRange subresourceRange;
2659 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
2660 0u, // deUint32 baseMipLevel;
2661 1u, // deUint32 mipLevels;
2662 0u, // deUint32 baseArraySlice;
2663 getArraySize(m_params.dst.image) // deUint32 arraySize;
2666 // destination image
2668 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
2669 DE_NULL, // const void* pNext;
2670 0u, // VkAccessFlags srcAccessMask;
2671 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
2672 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
2673 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
2674 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
2675 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
2676 m_destination.get(), // VkImage image;
2677 { // VkImageSubresourceRange subresourceRange;
2678 getAspectFlags(dstTcuFormat), // VkImageAspectFlags aspectMask;
2679 0u, // deUint32 baseMipLevel;
2680 1u, // deUint32 mipLevels;
2681 0u, // deUint32 baseArraySlice;
2682 getArraySize(m_params.dst.image) // deUint32 arraySize;
2687 const VkImageMemoryBarrier postImageBarrier =
2689 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
2690 DE_NULL, // const void* pNext;
2691 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
2692 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
2693 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
2694 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
2695 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
2696 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
2697 m_destination.get(), // VkImage image;
2698 { // VkImageSubresourceRange subresourceRange;
2699 getAspectFlags(dstTcuFormat), // VkImageAspectFlags aspectMask;
2700 0u, // deUint32 baseMipLevel;
2701 1u, // deUint32 mipLevels;
2702 0u, // deUint32 baseArraySlice;
2703 getArraySize(m_params.dst.image)// deUint32 arraySize;
2707 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
2709 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
2710 DE_NULL, // const void* pNext;
2711 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
2712 (const VkCommandBufferInheritanceInfo*)DE_NULL,
2715 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
2716 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);
2717 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());
2718 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);
2719 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
2721 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
2723 // check the result of resolving image
2725 de::MovePtr<tcu::TextureLevel> resultTextureLevel = readImage(vk, vkDevice, queue, memAlloc, *m_destination, m_params.dst.image);
2727 if (QP_TEST_RESULT_PASS != checkTestResult(resultTextureLevel->getAccess()).getCode())
2728 return tcu::TestStatus::fail("CopiesAndBlitting test");
2730 return tcu::TestStatus::pass("CopiesAndBlitting test");
2733 tcu::TestStatus ResolveImageToImage::checkTestResult (tcu::ConstPixelBufferAccess result)
2735 const tcu::ConstPixelBufferAccess expected = m_expectedTextureLevel->getAccess();
2736 const float fuzzyThreshold = 0.01f;
2738 for (int arrayLayerNdx = 0; arrayLayerNdx < (int)getArraySize(m_params.dst.image); ++arrayLayerNdx)
2740 const tcu::ConstPixelBufferAccess expectedSub = getSubregion (expected, 0, 0, arrayLayerNdx, expected.getWidth(), expected.getHeight(), 1u);
2741 const tcu::ConstPixelBufferAccess resultSub = getSubregion (result, 0, 0, arrayLayerNdx, result.getWidth(), result.getHeight(), 1u);
2742 if (!tcu::fuzzyCompare(m_context.getTestContext().getLog(), "Compare", "Result comparsion", expectedSub, resultSub, fuzzyThreshold, tcu::COMPARE_LOG_RESULT))
2743 return tcu::TestStatus::fail("CopiesAndBlitting test");
2746 return tcu::TestStatus::pass("CopiesAndBlitting test");
2749 void ResolveImageToImage::copyRegionToTextureLevel(tcu::ConstPixelBufferAccess src, tcu::PixelBufferAccess dst, CopyRegion region)
2751 VkOffset3D srcOffset = region.imageResolve.srcOffset;
2752 srcOffset.z = region.imageResolve.srcSubresource.baseArrayLayer;
2753 VkOffset3D dstOffset = region.imageResolve.dstOffset;
2754 dstOffset.z = region.imageResolve.dstSubresource.baseArrayLayer;
2755 VkExtent3D extent = region.imageResolve.extent;
2757 const tcu::ConstPixelBufferAccess srcSubRegion = getSubregion (src, srcOffset.x, srcOffset.y, srcOffset.z, extent.width, extent.height, extent.depth);
2758 // CopyImage acts like a memcpy. Replace the destination format with the srcformat to use a memcpy.
2759 const tcu::PixelBufferAccess dstWithSrcFormat (srcSubRegion.getFormat(), dst.getSize(), dst.getDataPtr());
2760 const tcu::PixelBufferAccess dstSubRegion = getSubregion (dstWithSrcFormat, dstOffset.x, dstOffset.y, dstOffset.z, extent.width, extent.height, extent.depth);
2762 tcu::copy(dstSubRegion, srcSubRegion);
2765 void ResolveImageToImage::copyMSImageToMSImage (void)
2767 const DeviceInterface& vk = m_context.getDeviceInterface();
2768 const VkDevice vkDevice = m_context.getDevice();
2769 const VkQueue queue = m_context.getUniversalQueue();
2770 const tcu::TextureFormat srcTcuFormat = mapVkFormat(m_params.src.image.format);
2771 std::vector<VkImageCopy> imageCopies;
2773 for (deUint32 layerNdx = 0; layerNdx < getArraySize(m_params.dst.image); ++layerNdx)
2775 const VkImageSubresourceLayers sourceSubresourceLayers =
2777 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
2778 0u, // uint32_t mipLevel;
2779 0u, // uint32_t baseArrayLayer;
2780 1u // uint32_t layerCount;
2783 const VkImageSubresourceLayers destinationSubresourceLayers =
2785 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;//getAspectFlags(dstTcuFormat)
2786 0u, // uint32_t mipLevel;
2787 layerNdx, // uint32_t baseArrayLayer;
2788 1u // uint32_t layerCount;
2791 const VkImageCopy imageCopy =
2793 sourceSubresourceLayers, // VkImageSubresourceLayers srcSubresource;
2794 {0, 0, 0}, // VkOffset3D srcOffset;
2795 destinationSubresourceLayers, // VkImageSubresourceLayers dstSubresource;
2796 {0, 0, 0}, // VkOffset3D dstOffset;
2797 getExtent3D(m_params.src.image), // VkExtent3D extent;
2799 imageCopies.push_back(imageCopy);
2802 const VkImageMemoryBarrier imageBarriers[] =
2806 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
2807 DE_NULL, // const void* pNext;
2808 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags srcAccessMask;
2809 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask;
2810 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout;
2811 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // VkImageLayout newLayout;
2812 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
2813 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
2814 m_multisampledImage.get(), // VkImage image;
2815 { // VkImageSubresourceRange subresourceRange;
2816 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
2817 0u, // deUint32 baseMipLevel;
2818 1u, // deUint32 mipLevels;
2819 0u, // deUint32 baseArraySlice;
2820 getArraySize(m_params.src.image) // deUint32 arraySize;
2823 // destination image
2825 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
2826 DE_NULL, // const void* pNext;
2827 0, // VkAccessFlags srcAccessMask;
2828 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask;
2829 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
2830 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout;
2831 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
2832 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
2833 m_multisampledCopyImage.get(), // VkImage image;
2834 { // VkImageSubresourceRange subresourceRange;
2835 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
2836 0u, // deUint32 baseMipLevel;
2837 1u, // deUint32 mipLevels;
2838 0u, // deUint32 baseArraySlice;
2839 getArraySize(m_params.dst.image) // deUint32 arraySize;
2844 const VkImageMemoryBarrier postImageBarriers =
2847 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
2848 DE_NULL, // const void* pNext;
2849 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
2850 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags dstAccessMask;
2851 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
2852 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout newLayout;
2853 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
2854 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
2855 m_multisampledCopyImage.get(), // VkImage image;
2856 { // VkImageSubresourceRange subresourceRange;
2857 getAspectFlags(srcTcuFormat), // VkImageAspectFlags aspectMask;
2858 0u, // deUint32 baseMipLevel;
2859 1u, // deUint32 mipLevels;
2860 0u, // deUint32 baseArraySlice;
2861 getArraySize(m_params.dst.image) // deUint32 arraySize;
2865 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
2867 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
2868 DE_NULL, // const void* pNext;
2869 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
2870 (const VkCommandBufferInheritanceInfo*)DE_NULL,
2873 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
2874 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);
2875 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());
2876 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);
2877 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
2879 submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
2881 m_multisampledImage = m_multisampledCopyImage;
2884 class ResolveImageToImageTestCase : public vkt::TestCase
2887 ResolveImageToImageTestCase (tcu::TestContext& testCtx,
2888 const std::string& name,
2889 const std::string& description,
2890 const TestParams params,
2891 const ResolveImageToImageOptions options = NO_OPTIONAL_OPERATION)
2892 : vkt::TestCase (testCtx, name, description)
2894 , m_options (options)
2896 virtual void initPrograms (SourceCollections& programCollection) const;
2898 virtual TestInstance* createInstance (Context& context) const
2900 return new ResolveImageToImage(context, m_params, m_options);
2903 TestParams m_params;
2904 const ResolveImageToImageOptions m_options;
2907 void ResolveImageToImageTestCase::initPrograms (SourceCollections& programCollection) const
2909 programCollection.glslSources.add("vert") << glu::VertexSource(
2911 "layout (location = 0) in highp vec4 a_position;\n"
2914 " gl_Position = a_position;\n"
2917 programCollection.glslSources.add("frag") << glu::FragmentSource(
2919 "layout (location = 0) out highp vec4 o_color;\n"
2922 " o_color = vec4(0.0, 1.0, 0.0, 1.0);\n"
2926 std::string getSampleCountCaseName (VkSampleCountFlagBits sampleFlag)
2928 return de::toLower(de::toString(getSampleCountFlagsStr(sampleFlag)).substr(16));
2931 std::string getFormatCaseName (VkFormat format)
2933 return de::toLower(de::toString(getFormatStr(format)).substr(10));
2936 void addCopyImageTestsAllFormats (tcu::TestCaseGroup* testCaseGroup,
2937 tcu::TestContext& testCtx,
2940 const VkFormat compatibleFormats8Bit[] =
2942 VK_FORMAT_R4G4_UNORM_PACK8,
2945 VK_FORMAT_R8_USCALED,
2946 VK_FORMAT_R8_SSCALED,
2953 const VkFormat compatibleFormats16Bit[] =
2955 VK_FORMAT_R4G4B4A4_UNORM_PACK16,
2956 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
2957 VK_FORMAT_R5G6B5_UNORM_PACK16,
2958 VK_FORMAT_B5G6R5_UNORM_PACK16,
2959 VK_FORMAT_R5G5B5A1_UNORM_PACK16,
2960 VK_FORMAT_B5G5R5A1_UNORM_PACK16,
2961 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
2962 VK_FORMAT_R8G8_UNORM,
2963 VK_FORMAT_R8G8_SNORM,
2964 VK_FORMAT_R8G8_USCALED,
2965 VK_FORMAT_R8G8_SSCALED,
2966 VK_FORMAT_R8G8_UINT,
2967 VK_FORMAT_R8G8_SINT,
2968 VK_FORMAT_R8G8_SRGB,
2969 VK_FORMAT_R16_UNORM,
2970 VK_FORMAT_R16_SNORM,
2971 VK_FORMAT_R16_USCALED,
2972 VK_FORMAT_R16_SSCALED,
2975 VK_FORMAT_R16_SFLOAT,
2979 const VkFormat compatibleFormats24Bit[] =
2981 VK_FORMAT_R8G8B8_UNORM,
2982 VK_FORMAT_R8G8B8_SNORM,
2983 VK_FORMAT_R8G8B8_USCALED,
2984 VK_FORMAT_R8G8B8_SSCALED,
2985 VK_FORMAT_R8G8B8_UINT,
2986 VK_FORMAT_R8G8B8_SINT,
2987 VK_FORMAT_R8G8B8_SRGB,
2988 VK_FORMAT_B8G8R8_UNORM,
2989 VK_FORMAT_B8G8R8_SNORM,
2990 VK_FORMAT_B8G8R8_USCALED,
2991 VK_FORMAT_B8G8R8_SSCALED,
2992 VK_FORMAT_B8G8R8_UINT,
2993 VK_FORMAT_B8G8R8_SINT,
2994 VK_FORMAT_B8G8R8_SRGB,
2998 const VkFormat compatibleFormats32Bit[] =
3000 VK_FORMAT_R8G8B8A8_UNORM,
3001 VK_FORMAT_R8G8B8A8_SNORM,
3002 VK_FORMAT_R8G8B8A8_USCALED,
3003 VK_FORMAT_R8G8B8A8_SSCALED,
3004 VK_FORMAT_R8G8B8A8_UINT,
3005 VK_FORMAT_R8G8B8A8_SINT,
3006 VK_FORMAT_R8G8B8A8_SRGB,
3007 VK_FORMAT_B8G8R8A8_UNORM,
3008 VK_FORMAT_B8G8R8A8_SNORM,
3009 VK_FORMAT_B8G8R8A8_USCALED,
3010 VK_FORMAT_B8G8R8A8_SSCALED,
3011 VK_FORMAT_B8G8R8A8_UINT,
3012 VK_FORMAT_B8G8R8A8_SINT,
3013 VK_FORMAT_B8G8R8A8_SRGB,
3014 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
3015 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
3016 VK_FORMAT_A8B8G8R8_USCALED_PACK32,
3017 VK_FORMAT_A8B8G8R8_SSCALED_PACK32,
3018 VK_FORMAT_A8B8G8R8_UINT_PACK32,
3019 VK_FORMAT_A8B8G8R8_SINT_PACK32,
3020 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
3021 VK_FORMAT_A2R10G10B10_UNORM_PACK32,
3022 VK_FORMAT_A2R10G10B10_SNORM_PACK32,
3023 VK_FORMAT_A2R10G10B10_USCALED_PACK32,
3024 VK_FORMAT_A2R10G10B10_SSCALED_PACK32,
3025 VK_FORMAT_A2R10G10B10_UINT_PACK32,
3026 VK_FORMAT_A2R10G10B10_SINT_PACK32,
3027 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
3028 VK_FORMAT_A2B10G10R10_SNORM_PACK32,
3029 VK_FORMAT_A2B10G10R10_USCALED_PACK32,
3030 VK_FORMAT_A2B10G10R10_SSCALED_PACK32,
3031 VK_FORMAT_A2B10G10R10_UINT_PACK32,
3032 VK_FORMAT_A2B10G10R10_SINT_PACK32,
3033 VK_FORMAT_R16G16_UNORM,
3034 VK_FORMAT_R16G16_SNORM,
3035 VK_FORMAT_R16G16_USCALED,
3036 VK_FORMAT_R16G16_SSCALED,
3037 VK_FORMAT_R16G16_UINT,
3038 VK_FORMAT_R16G16_SINT,
3039 VK_FORMAT_R16G16_SFLOAT,
3042 VK_FORMAT_R32_SFLOAT,
3046 const VkFormat compatibleFormats48Bit[] =
3048 VK_FORMAT_R16G16B16_UNORM,
3049 VK_FORMAT_R16G16B16_SNORM,
3050 VK_FORMAT_R16G16B16_USCALED,
3051 VK_FORMAT_R16G16B16_SSCALED,
3052 VK_FORMAT_R16G16B16_UINT,
3053 VK_FORMAT_R16G16B16_SINT,
3054 VK_FORMAT_R16G16B16_SFLOAT,
3058 const VkFormat compatibleFormats64Bit[] =
3060 VK_FORMAT_R16G16B16A16_UNORM,
3061 VK_FORMAT_R16G16B16A16_SNORM,
3062 VK_FORMAT_R16G16B16A16_USCALED,
3063 VK_FORMAT_R16G16B16A16_SSCALED,
3064 VK_FORMAT_R16G16B16A16_UINT,
3065 VK_FORMAT_R16G16B16A16_SINT,
3066 VK_FORMAT_R16G16B16A16_SFLOAT,
3067 VK_FORMAT_R32G32_UINT,
3068 VK_FORMAT_R32G32_SINT,
3069 VK_FORMAT_R32G32_SFLOAT,
3072 VK_FORMAT_R64_SFLOAT,
3076 const VkFormat compatibleFormats96Bit[] =
3078 VK_FORMAT_R32G32B32_UINT,
3079 VK_FORMAT_R32G32B32_SINT,
3080 VK_FORMAT_R32G32B32_SFLOAT,
3084 const VkFormat compatibleFormats128Bit[] =
3086 VK_FORMAT_R32G32B32A32_UINT,
3087 VK_FORMAT_R32G32B32A32_SINT,
3088 VK_FORMAT_R32G32B32A32_SFLOAT,
3089 VK_FORMAT_R64G64_UINT,
3090 VK_FORMAT_R64G64_SINT,
3091 VK_FORMAT_R64G64_SFLOAT,
3095 const VkFormat compatibleFormats192Bit[] =
3097 VK_FORMAT_R64G64B64_UINT,
3098 VK_FORMAT_R64G64B64_SINT,
3099 VK_FORMAT_R64G64B64_SFLOAT,
3103 const VkFormat compatibleFormats256Bit[] =
3105 VK_FORMAT_R64G64B64A64_UINT,
3106 VK_FORMAT_R64G64B64A64_SINT,
3107 VK_FORMAT_R64G64B64A64_SFLOAT,
3112 const VkFormat* colorImageFormatsToTest[] =
3114 compatibleFormats8Bit,
3115 compatibleFormats16Bit,
3116 compatibleFormats24Bit,
3117 compatibleFormats32Bit,
3118 compatibleFormats48Bit,
3119 compatibleFormats64Bit,
3120 compatibleFormats96Bit,
3121 compatibleFormats128Bit,
3122 compatibleFormats192Bit,
3123 compatibleFormats256Bit,
3125 const size_t numOfColorImageFormatsToTest = DE_LENGTH_OF_ARRAY(colorImageFormatsToTest);
3127 for (size_t compatibleFormatsIndex = 0; compatibleFormatsIndex < numOfColorImageFormatsToTest; ++compatibleFormatsIndex)
3129 const VkFormat* compatibleFormats = colorImageFormatsToTest[compatibleFormatsIndex];
3130 for (size_t srcFormatIndex = 0; compatibleFormats[srcFormatIndex] != VK_FORMAT_UNDEFINED; ++srcFormatIndex)
3132 params.src.image.format = compatibleFormats[srcFormatIndex];
3133 for (size_t dstFormatIndex = 0; compatibleFormats[dstFormatIndex] != VK_FORMAT_UNDEFINED; ++dstFormatIndex)
3135 params.dst.image.format = compatibleFormats[dstFormatIndex];
3136 std::ostringstream testName;
3137 testName << getFormatCaseName(params.src.image.format) << "_" << getFormatCaseName(params.dst.image.format);
3138 std::ostringstream description;
3139 description << "Copy from src " << params.src.image.format << " to dst " << params.dst.image.format;
3141 testCaseGroup->addChild(new CopyImageToImageTestCase(testCtx, testName.str(), description.str(), params));
3147 void addBlittingTestsAllFormats (tcu::TestCaseGroup* testCaseGroup,
3148 tcu::TestContext& testCtx,
3151 // Test Image formats.
3152 const VkFormat compatibleFormatsUInts[] =
3155 VK_FORMAT_R8G8_UINT,
3156 VK_FORMAT_R8G8B8_UINT,
3157 VK_FORMAT_B8G8R8_UINT,
3158 VK_FORMAT_R8G8B8A8_UINT,
3159 VK_FORMAT_B8G8R8A8_UINT,
3160 VK_FORMAT_A8B8G8R8_UINT_PACK32,
3161 VK_FORMAT_A2R10G10B10_UINT_PACK32,
3162 VK_FORMAT_A2B10G10R10_UINT_PACK32,
3164 VK_FORMAT_R16G16_UINT,
3165 VK_FORMAT_R16G16B16_UINT,
3166 VK_FORMAT_R16G16B16A16_UINT,
3168 VK_FORMAT_R32G32_UINT,
3169 VK_FORMAT_R32G32B32_UINT,
3170 VK_FORMAT_R32G32B32A32_UINT,
3172 VK_FORMAT_R64G64_UINT,
3173 VK_FORMAT_R64G64B64_UINT,
3174 VK_FORMAT_R64G64B64A64_UINT,
3178 const VkFormat compatibleFormatsSInts[] =
3181 VK_FORMAT_R8G8_SINT,
3182 VK_FORMAT_R8G8B8_SINT,
3183 VK_FORMAT_B8G8R8_SINT,
3184 VK_FORMAT_R8G8B8A8_SINT,
3185 VK_FORMAT_B8G8R8A8_SINT,
3186 VK_FORMAT_A8B8G8R8_SINT_PACK32,
3187 VK_FORMAT_A2R10G10B10_SINT_PACK32,
3188 VK_FORMAT_A2B10G10R10_SINT_PACK32,
3190 VK_FORMAT_R16G16_SINT,
3191 VK_FORMAT_R16G16B16_SINT,
3192 VK_FORMAT_R16G16B16A16_SINT,
3194 VK_FORMAT_R32G32_SINT,
3195 VK_FORMAT_R32G32B32_SINT,
3196 VK_FORMAT_R32G32B32A32_SINT,
3198 VK_FORMAT_R64G64_SINT,
3199 VK_FORMAT_R64G64B64_SINT,
3200 VK_FORMAT_R64G64B64A64_SINT,
3204 const VkFormat compatibleFormatsFloats[] =
3206 VK_FORMAT_R4G4_UNORM_PACK8,
3207 VK_FORMAT_R4G4B4A4_UNORM_PACK16,
3208 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
3209 VK_FORMAT_R5G6B5_UNORM_PACK16,
3210 VK_FORMAT_B5G6R5_UNORM_PACK16,
3211 VK_FORMAT_R5G5B5A1_UNORM_PACK16,
3212 VK_FORMAT_B5G5R5A1_UNORM_PACK16,
3213 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
3216 VK_FORMAT_R8_USCALED,
3217 VK_FORMAT_R8_SSCALED,
3218 VK_FORMAT_R8G8_UNORM,
3219 VK_FORMAT_R8G8_SNORM,
3220 VK_FORMAT_R8G8_USCALED,
3221 VK_FORMAT_R8G8_SSCALED,
3222 VK_FORMAT_R8G8B8_UNORM,
3223 VK_FORMAT_R8G8B8_SNORM,
3224 VK_FORMAT_R8G8B8_USCALED,
3225 VK_FORMAT_R8G8B8_SSCALED,
3226 VK_FORMAT_B8G8R8_UNORM,
3227 VK_FORMAT_B8G8R8_SNORM,
3228 VK_FORMAT_B8G8R8_USCALED,
3229 VK_FORMAT_B8G8R8_SSCALED,
3230 VK_FORMAT_R8G8B8A8_UNORM,
3231 VK_FORMAT_R8G8B8A8_SNORM,
3232 VK_FORMAT_R8G8B8A8_USCALED,
3233 VK_FORMAT_R8G8B8A8_SSCALED,
3234 VK_FORMAT_B8G8R8A8_UNORM,
3235 VK_FORMAT_B8G8R8A8_SNORM,
3236 VK_FORMAT_B8G8R8A8_USCALED,
3237 VK_FORMAT_B8G8R8A8_SSCALED,
3238 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
3239 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
3240 VK_FORMAT_A8B8G8R8_USCALED_PACK32,
3241 VK_FORMAT_A8B8G8R8_SSCALED_PACK32,
3242 VK_FORMAT_A2R10G10B10_UNORM_PACK32,
3243 VK_FORMAT_A2R10G10B10_SNORM_PACK32,
3244 VK_FORMAT_A2R10G10B10_USCALED_PACK32,
3245 VK_FORMAT_A2R10G10B10_SSCALED_PACK32,
3246 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
3247 VK_FORMAT_A2B10G10R10_SNORM_PACK32,
3248 VK_FORMAT_A2B10G10R10_USCALED_PACK32,
3249 VK_FORMAT_A2B10G10R10_SSCALED_PACK32,
3250 VK_FORMAT_R16_UNORM,
3251 VK_FORMAT_R16_SNORM,
3252 VK_FORMAT_R16_USCALED,
3253 VK_FORMAT_R16_SSCALED,
3254 VK_FORMAT_R16_SFLOAT,
3255 VK_FORMAT_R16G16_UNORM,
3256 VK_FORMAT_R16G16_SNORM,
3257 VK_FORMAT_R16G16_USCALED,
3258 VK_FORMAT_R16G16_SSCALED,
3259 VK_FORMAT_R16G16_SFLOAT,
3260 VK_FORMAT_R16G16B16_UNORM,
3261 VK_FORMAT_R16G16B16_SNORM,
3262 VK_FORMAT_R16G16B16_USCALED,
3263 VK_FORMAT_R16G16B16_SSCALED,
3264 VK_FORMAT_R16G16B16_SFLOAT,
3265 VK_FORMAT_R16G16B16A16_UNORM,
3266 VK_FORMAT_R16G16B16A16_SNORM,
3267 VK_FORMAT_R16G16B16A16_USCALED,
3268 VK_FORMAT_R16G16B16A16_SSCALED,
3269 VK_FORMAT_R16G16B16A16_SFLOAT,
3270 VK_FORMAT_R32_SFLOAT,
3271 VK_FORMAT_R32G32_SFLOAT,
3272 VK_FORMAT_R32G32B32_SFLOAT,
3273 VK_FORMAT_R32G32B32A32_SFLOAT,
3274 VK_FORMAT_R64_SFLOAT,
3275 VK_FORMAT_R64G64_SFLOAT,
3276 VK_FORMAT_R64G64B64_SFLOAT,
3277 VK_FORMAT_R64G64B64A64_SFLOAT,
3278 // VK_FORMAT_B10G11R11_UFLOAT_PACK32,
3279 // VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
3280 // VK_FORMAT_BC1_RGB_UNORM_BLOCK,
3281 // VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
3282 // VK_FORMAT_BC2_UNORM_BLOCK,
3283 // VK_FORMAT_BC3_UNORM_BLOCK,
3284 // VK_FORMAT_BC4_UNORM_BLOCK,
3285 // VK_FORMAT_BC4_SNORM_BLOCK,
3286 // VK_FORMAT_BC5_UNORM_BLOCK,
3287 // VK_FORMAT_BC5_SNORM_BLOCK,
3288 // VK_FORMAT_BC6H_UFLOAT_BLOCK,
3289 // VK_FORMAT_BC6H_SFLOAT_BLOCK,
3290 // VK_FORMAT_BC7_UNORM_BLOCK,
3291 // VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
3292 // VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,
3293 // VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,
3294 // VK_FORMAT_EAC_R11_UNORM_BLOCK,
3295 // VK_FORMAT_EAC_R11_SNORM_BLOCK,
3296 // VK_FORMAT_EAC_R11G11_UNORM_BLOCK,
3297 // VK_FORMAT_EAC_R11G11_SNORM_BLOCK,
3298 // VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
3299 // VK_FORMAT_ASTC_5x4_UNORM_BLOCK,
3300 // VK_FORMAT_ASTC_5x5_UNORM_BLOCK,
3301 // VK_FORMAT_ASTC_6x5_UNORM_BLOCK,
3302 // VK_FORMAT_ASTC_6x6_UNORM_BLOCK,
3303 // VK_FORMAT_ASTC_8x5_UNORM_BLOCK,
3304 // VK_FORMAT_ASTC_8x6_UNORM_BLOCK,
3305 // VK_FORMAT_ASTC_8x8_UNORM_BLOCK,
3306 // VK_FORMAT_ASTC_10x5_UNORM_BLOCK,
3307 // VK_FORMAT_ASTC_10x6_UNORM_BLOCK,
3308 // VK_FORMAT_ASTC_10x8_UNORM_BLOCK,
3309 // VK_FORMAT_ASTC_10x10_UNORM_BLOCK,
3310 // VK_FORMAT_ASTC_12x10_UNORM_BLOCK,
3311 // VK_FORMAT_ASTC_12x12_UNORM_BLOCK,
3315 const VkFormat compatibleFormatsSrgb[] =
3318 VK_FORMAT_R8G8_SRGB,
3319 VK_FORMAT_R8G8B8_SRGB,
3320 VK_FORMAT_B8G8R8_SRGB,
3321 VK_FORMAT_R8G8B8A8_SRGB,
3322 VK_FORMAT_B8G8R8A8_SRGB,
3323 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
3324 // VK_FORMAT_BC1_RGB_SRGB_BLOCK,
3325 // VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
3326 // VK_FORMAT_BC2_SRGB_BLOCK,
3327 // VK_FORMAT_BC3_SRGB_BLOCK,
3328 // VK_FORMAT_BC7_SRGB_BLOCK,
3329 // VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
3330 // VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
3331 // VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
3332 // VK_FORMAT_ASTC_4x4_SRGB_BLOCK,
3333 // VK_FORMAT_ASTC_5x4_SRGB_BLOCK,
3334 // VK_FORMAT_ASTC_5x5_SRGB_BLOCK,
3335 // VK_FORMAT_ASTC_6x5_SRGB_BLOCK,
3336 // VK_FORMAT_ASTC_6x6_SRGB_BLOCK,
3337 // VK_FORMAT_ASTC_8x5_SRGB_BLOCK,
3338 // VK_FORMAT_ASTC_8x6_SRGB_BLOCK,
3339 // VK_FORMAT_ASTC_8x8_SRGB_BLOCK,
3340 // VK_FORMAT_ASTC_10x5_SRGB_BLOCK,
3341 // VK_FORMAT_ASTC_10x6_SRGB_BLOCK,
3342 // VK_FORMAT_ASTC_10x8_SRGB_BLOCK,
3343 // VK_FORMAT_ASTC_10x10_SRGB_BLOCK,
3344 // VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
3345 // VK_FORMAT_ASTC_12x12_SRGB_BLOCK,
3351 const VkFormat* compatibleFormats;
3352 const bool onlyNearest;
3353 } colorImageFormatsToTest[] =
3355 { compatibleFormatsUInts, true },
3356 { compatibleFormatsSInts, true },
3357 { compatibleFormatsFloats, false },
3358 { compatibleFormatsSrgb, false },
3360 const size_t numOfColorImageFormatsToTest = DE_LENGTH_OF_ARRAY(colorImageFormatsToTest);
3362 for (size_t compatibleFormatsIndex = 0; compatibleFormatsIndex < numOfColorImageFormatsToTest; ++compatibleFormatsIndex)
3364 const VkFormat* compatibleFormats = colorImageFormatsToTest[compatibleFormatsIndex].compatibleFormats;
3365 const bool onlyNearest = colorImageFormatsToTest[compatibleFormatsIndex].onlyNearest;
3366 for (size_t srcFormatIndex = 0; compatibleFormats[srcFormatIndex] != VK_FORMAT_UNDEFINED; ++srcFormatIndex)
3368 params.src.image.format = compatibleFormats[srcFormatIndex];
3369 for (size_t dstFormatIndex = 0; compatibleFormats[dstFormatIndex] != VK_FORMAT_UNDEFINED; ++dstFormatIndex)
3371 params.dst.image.format = compatibleFormats[dstFormatIndex];
3372 std::ostringstream testName;
3373 testName << getFormatCaseName(params.src.image.format) << "_" << getFormatCaseName(params.dst.image.format);
3374 std::ostringstream description;
3375 description << "Blit image from src " << params.src.image.format << " to dst " << params.dst.image.format;
3377 params.filter = VK_FILTER_NEAREST;
3378 testCaseGroup->addChild(new BlittingTestCase(testCtx, testName.str() + "_nearest", description.str(), params));
3382 params.filter = VK_FILTER_LINEAR;
3383 testCaseGroup->addChild(new BlittingTestCase(testCtx, testName.str() + "_linear", description.str(), params));
3392 tcu::TestCaseGroup* createCopiesAndBlittingTests (tcu::TestContext& testCtx)
3394 de::MovePtr<tcu::TestCaseGroup> copiesAndBlittingTests (new tcu::TestCaseGroup(testCtx, "copy_and_blit", "Copies And Blitting Tests"));
3396 de::MovePtr<tcu::TestCaseGroup> imageToImageTests (new tcu::TestCaseGroup(testCtx, "image_to_image", "Copy from image to image"));
3397 de::MovePtr<tcu::TestCaseGroup> imgToImgSimpleTests (new tcu::TestCaseGroup(testCtx, "simple_tests", "Copy from image to image simple tests"));
3398 de::MovePtr<tcu::TestCaseGroup> imgToImgAllFormatsTests (new tcu::TestCaseGroup(testCtx, "all_formats", "Copy from image to image with all compatible formats"));
3400 de::MovePtr<tcu::TestCaseGroup> imageToBufferTests (new tcu::TestCaseGroup(testCtx, "image_to_buffer", "Copy from image to buffer"));
3401 de::MovePtr<tcu::TestCaseGroup> bufferToImageTests (new tcu::TestCaseGroup(testCtx, "buffer_to_image", "Copy from buffer to image"));
3402 de::MovePtr<tcu::TestCaseGroup> bufferToBufferTests (new tcu::TestCaseGroup(testCtx, "buffer_to_buffer", "Copy from buffer to buffer"));
3404 de::MovePtr<tcu::TestCaseGroup> blittingImageTests (new tcu::TestCaseGroup(testCtx, "blit_image", "Blitting image"));
3405 de::MovePtr<tcu::TestCaseGroup> blitImgSimpleTests (new tcu::TestCaseGroup(testCtx, "simple_tests", "Blitting image simple tests"));
3406 de::MovePtr<tcu::TestCaseGroup> blitImgAllFormatsTests (new tcu::TestCaseGroup(testCtx, "all_formats", "Blitting image with all compatible formats"));
3408 de::MovePtr<tcu::TestCaseGroup> resolveImageTests (new tcu::TestCaseGroup(testCtx, "resolve_image", "Resolve image"));
3410 const deInt32 defaultSize = 64;
3411 const deInt32 defaultHalfSize = defaultSize / 2;
3412 const deInt32 defaultFourthSize = defaultSize / 4;
3413 const VkExtent3D defaultExtent = {defaultSize, defaultSize, 1};
3414 const VkExtent3D defaultHalfExtent = {defaultHalfSize, defaultHalfSize, 1};
3416 const VkImageSubresourceLayers defaultSourceLayer =
3418 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
3419 0u, // uint32_t mipLevel;
3420 0u, // uint32_t baseArrayLayer;
3421 1u, // uint32_t layerCount;
3424 // Copy image to image testcases.
3427 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3428 params.src.image.format = VK_FORMAT_R8G8B8A8_UINT;
3429 params.src.image.extent = defaultExtent;
3430 params.dst.image.format = VK_FORMAT_R8G8B8A8_UINT;
3431 params.dst.image.extent = defaultExtent;
3434 const VkImageCopy testCopy =
3436 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
3437 {0, 0, 0}, // VkOffset3D srcOffset;
3438 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
3439 {0, 0, 0}, // VkOffset3D dstOffset;
3440 defaultExtent, // VkExtent3D extent;
3443 CopyRegion imageCopy;
3444 imageCopy.imageCopy = testCopy;
3446 params.regions.push_back(imageCopy);
3449 imgToImgSimpleTests->addChild(new CopyImageToImageTestCase(testCtx, "whole_image", "Whole image", params));
3454 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3455 params.src.image.format = VK_FORMAT_R8G8B8A8_UINT;
3456 params.src.image.extent = defaultExtent;
3457 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3458 params.dst.image.format = VK_FORMAT_R32_UINT;
3459 params.dst.image.extent = defaultExtent;
3462 const VkImageCopy testCopy =
3464 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
3465 {0, 0, 0}, // VkOffset3D srcOffset;
3466 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
3467 {0, 0, 0}, // VkOffset3D dstOffset;
3468 defaultExtent, // VkExtent3D extent;
3471 CopyRegion imageCopy;
3472 imageCopy.imageCopy = testCopy;
3474 params.regions.push_back(imageCopy);
3477 imgToImgSimpleTests->addChild(new CopyImageToImageTestCase(testCtx, "whole_image_diff_fromat", "Whole image with different format", params));
3482 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3483 params.src.image.format = VK_FORMAT_R8G8B8A8_UINT;
3484 params.src.image.extent = defaultExtent;
3485 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3486 params.dst.image.format = VK_FORMAT_R8G8B8A8_UINT;
3487 params.dst.image.extent = defaultExtent;
3490 const VkImageCopy testCopy =
3492 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
3493 {0, 0, 0}, // VkOffset3D srcOffset;
3494 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
3495 {defaultFourthSize, defaultFourthSize / 2, 0}, // VkOffset3D dstOffset;
3496 {defaultFourthSize / 2, defaultFourthSize / 2, 1}, // VkExtent3D extent;
3499 CopyRegion imageCopy;
3500 imageCopy.imageCopy = testCopy;
3502 params.regions.push_back(imageCopy);
3505 imgToImgSimpleTests->addChild(new CopyImageToImageTestCase(testCtx, "partial_image", "Partial image", params));
3510 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3511 params.src.image.format = VK_FORMAT_D32_SFLOAT;
3512 params.src.image.extent = defaultExtent;
3513 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3514 params.dst.image.format = VK_FORMAT_D32_SFLOAT;
3515 params.dst.image.extent = defaultExtent;
3518 const VkImageSubresourceLayers sourceLayer =
3520 VK_IMAGE_ASPECT_DEPTH_BIT, // VkImageAspectFlags aspectMask;
3521 0u, // uint32_t mipLevel;
3522 0u, // uint32_t baseArrayLayer;
3523 1u // uint32_t layerCount;
3525 const VkImageCopy testCopy =
3527 sourceLayer, // VkImageSubresourceLayers srcSubresource;
3528 {0, 0, 0}, // VkOffset3D srcOffset;
3529 sourceLayer, // VkImageSubresourceLayers dstSubresource;
3530 {defaultFourthSize, defaultFourthSize / 2, 0}, // VkOffset3D dstOffset;
3531 {defaultFourthSize / 2, defaultFourthSize / 2, 1}, // VkExtent3D extent;
3534 CopyRegion imageCopy;
3535 imageCopy.imageCopy = testCopy;
3537 params.regions.push_back(imageCopy);
3540 imgToImgSimpleTests->addChild(new CopyImageToImageTestCase(testCtx, "depth", "With depth", params));
3545 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3546 params.src.image.format = VK_FORMAT_S8_UINT;
3547 params.src.image.extent = defaultExtent;
3548 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3549 params.dst.image.format = VK_FORMAT_S8_UINT;
3550 params.dst.image.extent = defaultExtent;
3553 const VkImageSubresourceLayers sourceLayer =
3555 VK_IMAGE_ASPECT_STENCIL_BIT, // VkImageAspectFlags aspectMask;
3556 0u, // uint32_t mipLevel;
3557 0u, // uint32_t baseArrayLayer;
3558 1u // uint32_t layerCount;
3560 const VkImageCopy testCopy =
3562 sourceLayer, // VkImageSubresourceLayers srcSubresource;
3563 {0, 0, 0}, // VkOffset3D srcOffset;
3564 sourceLayer, // VkImageSubresourceLayers dstSubresource;
3565 {defaultFourthSize, defaultFourthSize / 2, 0}, // VkOffset3D dstOffset;
3566 {defaultFourthSize / 2, defaultFourthSize / 2, 1}, // VkExtent3D extent;
3569 CopyRegion imageCopy;
3570 imageCopy.imageCopy = testCopy;
3572 params.regions.push_back(imageCopy);
3575 imgToImgSimpleTests->addChild(new CopyImageToImageTestCase(testCtx, "stencil", "With stencil", params));
3580 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3581 params.src.image.extent = defaultExtent;
3582 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3583 params.dst.image.extent = defaultExtent;
3585 for (deInt32 i = 0; i < defaultSize; i += defaultFourthSize)
3587 const VkImageCopy testCopy =
3589 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
3590 {0, 0, 0}, // VkOffset3D srcOffset;
3591 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
3592 {i, defaultSize - i - defaultFourthSize, 0}, // VkOffset3D dstOffset;
3593 {defaultFourthSize, defaultFourthSize, 1}, // VkExtent3D extent;
3596 CopyRegion imageCopy;
3597 imageCopy.imageCopy = testCopy;
3599 params.regions.push_back(imageCopy);
3602 addCopyImageTestsAllFormats(imgToImgAllFormatsTests.get(), testCtx, params);
3604 imageToImageTests->addChild(imgToImgSimpleTests.release());
3605 imageToImageTests->addChild(imgToImgAllFormatsTests.release());
3607 // Copy image to buffer testcases.
3610 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3611 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
3612 params.src.image.extent = defaultExtent;
3613 params.dst.buffer.size = defaultSize * defaultSize;
3615 const VkBufferImageCopy bufferImageCopy =
3617 0u, // VkDeviceSize bufferOffset;
3618 0u, // uint32_t bufferRowLength;
3619 0u, // uint32_t bufferImageHeight;
3620 defaultSourceLayer, // VkImageSubresourceLayers imageSubresource;
3621 {0, 0, 0}, // VkOffset3D imageOffset;
3622 defaultExtent // VkExtent3D imageExtent;
3624 CopyRegion copyRegion;
3625 copyRegion.bufferImageCopy = bufferImageCopy;
3627 params.regions.push_back(copyRegion);
3629 imageToBufferTests->addChild(new CopyImageToBufferTestCase(testCtx, "whole", "Copy from image to buffer", params));
3634 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3635 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
3636 params.src.image.extent = defaultExtent;
3637 params.dst.buffer.size = defaultSize * defaultSize;
3639 const VkBufferImageCopy bufferImageCopy =
3641 defaultSize * defaultHalfSize, // VkDeviceSize bufferOffset;
3642 0u, // uint32_t bufferRowLength;
3643 0u, // uint32_t bufferImageHeight;
3644 defaultSourceLayer, // VkImageSubresourceLayers imageSubresource;
3645 {defaultFourthSize, defaultFourthSize, 0}, // VkOffset3D imageOffset;
3646 defaultHalfExtent // VkExtent3D imageExtent;
3648 CopyRegion copyRegion;
3649 copyRegion.bufferImageCopy = bufferImageCopy;
3651 params.regions.push_back(copyRegion);
3653 imageToBufferTests->addChild(new CopyImageToBufferTestCase(testCtx, "buffer_offset", "Copy from image to buffer with buffer offset", params));
3658 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3659 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
3660 params.src.image.extent = defaultExtent;
3661 params.dst.buffer.size = defaultSize * defaultSize;
3663 const int pixelSize = tcu::getPixelSize(mapVkFormat(params.src.image.format));
3664 const VkDeviceSize bufferSize = pixelSize * params.dst.buffer.size;
3665 const VkDeviceSize offsetSize = pixelSize * defaultFourthSize * defaultFourthSize;
3666 deUint32 divisor = 1;
3667 for (VkDeviceSize offset = 0; offset < bufferSize - offsetSize; offset += offsetSize, ++divisor)
3669 const deUint32 bufferRowLength = defaultFourthSize;
3670 const deUint32 bufferImageHeight = defaultFourthSize;
3671 const VkExtent3D imageExtent = {defaultFourthSize / divisor, defaultFourthSize, 1};
3672 DE_ASSERT(!bufferRowLength || bufferRowLength >= imageExtent.width);
3673 DE_ASSERT(!bufferImageHeight || bufferImageHeight >= imageExtent.height);
3674 DE_ASSERT(imageExtent.width * imageExtent.height *imageExtent.depth <= offsetSize);
3677 const VkBufferImageCopy bufferImageCopy =
3679 offset, // VkDeviceSize bufferOffset;
3680 bufferRowLength, // uint32_t bufferRowLength;
3681 bufferImageHeight, // uint32_t bufferImageHeight;
3682 defaultSourceLayer, // VkImageSubresourceLayers imageSubresource;
3683 {0, 0, 0}, // VkOffset3D imageOffset;
3684 imageExtent // VkExtent3D imageExtent;
3686 region.bufferImageCopy = bufferImageCopy;
3687 params.regions.push_back(region);
3690 imageToBufferTests->addChild(new CopyImageToBufferTestCase(testCtx, "regions", "Copy from image to buffer with multiple regions", params));
3693 // Copy buffer to image testcases.
3696 params.src.buffer.size = defaultSize * defaultSize;
3697 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3698 params.dst.image.format = VK_FORMAT_R8G8B8A8_UINT;
3699 params.dst.image.extent = defaultExtent;
3701 const VkBufferImageCopy bufferImageCopy =
3703 0u, // VkDeviceSize bufferOffset;
3704 0u, // uint32_t bufferRowLength;
3705 0u, // uint32_t bufferImageHeight;
3706 defaultSourceLayer, // VkImageSubresourceLayers imageSubresource;
3707 {0, 0, 0}, // VkOffset3D imageOffset;
3708 defaultExtent // VkExtent3D imageExtent;
3710 CopyRegion copyRegion;
3711 copyRegion.bufferImageCopy = bufferImageCopy;
3713 params.regions.push_back(copyRegion);
3715 bufferToImageTests->addChild(new CopyBufferToImageTestCase(testCtx, "whole", "Copy from buffer to image", params));
3720 params.src.buffer.size = defaultSize * defaultSize;
3721 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3722 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
3723 params.dst.image.extent = defaultExtent;
3726 deUint32 divisor = 1;
3727 for (int offset = 0; (offset + defaultFourthSize / divisor < defaultSize) && (defaultFourthSize > divisor); offset += defaultFourthSize / divisor++)
3729 const VkBufferImageCopy bufferImageCopy =
3731 0u, // VkDeviceSize bufferOffset;
3732 0u, // uint32_t bufferRowLength;
3733 0u, // uint32_t bufferImageHeight;
3734 defaultSourceLayer, // VkImageSubresourceLayers imageSubresource;
3735 {offset, defaultHalfSize, 0}, // VkOffset3D imageOffset;
3736 {defaultFourthSize / divisor, defaultFourthSize / divisor, 1} // VkExtent3D imageExtent;
3738 region.bufferImageCopy = bufferImageCopy;
3739 params.regions.push_back(region);
3742 bufferToImageTests->addChild(new CopyBufferToImageTestCase(testCtx, "regions", "Copy from buffer to image with multiple regions", params));
3747 params.src.buffer.size = defaultSize * defaultSize;
3748 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3749 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
3750 params.dst.image.extent = defaultExtent;
3752 const VkBufferImageCopy bufferImageCopy =
3754 defaultFourthSize, // VkDeviceSize bufferOffset;
3755 defaultHalfSize + defaultFourthSize, // uint32_t bufferRowLength;
3756 defaultHalfSize + defaultFourthSize, // uint32_t bufferImageHeight;
3757 defaultSourceLayer, // VkImageSubresourceLayers imageSubresource;
3758 {defaultFourthSize, defaultFourthSize, 0}, // VkOffset3D imageOffset;
3759 defaultHalfExtent // VkExtent3D imageExtent;
3761 CopyRegion copyRegion;
3762 copyRegion.bufferImageCopy = bufferImageCopy;
3764 params.regions.push_back(copyRegion);
3766 bufferToImageTests->addChild(new CopyBufferToImageTestCase(testCtx, "buffer_offset", "Copy from buffer to image with buffer offset", params));
3769 // Copy buffer to buffer testcases.
3772 params.src.buffer.size = defaultSize;
3773 params.dst.buffer.size = defaultSize;
3775 const VkBufferCopy bufferCopy =
3777 0u, // VkDeviceSize srcOffset;
3778 0u, // VkDeviceSize dstOffset;
3779 defaultSize, // VkDeviceSize size;
3782 CopyRegion copyRegion;
3783 copyRegion.bufferCopy = bufferCopy;
3784 params.regions.push_back(copyRegion);
3786 bufferToBufferTests->addChild(new BufferToBufferTestCase(testCtx, "whole", "Whole buffer", params));
3791 params.src.buffer.size = defaultFourthSize;
3792 params.dst.buffer.size = defaultFourthSize;
3794 const VkBufferCopy bufferCopy =
3796 12u, // VkDeviceSize srcOffset;
3797 4u, // VkDeviceSize dstOffset;
3798 1u, // VkDeviceSize size;
3801 CopyRegion copyRegion;
3802 copyRegion.bufferCopy = bufferCopy;
3803 params.regions.push_back(copyRegion);
3805 bufferToBufferTests->addChild(new BufferToBufferTestCase(testCtx, "partial", "Partial", params));
3809 const deUint32 size = 16;
3811 params.src.buffer.size = size;
3812 params.dst.buffer.size = size * (size + 1);
3814 // Copy region with size 1..size
3815 for (unsigned int i = 1; i <= size; i++)
3817 const VkBufferCopy bufferCopy =
3819 0, // VkDeviceSize srcOffset;
3820 i * size, // VkDeviceSize dstOffset;
3821 i, // VkDeviceSize size;
3824 CopyRegion copyRegion;
3825 copyRegion.bufferCopy = bufferCopy;
3826 params.regions.push_back(copyRegion);
3829 bufferToBufferTests->addChild(new BufferToBufferTestCase(testCtx, "regions", "Multiple regions", params));
3832 // Blitting testcases.
3834 const std::string description ("Blit without scaling (whole)");
3835 const std::string testName ("whole");
3838 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3839 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
3840 params.src.image.extent = defaultExtent;
3841 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3842 params.dst.image.extent = defaultExtent;
3845 const VkImageBlit imageBlit =
3847 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
3850 {defaultSize, defaultSize, 1}
3851 }, // VkOffset3D srcOffsets[2];
3853 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
3856 {defaultSize, defaultSize, 1}
3857 } // VkOffset3D dstOffset[2];
3861 region.imageBlit = imageBlit;
3862 params.regions.push_back(region);
3865 // Filter is VK_FILTER_NEAREST.
3867 params.filter = VK_FILTER_NEAREST;
3869 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
3870 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_nearest", description, params));
3872 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
3873 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
3874 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
3876 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
3877 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
3878 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
3881 // Filter is VK_FILTER_LINEAR.
3883 params.filter = VK_FILTER_LINEAR;
3885 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
3886 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_linear", description + " (VK_FILTER_LINEAR)", params));
3888 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
3889 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)" + " (VK_FILTER_LINEAR)");
3890 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
3892 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
3893 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)" + " (VK_FILTER_LINEAR)");
3894 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
3899 const std::string description ("Flipping x and y coordinates (whole)");
3900 const std::string testName ("mirror_xy");
3903 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3904 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
3905 params.src.image.extent = defaultExtent;
3906 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3907 params.dst.image.extent = defaultExtent;
3910 const VkImageBlit imageBlit =
3912 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
3915 {defaultSize, defaultSize, 1}
3916 }, // VkOffset3D srcOffsets[2];
3918 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
3920 {defaultSize, defaultSize, 1},
3922 } // VkOffset3D dstOffset[2];
3926 region.imageBlit = imageBlit;
3927 params.regions.push_back(region);
3930 // Filter is VK_FILTER_NEAREST.
3932 params.filter = VK_FILTER_NEAREST;
3934 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
3935 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_nearest", description, params));
3937 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
3938 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
3939 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
3941 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
3942 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
3943 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
3946 // Filter is VK_FILTER_LINEAR.
3948 params.filter = VK_FILTER_LINEAR;
3950 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
3951 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_linear", description + " (VK_FILTER_LINEAR)", params));
3953 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
3954 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)" + " (VK_FILTER_LINEAR)");
3955 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
3957 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
3958 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)" + " (VK_FILTER_LINEAR)");
3959 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
3964 const std::string description ("Flipping x coordinates (whole)");
3965 const std::string testName ("mirror_x");
3968 params.src.image.imageType = VK_IMAGE_TYPE_2D;
3969 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
3970 params.src.image.extent = defaultExtent;
3971 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
3972 params.dst.image.extent = defaultExtent;
3975 const VkImageBlit imageBlit =
3977 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
3980 {defaultSize, defaultSize, 1}
3981 }, // VkOffset3D srcOffsets[2];
3983 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
3985 {defaultSize, 0, 0},
3987 } // VkOffset3D dstOffset[2];
3991 region.imageBlit = imageBlit;
3992 params.regions.push_back(region);
3995 // Filter is VK_FILTER_NEAREST.
3997 params.filter = VK_FILTER_NEAREST;
3999 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4000 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_nearest", description, params));
4002 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4003 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4004 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4006 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4007 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4008 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4011 // Filter is VK_FILTER_LINEAR.
4013 params.filter = VK_FILTER_LINEAR;
4015 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4016 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_linear", description + " (VK_FILTER_LINEAR)", params));
4018 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4019 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)" + " (VK_FILTER_LINEAR)");
4020 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4022 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4023 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)" + " (VK_FILTER_LINEAR)");
4024 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4029 const std::string description ("Flipping Y coordinates (whole)");
4030 const std::string testName ("mirror_y");
4033 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4034 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4035 params.src.image.extent = defaultExtent;
4036 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4037 params.dst.image.extent = defaultExtent;
4040 const VkImageBlit imageBlit =
4042 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4045 {defaultSize, defaultSize, 1}
4046 }, // VkOffset3D srcOffsets[2];
4048 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4050 {0, defaultSize, 1},
4052 } // VkOffset3D dstOffset[2];
4056 region.imageBlit = imageBlit;
4057 params.regions.push_back(region);
4060 // Filter is VK_FILTER_NEAREST.
4062 params.filter = VK_FILTER_NEAREST;
4064 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4065 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_nearest", description, params));
4067 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4068 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4069 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4071 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4072 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4073 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4076 // Filter is VK_FILTER_LINEAR.
4078 params.filter = VK_FILTER_LINEAR;
4080 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4081 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_linear", description + " (VK_FILTER_LINEAR)", params));
4083 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4084 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)" + " (VK_FILTER_LINEAR)");
4085 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4087 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4088 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)" + " (VK_FILTER_LINEAR)");
4089 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4094 const std::string description ("Mirroring subregions in image (no flip ,y flip ,x flip, xy flip)");
4095 const std::string testName ("mirror_subregions");
4098 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4099 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4100 params.src.image.extent = defaultExtent;
4101 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4102 params.dst.image.extent = defaultExtent;
4106 const VkImageBlit imageBlit =
4108 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4111 {defaultHalfSize, defaultHalfSize, 1}
4112 }, // VkOffset3D srcOffsets[2];
4114 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4117 {defaultHalfSize, defaultHalfSize, 1}
4118 } // VkOffset3D dstOffset[2];
4122 region.imageBlit = imageBlit;
4123 params.regions.push_back(region);
4126 // Flipping y coordinates.
4128 const VkImageBlit imageBlit =
4130 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4132 {defaultHalfSize, 0, 0},
4133 {defaultSize, defaultHalfSize, 1}
4134 }, // VkOffset3D srcOffsets[2];
4136 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4138 {defaultHalfSize, defaultHalfSize, 0},
4140 } // VkOffset3D dstOffset[2];
4144 region.imageBlit = imageBlit;
4145 params.regions.push_back(region);
4148 // Flipping x coordinates.
4150 const VkImageBlit imageBlit =
4152 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4154 {0, defaultHalfSize, 0},
4155 {defaultHalfSize, defaultSize, 1}
4156 }, // VkOffset3D srcOffsets[2];
4158 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4160 {defaultHalfSize, defaultHalfSize, 0},
4162 } // VkOffset3D dstOffset[2];
4166 region.imageBlit = imageBlit;
4167 params.regions.push_back(region);
4170 // Flipping x and y coordinates.
4172 const VkImageBlit imageBlit =
4174 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4176 {defaultHalfSize, defaultHalfSize, 0},
4177 {defaultSize, defaultSize, 1}
4178 }, // VkOffset3D srcOffsets[2];
4180 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4182 {defaultSize, defaultSize, 0},
4183 {defaultHalfSize, defaultHalfSize, 1}
4184 } // VkOffset3D dstOffset[2];
4188 region.imageBlit = imageBlit;
4189 params.regions.push_back(region);
4192 // Filter is VK_FILTER_NEAREST.
4194 params.filter = VK_FILTER_NEAREST;
4196 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4197 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_nearest", description, params));
4199 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4200 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4201 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4203 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4204 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4205 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4208 // Filter is VK_FILTER_LINEAR.
4210 params.filter = VK_FILTER_LINEAR;
4212 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4213 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_linear", description + " (VK_FILTER_LINEAR)", params));
4215 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4216 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)" + " (VK_FILTER_LINEAR)");
4217 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4219 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4220 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)" + " (VK_FILTER_LINEAR)");
4221 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_" + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4226 const std::string description ("Blit with scaling (whole, src extent bigger)");
4227 const std::string testName ("scaling_whole1");
4230 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4231 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4232 params.src.image.extent = defaultExtent;
4233 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4234 params.dst.image.extent = defaultHalfExtent;
4237 const VkImageBlit imageBlit =
4239 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4242 {defaultSize, defaultSize, 1}
4243 }, // VkOffset3D srcOffsets[2];
4245 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4248 {defaultHalfSize, defaultHalfSize, 1}
4249 } // VkOffset3D dstOffset[2];
4253 region.imageBlit = imageBlit;
4254 params.regions.push_back(region);
4257 // Filter is VK_FILTER_NEAREST.
4259 params.filter = VK_FILTER_NEAREST;
4261 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4262 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_nearest", description, params));
4264 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4265 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4266 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4268 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4269 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4270 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4273 // Filter is VK_FILTER_LINEAR.
4275 params.filter = VK_FILTER_LINEAR;
4277 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4278 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_linear", description + " (VK_FILTER_LINEAR)", params));
4280 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4281 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)" + " (VK_FILTER_LINEAR)");
4282 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4284 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4285 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)" + " (VK_FILTER_LINEAR)");
4286 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4291 const std::string description ("Blit with scaling (whole, dst extent bigger)");
4292 const std::string testName ("scaling_whole2");
4295 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4296 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4297 params.src.image.extent = defaultHalfExtent;
4298 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4299 params.dst.image.extent = defaultExtent;
4302 const VkImageBlit imageBlit =
4304 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4307 {defaultHalfSize, defaultHalfSize, 1}
4308 }, // VkOffset3D srcOffsets[2];
4310 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4313 {defaultSize, defaultSize, 1}
4314 } // VkOffset3D dstOffset[2];
4318 region.imageBlit = imageBlit;
4319 params.regions.push_back(region);
4322 // Filter is VK_FILTER_NEAREST.
4324 params.filter = VK_FILTER_NEAREST;
4326 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4327 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_nearest", description, params));
4329 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4330 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4331 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4333 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4334 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4335 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4338 // Filter is VK_FILTER_LINEAR.
4340 params.filter = VK_FILTER_LINEAR;
4342 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4343 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_linear", description + " (VK_FILTER_LINEAR)", params));
4345 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4346 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)" + " (VK_FILTER_LINEAR)");
4347 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4349 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4350 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)" + " (VK_FILTER_LINEAR)");
4351 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4356 const std::string description ("Blit with scaling and offset (whole, dst extent bigger)");
4357 const std::string testName ("scaling_and_offset");
4360 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4361 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4362 params.src.image.extent = defaultExtent;
4363 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4364 params.dst.image.extent = defaultExtent;
4367 const VkImageBlit imageBlit =
4369 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4371 {defaultFourthSize, defaultFourthSize, 0},
4372 {defaultFourthSize*3, defaultFourthSize*3, 1}
4373 }, // VkOffset3D srcOffsets[2];
4375 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4378 {defaultSize, defaultSize, 1}
4379 } // VkOffset3D dstOffset[2];
4383 region.imageBlit = imageBlit;
4384 params.regions.push_back(region);
4387 // Filter is VK_FILTER_NEAREST.
4389 params.filter = VK_FILTER_NEAREST;
4391 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4392 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_nearest", description, params));
4394 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4395 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4396 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4398 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4399 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4400 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4403 // Filter is VK_FILTER_LINEAR.
4405 params.filter = VK_FILTER_LINEAR;
4407 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4408 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_linear", description + " (VK_FILTER_LINEAR)", params));
4410 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4411 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)" + " (VK_FILTER_LINEAR)");
4412 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4414 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4415 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)" + " (VK_FILTER_LINEAR)");
4416 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4421 const std::string description ("Blit without scaling (partial)");
4422 const std::string testName ("without_scaling_partial");
4425 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4426 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4427 params.src.image.extent = defaultExtent;
4428 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4429 params.dst.image.extent = defaultExtent;
4433 for (int i = 0; i < defaultSize; i += defaultFourthSize)
4435 const VkImageBlit imageBlit =
4437 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4439 {defaultSize - defaultFourthSize - i, defaultSize - defaultFourthSize - i, 0},
4440 {defaultSize - i, defaultSize - i, 1}
4441 }, // VkOffset3D srcOffsets[2];
4443 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4446 {i + defaultFourthSize, i + defaultFourthSize, 1}
4447 } // VkOffset3D dstOffset[2];
4449 region.imageBlit = imageBlit;
4450 params.regions.push_back(region);
4454 // Filter is VK_FILTER_NEAREST.
4456 params.filter = VK_FILTER_NEAREST;
4458 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4459 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_nearest", description, params));
4461 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4462 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)");
4463 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToR32, params));
4465 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4466 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)");
4467 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_nearest", descriptionOfRGBAToBGRA, params));
4470 // Filter is VK_FILTER_LINEAR.
4472 params.filter = VK_FILTER_LINEAR;
4474 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4475 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + "_linear", description + " (VK_FILTER_LINEAR)", params));
4477 params.dst.image.format = VK_FORMAT_R32_SFLOAT;
4478 const std::string descriptionOfRGBAToR32 (description + " and different formats (R8G8B8A8 -> R32)" + " (VK_FILTER_LINEAR)");
4479 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToR32, params));
4481 params.dst.image.format = VK_FORMAT_B8G8R8A8_UNORM;
4482 const std::string descriptionOfRGBAToBGRA (description + " and different formats (R8G8B8A8 -> B8G8R8A8)" + " (VK_FILTER_LINEAR)");
4483 blitImgSimpleTests->addChild(new BlittingTestCase(testCtx, testName + getFormatCaseName(params.dst.image.format) + "_linear", descriptionOfRGBAToBGRA, params));
4488 const std::string description ("Blit with scaling (partial)");
4489 const std::string testName ("scaling_partial");
4491 // Test Color formats.
4494 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4495 params.src.image.extent = defaultExtent;
4496 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4497 params.dst.image.extent = defaultExtent;
4500 for (int i = 0, j = 1; (i + defaultFourthSize / j < defaultSize) && (defaultFourthSize > j); i += defaultFourthSize / j++)
4502 const VkImageBlit imageBlit =
4504 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4507 {defaultSize, defaultSize, 1}
4508 }, // VkOffset3D srcOffsets[2];
4510 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4513 {i + defaultFourthSize / j, defaultFourthSize / j, 1}
4514 } // VkOffset3D dstOffset[2];
4516 region.imageBlit = imageBlit;
4517 params.regions.push_back(region);
4519 for (int i = 0; i < defaultSize; i += defaultFourthSize)
4521 const VkImageBlit imageBlit =
4523 defaultSourceLayer, // VkImageSubresourceLayers srcSubresource;
4526 {i + defaultFourthSize, i + defaultFourthSize, 1}
4527 }, // VkOffset3D srcOffsets[2];
4529 defaultSourceLayer, // VkImageSubresourceLayers dstSubresource;
4531 {i, defaultSize / 2, 0},
4532 {i + defaultFourthSize, defaultSize / 2 + defaultFourthSize, 1}
4533 } // VkOffset3D dstOffset[2];
4535 region.imageBlit = imageBlit;
4536 params.regions.push_back(region);
4539 addBlittingTestsAllFormats(blitImgAllFormatsTests.get(), testCtx, params);
4542 // Test Depth and Stencil formats.
4544 const VkFormat compatibleDepthAndStencilFormats[] =
4546 VK_FORMAT_D16_UNORM,
4547 VK_FORMAT_X8_D24_UNORM_PACK32,
4548 VK_FORMAT_D32_SFLOAT,
4550 VK_FORMAT_D16_UNORM_S8_UINT,
4551 VK_FORMAT_D24_UNORM_S8_UINT,
4552 VK_FORMAT_D32_SFLOAT_S8_UINT,
4555 for (size_t compatibleFormatsIndex = 0; compatibleFormatsIndex < DE_LENGTH_OF_ARRAY(compatibleDepthAndStencilFormats); ++compatibleFormatsIndex)
4559 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4560 params.src.image.extent = defaultExtent;
4561 params.dst.image.extent = defaultExtent;
4562 params.src.image.format = compatibleDepthAndStencilFormats[compatibleFormatsIndex];
4563 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4564 params.dst.image.format = params.src.image.format;
4565 std::ostringstream oss;
4566 oss << testName << "_" << getFormatCaseName(params.src.image.format) << "_" << getFormatCaseName(params.dst.image.format);
4568 const VkImageSubresourceLayers defaultDepthSourceLayer = { VK_IMAGE_ASPECT_DEPTH_BIT, 0u, 0u, 1u };
4569 const VkImageSubresourceLayers defaultStencilSourceLayer = { VK_IMAGE_ASPECT_STENCIL_BIT, 0u, 0u, 1u };
4572 for (int i = 0, j = 1; (i + defaultFourthSize / j < defaultSize) && (defaultFourthSize > j); i += defaultFourthSize / j++)
4574 const VkOffset3D srcOffset0 = {0, 0, 0};
4575 const VkOffset3D srcOffset1 = {defaultSize, defaultSize, 1};
4576 const VkOffset3D dstOffset0 = {i, 0, 0};
4577 const VkOffset3D dstOffset1 = {i + defaultFourthSize / j, defaultFourthSize / j, 1};
4579 if (tcu::hasDepthComponent(mapVkFormat(params.src.image.format).order))
4581 const VkImageBlit imageBlit =
4583 defaultDepthSourceLayer, // VkImageSubresourceLayers srcSubresource;
4584 { srcOffset0 , srcOffset1 }, // VkOffset3D srcOffsets[2];
4585 defaultDepthSourceLayer, // VkImageSubresourceLayers dstSubresource;
4586 { dstOffset0 , dstOffset1 }, // VkOffset3D dstOffset[2];
4588 region.imageBlit = imageBlit;
4589 params.regions.push_back(region);
4591 if (tcu::hasStencilComponent(mapVkFormat(params.src.image.format).order))
4593 const VkImageBlit imageBlit =
4595 defaultStencilSourceLayer, // VkImageSubresourceLayers srcSubresource;
4596 { srcOffset0 , srcOffset1 }, // VkOffset3D srcOffsets[2];
4597 defaultStencilSourceLayer, // VkImageSubresourceLayers dstSubresource;
4598 { dstOffset0 , dstOffset1 }, // VkOffset3D dstOffset[2];
4600 region.imageBlit = imageBlit;
4601 params.regions.push_back(region);
4604 for (int i = 0; i < defaultSize; i += defaultFourthSize)
4606 const VkOffset3D srcOffset0 = {i, i, 0};
4607 const VkOffset3D srcOffset1 = {i + defaultFourthSize, i + defaultFourthSize, 1};
4608 const VkOffset3D dstOffset0 = {i, defaultSize / 2, 0};
4609 const VkOffset3D dstOffset1 = {i + defaultFourthSize, defaultSize / 2 + defaultFourthSize, 1};
4611 if (tcu::hasDepthComponent(mapVkFormat(params.src.image.format).order))
4613 const VkImageBlit imageBlit =
4615 defaultDepthSourceLayer, // VkImageSubresourceLayers srcSubresource;
4616 { srcOffset0, srcOffset1 }, // VkOffset3D srcOffsets[2];
4617 defaultDepthSourceLayer, // VkImageSubresourceLayers dstSubresource;
4618 { dstOffset0, dstOffset1 } // VkOffset3D dstOffset[2];
4620 region.imageBlit = imageBlit;
4621 params.regions.push_back(region);
4623 if (tcu::hasStencilComponent(mapVkFormat(params.src.image.format).order))
4625 const VkImageBlit imageBlit =
4627 defaultStencilSourceLayer, // VkImageSubresourceLayers srcSubresource;
4628 { srcOffset0, srcOffset1 }, // VkOffset3D srcOffsets[2];
4629 defaultStencilSourceLayer, // VkImageSubresourceLayers dstSubresource;
4630 { dstOffset0, dstOffset1 } // VkOffset3D dstOffset[2];
4632 region.imageBlit = imageBlit;
4633 params.regions.push_back(region);
4637 params.filter = VK_FILTER_NEAREST;
4638 blitImgAllFormatsTests->addChild(new BlittingTestCase(testCtx, oss.str() + "_nearest", description, params));
4642 blittingImageTests->addChild(blitImgSimpleTests.release());
4643 blittingImageTests->addChild(blitImgAllFormatsTests.release());
4645 // Resolve image to image testcases.
4646 const VkSampleCountFlagBits samples[] =
4648 VK_SAMPLE_COUNT_2_BIT,
4649 VK_SAMPLE_COUNT_4_BIT,
4650 VK_SAMPLE_COUNT_8_BIT,
4651 VK_SAMPLE_COUNT_16_BIT,
4652 VK_SAMPLE_COUNT_32_BIT,
4653 VK_SAMPLE_COUNT_64_BIT
4655 const VkExtent3D resolveExtent = {256u, 256u, 1};
4658 const std::string description ("Resolve from image to image");
4659 const std::string testName ("whole");
4662 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4663 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4664 params.src.image.extent = resolveExtent;
4665 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4666 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4667 params.dst.image.extent = resolveExtent;
4670 const VkImageSubresourceLayers sourceLayer =
4672 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
4673 0u, // uint32_t mipLevel;
4674 0u, // uint32_t baseArrayLayer;
4675 1u // uint32_t layerCount;
4677 const VkImageResolve testResolve =
4679 sourceLayer, // VkImageSubresourceLayers srcSubresource;
4680 {0, 0, 0}, // VkOffset3D srcOffset;
4681 sourceLayer, // VkImageSubresourceLayers dstSubresource;
4682 {0, 0, 0}, // VkOffset3D dstOffset;
4683 resolveExtent, // VkExtent3D extent;
4686 CopyRegion imageResolve;
4687 imageResolve.imageResolve = testResolve;
4688 params.regions.push_back(imageResolve);
4691 for (int samplesIndex = 0; samplesIndex < DE_LENGTH_OF_ARRAY(samples); ++samplesIndex)
4693 params.samples = samples[samplesIndex];
4694 std::ostringstream caseName;
4695 caseName << testName << "_" << getSampleCountCaseName(samples[samplesIndex]);
4696 resolveImageTests->addChild(new ResolveImageToImageTestCase(testCtx, caseName.str(), description, params));
4701 const std::string description ("Resolve from image to image");
4702 const std::string testName ("partial");
4705 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4706 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4707 params.src.image.extent = resolveExtent;
4708 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4709 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4710 params.dst.image.extent = resolveExtent;
4713 const VkImageSubresourceLayers sourceLayer =
4715 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
4716 0u, // uint32_t mipLevel;
4717 0u, // uint32_t baseArrayLayer;
4718 1u // uint32_t layerCount;
4720 const VkImageResolve testResolve =
4722 sourceLayer, // VkImageSubresourceLayers srcSubresource;
4723 {0, 0, 0}, // VkOffset3D srcOffset;
4724 sourceLayer, // VkImageSubresourceLayers dstSubresource;
4725 {64u, 64u, 0}, // VkOffset3D dstOffset;
4726 {128u, 128u, 1u}, // VkExtent3D extent;
4729 CopyRegion imageResolve;
4730 imageResolve.imageResolve = testResolve;
4731 params.regions.push_back(imageResolve);
4734 for (int samplesIndex = 0; samplesIndex < DE_LENGTH_OF_ARRAY(samples); ++samplesIndex)
4736 params.samples = samples[samplesIndex];
4737 std::ostringstream caseName;
4738 caseName << testName << "_" << getSampleCountCaseName(samples[samplesIndex]);
4739 resolveImageTests->addChild(new ResolveImageToImageTestCase(testCtx, caseName.str(), description, params));
4744 const std::string description ("Resolve from image to image");
4745 const std::string testName ("with_regions");
4748 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4749 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4750 params.src.image.extent = resolveExtent;
4751 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4752 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4753 params.dst.image.extent = resolveExtent;
4756 const VkImageSubresourceLayers sourceLayer =
4758 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
4759 0u, // uint32_t mipLevel;
4760 0u, // uint32_t baseArrayLayer;
4761 1u // uint32_t layerCount;
4764 for (int i = 0; i < 256; i += 64)
4766 const VkImageResolve testResolve =
4768 sourceLayer, // VkImageSubresourceLayers srcSubresource;
4769 {i, i, 0}, // VkOffset3D srcOffset;
4770 sourceLayer, // VkImageSubresourceLayers dstSubresource;
4771 {i, 0, 0}, // VkOffset3D dstOffset;
4772 {64u, 64u, 1u}, // VkExtent3D extent;
4775 CopyRegion imageResolve;
4776 imageResolve.imageResolve = testResolve;
4777 params.regions.push_back(imageResolve);
4781 for (int samplesIndex = 0; samplesIndex < DE_LENGTH_OF_ARRAY(samples); ++samplesIndex)
4783 params.samples = samples[samplesIndex];
4784 std::ostringstream caseName;
4785 caseName << testName << "_" << getSampleCountCaseName(samples[samplesIndex]);
4786 resolveImageTests->addChild(new ResolveImageToImageTestCase(testCtx, caseName.str(), description, params));
4791 const std::string description ("Resolve from image to image");
4792 const std::string testName ("whole_copy_before_resolving");
4795 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4796 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4797 params.src.image.extent = defaultExtent;
4798 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4799 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4800 params.dst.image.extent = defaultExtent;
4803 const VkImageSubresourceLayers sourceLayer =
4805 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
4806 0u, // uint32_t mipLevel;
4807 0u, // uint32_t baseArrayLayer;
4808 1u // uint32_t layerCount;
4811 const VkImageResolve testResolve =
4813 sourceLayer, // VkImageSubresourceLayers srcSubresource;
4814 {0, 0, 0}, // VkOffset3D srcOffset;
4815 sourceLayer, // VkImageSubresourceLayers dstSubresource;
4816 {0, 0, 0}, // VkOffset3D dstOffset;
4817 defaultExtent, // VkExtent3D extent;
4820 CopyRegion imageResolve;
4821 imageResolve.imageResolve = testResolve;
4822 params.regions.push_back(imageResolve);
4825 for (int samplesIndex = 0; samplesIndex < DE_LENGTH_OF_ARRAY(samples); ++samplesIndex)
4827 params.samples = samples[samplesIndex];
4828 std::ostringstream caseName;
4829 caseName << testName << "_" << getSampleCountCaseName(samples[samplesIndex]);
4830 resolveImageTests->addChild(new ResolveImageToImageTestCase(testCtx, caseName.str(), description, params, COPY_MS_IMAGE_TO_MS_IMAGE));
4835 const std::string description ("Resolve from image to image");
4836 const std::string testName ("whole_array_image");
4839 params.src.image.imageType = VK_IMAGE_TYPE_2D;
4840 params.src.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4841 params.src.image.extent = defaultExtent;
4842 params.dst.image.imageType = VK_IMAGE_TYPE_2D;
4843 params.dst.image.format = VK_FORMAT_R8G8B8A8_UNORM;
4844 params.dst.image.extent = defaultExtent;
4845 params.dst.image.extent.depth = 5u;
4847 for (deUint32 layerNdx=0; layerNdx < params.dst.image.extent.depth; ++layerNdx)
4849 const VkImageSubresourceLayers sourceLayer =
4851 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask;
4852 0u, // uint32_t mipLevel;
4853 layerNdx, // uint32_t baseArrayLayer;
4854 1u // uint32_t layerCount;
4857 const VkImageResolve testResolve =
4859 sourceLayer, // VkImageSubresourceLayers srcSubresource;
4860 {0, 0, 0}, // VkOffset3D srcOffset;
4861 sourceLayer, // VkImageSubresourceLayers dstSubresource;
4862 {0, 0, 0}, // VkOffset3D dstOffset;
4863 defaultExtent, // VkExtent3D extent;
4866 CopyRegion imageResolve;
4867 imageResolve.imageResolve = testResolve;
4868 params.regions.push_back(imageResolve);
4871 for (int samplesIndex = 0; samplesIndex < DE_LENGTH_OF_ARRAY(samples); ++samplesIndex)
4873 params.samples = samples[samplesIndex];
4874 std::ostringstream caseName;
4875 caseName << testName << "_" << getSampleCountCaseName(samples[samplesIndex]);
4876 resolveImageTests->addChild(new ResolveImageToImageTestCase(testCtx, caseName.str(), description, params, COPY_MS_IMAGE_TO_ARRAY_MS_IMAGE));
4880 copiesAndBlittingTests->addChild(imageToImageTests.release());
4881 copiesAndBlittingTests->addChild(imageToBufferTests.release());
4882 copiesAndBlittingTests->addChild(bufferToImageTests.release());
4883 copiesAndBlittingTests->addChild(bufferToBufferTests.release());
4884 copiesAndBlittingTests->addChild(blittingImageTests.release());
4885 copiesAndBlittingTests->addChild(resolveImageTests.release());
4887 return copiesAndBlittingTests.release();