mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-18 06:30:55 +00:00
Add environment variable override helper function
This allows FORCE_QT_GLES and SEPARATE_TEST_DECODER to override both true and false.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "d3d11va.h"
|
||||
#include "dxutil.h"
|
||||
#include "path.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include "streaming/streamutils.h"
|
||||
#include "streaming/session.h"
|
||||
@@ -209,29 +210,26 @@ bool D3D11VARenderer::createDeviceByAdapterIndex(int adapterIndex, bool* adapter
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
bool ok;
|
||||
m_BindDecoderOutputTextures = !!qEnvironmentVariableIntValue("D3D11VA_FORCE_BIND", &ok);
|
||||
if (!ok) {
|
||||
if (Utils::getEnvironmentVariableOverride("D3D11VA_FORCE_BIND", &m_BindDecoderOutputTextures)) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Using D3D11VA_FORCE_BIND to override default bind/copy logic");
|
||||
}
|
||||
else {
|
||||
// Skip copying to our own internal texture on Intel GPUs due to
|
||||
// significant performance impact of the extra copy. See:
|
||||
// https://github.com/moonlight-stream/moonlight-qt/issues/1304
|
||||
m_BindDecoderOutputTextures = adapterDesc.VendorId == 0x8086;
|
||||
}
|
||||
else {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Using D3D11VA_FORCE_BIND to override default bind/copy logic");
|
||||
}
|
||||
|
||||
m_UseFenceHack = !!qEnvironmentVariableIntValue("D3D11VA_FORCE_FENCE", &ok);
|
||||
if (!ok) {
|
||||
if (Utils::getEnvironmentVariableOverride("D3D11VA_FORCE_FENCE", &m_UseFenceHack)) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Using D3D11VA_FORCE_FENCE to override default fence workaround logic");
|
||||
}
|
||||
else {
|
||||
// Old Intel GPUs (HD 4000) require a fence to properly synchronize
|
||||
// the video engine with the 3D engine for texture sampling.
|
||||
m_UseFenceHack = adapterDesc.VendorId == 0x8086 && featureLevel < D3D_FEATURE_LEVEL_11_1;
|
||||
}
|
||||
else {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Using D3D11VA_FORCE_FENCE to override default fence workaround logic");
|
||||
}
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Decoder texture access: %s (fence: %s)",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#endif
|
||||
|
||||
#include "drm.h"
|
||||
#include "string.h"
|
||||
#include "utils.h"
|
||||
|
||||
extern "C" {
|
||||
#include <libavutil/hwcontext_drm.h>
|
||||
@@ -80,6 +80,7 @@ struct dma_buf_sync {
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
|
||||
@@ -576,8 +577,12 @@ bool DrmRenderer::initialize(PDECODER_PARAMETERS params)
|
||||
// formats with the linear modifier on all planes, but doesn't actually
|
||||
// support raw YUV formats on the primary plane. Don't ever use primary
|
||||
// planes on Spacemit hardware to avoid triggering this bug.
|
||||
bool ok, allowPrimaryPlane = !!qEnvironmentVariableIntValue("DRM_ALLOW_PRIMARY_PLANE", &ok);
|
||||
if (!ok) {
|
||||
bool allowPrimaryPlane;
|
||||
if (Utils::getEnvironmentVariableOverride("DRM_ALLOW_PRIMARY_PLANE", &allowPrimaryPlane)) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Using DRM_ALLOW_PRIMARY_PLANE to override default plane selection logic");
|
||||
}
|
||||
else {
|
||||
allowPrimaryPlane = strcmp(m_Version->name, "spacemit") != 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <initguid.h>
|
||||
#include "dxva2.h"
|
||||
#include "dxutil.h"
|
||||
#include "utils.h"
|
||||
#include "../ffmpeg.h"
|
||||
#include <streaming/streamutils.h>
|
||||
#include <streaming/session.h>
|
||||
@@ -390,16 +391,11 @@ bool DXVA2Renderer::initializeQuirksForAdapter(IDirect3D9Ex* d3d9ex, int adapter
|
||||
SDL_assert(m_DeviceQuirks == 0);
|
||||
SDL_assert(!m_Device);
|
||||
|
||||
{
|
||||
bool ok;
|
||||
|
||||
m_DeviceQuirks = qEnvironmentVariableIntValue("DXVA2_QUIRK_FLAGS", &ok);
|
||||
if (ok) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Using DXVA2 quirk override: 0x%x",
|
||||
m_DeviceQuirks);
|
||||
return true;
|
||||
}
|
||||
if (Utils::getEnvironmentVariableOverride("DXVA2_QUIRK_FLAGS", &m_DeviceQuirks)) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Using DXVA2 quirk override: 0x%x",
|
||||
m_DeviceQuirks);
|
||||
return true;
|
||||
}
|
||||
|
||||
UINT adapterCount = d3d9ex->GetAdapterCount();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "genhwaccel.h"
|
||||
#include "utils.h"
|
||||
|
||||
GenericHwAccelRenderer::GenericHwAccelRenderer(AVHWDeviceType hwDeviceType)
|
||||
: IFFmpegRenderer(RendererType::Unknown),
|
||||
@@ -56,9 +57,9 @@ bool GenericHwAccelRenderer::isDirectRenderingSupported()
|
||||
|
||||
int GenericHwAccelRenderer::getDecoderCapabilities()
|
||||
{
|
||||
bool ok;
|
||||
int caps = qEnvironmentVariableIntValue("GENHWACCEL_CAPS", &ok);
|
||||
if (ok) {
|
||||
int caps;
|
||||
|
||||
if (Utils::getEnvironmentVariableOverride("GENHWACCEL_CAPS", &caps)) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Using GENHWACCEL_CAPS for decoder capabilities: %x",
|
||||
caps);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <Limelight.h>
|
||||
#include "ffmpeg.h"
|
||||
#include "utils.h"
|
||||
#include "streaming/session.h"
|
||||
|
||||
#include <h264_stream.h>
|
||||
@@ -109,10 +110,9 @@ bool FFmpegVideoDecoder::notifyWindowChanged(PWINDOW_STATE_CHANGE_INFO info)
|
||||
|
||||
int FFmpegVideoDecoder::getDecoderCapabilities()
|
||||
{
|
||||
bool ok;
|
||||
int capabilities;
|
||||
|
||||
int capabilities = qEnvironmentVariableIntValue("DECODER_CAPS", &ok);
|
||||
if (ok) {
|
||||
if (Utils::getEnvironmentVariableOverride("DECODER_CAPS", &capabilities)) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Using decoder capability override: 0x%x",
|
||||
capabilities);
|
||||
@@ -1080,8 +1080,9 @@ bool FFmpegVideoDecoder::isSeparateTestDecoderRequired(const AVCodec* decoder)
|
||||
// the decoder can handle a change in surface sizes while streaming.
|
||||
// We know v4l2m2m can't handle this (see comment below), so let's just
|
||||
// opt-out all non-hwaccel decoders just to be safe.
|
||||
if (qEnvironmentVariableIntValue("SEPARATE_TEST_DECODER")) {
|
||||
return true;
|
||||
bool value;
|
||||
if (Utils::getEnvironmentVariableOverride("SEPARATE_TEST_DECODER", &value)) {
|
||||
return value;
|
||||
}
|
||||
else if (getAVCodecCapabilities(decoder) & AV_CODEC_CAP_HARDWARE) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user