blob: 0574bfc9374f77c0450fee32081ed2e131c50dca [file] [log] [blame]
bsalomon@google.coma8e686e2011-08-16 15:45:58 +00001
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
bsalomon@google.comd4726202012-08-03 14:34:46 +00009// This is a GPU-backend specific test. It relies on static intializers to work
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +000010
bsalomon@google.com2a48c3a2012-08-03 14:54:45 +000011#include "SkTypes.h"
12
13#if SK_SUPPORT_GPU && SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
14
bsalomon@google.com396e61f2012-10-25 19:00:29 +000015#include "GrBackendEffectFactory.h"
bsalomon@google.com67b915d2013-02-04 16:13:32 +000016#include "GrContextFactory.h"
bsalomon@google.coma04e8e82012-08-27 12:53:13 +000017#include "effects/GrConfigConversionEffect.h"
kkinnunenec56e452014-08-25 22:21:16 -070018#include "gl/GrGLPathRendering.h"
tfarina@chromium.org8f6884a2014-01-24 20:56:26 +000019#include "gl/GrGpuGL.h"
bsalomon@google.com2db3ded2013-05-22 14:34:04 +000020#include "SkChecksum.h"
tfarina@chromium.org223137f2012-11-21 22:38:36 +000021#include "SkRandom.h"
bsalomon@google.comc3841b92012-08-02 18:11:43 +000022#include "Test.h"
23
egdaniela7dc0a82014-09-17 08:25:05 -070024static void get_stage_stats(const GrEffectStage stage, bool* readsDst,
25 bool* readsFragPosition, bool* requiresVertexShader) {
26 if (stage.getEffect()->willReadDstColor()) {
27 *readsDst = true;
28 }
29 if (stage.getEffect()->willReadFragmentPosition()) {
30 *readsFragPosition = true;
31 }
32 if (stage.getEffect()->requiresVertexShader()) {
33 *requiresVertexShader = true;
34 }
35}
36
bsalomon848faf02014-07-11 10:01:02 -070037bool GrGLProgramDesc::setRandom(SkRandom* random,
egdanielae444962014-09-22 12:29:52 -070038 GrGpuGL* gpu,
bsalomon@google.com2db3ded2013-05-22 14:34:04 +000039 const GrRenderTarget* dstRenderTarget,
40 const GrTexture* dstCopyTexture,
joshualittbd769d02014-09-04 08:56:46 -070041 const GrEffectStage* geometryProcessor,
bsalomon@google.com2db3ded2013-05-22 14:34:04 +000042 const GrEffectStage* stages[],
43 int numColorStages,
44 int numCoverageStages,
egdanielae444962014-09-22 12:29:52 -070045 int currAttribIndex,
46 GrGpu::DrawType drawType) {
47 bool isPathRendering = GrGpu::IsPathRenderingDrawType(drawType);
48 bool useLocalCoords = !isPathRendering &&
49 random->nextBool() &&
50 currAttribIndex < GrDrawState::kMaxVertexAttribCnt;
bsalomon848faf02014-07-11 10:01:02 -070051
52 int numStages = numColorStages + numCoverageStages;
53 fKey.reset();
54
bsalomon929f29a2014-07-17 07:55:11 -070055 GR_STATIC_ASSERT(0 == kEffectKeyOffsetsAndLengthOffset % sizeof(uint32_t));
bsalomon848faf02014-07-11 10:01:02 -070056
57 // Make room for everything up to and including the array of offsets to effect keys.
joshualittbd769d02014-09-04 08:56:46 -070058 fKey.push_back_n(kEffectKeyOffsetsAndLengthOffset + 2 * sizeof(uint16_t) * (numStages +
59 (geometryProcessor ? 1 : 0)));
bsalomon848faf02014-07-11 10:01:02 -070060
61 bool dstRead = false;
62 bool fragPos = false;
bsalomon49f085d2014-09-05 13:34:00 -070063 bool vertexShader = SkToBool(geometryProcessor);
joshualittbd769d02014-09-04 08:56:46 -070064 int offset = 0;
bsalomon49f085d2014-09-05 13:34:00 -070065 if (geometryProcessor) {
joshualittbd769d02014-09-04 08:56:46 -070066 const GrEffectStage* stage = geometryProcessor;
bsalomon929f29a2014-07-17 07:55:11 -070067 uint16_t* offsetAndSize = reinterpret_cast<uint16_t*>(fKey.begin() +
68 kEffectKeyOffsetsAndLengthOffset +
joshualittbd769d02014-09-04 08:56:46 -070069 offset * 2 * sizeof(uint16_t));
bsalomon929f29a2014-07-17 07:55:11 -070070 uint32_t effectKeyOffset = fKey.count();
71 if (effectKeyOffset > SK_MaxU16) {
bsalomonc0ea3982014-07-15 19:41:17 -070072 fKey.reset();
73 return false;
bsalomon848faf02014-07-11 10:01:02 -070074 }
bsalomon929f29a2014-07-17 07:55:11 -070075 GrEffectKeyBuilder b(&fKey);
76 uint16_t effectKeySize;
egdaniela7dc0a82014-09-17 08:25:05 -070077 if (!GetEffectKey(*stage, gpu->glCaps(), useLocalCoords, &b, &effectKeySize)) {
joshualittbd769d02014-09-04 08:56:46 -070078 fKey.reset();
79 return false;
80 }
egdaniela7dc0a82014-09-17 08:25:05 -070081 get_stage_stats(*stage, &dstRead, &fragPos, &vertexShader);
joshualittbd769d02014-09-04 08:56:46 -070082 offsetAndSize[0] = effectKeyOffset;
83 offsetAndSize[1] = effectKeySize;
84 offset++;
85 }
86
87 for (int s = 0; s < numStages; ++s, ++offset) {
88 const GrEffectStage* stage = stages[s];
89 uint16_t* offsetAndSize = reinterpret_cast<uint16_t*>(fKey.begin() +
90 kEffectKeyOffsetsAndLengthOffset +
91 offset * 2 * sizeof(uint16_t));
92 uint32_t effectKeyOffset = fKey.count();
93 if (effectKeyOffset > SK_MaxU16) {
94 fKey.reset();
95 return false;
96 }
joshualittbd769d02014-09-04 08:56:46 -070097 GrEffectKeyBuilder b(&fKey);
98 uint16_t effectKeySize;
egdaniela7dc0a82014-09-17 08:25:05 -070099 if (!GetEffectKey(*stages[s], gpu->glCaps(), useLocalCoords, &b, &effectKeySize)) {
bsalomon929f29a2014-07-17 07:55:11 -0700100 fKey.reset();
101 return false;
mtklein79401002014-07-16 06:16:43 -0700102 }
egdaniela7dc0a82014-09-17 08:25:05 -0700103 get_stage_stats(*stage, &dstRead, &fragPos, &vertexShader);
bsalomon929f29a2014-07-17 07:55:11 -0700104 offsetAndSize[0] = effectKeyOffset;
105 offsetAndSize[1] = effectKeySize;
bsalomon848faf02014-07-11 10:01:02 -0700106 }
jvanverth@google.com054ae992013-04-01 20:06:51 +0000107
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000108 KeyHeader* header = this->header();
bsalomon848faf02014-07-11 10:01:02 -0700109 memset(header, 0, kHeaderSize);
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000110 header->fEmitsPointSize = random->nextBool();
111
112 header->fPositionAttributeIndex = 0;
jvanverth@google.com054ae992013-04-01 20:06:51 +0000113
skia.committer@gmail.com05a2ee02013-04-02 07:01:34 +0000114 // if the effects have used up all off the available attributes,
jvanverth@google.com054ae992013-04-01 20:06:51 +0000115 // don't try to use color or coverage attributes as input
116 do {
egdanielae444962014-09-22 12:29:52 -0700117 header->fColorInput = static_cast<GrGLProgramDesc::ColorInput>(
118 random->nextULessThan(kColorInputCnt));
119 } while ((GrDrawState::kMaxVertexAttribCnt <= currAttribIndex || isPathRendering) &&
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000120 kAttribute_ColorInput == header->fColorInput);
121 header->fColorAttributeIndex = (header->fColorInput == kAttribute_ColorInput) ?
122 currAttribIndex++ :
123 -1;
jvanverth@google.com054ae992013-04-01 20:06:51 +0000124
125 do {
commit-bot@chromium.org949eef02013-10-01 18:43:29 +0000126 header->fCoverageInput = static_cast<GrGLProgramDesc::ColorInput>(
127 random->nextULessThan(kColorInputCnt));
egdanielae444962014-09-22 12:29:52 -0700128 } while ((GrDrawState::kMaxVertexAttribCnt <= currAttribIndex || isPathRendering) &&
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000129 kAttribute_ColorInput == header->fCoverageInput);
130 header->fCoverageAttributeIndex = (header->fCoverageInput == kAttribute_ColorInput) ?
131 currAttribIndex++ :
132 -1;
bsalomon43d361f2014-09-19 07:47:08 -0700133 bool useGS = random->nextBool();
bsalomon@google.com91207482013-02-12 21:45:24 +0000134#if GR_GL_EXPERIMENTAL_GS
bsalomon43d361f2014-09-19 07:47:08 -0700135 header->fExperimentalGS = gpu->caps()->geometryShaderSupport() && useGS;
136#else
137 (void) useGS;
bsalomon@google.com91207482013-02-12 21:45:24 +0000138#endif
139
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000140 header->fLocalCoordAttributeIndex = useLocalCoords ? currAttribIndex++ : -1;
141
142 header->fColorEffectCnt = numColorStages;
143 header->fCoverageEffectCnt = numCoverageStages;
bsalomon@google.comc7818882013-03-20 19:19:53 +0000144
bsalomon@google.comb79d8652013-03-29 20:30:50 +0000145 if (dstRead) {
joshualitt30ba4362014-08-21 20:18:45 -0700146 header->fDstReadKey = SkToU8(GrGLFragmentShaderBuilder::KeyForDstRead(dstCopyTexture,
bsalomon848faf02014-07-11 10:01:02 -0700147 gpu->glCaps()));
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000148 } else {
149 header->fDstReadKey = 0;
150 }
151 if (fragPos) {
joshualitt30ba4362014-08-21 20:18:45 -0700152 header->fFragPosKey = SkToU8(GrGLFragmentShaderBuilder::KeyForFragmentPosition(dstRenderTarget,
bsalomon848faf02014-07-11 10:01:02 -0700153 gpu->glCaps()));
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000154 } else {
155 header->fFragPosKey = 0;
bsalomon@google.comb79d8652013-03-29 20:30:50 +0000156 }
bsalomon@google.com5920ac22013-04-19 13:14:45 +0000157
egdanielae444962014-09-22 12:29:52 -0700158 header->fUseFragShaderOnly = isPathRendering && gpu->glPathRendering()->texturingMode() ==
159 GrGLPathRendering::FixedFunction_TexturingMode;
joshualittbd769d02014-09-04 08:56:46 -0700160 header->fHasGeometryProcessor = vertexShader;
commit-bot@chromium.org6b30e452013-10-04 20:02:53 +0000161
bsalomon@google.com5920ac22013-04-19 13:14:45 +0000162 CoverageOutput coverageOutput;
163 bool illegalCoverageOutput;
164 do {
165 coverageOutput = static_cast<CoverageOutput>(random->nextULessThan(kCoverageOutputCnt));
166 illegalCoverageOutput = (!gpu->caps()->dualSourceBlendingSupport() &&
167 CoverageOutputUsesSecondaryOutput(coverageOutput)) ||
bsalomon@google.com72993ab2013-04-19 13:25:28 +0000168 (!dstRead && kCombineWithDst_CoverageOutput == coverageOutput);
bsalomon@google.com5920ac22013-04-19 13:14:45 +0000169 } while (illegalCoverageOutput);
170
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000171 header->fCoverageOutput = coverageOutput;
172
bsalomon848faf02014-07-11 10:01:02 -0700173 this->finalize();
174 return true;
bsalomon@google.com91207482013-02-12 21:45:24 +0000175}
176
joshualitt249af152014-09-15 11:41:13 -0700177// TODO clean this up, we have to do this to test geometry processors but there has got to be
178// a better way. In the mean time, we actually fill out these generic vertex attribs below with
179// the correct vertex attribs from the GP. We have to ensure, however, we don't try to add more
180// than two attributes.
181GrVertexAttrib genericVertexAttribs[] = {
182 { kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding },
183 { kVec2f_GrVertexAttribType, 0, kEffect_GrVertexAttribBinding },
184 { kVec2f_GrVertexAttribType, 0, kEffect_GrVertexAttribBinding }
185};
186
187/*
188 * convert sl type to vertexattrib type, not a complete implementation, only use for debugging
189 */
190GrVertexAttribType convert_sltype_to_attribtype(GrSLType type) {
191 switch (type) {
192 case kFloat_GrSLType:
193 return kFloat_GrVertexAttribType;
194 case kVec2f_GrSLType:
195 return kVec2f_GrVertexAttribType;
196 case kVec3f_GrSLType:
197 return kVec3f_GrVertexAttribType;
198 case kVec4f_GrSLType:
199 return kVec4f_GrVertexAttribType;
200 default:
201 SkFAIL("Type isn't convertible");
202 return kFloat_GrVertexAttribType;
203 }
204}
205// TODO end test hack
206
207
bsalomon@google.com042a2862013-02-04 18:39:24 +0000208bool GrGpuGL::programUnitTest(int maxStages) {
209
bsalomon@google.comd4726202012-08-03 14:34:46 +0000210 GrTextureDesc dummyDesc;
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000211 dummyDesc.fFlags = kRenderTarget_GrTextureFlagBit;
bsalomon@google.comfec0bc32013-02-07 14:43:04 +0000212 dummyDesc.fConfig = kSkia8888_GrPixelConfig;
bsalomon@google.comd4726202012-08-03 14:34:46 +0000213 dummyDesc.fWidth = 34;
214 dummyDesc.fHeight = 18;
215 SkAutoTUnref<GrTexture> dummyTexture1(this->createTexture(dummyDesc, NULL, 0));
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000216 dummyDesc.fFlags = kNone_GrTextureFlags;
bsalomon@google.comd4726202012-08-03 14:34:46 +0000217 dummyDesc.fConfig = kAlpha_8_GrPixelConfig;
218 dummyDesc.fWidth = 16;
219 dummyDesc.fHeight = 22;
220 SkAutoTUnref<GrTexture> dummyTexture2(this->createTexture(dummyDesc, NULL, 0));
221
bsalomone904c092014-07-17 10:50:59 -0700222 if (!dummyTexture1 || ! dummyTexture2) {
223 return false;
224 }
225
bsalomon@google.comc3841b92012-08-02 18:11:43 +0000226 static const int NUM_TESTS = 512;
227
commit-bot@chromium.orge0e7cfe2013-09-09 20:09:12 +0000228 SkRandom random;
bsalomon@google.comc3841b92012-08-02 18:11:43 +0000229 for (int t = 0; t < NUM_TESTS; ++t) {
230
231#if 0
232 GrPrintf("\nTest Program %d\n-------------\n", t);
233 static const int stop = -1;
234 if (t == stop) {
235 int breakpointhere = 9;
236 }
237#endif
238
bsalomon@google.com31ec7982013-03-27 18:14:57 +0000239 GrGLProgramDesc pdesc;
bsalomon@google.comc3841b92012-08-02 18:11:43 +0000240
jvanverth@google.com054ae992013-04-01 20:06:51 +0000241 int currAttribIndex = 1; // we need to always leave room for position
commit-bot@chromium.org8e919ad2013-10-21 14:48:23 +0000242 int currTextureCoordSet = 0;
bsalomon@google.comb79d8652013-03-29 20:30:50 +0000243 GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()};
commit-bot@chromium.org9ae78502013-03-21 17:44:39 +0000244
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000245 int numStages = random.nextULessThan(maxStages + 1);
246 int numColorStages = random.nextULessThan(numStages + 1);
247 int numCoverageStages = numStages - numColorStages;
248
249 SkAutoSTMalloc<8, const GrEffectStage*> stages(numStages);
250
egdanielae444962014-09-22 12:29:52 -0700251 bool usePathRendering = this->glCaps().pathRenderingSupport() && random.nextBool();
252
253 GrGpu::DrawType drawType = usePathRendering ? GrGpu::kDrawPath_DrawType :
254 GrGpu::kDrawPoints_DrawType;
commit-bot@chromium.org8e919ad2013-10-21 14:48:23 +0000255
joshualittbd769d02014-09-04 08:56:46 -0700256 SkAutoTDelete<GrEffectStage> geometryProcessor;
egdanielae444962014-09-22 12:29:52 -0700257 bool hasGeometryProcessor = usePathRendering ? false : random.nextBool();
joshualittbd769d02014-09-04 08:56:46 -0700258 if (hasGeometryProcessor) {
259 while (true) {
260 SkAutoTUnref<const GrEffect> effect(GrEffectTestFactory::CreateStage(
261 &random,
262 this->getContext(),
263 *this->caps(),
264 dummyTextures));
265 SkASSERT(effect);
joshualittbd769d02014-09-04 08:56:46 -0700266 // Only geometryProcessor can use vertex shader
267 if (!effect->requiresVertexShader()) {
268 continue;
269 }
270
joshualitt249af152014-09-15 11:41:13 -0700271 GrEffectStage* stage = SkNEW_ARGS(GrEffectStage, (effect.get()));
joshualittbd769d02014-09-04 08:56:46 -0700272 geometryProcessor.reset(stage);
joshualitt249af152014-09-15 11:41:13 -0700273
274 // we have to set dummy vertex attribs
275 const GrEffect::VertexAttribArray& v = effect->getVertexAttribs();
276 int numVertexAttribs = v.count();
277
278 SkASSERT(GrEffect::kMaxVertexAttribs == 2 &&
279 GrEffect::kMaxVertexAttribs >= numVertexAttribs);
280 size_t runningStride = GrVertexAttribTypeSize(genericVertexAttribs[0].fType);
281 for (int i = 0; i < numVertexAttribs; i++) {
282 genericVertexAttribs[i + 1].fOffset = runningStride;
283 genericVertexAttribs[i + 1].fType =
284 convert_sltype_to_attribtype(v[i].getType());
285 runningStride += GrVertexAttribTypeSize(genericVertexAttribs[i + 1].fType);
286 }
287
288 // update the vertex attributes with the ds
289 GrDrawState* ds = this->drawState();
290 ds->setVertexAttribs<genericVertexAttribs>(numVertexAttribs + 1, runningStride);
291 currAttribIndex = numVertexAttribs + 1;
joshualittbd769d02014-09-04 08:56:46 -0700292 break;
293 }
294 }
commit-bot@chromium.org8e919ad2013-10-21 14:48:23 +0000295 for (int s = 0; s < numStages;) {
bsalomon83d081a2014-07-08 09:56:10 -0700296 SkAutoTUnref<const GrEffect> effect(GrEffectTestFactory::CreateStage(
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000297 &random,
298 this->getContext(),
299 *this->caps(),
300 dummyTextures));
commit-bot@chromium.org65ee5f42014-02-04 17:49:48 +0000301 SkASSERT(effect);
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000302
joshualittbd769d02014-09-04 08:56:46 -0700303 // Only geometryProcessor can use vertex shader
304 if (effect->requiresVertexShader()) {
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000305 continue;
bsalomon@google.comc3841b92012-08-02 18:11:43 +0000306 }
commit-bot@chromium.org8e919ad2013-10-21 14:48:23 +0000307
commit-bot@chromium.org8e919ad2013-10-21 14:48:23 +0000308 // If adding this effect would exceed the max texture coord set count then generate a
309 // new random effect.
egdanielae444962014-09-22 12:29:52 -0700310 if (usePathRendering && this->glPathRendering()->texturingMode() ==
311 GrGLPathRendering::FixedFunction_TexturingMode) {;
bsalomon97b9ab72014-07-08 06:52:35 -0700312 int numTransforms = effect->numTransforms();
commit-bot@chromium.org8e919ad2013-10-21 14:48:23 +0000313 if (currTextureCoordSet + numTransforms > this->glCaps().maxFixedFunctionTextureCoords()) {
314 continue;
315 }
316 currTextureCoordSet += numTransforms;
317 }
joshualitt249af152014-09-15 11:41:13 -0700318 GrEffectStage* stage = SkNEW_ARGS(GrEffectStage, (effect.get()));
joshualittbd769d02014-09-04 08:56:46 -0700319
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000320 stages[s] = stage;
commit-bot@chromium.org8e919ad2013-10-21 14:48:23 +0000321 ++s;
bsalomon@google.comc3841b92012-08-02 18:11:43 +0000322 }
bsalomon@google.comb79d8652013-03-29 20:30:50 +0000323 const GrTexture* dstTexture = random.nextBool() ? dummyTextures[0] : dummyTextures[1];
bsalomon848faf02014-07-11 10:01:02 -0700324 if (!pdesc.setRandom(&random,
325 this,
326 dummyTextures[0]->asRenderTarget(),
327 dstTexture,
joshualittbd769d02014-09-04 08:56:46 -0700328 geometryProcessor.get(),
bsalomon848faf02014-07-11 10:01:02 -0700329 stages.get(),
330 numColorStages,
331 numCoverageStages,
egdanielae444962014-09-22 12:29:52 -0700332 currAttribIndex,
333 drawType)) {
bsalomon848faf02014-07-11 10:01:02 -0700334 return false;
335 }
skia.committer@gmail.com05a2ee02013-04-02 07:01:34 +0000336
commit-bot@chromium.org9188a152013-09-05 18:28:24 +0000337 SkAutoTUnref<GrGLProgram> program(GrGLProgram::Create(this,
bsalomon@google.comc3841b92012-08-02 18:11:43 +0000338 pdesc,
joshualittbd769d02014-09-04 08:56:46 -0700339 geometryProcessor.get(),
bsalomon@google.com2c84aa32013-06-06 20:28:57 +0000340 stages,
341 stages + numColorStages));
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000342 for (int s = 0; s < numStages; ++s) {
bsalomon@google.com504976e2013-05-09 13:45:02 +0000343 SkDELETE(stages[s]);
344 }
bsalomon@google.comc3841b92012-08-02 18:11:43 +0000345 if (NULL == program.get()) {
346 return false;
347 }
joshualitt249af152014-09-15 11:41:13 -0700348
349 // We have to reset the drawstate because we might have added a gp
350 this->drawState()->reset();
bsalomon@google.comc3841b92012-08-02 18:11:43 +0000351 }
352 return true;
353}
bsalomon@google.coma8e686e2011-08-16 15:45:58 +0000354
tfarina@chromium.org4ee16bf2014-01-10 22:08:27 +0000355DEF_GPUTEST(GLPrograms, reporter, factory) {
bsalomon@google.com67b915d2013-02-04 16:13:32 +0000356 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
357 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextType>(type));
bsalomon49f085d2014-09-05 13:34:00 -0700358 if (context) {
bsalomon@google.com042a2862013-02-04 18:39:24 +0000359 GrGpuGL* gpu = static_cast<GrGpuGL*>(context->getGpu());
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000360 int maxStages = 6;
bsalomon@google.com042a2862013-02-04 18:39:24 +0000361#if SK_ANGLE
362 // Some long shaders run out of temporary registers in the D3D compiler on ANGLE.
363 if (type == GrContextFactory::kANGLE_GLContextType) {
364 maxStages = 3;
365 }
366#endif
367 REPORTER_ASSERT(reporter, gpu->programUnitTest(maxStages));
bsalomon@google.com67b915d2013-02-04 16:13:32 +0000368 }
369 }
bsalomon@google.coma8e686e2011-08-16 15:45:58 +0000370}
371
rmistry@google.comd6176b02012-08-23 18:14:13 +0000372// This is evil evil evil. The linker may throw away whole translation units as dead code if it
bsalomon@google.com67e78c92012-10-17 13:36:14 +0000373// thinks none of the functions are called. It will do this even if there are static initializers
bsalomon@google.coma1bf0ff2012-08-07 17:36:29 +0000374// in the unit that could pass pointers to functions from the unit out to other translation units!
375// We force some of the effects that would otherwise be discarded to link here.
376
commit-bot@chromium.org40eb3c12014-01-06 23:41:14 +0000377#include "SkAlphaThresholdFilter.h"
tfarina@chromium.org8f6884a2014-01-24 20:56:26 +0000378#include "SkColorMatrixFilter.h"
bsalomon@google.coma1bf0ff2012-08-07 17:36:29 +0000379#include "SkLightingImageFilter.h"
bsalomon@google.com82aa7482012-08-13 14:22:17 +0000380#include "SkMagnifierImageFilter.h"
bsalomon@google.coma1bf0ff2012-08-07 17:36:29 +0000381
382void forceLinking();
383
384void forceLinking() {
385 SkLightingImageFilter::CreateDistantLitDiffuse(SkPoint3(0,0,0), 0, 0, 0);
commit-bot@chromium.org9109e182014-01-07 16:04:01 +0000386 SkAlphaThresholdFilter::Create(SkRegion(), .5f, .5f);
reed9fa60da2014-08-21 07:59:51 -0700387 SkAutoTUnref<SkImageFilter> mag(SkMagnifierImageFilter::Create(
commit-bot@chromium.orgcac5fd52014-03-10 10:51:58 +0000388 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1));
bsalomon@google.comadc65362013-01-28 14:26:09 +0000389 GrConfigConversionEffect::Create(NULL,
390 false,
391 GrConfigConversionEffect::kNone_PMConversion,
392 SkMatrix::I());
bsalomon@google.com67e78c92012-10-17 13:36:14 +0000393 SkScalar matrix[20];
commit-bot@chromium.org727a3522014-02-21 18:46:30 +0000394 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix));
bsalomon@google.coma1bf0ff2012-08-07 17:36:29 +0000395}
396
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +0000397#endif