| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 vertex_array_manager()->GetVertexAttribManager(client_id); | 1090 vertex_array_manager()->GetVertexAttribManager(client_id); |
| 1091 return info; | 1091 return info; |
| 1092 } | 1092 } |
| 1093 | 1093 |
| 1094 // Removes the vertex attrib manager for the given vertex array. | 1094 // Removes the vertex attrib manager for the given vertex array. |
| 1095 void RemoveVertexAttribManager(GLuint client_id) { | 1095 void RemoveVertexAttribManager(GLuint client_id) { |
| 1096 vertex_array_manager()->RemoveVertexAttribManager(client_id); | 1096 vertex_array_manager()->RemoveVertexAttribManager(client_id); |
| 1097 } | 1097 } |
| 1098 | 1098 |
| 1099 // Creates a vertex attrib manager for the given vertex array. | 1099 // Creates a vertex attrib manager for the given vertex array. |
| 1100 void CreateVertexAttribManager(GLuint client_id, GLuint service_id) { | 1100 scoped_refptr<VertexAttribManager> CreateVertexAttribManager( |
| 1101 vertex_array_manager()->CreateVertexAttribManager( | 1101 GLuint client_id, |
| 1102 client_id, service_id, group_->max_vertex_attribs()); | 1102 GLuint service_id, |
| 1103 bool client_visible) { |
| 1104 return vertex_array_manager()->CreateVertexAttribManager( |
| 1105 client_id, service_id, group_->max_vertex_attribs(), client_visible); |
| 1103 } | 1106 } |
| 1104 | 1107 |
| 1105 void DoBindAttribLocation(GLuint client_id, GLuint index, const char* name); | 1108 void DoBindAttribLocation(GLuint client_id, GLuint index, const char* name); |
| 1106 void DoBindUniformLocationCHROMIUM( | 1109 void DoBindUniformLocationCHROMIUM( |
| 1107 GLuint client_id, GLint location, const char* name); | 1110 GLuint client_id, GLint location, const char* name); |
| 1108 | 1111 |
| 1109 error::Error GetAttribLocationHelper( | 1112 error::Error GetAttribLocationHelper( |
| 1110 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, | 1113 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, |
| 1111 const std::string& name_str); | 1114 const std::string& name_str); |
| 1112 | 1115 |
| (...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2340 << "failed to initialize."; | 2343 << "failed to initialize."; |
| 2341 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. | 2344 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. |
| 2342 Destroy(true); | 2345 Destroy(true); |
| 2343 return false; | 2346 return false; |
| 2344 } | 2347 } |
| 2345 CHECK_GL_ERROR(); | 2348 CHECK_GL_ERROR(); |
| 2346 | 2349 |
| 2347 disallowed_features_ = disallowed_features; | 2350 disallowed_features_ = disallowed_features; |
| 2348 | 2351 |
| 2349 state_.attrib_values.resize(group_->max_vertex_attribs()); | 2352 state_.attrib_values.resize(group_->max_vertex_attribs()); |
| 2350 state_.default_vertex_attrib_manager = new VertexAttribManager(); | 2353 vertex_array_manager_.reset(new VertexArrayManager()); |
| 2354 |
| 2355 GLuint default_vertex_attrib_service_id = 0; |
| 2356 if (features().native_vertex_array_object) { |
| 2357 glGenVertexArraysOES(1, &default_vertex_attrib_service_id); |
| 2358 glBindVertexArrayOES(default_vertex_attrib_service_id); |
| 2359 } |
| 2360 |
| 2361 state_.default_vertex_attrib_manager = |
| 2362 CreateVertexAttribManager(0, default_vertex_attrib_service_id, false); |
| 2363 |
| 2351 state_.default_vertex_attrib_manager->Initialize( | 2364 state_.default_vertex_attrib_manager->Initialize( |
| 2352 group_->max_vertex_attribs(), | 2365 group_->max_vertex_attribs(), |
| 2353 feature_info_->workarounds().init_vertex_attributes); | 2366 feature_info_->workarounds().init_vertex_attributes); |
| 2354 | 2367 |
| 2355 // vertex_attrib_manager is set to default_vertex_attrib_manager by this call | 2368 // vertex_attrib_manager is set to default_vertex_attrib_manager by this call |
| 2356 DoBindVertexArrayOES(0); | 2369 DoBindVertexArrayOES(0); |
| 2357 | 2370 |
| 2358 query_manager_.reset(new QueryManager(this, feature_info_.get())); | 2371 query_manager_.reset(new QueryManager(this, feature_info_.get())); |
| 2359 vertex_array_manager_.reset(new VertexArrayManager()); | |
| 2360 | 2372 |
| 2361 util_.set_num_compressed_texture_formats( | 2373 util_.set_num_compressed_texture_formats( |
| 2362 validators_->compressed_texture_format.GetValues().size()); | 2374 validators_->compressed_texture_format.GetValues().size()); |
| 2363 | 2375 |
| 2364 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { | 2376 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
| 2365 // We have to enable vertex array 0 on OpenGL or it won't render. Note that | 2377 // We have to enable vertex array 0 on OpenGL or it won't render. Note that |
| 2366 // OpenGL ES 2.0 does not have this issue. | 2378 // OpenGL ES 2.0 does not have this issue. |
| 2367 glEnableVertexAttribArray(0); | 2379 glEnableVertexAttribArray(0); |
| 2368 } | 2380 } |
| 2369 glGenBuffersARB(1, &attrib_0_buffer_id_); | 2381 glGenBuffersARB(1, &attrib_0_buffer_id_); |
| (...skipping 7307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9677 GLsizei n, const GLuint* client_ids) { | 9689 GLsizei n, const GLuint* client_ids) { |
| 9678 for (GLsizei ii = 0; ii < n; ++ii) { | 9690 for (GLsizei ii = 0; ii < n; ++ii) { |
| 9679 if (GetVertexAttribManager(client_ids[ii])) { | 9691 if (GetVertexAttribManager(client_ids[ii])) { |
| 9680 return false; | 9692 return false; |
| 9681 } | 9693 } |
| 9682 } | 9694 } |
| 9683 | 9695 |
| 9684 if (!features().native_vertex_array_object) { | 9696 if (!features().native_vertex_array_object) { |
| 9685 // Emulated VAO | 9697 // Emulated VAO |
| 9686 for (GLsizei ii = 0; ii < n; ++ii) { | 9698 for (GLsizei ii = 0; ii < n; ++ii) { |
| 9687 CreateVertexAttribManager(client_ids[ii], 0); | 9699 CreateVertexAttribManager(client_ids[ii], 0, true); |
| 9688 } | 9700 } |
| 9689 } else { | 9701 } else { |
| 9690 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); | 9702 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); |
| 9691 | 9703 |
| 9692 glGenVertexArraysOES(n, service_ids.get()); | 9704 glGenVertexArraysOES(n, service_ids.get()); |
| 9693 for (GLsizei ii = 0; ii < n; ++ii) { | 9705 for (GLsizei ii = 0; ii < n; ++ii) { |
| 9694 CreateVertexAttribManager(client_ids[ii], service_ids[ii]); | 9706 CreateVertexAttribManager(client_ids[ii], service_ids[ii], true); |
| 9695 } | 9707 } |
| 9696 } | 9708 } |
| 9697 | 9709 |
| 9698 return true; | 9710 return true; |
| 9699 } | 9711 } |
| 9700 | 9712 |
| 9701 void GLES2DecoderImpl::DeleteVertexArraysOESHelper( | 9713 void GLES2DecoderImpl::DeleteVertexArraysOESHelper( |
| 9702 GLsizei n, const GLuint* client_ids) { | 9714 GLsizei n, const GLuint* client_ids) { |
| 9703 for (GLsizei ii = 0; ii < n; ++ii) { | 9715 for (GLsizei ii = 0; ii < n; ++ii) { |
| 9704 VertexAttribManager* vao = | 9716 VertexAttribManager* vao = |
| 9705 GetVertexAttribManager(client_ids[ii]); | 9717 GetVertexAttribManager(client_ids[ii]); |
| 9706 if (vao && !vao->IsDeleted()) { | 9718 if (vao && !vao->IsDeleted()) { |
| 9707 if (state_.vertex_attrib_manager.get() == vao) { | 9719 if (state_.vertex_attrib_manager.get() == vao) { |
| 9708 DoBindVertexArrayOES(0); | 9720 DoBindVertexArrayOES(0); |
| 9709 } | 9721 } |
| 9710 RemoveVertexAttribManager(client_ids[ii]); | 9722 RemoveVertexAttribManager(client_ids[ii]); |
| 9711 } | 9723 } |
| 9712 } | 9724 } |
| 9713 } | 9725 } |
| 9714 | 9726 |
| 9715 void GLES2DecoderImpl::DoBindVertexArrayOES(GLuint client_id) { | 9727 void GLES2DecoderImpl::DoBindVertexArrayOES(GLuint client_id) { |
| 9716 VertexAttribManager* vao = NULL; | 9728 VertexAttribManager* vao = NULL; |
| 9717 GLuint service_id = 0; | |
| 9718 if (client_id != 0) { | 9729 if (client_id != 0) { |
| 9719 vao = GetVertexAttribManager(client_id); | 9730 vao = GetVertexAttribManager(client_id); |
| 9720 if (!vao) { | 9731 if (!vao) { |
| 9721 // Unlike most Bind* methods, the spec explicitly states that VertexArray | 9732 // Unlike most Bind* methods, the spec explicitly states that VertexArray |
| 9722 // only allows names that have been previously generated. As such, we do | 9733 // only allows names that have been previously generated. As such, we do |
| 9723 // not generate new names here. | 9734 // not generate new names here. |
| 9724 LOCAL_SET_GL_ERROR( | 9735 LOCAL_SET_GL_ERROR( |
| 9725 GL_INVALID_OPERATION, | 9736 GL_INVALID_OPERATION, |
| 9726 "glBindVertexArrayOES", "bad vertex array id."); | 9737 "glBindVertexArrayOES", "bad vertex array id."); |
| 9727 current_decoder_error_ = error::kNoError; | 9738 current_decoder_error_ = error::kNoError; |
| 9728 return; | 9739 return; |
| 9729 } else { | |
| 9730 service_id = vao->service_id(); | |
| 9731 } | 9740 } |
| 9732 } else { | 9741 } else { |
| 9733 vao = state_.default_vertex_attrib_manager.get(); | 9742 vao = state_.default_vertex_attrib_manager.get(); |
| 9734 } | 9743 } |
| 9735 | 9744 |
| 9736 // Only set the VAO state if it's changed | 9745 // Only set the VAO state if it's changed |
| 9737 if (state_.vertex_attrib_manager.get() != vao) { | 9746 if (state_.vertex_attrib_manager.get() != vao) { |
| 9738 state_.vertex_attrib_manager = vao; | 9747 state_.vertex_attrib_manager = vao; |
| 9739 if (!features().native_vertex_array_object) { | 9748 if (!features().native_vertex_array_object) { |
| 9740 EmulateVertexArrayState(); | 9749 EmulateVertexArrayState(); |
| 9741 } else { | 9750 } else { |
| 9751 GLuint service_id = vao->service_id(); |
| 9742 glBindVertexArrayOES(service_id); | 9752 glBindVertexArrayOES(service_id); |
| 9743 } | 9753 } |
| 9744 } | 9754 } |
| 9745 } | 9755 } |
| 9746 | 9756 |
| 9747 // Used when OES_vertex_array_object isn't natively supported | 9757 // Used when OES_vertex_array_object isn't natively supported |
| 9748 void GLES2DecoderImpl::EmulateVertexArrayState() { | 9758 void GLES2DecoderImpl::EmulateVertexArrayState() { |
| 9749 // Setup the Vertex attribute state | 9759 // Setup the Vertex attribute state |
| 9750 for (uint32 vv = 0; vv < group_->max_vertex_attribs(); ++vv) { | 9760 for (uint32 vv = 0; vv < group_->max_vertex_attribs(); ++vv) { |
| 9751 RestoreStateForAttrib(vv); | 9761 RestoreStateForAttrib(vv); |
| (...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10787 } | 10797 } |
| 10788 } | 10798 } |
| 10789 | 10799 |
| 10790 // Include the auto-generated part of this file. We split this because it means | 10800 // Include the auto-generated part of this file. We split this because it means |
| 10791 // we can easily edit the non-auto generated parts right here in this file | 10801 // we can easily edit the non-auto generated parts right here in this file |
| 10792 // instead of having to edit some template or the code generator. | 10802 // instead of having to edit some template or the code generator. |
| 10793 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10803 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 10794 | 10804 |
| 10795 } // namespace gles2 | 10805 } // namespace gles2 |
| 10796 } // namespace gpu | 10806 } // namespace gpu |
| OLD | NEW |