| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } | 220 } |
| 221 | 221 |
| 222 void GrGLSLProgramBuilder::emitSamplers(const GrProcessor& processor, | 222 void GrGLSLProgramBuilder::emitSamplers(const GrProcessor& processor, |
| 223 SkTArray<SamplerHandle>* outTexSamplers, | 223 SkTArray<SamplerHandle>* outTexSamplers, |
| 224 SkTArray<SamplerHandle>* outBufferSample
rs) { | 224 SkTArray<SamplerHandle>* outBufferSample
rs) { |
| 225 SkString name; | 225 SkString name; |
| 226 int numTextures = processor.numTextures(); | 226 int numTextures = processor.numTextures(); |
| 227 for (int t = 0; t < numTextures; ++t) { | 227 for (int t = 0; t < numTextures; ++t) { |
| 228 const GrTextureAccess& access = processor.textureAccess(t); | 228 const GrTextureAccess& access = processor.textureAccess(t); |
| 229 GrSLType samplerType = access.getTexture()->samplerType(); | 229 GrSLType samplerType = access.getTexture()->samplerType(); |
| 230 if (kSamplerExternal_GrSLType == samplerType) { | 230 if (kTextureExternalSampler_GrSLType == samplerType) { |
| 231 const char* externalFeatureString = this->glslCaps()->externalTextur
eExtensionString(); | 231 const char* externalFeatureString = this->glslCaps()->externalTextur
eExtensionString(); |
| 232 // We shouldn't ever create a GrGLTexture that requires external sam
pler type | 232 // We shouldn't ever create a GrGLTexture that requires external sam
pler type |
| 233 SkASSERT(externalFeatureString); | 233 SkASSERT(externalFeatureString); |
| 234 this->addFeature(access.getVisibility(), | 234 this->addFeature(access.getVisibility(), |
| 235 1 << GrGLSLShaderBuilder::kExternalTexture_GLSLPriv
ateFeature, | 235 1 << GrGLSLShaderBuilder::kExternalTexture_GLSLPriv
ateFeature, |
| 236 externalFeatureString); | 236 externalFeatureString); |
| 237 } | 237 } |
| 238 name.printf("TextureSampler%d", t); | 238 name.printf("TextureSampler%d", t); |
| 239 this->emitSampler(samplerType, access.getTexture()->config(), | 239 this->emitSampler(samplerType, access.getTexture()->config(), |
| 240 name.c_str(), access.getVisibility(), outTexSamplers); | 240 name.c_str(), access.getVisibility(), outTexSamplers); |
| 241 } | 241 } |
| 242 | 242 |
| 243 if (int numBuffers = processor.numBuffers()) { | 243 if (int numBuffers = processor.numBuffers()) { |
| 244 SkASSERT(this->glslCaps()->texelBufferSupport()); | 244 SkASSERT(this->glslCaps()->texelBufferSupport()); |
| 245 GrShaderFlags texelBufferVisibility = kNone_GrShaderFlags; | 245 GrShaderFlags texelBufferVisibility = kNone_GrShaderFlags; |
| 246 | 246 |
| 247 for (int b = 0; b < numBuffers; ++b) { | 247 for (int b = 0; b < numBuffers; ++b) { |
| 248 const GrBufferAccess& access = processor.bufferAccess(b); | 248 const GrBufferAccess& access = processor.bufferAccess(b); |
| 249 name.printf("BufferSampler%d", b); | 249 name.printf("BufferSampler%d", b); |
| 250 this->emitSampler(kSamplerBuffer_GrSLType, access.texelConfig(), nam
e.c_str(), | 250 this->emitSampler(kTextureBufferSampler_GrSLType, access.texelConfig
(), name.c_str(), |
| 251 access.visibility(), outBufferSamplers); | 251 access.visibility(), outBufferSamplers); |
| 252 texelBufferVisibility |= access.visibility(); | 252 texelBufferVisibility |= access.visibility(); |
| 253 } | 253 } |
| 254 | 254 |
| 255 if (const char* extension = this->glslCaps()->texelBufferExtensionString
()) { | 255 if (const char* extension = this->glslCaps()->texelBufferExtensionString
()) { |
| 256 this->addFeature(texelBufferVisibility, | 256 this->addFeature(texelBufferVisibility, |
| 257 1 << GrGLSLShaderBuilder::kTexelBuffer_GLSLPrivateF
eature, | 257 1 << GrGLSLShaderBuilder::kTexelBuffer_GLSLPrivateF
eature, |
| 258 extension); | 258 extension); |
| 259 } | 259 } |
| 260 } | 260 } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 delete fFragmentProcessors[i]; | 401 delete fFragmentProcessors[i]; |
| 402 } | 402 } |
| 403 } | 403 } |
| 404 | 404 |
| 405 void GrGLSLProgramBuilder::finalizeShaders() { | 405 void GrGLSLProgramBuilder::finalizeShaders() { |
| 406 this->varyingHandler()->finalize(); | 406 this->varyingHandler()->finalize(); |
| 407 fVS.finalize(kVertex_GrShaderFlag); | 407 fVS.finalize(kVertex_GrShaderFlag); |
| 408 fFS.finalize(kFragment_GrShaderFlag); | 408 fFS.finalize(kFragment_GrShaderFlag); |
| 409 | 409 |
| 410 } | 410 } |
| OLD | NEW |