Diligent Engine  v.2.4.g
VulkanCommandBuffer.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2019-2021 Diligent Graphics LLC
3  * Copyright 2015-2019 Egor Yusov
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * In no event and under no legal theory, whether in tort (including negligence),
18  * contract, or otherwise, unless required by applicable law (such as deliberate
19  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
20  * liable for any damages, including any direct, indirect, special, incidental,
21  * or consequential damages of any character arising as a result of this License or
22  * out of the use or inability to use the software (including but not limited to damages
23  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
24  * all other commercial damages or losses), even if such Contributor has been advised
25  * of the possibility of such damages.
26  */
27 
28 #pragma once
29 
30 #include "VulkanHeaders.h"
31 #include "DebugUtilities.hpp"
32 
33 namespace VulkanUtilities
34 {
35 
37 {
38 public:
39  VulkanCommandBuffer(VkPipelineStageFlags EnabledShaderStages) noexcept :
40  m_EnabledShaderStages{EnabledShaderStages}
41  {}
42 
43  // clang-format off
44  VulkanCommandBuffer (const VulkanCommandBuffer&) = delete;
48  // clang-format on
49 
50  __forceinline void ClearColorImage(VkImage Image,
51  const VkClearColorValue& Color,
52  const VkImageSubresourceRange& Subresource)
53  {
54  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
55  VERIFY(m_State.RenderPass == VK_NULL_HANDLE, "vkCmdClearColorImage() must be called outside of render pass (17.1)");
56  VERIFY(Subresource.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT, "The aspectMask of all image subresource ranges must only include VK_IMAGE_ASPECT_COLOR_BIT (17.1)");
57 
58  vkCmdClearColorImage(
59  m_VkCmdBuffer,
60  Image,
61  VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // must be VK_IMAGE_LAYOUT_GENERAL or VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
62  &Color,
63  1,
64  &Subresource);
65  }
66 
67  __forceinline void ClearDepthStencilImage(VkImage Image,
68  const VkClearDepthStencilValue& DepthStencil,
69  const VkImageSubresourceRange& Subresource)
70  {
71  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
72  VERIFY(m_State.RenderPass == VK_NULL_HANDLE, "vkCmdClearDepthStencilImage() must be called outside of render pass (17.1)");
73  // clang-format off
74  VERIFY((Subresource.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) != 0 &&
75  (Subresource.aspectMask & ~(VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) == 0,
76  "The aspectMask of all image subresource ranges must only include VK_IMAGE_ASPECT_DEPTH_BIT or VK_IMAGE_ASPECT_STENCIL_BIT(17.1)");
77  // clang-format on
78 
79  vkCmdClearDepthStencilImage(
80  m_VkCmdBuffer,
81  Image,
82  VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // must be VK_IMAGE_LAYOUT_GENERAL or VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
83  &DepthStencil,
84  1,
85  &Subresource);
86  }
87 
88  __forceinline void ClearAttachment(const VkClearAttachment& Attachment, const VkClearRect& ClearRect)
89  {
90  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
91  VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "vkCmdClearAttachments() must be called inside render pass (17.2)");
92 
93  vkCmdClearAttachments(
94  m_VkCmdBuffer,
95  1,
96  &Attachment,
97  1,
98  &ClearRect // The rectangular region specified by each element of pRects must be
99  // contained within the render area of the current render pass instance
100  );
101  }
102 
103  __forceinline void Draw(uint32_t VertexCount, uint32_t InstanceCount, uint32_t FirstVertex, uint32_t FirstInstance)
104  {
105  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
106  VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "vkCmdDraw() must be called inside render pass (19.3)");
107  VERIFY(m_State.GraphicsPipeline != VK_NULL_HANDLE, "No graphics pipeline bound");
108 
109  vkCmdDraw(m_VkCmdBuffer, VertexCount, InstanceCount, FirstVertex, FirstInstance);
110  }
111 
112  __forceinline void DrawIndexed(uint32_t IndexCount, uint32_t InstanceCount, uint32_t FirstIndex, int32_t VertexOffset, uint32_t FirstInstance)
113  {
114  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
115  VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "vkCmdDrawIndexed() must be called inside render pass (19.3)");
116  VERIFY(m_State.GraphicsPipeline != VK_NULL_HANDLE, "No graphics pipeline bound");
117  VERIFY(m_State.IndexBuffer != VK_NULL_HANDLE, "No index buffer bound");
118 
119  vkCmdDrawIndexed(m_VkCmdBuffer, IndexCount, InstanceCount, FirstIndex, VertexOffset, FirstInstance);
120  }
121 
122  __forceinline void DrawIndirect(VkBuffer Buffer, VkDeviceSize Offset, uint32_t DrawCount, uint32_t Stride)
123  {
124  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
125  VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "vkCmdDrawIndirect() must be called inside render pass (19.3)");
126  VERIFY(m_State.GraphicsPipeline != VK_NULL_HANDLE, "No graphics pipeline bound");
127 
128  vkCmdDrawIndirect(m_VkCmdBuffer, Buffer, Offset, DrawCount, Stride);
129  }
130 
131  __forceinline void DrawIndexedIndirect(VkBuffer Buffer, VkDeviceSize Offset, uint32_t DrawCount, uint32_t Stride)
132  {
133  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
134  VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "vkCmdDrawIndirect() must be called inside render pass (19.3)");
135  VERIFY(m_State.GraphicsPipeline != VK_NULL_HANDLE, "No graphics pipeline bound");
136  VERIFY(m_State.IndexBuffer != VK_NULL_HANDLE, "No index buffer bound");
137 
138  vkCmdDrawIndexedIndirect(m_VkCmdBuffer, Buffer, Offset, DrawCount, Stride);
139  }
140 
141  __forceinline void DrawMesh(uint32_t TaskCount, uint32_t FirstTask)
142  {
143 #if DILIGENT_USE_VOLK
144  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
145  VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "vkCmdDrawMeshTasksNV() must be called inside render pass");
146  VERIFY(m_State.GraphicsPipeline != VK_NULL_HANDLE, "No graphics pipeline bound");
147 
148  vkCmdDrawMeshTasksNV(m_VkCmdBuffer, TaskCount, FirstTask);
149 #else
150  UNSUPPORTED("DrawMesh is not supported when vulkan library is linked statically");
151 #endif
152  }
153 
154  __forceinline void DrawMeshIndirect(VkBuffer Buffer, VkDeviceSize Offset, uint32_t DrawCount, uint32_t Stride)
155  {
156 #if DILIGENT_USE_VOLK
157  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
158  VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "vkCmdDrawMeshTasksNV() must be called inside render pass");
159  VERIFY(m_State.GraphicsPipeline != VK_NULL_HANDLE, "No graphics pipeline bound");
160 
161  vkCmdDrawMeshTasksIndirectNV(m_VkCmdBuffer, Buffer, Offset, DrawCount, Stride);
162 #else
163  UNSUPPORTED("DrawMeshIndirect is not supported when vulkan library is linked statically");
164 #endif
165  }
166 
167  __forceinline void DrawMeshIndirectCount(VkBuffer Buffer, VkDeviceSize Offset, VkBuffer CountBuffer, VkDeviceSize CountBufferOffset, uint32_t MaxDrawCount, uint32_t Stride)
168  {
169 #if DILIGENT_USE_VOLK
170  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
171  VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "vkCmdDrawMeshTasksIndirectCountNV() must be called inside render pass");
172  VERIFY(m_State.GraphicsPipeline != VK_NULL_HANDLE, "No graphics pipeline bound");
173 
174  vkCmdDrawMeshTasksIndirectCountNV(m_VkCmdBuffer, Buffer, Offset, CountBuffer, CountBufferOffset, MaxDrawCount, Stride);
175 #else
176  UNSUPPORTED("DrawMeshIndirectCount is not supported when vulkan library is linked statically");
177 #endif
178  }
179 
180  __forceinline void Dispatch(uint32_t GroupCountX, uint32_t GroupCountY, uint32_t GroupCountZ)
181  {
182  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
183  VERIFY(m_State.RenderPass == VK_NULL_HANDLE, "vkCmdDispatch() must be called outside of render pass (27)");
184  VERIFY(m_State.ComputePipeline != VK_NULL_HANDLE, "No compute pipeline bound");
185 
186  vkCmdDispatch(m_VkCmdBuffer, GroupCountX, GroupCountY, GroupCountZ);
187  }
188 
189  __forceinline void DispatchIndirect(VkBuffer Buffer, VkDeviceSize Offset)
190  {
191  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
192  VERIFY(m_State.RenderPass == VK_NULL_HANDLE, "vkCmdDispatchIndirect() must be called outside of render pass (27)");
193  VERIFY(m_State.ComputePipeline != VK_NULL_HANDLE, "No compute pipeline bound");
194 
195  vkCmdDispatchIndirect(m_VkCmdBuffer, Buffer, Offset);
196  }
197 
198  __forceinline void BeginRenderPass(VkRenderPass RenderPass,
199  VkFramebuffer Framebuffer,
200  uint32_t FramebufferWidth,
201  uint32_t FramebufferHeight,
202  uint32_t ClearValueCount = 0,
203  const VkClearValue* pClearValues = nullptr)
204  {
205  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
206  VERIFY(m_State.RenderPass == VK_NULL_HANDLE, "Current pass has not been ended");
207 
208  if (m_State.RenderPass != RenderPass || m_State.Framebuffer != Framebuffer)
209  {
210  VkRenderPassBeginInfo BeginInfo;
211  BeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
212  BeginInfo.pNext = nullptr;
213  BeginInfo.renderPass = RenderPass;
214  BeginInfo.framebuffer = Framebuffer;
215  // The render area MUST be contained within the framebuffer dimensions (7.4)
216  BeginInfo.renderArea = {{0, 0}, {FramebufferWidth, FramebufferHeight}};
217  BeginInfo.clearValueCount = ClearValueCount;
218  BeginInfo.pClearValues = pClearValues; // an array of VkClearValue structures that contains clear values for
219  // each attachment, if the attachment uses a loadOp value of VK_ATTACHMENT_LOAD_OP_CLEAR
220  // or if the attachment has a depth/stencil format and uses a stencilLoadOp value of
221  // VK_ATTACHMENT_LOAD_OP_CLEAR. The array is indexed by attachment number. Only elements
222  // corresponding to cleared attachments are used. Other elements of pClearValues are
223  // ignored (7.4)
224 
225  vkCmdBeginRenderPass(m_VkCmdBuffer, &BeginInfo,
226  VK_SUBPASS_CONTENTS_INLINE // the contents of the subpass will be recorded inline in the
227  // primary command buffer, and secondary command buffers must not
228  // be executed within the subpass
229  );
230  m_State.RenderPass = RenderPass;
231  m_State.Framebuffer = Framebuffer;
232  m_State.FramebufferWidth = FramebufferWidth;
233  m_State.FramebufferHeight = FramebufferHeight;
234  }
235  }
236 
237  __forceinline void EndRenderPass()
238  {
239  VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "Render pass has not been started");
240  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
241  vkCmdEndRenderPass(m_VkCmdBuffer);
242  m_State.RenderPass = VK_NULL_HANDLE;
243  m_State.Framebuffer = VK_NULL_HANDLE;
244  m_State.FramebufferWidth = 0;
245  m_State.FramebufferHeight = 0;
246  if (m_State.InsidePassQueries != 0)
247  {
248  LOG_ERROR_MESSAGE("Ending render pass while there are outstanding queries that have been started inside the pass, "
249  "but have not been ended. Vulkan requires that a query must either begin and end inside the same "
250  "subpass of a render pass instance, or must both begin and end outside of a render pass "
251  "instance (i.e. contain entire render pass instances). (17.2)");
252  }
253  }
254 
255  __forceinline void NextSubpass()
256  {
257  VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "Render pass has not been started");
258  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
259  vkCmdNextSubpass(m_VkCmdBuffer, VK_SUBPASS_CONTENTS_INLINE);
260  }
261 
262  __forceinline void EndCommandBuffer()
263  {
264  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
265  vkEndCommandBuffer(m_VkCmdBuffer);
266  }
267 
268  __forceinline void Reset()
269  {
270  m_VkCmdBuffer = VK_NULL_HANDLE;
271  m_State = StateCache{};
272  }
273 
274  __forceinline void BindComputePipeline(VkPipeline ComputePipeline)
275  {
276  // 9.8
277  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
278  if (m_State.ComputePipeline != ComputePipeline)
279  {
280  vkCmdBindPipeline(m_VkCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, ComputePipeline);
281  m_State.ComputePipeline = ComputePipeline;
282  }
283  }
284 
285  __forceinline void BindGraphicsPipeline(VkPipeline GraphicsPipeline)
286  {
287  // 9.8
288  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
289  if (m_State.GraphicsPipeline != GraphicsPipeline)
290  {
291  vkCmdBindPipeline(m_VkCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, GraphicsPipeline);
292  m_State.GraphicsPipeline = GraphicsPipeline;
293  }
294  }
295 
296  __forceinline void BindRayTracingPipeline(VkPipeline RayTracingPipeline)
297  {
298  // 9.8
299  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
300  if (m_State.RayTracingPipeline != RayTracingPipeline)
301  {
302  vkCmdBindPipeline(m_VkCmdBuffer, VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR, RayTracingPipeline);
303  m_State.RayTracingPipeline = RayTracingPipeline;
304  }
305  }
306 
307  __forceinline void SetViewports(uint32_t FirstViewport, uint32_t ViewportCount, const VkViewport* pViewports)
308  {
309  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
310  vkCmdSetViewport(m_VkCmdBuffer, FirstViewport, ViewportCount, pViewports);
311  }
312 
313  __forceinline void SetScissorRects(uint32_t FirstScissor, uint32_t ScissorCount, const VkRect2D* pScissors)
314  {
315  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
316  vkCmdSetScissor(m_VkCmdBuffer, FirstScissor, ScissorCount, pScissors);
317  }
318 
319  __forceinline void SetStencilReference(uint32_t Reference)
320  {
321  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
322  vkCmdSetStencilReference(m_VkCmdBuffer, VK_STENCIL_FRONT_AND_BACK, Reference);
323  }
324 
325  __forceinline void SetBlendConstants(const float BlendConstants[4])
326  {
327  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
328  vkCmdSetBlendConstants(m_VkCmdBuffer, BlendConstants);
329  }
330 
331  __forceinline void BindIndexBuffer(VkBuffer Buffer, VkDeviceSize Offset, VkIndexType IndexType)
332  {
333  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
334  // clang-format off
335  if (m_State.IndexBuffer != Buffer ||
336  m_State.IndexBufferOffset != Offset ||
337  m_State.IndexType != IndexType)
338  {
339  // clang-format on
340  vkCmdBindIndexBuffer(m_VkCmdBuffer, Buffer, Offset, IndexType);
341  m_State.IndexBuffer = Buffer;
342  m_State.IndexBufferOffset = Offset;
343  m_State.IndexType = IndexType;
344  }
345  }
346 
347  __forceinline void BindVertexBuffers(uint32_t firstBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets)
348  {
349  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
350  vkCmdBindVertexBuffers(m_VkCmdBuffer, firstBinding, bindingCount, pBuffers, pOffsets);
351  }
352 
353  static void TransitionImageLayout(VkCommandBuffer CmdBuffer,
354  VkImage Image,
355  VkImageLayout OldLayout,
356  VkImageLayout NewLayout,
357  const VkImageSubresourceRange& SubresRange,
358  VkPipelineStageFlags EnabledShaderStages,
359  VkPipelineStageFlags SrcStages = 0,
360  VkPipelineStageFlags DestStages = 0);
361 
362  __forceinline void TransitionImageLayout(VkImage Image,
363  VkImageLayout OldLayout,
364  VkImageLayout NewLayout,
365  const VkImageSubresourceRange& SubresRange,
366  VkPipelineStageFlags SrcStages = 0,
367  VkPipelineStageFlags DestStages = 0)
368  {
369  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
370  if (m_State.RenderPass != VK_NULL_HANDLE)
371  {
372  // Image layout transitions within a render pass execute
373  // dependencies between attachments
374  EndRenderPass();
375  }
376  TransitionImageLayout(m_VkCmdBuffer, Image, OldLayout, NewLayout, SubresRange, m_EnabledShaderStages, SrcStages, DestStages);
377  }
378 
379 
380  static void BufferMemoryBarrier(VkCommandBuffer CmdBuffer,
381  VkBuffer Buffer,
382  VkAccessFlags srcAccessMask,
383  VkAccessFlags dstAccessMask,
384  VkPipelineStageFlags EnabledShaderStages,
385  VkPipelineStageFlags SrcStages = 0,
386  VkPipelineStageFlags DestStages = 0);
387 
388  __forceinline void BufferMemoryBarrier(VkBuffer Buffer,
389  VkAccessFlags srcAccessMask,
390  VkAccessFlags dstAccessMask,
391  VkPipelineStageFlags SrcStages = 0,
392  VkPipelineStageFlags DestStages = 0)
393  {
394  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
395  if (m_State.RenderPass != VK_NULL_HANDLE)
396  {
397  // Image layout transitions within a render pass execute
398  // dependencies between attachments
399  EndRenderPass();
400  }
401  BufferMemoryBarrier(m_VkCmdBuffer, Buffer, srcAccessMask, dstAccessMask, m_EnabledShaderStages, SrcStages, DestStages);
402  }
403 
404 
405  // for Acceleration structures
406  static void ASMemoryBarrier(VkCommandBuffer CmdBuffer,
407  VkAccessFlags srcAccessMask,
408  VkAccessFlags dstAccessMask,
409  VkPipelineStageFlags EnabledShaderStages,
410  VkPipelineStageFlags SrcStages = 0,
411  VkPipelineStageFlags DestStages = 0);
412 
413  __forceinline void ASMemoryBarrier(VkAccessFlags srcAccessMask,
414  VkAccessFlags dstAccessMask,
415  VkPipelineStageFlags SrcStages = 0,
416  VkPipelineStageFlags DestStages = 0)
417  {
418  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
419  if (m_State.RenderPass != VK_NULL_HANDLE)
420  {
421  // Image layout transitions within a render pass execute
422  // dependencies between attachments
423  EndRenderPass();
424  }
425  ASMemoryBarrier(m_VkCmdBuffer, srcAccessMask, dstAccessMask, m_EnabledShaderStages, SrcStages, DestStages);
426  }
427 
428  __forceinline void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint,
429  VkPipelineLayout layout,
430  uint32_t firstSet,
431  uint32_t descriptorSetCount,
432  const VkDescriptorSet* pDescriptorSets,
433  uint32_t dynamicOffsetCount = 0,
434  const uint32_t* pDynamicOffsets = nullptr)
435  {
436  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
437  vkCmdBindDescriptorSets(m_VkCmdBuffer, pipelineBindPoint, layout, firstSet, descriptorSetCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets);
438  }
439 
440  __forceinline void CopyBuffer(VkBuffer srcBuffer,
441  VkBuffer dstBuffer,
442  uint32_t regionCount,
443  const VkBufferCopy* pRegions)
444  {
445  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
446  if (m_State.RenderPass != VK_NULL_HANDLE)
447  {
448  // Copy buffer operation must be performed outside of render pass.
449  EndRenderPass();
450  }
451  vkCmdCopyBuffer(m_VkCmdBuffer, srcBuffer, dstBuffer, regionCount, pRegions);
452  }
453 
454  __forceinline void CopyImage(VkImage srcImage,
455  VkImageLayout srcImageLayout,
456  VkImage dstImage,
457  VkImageLayout dstImageLayout,
458  uint32_t regionCount,
459  const VkImageCopy* pRegions)
460  {
461  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
462  if (m_State.RenderPass != VK_NULL_HANDLE)
463  {
464  // Copy operations must be performed outside of render pass.
465  EndRenderPass();
466  }
467 
468  vkCmdCopyImage(m_VkCmdBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);
469  }
470 
471  __forceinline void CopyBufferToImage(VkBuffer srcBuffer,
472  VkImage dstImage,
473  VkImageLayout dstImageLayout,
474  uint32_t regionCount,
475  const VkBufferImageCopy* pRegions)
476  {
477  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
478  if (m_State.RenderPass != VK_NULL_HANDLE)
479  {
480  // Copy operations must be performed outside of render pass.
481  EndRenderPass();
482  }
483 
484  vkCmdCopyBufferToImage(m_VkCmdBuffer, srcBuffer, dstImage, dstImageLayout, regionCount, pRegions);
485  }
486 
487  __forceinline void CopyImageToBuffer(VkImage srcImage,
488  VkImageLayout srcImageLayout,
489  VkBuffer dstBuffer,
490  uint32_t regionCount,
491  const VkBufferImageCopy* pRegions)
492  {
493  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
494  if (m_State.RenderPass != VK_NULL_HANDLE)
495  {
496  // Copy operations must be performed outside of render pass.
497  EndRenderPass();
498  }
499 
500  vkCmdCopyImageToBuffer(m_VkCmdBuffer, srcImage, srcImageLayout, dstBuffer, regionCount, pRegions);
501  }
502 
503  __forceinline void BlitImage(VkImage srcImage,
504  VkImageLayout srcImageLayout,
505  VkImage dstImage,
506  VkImageLayout dstImageLayout,
507  uint32_t regionCount,
508  const VkImageBlit* pRegions,
509  VkFilter filter)
510  {
511  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
512  if (m_State.RenderPass != VK_NULL_HANDLE)
513  {
514  // Blit must be performed outside of render pass.
515  EndRenderPass();
516  }
517 
518  vkCmdBlitImage(m_VkCmdBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, filter);
519  }
520 
521  __forceinline void ResolveImage(VkImage srcImage,
522  VkImageLayout srcImageLayout,
523  VkImage dstImage,
524  VkImageLayout dstImageLayout,
525  uint32_t regionCount,
526  const VkImageResolve* pRegions)
527  {
528  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
529  if (m_State.RenderPass != VK_NULL_HANDLE)
530  {
531  // Resolve must be performed outside of render pass.
532  EndRenderPass();
533  }
534  vkCmdResolveImage(m_VkCmdBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);
535  }
536 
537  __forceinline void BeginQuery(VkQueryPool queryPool,
538  uint32_t query,
539  VkQueryControlFlags flags,
540  uint32_t queryFlag)
541  {
542  // queryPool must have been created with a queryType that differs from that of any queries that
543  // are active within commandBuffer (17.2). In other words, only one query of given type can be active
544  // in the command buffer.
545 
546  if ((m_State.InsidePassQueries | m_State.OutsidePassQueries) & queryFlag)
547  {
548  LOG_ERROR_MESSAGE("Another query of the same type is already active in the command buffer. "
549  "Overlapping queries are not allowed in Vulkan. The command will be ignored.");
550  return;
551  }
552 
553  // A query must either begin and end inside the same subpass of a render pass instance, or must both
554  // begin and end outside of a render pass instance (i.e. contain entire render pass instances) (17.2).
555 
556  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
557  vkCmdBeginQuery(m_VkCmdBuffer, queryPool, query, flags);
558  if (m_State.RenderPass != VK_NULL_HANDLE)
559  m_State.InsidePassQueries |= queryFlag;
560  else
561  m_State.OutsidePassQueries |= queryFlag;
562  }
563 
564  __forceinline void EndQuery(VkQueryPool queryPool,
565  uint32_t query,
566  uint32_t queryFlag)
567  {
568  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
569  vkCmdEndQuery(m_VkCmdBuffer, queryPool, query);
570  if (m_State.RenderPass != VK_NULL_HANDLE)
571  {
572  VERIFY((m_State.InsidePassQueries & queryFlag) != 0, "No active inside-pass queries found.");
573  m_State.InsidePassQueries &= ~queryFlag;
574  }
575  else
576  {
577  VERIFY((m_State.OutsidePassQueries & queryFlag) != 0, "No active outside-pass queries found.");
578  m_State.OutsidePassQueries &= ~queryFlag;
579  }
580  }
581 
582  __forceinline void WriteTimestamp(VkPipelineStageFlagBits pipelineStage,
583  VkQueryPool queryPool,
584  uint32_t query)
585  {
586  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
587  vkCmdWriteTimestamp(m_VkCmdBuffer, pipelineStage, queryPool, query);
588  }
589 
590  __forceinline void ResetQueryPool(VkQueryPool queryPool,
591  uint32_t firstQuery,
592  uint32_t queryCount)
593  {
594  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
595  if (m_State.RenderPass != VK_NULL_HANDLE)
596  {
597  // Query pool reset must be performed outside of render pass (17.2).
598  EndRenderPass();
599  }
600  vkCmdResetQueryPool(m_VkCmdBuffer, queryPool, firstQuery, queryCount);
601  }
602 
603  __forceinline void CopyQueryPoolResults(VkQueryPool queryPool,
604  uint32_t firstQuery,
605  uint32_t queryCount,
606  VkBuffer dstBuffer,
607  VkDeviceSize dstOffset,
608  VkDeviceSize stride,
609  VkQueryResultFlags flags)
610  {
611  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
612  if (m_State.RenderPass != VK_NULL_HANDLE)
613  {
614  // Copy query results must be performed outside of render pass (17.2).
615  EndRenderPass();
616  }
617  vkCmdCopyQueryPoolResults(m_VkCmdBuffer, queryPool, firstQuery, queryCount,
618  dstBuffer, dstOffset, stride, flags);
619  }
620 
621  __forceinline void BuildAccelerationStructure(uint32_t infoCount,
622  const VkAccelerationStructureBuildGeometryInfoKHR* pInfos,
623  const VkAccelerationStructureBuildRangeInfoKHR* const* ppBuildRangeInfos)
624  {
625 #if DILIGENT_USE_VOLK
626  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
627  if (m_State.RenderPass != VK_NULL_HANDLE)
628  {
629  // Build AS operations must be performed outside of render pass.
630  EndRenderPass();
631  }
632  vkCmdBuildAccelerationStructuresKHR(m_VkCmdBuffer, infoCount, pInfos, ppBuildRangeInfos);
633 #else
634  UNSUPPORTED("Ray tracing is not supported when vulkan library is linked statically");
635 #endif
636  }
637 
638  __forceinline void CopyAccelerationStructure(const VkCopyAccelerationStructureInfoKHR& Info)
639  {
640 #if DILIGENT_USE_VOLK
641  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
642  if (m_State.RenderPass != VK_NULL_HANDLE)
643  {
644  // Copy AS operations must be performed outside of render pass.
645  EndRenderPass();
646  }
647  vkCmdCopyAccelerationStructureKHR(m_VkCmdBuffer, &Info);
648 #else
649  UNSUPPORTED("Ray tracing is not supported when vulkan library is linked statically");
650 #endif
651  }
652 
653  __forceinline void WriteAccelerationStructuresProperties(VkAccelerationStructureKHR accelerationStructure, VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery)
654  {
655 #if DILIGENT_USE_VOLK
656  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
657  if (m_State.RenderPass != VK_NULL_HANDLE)
658  {
659  // Write AS properties operations must be performed outside of render pass.
660  EndRenderPass();
661  }
662  vkCmdWriteAccelerationStructuresPropertiesKHR(m_VkCmdBuffer, 1, &accelerationStructure, queryType, queryPool, firstQuery);
663 #else
664  UNSUPPORTED("Ray tracing is not supported when vulkan library is linked statically");
665 #endif
666  }
667 
668  __forceinline void TraceRays(const VkStridedDeviceAddressRegionKHR& RaygenShaderBindingTable,
669  const VkStridedDeviceAddressRegionKHR& MissShaderBindingTable,
670  const VkStridedDeviceAddressRegionKHR& HitShaderBindingTable,
671  const VkStridedDeviceAddressRegionKHR& CallableShaderBindingTable,
672  uint32_t width,
673  uint32_t height,
674  uint32_t depth)
675  {
676 #if DILIGENT_USE_VOLK
677  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
678  VERIFY(m_State.RayTracingPipeline != VK_NULL_HANDLE, "No ray tracing pipeline bound");
679 
680  vkCmdTraceRaysKHR(m_VkCmdBuffer, &RaygenShaderBindingTable, &MissShaderBindingTable, &HitShaderBindingTable, &CallableShaderBindingTable, width, height, depth);
681 #else
682  UNSUPPORTED("Ray tracing is not supported when vulkan library is linked statically");
683 #endif
684  }
685 
686  __forceinline void TraceRaysIndirect(const VkStridedDeviceAddressRegionKHR& RaygenShaderBindingTable,
687  const VkStridedDeviceAddressRegionKHR& MissShaderBindingTable,
688  const VkStridedDeviceAddressRegionKHR& HitShaderBindingTable,
689  const VkStridedDeviceAddressRegionKHR& CallableShaderBindingTable,
690  VkDeviceAddress indirectDeviceAddress)
691  {
692 #if DILIGENT_USE_VOLK
693  VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
694  VERIFY(m_State.RayTracingPipeline != VK_NULL_HANDLE, "No ray tracing pipeline bound");
695 
696  vkCmdTraceRaysIndirectKHR(m_VkCmdBuffer, &RaygenShaderBindingTable, &MissShaderBindingTable, &HitShaderBindingTable, &CallableShaderBindingTable, indirectDeviceAddress);
697 #else
698  UNSUPPORTED("Ray tracing is not supported when vulkan library is linked statically");
699 #endif
700  }
701 
702  void FlushBarriers();
703 
704  __forceinline void SetVkCmdBuffer(VkCommandBuffer VkCmdBuffer)
705  {
706  m_VkCmdBuffer = VkCmdBuffer;
707  }
708  VkCommandBuffer GetVkCmdBuffer() const { return m_VkCmdBuffer; }
709 
710  VkPipelineStageFlags GetEnabledShaderStages() const { return m_EnabledShaderStages; }
711 
712  struct StateCache
713  {
714  VkRenderPass RenderPass = VK_NULL_HANDLE;
715  VkFramebuffer Framebuffer = VK_NULL_HANDLE;
716  VkPipeline GraphicsPipeline = VK_NULL_HANDLE;
717  VkPipeline ComputePipeline = VK_NULL_HANDLE;
718  VkPipeline RayTracingPipeline = VK_NULL_HANDLE;
719  VkBuffer IndexBuffer = VK_NULL_HANDLE;
720  VkDeviceSize IndexBufferOffset = 0;
721  VkIndexType IndexType = VK_INDEX_TYPE_MAX_ENUM;
722  uint32_t FramebufferWidth = 0;
723  uint32_t FramebufferHeight = 0;
724  uint32_t InsidePassQueries = 0;
725  uint32_t OutsidePassQueries = 0;
726  };
727 
728  const StateCache& GetState() const { return m_State; }
729 
730 private:
731  StateCache m_State;
732  VkCommandBuffer m_VkCmdBuffer = VK_NULL_HANDLE;
733  const VkPipelineStageFlags m_EnabledShaderStages;
734 };
735 
736 } // namespace VulkanUtilities
VulkanUtilities::VulkanCommandBuffer::StateCache::IndexBufferOffset
VkDeviceSize IndexBufferOffset
Definition: VulkanCommandBuffer.hpp:720
VulkanUtilities::VulkanCommandBuffer::CopyImageToBuffer
__forceinline void CopyImageToBuffer(VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy *pRegions)
Definition: VulkanCommandBuffer.hpp:487
VulkanHeaders.h
LOG_ERROR_MESSAGE
#define LOG_ERROR_MESSAGE(...)
Definition: Errors.hpp:122
VulkanUtilities::VulkanCommandBuffer::DispatchIndirect
__forceinline void DispatchIndirect(VkBuffer Buffer, VkDeviceSize Offset)
Definition: VulkanCommandBuffer.hpp:189
VulkanUtilities::VulkanCommandBuffer::EndRenderPass
__forceinline void EndRenderPass()
Definition: VulkanCommandBuffer.hpp:237
VulkanUtilities::VulkanCommandBuffer
Definition: VulkanCommandBuffer.hpp:36
VulkanUtilities::VulkanCommandBuffer::BeginRenderPass
__forceinline void BeginRenderPass(VkRenderPass RenderPass, VkFramebuffer Framebuffer, uint32_t FramebufferWidth, uint32_t FramebufferHeight, uint32_t ClearValueCount=0, const VkClearValue *pClearValues=nullptr)
Definition: VulkanCommandBuffer.hpp:198
VulkanUtilities::VulkanCommandBuffer::StateCache::Framebuffer
VkFramebuffer Framebuffer
Definition: VulkanCommandBuffer.hpp:715
VulkanUtilities::VulkanCommandBuffer::WriteTimestamp
__forceinline void WriteTimestamp(VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t query)
Definition: VulkanCommandBuffer.hpp:582
VulkanUtilities::VulkanCommandBuffer::TraceRaysIndirect
__forceinline void TraceRaysIndirect(const VkStridedDeviceAddressRegionKHR &RaygenShaderBindingTable, const VkStridedDeviceAddressRegionKHR &MissShaderBindingTable, const VkStridedDeviceAddressRegionKHR &HitShaderBindingTable, const VkStridedDeviceAddressRegionKHR &CallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress)
Definition: VulkanCommandBuffer.hpp:686
VulkanUtilities::VulkanCommandBuffer::BindGraphicsPipeline
__forceinline void BindGraphicsPipeline(VkPipeline GraphicsPipeline)
Definition: VulkanCommandBuffer.hpp:285
VulkanUtilities::VulkanCommandBuffer::DrawMesh
__forceinline void DrawMesh(uint32_t TaskCount, uint32_t FirstTask)
Definition: VulkanCommandBuffer.hpp:141
VulkanUtilities::VulkanCommandBuffer::SetScissorRects
__forceinline void SetScissorRects(uint32_t FirstScissor, uint32_t ScissorCount, const VkRect2D *pScissors)
Definition: VulkanCommandBuffer.hpp:313
VulkanUtilities::VulkanCommandBuffer::StateCache::IndexType
VkIndexType IndexType
Definition: VulkanCommandBuffer.hpp:721
VulkanUtilities::VulkanCommandBuffer::CopyBuffer
__forceinline void CopyBuffer(VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferCopy *pRegions)
Definition: VulkanCommandBuffer.hpp:440
VulkanUtilities::VulkanCommandBuffer::SetBlendConstants
__forceinline void SetBlendConstants(const float BlendConstants[4])
Definition: VulkanCommandBuffer.hpp:325
VulkanUtilities::VulkanCommandBuffer::Reset
__forceinline void Reset()
Definition: VulkanCommandBuffer.hpp:268
VulkanUtilities::VulkanCommandBuffer::StateCache::GraphicsPipeline
VkPipeline GraphicsPipeline
Definition: VulkanCommandBuffer.hpp:716
VulkanUtilities::VulkanCommandBuffer::ResolveImage
__forceinline void ResolveImage(VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageResolve *pRegions)
Definition: VulkanCommandBuffer.hpp:521
VulkanUtilities::VulkanCommandBuffer::TraceRays
__forceinline void TraceRays(const VkStridedDeviceAddressRegionKHR &RaygenShaderBindingTable, const VkStridedDeviceAddressRegionKHR &MissShaderBindingTable, const VkStridedDeviceAddressRegionKHR &HitShaderBindingTable, const VkStridedDeviceAddressRegionKHR &CallableShaderBindingTable, uint32_t width, uint32_t height, uint32_t depth)
Definition: VulkanCommandBuffer.hpp:668
DebugUtilities.hpp
VulkanUtilities::VulkanCommandBuffer::StateCache::RayTracingPipeline
VkPipeline RayTracingPipeline
Definition: VulkanCommandBuffer.hpp:718
UNSUPPORTED
#define UNSUPPORTED(...)
Definition: DebugUtilities.hpp:78
VulkanUtilities::VulkanCommandBuffer::BindDescriptorSets
__forceinline void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t descriptorSetCount, const VkDescriptorSet *pDescriptorSets, uint32_t dynamicOffsetCount=0, const uint32_t *pDynamicOffsets=nullptr)
Definition: VulkanCommandBuffer.hpp:428
VulkanUtilities::VulkanCommandBuffer::operator=
VulkanCommandBuffer & operator=(const VulkanCommandBuffer &)=delete
VulkanUtilities::VulkanCommandBuffer::CopyAccelerationStructure
__forceinline void CopyAccelerationStructure(const VkCopyAccelerationStructureInfoKHR &Info)
Definition: VulkanCommandBuffer.hpp:638
VulkanUtilities::VulkanCommandBuffer::ResetQueryPool
__forceinline void ResetQueryPool(VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount)
Definition: VulkanCommandBuffer.hpp:590
VulkanUtilities::VulkanCommandBuffer::FlushBarriers
void FlushBarriers()
Definition: VulkanCommandBuffer.cpp:437
VulkanUtilities::VulkanCommandBuffer::BlitImage
__forceinline void BlitImage(VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit *pRegions, VkFilter filter)
Definition: VulkanCommandBuffer.hpp:503
VulkanUtilities::VulkanCommandBuffer::ClearDepthStencilImage
__forceinline void ClearDepthStencilImage(VkImage Image, const VkClearDepthStencilValue &DepthStencil, const VkImageSubresourceRange &Subresource)
Definition: VulkanCommandBuffer.hpp:67
VulkanUtilities::VulkanCommandBuffer::ClearColorImage
__forceinline void ClearColorImage(VkImage Image, const VkClearColorValue &Color, const VkImageSubresourceRange &Subresource)
Definition: VulkanCommandBuffer.hpp:50
VulkanUtilities::VulkanCommandBuffer::WriteAccelerationStructuresProperties
__forceinline void WriteAccelerationStructuresProperties(VkAccelerationStructureKHR accelerationStructure, VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery)
Definition: VulkanCommandBuffer.hpp:653
VulkanUtilities::VulkanCommandBuffer::StateCache::InsidePassQueries
uint32_t InsidePassQueries
Definition: VulkanCommandBuffer.hpp:724
VulkanUtilities::VulkanHandleTypeId::Buffer
@ Buffer
VulkanUtilities::VulkanCommandBuffer::BindComputePipeline
__forceinline void BindComputePipeline(VkPipeline ComputePipeline)
Definition: VulkanCommandBuffer.hpp:274
VulkanUtilities::VulkanCommandBuffer::EndCommandBuffer
__forceinline void EndCommandBuffer()
Definition: VulkanCommandBuffer.hpp:262
VulkanUtilities::VulkanCommandBuffer::ASMemoryBarrier
static void ASMemoryBarrier(VkCommandBuffer CmdBuffer, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags EnabledShaderStages, VkPipelineStageFlags SrcStages=0, VkPipelineStageFlags DestStages=0)
Definition: VulkanCommandBuffer.cpp:388
VulkanUtilities::VulkanCommandBuffer::BufferMemoryBarrier
__forceinline void BufferMemoryBarrier(VkBuffer Buffer, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags SrcStages=0, VkPipelineStageFlags DestStages=0)
Definition: VulkanCommandBuffer.hpp:388
VulkanUtilities::VulkanCommandBuffer::DrawIndirect
__forceinline void DrawIndirect(VkBuffer Buffer, VkDeviceSize Offset, uint32_t DrawCount, uint32_t Stride)
Definition: VulkanCommandBuffer.hpp:122
VulkanUtilities::VulkanCommandBuffer::TransitionImageLayout
__forceinline void TransitionImageLayout(VkImage Image, VkImageLayout OldLayout, VkImageLayout NewLayout, const VkImageSubresourceRange &SubresRange, VkPipelineStageFlags SrcStages=0, VkPipelineStageFlags DestStages=0)
Definition: VulkanCommandBuffer.hpp:362
VulkanUtilities::VulkanCommandBuffer::VulkanCommandBuffer
VulkanCommandBuffer(VkPipelineStageFlags EnabledShaderStages) noexcept
Definition: VulkanCommandBuffer.hpp:39
VulkanUtilities::VulkanCommandBuffer::SetVkCmdBuffer
__forceinline void SetVkCmdBuffer(VkCommandBuffer VkCmdBuffer)
Definition: VulkanCommandBuffer.hpp:704
VulkanUtilities::VulkanCommandBuffer::StateCache::IndexBuffer
VkBuffer IndexBuffer
Definition: VulkanCommandBuffer.hpp:719
VulkanUtilities::VulkanCommandBuffer::StateCache::ComputePipeline
VkPipeline ComputePipeline
Definition: VulkanCommandBuffer.hpp:717
VulkanUtilities::VulkanCommandBuffer::DrawIndexed
__forceinline void DrawIndexed(uint32_t IndexCount, uint32_t InstanceCount, uint32_t FirstIndex, int32_t VertexOffset, uint32_t FirstInstance)
Definition: VulkanCommandBuffer.hpp:112
VulkanUtilities::VulkanCommandBuffer::SetStencilReference
__forceinline void SetStencilReference(uint32_t Reference)
Definition: VulkanCommandBuffer.hpp:319
VulkanUtilities::VulkanCommandBuffer::CopyQueryPoolResults
__forceinline void CopyQueryPoolResults(VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags)
Definition: VulkanCommandBuffer.hpp:603
VulkanUtilities::VulkanCommandBuffer::CopyBufferToImage
__forceinline void CopyBufferToImage(VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy *pRegions)
Definition: VulkanCommandBuffer.hpp:471
VulkanUtilities::VulkanCommandBuffer::GetState
const StateCache & GetState() const
Definition: VulkanCommandBuffer.hpp:728
VulkanUtilities::VulkanCommandBuffer::DrawMeshIndirectCount
__forceinline void DrawMeshIndirectCount(VkBuffer Buffer, VkDeviceSize Offset, VkBuffer CountBuffer, VkDeviceSize CountBufferOffset, uint32_t MaxDrawCount, uint32_t Stride)
Definition: VulkanCommandBuffer.hpp:167
VulkanUtilities::VulkanCommandBuffer::GetEnabledShaderStages
VkPipelineStageFlags GetEnabledShaderStages() const
Definition: VulkanCommandBuffer.hpp:710
VulkanUtilities::VulkanCommandBuffer::BufferMemoryBarrier
static void BufferMemoryBarrier(VkCommandBuffer CmdBuffer, VkBuffer Buffer, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags EnabledShaderStages, VkPipelineStageFlags SrcStages=0, VkPipelineStageFlags DestStages=0)
Definition: VulkanCommandBuffer.cpp:340
VulkanUtilities::VulkanCommandBuffer::Dispatch
__forceinline void Dispatch(uint32_t GroupCountX, uint32_t GroupCountY, uint32_t GroupCountZ)
Definition: VulkanCommandBuffer.hpp:180
VulkanUtilities::VulkanCommandBuffer::SetViewports
__forceinline void SetViewports(uint32_t FirstViewport, uint32_t ViewportCount, const VkViewport *pViewports)
Definition: VulkanCommandBuffer.hpp:307
VulkanUtilities::VulkanCommandBuffer::StateCache
Definition: VulkanCommandBuffer.hpp:712
VulkanUtilities::VulkanCommandBuffer::StateCache::FramebufferWidth
uint32_t FramebufferWidth
Definition: VulkanCommandBuffer.hpp:722
VulkanUtilities::VulkanCommandBuffer::DrawMeshIndirect
__forceinline void DrawMeshIndirect(VkBuffer Buffer, VkDeviceSize Offset, uint32_t DrawCount, uint32_t Stride)
Definition: VulkanCommandBuffer.hpp:154
VulkanUtilities::VulkanCommandBuffer::ClearAttachment
__forceinline void ClearAttachment(const VkClearAttachment &Attachment, const VkClearRect &ClearRect)
Definition: VulkanCommandBuffer.hpp:88
VulkanUtilities::VulkanCommandBuffer::NextSubpass
__forceinline void NextSubpass()
Definition: VulkanCommandBuffer.hpp:255
VulkanUtilities::VulkanCommandBuffer::BindRayTracingPipeline
__forceinline void BindRayTracingPipeline(VkPipeline RayTracingPipeline)
Definition: VulkanCommandBuffer.hpp:296
VulkanUtilities::VulkanCommandBuffer::ASMemoryBarrier
__forceinline void ASMemoryBarrier(VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags SrcStages=0, VkPipelineStageFlags DestStages=0)
Definition: VulkanCommandBuffer.hpp:413
VulkanUtilities::VulkanHandleTypeId::Framebuffer
@ Framebuffer
VERIFY_EXPR
#define VERIFY_EXPR(...)
Definition: DebugUtilities.hpp:79
VulkanUtilities::VulkanCommandBuffer::StateCache::RenderPass
VkRenderPass RenderPass
Definition: VulkanCommandBuffer.hpp:714
VulkanUtilities::VulkanCommandBuffer::StateCache::FramebufferHeight
uint32_t FramebufferHeight
Definition: VulkanCommandBuffer.hpp:723
VERIFY
#define VERIFY(...)
Definition: DebugUtilities.hpp:76
VulkanUtilities::VulkanCommandBuffer::BindIndexBuffer
__forceinline void BindIndexBuffer(VkBuffer Buffer, VkDeviceSize Offset, VkIndexType IndexType)
Definition: VulkanCommandBuffer.hpp:331
VulkanUtilities
Definition: VulkanCommandBuffer.hpp:33
VulkanUtilities::VulkanHandleTypeId::RenderPass
@ RenderPass
VulkanUtilities::VulkanHandleTypeId::Image
@ Image
VulkanUtilities::VulkanCommandBuffer::BeginQuery
__forceinline void BeginQuery(VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags, uint32_t queryFlag)
Definition: VulkanCommandBuffer.hpp:537
VulkanUtilities::VulkanCommandBuffer::GetVkCmdBuffer
VkCommandBuffer GetVkCmdBuffer() const
Definition: VulkanCommandBuffer.hpp:708
VulkanUtilities::VulkanCommandBuffer::StateCache::OutsidePassQueries
uint32_t OutsidePassQueries
Definition: VulkanCommandBuffer.hpp:725
VulkanUtilities::VulkanCommandBuffer::BindVertexBuffers
__forceinline void BindVertexBuffers(uint32_t firstBinding, uint32_t bindingCount, const VkBuffer *pBuffers, const VkDeviceSize *pOffsets)
Definition: VulkanCommandBuffer.hpp:347
VulkanUtilities::VulkanCommandBuffer::Draw
__forceinline void Draw(uint32_t VertexCount, uint32_t InstanceCount, uint32_t FirstVertex, uint32_t FirstInstance)
Definition: VulkanCommandBuffer.hpp:103
VulkanUtilities::VulkanCommandBuffer::CopyImage
__forceinline void CopyImage(VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy *pRegions)
Definition: VulkanCommandBuffer.hpp:454
VulkanUtilities::VulkanCommandBuffer::DrawIndexedIndirect
__forceinline void DrawIndexedIndirect(VkBuffer Buffer, VkDeviceSize Offset, uint32_t DrawCount, uint32_t Stride)
Definition: VulkanCommandBuffer.hpp:131
VulkanUtilities::VulkanCommandBuffer::TransitionImageLayout
static void TransitionImageLayout(VkCommandBuffer CmdBuffer, VkImage Image, VkImageLayout OldLayout, VkImageLayout NewLayout, const VkImageSubresourceRange &SubresRange, VkPipelineStageFlags EnabledShaderStages, VkPipelineStageFlags SrcStages=0, VkPipelineStageFlags DestStages=0)
Definition: VulkanCommandBuffer.cpp:252
VulkanUtilities::VulkanCommandBuffer::BuildAccelerationStructure
__forceinline void BuildAccelerationStructure(uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos)
Definition: VulkanCommandBuffer.hpp:621
VulkanUtilities::VulkanCommandBuffer::EndQuery
__forceinline void EndQuery(VkQueryPool queryPool, uint32_t query, uint32_t queryFlag)
Definition: VulkanCommandBuffer.hpp:564