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

Side by Side Diff: cc/resources/resource_provider.cc

Issue 1071273002: NotForReview: Implement zero/one-copy texture for ozone freon using Intel DRM Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "cc/resources/resource_provider.h" 5 #include "cc/resources/resource_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 DCHECK_EQ(RESOURCE_TYPE_BITMAP, resource->type); 694 DCHECK_EQ(RESOURCE_TYPE_BITMAP, resource->type);
695 delete resource->shared_bitmap; 695 delete resource->shared_bitmap;
696 resource->pixels = NULL; 696 resource->pixels = NULL;
697 } 697 }
698 if (resource->pixels) { 698 if (resource->pixels) {
699 DCHECK(resource->origin == Resource::INTERNAL); 699 DCHECK(resource->origin == Resource::INTERNAL);
700 delete[] resource->pixels; 700 delete[] resource->pixels;
701 resource->pixels = NULL; 701 resource->pixels = NULL;
702 } 702 }
703 if (resource->gpu_memory_buffer) { 703 if (resource->gpu_memory_buffer) {
704 // TODO(dshwang): It can fix glitch and crash bugs for Ozone GBM
705 // I guess the root reason is originated from kernel bug, but it
706 // demonstrates it's possible to workaround in chromium.
707 // ContextGL()->Finish();
dshwang 2015/04/09 19:12:26 This glFinish almost fix the glitch bug. So I try
704 DCHECK(resource->origin == Resource::INTERNAL); 708 DCHECK(resource->origin == Resource::INTERNAL);
705 delete resource->gpu_memory_buffer; 709 delete resource->gpu_memory_buffer;
706 resource->gpu_memory_buffer = NULL; 710 resource->gpu_memory_buffer = NULL;
707 } 711 }
708 resources_.erase(it); 712 resources_.erase(it);
709 } 713 }
710 714
711 ResourceProvider::ResourceType ResourceProvider::GetResourceType( 715 ResourceProvider::ResourceType ResourceProvider::GetResourceType(
712 ResourceId id) { 716 ResourceId id) {
713 return GetResource(id)->type; 717 return GetResource(id)->type;
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 ~ScopedWriteLockGpuMemoryBuffer() { 1074 ~ScopedWriteLockGpuMemoryBuffer() {
1071 DCHECK(thread_checker_.CalledOnValidThread()); 1075 DCHECK(thread_checker_.CalledOnValidThread());
1072 resource_provider_->UnlockForWrite(resource_); 1076 resource_provider_->UnlockForWrite(resource_);
1073 if (!gpu_memory_buffer_) 1077 if (!gpu_memory_buffer_)
1074 return; 1078 return;
1075 1079
1076 if (!resource_->image_id) { 1080 if (!resource_->image_id) {
1077 GLES2Interface* gl = resource_provider_->ContextGL(); 1081 GLES2Interface* gl = resource_provider_->ContextGL();
1078 DCHECK(gl); 1082 DCHECK(gl);
1079 1083
1080 #if defined(OS_CHROMEOS)
1081 // TODO(reveman): GL_COMMANDS_ISSUED_CHROMIUM is used for synchronization
1082 // on ChromeOS to avoid some performance issues. This only works with
1083 // shared memory backed buffers. crbug.com/436314
1084 DCHECK_EQ(gpu_memory_buffer_->GetHandle().type, gfx::SHARED_MEMORY_BUFFER);
1085 #endif
1086
1087 resource_->image_id = gl->CreateImageCHROMIUM( 1084 resource_->image_id = gl->CreateImageCHROMIUM(
1088 gpu_memory_buffer_->AsClientBuffer(), size_.width(), size_.height(), 1085 gpu_memory_buffer_->AsClientBuffer(), size_.width(), size_.height(),
1089 GLInternalFormat(resource_->format)); 1086 GLInternalFormat(resource_->format));
1090 } 1087 }
1091 1088
1092 std::swap(resource_->gpu_memory_buffer, gpu_memory_buffer_); 1089 std::swap(resource_->gpu_memory_buffer, gpu_memory_buffer_);
1093 resource_->allocated = true; 1090 resource_->allocated = true;
1094 resource_->dirty_image = true; 1091 resource_->dirty_image = true;
1095 1092
1096 // GpuMemoryBuffer provides direct access to the memory used by the GPU. 1093 // GpuMemoryBuffer provides direct access to the memory used by the GPU.
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
2059 GLES2Interface* gl = ContextGL(); 2056 GLES2Interface* gl = ContextGL();
2060 DCHECK(gl); 2057 DCHECK(gl);
2061 if (source_resource->image_id && source_resource->dirty_image) { 2058 if (source_resource->image_id && source_resource->dirty_image) {
2062 gl->BindTexture(source_resource->target, source_resource->gl_id); 2059 gl->BindTexture(source_resource->target, source_resource->gl_id);
2063 BindImageForSampling(source_resource); 2060 BindImageForSampling(source_resource);
2064 } 2061 }
2065 if (use_sync_query_) { 2062 if (use_sync_query_) {
2066 if (!source_resource->gl_read_lock_query_id) 2063 if (!source_resource->gl_read_lock_query_id)
2067 gl->GenQueriesEXT(1, &source_resource->gl_read_lock_query_id); 2064 gl->GenQueriesEXT(1, &source_resource->gl_read_lock_query_id);
2068 #if defined(OS_CHROMEOS) 2065 #if defined(OS_CHROMEOS)
2069 // TODO(reveman): This avoids a performance problem on some ChromeOS 2066 // TODO(reveman): GL_COMMANDS_ISSUED_CHROMIUM is used for synchronization
reveman 2015/04/13 00:46:13 We'll need to fix this TODO instead.
dshwang 2015/04/14 13:15:55 It's Exynos 5 workaround. Even if vgem one-copy is
2070 // devices. This needs to be removed to support native GpuMemoryBuffer 2067 // on ChromeOS to avoid some performance issues. This only works with
2071 // implementations. crbug.com/436314 2068 // shared memory backed buffers. crbug.com/436314
2072 gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, 2069 if (source_resource->gpu_memory_buffer->GetHandle().type ==
2073 source_resource->gl_read_lock_query_id); 2070 gfx::SHARED_MEMORY_BUFFER)
2074 #else 2071 gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM,
2072 source_resource->gl_read_lock_query_id);
2073 else
2074 #endif
2075 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, 2075 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM,
2076 source_resource->gl_read_lock_query_id); 2076 source_resource->gl_read_lock_query_id);
2077 #endif
2078 } 2077 }
2079 DCHECK(!dest_resource->image_id); 2078 DCHECK(!dest_resource->image_id);
2080 dest_resource->allocated = true; 2079 dest_resource->allocated = true;
2081 gl->CopySubTextureCHROMIUM(dest_resource->target, source_resource->gl_id, 2080 gl->CopySubTextureCHROMIUM(dest_resource->target, source_resource->gl_id,
2082 dest_resource->gl_id, 0, 0); 2081 dest_resource->gl_id, 0, 0);
2083 if (source_resource->gl_read_lock_query_id) { 2082 if (source_resource->gl_read_lock_query_id) {
2084 // End query and create a read lock fence that will prevent access to 2083 // End query and create a read lock fence that will prevent access to
2085 // source resource until CopySubTextureCHROMIUM command has completed. 2084 // source resource until CopySubTextureCHROMIUM command has completed.
2086 #if defined(OS_CHROMEOS) 2085 #if defined(OS_CHROMEOS)
2087 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); 2086 if (source_resource->gpu_memory_buffer->GetHandle().type ==
2088 #else 2087 gfx::SHARED_MEMORY_BUFFER)
2089 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); 2088 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM);
2089 else
2090 #endif 2090 #endif
2091 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM);
2091 source_resource->read_lock_fence = make_scoped_refptr( 2092 source_resource->read_lock_fence = make_scoped_refptr(
2092 new CopyTextureFence(gl, source_resource->gl_read_lock_query_id)); 2093 new CopyTextureFence(gl, source_resource->gl_read_lock_query_id));
2093 } else { 2094 } else {
2094 // Create a SynchronousFence when CHROMIUM_sync_query extension is missing. 2095 // Create a SynchronousFence when CHROMIUM_sync_query extension is missing.
2095 // Try to use one synchronous fence for as many CopyResource operations as 2096 // Try to use one synchronous fence for as many CopyResource operations as
2096 // possible as that reduce the number of times we have to synchronize with 2097 // possible as that reduce the number of times we have to synchronize with
2097 // the GL. 2098 // the GL.
2098 if (!synchronous_fence_.get() || synchronous_fence_->has_synchronized()) 2099 if (!synchronous_fence_.get() || synchronous_fence_->has_synchronized())
2099 synchronous_fence_ = make_scoped_refptr(new SynchronousFence(gl)); 2100 synchronous_fence_ = make_scoped_refptr(new SynchronousFence(gl));
2100 source_resource->read_lock_fence = synchronous_fence_; 2101 source_resource->read_lock_fence = synchronous_fence_;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 } 2146 }
2146 2147
2147 class GrContext* ResourceProvider::GrContext(bool worker_context) const { 2148 class GrContext* ResourceProvider::GrContext(bool worker_context) const {
2148 ContextProvider* context_provider = 2149 ContextProvider* context_provider =
2149 worker_context ? output_surface_->worker_context_provider() 2150 worker_context ? output_surface_->worker_context_provider()
2150 : output_surface_->context_provider(); 2151 : output_surface_->context_provider();
2151 return context_provider ? context_provider->GrContext() : NULL; 2152 return context_provider ? context_provider->GrContext() : NULL;
2152 } 2153 }
2153 2154
2154 } // namespace cc 2155 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698