mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 22:06:59 +01:00
vulkan: start without fragmentShaderBarycentric on GPUs that lack it (#1590)
* vulkan: start without fragmentShaderBarycentric on GPUs that lack it Pascal (GTX 10xx), RDNA 1 and older drivers have no VK_KHR_fragment_shader_barycentric, so device selection rejected them with 'Could not find suitable device' (#1432, #1416, #762). The SPIR-V backend only emits the capability for pixel shaders with per-vertex/barycentric inputs, so make the extension and feature optional: warn at selection and creation, enable only when supported. Shaders that need custom barycentrics fail at pipeline creation instead of blocking startup for every game. * vulkan: fix macOS build and warn about unsupported GPUs --------- Co-authored-by: Matthew Hurley <171001439+theantipopau@users.noreply.github.com> Co-authored-by: nmzik <Nmzik@mail.ru>
This commit is contained in:
@@ -266,7 +266,6 @@ static void VulkanFindPhysicalDevice(vk::Instance instance, vk::SurfaceKHR surfa
|
|||||||
#endif
|
#endif
|
||||||
#if !defined(__APPLE__)
|
#if !defined(__APPLE__)
|
||||||
check_feature(device_features2.features.depthClamp, "depthClamp");
|
check_feature(device_features2.features.depthClamp, "depthClamp");
|
||||||
check_feature(fragment_barycentric.fragmentShaderBarycentric, "fragmentShaderBarycentric");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
check_feature(features12.samplerMirrorClampToEdge, "samplerMirrorClampToEdge",
|
check_feature(features12.samplerMirrorClampToEdge, "samplerMirrorClampToEdge",
|
||||||
@@ -498,7 +497,21 @@ static vk::Device VulkanCreateDevice(GraphicContext& graphics,
|
|||||||
image_atomic_int64.pNext = supported_features2.pNext;
|
image_atomic_int64.pNext = supported_features2.pNext;
|
||||||
supported_features2.pNext = &image_atomic_int64;
|
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);
|
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;
|
graphics.shader_image_int64_atomics_enabled = image_atomic_int64.shaderImageInt64Atomics;
|
||||||
|
|
||||||
auto features12 = WindowContext::RequiredVulkan12Features();
|
auto features12 = WindowContext::RequiredVulkan12Features();
|
||||||
@@ -610,9 +623,13 @@ static vk::Device VulkanCreateDevice(GraphicContext& graphics,
|
|||||||
robustness2.pNext = &features12;
|
robustness2.pNext = &features12;
|
||||||
#else
|
#else
|
||||||
vk::PhysicalDeviceFragmentShaderBarycentricFeaturesKHR fragment_barycentric {};
|
vk::PhysicalDeviceFragmentShaderBarycentricFeaturesKHR fragment_barycentric {};
|
||||||
fragment_barycentric.pNext = &features12;
|
if (barycentric_supported) {
|
||||||
fragment_barycentric.fragmentShaderBarycentric = VK_TRUE;
|
fragment_barycentric.pNext = &features12;
|
||||||
robustness2.pNext = &fragment_barycentric;
|
fragment_barycentric.fragmentShaderBarycentric = VK_TRUE;
|
||||||
|
robustness2.pNext = &fragment_barycentric;
|
||||||
|
} else {
|
||||||
|
robustness2.pNext = &features12;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
robustness2.robustBufferAccess2 = supported_robustness2.robustBufferAccess2;
|
robustness2.robustBufferAccess2 = supported_robustness2.robustBufferAccess2;
|
||||||
robustness2.robustImageAccess2 = supported_robustness2.robustImageAccess2;
|
robustness2.robustImageAccess2 = supported_robustness2.robustImageAccess2;
|
||||||
@@ -966,7 +983,6 @@ void WindowContext::CreateVulkan() {
|
|||||||
#else
|
#else
|
||||||
device_extensions.push_back(VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME);
|
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_EXT_COLOR_WRITE_ENABLE_EXTENSION_NAME);
|
||||||
device_extensions.push_back(VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef KYTY_ENABLE_DEBUG_PRINTF
|
#ifdef KYTY_ENABLE_DEBUG_PRINTF
|
||||||
@@ -1024,7 +1040,8 @@ void WindowContext::CreateVulkan() {
|
|||||||
VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME,
|
VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME,
|
||||||
VK_EXT_MESH_SHADER_EXTENSION_NAME,
|
VK_EXT_MESH_SHADER_EXTENSION_NAME,
|
||||||
VK_KHR_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_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)) {
|
if (HasExtension(available_extensions, extension)) {
|
||||||
device_extensions.push_back(extension);
|
device_extensions.push_back(extension);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user