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 <list> | 10 #include <list> |
(...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 | 1564 |
1565 // Validates the program and location for a glGetUniform call and returns | 1565 // Validates the program and location for a glGetUniform call and returns |
1566 // a SizeResult setup to receive the result. Returns true if glGetUniform | 1566 // a SizeResult setup to receive the result. Returns true if glGetUniform |
1567 // should be called. | 1567 // should be called. |
1568 bool GetUniformSetup( | 1568 bool GetUniformSetup( |
1569 GLuint program, GLint fake_location, | 1569 GLuint program, GLint fake_location, |
1570 uint32 shm_id, uint32 shm_offset, | 1570 uint32 shm_id, uint32 shm_offset, |
1571 error::Error* error, GLint* real_location, GLuint* service_id, | 1571 error::Error* error, GLint* real_location, GLuint* service_id, |
1572 void** result, GLenum* result_type); | 1572 void** result, GLenum* result_type); |
1573 | 1573 |
| 1574 void MaybeExitOnContextLost(); |
1574 virtual bool WasContextLost() override; | 1575 virtual bool WasContextLost() override; |
1575 virtual bool WasContextLostByRobustnessExtension() override; | 1576 virtual bool WasContextLostByRobustnessExtension() override; |
1576 virtual void LoseContext(uint32 reset_status) override; | 1577 virtual void LoseContext(uint32 reset_status) override; |
1577 | 1578 |
1578 #if defined(OS_MACOSX) | 1579 #if defined(OS_MACOSX) |
1579 void ReleaseIOSurfaceForTexture(GLuint texture_id); | 1580 void ReleaseIOSurfaceForTexture(GLuint texture_id); |
1580 #endif | 1581 #endif |
1581 | 1582 |
1582 bool ValidateCompressedTexDimensions( | 1583 bool ValidateCompressedTexDimensions( |
1583 const char* function_name, | 1584 const char* function_name, |
(...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3044 | 3045 |
3045 // } // anonymous namespace | 3046 // } // anonymous namespace |
3046 | 3047 |
3047 bool GLES2DecoderImpl::MakeCurrent() { | 3048 bool GLES2DecoderImpl::MakeCurrent() { |
3048 if (!context_.get()) | 3049 if (!context_.get()) |
3049 return false; | 3050 return false; |
3050 | 3051 |
3051 if (!context_->MakeCurrent(surface_.get()) || WasContextLost()) { | 3052 if (!context_->MakeCurrent(surface_.get()) || WasContextLost()) { |
3052 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent."; | 3053 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent."; |
3053 | 3054 |
3054 // Some D3D drivers cannot recover from device lost in the GPU process | 3055 MaybeExitOnContextLost(); |
3055 // sandbox. Allow a new GPU process to launch. | |
3056 if (workarounds().exit_on_context_lost) { | |
3057 LOG(ERROR) << "Exiting GPU process because some drivers cannot reset" | |
3058 << " a D3D device in the Chrome GPU process sandbox."; | |
3059 #if defined(OS_WIN) | |
3060 base::win::SetShouldCrashOnProcessDetach(false); | |
3061 #endif | |
3062 exit(0); | |
3063 } | |
3064 | 3056 |
3065 return false; | 3057 return false; |
3066 } | 3058 } |
3067 | 3059 |
3068 ProcessFinishedAsyncTransfers(); | 3060 ProcessFinishedAsyncTransfers(); |
3069 | 3061 |
3070 // Rebind the FBO if it was unbound by the context. | 3062 // Rebind the FBO if it was unbound by the context. |
3071 if (workarounds().unbind_fbo_on_context_switch) | 3063 if (workarounds().unbind_fbo_on_context_switch) |
3072 RestoreFramebufferBindings(); | 3064 RestoreFramebufferBindings(); |
3073 | 3065 |
(...skipping 6579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9653 case GL_INNOCENT_CONTEXT_RESET_ARB: | 9645 case GL_INNOCENT_CONTEXT_RESET_ARB: |
9654 return error::kInnocent; | 9646 return error::kInnocent; |
9655 case GL_UNKNOWN_CONTEXT_RESET_ARB: | 9647 case GL_UNKNOWN_CONTEXT_RESET_ARB: |
9656 return error::kUnknown; | 9648 return error::kUnknown; |
9657 } | 9649 } |
9658 | 9650 |
9659 NOTREACHED(); | 9651 NOTREACHED(); |
9660 return error::kUnknown; | 9652 return error::kUnknown; |
9661 } | 9653 } |
9662 | 9654 |
| 9655 void GLES2DecoderImpl::MaybeExitOnContextLost() { |
| 9656 // Some D3D drivers cannot recover from device lost in the GPU process |
| 9657 // sandbox. Allow a new GPU process to launch. |
| 9658 if (workarounds().exit_on_context_lost) { |
| 9659 LOG(ERROR) << "Exiting GPU process because some drivers cannot reset" |
| 9660 << " a D3D device in the Chrome GPU process sandbox."; |
| 9661 #if defined(OS_WIN) |
| 9662 base::win::SetShouldCrashOnProcessDetach(false); |
| 9663 #endif |
| 9664 exit(0); |
| 9665 } |
| 9666 } |
| 9667 |
9663 bool GLES2DecoderImpl::WasContextLost() { | 9668 bool GLES2DecoderImpl::WasContextLost() { |
9664 if (reset_status_ != GL_NO_ERROR) { | 9669 if (reset_status_ != GL_NO_ERROR) { |
| 9670 MaybeExitOnContextLost(); |
9665 return true; | 9671 return true; |
9666 } | 9672 } |
9667 if (context_->WasAllocatedUsingRobustnessExtension()) { | 9673 if (context_->WasAllocatedUsingRobustnessExtension()) { |
9668 GLenum status = GL_NO_ERROR; | 9674 GLenum status = GL_NO_ERROR; |
9669 if (has_robustness_extension_) | 9675 if (has_robustness_extension_) |
9670 status = glGetGraphicsResetStatusARB(); | 9676 status = glGetGraphicsResetStatusARB(); |
9671 if (status != GL_NO_ERROR) { | 9677 if (status != GL_NO_ERROR) { |
9672 // The graphics card was reset. Signal a lost context to the application. | 9678 // The graphics card was reset. Signal a lost context to the application. |
9673 reset_status_ = status; | 9679 reset_status_ = status; |
9674 reset_by_robustness_extension_ = true; | 9680 reset_by_robustness_extension_ = true; |
9675 LOG(ERROR) << (surface_->IsOffscreen() ? "Offscreen" : "Onscreen") | 9681 LOG(ERROR) << (surface_->IsOffscreen() ? "Offscreen" : "Onscreen") |
9676 << " context lost via ARB/EXT_robustness. Reset status = " | 9682 << " context lost via ARB/EXT_robustness. Reset status = " |
9677 << GLES2Util::GetStringEnum(status); | 9683 << GLES2Util::GetStringEnum(status); |
| 9684 MaybeExitOnContextLost(); |
9678 return true; | 9685 return true; |
9679 } | 9686 } |
9680 } | 9687 } |
9681 return false; | 9688 return false; |
9682 } | 9689 } |
9683 | 9690 |
9684 bool GLES2DecoderImpl::WasContextLostByRobustnessExtension() { | 9691 bool GLES2DecoderImpl::WasContextLostByRobustnessExtension() { |
9685 return WasContextLost() && reset_by_robustness_extension_; | 9692 return WasContextLost() && reset_by_robustness_extension_; |
9686 } | 9693 } |
9687 | 9694 |
(...skipping 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11189 } | 11196 } |
11190 } | 11197 } |
11191 | 11198 |
11192 // Include the auto-generated part of this file. We split this because it means | 11199 // Include the auto-generated part of this file. We split this because it means |
11193 // we can easily edit the non-auto generated parts right here in this file | 11200 // we can easily edit the non-auto generated parts right here in this file |
11194 // instead of having to edit some template or the code generator. | 11201 // instead of having to edit some template or the code generator. |
11195 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 11202 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
11196 | 11203 |
11197 } // namespace gles2 | 11204 } // namespace gles2 |
11198 } // namespace gpu | 11205 } // namespace gpu |
OLD | NEW |