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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
15 #include "gpu/command_buffer/service/buffer_manager.h" | 15 #include "gpu/command_buffer/service/buffer_manager.h" |
16 #include "gpu/command_buffer/service/framebuffer_manager.h" | 16 #include "gpu/command_buffer/service/framebuffer_manager.h" |
17 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h" | 17 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h" |
18 #include "gpu/command_buffer/service/gpu_preferences.h" | 18 #include "gpu/command_buffer/service/gpu_preferences.h" |
19 #include "gpu/command_buffer/service/mailbox_manager_impl.h" | 19 #include "gpu/command_buffer/service/mailbox_manager_impl.h" |
20 #include "gpu/command_buffer/service/path_manager.h" | 20 #include "gpu/command_buffer/service/path_manager.h" |
21 #include "gpu/command_buffer/service/program_manager.h" | 21 #include "gpu/command_buffer/service/program_manager.h" |
22 #include "gpu/command_buffer/service/progress_reporter.h" | 22 #include "gpu/command_buffer/service/progress_reporter.h" |
23 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 23 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
24 #include "gpu/command_buffer/service/sampler_manager.h" | 24 #include "gpu/command_buffer/service/sampler_manager.h" |
| 25 #include "gpu/command_buffer/service/service_discardable_manager.h" |
25 #include "gpu/command_buffer/service/shader_manager.h" | 26 #include "gpu/command_buffer/service/shader_manager.h" |
26 #include "gpu/command_buffer/service/texture_manager.h" | 27 #include "gpu/command_buffer/service/texture_manager.h" |
27 #include "gpu/command_buffer/service/transfer_buffer_manager.h" | 28 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
28 #include "ui/gl/gl_bindings.h" | 29 #include "ui/gl/gl_bindings.h" |
29 #include "ui/gl/gl_version_info.h" | 30 #include "ui/gl/gl_version_info.h" |
30 | 31 |
31 namespace gpu { | 32 namespace gpu { |
32 namespace gles2 { | 33 namespace gles2 { |
33 | 34 |
34 namespace { | 35 namespace { |
(...skipping 28 matching lines...) Expand all Loading... |
63 const GpuPreferences& gpu_preferences, | 64 const GpuPreferences& gpu_preferences, |
64 const scoped_refptr<MailboxManager>& mailbox_manager, | 65 const scoped_refptr<MailboxManager>& mailbox_manager, |
65 const scoped_refptr<MemoryTracker>& memory_tracker, | 66 const scoped_refptr<MemoryTracker>& memory_tracker, |
66 const scoped_refptr<ShaderTranslatorCache>& shader_translator_cache, | 67 const scoped_refptr<ShaderTranslatorCache>& shader_translator_cache, |
67 const scoped_refptr<FramebufferCompletenessCache>& | 68 const scoped_refptr<FramebufferCompletenessCache>& |
68 framebuffer_completeness_cache, | 69 framebuffer_completeness_cache, |
69 const scoped_refptr<FeatureInfo>& feature_info, | 70 const scoped_refptr<FeatureInfo>& feature_info, |
70 bool bind_generates_resource, | 71 bool bind_generates_resource, |
71 gpu::ImageFactory* image_factory, | 72 gpu::ImageFactory* image_factory, |
72 ProgressReporter* progress_reporter, | 73 ProgressReporter* progress_reporter, |
73 const GpuFeatureInfo& gpu_feature_info) | 74 const GpuFeatureInfo& gpu_feature_info, |
| 75 ServiceDiscardableManager* discardable_manager) |
74 : gpu_preferences_(gpu_preferences), | 76 : gpu_preferences_(gpu_preferences), |
75 mailbox_manager_(mailbox_manager), | 77 mailbox_manager_(mailbox_manager), |
76 memory_tracker_(memory_tracker), | 78 memory_tracker_(memory_tracker), |
77 shader_translator_cache_(shader_translator_cache), | 79 shader_translator_cache_(shader_translator_cache), |
78 #if defined(OS_MACOSX) | 80 #if defined(OS_MACOSX) |
79 // Framebuffer completeness is not cacheable on OS X because of dynamic | 81 // Framebuffer completeness is not cacheable on OS X because of dynamic |
80 // graphics switching. | 82 // graphics switching. |
81 // http://crbug.com/180876 | 83 // http://crbug.com/180876 |
82 // TODO(tobiasjs): determine whether GPU switching is possible | 84 // TODO(tobiasjs): determine whether GPU switching is possible |
83 // programmatically, rather than just hardcoding this behaviour | 85 // programmatically, rather than just hardcoding this behaviour |
(...skipping 19 matching lines...) Expand all Loading... |
103 min_program_texel_offset_(0), | 105 min_program_texel_offset_(0), |
104 max_program_texel_offset_(0), | 106 max_program_texel_offset_(0), |
105 max_transform_feedback_separate_attribs_(0u), | 107 max_transform_feedback_separate_attribs_(0u), |
106 max_uniform_buffer_bindings_(0u), | 108 max_uniform_buffer_bindings_(0u), |
107 uniform_buffer_offset_alignment_(1u), | 109 uniform_buffer_offset_alignment_(1u), |
108 program_cache_(NULL), | 110 program_cache_(NULL), |
109 feature_info_(feature_info), | 111 feature_info_(feature_info), |
110 image_factory_(image_factory), | 112 image_factory_(image_factory), |
111 passthrough_resources_(new PassthroughResources), | 113 passthrough_resources_(new PassthroughResources), |
112 progress_reporter_(progress_reporter), | 114 progress_reporter_(progress_reporter), |
113 gpu_feature_info_(gpu_feature_info) { | 115 gpu_feature_info_(gpu_feature_info), |
| 116 discardable_manager_(discardable_manager) { |
| 117 DCHECK(discardable_manager); |
114 DCHECK(feature_info_); | 118 DCHECK(feature_info_); |
115 if (!mailbox_manager_.get()) | 119 if (!mailbox_manager_.get()) |
116 mailbox_manager_ = new MailboxManagerImpl; | 120 mailbox_manager_ = new MailboxManagerImpl; |
117 transfer_buffer_manager_ = | 121 transfer_buffer_manager_ = |
118 base::MakeUnique<TransferBufferManager>(memory_tracker_.get()); | 122 base::MakeUnique<TransferBufferManager>(memory_tracker_.get()); |
119 } | 123 } |
120 | 124 |
121 bool ContextGroup::Initialize(GLES2Decoder* decoder, | 125 bool ContextGroup::Initialize(GLES2Decoder* decoder, |
122 ContextType context_type, | 126 ContextType context_type, |
123 const DisallowedFeatures& disallowed_features) { | 127 const DisallowedFeatures& disallowed_features) { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 feature_info_->workarounds().max_texture_size); | 308 feature_info_->workarounds().max_texture_size); |
305 max_rectangle_texture_size = std::min( | 309 max_rectangle_texture_size = std::min( |
306 max_rectangle_texture_size, | 310 max_rectangle_texture_size, |
307 feature_info_->workarounds().max_texture_size); | 311 feature_info_->workarounds().max_texture_size); |
308 } | 312 } |
309 | 313 |
310 texture_manager_.reset(new TextureManager( | 314 texture_manager_.reset(new TextureManager( |
311 memory_tracker_.get(), feature_info_.get(), max_texture_size, | 315 memory_tracker_.get(), feature_info_.get(), max_texture_size, |
312 max_cube_map_texture_size, max_rectangle_texture_size, | 316 max_cube_map_texture_size, max_rectangle_texture_size, |
313 max_3d_texture_size, max_array_texture_layers, bind_generates_resource_, | 317 max_3d_texture_size, max_array_texture_layers, bind_generates_resource_, |
314 progress_reporter_)); | 318 progress_reporter_, discardable_manager_)); |
315 | 319 |
316 const GLint kMinTextureImageUnits = 8; | 320 const GLint kMinTextureImageUnits = 8; |
317 const GLint kMinVertexTextureImageUnits = 0; | 321 const GLint kMinVertexTextureImageUnits = 0; |
318 if (!QueryGLFeatureU(GL_MAX_TEXTURE_IMAGE_UNITS, kMinTextureImageUnits, | 322 if (!QueryGLFeatureU(GL_MAX_TEXTURE_IMAGE_UNITS, kMinTextureImageUnits, |
319 &max_texture_image_units_)) { | 323 &max_texture_image_units_)) { |
320 DLOG(ERROR) << "ContextGroup::Initialize failed because too few " | 324 DLOG(ERROR) << "ContextGroup::Initialize failed because too few " |
321 << "texture image units supported (" | 325 << "texture image units supported (" |
322 << max_texture_image_units_ | 326 << max_texture_image_units_ |
323 << ", should be " << kMinTextureImageUnits << ")."; | 327 << ", should be " << kMinTextureImageUnits << ")."; |
324 } | 328 } |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 GLuint client_id, GLuint* service_id) const { | 619 GLuint client_id, GLuint* service_id) const { |
616 Buffer* buffer = buffer_manager_->GetBuffer(client_id); | 620 Buffer* buffer = buffer_manager_->GetBuffer(client_id); |
617 if (!buffer) | 621 if (!buffer) |
618 return false; | 622 return false; |
619 *service_id = buffer->service_id(); | 623 *service_id = buffer->service_id(); |
620 return true; | 624 return true; |
621 } | 625 } |
622 | 626 |
623 } // namespace gles2 | 627 } // namespace gles2 |
624 } // namespace gpu | 628 } // namespace gpu |
OLD | NEW |