]> git.tdb.fi Git - libs/gui.git/blobdiff - source/graphics/vkxlib/vulkancontext.cpp
Use default member initializers and defaulted default constructors
[libs/gui.git] / source / graphics / vkxlib / vulkancontext.cpp
index 8e253e148b0fbc0a972701382ee42565ce313227..439ece68a7d8643134b8e45288cacf0ad6f1e5ef 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;
@@ -60,12 +61,6 @@ string vulkan_error::get_error_message(unsigned code)
        }
 }
 
-VulkanOptions::VulkanOptions():
-       enable_validation(false),
-       enable_debug_report(false),
-       enable_geometry_shader(false)
-{ }
-
 
 void VulkanContext::platform_init(const VulkanOptions &opts)
 {
@@ -121,7 +116,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;
 
@@ -129,8 +124,6 @@ void VulkanContext::platform_init(const VulkanOptions &opts)
                        if(result!=VK_SUCCESS)
                                throw vulkan_error(result, "vkCreateDebugReportCallback");
                }
-               else
-                       priv->debug_report_callback = 0;
 
                VkXlibSurfaceCreateInfoKHR surface_create_info = { };
                surface_create_info.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
@@ -152,7 +145,6 @@ void VulkanContext::platform_init(const VulkanOptions &opts)
                if(result!=VK_SUCCESS)
                        throw vulkan_error(result, "vkEnumeratePhysicalDevices");
 
-               priv->physical_device = 0;
                unsigned gfx_queue_index = 0;
                for(unsigned i=0; i<n_phys_devices; ++i)
                {
@@ -176,7 +168,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 +191,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;
@@ -243,17 +239,11 @@ void (*VulkanContext::_get_function(const std::string &name) const)()
 }
 
 
-VulkanContext::Private::Private():
-       instance(0),
-       physical_device(0),
-       device(0),
-       graphics_queue(0),
-       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;
 }