Control the creation of DX9 or DX11 renderers through eglGetDisplay.

TRAC #23029 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@2223 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 68b07547
...@@ -306,6 +306,12 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay ...@@ -306,6 +306,12 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay
#define EGL_SOFTWARE_DISPLAY_ANGLE ((EGLNativeDisplayType)-1) #define EGL_SOFTWARE_DISPLAY_ANGLE ((EGLNativeDisplayType)-1)
#endif #endif
#ifndef EGL_ANGLE_direct3d_display
#define EGL_ANGLE_direct3d_display 1
#define EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE ((EGLNativeDisplayType)-2)
#define EGL_D3D11_ONLY_DISPLAY_ANGLE ((EGLNativeDisplayType)-3)
#endif
#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle #ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle
#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1 #define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1
#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200 #define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200
......
// //
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -37,32 +37,17 @@ egl::Display *Display::getDisplay(EGLNativeDisplayType displayId) ...@@ -37,32 +37,17 @@ egl::Display *Display::getDisplay(EGLNativeDisplayType displayId)
{ {
return displays[displayId]; return displays[displayId];
} }
// FIXME: Check if displayId is a valid display device context
egl::Display *display = NULL; egl::Display *display = new egl::Display(displayId, (HDC)displayId);
if (displayId == EGL_DEFAULT_DISPLAY)
{
display = new egl::Display(displayId, (HDC)NULL, false);
}
else if (displayId == EGL_SOFTWARE_DISPLAY_ANGLE)
{
display = new egl::Display(displayId, (HDC)NULL, true);
}
else
{
// FIXME: Check if displayId is a valid display device context
display = new egl::Display(displayId, (HDC)displayId, false);
}
displays[displayId] = display; displays[displayId] = display;
return display; return display;
} }
Display::Display(EGLNativeDisplayType displayId, HDC deviceContext, bool software) : mDc(deviceContext) Display::Display(EGLNativeDisplayType displayId, HDC deviceContext) : mDc(deviceContext)
{ {
mSoftwareDevice = software;
mDisplayId = displayId; mDisplayId = displayId;
mRenderer = NULL; mRenderer = NULL;
} }
...@@ -86,7 +71,7 @@ bool Display::initialize() ...@@ -86,7 +71,7 @@ bool Display::initialize()
return true; return true;
} }
mRenderer = glCreateRenderer(this, mDc, mSoftwareDevice); mRenderer = glCreateRenderer(this, mDc, mDisplayId);
if (!mRenderer) if (!mRenderer)
{ {
......
// //
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -64,7 +64,7 @@ class Display ...@@ -64,7 +64,7 @@ class Display
private: private:
DISALLOW_COPY_AND_ASSIGN(Display); DISALLOW_COPY_AND_ASSIGN(Display);
Display(EGLNativeDisplayType displayId, HDC deviceContext, bool software); Display(EGLNativeDisplayType displayId, HDC deviceContext);
bool restoreLostDevice(); bool restoreLostDevice();
......
// //
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -58,7 +58,7 @@ gl::Context *glCreateContext(const gl::Context *shareContext, rx::Renderer *rend ...@@ -58,7 +58,7 @@ gl::Context *glCreateContext(const gl::Context *shareContext, rx::Renderer *rend
void glDestroyContext(gl::Context *context); void glDestroyContext(gl::Context *context);
void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *surface); void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *surface);
gl::Context *glGetCurrentContext(); gl::Context *glGetCurrentContext();
rx::Renderer *glCreateRenderer(egl::Display *display, HDC hDc, bool softwareDevice); rx::Renderer *glCreateRenderer(egl::Display *display, HDC hDc, EGLNativeDisplayType displayId);
void glDestroyRenderer(rx::Renderer *renderer); void glDestroyRenderer(rx::Renderer *renderer);
__eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname); __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
// Renderer.cpp: Implements EGL dependencies for creating and destroying Renderer instances. // Renderer.cpp: Implements EGL dependencies for creating and destroying Renderer instances.
#include <EGL/eglext.h>
#include "libGLESv2/main.h" #include "libGLESv2/main.h"
#include "libGLESv2/Program.h" #include "libGLESv2/Program.h"
#include "libGLESv2/renderer/Renderer.h" #include "libGLESv2/renderer/Renderer.h"
...@@ -15,7 +16,7 @@ ...@@ -15,7 +16,7 @@
#include "libGLESv2/utilities.h" #include "libGLESv2/utilities.h"
#if !defined(ANGLE_ENABLE_D3D11) #if !defined(ANGLE_ENABLE_D3D11)
// Enables use of the Direct3D 11 API, when available // Enables use of the Direct3D 11 API for a default display, when available
#define ANGLE_ENABLE_D3D11 0 #define ANGLE_ENABLE_D3D11 0
#endif #endif
...@@ -166,12 +167,14 @@ ShaderBlob *Renderer::compileToBinary(gl::InfoLog &infoLog, const char *hlsl, co ...@@ -166,12 +167,14 @@ ShaderBlob *Renderer::compileToBinary(gl::InfoLog &infoLog, const char *hlsl, co
extern "C" extern "C"
{ {
rx::Renderer *glCreateRenderer(egl::Display *display, HDC hDc, bool softwareDevice) rx::Renderer *glCreateRenderer(egl::Display *display, HDC hDc, EGLNativeDisplayType displayId)
{ {
rx::Renderer *renderer = NULL; rx::Renderer *renderer = NULL;
EGLint status = EGL_BAD_ALLOC; EGLint status = EGL_BAD_ALLOC;
if (ANGLE_ENABLE_D3D11) if (ANGLE_ENABLE_D3D11 ||
displayId == EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE ||
displayId == EGL_D3D11_ONLY_DISPLAY_ANGLE)
{ {
renderer = new rx::Renderer11(display, hDc); renderer = new rx::Renderer11(display, hDc);
...@@ -184,11 +187,16 @@ rx::Renderer *glCreateRenderer(egl::Display *display, HDC hDc, bool softwareDevi ...@@ -184,11 +187,16 @@ rx::Renderer *glCreateRenderer(egl::Display *display, HDC hDc, bool softwareDevi
{ {
return renderer; return renderer;
} }
else if (displayId == EGL_D3D11_ONLY_DISPLAY_ANGLE)
{
return NULL;
}
// Failed to create a D3D11 renderer, try creating a D3D9 renderer // Failed to create a D3D11 renderer, try creating a D3D9 renderer
delete renderer; delete renderer;
} }
bool softwareDevice = (displayId == EGL_SOFTWARE_DISPLAY_ANGLE);
renderer = new rx::Renderer9(display, hDc, softwareDevice); renderer = new rx::Renderer9(display, hDc, softwareDevice);
if (renderer) if (renderer)
......
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