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

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

Issue 1885903002: Revert of 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: 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),
164 current_trace_stack_(0), 165 current_trace_stack_(0),
165 gpu_control_(gpu_control), 166 gpu_control_(gpu_control),
166 capabilities_(gpu_control->GetCapabilities()), 167 capabilities_(gpu_control->GetCapabilities()),
167 aggressively_free_resources_(false), 168 aggressively_free_resources_(false),
168 cached_extension_string_(nullptr), 169 cached_extension_string_(nullptr),
169 weak_ptr_factory_(this) { 170 weak_ptr_factory_(this) {
170 DCHECK(helper); 171 DCHECK(helper);
171 DCHECK(transfer_buffer); 172 DCHECK(transfer_buffer);
172 DCHECK(gpu_control); 173 DCHECK(gpu_control);
173 174
(...skipping 19 matching lines...) Expand all
193 bool GLES2Implementation::Initialize( 194 bool GLES2Implementation::Initialize(
194 unsigned int starting_transfer_buffer_size, 195 unsigned int starting_transfer_buffer_size,
195 unsigned int min_transfer_buffer_size, 196 unsigned int min_transfer_buffer_size,
196 unsigned int max_transfer_buffer_size, 197 unsigned int max_transfer_buffer_size,
197 unsigned int mapped_memory_limit) { 198 unsigned int mapped_memory_limit) {
198 TRACE_EVENT0("gpu", "GLES2Implementation::Initialize"); 199 TRACE_EVENT0("gpu", "GLES2Implementation::Initialize");
199 DCHECK_GE(starting_transfer_buffer_size, min_transfer_buffer_size); 200 DCHECK_GE(starting_transfer_buffer_size, min_transfer_buffer_size);
200 DCHECK_LE(starting_transfer_buffer_size, max_transfer_buffer_size); 201 DCHECK_LE(starting_transfer_buffer_size, max_transfer_buffer_size);
201 DCHECK_GE(min_transfer_buffer_size, kStartingOffset); 202 DCHECK_GE(min_transfer_buffer_size, kStartingOffset);
202 203
203 gpu_control_->SetGpuControlClient(this);
204
205 if (!transfer_buffer_->Initialize( 204 if (!transfer_buffer_->Initialize(
206 starting_transfer_buffer_size, 205 starting_transfer_buffer_size,
207 kStartingOffset, 206 kStartingOffset,
208 min_transfer_buffer_size, 207 min_transfer_buffer_size,
209 max_transfer_buffer_size, 208 max_transfer_buffer_size,
210 kAlignment, 209 kAlignment,
211 kSizeToFlush)) { 210 kSizeToFlush)) {
212 return false; 211 return false;
213 } 212 }
214 213
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 // called but not the UnmapBuffer() pair. 292 // called but not the UnmapBuffer() pair.
294 ClearMappedBufferRangeMap(); 293 ClearMappedBufferRangeMap();
295 294
296 // Release any per-context data in share group. 295 // Release any per-context data in share group.
297 share_group_->FreeContext(this); 296 share_group_->FreeContext(this);
298 297
299 buffer_tracker_.reset(); 298 buffer_tracker_.reset();
300 299
301 // Make sure the commands make it the service. 300 // Make sure the commands make it the service.
302 WaitForCmd(); 301 WaitForCmd();
303
304 // The gpu_control_ outlives this class, so clear the client on it before we
305 // self-destruct.
306 gpu_control_->SetGpuControlClient(nullptr);
307 } 302 }
308 303
309 GLES2CmdHelper* GLES2Implementation::helper() const { 304 GLES2CmdHelper* GLES2Implementation::helper() const {
310 return helper_; 305 return helper_;
311 } 306 }
312 307
313 IdHandlerInterface* GLES2Implementation::GetIdHandler(int namespace_id) const { 308 IdHandlerInterface* GLES2Implementation::GetIdHandler(int namespace_id) const {
314 return share_group_->GetIdHandler(namespace_id); 309 return share_group_->GetIdHandler(namespace_id);
315 } 310 }
316 311
317 RangeIdHandlerInterface* GLES2Implementation::GetRangeIdHandler( 312 RangeIdHandlerInterface* GLES2Implementation::GetRangeIdHandler(
318 int namespace_id) const { 313 int namespace_id) const {
319 return share_group_->GetRangeIdHandler(namespace_id); 314 return share_group_->GetRangeIdHandler(namespace_id);
320 } 315 }
321 316
322 IdAllocator* GLES2Implementation::GetIdAllocator(int namespace_id) const { 317 IdAllocator* GLES2Implementation::GetIdAllocator(int namespace_id) const {
323 if (namespace_id == id_namespaces::kQueries) 318 if (namespace_id == id_namespaces::kQueries)
324 return query_id_allocator_.get(); 319 return query_id_allocator_.get();
325 NOTREACHED(); 320 NOTREACHED();
326 return NULL; 321 return NULL;
327 } 322 }
328 323
329 void GLES2Implementation::OnGpuControlLostContext() {
330 #if DCHECK_IS_ON()
331 // This should never occur more than once.
332 DCHECK(!lost_context_);
333 lost_context_ = true;
334 #endif
335 if (!lost_context_callback_.is_null())
336 lost_context_callback_.Run();
337 }
338
339 void GLES2Implementation::OnGpuControlErrorMessage(const char* message,
340 int32_t id) {
341 if (!error_message_callback_.is_null())
342 error_message_callback_.Run(message, id);
343 }
344
345 void* GLES2Implementation::GetResultBuffer() { 324 void* GLES2Implementation::GetResultBuffer() {
346 return transfer_buffer_->GetResultBuffer(); 325 return transfer_buffer_->GetResultBuffer();
347 } 326 }
348 327
349 int32_t GLES2Implementation::GetResultShmId() { 328 int32_t GLES2Implementation::GetResultShmId() {
350 return transfer_buffer_->GetShmId(); 329 return transfer_buffer_->GetShmId();
351 } 330 }
352 331
353 uint32_t GLES2Implementation::GetResultShmOffset() { 332 uint32_t GLES2Implementation::GetResultShmOffset() {
354 return transfer_buffer_->GetResultOffset(); 333 return transfer_buffer_->GetResultOffset();
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 542
564 void GLES2Implementation::SetGLError( 543 void GLES2Implementation::SetGLError(
565 GLenum error, const char* function_name, const char* msg) { 544 GLenum error, const char* function_name, const char* msg) {
566 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] Client Synthesized Error: " 545 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] Client Synthesized Error: "
567 << GLES2Util::GetStringError(error) << ": " 546 << GLES2Util::GetStringError(error) << ": "
568 << function_name << ": " << msg); 547 << function_name << ": " << msg);
569 FailGLError(error); 548 FailGLError(error);
570 if (msg) { 549 if (msg) {
571 last_error_ = msg; 550 last_error_ = msg;
572 } 551 }
573 if (!error_message_callback_.is_null()) { 552 if (error_message_callback_) {
574 std::string temp(GLES2Util::GetStringError(error) + " : " + 553 std::string temp(GLES2Util::GetStringError(error) + " : " +
575 function_name + ": " + (msg ? msg : "")); 554 function_name + ": " + (msg ? msg : ""));
576 error_message_callback_.Run(temp.c_str(), 0); 555 error_message_callback_->OnErrorMessage(temp.c_str(), 0);
577 } 556 }
578 error_bits_ |= GLES2Util::GLErrorToErrorBit(error); 557 error_bits_ |= GLES2Util::GLErrorToErrorBit(error);
579 558
580 if (error == GL_OUT_OF_MEMORY && lose_context_when_out_of_memory_) { 559 if (error == GL_OUT_OF_MEMORY && lose_context_when_out_of_memory_) {
581 helper_->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, 560 helper_->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
582 GL_UNKNOWN_CONTEXT_RESET_ARB); 561 GL_UNKNOWN_CONTEXT_RESET_ARB);
583 } 562 }
584 } 563 }
585 564
586 void GLES2Implementation::SetGLErrorInvalidEnum( 565 void GLES2Implementation::SetGLErrorInvalidEnum(
(...skipping 5245 matching lines...) Expand 10 before | Expand all | Expand 10 after
5832 } 5811 }
5833 buffer->set_mapped(false); 5812 buffer->set_mapped(false);
5834 CheckGLError(); 5813 CheckGLError();
5835 return true; 5814 return true;
5836 } 5815 }
5837 5816
5838 uint64_t GLES2Implementation::ShareGroupTracingGUID() const { 5817 uint64_t GLES2Implementation::ShareGroupTracingGUID() const {
5839 return share_group_->TracingGUID(); 5818 return share_group_->TracingGUID();
5840 } 5819 }
5841 5820
5842 void GLES2Implementation::SetErrorMessageCallback(
5843 const base::Callback<void(const char*, int32_t)>& callback) {
5844 error_message_callback_ = callback;
5845 }
5846
5847 void GLES2Implementation::SetLostContextCallback(
5848 const base::Closure& callback) {
5849 lost_context_callback_ = callback;
5850 }
5851
5852 GLuint64 GLES2Implementation::InsertFenceSyncCHROMIUM() { 5821 GLuint64 GLES2Implementation::InsertFenceSyncCHROMIUM() {
5853 const uint64_t release = gpu_control_->GenerateFenceSyncRelease(); 5822 const uint64_t release = gpu_control_->GenerateFenceSyncRelease();
5854 helper_->InsertFenceSyncCHROMIUM(release); 5823 helper_->InsertFenceSyncCHROMIUM(release);
5855 return release; 5824 return release;
5856 } 5825 }
5857 5826
5858 void GLES2Implementation::GenSyncTokenCHROMIUM(GLuint64 fence_sync, 5827 void GLES2Implementation::GenSyncTokenCHROMIUM(GLuint64 fence_sync,
5859 GLbyte* sync_token) { 5828 GLbyte* sync_token) {
5860 if (!sync_token) { 5829 if (!sync_token) {
5861 SetGLError(GL_INVALID_VALUE, "glGenSyncTokenCHROMIUM", "empty sync_token"); 5830 SetGLError(GL_INVALID_VALUE, "glGenSyncTokenCHROMIUM", "empty sync_token");
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
6877 cached_extensions_.clear(); 6846 cached_extensions_.clear();
6878 } 6847 }
6879 6848
6880 // Include the auto-generated part of this file. We split this because it means 6849 // Include the auto-generated part of this file. We split this because it means
6881 // we can easily edit the non-auto generated parts right here in this file 6850 // we can easily edit the non-auto generated parts right here in this file
6882 // instead of having to edit some template or the code generator. 6851 // instead of having to edit some template or the code generator.
6883 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 6852 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
6884 6853
6885 } // namespace gles2 6854 } // namespace gles2
6886 } // namespace gpu 6855 } // 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