Add support for more depth buffer formats in our EGLConfigs.

This includes no depth buffer and 16-bit depth buffer with no stencil buffer. TRAC #22496 Signed-off-by: Geoff Lang Signed-off-by: Shannon Woods Author: Jamie Madill git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1851 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 25950eac
......@@ -365,7 +365,7 @@ void Image11::createStagingTexture()
ID3D11Texture2D *newTexture = NULL;
const DXGI_FORMAT dxgiFormat = getDXGIFormat();
ASSERT(dxgiFormat != DXGI_FORMAT_D24_UNORM_S8_UINT); // We should never get here for depth textures
ASSERT(!d3d11::IsDepthStencilFormat(dxgiFormat)); // We should never get here for depth textures
if (mWidth != 0 && mHeight != 0)
{
......
......@@ -49,7 +49,9 @@ static const DXGI_FORMAT RenderTargetFormats[] =
static const DXGI_FORMAT DepthStencilFormats[] =
{
DXGI_FORMAT_D24_UNORM_S8_UINT
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_D24_UNORM_S8_UINT,
DXGI_FORMAT_D16_UNORM
};
enum
......@@ -286,10 +288,16 @@ int Renderer11::generateConfigs(ConfigDesc **configDescList)
{
DXGI_FORMAT depthStencilFormat = DepthStencilFormats[depthStencilIndex];
UINT formatSupport = 0;
HRESULT result = mDevice->CheckFormatSupport(depthStencilFormat, &formatSupport);
bool depthStencilFormatOK = true;
if (SUCCEEDED(result) && (formatSupport & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL))
if (depthStencilFormat != DXGI_FORMAT_UNKNOWN)
{
UINT formatSupport = 0;
result = mDevice->CheckFormatSupport(depthStencilFormat, &formatSupport);
depthStencilFormatOK = SUCCEEDED(result) && (formatSupport & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL);
}
if (depthStencilFormatOK)
{
ConfigDesc newConfig;
newConfig.renderTargetFormat = d3d11_gl::ConvertBackBufferFormat(renderTargetFormat);
......
......@@ -41,7 +41,7 @@ DWORD TextureStorage11::GetTextureBindFlags(DXGI_FORMAT format, GLenum glusage,
{
UINT bindFlags = D3D11_BIND_SHADER_RESOURCE;
if (format == DXGI_FORMAT_D24_UNORM_S8_UINT)
if (d3d11::IsDepthStencilFormat(format))
{
bindFlags |= D3D11_BIND_DEPTH_STENCIL;
}
......
......@@ -229,6 +229,8 @@ GLenum ConvertDepthStencilFormat(DXGI_FORMAT format)
{
switch (format)
{
case DXGI_FORMAT_UNKNOWN: return GL_NONE;
case DXGI_FORMAT_D16_UNORM: return GL_DEPTH_COMPONENT16;
case DXGI_FORMAT_D24_UNORM_S8_UINT: return GL_DEPTH24_STENCIL8_OES;
default:
UNREACHABLE();
......@@ -245,6 +247,8 @@ GLenum ConvertRenderbufferFormat(DXGI_FORMAT format)
return GL_BGRA8_EXT;
case DXGI_FORMAT_R8G8B8A8_UNORM:
return GL_RGBA8_OES;
case DXGI_FORMAT_D16_UNORM:
return GL_DEPTH_COMPONENT16;
case DXGI_FORMAT_D24_UNORM_S8_UINT:
return GL_DEPTH24_STENCIL8_OES;
default:
......@@ -284,6 +288,8 @@ GLenum ConvertTextureInternalFormat(DXGI_FORMAT format)
return GL_R16F_EXT;
case DXGI_FORMAT_R16G16_FLOAT:
return GL_RG16F_EXT;
case DXGI_FORMAT_D16_UNORM:
return GL_DEPTH_COMPONENT16;
case DXGI_FORMAT_D24_UNORM_S8_UINT:
return GL_DEPTH24_STENCIL8_OES;
case DXGI_FORMAT_UNKNOWN:
......@@ -313,6 +319,7 @@ DXGI_FORMAT ConvertRenderbufferFormat(GLenum format)
case GL_BGRA8_EXT:
return DXGI_FORMAT_B8G8R8A8_UNORM;
case GL_DEPTH_COMPONENT16:
return DXGI_FORMAT_D16_UNORM;
case GL_STENCIL_INDEX8:
case GL_DEPTH24_STENCIL8_OES:
return DXGI_FORMAT_D24_UNORM_S8_UINT;
......@@ -368,6 +375,7 @@ DXGI_FORMAT ConvertTextureFormat(GLenum internalformat)
case GL_RG16F_EXT:
return DXGI_FORMAT_R16G16_FLOAT;
case GL_DEPTH_COMPONENT16:
return DXGI_FORMAT_D16_UNORM;
case GL_DEPTH_COMPONENT32_OES:
case GL_DEPTH24_STENCIL8_OES:
return DXGI_FORMAT_D24_UNORM_S8_UINT;
......@@ -563,6 +571,18 @@ size_t ComputeBlockSizeBits(DXGI_FORMAT format)
}
}
bool IsDepthStencilFormat(DXGI_FORMAT format)
{
switch (format)
{
case DXGI_FORMAT_D16_UNORM:
case DXGI_FORMAT_D24_UNORM_S8_UINT:
return true;
default:
return false;
}
}
HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name)
{
#if defined(_DEBUG)
......
......@@ -68,6 +68,7 @@ void SetPositionDepthColorVertex(PositionDepthColorVertex* vertex, float x, floa
size_t ComputePixelSizeBits(DXGI_FORMAT format);
size_t ComputeBlockSizeBits(DXGI_FORMAT format);
bool IsDepthStencilFormat(DXGI_FORMAT format);
HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name);
}
......
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