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

Side by Side Diff: src/gpu/batches/GrTInstanceBatch.h

Issue 1806983002: Update how we send draws to gpu backend to reduce state setting. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 9 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 /* 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 #ifndef GrTInstanceBatch_DEFINED 8 #ifndef GrTInstanceBatch_DEFINED
9 #define GrTInstanceBatch_DEFINED 9 #define GrTInstanceBatch_DEFINED
10 10
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 GrTInstanceBatch() : INHERITED(ClassID()) {} 89 GrTInstanceBatch() : INHERITED(ClassID()) {}
90 90
91 void onPrepareDraws(Target* target) const override { 91 void onPrepareDraws(Target* target) const override {
92 SkAutoTUnref<const GrGeometryProcessor> gp(Impl::CreateGP(this->seedGeom etry(), 92 SkAutoTUnref<const GrGeometryProcessor> gp(Impl::CreateGP(this->seedGeom etry(),
93 fOverrides)); 93 fOverrides));
94 if (!gp) { 94 if (!gp) {
95 SkDebugf("Couldn't create GrGeometryProcessor\n"); 95 SkDebugf("Couldn't create GrGeometryProcessor\n");
96 return; 96 return;
97 } 97 }
98 98
99 target->initDraw(gp, this->pipeline()); 99 target->initDraw(gp, kTriangles_GrPrimitiveType);
100 100
101 size_t vertexStride = gp->getVertexStride(); 101 size_t vertexStride = gp->getVertexStride();
102 int instanceCount = fGeoData.count(); 102 int instanceCount = fGeoData.count();
103 103
104 SkAutoTUnref<const GrIndexBuffer> indexBuffer( 104 SkAutoTUnref<const GrIndexBuffer> indexBuffer(
105 Impl::GetIndexBuffer(target->resourceProvider())); 105 Impl::GetIndexBuffer(target->resourceProvider()));
106 InstancedHelper helper; 106 InstancedHelper helper;
107 void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexS tride, 107 void* vertices = helper.init(target, vertexStride, indexBuffer, Impl::kV ertsPerInstance,
108 indexBuffer, Impl::kVertsPerInstance,
109 Impl::kIndicesPerInstance, instanceCount); 108 Impl::kIndicesPerInstance, instanceCount);
110 if (!vertices || !indexBuffer) { 109 if (!vertices || !indexBuffer) {
111 SkDebugf("Could not allocate vertices\n"); 110 SkDebugf("Could not allocate vertices\n");
112 return; 111 return;
113 } 112 }
114 113
115 for (int i = 0; i < instanceCount; i++) { 114 for (int i = 0; i < instanceCount; i++) {
116 intptr_t verts = reinterpret_cast<intptr_t>(vertices) + 115 intptr_t verts = reinterpret_cast<intptr_t>(vertices) +
117 i * Impl::kVertsPerInstance * vertexStride; 116 i * Impl::kVertsPerInstance * vertexStride;
118 Impl::Tesselate(verts, vertexStride, fGeoData[i], fOverrides); 117 Impl::Tesselate(verts, vertexStride, fGeoData[i], fOverrides);
(...skipping 25 matching lines...) Expand all
144 return true; 143 return true;
145 } 144 }
146 145
147 GrXPOverridesForBatch fOverrides; 146 GrXPOverridesForBatch fOverrides;
148 SkSTArray<1, Geometry, true> fGeoData; 147 SkSTArray<1, Geometry, true> fGeoData;
149 148
150 typedef GrVertexBatch INHERITED; 149 typedef GrVertexBatch INHERITED;
151 }; 150 };
152 151
153 #endif 152 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698