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

Side by Side Diff: gpu/command_buffer/client/gles2_implementation.cc

Issue 116863003: gpu: Reuse transfer buffers more aggresively (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years 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
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 // A class to emulate GLES2 over command buffers. 5 // A class to emulate GLES2 over command buffers.
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 if (!transfer_buffer_->Initialize( 148 if (!transfer_buffer_->Initialize(
149 starting_transfer_buffer_size, 149 starting_transfer_buffer_size,
150 kStartingOffset, 150 kStartingOffset,
151 min_transfer_buffer_size, 151 min_transfer_buffer_size,
152 max_transfer_buffer_size, 152 max_transfer_buffer_size,
153 kAlignment, 153 kAlignment,
154 kSizeToFlush)) { 154 kSizeToFlush)) {
155 return false; 155 return false;
156 } 156 }
157 157
158 mapped_memory_.reset(new MappedMemoryManager(helper_, mapped_memory_limit)); 158 MappedMemoryManagerSettings mapped_memory_settings;
159 mapped_memory_settings.unused_memory_reclaim_limit =
160 mapped_memory_limit;
161 mapped_memory_settings.aggressive_reuse = false;
162 mapped_memory_.reset(new MappedMemoryManager(
163 helper_, mapped_memory_settings));
159 164
165 MappedMemoryManagerSettings transfer_buffer_memory_settings;
166 transfer_buffer_memory_settings.unused_memory_reclaim_limit =
167 mapped_memory_limit;
168 transfer_buffer_memory_settings.aggressive_reuse = true;
169 transfer_buffer_memory_.reset(new MappedMemoryManager(
170 helper_, transfer_buffer_memory_settings));
171
172 // Set the chunk size of transfer buffer chunks. Let the generic memory
173 // manager allocate chunks to be as small as possible, i.e. the default size
174 // multiple 1.
160 unsigned chunk_size = 2 * 1024 * 1024; 175 unsigned chunk_size = 2 * 1024 * 1024;
161 if (mapped_memory_limit != kNoLimit) { 176 if (mapped_memory_limit != kNoLimit) {
162 // Use smaller chunks if the client is very memory conscientious. 177 // Use smaller chunks if the client is very memory conscientious.
163 chunk_size = std::min(mapped_memory_limit / 4, chunk_size); 178 chunk_size = std::min(mapped_memory_limit / 4, chunk_size);
164 } 179 }
165 mapped_memory_->set_chunk_size_multiple(chunk_size); 180 transfer_buffer_memory_->set_chunk_size_multiple(chunk_size);
166 181
167 if (!QueryAndCacheStaticState()) 182 if (!QueryAndCacheStaticState())
168 return false; 183 return false;
169 184
170 util_.set_num_compressed_texture_formats( 185 util_.set_num_compressed_texture_formats(
171 static_state_.int_state.num_compressed_texture_formats); 186 static_state_.int_state.num_compressed_texture_formats);
172 util_.set_num_shader_binary_formats( 187 util_.set_num_shader_binary_formats(
173 static_state_.int_state.num_shader_binary_formats); 188 static_state_.int_state.num_shader_binary_formats);
174 189
175 texture_units_.reset( 190 texture_units_.reset(
176 new TextureUnit[ 191 new TextureUnit[
177 static_state_.int_state.max_combined_texture_image_units]); 192 static_state_.int_state.max_combined_texture_image_units]);
178 193
179 query_tracker_.reset(new QueryTracker(mapped_memory_.get())); 194 query_tracker_.reset(new QueryTracker(mapped_memory_.get()));
180 buffer_tracker_.reset(new BufferTracker(mapped_memory_.get())); 195 buffer_tracker_.reset(new BufferTracker(transfer_buffer_memory_.get()));
181 gpu_memory_buffer_tracker_.reset(new GpuMemoryBufferTracker(gpu_control_)); 196 gpu_memory_buffer_tracker_.reset(new GpuMemoryBufferTracker(gpu_control_));
182 197
183 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) 198 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
184 GetIdHandler(id_namespaces::kBuffers)->MakeIds( 199 GetIdHandler(id_namespaces::kBuffers)->MakeIds(
185 this, kClientSideArrayId, arraysize(reserved_ids_), &reserved_ids_[0]); 200 this, kClientSideArrayId, arraysize(reserved_ids_), &reserved_ids_[0]);
186 #endif 201 #endif
187 202
188 vertex_array_object_manager_.reset(new VertexArrayObjectManager( 203 vertex_array_object_manager_.reset(new VertexArrayObjectManager(
189 static_state_.int_state.max_vertex_attribs, 204 static_state_.int_state.max_vertex_attribs,
190 reserved_ids_[0], 205 reserved_ids_[0],
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 int32 GLES2Implementation::GetResultShmId() { 312 int32 GLES2Implementation::GetResultShmId() {
298 return transfer_buffer_->GetShmId(); 313 return transfer_buffer_->GetShmId();
299 } 314 }
300 315
301 uint32 GLES2Implementation::GetResultShmOffset() { 316 uint32 GLES2Implementation::GetResultShmOffset() {
302 return transfer_buffer_->GetResultOffset(); 317 return transfer_buffer_->GetResultOffset();
303 } 318 }
304 319
305 void GLES2Implementation::FreeUnusedSharedMemory() { 320 void GLES2Implementation::FreeUnusedSharedMemory() {
306 mapped_memory_->FreeUnused(); 321 mapped_memory_->FreeUnused();
322 transfer_buffer_memory_->FreeUnused();
307 } 323 }
308 324
309 void GLES2Implementation::FreeEverything() { 325 void GLES2Implementation::FreeEverything() {
310 WaitForCmd(); 326 WaitForCmd();
311 query_tracker_->Shrink(); 327 query_tracker_->Shrink();
312 FreeUnusedSharedMemory(); 328 FreeUnusedSharedMemory();
313 transfer_buffer_->Free(); 329 transfer_buffer_->Free();
314 helper_->FreeRingBuffer(); 330 helper_->FreeRingBuffer();
315 } 331 }
316 332
(...skipping 3598 matching lines...) Expand 10 before | Expand all | Expand 10 after
3915 CheckGLError(); 3931 CheckGLError();
3916 } 3932 }
3917 3933
3918 // Include the auto-generated part of this file. We split this because it means 3934 // Include the auto-generated part of this file. We split this because it means
3919 // we can easily edit the non-auto generated parts right here in this file 3935 // we can easily edit the non-auto generated parts right here in this file
3920 // instead of having to edit some template or the code generator. 3936 // instead of having to edit some template or the code generator.
3921 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 3937 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
3922 3938
3923 } // namespace gles2 3939 } // namespace gles2
3924 } // namespace gpu 3940 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698