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
public:
D3DTextureSurfaceWGL(const egl::SurfaceState &state,
RendererGL *renderer,
EGLenum buftype,
EGLClientBuffer clientBuffer,
DisplayWGL *display,
HGLRC wglContext,
HDC deviceContext,
ID3D11Device *displayD3D11Device,
const FunctionsGL *functionsGL,
const FunctionsWGL *functionsWGL);
~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 makeCurrent() override;
......@@ -57,10 +61,13 @@ class D3DTextureSurfaceWGL : public SurfaceGL
FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &data) override;
private:
EGLenum mBuftype;
EGLClientBuffer mClientBuffer;
RendererGL *mRenderer;
ID3D11Device *mDisplayD3D11Device;
DisplayWGL *mDisplay;
StateManagerGL *mStateManager;
const WorkaroundsGL &mWorkarounds;
......@@ -75,6 +82,7 @@ class D3DTextureSurfaceWGL : public SurfaceGL
HANDLE mDeviceHandle;
IUnknown *mObject;
IDXGIKeyedMutex *mKeyedMutex;
HANDLE mBoundObjectTextureHandle;
HANDLE mBoundObjectRenderbufferHandle;
......
......@@ -375,7 +375,7 @@ egl::Error DisplayWGL::initialize(egl::Display *display)
mUseDXGISwapChains = false;
}
if (mUseDXGISwapChains)
if (mFunctionsWGL->hasExtension("WGL_NV_DX_interop2"))
{
egl::Error error = initializeD3DDevice();
if (error.isError())
......@@ -383,6 +383,11 @@ egl::Error DisplayWGL::initialize(egl::Display *display)
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);
}
......@@ -465,9 +470,8 @@ SurfaceImpl *DisplayWGL::createPbufferFromClientBuffer(const egl::SurfaceState &
EGLClientBuffer clientBuffer,
const egl::AttributeMap &attribs)
{
ASSERT(buftype == EGL_D3D_TEXTURE_ANGLE);
return new D3DTextureSurfaceWGL(state, getRenderer(), clientBuffer, this, mWGLContext,
mDeviceContext, mFunctionsGL, mFunctionsWGL);
return new D3DTextureSurfaceWGL(state, getRenderer(), buftype, clientBuffer, this, mWGLContext,
mDeviceContext, mD3D11Device, mFunctionsGL, mFunctionsWGL);
}
SurfaceImpl *DisplayWGL::createPixmapSurface(const egl::SurfaceState &state,
......@@ -588,7 +592,9 @@ egl::Error DisplayWGL::validateClientBuffer(const egl::Config *configuration,
switch (buftype)
{
case EGL_D3D_TEXTURE_ANGLE:
return D3DTextureSurfaceWGL::ValidateD3DTextureClientBuffer(clientBuffer);
case EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE:
return D3DTextureSurfaceWGL::ValidateD3DTextureClientBuffer(buftype, clientBuffer,
mD3D11Device);
default:
return DisplayGL::validateClientBuffer(configuration, buftype, clientBuffer, attribs);
......@@ -659,7 +665,11 @@ void DisplayWGL::generateExtensions(egl::DisplayExtensions *outExtensions) const
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
outExtensions->displayTextureShareGroup = true;
......
......@@ -134,7 +134,7 @@ egl::Error PbufferSurfaceWGL::postSubBuffer(EGLint x, EGLint y, EGLint width, EG
egl::Error PbufferSurfaceWGL::querySurfacePointerANGLE(EGLint attribute, void **value)
{
UNIMPLEMENTED();
*value = nullptr;
return egl::Error(EGL_SUCCESS);
}
......
......@@ -119,7 +119,7 @@ egl::Error WindowSurfaceWGL::postSubBuffer(EGLint x, EGLint y, EGLint width, EGL
egl::Error WindowSurfaceWGL::querySurfacePointerANGLE(EGLint attribute, void **value)
{
UNIMPLEMENTED();
*value = nullptr;
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