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

Unified Diff: src/gpu/glsl/GrGLSLFragmentProcessor.cpp

Issue 2365943003: Stop aggregating texture/buffer access objects in GrFragmentProcessor parents. (Closed)
Patch Set: Readd base class, rebase Created 4 years, 3 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/glsl/GrGLSLFragmentProcessor.h ('k') | src/gpu/glsl/GrGLSLProgramBuilder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/glsl/GrGLSLFragmentProcessor.cpp
diff --git a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
index 82a07ca39d819a88292f9ae1710f6a779b0dd1df..5ae7fee7db09bac4d22592d6d207c64666c0a9c3 100644
--- a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
@@ -42,58 +42,13 @@ void GrGLSLFragmentProcessor::internalEmitChild(int childIndex, const char* inpu
const GrFragmentProcessor& childProc = args.fFp.childProcessor(childIndex);
- /*
- * TODO: Move textures and buffers to the iterator model used by coords.
- * We now want to find the subset of samplers that belong to the child and its descendants and
- * put that into childSamplers. To do so, we'll do a forwards linear search.
- *
- * Explanation:
- * Each GrFragmentProcessor has a copy of all the textures of itself and all procs in its
- * subtree. For example, suppose we have frag proc A, who has two children B and D. B has a
- * child C, and D has two children E and F. Each frag proc's textures array contains its own
- * textures, followed by the textures of all its descendants (i.e. preorder traversal). Suppose
- * procs A, B, C, D, E, F have 1, 2, 1, 1, 3, 2 textures respectively.
- *
- * (A)
- * [a1,b1,b2,c1,d1,e1,e2,e3,f1,f2]
- * / \
- * / \
- * (B) (D)
- * [b1,b2,c1] [d1,e1,e2,e3,f1,f2]
- * / / \
- * / / \
- * (C) (E) (F)
- * [c1] [e1,e2,e3] [f1,f2]
- *
- * So if we're inside proc A's emitCode, and A is about to call emitCode on proc D, we want the
- * EmitArgs that's passed onto D to only contain its and its descendants' textures. The
- * EmitArgs given to A would contain the textures [a1,b1,b2,c1,d1,e1,e2,e3,f1,f2], and we want
- * to extract the subset [d1,e1,e2,e3,f1,f2] to pass on to D. We can do this with a linear
- * search since we know that A has 1 texture (using A.numTexturesExclChildren()), and B's
- * subtree has 3 textures (using B.numTextures()), so we know the start of D's textures is
- * 4 after the start of A's textures.
- * Textures work the same way as textures.
- */
- int firstTextureAt = args.fFp.numTexturesExclChildren();
- int firstBufferAt = args.fFp.numBuffersExclChildren();
- for (int i = 0; i < childIndex; ++i) {
- firstTextureAt += args.fFp.childProcessor(i).numTextures();
- firstBufferAt += args.fFp.childProcessor(i).numBuffers();
- }
- const SamplerHandle* childTexSamplers = nullptr;
- const SamplerHandle* childBufferSamplers = nullptr;
- if (childProc.numTextures() > 0) {
- childTexSamplers = &args.fTexSamplers[firstTextureAt];
- }
- if (childProc.numBuffers() > 0) {
- childBufferSamplers = &args.fBufferSamplers[firstBufferAt];
- }
-
// emit the code for the child in its own scope
fragBuilder->codeAppend("{\n");
fragBuilder->codeAppendf("// Child Index %d (mangle: %s): %s\n", childIndex,
fragBuilder->getMangleString().c_str(), childProc.name());
- TransformedCoordVars coordVars = args.fTransformedCoords.childTransforms(childIndex);
+ TransformedCoordVars coordVars = args.fTransformedCoords.childInputs(childIndex);
+ TextureSamplers textureSamplers = args.fTexSamplers.childInputs(childIndex);
+ BufferSamplers bufferSamplers = args.fBufferSamplers.childInputs(childIndex);
EmitArgs childArgs(fragBuilder,
args.fUniformHandler,
args.fGLSLCaps,
@@ -101,8 +56,8 @@ void GrGLSLFragmentProcessor::internalEmitChild(int childIndex, const char* inpu
outputColor,
inputColor,
coordVars,
- childTexSamplers,
- childBufferSamplers,
+ textureSamplers,
+ bufferSamplers,
args.fGpImplementsDistanceVector);
this->childProcessor(childIndex)->emitCode(childArgs);
fragBuilder->codeAppend("}\n");
@@ -112,16 +67,14 @@ void GrGLSLFragmentProcessor::internalEmitChild(int childIndex, const char* inpu
//////////////////////////////////////////////////////////////////////////////
-using TransformedCoordVars = GrGLSLFragmentProcessor::TransformedCoordVars;
-TransformedCoordVars TransformedCoordVars::childTransforms(int childIdx) const {
- const GrFragmentProcessor* child = &fFP->childProcessor(childIdx);
- GrFragmentProcessor::Iter iter(fFP);
- int numToSkip = 0;
- while (true) {
- const GrFragmentProcessor* fp = iter.next();
- if (fp == child) {
- return TransformedCoordVars(child, fTransformedVars + numToSkip);
- }
- numToSkip += fp->numCoordTransforms();
+GrGLSLFragmentProcessor* GrGLSLFragmentProcessor::Iter::next() {
+ if (fFPStack.empty()) {
+ return nullptr;
+ }
+ GrGLSLFragmentProcessor* back = fFPStack.back();
+ fFPStack.pop_back();
+ for (int i = back->numChildProcessors() - 1; i >= 0; --i) {
+ fFPStack.push_back(back->childProcessor(i));
}
+ return back;
}
« no previous file with comments | « src/gpu/glsl/GrGLSLFragmentProcessor.h ('k') | src/gpu/glsl/GrGLSLProgramBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698