| OLD | NEW | 
|---|
| 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 "glsl/GrGLSLProgramBuilder.h" | 8 #include "glsl/GrGLSLProgramBuilder.h" | 
| 9 | 9 | 
| 10 #include "GrPipeline.h" | 10 #include "GrPipeline.h" | 
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 151     AutoStageAdvance adv(this); | 151     AutoStageAdvance adv(this); | 
| 152     this->nameExpression(output, "output"); | 152     this->nameExpression(output, "output"); | 
| 153 | 153 | 
| 154     // Enclose custom code in a block to avoid namespace conflicts | 154     // Enclose custom code in a block to avoid namespace conflicts | 
| 155     SkString openBrace; | 155     SkString openBrace; | 
| 156     openBrace.printf("{ // Stage %d, %s\n", fStageIndex, fp.name()); | 156     openBrace.printf("{ // Stage %d, %s\n", fStageIndex, fp.name()); | 
| 157     fFS.codeAppend(openBrace.c_str()); | 157     fFS.codeAppend(openBrace.c_str()); | 
| 158 | 158 | 
| 159     GrGLSLFragmentProcessor* fragProc = fp.createGLSLInstance(); | 159     GrGLSLFragmentProcessor* fragProc = fp.createGLSLInstance(); | 
| 160 | 160 | 
| 161     SkSTArray<4, SamplerHandle> texSamplers(fp.numTextures()); | 161     SkSTArray<4, SamplerHandle> textureSamplerArray(fp.numTextures()); | 
| 162     SkSTArray<2, SamplerHandle> bufferSamplers(fp.numBuffers()); | 162     SkSTArray<2, SamplerHandle> bufferSamplerArray(fp.numBuffers()); | 
| 163     this->emitSamplers(fp, &texSamplers, &bufferSamplers); | 163     GrFragmentProcessor::Iter iter(&fp); | 
|  | 164     while (const GrFragmentProcessor* subFP = iter.next()) { | 
|  | 165         this->emitSamplers(*subFP, &textureSamplerArray, &bufferSamplerArray); | 
|  | 166     } | 
| 164 | 167 | 
| 165     const GrShaderVar* coordVars = fTransformedCoordVars.begin() + transformedCo
     ordVarsIdx; | 168     const GrShaderVar* coordVars = fTransformedCoordVars.begin() + transformedCo
     ordVarsIdx; | 
| 166     GrGLSLFragmentProcessor::TransformedCoordVars coords(&fp, coordVars); | 169     GrGLSLFragmentProcessor::TransformedCoordVars coords(&fp, coordVars); | 
|  | 170     GrGLSLFragmentProcessor::TextureSamplers textureSamplers(&fp, textureSampler
     Array.begin()); | 
|  | 171     GrGLSLFragmentProcessor::BufferSamplers bufferSamplers(&fp, bufferSamplerArr
     ay.begin()); | 
| 167     GrGLSLFragmentProcessor::EmitArgs args(&fFS, | 172     GrGLSLFragmentProcessor::EmitArgs args(&fFS, | 
| 168                                            this->uniformHandler(), | 173                                            this->uniformHandler(), | 
| 169                                            this->glslCaps(), | 174                                            this->glslCaps(), | 
| 170                                            fp, | 175                                            fp, | 
| 171                                            output->c_str(), | 176                                            output->c_str(), | 
| 172                                            input.isOnes() ? nullptr : input.c_st
     r(), | 177                                            input.isOnes() ? nullptr : input.c_st
     r(), | 
| 173                                            coords, | 178                                            coords, | 
| 174                                            texSamplers.begin(), | 179                                            textureSamplers, | 
| 175                                            bufferSamplers.begin(), | 180                                            bufferSamplers, | 
| 176                                            this->primitiveProcessor().implements
     DistanceVector()); | 181                                            this->primitiveProcessor().implements
     DistanceVector()); | 
| 177 | 182 | 
| 178     fragProc->emitCode(args); | 183     fragProc->emitCode(args); | 
| 179 | 184 | 
| 180     // We have to check that effects and the code they emit are consistent, ie i
     f an effect | 185     // We have to check that effects and the code they emit are consistent, ie i
     f an effect | 
