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

Unified Diff: src/gpu/gl/builders/GrGLShaderBuilder.h

Issue 929503002: Multi-string shaders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: windows warning Created 5 years, 10 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/builders/GrGLSLPrettyPrint.cpp ('k') | src/gpu/gl/builders/GrGLShaderBuilder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/builders/GrGLShaderBuilder.h
diff --git a/src/gpu/gl/builders/GrGLShaderBuilder.h b/src/gpu/gl/builders/GrGLShaderBuilder.h
index 8b7b9f9974d9728d9cc52eae068f30163475acd7..3b06c05a00b32f6bb7471fef28cc64fcd5752246 100644
--- a/src/gpu/gl/builders/GrGLShaderBuilder.h
+++ b/src/gpu/gl/builders/GrGLShaderBuilder.h
@@ -8,6 +8,7 @@
#ifndef GrGLShaderBuilder_DEFINED
#define GrGLShaderBuilder_DEFINED
+#include "SkTArray.h"
#include "gl/GrGLProcessor.h"
#include "gl/GrGLProgramDesc.h"
#include "gl/GrGLProgramDataManager.h"
@@ -73,16 +74,16 @@ public:
void codeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) {
va_list args;
va_start(args, format);
- fCode.appendVAList(format, args);
+ this->code().appendVAList(format, args);
va_end(args);
}
- void codeAppend(const char* str) { fCode.append(str); }
+ void codeAppend(const char* str) { this->code().append(str); }
void codePrependf(const char format[], ...) SK_PRINTF_LIKE(2, 3) {
va_list args;
va_start(args, format);
- fCode.prependVAList(format, args);
+ this->code().prependVAList(format, args);
va_end(args);
}
@@ -138,8 +139,40 @@ protected:
*/
void addFeature(uint32_t featureBit, const char* extensionName);
- GrGLProgramBuilder* fProgramBuilder;
+ void nextStage() {
+ fShaderStrings.push_back();
+ fCompilerStrings.push_back(this->code().c_str());
+ fCompilerStringLengths.push_back((int)this->code().size());
+ fCodeIndex++;
+ }
+
+ SkString& versionDecl() { return fShaderStrings[kVersionDecl]; }
+ SkString& extensions() { return fShaderStrings[kExtensions]; }
+ SkString& precisionQualifier() { return fShaderStrings[kPrecisionQualifier]; }
+ SkString& uniforms() { return fShaderStrings[kUniforms]; }
+ SkString& inputs() { return fShaderStrings[kInputs]; }
+ SkString& outputs() { return fShaderStrings[kOutputs]; }
+ SkString& functions() { return fShaderStrings[kFunctions]; }
+ SkString& main() { return fShaderStrings[kMain]; }
+ SkString& code() { return fShaderStrings[fCodeIndex]; }
+ bool finalize(GrGLuint programId, GrGLenum type, SkTDArray<GrGLuint>* shaderIds);
+
+ enum {
+ kVersionDecl,
+ kExtensions,
+ kPrecisionQualifier,
+ kUniforms,
+ kInputs,
+ kOutputs,
+ kFunctions,
+ kMain,
+ kCode,
+ };
+ GrGLProgramBuilder* fProgramBuilder;
+ SkSTArray<kCode, const char*, true> fCompilerStrings;
+ SkSTArray<kCode, int, true> fCompilerStringLengths;
+ SkSTArray<kCode, SkString> fShaderStrings;
SkString fCode;
SkString fFunctions;
SkString fExtensions;
@@ -147,5 +180,9 @@ protected:
VarArray fInputs;
VarArray fOutputs;
uint32_t fFeaturesAddedMask;
+ int fCodeIndex;
+ bool fFinalized;
+
+ friend class GrGLProgramBuilder;
};
#endif
« no previous file with comments | « src/gpu/gl/builders/GrGLSLPrettyPrint.cpp ('k') | src/gpu/gl/builders/GrGLShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698