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

Side by Side Diff: tests/GLProgramsTest.cpp

Issue 614163002: Force linking of static member variables for GLPrograms (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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
« include/gpu/GrProcessorUnitTest.h ('K') | « src/gpu/GrProcessor.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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 do { 124 do {
125 header->fCoverageInput = static_cast<GrGLProgramDesc::ColorInput>( 125 header->fCoverageInput = static_cast<GrGLProgramDesc::ColorInput>(
126 random->nextULessThan(kColorInputCnt)); 126 random->nextULessThan(kColorInputCnt));
127 } while ((GrDrawState::kMaxVertexAttribCnt <= currAttribIndex || isPathRende ring) && 127 } while ((GrDrawState::kMaxVertexAttribCnt <= currAttribIndex || isPathRende ring) &&
128 kAttribute_ColorInput == header->fCoverageInput); 128 kAttribute_ColorInput == header->fCoverageInput);
129 header->fCoverageAttributeIndex = (header->fCoverageInput == kAttribute_Colo rInput) ? 129 header->fCoverageAttributeIndex = (header->fCoverageInput == kAttribute_Colo rInput) ?
130 currAttribIndex++ : 130 currAttribIndex++ :
131 -1; 131 -1;
132 bool useGS = random->nextBool(); 132 bool useGS = random->nextBool();
133 #if GR_GL_EXPERIMENTAL_GS 133 #if GR_GL_EXPERIMENTAL_GS
134 header->fExperimentalGS = gpu->caps()->geometryShaderSupport() && useGS; 134 header->fExperimentalGS = gpu->caps()->geometryShaderSupport() && useGS &&
bsalomon 2014/10/01 19:40:58 Feel free to delete this entirely.
135 kGL_GrGLStandard == gpu->glStandard();
135 #else 136 #else
136 (void) useGS; 137 (void) useGS;
137 #endif 138 #endif
138 139
139 header->fLocalCoordAttributeIndex = useLocalCoords ? currAttribIndex++ : -1; 140 header->fLocalCoordAttributeIndex = useLocalCoords ? currAttribIndex++ : -1;
140 141
141 header->fColorEffectCnt = numColorStages; 142 header->fColorEffectCnt = numColorStages;
142 header->fCoverageEffectCnt = numCoverageStages; 143 header->fCoverageEffectCnt = numCoverageStages;
143 144
144 if (dstRead) { 145 if (dstRead) {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 dummyTextures[0]->asRenderTarget(), 325 dummyTextures[0]->asRenderTarget(),
325 dstTexture, 326 dstTexture,
326 geometryProcessor.get(), 327 geometryProcessor.get(),
327 stages.get(), 328 stages.get(),
328 numColorStages, 329 numColorStages,
329 numCoverageStages, 330 numCoverageStages,
330 currAttribIndex, 331 currAttribIndex,
331 drawType)) { 332 drawType)) {
332 return false; 333 return false;
333 } 334 }
334
335 SkAutoTUnref<GrGLProgram> program(GrGLProgram::Create(this, 335 SkAutoTUnref<GrGLProgram> program(GrGLProgram::Create(this,
336 pdesc, 336 pdesc,
337 geometryProcessor. get(), 337 geometryProcessor. get(),
338 stages, 338 stages,
339 stages + numColorS tages)); 339 stages + numColorS tages));
340 for (int s = 0; s < numStages; ++s) { 340 for (int s = 0; s < numStages; ++s) {
341 SkDELETE(stages[s]); 341 SkDELETE(stages[s]);
342 } 342 }
343 if (NULL == program.get()) { 343 if (NULL == program.get()) {
344 return false; 344 return false;
345 } 345 }
346
347 // We have to reset the drawstate because we might have added a gp 346 // We have to reset the drawstate because we might have added a gp
348 this->drawState()->reset(); 347 this->drawState()->reset();
349 } 348 }
350 return true; 349 return true;
351 } 350 }
352 351
353 DEF_GPUTEST(GLPrograms, reporter, factory) { 352 DEF_GPUTEST(GLPrograms, reporter, factory) {
354 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { 353 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
355 GrContext* context = factory->get(static_cast<GrContextFactory::GLContex tType>(type)); 354 GrContext* context = factory->get(static_cast<GrContextFactory::GLContex tType>(type));
356 if (context) { 355 if (context) {
357 GrGpuGL* gpu = static_cast<GrGpuGL*>(context->getGpu()); 356 GrGpuGL* gpu = static_cast<GrGpuGL*>(context->getGpu());
358 int maxStages = 6; 357 /*
358 * For the time being, we only support the test with desktop GL or f or android on
359 * ARM platforms
360 * TODO When we run ES 3.00 GLSL in more places, test again
361 */
362 int maxStages;
robertphillips 2014/10/01 19:45:56 This line alignment is a bit odd.
363 if (kGL_GrGLStandard == gpu->glStandard() ||
364 kARM_GrGLVendor == gpu->ctxInfo().vendor()) {
365 maxStages = 6;
366 } else if (kTegra3_GrGLRenderer == gpu->ctxInfo().renderer() ||
367 kOther_GrGLRenderer == gpu->ctxInfo().renderer()) {
368 maxStages = 1;
369 } else {
370 return;
371 }
359 #if SK_ANGLE 372 #if SK_ANGLE
360 // Some long shaders run out of temporary registers in the D3D compi ler on ANGLE. 373 // Some long shaders run out of temporary registers in the D3D compi ler on ANGLE.
361 if (type == GrContextFactory::kANGLE_GLContextType) { 374 if (type == GrContextFactory::kANGLE_GLContextType) {
362 maxStages = 3; 375 maxStages = 3;
363 } 376 }
364 #endif 377 #endif
365 REPORTER_ASSERT(reporter, gpu->programUnitTest(maxStages)); 378 REPORTER_ASSERT(reporter, gpu->programUnitTest(maxStages));
366 } 379 }
367 } 380 }
368 } 381 }
369 382
370 // This is evil evil evil. The linker may throw away whole translation units as dead code if it
371 // thinks none of the functions are called. It will do this even if there are st atic initializers
372 // in the unit that could pass pointers to functions from the unit out to other translation units!
373 // We force some of the effects that would otherwise be discarded to link here.
374
375 #include "SkAlphaThresholdFilter.h"
376 #include "SkColorMatrixFilter.h"
377 #include "SkLightingImageFilter.h"
378 #include "SkMagnifierImageFilter.h"
379
380 void forceLinking();
381
382 void forceLinking() {
383 SkLightingImageFilter::CreateDistantLitDiffuse(SkPoint3(0,0,0), 0, 0, 0);
384 SkAlphaThresholdFilter::Create(SkRegion(), .5f, .5f);
385 SkAutoTUnref<SkImageFilter> mag(SkMagnifierImageFilter::Create(
386 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1));
387 GrConfigConversionEffect::Create(NULL,
388 false,
389 GrConfigConversionEffect::kNone_PMConversio n,
390 SkMatrix::I());
391 SkScalar matrix[20];
392 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix));
393 }
394
395 #endif 383 #endif
OLDNEW
« include/gpu/GrProcessorUnitTest.h ('K') | « src/gpu/GrProcessor.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698