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

Side by Side Diff: src/gpu/gl/builders/GrGLProgramBuilder.h

Issue 1434483002: Add addFragPosUniform to GrGLrogramBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 #ifndef GrGLProgramBuilder_DEFINED 8 #ifndef GrGLProgramBuilder_DEFINED
9 #define GrGLProgramBuilder_DEFINED 9 #define GrGLProgramBuilder_DEFINED
10 10
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 const char** outName = nullptr) { 61 const char** outName = nullptr) {
62 return this->addUniformArray(visibility, type, precision, name, 0, outNa me); 62 return this->addUniformArray(visibility, type, precision, name, 0, outNa me);
63 } 63 }
64 64
65 virtual UniformHandle addUniformArray( 65 virtual UniformHandle addUniformArray(
66 uint32_t visibility, 66 uint32_t visibility,
67 GrSLType type, 67 GrSLType type,
68 GrSLPrecision precision, 68 GrSLPrecision precision,
69 const char* name, 69 const char* name,
70 int arrayCount, 70 int arrayCount,
71 const char** outName = nullptr) = 0; 71 const char** outName = nullptr) {
72 return this->internalAddUniformArray(visibility, type, precision, name, true, arrayCount,
73 outName);
74 }
75
76 UniformHandle addFragPosUniform(uint32_t visibility,
joshualitt 2015/11/04 21:50:52 However you want to handle this, it should be priv
egdaniel 2015/11/05 21:49:59 Done.
77 GrSLType type,
78 GrSLPrecision precision,
79 const char* name,
80 const char** outName) {
81 return this->internalAddUniformArray(visibility, type, precision, name, false, 0, outName);
82 }
83
72 84
73 virtual const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const = 0 ; 85 virtual const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const = 0 ;
74 86
75 /** 87 /**
76 * Shortcut for getUniformVariable(u).c_str() 88 * Shortcut for getUniformVariable(u).c_str()
77 */ 89 */
78 virtual const char* getUniformCStr(UniformHandle u) const = 0; 90 virtual const char* getUniformCStr(UniformHandle u) const = 0;
79 91
80 virtual const GrGLContextInfo& ctxInfo() const = 0; 92 virtual const GrGLContextInfo& ctxInfo() const = 0;
81 93
82 virtual const GrGLSLCaps* glslCaps() const = 0; 94 virtual const GrGLSLCaps* glslCaps() const = 0;
83 95
84 virtual GrGLGpu* gpu() const = 0; 96 virtual GrGLGpu* gpu() const = 0;
85 97
86 /* 98 /*
87 * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE 99 * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE
88 */ 100 */
101 private:
102 virtual UniformHandle internalAddUniformArray(
103 uint32_t visibility,
104 GrSLType type,
105 GrSLPrecision precision,
106 const char* name,
107 bool mangleName,
108 int arrayCount,
109 const char** outName) = 0;
89 }; 110 };
90 111
91 // TODO move this into GrGLGPBuilder and move them both out of this file 112 // TODO move this into GrGLGPBuilder and move them both out of this file
92 class GrGLVarying { 113 class GrGLVarying {
93 public: 114 public:
94 bool vsVarying() const { return kVertToFrag_Varying == fVarying || 115 bool vsVarying() const { return kVertToFrag_Varying == fVarying ||
95 kVertToGeo_Varying == fVarying; } 116 kVertToGeo_Varying == fVarying; }
96 bool fsVarying() const { return kVertToFrag_Varying == fVarying || 117 bool fsVarying() const { return kVertToFrag_Varying == fVarying ||
97 kGeoToFrag_Varying == fVarying; } 118 kGeoToFrag_Varying == fVarying; }
98 const char* vsOut() const { return fVsOut; } 119 const char* vsOut() const { return fVsOut; }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 public: 252 public:
232 typedef GrGpu::DrawArgs DrawArgs; 253 typedef GrGpu::DrawArgs DrawArgs;
233 /** Generates a shader program. 254 /** Generates a shader program.
234 * 255 *
235 * The program implements what is specified in the stages given as input. 256 * The program implements what is specified in the stages given as input.
236 * After successful generation, the builder result objects are available 257 * After successful generation, the builder result objects are available
237 * to be used. 258 * to be used.
238 * @return true if generation was successful. 259 * @return true if generation was successful.
239 */ 260 */
240 static GrGLProgram* CreateProgram(const DrawArgs&, GrGLGpu*); 261 static GrGLProgram* CreateProgram(const DrawArgs&, GrGLGpu*);
241 262
joshualitt 2015/11/04 21:50:52 This should be private
egdaniel 2015/11/05 21:49:59 Done.
242 UniformHandle addUniformArray(uint32_t visibility, 263 UniformHandle internalAddUniformArray(uint32_t visibility,
243 GrSLType type, 264 GrSLType type,
244 GrSLPrecision precision, 265 GrSLPrecision precision,
245 const char* name, 266 const char* name,
246 int arrayCount, 267 bool mangleName,
247 const char** outName) override; 268 int arrayCount,
269 const char** outName) override;
248 270
249 const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const override { 271 const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const override {
250 return fUniforms[u.toIndex()].fVariable; 272 return fUniforms[u.toIndex()].fVariable;
251 } 273 }
252 274
253 const char* getUniformCStr(UniformHandle u) const override { 275 const char* getUniformCStr(UniformHandle u) const override {
254 return this->getUniformVariable(u).c_str(); 276 return this->getUniformVariable(u).c_str();
255 } 277 }
256 278
257 const GrGLContextInfo& ctxInfo() const override; 279 const GrGLContextInfo& ctxInfo() const override;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 315
294 GrGLProgramBuilder(GrGLGpu*, const DrawArgs&); 316 GrGLProgramBuilder(GrGLGpu*, const DrawArgs&);
295 317
296 const GrPrimitiveProcessor& primitiveProcessor() const { return *fArgs.fPrim itiveProcessor; } 318 const GrPrimitiveProcessor& primitiveProcessor() const { return *fArgs.fPrim itiveProcessor; }
297 const GrPipeline& pipeline() const { return *fArgs.fPipeline; } 319 const GrPipeline& pipeline() const { return *fArgs.fPipeline; }
298 const GrProgramDesc& desc() const { return *fArgs.fDesc; } 320 const GrProgramDesc& desc() const { return *fArgs.fDesc; }
299 const GrProgramDesc::KeyHeader& header() const { return fArgs.fDesc->header( ); } 321 const GrProgramDesc::KeyHeader& header() const { return fArgs.fDesc->header( ); }
300 322
301 // Generates a name for a variable. The generated string will be name prefix ed by the prefix 323 // Generates a name for a variable. The generated string will be name prefix ed by the prefix
302 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp ecific if we're 324 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp ecific if we're
303 // generating stage code. 325 // generating stage code and mangle is true.
304 void nameVariable(SkString* out, char prefix, const char* name); 326 void nameVariable(SkString* out, char prefix, const char* name, bool mangle = true);
305 // Generates a possibly mangled name for a stage variable and writes it to t he fragment shader. 327 // Generates a possibly mangled name for a stage variable and writes it to t he fragment shader.
306 // If GrGLSLExpr4 has a valid name then it will use that instead 328 // If GrGLSLExpr4 has a valid name then it will use that instead
307 void nameExpression(GrGLSLExpr4*, const char* baseName); 329 void nameExpression(GrGLSLExpr4*, const char* baseName);
308 bool emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr4* inputCoverage ); 330 bool emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr4* inputCoverage );
309 void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOu t); 331 void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOu t);
310 void emitAndInstallProc(const GrFragmentProcessor&, 332 void emitAndInstallProc(const GrFragmentProcessor&,
311 int index, 333 int index,
312 const GrGLSLExpr4& input, 334 const GrGLSLExpr4& input,
313 GrGLSLExpr4* output); 335 GrGLSLExpr4* output);
314 336
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // reset is called by program creator between each processor's emit code. I t increments the 377 // reset is called by program creator between each processor's emit code. I t increments the
356 // stage offset for variable name mangling, and also ensures verfication var iables in the 378 // stage offset for variable name mangling, and also ensures verfication var iables in the
357 // fragment shader are cleared. 379 // fragment shader are cleared.
358 void reset() { 380 void reset() {
359 this->enterStage(); 381 this->enterStage();
360 this->addStage(); 382 this->addStage();
361 fFS.reset(); 383 fFS.reset();
362 } 384 }
363 void addStage() { fStageIndex++; } 385 void addStage() { fStageIndex++; }
364 386
365 // This simple class exits the stage and then restores the stage when it goe s out of scope
366 class AutoStageRestore {
367 public:
368 AutoStageRestore(GrGLProgramBuilder* pb)
369 : fPB(pb), fOutOfStage(pb->fOutOfStage) { pb->exitStage(); }
370 ~AutoStageRestore() { fPB->fOutOfStage = fOutOfStage; }
371 private:
372 GrGLProgramBuilder* fPB;
373 bool fOutOfStage;
374 };
375 class AutoStageAdvance { 387 class AutoStageAdvance {
376 public: 388 public:
377 AutoStageAdvance(GrGLProgramBuilder* pb) 389 AutoStageAdvance(GrGLProgramBuilder* pb)
378 : fPB(pb) { 390 : fPB(pb) {
379 fPB->reset(); 391 fPB->reset();
380 // Each output to the fragment processor gets its own code section 392 // Each output to the fragment processor gets its own code section
381 fPB->fFS.nextStage(); 393 fPB->fFS.nextStage();
382 } 394 }
383 ~AutoStageAdvance() { fPB->exitStage(); } 395 ~AutoStageAdvance() { fPB->exitStage(); }
384 private: 396 private:
(...skipping 26 matching lines...) Expand all
411 GrGLPrimitiveProcessor::TransformsOut fOutCoords; 423 GrGLPrimitiveProcessor::TransformsOut fOutCoords;
412 SkTArray<UniformHandle> fSamplerUniforms; 424 SkTArray<UniformHandle> fSamplerUniforms;
413 SeparableVaryingInfoArray fSeparableVaryingInfos; 425 SeparableVaryingInfoArray fSeparableVaryingInfos;
414 426
415 friend class GrGLShaderBuilder; 427 friend class GrGLShaderBuilder;
416 friend class GrGLVertexBuilder; 428 friend class GrGLVertexBuilder;
417 friend class GrGLFragmentShaderBuilder; 429 friend class GrGLFragmentShaderBuilder;
418 friend class GrGLGeometryBuilder; 430 friend class GrGLGeometryBuilder;
419 }; 431 };
420 #endif 432 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698