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

Side by Side Diff: src/gpu/GrTargetCommands.cpp

Issue 1105203002: Revert of Stop closing batch prematurely (Closed) Base URL: https://skia.googlesource.com/skia.git@atdfopt3
Patch Set: Created 5 years, 7 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
« no previous file with comments | « src/gpu/GrTargetCommands.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrTargetCommands.h" 8 #include "GrTargetCommands.h"
9 9
10 #include "GrColor.h" 10 #include "GrColor.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // update last fGpuCmdMarkers to include any additional trace markers that h ave been added 75 // update last fGpuCmdMarkers to include any additional trace markers that h ave been added
76 iodb->recordTraceMarkersIfNecessary(draw); 76 iodb->recordTraceMarkersIfNecessary(draw);
77 return instancesToConcat; 77 return instancesToConcat;
78 } 78 }
79 79
80 GrTargetCommands::Cmd* GrTargetCommands::recordDraw( 80 GrTargetCommands::Cmd* GrTargetCommands::recordDraw(
81 GrInOrderDrawBuffer* iodb, 81 GrInOrderDrawBuffer* iodb,
82 const GrGeometryProcessor* gp, 82 const GrGeometryProcessor* gp,
83 const GrDrawTarget::DrawInfo& info, 83 const GrDrawTarget::DrawInfo& info,
84 const GrDrawTarget::PipelineIn fo& pipelineInfo) { 84 const GrDrawTarget::PipelineIn fo& pipelineInfo) {
85 #ifdef USE_BITMAP_TEXTBLOBS
86 SkFAIL("Non-batch no longer supported\n");
87 #endif
88 SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer())); 85 SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer()));
89 CLOSE_BATCH 86 this->closeBatch();
90 87
91 if (!this->setupPipelineAndShouldDraw(iodb, gp, pipelineInfo)) { 88 if (!this->setupPipelineAndShouldDraw(iodb, gp, pipelineInfo)) {
92 return NULL; 89 return NULL;
93 } 90 }
94 91
95 Draw* draw; 92 Draw* draw;
96 if (info.isInstanced()) { 93 if (info.isInstanced()) {
97 int instancesConcated = this->concatInstancedDraw(iodb, info); 94 int instancesConcated = this->concatInstancedDraw(iodb, info);
98 if (info.instanceCount() > instancesConcated) { 95 if (info.instanceCount() > instancesConcated) {
99 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); 96 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info));
(...skipping 17 matching lines...) Expand all
117 } 114 }
118 115
119 // Check if there is a Batch Draw we can batch with 116 // Check if there is a Batch Draw we can batch with
120 if (Cmd::kDrawBatch_CmdType != fCmdBuffer.back().type() || !fDrawBatch) { 117 if (Cmd::kDrawBatch_CmdType != fCmdBuffer.back().type() || !fDrawBatch) {
121 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fB atchTarget)); 118 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fB atchTarget));
122 return fDrawBatch; 119 return fDrawBatch;
123 } 120 }
124 121
125 SkASSERT(&fCmdBuffer.back() == fDrawBatch); 122 SkASSERT(&fCmdBuffer.back() == fDrawBatch);
126 if (!fDrawBatch->fBatch->combineIfPossible(batch)) { 123 if (!fDrawBatch->fBatch->combineIfPossible(batch)) {
127 CLOSE_BATCH 124 this->closeBatch();
128 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fB atchTarget)); 125 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fB atchTarget));
129 } 126 }
130 127
131 return fDrawBatch; 128 return fDrawBatch;
132 } 129 }
133 130
134 GrTargetCommands::Cmd* GrTargetCommands::recordStencilPath( 131 GrTargetCommands::Cmd* GrTargetCommands::recordStencilPath(
135 GrInOrderDrawBuffer* iod b, 132 GrInOrderDrawBuffer* iod b,
136 const GrPipelineBuilder& pipelineBuilder, 133 const GrPipelineBuilder& pipelineBuilder,
137 const GrPathProcessor* p athProc, 134 const GrPathProcessor* p athProc,
138 const GrPath* path, 135 const GrPath* path,
139 const GrScissorState& sc issorState, 136 const GrScissorState& sc issorState,
140 const GrStencilSettings& stencilSettings) { 137 const GrStencilSettings& stencilSettings) {
141 CLOSE_BATCH 138 this->closeBatch();
142 139
143 StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath, 140 StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath,
144 (path, pipelineBuilder.getRenderT arget())); 141 (path, pipelineBuilder.getRenderT arget()));
145 142
146 sp->fScissor = scissorState; 143 sp->fScissor = scissorState;
147 sp->fUseHWAA = pipelineBuilder.isHWAntialias(); 144 sp->fUseHWAA = pipelineBuilder.isHWAntialias();
148 sp->fViewMatrix = pathProc->viewMatrix(); 145 sp->fViewMatrix = pathProc->viewMatrix();
149 sp->fStencil = stencilSettings; 146 sp->fStencil = stencilSettings;
150 return sp; 147 return sp;
151 } 148 }
152 149
153 GrTargetCommands::Cmd* GrTargetCommands::recordDrawPath( 150 GrTargetCommands::Cmd* GrTargetCommands::recordDrawPath(
154 GrInOrderDrawBuffer* iodb, 151 GrInOrderDrawBuffer* iodb,
155 const GrPathProcessor* pathPro c, 152 const GrPathProcessor* pathPro c,
156 const GrPath* path, 153 const GrPath* path,
157 const GrStencilSettings& stenc ilSettings, 154 const GrStencilSettings& stenc ilSettings,
158 const GrDrawTarget::PipelineIn fo& pipelineInfo) { 155 const GrDrawTarget::PipelineIn fo& pipelineInfo) {
159 CLOSE_BATCH 156 this->closeBatch();
160 157
161 // TODO: Only compare the subset of GrPipelineBuilder relevant to path cover ing? 158 // TODO: Only compare the subset of GrPipelineBuilder relevant to path cover ing?
162 if (!this->setupPipelineAndShouldDraw(iodb, pathProc, pipelineInfo)) { 159 if (!this->setupPipelineAndShouldDraw(iodb, pathProc, pipelineInfo)) {
163 return NULL; 160 return NULL;
164 } 161 }
165 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); 162 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path));
166 dp->fStencilSettings = stencilSettings; 163 dp->fStencilSettings = stencilSettings;
167 return dp; 164 return dp;
168 } 165 }
169 166
170 GrTargetCommands::Cmd* GrTargetCommands::recordDrawPaths( 167 GrTargetCommands::Cmd* GrTargetCommands::recordDrawPaths(
171 GrInOrderDrawBuffer* iodb, 168 GrInOrderDrawBuffer* iodb,
172 const GrPathProcessor* pathPro c, 169 const GrPathProcessor* pathPro c,
173 const GrPathRange* pathRange, 170 const GrPathRange* pathRange,
174 const void* indexValues, 171 const void* indexValues,
175 GrDrawTarget::PathIndexType in dexType, 172 GrDrawTarget::PathIndexType in dexType,
176 const float transformValues[], 173 const float transformValues[],
177 GrDrawTarget::PathTransformTyp e transformType, 174 GrDrawTarget::PathTransformTyp e transformType,
178 int count, 175 int count,
179 const GrStencilSettings& stenc ilSettings, 176 const GrStencilSettings& stenc ilSettings,
180 const GrDrawTarget::PipelineIn fo& pipelineInfo) { 177 const GrDrawTarget::PipelineIn fo& pipelineInfo) {
181 SkASSERT(pathRange); 178 SkASSERT(pathRange);
182 SkASSERT(indexValues); 179 SkASSERT(indexValues);
183 SkASSERT(transformValues); 180 SkASSERT(transformValues);
184 CLOSE_BATCH 181 this->closeBatch();
185 182
186 if (!this->setupPipelineAndShouldDraw(iodb, pathProc, pipelineInfo)) { 183 if (!this->setupPipelineAndShouldDraw(iodb, pathProc, pipelineInfo)) {
187 return NULL; 184 return NULL;
188 } 185 }
189 186
190 char* savedIndices; 187 char* savedIndices;
191 float* savedTransforms; 188 float* savedTransforms;
192 189
193 iodb->appendIndicesAndTransforms(indexValues, indexType, 190 iodb->appendIndicesAndTransforms(indexValues, indexType,
194 transformValues, transformType, 191 transformValues, transformType,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 dp->fStencilSettings = stencilSettings; 227 dp->fStencilSettings = stencilSettings;
231 return dp; 228 return dp;
232 } 229 }
233 230
234 GrTargetCommands::Cmd* GrTargetCommands::recordClear(GrInOrderDrawBuffer* iodb, 231 GrTargetCommands::Cmd* GrTargetCommands::recordClear(GrInOrderDrawBuffer* iodb,
235 const SkIRect* rect, 232 const SkIRect* rect,
236 GrColor color, 233 GrColor color,
237 bool canIgnoreRect, 234 bool canIgnoreRect,
238 GrRenderTarget* renderTarge t) { 235 GrRenderTarget* renderTarge t) {
239 SkASSERT(renderTarget); 236 SkASSERT(renderTarget);
240 CLOSE_BATCH 237 this->closeBatch();
241 238
242 SkIRect r; 239 SkIRect r;
243 if (NULL == rect) { 240 if (NULL == rect) {
244 // We could do something smart and remove previous draws and clears to 241 // We could do something smart and remove previous draws and clears to
245 // the current render target. If we get that smart we have to make sure 242 // the current render target. If we get that smart we have to make sure
246 // those draws aren't read before this clear (render-to-texture). 243 // those draws aren't read before this clear (render-to-texture).
247 r.setLTRB(0, 0, renderTarget->width(), renderTarget->height()); 244 r.setLTRB(0, 0, renderTarget->width(), renderTarget->height());
248 rect = &r; 245 rect = &r;
249 } 246 }
250 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget)); 247 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget));
251 GrColorIsPMAssert(color); 248 GrColorIsPMAssert(color);
252 clr->fColor = color; 249 clr->fColor = color;
253 clr->fRect = *rect; 250 clr->fRect = *rect;
254 clr->fCanIgnoreRect = canIgnoreRect; 251 clr->fCanIgnoreRect = canIgnoreRect;
255 return clr; 252 return clr;
256 } 253 }
257 254
258 GrTargetCommands::Cmd* GrTargetCommands::recordClearStencilClip(GrInOrderDrawBuf fer* iodb, 255 GrTargetCommands::Cmd* GrTargetCommands::recordClearStencilClip(GrInOrderDrawBuf fer* iodb,
259 const SkIRect& r ect, 256 const SkIRect& r ect,
260 bool insideClip, 257 bool insideClip,
261 GrRenderTarget* renderTarget) { 258 GrRenderTarget* renderTarget) {
262 SkASSERT(renderTarget); 259 SkASSERT(renderTarget);
263 CLOSE_BATCH 260 this->closeBatch();
264 261
265 ClearStencilClip* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, ClearStencilCli p, (renderTarget)); 262 ClearStencilClip* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, ClearStencilCli p, (renderTarget));
266 clr->fRect = rect; 263 clr->fRect = rect;
267 clr->fInsideClip = insideClip; 264 clr->fInsideClip = insideClip;
268 return clr; 265 return clr;
269 } 266 }
270 267
271 GrTargetCommands::Cmd* GrTargetCommands::recordDiscard(GrInOrderDrawBuffer* iodb , 268 GrTargetCommands::Cmd* GrTargetCommands::recordDiscard(GrInOrderDrawBuffer* iodb ,
272 GrRenderTarget* renderTar get) { 269 GrRenderTarget* renderTar get) {
273 SkASSERT(renderTarget); 270 SkASSERT(renderTarget);
274 CLOSE_BATCH 271 this->closeBatch();
275 272
276 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget)); 273 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget));
277 clr->fColor = GrColor_ILLEGAL; 274 clr->fColor = GrColor_ILLEGAL;
278 return clr; 275 return clr;
279 } 276 }
280 277
281 void GrTargetCommands::reset() { 278 void GrTargetCommands::reset() {
282 fCmdBuffer.reset(); 279 fCmdBuffer.reset();
283 fPrevState = NULL; 280 fPrevState = NULL;
284 fDrawBatch = NULL; 281 fDrawBatch = NULL;
285 } 282 }
286 283
287 void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) { 284 void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) {
288 if (fCmdBuffer.empty()) { 285 if (fCmdBuffer.empty()) {
289 return; 286 return;
290 } 287 }
291 288
292 // TODO this is temporary while batch is being rolled out 289 // TODO this is temporary while batch is being rolled out
293 CLOSE_BATCH 290 this->closeBatch();
291 iodb->getVertexAllocPool()->unmap();
292 iodb->getIndexAllocPool()->unmap();
293 fBatchTarget.preFlush();
294 294
295 // Updated every time we find a set state cmd to reflect the current state i n the playback 295 // Updated every time we find a set state cmd to reflect the current state i n the playback
296 // stream. 296 // stream.
297 SetState* currentState = NULL; 297 SetState* currentState = NULL;
298 298
299 CmdBuffer::Iter iter(fCmdBuffer);
300
299 GrGpu* gpu = iodb->getGpu(); 301 GrGpu* gpu = iodb->getGpu();
300 302
301 #ifdef USE_BITMAP_TEXTBLOBS
302 // Loop over all batches and generate geometry
303 CmdBuffer::Iter genIter(fCmdBuffer);
304 while (genIter.next()) {
305 if (Cmd::kDrawBatch_CmdType == genIter->type()) {
306 DrawBatch* db = reinterpret_cast<DrawBatch*>(genIter.get());
307 fBatchTarget.resetNumberOfDraws();
308 db->execute(NULL, currentState);
309 db->fBatch->setNumberOfDraws(fBatchTarget.numberOfDraws());
310 } else if (Cmd::kSetState_CmdType == genIter->type()) {
311 SetState* ss = reinterpret_cast<SetState*>(genIter.get());
312
313 ss->execute(gpu, currentState);
314 currentState = ss;
315 }
316 }
317 #endif
318
319 iodb->getVertexAllocPool()->unmap();
320 iodb->getIndexAllocPool()->unmap();
321 fBatchTarget.preFlush();
322
323 CmdBuffer::Iter iter(fCmdBuffer);
324
325 while (iter.next()) { 303 while (iter.next()) {
326 GrGpuTraceMarker newMarker("", -1); 304 GrGpuTraceMarker newMarker("", -1);
327 SkString traceString; 305 SkString traceString;
328 if (iter->isTraced()) { 306 if (iter->isTraced()) {
329 traceString = iodb->getCmdString(iter->markerID()); 307 traceString = iodb->getCmdString(iter->markerID());
330 newMarker.fMarker = traceString.c_str(); 308 newMarker.fMarker = traceString.c_str();
331 gpu->addGpuTraceMarker(&newMarker); 309 gpu->addGpuTraceMarker(&newMarker);
332 } 310 }
333 311
334 // TODO temporary hack 312 // TODO temporary hack
335 if (Cmd::kDrawBatch_CmdType == iter->type()) { 313 if (Cmd::kDrawBatch_CmdType == iter->type()) {
336 DrawBatch* db = reinterpret_cast<DrawBatch*>(iter.get()); 314 DrawBatch* db = reinterpret_cast<DrawBatch*>(iter.get());
337 fBatchTarget.flushNext(db->fBatch->numberOfDraws()); 315 fBatchTarget.flushNext(db->fBatch->numberOfDraws());
338 316
339 if (iter->isTraced()) { 317 if (iter->isTraced()) {
340 gpu->removeGpuTraceMarker(&newMarker); 318 gpu->removeGpuTraceMarker(&newMarker);
341 } 319 }
342 continue; 320 continue;
343 } 321 }
344 322
345 if (Cmd::kSetState_CmdType == iter->type()) { 323 if (Cmd::kSetState_CmdType == iter->type()) {
346 #ifndef USE_BITMAP_TEXTBLOBS
347 SetState* ss = reinterpret_cast<SetState*>(iter.get()); 324 SetState* ss = reinterpret_cast<SetState*>(iter.get());
348 325
349 ss->execute(gpu, currentState); 326 ss->execute(gpu, currentState);
350 currentState = ss; 327 currentState = ss;
351 #endif
352 } else { 328 } else {
353 iter->execute(gpu, currentState); 329 iter->execute(gpu, currentState);
354 } 330 }
355 331
356 if (iter->isTraced()) { 332 if (iter->isTraced()) {
357 gpu->removeGpuTraceMarker(&newMarker); 333 gpu->removeGpuTraceMarker(&newMarker);
358 } 334 }
359 } 335 }
360 336
361 // TODO see copious notes about hack 337 // TODO see copious notes about hack
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 void GrTargetCommands::CopySurface::execute(GrGpu* gpu, const SetState*) { 401 void GrTargetCommands::CopySurface::execute(GrGpu* gpu, const SetState*) {
426 gpu->copySurface(this->dst(), this->src(), fSrcRect, fDstPoint); 402 gpu->copySurface(this->dst(), this->src(), fSrcRect, fDstPoint);
427 } 403 }
428 404
429 GrTargetCommands::Cmd* GrTargetCommands::recordCopySurface(GrInOrderDrawBuffer* iodb, 405 GrTargetCommands::Cmd* GrTargetCommands::recordCopySurface(GrInOrderDrawBuffer* iodb,
430 GrSurface* dst, 406 GrSurface* dst,
431 GrSurface* src, 407 GrSurface* src,
432 const SkIRect& srcRec t, 408 const SkIRect& srcRec t,
433 const SkIPoint& dstPo int) { 409 const SkIPoint& dstPo int) {
434 if (iodb->getGpu()->canCopySurface(dst, src, srcRect, dstPoint)) { 410 if (iodb->getGpu()->canCopySurface(dst, src, srcRect, dstPoint)) {
435 CLOSE_BATCH 411 this->closeBatch();
436 CopySurface* cs = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, CopySurface, (dst , src)); 412 CopySurface* cs = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, CopySurface, (dst , src));
437 cs->fSrcRect = srcRect; 413 cs->fSrcRect = srcRect;
438 cs->fDstPoint = dstPoint; 414 cs->fDstPoint = dstPoint;
439 return cs; 415 return cs;
440 } 416 }
441 return NULL; 417 return NULL;
442 } 418 }
443 419
444 bool GrTargetCommands::setupPipelineAndShouldDraw(GrInOrderDrawBuffer* iodb, 420 bool GrTargetCommands::setupPipelineAndShouldDraw(GrInOrderDrawBuffer* iodb,
445 const GrPrimitiveProcessor* pr imProc, 421 const GrPrimitiveProcessor* pr imProc,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 fCmdBuffer.pop_back(); 454 fCmdBuffer.pop_back();
479 return false; 455 return false;
480 } 456 }
481 457
482 batch->initBatchTracker(ss->getPipeline()->getInitBatchTracker()); 458 batch->initBatchTracker(ss->getPipeline()->getInitBatchTracker());
483 459
484 if (fPrevState && !fPrevState->fPrimitiveProcessor.get() && 460 if (fPrevState && !fPrevState->fPrimitiveProcessor.get() &&
485 fPrevState->getPipeline()->isEqual(*ss->getPipeline())) { 461 fPrevState->getPipeline()->isEqual(*ss->getPipeline())) {
486 fCmdBuffer.pop_back(); 462 fCmdBuffer.pop_back();
487 } else { 463 } else {
488 CLOSE_BATCH 464 this->closeBatch();
489 fPrevState = ss; 465 fPrevState = ss;
490 iodb->recordTraceMarkersIfNecessary(ss); 466 iodb->recordTraceMarkersIfNecessary(ss);
491 } 467 }
492 return true; 468 return true;
493 } 469 }
494 470
OLDNEW
« no previous file with comments | « src/gpu/GrTargetCommands.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698