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 @@
#include "Display.h"
#include "Texture2D.hpp"
#include "libGLESv2/Image.hpp"
#include "libGLESv2/Device.hpp"
#include "common/debug.h"
#include "Main/FrameBuffer.hpp"
......@@ -128,13 +127,6 @@ bool Surface::reset()
bool Surface::reset(int backBufferWidth, int backBufferHeight)
{
gl::Device *device = mDisplay->getDevice();
if(device == NULL)
{
return false;
}
release();
if(mWindow)
......@@ -160,7 +152,7 @@ bool Surface::reset(int backBufferWidth, int backBufferHeight)
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)
{
......
......@@ -94,6 +94,7 @@ CONSTRUCTOR static bool eglAttachProcess()
gl::makeCurrent = (void (*)(egl::Context*, egl::Display*, egl::Surface*))getProcAddress(libGLESv2, "glMakeCurrent");
gl::getProcAddress = (__eglMustCastToProperFunctionPointerType (*)(const char*))getProcAddress(libGLESv2, "glGetProcAddress");
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");
return libGLESv2 != 0;
......@@ -267,6 +268,7 @@ namespace gl
egl::Context *(*getCurrentContext)() = 0;
__eglMustCastToProperFunctionPointerType (*getProcAddress)(const char *procname) = 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;
}
......
......@@ -78,6 +78,7 @@ namespace egl
namespace sw
{
class FrameBuffer;
enum Format : unsigned char;
}
// libGLESv2 dependencies
......@@ -91,6 +92,7 @@ namespace gl
extern void (*makeCurrent)(egl::Context *context, egl::Display *display, egl::Surface *surface);
extern __eglMustCastToProperFunctionPointerType (*getProcAddress)(const char *procname);
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);
}
......
......@@ -732,4 +732,48 @@ extern "C"
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
createFrameBuffer @172
createBackBuffer @173
createDevice @174
createDepthStencil @175
Register
\ No newline at end of file
......@@ -1165,4 +1165,48 @@ extern "C"
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
createFrameBuffer @172
createBackBuffer @173
createDevice @174
createDepthStencil @175
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