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

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

Issue 199443004: gpu: Raise GL_OUT_OF_MEMORY when BeginQueryEXT fails to allocate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: checkmem: Created 6 years, 9 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_UNKNOWN_CONTEXT_RESET_ARB,
piman 2014/03/21 21:34:48 nit: we're the guilty one.
danakj 2014/03/21 21:36:02 Should I tell the others they're innocent also? I
danakj 2014/03/21 22:53:50 Done.
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 2385 matching lines...) Expand 10 before | Expand all | Expand 10 after
3278 return; 3275 return;
3279 } 3276 }
3280 3277
3281 // TODO(gman) if id not GENned INV_OPERATION 3278 // TODO(gman) if id not GENned INV_OPERATION
3282 3279
3283 // if id does not have an object 3280 // if id does not have an object
3284 QueryTracker::Query* query = query_tracker_->GetQuery(id); 3281 QueryTracker::Query* query = query_tracker_->GetQuery(id);
3285 if (!query) { 3282 if (!query) {
3286 query = query_tracker_->CreateQuery(id, target); 3283 query = query_tracker_->CreateQuery(id, target);
3287 if (!query) { 3284 if (!query) {
3288 MustBeContextLost(); 3285 SetGLError(GL_OUT_OF_MEMORY,
3286 "glBeginQueryEXT",
3287 "transfer buffer allocation failed");
3289 return; 3288 return;
3290 } 3289 }
3291 } else if (query->target() != target) { 3290 } else if (query->target() != target) {
3292 SetGLError( 3291 SetGLError(
3293 GL_INVALID_OPERATION, "glBeginQueryEXT", "target does not match"); 3292 GL_INVALID_OPERATION, "glBeginQueryEXT", "target does not match");
3294 return; 3293 return;
3295 } 3294 }
3296 3295
3297 current_queries_[target] = query; 3296 current_queries_[target] = query;
3298 3297
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
3921 CheckGLError(); 3920 CheckGLError();
3922 } 3921 }
3923 3922
3924 // Include the auto-generated part of this file. We split this because it means 3923 // Include the auto-generated part of this file. We split this because it means
3925 // we can easily edit the non-auto generated parts right here in this file 3924 // we can easily edit the non-auto generated parts right here in this file
3926 // instead of having to edit some template or the code generator. 3925 // instead of having to edit some template or the code generator.
3927 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 3926 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
3928 3927
3929 } // namespace gles2 3928 } // namespace gles2
3930 } // namespace gpu 3929 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698