[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) vroad <396351+vroad@users.noreply.github.com> (vroad)
williamvds <w.vigolodasilva@gmail.com> (williamvds) williamvds <w.vigolodasilva@gmail.com> (williamvds)
SytheZN <sythe.zn@gmail.com> (SytheZN) 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, .type = OPTION_TYPE_INT,
.value.x_int = 128 .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} {0}
}; };
@ -187,11 +194,13 @@ static bool nvfbc_init(void)
free(buffer); free(buffer);
} }
int adapterIndex = option_get_int("nvfbc", "adapterIndex");
// NOTE: Calling this on hardware that doesn't support NvFBC such as GeForce // 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 // 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 // attempt NvFBC as a last resort, or if configured via the app:capture
// option. // option.
if (!NvFBCToSysCreate(privData, privDataLen, &this->nvfbc, &this->maxWidth, &this->maxHeight)) if (!NvFBCToSysCreate(adapterIndex, privData, privDataLen, &this->nvfbc, &this->maxWidth, &this->maxHeight))
{ {
free(privData); free(privData);
return false; return false;

View File

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

View File

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