1 /*-------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2015 Google Inc.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and/or associated documentation files (the
9 * "Materials"), to deal in the Materials without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Materials, and to
12 * permit persons to whom the Materials are furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice(s) and this permission notice shall be
16 * included in all copies or substantial portions of the Materials.
18 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
28 * \brief Simple Smoke Tests
29 *//*--------------------------------------------------------------------*/
31 #include "vktApiTests.hpp"
33 #include "vktTestCaseUtil.hpp"
36 #include "vkPlatform.hpp"
37 #include "vkStrUtil.hpp"
39 #include "vkRefUtil.hpp"
40 #include "vkQueryUtil.hpp"
41 #include "vkMemUtil.hpp"
42 #include "vkDeviceUtil.hpp"
43 #include "vkPrograms.hpp"
44 #include "vkTypeUtil.hpp"
46 #include "tcuTestLog.hpp"
47 #include "tcuFormatUtil.hpp"
49 #include "deUniquePtr.hpp"
64 tcu::TestStatus createSamplerTest (Context& context)
66 const VkDevice vkDevice = context.getDevice();
67 const DeviceInterface& vk = context.getDeviceInterface();
70 const struct VkSamplerCreateInfo samplerInfo =
72 VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, // sType
75 VK_FILTER_NEAREST, // magFilter
76 VK_FILTER_NEAREST, // minFilter
77 VK_SAMPLER_MIPMAP_MODE_NEAREST, // mipmapMode
78 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // addressModeU
79 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // addressModeV
80 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // addressModeW
82 VK_FALSE, // anisotropyEnable
83 1.0f, // maxAnisotropy
84 DE_FALSE, // compareEnable
85 VK_COMPARE_OP_ALWAYS, // compareOp
88 VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK, // borderColor
89 VK_FALSE, // unnormalizedCoords
92 Move<VkSampler> tmpSampler = createSampler(vk, vkDevice, &samplerInfo);
93 Move<VkSampler> tmp2Sampler;
95 tmp2Sampler = tmpSampler;
97 const Unique<VkSampler> sampler (tmp2Sampler);
100 return tcu::TestStatus::pass("Creating sampler succeeded");
103 void createShaderProgs (SourceCollections& dst)
105 dst.glslSources.add("test") << glu::VertexSource(
107 "in highp vec4 a_position;\n"
108 "void main (void) { gl_Position = a_position; }\n");
111 tcu::TestStatus createShaderModuleTest (Context& context)
113 const VkDevice vkDevice = context.getDevice();
114 const DeviceInterface& vk = context.getDeviceInterface();
115 const Unique<VkShaderModule> shader (createShaderModule(vk, vkDevice, context.getBinaryCollection().get("test"), 0));
117 return tcu::TestStatus::pass("Creating shader module succeeded");
120 void createTriangleAsmProgs (SourceCollections& dst)
122 dst.spirvAsmSources.add("vert") <<
123 " OpCapability Shader\n"
124 "%1 = OpExtInstImport \"GLSL.std.450\"\n"
125 " OpMemoryModel Logical GLSL450\n"
126 " OpEntryPoint Vertex %4 \"main\" %10 %12 %16 %17\n"
127 " OpSource ESSL 300\n"
128 " OpName %4 \"main\"\n"
129 " OpName %10 \"gl_Position\"\n"
130 " OpName %12 \"a_position\"\n"
131 " OpName %16 \"gl_VertexIndex\"\n"
132 " OpName %17 \"gl_InstanceIndex\"\n"
133 " OpDecorate %10 BuiltIn Position\n"
134 " OpDecorate %12 Location 0\n"
135 " OpDecorate %16 BuiltIn VertexIndex\n"
136 " OpDecorate %17 BuiltIn InstanceIndex\n"
138 "%3 = OpTypeFunction %2\n"
139 "%7 = OpTypeFloat 32\n"
140 "%8 = OpTypeVector %7 4\n"
141 "%9 = OpTypePointer Output %8\n"
142 "%10 = OpVariable %9 Output\n"
143 "%11 = OpTypePointer Input %8\n"
144 "%12 = OpVariable %11 Input\n"
145 "%14 = OpTypeInt 32 1\n"
146 "%15 = OpTypePointer Input %14\n"
147 "%16 = OpVariable %15 Input\n"
148 "%17 = OpVariable %15 Input\n"
149 "%4 = OpFunction %2 None %3\n"
151 "%13 = OpLoad %8 %12\n"
157 dst.spirvAsmSources.add("frag") <<
158 " OpCapability Shader\n"
159 "%1 = OpExtInstImport \"GLSL.std.450\"\n"
160 " OpMemoryModel Logical GLSL450\n"
161 " OpEntryPoint Fragment %4 \"main\" %10\n"
162 " OpExecutionMode %4 OriginLowerLeft\n"
163 " OpSource ESSL 300\n"
164 " OpName %4 \"main\"\n"
165 " OpName %10 \"o_color\"\n"
166 " OpDecorate %10 RelaxedPrecision\n"
167 " OpDecorate %10 Location 0\n"
169 "%3 = OpTypeFunction %2\n"
170 "%7 = OpTypeFloat 32\n"
171 "%8 = OpTypeVector %7 4\n"
172 "%9 = OpTypePointer Output %8\n"
173 "%10 = OpVariable %9 Output\n"
174 "%11 = OpConstant %7 1065353216\n"
175 "%12 = OpConstant %7 0\n"
176 "%13 = OpConstantComposite %8 %11 %12 %11 %11\n"
177 "%4 = OpFunction %2 None %3\n"
186 void createTriangleProgs (SourceCollections& dst)
188 dst.glslSources.add("vert") << glu::VertexSource(
190 "layout(location = 0) in highp vec4 a_position;\n"
191 "void main (void) { gl_Position = a_position; }\n");
192 dst.glslSources.add("frag") << glu::FragmentSource(
194 "layout(location = 0) out lowp vec4 o_color;\n"
195 "void main (void) { o_color = vec4(1.0, 0.0, 1.0, 1.0); }\n");
198 tcu::TestStatus renderTriangleTest (Context& context)
200 const VkDevice vkDevice = context.getDevice();
201 const DeviceInterface& vk = context.getDeviceInterface();
202 const VkQueue queue = context.getUniversalQueue();
203 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
204 SimpleAllocator memAlloc (vk, vkDevice, getPhysicalDeviceMemoryProperties(context.getInstanceInterface(), context.getPhysicalDevice()));
205 const tcu::IVec2 renderSize (256, 256);
207 const tcu::Vec4 vertices[] =
209 tcu::Vec4(-0.5f, -0.5f, 0.0f, 1.0f),
210 tcu::Vec4(+0.5f, -0.5f, 0.0f, 1.0f),
211 tcu::Vec4( 0.0f, +0.5f, 0.0f, 1.0f)
214 const VkBufferCreateInfo vertexBufferParams =
216 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // sType
219 (VkDeviceSize)sizeof(vertices), // size
220 VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, // usage
221 VK_SHARING_MODE_EXCLUSIVE, // sharingMode
222 1u, // queueFamilyIndexCount
223 &queueFamilyIndex, // pQueueFamilyIndices
225 const Unique<VkBuffer> vertexBuffer (createBuffer(vk, vkDevice, &vertexBufferParams));
226 const UniquePtr<Allocation> vertexBufferMemory (memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *vertexBuffer), MemoryRequirement::HostVisible));
228 VK_CHECK(vk.bindBufferMemory(vkDevice, *vertexBuffer, vertexBufferMemory->getMemory(), vertexBufferMemory->getOffset()));
230 const VkDeviceSize imageSizeBytes = (VkDeviceSize)(sizeof(deUint32)*renderSize.x()*renderSize.y());
231 const VkBufferCreateInfo readImageBufferParams =
233 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // sType
235 (VkBufferCreateFlags)0u, // flags
236 imageSizeBytes, // size
237 VK_BUFFER_USAGE_TRANSFER_DST_BIT, // usage
238 VK_SHARING_MODE_EXCLUSIVE, // sharingMode
239 1u, // queueFamilyIndexCount
240 &queueFamilyIndex, // pQueueFamilyIndices
242 const Unique<VkBuffer> readImageBuffer (createBuffer(vk, vkDevice, &readImageBufferParams));
243 const UniquePtr<Allocation> readImageBufferMemory (memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *readImageBuffer), MemoryRequirement::HostVisible));
245 VK_CHECK(vk.bindBufferMemory(vkDevice, *readImageBuffer, readImageBufferMemory->getMemory(), readImageBufferMemory->getOffset()));
247 const VkImageCreateInfo imageParams =
249 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // sType
252 VK_IMAGE_TYPE_2D, // imageType
253 VK_FORMAT_R8G8B8A8_UNORM, // format
254 { (deUint32)renderSize.x(), (deUint32)renderSize.y(), 1 }, // extent
257 VK_SAMPLE_COUNT_1_BIT, // samples
258 VK_IMAGE_TILING_OPTIMAL, // tiling
259 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT, // usage
260 VK_SHARING_MODE_EXCLUSIVE, // sharingMode
261 1u, // queueFamilyIndexCount
262 &queueFamilyIndex, // pQueueFamilyIndices
263 VK_IMAGE_LAYOUT_UNDEFINED, // initialLayout
266 const Unique<VkImage> image (createImage(vk, vkDevice, &imageParams));
267 const UniquePtr<Allocation> imageMemory (memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *image), MemoryRequirement::Any));
269 VK_CHECK(vk.bindImageMemory(vkDevice, *image, imageMemory->getMemory(), imageMemory->getOffset()));
271 const VkAttachmentDescription colorAttDesc =
274 VK_FORMAT_R8G8B8A8_UNORM, // format
275 VK_SAMPLE_COUNT_1_BIT, // samples
276 VK_ATTACHMENT_LOAD_OP_CLEAR, // loadOp
277 VK_ATTACHMENT_STORE_OP_STORE, // storeOp
278 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // stencilLoadOp
279 VK_ATTACHMENT_STORE_OP_DONT_CARE, // stencilStoreOp
280 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // initialLayout
281 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // finalLayout
283 const VkAttachmentReference colorAttRef =
286 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // layout
288 const VkSubpassDescription subpassDesc =
290 (VkSubpassDescriptionFlags)0u, // flags
291 VK_PIPELINE_BIND_POINT_GRAPHICS, // pipelineBindPoint
292 0u, // inputAttachmentCount
293 DE_NULL, // pInputAttachments
294 1u, // colorAttachmentCount
295 &colorAttRef, // pColorAttachments
296 DE_NULL, // pResolveAttachments
297 DE_NULL, // depthStencilAttachment
298 0u, // preserveAttachmentCount
299 DE_NULL, // pPreserveAttachments
301 const VkRenderPassCreateInfo renderPassParams =
303 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // sType
306 1u, // attachmentCount
307 &colorAttDesc, // pAttachments
309 &subpassDesc, // pSubpasses
310 0u, // dependencyCount
311 DE_NULL, // pDependencies
313 const Unique<VkRenderPass> renderPass (createRenderPass(vk, vkDevice, &renderPassParams));
315 const VkImageViewCreateInfo colorAttViewParams =
317 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // sType
321 VK_IMAGE_VIEW_TYPE_2D, // viewType
322 VK_FORMAT_R8G8B8A8_UNORM, // format
324 VK_COMPONENT_SWIZZLE_R,
325 VK_COMPONENT_SWIZZLE_G,
326 VK_COMPONENT_SWIZZLE_B,
327 VK_COMPONENT_SWIZZLE_A
330 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
333 0u, // baseArrayLayer
335 }, // subresourceRange
337 const Unique<VkImageView> colorAttView (createImageView(vk, vkDevice, &colorAttViewParams));
340 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
342 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // sType
344 (vk::VkPipelineLayoutCreateFlags)0,
345 0u, // setLayoutCount
346 DE_NULL, // pSetLayouts
347 0u, // pushConstantRangeCount
348 DE_NULL, // pPushConstantRanges
350 const Unique<VkPipelineLayout> pipelineLayout (createPipelineLayout(vk, vkDevice, &pipelineLayoutParams));
353 const Unique<VkShaderModule> vertShaderModule (createShaderModule(vk, vkDevice, context.getBinaryCollection().get("vert"), 0));
354 const Unique<VkShaderModule> fragShaderModule (createShaderModule(vk, vkDevice, context.getBinaryCollection().get("frag"), 0));
357 const VkSpecializationInfo emptyShaderSpecParams =
364 const VkPipelineShaderStageCreateInfo shaderStageParams[] =
367 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // sType
370 VK_SHADER_STAGE_VERTEX_BIT, // stage
371 *vertShaderModule, // module
373 &emptyShaderSpecParams, // pSpecializationInfo
376 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // sType
379 VK_SHADER_STAGE_FRAGMENT_BIT, // stage
380 *fragShaderModule, // module
382 &emptyShaderSpecParams, // pSpecializationInfo
385 const VkPipelineDepthStencilStateCreateInfo depthStencilParams =
387 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // sType
390 DE_FALSE, // depthTestEnable
391 DE_FALSE, // depthWriteEnable
392 VK_COMPARE_OP_ALWAYS, // depthCompareOp
393 DE_FALSE, // depthBoundsTestEnable
394 DE_FALSE, // stencilTestEnable
396 VK_STENCIL_OP_KEEP, // failOp
397 VK_STENCIL_OP_KEEP, // passOp
398 VK_STENCIL_OP_KEEP, // depthFailOp
399 VK_COMPARE_OP_ALWAYS, // compareOp
405 VK_STENCIL_OP_KEEP, // failOp
406 VK_STENCIL_OP_KEEP, // passOp
407 VK_STENCIL_OP_KEEP, // depthFailOp
408 VK_COMPARE_OP_ALWAYS, // compareOp
413 -1.0f, // float minDepthBounds;
414 +1.0f, // float maxDepthBounds;
416 const VkViewport viewport0 =
420 (float)renderSize.x(), // width
421 (float)renderSize.y(), // height
425 const VkRect2D scissor0 =
432 (deUint32)renderSize.x(), // width
433 (deUint32)renderSize.y(), // height
436 const VkPipelineViewportStateCreateInfo viewportParams =
438 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // sType
442 &viewport0, // pViewports
444 &scissor0 // pScissors
446 const VkSampleMask sampleMask = ~0u;
447 const VkPipelineMultisampleStateCreateInfo multisampleParams =
449 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // sType
452 VK_SAMPLE_COUNT_1_BIT, // rasterizationSamples
453 VK_FALSE, // sampleShadingEnable
454 0.0f, // minSampleShading
455 &sampleMask, // sampleMask
456 VK_FALSE, // alphaToCoverageEnable
457 VK_FALSE, // alphaToOneEnable
459 const VkPipelineRasterizationStateCreateInfo rasterParams =
461 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // sType
464 VK_TRUE, // depthClampEnable
465 VK_FALSE, // rasterizerDiscardEnable
466 VK_POLYGON_MODE_FILL, // polygonMode
467 VK_CULL_MODE_NONE, // cullMode
468 VK_FRONT_FACE_COUNTER_CLOCKWISE, // frontFace
469 VK_FALSE, // depthBiasEnable
470 0.0f, // depthBiasConstantFactor
471 0.0f, // depthBiasClamp
472 0.0f, // depthBiasSlopeFactor
475 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyParams =
477 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // sType
480 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, // topology
481 DE_FALSE, // primitiveRestartEnable
483 const VkVertexInputBindingDescription vertexBinding0 =
486 (deUint32)sizeof(tcu::Vec4), // stride
487 VK_VERTEX_INPUT_RATE_VERTEX, // inputRate
489 const VkVertexInputAttributeDescription vertexAttrib0 =
493 VK_FORMAT_R32G32B32A32_SFLOAT, // format
496 const VkPipelineVertexInputStateCreateInfo vertexInputStateParams =
498 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // sType
501 1u, // vertexBindingDescriptionCount
502 &vertexBinding0, // pVertexBindingDescriptions
503 1u, // vertexAttributeDescriptionCount
504 &vertexAttrib0, // pVertexAttributeDescriptions
506 const VkPipelineColorBlendAttachmentState attBlendParams =
508 VK_FALSE, // blendEnable
509 VK_BLEND_FACTOR_ONE, // srcColorBlendFactor
510 VK_BLEND_FACTOR_ZERO, // dstColorBlendFactor
511 VK_BLEND_OP_ADD, // colorBlendOp
512 VK_BLEND_FACTOR_ONE, // srcAlphaBlendFactor
513 VK_BLEND_FACTOR_ZERO, // dstAlphaBlendFactor
514 VK_BLEND_OP_ADD, // alphaBlendOp
515 (VK_COLOR_COMPONENT_R_BIT|
516 VK_COLOR_COMPONENT_G_BIT|
517 VK_COLOR_COMPONENT_B_BIT|
518 VK_COLOR_COMPONENT_A_BIT), // colorWriteMask
520 const VkPipelineColorBlendStateCreateInfo blendParams =
522 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // sType
525 DE_FALSE, // logicOpEnable
526 VK_LOGIC_OP_COPY, // logicOp
527 1u, // attachmentCount
528 &attBlendParams, // pAttachments
529 { 0.0f, 0.0f, 0.0f, 0.0f }, // blendConstants[4]
531 const VkPipelineDynamicStateCreateInfo dynamicStateInfo =
533 VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, // sType
536 0u, // dynamicStateCount
537 DE_NULL // pDynamicStates
539 const VkGraphicsPipelineCreateInfo pipelineParams =
541 VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // sType
544 (deUint32)DE_LENGTH_OF_ARRAY(shaderStageParams), // stageCount
545 shaderStageParams, // pStages
546 &vertexInputStateParams, // pVertexInputState
547 &inputAssemblyParams, // pInputAssemblyState
548 DE_NULL, // pTessellationState
549 &viewportParams, // pViewportState
550 &rasterParams, // pRasterizationState
551 &multisampleParams, // pMultisampleState
552 &depthStencilParams, // pDepthStencilState
553 &blendParams, // pColorBlendState
554 &dynamicStateInfo, // pDynamicState
555 *pipelineLayout, // layout
556 *renderPass, // renderPass
558 DE_NULL, // basePipelineHandle
559 0u, // basePipelineIndex
562 const Unique<VkPipeline> pipeline (createGraphicsPipeline(vk, vkDevice, DE_NULL, &pipelineParams));
565 const VkFramebufferCreateInfo framebufferParams =
567 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // sType
570 *renderPass, // renderPass
571 1u, // attachmentCount
572 &*colorAttView, // pAttachments
573 (deUint32)renderSize.x(), // width
574 (deUint32)renderSize.y(), // height
577 const Unique<VkFramebuffer> framebuffer (createFramebuffer(vk, vkDevice, &framebufferParams));
579 const VkCommandPoolCreateInfo cmdPoolParams =
581 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // sType
583 VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, // flags
584 queueFamilyIndex, // queueFamilyIndex
586 const Unique<VkCommandPool> cmdPool (createCommandPool(vk, vkDevice, &cmdPoolParams));
589 const VkCommandBufferAllocateInfo cmdBufParams =
591 VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // sType
594 VK_COMMAND_BUFFER_LEVEL_PRIMARY, // level
597 const Unique<VkCommandBuffer> cmdBuf (allocateCommandBuffer(vk, vkDevice, &cmdBufParams));
599 const VkCommandBufferBeginInfo cmdBufBeginParams =
601 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // sType
604 (const VkCommandBufferInheritanceInfo*)DE_NULL,
608 VK_CHECK(vk.beginCommandBuffer(*cmdBuf, &cmdBufBeginParams));
611 const VkMemoryBarrier vertFlushBarrier =
613 VK_STRUCTURE_TYPE_MEMORY_BARRIER, // sType
615 VK_ACCESS_HOST_WRITE_BIT, // srcAccessMask
616 VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT, // dstAccessMask
618 const VkImageMemoryBarrier colorAttBarrier =
620 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
623 (VK_ACCESS_COLOR_ATTACHMENT_READ_BIT|
624 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT), // dstAccessMask
625 VK_IMAGE_LAYOUT_UNDEFINED, // oldLayout
626 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // newLayout
627 queueFamilyIndex, // srcQueueFamilyIndex
628 queueFamilyIndex, // dstQueueFamilyIndex
631 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
634 0u, // baseArrayLayer
636 } // subresourceRange
638 vk.cmdPipelineBarrier(*cmdBuf, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, (VkDependencyFlags)0, 1, &vertFlushBarrier, 0, (const VkBufferMemoryBarrier*)DE_NULL, 1, &colorAttBarrier);
642 const VkClearValue clearValue = makeClearValueColorF32(0.125f, 0.25f, 0.75f, 1.0f);
643 const VkRenderPassBeginInfo passBeginParams =
645 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // sType
647 *renderPass, // renderPass
648 *framebuffer, // framebuffer
651 { (deUint32)renderSize.x(), (deUint32)renderSize.y() }
653 1u, // clearValueCount
654 &clearValue, // pClearValues
656 vk.cmdBeginRenderPass(*cmdBuf, &passBeginParams, VK_SUBPASS_CONTENTS_INLINE);
659 vk.cmdBindPipeline(*cmdBuf, VK_PIPELINE_BIND_POINT_GRAPHICS, *pipeline);
661 const VkDeviceSize bindingOffset = 0;
662 vk.cmdBindVertexBuffers(*cmdBuf, 0u, 1u, &vertexBuffer.get(), &bindingOffset);
664 vk.cmdDraw(*cmdBuf, 3u, 1u, 0u, 0u);
665 vk.cmdEndRenderPass(*cmdBuf);
668 const VkImageMemoryBarrier renderFinishBarrier =
670 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
672 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // outputMask
673 VK_ACCESS_TRANSFER_READ_BIT, // inputMask
674 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // oldLayout
675 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // newLayout
676 queueFamilyIndex, // srcQueueFamilyIndex
677 queueFamilyIndex, // dstQueueFamilyIndex
680 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
683 0u, // baseArraySlice
685 } // subresourceRange
687 vk.cmdPipelineBarrier(*cmdBuf, VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 0, (const VkBufferMemoryBarrier*)DE_NULL, 1, &renderFinishBarrier);
691 const VkBufferImageCopy copyParams =
693 (VkDeviceSize)0u, // bufferOffset
694 (deUint32)renderSize.x(), // bufferRowLength
695 (deUint32)renderSize.y(), // bufferImageHeight
697 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
699 0u, // baseArrayLayer
701 }, // imageSubresource
702 { 0u, 0u, 0u }, // imageOffset
704 (deUint32)renderSize.x(),
705 (deUint32)renderSize.y(),
709 vk.cmdCopyImageToBuffer(*cmdBuf, *image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *readImageBuffer, 1u, ©Params);
713 const VkBufferMemoryBarrier copyFinishBarrier =
715 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // sType
717 VK_ACCESS_TRANSFER_WRITE_BIT, // srcAccessMask
718 VK_ACCESS_HOST_READ_BIT, // dstAccessMask
719 queueFamilyIndex, // srcQueueFamilyIndex
720 queueFamilyIndex, // dstQueueFamilyIndex
721 *readImageBuffer, // buffer
723 imageSizeBytes // size
725 vk.cmdPipelineBarrier(*cmdBuf, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_HOST_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 1, ©FinishBarrier, 0, (const VkImageMemoryBarrier*)DE_NULL);
728 VK_CHECK(vk.endCommandBuffer(*cmdBuf));
730 // Upload vertex data
732 const VkMappedMemoryRange range =
734 VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // sType
736 vertexBufferMemory->getMemory(), // memory
738 (VkDeviceSize)sizeof(vertices), // size
740 void* vertexBufPtr = vertexBufferMemory->getHostPtr();
742 deMemcpy(vertexBufPtr, &vertices[0], sizeof(vertices));
743 VK_CHECK(vk.flushMappedMemoryRanges(vkDevice, 1u, &range));
746 // Submit & wait for completion
748 const VkFenceCreateInfo fenceParams =
750 VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, // sType
754 const VkSubmitInfo submitInfo =
756 VK_STRUCTURE_TYPE_SUBMIT_INFO, // sType
758 0u, // waitSemaphoreCount
759 DE_NULL, // pWaitSemaphores
760 (const VkPipelineStageFlags*)DE_NULL,
761 1u, // commandBufferCount
762 &cmdBuf.get(), // pCommandBuffers
763 0u, // signalSemaphoreCount
764 DE_NULL, // pSignalSemaphores
766 const Unique<VkFence> fence (createFence(vk, vkDevice, &fenceParams));
768 VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, *fence));
769 VK_CHECK(vk.waitForFences(vkDevice, 1u, &fence.get(), DE_TRUE, ~0ull));
774 const VkMappedMemoryRange range =
776 VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // sType
778 readImageBufferMemory->getMemory(), // memory
780 imageSizeBytes, // size
782 void* imagePtr = readImageBufferMemory->getHostPtr();
784 VK_CHECK(vk.invalidateMappedMemoryRanges(vkDevice, 1u, &range));
785 context.getTestContext().getLog() << TestLog::Image("Result", "Result", tcu::ConstPixelBufferAccess(tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), renderSize.x(), renderSize.y(), 1, imagePtr));
788 return tcu::TestStatus::pass("Rendering succeeded");
793 tcu::TestCaseGroup* createSmokeTests (tcu::TestContext& testCtx)
795 de::MovePtr<tcu::TestCaseGroup> smokeTests (new tcu::TestCaseGroup(testCtx, "smoke", "Smoke Tests"));
797 addFunctionCase (smokeTests.get(), "create_sampler", "", createSamplerTest);
798 addFunctionCaseWithPrograms (smokeTests.get(), "create_shader", "", createShaderProgs, createShaderModuleTest);
799 addFunctionCaseWithPrograms (smokeTests.get(), "triangle", "", createTriangleProgs, renderTriangleTest);
800 addFunctionCaseWithPrograms (smokeTests.get(), "asm_triangle", "", createTriangleAsmProgs, renderTriangleTest);
802 return smokeTests.release();