| 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/context_group.h" | 5 #include "gpu/command_buffer/service/context_group.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "gpu/command_buffer/common/id_allocator.h" | 11 #include "gpu/command_buffer/common/id_allocator.h" |
| 12 #include "gpu/command_buffer/service/buffer_manager.h" | 12 #include "gpu/command_buffer/service/buffer_manager.h" |
| 13 #include "gpu/command_buffer/service/framebuffer_manager.h" | 13 #include "gpu/command_buffer/service/framebuffer_manager.h" |
| 14 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 14 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 15 #include "gpu/command_buffer/service/gpu_switches.h" | 15 #include "gpu/command_buffer/service/gpu_switches.h" |
| 16 #include "gpu/command_buffer/service/mailbox_manager.h" | 16 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 17 #include "gpu/command_buffer/service/memory_tracking.h" |
| 17 #include "gpu/command_buffer/service/program_manager.h" | 18 #include "gpu/command_buffer/service/program_manager.h" |
| 18 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 19 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
| 19 #include "gpu/command_buffer/service/shader_manager.h" | 20 #include "gpu/command_buffer/service/shader_manager.h" |
| 20 #include "gpu/command_buffer/service/texture_manager.h" | 21 #include "gpu/command_buffer/service/texture_manager.h" |
| 21 #include "gpu/command_buffer/service/transfer_buffer_manager.h" | 22 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| 22 #include "ui/gl/gl_implementation.h" | 23 #include "ui/gl/gl_implementation.h" |
| 23 | 24 |
| 24 namespace gpu { | 25 namespace gpu { |
| 25 namespace gles2 { | 26 namespace gles2 { |
| 26 | 27 |
| 27 ContextGroup::ContextGroup( | 28 ContextGroup::ContextGroup( |
| 28 MailboxManager* mailbox_manager, | 29 MailboxManager* mailbox_manager, |
| 30 MemoryTracker* memory_tracker, |
| 29 bool bind_generates_resource) | 31 bool bind_generates_resource) |
| 30 : mailbox_manager_(mailbox_manager ? mailbox_manager : new MailboxManager), | 32 : mailbox_manager_(mailbox_manager ? mailbox_manager : new MailboxManager), |
| 33 memory_tracker_(memory_tracker), |
| 31 num_contexts_(0), | 34 num_contexts_(0), |
| 32 enforce_gl_minimums_(CommandLine::ForCurrentProcess()->HasSwitch( | 35 enforce_gl_minimums_(CommandLine::ForCurrentProcess()->HasSwitch( |
| 33 switches::kEnforceGLMinimums)), | 36 switches::kEnforceGLMinimums)), |
| 34 bind_generates_resource_(bind_generates_resource), | 37 bind_generates_resource_(bind_generates_resource), |
| 35 max_vertex_attribs_(0u), | 38 max_vertex_attribs_(0u), |
| 36 max_texture_units_(0u), | 39 max_texture_units_(0u), |
| 37 max_texture_image_units_(0u), | 40 max_texture_image_units_(0u), |
| 38 max_vertex_texture_image_units_(0u), | 41 max_vertex_texture_image_units_(0u), |
| 39 max_fragment_uniform_vectors_(0u), | 42 max_fragment_uniform_vectors_(0u), |
| 40 max_varying_vectors_(0u), | 43 max_varying_vectors_(0u), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 &max_renderbuffer_size)) { | 84 &max_renderbuffer_size)) { |
| 82 LOG(ERROR) << "ContextGroup::Initialize failed because maximum " | 85 LOG(ERROR) << "ContextGroup::Initialize failed because maximum " |
| 83 << "renderbuffer size too small."; | 86 << "renderbuffer size too small."; |
| 84 return false; | 87 return false; |
| 85 } | 88 } |
| 86 GLint max_samples = 0; | 89 GLint max_samples = 0; |
| 87 if (feature_info_->feature_flags().chromium_framebuffer_multisample) { | 90 if (feature_info_->feature_flags().chromium_framebuffer_multisample) { |
| 88 glGetIntegerv(GL_MAX_SAMPLES, &max_samples); | 91 glGetIntegerv(GL_MAX_SAMPLES, &max_samples); |
| 89 } | 92 } |
| 90 | 93 |
| 91 buffer_manager_.reset(new BufferManager()); | 94 buffer_manager_.reset(new BufferManager(memory_tracker_)); |
| 92 framebuffer_manager_.reset(new FramebufferManager()); | 95 framebuffer_manager_.reset(new FramebufferManager()); |
| 93 renderbuffer_manager_.reset(new RenderbufferManager( | 96 renderbuffer_manager_.reset(new RenderbufferManager(memory_tracker_, |
| 94 max_renderbuffer_size, max_samples)); | 97 max_renderbuffer_size, |
| 98 max_samples)); |
| 95 shader_manager_.reset(new ShaderManager()); | 99 shader_manager_.reset(new ShaderManager()); |
| 96 program_manager_.reset(new ProgramManager()); | 100 program_manager_.reset(new ProgramManager()); |
| 97 | 101 |
| 98 // Lookup GL things we need to know. | 102 // Lookup GL things we need to know. |
| 99 const GLint kGLES2RequiredMinimumVertexAttribs = 8u; | 103 const GLint kGLES2RequiredMinimumVertexAttribs = 8u; |
| 100 if (!QueryGLFeatureU( | 104 if (!QueryGLFeatureU( |
| 101 GL_MAX_VERTEX_ATTRIBS, kGLES2RequiredMinimumVertexAttribs, | 105 GL_MAX_VERTEX_ATTRIBS, kGLES2RequiredMinimumVertexAttribs, |
| 102 &max_vertex_attribs_)) { | 106 &max_vertex_attribs_)) { |
| 103 LOG(ERROR) << "ContextGroup::Initialize failed because too few " | 107 LOG(ERROR) << "ContextGroup::Initialize failed because too few " |
| 104 << "vertex attributes supported."; | 108 << "vertex attributes supported."; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 static_cast<GLint>(512), max_cube_map_texture_size); | 145 static_cast<GLint>(512), max_cube_map_texture_size); |
| 142 } | 146 } |
| 143 if (feature_info_->feature_flags().is_amd) { | 147 if (feature_info_->feature_flags().is_amd) { |
| 144 max_texture_size = std::min( | 148 max_texture_size = std::min( |
| 145 static_cast<GLint>(4096), max_texture_size); | 149 static_cast<GLint>(4096), max_texture_size); |
| 146 max_cube_map_texture_size = std::min( | 150 max_cube_map_texture_size = std::min( |
| 147 static_cast<GLint>(4096), max_cube_map_texture_size); | 151 static_cast<GLint>(4096), max_cube_map_texture_size); |
| 148 } | 152 } |
| 149 } | 153 } |
| 150 #endif | 154 #endif |
| 151 texture_manager_.reset(new TextureManager(feature_info_.get(), | 155 texture_manager_.reset(new TextureManager(memory_tracker_, |
| 156 feature_info_.get(), |
| 152 max_texture_size, | 157 max_texture_size, |
| 153 max_cube_map_texture_size)); | 158 max_cube_map_texture_size)); |
| 154 | 159 |
| 155 const GLint kMinTextureImageUnits = 8; | 160 const GLint kMinTextureImageUnits = 8; |
| 156 const GLint kMinVertexTextureImageUnits = 0; | 161 const GLint kMinVertexTextureImageUnits = 0; |
| 157 if (!QueryGLFeatureU( | 162 if (!QueryGLFeatureU( |
| 158 GL_MAX_TEXTURE_IMAGE_UNITS, kMinTextureImageUnits, | 163 GL_MAX_TEXTURE_IMAGE_UNITS, kMinTextureImageUnits, |
| 159 &max_texture_image_units_) || | 164 &max_texture_image_units_) || |
| 160 !QueryGLFeatureU( | 165 !QueryGLFeatureU( |
| 161 GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, kMinVertexTextureImageUnits, | 166 GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, kMinVertexTextureImageUnits, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 237 |
| 233 if (program_manager_ != NULL) { | 238 if (program_manager_ != NULL) { |
| 234 program_manager_->Destroy(have_context); | 239 program_manager_->Destroy(have_context); |
| 235 program_manager_.reset(); | 240 program_manager_.reset(); |
| 236 } | 241 } |
| 237 | 242 |
| 238 if (shader_manager_ != NULL) { | 243 if (shader_manager_ != NULL) { |
| 239 shader_manager_->Destroy(have_context); | 244 shader_manager_->Destroy(have_context); |
| 240 shader_manager_.reset(); | 245 shader_manager_.reset(); |
| 241 } | 246 } |
| 247 |
| 248 if (memory_tracker_.get()) { |
| 249 memory_tracker_.release(); |
| 250 } |
| 242 } | 251 } |
| 243 | 252 |
| 244 IdAllocatorInterface* ContextGroup::GetIdAllocator(unsigned namespace_id) { | 253 IdAllocatorInterface* ContextGroup::GetIdAllocator(unsigned namespace_id) { |
| 245 if (namespace_id >= arraysize(id_namespaces_)) | 254 if (namespace_id >= arraysize(id_namespaces_)) |
| 246 return NULL; | 255 return NULL; |
| 247 | 256 |
| 248 return id_namespaces_[namespace_id].get(); | 257 return id_namespaces_[namespace_id].get(); |
| 249 } | 258 } |
| 250 | 259 |
| 251 uint32 ContextGroup::GetMemRepresented() const { | 260 uint32 ContextGroup::GetMemRepresented() const { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 GetIntegerv(pname, &value); | 304 GetIntegerv(pname, &value); |
| 296 bool result = CheckGLFeatureU(min_required, &value); | 305 bool result = CheckGLFeatureU(min_required, &value); |
| 297 *v = value; | 306 *v = value; |
| 298 return result; | 307 return result; |
| 299 } | 308 } |
| 300 | 309 |
| 301 } // namespace gles2 | 310 } // namespace gles2 |
| 302 } // namespace gpu | 311 } // namespace gpu |
| 303 | 312 |
| 304 | 313 |
| OLD | NEW |