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

Side by Side Diff: gpu/command_buffer/tests/gl_manager.cc

Issue 1871613002: Compute GpuDriverBugWorkarounds only one time in the GPU process (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 8 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
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/tests/gl_manager.h" 5 #include "gpu/command_buffer/tests/gl_manager.h"
6 6
7 #include <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #include <GLES2/gl2ext.h> 8 #include <GLES2/gl2ext.h>
9 #include <GLES2/gl2extchromium.h> 9 #include <GLES2/gl2extchromium.h>
10 #include <stddef.h> 10 #include <stddef.h>
11 #include <stdint.h> 11 #include <stdint.h>
12 12
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/at_exit.h" 15 #include "base/at_exit.h"
16 #include "base/bind.h" 16 #include "base/bind.h"
17 #include "base/command_line.h"
17 #include "base/memory/ref_counted_memory.h" 18 #include "base/memory/ref_counted_memory.h"
18 #include "build/build_config.h" 19 #include "build/build_config.h"
19 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 20 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
20 #include "gpu/command_buffer/client/gles2_implementation.h" 21 #include "gpu/command_buffer/client/gles2_implementation.h"
21 #include "gpu/command_buffer/client/gles2_lib.h" 22 #include "gpu/command_buffer/client/gles2_lib.h"
22 #include "gpu/command_buffer/client/transfer_buffer.h" 23 #include "gpu/command_buffer/client/transfer_buffer.h"
23 #include "gpu/command_buffer/common/constants.h" 24 #include "gpu/command_buffer/common/constants.h"
24 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 25 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
25 #include "gpu/command_buffer/common/sync_token.h" 26 #include "gpu/command_buffer/common/sync_token.h"
26 #include "gpu/command_buffer/common/value_state.h" 27 #include "gpu/command_buffer/common/value_state.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 new IOSurfaceGpuMemoryBuffer(size, format)); 224 new IOSurfaceGpuMemoryBuffer(size, format));
224 } 225 }
225 #endif // defined(OS_MACOSX) 226 #endif // defined(OS_MACOSX)
226 std::vector<uint8_t> data(gfx::BufferSizeForBufferFormat(size, format), 0); 227 std::vector<uint8_t> data(gfx::BufferSizeForBufferFormat(size, format), 0);
227 scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data)); 228 scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data));
228 return make_scoped_ptr<gfx::GpuMemoryBuffer>( 229 return make_scoped_ptr<gfx::GpuMemoryBuffer>(
229 new GpuMemoryBufferImpl(bytes.get(), size, format)); 230 new GpuMemoryBufferImpl(bytes.get(), size, format));
230 } 231 }
231 232
232 void GLManager::Initialize(const GLManager::Options& options) { 233 void GLManager::Initialize(const GLManager::Options& options) {
233 InitializeWithCommandLine(options, nullptr); 234 InitializeWithCommandLine(options, *base::CommandLine::ForCurrentProcess());
234 } 235 }
235 236
236 void GLManager::InitializeWithCommandLine(const GLManager::Options& options, 237 void GLManager::InitializeWithCommandLine(
237 base::CommandLine* command_line) { 238 const GLManager::Options& options,
239 const base::CommandLine& command_line) {
238 const int32_t kCommandBufferSize = 1024 * 1024; 240 const int32_t kCommandBufferSize = 1024 * 1024;
239 const size_t kStartTransferBufferSize = 4 * 1024 * 1024; 241 const size_t kStartTransferBufferSize = 4 * 1024 * 1024;
240 const size_t kMinTransferBufferSize = 1 * 256 * 1024; 242 const size_t kMinTransferBufferSize = 1 * 256 * 1024;
241 const size_t kMaxTransferBufferSize = 16 * 1024 * 1024; 243 const size_t kMaxTransferBufferSize = 16 * 1024 * 1024;
242 244
243 context_lost_allowed_ = options.context_lost_allowed; 245 context_lost_allowed_ = options.context_lost_allowed;
244 246
245 gles2::MailboxManager* mailbox_manager = NULL; 247 gles2::MailboxManager* mailbox_manager = NULL;
246 if (options.share_mailbox_manager) { 248 if (options.share_mailbox_manager) {
247 mailbox_manager = options.share_mailbox_manager->mailbox_manager(); 249 mailbox_manager = options.share_mailbox_manager->mailbox_manager();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 attrib_helper.red_size = 8; 282 attrib_helper.red_size = 8;
281 attrib_helper.green_size = 8; 283 attrib_helper.green_size = 8;
282 attrib_helper.blue_size = 8; 284 attrib_helper.blue_size = 8;
283 attrib_helper.alpha_size = 8; 285 attrib_helper.alpha_size = 8;
284 attrib_helper.depth_size = 16; 286 attrib_helper.depth_size = 16;
285 attrib_helper.stencil_size = 8; 287 attrib_helper.stencil_size = 8;
286 attrib_helper.context_type = options.context_type; 288 attrib_helper.context_type = options.context_type;
287 289
288 attrib_helper.Serialize(&attribs); 290 attrib_helper.Serialize(&attribs);
289 291
290 DCHECK(!command_line || !context_group);
291 if (!context_group) { 292 if (!context_group) {
292 scoped_refptr<gles2::FeatureInfo> feature_info; 293 GpuDriverBugWorkarounds gpu_driver_bug_workaround(&command_line);
293 if (command_line) 294 scoped_refptr<gles2::FeatureInfo> feature_info =
294 feature_info = new gles2::FeatureInfo(*command_line); 295 new gles2::FeatureInfo(command_line, gpu_driver_bug_workaround);
295 context_group = new gles2::ContextGroup( 296 context_group = new gles2::ContextGroup(
296 gpu_preferences_, mailbox_manager_.get(), NULL, 297 gpu_preferences_, mailbox_manager_.get(), NULL,
297 new gpu::gles2::ShaderTranslatorCache(gpu_preferences_), 298 new gpu::gles2::ShaderTranslatorCache(gpu_preferences_),
298 new gpu::gles2::FramebufferCompletenessCache, feature_info, NULL, NULL, 299 new gpu::gles2::FramebufferCompletenessCache, feature_info, NULL, NULL,
299 options.bind_generates_resource); 300 options.bind_generates_resource);
300 } 301 }
301 302
302 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group)); 303 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group));
303 if (options.force_shader_name_hashing) { 304 if (options.force_shader_name_hashing) {
304 decoder_->SetForceShaderNameHashingForTest(true); 305 decoder_->SetForceShaderNameHashingForTest(true);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 sync_point_order_data_ = nullptr; 457 sync_point_order_data_ = nullptr;
457 } 458 }
458 if (decoder_.get()) { 459 if (decoder_.get()) {
459 bool have_context = decoder_->GetGLContext() && 460 bool have_context = decoder_->GetGLContext() &&
460 decoder_->GetGLContext()->MakeCurrent(surface_.get()); 461 decoder_->GetGLContext()->MakeCurrent(surface_.get());
461 decoder_->Destroy(have_context); 462 decoder_->Destroy(have_context);
462 decoder_.reset(); 463 decoder_.reset();
463 } 464 }
464 } 465 }
465 466
466 const gpu::gles2::FeatureInfo::Workarounds& GLManager::workarounds() const { 467 const GpuDriverBugWorkarounds& GLManager::workarounds() const {
467 return decoder_->GetContextGroup()->feature_info()->workarounds(); 468 return decoder_->GetContextGroup()->feature_info()->workarounds();
468 } 469 }
469 470
470 void GLManager::PumpCommands() { 471 void GLManager::PumpCommands() {
471 if (!decoder_->MakeCurrent()) { 472 if (!decoder_->MakeCurrent()) {
472 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason()); 473 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason());
473 command_buffer_->SetParseError(::gpu::error::kLostContext); 474 command_buffer_->SetParseError(::gpu::error::kLostContext);
474 return; 475 return;
475 } 476 }
476 uint32_t order_num = 0; 477 uint32_t order_num = 0;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 639
639 // Something went wrong, just run the callback now. 640 // Something went wrong, just run the callback now.
640 callback.Run(); 641 callback.Run();
641 } 642 }
642 643
643 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) { 644 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) {
644 return false; 645 return false;
645 } 646 }
646 647
647 } // namespace gpu 648 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/gl_manager.h ('k') | gpu/command_buffer/tests/gl_request_extension_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698