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

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

Issue 815643005: Move program descriptor and primitive processor off of optstate (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: bug fix Created 5 years, 11 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/GrOptDrawState.h ('k') | src/gpu/GrTest.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 2014 Google Inc. 2 * Copyright 2014 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 "GrOptDrawState.h" 8 #include "GrOptDrawState.h"
9 9
10 #include "GrDrawState.h" 10 #include "GrDrawState.h"
11 #include "GrDrawTargetCaps.h" 11 #include "GrDrawTargetCaps.h"
12 #include "GrGpu.h" 12 #include "GrGpu.h"
13 #include "GrProcOptInfo.h" 13 #include "GrProcOptInfo.h"
14 #include "GrXferProcessor.h" 14 #include "GrXferProcessor.h"
15 15
16 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, 16 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
17 const GrPrimitiveProcessor* primProc, 17 const GrPrimitiveProcessor* primProc,
18 const GrDrawTargetCaps& caps, 18 const GrDrawTargetCaps& caps,
19 const GrScissorState& scissorState, 19 const GrScissorState& scissorState,
20 const GrDeviceCoordTexture* dstCopy, 20 const GrDeviceCoordTexture* dstCopy,
21 GrGpu::DrawType drawType) 21 GrGpu::DrawType drawType) {
22 : fFinalized(false) {
23 fDrawType = drawType; 22 fDrawType = drawType;
24 23
25 fPrimitiveProcessor.reset(primProc); 24 const GrProcOptInfo& colorPOI = drawState.colorProcInfo(primProc);
26 25 const GrProcOptInfo& coveragePOI = drawState.coverageProcInfo(primProc);
27
28 const GrProcOptInfo& colorPOI = drawState.colorProcInfo(fPrimitiveProcessor) ;
29 const GrProcOptInfo& coveragePOI = drawState.coverageProcInfo(fPrimitiveProc essor);
30 26
31 // Create XferProcessor from DS's XPFactory 27 // Create XferProcessor from DS's XPFactory
32 SkAutoTUnref<GrXferProcessor> xferProcessor( 28 SkAutoTUnref<GrXferProcessor> xferProcessor(
33 drawState.getXPFactory()->createXferProcessor(colorPOI, coveragePOI)); 29 drawState.getXPFactory()->createXferProcessor(colorPOI, coveragePOI));
34 30
35 GrColor overrideColor = GrColor_ILLEGAL; 31 GrColor overrideColor = GrColor_ILLEGAL;
36 if (colorPOI.firstEffectiveStageIndex() != 0) { 32 if (colorPOI.firstEffectiveStageIndex() != 0) {
37 overrideColor = colorPOI.inputColorToEffectiveStage(); 33 overrideColor = colorPOI.inputColorToEffectiveStage();
38 } 34 }
39 35
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 fNumColorStages = fFragmentStages.count(); 101 fNumColorStages = fFragmentStages.count();
106 for (int i = firstCoverageStageIdx; i < drawState.numCoverageStages(); ++i) { 102 for (int i = firstCoverageStageIdx; i < drawState.numCoverageStages(); ++i) {
107 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, 103 SkNEW_APPEND_TO_TARRAY(&fFragmentStages,
108 GrPendingFragmentStage, 104 GrPendingFragmentStage,
109 (drawState.fCoverageStages[i])); 105 (drawState.fCoverageStages[i]));
110 usesLocalCoords = usesLocalCoords || 106 usesLocalCoords = usesLocalCoords ||
111 drawState.fCoverageStages[i].processor()->usesLocalCoo rds(); 107 drawState.fCoverageStages[i].processor()->usesLocalCoo rds();
112 } 108 }
113 109
114 // let the GP init the batch tracker 110 // let the GP init the batch tracker
115 GrGeometryProcessor::InitBT init; 111 fInitBT.fColorIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreColor_Op tFlag);
116 init.fColorIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreColor_OptFl ag); 112 fInitBT.fOverrideColor = fInitBT.fColorIgnored ? GrColor_ILLEGAL : overrideC olor;
117 init.fOverrideColor = init.fColorIgnored ? GrColor_ILLEGAL : overrideColor; 113 fInitBT.fCoverageIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreCover age_OptFlag);
118 init.fCoverageIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreCoverage _OptFlag); 114 fInitBT.fUsesLocalCoords = usesLocalCoords;
119 init.fUsesLocalCoords = usesLocalCoords;
120 fPrimitiveProcessor->initBatchTracker(&fBatchTracker, init);
121 } 115 }
122 116
123 void GrOptDrawState::adjustProgramFromOptimizations(const GrDrawState& ds, 117 void GrOptDrawState::adjustProgramFromOptimizations(const GrDrawState& ds,
124 GrXferProcessor::OptFlags fl ags, 118 GrXferProcessor::OptFlags fl ags,
125 const GrProcOptInfo& colorPO I, 119 const GrProcOptInfo& colorPO I,
126 const GrProcOptInfo& coverag ePOI, 120 const GrProcOptInfo& coverag ePOI,
127 int* firstColorStageIdx, 121 int* firstColorStageIdx,
128 int* firstCoverageStageIdx) { 122 int* firstCoverageStageIdx) {
129 fDescInfo.fReadsFragPosition = false; 123 fDescInfo.fReadsFragPosition = false;
130 124
131 if ((flags & GrXferProcessor::kIgnoreColor_OptFlag) || 125 if ((flags & GrXferProcessor::kIgnoreColor_OptFlag) ||
132 (flags & GrXferProcessor::kOverrideColor_OptFlag)) { 126 (flags & GrXferProcessor::kOverrideColor_OptFlag)) {
133 *firstColorStageIdx = ds.numColorStages(); 127 *firstColorStageIdx = ds.numColorStages();
134 } else { 128 } else {
135 fDescInfo.fReadsFragPosition = colorPOI.readsFragPosition(); 129 fDescInfo.fReadsFragPosition = colorPOI.readsFragPosition();
136 } 130 }
137 131
138 if (flags & GrXferProcessor::kIgnoreCoverage_OptFlag) { 132 if (flags & GrXferProcessor::kIgnoreCoverage_OptFlag) {
139 *firstCoverageStageIdx = ds.numCoverageStages(); 133 *firstCoverageStageIdx = ds.numCoverageStages();
140 } else { 134 } else {
141 if (coveragePOI.readsFragPosition()) { 135 if (coveragePOI.readsFragPosition()) {
142 fDescInfo.fReadsFragPosition = true; 136 fDescInfo.fReadsFragPosition = true;
143 } 137 }
144 } 138 }
145 } 139 }
146 140
147 void GrOptDrawState::finalize(GrGpu* gpu) {
148 gpu->buildProgramDesc(*this, fDescInfo, fDrawType, &fDesc);
149 fFinalized = true;
150 }
151
152 //////////////////////////////////////////////////////////////////////////////// 141 ////////////////////////////////////////////////////////////////////////////////
153 142
154 bool GrOptDrawState::combineIfPossible(const GrOptDrawState& that) { 143 bool GrOptDrawState::isEqual(const GrOptDrawState& that) const {
155 if (fDescInfo != that.fDescInfo) {
156 return false;
157 }
158
159 if (this->getRenderTarget() != that.getRenderTarget() || 144 if (this->getRenderTarget() != that.getRenderTarget() ||
160 this->fFragmentStages.count() != that.fFragmentStages.count() || 145 this->fFragmentStages.count() != that.fFragmentStages.count() ||
161 this->fNumColorStages != that.fNumColorStages || 146 this->fNumColorStages != that.fNumColorStages ||
162 this->fScissorState != that.fScissorState || 147 this->fScissorState != that.fScissorState ||
163 this->fDrawType != that.fDrawType || 148 this->fDrawType != that.fDrawType ||
164 this->fFlags != that.fFlags || 149 this->fFlags != that.fFlags ||
165 this->fStencilSettings != that.fStencilSettings || 150 this->fStencilSettings != that.fStencilSettings ||
166 this->fDrawFace != that.fDrawFace || 151 this->fDrawFace != that.fDrawFace ||
167 this->fDstCopy.texture() != that.fDstCopy.texture()) { 152 this->fDstCopy.texture() != that.fDstCopy.texture()) {
168 return false; 153 return false;
169 } 154 }
170 155
171 if (!this->getPrimitiveProcessor()->canMakeEqual(fBatchTracker,
172 *that.getPrimitiveProcessor (),
173 that.getBatchTracker())) {
174 return false;
175 }
176
177 if (!this->getXferProcessor()->isEqual(*that.getXferProcessor())) { 156 if (!this->getXferProcessor()->isEqual(*that.getXferProcessor())) {
178 return false; 157 return false;
179 } 158 }
180 159
181 // The program desc comparison should have already assured that the stage co unts match. 160 // The program desc comparison should have already assured that the stage co unts match.
182 SkASSERT(this->numFragmentStages() == that.numFragmentStages()); 161 SkASSERT(this->numFragmentStages() == that.numFragmentStages());
183 for (int i = 0; i < this->numFragmentStages(); i++) { 162 for (int i = 0; i < this->numFragmentStages(); i++) {
184 163
185 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { 164 if (this->getFragmentStage(i) != that.getFragmentStage(i)) {
186 return false; 165 return false;
187 } 166 }
188 } 167 }
189
190 // Now update the GrPrimitiveProcessor's batch tracker
191 fPrimitiveProcessor->makeEqual(&fBatchTracker, that.getBatchTracker());
192 return true; 168 return true;
193 } 169 }
194 170
OLDNEW
« no previous file with comments | « src/gpu/GrOptDrawState.h ('k') | src/gpu/GrTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698