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

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

Issue 1126613003: Revert of Move instanced index buffer creation to flush time (Closed) Base URL: https://skia.googlesource.com/skia.git@master
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/GrGpu.cpp ('k') | src/gpu/GrOvalRenderer.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 /* 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 "GrDefaultGeoProcFactory.h" 10 #include "GrDefaultGeoProcFactory.h"
11 #include "GrResourceProvider.h"
12 #include "GrTemplates.h" 11 #include "GrTemplates.h"
13 12
14 GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrContext* context, 13 GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrContext* context,
15 GrVertexBufferAllocPool* vertexPool, 14 GrVertexBufferAllocPool* vertexPool,
16 GrIndexBufferAllocPool* indexPool) 15 GrIndexBufferAllocPool* indexPool)
17 : INHERITED(context, vertexPool, indexPool) 16 : INHERITED(context, vertexPool, indexPool)
18 , fCommands(context->getGpu(), vertexPool, indexPool) 17 , fCommands(context->getGpu(), vertexPool, indexPool)
19 , fPathIndexBuffer(kPathIdxBufferMinReserve * sizeof(char)/4) 18 , fPathIndexBuffer(kPathIdxBufferMinReserve * sizeof(char)/4)
20 , fPathTransformBuffer(kPathXformBufferMinReserve * sizeof(float)/4) 19 , fPathTransformBuffer(kPathXformBufferMinReserve * sizeof(float)/4)
21 , fDrawID(0) { 20 , fDrawID(0) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 init.fUsesLocalCoords = this->usesLocalCoords(); 130 init.fUsesLocalCoords = this->usesLocalCoords();
132 gp->initBatchTracker(batchTarget->currentBatchTracker(), init); 131 gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
133 132
134 size_t vertexStride = gp->getVertexStride(); 133 size_t vertexStride = gp->getVertexStride();
135 134
136 SkASSERT(hasExplicitLocalCoords ? 135 SkASSERT(hasExplicitLocalCoords ?
137 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorLo calCoordAttr) : 136 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorLo calCoordAttr) :
138 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr)); 137 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr));
139 138
140 int instanceCount = fGeoData.count(); 139 int instanceCount = fGeoData.count();
141 SkAutoTUnref<const GrIndexBuffer> indexBuffer( 140 int vertexCount = kVertsPerRect * instanceCount;
142 batchTarget->resourceProvider()->refQuadIndexBuffer());
143 141
144 int vertexCount = kVertsPerRect * instanceCount;
145 const GrVertexBuffer* vertexBuffer; 142 const GrVertexBuffer* vertexBuffer;
146 int firstVertex; 143 int firstVertex;
144
147 void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, 145 void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
148 vertexCount, 146 vertexCount,
149 &vertexBuffer, 147 &vertexBuffer,
150 &firstVertex); 148 &firstVertex);
151 149
152 if (!vertices || !indexBuffer) { 150 if (!vertices || !batchTarget->quadIndexBuffer()) {
153 SkDebugf("Could not allocate buffers\n"); 151 SkDebugf("Could not allocate buffers\n");
154 return; 152 return;
155 } 153 }
156 154
157 for (int i = 0; i < instanceCount; i++) { 155 for (int i = 0; i < instanceCount; i++) {
158 const Geometry& args = fGeoData[i]; 156 const Geometry& args = fGeoData[i];
159 157
160 intptr_t offset = GrTCast<intptr_t>(vertices) + kVertsPerRect * i * vertexStride; 158 intptr_t offset = GrTCast<intptr_t>(vertices) + kVertsPerRect * i * vertexStride;
161 SkPoint* positions = GrTCast<SkPoint*>(offset); 159 SkPoint* positions = GrTCast<SkPoint*>(offset);
162 160
(...skipping 13 matching lines...) Expand all
176 } 174 }
177 175
178 static const int kColorOffset = sizeof(SkPoint); 176 static const int kColorOffset = sizeof(SkPoint);
179 GrColor* vertColor = GrTCast<GrColor*>(offset + kColorOffset); 177 GrColor* vertColor = GrTCast<GrColor*>(offset + kColorOffset);
180 for (int j = 0; j < 4; ++j) { 178 for (int j = 0; j < 4; ++j) {
181 *vertColor = args.fColor; 179 *vertColor = args.fColor;
182 vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride); 180 vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride);
183 } 181 }
184 } 182 }
185 183
184 const GrIndexBuffer* quadIndexBuffer = batchTarget->quadIndexBuffer();
185
186 GrDrawTarget::DrawInfo drawInfo; 186 GrDrawTarget::DrawInfo drawInfo;
187 drawInfo.setPrimitiveType(kTriangles_GrPrimitiveType); 187 drawInfo.setPrimitiveType(kTriangles_GrPrimitiveType);
188 drawInfo.setStartVertex(0); 188 drawInfo.setStartVertex(0);
189 drawInfo.setStartIndex(0); 189 drawInfo.setStartIndex(0);
190 drawInfo.setVerticesPerInstance(kVertsPerRect); 190 drawInfo.setVerticesPerInstance(kVertsPerRect);
191 drawInfo.setIndicesPerInstance(kIndicesPerRect); 191 drawInfo.setIndicesPerInstance(kIndicesPerRect);
192 drawInfo.adjustStartVertex(firstVertex); 192 drawInfo.adjustStartVertex(firstVertex);
193 drawInfo.setVertexBuffer(vertexBuffer); 193 drawInfo.setVertexBuffer(vertexBuffer);
194 drawInfo.setIndexBuffer(indexBuffer); 194 drawInfo.setIndexBuffer(quadIndexBuffer);
195 195
196 int maxInstancesPerDraw = indexBuffer->maxQuads(); 196 int maxInstancesPerDraw = quadIndexBuffer->maxQuads();
197 while (instanceCount) { 197 while (instanceCount) {
198 drawInfo.setInstanceCount(SkTMin(instanceCount, maxInstancesPerDraw) ); 198 drawInfo.setInstanceCount(SkTMin(instanceCount, maxInstancesPerDraw) );
199 drawInfo.setVertexCount(drawInfo.instanceCount() * drawInfo.vertices PerInstance()); 199 drawInfo.setVertexCount(drawInfo.instanceCount() * drawInfo.vertices PerInstance());
200 drawInfo.setIndexCount(drawInfo.instanceCount() * drawInfo.indicesPe rInstance()); 200 drawInfo.setIndexCount(drawInfo.instanceCount() * drawInfo.indicesPe rInstance());
201 201
202 batchTarget->draw(drawInfo); 202 batchTarget->draw(drawInfo);
203 203
204 drawInfo.setStartVertex(drawInfo.startVertex() + drawInfo.vertexCoun t()); 204 drawInfo.setStartVertex(drawInfo.startVertex() + drawInfo.vertexCoun t());
205 instanceCount -= drawInfo.instanceCount(); 205 instanceCount -= drawInfo.instanceCount();
206 } 206 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); 393 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers();
394 if (activeTraceMarkers.count() > 0) { 394 if (activeTraceMarkers.count() > 0) {
395 if (cmd->isTraced()) { 395 if (cmd->isTraced()) {
396 fGpuCmdMarkers[cmd->markerID()].addSet(activeTraceMarkers); 396 fGpuCmdMarkers[cmd->markerID()].addSet(activeTraceMarkers);
397 } else { 397 } else {
398 cmd->setMarkerID(fGpuCmdMarkers.count()); 398 cmd->setMarkerID(fGpuCmdMarkers.count());
399 fGpuCmdMarkers.push_back(activeTraceMarkers); 399 fGpuCmdMarkers.push_back(activeTraceMarkers);
400 } 400 }
401 } 401 }
402 } 402 }
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.cpp ('k') | src/gpu/GrOvalRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698