mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-24 06:27:17 +00:00
[host] nvfbc: retry on failure to init
@quantum has observed nvfbc under rare circumstances fail to initialize, this adds a retry to the init with a short delay to hopefully recover from this situation.
This commit is contained in:
parent
60ac03ebaf
commit
8619f787b9
@ -316,43 +316,55 @@ static bool nvfbc_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int adapterIndex = option_get_int("nvfbc", "adapterIndex");
|
int adapterIndex = option_get_int("nvfbc", "adapterIndex");
|
||||||
// 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
|
bool created = false;
|
||||||
// attempt NvFBC as a last resort, or if configured via the app:capture
|
for(int retry = 0; retry < 2; ++retry)
|
||||||
// option.
|
|
||||||
if (adapterIndex < 0)
|
|
||||||
{
|
{
|
||||||
IDirect3D9 * d3d = Direct3DCreate9(D3D_SDK_VERSION);
|
// NOTE: Calling this on hardware that doesn't support NvFBC such as GeForce
|
||||||
int adapterCount = IDirect3D9_GetAdapterCount(d3d);
|
// causes a substantial performance pentalty even if it fails! As such we only
|
||||||
for(int i = 0; i < adapterCount; ++i)
|
// attempt NvFBC as a last resort, or if configured via the app:capture
|
||||||
{
|
// option.
|
||||||
D3DADAPTER_IDENTIFIER9 ident;
|
|
||||||
IDirect3D9_GetAdapterIdentifier(d3d, i, 0, &ident);
|
|
||||||
if (ident.VendorId != 0x10DE)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (NvFBCToSysCreate(i, privData, privDataLen, &this->nvfbc,
|
|
||||||
&this->maxWidth, &this->maxHeight))
|
|
||||||
{
|
|
||||||
adapterIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IDirect3D9_Release(d3d);
|
|
||||||
|
|
||||||
if (adapterIndex < 0)
|
if (adapterIndex < 0)
|
||||||
{
|
{
|
||||||
free(privData);
|
IDirect3D9 * d3d = Direct3DCreate9(D3D_SDK_VERSION);
|
||||||
return false;
|
int adapterCount = IDirect3D9_GetAdapterCount(d3d);
|
||||||
|
for(int i = 0; i < adapterCount; ++i)
|
||||||
|
{
|
||||||
|
D3DADAPTER_IDENTIFIER9 ident;
|
||||||
|
IDirect3D9_GetAdapterIdentifier(d3d, i, 0, &ident);
|
||||||
|
if (ident.VendorId != 0x10DE)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (NvFBCToSysCreate(i, privData, privDataLen, &this->nvfbc,
|
||||||
|
&this->maxWidth, &this->maxHeight))
|
||||||
|
{
|
||||||
|
adapterIndex = i;
|
||||||
|
created = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IDirect3D9_Release(d3d);
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
|
||||||
if (!NvFBCToSysCreate(adapterIndex, privData, privDataLen, &this->nvfbc, &this->maxWidth, &this->maxHeight))
|
|
||||||
{
|
{
|
||||||
free(privData);
|
if (!NvFBCToSysCreate(adapterIndex, privData, privDataLen, &this->nvfbc, &this->maxWidth, &this->maxHeight))
|
||||||
return false;
|
continue;
|
||||||
|
created = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (created)
|
||||||
|
break;
|
||||||
|
|
||||||
|
//10ms delay before retry
|
||||||
|
nsleep(10000000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!created)
|
||||||
|
{
|
||||||
|
free(privData);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int diffRes = option_get_int("nvfbc", "diffRes");
|
int diffRes = option_get_int("nvfbc", "diffRes");
|
||||||
enum DiffMapBlockSize blockSize;
|
enum DiffMapBlockSize blockSize;
|
||||||
NvFBCGetDiffMapBlockSize(diffRes, &blockSize, &this->diffShift, privData, privDataLen);
|
NvFBCGetDiffMapBlockSize(diffRes, &blockSize, &this->diffShift, privData, privDataLen);
|
||||||
|
Loading…
Reference in New Issue
Block a user