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

Side by Side Diff: gpu/command_buffer/client/gles2_implementation.cc

Issue 226423002: Merge 261120 "gpu: Lose context when BeginQueryEXT fails to allo..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1916/src/
Patch Set: Created 6 years, 8 months 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 // A class to emulate GLES2 over command buffers. 5 // A class to emulate GLES2 over command buffers.
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 CHECK_EQ(0, gles2_implementation_->use_count_); 75 CHECK_EQ(0, gles2_implementation_->use_count_);
76 ++gles2_implementation_->use_count_; 76 ++gles2_implementation_->use_count_;
77 } 77 }
78 78
79 GLES2Implementation::SingleThreadChecker::~SingleThreadChecker() { 79 GLES2Implementation::SingleThreadChecker::~SingleThreadChecker() {
80 --gles2_implementation_->use_count_; 80 --gles2_implementation_->use_count_;
81 CHECK_EQ(0, gles2_implementation_->use_count_); 81 CHECK_EQ(0, gles2_implementation_->use_count_);
82 } 82 }
83 83
84 GLES2Implementation::GLES2Implementation( 84 GLES2Implementation::GLES2Implementation(
85 GLES2CmdHelper* helper, 85 GLES2CmdHelper* helper,
86 ShareGroup* share_group, 86 ShareGroup* share_group,
87 TransferBufferInterface* transfer_buffer, 87 TransferBufferInterface* transfer_buffer,
88 bool bind_generates_resource, 88 bool bind_generates_resource,
89 GpuControl* gpu_control) 89 bool lose_context_when_out_of_memory,
90 GpuControl* gpu_control)
90 : helper_(helper), 91 : helper_(helper),
91 transfer_buffer_(transfer_buffer), 92 transfer_buffer_(transfer_buffer),
92 angle_pack_reverse_row_order_status_(kUnknownExtensionStatus), 93 angle_pack_reverse_row_order_status_(kUnknownExtensionStatus),
93 chromium_framebuffer_multisample_(kUnknownExtensionStatus), 94 chromium_framebuffer_multisample_(kUnknownExtensionStatus),
94 pack_alignment_(4), 95 pack_alignment_(4),
95 unpack_alignment_(4), 96 unpack_alignment_(4),
96 unpack_flip_y_(false), 97 unpack_flip_y_(false),
97 unpack_row_length_(0), 98 unpack_row_length_(0),
98 unpack_skip_rows_(0), 99 unpack_skip_rows_(0),
99 unpack_skip_pixels_(0), 100 unpack_skip_pixels_(0),
100 pack_reverse_row_order_(false), 101 pack_reverse_row_order_(false),
101 active_texture_unit_(0), 102 active_texture_unit_(0),
102 bound_framebuffer_(0), 103 bound_framebuffer_(0),
103 bound_read_framebuffer_(0), 104 bound_read_framebuffer_(0),
104 bound_renderbuffer_(0), 105 bound_renderbuffer_(0),
105 current_program_(0), 106 current_program_(0),
106 bound_array_buffer_id_(0), 107 bound_array_buffer_id_(0),
107 bound_pixel_pack_transfer_buffer_id_(0), 108 bound_pixel_pack_transfer_buffer_id_(0),
108 bound_pixel_unpack_transfer_buffer_id_(0), 109 bound_pixel_unpack_transfer_buffer_id_(0),
109 error_bits_(0), 110 error_bits_(0),
110 debug_(false), 111 debug_(false),
112 lose_context_when_out_of_memory_(lose_context_when_out_of_memory),
111 use_count_(0), 113 use_count_(0),
112 error_message_callback_(NULL), 114 error_message_callback_(NULL),
113 gpu_control_(gpu_control), 115 gpu_control_(gpu_control),
114 capabilities_(gpu_control->GetCapabilities()), 116 capabilities_(gpu_control->GetCapabilities()),
115 weak_ptr_factory_(this) { 117 weak_ptr_factory_(this) {
116 DCHECK(helper); 118 DCHECK(helper);
117 DCHECK(transfer_buffer); 119 DCHECK(transfer_buffer);
118 DCHECK(gpu_control); 120 DCHECK(gpu_control);
119 121
120 std::stringstream ss; 122 std::stringstream ss;
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 FailGLError(error); 478 FailGLError(error);
477 if (msg) { 479 if (msg) {
478 last_error_ = msg; 480 last_error_ = msg;
479 } 481 }
480 if (error_message_callback_) { 482 if (error_message_callback_) {
481 std::string temp(GLES2Util::GetStringError(error) + " : " + 483 std::string temp(GLES2Util::GetStringError(error) + " : " +
482 function_name + ": " + (msg ? msg : "")); 484 function_name + ": " + (msg ? msg : ""));
483 error_message_callback_->OnErrorMessage(temp.c_str(), 0); 485 error_message_callback_->OnErrorMessage(temp.c_str(), 0);
484 } 486 }
485 error_bits_ |= GLES2Util::GLErrorToErrorBit(error); 487 error_bits_ |= GLES2Util::GLErrorToErrorBit(error);
488
489 if (error == GL_OUT_OF_MEMORY && lose_context_when_out_of_memory_) {
490 helper_->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
491 GL_UNKNOWN_CONTEXT_RESET_ARB);
492 }
486 } 493 }
487 494
488 void GLES2Implementation::SetGLErrorInvalidEnum( 495 void GLES2Implementation::SetGLErrorInvalidEnum(
489 const char* function_name, GLenum value, const char* label) { 496 const char* function_name, GLenum value, const char* label) {
490 SetGLError(GL_INVALID_ENUM, function_name, 497 SetGLError(GL_INVALID_ENUM, function_name,
491 (std::string(label) + " was " + 498 (std::string(label) + " was " +
492 GLES2Util::GetStringEnum(value)).c_str()); 499 GLES2Util::GetStringEnum(value)).c_str());
493 } 500 }
494 501
495 bool GLES2Implementation::GetBucketContents(uint32 bucket_id, 502 bool GLES2Implementation::GetBucketContents(uint32 bucket_id,
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 } 870 }
864 871
865 void GLES2Implementation::ShallowFinishCHROMIUM() { 872 void GLES2Implementation::ShallowFinishCHROMIUM() {
866 GPU_CLIENT_SINGLE_THREAD_CHECK(); 873 GPU_CLIENT_SINGLE_THREAD_CHECK();
867 TRACE_EVENT0("gpu", "GLES2::ShallowFinishCHROMIUM"); 874 TRACE_EVENT0("gpu", "GLES2::ShallowFinishCHROMIUM");
868 // Flush our command buffer (tell the service to execute up to the flush cmd 875 // Flush our command buffer (tell the service to execute up to the flush cmd
869 // and don't return until it completes). 876 // and don't return until it completes).
870 helper_->CommandBufferHelper::Finish(); 877 helper_->CommandBufferHelper::Finish();
871 } 878 }
872 879
873 bool GLES2Implementation::MustBeContextLost() {
874 bool context_lost = helper_->IsContextLost();
875 if (!context_lost) {
876 WaitForCmd();
877 context_lost = helper_->IsContextLost();
878 }
879 CHECK(context_lost);
880 return context_lost;
881 }
882
883 void GLES2Implementation::FinishHelper() { 880 void GLES2Implementation::FinishHelper() {
884 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glFinish()"); 881 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glFinish()");
885 TRACE_EVENT0("gpu", "GLES2::Finish"); 882 TRACE_EVENT0("gpu", "GLES2::Finish");
886 // Insert the cmd to call glFinish 883 // Insert the cmd to call glFinish
887 helper_->Finish(); 884 helper_->Finish();
888 // Finish our command buffer 885 // Finish our command buffer
889 // (tell the service to execute up to the Finish cmd and wait for it to 886 // (tell the service to execute up to the Finish cmd and wait for it to
890 // execute.) 887 // execute.)
891 helper_->CommandBufferHelper::Finish(); 888 helper_->CommandBufferHelper::Finish();
892 } 889 }
(...skipping 2392 matching lines...) Expand 10 before | Expand all | Expand 10 after
3285 return; 3282 return;
3286 } 3283 }
3287 3284
3288 // TODO(gman) if id not GENned INV_OPERATION 3285 // TODO(gman) if id not GENned INV_OPERATION
3289 3286
3290 // if id does not have an object 3287 // if id does not have an object
3291 QueryTracker::Query* query = query_tracker_->GetQuery(id); 3288 QueryTracker::Query* query = query_tracker_->GetQuery(id);
3292 if (!query) { 3289 if (!query) {
3293 query = query_tracker_->CreateQuery(id, target); 3290 query = query_tracker_->CreateQuery(id, target);
3294 if (!query) { 3291 if (!query) {
3295 MustBeContextLost(); 3292 SetGLError(GL_OUT_OF_MEMORY,
3293 "glBeginQueryEXT",
3294 "transfer buffer allocation failed");
3296 return; 3295 return;
3297 } 3296 }
3298 } else if (query->target() != target) { 3297 } else if (query->target() != target) {
3299 SetGLError( 3298 SetGLError(
3300 GL_INVALID_OPERATION, "glBeginQueryEXT", "target does not match"); 3299 GL_INVALID_OPERATION, "glBeginQueryEXT", "target does not match");
3301 return; 3300 return;
3302 } 3301 }
3303 3302
3304 current_queries_[target] = query; 3303 current_queries_[target] = query;
3305 3304
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
3928 CheckGLError(); 3927 CheckGLError();
3929 } 3928 }
3930 3929
3931 // Include the auto-generated part of this file. We split this because it means 3930 // Include the auto-generated part of this file. We split this because it means
3932 // we can easily edit the non-auto generated parts right here in this file 3931 // we can easily edit the non-auto generated parts right here in this file
3933 // instead of having to edit some template or the code generator. 3932 // instead of having to edit some template or the code generator.
3934 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 3933 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
3935 3934
3936 } // namespace gles2 3935 } // namespace gles2
3937 } // namespace gpu 3936 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.h ('k') | gpu/command_buffer/client/gles2_implementation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698