xref: /aosp_15_r20/external/deqp/external/vulkancts/framework/vulkan/vkCmdUtil.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
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 "vkRef.hpp"
28 #include "tcuVector.hpp"
29 
30 namespace vk
31 {
32 
33 void beginCommandBuffer(const DeviceInterface &vk, 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, const VkCommandBuffer commandBuffer,
39                                  const VkRenderPass renderPass         = VK_NULL_HANDLE,
40                                  const VkFramebuffer framebuffer       = VK_NULL_HANDLE,
41                                  const VkCommandBufferUsageFlags flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);
42 
43 void endCommandBuffer(const DeviceInterface &vk, const VkCommandBuffer commandBuffer);
44 
45 void beginRenderPass(const DeviceInterface &vk, const VkCommandBuffer commandBuffer, const VkRenderPass renderPass,
46                      const VkFramebuffer framebuffer, const VkRect2D &renderArea, const uint32_t clearValueCount,
47                      const VkClearValue *clearValues, const VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE,
48                      const void *pNext = DE_NULL);
49 
50 void beginRenderPass(const DeviceInterface &vk, const VkCommandBuffer commandBuffer, const VkRenderPass renderPass,
51                      const VkFramebuffer framebuffer, const VkRect2D &renderArea, const VkClearValue &clearValue,
52                      const VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE);
53 
54 void beginRenderPass(const DeviceInterface &vk, const VkCommandBuffer commandBuffer, const VkRenderPass renderPass,
55                      const VkFramebuffer framebuffer, const VkRect2D &renderArea,
56                      const VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE);
57 
58 void beginRenderPass(const DeviceInterface &vk, const VkCommandBuffer commandBuffer, const VkRenderPass renderPass,
59                      const VkFramebuffer framebuffer, const VkRect2D &renderArea, const tcu::Vec4 &clearColor,
60                      const VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE);
61 
62 void beginRenderPass(const DeviceInterface &vk, const VkCommandBuffer commandBuffer, const VkRenderPass renderPass,
63                      const VkFramebuffer framebuffer, const VkRect2D &renderArea, const tcu::Vec4 &clearColor,
64                      const void *pNext, const VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE);
65 
66 void beginRenderPass(const DeviceInterface &vk, const VkCommandBuffer commandBuffer, const VkRenderPass renderPass,
67                      const VkFramebuffer framebuffer, const VkRect2D &renderArea, const tcu::Vec4 &clearColor,
68                      const float clearDepth, const uint32_t clearStencil, const void *pNext,
69                      const VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE);
70 
71 void beginRenderPass(const DeviceInterface &vk, const VkCommandBuffer commandBuffer, const VkRenderPass renderPass,
72                      const VkFramebuffer framebuffer, const VkRect2D &renderArea, const tcu::UVec4 &clearColor,
73                      const VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE);
74 
75 void beginRenderPass(const DeviceInterface &vk, const VkCommandBuffer commandBuffer, const VkRenderPass renderPass,
76                      const VkFramebuffer framebuffer, const VkRect2D &renderArea, const tcu::Vec4 &clearColor,
77                      const float clearDepth, const uint32_t clearStencil,
78                      const VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE);
79 
80 void endRenderPass(const DeviceInterface &vk, const VkCommandBuffer commandBuffer);
81 
82 #ifndef CTS_USES_VULKANSC
83 void beginRendering(const DeviceInterface &vk, const VkCommandBuffer commandBuffer, const VkImageView colorImageView,
84                     const VkRect2D &renderArea, const VkClearValue &clearValue,
85                     const VkImageLayout imageLayout        = VK_IMAGE_LAYOUT_GENERAL,
86                     const VkAttachmentLoadOp loadOperation = VK_ATTACHMENT_LOAD_OP_LOAD,
87                     VkRenderingFlagsKHR renderingFlags = 0, const uint32_t layerCount = 1u,
88                     const uint32_t viewMask = 0u);
89 
90 void beginRendering(const DeviceInterface &vk, const VkCommandBuffer commandBuffer, const VkImageView colorImageView,
91                     const VkImageView depthStencilImageView, const bool useStencilAttachment,
92                     const VkRect2D &renderArea, const VkClearValue &clearColorValue,
93                     const VkClearValue &clearDepthValue, const VkImageLayout colorImageLayout = VK_IMAGE_LAYOUT_GENERAL,
94                     const VkImageLayout depthImageLayout   = VK_IMAGE_LAYOUT_GENERAL,
95                     const VkAttachmentLoadOp loadOperation = VK_ATTACHMENT_LOAD_OP_LOAD,
96                     VkRenderingFlagsKHR renderingFlags = 0, const uint32_t layerCount = 1u,
97                     const uint32_t viewMask = 0u);
98 
99 void endRendering(const DeviceInterface &vk, const VkCommandBuffer commandBuffer);
100 #endif // CTS_USES_VULKANSC
101 
102 void submitCommandsAndWait(const DeviceInterface &vk, const VkDevice device, const VkQueue queue,
103                            const VkCommandBuffer commandBuffer, const bool useDeviceGroups = false,
104                            const uint32_t deviceMask = 1u, const uint32_t waitSemaphoreCount = 0u,
105                            const VkSemaphore *waitSemaphores      = nullptr,
106                            const VkPipelineStageFlags *waitStages = nullptr, const uint32_t signalSemaphoreCount = 0u,
107                            const VkSemaphore *pSignalSemaphores = nullptr);
108 
109 vk::Move<VkFence> submitCommands(const DeviceInterface &vk, const VkDevice device, const VkQueue queue,
110                                  const VkCommandBuffer commandBuffer, const bool useDeviceGroups = false,
111                                  const uint32_t deviceMask = 1u, const uint32_t waitSemaphoreCount = 0u,
112                                  const VkSemaphore *waitSemaphores      = nullptr,
113                                  const VkPipelineStageFlags *waitStages = nullptr,
114                                  const uint32_t signalSemaphoreCount    = 0u,
115                                  const VkSemaphore *pSignalSemaphores   = nullptr);
116 
117 void waitForFence(const DeviceInterface &vk, const VkDevice device, const VkFence fence,
118                   uint64_t timeoutNanos = (~0ull));
119 
120 } // namespace vk
121 
122 #endif // _VKCMDUTIL_HPP
123