Revert of added support for PLS path rendering (patchset #16 id:360001 of https://codereview.chromium.org/1541903002/ )

Reason for revert:
ASAN failure at src/gpu/GrXferProcessor.cpp:224

Original issue's description:
> added support for PLS path rendering
>
> BUG=skia:3555
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1541903002
>
> Committed: https://skia.googlesource.com/skia/+/7df3f5e127f8016d17b637cc48a6a4718f1a6822

TBR=bsalomon@google.com,egdaniel@google.com,joshualitt@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:3555
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1626553002

Review URL: https://codereview.chromium.org/1626553002
This commit is contained in:
ethannicholas 2016-01-22 09:45:47 -08:00 committed by Commit bot
parent 1c2729c8bb
commit 5366a09ed0
44 changed files with 106 additions and 1651 deletions

View File

@ -232,8 +232,6 @@
'<(skia_src_path)/gpu/batches/GrNonAAStrokeRectBatch.h',
'<(skia_src_path)/gpu/batches/GrNinePatch.cpp',
'<(skia_src_path)/gpu/batches/GrNinePatch.h',
'<(skia_src_path)/gpu/batches/GrPLSPathRenderer.cpp',
'<(skia_src_path)/gpu/batches/GrPLSPathRenderer.h',
'<(skia_src_path)/gpu/batches/GrRectBatchFactory.h',
'<(skia_src_path)/gpu/batches/GrRectBatchFactory.cpp',
'<(skia_src_path)/gpu/batches/GrStencilAndCoverPathRenderer.cpp',

View File

@ -81,24 +81,6 @@ public:
*/
bool floatPrecisionVaries() const { return fShaderPrecisionVaries; }
/**
* PLS storage size in bytes (0 when not supported). The PLS spec defines a minimum size of 16
* bytes whenever PLS is supported.
*/
int pixelLocalStorageSize() const { return fPixelLocalStorageSize; }
/**
* True if this context supports the necessary extensions and features to enable the PLS path
* renderer.
*/
bool plsPathRenderingSupport() const {
#if GR_ENABLE_PLS_PATH_RENDERING
return fPLSPathRenderingSupport;
#else
return false;
#endif
}
protected:
/** Subclasses must call this after initialization in order to apply caps overrides requested by
the client. Note that overrides will only reduce the caps never expand them. */
@ -112,8 +94,6 @@ protected:
bool fShaderPrecisionVaries;
PrecisionInfo fFloatPrecisions[kGrShaderTypeCount][kGrSLPrecisionCount];
int fPixelLocalStorageSize;
bool fPLSPathRenderingSupport;
private:
virtual void onApplyOptionsOverrides(const GrContextOptions&) {};

View File

@ -193,12 +193,4 @@ typedef unsigned __int64 uint64_t;
#if !defined(GR_BATCH_DEBUGGING_OUTPUT)
#define GR_BATCH_DEBUGGING_OUTPUT 0
#endif
/**
* Set to 1 to enable pixel local storage path rendering on supported devices.
*/
#if !defined(GR_ENABLE_PLS_PATH_RENDERING)
#define GR_ENABLE_PLS_PATH_RENDERING 0
#endif
#endif

View File

@ -51,7 +51,7 @@ public:
, fName(name)
, fCount(arrayCount)
, fPrecision(precision) {
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
SkASSERT(kVoid_GrSLType != type);
}
@ -62,7 +62,7 @@ public:
, fName(name)
, fCount(arrayCount)
, fPrecision(precision) {
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
SkASSERT(kVoid_GrSLType != type);
}
@ -73,7 +73,7 @@ public:
, fName(name)
, fCount(arrayCount)
, fPrecision(precision) {
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
SkASSERT(kVoid_GrSLType != type);
}
@ -91,7 +91,7 @@ public:
GrSLPrecision precision = kDefault_GrSLPrecision,
int count = kNonArray) {
SkASSERT(kVoid_GrSLType != type);
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
fType = type;
fTypeModifier = typeModifier;
fName = name;
@ -105,7 +105,7 @@ public:
GrSLPrecision precision = kDefault_GrSLPrecision,
int count = kNonArray) {
SkASSERT(kVoid_GrSLType != type);
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
fType = type;
fTypeModifier = typeModifier;
fName = name;

View File

@ -27,10 +27,8 @@ enum GrSLType {
kSampler2D_GrSLType,
kSamplerExternal_GrSLType,
kSampler2DRect_GrSLType,
kBool_GrSLType,
kInt_GrSLType,
kLast_GrSLType = kInt_GrSLType
kLast_GrSLType = kSampler2DRect_GrSLType
};
static const int kGrSLTypeCount = kLast_GrSLType + 1;
@ -67,7 +65,7 @@ static const int kGrSLPrecisionCount = kLast_GrSLPrecision + 1;
*/
static inline int GrSLTypeVectorCount(GrSLType type) {
SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount));
static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1, -1, -1, -1 };
static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1, -1 };
return kCounts[type];
GR_STATIC_ASSERT(0 == kVoid_GrSLType);
@ -80,8 +78,6 @@ static inline int GrSLTypeVectorCount(GrSLType type) {
GR_STATIC_ASSERT(7 == kSampler2D_GrSLType);
GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType);
GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType);
GR_STATIC_ASSERT(10 == kBool_GrSLType);
GR_STATIC_ASSERT(11 == kInt_GrSLType);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrSLTypeCount);
}
@ -97,10 +93,10 @@ static inline GrSLType GrSLFloatVectorType(int count) {
GR_STATIC_ASSERT(kVec4f_GrSLType == 4);
}
/** Is the shading language type float (including vectors/matrices)? */
/** Is the shading language type floating point (or vector/matrix of fp)? */
static inline bool GrSLTypeIsFloatType(GrSLType type) {
SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount));
return (type >= 1 && type <= 6);
return type >= 1 && type <= 6;
GR_STATIC_ASSERT(0 == kVoid_GrSLType);
GR_STATIC_ASSERT(1 == kFloat_GrSLType);
@ -112,34 +108,7 @@ static inline bool GrSLTypeIsFloatType(GrSLType type) {
GR_STATIC_ASSERT(7 == kSampler2D_GrSLType);
GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType);
GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType);
GR_STATIC_ASSERT(10 == kBool_GrSLType);
GR_STATIC_ASSERT(11 == kInt_GrSLType);
GR_STATIC_ASSERT(12 == kGrSLTypeCount);
}
/** Is the shading language type integral (including vectors/matrices)? */
static inline bool GrSLTypeIsIntType(GrSLType type) {
SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount));
return type == kInt_GrSLType;
GR_STATIC_ASSERT(0 == kVoid_GrSLType);
GR_STATIC_ASSERT(1 == kFloat_GrSLType);
GR_STATIC_ASSERT(2 == kVec2f_GrSLType);
GR_STATIC_ASSERT(3 == kVec3f_GrSLType);
GR_STATIC_ASSERT(4 == kVec4f_GrSLType);
GR_STATIC_ASSERT(5 == kMat33f_GrSLType);
GR_STATIC_ASSERT(6 == kMat44f_GrSLType);
GR_STATIC_ASSERT(7 == kSampler2D_GrSLType);
GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType);
GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType);
GR_STATIC_ASSERT(10 == kBool_GrSLType);
GR_STATIC_ASSERT(11 == kInt_GrSLType);
GR_STATIC_ASSERT(12 == kGrSLTypeCount);
}
/** Is the shading language type numeric (including vectors/matrices)? */
static inline bool GrSLTypeIsNumeric(GrSLType type) {
return GrSLTypeIsFloatType(type) || GrSLTypeIsIntType(type);
GR_STATIC_ASSERT(10 == kGrSLTypeCount);
}
/** Returns the size in bytes for floating point GrSLTypes. For non floating point type returns 0 */
@ -154,10 +123,8 @@ static inline size_t GrSLTypeSize(GrSLType type) {
9 * sizeof(float), // kMat33f_GrSLType
16 * sizeof(float), // kMat44f_GrSLType
0, // kSampler2D_GrSLType
0, // kSamplerExternal_GrSLType
0, // kSampler2DRect_GrSLType
0, // kBool_GrSLType
0, // kInt_GrSLType
0, // kSamplerExternal_GrSLType
0 // kSampler2DRect_GrSLType
};
return kSizes[type];
@ -171,9 +138,7 @@ static inline size_t GrSLTypeSize(GrSLType type) {
GR_STATIC_ASSERT(7 == kSampler2D_GrSLType);
GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType);
GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType);
GR_STATIC_ASSERT(10 == kBool_GrSLType);
GR_STATIC_ASSERT(11 == kInt_GrSLType);
GR_STATIC_ASSERT(12 == kGrSLTypeCount);
GR_STATIC_ASSERT(10 == kGrSLTypeCount);
}
static inline bool GrSLTypeIsSamplerType(GrSLType type) {
@ -200,10 +165,8 @@ enum GrVertexAttribType {
kVec4ub_GrVertexAttribType, // vector of 4 unsigned bytes, e.g. colors
kVec2s_GrVertexAttribType, // vector of 2 shorts, e.g. texture coordinates
kInt_GrVertexAttribType,
kLast_GrVertexAttribType = kInt_GrVertexAttribType
kLast_GrVertexAttribType = kVec2s_GrVertexAttribType
};
static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1;
@ -211,7 +174,8 @@ static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1;
* Returns the vector size of the type.
*/
static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) {
static const int kCounts[] = { 1, 2, 3, 4, 1, 4, 2, 1 };
SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount);
static const int kCounts[] = { 1, 2, 3, 4, 1, 4, 2 };
return kCounts[type];
GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType);
@ -221,7 +185,6 @@ static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) {
GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType);
GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType);
GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType);
GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrVertexAttribTypeCount);
}
@ -229,6 +192,7 @@ static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) {
* Returns the size of the attrib type in bytes.
*/
static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) {
SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount);
static const size_t kSizes[] = {
sizeof(float), // kFloat_GrVertexAttribType
2*sizeof(float), // kVec2f_GrVertexAttribType
@ -236,8 +200,7 @@ static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) {
4*sizeof(float), // kVec4f_GrVertexAttribType
1*sizeof(char), // kUByte_GrVertexAttribType
4*sizeof(char), // kVec4ub_GrVertexAttribType
2*sizeof(int16_t), // kVec2s_GrVertexAttribType
sizeof(int32_t) // kInt_GrVertexAttribType
2*sizeof(int16_t) // kVec2s_GrVertexAttribType
};
return kSizes[type];
@ -248,7 +211,6 @@ static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) {
GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType);
GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType);
GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType);
GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kSizes) == kGrVertexAttribTypeCount);
}
@ -271,8 +233,6 @@ static inline GrSLType GrVertexAttribTypeToSLType(GrVertexAttribType type) {
case kVec4ub_GrVertexAttribType:
case kVec4f_GrVertexAttribType:
return kVec4f_GrSLType;
case kInt_GrVertexAttribType:
return kInt_GrSLType;
}
}

View File

@ -355,19 +355,15 @@ private:
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples,
const DstTexture*) const = 0;
virtual bool onIsEqual(const GrXPFactory&) const = 0;
bool willReadDstColor(const GrCaps& caps,
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples) const;
/**
* Returns true if the XP generated by this factory will explicitly read dst in the fragment
* shader.
*/
virtual bool onWillReadDstColor(const GrCaps& caps,
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples) const = 0;
virtual bool willReadDstColor(const GrCaps& caps,
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples) const = 0;
virtual bool onIsEqual(const GrXPFactory&) const = 0;
static uint32_t GenClassID() {
// fCurrXPFactoryID has been initialized to kIllegalXPFactoryID. The

View File

@ -34,9 +34,9 @@ private:
bool hasMixedSamples,
const DstTexture*) const override;
bool onWillReadDstColor(const GrCaps& /*caps*/,
const GrPipelineOptimizations& /*optimizations*/,
bool /*hasMixedSamples*/) const override {
bool willReadDstColor(const GrCaps& /*caps*/,
const GrPipelineOptimizations& /*optimizations*/,
bool /*hasMixedSamples*/) const override {
return false;
}

View File

@ -60,9 +60,9 @@ private:
bool hasMixedSamples,
const DstTexture*) const override;
bool onWillReadDstColor(const GrCaps& caps,
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples) const override;
bool willReadDstColor(const GrCaps& caps,
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples) const override;
bool onIsEqual(const GrXPFactory& xpfBase) const override {
const GrPorterDuffXPFactory& xpf = xpfBase.cast<GrPorterDuffXPFactory>();

View File

@ -92,9 +92,9 @@ private:
bool hasMixedSamples,
const DstTexture*) const override;
bool onWillReadDstColor(const GrCaps& caps,
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples) const override {
bool willReadDstColor(const GrCaps& caps,
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples) const override {
return true;
}

View File

@ -20,7 +20,6 @@
#include "GrSurfacePriv.h"
#include "GrTexture.h"
#include "GrVertexBuffer.h"
#include "gl/GrGLRenderTarget.h"
#include "SkStrokeRec.h"
@ -213,8 +212,6 @@ void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) {
}
fBatches[i]->draw(flushState);
}
fGpu->performFlushWorkaround();
}
void GrDrawTarget::reset() {
@ -490,31 +487,6 @@ bool GrDrawTarget::installPipelineInDrawBatch(const GrPipelineBuilder* pipelineB
args.fCaps = this->caps();
args.fScissor = scissor;
batch->getPipelineOptimizations(&args.fOpts);
GrScissorState finalScissor;
if (args.fOpts.fOverrides.fUsePLSDstRead) {
GrRenderTarget* rt = pipelineBuilder->getRenderTarget();
GrGLIRect viewport;
viewport.fLeft = 0;
viewport.fBottom = 0;
viewport.fWidth = rt->width();
viewport.fHeight = rt->height();
SkIRect ibounds;
ibounds.fLeft = SkTPin(SkScalarFloorToInt(batch->bounds().fLeft), viewport.fLeft,
viewport.fWidth);
ibounds.fTop = SkTPin(SkScalarFloorToInt(batch->bounds().fTop), viewport.fBottom,
viewport.fHeight);
ibounds.fRight = SkTPin(SkScalarCeilToInt(batch->bounds().fRight), viewport.fLeft,
viewport.fWidth);
ibounds.fBottom = SkTPin(SkScalarCeilToInt(batch->bounds().fBottom), viewport.fBottom,
viewport.fHeight);
if (scissor != nullptr && scissor->enabled()) {
if (!ibounds.intersect(scissor->rect())) {
ibounds = scissor->rect();
}
}
finalScissor.set(ibounds);
args.fScissor = &finalScissor;
}
args.fOpts.fColorPOI.completeCalculations(pipelineBuilder->fColorFragmentProcessors.begin(),
pipelineBuilder->numColorFragmentProcessors());
args.fOpts.fCoveragePOI.completeCalculations(

View File

@ -20,7 +20,8 @@
class GrGeometryProcessor : public GrPrimitiveProcessor {
public:
GrGeometryProcessor()
: fWillUseGeoShader(false)
: INHERITED(false)
, fWillUseGeoShader(false)
, fLocalCoordsType(kUnused_LocalCoordsType) {}
bool willUseGeoShader() const override { return fWillUseGeoShader; }

View File

@ -367,9 +367,6 @@ void GrGpu::resolveRenderTarget(GrRenderTarget* target) {
this->onResolveRenderTarget(target);
}
void GrGpu::performFlushWorkaround() {
}
////////////////////////////////////////////////////////////////////////////////
void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) {
@ -385,4 +382,3 @@ void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) {
fStats.incNumDraws();
} while ((verts = iter.next()));
}

View File

@ -349,9 +349,6 @@ public:
void draw(const DrawArgs&, const GrVertices&);
// Called by drawtarget when flushing. Provides a hook for working around an ARM PLS driver bug.
virtual void performFlushWorkaround();
///////////////////////////////////////////////////////////////////////////
// Debugging and Stats

View File

@ -1,35 +0,0 @@
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrPLSGeometryProcessor_DEFINED
#define GrPLSGeometryProcessor_DEFINED
#include "GrGeometryProcessor.h"
/**
* A minor extension to GrGeometryProcessor that adds bounds tracking for pixel local storage
* purposes.
*/
class GrPLSGeometryProcessor : public GrGeometryProcessor {
public:
GrPixelLocalStorageState getPixelLocalStorageState() const override {
return GrPixelLocalStorageState::kDraw_GrPixelLocalStorageState;
}
const SkRect& getBounds() const {
return fBounds;
}
void setBounds(SkRect& bounds) {
fBounds = bounds;
}
private:
SkRect fBounds;
};
#endif

View File

@ -123,7 +123,8 @@ GrPathProcessor::GrPathProcessor(GrColor color,
const GrXPOverridesForBatch& overrides,
const SkMatrix& viewMatrix,
const SkMatrix& localMatrix)
: fColor(color)
: INHERITED(true)
, fColor(color)
, fViewMatrix(viewMatrix)
, fLocalMatrix(localMatrix)
, fOverrides(overrides) {

View File

@ -40,8 +40,6 @@ public:
const GrXPOverridesForBatch& overrides() const { return fOverrides; }
virtual bool isPathRendering() const override { return true; }
private:
GrPathProcessor(GrColor color, const GrXPOverridesForBatch& overrides,
const SkMatrix& viewMatrix, const SkMatrix& localMatrix);

View File

@ -10,8 +10,6 @@
#include "GrPathRendererChain.h"
#include "GrCaps.h"
#include "gl/GrGLCaps.h"
#include "glsl/GrGLSLCaps.h"
#include "GrContext.h"
#include "GrGpu.h"
@ -23,7 +21,6 @@
#include "batches/GrDefaultPathRenderer.h"
#include "batches/GrStencilAndCoverPathRenderer.h"
#include "batches/GrTessellatingPathRenderer.h"
#include "batches/GrPLSPathRenderer.h"
GrPathRendererChain::GrPathRendererChain(GrContext* context) {
const GrCaps& caps = *context->caps();
@ -37,9 +34,6 @@ GrPathRendererChain::GrPathRendererChain(GrContext* context) {
this->addPathRenderer(new GrAAHairLinePathRenderer)->unref();
this->addPathRenderer(new GrAAConvexPathRenderer)->unref();
this->addPathRenderer(new GrAALinearizingConvexPathRenderer)->unref();
if (caps.shaderCaps()->plsPathRenderingSupport()) {
this->addPathRenderer(new GrPLSPathRenderer)->unref();
}
this->addPathRenderer(new GrAADistanceFieldPathRenderer)->unref();
this->addPathRenderer(new GrDefaultPathRenderer(caps.twoSidedStencilSupport(),
caps.stencilWrapOpsSupport()))->unref();

View File

@ -47,16 +47,6 @@ class GrGLSLPrimitiveProcessor;
struct GrInitInvariantOutput;
// Describes the state of pixel local storage with respect to the current draw.
enum GrPixelLocalStorageState {
// The draw is actively updating PLS.
kDraw_GrPixelLocalStorageState,
// The draw is a "finish" operation which is reading from PLS and writing color.
kFinish_GrPixelLocalStorageState,
// The draw does not use PLS.
kDisabled_GrPixelLocalStorageState
};
/*
* This class allows the GrPipeline to communicate information about the pipeline to a
* GrBatch which should be forwarded to the GrPrimitiveProcessor(s) created by the batch.
@ -209,7 +199,7 @@ public:
the object. */
virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps& caps) const = 0;
virtual bool isPathRendering() const { return false; }
bool isPathRendering() const { return fIsPathRendering; }
/**
* No Local Coord Transformation is needed in the shader, instead transformed local coords will
@ -217,19 +207,11 @@ public:
*/
virtual bool hasTransformedLocalCoords() const = 0;
virtual GrPixelLocalStorageState getPixelLocalStorageState() const {
return kDisabled_GrPixelLocalStorageState;
}
/**
* If non-null, overrides the dest color returned by GrGLSLFragmentShaderBuilder::dstColor().
*/
virtual const char* getDestColorOverride() const { return nullptr; }
protected:
GrPrimitiveProcessor()
GrPrimitiveProcessor(bool isPathRendering)
: fNumAttribs(0)
, fVertexStride(0) {}
, fVertexStride(0)
, fIsPathRendering(isPathRendering) {}
Attribute fAttribs[kMaxVertexAttribs];
int fNumAttribs;
@ -239,6 +221,8 @@ private:
void notifyRefCntIsZero() const final {};
virtual bool hasExplicitLocalCoords() const = 0;
bool fIsPathRendering;
typedef GrProcessor INHERITED;
};

View File

@ -217,10 +217,3 @@ bool GrXPFactory::willNeedDstTexture(const GrCaps& caps,
return (this->willReadDstColor(caps, optimizations, hasMixedSamples) &&
!caps.shaderCaps()->dstReadInShaderSupport());
}
bool GrXPFactory::willReadDstColor(const GrCaps& caps,
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples) const {
return optimizations.fOverrides.fUsePLSDstRead || this->onWillReadDstColor(caps, optimizations,
hasMixedSamples);
}

View File

@ -692,7 +692,7 @@ public:
// When this is called on a batch, there is only one geometry bundle
color->setKnownFourComponents(fGeoData[0].fColor);
coverage->setUnknownSingleComponent();
overrides->fUsePLSDstRead = false;
overrides->fUsePLSDstRead = true;
}
private:

View File

@ -257,7 +257,6 @@ void GrAtlasTextBatch::computePipelineOptimizations(GrInitInvariantOutput* color
case kColorBitmapMask_MaskType:
coverage->setKnownSingleComponent(0xff);
}
overrides->fUsePLSDstRead = false;
}
void GrAtlasTextBatch::initBatchTracker(const GrXPOverridesForBatch& overrides) {

File diff suppressed because it is too large Load Diff

View File

@ -1,49 +0,0 @@
/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrPLSPathRenderer_DEFINED
#define GrPLSPathRenderer_DEFINED
#include "GrPathRenderer.h"
/*
* Renders arbitrary antialiased paths using pixel local storage as a scratch buffer. The overall
* technique is very similar to the approach presented in "Resolution independent rendering of
* deformable vector objects using graphics hardware" by Kokojima et al.
* We first render the straight-line portions of the path (essentially pretending as if all segments
* were kLine_Verb) as a triangle fan, using a fragment shader which updates the winding counts
* appropriately. We then render the curved portions of the path using a Loop-Blinn shader which
* calculates which portion of the triangle is covered by the quad (conics and cubics are split down
* to quads). Where we diverge from Kokojima is that, instead of rendering into the stencil buffer
* and using built-in MSAA to handle straight-line antialiasing, we use the pixel local storage area
* and calculate the MSAA ourselves in the fragment shader. Essentially, we manually evaluate the
* coverage of each pixel four times, storing four winding counts into the pixel local storage area,
* and compute the final coverage based on those winding counts.
*
* Our approach is complicated by the need to perform antialiasing on straight edges as well,
* without relying on hardware MSAA. We instead bloat the triangles to ensure complete coverage,
* pass the original (un-bloated) vertices in to the fragment shader, and then have the fragment
* shader use these vertices to evaluate whether a given sample is located within the triangle or
* not. This gives us MSAA4 edges on triangles which line up nicely with no seams. We similarly face
* problems on the back (flat) edges of quads, where we have to ensure that the back edge is
* antialiased in the same way. Similar to the triangle case, we pass in the two (unbloated)
* vertices defining the back edge of the quad and the fragment shader uses these vertex coordinates
* to discard samples falling on the other side of the quad's back edge.
*/
class GrPLSPathRenderer : public GrPathRenderer {
public:
GrPLSPathRenderer();
bool onCanDrawPath(const CanDrawPathArgs& args) const override;
protected:
bool onDrawPath(const DrawPathArgs& args) override;
};
#endif

View File

@ -9,7 +9,6 @@
#include "effects/GrCoverageSetOpXP.h"
#include "GrCaps.h"
#include "GrColor.h"
#include "GrPipeline.h"
#include "GrProcessor.h"
#include "GrProcOptInfo.h"
#include "glsl/GrGLSLBlend.h"
@ -152,6 +151,7 @@ class ShaderCSOXferProcessor : public GrXferProcessor {
public:
ShaderCSOXferProcessor(const DstTexture* dstTexture,
bool hasMixedSamples,
SkXfermode::Mode xfermode,
SkRegion::Op regionOp,
bool invertCoverage)
: INHERITED(dstTexture, true, hasMixedSamples)
@ -323,9 +323,6 @@ GrCoverageSetOpXPFactory::onCreateXferProcessor(const GrCaps& caps,
return nullptr;
}
if (optimizations.fOverrides.fUsePLSDstRead) {
return new ShaderCSOXferProcessor(dst, hasMixedSamples, fRegionOp, fInvertCoverage);
}
return CoverageSetOpXP::Create(fRegionOp, fInvertCoverage);
}

View File

@ -54,15 +54,12 @@ static GrBlendEquation hw_blend_equation(SkXfermode::Mode mode) {
}
static bool can_use_hw_blend_equation(GrBlendEquation equation,
const GrPipelineOptimizations& opt,
const GrProcOptInfo& coveragePOI,
const GrCaps& caps) {
if (!caps.advancedBlendEquationSupport()) {
return false;
}
if (opt.fOverrides.fUsePLSDstRead) {
return false;
}
if (opt.fCoveragePOI.isFourChannelOutput()) {
if (coveragePOI.isFourChannelOutput()) {
return false; // LCD coverage must be applied after the blend equation.
}
if (caps.canUseAdvancedBlendEquation(equation)) {
@ -346,7 +343,7 @@ private:
bool hasMixedSamples,
const DstTexture*) const override;
bool onWillReadDstColor(const GrCaps& caps,
bool willReadDstColor(const GrCaps& caps,
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples) const override;
@ -374,17 +371,17 @@ GrXferProcessor* CustomXPFactory::onCreateXferProcessor(const GrCaps& caps,
const GrPipelineOptimizations& opt,
bool hasMixedSamples,
const DstTexture* dstTexture) const {
if (can_use_hw_blend_equation(fHWBlendEquation, opt, caps)) {
if (can_use_hw_blend_equation(fHWBlendEquation, opt.fCoveragePOI, caps)) {
SkASSERT(!dstTexture || !dstTexture->texture());
return new CustomXP(fMode, fHWBlendEquation);
}
return new CustomXP(dstTexture, hasMixedSamples, fMode);
}
bool CustomXPFactory::onWillReadDstColor(const GrCaps& caps,
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples) const {
return !can_use_hw_blend_equation(fHWBlendEquation, optimizations, caps);
bool CustomXPFactory::willReadDstColor(const GrCaps& caps,
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples) const {
return !can_use_hw_blend_equation(fHWBlendEquation, optimizations.fCoveragePOI, caps);
}
void CustomXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI,

View File

@ -6,7 +6,6 @@
*/
#include "effects/GrDisableColorXP.h"
#include "GrPipeline.h"
#include "GrProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
@ -98,7 +97,6 @@ GrDisableColorXPFactory::onCreateXferProcessor(const GrCaps& caps,
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples,
const DstTexture* dst) const {
SkASSERT(!optimizations.fOverrides.fUsePLSDstRead);
return DisableColorXP::Create();
}

View File

@ -31,9 +31,9 @@ private:
bool hasMixedSamples,
const DstTexture* dstTexture) const override;
bool onWillReadDstColor(const GrCaps& caps,
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples) const override {
bool willReadDstColor(const GrCaps& caps,
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples) const override {
return false;
}

View File

@ -748,9 +748,6 @@ GrPorterDuffXPFactory::onCreateXferProcessor(const GrCaps& caps,
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples,
const DstTexture* dstTexture) const {
if (optimizations.fOverrides.fUsePLSDstRead) {
return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, fXfermode);
}
BlendFormula blendFormula;
if (optimizations.fCoveragePOI.isFourChannelOutput()) {
if (SkXfermode::kSrcOver_Mode == fXfermode &&
@ -807,9 +804,9 @@ void GrPorterDuffXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorP
}
}
bool GrPorterDuffXPFactory::onWillReadDstColor(const GrCaps& caps,
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples) const {
bool GrPorterDuffXPFactory::willReadDstColor(const GrCaps& caps,
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples) const {
if (caps.shaderCaps()->dualSourceBlendingSupport()) {
return false;
}
@ -866,9 +863,6 @@ GrXferProcessor* GrPorterDuffXPFactory::CreateSrcOverXferProcessor(
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples,
const GrXferProcessor::DstTexture* dstTexture) {
if (optimizations.fOverrides.fUsePLSDstRead) {
return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, SkXfermode::kSrcOver_Mode);
}
if (!optimizations.fCoveragePOI.isFourChannelOutput() &&
!(optimizations.fCoveragePOI.isSolidWhite() &&
!hasMixedSamples &&

View File

@ -284,17 +284,6 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
ctxInfo.hasExtension("GL_OES_standard_derivatives");
}
if (ctxInfo.hasExtension("GL_EXT_shader_pixel_local_storage")) {
#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT 0x8F63
GR_GL_GetIntegerv(gli, GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT,
&glslCaps->fPixelLocalStorageSize);
glslCaps->fPLSPathRenderingSupport = glslCaps->fFBFetchSupport;
}
else {
glslCaps->fPixelLocalStorageSize = 0;
glslCaps->fPLSPathRenderingSupport = false;
}
/**************************************************************************
* GrCaps fields
**************************************************************************/
@ -541,6 +530,7 @@ void GrGLCaps::initGLSL(const GrGLContextInfo& ctxInfo) {
GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get());
glslCaps->fGLSLGeneration = ctxInfo.glslGeneration();
if (kGLES_GrGLStandard == standard) {
if (ctxInfo.hasExtension("GL_EXT_shader_framebuffer_fetch")) {
glslCaps->fFBFetchNeedsCustomOutput = (version >= GR_GL_VER(3, 0));

View File

@ -161,7 +161,6 @@
#define GR_GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
#define GR_GL_LINE_STIPPLE 0x0B24
#define GR_GL_FRAMEBUFFER_SRGB 0x8DB9
#define GR_GL_SHADER_PIXEL_LOCAL_STORAGE 0x8F64
/* ErrorCode */
#define GR_GL_NO_ERROR 0
@ -422,30 +421,29 @@
#define GR_GL_UNSIGNED_SHORT_5_6_5 0x8363
/* Shaders */
#define GR_GL_FRAGMENT_SHADER 0x8B30
#define GR_GL_VERTEX_SHADER 0x8B31
#define GR_GL_GEOMETRY_SHADER 0x8DD9
#define GR_GL_MAX_VERTEX_ATTRIBS 0x8869
#define GR_GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
#define GR_GL_MAX_VARYING_VECTORS 0x8DFC
#define GR_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
#define GR_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
#define GR_GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
#define GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
#define GR_GL_SHADER_TYPE 0x8B4F
#define GR_GL_DELETE_STATUS 0x8B80
#define GR_GL_LINK_STATUS 0x8B82
#define GR_GL_VALIDATE_STATUS 0x8B83
#define GR_GL_ATTACHED_SHADERS 0x8B85
#define GR_GL_ACTIVE_UNIFORMS 0x8B86
#define GR_GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
#define GR_GL_ACTIVE_ATTRIBUTES 0x8B89
#define GR_GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
#define GR_GL_SHADING_LANGUAGE_VERSION 0x8B8C
#define GR_GL_CURRENT_PROGRAM 0x8B8D
#define GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
#define GR_GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
#define GR_GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE 0x8F63
#define GR_GL_FRAGMENT_SHADER 0x8B30
#define GR_GL_VERTEX_SHADER 0x8B31
#define GR_GL_GEOMETRY_SHADER 0x8DD9
#define GR_GL_MAX_VERTEX_ATTRIBS 0x8869
#define GR_GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
#define GR_GL_MAX_VARYING_VECTORS 0x8DFC
#define GR_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
#define GR_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
#define GR_GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
#define GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
#define GR_GL_SHADER_TYPE 0x8B4F
#define GR_GL_DELETE_STATUS 0x8B80
#define GR_GL_LINK_STATUS 0x8B82
#define GR_GL_VALIDATE_STATUS 0x8B83
#define GR_GL_ATTACHED_SHADERS 0x8B85
#define GR_GL_ACTIVE_UNIFORMS 0x8B86
#define GR_GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
#define GR_GL_ACTIVE_ATTRIBUTES 0x8B89
#define GR_GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
#define GR_GL_SHADING_LANGUAGE_VERSION 0x8B8C
#define GR_GL_CURRENT_PROGRAM 0x8B8D
#define GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
#define GR_GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
/* StencilFunction */
#define GR_GL_NEVER 0x0200

View File

@ -12,7 +12,6 @@
#include "GrGLTextureRenderTarget.h"
#include "GrGpuResourcePriv.h"
#include "GrPipeline.h"
#include "GrPLSGeometryProcessor.h"
#include "GrRenderTargetPriv.h"
#include "GrSurfacePriv.h"
#include "GrTexturePriv.h"
@ -21,7 +20,6 @@
#include "builders/GrGLShaderStringBuilder.h"
#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLPLSPathRendering.h"
#include "SkStrokeRec.h"
#include "SkTemplates.h"
@ -40,6 +38,7 @@
#define CHECK_ALLOC_ERROR(iface) GR_GL_NO_ERROR
#endif
///////////////////////////////////////////////////////////////////////////////
@ -225,14 +224,6 @@ GrGLGpu::GrGLGpu(GrGLContext* ctx, GrContext* context)
this->createCopyPrograms();
fWireRectProgram.fProgram = 0;
fWireRectArrayBuffer = 0;
if (this->glCaps().shaderCaps()->plsPathRenderingSupport()) {
this->createPLSSetupProgram();
}
else {
memset(&fPLSSetupProgram, 0, sizeof(fPLSSetupProgram));
}
fHWPLSEnabled = false;
fPLSHasBeenUsed = false;
}
GrGLGpu::~GrGLGpu() {
@ -274,106 +265,9 @@ GrGLGpu::~GrGLGpu() {
GL_CALL(DeleteBuffers(1, &fWireRectArrayBuffer));
}
if (0 != fPLSSetupProgram.fArrayBuffer) {
GL_CALL(DeleteBuffers(1, &fPLSSetupProgram.fArrayBuffer));
}
if (0 != fPLSSetupProgram.fProgram) {
GL_CALL(DeleteProgram(fPLSSetupProgram.fProgram));
}
delete fProgramCache;
}
void GrGLGpu::createPLSSetupProgram() {
const char* version = this->glCaps().glslCaps()->versionDeclString();
GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttribute_TypeModifier);
GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
GrShaderVar::kUniform_TypeModifier);
GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
GrGLSLShaderVar uTexture("u_texture", kSampler2D_GrSLType, GrShaderVar::kUniform_TypeModifier);
GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kVaryingOut_TypeModifier);
SkString vshaderTxt(version);
aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt);
vshaderTxt.append(";");
uTexCoordXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt);
vshaderTxt.append(";");
uPosXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt);
vshaderTxt.append(";");
vTexCoord.appendDecl(this->glCaps().glslCaps(), &vshaderTxt);
vshaderTxt.append(";");
vshaderTxt.append(
"// PLS Setup Program VS\n"
"void main() {"
" gl_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;"
" gl_Position.zw = vec2(0, 1);"
"}"
);
SkString fshaderTxt(version);
fshaderTxt.append("#extension ");
fshaderTxt.append(this->glCaps().glslCaps()->fbFetchExtensionString());
fshaderTxt.append(" : require\n");
fshaderTxt.append("#extension GL_EXT_shader_pixel_local_storage : require\n");
GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision,
*this->glCaps().glslCaps(),
&fshaderTxt);
vTexCoord.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier);
vTexCoord.appendDecl(this->glCaps().glslCaps(), &fshaderTxt);
fshaderTxt.append(";");
uTexture.appendDecl(this->glCaps().glslCaps(), &fshaderTxt);
fshaderTxt.append(";");
fshaderTxt.appendf(
"// PLS Setup Program FS\n"
GR_GL_PLS_PATH_DATA_DECL
"void main() {\n"
" " GR_GL_PLS_DSTCOLOR_NAME " = gl_LastFragColorARM;\n"
" pls.windings = ivec4(0, 0, 0, 0);\n"
"}"
);
GL_CALL_RET(fPLSSetupProgram.fProgram, CreateProgram());
const char* str;
GrGLint length;
str = vshaderTxt.c_str();
length = SkToInt(vshaderTxt.size());
GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fPLSSetupProgram.fProgram,
GR_GL_VERTEX_SHADER, &str, &length, 1, &fStats);
str = fshaderTxt.c_str();
length = SkToInt(fshaderTxt.size());
GrGLuint fshader = GrGLCompileAndAttachShader(*fGLContext, fPLSSetupProgram.fProgram,
GR_GL_FRAGMENT_SHADER, &str, &length, 1, &fStats);
GL_CALL(LinkProgram(fPLSSetupProgram.fProgram));
GL_CALL_RET(fPLSSetupProgram.fPosXformUniform, GetUniformLocation(fPLSSetupProgram.fProgram,
"u_posXform"));
GL_CALL(BindAttribLocation(fPLSSetupProgram.fProgram, 0, "a_vertex"));
GL_CALL(DeleteShader(vshader));
GL_CALL(DeleteShader(fshader));
GL_CALL(GenBuffers(1, &fPLSSetupProgram.fArrayBuffer));
fHWGeometryState.setVertexBufferID(this, fPLSSetupProgram.fArrayBuffer);
static const GrGLfloat vdata[] = {
0, 0,
0, 1,
1, 0,
1, 1
};
GL_ALLOC_CALL(this->glInterface(),
BufferData(GR_GL_ARRAY_BUFFER,
(GrGLsizeiptr) sizeof(vdata),
vdata, // data ptr
GR_GL_STATIC_DRAW));
}
void GrGLGpu::contextAbandoned() {
INHERITED::contextAbandoned();
fProgramCache->abandon();
@ -2307,28 +2201,8 @@ bool GrGLGpu::onReadPixels(GrSurface* surface,
return true;
}
void GrGLGpu::performFlushWorkaround() {
if (fPLSHasBeenUsed) {
/* There is an ARM driver bug where if we use PLS, and then draw a frame which does not
* use PLS, it leaves garbage all over the place. As a workaround, we use PLS in a
* trivial way every frame. And since we use it every frame, there's never a point at which
* it becomes safe to stop using this workaround once we start.
*/
this->disableScissor();
// using PLS in the presence of MSAA results in GL_INVALID_OPERATION
this->flushHWAAState(nullptr, false);
SkASSERT(!fHWPLSEnabled);
SkASSERT(fMSAAEnabled != kYes_TriState);
GL_CALL(Enable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE));
this->stampRectUsingProgram(fPLSSetupProgram.fProgram,
SkRect::MakeXYWH(-100.0f, -100.0f, 0.01f, 0.01f),
fPLSSetupProgram.fPosXformUniform,
fPLSSetupProgram.fArrayBuffer);
GL_CALL(Disable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE));
}
}
void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound) {
SkASSERT(target);
uint32_t rtID = target->getUniqueID();
@ -2411,19 +2285,6 @@ void GrGLGpu::onDraw(const DrawArgs& args, const GrNonInstancedVertices& vertice
return;
}
GrPixelLocalStorageState plsState = args.fPrimitiveProcessor->getPixelLocalStorageState();
if (!fHWPLSEnabled && plsState !=
GrPixelLocalStorageState::kDisabled_GrPixelLocalStorageState) {
GL_CALL(Enable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE));
this->setupPixelLocalStorage(args);
fHWPLSEnabled = true;
}
if (plsState == GrPixelLocalStorageState::kFinish_GrPixelLocalStorageState) {
GrStencilSettings stencil;
stencil.setDisabled();
this->flushStencil(stencil);
}
size_t indexOffsetInBytes = 0;
this->setupGeometry(*args.fPrimitiveProcessor, vertices, &indexOffsetInBytes);
@ -2445,16 +2306,6 @@ void GrGLGpu::onDraw(const DrawArgs& args, const GrNonInstancedVertices& vertice
GL_CALL(DrawArrays(gPrimitiveType2GLMode[vertices.primitiveType()], 0,
vertices.vertexCount()));
}
if (fHWPLSEnabled && plsState == GrPixelLocalStorageState::kFinish_GrPixelLocalStorageState) {
// PLS draws always involve multiple draws, finishing up with a non-PLS
// draw that writes to the color buffer. That draw ends up here; we wait
// until after it is complete to actually disable PLS.
GL_CALL(Disable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE));
fHWPLSEnabled = false;
this->disableScissor();
}
#if SWAP_PER_DRAW
glFlush();
#if defined(SK_BUILD_FOR_MAC)
@ -2469,57 +2320,6 @@ void GrGLGpu::onDraw(const DrawArgs& args, const GrNonInstancedVertices& vertice
#endif
}
void GrGLGpu::stampRectUsingProgram(GrGLuint program, const SkRect& bounds, GrGLint posXformUniform,
GrGLuint arrayBuffer) {
GL_CALL(UseProgram(program));
this->fHWGeometryState.setVertexArrayID(this, 0);
GrGLAttribArrayState* attribs =
this->fHWGeometryState.bindArrayAndBufferToDraw(this, arrayBuffer);
attribs->set(this, 0, arrayBuffer, 2, GR_GL_FLOAT, false, 2 * sizeof(GrGLfloat), 0);
attribs->disableUnusedArrays(this, 0x1);
GL_CALL(Uniform4f(posXformUniform, bounds.width(), bounds.height(), bounds.left(),
bounds.top()));
GrXferProcessor::BlendInfo blendInfo;
blendInfo.reset();
this->flushBlend(blendInfo, GrSwizzle());
this->flushColorWrite(true);
this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace);
if (!fHWStencilSettings.isDisabled()) {
GL_CALL(Disable(GR_GL_STENCIL_TEST));
}
GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4));
GL_CALL(UseProgram(fHWProgramID));
if (!fHWStencilSettings.isDisabled()) {
GL_CALL(Enable(GR_GL_STENCIL_TEST));
}
}
void GrGLGpu::setupPixelLocalStorage(const DrawArgs& args) {
fPLSHasBeenUsed = true;
const SkRect& bounds =
static_cast<const GrPLSGeometryProcessor*>(args.fPrimitiveProcessor)->getBounds();
// setup pixel local storage -- this means capturing and storing the current framebuffer color
// and initializing the winding counts to zero
GrRenderTarget* rt = args.fPipeline->getRenderTarget();
SkScalar width = SkIntToScalar(rt->width());
SkScalar height = SkIntToScalar(rt->height());
// dst rect edges in NDC (-1 to 1)
// having some issues with rounding, just expand the bounds by 1 and trust the scissor to keep
// it contained properly
GrGLfloat dx0 = 2.0f * (bounds.left() - 1) / width - 1.0f;
GrGLfloat dx1 = 2.0f * (bounds.right() + 1) / width - 1.0f;
GrGLfloat dy0 = -2.0f * (bounds.top() - 1) / height + 1.0f;
GrGLfloat dy1 = -2.0f * (bounds.bottom() + 1) / height + 1.0f;
SkRect deviceBounds = SkRect::MakeXYWH(dx0, dy0, dx1 - dx0, dy1 - dy0);
GL_CALL(Enable(GR_GL_FETCH_PER_SAMPLE_ARM));
this->stampRectUsingProgram(fPLSSetupProgram.fProgram, deviceBounds,
fPLSSetupProgram.fPosXformUniform, fPLSSetupProgram.fArrayBuffer);
}
void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) {
GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target);
if (rt->needsResolve()) {

View File

@ -134,8 +134,6 @@ public:
void drawDebugWireRect(GrRenderTarget*, const SkIRect&, GrColor) override;
void performFlushWorkaround() override;
private:
GrGLGpu(GrGLContext* ctx, GrContext* context);
@ -236,11 +234,6 @@ private:
const SkIRect& srcRect,
const SkIPoint& dstPoint);
void stampRectUsingProgram(GrGLuint program, const SkRect& bounds, GrGLint posXformUniform,
GrGLuint arrayBuffer);
void setupPixelLocalStorage(const DrawArgs& args);
static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff);
class ProgramCache : public ::SkNoncopyable {
@ -362,8 +355,6 @@ private:
void createWireRectProgram();
void createUnitRectBuffer();
void createPLSSetupProgram();
// GL program-related state
ProgramCache* fProgramCache;
@ -574,15 +565,6 @@ private:
}
}
struct {
GrGLuint fProgram;
GrGLint fPosXformUniform;
GrGLuint fArrayBuffer;
} fPLSSetupProgram;
bool fHWPLSEnabled;
bool fPLSHasBeenUsed;
typedef GrGpu INHERITED;
friend class GrGLPathRendering; // For accessing setTextureUnit.
};

View File

@ -89,12 +89,9 @@ void GrGLProgram::setData(const GrPrimitiveProcessor& primProc,
this->setFragmentData(primProc, pipeline, textureBindings);
if (primProc.getPixelLocalStorageState() !=
GrPixelLocalStorageState::kDraw_GrPixelLocalStorageState) {
const GrXferProcessor& xp = pipeline.getXferProcessor();
fXferProcessor->setData(fProgramDataManager, xp);
append_texture_bindings(xp, textureBindings);
}
const GrXferProcessor& xp = pipeline.getXferProcessor();
fXferProcessor->setData(fProgramDataManager, xp);
append_texture_bindings(xp, textureBindings);
}
void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc,

View File

@ -26,7 +26,7 @@ GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray(
SkDEBUGCODE(static const uint32_t kVisibilityMask = kVertex_Visibility | kFragment_Visibility);
SkASSERT(0 == (~kVisibilityMask & visibility));
SkASSERT(0 != visibility);
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
UniformInfo& uni = fUniforms.push_back();
uni.fVariable.setType(type);

View File

@ -24,6 +24,7 @@ struct GrGLAttribLayout {
};
static inline const GrGLAttribLayout& GrGLAttribTypeToLayout(GrVertexAttribType type) {
SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount);
static const GrGLAttribLayout kLayouts[kGrVertexAttribTypeCount] = {
{1, GR_GL_FLOAT, false}, // kFloat_GrVertexAttribType
{2, GR_GL_FLOAT, false}, // kVec2f_GrVertexAttribType
@ -32,7 +33,6 @@ static inline const GrGLAttribLayout& GrGLAttribTypeToLayout(GrVertexAttribType
{1, GR_GL_UNSIGNED_BYTE, true}, // kUByte_GrVertexAttribType
{4, GR_GL_UNSIGNED_BYTE, true}, // kVec4ub_GrVertexAttribType
{2, GR_GL_SHORT, false}, // kVec2s_GrVertexAttribType
{4, GR_GL_INT, false}, // kInt_GrVertexAttribType
};
GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType);
GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType);
@ -41,7 +41,6 @@ static inline const GrGLAttribLayout& GrGLAttribTypeToLayout(GrVertexAttribType
GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType);
GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType);
GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType);
GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kLayouts) == kGrVertexAttribTypeCount);
return kLayouts[type];
}

