Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
Utilities.h
Go to the documentation of this file.
1/* Copyright (C) 2023 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef INCLUDED_RENDERER_BACKEND_VULKAN_UTILITIES
19#define INCLUDED_RENDERER_BACKEND_VULKAN_UTILITIES
20
21#include "ps/CStr.h"
22
23#include <glad/vulkan.h>
24
25#define ENSURE_VK_SUCCESS(EXPR) \
26 do \
27 { \
28 const VkResult result = (EXPR); \
29 if (result != VK_SUCCESS) \
30 { \
31 LOGERROR(#EXPR " returned %d (%s) instead of VK_SUCCESS", static_cast<int>(result), Utilities::GetVkResultName(result)); \
32 ENSURE(false && #EXPR); \
33 } \
34 } while (0)
35
36namespace Renderer
37{
38
39namespace Backend
40{
41
42namespace Vulkan
43{
44
45class CBuffer;
46class CTexture;
47
48namespace Utilities
49{
50
51// https://github.com/KhronosGroup/Vulkan-Docs/wiki/Synchronization-Examples-(Legacy-synchronization-APIs)
52
54 VkCommandBuffer commandBuffer, CTexture* texture,
55 const VkImageLayout oldLayout, const VkImageLayout newLayout,
56 const VkAccessFlags srcAccessMask, const VkAccessFlags dstAccessMask,
57 const VkPipelineStageFlags srcStageMask, const VkPipelineStageFlags dstStageMask);
58
60 VkCommandBuffer commandBuffer, VkImage image, const uint32_t level, const uint32_t layer,
61 const VkAccessFlags srcAccessMask, const VkAccessFlags dstAccessMask,
62 const VkImageLayout oldLayout, const VkImageLayout newLayout,
63 const VkPipelineStageFlags srcStageMask, const VkPipelineStageFlags dstStageMask,
64 const VkImageAspectFlags aspectMask = VK_IMAGE_ASPECT_COLOR_BIT);
65
67 VkCommandBuffer commandBuffer, CBuffer* buffer,
68 const VkDeviceSize offset, const VkDeviceSize size,
69 const VkAccessFlags srcAccessMask, const VkAccessFlags dstAccessMask,
70 const VkPipelineStageFlags srcStageMask, const VkPipelineStageFlags dstStageMask);
71
73 VkCommandBuffer commandBuffer,
74 const VkAccessFlags srcAccessMask, const VkAccessFlags dstAccessMask,
75 const VkPipelineStageFlags srcStageMask, const VkPipelineStageFlags dstStageMask);
76
78 VkCommandBuffer commandBuffer,
79 const VkPipelineStageFlags srcStageMask, const VkPipelineStageFlags dstStageMask);
80
81void SubmitDebugSyncMemoryBarrier(VkCommandBuffer commandBuffer);
82
83const char* GetVkResultName(const VkResult result);
84
85} // namespace Utilities
86
87} // namespace Vulkan
88
89} // namespace Backend
90
91} // namespace Renderer
92
93#endif // INCLUDED_RENDERER_BACKEND_VULKAN_UTILITIES
Represents a texture object.
Definition: TextureManager.h:262
void SubmitImageMemoryBarrier(VkCommandBuffer commandBuffer, VkImage image, const uint32_t level, const uint32_t layer, const VkAccessFlags srcAccessMask, const VkAccessFlags dstAccessMask, const VkImageLayout oldLayout, const VkImageLayout newLayout, const VkPipelineStageFlags srcStageMask, const VkPipelineStageFlags dstStageMask, const VkImageAspectFlags aspectMask)
Definition: Utilities.cpp:70
void SubmitDebugSyncMemoryBarrier(VkCommandBuffer commandBuffer)
Definition: Utilities.cpp:141
void SubmitMemoryBarrier(VkCommandBuffer commandBuffer, const VkAccessFlags srcAccessMask, const VkAccessFlags dstAccessMask, const VkPipelineStageFlags srcStageMask, const VkPipelineStageFlags dstStageMask)
Definition: Utilities.cpp:118
void SubmitBufferMemoryBarrier(VkCommandBuffer commandBuffer, CBuffer *buffer, const VkDeviceSize offset, const VkDeviceSize size, const VkAccessFlags srcAccessMask, const VkAccessFlags dstAccessMask, const VkPipelineStageFlags srcStageMask, const VkPipelineStageFlags dstStageMask)
Definition: Utilities.cpp:97
void SubmitPipelineBarrier(VkCommandBuffer commandBuffer, const VkPipelineStageFlags srcStageMask, const VkPipelineStageFlags dstStageMask)
Definition: Utilities.cpp:132
void SetTextureLayout(VkCommandBuffer commandBuffer, CTexture *texture, const VkImageLayout oldLayout, const VkImageLayout newLayout, const VkAccessFlags srcAccessMask, const VkAccessFlags dstAccessMask, const VkPipelineStageFlags srcStageMask, const VkPipelineStageFlags dstStageMask)
Definition: Utilities.cpp:39
const char * GetVkResultName(const VkResult result)
Definition: Utilities.cpp:164
Backend
Definition: Backend.h:28
Definition: VideoMode.h:29
unsigned int uint32_t
Definition: wposix_types.h:53