Commit d082819c by Yuly Novikov Committed by Commit Bot

Fix format support conditions

This fixes format support tables in formatutils.cpp and formatutilsgl.cpp to conform to the core and extension GLES specs, for a large portion of the formats. ExtsOnly SupportRequirement was enhanced to accept multiple sets of extensions. Format is supported if all the extensions in one of the sets are available. Also fixes determining support for extensions based on those formats. And some fixes to tests which fail due to more strict format support. Bug: angleproject:2567 Change-Id: I6050fff9c597f658fdcea2477bff59a603cdb7e8 Reviewed-on: https://chromium-review.googlesource.com/1105612Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Yuly Novikov <ynovikov@google.com>
parent 5dc0a6f9
...@@ -349,7 +349,7 @@ static bool DetermineRGB8AndRGBA8TextureSupport(const TextureCapsMap &textureCap ...@@ -349,7 +349,7 @@ static bool DetermineRGB8AndRGBA8TextureSupport(const TextureCapsMap &textureCap
GL_RGB8, GL_RGBA8, GL_RGB8, GL_RGBA8,
}; };
return GetFormatSupport(textureCaps, requiredFormats, true, true, true, true); return GetFormatSupport(textureCaps, requiredFormats, false, false, false, true);
} }
// Checks for GL_EXT_texture_format_BGRA8888 support // Checks for GL_EXT_texture_format_BGRA8888 support
...@@ -363,20 +363,37 @@ static bool DetermineBGRA8TextureSupport(const TextureCapsMap &textureCaps) ...@@ -363,20 +363,37 @@ static bool DetermineBGRA8TextureSupport(const TextureCapsMap &textureCaps)
} }
// Checks for GL_OES_color_buffer_half_float support // Checks for GL_OES_color_buffer_half_float support
static bool DetermineColorBufferHalfFloatSupport(const TextureCapsMap &textureCaps) static bool DetermineColorBufferHalfFloatSupport(const TextureCapsMap &textureCaps,
bool checkRGFormats)
{ {
constexpr GLenum requiredFormats[] = { constexpr GLenum requiredRGRenderbufferFormats[] = {
GL_RGBA16F, GL_RGB16F, GL_RG16F, GL_R16F, GL_R16F, GL_RG16F,
};
constexpr GLenum requiredRenderbufferFormats[] = {
GL_RGB16F, GL_RGBA16F,
};
// GL_RGBA16F since the extension says format=RGBA type=HALF_FLOAT_OES textures are renderable
// GL_RGB16F because dEQP GLES3 tests for it in es3fFboColorbufferTests.cpp
constexpr GLenum requiredTextureAttachmentFormats[] = {
GL_RGB16F, GL_RGBA16F,
}; };
return GetFormatSupport(textureCaps, requiredFormats, true, false, true, true); if (checkRGFormats &&
!GetFormatSupport(textureCaps, requiredRGRenderbufferFormats, false, false, false, true))
{
return false;
}
return GetFormatSupport(textureCaps, requiredRenderbufferFormats, false, false, false, true) &&
GetFormatSupport(textureCaps, requiredTextureAttachmentFormats, false, false, true,
false);
} }
// Checks for GL_OES_texture_half_float support // Checks for GL_OES_texture_half_float support
static bool DetermineHalfFloatTextureSupport(const TextureCapsMap &textureCaps) static bool DetermineHalfFloatTextureSupport(const TextureCapsMap &textureCaps)
{ {
constexpr GLenum requiredFormats[] = { constexpr GLenum requiredFormats[] = {
GL_RGB16F, GL_RGBA16F, GL_RGBA16F, GL_RGB16F, GL_LUMINANCE_ALPHA16F_EXT, GL_LUMINANCE16F_EXT, GL_ALPHA16F_EXT,
}; };
return GetFormatSupport(textureCaps, requiredFormats, true, false, false, false); return GetFormatSupport(textureCaps, requiredFormats, true, false, false, false);
...@@ -386,18 +403,17 @@ static bool DetermineHalfFloatTextureSupport(const TextureCapsMap &textureCaps) ...@@ -386,18 +403,17 @@ static bool DetermineHalfFloatTextureSupport(const TextureCapsMap &textureCaps)
static bool DetermineHalfFloatTextureFilteringSupport(const TextureCapsMap &textureCaps) static bool DetermineHalfFloatTextureFilteringSupport(const TextureCapsMap &textureCaps)
{ {
constexpr GLenum requiredFormats[] = { constexpr GLenum requiredFormats[] = {
GL_RGB16F, GL_RGBA16F, GL_RGBA16F, GL_RGB16F, GL_LUMINANCE_ALPHA16F_EXT, GL_LUMINANCE16F_EXT, GL_ALPHA16F_EXT,
}; };
return DetermineHalfFloatTextureSupport(textureCaps) && return GetFormatSupport(textureCaps, requiredFormats, false, true, false, false);
GetFormatSupport(textureCaps, requiredFormats, true, true, false, false);
} }
// Checks for GL_OES_texture_float support // Checks for GL_OES_texture_float support
static bool DetermineFloatTextureSupport(const TextureCapsMap &textureCaps) static bool DetermineFloatTextureSupport(const TextureCapsMap &textureCaps)
{ {
constexpr GLenum requiredFormats[] = { constexpr GLenum requiredFormats[] = {
GL_RGB32F, GL_RGBA32F, GL_RGBA32F, GL_RGB32F, GL_LUMINANCE_ALPHA32F_EXT, GL_LUMINANCE32F_EXT, GL_ALPHA32F_EXT,
}; };
return GetFormatSupport(textureCaps, requiredFormats, true, false, false, false); return GetFormatSupport(textureCaps, requiredFormats, true, false, false, false);
...@@ -407,48 +423,40 @@ static bool DetermineFloatTextureSupport(const TextureCapsMap &textureCaps) ...@@ -407,48 +423,40 @@ static bool DetermineFloatTextureSupport(const TextureCapsMap &textureCaps)
static bool DetermineFloatTextureFilteringSupport(const TextureCapsMap &textureCaps) static bool DetermineFloatTextureFilteringSupport(const TextureCapsMap &textureCaps)
{ {
constexpr GLenum requiredFormats[] = { constexpr GLenum requiredFormats[] = {
GL_RGB32F, GL_RGBA32F, GL_RGBA32F, GL_RGB32F, GL_LUMINANCE_ALPHA32F_EXT, GL_LUMINANCE32F_EXT, GL_ALPHA32F_EXT,
}; };
return DetermineFloatTextureSupport(textureCaps) && return GetFormatSupport(textureCaps, requiredFormats, false, true, false, false);
GetFormatSupport(textureCaps, requiredFormats, true, true, false, false);
} }
// Checks for GL_EXT_texture_rg support // Checks for GL_EXT_texture_rg support
static bool DetermineRGHalfFloatTextureSupport(const TextureCapsMap &textureCaps) static bool DetermineRGTextureSupport(const TextureCapsMap &textureCaps,
bool checkHalfFloatFormats,
bool checkFloatFormats)
{ {
constexpr GLenum requiredFormats[] = { constexpr GLenum requiredFormats[] = {
GL_R8, GL_RG8,
};
constexpr GLenum requiredHalfFloatFormats[] = {
GL_R16F, GL_RG16F, GL_R16F, GL_RG16F,
}; };
return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false); constexpr GLenum requiredFloatFormats[] = {
}
static bool DetermineRGFloatTextureSupport(const TextureCapsMap &textureCaps)
{
constexpr GLenum requiredFormats[] = {
GL_R32F, GL_RG32F, GL_R32F, GL_RG32F,
}; };
return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false);
}
static bool DetermineRGTextureSupport(const TextureCapsMap &textureCaps, if (checkHalfFloatFormats &&
bool checkHalfFloatFormats, !GetFormatSupport(textureCaps, requiredHalfFloatFormats, true, false, false, false))
bool checkFloatFormats)
{
if (checkHalfFloatFormats && !DetermineRGHalfFloatTextureSupport(textureCaps))
{ {
return false; return false;
} }
if (checkFloatFormats && !DetermineRGFloatTextureSupport(textureCaps)) if (checkFloatFormats &&
!GetFormatSupport(textureCaps, requiredFloatFormats, true, false, false, false))
{ {
return false; return false;
} }
constexpr GLenum requiredFormats[] = { return GetFormatSupport(textureCaps, requiredFormats, true, true, true, true);
GL_R8, GL_RG8,
};
return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false);
} }
// Check for GL_EXT_texture_compression_dxt1 // Check for GL_EXT_texture_compression_dxt1
...@@ -625,7 +633,7 @@ static bool DetermineEACRG11SignedTextureSupport(const TextureCapsMap &textureCa ...@@ -625,7 +633,7 @@ static bool DetermineEACRG11SignedTextureSupport(const TextureCapsMap &textureCa
return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false); return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false);
} }
// Check for GL_ANGLE_texture_compression_dxt5 // Check for GL_EXT_sRGB
static bool DetermineSRGBTextureSupport(const TextureCapsMap &textureCaps) static bool DetermineSRGBTextureSupport(const TextureCapsMap &textureCaps)
{ {
constexpr GLenum requiredFilterFormats[] = { constexpr GLenum requiredFilterFormats[] = {
...@@ -667,7 +675,7 @@ static bool DetermineColorBufferFloatRGBSupport(const TextureCapsMap &textureCap ...@@ -667,7 +675,7 @@ static bool DetermineColorBufferFloatRGBSupport(const TextureCapsMap &textureCap
GL_RGB32F, GL_RGB32F,
}; };
return GetFormatSupport(textureCaps, requiredFormats, true, false, true, true); return GetFormatSupport(textureCaps, requiredFormats, true, false, true, false);
} }
// Check for GL_CHROMIUM_color_buffer_float_rgba // Check for GL_CHROMIUM_color_buffer_float_rgba
...@@ -677,7 +685,7 @@ static bool DetermineColorBufferFloatRGBASupport(const TextureCapsMap &textureCa ...@@ -677,7 +685,7 @@ static bool DetermineColorBufferFloatRGBASupport(const TextureCapsMap &textureCa
GL_RGBA32F, GL_RGBA32F,
}; };
return GetFormatSupport(textureCaps, requiredFormats, true, false, true, true); return GetFormatSupport(textureCaps, requiredFormats, true, false, true, false);
} }
// Check for GL_EXT_color_buffer_float // Check for GL_EXT_color_buffer_float
...@@ -708,15 +716,20 @@ static bool DetermineTextureNorm16Support(const TextureCapsMap &textureCaps) ...@@ -708,15 +716,20 @@ static bool DetermineTextureNorm16Support(const TextureCapsMap &textureCaps)
void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps) void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps)
{ {
// TODO(ynovikov): rgb8rgba8, colorBufferHalfFloat, textureHalfFloat, textureHalfFloatLinear,
// textureFloat, textureFloatLinear, textureRG, sRGB, colorBufferFloatRGB, colorBufferFloatRGBA
// and colorBufferFloat were verified. Verify the rest.
packedDepthStencil = DeterminePackedDepthStencilSupport(textureCaps); packedDepthStencil = DeterminePackedDepthStencilSupport(textureCaps);
rgb8rgba8 = DetermineRGB8AndRGBA8TextureSupport(textureCaps); rgb8rgba8 = DetermineRGB8AndRGBA8TextureSupport(textureCaps);
textureFormatBGRA8888 = DetermineBGRA8TextureSupport(textureCaps); textureFormatBGRA8888 = DetermineBGRA8TextureSupport(textureCaps);
colorBufferHalfFloat = DetermineColorBufferHalfFloatSupport(textureCaps);
textureHalfFloat = DetermineHalfFloatTextureSupport(textureCaps); textureHalfFloat = DetermineHalfFloatTextureSupport(textureCaps);
textureHalfFloatLinear = DetermineHalfFloatTextureFilteringSupport(textureCaps); textureHalfFloatLinear =
textureHalfFloat && DetermineHalfFloatTextureFilteringSupport(textureCaps);
textureFloat = DetermineFloatTextureSupport(textureCaps); textureFloat = DetermineFloatTextureSupport(textureCaps);
textureFloatLinear = DetermineFloatTextureFilteringSupport(textureCaps); textureFloatLinear = textureFloat && DetermineFloatTextureFilteringSupport(textureCaps);
textureRG = DetermineRGTextureSupport(textureCaps, textureHalfFloat, textureFloat); textureRG = DetermineRGTextureSupport(textureCaps, textureHalfFloat, textureFloat);
colorBufferHalfFloat =
textureHalfFloat && DetermineColorBufferHalfFloatSupport(textureCaps, textureRG);
textureCompressionDXT1 = DetermineDXT1TextureSupport(textureCaps); textureCompressionDXT1 = DetermineDXT1TextureSupport(textureCaps);
textureCompressionDXT3 = DetermineDXT3TextureSupport(textureCaps); textureCompressionDXT3 = DetermineDXT3TextureSupport(textureCaps);
textureCompressionDXT5 = DetermineDXT5TextureSupport(textureCaps); textureCompressionDXT5 = DetermineDXT5TextureSupport(textureCaps);
......
...@@ -37,8 +37,9 @@ struct SupportRequirement ...@@ -37,8 +37,9 @@ struct SupportRequirement
// Extensions that are required if the minimum version is not met // Extensions that are required if the minimum version is not met
std::vector<std::string> versionExtensions; std::vector<std::string> versionExtensions;
// Extensions that are always required to support this format // Sets of extensions that are required to support this format
std::vector<std::string> requiredExtensions; // All the extensions in one of the sets have to be available for a format to be supported
std::vector<std::vector<std::string>> requiredExtensions;
}; };
struct InternalFormat struct InternalFormat
......
...@@ -63,12 +63,27 @@ namespace nativegl_gl ...@@ -63,12 +63,27 @@ namespace nativegl_gl
static bool MeetsRequirements(const FunctionsGL *functions, const nativegl::SupportRequirement &requirements) static bool MeetsRequirements(const FunctionsGL *functions, const nativegl::SupportRequirement &requirements)
{ {
for (const std::string &extension : requirements.requiredExtensions) bool hasRequiredExtensions = false;
for (const std::vector<std::string> &exts : requirements.requiredExtensions)
{
bool hasAllExtensionsInSet = true;
for (const std::string &extension : exts)
{ {
if (!functions->hasExtension(extension)) if (!functions->hasExtension(extension))
{ {
return false; hasAllExtensionsInSet = false;
break;
}
}
if (hasAllExtensionsInSet)
{
hasRequiredExtensions = true;
break;
}
} }
if (!requirements.requiredExtensions.empty() && !hasRequiredExtensions)
{
return false;
} }
if (functions->version >= requirements.version) if (functions->version >= requirements.version)
......
...@@ -358,8 +358,8 @@ TEST_P(D3DTextureTest, TestD3D11SupportedFormatsSurface) ...@@ -358,8 +358,8 @@ TEST_P(D3DTextureTest, TestD3D11SupportedFormatsSurface)
// formats. The test renders to and samples from the pbuffer. // formats. The test renders to and samples from the pbuffer.
TEST_P(D3DTextureTest, TestD3D11SupportedFormatsTexture) TEST_P(D3DTextureTest, TestD3D11SupportedFormatsTexture)
{ {
bool srgbSupported = extensionEnabled("GL_EXT_sRGB") || getClientMajorVersion() == 3; bool srgb8alpha8TextureAttachmentSupported = getClientMajorVersion() >= 3;
ANGLE_SKIP_TEST_IF(!valid() || !mD3D11Device || !srgbSupported); ANGLE_SKIP_TEST_IF(!valid() || !mD3D11Device || !srgb8alpha8TextureAttachmentSupported);
bool srgbWriteControlSupported = extensionEnabled("GL_EXT_sRGB_write_control") && !IsOpenGL(); bool srgbWriteControlSupported = extensionEnabled("GL_EXT_sRGB_write_control") && !IsOpenGL();
...@@ -464,8 +464,8 @@ TEST_P(D3DTextureTest, TestD3D11TypelessTexture) ...@@ -464,8 +464,8 @@ TEST_P(D3DTextureTest, TestD3D11TypelessTexture)
// Typeless formats are optional in the spec and currently only supported on D3D11 backend. // Typeless formats are optional in the spec and currently only supported on D3D11 backend.
ANGLE_SKIP_TEST_IF(!IsD3D11()); ANGLE_SKIP_TEST_IF(!IsD3D11());
// SRGB support is required. // GL_SRGB8_ALPHA8 texture attachment support is required.
ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_EXT_sRGB") && getClientMajorVersion() < 3); ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3);
const std::array<EGLint, 2> eglGlColorspaces = {EGL_GL_COLORSPACE_LINEAR, const std::array<EGLint, 2> eglGlColorspaces = {EGL_GL_COLORSPACE_LINEAR,
EGL_GL_COLORSPACE_SRGB}; EGL_GL_COLORSPACE_SRGB};
......
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