diff options
author | Dario <dariosamo@gmail.com> | 2023-09-22 18:38:02 -0300 |
---|---|---|
committer | Dario <dariosamo@gmail.com> | 2023-09-25 10:37:47 -0300 |
commit | 057367bf4f23850eb455585c3845b0bebee2aa03 (patch) | |
tree | 198d72760c84a126dcb939193cf274a16adb201e /drivers/vulkan | |
parent | df0a822323a79e1a645f0c6a17d51c7602f23166 (diff) | |
download | redot-engine-057367bf4f23850eb455585c3845b0bebee2aa03.tar.gz |
Add FidelityFX Super Resolution 2.2 (FSR 2.2.1) support.
Introduces support for FSR2 as a new upscaler option available from the project settings. Also introduces an specific render list for surfaces that require motion and the ability to derive motion vectors from depth buffer and camera motion.
Diffstat (limited to 'drivers/vulkan')
-rw-r--r-- | drivers/vulkan/rendering_device_vulkan.cpp | 12 | ||||
-rw-r--r-- | drivers/vulkan/vulkan_context.cpp | 23 | ||||
-rw-r--r-- | drivers/vulkan/vulkan_context.h | 3 |
3 files changed, 36 insertions, 2 deletions
diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index b2f4123fb9..11321b2121 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -5750,8 +5750,8 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, Buffer *buffer = uniform_buffer_owner.get_or_null(uniform.get_id(0)); ERR_FAIL_NULL_V_MSG(buffer, RID(), "Uniform buffer supplied (binding: " + itos(uniform.binding) + ") is invalid."); - ERR_FAIL_COND_V_MSG(buffer->size != (uint32_t)set_uniform.length, RID(), - "Uniform buffer supplied (binding: " + itos(uniform.binding) + ") size (" + itos(buffer->size) + " does not match size of shader uniform: (" + itos(set_uniform.length) + ")."); + ERR_FAIL_COND_V_MSG(buffer->size < (uint32_t)set_uniform.length, RID(), + "Uniform buffer supplied (binding: " + itos(uniform.binding) + ") size (" + itos(buffer->size) + " is smaller than size of shader uniform: (" + itos(set_uniform.length) + ")."); write.dstArrayElement = 0; write.descriptorCount = 1; @@ -9562,6 +9562,14 @@ uint64_t RenderingDeviceVulkan::limit_get(Limit p_limit) const { VulkanContext::SubgroupCapabilities subgroup_capabilities = context->get_subgroup_capabilities(); return subgroup_capabilities.size; } + case LIMIT_SUBGROUP_MIN_SIZE: { + VulkanContext::SubgroupCapabilities subgroup_capabilities = context->get_subgroup_capabilities(); + return subgroup_capabilities.min_size; + } + case LIMIT_SUBGROUP_MAX_SIZE: { + VulkanContext::SubgroupCapabilities subgroup_capabilities = context->get_subgroup_capabilities(); + return subgroup_capabilities.max_size; + } case LIMIT_SUBGROUP_IN_SHADERS: { VulkanContext::SubgroupCapabilities subgroup_capabilities = context->get_subgroup_capabilities(); return subgroup_capabilities.supported_stages_flags_rd(); diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp index 344ea0d324..99ee6d64d9 100644 --- a/drivers/vulkan/vulkan_context.cpp +++ b/drivers/vulkan/vulkan_context.cpp @@ -504,6 +504,7 @@ Error VulkanContext::_initialize_device_extensions() { register_requested_device_extension(VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME, false); register_requested_device_extension(VK_KHR_MAINTENANCE_2_EXTENSION_NAME, false); register_requested_device_extension(VK_EXT_PIPELINE_CREATION_CACHE_CONTROL_EXTENSION_NAME, false); + register_requested_device_extension(VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME, false); if (Engine::get_singleton()->is_generate_spirv_debug_info_enabled()) { register_requested_device_extension(VK_KHR_SHADER_NON_SEMANTIC_INFO_EXTENSION_NAME, true); @@ -739,9 +740,12 @@ Error VulkanContext::_check_capabilities() { multiview_capabilities.max_view_count = 0; multiview_capabilities.max_instance_count = 0; subgroup_capabilities.size = 0; + subgroup_capabilities.min_size = 0; + subgroup_capabilities.max_size = 0; subgroup_capabilities.supportedStages = 0; subgroup_capabilities.supportedOperations = 0; subgroup_capabilities.quadOperationsInAllStages = false; + subgroup_capabilities.size_control_is_supported = false; shader_capabilities.shader_float16_is_supported = false; shader_capabilities.shader_int8_is_supported = false; storage_buffer_capabilities.storage_buffer_16_bit_access_is_supported = false; @@ -886,6 +890,7 @@ Error VulkanContext::_check_capabilities() { VkPhysicalDeviceFragmentShadingRatePropertiesKHR vrsProperties{}; VkPhysicalDeviceMultiviewProperties multiviewProperties{}; VkPhysicalDeviceSubgroupProperties subgroupProperties{}; + VkPhysicalDeviceSubgroupSizeControlProperties subgroupSizeControlProperties = {}; VkPhysicalDeviceProperties2 physicalDeviceProperties{}; void *nextptr = nullptr; @@ -894,6 +899,15 @@ Error VulkanContext::_check_capabilities() { subgroupProperties.pNext = nextptr; nextptr = &subgroupProperties; + + subgroup_capabilities.size_control_is_supported = is_device_extension_enabled(VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME); + + if (subgroup_capabilities.size_control_is_supported) { + subgroupSizeControlProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES; + subgroupSizeControlProperties.pNext = nextptr; + + nextptr = &subgroupSizeControlProperties; + } } if (multiview_capabilities.is_supported) { @@ -916,6 +930,8 @@ Error VulkanContext::_check_capabilities() { device_properties_func(gpu, &physicalDeviceProperties); subgroup_capabilities.size = subgroupProperties.subgroupSize; + subgroup_capabilities.min_size = subgroupProperties.subgroupSize; + subgroup_capabilities.max_size = subgroupProperties.subgroupSize; subgroup_capabilities.supportedStages = subgroupProperties.supportedStages; subgroup_capabilities.supportedOperations = subgroupProperties.supportedOperations; // Note: quadOperationsInAllStages will be true if: @@ -923,6 +939,11 @@ Error VulkanContext::_check_capabilities() { // - supportedOperations has VK_SUBGROUP_FEATURE_QUAD_BIT. subgroup_capabilities.quadOperationsInAllStages = subgroupProperties.quadOperationsInAllStages; + if (subgroup_capabilities.size_control_is_supported && (subgroupSizeControlProperties.requiredSubgroupSizeStages & VK_SHADER_STAGE_COMPUTE_BIT)) { + subgroup_capabilities.min_size = subgroupSizeControlProperties.minSubgroupSize; + subgroup_capabilities.max_size = subgroupSizeControlProperties.maxSubgroupSize; + } + if (vrs_capabilities.pipeline_vrs_supported || vrs_capabilities.primitive_vrs_supported || vrs_capabilities.attachment_vrs_supported) { print_verbose("- Vulkan Variable Rate Shading supported:"); if (vrs_capabilities.pipeline_vrs_supported) { @@ -962,6 +983,8 @@ Error VulkanContext::_check_capabilities() { print_verbose("- Vulkan subgroup:"); print_verbose(" size: " + itos(subgroup_capabilities.size)); + print_verbose(" min size: " + itos(subgroup_capabilities.min_size)); + print_verbose(" max size: " + itos(subgroup_capabilities.max_size)); print_verbose(" stages: " + subgroup_capabilities.supported_stages_desc()); print_verbose(" supported ops: " + subgroup_capabilities.supported_operations_desc()); if (subgroup_capabilities.quadOperationsInAllStages) { diff --git a/drivers/vulkan/vulkan_context.h b/drivers/vulkan/vulkan_context.h index ef40aba9e1..2ccfd13739 100644 --- a/drivers/vulkan/vulkan_context.h +++ b/drivers/vulkan/vulkan_context.h @@ -52,9 +52,12 @@ class VulkanContext { public: struct SubgroupCapabilities { uint32_t size; + uint32_t min_size; + uint32_t max_size; VkShaderStageFlags supportedStages; VkSubgroupFeatureFlags supportedOperations; VkBool32 quadOperationsInAllStages; + bool size_control_is_supported; uint32_t supported_stages_flags_rd() const; String supported_stages_desc() const; |