Implement GL_OES_packed_depth_stencil
TRAC #12336
Signed-off-by: Andrew Lewycky
Signed-off-by: Daniel Koch
Author: Shannon Woods
git-svn-id: https://angleproject.googlecode.com/svn/trunk@358 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Renderbuffer.cpp b/src/libGLESv2/Renderbuffer.cpp
index edd38ec..318b862 100644
--- a/src/libGLESv2/Renderbuffer.cpp
+++ b/src/libGLESv2/Renderbuffer.cpp
@@ -199,7 +199,7 @@
return mRenderTarget;
}
-Depthbuffer::Depthbuffer(IDirect3DSurface9 *depthStencil) : mDepthStencil(depthStencil)
+DepthStencilbuffer::DepthStencilbuffer(IDirect3DSurface9 *depthStencil) : mDepthStencil(depthStencil)
{
if (depthStencil)
{
@@ -209,13 +209,11 @@
depthStencil->GetDesc(&description);
setSize(description.Width, description.Height);
- mFormat = GL_DEPTH_COMPONENT16; // If the renderbuffer parameters are queried, the calling function
- // will expect one of the valid renderbuffer formats for use in
- // glRenderbufferStorage
+ mFormat = GL_DEPTH24_STENCIL8_OES;
}
}
-Depthbuffer::Depthbuffer(int width, int height)
+DepthStencilbuffer::DepthStencilbuffer(int width, int height)
{
IDirect3DDevice9 *device = getDevice();
@@ -234,9 +232,7 @@
if (mDepthStencil)
{
setSize(width, height);
- mFormat = GL_DEPTH_COMPONENT16; // If the renderbuffer parameters are queried, the calling function
- // will expect one of the valid renderbuffer formats for use in
- // glRenderbufferStorage
+ mFormat = GL_DEPTH24_STENCIL8_OES;
}
else
{
@@ -245,7 +241,7 @@
}
}
-Depthbuffer::~Depthbuffer()
+DepthStencilbuffer::~DepthStencilbuffer()
{
if (mDepthStencil)
{
@@ -253,12 +249,17 @@
}
}
-bool Depthbuffer::isDepthbuffer()
+bool DepthStencilbuffer::isDepthbuffer()
{
return true;
}
-GLuint Depthbuffer::getDepthSize()
+bool DepthStencilbuffer::isStencilbuffer()
+{
+ return true;
+}
+
+GLuint DepthStencilbuffer::getDepthSize()
{
if (mDepthStencil)
{
@@ -271,66 +272,7 @@
return 0;
}
-IDirect3DSurface9 *Depthbuffer::getDepthStencil()
-{
- return mDepthStencil;
-}
-
-Stencilbuffer::Stencilbuffer(IDirect3DSurface9 *depthStencil) : mDepthStencil(depthStencil)
-{
- if (depthStencil)
- {
- depthStencil->AddRef();
-
- D3DSURFACE_DESC description;
- depthStencil->GetDesc(&description);
-
- setSize(description.Width, description.Height);
- mFormat = GL_STENCIL_INDEX8; // If the renderbuffer parameters are queried, the calling function
- // will expect one of the valid renderbuffer formats for use in
- // glRenderbufferStorage
- }
-}
-
-Stencilbuffer::Stencilbuffer(int width, int height)
-{
- IDirect3DDevice9 *device = getDevice();
-
- mDepthStencil = NULL;
- HRESULT result = device->CreateDepthStencilSurface(width, height, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, 0, FALSE, &mDepthStencil, 0);
-
- if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY)
- {
- error(GL_OUT_OF_MEMORY);
-
- return;
- }
-
- ASSERT(SUCCEEDED(result));
-
- if (mDepthStencil)
- {
- setSize(width, height);
- mFormat = GL_STENCIL_INDEX8; // If the renderbuffer parameters are queried, the calling function
- // will expect one of the valid renderbuffer formats for use in
- // glRenderbufferStorage
- }
- else
- {
- setSize(0, 0);
- mFormat = GL_RGBA4; //default format
- }
-}
-
-Stencilbuffer::~Stencilbuffer()
-{
- if (mDepthStencil)
- {
- mDepthStencil->Release();
- }
-}
-
-GLuint Stencilbuffer::getStencilSize()
+GLuint DepthStencilbuffer::getStencilSize()
{
if (mDepthStencil)
{
@@ -343,13 +285,80 @@
return 0;
}
-bool Stencilbuffer::isStencilbuffer()
+IDirect3DSurface9 *DepthStencilbuffer::getDepthStencil()
+{
+ return mDepthStencil;
+}
+
+Depthbuffer::Depthbuffer(IDirect3DSurface9 *depthStencil) : DepthStencilbuffer(depthStencil)
+{
+ if (depthStencil)
+ {
+ mFormat = GL_DEPTH_COMPONENT16; // If the renderbuffer parameters are queried, the calling function
+ // will expect one of the valid renderbuffer formats for use in
+ // glRenderbufferStorage
+ }
+}
+
+Depthbuffer::Depthbuffer(int width, int height) : DepthStencilbuffer(width, height)
+{
+ if (getDepthStencil())
+ {
+ mFormat = GL_DEPTH_COMPONENT16; // If the renderbuffer parameters are queried, the calling function
+ // will expect one of the valid renderbuffer formats for use in
+ // glRenderbufferStorage
+ }
+}
+
+Depthbuffer::~Depthbuffer()
+{
+}
+
+bool Depthbuffer::isDepthbuffer()
{
return true;
}
-IDirect3DSurface9 *Stencilbuffer::getDepthStencil()
+bool Depthbuffer::isStencilbuffer()
{
- return mDepthStencil;
+ return false;
+}
+
+Stencilbuffer::Stencilbuffer(IDirect3DSurface9 *depthStencil) : DepthStencilbuffer(depthStencil)
+{
+ if (depthStencil)
+ {
+ mFormat = GL_STENCIL_INDEX8; // If the renderbuffer parameters are queried, the calling function
+ // will expect one of the valid renderbuffer formats for use in
+ // glRenderbufferStorage
+ }
+ else
+ {
+ mFormat = GL_RGBA4; //default format
+ }
+}
+
+Stencilbuffer::Stencilbuffer(int width, int height) : DepthStencilbuffer(width, height)
+{
+ if (getDepthStencil())
+ {
+ mFormat = GL_STENCIL_INDEX8; // If the renderbuffer parameters are queried, the calling function
+ // will expect one of the valid renderbuffer formats for use in
+ // glRenderbufferStorage
+ }
+}
+
+Stencilbuffer::~Stencilbuffer()
+{
+}
+
+bool Stencilbuffer::isDepthbuffer()
+{
+ return false;
+}
+
+bool Stencilbuffer::isStencilbuffer()
+{
+ return true;
}
}