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

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: 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 8392)
+++ src/gpu/gl/GrGLShaderBuilder.cpp (working copy)
@@ -96,6 +96,7 @@
, fCtxInfo(ctxInfo)
, fUniformManager(uniformManager)
, fCurrentStageIdx(kNonStageIdx)
+ , fFSFeaturesAddedMask(0)
, fSetupFragPosition(false)
, fRTHeightUniform(GrGLUniformManager::kInvalidUniformHandle) {
@@ -111,6 +112,48 @@
}
}
+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;
+ }
+}
+
robertphillips 2013/03/26 17:26:05 "require" vs. "enable"
bsalomon 2013/04/01 17:49:31 require is more correct. We need the extension to
+void GrGLShaderBuilder::addFSFeature(uint32_t featureBit, const char* extensionName) {
+ if (!(featureBit & fFSFeaturesAddedMask)) {
+ fFSHeader.appendf("#extension %s: require\n", extensionName);
+ fFSFeaturesAddedMask |= featureBit;
+ }
+}
+
+
void GrGLShaderBuilder::codeAppendf(ShaderType type, const char format[], va_list args) {
SkString* string = NULL;
switch (type) {
@@ -334,9 +377,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",
@@ -453,9 +494,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);
@@ -465,7 +508,7 @@
break;
case kGeometry_ShaderType:
if (fUsesGS) {
- *shaderStr = fHeader;
+ *shaderStr = version;
shaderStr->append(fGSHeader);
this->appendDecls(fGSInputs, shaderStr);
this->appendDecls(fGSOutputs, shaderStr);
@@ -477,7 +520,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