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_BASE, // 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 1.0f, // maxAnisotropy
87 DE_FALSE, // compareEnable
88 VK_COMPARE_OP_ALWAYS, // compareOp
91 VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK, // borderColor
92 VK_FALSE, // unnormalizedCoords
95 Move<VkSampler> tmpSampler = createSampler(vk, vkDevice, &samplerInfo);
96 Move<VkSampler> tmp2Sampler;
98 tmp2Sampler = tmpSampler;
100 const Unique<VkSampler> sampler (tmp2Sampler);
103 return tcu::TestStatus::pass("Creating sampler succeeded");
106 void createShaderProgs (SourceCollections& dst)
108 dst.glslSources.add("test") << glu::VertexSource(
110 "in highp vec4 a_position;\n"
111 "void main (void) { gl_Position = a_position; }\n");
114 tcu::TestStatus createShaderModuleTest (Context& context)
116 const VkDevice vkDevice = context.getDevice();
117 const DeviceInterface& vk = context.getDeviceInterface();
118 const Unique<VkShaderModule> shader (createShaderModule(vk, vkDevice, context.getBinaryCollection().get("test"), 0));
120 return tcu::TestStatus::pass("Creating shader module succeeded");
123 void createTriangleAsmProgs (SourceCollections& dst)
125 dst.spirvAsmSources.add("vert") <<
126 " OpCapability Shader\n"
127 "%1 = OpExtInstImport \"GLSL.std.450\"\n"
128 " OpMemoryModel Logical GLSL450\n"
129 " OpEntryPoint Vertex %4 \"main\" %10 %12 %16 %17\n"
130 " OpSource ESSL 300\n"
131 " OpName %4 \"main\"\n"
132 " OpName %10 \"gl_Position\"\n"
133 " OpName %12 \"a_position\"\n"
134 " OpName %16 \"gl_VertexID\"\n"
135 " OpName %17 \"gl_InstanceID\"\n"
136 " OpDecorate %10 BuiltIn Position\n"
137 " OpDecorate %12 Location 0\n"
138 " OpDecorate %16 BuiltIn VertexId\n"
139 " OpDecorate %17 BuiltIn InstanceId\n"
141 "%3 = OpTypeFunction %2\n"
142 "%7 = OpTypeFloat 32\n"
143 "%8 = OpTypeVector %7 4\n"
144 "%9 = OpTypePointer Output %8\n"
145 "%10 = OpVariable %9 Output\n"
146 "%11 = OpTypePointer Input %8\n"
147 "%12 = OpVariable %11 Input\n"
148 "%14 = OpTypeInt 32 1\n"
149 "%15 = OpTypePointer Input %14\n"
150 "%16 = OpVariable %15 Input\n"
151 "%17 = OpVariable %15 Input\n"
152 "%4 = OpFunction %2 None %3\n"
154 "%13 = OpLoad %8 %12\n"
160 dst.spirvAsmSources.add("frag") <<
161 " OpCapability Shader\n"
162 "%1 = OpExtInstImport \"GLSL.std.450\"\n"
163 " OpMemoryModel Logical GLSL450\n"
164 " OpEntryPoint Fragment %4 \"main\" %10\n"
165 " OpExecutionMode %4 OriginLowerLeft\n"
166 " OpSource ESSL 300\n"
167 " OpName %4 \"main\"\n"
168 " OpName %10 \"o_color\"\n"
169 " OpDecorate %10 RelaxedPrecision\n"
170 " OpDecorate %10 Location 0\n"
172 "%3 = OpTypeFunction %2\n"
173 "%7 = OpTypeFloat 32\n"
174 "%8 = OpTypeVector %7 4\n"
175 "%9 = OpTypePointer Output %8\n"
176 "%10 = OpVariable %9 Output\n"
177 "%11 = OpConstant %7 1065353216\n"
178 "%12 = OpConstant %7 0\n"
179 "%13 = OpConstantComposite %8 %11 %12 %11 %11\n"
180 "%4 = OpFunction %2 None %3\n"
189 void createTriangleProgs (SourceCollections& dst)
191 dst.glslSources.add("vert") << glu::VertexSource(
193 "layout(location = 0) in highp vec4 a_position;\n"
194 "void main (void) { gl_Position = a_position; }\n");
195 dst.glslSources.add("frag") << glu::FragmentSource(
197 "layout(location = 0) out lowp vec4 o_color;\n"
198 "void main (void) { o_color = vec4(1.0, 0.0, 1.0, 1.0); }\n");
201 tcu::TestStatus renderTriangleTest (Context& context)
203 const VkDevice vkDevice = context.getDevice();
204 const DeviceInterface& vk = context.getDeviceInterface();
205 const VkQueue queue = context.getUniversalQueue();
206 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
207 SimpleAllocator memAlloc (vk, vkDevice, getPhysicalDeviceMemoryProperties(context.getInstanceInterface(), context.getPhysicalDevice()));
208 const tcu::IVec2 renderSize (256, 256);
210 const tcu::Vec4 vertices[] =
212 tcu::Vec4(-0.5f, -0.5f, 0.0f, 1.0f),
213 tcu::Vec4(+0.5f, -0.5f, 0.0f, 1.0f),
214 tcu::Vec4( 0.0f, +0.5f, 0.0f, 1.0f)
217 const VkBufferCreateInfo vertexBufferParams =
219 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // sType
222 (VkDeviceSize)sizeof(vertices), // size
223 VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, // usage
224 VK_SHARING_MODE_EXCLUSIVE, // sharingMode
225 1u, // queueFamilyIndexCount
226 &queueFamilyIndex, // pQueueFamilyIndices
228 const Unique<VkBuffer> vertexBuffer (createBuffer(vk, vkDevice, &vertexBufferParams));
229 const UniquePtr<Allocation> vertexBufferMemory (memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *vertexBuffer), MemoryRequirement::HostVisible));
231 VK_CHECK(vk.bindBufferMemory(vkDevice, *vertexBuffer, vertexBufferMemory->getMemory(), vertexBufferMemory->getOffset()));
233 const VkDeviceSize imageSizeBytes = (VkDeviceSize)(sizeof(deUint32)*renderSize.x()*renderSize.y());
234 const VkBufferCreateInfo readImageBufferParams =
236 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // sType
238 (VkBufferCreateFlags)0u, // flags
239 imageSizeBytes, // size
240 VK_BUFFER_USAGE_TRANSFER_DST_BIT, // usage
241 VK_SHARING_MODE_EXCLUSIVE, // sharingMode
242 1u, // queueFamilyIndexCount
243 &queueFamilyIndex, // pQueueFamilyIndices
245 const Unique<VkBuffer> readImageBuffer (createBuffer(vk, vkDevice, &readImageBufferParams));
246 const UniquePtr<Allocation> readImageBufferMemory (memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *readImageBuffer), MemoryRequirement::HostVisible));
248 VK_CHECK(vk.bindBufferMemory(vkDevice, *readImageBuffer, readImageBufferMemory->getMemory(), readImageBufferMemory->getOffset()));
250 const VkImageCreateInfo imageParams =
252 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // sType
255 VK_IMAGE_TYPE_2D, // imageType
256 VK_FORMAT_R8G8B8A8_UNORM, // format
257 { renderSize.x(), renderSize.y(), 1 }, // extent
260 VK_SAMPLE_COUNT_1_BIT, // samples
261 VK_IMAGE_TILING_OPTIMAL, // tiling
262 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT, // usage
263 VK_SHARING_MODE_EXCLUSIVE, // sharingMode
264 1u, // queueFamilyIndexCount
265 &queueFamilyIndex, // pQueueFamilyIndices
266 VK_IMAGE_LAYOUT_UNDEFINED, // initialLayout
269 const Unique<VkImage> image (createImage(vk, vkDevice, &imageParams));
270 const UniquePtr<Allocation> imageMemory (memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *image), MemoryRequirement::Any));
272 VK_CHECK(vk.bindImageMemory(vkDevice, *image, imageMemory->getMemory(), imageMemory->getOffset()));
274 const VkAttachmentDescription colorAttDesc =
277 VK_FORMAT_R8G8B8A8_UNORM, // format
278 VK_SAMPLE_COUNT_1_BIT, // samples
279 VK_ATTACHMENT_LOAD_OP_CLEAR, // loadOp
280 VK_ATTACHMENT_STORE_OP_STORE, // storeOp
281 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // stencilLoadOp
282 VK_ATTACHMENT_STORE_OP_DONT_CARE, // stencilStoreOp
283 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // initialLayout
284 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // finalLayout
286 const VkAttachmentReference colorAttRef =
289 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // layout
291 const VkSubpassDescription subpassDesc =
293 (VkSubpassDescriptionFlags)0u, // flags
294 VK_PIPELINE_BIND_POINT_GRAPHICS, // pipelineBindPoint
295 0u, // inputAttachmentCount
296 DE_NULL, // pInputAttachments
297 1u, // colorAttachmentCount
298 &colorAttRef, // pColorAttachments
299 DE_NULL, // pResolveAttachments
300 DE_NULL, // depthStencilAttachment
301 0u, // preserveAttachmentCount
302 DE_NULL, // pPreserveAttachments
304 const VkRenderPassCreateInfo renderPassParams =
306 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // sType
309 1u, // attachmentCount
310 &colorAttDesc, // pAttachments
312 &subpassDesc, // pSubpasses
313 0u, // dependencyCount
314 DE_NULL, // pDependencies
316 const Unique<VkRenderPass> renderPass (createRenderPass(vk, vkDevice, &renderPassParams));
318 const VkImageViewCreateInfo colorAttViewParams =
320 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // sType
324 VK_IMAGE_VIEW_TYPE_2D, // viewType
325 VK_FORMAT_R8G8B8A8_UNORM, // format
327 VK_COMPONENT_SWIZZLE_R,
328 VK_COMPONENT_SWIZZLE_G,
329 VK_COMPONENT_SWIZZLE_B,
330 VK_COMPONENT_SWIZZLE_A
333 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
336 0u, // baseArrayLayer
338 }, // subresourceRange
340 const Unique<VkImageView> colorAttView (createImageView(vk, vkDevice, &colorAttViewParams));
343 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
345 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // sType
347 (vk::VkPipelineLayoutCreateFlags)0,
348 0u, // setLayoutCount
349 DE_NULL, // pSetLayouts
350 0u, // pushConstantRangeCount
351 DE_NULL, // pPushConstantRanges
353 const Unique<VkPipelineLayout> pipelineLayout (createPipelineLayout(vk, vkDevice, &pipelineLayoutParams));
356 const Unique<VkShaderModule> vertShaderModule (createShaderModule(vk, vkDevice, context.getBinaryCollection().get("vert"), 0));
357 const Unique<VkShaderModule> fragShaderModule (createShaderModule(vk, vkDevice, context.getBinaryCollection().get("frag"), 0));
360 const VkSpecializationInfo emptyShaderSpecParams =
367 const VkPipelineShaderStageCreateInfo shaderStageParams[] =
370 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // sType
373 VK_SHADER_STAGE_VERTEX_BIT, // stage
374 *vertShaderModule, // module
376 &emptyShaderSpecParams, // pSpecializationInfo
379 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // sType
382 VK_SHADER_STAGE_FRAGMENT_BIT, // stage
383 *fragShaderModule, // module
385 &emptyShaderSpecParams, // pSpecializationInfo
388 const VkPipelineDepthStencilStateCreateInfo depthStencilParams =
390 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // sType
393 DE_FALSE, // depthTestEnable
394 DE_FALSE, // depthWriteEnable
395 VK_COMPARE_OP_ALWAYS, // depthCompareOp
396 DE_FALSE, // depthBoundsTestEnable
397 DE_FALSE, // stencilTestEnable
399 VK_STENCIL_OP_KEEP, // failOp
400 VK_STENCIL_OP_KEEP, // passOp
401 VK_STENCIL_OP_KEEP, // depthFailOp
402 VK_COMPARE_OP_ALWAYS, // compareOp
408 VK_STENCIL_OP_KEEP, // failOp
409 VK_STENCIL_OP_KEEP, // passOp
410 VK_STENCIL_OP_KEEP, // depthFailOp
411 VK_COMPARE_OP_ALWAYS, // compareOp
416 -1.0f, // float minDepthBounds;
417 +1.0f, // float maxDepthBounds;
419 const VkViewport viewport0 =
423 (float)renderSize.x(), // width
424 (float)renderSize.y(), // height
428 const VkRect2D scissor0 =
435 renderSize.x(), // width
436 renderSize.y(), // height
439 const VkPipelineViewportStateCreateInfo viewportParams =
441 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // sType
445 &viewport0, // pViewports
447 &scissor0 // pScissors
449 const VkSampleMask sampleMask = ~0u;
450 const VkPipelineMultisampleStateCreateInfo multisampleParams =
452 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // sType
455 VK_SAMPLE_COUNT_1_BIT, // rasterizationSamples
456 VK_FALSE, // sampleShadingEnable
457 0.0f, // minSampleShading
458 &sampleMask, // sampleMask
459 VK_FALSE, // alphaToCoverageEnable
460 VK_FALSE, // alphaToOneEnable
462 const VkPipelineRasterizationStateCreateInfo rasterParams =
464 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // sType
467 VK_TRUE, // depthClampEnable
468 VK_FALSE, // rasterizerDiscardEnable
469 VK_POLYGON_MODE_FILL, // polygonMode
470 VK_CULL_MODE_NONE, // cullMode
471 VK_FRONT_FACE_COUNTER_CLOCKWISE, // frontFace
472 VK_FALSE, // depthBiasEnable
473 0.0f, // depthBiasConstantFactor
474 0.0f, // depthBiasClamp
475 0.0f, // depthBiasSlopeFactor
478 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyParams =
480 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // sType
483 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, // topology
484 DE_FALSE, // primitiveRestartEnable
486 const VkVertexInputBindingDescription vertexBinding0 =
489 (deUint32)sizeof(tcu::Vec4), // stride
490 VK_VERTEX_INPUT_RATE_VERTEX, // inputRate
492 const VkVertexInputAttributeDescription vertexAttrib0 =
496 VK_FORMAT_R32G32B32A32_SFLOAT, // format
499 const VkPipelineVertexInputStateCreateInfo vertexInputStateParams =
501 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // sType
504 1u, // vertexBindingDescriptionCount
505 &vertexBinding0, // pVertexBindingDescriptions
506 1u, // vertexAttributeDescriptionCount
507 &vertexAttrib0, // pVertexAttributeDescriptions
509 const VkPipelineColorBlendAttachmentState attBlendParams =
511 VK_FALSE, // blendEnable
512 VK_BLEND_FACTOR_ONE, // srcColorBlendFactor
513 VK_BLEND_FACTOR_ZERO, // dstColorBlendFactor
514 VK_BLEND_OP_ADD, // colorBlendOp
515 VK_BLEND_FACTOR_ONE, // srcAlphaBlendFactor
516 VK_BLEND_FACTOR_ZERO, // dstAlphaBlendFactor
517 VK_BLEND_OP_ADD, // alphaBlendOp
518 (VK_COLOR_COMPONENT_R_BIT|
519 VK_COLOR_COMPONENT_G_BIT|
520 VK_COLOR_COMPONENT_B_BIT|
521 VK_COLOR_COMPONENT_A_BIT), // colorWriteMask
523 const VkPipelineColorBlendStateCreateInfo blendParams =
525 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // sType
528 DE_FALSE, // logicOpEnable
529 VK_LOGIC_OP_COPY, // logicOp
530 1u, // attachmentCount
531 &attBlendParams, // pAttachments
532 { 0.0f, 0.0f, 0.0f, 0.0f }, // blendConstants[4]
534 const VkPipelineDynamicStateCreateInfo dynamicStateInfo =
536 VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, // sType
539 0u, // dynamicStateCount
540 DE_NULL // pDynamicStates
542 const VkGraphicsPipelineCreateInfo pipelineParams =
544 VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // sType
547 (deUint32)DE_LENGTH_OF_ARRAY(shaderStageParams), // stageCount
548 shaderStageParams, // pStages
549 &vertexInputStateParams, // pVertexInputState
550 &inputAssemblyParams, // pInputAssemblyState
551 DE_NULL, // pTessellationState
552 &viewportParams, // pViewportState
553 &rasterParams, // pRasterizationState
554 &multisampleParams, // pMultisampleState
555 &depthStencilParams, // pDepthStencilState
556 &blendParams, // pColorBlendState
557 &dynamicStateInfo, // pDynamicState
558 *pipelineLayout, // layout
559 *renderPass, // renderPass
561 DE_NULL, // basePipelineHandle
562 0u, // basePipelineIndex
565 const Unique<VkPipeline> pipeline (createGraphicsPipeline(vk, vkDevice, DE_NULL, &pipelineParams));
568 const VkFramebufferCreateInfo framebufferParams =
570 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // sType
573 *renderPass, // renderPass
574 1u, // attachmentCount
575 &*colorAttView, // pAttachments
576 (deUint32)renderSize.x(), // width
577 (deUint32)renderSize.y(), // height
580 const Unique<VkFramebuffer> framebuffer (createFramebuffer(vk, vkDevice, &framebufferParams));
582 const VkCommandPoolCreateInfo cmdPoolParams =
584 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // sType
586 VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, // flags
587 queueFamilyIndex, // queueFamilyIndex
589 const Unique<VkCommandPool> cmdPool (createCommandPool(vk, vkDevice, &cmdPoolParams));
592 const VkCommandBufferAllocateInfo cmdBufParams =
594 VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // sType
597 VK_COMMAND_BUFFER_LEVEL_PRIMARY, // level
600 const Unique<VkCommandBuffer> cmdBuf (allocateCommandBuffer(vk, vkDevice, &cmdBufParams));
602 const VkCommandBufferBeginInfo cmdBufBeginParams =
604 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // sType
607 DE_NULL, // renderPass
609 DE_NULL, // framebuffer
610 VK_FALSE, // occlusionQueryEnable
611 (VkQueryControlFlags)0u, // queryFlags
612 (VkQueryPipelineStatisticFlags)0u, // pipelineStatistics
616 VK_CHECK(vk.beginCommandBuffer(*cmdBuf, &cmdBufBeginParams));
619 const VkMemoryBarrier vertFlushBarrier =
621 VK_STRUCTURE_TYPE_MEMORY_BARRIER, // sType
623 VK_ACCESS_HOST_WRITE_BIT, // srcAccessMask
624 VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT, // dstAccessMask
626 const VkImageMemoryBarrier colorAttBarrier =
628 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
631 (VK_ACCESS_COLOR_ATTACHMENT_READ_BIT|
632 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT), // dstAccessMask
633 VK_IMAGE_LAYOUT_UNDEFINED, // oldLayout
634 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // newLayout
635 queueFamilyIndex, // srcQueueFamilyIndex
636 queueFamilyIndex, // dstQueueFamilyIndex
639 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
642 0u, // baseArrayLayer
644 } // subresourceRange
646 const void* barriers[] = { &vertFlushBarrier, &colorAttBarrier };
647 vk.cmdPipelineBarrier(*cmdBuf, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, DE_FALSE, (deUint32)DE_LENGTH_OF_ARRAY(barriers), barriers);
651 const VkClearValue clearValue = makeClearValueColorF32(0.125f, 0.25f, 0.75f, 1.0f);
652 const VkRenderPassBeginInfo passBeginParams =
654 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // sType
656 *renderPass, // renderPass
657 *framebuffer, // framebuffer
658 { { 0, 0 }, { renderSize.x(), renderSize.y() } }, // renderArea
659 1u, // clearValueCount
660 &clearValue, // pClearValues
662 vk.cmdBeginRenderPass(*cmdBuf, &passBeginParams, VK_SUBPASS_CONTENTS_INLINE);
665 vk.cmdBindPipeline(*cmdBuf, VK_PIPELINE_BIND_POINT_GRAPHICS, *pipeline);
667 const VkDeviceSize bindingOffset = 0;
668 vk.cmdBindVertexBuffers(*cmdBuf, 0u, 1u, &vertexBuffer.get(), &bindingOffset);
670 vk.cmdDraw(*cmdBuf, 3u, 1u, 0u, 0u);
671 vk.cmdEndRenderPass(*cmdBuf);
674 const VkImageMemoryBarrier renderFinishBarrier =
676 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
678 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // outputMask
679 VK_ACCESS_TRANSFER_READ_BIT, // inputMask
680 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // oldLayout
681 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // newLayout
682 queueFamilyIndex, // srcQueueFamilyIndex
683 queueFamilyIndex, // dstQueueFamilyIndex
686 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
689 0u, // baseArraySlice
691 } // subresourceRange
693 const void* barriers[] = { &renderFinishBarrier };
694 vk.cmdPipelineBarrier(*cmdBuf, VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, DE_FALSE, (deUint32)DE_LENGTH_OF_ARRAY(barriers), barriers);
698 const VkBufferImageCopy copyParams =
700 (VkDeviceSize)0u, // bufferOffset
701 (deUint32)renderSize.x(), // bufferRowLength
702 (deUint32)renderSize.y(), // bufferImageHeight
704 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
706 0u, // baseArrayLayer
708 }, // imageSubresource
709 { 0u, 0u, 0u }, // imageOffset
710 { renderSize.x(), renderSize.y(), 1u } // imageExtent
712 vk.cmdCopyImageToBuffer(*cmdBuf, *image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *readImageBuffer, 1u, ©Params);
716 const VkBufferMemoryBarrier copyFinishBarrier =
718 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // sType
720 VK_ACCESS_TRANSFER_WRITE_BIT, // srcAccessMask
721 VK_ACCESS_HOST_READ_BIT, // dstAccessMask
722 queueFamilyIndex, // srcQueueFamilyIndex
723 queueFamilyIndex, // dstQueueFamilyIndex
724 *readImageBuffer, // buffer
726 imageSizeBytes // size
728 const void* barriers[] = { ©FinishBarrier };
729 vk.cmdPipelineBarrier(*cmdBuf, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_HOST_BIT, DE_FALSE, (deUint32)DE_LENGTH_OF_ARRAY(barriers), barriers);
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 1u, // commandBufferCount
765 &cmdBuf.get(), // pCommandBuffers
766 0u, // signalSemaphoreCount
767 DE_NULL, // pSignalSemaphores
769 const Unique<VkFence> fence (createFence(vk, vkDevice, &fenceParams));
771 VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, *fence));
772 VK_CHECK(vk.waitForFences(vkDevice, 1u, &fence.get(), DE_TRUE, ~0ull));
777 const VkMappedMemoryRange range =
779 VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // sType
781 readImageBufferMemory->getMemory(), // memory
783 imageSizeBytes, // size
785 void* imagePtr = readImageBufferMemory->getHostPtr();
787 VK_CHECK(vk.invalidateMappedMemoryRanges(vkDevice, 1u, &range));
788 context.getTestContext().getLog() << TestLog::Image("Result", "Result", tcu::ConstPixelBufferAccess(tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), renderSize.x(), renderSize.y(), 1, imagePtr));
791 return tcu::TestStatus::pass("Rendering succeeded");
796 tcu::TestCaseGroup* createSmokeTests (tcu::TestContext& testCtx)
798 de::MovePtr<tcu::TestCaseGroup> smokeTests (new tcu::TestCaseGroup(testCtx, "smoke", "Smoke Tests"));
800 addFunctionCase (smokeTests.get(), "create_sampler", "", createSamplerTest);
801 addFunctionCaseWithPrograms (smokeTests.get(), "create_shader", "", createShaderProgs, createShaderModuleTest);
802 addFunctionCaseWithPrograms (smokeTests.get(), "triangle", "", createTriangleProgs, renderTriangleTest);
803 addFunctionCaseWithPrograms (smokeTests.get(), "asm_triangle", "", createTriangleAsmProgs, renderTriangleTest);
805 return smokeTests.release();