Commit 8bb46c5b by Clemen Deng Committed by Commit Bot

Refactor: add InternalFormat::isInt()

Bug: angleproject:3727 Change-Id: I33ee85563e3b070b4b86afc37230d3f5af54f446 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1713091 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent dd3de6f0
...@@ -75,8 +75,7 @@ TextureCaps GenerateMinimumTextureCaps(GLenum sizedInternalFormat, ...@@ -75,8 +75,7 @@ TextureCaps GenerateMinimumTextureCaps(GLenum sizedInternalFormat,
if (internalFormatInfo.isRequiredRenderbufferFormat(clientVersion)) if (internalFormatInfo.isRequiredRenderbufferFormat(clientVersion))
{ {
if ((clientVersion.major >= 3 && clientVersion.minor >= 1) || if ((clientVersion.major >= 3 && clientVersion.minor >= 1) ||
(clientVersion.major >= 3 && internalFormatInfo.componentType != GL_UNSIGNED_INT && (clientVersion.major >= 3 && !internalFormatInfo.isInt()))
internalFormatInfo.componentType != GL_INT))
{ {
caps.sampleCounts.insert(4); caps.sampleCounts.insert(4);
} }
......
...@@ -3442,7 +3442,7 @@ void Context::updateCaps() ...@@ -3442,7 +3442,7 @@ void Context::updateCaps()
// OpenGL ES 3.0 or prior does not support multisampling with integer formats // OpenGL ES 3.0 or prior does not support multisampling with integer formats
if (!formatCaps.renderbuffer || if (!formatCaps.renderbuffer ||
(getClientVersion() < ES_3_1 && !mSupportedExtensions.textureMultisample && (getClientVersion() < ES_3_1 && !mSupportedExtensions.textureMultisample &&
(formatInfo.componentType == GL_INT || formatInfo.componentType == GL_UNSIGNED_INT))) formatInfo.isInt()))
{ {
formatCaps.sampleCounts.clear(); formatCaps.sampleCounts.clear();
} }
...@@ -3455,8 +3455,7 @@ void Context::updateCaps() ...@@ -3455,8 +3455,7 @@ void Context::updateCaps()
// GLES 3.0.5 section 4.4.2.2: "Implementations must support creation of renderbuffers // 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 // in these required formats with up to the value of MAX_SAMPLES multisamples, with the
// exception of signed and unsigned integer formats." // exception of signed and unsigned integer formats."
if (formatInfo.componentType != GL_INT && formatInfo.componentType != GL_UNSIGNED_INT && if (!formatInfo.isInt() && formatInfo.isRequiredRenderbufferFormat(getClientVersion()))
formatInfo.isRequiredRenderbufferFormat(getClientVersion()))
{ {
ASSERT(getClientVersion() < ES_3_0 || formatMaxSamples >= 4); ASSERT(getClientVersion() < ES_3_0 || formatMaxSamples >= 4);
mState.mCaps.maxSamples = std::min(mState.mCaps.maxSamples, formatMaxSamples); mState.mCaps.maxSamples = std::min(mState.mCaps.maxSamples, formatMaxSamples);
...@@ -3470,8 +3469,7 @@ void Context::updateCaps() ...@@ -3470,8 +3469,7 @@ void Context::updateCaps()
// the exception that the signed and unsigned integer formats are required only to // the exception that the signed and unsigned integer formats are required only to
// support creation of renderbuffers with up to the value of MAX_INTEGER_SAMPLES // support creation of renderbuffers with up to the value of MAX_INTEGER_SAMPLES
// multisamples, which must be at least one." // multisamples, which must be at least one."
if (formatInfo.componentType == GL_INT || if (formatInfo.isInt())
formatInfo.componentType == GL_UNSIGNED_INT)
{ {
mState.mCaps.maxIntegerSamples = mState.mCaps.maxIntegerSamples =
std::min(mState.mCaps.maxIntegerSamples, formatMaxSamples); std::min(mState.mCaps.maxIntegerSamples, formatMaxSamples);
......
...@@ -488,6 +488,11 @@ bool InternalFormat::isRequiredRenderbufferFormat(const Version &version) const ...@@ -488,6 +488,11 @@ bool InternalFormat::isRequiredRenderbufferFormat(const Version &version) const
} }
} }
bool InternalFormat::isInt() const
{
return componentType == GL_INT || componentType == GL_UNSIGNED_INT;
}
Format::Format(GLenum internalFormat) : Format(GetSizedInternalFormatInfo(internalFormat)) {} Format::Format(GLenum internalFormat) : Format(GetSizedInternalFormatInfo(internalFormat)) {}
Format::Format(const InternalFormat &internalFormat) : info(&internalFormat) {} Format::Format(const InternalFormat &internalFormat) : info(&internalFormat) {}
......
...@@ -126,6 +126,8 @@ struct InternalFormat ...@@ -126,6 +126,8 @@ struct InternalFormat
// extension formats are conservatively not included. // extension formats are conservatively not included.
bool isRequiredRenderbufferFormat(const Version &version) const; bool isRequiredRenderbufferFormat(const Version &version) const;
bool isInt() const;
bool operator==(const InternalFormat &other) const; bool operator==(const InternalFormat &other) const;
bool operator!=(const InternalFormat &other) const; bool operator!=(const InternalFormat &other) const;
......
...@@ -1419,9 +1419,7 @@ bool ValidateBlitFramebufferParameters(Context *context, ...@@ -1419,9 +1419,7 @@ bool ValidateBlitFramebufferParameters(Context *context,
} }
} }
if ((readFormat.info->componentType == GL_INT || if (readFormat.info->isInt() && filter == GL_LINEAR)
readFormat.info->componentType == GL_UNSIGNED_INT) &&
filter == GL_LINEAR)
{ {
context->validationError(GL_INVALID_OPERATION, kBlitIntegerWithLinearFilter); context->validationError(GL_INVALID_OPERATION, kBlitIntegerWithLinearFilter);
return false; return false;
......
...@@ -2971,7 +2971,7 @@ bool ValidateRenderbufferStorageMultisample(Context *context, ...@@ -2971,7 +2971,7 @@ bool ValidateRenderbufferStorageMultisample(Context *context,
// format if samples is greater than zero. In ES3.1(section 9.2.5), it can support integer // format if samples is greater than zero. In ES3.1(section 9.2.5), it can support integer
// multisample renderbuffer, but the samples should not be greater than MAX_INTEGER_SAMPLES. // multisample renderbuffer, but the samples should not be greater than MAX_INTEGER_SAMPLES.
const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(internalformat); const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(internalformat);
if ((formatInfo.componentType == GL_UNSIGNED_INT || formatInfo.componentType == GL_INT)) if (formatInfo.isInt())
{ {
if ((samples > 0 && context->getClientVersion() == ES_3_0) || if ((samples > 0 && context->getClientVersion() == ES_3_0) ||
static_cast<GLuint>(samples) > context->getCaps().maxIntegerSamples) static_cast<GLuint>(samples) > context->getCaps().maxIntegerSamples)
......
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