| 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 "content/common/gpu/gpu_command_buffer_stub.h" | 5 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/command_line.h" | |
| 12 #include "base/hash.h" | 11 #include "base/hash.h" |
| 13 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
| 14 #include "base/macros.h" | 13 #include "base/macros.h" |
| 15 #include "base/memory/shared_memory.h" | 14 #include "base/memory/shared_memory.h" |
| 16 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 17 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
| 18 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 19 #include "content/common/gpu/gpu_channel.h" | 18 #include "content/common/gpu/gpu_channel.h" |
| 20 #include "content/common/gpu/gpu_channel_manager.h" | 19 #include "content/common/gpu/gpu_channel_manager.h" |
| 21 #include "content/common/gpu/gpu_channel_manager_delegate.h" | 20 #include "content/common/gpu/gpu_channel_manager_delegate.h" |
| 22 #include "content/common/gpu/gpu_memory_manager.h" | 21 #include "content/common/gpu/gpu_memory_manager.h" |
| 23 #include "content/common/gpu/gpu_memory_tracking.h" | 22 #include "content/common/gpu/gpu_memory_tracking.h" |
| 24 #include "content/common/gpu/gpu_messages.h" | 23 #include "content/common/gpu/gpu_messages.h" |
| 25 #include "content/common/gpu/gpu_watchdog.h" | 24 #include "content/common/gpu/gpu_watchdog.h" |
| 26 #include "content/common/gpu/image_transport_surface.h" | 25 #include "content/common/gpu/image_transport_surface.h" |
| 27 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" | 26 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
| 28 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" | 27 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" |
| 29 #include "content/common/gpu/media_messages.h" | 28 #include "content/common/gpu/media_messages.h" |
| 30 #include "content/public/common/content_client.h" | 29 #include "content/public/common/content_client.h" |
| 31 #include "content/public/common/content_switches.h" | |
| 32 #include "gpu/command_buffer/common/constants.h" | 30 #include "gpu/command_buffer/common/constants.h" |
| 33 #include "gpu/command_buffer/common/mailbox.h" | 31 #include "gpu/command_buffer/common/mailbox.h" |
| 34 #include "gpu/command_buffer/common/sync_token.h" | 32 #include "gpu/command_buffer/common/sync_token.h" |
| 35 #include "gpu/command_buffer/service/gl_context_virtual.h" | 33 #include "gpu/command_buffer/service/gl_context_virtual.h" |
| 36 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" | 34 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" |
| 37 #include "gpu/command_buffer/service/image_factory.h" | 35 #include "gpu/command_buffer/service/image_factory.h" |
| 38 #include "gpu/command_buffer/service/image_manager.h" | 36 #include "gpu/command_buffer/service/image_manager.h" |
| 39 #include "gpu/command_buffer/service/logger.h" | 37 #include "gpu/command_buffer/service/logger.h" |
| 40 #include "gpu/command_buffer/service/mailbox_manager.h" | 38 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 41 #include "gpu/command_buffer/service/memory_tracking.h" | 39 #include "gpu/command_buffer/service/memory_tracking.h" |
| 42 #include "gpu/command_buffer/service/query_manager.h" | 40 #include "gpu/command_buffer/service/query_manager.h" |
| 43 #include "gpu/command_buffer/service/sync_point_manager.h" | 41 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 44 #include "gpu/command_buffer/service/transfer_buffer_manager.h" | 42 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| 45 #include "gpu/command_buffer/service/valuebuffer_manager.h" | 43 #include "gpu/command_buffer/service/valuebuffer_manager.h" |
| 46 #include "ui/gl/gl_bindings.h" | 44 #include "ui/gl/gl_bindings.h" |
| 47 #include "ui/gl/gl_switches.h" | |
| 48 | 45 |
| 49 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
| 50 #include "base/win/win_util.h" | 47 #include "base/win/win_util.h" |
| 51 #include "content/public/common/sandbox_init.h" | 48 #include "content/public/common/sandbox_init.h" |
| 52 #endif | 49 #endif |
| 53 | 50 |
| 54 #if defined(OS_ANDROID) | 51 #if defined(OS_ANDROID) |
| 55 #include "content/common/gpu/stream_texture_android.h" | 52 #include "content/common/gpu/stream_texture_android.h" |
| 56 #endif | 53 #endif |
| 57 | 54 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 207 |
| 211 gpu::gles2::ContextCreationAttribHelper attrib_parser; | 208 gpu::gles2::ContextCreationAttribHelper attrib_parser; |
| 212 attrib_parser.Parse(requested_attribs_); | 209 attrib_parser.Parse(requested_attribs_); |
| 213 | 210 |
| 214 if (share_group) { | 211 if (share_group) { |
| 215 context_group_ = share_group->context_group_; | 212 context_group_ = share_group->context_group_; |
| 216 DCHECK(context_group_->bind_generates_resource() == | 213 DCHECK(context_group_->bind_generates_resource() == |
| 217 attrib_parser.bind_generates_resource); | 214 attrib_parser.bind_generates_resource); |
| 218 } else { | 215 } else { |
| 219 context_group_ = new gpu::gles2::ContextGroup( | 216 context_group_ = new gpu::gles2::ContextGroup( |
| 220 mailbox_manager, new GpuCommandBufferMemoryTracker( | 217 channel_->gpu_channel_manager()->gpu_preferences(), mailbox_manager, |
| 221 channel, command_buffer_id_.GetUnsafeValue()), | 218 new GpuCommandBufferMemoryTracker(channel, |
| 219 command_buffer_id_.GetUnsafeValue()), |
| 222 channel_->gpu_channel_manager()->shader_translator_cache(), | 220 channel_->gpu_channel_manager()->shader_translator_cache(), |
| 223 channel_->gpu_channel_manager()->framebuffer_completeness_cache(), NULL, | 221 channel_->gpu_channel_manager()->framebuffer_completeness_cache(), NULL, |
| 224 subscription_ref_set, pending_valuebuffer_state, | 222 subscription_ref_set, pending_valuebuffer_state, |
| 225 attrib_parser.bind_generates_resource); | 223 attrib_parser.bind_generates_resource); |
| 226 } | 224 } |
| 227 | 225 |
| 228 // Virtualize PreferIntegratedGpu contexts by default on OS X to prevent | 226 // Virtualize PreferIntegratedGpu contexts by default on OS X to prevent |
| 229 // performance regressions when enabling FCM. | 227 // performance regressions when enabling FCM. |
| 230 // http://crbug.com/180463 | 228 // http://crbug.com/180463 |
| 231 #if defined(OS_MACOSX) | 229 #if defined(OS_MACOSX) |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 } | 613 } |
| 616 | 614 |
| 617 // Initialize the decoder with either the view or pbuffer GLContext. | 615 // Initialize the decoder with either the view or pbuffer GLContext. |
| 618 if (!decoder_->Initialize(surface_, context, offscreen_, initial_size_, | 616 if (!decoder_->Initialize(surface_, context, offscreen_, initial_size_, |
| 619 disallowed_features_, requested_attribs_)) { | 617 disallowed_features_, requested_attribs_)) { |
| 620 DLOG(ERROR) << "Failed to initialize decoder."; | 618 DLOG(ERROR) << "Failed to initialize decoder."; |
| 621 OnInitializeFailed(reply_message); | 619 OnInitializeFailed(reply_message); |
| 622 return; | 620 return; |
| 623 } | 621 } |
| 624 | 622 |
| 625 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 623 if (channel_->gpu_channel_manager()-> |
| 626 switches::kEnableGPUServiceLogging)) { | 624 gpu_preferences().enable_gpu_service_logging) { |
| 627 decoder_->set_log_commands(true); | 625 decoder_->set_log_commands(true); |
| 628 } | 626 } |
| 629 | 627 |
| 630 decoder_->GetLogger()->SetMsgCallback( | 628 decoder_->GetLogger()->SetMsgCallback( |
| 631 base::Bind(&GpuCommandBufferStub::SendConsoleMessage, | 629 base::Bind(&GpuCommandBufferStub::SendConsoleMessage, |
| 632 base::Unretained(this))); | 630 base::Unretained(this))); |
| 633 decoder_->SetShaderCacheCallback( | 631 decoder_->SetShaderCacheCallback( |
| 634 base::Bind(&GpuCommandBufferStub::SendCachedShader, | 632 base::Bind(&GpuCommandBufferStub::SendCachedShader, |
| 635 base::Unretained(this))); | 633 base::Unretained(this))); |
| 636 decoder_->SetFenceSyncReleaseCallback(base::Bind( | 634 decoder_->SetFenceSyncReleaseCallback(base::Bind( |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); | 1121 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); |
| 1124 bool was_lost = state.error == gpu::error::kLostContext; | 1122 bool was_lost = state.error == gpu::error::kLostContext; |
| 1125 | 1123 |
| 1126 if (was_lost) { | 1124 if (was_lost) { |
| 1127 bool was_lost_by_robustness = | 1125 bool was_lost_by_robustness = |
| 1128 decoder_ && decoder_->WasContextLostByRobustnessExtension(); | 1126 decoder_ && decoder_->WasContextLostByRobustnessExtension(); |
| 1129 | 1127 |
| 1130 // Work around issues with recovery by allowing a new GPU process to launch. | 1128 // Work around issues with recovery by allowing a new GPU process to launch. |
| 1131 if ((was_lost_by_robustness || | 1129 if ((was_lost_by_robustness || |
| 1132 context_group_->feature_info()->workarounds().exit_on_context_lost) && | 1130 context_group_->feature_info()->workarounds().exit_on_context_lost) && |
| 1133 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 1131 !channel_->gpu_channel_manager()->gpu_preferences().single_process && |
| 1134 switches::kSingleProcess) && | 1132 !channel_->gpu_channel_manager()->gpu_preferences().in_process_gpu) { |
| 1135 !base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 1136 switches::kInProcessGPU)) { | |
| 1137 LOG(ERROR) << "Exiting GPU process because some drivers cannot recover" | 1133 LOG(ERROR) << "Exiting GPU process because some drivers cannot recover" |
| 1138 << " from problems."; | 1134 << " from problems."; |
| 1139 // Signal the message loop to quit to shut down other threads | 1135 // Signal the message loop to quit to shut down other threads |
| 1140 // gracefully. | 1136 // gracefully. |
| 1141 base::MessageLoop::current()->QuitNow(); | 1137 base::MessageLoop::current()->QuitNow(); |
| 1142 } | 1138 } |
| 1143 | 1139 |
| 1144 // Lose all other contexts if the reset was triggered by the robustness | 1140 // Lose all other contexts if the reset was triggered by the robustness |
| 1145 // extension instead of being synthetic. | 1141 // extension instead of being synthetic. |
| 1146 if (was_lost_by_robustness && | 1142 if (was_lost_by_robustness && |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1172 result)); | 1168 result)); |
| 1173 } | 1169 } |
| 1174 | 1170 |
| 1175 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1171 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
| 1176 base::TimeDelta interval) { | 1172 base::TimeDelta interval) { |
| 1177 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1173 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
| 1178 interval)); | 1174 interval)); |
| 1179 } | 1175 } |
| 1180 | 1176 |
| 1181 } // namespace content | 1177 } // namespace content |
| OLD | NEW |