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/es3proto@2328 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 094cc410
......@@ -305,6 +305,12 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay
#define EGL_SOFTWARE_DISPLAY_ANGLE ((EGLNativeDisplayType)-1)
#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
#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1
#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200
......
......@@ -37,32 +37,17 @@ egl::Display *Display::getDisplay(EGLNativeDisplayType displayId)
{
return displays[displayId];
}
// FIXME: Check if displayId is a valid display device context
egl::Display *display = NULL;
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);
}
egl::Display *display = new egl::Display(displayId, (HDC)displayId);
displays[displayId] = 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;
mRenderer = NULL;
}
......@@ -86,7 +71,7 @@ bool Display::initialize()
return true;
}
mRenderer = glCreateRenderer(this, mDc, mSoftwareDevice);
mRenderer = glCreateRenderer(this, mDc, mDisplayId);
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
// found in the LICENSE file.
//
......@@ -64,7 +64,7 @@ class Display
private:
DISALLOW_COPY_AND_ASSIGN(Display);
Display(EGLNativeDisplayType displayId, HDC deviceContext, bool software);
Display(EGLNativeDisplayType displayId, HDC deviceContext);
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
// found in the LICENSE file.
//
......@@ -58,7 +58,7 @@ gl::Context *glCreateContext(int clientVersion, const gl::Context *shareContext,
void glDestroyContext(gl::Context *context);
void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *surface);
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);
__eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname);
......
......@@ -7,6 +7,7 @@
// Renderer.cpp: Implements EGL dependencies for creating and destroying Renderer instances.
#include <EGL/eglext.h>
#include "libGLESv2/main.h"
#include "libGLESv2/Program.h"
#include "libGLESv2/renderer/Renderer.h"
......@@ -15,7 +16,7 @@
#include "libGLESv2/utilities.h"
#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
#endif
......@@ -171,12 +172,14 @@ ShaderBlob *Renderer::compileToBinary(gl::InfoLog &infoLog, const char *hlsl, co
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;
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);
......@@ -189,11 +192,16 @@ rx::Renderer *glCreateRenderer(egl::Display *display, HDC hDc, bool softwareDevi
{
return renderer;
}
else if (displayId == EGL_D3D11_ONLY_DISPLAY_ANGLE)
{
return NULL;
}
// Failed to create a D3D11 renderer, try creating a D3D9 renderer
delete renderer;
}
bool softwareDevice = (displayId == EGL_SOFTWARE_DISPLAY_ANGLE);
renderer = new rx::Renderer9(display, hDc, softwareDevice);
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