summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorvmiura@chromium.org <vmiura@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-16 03:50:53 +0000
committervmiura@chromium.org <vmiura@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-16 03:50:53 +0000
commit9f2a22de216cefa3a9f4556fab21fee8b99da910 (patch)
tree19540595db48508b95741e1062040cdd3d85bc22 /gpu
parentf80a593f750aaa51fde745d61e294f73be6c19af (diff)
downloadchromium_src-9f2a22de216cefa3a9f4556fab21fee8b99da910.zip
chromium_src-9f2a22de216cefa3a9f4556fab21fee8b99da910.tar.gz
chromium_src-9f2a22de216cefa3a9f4556fab21fee8b99da910.tar.bz2
Restore bound VAO in ContextState::RestoreState().
BUG=363407 Review URL: https://codereview.chromium.org/237893004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@264104 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/service/context_state.cc38
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc14
2 files changed, 43 insertions, 9 deletions
diff --git a/gpu/command_buffer/service/context_state.cc b/gpu/command_buffer/service/context_state.cc
index 6c81655..88715a2 100644
--- a/gpu/command_buffer/service/context_state.cc
+++ b/gpu/command_buffer/service/context_state.cc
@@ -193,11 +193,21 @@ void ContextState::RestoreAttribute(GLuint attrib_index) const {
vertex_attrib_manager->GetVertexAttrib(attrib_index);
const void* ptr = reinterpret_cast<const void*>(attrib->offset());
Buffer* buffer = attrib->buffer();
- glBindBuffer(GL_ARRAY_BUFFER, buffer ? buffer->service_id() : 0);
- glVertexAttribPointer(
- attrib_index, attrib->size(), attrib->type(), attrib->normalized(),
- attrib->gl_stride(), ptr);
- if (attrib->divisor())
+ GLuint buffer_service_id = buffer ? buffer->service_id() : 0;
+ glBindBuffer(GL_ARRAY_BUFFER, buffer_service_id);
+
+ if (buffer_service_id || vertex_attrib_manager->service_id() == 0) {
+ // On Adreno driver glVertexAttribPointer with GL_ARRAY_BUFFER == 0
+ // and VAO != 0 causes error GL_INVALID_OPERATION.
+ glVertexAttribPointer(attrib_index,
+ attrib->size(),
+ attrib->type(),
+ attrib->normalized(),
+ attrib->gl_stride(),
+ ptr);
+ }
+
+ if (feature_info_->feature_flags().angle_instanced_arrays)
glVertexAttribDivisorANGLE(attrib_index, attrib->divisor());
// Never touch vertex attribute 0's state (in particular, never
// disable it) when running on desktop GL because it will never be
@@ -225,10 +235,20 @@ void ContextState::RestoreState(const ContextState* prev_state) const {
// TODO: This if should not be needed. RestoreState is getting called
// before GLES2Decoder::Initialize which is a bug.
if (vertex_attrib_manager.get()) {
- // TODO(gman): Move this restoration to VertexAttribManager.
- for (size_t attrib = 0; attrib < vertex_attrib_manager->num_attribs();
- ++attrib) {
- RestoreAttribute(attrib);
+ if (feature_info_->feature_flags().native_vertex_array_object) {
+ GLuint service_id = vertex_attrib_manager->service_id();
+ glBindVertexArrayOES(service_id);
+ for (size_t attrib = 0; attrib < vertex_attrib_manager->num_attribs();
+ ++attrib) {
+ glVertexAttrib4fv(attrib, attrib_values[attrib].v);
+ }
+ } else {
+ // Emulated VAO, so restore every attribute.
+ // TODO(gman): Move this restoration to VertexAttribManager.
+ for (size_t attrib = 0; attrib < vertex_attrib_manager->num_attribs();
+ ++attrib) {
+ RestoreAttribute(attrib);
+ }
}
}
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
index 19b7292..3c53d63 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -9167,6 +9167,20 @@ TEST_F(GLES2DecoderRestoreStateTest, DefaultUnit1) {
GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
}
+// TODO(vmiura): Tests for VAO restore.
+
+// TODO(vmiura): Tests for ContextState::RestoreAttribute().
+
+// TODO(vmiura): Tests for ContextState::RestoreBufferBindings().
+
+// TODO(vmiura): Tests for ContextState::RestoreProgramBindings().
+
+// TODO(vmiura): Tests for RestoreRenderbufferBindings().
+
+// TODO(vmiura): Tests for RestoreProgramBindings().
+
+// TODO(vmiura): Tests for RestoreGlobalState().
+
TEST_F(GLES2DecoderManualInitTest, ClearUniformsBeforeFirstProgramUse) {
CommandLine command_line(0, NULL);
command_line.AppendSwitchASCII(