зеркало из https://github.com/mozilla/moz-skia.git
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:
Родитель
4285accf5a
Коммит
d7bafb700c
|
@ -364,9 +364,8 @@ void GrGLProgram::genGeometryShader(GrGLShaderBuilder* segments) const {
|
||||||
GrAssert(fContextInfo.glslGeneration() >= k150_GrGLSLGeneration);
|
GrAssert(fContextInfo.glslGeneration() >= k150_GrGLSLGeneration);
|
||||||
segments->fGSHeader.append("layout(triangles) in;\n"
|
segments->fGSHeader.append("layout(triangles) in;\n"
|
||||||
"layout(triangle_strip, max_vertices = 6) out;\n");
|
"layout(triangle_strip, max_vertices = 6) out;\n");
|
||||||
segments->fGSCode.append("void main() {\n"
|
segments->fGSCode.append("\tfor (int i = 0; i < 3; ++i) {\n"
|
||||||
"\tfor (int i = 0; i < 3; ++i) {\n"
|
"\t\tgl_Position = gl_in[i].gl_Position;\n");
|
||||||
"\t\tgl_Position = gl_in[i].gl_Position;\n");
|
|
||||||
if (fDesc.fEmitsPointSize) {
|
if (fDesc.fEmitsPointSize) {
|
||||||
segments->fGSCode.append("\t\tgl_PointSize = 1.0;\n");
|
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"
|
segments->fGSCode.append("\t\tEmitVertex();\n"
|
||||||
"\t}\n"
|
"\t}\n"
|
||||||
"\tEndPrimitive();\n"
|
"\tEndPrimitive();\n");
|
||||||
"}\n");
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -571,9 +569,8 @@ bool GrGLProgram::genProgram(const GrCustomStage** customStages) {
|
||||||
GrGLShaderVar::kAttribute_TypeModifier,
|
GrGLShaderVar::kAttribute_TypeModifier,
|
||||||
POS_ATTR_NAME);
|
POS_ATTR_NAME);
|
||||||
|
|
||||||
builder.fVSCode.appendf("void main() {\n"
|
builder.fVSCode.appendf("\tvec3 pos3 = %s * vec3("POS_ATTR_NAME", 1);\n"
|
||||||
"\tvec3 pos3 = %s * vec3("POS_ATTR_NAME", 1);\n"
|
"\tgl_Position = vec4(pos3.xy, 0, pos3.z);\n",
|
||||||
"\tgl_Position = vec4(pos3.xy, 0, pos3.z);\n",
|
|
||||||
viewMName);
|
viewMName);
|
||||||
|
|
||||||
// incoming color to current stage being processed.
|
// 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.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
|
// add texture coordinates that are used to the list of vertex attr decls
|
||||||
SkString texCoordAttrs[GrDrawState::kMaxTexCoords];
|
SkString texCoordAttrs[GrDrawState::kMaxTexCoords];
|
||||||
for (int t = 0; t < GrDrawState::kMaxTexCoords; ++t) {
|
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
|
// insert GS
|
||||||
#if GR_DEBUG
|
#if GR_DEBUG
|
||||||
|
|
|
@ -359,7 +359,9 @@ void GrGLShaderBuilder::getShader(ShaderType type, SkString* shaderStr) const {
|
||||||
this->appendUniformDecls(kVertex_ShaderType, shaderStr);
|
this->appendUniformDecls(kVertex_ShaderType, shaderStr);
|
||||||
this->appendDecls(fVSAttrs, shaderStr);
|
this->appendDecls(fVSAttrs, shaderStr);
|
||||||
this->appendDecls(fVSOutputs, shaderStr);
|
this->appendDecls(fVSOutputs, shaderStr);
|
||||||
|
shaderStr->append("void main() {\n");
|
||||||
shaderStr->append(fVSCode);
|
shaderStr->append(fVSCode);
|
||||||
|
shaderStr->append("}\n");
|
||||||
break;
|
break;
|
||||||
case kGeometry_ShaderType:
|
case kGeometry_ShaderType:
|
||||||
if (fUsesGS) {
|
if (fUsesGS) {
|
||||||
|
@ -367,7 +369,9 @@ void GrGLShaderBuilder::getShader(ShaderType type, SkString* shaderStr) const {
|
||||||
shaderStr->append(fGSHeader);
|
shaderStr->append(fGSHeader);
|
||||||
this->appendDecls(fGSInputs, shaderStr);
|
this->appendDecls(fGSInputs, shaderStr);
|
||||||
this->appendDecls(fGSOutputs, shaderStr);
|
this->appendDecls(fGSOutputs, shaderStr);
|
||||||
|
shaderStr->append("void main() {\n");
|
||||||
shaderStr->append(fGSCode);
|
shaderStr->append(fGSCode);
|
||||||
|
shaderStr->append("}\n");
|
||||||
} else {
|
} else {
|
||||||
shaderStr->reset();
|
shaderStr->reset();
|
||||||
}
|
}
|
||||||
|
@ -383,7 +387,9 @@ void GrGLShaderBuilder::getShader(ShaderType type, SkString* shaderStr) const {
|
||||||
GrAssert(k110_GrGLSLGeneration != fContext.glslGeneration() || fFSOutputs.empty());
|
GrAssert(k110_GrGLSLGeneration != fContext.glslGeneration() || fFSOutputs.empty());
|
||||||
this->appendDecls(fFSOutputs, shaderStr);
|
this->appendDecls(fFSOutputs, shaderStr);
|
||||||
shaderStr->append(fFSFunctions);
|
shaderStr->append(fFSFunctions);
|
||||||
|
shaderStr->append("void main() {\n");
|
||||||
shaderStr->append(fFSCode);
|
shaderStr->append(fFSCode);
|
||||||
|
shaderStr->append("}\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче