Commit b02a8ee6 by Alexis Hetu Committed by Alexis Hétu

Added support for more depth types

Added format arguments to DepthBuffer/DepthStencilBuffer constructors and added existing types to type conversion functions so that more than one depth/stencil format may be supported. Change-Id: Ifd60b896e93a1ba4d05a30f123a1322cdd5254a5 Reviewed-on: https://swiftshader-review.googlesource.com/4766Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 1410a682
......@@ -259,6 +259,8 @@ namespace es2
case FORMAT_D24FS8:
case FORMAT_D32:
case FORMAT_D16:
case FORMAT_D32F:
case FORMAT_D32F_COMPLEMENTARY:
lockable = false;
break;
// case FORMAT_S8_LOCKABLE:
......@@ -267,6 +269,8 @@ namespace es2
// case FORMAT_D32_LOCKABLE:
case FORMAT_DF24S8:
case FORMAT_DF16S8:
case FORMAT_D32FS8_TEXTURE:
case FORMAT_D32FS8_SHADOW:
lockable = true;
break;
default:
......
......@@ -544,15 +544,41 @@ DepthStencilbuffer::DepthStencilbuffer(egl::Image *depthStencil) : mDepthStencil
}
}
DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples) : mDepthStencil(nullptr)
DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLenum requestedFormat, GLsizei samples) : mDepthStencil(nullptr)
{
format = requestedFormat;
switch(requestedFormat)
{
case GL_STENCIL_INDEX8:
case GL_DEPTH_COMPONENT24:
case GL_DEPTH24_STENCIL8_OES:
internalFormat = sw::FORMAT_D24S8;
break;
case GL_DEPTH32F_STENCIL8:
internalFormat = sw::FORMAT_D32FS8_TEXTURE;
break;
case GL_DEPTH_COMPONENT16:
internalFormat = sw::FORMAT_D16;
break;
case GL_DEPTH_COMPONENT32_OES:
internalFormat = sw::FORMAT_D32;
break;
case GL_DEPTH_COMPONENT32F:
internalFormat = sw::FORMAT_D32F;
break;
default:
UNREACHABLE(requestedFormat);
format = GL_DEPTH24_STENCIL8_OES;
internalFormat = sw::FORMAT_D24S8;
}
Device *device = getDevice();
int supportedSamples = Context::getSupportedMultisampleCount(samples);
if(width > 0 && height > 0)
{
mDepthStencil = device->createDepthStencilSurface(width, height, sw::FORMAT_D24S8, supportedSamples, false);
mDepthStencil = device->createDepthStencilSurface(width, height, internalFormat, supportedSamples, false);
if(!mDepthStencil)
{
......@@ -563,8 +589,6 @@ DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples) :
mWidth = width;
mHeight = height;
format = GL_DEPTH24_STENCIL8_OES;
internalFormat = sw::FORMAT_D24S8;
mSamples = supportedSamples;
}
......@@ -616,14 +640,8 @@ Depthbuffer::Depthbuffer(egl::Image *depthStencil) : DepthStencilbuffer(depthSte
}
}
Depthbuffer::Depthbuffer(int width, int height, GLsizei samples) : DepthStencilbuffer(width, height, samples)
Depthbuffer::Depthbuffer(int width, int height, GLenum format, GLsizei samples) : DepthStencilbuffer(width, height, format, samples)
{
if(mDepthStencil)
{
format = 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()
......@@ -640,14 +658,8 @@ Stencilbuffer::Stencilbuffer(egl::Image *depthStencil) : DepthStencilbuffer(dept
}
}
Stencilbuffer::Stencilbuffer(int width, int height, GLsizei samples) : DepthStencilbuffer(width, height, samples)
Stencilbuffer::Stencilbuffer(int width, int height, GLsizei samples) : DepthStencilbuffer(width, height, GL_STENCIL_INDEX8, samples)
{
if(mDepthStencil)
{
format = 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()
......
......@@ -246,7 +246,7 @@ class DepthStencilbuffer : public RenderbufferStorage
{
public:
explicit DepthStencilbuffer(egl::Image *depthStencil);
DepthStencilbuffer(GLsizei width, GLsizei height, GLsizei samples);
DepthStencilbuffer(GLsizei width, GLsizei height, GLenum format, GLsizei samples);
~DepthStencilbuffer();
......@@ -262,7 +262,7 @@ class Depthbuffer : public DepthStencilbuffer
{
public:
explicit Depthbuffer(egl::Image *depthStencil);
Depthbuffer(GLsizei width, GLsizei height, GLsizei samples);
Depthbuffer(GLsizei width, GLsizei height, GLenum format, GLsizei samples);
virtual ~Depthbuffer();
};
......
......@@ -4766,7 +4766,7 @@ void RenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum
case GL_DEPTH_COMPONENT16:
case GL_DEPTH_COMPONENT24:
case GL_DEPTH_COMPONENT32_OES:
context->setRenderbufferStorage(new es2::Depthbuffer(width, height, samples));
context->setRenderbufferStorage(new es2::Depthbuffer(width, height, internalformat, samples));
break;
case GL_R8:
case GL_R8UI:
......@@ -4821,7 +4821,7 @@ void RenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum
}
// fall through
case GL_DEPTH24_STENCIL8_OES:
context->setRenderbufferStorage(new es2::DepthStencilbuffer(width, height, samples));
context->setRenderbufferStorage(new es2::DepthStencilbuffer(width, height, internalformat, samples));
break;
default:
return error(GL_INVALID_ENUM);
......
......@@ -1484,7 +1484,7 @@ GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisample(GLenum target, GLsi
case GL_DEPTH_COMPONENT24:
case GL_DEPTH_COMPONENT32_OES:
case GL_DEPTH_COMPONENT32F:
context->setRenderbufferStorage(new es2::Depthbuffer(width, height, samples));
context->setRenderbufferStorage(new es2::Depthbuffer(width, height, internalformat, samples));
break;
case GL_R8UI:
case GL_R8I:
......@@ -1531,7 +1531,7 @@ GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisample(GLenum target, GLsi
break;
case GL_DEPTH24_STENCIL8:
case GL_DEPTH32F_STENCIL8:
context->setRenderbufferStorage(new es2::DepthStencilbuffer(width, height, samples));
context->setRenderbufferStorage(new es2::DepthStencilbuffer(width, height, internalformat, samples));
break;
default:
......
......@@ -1356,6 +1356,8 @@ namespace sw2es
case sw::FORMAT_D24FS8:
case sw::FORMAT_D24S8:
case sw::FORMAT_D32FS8_TEXTURE:
case sw::FORMAT_D32FS8_SHADOW:
case sw::FORMAT_S8:
return 8;
// case sw::FORMAT_D24X4S4:
// return 4;
......@@ -1568,11 +1570,16 @@ namespace sw2es
case sw::FORMAT_D24S8: return 24;
case sw::FORMAT_D24X8: return 24;
// case sw::FORMAT_D24X4S4: return 24;
case sw::FORMAT_DF16S8:
case sw::FORMAT_D16: return 16;
case sw::FORMAT_D32F:
case sw::FORMAT_D32F_COMPLEMENTARY:
case sw::FORMAT_D32F_LOCKABLE: return 32;
case sw::FORMAT_DF24S8:
case sw::FORMAT_D24FS8: return 24;
// case sw::FORMAT_D32_LOCKABLE: return 32;
// case sw::FORMAT_S8_LOCKABLE: return 0;
case sw::FORMAT_D32FS8_SHADOW:
case sw::FORMAT_D32FS8_TEXTURE: return 32;
default: return 0;
}
......@@ -1710,6 +1717,15 @@ namespace sw2es
return GL_DEPTH_COMPONENT16;
case sw::FORMAT_D24S8:
return GL_DEPTH24_STENCIL8_OES;
case sw::FORMAT_D32F:
case sw::FORMAT_D32F_COMPLEMENTARY:
case sw::FORMAT_D32F_LOCKABLE:
return GL_DEPTH_COMPONENT32F;
case sw::FORMAT_D32FS8_TEXTURE:
case sw::FORMAT_D32FS8_SHADOW:
return GL_DEPTH32F_STENCIL8;
case sw::FORMAT_S8:
return GL_STENCIL_INDEX8;
default:
UNREACHABLE(format);
}
......
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