[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 = { struct DXGICopyBackend copyBackendD3D11 = {
.name = "Direct3D 11", .name = "Direct3D 11",
.code = "d3d11",
.create = d3d11_create, .create = d3d11_create,
.free = d3d11_free, .free = d3d11_free,
.copyFrame = d3d11_copyFrame, .copyFrame = d3d11_copyFrame,

View File

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

View File

@ -106,6 +106,13 @@ static void dxgi_initOptions(void)
.type = OPTION_TYPE_BOOL, .type = OPTION_TYPE_BOOL,
.value.x_bool = false .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} {0}
}; };
@ -487,10 +494,17 @@ static bool dxgi_init(void)
goto fail; goto fail;
} }
const char * copyBackend = option_get_string("dxgi", "copyBackend");
for (int i = 0; i < ARRAY_LENGTH(backends); ++i) 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]; this->backend = backends[i];
break; break;
} }
@ -498,12 +512,12 @@ static bool dxgi_init(void)
if (!this->backend) if (!this->backend)
{ {
DEBUG_ERROR("Could not find a usable copy backend"); DEBUG_ERROR("Could not find copy backend: %s", copyBackend);
goto fail; goto fail;
} }
DEBUG_INFO("Copy backend : %s", this->backend->name); DEBUG_INFO("Copy backend : %s", this->backend->name);
DEBUG_INFO("AcquireLock : %s", this->useAcquireLock ? "enabled" : "disabled"); DEBUG_INFO("AcquireLock : %s", this->useAcquireLock ? "enabled" : "disabled");
for (int i = 0; i < this->maxTextures; ++i) for (int i = 0; i < this->maxTextures; ++i)
this->texture[i].texDamageCount = -1; this->texture[i].texDamageCount = -1;

View File

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