summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2020-05-04 16:41:19 -0300
committerGravatar ReinUsesLisp2020-05-04 20:49:23 -0300
commit227278098a6b883e3a40faeb28ec8f130d898240 (patch)
tree02012403a62f080c9f5844526b80ca1d03551eb2
parentexternals: Update Vulkan-Headers (diff)
downloadyuzu-227278098a6b883e3a40faeb28ec8f130d898240.tar.gz
yuzu-227278098a6b883e3a40faeb28ec8f130d898240.tar.xz
yuzu-227278098a6b883e3a40faeb28ec8f130d898240.zip
vk_sampler_cache: Use VK_EXT_custom_border_color when available
This should fix grass interactions on Breath of the Wild on Vulkan. It is currently untested against validation layers. Nvidia's Windows 443.09 beta driver or Linux 440.66.12 is required for now.
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_vulkan/vk_device.cpp27
-rw-r--r--src/video_core/renderer_vulkan/vk_device.h6
-rw-r--r--src/video_core/renderer_vulkan/vk_sampler_cache.cpp13
3 files changed, 44 insertions, 2 deletions
diff --git a/src/video_core/renderer_vulkan/vk_device.cpp b/src/video_core/renderer_vulkan/vk_device.cpp
index 0e4bbca97..09ddfa59c 100644
--- a/src/video_core/renderer_vulkan/vk_device.cpp
+++ b/src/video_core/renderer_vulkan/vk_device.cpp
@@ -293,6 +293,17 @@ bool VKDevice::Create() {
293 LOG_INFO(Render_Vulkan, "Device doesn't support transform feedbacks"); 293 LOG_INFO(Render_Vulkan, "Device doesn't support transform feedbacks");
294 } 294 }
295 295
296 VkPhysicalDeviceCustomBorderColorFeaturesEXT custom_border;
297 if (ext_custom_border_color) {
298 custom_border.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_FEATURES_EXT;
299 custom_border.pNext = nullptr;
300 custom_border.customBorderColors = VK_TRUE;
301 custom_border.customBorderColorWithoutFormat = VK_TRUE;
302 SetNext(next, custom_border);
303 } else {
304 LOG_INFO(Render_Vulkan, "Device doesn't support custom border colors");
305 }
306
296 if (!ext_depth_range_unrestricted) { 307 if (!ext_depth_range_unrestricted) {
297 LOG_INFO(Render_Vulkan, "Device doesn't support depth range unrestricted"); 308 LOG_INFO(Render_Vulkan, "Device doesn't support depth range unrestricted");
298 } 309 }
@@ -520,6 +531,7 @@ std::vector<const char*> VKDevice::LoadExtensions() {
520 bool has_khr_shader_float16_int8{}; 531 bool has_khr_shader_float16_int8{};
521 bool has_ext_subgroup_size_control{}; 532 bool has_ext_subgroup_size_control{};
522 bool has_ext_transform_feedback{}; 533 bool has_ext_transform_feedback{};
534 bool has_ext_custom_border_color{};
523 for (const auto& extension : physical.EnumerateDeviceExtensionProperties()) { 535 for (const auto& extension : physical.EnumerateDeviceExtensionProperties()) {
524 Test(extension, khr_uniform_buffer_standard_layout, 536 Test(extension, khr_uniform_buffer_standard_layout,
525 VK_KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_EXTENSION_NAME, true); 537 VK_KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_EXTENSION_NAME, true);
@@ -534,6 +546,8 @@ std::vector<const char*> VKDevice::LoadExtensions() {
534 false); 546 false);
535 Test(extension, has_ext_transform_feedback, VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME, 547 Test(extension, has_ext_transform_feedback, VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME,
536 false); 548 false);
549 Test(extension, has_ext_custom_border_color, VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME,
550 false);
537 if (Settings::values.renderer_debug) { 551 if (Settings::values.renderer_debug) {
538 Test(extension, nv_device_diagnostics_config, 552 Test(extension, nv_device_diagnostics_config,
539 VK_NV_DEVICE_DIAGNOSTICS_CONFIG_EXTENSION_NAME, true); 553 VK_NV_DEVICE_DIAGNOSTICS_CONFIG_EXTENSION_NAME, true);
@@ -606,6 +620,19 @@ std::vector<const char*> VKDevice::LoadExtensions() {
606 } 620 }
607 } 621 }
608 622
623 if (has_ext_custom_border_color) {
624 VkPhysicalDeviceCustomBorderColorFeaturesEXT border_features;
625 border_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_FEATURES_EXT;
626 border_features.pNext = nullptr;
627 features.pNext = &border_features;
628 physical.GetFeatures2KHR(features);
629
630 if (border_features.customBorderColors && border_features.customBorderColorWithoutFormat) {
631 extensions.push_back(VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
632 ext_custom_border_color = true;
633 }
634 }
635
609 return extensions; 636 return extensions;
610} 637}
611 638
diff --git a/src/video_core/renderer_vulkan/vk_device.h b/src/video_core/renderer_vulkan/vk_device.h
index c8640762d..ccdf82754 100644
--- a/src/video_core/renderer_vulkan/vk_device.h
+++ b/src/video_core/renderer_vulkan/vk_device.h
@@ -172,6 +172,11 @@ public:
172 return ext_transform_feedback; 172 return ext_transform_feedback;
173 } 173 }
174 174
175 /// Returns true if the device supports VK_EXT_custom_border_color.
176 bool IsExtCustomBorderColorSupported() const {
177 return ext_custom_border_color;
178 }
179
175 /// Returns the vendor name reported from Vulkan. 180 /// Returns the vendor name reported from Vulkan.
176 std::string_view GetVendorName() const { 181 std::string_view GetVendorName() const {
177 return vendor_name; 182 return vendor_name;
@@ -227,6 +232,7 @@ private:
227 bool ext_depth_range_unrestricted{}; ///< Support for VK_EXT_depth_range_unrestricted. 232 bool ext_depth_range_unrestricted{}; ///< Support for VK_EXT_depth_range_unrestricted.
228 bool ext_shader_viewport_index_layer{}; ///< Support for VK_EXT_shader_viewport_index_layer. 233 bool ext_shader_viewport_index_layer{}; ///< Support for VK_EXT_shader_viewport_index_layer.
229 bool ext_transform_feedback{}; ///< Support for VK_EXT_transform_feedback. 234 bool ext_transform_feedback{}; ///< Support for VK_EXT_transform_feedback.
235 bool ext_custom_border_color{}; ///< Support for VK_EXT_custom_border_color.
230 bool nv_device_diagnostics_config{}; ///< Support for VK_NV_device_diagnostics_config. 236 bool nv_device_diagnostics_config{}; ///< Support for VK_NV_device_diagnostics_config.
231 237
232 // Telemetry parameters 238 // Telemetry parameters
diff --git a/src/video_core/renderer_vulkan/vk_sampler_cache.cpp b/src/video_core/renderer_vulkan/vk_sampler_cache.cpp
index 2687d8d95..e6f2fa553 100644
--- a/src/video_core/renderer_vulkan/vk_sampler_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_sampler_cache.cpp
@@ -39,9 +39,18 @@ VKSamplerCache::VKSamplerCache(const VKDevice& device) : device{device} {}
39VKSamplerCache::~VKSamplerCache() = default; 39VKSamplerCache::~VKSamplerCache() = default;
40 40
41vk::Sampler VKSamplerCache::CreateSampler(const Tegra::Texture::TSCEntry& tsc) const { 41vk::Sampler VKSamplerCache::CreateSampler(const Tegra::Texture::TSCEntry& tsc) const {
42 const bool arbitrary_borders = device.IsExtCustomBorderColorSupported();
43 const std::array color = tsc.GetBorderColor();
44
45 VkSamplerCustomBorderColorCreateInfoEXT border;
46 border.sType = VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT;
47 border.pNext = nullptr;
48 border.format = VK_FORMAT_UNDEFINED;
49 std::memcpy(&border.customBorderColor, color.data(), sizeof(color));
50
42 VkSamplerCreateInfo ci; 51 VkSamplerCreateInfo ci;
43 ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; 52 ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
44 ci.pNext = nullptr; 53 ci.pNext = arbitrary_borders ? &border : nullptr;
45 ci.flags = 0; 54 ci.flags = 0;
46 ci.magFilter = MaxwellToVK::Sampler::Filter(tsc.mag_filter); 55 ci.magFilter = MaxwellToVK::Sampler::Filter(tsc.mag_filter);
47 ci.minFilter = MaxwellToVK::Sampler::Filter(tsc.min_filter); 56 ci.minFilter = MaxwellToVK::Sampler::Filter(tsc.min_filter);
@@ -56,7 +65,7 @@ vk::Sampler VKSamplerCache::CreateSampler(const Tegra::Texture::TSCEntry& tsc) c
56 ci.compareOp = MaxwellToVK::Sampler::DepthCompareFunction(tsc.depth_compare_func); 65 ci.compareOp = MaxwellToVK::Sampler::DepthCompareFunction(tsc.depth_compare_func);
57 ci.minLod = tsc.GetMinLod(); 66 ci.minLod = tsc.GetMinLod();
58 ci.maxLod = tsc.GetMaxLod(); 67 ci.maxLod = tsc.GetMaxLod();
59 ci.borderColor = ConvertBorderColor(tsc.GetBorderColor()); 68 ci.borderColor = arbitrary_borders ? VK_BORDER_COLOR_INT_CUSTOM_EXT : ConvertBorderColor(color);
60 ci.unnormalizedCoordinates = VK_FALSE; 69 ci.unnormalizedCoordinates = VK_FALSE;
61 return device.GetLogical().CreateSampler(ci); 70 return device.GetLogical().CreateSampler(ci);
62} 71}