From 20deb0917d466ca9dd1bf435dfb326c72f73e3c0 Mon Sep 17 00:00:00 2001 From: Je06jm Date: Tue, 23 Nov 2021 14:16:03 -0700 Subject: Implemented AMD's FSR as a computer shader for upscaling 3D scenes --- drivers/vulkan/rendering_device_vulkan.cpp | 1 + drivers/vulkan/vulkan_context.cpp | 18 ++++++++++++++++++ drivers/vulkan/vulkan_context.h | 12 ++++++++++++ 3 files changed, 31 insertions(+) (limited to 'drivers/vulkan') diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 4cae051302..952ee50074 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -8822,6 +8822,7 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context, bool p_local_de // get info about further features VulkanContext::MultiviewCapabilities multiview_capabilies = p_context->get_multiview_capabilities(); device_capabilities.supports_multiview = multiview_capabilies.is_supported && multiview_capabilies.max_view_count > 1; + device_capabilities.supports_fsr_half_float = p_context->get_shader_capabilities().shader_float16_is_supported && p_context->get_storage_buffer_capabilities().storage_buffer_16_bit_access_is_supported; } context = p_context; diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp index c178a68236..5912f481ec 100644 --- a/drivers/vulkan/vulkan_context.cpp +++ b/drivers/vulkan/vulkan_context.cpp @@ -535,6 +535,24 @@ Error VulkanContext::_check_capabilities() { multiview_capabilities.is_supported = multiview_features.multiview; multiview_capabilities.geometry_shader_is_supported = multiview_features.multiviewGeometryShader; multiview_capabilities.tessellation_shader_is_supported = multiview_features.multiviewTessellationShader; + + VkPhysicalDeviceShaderFloat16Int8FeaturesKHR shader_features; + shader_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES_KHR; + shader_features.pNext = NULL; + + device_features.pNext = &shader_features; + + device_features_func(gpu, &device_features); + shader_capabilities.shader_float16_is_supported = shader_features.shaderFloat16; + + VkPhysicalDevice16BitStorageFeaturesKHR storage_feature; + storage_feature.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR; + storage_feature.pNext = NULL; + + device_features.pNext = &storage_feature; + + device_features_func(gpu, &device_features); + storage_buffer_capabilities.storage_buffer_16_bit_access_is_supported = storage_feature.storageBuffer16BitAccess; } // check extended properties diff --git a/drivers/vulkan/vulkan_context.h b/drivers/vulkan/vulkan_context.h index ae7c697be8..ab2f6a3eb5 100644 --- a/drivers/vulkan/vulkan_context.h +++ b/drivers/vulkan/vulkan_context.h @@ -66,6 +66,14 @@ public: uint32_t max_instance_count; }; + struct ShaderCapabilities { + bool shader_float16_is_supported; + }; + + struct StorageBufferCapabilities { + bool storage_buffer_16_bit_access_is_supported; + }; + private: enum { MAX_EXTENSIONS = 128, @@ -88,6 +96,8 @@ private: uint32_t vulkan_patch = 0; SubgroupCapabilities subgroup_capabilities; MultiviewCapabilities multiview_capabilities; + ShaderCapabilities shader_capabilities; + StorageBufferCapabilities storage_buffer_capabilities; String device_vendor; String device_name; @@ -239,6 +249,8 @@ public: uint32_t get_vulkan_minor() const { return vulkan_minor; }; SubgroupCapabilities get_subgroup_capabilities() const { return subgroup_capabilities; }; MultiviewCapabilities get_multiview_capabilities() const { return multiview_capabilities; }; + ShaderCapabilities get_shader_capabilities() const { return shader_capabilities; }; + StorageBufferCapabilities get_storage_buffer_capabilities() const { return storage_buffer_capabilities; }; VkDevice get_device(); VkPhysicalDevice get_physical_device(); -- cgit v1.2.3