Fix VAAPI with intel iGPU's

This commit is contained in:
loki
2021-08-18 20:19:15 +02:00
parent fc7ec9e538
commit 869b6ed89d
2 changed files with 22 additions and 11 deletions
+2 -2
View File
@@ -547,14 +547,14 @@ int vaapi_make_hwdevice_ctx(platf::hwdevice_t *base, AVBufferRef **hw_device_buf
return 0; return 0;
} }
bool query(display_t::pointer display, profile_e profile) { static bool query(display_t::pointer display, profile_e profile) {
std::vector<entry_e> entrypoints; std::vector<entry_e> entrypoints;
entrypoints.resize(maxNumEntrypoints(display)); entrypoints.resize(maxNumEntrypoints(display));
int count; int count;
auto status = queryConfigEntrypoints(display, profile, entrypoints.data(), &count); auto status = queryConfigEntrypoints(display, profile, entrypoints.data(), &count);
if(status) { if(status) {
BOOST_LOG(error) << "Couldn't query entrypoints for profile::H264Main "sv << va::errorStr(status); BOOST_LOG(error) << "Couldn't query entrypoints: "sv << va::errorStr(status);
return false; return false;
} }
entrypoints.resize(count); entrypoints.resize(count);
+20 -9
View File
@@ -237,10 +237,11 @@ public:
}; };
enum flag_e { enum flag_e {
DEFAULT = 0x00, DEFAULT = 0x00,
SYSTEM_MEMORY = 0x01, PARALLEL_ENCODING = 0x01,
H264_ONLY = 0x02, H264_ONLY = 0x02, // When HEVC is to heavy
LIMITED_GOP_SIZE = 0x04, LIMITED_GOP_SIZE = 0x04, // Some encoders don't like it when you have an infinite GOP_SIZE. *cough* VAAPI *cough*
SINGLE_SLICE_ONLY = 0x08, // Never use multiple slices <-- Older intel iGPU's ruin it for everyone else :P
}; };
struct encoder_t { struct encoder_t {
@@ -440,7 +441,7 @@ static encoder_t nvenc {
DEFAULT, DEFAULT,
dxgi_make_hwdevice_ctx dxgi_make_hwdevice_ctx
#else #else
SYSTEM_MEMORY, PARALLEL_ENCODING,
cuda_make_hwdevice_ctx cuda_make_hwdevice_ctx
#endif #endif
}; };
@@ -506,7 +507,7 @@ static encoder_t software {
std::make_optional<encoder_t::option_t>("qp"s, &config::video.qp), std::make_optional<encoder_t::option_t>("qp"s, &config::video.qp),
"libx264"s, "libx264"s,
}, },
H264_ONLY | SYSTEM_MEMORY, H264_ONLY | PARALLEL_ENCODING,
nullptr nullptr
}; };
@@ -534,7 +535,7 @@ static encoder_t vaapi {
std::make_optional<encoder_t::option_t>("qp"s, &config::video.qp), std::make_optional<encoder_t::option_t>("qp"s, &config::video.qp),
"h264_vaapi"s, "h264_vaapi"s,
}, },
LIMITED_GOP_SIZE | SYSTEM_MEMORY, LIMITED_GOP_SIZE | PARALLEL_ENCODING | SINGLE_SLICE_ONLY,
vaapi_make_hwdevice_ctx vaapi_make_hwdevice_ctx
}; };
@@ -1374,7 +1375,7 @@ void capture(
auto idr_events = mail->event<bool>(mail::idr); auto idr_events = mail->event<bool>(mail::idr);
idr_events->raise(true); idr_events->raise(true);
if(encoders.front().flags & SYSTEM_MEMORY) { if(encoders.front().flags & PARALLEL_ENCODING) {
capture_async(std::move(mail), config, channel_data); capture_async(std::move(mail), config, channel_data);
} }
else { else {
@@ -1540,8 +1541,13 @@ retry:
std::vector<std::pair<encoder_t::flag_e, config_t>> configs { std::vector<std::pair<encoder_t::flag_e, config_t>> configs {
{ encoder_t::DYNAMIC_RANGE, { 1920, 1080, 60, 1000, 1, 0, 3, 1, 1 } }, { encoder_t::DYNAMIC_RANGE, { 1920, 1080, 60, 1000, 1, 0, 3, 1, 1 } },
{ encoder_t::SLICE, { 1920, 1080, 60, 1000, 2, 1, 1, 0, 0 } },
}; };
if(!(encoder.flags & SINGLE_SLICE_ONLY)) {
configs.emplace_back(
std::pair<encoder_t::flag_e, config_t> { encoder_t::SLICE, { 1920, 1080, 60, 1000, 2, 1, 1, 0, 0 } });
}
for(auto &[flag, config] : configs) { for(auto &[flag, config] : configs) {
auto h264 = config; auto h264 = config;
auto hevc = config; auto hevc = config;
@@ -1555,6 +1561,11 @@ retry:
} }
} }
if(encoder.flags & SINGLE_SLICE_ONLY) {
encoder.h264.capabilities[encoder_t::SLICE] = false;
encoder.hevc.capabilities[encoder_t::SLICE] = false;
}
encoder.h264[encoder_t::VUI_PARAMETERS] = encoder.h264[encoder_t::VUI_PARAMETERS] && !config::sunshine.flags[config::flag::FORCE_VIDEO_HEADER_REPLACE]; encoder.h264[encoder_t::VUI_PARAMETERS] = encoder.h264[encoder_t::VUI_PARAMETERS] && !config::sunshine.flags[config::flag::FORCE_VIDEO_HEADER_REPLACE];
encoder.hevc[encoder_t::VUI_PARAMETERS] = encoder.hevc[encoder_t::VUI_PARAMETERS] && !config::sunshine.flags[config::flag::FORCE_VIDEO_HEADER_REPLACE]; encoder.hevc[encoder_t::VUI_PARAMETERS] = encoder.hevc[encoder_t::VUI_PARAMETERS] && !config::sunshine.flags[config::flag::FORCE_VIDEO_HEADER_REPLACE];