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

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

Issue 719203002: Add GrProcOptInfo class to track various output information for color and coverage stages. (Closed) Base URL: https://skia.googlesource.com/skia.git@moveIO
Patch Set: Clean up 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
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 "GrDefaultGeoProcFactory.h" 10 #include "GrDefaultGeoProcFactory.h"
11 #include "GrDrawState.h" 11 #include "GrDrawState.h"
12 #include "GrDrawTargetCaps.h" 12 #include "GrDrawTargetCaps.h"
13 #include "GrGpu.h" 13 #include "GrGpu.h"
14 #include "GrInvariantOutput.h" 14 #include "GrProcOptInfo.h"
15 15
16 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, 16 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
17 BlendOptFlags blendOptFlags, 17 BlendOptFlags blendOptFlags,
18 GrBlendCoeff optSrcCoeff, 18 GrBlendCoeff optSrcCoeff,
19 GrBlendCoeff optDstCoeff, 19 GrBlendCoeff optDstCoeff,
20 GrGpu* gpu, 20 GrGpu* gpu,
21 const GrDeviceCoordTexture* dstCopy, 21 const GrDeviceCoordTexture* dstCopy,
22 GrGpu::DrawType drawType) { 22 GrGpu::DrawType drawType) {
23 fRenderTarget.set(SkSafeRef(drawState.getRenderTarget()), kWrite_GrIOType); 23 fRenderTarget.set(SkSafeRef(drawState.getRenderTarget()), kWrite_GrIOType);
24 fColor = drawState.getColor(); 24 fColor = drawState.getColor();
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } else { 232 } else {
233 if (ds.vertexColorsAreOpaque()) { 233 if (ds.vertexColorsAreOpaque()) {
234 color = 0xFF << GrColor_SHIFT_A; 234 color = 0xFF << GrColor_SHIFT_A;
235 flags = kA_GrColorComponentFlag; 235 flags = kA_GrColorComponentFlag;
236 } else { 236 } else {
237 flags = static_cast<GrColorComponentFlags>(0); 237 flags = static_cast<GrColorComponentFlags>(0);
238 // not strictly necessary but we get false alarms from tools about u ninit. 238 // not strictly necessary but we get false alarms from tools about u ninit.
239 color = 0; 239 color = 0;
240 } 240 }
241 } 241 }
242 GrInvariantOutput inout(color, flags, false); 242 GrProcOptInfo poi;
243 243 if (ds.numColorStages() > 0) {
244 poi.calcWithInitialValues(&ds.getColorStage(0), ds.numColorStages(), col or, flags, false);
245 *firstColorStageIdx = poi.firstEffectiveStageIndex();
246 descInfo->fInputColorIsUsed = poi.inputColorIsUsed();
247 fColor = poi.inputColorToEffectiveStage();
248 if (poi.removeVertexAttrib()) {
249 *fixedFunctionVAToRemove |= 0x1 << kColor_GrVertexAttribBinding;
250 }
251 }
252 /*
244 for (int i = 0; i < ds.numColorStages(); ++i) { 253 for (int i = 0; i < ds.numColorStages(); ++i) {
245 const GrFragmentProcessor* fp = ds.getColorStage(i).getProcessor(); 254 const GrFragmentProcessor* fp = ds.getColorStage(i).getProcessor();
246 fp->computeInvariantOutput(&inout); 255 fp->computeInvariantOutput(&inout);
247 if (!inout.willUseInputColor()) { 256 if (!inout.willUseInputColor()) {
248 *firstColorStageIdx = i; 257 *firstColorStageIdx = i;
249 descInfo->fInputColorIsUsed = false; 258 descInfo->fInputColorIsUsed = false;
250 } 259 }
251 if (kRGBA_GrColorComponentFlags == inout.validFlags()) { 260 if (kRGBA_GrColorComponentFlags == inout.validFlags()) {
252 *firstColorStageIdx = i + 1; 261 *firstColorStageIdx = i + 1;
253 fColor = inout.color(); 262 fColor = inout.color();
254 descInfo->fInputColorIsUsed = true; 263 descInfo->fInputColorIsUsed = true;
255 *fixedFunctionVAToRemove |= 0x1 << kColor_GrVertexAttribBinding; 264 *fixedFunctionVAToRemove |= 0x1 << kColor_GrVertexAttribBinding;
256 // Since we are clearing all previous color stages we are in a state where we have found 265 // Since we are clearing all previous color stages we are in a state where we have found
257 // zero stages that don't multiply the inputColor. 266 // zero stages that don't multiply the inputColor.
258 inout.resetNonMulStageFound(); 267 inout.resetNonMulStageFound();
259 } 268 }
260 } 269 }
270 */
261 } 271 }
262 272
263 void GrOptDrawState::computeEffectiveCoverageStages(const GrDrawState& ds, 273 void GrOptDrawState::computeEffectiveCoverageStages(const GrDrawState& ds,
264 GrProgramDesc::DescInfo* des cInfo, 274 GrProgramDesc::DescInfo* des cInfo,
265 int* firstCoverageStageIdx) { 275 int* firstCoverageStageIdx) {
266 // We do not try to optimize out constantColor coverage effects here. It is extremely rare 276 // We do not try to optimize out constantColor coverage effects here. It is extremely rare
267 // to have a coverage effect that returns a constant value for all four chan nels. Thus we 277 // to have a coverage effect that returns a constant value for all four chan nels. Thus we
268 // save having to make extra virtual calls by not checking for it. 278 // save having to make extra virtual calls by not checking for it.
269 279
270 // Don't do any optimizations on coverage stages. It should not be the case where we do not use 280 // Don't do any optimizations on coverage stages. It should not be the case where we do not use
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 bool explicitLocalCoords = this->fDesc.header().fLocalCoordAttributeIndex != -1; 372 bool explicitLocalCoords = this->fDesc.header().fLocalCoordAttributeIndex != -1;
363 for (int i = 0; i < this->numFragmentStages(); i++) { 373 for (int i = 0; i < this->numFragmentStages(); i++) {
364 if (!GrFragmentStage::AreCompatible(this->getFragmentStage(i), that.getF ragmentStage(i), 374 if (!GrFragmentStage::AreCompatible(this->getFragmentStage(i), that.getF ragmentStage(i),
365 explicitLocalCoords)) { 375 explicitLocalCoords)) {
366 return false; 376 return false;
367 } 377 }
368 } 378 }
369 return true; 379 return true;
370 } 380 }
371 381
OLDNEW
« no previous file with comments | « src/gpu/GrInvariantOutput.cpp ('k') | src/gpu/GrPaint.cpp » ('j') | src/gpu/GrProcessor.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698