Make egl::Surface independent of the Renderer implementation.

TRAC #21926 Signed-off-by: Daniel Koch Signed-off-by: Geoff Lang Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1427 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 38380883
...@@ -28,7 +28,7 @@ namespace egl ...@@ -28,7 +28,7 @@ namespace egl
Surface::Surface(Display *display, const Config *config, HWND window, EGLint postSubBufferSupported) Surface::Surface(Display *display, const Config *config, HWND window, EGLint postSubBufferSupported)
: mDisplay(display), mConfig(config), mWindow(window), mPostSubBufferSupported(postSubBufferSupported) : mDisplay(display), mConfig(config), mWindow(window), mPostSubBufferSupported(postSubBufferSupported)
{ {
mRenderer = mDisplay->getRenderer9(); mRenderer = mDisplay->getRenderer();
mSwapChain = NULL; mSwapChain = NULL;
mShareHandle = NULL; mShareHandle = NULL;
mTexture = NULL; mTexture = NULL;
...@@ -97,7 +97,7 @@ bool Surface::initialize() ...@@ -97,7 +97,7 @@ bool Surface::initialize()
void Surface::release() void Surface::release()
{ {
glDestroySwapChain(mSwapChain); delete mSwapChain;
mSwapChain = NULL; mSwapChain = NULL;
if (mTexture) if (mTexture)
...@@ -135,8 +135,9 @@ bool Surface::resetSwapChain() ...@@ -135,8 +135,9 @@ bool Surface::resetSwapChain()
height = mHeight; height = mHeight;
} }
mSwapChain = glCreateSwapChain(mRenderer, mWindow, mShareHandle, mSwapChain = mRenderer->createSwapChain(mWindow, mShareHandle,
mConfig->mRenderTargetFormat, mConfig->mDepthStencilFormat); mConfig->mRenderTargetFormat,
mConfig->mDepthStencilFormat);
if (!mSwapChain) if (!mSwapChain)
{ {
return error(EGL_BAD_ALLOC, false); return error(EGL_BAD_ALLOC, false);
...@@ -144,7 +145,7 @@ bool Surface::resetSwapChain() ...@@ -144,7 +145,7 @@ bool Surface::resetSwapChain()
if (!resetSwapChain(width, height)) if (!resetSwapChain(width, height))
{ {
glDestroySwapChain(mSwapChain); delete mSwapChain;
mSwapChain = NULL; mSwapChain = NULL;
return false; return false;
} }
......
...@@ -22,7 +22,7 @@ class Texture2D; ...@@ -22,7 +22,7 @@ class Texture2D;
} }
namespace rx namespace rx
{ {
class Renderer9; class Renderer;
class SwapChain; class SwapChain;
} }
...@@ -68,7 +68,7 @@ private: ...@@ -68,7 +68,7 @@ private:
DISALLOW_COPY_AND_ASSIGN(Surface); DISALLOW_COPY_AND_ASSIGN(Surface);
Display *const mDisplay; Display *const mDisplay;
rx::Renderer9 *mRenderer; // D3D9_REPLACE rx::Renderer *mRenderer;
HANDLE mShareHandle; HANDLE mShareHandle;
rx::SwapChain *mSwapChain; rx::SwapChain *mSwapChain;
......
...@@ -1924,7 +1924,7 @@ void Context::applyState(GLenum drawMode) ...@@ -1924,7 +1924,7 @@ void Context::applyState(GLenum drawMode)
GLint alwaysFront = !isTriangleMode(drawMode); GLint alwaysFront = !isTriangleMode(drawMode);
programBinary->setUniform1iv(pointsOrLines, 1, &alwaysFront); programBinary->setUniform1iv(pointsOrLines, 1, &alwaysFront);
const gl::Renderbuffer *depthbuffer = framebufferObject->getDepthbuffer(); const gl::Renderbuffer *depthbuffer = framebufferObject->getDepthbuffer();
unsigned int depthSize = depthbuffer ? depthbuffer->getDepthSize() : 0; unsigned int depthSize = depthbuffer ? depthbuffer->getDepthSize() : 0;
mRenderer->setRasterizerState(mState.rasterizer, depthSize); mRenderer->setRasterizerState(mState.rasterizer, depthSize);
...@@ -4076,16 +4076,4 @@ gl::Context *glGetCurrentContext() ...@@ -4076,16 +4076,4 @@ gl::Context *glGetCurrentContext()
return gl::getContext(); return gl::getContext();
} }
rx::SwapChain *glCreateSwapChain(rx::Renderer9 *renderer, HWND window, HANDLE shareHandle,
GLenum backBufferFormat, GLenum depthBufferFormat)
{
return new rx::SwapChain(renderer, window, shareHandle, backBufferFormat, depthBufferFormat);
}
void glDestroySwapChain(rx::SwapChain *swapChain)
{
delete swapChain;
}
} }
...@@ -181,6 +181,4 @@ EXPORTS ...@@ -181,6 +181,4 @@ EXPORTS
glGetProcAddress @148 NONAME glGetProcAddress @148 NONAME
glBindTexImage @158 NONAME glBindTexImage @158 NONAME
glCreateRenderer @177 NONAME glCreateRenderer @177 NONAME
glDestroyRenderer @178 NONAME glDestroyRenderer @178 NONAME
glCreateSwapChain @179 NONAME \ No newline at end of file
glDestroySwapChain @180 NONAME
...@@ -54,9 +54,6 @@ void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *su ...@@ -54,9 +54,6 @@ void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *su
gl::Context *glGetCurrentContext(); gl::Context *glGetCurrentContext();
rx::Renderer *glCreateRenderer(egl::Display *display, HDC hDc, bool softwareDevice); rx::Renderer *glCreateRenderer(egl::Display *display, HDC hDc, bool softwareDevice);
void glDestroyRenderer(rx::Renderer *renderer); void glDestroyRenderer(rx::Renderer *renderer);
rx::SwapChain *glCreateSwapChain(rx::Renderer9 *renderer, HWND window, HANDLE shareHandle,
GLenum backBufferFormat, GLenum depthBufferFormat); // D3D9_REPLACE
void glDestroySwapChain(rx::SwapChain *swapChain);
__eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname); __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname);
bool __stdcall glBindTexImage(egl::Surface *surface); bool __stdcall glBindTexImage(egl::Surface *surface);
......
...@@ -68,6 +68,8 @@ class Renderer ...@@ -68,6 +68,8 @@ class Renderer
virtual void sync(bool block) = 0; virtual void sync(bool block) = 0;
virtual SwapChain *createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat) = 0;
virtual void setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &sampler) = 0; virtual void setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &sampler) = 0;
virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture) = 0; virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture) = 0;
......
...@@ -31,6 +31,8 @@ Renderer11::Renderer11(egl::Display *display, HDC hDc) : Renderer(display), mDc( ...@@ -31,6 +31,8 @@ Renderer11::Renderer11(egl::Display *display, HDC hDc) : Renderer(display), mDc(
mD3d11Module = NULL; mD3d11Module = NULL;
mDxgiModule = NULL; mDxgiModule = NULL;
mDeviceLost = false;
mDevice = NULL; mDevice = NULL;
mDeviceContext = NULL; mDeviceContext = NULL;
mDxgiAdapter = NULL; mDxgiAdapter = NULL;
...@@ -224,6 +226,16 @@ void Renderer11::sync(bool block) ...@@ -224,6 +226,16 @@ void Renderer11::sync(bool block)
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
SwapChain *Renderer11::createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat)
{
// TODO
UNIMPLEMENTED();
//return new rx::SwapChain(this, window, shareHandle, backBufferFormat, depthBufferFormat);
return NULL;
}
void Renderer11::setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &samplerState) void Renderer11::setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &samplerState)
{ {
// TODO // TODO
...@@ -298,7 +310,7 @@ bool Renderer11::testDeviceLost(bool notify) ...@@ -298,7 +310,7 @@ bool Renderer11::testDeviceLost(bool notify)
bool isLost = false; bool isLost = false;
// TODO // TODO
UNIMPLEMENTED(); //UNIMPLEMENTED();
if (isLost) if (isLost)
{ {
...@@ -484,7 +496,7 @@ bool Renderer11::getInstancingSupport() const ...@@ -484,7 +496,7 @@ bool Renderer11::getInstancingSupport() const
bool Renderer11::getShareHandleSupport() const bool Renderer11::getShareHandleSupport() const
{ {
// TODO // TODO
UNIMPLEMENTED(); //UNIMPLEMENTED();
// PIX doesn't seem to support using share handles, so disable them. // PIX doesn't seem to support using share handles, so disable them.
return false && !gl::perfActive(); return false && !gl::perfActive();
......
...@@ -42,6 +42,8 @@ class Renderer11 : public Renderer ...@@ -42,6 +42,8 @@ class Renderer11 : public Renderer
virtual void sync(bool block); virtual void sync(bool block);
virtual SwapChain *createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat);
virtual void setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &sampler); virtual void setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &sampler);
virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture); virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture);
......
...@@ -502,6 +502,11 @@ void Renderer9::sync(bool block) ...@@ -502,6 +502,11 @@ void Renderer9::sync(bool block)
} }
} }
SwapChain *Renderer9::createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat)
{
return new rx::SwapChain(this, window, shareHandle, backBufferFormat, depthBufferFormat);
}
// D3D9_REPLACE // D3D9_REPLACE
IDirect3DQuery9* Renderer9::allocateEventQuery() IDirect3DQuery9* Renderer9::allocateEventQuery()
{ {
......
...@@ -44,6 +44,9 @@ class Renderer9 : public Renderer ...@@ -44,6 +44,9 @@ class Renderer9 : public Renderer
virtual void endScene(); virtual void endScene();
virtual void sync(bool block); virtual void sync(bool block);
virtual SwapChain *createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat);
IDirect3DQuery9* allocateEventQuery(); IDirect3DQuery9* allocateEventQuery();
void freeEventQuery(IDirect3DQuery9* query); void freeEventQuery(IDirect3DQuery9* query);
......
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