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

Side by Side Diff: tests/GLProgramsTest.cpp

Issue 791743003: Remove GP from drawstate, revision of invariant output for GP (Closed) Base URL: https://skia.googlesource.com/skia.git@color-to-gp
Patch Set: more windows fix Created 6 years 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/effects/GrTextureDomain.cpp ('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
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 122 }
123 123
124 static void set_random_xpf(GrContext* context, const GrDrawTargetCaps& caps, GrD rawState* ds, 124 static void set_random_xpf(GrContext* context, const GrDrawTargetCaps& caps, GrD rawState* ds,
125 SkRandom* random, GrTexture* dummyTextures[]) { 125 SkRandom* random, GrTexture* dummyTextures[]) {
126 SkAutoTUnref<const GrXPFactory> xpf( 126 SkAutoTUnref<const GrXPFactory> xpf(
127 GrProcessorTestFactory<GrXPFactory>::CreateStage(random, context, caps, dummyTextures)); 127 GrProcessorTestFactory<GrXPFactory>::CreateStage(random, context, caps, dummyTextures));
128 SkASSERT(xpf); 128 SkASSERT(xpf);
129 ds->setXPFactory(xpf.get()); 129 ds->setXPFactory(xpf.get());
130 } 130 }
131 131
132 static void set_random_gp(GrContext* context, 132 static const GrGeometryProcessor* get_random_gp(GrContext* context,
133 const GrDrawTargetCaps& caps, 133 const GrDrawTargetCaps& caps,
134 GrDrawState* ds, 134 SkRandom* random,
135 SkRandom* random, 135 GrTexture* dummyTextures[]) {
136 GrTexture* dummyTextures[]) { 136 return GrProcessorTestFactory<GrGeometryProcessor>::CreateStage(random,
137 SkAutoTUnref<const GrGeometryProcessor> gp( 137 context,
138 GrProcessorTestFactory<GrGeometryProcessor>::CreateStage(random, 138 caps,
139 context, 139 dummyTexture s);
140 caps,
141 dummyTextur es));
142 SkASSERT(gp);
143
144 ds->setGeometryProcessor(gp);
145 } 140 }
146 141
147 static void set_random_color_coverage_stages(GrGpuGL* gpu, 142 static void set_random_color_coverage_stages(GrGpuGL* gpu,
148 GrDrawState* ds, 143 GrDrawState* ds,
149 int maxStages, 144 int maxStages,
150 bool usePathRendering, 145 bool usePathRendering,
151 SkRandom* random, 146 SkRandom* random,
152 GrTexture* dummyTextures[]) { 147 GrTexture* dummyTextures[]) {
153 int numProcs = random->nextULessThan(maxStages + 1); 148 int numProcs = random->nextULessThan(maxStages + 1);
154 int numColorProcs = random->nextULessThan(numProcs + 1); 149 int numColorProcs = random->nextULessThan(numProcs + 1);
(...skipping 27 matching lines...) Expand all
182 // finally add the stage to the correct pipeline in the drawstate 177 // finally add the stage to the correct pipeline in the drawstate
183 if (s < numColorProcs) { 178 if (s < numColorProcs) {
184 ds->addColorProcessor(fp); 179 ds->addColorProcessor(fp);
185 } else { 180 } else {
186 ds->addCoverageProcessor(fp); 181 ds->addCoverageProcessor(fp);
187 } 182 }
188 ++s; 183 ++s;
189 } 184 }
190 } 185 }
191 186
192 static void set_random_hints(GrDrawState* ds, SkRandom* random) {
193 for (int i = 1; i <= GrDrawState::kLast_Hint; i <<= 1) {
194 ds->setHint(GrDrawState::Hints(i), random->nextBool());
195 }
196 }
197
198 static void set_random_state(GrDrawState* ds, SkRandom* random) { 187 static void set_random_state(GrDrawState* ds, SkRandom* random) {
199 int state = 0; 188 int state = 0;
200 for (int i = 1; i <= GrDrawState::kLast_StateBit; i <<= 1) { 189 for (int i = 1; i <= GrDrawState::kLast_StateBit; i <<= 1) {
201 state |= random->nextBool() * i; 190 state |= random->nextBool() * i;
202 } 191 }
203 ds->enableState(state); 192 ds->enableState(state);
204 } 193 }
205 194
206 // right now, the only thing we seem to care about in drawState's stencil is 'do esWrite()' 195 // right now, the only thing we seem to care about in drawState's stencil is 'do esWrite()'
207 static void set_random_stencil(GrDrawState* ds, SkRandom* random) { 196 static void set_random_stencil(GrDrawState* ds, SkRandom* random) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 ds.setRenderTarget(rt.get()); 275 ds.setRenderTarget(rt.get());
287 276
288 // if path rendering we have to setup a couple of things like the draw t ype 277 // if path rendering we have to setup a couple of things like the draw t ype
289 bool usePathRendering = gpu->glCaps().pathRenderingSupport() && random.n extBool(); 278 bool usePathRendering = gpu->glCaps().pathRenderingSupport() && random.n extBool();
290 279
291 GrGpu::DrawType drawType = usePathRendering ? GrGpu::kDrawPath_DrawType : 280 GrGpu::DrawType drawType = usePathRendering ? GrGpu::kDrawPath_DrawType :
292 GrGpu::kDrawPoints_DrawTyp e; 281 GrGpu::kDrawPoints_DrawTyp e;
293 282
294 // twiddle drawstate knobs randomly 283 // twiddle drawstate knobs randomly
295 bool hasGeometryProcessor = !usePathRendering; 284 bool hasGeometryProcessor = !usePathRendering;
285 const GrGeometryProcessor* gp = NULL;
286 const GrPathProcessor* pathProc = NULL;
296 if (hasGeometryProcessor) { 287 if (hasGeometryProcessor) {
297 set_random_gp(fContext, gpu->glCaps(), &ds, &random, dummyTextures); 288 gp = get_random_gp(fContext, gpu->glCaps(), &random, dummyTextures);
289 } else {
290 pathProc = GrPathProcessor::Create(GrColor_WHITE);
298 } 291 }
299 set_random_color_coverage_stages(gpu, 292 set_random_color_coverage_stages(gpu,
300 &ds, 293 &ds,
301 maxStages - hasGeometryProcessor, 294 maxStages - hasGeometryProcessor,
302 usePathRendering, 295 usePathRendering,
303 &random, 296 &random,
304 dummyTextures); 297 dummyTextures);
305 298
306 // creates a random xfer processor factory on the draw state 299 // creates a random xfer processor factory on the draw state
307 set_random_xpf(fContext, gpu->glCaps(), &ds, &random, dummyTextures); 300 set_random_xpf(fContext, gpu->glCaps(), &ds, &random, dummyTextures);
308 301
309 set_random_hints(&ds, &random);
310 set_random_state(&ds, &random); 302 set_random_state(&ds, &random);
311 set_random_stencil(&ds, &random); 303 set_random_stencil(&ds, &random);
312 304
313 GrDeviceCoordTexture dstCopy; 305 GrDeviceCoordTexture dstCopy;
314 306
315 // TODO take color off the PP when its installed 307 const GrPrimitiveProcessor* primProc;
316 GrColor color = ds.hasGeometryProcessor() ? ds.getGeometryProcessor()->g etColor() : 308 if (hasGeometryProcessor) {
317 GrColor_WHITE; 309 primProc = gp;
318 uint8_t coverage = ds.hasGeometryProcessor() ? ds.getGeometryProcessor() ->getCoverage() : 310 } else {
319 0xff; 311 primProc = pathProc;
320 if (!this->setupDstReadIfNecessary(&ds, color, coverage, &dstCopy, NULL) ) { 312 }
313 if (!this->setupDstReadIfNecessary(&ds, primProc, &dstCopy, NULL)) {
321 SkDebugf("Couldn't setup dst read texture"); 314 SkDebugf("Couldn't setup dst read texture");
322 return false; 315 return false;
323 } 316 }
324 317
325 // create optimized draw state, setup readDst texture if required, and b uild a descriptor 318 // create optimized draw state, setup readDst texture if required, and b uild a descriptor
326 // and program. ODS creation can fail, so we have to check 319 // and program. ODS creation can fail, so we have to check
327 GrOptDrawState ods(ds, color, coverage, *gpu->caps(), scissor, &dstCopy, drawType); 320 GrOptDrawState ods(ds, gp, pathProc, *gpu->caps(), scissor, &dstCopy, dr awType);
328 if (ods.mustSkip()) { 321 if (ods.mustSkip()) {
329 continue; 322 continue;
330 } 323 }
331 ods.finalize(gpu); 324 ods.finalize(gpu);
332 SkAutoTUnref<GrGLProgram> program(GrGLProgramBuilder::CreateProgram(ods, gpu)); 325 SkAutoTUnref<GrGLProgram> program(GrGLProgramBuilder::CreateProgram(ods, gpu));
333 if (NULL == program.get()) { 326 if (NULL == program.get()) {
334 SkDebugf("Failed to create program!"); 327 SkDebugf("Failed to create program!");
335 return false; 328 return false;
336 } 329 }
337 330
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 } 363 }
371 #endif 364 #endif
372 GrTestTarget target; 365 GrTestTarget target;
373 context->getTestTarget(&target); 366 context->getTestTarget(&target);
374 REPORTER_ASSERT(reporter, target.target()->programUnitTest(maxStages )); 367 REPORTER_ASSERT(reporter, target.target()->programUnitTest(maxStages ));
375 } 368 }
376 } 369 }
377 } 370 }
378 371
379 #endif 372 #endif
OLDNEW
« no previous file with comments | « src/gpu/effects/GrTextureDomain.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698