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 Confidential Information as defined by the
19 * Khronos Membership Agreement until designated non-confidential by
20 * Khronos, at which point this condition clause shall be removed.
22 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
26 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
32 * \brief Simple Smoke Tests
33 *//*--------------------------------------------------------------------*/
35 #include "vktApiTests.hpp"
37 #include "vktTestCaseUtil.hpp"
40 #include "vkPlatform.hpp"
41 #include "vkStrUtil.hpp"
43 #include "vkRefUtil.hpp"
44 #include "vkQueryUtil.hpp"
45 #include "vkMemUtil.hpp"
46 #include "vkDeviceUtil.hpp"
47 #include "vkPrograms.hpp"
48 #include "vkTypeUtil.hpp"
50 #include "tcuTestLog.hpp"
51 #include "tcuFormatUtil.hpp"
53 #include "deUniquePtr.hpp"
68 tcu::TestStatus createSamplerTest (Context& context)
70 const VkDevice vkDevice = context.getDevice();
71 const DeviceInterface& vk = context.getDeviceInterface();
74 const struct VkSamplerCreateInfo samplerInfo =
76 VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, // sType
79 VK_FILTER_NEAREST, // magFilter
80 VK_FILTER_NEAREST, // minFilter
81 VK_SAMPLER_MIPMAP_MODE_NEAREST, // mipmapMode
82 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // addressModeU
83 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // addressModeV
84 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // addressModeW
86 VK_FALSE, // anisotropyEnable
87 1.0f, // maxAnisotropy
88 DE_FALSE, // compareEnable
89 VK_COMPARE_OP_ALWAYS, // compareOp
92 VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK, // borderColor
93 VK_FALSE, // unnormalizedCoords
96 Move<VkSampler> tmpSampler = createSampler(vk, vkDevice, &samplerInfo);
97 Move<VkSampler> tmp2Sampler;
99 tmp2Sampler = tmpSampler;
101 const Unique<VkSampler> sampler (tmp2Sampler);
104 return tcu::TestStatus::pass("Creating sampler succeeded");
107 void createShaderProgs (SourceCollections& dst)
109 dst.glslSources.add("test") << glu::VertexSource(
111 "in highp vec4 a_position;\n"
112 "void main (void) { gl_Position = a_position; }\n");
115 tcu::TestStatus createShaderModuleTest (Context& context)
117 const VkDevice vkDevice = context.getDevice();
118 const DeviceInterface& vk = context.getDeviceInterface();
119 const Unique<VkShaderModule> shader (createShaderModule(vk, vkDevice, context.getBinaryCollection().get("test"), 0));
121 return tcu::TestStatus::pass("Creating shader module succeeded");
124 void createTriangleAsmProgs (SourceCollections& dst)
126 dst.spirvAsmSources.add("vert") <<
127 " OpCapability Shader\n"
128 "%1 = OpExtInstImport \"GLSL.std.450\"\n"
129 " OpMemoryModel Logical GLSL450\n"
130 " OpEntryPoint Vertex %4 \"main\" %10 %12 %16 %17\n"
131 " OpSource ESSL 300\n"
132 " OpName %4 \"main\"\n"
133 " OpName %10 \"gl_Position\"\n"
134 " OpName %12 \"a_position\"\n"
135 " OpName %16 \"gl_VertexID\"\n"
136 " OpName %17 \"gl_InstanceID\"\n"
137 " OpDecorate %10 BuiltIn Position\n"
138 " OpDecorate %12 Location 0\n"
139 " OpDecorate %16 BuiltIn VertexId\n"
140 " OpDecorate %17 BuiltIn InstanceId\n"
142 "%3 = OpTypeFunction %2\n"
143 "%7 = OpTypeFloat 32\n"
144 "%8 = OpTypeVector %7 4\n"
145 "%9 = OpTypePointer Output %8\n"
146 "%10 = OpVariable %9 Output\n"
147 "%11 = OpTypePointer Input %8\n"
148 "%12 = OpVariable %11 Input\n"
149 "%14 = OpTypeInt 32 1\n"
150 "%15 = OpTypePointer Input %14\n"
151 "%16 = OpVariable %15 Input\n"
152 "%17 = OpVariable %15 Input\n"
153 "%4 = OpFunction %2 None %3\n"
155 "%13 = OpLoad %8 %12\n"
161 dst.spirvAsmSources.add("frag") <<
162 " OpCapability Shader\n"
163 "%1 = OpExtInstImport \"GLSL.std.450\"\n"
164 " OpMemoryModel Logical GLSL450\n"
165 " OpEntryPoint Fragment %4 \"main\" %10\n"
166 " OpExecutionMode %4 OriginLowerLeft\n"
167 " OpSource ESSL 300\n"
168 " OpName %4 \"main\"\n"
169 " OpName %10 \"o_color\"\n"
170 " OpDecorate %10 RelaxedPrecision\n"
171 " OpDecorate %10 Location 0\n"
173 "%3 = OpTypeFunction %2\n"
174 "%7 = OpTypeFloat 32\n"
175 "%8 = OpTypeVector %7 4\n"
176 "%9 = OpTypePointer Output %8\n"
177 "%10 = OpVariable %9 Output\n"
178 "%11 = OpConstant %7 1065353216\n"
179 "%12 = OpConstant %7 0\n"
180 "%13 = OpConstantComposite %8 %11 %12 %11 %11\n"
181 "%4 = OpFunction %2 None %3\n"
190 void createTriangleProgs (SourceCollections& dst)
192 dst.glslSources.add("vert") << glu::VertexSource(
194 "layout(location = 0) in highp vec4 a_position;\n"
195 "void main (void) { gl_Position = a_position; }\n");
196 dst.glslSources.add("frag") << glu::FragmentSource(
198 "layout(location = 0) out lowp vec4 o_color;\n"
199 "void main (void) { o_color = vec4(1.0, 0.0, 1.0, 1.0); }\n");
202 tcu::TestStatus renderTriangleTest (Context& context)
204 const VkDevice vkDevice = context.getDevice();
205 const DeviceInterface& vk = context.getDeviceInterface();
206 const VkQueue queue = context.getUniversalQueue();
207 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
208 SimpleAllocator memAlloc (vk, vkDevice, getPhysicalDeviceMemoryProperties(context.getInstanceInterface(), context.getPhysicalDevice()));
209 const tcu::IVec2 renderSize (256, 256);
211 const tcu::Vec4 vertices[] =
213 tcu::Vec4(-0.5f, -0.5f, 0.0f, 1.0f),
214 tcu::Vec4(+0.5f, -0.5f, 0.0f, 1.0f),
215 tcu::Vec4( 0.0f, +0.5f, 0.0f, 1.0f)
218 const VkBufferCreateInfo vertexBufferParams =
220 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // sType
223 (VkDeviceSize)sizeof(vertices), // size
224 VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, // usage
225 VK_SHARING_MODE_EXCLUSIVE, // sharingMode
226 1u, // queueFamilyIndexCount
227 &queueFamilyIndex, // pQueueFamilyIndices
229 const Unique<VkBuffer> vertexBuffer (createBuffer(vk, vkDevice, &vertexBufferParams));
230 const UniquePtr<Allocation> vertexBufferMemory (memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *vertexBuffer), MemoryRequirement::HostVisible));
232 VK_CHECK(vk.bindBufferMemory(vkDevice, *vertexBuffer, vertexBufferMemory->getMemory(), vertexBufferMemory->getOffset()));
234 const VkDeviceSize imageSizeBytes = (VkDeviceSize)(sizeof(deUint32)*renderSize.x()*renderSize.y());
235 const VkBufferCreateInfo readImageBufferParams =
237 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // sType
239 (VkBufferCreateFlags)0u, // flags
240 imageSizeBytes, // size
241 VK_BUFFER_USAGE_TRANSFER_DST_BIT, // usage
242 VK_SHARING_MODE_EXCLUSIVE, // sharingMode
243 1u, // queueFamilyIndexCount
244 &queueFamilyIndex, // pQueueFamilyIndices
246 const Unique<VkBuffer> readImageBuffer (createBuffer(vk, vkDevice, &readImageBufferParams));
247 const UniquePtr<Allocation> readImageBufferMemory (memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *readImageBuffer), MemoryRequirement::HostVisible));
249 VK_CHECK(vk.bindBufferMemory(vkDevice, *readImageBuffer, readImageBufferMemory->getMemory(), readImageBufferMemory->getOffset()));
251 const VkImageCreateInfo imageParams =
253 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // sType
256 VK_IMAGE_TYPE_2D, // imageType
257 VK_FORMAT_R8G8B8A8_UNORM, // format
258 { (deUint32)renderSize.x(), (deUint32)renderSize.y(), 1 }, // extent
261 VK_SAMPLE_COUNT_1_BIT, // samples
262 VK_IMAGE_TILING_OPTIMAL, // tiling
263 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT, // usage
264 VK_SHARING_MODE_EXCLUSIVE, // sharingMode
265 1u, // queueFamilyIndexCount
266 &queueFamilyIndex, // pQueueFamilyIndices
267 VK_IMAGE_LAYOUT_UNDEFINED, // initialLayout
270 const Unique<VkImage> image (createImage(vk, vkDevice, &imageParams));
271 const UniquePtr<Allocation> imageMemory (memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *image), MemoryRequirement::Any));
273 VK_CHECK(vk.bindImageMemory(vkDevice, *image, imageMemory->getMemory(), imageMemory->getOffset()));
275 const VkAttachmentDescription colorAttDesc =
278 VK_FORMAT_R8G8B8A8_UNORM, // format
279 VK_SAMPLE_COUNT_1_BIT, // samples
280 VK_ATTACHMENT_LOAD_OP_CLEAR, // loadOp
281 VK_ATTACHMENT_STORE_OP_STORE, // storeOp
282 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // stencilLoadOp
283 VK_ATTACHMENT_STORE_OP_DONT_CARE, // stencilStoreOp
284 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // initialLayout
285 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // finalLayout
287 const VkAttachmentReference colorAttRef =
290 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // layout
292 const VkSubpassDescription subpassDesc =
294 (VkSubpassDescriptionFlags)0u, // flags
295 VK_PIPELINE_BIND_POINT_GRAPHICS, // pipelineBindPoint
296 0u, // inputAttachmentCount
297 DE_NULL, // pInputAttachments
298 1u, // colorAttachmentCount
299 &colorAttRef, // pColorAttachments
300 DE_NULL, // pResolveAttachments
301 DE_NULL, // depthStencilAttachment
302 0u, // preserveAttachmentCount
303 DE_NULL, // pPreserveAttachments
305 const VkRenderPassCreateInfo renderPassParams =
307 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // sType
310 1u, // attachmentCount
311 &colorAttDesc, // pAttachments
313 &subpassDesc, // pSubpasses
314 0u, // dependencyCount
315 DE_NULL, // pDependencies
317 const Unique<VkRenderPass> renderPass (createRenderPass(vk, vkDevice, &renderPassParams));
319 const VkImageViewCreateInfo colorAttViewParams =
321 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // sType
325 VK_IMAGE_VIEW_TYPE_2D, // viewType
326 VK_FORMAT_R8G8B8A8_UNORM, // format
328 VK_COMPONENT_SWIZZLE_R,
329 VK_COMPONENT_SWIZZLE_G,
330 VK_COMPONENT_SWIZZLE_B,
331 VK_COMPONENT_SWIZZLE_A
334 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
337 0u, // baseArrayLayer
339 }, // subresourceRange
341 const Unique<VkImageView> colorAttView (createImageView(vk, vkDevice, &colorAttViewParams));
344 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
346 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // sType
348 (vk::VkPipelineLayoutCreateFlags)0,
349 0u, // setLayoutCount
350 DE_NULL, // pSetLayouts
351 0u, // pushConstantRangeCount
352 DE_NULL, // pPushConstantRanges
354 const Unique<VkPipelineLayout> pipelineLayout (createPipelineLayout(vk, vkDevice, &pipelineLayoutParams));
357 const Unique<VkShaderModule> vertShaderModule (createShaderModule(vk, vkDevice, context.getBinaryCollection().get("vert"), 0));
358 const Unique<VkShaderModule> fragShaderModule (createShaderModule(vk, vkDevice, context.getBinaryCollection().get("frag"), 0));
361 const VkSpecializationInfo emptyShaderSpecParams =
368 const VkPipelineShaderStageCreateInfo shaderStageParams[] =
371 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // sType
374 VK_SHADER_STAGE_VERTEX_BIT, // stage
375 *vertShaderModule, // module
377 &emptyShaderSpecParams, // pSpecializationInfo
380 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // sType
383 VK_SHADER_STAGE_FRAGMENT_BIT, // stage
384 *fragShaderModule, // module
386 &emptyShaderSpecParams, // pSpecializationInfo
389 const VkPipelineDepthStencilStateCreateInfo depthStencilParams =
391 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // sType
394 DE_FALSE, // depthTestEnable
395 DE_FALSE, // depthWriteEnable
396 VK_COMPARE_OP_ALWAYS, // depthCompareOp
397 DE_FALSE, // depthBoundsTestEnable
398 DE_FALSE, // stencilTestEnable
400 VK_STENCIL_OP_KEEP, // failOp
401 VK_STENCIL_OP_KEEP, // passOp
402 VK_STENCIL_OP_KEEP, // depthFailOp
403 VK_COMPARE_OP_ALWAYS, // compareOp
409 VK_STENCIL_OP_KEEP, // failOp
410 VK_STENCIL_OP_KEEP, // passOp
411 VK_STENCIL_OP_KEEP, // depthFailOp
412 VK_COMPARE_OP_ALWAYS, // compareOp
417 -1.0f, // float minDepthBounds;
418 +1.0f, // float maxDepthBounds;
420 const VkViewport viewport0 =
424 (float)renderSize.x(), // width
425 (float)renderSize.y(), // height
429 const VkRect2D scissor0 =
436 (deUint32)renderSize.x(), // width
437 (deUint32)renderSize.y(), // height
440 const VkPipelineViewportStateCreateInfo viewportParams =
442 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // sType
446 &viewport0, // pViewports
448 &scissor0 // pScissors
450 const VkSampleMask sampleMask = ~0u;
451 const VkPipelineMultisampleStateCreateInfo multisampleParams =
453 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // sType
456 VK_SAMPLE_COUNT_1_BIT, // rasterizationSamples
457 VK_FALSE, // sampleShadingEnable
458 0.0f, // minSampleShading
459 &sampleMask, // sampleMask
460 VK_FALSE, // alphaToCoverageEnable
461 VK_FALSE, // alphaToOneEnable
463 const VkPipelineRasterizationStateCreateInfo rasterParams =
465 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // sType
468 VK_TRUE, // depthClampEnable
469 VK_FALSE, // rasterizerDiscardEnable
470 VK_POLYGON_MODE_FILL, // polygonMode
471 VK_CULL_MODE_NONE, // cullMode
472 VK_FRONT_FACE_COUNTER_CLOCKWISE, // frontFace
473 VK_FALSE, // depthBiasEnable
474 0.0f, // depthBiasConstantFactor
475 0.0f, // depthBiasClamp
476 0.0f, // depthBiasSlopeFactor
479 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyParams =
481 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // sType
484 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, // topology
485 DE_FALSE, // primitiveRestartEnable
487 const VkVertexInputBindingDescription vertexBinding0 =
490 (deUint32)sizeof(tcu::Vec4), // stride
491 VK_VERTEX_INPUT_RATE_VERTEX, // inputRate
493 const VkVertexInputAttributeDescription vertexAttrib0 =
497 VK_FORMAT_R32G32B32A32_SFLOAT, // format
500 const VkPipelineVertexInputStateCreateInfo vertexInputStateParams =
502 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // sType
505 1u, // vertexBindingDescriptionCount
506 &vertexBinding0, // pVertexBindingDescriptions
507 1u, // vertexAttributeDescriptionCount
508 &vertexAttrib0, // pVertexAttributeDescriptions
510 const VkPipelineColorBlendAttachmentState attBlendParams =
512 VK_FALSE, // blendEnable
513 VK_BLEND_FACTOR_ONE, // srcColorBlendFactor
514 VK_BLEND_FACTOR_ZERO, // dstColorBlendFactor
515 VK_BLEND_OP_ADD, // colorBlendOp
516 VK_BLEND_FACTOR_ONE, // srcAlphaBlendFactor
517 VK_BLEND_FACTOR_ZERO, // dstAlphaBlendFactor
518 VK_BLEND_OP_ADD, // alphaBlendOp
519 (VK_COLOR_COMPONENT_R_BIT|
520 VK_COLOR_COMPONENT_G_BIT|
521 VK_COLOR_COMPONENT_B_BIT|
522 VK_COLOR_COMPONENT_A_BIT), // colorWriteMask
524 const VkPipelineColorBlendStateCreateInfo blendParams =
526 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // sType
529 DE_FALSE, // logicOpEnable
530 VK_LOGIC_OP_COPY, // logicOp
531 1u, // attachmentCount
532 &attBlendParams, // pAttachments
533 { 0.0f, 0.0f, 0.0f, 0.0f }, // blendConstants[4]
535 const VkPipelineDynamicStateCreateInfo dynamicStateInfo =
537 VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, // sType
540 0u, // dynamicStateCount
541 DE_NULL // pDynamicStates
543 const VkGraphicsPipelineCreateInfo pipelineParams =
545 VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // sType
548 (deUint32)DE_LENGTH_OF_ARRAY(shaderStageParams), // stageCount
549 shaderStageParams, // pStages
550 &vertexInputStateParams, // pVertexInputState
551 &inputAssemblyParams, // pInputAssemblyState
552 DE_NULL, // pTessellationState
553 &viewportParams, // pViewportState
554 &rasterParams, // pRasterizationState
555 &multisampleParams, // pMultisampleState
556 &depthStencilParams, // pDepthStencilState
557 &blendParams, // pColorBlendState
558 &dynamicStateInfo, // pDynamicState
559 *pipelineLayout, // layout
560 *renderPass, // renderPass
562 DE_NULL, // basePipelineHandle
563 0u, // basePipelineIndex
566 const Unique<VkPipeline> pipeline (createGraphicsPipeline(vk, vkDevice, DE_NULL, &pipelineParams));
569 const VkFramebufferCreateInfo framebufferParams =
571 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // sType
574 *renderPass, // renderPass
575 1u, // attachmentCount
576 &*colorAttView, // pAttachments
577 (deUint32)renderSize.x(), // width
578 (deUint32)renderSize.y(), // height
581 const Unique<VkFramebuffer> framebuffer (createFramebuffer(vk, vkDevice, &framebufferParams));
583 const VkCommandPoolCreateInfo cmdPoolParams =
585 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // sType
587 VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, // flags
588 queueFamilyIndex, // queueFamilyIndex
590 const Unique<VkCommandPool> cmdPool (createCommandPool(vk, vkDevice, &cmdPoolParams));
593 const VkCommandBufferAllocateInfo cmdBufParams =
595 VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // sType
598 VK_COMMAND_BUFFER_LEVEL_PRIMARY, // level
601 const Unique<VkCommandBuffer> cmdBuf (allocateCommandBuffer(vk, vkDevice, &cmdBufParams));
603 const VkCommandBufferBeginInfo cmdBufBeginParams =
605 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // sType
608 (const VkCommandBufferInheritanceInfo*)DE_NULL,
612 VK_CHECK(vk.beginCommandBuffer(*cmdBuf, &cmdBufBeginParams));
615 const VkMemoryBarrier vertFlushBarrier =
617 VK_STRUCTURE_TYPE_MEMORY_BARRIER, // sType
619 VK_ACCESS_HOST_WRITE_BIT, // srcAccessMask
620 VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT, // dstAccessMask
622 const VkImageMemoryBarrier colorAttBarrier =
624 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
627 (VK_ACCESS_COLOR_ATTACHMENT_READ_BIT|
628 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT), // dstAccessMask
629 VK_IMAGE_LAYOUT_UNDEFINED, // oldLayout
630 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // newLayout
631 queueFamilyIndex, // srcQueueFamilyIndex
632 queueFamilyIndex, // dstQueueFamilyIndex
635 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
638 0u, // baseArrayLayer
640 } // subresourceRange
642 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);
646 const VkClearValue clearValue = makeClearValueColorF32(0.125f, 0.25f, 0.75f, 1.0f);
647 const VkRenderPassBeginInfo passBeginParams =
649 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // sType
651 *renderPass, // renderPass
652 *framebuffer, // framebuffer
655 { (deUint32)renderSize.x(), (deUint32)renderSize.y() }
657 1u, // clearValueCount
658 &clearValue, // pClearValues
660 vk.cmdBeginRenderPass(*cmdBuf, &passBeginParams, VK_SUBPASS_CONTENTS_INLINE);
663 vk.cmdBindPipeline(*cmdBuf, VK_PIPELINE_BIND_POINT_GRAPHICS, *pipeline);
665 const VkDeviceSize bindingOffset = 0;
666 vk.cmdBindVertexBuffers(*cmdBuf, 0u, 1u, &vertexBuffer.get(), &bindingOffset);
668 vk.cmdDraw(*cmdBuf, 3u, 1u, 0u, 0u);
669 vk.cmdEndRenderPass(*cmdBuf);
672 const VkImageMemoryBarrier renderFinishBarrier =
674 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
676 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // outputMask
677 VK_ACCESS_TRANSFER_READ_BIT, // inputMask
678 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // oldLayout
679 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // newLayout
680 queueFamilyIndex, // srcQueueFamilyIndex
681 queueFamilyIndex, // dstQueueFamilyIndex
684 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
687 0u, // baseArraySlice
689 } // subresourceRange
691 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);
695 const VkBufferImageCopy copyParams =
697 (VkDeviceSize)0u, // bufferOffset
698 (deUint32)renderSize.x(), // bufferRowLength
699 (deUint32)renderSize.y(), // bufferImageHeight
701 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
703 0u, // baseArrayLayer
705 }, // imageSubresource
706 { 0u, 0u, 0u }, // imageOffset
708 (deUint32)renderSize.x(),
709 (deUint32)renderSize.y(),
713 vk.cmdCopyImageToBuffer(*cmdBuf, *image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *readImageBuffer, 1u, ©Params);
717 const VkBufferMemoryBarrier copyFinishBarrier =
719 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // sType
721 VK_ACCESS_TRANSFER_WRITE_BIT, // srcAccessMask
722 VK_ACCESS_HOST_READ_BIT, // dstAccessMask
723 queueFamilyIndex, // srcQueueFamilyIndex
724 queueFamilyIndex, // dstQueueFamilyIndex
725 *readImageBuffer, // buffer
727 imageSizeBytes // size
729 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);
732 VK_CHECK(vk.endCommandBuffer(*cmdBuf));
734 // Upload vertex data
736 const VkMappedMemoryRange range =
738 VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // sType
740 vertexBufferMemory->getMemory(), // memory
742 (VkDeviceSize)sizeof(vertices), // size
744 void* vertexBufPtr = vertexBufferMemory->getHostPtr();
746 deMemcpy(vertexBufPtr, &vertices[0], sizeof(vertices));
747 VK_CHECK(vk.flushMappedMemoryRanges(vkDevice, 1u, &range));
750 // Submit & wait for completion
752 const VkFenceCreateInfo fenceParams =
754 VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, // sType
758 const VkSubmitInfo submitInfo =
760 VK_STRUCTURE_TYPE_SUBMIT_INFO, // sType
762 0u, // waitSemaphoreCount
763 DE_NULL, // pWaitSemaphores
764 (const VkPipelineStageFlags*)DE_NULL,
765 1u, // commandBufferCount
766 &cmdBuf.get(), // pCommandBuffers
767 0u, // signalSemaphoreCount
768 DE_NULL, // pSignalSemaphores
770 const Unique<VkFence> fence (createFence(vk, vkDevice, &fenceParams));
772 VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, *fence));
773 VK_CHECK(vk.waitForFences(vkDevice, 1u, &fence.get(), DE_TRUE, ~0ull));
778 const VkMappedMemoryRange range =
780 VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // sType
782 readImageBufferMemory->getMemory(), // memory
784 imageSizeBytes, // size
786 void* imagePtr = readImageBufferMemory->getHostPtr();
788 VK_CHECK(vk.invalidateMappedMemoryRanges(vkDevice, 1u, &range));
789 context.getTestContext().getLog() << TestLog::Image("Result", "Result", tcu::ConstPixelBufferAccess(tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), renderSize.x(), renderSize.y(), 1, imagePtr));
792 return tcu::TestStatus::pass("Rendering succeeded");
797 tcu::TestCaseGroup* createSmokeTests (tcu::TestContext& testCtx)
799 de::MovePtr<tcu::TestCaseGroup> smokeTests (new tcu::TestCaseGroup(testCtx, "smoke", "Smoke Tests"));
801 addFunctionCase (smokeTests.get(), "create_sampler", "", createSamplerTest);
802 addFunctionCaseWithPrograms (smokeTests.get(), "create_shader", "", createShaderProgs, createShaderModuleTest);
803 addFunctionCaseWithPrograms (smokeTests.get(), "triangle", "", createTriangleProgs, renderTriangleTest);
804 addFunctionCaseWithPrograms (smokeTests.get(), "asm_triangle", "", createTriangleAsmProgs, renderTriangleTest);
806 return smokeTests.release();