From 421293b8e9d81f465d2f749fe15d631672efc318 Mon Sep 17 00:00:00 2001 From: Benau Date: Fri, 30 Sep 2022 14:42:06 +0800 Subject: [PATCH] Add shader draw parameters detection --- .../include/ge_vulkan_features.hpp | 2 ++ lib/graphics_engine/src/ge_vulkan_features.cpp | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/graphics_engine/include/ge_vulkan_features.hpp b/lib/graphics_engine/include/ge_vulkan_features.hpp index 665053d4c..e19ed9ea1 100644 --- a/lib/graphics_engine/include/ge_vulkan_features.hpp +++ b/lib/graphics_engine/include/ge_vulkan_features.hpp @@ -34,6 +34,8 @@ bool supportsMultiDrawIndirect(); bool supportsBaseVertexRendering(); // ---------------------------------------------------------------------------- bool supportsComputeInMainQueue(); + // ---------------------------------------------------------------------------- +bool supportsShaderDrawParameters(); // ---------------------------------------------------------------------------- bool supportsS3TCBC3(); // ---------------------------------------------------------------------------- diff --git a/lib/graphics_engine/src/ge_vulkan_features.cpp b/lib/graphics_engine/src/ge_vulkan_features.cpp index e03e8680d..67e7a4b0c 100644 --- a/lib/graphics_engine/src/ge_vulkan_features.cpp +++ b/lib/graphics_engine/src/ge_vulkan_features.cpp @@ -28,6 +28,7 @@ uint32_t g_max_sampler_supported = 0; bool g_supports_multi_draw_indirect = false; bool g_supports_base_vertex_rendering = true; bool g_supports_compute_in_main_queue = false; +bool g_supports_shader_draw_parameters = false; bool g_supports_s3tc_bc3 = false; bool g_supports_bptc_bc7 = false; bool g_supports_astc_4x4 = false; @@ -127,6 +128,11 @@ void GEVulkanFeatures::init(GEVulkanDriver* vk) VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES; supported_features.pNext = &descriptor_indexing_features; + VkPhysicalDeviceShaderDrawParametersFeatures shader_draw = {}; + shader_draw.sType = + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES; + descriptor_indexing_features.pNext = &shader_draw; + PFN_vkGetPhysicalDeviceFeatures2 get_features = vkGetPhysicalDeviceFeatures2; if (vk->getPhysicalDeviceProperties().apiVersion < VK_API_VERSION_1_1 || !get_features) @@ -145,6 +151,8 @@ void GEVulkanFeatures::init(GEVulkanDriver* vk) .shaderSampledImageArrayNonUniformIndexing == VK_TRUE); g_supports_partially_bound = (descriptor_indexing_features .descriptorBindingPartiallyBound == VK_TRUE); + g_supports_shader_draw_parameters = (shader_draw + .shaderDrawParameters == VK_TRUE); #if defined(__APPLE__) bool missing_vkGetPhysicalDeviceProperties2 = @@ -212,6 +220,9 @@ void GEVulkanFeatures::printStats() os::Printer::log( "Vulkan supports compute in main queue", g_supports_compute_in_main_queue ? "true" : "false"); + os::Printer::log( + "Vulkan supports shader draw parameters", + g_supports_shader_draw_parameters ? "true" : "false"); os::Printer::log( "Vulkan supports s3 texture compression (bc3, dxt5)", g_supports_s3tc_bc3 ? "true" : "false"); @@ -300,6 +311,12 @@ bool GEVulkanFeatures::supportsComputeInMainQueue() return g_supports_compute_in_main_queue; } // supportsComputeInMainQueue +// ---------------------------------------------------------------------------- +bool GEVulkanFeatures::supportsShaderDrawParameters() +{ + return g_supports_shader_draw_parameters; +} // supportsShaderDrawParameters + // ---------------------------------------------------------------------------- bool GEVulkanFeatures::supportsS3TCBC3() {