Chromium Code Reviews| 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 "GrGLProgramBuilder.h" | 8 #include "GrGLProgramBuilder.h" |
| 9 | 9 |
| 10 #include "GrAutoLocaleSetter.h" | 10 #include "GrAutoLocaleSetter.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 fArgs.fPrimitiveProcessor->isPathRendering() && | 100 fArgs.fPrimitiveProcessor->isPathRendering() && |
| 101 !fArgs.fPrimitiveProcessor->willUseGeoShader() && | 101 !fArgs.fPrimitiveProcessor->willUseGeoShader() && |
| 102 fArgs.fPrimitiveProcessor->numAttribs() == 0); | 102 fArgs.fPrimitiveProcessor->numAttribs() == 0); |
| 103 this->addVarying(name, v, fsPrecision); | 103 this->addVarying(name, v, fsPrecision); |
| 104 SeparableVaryingInfo& varyingInfo = fSeparableVaryingInfos.push_back(); | 104 SeparableVaryingInfo& varyingInfo = fSeparableVaryingInfos.push_back(); |
| 105 varyingInfo.fVariable = this->getFragmentShaderBuilder()->fInputs.back(); | 105 varyingInfo.fVariable = this->getFragmentShaderBuilder()->fInputs.back(); |
| 106 varyingInfo.fLocation = fSeparableVaryingInfos.count() - 1; | 106 varyingInfo.fLocation = fSeparableVaryingInfos.count() - 1; |
| 107 return SeparableVaryingHandle(varyingInfo.fLocation); | 107 return SeparableVaryingHandle(varyingInfo.fLocation); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void GrGLProgramBuilder::nameVariable(SkString* out, char prefix, const char* na me) { | 110 void GrGLProgramBuilder::nameVariable(SkString* out, char prefix, const char* na me, bool mangle) { |
| 111 if ('\0' == prefix) { | 111 if ('\0' == prefix) { |
| 112 *out = name; | 112 *out = name; |
| 113 } else { | 113 } else { |
| 114 out->printf("%c%s", prefix, name); | 114 out->printf("%c%s", prefix, name); |
| 115 } | 115 } |
| 116 if (!fOutOfStage) { | 116 if (!fOutOfStage && mangle) { |
|
joshualitt
2015/11/04 21:50:52
Do we still need fOutOfStage?
egdaniel
2015/11/05 21:49:59
removed
| |
| 117 if (out->endsWith('_')) { | 117 if (out->endsWith('_')) { |
| 118 // Names containing "__" are reserved. | 118 // Names containing "__" are reserved. |
| 119 out->append("x"); | 119 out->append("x"); |
| 120 } | 120 } |
| 121 out->appendf("_Stage%d%s", fStageIndex, fFS.getMangleString().c_str()); | 121 out->appendf("_Stage%d%s", fStageIndex, fFS.getMangleString().c_str()); |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 GrGLSLProgramDataManager::UniformHandle GrGLProgramBuilder::addUniformArray( | 125 GrGLSLProgramDataManager::UniformHandle GrGLProgramBuilder::internalAddUniformAr ray( |
| 126 uint32_t visibil ity, | 126 uint32_t visibil ity, |
| 127 GrSLType type, | 127 GrSLType type, |
| 128 GrSLPrecision pr ecision, | 128 GrSLPrecision pr ecision, |
| 129 const char* name , | 129 const char* name , |
| 130 bool mangleName, | |
| 130 int count, | 131 int count, |
| 131 const char** out Name) { | 132 const char** out Name) { |
| 132 SkASSERT(name && strlen(name)); | 133 SkASSERT(name && strlen(name)); |
| 133 SkDEBUGCODE(static const uint32_t kVisibilityMask = kVertex_Visibility | kFr agment_Visibility); | 134 SkDEBUGCODE(static const uint32_t kVisibilityMask = kVertex_Visibility | kFr agment_Visibility); |
| 134 SkASSERT(0 == (~kVisibilityMask & visibility)); | 135 SkASSERT(0 == (~kVisibilityMask & visibility)); |
| 135 SkASSERT(0 != visibility); | 136 SkASSERT(0 != visibility); |
| 136 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type)); | 137 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type)); |
| 137 | 138 |
| 138 UniformInfo& uni = fUniforms.push_back(); | 139 UniformInfo& uni = fUniforms.push_back(); |
| 139 uni.fVariable.setType(type); | 140 uni.fVariable.setType(type); |
| 140 uni.fVariable.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier); | 141 uni.fVariable.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier); |
| 141 // TODO this is a bit hacky, lets think of a better way. Basically we need to be able to use | 142 // TODO this is a bit hacky, lets think of a better way. Basically we need to be able to use |
| 142 // the uniform view matrix name in the GP, and the GP is immutable so it has to tell the PB | 143 // the uniform view matrix name in the GP, and the GP is immutable so it has to tell the PB |
| 143 // exactly what name it wants to use for the uniform view matrix. If we pre fix anythings, then | 144 // exactly what name it wants to use for the uniform view matrix. If we pre fix anythings, then |
| 144 // the names will mismatch. I think the correct solution is to have all GPs which need the | 145 // the names will mismatch. I think the correct solution is to have all GPs which need the |
| 145 // uniform view matrix, they should upload the view matrix in their setData along with regular | 146 // uniform view matrix, they should upload the view matrix in their setData along with regular |
| 146 // uniforms. | 147 // uniforms. |
| 147 char prefix = 'u'; | 148 char prefix = 'u'; |
| 148 if ('u' == name[0]) { | 149 if ('u' == name[0]) { |
| 149 prefix = '\0'; | 150 prefix = '\0'; |
| 150 } | 151 } |
| 151 this->nameVariable(uni.fVariable.accessName(), prefix, name); | 152 this->nameVariable(uni.fVariable.accessName(), prefix, name, mangleName); |
| 152 uni.fVariable.setArrayCount(count); | 153 uni.fVariable.setArrayCount(count); |
| 153 uni.fVisibility = visibility; | 154 uni.fVisibility = visibility; |
| 154 uni.fVariable.setPrecision(precision); | 155 uni.fVariable.setPrecision(precision); |
| 155 | 156 |
| 156 if (outName) { | 157 if (outName) { |
| 157 *outName = uni.fVariable.c_str(); | 158 *outName = uni.fVariable.c_str(); |
| 158 } | 159 } |
| 159 return GrGLSLProgramDataManager::UniformHandle(fUniforms.count() - 1); | 160 return GrGLSLProgramDataManager::UniformHandle(fUniforms.count() - 1); |
| 160 } | 161 } |
| 161 | 162 |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 544 } | 545 } |
| 545 | 546 |
| 546 //////////////////////////////////////////////////////////////////////////////// /////////////////// | 547 //////////////////////////////////////////////////////////////////////////////// /////////////////// |
| 547 | 548 |
| 548 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { | 549 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { |
| 549 int numProcs = fProcs.count(); | 550 int numProcs = fProcs.count(); |
| 550 for (int i = 0; i < numProcs; ++i) { | 551 for (int i = 0; i < numProcs; ++i) { |
| 551 delete fProcs[i]; | 552 delete fProcs[i]; |
| 552 } | 553 } |
| 553 } | 554 } |
| OLD | NEW |