Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 11568029: Add a command to lose the context (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add docs, lose parent and children, fix typo Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 bool GetUniformSetup( 1438 bool GetUniformSetup(
1439 GLuint program, GLint fake_location, 1439 GLuint program, GLint fake_location,
1440 uint32 shm_id, uint32 shm_offset, 1440 uint32 shm_id, uint32 shm_offset,
1441 error::Error* error, GLint* real_location, GLuint* service_id, 1441 error::Error* error, GLint* real_location, GLuint* service_id,
1442 void** result, GLenum* result_type); 1442 void** result, GLenum* result_type);
1443 1443
1444 // Computes the estimated memory used for the backbuffer and passes it to 1444 // Computes the estimated memory used for the backbuffer and passes it to
1445 // the tracing system. 1445 // the tracing system.
1446 size_t GetBackbufferMemoryTotal(); 1446 size_t GetBackbufferMemoryTotal();
1447 1447
1448 // Returns true if the context was just lost due to e.g. GL_ARB_robustness.
1449 virtual bool WasContextLost() OVERRIDE; 1448 virtual bool WasContextLost() OVERRIDE;
1449 virtual void LoseContext(uint32 reset_status) OVERRIDE;
1450 1450
1451 #if defined(OS_MACOSX) 1451 #if defined(OS_MACOSX)
1452 void ReleaseIOSurfaceForTexture(GLuint texture_id); 1452 void ReleaseIOSurfaceForTexture(GLuint texture_id);
1453 #endif 1453 #endif
1454 1454
1455 // Validates the combination of texture parameters. For example validates that 1455 // Validates the combination of texture parameters. For example validates that
1456 // for a given format the specific type, level and targets are valid. 1456 // for a given format the specific type, level and targets are valid.
1457 // Synthesizes the correct GL error if invalid. Returns true if valid. 1457 // Synthesizes the correct GL error if invalid. Returns true if valid.
1458 bool ValidateTextureParameters( 1458 bool ValidateTextureParameters(
1459 const char* function_name, 1459 const char* function_name,
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 2130
2131 compile_shader_always_succeeds_ = CommandLine::ForCurrentProcess()->HasSwitch( 2131 compile_shader_always_succeeds_ = CommandLine::ForCurrentProcess()->HasSwitch(
2132 switches::kCompileShaderAlwaysSucceeds); 2132 switches::kCompileShaderAlwaysSucceeds);
2133 2133
2134 2134
2135 // Take ownership of the context and surface. The surface can be replaced with 2135 // Take ownership of the context and surface. The surface can be replaced with
2136 // SetSurface. 2136 // SetSurface.
2137 context_ = context; 2137 context_ = context;
2138 surface_ = surface; 2138 surface_ = surface;
2139 2139
2140 if (!group_->Initialize(disallowed_features, allowed_extensions)) { 2140 if (!group_->Initialize(this, disallowed_features, allowed_extensions)) {
2141 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group " 2141 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group "
2142 << "failed to initialize."; 2142 << "failed to initialize.";
2143 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. 2143 group_ = NULL; // Must not destroy ContextGroup if it is not initialized.
2144 Destroy(true); 2144 Destroy(true);
2145 return false; 2145 return false;
2146 } 2146 }
2147 CHECK_GL_ERROR(); 2147 CHECK_GL_ERROR();
2148 2148
2149 disallowed_features_ = disallowed_features; 2149 disallowed_features_ = disallowed_features;
2150 2150
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
2995 query_manager_->Destroy(have_context); 2995 query_manager_->Destroy(have_context);
2996 query_manager_.reset(); 2996 query_manager_.reset();
2997 } 2997 }
2998 2998
2999 if (vertex_array_manager_ .get()) { 2999 if (vertex_array_manager_ .get()) {
3000 vertex_array_manager_->Destroy(have_context); 3000 vertex_array_manager_->Destroy(have_context);
3001 vertex_array_manager_.reset(); 3001 vertex_array_manager_.reset();
3002 } 3002 }
3003 3003
3004 if (group_) { 3004 if (group_) {
3005 group_->Destroy(have_context); 3005 group_->Destroy(this, have_context);
3006 group_ = NULL; 3006 group_ = NULL;
3007 } 3007 }
3008 3008
3009 if (context_.get()) { 3009 if (context_.get()) {
3010 context_->ReleaseCurrent(NULL); 3010 context_->ReleaseCurrent(NULL);
3011 context_ = NULL; 3011 context_ = NULL;
3012 } 3012 }
3013 3013
3014 offscreen_target_frame_buffer_.reset(); 3014 offscreen_target_frame_buffer_.reset();
3015 offscreen_target_color_texture_.reset(); 3015 offscreen_target_color_texture_.reset();
(...skipping 5778 matching lines...) Expand 10 before | Expand all | Expand 10 after
8794 return error::kInnocent; 8794 return error::kInnocent;
8795 case GL_UNKNOWN_CONTEXT_RESET_ARB: 8795 case GL_UNKNOWN_CONTEXT_RESET_ARB:
8796 return error::kUnknown; 8796 return error::kUnknown;
8797 } 8797 }
8798 8798
8799 NOTREACHED(); 8799 NOTREACHED();
8800 return error::kUnknown; 8800 return error::kUnknown;
8801 } 8801 }
8802 8802
8803 bool GLES2DecoderImpl::WasContextLost() { 8803 bool GLES2DecoderImpl::WasContextLost() {
8804 if (reset_status_ != GL_NO_ERROR) {
8805 return true;
8806 }
8804 if (context_->WasAllocatedUsingRobustnessExtension()) { 8807 if (context_->WasAllocatedUsingRobustnessExtension()) {
8805 GLenum status = GL_NO_ERROR; 8808 GLenum status = GL_NO_ERROR;
8806 if (has_robustness_extension_) 8809 if (has_robustness_extension_)
8807 status = glGetGraphicsResetStatusARB(); 8810 status = glGetGraphicsResetStatusARB();
8808 if (status != GL_NO_ERROR) { 8811 if (status != GL_NO_ERROR) {
8809 // The graphics card was reset. Signal a lost context to the application. 8812 // The graphics card was reset. Signal a lost context to the application.
8810 reset_status_ = status; 8813 reset_status_ = status;
8811 LOG(ERROR) << (surface_->IsOffscreen() ? "Offscreen" : "Onscreen") 8814 LOG(ERROR) << (surface_->IsOffscreen() ? "Offscreen" : "Onscreen")
8812 << " context lost via ARB/EXT_robustness. Reset status = 0x" 8815 << " context lost via ARB/EXT_robustness. Reset status = "
8813 << std::hex << status << std::dec; 8816 << GLES2Util::GetStringEnum(status);
8814 return true; 8817 return true;
8815 } 8818 }
8816 } 8819 }
8817 return false; 8820 return false;
8818 } 8821 }
8819 8822
8823 void GLES2DecoderImpl::LoseContext(uint32 reset_status) {
8824 // Only loses the context once.
8825 if (reset_status_ != GL_NO_ERROR) {
8826 return;
8827 }
8828
8829 // Marks this context as lost.
8830 reset_status_ = reset_status;
8831 current_decoder_error_ = error::kLostContext;
8832
8833 // Loses the parent's context.
8834 if (parent_) {
8835 parent_->LoseContext(reset_status);
8836 }
8837
8838 // Loses any child contexts.
8839 for (ChildList::iterator it = children_.begin();
8840 it != children_.end();
8841 ++it) {
8842 (*it)->LoseContext(reset_status);
8843 }
8844 }
8845
8846 error::Error GLES2DecoderImpl::HandleLoseContextCHROMIUM(
8847 uint32 immediate_data_size, const gles2::LoseContextCHROMIUM& c) {
8848 GLenum current = static_cast<GLenum>(c.current);
8849 GLenum other = static_cast<GLenum>(c.other);
8850 if (!validators_->reset_status.IsValid(current)) {
8851 SetGLErrorInvalidEnum("glLoseContextCHROMIUM", current, "current");
8852 }
8853 if (!validators_->reset_status.IsValid(other)) {
8854 SetGLErrorInvalidEnum("glLoseContextCHROMIUM", other, "other");
8855 }
8856 group_->LoseContexts(other);
8857 reset_status_ = current;
8858 current_decoder_error_ = error::kLostContext;
8859 return error::kLostContext;
8860 }
8861
8820 bool GLES2DecoderImpl::GenQueriesEXTHelper( 8862 bool GLES2DecoderImpl::GenQueriesEXTHelper(
8821 GLsizei n, const GLuint* client_ids) { 8863 GLsizei n, const GLuint* client_ids) {
8822 for (GLsizei ii = 0; ii < n; ++ii) { 8864 for (GLsizei ii = 0; ii < n; ++ii) {
8823 if (query_manager_->GetQuery(client_ids[ii])) { 8865 if (query_manager_->GetQuery(client_ids[ii])) {
8824 return false; 8866 return false;
8825 } 8867 }
8826 } 8868 }
8827 // NOTE: We don't generate Query objects here. Only in BeginQueryEXT 8869 // NOTE: We don't generate Query objects here. Only in BeginQueryEXT
8828 return true; 8870 return true;
8829 } 8871 }
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
9751 target, level, xoffset, yoffset, width, height, format, type, pixels); 9793 target, level, xoffset, yoffset, width, height, format, type, pixels);
9752 } 9794 }
9753 9795
9754 // Include the auto-generated part of this file. We split this because it means 9796 // Include the auto-generated part of this file. We split this because it means
9755 // we can easily edit the non-auto generated parts right here in this file 9797 // we can easily edit the non-auto generated parts right here in this file
9756 // instead of having to edit some template or the code generator. 9798 // instead of having to edit some template or the code generator.
9757 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 9799 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
9758 9800
9759 } // namespace gles2 9801 } // namespace gles2
9760 } // namespace gpu 9802 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698