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

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

Issue 611653002: Cleanup of shader building system (Closed) Base URL: https://skia.googlesource.com/skia.git@solo_gp
Patch Set: more cleanup 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
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 "GrGLESNvprProgramBuilder.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 GrGLESNvprProgramBuilder::GrGLESNvprProgramBuilder(GrGpuGL* gpu, const GrGLProgr amDesc& desc)
15 : INHERITED(gpu, desc)
16 , fSeparableVaryingInfos(kVarsPerBlock) {
17 }
18
19 void GrGLESNvprProgramBuilder::emitTransforms(const GrProcessorStage& processorS tage,
20 GrGLProcessor::TransformedCoordsAr ray* outCoords,
21 GrGLInstalledProcessors* installed Processors) {
22 const GrProcessor* effect = processorStage.getProcessor();
23 int numTransforms = effect->numTransforms();
24
25 SkTArray<GrGLInstalledProcessors::Transform, true>& transforms =
26 installedProcessors->addTransforms();
27 transforms.push_back_n(numTransforms);
28
29 for (int t = 0; t < numTransforms; t++) {
30 GrSLType varyingType =
31 processorStage.isPerspectiveCoordTransform(t, false) ?
32 kVec3f_GrSLType :
33 kVec2f_GrSLType;
34
35 const char* varyingName = "MatrixCoord";
36 SkString suffixedVaryingName;
37 if (0 != t) {
38 suffixedVaryingName.append(varyingName);
39 suffixedVaryingName.appendf("_%i", t);
40 varyingName = suffixedVaryingName.c_str();
41 }
42 const char* vsVaryingName;
43 const char* fsVaryingName;
44 transforms[t].fHandle = this->addSeparableVarying(varyingType, varyingNa me,
45 &vsVaryingName, &fsVar yingName);
46 transforms[t].fType = varyingType;
47
48 SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords,
49 (SkString(fsVaryingName), varyingType));
50 }
51 }
52
53 GrGLInstalledProcessors::ShaderVarHandle
54 GrGLESNvprProgramBuilder::addSeparableVarying(GrSLType type,
55 const char* name,
56 const char** vsOutName,
57 const char** fsInName) {
58 addVarying(type, name, vsOutName, fsInName);
59 SeparableVaryingInfo& varying = fSeparableVaryingInfos.push_back();
60 varying.fVariable = fFS.fInputs.back();
61 return GrGLInstalledProcessors::ShaderVarHandle(fSeparableVaryingInfos.count () - 1);
62 }
63
64 void GrGLESNvprProgramBuilder::resolveSeparableVaryings(GrGLuint programId) {
65 int count = fSeparableVaryingInfos.count();
66 for (int i = 0; i < count; ++i) {
67 GrGLint location;
68 GL_CALL_RET(location,
69 GetProgramResourceLocation(programId,
70 GR_GL_FRAGMENT_INPUT,
71 fSeparableVaryingInfos[i].fVariab le.c_str()));
72 fSeparableVaryingInfos[i].fLocation = location;
73 }
74 }
75
76 GrGLProgram* GrGLESNvprProgramBuilder::createProgram(GrGLuint programID) {
77 return SkNEW_ARGS(GrGLESNvprProgram, (fGpu, fDesc, fUniformHandles, programI D, fUniforms,
78 fColorEffects, fCoverageEffects, fSepa rableVaryingInfos));
79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698