| 181     // asks for dst color, then the emit code needs to follow suit | 186     // asks for dst color, then the emit code needs to follow suit | 
| 182     SkDEBUGCODE(verify(fp);) | 187     SkDEBUGCODE(verify(fp);) | 
| 183     fFragmentProcessors.push_back(fragProc); | 188     fFragmentProcessors.push_back(fragProc); | 
| 184 | 189 | 
| 185     fFS.codeAppend("}"); | 190     fFS.codeAppend("}"); | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 241         const GrTextureAccess& access = processor.textureAccess(t); | 246         const GrTextureAccess& access = processor.textureAccess(t); | 
| 242         GrSLType samplerType = access.getTexture()->samplerType(); | 247         GrSLType samplerType = access.getTexture()->samplerType(); | 
| 243         if (kTextureExternalSampler_GrSLType == samplerType) { | 248         if (kTextureExternalSampler_GrSLType == samplerType) { | 
| 244             const char* externalFeatureString = this->glslCaps()->externalTextur
     eExtensionString(); | 249             const char* externalFeatureString = this->glslCaps()->externalTextur
     eExtensionString(); | 
| 245             // We shouldn't ever create a GrGLTexture that requires external sam
     pler type | 250             // We shouldn't ever create a GrGLTexture that requires external sam
     pler type | 
| 246             SkASSERT(externalFeatureString); | 251             SkASSERT(externalFeatureString); | 
| 247             this->addFeature(access.getVisibility(), | 252             this->addFeature(access.getVisibility(), | 
| 248                              1 << GrGLSLShaderBuilder::kExternalTexture_GLSLPriv
     ateFeature, | 253                              1 << GrGLSLShaderBuilder::kExternalTexture_GLSLPriv
     ateFeature, | 
| 249                              externalFeatureString); | 254                              externalFeatureString); | 
| 250         } | 255         } | 
| 251         name.printf("TextureSampler%d", t); | 256         name.printf("TextureSampler_%d", outTexSamplers->count()); | 
| 252         this->emitSampler(samplerType, access.getTexture()->config(), | 257         this->emitSampler(samplerType, access.getTexture()->config(), | 
| 253                           name.c_str(), access.getVisibility(), outTexSamplers); | 258                           name.c_str(), access.getVisibility(), outTexSamplers); | 
| 254     } | 259     } | 
| 255 | 260 | 
| 256     if (int numBuffers = processor.numBuffers()) { | 261     if (int numBuffers = processor.numBuffers()) { | 
| 257         SkASSERT(this->glslCaps()->texelBufferSupport()); | 262         SkASSERT(this->glslCaps()->texelBufferSupport()); | 
| 258         GrShaderFlags texelBufferVisibility = kNone_GrShaderFlags; | 263         GrShaderFlags texelBufferVisibility = kNone_GrShaderFlags; | 
| 259 | 264 | 
| 260         for (int b = 0; b < numBuffers; ++b) { | 265         for (int b = 0; b < numBuffers; ++b) { | 
| 261             const GrBufferAccess& access = processor.bufferAccess(b); | 266             const GrBufferAccess& access = processor.bufferAccess(b); | 
| 262             name.printf("BufferSampler%d", b); | 267             name.printf("BufferSampler_%d", outBufferSamplers->count()); | 
| 263             this->emitSampler(kTextureBufferSampler_GrSLType, access.texelConfig
     (), name.c_str(), | 268             this->emitSampler(kTextureBufferSampler_GrSLType, access.texelConfig
     (), name.c_str(), | 
| 264                               access.visibility(), outBufferSamplers); | 269                               access.visibility(), outBufferSamplers); | 
| 265             texelBufferVisibility |= access.visibility(); | 270             texelBufferVisibility |= access.visibility(); | 
| 266         } | 271         } | 
| 267 | 272 | 
| 268         if (const char* extension = this->glslCaps()->texelBufferExtensionString
     ()) { | 273         if (const char* extension = this->glslCaps()->texelBufferExtensionString
     ()) { | 
| 269             this->addFeature(texelBufferVisibility, | 274             this->addFeature(texelBufferVisibility, | 
| 270                              1 << GrGLSLShaderBuilder::kTexelBuffer_GLSLPrivateF
     eature, | 275                              1 << GrGLSLShaderBuilder::kTexelBuffer_GLSLPrivateF
     eature, | 
| 271                              extension); | 276                              extension); | 
| 272         } | 277         } | 
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 413     for (int i = 0; i < fFragmentProcessors.count(); ++i) { | 418     for (int i = 0; i < fFragmentProcessors.count(); ++i) { | 
| 414         delete fFragmentProcessors[i]; | 419         delete fFragmentProcessors[i]; | 
| 415     } | 420     } | 
| 416 } | 421 } | 
| 417 | 422 | 
| 418 void GrGLSLProgramBuilder::finalizeShaders() { | 423 void GrGLSLProgramBuilder::finalizeShaders() { | 
| 419     this->varyingHandler()->finalize(); | 424     this->varyingHandler()->finalize(); | 
| 420     fVS.finalize(kVertex_GrShaderFlag); | 425     fVS.finalize(kVertex_GrShaderFlag); | 
| 421     fFS.finalize(kFragment_GrShaderFlag); | 426     fFS.finalize(kFragment_GrShaderFlag); | 
| 422 } | 427 } | 
| OLD | NEW | 
|---|