Confirmed users
156
edits
mNo edit summary |
No edit summary |
||
| Line 24: | Line 24: | ||
* NPNVsupportsAsyncBitmapSurfaceBool (NPNVariable = 2007) | * NPNVsupportsAsyncBitmapSurfaceBool (NPNVariable = 2007) | ||
* NPNVsupportsAsyncWindowsDXGISurfaceBool (NPNVariable = 2008) | * NPNVsupportsAsyncWindowsDXGISurfaceBool (NPNVariable = 2008) | ||
* NPNVpreferredDXGIAdapter (NPNVariable = 2009) | |||
Since these are the first new models for Windows and Linux the existing models will be assigned names: | Since these are the first new models for Windows and Linux the existing models will be assigned names: | ||
| Line 122: | Line 123: | ||
Plugins should finalize Windows shared surfaces by calling <code>NPN_FinalizeAsyncSurface</code> when they are done with the surface. | Plugins should finalize Windows shared surfaces by calling <code>NPN_FinalizeAsyncSurface</code> when they are done with the surface. | ||
== Creating the Device == | |||
On dual-GPU systems, the browser and plugin process may unintentionally bind to different GPUs if default DXGI parameters are used. When this happens the plugin's draw calls will most likely fail, or crash. To address this, it is necessary to open the browser's shared DXGI surfaces on the same adapter. The adapter can be found using <tt>NPNVpreferredDXGIAdapter</tt>. For example, | |||
<pre> | |||
static IDXGIAdapter1* | |||
FindDXGIAdapter(NPP npp, IDXGIFactory1* factory) | |||
{ | |||
DXGI_ADAPTER_DESC preferred; | |||
if (NPN_GetValue(npp, NPNVpreferredDXGIAdapter, &preferred) != NPERR_NO_ERROR) { | |||
return NULL; | |||
} | |||
for (UINT index = 0; ; index++) { | |||
IDXGIAdapter* adapter = NULL; | |||
if (FAILED(factory1->EnumAdapters1(index, &adapter)) || !adapter) { | |||
return nullptr; | |||
} | |||
DXGI_ADAPTER_DESC desc; | |||
if (SUCCEEDED(adapter->GetDesc(&desc)) && | |||
desc.AdapterLuid.LowPart == preferred.AdapterLuid.LowPart && | |||
desc.AdapterLuid.HighPart == preferred.AdapterLuid.HighPart) | |||
{ | |||
return adapter; | |||
} | |||
adapter->Release(); | |||
} | |||
return NULL; | |||
} | |||
</pre> | |||
The adapter returned by this function can then be used with any DXGI device creation function, such as <tt>D3D10CreateDevice</tt>. Failure to negotiate the adapter properly (or use a IDXGIAdapter1, provided by DXGI 1.1) will result in undefined behavior. | |||
== Sample Code == | |||
This sample code illustrates usage of this drawing model: | This sample code illustrates usage of this drawing model: | ||
<pre> | |||
ID3D10Device *pDevice10; | ID3D10Device *pDevice10; | ||
NPAsyncSurface *npFrontBuffer = new NPAsyncSurface; | NPAsyncSurface *npFrontBuffer = new NPAsyncSurface; | ||
| Line 184: | Line 222: | ||
delete npBackBuffer; | delete npBackBuffer; | ||
} | } | ||
</pre> | |||