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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 1716813002: Use GpuPreferences to avoid directly accessing switches in gpu related code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 4 years, 10 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/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdio.h> 10 #include <stdio.h>
11 11
12 #include <algorithm> 12 #include <algorithm>
13 #include <cmath> 13 #include <cmath>
14 #include <list> 14 #include <list>
15 #include <map> 15 #include <map>
16 #include <queue> 16 #include <queue>
17 17
18 #include "base/callback.h" 18 #include "base/callback.h"
19 #include "base/callback_helpers.h" 19 #include "base/callback_helpers.h"
20 #include "base/command_line.h" 20 #include "base/command_line.h"
Fady Samuel 2016/02/25 16:26:33 No longer necessary?
Peng 2016/02/25 17:13:22 Done.
21 #include "base/logging.h" 21 #include "base/logging.h"
22 #include "base/memory/linked_ptr.h" 22 #include "base/memory/linked_ptr.h"
23 #include "base/memory/scoped_ptr.h" 23 #include "base/memory/scoped_ptr.h"
24 #include "base/metrics/histogram_macros.h" 24 #include "base/metrics/histogram_macros.h"
25 #include "base/numerics/safe_math.h" 25 #include "base/numerics/safe_math.h"
26 #include "base/strings/string_number_conversions.h" 26 #include "base/strings/string_number_conversions.h"
27 #include "base/trace_event/trace_event.h" 27 #include "base/trace_event/trace_event.h"
28 #include "base/trace_event/trace_event_synthetic_delay.h" 28 #include "base/trace_event/trace_event_synthetic_delay.h"
29 #include "build/build_config.h" 29 #include "build/build_config.h"
30 #include "gpu/command_buffer/common/debug_marker_manager.h" 30 #include "gpu/command_buffer/common/debug_marker_manager.h"
31 #include "gpu/command_buffer/common/gles2_cmd_format.h" 31 #include "gpu/command_buffer/common/gles2_cmd_format.h"
32 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 32 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
33 #include "gpu/command_buffer/common/mailbox.h" 33 #include "gpu/command_buffer/common/mailbox.h"
34 #include "gpu/command_buffer/service/buffer_manager.h" 34 #include "gpu/command_buffer/service/buffer_manager.h"
35 #include "gpu/command_buffer/service/context_group.h" 35 #include "gpu/command_buffer/service/context_group.h"
36 #include "gpu/command_buffer/service/context_state.h" 36 #include "gpu/command_buffer/service/context_state.h"
37 #include "gpu/command_buffer/service/error_state.h" 37 #include "gpu/command_buffer/service/error_state.h"
38 #include "gpu/command_buffer/service/feature_info.h" 38 #include "gpu/command_buffer/service/feature_info.h"
39 #include "gpu/command_buffer/service/framebuffer_manager.h" 39 #include "gpu/command_buffer/service/framebuffer_manager.h"
40 #include "gpu/command_buffer/service/gl_stream_texture_image.h" 40 #include "gpu/command_buffer/service/gl_stream_texture_image.h"
41 #include "gpu/command_buffer/service/gl_utils.h" 41 #include "gpu/command_buffer/service/gl_utils.h"
42 #include "gpu/command_buffer/service/gles2_cmd_clear_framebuffer.h" 42 #include "gpu/command_buffer/service/gles2_cmd_clear_framebuffer.h"
43 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" 43 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h"
44 #include "gpu/command_buffer/service/gles2_cmd_validation.h" 44 #include "gpu/command_buffer/service/gles2_cmd_validation.h"
45 #include "gpu/command_buffer/service/gpu_preferences.h"
45 #include "gpu/command_buffer/service/gpu_state_tracer.h" 46 #include "gpu/command_buffer/service/gpu_state_tracer.h"
46 #include "gpu/command_buffer/service/gpu_switches.h" 47 #include "gpu/command_buffer/service/gpu_switches.h"
Fady Samuel 2016/02/25 16:26:33 No longer necessary?
Peng 2016/02/25 17:13:22 Done.
47 #include "gpu/command_buffer/service/gpu_tracer.h" 48 #include "gpu/command_buffer/service/gpu_tracer.h"
48 #include "gpu/command_buffer/service/image_manager.h" 49 #include "gpu/command_buffer/service/image_manager.h"
49 #include "gpu/command_buffer/service/logger.h" 50 #include "gpu/command_buffer/service/logger.h"
50 #include "gpu/command_buffer/service/mailbox_manager.h" 51 #include "gpu/command_buffer/service/mailbox_manager.h"
51 #include "gpu/command_buffer/service/memory_tracking.h" 52 #include "gpu/command_buffer/service/memory_tracking.h"
52 #include "gpu/command_buffer/service/path_manager.h" 53 #include "gpu/command_buffer/service/path_manager.h"
53 #include "gpu/command_buffer/service/program_manager.h" 54 #include "gpu/command_buffer/service/program_manager.h"
54 #include "gpu/command_buffer/service/query_manager.h" 55 #include "gpu/command_buffer/service/query_manager.h"
55 #include "gpu/command_buffer/service/renderbuffer_manager.h" 56 #include "gpu/command_buffer/service/renderbuffer_manager.h"
56 #include "gpu/command_buffer/service/sampler_manager.h" 57 #include "gpu/command_buffer/service/sampler_manager.h"
(...skipping 2514 matching lines...) Expand 10 before | Expand all | Expand 10 after
2571 supports_post_sub_buffer_(false), 2572 supports_post_sub_buffer_(false),
2572 supports_commit_overlay_planes_(false), 2573 supports_commit_overlay_planes_(false),
2573 supports_async_swap_(false), 2574 supports_async_swap_(false),
2574 context_type_(CONTEXT_TYPE_OPENGLES2), 2575 context_type_(CONTEXT_TYPE_OPENGLES2),
2575 derivatives_explicitly_enabled_(false), 2576 derivatives_explicitly_enabled_(false),
2576 frag_depth_explicitly_enabled_(false), 2577 frag_depth_explicitly_enabled_(false),
2577 draw_buffers_explicitly_enabled_(false), 2578 draw_buffers_explicitly_enabled_(false),
2578 shader_texture_lod_explicitly_enabled_(false), 2579 shader_texture_lod_explicitly_enabled_(false),
2579 compile_shader_always_succeeds_(false), 2580 compile_shader_always_succeeds_(false),
2580 lose_context_when_out_of_memory_(false), 2581 lose_context_when_out_of_memory_(false),
2581 service_logging_(base::CommandLine::InitializedForCurrentProcess() 2582 service_logging_(
2582 ? base::CommandLine::ForCurrentProcess()->HasSwitch( 2583 group_->gpu_preferences().enable_gpu_service_logging_gpu),
2583 switches::kEnableGPUServiceLoggingGPU)
2584 : false),
2585 viewport_max_width_(0), 2584 viewport_max_width_(0),
2586 viewport_max_height_(0), 2585 viewport_max_height_(0),
2587 texture_state_(group_->feature_info()->workarounds()), 2586 texture_state_(group_->feature_info()->workarounds()),
2588 gpu_decoder_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( 2587 gpu_decoder_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(
2589 TRACE_DISABLED_BY_DEFAULT("gpu_decoder"))), 2588 TRACE_DISABLED_BY_DEFAULT("gpu_decoder"))),
2590 gpu_trace_level_(2), 2589 gpu_trace_level_(2),
2591 gpu_trace_commands_(false), 2590 gpu_trace_commands_(false),
2592 gpu_debug_commands_(false), 2591 gpu_debug_commands_(false),
2593 validation_texture_(0), 2592 validation_texture_(0),
2594 validation_fbo_multisample_(0), 2593 validation_fbo_multisample_(0),
(...skipping 19 matching lines...) Expand all
2614 2613
2615 ContextCreationAttribHelper attrib_parser; 2614 ContextCreationAttribHelper attrib_parser;
2616 if (!attrib_parser.Parse(attribs)) 2615 if (!attrib_parser.Parse(attribs))
2617 return false; 2616 return false;
2618 2617
2619 surfaceless_ = surface->IsSurfaceless() && !offscreen; 2618 surfaceless_ = surface->IsSurfaceless() && !offscreen;
2620 2619
2621 set_initialized(); 2620 set_initialized();
2622 gpu_state_tracer_ = GPUStateTracer::Create(&state_); 2621 gpu_state_tracer_ = GPUStateTracer::Create(&state_);
2623 2622
2624 if (base::CommandLine::InitializedForCurrentProcess()) { 2623 if (group_->gpu_preferences().enable_gpu_debugging)
2625 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 2624 set_debug(true);
2626 switches::kEnableGPUDebugging)) {
2627 set_debug(true);
2628 }
2629 2625
2630 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 2626 if (group_->gpu_preferences().enable_gpu_command_logging)
2631 switches::kEnableGPUCommandLogging)) { 2627 set_log_commands(true);
2632 set_log_commands(true);
2633 }
2634 2628
2635 compile_shader_always_succeeds_ = 2629 compile_shader_always_succeeds_ =
2636 base::CommandLine::ForCurrentProcess()->HasSwitch( 2630 group_->gpu_preferences().compile_shader_always_succeeds;
2637 switches::kCompileShaderAlwaysSucceeds);
2638 }
2639 2631
2640 // Take ownership of the context and surface. The surface can be replaced with 2632 // Take ownership of the context and surface. The surface can be replaced with
2641 // SetSurface. 2633 // SetSurface.
2642 context_ = context; 2634 context_ = context;
2643 surface_ = surface; 2635 surface_ = surface;
2644 2636
2645 // Create GPU Tracer for timing values. 2637 // Create GPU Tracer for timing values.
2646 gpu_tracer_.reset(new GPUTracer(this)); 2638 gpu_tracer_.reset(new GPUTracer(this));
2647 2639
2648 if (feature_info_->workarounds().disable_timestamp_queries) { 2640 if (feature_info_->workarounds().disable_timestamp_queries) {
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
3299 driver_bug_workarounds |= SH_INIT_VARYINGS_WITHOUT_STATIC_USE; 3291 driver_bug_workarounds |= SH_INIT_VARYINGS_WITHOUT_STATIC_USE;
3300 if (workarounds().unroll_for_loop_with_sampler_array_index) 3292 if (workarounds().unroll_for_loop_with_sampler_array_index)
3301 driver_bug_workarounds |= SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX; 3293 driver_bug_workarounds |= SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX;
3302 if (workarounds().scalarize_vec_and_mat_constructor_args) 3294 if (workarounds().scalarize_vec_and_mat_constructor_args)
3303 driver_bug_workarounds |= SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS; 3295 driver_bug_workarounds |= SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS;
3304 if (workarounds().regenerate_struct_names) 3296 if (workarounds().regenerate_struct_names)
3305 driver_bug_workarounds |= SH_REGENERATE_STRUCT_NAMES; 3297 driver_bug_workarounds |= SH_REGENERATE_STRUCT_NAMES;
3306 if (workarounds().remove_pow_with_constant_exponent) 3298 if (workarounds().remove_pow_with_constant_exponent)
3307 driver_bug_workarounds |= SH_REMOVE_POW_WITH_CONSTANT_EXPONENT; 3299 driver_bug_workarounds |= SH_REMOVE_POW_WITH_CONSTANT_EXPONENT;
3308 3300
3309 if (base::CommandLine::InitializedForCurrentProcess() && 3301 resources.WEBGL_debug_shader_precision =
3310 base::CommandLine::ForCurrentProcess()->HasSwitch( 3302 group_->gpu_preferences().emulate_shader_precision;
3311 switches::kEmulateShaderPrecision))
3312 resources.WEBGL_debug_shader_precision = true;
3313 3303
3314 ShShaderOutput shader_output_language = 3304 ShShaderOutput shader_output_language =
3315 ShaderTranslator::GetShaderOutputLanguageForContext( 3305 ShaderTranslator::GetShaderOutputLanguageForContext(
3316 feature_info_->gl_version_info()); 3306 feature_info_->gl_version_info());
3317 3307
3318 vertex_translator_ = shader_translator_cache()->GetTranslator( 3308 vertex_translator_ = shader_translator_cache()->GetTranslator(
3319 GL_VERTEX_SHADER, shader_spec, &resources, shader_output_language, 3309 GL_VERTEX_SHADER, shader_spec, &resources, shader_output_language,
3320 static_cast<ShCompileOptions>(driver_bug_workarounds)); 3310 static_cast<ShCompileOptions>(driver_bug_workarounds));
3321 if (!vertex_translator_.get()) { 3311 if (!vertex_translator_.get()) {
3322 LOG(ERROR) << "Could not initialize vertex shader translator."; 3312 LOG(ERROR) << "Could not initialize vertex shader translator.";
(...skipping 12640 matching lines...) Expand 10 before | Expand all | Expand 10 after
15963 } 15953 }
15964 15954
15965 // Include the auto-generated part of this file. We split this because it means 15955 // Include the auto-generated part of this file. We split this because it means
15966 // we can easily edit the non-auto generated parts right here in this file 15956 // we can easily edit the non-auto generated parts right here in this file
15967 // instead of having to edit some template or the code generator. 15957 // instead of having to edit some template or the code generator.
15968 #include "base/macros.h" 15958 #include "base/macros.h"
15969 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 15959 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
15970 15960
15971 } // namespace gles2 15961 } // namespace gles2
15972 } // namespace gpu 15962 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698