Etterna 0.75.1
Loading...
Searching...
No Matches
VkUtils.h
1#ifndef VK_UTILS_H
2#define VK_UTILS_H
3
4#include <vulkan/vulkan_raii.hpp>
5#include <VkBootstrap.h>
6#include <deque>
7#include <functional>
8#include <source_location>
9#include <span>
10#include <optional>
11#include <RageUtil/Misc/RageTypes.h>
12
13void
14ThrowIfFail(
15 VkResult result,
16 const std::source_location location = std::source_location::current());
17
18void
19ThrowIfFail(
20 vk::Result result,
21 const std::source_location location = std::source_location::current());
22
23void
24Fail(const std::source_location location = std::source_location::current());
25
26vk::raii::ShaderModule
27LoadShaderFromFile(std::string path,
28 vk::raii::Device& device,
29 ShaderType shaderType);
30
31std::optional<uint32_t>
32GetMemoryType(uint32_t typeBits,
33 vk::MemoryPropertyFlags neededProps,
34 vk::PhysicalDeviceMemoryProperties memoryProps);
35
36template <typename T>
37std::string
38GetDetailedErrorString(vkb::Result<T>& result)
39{
40 std::string reason;
41 auto& reasons = result.detailed_failure_reasons();
42
43 for (int i = 0; i < reasons.size(); i++) {
44 reason += reasons[i];
45 if (i != reasons.size() - 1) {
46 reason += " ; ";
47 }
48 }
49
50 if (reasons.empty()) {
51 reason = "No reason given";
52 }
53
54 return reason;
55}
56
57#endif