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

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
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..b4afb9ff7be6ac90c793c631f0e3b2e8d5ad9d8a 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 'n' more than "someuniform[0]".
apatrick_chromium 2012/06/18 18:58:03 nit: [1]->[n]
+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

Powered by Google App Engine
This is Rietveld 408576698