Commit a5410480 by Jamie Madill Committed by Commit Bot

Inline ValidateBindTexture.

Tiny speed improvement in the perf test. Bug: angleproject:3117 Change-Id: Ie2892772da4808615b2a810ff523602894440b64 Reviewed-on: https://chromium-review.googlesource.com/c/1350490Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent cf9383ed
...@@ -1111,45 +1111,6 @@ bool ValidDstBlendFunc(const Context *context, GLenum val) ...@@ -1111,45 +1111,6 @@ bool ValidDstBlendFunc(const Context *context, GLenum val)
return false; return false;
} }
void RecordBindTextureTypeError(Context *context, TextureType target)
{
ASSERT(!context->getStateCache().isValidBindTextureType(target));
switch (target)
{
case TextureType::Rectangle:
ASSERT(!context->getExtensions().textureRectangle);
context->validationError(GL_INVALID_ENUM, kTextureRectangleNotSupported);
break;
case TextureType::_3D:
case TextureType::_2DArray:
ASSERT(context->getClientMajorVersion() < 3);
context->validationError(GL_INVALID_ENUM, kES3Required);
break;
case TextureType::_2DMultisample:
ASSERT(context->getClientVersion() < Version(3, 1) &&
!context->getExtensions().textureMultisample);
context->validationError(GL_INVALID_ENUM, kMultisampleTextureExtensionOrES31Required);
break;
case TextureType::_2DMultisampleArray:
ASSERT(!context->getExtensions().textureStorageMultisample2DArray);
context->validationError(GL_INVALID_ENUM, kMultisampleArrayExtensionRequired);
break;
case TextureType::External:
ASSERT(!context->getExtensions().eglImageExternal &&
!context->getExtensions().eglStreamConsumerExternal);
context->validationError(GL_INVALID_ENUM, kExternalTextureNotSupported);
break;
default:
context->validationError(GL_INVALID_ENUM, kInvalidTextureTarget);
}
}
} // anonymous namespace } // anonymous namespace
bool ValidateES2TexImageParameters(Context *context, bool ValidateES2TexImageParameters(Context *context,
...@@ -3073,36 +3034,6 @@ bool ValidateFlushMappedBufferRangeEXT(Context *context, ...@@ -3073,36 +3034,6 @@ bool ValidateFlushMappedBufferRangeEXT(Context *context,
return ValidateFlushMappedBufferRangeBase(context, target, offset, length); return ValidateFlushMappedBufferRangeBase(context, target, offset, length);
} }
bool ValidateBindTexture(Context *context, TextureType target, GLuint texture)
{
if (!context->getStateCache().isValidBindTextureType(target))
{
RecordBindTextureTypeError(context, target);
return false;
}
if (texture == 0)
{
return true;
}
Texture *textureObject = context->getTexture(texture);
if (textureObject && textureObject->getType() != target)
{
context->validationError(GL_INVALID_OPERATION, kTypeMismatch);
return false;
}
if (!context->getState().isBindGeneratesResourceEnabled() &&
!context->isTextureGenerated(texture))
{
context->validationError(GL_INVALID_OPERATION, kObjectNotGenerated);
return false;
}
return true;
}
bool ValidateBindUniformLocationCHROMIUM(Context *context, bool ValidateBindUniformLocationCHROMIUM(Context *context,
GLuint program, GLuint program,
GLint location, GLint location,
...@@ -6654,4 +6585,43 @@ bool ValidateProvokingVertexANGLE(Context *context, ProvokingVertex modePacked) ...@@ -6654,4 +6585,43 @@ bool ValidateProvokingVertexANGLE(Context *context, ProvokingVertex modePacked)
return true; return true;
} }
void RecordBindTextureTypeError(Context *context, TextureType target)
{
ASSERT(!context->getStateCache().isValidBindTextureType(target));
switch (target)
{
case TextureType::Rectangle:
ASSERT(!context->getExtensions().textureRectangle);
context->validationError(GL_INVALID_ENUM, kTextureRectangleNotSupported);
break;
case TextureType::_3D:
case TextureType::_2DArray:
ASSERT(context->getClientMajorVersion() < 3);
context->validationError(GL_INVALID_ENUM, kES3Required);
break;
case TextureType::_2DMultisample:
ASSERT(context->getClientVersion() < Version(3, 1) &&
!context->getExtensions().textureMultisample);
context->validationError(GL_INVALID_ENUM, kMultisampleTextureExtensionOrES31Required);
break;
case TextureType::_2DMultisampleArray:
ASSERT(!context->getExtensions().textureStorageMultisample2DArray);
context->validationError(GL_INVALID_ENUM, kMultisampleArrayExtensionRequired);
break;
case TextureType::External:
ASSERT(!context->getExtensions().eglImageExternal &&
!context->getExtensions().eglStreamConsumerExternal);
context->validationError(GL_INVALID_ENUM, kExternalTextureNotSupported);
break;
default:
context->validationError(GL_INVALID_ENUM, kInvalidTextureTarget);
}
}
} // namespace gl } // namespace gl
...@@ -121,6 +121,38 @@ ANGLE_INLINE bool ValidateVertexAttribPointer(Context *context, ...@@ -121,6 +121,38 @@ ANGLE_INLINE bool ValidateVertexAttribPointer(Context *context,
return true; return true;
} }
void RecordBindTextureTypeError(Context *context, TextureType target);
ANGLE_INLINE bool ValidateBindTexture(Context *context, TextureType target, GLuint texture)
{
if (!context->getStateCache().isValidBindTextureType(target))
{
RecordBindTextureTypeError(context, target);
return false;
}
if (texture == 0)
{
return true;
}
Texture *textureObject = context->getTexture(texture);
if (textureObject && textureObject->getType() != target)
{
context->validationError(GL_INVALID_OPERATION, err::kTypeMismatch);
return false;
}
if (!context->getState().isBindGeneratesResourceEnabled() &&
!context->isTextureGenerated(texture))
{
context->validationError(GL_INVALID_OPERATION, err::kObjectNotGenerated);
return false;
}
return true;
}
} // namespace gl } // namespace gl
#endif // LIBANGLE_VALIDATION_ES2_H_ #endif // LIBANGLE_VALIDATION_ES2_H_
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