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
|
|
|
|
|
2013-02-04 16:13:32 +00:00
|
|
|
#include "GrContextFactory.h"
|
2014-11-12 16:35:25 +00:00
|
|
|
#include "GrInvariantOutput.h"
|
2015-01-22 18:16:09 +00:00
|
|
|
#include "GrPipeline.h"
|
2014-11-06 20:57:13 +00:00
|
|
|
#include "GrTest.h"
|
2014-12-09 19:15:43 +00:00
|
|
|
#include "GrXferProcessor.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-11-06 20:57:13 +00:00
|
|
|
#include "effects/GrConfigConversionEffect.h"
|
2014-12-09 19:15:43 +00:00
|
|
|
#include "effects/GrPorterDuffXferProcessor.h"
|
2014-12-22 19:44:19 +00:00
|
|
|
#include "gl/GrGLGpu.h"
|
2014-11-06 20:57:13 +00:00
|
|
|
#include "gl/GrGLPathRendering.h"
|
|
|
|
#include "gl/builders/GrGLProgramBuilder.h"
|
2012-08-02 18:11:43 +00:00
|
|
|
|
2014-10-09 14:25:36 +00:00
|
|
|
/*
|
2014-10-15 18:05:26 +00:00
|
|
|
* A dummy processor which just tries to insert a massive key and verify that it can retrieve the
|
2014-10-09 14:25:36 +00:00
|
|
|
* whole thing correctly
|
|
|
|
*/
|
|
|
|
static const uint32_t kMaxKeySize = 1024;
|
2014-10-07 15:37:36 +00:00
|
|
|
|
2014-12-04 19:35:33 +00:00
|
|
|
class GLBigKeyProcessor : public GrGLFragmentProcessor {
|
|
|
|
public:
|
|
|
|
GLBigKeyProcessor(const GrProcessor&) {}
|
|
|
|
|
|
|
|
virtual void emitCode(GrGLFPBuilder* builder,
|
|
|
|
const GrFragmentProcessor& fp,
|
|
|
|
const char* outputColor,
|
|
|
|
const char* inputColor,
|
|
|
|
const TransformedCoordsArray&,
|
|
|
|
const TextureSamplerArray&) {}
|
|
|
|
|
|
|
|
static void GenKey(const GrProcessor& processor, const GrGLCaps&, GrProcessorKeyBuilder* b) {
|
|
|
|
for (uint32_t i = 0; i < kMaxKeySize; i++) {
|
|
|
|
b->add32(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
typedef GrGLFragmentProcessor INHERITED;
|
|
|
|
};
|
2014-10-07 15:37:36 +00:00
|
|
|
|
2014-10-09 14:25:36 +00:00
|
|
|
class BigKeyProcessor : public GrFragmentProcessor {
|
|
|
|
public:
|
|
|
|
static GrFragmentProcessor* Create() {
|
2014-10-15 18:05:26 +00:00
|
|
|
GR_CREATE_STATIC_PROCESSOR(gBigKeyProcessor, BigKeyProcessor, ())
|
2014-10-09 14:25:36 +00:00
|
|
|
return SkRef(gBigKeyProcessor);
|
2014-10-07 15:37:36 +00:00
|
|
|
}
|
|
|
|
|
2015-01-09 18:06:39 +00:00
|
|
|
const char* name() const SK_OVERRIDE { return "Big Ole Key"; }
|
2014-10-07 15:37:36 +00:00
|
|
|
|
2014-12-04 19:35:33 +00:00
|
|
|
virtual void getGLProcessorKey(const GrGLCaps& caps,
|
|
|
|
GrProcessorKeyBuilder* b) const SK_OVERRIDE {
|
|
|
|
GLBigKeyProcessor::GenKey(*this, caps, b);
|
2014-10-09 14:25:36 +00:00
|
|
|
}
|
2014-10-07 15:37:36 +00:00
|
|
|
|
2015-01-09 18:06:39 +00:00
|
|
|
GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE {
|
2014-12-04 19:35:33 +00:00
|
|
|
return SkNEW_ARGS(GLBigKeyProcessor, (*this));
|
|
|
|
}
|
2014-10-07 15:37:36 +00:00
|
|
|
|
2014-10-09 14:25:36 +00:00
|
|
|
private:
|
2014-12-04 19:35:33 +00:00
|
|
|
BigKeyProcessor() {
|
|
|
|
this->initClassID<BigKeyProcessor>();
|
|
|
|
}
|
2015-01-09 18:06:39 +00:00
|
|
|
bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE { return true; }
|
|
|
|
void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE { }
|
2014-10-07 15:37:36 +00:00
|
|
|
|
2014-10-09 14:25:36 +00:00
|
|
|
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
|
2014-10-07 15:37:36 +00:00
|
|
|
|
2014-10-09 14:25:36 +00:00
|
|
|
typedef GrFragmentProcessor INHERITED;
|
|
|
|
};
|
2014-10-07 15:37:36 +00:00
|
|
|
|
2014-10-09 14:25:36 +00:00
|
|
|
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(BigKeyProcessor);
|
2014-10-07 15:37:36 +00:00
|
|
|
|
2014-10-09 14:25:36 +00:00
|
|
|
GrFragmentProcessor* BigKeyProcessor::TestCreate(SkRandom*,
|
|
|
|
GrContext*,
|
|
|
|
const GrDrawTargetCaps&,
|
|
|
|
GrTexture*[]) {
|
|
|
|
return BigKeyProcessor::Create();
|
|
|
|
}
|
2014-10-07 15:37:36 +00:00
|
|
|
|
2014-10-09 14:25:36 +00:00
|
|
|
/*
|
|
|
|
* Begin test code
|
|
|
|
*/
|
|
|
|
static const int kRenderTargetHeight = 1;
|
|
|
|
static const int kRenderTargetWidth = 1;
|
|
|
|
|
2015-01-23 12:24:04 +00:00
|
|
|
static GrRenderTarget* random_render_target(GrContext* context, SkRandom* random) {
|
2014-10-09 14:25:36 +00:00
|
|
|
// setup render target
|
|
|
|
GrTextureParams params;
|
2014-10-28 21:33:06 +00:00
|
|
|
GrSurfaceDesc texDesc;
|
2014-10-09 14:25:36 +00:00
|
|
|
texDesc.fWidth = kRenderTargetWidth;
|
|
|
|
texDesc.fHeight = kRenderTargetHeight;
|
2014-10-28 21:33:06 +00:00
|
|
|
texDesc.fFlags = kRenderTarget_GrSurfaceFlag;
|
2014-10-09 14:25:36 +00:00
|
|
|
texDesc.fConfig = kRGBA_8888_GrPixelConfig;
|
|
|
|
texDesc.fOrigin = random->nextBool() == true ? kTopLeft_GrSurfaceOrigin :
|
|
|
|
kBottomLeft_GrSurfaceOrigin;
|
2015-01-23 12:24:04 +00:00
|
|
|
GrContentKey key;
|
|
|
|
static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain();
|
|
|
|
GrContentKey::Builder builder(&key, kDomain, 1);
|
|
|
|
builder[0] = texDesc.fOrigin;
|
|
|
|
builder.finish();
|
2014-10-09 14:25:36 +00:00
|
|
|
|
2015-02-02 21:00:10 +00:00
|
|
|
GrTexture* texture = context->findAndRefCachedTexture(key);
|
2014-10-12 12:40:00 +00:00
|
|
|
if (!texture) {
|
2015-02-06 16:49:24 +00:00
|
|
|
texture = context->createTexture(texDesc, true);
|
2015-02-02 21:00:10 +00:00
|
|
|
if (texture) {
|
|
|
|
SkAssertResult(context->addResourceToCache(key, texture));
|
2014-10-09 14:25:36 +00:00
|
|
|
}
|
|
|
|
}
|
2015-02-02 21:00:10 +00:00
|
|
|
return texture ? texture->asRenderTarget() : NULL;
|
2013-02-12 21:45:24 +00:00
|
|
|
}
|
|
|
|
|
2015-01-22 18:16:09 +00:00
|
|
|
static void set_random_xpf(GrContext* context, const GrDrawTargetCaps& caps,
|
|
|
|
GrPipelineBuilder* pipelineBuilder, SkRandom* random,
|
|
|
|
GrTexture* dummyTextures[]) {
|
2014-12-11 21:15:13 +00:00
|
|
|
SkAutoTUnref<const GrXPFactory> xpf(
|
|
|
|
GrProcessorTestFactory<GrXPFactory>::CreateStage(random, context, caps, dummyTextures));
|
|
|
|
SkASSERT(xpf);
|
2015-01-22 18:16:09 +00:00
|
|
|
pipelineBuilder->setXPFactory(xpf.get());
|
2014-12-11 21:15:13 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 23:44:02 +00:00
|
|
|
static const GrGeometryProcessor* get_random_gp(GrContext* context,
|
|
|
|
const GrDrawTargetCaps& caps,
|
|
|
|
SkRandom* random,
|
|
|
|
GrTexture* dummyTextures[]) {
|
|
|
|
return GrProcessorTestFactory<GrGeometryProcessor>::CreateStage(random,
|
|
|
|
context,
|
|
|
|
caps,
|
|
|
|
dummyTextures);
|
2014-10-09 14:25:36 +00:00
|
|
|
}
|
|
|
|
|
2014-12-16 15:33:49 +00:00
|
|
|
static void set_random_color_coverage_stages(GrGLGpu* gpu,
|
2015-01-22 18:16:09 +00:00
|
|
|
GrPipelineBuilder* pipelineBuilder,
|
2014-10-09 14:25:36 +00:00
|
|
|
int maxStages,
|
|
|
|
bool usePathRendering,
|
|
|
|
SkRandom* random,
|
|
|
|
GrTexture* dummyTextures[]) {
|
|
|
|
int numProcs = random->nextULessThan(maxStages + 1);
|
|
|
|
int numColorProcs = random->nextULessThan(numProcs + 1);
|
|
|
|
|
|
|
|
int currTextureCoordSet = 0;
|
|
|
|
for (int s = 0; s < numProcs;) {
|
2014-11-19 16:23:49 +00:00
|
|
|
SkAutoTUnref<const GrFragmentProcessor> fp(
|
2014-10-09 14:25:36 +00:00
|
|
|
GrProcessorTestFactory<GrFragmentProcessor>::CreateStage(random,
|
|
|
|
gpu->getContext(),
|
|
|
|
*gpu->caps(),
|
|
|
|
dummyTextures));
|
|
|
|
SkASSERT(fp);
|
|
|
|
|
|
|
|
// If adding this effect would exceed the max texture coord set count then generate a
|
|
|
|
// new random effect.
|
|
|
|
if (usePathRendering && gpu->glPathRendering()->texturingMode() ==
|
|
|
|
GrGLPathRendering::FixedFunction_TexturingMode) {;
|
|
|
|
int numTransforms = fp->numTransforms();
|
|
|
|
if (currTextureCoordSet + numTransforms >
|
|
|
|
gpu->glCaps().maxFixedFunctionTextureCoords()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
currTextureCoordSet += numTransforms;
|
|
|
|
}
|
|
|
|
|
|
|
|
// finally add the stage to the correct pipeline in the drawstate
|
|
|
|
if (s < numColorProcs) {
|
2015-01-22 18:16:09 +00:00
|
|
|
pipelineBuilder->addColorProcessor(fp);
|
2014-10-09 14:25:36 +00:00
|
|
|
} else {
|
2015-01-22 18:16:09 +00:00
|
|
|
pipelineBuilder->addCoverageProcessor(fp);
|
2014-10-09 14:25:36 +00:00
|
|
|
}
|
|
|
|
++s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-22 18:16:09 +00:00
|
|
|
static void set_random_state(GrPipelineBuilder* pipelineBuilder, SkRandom* random) {
|
2014-10-09 14:25:36 +00:00
|
|
|
int state = 0;
|
2015-01-22 18:16:09 +00:00
|
|
|
for (int i = 1; i <= GrPipelineBuilder::kLast_StateBit; i <<= 1) {
|
2014-10-09 14:25:36 +00:00
|
|
|
state |= random->nextBool() * i;
|
|
|
|
}
|
2015-01-22 18:16:09 +00:00
|
|
|
pipelineBuilder->enableState(state);
|
2014-10-09 14:25:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// right now, the only thing we seem to care about in drawState's stencil is 'doesWrite()'
|
2015-01-22 18:16:09 +00:00
|
|
|
static void set_random_stencil(GrPipelineBuilder* pipelineBuilder, SkRandom* random) {
|
2014-10-09 14:25:36 +00:00
|
|
|
GR_STATIC_CONST_SAME_STENCIL(kDoesWriteStencil,
|
|
|
|
kReplace_StencilOp,
|
|
|
|
kReplace_StencilOp,
|
|
|
|
kAlways_StencilFunc,
|
|
|
|
0xffff,
|
|
|
|
0xffff,
|
|
|
|
0xffff);
|
|
|
|
GR_STATIC_CONST_SAME_STENCIL(kDoesNotWriteStencil,
|
|
|
|
kKeep_StencilOp,
|
|
|
|
kKeep_StencilOp,
|
|
|
|
kNever_StencilFunc,
|
|
|
|
0xffff,
|
|
|
|
0xffff,
|
|
|
|
0xffff);
|
|
|
|
|
|
|
|
if (random->nextBool()) {
|
2015-01-22 18:16:09 +00:00
|
|
|
pipelineBuilder->setStencil(kDoesWriteStencil);
|
2014-10-09 14:25:36 +00:00
|
|
|
} else {
|
2015-01-22 18:16:09 +00:00
|
|
|
pipelineBuilder->setStencil(kDoesNotWriteStencil);
|
2014-10-09 14:25:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-06 20:57:13 +00:00
|
|
|
bool GrDrawTarget::programUnitTest(int maxStages) {
|
2014-12-16 15:33:49 +00:00
|
|
|
GrGLGpu* gpu = static_cast<GrGLGpu*>(fContext->getGpu());
|
2014-10-09 14:25:36 +00:00
|
|
|
// setup dummy textures
|
2014-10-28 21:33:06 +00:00
|
|
|
GrSurfaceDesc dummyDesc;
|
|
|
|
dummyDesc.fFlags = kRenderTarget_GrSurfaceFlag;
|
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;
|
2015-01-14 18:42:08 +00:00
|
|
|
SkAutoTUnref<GrTexture> dummyTexture1(gpu->createTexture(dummyDesc, false, NULL, 0));
|
2014-10-28 21:33:06 +00:00
|
|
|
dummyDesc.fFlags = kNone_GrSurfaceFlags;
|
2012-08-03 14:34:46 +00:00
|
|
|
dummyDesc.fConfig = kAlpha_8_GrPixelConfig;
|
|
|
|
dummyDesc.fWidth = 16;
|
|
|
|
dummyDesc.fHeight = 22;
|
2015-01-14 18:42:08 +00:00
|
|
|
SkAutoTUnref<GrTexture> dummyTexture2(gpu->createTexture(dummyDesc, false, NULL, 0));
|
2012-08-03 14:34:46 +00:00
|
|
|
|
2014-07-17 17:50:59 +00:00
|
|
|
if (!dummyTexture1 || ! dummyTexture2) {
|
2014-10-09 14:25:36 +00:00
|
|
|
SkDebugf("Could not allocate dummy textures");
|
2014-07-17 17:50:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-10-09 14:25:36 +00:00
|
|
|
GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()};
|
2012-08-02 18:11:43 +00:00
|
|
|
|
2014-11-19 17:38:51 +00:00
|
|
|
// dummy scissor state
|
2014-12-17 21:43:13 +00:00
|
|
|
GrScissorState scissor;
|
2014-11-19 17:38:51 +00:00
|
|
|
|
2014-10-09 14:25:36 +00:00
|
|
|
// setup clip
|
2014-11-06 20:57:13 +00:00
|
|
|
SkRect screen = SkRect::MakeWH(SkIntToScalar(kRenderTargetWidth),
|
|
|
|
SkIntToScalar(kRenderTargetHeight));
|
2012-08-02 18:11:43 +00:00
|
|
|
|
2014-10-09 14:25:36 +00:00
|
|
|
SkClipStack stack;
|
|
|
|
stack.clipDevRect(screen, SkRegion::kReplace_Op, false);
|
2012-08-02 18:11:43 +00:00
|
|
|
|
2014-10-09 14:25:36 +00:00
|
|
|
// wrap the SkClipStack in a GrClipData
|
|
|
|
GrClipData clipData;
|
2015-02-05 16:19:35 +00:00
|
|
|
clipData.fClipStack.reset(SkRef(&stack));
|
2014-10-09 14:25:36 +00:00
|
|
|
this->setClip(&clipData);
|
2013-05-22 14:34:04 +00:00
|
|
|
|
2014-10-09 14:25:36 +00:00
|
|
|
SkRandom random;
|
|
|
|
static const int NUM_TESTS = 512;
|
|
|
|
for (int t = 0; t < NUM_TESTS;) {
|
|
|
|
// setup random render target(can fail)
|
2015-01-23 12:24:04 +00:00
|
|
|
SkAutoTUnref<GrRenderTarget> rt(random_render_target(fContext, &random));
|
2014-11-06 20:57:13 +00:00
|
|
|
if (!rt.get()) {
|
2014-10-09 14:25:36 +00:00
|
|
|
SkDebugf("Could not allocate render target");
|
|
|
|
return false;
|
|
|
|
}
|
2013-05-22 14:34:04 +00:00
|
|
|
|
2015-01-22 18:16:09 +00:00
|
|
|
GrPipelineBuilder pipelineBuilder;
|
|
|
|
pipelineBuilder.setRenderTarget(rt.get());
|
2013-05-22 14:34:04 +00:00
|
|
|
|
2014-10-09 14:25:36 +00:00
|
|
|
// if path rendering we have to setup a couple of things like the draw type
|
2014-11-06 20:57:13 +00:00
|
|
|
bool usePathRendering = gpu->glCaps().pathRenderingSupport() && random.nextBool();
|
2014-09-22 20:17:02 +00:00
|
|
|
|
2014-10-09 14:25:36 +00:00
|
|
|
// twiddle drawstate knobs randomly
|
2014-11-15 00:00:38 +00:00
|
|
|
bool hasGeometryProcessor = !usePathRendering;
|
2014-12-13 14:46:13 +00:00
|
|
|
SkAutoTUnref<const GrGeometryProcessor> gp;
|
|
|
|
SkAutoTUnref<const GrPathProcessor> pathProc;
|
2014-09-04 15:56:46 +00:00
|
|
|
if (hasGeometryProcessor) {
|
2014-12-13 14:46:13 +00:00
|
|
|
gp.reset(get_random_gp(fContext, gpu->glCaps(), &random, dummyTextures));
|
2014-12-11 23:44:02 +00:00
|
|
|
} else {
|
2014-12-13 14:46:13 +00:00
|
|
|
pathProc.reset(GrPathProcessor::Create(GrColor_WHITE));
|
2012-08-02 18:11:43 +00:00
|
|
|
}
|
2014-11-06 20:57:13 +00:00
|
|
|
set_random_color_coverage_stages(gpu,
|
2015-01-22 18:16:09 +00:00
|
|
|
&pipelineBuilder,
|
2014-11-06 20:57:13 +00:00
|
|
|
maxStages - hasGeometryProcessor,
|
|
|
|
usePathRendering,
|
|
|
|
&random,
|
|
|
|
dummyTextures);
|
2014-12-11 21:15:13 +00:00
|
|
|
|
|
|
|
// creates a random xfer processor factory on the draw state
|
2015-01-22 18:16:09 +00:00
|
|
|
set_random_xpf(fContext, gpu->glCaps(), &pipelineBuilder, &random, dummyTextures);
|
2014-12-11 21:15:13 +00:00
|
|
|
|
2015-01-22 18:16:09 +00:00
|
|
|
set_random_state(&pipelineBuilder, &random);
|
|
|
|
set_random_stencil(&pipelineBuilder, &random);
|
2014-10-09 14:25:36 +00:00
|
|
|
|
2014-10-29 00:59:26 +00:00
|
|
|
GrDeviceCoordTexture dstCopy;
|
|
|
|
|
2014-12-11 23:44:02 +00:00
|
|
|
const GrPrimitiveProcessor* primProc;
|
|
|
|
if (hasGeometryProcessor) {
|
2014-12-13 14:46:13 +00:00
|
|
|
primProc = gp.get();
|
2014-12-11 23:44:02 +00:00
|
|
|
} else {
|
2014-12-13 14:46:13 +00:00
|
|
|
primProc = pathProc.get();
|
2014-12-11 23:44:02 +00:00
|
|
|
}
|
2015-02-13 17:00:33 +00:00
|
|
|
|
|
|
|
const GrProcOptInfo& colorPOI = pipelineBuilder.colorProcInfo(primProc);
|
|
|
|
const GrProcOptInfo& coveragePOI = pipelineBuilder.coverageProcInfo(primProc);
|
|
|
|
|
|
|
|
if (!this->setupDstReadIfNecessary(pipelineBuilder, colorPOI, coveragePOI, &dstCopy,
|
|
|
|
NULL)) {
|
2014-10-29 00:59:26 +00:00
|
|
|
SkDebugf("Couldn't setup dst read texture");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-10-09 14:25:36 +00:00
|
|
|
// create optimized draw state, setup readDst texture if required, and build a descriptor
|
|
|
|
// and program. ODS creation can fail, so we have to check
|
2015-02-13 17:00:33 +00:00
|
|
|
GrPipeline pipeline(pipelineBuilder, colorPOI, coveragePOI,
|
|
|
|
*gpu->caps(), scissor, &dstCopy);
|
2015-01-22 18:16:09 +00:00
|
|
|
if (pipeline.mustSkip()) {
|
2014-10-09 14:25:36 +00:00
|
|
|
continue;
|
2014-07-11 17:01:02 +00:00
|
|
|
}
|
2015-01-20 17:08:51 +00:00
|
|
|
GrBatchTracker bt;
|
2015-01-22 18:16:09 +00:00
|
|
|
primProc->initBatchTracker(&bt, pipeline.getInitBatchTracker());
|
2015-01-20 17:08:51 +00:00
|
|
|
|
|
|
|
GrProgramDesc desc;
|
2015-02-06 15:02:37 +00:00
|
|
|
gpu->buildProgramDesc(&desc, *primProc, pipeline, bt);
|
2015-01-20 17:08:51 +00:00
|
|
|
|
2015-01-22 18:16:09 +00:00
|
|
|
GrGpu::DrawArgs args(primProc, &pipeline, &desc, &bt);
|
2015-01-20 17:08:51 +00:00
|
|
|
SkAutoTUnref<GrGLProgram> program(GrGLProgramBuilder::CreateProgram(args, gpu));
|
|
|
|
|
2012-08-02 18:11:43 +00:00
|
|
|
if (NULL == program.get()) {
|
2014-10-09 14:25:36 +00:00
|
|
|
SkDebugf("Failed to create program!");
|
2012-08-02 18:11:43 +00:00
|
|
|
return false;
|
|
|
|
}
|
2014-09-15 18:41:13 +00:00
|
|
|
|
2014-10-09 14:25:36 +00:00
|
|
|
// because occasionally optimized drawstate creation will fail for valid reasons, we only
|
|
|
|
// want to increment on success
|
|
|
|
++t;
|
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) {
|
2014-12-16 15:33:49 +00:00
|
|
|
GrGLGpu* gpu = static_cast<GrGLGpu*>(context->getGpu());
|
2014-10-09 20:12:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For the time being, we only support the test with desktop GL or for android on
|
|
|
|
* ARM platforms
|
|
|
|
* TODO When we run ES 3.00 GLSL in more places, test again
|
|
|
|
*/
|
|
|
|
int maxStages;
|
|
|
|
if (kGL_GrGLStandard == gpu->glStandard() ||
|
|
|
|
kARM_GrGLVendor == gpu->ctxInfo().vendor()) {
|
|
|
|
maxStages = 6;
|
|
|
|
} else if (kTegra3_GrGLRenderer == gpu->ctxInfo().renderer() ||
|
|
|
|
kOther_GrGLRenderer == gpu->ctxInfo().renderer()) {
|
|
|
|
maxStages = 1;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
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
|
2014-11-06 20:57:13 +00:00
|
|
|
GrTestTarget target;
|
|
|
|
context->getTestTarget(&target);
|
|
|
|
REPORTER_ASSERT(reporter, target.target()->programUnitTest(maxStages));
|
2013-02-04 16:13:32 +00:00
|
|
|
}
|
|
|
|
}
|
2011-08-16 15:45:58 +00:00
|
|
|
}
|
|
|
|
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif
|