1 #ifndef _VKCMDUTIL_HPP 2 #define _VKCMDUTIL_HPP 3 /*------------------------------------------------------------------------- 4 * Vulkan CTS Framework 5 * -------------------- 6 * 7 * Copyright (c) 2018 Google Inc. 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 * 21 *//*! 22 * \file 23 * \brief Utilities for commonly used command tasks 24 *//*--------------------------------------------------------------------*/ 25 26 #include "vkDefs.hpp" 27 #include "tcuVector.hpp" 28 29 namespace vk 30 { 31 32 void beginCommandBuffer (const DeviceInterface& vk, 33 const VkCommandBuffer commandBuffer, 34 VkCommandBufferUsageFlags flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT); 35 36 // Begins a secondary command buffer. 37 // Note if renderPass is not DE_NULL, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT will be added to the flags. 38 void beginSecondaryCommandBuffer (const DeviceInterface& vk, 39 const VkCommandBuffer commandBuffer, 40 const VkRenderPass renderPass = DE_NULL, 41 const VkFramebuffer framebuffer = DE_NULL, 42 const VkCommandBufferUsageFlags flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT); 43 44 void endCommandBuffer (const DeviceInterface& vk, 45 const VkCommandBuffer commandBuffer); 46 47 void beginRenderPass (const DeviceInterface& vk, 48 const VkCommandBuffer commandBuffer, 49 const VkRenderPass renderPass, 50 const VkFramebuffer framebuffer, 51 const VkRect2D& renderArea, 52 const deUint32 clearValueCount, 53 const VkClearValue* clearValues, 54 const VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE, 55 const void* pNext = DE_NULL); 56 57 void beginRenderPass (const DeviceInterface& vk, 58 const VkCommandBuffer commandBuffer, 59 const VkRenderPass renderPass, 60 const VkFramebuffer framebuffer, 61 const VkRect2D& renderArea, 62 const VkClearValue& clearValue, 63 const VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE); 64 65 void beginRenderPass (const DeviceInterface& vk, 66 const VkCommandBuffer commandBuffer, 67 const VkRenderPass renderPass, 68 const VkFramebuffer framebuffer, 69 const VkRect2D& renderArea, 70 const VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE); 71 72 void beginRenderPass (const DeviceInterface& vk, 73 const VkCommandBuffer commandBuffer, 74 const VkRenderPass renderPass, 75 const VkFramebuffer framebuffer, 76 const VkRect2D& renderArea, 77 const tcu::Vec4& clearColor, 78 const VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE); 79 80 void beginRenderPass (const DeviceInterface& vk, 81 const VkCommandBuffer commandBuffer, 82 const VkRenderPass renderPass, 83 const VkFramebuffer framebuffer, 84 const VkRect2D& renderArea, 85 const tcu::Vec4& clearColor, 86 const void* pNext, 87 const VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE); 88 89 void beginRenderPass (const DeviceInterface& vk, 90 const VkCommandBuffer commandBuffer, 91 const VkRenderPass renderPass, 92 const VkFramebuffer framebuffer, 93 const VkRect2D& renderArea, 94 const tcu::Vec4& clearColor, 95 const float clearDepth, 96 const deUint32 clearStencil, 97 const void* pNext, 98 const VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE); 99 100 void beginRenderPass (const DeviceInterface& vk, 101 const VkCommandBuffer commandBuffer, 102 const VkRenderPass renderPass, 103 const VkFramebuffer framebuffer, 104 const VkRect2D& renderArea, 105 const tcu::UVec4& clearColor, 106 const VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE); 107 108 void beginRenderPass (const DeviceInterface& vk, 109 const VkCommandBuffer commandBuffer, 110 const VkRenderPass renderPass, 111 const VkFramebuffer framebuffer, 112 const VkRect2D& renderArea, 113 const tcu::Vec4& clearColor, 114 const float clearDepth, 115 const deUint32 clearStencil, 116 const VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE); 117 118 void endRenderPass (const DeviceInterface& vk, 119 const VkCommandBuffer commandBuffer); 120 121 #ifndef CTS_USES_VULKANSC 122 void beginRendering (const DeviceInterface& vk, 123 const VkCommandBuffer commandBuffer, 124 const VkImageView colorImageView, 125 const VkRect2D& renderArea, 126 const VkClearValue& clearValue, 127 const VkImageLayout imageLayout = VK_IMAGE_LAYOUT_GENERAL, 128 const VkAttachmentLoadOp loadOperation = VK_ATTACHMENT_LOAD_OP_LOAD, 129 VkRenderingFlagsKHR renderingFlags = 0, 130 const deUint32 layerCount = 1u, 131 const deUint32 viewMask = 0u); 132 133 void beginRendering (const DeviceInterface& vk, 134 const VkCommandBuffer commandBuffer, 135 const VkImageView colorImageView, 136 const VkImageView depthStencilImageView, 137 const bool useStencilAttachment, 138 const VkRect2D& renderArea, 139 const VkClearValue& clearColorValue, 140 const VkClearValue& clearDepthValue, 141 const VkImageLayout colorImageLayout = VK_IMAGE_LAYOUT_GENERAL, 142 const VkImageLayout depthImageLayout = VK_IMAGE_LAYOUT_GENERAL, 143 const VkAttachmentLoadOp loadOperation = VK_ATTACHMENT_LOAD_OP_LOAD, 144 VkRenderingFlagsKHR renderingFlags = 0, 145 const deUint32 layerCount = 1u, 146 const deUint32 viewMask = 0u); 147 148 void endRendering (const DeviceInterface& vk, 149 const VkCommandBuffer commandBuffer); 150 #endif // CTS_USES_VULKANSC 151 152 void submitCommandsAndWait (const DeviceInterface& vk, 153 const VkDevice device, 154 const VkQueue queue, 155 const VkCommandBuffer commandBuffer, 156 const bool useDeviceGroups = false, 157 const deUint32 deviceMask = 1u, 158 const deUint32 waitSemaphoreCount = 0u, 159 const VkSemaphore* waitSemaphores = nullptr, 160 const VkPipelineStageFlags* waitStages = nullptr); 161 162 } // vk 163 164 #endif // _VKCMDUTIL_HPP 165