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,
34 							 const VkCommandBuffer		commandBuffer,
35 							 VkCommandBufferUsageFlags	flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);
36 
37 // Begins a secondary command buffer.
38 // Note if renderPass is not DE_NULL, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT will be added to the flags.
39 void beginSecondaryCommandBuffer	(const DeviceInterface&				vk,
40 									 const VkCommandBuffer				commandBuffer,
41 									 const VkRenderPass					renderPass		= DE_NULL,
42 									 const VkFramebuffer				framebuffer		= DE_NULL,
43 									 const VkCommandBufferUsageFlags	flags			= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);
44 
45 void endCommandBuffer		(const DeviceInterface&	vk,
46 							 const VkCommandBuffer	commandBuffer);
47 
48 void beginRenderPass (const DeviceInterface&	vk,
49 					  const VkCommandBuffer		commandBuffer,
50 					  const VkRenderPass		renderPass,
51 					  const VkFramebuffer		framebuffer,
52 					  const VkRect2D&			renderArea,
53 					  const deUint32			clearValueCount,
54 					  const VkClearValue*		clearValues,
55 					  const VkSubpassContents	contents			= VK_SUBPASS_CONTENTS_INLINE,
56 					  const void*				pNext				= DE_NULL);
57 
58 void beginRenderPass (const DeviceInterface&	vk,
59 					  const VkCommandBuffer		commandBuffer,
60 					  const VkRenderPass		renderPass,
61 					  const VkFramebuffer		framebuffer,
62 					  const VkRect2D&			renderArea,
63 					  const VkClearValue&		clearValue,
64 					  const VkSubpassContents	contents = VK_SUBPASS_CONTENTS_INLINE);
65 
66 void beginRenderPass (const DeviceInterface&	vk,
67 					  const VkCommandBuffer		commandBuffer,
68 					  const VkRenderPass		renderPass,
69 					  const VkFramebuffer		framebuffer,
70 					  const VkRect2D&			renderArea,
71 					  const VkSubpassContents	contents = VK_SUBPASS_CONTENTS_INLINE);
72 
73 void beginRenderPass (const DeviceInterface&	vk,
74 					  const VkCommandBuffer		commandBuffer,
75 					  const VkRenderPass		renderPass,
76 					  const VkFramebuffer		framebuffer,
77 					  const VkRect2D&			renderArea,
78 					  const tcu::Vec4&			clearColor,
79 					  const VkSubpassContents	contents = VK_SUBPASS_CONTENTS_INLINE);
80 
81 void beginRenderPass (const DeviceInterface&	vk,
82 					  const VkCommandBuffer		commandBuffer,
83 					  const VkRenderPass		renderPass,
84 					  const VkFramebuffer		framebuffer,
85 					  const VkRect2D&			renderArea,
86 					  const tcu::Vec4&			clearColor,
87 					  const void*				pNext,
88 					  const VkSubpassContents	contents = VK_SUBPASS_CONTENTS_INLINE);
89 
90 void beginRenderPass (const DeviceInterface&	vk,
91 					  const VkCommandBuffer		commandBuffer,
92 					  const VkRenderPass		renderPass,
93 					  const VkFramebuffer		framebuffer,
94 					  const VkRect2D&			renderArea,
95 					  const tcu::Vec4&			clearColor,
96 					  const float				clearDepth,
97 					  const deUint32			clearStencil,
98 					  const void*				pNext,
99 					  const VkSubpassContents	contents = VK_SUBPASS_CONTENTS_INLINE);
100 
101 void beginRenderPass (const DeviceInterface&	vk,
102 					  const VkCommandBuffer		commandBuffer,
103 					  const VkRenderPass		renderPass,
104 					  const VkFramebuffer		framebuffer,
105 					  const VkRect2D&			renderArea,
106 					  const tcu::UVec4&			clearColor,
107 					  const VkSubpassContents	contents = VK_SUBPASS_CONTENTS_INLINE);
108 
109 void beginRenderPass (const DeviceInterface&	vk,
110 					  const VkCommandBuffer		commandBuffer,
111 					  const VkRenderPass		renderPass,
112 					  const VkFramebuffer		framebuffer,
113 					  const VkRect2D&			renderArea,
114 					  const tcu::Vec4&			clearColor,
115 					  const float				clearDepth,
116 					  const deUint32			clearStencil,
117 					  const VkSubpassContents	contents = VK_SUBPASS_CONTENTS_INLINE);
118 
119 void endRenderPass (const DeviceInterface&	vk,
120 					const VkCommandBuffer	commandBuffer);
121 
122 #ifndef CTS_USES_VULKANSC
123 void beginRendering (const DeviceInterface&		vk,
124 					 const VkCommandBuffer		commandBuffer,
125 					 const VkImageView			colorImageView,
126 					 const VkRect2D&			renderArea,
127 					 const VkClearValue&		clearValue,
128 					 const VkImageLayout		imageLayout = VK_IMAGE_LAYOUT_GENERAL,
129 					 const VkAttachmentLoadOp	loadOperation = VK_ATTACHMENT_LOAD_OP_LOAD,
130 					 VkRenderingFlagsKHR		renderingFlags = 0,
131 					 const deUint32				layerCount = 1u,
132 					 const deUint32				viewMask = 0u);
133 
134 void beginRendering (const DeviceInterface&		vk,
135 					 const VkCommandBuffer		commandBuffer,
136 					 const VkImageView			colorImageView,
137 					 const VkImageView			depthStencilImageView,
138 					 const bool					useStencilAttachment,
139 					 const VkRect2D&			renderArea,
140 					 const VkClearValue&		clearColorValue,
141 					 const VkClearValue&		clearDepthValue,
142 					 const VkImageLayout		colorImageLayout = VK_IMAGE_LAYOUT_GENERAL,
143 					 const VkImageLayout		depthImageLayout = VK_IMAGE_LAYOUT_GENERAL,
144 					 const VkAttachmentLoadOp	loadOperation = VK_ATTACHMENT_LOAD_OP_LOAD,
145 					 VkRenderingFlagsKHR		renderingFlags = 0,
146 					 const deUint32				layerCount = 1u,
147 					 const deUint32				viewMask = 0u);
148 
149 void endRendering (const DeviceInterface&		vk,
150 				   const VkCommandBuffer		commandBuffer);
151 #endif // CTS_USES_VULKANSC
152 
153 void submitCommandsAndWait	(const DeviceInterface&			vk,
154 							 const VkDevice					device,
155 							 const VkQueue					queue,
156 							 const VkCommandBuffer			commandBuffer,
157 							 const bool						useDeviceGroups = false,
158 							 const deUint32					deviceMask = 1u,
159 							 const deUint32					waitSemaphoreCount = 0u,
160 							 const VkSemaphore*				waitSemaphores = nullptr,
161 							 const VkPipelineStageFlags*	waitStages = nullptr);
162 
163 vk::Move<VkFence> submitCommands (const DeviceInterface&		vk,
164 								  const VkDevice				device,
165 								  const VkQueue					queue,
166 								  const VkCommandBuffer			commandBuffer,
167 								  const bool					useDeviceGroups = false,
168 								  const deUint32				deviceMask = 1u,
169 								  const deUint32				waitSemaphoreCount = 0u,
170 								  const VkSemaphore*			waitSemaphores = nullptr,
171 								  const VkPipelineStageFlags*	waitStages = nullptr);
172 
173 void waitForFence (const DeviceInterface& vk, const VkDevice device, const VkFence fence, uint64_t timeoutNanos = (~0ull));
174 
175 } // vk
176 
177 #endif // _VKCMDUTIL_HPP
178