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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 235563002: gpu: Separate GpuControlService from GpuControl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove MailboxManager Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 vertex_array_manager()->GetVertexAttribManager(client_id); 1098 vertex_array_manager()->GetVertexAttribManager(client_id);
1099 return info; 1099 return info;
1100 } 1100 }
1101 1101
1102 // Removes the vertex attrib manager for the given vertex array. 1102 // Removes the vertex attrib manager for the given vertex array.
1103 void RemoveVertexAttribManager(GLuint client_id) { 1103 void RemoveVertexAttribManager(GLuint client_id) {
1104 vertex_array_manager()->RemoveVertexAttribManager(client_id); 1104 vertex_array_manager()->RemoveVertexAttribManager(client_id);
1105 } 1105 }
1106 1106
1107 // Creates a vertex attrib manager for the given vertex array. 1107 // Creates a vertex attrib manager for the given vertex array.
1108 scoped_refptr<VertexAttribManager> CreateVertexAttribManager( 1108 void CreateVertexAttribManager(GLuint client_id, GLuint service_id) {
1109 GLuint client_id,
1110 GLuint service_id,
1111 bool client_visible) {
1112 return vertex_array_manager()->CreateVertexAttribManager( 1109 return vertex_array_manager()->CreateVertexAttribManager(
1113 client_id, service_id, group_->max_vertex_attribs(), client_visible); 1110 client_id, service_id, group_->max_vertex_attribs());
1114 } 1111 }
1115 1112
1116 void DoBindAttribLocation(GLuint client_id, GLuint index, const char* name); 1113 void DoBindAttribLocation(GLuint client_id, GLuint index, const char* name);
1117 void DoBindUniformLocationCHROMIUM( 1114 void DoBindUniformLocationCHROMIUM(
1118 GLuint client_id, GLint location, const char* name); 1115 GLuint client_id, GLint location, const char* name);
1119 1116
1120 error::Error GetAttribLocationHelper( 1117 error::Error GetAttribLocationHelper(
1121 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 1118 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
1122 const std::string& name_str); 1119 const std::string& name_str);
1123 1120
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after
2351 << "failed to initialize."; 2348 << "failed to initialize.";
2352 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. 2349 group_ = NULL; // Must not destroy ContextGroup if it is not initialized.
2353 Destroy(true); 2350 Destroy(true);
2354 return false; 2351 return false;
2355 } 2352 }
2356 CHECK_GL_ERROR(); 2353 CHECK_GL_ERROR();
2357 2354
2358 disallowed_features_ = disallowed_features; 2355 disallowed_features_ = disallowed_features;
2359 2356
2360 state_.attrib_values.resize(group_->max_vertex_attribs()); 2357 state_.attrib_values.resize(group_->max_vertex_attribs());
2361 vertex_array_manager_.reset(new VertexArrayManager()); 2358 state_.default_vertex_attrib_manager = new VertexAttribManager();
vmiura 2014/05/08 20:21:22 Was there a reason for this change? Using non zer
boliu 2014/05/08 20:23:25 Doh! Really sorry! I had your CL locally reverted
2362
2363 GLuint default_vertex_attrib_service_id = 0;
2364 if (features().native_vertex_array_object) {
2365 glGenVertexArraysOES(1, &default_vertex_attrib_service_id);
2366 glBindVertexArrayOES(default_vertex_attrib_service_id);
2367 }
2368
2369 state_.default_vertex_attrib_manager =
2370 CreateVertexAttribManager(0, default_vertex_attrib_service_id, false);
2371
2372 state_.default_vertex_attrib_manager->Initialize( 2359 state_.default_vertex_attrib_manager->Initialize(
2373 group_->max_vertex_attribs(), 2360 group_->max_vertex_attribs(),
2374 feature_info_->workarounds().init_vertex_attributes); 2361 feature_info_->workarounds().init_vertex_attributes);
2375 2362
2376 // vertex_attrib_manager is set to default_vertex_attrib_manager by this call 2363 // vertex_attrib_manager is set to default_vertex_attrib_manager by this call
2377 DoBindVertexArrayOES(0); 2364 DoBindVertexArrayOES(0);
2378 2365
2379 query_manager_.reset(new QueryManager(this, feature_info_.get())); 2366 query_manager_.reset(new QueryManager(this, feature_info_.get()));
2367 vertex_array_manager_.reset(new VertexArrayManager());
2380 2368
2381 util_.set_num_compressed_texture_formats( 2369 util_.set_num_compressed_texture_formats(
2382 validators_->compressed_texture_format.GetValues().size()); 2370 validators_->compressed_texture_format.GetValues().size());
2383 2371
2384 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { 2372 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
2385 // We have to enable vertex array 0 on OpenGL or it won't render. Note that 2373 // We have to enable vertex array 0 on OpenGL or it won't render. Note that
2386 // OpenGL ES 2.0 does not have this issue. 2374 // OpenGL ES 2.0 does not have this issue.
2387 glEnableVertexAttribArray(0); 2375 glEnableVertexAttribArray(0);
2388 } 2376 }
2389 glGenBuffersARB(1, &attrib_0_buffer_id_); 2377 glGenBuffersARB(1, &attrib_0_buffer_id_);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
2681 caps.discard_framebuffer = 2669 caps.discard_framebuffer =
2682 feature_info_->feature_flags().ext_discard_framebuffer; 2670 feature_info_->feature_flags().ext_discard_framebuffer;
2683 caps.sync_query = feature_info_->feature_flags().chromium_sync_query; 2671 caps.sync_query = feature_info_->feature_flags().chromium_sync_query;
2684 2672
2685 #if defined(OS_MACOSX) 2673 #if defined(OS_MACOSX)
2686 // This is unconditionally true on mac, no need to test for it at runtime. 2674 // This is unconditionally true on mac, no need to test for it at runtime.
2687 caps.iosurface = true; 2675 caps.iosurface = true;
2688 #endif 2676 #endif
2689 2677
2690 caps.post_sub_buffer = supports_post_sub_buffer_; 2678 caps.post_sub_buffer = supports_post_sub_buffer_;
2679 caps.map_image = !!image_manager();
2691 2680
2692 return caps; 2681 return caps;
2693 } 2682 }
2694 2683
2695 void GLES2DecoderImpl::UpdateCapabilities() { 2684 void GLES2DecoderImpl::UpdateCapabilities() {
2696 util_.set_num_compressed_texture_formats( 2685 util_.set_num_compressed_texture_formats(
2697 validators_->compressed_texture_format.GetValues().size()); 2686 validators_->compressed_texture_format.GetValues().size());
2698 util_.set_num_shader_binary_formats( 2687 util_.set_num_shader_binary_formats(
2699 validators_->shader_binary_format.GetValues().size()); 2688 validators_->shader_binary_format.GetValues().size());
2700 } 2689 }
(...skipping 6987 matching lines...) Expand 10 before | Expand all | Expand 10 after
9688 GLsizei n, const GLuint* client_ids) { 9677 GLsizei n, const GLuint* client_ids) {
9689 for (GLsizei ii = 0; ii < n; ++ii) { 9678 for (GLsizei ii = 0; ii < n; ++ii) {
9690 if (GetVertexAttribManager(client_ids[ii])) { 9679 if (GetVertexAttribManager(client_ids[ii])) {
9691 return false; 9680 return false;
9692 } 9681 }
9693 } 9682 }
9694 9683
9695 if (!features().native_vertex_array_object) { 9684 if (!features().native_vertex_array_object) {
9696 // Emulated VAO 9685 // Emulated VAO
9697 for (GLsizei ii = 0; ii < n; ++ii) { 9686 for (GLsizei ii = 0; ii < n; ++ii) {
9698 CreateVertexAttribManager(client_ids[ii], 0, true); 9687 CreateVertexAttribManager(client_ids[ii], 0);
9699 } 9688 }
9700 } else { 9689 } else {
9701 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); 9690 scoped_ptr<GLuint[]> service_ids(new GLuint[n]);
9702 9691
9703 glGenVertexArraysOES(n, service_ids.get()); 9692 glGenVertexArraysOES(n, service_ids.get());
9704 for (GLsizei ii = 0; ii < n; ++ii) { 9693 for (GLsizei ii = 0; ii < n; ++ii) {
9705 CreateVertexAttribManager(client_ids[ii], service_ids[ii], true); 9694 CreateVertexAttribManager(client_ids[ii], service_ids[ii]);
9706 } 9695 }
9707 } 9696 }
9708 9697
9709 return true; 9698 return true;
9710 } 9699 }
9711 9700
9712 void GLES2DecoderImpl::DeleteVertexArraysOESHelper( 9701 void GLES2DecoderImpl::DeleteVertexArraysOESHelper(
9713 GLsizei n, const GLuint* client_ids) { 9702 GLsizei n, const GLuint* client_ids) {
9714 for (GLsizei ii = 0; ii < n; ++ii) { 9703 for (GLsizei ii = 0; ii < n; ++ii) {
9715 VertexAttribManager* vao = 9704 VertexAttribManager* vao =
9716 GetVertexAttribManager(client_ids[ii]); 9705 GetVertexAttribManager(client_ids[ii]);
9717 if (vao && !vao->IsDeleted()) { 9706 if (vao && !vao->IsDeleted()) {
9718 if (state_.vertex_attrib_manager.get() == vao) { 9707 if (state_.vertex_attrib_manager.get() == vao) {
9719 DoBindVertexArrayOES(0); 9708 DoBindVertexArrayOES(0);
9720 } 9709 }
9721 RemoveVertexAttribManager(client_ids[ii]); 9710 RemoveVertexAttribManager(client_ids[ii]);
9722 } 9711 }
9723 } 9712 }
9724 } 9713 }
9725 9714
9726 void GLES2DecoderImpl::DoBindVertexArrayOES(GLuint client_id) { 9715 void GLES2DecoderImpl::DoBindVertexArrayOES(GLuint client_id) {
9727 VertexAttribManager* vao = NULL; 9716 VertexAttribManager* vao = NULL;
9717 GLuint service_id = 0;
9728 if (client_id != 0) { 9718 if (client_id != 0) {
9729 vao = GetVertexAttribManager(client_id); 9719 vao = GetVertexAttribManager(client_id);
9730 if (!vao) { 9720 if (!vao) {
9731 // Unlike most Bind* methods, the spec explicitly states that VertexArray 9721 // Unlike most Bind* methods, the spec explicitly states that VertexArray
9732 // only allows names that have been previously generated. As such, we do 9722 // only allows names that have been previously generated. As such, we do
9733 // not generate new names here. 9723 // not generate new names here.
9734 LOCAL_SET_GL_ERROR( 9724 LOCAL_SET_GL_ERROR(
9735 GL_INVALID_OPERATION, 9725 GL_INVALID_OPERATION,
9736 "glBindVertexArrayOES", "bad vertex array id."); 9726 "glBindVertexArrayOES", "bad vertex array id.");
9737 current_decoder_error_ = error::kNoError; 9727 current_decoder_error_ = error::kNoError;
9738 return; 9728 return;
9729 } else {
9730 service_id = vao->service_id();
9739 } 9731 }
9740 } else { 9732 } else {
9741 vao = state_.default_vertex_attrib_manager.get(); 9733 vao = state_.default_vertex_attrib_manager.get();
9742 } 9734 }
9743 9735
9744 // Only set the VAO state if it's changed 9736 // Only set the VAO state if it's changed
9745 if (state_.vertex_attrib_manager.get() != vao) { 9737 if (state_.vertex_attrib_manager.get() != vao) {
9746 state_.vertex_attrib_manager = vao; 9738 state_.vertex_attrib_manager = vao;
9747 if (!features().native_vertex_array_object) { 9739 if (!features().native_vertex_array_object) {
9748 EmulateVertexArrayState(); 9740 EmulateVertexArrayState();
9749 } else { 9741 } else {
9750 GLuint service_id = vao->service_id();
9751 glBindVertexArrayOES(service_id); 9742 glBindVertexArrayOES(service_id);
9752 } 9743 }
9753 } 9744 }
9754 } 9745 }
9755 9746
9756 // Used when OES_vertex_array_object isn't natively supported 9747 // Used when OES_vertex_array_object isn't natively supported
9757 void GLES2DecoderImpl::EmulateVertexArrayState() { 9748 void GLES2DecoderImpl::EmulateVertexArrayState() {
9758 // Setup the Vertex attribute state 9749 // Setup the Vertex attribute state
9759 for (uint32 vv = 0; vv < group_->max_vertex_attribs(); ++vv) { 9750 for (uint32 vv = 0; vv < group_->max_vertex_attribs(); ++vv) {
9760 RestoreStateForAttrib(vv); 9751 RestoreStateForAttrib(vv);
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
10796 } 10787 }
10797 } 10788 }
10798 10789
10799 // Include the auto-generated part of this file. We split this because it means 10790 // Include the auto-generated part of this file. We split this because it means
10800 // we can easily edit the non-auto generated parts right here in this file 10791 // we can easily edit the non-auto generated parts right here in this file
10801 // instead of having to edit some template or the code generator. 10792 // instead of having to edit some template or the code generator.
10802 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10793 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10803 10794
10804 } // namespace gles2 10795 } // namespace gles2
10805 } // namespace gpu 10796 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/gpu_control.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698