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

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

Issue 1266633003: Added registerChild; transforms, textures, glKey automatically handled. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 years, 5 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
« include/gpu/GrFragmentProcessor.h ('K') | « src/gpu/gl/GrGLProgramDesc.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/builders/GrGLProgramBuilder.cpp
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 9c0e7ab526f5f940e56257a9e8c15c6d542959bd..e3003b4ac6aa2c2748ad1d21ad9a5cd5c2109396 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -179,6 +179,43 @@ const GrGLContextInfo& GrGLProgramBuilder::ctxInfo() const {
return fGpu->ctxInfo();
}
+template <>
+void GrGLProgramBuilder::emitSamplers(const GrProcessor& processor,
joshualitt 2015/08/03 14:06:02 This should be GrFragmentProcessor& so it doesn't
wangyix 2015/08/03 16:12:47 Removed this function for the time being; Was disc
+ GrGLProcessor::TextureSamplerArray* outSamplers,
+ GrGLInstalledProc<GrGLFragmentProcessor>* ifp) {
+ SkDEBUGCODE(ifp->fSamplersIdx = fSamplerUniforms.count();)
+ int numTextures = processor.numTextures();
+ int samplerUniformsOffset = fSamplerUniforms.count();
+ UniformHandle* localSamplerUniforms = fSamplerUniforms.push_back_n(numTextures);
+ SkString name;
+ for (int t = 0; t < numTextures; ++t) {
+ name.printf("Sampler%d", samplerUniformsOffset + t);
+ localSamplerUniforms[t] = this->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+ kSampler2D_GrSLType, kDefault_GrSLPrecision,
+ name.c_str());
+ SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLProcessor::TextureSampler,
+ (localSamplerUniforms[t], processor.textureAccess(t)));
+ }
+
+ // recursively emit the samplers of this processor's child processors
+ const GrFragmentProcessor& fp = processor.cast<GrFragmentProcessor>();
+ for (int i = 0; i < fp.numChildProcessors(); ++i) {
+ this->emitSamplers(*fp.childProcessor(i), outSamplers, ifp);
+ }
+}
+
+void appendGrFPCoordTransforms(const GrFragmentProcessor* processor,
joshualitt 2015/08/03 14:06:02 static void append_gr_fp_coord_transforms
wangyix 2015/08/03 16:12:47 Done.
+ SkTArray<const GrCoordTransform*, true>* procCoords) {
+ // add the coord transforms of this processor
+ for (int i = 0; i < processor->numTransforms(); ++i) {
+ procCoords->push_back(&processor->coordTransform(i));
+ }
+ // recursively add the coord transforms of this processor's child processors
+ for (int i = 0; i < processor->numChildProcessors(); ++i) {
+ appendGrFPCoordTransforms(processor->childProcessor(i), procCoords);
+ }
+}
+
bool GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr4* inputCoverage) {
// First we loop over all of the installed processors and collect coord transforms. These will
// be sent to the GrGLPrimitiveProcessor in its emitCode function
@@ -189,11 +226,10 @@ bool GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr
for (int i = 0; i < this->pipeline().numFragmentStages(); i++) {
const GrFragmentProcessor* processor = this->pipeline().getFragmentStage(i).processor();
SkSTArray<2, const GrCoordTransform*, true>& procCoords = fCoordTransforms.push_back();
- for (int t = 0; t < processor->numTransforms(); t++) {
- procCoords.push_back(&processor->coordTransform(t));
- }
- totalTextures += processor->numTextures();
+ appendGrFPCoordTransforms(processor, &procCoords);
+
+ totalTextures += processor->numTexturesIncludeChildProcs();
if (totalTextures >= maxTextureUnits) {
GrCapsDebugf(fGpu->caps(), "Program would use too many texture units\n");
return false;
@@ -284,7 +320,7 @@ void GrGLProgramBuilder::emitAndInstallProc(const GrPendingFragmentStage& fs,
const GrFragmentProcessor& fp = *fs.processor();
ifp->fGLProc.reset(fp.createGLInstance());
- SkSTArray<4, GrGLProcessor::TextureSampler> samplers(fp.numTextures());
+ SkSTArray<4, GrGLProcessor::TextureSampler> samplers(fp.numTexturesIncludeChildProcs());
this->emitSamplers(fp, &samplers, ifp);
GrGLFragmentProcessor::EmitArgs args(this, fp, outColor, inColor, fOutCoords[index], samplers);
« include/gpu/GrFragmentProcessor.h ('K') | « src/gpu/gl/GrGLProgramDesc.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698