[host] allow user to select capture backend

This commit introduces a new option, app:capture, which can be set to
either DXGI or NvFBC to force the host application to use that backend.

This is very useful for testing DXGI on Quadro cards, which would default
to running with NvFBC.
This commit is contained in:
Quantum authored and Geoffrey McRae committed 2021-02-27 17:41:44 +11:00
1 parent 54da11a206
commit f2c0b8c0b4
5 files changed
+39 -1

No files matched your search

+1
View File
@@ -89,6 +89,7 @@ typedef void (*CapturePostPointerBuffer)(CapturePointer pointer);
typedef struct CaptureInterface
{
const char *shortName;
const char * (*getName )();
void (*initOptions )();
@@ -235,6 +235,7 @@ static CaptureResult xcb_getFrame(FrameBuffer * frame)
struct CaptureInterface Capture_XCB =
{
.shortName = "XCB",
.getName = xcb_getName,
.create = xcb_create,
.init = xcb_init,
@@ -1023,6 +1023,7 @@ static CaptureResult dxgi_releaseFrame(void)
struct CaptureInterface Capture_DXGI =
{
.shortName = "DXGI",
.getName = dxgi_getName,
.initOptions = dxgi_initOptions,
.create = dxgi_create,
@@ -427,6 +427,7 @@ static int pointerThread(void * unused)
struct CaptureInterface Capture_NVFBC =
{
.shortName = "NvFBC",
.getName = nvfbc_getName,
.initOptions = nvfbc_initOptions,
+35 -1
View File
@@ -97,6 +97,31 @@ struct app
static struct app app;
static bool validateCaptureBackend(struct Option * opt, const char ** error)
{
if (!*opt->value.x_string)
return true;
for (int i = 0; CaptureInterfaces[i]; ++i)
if (!strcasecmp(opt->value.x_string, CaptureInterfaces[i]->shortName))
return true;
return false;
}
static struct Option options[] =
{
{
.module = "app",
.name = "capture",
.description = "Select the capture backend",
.type = OPTION_TYPE_STRING,
.value.x_string = "",
.validator = validateCaptureBackend,
},
{0}
};
static bool lgmpTimer(void * opaque)
{
LGMP_STATUS status;
@@ -407,6 +432,8 @@ int app_main(int argc, char * argv[])
if (CaptureInterfaces[i]->initOptions)
CaptureInterfaces[i]->initOptions();
option_register(options);
// try load values from a config file
const char * dataPath = os_getDataPath();
if (!dataPath)
@@ -528,10 +555,14 @@ int app_main(int argc, char * argv[])
}
}
const char * ifaceName = option_get_string("app", "capture");
CaptureInterface * iface = NULL;
for(int i = 0; CaptureInterfaces[i]; ++i)
{
iface = CaptureInterfaces[i];
if (*ifaceName && strcasecmp(ifaceName, iface->shortName))
continue;
DEBUG_INFO("Trying : %s", iface->getName());
if (!iface->create(captureGetPointerBuffer, capturePostPointerBuffer))
@@ -549,7 +580,10 @@ int app_main(int argc, char * argv[])
if (!iface)
{
DEBUG_ERROR("Failed to find a supported capture interface");
if (*ifaceName)
DEBUG_ERROR("Specified capture interface not supported");
else
DEBUG_ERROR("Failed to find a supported capture interface");
exitcode = LG_HOST_EXIT_FAILED;
goto fail_lgmp;
}