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