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

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

Issue 737723003: drawinfo carries bufferinfo (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: feedback inc Created 6 years, 1 month 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/GrInOrderDrawBuffer.h ('k') | src/gpu/gl/GrGpuGL_program.cpp » ('j') | 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 2011 Google Inc. 2 * Copyright 2011 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 "GrInOrderDrawBuffer.h" 8 #include "GrInOrderDrawBuffer.h"
9 9
10 #include "GrBufferAllocPool.h" 10 #include "GrBufferAllocPool.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 return 0; 212 return 0;
213 } 213 }
214 214
215 Draw* draw = static_cast<Draw*>(&fCmdBuffer.back()); 215 Draw* draw = static_cast<Draw*>(&fCmdBuffer.back());
216 GeometryPoolState& poolState = fGeoPoolStateStack.back(); 216 GeometryPoolState& poolState = fGeoPoolStateStack.back();
217 const GrVertexBuffer* vertexBuffer = poolState.fPoolVertexBuffer; 217 const GrVertexBuffer* vertexBuffer = poolState.fPoolVertexBuffer;
218 218
219 if (!draw->fInfo.isInstanced() || 219 if (!draw->fInfo.isInstanced() ||
220 draw->fInfo.verticesPerInstance() != info.verticesPerInstance() || 220 draw->fInfo.verticesPerInstance() != info.verticesPerInstance() ||
221 draw->fInfo.indicesPerInstance() != info.indicesPerInstance() || 221 draw->fInfo.indicesPerInstance() != info.indicesPerInstance() ||
222 draw->vertexBuffer() != vertexBuffer || 222 draw->fInfo.vertexBuffer() != vertexBuffer ||
223 draw->indexBuffer() != geomSrc.fIndexBuffer || 223 draw->fInfo.indexBuffer() != geomSrc.fIndexBuffer ||
224 draw->fScissorState != scissorState) { 224 draw->fScissorState != scissorState) {
225 return 0; 225 return 0;
226 } 226 }
227 // info does not yet account for the offset from the start of the pool's VB while the previous 227 // info does not yet account for the offset from the start of the pool's VB while the previous
228 // draw record does. 228 // draw record does.
229 int adjustedStartVertex = poolState.fPoolStartVertex + info.startVertex(); 229 int adjustedStartVertex = poolState.fPoolStartVertex + info.startVertex();
230 if (draw->fInfo.startVertex() + draw->fInfo.vertexCount() != adjustedStartVe rtex) { 230 if (draw->fInfo.startVertex() + draw->fInfo.vertexCount() != adjustedStartVe rtex) {
231 return 0; 231 return 0;
232 } 232 }
233 233
(...skipping 19 matching lines...) Expand all
253 draw->fType = add_trace_bit(draw->fType); 253 draw->fType = add_trace_bit(draw->fType);
254 } 254 }
255 } 255 }
256 256
257 return instancesToConcat; 257 return instancesToConcat;
258 } 258 }
259 259
260 void GrInOrderDrawBuffer::onDraw(const GrDrawState& ds, 260 void GrInOrderDrawBuffer::onDraw(const GrDrawState& ds,
261 const DrawInfo& info, 261 const DrawInfo& info,
262 const GrClipMaskManager::ScissorState& scissorS tate) { 262 const GrClipMaskManager::ScissorState& scissorS tate) {
263 SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer()));
264
263 GeometryPoolState& poolState = fGeoPoolStateStack.back(); 265 GeometryPoolState& poolState = fGeoPoolStateStack.back();
264 266
265 this->recordStateIfNecessary(ds, 267 this->recordStateIfNecessary(ds,
266 GrGpu::PrimTypeToDrawType(info.primitiveType()) , 268 GrGpu::PrimTypeToDrawType(info.primitiveType()) ,
267 info.getDstCopy()); 269 info.getDstCopy());
268 270
269 const GrVertexBuffer* vb;
270 if (kBuffer_GeometrySrcType == this->getGeomSrc().fVertexSrc) {
271 vb = this->getGeomSrc().fVertexBuffer;
272 } else {
273 vb = poolState.fPoolVertexBuffer;
274 }
275
276 const GrIndexBuffer* ib = NULL;
277 if (info.isIndexed()) {
278 if (kBuffer_GeometrySrcType == this->getGeomSrc().fIndexSrc) {
279 ib = this->getGeomSrc().fIndexBuffer;
280 } else {
281 ib = poolState.fPoolIndexBuffer;
282 }
283 }
284
285 Draw* draw; 271 Draw* draw;
286 if (info.isInstanced()) { 272 if (info.isInstanced()) {
287 int instancesConcated = this->concatInstancedDraw(ds, info, scissorState ); 273 int instancesConcated = this->concatInstancedDraw(ds, info, scissorState );
288 if (info.instanceCount() > instancesConcated) { 274 if (info.instanceCount() > instancesConcated) {
289 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info, scissorStat e, vb, ib)); 275 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info, scissorStat e));
290 draw->fInfo.adjustInstanceCount(-instancesConcated); 276 draw->fInfo.adjustInstanceCount(-instancesConcated);
291 } else { 277 } else {
292 return; 278 return;
293 } 279 }
294 } else { 280 } else {
295 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info, scissorState, v b, ib)); 281 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info, scissorState));
296 } 282 }
297 this->recordTraceMarkersIfNecessary(); 283 this->recordTraceMarkersIfNecessary();
298 284
299 // Adjust the starting vertex and index when we are using reserved or array sources to 285 // Adjust the starting vertex and index when we are using reserved or array sources to
300 // compensate for the fact that the data was inserted into a larger vb/ib ow ned by the pool. 286 // compensate for the fact that the data was inserted into a larger vb/ib ow ned by the pool.
301 if (kBuffer_GeometrySrcType != this->getGeomSrc().fVertexSrc) { 287 if (kBuffer_GeometrySrcType != this->getGeomSrc().fVertexSrc) {
302 size_t bytes = (info.vertexCount() + info.startVertex()) * ds.getVertexS tride(); 288 size_t bytes = (info.vertexCount() + info.startVertex()) * ds.getVertexS tride();
303 poolState.fUsedPoolVertexBytes = SkTMax(poolState.fUsedPoolVertexBytes, bytes); 289 poolState.fUsedPoolVertexBytes = SkTMax(poolState.fUsedPoolVertexBytes, bytes);
304 draw->fInfo.adjustStartVertex(poolState.fPoolStartVertex); 290 draw->fInfo.adjustStartVertex(poolState.fPoolStartVertex);
305 } 291 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 void GrInOrderDrawBuffer::discard(GrRenderTarget* renderTarget) { 411 void GrInOrderDrawBuffer::discard(GrRenderTarget* renderTarget) {
426 SkASSERT(renderTarget); 412 SkASSERT(renderTarget);
427 if (!this->caps()->discardRenderTargetSupport()) { 413 if (!this->caps()->discardRenderTargetSupport()) {
428 return; 414 return;
429 } 415 }
430 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget)); 416 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget));
431 clr->fColor = GrColor_ILLEGAL; 417 clr->fColor = GrColor_ILLEGAL;
432 this->recordTraceMarkersIfNecessary(); 418 this->recordTraceMarkersIfNecessary();
433 } 419 }
434 420
421 void GrInOrderDrawBuffer::setDrawBuffers(DrawInfo* info) {
422 GeometryPoolState& poolState = fGeoPoolStateStack.back();
423 if (kBuffer_GeometrySrcType == this->getGeomSrc().fVertexSrc) {
424 info->setVertexBuffer(this->getGeomSrc().fVertexBuffer);
425 } else {
426 info->setVertexBuffer(poolState.fPoolVertexBuffer);
427 }
428
429 if (info->isIndexed()) {
430 if (kBuffer_GeometrySrcType == this->getGeomSrc().fIndexSrc) {
431 info->setIndexBuffer(this->getGeomSrc().fIndexBuffer);
432 } else {
433 info->setIndexBuffer(poolState.fPoolIndexBuffer);
434 }
435 }
436 }
437
435 void GrInOrderDrawBuffer::reset() { 438 void GrInOrderDrawBuffer::reset() {
436 SkASSERT(1 == fGeoPoolStateStack.count()); 439 SkASSERT(1 == fGeoPoolStateStack.count());
437 this->resetVertexSource(); 440 this->resetVertexSource();
438 this->resetIndexSource(); 441 this->resetIndexSource();
439 442
440 fCmdBuffer.reset(); 443 fCmdBuffer.reset();
441 fLastState = NULL; 444 fLastState = NULL;
442 fVertexPool.reset(); 445 fVertexPool.reset();
443 fIndexPool.reset(); 446 fIndexPool.reset();
444 reset_data_buffer(&fPathIndexBuffer, kPathIdxBufferMinReserve); 447 reset_data_buffer(&fPathIndexBuffer, kPathIdxBufferMinReserve);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 SkASSERT(fGpuCmdMarkers.count() == currCmdMarker); 507 SkASSERT(fGpuCmdMarkers.count() == currCmdMarker);
505 508
506 this->reset(); 509 this->reset();
507 ++fDrawID; 510 ++fDrawID;
508 } 511 }
509 512
510 void GrInOrderDrawBuffer::Draw::execute(GrInOrderDrawBuffer* buf, const GrOptDra wState* optState) { 513 void GrInOrderDrawBuffer::Draw::execute(GrInOrderDrawBuffer* buf, const GrOptDra wState* optState) {
511 if (!optState) { 514 if (!optState) {
512 return; 515 return;
513 } 516 }
514 GrGpu* dstGpu = buf->fDstGpu; 517 buf->fDstGpu->draw(*optState, fInfo, fScissorState);
515 dstGpu->setVertexSourceToBuffer(this->vertexBuffer(), optState->getVertexStr ide());
516 if (fInfo.isIndexed()) {
517 dstGpu->setIndexSourceToBuffer(this->indexBuffer());
518 }
519 dstGpu->draw(*optState, fInfo, fScissorState);
520 } 518 }
521 519
522 void GrInOrderDrawBuffer::StencilPath::execute(GrInOrderDrawBuffer* buf, 520 void GrInOrderDrawBuffer::StencilPath::execute(GrInOrderDrawBuffer* buf,
523 const GrOptDrawState* optState) { 521 const GrOptDrawState* optState) {
524 if (!optState) { 522 if (!optState) {
525 return; 523 return;
526 } 524 }
527 buf->fDstGpu->stencilPath(*optState, this->path(), fScissorState, fStencilSe ttings); 525 buf->fDstGpu->stencilPath(*optState, this->path(), fScissorState, fStencilSe ttings);
528 } 526 }
529 527
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 788
791 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { 789 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() {
792 SkASSERT(!fCmdBuffer.empty()); 790 SkASSERT(!fCmdBuffer.empty());
793 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType)); 791 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType));
794 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); 792 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers();
795 if (activeTraceMarkers.count() > 0) { 793 if (activeTraceMarkers.count() > 0) {
796 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); 794 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType);
797 fGpuCmdMarkers.push_back(activeTraceMarkers); 795 fGpuCmdMarkers.push_back(activeTraceMarkers);
798 } 796 }
799 } 797 }
OLDNEW
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.h ('k') | src/gpu/gl/GrGpuGL_program.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698