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 <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 const ContextState* GetContextState() override { return &state_; } | 678 const ContextState* GetContextState() override { return &state_; } |
679 | 679 |
680 void SetShaderCacheCallback(const ShaderCacheCallback& callback) override; | 680 void SetShaderCacheCallback(const ShaderCacheCallback& callback) override; |
681 void SetWaitSyncPointCallback(const WaitSyncPointCallback& callback) override; | 681 void SetWaitSyncPointCallback(const WaitSyncPointCallback& callback) override; |
682 | 682 |
683 AsyncPixelTransferManager* GetAsyncPixelTransferManager() override; | 683 AsyncPixelTransferManager* GetAsyncPixelTransferManager() override; |
684 void ResetAsyncPixelTransferManagerForTest() override; | 684 void ResetAsyncPixelTransferManagerForTest() override; |
685 void SetAsyncPixelTransferManagerForTest( | 685 void SetAsyncPixelTransferManagerForTest( |
686 AsyncPixelTransferManager* manager) override; | 686 AsyncPixelTransferManager* manager) override; |
687 void SetIgnoreCachedStateForTest(bool ignore) override; | 687 void SetIgnoreCachedStateForTest(bool ignore) override; |
| 688 void SetAllowExit(bool allow_exit) override; |
688 void ProcessFinishedAsyncTransfers(); | 689 void ProcessFinishedAsyncTransfers(); |
689 | 690 |
690 bool GetServiceTextureId(uint32 client_texture_id, | 691 bool GetServiceTextureId(uint32 client_texture_id, |
691 uint32* service_texture_id) override; | 692 uint32* service_texture_id) override; |
692 | 693 |
693 uint32 GetTextureUploadCount() override; | 694 uint32 GetTextureUploadCount() override; |
694 base::TimeDelta GetTotalTextureUploadTime() override; | 695 base::TimeDelta GetTotalTextureUploadTime() override; |
695 base::TimeDelta GetTotalProcessingCommandsTime() override; | 696 base::TimeDelta GetTotalProcessingCommandsTime() override; |
696 void AddProcessingCommandsTime(base::TimeDelta) override; | 697 void AddProcessingCommandsTime(base::TimeDelta) override; |
697 | 698 |
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 bool gpu_trace_commands_; | 1991 bool gpu_trace_commands_; |
1991 bool gpu_debug_commands_; | 1992 bool gpu_debug_commands_; |
1992 | 1993 |
1993 std::queue<linked_ptr<FenceCallback> > pending_readpixel_fences_; | 1994 std::queue<linked_ptr<FenceCallback> > pending_readpixel_fences_; |
1994 | 1995 |
1995 // Used to validate multisample renderbuffers if needed | 1996 // Used to validate multisample renderbuffers if needed |
1996 GLuint validation_texture_; | 1997 GLuint validation_texture_; |
1997 GLuint validation_fbo_multisample_; | 1998 GLuint validation_fbo_multisample_; |
1998 GLuint validation_fbo_; | 1999 GLuint validation_fbo_; |
1999 | 2000 |
| 2001 bool allow_exit_; |
| 2002 |
2000 typedef gpu::gles2::GLES2Decoder::Error (GLES2DecoderImpl::*CmdHandler)( | 2003 typedef gpu::gles2::GLES2Decoder::Error (GLES2DecoderImpl::*CmdHandler)( |
2001 uint32 immediate_data_size, | 2004 uint32 immediate_data_size, |
2002 const void* data); | 2005 const void* data); |
2003 | 2006 |
2004 // A struct to hold info about each command. | 2007 // A struct to hold info about each command. |
2005 struct CommandInfo { | 2008 struct CommandInfo { |
2006 CmdHandler cmd_handler; | 2009 CmdHandler cmd_handler; |
2007 uint8 arg_flags; // How to handle the arguments for this command | 2010 uint8 arg_flags; // How to handle the arguments for this command |
2008 uint8 cmd_flags; // How to handle this command | 2011 uint8 cmd_flags; // How to handle this command |
2009 uint16 arg_count; // How many arguments are expected for this command. | 2012 uint16 arg_count; // How many arguments are expected for this command. |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2502 .texsubimage_faster_than_teximage), | 2505 .texsubimage_faster_than_teximage), |
2503 cb_command_trace_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( | 2506 cb_command_trace_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( |
2504 TRACE_DISABLED_BY_DEFAULT("cb_command"))), | 2507 TRACE_DISABLED_BY_DEFAULT("cb_command"))), |
2505 gpu_decoder_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( | 2508 gpu_decoder_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( |
2506 TRACE_DISABLED_BY_DEFAULT("gpu_decoder"))), | 2509 TRACE_DISABLED_BY_DEFAULT("gpu_decoder"))), |
2507 gpu_trace_level_(2), | 2510 gpu_trace_level_(2), |
2508 gpu_trace_commands_(false), | 2511 gpu_trace_commands_(false), |
2509 gpu_debug_commands_(false), | 2512 gpu_debug_commands_(false), |
2510 validation_texture_(0), | 2513 validation_texture_(0), |
2511 validation_fbo_multisample_(0), | 2514 validation_fbo_multisample_(0), |
2512 validation_fbo_(0) { | 2515 validation_fbo_(0), |
| 2516 allow_exit_(false) { |
2513 DCHECK(group); | 2517 DCHECK(group); |
2514 | 2518 |
2515 // The shader translator is used for WebGL even when running on EGL | 2519 // The shader translator is used for WebGL even when running on EGL |
2516 // because additional restrictions are needed (like only enabling | 2520 // because additional restrictions are needed (like only enabling |
2517 // GL_OES_standard_derivatives on demand). It is used for the unit | 2521 // GL_OES_standard_derivatives on demand). It is used for the unit |
2518 // tests because GLES2DecoderWithShaderTest.GetShaderInfoLogValidArgs passes | 2522 // tests because GLES2DecoderWithShaderTest.GetShaderInfoLogValidArgs passes |
2519 // the empty string to CompileShader and this is not a valid shader. | 2523 // the empty string to CompileShader and this is not a valid shader. |
2520 if (gfx::GetGLImplementation() == gfx::kGLImplementationMockGL || | 2524 if (gfx::GetGLImplementation() == gfx::kGLImplementationMockGL || |
2521 base::CommandLine::ForCurrentProcess()->HasSwitch( | 2525 base::CommandLine::ForCurrentProcess()->HasSwitch( |
2522 switches::kDisableGLSLTranslator)) { | 2526 switches::kDisableGLSLTranslator)) { |
(...skipping 1964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4487 } | 4491 } |
4488 | 4492 |
4489 void GLES2DecoderImpl::RestoreAllAttributes() const { | 4493 void GLES2DecoderImpl::RestoreAllAttributes() const { |
4490 state_.RestoreVertexAttribs(); | 4494 state_.RestoreVertexAttribs(); |
4491 } | 4495 } |
4492 | 4496 |
4493 void GLES2DecoderImpl::SetIgnoreCachedStateForTest(bool ignore) { | 4497 void GLES2DecoderImpl::SetIgnoreCachedStateForTest(bool ignore) { |
4494 state_.SetIgnoreCachedStateForTest(ignore); | 4498 state_.SetIgnoreCachedStateForTest(ignore); |
4495 } | 4499 } |
4496 | 4500 |
| 4501 void GLES2DecoderImpl::SetAllowExit(bool allow_exit) { |
| 4502 allow_exit_ = allow_exit; |
| 4503 } |
| 4504 |
4497 void GLES2DecoderImpl::OnFboChanged() const { | 4505 void GLES2DecoderImpl::OnFboChanged() const { |
4498 if (workarounds().restore_scissor_on_fbo_change) | 4506 if (workarounds().restore_scissor_on_fbo_change) |
4499 state_.fbo_binding_for_scissor_workaround_dirty = true; | 4507 state_.fbo_binding_for_scissor_workaround_dirty = true; |
4500 | 4508 |
4501 if (workarounds().gl_begin_gl_end_on_fbo_change_to_backbuffer) { | 4509 if (workarounds().gl_begin_gl_end_on_fbo_change_to_backbuffer) { |
4502 GLint bound_fbo_unsigned = -1; | 4510 GLint bound_fbo_unsigned = -1; |
4503 glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &bound_fbo_unsigned); | 4511 glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &bound_fbo_unsigned); |
4504 GLuint bound_fbo = static_cast<GLuint>(bound_fbo_unsigned); | 4512 GLuint bound_fbo = static_cast<GLuint>(bound_fbo_unsigned); |
4505 if (surface_ && surface_->GetBackingFrameBufferObject() == bound_fbo) | 4513 if (surface_ && surface_->GetBackingFrameBufferObject() == bound_fbo) |
4506 surface_->NotifyWasBound(); | 4514 surface_->NotifyWasBound(); |
(...skipping 6812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11319 void GLES2DecoderImpl::MarkContextLost(error::ContextLostReason reason) { | 11327 void GLES2DecoderImpl::MarkContextLost(error::ContextLostReason reason) { |
11320 // Only lose the context once. | 11328 // Only lose the context once. |
11321 if (WasContextLost()) | 11329 if (WasContextLost()) |
11322 return; | 11330 return; |
11323 | 11331 |
11324 // Don't make GL calls in here, the context might not be current. | 11332 // Don't make GL calls in here, the context might not be current. |
11325 context_lost_reason_ = reason; | 11333 context_lost_reason_ = reason; |
11326 current_decoder_error_ = error::kLostContext; | 11334 current_decoder_error_ = error::kLostContext; |
11327 context_was_lost_ = true; | 11335 context_was_lost_ = true; |
11328 | 11336 |
11329 // Some D3D drivers cannot recover from device lost in the GPU process | 11337 // Work around issues with recovery by allowing a new GPU process to launch. |
11330 // sandbox. Allow a new GPU process to launch. | 11338 if (workarounds().exit_on_context_lost && allow_exit_) { |
11331 if (workarounds().exit_on_context_lost) { | 11339 LOG(ERROR) << "Exiting GPU process because some drivers cannot recover" |
11332 LOG(ERROR) << "Exiting GPU process because some drivers cannot reset" | 11340 << " from problems."; |
11333 << " a D3D device in the Chrome GPU process sandbox."; | |
11334 #if defined(OS_WIN) | 11341 #if defined(OS_WIN) |
11335 base::win::SetShouldCrashOnProcessDetach(false); | 11342 base::win::SetShouldCrashOnProcessDetach(false); |
11336 #endif | 11343 #endif |
11337 exit(0); | 11344 exit(0); |
11338 } | 11345 } |
11339 } | 11346 } |
11340 | 11347 |
11341 bool GLES2DecoderImpl::CheckResetStatus() { | 11348 bool GLES2DecoderImpl::CheckResetStatus() { |
11342 DCHECK(!WasContextLost()); | 11349 DCHECK(!WasContextLost()); |
11343 DCHECK(context_->IsCurrent(NULL)); | 11350 DCHECK(context_->IsCurrent(NULL)); |
(...skipping 1968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13312 } | 13319 } |
13313 } | 13320 } |
13314 | 13321 |
13315 // Include the auto-generated part of this file. We split this because it means | 13322 // Include the auto-generated part of this file. We split this because it means |
13316 // we can easily edit the non-auto generated parts right here in this file | 13323 // we can easily edit the non-auto generated parts right here in this file |
13317 // instead of having to edit some template or the code generator. | 13324 // instead of having to edit some template or the code generator. |
13318 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 13325 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
13319 | 13326 |
13320 } // namespace gles2 | 13327 } // namespace gles2 |
13321 } // namespace gpu | 13328 } // namespace gpu |
OLD | NEW |