[host] dxgi: allow copy backend selection

This commit is contained in:
Quantum 2022-01-09 22:23:59 -05:00 committed by Geoffrey McRae
parent 68e5b812a9
commit cf7d501bc4
4 changed files with 21 additions and 4 deletions

View File

@ -195,6 +195,7 @@ static void d3d11_preRelease(void)
struct DXGICopyBackend copyBackendD3D11 = {
.name = "Direct3D 11",
.code = "d3d11",
.create = d3d11_create,
.free = d3d11_free,
.copyFrame = d3d11_copyFrame,

View File

@ -446,6 +446,7 @@ static void d3d12_preRelease(void)
struct DXGICopyBackend copyBackendD3D12 = {
.name = "Direct3D 12",
.code = "d3d12",
.create = d3d12_create,
.free = d3d12_free,
.copyFrame = d3d12_copyFrame,

View File

@ -106,6 +106,13 @@ static void dxgi_initOptions(void)
.type = OPTION_TYPE_BOOL,
.value.x_bool = false
},
{
.module = "dxgi",
.name = "copyBackend",
.description = "The copy backend to use, i.e. d3d11 or d3d12",
.type = OPTION_TYPE_STRING,
.value.x_string = "d3d11",
},
{0}
};
@ -487,10 +494,17 @@ static bool dxgi_init(void)
goto fail;
}
const char * copyBackend = option_get_string("dxgi", "copyBackend");
for (int i = 0; i < ARRAY_LENGTH(backends); ++i)
{
if (backends[i]->create(this))
if (!strcasecmp(copyBackend, backends[i]->code))
{
if (!backends[i]->create(this))
{
DEBUG_ERROR("Failed to initialize selected capture backend: %s", backends[i]->name);
goto fail;
}
this->backend = backends[i];
break;
}
@ -498,7 +512,7 @@ static bool dxgi_init(void)
if (!this->backend)
{
DEBUG_ERROR("Could not find a usable copy backend");
DEBUG_ERROR("Could not find copy backend: %s", copyBackend);
goto fail;
}

View File

@ -108,6 +108,7 @@ struct DXGIInterface
struct DXGICopyBackend
{
const char * name;
const char * code;
bool (*create)(struct DXGIInterface * intf);
void (*free)(void);
bool (*copyFrame)(Texture * tex, ID3D11Texture2D * src);