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 #include "content/common/gpu/client/command_buffer_proxy_impl.h" | 5 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 | 409 |
410 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = | 410 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = |
411 channel_->gpu_memory_buffer_manager(); | 411 channel_->gpu_memory_buffer_manager(); |
412 gfx::GpuMemoryBuffer* gpu_memory_buffer = | 412 gfx::GpuMemoryBuffer* gpu_memory_buffer = |
413 gpu_memory_buffer_manager->GpuMemoryBufferFromClientBuffer(buffer); | 413 gpu_memory_buffer_manager->GpuMemoryBufferFromClientBuffer(buffer); |
414 DCHECK(gpu_memory_buffer); | 414 DCHECK(gpu_memory_buffer); |
415 | 415 |
416 // This handle is owned by the GPU process and must be passed to it or it | 416 // This handle is owned by the GPU process and must be passed to it or it |
417 // will leak. In otherwords, do not early out on error between here and the | 417 // will leak. In otherwords, do not early out on error between here and the |
418 // sending of the CreateImage IPC below. | 418 // sending of the CreateImage IPC below. |
419 bool requires_sync_point = false; | 419 bool requires_sync_token = false; |
420 gfx::GpuMemoryBufferHandle handle = | 420 gfx::GpuMemoryBufferHandle handle = |
421 channel_->ShareGpuMemoryBufferToGpuProcess(gpu_memory_buffer->GetHandle(), | 421 channel_->ShareGpuMemoryBufferToGpuProcess(gpu_memory_buffer->GetHandle(), |
422 &requires_sync_point); | 422 &requires_sync_token); |
423 | |
424 uint64_t image_fence_sync = 0; | |
425 if (requires_sync_token) { | |
426 image_fence_sync = GenerateFenceSyncRelease(); | |
427 | |
428 // Make sure fence syncs were flushed before CreateImage() was called. | |
429 DCHECK((image_fence_sync - 1) <= flushed_fence_sync_release_); | |
dcheng
2015/11/04 19:22:43
DCHECK_LE
David Yen
2015/11/04 19:47:39
Done.
| |
430 } | |
423 | 431 |
424 DCHECK(gpu::ImageFactory::IsGpuMemoryBufferFormatSupported( | 432 DCHECK(gpu::ImageFactory::IsGpuMemoryBufferFormatSupported( |
425 gpu_memory_buffer->GetFormat(), capabilities_)); | 433 gpu_memory_buffer->GetFormat(), capabilities_)); |
426 DCHECK(gpu::ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( | 434 DCHECK(gpu::ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( |
427 gfx::Size(width, height), gpu_memory_buffer->GetFormat())); | 435 gfx::Size(width, height), gpu_memory_buffer->GetFormat())); |
428 DCHECK(gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( | 436 DCHECK(gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( |
429 internalformat, gpu_memory_buffer->GetFormat())); | 437 internalformat, gpu_memory_buffer->GetFormat())); |
430 if (!Send(new GpuCommandBufferMsg_CreateImage(route_id_, | 438 |
431 new_id, | 439 GpuCommandBufferMsg_CreateImage_Params params; |
432 handle, | 440 params.id = new_id; |
433 gfx::Size(width, height), | 441 params.gpu_memory_buffer = handle; |
434 gpu_memory_buffer->GetFormat(), | 442 params.size = gfx::Size(width, height); |
435 internalformat))) { | 443 params.format = gpu_memory_buffer->GetFormat(); |
444 params.internalformat = internalformat; | |
445 params.image_release_count = image_fence_sync; | |
446 | |
447 if (!Send(new GpuCommandBufferMsg_CreateImage(route_id_, params))) | |
436 return -1; | 448 return -1; |
437 } | |
438 | 449 |
439 if (requires_sync_point) { | 450 if (image_fence_sync) { |
440 gpu_memory_buffer_manager->SetDestructionSyncPoint(gpu_memory_buffer, | 451 gpu::SyncToken sync_token(GetNamespaceID(), GetCommandBufferID(), |
441 InsertSyncPoint()); | 452 image_fence_sync); |
453 | |
454 // Force a synchronous IPC to validate sync token. | |
455 channel_->ValidateFlushIDReachedServer(stream_id_, true); | |
456 sync_token.SetVerifyFlush(); | |
457 | |
458 gpu_memory_buffer_manager->SetDestructionSyncToken(gpu_memory_buffer, | |
459 sync_token); | |
442 } | 460 } |
443 | 461 |
444 return new_id; | 462 return new_id; |
445 } | 463 } |
446 | 464 |
447 void CommandBufferProxyImpl::DestroyImage(int32 id) { | 465 void CommandBufferProxyImpl::DestroyImage(int32 id) { |
448 CheckLock(); | 466 CheckLock(); |
449 if (last_state_.error != gpu::error::kNoError) | 467 if (last_state_.error != gpu::error::kNoError) |
450 return; | 468 return; |
451 | 469 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
523 | 541 |
524 // Check if we have actually flushed the fence sync release. | 542 // Check if we have actually flushed the fence sync release. |
525 if (release <= flushed_fence_sync_release_) { | 543 if (release <= flushed_fence_sync_release_) { |
526 DCHECK(!flushed_release_flush_id_.empty()); | 544 DCHECK(!flushed_release_flush_id_.empty()); |
527 // Check if it has already been validated by another context. | 545 // Check if it has already been validated by another context. |
528 UpdateVerifiedReleases(channel_->GetHighestValidatedFlushID(stream_id_)); | 546 UpdateVerifiedReleases(channel_->GetHighestValidatedFlushID(stream_id_)); |
529 if (release <= verified_fence_sync_release_) | 547 if (release <= verified_fence_sync_release_) |
530 return true; | 548 return true; |
531 | 549 |
532 // Has not been validated, validate it now. | 550 // Has not been validated, validate it now. |
533 UpdateVerifiedReleases(channel_->ValidateFlushIDReachedServer(stream_id_)); | 551 UpdateVerifiedReleases( |
552 channel_->ValidateFlushIDReachedServer(stream_id_, false)); | |
534 return release <= verified_fence_sync_release_; | 553 return release <= verified_fence_sync_release_; |
535 } | 554 } |
536 | 555 |
537 return false; | 556 return false; |
538 } | 557 } |
539 | 558 |
540 void CommandBufferProxyImpl::SignalSyncToken(const gpu::SyncToken& sync_token, | 559 void CommandBufferProxyImpl::SignalSyncToken(const gpu::SyncToken& sync_token, |
541 const base::Closure& callback) { | 560 const base::Closure& callback) { |
542 CheckLock(); | 561 CheckLock(); |
543 if (last_state_.error != gpu::error::kNoError) | 562 if (last_state_.error != gpu::error::kNoError) |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
738 } | 757 } |
739 } | 758 } |
740 | 759 |
741 void CommandBufferProxyImpl::OnUpdateVSyncParameters(base::TimeTicks timebase, | 760 void CommandBufferProxyImpl::OnUpdateVSyncParameters(base::TimeTicks timebase, |
742 base::TimeDelta interval) { | 761 base::TimeDelta interval) { |
743 if (!update_vsync_parameters_completion_callback_.is_null()) | 762 if (!update_vsync_parameters_completion_callback_.is_null()) |
744 update_vsync_parameters_completion_callback_.Run(timebase, interval); | 763 update_vsync_parameters_completion_callback_.Run(timebase, interval); |
745 } | 764 } |
746 | 765 |
747 } // namespace content | 766 } // namespace content |
OLD | NEW |