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/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" | |
21 #include "base/logging.h" | 20 #include "base/logging.h" |
22 #include "base/memory/linked_ptr.h" | 21 #include "base/memory/linked_ptr.h" |
23 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
24 #include "base/metrics/histogram_macros.h" | 23 #include "base/metrics/histogram_macros.h" |
25 #include "base/numerics/safe_math.h" | 24 #include "base/numerics/safe_math.h" |
26 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
27 #include "base/trace_event/trace_event.h" | 26 #include "base/trace_event/trace_event.h" |
28 #include "base/trace_event/trace_event_synthetic_delay.h" | 27 #include "base/trace_event/trace_event_synthetic_delay.h" |
29 #include "build/build_config.h" | 28 #include "build/build_config.h" |
30 #include "gpu/command_buffer/common/debug_marker_manager.h" | 29 #include "gpu/command_buffer/common/debug_marker_manager.h" |
31 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 30 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
32 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 31 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
33 #include "gpu/command_buffer/common/mailbox.h" | 32 #include "gpu/command_buffer/common/mailbox.h" |
34 #include "gpu/command_buffer/service/buffer_manager.h" | 33 #include "gpu/command_buffer/service/buffer_manager.h" |
35 #include "gpu/command_buffer/service/context_group.h" | 34 #include "gpu/command_buffer/service/context_group.h" |
36 #include "gpu/command_buffer/service/context_state.h" | 35 #include "gpu/command_buffer/service/context_state.h" |
37 #include "gpu/command_buffer/service/error_state.h" | 36 #include "gpu/command_buffer/service/error_state.h" |
38 #include "gpu/command_buffer/service/feature_info.h" | 37 #include "gpu/command_buffer/service/feature_info.h" |
39 #include "gpu/command_buffer/service/framebuffer_manager.h" | 38 #include "gpu/command_buffer/service/framebuffer_manager.h" |
40 #include "gpu/command_buffer/service/gl_stream_texture_image.h" | 39 #include "gpu/command_buffer/service/gl_stream_texture_image.h" |
41 #include "gpu/command_buffer/service/gl_utils.h" | 40 #include "gpu/command_buffer/service/gl_utils.h" |
42 #include "gpu/command_buffer/service/gles2_cmd_clear_framebuffer.h" | 41 #include "gpu/command_buffer/service/gles2_cmd_clear_framebuffer.h" |
43 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | 42 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
44 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 43 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
| 44 #include "gpu/command_buffer/service/gpu_preferences.h" |
45 #include "gpu/command_buffer/service/gpu_state_tracer.h" | 45 #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_tracer.h" | 46 #include "gpu/command_buffer/service/gpu_tracer.h" |
48 #include "gpu/command_buffer/service/image_manager.h" | 47 #include "gpu/command_buffer/service/image_manager.h" |
49 #include "gpu/command_buffer/service/logger.h" | 48 #include "gpu/command_buffer/service/logger.h" |
50 #include "gpu/command_buffer/service/mailbox_manager.h" | 49 #include "gpu/command_buffer/service/mailbox_manager.h" |
51 #include "gpu/command_buffer/service/memory_tracking.h" | 50 #include "gpu/command_buffer/service/memory_tracking.h" |
52 #include "gpu/command_buffer/service/path_manager.h" | 51 #include "gpu/command_buffer/service/path_manager.h" |
53 #include "gpu/command_buffer/service/program_manager.h" | 52 #include "gpu/command_buffer/service/program_manager.h" |
54 #include "gpu/command_buffer/service/query_manager.h" | 53 #include "gpu/command_buffer/service/query_manager.h" |
55 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 54 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
56 #include "gpu/command_buffer/service/sampler_manager.h" | 55 #include "gpu/command_buffer/service/sampler_manager.h" |
(...skipping 2513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2570 supports_post_sub_buffer_(false), | 2569 supports_post_sub_buffer_(false), |
2571 supports_commit_overlay_planes_(false), | 2570 supports_commit_overlay_planes_(false), |
2572 supports_async_swap_(false), | 2571 supports_async_swap_(false), |
2573 context_type_(CONTEXT_TYPE_OPENGLES2), | 2572 context_type_(CONTEXT_TYPE_OPENGLES2), |
2574 derivatives_explicitly_enabled_(false), | 2573 derivatives_explicitly_enabled_(false), |
2575 frag_depth_explicitly_enabled_(false), | 2574 frag_depth_explicitly_enabled_(false), |
2576 draw_buffers_explicitly_enabled_(false), | 2575 draw_buffers_explicitly_enabled_(false), |
2577 shader_texture_lod_explicitly_enabled_(false), | 2576 shader_texture_lod_explicitly_enabled_(false), |
2578 compile_shader_always_succeeds_(false), | 2577 compile_shader_always_succeeds_(false), |
2579 lose_context_when_out_of_memory_(false), | 2578 lose_context_when_out_of_memory_(false), |
2580 service_logging_(base::CommandLine::InitializedForCurrentProcess() | 2579 service_logging_( |
2581 ? base::CommandLine::ForCurrentProcess()->HasSwitch( | 2580 group_->gpu_preferences().enable_gpu_service_logging_gpu), |
2582 switches::kEnableGPUServiceLoggingGPU) | |
2583 : false), | |
2584 viewport_max_width_(0), | 2581 viewport_max_width_(0), |
2585 viewport_max_height_(0), | 2582 viewport_max_height_(0), |
2586 texture_state_(group_->feature_info()->workarounds()), | 2583 texture_state_(group_->feature_info()->workarounds()), |
2587 gpu_decoder_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( | 2584 gpu_decoder_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( |
2588 TRACE_DISABLED_BY_DEFAULT("gpu_decoder"))), | 2585 TRACE_DISABLED_BY_DEFAULT("gpu_decoder"))), |
2589 gpu_trace_level_(2), | 2586 gpu_trace_level_(2), |
2590 gpu_trace_commands_(false), | 2587 gpu_trace_commands_(false), |
2591 gpu_debug_commands_(false), | 2588 gpu_debug_commands_(false), |
2592 validation_texture_(0), | 2589 validation_texture_(0), |
2593 validation_fbo_multisample_(0), | 2590 validation_fbo_multisample_(0), |
(...skipping 19 matching lines...) Expand all Loading... |
2613 | 2610 |
2614 ContextCreationAttribHelper attrib_parser; | 2611 ContextCreationAttribHelper attrib_parser; |
2615 if (!attrib_parser.Parse(attribs)) | 2612 if (!attrib_parser.Parse(attribs)) |
2616 return false; | 2613 return false; |
2617 | 2614 |
2618 surfaceless_ = surface->IsSurfaceless() && !offscreen; | 2615 surfaceless_ = surface->IsSurfaceless() && !offscreen; |
2619 | 2616 |
2620 set_initialized(); | 2617 set_initialized(); |
2621 gpu_state_tracer_ = GPUStateTracer::Create(&state_); | 2618 gpu_state_tracer_ = GPUStateTracer::Create(&state_); |
2622 | 2619 |
2623 if (base::CommandLine::InitializedForCurrentProcess()) { | 2620 if (group_->gpu_preferences().enable_gpu_debugging) |
2624 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 2621 set_debug(true); |
2625 switches::kEnableGPUDebugging)) { | |
2626 set_debug(true); | |
2627 } | |
2628 | 2622 |
2629 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 2623 if (group_->gpu_preferences().enable_gpu_command_logging) |
2630 switches::kEnableGPUCommandLogging)) { | 2624 set_log_commands(true); |
2631 set_log_commands(true); | |
2632 } | |
2633 | 2625 |
2634 compile_shader_always_succeeds_ = | 2626 compile_shader_always_succeeds_ = |
2635 base::CommandLine::ForCurrentProcess()->HasSwitch( | 2627 group_->gpu_preferences().compile_shader_always_succeeds; |
2636 switches::kCompileShaderAlwaysSucceeds); | |
2637 } | |
2638 | 2628 |
2639 // Take ownership of the context and surface. The surface can be replaced with | 2629 // Take ownership of the context and surface. The surface can be replaced with |
2640 // SetSurface. | 2630 // SetSurface. |
2641 context_ = context; | 2631 context_ = context; |
2642 surface_ = surface; | 2632 surface_ = surface; |
2643 | 2633 |
2644 // Create GPU Tracer for timing values. | 2634 // Create GPU Tracer for timing values. |
2645 gpu_tracer_.reset(new GPUTracer(this)); | 2635 gpu_tracer_.reset(new GPUTracer(this)); |
2646 | 2636 |
2647 if (feature_info_->workarounds().disable_timestamp_queries) { | 2637 if (feature_info_->workarounds().disable_timestamp_queries) { |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3298 driver_bug_workarounds |= SH_INIT_VARYINGS_WITHOUT_STATIC_USE; | 3288 driver_bug_workarounds |= SH_INIT_VARYINGS_WITHOUT_STATIC_USE; |
3299 if (workarounds().unroll_for_loop_with_sampler_array_index) | 3289 if (workarounds().unroll_for_loop_with_sampler_array_index) |
3300 driver_bug_workarounds |= SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX; | 3290 driver_bug_workarounds |= SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX; |
3301 if (workarounds().scalarize_vec_and_mat_constructor_args) | 3291 if (workarounds().scalarize_vec_and_mat_constructor_args) |
3302 driver_bug_workarounds |= SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS; | 3292 driver_bug_workarounds |= SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS; |
3303 if (workarounds().regenerate_struct_names) | 3293 if (workarounds().regenerate_struct_names) |
3304 driver_bug_workarounds |= SH_REGENERATE_STRUCT_NAMES; | 3294 driver_bug_workarounds |= SH_REGENERATE_STRUCT_NAMES; |
3305 if (workarounds().remove_pow_with_constant_exponent) | 3295 if (workarounds().remove_pow_with_constant_exponent) |
3306 driver_bug_workarounds |= SH_REMOVE_POW_WITH_CONSTANT_EXPONENT; | 3296 driver_bug_workarounds |= SH_REMOVE_POW_WITH_CONSTANT_EXPONENT; |
3307 | 3297 |
3308 if (base::CommandLine::InitializedForCurrentProcess() && | 3298 resources.WEBGL_debug_shader_precision = |
3309 base::CommandLine::ForCurrentProcess()->HasSwitch( | 3299 group_->gpu_preferences().emulate_shader_precision; |
3310 switches::kEmulateShaderPrecision)) | |
3311 resources.WEBGL_debug_shader_precision = true; | |
3312 | 3300 |
3313 ShShaderOutput shader_output_language = | 3301 ShShaderOutput shader_output_language = |
3314 ShaderTranslator::GetShaderOutputLanguageForContext( | 3302 ShaderTranslator::GetShaderOutputLanguageForContext( |
3315 feature_info_->gl_version_info()); | 3303 feature_info_->gl_version_info()); |
3316 | 3304 |
3317 vertex_translator_ = shader_translator_cache()->GetTranslator( | 3305 vertex_translator_ = shader_translator_cache()->GetTranslator( |
3318 GL_VERTEX_SHADER, shader_spec, &resources, shader_output_language, | 3306 GL_VERTEX_SHADER, shader_spec, &resources, shader_output_language, |
3319 static_cast<ShCompileOptions>(driver_bug_workarounds)); | 3307 static_cast<ShCompileOptions>(driver_bug_workarounds)); |
3320 if (!vertex_translator_.get()) { | 3308 if (!vertex_translator_.get()) { |
3321 LOG(ERROR) << "Could not initialize vertex shader translator."; | 3309 LOG(ERROR) << "Could not initialize vertex shader translator."; |
(...skipping 12624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15946 } | 15934 } |
15947 | 15935 |
15948 // Include the auto-generated part of this file. We split this because it means | 15936 // Include the auto-generated part of this file. We split this because it means |
15949 // we can easily edit the non-auto generated parts right here in this file | 15937 // we can easily edit the non-auto generated parts right here in this file |
15950 // instead of having to edit some template or the code generator. | 15938 // instead of having to edit some template or the code generator. |
15951 #include "base/macros.h" | 15939 #include "base/macros.h" |
15952 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15940 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
15953 | 15941 |
15954 } // namespace gles2 | 15942 } // namespace gles2 |
15955 } // namespace gpu | 15943 } // namespace gpu |
OLD | NEW |