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

Unified Diff: src/gpu/gl/GrGLShaderBuilder.cpp

Issue 12668019: Make GrGLShaderBuilder responsible for enabling GLSL extensions (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: sync to TOT Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLShaderBuilder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLShaderBuilder.cpp
===================================================================
--- src/gpu/gl/GrGLShaderBuilder.cpp (revision 8458)
+++ src/gpu/gl/GrGLShaderBuilder.cpp (working copy)
@@ -104,6 +104,7 @@
, fCtxInfo(ctxInfo)
, fUniformManager(uniformManager)
, fCurrentStageIdx(kNonStageIdx)
+ , fFSFeaturesAddedMask(0)
#if GR_GL_EXPERIMENTAL_GS
, fUsesGS(desc.fExperimentalGS)
#else
@@ -157,6 +158,47 @@
}
}
+bool GrGLShaderBuilder::enableFeature(GLSLFeature feature) {
+ switch (feature) {
+ case kStandardDerivatives_GLSLFeature:
+ if (!fCtxInfo.caps()->shaderDerivativeSupport()) {
+ return false;
+ }
+ if (kES2_GrGLBinding == fCtxInfo.binding()) {
+ this->addFSFeature(1 << kStandardDerivatives_GLSLFeature,
+ "GL_OES_standard_derivatives");
+ }
+ return true;
+ default:
+ GrCrash("Unexpected GLSLFeature requested.");
+ return false;
+ }
+}
+
+bool GrGLShaderBuilder::enablePrivateFeature(GLSLPrivateFeature feature) {
+ switch (feature) {
+ case kFragCoordConventions_GLSLPrivateFeature:
+ if (!fCtxInfo.caps()->fragCoordConventionsSupport()) {
+ return false;
+ }
+ if (fCtxInfo.glslGeneration() < k150_GrGLSLGeneration) {
+ this->addFSFeature(1 << kFragCoordConventions_GLSLPrivateFeature,
+ "GL_ARB_fragment_coord_conventions");
+ }
+ return true;
+ default:
+ GrCrash("Unexpected GLSLPrivateFeature requested.");
+ return false;
+ }
+}
+
+void GrGLShaderBuilder::addFSFeature(uint32_t featureBit, const char* extensionName) {
+ if (!(featureBit & fFSFeaturesAddedMask)) {
+ fFSHeader.appendf("#extension %s: require\n", extensionName);
+ fFSFeaturesAddedMask |= featureBit;
+ }
+}
+
const char* GrGLShaderBuilder::dstColor() const {
if (fDstCopySampler.isInitialized()) {
return kDstColorName;
@@ -388,9 +430,7 @@
#if 1
if (fCtxInfo.caps()->fragCoordConventionsSupport()) {
if (!fSetupFragPosition) {
- if (fCtxInfo.glslGeneration() < k150_GrGLSLGeneration) {
- fFSHeader.append("#extension GL_ARB_fragment_coord_conventions: require\n");
- }
+ SkAssertResult(this->enablePrivateFeature(kFragCoordConventions_GLSLPrivateFeature));
fFSInputs.push_back().set(kVec4f_GrSLType,
GrGLShaderVar::kIn_TypeModifier,
"gl_FragCoord",
@@ -507,9 +547,11 @@
}
void GrGLShaderBuilder::getShader(ShaderType type, SkString* shaderStr) const {
+ const char* version = GrGetGLSLVersionDecl(fCtxInfo.binding(), fCtxInfo.glslGeneration());
+
switch (type) {
case kVertex_ShaderType:
- *shaderStr = fHeader;
+ *shaderStr = version;
this->appendUniformDecls(kVertex_ShaderType, shaderStr);
this->appendDecls(fVSAttrs, shaderStr);
this->appendDecls(fVSOutputs, shaderStr);
@@ -519,7 +561,7 @@
break;
case kGeometry_ShaderType:
if (fUsesGS) {
- *shaderStr = fHeader;
+ *shaderStr = version;
shaderStr->append(fGSHeader);
this->appendDecls(fGSInputs, shaderStr);
this->appendDecls(fGSOutputs, shaderStr);
@@ -531,7 +573,7 @@
}
break;
case kFragment_ShaderType:
- *shaderStr = fHeader;
+ *shaderStr = version;
append_default_precision_qualifier(kDefaultFragmentPrecision,
fCtxInfo.binding(),
shaderStr);
« no previous file with comments | « src/gpu/gl/GrGLShaderBuilder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698