View File

@ -100,10 +100,6 @@ static inline const char* GrGLSLTypeString(GrSLType t) {
return "samplerExternalOES";
case kSampler2DRect_GrSLType:
return "sampler2DRect";
case kBool_GrSLType:
return "bool";
case kInt_GrSLType:
return "int";
default:
SkFAIL("Unknown shader var type.");
return ""; // suppress warning

View File

@ -7,7 +7,6 @@
#include "GrGLSLFragmentShaderBuilder.h"
#include "GrRenderTarget.h"
#include "gl/GrGLGpu.h"
#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLProgramBuilder.h"
@ -88,14 +87,6 @@ bool GrGLSLFragmentShaderBuilder::enableFeature(GLSLFeature feature) {
}
return true;
}
case kPixelLocalStorage_GLSLFeature: {
if (fProgramBuilder->glslCaps()->pixelLocalStorageSize() <= 0) {
return false;
}
this->addFeature(1 << kPixelLocalStorage_GLSLFeature,
"GL_EXT_shader_pixel_local_storage");
return true;
}
default:
SkFAIL("Unexpected GLSLFeature requested.");
return false;
@ -169,11 +160,6 @@ const char* GrGLSLFragmentShaderBuilder::fragmentPosition() {
const char* GrGLSLFragmentShaderBuilder::dstColor() {
fHasReadDstColor = true;
const char* override = fProgramBuilder->primitiveProcessor().getDestColorOverride();
if (override != nullptr) {
return override;
}
const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps();
if (glslCaps->fbFetchSupport()) {
this->addFeature(1 << (GrGLSLFragmentShaderBuilder::kLastGLSLPrivateFeature + 1),
@ -241,13 +227,6 @@ const char* GrGLSLFragmentShaderBuilder::getPrimaryColorOutputName() const {
return fHasCustomColorOutput ? DeclaredColorOutputName() : "gl_FragColor";
}
void GrGLSLFragmentBuilder::declAppendf(const char* fmt, ...) {
va_list argp;
va_start(argp, fmt);
inputs().appendVAList(fmt, argp);
va_end(argp);
}
const char* GrGLSLFragmentShaderBuilder::getSecondaryColorOutputName() const {
const GrGLSLCaps& caps = *fProgramBuilder->glslCaps();
return caps.mustDeclareFragmentShaderOutput() ? DeclaredSecondaryColorOutputName()

View File

@ -33,8 +33,7 @@ public:
*/
enum GLSLFeature {
kStandardDerivatives_GLSLFeature = 0,
kPixelLocalStorage_GLSLFeature = 1,
kLastGLSLFeature = kPixelLocalStorage_GLSLFeature
kLastGLSLFeature = kStandardDerivatives_GLSLFeature
};
/**
@ -67,8 +66,6 @@ public:
bool hasCustomColorOutput() const { return fHasCustomColorOutput; }
bool hasSecondaryOutput() const { return fHasSecondaryOutput; }
void declAppendf(const char* fmt, ...);
protected:
bool fHasCustomColorOutput;
bool fHasSecondaryOutput;

View File

@ -1,13 +0,0 @@
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#define GR_GL_PLS_DSTCOLOR_NAME "pls.dstColor"
#define GR_GL_PLS_PATH_DATA_DECL "__pixel_localEXT PLSData {\n"\
" layout(rgba8i) ivec4 windings;\n"\
" layout(rgba8) vec4 dstColor;\n"\
"} pls;\n"

View File

@ -53,13 +53,9 @@ bool GrGLSLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor,
this->emitAndInstallFragProcs(0, this->pipeline().numColorFragmentProcessors(), inputColor);
this->emitAndInstallFragProcs(this->pipeline().numColorFragmentProcessors(), numProcs,
inputCoverage);
if (primProc.getPixelLocalStorageState() !=
GrPixelLocalStorageState::kDraw_GrPixelLocalStorageState) {
this->emitAndInstallXferProc(this->pipeline().getXferProcessor(), *inputColor,
*inputCoverage, this->pipeline().ignoresCoverage(),
primProc.getPixelLocalStorageState());
this->emitFSOutputSwizzle(this->pipeline().getXferProcessor().hasSecondaryOutput());
}
this->emitAndInstallXferProc(this->pipeline().getXferProcessor(), *inputColor, *inputCoverage,
this->pipeline().ignoresCoverage());
this->emitFSOutputSwizzle(this->pipeline().getXferProcessor().hasSecondaryOutput());
return true;
}
@ -155,8 +151,7 @@ void GrGLSLProgramBuilder::emitAndInstallFragProc(const GrFragmentProcessor& fp,
void GrGLSLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp,
const GrGLSLExpr4& colorIn,
const GrGLSLExpr4& coverageIn,
bool ignoresCoverage,
GrPixelLocalStorageState plsState) {
bool ignoresCoverage) {
// Program builders have a bit of state we need to clear with each effect
AutoStageAdvance adv(this);
@ -179,7 +174,6 @@ void GrGLSLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp,
SkSTArray<4, GrGLSLTextureSampler> samplers(xp.numTextures());
this->emitSamplers(xp, &samplers);
bool usePLSDstRead = (plsState == GrPixelLocalStorageState::kFinish_GrPixelLocalStorageState);
GrGLSLXferProcessor::EmitArgs args(&fFS,
this->uniformHandler(),
this->glslCaps(),
@ -187,8 +181,7 @@ void GrGLSLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp,
ignoresCoverage ? nullptr : coverageIn.c_str(),
fFS.getPrimaryColorOutputName(),
fFS.getSecondaryColorOutputName(),
samplers,
usePLSDstRead);
samplers);
fXferProcessor->emitCode(args);
// We have to check that effects and the code they emit are consistent, ie if an effect

View File

@ -131,8 +131,7 @@ private:
void emitAndInstallXferProc(const GrXferProcessor&,
const GrGLSLExpr4& colorIn,
const GrGLSLExpr4& coverageIn,
bool ignoresCoverage,
GrPixelLocalStorageState plsState);
bool ignoresCoverage);
void emitFSOutputSwizzle(bool hasSecondaryOutput);
void verify(const GrPrimitiveProcessor&);

View File

@ -73,7 +73,7 @@ public:
const char* layoutQualifier = nullptr,
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
SkASSERT(kVoid_GrSLType != type);
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
INHERITED::set(type, name, typeModifier, precision);
fLayoutQualifier = layoutQualifier;
fUseUniformFloatArrays = useUniformFloatArrays;
@ -89,7 +89,7 @@ public:
const char* layoutQualifier = nullptr,
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
SkASSERT(kVoid_GrSLType != type);
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
INHERITED::set(type, name, typeModifier, precision);
fLayoutQualifier = layoutQualifier;
fUseUniformFloatArrays = useUniformFloatArrays;
@ -106,7 +106,7 @@ public:
const char* layoutQualifier = nullptr,
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
SkASSERT(kVoid_GrSLType != type);
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
INHERITED::set(type, name, typeModifier, precision, count);
fLayoutQualifier = layoutQualifier;
fUseUniformFloatArrays = useUniformFloatArrays;
@ -123,7 +123,7 @@ public:
const char* layoutQualifier = nullptr,
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
SkASSERT(kVoid_GrSLType != type);
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
INHERITED::set(type, name, typeModifier, precision, count);
fLayoutQualifier = layoutQualifier;
fUseUniformFloatArrays = useUniformFloatArrays;
@ -140,22 +140,16 @@ public:
* Write a declaration of this variable to out.
*/
void appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const {
SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeIsNumeric(fType));
SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeIsFloatType(fType));
if (!fLayoutQualifier.isEmpty()) {
out->appendf("layout(%s) ", fLayoutQualifier.c_str());
}
if (this->getTypeModifier() != kNone_TypeModifier) {
if (GrSLTypeIsIntType(fType) && (this->getTypeModifier() == kVaryingIn_TypeModifier ||
this->getTypeModifier() == kVaryingOut_TypeModifier)) {
out->append("flat ");
}
out->append(TypeModifierString(glslCaps, this->getTypeModifier()));
out->append(" ");
out->append(TypeModifierString(glslCaps, this->getTypeModifier()));
out->append(" ");
}
out->append(PrecisionString(glslCaps, fPrecision));
GrSLType effectiveType = this->getType();
if (effectiveType != kBool_GrSLType) {
out->append(PrecisionString(glslCaps, fPrecision));
}
if (this->isArray()) {
if (this->isUnsizedArray()) {
out->appendf("%s %s[]",

View File

@ -32,8 +32,7 @@ public:
const char* inputCoverage,
const char* outputPrimary,
const char* outputSecondary,
const TextureSamplerArray& samplers,
const bool usePLSDstRead)
const TextureSamplerArray& samplers)
: fXPFragBuilder(fragBuilder)
, fUniformHandler(uniformHandler)
, fGLSLCaps(caps)
@ -42,8 +41,7 @@ public:
, fInputCoverage(inputCoverage)
, fOutputPrimary(outputPrimary)
, fOutputSecondary(outputSecondary)
, fSamplers(samplers)
, fUsePLSDstRead(usePLSDstRead) {}
, fSamplers(samplers) {}
GrGLSLXPFragmentBuilder* fXPFragBuilder;
GrGLSLUniformHandler* fUniformHandler;
@ -54,7 +52,6 @@ public:
const char* fOutputPrimary;
const char* fOutputSecondary;
const TextureSamplerArray& fSamplers;
bool fUsePLSDstRead;
};
/**
* This is similar to emitCode() in the base class, except it takes a full shader builder.

View File

@ -98,7 +98,6 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
opt.fColorPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags, false);
// Setting 2nd to last value to false and last to true will force covPOI to LCD coverage.
opt.fCoveragePOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags, false, true);
opt.fOverrides.fUsePLSDstRead = false;
SkASSERT(!opt.fColorPOI.isOpaque());
SkASSERT(!opt.fColorPOI.isSolidWhite());
@ -291,7 +290,6 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
false);
optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags,
true);
optimizations.fOverrides.fUsePLSDstRead = false;
SkASSERT(!optimizations.fColorPOI.isOpaque());
SkASSERT(!optimizations.fColorPOI.isSolidWhite());
@ -486,7 +484,6 @@ static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G
kR_GrColorComponentFlag | kB_GrColorComponentFlag, false);
optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255),
kRGBA_GrColorComponentFlags, true);
optimizations.fOverrides.fUsePLSDstRead = false;
SkASSERT(!optimizations.fColorPOI.isOpaque());
SkASSERT(!optimizations.fColorPOI.isSolidWhite());
@ -691,7 +688,6 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
kA_GrColorComponentFlag, false);
optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags,
true);
optimizations.fOverrides.fUsePLSDstRead = false;
SkASSERT(optimizations.fColorPOI.isOpaque());
SkASSERT(!optimizations.fColorPOI.isSolidWhite());
@ -891,7 +887,6 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
kG_GrColorComponentFlag | kA_GrColorComponentFlag, false);
optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255),
kRGBA_GrColorComponentFlags, true);
optimizations.fOverrides.fUsePLSDstRead = false;
SkASSERT(optimizations.fColorPOI.isOpaque());
SkASSERT(!optimizations.fColorPOI.isSolidWhite());