| 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 "GrGLNvprProgramBuilder.h" | 8 #include "GrGLNvprProgramBuilder.h" |
| 9 #include "../GrGpuGL.h" | 9 #include "../GrGpuGL.h" |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 kVec3f_GrSLType : | 32 kVec3f_GrSLType : |
| 33 kVec2f_GrSLType; | 33 kVec2f_GrSLType; |
| 34 | 34 |
| 35 const char* varyingName = "MatrixCoord"; | 35 const char* varyingName = "MatrixCoord"; |
| 36 SkString suffixedVaryingName; | 36 SkString suffixedVaryingName; |
| 37 if (0 != t) { | 37 if (0 != t) { |
| 38 suffixedVaryingName.append(varyingName); | 38 suffixedVaryingName.append(varyingName); |
| 39 suffixedVaryingName.appendf("_%i", t); | 39 suffixedVaryingName.appendf("_%i", t); |
| 40 varyingName = suffixedVaryingName.c_str(); | 40 varyingName = suffixedVaryingName.c_str(); |
| 41 } | 41 } |
| 42 const char* vsVaryingName; | 42 GrGLVertToFrag v(varyingType); |
| 43 const char* fsVaryingName; | 43 ifp->fTransforms[t].fHandle = this->addSeparableVarying(varyingName, &v)
; |
| 44 ifp->fTransforms[t].fHandle = this->addSeparableVarying(varyingType, var
yingName, | |
| 45 &vsVaryingName,
&fsVaryingName); | |
| 46 ifp->fTransforms[t].fType = varyingType; | 44 ifp->fTransforms[t].fType = varyingType; |
| 47 | 45 |
| 48 SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords, | 46 SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords, |
| 49 (SkString(fsVaryingName), varyingType)); | 47 (SkString(v.fsIn()), varyingType)); |
| 50 } | 48 } |
| 51 } | 49 } |
| 52 | 50 |
| 53 GrGLInstalledFragProc::ShaderVarHandle | 51 GrGLInstalledFragProc::ShaderVarHandle |
| 54 GrGLNvprProgramBuilder::addSeparableVarying(GrSLType type, | 52 GrGLNvprProgramBuilder::addSeparableVarying(const char* name, GrGLVarying* v) { |
| 55 const char* name, | 53 this->addVarying(name, v); |
| 56 const char** vsOutName, | |
| 57 const char** fsInName) { | |
| 58 SeparableVaryingInfo& varying = fSeparableVaryingInfos.push_back(); | 54 SeparableVaryingInfo& varying = fSeparableVaryingInfos.push_back(); |
| 59 varying.fVariable = fFS.fInputs.back(); | 55 varying.fVariable = fFS.fInputs.back(); |
| 60 return GrGLInstalledFragProc::ShaderVarHandle(fSeparableVaryingInfos.count()
- 1); | 56 return GrGLInstalledFragProc::ShaderVarHandle(fSeparableVaryingInfos.count()
- 1); |
| 61 } | 57 } |
| 62 | 58 |
| 63 void GrGLNvprProgramBuilder::resolveSeparableVaryings(GrGLuint programId) { | 59 void GrGLNvprProgramBuilder::resolveSeparableVaryings(GrGLuint programId) { |
| 64 int count = fSeparableVaryingInfos.count(); | 60 int count = fSeparableVaryingInfos.count(); |
| 65 for (int i = 0; i < count; ++i) { | 61 for (int i = 0; i < count; ++i) { |
| 66 GrGLint location; | 62 GrGLint location; |
| 67 GL_CALL_RET(location, | 63 GL_CALL_RET(location, |
| 68 GetProgramResourceLocation(programId, | 64 GetProgramResourceLocation(programId, |
| 69 GR_GL_FRAGMENT_INPUT, | 65 GR_GL_FRAGMENT_INPUT, |
| 70 fSeparableVaryingInfos[i].fVariab
le.c_str())); | 66 fSeparableVaryingInfos[i].fVariab
le.c_str())); |
| 71 fSeparableVaryingInfos[i].fLocation = location; | 67 fSeparableVaryingInfos[i].fLocation = location; |
| 72 } | 68 } |
| 73 } | 69 } |
| 74 | 70 |
| 75 GrGLProgram* GrGLNvprProgramBuilder::createProgram(GrGLuint programID) { | 71 GrGLProgram* GrGLNvprProgramBuilder::createProgram(GrGLuint programID) { |
| 76 // this is just for nvpr es, which has separable varyings that are plugged i
n after | 72 // this is just for nvpr es, which has separable varyings that are plugged i
n after |
| 77 // building | 73 // building |
| 78 this->resolveSeparableVaryings(programID); | 74 this->resolveSeparableVaryings(programID); |
| 79 return SkNEW_ARGS(GrGLNvprProgram, (fGpu, fDesc, fUniformHandles, programID,
fUniforms, | 75 return SkNEW_ARGS(GrGLNvprProgram, (fGpu, fDesc, fUniformHandles, programID,
fUniforms, |
| 80 fFragmentProcessors.get(), fSeparableVar
yingInfos)); | 76 fFragmentProcessors.get(), fSeparableVar
yingInfos)); |
| 81 } | 77 } |
| OLD | NEW |