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

Side by Side Diff: src/gpu/glsl/GrGLSLFragmentProcessor.cpp

Issue 1870893002: Implement texel buffers (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_texelfetch
Patch Set: GrBuffer(Access) into include/gpu Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « src/gpu/glsl/GrGLSLFragmentProcessor.h ('k') | src/gpu/glsl/GrGLSLPrimitiveProcessor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrGLSLFragmentProcessor.h" 8 #include "GrGLSLFragmentProcessor.h"
9 #include "GrFragmentProcessor.h" 9 #include "GrFragmentProcessor.h"
10 #include "GrProcessor.h" 10 #include "GrProcessor.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 * So if we're inside proc A's emitCode, and A is about to call emitCode on proc D, we want the 68 * So if we're inside proc A's emitCode, and A is about to call emitCode on proc D, we want the
69 * EmitArgs that's passed onto D to only contain its and its descendants' co ords. The 69 * EmitArgs that's passed onto D to only contain its and its descendants' co ords. The
70 * EmitArgs given to A would contain the transforms [a1,b1,b2,c1,d1,e1,e2,e3 ,f1,f2], and we want 70 * EmitArgs given to A would contain the transforms [a1,b1,b2,c1,d1,e1,e2,e3 ,f1,f2], and we want
71 * to extract the subset [d1,e1,e2,e3,f1,f2] to pass on to D. We can do this with a linear 71 * to extract the subset [d1,e1,e2,e3,f1,f2] to pass on to D. We can do this with a linear
72 * search since we know that A has 1 transform (using A.numTransformsExclChi ldren()), and B's 72 * search since we know that A has 1 transform (using A.numTransformsExclChi ldren()), and B's
73 * subtree has 3 transforms (using B.numTransforms()), so we know the start of D's transforms is 73 * subtree has 3 transforms (using B.numTransforms()), so we know the start of D's transforms is
74 * 4 after the start of A's transforms. 74 * 4 after the start of A's transforms.
75 * Textures work the same way as transforms. 75 * Textures work the same way as transforms.
76 */ 76 */
77 int firstCoordAt = args.fFp.numTransformsExclChildren(); 77 int firstCoordAt = args.fFp.numTransformsExclChildren();
78 int firstSamplerAt = args.fFp.numTexturesExclChildren(); 78 int firstTextureAt = args.fFp.numTexturesExclChildren();
79 int firstBufferAt = args.fFp.numBuffersExclChildren();
79 for (int i = 0; i < childIndex; ++i) { 80 for (int i = 0; i < childIndex; ++i) {
80 firstCoordAt += args.fFp.childProcessor(i).numTransforms(); 81 firstCoordAt += args.fFp.childProcessor(i).numTransforms();
81 firstSamplerAt += args.fFp.childProcessor(i).numTextures(); 82 firstTextureAt += args.fFp.childProcessor(i).numTextures();
83 firstBufferAt += args.fFp.childProcessor(i).numBuffers();
82 } 84 }
83 GrGLSLTransformedCoordsArray childCoords; 85 GrGLSLTransformedCoordsArray childCoords;
84 SamplerArray childTexSamplers; 86 SamplerArray childTexSamplers;
87 SamplerArray childBufferSamplers;
85 if (childProc.numTransforms() > 0) { 88 if (childProc.numTransforms() > 0) {
86 childCoords.push_back_n(childProc.numTransforms(), &args.fCoords[firstCo ordAt]); 89 childCoords.push_back_n(childProc.numTransforms(), &args.fCoords[firstCo ordAt]);
87 } 90 }
88 if (childProc.numTextures() > 0) { 91 if (childProc.numTextures() > 0) {
89 childTexSamplers.push_back_n(childProc.numTextures(), &args.fTexSamplers [firstSamplerAt]); 92 childTexSamplers.push_back_n(childProc.numTextures(), &args.fTexSamplers [firstTextureAt]);
93 }
94 if (childProc.numBuffers() > 0) {
95 childBufferSamplers.push_back_n(childProc.numBuffers(),
96 &args.fBufferSamplers[firstBufferAt]);
90 } 97 }
91 98
92 // emit the code for the child in its own scope 99 // emit the code for the child in its own scope
93 fragBuilder->codeAppend("{\n"); 100 fragBuilder->codeAppend("{\n");
94 fragBuilder->codeAppendf("// Child Index %d (mangle: %s): %s\n", childIndex, 101 fragBuilder->codeAppendf("// Child Index %d (mangle: %s): %s\n", childIndex,
95 fragBuilder->getMangleString().c_str(), childProc.n ame()); 102 fragBuilder->getMangleString().c_str(), childProc.n ame());
96 EmitArgs childArgs(fragBuilder, 103 EmitArgs childArgs(fragBuilder,
97 args.fUniformHandler, 104 args.fUniformHandler,
98 args.fGLSLCaps, 105 args.fGLSLCaps,
99 childProc, 106 childProc,
100 outputColor, 107 outputColor,
101 inputColor, 108 inputColor,
102 childCoords, 109 childCoords,
103 childTexSamplers); 110 childTexSamplers,
111 childBufferSamplers);
104 this->childProcessor(childIndex)->emitCode(childArgs); 112 this->childProcessor(childIndex)->emitCode(childArgs);
105 fragBuilder->codeAppend("}\n"); 113 fragBuilder->codeAppend("}\n");
106 114
107 fragBuilder->onAfterChildProcEmitCode(); 115 fragBuilder->onAfterChildProcEmitCode();
108 } 116 }
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLFragmentProcessor.h ('k') | src/gpu/glsl/GrGLSLPrimitiveProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698