1d816b92bb
This reverts commit 88d99c6387
.
Reason for revert: Believed to be causing unit test failures in Chrome roll:
https://build.chromium.org/p/tryserver.chromium.android/builders/linux_android_rel_ng/builds/364433
https://luci-logdog.appspot.com/v/?s=chromium%2Fbb%2Ftryserver.chromium.android%2Flinux_android_rel_ng%2F364433%2F%2B%2Frecipes%2Fsteps%2Fcontent_browsertests__with_patch__on_Android%2F0%2Flogs%2FWebRtcCaptureFromElementBrowserTest.VerifyCanvasWebGLCaptureColor%2F0
Original change's description:
> Switched highp float to highfloat and mediump float to half.
>
> The ultimate goal is to end up with "float" and "half", but this
> intermediate step uses "highfloat" so that it is clear if I missed a
> "float" somewhere. Once this lands, a subsequent CL will switch all
> "highfloats" back to "floats".
>
> Bug: skia:
> Change-Id: Ia13225c7a0a0a2901e07665891c473d2500ddcca
> Reviewed-on: https://skia-review.googlesource.com/31000
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
TBR=bsalomon@google.com,csmartdalton@google.com,ethannicholas@google.com
Change-Id: I8bfa97547ac3920d433665f161d27df3f15c83aa
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/35705
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
147 lines
5.5 KiB
C++
147 lines
5.5 KiB
C++
/*
|
|
* Copyright 2016 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
// This is a GPU-backend specific test. It relies on static intializers to work
|
|
|
|
#include "SkTypes.h"
|
|
#include "Test.h"
|
|
|
|
#if SK_SUPPORT_GPU
|
|
#include "GrContext.h"
|
|
#include "GrGeometryProcessor.h"
|
|
#include "GrGpu.h"
|
|
#include "GrOpFlushState.h"
|
|
#include "GrRenderTargetContext.h"
|
|
#include "GrRenderTargetContextPriv.h"
|
|
#include "SkString.h"
|
|
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
|
#include "glsl/GrGLSLGeometryProcessor.h"
|
|
#include "glsl/GrGLSLVarying.h"
|
|
#include "ops/GrMeshDrawOp.h"
|
|
|
|
namespace {
|
|
class Op : public GrMeshDrawOp {
|
|
public:
|
|
DEFINE_OP_CLASS_ID
|
|
|
|
const char* name() const override { return "Dummy Op"; }
|
|
|
|
static std::unique_ptr<GrDrawOp> Make(int numAttribs) {
|
|
return std::unique_ptr<GrDrawOp>(new Op(numAttribs));
|
|
}
|
|
|
|
FixedFunctionFlags fixedFunctionFlags() const override {
|
|
return FixedFunctionFlags::kNone;
|
|
}
|
|
|
|
RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip) override {
|
|
return RequiresDstTexture::kNo;
|
|
}
|
|
|
|
private:
|
|
Op(int numAttribs) : INHERITED(ClassID()), fNumAttribs(numAttribs) {
|
|
this->setBounds(SkRect::MakeWH(1.f, 1.f), HasAABloat::kNo, IsZeroArea::kNo);
|
|
}
|
|
|
|
bool onCombineIfPossible(GrOp*, const GrCaps&) override { return false; }
|
|
|
|
void onPrepareDraws(Target* target) override {
|
|
class GP : public GrGeometryProcessor {
|
|
public:
|
|
GP(int numAttribs) {
|
|
this->initClassID<GP>();
|
|
SkASSERT(numAttribs > 1);
|
|
for (auto i = 0; i < numAttribs; ++i) {
|
|
fAttribNames.push_back().printf("attr%d", i);
|
|
}
|
|
for (auto i = 0; i < numAttribs; ++i) {
|
|
this->addVertexAttrib(fAttribNames[i].c_str(), kVec2f_GrVertexAttribType);
|
|
}
|
|
}
|
|
const char* name() const override { return "Dummy GP"; }
|
|
|
|
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
|
|
class GLSLGP : public GrGLSLGeometryProcessor {
|
|
public:
|
|
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
|
|
const GP& gp = args.fGP.cast<GP>();
|
|
args.fVaryingHandler->emitAttributes(gp);
|
|
this->writeOutputPosition(args.fVertBuilder, gpArgs, gp.getAttrib(0).fName);
|
|
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
|
fragBuilder->codeAppendf("%s = float4(1);", args.fOutputColor);
|
|
fragBuilder->codeAppendf("%s = float4(1);", args.fOutputCoverage);
|
|
}
|
|
void setData(const GrGLSLProgramDataManager& pdman,
|
|
const GrPrimitiveProcessor& primProc,
|
|
FPCoordTransformIter&&) override {}
|
|
};
|
|
return new GLSLGP();
|
|
}
|
|
void getGLSLProcessorKey(const GrShaderCaps&,
|
|
GrProcessorKeyBuilder* builder) const override {
|
|
builder->add32(this->numAttribs());
|
|
}
|
|
|
|
private:
|
|
SkTArray<SkString> fAttribNames;
|
|
};
|
|
sk_sp<GrGeometryProcessor> gp(new GP(fNumAttribs));
|
|
QuadHelper helper;
|
|
size_t vertexStride = gp->getVertexStride();
|
|
SkPoint* vertices = reinterpret_cast<SkPoint*>(helper.init(target, vertexStride, 1));
|
|
vertices->setRectFan(0.f, 0.f, 1.f, 1.f, vertexStride);
|
|
helper.recordDraw(target, gp.get(),
|
|
target->makePipeline(0, GrProcessorSet::MakeEmptySet(),
|
|
target->detachAppliedClip()));
|
|
}
|
|
|
|
int fNumAttribs;
|
|
|
|
typedef GrMeshDrawOp INHERITED;
|
|
};
|
|
}
|
|
|
|
DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
|
|
GrContext* context = ctxInfo.grContext();
|
|
|
|
sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
|
|
SkBackingFit::kApprox,
|
|
1, 1, kRGBA_8888_GrPixelConfig,
|
|
nullptr));
|
|
if (!renderTargetContext) {
|
|
ERRORF(reporter, "Could not create render target context.");
|
|
return;
|
|
}
|
|
int attribCnt = context->caps()->maxVertexAttributes();
|
|
if (!attribCnt) {
|
|
ERRORF(reporter, "No attributes allowed?!");
|
|
return;
|
|
}
|
|
context->flush();
|
|
context->resetGpuStats();
|
|
#if GR_GPU_STATS
|
|
REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0);
|
|
REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 0);
|
|
#endif
|
|
GrPaint grPaint;
|
|
// This one should succeed.
|
|
renderTargetContext->priv().testingOnly_addDrawOp(Op::Make(attribCnt));
|
|
context->flush();
|
|
#if GR_GPU_STATS
|
|
REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 1);
|
|
REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 0);
|
|
#endif
|
|
context->resetGpuStats();
|
|
renderTargetContext->priv().testingOnly_addDrawOp(Op::Make(attribCnt + 1));
|
|
context->flush();
|
|
#if GR_GPU_STATS
|
|
REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0);
|
|
REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 1);
|
|
#endif
|
|
}
|
|
#endif
|