Rename GrGLSLGeometryProcessor to GrGeometryProcessor::ProgramImpl

return from GrGP by unique_ptr, rename factory function to
makeProgramImpl()

Bug: skia:11358

Change-Id: I61dd36f770d2fc0b54de0e0e7b78ac4d3fbd119a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437741
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2021-08-09 15:56:24 -04:00 committed by SkCQ
parent e1d523d70f
commit f95940bc23
57 changed files with 357 additions and 340 deletions

View File

@ -45,8 +45,8 @@ public:
const char* name() const override { return "VertexColorXformGP"; }
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override {
class GLSLGP : public GrGLSLGeometryProcessor {
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override {
class GLSLGP : public ProgramImpl {
public:
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
const GP& gp = args.fGeomProc.cast<GP>();
@ -89,7 +89,7 @@ public:
GrGLSLColorSpaceXformHelper fColorSpaceHelper;
};
return new GLSLGP();
return std::make_unique<GLSLGP>();
}
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const override {

View File

@ -77,7 +77,7 @@ public:
b->add32(fReadSkFragCoord);
}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const final;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const final;
bool readSkFragCoord() const { return fReadSkFragCoord; }
@ -93,7 +93,7 @@ private:
using INHERITED = GrGeometryProcessor;
};
class GLSLClockwiseTestProcessor : public GrGLSLGeometryProcessor {
class GLSLClockwiseTestProcessor : public GrGeometryProcessor::ProgramImpl {
void setData(const GrGLSLProgramDataManager&,
const GrShaderCaps&,
const GrGeometryProcessor&) override {}
@ -115,8 +115,9 @@ class GLSLClockwiseTestProcessor : public GrGLSLGeometryProcessor {
}
};
GrGLSLGeometryProcessor* ClockwiseTestProcessor::createGLSLInstance(const GrShaderCaps&) const {
return new GLSLClockwiseTestProcessor;
std::unique_ptr<GrGeometryProcessor::ProgramImpl> ClockwiseTestProcessor::makeProgramImpl(
const GrShaderCaps&) const {
return std::make_unique<GLSLClockwiseTestProcessor>();
}
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -72,7 +72,7 @@ public:
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const final {}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const final;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const final;
private:
FwidthSquircleTestProcessor(const SkMatrix& viewMatrix)
@ -88,7 +88,7 @@ private:
using INHERITED = GrGeometryProcessor;
};
class FwidthSquircleTestProcessor::Impl : public GrGLSLGeometryProcessor {
class FwidthSquircleTestProcessor::Impl : public ProgramImpl {
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
const auto& proc = args.fGeomProc.cast<FwidthSquircleTestProcessor>();
@ -136,9 +136,9 @@ class FwidthSquircleTestProcessor::Impl : public GrGLSLGeometryProcessor {
UniformHandle fViewMatrixHandle;
};
GrGLSLGeometryProcessor* FwidthSquircleTestProcessor::createGLSLInstance(
std::unique_ptr<GrGeometryProcessor::ProgramImpl> FwidthSquircleTestProcessor::makeProgramImpl(
const GrShaderCaps&) const {
return new Impl();
return std::make_unique<Impl>();
}
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -64,7 +64,7 @@ private:
const char* name() const final { return "TessellationTestTriShader"; }
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const final {}
class Impl : public GrGLSLGeometryProcessor {
class Impl : public ProgramImpl {
void onEmitCode(EmitArgs& args, GrGPArgs*) override {
args.fVaryingHandler->emitAttributes(args.fGeomProc.cast<TessellationTestTriShader>());
const char* viewMatrix;
@ -157,8 +157,8 @@ private:
GrGLSLUniformHandler::UniformHandle fViewMatrixUniform;
};
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override {
return new Impl;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const final {
return std::make_unique<Impl>();
}
const SkMatrix fViewMatrix;
@ -175,7 +175,7 @@ private:
const char* name() const final { return "TessellationTestRectShader"; }
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const final {}
class Impl : public GrGLSLGeometryProcessor {
class Impl : public ProgramImpl {
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
const char* viewMatrix;
fViewMatrixUniform = args.fUniformHandler->addUniform(
@ -265,8 +265,8 @@ private:
GrGLSLUniformHandler::UniformHandle fViewMatrixUniform;
};
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override {
return new Impl;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const final {
return std::make_unique<Impl>();
}
const SkMatrix fViewMatrix;

View File

@ -56,7 +56,7 @@ public:
uint8_t coverage() const { return fCoverage; }
bool hasVertexCoverage() const { return fInCoverage.isInitialized(); }
class GLSLProcessor : public GrGLSLGeometryProcessor {
class GLSLProcessor : public ProgramImpl {
public:
GLSLProcessor()
: fViewMatrixPrev(SkMatrix::InvalidMatrix())
@ -206,15 +206,15 @@ public:
UniformHandle fColorUniform;
UniformHandle fCoverageUniform;
using INHERITED = GrGLSLGeometryProcessor;
using INHERITED = ProgramImpl;
};
void addToKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GLSLProcessor::GenKey(*this, caps, b);
}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override {
return new GLSLProcessor();
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override {
return std::make_unique<GLSLProcessor>();
}
private:

View File

@ -18,7 +18,7 @@ const GrGeometryProcessor::TextureSampler& GrGeometryProcessor::textureSampler(i
}
uint32_t GrGeometryProcessor::ComputeCoordTransformsKey(const GrFragmentProcessor& fp) {
// This is highly coupled with the code in GrGLSLGeometryProcessor::collectTransforms().
// This is highly coupled with the code in ProgramImpl::collectTransforms().
uint32_t key = static_cast<uint32_t>(fp.sampleUsage().kind()) << 1;
// This needs to be updated if GP starts specializing varyings on additional matrix types.
if (fp.sampleUsage().hasPerspective()) {

View File

@ -14,7 +14,6 @@
#include "src/gpu/GrShaderVar.h"
#include "src/gpu/GrSwizzle.h"
class GrGLSLGeometryProcessor;
class GrGLSLUniformHandler;
/**
@ -45,6 +44,14 @@ class GrGLSLUniformHandler;
*/
class GrGeometryProcessor : public GrProcessor, public GrNonAtomicRef<GrGeometryProcessor> {
public:
/**
* Any GrGeometryProcessor is capable of creating a subclass of ProgramImpl. The ProgramImpl
* emits the shader code that implements the GrGeometryProcessor, is attached to the generated
* backend API pipeline/program and used to extract uniform data from GrGeometryProcessor
* instances.
*/
class ProgramImpl;
class TextureSampler;
/** Describes a vertex or instance attribute. */
@ -210,10 +217,11 @@ public:
add_attributes(fInstanceAttributes.fAttributes, fInstanceAttributes.fRawCount);
}
/** Returns a new instance of the appropriate *GL* implementation class
for the given GrProcessor; caller is responsible for deleting
the object. */
virtual GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const = 0;
/**
* Returns a new instance of the appropriate implementation class for the given
* GrGeometryProcessor.
*/
virtual std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const = 0;
protected:
// GPs that need to use either float or ubyte colors can just call this to get a correctly

View File

@ -24,30 +24,31 @@ GrD3DPipelineState::GrD3DPipelineState(
sk_sp<GrD3DPipeline> pipeline,
sk_sp<GrD3DRootSignature> rootSignature,
const GrGLSLBuiltinUniformHandles& builtinUniformHandles,
const UniformInfoArray& uniforms, uint32_t uniformSize,
const UniformInfoArray& uniforms,
uint32_t uniformSize,
uint32_t numSamplers,
std::unique_ptr<GrGLSLGeometryProcessor> geometryProcessor,
std::unique_ptr<GrGeometryProcessor::ProgramImpl> gpImpl,
std::unique_ptr<GrGLSLXferProcessor> xferProcessor,
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fpImpls,
size_t vertexStride,
size_t instanceStride)
: fPipeline(std::move(pipeline))
, fRootSignature(std::move(rootSignature))
, fBuiltinUniformHandles(builtinUniformHandles)
, fGeometryProcessor(std::move(geometryProcessor))
, fXferProcessor(std::move(xferProcessor))
, fFPImpls(std::move(fpImpls))
, fDataManager(uniforms, uniformSize)
, fNumSamplers(numSamplers)
, fVertexStride(vertexStride)
, fInstanceStride(instanceStride) {}
: fPipeline(std::move(pipeline))
, fRootSignature(std::move(rootSignature))
, fBuiltinUniformHandles(builtinUniformHandles)
, fGPImpl(std::move(gpImpl))
, fXferProcessor(std::move(xferProcessor))
, fFPImpls(std::move(fpImpls))
, fDataManager(uniforms, uniformSize)
, fNumSamplers(numSamplers)
, fVertexStride(vertexStride)
, fInstanceStride(instanceStride) {}
void GrD3DPipelineState::setAndBindConstants(GrD3DGpu* gpu,
const GrRenderTarget* renderTarget,
const GrProgramInfo& programInfo) {
this->setRenderTargetState(renderTarget, programInfo.origin());
fGeometryProcessor->setData(fDataManager, *gpu->caps()->shaderCaps(), programInfo.geomProc());
fGPImpl->setData(fDataManager, *gpu->caps()->shaderCaps(), programInfo.geomProc());
for (int i = 0; i < programInfo.pipeline().numFragmentProcessors(); ++i) {
const auto& fp = programInfo.pipeline().getFragmentProcessor(i);

View File

@ -33,7 +33,7 @@ public:
const UniformInfoArray& uniforms,
uint32_t uniformSize,
uint32_t numSamplers,
std::unique_ptr<GrGLSLGeometryProcessor> geometryProcessor,
std::unique_ptr<GrGeometryProcessor::ProgramImpl> gpImpl,
std::unique_ptr<GrGLSLXferProcessor> xferProcessor,
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fpImpls,
size_t vertexStride,
@ -87,8 +87,8 @@ private:
GrGLSLBuiltinUniformHandles fBuiltinUniformHandles;
// Processors in the GrD3DPipelineState
std::unique_ptr<GrGLSLGeometryProcessor> fGeometryProcessor;
std::unique_ptr<GrGLSLXferProcessor> fXferProcessor;
std::unique_ptr<GrGeometryProcessor::ProgramImpl> fGPImpl;
std::unique_ptr<GrGLSLXferProcessor> fXferProcessor;
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fFPImpls;
GrD3DPipelineStateDataManager fDataManager;

View File

@ -674,17 +674,17 @@ std::unique_ptr<GrD3DPipelineState> GrD3DPipelineStateBuilder::finalize() {
sk_sp<GrD3DPipeline> pipeline = GrD3DPipeline::Make(std::move(pipelineState));
return std::unique_ptr<GrD3DPipelineState>(
new GrD3DPipelineState(std::move(pipeline),
std::move(rootSig),
fUniformHandles,
fUniformHandler.fUniforms,
fUniformHandler.fCurrentUBOOffset,
fUniformHandler.fSamplers.count(),
std::move(fGeometryProcessor),
std::move(fXferProcessor),
std::move(fFPImpls),
geomProc.vertexStride(),
geomProc.instanceStride()));
new GrD3DPipelineState(std::move(pipeline),
std::move(rootSig),
fUniformHandles,
fUniformHandler.fUniforms,
fUniformHandler.fCurrentUBOOffset,
fUniformHandler.fSamplers.count(),
std::move(fGPImpl),
std::move(fXferProcessor),
std::move(fFPImpls),
geomProc.vertexStride(),
geomProc.instanceStride()));
}

View File

@ -279,7 +279,7 @@ sk_sp<GrDawnProgram> GrDawnProgramBuilder::Build(GrDawnGpu* gpu,
GrSPIRVUniformHandler::UniformInfoArray& uniforms = builder.fUniformHandler.fUniforms;
uint32_t uniformBufferSize = builder.fUniformHandler.fCurrentUBOOffset;
sk_sp<GrDawnProgram> result(new GrDawnProgram(uniforms, uniformBufferSize));
result->fGeometryProcessor = std::move(builder.fGeometryProcessor);
result->fGPImpl = std::move(builder.fGPImpl);
result->fXferProcessor = std::move(builder.fXferProcessor);
result->fFPImpls = std::move(builder.fFPImpls);
std::vector<wgpu::BindGroupLayoutEntry> uniformLayoutEntries;
@ -502,7 +502,7 @@ wgpu::BindGroup GrDawnProgram::setUniformData(GrDawnGpu* gpu, const GrRenderTarg
this->setRenderTargetState(renderTarget, programInfo.origin());
const GrPipeline& pipeline = programInfo.pipeline();
const GrGeometryProcessor& geomProc = programInfo.geomProc();
fGeometryProcessor->setData(fDataManager, *gpu->caps()->shaderCaps(), geomProc);
fGPImpl->setData(fDataManager, *gpu->caps()->shaderCaps(), geomProc);
for (int i = 0; i < programInfo.pipeline().numFragmentProcessors(); ++i) {
const auto& fp = programInfo.pipeline().getFragmentProcessor(i);

View File

@ -36,7 +36,7 @@ struct GrDawnProgram : public SkRefCnt {
uint32_t uniformBufferSize)
: fDataManager(uniforms, uniformBufferSize) {
}
std::unique_ptr<GrGLSLGeometryProcessor> fGeometryProcessor;
std::unique_ptr<GrGeometryProcessor::ProgramImpl> fGPImpl;
std::unique_ptr<GrGLSLXferProcessor> fXferProcessor;
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fFPImpls;
std::vector<wgpu::BindGroupLayout> fBindGroupLayouts;

View File

@ -15,7 +15,7 @@
#include "src/gpu/glsl/GrGLSLVarying.h"
#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
static void append_index_uv_varyings(GrGLSLGeometryProcessor::EmitArgs& args,
static void append_index_uv_varyings(GrGeometryProcessor::ProgramImpl::EmitArgs& args,
int numTextureSamplers,
const char* inTexCoordsName,
const char* atlasDimensionsInvName,
@ -76,9 +76,9 @@ static void append_index_uv_varyings(GrGLSLGeometryProcessor::EmitArgs& args,
}
}
static void append_multitexture_lookup(GrGLSLGeometryProcessor::EmitArgs& args,
static void append_multitexture_lookup(GrGeometryProcessor::ProgramImpl::EmitArgs& args,
int numTextureSamplers,
const GrGLSLVarying &texIdx,
const GrGLSLVarying& texIdx,
const char* coordName,
const char* colorName) {
SkASSERT(numTextureSamplers > 0);

View File

@ -14,7 +14,7 @@
#include "src/gpu/glsl/GrGLSLVarying.h"
#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
class GrGLConicEffect : public GrGLSLGeometryProcessor {
class GrGLConicEffect : public GrGeometryProcessor::ProgramImpl {
public:
GrGLConicEffect(const GrGeometryProcessor&);
@ -53,7 +53,7 @@ private:
UniformHandle fViewMatrixUniform;
UniformHandle fLocalMatrixUniform;
using INHERITED = GrGLSLGeometryProcessor;
using INHERITED = ProgramImpl;
};
GrGLConicEffect::GrGLConicEffect(const GrGeometryProcessor& processor)
@ -185,8 +185,9 @@ void GrConicEffect::addToKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b)
GrGLConicEffect::GenKey(*this, caps, b);
}
GrGLSLGeometryProcessor* GrConicEffect::createGLSLInstance(const GrShaderCaps&) const {
return new GrGLConicEffect(*this);
std::unique_ptr<GrGeometryProcessor::ProgramImpl> GrConicEffect::makeProgramImpl(
const GrShaderCaps&) const {
return std::make_unique<GrGLConicEffect>(*this);
}
GrConicEffect::GrConicEffect(const SkPMColor4f& color, const SkMatrix& viewMatrix, uint8_t coverage,
@ -223,7 +224,7 @@ GrGeometryProcessor* GrConicEffect::TestCreate(GrProcessorTestData* d) {
// Quad
//////////////////////////////////////////////////////////////////////////////
class GrGLQuadEffect : public GrGLSLGeometryProcessor {
class GrGLQuadEffect : public GrGeometryProcessor::ProgramImpl {
public:
GrGLQuadEffect(const GrGeometryProcessor&);
@ -263,7 +264,7 @@ private:
UniformHandle fViewMatrixUniform;
UniformHandle fLocalMatrixUniform;
using INHERITED = GrGLSLGeometryProcessor;
using INHERITED = ProgramImpl;
};
GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor)
@ -360,8 +361,9 @@ void GrQuadEffect::addToKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b)
GrGLQuadEffect::GenKey(*this, caps, b);
}
GrGLSLGeometryProcessor* GrQuadEffect::createGLSLInstance(const GrShaderCaps&) const {
return new GrGLQuadEffect(*this);
std::unique_ptr<GrGeometryProcessor::ProgramImpl> GrQuadEffect::makeProgramImpl(
const GrShaderCaps&) const {
return std::make_unique<GrGLQuadEffect>(*this);
}
GrQuadEffect::GrQuadEffect(const SkPMColor4f& color, const SkMatrix& viewMatrix, uint8_t coverage,

View File

@ -91,7 +91,7 @@ public:
void addToKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override;
private:
GrConicEffect(const SkPMColor4f&, const SkMatrix& viewMatrix, uint8_t coverage,
@ -158,7 +158,7 @@ public:
void addToKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override;
private:
GrQuadEffect(const SkPMColor4f&, const SkMatrix& viewMatrix, uint8_t coverage,

View File

@ -18,7 +18,7 @@
#include "src/gpu/glsl/GrGLSLVarying.h"
#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
class GrGLBitmapTextGeoProc : public GrGLSLGeometryProcessor {
class GrGLBitmapTextGeoProc : public GrGeometryProcessor::ProgramImpl {
public:
GrGLBitmapTextGeoProc()
: fColor(SK_PMColor4fILLEGAL)
@ -121,7 +121,7 @@ private:
SkMatrix fLocalMatrix;
UniformHandle fLocalMatrixUniform;
using INHERITED = GrGLSLGeometryProcessor;
using INHERITED = ProgramImpl;
};
///////////////////////////////////////////////////////////////////////////////
@ -197,8 +197,9 @@ void GrBitmapTextGeoProc::addToKey(const GrShaderCaps& caps, GrProcessorKeyBuild
GrGLBitmapTextGeoProc::GenKey(*this, caps, b);
}
GrGLSLGeometryProcessor* GrBitmapTextGeoProc::createGLSLInstance(const GrShaderCaps& caps) const {
return new GrGLBitmapTextGeoProc();
std::unique_ptr<GrGeometryProcessor::ProgramImpl> GrBitmapTextGeoProc::makeProgramImpl(
const GrShaderCaps& caps) const {
return std::make_unique<GrGLBitmapTextGeoProc>();
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -59,7 +59,7 @@ public:
void addToKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps& caps) const override;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps& caps) const override;
private:
GrBitmapTextGeoProc(const GrShaderCaps&, const SkPMColor4f&, bool wideColor,

View File

@ -21,7 +21,7 @@
// Assuming a radius of a little less than the diagonal of the fragment
#define SK_DistanceFieldAAFactor "0.65"
class GrGLDistanceFieldA8TextGeoProc : public GrGLSLGeometryProcessor {
class GrGLDistanceFieldA8TextGeoProc : public GrGeometryProcessor::ProgramImpl {
public:
GrGLDistanceFieldA8TextGeoProc() = default;
@ -205,7 +205,7 @@ private:
SkMatrix fLocalMatrix = SkMatrix::InvalidMatrix();
UniformHandle fLocalMatrixUniform;
using INHERITED = GrGLSLGeometryProcessor;
using INHERITED = ProgramImpl;
};
///////////////////////////////////////////////////////////////////////////////
@ -278,9 +278,9 @@ void GrDistanceFieldA8TextGeoProc::addToKey(const GrShaderCaps& caps,
GrGLDistanceFieldA8TextGeoProc::GenKey(*this, caps, b);
}
GrGLSLGeometryProcessor*
GrDistanceFieldA8TextGeoProc::createGLSLInstance(const GrShaderCaps&) const {
return new GrGLDistanceFieldA8TextGeoProc();
std::unique_ptr<GrGeometryProcessor::ProgramImpl> GrDistanceFieldA8TextGeoProc::makeProgramImpl(
const GrShaderCaps&) const {
return std::make_unique<GrGLDistanceFieldA8TextGeoProc>();
}
///////////////////////////////////////////////////////////////////////////////
@ -318,7 +318,7 @@ GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorTestDat
///////////////////////////////////////////////////////////////////////////////
class GrGLDistanceFieldPathGeoProc : public GrGLSLGeometryProcessor {
class GrGLDistanceFieldPathGeoProc : public GrGeometryProcessor::ProgramImpl {
public:
GrGLDistanceFieldPathGeoProc() : fMatrix(SkMatrix::InvalidMatrix()), fAtlasDimensions{0,0} {}
@ -487,7 +487,7 @@ private:
SkISize fAtlasDimensions;
UniformHandle fAtlasDimensionsInvUniform;
using INHERITED = GrGLSLGeometryProcessor;
using INHERITED = ProgramImpl;
};
///////////////////////////////////////////////////////////////////////////////
@ -551,9 +551,9 @@ void GrDistanceFieldPathGeoProc::addToKey(const GrShaderCaps& caps,
GrGLDistanceFieldPathGeoProc::GenKey(*this, caps, b);
}
GrGLSLGeometryProcessor*
GrDistanceFieldPathGeoProc::createGLSLInstance(const GrShaderCaps&) const {
return new GrGLDistanceFieldPathGeoProc();
std::unique_ptr<GrGeometryProcessor::ProgramImpl> GrDistanceFieldPathGeoProc::makeProgramImpl(
const GrShaderCaps&) const {
return std::make_unique<GrGLDistanceFieldPathGeoProc>();
}
///////////////////////////////////////////////////////////////////////////////
@ -588,7 +588,7 @@ GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTestData*
///////////////////////////////////////////////////////////////////////////////
class GrGLDistanceFieldLCDTextGeoProc : public GrGLSLGeometryProcessor {
class GrGLDistanceFieldLCDTextGeoProc : public GrGeometryProcessor::ProgramImpl {
public:
GrGLDistanceFieldLCDTextGeoProc()
: fAtlasDimensions({0, 0})
@ -809,7 +809,7 @@ private:
SkMatrix fLocalMatrix;
UniformHandle fLocalMatrixUniform;
using INHERITED = GrGLSLGeometryProcessor;
using INHERITED = ProgramImpl;
};
///////////////////////////////////////////////////////////////////////////////
@ -878,9 +878,9 @@ void GrDistanceFieldLCDTextGeoProc::addToKey(const GrShaderCaps& caps,
GrGLDistanceFieldLCDTextGeoProc::GenKey(*this, caps, b);
}
GrGLSLGeometryProcessor* GrDistanceFieldLCDTextGeoProc::createGLSLInstance(
std::unique_ptr<GrGeometryProcessor::ProgramImpl> GrDistanceFieldLCDTextGeoProc::makeProgramImpl(
const GrShaderCaps&) const {
return new GrGLDistanceFieldLCDTextGeoProc();
return std::make_unique<GrGLDistanceFieldLCDTextGeoProc>();
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -104,7 +104,7 @@ public:
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override;
private:
GrDistanceFieldA8TextGeoProc(const GrShaderCaps& caps,
@ -171,7 +171,7 @@ public:
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override;
private:
GrDistanceFieldPathGeoProc(const GrShaderCaps& caps,
@ -253,7 +253,7 @@ public:
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override;
private:
GrDistanceFieldLCDTextGeoProc(const GrShaderCaps& caps, const GrSurfaceProxyView* views,

View File

@ -14,7 +14,7 @@
#include "src/gpu/glsl/GrGLSLVarying.h"
#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
class GrGLSLRRectShadowGeoProc : public GrGLSLGeometryProcessor {
class GrGLSLRRectShadowGeoProc : public GrGeometryProcessor::ProgramImpl {
public:
GrGLSLRRectShadowGeoProc() {}
@ -50,7 +50,7 @@ public:
const GrGeometryProcessor&) override {}
private:
using INHERITED = GrGLSLGeometryProcessor;
using INHERITED = ProgramImpl;
};
///////////////////////////////////////////////////////////////////////////////
@ -68,8 +68,9 @@ GrRRectShadowGeoProc::GrRRectShadowGeoProc(const GrSurfaceProxyView& lutView)
this->setTextureSamplerCnt(1);
}
GrGLSLGeometryProcessor* GrRRectShadowGeoProc::createGLSLInstance(const GrShaderCaps&) const {
return new GrGLSLRRectShadowGeoProc();
std::unique_ptr<GrGeometryProcessor::ProgramImpl> GrRRectShadowGeoProc::makeProgramImpl(
const GrShaderCaps&) const {
return std::make_unique<GrGLSLRRectShadowGeoProc>();
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -36,7 +36,7 @@ public:
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override;
private:
GrRRectShadowGeoProc(const GrSurfaceProxyView& lutView);

View File

@ -31,7 +31,7 @@ sk_sp<GrGLProgram> GrGLProgram::Make(
GrGLuint programID,
const UniformInfoArray& uniforms,
const UniformInfoArray& textureSamplers,
std::unique_ptr<GrGLSLGeometryProcessor> geometryProcessor,
std::unique_ptr<GrGeometryProcessor::ProgramImpl> gpImpl,
std::unique_ptr<GrGLSLXferProcessor> xferProcessor,
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fpImpls,
std::unique_ptr<Attribute[]> attributes,
@ -44,7 +44,7 @@ sk_sp<GrGLProgram> GrGLProgram::Make(
programID,
uniforms,
textureSamplers,
std::move(geometryProcessor),
std::move(gpImpl),
std::move(xferProcessor),
std::move(fpImpls),
std::move(attributes),
@ -63,7 +63,7 @@ GrGLProgram::GrGLProgram(GrGLGpu* gpu,
GrGLuint programID,
const UniformInfoArray& uniforms,
const UniformInfoArray& textureSamplers,
std::unique_ptr<GrGLSLGeometryProcessor> geometryProcessor,
std::unique_ptr<GrGeometryProcessor::ProgramImpl> gpImpl,
std::unique_ptr<GrGLSLXferProcessor> xferProcessor,
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fpImpls,
std::unique_ptr<Attribute[]> attributes,
@ -73,7 +73,7 @@ GrGLProgram::GrGLProgram(GrGLGpu* gpu,
int instanceStride)
: fBuiltinUniformHandles(builtinUniforms)
, fProgramID(programID)
, fGeometryProcessor(std::move(geometryProcessor))
, fGPImpl(std::move(gpImpl))
, fXferProcessor(std::move(xferProcessor))
, fFPImpls(std::move(fpImpls))
, fAttributes(std::move(attributes))
@ -83,8 +83,7 @@ GrGLProgram::GrGLProgram(GrGLGpu* gpu,
, fInstanceStride(instanceStride)
, fGpu(gpu)
, fProgramDataManager(gpu, uniforms)
, fNumTextureSamplers(textureSamplers.count()) {
}
, fNumTextureSamplers(textureSamplers.count()) {}
GrGLProgram::~GrGLProgram() {
if (fProgramID) {
@ -108,9 +107,7 @@ void GrGLProgram::updateUniforms(const GrRenderTarget* renderTarget,
// We must bind to texture units in the same order in which we set the uniforms in
// GrGLProgramDataManager. That is, we bind textures for processors in this order:
// primProc, fragProcs, XP.
fGeometryProcessor->setData(fProgramDataManager,
*fGpu->caps()->shaderCaps(),
programInfo.geomProc());
fGPImpl->setData(fProgramDataManager, *fGpu->caps()->shaderCaps(), programInfo.geomProc());
for (int i = 0; i < programInfo.pipeline().numFragmentProcessors(); ++i) {
const auto& fp = programInfo.pipeline().getFragmentProcessor(i);

View File

@ -10,13 +10,13 @@
#define GrGLProgram_DEFINED
#include "src/gpu/GrFragmentProcessor.h"
#include "src/gpu/GrGeometryProcessor.h"
#include "src/gpu/gl/GrGLProgramDataManager.h"
#include "src/gpu/glsl/GrGLSLProgramDataManager.h"
#include "src/gpu/glsl/GrGLSLUniformHandler.h"
#include <vector>
class GrGLSLGeometryProcessor;
class GrGLSLXferProcessor;
class GrPipeline;
class GrGeometryProcessor;
@ -56,7 +56,7 @@ public:
GrGLuint programID,
const UniformInfoArray& uniforms,
const UniformInfoArray& textureSamplers,
std::unique_ptr<GrGLSLGeometryProcessor>,
std::unique_ptr<GrGeometryProcessor::ProgramImpl>,
std::unique_ptr<GrGLSLXferProcessor>,
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fps,
std::unique_ptr<Attribute[]>,
@ -129,7 +129,7 @@ private:
GrGLuint programID,
const UniformInfoArray& uniforms,
const UniformInfoArray& textureSamplers,
std::unique_ptr<GrGLSLGeometryProcessor>,
std::unique_ptr<GrGeometryProcessor::ProgramImpl>,
std::unique_ptr<GrGLSLXferProcessor>,
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fpImpls,
std::unique_ptr<Attribute[]>,
@ -147,8 +147,8 @@ private:
GrGLuint fProgramID;
// the installed effects
std::unique_ptr<GrGLSLGeometryProcessor> fGeometryProcessor;
std::unique_ptr<GrGLSLXferProcessor> fXferProcessor;
std::unique_ptr<GrGeometryProcessor::ProgramImpl> fGPImpl;
std::unique_ptr<GrGLSLXferProcessor> fXferProcessor;
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fFPImpls;
std::unique_ptr<Attribute[]> fAttributes;

View File

@ -388,9 +388,11 @@ sk_sp<GrGLProgram> GrGLProgramBuilder::finalize(const GrGLPrecompiledProgram* pr
versionAndExtensionDecls.appendf("#extension %s : require\n", extensionString);
}
SkString tessControlShader = fGeometryProcessor->getTessControlShaderGLSL(
geomProc, versionAndExtensionDecls.c_str(), fUniformHandler,
*this->shaderCaps());
SkString tessControlShader =
fGPImpl->getTessControlShaderGLSL(geomProc,
versionAndExtensionDecls.c_str(),
fUniformHandler,
*this->shaderCaps());
if (!this->compileAndAttachShaders(tessControlShader.c_str(), programID,
GR_GL_TESS_CONTROL_SHADER, &shadersToDelete,
errorHandler)) {
@ -398,9 +400,11 @@ sk_sp<GrGLProgram> GrGLProgramBuilder::finalize(const GrGLPrecompiledProgram* pr
return nullptr;
}
SkString tessEvaluationShader = fGeometryProcessor->getTessEvaluationShaderGLSL(
geomProc, versionAndExtensionDecls.c_str(), fUniformHandler,
*this->shaderCaps());
SkString tessEvaluationShader =
fGPImpl->getTessEvaluationShaderGLSL(geomProc,
versionAndExtensionDecls.c_str(),
fUniformHandler,
*this->shaderCaps());
if (!this->compileAndAttachShaders(tessEvaluationShader.c_str(), programID,
GR_GL_TESS_EVALUATION_SHADER, &shadersToDelete,
errorHandler)) {
@ -458,7 +462,7 @@ sk_sp<GrGLProgram> GrGLProgramBuilder::finalize(const GrGLPrecompiledProgram* pr
if (!cached && !geomProc.willUseTessellationShaders() && !precompiledProgram) {
// FIXME: Remove the check for tessellation shaders in the above 'if' once the back door
// GLSL mechanism is removed.
(void)&GrGLSLGeometryProcessor::getTessControlShaderGLSL;
(void)&GrGeometryProcessor::ProgramImpl::getTessControlShaderGLSL;
bool isSkSL = false;
if (fGpu->getContext()->priv().options().fShaderCacheStrategy ==
GrContextOptions::ShaderCacheStrategy::kSkSL) {
@ -531,7 +535,7 @@ sk_sp<GrGLProgram> GrGLProgramBuilder::createProgram(GrGLuint programID) {
programID,
fUniformHandler.fUniforms,
fUniformHandler.fSamplers,
std::move(fGeometryProcessor),
std::move(fGPImpl),
std::move(fXferProcessor),
std::move(fFPImpls),
std::move(fAttributes),

View File

@ -17,8 +17,9 @@
#include <queue>
GrGLSLGeometryProcessor::FPCoordsMap GrGLSLGeometryProcessor::emitCode(EmitArgs& args,
const GrPipeline& pipeline) {
using ProgramImpl = GrGeometryProcessor::ProgramImpl;
ProgramImpl::FPCoordsMap ProgramImpl::emitCode(EmitArgs& args, const GrPipeline& pipeline) {
GrGPArgs gpArgs;
this->onEmitCode(args, &gpArgs);
@ -77,13 +78,12 @@ GrGLSLGeometryProcessor::FPCoordsMap GrGLSLGeometryProcessor::emitCode(EmitArgs&
return transformMap;
}
GrGLSLGeometryProcessor::FPCoordsMap GrGLSLGeometryProcessor::collectTransforms(
GrGLSLVertexBuilder* vb,
GrGLSLVaryingHandler* varyingHandler,
GrGLSLUniformHandler* uniformHandler,
const GrShaderVar& localCoordsVar,
const GrShaderVar& positionVar,
const GrPipeline& pipeline) {
ProgramImpl::FPCoordsMap ProgramImpl::collectTransforms(GrGLSLVertexBuilder* vb,
GrGLSLVaryingHandler* varyingHandler,
GrGLSLUniformHandler* uniformHandler,
const GrShaderVar& localCoordsVar,
const GrShaderVar& positionVar,
const GrPipeline& pipeline) {
SkASSERT(localCoordsVar.getType() == kFloat2_GrSLType ||
localCoordsVar.getType() == kFloat3_GrSLType ||
localCoordsVar.getType() == kVoid_GrSLType);
@ -201,8 +201,7 @@ GrGLSLGeometryProcessor::FPCoordsMap GrGLSLGeometryProcessor::collectTransforms(
return result;
}
void GrGLSLGeometryProcessor::emitTransformCode(GrGLSLVertexBuilder* vb,
GrGLSLUniformHandler* uniformHandler) {
void ProgramImpl::emitTransformCode(GrGLSLVertexBuilder* vb, GrGLSLUniformHandler* uniformHandler) {
// Because descendant varyings may be computed using the varyings of ancestor FPs we make
// sure to visit the varyings according to FP pre-order traversal by dumping them into a
// priority queue.
@ -285,10 +284,10 @@ void GrGLSLGeometryProcessor::emitTransformCode(GrGLSLVertexBuilder* vb,
fTransformVaryingsMap.clear();
}
void GrGLSLGeometryProcessor::setupUniformColor(GrGLSLFPFragmentBuilder* fragBuilder,
GrGLSLUniformHandler* uniformHandler,
const char* outputName,
UniformHandle* colorUniform) {
void ProgramImpl::setupUniformColor(GrGLSLFPFragmentBuilder* fragBuilder,
GrGLSLUniformHandler* uniformHandler,
const char* outputName,
UniformHandle* colorUniform) {
SkASSERT(colorUniform);
const char* stagedLocalVarName;
*colorUniform = uniformHandler->addUniform(nullptr,
@ -302,11 +301,11 @@ void GrGLSLGeometryProcessor::setupUniformColor(GrGLSLFPFragmentBuilder* fragBui
}
}
void GrGLSLGeometryProcessor::SetTransform(const GrGLSLProgramDataManager& pdman,
const GrShaderCaps& shaderCaps,
const UniformHandle& uniform,
const SkMatrix& matrix,
SkMatrix* state) {
void ProgramImpl::SetTransform(const GrGLSLProgramDataManager& pdman,
const GrShaderCaps& shaderCaps,
const UniformHandle& uniform,
const SkMatrix& matrix,
SkMatrix* state) {
if (!uniform.isValid() || (state && SkMatrixPriv::CheapEqual(*state, matrix))) {
// No update needed
return;
@ -344,7 +343,7 @@ static void write_vertex_position(GrGLSLVertexBuilder* vertBuilder,
const SkMatrix& matrix,
const char* matrixName,
GrShaderVar* outPos,
GrGLSLGeometryProcessor::UniformHandle* matrixUniform) {
ProgramImpl::UniformHandle* matrixUniform) {
SkASSERT(inPos.getType() == kFloat3_GrSLType || inPos.getType() == kFloat2_GrSLType);
SkString outName = vertBuilder->newTmpVarName(inPos.getName().c_str());
@ -410,21 +409,21 @@ static void write_vertex_position(GrGLSLVertexBuilder* vertBuilder,
outPos->set(kFloat2_GrSLType, outName.c_str());
}
void GrGLSLGeometryProcessor::WriteOutputPosition(GrGLSLVertexBuilder* vertBuilder,
GrGPArgs* gpArgs,
const char* posName) {
void ProgramImpl::WriteOutputPosition(GrGLSLVertexBuilder* vertBuilder,
GrGPArgs* gpArgs,
const char* posName) {
// writeOutputPosition assumes the incoming pos name points to a float2 variable
GrShaderVar inPos(posName, kFloat2_GrSLType);
write_passthrough_vertex_position(vertBuilder, inPos, &gpArgs->fPositionVar);
}
void GrGLSLGeometryProcessor::WriteOutputPosition(GrGLSLVertexBuilder* vertBuilder,
GrGLSLUniformHandler* uniformHandler,
const GrShaderCaps& shaderCaps,
GrGPArgs* gpArgs,
const char* posName,
const SkMatrix& mat,
UniformHandle* viewMatrixUniform) {
void ProgramImpl::WriteOutputPosition(GrGLSLVertexBuilder* vertBuilder,
GrGLSLUniformHandler* uniformHandler,
const GrShaderCaps& shaderCaps,
GrGPArgs* gpArgs,
const char* posName,
const SkMatrix& mat,
UniformHandle* viewMatrixUniform) {
GrShaderVar inPos(posName, kFloat2_GrSLType);
write_vertex_position(vertBuilder,
uniformHandler,
@ -436,13 +435,13 @@ void GrGLSLGeometryProcessor::WriteOutputPosition(GrGLSLVertexBuilder* vertBuild
viewMatrixUniform);
}
void GrGLSLGeometryProcessor::WriteLocalCoord(GrGLSLVertexBuilder* vertBuilder,
GrGLSLUniformHandler* uniformHandler,
const GrShaderCaps& shaderCaps,
GrGPArgs* gpArgs,
GrShaderVar localVar,
const SkMatrix& localMatrix,
UniformHandle* localMatrixUniform) {
void ProgramImpl::WriteLocalCoord(GrGLSLVertexBuilder* vertBuilder,
GrGLSLUniformHandler* uniformHandler,
const GrShaderCaps& shaderCaps,
GrGPArgs* gpArgs,
GrShaderVar localVar,
const SkMatrix& localMatrix,
UniformHandle* localMatrixUniform) {
write_vertex_position(vertBuilder,
uniformHandler,
shaderCaps,

View File

@ -20,17 +20,11 @@
class GrGeometryProcessor;
class GrGLSLFPFragmentBuilder;
class GrGLSLGeometryBuilder;
class GrGLSLGPBuilder;
class GrGLSLVaryingHandler;
class GrGLSLVertexBuilder;
class GrShaderCaps;
/**
* GrGeometryProcessor-derived classes that need to emit GLSL vertex shader code should be paired
* with a sibling class derived from GrGLSLGeometryProcessor (and return an instance of it from
* createGLSLInstance).
*/
class GrGLSLGeometryProcessor {
class GrGeometryProcessor::ProgramImpl {
public:
using UniformHandle = GrGLSLProgramDataManager::UniformHandle;
using SamplerHandle = GrGLSLUniformHandler::SamplerHandle;
@ -42,8 +36,7 @@ public:
struct FPCoords {GrShaderVar coordsVarying; bool hasCoordsParam;};
using FPCoordsMap = std::unordered_map<const GrFragmentProcessor*, FPCoords>;
virtual ~GrGLSLGeometryProcessor() {}
virtual ~ProgramImpl() = default;
struct EmitArgs {
EmitArgs(GrGLSLVertexBuilder* vertBuilder,
@ -96,12 +89,11 @@ public:
GrGLSLUniformHandler* uniformHandler);
/**
* A GrGLSLGeometryProcessor instance can be reused with any GrGLSLGeometryProcessor that
* produces the same stage key; this function reads data from a GrGLSLGeometryProcessor and
* uploads any uniform variables required by the shaders created in emitCode(). The
* GrGeometryProcessor parameter is guaranteed to be of the same type and to have an
* identical processor key as the GrGeometryProcessor that created this
* GrGLSLGeometryProcessor.
* A ProgramImpl instance can be reused with any GrGeometryProcessor that produces the same key.
* This function reads data from a GrGeometryProcessor and updates any uniform variables
* required by the shaders created in emitCode(). The GrGeometryProcessor parameter is
* guaranteed to be of the same type and to have an identical processor key as the
* GrGeometryProcessor that created this ProgramImpl.
*/
virtual void setData(const GrGLSLProgramDataManager&,
const GrShaderCaps&,
@ -145,7 +137,7 @@ protected:
// Used to specify the variable storing the draw's local coordinates. It can be either a
// float2, float3, or void. It can only be void when no FP needs local coordinates. This
// variable can be an attribute or local variable, but should not itself be a varying.
// GrGLSLGeometryProcessor automatically determines if this must be passed to a FS.
// ProgramImpl automatically determines if this must be passed to a FS.
GrShaderVar fLocalCoordVar;
};

View File

@ -32,7 +32,7 @@ GrGLSLProgramBuilder::GrGLSLProgramBuilder(const GrProgramDesc& desc,
, fStageIndex(-1)
, fDesc(desc)
, fProgramInfo(programInfo)
, fGeometryProcessor(nullptr)
, fGPImpl(nullptr)
, fXferProcessor(nullptr)
, fNumFragmentSamplers(0) {}
@ -55,7 +55,7 @@ void GrGLSLProgramBuilder::addFeature(GrShaderFlags shaders,
bool GrGLSLProgramBuilder::emitAndInstallProcs() {
// First we loop over all of the installed processors and collect coord transforms. These will
// be sent to the GrGLSLGeometryProcessor in its emitCode function
// be sent to the ProgramImpl in its emitCode function
SkSL::dsl::Start(this->shaderCompiler());
SkString inputColor;
SkString inputCoverage;
@ -71,7 +71,7 @@ bool GrGLSLProgramBuilder::emitAndInstallProcs() {
if (!this->emitAndInstallXferProc(inputColor, inputCoverage)) {
return false;
}
fGeometryProcessor->emitTransformCode(&fVS, this->uniformHandler());
fGPImpl->emitTransformCode(&fVS, this->uniformHandler());
SkSL::dsl::End();
return this->checkSamplerCounts();
@ -100,8 +100,8 @@ bool GrGLSLProgramBuilder::emitAndInstallPrimProc(SkString* outputColor, SkStrin
fFS.codeAppendf("// Stage %d, %s\n", fStageIndex, geomProc.name());
fVS.codeAppendf("// Primitive Processor %s\n", geomProc.name());
SkASSERT(!fGeometryProcessor);
fGeometryProcessor.reset(geomProc.createGLSLInstance(*this->shaderCaps()));
SkASSERT(!fGPImpl);
fGPImpl = geomProc.makeProgramImpl(*this->shaderCaps());
SkAutoSTArray<4, SamplerHandle> texSamplers(geomProc.numTextureSamplers());
for (int i = 0; i < geomProc.numTextureSamplers(); ++i) {
@ -117,17 +117,17 @@ bool GrGLSLProgramBuilder::emitAndInstallPrimProc(SkString* outputColor, SkStrin
}
}
GrGLSLGeometryProcessor::EmitArgs args(&fVS,
geomProc.willUseGeoShader() ? &fGS : nullptr,
&fFS,
this->varyingHandler(),
this->uniformHandler(),
this->shaderCaps(),
geomProc,
outputColor->c_str(),
outputCoverage->c_str(),
texSamplers.get());
fFPCoordsMap = fGeometryProcessor->emitCode(args, this->pipeline());
GrGeometryProcessor::ProgramImpl::EmitArgs args(&fVS,
geomProc.willUseGeoShader() ? &fGS : nullptr,
&fFS,
this->varyingHandler(),
this->uniformHandler(),
this->shaderCaps(),
geomProc,
outputColor->c_str(),
outputCoverage->c_str(),
texSamplers.get());
fFPCoordsMap = fGPImpl->emitCode(args, this->pipeline());
// We have to check that effects and the code they emit are consistent, ie if an effect
// asks for dst color, then the emit code needs to follow suit

View File

@ -117,9 +117,9 @@ public:
GrGLSLBuiltinUniformHandles fUniformHandles;
std::unique_ptr<GrGLSLGeometryProcessor> fGeometryProcessor;
std::unique_ptr<GrGLSLXferProcessor> fXferProcessor;
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fFPImpls;
std::unique_ptr<GrGeometryProcessor::ProgramImpl> fGPImpl;
std::unique_ptr<GrGLSLXferProcessor> fXferProcessor;
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fFPImpls;
SamplerHandle fDstTextureSamplerHandle;
GrSurfaceOrigin fDstTextureOrigin;
@ -182,7 +182,7 @@ private:
// These are used to check that we don't excede the allowable number of resources in a shader.
int fNumFragmentSamplers;
GrGLSLGeometryProcessor::FPCoordsMap fFPCoordsMap;
GrGeometryProcessor::ProgramImpl::FPCoordsMap fFPCoordsMap;
};
#endif

View File

@ -8,6 +8,7 @@
#ifndef GrGLSLVertexGeoBuilder_DEFINED
#define GrGLSLVertexGeoBuilder_DEFINED
#include "src/gpu/GrGeometryProcessor.h"
#include "src/gpu/glsl/GrGLSLShaderBuilder.h"
/**
@ -36,7 +37,7 @@ protected:
void emitNormalizedSkPosition(SkString* out, const char* devPos,
GrSLType devPosType = GrSLType::kFloat2_GrSLType);
friend class GrGLSLGeometryProcessor;
friend class GrGeometryProcessor::ProgramImpl;
using INHERITED = GrGLSLShaderBuilder;
};

View File

@ -35,17 +35,16 @@ public:
using UniformInfoArray = GrMtlPipelineStateDataManager::UniformInfoArray;
using UniformHandle = GrGLSLProgramDataManager::UniformHandle;
GrMtlPipelineState(
GrMtlGpu*,
sk_sp<GrMtlRenderPipeline> pipeline,
MTLPixelFormat,
const GrGLSLBuiltinUniformHandles& builtinUniformHandles,
const UniformInfoArray& uniforms,
uint32_t uniformBufferSize,
uint32_t numSamplers,
std::unique_ptr<GrGLSLGeometryProcessor>,
std::unique_ptr<GrGLSLXferProcessor>,
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fpImpls);
GrMtlPipelineState(GrMtlGpu*,
sk_sp<GrMtlRenderPipeline> pipeline,
MTLPixelFormat,
const GrGLSLBuiltinUniformHandles& builtinUniformHandles,
const UniformInfoArray& uniforms,
uint32_t uniformBufferSize,
uint32_t numSamplers,
std::unique_ptr<GrGeometryProcessor::ProgramImpl>,
std::unique_ptr<GrGLSLXferProcessor>,
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fpImpls);
const sk_sp<GrMtlRenderPipeline>& pipeline() const { return fPipeline; }
@ -112,8 +111,8 @@ private:
int fNumSamplers;
SkTArray<SamplerBindings> fSamplerBindings;
std::unique_ptr<GrGLSLGeometryProcessor> fGeometryProcessor;
std::unique_ptr<GrGLSLXferProcessor> fXferProcessor;
std::unique_ptr<GrGeometryProcessor::ProgramImpl> fGPImpl;
std::unique_ptr<GrGLSLXferProcessor> fXferProcessor;
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fFPImpls;
GrMtlPipelineStateDataManager fDataManager;

View File

@ -35,22 +35,22 @@ GrMtlPipelineState::SamplerBindings::SamplerBindings(GrSamplerState state,
}
GrMtlPipelineState::GrMtlPipelineState(
GrMtlGpu* gpu,
sk_sp<GrMtlRenderPipeline> pipeline,
MTLPixelFormat pixelFormat,
const GrGLSLBuiltinUniformHandles& builtinUniformHandles,
const UniformInfoArray& uniforms,
uint32_t uniformBufferSize,
uint32_t numSamplers,
std::unique_ptr<GrGLSLGeometryProcessor> geometryProcessor,
std::unique_ptr<GrGLSLXferProcessor> xferProcessor,
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fpImpls)
GrMtlGpu* gpu,
sk_sp<GrMtlRenderPipeline> pipeline,
MTLPixelFormat pixelFormat,
const GrGLSLBuiltinUniformHandles& builtinUniformHandles,
const UniformInfoArray& uniforms,
uint32_t uniformBufferSize,
uint32_t numSamplers,
std::unique_ptr<GrGeometryProcessor::ProgramImpl> gpImpl,
std::unique_ptr<GrGLSLXferProcessor> xferProcessor,
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fpImpls)
: fGpu(gpu)
, fPipeline(pipeline)
, fPixelFormat(pixelFormat)
, fBuiltinUniformHandles(builtinUniformHandles)
, fNumSamplers(numSamplers)
, fGeometryProcessor(std::move(geometryProcessor))
, fGPImpl(std::move(gpImpl))
, fXferProcessor(std::move(xferProcessor))
, fFPImpls(std::move(fpImpls))
, fDataManager(uniforms, uniformBufferSize) {
@ -62,7 +62,7 @@ void GrMtlPipelineState::setData(GrMtlFramebuffer* framebuffer,
SkISize colorAttachmentDimensions = framebuffer->colorAttachment()->dimensions();
this->setRenderTargetState(colorAttachmentDimensions, programInfo.origin());
fGeometryProcessor->setData(fDataManager, *fGpu->caps()->shaderCaps(), programInfo.geomProc());
fGPImpl->setData(fDataManager, *fGpu->caps()->shaderCaps(), programInfo.geomProc());
for (int i = 0; i < programInfo.pipeline().numFragmentProcessors(); ++i) {
const auto& fp = programInfo.pipeline().getFragmentProcessor(i);

View File

@ -736,7 +736,7 @@ GrMtlPipelineState* GrMtlPipelineStateBuilder::finalize(
fUniformHandler.fUniforms,
bufferSize,
(uint32_t)fUniformHandler.numSamplers(),
std::move(fGeometryProcessor),
std::move(fGPImpl),
std::move(fXferProcessor),
std::move(fFPImpls));
}

View File

@ -561,7 +561,7 @@ public:
const char* name() const override { return "QuadEdge"; }
class GLSLProcessor : public GrGLSLGeometryProcessor {
class GLSLProcessor : public ProgramImpl {
public:
GLSLProcessor() {}
@ -636,7 +636,7 @@ public:
}
private:
using INHERITED = GrGLSLGeometryProcessor;
using INHERITED = ProgramImpl;
SkMatrix fLocalMatrix = SkMatrix::InvalidMatrix();
UniformHandle fLocalMatrixUniform;
@ -646,8 +646,8 @@ public:
GLSLProcessor::GenKey(*this, caps, b);
}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override {
return new GLSLProcessor();
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override {
return std::make_unique<GLSLProcessor>();
}
private:

View File

@ -37,7 +37,8 @@ void GrAtlasInstancedHelper::writeInstanceData(GrVertexWriter* instanceWriter,
}
void GrAtlasInstancedHelper::injectShaderCode(
const GrGLSLGeometryProcessor::EmitArgs& args, const GrShaderVar& devCoord,
const GrGeometryProcessor::ProgramImpl::EmitArgs& args,
const GrShaderVar& devCoord,
GrGLSLUniformHandler::UniformHandle* atlasAdjustUniformHandle) const {
GrGLSLVarying atlasCoord(kFloat2_GrSLType);
args.fVaryingHandler->addVarying("atlasCoord", &atlasCoord);

View File

@ -80,7 +80,8 @@ public:
//
// The caller is responsible to store "atlasAdjustUniformHandle" and pass it to
// setUniformData().
void injectShaderCode(const GrGLSLGeometryProcessor::EmitArgs&, const GrShaderVar& devCoord,
void injectShaderCode(const GrGeometryProcessor::ProgramImpl::EmitArgs&,
const GrShaderVar& devCoord,
GrGLSLUniformHandler::UniformHandle* atlasAdjustUniformHandle) const;
// The atlas clip requires one uniform value -- "atlasAdjustUniform". The caller should have

View File

@ -832,7 +832,7 @@ public:
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override;
private:
friend class GLDashingCircleEffect;
@ -856,7 +856,7 @@ private:
//////////////////////////////////////////////////////////////////////////////
class GLDashingCircleEffect : public GrGLSLGeometryProcessor {
class GLDashingCircleEffect : public GrGeometryProcessor::ProgramImpl {
public:
GLDashingCircleEffect();
@ -881,7 +881,7 @@ private:
SkScalar fPrevCenterX;
SkScalar fPrevIntervalLength;
using INHERITED = GrGLSLGeometryProcessor;
using INHERITED = ProgramImpl;
};
GLDashingCircleEffect::GLDashingCircleEffect() {
@ -985,8 +985,9 @@ void DashingCircleEffect::addToKey(const GrShaderCaps& caps, GrProcessorKeyBuild
GLDashingCircleEffect::GenKey(*this, caps, b);
}
GrGLSLGeometryProcessor* DashingCircleEffect::createGLSLInstance(const GrShaderCaps&) const {
return new GLDashingCircleEffect();
std::unique_ptr<GrGeometryProcessor::ProgramImpl> DashingCircleEffect::makeProgramImpl(
const GrShaderCaps&) const {
return std::make_unique<GLDashingCircleEffect>();
}
DashingCircleEffect::DashingCircleEffect(const SkPMColor4f& color,
@ -1054,7 +1055,7 @@ public:
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override;
private:
friend class GLDashingLineEffect;
@ -1078,7 +1079,7 @@ private:
//////////////////////////////////////////////////////////////////////////////
class GLDashingLineEffect : public GrGLSLGeometryProcessor {
class GLDashingLineEffect : public GrGeometryProcessor::ProgramImpl {
public:
GLDashingLineEffect();
@ -1099,7 +1100,7 @@ private:
SkMatrix fLocalMatrix;
UniformHandle fLocalMatrixUniform;
using INHERITED = GrGLSLGeometryProcessor;
using INHERITED = ProgramImpl;
};
GLDashingLineEffect::GLDashingLineEffect() : fColor(SK_PMColor4fILLEGAL) {}
@ -1223,8 +1224,9 @@ void DashingLineEffect::addToKey(const GrShaderCaps& caps, GrProcessorKeyBuilder
GLDashingLineEffect::GenKey(*this, caps, b);
}
GrGLSLGeometryProcessor* DashingLineEffect::createGLSLInstance(const GrShaderCaps&) const {
return new GLDashingLineEffect();
std::unique_ptr<GrGeometryProcessor::ProgramImpl> DashingLineEffect::makeProgramImpl(
const GrShaderCaps&) const {
return std::make_unique<GLDashingLineEffect>();
}
DashingLineEffect::DashingLineEffect(const SkPMColor4f& color,

View File

@ -54,7 +54,7 @@ private:
fAtlasHelper->getKeyBits(b);
}
const TextureSampler& onTextureSampler(int) const override { return fAtlasAccess; }
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override;
const bool fUsesLocalCoords;
const GrAtlasInstancedHelper* const fAtlasHelper;
@ -65,7 +65,7 @@ private:
class Impl;
};
class DrawAtlasPathShader::Impl : public GrGLSLGeometryProcessor {
class DrawAtlasPathShader::Impl : public ProgramImpl {
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
const auto& shader = args.fGeomProc.cast<DrawAtlasPathShader>();
args.fVaryingHandler->emitAttributes(shader);
@ -107,8 +107,9 @@ class DrawAtlasPathShader::Impl : public GrGLSLGeometryProcessor {
GrGLSLUniformHandler::UniformHandle fAtlasAdjustUniform;
};
GrGLSLGeometryProcessor* DrawAtlasPathShader::createGLSLInstance(const GrShaderCaps&) const {
return new Impl();
std::unique_ptr<GrGeometryProcessor::ProgramImpl> DrawAtlasPathShader::makeProgramImpl(
const GrShaderCaps&) const {
return std::make_unique<Impl>();
}
} // namespace

View File

@ -60,7 +60,7 @@ public:
const Attribute& colorAttr() const { return fAttributes[kColorIndex]; }
const Attribute& localCoordsAttr() const { return fAttributes[kLocalCoordsIndex]; }
class GLSLProcessor : public GrGLSLGeometryProcessor {
class GLSLProcessor : public ProgramImpl {
public:
GLSLProcessor()
: fViewMatrix(SkMatrix::InvalidMatrix())
@ -154,15 +154,15 @@ public:
UniformHandle fColorUniform;
GrGLSLColorSpaceXformHelper fColorSpaceHelper;
using INHERITED = GrGLSLGeometryProcessor;
using INHERITED = ProgramImpl;
};
void addToKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GLSLProcessor::GenKey(*this, caps, b);
}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override {
return new GLSLProcessor();
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override {
return std::make_unique<GLSLProcessor>();
}
private:

View File

@ -343,7 +343,7 @@ public:
b->addBits(kNumProcessorFlags, (uint32_t)fFlags, "flags");
}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const final;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const final;
private:
Processor(GrAAType aaType, ProcessorFlags flags)
@ -568,7 +568,7 @@ void FillRRectOp::onPrepareDraws(GrMeshDrawTarget* target) {
gVertexBufferKey);
}
class FillRRectOp::Processor::Impl : public GrGLSLGeometryProcessor {
class FillRRectOp::Processor::Impl : public ProgramImpl {
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
GrGLSLVertexBuilder* v = args.fVertBuilder;
GrGLSLFPFragmentBuilder* f = args.fFragBuilder;
@ -759,9 +759,9 @@ class FillRRectOp::Processor::Impl : public GrGLSLGeometryProcessor {
const GrGeometryProcessor&) override {}
};
GrGLSLGeometryProcessor* FillRRectOp::Processor::createGLSLInstance(const GrShaderCaps&) const {
return new Impl();
std::unique_ptr<GrGeometryProcessor::ProgramImpl> FillRRectOp::Processor::makeProgramImpl(
const GrShaderCaps&) const {
return std::make_unique<Impl>();
}
void FillRRectOp::onCreateProgramInfo(const GrCaps* caps,

View File

@ -45,8 +45,8 @@ public:
b->add32(GrColorSpaceXform::XformKey(fColorSpaceXform.get()));
}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps& caps) const override {
class GLSLProcessor : public GrGLSLGeometryProcessor {
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override {
class GLSLProcessor : public ProgramImpl {
public:
void setData(const GrGLSLProgramDataManager& pdman,
const GrShaderCaps&,
@ -88,7 +88,7 @@ public:
}
GrGLSLColorSpaceXformHelper fColorSpaceXformHelper;
};
return new GLSLProcessor;
return std::make_unique<GLSLProcessor>();
}
private:

View File

@ -79,8 +79,8 @@ public:
GLSLProcessor::GenKey(*this, caps, b);
}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override {
return new GLSLProcessor();
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override {
return std::make_unique<GLSLProcessor>();
}
private:
@ -111,7 +111,7 @@ private:
this->setVertexAttributes(&fInPosition, 7);
}
class GLSLProcessor : public GrGLSLGeometryProcessor {
class GLSLProcessor : public ProgramImpl {
public:
GLSLProcessor() {}
@ -232,7 +232,7 @@ private:
}
private:
using INHERITED = GrGLSLGeometryProcessor;
using INHERITED = ProgramImpl;
SkMatrix fLocalMatrix = SkMatrix::InvalidMatrix();
UniformHandle fLocalMatrixUniform;
@ -288,8 +288,8 @@ public:
GLSLProcessor::GenKey(*this, caps, b);
}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override {
return new GLSLProcessor();
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override {
return std::make_unique<GLSLProcessor>();
}
private:
@ -303,7 +303,7 @@ private:
this->setVertexAttributes(&fInPosition, 4);
}
class GLSLProcessor : public GrGLSLGeometryProcessor {
class GLSLProcessor : public ProgramImpl {
public:
GLSLProcessor() {}
@ -501,7 +501,7 @@ private:
}
private:
using INHERITED = GrGLSLGeometryProcessor;
using INHERITED = ProgramImpl;
SkMatrix fLocalMatrix = SkMatrix::InvalidMatrix();
UniformHandle fLocalMatrixUniform;
@ -553,8 +553,8 @@ public:
GLSLProcessor::GenKey(*this, caps, b);
}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override {
return new GLSLProcessor();
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override {
return std::make_unique<GLSLProcessor>();
}
private:
@ -575,7 +575,7 @@ private:
this->setVertexAttributes(&fInPosition, 4);
}
class GLSLProcessor : public GrGLSLGeometryProcessor {
class GLSLProcessor : public ProgramImpl {
public:
GLSLProcessor() {}
@ -697,7 +697,7 @@ private:
}
private:
using INHERITED = GrGLSLGeometryProcessor;
using INHERITED = ProgramImpl;
SkMatrix fLocalMatrix = SkMatrix::InvalidMatrix();
UniformHandle fLocalMatrixUniform;
@ -759,8 +759,8 @@ public:
GLSLProcessor::GenKey(*this, caps, b);
}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override {
return new GLSLProcessor();
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override {
return std::make_unique<GLSLProcessor>();
}
private:
@ -783,7 +783,7 @@ private:
this->setVertexAttributes(&fInPosition, 4);
}
class GLSLProcessor : public GrGLSLGeometryProcessor {
class GLSLProcessor : public ProgramImpl {
public:
GLSLProcessor() : fViewMatrix(SkMatrix::InvalidMatrix()) {}
@ -900,10 +900,9 @@ private:
SkMatrix fViewMatrix;
UniformHandle fViewMatrixUniform;
using INHERITED = GrGLSLGeometryProcessor;
using INHERITED = ProgramImpl;
};
Attribute fInPosition;
Attribute fInColor;
Attribute fInEllipseOffsets0;

View File

@ -602,8 +602,8 @@ public:
b->add32(GrColorSpaceXform::XformKey(fTextureColorSpaceXform.get()), "colorSpaceXform");
}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps& caps) const override {
class GLSLProcessor : public GrGLSLGeometryProcessor {
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override {
class GLSLProcessor : public ProgramImpl {
public:
void setData(const GrGLSLProgramDataManager& pdman,
const GrShaderCaps&,
@ -762,7 +762,7 @@ public:
}
GrGLSLColorSpaceXformHelper fTextureColorSpaceXformHelper;
};
return new GLSLProcessor;
return std::make_unique<GLSLProcessor>();
}
private:

View File

@ -50,13 +50,14 @@ public:
private:
const char* name() const final { return "tessellate_HullShader"; }
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const final {}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const final;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const final;
constexpr static int kMaxInstanceAttribCount = 3;
SkSTArray<kMaxInstanceAttribCount, Attribute> fInstanceAttribs;
};
GrGLSLGeometryProcessor* HullShader::createGLSLInstance(const GrShaderCaps&) const {
std::unique_ptr<GrGeometryProcessor::ProgramImpl> HullShader::makeProgramImpl(
const GrShaderCaps&) const {
class Impl : public GrPathTessellationShader::Impl {
void emitVertexCode(const GrShaderCaps& shaderCaps, const GrPathTessellationShader&,
GrGLSLVertexBuilder* v, GrGPArgs* gpArgs) override {
@ -156,7 +157,7 @@ GrGLSLGeometryProcessor* HullShader::createGLSLInstance(const GrShaderCaps&) con
gpArgs->fPositionVar.set(kFloat2_GrSLType, "vertexpos");
}
};
return new Impl;
return std::make_unique<Impl>();
}
} // namespace

View File

@ -49,13 +49,14 @@ public:
private:
const char* name() const final { return "tessellate_BoundingBoxShader"; }
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const final {}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const final;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const final;
const SkPMColor4f fColor;
};
GrGLSLGeometryProcessor* BoundingBoxShader::createGLSLInstance(const GrShaderCaps&) const {
class Impl : public GrGLSLGeometryProcessor {
std::unique_ptr<GrGeometryProcessor::ProgramImpl> BoundingBoxShader::makeProgramImpl(
const GrShaderCaps&) const {
class Impl : public ProgramImpl {
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) final {
args.fVaryingHandler->emitAttributes(args.fGeomProc);
@ -94,7 +95,7 @@ GrGLSLGeometryProcessor* BoundingBoxShader::createGLSLInstance(const GrShaderCap
GrGLSLUniformHandler::UniformHandle fColorUniform;
};
return new Impl;
return std::make_unique<Impl>();
}
} // namespace

View File

@ -28,10 +28,11 @@ public:
private:
const char* name() const final { return "tessellate_SimpleTriangleShader"; }
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const final {}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const final;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const final;
};
GrGLSLGeometryProcessor* SimpleTriangleShader::createGLSLInstance(const GrShaderCaps&) const {
std::unique_ptr<GrGeometryProcessor::ProgramImpl> SimpleTriangleShader::makeProgramImpl(
const GrShaderCaps&) const {
class Impl : public GrPathTessellationShader::Impl {
void emitVertexCode(const GrShaderCaps&, const GrPathTessellationShader&,
GrGLSLVertexBuilder* v, GrGPArgs* gpArgs) override {
@ -42,7 +43,7 @@ GrGLSLGeometryProcessor* SimpleTriangleShader::createGLSLInstance(const GrShader
gpArgs->fPositionVar.set(kFloat2_GrSLType, "vertexpos");
}
};
return new Impl;
return std::make_unique<Impl>();
}
} // namespace

View File

@ -169,7 +169,7 @@ protected:
}
// Default path tessellation shader implementation that manages a uniform matrix and color.
class Impl : public GrGLSLGeometryProcessor {
class Impl : public ProgramImpl {
public:
void onEmitCode(EmitArgs&, GrGPArgs*) final;
void setData(const GrGLSLProgramDataManager&, const GrShaderCaps&,

View File

@ -41,10 +41,11 @@ public:
private:
const char* name() const final { return "tessellate_HardwareWedgeShader"; }
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const final {}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const final;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const final;
};
GrGLSLGeometryProcessor* HardwareWedgeShader::createGLSLInstance(const GrShaderCaps&) const {
std::unique_ptr<GrGeometryProcessor::ProgramImpl> HardwareWedgeShader::makeProgramImpl(
const GrShaderCaps&) const {
class Impl : public GrPathTessellationShader::Impl {
void emitVertexCode(const GrShaderCaps&, const GrPathTessellationShader&,
GrGLSLVertexBuilder* v, GrGPArgs*) override {
@ -150,7 +151,7 @@ GrGLSLGeometryProcessor* HardwareWedgeShader::createGLSLInstance(const GrShaderC
return code;
}
};
return new Impl;
return std::make_unique<Impl>();
}
// Uses GPU tessellation shaders to linearize, triangulate, and render standalone closed cubics.
@ -168,10 +169,11 @@ public:
private:
const char* name() const final { return "tessellate_HardwareCurveShader"; }
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const final {}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const final;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const final;
};
GrGLSLGeometryProcessor* HardwareCurveShader::createGLSLInstance(const GrShaderCaps&) const {
std::unique_ptr<GrGeometryProcessor::ProgramImpl> HardwareCurveShader::makeProgramImpl(
const GrShaderCaps&) const {
class Impl : public GrPathTessellationShader::Impl {
void emitVertexCode(const GrShaderCaps&, const GrPathTessellationShader&,
GrGLSLVertexBuilder* v, GrGPArgs*) override {
@ -305,7 +307,7 @@ GrGLSLGeometryProcessor* HardwareCurveShader::createGLSLInstance(const GrShaderC
return code;
}
};
return new Impl;
return std::make_unique<Impl>();
}
} // namespace

View File

@ -56,14 +56,15 @@ private:
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const final {
b->add32((uint32_t)fPatchType);
}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const final;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const final;
const PatchType fPatchType;
constexpr static int kMaxInstanceAttribCount = 4;
SkSTArray<kMaxInstanceAttribCount, Attribute> fInstanceAttribs;
};
GrGLSLGeometryProcessor* MiddleOutShader::createGLSLInstance(const GrShaderCaps&) const {
std::unique_ptr<GrGeometryProcessor::ProgramImpl> MiddleOutShader::makeProgramImpl(
const GrShaderCaps&) const {
class Impl : public GrPathTessellationShader::Impl {
void emitVertexCode(const GrShaderCaps& shaderCaps, const GrPathTessellationShader& shader,
GrGLSLVertexBuilder* v, GrGPArgs* gpArgs) override {
@ -167,7 +168,7 @@ GrGLSLGeometryProcessor* MiddleOutShader::createGLSLInstance(const GrShaderCaps&
gpArgs->fPositionVar.set(kFloat2_GrSLType, "vertexpos");
}
};
return new Impl;
return std::make_unique<Impl>();
}
} // namespace

View File

@ -403,13 +403,14 @@ void GrStrokeTessellationShader::addToKey(const GrShaderCaps&, GrProcessorKeyBui
b->add32(key);
}
GrGLSLGeometryProcessor* GrStrokeTessellationShader::createGLSLInstance(const GrShaderCaps&) const {
std::unique_ptr<GrGeometryProcessor::ProgramImpl> GrStrokeTessellationShader::makeProgramImpl(
const GrShaderCaps&) const {
switch (fMode) {
case Mode::kHardwareTessellation:
return new HardwareImpl;
return std::make_unique<HardwareImpl>();
case Mode::kLog2Indirect:
case Mode::kFixedCount:
return new InstancedImpl;
return std::make_unique<InstancedImpl>();
}
SkUNREACHABLE;
}

View File

@ -134,7 +134,7 @@ private:
SkUNREACHABLE;
}
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const final;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const final;
const Mode fMode;
const ShaderFlags fShaderFlags;
@ -158,7 +158,7 @@ GR_MAKE_BITFIELD_CLASS_OPS(GrStrokeTessellationShader::ShaderFlags)
// This common base class emits shader code for our parametric/radial stroke tessellation algorithm
// described above. The subclass emits its own specific setup code before calling into
// emitTessellationCode and emitFragment code.
class GrStrokeTessellationShader::Impl : public GrGLSLGeometryProcessor {
class GrStrokeTessellationShader::Impl : public ProgramImpl {
protected:
// float cosine_between_vectors(float2 a, float2 b) { ...
//

View File

@ -28,21 +28,21 @@
#include "src/gpu/vk/GrVkTexture.h"
GrVkPipelineState::GrVkPipelineState(
GrVkGpu* gpu,
sk_sp<const GrVkPipeline> pipeline,
const GrVkDescriptorSetManager::Handle& samplerDSHandle,
const GrGLSLBuiltinUniformHandles& builtinUniformHandles,
const UniformInfoArray& uniforms,
uint32_t uniformSize,
bool usePushConstants,
const UniformInfoArray& samplers,
std::unique_ptr<GrGLSLGeometryProcessor> geometryProcessor,
std::unique_ptr<GrGLSLXferProcessor> xferProcessor,
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fpImpls)
GrVkGpu* gpu,
sk_sp<const GrVkPipeline> pipeline,
const GrVkDescriptorSetManager::Handle& samplerDSHandle,
const GrGLSLBuiltinUniformHandles& builtinUniformHandles,
const UniformInfoArray& uniforms,
uint32_t uniformSize,
bool usePushConstants,
const UniformInfoArray& samplers,
std::unique_ptr<GrGeometryProcessor::ProgramImpl> gpImpl,
std::unique_ptr<GrGLSLXferProcessor> xferProcessor,
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fpImpls)
: fPipeline(std::move(pipeline))
, fSamplerDSHandle(samplerDSHandle)
, fBuiltinUniformHandles(builtinUniformHandles)
, fGeometryProcessor(std::move(geometryProcessor))
, fGPImpl(std::move(gpImpl))
, fXferProcessor(std::move(xferProcessor))
, fFPImpls(std::move(fpImpls))
, fDataManager(uniforms, uniformSize, usePushConstants) {
@ -79,7 +79,7 @@ bool GrVkPipelineState::setAndBindUniforms(GrVkGpu* gpu,
GrVkCommandBuffer* commandBuffer) {
this->setRenderTargetState(colorAttachmentDimensions, programInfo.origin());
fGeometryProcessor->setData(fDataManager, *gpu->caps()->shaderCaps(), programInfo.geomProc());
fGPImpl->setData(fDataManager, *gpu->caps()->shaderCaps(), programInfo.geomProc());
for (int i = 0; i < programInfo.pipeline().numFragmentProcessors(); ++i) {
const auto& fp = programInfo.pipeline().getFragmentProcessor(i);

View File

@ -38,18 +38,17 @@ public:
using UniformInfoArray = GrVkPipelineStateDataManager::UniformInfoArray;
using UniformHandle = GrGLSLProgramDataManager::UniformHandle;
GrVkPipelineState(
GrVkGpu*,
sk_sp<const GrVkPipeline>,
const GrVkDescriptorSetManager::Handle& samplerDSHandle,
const GrGLSLBuiltinUniformHandles& builtinUniformHandles,
const UniformInfoArray& uniforms,
uint32_t uniformSize,
bool usePushConstants,
const UniformInfoArray& samplers,
std::unique_ptr<GrGLSLGeometryProcessor>,
std::unique_ptr<GrGLSLXferProcessor>,
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fpImpls);
GrVkPipelineState(GrVkGpu*,
sk_sp<const GrVkPipeline>,
const GrVkDescriptorSetManager::Handle& samplerDSHandle,
const GrGLSLBuiltinUniformHandles& builtinUniformHandles,
const UniformInfoArray& uniforms,
uint32_t uniformSize,
bool usePushConstants,
const UniformInfoArray& samplers,
std::unique_ptr<GrGeometryProcessor::ProgramImpl>,
std::unique_ptr<GrGLSLXferProcessor>,
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fpImpls);
~GrVkPipelineState();
@ -105,8 +104,8 @@ private:
GrGLSLBuiltinUniformHandles fBuiltinUniformHandles;
// Processors in the GrVkPipelineState
std::unique_ptr<GrGLSLGeometryProcessor> fGeometryProcessor;
std::unique_ptr<GrGLSLXferProcessor> fXferProcessor;
std::unique_ptr<GrGeometryProcessor::ProgramImpl> fGPImpl;
std::unique_ptr<GrGLSLXferProcessor> fXferProcessor;
std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fFPImpls;
GrVkPipelineStateDataManager fDataManager;

View File

@ -379,7 +379,7 @@ GrVkPipelineState* GrVkPipelineStateBuilder::finalize(const GrProgramDesc& desc,
fUniformHandler.currentOffset(),
fUniformHandler.usePushConstants(),
fUniformHandler.fSamplers,
std::move(fGeometryProcessor),
std::move(fGPImpl),
std::move(fXferProcessor),
std::move(fFPImpls));
}

View File

@ -461,7 +461,7 @@ public:
b->add32(fVertexPosition.isInitialized());
}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const final;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const final;
private:
friend class GLSLMeshTestProcessor;
@ -492,7 +492,7 @@ private:
using INHERITED = GrGeometryProcessor;
};
class GLSLMeshTestProcessor : public GrGLSLGeometryProcessor {
class GLSLMeshTestProcessor : public GrGeometryProcessor::ProgramImpl {
void setData(const GrGLSLProgramDataManager&,
const GrShaderCaps&,
const GrGeometryProcessor&) final {}
@ -524,8 +524,9 @@ class GLSLMeshTestProcessor : public GrGLSLGeometryProcessor {
}
};
GrGLSLGeometryProcessor* GrMeshTestProcessor::createGLSLInstance(const GrShaderCaps&) const {
return new GLSLMeshTestProcessor;
std::unique_ptr<GrGeometryProcessor::ProgramImpl> GrMeshTestProcessor::makeProgramImpl(
const GrShaderCaps&) const {
return std::make_unique<GLSLMeshTestProcessor>();
}
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -68,7 +68,7 @@ public:
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const final {}
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const final;
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const final;
const Attribute& inVertex() const { return kAttributes[0]; }
const Attribute& inColor() const { return kAttributes[1]; }
@ -89,7 +89,7 @@ private:
};
constexpr GrGeometryProcessor::Attribute GrPipelineDynamicStateTestProcessor::kAttributes[];
class GLSLPipelineDynamicStateTestProcessor : public GrGLSLGeometryProcessor {
class GLSLPipelineDynamicStateTestProcessor : public GrGeometryProcessor::ProgramImpl {
void setData(const GrGLSLProgramDataManager&,
const GrShaderCaps&,
const GrGeometryProcessor&) final {}
@ -111,9 +111,9 @@ class GLSLPipelineDynamicStateTestProcessor : public GrGLSLGeometryProcessor {
}
};
GrGLSLGeometryProcessor*
GrPipelineDynamicStateTestProcessor::createGLSLInstance(const GrShaderCaps&) const {
return new GLSLPipelineDynamicStateTestProcessor;
std::unique_ptr<GrGeometryProcessor::ProgramImpl>
GrPipelineDynamicStateTestProcessor::makeProgramImpl(const GrShaderCaps&) const {
return std::make_unique<GLSLPipelineDynamicStateTestProcessor>();
}
class GrPipelineDynamicStateTestOp : public GrDrawOp {

View File

@ -74,8 +74,8 @@ private:
const char* name() const override { return "Test GP"; }
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const override {
class GLSLGP : public GrGLSLGeometryProcessor {
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override {
class GLSLGP : public ProgramImpl {
public:
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
const GP& gp = args.fGeomProc.cast<GP>();
@ -90,7 +90,7 @@ private:
const GrShaderCaps&,
const GrGeometryProcessor&) override {}
};
return new GLSLGP();
return std::make_unique<GLSLGP>();
}
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder* builder) const override {
builder->add32(fNumAttribs);

View File

@ -32,8 +32,8 @@ public:
const char* name() const override { return "TestRectOp::GP"; }
GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps& caps) const override {
return new GLSLGP();
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override {
return std::make_unique<GLSLGP>();
}
void addToKey(const GrShaderCaps& shaderCaps, GrProcessorKeyBuilder* b) const override {
@ -43,7 +43,7 @@ public:
bool wideColor() const { return fInColor.cpuType() != kUByte4_norm_GrVertexAttribType; }
private:
class GLSLGP : public GrGLSLGeometryProcessor {
class GLSLGP : public ProgramImpl {
public:
void setData(const GrGLSLProgramDataManager& pdman,
const GrShaderCaps& shaderCaps,