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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 SkDEBUGFAIL("GrGLEffect asked for frag position but its generating G
rEffect " | 492 SkDEBUGFAIL("GrGLEffect asked for frag position but its generating G
rEffect " |
493 "did not request access."); | 493 "did not request access."); |
494 return ""; | 494 return ""; |
495 } | 495 } |
496 } | 496 } |
497 // We only declare "gl_FragCoord" when we're in the case where we want to us
e layout qualifiers | 497 // We only declare "gl_FragCoord" when we're in the case where we want to us
e layout qualifiers |
498 // to reverse y. Otherwise it isn't necessary and whether the "in" qualifier
appears in the | 498 // to reverse y. Otherwise it isn't necessary and whether the "in" qualifier
appears in the |
499 // declaration varies in earlier GLSL specs. So it is simpler to omit it. | 499 // declaration varies in earlier GLSL specs. So it is simpler to omit it. |
500 if (fTopLeftFragPosRead) { | 500 if (fTopLeftFragPosRead) { |
501 fSetupFragPosition = true; | 501 fSetupFragPosition = true; |
502 return "(gl_FragCoord.xy)"; | 502 return "gl_FragCoord"; |
503 } else if (fGpu->glCaps().fragCoordConventionsSupport()) { | 503 } else if (fGpu->glCaps().fragCoordConventionsSupport()) { |
504 if (!fSetupFragPosition) { | 504 if (!fSetupFragPosition) { |
505 SkAssertResult(this->enablePrivateFeature(kFragCoordConventions_GLSL
PrivateFeature)); | 505 SkAssertResult(this->enablePrivateFeature(kFragCoordConventions_GLSL
PrivateFeature)); |
506 fFSInputs.push_back().set(kVec4f_GrSLType, | 506 fFSInputs.push_back().set(kVec4f_GrSLType, |
507 GrGLShaderVar::kIn_TypeModifier, | 507 GrGLShaderVar::kIn_TypeModifier, |
508 "gl_FragCoord", | 508 "gl_FragCoord", |
509 GrGLShaderVar::kDefault_Precision, | 509 GrGLShaderVar::kDefault_Precision, |
510 GrGLShaderVar::kUpperLeft_Origin); | 510 GrGLShaderVar::kUpperLeft_Origin); |
511 fSetupFragPosition = true; | 511 fSetupFragPosition = true; |
512 } | 512 } |
513 return "(gl_FragCoord.xy)"; | 513 return "gl_FragCoord"; |
514 } else { | 514 } else { |
515 static const char* kCoordName = "fragCoordYDown"; | 515 static const char* kCoordName = "fragCoordYDown"; |
516 if (!fSetupFragPosition) { | 516 if (!fSetupFragPosition) { |
517 // temporarily change the stage index because we're inserting non-st
age code. | 517 // temporarily change the stage index because we're inserting non-st
age code. |
518 CodeStage::AutoStageRestore csar(&fCodeStage, NULL); | 518 CodeStage::AutoStageRestore csar(&fCodeStage, NULL); |
519 | 519 |
520 SkASSERT(!fOutput.fUniformHandles.fRTHeightUni.isValid()); | 520 SkASSERT(!fOutput.fUniformHandles.fRTHeightUni.isValid()); |
521 const char* rtHeightName; | 521 const char* rtHeightName; |
522 | 522 |
523 fOutput.fUniformHandles.fRTHeightUni = | 523 fOutput.fUniformHandles.fRTHeightUni = |
524 this->addUniform(kFragment_Visibility, kFloat_GrSLType, "RTHeigh
t", &rtHeightName); | 524 this->addUniform(kFragment_Visibility, kFloat_GrSLType, "RTHeigh
t", &rtHeightName); |
525 | 525 |
526 this->fFSCode.prependf("\tvec2 %s = vec2(gl_FragCoord.x, %s - gl_Fra
gCoord.y);\n", | 526 // Using glFragCoord.zw for the last two components tickles an Adren
o driver bug that |
527 kCoordName, rtHeightName); | 527 // causes programs to fail to link. Making this function return a ve
c2() didn't fix the |
| 528 // problem but using 1.0 for the last two components does. |
| 529 this->fFSCode.prependf("\tvec4 %s = vec4(gl_FragCoord.x, %s - gl_Fra
gCoord.y, 1.0, " |
| 530 "1.0);\n", kCoordName, rtHeightName); |
528 fSetupFragPosition = true; | 531 fSetupFragPosition = true; |
529 } | 532 } |
530 SkASSERT(fOutput.fUniformHandles.fRTHeightUni.isValid()); | 533 SkASSERT(fOutput.fUniformHandles.fRTHeightUni.isValid()); |
531 return kCoordName; | 534 return kCoordName; |
532 } | 535 } |
533 } | 536 } |
534 | 537 |
535 void GrGLShaderBuilder::fsEmitFunction(GrSLType returnType, | 538 void GrGLShaderBuilder::fsEmitFunction(GrSLType returnType, |
536 const char* name, | 539 const char* name, |
537 int argCnt, | 540 int argCnt, |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 | 1096 |
1094 GrGLPathTexGenProgramEffectsBuilder pathTexGenEffectsBuilder(this, | 1097 GrGLPathTexGenProgramEffectsBuilder pathTexGenEffectsBuilder(this, |
1095 effectCnt); | 1098 effectCnt); |
1096 this->INHERITED::createAndEmitEffects(&pathTexGenEffectsBuilder, | 1099 this->INHERITED::createAndEmitEffects(&pathTexGenEffectsBuilder, |
1097 effectStages, | 1100 effectStages, |
1098 effectKeys, | 1101 effectKeys, |
1099 effectCnt, | 1102 effectCnt, |
1100 inOutFSColor); | 1103 inOutFSColor); |
1101 return pathTexGenEffectsBuilder.finish(); | 1104 return pathTexGenEffectsBuilder.finish(); |
1102 } | 1105 } |
OLD | NEW |