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

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

Issue 1864723003: Make lost context and error message callbacks on GpuControl go to client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: errorcallback: . Created 4 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
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 <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 #if defined(OS_NACL) 154 #if defined(OS_NACL)
155 0), 155 0),
156 #else 156 #else
157 // Do not use more than 5% of extra shared memory, and do not 157 // Do not use more than 5% of extra shared memory, and do not
158 // use any extra for memory contrained devices (<=1GB). 158 // use any extra for memory contrained devices (<=1GB).
159 base::SysInfo::AmountOfPhysicalMemory() > 1024 * 1024 * 1024 159 base::SysInfo::AmountOfPhysicalMemory() > 1024 * 1024 * 1024
160 ? base::saturated_cast<uint32_t>( 160 ? base::saturated_cast<uint32_t>(
161 base::SysInfo::AmountOfPhysicalMemory() / 20) 161 base::SysInfo::AmountOfPhysicalMemory() / 20)
162 : 0), 162 : 0),
163 #endif 163 #endif
164 error_message_callback_(NULL),
165 current_trace_stack_(0), 164 current_trace_stack_(0),
166 gpu_control_(gpu_control), 165 gpu_control_(gpu_control),
167 capabilities_(gpu_control->GetCapabilities()), 166 capabilities_(gpu_control->GetCapabilities()),
168 aggressively_free_resources_(false), 167 aggressively_free_resources_(false),
169 cached_extension_string_(nullptr), 168 cached_extension_string_(nullptr),
170 weak_ptr_factory_(this) { 169 weak_ptr_factory_(this) {
171 DCHECK(helper); 170 DCHECK(helper);
172 DCHECK(transfer_buffer); 171 DCHECK(transfer_buffer);
173 DCHECK(gpu_control); 172 DCHECK(gpu_control);
174 173
(...skipping 19 matching lines...) Expand all
194 bool GLES2Implementation::Initialize( 193 bool GLES2Implementation::Initialize(
195 unsigned int starting_transfer_buffer_size, 194 unsigned int starting_transfer_buffer_size,
196 unsigned int min_transfer_buffer_size, 195 unsigned int min_transfer_buffer_size,
197 unsigned int max_transfer_buffer_size, 196 unsigned int max_transfer_buffer_size,
198 unsigned int mapped_memory_limit) { 197 unsigned int mapped_memory_limit) {
199 TRACE_EVENT0("gpu", "GLES2Implementation::Initialize"); 198 TRACE_EVENT0("gpu", "GLES2Implementation::Initialize");
200 DCHECK_GE(starting_transfer_buffer_size, min_transfer_buffer_size); 199 DCHECK_GE(starting_transfer_buffer_size, min_transfer_buffer_size);
201 DCHECK_LE(starting_transfer_buffer_size, max_transfer_buffer_size); 200 DCHECK_LE(starting_transfer_buffer_size, max_transfer_buffer_size);
202 DCHECK_GE(min_transfer_buffer_size, kStartingOffset); 201 DCHECK_GE(min_transfer_buffer_size, kStartingOffset);
203 202
203 gpu_control_->SetGpuControlClient(this);
204
204 if (!transfer_buffer_->Initialize( 205 if (!transfer_buffer_->Initialize(
205 starting_transfer_buffer_size, 206 starting_transfer_buffer_size,
206 kStartingOffset, 207 kStartingOffset,
207 min_transfer_buffer_size, 208 min_transfer_buffer_size,
208 max_transfer_buffer_size, 209 max_transfer_buffer_size,
209 kAlignment, 210 kAlignment,
210 kSizeToFlush)) { 211 kSizeToFlush)) {
211 return false; 212 return false;
212 } 213 }
213 214
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 543
543 void GLES2Implementation::SetGLError( 544 void GLES2Implementation::SetGLError(
544 GLenum error, const char* function_name, const char* msg) { 545 GLenum error, const char* function_name, const char* msg) {
545 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] Client Synthesized Error: " 546 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] Client Synthesized Error: "
546 << GLES2Util::GetStringError(error) << ": " 547 << GLES2Util::GetStringError(error) << ": "
547 << function_name << ": " << msg); 548 << function_name << ": " << msg);
548 FailGLError(error); 549 FailGLError(error);
549 if (msg) { 550 if (msg) {
550 last_error_ = msg; 551 last_error_ = msg;
551 } 552 }
552 if (error_message_callback_) { 553 if (!error_message_callback_.is_null()) {
553 std::string temp(GLES2Util::GetStringError(error) + " : " + 554 std::string temp(GLES2Util::GetStringError(error) + " : " +
554 function_name + ": " + (msg ? msg : "")); 555 function_name + ": " + (msg ? msg : ""));
555 error_message_callback_->OnErrorMessage(temp.c_str(), 0); 556 error_message_callback_.Run(temp.c_str(), 0);
556 } 557 }
557 error_bits_ |= GLES2Util::GLErrorToErrorBit(error); 558 error_bits_ |= GLES2Util::GLErrorToErrorBit(error);
558 559
559 if (error == GL_OUT_OF_MEMORY && lose_context_when_out_of_memory_) { 560 if (error == GL_OUT_OF_MEMORY && lose_context_when_out_of_memory_) {
560 helper_->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, 561 helper_->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
561 GL_UNKNOWN_CONTEXT_RESET_ARB); 562 GL_UNKNOWN_CONTEXT_RESET_ARB);
562 } 563 }
563 } 564 }
564 565
565 void GLES2Implementation::SetGLErrorInvalidEnum( 566 void GLES2Implementation::SetGLErrorInvalidEnum(
(...skipping 5245 matching lines...) Expand 10 before | Expand all | Expand 10 after
5811 } 5812 }
5812 buffer->set_mapped(false); 5813 buffer->set_mapped(false);
5813 CheckGLError(); 5814 CheckGLError();
5814 return true; 5815 return true;
5815 } 5816 }
5816 5817
5817 uint64_t GLES2Implementation::ShareGroupTracingGUID() const { 5818 uint64_t GLES2Implementation::ShareGroupTracingGUID() const {
5818 return share_group_->TracingGUID(); 5819 return share_group_->TracingGUID();
5819 } 5820 }
5820 5821
5822 void GLES2Implementation::SetErrorMessageCallback(
5823 const base::Callback<void(const char*, int32_t)>& callback) {
5824 error_message_callback_ = callback;
5825 }
5826
5827 void GLES2Implementation::SetLostContextCallback(
5828 const base::Closure& callback) {
5829 lost_context_callback_ = callback;
5830 }
5831
5832 void GLES2Implementation::OnGpuControlLostContext() {
5833 if (!lost_context_callback_.is_null())
5834 lost_context_callback_.Run();
5835 }
5836
5837 void GLES2Implementation::OnGpuControlErrorMessage(const char* message,
5838 int32_t id) {
5839 if (!error_message_callback_.is_null())
5840 error_message_callback_.Run(message, id);
5841 }
5842
5821 GLuint64 GLES2Implementation::InsertFenceSyncCHROMIUM() { 5843 GLuint64 GLES2Implementation::InsertFenceSyncCHROMIUM() {
5822 const uint64_t release = gpu_control_->GenerateFenceSyncRelease(); 5844 const uint64_t release = gpu_control_->GenerateFenceSyncRelease();
5823 helper_->InsertFenceSyncCHROMIUM(release); 5845 helper_->InsertFenceSyncCHROMIUM(release);
5824 return release; 5846 return release;
5825 } 5847 }
5826 5848
5827 void GLES2Implementation::GenSyncTokenCHROMIUM(GLuint64 fence_sync, 5849 void GLES2Implementation::GenSyncTokenCHROMIUM(GLuint64 fence_sync,
5828 GLbyte* sync_token) { 5850 GLbyte* sync_token) {
5829 if (!sync_token) { 5851 if (!sync_token) {
5830 SetGLError(GL_INVALID_VALUE, "glGenSyncTokenCHROMIUM", "empty sync_token"); 5852 SetGLError(GL_INVALID_VALUE, "glGenSyncTokenCHROMIUM", "empty sync_token");
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
6846 cached_extensions_.clear(); 6868 cached_extensions_.clear();
6847 } 6869 }
6848 6870
6849 // Include the auto-generated part of this file. We split this because it means 6871 // Include the auto-generated part of this file. We split this because it means
6850 // we can easily edit the non-auto generated parts right here in this file 6872 // we can easily edit the non-auto generated parts right here in this file
6851 // instead of having to edit some template or the code generator. 6873 // instead of having to edit some template or the code generator.
6852 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 6874 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
6853 6875
6854 } // namespace gles2 6876 } // namespace gles2
6855 } // namespace gpu 6877 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698