TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
vk_types.h
Go to the documentation of this file.
1// Core GPU resource types of the Vulkan backend: Vulkan handles (images, buffers)
2// with their VMA allocations and metadata.
3
4#pragma once
5
8
9#include <vulkan/vulkan.h>
10#define VMA_DEBUG_LOG_FORMAT
11#include <vk_mem_alloc.h>
12
13#include <cstdio>
14
15namespace tachyon::vulkan
16{
19
21 {
22 VkImage image;
23 VkImageView imageView;
24 VmaAllocation allocation;
25 VkExtent3D imageExtent;
26 VkFormat imageFormat;
27 };
28
30 {
31 VkBuffer buffer;
32 VmaAllocation allocation;
33 VmaAllocationInfo info;
34 };
35
38 void OnVulkanError(VkResult result, const char* call);
40 void SetDeviceLost(bool lost);
41
42 #define TACHYON_VK_CHECK(x) \
43 do \
44 { \
45 const VkResult tachyon_vk_result = (x); \
46 if (tachyon_vk_result != VK_SUCCESS) \
47 ::tachyon::vulkan::OnVulkanError(tachyon_vk_result, #x); \
48 } while (0)
49
53 inline void WaitForFence(VkDevice device, VkFence fence)
54 {
55 VkResult result;
56 do
57 {
58 result = vkWaitForFences(device, 1, &fence, VK_TRUE, 1000000000);
59 } while (result == VK_TIMEOUT);
60 TACHYON_VK_CHECK(result);
61 }
62
63}
#define TACHYON_VK_CHECK(x)
Definition vk_types.h:42
void OnVulkanError(VkResult result, const char *call)
Logs a failed Vulkan call; the frame carries on.
void SetDeviceLost(bool lost)
void WaitForFence(VkDevice device, VkFence fence)
Waits for fence however long the GPU takes: VK_TIMEOUT only means the GPU is slow (a busy or stalled ...
Definition vk_types.h:53
Definition vk_defaults.h:4
Definition vk_types.h:30
VmaAllocation allocation
Definition vk_types.h:32
VkBuffer buffer
Definition vk_types.h:31
VmaAllocationInfo info
Definition vk_types.h:33
Definition vk_types.h:21
VkImage image
Definition vk_types.h:22
VkImageView imageView
Definition vk_types.h:23
VkFormat imageFormat
Definition vk_types.h:26
VmaAllocation allocation
Definition vk_types.h:24
VkExtent3D imageExtent
Definition vk_types.h:25