Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a541048

Browse files
null77Commit Bot
authored andcommitted
Inline ValidateBindTexture.
Tiny speed improvement in the perf test. Bug: angleproject:3117 Change-Id: Ie2892772da4808615b2a810ff523602894440b64 Reviewed-on: https://chromium-review.googlesource.com/c/1350490 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
1 parent cf9383e commit a541048

File tree

2 files changed

+71
-69
lines changed

2 files changed

+71
-69
lines changed

src/libANGLE/validationES2.cpp

Lines changed: 39 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,45 +1111,6 @@ bool ValidDstBlendFunc(const Context *context, GLenum val)
11111111

11121112
return false;
11131113
}
1114-
1115-
void RecordBindTextureTypeError(Context *context, TextureType target)
1116-
{
1117-
ASSERT(!context->getStateCache().isValidBindTextureType(target));
1118-
1119-
switch (target)
1120-
{
1121-
case TextureType::Rectangle:
1122-
ASSERT(!context->getExtensions().textureRectangle);
1123-
context->validationError(GL_INVALID_ENUM, kTextureRectangleNotSupported);
1124-
break;
1125-
1126-
case TextureType::_3D:
1127-
case TextureType::_2DArray:
1128-
ASSERT(context->getClientMajorVersion() < 3);
1129-
context->validationError(GL_INVALID_ENUM, kES3Required);
1130-
break;
1131-
1132-
case TextureType::_2DMultisample:
1133-
ASSERT(context->getClientVersion() < Version(3, 1) &&
1134-
!context->getExtensions().textureMultisample);
1135-
context->validationError(GL_INVALID_ENUM, kMultisampleTextureExtensionOrES31Required);
1136-
break;
1137-
1138-
case TextureType::_2DMultisampleArray:
1139-
ASSERT(!context->getExtensions().textureStorageMultisample2DArray);
1140-
context->validationError(GL_INVALID_ENUM, kMultisampleArrayExtensionRequired);
1141-
break;
1142-
1143-
case TextureType::External:
1144-
ASSERT(!context->getExtensions().eglImageExternal &&
1145-
!context->getExtensions().eglStreamConsumerExternal);
1146-
context->validationError(GL_INVALID_ENUM, kExternalTextureNotSupported);
1147-
break;
1148-
1149-
default:
1150-
context->validationError(GL_INVALID_ENUM, kInvalidTextureTarget);
1151-
}
1152-
}
11531114
} // anonymous namespace
11541115

11551116
bool ValidateES2TexImageParameters(Context *context,
@@ -3073,36 +3034,6 @@ bool ValidateFlushMappedBufferRangeEXT(Context *context,
30733034
return ValidateFlushMappedBufferRangeBase(context, target, offset, length);
30743035
}
30753036

3076-
bool ValidateBindTexture(Context *context, TextureType target, GLuint texture)
3077-
{
3078-
if (!context->getStateCache().isValidBindTextureType(target))
3079-
{
3080-
RecordBindTextureTypeError(context, target);
3081-
return false;
3082-
}
3083-
3084-
if (texture == 0)
3085-
{
3086-
return true;
3087-
}
3088-
3089-
Texture *textureObject = context->getTexture(texture);
3090-
if (textureObject && textureObject->getType() != target)
3091-
{
3092-
context->validationError(GL_INVALID_OPERATION, kTypeMismatch);
3093-
return false;
3094-
}
3095-
3096-
if (!context->getState().isBindGeneratesResourceEnabled() &&
3097-
!context->isTextureGenerated(texture))
3098-
{
3099-
context->validationError(GL_INVALID_OPERATION, kObjectNotGenerated);
3100-
return false;
3101-
}
3102-
3103-
return true;
3104-
}
3105-
31063037
bool ValidateBindUniformLocationCHROMIUM(Context *context,
31073038
GLuint program,
31083039
GLint location,
@@ -6654,4 +6585,43 @@ bool ValidateProvokingVertexANGLE(Context *context, ProvokingVertex modePacked)
66546585
return true;
66556586
}
66566587

6588+
void RecordBindTextureTypeError(Context *context, TextureType target)
6589+
{
6590+
ASSERT(!context->getStateCache().isValidBindTextureType(target));
6591+
6592+
switch (target)
6593+
{
6594+
case TextureType::Rectangle:
6595+
ASSERT(!context->getExtensions().textureRectangle);
6596+
context->validationError(GL_INVALID_ENUM, kTextureRectangleNotSupported);
6597+
break;
6598+
6599+
case TextureType::_3D:
6600+
case TextureType::_2DArray:
6601+
ASSERT(context->getClientMajorVersion() < 3);
6602+
context->validationError(GL_INVALID_ENUM, kES3Required);
6603+
break;
6604+
6605+
case TextureType::_2DMultisample:
6606+
ASSERT(context->getClientVersion() < Version(3, 1) &&
6607+
!context->getExtensions().textureMultisample);
6608+
context->validationError(GL_INVALID_ENUM, kMultisampleTextureExtensionOrES31Required);
6609+
break;
6610+
6611+
case TextureType::_2DMultisampleArray:
6612+
ASSERT(!context->getExtensions().textureStorageMultisample2DArray);
6613+
context->validationError(GL_INVALID_ENUM, kMultisampleArrayExtensionRequired);
6614+
break;
6615+
6616+
case TextureType::External:
6617+
ASSERT(!context->getExtensions().eglImageExternal &&
6618+
!context->getExtensions().eglStreamConsumerExternal);
6619+
context->validationError(GL_INVALID_ENUM, kExternalTextureNotSupported);
6620+
break;
6621+
6622+
default:
6623+
context->validationError(GL_INVALID_ENUM, kInvalidTextureTarget);
6624+
}
6625+
}
6626+
66576627
} // namespace gl

src/libANGLE/validationES2.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,38 @@ ANGLE_INLINE bool ValidateVertexAttribPointer(Context *context,
121121

122122
return true;
123123
}
124+
125+
void RecordBindTextureTypeError(Context *context, TextureType target);
126+
127+
ANGLE_INLINE bool ValidateBindTexture(Context *context, TextureType target, GLuint texture)
128+
{
129+
if (!context->getStateCache().isValidBindTextureType(target))
130+
{
131+
RecordBindTextureTypeError(context, target);
132+
return false;
133+
}
134+
135+
if (texture == 0)
136+
{
137+
return true;
138+
}
139+
140+
Texture *textureObject = context->getTexture(texture);
141+
if (textureObject && textureObject->getType() != target)
142+
{
143+
context->validationError(GL_INVALID_OPERATION, err::kTypeMismatch);
144+
return false;
145+
}
146+
147+
if (!context->getState().isBindGeneratesResourceEnabled() &&
148+
!context->isTextureGenerated(texture))
149+
{
150+
context->validationError(GL_INVALID_OPERATION, err::kObjectNotGenerated);
151+
return false;
152+
}
153+
154+
return true;
155+
}
124156
} // namespace gl
125157

126158
#endif // LIBANGLE_VALIDATION_ES2_H_

0 commit comments

Comments
 (0)