Commit 84d7cbc3 by jbauman@chromium.org

Add extension to create software device.

Add an extension so that users can receive a device that renders in software. Currently this is done by loading a swiftshader dll. BUG= TEST= Review URL: http://codereview.appspot.com/4631093 git-svn-id: https://angleproject.googlecode.com/svn/trunk@705 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent b481b23f
Name
ANGLE_software_display
Name Strings
EGL_ANGLE_software_display
Contributors
John Bauman
Daniel Koch
Contacts
John Bauman, Google Inc. (jbauman 'at' chromium.org)
Status
In progress
Version
Version 1, July 12, 2011
Number
EGL Extension #??
Dependencies
This extension is written against the wording of the EGL 1.4
Specification.
Overview
This extension allows for receiving a device that uses software rendering.
New Types
None
New Procedures and Functions
None
New Tokens
None
Additions to Chapter 3 of the EGL 1.4 Specification (EGL Functions and Errors)
Add before the last sentence of the first paragraph of section 3.2,
"Initialization":
"If <display_id> is EGL_SOFTWARE_DISPLAY_ANGLE, a display that will render
everything in software will be returned."
Issues
Revision History
Version 1, 2011/07/12 - first draft.
......@@ -228,6 +228,11 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay
#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200
#endif
#ifndef EGL_ANGLE_software_display
#define EGL_ANGLE_software_display
#define EGL_SOFTWARE_DISPLAY_ANGLE ((EGLNativeDisplayType)-1)
#endif
#ifdef __cplusplus
}
#endif
......
#define MAJOR_VERSION 0
#define MINOR_VERSION 0
#define BUILD_VERSION 0
#define BUILD_REVISION 704
#define BUILD_REVISION 705
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -11,6 +11,7 @@
#include "libEGL/Display.h"
#include <algorithm>
#include <map>
#include <vector>
#include "common/debug.h"
......@@ -31,7 +32,41 @@
namespace egl
{
Display::Display(HDC deviceContext) : mDc(deviceContext)
namespace
{
typedef std::map<EGLNativeDisplayType, Display*> DisplayMap;
DisplayMap displays;
}
egl::Display *Display::getDisplay(EGLNativeDisplayType displayId)
{
if (displays.find(displayId) != displays.end())
{
return displays[displayId];
}
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);
}
displays[displayId] = display;
return display;
}
Display::Display(EGLNativeDisplayType displayId, HDC deviceContext, bool software) : mDc(deviceContext)
{
mD3d9Module = NULL;
......@@ -51,11 +86,20 @@ Display::Display(HDC deviceContext) : mDc(deviceContext)
mMinSwapInterval = 1;
mMaxSwapInterval = 1;
mSoftwareDevice = software;
mDisplayId = displayId;
}
Display::~Display()
{
terminate();
DisplayMap::iterator thisDisplay = displays.find(mDisplayId);
if (thisDisplay != displays.end())
{
displays.erase(thisDisplay);
}
}
bool Display::initialize()
......@@ -65,7 +109,14 @@ bool Display::initialize()
return true;
}
mD3d9Module = GetModuleHandle(TEXT("d3d9.dll"));
if (mSoftwareDevice)
{
mD3d9Module = GetModuleHandle(TEXT("swiftshader_d3d9.dll"));
}
else
{
mD3d9Module = GetModuleHandle(TEXT("d3d9.dll"));
}
if (mD3d9Module == NULL)
{
terminate();
......@@ -856,6 +907,12 @@ D3DPRESENT_PARAMETERS Display::getDefaultPresentParameters()
void Display::initExtensionString()
{
mExtensionString += "EGL_ANGLE_query_surface_pointer ";
HMODULE swiftShader = GetModuleHandle(TEXT("swiftshader_d3d9.dll"));
if (swiftShader)
{
mExtensionString += "EGL_ANGLE_software_display ";
}
if (isD3d9ExDevice()) {
mExtensionString += "EGL_ANGLE_surface_d3d_texture_2d_share_handle ";
......
......@@ -29,8 +29,6 @@ namespace egl
class Display
{
public:
Display(HDC deviceContext);
~Display();
bool initialize();
......@@ -39,6 +37,8 @@ class Display
virtual void startScene();
virtual void endScene();
static egl::Display *getDisplay(EGLNativeDisplayType displayId);
bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig);
bool getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value);
......@@ -79,8 +79,11 @@ class Display
private:
DISALLOW_COPY_AND_ASSIGN(Display);
Display(EGLNativeDisplayType displayId, HDC deviceContext, bool software);
D3DPRESENT_PARAMETERS getDefaultPresentParameters();
EGLNativeDisplayType mDisplayId;
const HDC mDc;
HMODULE mD3d9Module;
......@@ -98,6 +101,7 @@ class Display
bool mSceneStarted;
EGLint mMaxSwapInterval;
EGLint mMinSwapInterval;
bool mSoftwareDevice;
typedef std::set<Surface*> SurfaceSet;
SurfaceSet mSurfaceSet;
......
......@@ -99,18 +99,7 @@ EGLDisplay __stdcall eglGetDisplay(EGLNativeDisplayType display_id)
try
{
// FIXME: Return the same EGLDisplay handle when display_id already created a display
if (display_id == EGL_DEFAULT_DISPLAY)
{
return new egl::Display((HDC)NULL);
}
else
{
// FIXME: Check if display_id is a valid display device context
return new egl::Display((HDC)display_id);
}
return egl::Display::getDisplay(display_id);
}
catch(std::bad_alloc&)
{
......
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