Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 439253002: Micro-optimization in HandleVertexAttribPointer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/gles2_cmd_decoder.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 8d3358757aa7a50c07391d23edb6e9a6cfd70b7a..7e5f94223651dab84daffc5b04579490d55f3356 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -7205,13 +7205,15 @@ error::Error GLES2DecoderImpl::HandleVertexAttribPointer(
}
GLsizei component_size =
GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type);
- if (offset % component_size > 0) {
+ // component_size must be a power of two to use & as optimized modulo.
+ DCHECK(GLES2Util::IsPOT(component_size));
+ if (offset & (component_size - 1)) {
LOCAL_SET_GL_ERROR(
GL_INVALID_OPERATION,
"glVertexAttribPointer", "offset not valid for type");
return error::kNoError;
}
- if (stride % component_size > 0) {
+ if (stride & (component_size - 1)) {
LOCAL_SET_GL_ERROR(
GL_INVALID_OPERATION,
"glVertexAttribPointer", "stride not valid for type");
@@ -7984,8 +7986,7 @@ bool IsValidDXTSize(GLint level, GLsizei size) {
}
bool IsValidPVRTCSize(GLint level, GLsizei size) {
- // Ensure that the size is a power of two
- return (size & (size - 1)) == 0;
+ return GLES2Util::IsPOT(size);
}
} // anonymous namespace.
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698