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

Side by Side Diff: tests/GLProgramsTest.cpp

Issue 554833002: Calculate Primary and Secondary output types in the GrOptDrawState (Closed) Base URL: https://skia.googlesource.com/skia.git@optReadDst
Patch Set: Rebase Created 6 years, 3 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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 // This is a GPU-backend specific test. It relies on static intializers to work 9 // This is a GPU-backend specific test. It relies on static intializers to work
10 10
11 #include "SkTypes.h" 11 #include "SkTypes.h"
12 12
13 #if SK_SUPPORT_GPU && SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 13 #if SK_SUPPORT_GPU && SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
14 14
15 #include "GrBackendEffectFactory.h" 15 #include "GrBackendEffectFactory.h"
16 #include "GrContextFactory.h" 16 #include "GrContextFactory.h"
17 #include "GrOptDrawState.h"
17 #include "effects/GrConfigConversionEffect.h" 18 #include "effects/GrConfigConversionEffect.h"
18 #include "gl/GrGLPathRendering.h" 19 #include "gl/GrGLPathRendering.h"
19 #include "gl/GrGpuGL.h" 20 #include "gl/GrGpuGL.h"
20 #include "SkChecksum.h" 21 #include "SkChecksum.h"
21 #include "SkRandom.h" 22 #include "SkRandom.h"
22 #include "Test.h" 23 #include "Test.h"
23 24
24 static void get_stage_stats(const GrEffectStage stage, bool* readsDst, 25 static void get_stage_stats(const GrEffectStage stage, bool* readsDst,
25 bool* readsFragPosition, bool* requiresVertexShader) { 26 bool* readsFragPosition, bool* requiresVertexShader) {
26 if (stage.getEffect()->willReadDstColor()) { 27 if (stage.getEffect()->willReadDstColor()) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } else { 151 } else {
151 header->fFragPosKey = 0; 152 header->fFragPosKey = 0;
152 } 153 }
153 154
154 header->fRequiresVertexShader = vertexShader || 155 header->fRequiresVertexShader = vertexShader ||
155 useLocalCoords || 156 useLocalCoords ||
156 kAttribute_ColorInput == header->fColorInput || 157 kAttribute_ColorInput == header->fColorInput ||
157 kAttribute_ColorInput == header->fCoverageIn put; 158 kAttribute_ColorInput == header->fCoverageIn put;
158 header->fHasGeometryProcessor = vertexShader; 159 header->fHasGeometryProcessor = vertexShader;
159 160
160 CoverageOutput coverageOutput; 161 GrOptDrawState::PrimaryOutputType primaryOutput;
bsalomon 2014/09/17 19:47:42 At some point this has to turn into build a random
egdaniel 2014/09/18 15:24:37 Yes I definitely agree. Let's wait till we finaliz
161 bool illegalCoverageOutput; 162 GrOptDrawState::SecondaryOutputType secondaryOutput;
162 do { 163 if (!dstRead) {
163 coverageOutput = static_cast<CoverageOutput>(random->nextULessThan(kCove rageOutputCnt)); 164 primaryOutput = GrOptDrawState::kModulate_PrimaryOutputType;
164 illegalCoverageOutput = (!gpu->caps()->dualSourceBlendingSupport() && 165 } else {
165 CoverageOutputUsesSecondaryOutput(coverageOutpu t)) || 166 primaryOutput = static_cast<GrOptDrawState::PrimaryOutputType>(
166 (!dstRead && kCombineWithDst_CoverageOutput == c overageOutput); 167 random->nextULessThan(GrOptDrawState::kPrimaryOutputTypeCnt));
167 } while (illegalCoverageOutput); 168 }
168 169
169 header->fCoverageOutput = coverageOutput; 170 if (GrOptDrawState::kCombineWithDst_PrimaryOutputType == primaryOutput ||
171 !gpu->caps()->dualSourceBlendingSupport()) {
172 secondaryOutput = GrOptDrawState::kNone_SecondaryOutputType;
173 } else {
174 secondaryOutput = static_cast<GrOptDrawState::SecondaryOutputType>(
175 random->nextULessThan(GrOptDrawState::kSecondaryOutputTypeCnt));
176 }
177
178 header->fPrimaryOutputType = primaryOutput;
179 header->fSecondaryOutputType = secondaryOutput;
170 180
171 this->finalize(); 181 this->finalize();
172 return true; 182 return true;
173 } 183 }
174 184
175 // TODO clean this up, we have to do this to test geometry processors but there has got to be 185 // TODO clean this up, we have to do this to test geometry processors but there has got to be
176 // a better way. In the mean time, we actually fill out these generic vertex at tribs below with 186 // a better way. In the mean time, we actually fill out these generic vertex at tribs below with
177 // the correct vertex attribs from the GP. We have to ensure, however, we don't try to add more 187 // the correct vertex attribs from the GP. We have to ensure, however, we don't try to add more
178 // than two attributes. 188 // than two attributes.
179 GrVertexAttrib genericVertexAttribs[] = { 189 GrVertexAttrib genericVertexAttribs[] = {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1)); 393 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1));
384 GrConfigConversionEffect::Create(NULL, 394 GrConfigConversionEffect::Create(NULL,
385 false, 395 false,
386 GrConfigConversionEffect::kNone_PMConversio n, 396 GrConfigConversionEffect::kNone_PMConversio n,
387 SkMatrix::I()); 397 SkMatrix::I());
388 SkScalar matrix[20]; 398 SkScalar matrix[20];
389 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix)); 399 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix));
390 } 400 }
391 401
392 #endif 402 #endif
OLDNEW
« src/gpu/GrOptDrawState.h ('K') | « src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698