OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "gpu/command_buffer/service/in_process_command_buffer.h" | 5 #include "gpu/command_buffer/service/in_process_command_buffer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <queue> | 10 #include <queue> |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 gpu_memory_buffer_manager_->GpuMemoryBufferFromClientBuffer(buffer); | 677 gpu_memory_buffer_manager_->GpuMemoryBufferFromClientBuffer(buffer); |
678 DCHECK(gpu_memory_buffer); | 678 DCHECK(gpu_memory_buffer); |
679 | 679 |
680 int32_t new_id = next_image_id_.GetNext(); | 680 int32_t new_id = next_image_id_.GetNext(); |
681 | 681 |
682 DCHECK(gpu::IsGpuMemoryBufferFormatSupported(gpu_memory_buffer->GetFormat(), | 682 DCHECK(gpu::IsGpuMemoryBufferFormatSupported(gpu_memory_buffer->GetFormat(), |
683 capabilities_)); | 683 capabilities_)); |
684 DCHECK(gpu::IsImageFormatCompatibleWithGpuMemoryBufferFormat( | 684 DCHECK(gpu::IsImageFormatCompatibleWithGpuMemoryBufferFormat( |
685 internalformat, gpu_memory_buffer->GetFormat())); | 685 internalformat, gpu_memory_buffer->GetFormat())); |
686 | 686 |
687 DCHECK(image_gmb_ids_map_.find(new_id) == image_gmb_ids_map_.end()); | |
688 image_gmb_ids_map_[new_id] = gpu_memory_buffer->GetId().id; | |
689 | |
690 // This handle is owned by the GPU thread and must be passed to it or it | 687 // This handle is owned by the GPU thread and must be passed to it or it |
691 // will leak. In otherwords, do not early out on error between here and the | 688 // will leak. In otherwords, do not early out on error between here and the |
692 // queuing of the CreateImage task below. | 689 // queuing of the CreateImage task below. |
693 bool requires_sync_point = false; | 690 bool requires_sync_point = false; |
694 gfx::GpuMemoryBufferHandle handle = | 691 gfx::GpuMemoryBufferHandle handle = |
695 ShareGpuMemoryBufferToGpuThread(gpu_memory_buffer->GetHandle(), | 692 ShareGpuMemoryBufferToGpuThread(gpu_memory_buffer->GetHandle(), |
696 &requires_sync_point); | 693 &requires_sync_point); |
697 | 694 |
698 SyncPointManager* sync_manager = service_->sync_point_manager(); | 695 SyncPointManager* sync_manager = service_->sync_point_manager(); |
699 const uint32_t order_num = | 696 const uint32_t order_num = |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 } | 781 } |
785 | 782 |
786 if (fence_sync) { | 783 if (fence_sync) { |
787 sync_point_client_->ReleaseFenceSync(fence_sync); | 784 sync_point_client_->ReleaseFenceSync(fence_sync); |
788 } | 785 } |
789 } | 786 } |
790 | 787 |
791 void InProcessCommandBuffer::DestroyImage(int32_t id) { | 788 void InProcessCommandBuffer::DestroyImage(int32_t id) { |
792 CheckSequencedThread(); | 789 CheckSequencedThread(); |
793 | 790 |
794 auto it = image_gmb_ids_map_.find(id); | |
795 if (it != image_gmb_ids_map_.end()) | |
796 image_gmb_ids_map_.erase(it); | |
797 | |
798 QueueTask(base::Bind(&InProcessCommandBuffer::DestroyImageOnGpuThread, | 791 QueueTask(base::Bind(&InProcessCommandBuffer::DestroyImageOnGpuThread, |
799 base::Unretained(this), | 792 base::Unretained(this), |
800 id)); | 793 id)); |
801 } | 794 } |
802 | 795 |
803 void InProcessCommandBuffer::DestroyImageOnGpuThread(int32_t id) { | 796 void InProcessCommandBuffer::DestroyImageOnGpuThread(int32_t id) { |
804 if (!decoder_) | 797 if (!decoder_) |
805 return; | 798 return; |
806 | 799 |
807 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); | 800 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); |
(...skipping 18 matching lines...) Expand all Loading... |
826 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( | 819 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( |
827 gfx::Size(width, height), | 820 gfx::Size(width, height), |
828 gpu::DefaultBufferFormatForImageFormat(internalformat), | 821 gpu::DefaultBufferFormatForImageFormat(internalformat), |
829 gfx::BufferUsage::SCANOUT, gpu::kNullSurfaceHandle)); | 822 gfx::BufferUsage::SCANOUT, gpu::kNullSurfaceHandle)); |
830 if (!buffer) | 823 if (!buffer) |
831 return -1; | 824 return -1; |
832 | 825 |
833 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); | 826 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); |
834 } | 827 } |
835 | 828 |
836 int32_t InProcessCommandBuffer::GetImageGpuMemoryBufferId(unsigned image_id) { | |
837 CheckSequencedThread(); | |
838 auto it = image_gmb_ids_map_.find(image_id); | |
839 if (it != image_gmb_ids_map_.end()) | |
840 return it->second; | |
841 return -1; | |
842 } | |
843 | |
844 void InProcessCommandBuffer::FenceSyncReleaseOnGpuThread(uint64_t release) { | 829 void InProcessCommandBuffer::FenceSyncReleaseOnGpuThread(uint64_t release) { |
845 DCHECK(!sync_point_client_->client_state()->IsFenceSyncReleased(release)); | 830 DCHECK(!sync_point_client_->client_state()->IsFenceSyncReleased(release)); |
846 gles2::MailboxManager* mailbox_manager = | 831 gles2::MailboxManager* mailbox_manager = |
847 decoder_->GetContextGroup()->mailbox_manager(); | 832 decoder_->GetContextGroup()->mailbox_manager(); |
848 if (mailbox_manager->UsesSync()) { | 833 if (mailbox_manager->UsesSync()) { |
849 SyncToken sync_token(GetNamespaceID(), GetExtraCommandBufferData(), | 834 SyncToken sync_token(GetNamespaceID(), GetExtraCommandBufferData(), |
850 GetCommandBufferID(), release); | 835 GetCommandBufferID(), release); |
851 mailbox_manager->PushTextureUpdates(sync_token); | 836 mailbox_manager->PushTextureUpdates(sync_token); |
852 } | 837 } |
853 | 838 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 framebuffer_completeness_cache_ = | 1054 framebuffer_completeness_cache_ = |
1070 new gpu::gles2::FramebufferCompletenessCache; | 1055 new gpu::gles2::FramebufferCompletenessCache; |
1071 return framebuffer_completeness_cache_; | 1056 return framebuffer_completeness_cache_; |
1072 } | 1057 } |
1073 | 1058 |
1074 SyncPointManager* GpuInProcessThread::sync_point_manager() { | 1059 SyncPointManager* GpuInProcessThread::sync_point_manager() { |
1075 return sync_point_manager_; | 1060 return sync_point_manager_; |
1076 } | 1061 } |
1077 | 1062 |
1078 } // namespace gpu | 1063 } // namespace gpu |
OLD | NEW |