Commit 6cf8e1b9 by Geoff Lang

Reduce the number of TextureFormatCaps members.

Since GL has no notion of texture formats that can be used for different types of textures, merge the TextureFormatCaps texture support members. Also merge the various renderability members since the texture type is enough to determine what type of renderable a format is. BUG=angle:658 Change-Id: I7cba50b147fcca8f3880d65c06c57df9c65ed19c Reviewed-on: https://chromium-review.googlesource.com/206830Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent ad8636ee
...@@ -17,14 +17,9 @@ namespace gl ...@@ -17,14 +17,9 @@ namespace gl
{ {
TextureCaps::TextureCaps() TextureCaps::TextureCaps()
: texture2D(false), : texturable(false),
textureCubeMap(false), filterable(false),
texture3D(false), renderable(false),
texture2DArray(false),
filtering(false),
colorRendering(false),
depthRendering(false),
stencilRendering(false),
sampleCounts() sampleCounts()
{ {
} }
...@@ -150,23 +145,18 @@ std::vector<std::string> Extensions::getStrings(GLuint clientVersion) const ...@@ -150,23 +145,18 @@ std::vector<std::string> Extensions::getStrings(GLuint clientVersion) const
} }
static bool GetFormatSupport(const TextureCapsMap &textureCaps, const std::vector<GLenum> &requiredFormats, static bool GetFormatSupport(const TextureCapsMap &textureCaps, const std::vector<GLenum> &requiredFormats,
bool requiresFiltering, bool requiresColorBuffer, bool requiresDepthStencil) bool requiresFiltering, bool requiresRendering)
{ {
for (size_t i = 0; i < requiredFormats.size(); i++) for (size_t i = 0; i < requiredFormats.size(); i++)
{ {
const TextureCaps &cap = textureCaps.get(requiredFormats[i]); const TextureCaps &cap = textureCaps.get(requiredFormats[i]);
if (requiresFiltering && !cap.filtering) if (requiresFiltering && !cap.filterable)
{ {
return false; return false;
} }
if (requiresColorBuffer && !cap.colorRendering) if (requiresRendering && !cap.renderable)
{
return false;
}
if (requiresDepthStencil && !cap.depthRendering)
{ {
return false; return false;
} }
...@@ -182,7 +172,7 @@ static bool DetermineRGB8AndRGBA8TextureSupport(const TextureCapsMap &textureCap ...@@ -182,7 +172,7 @@ static bool DetermineRGB8AndRGBA8TextureSupport(const TextureCapsMap &textureCap
requiredFormats.push_back(GL_RGB8); requiredFormats.push_back(GL_RGB8);
requiredFormats.push_back(GL_RGBA8); requiredFormats.push_back(GL_RGBA8);
return GetFormatSupport(textureCaps, requiredFormats, true, true, false); return GetFormatSupport(textureCaps, requiredFormats, true, true);
} }
// Checks for GL_EXT_texture_format_BGRA8888 support // Checks for GL_EXT_texture_format_BGRA8888 support
...@@ -191,7 +181,7 @@ static bool DetermineBGRA8TextureSupport(const TextureCapsMap &textureCaps) ...@@ -191,7 +181,7 @@ static bool DetermineBGRA8TextureSupport(const TextureCapsMap &textureCaps)
std::vector<GLenum> requiredFormats; std::vector<GLenum> requiredFormats;
requiredFormats.push_back(GL_BGRA8_EXT); requiredFormats.push_back(GL_BGRA8_EXT);
return GetFormatSupport(textureCaps, requiredFormats, true, true, false); return GetFormatSupport(textureCaps, requiredFormats, true, true);
} }
// Checks for GL_OES_texture_half_float support // Checks for GL_OES_texture_half_float support
...@@ -201,7 +191,7 @@ static bool DetermineHalfFloatTextureSupport(const TextureCapsMap &textureCaps) ...@@ -201,7 +191,7 @@ static bool DetermineHalfFloatTextureSupport(const TextureCapsMap &textureCaps)
requiredFormats.push_back(GL_RGB16F); requiredFormats.push_back(GL_RGB16F);
requiredFormats.push_back(GL_RGBA16F); requiredFormats.push_back(GL_RGBA16F);
return GetFormatSupport(textureCaps, requiredFormats, false, true, false); return GetFormatSupport(textureCaps, requiredFormats, false, true);
} }
// Checks for GL_OES_texture_half_float_linear support // Checks for GL_OES_texture_half_float_linear support
...@@ -211,7 +201,7 @@ static bool DetermineHalfFloatTextureFilteringSupport(const TextureCapsMap &text ...@@ -211,7 +201,7 @@ static bool DetermineHalfFloatTextureFilteringSupport(const TextureCapsMap &text
requiredFormats.push_back(GL_RGB16F); requiredFormats.push_back(GL_RGB16F);
requiredFormats.push_back(GL_RGBA16F); requiredFormats.push_back(GL_RGBA16F);
return GetFormatSupport(textureCaps, requiredFormats, true, false, false); return GetFormatSupport(textureCaps, requiredFormats, true, false);
} }
// Checks for GL_OES_texture_float support // Checks for GL_OES_texture_float support
...@@ -221,7 +211,7 @@ static bool DetermineFloatTextureSupport(const TextureCapsMap &textureCaps) ...@@ -221,7 +211,7 @@ static bool DetermineFloatTextureSupport(const TextureCapsMap &textureCaps)
requiredFormats.push_back(GL_RGB32F); requiredFormats.push_back(GL_RGB32F);
requiredFormats.push_back(GL_RGBA32F); requiredFormats.push_back(GL_RGBA32F);
return GetFormatSupport(textureCaps, requiredFormats, false, true, false); return GetFormatSupport(textureCaps, requiredFormats, false, true);
} }
// Checks for GL_OES_texture_float_linear support // Checks for GL_OES_texture_float_linear support
...@@ -231,7 +221,7 @@ static bool DetermineFloatTextureFilteringSupport(const TextureCapsMap &textureC ...@@ -231,7 +221,7 @@ static bool DetermineFloatTextureFilteringSupport(const TextureCapsMap &textureC
requiredFormats.push_back(GL_RGB32F); requiredFormats.push_back(GL_RGB32F);
requiredFormats.push_back(GL_RGBA32F); requiredFormats.push_back(GL_RGBA32F);
return GetFormatSupport(textureCaps, requiredFormats, true, false, false); return GetFormatSupport(textureCaps, requiredFormats, true, false);
} }
// Checks for GL_EXT_texture_rg support // Checks for GL_EXT_texture_rg support
...@@ -251,7 +241,7 @@ static bool DetermineRGTextureSupport(const TextureCapsMap &textureCaps, bool ch ...@@ -251,7 +241,7 @@ static bool DetermineRGTextureSupport(const TextureCapsMap &textureCaps, bool ch
requiredFormats.push_back(GL_RG32F); requiredFormats.push_back(GL_RG32F);
} }
return GetFormatSupport(textureCaps, requiredFormats, true, false, false); return GetFormatSupport(textureCaps, requiredFormats, true, false);
} }
// Check for GL_EXT_texture_compression_dxt1 // Check for GL_EXT_texture_compression_dxt1
...@@ -261,7 +251,7 @@ static bool DetermineDXT1TextureSupport(const TextureCapsMap &textureCaps) ...@@ -261,7 +251,7 @@ static bool DetermineDXT1TextureSupport(const TextureCapsMap &textureCaps)
requiredFormats.push_back(GL_COMPRESSED_RGB_S3TC_DXT1_EXT); requiredFormats.push_back(GL_COMPRESSED_RGB_S3TC_DXT1_EXT);
requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT); requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
return GetFormatSupport(textureCaps, requiredFormats, true, false, false); return GetFormatSupport(textureCaps, requiredFormats, true, false);
} }
// Check for GL_ANGLE_texture_compression_dxt3 // Check for GL_ANGLE_texture_compression_dxt3
...@@ -270,7 +260,7 @@ static bool DetermineDXT3TextureSupport(const TextureCapsMap &textureCaps) ...@@ -270,7 +260,7 @@ static bool DetermineDXT3TextureSupport(const TextureCapsMap &textureCaps)
std::vector<GLenum> requiredFormats; std::vector<GLenum> requiredFormats;
requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE); requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE);
return GetFormatSupport(textureCaps, requiredFormats, true, false, false); return GetFormatSupport(textureCaps, requiredFormats, true, false);
} }
// Check for GL_ANGLE_texture_compression_dxt5 // Check for GL_ANGLE_texture_compression_dxt5
...@@ -279,7 +269,7 @@ static bool DetermineDXT5TextureSupport(const TextureCapsMap &textureCaps) ...@@ -279,7 +269,7 @@ static bool DetermineDXT5TextureSupport(const TextureCapsMap &textureCaps)
std::vector<GLenum> requiredFormats; std::vector<GLenum> requiredFormats;
requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE); requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE);
return GetFormatSupport(textureCaps, requiredFormats, true, false, false); return GetFormatSupport(textureCaps, requiredFormats, true, false);
} }
// Check for GL_ANGLE_texture_compression_dxt5 // Check for GL_ANGLE_texture_compression_dxt5
...@@ -292,8 +282,8 @@ static bool DetermineSRGBTextureSupport(const TextureCapsMap &textureCaps) ...@@ -292,8 +282,8 @@ static bool DetermineSRGBTextureSupport(const TextureCapsMap &textureCaps)
std::vector<GLenum> requiredRenderFormats; std::vector<GLenum> requiredRenderFormats;
requiredRenderFormats.push_back(GL_SRGB8_ALPHA8); requiredRenderFormats.push_back(GL_SRGB8_ALPHA8);
return GetFormatSupport(textureCaps, requiredFilterFormats, true, false, false) && return GetFormatSupport(textureCaps, requiredFilterFormats, true, false) &&
GetFormatSupport(textureCaps, requiredRenderFormats, false, true, false); GetFormatSupport(textureCaps, requiredRenderFormats, false, true);
} }
// Check for GL_ANGLE_depth_texture // Check for GL_ANGLE_depth_texture
...@@ -304,7 +294,7 @@ static bool DetermineDepthTextureSupport(const TextureCapsMap &textureCaps) ...@@ -304,7 +294,7 @@ static bool DetermineDepthTextureSupport(const TextureCapsMap &textureCaps)
requiredFormats.push_back(GL_DEPTH_COMPONENT32_OES); requiredFormats.push_back(GL_DEPTH_COMPONENT32_OES);
requiredFormats.push_back(GL_DEPTH24_STENCIL8_OES); requiredFormats.push_back(GL_DEPTH24_STENCIL8_OES);
return GetFormatSupport(textureCaps, requiredFormats, true, false, true); return GetFormatSupport(textureCaps, requiredFormats, true, true);
} }
// Check for GL_EXT_color_buffer_float // Check for GL_EXT_color_buffer_float
...@@ -319,7 +309,7 @@ static bool DetermineColorBufferFloatSupport(const TextureCapsMap &textureCaps) ...@@ -319,7 +309,7 @@ static bool DetermineColorBufferFloatSupport(const TextureCapsMap &textureCaps)
requiredFormats.push_back(GL_RGBA32F); requiredFormats.push_back(GL_RGBA32F);
requiredFormats.push_back(GL_R11F_G11F_B10F); requiredFormats.push_back(GL_R11F_G11F_B10F);
return GetFormatSupport(textureCaps, requiredFormats, false, true, false); return GetFormatSupport(textureCaps, requiredFormats, false, true);
} }
void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps) void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps)
......
...@@ -21,14 +21,14 @@ struct TextureCaps ...@@ -21,14 +21,14 @@ struct TextureCaps
{ {
TextureCaps(); TextureCaps();
bool texture2D; // Supports for basic texturing: glTexImage, glTexSubImage, etc
bool textureCubeMap; bool texturable;
bool texture3D;
bool texture2DArray; // Support for linear or anisotropic filtering
bool filtering; bool filterable;
bool colorRendering;
bool depthRendering; // Support for being used as a framebuffer attachment or renderbuffer format
bool stencilRendering; bool renderable;
std::set<GLuint> sampleCounts; std::set<GLuint> sampleCounts;
}; };
......
...@@ -753,30 +753,25 @@ void Context::setFramebufferZero(Framebuffer *buffer) ...@@ -753,30 +753,25 @@ void Context::setFramebufferZero(Framebuffer *buffer)
void Context::setRenderbufferStorage(GLsizei width, GLsizei height, GLenum internalformat, GLsizei samples) void Context::setRenderbufferStorage(GLsizei width, GLsizei height, GLenum internalformat, GLsizei samples)
{ {
const TextureCaps &formatCaps = getTextureCaps().get(internalformat); ASSERT(getTextureCaps().get(internalformat).renderable);
RenderbufferStorage *renderbuffer = NULL; RenderbufferStorage *renderbuffer = NULL;
if (formatCaps.colorRendering) if (GetDepthBits(internalformat) > 0 && GetStencilBits(internalformat) > 0)
{
renderbuffer = new gl::Colorbuffer(mRenderer,width, height, internalformat, samples);
}
else if (formatCaps.depthRendering && formatCaps.stencilRendering)
{ {
renderbuffer = new gl::DepthStencilbuffer(mRenderer, width, height, samples); renderbuffer = new gl::DepthStencilbuffer(mRenderer, width, height, samples);
} }
else if (formatCaps.depthRendering) else if (GetDepthBits(internalformat) > 0)
{ {
renderbuffer = new gl::Depthbuffer(mRenderer, width, height, samples); renderbuffer = new gl::Depthbuffer(mRenderer, width, height, samples);
} }
else if (formatCaps.stencilRendering) else if (GetStencilBits(internalformat) > 0)
{ {
renderbuffer = new gl::Stencilbuffer(mRenderer, width, height, samples); renderbuffer = new gl::Stencilbuffer(mRenderer, width, height, samples);
} }
else else
{ {
UNREACHABLE(); renderbuffer = new gl::Colorbuffer(mRenderer, width, height, internalformat, samples);
return;
} }
mState.getCurrentRenderbuffer()->setStorage(renderbuffer); mState.getCurrentRenderbuffer()->setStorage(renderbuffer);
......
...@@ -366,20 +366,19 @@ GLenum Framebuffer::completeness() const ...@@ -366,20 +366,19 @@ GLenum Framebuffer::completeness() const
const TextureCaps &formatCaps = mRenderer->getRendererTextureCaps().get(internalformat); const TextureCaps &formatCaps = mRenderer->getRendererTextureCaps().get(internalformat);
if (colorbuffer->isTexture()) if (colorbuffer->isTexture())
{ {
if (!formatCaps.colorRendering) if (!formatCaps.renderable)
{ {
return GL_FRAMEBUFFER_UNSUPPORTED; return GL_FRAMEBUFFER_UNSUPPORTED;
} }
if (gl::GetDepthBits(internalformat) > 0 || if (gl::GetDepthBits(internalformat) > 0 || gl::GetStencilBits(internalformat) > 0)
gl::GetStencilBits(internalformat) > 0)
{ {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
} }
else else
{ {
if (!formatCaps.colorRendering) if (!formatCaps.renderable || gl::GetDepthBits(internalformat) > 0 || gl::GetStencilBits(internalformat) > 0)
{ {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
...@@ -455,7 +454,7 @@ GLenum Framebuffer::completeness() const ...@@ -455,7 +454,7 @@ GLenum Framebuffer::completeness() const
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
if (!formatCaps.depthRendering) if (!formatCaps.renderable)
{ {
return GL_FRAMEBUFFER_UNSUPPORTED; return GL_FRAMEBUFFER_UNSUPPORTED;
} }
...@@ -467,7 +466,7 @@ GLenum Framebuffer::completeness() const ...@@ -467,7 +466,7 @@ GLenum Framebuffer::completeness() const
} }
else else
{ {
if (!formatCaps.depthRendering) if (!formatCaps.renderable || gl::GetDepthBits(internalformat) == 0)
{ {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
...@@ -512,7 +511,7 @@ GLenum Framebuffer::completeness() const ...@@ -512,7 +511,7 @@ GLenum Framebuffer::completeness() const
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
if (!formatCaps.stencilRendering) if (!formatCaps.renderable)
{ {
return GL_FRAMEBUFFER_UNSUPPORTED; return GL_FRAMEBUFFER_UNSUPPORTED;
} }
...@@ -524,7 +523,7 @@ GLenum Framebuffer::completeness() const ...@@ -524,7 +523,7 @@ GLenum Framebuffer::completeness() const
} }
else else
{ {
if (!formatCaps.stencilRendering) if (!formatCaps.renderable || gl::GetStencilBits(internalformat) == 0)
{ {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
......
...@@ -1049,7 +1049,7 @@ bool Texture2DArray::isSamplerComplete(const SamplerState &samplerState) const ...@@ -1049,7 +1049,7 @@ bool Texture2DArray::isSamplerComplete(const SamplerState &samplerState) const
} }
// TODO(geofflang): use context's texture caps // TODO(geofflang): use context's texture caps
if (!mRenderer->getRendererTextureCaps().get(getBaseLevelInternalFormat()).filtering) if (!mRenderer->getRendererTextureCaps().get(getBaseLevelInternalFormat()).filterable)
{ {
if (samplerState.magFilter != GL_NEAREST || if (samplerState.magFilter != GL_NEAREST ||
(samplerState.minFilter != GL_NEAREST && samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST)) (samplerState.minFilter != GL_NEAREST && samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
......
...@@ -2004,8 +2004,8 @@ void __stdcall glGenerateMipmap(GLenum target) ...@@ -2004,8 +2004,8 @@ void __stdcall glGenerateMipmap(GLenum target)
internalFormat == GL_LUMINANCE8_ALPHA8_EXT || internalFormat == GL_LUMINANCE8_ALPHA8_EXT ||
internalFormat == GL_ALPHA8_EXT; internalFormat == GL_ALPHA8_EXT;
if (formatCaps.depthRendering || !formatCaps.filtering || (!formatCaps.colorRendering && !isLUMA) || if (gl::GetDepthBits(internalFormat) > 0 || gl::GetStencilBits(internalFormat) > 0 || !formatCaps.filterable ||
gl::IsFormatCompressed(internalFormat)) (!formatCaps.renderable && !isLUMA) || gl::IsFormatCompressed(internalFormat))
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
} }
...@@ -9612,7 +9612,7 @@ void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenu ...@@ -9612,7 +9612,7 @@ void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenu
} }
const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalformat); const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
if (!formatCaps.colorRendering && !formatCaps.depthRendering && !formatCaps.stencilRendering) if (!formatCaps.renderable)
{ {
return gl::error(GL_INVALID_ENUM); return gl::error(GL_INVALID_ENUM);
} }
......
...@@ -449,7 +449,7 @@ bool TextureD3D_2D::isSamplerComplete(const gl::SamplerState &samplerState) cons ...@@ -449,7 +449,7 @@ bool TextureD3D_2D::isSamplerComplete(const gl::SamplerState &samplerState) cons
return false; return false;
} }
if (!mRenderer->getRendererTextureCaps().get(getInternalFormat(0)).filtering) if (!mRenderer->getRendererTextureCaps().get(getInternalFormat(0)).filterable)
{ {
if (samplerState.magFilter != GL_NEAREST || if (samplerState.magFilter != GL_NEAREST ||
(samplerState.minFilter != GL_NEAREST && samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST)) (samplerState.minFilter != GL_NEAREST && samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
...@@ -1027,7 +1027,7 @@ bool TextureD3D_Cube::isSamplerComplete(const gl::SamplerState &samplerState) co ...@@ -1027,7 +1027,7 @@ bool TextureD3D_Cube::isSamplerComplete(const gl::SamplerState &samplerState) co
bool mipmapping = IsMipmapFiltered(samplerState); bool mipmapping = IsMipmapFiltered(samplerState);
// TODO(geofflang): use context's texture caps // TODO(geofflang): use context's texture caps
if (!mRenderer->getRendererTextureCaps().get(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0)).filtering) if (!mRenderer->getRendererTextureCaps().get(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0)).filterable)
{ {
if (samplerState.magFilter != GL_NEAREST || if (samplerState.magFilter != GL_NEAREST ||
(samplerState.minFilter != GL_NEAREST && samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST)) (samplerState.minFilter != GL_NEAREST && samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
...@@ -1649,7 +1649,7 @@ bool TextureD3D_3D::isSamplerComplete(const gl::SamplerState &samplerState) cons ...@@ -1649,7 +1649,7 @@ bool TextureD3D_3D::isSamplerComplete(const gl::SamplerState &samplerState) cons
} }
// TODO(geofflang): use context's texture caps // TODO(geofflang): use context's texture caps
if (!mRenderer->getRendererTextureCaps().get(getInternalFormat(0)).filtering) if (!mRenderer->getRendererTextureCaps().get(getInternalFormat(0)).filterable)
{ {
if (samplerState.magFilter != GL_NEAREST || if (samplerState.magFilter != GL_NEAREST ||
(samplerState.minFilter != GL_NEAREST && samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST)) (samplerState.minFilter != GL_NEAREST && samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
......
...@@ -2708,7 +2708,7 @@ bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const ...@@ -2708,7 +2708,7 @@ bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const
} }
// We cannot support direct copies to non-color-renderable formats // We cannot support direct copies to non-color-renderable formats
if (!getRendererTextureCaps().get(internalFormat).colorRendering) if (gl_d3d11::GetRTVFormat(internalFormat) != DXGI_FORMAT_UNKNOWN)
{ {
return false; return false;
} }
......
...@@ -233,14 +233,20 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLenum internalFormat, ID3D11De ...@@ -233,14 +233,20 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLenum internalFormat, ID3D11De
UINT formatSupport; UINT formatSupport;
if (SUCCEEDED(device->CheckFormatSupport(textureFormat, &formatSupport))) if (SUCCEEDED(device->CheckFormatSupport(textureFormat, &formatSupport)))
{ {
textureCaps.texture2D = (formatSupport & D3D11_FORMAT_SUPPORT_TEXTURE2D) != 0; if (gl::GetDepthBits(internalFormat) > 0 || gl::GetStencilBits(internalFormat) > 0)
textureCaps.textureCubeMap = (formatSupport & D3D11_FORMAT_SUPPORT_TEXTURECUBE) != 0; {
textureCaps.texture3D = (formatSupport & D3D11_FORMAT_SUPPORT_TEXTURE3D) != 0; textureCaps.texturable = ((formatSupport & D3D11_FORMAT_SUPPORT_TEXTURE2D) != 0);
textureCaps.texture2DArray = (formatSupport & D3D11_FORMAT_SUPPORT_TEXTURE2D) != 0; }
else
{
textureCaps.texturable = ((formatSupport & D3D11_FORMAT_SUPPORT_TEXTURE2D) != 0) &&
((formatSupport & D3D11_FORMAT_SUPPORT_TEXTURECUBE) != 0) &&
((formatSupport & D3D11_FORMAT_SUPPORT_TEXTURE3D) != 0);
}
} }
if (SUCCEEDED(device->CheckFormatSupport(renderFormat, &formatSupport)) && if (SUCCEEDED(device->CheckFormatSupport(renderFormat, &formatSupport)) &&
(formatSupport & D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET)) ((formatSupport & D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET) != 0))
{ {
for (size_t sampleCount = 1; sampleCount <= D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT; sampleCount++) for (size_t sampleCount = 1; sampleCount <= D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT; sampleCount++)
{ {
...@@ -253,23 +259,12 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLenum internalFormat, ID3D11De ...@@ -253,23 +259,12 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLenum internalFormat, ID3D11De
} }
} }
if (SUCCEEDED(device->CheckFormatSupport(srvFormat, &formatSupport))) textureCaps.filterable = SUCCEEDED(device->CheckFormatSupport(srvFormat, &formatSupport)) &&
{ ((formatSupport & D3D11_FORMAT_SUPPORT_SHADER_SAMPLE)) != 0;
textureCaps.filtering = (formatSupport & D3D11_FORMAT_SUPPORT_SHADER_SAMPLE) != 0; textureCaps.renderable = (SUCCEEDED(device->CheckFormatSupport(rtvFormat, &formatSupport)) &&
} ((formatSupport & D3D11_FORMAT_SUPPORT_RENDER_TARGET)) != 0) ||
(SUCCEEDED(device->CheckFormatSupport(dsvFormat, &formatSupport)) &&
if (SUCCEEDED(device->CheckFormatSupport(rtvFormat, &formatSupport))) ((formatSupport & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL) != 0));
{
textureCaps.colorRendering = (formatSupport & D3D11_FORMAT_SUPPORT_RENDER_TARGET) != 0;
}
if (SUCCEEDED(device->CheckFormatSupport(dsvFormat, &formatSupport)))
{
textureCaps.depthRendering = gl::GetDepthBits(internalFormat) > 0 &&
(formatSupport & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL) != 0;
textureCaps.stencilRendering = gl::GetStencilBits(internalFormat) > 0 &&
(formatSupport & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL) != 0;
}
return textureCaps; return textureCaps;
} }
......
...@@ -256,42 +256,23 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLenum internalFormat, IDirect3 ...@@ -256,42 +256,23 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLenum internalFormat, IDirect3
{ {
gl::TextureCaps textureCaps; gl::TextureCaps textureCaps;
D3DFORMAT textureFormat = gl_d3d9::GetTextureFormat(internalFormat);
D3DFORMAT renderFormat = gl_d3d9::GetRenderFormat(internalFormat); D3DFORMAT renderFormat = gl_d3d9::GetRenderFormat(internalFormat);
if (gl::GetDepthBits(internalFormat) > 0 || gl::GetStencilBits(internalFormat) > 0)
textureCaps.texture2D = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, {
0, D3DRTYPE_TEXTURE, textureFormat)); textureCaps.texturable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, 0, D3DRTYPE_TEXTURE, renderFormat));
textureCaps.filterable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, renderFormat));
textureCaps.textureCubeMap = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, textureCaps.renderable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, renderFormat)) ||
0, D3DRTYPE_CUBETEXTURE, textureFormat)); SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, renderFormat));
}
// D3D9 Renderer doesn't support 3D textures else
//textureCaps.setTexture3DSupport(SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, currentDisplayMode.Format, {
// 0, D3DRTYPE_VOLUMETEXTURE, textureFormat))); D3DFORMAT textureFormat = gl_d3d9::GetTextureFormat(internalFormat);
textureCaps.texture3D = false; textureCaps.texturable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, 0, D3DRTYPE_TEXTURE, textureFormat)) &&
SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, 0, D3DRTYPE_CUBETEXTURE, textureFormat));
// D3D9 doesn't support 2D array textures textureCaps.filterable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, textureFormat));
textureCaps.texture2DArray = false; textureCaps.renderable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, textureFormat)) ||
SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, textureFormat));
textureCaps.filtering = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, }
D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, textureFormat));
textureCaps.colorRendering = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat,
D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, textureFormat)) ||
SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat,
D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, renderFormat));
textureCaps.depthRendering = gl::GetDepthBits(internalFormat) > 0 &&
(SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat,
D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, textureFormat)) ||
SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat,
D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, renderFormat)));
textureCaps.stencilRendering = gl::GetStencilBits(internalFormat) > 0 &&
(SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat,
D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, textureFormat)) ||
SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat,
D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, renderFormat)));
textureCaps.sampleCounts.insert(1); textureCaps.sampleCounts.insert(1);
for (size_t i = D3DMULTISAMPLE_2_SAMPLES; i <= D3DMULTISAMPLE_16_SAMPLES; i++) for (size_t i = D3DMULTISAMPLE_2_SAMPLES; i <= D3DMULTISAMPLE_16_SAMPLES; i++)
......
...@@ -319,7 +319,7 @@ bool ValidateRenderbufferStorageParameters(const gl::Context *context, GLenum ta ...@@ -319,7 +319,7 @@ bool ValidateRenderbufferStorageParameters(const gl::Context *context, GLenum ta
} }
const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat); const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
if (!formatCaps.colorRendering && !formatCaps.depthRendering && !formatCaps.stencilRendering) if (!formatCaps.renderable)
{ {
return gl::error(GL_INVALID_ENUM, false); return gl::error(GL_INVALID_ENUM, false);
} }
......
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