1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2016 The Khronos Group Inc.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 * \file vktPipelineMultisampleBaseResolve.cpp
21 * \brief Base class for tests that check results of multisample resolve
22 *//*--------------------------------------------------------------------*/
24 #include "vktPipelineMultisampleBaseResolve.hpp"
25 #include "vktPipelineMakeUtil.hpp"
26 #include "vkBuilderUtil.hpp"
27 #include "vkQueryUtil.hpp"
28 #include "tcuTestLog.hpp"
40 tcu::TestStatus MSInstanceBaseResolve::iterate (void)
42 const InstanceInterface& instance = m_context.getInstanceInterface();
43 const DeviceInterface& deviceInterface = m_context.getDeviceInterface();
44 const VkDevice device = m_context.getDevice();
45 const VkPhysicalDevice physicalDevice = m_context.getPhysicalDevice();
46 Allocator& allocator = m_context.getDefaultAllocator();
47 const VkQueue queue = m_context.getUniversalQueue();
48 const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
50 VkImageCreateInfo imageMSInfo;
51 VkImageCreateInfo imageRSInfo;
53 // Check if image size does not exceed device limits
54 validateImageSize(instance, physicalDevice, m_imageType, m_imageMSParams.imageSize);
56 // Check if device supports image format as color attachment
57 validateImageFeatureFlags(instance, physicalDevice, mapTextureFormat(m_imageFormat), VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT);
59 imageMSInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
60 imageMSInfo.pNext = DE_NULL;
61 imageMSInfo.flags = 0u;
62 imageMSInfo.imageType = mapImageType(m_imageType);
63 imageMSInfo.format = mapTextureFormat(m_imageFormat);
64 imageMSInfo.extent = makeExtent3D(getLayerSize(m_imageType, m_imageMSParams.imageSize));
65 imageMSInfo.arrayLayers = getNumLayers(m_imageType, m_imageMSParams.imageSize);
66 imageMSInfo.mipLevels = 1u;
67 imageMSInfo.samples = m_imageMSParams.numSamples;
68 imageMSInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
69 imageMSInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
70 imageMSInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
71 imageMSInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
72 imageMSInfo.queueFamilyIndexCount = 0u;
73 imageMSInfo.pQueueFamilyIndices = DE_NULL;
75 if (m_imageType == IMAGE_TYPE_CUBE || m_imageType == IMAGE_TYPE_CUBE_ARRAY)
77 imageMSInfo.flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
80 validateImageInfo(instance, physicalDevice, imageMSInfo);
82 const de::UniquePtr<Image> imageMS(new Image(deviceInterface, device, allocator, imageMSInfo, MemoryRequirement::Any));
84 imageRSInfo = imageMSInfo;
85 imageRSInfo.samples = VK_SAMPLE_COUNT_1_BIT;
87 validateImageInfo(instance, physicalDevice, imageRSInfo);
89 const de::UniquePtr<Image> imageRS(new Image(deviceInterface, device, allocator, imageRSInfo, MemoryRequirement::Any));
92 const VkAttachmentDescription attachmentMSDesc =
94 (VkAttachmentDescriptionFlags)0u, // VkAttachmentDescriptionFlags flags;
95 imageMSInfo.format, // VkFormat format;
96 imageMSInfo.samples, // VkSampleCountFlagBits samples;
97 VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp;
98 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
99 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp;
100 VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp;
101 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout;
102 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout;
105 const VkAttachmentDescription attachmentRSDesc =
107 (VkAttachmentDescriptionFlags)0u, // VkAttachmentDescriptionFlags flags;
108 imageRSInfo.format, // VkFormat format;
109 imageRSInfo.samples, // VkSampleCountFlagBits samples;
110 VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp;
111 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
112 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp;
113 VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp;
114 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout;
115 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout;
118 const VkAttachmentDescription attachments[] = { attachmentMSDesc, attachmentRSDesc };
120 const VkAttachmentReference attachmentMSRef =
122 0u, // deUint32 attachment;
123 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout layout;
126 const VkAttachmentReference attachmentRSRef =
128 1u, // deUint32 attachment;
129 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout layout;
132 const VkAttachmentReference* resolveAttachment = m_imageMSParams.numSamples == VK_SAMPLE_COUNT_1_BIT ? DE_NULL : &attachmentRSRef;
134 const VkSubpassDescription subpassDescription =
136 (VkSubpassDescriptionFlags)0u, // VkSubpassDescriptionFlags flags;
137 VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint;
138 0u, // deUint32 inputAttachmentCount;
139 DE_NULL, // const VkAttachmentReference* pInputAttachments;
140 1u, // deUint32 colorAttachmentCount;
141 &attachmentMSRef, // const VkAttachmentReference* pColorAttachments;
142 resolveAttachment, // const VkAttachmentReference* pResolveAttachments;
143 DE_NULL, // const VkAttachmentReference* pDepthStencilAttachment;
144 0u, // deUint32 preserveAttachmentCount;
145 DE_NULL // const deUint32* pPreserveAttachments;
148 const VkRenderPassCreateInfo renderPassInfo =
150 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType;
151 DE_NULL, // const void* pNext;
152 (VkRenderPassCreateFlags)0u, // VkRenderPassCreateFlags flags;
153 2u, // deUint32 attachmentCount;
154 attachments, // const VkAttachmentDescription* pAttachments;
155 1u, // deUint32 subpassCount;
156 &subpassDescription, // const VkSubpassDescription* pSubpasses;
157 0u, // deUint32 dependencyCount;
158 DE_NULL // const VkSubpassDependency* pDependencies;
161 const Unique<VkRenderPass> renderPass(createRenderPass(deviceInterface, device, &renderPassInfo));
163 const VkImageSubresourceRange fullImageRange = makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, imageMSInfo.mipLevels, 0u, imageMSInfo.arrayLayers);
165 // Create color attachments image views
166 const Unique<VkImageView> imageMSView(makeImageView(deviceInterface, device, **imageMS, mapImageViewType(m_imageType), imageMSInfo.format, fullImageRange));
167 const Unique<VkImageView> imageRSView(makeImageView(deviceInterface, device, **imageRS, mapImageViewType(m_imageType), imageMSInfo.format, fullImageRange));
169 const VkImageView attachmentsViews[] = { *imageMSView, *imageRSView };
171 // Create framebuffer
172 const VkFramebufferCreateInfo framebufferInfo =
174 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType;
175 DE_NULL, // const void* pNext;
176 (VkFramebufferCreateFlags)0u, // VkFramebufferCreateFlags flags;
177 *renderPass, // VkRenderPass renderPass;
178 2u, // uint32_t attachmentCount;
179 attachmentsViews, // const VkImageView* pAttachments;
180 imageMSInfo.extent.width, // uint32_t width;
181 imageMSInfo.extent.height, // uint32_t height;
182 imageMSInfo.arrayLayers, // uint32_t layers;
185 const Unique<VkFramebuffer> framebuffer(createFramebuffer(deviceInterface, device, &framebufferInfo));
187 // Create pipeline layout
188 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
190 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // VkStructureType sType;
191 DE_NULL, // const void* pNext;
192 (VkPipelineLayoutCreateFlags)0u, // VkPipelineLayoutCreateFlags flags;
193 0u, // deUint32 setLayoutCount;
194 DE_NULL, // const VkDescriptorSetLayout* pSetLayouts;
195 0u, // deUint32 pushConstantRangeCount;
196 DE_NULL, // const VkPushConstantRange* pPushConstantRanges;
199 const Unique<VkPipelineLayout> pipelineLayout(createPipelineLayout(deviceInterface, device, &pipelineLayoutParams));
201 // Create vertex attributes data
202 const VertexDataDesc vertexDataDesc = getVertexDataDescripton();
204 de::SharedPtr<Buffer> vertexBuffer = de::SharedPtr<Buffer>(new Buffer(deviceInterface, device, allocator, makeBufferCreateInfo(vertexDataDesc.dataSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT), MemoryRequirement::HostVisible));
205 const Allocation& vertexBufferAllocation = vertexBuffer->getAllocation();
207 uploadVertexData(vertexBufferAllocation, vertexDataDesc);
209 flushMappedMemoryRange(deviceInterface, device, vertexBufferAllocation.getMemory(), vertexBufferAllocation.getOffset(), VK_WHOLE_SIZE);
211 const VkVertexInputBindingDescription vertexBinding =
213 0u, // deUint32 binding;
214 vertexDataDesc.dataStride, // deUint32 stride;
215 VK_VERTEX_INPUT_RATE_VERTEX // VkVertexInputRate inputRate;
218 const VkPipelineVertexInputStateCreateInfo vertexInputStateInfo =
220 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // VkStructureType sType;
221 DE_NULL, // const void* pNext;
222 (VkPipelineVertexInputStateCreateFlags)0u, // VkPipelineVertexInputStateCreateFlags flags;
223 1u, // uint32_t vertexBindingDescriptionCount;
224 &vertexBinding, // const VkVertexInputBindingDescription* pVertexBindingDescriptions;
225 static_cast<deUint32>(vertexDataDesc.vertexAttribDescVec.size()), // uint32_t vertexAttributeDescriptionCount;
226 dataPointer(vertexDataDesc.vertexAttribDescVec), // const VkVertexInputAttributeDescription* pVertexAttributeDescriptions;
229 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateInfo =
231 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // VkStructureType sType;
232 DE_NULL, // const void* pNext;
233 (VkPipelineInputAssemblyStateCreateFlags)0u, // VkPipelineInputAssemblyStateCreateFlags flags;
234 vertexDataDesc.primitiveTopology, // VkPrimitiveTopology topology;
235 VK_FALSE, // VkBool32 primitiveRestartEnable;
238 const VkViewport viewport =
241 static_cast<float>(imageMSInfo.extent.width), static_cast<float>(imageMSInfo.extent.height),
245 const VkRect2D scissor =
248 makeExtent2D(imageMSInfo.extent.width, imageMSInfo.extent.height),
251 const VkPipelineViewportStateCreateInfo viewportStateInfo =
253 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // VkStructureType sType;
254 DE_NULL, // const void* pNext;
255 (VkPipelineViewportStateCreateFlags)0u, // VkPipelineViewportStateCreateFlags flags;
256 1u, // uint32_t viewportCount;
257 &viewport, // const VkViewport* pViewports;
258 1u, // uint32_t scissorCount;
259 &scissor, // const VkRect2D* pScissors;
262 const VkPipelineRasterizationStateCreateInfo rasterizationStateInfo =
264 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // VkStructureType sType;
265 DE_NULL, // const void* pNext;
266 (VkPipelineRasterizationStateCreateFlags)0u, // VkPipelineRasterizationStateCreateFlags flags;
267 VK_FALSE, // VkBool32 depthClampEnable;
268 VK_FALSE, // VkBool32 rasterizerDiscardEnable;
269 VK_POLYGON_MODE_FILL, // VkPolygonMode polygonMode;
270 VK_CULL_MODE_NONE, // VkCullModeFlags cullMode;
271 VK_FRONT_FACE_COUNTER_CLOCKWISE, // VkFrontFace frontFace;
272 VK_FALSE, // VkBool32 depthBiasEnable;
273 0.0f, // float depthBiasConstantFactor;
274 0.0f, // float depthBiasClamp;
275 0.0f, // float depthBiasSlopeFactor;
276 1.0f, // float lineWidth;
279 const VkPipelineMultisampleStateCreateInfo multisampleStateInfo =
281 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // VkStructureType sType;
282 DE_NULL, // const void* pNext;
283 (VkPipelineMultisampleStateCreateFlags)0u, // VkPipelineMultisampleStateCreateFlags flags;
284 imageMSInfo.samples, // VkSampleCountFlagBits rasterizationSamples;
285 VK_TRUE, // VkBool32 sampleShadingEnable;
286 1.0f, // float minSampleShading;
287 DE_NULL, // const VkSampleMask* pSampleMask;
288 VK_FALSE, // VkBool32 alphaToCoverageEnable;
289 VK_FALSE, // VkBool32 alphaToOneEnable;
292 const VkStencilOpState stencilOpState = makeStencilOpState
294 VK_STENCIL_OP_KEEP, // stencil fail
295 VK_STENCIL_OP_KEEP, // depth & stencil pass
296 VK_STENCIL_OP_KEEP, // depth only fail
297 VK_COMPARE_OP_ALWAYS, // compare op
303 const VkPipelineDepthStencilStateCreateInfo depthStencilStateInfo =
305 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // VkStructureType sType;
306 DE_NULL, // const void* pNext;
307 (VkPipelineDepthStencilStateCreateFlags)0u, // VkPipelineDepthStencilStateCreateFlags flags;
308 VK_FALSE, // VkBool32 depthTestEnable;
309 VK_FALSE, // VkBool32 depthWriteEnable;
310 VK_COMPARE_OP_LESS, // VkCompareOp depthCompareOp;
311 VK_FALSE, // VkBool32 depthBoundsTestEnable;
312 VK_FALSE, // VkBool32 stencilTestEnable;
313 stencilOpState, // VkStencilOpState front;
314 stencilOpState, // VkStencilOpState back;
315 0.0f, // float minDepthBounds;
316 1.0f, // float maxDepthBounds;
319 const VkColorComponentFlags colorComponentsAll = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
321 const VkPipelineColorBlendAttachmentState colorBlendAttachmentState =
323 VK_FALSE, // VkBool32 blendEnable;
324 VK_BLEND_FACTOR_ONE, // VkBlendFactor srcColorBlendFactor;
325 VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstColorBlendFactor;
326 VK_BLEND_OP_ADD, // VkBlendOp colorBlendOp;
327 VK_BLEND_FACTOR_ONE, // VkBlendFactor srcAlphaBlendFactor;
328 VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstAlphaBlendFactor;
329 VK_BLEND_OP_ADD, // VkBlendOp alphaBlendOp;
330 colorComponentsAll, // VkColorComponentFlags colorWriteMask;
333 const VkPipelineColorBlendStateCreateInfo colorBlendStateInfo =
335 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // VkStructureType sType;
336 DE_NULL, // const void* pNext;
337 (VkPipelineColorBlendStateCreateFlags)0u, // VkPipelineColorBlendStateCreateFlags flags;
338 VK_FALSE, // VkBool32 logicOpEnable;
339 VK_LOGIC_OP_COPY, // VkLogicOp logicOp;
340 1u, // deUint32 attachmentCount;
341 &colorBlendAttachmentState, // const VkPipelineColorBlendAttachmentState* pAttachments;
342 { 0.0f, 0.0f, 0.0f, 0.0f }, // float blendConstants[4];
345 const Unique<VkShaderModule> vsModule(createShaderModule(deviceInterface, device, m_context.getBinaryCollection().get("vertex_shader"), (VkShaderModuleCreateFlags)0));
347 const VkPipelineShaderStageCreateInfo vsShaderStageInfo =
349 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
350 DE_NULL, // const void* pNext;
351 (VkPipelineShaderStageCreateFlags)0u, // VkPipelineShaderStageCreateFlags flags;
352 VK_SHADER_STAGE_VERTEX_BIT, // VkShaderStageFlagBits stage;
353 *vsModule, // VkShaderModule module;
354 "main", // const char* pName;
355 DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
358 const Unique<VkShaderModule> fsModule(createShaderModule(deviceInterface, device, m_context.getBinaryCollection().get("fragment_shader"), (VkShaderModuleCreateFlags)0));
360 const VkPipelineShaderStageCreateInfo fsShaderStageInfo =
362 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
363 DE_NULL, // const void* pNext;
364 (VkPipelineShaderStageCreateFlags)0u, // VkPipelineShaderStageCreateFlags flags;
365 VK_SHADER_STAGE_FRAGMENT_BIT, // VkShaderStageFlagBits stage;
366 *fsModule, // VkShaderModule module;
367 "main", // const char* pName;
368 DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
371 const VkPipelineShaderStageCreateInfo shaderStageInfos[] = { vsShaderStageInfo, fsShaderStageInfo };
373 const VkGraphicsPipelineCreateInfo graphicsPipelineInfo =
375 VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // VkStructureType sType;
376 DE_NULL, // const void* pNext;
377 (VkPipelineCreateFlags)0, // VkPipelineCreateFlags flags;
378 2u, // deUint32 stageCount;
379 shaderStageInfos, // const VkPipelineShaderStageCreateInfo* pStages;
380 &vertexInputStateInfo, // const VkPipelineVertexInputStateCreateInfo* pVertexInputState;
381 &inputAssemblyStateInfo, // const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState;
382 DE_NULL, // const VkPipelineTessellationStateCreateInfo* pTessellationState;
383 &viewportStateInfo, // const VkPipelineViewportStateCreateInfo* pViewportState;
384 &rasterizationStateInfo, // const VkPipelineRasterizationStateCreateInfo* pRasterizationState;
385 &multisampleStateInfo, // const VkPipelineMultisampleStateCreateInfo* pMultisampleState;
386 &depthStencilStateInfo, // const VkPipelineDepthStencilStateCreateInfo* pDepthStencilState;
387 &colorBlendStateInfo, // const VkPipelineColorBlendStateCreateInfo* pColorBlendState;
388 DE_NULL, // const VkPipelineDynamicStateCreateInfo* pDynamicState;
389 *pipelineLayout, // VkPipelineLayout layout;
390 *renderPass, // VkRenderPass renderPass;
391 0u, // deUint32 subpass;
392 DE_NULL, // VkPipeline basePipelineHandle;
393 0u, // deInt32 basePipelineIndex;
396 // Create graphics pipeline
397 const Unique<VkPipeline> graphicsPipeline(createGraphicsPipeline(deviceInterface, device, DE_NULL, &graphicsPipelineInfo));
399 // Create command buffer for compute and transfer oparations
400 const Unique<VkCommandPool> commandPool(createCommandPool(deviceInterface, device, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, queueFamilyIndex));
401 const Unique<VkCommandBuffer> commandBuffer(makeCommandBuffer(deviceInterface, device, *commandPool));
403 // Start recording commands
404 beginCommandBuffer(deviceInterface, *commandBuffer);
407 VkImageMemoryBarrier imageOutputAttachmentBarriers[2];
409 imageOutputAttachmentBarriers[0] = makeImageMemoryBarrier
412 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
413 VK_IMAGE_LAYOUT_UNDEFINED,
414 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
419 imageOutputAttachmentBarriers[1] = makeImageMemoryBarrier
422 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
423 VK_IMAGE_LAYOUT_UNDEFINED,
424 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
429 deviceInterface.cmdPipelineBarrier(*commandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0u, 0u, DE_NULL, 0u, DE_NULL, 2u, imageOutputAttachmentBarriers);
433 const VkDeviceSize vertexStartOffset = 0u;
435 std::vector<VkClearValue> clearValues;
436 clearValues.push_back(makeClearValueColor(tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f)));
437 clearValues.push_back(makeClearValueColor(tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f)));
439 const vk::VkRect2D renderArea =
441 makeOffset2D(0u, 0u),
442 makeExtent2D(imageMSInfo.extent.width, imageMSInfo.extent.height),
446 const VkRenderPassBeginInfo renderPassBeginInfo =
448 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // VkStructureType sType;
449 DE_NULL, // const void* pNext;
450 *renderPass, // VkRenderPass renderPass;
451 *framebuffer, // VkFramebuffer framebuffer;
452 renderArea, // VkRect2D renderArea;
453 static_cast<deUint32>(clearValues.size()), // deUint32 clearValueCount;
454 &clearValues[0], // const VkClearValue* pClearValues;
457 deviceInterface.cmdBeginRenderPass(*commandBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
459 // Bind graphics pipeline
460 deviceInterface.cmdBindPipeline(*commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *graphicsPipeline);
462 // Bind vertex buffer
463 deviceInterface.cmdBindVertexBuffers(*commandBuffer, 0u, 1u, &vertexBuffer->get(), &vertexStartOffset);
465 // Draw full screen quad
466 deviceInterface.cmdDraw(*commandBuffer, vertexDataDesc.verticesCount, 1u, 0u, 0u);
469 deviceInterface.cmdEndRenderPass(*commandBuffer);
472 const VkImage sourceImage = m_imageMSParams.numSamples == VK_SAMPLE_COUNT_1_BIT ? **imageMS : **imageRS;
475 const VkImageMemoryBarrier imageTransferSrcBarrier = makeImageMemoryBarrier
477 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
478 VK_ACCESS_TRANSFER_READ_BIT,
479 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
480 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
485 deviceInterface.cmdPipelineBarrier(*commandBuffer, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0u, 0u, DE_NULL, 0u, DE_NULL, 1u, &imageTransferSrcBarrier);
488 // Copy data from resolve image to buffer
489 const deUint32 imageRSSizeInBytes = getImageSizeInBytes(imageRSInfo.extent, imageRSInfo.arrayLayers, m_imageFormat, imageRSInfo.mipLevels);
491 const VkBufferCreateInfo bufferRSInfo = makeBufferCreateInfo(imageRSSizeInBytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT);
492 const de::UniquePtr<Buffer> bufferRS(new Buffer(deviceInterface, device, allocator, bufferRSInfo, MemoryRequirement::HostVisible));
495 const VkBufferImageCopy bufferImageCopy =
497 0u, // VkDeviceSize bufferOffset;
498 0u, // deUint32 bufferRowLength;
499 0u, // deUint32 bufferImageHeight;
500 makeImageSubresourceLayers(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 0u, imageRSInfo.arrayLayers), // VkImageSubresourceLayers imageSubresource;
501 makeOffset3D(0, 0, 0), // VkOffset3D imageOffset;
502 imageRSInfo.extent, // VkExtent3D imageExtent;
505 deviceInterface.cmdCopyImageToBuffer(*commandBuffer, sourceImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, bufferRS->get(), 1u, &bufferImageCopy);
509 const VkBufferMemoryBarrier bufferRSHostReadBarrier = makeBufferMemoryBarrier
511 VK_ACCESS_TRANSFER_WRITE_BIT,
512 VK_ACCESS_HOST_READ_BIT,
518 deviceInterface.cmdPipelineBarrier(*commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_HOST_BIT, 0u, 0u, DE_NULL, 1u, &bufferRSHostReadBarrier, 0u, DE_NULL);
521 // End recording commands
522 VK_CHECK(deviceInterface.endCommandBuffer(*commandBuffer));
524 // Submit commands for execution and wait for completion
525 submitCommandsAndWait(deviceInterface, device, queue, *commandBuffer);
527 // Retrieve data from buffer to host memory
528 const Allocation& bufferRSAllocation = bufferRS->getAllocation();
530 invalidateMappedMemoryRange(deviceInterface, device, bufferRSAllocation.getMemory(), bufferRSAllocation.getOffset(), VK_WHOLE_SIZE);
532 const tcu::ConstPixelBufferAccess bufferRSData (m_imageFormat,
533 imageRSInfo.extent.width,
534 imageRSInfo.extent.height,
535 imageRSInfo.extent.depth * imageRSInfo.arrayLayers,
536 bufferRSAllocation.getHostPtr());
538 std::stringstream imageName;
539 imageName << getImageTypeName(m_imageType) << "_" << bufferRSData.getWidth() << "_" << bufferRSData.getHeight() << "_" << bufferRSData.getDepth() << std::endl;
541 m_context.getTestContext().getLog()
542 << tcu::TestLog::Section(imageName.str(), imageName.str())
543 << tcu::LogImage("image", "", bufferRSData)
544 << tcu::TestLog::EndSection;
546 return verifyImageData(imageRSInfo, bufferRSData);