[host] nvfbc: add an option to specify adapter

This commit is contained in:
WYF 2021-10-24 19:00:02 +08:00 committed by Geoffrey McRae
parent 9fa643484c
commit b21d842f0e
4 changed files with 14 additions and 2 deletions

View File

@ -54,3 +54,4 @@ thejavascriptman <thejavascriptman@outlook.com> (thejavascriptman)
vroad <396351+vroad@users.noreply.github.com> (vroad)
williamvds <w.vigolodasilva@gmail.com> (williamvds)
SytheZN <sythe.zn@gmail.com> (SytheZN)
RTXUX <wyf@rtxux.xyz> (RTXUX)

View File

@ -140,6 +140,13 @@ static void nvfbc_initOptions(void)
.type = OPTION_TYPE_INT,
.value.x_int = 128
},
{
.module = "nvfbc",
.name = "adapterIndex",
.description = "The index of the adapter to capture from",
.type = OPTION_TYPE_INT,
.value.x_int = 0
},
{0}
};
@ -186,12 +193,14 @@ static bool nvfbc_init(void)
free(buffer);
}
int adapterIndex = option_get_int("nvfbc", "adapterIndex");
// NOTE: Calling this on hardware that doesn't support NvFBC such as GeForce
// causes a substantial performance pentalty even if it fails! As such we only
// attempt NvFBC as a last resort, or if configured via the app:capture
// option.
if (!NvFBCToSysCreate(privData, privDataLen, &this->nvfbc, &this->maxWidth, &this->maxHeight))
if (!NvFBCToSysCreate(adapterIndex, privData, privDataLen, &this->nvfbc, &this->maxWidth, &this->maxHeight))
{
free(privData);
return false;

View File

@ -109,6 +109,7 @@ void NvFBCFree()
}
bool NvFBCToSysCreate(
int adapterIndex,
void * privData,
unsigned int privDataSize,
NvFBCHandle * handle,
@ -121,7 +122,7 @@ bool NvFBCToSysCreate(
params.dwVersion = NVFBC_CREATE_PARAMS_VER;
params.dwInterfaceType = NVFBC_TO_SYS;
params.pDevice = NULL;
params.dwAdapterIdx = 0;
params.dwAdapterIdx = adapterIndex;
params.dwPrivateDataSize = privDataSize;
params.pPrivateData = privData;

View File

@ -52,6 +52,7 @@ bool NvFBCInit();
void NvFBCFree();
bool NvFBCToSysCreate(
int adapterIndex,
void * privData,
unsigned int privDataSize,
NvFBCHandle * handle,