Commit a21362f5 by Jonah Ryan-Davis Committed by Commit Bot

GL: Missing check for texture format sample counts

ANGLE was hitting an issue running on llvmpipe because llvmpipe doesn't properly implement texture formats with multisampling, but claims otherwise to be OpenGL 3.3 compliant. ANGLE did not validate the claim on the backend, so the frontend was hitting an ASSERT that failed. This patch makes sure to validate this part of the spec, and limits the driver to OpenGL 2 if it's not conformant. Bug: 976382 Change-Id: I6ad6d757e26f90068df83aeb3caf7685aa2f1c07 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1853889 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 67486ec2
...@@ -227,9 +227,18 @@ static bool CheckInternalFormatRenderbufferRenderability(const FunctionsGL *func ...@@ -227,9 +227,18 @@ static bool CheckInternalFormatRenderbufferRenderability(const FunctionsGL *func
return supported; return supported;
} }
static void LimitVersion(gl::Version *curVersion, const gl::Version &maxVersion)
{
if (*curVersion >= maxVersion)
{
*curVersion = maxVersion;
}
}
static gl::TextureCaps GenerateTextureFormatCaps(const FunctionsGL *functions, static gl::TextureCaps GenerateTextureFormatCaps(const FunctionsGL *functions,
const angle::FeaturesGL &features, const angle::FeaturesGL &features,
GLenum internalFormat) GLenum internalFormat,
gl::Version *maxSupportedESVersion)
{ {
ASSERT(functions->getError() == GL_NO_ERROR); ASSERT(functions->getError() == GL_NO_ERROR);
...@@ -327,6 +336,17 @@ static gl::TextureCaps GenerateTextureFormatCaps(const FunctionsGL *functions, ...@@ -327,6 +336,17 @@ static gl::TextureCaps GenerateTextureFormatCaps(const FunctionsGL *functions,
} }
} }
// GLES 3.0.5 section 4.4.2.2: "Implementations must support creation of renderbuffers in these
// required formats with up to the value of MAX_SAMPLES multisamples, with the exception of
// signed and unsigned integer formats."
const gl::InternalFormat &glFormatInfo = gl::GetSizedInternalFormatInfo(internalFormat);
if (textureCaps.renderbuffer && !glFormatInfo.isInt() &&
glFormatInfo.isRequiredRenderbufferFormat(gl::Version(3, 0)) &&
textureCaps.getMaxSamples() < 4)
{
LimitVersion(maxSupportedESVersion, gl::Version(2, 0));
}
ASSERT(functions->getError() == GL_NO_ERROR); ASSERT(functions->getError() == GL_NO_ERROR);
return textureCaps; return textureCaps;
} }
...@@ -402,14 +422,6 @@ static GLint QueryQueryValue(const FunctionsGL *functions, GLenum target, GLenum ...@@ -402,14 +422,6 @@ static GLint QueryQueryValue(const FunctionsGL *functions, GLenum target, GLenum
return result; return result;
} }
static void LimitVersion(gl::Version *curVersion, const gl::Version &maxVersion)
{
if (*curVersion >= maxVersion)
{
*curVersion = maxVersion;
}
}
void CapCombinedLimitToESShaders(GLuint *combinedLimit, gl::ShaderMap<GLuint> &perShaderLimit) void CapCombinedLimitToESShaders(GLuint *combinedLimit, gl::ShaderMap<GLuint> &perShaderLimit)
{ {
GLuint combinedESLimit = 0; GLuint combinedESLimit = 0;
...@@ -429,12 +441,15 @@ void GenerateCaps(const FunctionsGL *functions, ...@@ -429,12 +441,15 @@ void GenerateCaps(const FunctionsGL *functions,
gl::Version *maxSupportedESVersion, gl::Version *maxSupportedESVersion,
MultiviewImplementationTypeGL *multiviewImplementationType) MultiviewImplementationTypeGL *multiviewImplementationType)
{ {
// Start by assuming ES3.1 support and work down
*maxSupportedESVersion = gl::Version(3, 1);
// Texture format support checks // Texture format support checks
const gl::FormatSet &allFormats = gl::GetAllSizedInternalFormats(); const gl::FormatSet &allFormats = gl::GetAllSizedInternalFormats();
for (GLenum internalFormat : allFormats) for (GLenum internalFormat : allFormats)
{ {
gl::TextureCaps textureCaps = gl::TextureCaps textureCaps =
GenerateTextureFormatCaps(functions, features, internalFormat); GenerateTextureFormatCaps(functions, features, internalFormat, maxSupportedESVersion);
textureCapsMap->insert(internalFormat, textureCaps); textureCapsMap->insert(internalFormat, textureCaps);
if (gl::GetSizedInternalFormatInfo(internalFormat).compressed) if (gl::GetSizedInternalFormatInfo(internalFormat).compressed)
...@@ -443,9 +458,6 @@ void GenerateCaps(const FunctionsGL *functions, ...@@ -443,9 +458,6 @@ void GenerateCaps(const FunctionsGL *functions,
} }
} }
// Start by assuming ES3.1 support and work down
*maxSupportedESVersion = gl::Version(3, 1);
// Table 6.28, implementation dependent values // Table 6.28, implementation dependent values
if (functions->isAtLeastGL(gl::Version(4, 3)) || if (functions->isAtLeastGL(gl::Version(4, 3)) ||
functions->hasGLExtension("GL_ARB_ES3_compatibility") || functions->hasGLExtension("GL_ARB_ES3_compatibility") ||
......
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