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

Side by Side Diff: src/gpu/gl/builders/GrGLGeometryShaderBuilder.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
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrGLGeometryShaderBuilder.h" 8 #include "GrGLGeometryShaderBuilder.h"
9 #include "GrGLShaderStringBuilder.h" 9 #include "GrGLShaderStringBuilder.h"
10 #include "GrGLProgramBuilder.h" 10 #include "GrGLProgramBuilder.h"
11 #include "../GrGpuGL.h" 11 #include "../GrGpuGL.h"
12 12
13 GrGLGeometryBuilder::GrGLGeometryBuilder(GrGLProgramBuilder* program) 13 GrGLGeometryShaderBuilder::GrGLGeometryShaderBuilder(GrGLFullProgramBuilder* pro gram)
14 : INHERITED(program) { 14 : INHERITED(program) {
15 15
16 } 16 }
17 17
18 void GrGLGeometryBuilder::addVarying(GrSLType type, 18 void GrGLGeometryShaderBuilder::addVarying(GrSLType type,
19 const char* name, 19 const char* name,
20 const char** gsOutName) { 20 const char** gsOutName) {
21 // if we have a GS take each varying in as an array 21 // if we have a GS take each varying in as an array
22 // and output as non-array. 22 // and output as non-array.
23 fInputs.push_back(); 23 fInputs.push_back();
24 fInputs.back().setType(type); 24 fInputs.back().setType(type);
25 fInputs.back().setTypeModifier(GrGLShaderVar::kVaryingIn_TypeModifier); 25 fInputs.back().setTypeModifier(GrGLShaderVar::kVaryingIn_TypeModifier);
26 fInputs.back().setUnsizedArray(); 26 fInputs.back().setUnsizedArray();
27 *fInputs.back().accessName() = name; 27 *fInputs.back().accessName() = name;
28 fOutputs.push_back(); 28 fOutputs.push_back();
29 fOutputs.back().setType(type); 29 fOutputs.back().setType(type);
30 fOutputs.back().setTypeModifier(GrGLShaderVar::kVaryingOut_TypeModifier); 30 fOutputs.back().setTypeModifier(GrGLShaderVar::kVaryingOut_TypeModifier);
31 fProgramBuilder->nameVariable(fOutputs.back().accessName(), 'g', name); 31 fProgramBuilder->nameVariable(fOutputs.back().accessName(), 'g', name);
32 if (gsOutName) { 32 if (gsOutName) {
33 *gsOutName = fOutputs.back().getName().c_str(); 33 *gsOutName = fOutputs.back().getName().c_str();
34 } 34 }
35 } 35 }
36 36
37 37
38 bool GrGLGeometryBuilder::compileAndAttachShaders(GrGLuint programId, 38 bool GrGLGeometryShaderBuilder::compileAndAttachShaders(GrGLuint programId,
39 SkTDArray<GrGLuint>* shaderIds) const { 39 SkTDArray<GrGLuint>* shaderIds) const {
40 const GrGLContext& glCtx = fProgramBuilder->gpu()->glContext(); 40 const GrGLContext& glCtx = fProgramBuilder->gpu()->glContext();
41 SkASSERT(fProgramBuilder->ctxInfo().glslGeneration() >= k150_GrGLSLGeneratio n); 41 SkASSERT(fProgramBuilder->ctxInfo().glslGeneration() >= k150_GrGLSLGeneratio n);
42 SkString geomShaderSrc(GrGetGLSLVersionDecl(fProgramBuilder->ctxInfo())); 42 SkString geomShaderSrc(GrGetGLSLVersionDecl(fProgramBuilder->ctxInfo()));
43 geomShaderSrc.append("layout(triangles) in;\n" 43 geomShaderSrc.append("layout(triangles) in;\n"
44 "layout(triangle_strip, max_vertices = 6) out;\n"); 44 "layout(triangle_strip, max_vertices = 6) out;\n");
45 this->appendDecls(fInputs, &geomShaderSrc); 45 fProgramBuilder->appendDecls(fInputs, &geomShaderSrc);
46 this->appendDecls(fOutputs, &geomShaderSrc); 46 fProgramBuilder->appendDecls(fOutputs, &geomShaderSrc);
47 geomShaderSrc.append("void main() {\n"); 47 geomShaderSrc.append("void main() {\n");
48 geomShaderSrc.append("\tfor (int i = 0; i < 3; ++i) {\n" 48 geomShaderSrc.append("\tfor (int i = 0; i < 3; ++i) {\n"
49 "\t\tgl_Position = gl_in[i].gl_Position;\n"); 49 "\t\tgl_Position = gl_in[i].gl_Position;\n");
50 if (fProgramBuilder->desc().getHeader().fEmitsPointSize) { 50 if (fProgramBuilder->desc().getHeader().fEmitsPointSize) {
51 geomShaderSrc.append("\t\tgl_PointSize = 1.0;\n"); 51 geomShaderSrc.append("\t\tgl_PointSize = 1.0;\n");
52 } 52 }
53 SkASSERT(fInputs.count() == fOutputs.count()); 53 SkASSERT(fInputs.count() == fOutputs.count());
54 for (int i = 0; i < fInputs.count(); ++i) { 54 for (int i = 0; i < fInputs.count(); ++i) {
55 geomShaderSrc.appendf("\t\t%s = %s[i];\n", 55 geomShaderSrc.appendf("\t\t%s = %s[i];\n",
56 fOutputs[i].getName().c_str(), 56 fOutputs[i].getName().c_str(),
57 fInputs[i].getName().c_str()); 57 fInputs[i].getName().c_str());
58 } 58 }
59 geomShaderSrc.append("\t\tEmitVertex();\n" 59 geomShaderSrc.append("\t\tEmitVertex();\n"
60 "\t}\n" 60 "\t}\n"
61 "\tEndPrimitive();\n"); 61 "\tEndPrimitive();\n");
62 geomShaderSrc.append("}\n"); 62 geomShaderSrc.append("}\n");
63 GrGLuint geomShaderId = 63 GrGLuint geomShaderId =
64 GrGLCompileAndAttachShader(glCtx, programId, 64 GrGLCompileAndAttachShader(glCtx, programId,
65 GR_GL_GEOMETRY_SHADER, geomShaderSrc, 65 GR_GL_GEOMETRY_SHADER, geomShaderSrc,
66 fProgramBuilder->gpu()->gpuStats()); 66 fProgramBuilder->gpu()->gpuStats());
67 if (!geomShaderId) { 67 if (!geomShaderId) {
68 return false; 68 return false;
69 } 69 }
70 *shaderIds->append() = geomShaderId; 70 *shaderIds->append() = geomShaderId;
71 return true; 71 return true;
72 } 72 }
OLDNEW
« no previous file with comments | « src/gpu/gl/builders/GrGLGeometryShaderBuilder.h ('k') | src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698