diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 1e38c6260..d4e2ba25d 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -7,16 +7,15 @@ #include VKAPI_ATTR VkBool32 VKAPI_CALL MyDebugReportCallback( - VkDebugReportFlagsEXT flags, - VkDebugReportObjectTypeEXT objectType, - uint64_t object, - size_t location, - int32_t messageCode, - const char* pLayerPrefix, - const char* pMessage, - void* pUserData) + VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, + VkDebugUtilsMessageTypeFlagsEXT messageTypes, + const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, + void* pUserData) { - std::cerr << pMessage << std::endl; + if (pCallbackData->messageIdNumber != 0) + std::cerr << "#" << pCallbackData->messageIdNumber << " " << pCallbackData->messageIdNumber << ": "; + + std::cerr << pCallbackData->pMessage << std::endl; return VK_FALSE; } @@ -44,15 +43,15 @@ int main() Nz::Vk::Instance& instance = Nz::Vulkan::GetInstance(); - VkDebugReportCallbackCreateInfoEXT callbackCreateInfo = {}; - callbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; - callbackCreateInfo.flags = VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | VK_DEBUG_REPORT_DEBUG_BIT_EXT ; - callbackCreateInfo.pfnCallback = &MyDebugReportCallback; + VkDebugUtilsMessengerCreateInfoEXT callbackCreateInfo = { VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT }; + callbackCreateInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT; + callbackCreateInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT; + callbackCreateInfo.pfnUserCallback = &MyDebugReportCallback; /* Register the callback */ - VkDebugReportCallbackEXT callback; + VkDebugUtilsMessengerEXT callback; - instance.vkCreateDebugReportCallbackEXT(instance, &callbackCreateInfo, nullptr, &callback); + instance.vkCreateDebugUtilsMessengerEXT(instance, &callbackCreateInfo, nullptr, &callback); std::vector layerProperties; @@ -216,9 +215,6 @@ int main() std::unique_ptr pipeline = device->InstantiateRenderPipeline(pipelineInfo); - Nz::VulkanRenderPipeline::CreateInfo pipelineCreateInfo = Nz::VulkanRenderPipeline::BuildCreateInfo(pipelineInfo); - pipelineCreateInfo.pipelineInfo.renderPass = vulkanWindow.GetRenderPass(); - std::array clearValues; clearValues[0].color = {0.0f, 0.0f, 0.0f, 0.0f}; clearValues[1].depthStencil = {1.f, 0}; @@ -276,7 +272,7 @@ int main() }; renderCmd.Begin(); - + renderCmd.BeginDebugRegion("Main window rendering", Nz::Color::Green); renderCmd.BeginRenderPass(render_pass_begin_info); renderCmd.BindIndexBuffer(indexBufferImpl->GetBuffer(), 0, VK_INDEX_TYPE_UINT16); renderCmd.BindVertexBuffer(0, vertexBufferImpl->GetBuffer(), 0); @@ -286,6 +282,7 @@ int main() renderCmd.SetViewport({0.f, 0.f, float(windowSize.x), float(windowSize.y)}, 0.f, 1.f); renderCmd.DrawIndexed(drfreakIB->GetIndexCount()); renderCmd.EndRenderPass(); + renderCmd.EndDebugRegion(); if (!renderCmd.End()) { @@ -314,6 +311,7 @@ int main() Nz::Vk::CommandPool transientPool; transientPool.Create(vulkanDevice, 0, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT); + transientPool.SetDebugName("Transient command pool"); std::vector frameSync(MaxConcurrentImage); for (ImageData& syncData : frameSync) @@ -424,9 +422,11 @@ int main() std::memcpy(allocData->mappedPtr, &ubo, sizeof(ubo)); frame.commandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT); + frame.commandBuffer->BeginDebugRegion("UBO Update", Nz::Color::Yellow); frame.commandBuffer->MemoryBarrier(VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0U, VK_ACCESS_TRANSFER_READ_BIT); frame.commandBuffer->CopyBuffer(allocData->buffer, static_cast(uniformBuffer.get())->GetBuffer(), allocData->size, allocData->offset); frame.commandBuffer->MemoryBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_UNIFORM_READ_BIT); + frame.commandBuffer->EndDebugRegion(); frame.commandBuffer->End(); if (!graphicsQueue.Submit(frame.commandBuffer)) @@ -462,7 +462,7 @@ int main() currentFrame = (currentFrame + 1) % imageCount; } - instance.vkDestroyDebugReportCallbackEXT(instance, callback, nullptr); + instance.vkDestroyDebugUtilsMessengerEXT(instance, callback, nullptr); return EXIT_SUCCESS; } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp index 4dba01ec1..8e868df14 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class Buffer : public DeviceObject + class Buffer : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp index bac7e5f61..47982a0be 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp @@ -8,6 +8,7 @@ #define NAZARA_VULKANRENDERER_VKCOMMANDBUFFER_HPP #include +#include #include #include #include @@ -33,6 +34,8 @@ namespace Nz inline bool Begin(VkCommandBufferUsageFlags flags, VkRenderPass renderPass, UInt32 subpass, VkFramebuffer framebuffer, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics); inline bool Begin(VkCommandBufferUsageFlags flags, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics); + inline void BeginDebugRegion(const char* label); + inline void BeginDebugRegion(const char* label, Nz::Color color); inline void BeginRenderPass(const VkRenderPassBeginInfo& beginInfo, VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE); inline void BindDescriptorSet(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, const VkDescriptorSet& descriptorSets); @@ -60,10 +63,14 @@ namespace Nz inline bool End(); + inline void EndDebugRegion(); inline void EndRenderPass(); inline void Free(); + inline void InsertDebugLabel(const char* label); + inline void InsertDebugLabel(const char* label, Nz::Color color); + inline void MemoryBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask); inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkImageMemoryBarrier& imageMemoryBarrier); diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl index 9b2558a63..a34dde3f5 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl @@ -118,6 +118,34 @@ namespace Nz return Begin(beginInfo); } + inline void CommandBuffer::BeginDebugRegion(const char* label) + { + Vk::Device* device = m_pool->GetDevice(); + if (device->vkCmdBeginDebugUtilsLabelEXT) + { + VkDebugUtilsLabelEXT debugLabel = { VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT }; + debugLabel.pLabelName = label; + + device->vkCmdBeginDebugUtilsLabelEXT(m_handle, &debugLabel); + } + } + + inline void CommandBuffer::BeginDebugRegion(const char* label, Nz::Color color) + { + Vk::Device* device = m_pool->GetDevice(); + if (device->vkCmdBeginDebugUtilsLabelEXT) + { + VkDebugUtilsLabelEXT debugLabel = { VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT }; + debugLabel.pLabelName = label; + debugLabel.color[0] = color.r / 255.f; + debugLabel.color[1] = color.g / 255.f; + debugLabel.color[2] = color.b / 255.f; + debugLabel.color[3] = color.a / 255.f; + + device->vkCmdBeginDebugUtilsLabelEXT(m_handle, &debugLabel); + } + } + inline void CommandBuffer::BeginRenderPass(const VkRenderPassBeginInfo& beginInfo, VkSubpassContents contents) { return m_pool->GetDevice()->vkCmdBeginRenderPass(m_handle, &beginInfo, contents); @@ -243,6 +271,13 @@ namespace Nz return true; } + inline void CommandBuffer::EndDebugRegion() + { + Vk::Device* device = m_pool->GetDevice(); + if (device->vkCmdEndDebugUtilsLabelEXT) + device->vkCmdEndDebugUtilsLabelEXT(m_handle); + } + inline void CommandBuffer::EndRenderPass() { return m_pool->GetDevice()->vkCmdEndRenderPass(m_handle); @@ -257,6 +292,34 @@ namespace Nz } } + inline void CommandBuffer::InsertDebugLabel(const char* label) + { + Vk::Device* device = m_pool->GetDevice(); + if (device->vkCmdInsertDebugUtilsLabelEXT) + { + VkDebugUtilsLabelEXT debugLabel = { VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT }; + debugLabel.pLabelName = label; + + device->vkCmdInsertDebugUtilsLabelEXT(m_handle, &debugLabel); + } + } + + inline void CommandBuffer::InsertDebugLabel(const char* label, Nz::Color color) + { + Vk::Device* device = m_pool->GetDevice(); + if (device->vkCmdInsertDebugUtilsLabelEXT) + { + VkDebugUtilsLabelEXT debugLabel = { VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT }; + debugLabel.pLabelName = label; + debugLabel.color[0] = color.r / 255.f; + debugLabel.color[1] = color.g / 255.f; + debugLabel.color[2] = color.b / 255.f; + debugLabel.color[3] = color.a / 255.f; + + device->vkCmdInsertDebugUtilsLabelEXT(m_handle, &debugLabel); + } + } + inline void CommandBuffer::MemoryBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask) { VkMemoryBarrier memoryBarrier = { diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp index 807f26f19..fbe253bd1 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp @@ -16,7 +16,7 @@ namespace Nz { class CommandBuffer; - class NAZARA_VULKANRENDERER_API CommandPool : public DeviceObject + class NAZARA_VULKANRENDERER_API CommandPool : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp index 890b882d2..ee68a6e32 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp @@ -16,7 +16,7 @@ namespace Nz { class DescriptorSet; - class NAZARA_VULKANRENDERER_API DescriptorPool : public DeviceObject + class NAZARA_VULKANRENDERER_API DescriptorPool : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp index 81ef4849e..c49fadcf2 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class DescriptorSetLayout : public DeviceObject + class DescriptorSetLayout : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp index e1c5e48de..86c42ad5f 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp @@ -22,7 +22,7 @@ namespace Nz { namespace Vk { - class CommandBuffer; + class AutoCommandBuffer; class Instance; class QueueHandle; @@ -38,7 +38,7 @@ namespace Nz Device(Device&&) = delete; ~Device(); - CommandBuffer AllocateTransferCommandBuffer(); + AutoCommandBuffer AllocateTransferCommandBuffer(); bool Create(const Vk::PhysicalDevice& deviceInfo, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline void Destroy(); @@ -71,6 +71,8 @@ namespace Nz #define NAZARA_VULKANRENDERER_DEVICE_CORE_EXT_FUNCTION(func, ...) NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) #define NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN(ext) #define NAZARA_VULKANRENDERER_DEVICE_EXT_END() +#define NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(ext) +#define NAZARA_VULKANRENDERER_INSTANCE_EXT_END() #include @@ -78,6 +80,8 @@ namespace Nz #undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION #undef NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN #undef NAZARA_VULKANRENDERER_DEVICE_EXT_END +#undef NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN +#undef NAZARA_VULKANRENDERER_INSTANCE_EXT_END struct QueueInfo { diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceFunctions.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceFunctions.hpp index 6c76c4e7e..8c68aa569 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceFunctions.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceFunctions.hpp @@ -144,3 +144,14 @@ NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN(VK_KHR_swapchain) NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetSwapchainImagesKHR) NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkQueuePresentKHR) NAZARA_VULKANRENDERER_DEVICE_EXT_END() + +NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_EXT_debug_utils) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBeginDebugUtilsLabelEXT) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdEndDebugUtilsLabelEXT) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdInsertDebugUtilsLabelEXT) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkQueueBeginDebugUtilsLabelEXT) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkQueueEndDebugUtilsLabelEXT) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkQueueInsertDebugUtilsLabelEXT) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkSetDebugUtilsObjectNameEXT) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkSetDebugUtilsObjectTagEXT) +NAZARA_VULKANRENDERER_INSTANCE_EXT_END() diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp index e750779b4..490a95095 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp @@ -15,7 +15,7 @@ namespace Nz { namespace Vk { - class DeviceMemory : public DeviceObject + class DeviceMemory : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp index 4ce478418..e16b73c16 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp @@ -11,12 +11,13 @@ #include #include #include +#include namespace Nz { namespace Vk { - template + template class DeviceObject { public: @@ -33,6 +34,9 @@ namespace Nz Device* GetDevice() const; VkResult GetLastErrorCode() const; + void SetDebugName(const char* name); + void SetDebugName(const std::string& name); + DeviceObject& operator=(const DeviceObject&) = delete; DeviceObject& operator=(DeviceObject&&) = delete; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl index fcc5245d1..e6728d016 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl @@ -13,14 +13,14 @@ namespace Nz { namespace Vk { - template - DeviceObject::DeviceObject() : + template + DeviceObject::DeviceObject() : m_handle(VK_NULL_HANDLE) { } - template - DeviceObject::DeviceObject(DeviceObject&& object) noexcept : + template + DeviceObject::DeviceObject(DeviceObject&& object) noexcept : m_device(std::move(object.m_device)), m_allocator(object.m_allocator), m_handle(object.m_handle), @@ -29,14 +29,14 @@ namespace Nz object.m_handle = VK_NULL_HANDLE; } - template - DeviceObject::~DeviceObject() + template + DeviceObject::~DeviceObject() { Destroy(); } - template - bool DeviceObject::Create(Device& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) + template + bool DeviceObject::Create(Device& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) { m_device = &device; m_lastErrorCode = C::CreateHelper(*m_device, &createInfo, allocator, &m_handle); @@ -55,8 +55,8 @@ namespace Nz return true; } - template - void DeviceObject::Destroy() + template + void DeviceObject::Destroy() { if (IsValid()) { @@ -65,26 +65,46 @@ namespace Nz } } - template - bool DeviceObject::IsValid() const + template + bool DeviceObject::IsValid() const { return m_handle != VK_NULL_HANDLE; } - template - Device* DeviceObject::GetDevice() const + template + Device* DeviceObject::GetDevice() const { return m_device; } - template - VkResult DeviceObject::GetLastErrorCode() const + template + VkResult DeviceObject::GetLastErrorCode() const { return m_lastErrorCode; } - template - DeviceObject::operator VkType() const + template + void DeviceObject::SetDebugName(const char* name) + { + if (m_device->vkSetDebugUtilsObjectNameEXT) + { + VkDebugUtilsObjectNameInfoEXT debugName = { VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT }; + debugName.objectType = ObjectType; + debugName.objectHandle = static_cast(reinterpret_cast(m_handle)); + debugName.pObjectName = name; + + m_device->vkSetDebugUtilsObjectNameEXT(*m_device, &debugName); + } + } + + template + void DeviceObject::SetDebugName(const std::string& name) + { + return SetDebugName(name.data()); + } + + template + DeviceObject::operator VkType() const { return m_handle; } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Fence.hpp b/include/Nazara/VulkanRenderer/Wrapper/Fence.hpp index 054083a3a..b4b5939df 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Fence.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Fence.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class Fence : public DeviceObject + class Fence : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp index 014d1e205..8dd3446a0 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class Framebuffer : public DeviceObject + class Framebuffer : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Image.hpp b/include/Nazara/VulkanRenderer/Wrapper/Image.hpp index 3c6cdc0e1..14ff705d0 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Image.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Image.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class Image : public DeviceObject + class Image : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp b/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp index 957453774..78c99d9b4 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class ImageView : public DeviceObject + class ImageView : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp b/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp index 25e9235c0..ec258bbc3 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp @@ -41,10 +41,12 @@ NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_KHR_surface) NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceSupportKHR) NAZARA_VULKANRENDERER_INSTANCE_EXT_END() -NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_EXT_debug_report) - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateDebugReportCallbackEXT) - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkDestroyDebugReportCallbackEXT) - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkDebugReportMessageEXT) +NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_EXT_debug_utils) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateDebugUtilsMessengerEXT) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkDestroyDebugUtilsMessengerEXT) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkSetDebugUtilsObjectNameEXT) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkSetDebugUtilsObjectTagEXT) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkSubmitDebugUtilsMessageEXT) NAZARA_VULKANRENDERER_INSTANCE_EXT_END() #ifdef VK_USE_PLATFORM_ANDROID_KHR diff --git a/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp b/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp index 8c923c311..eb697b9ed 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class PipelineCache : public DeviceObject + class PipelineCache : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp index ad97ca925..9db58733d 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class PipelineLayout : public DeviceObject + class PipelineLayout : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp index de95bfcca..c8b93093a 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class RenderPass : public DeviceObject + class RenderPass : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Sampler.hpp b/include/Nazara/VulkanRenderer/Wrapper/Sampler.hpp index 8cbde84d1..1fa92b55a 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Sampler.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Sampler.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class Sampler : public DeviceObject + class Sampler : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp index b42cd8c27..62084b9b6 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class Semaphore : public DeviceObject + class Semaphore : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp index caacaccea..d3724d464 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class ShaderModule : public DeviceObject + class ShaderModule : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp index d8d611585..399ca909f 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp @@ -15,7 +15,7 @@ namespace Nz { namespace Vk { - class Swapchain : public DeviceObject + class Swapchain : public DeviceObject { friend DeviceObject; diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index c60650158..ff9095478 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -166,6 +166,9 @@ namespace Nz if (availableExtensions.count(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) enabledExtensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); + + if (availableExtensions.count(VK_EXT_DEBUG_UTILS_EXTENSION_NAME)) + enabledExtensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); } std::vector additionalExtensions; // Just to keep the String alive diff --git a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp index 6d0248bef..49d22d586 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp @@ -40,7 +40,7 @@ namespace Nz WaitAndDestroyDevice(); } - CommandBuffer Device::AllocateTransferCommandBuffer() + AutoCommandBuffer Device::AllocateTransferCommandBuffer() { return m_internalData->transferCommandPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY); } @@ -82,6 +82,9 @@ namespace Nz #define NAZARA_VULKANRENDERER_DEVICE_EXT_END() } #define NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) func = reinterpret_cast(GetProcAddr(#func)); +#define NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(ext) if (m_instance.IsExtensionLoaded(#ext)) { +#define NAZARA_VULKANRENDERER_INSTANCE_EXT_END() } + #define NAZARA_VULKANRENDERER_DEVICE_CORE_EXT_FUNCTION(func, coreVersion, suffix, extName) \ if (deviceVersion >= coreVersion) \ func = reinterpret_cast(GetProcAddr(#func)); \ @@ -94,6 +97,8 @@ namespace Nz #undef NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN #undef NAZARA_VULKANRENDERER_DEVICE_EXT_END #undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION +#undef NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN +#undef NAZARA_VULKANRENDERER_INSTANCE_EXT_END } catch (const std::exception& e) { @@ -239,6 +244,8 @@ namespace Nz #define NAZARA_VULKANRENDERER_DEVICE_CORE_EXT_FUNCTION(func, ...) NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) #define NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN(ext) #define NAZARA_VULKANRENDERER_DEVICE_EXT_END() +#define NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(ext) +#define NAZARA_VULKANRENDERER_INSTANCE_EXT_END() #include @@ -246,6 +253,8 @@ namespace Nz #undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION #undef NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN #undef NAZARA_VULKANRENDERER_DEVICE_EXT_END +#undef NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN +#undef NAZARA_VULKANRENDERER_INSTANCE_EXT_END } void Device::WaitAndDestroyDevice()