Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Unified Diff: src/gpu/gl/builders/GrGLProgramBuilder.h

Issue 637003003: Opt state takes a GP instead of a GeometryStage (Closed) Base URL: https://skia.googlesource.com/skia.git@builder_cleanup
Patch Set: memory leaks fixed Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/builders/GrGLNvprProgramBuilder.cpp ('k') | src/gpu/gl/builders/GrGLProgramBuilder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/builders/GrGLProgramBuilder.h
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h
index 6141058152b88546f12bb9c2aefc29eb9c151a73..2afdd099f4322abf2246bedb0181137159808df0 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.h
@@ -13,8 +13,7 @@
#include "GrGLVertexShaderBuilder.h"
#include "../GrGLProgramDataManager.h"
#include "../GrGLUniformHandle.h"
-
-class GrGLInstalledProcessors;
+#include "../GrGLGeometryProcessor.h"
/*
* This is the base class for a series of interfaces. This base class *MUST* remain abstract with
@@ -98,6 +97,11 @@ public:
*/
};
+struct GrGLInstalledProc;
+struct GrGLInstalledGeoProc;
+struct GrGLInstalledFragProc;
+struct GrGLInstalledFragProcs;
+
/*
* Please note - no diamond problems because of virtual inheritance. Also, both base classes
* are pure virtual with no data members. This is the base class for program building.
@@ -118,9 +122,6 @@ public:
static GrGLProgram* CreateProgram(const GrOptDrawState&,
const GrGLProgramDesc&,
GrGpu::DrawType,
- const GrGeometryStage* inGeometryProcessor,
- const GrFragmentStage* inColorStages[],
- const GrFragmentStage* inCoverageStages[],
GrGpuGL* gpu);
virtual UniformHandle addUniform(uint32_t visibility,
@@ -150,11 +151,12 @@ public:
virtual GrGLFPFragmentBuilder* getFragmentShaderBuilder() SK_OVERRIDE { return &fFS; }
virtual GrGLVertexBuilder* getVertexShaderBuilder() SK_OVERRIDE { return &fVS; }
- virtual void addVarying(GrSLType type,
- const char* name,
- const char** vsOutName = NULL,
- const char** fsInName = NULL,
- GrGLShaderVar::Precision fsPrecision=GrGLShaderVar::kDefault_Precision);
+ virtual void addVarying(
+ GrSLType type,
+ const char* name,
+ const char** vsOutName = NULL,
+ const char** fsInName = NULL,
+ GrGLShaderVar::Precision fsPrecision=GrGLShaderVar::kDefault_Precision) SK_OVERRIDE;
// Handles for program uniforms (other than per-effect uniforms)
struct BuiltinUniformHandles {
@@ -174,6 +176,10 @@ public:
};
protected:
+ typedef GrGLProgramDesc::ProcKeyProvider ProcKeyProvider;
+ typedef GrGLProgramDataManager::UniformInfo UniformInfo;
+ typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray;
+
static GrGLProgramBuilder* CreateProgramBuilder(const GrGLProgramDesc&,
const GrOptDrawState&,
GrGpu::DrawType,
@@ -191,32 +197,40 @@ protected:
// generating stage code.
void nameVariable(SkString* out, char prefix, const char* name);
void setupUniformColorAndCoverageIfNeeded(GrGLSLExpr4* inputColor, GrGLSLExpr4* inputCoverage);
- void createAndEmitProcessors(const GrGeometryStage* geometryProcessor,
- const GrFragmentStage* colorStages[],
- const GrFragmentStage* coverageStages[],
- GrGLSLExpr4* inputColor,
- GrGLSLExpr4* inputCoverage);
- template <class ProcessorStage>
- void createAndEmitProcessors(const ProcessorStage*[],
- int effectCnt,
- const GrGLProgramDesc::EffectKeyProvider&,
- GrGLSLExpr4* fsInOutColor,
- GrGLInstalledProcessors*);
+ void emitAndInstallProcs(const GrOptDrawState& optState,
+ GrGLSLExpr4* inputColor,
+ GrGLSLExpr4* inputCoverage);
+ void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOut);
+ template <class Proc>
+ void emitAndInstallProc(const Proc&,
+ int index,
+ const ProcKeyProvider,
+ const GrGLSLExpr4& input,
+ GrGLSLExpr4* output);
+
+ // these emit functions help to keep the createAndEmitProcessors template general
+ void emitAndInstallProc(const GrFragmentStage&,
+ const GrProcessorKey&,
+ const char* outColor,
+ const char* inColor);
+ void emitAndInstallProc(const GrGeometryProcessor&,
+ const GrProcessorKey&,
+ const char* outColor,
+ const char* inColor);
void verify(const GrGeometryProcessor&);
void verify(const GrFragmentProcessor&);
void emitSamplers(const GrProcessor&,
GrGLProcessor::TextureSamplerArray* outSamplers,
- GrGLInstalledProcessors*);
+ GrGLInstalledProc*);
// each specific program builder has a distinct transform and must override this function
- virtual void emitTransforms(const GrProcessorStage&,
+ virtual void emitTransforms(const GrFragmentStage&,
GrGLProcessor::TransformedCoordsArray* outCoords,
- GrGLInstalledProcessors*);
+ GrGLInstalledFragProc*);
GrGLProgram* finalize();
void bindUniformLocations(GrGLuint programID);
bool checkLinkStatus(GrGLuint programID);
void resolveUniformLocations(GrGLuint programID);
-
void cleanupProgram(GrGLuint programID, const SkTDArray<GrGLuint>& shaderIDs);
void cleanupShaders(const SkTDArray<GrGLuint>& shaderIDs);
@@ -256,10 +270,6 @@ protected:
void enterStage() { fOutOfStage = false; }
int stageIndex() const { return fStageIndex; }
- typedef GrGLProgramDesc::EffectKeyProvider EffectKeyProvider;
- typedef GrGLProgramDataManager::UniformInfo UniformInfo;
- typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray;
-
// number of each input/output type in a single allocation block, used by many builders
static const int kVarsPerBlock;
@@ -270,9 +280,8 @@ protected:
bool fOutOfStage;
int fStageIndex;
- SkAutoTUnref<GrGLInstalledProcessors> fGeometryProcessor;
- SkAutoTUnref<GrGLInstalledProcessors> fColorEffects;
- SkAutoTUnref<GrGLInstalledProcessors> fCoverageEffects;
+ GrGLInstalledGeoProc* fGeometryProcessor;
+ SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors;
const GrOptDrawState& fOptState;
const GrGLProgramDesc& fDesc;
@@ -286,32 +295,26 @@ protected:
};
/**
- * This class encapsulates an array of GrGLProcessors and their supporting data (coord transforms
- * and textures). It is built by GrGLProgramBuilder, then used to manage the necessary GL
- * state and shader uniforms in GLPrograms. Its just Plain old data, and as such is entirely public
- *
- * TODO We really don't need this class to have an array of processors. It makes sense for it
- * to just have one, also break out the transforms
+ * The below structs represent processors installed in programs. All processors can have texture
+ * samplers, but only frag processors have coord transforms, hence the need for different structs
*/
-class GrGLInstalledProcessors : public SkRefCnt {
-public:
- GrGLInstalledProcessors(int reserveCount, bool hasExplicitLocalCoords = false)
- : fGLProcessors(reserveCount)
- , fSamplers(reserveCount)
- , fTransforms(reserveCount)
- , fHasExplicitLocalCoords(hasExplicitLocalCoords) {
- }
-
- virtual ~GrGLInstalledProcessors();
-
- typedef GrGLProgramDataManager::UniformHandle UniformHandle;
+struct GrGLInstalledProc {
+ typedef GrGLProgramDataManager::UniformHandle UniformHandle;
+
+ struct Sampler {
+ SkDEBUGCODE(Sampler() : fTextureUnit(-1) {})
+ UniformHandle fUniform;
+ int fTextureUnit;
+ };
+ SkSTArray<4, Sampler, true> fSamplers;
+};
- struct Sampler {
- SkDEBUGCODE(Sampler() : fTextureUnit(-1) {})
- UniformHandle fUniform;
- int fTextureUnit;
- };
+struct GrGLInstalledGeoProc : public GrGLInstalledProc {
+ SkAutoTDelete<GrGLGeometryProcessor> fGLProc;
+};
+struct GrGLInstalledFragProc : public GrGLInstalledProc {
+ GrGLInstalledFragProc(bool useLocalCoords) : fGLProc(NULL), fLocalCoordAttrib(useLocalCoords) {}
class ShaderVarHandle {
public:
bool isValid() const { return fHandle > -1; }
@@ -334,19 +337,14 @@ public:
GrSLType fType;
};
- void addEffect(GrGLProcessor* effect) { fGLProcessors.push_back(effect); }
- SkTArray<Sampler, true>& addSamplers() { return fSamplers.push_back(); }
- SkTArray<Transform, true>& addTransforms() { return fTransforms.push_back(); }
-
- SkTArray<GrGLProcessor*> fGLProcessors;
- SkTArray<SkSTArray<4, Sampler, true> > fSamplers;
- SkTArray<SkSTArray<2, Transform, true> > fTransforms;
- bool fHasExplicitLocalCoords;
+ SkAutoTDelete<GrGLFragmentProcessor> fGLProc;
+ SkSTArray<2, Transform, true> fTransforms;
+ bool fLocalCoordAttrib;
+};
- friend class GrGLShaderBuilder;
- friend class GrGLVertexShaderBuilder;
- friend class GrGLFragmentShaderBuilder;
- friend class GrGLGeometryShaderBuilder;
+struct GrGLInstalledFragProcs : public SkRefCnt {
+ virtual ~GrGLInstalledFragProcs();
+ SkSTArray<8, GrGLInstalledFragProc*, true> fProcs;
};
#endif
« no previous file with comments | « src/gpu/gl/builders/GrGLNvprProgramBuilder.cpp ('k') | src/gpu/gl/builders/GrGLProgramBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698