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

Side by Side Diff: gpu/command_buffer/service/in_process_command_buffer.cc

Issue 1974163003: Expose GpuMemoryBufferId through glGetImageivCHROMIUM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test. Created 4 years, 6 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 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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 gpu_memory_buffer_manager_->GpuMemoryBufferFromClientBuffer(buffer); 675 gpu_memory_buffer_manager_->GpuMemoryBufferFromClientBuffer(buffer);
676 DCHECK(gpu_memory_buffer); 676 DCHECK(gpu_memory_buffer);
677 677
678 int32_t new_id = next_image_id_.GetNext(); 678 int32_t new_id = next_image_id_.GetNext();
679 679
680 DCHECK(gpu::IsGpuMemoryBufferFormatSupported(gpu_memory_buffer->GetFormat(), 680 DCHECK(gpu::IsGpuMemoryBufferFormatSupported(gpu_memory_buffer->GetFormat(),
681 capabilities_)); 681 capabilities_));
682 DCHECK(gpu::IsImageFormatCompatibleWithGpuMemoryBufferFormat( 682 DCHECK(gpu::IsImageFormatCompatibleWithGpuMemoryBufferFormat(
683 internalformat, gpu_memory_buffer->GetFormat())); 683 internalformat, gpu_memory_buffer->GetFormat()));
684 684
685 DCHECK(image_gmb_ids_map_.find(new_id) == image_gmb_ids_map_.end());
686 image_gmb_ids_map_[new_id] = gpu_memory_buffer->GetId().id;
687
685 // This handle is owned by the GPU thread and must be passed to it or it 688 // This handle is owned by the GPU thread and must be passed to it or it
686 // will leak. In otherwords, do not early out on error between here and the 689 // will leak. In otherwords, do not early out on error between here and the
687 // queuing of the CreateImage task below. 690 // queuing of the CreateImage task below.
688 bool requires_sync_point = false; 691 bool requires_sync_point = false;
689 gfx::GpuMemoryBufferHandle handle = 692 gfx::GpuMemoryBufferHandle handle =
690 ShareGpuMemoryBufferToGpuThread(gpu_memory_buffer->GetHandle(), 693 ShareGpuMemoryBufferToGpuThread(gpu_memory_buffer->GetHandle(),
691 &requires_sync_point); 694 &requires_sync_point);
692 695
693 SyncPointManager* sync_manager = service_->sync_point_manager(); 696 SyncPointManager* sync_manager = service_->sync_point_manager();
694 const uint32_t order_num = 697 const uint32_t order_num =
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 } 782 }
780 783
781 if (fence_sync) { 784 if (fence_sync) {
782 sync_point_client_->ReleaseFenceSync(fence_sync); 785 sync_point_client_->ReleaseFenceSync(fence_sync);
783 } 786 }
784 } 787 }
785 788
786 void InProcessCommandBuffer::DestroyImage(int32_t id) { 789 void InProcessCommandBuffer::DestroyImage(int32_t id) {
787 CheckSequencedThread(); 790 CheckSequencedThread();
788 791
792 auto it = image_gmb_ids_map_.find(id);
793 if (it != image_gmb_ids_map_.end())
794 image_gmb_ids_map_.erase(it);
795
789 QueueTask(base::Bind(&InProcessCommandBuffer::DestroyImageOnGpuThread, 796 QueueTask(base::Bind(&InProcessCommandBuffer::DestroyImageOnGpuThread,
790 base::Unretained(this), 797 base::Unretained(this),
791 id)); 798 id));
792 } 799 }
793 800
794 void InProcessCommandBuffer::DestroyImageOnGpuThread(int32_t id) { 801 void InProcessCommandBuffer::DestroyImageOnGpuThread(int32_t id) {
795 if (!decoder_) 802 if (!decoder_)
796 return; 803 return;
797 804
798 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); 805 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
(...skipping 18 matching lines...) Expand all
817 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( 824 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer(
818 gfx::Size(width, height), 825 gfx::Size(width, height),
819 gpu::DefaultBufferFormatForImageFormat(internalformat), 826 gpu::DefaultBufferFormatForImageFormat(internalformat),
820 gfx::BufferUsage::SCANOUT, gpu::kNullSurfaceHandle)); 827 gfx::BufferUsage::SCANOUT, gpu::kNullSurfaceHandle));
821 if (!buffer) 828 if (!buffer)
822 return -1; 829 return -1;
823 830
824 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); 831 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat);
825 } 832 }
826 833
834 int32_t InProcessCommandBuffer::GetImageGpuMemoryBufferId(unsigned image_id) {
835 CheckSequencedThread();
836 auto it = image_gmb_ids_map_.find(image_id);
837 if (it != image_gmb_ids_map_.end())
838 return it->second;
839 return -1;
840 }
841
827 void InProcessCommandBuffer::FenceSyncReleaseOnGpuThread(uint64_t release) { 842 void InProcessCommandBuffer::FenceSyncReleaseOnGpuThread(uint64_t release) {
828 DCHECK(!sync_point_client_->client_state()->IsFenceSyncReleased(release)); 843 DCHECK(!sync_point_client_->client_state()->IsFenceSyncReleased(release));
829 gles2::MailboxManager* mailbox_manager = 844 gles2::MailboxManager* mailbox_manager =
830 decoder_->GetContextGroup()->mailbox_manager(); 845 decoder_->GetContextGroup()->mailbox_manager();
831 if (mailbox_manager->UsesSync()) { 846 if (mailbox_manager->UsesSync()) {
832 SyncToken sync_token(GetNamespaceID(), GetExtraCommandBufferData(), 847 SyncToken sync_token(GetNamespaceID(), GetExtraCommandBufferData(),
833 GetCommandBufferID(), release); 848 GetCommandBufferID(), release);
834 mailbox_manager->PushTextureUpdates(sync_token); 849 mailbox_manager->PushTextureUpdates(sync_token);
835 } 850 }
836 851
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 framebuffer_completeness_cache_ = 1059 framebuffer_completeness_cache_ =
1045 new gpu::gles2::FramebufferCompletenessCache; 1060 new gpu::gles2::FramebufferCompletenessCache;
1046 return framebuffer_completeness_cache_; 1061 return framebuffer_completeness_cache_;
1047 } 1062 }
1048 1063
1049 SyncPointManager* GpuInProcessThread::sync_point_manager() { 1064 SyncPointManager* GpuInProcessThread::sync_point_manager() {
1050 return sync_point_manager_; 1065 return sync_point_manager_;
1051 } 1066 }
1052 1067
1053 } // namespace gpu 1068 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/in_process_command_buffer.h ('k') | gpu/command_buffer/tests/gl_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698