| OLD | NEW |
| 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 } | 320 } |
| 321 | 321 |
| 322 IdAllocator* GLES2Implementation::GetIdAllocator(int namespace_id) const { | 322 IdAllocator* GLES2Implementation::GetIdAllocator(int namespace_id) const { |
| 323 if (namespace_id == id_namespaces::kQueries) | 323 if (namespace_id == id_namespaces::kQueries) |
| 324 return query_id_allocator_.get(); | 324 return query_id_allocator_.get(); |
| 325 NOTREACHED(); | 325 NOTREACHED(); |
| 326 return NULL; | 326 return NULL; |
| 327 } | 327 } |
| 328 | 328 |
| 329 void GLES2Implementation::OnGpuControlLostContext() { | 329 void GLES2Implementation::OnGpuControlLostContext() { |
| 330 #if DCHECK_IS_ON() | |
| 331 // This should never occur more than once. | 330 // This should never occur more than once. |
| 332 DCHECK(!lost_context_); | 331 DCHECK(!lost_context_callback_run_); |
| 333 lost_context_ = true; | 332 lost_context_callback_run_ = true; |
| 334 #endif | 333 share_group_->Lose(); |
| 335 if (!lost_context_callback_.is_null()) | 334 if (!lost_context_callback_.is_null()) |
| 336 lost_context_callback_.Run(); | 335 lost_context_callback_.Run(); |
| 337 } | 336 } |
| 338 | 337 |
| 338 void GLES2Implementation::OnGpuControlLostContextMaybeReentrant() { |
| 339 // Queries for lost context state should immediately reflect reality, |
| 340 // but don't call out to clients yet to avoid them re-entering this |
| 341 // class. |
| 342 share_group_->Lose(); |
| 343 } |
| 344 |
| 339 void GLES2Implementation::OnGpuControlErrorMessage(const char* message, | 345 void GLES2Implementation::OnGpuControlErrorMessage(const char* message, |
| 340 int32_t id) { | 346 int32_t id) { |
| 341 if (!error_message_callback_.is_null()) | 347 if (!error_message_callback_.is_null()) |
| 342 error_message_callback_.Run(message, id); | 348 error_message_callback_.Run(message, id); |
| 343 } | 349 } |
| 344 | 350 |
| 345 void* GLES2Implementation::GetResultBuffer() { | 351 void* GLES2Implementation::GetResultBuffer() { |
| 346 return transfer_buffer_->GetResultBuffer(); | 352 return transfer_buffer_->GetResultBuffer(); |
| 347 } | 353 } |
| 348 | 354 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 360 | 366 |
| 361 void GLES2Implementation::FreeEverything() { | 367 void GLES2Implementation::FreeEverything() { |
| 362 WaitForCmd(); | 368 WaitForCmd(); |
| 363 query_tracker_->Shrink(); | 369 query_tracker_->Shrink(); |
| 364 FreeUnusedSharedMemory(); | 370 FreeUnusedSharedMemory(); |
| 365 transfer_buffer_->Free(); | 371 transfer_buffer_->Free(); |
| 366 helper_->FreeRingBuffer(); | 372 helper_->FreeRingBuffer(); |
| 367 } | 373 } |
| 368 | 374 |
| 369 void GLES2Implementation::RunIfContextNotLost(const base::Closure& callback) { | 375 void GLES2Implementation::RunIfContextNotLost(const base::Closure& callback) { |
| 370 if (!helper_->IsContextLost()) | 376 if (!lost_context_callback_run_) |
| 371 callback.Run(); | 377 callback.Run(); |
| 372 } | 378 } |
| 373 | 379 |
| 374 void GLES2Implementation::SignalSyncToken(const gpu::SyncToken& sync_token, | 380 void GLES2Implementation::SignalSyncToken(const gpu::SyncToken& sync_token, |
| 375 const base::Closure& callback) { | 381 const base::Closure& callback) { |
| 376 if (sync_token.HasData() && | 382 if (sync_token.HasData() && |
| 377 (sync_token.verified_flush() || | 383 (sync_token.verified_flush() || |
| 378 gpu_control_->CanWaitUnverifiedSyncToken(&sync_token))) { | 384 gpu_control_->CanWaitUnverifiedSyncToken(&sync_token))) { |
| 379 | 385 |
| 380 gpu::SyncToken intermediate_sync_token = sync_token; | 386 gpu::SyncToken intermediate_sync_token = sync_token; |
| (...skipping 4249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4630 for (int32_t i = 0; i < result->GetNumResults(); ++i) { | 4636 for (int32_t i = 0; i < result->GetNumResults(); ++i) { |
| 4631 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); | 4637 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); |
| 4632 } | 4638 } |
| 4633 }); | 4639 }); |
| 4634 CheckGLError(); | 4640 CheckGLError(); |
| 4635 } | 4641 } |
| 4636 | 4642 |
| 4637 GLenum GLES2Implementation::GetGraphicsResetStatusKHR() { | 4643 GLenum GLES2Implementation::GetGraphicsResetStatusKHR() { |
| 4638 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 4644 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 4639 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetGraphicsResetStatusKHR()"); | 4645 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetGraphicsResetStatusKHR()"); |
| 4640 // If we can't make command buffers then the context is lost. | 4646 // If any context (including ourselves) has seen itself become lost, |
| 4641 if (gpu_control_->IsGpuChannelLost()) | 4647 // then it will have told the ShareGroup, so just report its status. |
| 4648 if (share_group_->IsLost()) |
| 4642 return GL_UNKNOWN_CONTEXT_RESET_KHR; | 4649 return GL_UNKNOWN_CONTEXT_RESET_KHR; |
| 4643 // Otherwise, check the command buffer if it is lost. | |
| 4644 if (helper_->IsContextLost()) { | |
| 4645 // TODO(danakj): We could GetLastState() off the CommandBuffer and return | |
| 4646 // the actual reason here if we cared to. | |
| 4647 return GL_UNKNOWN_CONTEXT_RESET_KHR; | |
| 4648 } | |
| 4649 return GL_NO_ERROR; | 4650 return GL_NO_ERROR; |
| 4650 } | 4651 } |
| 4651 | 4652 |
| 4652 void GLES2Implementation::Swap() { | 4653 void GLES2Implementation::Swap() { |
| 4653 SwapBuffers(); | 4654 SwapBuffers(); |
| 4654 } | 4655 } |
| 4655 | 4656 |
| 4656 void GLES2Implementation::PartialSwapBuffers(const gfx::Rect& sub_buffer) { | 4657 void GLES2Implementation::PartialSwapBuffers(const gfx::Rect& sub_buffer) { |
| 4657 PostSubBufferCHROMIUM( | 4658 PostSubBufferCHROMIUM( |
| 4658 sub_buffer.x(), sub_buffer.y(), sub_buffer.width(), sub_buffer.height()); | 4659 sub_buffer.x(), sub_buffer.y(), sub_buffer.width(), sub_buffer.height()); |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5375 } | 5376 } |
| 5376 | 5377 |
| 5377 if (query_tracker_->BeginQuery(id, target, this)) | 5378 if (query_tracker_->BeginQuery(id, target, this)) |
| 5378 CheckGLError(); | 5379 CheckGLError(); |
| 5379 } | 5380 } |
| 5380 | 5381 |
| 5381 void GLES2Implementation::EndQueryEXT(GLenum target) { | 5382 void GLES2Implementation::EndQueryEXT(GLenum target) { |
| 5382 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 5383 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 5383 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] EndQueryEXT(" | 5384 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] EndQueryEXT(" |
| 5384 << GLES2Util::GetStringQueryTarget(target) << ")"); | 5385 << GLES2Util::GetStringQueryTarget(target) << ")"); |
| 5385 // Don't do anything if the context is lost. | |
| 5386 if (helper_->IsContextLost()) { | |
| 5387 return; | |
| 5388 } | |
| 5389 | |
| 5390 if (query_tracker_->EndQuery(target, this)) | 5386 if (query_tracker_->EndQuery(target, this)) |
| 5391 CheckGLError(); | 5387 CheckGLError(); |
| 5392 } | 5388 } |
| 5393 | 5389 |
| 5394 void GLES2Implementation::QueryCounterEXT(GLuint id, GLenum target) { | 5390 void GLES2Implementation::QueryCounterEXT(GLuint id, GLenum target) { |
| 5395 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 5391 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 5396 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] QueryCounterEXT(" | 5392 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] QueryCounterEXT(" |
| 5397 << id | 5393 << id |
| 5398 << ", " << GLES2Util::GetStringQueryTarget(target) << ")"); | 5394 << ", " << GLES2Util::GetStringQueryTarget(target) << ")"); |
| 5399 | 5395 |
| (...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6821 cached_extensions_.clear(); | 6817 cached_extensions_.clear(); |
| 6822 } | 6818 } |
| 6823 | 6819 |
| 6824 // Include the auto-generated part of this file. We split this because it means | 6820 // Include the auto-generated part of this file. We split this because it means |
| 6825 // we can easily edit the non-auto generated parts right here in this file | 6821 // we can easily edit the non-auto generated parts right here in this file |
| 6826 // instead of having to edit some template or the code generator. | 6822 // instead of having to edit some template or the code generator. |
| 6827 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 6823 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
| 6828 | 6824 |
| 6829 } // namespace gles2 | 6825 } // namespace gles2 |
| 6830 } // namespace gpu | 6826 } // namespace gpu |
| OLD | NEW |