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

Side by Side Diff: bench/GLVertexAttributesBench.cpp

Issue 2288033003: Turned on SkSL->GLSL compiler (Closed)
Patch Set: changed <iostream> to <ostream> Created 4 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 | « bench/GLVec4ScalarBench.cpp ('k') | gyp/sksl.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "Benchmark.h" 8 #include "Benchmark.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkImageEncoder.h" 10 #include "SkImageEncoder.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 vshaderTxt.appendf("%s = %s;\n", oVars[i].c_str(), aVars[i].c_str()); 107 vshaderTxt.appendf("%s = %s;\n", oVars[i].c_str(), aVars[i].c_str());
108 } 108 }
109 109
110 // Passthrough position as a dummy 110 // Passthrough position as a dummy
111 for (uint32_t i = attribs; i < maxAttribs; i++) { 111 for (uint32_t i = attribs; i < maxAttribs; i++) {
112 vshaderTxt.appendf("%s = vec4(0, 0, 0, 1);\n", oVars[i].c_str()); 112 vshaderTxt.appendf("%s = vec4(0, 0, 0, 1);\n", oVars[i].c_str());
113 } 113 }
114 114
115 vshaderTxt.append("}\n"); 115 vshaderTxt.append("}\n");
116 116
117 const GrGLInterface* gl = ctx->interface();
118
119 // setup fragment shader 117 // setup fragment shader
120 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut _TypeModifier); 118 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut _TypeModifier);
121 SkString fshaderTxt(version); 119 SkString fshaderTxt(version);
122 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCa ps, &fshaderTxt); 120 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCa ps, &fshaderTxt);
123 121
124 const char* fsOutName; 122 const char* fsOutName;
125 if (glslCaps->mustDeclareFragmentShaderOutput()) { 123 if (glslCaps->mustDeclareFragmentShaderOutput()) {
126 oFragColor.appendDecl(glslCaps, &fshaderTxt); 124 oFragColor.appendDecl(glslCaps, &fshaderTxt);
127 fshaderTxt.append(";\n"); 125 fshaderTxt.append(";\n");
128 fsOutName = oFragColor.c_str(); 126 fsOutName = oFragColor.c_str();
129 } else { 127 } else {
130 fsOutName = "gl_FragColor"; 128 fsOutName = "sk_FragColor";
131 } 129 }
132 130
133 for (uint32_t i = 0; i < maxAttribs; i++) { 131 for (uint32_t i = 0; i < maxAttribs; i++) {
134 oVars[i].setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); 132 oVars[i].setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier);
135 oVars[i].appendDecl(glslCaps, &fshaderTxt); 133 oVars[i].appendDecl(glslCaps, &fshaderTxt);
136 fshaderTxt.append(";\n"); 134 fshaderTxt.append(";\n");
137 } 135 }
138 136
139 fshaderTxt.appendf( 137 fshaderTxt.appendf(
140 "void main()\n" 138 "void main()\n"
141 "{\n" 139 "{\n"
142 "%s = ", fsOutName); 140 "%s = ", fsOutName);
143 141
144 fshaderTxt.appendf("%s", oVars[0].c_str()); 142 fshaderTxt.appendf("%s", oVars[0].c_str());
145 for (uint32_t i = 1; i < maxAttribs; i++) { 143 for (uint32_t i = 1; i < maxAttribs; i++) {
146 fshaderTxt.appendf(" + %s", oVars[i].c_str()); 144 fshaderTxt.appendf(" + %s", oVars[i].c_str());
147 } 145 }
148 146
149 fshaderTxt.append(";\n" 147 fshaderTxt.append(";\n"
150 "}\n"); 148 "}\n");
151 149
152 return CreateProgram(gl, vshaderTxt.c_str(), fshaderTxt.c_str()); 150 return CreateProgram(ctx, vshaderTxt.c_str(), fshaderTxt.c_str());
153 } 151 }
154 152
155 //////////////////////////////////////////////////////////////////////////////// /////////////////// 153 //////////////////////////////////////////////////////////////////////////////// ///////////////////
156 154
157 void GLVertexAttributesBench::setup(const GrGLContext* ctx) { 155 void GLVertexAttributesBench::setup(const GrGLContext* ctx) {
158 const GrGLInterface* gl = ctx->interface(); 156 const GrGLInterface* gl = ctx->interface();
159 fTexture = SetupFramebuffer(gl, kScreenWidth, kScreenHeight); 157 fTexture = SetupFramebuffer(gl, kScreenWidth, kScreenHeight);
160 158
161 fProgram = setupShader(ctx, fAttribs, kMaxAttribs); 159 fProgram = setupShader(ctx, fAttribs, kMaxAttribs);
162 160
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 259
262 DEF_BENCH( return new GLVertexAttributesBench(0) ) 260 DEF_BENCH( return new GLVertexAttributesBench(0) )
263 DEF_BENCH( return new GLVertexAttributesBench(1) ) 261 DEF_BENCH( return new GLVertexAttributesBench(1) )
264 DEF_BENCH( return new GLVertexAttributesBench(2) ) 262 DEF_BENCH( return new GLVertexAttributesBench(2) )
265 DEF_BENCH( return new GLVertexAttributesBench(3) ) 263 DEF_BENCH( return new GLVertexAttributesBench(3) )
266 DEF_BENCH( return new GLVertexAttributesBench(4) ) 264 DEF_BENCH( return new GLVertexAttributesBench(4) )
267 DEF_BENCH( return new GLVertexAttributesBench(5) ) 265 DEF_BENCH( return new GLVertexAttributesBench(5) )
268 DEF_BENCH( return new GLVertexAttributesBench(6) ) 266 DEF_BENCH( return new GLVertexAttributesBench(6) )
269 DEF_BENCH( return new GLVertexAttributesBench(7) ) 267 DEF_BENCH( return new GLVertexAttributesBench(7) )
270 #endif 268 #endif
OLDNEW
« no previous file with comments | « bench/GLVec4ScalarBench.cpp ('k') | gyp/sksl.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698