Commit 6b2ea3fe by Geoff Lang Committed by Commit Bot

Support D3D texture share handles in the OpenGL backend on Windows.

BUG=angleproject:1144 Change-Id: Ideb0ed306ae8417f53b813745ced43002d028126 Reviewed-on: https://chromium-review.googlesource.com/461271Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 9ec79391
...@@ -27,15 +27,19 @@ class D3DTextureSurfaceWGL : public SurfaceGL ...@@ -27,15 +27,19 @@ class D3DTextureSurfaceWGL : public SurfaceGL
public: public:
D3DTextureSurfaceWGL(const egl::SurfaceState &state, D3DTextureSurfaceWGL(const egl::SurfaceState &state,
RendererGL *renderer, RendererGL *renderer,
EGLenum buftype,
EGLClientBuffer clientBuffer, EGLClientBuffer clientBuffer,
DisplayWGL *display, DisplayWGL *display,
HGLRC wglContext, HGLRC wglContext,
HDC deviceContext, HDC deviceContext,
ID3D11Device *displayD3D11Device,
const FunctionsGL *functionsGL, const FunctionsGL *functionsGL,
const FunctionsWGL *functionsWGL); const FunctionsWGL *functionsWGL);
~D3DTextureSurfaceWGL() override; ~D3DTextureSurfaceWGL() override;
static egl::Error ValidateD3DTextureClientBuffer(EGLClientBuffer clientBuffer); static egl::Error ValidateD3DTextureClientBuffer(EGLenum buftype,
EGLClientBuffer clientBuffer,
ID3D11Device *d3d11Device);
egl::Error initialize(const DisplayImpl *displayImpl) override; egl::Error initialize(const DisplayImpl *displayImpl) override;
egl::Error makeCurrent() override; egl::Error makeCurrent() override;
...@@ -57,10 +61,13 @@ class D3DTextureSurfaceWGL : public SurfaceGL ...@@ -57,10 +61,13 @@ class D3DTextureSurfaceWGL : public SurfaceGL
FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &data) override; FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &data) override;
private: private:
EGLenum mBuftype;
EGLClientBuffer mClientBuffer; EGLClientBuffer mClientBuffer;
RendererGL *mRenderer; RendererGL *mRenderer;
ID3D11Device *mDisplayD3D11Device;
DisplayWGL *mDisplay; DisplayWGL *mDisplay;
StateManagerGL *mStateManager; StateManagerGL *mStateManager;
const WorkaroundsGL &mWorkarounds; const WorkaroundsGL &mWorkarounds;
...@@ -75,6 +82,7 @@ class D3DTextureSurfaceWGL : public SurfaceGL ...@@ -75,6 +82,7 @@ class D3DTextureSurfaceWGL : public SurfaceGL
HANDLE mDeviceHandle; HANDLE mDeviceHandle;
IUnknown *mObject; IUnknown *mObject;
IDXGIKeyedMutex *mKeyedMutex;
HANDLE mBoundObjectTextureHandle; HANDLE mBoundObjectTextureHandle;
HANDLE mBoundObjectRenderbufferHandle; HANDLE mBoundObjectRenderbufferHandle;
......
...@@ -375,7 +375,7 @@ egl::Error DisplayWGL::initialize(egl::Display *display) ...@@ -375,7 +375,7 @@ egl::Error DisplayWGL::initialize(egl::Display *display)
mUseDXGISwapChains = false; mUseDXGISwapChains = false;
} }
if (mUseDXGISwapChains) if (mFunctionsWGL->hasExtension("WGL_NV_DX_interop2"))
{ {
egl::Error error = initializeD3DDevice(); egl::Error error = initializeD3DDevice();
if (error.isError()) if (error.isError())
...@@ -383,6 +383,11 @@ egl::Error DisplayWGL::initialize(egl::Display *display) ...@@ -383,6 +383,11 @@ egl::Error DisplayWGL::initialize(egl::Display *display)
return error; return error;
} }
} }
else if (mUseDXGISwapChains)
{
// Want to use DXGI swap chains but WGL_NV_DX_interop2 is not present, fail initialization
return egl::Error(EGL_NOT_INITIALIZED, "WGL_NV_DX_interop2 is required but not present.");
}
return DisplayGL::initialize(display); return DisplayGL::initialize(display);
} }
...@@ -465,9 +470,8 @@ SurfaceImpl *DisplayWGL::createPbufferFromClientBuffer(const egl::SurfaceState & ...@@ -465,9 +470,8 @@ SurfaceImpl *DisplayWGL::createPbufferFromClientBuffer(const egl::SurfaceState &
EGLClientBuffer clientBuffer, EGLClientBuffer clientBuffer,
const egl::AttributeMap &attribs) const egl::AttributeMap &attribs)
{ {
ASSERT(buftype == EGL_D3D_TEXTURE_ANGLE); return new D3DTextureSurfaceWGL(state, getRenderer(), buftype, clientBuffer, this, mWGLContext,
return new D3DTextureSurfaceWGL(state, getRenderer(), clientBuffer, this, mWGLContext, mDeviceContext, mD3D11Device, mFunctionsGL, mFunctionsWGL);
mDeviceContext, mFunctionsGL, mFunctionsWGL);
} }
SurfaceImpl *DisplayWGL::createPixmapSurface(const egl::SurfaceState &state, SurfaceImpl *DisplayWGL::createPixmapSurface(const egl::SurfaceState &state,
...@@ -588,7 +592,9 @@ egl::Error DisplayWGL::validateClientBuffer(const egl::Config *configuration, ...@@ -588,7 +592,9 @@ egl::Error DisplayWGL::validateClientBuffer(const egl::Config *configuration,
switch (buftype) switch (buftype)
{ {
case EGL_D3D_TEXTURE_ANGLE: case EGL_D3D_TEXTURE_ANGLE:
return D3DTextureSurfaceWGL::ValidateD3DTextureClientBuffer(clientBuffer); case EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE:
return D3DTextureSurfaceWGL::ValidateD3DTextureClientBuffer(buftype, clientBuffer,
mD3D11Device);
default: default:
return DisplayGL::validateClientBuffer(configuration, buftype, clientBuffer, attribs); return DisplayGL::validateClientBuffer(configuration, buftype, clientBuffer, attribs);
...@@ -659,7 +665,11 @@ void DisplayWGL::generateExtensions(egl::DisplayExtensions *outExtensions) const ...@@ -659,7 +665,11 @@ void DisplayWGL::generateExtensions(egl::DisplayExtensions *outExtensions) const
outExtensions->createContextRobustness = mHasRobustness; outExtensions->createContextRobustness = mHasRobustness;
outExtensions->d3dTextureClientBuffer = mFunctionsWGL->hasExtension("WGL_NV_DX_interop2"); outExtensions->d3dTextureClientBuffer = mD3D11Device != nullptr;
outExtensions->d3dShareHandleClientBuffer = mD3D11Device != nullptr;
outExtensions->surfaceD3DTexture2DShareHandle = true;
outExtensions->querySurfacePointer = true;
outExtensions->keyedMutex = true;
// Contexts are virtualized so textures can be shared globally // Contexts are virtualized so textures can be shared globally
outExtensions->displayTextureShareGroup = true; outExtensions->displayTextureShareGroup = true;
......
...@@ -134,7 +134,7 @@ egl::Error PbufferSurfaceWGL::postSubBuffer(EGLint x, EGLint y, EGLint width, EG ...@@ -134,7 +134,7 @@ egl::Error PbufferSurfaceWGL::postSubBuffer(EGLint x, EGLint y, EGLint width, EG
egl::Error PbufferSurfaceWGL::querySurfacePointerANGLE(EGLint attribute, void **value) egl::Error PbufferSurfaceWGL::querySurfacePointerANGLE(EGLint attribute, void **value)
{ {
UNIMPLEMENTED(); *value = nullptr;
return egl::Error(EGL_SUCCESS); return egl::Error(EGL_SUCCESS);
} }
......
...@@ -119,7 +119,7 @@ egl::Error WindowSurfaceWGL::postSubBuffer(EGLint x, EGLint y, EGLint width, EGL ...@@ -119,7 +119,7 @@ egl::Error WindowSurfaceWGL::postSubBuffer(EGLint x, EGLint y, EGLint width, EGL
egl::Error WindowSurfaceWGL::querySurfacePointerANGLE(EGLint attribute, void **value) egl::Error WindowSurfaceWGL::querySurfacePointerANGLE(EGLint attribute, void **value)
{ {
UNIMPLEMENTED(); *value = nullptr;
return egl::Error(EGL_SUCCESS); return egl::Error(EGL_SUCCESS);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment