]> git.tdb.fi Git - libs/gui.git/blobdiff - source/graphics/vkxlib/vulkancontext.cpp
Use standard fixed size integer types
[libs/gui.git] / source / graphics / vkxlib / vulkancontext.cpp
index 8e253e148b0fbc0a972701382ee42565ce313227..0d332b3d25e0ccaacb751482daefff15f0ed5e62 100644 (file)
@@ -1,12 +1,13 @@
+#include "vulkancontext.h"
+#include "vulkancontext_platform.h"
 #include <stdexcept>
 #include <vector>
 #define VK_USE_PLATFORM_XLIB_KHR
 #include <vulkan/vulkan.h>
 #include <msp/core/application.h>
+#include <msp/debug/debugapi.h>
 #include <msp/io/print.h>
 #include "display_private.h"
-#include "vulkancontext.h"
-#include "vulkancontext_platform.h"
 #include "window_private.h"
 
 using namespace std;
@@ -63,7 +64,8 @@ string vulkan_error::get_error_message(unsigned code)
 VulkanOptions::VulkanOptions():
        enable_validation(false),
        enable_debug_report(false),
-       enable_geometry_shader(false)
+       enable_geometry_shader(false),
+       enable_tessellation_shader(false)
 { }
 
 
@@ -121,7 +123,7 @@ void VulkanContext::platform_init(const VulkanOptions &opts)
                {
                        VkDebugReportCallbackCreateInfoEXT debug_report_create_info = { };
                        debug_report_create_info.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
-                       debug_report_create_info.flags = VK_DEBUG_REPORT_WARNING_BIT_EXT|VK_DEBUG_REPORT_ERROR_BIT_EXT|VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
+                       debug_report_create_info.flags = VK_DEBUG_REPORT_WARNING_BIT_EXT|VK_DEBUG_REPORT_ERROR_BIT_EXT|VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT|VK_DEBUG_REPORT_INFORMATION_BIT_EXT;
                        debug_report_create_info.pfnCallback = &Private::debug_report_func;
                        debug_report_create_info.pUserData = this;
 
@@ -176,7 +178,10 @@ void VulkanContext::platform_init(const VulkanOptions &opts)
                                continue;
 
                        if(supported)
-                               priv->physical_device = phys_devices[0];
+                       {
+                               priv->physical_device = phys_device;
+                               break;
+                       }
                }
 
                if(!priv->physical_device)
@@ -196,6 +201,7 @@ void VulkanContext::platform_init(const VulkanOptions &opts)
 
                VkPhysicalDeviceFeatures features = { };
                features.geometryShader = (opts.enable_geometry_shader ? VK_TRUE : VK_FALSE);
+               features.tessellationShader = (opts.enable_tessellation_shader ? VK_TRUE : VK_FALSE);
 
                VkDeviceCreateInfo device_create_info = { };
                device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
@@ -251,9 +257,11 @@ VulkanContext::Private::Private():
        debug_report_callback(0)
 { }
 
-VkBool32 VulkanContext::Private::debug_report_func(VkDebugReportFlagsEXT, VkDebugReportObjectTypeEXT obj_type, uint64_t obj_id, size_t, int32_t, const char *layer_prefix, const char *message, void *)
+VkBool32 VulkanContext::Private::debug_report_func(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT, uint64_t, size_t, int32_t, const char *, const char *message, void *)
 {
-       IO::print(IO::cerr, "Vulkan debug report from %s: Object %d of type %d: %s\n", layer_prefix, obj_type, obj_id, message);
+       IO::print(IO::cerr, "%s\n", message);
+       if((flags&VK_DEBUG_REPORT_ERROR_BIT_EXT) && Debug::check_debugger()==Debug::GDB)
+               Debug::debug_break();
        return VK_FALSE;
 }