summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2023-04-25 14:14:01 +0200
committerRémi Verschelde <rverschelde@gmail.com>2023-04-27 08:43:30 +0200
commit908325c29ebc94e58289911f64ebfb451679011c (patch)
tree530abcbced9afaa10079cce1df466d68a1edb4e4 /drivers
parenta5779ff2817f0d99aba484b825192a06749a17c1 (diff)
Fix unsupported sampler filter used for voxel GI
(cherry picked from commit 09aa1bbdb3c9dc4891a192854636a4e33ccd46bc)
Diffstat (limited to 'drivers')
-rw-r--r--drivers/vulkan/rendering_device_vulkan.cpp12
-rw-r--r--drivers/vulkan/rendering_device_vulkan.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp
index 2f01376a45..f6cc2ae4f1 100644
--- a/drivers/vulkan/rendering_device_vulkan.cpp
+++ b/drivers/vulkan/rendering_device_vulkan.cpp
@@ -4306,6 +4306,18 @@ RID RenderingDeviceVulkan::sampler_create(const SamplerState &p_state) {
return id;
}
+bool RenderingDeviceVulkan::sampler_is_format_supported_for_filter(DataFormat p_format, SamplerFilter p_sampler_filter) const {
+ ERR_FAIL_INDEX_V(p_format, DATA_FORMAT_MAX, false);
+
+ _THREAD_SAFE_METHOD_
+
+ // Validate that this image is supported for the intended filtering.
+ VkFormatProperties properties;
+ vkGetPhysicalDeviceFormatProperties(context->get_physical_device(), vulkan_formats[p_format], &properties);
+
+ return p_sampler_filter == RD::SAMPLER_FILTER_NEAREST || (p_sampler_filter == RD::SAMPLER_FILTER_LINEAR && (properties.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT));
+}
+
/**********************/
/**** VERTEX ARRAY ****/
/**********************/
diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h
index 3f01895745..2ec1574955 100644
--- a/drivers/vulkan/rendering_device_vulkan.h
+++ b/drivers/vulkan/rendering_device_vulkan.h
@@ -1084,6 +1084,7 @@ public:
/*****************/
virtual RID sampler_create(const SamplerState &p_state);
+ virtual bool sampler_is_format_supported_for_filter(DataFormat p_format, SamplerFilter p_sampler_filter) const;
/**********************/
/**** VERTEX ARRAY ****/