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

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

Issue 1192463003: Don't call bindTexture from GrGLProgram (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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
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 9
10 #include "gl/GrGLGeometryProcessor.h" 10 #include "gl/GrGLGeometryProcessor.h"
(...skipping 20 matching lines...) Expand all
31 GrGLNvprProgramBuilder(GrGLGpu* gpu, const DrawArgs& args) 31 GrGLNvprProgramBuilder(GrGLGpu* gpu, const DrawArgs& args)
32 : INHERITED(gpu, args) {} 32 : INHERITED(gpu, args) {}
33 33
34 GrGLProgram* createProgram(GrGLuint programID) override { 34 GrGLProgram* createProgram(GrGLuint programID) override {
35 // this is just for nvpr es, which has separable varyings that are plugg ed in after 35 // this is just for nvpr es, which has separable varyings that are plugg ed in after
36 // building 36 // building
37 GrGLPathProcessor* pathProc = 37 GrGLPathProcessor* pathProc =
38 static_cast<GrGLPathProcessor*>(fGeometryProcessor->fGLProc.get( )); 38 static_cast<GrGLPathProcessor*>(fGeometryProcessor->fGLProc.get( ));
39 pathProc->resolveSeparableVaryings(fGpu, programID); 39 pathProc->resolveSeparableVaryings(fGpu, programID);
40 return SkNEW_ARGS(GrGLNvprProgram, (fGpu, this->desc(), fUniformHandles, programID, 40 return SkNEW_ARGS(GrGLNvprProgram, (fGpu, this->desc(), fUniformHandles, programID,
41 fUniforms, 41 fUniforms, fGeometryProcessor, fXfer Processor,
42 fGeometryProcessor, 42 fFragmentProcessors.get(), &fSampler Uniforms));
43 fXferProcessor, fFragmentProcessors. get()));
44 } 43 }
45 44
46 private: 45 private:
47 typedef GrGLProgramBuilder INHERITED; 46 typedef GrGLProgramBuilder INHERITED;
48 }; 47 };
49 48
50 49
51 50
52 ////////////////////////////////////////////////////////////////////////////// 51 //////////////////////////////////////////////////////////////////////////////
53 52
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 GrGLProgramBuilder::GrGLProgramBuilder(GrGLGpu* gpu, const DrawArgs& args) 90 GrGLProgramBuilder::GrGLProgramBuilder(GrGLGpu* gpu, const DrawArgs& args)
92 : fVS(this) 91 : fVS(this)
93 , fGS(this) 92 , fGS(this)
94 , fFS(this, args.fDesc->header().fFragPosKey) 93 , fFS(this, args.fDesc->header().fFragPosKey)
95 , fOutOfStage(true) 94 , fOutOfStage(true)
96 , fStageIndex(-1) 95 , fStageIndex(-1)
97 , fGeometryProcessor(NULL) 96 , fGeometryProcessor(NULL)
98 , fXferProcessor(NULL) 97 , fXferProcessor(NULL)
99 , fArgs(args) 98 , fArgs(args)
100 , fGpu(gpu) 99 , fGpu(gpu)
101 , fUniforms(kVarsPerBlock) { 100 , fUniforms(kVarsPerBlock)
101 , fSamplerUniforms(4) {
102 } 102 }
103 103
104 void GrGLProgramBuilder::addVarying(const char* name, 104 void GrGLProgramBuilder::addVarying(const char* name,
105 GrGLVarying* varying, 105 GrGLVarying* varying,
106 GrSLPrecision fsPrecision) { 106 GrSLPrecision fsPrecision) {
107 SkASSERT(varying); 107 SkASSERT(varying);
108 if (varying->vsVarying()) { 108 if (varying->vsVarying()) {
109 fVS.addVarying(name, varying); 109 fVS.addVarying(name, varying);
110 } 110 }
111 if (this->primitiveProcessor().willUseGeoShader()) { 111 if (this->primitiveProcessor().willUseGeoShader()) {
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } 374 }
375 375
376 void GrGLProgramBuilder::verify(const GrFragmentProcessor& fp) { 376 void GrGLProgramBuilder::verify(const GrFragmentProcessor& fp) {
377 SkASSERT(fFS.hasReadFragmentPosition() == fp.willReadFragmentPosition()); 377 SkASSERT(fFS.hasReadFragmentPosition() == fp.willReadFragmentPosition());
378 } 378 }
379 379
380 template <class Proc> 380 template <class Proc>
381 void GrGLProgramBuilder::emitSamplers(const GrProcessor& processor, 381 void GrGLProgramBuilder::emitSamplers(const GrProcessor& processor,
382 GrGLProcessor::TextureSamplerArray* outSam plers, 382 GrGLProcessor::TextureSamplerArray* outSam plers,
383 GrGLInstalledProc<Proc>* ip) { 383 GrGLInstalledProc<Proc>* ip) {
384 SkDEBUGCODE(ip->fSamplersIdx = fSamplerUniforms.count();)
384 int numTextures = processor.numTextures(); 385 int numTextures = processor.numTextures();
385 ip->fSamplers.push_back_n(numTextures); 386 UniformHandle* localSamplerUniforms = fSamplerUniforms.push_back_n(numTextur es);
386 SkString name; 387 SkString name;
387 for (int t = 0; t < numTextures; ++t) { 388 for (int t = 0; t < numTextures; ++t) {
388 name.printf("Sampler%d", t); 389 name.printf("Sampler%d", t);
389 ip->fSamplers[t].fUniform = this->addUniform(GrGLProgramBuilder::kFragme nt_Visibility, 390 localSamplerUniforms[t] = this->addUniform(GrGLProgramBuilder::kFragment _Visibility,
390 kSampler2D_GrSLType, kDefau lt_GrSLPrecision, 391 kSampler2D_GrSLType, kDefault _GrSLPrecision,
391 name.c_str()); 392 name.c_str());
392 SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLProcessor::TextureSampler, 393 SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLProcessor::TextureSampler,
393 (ip->fSamplers[t].fUniform, processor.textureAcce ss(t))); 394 (localSamplerUniforms[t], processor.textureAccess (t)));
394 } 395 }
395 } 396 }
396 397
397 GrGLProgram* GrGLProgramBuilder::finalize() { 398 GrGLProgram* GrGLProgramBuilder::finalize() {
398 // verify we can get a program id 399 // verify we can get a program id
399 GrGLuint programID; 400 GrGLuint programID;
400 GL_CALL_RET(programID, CreateProgram()); 401 GL_CALL_RET(programID, CreateProgram());
401 if (0 == programID) { 402 if (0 == programID) {
402 return NULL; 403 return NULL;
403 } 404 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 cleanupShaders(shaderIDs); 492 cleanupShaders(shaderIDs);
492 } 493 }
493 void GrGLProgramBuilder::cleanupShaders(const SkTDArray<GrGLuint>& shaderIDs) { 494 void GrGLProgramBuilder::cleanupShaders(const SkTDArray<GrGLuint>& shaderIDs) {
494 for (int i = 0; i < shaderIDs.count(); ++i) { 495 for (int i = 0; i < shaderIDs.count(); ++i) {
495 GL_CALL(DeleteShader(shaderIDs[i])); 496 GL_CALL(DeleteShader(shaderIDs[i]));
496 } 497 }
497 } 498 }
498 499
499 GrGLProgram* GrGLProgramBuilder::createProgram(GrGLuint programID) { 500 GrGLProgram* GrGLProgramBuilder::createProgram(GrGLuint programID) {
500 return SkNEW_ARGS(GrGLProgram, (fGpu, this->desc(), fUniformHandles, program ID, fUniforms, 501 return SkNEW_ARGS(GrGLProgram, (fGpu, this->desc(), fUniformHandles, program ID, fUniforms,
501 fGeometryProcessor, fXferProcessor, fFragmen tProcessors.get())); 502 fGeometryProcessor, fXferProcessor, fFragmen tProcessors.get(),
503 &fSamplerUniforms));
502 } 504 }
503 505
504 //////////////////////////////////////////////////////////////////////////////// /////////////////// 506 //////////////////////////////////////////////////////////////////////////////// ///////////////////
505 507
506 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { 508 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() {
507 int numProcs = fProcs.count(); 509 int numProcs = fProcs.count();
508 for (int e = 0; e < numProcs; ++e) { 510 for (int e = 0; e < numProcs; ++e) {
509 SkDELETE(fProcs[e]); 511 SkDELETE(fProcs[e]);
510 } 512 }
511 } 513 }
OLDNEW
« src/gpu/gl/GrGLProgram.cpp ('K') | « src/gpu/gl/builders/GrGLProgramBuilder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698