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

Side by Side Diff: src/gpu/instanced/InstancedRendering.cpp

Issue 2182783004: Add test configs for instanced rendering (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add test configs for instanced rendering Created 4 years, 4 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/instanced/InstancedRendering.h ('k') | src/gpu/vk/GrVkGpu.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 2016 Google Inc. 2 * Copyright 2016 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 "InstancedRendering.h" 8 #include "InstancedRendering.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
11 #include "GrCaps.h" 11 #include "GrCaps.h"
12 #include "GrPipeline.h" 12 #include "GrPipeline.h"
13 #include "GrResourceProvider.h" 13 #include "GrResourceProvider.h"
14 #include "instanced/InstanceProcessor.h" 14 #include "instanced/InstanceProcessor.h"
15 15
16 namespace gr_instanced { 16 namespace gr_instanced {
17 17
18 InstancedRendering::InstancedRendering(GrGpu* gpu, AntialiasMode lastSupportedAA Mode, 18 InstancedRendering::InstancedRendering(GrGpu* gpu)
19 bool canRenderToFloat)
20 : fGpu(SkRef(gpu)), 19 : fGpu(SkRef(gpu)),
21 fLastSupportedAAMode(lastSupportedAAMode),
22 fCanRenderToFloat(canRenderToFloat),
23 fState(State::kRecordingDraws), 20 fState(State::kRecordingDraws),
24 fDrawPool(1024 * sizeof(Batch::Draw), 1024 * sizeof(Batch::Draw)) { 21 fDrawPool(1024 * sizeof(Batch::Draw), 1024 * sizeof(Batch::Draw)) {
25 } 22 }
26 23
27 GrDrawBatch* InstancedRendering::recordRect(const SkRect& rect, const SkMatrix& viewMatrix, 24 GrDrawBatch* InstancedRendering::recordRect(const SkRect& rect, const SkMatrix& viewMatrix,
28 GrColor color, bool antialias, 25 GrColor color, bool antialias,
29 const GrInstancedPipelineInfo& info, bool* useHWAA) { 26 const GrInstancedPipelineInfo& info, bool* useHWAA) {
30 return this->recordShape(ShapeType::kRect, rect, viewMatrix, color, rect, an tialias, info, 27 return this->recordShape(ShapeType::kRect, rect, viewMatrix, color, rect, an tialias, info,
31 useHWAA); 28 useHWAA);
32 } 29 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 97 }
101 98
102 InstancedRendering::Batch* InstancedRendering::recordShape(ShapeType type, const SkRect& bounds, 99 InstancedRendering::Batch* InstancedRendering::recordShape(ShapeType type, const SkRect& bounds,
103 const SkMatrix& viewM atrix, 100 const SkMatrix& viewM atrix,
104 GrColor color, const SkRect& localRect, 101 GrColor color, const SkRect& localRect,
105 bool antialias, 102 bool antialias,
106 const GrInstancedPipe lineInfo& info, 103 const GrInstancedPipe lineInfo& info,
107 bool* useHWAA) { 104 bool* useHWAA) {
108 SkASSERT(State::kRecordingDraws == fState); 105 SkASSERT(State::kRecordingDraws == fState);
109 106
110 if (info.fIsRenderingToFloat && !fCanRenderToFloat) { 107 if (info.fIsRenderingToFloat && fGpu->caps()->avoidInstancedDrawsToFPTargets ()) {
111 return nullptr; 108 return nullptr;
112 } 109 }
113 110
114 AntialiasMode antialiasMode; 111 AntialiasMode antialiasMode;
115 if (!this->selectAntialiasMode(viewMatrix, antialias, info, useHWAA, &antial iasMode)) { 112 if (!this->selectAntialiasMode(viewMatrix, antialias, info, useHWAA, &antial iasMode)) {
116 return nullptr; 113 return nullptr;
117 } 114 }
118 115
119 Batch* batch = this->createBatch(); 116 Batch* batch = this->createBatch();
120 batch->fInfo.fAntialiasMode = antialiasMode; 117 batch->fInfo.fAntialiasMode = antialiasMode;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 191
195 batch->fPixelLoad = batch->bounds().height() * batch->bounds().width(); 192 batch->fPixelLoad = batch->bounds().height() * batch->bounds().width();
196 return batch; 193 return batch;
197 } 194 }
198 195
199 inline bool InstancedRendering::selectAntialiasMode(const SkMatrix& viewMatrix, bool antialias, 196 inline bool InstancedRendering::selectAntialiasMode(const SkMatrix& viewMatrix, bool antialias,
200 const GrInstancedPipelineInf o& info, 197 const GrInstancedPipelineInf o& info,
201 bool* useHWAA, AntialiasMode * antialiasMode) { 198 bool* useHWAA, AntialiasMode * antialiasMode) {
202 SkASSERT(!info.fColorDisabled || info.fDrawingShapeToStencil); 199 SkASSERT(!info.fColorDisabled || info.fDrawingShapeToStencil);
203 SkASSERT(!info.fIsMixedSampled || info.fIsMultisampled); 200 SkASSERT(!info.fIsMixedSampled || info.fIsMultisampled);
201 SkASSERT(GrCaps::InstancedSupport::kNone != fGpu->caps()->instancedSupport() );
204 202
205 if (!info.fIsMultisampled || fGpu->caps()->multisampleDisableSupport()) { 203 if (!info.fIsMultisampled || fGpu->caps()->multisampleDisableSupport()) {
206 SkASSERT(fLastSupportedAAMode >= AntialiasMode::kCoverage);
207 if (!antialias) { 204 if (!antialias) {
208 if (info.fDrawingShapeToStencil && !info.fCanDiscard) { 205 if (info.fDrawingShapeToStencil && !info.fCanDiscard) {
209 // We can't draw to the stencil buffer without discard (or sampl e mask if MSAA). 206 // We can't draw to the stencil buffer without discard (or sampl e mask if MSAA).
210 return false; 207 return false;
211 } 208 }
212 *antialiasMode = AntialiasMode::kNone; 209 *antialiasMode = AntialiasMode::kNone;
213 *useHWAA = false; 210 *useHWAA = false;
214 return true; 211 return true;
215 } 212 }
216 213
217 if (info.canUseCoverageAA() && viewMatrix.preservesRightAngles()) { 214 if (info.canUseCoverageAA() && viewMatrix.preservesRightAngles()) {
218 *antialiasMode = AntialiasMode::kCoverage; 215 *antialiasMode = AntialiasMode::kCoverage;
219 *useHWAA = false; 216 *useHWAA = false;
220 return true; 217 return true;
221 } 218 }
222 } 219 }
223 220
224 if (info.fIsMultisampled && fLastSupportedAAMode >= AntialiasMode::kMSAA) { 221 if (info.fIsMultisampled &&
222 fGpu->caps()->instancedSupport() >= GrCaps::InstancedSupport::kMultisamp led) {
225 if (!info.fIsMixedSampled || info.fColorDisabled) { 223 if (!info.fIsMixedSampled || info.fColorDisabled) {
226 *antialiasMode = AntialiasMode::kMSAA; 224 *antialiasMode = AntialiasMode::kMSAA;
227 *useHWAA = true; 225 *useHWAA = true;
228 return true; 226 return true;
229 } 227 }
230 if (fLastSupportedAAMode >= AntialiasMode::kMixedSamples) { 228 if (fGpu->caps()->instancedSupport() >= GrCaps::InstancedSupport::kMixed Sampled) {
231 *antialiasMode = AntialiasMode::kMixedSamples; 229 *antialiasMode = AntialiasMode::kMixedSamples;
232 *useHWAA = true; 230 *useHWAA = true;
233 return true; 231 return true;
234 } 232 }
235 } 233 }
236 234
237 return false; 235 return false;
238 } 236 }
239 237
240 InstancedRendering::Batch::Batch(uint32_t classID, InstancedRendering* ir) 238 InstancedRendering::Batch::Batch(uint32_t classID, InstancedRendering* ir)
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 } 487 }
490 488
491 void InstancedRendering::resetGpuResources(ResetType resetType) { 489 void InstancedRendering::resetGpuResources(ResetType resetType) {
492 fVertexBuffer.reset(); 490 fVertexBuffer.reset();
493 fIndexBuffer.reset(); 491 fIndexBuffer.reset();
494 fParamsBuffer.reset(); 492 fParamsBuffer.reset();
495 this->onResetGpuResources(resetType); 493 this->onResetGpuResources(resetType);
496 } 494 }
497 495
498 } 496 }
OLDNEW
« no previous file with comments | « src/gpu/instanced/InstancedRendering.h ('k') | src/gpu/vk/GrVkGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698