OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrGLProgramBuilder.h" | 8 #include "GrGLProgramBuilder.h" |
9 #include "gl/GrGLProgram.h" | 9 #include "gl/GrGLProgram.h" |
10 #include "gl/GrGLSLPrettyPrint.h" | 10 #include "gl/GrGLSLPrettyPrint.h" |
11 #include "gl/GrGLUniformHandle.h" | 11 #include "gl/GrGLUniformHandle.h" |
12 #include "../GrGLXferProcessor.h" | 12 #include "../GrGLXferProcessor.h" |
13 #include "../GrGLGpu.h" | 13 #include "../GrGLGpu.h" |
14 #include "GrCoordTransform.h" | 14 #include "GrCoordTransform.h" |
15 #include "GrGLLegacyNvprProgramBuilder.h" | |
16 #include "GrGLNvprProgramBuilder.h" | |
17 #include "GrGLProgramBuilder.h" | 15 #include "GrGLProgramBuilder.h" |
18 #include "GrTexture.h" | 16 #include "GrTexture.h" |
19 #include "SkRTConf.h" | 17 #include "SkRTConf.h" |
20 #include "SkTraceEvent.h" | 18 #include "SkTraceEvent.h" |
21 | 19 |
22 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) | 20 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) |
23 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X) | 21 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X) |
24 | 22 |
| 23 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 24 |
| 25 class GrGLNvprProgramBuilder : public GrGLProgramBuilder { |
| 26 public: |
| 27 GrGLNvprProgramBuilder(GrGLGpu* gpu, const GrOptDrawState& optState) |
| 28 : INHERITED(gpu, optState) {} |
| 29 |
| 30 GrGLProgram* createProgram(GrGLuint programID) SK_OVERRIDE { |
| 31 // this is just for nvpr es, which has separable varyings that are plugg
ed in after |
| 32 // building |
| 33 GrGLPathProcessor* pathProc = |
| 34 static_cast<GrGLPathProcessor*>(fGeometryProcessor->fGLProc.get(
)); |
| 35 pathProc->resolveSeparableVaryings(fGpu, programID); |
| 36 return SkNEW_ARGS(GrGLNvprProgram, (fGpu, fDesc, fUniformHandles, progra
mID, fUniforms, |
| 37 fGeometryProcessor, |
| 38 fXferProcessor, fFragmentProcessors.
get())); |
| 39 } |
| 40 |
| 41 private: |
| 42 typedef GrGLProgramBuilder INHERITED; |
| 43 }; |
| 44 |
| 45 |
| 46 |
25 ////////////////////////////////////////////////////////////////////////////// | 47 ////////////////////////////////////////////////////////////////////////////// |
26 | 48 |
27 const int GrGLProgramBuilder::kVarsPerBlock = 8; | 49 const int GrGLProgramBuilder::kVarsPerBlock = 8; |
28 | 50 |
29 GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState, G
rGLGpu* gpu) { | 51 GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState, G
rGLGpu* gpu) { |
30 // create a builder. This will be handed off to effects so they can use it
to add | 52 // create a builder. This will be handed off to effects so they can use it
to add |
31 // uniforms, varyings, textures, etc | 53 // uniforms, varyings, textures, etc |
32 SkAutoTDelete<GrGLProgramBuilder> builder(CreateProgramBuilder(optState, | 54 SkAutoTDelete<GrGLProgramBuilder> builder(CreateProgramBuilder(optState, gpu
)); |
33 optState.hasG
eometryProcessor(), | |
34 gpu)); | |
35 | 55 |
36 GrGLProgramBuilder* pb = builder.get(); | 56 GrGLProgramBuilder* pb = builder.get(); |
37 const GrGLProgramDescBuilder::GLKeyHeader& header = GrGLProgramDescBuilder::
GetHeader(pb->desc()); | 57 const GrGLProgramDescBuilder::GLKeyHeader& header = |
| 58 GrGLProgramDescBuilder::GetHeader(pb->desc()); |
38 | 59 |
39 // emit code to read the dst copy texture, if necessary | 60 // emit code to read the dst copy texture, if necessary |
40 if (GrGLFragmentShaderBuilder::kNoDstRead_DstReadKey != header.fDstReadKey &
& | 61 if (GrGLFragmentShaderBuilder::kNoDstRead_DstReadKey != header.fDstReadKey &
& |
41 !gpu->glCaps().fbFetchSupport()) { | 62 !gpu->glCaps().fbFetchSupport()) { |
42 pb->fFS.emitCodeToReadDstTexture(); | 63 pb->fFS.emitCodeToReadDstTexture(); |
43 } | 64 } |
44 | 65 |
45 // TODO: Once all stages can handle taking a float or vec4 and correctly han
dling them we can | 66 // TODO: Once all stages can handle taking a float or vec4 and correctly han
dling them we can |
46 // seed correctly here | 67 // seed correctly here |
47 GrGLSLExpr4 inputColor; | 68 GrGLSLExpr4 inputColor; |
48 GrGLSLExpr4 inputCoverage; | 69 GrGLSLExpr4 inputCoverage; |
49 | 70 |
50 pb->emitAndInstallProcs(&inputColor, &inputCoverage); | 71 pb->emitAndInstallProcs(&inputColor, &inputCoverage); |
51 | 72 |
52 return pb->finalize(); | 73 return pb->finalize(); |
53 } | 74 } |
54 | 75 |
55 GrGLProgramBuilder* GrGLProgramBuilder::CreateProgramBuilder(const GrOptDrawStat
e& optState, | 76 GrGLProgramBuilder* GrGLProgramBuilder::CreateProgramBuilder(const GrOptDrawStat
e& optState, |
56 bool hasGeometryPro
cessor, | |
57 GrGLGpu* gpu) { | 77 GrGLGpu* gpu) { |
58 const GrProgramDesc& desc = optState.programDesc(); | 78 const GrProgramDesc& desc = optState.programDesc(); |
59 if (GrGLProgramDescBuilder::GetHeader(desc).fUseNvpr) { | 79 if (GrGLProgramDescBuilder::GetHeader(desc).fUseNvpr) { |
60 SkASSERT(gpu->glCaps().pathRenderingSupport()); | 80 SkASSERT(gpu->glCaps().pathRenderingSupport()); |
61 SkASSERT(!hasGeometryProcessor); | 81 SkASSERT(!optState.hasGeometryProcessor()); |
62 if (gpu->glPathRendering()->texturingMode() == | 82 return SkNEW_ARGS(GrGLNvprProgramBuilder, (gpu, optState)); |
63 GrGLPathRendering::FixedFunction_TexturingMode) { | |
64 return SkNEW_ARGS(GrGLLegacyNvprProgramBuilder, (gpu, optState)); | |
65 } else { | |
66 return SkNEW_ARGS(GrGLNvprProgramBuilder, (gpu, optState)); | |
67 } | |
68 } else { | 83 } else { |
69 return SkNEW_ARGS(GrGLProgramBuilder, (gpu, optState)); | 84 return SkNEW_ARGS(GrGLProgramBuilder, (gpu, optState)); |
70 } | 85 } |
71 } | 86 } |
72 | 87 |
73 ///////////////////////////////////////////////////////////////////////////// | 88 ///////////////////////////////////////////////////////////////////////////// |
74 | 89 |
75 GrGLProgramBuilder::GrGLProgramBuilder(GrGLGpu* gpu, const GrOptDrawState& optSt
ate) | 90 GrGLProgramBuilder::GrGLProgramBuilder(GrGLGpu* gpu, const GrOptDrawState& optSt
ate) |
76 : fVS(this) | 91 : fVS(this) |
77 , fGS(this) | 92 , fGS(this) |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 out->append(";\n"); | 185 out->append(";\n"); |
171 } | 186 } |
172 } | 187 } |
173 } | 188 } |
174 | 189 |
175 const GrGLContextInfo& GrGLProgramBuilder::ctxInfo() const { | 190 const GrGLContextInfo& GrGLProgramBuilder::ctxInfo() const { |
176 return fGpu->ctxInfo(); | 191 return fGpu->ctxInfo(); |
177 } | 192 } |
178 | 193 |
179 void GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr
4* inputCoverage) { | 194 void GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr
4* inputCoverage) { |
180 if (fOptState.hasGeometryProcessor()) { | 195 // First we loop over all of the installed processors and collect coord tran
sforms. These will |
181 fVS.codeAppend("gl_PointSize = 1.0;"); | 196 // be sent to the GrGLPrimitiveProcessor in its emitCode function |
182 | 197 SkSTArray<8, GrGLProcessor::TransformedCoordsArray> outCoords; |
183 // Setup position | 198 for (int i = 0; i < fOptState.numFragmentStages(); i++) { |
184 // TODO it'd be possible to remove these from the vertexshader builder a
nd have them | 199 const GrFragmentProcessor* processor = fOptState.getFragmentStage(i).pro
cessor(); |
185 // be outputs from the emit call. We don't do this because emitargs is
constant. It would | 200 SkSTArray<2, const GrCoordTransform*, true>& procCoords = fCoordTransfor
ms.push_back(); |
186 // be easy to change this though | 201 for (int t = 0; t < processor->numTransforms(); t++) { |
187 fVS.codeAppendf("vec3 %s;", fVS.glPosition()); | 202 procCoords.push_back(&processor->coordTransform(t)); |
188 fVS.codeAppendf("vec2 %s;", fVS.positionCoords()); | 203 } |
189 fVS.codeAppendf("vec2 %s;", fVS.localCoords()); | |
190 | |
191 const GrGeometryProcessor& gp = *fOptState.getGeometryProcessor(); | |
192 fVS.emitAttributes(gp); | |
193 } | 204 } |
194 | 205 |
195 const GrPrimitiveProcessor& primProc = *fOptState.getPrimitiveProcessor(); | 206 const GrPrimitiveProcessor& primProc = *fOptState.getPrimitiveProcessor(); |
196 this->emitAndInstallProc(primProc, inputColor, inputCoverage); | 207 this->emitAndInstallProc(primProc, inputColor, inputCoverage); |
197 | 208 |
198 fFragmentProcessors.reset(SkNEW(GrGLInstalledFragProcs)); | 209 fFragmentProcessors.reset(SkNEW(GrGLInstalledFragProcs)); |
199 int numProcs = fOptState.numFragmentStages(); | 210 int numProcs = fOptState.numFragmentStages(); |
200 this->emitAndInstallFragProcs(0, fOptState.numColorStages(), inputColor); | 211 this->emitAndInstallFragProcs(0, fOptState.numColorStages(), inputColor); |
201 this->emitAndInstallFragProcs(fOptState.numColorStages(), numProcs, inputCo
verage); | 212 this->emitAndInstallFragProcs(fOptState.numColorStages(), numProcs, inputCo
verage); |
202 | |
203 if (fOptState.hasGeometryProcessor()) { | |
204 fVS.transformToNormalizedDeviceSpace(); | |
205 } | |
206 | |
207 this->emitAndInstallXferProc(*fOptState.getXferProcessor(), *inputColor, *in
putCoverage); | 213 this->emitAndInstallXferProc(*fOptState.getXferProcessor(), *inputColor, *in
putCoverage); |
208 } | 214 } |
209 | 215 |
210 void GrGLProgramBuilder::emitAndInstallFragProcs(int procOffset, | 216 void GrGLProgramBuilder::emitAndInstallFragProcs(int procOffset, |
211 int numProcs, | 217 int numProcs, |
212 GrGLSLExpr4* inOut) { | 218 GrGLSLExpr4* inOut) { |
213 for (int e = procOffset; e < numProcs; ++e) { | 219 for (int e = procOffset; e < numProcs; ++e) { |
214 GrGLSLExpr4 output; | 220 GrGLSLExpr4 output; |
215 const GrPendingFragmentStage& stage = fOptState.getFragmentStage(e); | 221 const GrPendingFragmentStage& stage = fOptState.getFragmentStage(e); |
216 this->emitAndInstallProc(stage, e, *inOut, &output); | 222 this->emitAndInstallProc(stage, e, *inOut, &output); |
(...skipping 23 matching lines...) Expand all Loading... |
240 GrGLSLExpr4* output) { | 246 GrGLSLExpr4* output) { |
241 // Program builders have a bit of state we need to clear with each effect | 247 // Program builders have a bit of state we need to clear with each effect |
242 AutoStageAdvance adv(this); | 248 AutoStageAdvance adv(this); |
243 this->nameExpression(output, "output"); | 249 this->nameExpression(output, "output"); |
244 | 250 |
245 // Enclose custom code in a block to avoid namespace conflicts | 251 // Enclose custom code in a block to avoid namespace conflicts |
246 SkString openBrace; | 252 SkString openBrace; |
247 openBrace.printf("{ // Stage %d, %s\n", fStageIndex, proc.name()); | 253 openBrace.printf("{ // Stage %d, %s\n", fStageIndex, proc.name()); |
248 fFS.codeAppend(openBrace.c_str()); | 254 fFS.codeAppend(openBrace.c_str()); |
249 | 255 |
250 this->emitAndInstallProc(proc, output->c_str(), input.isOnes() ? NULL : inpu
t.c_str()); | 256 this->emitAndInstallProc(proc, index, output->c_str(), input.isOnes() ? NULL
: input.c_str()); |
251 | 257 |
252 fFS.codeAppend("}"); | 258 fFS.codeAppend("}"); |
253 } | 259 } |
254 | 260 |
255 void GrGLProgramBuilder::emitAndInstallProc(const GrPrimitiveProcessor& proc, | 261 void GrGLProgramBuilder::emitAndInstallProc(const GrPrimitiveProcessor& proc, |
256 GrGLSLExpr4* outputColor, | 262 GrGLSLExpr4* outputColor, |
257 GrGLSLExpr4* outputCoverage) { | 263 GrGLSLExpr4* outputCoverage) { |
258 // Program builders have a bit of state we need to clear with each effect | 264 // Program builders have a bit of state we need to clear with each effect |
259 AutoStageAdvance adv(this); | 265 AutoStageAdvance adv(this); |
260 this->nameExpression(outputColor, "outputColor"); | 266 this->nameExpression(outputColor, "outputColor"); |
261 this->nameExpression(outputCoverage, "outputCoverage"); | 267 this->nameExpression(outputCoverage, "outputCoverage"); |
262 | 268 |
263 // Enclose custom code in a block to avoid namespace conflicts | 269 // Enclose custom code in a block to avoid namespace conflicts |
264 SkString openBrace; | 270 SkString openBrace; |
265 openBrace.printf("{ // Stage %d, %s\n", fStageIndex, proc.name()); | 271 openBrace.printf("{ // Stage %d, %s\n", fStageIndex, proc.name()); |
266 fFS.codeAppend(openBrace.c_str()); | 272 fFS.codeAppend(openBrace.c_str()); |
267 | 273 |
268 this->emitAndInstallProc(proc, outputColor->c_str(), outputCoverage->c_str()
); | 274 this->emitAndInstallProc(proc, outputColor->c_str(), outputCoverage->c_str()
); |
269 | 275 |
270 fFS.codeAppend("}"); | 276 fFS.codeAppend("}"); |
271 } | 277 } |
272 | 278 |
273 void GrGLProgramBuilder::emitAndInstallProc(const GrPendingFragmentStage& fs, | 279 void GrGLProgramBuilder::emitAndInstallProc(const GrPendingFragmentStage& fs, |
| 280 int index, |
274 const char* outColor, | 281 const char* outColor, |
275 const char* inColor) { | 282 const char* inColor) { |
276 GrGLInstalledFragProc* ifp = SkNEW(GrGLInstalledFragProc); | 283 GrGLInstalledFragProc* ifp = SkNEW(GrGLInstalledFragProc); |
277 | 284 |
278 const GrFragmentProcessor& fp = *fs.processor(); | 285 const GrFragmentProcessor& fp = *fs.processor(); |
279 ifp->fGLProc.reset(fp.createGLInstance()); | 286 ifp->fGLProc.reset(fp.createGLInstance()); |
280 | 287 |
281 SkSTArray<4, GrGLProcessor::TextureSampler> samplers(fp.numTextures()); | 288 SkSTArray<4, GrGLProcessor::TextureSampler> samplers(fp.numTextures()); |
282 this->emitSamplers(fp, &samplers, ifp); | 289 this->emitSamplers(fp, &samplers, ifp); |
283 | 290 |
284 // Fragment processors can have coord transforms | 291 ifp->fGLProc->emitCode(this, fp, outColor, inColor, fOutCoords[index], sampl
ers); |
285 SkSTArray<2, GrGLProcessor::TransformedCoords> coords(fp.numTransforms()); | |
286 this->emitTransforms(fs, &coords, ifp); | |
287 | |
288 ifp->fGLProc->emitCode(this, fp, outColor, inColor, coords, samplers); | |
289 | 292 |
290 // We have to check that effects and the code they emit are consistent, ie i
f an effect | 293 // We have to check that effects and the code they emit are consistent, ie i
f an effect |
291 // asks for dst color, then the emit code needs to follow suit | 294 // asks for dst color, then the emit code needs to follow suit |
292 verify(fp); | 295 verify(fp); |
293 fFragmentProcessors->fProcs.push_back(ifp); | 296 fFragmentProcessors->fProcs.push_back(ifp); |
294 } | 297 } |
295 | 298 |
296 void GrGLProgramBuilder::emitAndInstallProc(const GrPrimitiveProcessor& gp, | 299 void GrGLProgramBuilder::emitAndInstallProc(const GrPrimitiveProcessor& gp, |
297 const char* outColor, | 300 const char* outColor, |
298 const char* outCoverage) { | 301 const char* outCoverage) { |
299 SkASSERT(!fGeometryProcessor); | 302 SkASSERT(!fGeometryProcessor); |
300 fGeometryProcessor = SkNEW(GrGLInstalledGeoProc); | 303 fGeometryProcessor = SkNEW(GrGLInstalledGeoProc); |
301 | 304 |
302 const GrBatchTracker& bt = fOptState.getBatchTracker(); | 305 const GrBatchTracker& bt = fOptState.getBatchTracker(); |
303 fGeometryProcessor->fGLProc.reset(gp.createGLInstance(bt)); | 306 fGeometryProcessor->fGLProc.reset(gp.createGLInstance(bt, fGpu->glCaps())); |
304 | 307 |
305 SkSTArray<4, GrGLProcessor::TextureSampler> samplers(gp.numTextures()); | 308 SkSTArray<4, GrGLProcessor::TextureSampler> samplers(gp.numTextures()); |
306 this->emitSamplers(gp, &samplers, fGeometryProcessor); | 309 this->emitSamplers(gp, &samplers, fGeometryProcessor); |
307 | 310 |
308 GrGLGeometryProcessor::EmitArgs args(this, gp, bt, outColor, outCoverage, sa
mplers); | 311 GrGLGeometryProcessor::EmitArgs args(this, gp, bt, outColor, outCoverage, sa
mplers, |
| 312 fCoordTransforms, &fOutCoords); |
309 fGeometryProcessor->fGLProc->emitCode(args); | 313 fGeometryProcessor->fGLProc->emitCode(args); |
310 | 314 |
311 // We have to check that effects and the code they emit are consistent, ie i
f an effect | 315 // We have to check that effects and the code they emit are consistent, ie i
f an effect |
312 // asks for dst color, then the emit code needs to follow suit | 316 // asks for dst color, then the emit code needs to follow suit |
313 verify(gp); | 317 verify(gp); |
314 } | 318 } |
315 | 319 |
316 void GrGLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp, | 320 void GrGLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp, |
317 const GrGLSLExpr4& colorIn, | 321 const GrGLSLExpr4& colorIn, |
318 const GrGLSLExpr4& coverageIn) { | 322 const GrGLSLExpr4& coverageIn) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 // TODO: Once will readDst is only xp enable this assert and remove it from
the | 364 // TODO: Once will readDst is only xp enable this assert and remove it from
the |
361 // FragmentProcessor verify() | 365 // FragmentProcessor verify() |
362 //SkASSERT(fFS.hasReadDstColor() == xp.willReadDstColor()); | 366 //SkASSERT(fFS.hasReadDstColor() == xp.willReadDstColor()); |
363 } | 367 } |
364 | 368 |
365 void GrGLProgramBuilder::verify(const GrFragmentProcessor& fp) { | 369 void GrGLProgramBuilder::verify(const GrFragmentProcessor& fp) { |
366 SkASSERT(fFS.hasReadFragmentPosition() == fp.willReadFragmentPosition()); | 370 SkASSERT(fFS.hasReadFragmentPosition() == fp.willReadFragmentPosition()); |
367 SkASSERT(fFS.hasReadDstColor() == fp.willReadDstColor()); | 371 SkASSERT(fFS.hasReadDstColor() == fp.willReadDstColor()); |
368 } | 372 } |
369 | 373 |
370 void GrGLProgramBuilder::emitTransforms(const GrPendingFragmentStage& stage, | 374 template <class Proc> |
371 GrGLProcessor::TransformedCoordsArray* o
utCoords, | |
372 GrGLInstalledFragProc* ifp) { | |
373 const GrFragmentProcessor* processor = stage.processor(); | |
374 int numTransforms = processor->numTransforms(); | |
375 ifp->fTransforms.push_back_n(numTransforms); | |
376 | |
377 for (int t = 0; t < numTransforms; t++) { | |
378 const char* uniName = "StageMatrix"; | |
379 GrSLType varyingType; | |
380 | |
381 GrCoordSet coordType = processor->coordTransform(t).sourceCoords(); | |
382 const SkMatrix& localMatrix = fOptState.getPrimitiveProcessor()->localMa
trix(); | |
383 uint32_t type = processor->coordTransform(t).getMatrix().getType(); | |
384 if (kLocal_GrCoordSet == coordType) { | |
385 type |= localMatrix.getType(); | |
386 } | |
387 varyingType = SkToBool(SkMatrix::kPerspective_Mask & type) ? kVec3f_GrSL
Type : | |
388 kVec2f_GrSL
Type; | |
389 GrSLPrecision precision = processor->coordTransform(t).precision(); | |
390 | |
391 SkString suffixedUniName; | |
392 if (0 != t) { | |
393 suffixedUniName.append(uniName); | |
394 suffixedUniName.appendf("_%i", t); | |
395 uniName = suffixedUniName.c_str(); | |
396 } | |
397 ifp->fTransforms[t].fHandle = this->addUniform(GrGLProgramBuilder::kVert
ex_Visibility, | |
398 kMat33f_GrSLType, precisi
on, | |
399 uniName, | |
400 &uniName).toShaderBuilder
Index(); | |
401 | |
402 const char* varyingName = "MatrixCoord"; | |
403 SkString suffixedVaryingName; | |
404 if (0 != t) { | |
405 suffixedVaryingName.append(varyingName); | |
406 suffixedVaryingName.appendf("_%i", t); | |
407 varyingName = suffixedVaryingName.c_str(); | |
408 } | |
409 | |
410 GrGLVertToFrag v(varyingType); | |
411 this->addVarying(varyingName, &v, precision); | |
412 fCoordVaryings.push_back(TransformVarying(v, uniName, coordType)); | |
413 | |
414 SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyingTyp
e); | |
415 SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords, | |
416 (SkString(v.fsIn()), varyingType)); | |
417 } | |
418 } | |
419 | |
420 void GrGLProgramBuilder::emitSamplers(const GrProcessor& processor, | 375 void GrGLProgramBuilder::emitSamplers(const GrProcessor& processor, |
421 GrGLProcessor::TextureSamplerArray* outSam
plers, | 376 GrGLProcessor::TextureSamplerArray* outSam
plers, |
422 GrGLInstalledProc* ip) { | 377 GrGLInstalledProc<Proc>* ip) { |
423 int numTextures = processor.numTextures(); | 378 int numTextures = processor.numTextures(); |
424 ip->fSamplers.push_back_n(numTextures); | 379 ip->fSamplers.push_back_n(numTextures); |
425 SkString name; | 380 SkString name; |
426 for (int t = 0; t < numTextures; ++t) { | 381 for (int t = 0; t < numTextures; ++t) { |
427 name.printf("Sampler%d", t); | 382 name.printf("Sampler%d", t); |
428 ip->fSamplers[t].fUniform = this->addUniform(GrGLProgramBuilder::kFragme
nt_Visibility, | 383 ip->fSamplers[t].fUniform = this->addUniform(GrGLProgramBuilder::kFragme
nt_Visibility, |
429 kSampler2D_GrSLType, kDefau
lt_GrSLPrecision, | 384 kSampler2D_GrSLType, kDefau
lt_GrSLPrecision, |
430 name.c_str()); | 385 name.c_str()); |
431 SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLProcessor::TextureSampler, | 386 SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLProcessor::TextureSampler, |
432 (ip->fSamplers[t].fUniform, processor.textureAcce
ss(t))); | 387 (ip->fSamplers[t].fUniform, processor.textureAcce
ss(t))); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 } | 498 } |
544 | 499 |
545 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 500 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
546 | 501 |
547 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { | 502 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { |
548 int numProcs = fProcs.count(); | 503 int numProcs = fProcs.count(); |
549 for (int e = 0; e < numProcs; ++e) { | 504 for (int e = 0; e < numProcs; ++e) { |
550 SkDELETE(fProcs[e]); | 505 SkDELETE(fProcs[e]); |
551 } | 506 } |
552 } | 507 } |
OLD | NEW |