intel / libyami

Yet Another Media Infrastructure. it is core part of media codec with hardware acceleration, it is yummy to your video experience on Linux like platform.
Apache License 2.0
146 stars 106 forks source link

Add support of choosing device for executing #809

Closed AlexanderKomarov closed 6 years ago

AlexanderKomarov commented 6 years ago

libyami doesn't support choosing a device for executing. It uses a default device.

xuguangxin commented 6 years ago

Hi Alexander: Could you explain more your use case? Is intel graphic card not exposed as renderD128 at your env? thanks

AlexanderKomarov commented 6 years ago

Hi xuguangxin, My PC has Nvidia GPU and Intel GPU. Nvidia is exposed as renderD128. Intel GPU is exposed as renderD129.

jsorg71 commented 6 years ago

This is interesting. I run both GPUs together often. I never seen Nvidia create a D128 file. What driver are you using for Nvidia? This is also a problem for libva. The DRM open logic is the same as vainfo. t would be easy enough to use an environment variable.

xuguangxin commented 6 years ago

Hi Jsorg thanks for the information.

Hi Alexander: It may need some efforts to add support for this. To quick work around your problem you can do:

  1. Change NativeDisplayDrm::initialize to D129. Or
  2. If you write your program uses libyami.so only. I suggest you follow the grid application's way thanks
jsorg71 commented 6 years ago

Here is a quick patch if you want to use environment variable.

diff --git a/vaapi/vaapidisplay.cpp b/vaapi/vaapidisplay.cpp
index 0651be1..f9663e7 100644
--- a/vaapi/vaapidisplay.cpp
+++ b/vaapi/vaapidisplay.cpp
@@ -19,6 +19,7 @@
 #endif

 #include "vaapi/vaapidisplay.h"
+#include <stdlib.h>
 #include <stdint.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -130,7 +131,12 @@ class NativeDisplayDrm : public NativeDisplayBase{
         if (acceptValidExternalHandle(display))
             return true;

-        m_handle = open("/dev/dri/renderD128", O_RDWR);
+        m_handle = -1;
+        char* device_env = getenv("VA_DRM_DEVICE");
+        if (device_env)
+            m_handle = open(device_env, O_RDWR);
+        if (m_handle < 0)
+            m_handle = open("/dev/dri/renderD128", O_RDWR);
         if (m_handle < 0)
             m_handle = open("/dev/dri/card0", O_RDWR);
         m_selfCreated = true;
xuguangxin commented 6 years ago

@jsorg71 , you are so fast. :) thanks for the patch, you can consider submit.

jsorg71 commented 6 years ago

Not fast, just had this one laying around. I create #811 for this.

AlexanderKomarov commented 6 years ago

Hi @jsorg71 I use a driver from repo. Thanks for helping. I will try to use it.