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

Unified Diff: gpu/command_buffer/client/gles2_implementation.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/client/gles2_implementation.cc
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index 5d46196ff18716d7950e3757bb5f4eed017534ed..575d180b11a0ad51f42415fd966cf77d3b19c8dc 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -6,9 +6,10 @@
#include "../client/gles2_implementation.h"
+#include <algorithm>
#include <map>
-#include <set>
#include <queue>
+#include <set>
#include <GLES2/gl2ext.h>
#include "../client/mapped_memory.h"
#include "../client/program_info_manager.h"
@@ -2090,6 +2091,7 @@ const GLubyte* GLES2Implementation::GetStringHelper(GLenum name) {
str += std::string(str.empty() ? "" : " ") +
"GL_CHROMIUM_map_sub "
"GL_CHROMIUM_flipy "
+ "GL_CHROMIUM_consistent_uniform_locations "
"GL_EXT_unpack_subimage";
break;
default:
@@ -3276,5 +3278,76 @@ void GLES2Implementation::GenMailboxCHROMIUM(
std::copy(result.begin(), result.end(), mailbox);
}
+namespace {
+
+class GLUniformDefinitionComparer {
+ public:
+ explicit GLUniformDefinitionComparer(
+ const GLUniformDefinitionCHROMIUM* uniforms)
+ : uniforms_(uniforms) {
+ }
+
+ bool operator()(const GLint lhs, const GLint rhs) const {
+ return strcmp(uniforms_[lhs].name, uniforms_[rhs].name) < 0;
+ }
+
+ private:
+ const GLUniformDefinitionCHROMIUM* uniforms_;
+};
+
+} // anonymous namespace.
+
+void GLES2Implementation::GetUniformLocationsCHROMIUM(
+ const GLUniformDefinitionCHROMIUM* uniforms,
+ GLsizei count,
+ GLsizei max_locations,
+ GLint* locations) {
+ GPU_CLIENT_SINGLE_THREAD_CHECK();
+ GPU_CLIENT_LOG("[" << this << "] glGenUniformLocationsCHROMIUM("
+ << static_cast<const void*>(uniforms) << ", " << count << ", "
+ << max_locations << ", " << static_cast<const void*>(locations) << ")");
+
+ if (count <= 0) {
+ SetGLError(GL_INVALID_VALUE, "glGetUniformLocationsCHROMIUM", "count <= 0");
+ return;
+ }
+
+ for (GLsizei ii = 0; ii < count; ++ii) {
+ const GLUniformDefinitionCHROMIUM& def = uniforms[ii];
+ if (def.size <= 0) {
+ SetGLError(
+ GL_INVALID_VALUE, "glGetUniformLocationsCHROMIUM", "size <= 0");
+ return;
+ }
+ }
+
+ scoped_array<GLint> indices(new GLint[count]);
+ for (GLint ii = 0; ii < count; ++ii) {
+ indices[ii] = ii;
+ }
+
+ std::sort(&indices[0], &indices[count],
+ GLUniformDefinitionComparer(uniforms));
+
+ scoped_array<GLint> reverse_map(new GLint[count]);
+
+ for (GLint ii = 0; ii < count; ++ii) {
+ reverse_map[indices[ii]] = ii;
+ }
+
+ for (GLsizei ii = 0; ii < count; ++ii) {
+ const GLUniformDefinitionCHROMIUM& def = uniforms[ii];
+ GLint base_location = reverse_map[ii];
+ for (GLsizei jj = 0; jj < def.size; ++jj) {
+ if (max_locations <= 0) {
+ return;
+ }
+ *locations++ = GLES2Util::SwizzleLocation(
+ GLES2Util::MakeFakeLocation(base_location, jj));
+ --max_locations;
+ }
+ }
+}
+
} // namespace gles2
} // namespace gpu
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.h ('k') | gpu/command_buffer/client/gles2_implementation_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698