From 53048bd82ae50b366225dadb3ac352951c559441 Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Wed, 3 Jan 2024 15:15:38 +0100 Subject: [PATCH] improving vulkan error messages --- example/main.c | 2 +- includes/mlx_profile.h | 68 ++++++++++++++++++- src/renderer/command/vk_cmd_buffer.cpp | 17 +++-- src/renderer/command/vk_cmd_pool.cpp | 7 +- src/renderer/core/memory.cpp | 24 ++++--- src/renderer/core/render_core.cpp | 21 +++--- src/renderer/core/vk_validation_layers.cpp | 7 +- .../descriptors/vk_descriptor_pool.cpp | 7 +- .../descriptors/vk_descriptor_set.cpp | 8 ++- .../descriptors/vk_descriptor_set_layout.cpp | 7 +- src/renderer/images/vk_image.cpp | 12 ++-- src/renderer/pipeline/pipeline.cpp | 7 +- src/renderer/renderpass/vk_framebuffer.cpp | 7 +- src/renderer/renderpass/vk_render_pass.cpp | 7 +- src/renderer/swapchain/vk_swapchain.cpp | 7 +- 15 files changed, 149 insertions(+), 59 deletions(-) diff --git a/example/main.c b/example/main.c index 682d4de..3f55325 100644 --- a/example/main.c +++ b/example/main.c @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/04 17:55:21 by maldavid #+# #+# */ -/* Updated: 2023/12/31 01:13:40 by maldavid ### ########.fr */ +/* Updated: 2024/01/03 12:29:31 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/includes/mlx_profile.h b/includes/mlx_profile.h index 5a06edb..ddd9dec 100644 --- a/includes/mlx_profile.h +++ b/includes/mlx_profile.h @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/10 08:49:17 by maldavid #+# #+# */ -/* Updated: 2023/12/16 20:20:35 by maldavid ### ########.fr */ +/* Updated: 2024/01/03 14:39:23 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -93,6 +93,32 @@ #define MLX_FUNC_SIG "Unknown function" #endif +#ifndef __cplusplus // if we compile in C + #ifdef __STDC__ + #ifdef __STDC_VERSION__ + #if __STDC_VERSION__ == 199409L + #define MLX_C_VERSION 1994 + #elif __STDC_VERSION__ == 199901L + #define MLX_C_VERSION 1999 + #elif __STDC_VERSION__ == 201112L + #define MLX_C_VERSION 2011 + #elif __STDC_VERSION__ == 201710L + #define MLX_C_VERSION 2017 + #elif __STDC_VERSION__ == 202311L + #define MLX_C_VERSION 2023 + #else + #define MLX_C_VERSION 0 + #endif + #else + #define MLX_C_VERSION 0 + #endif + #else + #define MLX_C_VERSION 0 + #endif +#else + #define MLX_C_VERSION 0 +#endif + // Checking common assumptions #ifdef __cplusplus #include @@ -109,8 +135,48 @@ static_assert(sizeof(uint16_t) == 2, "uint16_t is not of the correct size"); static_assert(sizeof(uint32_t) == 4, "uint32_t is not of the correct size"); static_assert(sizeof(uint64_t) == 8, "uint64_t is not of the correct size"); +#elif MLX_C_VERSION >= 2011 + #if MLX_C_VERSION < 2023 + #include + #endif + #include + #include + + static_assert(CHAR_BIT == 8, "CHAR_BIT is expected to be 8"); + + static_assert(sizeof(int8_t) == 1, "int8_t is not of the correct size" ); + static_assert(sizeof(int16_t) == 2, "int16_t is not of the correct size"); + static_assert(sizeof(int32_t) == 4, "int32_t is not of the correct size"); + static_assert(sizeof(int64_t) == 8, "int64_t is not of the correct size"); + + static_assert(sizeof(uint8_t) == 1, "uint8_t is not of the correct size" ); + static_assert(sizeof(uint16_t) == 2, "uint16_t is not of the correct size"); + static_assert(sizeof(uint32_t) == 4, "uint32_t is not of the correct size"); + static_assert(sizeof(uint64_t) == 8, "uint64_t is not of the correct size"); +#elif defined(MLX_COMPILER_GCC) + #define STATIC_ASSERT(cnd, descr) \ + ({ \ + extern int __attribute__((error("static assert failed: (" #cnd ") (" #descr ")"))) compile_time_check(void); \ + ((cnd) ? 0 : compile_time_check()), 0; \ + }) + + #include + #include + + STATIC_ASSERT(CHAR_BIT == 8, "CHAR_BIT is expected to be 8"); + + STATIC_ASSERT(sizeof(int8_t) == 1, "int8_t is not of the correct size" ); + STATIC_ASSERT(sizeof(int16_t) == 2, "int16_t is not of the correct size"); + STATIC_ASSERT(sizeof(int32_t) == 4, "int32_t is not of the correct size"); + STATIC_ASSERT(sizeof(int64_t) == 8, "int64_t is not of the correct size"); + + STATIC_ASSERT(sizeof(uint8_t) == 1, "uint8_t is not of the correct size" ); + STATIC_ASSERT(sizeof(uint16_t) == 2, "uint16_t is not of the correct size"); + STATIC_ASSERT(sizeof(uint32_t) == 4, "uint32_t is not of the correct size"); + STATIC_ASSERT(sizeof(uint64_t) == 8, "uint64_t is not of the correct size"); #else #define STATIC_ASSERT(COND, MSG) typedef char static_assertion___##MSG[(COND)?1:-1] + #include #include diff --git a/src/renderer/command/vk_cmd_buffer.cpp b/src/renderer/command/vk_cmd_buffer.cpp index b1dade7..7405dc7 100644 --- a/src/renderer/command/vk_cmd_buffer.cpp +++ b/src/renderer/command/vk_cmd_buffer.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/06 18:26:06 by maldavid #+# #+# */ -/* Updated: 2023/12/24 12:58:36 by kbz_8 ### ########.fr */ +/* Updated: 2024/01/03 13:12:58 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,8 +32,9 @@ namespace mlx allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; allocInfo.commandBufferCount = 1; - if(vkAllocateCommandBuffers(Render_Core::get().getDevice().get(), &allocInfo, &_cmd_buffer) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan : failed to allocate command buffer"); + VkResult res = vkAllocateCommandBuffers(Render_Core::get().getDevice().get(), &allocInfo, &_cmd_buffer); + if(res != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Vulkan : failed to allocate command buffer, %s", RCore::verbaliseResultVk(res)); #ifdef DEBUG core::error::report(e_kind::message, "Vulkan : created new command buffer"); #endif @@ -85,8 +86,9 @@ namespace mlx VkFence fence; vkCreateFence(device, &fenceCreateInfo, nullptr, &fence); vkResetFences(device, 1, &fence); - if(vkQueueSubmit(Render_Core::get().getQueue().getGraphic(), 1, &submitInfo, fence) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan error : failed to submit a single time command buffer"); + VkResult res = vkQueueSubmit(Render_Core::get().getQueue().getGraphic(), 1, &submitInfo, fence); + if(res != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Vulkan error : failed to submit a single time command buffer, %s", RCore::verbaliseResultVk(res)); _state = state::submitted; vkWaitForFences(device, 1, &fence, VK_TRUE, UINT64_MAX); vkDestroyFence(device, fence, nullptr); @@ -120,8 +122,9 @@ namespace mlx submitInfo.signalSemaphoreCount = (semaphores == nullptr ? 0 : signalSemaphores.size()); submitInfo.pSignalSemaphores = signalSemaphores.data(); - if(vkQueueSubmit(Render_Core::get().getQueue().getGraphic(), 1, &submitInfo, _fence.get()) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan error : failed to submit draw command buffer"); + VkResult res = vkQueueSubmit(Render_Core::get().getQueue().getGraphic(), 1, &submitInfo, _fence.get()); + if(res != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Vulkan error : failed to submit draw command buffer, %s", RCore::verbaliseResultVk(res)); _state = state::submitted; } diff --git a/src/renderer/command/vk_cmd_pool.cpp b/src/renderer/command/vk_cmd_pool.cpp index f78538f..148932f 100644 --- a/src/renderer/command/vk_cmd_pool.cpp +++ b/src/renderer/command/vk_cmd_pool.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/06 18:24:33 by maldavid #+# #+# */ -/* Updated: 2023/11/18 17:23:38 by maldavid ### ########.fr */ +/* Updated: 2024/01/03 13:13:25 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,8 +22,9 @@ namespace mlx poolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; poolInfo.queueFamilyIndex = Render_Core::get().getQueue().getFamilies().graphicsFamily.value(); - if(vkCreateCommandPool(Render_Core::get().getDevice().get(), &poolInfo, nullptr, &_cmd_pool) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan : failed to create command pool"); + VkResult res = vkCreateCommandPool(Render_Core::get().getDevice().get(), &poolInfo, nullptr, &_cmd_pool); + if(res != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Vulkan : failed to create command pool, %s", RCore::verbaliseResultVk(res)); } void CmdPool::destroy() noexcept diff --git a/src/renderer/core/memory.cpp b/src/renderer/core/memory.cpp index 8712085..0604c15 100644 --- a/src/renderer/core/memory.cpp +++ b/src/renderer/core/memory.cpp @@ -6,7 +6,7 @@ /* By: kbz_8 +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/10/20 22:02:37 by kbz_8 #+# #+# */ -/* Updated: 2023/12/27 21:31:04 by maldavid ### ########.fr */ +/* Updated: 2024/01/03 13:09:40 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -76,18 +76,20 @@ namespace mlx allocatorCreateInfo.instance = Render_Core::get().getInstance().get(); allocatorCreateInfo.pVulkanFunctions = &vma_vulkan_func; - if(vmaCreateAllocator(&allocatorCreateInfo, &_allocator) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan : failed to create graphics memory allocator"); + VkResult res = vmaCreateAllocator(&allocatorCreateInfo, &_allocator); + if(res != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Graphics allocator : failed to create graphics memory allocator, %s", RCore::verbaliseResultVk(res)); #ifdef DEBUG - core::error::report(e_kind::message, "Vulkan : created new allocator"); + core::error::report(e_kind::message, "Graphics allocator : created new allocator"); #endif } VmaAllocation GPUallocator::createBuffer(const VkBufferCreateInfo* binfo, const VmaAllocationCreateInfo* vinfo, VkBuffer& buffer, const char* name) noexcept { VmaAllocation allocation; - if(vmaCreateBuffer(_allocator, binfo, vinfo, &buffer, &allocation, nullptr) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan : failed to allocate a buffer"); + VkResult res = vmaCreateBuffer(_allocator, binfo, vinfo, &buffer, &allocation, nullptr); + if(res != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Graphics allocator : failed to allocate a buffer, %s", RCore::verbaliseResultVk(res)); if(name != nullptr) vmaSetAllocationName(_allocator, allocation, name); #ifdef DEBUG @@ -110,8 +112,9 @@ namespace mlx VmaAllocation GPUallocator::createImage(const VkImageCreateInfo* iminfo, const VmaAllocationCreateInfo* vinfo, VkImage& image, const char* name) noexcept { VmaAllocation allocation; - if(vmaCreateImage(_allocator, iminfo, vinfo, &image, &allocation, nullptr) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan : failed to allocate an image"); + VkResult res = vmaCreateImage(_allocator, iminfo, vinfo, &image, &allocation, nullptr); + if(res != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Graphics allocator : failed to allocate an image, %s", RCore::verbaliseResultVk(res)); if(name != nullptr) vmaSetAllocationName(_allocator, allocation, name); #ifdef DEBUG @@ -133,8 +136,9 @@ namespace mlx void GPUallocator::mapMemory(VmaAllocation allocation, void** data) noexcept { - if(vmaMapMemory(_allocator, allocation, data) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Graphics allocator : unable to map GPU memory to CPU memory"); + VkResult res = vmaMapMemory(_allocator, allocation, data); + if(res != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Graphics allocator : unable to map GPU memory to CPU memory, %s", RCore::verbaliseResultVk(res)); } void GPUallocator::unmapMemory(VmaAllocation allocation) noexcept diff --git a/src/renderer/core/render_core.cpp b/src/renderer/core/render_core.cpp index fa615ff..6ff4a0a 100644 --- a/src/renderer/core/render_core.cpp +++ b/src/renderer/core/render_core.cpp @@ -6,30 +6,34 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/12/17 23:33:34 by maldavid #+# #+# */ -/* Updated: 2023/12/15 20:32:01 by maldavid ### ########.fr */ +/* Updated: 2024/01/03 13:47:13 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ #define VOLK_IMPLEMENTATION -#if defined(_WIN32) || defined(_WIN64) +#if defined(MLX_PLAT_WINDOWS) #define VK_USE_PLATFORM_WIN32_KHR -#elif defined(__APPLE__) || defined(__MACH__) + constexpr const char* VULKAN_LIB_NAME = "vulkan-1.dll"; +#elif defined(MLX_PLAT_MACOS) #define VK_USE_PLATFORM_MACOS_MVK #define VK_USE_PLATFORM_METAL_EXT + constexpr const char* VULKAN_LIB_NAME = "libvulkan.dylib / libvulkan.1.dylib / libMoltenVK.dylib"; #else #define VK_USE_PLATFORM_XLIB_KHR #define VK_USE_PLATFORM_WAYLAND_KHR + constexpr const char* VULKAN_LIB_NAME = "libvulkan.so / libvulkan.so.1"; #endif -#include "render_core.h" +#include +#include #include #ifdef DEBUG - #ifndef MLX_COMPILER_MSVC - #warning "MLX is being compiled in debug mode, this activates Vulkan's validation layers and debug messages which may impact rendering performances" - #else + #ifdef MLX_COMPILER_MSVC #pragma NOTE("MLX is being compiled in debug mode, this activates Vulkan's validation layers and debug messages which may impact rendering performances") + #else + #warning "MLX is being compiled in debug mode, this activates Vulkan's validation layers and debug messages which may impact rendering performances" #endif #endif @@ -88,7 +92,8 @@ namespace mlx void Render_Core::init() { - volkInitialize(); + if(volkInitialize() != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Vulkan loader : cannot load %s, are you sure Vulkan is installed on your system ?", VULKAN_LIB_NAME); _instance.init(); volkLoadInstance(_instance.get()); diff --git a/src/renderer/core/vk_validation_layers.cpp b/src/renderer/core/vk_validation_layers.cpp index 837aa1b..367c1fb 100644 --- a/src/renderer/core/vk_validation_layers.cpp +++ b/src/renderer/core/vk_validation_layers.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/12/19 14:05:25 by maldavid #+# #+# */ -/* Updated: 2023/12/31 00:41:39 by maldavid ### ########.fr */ +/* Updated: 2024/01/03 13:11:27 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,8 +27,9 @@ namespace mlx VkDebugUtilsMessengerCreateInfoEXT createInfo{}; populateDebugMessengerCreateInfo(createInfo); - if(createDebugUtilsMessengerEXT(&createInfo, nullptr) != VK_SUCCESS) - core::error::report(e_kind::warning, "Vulkan : failed to set up debug messenger"); + VkResult res = createDebugUtilsMessengerEXT(&createInfo, nullptr); + if(res != VK_SUCCESS) + core::error::report(e_kind::warning, "Vulkan : failed to set up debug messenger, %s", RCore::verbaliseResultVk(res)); #ifdef DEBUG else core::error::report(e_kind::message, "Vulkan : enabled validation layers"); diff --git a/src/renderer/descriptors/vk_descriptor_pool.cpp b/src/renderer/descriptors/vk_descriptor_pool.cpp index 95e2f6e..188403f 100644 --- a/src/renderer/descriptors/vk_descriptor_pool.cpp +++ b/src/renderer/descriptors/vk_descriptor_pool.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/01/23 18:34:23 by maldavid #+# #+# */ -/* Updated: 2023/11/18 17:23:05 by maldavid ### ########.fr */ +/* Updated: 2024/01/03 13:13:54 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,8 +23,9 @@ namespace mlx poolInfo.pPoolSizes = size; poolInfo.maxSets = 8192; - if(vkCreateDescriptorPool(Render_Core::get().getDevice().get(), &poolInfo, nullptr, &_pool) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan : failed to create descriptor pool"); + VkResult res = vkCreateDescriptorPool(Render_Core::get().getDevice().get(), &poolInfo, nullptr, &_pool); + if(res != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Vulkan : failed to create descriptor pool, %s", RCore::verbaliseResultVk(res)); } void DescriptorPool::destroy() noexcept diff --git a/src/renderer/descriptors/vk_descriptor_set.cpp b/src/renderer/descriptors/vk_descriptor_set.cpp index cf6a624..b840c7f 100644 --- a/src/renderer/descriptors/vk_descriptor_set.cpp +++ b/src/renderer/descriptors/vk_descriptor_set.cpp @@ -6,11 +6,12 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/01/23 18:40:44 by maldavid #+# #+# */ -/* Updated: 2023/12/24 09:37:55 by kbz_8 ### ########.fr */ +/* Updated: 2024/01/03 13:14:24 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ #include "vk_descriptor_set.h" +#include "renderer/core/render_core.h" #include "vk_descriptor_pool.h" #include "vk_descriptor_set_layout.h" #include @@ -36,8 +37,9 @@ namespace mlx allocInfo.descriptorSetCount = static_cast(MAX_FRAMES_IN_FLIGHT); allocInfo.pSetLayouts = layouts.data(); - if(vkAllocateDescriptorSets(device, &allocInfo, _desc_set.data()) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan : failed to allocate descriptor set"); + VkResult res = vkAllocateDescriptorSets(device, &allocInfo, _desc_set.data()); + if(res != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Vulkan : failed to allocate descriptor set, %s", RCore::verbaliseResultVk(res)); #ifdef DEBUG core::error::report(e_kind::message, "Vulkan : created new descriptor set"); #endif diff --git a/src/renderer/descriptors/vk_descriptor_set_layout.cpp b/src/renderer/descriptors/vk_descriptor_set_layout.cpp index 70909a7..12b98d8 100644 --- a/src/renderer/descriptors/vk_descriptor_set_layout.cpp +++ b/src/renderer/descriptors/vk_descriptor_set_layout.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/01/23 18:37:28 by maldavid #+# #+# */ -/* Updated: 2023/12/10 22:25:59 by kbz_8 ### ########.fr */ +/* Updated: 2024/01/03 13:14:58 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -34,8 +34,9 @@ namespace mlx layoutInfo.bindingCount = _bindings.size(); layoutInfo.pBindings = bindings.data(); - if(vkCreateDescriptorSetLayout(Render_Core::get().getDevice().get(), &layoutInfo, nullptr, &_layout) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan : failed to create descriptor set layout"); + VkResult res = vkCreateDescriptorSetLayout(Render_Core::get().getDevice().get(), &layoutInfo, nullptr, &_layout); + if(res != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Vulkan : failed to create descriptor set layout, %s", RCore::verbaliseResultVk(res)); } void DescriptorSetLayout::destroy() noexcept diff --git a/src/renderer/images/vk_image.cpp b/src/renderer/images/vk_image.cpp index 2d31cd5..9cca944 100644 --- a/src/renderer/images/vk_image.cpp +++ b/src/renderer/images/vk_image.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/01/25 11:59:07 by maldavid #+# #+# */ -/* Updated: 2023/12/22 23:35:07 by kbz_8 ### ########.fr */ +/* Updated: 2024/01/03 13:16:21 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -182,8 +182,9 @@ namespace mlx viewInfo.subresourceRange.baseArrayLayer = 0; viewInfo.subresourceRange.layerCount = 1; - if(vkCreateImageView(Render_Core::get().getDevice().get(), &viewInfo, nullptr, &_image_view) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan : failed to create an image view"); + VkResult res = vkCreateImageView(Render_Core::get().getDevice().get(), &viewInfo, nullptr, &_image_view); + if(res != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Vulkan : failed to create an image view, %s", RCore::verbaliseResultVk(res)); } void Image::createSampler() noexcept @@ -201,8 +202,9 @@ namespace mlx info.anisotropyEnable = VK_FALSE; info.maxAnisotropy = 1.0f; - if(vkCreateSampler(Render_Core::get().getDevice().get(), &info, nullptr, &_sampler) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan : failed to create an image"); + VkResult res = vkCreateSampler(Render_Core::get().getDevice().get(), &info, nullptr, &_sampler); + if(res != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Vulkan : failed to create an image, %s", RCore::verbaliseResultVk(res)); } void Image::copyFromBuffer(Buffer& buffer) diff --git a/src/renderer/pipeline/pipeline.cpp b/src/renderer/pipeline/pipeline.cpp index 9d962bb..8d234f7 100644 --- a/src/renderer/pipeline/pipeline.cpp +++ b/src/renderer/pipeline/pipeline.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/12/18 21:27:38 by maldavid #+# #+# */ -/* Updated: 2023/12/22 22:00:37 by kbz_8 ### ########.fr */ +/* Updated: 2024/01/03 13:16:57 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -305,8 +305,9 @@ namespace mlx pipelineInfo.subpass = 0; pipelineInfo.basePipelineHandle = VK_NULL_HANDLE; - if(vkCreateGraphicsPipelines(Render_Core::get().getDevice().get(), VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &_graphicsPipeline) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan : failed to create a graphics pipeline"); + VkResult res = vkCreateGraphicsPipelines(Render_Core::get().getDevice().get(), VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &_graphicsPipeline); + if(res != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Vulkan : failed to create a graphics pipeline, %s", RCore::verbaliseResultVk(res)); #ifdef DEBUG core::error::report(e_kind::message, "Vulkan : created new graphic pipeline"); #endif diff --git a/src/renderer/renderpass/vk_framebuffer.cpp b/src/renderer/renderpass/vk_framebuffer.cpp index ed868ca..c96c54d 100644 --- a/src/renderer/renderpass/vk_framebuffer.cpp +++ b/src/renderer/renderpass/vk_framebuffer.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/06 18:18:06 by maldavid #+# #+# */ -/* Updated: 2023/11/20 07:24:26 by maldavid ### ########.fr */ +/* Updated: 2024/01/03 13:17:27 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,8 +33,9 @@ namespace mlx framebufferInfo.height = _height; framebufferInfo.layers = 1; - if(vkCreateFramebuffer(Render_Core::get().getDevice().get(), &framebufferInfo, nullptr, &_framebuffer) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan : failed to create a framebuffer"); + VkResult res = vkCreateFramebuffer(Render_Core::get().getDevice().get(), &framebufferInfo, nullptr, &_framebuffer); + if(res != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Vulkan : failed to create a framebuffer, %s", RCore::verbaliseResultVk(res)); #ifdef DEBUG core::error::report(e_kind::message, "Vulkan : created new framebuffer"); #endif diff --git a/src/renderer/renderpass/vk_render_pass.cpp b/src/renderer/renderpass/vk_render_pass.cpp index 2c2dc9c..6bd6b6c 100644 --- a/src/renderer/renderpass/vk_render_pass.cpp +++ b/src/renderer/renderpass/vk_render_pass.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/06 18:21:36 by maldavid #+# #+# */ -/* Updated: 2023/12/24 15:31:02 by kbz_8 ### ########.fr */ +/* Updated: 2024/01/03 13:17:56 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -70,8 +70,9 @@ namespace mlx renderPassInfo.dependencyCount = static_cast(subpassesDeps.size()); renderPassInfo.pDependencies = subpassesDeps.data(); - if(vkCreateRenderPass(Render_Core::get().getDevice().get(), &renderPassInfo, nullptr, &_renderPass) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan : failed to create render pass"); + VkResult res = vkCreateRenderPass(Render_Core::get().getDevice().get(), &renderPassInfo, nullptr, &_renderPass); + if(res != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Vulkan : failed to create render pass, %s", RCore::verbaliseResultVk(res)); #ifdef DEBUG core::error::report(e_kind::message, "Vulkan : created new render pass"); #endif diff --git a/src/renderer/swapchain/vk_swapchain.cpp b/src/renderer/swapchain/vk_swapchain.cpp index cada9ba..ccd0620 100644 --- a/src/renderer/swapchain/vk_swapchain.cpp +++ b/src/renderer/swapchain/vk_swapchain.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/06 18:22:28 by maldavid #+# #+# */ -/* Updated: 2023/12/15 21:49:19 by maldavid ### ########.fr */ +/* Updated: 2024/01/03 13:18:25 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -59,8 +59,9 @@ namespace mlx else createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; - if(vkCreateSwapchainKHR(device, &createInfo, nullptr, &_swapChain) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan : failed to create the swapchain"); + VkResult res = vkCreateSwapchainKHR(device, &createInfo, nullptr, &_swapChain); + if(res != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Vulkan : failed to create the swapchain, %s", RCore::verbaliseResultVk(res)); std::vector tmp; vkGetSwapchainImagesKHR(device, _swapChain, &imageCount, nullptr);