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

Side by Side Diff: src/gpu/gl/builders/GrGLNvprProgramBuilder.cpp

Issue 635533005: Revert of 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "GrGLNvprProgramBuilder.h"
9 #include "../GrGpuGL.h"
10
11 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X)
12 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X)
13
14 GrGLNvprProgramBuilder::GrGLNvprProgramBuilder(GrGpuGL* gpu,
15 const GrOptDrawState& optState,
16 const GrGLProgramDesc& desc)
17 : INHERITED(gpu, optState, desc)
18 , fSeparableVaryingInfos(kVarsPerBlock) {
19 }
20
21 void GrGLNvprProgramBuilder::emitTransforms(const GrProcessorStage& processorSta ge,
22 GrGLProcessor::TransformedCoordsArra y* outCoords,
23 GrGLInstalledProcessors* installedPr ocessors) {
24 const GrProcessor* effect = processorStage.getProcessor();
25 int numTransforms = effect->numTransforms();
26
27 SkTArray<GrGLInstalledProcessors::Transform, true>& transforms =
28 installedProcessors->addTransforms();
29 transforms.push_back_n(numTransforms);
30
31 for (int t = 0; t < numTransforms; t++) {
32 GrSLType varyingType =
33 processorStage.isPerspectiveCoordTransform(t, false) ?
34 kVec3f_GrSLType :
35 kVec2f_GrSLType;
36
37 const char* varyingName = "MatrixCoord";
38 SkString suffixedVaryingName;
39 if (0 != t) {
40 suffixedVaryingName.append(varyingName);
41 suffixedVaryingName.appendf("_%i", t);
42 varyingName = suffixedVaryingName.c_str();
43 }
44 const char* vsVaryingName;
45 const char* fsVaryingName;
46 transforms[t].fHandle = this->addSeparableVarying(varyingType, varyingNa me,
47 &vsVaryingName, &fsVar yingName);
48 transforms[t].fType = varyingType;
49
50 SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords,
51 (SkString(fsVaryingName), varyingType));
52 }
53 }
54
55 GrGLInstalledProcessors::ShaderVarHandle
56 GrGLNvprProgramBuilder::addSeparableVarying(GrSLType type,
57 const char* name,
58 const char** vsOutName,
59 const char** fsInName) {
60 addVarying(type, name, vsOutName, fsInName);
61 SeparableVaryingInfo& varying = fSeparableVaryingInfos.push_back();
62 varying.fVariable = fFS.fInputs.back();
63 return GrGLInstalledProcessors::ShaderVarHandle(fSeparableVaryingInfos.count () - 1);
64 }
65
66 void GrGLNvprProgramBuilder::resolveSeparableVaryings(GrGLuint programId) {
67 int count = fSeparableVaryingInfos.count();
68 for (int i = 0; i < count; ++i) {
69 GrGLint location;
70 GL_CALL_RET(location,
71 GetProgramResourceLocation(programId,
72 GR_GL_FRAGMENT_INPUT,
73 fSeparableVaryingInfos[i].fVariab le.c_str()));
74 fSeparableVaryingInfos[i].fLocation = location;
75 }
76 }
77
78 GrGLProgram* GrGLNvprProgramBuilder::createProgram(GrGLuint programID) {
79 // this is just for nvpr es, which has separable varyings that are plugged i n after
80 // building
81 this->resolveSeparableVaryings(programID);
82 return SkNEW_ARGS(GrGLNvprProgram, (fGpu, fDesc, fUniformHandles, programID, fUniforms,
83 fColorEffects, fCoverageEffects, fSepara bleVaryingInfos));
84 }
OLDNEW
« 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