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

Unified Diff: src/gpu/gl/builders/GrGLNvprProgramBuilder.cpp

Issue 611653002: Cleanup of shader building system (Closed) Base URL: https://skia.googlesource.com/skia.git@solo_gp
Patch Set: Created 6 years, 2 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/GrGLNvprProgramBuilder.h ('k') | src/gpu/gl/builders/GrGLProgramBuilder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/builders/GrGLNvprProgramBuilder.cpp
diff --git a/src/gpu/gl/builders/GrGLNvprProgramBuilder.cpp b/src/gpu/gl/builders/GrGLNvprProgramBuilder.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e5eae9d884cd8014cc0406946c1b37d0e20bfb31
--- /dev/null
+++ b/src/gpu/gl/builders/GrGLNvprProgramBuilder.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrGLNvprProgramBuilder.h"
+#include "../GrGpuGL.h"
+
+#define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X)
+#define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X)
+
+GrGLNvprProgramBuilder::GrGLNvprProgramBuilder(GrGpuGL* gpu,
+ const GrOptDrawState& optState,
+ const GrGLProgramDesc& desc)
+ : INHERITED(gpu, optState, desc)
+ , fSeparableVaryingInfos(kVarsPerBlock) {
+}
+
+void GrGLNvprProgramBuilder::emitTransforms(const GrProcessorStage& processorStage,
+ GrGLProcessor::TransformedCoordsArray* outCoords,
+ GrGLInstalledProcessors* installedProcessors) {
+ const GrProcessor* effect = processorStage.getProcessor();
+ int numTransforms = effect->numTransforms();
+
+ SkTArray<GrGLInstalledProcessors::Transform, true>& transforms =
+ installedProcessors->addTransforms();
+ transforms.push_back_n(numTransforms);
+
+ for (int t = 0; t < numTransforms; t++) {
+ GrSLType varyingType =
+ processorStage.isPerspectiveCoordTransform(t, false) ?
+ kVec3f_GrSLType :
+ kVec2f_GrSLType;
+
+ const char* varyingName = "MatrixCoord";
+ SkString suffixedVaryingName;
+ if (0 != t) {
+ suffixedVaryingName.append(varyingName);
+ suffixedVaryingName.appendf("_%i", t);
+ varyingName = suffixedVaryingName.c_str();
+ }
+ const char* vsVaryingName;
+ const char* fsVaryingName;
+ transforms[t].fHandle = this->addSeparableVarying(varyingType, varyingName,
+ &vsVaryingName, &fsVaryingName);
+ transforms[t].fType = varyingType;
+
+ SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords,
+ (SkString(fsVaryingName), varyingType));
+ }
+}
+
+GrGLInstalledProcessors::ShaderVarHandle
+GrGLNvprProgramBuilder::addSeparableVarying(GrSLType type,
+ const char* name,
+ const char** vsOutName,
+ const char** fsInName) {
+ addVarying(type, name, vsOutName, fsInName);
+ SeparableVaryingInfo& varying = fSeparableVaryingInfos.push_back();
+ varying.fVariable = fFS.fInputs.back();
+ return GrGLInstalledProcessors::ShaderVarHandle(fSeparableVaryingInfos.count() - 1);
+}
+
+void GrGLNvprProgramBuilder::resolveSeparableVaryings(GrGLuint programId) {
+ int count = fSeparableVaryingInfos.count();
+ for (int i = 0; i < count; ++i) {
+ GrGLint location;
+ GL_CALL_RET(location,
+ GetProgramResourceLocation(programId,
+ GR_GL_FRAGMENT_INPUT,
+ fSeparableVaryingInfos[i].fVariable.c_str()));
+ fSeparableVaryingInfos[i].fLocation = location;
+ }
+}
+
+GrGLProgram* GrGLNvprProgramBuilder::createProgram(GrGLuint programID) {
+ // this is just for nvpr es, which has separable varyings that are plugged in after
+ // building
+ this->resolveSeparableVaryings(programID);
+ return SkNEW_ARGS(GrGLNvprProgram, (fGpu, fDesc, fUniformHandles, programID, fUniforms,
+ fColorEffects, fCoverageEffects, fSeparableVaryingInfos));
+}
« no previous file with comments | « src/gpu/gl/builders/GrGLNvprProgramBuilder.h ('k') | src/gpu/gl/builders/GrGLProgramBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698