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

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

Issue 1136713003: Add ES3 commands GetVertexAttribI{u}iv to GPU command buffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: switch to union Created 5 years, 7 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/service/context_state.h ('k') | gpu/command_buffer/service/context_state_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/context_state.cc
diff --git a/gpu/command_buffer/service/context_state.cc b/gpu/command_buffer/service/context_state.cc
index 5c5da8275053b1abfc106abf9dea885472572854..9232c8ed4b58a0e7fbe24e643ed808034da90f22 100644
--- a/gpu/command_buffer/service/context_state.cc
+++ b/gpu/command_buffer/service/context_state.cc
@@ -81,6 +81,113 @@ TextureUnit::TextureUnit()
TextureUnit::~TextureUnit() {
}
+bool Vec4::Equal(const Vec4& other) const {
+ if (type_ != other.type_)
+ return false;
+ switch (type_) {
+ case kFloat:
+ for (size_t ii = 0; ii < 4; ++ii) {
+ if (v_[ii].float_value != other.v_[ii].float_value)
+ return false;
+ }
+ break;
+ case kInt:
+ for (size_t ii = 0; ii < 4; ++ii) {
+ if (v_[ii].int_value != other.v_[ii].int_value)
+ return false;
+ }
+ break;
+ case kUInt:
+ for (size_t ii = 0; ii < 4; ++ii) {
+ if (v_[ii].uint_value != other.v_[ii].uint_value)
+ return false;
+ }
+ break;
+ }
+ return true;
+}
+
+template <>
+void Vec4::GetValues<GLfloat>(GLfloat* values) const {
+ DCHECK(values);
+ switch (type_) {
+ case kFloat:
+ for (size_t ii = 0; ii < 4; ++ii)
+ values[ii] = v_[ii].float_value;
+ break;
+ case kInt:
+ for (size_t ii = 0; ii < 4; ++ii)
+ values[ii] = static_cast<GLfloat>(v_[ii].int_value);
Zhenyao Mo 2015/05/13 16:52:25 Note that the casting behavior might change depend
+ break;
+ case kUInt:
+ for (size_t ii = 0; ii < 4; ++ii)
+ values[ii] = static_cast<GLfloat>(v_[ii].uint_value);
+ break;
+ }
+}
+
+template <>
+void Vec4::GetValues<GLint>(GLint* values) const {
+ DCHECK(values);
+ switch (type_) {
+ case kFloat:
+ for (size_t ii = 0; ii < 4; ++ii)
+ values[ii] = static_cast<GLint>(v_[ii].float_value);
+ break;
+ case kInt:
+ for (size_t ii = 0; ii < 4; ++ii)
+ values[ii] = v_[ii].int_value;
+ break;
+ case kUInt:
+ for (size_t ii = 0; ii < 4; ++ii)
+ values[ii] = static_cast<GLint>(v_[ii].uint_value);
+ break;
+ }
+}
+
+template <>
+void Vec4::GetValues<GLuint>(GLuint* values) const {
+ DCHECK(values);
+ switch (type_) {
+ case kFloat:
+ for (size_t ii = 0; ii < 4; ++ii)
+ values[ii] = static_cast<GLuint>(v_[ii].float_value);
+ break;
+ case kInt:
+ for (size_t ii = 0; ii < 4; ++ii)
+ values[ii] = static_cast<GLuint>(v_[ii].int_value);
+ break;
+ case kUInt:
+ for (size_t ii = 0; ii < 4; ++ii)
+ values[ii] = v_[ii].uint_value;
+ break;
+ }
+}
+
+template <>
+void Vec4::SetValues<GLfloat>(const GLfloat* values) {
+ DCHECK(values);
+ for (size_t ii = 0; ii < 4; ++ii)
+ v_[ii].float_value = values[ii];
+ type_ = kFloat;
+}
+
+template <>
+void Vec4::SetValues<GLint>(const GLint* values) {
+ DCHECK(values);
+ for (size_t ii = 0; ii < 4; ++ii)
+ v_[ii].int_value = values[ii];
+ type_ = kInt;
+}
+
+template <>
+void Vec4::SetValues<GLuint>(const GLuint* values) {
+ DCHECK(values);
+ for (size_t ii = 0; ii < 4; ++ii)
+ v_[ii].uint_value = values[ii];
+ type_ = kUInt;
+}
+
ContextState::ContextState(FeatureInfo* feature_info,
ErrorStateClient* error_state_client,
Logger* logger)
@@ -185,7 +292,29 @@ void ContextState::RestoreActiveTextureUnitBinding(unsigned int target) const {
void ContextState::RestoreVertexAttribValues() const {
for (size_t attrib = 0; attrib < vertex_attrib_manager->num_attribs();
++attrib) {
- glVertexAttrib4fv(attrib, attrib_values[attrib].v);
+ switch (attrib_values[attrib].type()) {
+ case Vec4::kFloat:
+ {
+ GLfloat v[4];
+ attrib_values[attrib].GetValues(v);
+ glVertexAttrib4fv(attrib, v);
+ }
+ break;
+ case Vec4::kInt:
+ {
+ GLint v[4];
+ attrib_values[attrib].GetValues(v);
+ glVertexAttribI4iv(attrib, v);
+ }
+ break;
+ case Vec4::kUInt:
+ {
+ GLuint v[4];
+ attrib_values[attrib].GetValues(v);
+ glVertexAttribI4uiv(attrib, v);
+ }
+ break;
+ }
}
}
« no previous file with comments | « gpu/command_buffer/service/context_state.h ('k') | gpu/command_buffer/service/context_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698