102f4aeb0Sopenharmony_ciName 202f4aeb0Sopenharmony_ci 302f4aeb0Sopenharmony_ci EXT_device_persistent_id 402f4aeb0Sopenharmony_ci 502f4aeb0Sopenharmony_ciName Strings 602f4aeb0Sopenharmony_ci 702f4aeb0Sopenharmony_ci EGL_EXT_device_persistent_id 802f4aeb0Sopenharmony_ci 902f4aeb0Sopenharmony_ciContributors 1002f4aeb0Sopenharmony_ci 1102f4aeb0Sopenharmony_ci Kyle Brenneman, NVIDIA (kbrenneman 'at' nvidia.com) 1202f4aeb0Sopenharmony_ci 1302f4aeb0Sopenharmony_ciContact 1402f4aeb0Sopenharmony_ci 1502f4aeb0Sopenharmony_ci Kyle Brenneman, NVIDIA (kbrenneman 'at' nvidia.com) 1602f4aeb0Sopenharmony_ci 1702f4aeb0Sopenharmony_ciVersion 1802f4aeb0Sopenharmony_ci 1902f4aeb0Sopenharmony_ci Version 1 - April 19, 2021 2002f4aeb0Sopenharmony_ci 2102f4aeb0Sopenharmony_ciNumber 2202f4aeb0Sopenharmony_ci 2302f4aeb0Sopenharmony_ci EGL Extension #142 2402f4aeb0Sopenharmony_ci 2502f4aeb0Sopenharmony_ciExtension Type 2602f4aeb0Sopenharmony_ci 2702f4aeb0Sopenharmony_ci EGL device extension 2802f4aeb0Sopenharmony_ci 2902f4aeb0Sopenharmony_ciDependencies 3002f4aeb0Sopenharmony_ci 3102f4aeb0Sopenharmony_ci Written based on the wording of the EGL 1.5 specification. 3202f4aeb0Sopenharmony_ci 3302f4aeb0Sopenharmony_ci EGL_EXT_device_query is required. 3402f4aeb0Sopenharmony_ci 3502f4aeb0Sopenharmony_ciOverview 3602f4aeb0Sopenharmony_ci 3702f4aeb0Sopenharmony_ci Applications can query a list of EGLDeviceEXT handles, but those 3802f4aeb0Sopenharmony_ci handles are only valid within the process that queried them. An 3902f4aeb0Sopenharmony_ci application has no way, for example, to record its selection and 4002f4aeb0Sopenharmony_ci select the same device when run again later. 4102f4aeb0Sopenharmony_ci 4202f4aeb0Sopenharmony_ci This extension provides a vendor name and a set of UUID's, which 4302f4aeb0Sopenharmony_ci provide a unique, persistent identifier for EGLDeviceEXT handles. 4402f4aeb0Sopenharmony_ci This allows applications to find the EGLDeviceEXT for the same 4502f4aeb0Sopenharmony_ci device across multiple processes, and across multiple APIs. 4602f4aeb0Sopenharmony_ci 4702f4aeb0Sopenharmony_ciNew Procedures and Functions 4802f4aeb0Sopenharmony_ci 4902f4aeb0Sopenharmony_ci EGLBoolean eglQueryDeviceBinaryEXT(EGLDeviceEXT device, 5002f4aeb0Sopenharmony_ci EGLint name, 5102f4aeb0Sopenharmony_ci EGLint max_size, 5202f4aeb0Sopenharmony_ci void *value, 5302f4aeb0Sopenharmony_ci EGLint *size); 5402f4aeb0Sopenharmony_ci 5502f4aeb0Sopenharmony_ciNew Tokens 5602f4aeb0Sopenharmony_ci 5702f4aeb0Sopenharmony_ci Accepted by the <name> parameter of eglQueryDeviceStringEXT: 5802f4aeb0Sopenharmony_ci 5902f4aeb0Sopenharmony_ci EGL_DRIVER_NAME_EXT 0x335E 6002f4aeb0Sopenharmony_ci 6102f4aeb0Sopenharmony_ci Accepted by the <name> parameter of eglQueryDeviceBinaryEXT: 6202f4aeb0Sopenharmony_ci 6302f4aeb0Sopenharmony_ci EGL_DEVICE_UUID_EXT 0x335C 6402f4aeb0Sopenharmony_ci EGL_DRIVER_UUID_EXT 0x335D 6502f4aeb0Sopenharmony_ci 6602f4aeb0Sopenharmony_ciChanges to section 3.2 (Devices) 6702f4aeb0Sopenharmony_ci 6802f4aeb0Sopenharmony_ci Add the following paragraph to the description of 6902f4aeb0Sopenharmony_ci eglQueryDeviceStringEXT: 7002f4aeb0Sopenharmony_ci 7102f4aeb0Sopenharmony_ci EGL_DRIVER_NAME_EXT returns a string which identifies the driver 7202f4aeb0Sopenharmony_ci that controls the device. This string remains persistent across 7302f4aeb0Sopenharmony_ci multiple versions of a driver, and an application can use strcmp(3) 7402f4aeb0Sopenharmony_ci to compare the strings for equality. Otherwise, the contents are 7502f4aeb0Sopenharmony_ci implementation-defined. 7602f4aeb0Sopenharmony_ci 7702f4aeb0Sopenharmony_ci 7802f4aeb0Sopenharmony_ci Add to the end of section 3.2: 7902f4aeb0Sopenharmony_ci 8002f4aeb0Sopenharmony_ci To query a binary attribute for a device, use: 8102f4aeb0Sopenharmony_ci 8202f4aeb0Sopenharmony_ci EGLBoolean eglQueryDeviceBinaryEXT(EGLDeviceEXT device, 8302f4aeb0Sopenharmony_ci EGLint name, 8402f4aeb0Sopenharmony_ci EGLint max_size, 8502f4aeb0Sopenharmony_ci void *value, 8602f4aeb0Sopenharmony_ci EGLint *size); 8702f4aeb0Sopenharmony_ci 8802f4aeb0Sopenharmony_ci On success, EGL_TRUE is returned. If <value> is NULL, then 8902f4aeb0Sopenharmony_ci <max_size> is ignored, and the size of the attribute in bytes is 9002f4aeb0Sopenharmony_ci returned in <size>. 9102f4aeb0Sopenharmony_ci 9202f4aeb0Sopenharmony_ci On failure, EGL_FALSE is returned. An EGL_BAD_ATTRIBUTE error is 9302f4aeb0Sopenharmony_ci generated if <name> is not a valid attribute. An EGL_BAD_DEVICE_EXT 9402f4aeb0Sopenharmony_ci error is generated if <device> is not a valid EGLDeviceEXT. 9502f4aeb0Sopenharmony_ci 9602f4aeb0Sopenharmony_ci If <value> is not NULL, then the attribute value is returned in 9702f4aeb0Sopenharmony_ci <value>. At most <max_size> bytes are written. <size> returns the 9802f4aeb0Sopenharmony_ci number of bytes that were actually written. 9902f4aeb0Sopenharmony_ci 10002f4aeb0Sopenharmony_ci Note that the EGL_DEVICE_UUID_EXT and EGL_DRIVER_UUID_EXT attributes 10102f4aeb0Sopenharmony_ci are always 16-byte values, and so the application can simply use a 10202f4aeb0Sopenharmony_ci 16-byte buffer without needing to query the size beforehand. Future 10302f4aeb0Sopenharmony_ci extensions may add variable-length attributes. 10402f4aeb0Sopenharmony_ci 10502f4aeb0Sopenharmony_ci 10602f4aeb0Sopenharmony_ci EGL_DEVICE_UUID_EXT is a UUID that identifies a physical device, 10702f4aeb0Sopenharmony_ci returned as a 16-byte binary value. The device UUID uniquely 10802f4aeb0Sopenharmony_ci identifies a physical device, and is persistent across reboots, 10902f4aeb0Sopenharmony_ci processes, APIs, and (to the extent possible) driver versions. 11002f4aeb0Sopenharmony_ci 11102f4aeb0Sopenharmony_ci EGL_DEVICE_UUID_EXT may or may not be persistent across changes in 11202f4aeb0Sopenharmony_ci hardware configuration. Similarly, it is not guaranteed to be unique 11302f4aeb0Sopenharmony_ci or persistent across different (physical or virtual) computers. 11402f4aeb0Sopenharmony_ci 11502f4aeb0Sopenharmony_ci Note that EGL_DEVICE_UUID_EXT alone is not guaranteed to be unique 11602f4aeb0Sopenharmony_ci across all EGLDeviceEXT handles. If an EGL implementation supports 11702f4aeb0Sopenharmony_ci multiple drivers, and two drivers can use the same physical device, 11802f4aeb0Sopenharmony_ci then there will be a separate EGLDeviceEXT handle from each driver. 11902f4aeb0Sopenharmony_ci Both EGLDeviceEXT handles may use the same device UUID. 12002f4aeb0Sopenharmony_ci 12102f4aeb0Sopenharmony_ci In that case, an application must use EGL_DRIVER_NAME_EXT or 12202f4aeb0Sopenharmony_ci EGL_DRIVER_UUID_EXT to distinguish between the two EGLDeviceEXT 12302f4aeb0Sopenharmony_ci handles. 12402f4aeb0Sopenharmony_ci 12502f4aeb0Sopenharmony_ci 12602f4aeb0Sopenharmony_ci EGL_DRIVER_UUID_EXT is a UUID that identifies a driver build 12702f4aeb0Sopenharmony_ci in use for a device. The driver UUID is persistent across reboots, 12802f4aeb0Sopenharmony_ci processes, and APIs, but is not persistent across driver versions. 12902f4aeb0Sopenharmony_ci 13002f4aeb0Sopenharmony_ciIssues 13102f4aeb0Sopenharmony_ci 13202f4aeb0Sopenharmony_ci 1. Should we use UUID's or strings to identify devices? 13302f4aeb0Sopenharmony_ci 13402f4aeb0Sopenharmony_ci RESOLVED: Use UUID's for devices, plus a vendor name string to 13502f4aeb0Sopenharmony_ci disambiguate devices that are supported by multiple drivers. 13602f4aeb0Sopenharmony_ci 13702f4aeb0Sopenharmony_ci A device UUID and driver UUID allow an application to correlate 13802f4aeb0Sopenharmony_ci an EGLDeviceEXT with the same device in other APIs, such as a 13902f4aeb0Sopenharmony_ci VkPhysicalDevice in Vulkan. 14002f4aeb0Sopenharmony_ci 14102f4aeb0Sopenharmony_ci A UUID does not impose any additional requirements on an EGL 14202f4aeb0Sopenharmony_ci implementation compared to a string: If an EGL implementation 14302f4aeb0Sopenharmony_ci could generate a string identifier, then the implementation can 14402f4aeb0Sopenharmony_ci simply hash that string to generate a UUID value. 14502f4aeb0Sopenharmony_ci 14602f4aeb0Sopenharmony_ci 2. Can two EGLDeviceEXT handles have the same EGL_DEVICE_UUID_EXT? 14702f4aeb0Sopenharmony_ci 14802f4aeb0Sopenharmony_ci RESOLVED: Yes, if they correspond to the same physical device. 14902f4aeb0Sopenharmony_ci 15002f4aeb0Sopenharmony_ci The semantics of the device and driver UUID's are inherited from 15102f4aeb0Sopenharmony_ci Vulkan, which only requires that a device UUID be unique to a 15202f4aeb0Sopenharmony_ci physical device, not unique across VkPhysicalDevice handles. 15302f4aeb0Sopenharmony_ci 15402f4aeb0Sopenharmony_ci 3. Do we need the EGL_DRIVER_NAME_EXT string? 15502f4aeb0Sopenharmony_ci 15602f4aeb0Sopenharmony_ci RESOLVED: Yes, because the EGL_DEVICE_UUID_EXT alone is not 15702f4aeb0Sopenharmony_ci unique, and EGL_DRIVER_UUID_EXT is not persistent. 15802f4aeb0Sopenharmony_ci 15902f4aeb0Sopenharmony_ci A (EGL_DRIVER_NAME_EXT, EGL_DEVICE_UUID_EXT) pair provides a 16002f4aeb0Sopenharmony_ci unique, persistent identifier. 16102f4aeb0Sopenharmony_ci 16202f4aeb0Sopenharmony_ci In addition, on systems that use libglvnd, applications could 16302f4aeb0Sopenharmony_ci use EGL_DRIVER_NAME_EXT to match the vendor names from 16402f4aeb0Sopenharmony_ci GLX_EXT_libglvnd. 16502f4aeb0Sopenharmony_ci 16602f4aeb0Sopenharmony_ci 4. What happens if an application stores a device UUID, and the 16702f4aeb0Sopenharmony_ci hardware configuration or driver version changes? 16802f4aeb0Sopenharmony_ci 16902f4aeb0Sopenharmony_ci RESOLVED: The device UUID may become invalid, and the 17002f4aeb0Sopenharmony_ci application should select a new device. 17102f4aeb0Sopenharmony_ci 17202f4aeb0Sopenharmony_ci If a device is removed from a system, then there will be no 17302f4aeb0Sopenharmony_ci EGLDeviceEXT handle for it, and thus no device UUID for it. 17402f4aeb0Sopenharmony_ci 17502f4aeb0Sopenharmony_ci Similarly, if a device is moved within a system (e.g., plugged 17602f4aeb0Sopenharmony_ci into a different PCI slot), then a driver may not be able to 17702f4aeb0Sopenharmony_ci identify it as the same device, and so the device might get a 17802f4aeb0Sopenharmony_ci different UUID. 17902f4aeb0Sopenharmony_ci 18002f4aeb0Sopenharmony_ci While not a requirement, drivers should still try to keep device 18102f4aeb0Sopenharmony_ci UUID's persistent whenever possible, to avoid invalidating 18202f4aeb0Sopenharmony_ci config files. Similarly, if a device is removed or replaced, 18302f4aeb0Sopenharmony_ci then a driver should try to ensure that the same device UUID 18402f4aeb0Sopenharmony_ci does not refer to a different device. 18502f4aeb0Sopenharmony_ci 18602f4aeb0Sopenharmony_ci As an example, a driver could derive a UUID based on a PCI 18702f4aeb0Sopenharmony_ci vendor and device number, plus the PCI domain, bus, slot, and 18802f4aeb0Sopenharmony_ci function numbers: 18902f4aeb0Sopenharmony_ci 19002f4aeb0Sopenharmony_ci * The PCI device number ensures that replacing a GPU with a 19102f4aeb0Sopenharmony_ci different model in the same PCI slot produces a different 19202f4aeb0Sopenharmony_ci device UUID string. 19302f4aeb0Sopenharmony_ci * Using the PCI bus numbers ensures that two identical 19402f4aeb0Sopenharmony_ci GPU's in the same system have unique UUID's. 19502f4aeb0Sopenharmony_ci * The whole tuple can easily stay persistent across driver 19602f4aeb0Sopenharmony_ci versions. 19702f4aeb0Sopenharmony_ci 19802f4aeb0Sopenharmony_ciRevision History 19902f4aeb0Sopenharmony_ci 20002f4aeb0Sopenharmony_ci #1 (April 19, 2021) Kyle Brenneman 20102f4aeb0Sopenharmony_ci 20202f4aeb0Sopenharmony_ci - Initial draft 203