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

Side by Side Diff: src/gpu/gl/builders/GrGLProgramBuilder.cpp

Issue 647183002: Revert of Opt state takes a GP instead of a GeometryStage (Closed) Base URL: https://skia.googlesource.com/skia.git@builder_cleanup
Patch Set: Created 6 years, 2 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/gl/builders/GrGLProgramBuilder.h ('k') | src/gpu/gl/builders/GrGLVertexShaderBuilder.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 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/GrGLGeometryProcessor.h" 9 #include "gl/GrGLGeometryProcessor.h"
10 #include "gl/GrGLProgram.h" 10 #include "gl/GrGLProgram.h"
(...skipping 14 matching lines...) Expand all
25 // ES2 FS only guarantees mediump and lowp support 25 // ES2 FS only guarantees mediump and lowp support
26 static const GrGLShaderVar::Precision kDefaultFragmentPrecision = GrGLShaderVar: :kMedium_Precision; 26 static const GrGLShaderVar::Precision kDefaultFragmentPrecision = GrGLShaderVar: :kMedium_Precision;
27 27
28 ////////////////////////////////////////////////////////////////////////////// 28 //////////////////////////////////////////////////////////////////////////////
29 29
30 const int GrGLProgramBuilder::kVarsPerBlock = 8; 30 const int GrGLProgramBuilder::kVarsPerBlock = 8;
31 31
32 GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState, 32 GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState,
33 const GrGLProgramDesc& desc, 33 const GrGLProgramDesc& desc,
34 GrGpu::DrawType drawType, 34 GrGpu::DrawType drawType,
35 const GrGeometryStage* geometryPr ocessor,
36 const GrFragmentStage* colorStage s[],
37 const GrFragmentStage* coverageSt ages[],
35 GrGpuGL* gpu) { 38 GrGpuGL* gpu) {
36 // create a builder. This will be handed off to effects so they can use it to add 39 // create a builder. This will be handed off to effects so they can use it to add
37 // uniforms, varyings, textures, etc 40 // uniforms, varyings, textures, etc
38 SkAutoTDelete<GrGLProgramBuilder> builder(CreateProgramBuilder(desc, 41 SkAutoTDelete<GrGLProgramBuilder> builder(CreateProgramBuilder(desc,
39 optState, 42 optState,
40 drawType, 43 drawType,
41 optState.hasG eometryProcessor(), 44 SkToBool(geom etryProcessor),
42 gpu)); 45 gpu));
43 46
44 GrGLProgramBuilder* pb = builder.get(); 47 GrGLProgramBuilder* pb = builder.get();
45 const GrGLProgramDesc::KeyHeader& header = pb->header(); 48 const GrGLProgramDesc::KeyHeader& header = pb->header();
46 49
47 // emit code to read the dst copy texture, if necessary 50 // emit code to read the dst copy texture, if necessary
48 if (GrGLFragmentShaderBuilder::kNoDstRead_DstReadKey != header.fDstReadKey 51 if (GrGLFragmentShaderBuilder::kNoDstRead_DstReadKey != header.fDstReadKey
49 && !gpu->glCaps().fbFetchSupport()) { 52 && !gpu->glCaps().fbFetchSupport()) {
50 pb->fFS.emitCodeToReadDstTexture(); 53 pb->fFS.emitCodeToReadDstTexture();
51 } 54 }
(...skipping 12 matching lines...) Expand all
64 pb->fVS.codeAppend("gl_PointSize = 1.0;"); 67 pb->fVS.codeAppend("gl_PointSize = 1.0;");
65 } 68 }
66 if (GrGLProgramDesc::kAttribute_ColorInput == header.fColorInput) { 69 if (GrGLProgramDesc::kAttribute_ColorInput == header.fColorInput) {
67 pb->fVS.setupBuiltinVertexAttribute("Color", &inputColor); 70 pb->fVS.setupBuiltinVertexAttribute("Color", &inputColor);
68 } 71 }
69 if (GrGLProgramDesc::kAttribute_ColorInput == header.fCoverageInput) { 72 if (GrGLProgramDesc::kAttribute_ColorInput == header.fCoverageInput) {
70 pb->fVS.setupBuiltinVertexAttribute("Coverage", &inputCoverage); 73 pb->fVS.setupBuiltinVertexAttribute("Coverage", &inputCoverage);
71 } 74 }
72 } 75 }
73 76
74 pb->emitAndInstallProcs(optState, &inputColor, &inputCoverage); 77 pb->createAndEmitProcessors(geometryProcessor, colorStages, coverageStages, &inputColor,
78 &inputCoverage);
75 79
76 if (hasVertexShader) { 80 if (hasVertexShader) {
77 pb->fVS.transformSkiaToGLCoords(); 81 pb->fVS.transformSkiaToGLCoords();
78 } 82 }
79 83
80 // write the secondary color output if necessary 84 // write the secondary color output if necessary
81 if (GrOptDrawState::kNone_SecondaryOutputType != header.fSecondaryOutputType ) { 85 if (GrOptDrawState::kNone_SecondaryOutputType != header.fSecondaryOutputType ) {
82 pb->fFS.enableSecondaryOutput(inputColor, inputCoverage); 86 pb->fFS.enableSecondaryOutput(inputColor, inputCoverage);
83 } 87 }
84 88
(...skipping 20 matching lines...) Expand all
105 GrGLPathRendering::SeparableShaders_TexturingMode); 109 GrGLPathRendering::SeparableShaders_TexturingMode);
106 SkASSERT(!hasGeometryProcessor); 110 SkASSERT(!hasGeometryProcessor);
107 return SkNEW_ARGS(GrGLNvprProgramBuilder, (gpu, optState, desc)); 111 return SkNEW_ARGS(GrGLNvprProgramBuilder, (gpu, optState, desc));
108 } else { 112 } else {
109 return SkNEW_ARGS(GrGLProgramBuilder, (gpu, optState, desc)); 113 return SkNEW_ARGS(GrGLProgramBuilder, (gpu, optState, desc));
110 } 114 }
111 } 115 }
112 116
113 ///////////////////////////////////////////////////////////////////////////// 117 /////////////////////////////////////////////////////////////////////////////
114 118
115 GrGLProgramBuilder::GrGLProgramBuilder(GrGpuGL* gpu, 119 GrGLProgramBuilder::GrGLProgramBuilder(GrGpuGL* gpu, const GrOptDrawState& optSt ate,
116 const GrOptDrawState& optState,
117 const GrGLProgramDesc& desc) 120 const GrGLProgramDesc& desc)
118 : fVS(this) 121 : fVS(this)
119 , fGS(this) 122 , fGS(this)
120 , fFS(this, desc) 123 , fFS(this, desc)
121 , fOutOfStage(true) 124 , fOutOfStage(true)
122 , fStageIndex(-1) 125 , fStageIndex(-1)
123 , fGeometryProcessor(NULL)
124 , fOptState(optState) 126 , fOptState(optState)
125 , fDesc(desc) 127 , fDesc(desc)
126 , fGpu(gpu) 128 , fGpu(gpu)
127 , fUniforms(kVarsPerBlock) { 129 , fUniforms(kVarsPerBlock) {
128 } 130 }
129 131
130 void GrGLProgramBuilder::addVarying(GrSLType type, 132 void GrGLProgramBuilder::addVarying(GrSLType type,
131 const char* name, 133 const char* name,
132 const char** vsOutName, 134 const char** vsOutName,
133 const char** fsInName, 135 const char** fsInName,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 this->addUniform(GrGLProgramBuilder::kFragment_Visibility, 218 this->addUniform(GrGLProgramBuilder::kFragment_Visibility,
217 kVec4f_GrSLType, 219 kVec4f_GrSLType,
218 "Coverage", 220 "Coverage",
219 &name); 221 &name);
220 *inputCoverage = GrGLSLExpr4(name); 222 *inputCoverage = GrGLSLExpr4(name);
221 } else if (GrGLProgramDesc::kAllOnes_ColorInput == header.fCoverageInput) { 223 } else if (GrGLProgramDesc::kAllOnes_ColorInput == header.fCoverageInput) {
222 *inputCoverage = GrGLSLExpr4(1); 224 *inputCoverage = GrGLSLExpr4(1);
223 } 225 }
224 } 226 }
225 227
226 void GrGLProgramBuilder::emitAndInstallProcs(const GrOptDrawState& optState, 228 void GrGLProgramBuilder::createAndEmitProcessors(const GrGeometryStage* geometry Processor,
227 GrGLSLExpr4* inputColor, 229 const GrFragmentStage* colorSta ges[],
228 GrGLSLExpr4* inputCoverage) { 230 const GrFragmentStage* coverage Stages[],
229 fFragmentProcessors.reset(SkNEW(GrGLInstalledFragProcs)); 231 GrGLSLExpr4* inputColor,
230 int numProcs = optState.numFragmentStages(); 232 GrGLSLExpr4* inputCoverage) {
231 this->emitAndInstallFragProcs(0, optState.numColorStages(), inputColor); 233 bool useLocalCoords = fVS.hasExplicitLocalCoords();
232 if (optState.hasGeometryProcessor()) { 234
233 const GrGeometryProcessor& gp = *optState.getGeometryProcessor(); 235 EffectKeyProvider colorKeyProvider(&fDesc, EffectKeyProvider::kColor_EffectT ype);
234 fVS.emitAttributes(gp); 236 int numColorEffects = fDesc.numColorEffects();
235 ProcKeyProvider keyProvider(&fDesc, ProcKeyProvider::kGeometry_Processor Type); 237 GrGLInstalledProcessors* ip = SkNEW_ARGS(GrGLInstalledProcessors, (numColorE ffects,
236 GrGLSLExpr4 output; 238 useLocalC oords));
237 this->emitAndInstallProc<GrGeometryProcessor>(gp, 0, keyProvider, *input Coverage, &output); 239 this->createAndEmitProcessors<GrFragmentStage>(colorStages, numColorEffects, colorKeyProvider,
238 *inputCoverage = output; 240 inputColor, ip);
241 fColorEffects.reset(ip);
242
243 if (geometryProcessor) {
244 fVS.emitAttributes(*geometryProcessor->getProcessor());
245 EffectKeyProvider gpKeyProvider(&fDesc, EffectKeyProvider::kGeometryProc essor_EffectType);
246 ip = SkNEW_ARGS(GrGLInstalledProcessors, (1, useLocalCoords));
247 this->createAndEmitProcessors<GrGeometryStage>(&geometryProcessor, 1, gp KeyProvider,
248 inputCoverage, ip);
249 fGeometryProcessor.reset(ip);
239 } 250 }
240 this->emitAndInstallFragProcs(optState.numColorStages(), numProcs, inputCov erage); 251
252 EffectKeyProvider coverageKeyProvider(&fDesc, EffectKeyProvider::kCoverage_E ffectType);
253 int numCoverageEffects = fDesc.numCoverageEffects();
254 ip = SkNEW_ARGS(GrGLInstalledProcessors, (numCoverageEffects, useLocalCoords ));
255 this->createAndEmitProcessors<GrFragmentStage>(coverageStages, numCoverageEf fects,
256 coverageKeyProvider, inputCov erage, ip);
257 fCoverageEffects.reset(ip);
241 } 258 }
242 259
243 void GrGLProgramBuilder::emitAndInstallFragProcs(int procOffset, int numProcs, G rGLSLExpr4* inOut) { 260 template <class ProcessorStage>
244 ProcKeyProvider keyProvider(&fDesc, ProcKeyProvider::kFragment_ProcessorType ); 261 void GrGLProgramBuilder::createAndEmitProcessors(const ProcessorStage* processSt ages[],
245 for (int e = procOffset; e < numProcs; ++e) { 262 int effectCnt,
246 GrGLSLExpr4 output; 263 const EffectKeyProvider& keyPro vider,
247 const GrFragmentStage& stage = fOptState.getFragmentStage(e); 264 GrGLSLExpr4* fsInOutColor,
248 this->emitAndInstallProc<GrFragmentStage>(stage, e, keyProvider, *inOut, &output); 265 GrGLInstalledProcessors* instal ledProcessors) {
249 *inOut = output; 266 bool effectEmitted = false;
267
268 GrGLSLExpr4 inColor = *fsInOutColor;
269 GrGLSLExpr4 outColor;
270
271 for (int e = 0; e < effectCnt; ++e) {
272 // Program builders have a bit of state we need to clear with each effec t
273 AutoStageAdvance adv(this);
274 const ProcessorStage& stage = *processStages[e];
275 SkASSERT(stage.getProcessor());
276
277 if (inColor.isZeros()) {
278 SkString inColorName;
279
280 // Effects have no way to communicate zeros, they treat an empty str ing as ones.
281 this->nameVariable(&inColorName, '\0', "input");
282 fFS.codeAppendf("vec4 %s = %s;", inColorName.c_str(), inColor.c_str( ));
283 inColor = inColorName;
284 }
285
286 // create var to hold stage result
287 SkString outColorName;
288 this->nameVariable(&outColorName, '\0', "output");
289 fFS.codeAppendf("vec4 %s;", outColorName.c_str());
290 outColor = outColorName;
291
292 SkASSERT(installedProcessors);
293 const typename ProcessorStage::Processor& processor = *stage.getProcesso r();
294 SkSTArray<2, GrGLProcessor::TransformedCoords> coords(processor.numTrans forms());
295 SkSTArray<4, GrGLProcessor::TextureSampler> samplers(processor.numTextur es());
296
297 this->emitTransforms(stage, &coords, installedProcessors);
298 this->emitSamplers(processor, &samplers, installedProcessors);
299
300 typename ProcessorStage::GLProcessor* glEffect =
301 processor.getFactory().createGLInstance(processor);
302 installedProcessors->addEffect(glEffect);
303
304 // Enclose custom code in a block to avoid namespace conflicts
305 SkString openBrace;
306 openBrace.printf("{ // Stage %d: %s\n", fStageIndex, glEffect->name());
307 fFS.codeAppend(openBrace.c_str());
308 fVS.codeAppend(openBrace.c_str());
309
310 glEffect->emitCode(this, processor, keyProvider.get(e), outColor.c_str() ,
311 inColor.isOnes() ? NULL : inColor.c_str(), coords, sa mplers);
312
313 // We have to check that effects and the code they emit are consistent, ie if an effect
314 // asks for dst color, then the emit code needs to follow suit
315 verify(processor);
316 fFS.codeAppend("}");
317 fVS.codeAppend("}");
318
319 inColor = outColor;
320 effectEmitted = true;
321 }
322
323 if (effectEmitted) {
324 *fsInOutColor = outColor;
250 } 325 }
251 } 326 }
252 327
253 // TODO Processors cannot output zeros because an empty string is all 1s
254 // the fix is to allow effects to take the GrGLSLExpr4 directly
255 template <class Proc>
256 void GrGLProgramBuilder::emitAndInstallProc(const Proc& proc,
257 int index,
258 const ProcKeyProvider keyProvider,
259 const GrGLSLExpr4& input,
260 GrGLSLExpr4* output) {
261 // Program builders have a bit of state we need to clear with each effect
262 AutoStageAdvance adv(this);
263
264 // create var to hold stage result
265 SkString outColorName;
266 this->nameVariable(&outColorName, '\0', "output");
267 fFS.codeAppendf("vec4 %s;", outColorName.c_str());
268 *output = outColorName;
269
270 // Enclose custom code in a block to avoid namespace conflicts
271 SkString openBrace;
272 openBrace.printf("{ // Stage %d\n", fStageIndex);
273 fFS.codeAppend(openBrace.c_str());
274
275 this->emitAndInstallProc(proc, keyProvider.get(index), output->c_str(),
276 input.isOnes() ? NULL : input.c_str());
277
278 fFS.codeAppend("}");
279 }
280
281 void GrGLProgramBuilder::emitAndInstallProc(const GrFragmentStage& fs,
282 const GrProcessorKey& key,
283 const char* outColor,
284 const char* inColor) {
285 GrGLInstalledFragProc* ifp = SkNEW_ARGS(GrGLInstalledFragProc, (fVS.hasLocal Coords()));
286
287 const GrFragmentProcessor& fp = *fs.getProcessor();
288 ifp->fGLProc = fp.getFactory().createGLInstance(fp);
289
290 SkSTArray<4, GrGLProcessor::TextureSampler> samplers(fp.numTextures());
291 this->emitSamplers(fp, &samplers, ifp);
292
293 // Fragment processors can have coord transforms
294 SkSTArray<2, GrGLProcessor::TransformedCoords> coords(fp.numTransforms());
295 this->emitTransforms(fs, &coords, ifp);
296
297 ifp->fGLProc->emitCode(this, fp, key, outColor, inColor, coords, samplers);
298
299 // We have to check that effects and the code they emit are consistent, ie i f an effect
300 // asks for dst color, then the emit code needs to follow suit
301 verify(fp);
302 fFragmentProcessors->fProcs.push_back(ifp);
303 }
304
305 void GrGLProgramBuilder::emitAndInstallProc(const GrGeometryProcessor& gp,
306 const GrProcessorKey& key,
307 const char* outColor,
308 const char* inColor) {
309 SkASSERT(!fGeometryProcessor);
310 fGeometryProcessor = SkNEW(GrGLInstalledGeoProc);
311
312 fGeometryProcessor->fGLProc = gp.getFactory().createGLInstance(gp);
313
314 SkSTArray<4, GrGLProcessor::TextureSampler> samplers(gp.numTextures());
315 this->emitSamplers(gp, &samplers, fGeometryProcessor);
316
317 SkSTArray<2, GrGLProcessor::TransformedCoords> coords;
318
319 // TODO remove coords from emit code signature, probably best to use a struc t here so these
320 // updates are less painful
321 fGeometryProcessor->fGLProc->emitCode(this, gp, key, outColor, inColor, coor ds, samplers);
322
323 // We have to check that effects and the code they emit are consistent, ie i f an effect
324 // asks for dst color, then the emit code needs to follow suit
325 verify(gp);
326 }
327
328 void GrGLProgramBuilder::verify(const GrGeometryProcessor& gp) { 328 void GrGLProgramBuilder::verify(const GrGeometryProcessor& gp) {
329 SkASSERT(fFS.hasReadFragmentPosition() == gp.willReadFragmentPosition()); 329 SkASSERT(fFS.hasReadFragmentPosition() == gp.willReadFragmentPosition());
330 } 330 }
331 331
332 void GrGLProgramBuilder::verify(const GrFragmentProcessor& fp) { 332 void GrGLProgramBuilder::verify(const GrFragmentProcessor& fp) {
333 SkASSERT(fFS.hasReadFragmentPosition() == fp.willReadFragmentPosition()); 333 SkASSERT(fFS.hasReadFragmentPosition() == fp.willReadFragmentPosition());
334 SkASSERT(fFS.hasReadDstColor() == fp.willReadDstColor()); 334 SkASSERT(fFS.hasReadDstColor() == fp.willReadDstColor());
335 } 335 }
336 336
337 void GrGLProgramBuilder::emitTransforms(const GrFragmentStage& effectStage, 337 void GrGLProgramBuilder::emitTransforms(const GrProcessorStage& effectStage,
338 GrGLProcessor::TransformedCoordsArray* o utCoords, 338 GrGLProcessor::TransformedCoordsArray* o utCoords,
339 GrGLInstalledFragProc* ifp) { 339 GrGLInstalledProcessors* installedProces sors) {
340 const GrFragmentProcessor* effect = effectStage.getProcessor(); 340 SkTArray<GrGLInstalledProcessors::Transform, true>& transforms =
341 installedProcessors->addTransforms();
342 const GrProcessor* effect = effectStage.getProcessor();
341 int numTransforms = effect->numTransforms(); 343 int numTransforms = effect->numTransforms();
342 ifp->fTransforms.push_back_n(numTransforms); 344 transforms.push_back_n(numTransforms);
343 345
344 for (int t = 0; t < numTransforms; t++) { 346 for (int t = 0; t < numTransforms; t++) {
345 const char* uniName = "StageMatrix"; 347 const char* uniName = "StageMatrix";
346 GrSLType varyingType = 348 GrSLType varyingType =
347 effectStage.isPerspectiveCoordTransform(t, fVS.hasLocalCoords()) ? 349 effectStage.isPerspectiveCoordTransform(t, fVS.hasExplicitLocalC oords()) ?
348 kVec3f_GrSLType : 350 kVec3f_GrSLType :
349 kVec2f_GrSLType; 351 kVec2f_GrSLType;
350 352
351 SkString suffixedUniName; 353 SkString suffixedUniName;
352 if (0 != t) { 354 if (0 != t) {
353 suffixedUniName.append(uniName); 355 suffixedUniName.append(uniName);
354 suffixedUniName.appendf("_%i", t); 356 suffixedUniName.appendf("_%i", t);
355 uniName = suffixedUniName.c_str(); 357 uniName = suffixedUniName.c_str();
356 } 358 }
357 ifp->fTransforms[t].fHandle = this->addUniform(GrGLProgramBuilder::kVert ex_Visibility, 359 transforms[t].fHandle = this->addUniform(GrGLProgramBuilder::kVertex_Vis ibility,
358 kMat33f_GrSLType, 360 kMat33f_GrSLType,
359 uniName, 361 uniName,
360 &uniName).toShaderBuilder Index(); 362 &uniName).toShaderBuilderIndex( );
361 363
362 const char* varyingName = "MatrixCoord"; 364 const char* varyingName = "MatrixCoord";
363 SkString suffixedVaryingName; 365 SkString suffixedVaryingName;
364 if (0 != t) { 366 if (0 != t) {
365 suffixedVaryingName.append(varyingName); 367 suffixedVaryingName.append(varyingName);
366 suffixedVaryingName.appendf("_%i", t); 368 suffixedVaryingName.appendf("_%i", t);
367 varyingName = suffixedVaryingName.c_str(); 369 varyingName = suffixedVaryingName.c_str();
368 } 370 }
369 const char* vsVaryingName; 371 const char* vsVaryingName;
370 const char* fsVaryingName; 372 const char* fsVaryingName;
(...skipping 13 matching lines...) Expand all
384 fVS.codeAppendf("%s = %s * vec3(%s, 1);", 386 fVS.codeAppendf("%s = %s * vec3(%s, 1);",
385 vsVaryingName, uniName, coords.c_str()); 387 vsVaryingName, uniName, coords.c_str());
386 } 388 }
387 SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords, 389 SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords,
388 (SkString(fsVaryingName), varyingType)); 390 (SkString(fsVaryingName), varyingType));
389 } 391 }
390 } 392 }
391 393
392 void GrGLProgramBuilder::emitSamplers(const GrProcessor& processor, 394 void GrGLProgramBuilder::emitSamplers(const GrProcessor& processor,
393 GrGLProcessor::TextureSamplerArray* outSam plers, 395 GrGLProcessor::TextureSamplerArray* outSam plers,
394 GrGLInstalledProc* ip) { 396 GrGLInstalledProcessors* installedProcesso rs) {
397 SkTArray<GrGLInstalledProcessors::Sampler, true>& samplers = installedProces sors->addSamplers();
395 int numTextures = processor.numTextures(); 398 int numTextures = processor.numTextures();
396 ip->fSamplers.push_back_n(numTextures); 399 samplers.push_back_n(numTextures);
397 SkString name; 400 SkString name;
398 for (int t = 0; t < numTextures; ++t) { 401 for (int t = 0; t < numTextures; ++t) {
399 name.printf("Sampler%d", t); 402 name.printf("Sampler%d", t);
400 ip->fSamplers[t].fUniform = this->addUniform(GrGLProgramBuilder::kFragme nt_Visibility, 403 samplers[t].fUniform = this->addUniform(GrGLProgramBuilder::kFragment_Vi sibility,
401 kSampler2D_GrSLType, 404 kSampler2D_GrSLType,
402 name.c_str()); 405 name.c_str());
403 SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLProcessor::TextureSampler, 406 SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLProcessor::TextureSampler,
404 (ip->fSamplers[t].fUniform, processor.textureAcce ss(t))); 407 (samplers[t].fUniform, processor.textureAccess(t) ));
405 } 408 }
406 } 409 }
407 410
408 GrGLProgram* GrGLProgramBuilder::finalize() { 411 GrGLProgram* GrGLProgramBuilder::finalize() {
409 // verify we can get a program id 412 // verify we can get a program id
410 GrGLuint programID; 413 GrGLuint programID;
411 GL_CALL_RET(programID, CreateProgram()); 414 GL_CALL_RET(programID, CreateProgram());
412 if (0 == programID) { 415 if (0 == programID) {
413 return NULL; 416 return NULL;
414 } 417 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 cleanupShaders(shaderIDs); 499 cleanupShaders(shaderIDs);
497 } 500 }
498 void GrGLProgramBuilder::cleanupShaders(const SkTDArray<GrGLuint>& shaderIDs) { 501 void GrGLProgramBuilder::cleanupShaders(const SkTDArray<GrGLuint>& shaderIDs) {
499 for (int i = 0; i < shaderIDs.count(); ++i) { 502 for (int i = 0; i < shaderIDs.count(); ++i) {
500 GL_CALL(DeleteShader(shaderIDs[i])); 503 GL_CALL(DeleteShader(shaderIDs[i]));
501 } 504 }
502 } 505 }
503 506
504 GrGLProgram* GrGLProgramBuilder::createProgram(GrGLuint programID) { 507 GrGLProgram* GrGLProgramBuilder::createProgram(GrGLuint programID) {
505 return SkNEW_ARGS(GrGLProgram, (fGpu, fDesc, fUniformHandles, programID, fUn iforms, 508 return SkNEW_ARGS(GrGLProgram, (fGpu, fDesc, fUniformHandles, programID, fUn iforms,
506 fGeometryProcessor, fFragmentProcessors.get( ))); 509 fGeometryProcessor, fColorEffects, fCoverage Effects));
507 } 510 }
508 511
509 //////////////////////////////////////////////////////////////////////////////// /////////////////// 512 ////////////////////////////////////////////////////////////////////////////////
510 513
511 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { 514 GrGLInstalledProcessors::~GrGLInstalledProcessors() {
512 int numProcs = fProcs.count(); 515 int numEffects = fGLProcessors.count();
513 for (int e = 0; e < numProcs; ++e) { 516 for (int e = 0; e < numEffects; ++e) {
514 SkDELETE(fProcs[e]->fGLProc); 517 SkDELETE(fGLProcessors[e]);
515 } 518 }
516 } 519 }
OLDNEW
« no previous file with comments | « src/gpu/gl/builders/GrGLProgramBuilder.h ('k') | src/gpu/gl/builders/GrGLVertexShaderBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698