mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 18:35:34 +00:00
internal/vk: ignore software Vulkan implementations
It's better to fall back on OpenGL than to accept a software Vulkan implementation. More importantly, some software implementations such as lavapipe doesn't even work[0]. [0] https://gitlab.freedesktop.org/mesa/mesa/-/issues/5473 Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -327,6 +327,10 @@ static VkResult vkResetFences(PFN_vkResetFences f, VkDevice device, uint32_t fen
|
|||||||
return f(device, fenceCount, pFences);
|
return f(device, fenceCount, pFences);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void vkGetPhysicalDeviceProperties(PFN_vkGetPhysicalDeviceProperties f, VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties *pProperties) {
|
||||||
|
f(physicalDevice, pProperties);
|
||||||
|
}
|
||||||
|
|
||||||
static VkResult vkGetPhysicalDeviceSurfaceSupportKHR(PFN_vkGetPhysicalDeviceSurfaceSupportKHR f, VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32 *pSupported) {
|
static VkResult vkGetPhysicalDeviceSurfaceSupportKHR(PFN_vkGetPhysicalDeviceSurfaceSupportKHR f, VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32 *pSupported) {
|
||||||
return f(physicalDevice, queueFamilyIndex, surface, pSupported);
|
return f(physicalDevice, queueFamilyIndex, surface, pSupported);
|
||||||
}
|
}
|
||||||
@@ -654,6 +658,7 @@ var funcs struct {
|
|||||||
vkDestroyFence C.PFN_vkDestroyFence
|
vkDestroyFence C.PFN_vkDestroyFence
|
||||||
vkWaitForFences C.PFN_vkWaitForFences
|
vkWaitForFences C.PFN_vkWaitForFences
|
||||||
vkResetFences C.PFN_vkResetFences
|
vkResetFences C.PFN_vkResetFences
|
||||||
|
vkGetPhysicalDeviceProperties C.PFN_vkGetPhysicalDeviceProperties
|
||||||
|
|
||||||
vkGetPhysicalDeviceSurfaceSupportKHR C.PFN_vkGetPhysicalDeviceSurfaceSupportKHR
|
vkGetPhysicalDeviceSurfaceSupportKHR C.PFN_vkGetPhysicalDeviceSurfaceSupportKHR
|
||||||
vkDestroySurfaceKHR C.PFN_vkDestroySurfaceKHR
|
vkDestroySurfaceKHR C.PFN_vkDestroySurfaceKHR
|
||||||
@@ -793,6 +798,7 @@ func vkInit() error {
|
|||||||
funcs.vkDestroyFence = must("vkDestroyFence")
|
funcs.vkDestroyFence = must("vkDestroyFence")
|
||||||
funcs.vkWaitForFences = must("vkWaitForFences")
|
funcs.vkWaitForFences = must("vkWaitForFences")
|
||||||
funcs.vkResetFences = must("vkResetFences")
|
funcs.vkResetFences = must("vkResetFences")
|
||||||
|
funcs.vkGetPhysicalDeviceProperties = must("vkGetPhysicalDeviceProperties")
|
||||||
|
|
||||||
funcs.vkGetPhysicalDeviceSurfaceSupportKHR = dlopen("vkGetPhysicalDeviceSurfaceSupportKHR")
|
funcs.vkGetPhysicalDeviceSurfaceSupportKHR = dlopen("vkGetPhysicalDeviceSurfaceSupportKHR")
|
||||||
funcs.vkDestroySurfaceKHR = dlopen("vkDestroySurfaceKHR")
|
funcs.vkDestroySurfaceKHR = dlopen("vkDestroySurfaceKHR")
|
||||||
@@ -884,6 +890,12 @@ func ChoosePhysicalDevice(inst Instance, surf Surface) (PhysicalDevice, int, err
|
|||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
for _, pd := range devs {
|
for _, pd := range devs {
|
||||||
|
var props C.VkPhysicalDeviceProperties
|
||||||
|
C.vkGetPhysicalDeviceProperties(funcs.vkGetPhysicalDeviceProperties, pd, &props)
|
||||||
|
// Skip software implementations such as lavapipe.
|
||||||
|
if props.deviceType == C.VK_PHYSICAL_DEVICE_TYPE_CPU {
|
||||||
|
continue
|
||||||
|
}
|
||||||
const caps = C.VK_QUEUE_GRAPHICS_BIT | C.VK_QUEUE_COMPUTE_BIT
|
const caps = C.VK_QUEUE_GRAPHICS_BIT | C.VK_QUEUE_COMPUTE_BIT
|
||||||
queueIdx, ok, err := chooseQueue(pd, surf, caps)
|
queueIdx, ok, err := chooseQueue(pd, surf, caps)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user