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

Unified Diff: gpu/command_buffer/common/gles2_cmd_utils.cc

Issue 10568003: Add support for GL_CHROMIUM_consistent_uniform_locations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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') | gpu/command_buffer/common/gles2_cmd_utils_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/common/gles2_cmd_utils.cc
diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc
index ea0bd7387487462c7ef9b953fcb2bffd739491d8..5cecd2e07f43ab5b945623eb8423fdc5c29c4696 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils.cc
+++ b/gpu/command_buffer/common/gles2_cmd_utils.cc
@@ -758,6 +758,29 @@ bool ContextCreationAttribParser::Parse(const std::vector<int32>& attribs) {
return true;
}
+// Swizzles the locations to prevent developers from assuming they
+// can do math on uniforms. According to the OpenGL ES 2.0 spec
+// the location of "someuniform[1]" is not '1' more than "someuniform[0]".
+static int32 Swizzle(int32 location) {
+ return (location & 0xF0000000U) |
+ ((location & 0x0AAAAAAAU) >> 1) |
+ ((location & 0x05555555U) << 1);
+}
+
+// Adds uniform_swizzle_ to prevent developers from assuming that locations are
+// always the same across GPUs and drivers.
+int32 GLES2Util::SwizzleLocation(int32 v) {
+ return v < 0 ? v : Swizzle(v);
+}
+
+int32 GLES2Util::UnswizzleLocation(int32 v) {
+ return v < 0 ? v : Swizzle(v);
+}
+
+int32 GLES2Util::MakeFakeLocation(int32 index, int32 element) {
+ return index + element * 0x10000;
+}
+
#include "../common/gles2_cmd_utils_implementation_autogen.h"
} // namespace gles2
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.h ('k') | gpu/command_buffer/common/gles2_cmd_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698