1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
4 *
5 * Copyright (c) 2016 The Khronos Group Inc.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief Image Tests Utility Classes
22 *//*--------------------------------------------------------------------*/
23
24 #include "vktImageTestsUtil.hpp"
25 #include "vkQueryUtil.hpp"
26 #include "vkTypeUtil.hpp"
27 #include "vkCmdUtil.hpp"
28 #include "vkObjUtil.hpp"
29 #include "tcuTextureUtil.hpp"
30
31 using namespace vk;
32
33 namespace vkt
34 {
35 namespace image
36 {
37
Buffer(const DeviceInterface & vk,const VkDevice device,Allocator & allocator,const VkBufferCreateInfo & bufferCreateInfo,const MemoryRequirement memoryRequirement)38 Buffer::Buffer (const DeviceInterface& vk,
39 const VkDevice device,
40 Allocator& allocator,
41 const VkBufferCreateInfo& bufferCreateInfo,
42 const MemoryRequirement memoryRequirement)
43 {
44 m_buffer = createBuffer(vk, device, &bufferCreateInfo);
45 m_allocation = allocator.allocate(getBufferMemoryRequirements(vk, device, *m_buffer), memoryRequirement);
46 VK_CHECK(vk.bindBufferMemory(device, *m_buffer, m_allocation->getMemory(), m_allocation->getOffset()));
47 }
48
Image(const DeviceInterface & vk,const VkDevice device,Allocator & allocator,const VkImageCreateInfo & imageCreateInfo,const MemoryRequirement memoryRequirement)49 Image::Image (const DeviceInterface& vk,
50 const VkDevice device,
51 Allocator& allocator,
52 const VkImageCreateInfo& imageCreateInfo,
53 const MemoryRequirement memoryRequirement)
54 {
55 m_image = createImage(vk, device, &imageCreateInfo);
56 de::SharedPtr<vk::Allocation> allocation(allocator.allocate(getImageMemoryRequirements(vk, device, *m_image), memoryRequirement).release());
57 m_allocations.push_back(allocation);
58 VK_CHECK(vk.bindImageMemory(device, *m_image, allocation->getMemory(), allocation->getOffset()));
59 }
60
Image(void)61 Image::Image (void)
62 : m_allocations ()
63 , m_image ()
64 {}
65
SparseImage(const vk::DeviceInterface & vkd,vk::VkDevice device,vk::VkPhysicalDevice physicalDevice,const vk::InstanceInterface & vki,const vk::VkImageCreateInfo & createInfo,const vk::VkQueue sparseQueue,vk::Allocator & allocator,const tcu::TextureFormat & format)66 SparseImage::SparseImage (const vk::DeviceInterface& vkd,
67 vk::VkDevice device,
68 vk::VkPhysicalDevice physicalDevice,
69 const vk::InstanceInterface& vki,
70 const vk::VkImageCreateInfo& createInfo,
71 const vk::VkQueue sparseQueue,
72 vk::Allocator& allocator,
73 const tcu::TextureFormat& format)
74 : Image ()
75 , m_semaphore ()
76 {
77 m_image = createImage(vkd, device, &createInfo);
78 m_semaphore = createSemaphore(vkd, device);
79 allocateAndBindSparseImage(vkd, device, physicalDevice, vki, createInfo, m_semaphore.get(), sparseQueue, allocator, m_allocations, format, m_image.get());
80 }
81
getShaderGridSize(const ImageType imageType,const tcu::UVec3 & imageSize)82 tcu::UVec3 getShaderGridSize (const ImageType imageType, const tcu::UVec3& imageSize)
83 {
84 switch (imageType)
85 {
86 case IMAGE_TYPE_1D:
87 case IMAGE_TYPE_BUFFER:
88 return tcu::UVec3(imageSize.x(), 1u, 1u);
89
90 case IMAGE_TYPE_1D_ARRAY:
91 return tcu::UVec3(imageSize.x(), imageSize.z(), 1u);
92
93 case IMAGE_TYPE_2D:
94 return tcu::UVec3(imageSize.x(), imageSize.y(), 1u);
95
96 case IMAGE_TYPE_2D_ARRAY:
97 case IMAGE_TYPE_3D:
98 return tcu::UVec3(imageSize.x(), imageSize.y(), imageSize.z());
99
100 case IMAGE_TYPE_CUBE:
101 return tcu::UVec3(imageSize.x(), imageSize.y(), 6u);
102
103 case IMAGE_TYPE_CUBE_ARRAY:
104 return tcu::UVec3(imageSize.x(), imageSize.y(), 6u * imageSize.z());
105
106 default:
107 DE_FATAL("Unknown image type");
108 return tcu::UVec3(1u, 1u, 1u);
109 }
110 }
111
getLayerSize(const ImageType imageType,const tcu::UVec3 & imageSize)112 tcu::UVec3 getLayerSize (const ImageType imageType, const tcu::UVec3& imageSize)
113 {
114 switch (imageType)
115 {
116 case IMAGE_TYPE_1D:
117 case IMAGE_TYPE_1D_ARRAY:
118 case IMAGE_TYPE_BUFFER:
119 return tcu::UVec3(imageSize.x(), 1u, 1u);
120
121 case IMAGE_TYPE_2D:
122 case IMAGE_TYPE_2D_ARRAY:
123 case IMAGE_TYPE_CUBE:
124 case IMAGE_TYPE_CUBE_ARRAY:
125 return tcu::UVec3(imageSize.x(), imageSize.y(), 1u);
126
127 case IMAGE_TYPE_3D:
128 return tcu::UVec3(imageSize.x(), imageSize.y(), imageSize.z());
129
130 default:
131 DE_FATAL("Unknown image type");
132 return tcu::UVec3(1u, 1u, 1u);
133 }
134 }
135
getNumLayers(const ImageType imageType,const tcu::UVec3 & imageSize)136 deUint32 getNumLayers (const ImageType imageType, const tcu::UVec3& imageSize)
137 {
138 switch (imageType)
139 {
140 case IMAGE_TYPE_1D:
141 case IMAGE_TYPE_2D:
142 case IMAGE_TYPE_3D:
143 case IMAGE_TYPE_BUFFER:
144 return 1u;
145
146 case IMAGE_TYPE_1D_ARRAY:
147 case IMAGE_TYPE_2D_ARRAY:
148 return imageSize.z();
149
150 case IMAGE_TYPE_CUBE:
151 return 6u;
152
153 case IMAGE_TYPE_CUBE_ARRAY:
154 return imageSize.z() * 6u;
155
156 default:
157 DE_FATAL("Unknown image type");
158 return 0u;
159 }
160 }
161
getNumPixels(const ImageType imageType,const tcu::UVec3 & imageSize)162 deUint32 getNumPixels (const ImageType imageType, const tcu::UVec3& imageSize)
163 {
164 const tcu::UVec3 gridSize = getShaderGridSize(imageType, imageSize);
165
166 return gridSize.x() * gridSize.y() * gridSize.z();
167 }
168
getDimensions(const ImageType imageType)169 deUint32 getDimensions (const ImageType imageType)
170 {
171 switch (imageType)
172 {
173 case IMAGE_TYPE_1D:
174 case IMAGE_TYPE_BUFFER:
175 return 1u;
176
177 case IMAGE_TYPE_1D_ARRAY:
178 case IMAGE_TYPE_2D:
179 return 2u;
180
181 case IMAGE_TYPE_2D_ARRAY:
182 case IMAGE_TYPE_CUBE:
183 case IMAGE_TYPE_CUBE_ARRAY:
184 case IMAGE_TYPE_3D:
185 return 3u;
186
187 default:
188 DE_FATAL("Unknown image type");
189 return 0u;
190 }
191 }
192
getLayerDimensions(const ImageType imageType)193 deUint32 getLayerDimensions (const ImageType imageType)
194 {
195 switch (imageType)
196 {
197 case IMAGE_TYPE_1D:
198 case IMAGE_TYPE_BUFFER:
199 case IMAGE_TYPE_1D_ARRAY:
200 return 1u;
201
202 case IMAGE_TYPE_2D:
203 case IMAGE_TYPE_2D_ARRAY:
204 case IMAGE_TYPE_CUBE:
205 case IMAGE_TYPE_CUBE_ARRAY:
206 return 2u;
207
208 case IMAGE_TYPE_3D:
209 return 3u;
210
211 default:
212 DE_FATAL("Unknown image type");
213 return 0u;
214 }
215 }
216
makeBufferImageCopy(const VkExtent3D extent,const deUint32 arraySize)217 VkBufferImageCopy makeBufferImageCopy (const VkExtent3D extent,
218 const deUint32 arraySize)
219 {
220 const VkBufferImageCopy copyParams =
221 {
222 0ull, // VkDeviceSize bufferOffset;
223 0u, // deUint32 bufferRowLength;
224 0u, // deUint32 bufferImageHeight;
225 makeImageSubresourceLayers(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 0u, arraySize), // VkImageSubresourceLayers imageSubresource;
226 makeOffset3D(0, 0, 0), // VkOffset3D imageOffset;
227 extent, // VkExtent3D imageExtent;
228 };
229 return copyParams;
230 }
231
makeComputePipeline(const DeviceInterface & vk,const VkDevice device,const VkPipelineLayout pipelineLayout,const VkShaderModule shaderModule)232 Move<VkPipeline> makeComputePipeline (const DeviceInterface& vk,
233 const VkDevice device,
234 const VkPipelineLayout pipelineLayout,
235 const VkShaderModule shaderModule)
236 {
237 const VkPipelineShaderStageCreateInfo pipelineShaderStageParams =
238 {
239 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
240 DE_NULL, // const void* pNext;
241 0u, // VkPipelineShaderStageCreateFlags flags;
242 VK_SHADER_STAGE_COMPUTE_BIT, // VkShaderStageFlagBits stage;
243 shaderModule, // VkShaderModule module;
244 "main", // const char* pName;
245 DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
246 };
247 const VkComputePipelineCreateInfo pipelineCreateInfo =
248 {
249 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, // VkStructureType sType;
250 DE_NULL, // const void* pNext;
251 0u, // VkPipelineCreateFlags flags;
252 pipelineShaderStageParams, // VkPipelineShaderStageCreateInfo stage;
253 pipelineLayout, // VkPipelineLayout layout;
254 DE_NULL, // VkPipeline basePipelineHandle;
255 0, // deInt32 basePipelineIndex;
256 };
257 return createComputePipeline(vk, device, DE_NULL , &pipelineCreateInfo);
258 }
259
makeGraphicsPipeline(const DeviceInterface & vk,const VkDevice device,const VkPipelineLayout pipelineLayout,const VkRenderPass renderPass,const VkShaderModule vertexModule,const VkShaderModule fragmentModule,const VkExtent2D renderSize,const deUint32 colorAttachmentCount,const bool dynamicSize)260 Move<VkPipeline> makeGraphicsPipeline (const DeviceInterface& vk,
261 const VkDevice device,
262 const VkPipelineLayout pipelineLayout,
263 const VkRenderPass renderPass,
264 const VkShaderModule vertexModule,
265 const VkShaderModule fragmentModule,
266 const VkExtent2D renderSize,
267 const deUint32 colorAttachmentCount,
268 const bool dynamicSize)
269 {
270 std::vector<VkViewport> viewports;
271 std::vector<VkRect2D> scissors;
272
273 const VkViewport viewport = makeViewport(renderSize);
274 const VkRect2D scissor = makeRect2D(renderSize);
275
276 const VkFormat vertexFormatPosition = VK_FORMAT_R32G32B32A32_SFLOAT;
277 const deUint32 vertexSizePosition = tcu::getPixelSize(mapVkFormat(vertexFormatPosition));
278 const deUint32 vertexBufferOffsetPosition = 0u;
279 const deUint32 vertexDataStride = vertexSizePosition;
280
281 if (!dynamicSize)
282 {
283 viewports.push_back(viewport);
284 scissors.push_back(scissor);
285 }
286
287 const VkVertexInputBindingDescription vertexInputBindingDescription =
288 {
289 0u, // deUint32 binding;
290 vertexDataStride, // deUint32 stride;
291 VK_VERTEX_INPUT_RATE_VERTEX // VkVertexInputRate inputRate;
292 };
293
294 const VkVertexInputAttributeDescription vertexInputAttributeDescription =
295 {
296 0u, // deUint32 location;
297 0u, // deUint32 binding;
298 vertexFormatPosition, // VkFormat format;
299 vertexBufferOffsetPosition, // deUint32 offset;
300 };
301
302 const VkPipelineVertexInputStateCreateInfo vertexInputStateCreateInfo =
303 {
304 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // VkStructureType sType;
305 DE_NULL, // const void* pNext;
306 (VkPipelineVertexInputStateCreateFlags)0, // VkPipelineVertexInputStateCreateFlags flags;
307 1u, // deUint32 vertexBindingDescriptionCount;
308 &vertexInputBindingDescription, // const VkVertexInputBindingDescription* pVertexBindingDescriptions;
309 1u, // deUint32 vertexAttributeDescriptionCount;
310 &vertexInputAttributeDescription // const VkVertexInputAttributeDescription* pVertexAttributeDescriptions;
311 };
312
313 const VkColorComponentFlags colorComponentsAll = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
314 const VkPipelineColorBlendAttachmentState colorBlendAttachmentState =
315 {
316 VK_FALSE, // VkBool32 blendEnable;
317 VK_BLEND_FACTOR_ONE, // VkBlendFactor srcColorBlendFactor;
318 VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstColorBlendFactor;
319 VK_BLEND_OP_ADD, // VkBlendOp colorBlendOp;
320 VK_BLEND_FACTOR_ONE, // VkBlendFactor srcAlphaBlendFactor;
321 VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstAlphaBlendFactor;
322 VK_BLEND_OP_ADD, // VkBlendOp alphaBlendOp;
323 colorComponentsAll // VkColorComponentFlags colorWriteMask;
324 };
325
326 std::vector<VkPipelineColorBlendAttachmentState> colorAttachments (colorAttachmentCount, colorBlendAttachmentState);
327
328 const VkPipelineColorBlendStateCreateInfo pipelineColorBlendStateInfo =
329 {
330 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // VkStructureType sType;
331 DE_NULL, // const void* pNext;
332 (VkPipelineColorBlendStateCreateFlags)0, // VkPipelineColorBlendStateCreateFlags flags;
333 VK_FALSE, // VkBool32 logicOpEnable;
334 VK_LOGIC_OP_COPY, // VkLogicOp logicOp;
335 (deUint32)colorAttachments.size(), // deUint32 attachmentCount;
336 colorAttachments.size() != 0 ? &colorAttachments[0] : DE_NULL, // const VkPipelineColorBlendAttachmentState* pAttachments;
337 { 0.0f, 0.0f, 0.0f, 0.0f } // float blendConstants[4];
338 };
339
340 return vk::makeGraphicsPipeline(vk, // const DeviceInterface& vk
341 device, // const VkDevice device
342 pipelineLayout, // const VkPipelineLayout pipelineLayout
343 vertexModule, // const VkShaderModule vertexShaderModule
344 DE_NULL, // const VkShaderModule tessellationControlModule
345 DE_NULL, // const VkShaderModule tessellationEvalModule
346 DE_NULL, // const VkShaderModule geometryShaderModule
347 fragmentModule, // const VkShaderModule fragmentShaderModule
348 renderPass, // const VkRenderPass renderPass
349 viewports, // const std::vector<VkViewport>& viewports
350 scissors, // const std::vector<VkRect2D>& scissors
351 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, // const VkPrimitiveTopology topology
352 0u, // const deUint32 subpass
353 0u, // const deUint32 patchControlPoints
354 &vertexInputStateCreateInfo, // const VkPipelineVertexInputStateCreateInfo* vertexInputStateCreateInfo
355 DE_NULL, // const VkPipelineRasterizationStateCreateInfo* rasterizationStateCreateInfo
356 DE_NULL, // const VkPipelineMultisampleStateCreateInfo* multisampleStateCreateInfo
357 DE_NULL, // const VkPipelineDepthStencilStateCreateInfo* depthStencilStateCreateInfo
358 &pipelineColorBlendStateInfo); // const VkPipelineColorBlendStateCreateInfo* colorBlendStateCreateInfo
359 }
360
361 //! A single-subpass render pass.
makeRenderPass(const DeviceInterface & vk,const VkDevice device,const VkFormat inputFormat,const VkFormat colorFormat)362 Move<VkRenderPass> makeRenderPass (const DeviceInterface& vk,
363 const VkDevice device,
364 const VkFormat inputFormat,
365 const VkFormat colorFormat)
366 {
367 const VkAttachmentReference inputAttachmentRef =
368 {
369 0u, // deUint32 attachment;
370 VK_IMAGE_LAYOUT_GENERAL // VkImageLayout layout;
371 };
372
373 const VkAttachmentReference colorAttachmentRef =
374 {
375 1u, // deUint32 attachment;
376 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout layout;
377 };
378
379 const VkSubpassDescription subpassDescription =
380 {
381 (VkSubpassDescriptionFlags)0, // VkSubpassDescriptionFlags flags;
382 VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint;
383 1u, // deUint32 inputAttachmentCount;
384 &inputAttachmentRef, // const VkAttachmentReference* pInputAttachments;
385 1u, // deUint32 colorAttachmentCount;
386 &colorAttachmentRef, // const VkAttachmentReference* pColorAttachments;
387 DE_NULL, // const VkAttachmentReference* pResolveAttachments;
388 DE_NULL, // const VkAttachmentReference* pDepthStencilAttachment;
389 0u, // deUint32 preserveAttachmentCount;
390 DE_NULL // const deUint32* pPreserveAttachments;
391 };
392
393 const VkAttachmentDescription attachmentsDescriptions[] =
394 {
395 //inputAttachmentDescription,
396 {
397 (VkAttachmentDescriptionFlags)0, // VkAttachmentDescriptionFlags flags;
398 inputFormat, // VkFormat format;
399 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
400 VK_ATTACHMENT_LOAD_OP_LOAD, // VkAttachmentLoadOp loadOp;
401 VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp storeOp;
402 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp;
403 VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp;
404 VK_IMAGE_LAYOUT_GENERAL, // VkImageLayout initialLayout;
405 VK_IMAGE_LAYOUT_GENERAL, // VkImageLayout finalLayout;
406 },
407 //colorAttachmentDescription
408 {
409 (VkAttachmentDescriptionFlags)0, // VkAttachmentDescriptionFlags flags;
410 colorFormat, // VkFormat format;
411 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
412 VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp;
413 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
414 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp;
415 VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp;
416 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
417 VK_IMAGE_LAYOUT_GENERAL, // VkImageLayout finalLayout;
418 }
419 };
420
421 const VkRenderPassCreateInfo renderPassInfo =
422 {
423 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType;
424 DE_NULL, // const void* pNext;
425 (VkRenderPassCreateFlags)0, // VkRenderPassCreateFlags flags;
426 DE_LENGTH_OF_ARRAY(attachmentsDescriptions), // deUint32 attachmentCount;
427 attachmentsDescriptions, // const VkAttachmentDescription* pAttachments;
428 1u, // deUint32 subpassCount;
429 &subpassDescription, // const VkSubpassDescription* pSubpasses;
430 0u, // deUint32 dependencyCount;
431 DE_NULL // const VkSubpassDependency* pDependencies;
432 };
433
434 return createRenderPass(vk, device, &renderPassInfo);
435 }
436
makeImageViewUsageCreateInfo(const VkImageUsageFlags imageUsageFlags)437 VkImageViewUsageCreateInfo makeImageViewUsageCreateInfo (const VkImageUsageFlags imageUsageFlags)
438 {
439 VkImageViewUsageCreateInfo imageViewUsageCreateInfo =
440 {
441 VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO_KHR, //VkStructureType sType;
442 DE_NULL, //const void* pNext;
443 imageUsageFlags, //VkImageUsageFlags usage;
444 };
445
446 return imageViewUsageCreateInfo;
447 }
448
makeSamplerCreateInfo()449 VkSamplerCreateInfo makeSamplerCreateInfo ()
450 {
451 const VkSamplerCreateInfo defaultSamplerParams =
452 {
453 VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, // VkStructureType sType;
454 DE_NULL, // const void* pNext;
455 0u, // VkSamplerCreateFlags flags;
456 VK_FILTER_NEAREST, // VkFilter magFilter;
457 VK_FILTER_NEAREST, // VkFilter minFilter;
458 VK_SAMPLER_MIPMAP_MODE_NEAREST, // VkSamplerMipmapMode mipmapMode;
459 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // VkSamplerAddressMode addressModeU;
460 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // VkSamplerAddressMode addressModeV;
461 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // VkSamplerAddressMode addressModeW;
462 0.0f, // float mipLodBias;
463 VK_FALSE, // VkBool32 anisotropyEnable;
464 1.0f, // float maxAnisotropy;
465 VK_FALSE, // VkBool32 compareEnable;
466 VK_COMPARE_OP_NEVER, // VkCompareOp compareOp;
467 0.0f, // float minLod;
468 0.25f, // float maxLod;
469 VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK, // VkBorderColor borderColor;
470 VK_FALSE // VkBool32 unnormalizedCoordinates;
471 };
472
473 return defaultSamplerParams;
474 }
475
getCompressedImageResolutionInBlocks(const vk::VkFormat format,const tcu::UVec3 & size)476 tcu::UVec3 getCompressedImageResolutionInBlocks (const vk::VkFormat format, const tcu::UVec3& size)
477 {
478 deUint32 blockWidth = getBlockWidth(format);
479 deUint32 blockHeight = getBlockHeight(format);
480
481 DE_ASSERT(size[2] == 1);
482 DE_ASSERT(blockWidth != 0 && blockHeight != 0);
483
484 deUint32 widthInBlocks = (size[0] + blockWidth - 1) / blockWidth;
485 deUint32 heightInBlocks = (size[1] + blockHeight - 1) / blockHeight;
486
487 return tcu::UVec3(widthInBlocks, heightInBlocks, 1);
488 }
489
getCompressedImageResolutionBlockCeil(const vk::VkFormat format,const tcu::UVec3 & size)490 tcu::UVec3 getCompressedImageResolutionBlockCeil (const vk::VkFormat format, const tcu::UVec3& size)
491 {
492 deUint32 blockWidth = getBlockWidth(format);
493 deUint32 blockHeight = getBlockHeight(format);
494
495 DE_ASSERT(size[2] == 1);
496 DE_ASSERT(blockWidth != 0 && blockHeight != 0);
497
498 deUint32 widthInBlocks = (size[0] + blockWidth - 1) / blockWidth;
499 deUint32 heightInBlocks = (size[1] + blockHeight - 1) / blockHeight;
500
501 return tcu::UVec3(blockWidth * widthInBlocks, blockHeight * heightInBlocks, 1);
502 }
503
getCompressedImageSizeInBytes(const vk::VkFormat format,const tcu::UVec3 & size)504 VkDeviceSize getCompressedImageSizeInBytes (const vk::VkFormat format, const tcu::UVec3& size)
505 {
506 tcu::UVec3 sizeInBlocks = getCompressedImageResolutionInBlocks(format, size);
507 deUint32 blockBytes = getBlockSizeInBytes(format);
508 VkDeviceSize sizeBytes = sizeInBlocks[0] * sizeInBlocks[1] * sizeInBlocks[2] * blockBytes;
509
510 return sizeBytes;
511 }
512
getUncompressedImageSizeInBytes(const vk::VkFormat format,const tcu::UVec3 & size)513 VkDeviceSize getUncompressedImageSizeInBytes (const vk::VkFormat format, const tcu::UVec3& size)
514 {
515 const tcu::IVec3 sizeAsIVec3 = tcu::IVec3((int)size.x(), (int)size.y(), (int)size.z());
516 const VkDeviceSize sizeBytes = getImageSizeBytes(sizeAsIVec3, format);
517
518 return sizeBytes;
519 }
520
mapImageType(const ImageType imageType)521 VkImageType mapImageType (const ImageType imageType)
522 {
523 switch (imageType)
524 {
525 case IMAGE_TYPE_1D:
526 case IMAGE_TYPE_1D_ARRAY:
527 case IMAGE_TYPE_BUFFER:
528 return VK_IMAGE_TYPE_1D;
529
530 case IMAGE_TYPE_2D:
531 case IMAGE_TYPE_2D_ARRAY:
532 case IMAGE_TYPE_CUBE:
533 case IMAGE_TYPE_CUBE_ARRAY:
534 return VK_IMAGE_TYPE_2D;
535
536 case IMAGE_TYPE_3D:
537 return VK_IMAGE_TYPE_3D;
538
539 default:
540 DE_ASSERT(false);
541 return VK_IMAGE_TYPE_LAST;
542 }
543 }
544
mapImageViewType(const ImageType imageType)545 VkImageViewType mapImageViewType (const ImageType imageType)
546 {
547 switch (imageType)
548 {
549 case IMAGE_TYPE_1D: return VK_IMAGE_VIEW_TYPE_1D;
550 case IMAGE_TYPE_1D_ARRAY: return VK_IMAGE_VIEW_TYPE_1D_ARRAY;
551 case IMAGE_TYPE_2D: return VK_IMAGE_VIEW_TYPE_2D;
552 case IMAGE_TYPE_2D_ARRAY: return VK_IMAGE_VIEW_TYPE_2D_ARRAY;
553 case IMAGE_TYPE_3D: return VK_IMAGE_VIEW_TYPE_3D;
554 case IMAGE_TYPE_CUBE: return VK_IMAGE_VIEW_TYPE_CUBE;
555 case IMAGE_TYPE_CUBE_ARRAY: return VK_IMAGE_VIEW_TYPE_CUBE_ARRAY;
556
557 default:
558 DE_ASSERT(false);
559 return VK_IMAGE_VIEW_TYPE_LAST;
560 }
561 }
562
getImageTypeName(const ImageType imageType)563 std::string getImageTypeName (const ImageType imageType)
564 {
565 switch (imageType)
566 {
567 case IMAGE_TYPE_1D: return "1d";
568 case IMAGE_TYPE_1D_ARRAY: return "1d_array";
569 case IMAGE_TYPE_2D: return "2d";
570 case IMAGE_TYPE_2D_ARRAY: return "2d_array";
571 case IMAGE_TYPE_3D: return "3d";
572 case IMAGE_TYPE_CUBE: return "cube";
573 case IMAGE_TYPE_CUBE_ARRAY: return "cube_array";
574 case IMAGE_TYPE_BUFFER: return "buffer";
575
576 default:
577 DE_ASSERT(false);
578 return "";
579 }
580 }
581
getFormatPrefix(const tcu::TextureFormat & format)582 std::string getFormatPrefix (const tcu::TextureFormat& format)
583 {
584 const std::string image64 = ((mapTextureFormat(format) == VK_FORMAT_R64_UINT || mapTextureFormat(format) == VK_FORMAT_R64_SINT) ? "64" : "");
585 return tcu::getTextureChannelClass(format.type) == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER ? "u" + image64 :
586 tcu::getTextureChannelClass(format.type) == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER ? "i" + image64 : "";
587 }
588
getShaderImageType(const tcu::TextureFormat & format,const ImageType imageType,const bool multisample)589 std::string getShaderImageType (const tcu::TextureFormat& format, const ImageType imageType, const bool multisample)
590 {
591 std::string formatPart = getFormatPrefix(format);
592
593 std::string imageTypePart;
594 if (multisample)
595 {
596 switch (imageType)
597 {
598 case IMAGE_TYPE_2D: imageTypePart = "2DMS"; break;
599 case IMAGE_TYPE_2D_ARRAY: imageTypePart = "2DMSArray"; break;
600
601 default:
602 DE_ASSERT(false);
603 }
604 }
605 else
606 {
607 switch (imageType)
608 {
609 case IMAGE_TYPE_1D: imageTypePart = "1D"; break;
610 case IMAGE_TYPE_1D_ARRAY: imageTypePart = "1DArray"; break;
611 case IMAGE_TYPE_2D: imageTypePart = "2D"; break;
612 case IMAGE_TYPE_2D_ARRAY: imageTypePart = "2DArray"; break;
613 case IMAGE_TYPE_3D: imageTypePart = "3D"; break;
614 case IMAGE_TYPE_CUBE: imageTypePart = "Cube"; break;
615 case IMAGE_TYPE_CUBE_ARRAY: imageTypePart = "CubeArray"; break;
616 case IMAGE_TYPE_BUFFER: imageTypePart = "Buffer"; break;
617
618 default:
619 DE_ASSERT(false);
620 }
621 }
622
623 return formatPart + "image" + imageTypePart;
624 }
625
getShaderImageFormatQualifier(const tcu::TextureFormat & format)626 std::string getShaderImageFormatQualifier (const tcu::TextureFormat& format)
627 {
628 if (!isPackedType(mapTextureFormat(format)))
629 {
630 const char* orderPart;
631 const char* typePart;
632
633 switch (format.order)
634 {
635 case tcu::TextureFormat::R: orderPart = "r"; break;
636 case tcu::TextureFormat::RG: orderPart = "rg"; break;
637 case tcu::TextureFormat::RGB: orderPart = "rgb"; break;
638 case tcu::TextureFormat::RGBA: orderPart = "rgba"; break;
639 case tcu::TextureFormat::sRGBA: orderPart = "rgba"; break;
640
641 default:
642 DE_FATAL("Order not found");
643 orderPart = DE_NULL;
644 }
645
646 switch (format.type)
647 {
648 case tcu::TextureFormat::FLOAT: typePart = "32f"; break;
649 case tcu::TextureFormat::HALF_FLOAT: typePart = "16f"; break;
650
651 case tcu::TextureFormat::UNSIGNED_INT64: typePart = "64ui"; break;
652 case tcu::TextureFormat::UNSIGNED_INT32: typePart = "32ui"; break;
653 case tcu::TextureFormat::USCALED_INT16:
654 case tcu::TextureFormat::UNSIGNED_INT16: typePart = "16ui"; break;
655 case tcu::TextureFormat::USCALED_INT8:
656 case tcu::TextureFormat::UNSIGNED_INT8: typePart = "8ui"; break;
657
658 case tcu::TextureFormat::SIGNED_INT64: typePart = "64i"; break;
659 case tcu::TextureFormat::SIGNED_INT32: typePart = "32i"; break;
660 case tcu::TextureFormat::SSCALED_INT16:
661 case tcu::TextureFormat::SIGNED_INT16: typePart = "16i"; break;
662 case tcu::TextureFormat::SSCALED_INT8:
663 case tcu::TextureFormat::SIGNED_INT8: typePart = "8i"; break;
664
665 case tcu::TextureFormat::UNORM_INT16: typePart = "16"; break;
666 case tcu::TextureFormat::UNORM_INT8: typePart = "8"; break;
667
668 case tcu::TextureFormat::SNORM_INT16: typePart = "16_snorm"; break;
669 case tcu::TextureFormat::SNORM_INT8: typePart = "8_snorm"; break;
670
671 default:
672 DE_FATAL("Type not found");
673 typePart = DE_NULL;
674 }
675
676 return std::string() + orderPart + typePart;
677 }
678 else
679 {
680 switch (mapTextureFormat(format))
681 {
682 case VK_FORMAT_B10G11R11_UFLOAT_PACK32: return "r11f_g11f_b10f";
683 case VK_FORMAT_A2B10G10R10_UNORM_PACK32: return "rgb10_a2";
684 case VK_FORMAT_A2B10G10R10_UINT_PACK32: return "rgb10_a2ui";
685
686 default:
687 DE_FATAL("Qualifier not found");
688 return "";
689 }
690 }
691 }
692
getGlslSamplerType(const tcu::TextureFormat & format,VkImageViewType type)693 std::string getGlslSamplerType (const tcu::TextureFormat& format, VkImageViewType type)
694 {
695 const char* typePart = DE_NULL;
696 const char* formatPart = tcu::getTextureChannelClass(format.type) == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER ? "u" :
697 tcu::getTextureChannelClass(format.type) == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER ? "i" : "";
698
699 switch (type)
700 {
701 case VK_IMAGE_VIEW_TYPE_1D: typePart = "sampler1D"; break;
702 case VK_IMAGE_VIEW_TYPE_1D_ARRAY: typePart = "sampler1DArray"; break;
703 case VK_IMAGE_VIEW_TYPE_2D: typePart = "sampler2D"; break;
704 case VK_IMAGE_VIEW_TYPE_2D_ARRAY: typePart = "sampler2DArray"; break;
705 case VK_IMAGE_VIEW_TYPE_3D: typePart = "sampler3D"; break;
706 case VK_IMAGE_VIEW_TYPE_CUBE: typePart = "samplerCube"; break;
707 case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY: typePart = "samplerCubeArray"; break;
708
709 default:
710 DE_FATAL("Unknown image view type");
711 break;
712 }
713
714 return std::string(formatPart) + typePart;
715 }
716
717
getGlslInputFormatType(const vk::VkFormat format)718 const char* getGlslInputFormatType (const vk::VkFormat format)
719 {
720 switch (format)
721 {
722 // 64-bit
723 case VK_FORMAT_R16G16B16A16_UNORM: return "subpassInput";
724 case VK_FORMAT_R16G16B16A16_SNORM: return "subpassInput";
725 case VK_FORMAT_R16G16B16A16_USCALED: return "subpassInput";
726 case VK_FORMAT_R16G16B16A16_SSCALED: return "subpassInput";
727 case VK_FORMAT_R16G16B16A16_UINT: return "usubpassInput";
728 case VK_FORMAT_R16G16B16A16_SINT: return "isubpassInput";
729 case VK_FORMAT_R16G16B16A16_SFLOAT: return "subpassInput";
730 case VK_FORMAT_R32G32_UINT: return "usubpassInput";
731 case VK_FORMAT_R32G32_SINT: return "isubpassInput";
732 case VK_FORMAT_R32G32_SFLOAT: return "subpassInput";
733 // TODO: case VK_FORMAT_R64_UINT: return "usubpassInput";
734 // TODO: case VK_FORMAT_R64_SINT: return "isubpassInput";
735 // TODO: case VK_FORMAT_R64_SFLOAT: return "subpassInput";
736
737 // 128-bit
738 case VK_FORMAT_R32G32B32A32_UINT: return "usubpassInput";
739 case VK_FORMAT_R32G32B32A32_SINT: return "isubpassInput";
740 case VK_FORMAT_R32G32B32A32_SFLOAT: return "subpassInput";
741 // TODO: case VK_FORMAT_R64G64_UINT: return "usubpassInput";
742 // TODO: case VK_FORMAT_R64G64_SINT: return "isubpassInput";
743 // TODO: case VK_FORMAT_R64G64_SFLOAT: return "subpassInput";
744
745 default: TCU_THROW(InternalError, "Unknown format");
746 }
747 }
748
getGlslFormatType(const vk::VkFormat format)749 const char* getGlslFormatType (const vk::VkFormat format)
750 {
751 switch (format)
752 {
753 // 64-bit
754 case VK_FORMAT_R16G16B16A16_UNORM: return "vec4";
755 case VK_FORMAT_R16G16B16A16_SNORM: return "vec4";
756 case VK_FORMAT_R16G16B16A16_USCALED: return "vec4";
757 case VK_FORMAT_R16G16B16A16_SSCALED: return "vec4";
758 case VK_FORMAT_R16G16B16A16_UINT: return "uvec4";
759 case VK_FORMAT_R16G16B16A16_SINT: return "ivec4";
760 case VK_FORMAT_R16G16B16A16_SFLOAT: return "vec4";
761 case VK_FORMAT_R32G32_UINT: return "uvec2";
762 case VK_FORMAT_R32G32_SINT: return "ivec2";
763 case VK_FORMAT_R32G32_SFLOAT: return "vec2";
764 // TODO: case VK_FORMAT_R64_UINT: return "uint64";
765 // TODO: case VK_FORMAT_R64_SINT: return "int64";
766 // TODO: case VK_FORMAT_R64_SFLOAT: return "double";
767
768 // 128-bit
769 case VK_FORMAT_R32G32B32A32_UINT: return "uvec4";
770 case VK_FORMAT_R32G32B32A32_SINT: return "ivec4";
771 case VK_FORMAT_R32G32B32A32_SFLOAT: return "vec4";
772 // TODO: case VK_FORMAT_R64G64_UINT: return "ulvec2";
773 // TODO: case VK_FORMAT_R64G64_SINT: return "ilvec2";
774 // TODO: case VK_FORMAT_R64G64_SFLOAT: return "dvec2";
775
776 default: TCU_THROW(InternalError, "Unknown format");
777 }
778 }
779
getGlslAttachmentType(const vk::VkFormat format)780 const char* getGlslAttachmentType (const vk::VkFormat format)
781 {
782 const tcu::TextureFormat textureFormat = mapVkFormat(format);
783 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(textureFormat.type);
784
785 switch (channelClass)
786 {
787 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
788 return "ivec4";
789
790 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
791 return "uvec4";
792
793 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
794 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
795 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
796 return "vec4";
797
798 default:
799 DE_FATAL("Unknown channel class");
800 return "";
801 }
802 }
803
getGlslInputAttachmentType(const vk::VkFormat format)804 const char* getGlslInputAttachmentType (const vk::VkFormat format)
805 {
806 const tcu::TextureFormat textureFormat = mapVkFormat(format);
807 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(textureFormat.type);
808
809 switch (channelClass)
810 {
811 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
812 return "isubpassInput";
813
814 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
815 return "usubpassInput";
816
817 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
818 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
819 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
820 return "subpassInput";
821
822 default:
823 DE_FATAL("Unknown channel class");
824 return "";
825 }
826 }
827
isPackedType(const vk::VkFormat format)828 bool isPackedType (const vk::VkFormat format)
829 {
830 const tcu::TextureFormat textureFormat = mapVkFormat(format);
831
832 DE_STATIC_ASSERT(tcu::TextureFormat::CHANNELTYPE_LAST == 48);
833
834 switch (textureFormat.type)
835 {
836 case tcu::TextureFormat::UNORM_BYTE_44:
837 case tcu::TextureFormat::UNORM_SHORT_565:
838 case tcu::TextureFormat::UNORM_SHORT_555:
839 case tcu::TextureFormat::UNORM_SHORT_4444:
840 case tcu::TextureFormat::UNORM_SHORT_5551:
841 case tcu::TextureFormat::UNORM_SHORT_1555:
842 case tcu::TextureFormat::UNORM_INT_101010:
843 case tcu::TextureFormat::SNORM_INT_1010102_REV:
844 case tcu::TextureFormat::UNORM_INT_1010102_REV:
845 case tcu::TextureFormat::UNSIGNED_BYTE_44:
846 case tcu::TextureFormat::UNSIGNED_SHORT_565:
847 case tcu::TextureFormat::UNSIGNED_SHORT_4444:
848 case tcu::TextureFormat::UNSIGNED_SHORT_5551:
849 case tcu::TextureFormat::SIGNED_INT_1010102_REV:
850 case tcu::TextureFormat::UNSIGNED_INT_1010102_REV:
851 case tcu::TextureFormat::UNSIGNED_INT_11F_11F_10F_REV:
852 case tcu::TextureFormat::UNSIGNED_INT_999_E5_REV:
853 case tcu::TextureFormat::UNSIGNED_INT_16_8_8:
854 case tcu::TextureFormat::UNSIGNED_INT_24_8:
855 case tcu::TextureFormat::UNSIGNED_INT_24_8_REV:
856 case tcu::TextureFormat::SSCALED_INT_1010102_REV:
857 case tcu::TextureFormat::USCALED_INT_1010102_REV:
858 return true;
859
860 default:
861 return false;
862 }
863 }
864
isComponentSwizzled(const vk::VkFormat format)865 bool isComponentSwizzled (const vk::VkFormat format)
866 {
867 const tcu::TextureFormat textureFormat = mapVkFormat(format);
868
869 DE_STATIC_ASSERT(tcu::TextureFormat::CHANNELORDER_LAST == 22);
870
871 switch (textureFormat.order)
872 {
873 case tcu::TextureFormat::ARGB:
874 case tcu::TextureFormat::ABGR:
875 case tcu::TextureFormat::BGR:
876 case tcu::TextureFormat::BGRA:
877 case tcu::TextureFormat::sBGR:
878 case tcu::TextureFormat::sBGRA:
879 return true;
880
881 default:
882 return false;
883 }
884 }
885
getNumUsedChannels(const vk::VkFormat format)886 int getNumUsedChannels (const vk::VkFormat format)
887 {
888 // make sure this function will be checked if type table is updated
889 DE_STATIC_ASSERT(tcu::TextureFormat::CHANNELORDER_LAST == 22);
890
891 const tcu::TextureFormat textureFormat = mapVkFormat(format);
892
893 return getNumUsedChannels(textureFormat.order);
894 }
895
isFormatImageLoadStoreCapable(const vk::VkFormat format)896 bool isFormatImageLoadStoreCapable (const vk::VkFormat format)
897 {
898 // These come from https://www.khronos.org/registry/vulkan/specs/1.1/html/vkspec.html#spirvenv-image-formats
899 switch (format)
900 {
901 case VK_FORMAT_R32G32B32A32_SFLOAT:
902 case VK_FORMAT_R16G16B16A16_SFLOAT:
903 case VK_FORMAT_R32_SFLOAT:
904 case VK_FORMAT_R8G8B8A8_UNORM:
905 case VK_FORMAT_R8G8B8A8_SNORM:
906 case VK_FORMAT_R32G32_SFLOAT:
907 case VK_FORMAT_R16G16_SFLOAT:
908 case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
909 case VK_FORMAT_R16_SFLOAT:
910 case VK_FORMAT_R16G16B16A16_UNORM:
911 case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
912 case VK_FORMAT_R16G16_UNORM:
913 case VK_FORMAT_R8G8_UNORM:
914 case VK_FORMAT_R16_UNORM:
915 case VK_FORMAT_R8_UNORM:
916 case VK_FORMAT_R16G16B16A16_SNORM:
917 case VK_FORMAT_R16G16_SNORM:
918 case VK_FORMAT_R8G8_SNORM:
919 case VK_FORMAT_R16_SNORM:
920 case VK_FORMAT_R8_SNORM:
921 case VK_FORMAT_R32G32B32A32_SINT:
922 case VK_FORMAT_R16G16B16A16_SINT:
923 case VK_FORMAT_R8G8B8A8_SINT:
924 case VK_FORMAT_R32_SINT:
925 case VK_FORMAT_R32G32_SINT:
926 case VK_FORMAT_R16G16_SINT:
927 case VK_FORMAT_R8G8_SINT:
928 case VK_FORMAT_R16_SINT:
929 case VK_FORMAT_R8_SINT:
930 case VK_FORMAT_R32G32B32A32_UINT:
931 case VK_FORMAT_R16G16B16A16_UINT:
932 case VK_FORMAT_R8G8B8A8_UINT:
933 case VK_FORMAT_R32_UINT:
934 case VK_FORMAT_A2B10G10R10_UINT_PACK32:
935 case VK_FORMAT_R32G32_UINT:
936 case VK_FORMAT_R16G16_UINT:
937 case VK_FORMAT_R8G8_UINT:
938 case VK_FORMAT_R16_UINT:
939 case VK_FORMAT_R8_UINT:
940 return true;
941
942 default:
943 return false;
944 }
945 }
946
getFormatShortString(const VkFormat format)947 std::string getFormatShortString (const VkFormat format)
948 {
949 const std::string fullName = getFormatName(format);
950
951 DE_ASSERT(de::beginsWith(fullName, "VK_FORMAT_"));
952
953 return de::toLower(fullName.substr(10));
954 }
955
createFullscreenQuad(void)956 std::vector<tcu::Vec4> createFullscreenQuad (void)
957 {
958 const tcu::Vec4 lowerLeftVertex (-1.0f, -1.0f, 0.0f, 1.0f);
959 const tcu::Vec4 upperLeftVertex (-1.0f, 1.0f, 0.0f, 1.0f);
960 const tcu::Vec4 lowerRightVertex (1.0f, -1.0f, 0.0f, 1.0f);
961 const tcu::Vec4 upperRightVertex (1.0f, 1.0f, 0.0f, 1.0f);
962
963 const tcu::Vec4 vertices[6] =
964 {
965 lowerLeftVertex,
966 lowerRightVertex,
967 upperLeftVertex,
968
969 upperLeftVertex,
970 lowerRightVertex,
971 upperRightVertex
972 };
973
974 return std::vector<tcu::Vec4>(vertices, vertices + DE_LENGTH_OF_ARRAY(vertices));
975 }
976
makeBufferImageCopy(const deUint32 imageWidth,const deUint32 imageHeight,const deUint32 mipLevel,const deUint32 layer)977 vk::VkBufferImageCopy makeBufferImageCopy (const deUint32 imageWidth, const deUint32 imageHeight, const deUint32 mipLevel, const deUint32 layer)
978 {
979 const VkBufferImageCopy copyParams =
980 {
981 (VkDeviceSize)0u, // bufferOffset
982 imageWidth, // bufferRowLength
983 imageHeight, // bufferImageHeight
984 {
985 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
986 mipLevel, // mipLevel
987 layer, // baseArrayLayer
988 1u, // layerCount
989 }, // imageSubresource
990 { 0u, 0u, 0u }, // imageOffset
991 {
992 imageWidth,
993 imageHeight,
994 1u
995 } // imageExtent
996 };
997
998 return copyParams;
999 }
1000
makeBufferImageCopy(const deUint32 imageWidth,const deUint32 imageHeight,const deUint32 mipLevel,const deUint32 layer,const deUint32 bufferRowLength,const deUint32 bufferImageHeight)1001 vk::VkBufferImageCopy makeBufferImageCopy (const deUint32 imageWidth, const deUint32 imageHeight, const deUint32 mipLevel, const deUint32 layer, const deUint32 bufferRowLength, const deUint32 bufferImageHeight)
1002 {
1003 const VkBufferImageCopy copyParams =
1004 {
1005 (VkDeviceSize)0u, // bufferOffset
1006 bufferRowLength, // bufferRowLength
1007 bufferImageHeight, // bufferImageHeight
1008 {
1009 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
1010 mipLevel, // mipLevel
1011 layer, // baseArrayLayer
1012 1u, // layerCount
1013 }, // imageSubresource
1014 { 0u, 0u, 0u }, // imageOffset
1015 {
1016 imageWidth,
1017 imageHeight,
1018 1u
1019 } // imageExtent
1020 };
1021
1022 return copyParams;
1023 }
1024
beginRenderPass(const DeviceInterface & vk,const VkCommandBuffer commandBuffer,const VkRenderPass renderPass,const VkFramebuffer framebuffer,const VkExtent2D & renderSize)1025 void beginRenderPass (const DeviceInterface& vk,
1026 const VkCommandBuffer commandBuffer,
1027 const VkRenderPass renderPass,
1028 const VkFramebuffer framebuffer,
1029 const VkExtent2D& renderSize)
1030 {
1031 const VkRect2D renderArea =
1032 {
1033 {0, 0}, // VkOffset2D offset;
1034 renderSize, // VkExtent2D extent;
1035 };
1036
1037 beginRenderPass(vk, commandBuffer, renderPass, framebuffer, renderArea, tcu::Vec4(0.0f), 0.0f, 0u);
1038 }
1039
1040 } // image
1041 } // vkt
1042