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

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

Issue 674543004: OptState owns program descriptor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cleaup Created 6 years, 1 month 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"
(...skipping 30 matching lines...) Expand all
41 const GrGLContext& glCtx = fProgramBuilder->gpu()->glContext(); 41 const GrGLContext& glCtx = fProgramBuilder->gpu()->glContext();
42 SkASSERT(fProgramBuilder->ctxInfo().glslGeneration() >= k150_GrGLSLGeneratio n); 42 SkASSERT(fProgramBuilder->ctxInfo().glslGeneration() >= k150_GrGLSLGeneratio n);
43 SkString geomShaderSrc(GrGetGLSLVersionDecl(fProgramBuilder->ctxInfo())); 43 SkString geomShaderSrc(GrGetGLSLVersionDecl(fProgramBuilder->ctxInfo()));
44 geomShaderSrc.append("layout(triangles) in;\n" 44 geomShaderSrc.append("layout(triangles) in;\n"
45 "layout(triangle_strip, max_vertices = 6) out;\n"); 45 "layout(triangle_strip, max_vertices = 6) out;\n");
46 this->appendDecls(fInputs, &geomShaderSrc); 46 this->appendDecls(fInputs, &geomShaderSrc);
47 this->appendDecls(fOutputs, &geomShaderSrc); 47 this->appendDecls(fOutputs, &geomShaderSrc);
48 geomShaderSrc.append("void main() {\n"); 48 geomShaderSrc.append("void main() {\n");
49 geomShaderSrc.append("\tfor (int i = 0; i < 3; ++i) {\n" 49 geomShaderSrc.append("\tfor (int i = 0; i < 3; ++i) {\n"
50 "\t\tgl_Position = gl_in[i].gl_Position;\n"); 50 "\t\tgl_Position = gl_in[i].gl_Position;\n");
51 if (fProgramBuilder->desc().getHeader().fEmitsPointSize) { 51 if (fProgramBuilder->desc().header().fEmitsPointSize) {
52 geomShaderSrc.append("\t\tgl_PointSize = 1.0;\n"); 52 geomShaderSrc.append("\t\tgl_PointSize = 1.0;\n");
53 } 53 }
54 SkASSERT(fInputs.count() == fOutputs.count()); 54 SkASSERT(fInputs.count() == fOutputs.count());
55 for (int i = 0; i < fInputs.count(); ++i) { 55 for (int i = 0; i < fInputs.count(); ++i) {
56 geomShaderSrc.appendf("\t\t%s = %s[i];\n", 56 geomShaderSrc.appendf("\t\t%s = %s[i];\n",
57 fOutputs[i].getName().c_str(), 57 fOutputs[i].getName().c_str(),
58 fInputs[i].getName().c_str()); 58 fInputs[i].getName().c_str());
59 } 59 }
60 geomShaderSrc.append("\t\tEmitVertex();\n" 60 geomShaderSrc.append("\t\tEmitVertex();\n"
61 "\t}\n" 61 "\t}\n"
62 "\tEndPrimitive();\n"); 62 "\tEndPrimitive();\n");
63 geomShaderSrc.append("}\n"); 63 geomShaderSrc.append("}\n");
64 GrGLuint geomShaderId = 64 GrGLuint geomShaderId =
65 GrGLCompileAndAttachShader(glCtx, programId, 65 GrGLCompileAndAttachShader(glCtx, programId,
66 GR_GL_GEOMETRY_SHADER, geomShaderSrc, 66 GR_GL_GEOMETRY_SHADER, geomShaderSrc,
67 fProgramBuilder->gpu()->gpuStats()); 67 fProgramBuilder->gpu()->gpuStats());
68 if (!geomShaderId) { 68 if (!geomShaderId) {
69 return false; 69 return false;
70 } 70 }
71 *shaderIds->append() = geomShaderId; 71 *shaderIds->append() = geomShaderId;
72 return true; 72 return true;
73 } 73 }
OLDNEW
« no previous file with comments | « src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp ('k') | src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698