2011-08-16 15:45:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2012-08-03 14:34:46 +00:00
|
|
|
// This is a GPU-backend specific test. It relies on static intializers to work
|
2012-08-02 14:03:32 +00:00
|
|
|
|
2012-08-03 14:54:45 +00:00
|
|
|
#include "SkTypes.h"
|
|
|
|
|
|
|
|
#if SK_SUPPORT_GPU && SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
|
|
|
|
|
2012-10-25 19:00:29 +00:00
|
|
|
#include "GrBackendEffectFactory.h"
|
2013-02-04 16:13:32 +00:00
|
|
|
#include "GrContextFactory.h"
|
2012-08-27 12:53:13 +00:00
|
|
|
#include "effects/GrConfigConversionEffect.h"
|
2014-08-26 05:21:16 +00:00
|
|
|
#include "gl/GrGLPathRendering.h"
|
2014-01-24 20:56:26 +00:00
|
|
|
#include "gl/GrGpuGL.h"
|
2013-05-22 14:34:04 +00:00
|
|
|
#include "SkChecksum.h"
|
2012-11-21 22:38:36 +00:00
|
|
|
#include "SkRandom.h"
|
2012-08-02 18:11:43 +00:00
|
|
|
#include "Test.h"
|
|
|
|
|
2014-09-17 15:25:05 +00:00
|
|
|
static void get_stage_stats(const GrEffectStage stage, bool* readsDst,
|
|
|
|
bool* readsFragPosition, bool* requiresVertexShader) {
|
|
|
|
if (stage.getEffect()->willReadDstColor()) {
|
|
|
|
*readsDst = true;
|
|
|
|
}
|
|
|
|
if (stage.getEffect()->willReadFragmentPosition()) {
|
|
|
|
*readsFragPosition = true;
|
|
|
|
}
|
|
|
|
if (stage.getEffect()->requiresVertexShader()) {
|
|
|
|
*requiresVertexShader = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-11 17:01:02 +00:00
|
|
|
bool GrGLProgramDesc::setRandom(SkRandom* random,
|
2013-03-27 18:14:57 +00:00
|
|
|
const GrGpuGL* gpu,
|
2013-05-22 14:34:04 +00:00
|
|
|
const GrRenderTarget* dstRenderTarget,
|
|
|
|
const GrTexture* dstCopyTexture,
|
2014-09-04 15:56:46 +00:00
|
|
|
const GrEffectStage* geometryProcessor,
|
2013-05-22 14:34:04 +00:00
|
|
|
const GrEffectStage* stages[],
|
|
|
|
int numColorStages,
|
|
|
|
int numCoverageStages,
|
2013-04-01 20:06:51 +00:00
|
|
|
int currAttribIndex) {
|
2014-07-11 17:01:02 +00:00
|
|
|
bool useLocalCoords = random->nextBool() && currAttribIndex < GrDrawState::kMaxVertexAttribCnt;
|
|
|
|
|
|
|
|
int numStages = numColorStages + numCoverageStages;
|
|
|
|
fKey.reset();
|
|
|
|
|
2014-07-17 14:55:11 +00:00
|
|
|
GR_STATIC_ASSERT(0 == kEffectKeyOffsetsAndLengthOffset % sizeof(uint32_t));
|
2014-07-11 17:01:02 +00:00
|
|
|
|
|
|
|
// Make room for everything up to and including the array of offsets to effect keys.
|
2014-09-04 15:56:46 +00:00
|
|
|
fKey.push_back_n(kEffectKeyOffsetsAndLengthOffset + 2 * sizeof(uint16_t) * (numStages +
|
|
|
|
(geometryProcessor ? 1 : 0)));
|
2014-07-11 17:01:02 +00:00
|
|
|
|
|
|
|
bool dstRead = false;
|
|
|
|
bool fragPos = false;
|
2014-09-05 20:34:00 +00:00
|
|
|
bool vertexShader = SkToBool(geometryProcessor);
|
2014-09-04 15:56:46 +00:00
|
|
|
int offset = 0;
|
2014-09-05 20:34:00 +00:00
|
|
|
if (geometryProcessor) {
|
2014-09-04 15:56:46 +00:00
|
|
|
const GrEffectStage* stage = geometryProcessor;
|
2014-07-17 14:55:11 +00:00
|
|
|
uint16_t* offsetAndSize = reinterpret_cast<uint16_t*>(fKey.begin() +
|
|
|
|
kEffectKeyOffsetsAndLengthOffset +
|
2014-09-04 15:56:46 +00:00
|
|
|
offset * 2 * sizeof(uint16_t));
|
2014-07-17 14:55:11 +00:00
|
|
|
uint32_t effectKeyOffset = fKey.count();
|
|
|
|
if (effectKeyOffset > SK_MaxU16) {
|
|
|
|
fKey.reset();
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-11 17:01:02 +00:00
|
|
|
GrEffectKeyBuilder b(&fKey);
|
2014-07-17 14:55:11 +00:00
|
|
|
uint16_t effectKeySize;
|
2014-09-17 15:25:05 +00:00
|
|
|
if (!GetEffectKey(*stage, gpu->glCaps(), useLocalCoords, &b, &effectKeySize)) {
|
2014-09-04 15:56:46 +00:00
|
|
|
fKey.reset();
|
|
|
|
return false;
|
|
|
|
}
|
2014-09-17 15:25:05 +00:00
|
|
|
get_stage_stats(*stage, &dstRead, &fragPos, &vertexShader);
|
2014-09-04 15:56:46 +00:00
|
|
|
offsetAndSize[0] = effectKeyOffset;
|
|
|
|
offsetAndSize[1] = effectKeySize;
|
|
|
|
offset++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int s = 0; s < numStages; ++s, ++offset) {
|
|
|
|
const GrEffectStage* stage = stages[s];
|
|
|
|
uint16_t* offsetAndSize = reinterpret_cast<uint16_t*>(fKey.begin() +
|
|
|
|
kEffectKeyOffsetsAndLengthOffset +
|
|
|
|
offset * 2 * sizeof(uint16_t));
|
|
|
|
uint32_t effectKeyOffset = fKey.count();
|
|
|
|
if (effectKeyOffset > SK_MaxU16) {
|
|
|
|
fKey.reset();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
GrEffectKeyBuilder b(&fKey);
|
|
|
|
uint16_t effectKeySize;
|
2014-09-17 15:25:05 +00:00
|
|
|
if (!GetEffectKey(*stages[s], gpu->glCaps(), useLocalCoords, &b, &effectKeySize)) {
|
2014-07-11 17:01:02 +00:00
|
|
|
fKey.reset();
|
|
|
|
return false;
|
|
|
|
}
|
2014-09-17 15:25:05 +00:00
|
|
|
get_stage_stats(*stage, &dstRead, &fragPos, &vertexShader);
|
2014-07-17 14:55:11 +00:00
|
|
|
offsetAndSize[0] = effectKeyOffset;
|
|
|
|
offsetAndSize[1] = effectKeySize;
|
2014-07-11 17:01:02 +00:00
|
|
|
}
|
2013-04-01 20:06:51 +00:00
|
|
|
|
2013-05-22 14:34:04 +00:00
|
|
|
KeyHeader* header = this->header();
|
2014-07-11 17:01:02 +00:00
|
|
|
memset(header, 0, kHeaderSize);
|
2013-05-22 14:34:04 +00:00
|
|
|
header->fEmitsPointSize = random->nextBool();
|
|
|
|
|
|
|
|
header->fPositionAttributeIndex = 0;
|
2013-04-01 20:06:51 +00:00
|
|
|
|
2013-04-02 07:01:34 +00:00
|
|
|
// if the effects have used up all off the available attributes,
|
2013-04-01 20:06:51 +00:00
|
|
|
// don't try to use color or coverage attributes as input
|
|
|
|
do {
|
2014-07-21 18:37:28 +00:00
|
|
|
uint32_t colorRand = random->nextULessThan(2);
|
|
|
|
header->fColorInput = (0 == colorRand) ? GrGLProgramDesc::kAttribute_ColorInput :
|
|
|
|
GrGLProgramDesc::kUniform_ColorInput;
|
2013-04-02 07:01:34 +00:00
|
|
|
} while (GrDrawState::kMaxVertexAttribCnt <= currAttribIndex &&
|
2013-05-22 14:34:04 +00:00
|
|
|
kAttribute_ColorInput == header->fColorInput);
|
2014-07-11 17:01:02 +00:00
|
|
|
|
2013-05-22 14:34:04 +00:00
|
|
|
header->fColorAttributeIndex = (header->fColorInput == kAttribute_ColorInput) ?
|
|
|
|
currAttribIndex++ :
|
|
|
|
-1;
|
2013-04-01 20:06:51 +00:00
|
|
|
|
|
|
|
do {
|
2013-10-01 18:43:29 +00:00
|
|
|
header->fCoverageInput = static_cast<GrGLProgramDesc::ColorInput>(
|
|
|
|
random->nextULessThan(kColorInputCnt));
|
2013-04-01 20:06:51 +00:00
|
|
|
} while (GrDrawState::kMaxVertexAttribCnt <= currAttribIndex &&
|
2013-05-22 14:34:04 +00:00
|
|
|
kAttribute_ColorInput == header->fCoverageInput);
|
|
|
|
header->fCoverageAttributeIndex = (header->fCoverageInput == kAttribute_ColorInput) ?
|
|
|
|
currAttribIndex++ :
|
|
|
|
-1;
|
2014-09-19 14:47:08 +00:00
|
|
|
bool useGS = random->nextBool();
|
2013-02-12 21:45:24 +00:00
|
|
|
#if GR_GL_EXPERIMENTAL_GS
|
2014-09-19 14:47:08 +00:00
|
|
|
header->fExperimentalGS = gpu->caps()->geometryShaderSupport() && useGS;
|
|
|
|
#else
|
|
|
|
(void) useGS;
|
2013-02-12 21:45:24 +00:00
|
|
|
#endif
|
|
|
|
|
2013-05-22 14:34:04 +00:00
|
|
|
header->fLocalCoordAttributeIndex = useLocalCoords ? currAttribIndex++ : -1;
|
|
|
|
|
|
|
|
header->fColorEffectCnt = numColorStages;
|
|
|
|
header->fCoverageEffectCnt = numCoverageStages;
|
2013-03-20 19:19:53 +00:00
|
|
|
|
2013-03-29 20:30:50 +00:00
|
|
|
if (dstRead) {
|
2014-08-22 03:18:45 +00:00
|
|
|
header->fDstReadKey = SkToU8(GrGLFragmentShaderBuilder::KeyForDstRead(dstCopyTexture,
|
2014-07-11 17:01:02 +00:00
|
|
|
gpu->glCaps()));
|
2013-05-22 14:34:04 +00:00
|
|
|
} else {
|
|
|
|
header->fDstReadKey = 0;
|
|
|
|
}
|
|
|
|
if (fragPos) {
|
2014-08-22 03:18:45 +00:00
|
|
|
header->fFragPosKey = SkToU8(GrGLFragmentShaderBuilder::KeyForFragmentPosition(dstRenderTarget,
|
2014-07-11 17:01:02 +00:00
|
|
|
gpu->glCaps()));
|
2013-05-22 14:34:04 +00:00
|
|
|
} else {
|
|
|
|
header->fFragPosKey = 0;
|
2013-03-29 20:30:50 +00:00
|
|
|
}
|
2013-04-19 13:14:45 +00:00
|
|
|
|
2014-08-26 05:21:16 +00:00
|
|
|
header->fRequiresVertexShader = vertexShader ||
|
|
|
|
useLocalCoords ||
|
|
|
|
kAttribute_ColorInput == header->fColorInput ||
|
|
|
|
kAttribute_ColorInput == header->fCoverageInput;
|
2014-09-04 15:56:46 +00:00
|
|
|
header->fHasGeometryProcessor = vertexShader;
|
2013-10-04 20:02:53 +00:00
|
|
|
|
2013-04-19 13:14:45 +00:00
|
|
|
CoverageOutput coverageOutput;
|
|
|
|
bool illegalCoverageOutput;
|
|
|
|
do {
|
|
|
|
coverageOutput = static_cast<CoverageOutput>(random->nextULessThan(kCoverageOutputCnt));
|
|
|
|
illegalCoverageOutput = (!gpu->caps()->dualSourceBlendingSupport() &&
|
|
|
|
CoverageOutputUsesSecondaryOutput(coverageOutput)) ||
|
2013-04-19 13:25:28 +00:00
|
|
|
(!dstRead && kCombineWithDst_CoverageOutput == coverageOutput);
|
2013-04-19 13:14:45 +00:00
|
|
|
} while (illegalCoverageOutput);
|
|
|
|
|
2013-05-22 14:34:04 +00:00
|
|
|
header->fCoverageOutput = coverageOutput;
|
|
|
|
|
2014-07-11 17:01:02 +00:00
|
|
|
this->finalize();
|
|
|
|
return true;
|
2013-02-12 21:45:24 +00:00
|
|
|
}
|
|
|
|
|
2014-09-15 18:41:13 +00:00
|
|
|
// TODO clean this up, we have to do this to test geometry processors but there has got to be
|
|
|
|
// a better way. In the mean time, we actually fill out these generic vertex attribs below with
|
|
|
|
// the correct vertex attribs from the GP. We have to ensure, however, we don't try to add more
|
|
|
|
// than two attributes.
|
|
|
|
GrVertexAttrib genericVertexAttribs[] = {
|
|
|
|
{ kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding },
|
|
|
|
{ kVec2f_GrVertexAttribType, 0, kEffect_GrVertexAttribBinding },
|
|
|
|
{ kVec2f_GrVertexAttribType, 0, kEffect_GrVertexAttribBinding }
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* convert sl type to vertexattrib type, not a complete implementation, only use for debugging
|
|
|
|
*/
|
|
|
|
GrVertexAttribType convert_sltype_to_attribtype(GrSLType type) {
|
|
|
|
switch (type) {
|
|
|
|
case kFloat_GrSLType:
|
|
|
|
return kFloat_GrVertexAttribType;
|
|
|
|
case kVec2f_GrSLType:
|
|
|
|
return kVec2f_GrVertexAttribType;
|
|
|
|
case kVec3f_GrSLType:
|
|
|
|
return kVec3f_GrVertexAttribType;
|
|
|
|
case kVec4f_GrSLType:
|
|
|
|
return kVec4f_GrVertexAttribType;
|
|
|
|
default:
|
|
|
|
SkFAIL("Type isn't convertible");
|
|
|
|
return kFloat_GrVertexAttribType;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO end test hack
|
|
|
|
|
|
|
|
|
2013-02-04 18:39:24 +00:00
|
|
|
bool GrGpuGL::programUnitTest(int maxStages) {
|
|
|
|
|
2012-08-03 14:34:46 +00:00
|
|
|
GrTextureDesc dummyDesc;
|
2013-05-22 14:34:04 +00:00
|
|
|
dummyDesc.fFlags = kRenderTarget_GrTextureFlagBit;
|
2013-02-07 14:43:04 +00:00
|
|
|
dummyDesc.fConfig = kSkia8888_GrPixelConfig;
|
2012-08-03 14:34:46 +00:00
|
|
|
dummyDesc.fWidth = 34;
|
|
|
|
dummyDesc.fHeight = 18;
|
|
|
|
SkAutoTUnref<GrTexture> dummyTexture1(this->createTexture(dummyDesc, NULL, 0));
|
2013-05-22 14:34:04 +00:00
|
|
|
dummyDesc.fFlags = kNone_GrTextureFlags;
|
2012-08-03 14:34:46 +00:00
|
|
|
dummyDesc.fConfig = kAlpha_8_GrPixelConfig;
|
|
|
|
dummyDesc.fWidth = 16;
|
|
|
|
dummyDesc.fHeight = 22;
|
|
|
|
SkAutoTUnref<GrTexture> dummyTexture2(this->createTexture(dummyDesc, NULL, 0));
|
|
|
|
|
2014-07-17 17:50:59 +00:00
|
|
|
if (!dummyTexture1 || ! dummyTexture2) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-08-02 18:11:43 +00:00
|
|
|
static const int NUM_TESTS = 512;
|
|
|
|
|
2013-09-09 20:09:12 +00:00
|
|
|
SkRandom random;
|
2012-08-02 18:11:43 +00:00
|
|
|
for (int t = 0; t < NUM_TESTS; ++t) {
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
GrPrintf("\nTest Program %d\n-------------\n", t);
|
|
|
|
static const int stop = -1;
|
|
|
|
if (t == stop) {
|
|
|
|
int breakpointhere = 9;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-03-27 18:14:57 +00:00
|
|
|
GrGLProgramDesc pdesc;
|
2012-08-02 18:11:43 +00:00
|
|
|
|
2013-04-01 20:06:51 +00:00
|
|
|
int currAttribIndex = 1; // we need to always leave room for position
|
2013-10-21 14:48:23 +00:00
|
|
|
int currTextureCoordSet = 0;
|
2013-03-29 20:30:50 +00:00
|
|
|
GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()};
|
2013-05-22 14:34:04 +00:00
|
|
|
|
|
|
|
int numStages = random.nextULessThan(maxStages + 1);
|
|
|
|
int numColorStages = random.nextULessThan(numStages + 1);
|
|
|
|
int numCoverageStages = numStages - numColorStages;
|
|
|
|
|
|
|
|
SkAutoSTMalloc<8, const GrEffectStage*> stages(numStages);
|
|
|
|
|
2014-08-26 05:21:16 +00:00
|
|
|
bool useFixedFunctionPathRendering = this->glCaps().pathRenderingSupport() &&
|
2014-09-04 15:56:46 +00:00
|
|
|
this->glPathRendering()->texturingMode() == GrGLPathRendering::FixedFunction_TexturingMode &&
|
|
|
|
random.nextBool();
|
|
|
|
|
|
|
|
SkAutoTDelete<GrEffectStage> geometryProcessor;
|
|
|
|
bool hasGeometryProcessor = useFixedFunctionPathRendering ? false : random.nextBool();
|
|
|
|
if (hasGeometryProcessor) {
|
|
|
|
while (true) {
|
|
|
|
SkAutoTUnref<const GrEffect> effect(GrEffectTestFactory::CreateStage(
|
|
|
|
&random,
|
|
|
|
this->getContext(),
|
|
|
|
*this->caps(),
|
|
|
|
dummyTextures));
|
|
|
|
SkASSERT(effect);
|
|
|
|
// Only geometryProcessor can use vertex shader
|
|
|
|
if (!effect->requiresVertexShader()) {
|
|
|
|
continue;
|
|
|
|
}
|
2013-10-21 14:48:23 +00:00
|
|
|
|
2014-09-15 18:41:13 +00:00
|
|
|
GrEffectStage* stage = SkNEW_ARGS(GrEffectStage, (effect.get()));
|
2014-09-04 15:56:46 +00:00
|
|
|
geometryProcessor.reset(stage);
|
2014-09-15 18:41:13 +00:00
|
|
|
|
|
|
|
// we have to set dummy vertex attribs
|
|
|
|
const GrEffect::VertexAttribArray& v = effect->getVertexAttribs();
|
|
|
|
int numVertexAttribs = v.count();
|
|
|
|
|
|
|
|
SkASSERT(GrEffect::kMaxVertexAttribs == 2 &&
|
|
|
|
GrEffect::kMaxVertexAttribs >= numVertexAttribs);
|
|
|
|
size_t runningStride = GrVertexAttribTypeSize(genericVertexAttribs[0].fType);
|
|
|
|
for (int i = 0; i < numVertexAttribs; i++) {
|
|
|
|
genericVertexAttribs[i + 1].fOffset = runningStride;
|
|
|
|
genericVertexAttribs[i + 1].fType =
|
|
|
|
convert_sltype_to_attribtype(v[i].getType());
|
|
|
|
runningStride += GrVertexAttribTypeSize(genericVertexAttribs[i + 1].fType);
|
|
|
|
}
|
|
|
|
|
|
|
|
// update the vertex attributes with the ds
|
|
|
|
GrDrawState* ds = this->drawState();
|
|
|
|
ds->setVertexAttribs<genericVertexAttribs>(numVertexAttribs + 1, runningStride);
|
|
|
|
currAttribIndex = numVertexAttribs + 1;
|
2014-09-04 15:56:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-10-21 14:48:23 +00:00
|
|
|
for (int s = 0; s < numStages;) {
|
2014-07-08 16:56:10 +00:00
|
|
|
SkAutoTUnref<const GrEffect> effect(GrEffectTestFactory::CreateStage(
|
2013-05-22 14:34:04 +00:00
|
|
|
&random,
|
|
|
|
this->getContext(),
|
|
|
|
*this->caps(),
|
|
|
|
dummyTextures));
|
2014-02-04 17:49:48 +00:00
|
|
|
SkASSERT(effect);
|
2013-05-22 14:34:04 +00:00
|
|
|
|
2014-09-04 15:56:46 +00:00
|
|
|
// Only geometryProcessor can use vertex shader
|
|
|
|
if (effect->requiresVertexShader()) {
|
2013-05-22 14:34:04 +00:00
|
|
|
continue;
|
|
|
|
}
|
2013-10-21 14:48:23 +00:00
|
|
|
|
|
|
|
// If adding this effect would exceed the max texture coord set count then generate a
|
|
|
|
// new random effect.
|
2014-09-04 15:56:46 +00:00
|
|
|
if (useFixedFunctionPathRendering) {
|
2014-07-08 13:52:35 +00:00
|
|
|
int numTransforms = effect->numTransforms();
|
2013-10-21 14:48:23 +00:00
|
|
|
if (currTextureCoordSet + numTransforms > this->glCaps().maxFixedFunctionTextureCoords()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
currTextureCoordSet += numTransforms;
|
|
|
|
}
|
2014-09-15 18:41:13 +00:00
|
|
|
GrEffectStage* stage = SkNEW_ARGS(GrEffectStage, (effect.get()));
|
2014-09-04 15:56:46 +00:00
|
|
|
|
2013-05-22 14:34:04 +00:00
|
|
|
stages[s] = stage;
|
2013-10-21 14:48:23 +00:00
|
|
|
++s;
|
2012-08-02 18:11:43 +00:00
|
|
|
}
|
2013-03-29 20:30:50 +00:00
|
|
|
const GrTexture* dstTexture = random.nextBool() ? dummyTextures[0] : dummyTextures[1];
|
2014-07-11 17:01:02 +00:00
|
|
|
if (!pdesc.setRandom(&random,
|
|
|
|
this,
|
|
|
|
dummyTextures[0]->asRenderTarget(),
|
|
|
|
dstTexture,
|
2014-09-04 15:56:46 +00:00
|
|
|
geometryProcessor.get(),
|
2014-07-11 17:01:02 +00:00
|
|
|
stages.get(),
|
|
|
|
numColorStages,
|
|
|
|
numCoverageStages,
|
|
|
|
currAttribIndex)) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-04-02 07:01:34 +00:00
|
|
|
|
2013-09-05 18:28:24 +00:00
|
|
|
SkAutoTUnref<GrGLProgram> program(GrGLProgram::Create(this,
|
2012-08-02 18:11:43 +00:00
|
|
|
pdesc,
|
2014-09-04 15:56:46 +00:00
|
|
|
geometryProcessor.get(),
|
2013-06-06 20:28:57 +00:00
|
|
|
stages,
|
|
|
|
stages + numColorStages));
|
2013-05-22 14:34:04 +00:00
|
|
|
for (int s = 0; s < numStages; ++s) {
|
2013-05-09 13:45:02 +00:00
|
|
|
SkDELETE(stages[s]);
|
|
|
|
}
|
2012-08-02 18:11:43 +00:00
|
|
|
if (NULL == program.get()) {
|
|
|
|
return false;
|
|
|
|
}
|
2014-09-15 18:41:13 +00:00
|
|
|
|
|
|
|
// We have to reset the drawstate because we might have added a gp
|
|
|
|
this->drawState()->reset();
|
2012-08-02 18:11:43 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2011-08-16 15:45:58 +00:00
|
|
|
|
2014-01-10 22:08:27 +00:00
|
|
|
DEF_GPUTEST(GLPrograms, reporter, factory) {
|
2013-02-04 16:13:32 +00:00
|
|
|
for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
|
|
|
|
GrContext* context = factory->get(static_cast<GrContextFactory::GLContextType>(type));
|
2014-09-05 20:34:00 +00:00
|
|
|
if (context) {
|
2013-02-04 18:39:24 +00:00
|
|
|
GrGpuGL* gpu = static_cast<GrGpuGL*>(context->getGpu());
|
2013-06-13 19:34:18 +00:00
|
|
|
int maxStages = 6;
|
2013-02-04 18:39:24 +00:00
|
|
|
#if SK_ANGLE
|
|
|
|
// Some long shaders run out of temporary registers in the D3D compiler on ANGLE.
|
|
|
|
if (type == GrContextFactory::kANGLE_GLContextType) {
|
|
|
|
maxStages = 3;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
REPORTER_ASSERT(reporter, gpu->programUnitTest(maxStages));
|
2013-02-04 16:13:32 +00:00
|
|
|
}
|
|
|
|
}
|
2011-08-16 15:45:58 +00:00
|
|
|
}
|
|
|
|
|
2012-08-23 18:14:13 +00:00
|
|
|
// This is evil evil evil. The linker may throw away whole translation units as dead code if it
|
2012-10-17 13:36:14 +00:00
|
|
|
// thinks none of the functions are called. It will do this even if there are static initializers
|
2012-08-07 17:36:29 +00:00
|
|
|
// in the unit that could pass pointers to functions from the unit out to other translation units!
|
|
|
|
// We force some of the effects that would otherwise be discarded to link here.
|
|
|
|
|
2014-01-06 23:41:14 +00:00
|
|
|
#include "SkAlphaThresholdFilter.h"
|
2014-01-24 20:56:26 +00:00
|
|
|
#include "SkColorMatrixFilter.h"
|
2012-08-07 17:36:29 +00:00
|
|
|
#include "SkLightingImageFilter.h"
|
2012-08-13 14:22:17 +00:00
|
|
|
#include "SkMagnifierImageFilter.h"
|
2012-08-07 17:36:29 +00:00
|
|
|
|
|
|
|
void forceLinking();
|
|
|
|
|
|
|
|
void forceLinking() {
|
|
|
|
SkLightingImageFilter::CreateDistantLitDiffuse(SkPoint3(0,0,0), 0, 0, 0);
|
2014-01-07 16:04:01 +00:00
|
|
|
SkAlphaThresholdFilter::Create(SkRegion(), .5f, .5f);
|
2014-08-21 14:59:51 +00:00
|
|
|
SkAutoTUnref<SkImageFilter> mag(SkMagnifierImageFilter::Create(
|
2014-03-10 10:51:58 +00:00
|
|
|
SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1));
|
2013-01-28 14:26:09 +00:00
|
|
|
GrConfigConversionEffect::Create(NULL,
|
|
|
|
false,
|
|
|
|
GrConfigConversionEffect::kNone_PMConversion,
|
|
|
|
SkMatrix::I());
|
2012-10-17 13:36:14 +00:00
|
|
|
SkScalar matrix[20];
|
2014-02-21 18:46:30 +00:00
|
|
|
SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix));
|
2012-08-07 17:36:29 +00:00
|
|
|
}
|
|
|
|
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif
|