mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 14:57:20 +00:00
[host] nvfbc: do not try to init on non NVIDIA hardware
This commit is contained in:
parent
a6a6b8779a
commit
12d051d8c0
@ -295,6 +295,17 @@ static void updateScale(void)
|
|||||||
|
|
||||||
static bool nvfbc_init(void)
|
static bool nvfbc_init(void)
|
||||||
{
|
{
|
||||||
|
int adapterIndex = option_get_int("nvfbc", "adapterIndex");
|
||||||
|
|
||||||
|
IDirect3D9 * d3d = Direct3DCreate9(D3D_SDK_VERSION);
|
||||||
|
int adapterCount = IDirect3D9_GetAdapterCount(d3d);
|
||||||
|
if (adapterIndex > adapterCount)
|
||||||
|
{
|
||||||
|
DEBUG_ERROR("Invalid adapterIndex specified");
|
||||||
|
IDirect3D9_Release(d3d);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int bufferLen = GetEnvironmentVariable("NVFBC_PRIV_DATA", NULL, 0);
|
int bufferLen = GetEnvironmentVariable("NVFBC_PRIV_DATA", NULL, 0);
|
||||||
uint8_t * privData = NULL;
|
uint8_t * privData = NULL;
|
||||||
int privDataLen = 0;
|
int privDataLen = 0;
|
||||||
@ -316,8 +327,7 @@ static bool nvfbc_init(void)
|
|||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
int adapterIndex = option_get_int("nvfbc", "adapterIndex");
|
D3DADAPTER_IDENTIFIER9 ident;
|
||||||
|
|
||||||
bool created = false;
|
bool created = false;
|
||||||
for(int retry = 0; retry < 2; ++retry)
|
for(int retry = 0; retry < 2; ++retry)
|
||||||
{
|
{
|
||||||
@ -327,29 +337,34 @@ static bool nvfbc_init(void)
|
|||||||
// option.
|
// option.
|
||||||
if (adapterIndex < 0)
|
if (adapterIndex < 0)
|
||||||
{
|
{
|
||||||
IDirect3D9 * d3d = Direct3DCreate9(D3D_SDK_VERSION);
|
|
||||||
int adapterCount = IDirect3D9_GetAdapterCount(d3d);
|
|
||||||
for(int i = 0; i < adapterCount; ++i)
|
for(int i = 0; i < adapterCount; ++i)
|
||||||
{
|
{
|
||||||
D3DADAPTER_IDENTIFIER9 ident;
|
if (IDirect3D9_GetAdapterIdentifier(d3d, i, 0, &ident) != D3D_OK ||
|
||||||
IDirect3D9_GetAdapterIdentifier(d3d, i, 0, &ident);
|
ident.VendorId != 0x10DE)
|
||||||
if (ident.VendorId != 0x10DE)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (NvFBCToSysCreate(i, privData, privDataLen, &this->nvfbc,
|
if (!NvFBCToSysCreate(i, privData, privDataLen, &this->nvfbc,
|
||||||
&this->maxWidth, &this->maxHeight))
|
&this->maxWidth, &this->maxHeight))
|
||||||
{
|
continue;
|
||||||
adapterIndex = i;
|
|
||||||
created = true;
|
adapterIndex = i;
|
||||||
break;
|
created = true;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
IDirect3D9_Release(d3d);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!NvFBCToSysCreate(adapterIndex, privData, privDataLen, &this->nvfbc, &this->maxWidth, &this->maxHeight))
|
if (IDirect3D9_GetAdapterIdentifier(d3d, adapterIndex, 0, &ident) !=
|
||||||
|
D3D_OK || ident.VendorId != 0x10DE)
|
||||||
|
{
|
||||||
|
DEBUG_ERROR("adapterIndex %d is not a NVidia device", adapterIndex);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NvFBCToSysCreate(adapterIndex, privData, privDataLen, &this->nvfbc,
|
||||||
|
&this->maxWidth, &this->maxHeight))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
created = true;
|
created = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,6 +375,8 @@ static bool nvfbc_init(void)
|
|||||||
nsleep(1000000000);
|
nsleep(1000000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IDirect3D9_Release(d3d);
|
||||||
|
|
||||||
if (!created)
|
if (!created)
|
||||||
{
|
{
|
||||||
free(privData);
|
free(privData);
|
||||||
|
Loading…
Reference in New Issue
Block a user