diff --git a/src/graphics/presentation/window/vulkanWindow.cpp b/src/graphics/presentation/window/vulkanWindow.cpp index 9b6f2d6a6..81ddaf50f 100644 --- a/src/graphics/presentation/window/vulkanWindow.cpp +++ b/src/graphics/presentation/window/vulkanWindow.cpp @@ -266,7 +266,6 @@ static void VulkanFindPhysicalDevice(vk::Instance instance, vk::SurfaceKHR surfa #endif #if !defined(__APPLE__) check_feature(device_features2.features.depthClamp, "depthClamp"); - check_feature(fragment_barycentric.fragmentShaderBarycentric, "fragmentShaderBarycentric"); #endif check_feature(features12.samplerMirrorClampToEdge, "samplerMirrorClampToEdge", @@ -498,7 +497,21 @@ static vk::Device VulkanCreateDevice(GraphicContext& graphics, image_atomic_int64.pNext = supported_features2.pNext; supported_features2.pNext = &image_atomic_int64; } + const bool barycentric_extension = + HasExtension(device_extensions, VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME); + vk::PhysicalDeviceFragmentShaderBarycentricFeaturesKHR supported_barycentric {}; + if (barycentric_extension) { + supported_barycentric.pNext = supported_features2.pNext; + supported_features2.pNext = &supported_barycentric; + } physical_device.getFeatures2(&supported_features2); + const bool barycentric_supported = + barycentric_extension && supported_barycentric.fragmentShaderBarycentric == VK_TRUE; + if (!barycentric_supported) { + Log::WriteToConsoleAndLog( + "WARNING: Your GPU is not fully supported (fragmentShaderBarycentric is unavailable). " + "Some games may render incorrectly or crash.\n"); + } graphics.shader_image_int64_atomics_enabled = image_atomic_int64.shaderImageInt64Atomics; auto features12 = WindowContext::RequiredVulkan12Features(); @@ -610,9 +623,13 @@ static vk::Device VulkanCreateDevice(GraphicContext& graphics, robustness2.pNext = &features12; #else vk::PhysicalDeviceFragmentShaderBarycentricFeaturesKHR fragment_barycentric {}; - fragment_barycentric.pNext = &features12; - fragment_barycentric.fragmentShaderBarycentric = VK_TRUE; - robustness2.pNext = &fragment_barycentric; + if (barycentric_supported) { + fragment_barycentric.pNext = &features12; + fragment_barycentric.fragmentShaderBarycentric = VK_TRUE; + robustness2.pNext = &fragment_barycentric; + } else { + robustness2.pNext = &features12; + } #endif robustness2.robustBufferAccess2 = supported_robustness2.robustBufferAccess2; robustness2.robustImageAccess2 = supported_robustness2.robustImageAccess2; @@ -966,7 +983,6 @@ void WindowContext::CreateVulkan() { #else device_extensions.push_back(VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME); device_extensions.push_back(VK_EXT_COLOR_WRITE_ENABLE_EXTENSION_NAME); - device_extensions.push_back(VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME); #endif #ifdef KYTY_ENABLE_DEBUG_PRINTF @@ -1024,7 +1040,8 @@ void WindowContext::CreateVulkan() { VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME, VK_EXT_MESH_SHADER_EXTENSION_NAME, VK_KHR_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_EXTENSION_NAME, - VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME}) { + VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME, + VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME}) { if (HasExtension(available_extensions, extension)) { device_extensions.push_back(extension); }