| 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 2514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2571 supports_post_sub_buffer_(false), | 2570 supports_post_sub_buffer_(false), |
| 2572 supports_commit_overlay_planes_(false), | 2571 supports_commit_overlay_planes_(false), |
| 2573 supports_async_swap_(false), | 2572 supports_async_swap_(false), |
| 2574 context_type_(CONTEXT_TYPE_OPENGLES2), | 2573 context_type_(CONTEXT_TYPE_OPENGLES2), |
| 2575 derivatives_explicitly_enabled_(false), | 2574 derivatives_explicitly_enabled_(false), |
| 2576 frag_depth_explicitly_enabled_(false), | 2575 frag_depth_explicitly_enabled_(false), |
| 2577 draw_buffers_explicitly_enabled_(false), | 2576 draw_buffers_explicitly_enabled_(false), |
| 2578 shader_texture_lod_explicitly_enabled_(false), | 2577 shader_texture_lod_explicitly_enabled_(false), |
| 2579 compile_shader_always_succeeds_(false), | 2578 compile_shader_always_succeeds_(false), |
| 2580 lose_context_when_out_of_memory_(false), | 2579 lose_context_when_out_of_memory_(false), |
| 2581 service_logging_(base::CommandLine::InitializedForCurrentProcess() | 2580 service_logging_( |
| 2582 ? base::CommandLine::ForCurrentProcess()->HasSwitch( | 2581 group_->gpu_preferences().enable_gpu_service_logging_gpu), |
| 2583 switches::kEnableGPUServiceLoggingGPU) | |
| 2584 : false), | |
| 2585 viewport_max_width_(0), | 2582 viewport_max_width_(0), |
| 2586 viewport_max_height_(0), | 2583 viewport_max_height_(0), |
| 2587 texture_state_(group_->feature_info()->workarounds()), | 2584 texture_state_(group_->feature_info()->workarounds()), |
| 2588 gpu_decoder_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( | 2585 gpu_decoder_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( |
| 2589 TRACE_DISABLED_BY_DEFAULT("gpu_decoder"))), | 2586 TRACE_DISABLED_BY_DEFAULT("gpu_decoder"))), |
| 2590 gpu_trace_level_(2), | 2587 gpu_trace_level_(2), |
| 2591 gpu_trace_commands_(false), | 2588 gpu_trace_commands_(false), |
| 2592 gpu_debug_commands_(false), | 2589 gpu_debug_commands_(false), |
| 2593 validation_texture_(0), | 2590 validation_texture_(0), |
| 2594 validation_fbo_multisample_(0), | 2591 validation_fbo_multisample_(0), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2614 | 2611 |
| 2615 ContextCreationAttribHelper attrib_parser; | 2612 ContextCreationAttribHelper attrib_parser; |
| 2616 if (!attrib_parser.Parse(attribs)) | 2613 if (!attrib_parser.Parse(attribs)) |
| 2617 return false; | 2614 return false; |
| 2618 | 2615 |
| 2619 surfaceless_ = surface->IsSurfaceless() && !offscreen; | 2616 surfaceless_ = surface->IsSurfaceless() && !offscreen; |
| 2620 | 2617 |
| 2621 set_initialized(); | 2618 set_initialized(); |
| 2622 gpu_state_tracer_ = GPUStateTracer::Create(&state_); | 2619 gpu_state_tracer_ = GPUStateTracer::Create(&state_); |
| 2623 | 2620 |
| 2624 if (base::CommandLine::InitializedForCurrentProcess()) { | 2621 if (group_->gpu_preferences().enable_gpu_debugging) |
| 2625 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 2622 set_debug(true); |
| 2626 switches::kEnableGPUDebugging)) { | |
| 2627 set_debug(true); | |
| 2628 } | |
| 2629 | 2623 |
| 2630 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 2624 if (group_->gpu_preferences().enable_gpu_command_logging) |
| 2631 switches::kEnableGPUCommandLogging)) { | 2625 set_log_commands(true); |
| 2632 set_log_commands(true); | |
| 2633 } | |
| 2634 | 2626 |
| 2635 compile_shader_always_succeeds_ = | 2627 compile_shader_always_succeeds_ = |
| 2636 base::CommandLine::ForCurrentProcess()->HasSwitch( | 2628 group_->gpu_preferences().compile_shader_always_succeeds; |
| 2637 switches::kCompileShaderAlwaysSucceeds); | |
| 2638 } | |
| 2639 | 2629 |
| 2640 // Take ownership of the context and surface. The surface can be replaced with | 2630 // Take ownership of the context and surface. The surface can be replaced with |
| 2641 // SetSurface. | 2631 // SetSurface. |
| 2642 context_ = context; | 2632 context_ = context; |
| 2643 surface_ = surface; | 2633 surface_ = surface; |
| 2644 | 2634 |
| 2645 // Create GPU Tracer for timing values. | 2635 // Create GPU Tracer for timing values. |
| 2646 gpu_tracer_.reset(new GPUTracer(this)); | 2636 gpu_tracer_.reset(new GPUTracer(this)); |
| 2647 | 2637 |
| 2648 if (feature_info_->workarounds().disable_timestamp_queries) { | 2638 if (feature_info_->workarounds().disable_timestamp_queries) { |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3299 driver_bug_workarounds |= SH_INIT_VARYINGS_WITHOUT_STATIC_USE; | 3289 driver_bug_workarounds |= SH_INIT_VARYINGS_WITHOUT_STATIC_USE; |
| 3300 if (workarounds().unroll_for_loop_with_sampler_array_index) | 3290 if (workarounds().unroll_for_loop_with_sampler_array_index) |
| 3301 driver_bug_workarounds |= SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX; | 3291 driver_bug_workarounds |= SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX; |
| 3302 if (workarounds().scalarize_vec_and_mat_constructor_args) | 3292 if (workarounds().scalarize_vec_and_mat_constructor_args) |
| 3303 driver_bug_workarounds |= SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS; | 3293 driver_bug_workarounds |= SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS; |
| 3304 if (workarounds().regenerate_struct_names) | 3294 if (workarounds().regenerate_struct_names) |
| 3305 driver_bug_workarounds |= SH_REGENERATE_STRUCT_NAMES; | 3295 driver_bug_workarounds |= SH_REGENERATE_STRUCT_NAMES; |
| 3306 if (workarounds().remove_pow_with_constant_exponent) | 3296 if (workarounds().remove_pow_with_constant_exponent) |
| 3307 driver_bug_workarounds |= SH_REMOVE_POW_WITH_CONSTANT_EXPONENT; | 3297 driver_bug_workarounds |= SH_REMOVE_POW_WITH_CONSTANT_EXPONENT; |
| 3308 | 3298 |
| 3309 if (base::CommandLine::InitializedForCurrentProcess() && | 3299 resources.WEBGL_debug_shader_precision = |
| 3310 base::CommandLine::ForCurrentProcess()->HasSwitch( | 3300 group_->gpu_preferences().emulate_shader_precision; |
| 3311 switches::kEmulateShaderPrecision)) | |
| 3312 resources.WEBGL_debug_shader_precision = true; | |
| 3313 | 3301 |
| 3314 ShShaderOutput shader_output_language = | 3302 ShShaderOutput shader_output_language = |
| 3315 ShaderTranslator::GetShaderOutputLanguageForContext( | 3303 ShaderTranslator::GetShaderOutputLanguageForContext( |
| 3316 feature_info_->gl_version_info()); | 3304 feature_info_->gl_version_info()); |
| 3317 | 3305 |
| 3318 vertex_translator_ = shader_translator_cache()->GetTranslator( | 3306 vertex_translator_ = shader_translator_cache()->GetTranslator( |
| 3319 GL_VERTEX_SHADER, shader_spec, &resources, shader_output_language, | 3307 GL_VERTEX_SHADER, shader_spec, &resources, shader_output_language, |
| 3320 static_cast<ShCompileOptions>(driver_bug_workarounds)); | 3308 static_cast<ShCompileOptions>(driver_bug_workarounds)); |
| 3321 if (!vertex_translator_.get()) { | 3309 if (!vertex_translator_.get()) { |
| 3322 LOG(ERROR) << "Could not initialize vertex shader translator."; | 3310 LOG(ERROR) << "Could not initialize vertex shader translator."; |
| (...skipping 12640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15963 } | 15951 } |
| 15964 | 15952 |
| 15965 // Include the auto-generated part of this file. We split this because it means | 15953 // 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 | 15954 // 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. | 15955 // instead of having to edit some template or the code generator. |
| 15968 #include "base/macros.h" | 15956 #include "base/macros.h" |
| 15969 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15957 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 15970 | 15958 |
| 15971 } // namespace gles2 | 15959 } // namespace gles2 |
| 15972 } // namespace gpu | 15960 } // namespace gpu |
| OLD | NEW |