Move the ability to access textures, buffers, and image storages out from GrProcessor.
GrXferProcessor can no longer use this functionality so it is moved to a new intermediate class inherited by GrFragmentProcessor and GrPrimitiveProcessor. Change-Id: I4f30c89bdceb2d77b602bf0646107e0780881c26 Reviewed-on: https://skia-review.googlesource.com/11202 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
19aff5dd5c
commit
ab015efc48
@ -608,7 +608,7 @@ public:
|
||||
static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder* b);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
GrGLSLProgramDataManager::UniformHandle fStitchDataUni;
|
||||
@ -1003,7 +1003,7 @@ void GrGLPerlinNoise2::GenKey(const GrProcessor& processor, const GrShaderCaps&,
|
||||
}
|
||||
|
||||
void GrGLPerlinNoise2::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& processor) {
|
||||
const GrFragmentProcessor& processor) {
|
||||
INHERITED::onSetData(pdman, processor);
|
||||
|
||||
const GrPerlinNoise2Effect& turbulence = processor.cast<GrPerlinNoise2Effect>();
|
||||
@ -1027,7 +1027,7 @@ public:
|
||||
static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
GrGLSLProgramDataManager::UniformHandle fZUni;
|
||||
@ -1277,7 +1277,7 @@ void GrGLImprovedPerlinNoise::GenKey(const GrProcessor& processor, const GrShade
|
||||
}
|
||||
|
||||
void GrGLImprovedPerlinNoise::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& processor) {
|
||||
const GrFragmentProcessor& processor) {
|
||||
INHERITED::onSetData(pdman, processor);
|
||||
|
||||
const GrImprovedPerlinNoiseEffect& noise = processor.cast<GrImprovedPerlinNoiseEffect>();
|
||||
|
@ -23,7 +23,7 @@ class GrSwizzle;
|
||||
GrCoordTransforms to receive a transformation of the local coordinates that map from local space
|
||||
to the fragment being processed.
|
||||
*/
|
||||
class GrFragmentProcessor : public GrProcessor {
|
||||
class GrFragmentProcessor : public GrResourceIOProcessor {
|
||||
public:
|
||||
/**
|
||||
* In many instances (e.g. SkShader::asFragmentProcessor() implementations) it is desirable to
|
||||
@ -228,9 +228,9 @@ public:
|
||||
&GrFragmentProcessor::coordTransform>;
|
||||
|
||||
using TextureAccessIter = FPItemIter<TextureSampler,
|
||||
GrProcessor,
|
||||
&GrProcessor::numTextureSamplers,
|
||||
&GrProcessor::textureSampler>;
|
||||
GrResourceIOProcessor,
|
||||
&GrResourceIOProcessor::numTextureSamplers,
|
||||
&GrResourceIOProcessor::textureSampler>;
|
||||
|
||||
protected:
|
||||
enum OptimizationFlags : uint32_t {
|
||||
|
@ -79,7 +79,7 @@ private:
|
||||
called. */
|
||||
void pendingIOComplete() const;
|
||||
|
||||
friend class GrProcessor;
|
||||
friend class GrResourceIOProcessor;
|
||||
|
||||
GrGpuResource* fResource;
|
||||
mutable bool fOwnRef;
|
||||
|
@ -63,11 +63,7 @@ private:
|
||||
*/
|
||||
class GrProcessor : public GrProgramElement<GrProcessor> {
|
||||
public:
|
||||
class TextureSampler;
|
||||
class BufferAccess;
|
||||
class ImageStorageAccess;
|
||||
|
||||
virtual ~GrProcessor();
|
||||
virtual ~GrProcessor() = default;
|
||||
|
||||
/** Human-meaningful string to identify this prcoessor; may be embedded in generated shader
|
||||
code. */
|
||||
@ -80,26 +76,6 @@ public:
|
||||
return str;
|
||||
}
|
||||
|
||||
int numTextureSamplers() const { return fTextureSamplers.count(); }
|
||||
|
||||
/** Returns the access pattern for the texture at index. index must be valid according to
|
||||
numTextureSamplers(). */
|
||||
const TextureSampler& textureSampler(int index) const { return *fTextureSamplers[index]; }
|
||||
|
||||
int numBuffers() const { return fBufferAccesses.count(); }
|
||||
|
||||
/** Returns the access pattern for the buffer at index. index must be valid according to
|
||||
numBuffers(). */
|
||||
const BufferAccess& bufferAccess(int index) const { return *fBufferAccesses[index]; }
|
||||
|
||||
int numImageStorages() const { return fImageStorageAccesses.count(); }
|
||||
|
||||
/** Returns the access object for the image at index. index must be valid according to
|
||||
numImages(). */
|
||||
const ImageStorageAccess& imageStorageAccess(int index) const {
|
||||
return *fImageStorageAccesses[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Platform specific built-in features that a processor can request for the fragment shader.
|
||||
*/
|
||||
@ -130,18 +106,6 @@ public:
|
||||
protected:
|
||||
GrProcessor() : fClassID(kIllegalProcessorClassID), fRequiredFeatures(kNone_RequiredFeatures) {}
|
||||
|
||||
/**
|
||||
* Subclasses call these from their constructor to register sampler/image sources. The processor
|
||||
* subclass manages the lifetime of the objects (these functions only store pointers). The
|
||||
* TextureSampler and/or BufferAccess instances are typically member fields of the GrProcessor
|
||||
* subclass. These must only be called from the constructor because GrProcessors are immutable.
|
||||
*/
|
||||
void addTextureSampler(const TextureSampler*);
|
||||
void addBufferAccess(const BufferAccess*);
|
||||
void addImageStorageAccess(const ImageStorageAccess*);
|
||||
|
||||
bool hasSameSamplersAndAccesses(const GrProcessor &) const;
|
||||
|
||||
/**
|
||||
* If the prcoessor will generate code that uses platform specific built-in features, then it
|
||||
* must call these methods from its constructor. Otherwise, requests to use these features will
|
||||
@ -172,9 +136,9 @@ private:
|
||||
}
|
||||
|
||||
friend class GrProgramElement<GrProcessor>;
|
||||
void addPendingIOs() const;
|
||||
void removeRefs() const;
|
||||
void pendingIOComplete() const;
|
||||
virtual void addPendingIOs() const {}
|
||||
virtual void removeRefs() const {}
|
||||
virtual void pendingIOComplete() const {}
|
||||
|
||||
enum {
|
||||
kIllegalProcessorClassID = 0,
|
||||
@ -183,21 +147,73 @@ private:
|
||||
|
||||
uint32_t fClassID;
|
||||
RequiredFeatures fRequiredFeatures;
|
||||
SkSTArray<4, const TextureSampler*, true> fTextureSamplers;
|
||||
SkSTArray<1, const BufferAccess*, true> fBufferAccesses;
|
||||
SkSTArray<1, const ImageStorageAccess*, true> fImageStorageAccesses;
|
||||
|
||||
typedef GrProgramElement INHERITED;
|
||||
};
|
||||
|
||||
GR_MAKE_BITFIELD_OPS(GrProcessor::RequiredFeatures);
|
||||
|
||||
/** A GrProcessor with the ability to access textures, buffers, and image storages. */
|
||||
class GrResourceIOProcessor : public GrProcessor {
|
||||
public:
|
||||
class TextureSampler;
|
||||
class BufferAccess;
|
||||
class ImageStorageAccess;
|
||||
|
||||
int numTextureSamplers() const { return fTextureSamplers.count(); }
|
||||
|
||||
/** Returns the access pattern for the texture at index. index must be valid according to
|
||||
numTextureSamplers(). */
|
||||
const TextureSampler& textureSampler(int index) const { return *fTextureSamplers[index]; }
|
||||
|
||||
int numBuffers() const { return fBufferAccesses.count(); }
|
||||
|
||||
/** Returns the access pattern for the buffer at index. index must be valid according to
|
||||
numBuffers(). */
|
||||
const BufferAccess& bufferAccess(int index) const { return *fBufferAccesses[index]; }
|
||||
|
||||
int numImageStorages() const { return fImageStorageAccesses.count(); }
|
||||
|
||||
/** Returns the access object for the image at index. index must be valid according to
|
||||
numImages(). */
|
||||
const ImageStorageAccess& imageStorageAccess(int index) const {
|
||||
return *fImageStorageAccesses[index];
|
||||
}
|
||||
|
||||
protected:
|
||||
GrResourceIOProcessor() = default;
|
||||
|
||||
/**
|
||||
* Subclasses call these from their constructor to register sampler/image sources. The processor
|
||||
* subclass manages the lifetime of the objects (these functions only store pointers). The
|
||||
* TextureSampler and/or BufferAccess instances are typically member fields of the GrProcessor
|
||||
* subclass. These must only be called from the constructor because GrProcessors are immutable.
|
||||
*/
|
||||
void addTextureSampler(const TextureSampler*);
|
||||
void addBufferAccess(const BufferAccess*);
|
||||
void addImageStorageAccess(const ImageStorageAccess*);
|
||||
|
||||
bool hasSameSamplersAndAccesses(const GrResourceIOProcessor&) const;
|
||||
|
||||
private:
|
||||
friend class GrProgramElement<GrProcessor>;
|
||||
void addPendingIOs() const override;
|
||||
void removeRefs() const override;
|
||||
void pendingIOComplete() const override;
|
||||
|
||||
SkSTArray<4, const TextureSampler*, true> fTextureSamplers;
|
||||
SkSTArray<1, const BufferAccess*, true> fBufferAccesses;
|
||||
SkSTArray<1, const ImageStorageAccess*, true> fImageStorageAccesses;
|
||||
|
||||
typedef GrProcessor INHERITED;
|
||||
};
|
||||
|
||||
/**
|
||||
* Used to represent a texture that is required by a GrProcessor. It holds a GrTexture along with
|
||||
* an associated GrSamplerParams. TextureSamplers don't perform any coord manipulation to account
|
||||
* for texture origin.
|
||||
* Used to represent a texture that is required by a GrResourceIOProcessor. It holds a GrTexture
|
||||
* along with an associated GrSamplerParams. TextureSamplers don't perform any coord manipulation to
|
||||
* account for texture origin.
|
||||
*/
|
||||
class GrProcessor::TextureSampler : public SkNoncopyable {
|
||||
class GrResourceIOProcessor::TextureSampler : public SkNoncopyable {
|
||||
public:
|
||||
/**
|
||||
* Must be initialized before adding to a GrProcessor's texture access list.
|
||||
@ -258,10 +274,10 @@ private:
|
||||
};
|
||||
|
||||
/**
|
||||
* Used to represent a texel buffer that will be read in a GrProcessor. It holds a GrBuffer along
|
||||
* with an associated offset and texel config.
|
||||
* Used to represent a texel buffer that will be read in a GrResourceIOProcessor. It holds a
|
||||
* GrBuffer along with an associated offset and texel config.
|
||||
*/
|
||||
class GrProcessor::BufferAccess : public SkNoncopyable {
|
||||
class GrResourceIOProcessor::BufferAccess : public SkNoncopyable {
|
||||
public:
|
||||
BufferAccess() = default;
|
||||
BufferAccess(GrPixelConfig texelConfig, GrBuffer* buffer,
|
||||
@ -296,9 +312,9 @@ public:
|
||||
const GrGpuResourceRef* programBuffer() const { return &fBuffer;}
|
||||
|
||||
private:
|
||||
GrPixelConfig fTexelConfig;
|
||||
GrTGpuResourceRef<GrBuffer> fBuffer;
|
||||
GrShaderFlags fVisibility;
|
||||
GrPixelConfig fTexelConfig;
|
||||
GrTGpuResourceRef<GrBuffer> fBuffer;
|
||||
GrShaderFlags fVisibility;
|
||||
|
||||
typedef SkNoncopyable INHERITED;
|
||||
};
|
||||
@ -309,7 +325,7 @@ private:
|
||||
* Currently the format of the load/store data in the shader is inferred from the texture config,
|
||||
* though it could be made explicit.
|
||||
*/
|
||||
class GrProcessor::ImageStorageAccess : public SkNoncopyable {
|
||||
class GrResourceIOProcessor::ImageStorageAccess : public SkNoncopyable {
|
||||
public:
|
||||
ImageStorageAccess(sk_sp<GrTexture> texture, GrIOType ioType, GrSLMemoryModel, GrSLRestrict,
|
||||
GrShaderFlags visibility = kFragment_GrShaderFlag);
|
||||
@ -333,11 +349,11 @@ public:
|
||||
const GrGpuResourceRef* programTexture() const { return &fTexture; }
|
||||
|
||||
private:
|
||||
GrTGpuResourceRef<GrTexture> fTexture;
|
||||
GrShaderFlags fVisibility;
|
||||
GrImageStorageFormat fFormat;
|
||||
GrSLMemoryModel fMemoryModel;
|
||||
GrSLRestrict fRestrict;
|
||||
GrTGpuResourceRef<GrTexture> fTexture;
|
||||
GrShaderFlags fVisibility;
|
||||
GrImageStorageFormat fFormat;
|
||||
GrSLMemoryModel fMemoryModel;
|
||||
GrSLRestrict fRestrict;
|
||||
typedef SkNoncopyable INHERITED;
|
||||
};
|
||||
|
||||
|
@ -320,7 +320,7 @@ public:
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager& uniManager,
|
||||
const GrProcessor& proc) override {
|
||||
const GrFragmentProcessor& proc) override {
|
||||
const ColorMatrixEffect& cme = proc.cast<ColorMatrixEffect>();
|
||||
const float* m = cme.fMatrix;
|
||||
// The GL matrix is transposed from SkColorMatrix.
|
||||
|
@ -199,7 +199,8 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor& proc) override {
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& proc) override {
|
||||
const LightingFP& lightingFP = proc.cast<LightingFP>();
|
||||
|
||||
const SkTArray<SkLights::Light>& directionalLights = lightingFP.directionalLights();
|
||||
|
@ -112,7 +112,7 @@ public:
|
||||
|
||||
protected:
|
||||
void setNormalData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& proc) override {
|
||||
const GrFragmentProcessor& proc) override {
|
||||
const NormalBevelFP& normalBevelFP = proc.cast<NormalBevelFP>();
|
||||
|
||||
// Updating uniform if bevel type requires it and data has changed
|
||||
|
@ -39,8 +39,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void setNormalData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& proc) override {}
|
||||
void setNormalData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override {}
|
||||
};
|
||||
|
||||
const char* name() const override { return "NormalFlatFP"; }
|
||||
|
@ -79,7 +79,7 @@ public:
|
||||
|
||||
protected:
|
||||
void setNormalData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& proc) override {
|
||||
const GrFragmentProcessor& proc) override {
|
||||
const NormalMapFP& normalMapFP = proc.cast<NormalMapFP>();
|
||||
|
||||
const SkMatrix& invCTM = normalMapFP.invCTM();
|
||||
|
@ -39,7 +39,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor& proc) final override {
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& proc) final override {
|
||||
if (!fDidIntercept) {
|
||||
this->setNormalData(pdman, proc);
|
||||
}
|
||||
@ -47,7 +48,7 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void onEmitCode(EmitArgs& args) = 0;
|
||||
virtual void setNormalData(const GrGLSLProgramDataManager& pdman, const GrProcessor& proc) = 0;
|
||||
virtual void setNormalData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) = 0;
|
||||
|
||||
private:
|
||||
bool fDidIntercept;
|
||||
|
@ -181,7 +181,8 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor& proc) override {
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& proc) override {
|
||||
const RadialShadowMapFP &radialShadowMapFP = proc.cast<RadialShadowMapFP>();
|
||||
|
||||
const SkVector3& lightPos = radialShadowMapFP.lightPos();
|
||||
|
@ -461,7 +461,8 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor& proc) override {
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& proc) override {
|
||||
const ShadowFP &shadowFP = proc.cast<ShadowFP>();
|
||||
|
||||
for (int i = 0; i < shadowFP.numLights(); i++) {
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
GrGLSLProgramDataManager::UniformHandle fInnerThresholdVar;
|
||||
@ -132,7 +132,7 @@ void GrGLAlphaThresholdFragmentProcessor::emitCode(EmitArgs& args) {
|
||||
}
|
||||
|
||||
void GrGLAlphaThresholdFragmentProcessor::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& proc) {
|
||||
const GrFragmentProcessor& proc) {
|
||||
const GrAlphaThresholdFragmentProcessor& atfp = proc.cast<GrAlphaThresholdFragmentProcessor>();
|
||||
pdman.set1f(fInnerThresholdVar, atfp.innerThreshold());
|
||||
pdman.set1f(fOuterThresholdVar, atfp.outerThreshold());
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
void emitCode(EmitArgs&) override;
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
GrGLSLProgramDataManager::UniformHandle fDataUniform;
|
||||
@ -68,7 +68,7 @@ void GrCircleBlurFragmentProcessor::GLSLProcessor::emitCode(EmitArgs& args) {
|
||||
}
|
||||
|
||||
void GrCircleBlurFragmentProcessor::GLSLProcessor::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& proc) {
|
||||
const GrFragmentProcessor& proc) {
|
||||
const GrCircleBlurFragmentProcessor& cbfp = proc.cast<GrCircleBlurFragmentProcessor>();
|
||||
const SkRect& circle = cbfp.fCircle;
|
||||
|
||||
|
@ -264,7 +264,7 @@ private:
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& proc) override {
|
||||
const GrFragmentProcessor& proc) override {
|
||||
const ArithmeticFP& arith = proc.cast<ArithmeticFP>();
|
||||
pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4());
|
||||
}
|
||||
|
@ -844,7 +844,7 @@ public:
|
||||
static void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder* b);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
|
||||
@ -935,7 +935,7 @@ void GrGLRectBlurEffect::emitCode(EmitArgs& args) {
|
||||
}
|
||||
|
||||
void GrGLRectBlurEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& proc) {
|
||||
const GrFragmentProcessor& proc) {
|
||||
const GrRectBlurEffect& rbe = proc.cast<GrRectBlurEffect>();
|
||||
SkRect rect = rbe.getRect();
|
||||
|
||||
@ -1249,7 +1249,7 @@ public:
|
||||
void emitCode(EmitArgs&) override;
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
GrGLSLProgramDataManager::UniformHandle fProxyRectUniform;
|
||||
@ -1315,7 +1315,7 @@ void GrGLRRectBlurEffect::emitCode(EmitArgs& args) {
|
||||
}
|
||||
|
||||
void GrGLRRectBlurEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& proc) {
|
||||
const GrFragmentProcessor& proc) {
|
||||
const GrRRectBlurEffect& brre = proc.cast<GrRRectBlurEffect>();
|
||||
const SkRRect& rrect = brre.getRRect();
|
||||
|
||||
|
@ -461,7 +461,7 @@ public:
|
||||
static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
|
||||
@ -637,7 +637,7 @@ void GrGLDisplacementMapEffect::emitCode(EmitArgs& args) {
|
||||
}
|
||||
|
||||
void GrGLDisplacementMapEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& proc) {
|
||||
const GrFragmentProcessor& proc) {
|
||||
const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMapEffect>();
|
||||
GrTexture* colorTex = displacementMap.textureSampler(1).texture();
|
||||
SkScalar scaleX = displacementMap.scale().fX / colorTex->width();
|
||||
|
@ -318,7 +318,7 @@ public:
|
||||
GLHighContrastFilterEffect(const SkHighContrastConfig& config);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
void emitCode(EmitArgs& args) override;
|
||||
|
||||
private:
|
||||
@ -337,7 +337,8 @@ void HighContrastFilterEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GLHighContrastFilterEffect::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
void GLHighContrastFilterEffect::onSetData(const GrGLSLProgramDataManager& pdm, const GrProcessor& proc) {
|
||||
void GLHighContrastFilterEffect::onSetData(const GrGLSLProgramDataManager& pdm,
|
||||
const GrFragmentProcessor& proc) {
|
||||
const HighContrastFilterEffect& hcfe = proc.cast<HighContrastFilterEffect>();
|
||||
pdm.set1f(fContrastUni, hcfe.config().fContrast);
|
||||
}
|
||||
|
@ -1638,7 +1638,7 @@ protected:
|
||||
/**
|
||||
* Subclasses of GrGLLightingEffect must call INHERITED::onSetData();
|
||||
*/
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
virtual void emitLightFunc(GrGLSLUniformHandler*,
|
||||
GrGLSLFPFragmentBuilder*,
|
||||
@ -1660,7 +1660,7 @@ public:
|
||||
void emitLightFunc(GrGLSLUniformHandler*, GrGLSLFPFragmentBuilder*, SkString* funcName) override;
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
typedef GrGLLightingEffect INHERITED;
|
||||
@ -1675,7 +1675,7 @@ public:
|
||||
void emitLightFunc(GrGLSLUniformHandler*, GrGLSLFPFragmentBuilder*, SkString* funcName) override;
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
typedef GrGLLightingEffect INHERITED;
|
||||
@ -1891,7 +1891,7 @@ void GrGLLightingEffect::GenKey(const GrProcessor& proc,
|
||||
}
|
||||
|
||||
void GrGLLightingEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& proc) {
|
||||
const GrFragmentProcessor& proc) {
|
||||
const GrLightingEffect& lighting = proc.cast<GrLightingEffect>();
|
||||
if (!fLight) {
|
||||
fLight = lighting.light()->createGLLight();
|
||||
@ -1936,7 +1936,7 @@ void GrGLDiffuseLightingEffect::emitLightFunc(GrGLSLUniformHandler* uniformHandl
|
||||
}
|
||||
|
||||
void GrGLDiffuseLightingEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& proc) {
|
||||
const GrFragmentProcessor& proc) {
|
||||
INHERITED::onSetData(pdman, proc);
|
||||
const GrDiffuseLightingEffect& diffuse = proc.cast<GrDiffuseLightingEffect>();
|
||||
pdman.set1f(fKDUni, diffuse.kd());
|
||||
@ -2038,7 +2038,7 @@ void GrGLSpecularLightingEffect::emitLightFunc(GrGLSLUniformHandler* uniformHand
|
||||
}
|
||||
|
||||
void GrGLSpecularLightingEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& effect) {
|
||||
const GrFragmentProcessor& effect) {
|
||||
INHERITED::onSetData(pdman, effect);
|
||||
const GrSpecularLightingEffect& spec = effect.cast<GrSpecularLightingEffect>();
|
||||
pdman.set1f(fKSUni, spec.ks());
|
||||
|
@ -136,7 +136,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
UniformHandle fOffsetVar;
|
||||
@ -203,7 +203,7 @@ void GrGLMagnifierEffect::emitCode(EmitArgs& args) {
|
||||
}
|
||||
|
||||
void GrGLMagnifierEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& effect) {
|
||||
const GrFragmentProcessor& effect) {
|
||||
const GrMagnifierEffect& zoom = effect.cast<GrMagnifierEffect>();
|
||||
|
||||
GrTexture* tex = zoom.textureSampler(0).texture();
|
||||
|
@ -199,7 +199,7 @@ public:
|
||||
static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
GrGLSLProgramDataManager::UniformHandle fPixelSizeUni;
|
||||
@ -294,7 +294,7 @@ void GrGLMorphologyEffect::GenKey(const GrProcessor& proc,
|
||||
}
|
||||
|
||||
void GrGLMorphologyEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& proc) {
|
||||
const GrFragmentProcessor& proc) {
|
||||
const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>();
|
||||
GrTexture& texture = *m.textureSampler(0).texture();
|
||||
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
void emitCode(EmitArgs&) override;
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override {}
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override {}
|
||||
|
||||
private:
|
||||
GrColor4f fColors[SkOverdrawColorFilter::kNumColors];
|
||||
|
@ -472,7 +472,7 @@ public:
|
||||
static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
GrGLSLProgramDataManager::UniformHandle fStitchDataUni;
|
||||
@ -866,7 +866,7 @@ void GrGLPerlinNoise::GenKey(const GrProcessor& processor, const GrShaderCaps&,
|
||||
}
|
||||
|
||||
void GrGLPerlinNoise::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& processor) {
|
||||
const GrFragmentProcessor& processor) {
|
||||
INHERITED::onSetData(pdman, processor);
|
||||
|
||||
const GrPerlinNoiseEffect& turbulence = processor.cast<GrPerlinNoiseEffect>();
|
||||
|
@ -398,7 +398,8 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor& proc) override {
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& proc) override {
|
||||
const RRectsGaussianEdgeFP& edgeFP = proc.cast<RRectsGaussianEdgeFP>();
|
||||
|
||||
const SkRRect& first = edgeFP.first();
|
||||
|
@ -407,14 +407,15 @@ public:
|
||||
static void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*) {}
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
UniformHandle fRGBAYValuesUni;
|
||||
typedef GrGLSLFragmentProcessor INHERITED;
|
||||
};
|
||||
|
||||
void GLColorTableEffect::onSetData(const GrGLSLProgramDataManager& pdm, const GrProcessor& proc) {
|
||||
void GLColorTableEffect::onSetData(const GrGLSLProgramDataManager& pdm,
|
||||
const GrFragmentProcessor& proc) {
|
||||
// The textures are organized in a strip where the rows are ordered a, r, g, b.
|
||||
float rgbaYValues[4];
|
||||
const ColorTableEffect& cte = proc.cast<ColorTableEffect>();
|
||||
|
@ -1301,7 +1301,7 @@ static inline void set_before_interp_color_uni_array(const GrGLSLProgramDataMana
|
||||
}
|
||||
|
||||
void GrGradientEffect::GLSLProcessor::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& processor) {
|
||||
const GrFragmentProcessor& processor) {
|
||||
const GrGradientEffect& e = processor.cast<GrGradientEffect>();
|
||||
|
||||
switch (e.getColorType()) {
|
||||
|
@ -465,7 +465,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -146,7 +146,7 @@ public:
|
||||
static void GenKey(const GrProcessor&, const GrShaderCaps& caps, GrProcessorKeyBuilder* b);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
UniformHandle fParamUni;
|
||||
|
||||
@ -284,8 +284,7 @@ void Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::emitCode(EmitArgs& args)
|
||||
}
|
||||
|
||||
void Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::onSetData(
|
||||
const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& processor) {
|
||||
const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& processor) {
|
||||
INHERITED::onSetData(pdman, processor);
|
||||
const Edge2PtConicalEffect& data = processor.cast<Edge2PtConicalEffect>();
|
||||
SkScalar radius0 = data.radius();
|
||||
@ -427,7 +426,7 @@ public:
|
||||
static void GenKey(const GrProcessor&, const GrShaderCaps& caps, GrProcessorKeyBuilder* b);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
UniformHandle fParamUni;
|
||||
|
||||
@ -555,8 +554,7 @@ void FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::emitCode
|
||||
}
|
||||
|
||||
void FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::onSetData(
|
||||
const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& processor) {
|
||||
const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& processor) {
|
||||
INHERITED::onSetData(pdman, processor);
|
||||
const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtConicalEffect>();
|
||||
SkASSERT(data.isFlipped() == fIsFlipped);
|
||||
@ -633,7 +631,7 @@ public:
|
||||
static void GenKey(const GrProcessor&, const GrShaderCaps& caps, GrProcessorKeyBuilder* b);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
UniformHandle fFocalUni;
|
||||
|
||||
@ -737,8 +735,7 @@ void FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::emitCode(E
|
||||
}
|
||||
|
||||
void FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::onSetData(
|
||||
const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& processor) {
|
||||
const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& processor) {
|
||||
INHERITED::onSetData(pdman, processor);
|
||||
const FocalInside2PtConicalEffect& data = processor.cast<FocalInside2PtConicalEffect>();
|
||||
SkScalar focal = data.focal();
|
||||
@ -876,7 +873,7 @@ public:
|
||||
static void GenKey(const GrProcessor&, const GrShaderCaps& caps, GrProcessorKeyBuilder* b);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
UniformHandle fCenterUni;
|
||||
UniformHandle fParamUni;
|
||||
@ -1003,8 +1000,7 @@ void CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::emitCode
|
||||
}
|
||||
|
||||
void CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::onSetData(
|
||||
const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& processor) {
|
||||
const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& processor) {
|
||||
INHERITED::onSetData(pdman, processor);
|
||||
const CircleInside2PtConicalEffect& data = processor.cast<CircleInside2PtConicalEffect>();
|
||||
SkScalar centerX = data.centerX();
|
||||
@ -1107,7 +1103,7 @@ public:
|
||||
static void GenKey(const GrProcessor&, const GrShaderCaps& caps, GrProcessorKeyBuilder* b);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
UniformHandle fCenterUni;
|
||||
UniformHandle fParamUni;
|
||||
@ -1259,8 +1255,7 @@ void CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::emitCo
|
||||
}
|
||||
|
||||
void CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::onSetData(
|
||||
const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& processor) {
|
||||
const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& processor) {
|
||||
INHERITED::onSetData(pdman, processor);
|
||||
const CircleOutside2PtConicalEffect& data = processor.cast<CircleOutside2PtConicalEffect>();
|
||||
SkASSERT(data.isFlipped() == fIsFlipped);
|
||||
|
@ -353,7 +353,7 @@ sk_sp<GrFragmentProcessor> GrFragmentProcessor::OverrideInput(sk_sp<GrFragmentPr
|
||||
|
||||
private:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& fp) override {
|
||||
const GrFragmentProcessor& fp) override {
|
||||
GrColor4f color = fp.cast<ReplaceInputFragmentProcessor>().fColor;
|
||||
if (!fHaveSetColor || color != fPreviousColor) {
|
||||
pdman.set4fv(fColorUni, 1, color.fRGBA);
|
||||
|
@ -121,7 +121,7 @@ void GrPipeline::init(const InitArgs& args) {
|
||||
|
||||
static void add_dependencies_for_processor(const GrFragmentProcessor* proc, GrRenderTarget* rt) {
|
||||
GrFragmentProcessor::TextureAccessIter iter(proc);
|
||||
while (const GrProcessor::TextureSampler* sampler = iter.next()) {
|
||||
while (const GrResourceIOProcessor::TextureSampler* sampler = iter.next()) {
|
||||
SkASSERT(rt->getLastOpList());
|
||||
rt->getLastOpList()->addDependency(sampler->texture());
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class GrGLSLPrimitiveProcessor;
|
||||
* GrPrimitiveProcessors must proivide seed color and coverage for the Ganesh color / coverage
|
||||
* pipelines, and they must provide some notion of equality
|
||||
*/
|
||||
class GrPrimitiveProcessor : public GrProcessor {
|
||||
class GrPrimitiveProcessor : public GrResourceIOProcessor {
|
||||
public:
|
||||
// Only the GrGeometryProcessor subclass actually has a geo shader or vertex attributes, but
|
||||
// we put these calls on the base class to prevent having to cast
|
||||
|
@ -120,21 +120,27 @@ int32_t GrProcessor::gCurrProcessorClassID = GrProcessor::kIllegalProcessorClass
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrProcessor::~GrProcessor() {}
|
||||
void* GrProcessor::operator new(size_t size) { return MemoryPoolAccessor().pool()->allocate(size); }
|
||||
|
||||
void GrProcessor::addTextureSampler(const TextureSampler* access) {
|
||||
void GrProcessor::operator delete(void* target) {
|
||||
return MemoryPoolAccessor().pool()->release(target);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void GrResourceIOProcessor::addTextureSampler(const TextureSampler* access) {
|
||||
fTextureSamplers.push_back(access);
|
||||
}
|
||||
|
||||
void GrProcessor::addBufferAccess(const BufferAccess* access) {
|
||||
void GrResourceIOProcessor::addBufferAccess(const BufferAccess* access) {
|
||||
fBufferAccesses.push_back(access);
|
||||
}
|
||||
|
||||
void GrProcessor::addImageStorageAccess(const ImageStorageAccess* access) {
|
||||
void GrResourceIOProcessor::addImageStorageAccess(const ImageStorageAccess* access) {
|
||||
fImageStorageAccesses.push_back(access);
|
||||
}
|
||||
|
||||
void GrProcessor::addPendingIOs() const {
|
||||
void GrResourceIOProcessor::addPendingIOs() const {
|
||||
for (const auto& sampler : fTextureSamplers) {
|
||||
sampler->programTexture()->markPendingIO();
|
||||
}
|
||||
@ -146,7 +152,7 @@ void GrProcessor::addPendingIOs() const {
|
||||
}
|
||||
}
|
||||
|
||||
void GrProcessor::removeRefs() const {
|
||||
void GrResourceIOProcessor::removeRefs() const {
|
||||
for (const auto& sampler : fTextureSamplers) {
|
||||
sampler->programTexture()->removeRef();
|
||||
}
|
||||
@ -158,7 +164,7 @@ void GrProcessor::removeRefs() const {
|
||||
}
|
||||
}
|
||||
|
||||
void GrProcessor::pendingIOComplete() const {
|
||||
void GrResourceIOProcessor::pendingIOComplete() const {
|
||||
for (const auto& sampler : fTextureSamplers) {
|
||||
sampler->programTexture()->pendingIOComplete();
|
||||
}
|
||||
@ -170,15 +176,7 @@ void GrProcessor::pendingIOComplete() const {
|
||||
}
|
||||
}
|
||||
|
||||
void* GrProcessor::operator new(size_t size) {
|
||||
return MemoryPoolAccessor().pool()->allocate(size);
|
||||
}
|
||||
|
||||
void GrProcessor::operator delete(void* target) {
|
||||
return MemoryPoolAccessor().pool()->release(target);
|
||||
}
|
||||
|
||||
bool GrProcessor::hasSameSamplersAndAccesses(const GrProcessor &that) const {
|
||||
bool GrResourceIOProcessor::hasSameSamplersAndAccesses(const GrResourceIOProcessor& that) const {
|
||||
if (this->numTextureSamplers() != that.numTextureSamplers() ||
|
||||
this->numBuffers() != that.numBuffers() ||
|
||||
this->numImageStorages() != that.numImageStorages()) {
|
||||
@ -204,36 +202,37 @@ bool GrProcessor::hasSameSamplersAndAccesses(const GrProcessor &that) const {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrProcessor::TextureSampler::TextureSampler() {}
|
||||
GrResourceIOProcessor::TextureSampler::TextureSampler() {}
|
||||
|
||||
GrProcessor::TextureSampler::TextureSampler(GrTexture* texture, const GrSamplerParams& params) {
|
||||
GrResourceIOProcessor::TextureSampler::TextureSampler(GrTexture* texture,
|
||||
const GrSamplerParams& params) {
|
||||
this->reset(texture, params);
|
||||
}
|
||||
|
||||
GrProcessor::TextureSampler::TextureSampler(GrTexture* texture,
|
||||
GrSamplerParams::FilterMode filterMode,
|
||||
SkShader::TileMode tileXAndY,
|
||||
GrShaderFlags visibility) {
|
||||
GrResourceIOProcessor::TextureSampler::TextureSampler(GrTexture* texture,
|
||||
GrSamplerParams::FilterMode filterMode,
|
||||
SkShader::TileMode tileXAndY,
|
||||
GrShaderFlags visibility) {
|
||||
this->reset(texture, filterMode, tileXAndY, visibility);
|
||||
}
|
||||
|
||||
GrProcessor::TextureSampler::TextureSampler(GrResourceProvider* resourceProvider,
|
||||
sk_sp<GrTextureProxy> proxy,
|
||||
const GrSamplerParams& params) {
|
||||
GrResourceIOProcessor::TextureSampler::TextureSampler(GrResourceProvider* resourceProvider,
|
||||
sk_sp<GrTextureProxy> proxy,
|
||||
const GrSamplerParams& params) {
|
||||
this->reset(resourceProvider, std::move(proxy), params);
|
||||
}
|
||||
|
||||
GrProcessor::TextureSampler::TextureSampler(GrResourceProvider* resourceProvider,
|
||||
sk_sp<GrTextureProxy> proxy,
|
||||
GrSamplerParams::FilterMode filterMode,
|
||||
SkShader::TileMode tileXAndY,
|
||||
GrShaderFlags visibility) {
|
||||
GrResourceIOProcessor::TextureSampler::TextureSampler(GrResourceProvider* resourceProvider,
|
||||
sk_sp<GrTextureProxy> proxy,
|
||||
GrSamplerParams::FilterMode filterMode,
|
||||
SkShader::TileMode tileXAndY,
|
||||
GrShaderFlags visibility) {
|
||||
this->reset(resourceProvider, std::move(proxy), filterMode, tileXAndY, visibility);
|
||||
}
|
||||
|
||||
void GrProcessor::TextureSampler::reset(GrTexture* texture,
|
||||
const GrSamplerParams& params,
|
||||
GrShaderFlags visibility) {
|
||||
void GrResourceIOProcessor::TextureSampler::reset(GrTexture* texture,
|
||||
const GrSamplerParams& params,
|
||||
GrShaderFlags visibility) {
|
||||
SkASSERT(texture);
|
||||
fTexture.set(SkRef(texture), kRead_GrIOType);
|
||||
fParams = params;
|
||||
@ -241,10 +240,10 @@ void GrProcessor::TextureSampler::reset(GrTexture* texture,
|
||||
fVisibility = visibility;
|
||||
}
|
||||
|
||||
void GrProcessor::TextureSampler::reset(GrTexture* texture,
|
||||
GrSamplerParams::FilterMode filterMode,
|
||||
SkShader::TileMode tileXAndY,
|
||||
GrShaderFlags visibility) {
|
||||
void GrResourceIOProcessor::TextureSampler::reset(GrTexture* texture,
|
||||
GrSamplerParams::FilterMode filterMode,
|
||||
SkShader::TileMode tileXAndY,
|
||||
GrShaderFlags visibility) {
|
||||
SkASSERT(texture);
|
||||
fTexture.set(SkRef(texture), kRead_GrIOType);
|
||||
filterMode = SkTMin(filterMode, texture->texturePriv().highestFilterMode());
|
||||
@ -252,10 +251,10 @@ void GrProcessor::TextureSampler::reset(GrTexture* texture,
|
||||
fVisibility = visibility;
|
||||
}
|
||||
|
||||
void GrProcessor::TextureSampler::reset(GrResourceProvider* resourceProvider,
|
||||
sk_sp<GrTextureProxy> proxy,
|
||||
const GrSamplerParams& params,
|
||||
GrShaderFlags visibility) {
|
||||
void GrResourceIOProcessor::TextureSampler::reset(GrResourceProvider* resourceProvider,
|
||||
sk_sp<GrTextureProxy> proxy,
|
||||
const GrSamplerParams& params,
|
||||
GrShaderFlags visibility) {
|
||||
// For now, end the deferral at this time. Once all the TextureSamplers are swapped over
|
||||
// to taking a GrSurfaceProxy just use the IORefs on the proxy
|
||||
GrTexture* texture = proxy->instantiate(resourceProvider);
|
||||
@ -266,11 +265,11 @@ void GrProcessor::TextureSampler::reset(GrResourceProvider* resourceProvider,
|
||||
fVisibility = visibility;
|
||||
}
|
||||
|
||||
void GrProcessor::TextureSampler::reset(GrResourceProvider* resourceProvider,
|
||||
sk_sp<GrTextureProxy> proxy,
|
||||
GrSamplerParams::FilterMode filterMode,
|
||||
SkShader::TileMode tileXAndY,
|
||||
GrShaderFlags visibility) {
|
||||
void GrResourceIOProcessor::TextureSampler::reset(GrResourceProvider* resourceProvider,
|
||||
sk_sp<GrTextureProxy> proxy,
|
||||
GrSamplerParams::FilterMode filterMode,
|
||||
SkShader::TileMode tileXAndY,
|
||||
GrShaderFlags visibility) {
|
||||
// For now, end the deferral at this time. Once all the TextureSamplers are swapped over
|
||||
// to taking a GrSurfaceProxy just use the IORefs on the proxy
|
||||
GrTexture* texture = proxy->instantiate(resourceProvider);
|
||||
@ -283,10 +282,11 @@ void GrProcessor::TextureSampler::reset(GrResourceProvider* resourceProvider,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrProcessor::ImageStorageAccess::ImageStorageAccess(sk_sp<GrTexture> texture, GrIOType ioType,
|
||||
GrSLMemoryModel memoryModel,
|
||||
GrSLRestrict restrict,
|
||||
GrShaderFlags visibility) {
|
||||
GrResourceIOProcessor::ImageStorageAccess::ImageStorageAccess(sk_sp<GrTexture> texture,
|
||||
GrIOType ioType,
|
||||
GrSLMemoryModel memoryModel,
|
||||
GrSLRestrict restrict,
|
||||
GrShaderFlags visibility) {
|
||||
SkASSERT(texture);
|
||||
fTexture.set(texture.release(), ioType);
|
||||
fMemoryModel = memoryModel;
|
||||
|
@ -61,13 +61,13 @@ static uint16_t sampler_key(GrSLType samplerType, GrPixelConfig config, GrShader
|
||||
(caps.samplerPrecision(config, visibility) << (8 + kSamplerOrImageTypeKeyBits)));
|
||||
}
|
||||
|
||||
static uint16_t storage_image_key(const GrProcessor::ImageStorageAccess& imageAccess) {
|
||||
static uint16_t storage_image_key(const GrResourceIOProcessor::ImageStorageAccess& imageAccess) {
|
||||
GrSLType type = imageAccess.texture()->texturePriv().imageStorageType();
|
||||
return image_storage_or_sampler_uniform_type_key(type) |
|
||||
(int)imageAccess.format() << kSamplerOrImageTypeKeyBits;
|
||||
}
|
||||
|
||||
static void add_sampler_and_image_keys(GrProcessorKeyBuilder* b, const GrProcessor& proc,
|
||||
static void add_sampler_and_image_keys(GrProcessorKeyBuilder* b, const GrResourceIOProcessor& proc,
|
||||
const GrShaderCaps& caps) {
|
||||
int numTextureSamplers = proc.numTextureSamplers();
|
||||
int numBuffers = proc.numBuffers();
|
||||
@ -81,13 +81,13 @@ static void add_sampler_and_image_keys(GrProcessorKeyBuilder* b, const GrProcess
|
||||
uint16_t* k16 = SkTCast<uint16_t*>(b->add32n(word32Count));
|
||||
int j = 0;
|
||||
for (int i = 0; i < numTextureSamplers; ++i, ++j) {
|
||||
const GrProcessor::TextureSampler& sampler = proc.textureSampler(i);
|
||||
const GrResourceIOProcessor::TextureSampler& sampler = proc.textureSampler(i);
|
||||
const GrTexture* tex = sampler.texture();
|
||||
k16[j] = sampler_key(tex->texturePriv().samplerType(), tex->config(), sampler.visibility(),
|
||||
caps);
|
||||
}
|
||||
for (int i = 0; i < numBuffers; ++i, ++j) {
|
||||
const GrProcessor::BufferAccess& access = proc.bufferAccess(i);
|
||||
const GrResourceIOProcessor::BufferAccess& access = proc.bufferAccess(i);
|
||||
k16[j] = sampler_key(kBufferSampler_GrSLType, access.texelConfig(), access.visibility(),
|
||||
caps);
|
||||
}
|
||||
@ -109,7 +109,7 @@ static void add_sampler_and_image_keys(GrProcessorKeyBuilder* b, const GrProcess
|
||||
* transforms, etc, for the space allotted in the meta-key. NOTE, both FPs and GPs share this
|
||||
* function because it is hairy, though FPs do not have attribs, and GPs do not have transforms
|
||||
*/
|
||||
static bool gen_meta_key(const GrProcessor& proc,
|
||||
static bool gen_meta_key(const GrResourceIOProcessor& proc,
|
||||
const GrShaderCaps& shaderCaps,
|
||||
uint32_t transformKey,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
@ -130,6 +130,22 @@ static bool gen_meta_key(const GrProcessor& proc,
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool gen_meta_key(const GrXferProcessor& xp,
|
||||
const GrShaderCaps& shaderCaps,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
size_t processorKeySize = b->size();
|
||||
uint32_t classID = xp.classID();
|
||||
|
||||
// Currently we allow 16 bits for the class id and the overall processor key size.
|
||||
static const uint32_t kMetaKeyInvalidMask = ~((uint32_t)SK_MaxU16);
|
||||
if ((processorKeySize | classID) & kMetaKeyInvalidMask) {
|
||||
return false;
|
||||
}
|
||||
|
||||
b->add32((classID << 16) | SkToU32(processorKeySize));
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool gen_frag_proc_and_meta_keys(const GrPrimitiveProcessor& primProc,
|
||||
const GrFragmentProcessor& fp,
|
||||
const GrShaderCaps& shaderCaps,
|
||||
@ -187,7 +203,7 @@ bool GrProgramDesc::Build(GrProgramDesc* desc,
|
||||
originIfDstTexture = &origin;
|
||||
}
|
||||
xp.getGLSLProcessorKey(shaderCaps, &b, originIfDstTexture);
|
||||
if (!gen_meta_key(xp, shaderCaps, 0, &b)) {
|
||||
if (!gen_meta_key(xp, shaderCaps, &b)) {
|
||||
desc->key().reset();
|
||||
return false;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
|
||||
@ -118,7 +118,7 @@ void GrGLBicubicEffect::emitCode(EmitArgs& args) {
|
||||
}
|
||||
|
||||
void GrGLBicubicEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& processor) {
|
||||
const GrFragmentProcessor& processor) {
|
||||
const GrBicubicEffect& bicubicEffect = processor.cast<GrBicubicEffect>();
|
||||
GrTexture* texture = processor.textureSampler(0).texture();
|
||||
float imageIncrement[2];
|
||||
|
@ -48,7 +48,8 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor& proc) override {}
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& proc) override {}
|
||||
|
||||
GrBlurredEdgeFP::Mode fMode;
|
||||
};
|
||||
|
@ -42,7 +42,8 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdm, const GrProcessor& processor) override {
|
||||
void onSetData(const GrGLSLProgramDataManager& pdm,
|
||||
const GrFragmentProcessor& processor) override {
|
||||
GrColor4f color = processor.cast<GrConstColorProcessor>().color();
|
||||
// We use the "illegal" color value as an uninit sentinel. With GrColor4f, the "illegal"
|
||||
// color is *really* illegal (not just unpremultiplied), so this check is simple.
|
||||
|
@ -85,7 +85,7 @@ public:
|
||||
static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
GrGLSLProgramDataManager::UniformHandle fRectUniform;
|
||||
@ -137,7 +137,7 @@ void GLAARectEffect::emitCode(EmitArgs& args) {
|
||||
}
|
||||
|
||||
void GLAARectEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& processor) {
|
||||
const GrFragmentProcessor& processor) {
|
||||
const AARectEffect& aare = processor.cast<AARectEffect>();
|
||||
const SkRect& rect = aare.getRect();
|
||||
if (rect != fPrevRect) {
|
||||
@ -176,7 +176,7 @@ public:
|
||||
static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
GrGLSLProgramDataManager::UniformHandle fEdgeUniform;
|
||||
@ -217,7 +217,7 @@ void GrGLConvexPolyEffect::emitCode(EmitArgs& args) {
|
||||
}
|
||||
|
||||
void GrGLConvexPolyEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& effect) {
|
||||
const GrFragmentProcessor& effect) {
|
||||
const GrConvexPolyEffect& cpe = effect.cast<GrConvexPolyEffect>();
|
||||
size_t byteSize = 3 * cpe.getEdgeCount() * sizeof(SkScalar);
|
||||
if (0 != memcmp(fPrevEdges, cpe.getEdges(), byteSize)) {
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
UniformHandle fKernelUni;
|
||||
@ -98,7 +98,7 @@ void GrGLConvolutionEffect::emitCode(EmitArgs& args) {
|
||||
}
|
||||
|
||||
void GrGLConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& processor) {
|
||||
const GrFragmentProcessor& processor) {
|
||||
const GrGaussianConvolutionFragmentProcessor& conv =
|
||||
processor.cast<GrGaussianConvolutionFragmentProcessor>();
|
||||
GrTexture& texture = *conv.textureSampler(0).texture();
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
|
||||
@ -131,7 +131,7 @@ void GrGLMatrixConvolutionEffect::GenKey(const GrProcessor& processor,
|
||||
}
|
||||
|
||||
void GrGLMatrixConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& processor) {
|
||||
const GrFragmentProcessor& processor) {
|
||||
const GrMatrixConvolutionEffect& conv = processor.cast<GrMatrixConvolutionEffect>();
|
||||
GrTexture* texture = conv.textureSampler(0).texture();
|
||||
|
||||
|
@ -108,7 +108,8 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor& processor) override {
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& processor) override {
|
||||
const GrNonlinearColorSpaceXformEffect& csxe =
|
||||
processor.cast<GrNonlinearColorSpaceXformEffect>();
|
||||
if (SkToBool(csxe.ops() & GrNonlinearColorSpaceXformEffect::kSrcTransfer_Op)) {
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
GrGLSLProgramDataManager::UniformHandle fCircleUniform;
|
||||
@ -151,7 +151,7 @@ void GLCircleEffect::GenKey(const GrProcessor& processor, const GrShaderCaps&,
|
||||
}
|
||||
|
||||
void GLCircleEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& processor) {
|
||||
const GrFragmentProcessor& processor) {
|
||||
const CircleEffect& ce = processor.cast<CircleEffect>();
|
||||
if (ce.getRadius() != fPrevRadius || ce.getCenter() != fPrevCenter) {
|
||||
SkScalar radius = ce.getRadius();
|
||||
@ -266,7 +266,7 @@ public:
|
||||
static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
GrGLSLProgramDataManager::UniformHandle fEllipseUniform;
|
||||
@ -344,7 +344,7 @@ void GLEllipseEffect::GenKey(const GrProcessor& effect, const GrShaderCaps&,
|
||||
}
|
||||
|
||||
void GLEllipseEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& effect) {
|
||||
const GrFragmentProcessor& effect) {
|
||||
const EllipseEffect& ee = effect.cast<EllipseEffect>();
|
||||
if (ee.getRadii() != fPrevRadii || ee.getCenter() != fPrevCenter) {
|
||||
float invRXSqd;
|
||||
|
@ -135,7 +135,7 @@ public:
|
||||
static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
GrGLSLProgramDataManager::UniformHandle fInnerRectUniform;
|
||||
@ -291,7 +291,7 @@ void GLCircularRRectEffect::GenKey(const GrProcessor& processor, const GrShaderC
|
||||
}
|
||||
|
||||
void GLCircularRRectEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& processor) {
|
||||
const GrFragmentProcessor& processor) {
|
||||
const CircularRRectEffect& crre = processor.cast<CircularRRectEffect>();
|
||||
const SkRRect& rrect = crre.getRRect();
|
||||
if (rrect != fPrevRRect) {
|
||||
@ -487,7 +487,7 @@ public:
|
||||
static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
private:
|
||||
GrGLSLProgramDataManager::UniformHandle fInnerRectUniform;
|
||||
@ -602,7 +602,7 @@ void GLEllipticalRRectEffect::GenKey(const GrProcessor& effect, const GrShaderCa
|
||||
}
|
||||
|
||||
void GLEllipticalRRectEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& effect) {
|
||||
const GrFragmentProcessor& effect) {
|
||||
const EllipticalRRectEffect& erre = effect.cast<EllipticalRRectEffect>();
|
||||
const SkRRect& rrect = erre.getRRect();
|
||||
// If we're using a scale factor to work around precision issues, choose the largest radius
|
||||
|
@ -63,7 +63,8 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor& processor) override {
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& processor) override {
|
||||
const GrSimpleTextureEffect& textureEffect = processor.cast<GrSimpleTextureEffect>();
|
||||
if (SkToBool(textureEffect.colorSpaceXform())) {
|
||||
fColorSpaceHelper.setData(pdman, textureEffect.colorSpaceXform());
|
||||
|
@ -305,7 +305,8 @@ GrGLSLFragmentProcessor* GrTextureDomainEffect::onCreateGLSLInstance() const {
|
||||
}
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor& fp) override {
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& fp) override {
|
||||
const GrTextureDomainEffect& tde = fp.cast<GrTextureDomainEffect>();
|
||||
const GrTextureDomain& domain = tde.fTextureDomain;
|
||||
fGLDomain.setData(pdman, domain, tde.textureSampler(0).texture());
|
||||
@ -407,7 +408,8 @@ GrGLSLFragmentProcessor* GrDeviceSpaceTextureDecalFragmentProcessor::onCreateGLS
|
||||
}
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor& fp) override {
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& fp) override {
|
||||
const GrDeviceSpaceTextureDecalFragmentProcessor& dstdfp =
|
||||
fp.cast<GrDeviceSpaceTextureDecalFragmentProcessor>();
|
||||
GrTexture* texture = dstdfp.textureSampler(0).texture();
|
||||
|
@ -131,7 +131,7 @@ public:
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& processor) override {
|
||||
const GrFragmentProcessor& processor) override {
|
||||
const YUVtoRGBEffect& yuvEffect = processor.cast<YUVtoRGBEffect>();
|
||||
switch (yuvEffect.getColorSpace()) {
|
||||
case kJPEG_SkYUVColorSpace:
|
||||
@ -285,7 +285,7 @@ public:
|
||||
|
||||
private:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrProcessor& processor) override {
|
||||
const GrFragmentProcessor& processor) override {
|
||||
const RGBToYUVEffect& effect = processor.cast<RGBToYUVEffect>();
|
||||
OutputChannels oc = effect.outputChannels();
|
||||
if (effect.getColorSpace() != fLastColorSpace || oc != fLastOutputChannels) {
|
||||
|
@ -144,30 +144,29 @@ void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc,
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLProgram::bindTextures(const GrProcessor& processor,
|
||||
void GrGLProgram::bindTextures(const GrResourceIOProcessor& processor,
|
||||
bool allowSRGBInputs,
|
||||
int* nextSamplerIdx) {
|
||||
for (int i = 0; i < processor.numTextureSamplers(); ++i) {
|
||||
const GrProcessor::TextureSampler& sampler = processor.textureSampler(i);
|
||||
const GrResourceIOProcessor::TextureSampler& sampler = processor.textureSampler(i);
|
||||
fGpu->bindTexture((*nextSamplerIdx)++, sampler.params(),
|
||||
allowSRGBInputs, static_cast<GrGLTexture*>(sampler.texture()));
|
||||
}
|
||||
for (int i = 0; i < processor.numBuffers(); ++i) {
|
||||
const GrProcessor::BufferAccess& access = processor.bufferAccess(i);
|
||||
const GrResourceIOProcessor::BufferAccess& access = processor.bufferAccess(i);
|
||||
fGpu->bindTexelBuffer((*nextSamplerIdx)++, access.texelConfig(),
|
||||
static_cast<GrGLBuffer*>(access.buffer()));
|
||||
}
|
||||
for (int i = 0; i < processor.numImageStorages(); ++i) {
|
||||
const GrProcessor::ImageStorageAccess& access = processor.imageStorageAccess(i);
|
||||
const GrResourceIOProcessor::ImageStorageAccess& access = processor.imageStorageAccess(i);
|
||||
fGpu->bindImageStorage((*nextSamplerIdx)++, access.ioType(),
|
||||
static_cast<GrGLTexture *>(access.texture()));
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLProgram::generateMipmaps(const GrProcessor& processor,
|
||||
bool allowSRGBInputs) {
|
||||
void GrGLProgram::generateMipmaps(const GrResourceIOProcessor& processor, bool allowSRGBInputs) {
|
||||
for (int i = 0; i < processor.numTextureSamplers(); ++i) {
|
||||
const GrProcessor::TextureSampler& sampler = processor.textureSampler(i);
|
||||
const GrResourceIOProcessor::TextureSampler& sampler = processor.textureSampler(i);
|
||||
fGpu->generateMipmaps(sampler.params(), allowSRGBInputs,
|
||||
static_cast<GrGLTexture*>(sampler.texture()));
|
||||
}
|
||||
|
@ -125,10 +125,10 @@ protected:
|
||||
void setRenderTargetState(const GrPrimitiveProcessor&, const GrRenderTarget*);
|
||||
|
||||
// Helper for setData() that binds textures and texel buffers to the appropriate texture units
|
||||
void bindTextures(const GrProcessor&, bool allowSRGBInputs, int* nextSamplerIdx);
|
||||
void bindTextures(const GrResourceIOProcessor&, bool allowSRGBInputs, int* nextSamplerIdx);
|
||||
|
||||
// Helper for generateMipmaps() that ensures mipmaps are up to date
|
||||
void generateMipmaps(const GrProcessor&, bool allowSRGBInputs);
|
||||
void generateMipmaps(const GrResourceIOProcessor&, bool allowSRGBInputs);
|
||||
|
||||
// these reflect the current values of uniforms (GL uniform values travel with program)
|
||||
RenderTargetState fRenderTargetState;
|
||||
|
@ -70,12 +70,12 @@ private:
|
||||
public:
|
||||
using TransformedCoordVars = BuilderInputProvider<GrShaderVar, GrFragmentProcessor,
|
||||
&GrFragmentProcessor::numCoordTransforms>;
|
||||
using TextureSamplers = BuilderInputProvider<SamplerHandle, GrProcessor,
|
||||
&GrProcessor::numTextureSamplers>;
|
||||
using BufferSamplers = BuilderInputProvider<SamplerHandle, GrProcessor,
|
||||
&GrProcessor::numBuffers>;
|
||||
using ImageStorages = BuilderInputProvider<ImageStorageHandle, GrProcessor,
|
||||
&GrProcessor::numImageStorages>;
|
||||
using TextureSamplers = BuilderInputProvider<SamplerHandle, GrResourceIOProcessor,
|
||||
&GrResourceIOProcessor::numTextureSamplers>;
|
||||
using BufferSamplers = BuilderInputProvider<SamplerHandle, GrResourceIOProcessor,
|
||||
&GrResourceIOProcessor::numBuffers>;
|
||||
using ImageStorages = BuilderInputProvider<ImageStorageHandle, GrResourceIOProcessor,
|
||||
&GrResourceIOProcessor::numImageStorages>;
|
||||
|
||||
/** Called when the program stage should insert its code into the shaders. The code in each
|
||||
shader will be in its own block ({}) and so locally scoped names will not collide across
|
||||
@ -194,8 +194,7 @@ protected:
|
||||
uniform variables required by the shaders created in emitCode(). The GrFragmentProcessor
|
||||
parameter is guaranteed to be of the same type that created this GrGLSLFragmentProcessor and
|
||||
to have an identical processor key as the one that created this GrGLSLFragmentProcessor. */
|
||||
// TODO update this to pass in GrFragmentProcessor
|
||||
virtual void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) {}
|
||||
virtual void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) {}
|
||||
|
||||
private:
|
||||
void internalEmitChild(int, const char*, const char*, EmitArgs&);
|
||||
|
@ -264,14 +264,14 @@ void GrGLSLProgramBuilder::emitAndInstallXferProc(const GrGLSLExpr4& colorIn,
|
||||
}
|
||||
|
||||
void GrGLSLProgramBuilder::emitSamplersAndImageStorages(
|
||||
const GrProcessor& processor,
|
||||
const GrResourceIOProcessor& processor,
|
||||
SkTArray<SamplerHandle>* outTexSamplerHandles,
|
||||
SkTArray<SamplerHandle>* outBufferSamplerHandles,
|
||||
SkTArray<ImageStorageHandle>* outImageStorageHandles) {
|
||||
SkString name;
|
||||
int numTextureSamplers = processor.numTextureSamplers();
|
||||
for (int t = 0; t < numTextureSamplers; ++t) {
|
||||
const GrProcessor::TextureSampler& sampler = processor.textureSampler(t);
|
||||
const GrResourceIOProcessor::TextureSampler& sampler = processor.textureSampler(t);
|
||||
name.printf("TextureSampler_%d", outTexSamplerHandles->count());
|
||||
GrSLType samplerType = sampler.texture()->texturePriv().samplerType();
|
||||
if (kTextureExternalSampler_GrSLType == samplerType) {
|
||||
@ -291,7 +291,7 @@ void GrGLSLProgramBuilder::emitSamplersAndImageStorages(
|
||||
GrShaderFlags texelBufferVisibility = kNone_GrShaderFlags;
|
||||
|
||||
for (int b = 0; b < numBuffers; ++b) {
|
||||
const GrProcessor::BufferAccess& access = processor.bufferAccess(b);
|
||||
const GrResourceIOProcessor::BufferAccess& access = processor.bufferAccess(b);
|
||||
name.printf("BufferSampler_%d", outBufferSamplerHandles->count());
|
||||
outBufferSamplerHandles->emplace_back(
|
||||
this->emitSampler(kBufferSampler_GrSLType, access.texelConfig(), name.c_str(),
|
||||
@ -307,7 +307,8 @@ void GrGLSLProgramBuilder::emitSamplersAndImageStorages(
|
||||
}
|
||||
int numImageStorages = processor.numImageStorages();
|
||||
for (int i = 0; i < numImageStorages; ++i) {
|
||||
const GrProcessor::ImageStorageAccess& imageStorageAccess = processor.imageStorageAccess(i);
|
||||
const GrResourceIOProcessor::ImageStorageAccess& imageStorageAccess =
|
||||
processor.imageStorageAccess(i);
|
||||
name.printf("Image_%d", outImageStorageHandles->count());
|
||||
outImageStorageHandles->emplace_back(
|
||||
this->emitImageStorage(imageStorageAccess, name.c_str()));
|
||||
@ -334,7 +335,7 @@ GrGLSLProgramBuilder::SamplerHandle GrGLSLProgramBuilder::emitSampler(GrSLType s
|
||||
}
|
||||
|
||||
GrGLSLProgramBuilder::ImageStorageHandle GrGLSLProgramBuilder::emitImageStorage(
|
||||
const GrProcessor::ImageStorageAccess& access, const char* name) {
|
||||
const GrResourceIOProcessor::ImageStorageAccess& access, const char* name) {
|
||||
if (access.visibility() & kVertex_GrShaderFlag) {
|
||||
++fNumVertexImageStorages;
|
||||
}
|
||||
|
@ -153,13 +153,14 @@ private:
|
||||
const GrGLSLExpr4& input,
|
||||
GrGLSLExpr4* output);
|
||||
void emitAndInstallXferProc(const GrGLSLExpr4& colorIn, const GrGLSLExpr4& coverageIn);
|
||||
void emitSamplersAndImageStorages(const GrProcessor& processor,
|
||||
void emitSamplersAndImageStorages(const GrResourceIOProcessor& processor,
|
||||
SkTArray<SamplerHandle>* outTexSamplerHandles,
|
||||
SkTArray<SamplerHandle>* outBufferSamplerHandles,
|
||||
SkTArray<ImageStorageHandle>* outImageStorageHandles);
|
||||
SamplerHandle emitSampler(GrSLType samplerType, GrPixelConfig, const char* name,
|
||||
GrShaderFlags visibility);
|
||||
ImageStorageHandle emitImageStorage(const GrProcessor::ImageStorageAccess&, const char* name);
|
||||
ImageStorageHandle emitImageStorage(const GrResourceIOProcessor::ImageStorageAccess&,
|
||||
const char* name);
|
||||
void emitFSOutputSwizzle(bool hasSecondaryOutput);
|
||||
bool checkSamplerCounts();
|
||||
bool checkImageStorageCounts();
|
||||
|
@ -492,9 +492,9 @@ static void set_texture_layout(GrVkTexture* vkTexture, GrVkGpu* gpu) {
|
||||
false);
|
||||
}
|
||||
|
||||
static void prepare_sampled_images(const GrProcessor& processor, GrVkGpu* gpu) {
|
||||
static void prepare_sampled_images(const GrResourceIOProcessor& processor, GrVkGpu* gpu) {
|
||||
for (int i = 0; i < processor.numTextureSamplers(); ++i) {
|
||||
const GrProcessor::TextureSampler& sampler = processor.textureSampler(i);
|
||||
const GrResourceIOProcessor::TextureSampler& sampler = processor.textureSampler(i);
|
||||
GrVkTexture* vkTexture = static_cast<GrVkTexture*>(sampler.texture());
|
||||
SkASSERT(vkTexture);
|
||||
|
||||
|
@ -172,12 +172,13 @@ void GrVkPipelineState::abandonGPUResources() {
|
||||
}
|
||||
}
|
||||
|
||||
static void append_texture_bindings(const GrProcessor& processor,
|
||||
SkTArray<const GrProcessor::TextureSampler*>* textureBindings) {
|
||||
static void append_texture_bindings(
|
||||
const GrResourceIOProcessor& processor,
|
||||
SkTArray<const GrResourceIOProcessor::TextureSampler*>* textureBindings) {
|
||||
// We don't support image storages in VK.
|
||||
SkASSERT(!processor.numImageStorages());
|
||||
if (int numTextureSamplers = processor.numTextureSamplers()) {
|
||||
const GrProcessor::TextureSampler** bindings =
|
||||
const GrResourceIOProcessor::TextureSampler** bindings =
|
||||
textureBindings->push_back_n(numTextureSamplers);
|
||||
int i = 0;
|
||||
do {
|
||||
@ -195,7 +196,7 @@ void GrVkPipelineState::setData(GrVkGpu* gpu,
|
||||
|
||||
this->setRenderTargetState(pipeline.getRenderTarget());
|
||||
|
||||
SkSTArray<8, const GrProcessor::TextureSampler*> textureBindings;
|
||||
SkSTArray<8, const GrResourceIOProcessor::TextureSampler*> textureBindings;
|
||||
|
||||
fGeometryProcessor->setData(fDataManager, primProc,
|
||||
GrFragmentProcessor::CoordTransformIter(pipeline));
|
||||
@ -217,7 +218,7 @@ void GrVkPipelineState::setData(GrVkGpu* gpu,
|
||||
SkIPoint offset;
|
||||
GrTexture* dstTexture = pipeline.dstTexture(&offset);
|
||||
fXferProcessor->setData(fDataManager, pipeline.getXferProcessor(), dstTexture, offset);
|
||||
GrProcessor::TextureSampler dstTextureSampler;
|
||||
GrResourceIOProcessor::TextureSampler dstTextureSampler;
|
||||
if (dstTexture) {
|
||||
dstTextureSampler.reset(dstTexture);
|
||||
textureBindings.push_back(&dstTextureSampler);
|
||||
@ -313,7 +314,7 @@ void GrVkPipelineState::writeUniformBuffers(const GrVkGpu* gpu) {
|
||||
|
||||
void GrVkPipelineState::writeSamplers(
|
||||
GrVkGpu* gpu,
|
||||
const SkTArray<const GrProcessor::TextureSampler*>& textureBindings,
|
||||
const SkTArray<const GrResourceIOProcessor::TextureSampler*>& textureBindings,
|
||||
bool allowSRGBInputs) {
|
||||
SkASSERT(fNumSamplers == textureBindings.count());
|
||||
|
||||
|
@ -141,9 +141,10 @@ private:
|
||||
|
||||
void writeUniformBuffers(const GrVkGpu* gpu);
|
||||
|
||||
void writeSamplers(GrVkGpu* gpu,
|
||||
const SkTArray<const GrProcessor::TextureSampler*>& textureBindings,
|
||||
bool allowSRGBInputs);
|
||||
void writeSamplers(
|
||||
GrVkGpu* gpu,
|
||||
const SkTArray<const GrResourceIOProcessor::TextureSampler*>& textureBindings,
|
||||
bool allowSRGBInputs);
|
||||
|
||||
/**
|
||||
* We use the RT's size and origin to adjust from Skia device space to vulkan normalized device
|
||||
|
Loading…
Reference in New Issue
Block a user