Commit b387caa6 by Nicolas Capens Committed by Nicolas Capens

Create the depth/stencil buffer independently from the device.

BUG=18110152 Change-Id: Ie500fbac3697f877b30c38acfc68004e711c6e0f Reviewed-on: https://swiftshader-review.googlesource.com/1263Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 7ce51fcf
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "Display.h" #include "Display.h"
#include "Texture2D.hpp" #include "Texture2D.hpp"
#include "libGLESv2/Image.hpp" #include "libGLESv2/Image.hpp"
#include "libGLESv2/Device.hpp"
#include "common/debug.h" #include "common/debug.h"
#include "Main/FrameBuffer.hpp" #include "Main/FrameBuffer.hpp"
...@@ -128,13 +127,6 @@ bool Surface::reset() ...@@ -128,13 +127,6 @@ bool Surface::reset()
bool Surface::reset(int backBufferWidth, int backBufferHeight) bool Surface::reset(int backBufferWidth, int backBufferHeight)
{ {
gl::Device *device = mDisplay->getDevice();
if(device == NULL)
{
return false;
}
release(); release();
if(mWindow) if(mWindow)
...@@ -160,7 +152,7 @@ bool Surface::reset(int backBufferWidth, int backBufferHeight) ...@@ -160,7 +152,7 @@ bool Surface::reset(int backBufferWidth, int backBufferHeight)
if(mConfig->mDepthStencilFormat != sw::FORMAT_NULL) if(mConfig->mDepthStencilFormat != sw::FORMAT_NULL)
{ {
mDepthStencil = device->createDepthStencilSurface(backBufferWidth, backBufferHeight, mConfig->mDepthStencilFormat, 1, false); mDepthStencil = gl::createDepthStencil(backBufferWidth, backBufferHeight, mConfig->mDepthStencilFormat, 1, false);
if(!mDepthStencil) if(!mDepthStencil)
{ {
......
...@@ -94,6 +94,7 @@ CONSTRUCTOR static bool eglAttachProcess() ...@@ -94,6 +94,7 @@ CONSTRUCTOR static bool eglAttachProcess()
gl::makeCurrent = (void (*)(egl::Context*, egl::Display*, egl::Surface*))getProcAddress(libGLESv2, "glMakeCurrent"); gl::makeCurrent = (void (*)(egl::Context*, egl::Display*, egl::Surface*))getProcAddress(libGLESv2, "glMakeCurrent");
gl::getProcAddress = (__eglMustCastToProperFunctionPointerType (*)(const char*))getProcAddress(libGLESv2, "glGetProcAddress"); gl::getProcAddress = (__eglMustCastToProperFunctionPointerType (*)(const char*))getProcAddress(libGLESv2, "glGetProcAddress");
gl::createBackBuffer = (gl::Image *(*)(int, int, const egl::Config*))getProcAddress(libGLESv2, "createBackBuffer"); gl::createBackBuffer = (gl::Image *(*)(int, int, const egl::Config*))getProcAddress(libGLESv2, "createBackBuffer");
gl::createDepthStencil = (gl::Image *(*)(unsigned int, unsigned int, sw::Format, int, bool))getProcAddress(libGLESv2, "createDepthStencil");
gl::createFrameBuffer = (sw::FrameBuffer *(*)(EGLNativeDisplayType, EGLNativeWindowType, int, int))getProcAddress(libGLESv2, "createFrameBuffer"); gl::createFrameBuffer = (sw::FrameBuffer *(*)(EGLNativeDisplayType, EGLNativeWindowType, int, int))getProcAddress(libGLESv2, "createFrameBuffer");
return libGLESv2 != 0; return libGLESv2 != 0;
...@@ -267,6 +268,7 @@ namespace gl ...@@ -267,6 +268,7 @@ namespace gl
egl::Context *(*getCurrentContext)() = 0; egl::Context *(*getCurrentContext)() = 0;
__eglMustCastToProperFunctionPointerType (*getProcAddress)(const char *procname) = 0; __eglMustCastToProperFunctionPointerType (*getProcAddress)(const char *procname) = 0;
Image *(*createBackBuffer)(int width, int height, const egl::Config *config) = 0; Image *(*createBackBuffer)(int width, int height, const egl::Config *config) = 0;
Image *(*createDepthStencil)(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard) = 0;
sw::FrameBuffer *(*createFrameBuffer)(EGLNativeDisplayType display, EGLNativeWindowType window, int width, int height) = 0; sw::FrameBuffer *(*createFrameBuffer)(EGLNativeDisplayType display, EGLNativeWindowType window, int width, int height) = 0;
} }
......
...@@ -78,6 +78,7 @@ namespace egl ...@@ -78,6 +78,7 @@ namespace egl
namespace sw namespace sw
{ {
class FrameBuffer; class FrameBuffer;
enum Format : unsigned char;
} }
// libGLESv2 dependencies // libGLESv2 dependencies
...@@ -91,6 +92,7 @@ namespace gl ...@@ -91,6 +92,7 @@ namespace gl
extern void (*makeCurrent)(egl::Context *context, egl::Display *display, egl::Surface *surface); extern void (*makeCurrent)(egl::Context *context, egl::Display *display, egl::Surface *surface);
extern __eglMustCastToProperFunctionPointerType (*getProcAddress)(const char *procname); extern __eglMustCastToProperFunctionPointerType (*getProcAddress)(const char *procname);
extern Image *(*createBackBuffer)(int width, int height, const egl::Config *config); extern Image *(*createBackBuffer)(int width, int height, const egl::Config *config);
extern Image *(*createDepthStencil)(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard);
extern sw::FrameBuffer *(*createFrameBuffer)(EGLNativeDisplayType display, EGLNativeWindowType window, int width, int height); extern sw::FrameBuffer *(*createFrameBuffer)(EGLNativeDisplayType display, EGLNativeWindowType window, int width, int height);
} }
......
...@@ -732,4 +732,48 @@ extern "C" ...@@ -732,4 +732,48 @@ extern "C"
return 0; return 0;
} }
gl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard)
{
if(width == 0 || height == 0 || height > OUTLINE_RESOLUTION)
{
ERR("Invalid parameters");
return 0;
}
bool lockable = true;
switch(format)
{
// case sw::FORMAT_D15S1:
case sw::FORMAT_D24S8:
case sw::FORMAT_D24X8:
// case sw::FORMAT_D24X4S4:
case sw::FORMAT_D24FS8:
case sw::FORMAT_D32:
case sw::FORMAT_D16:
lockable = false;
break;
// case sw::FORMAT_S8_LOCKABLE:
// case sw::FORMAT_D16_LOCKABLE:
case sw::FORMAT_D32F_LOCKABLE:
// case sw::FORMAT_D32_LOCKABLE:
case sw::FORMAT_DF24S8:
case sw::FORMAT_DF16S8:
lockable = true;
break;
default:
UNREACHABLE();
}
gl::Image *surface = new gl::Image(0, width, height, format, GL_NONE_OES, GL_NONE_OES, multiSampleDepth, lockable, true);
if(!surface)
{
ERR("Out of memory");
return 0;
}
return surface;
}
} }
...@@ -153,5 +153,6 @@ EXPORTS ...@@ -153,5 +153,6 @@ EXPORTS
createFrameBuffer @172 createFrameBuffer @172
createBackBuffer @173 createBackBuffer @173
createDevice @174 createDevice @174
createDepthStencil @175
Register Register
\ No newline at end of file
...@@ -1165,4 +1165,48 @@ extern "C" ...@@ -1165,4 +1165,48 @@ extern "C"
return 0; return 0;
} }
gl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard)
{
if(width == 0 || height == 0 || height > OUTLINE_RESOLUTION)
{
ERR("Invalid parameters");
return 0;
}
bool lockable = true;
switch(format)
{
// case sw::FORMAT_D15S1:
case sw::FORMAT_D24S8:
case sw::FORMAT_D24X8:
// case sw::FORMAT_D24X4S4:
case sw::FORMAT_D24FS8:
case sw::FORMAT_D32:
case sw::FORMAT_D16:
lockable = false;
break;
// case sw::FORMAT_S8_LOCKABLE:
// case sw::FORMAT_D16_LOCKABLE:
case sw::FORMAT_D32F_LOCKABLE:
// case sw::FORMAT_D32_LOCKABLE:
case sw::FORMAT_DF24S8:
case sw::FORMAT_DF16S8:
lockable = true;
break;
default:
UNREACHABLE();
}
gl::Image *surface = new gl::Image(0, width, height, format, GL_NONE, GL_NONE, multiSampleDepth, lockable, true);
if(!surface)
{
ERR("Out of memory");
return 0;
}
return surface;
}
} }
...@@ -176,5 +176,6 @@ EXPORTS ...@@ -176,5 +176,6 @@ EXPORTS
createFrameBuffer @172 createFrameBuffer @172
createBackBuffer @173 createBackBuffer @173
createDevice @174 createDevice @174
createDepthStencil @175
Register Register
\ No newline at end of file
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