Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(488)

Side by Side Diff: src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp

Issue 1417123002: Move GrGLShaderVar to GrGLSL (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix gyp Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLShaderVar.h ('k') | src/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "GrGLFragmentShaderBuilder.h" 8 #include "GrGLFragmentShaderBuilder.h"
9 #include "GrGLProgramBuilder.h" 9 #include "GrGLProgramBuilder.h"
10 #include "gl/GrGLGpu.h" 10 #include "gl/GrGLGpu.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 if (fTopLeftFragPosRead) { 144 if (fTopLeftFragPosRead) {
145 fSetupFragPosition = true; 145 fSetupFragPosition = true;
146 return "gl_FragCoord"; 146 return "gl_FragCoord";
147 } else if (gpu->glCaps().fragCoordConventionsSupport()) { 147 } else if (gpu->glCaps().fragCoordConventionsSupport()) {
148 if (!fSetupFragPosition) { 148 if (!fSetupFragPosition) {
149 if (gpu->glslGeneration() < k150_GrGLSLGeneration) { 149 if (gpu->glslGeneration() < k150_GrGLSLGeneration) {
150 this->addFeature(1 << kFragCoordConventions_GLSLPrivateFeature, 150 this->addFeature(1 << kFragCoordConventions_GLSLPrivateFeature,
151 "GL_ARB_fragment_coord_conventions"); 151 "GL_ARB_fragment_coord_conventions");
152 } 152 }
153 fInputs.push_back().set(kVec4f_GrSLType, 153 fInputs.push_back().set(kVec4f_GrSLType,
154 GrGLShaderVar::kIn_TypeModifier, 154 GrGLSLShaderVar::kIn_TypeModifier,
155 "gl_FragCoord", 155 "gl_FragCoord",
156 kDefault_GrSLPrecision, 156 kDefault_GrSLPrecision,
157 GrGLShaderVar::kUpperLeft_Origin); 157 GrGLSLShaderVar::kUpperLeft_Origin);
158 fSetupFragPosition = true; 158 fSetupFragPosition = true;
159 } 159 }
160 return "gl_FragCoord"; 160 return "gl_FragCoord";
161 } else { 161 } else {
162 static const char* kTempName = "tmpXYFragCoord"; 162 static const char* kTempName = "tmpXYFragCoord";
163 static const char* kCoordName = "fragCoordYDown"; 163 static const char* kCoordName = "fragCoordYDown";
164 if (!fSetupFragPosition) { 164 if (!fSetupFragPosition) {
165 // temporarily change the stage index because we're inserting non-st age code. 165 // temporarily change the stage index because we're inserting non-st age code.
166 GrGLProgramBuilder::AutoStageRestore asr(fProgramBuilder); 166 GrGLProgramBuilder::AutoStageRestore asr(fProgramBuilder);
167 SkASSERT(!fProgramBuilder->fUniformHandles.fRTHeightUni.isValid()); 167 SkASSERT(!fProgramBuilder->fUniformHandles.fRTHeightUni.isValid());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } else { 225 } else {
226 this->addLayoutQualifier("blend_support_all_equations", kOut_InterfaceQu alifier); 226 this->addLayoutQualifier("blend_support_all_equations", kOut_InterfaceQu alifier);
227 } 227 }
228 } 228 }
229 229
230 void GrGLFragmentShaderBuilder::enableCustomOutput() { 230 void GrGLFragmentShaderBuilder::enableCustomOutput() {
231 if (!fHasCustomColorOutput) { 231 if (!fHasCustomColorOutput) {
232 fHasCustomColorOutput = true; 232 fHasCustomColorOutput = true;
233 fCustomColorOutputIndex = fOutputs.count(); 233 fCustomColorOutputIndex = fOutputs.count();
234 fOutputs.push_back().set(kVec4f_GrSLType, 234 fOutputs.push_back().set(kVec4f_GrSLType,
235 GrGLShaderVar::kOut_TypeModifier, 235 GrGLSLShaderVar::kOut_TypeModifier,
236 declared_color_output_name()); 236 declared_color_output_name());
237 } 237 }
238 } 238 }
239 239
240 void GrGLFragmentShaderBuilder::enableSecondaryOutput() { 240 void GrGLFragmentShaderBuilder::enableSecondaryOutput() {
241 SkASSERT(!fHasSecondaryOutput); 241 SkASSERT(!fHasSecondaryOutput);
242 fHasSecondaryOutput = true; 242 fHasSecondaryOutput = true;
243 if (kGLES_GrGLStandard == fProgramBuilder->gpu()->ctxInfo().standard()) { 243 if (kGLES_GrGLStandard == fProgramBuilder->gpu()->ctxInfo().standard()) {
244 this->addFeature(1 << kBlendFuncExtended_GLSLPrivateFeature, "GL_EXT_ble nd_func_extended"); 244 this->addFeature(1 << kBlendFuncExtended_GLSLPrivateFeature, "GL_EXT_ble nd_func_extended");
245 } 245 }
246 246
247 // If the primary output is declared, we must declare also the secondary out put 247 // If the primary output is declared, we must declare also the secondary out put
248 // and vice versa, since it is not allowed to use a built-in gl_FragColor an d a custom 248 // and vice versa, since it is not allowed to use a built-in gl_FragColor an d a custom
249 // output. The condition also co-incides with the condition in whici GLES SL 2.0 249 // output. The condition also co-incides with the condition in whici GLES SL 2.0
250 // requires the built-in gl_SecondaryFragColorEXT, where as 3.0 requires a c ustom output. 250 // requires the built-in gl_SecondaryFragColorEXT, where as 3.0 requires a c ustom output.
251 const GrGLSLCaps& caps = *fProgramBuilder->gpu()->glCaps().glslCaps(); 251 const GrGLSLCaps& caps = *fProgramBuilder->gpu()->glCaps().glslCaps();
252 if (caps.mustDeclareFragmentShaderOutput()) { 252 if (caps.mustDeclareFragmentShaderOutput()) {
253 fOutputs.push_back().set(kVec4f_GrSLType, GrGLShaderVar::kOut_TypeModifi er, 253 fOutputs.push_back().set(kVec4f_GrSLType, GrGLSLShaderVar::kOut_TypeModi fier,
254 declared_secondary_color_output_name()); 254 declared_secondary_color_output_name());
255 } 255 }
256 } 256 }
257 257
258 const char* GrGLFragmentShaderBuilder::getPrimaryColorOutputName() const { 258 const char* GrGLFragmentShaderBuilder::getPrimaryColorOutputName() const {
259 return fHasCustomColorOutput ? declared_color_output_name() : "gl_FragColor" ; 259 return fHasCustomColorOutput ? declared_color_output_name() : "gl_FragColor" ;
260 } 260 }
261 261
262 const char* GrGLFragmentShaderBuilder::getSecondaryColorOutputName() const { 262 const char* GrGLFragmentShaderBuilder::getSecondaryColorOutputName() const {
263 const GrGLSLCaps& caps = *fProgramBuilder->gpu()->glCaps().glslCaps(); 263 const GrGLSLCaps& caps = *fProgramBuilder->gpu()->glCaps().glslCaps();
(...skipping 27 matching lines...) Expand all
291 GL_CALL(BindFragDataLocationIndexed(programID, 0, 1, 291 GL_CALL(BindFragDataLocationIndexed(programID, 0, 1,
292 declared_secondary_color_output_name ())); 292 declared_secondary_color_output_name ()));
293 } 293 }
294 } 294 }
295 295
296 void GrGLFragmentShaderBuilder::addVarying(GrGLVarying* v, GrSLPrecision fsPrec) { 296 void GrGLFragmentShaderBuilder::addVarying(GrGLVarying* v, GrSLPrecision fsPrec) {
297 v->fFsIn = v->fVsOut; 297 v->fFsIn = v->fVsOut;
298 if (v->fGsOut) { 298 if (v->fGsOut) {
299 v->fFsIn = v->fGsOut; 299 v->fFsIn = v->fGsOut;
300 } 300 }
301 fInputs.push_back().set(v->fType, GrGLShaderVar::kVaryingIn_TypeModifier, v- >fFsIn, fsPrec); 301 fInputs.push_back().set(v->fType, GrGLSLShaderVar::kVaryingIn_TypeModifier, v->fFsIn, fsPrec);
302 } 302 }
303 303
304 void GrGLFragmentBuilder::onBeforeChildProcEmitCode() { 304 void GrGLFragmentBuilder::onBeforeChildProcEmitCode() {
305 SkASSERT(fSubstageIndices.count() >= 1); 305 SkASSERT(fSubstageIndices.count() >= 1);
306 fSubstageIndices.push_back(0); 306 fSubstageIndices.push_back(0);
307 // second-to-last value in the fSubstageIndices stack is the index of the ch ild proc 307 // second-to-last value in the fSubstageIndices stack is the index of the ch ild proc
308 // at that level which is currently emitting code. 308 // at that level which is currently emitting code.
309 fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2] ); 309 fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2] );
310 } 310 }
311 311
312 void GrGLFragmentBuilder::onAfterChildProcEmitCode() { 312 void GrGLFragmentBuilder::onAfterChildProcEmitCode() {
313 SkASSERT(fSubstageIndices.count() >= 2); 313 SkASSERT(fSubstageIndices.count() >= 2);
314 fSubstageIndices.pop_back(); 314 fSubstageIndices.pop_back();
315 fSubstageIndices.back()++; 315 fSubstageIndices.back()++;
316 int removeAt = fMangleString.findLastOf('_'); 316 int removeAt = fMangleString.findLastOf('_');
317 fMangleString.remove(removeAt, fMangleString.size() - removeAt); 317 fMangleString.remove(removeAt, fMangleString.size() - removeAt);
318 } 318 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLShaderVar.h ('k') | src/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698