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

Side by Side Diff: tests/GLProgramsTest.cpp

Issue 13327008: Fix GLPrograms test. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGLProgramDesc.h ('k') | no next file » | 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 /* 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 "gl/GrGpuGL.h" 15 #include "gl/GrGpuGL.h"
16 #include "GrBackendEffectFactory.h" 16 #include "GrBackendEffectFactory.h"
17 #include "GrContextFactory.h" 17 #include "GrContextFactory.h"
18 #include "GrDrawEffect.h" 18 #include "GrDrawEffect.h"
19 #include "effects/GrConfigConversionEffect.h" 19 #include "effects/GrConfigConversionEffect.h"
20 20
21 #include "SkRandom.h" 21 #include "SkRandom.h"
22 #include "Test.h" 22 #include "Test.h"
23 23
24 void GrGLProgramDesc::setRandom(SkMWCRandom* random, 24 void GrGLProgramDesc::setRandom(SkMWCRandom* random,
25 const GrGpuGL* gpu, 25 const GrGpuGL* gpu,
26 const GrTexture* dstTexture,
26 const GrEffectStage stages[GrDrawState::kNumStag es]) { 27 const GrEffectStage stages[GrDrawState::kNumStag es]) {
27 fAttribBindings = 0; 28 fAttribBindings = 0;
28 fEmitsPointSize = random->nextBool(); 29 fEmitsPointSize = random->nextBool();
29 fColorInput = random->nextULessThan(kColorInputCnt); 30 fColorInput = random->nextULessThan(kColorInputCnt);
30 fCoverageInput = random->nextULessThan(kColorInputCnt); 31 fCoverageInput = random->nextULessThan(kColorInputCnt);
31 32
32 fColorFilterXfermode = random->nextULessThan(SkXfermode::kCoeffModesCnt); 33 fColorFilterXfermode = random->nextULessThan(SkXfermode::kCoeffModesCnt);
33 34
34 fFirstCoverageStage = random->nextULessThan(GrDrawState::kNumStages); 35 fFirstCoverageStage = random->nextULessThan(GrDrawState::kNumStages);
35 36
36 fAttribBindings |= random->nextBool() ? GrDrawState::kCoverage_AttribBinding sBit : 0; 37 fAttribBindings |= random->nextBool() ? GrDrawState::kCoverage_AttribBinding sBit : 0;
37 38
38 #if GR_GL_EXPERIMENTAL_GS 39 #if GR_GL_EXPERIMENTAL_GS
39 fExperimentalGS = gpu->caps()->geometryShaderSupport() && random->nextBool() ; 40 fExperimentalGS = gpu->caps()->geometryShaderSupport() && random->nextBool() ;
40 #endif 41 #endif
41 42
42 fDiscardIfZeroCoverage = random->nextBool(); 43 fDiscardIfZeroCoverage = random->nextBool();
43 44
44 if (gpu->caps()->dualSourceBlendingSupport()) { 45 if (gpu->caps()->dualSourceBlendingSupport()) {
45 fDualSrcOutput = random->nextULessThan(kDualSrcOutputCnt); 46 fDualSrcOutput = random->nextULessThan(kDualSrcOutputCnt);
46 } else { 47 } else {
47 fDualSrcOutput = kNone_DualSrcOutput; 48 fDualSrcOutput = kNone_DualSrcOutput;
48 } 49 }
49 50
50 // use separate tex coords? 51 // use separate tex coords?
51 if (random->nextBool()) { 52 if (random->nextBool()) {
52 fAttribBindings |= GrDrawState::kLocalCoords_AttribBindingsBit; 53 fAttribBindings |= GrDrawState::kLocalCoords_AttribBindingsBit;
53 } 54 }
54 55
56 bool dstRead = false;
55 for (int s = 0; s < GrDrawState::kNumStages; ++s) { 57 for (int s = 0; s < GrDrawState::kNumStages; ++s) {
56 if (NULL != stages[s].getEffect()) { 58 if (NULL != stages[s].getEffect()) {
57 const GrBackendEffectFactory& factory = (*stages[s].getEffect())->ge tFactory(); 59 const GrBackendEffectFactory& factory = (*stages[s].getEffect())->ge tFactory();
58 bool explicitLocalCoords = (fAttribBindings & 60 bool explicitLocalCoords = (fAttribBindings &
59 GrDrawState::kLocalCoords_AttribBindings Bit); 61 GrDrawState::kLocalCoords_AttribBindings Bit);
60 GrDrawEffect drawEffect(stages[s], explicitLocalCoords); 62 GrDrawEffect drawEffect(stages[s], explicitLocalCoords);
61 fEffectKeys[s] = factory.glEffectKey(drawEffect, gpu->glCaps()); 63 fEffectKeys[s] = factory.glEffectKey(drawEffect, gpu->glCaps());
64 if ((*stages[s].getEffect())->willReadDst()) {
65 dstRead = true;
66 }
62 } 67 }
63 } 68 }
64 69
70 if (dstRead) {
71 this->fDstRead = GrGLShaderBuilder::KeyForDstRead(dstTexture, gpu->glCap s());
72 }
73
65 int attributeIndex = 0; 74 int attributeIndex = 0;
66 fPositionAttributeIndex = attributeIndex; 75 fPositionAttributeIndex = attributeIndex;
67 ++attributeIndex; 76 ++attributeIndex;
68 if (fColorInput || (fAttribBindings & GrDrawState::kColor_AttribBindingsBit) ) { 77 if (fColorInput || (fAttribBindings & GrDrawState::kColor_AttribBindingsBit) ) {
69 fColorAttributeIndex = attributeIndex; 78 fColorAttributeIndex = attributeIndex;
70 ++attributeIndex; 79 ++attributeIndex;
71 } 80 }
72 if (fCoverageInput || (fAttribBindings & GrDrawState::kCoverage_AttribBindin gsBit)) { 81 if (fCoverageInput || (fAttribBindings & GrDrawState::kCoverage_AttribBindin gsBit)) {
73 fCoverageAttributeIndex = attributeIndex; 82 fCoverageAttributeIndex = attributeIndex;
74 ++attributeIndex; 83 ++attributeIndex;
(...skipping 29 matching lines...) Expand all
104 if (t == stop) { 113 if (t == stop) {
105 int breakpointhere = 9; 114 int breakpointhere = 9;
106 } 115 }
107 #endif 116 #endif
108 117
109 GrGLProgramDesc pdesc; 118 GrGLProgramDesc pdesc;
110 GrEffectStage stages[GrDrawState::kNumStages]; 119 GrEffectStage stages[GrDrawState::kNumStages];
111 120
112 int currAttribIndex = GrDrawState::kAttribIndexCount; 121 int currAttribIndex = GrDrawState::kAttribIndexCount;
113 int attribIndices[2]; 122 int attribIndices[2];
123 GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()};
114 for (int s = 0; s < maxStages; ++s) { 124 for (int s = 0; s < maxStages; ++s) {
115 // enable the stage? 125 // enable the stage?
116 if (random.nextBool()) { 126 if (random.nextBool()) {
117 GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2 .get()};
118 SkAutoTUnref<const GrEffectRef> effect(GrEffectTestFactory::Crea teStage( 127 SkAutoTUnref<const GrEffectRef> effect(GrEffectTestFactory::Crea teStage(
119 &random, 128 &random,
120 this->getContext(), 129 this->getContext(),
121 *this->caps(), 130 *this->caps(),
122 dummyTextures)); 131 dummyTextures));
123 int numAttribs = (*effect)->numVertexAttribs(); 132 int numAttribs = (*effect)->numVertexAttribs();
124 133
125 // If adding this effect would cause to exceed the max attrib co unt then generate a 134 // If adding this effect would cause to exceed the max attrib co unt then generate a
126 // new random effect. The explanation for why this check is corr ect is a bit 135 // new random effect. The explanation for why this check is corr ect is a bit
127 // convoluted and this code will be removed soon. 136 // convoluted and this code will be removed soon.
128 if (currAttribIndex + numAttribs > GrDrawState::kCoverageOverrid eAttribIndexValue) { 137 if (currAttribIndex + numAttribs > GrDrawState::kCoverageOverrid eAttribIndexValue) {
129 --s; 138 --s;
130 continue; 139 continue;
131 } 140 }
132 for (int i = 0; i < numAttribs; ++i) { 141 for (int i = 0; i < numAttribs; ++i) {
133 attribIndices[i] = currAttribIndex++; 142 attribIndices[i] = currAttribIndex++;
134 } 143 }
135 stages[s].setEffect(effect.get(), attribIndices[0], attribIndice s[1]); 144 stages[s].setEffect(effect.get(), attribIndices[0], attribIndice s[1]);
136 } 145 }
137 } 146 }
138 pdesc.setRandom(&random, this, stages); 147 const GrTexture* dstTexture = random.nextBool() ? dummyTextures[0] : dum myTextures[1];
148 pdesc.setRandom(&random, this, dstTexture, stages);
139 149
140 const GrEffectStage* stagePtrs[GrDrawState::kNumStages]; 150 const GrEffectStage* stagePtrs[GrDrawState::kNumStages];
141 for (int s = 0; s < GrDrawState::kNumStages; ++s) { 151 for (int s = 0; s < GrDrawState::kNumStages; ++s) {
142 stagePtrs[s] = &stages[s]; 152 stagePtrs[s] = &stages[s];
143 } 153 }
144 SkAutoTUnref<GrGLProgram> program(GrGLProgram::Create(this->glContext(), 154 SkAutoTUnref<GrGLProgram> program(GrGLProgram::Create(this->glContext(),
145 pdesc, 155 pdesc,
146 stagePtrs)); 156 stagePtrs));
147 if (NULL == program.get()) { 157 if (NULL == program.get()) {
148 return false; 158 return false;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 SkMagnifierImageFilter mag(SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar 1); 197 SkMagnifierImageFilter mag(SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar 1);
188 GrConfigConversionEffect::Create(NULL, 198 GrConfigConversionEffect::Create(NULL,
189 false, 199 false,
190 GrConfigConversionEffect::kNone_PMConversio n, 200 GrConfigConversionEffect::kNone_PMConversio n,
191 SkMatrix::I()); 201 SkMatrix::I());
192 SkScalar matrix[20]; 202 SkScalar matrix[20];
193 SkColorMatrixFilter cmf(matrix); 203 SkColorMatrixFilter cmf(matrix);
194 } 204 }
195 205
196 #endif 206 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgramDesc.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698