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

Side by Side Diff: cc/raster/gpu_raster_buffer_provider.cc

Issue 2440093003: WIP GPU scheduler + delayed activation / tile draw
Patch Set: SignalSyncToken -> IsFenceSyncReleased Created 4 years 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
« no previous file with comments | « cc/raster/gpu_raster_buffer_provider.h ('k') | cc/raster/one_copy_raster_buffer_provider.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/raster/gpu_raster_buffer_provider.h" 5 #include "cc/raster/gpu_raster_buffer_provider.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
15 #include "cc/base/histograms.h" 15 #include "cc/base/histograms.h"
16 #include "cc/playback/image_hijack_canvas.h" 16 #include "cc/playback/image_hijack_canvas.h"
17 #include "cc/playback/raster_source.h" 17 #include "cc/playback/raster_source.h"
18 #include "cc/raster/scoped_gpu_raster.h" 18 #include "cc/raster/scoped_gpu_raster.h"
19 #include "cc/resources/resource.h" 19 #include "cc/resources/resource.h"
20 #include "gpu/command_buffer/client/context_support.h"
20 #include "gpu/command_buffer/client/gles2_interface.h" 21 #include "gpu/command_buffer/client/gles2_interface.h"
21 #include "third_party/skia/include/core/SkMultiPictureDraw.h" 22 #include "third_party/skia/include/core/SkMultiPictureDraw.h"
22 #include "third_party/skia/include/core/SkPictureRecorder.h" 23 #include "third_party/skia/include/core/SkPictureRecorder.h"
23 #include "third_party/skia/include/core/SkSurface.h" 24 #include "third_party/skia/include/core/SkSurface.h"
24 #include "third_party/skia/include/gpu/GrContext.h" 25 #include "third_party/skia/include/gpu/GrContext.h"
25 26
26 namespace cc { 27 namespace cc {
27 namespace { 28 namespace {
28 29
29 static sk_sp<SkPicture> PlaybackToPicture( 30 static sk_sp<SkPicture> PlaybackToPicture(
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 multi_picture_draw.add(canvas, picture); 125 multi_picture_draw.add(canvas, picture);
125 multi_picture_draw.draw(false); 126 multi_picture_draw.draw(false);
126 } 127 }
127 128
128 } // namespace 129 } // namespace
129 130
130 GpuRasterBufferProvider::RasterBufferImpl::RasterBufferImpl( 131 GpuRasterBufferProvider::RasterBufferImpl::RasterBufferImpl(
131 GpuRasterBufferProvider* client, 132 GpuRasterBufferProvider* client,
132 ResourceProvider* resource_provider, 133 ResourceProvider* resource_provider,
133 ResourceId resource_id, 134 ResourceId resource_id,
134 bool async_worker_context_enabled,
135 bool resource_has_previous_content) 135 bool resource_has_previous_content)
136 : client_(client), 136 : client_(client),
137 lock_(resource_provider, resource_id, async_worker_context_enabled), 137 lock_(resource_provider, resource_id, true),
138 resource_has_previous_content_(resource_has_previous_content) { 138 resource_has_previous_content_(resource_has_previous_content) {
139 client_->pending_raster_buffers_.insert(this); 139 client_->pending_raster_buffers_.insert(this);
140 } 140 }
141 141
142 GpuRasterBufferProvider::RasterBufferImpl::~RasterBufferImpl() { 142 GpuRasterBufferProvider::RasterBufferImpl::~RasterBufferImpl() {
143 client_->pending_raster_buffers_.erase(this); 143 client_->pending_raster_buffers_.erase(this);
144 } 144 }
145 145
146 void GpuRasterBufferProvider::RasterBufferImpl::Playback( 146 void GpuRasterBufferProvider::RasterBufferImpl::Playback(
147 const RasterSource* raster_source, 147 const RasterSource* raster_source,
(...skipping 30 matching lines...) Expand all
178 DCHECK(pending_raster_buffers_.empty()); 178 DCHECK(pending_raster_buffers_.empty());
179 } 179 }
180 180
181 std::unique_ptr<RasterBuffer> GpuRasterBufferProvider::AcquireBufferForRaster( 181 std::unique_ptr<RasterBuffer> GpuRasterBufferProvider::AcquireBufferForRaster(
182 const Resource* resource, 182 const Resource* resource,
183 uint64_t resource_content_id, 183 uint64_t resource_content_id,
184 uint64_t previous_content_id) { 184 uint64_t previous_content_id) {
185 bool resource_has_previous_content = 185 bool resource_has_previous_content =
186 resource_content_id && resource_content_id == previous_content_id; 186 resource_content_id && resource_content_id == previous_content_id;
187 return base::MakeUnique<RasterBufferImpl>( 187 return base::MakeUnique<RasterBufferImpl>(
188 this, resource_provider_, resource->id(), async_worker_context_enabled_, 188 this, resource_provider_, resource->id(), resource_has_previous_content);
189 resource_has_previous_content);
190 } 189 }
191 190
192 void GpuRasterBufferProvider::ReleaseBufferForRaster( 191 void GpuRasterBufferProvider::ReleaseBufferForRaster(
193 std::unique_ptr<RasterBuffer> buffer) { 192 std::unique_ptr<RasterBuffer> buffer) {
194 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. 193 // Nothing to do here. RasterBufferImpl destructor cleans up after itself.
195 } 194 }
196 195
197 void GpuRasterBufferProvider::OrderingBarrier() { 196 void GpuRasterBufferProvider::OrderingBarrier() {
198 TRACE_EVENT0("cc", "GpuRasterBufferProvider::OrderingBarrier"); 197 TRACE_EVENT0("cc", "GpuRasterBufferProvider::OrderingBarrier");
199 198
200 gpu::gles2::GLES2Interface* gl = compositor_context_provider_->ContextGL(); 199 gpu::gles2::GLES2Interface* gl = compositor_context_provider_->ContextGL();
201 if (async_worker_context_enabled_) { 200 if (async_worker_context_enabled_) {
202 GLuint64 fence = gl->InsertFenceSyncCHROMIUM(); 201 GLuint64 fence = gl->InsertFenceSyncCHROMIUM();
203 gl->OrderingBarrierCHROMIUM(); 202 gl->OrderingBarrierCHROMIUM();
204 203
205 gpu::SyncToken sync_token; 204 gpu::SyncToken sync_token;
206 gl->GenUnverifiedSyncTokenCHROMIUM(fence, sync_token.GetData()); 205 gl->GenUnverifiedSyncTokenCHROMIUM(fence, sync_token.GetData());
207 206
208 DCHECK(sync_token.HasData() || 207 DCHECK(sync_token.HasData() ||
209 gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR); 208 gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR);
210 209
211 for (RasterBufferImpl* buffer : pending_raster_buffers_) 210 for (RasterBufferImpl* buffer : pending_raster_buffers_)
212 buffer->set_sync_token(sync_token); 211 buffer->set_sync_token(sync_token);
213 } else { 212 } else {
214 gl->OrderingBarrierCHROMIUM(); 213 gl->OrderingBarrierCHROMIUM();
215 } 214 }
216 pending_raster_buffers_.clear(); 215 pending_raster_buffers_.clear();
217 } 216 }
218 217
218 bool GpuRasterBufferProvider::IsResourceReadyToDraw(
219 const Resource* resource) {
220 if (async_worker_context_enabled_) {
221 gpu::SyncToken sync_token =
222 resource_provider_->GetSyncTokenForResource(resource->id());
223 if (sync_token.HasData()) {
224 return worker_context_provider_->ContextSupport()->IsFenceSyncReleased(
225 sync_token.release_count());
226 }
227 }
228 return true;
229 }
230
231 void GpuRasterBufferProvider::SignalResourcesReadyToDraw(
232 const std::vector<const Resource*>& resources,
233 const base::Closure& callback) {
234 if (async_worker_context_enabled_) {
235 ResourceProvider::ResourceIdArray resource_ids;
236 for (const Resource* resource : resources)
237 resource_ids.push_back(resource->id());
238
239 gpu::SyncToken sync_token =
240 resource_provider_->GetSyncTokenForResources(resource_ids);
241 compositor_context_provider_->ContextSupport()->SignalSyncToken(sync_token,
242 callback);
243 } else if (!callback.is_null()) {
244 callback.Run();
245 }
246 }
247
219 ResourceFormat GpuRasterBufferProvider::GetResourceFormat( 248 ResourceFormat GpuRasterBufferProvider::GetResourceFormat(
220 bool must_support_alpha) const { 249 bool must_support_alpha) const {
221 return resource_provider_->best_render_buffer_format(); 250 return resource_provider_->best_render_buffer_format();
222 } 251 }
223 252
224 bool GpuRasterBufferProvider::IsResourceSwizzleRequired( 253 bool GpuRasterBufferProvider::IsResourceSwizzleRequired(
225 bool must_support_alpha) const { 254 bool must_support_alpha) const {
226 // This doesn't require a swizzle because we rasterize to the correct format. 255 // This doesn't require a swizzle because we rasterize to the correct format.
227 return false; 256 return false;
228 } 257 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 gl->OrderingBarrierCHROMIUM(); 312 gl->OrderingBarrierCHROMIUM();
284 313
285 // Generate sync token after the barrier for cross context synchronization. 314 // Generate sync token after the barrier for cross context synchronization.
286 gpu::SyncToken resource_sync_token; 315 gpu::SyncToken resource_sync_token;
287 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData()); 316 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData());
288 resource_lock->set_sync_token(resource_sync_token); 317 resource_lock->set_sync_token(resource_sync_token);
289 resource_lock->set_synchronized(!async_worker_context_enabled_); 318 resource_lock->set_synchronized(!async_worker_context_enabled_);
290 } 319 }
291 320
292 } // namespace cc 321 } // namespace cc
OLDNEW
« no previous file with comments | « cc/raster/gpu_raster_buffer_provider.h ('k') | cc/raster/one_copy_raster_buffer_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698