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 "gl/GrGLProgram.h" | 8 #include "gl/GrGLProgram.h" |
9 #include "gl/GrGLSLPrettyPrint.h" | 9 #include "gl/GrGLSLPrettyPrint.h" |
10 #include "gl/GrGLUniformHandle.h" | 10 #include "gl/GrGLUniformHandle.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 210 |
211 void GrGLProgramBuilder::emitSamplers(const GrEffect& effect, | 211 void GrGLProgramBuilder::emitSamplers(const GrEffect& effect, |
212 GrGLEffect::TextureSamplerArray* outSample
rs) { | 212 GrGLEffect::TextureSamplerArray* outSample
rs) { |
213 SkTArray<GrGLProgramEffects::Sampler, true>& samplers = | 213 SkTArray<GrGLProgramEffects::Sampler, true>& samplers = |
214 this->getProgramEffects()->addSamplers(); | 214 this->getProgramEffects()->addSamplers(); |
215 int numTextures = effect.numTextures(); | 215 int numTextures = effect.numTextures(); |
216 samplers.push_back_n(numTextures); | 216 samplers.push_back_n(numTextures); |
217 SkString name; | 217 SkString name; |
218 for (int t = 0; t < numTextures; ++t) { | 218 for (int t = 0; t < numTextures; ++t) { |
219 name.printf("Sampler%d", t); | 219 name.printf("Sampler%d", t); |
| 220 const GrTextureAccess& ta = effect.textureAccess(t); |
| 221 const GrTexture* tex = ta.getTexture(); |
| 222 bool is3D = (tex != NULL) && (tex->desc().fDepth > 0); |
220 samplers[t].fUniform = this->addUniform(GrGLProgramBuilder::kFragment_Vi
sibility, | 223 samplers[t].fUniform = this->addUniform(GrGLProgramBuilder::kFragment_Vi
sibility, |
221 kSampler2D_GrSLType, | 224 is3D ? kSampler3D_GrSLType : kSa
mpler2D_GrSLType, |
222 name.c_str()); | 225 name.c_str()); |
223 SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLEffect::TextureSampler, | 226 SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLEffect::TextureSampler, |
224 (samplers[t].fUniform, effect.textureAccess(t))); | 227 (samplers[t].fUniform, ta)); |
225 } | 228 } |
226 } | 229 } |
227 | 230 |
228 bool GrGLProgramBuilder::finish() { | 231 bool GrGLProgramBuilder::finish() { |
229 SkASSERT(0 == fProgramID); | 232 SkASSERT(0 == fProgramID); |
230 GL_CALL_RET(fProgramID, CreateProgram()); | 233 GL_CALL_RET(fProgramID, CreateProgram()); |
231 if (!fProgramID) { | 234 if (!fProgramID) { |
232 return false; | 235 return false; |
233 } | 236 } |
234 | 237 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 GetProgramResourceLocation(programId, | 322 GetProgramResourceLocation(programId, |
320 GR_GL_FRAGMENT_INPUT, | 323 GR_GL_FRAGMENT_INPUT, |
321 fSeparableVaryingInfos[i].fVariab
le.c_str())); | 324 fSeparableVaryingInfos[i].fVariab
le.c_str())); |
322 fSeparableVaryingInfos[i].fLocation = location; | 325 fSeparableVaryingInfos[i].fLocation = location; |
323 } | 326 } |
324 } | 327 } |
325 | 328 |
326 const GrGLContextInfo& GrGLProgramBuilder::ctxInfo() const { | 329 const GrGLContextInfo& GrGLProgramBuilder::ctxInfo() const { |
327 return fGpu->ctxInfo(); | 330 return fGpu->ctxInfo(); |
328 } | 331 } |
OLD | NEW |