mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 09:27:00 +00:00
Examples: Fixed enabling IMGUI_VULKAN_DEBUG_REPORT which was broken during refactor because of duplicate 'extensions' local variable.
This commit is contained in:
parent
8074d56bdd
commit
cf365ed00b
@ -189,9 +189,9 @@ static void resize_vulkan(SDL_Window*, int w, int h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
||||||
static VKAPI_ATTR VkBool32 VKAPI_CALL debug_report(
|
static VKAPI_ATTR VkBool32 VKAPI_CALL debug_report(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData)
|
||||||
VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData)
|
|
||||||
{
|
{
|
||||||
|
(void)flags; (void)object; (void)location; (void)messageCode; (void)pUserData; (void)pLayerPrefix; // Unused arguemnts
|
||||||
printf("[vulkan] ObjectType: %i\nMessage: %s\n\n", objectType, pMessage);
|
printf("[vulkan] ObjectType: %i\nMessage: %s\n\n", objectType, pMessage);
|
||||||
return VK_FALSE;
|
return VK_FALSE;
|
||||||
}
|
}
|
||||||
@ -209,25 +209,24 @@ static void setup_vulkan(SDL_Window* window, const char** extensions, uint32_t e
|
|||||||
create_info.ppEnabledExtensionNames = extensions;
|
create_info.ppEnabledExtensionNames = extensions;
|
||||||
|
|
||||||
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
||||||
// enabling multiple validation layers grouped as lunarg standard validation
|
// Enabling multiple validation layers grouped as LunarG standard validation
|
||||||
const char* layers[] = { "VK_LAYER_LUNARG_standard_validation" };
|
const char* layers[] = { "VK_LAYER_LUNARG_standard_validation" };
|
||||||
create_info.enabledLayerCount = 1;
|
create_info.enabledLayerCount = 1;
|
||||||
create_info.ppEnabledLayerNames = layers;
|
create_info.ppEnabledLayerNames = layers;
|
||||||
|
|
||||||
// need additional storage for char pointer to debug report extension
|
// Enable debug report extension (we need additional storage, so we duplicate the user array to add our new extension to it)
|
||||||
const char** extensions = (const char**)malloc(sizeof(const char*) * (extensions_count + 1));
|
const char** extensions_ext = (const char**)malloc(sizeof(const char*) * (extensions_count + 1));
|
||||||
for (size_t i = 0; i < extensions_count; i++)
|
memcpy(extensions_ext, extensions, extensions_count * sizeof(const char*));
|
||||||
extensions[i] = extensions[i];
|
extensions_ext[extensions_count] = "VK_EXT_debug_report";
|
||||||
extensions[extensions_count] = "VK_EXT_debug_report";
|
|
||||||
create_info.enabledExtensionCount = extensions_count + 1;
|
create_info.enabledExtensionCount = extensions_count + 1;
|
||||||
create_info.ppEnabledExtensionNames = extensions;
|
create_info.ppEnabledExtensionNames = extensions_ext;
|
||||||
#endif // IMGUI_VULKAN_DEBUG_REPORT
|
#endif // IMGUI_VULKAN_DEBUG_REPORT
|
||||||
|
|
||||||
err = vkCreateInstance(&create_info, g_Allocator, &g_Instance);
|
err = vkCreateInstance(&create_info, g_Allocator, &g_Instance);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
|
|
||||||
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
||||||
free(extensions);
|
free(extensions_ext);
|
||||||
|
|
||||||
// create the debug report callback
|
// create the debug report callback
|
||||||
VkDebugReportCallbackCreateInfoEXT debug_report_ci = {};
|
VkDebugReportCallbackCreateInfoEXT debug_report_ci = {};
|
||||||
|
@ -192,9 +192,9 @@ static void resize_vulkan(GLFWwindow*, int w, int h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
||||||
static VKAPI_ATTR VkBool32 VKAPI_CALL debug_report(
|
static VKAPI_ATTR VkBool32 VKAPI_CALL debug_report(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData)
|
||||||
VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData)
|
|
||||||
{
|
{
|
||||||
|
(void)flags; (void)object; (void)location; (void)messageCode; (void)pUserData; (void)pLayerPrefix; // Unused arguemnts
|
||||||
printf("[vulkan] ObjectType: %i\nMessage: %s\n\n", objectType, pMessage);
|
printf("[vulkan] ObjectType: %i\nMessage: %s\n\n", objectType, pMessage);
|
||||||
return VK_FALSE;
|
return VK_FALSE;
|
||||||
}
|
}
|
||||||
@ -212,25 +212,24 @@ static void setup_vulkan(GLFWwindow* window, const char** extensions, uint32_t e
|
|||||||
create_info.ppEnabledExtensionNames = extensions;
|
create_info.ppEnabledExtensionNames = extensions;
|
||||||
|
|
||||||
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
||||||
// enabling multiple validation layers grouped as lunarg standard validation
|
// Enabling multiple validation layers grouped as LunarG standard validation
|
||||||
const char* layers[] = { "VK_LAYER_LUNARG_standard_validation" };
|
const char* layers[] = { "VK_LAYER_LUNARG_standard_validation" };
|
||||||
create_info.enabledLayerCount = 1;
|
create_info.enabledLayerCount = 1;
|
||||||
create_info.ppEnabledLayerNames = layers;
|
create_info.ppEnabledLayerNames = layers;
|
||||||
|
|
||||||
// need additional storage for char pointer to debug report extension
|
// Enable debug report extension (we need additional storage, so we duplicate the user array to add our new extension to it)
|
||||||
const char** extensions = (const char**)malloc(sizeof(const char*) * (extensions_count + 1));
|
const char** extensions_ext = (const char**)malloc(sizeof(const char*) * (extensions_count + 1));
|
||||||
for (size_t i = 0; i < extensions_count; i++)
|
memcpy(extensions_ext, extensions, extensions_count * sizeof(const char*));
|
||||||
extensions[i] = extensions[i];
|
extensions_ext[extensions_count] = "VK_EXT_debug_report";
|
||||||
extensions[extensions_count] = "VK_EXT_debug_report";
|
|
||||||
create_info.enabledExtensionCount = extensions_count + 1;
|
create_info.enabledExtensionCount = extensions_count + 1;
|
||||||
create_info.ppEnabledExtensionNames = extensions;
|
create_info.ppEnabledExtensionNames = extensions_ext;
|
||||||
#endif // IMGUI_VULKAN_DEBUG_REPORT
|
#endif // IMGUI_VULKAN_DEBUG_REPORT
|
||||||
|
|
||||||
err = vkCreateInstance(&create_info, g_Allocator, &g_Instance);
|
err = vkCreateInstance(&create_info, g_Allocator, &g_Instance);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
|
|
||||||
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
||||||
free(extensions);
|
free(extensions_ext);
|
||||||
|
|
||||||
// create the debug report callback
|
// create the debug report callback
|
||||||
VkDebugReportCallbackCreateInfoEXT debug_report_ci = {};
|
VkDebugReportCallbackCreateInfoEXT debug_report_ci = {};
|
||||||
|
Loading…
Reference in New Issue
Block a user