OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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/GrGLShaderBuilder.h" | 8 #include "gl/GrGLShaderBuilder.h" |
9 #include "gl/GrGLProgram.h" | 9 #include "gl/GrGLProgram.h" |
10 #include "gl/GrGLUniformHandle.h" | 10 #include "gl/GrGLUniformHandle.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 return true; | 225 return true; |
226 } | 226 } |
227 | 227 |
228 ////////////////////////////////////////////////////////////////////////////// | 228 ////////////////////////////////////////////////////////////////////////////// |
229 | 229 |
230 GrGLShaderBuilder::GrGLShaderBuilder(GrGpuGL* gpu, | 230 GrGLShaderBuilder::GrGLShaderBuilder(GrGpuGL* gpu, |
231 const GrGLProgramDesc& desc) | 231 const GrGLProgramDesc& desc) |
232 : fHasVertexShader(false) | 232 : fHasVertexShader(false) |
233 , fTexCoordSetCnt(0) | 233 , fTexCoordSetCnt(0) |
234 , fProgramID(0) | 234 , fProgramID(0) |
| 235 , fFSInputs(kVarsPerBlock) |
| 236 , fSeparableVaryingInfos(kVarsPerBlock) |
235 , fDesc(desc) | 237 , fDesc(desc) |
236 , fGpu(gpu) | 238 , fGpu(gpu) |
237 , fFSFeaturesAddedMask(0) | 239 , fFSFeaturesAddedMask(0) |
238 , fFSInputs(kVarsPerBlock) | |
239 , fFSOutputs(kMaxFSOutputs) | 240 , fFSOutputs(kMaxFSOutputs) |
240 , fUniforms(kVarsPerBlock) | 241 , fUniforms(kVarsPerBlock) |
241 , fSetupFragPosition(false) | 242 , fSetupFragPosition(false) |
242 , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == desc.getHeader().fFr
agPosKey) | 243 , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == desc.getHeader().fFr
agPosKey) |
243 , fHasCustomColorOutput(false) | 244 , fHasCustomColorOutput(false) |
244 , fHasSecondaryOutput(false) { | 245 , fHasSecondaryOutput(false) { |
245 } | 246 } |
246 | 247 |
247 bool GrGLShaderBuilder::enableFeature(GLSLFeature feature) { | 248 bool GrGLShaderBuilder::enableFeature(GLSLFeature feature) { |
248 switch (feature) { | 249 switch (feature) { |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 bool usingBindUniform = fGpu->glInterface()->fFunctions.fBindUniformLocation
!= NULL; | 769 bool usingBindUniform = fGpu->glInterface()->fFunctions.fBindUniformLocation
!= NULL; |
769 if (!usingBindUniform) { | 770 if (!usingBindUniform) { |
770 int count = fUniforms.count(); | 771 int count = fUniforms.count(); |
771 for (int i = 0; i < count; ++i) { | 772 for (int i = 0; i < count; ++i) { |
772 GrGLint location; | 773 GrGLint location; |
773 GL_CALL_RET(location, | 774 GL_CALL_RET(location, |
774 GetUniformLocation(programId, fUniforms[i].fVariable.c_s
tr())); | 775 GetUniformLocation(programId, fUniforms[i].fVariable.c_s
tr())); |
775 fUniforms[i].fLocation = location; | 776 fUniforms[i].fLocation = location; |
776 } | 777 } |
777 } | 778 } |
| 779 |
| 780 int count = fSeparableVaryingInfos.count(); |
| 781 for (int i = 0; i < count; ++i) { |
| 782 GrGLint location; |
| 783 GL_CALL_RET(location, |
| 784 GetProgramResourceLocation(programId, |
| 785 GR_GL_FRAGMENT_INPUT, |
| 786 fSeparableVaryingInfos[i].fVariab
le.c_str())); |
| 787 fSeparableVaryingInfos[i].fLocation = location; |
| 788 } |
778 } | 789 } |
779 | 790 |
780 const GrGLContextInfo& GrGLShaderBuilder::ctxInfo() const { | 791 const GrGLContextInfo& GrGLShaderBuilder::ctxInfo() const { |
781 return fGpu->ctxInfo(); | 792 return fGpu->ctxInfo(); |
782 } | 793 } |
783 | 794 |
784 //////////////////////////////////////////////////////////////////////////////// | 795 //////////////////////////////////////////////////////////////////////////////// |
785 | 796 |
786 GrGLFullShaderBuilder::GrGLFullShaderBuilder(GrGpuGL* gpu, | 797 GrGLFullShaderBuilder::GrGLFullShaderBuilder(GrGpuGL* gpu, |
787 const GrGLProgramDesc& desc) | 798 const GrGLProgramDesc& desc) |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 fGSOutputs.push_back(); | 918 fGSOutputs.push_back(); |
908 fGSOutputs.back().setType(type); | 919 fGSOutputs.back().setType(type); |
909 fGSOutputs.back().setTypeModifier(GrGLShaderVar::kVaryingOut_TypeModifie
r); | 920 fGSOutputs.back().setTypeModifier(GrGLShaderVar::kVaryingOut_TypeModifie
r); |
910 this->nameVariable(fGSOutputs.back().accessName(), 'g', name); | 921 this->nameVariable(fGSOutputs.back().accessName(), 'g', name); |
911 fsName = fGSOutputs.back().accessName(); | 922 fsName = fGSOutputs.back().accessName(); |
912 } else | 923 } else |
913 #endif | 924 #endif |
914 { | 925 { |
915 fsName = fVSOutputs.back().accessName(); | 926 fsName = fVSOutputs.back().accessName(); |
916 } | 927 } |
917 this->fsInputAppend().set(type, GrGLShaderVar::kVaryingIn_TypeModifier, *fsN
ame); | 928 this->fFSInputs.push_back().set(type, GrGLShaderVar::kVaryingIn_TypeModifier
, *fsName); |
918 if (fsInName) { | 929 if (fsInName) { |
919 *fsInName = fsName->c_str(); | 930 *fsInName = fsName->c_str(); |
920 } | 931 } |
921 } | 932 } |
922 | 933 |
| 934 GrGLFullShaderBuilder::VaryingHandle |
| 935 GrGLFullShaderBuilder::addSeparableVarying(GrSLType type, |
| 936 const char* name, |
| 937 const char** vsOutName, |
| 938 const char** fsInName) { |
| 939 addVarying(type, name, vsOutName, fsInName); |
| 940 SeparableVaryingInfo& varying = fSeparableVaryingInfos.push_back(); |
| 941 varying.fVariable = fFSInputs.back(); |
| 942 return VaryingHandle::CreateFromSeparableVaryingIndex(fSeparableVaryingInfos
.count() - 1); |
| 943 } |
| 944 |
923 const SkString* GrGLFullShaderBuilder::getEffectAttributeName(int attributeIndex
) const { | 945 const SkString* GrGLFullShaderBuilder::getEffectAttributeName(int attributeIndex
) const { |
924 const AttributePair* attribEnd = fEffectAttributes.end(); | 946 const AttributePair* attribEnd = fEffectAttributes.end(); |
925 for (const AttributePair* attrib = fEffectAttributes.begin(); attrib != attr
ibEnd; ++attrib) { | 947 for (const AttributePair* attrib = fEffectAttributes.begin(); attrib != attr
ibEnd; ++attrib) { |
926 if (attrib->fIndex == attributeIndex) { | 948 if (attrib->fIndex == attributeIndex) { |
927 return &attrib->fName; | 949 return &attrib->fName; |
928 } | 950 } |
929 } | 951 } |
930 | 952 |
931 return NULL; | 953 return NULL; |
932 } | 954 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 | 1077 |
1056 GrGLPathTexGenProgramEffectsBuilder pathTexGenEffectsBuilder(this, | 1078 GrGLPathTexGenProgramEffectsBuilder pathTexGenEffectsBuilder(this, |
1057 effectCnt); | 1079 effectCnt); |
1058 this->INHERITED::createAndEmitEffects(&pathTexGenEffectsBuilder, | 1080 this->INHERITED::createAndEmitEffects(&pathTexGenEffectsBuilder, |
1059 effectStages, | 1081 effectStages, |
1060 effectCnt, | 1082 effectCnt, |
1061 keyProvider, | 1083 keyProvider, |
1062 inOutFSColor); | 1084 inOutFSColor); |
1063 return pathTexGenEffectsBuilder.finish(); | 1085 return pathTexGenEffectsBuilder.finish(); |
1064 } | 1086 } |
OLD | NEW |