mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-19 20:19:13 +12:00
Add initial vulkan instance creation
Headlessly creates a new vulkan instance, with conditional MacOS support, and enables the `VK_EXT_debug_utils` instance-extension with a debug-messenger to hook onto validation layer messages.
This commit is contained in:
parent
d2241a25bc
commit
870b6a21bf
6 changed files with 336 additions and 5 deletions
48
include/renderer_vk/vk_debug.hpp
Normal file
48
include/renderer_vk/vk_debug.hpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
#pragma once
|
||||
|
||||
#include <span>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "vulkan_api.hpp"
|
||||
|
||||
namespace Vulkan {
|
||||
|
||||
VKAPI_ATTR VkBool32 VKAPI_CALL debugMessageCallback(
|
||||
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType,
|
||||
const VkDebugUtilsMessengerCallbackDataEXT* callbackData, void* userData
|
||||
);
|
||||
|
||||
void setObjectName(vk::Device device, vk::ObjectType objectType, const void* objectHandle, const char* format, ...);
|
||||
|
||||
template <typename T, typename = std::enable_if_t<vk::isVulkanHandleType<T>::value == true>, typename... ArgsT>
|
||||
inline void setObjectName(vk::Device device, const T objectHandle, const char* format, ArgsT&&... args) {
|
||||
setObjectName(device, T::objectType, objectHandle, format, std::forward<ArgsT>(args)...);
|
||||
}
|
||||
|
||||
void beginDebugLabel(vk::CommandBuffer commandBuffer, std::span<const float, 4> color, const char* format, ...);
|
||||
|
||||
void insertDebugLabel(vk::CommandBuffer commandBuffer, std::span<const float, 4> color, const char* format, ...);
|
||||
|
||||
void endDebugLabel(vk::CommandBuffer commandBuffer);
|
||||
|
||||
class DebugLabelScope {
|
||||
private:
|
||||
const vk::CommandBuffer commandBuffer;
|
||||
|
||||
public:
|
||||
template <typename... ArgsT>
|
||||
DebugLabelScope(vk::CommandBuffer targetCommandBuffer, std::span<const float, 4> color, const char* format, ArgsT&&... args)
|
||||
: commandBuffer(targetCommandBuffer) {
|
||||
beginDebugLabel(commandBuffer, color, format, std::forward<ArgsT>(args)...);
|
||||
}
|
||||
|
||||
template <typename... ArgsT>
|
||||
void operator()(std::span<const float, 4> color, const char* format, ArgsT&&... args) const {
|
||||
insertDebugLabel(commandBuffer, color, format, std::forward<ArgsT>(args)...);
|
||||
}
|
||||
|
||||
~DebugLabelScope() { endDebugLabel(commandBuffer); }
|
||||
};
|
||||
|
||||
} // namespace Vulkan
|
Loading…
Add table
Add a link
Reference in a new issue