From: Mikko Rasa Date: Sun, 12 Dec 2021 11:01:15 +0000 (+0200) Subject: Add an option for enabling geometry shaders on Vulkan X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=235af0c1148e6dbce927e56846e851564bd083e8;p=libs%2Fgui.git Add an option for enabling geometry shaders on Vulkan --- diff --git a/source/graphics/vkxlib/vulkancontext.cpp b/source/graphics/vkxlib/vulkancontext.cpp index 34c0c51..8e253e1 100644 --- a/source/graphics/vkxlib/vulkancontext.cpp +++ b/source/graphics/vkxlib/vulkancontext.cpp @@ -62,7 +62,8 @@ string vulkan_error::get_error_message(unsigned code) VulkanOptions::VulkanOptions(): enable_validation(false), - enable_debug_report(false) + enable_debug_report(false), + enable_geometry_shader(false) { } @@ -193,12 +194,16 @@ void VulkanContext::platform_init(const VulkanOptions &opts) extensions.clear(); extensions.push_back("VK_KHR_swapchain"); + VkPhysicalDeviceFeatures features = { }; + features.geometryShader = (opts.enable_geometry_shader ? VK_TRUE : VK_FALSE); + VkDeviceCreateInfo device_create_info = { }; device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; device_create_info.queueCreateInfoCount = 1; device_create_info.pQueueCreateInfos = &queue_create_info; device_create_info.enabledExtensionCount = extensions.size(); device_create_info.ppEnabledExtensionNames = extensions.data(); + device_create_info.pEnabledFeatures = &features; result = f.vkCreateDevice(priv->physical_device, &device_create_info, 0, &priv->device); if(result!=VK_SUCCESS) diff --git a/source/graphics/vulkancontext.h b/source/graphics/vulkancontext.h index 44ac4a5..f80f5cb 100644 --- a/source/graphics/vulkancontext.h +++ b/source/graphics/vulkancontext.h @@ -24,6 +24,7 @@ struct VulkanOptions { bool enable_validation; bool enable_debug_report; + bool enable_geometry_shader; VulkanOptions(); };