1 /*-------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2015 Google 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.
21 * \brief Simple Smoke Tests
22 *//*--------------------------------------------------------------------*/
24 #include "vktApiTests.hpp"
26 #include "vktTestCaseUtil.hpp"
29 #include "vkPlatform.hpp"
30 #include "vkStrUtil.hpp"
32 #include "vkRefUtil.hpp"
33 #include "vkQueryUtil.hpp"
34 #include "vkMemUtil.hpp"
35 #include "vkDeviceUtil.hpp"
36 #include "vkPrograms.hpp"
37 #include "vkTypeUtil.hpp"
39 #include "tcuTestLog.hpp"
40 #include "tcuFormatUtil.hpp"
42 #include "deUniquePtr.hpp"
57 tcu::TestStatus createSamplerTest (Context& context)
59 const VkDevice vkDevice = context.getDevice();
60 const DeviceInterface& vk = context.getDeviceInterface();
63 const struct VkSamplerCreateInfo samplerInfo =
65 VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, // sType
68 VK_FILTER_NEAREST, // magFilter
69 VK_FILTER_NEAREST, // minFilter
70 VK_SAMPLER_MIPMAP_MODE_NEAREST, // mipmapMode
71 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // addressModeU
72 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // addressModeV
73 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // addressModeW
75 VK_FALSE, // anisotropyEnable
76 1.0f, // maxAnisotropy
77 DE_FALSE, // compareEnable
78 VK_COMPARE_OP_ALWAYS, // compareOp
81 VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK, // borderColor
82 VK_FALSE, // unnormalizedCoords
85 Move<VkSampler> tmpSampler = createSampler(vk, vkDevice, &samplerInfo);
86 Move<VkSampler> tmp2Sampler;
88 tmp2Sampler = tmpSampler;
90 const Unique<VkSampler> sampler (tmp2Sampler);
93 return tcu::TestStatus::pass("Creating sampler succeeded");
96 void createShaderProgs (SourceCollections& dst)
98 dst.glslSources.add("test") << glu::VertexSource(
100 "in highp vec4 a_position;\n"
101 "void main (void) { gl_Position = a_position; }\n");
104 tcu::TestStatus createShaderModuleTest (Context& context)
106 const VkDevice vkDevice = context.getDevice();
107 const DeviceInterface& vk = context.getDeviceInterface();
108 const Unique<VkShaderModule> shader (createShaderModule(vk, vkDevice, context.getBinaryCollection().get("test"), 0));
110 return tcu::TestStatus::pass("Creating shader module succeeded");
113 void createTriangleAsmProgs (SourceCollections& dst)
115 dst.spirvAsmSources.add("vert") <<
116 " OpCapability Shader\n"
117 "%1 = OpExtInstImport \"GLSL.std.450\"\n"
118 " OpMemoryModel Logical GLSL450\n"
119 " OpEntryPoint Vertex %4 \"main\" %10 %12 %16 %17\n"
120 " OpSource ESSL 300\n"
121 " OpName %4 \"main\"\n"
122 " OpName %10 \"gl_Position\"\n"
123 " OpName %12 \"a_position\"\n"
124 " OpName %16 \"gl_VertexIndex\"\n"
125 " OpName %17 \"gl_InstanceIndex\"\n"
126 " OpDecorate %10 BuiltIn Position\n"
127 " OpDecorate %12 Location 0\n"
128 " OpDecorate %16 BuiltIn VertexIndex\n"
129 " OpDecorate %17 BuiltIn InstanceIndex\n"
131 "%3 = OpTypeFunction %2\n"
132 "%7 = OpTypeFloat 32\n"
133 "%8 = OpTypeVector %7 4\n"
134 "%9 = OpTypePointer Output %8\n"
135 "%10 = OpVariable %9 Output\n"
136 "%11 = OpTypePointer Input %8\n"
137 "%12 = OpVariable %11 Input\n"
138 "%14 = OpTypeInt 32 1\n"
139 "%15 = OpTypePointer Input %14\n"
140 "%16 = OpVariable %15 Input\n"
141 "%17 = OpVariable %15 Input\n"
142 "%4 = OpFunction %2 None %3\n"
144 "%13 = OpLoad %8 %12\n"
150 dst.spirvAsmSources.add("frag") <<
151 " OpCapability Shader\n"
152 "%1 = OpExtInstImport \"GLSL.std.450\"\n"
153 " OpMemoryModel Logical GLSL450\n"
154 " OpEntryPoint Fragment %4 \"main\" %10\n"
155 " OpExecutionMode %4 OriginLowerLeft\n"
156 " OpSource ESSL 300\n"
157 " OpName %4 \"main\"\n"
158 " OpName %10 \"o_color\"\n"
159 " OpDecorate %10 RelaxedPrecision\n"
160 " OpDecorate %10 Location 0\n"
162 "%3 = OpTypeFunction %2\n"
163 "%7 = OpTypeFloat 32\n"
164 "%8 = OpTypeVector %7 4\n"
165 "%9 = OpTypePointer Output %8\n"
166 "%10 = OpVariable %9 Output\n"
167 "%11 = OpConstant %7 1065353216\n"
168 "%12 = OpConstant %7 0\n"
169 "%13 = OpConstantComposite %8 %11 %12 %11 %11\n"
170 "%4 = OpFunction %2 None %3\n"
179 void createTriangleProgs (SourceCollections& dst)
181 dst.glslSources.add("vert") << glu::VertexSource(
183 "layout(location = 0) in highp vec4 a_position;\n"
184 "void main (void) { gl_Position = a_position; }\n");
185 dst.glslSources.add("frag") << glu::FragmentSource(
187 "layout(location = 0) out lowp vec4 o_color;\n"
188 "void main (void) { o_color = vec4(1.0, 0.0, 1.0, 1.0); }\n");
191 tcu::TestStatus renderTriangleTest (Context& context)
193 const VkDevice vkDevice = context.getDevice();
194 const DeviceInterface& vk = context.getDeviceInterface();
195 const VkQueue queue = context.getUniversalQueue();
196 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
197 SimpleAllocator memAlloc (vk, vkDevice, getPhysicalDeviceMemoryProperties(context.getInstanceInterface(), context.getPhysicalDevice()));
198 const tcu::IVec2 renderSize (256, 256);
200 const tcu::Vec4 vertices[] =
202 tcu::Vec4(-0.5f, -0.5f, 0.0f, 1.0f),
203 tcu::Vec4(+0.5f, -0.5f, 0.0f, 1.0f),
204 tcu::Vec4( 0.0f, +0.5f, 0.0f, 1.0f)
207 const VkBufferCreateInfo vertexBufferParams =
209 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // sType
212 (VkDeviceSize)sizeof(vertices), // size
213 VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, // usage
214 VK_SHARING_MODE_EXCLUSIVE, // sharingMode
215 1u, // queueFamilyIndexCount
216 &queueFamilyIndex, // pQueueFamilyIndices
218 const Unique<VkBuffer> vertexBuffer (createBuffer(vk, vkDevice, &vertexBufferParams));
219 const UniquePtr<Allocation> vertexBufferMemory (memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *vertexBuffer), MemoryRequirement::HostVisible));
221 VK_CHECK(vk.bindBufferMemory(vkDevice, *vertexBuffer, vertexBufferMemory->getMemory(), vertexBufferMemory->getOffset()));
223 const VkDeviceSize imageSizeBytes = (VkDeviceSize)(sizeof(deUint32)*renderSize.x()*renderSize.y());
224 const VkBufferCreateInfo readImageBufferParams =
226 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // sType
228 (VkBufferCreateFlags)0u, // flags
229 imageSizeBytes, // size
230 VK_BUFFER_USAGE_TRANSFER_DST_BIT, // usage
231 VK_SHARING_MODE_EXCLUSIVE, // sharingMode
232 1u, // queueFamilyIndexCount
233 &queueFamilyIndex, // pQueueFamilyIndices
235 const Unique<VkBuffer> readImageBuffer (createBuffer(vk, vkDevice, &readImageBufferParams));
236 const UniquePtr<Allocation> readImageBufferMemory (memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *readImageBuffer), MemoryRequirement::HostVisible));
238 VK_CHECK(vk.bindBufferMemory(vkDevice, *readImageBuffer, readImageBufferMemory->getMemory(), readImageBufferMemory->getOffset()));
240 const VkImageCreateInfo imageParams =
242 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // sType
245 VK_IMAGE_TYPE_2D, // imageType
246 VK_FORMAT_R8G8B8A8_UNORM, // format
247 { (deUint32)renderSize.x(), (deUint32)renderSize.y(), 1 }, // extent
250 VK_SAMPLE_COUNT_1_BIT, // samples
251 VK_IMAGE_TILING_OPTIMAL, // tiling
252 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT, // usage
253 VK_SHARING_MODE_EXCLUSIVE, // sharingMode
254 1u, // queueFamilyIndexCount
255 &queueFamilyIndex, // pQueueFamilyIndices
256 VK_IMAGE_LAYOUT_UNDEFINED, // initialLayout
259 const Unique<VkImage> image (createImage(vk, vkDevice, &imageParams));
260 const UniquePtr<Allocation> imageMemory (memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *image), MemoryRequirement::Any));
262 VK_CHECK(vk.bindImageMemory(vkDevice, *image, imageMemory->getMemory(), imageMemory->getOffset()));
264 const VkAttachmentDescription colorAttDesc =
267 VK_FORMAT_R8G8B8A8_UNORM, // format
268 VK_SAMPLE_COUNT_1_BIT, // samples
269 VK_ATTACHMENT_LOAD_OP_CLEAR, // loadOp
270 VK_ATTACHMENT_STORE_OP_STORE, // storeOp
271 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // stencilLoadOp
272 VK_ATTACHMENT_STORE_OP_DONT_CARE, // stencilStoreOp
273 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // initialLayout
274 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // finalLayout
276 const VkAttachmentReference colorAttRef =
279 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // layout
281 const VkSubpassDescription subpassDesc =
283 (VkSubpassDescriptionFlags)0u, // flags
284 VK_PIPELINE_BIND_POINT_GRAPHICS, // pipelineBindPoint
285 0u, // inputAttachmentCount
286 DE_NULL, // pInputAttachments
287 1u, // colorAttachmentCount
288 &colorAttRef, // pColorAttachments
289 DE_NULL, // pResolveAttachments
290 DE_NULL, // depthStencilAttachment
291 0u, // preserveAttachmentCount
292 DE_NULL, // pPreserveAttachments
294 const VkRenderPassCreateInfo renderPassParams =
296 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // sType
299 1u, // attachmentCount
300 &colorAttDesc, // pAttachments
302 &subpassDesc, // pSubpasses
303 0u, // dependencyCount
304 DE_NULL, // pDependencies
306 const Unique<VkRenderPass> renderPass (createRenderPass(vk, vkDevice, &renderPassParams));
308 const VkImageViewCreateInfo colorAttViewParams =
310 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // sType
314 VK_IMAGE_VIEW_TYPE_2D, // viewType
315 VK_FORMAT_R8G8B8A8_UNORM, // format
317 VK_COMPONENT_SWIZZLE_R,
318 VK_COMPONENT_SWIZZLE_G,
319 VK_COMPONENT_SWIZZLE_B,
320 VK_COMPONENT_SWIZZLE_A
323 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
326 0u, // baseArrayLayer
328 }, // subresourceRange
330 const Unique<VkImageView> colorAttView (createImageView(vk, vkDevice, &colorAttViewParams));
333 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
335 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // sType
337 (vk::VkPipelineLayoutCreateFlags)0,
338 0u, // setLayoutCount
339 DE_NULL, // pSetLayouts
340 0u, // pushConstantRangeCount
341 DE_NULL, // pPushConstantRanges
343 const Unique<VkPipelineLayout> pipelineLayout (createPipelineLayout(vk, vkDevice, &pipelineLayoutParams));
346 const Unique<VkShaderModule> vertShaderModule (createShaderModule(vk, vkDevice, context.getBinaryCollection().get("vert"), 0));
347 const Unique<VkShaderModule> fragShaderModule (createShaderModule(vk, vkDevice, context.getBinaryCollection().get("frag"), 0));
350 const VkSpecializationInfo emptyShaderSpecParams =
357 const VkPipelineShaderStageCreateInfo shaderStageParams[] =
360 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // sType
363 VK_SHADER_STAGE_VERTEX_BIT, // stage
364 *vertShaderModule, // module
366 &emptyShaderSpecParams, // pSpecializationInfo
369 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // sType
372 VK_SHADER_STAGE_FRAGMENT_BIT, // stage
373 *fragShaderModule, // module
375 &emptyShaderSpecParams, // pSpecializationInfo
378 const VkPipelineDepthStencilStateCreateInfo depthStencilParams =
380 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // sType
383 DE_FALSE, // depthTestEnable
384 DE_FALSE, // depthWriteEnable
385 VK_COMPARE_OP_ALWAYS, // depthCompareOp
386 DE_FALSE, // depthBoundsTestEnable
387 DE_FALSE, // stencilTestEnable
389 VK_STENCIL_OP_KEEP, // failOp
390 VK_STENCIL_OP_KEEP, // passOp
391 VK_STENCIL_OP_KEEP, // depthFailOp
392 VK_COMPARE_OP_ALWAYS, // compareOp
398 VK_STENCIL_OP_KEEP, // failOp
399 VK_STENCIL_OP_KEEP, // passOp
400 VK_STENCIL_OP_KEEP, // depthFailOp
401 VK_COMPARE_OP_ALWAYS, // compareOp
406 -1.0f, // float minDepthBounds;
407 +1.0f, // float maxDepthBounds;
409 const VkViewport viewport0 =
413 (float)renderSize.x(), // width
414 (float)renderSize.y(), // height
418 const VkRect2D scissor0 =
425 (deUint32)renderSize.x(), // width
426 (deUint32)renderSize.y(), // height
429 const VkPipelineViewportStateCreateInfo viewportParams =
431 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // sType
435 &viewport0, // pViewports
437 &scissor0 // pScissors
439 const VkSampleMask sampleMask = ~0u;
440 const VkPipelineMultisampleStateCreateInfo multisampleParams =
442 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // sType
445 VK_SAMPLE_COUNT_1_BIT, // rasterizationSamples
446 VK_FALSE, // sampleShadingEnable
447 0.0f, // minSampleShading
448 &sampleMask, // sampleMask
449 VK_FALSE, // alphaToCoverageEnable
450 VK_FALSE, // alphaToOneEnable
452 const VkPipelineRasterizationStateCreateInfo rasterParams =
454 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // sType
457 VK_TRUE, // depthClampEnable
458 VK_FALSE, // rasterizerDiscardEnable
459 VK_POLYGON_MODE_FILL, // polygonMode
460 VK_CULL_MODE_NONE, // cullMode
461 VK_FRONT_FACE_COUNTER_CLOCKWISE, // frontFace
462 VK_FALSE, // depthBiasEnable
463 0.0f, // depthBiasConstantFactor
464 0.0f, // depthBiasClamp
465 0.0f, // depthBiasSlopeFactor
468 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyParams =
470 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // sType
473 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, // topology
474 DE_FALSE, // primitiveRestartEnable
476 const VkVertexInputBindingDescription vertexBinding0 =
479 (deUint32)sizeof(tcu::Vec4), // stride
480 VK_VERTEX_INPUT_RATE_VERTEX, // inputRate
482 const VkVertexInputAttributeDescription vertexAttrib0 =
486 VK_FORMAT_R32G32B32A32_SFLOAT, // format
489 const VkPipelineVertexInputStateCreateInfo vertexInputStateParams =
491 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // sType
494 1u, // vertexBindingDescriptionCount
495 &vertexBinding0, // pVertexBindingDescriptions
496 1u, // vertexAttributeDescriptionCount
497 &vertexAttrib0, // pVertexAttributeDescriptions
499 const VkPipelineColorBlendAttachmentState attBlendParams =
501 VK_FALSE, // blendEnable
502 VK_BLEND_FACTOR_ONE, // srcColorBlendFactor
503 VK_BLEND_FACTOR_ZERO, // dstColorBlendFactor
504 VK_BLEND_OP_ADD, // colorBlendOp
505 VK_BLEND_FACTOR_ONE, // srcAlphaBlendFactor
506 VK_BLEND_FACTOR_ZERO, // dstAlphaBlendFactor
507 VK_BLEND_OP_ADD, // alphaBlendOp
508 (VK_COLOR_COMPONENT_R_BIT|
509 VK_COLOR_COMPONENT_G_BIT|
510 VK_COLOR_COMPONENT_B_BIT|
511 VK_COLOR_COMPONENT_A_BIT), // colorWriteMask
513 const VkPipelineColorBlendStateCreateInfo blendParams =
515 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // sType
518 DE_FALSE, // logicOpEnable
519 VK_LOGIC_OP_COPY, // logicOp
520 1u, // attachmentCount
521 &attBlendParams, // pAttachments
522 { 0.0f, 0.0f, 0.0f, 0.0f }, // blendConstants[4]
524 const VkGraphicsPipelineCreateInfo pipelineParams =
526 VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // sType
529 (deUint32)DE_LENGTH_OF_ARRAY(shaderStageParams), // stageCount
530 shaderStageParams, // pStages
531 &vertexInputStateParams, // pVertexInputState
532 &inputAssemblyParams, // pInputAssemblyState
533 DE_NULL, // pTessellationState
534 &viewportParams, // pViewportState
535 &rasterParams, // pRasterizationState
536 &multisampleParams, // pMultisampleState
537 &depthStencilParams, // pDepthStencilState
538 &blendParams, // pColorBlendState
539 (const VkPipelineDynamicStateCreateInfo*)DE_NULL, // pDynamicState
540 *pipelineLayout, // layout
541 *renderPass, // renderPass
543 DE_NULL, // basePipelineHandle
544 0u, // basePipelineIndex
547 const Unique<VkPipeline> pipeline (createGraphicsPipeline(vk, vkDevice, DE_NULL, &pipelineParams));
550 const VkFramebufferCreateInfo framebufferParams =
552 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // sType
555 *renderPass, // renderPass
556 1u, // attachmentCount
557 &*colorAttView, // pAttachments
558 (deUint32)renderSize.x(), // width
559 (deUint32)renderSize.y(), // height
562 const Unique<VkFramebuffer> framebuffer (createFramebuffer(vk, vkDevice, &framebufferParams));
564 const VkCommandPoolCreateInfo cmdPoolParams =
566 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // sType
568 VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, // flags
569 queueFamilyIndex, // queueFamilyIndex
571 const Unique<VkCommandPool> cmdPool (createCommandPool(vk, vkDevice, &cmdPoolParams));
574 const VkCommandBufferAllocateInfo cmdBufParams =
576 VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // sType
579 VK_COMMAND_BUFFER_LEVEL_PRIMARY, // level
582 const Unique<VkCommandBuffer> cmdBuf (allocateCommandBuffer(vk, vkDevice, &cmdBufParams));
584 const VkCommandBufferBeginInfo cmdBufBeginParams =
586 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // sType
589 (const VkCommandBufferInheritanceInfo*)DE_NULL,
593 VK_CHECK(vk.beginCommandBuffer(*cmdBuf, &cmdBufBeginParams));
596 const VkMemoryBarrier vertFlushBarrier =
598 VK_STRUCTURE_TYPE_MEMORY_BARRIER, // sType
600 VK_ACCESS_HOST_WRITE_BIT, // srcAccessMask
601 VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT, // dstAccessMask
603 const VkImageMemoryBarrier colorAttBarrier =
605 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
608 (VK_ACCESS_COLOR_ATTACHMENT_READ_BIT|
609 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT), // dstAccessMask
610 VK_IMAGE_LAYOUT_UNDEFINED, // oldLayout
611 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // newLayout
612 queueFamilyIndex, // srcQueueFamilyIndex
613 queueFamilyIndex, // dstQueueFamilyIndex
616 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
619 0u, // baseArrayLayer
621 } // subresourceRange
623 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);
627 const VkClearValue clearValue = makeClearValueColorF32(0.125f, 0.25f, 0.75f, 1.0f);
628 const VkRenderPassBeginInfo passBeginParams =
630 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // sType
632 *renderPass, // renderPass
633 *framebuffer, // framebuffer
636 { (deUint32)renderSize.x(), (deUint32)renderSize.y() }
638 1u, // clearValueCount
639 &clearValue, // pClearValues
641 vk.cmdBeginRenderPass(*cmdBuf, &passBeginParams, VK_SUBPASS_CONTENTS_INLINE);
644 vk.cmdBindPipeline(*cmdBuf, VK_PIPELINE_BIND_POINT_GRAPHICS, *pipeline);
646 const VkDeviceSize bindingOffset = 0;
647 vk.cmdBindVertexBuffers(*cmdBuf, 0u, 1u, &vertexBuffer.get(), &bindingOffset);
649 vk.cmdDraw(*cmdBuf, 3u, 1u, 0u, 0u);
650 vk.cmdEndRenderPass(*cmdBuf);
653 const VkImageMemoryBarrier renderFinishBarrier =
655 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
657 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // outputMask
658 VK_ACCESS_TRANSFER_READ_BIT, // inputMask
659 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // oldLayout
660 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // newLayout
661 queueFamilyIndex, // srcQueueFamilyIndex
662 queueFamilyIndex, // dstQueueFamilyIndex
665 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
668 0u, // baseArraySlice
670 } // subresourceRange
672 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);
676 const VkBufferImageCopy copyParams =
678 (VkDeviceSize)0u, // bufferOffset
679 (deUint32)renderSize.x(), // bufferRowLength
680 (deUint32)renderSize.y(), // bufferImageHeight
682 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
684 0u, // baseArrayLayer
686 }, // imageSubresource
687 { 0u, 0u, 0u }, // imageOffset
689 (deUint32)renderSize.x(),
690 (deUint32)renderSize.y(),
694 vk.cmdCopyImageToBuffer(*cmdBuf, *image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *readImageBuffer, 1u, ©Params);
698 const VkBufferMemoryBarrier copyFinishBarrier =
700 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // sType
702 VK_ACCESS_TRANSFER_WRITE_BIT, // srcAccessMask
703 VK_ACCESS_HOST_READ_BIT, // dstAccessMask
704 queueFamilyIndex, // srcQueueFamilyIndex
705 queueFamilyIndex, // dstQueueFamilyIndex
706 *readImageBuffer, // buffer
708 imageSizeBytes // size
710 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);
713 VK_CHECK(vk.endCommandBuffer(*cmdBuf));
715 // Upload vertex data
717 const VkMappedMemoryRange range =
719 VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // sType
721 vertexBufferMemory->getMemory(), // memory
723 (VkDeviceSize)sizeof(vertices), // size
725 void* vertexBufPtr = vertexBufferMemory->getHostPtr();
727 deMemcpy(vertexBufPtr, &vertices[0], sizeof(vertices));
728 VK_CHECK(vk.flushMappedMemoryRanges(vkDevice, 1u, &range));
731 // Submit & wait for completion
733 const VkFenceCreateInfo fenceParams =
735 VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, // sType
739 const VkSubmitInfo submitInfo =
741 VK_STRUCTURE_TYPE_SUBMIT_INFO, // sType
743 0u, // waitSemaphoreCount
744 DE_NULL, // pWaitSemaphores
745 (const VkPipelineStageFlags*)DE_NULL,
746 1u, // commandBufferCount
747 &cmdBuf.get(), // pCommandBuffers
748 0u, // signalSemaphoreCount
749 DE_NULL, // pSignalSemaphores
751 const Unique<VkFence> fence (createFence(vk, vkDevice, &fenceParams));
753 VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, *fence));
754 VK_CHECK(vk.waitForFences(vkDevice, 1u, &fence.get(), DE_TRUE, ~0ull));
759 const VkMappedMemoryRange range =
761 VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // sType
763 readImageBufferMemory->getMemory(), // memory
765 imageSizeBytes, // size
767 void* imagePtr = readImageBufferMemory->getHostPtr();
769 VK_CHECK(vk.invalidateMappedMemoryRanges(vkDevice, 1u, &range));
770 context.getTestContext().getLog() << TestLog::Image("Result", "Result", tcu::ConstPixelBufferAccess(tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), renderSize.x(), renderSize.y(), 1, imagePtr));
773 return tcu::TestStatus::pass("Rendering succeeded");
778 tcu::TestCaseGroup* createSmokeTests (tcu::TestContext& testCtx)
780 de::MovePtr<tcu::TestCaseGroup> smokeTests (new tcu::TestCaseGroup(testCtx, "smoke", "Smoke Tests"));
782 addFunctionCase (smokeTests.get(), "create_sampler", "", createSamplerTest);
783 addFunctionCaseWithPrograms (smokeTests.get(), "create_shader", "", createShaderProgs, createShaderModuleTest);
784 addFunctionCaseWithPrograms (smokeTests.get(), "triangle", "", createTriangleProgs, renderTriangleTest);
785 addFunctionCaseWithPrograms (smokeTests.get(), "asm_triangle", "", createTriangleAsmProgs, renderTriangleTest);
787 return smokeTests.release();