Add option to select render device for VAAPI
This commit is contained in:
+20
-2
@@ -118,7 +118,11 @@
|
|||||||
# output_name = \\.\DISPLAY1
|
# output_name = \\.\DISPLAY1
|
||||||
|
|
||||||
# !! Linux only !!
|
# !! Linux only !!
|
||||||
# Set the display number to stream. I have no idea how they are numbered. They start from 0, usually.
|
# Set the display number to stream.
|
||||||
|
# You can find them by the following command:
|
||||||
|
# xrandr --listmonitors
|
||||||
|
# Example output: "0: +HDMI-1 1920/518x1200/324+0+0 HDMI-1"
|
||||||
|
# ^ <-- You need this.
|
||||||
# output_name = 0
|
# output_name = 0
|
||||||
|
|
||||||
###############################################
|
###############################################
|
||||||
@@ -222,6 +226,19 @@
|
|||||||
##########################
|
##########################
|
||||||
# amd_coder = auto
|
# amd_coder = auto
|
||||||
|
|
||||||
|
#################################### VAAPI ###################################
|
||||||
|
####### adapter ##########
|
||||||
|
# Unlike with `amfvce` and `nvenc`, it doesn't matter if video encoding is done
|
||||||
|
# on a different GPU.
|
||||||
|
# Run the following commands:
|
||||||
|
# 1. ls /dev/dri/renderD*
|
||||||
|
# to find all devices capable of VAAPI
|
||||||
|
# 2. vainfo --display drm --device /dev/dri/renderD129 | grep -E "((VAProfileH264High|VAProfileHEVCMain|VAProfileHEVCMain10).*VAEntrypointEncSlice)|Driver version"
|
||||||
|
# Lists the name and capabilities of the device.
|
||||||
|
# To be supported by Sunshine, it needs to have at the very minimum:
|
||||||
|
# VAProfileH264High : VAEntrypointEncSlice
|
||||||
|
# adapter_name = /dev/dri/renderD128
|
||||||
|
|
||||||
##############################################
|
##############################################
|
||||||
# Some configurable parameters, are merely toggles for specific features
|
# Some configurable parameters, are merely toggles for specific features
|
||||||
# The first occurrence turns it on, the second occurence turns it off, the third occurence turns it on again, etc, etc
|
# The first occurrence turns it on, the second occurence turns it off, the third occurence turns it on again, etc, etc
|
||||||
@@ -230,4 +247,5 @@
|
|||||||
# To set the initial state of flags -0 and -1 to on, set the following flags:
|
# To set the initial state of flags -0 and -1 to on, set the following flags:
|
||||||
# flags = 01
|
# flags = 01
|
||||||
#
|
#
|
||||||
# See: sunshine --help for all options under the header: flags
|
# See: sunshine --help for all options under the header: flags
|
||||||
|
adapter_name = /dev/dri/renderD129
|
||||||
@@ -15,6 +15,7 @@ extern "C" {
|
|||||||
#include <libavutil/hwcontext_vaapi.h>
|
#include <libavutil/hwcontext_vaapi.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "sunshine/config.h"
|
||||||
#include "sunshine/main.h"
|
#include "sunshine/main.h"
|
||||||
#include "sunshine/platform/common.h"
|
#include "sunshine/platform/common.h"
|
||||||
#include "sunshine/utility.h"
|
#include "sunshine/utility.h"
|
||||||
@@ -347,7 +348,6 @@ private:
|
|||||||
|
|
||||||
namespace platf {
|
namespace platf {
|
||||||
namespace egl {
|
namespace egl {
|
||||||
auto constexpr render_device = "/dev/dri/renderD129";
|
|
||||||
|
|
||||||
constexpr auto EGL_LINUX_DMA_BUF_EXT = 0x3270;
|
constexpr auto EGL_LINUX_DMA_BUF_EXT = 0x3270;
|
||||||
constexpr auto EGL_LINUX_DRM_FOURCC_EXT = 0x3271;
|
constexpr auto EGL_LINUX_DRM_FOURCC_EXT = 0x3271;
|
||||||
@@ -794,7 +794,9 @@ int vaapi_make_hwdevice_ctx(platf::hwdevice_t *base, AVBufferRef **hw_device_buf
|
|||||||
|
|
||||||
va::display_t display { vaGetDisplayDRM(egl->file.el) };
|
va::display_t display { vaGetDisplayDRM(egl->file.el) };
|
||||||
if(!display) {
|
if(!display) {
|
||||||
BOOST_LOG(error) << "Couldn't open a va display from DRM with device: "sv << platf::egl::render_device;
|
auto render_device = config::video.adapter_name.empty() ? "/dev/dri/renderD128" : config::video.adapter_name.c_str();
|
||||||
|
|
||||||
|
BOOST_LOG(error) << "Couldn't open a va display from DRM with device: "sv << render_device;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -832,6 +834,7 @@ int vaapi_make_hwdevice_ctx(platf::hwdevice_t *base, AVBufferRef **hw_device_buf
|
|||||||
std::shared_ptr<platf::hwdevice_t> make_hwdevice() {
|
std::shared_ptr<platf::hwdevice_t> make_hwdevice() {
|
||||||
auto egl = std::make_shared<egl_t>();
|
auto egl = std::make_shared<egl_t>();
|
||||||
|
|
||||||
|
auto render_device = config::video.adapter_name.empty() ? "/dev/dri/renderD128" : config::video.adapter_name.c_str();
|
||||||
if(egl->init(render_device)) {
|
if(egl->init(render_device)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -1486,7 +1486,9 @@ util::Either<buffer_t, int> vaapi_make_hwdevice_ctx(platf::hwdevice_t *base) {
|
|||||||
return hw_device_buf;
|
return hw_device_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto status = av_hwdevice_ctx_create(&hw_device_buf, AV_HWDEVICE_TYPE_VAAPI, "/dev/dri/renderD129", nullptr, 0);
|
auto render_device = config::video.adapter_name.empty() ? nullptr : config::video.adapter_name.c_str();
|
||||||
|
|
||||||
|
auto status = av_hwdevice_ctx_create(&hw_device_buf, AV_HWDEVICE_TYPE_VAAPI, render_device, nullptr, 0);
|
||||||
if(status < 0) {
|
if(status < 0) {
|
||||||
char string[AV_ERROR_MAX_STRING_SIZE];
|
char string[AV_ERROR_MAX_STRING_SIZE];
|
||||||
BOOST_LOG(error) << "Failed to create a VAAPI device: "sv << av_make_error_string(string, AV_ERROR_MAX_STRING_SIZE, status);
|
BOOST_LOG(error) << "Failed to create a VAAPI device: "sv << av_make_error_string(string, AV_ERROR_MAX_STRING_SIZE, status);
|
||||||
|
|||||||
Reference in New Issue
Block a user