Make GrGLShaderBuilder responsible for inserting begining of main() function defition and closing brace.
This will allow another change I am working on to insert code at the begining of a shader. R=robertphillips@google.com Review URL: https://codereview.appspot.com/6737058 git-svn-id: http://skia.googlecode.com/svn/trunk@6028 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
4285accf5a
commit
d7bafb700c
@ -364,9 +364,8 @@ void GrGLProgram::genGeometryShader(GrGLShaderBuilder* segments) const {
|
||||
GrAssert(fContextInfo.glslGeneration() >= k150_GrGLSLGeneration);
|
||||
segments->fGSHeader.append("layout(triangles) in;\n"
|
||||
"layout(triangle_strip, max_vertices = 6) out;\n");
|
||||
segments->fGSCode.append("void main() {\n"
|
||||
"\tfor (int i = 0; i < 3; ++i) {\n"
|
||||
"\t\tgl_Position = gl_in[i].gl_Position;\n");
|
||||
segments->fGSCode.append("\tfor (int i = 0; i < 3; ++i) {\n"
|
||||
"\t\tgl_Position = gl_in[i].gl_Position;\n");
|
||||
if (fDesc.fEmitsPointSize) {
|
||||
segments->fGSCode.append("\t\tgl_PointSize = 1.0;\n");
|
||||
}
|
||||
@ -379,8 +378,7 @@ void GrGLProgram::genGeometryShader(GrGLShaderBuilder* segments) const {
|
||||
}
|
||||
segments->fGSCode.append("\t\tEmitVertex();\n"
|
||||
"\t}\n"
|
||||
"\tEndPrimitive();\n"
|
||||
"}\n");
|
||||
"\tEndPrimitive();\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -571,9 +569,8 @@ bool GrGLProgram::genProgram(const GrCustomStage** customStages) {
|
||||
GrGLShaderVar::kAttribute_TypeModifier,
|
||||
POS_ATTR_NAME);
|
||||
|
||||
builder.fVSCode.appendf("void main() {\n"
|
||||
"\tvec3 pos3 = %s * vec3("POS_ATTR_NAME", 1);\n"
|
||||
"\tgl_Position = vec4(pos3.xy, 0, pos3.z);\n",
|
||||
builder.fVSCode.appendf("\tvec3 pos3 = %s * vec3("POS_ATTR_NAME", 1);\n"
|
||||
"\tgl_Position = vec4(pos3.xy, 0, pos3.z);\n",
|
||||
viewMName);
|
||||
|
||||
// incoming color to current stage being processed.
|
||||
@ -588,8 +585,6 @@ bool GrGLProgram::genProgram(const GrCustomStage** customStages) {
|
||||
builder.fVSCode.append("\tgl_PointSize = 1.0;\n");
|
||||
}
|
||||
|
||||
builder.fFSCode.append("void main() {\n");
|
||||
|
||||
// add texture coordinates that are used to the list of vertex attr decls
|
||||
SkString texCoordAttrs[GrDrawState::kMaxTexCoords];
|
||||
for (int t = 0; t < GrDrawState::kMaxTexCoords; ++t) {
|
||||
@ -791,9 +786,6 @@ bool GrGLProgram::genProgram(const GrCustomStage** customStages) {
|
||||
}
|
||||
}
|
||||
|
||||
builder.fVSCode.append("}\n");
|
||||
builder.fFSCode.append("}\n");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// insert GS
|
||||
#if GR_DEBUG
|
||||
|
@ -359,7 +359,9 @@ void GrGLShaderBuilder::getShader(ShaderType type, SkString* shaderStr) const {
|
||||
this->appendUniformDecls(kVertex_ShaderType, shaderStr);
|
||||
this->appendDecls(fVSAttrs, shaderStr);
|
||||
this->appendDecls(fVSOutputs, shaderStr);
|
||||
shaderStr->append("void main() {\n");
|
||||
shaderStr->append(fVSCode);
|
||||
shaderStr->append("}\n");
|
||||
break;
|
||||
case kGeometry_ShaderType:
|
||||
if (fUsesGS) {
|
||||
@ -367,7 +369,9 @@ void GrGLShaderBuilder::getShader(ShaderType type, SkString* shaderStr) const {
|
||||
shaderStr->append(fGSHeader);
|
||||
this->appendDecls(fGSInputs, shaderStr);
|
||||
this->appendDecls(fGSOutputs, shaderStr);
|
||||
shaderStr->append("void main() {\n");
|
||||
shaderStr->append(fGSCode);
|
||||
shaderStr->append("}\n");
|
||||
} else {
|
||||
shaderStr->reset();
|
||||
}
|
||||
@ -383,7 +387,9 @@ void GrGLShaderBuilder::getShader(ShaderType type, SkString* shaderStr) const {
|
||||
GrAssert(k110_GrGLSLGeneration != fContext.glslGeneration() || fFSOutputs.empty());
|
||||
this->appendDecls(fFSOutputs, shaderStr);
|
||||
shaderStr->append(fFSFunctions);
|
||||
shaderStr->append("void main() {\n");
|
||||
shaderStr->append(fFSCode);
|
||||
shaderStr->append("}\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user