Skip to content

Graphics locality support (OpenGL, Vulkan, anything else?) #776

Description

@bgoglin

GL support must be disabled in some cases to avoid hangs (#517). It's not clear if it's still useful, we may remove that backend at some point.

If somebody cares about GPU locality, we'll need to look at the API they use and find something better than the current GL implementation.

Last time I checked, Vulkan had vkGetPhysicalDeviceProperties2() but it didn't work. Sample code below.

#include <vulkan/vulkan.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
  VkInstanceCreateInfo instanceCreateInfo = {
    VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
    NULL,
    0, NULL,
    0, NULL,
    0, NULL,
  };
  VkInstance inst;
  VkPhysicalDevice *phys;
  uint32_t n, i, j;

  vkCreateInstance(&instanceCreateInfo, NULL, &inst);

  n = 0;
  vkEnumeratePhysicalDevices(inst, &n, NULL);
  printf("found %u devices\n", n);

  if (!n)
    goto out;

  phys = malloc(n *sizeof(*phys));
  if (!phys)
    goto out;
  vkEnumeratePhysicalDevices(inst, &n, phys);

  for(i=0; i<n; i++) {
    VkPhysicalDeviceProperties prop;
    vkGetPhysicalDeviceProperties(phys[i], &prop);
    printf("type %d vendor %x device %x name %s uuid ", prop.deviceType, prop.vendorID, prop.deviceID, prop.deviceName);
    for(j=0; j<VK_UUID_SIZE; j++)
      printf("%hhx", prop.pipelineCacheUUID[j]);
    printf("\n");
  }

  for(i=0; i<n; i++) {
    VkPhysicalDevicePCIBusInfoPropertiesEXT bi = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT};
    VkPhysicalDeviceProperties2 prop = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, &bi};
    vkGetPhysicalDeviceProperties2(phys[i], &prop);
    printf("%04x:%02x:%02x.%01x\n", bi.pciDomain, bi.pciBus, bi.pciDevice, bi.pciFunction);
  }

 out:
  vkDestroyInstance(inst, NULL);
  return 0;
}

gives this on my Intel integrated GPU (00:02.) laptop:

found 2 devices
type 1 vendor 8086 device a720 name Intel(R) Graphics (RPL-P) uuid 8bf51fcf98bd478f5e2c69bcd82a1b30
type 4 vendor 10005 device 0 name llvmpipe (LLVM 21.1.8, 256 bits) uuid 32362e302e362d316161616161616161
0000:00:00.0
0000:00:00.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions