Commit d87878e3 by Geoff Lang

Remove the requirement that a format must be texturable to be renderable.

Previously, to determine if a texture format was renderable, the texturable and renderable fields had to be and-ed together. This caused issues for formats such as D24S8 which can be renderable but not texturable depending on available extensions. Made the renderable flag a complete check that may be different than the textureable flag and removed assumptions that a format is texturable if renderable from the code. GL_DEPTH24_STENCIL8 now checks for ANGLE_depth_textures for texturability and ANGLE_depth_textures or OES_packed_depth_stencil for renderability. BUG=angle:752 Change-Id: I6d197cee72cc249e5996fa395303bdf43d246a87 Reviewed-on: https://chromium-review.googlesource.com/219093Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent c77e8c39
......@@ -182,12 +182,17 @@ std::vector<std::string> Extensions::getStrings() const
}
static bool GetFormatSupport(const TextureCapsMap &textureCaps, const std::vector<GLenum> &requiredFormats,
bool requiresFiltering, bool requiresRendering)
bool requiresTexturing, bool requiresFiltering, bool requiresRendering)
{
for (size_t i = 0; i < requiredFormats.size(); i++)
{
const TextureCaps &cap = textureCaps.get(requiredFormats[i]);
if (requiresTexturing && !cap.texturable)
{
return false;
}
if (requiresFiltering && !cap.filterable)
{
return false;
......@@ -209,7 +214,7 @@ static bool DetermineRGB8AndRGBA8TextureSupport(const TextureCapsMap &textureCap
requiredFormats.push_back(GL_RGB8);
requiredFormats.push_back(GL_RGBA8);
return GetFormatSupport(textureCaps, requiredFormats, true, true);
return GetFormatSupport(textureCaps, requiredFormats, true, true, true);
}
// Checks for GL_EXT_texture_format_BGRA8888 support
......@@ -218,7 +223,7 @@ static bool DetermineBGRA8TextureSupport(const TextureCapsMap &textureCaps)
std::vector<GLenum> requiredFormats;
requiredFormats.push_back(GL_BGRA8_EXT);
return GetFormatSupport(textureCaps, requiredFormats, true, true);
return GetFormatSupport(textureCaps, requiredFormats, true, true, true);
}
// Checks for GL_OES_texture_half_float support
......@@ -228,7 +233,7 @@ static bool DetermineHalfFloatTextureSupport(const TextureCapsMap &textureCaps)
requiredFormats.push_back(GL_RGB16F);
requiredFormats.push_back(GL_RGBA16F);
return GetFormatSupport(textureCaps, requiredFormats, false, true);
return GetFormatSupport(textureCaps, requiredFormats, true, false, true);
}
// Checks for GL_OES_texture_half_float_linear support
......@@ -238,7 +243,7 @@ static bool DetermineHalfFloatTextureFilteringSupport(const TextureCapsMap &text
requiredFormats.push_back(GL_RGB16F);
requiredFormats.push_back(GL_RGBA16F);
return GetFormatSupport(textureCaps, requiredFormats, true, false);
return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
}
// Checks for GL_OES_texture_float support
......@@ -248,7 +253,7 @@ static bool DetermineFloatTextureSupport(const TextureCapsMap &textureCaps)
requiredFormats.push_back(GL_RGB32F);
requiredFormats.push_back(GL_RGBA32F);
return GetFormatSupport(textureCaps, requiredFormats, false, true);
return GetFormatSupport(textureCaps, requiredFormats, true, false, true);
}
// Checks for GL_OES_texture_float_linear support
......@@ -258,7 +263,7 @@ static bool DetermineFloatTextureFilteringSupport(const TextureCapsMap &textureC
requiredFormats.push_back(GL_RGB32F);
requiredFormats.push_back(GL_RGBA32F);
return GetFormatSupport(textureCaps, requiredFormats, true, false);
return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
}
// Checks for GL_EXT_texture_rg support
......@@ -278,7 +283,7 @@ static bool DetermineRGTextureSupport(const TextureCapsMap &textureCaps, bool ch
requiredFormats.push_back(GL_RG32F);
}
return GetFormatSupport(textureCaps, requiredFormats, true, false);
return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
}
// Check for GL_EXT_texture_compression_dxt1
......@@ -288,7 +293,7 @@ static bool DetermineDXT1TextureSupport(const TextureCapsMap &textureCaps)
requiredFormats.push_back(GL_COMPRESSED_RGB_S3TC_DXT1_EXT);
requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
return GetFormatSupport(textureCaps, requiredFormats, true, false);
return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
}
// Check for GL_ANGLE_texture_compression_dxt3
......@@ -297,7 +302,7 @@ static bool DetermineDXT3TextureSupport(const TextureCapsMap &textureCaps)
std::vector<GLenum> requiredFormats;
requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE);
return GetFormatSupport(textureCaps, requiredFormats, true, false);
return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
}
// Check for GL_ANGLE_texture_compression_dxt5
......@@ -306,7 +311,7 @@ static bool DetermineDXT5TextureSupport(const TextureCapsMap &textureCaps)
std::vector<GLenum> requiredFormats;
requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE);
return GetFormatSupport(textureCaps, requiredFormats, true, false);
return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
}
// Check for GL_ANGLE_texture_compression_dxt5
......@@ -319,8 +324,8 @@ static bool DetermineSRGBTextureSupport(const TextureCapsMap &textureCaps)
std::vector<GLenum> requiredRenderFormats;
requiredRenderFormats.push_back(GL_SRGB8_ALPHA8);
return GetFormatSupport(textureCaps, requiredFilterFormats, true, false) &&
GetFormatSupport(textureCaps, requiredRenderFormats, false, true);
return GetFormatSupport(textureCaps, requiredFilterFormats, true, true, false) &&
GetFormatSupport(textureCaps, requiredRenderFormats, true, false, true);
}
// Check for GL_ANGLE_depth_texture
......@@ -331,7 +336,7 @@ static bool DetermineDepthTextureSupport(const TextureCapsMap &textureCaps)
requiredFormats.push_back(GL_DEPTH_COMPONENT32_OES);
requiredFormats.push_back(GL_DEPTH24_STENCIL8_OES);
return GetFormatSupport(textureCaps, requiredFormats, true, true);
return GetFormatSupport(textureCaps, requiredFormats, true, true, true);
}
// Check for GL_EXT_color_buffer_float
......@@ -346,7 +351,7 @@ static bool DetermineColorBufferFloatSupport(const TextureCapsMap &textureCaps)
requiredFormats.push_back(GL_RGBA32F);
requiredFormats.push_back(GL_R11F_G11F_B10F);
return GetFormatSupport(textureCaps, requiredFormats, false, true);
return GetFormatSupport(textureCaps, requiredFormats, true, false, true);
}
void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps)
......
......@@ -2391,26 +2391,25 @@ void Context::initCaps(GLuint clientVersion)
TextureCaps formatCaps = i->second;
const InternalFormat &formatInfo = GetInternalFormatInfo(format);
if (formatCaps.texturable && formatInfo.textureSupport(clientVersion, mExtensions))
{
// Update the format caps based on the client version and extensions
formatCaps.renderable = formatInfo.renderSupport(clientVersion, mExtensions);
formatCaps.filterable = formatInfo.filterSupport(clientVersion, mExtensions);
// OpenGL ES does not support multisampling with integer formats
if (formatInfo.componentType == GL_INT || formatInfo.componentType == GL_UNSIGNED_INT)
{
formatCaps.sampleCounts.clear();
}
maxSamples = std::max(maxSamples, formatCaps.getMaxSamples());
// Update the format caps based on the client version and extensions
formatCaps.texturable = formatInfo.textureSupport(clientVersion, mExtensions);
formatCaps.renderable = formatInfo.renderSupport(clientVersion, mExtensions);
formatCaps.filterable = formatInfo.filterSupport(clientVersion, mExtensions);
if (formatInfo.compressed)
{
mCaps.compressedTextureFormats.push_back(format);
}
// OpenGL ES does not support multisampling with integer formats
if (!formatInfo.renderSupport || formatInfo.componentType == GL_INT || formatInfo.componentType == GL_UNSIGNED_INT)
{
formatCaps.sampleCounts.clear();
}
maxSamples = std::max(maxSamples, formatCaps.getMaxSamples());
mTextureCaps.insert(format, formatCaps);
if (formatCaps.texturable && formatInfo.compressed)
{
mCaps.compressedTextureFormats.push_back(format);
}
mTextureCaps.insert(format, formatCaps);
}
mExtensions.maxSamples = maxSamples;
......
......@@ -277,20 +277,18 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLenum internalFormat, IDirect3
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0)
{
textureCaps.texturable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, 0, D3DRTYPE_TEXTURE, d3dFormatInfo.renderFormat));
textureCaps.filterable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, d3dFormatInfo.renderFormat));
textureCaps.renderable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, d3dFormatInfo.renderFormat)) ||
SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, d3dFormatInfo.renderFormat));
textureCaps.texturable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, 0, D3DRTYPE_TEXTURE, d3dFormatInfo.texFormat));
}
else
{
textureCaps.texturable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, 0, D3DRTYPE_TEXTURE, d3dFormatInfo.texFormat)) &&
SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, 0, D3DRTYPE_CUBETEXTURE, d3dFormatInfo.texFormat));
textureCaps.filterable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, d3dFormatInfo.texFormat));
textureCaps.renderable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, d3dFormatInfo.texFormat)) ||
SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, d3dFormatInfo.texFormat));
}
textureCaps.filterable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, d3dFormatInfo.texFormat));
textureCaps.renderable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, d3dFormatInfo.renderFormat)) ||
SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, d3dFormatInfo.renderFormat));
textureCaps.sampleCounts.insert(1);
for (size_t i = D3DMULTISAMPLE_2_SAMPLES; i <= D3DMULTISAMPLE_16_SAMPLES; i++)
{
......
......@@ -304,8 +304,8 @@ bool ValidateRenderbufferStorageParameters(gl::Context *context, GLenum target,
return false;
}
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
if (!formatInfo.textureSupport(context->getClientVersion(), context->getExtensions()))
const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
if (!formatCaps.renderable)
{
context->recordError(Error(GL_INVALID_ENUM));
return false;
......@@ -315,6 +315,7 @@ bool ValidateRenderbufferStorageParameters(gl::Context *context, GLenum target,
// sized but it does state that the format must be in the ES2.0 spec table 4.5 which contains
// only sized internal formats. The ES3 spec (section 4.4.2) does, however, state that the
// internal format must be sized and not an integer format if samples is greater than zero.
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
if (formatInfo.pixelBytes == 0)
{
context->recordError(Error(GL_INVALID_ENUM));
......@@ -327,13 +328,6 @@ bool ValidateRenderbufferStorageParameters(gl::Context *context, GLenum target,
return false;
}
const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
if (!formatCaps.renderable)
{
context->recordError(Error(GL_INVALID_ENUM));
return false;
}
if (static_cast<GLuint>(std::max(width, height)) > context->getCaps().maxRenderbufferSize)
{
context->recordError(Error(GL_INVALID_VALUE));
......
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