diff options
Diffstat (limited to 'src/gpu/gl')
-rw-r--r-- | src/gpu/gl/GrGLGeometryProcessor.h | 13 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProcessor.h | 23 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgram.cpp | 3 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgramDesc.cpp | 8 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLProgramBuilder.cpp | 5 |
5 files changed, 35 insertions, 17 deletions
diff --git a/src/gpu/gl/GrGLGeometryProcessor.h b/src/gpu/gl/GrGLGeometryProcessor.h index c3bee95266..a172904ac6 100644 --- a/src/gpu/gl/GrGLGeometryProcessor.h +++ b/src/gpu/gl/GrGLGeometryProcessor.h @@ -10,6 +10,7 @@ #include "GrGLProcessor.h" +class GrBatchTracker; class GrGLGPBuilder; /** @@ -25,16 +26,19 @@ public: struct EmitArgs { EmitArgs(GrGLGPBuilder* pb, const GrGeometryProcessor& gp, + const GrBatchTracker& bt, const char* outputColor, const char* outputCoverage, const TextureSamplerArray& samplers) : fPB(pb) , fGP(gp) + , fBT(bt) , fOutputColor(outputColor) , fOutputCoverage(outputCoverage) , fSamplers(samplers) {} GrGLGPBuilder* fPB; const GrGeometryProcessor& fGP; + const GrBatchTracker& fBT; const char* fOutputColor; const char* fOutputCoverage; const TextureSamplerArray& fSamplers; @@ -45,6 +49,15 @@ public: */ virtual void emitCode(const EmitArgs&) = 0; + /** A GrGLGeometryProcessor instance can be reused with any GrGLGeometryProcessor that produces + the same stage key; this function reads data from a GrGLGeometryProcessor and uploads any + uniform variables required by the shaders created in emitCode(). The GrGeometryProcessor + parameter is guaranteed to be of the same type that created this GrGLGeometryProcessor and + to have an identical processor key as the one that created this GrGLGeometryProcessor. */ + virtual void setData(const GrGLProgramDataManager&, + const GrGeometryProcessor&, + const GrBatchTracker&) = 0; + private: typedef GrGLProcessor INHERITED; }; diff --git a/src/gpu/gl/GrGLProcessor.h b/src/gpu/gl/GrGLProcessor.h index ca4fa2459f..6401e2b324 100644 --- a/src/gpu/gl/GrGLProcessor.h +++ b/src/gpu/gl/GrGLProcessor.h @@ -22,7 +22,7 @@ that their GrGLProcessors would emit the same GLSL code. The GrGLProcessor subclass must also have a constructor of the form: - EffectSubclass::EffectSubclass(const GrBackendProcessorFactory&, const GrProcessor&) + ProcessorSubclass::ProcessorSubclass(const GrBackendProcessorFactory&, const GrProcessor&) These objects are created by the factory object returned by the GrProcessor::getFactory(). */ @@ -70,13 +70,6 @@ public: virtual ~GrGLProcessor() {} - /** A GrGLProcessor instance can be reused with any GrProcessor that produces the same stage - key; this function reads data from a GrProcessor and uploads any uniform variables required - by the shaders created in emitCode(). The GrProcessor parameter is guaranteed to be of the - same type that created this GrGLProcessor and to have an identical effect key as the one - that created this GrGLProcessor. */ - virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) {} - const char* name() const { return fFactory.name(); } static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) {} @@ -100,7 +93,7 @@ public: stages. @param builder Interface used to emit code in the shaders. - @param effect The effect that generated this program stage. + @param processor The processor that generated this program stage. @param key The key that was computed by GenKey() from the generating GrProcessor. @param outputColor A predefined vec4 in the FS in which the stage should place its output color (or coverage). @@ -108,19 +101,27 @@ public: NULL in which case the implied input is solid white (all ones). TODO: Better system for communicating optimization info (e.g. input color is solid white, trans black, known to be opaque, etc.) that allows - the effect to communicate back similar known info about its output. + the processor to communicate back similar known info about its output. @param samplers Contains one entry for each GrTextureAccess of the GrProcessor. These can be passed to the builder to emit texture reads in the generated code. TODO this should take a struct */ virtual void emitCode(GrGLFPBuilder* builder, - const GrFragmentProcessor& effect, + const GrFragmentProcessor&, const char* outputColor, const char* inputColor, const TransformedCoordsArray& coords, const TextureSamplerArray& samplers) = 0; + /** A GrGLFragmentProcessor instance can be reused with any GrFragmentProcessor that produces + the same stage key; this function reads data from a GrFragmentProcessor and uploads any + uniform variables required by the shaders created in emitCode(). The GrFragmentProcessor + parameter is guaranteed to be of the same type that created this GrGLFragmentProcessor and + to have an identical processor key as the one that created this GrGLFragmentProcessor. */ + // TODO update this to pass in GrFragmentProcessor + virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) {} + private: typedef GrGLProcessor INHERITED; }; diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp index 3b04edb8c8..29c44ac56c 100644 --- a/src/gpu/gl/GrGLProgram.cpp +++ b/src/gpu/gl/GrGLProgram.cpp @@ -158,7 +158,8 @@ void GrGLProgram::setData(const GrOptDrawState& optState) { if (fGeometryProcessor.get()) { SkASSERT(optState.hasGeometryProcessor()); const GrGeometryProcessor& gp = *optState.getGeometryProcessor(); - fGeometryProcessor->fGLProc->setData(fProgramDataManager, gp); + const GrBatchTracker& bt = optState.getBatchTracker(); + fGeometryProcessor->fGLProc->setData(fProgramDataManager, gp, bt); this->bindTextures(fGeometryProcessor, gp); } this->setFragmentData(optState); diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp index f8dbbc26f9..474f7026e4 100644 --- a/src/gpu/gl/GrGLProgramDesc.cpp +++ b/src/gpu/gl/GrGLProgramDesc.cpp @@ -123,9 +123,6 @@ static bool get_meta_key(const GrProcessor& proc, uint32_t transformKey, uint32_t attribKey, GrProcessorKeyBuilder* b) { - const GrBackendProcessorFactory& factory = proc.getFactory(); - factory.getGLProcessorKey(proc, caps, b); - size_t processorKeySize = b->size(); uint32_t textureKey = gen_texture_key(proc, caps); uint32_t classID = proc.getFactory().classID(); @@ -170,6 +167,8 @@ bool GrGLProgramDescBuilder::Build(const GrOptDrawState& optState, if (optState.hasGeometryProcessor()) { const GrGeometryProcessor& gp = *optState.getGeometryProcessor(); GrProcessorKeyBuilder b(&desc->fKey); + const GrBackendGeometryProcessorFactory& factory = gp.getFactory(); + factory.getGLProcessorKey(gp, optState.getBatchTracker(), gpu->glCaps(), &b); if (!get_meta_key(gp, gpu->glCaps(), 0, gen_attrib_key(gp), &b)) { desc->fKey.reset(); return false; @@ -178,7 +177,10 @@ bool GrGLProgramDescBuilder::Build(const GrOptDrawState& optState, for (int s = 0; s < optState.numFragmentStages(); ++s) { const GrPendingFragmentStage& fps = optState.getFragmentStage(s); + const GrFragmentProcessor& fp = *fps.getProcessor(); GrProcessorKeyBuilder b(&desc->fKey); + const GrBackendFragmentProcessorFactory& factory = fp.getFactory(); + factory.getGLProcessorKey(fp, gpu->glCaps(), &b); if (!get_meta_key(*fps.getProcessor(), gpu->glCaps(), gen_transform_key(fps, requiresLocalCoordAttrib), 0, &b)) { desc->fKey.reset(); diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp index aa9e40c3f2..2f4329ae04 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -359,12 +359,13 @@ void GrGLProgramBuilder::emitAndInstallProc(const GrGeometryProcessor& gp, SkASSERT(!fGeometryProcessor); fGeometryProcessor = SkNEW(GrGLInstalledGeoProc); - fGeometryProcessor->fGLProc.reset(gp.getFactory().createGLInstance(gp)); + const GrBatchTracker& bt = fOptState.getBatchTracker(); + fGeometryProcessor->fGLProc.reset(gp.getFactory().createGLInstance(gp, bt)); SkSTArray<4, GrGLProcessor::TextureSampler> samplers(gp.numTextures()); this->emitSamplers(gp, &samplers, fGeometryProcessor); - GrGLGeometryProcessor::EmitArgs args(this, gp, outColor, outCoverage, samplers); + GrGLGeometryProcessor::EmitArgs args(this, gp, bt, outColor, outCoverage, samplers); fGeometryProcessor->fGLProc->emitCode(args); // We have to check that effects and the code they emit are consistent, ie if an effect |