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

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

Issue 962723002: Change CHROMIUM_image declarations to support multi planar input. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ImageFactory::CreateImageForGpuMemoryBuffer interface changes. Created 5 years, 9 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 <queue> 7 #include <queue>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 693
694 void InProcessCommandBuffer::DestroyTransferBufferOnGpuThread(int32 id) { 694 void InProcessCommandBuffer::DestroyTransferBufferOnGpuThread(int32 id) {
695 base::AutoLock lock(command_buffer_lock_); 695 base::AutoLock lock(command_buffer_lock_);
696 command_buffer_->DestroyTransferBuffer(id); 696 command_buffer_->DestroyTransferBuffer(id);
697 } 697 }
698 698
699 gpu::Capabilities InProcessCommandBuffer::GetCapabilities() { 699 gpu::Capabilities InProcessCommandBuffer::GetCapabilities() {
700 return capabilities_; 700 return capabilities_;
701 } 701 }
702 702
703 int32 InProcessCommandBuffer::CreateImage(ClientBuffer buffer, 703 int32 InProcessCommandBuffer::CreateImage(ClientBuffer* const buffers,
704 size_t width, 704 size_t width,
705 size_t height, 705 size_t height,
706 unsigned internalformat) { 706 unsigned internalformat) {
707 CheckSequencedThread(); 707 CheckSequencedThread();
708 708
709 DCHECK(gpu_memory_buffer_manager_); 709 DCHECK(gpu_memory_buffer_manager_);
710 gfx::GpuMemoryBuffer* gpu_memory_buffer =
711 gpu_memory_buffer_manager_->GpuMemoryBufferFromClientBuffer(buffer);
712 DCHECK(gpu_memory_buffer);
713
714 int32 new_id = next_image_id_.GetNext(); 710 int32 new_id = next_image_id_.GetNext();
715 711
716 DCHECK(gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( 712 int num_buffers =
717 internalformat, gpu_memory_buffer->GetFormat())); 713 gpu::ImageFactory::GpuMemoryBufferCountForImageFormat(internalformat);
718 714
719 // This handle is owned by the GPU thread and must be passed to it or it 715 gfx::GpuMemoryBuffer* gpu_memory_buffers[num_buffers];
720 // will leak. In otherwords, do not early out on error between here and the 716 std::vector<gfx::GpuMemoryBufferHandle> handles(num_buffers);
721 // queuing of the CreateImage task below. 717 std::vector<gfx::GpuMemoryBuffer::Format> formats(num_buffers);
722 bool requires_sync_point = false; 718 bool requires_sync_point[num_buffers];
723 gfx::GpuMemoryBufferHandle handle = 719 for (int i = 0; i < num_buffers; ++i) {
724 ShareGpuMemoryBufferToGpuThread(gpu_memory_buffer->GetHandle(), 720 gpu_memory_buffers[i] =
725 &requires_sync_point); 721 gpu_memory_buffer_manager_->GpuMemoryBufferFromClientBuffer(buffers[i]);
722 DCHECK(gpu_memory_buffers[i]);
723
724 formats[i] = gpu_memory_buffers[i]->GetFormat();
725 DCHECK(gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat(
726 internalformat, formats[i]));
727
728 requires_sync_point[i] = false;
729
730 // This handle is owned by the GPU thread and must be passed to it or it
731 // will leak. In otherwords, do not early out on error between here and the
732 // queuing of the CreateImage task below.
733 handles[i] = ShareGpuMemoryBufferToGpuThread(
734 gpu_memory_buffers[i]->GetHandle(), &requires_sync_point[i]);
735 }
726 736
727 QueueTask(base::Bind(&InProcessCommandBuffer::CreateImageOnGpuThread, 737 QueueTask(base::Bind(&InProcessCommandBuffer::CreateImageOnGpuThread,
728 base::Unretained(this), 738 base::Unretained(this),
729 new_id, 739 new_id,
730 handle, 740 handles,
731 gfx::Size(width, height), 741 gfx::Size(width, height),
732 gpu_memory_buffer->GetFormat(), 742 formats,
733 internalformat)); 743 internalformat));
734 744
735 if (requires_sync_point) { 745 for (int i = 0; i < num_buffers; ++i) {
736 gpu_memory_buffer_manager_->SetDestructionSyncPoint(gpu_memory_buffer, 746 if (requires_sync_point[i]) {
737 InsertSyncPoint()); 747 gpu_memory_buffer_manager_->SetDestructionSyncPoint(gpu_memory_buffers[i],
748 InsertSyncPoint());
749 }
738 } 750 }
739 751
740 return new_id; 752 return new_id;
741 } 753 }
742 754
743 void InProcessCommandBuffer::CreateImageOnGpuThread( 755 void InProcessCommandBuffer::CreateImageOnGpuThread(
744 int32 id, 756 int32 id,
745 const gfx::GpuMemoryBufferHandle& handle, 757 const std::vector<gfx::GpuMemoryBufferHandle>& handles,
746 const gfx::Size& size, 758 const gfx::Size& size,
747 gfx::GpuMemoryBuffer::Format format, 759 const std::vector<gfx::GpuMemoryBuffer::Format>& formats,
748 uint32 internalformat) { 760 uint32 internalformat) {
749 if (!decoder_) 761 if (!decoder_)
750 return; 762 return;
751 763
752 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); 764 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
753 DCHECK(image_manager); 765 DCHECK(image_manager);
754 if (image_manager->LookupImage(id)) { 766 if (image_manager->LookupImage(id)) {
755 LOG(ERROR) << "Image already exists with same ID."; 767 LOG(ERROR) << "Image already exists with same ID.";
756 return; 768 return;
757 } 769 }
758 770
759 // Note: this assumes that client ID is always 0. 771 // Note: this assumes that client ID is always 0.
760 const int kClientId = 0; 772 const int kClientId = 0;
761 773
762 DCHECK(image_factory_); 774 DCHECK(image_factory_);
763 scoped_refptr<gfx::GLImage> image = 775 scoped_refptr<gfx::GLImage> image =
764 image_factory_->CreateImageForGpuMemoryBuffer( 776 image_factory_->CreateImageForGpuMemoryBuffer(handles, size, formats,
765 handle, size, format, internalformat, kClientId); 777 internalformat, kClientId);
766 if (!image.get()) 778 if (!image.get())
767 return; 779 return;
768 780
769 image_manager->AddImage(image.get(), id); 781 image_manager->AddImage(image.get(), id);
770 } 782 }
771 783
772 void InProcessCommandBuffer::DestroyImage(int32 id) { 784 void InProcessCommandBuffer::DestroyImage(int32 id) {
773 CheckSequencedThread(); 785 CheckSequencedThread();
774 786
775 QueueTask(base::Bind(&InProcessCommandBuffer::DestroyImageOnGpuThread, 787 QueueTask(base::Bind(&InProcessCommandBuffer::DestroyImageOnGpuThread,
(...skipping 15 matching lines...) Expand all
791 image_manager->RemoveImage(id); 803 image_manager->RemoveImage(id);
792 } 804 }
793 805
794 int32 InProcessCommandBuffer::CreateGpuMemoryBufferImage( 806 int32 InProcessCommandBuffer::CreateGpuMemoryBufferImage(
795 size_t width, 807 size_t width,
796 size_t height, 808 size_t height,
797 unsigned internalformat, 809 unsigned internalformat,
798 unsigned usage) { 810 unsigned usage) {
799 CheckSequencedThread(); 811 CheckSequencedThread();
800 812
813 std::vector<gfx::GpuMemoryBuffer::Format> gpu_memory_buffer_formats;
814 gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormats(
815 internalformat, &gpu_memory_buffer_formats);
816 int num_buffers = gpu_memory_buffer_formats.size();
817
818 DCHECK_GE(num_buffers, 1);
801 DCHECK(gpu_memory_buffer_manager_); 819 DCHECK(gpu_memory_buffer_manager_);
802 scoped_ptr<gfx::GpuMemoryBuffer> buffer(
803 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer(
804 gfx::Size(width, height),
805 gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormat(internalformat),
806 gpu::ImageFactory::ImageUsageToGpuMemoryBufferUsage(usage)));
807 if (!buffer)
808 return -1;
809 820
810 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); 821 ScopedVector<gfx::GpuMemoryBuffer> buffers;
822 ClientBuffer client_buffers[num_buffers];
823 for (int i = 0; i < num_buffers; ++i) {
824 buffers.push_back(gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer(
825 gfx::Size(width, height), gpu_memory_buffer_formats[i],
826 gpu::ImageFactory::ImageUsageToGpuMemoryBufferUsage(usage)));
827
828 if (!buffers[i])
829 return -1;
830
831 client_buffers[i] = buffers[i]->AsClientBuffer();
832 }
833 return CreateImage(client_buffers, width, height, internalformat);
811 } 834 }
812 835
813 uint32 InProcessCommandBuffer::InsertSyncPoint() { 836 uint32 InProcessCommandBuffer::InsertSyncPoint() {
814 uint32 sync_point = g_sync_point_manager.Get().GenerateSyncPoint(); 837 uint32 sync_point = g_sync_point_manager.Get().GenerateSyncPoint();
815 QueueTask(base::Bind(&InProcessCommandBuffer::RetireSyncPointOnGpuThread, 838 QueueTask(base::Bind(&InProcessCommandBuffer::RetireSyncPointOnGpuThread,
816 base::Unretained(this), 839 base::Unretained(this),
817 sync_point)); 840 sync_point));
818 return sync_point; 841 return sync_point;
819 } 842 }
820 843
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 984
962 #if defined(OS_ANDROID) 985 #if defined(OS_ANDROID)
963 scoped_refptr<gfx::SurfaceTexture> 986 scoped_refptr<gfx::SurfaceTexture>
964 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { 987 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) {
965 DCHECK(stream_texture_manager_); 988 DCHECK(stream_texture_manager_);
966 return stream_texture_manager_->GetSurfaceTexture(stream_id); 989 return stream_texture_manager_->GetSurfaceTexture(stream_id);
967 } 990 }
968 #endif 991 #endif
969 992
970 } // namespace gpu 993 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698