Skip to content

Commit

Permalink
Bug 1092582. Add support to ANGLE for using IDXGIKeyedMutex.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmuizel committed Nov 1, 2014
1 parent f345e25 commit 6489380
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 2 deletions.
5 changes: 5 additions & 0 deletions gfx/angle/include/EGL/eglext.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSu
#define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x3208
#endif /* EGL_ANGLE_platform_angle_opengl */

#ifndef EGL_ANGLE_keyed_mutex
#define EGL_ANGLE_keyed_mutex 1
#define EGL_DXGI_KEYED_MUTEX_ANGLE 0x3209
#endif /* EGL_ANGLE_keyed_mutex */

#ifndef EGL_ARM_pixmap_multisample_discard
#define EGL_ARM_pixmap_multisample_discard 1
#define EGL_DISCARD_SAMPLES_ARM 0x3286
Expand Down
6 changes: 6 additions & 0 deletions gfx/angle/src/libEGL/libEGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,12 @@ EGLBoolean __stdcall eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surf
*value = (void*) (swapchain ? swapchain->getShareHandle() : NULL);
}
break;
case EGL_DXGI_KEYED_MUTEX_ANGLE:
{
rx::SwapChain *swapchain = eglSurface->getSwapChain();
*value = (void*) (swapchain ? swapchain->getKeyedMutex() : NULL);
}
break;
default:
return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE);
}
Expand Down
3 changes: 2 additions & 1 deletion gfx/angle/src/libGLESv2/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,11 @@ if CONFIG['MOZ_HAS_WINSDK_WITH_D3D']:
'renderer/d3d/d3d11/RenderStateCache.cpp',
'renderer/d3d/d3d11/RenderTarget11.cpp',
'renderer/d3d/d3d11/ShaderExecutable11.cpp',
'renderer/d3d/d3d11/SwapChain11.cpp',
'renderer/d3d/d3d11/TextureStorage11.cpp',
'renderer/d3d/d3d11/VertexBuffer11.cpp',
]
SOURCES += ['renderer/d3d/d3d11/SwapChain11.cpp']
SOURCES['renderer/d3d/d3d11/SwapChain11.cpp'].flags += ['-DANGLE_RESOURCE_SHARE_TYPE=D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX']


if CONFIG['GNU_CXX']:
Expand Down
1 change: 1 addition & 0 deletions gfx/angle/src/libGLESv2/renderer/SwapChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class SwapChain
virtual void recreate() = 0;

virtual HANDLE getShareHandle() {return mShareHandle;};
virtual void* getKeyedMutex() {return NULL;};

protected:
rx::NativeWindow mNativeWindow; // Handler for the Window that the surface is created for.
Expand Down
21 changes: 20 additions & 1 deletion gfx/angle/src/libGLESv2/renderer/d3d/d3d11/SwapChain11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@

#include "common/NativeWindow.h"

// This can be defined to other values like D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX as needed
#ifndef ANGLE_RESOURCE_SHARE_TYPE
#define ANGLE_RESOURCE_SHARE_TYPE D3D11_RESOURCE_MISC_SHARED
#endif

namespace rx
{

Expand All @@ -26,6 +31,7 @@ SwapChain11::SwapChain11(Renderer11 *renderer, rx::NativeWindow nativeWindow, HA
SwapChain(nativeWindow, shareHandle, backBufferFormat, depthBufferFormat)
{
mSwapChain = NULL;
mKeyedMutex = NULL;
mBackBufferTexture = NULL;
mBackBufferRTView = NULL;
mOffscreenTexture = NULL;
Expand Down Expand Up @@ -54,6 +60,7 @@ SwapChain11::~SwapChain11()
void SwapChain11::release()
{
SafeRelease(mSwapChain);
SafeRelease(mKeyedMutex);
SafeRelease(mBackBufferTexture);
SafeRelease(mBackBufferRTView);
SafeRelease(mOffscreenTexture);
Expand Down Expand Up @@ -161,7 +168,7 @@ EGLint SwapChain11::resetOffscreenTexture(int backbufferWidth, int backbufferHei
offscreenTextureDesc.Usage = D3D11_USAGE_DEFAULT;
offscreenTextureDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
offscreenTextureDesc.CPUAccessFlags = 0;
offscreenTextureDesc.MiscFlags = useSharedResource ? D3D11_RESOURCE_MISC_SHARED : 0;
offscreenTextureDesc.MiscFlags = useSharedResource ? ANGLE_RESOURCE_SHARE_TYPE : 0;

HRESULT result = device->CreateTexture2D(&offscreenTextureDesc, NULL, &mOffscreenTexture);

Expand Down Expand Up @@ -205,6 +212,18 @@ EGLint SwapChain11::resetOffscreenTexture(int backbufferWidth, int backbufferHei
}
}
}
IDXGIKeyedMutex *keyedMutex = NULL;
result = mOffscreenTexture->QueryInterface(__uuidof(IDXGIKeyedMutex), (void**)&keyedMutex);

if (FAILED(result))
{
mKeyedMutex = NULL;
}
else
{
mKeyedMutex = keyedMutex;
}

}


Expand Down
2 changes: 2 additions & 0 deletions gfx/angle/src/libGLESv2/renderer/d3d/d3d11/SwapChain11.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class SwapChain11 : public SwapChain

EGLint getWidth() const { return mWidth; }
EGLint getHeight() const { return mHeight; }
virtual void* getKeyedMutex() { return mKeyedMutex; };

static SwapChain11 *makeSwapChain11(SwapChain *swapChain);

Expand All @@ -57,6 +58,7 @@ class SwapChain11 : public SwapChain
bool mPassThroughResourcesInit;

IDXGISwapChain *mSwapChain;
IDXGIKeyedMutex *mKeyedMutex;

ID3D11Texture2D *mBackBufferTexture;
ID3D11RenderTargetView *mBackBufferRTView;
Expand Down

0 comments on commit 6489380

Please sign in to comment.