Skip to content

Commit

Permalink
INTERNAL: Sort the render devices before open
Browse files Browse the repository at this point in the history
The render devices Mesa get is disorder, sometimes open the
dGPU render node which cause the video playback garbage.

Tracked-On: OAM-112246
Signed-off-by: HeYue <[email protected]>
Signed-off-by: Fei Jiang [email protected]
  • Loading branch information
yhe39 authored and buildslave committed Sep 26, 2023
1 parent 195ae6c commit bfd7541
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/egl/drivers/dri2/platform_android.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ is_yuv(int native)
return false;
}

static int compare_devices(const void *a, const void *b) {
   const drmDevicePtr device_a = *(const drmDevicePtr *)a;
   const drmDevicePtr device_b = *(const drmDevicePtr *)b;
char *name_a = device_a->nodes[DRM_NODE_RENDER];
char *name_b = device_b->nodes[DRM_NODE_RENDER];
   int num_a = atoi(name_a + 16); // skip "/dev/dri/renderD" prefix
   int num_b = atoi(name_b + 16);
   return num_a - num_b;
}

static int
get_format_bpp(int native)
{
Expand Down Expand Up @@ -1742,6 +1752,8 @@ droid_open_device(_EGLDisplay *disp, bool swrast)
if (num_devices < 0)
return EGL_FALSE;

qsort(devices, num_devices, sizeof(drmDevicePtr), compare_devices);

for (int i = 0; i < num_devices; i++) {
device = devices[i];

Expand Down

0 comments on commit bfd7541

Please sign in to comment.