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

Side by Side Diff: src/gpu/gl/GrGLShaderBuilder.cpp

Issue 23537028: Enable vertexless shading when path rendering is supported (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 GrGLUniformManager& uniformManager, 95 GrGLUniformManager& uniformManager,
96 const GrGLProgramDesc& desc, 96 const GrGLProgramDesc& desc,
97 bool hasVertexShaderEffects) 97 bool hasVertexShaderEffects)
98 : fUniforms(kVarsPerBlock) 98 : fUniforms(kVarsPerBlock)
99 , fCtxInfo(ctxInfo) 99 , fCtxInfo(ctxInfo)
100 , fUniformManager(uniformManager) 100 , fUniformManager(uniformManager)
101 , fFSFeaturesAddedMask(0) 101 , fFSFeaturesAddedMask(0)
102 , fFSInputs(kVarsPerBlock) 102 , fFSInputs(kVarsPerBlock)
103 , fFSOutputs(kMaxFSOutputs) 103 , fFSOutputs(kMaxFSOutputs)
104 , fSetupFragPosition(false) 104 , fSetupFragPosition(false)
105 , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == desc.getHeader().fFr agPosKey) { 105 , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == desc.getHeader().fFr agPosKey)
106 , fNumTexGenUnits(0) {
106 107
107 const GrGLProgramDesc::KeyHeader& header = desc.getHeader(); 108 const GrGLProgramDesc::KeyHeader& header = desc.getHeader();
108 109
109 // TODO: go vertexless when possible. 110 // We only go without a vertex shader if every effect supports vertexless mo de, the context
110 fVertexBuilder.reset(SkNEW_ARGS(VertexBuilder, (this, desc))); 111 // has fixed function/path rendering support, and position is the only verte x attribute.
112 if (hasVertexShaderEffects ||
113 !ctxInfo.caps()->fixedFunctionSupport() ||
114 !ctxInfo.caps()->pathStencilingSupport() ||
115 -1 != header.fLocalCoordAttributeIndex ||
116 -1 != header.fColorAttributeIndex ||
117 -1 != header.fCoverageAttributeIndex) {
118 fVertexBuilder.reset(SkNEW_ARGS(VertexBuilder, (this, desc)));
119 }
111 120
112 // Emit code to read the dst copy textue if necessary. 121 // Emit code to read the dst copy textue if necessary.
113 if (kNoDstRead_DstReadKey != header.fDstReadKey && 122 if (kNoDstRead_DstReadKey != header.fDstReadKey &&
114 GrGLCaps::kNone_FBFetchType == ctxInfo.caps()->fbFetchType()) { 123 GrGLCaps::kNone_FBFetchType == ctxInfo.caps()->fbFetchType()) {
115 bool topDown = SkToBool(kTopLeftOrigin_DstReadKeyBit & header.fDstReadKe y); 124 bool topDown = SkToBool(kTopLeftOrigin_DstReadKeyBit & header.fDstReadKe y);
116 const char* dstCopyTopLeftName; 125 const char* dstCopyTopLeftName;
117 const char* dstCopyCoordScaleName; 126 const char* dstCopyCoordScaleName;
118 uint32_t configMask; 127 uint32_t configMask;
119 if (SkToBool(kUseAlphaConfig_DstReadKeyBit & header.fDstReadKey)) { 128 if (SkToBool(kUseAlphaConfig_DstReadKeyBit & header.fDstReadKey)) {
120 configMask = kA_GrColorComponentFlag; 129 configMask = kA_GrColorComponentFlag;
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 args[i].appendDecl(fCtxInfo, &fFSFunctions); 436 args[i].appendDecl(fCtxInfo, &fFSFunctions);
428 if (i < argCnt - 1) { 437 if (i < argCnt - 1) {
429 fFSFunctions.append(", "); 438 fFSFunctions.append(", ");
430 } 439 }
431 } 440 }
432 fFSFunctions.append(") {\n"); 441 fFSFunctions.append(") {\n");
433 fFSFunctions.append(body); 442 fFSFunctions.append(body);
434 fFSFunctions.append("}\n\n"); 443 fFSFunctions.append("}\n\n");
435 } 444 }
436 445
446 void GrGLShaderBuilder::addTexGenUnit(GrSLType type,
447 SkString* fsInName,
448 int* unitIdx,
449 int* numComponents)
450 {
bsalomon 2013/09/10 13:51:06 style nit: { up on prev line
451 const int index = fNumTexGenUnits++;
452 if (fsInName) {
453 fsInName->printf("%s(gl_TexCoord[%u])", GrGLSLTypeString(type), index);
454 }
455 if (unitIdx) {
456 *unitIdx = index;
457 }
458 if (numComponents) {
459 *numComponents = GrSLTypeToVecLength(type);
460 }
461 }
462
437 namespace { 463 namespace {
438 464
439 inline void append_default_precision_qualifier(GrGLShaderVar::Precision p, 465 inline void append_default_precision_qualifier(GrGLShaderVar::Precision p,
440 GrGLBinding binding, 466 GrGLBinding binding,
441 SkString* str) { 467 SkString* str) {
442 // Desktop GLSL has added precision qualifiers but they don't do anything. 468 // Desktop GLSL has added precision qualifiers but they don't do anything.
443 if (kES_GrGLBinding == binding) { 469 if (kES_GrGLBinding == binding) {
444 switch (p) { 470 switch (p) {
445 case GrGLShaderVar::kHigh_Precision: 471 case GrGLShaderVar::kHigh_Precision:
446 str->append("precision highp float;\n"); 472 str->append("precision highp float;\n");
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 for (const AttributePair* attrib = this->getEffectAttributes().begin(); 729 for (const AttributePair* attrib = this->getEffectAttributes().begin();
704 attrib != attribEnd; 730 attrib != attribEnd;
705 ++attrib) { 731 ++attrib) {
706 if (attrib->fIndex == attributeIndex) { 732 if (attrib->fIndex == attributeIndex) {
707 return &attrib->fName; 733 return &attrib->fName;
708 } 734 }
709 } 735 }
710 736
711 return NULL; 737 return NULL;
712 } 738 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698