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

Side by Side Diff: src/gpu/gl/GrGLShaderBuilder.h

Issue 367643004: Implement NVPR on GLES (Closed) Base URL: https://skia.googlesource.com/skia.git@02-path-program-fragment
Patch Set: Created 6 years, 5 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 2012 Google Inc. 2 * Copyright 2012 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 GrGLShaderBuilder_DEFINED 8 #ifndef GrGLShaderBuilder_DEFINED
9 #define GrGLShaderBuilder_DEFINED 9 #define GrGLShaderBuilder_DEFINED
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // We use the render target height to provide a y-down frag coord when s pecifying 53 // We use the render target height to provide a y-down frag coord when s pecifying
54 // origin_upper_left is not supported. 54 // origin_upper_left is not supported.
55 UniformHandle fRTHeightUni; 55 UniformHandle fRTHeightUni;
56 56
57 // Uniforms for computing texture coords to do the dst-copy lookup 57 // Uniforms for computing texture coords to do the dst-copy lookup
58 UniformHandle fDstCopyTopLeftUni; 58 UniformHandle fDstCopyTopLeftUni;
59 UniformHandle fDstCopyScaleUni; 59 UniformHandle fDstCopyScaleUni;
60 UniformHandle fDstCopySamplerUni; 60 UniformHandle fDstCopySamplerUni;
61 }; 61 };
62 62
63 struct GenProgramOutput { 63 struct GenProgramOutput {
Kimmo Kinnunen 2014/07/01 13:01:21 I think this is the correct concept to represent t
64 GenProgramOutput() 64 GenProgramOutput()
65 : fColorEffects(NULL) 65 : fColorEffects(NULL)
66 , fCoverageEffects(NULL) 66 , fCoverageEffects(NULL)
67 , fHasVertexShader(false) 67 , fHasVertexShader(false)
68 , fTexCoordSetCnt(0) 68 , fTexCoordSetCnt(0)
69 , fProgramID(0) {} 69 , fProgramID(0) {}
70 70
71 GenProgramOutput(const GenProgramOutput& other) { 71 GenProgramOutput(const GenProgramOutput& other) {
72 *this = other; 72 *this = other;
73 } 73 }
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 GrGLShaderBuilder* fBuilder; 240 GrGLShaderBuilder* fBuilder;
241 }; 241 };
242 242
243 protected: 243 protected:
244 GrGLShaderBuilder(GrGpuGL*, GrGLUniformManager*, const GrGLProgramDesc&); 244 GrGLShaderBuilder(GrGpuGL*, GrGLUniformManager*, const GrGLProgramDesc&);
245 245
246 GrGpuGL* gpu() const { return fGpu; } 246 GrGpuGL* gpu() const { return fGpu; }
247 247
248 const GrGLProgramDesc& desc() const { return fDesc; } 248 const GrGLProgramDesc& desc() const { return fDesc; }
249 249
250 /** Add input/output variable declarations (i.e. 'varying') to the fragment shader. */
251 GrGLShaderVar& fsInputAppend() { return fFSInputs.push_back(); }
252
253 // Helper for emitEffects(). 250 // Helper for emitEffects().
254 void createAndEmitEffects(GrGLProgramEffectsBuilder*, 251 void createAndEmitEffects(GrGLProgramEffectsBuilder*,
255 const GrEffectStage* effectStages[], 252 const GrEffectStage* effectStages[],
256 const EffectKey effectKeys[], 253 const EffectKey effectKeys[],
257 int effectCnt, 254 int effectCnt,
258 GrGLSLExpr4* inOutFSColor); 255 GrGLSLExpr4* inOutFSColor);
259 256
260 // Generates a name for a variable. The generated string will be name prefix ed by the prefix 257 // Generates a name for a variable. The generated string will be name prefix ed by the prefix
261 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp ecific if we're 258 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp ecific if we're
262 // generating stage code. 259 // generating stage code.
263 void nameVariable(SkString* out, char prefix, const char* name); 260 void nameVariable(SkString* out, char prefix, const char* name);
264 261
265 virtual bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint> * shaderIds) const; 262 virtual bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint> * shaderIds) const;
266 263
267 virtual void bindProgramLocations(GrGLuint programId) const; 264 virtual void bindProgramLocations(GrGLuint programId) const;
268 265
269 void appendDecls(const VarArray&, SkString*) const; 266 void appendDecls(const VarArray&, SkString*) const;
270 void appendUniformDecls(ShaderVisibility, SkString*) const; 267 void appendUniformDecls(ShaderVisibility, SkString*) const;
271 268
272 const GenProgramOutput& getOutput() const { return fOutput; } 269 const GenProgramOutput& getOutput() const { return fOutput; }
273 270
274 GenProgramOutput fOutput; 271 GenProgramOutput fOutput;
272 VarArray fFSInputs;
273 SkAutoTUnref<GrGLUniformManager> fUniformManager;
275 274
276 private: 275 private:
277 class CodeStage : SkNoncopyable { 276 class CodeStage : SkNoncopyable {
278 public: 277 public:
279 CodeStage() : fNextIndex(0), fCurrentIndex(-1), fEffectStage(NULL) {} 278 CodeStage() : fNextIndex(0), fCurrentIndex(-1), fEffectStage(NULL) {}
280 279
281 bool inStageCode() const { 280 bool inStageCode() const {
282 this->validate(); 281 this->validate();
283 return NULL != fEffectStage; 282 return NULL != fEffectStage;
284 } 283 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 }; 388 };
390 389
391 enum { 390 enum {
392 kNoFragPosRead_FragPosKey = 0, // The fragment positition wil l not be needed. 391 kNoFragPosRead_FragPosKey = 0, // The fragment positition wil l not be needed.
393 kTopLeftFragPosRead_FragPosKey = 0x1,// Read frag pos relative to t op-left. 392 kTopLeftFragPosRead_FragPosKey = 0x1,// Read frag pos relative to t op-left.
394 kBottomLeftFragPosRead_FragPosKey = 0x2,// Read frag pos relative to b ottom-left. 393 kBottomLeftFragPosRead_FragPosKey = 0x2,// Read frag pos relative to b ottom-left.
395 }; 394 };
396 395
397 const GrGLProgramDesc& fDesc; 396 const GrGLProgramDesc& fDesc;
398 GrGpuGL* fGpu; 397 GrGpuGL* fGpu;
399 SkAutoTUnref<GrGLUniformManager> fUniformManager;
400 uint32_t fFSFeaturesAddedMask; 398 uint32_t fFSFeaturesAddedMask;
401 SkString fFSFunctions; 399 SkString fFSFunctions;
402 SkString fFSExtensions; 400 SkString fFSExtensions;
403 VarArray fFSInputs;
404 VarArray fFSOutputs; 401 VarArray fFSOutputs;
405 GrGLUniformManager::BuilderUniformArray fUniforms; 402 GrGLUniformManager::BuilderUniformArray fUniforms;
406 403
407 SkString fFSCode; 404 SkString fFSCode;
408 405
409 bool fSetupFragPosition; 406 bool fSetupFragPosition;
410 bool fTopLeftFragPosRead; 407 bool fTopLeftFragPosRead;
411 408
412 bool fHasCustomColorOutput; 409 bool fHasCustomColorOutput;
413 bool fHasSecondaryOutput; 410 bool fHasSecondaryOutput;
(...skipping 17 matching lines...) Expand all
431 428
432 void vsCodeAppend(const char* str) { fVSCode.append(str); } 429 void vsCodeAppend(const char* str) { fVSCode.append(str); }
433 430
434 /** Add a vertex attribute to the current program that is passed in from the vertex data. 431 /** Add a vertex attribute to the current program that is passed in from the vertex data.
435 Returns false if the attribute was already there, true otherwise. */ 432 Returns false if the attribute was already there, true otherwise. */
436 bool addAttribute(GrSLType type, const char* name); 433 bool addAttribute(GrSLType type, const char* name);
437 434
438 /** Add a varying variable to the current program to pass values between vert ex and fragment 435 /** Add a varying variable to the current program to pass values between vert ex and fragment
439 shaders. If the last two parameters are non-NULL, they are filled in wit h the name 436 shaders. If the last two parameters are non-NULL, they are filled in wit h the name
440 generated. */ 437 generated. */
441 void addVarying(GrSLType type, 438 GrGLUniformManager::FragmentInputHandle addVarying(GrSLType type,
442 const char* name, 439 const char* name,
443 const char** vsOutName = NULL, 440 const char** vsOutName = NULL,
444 const char** fsInName = NULL); 441 const char** fsInName = N ULL);
442
443 void addFragmentInput(const char* fsName);
445 444
446 /** Returns a vertex attribute that represents the vertex position in the VS . This is the 445 /** Returns a vertex attribute that represents the vertex position in the VS . This is the
447 pre-matrix position and is commonly used by effects to compute texture c oords via a matrix. 446 pre-matrix position and is commonly used by effects to compute texture c oords via a matrix.
448 */ 447 */
449 const GrGLShaderVar& positionAttribute() const { return *fPositionVar; } 448 const GrGLShaderVar& positionAttribute() const { return *fPositionVar; }
450 449
451 /** Returns a vertex attribute that represents the local coords in the VS. T his may be the same 450 /** Returns a vertex attribute that represents the local coords in the VS. T his may be the same
452 as positionAttribute() or it may not be. It depends upon whether the ren dering code 451 as positionAttribute() or it may not be. It depends upon whether the ren dering code
453 specified explicit local coords or not in the GrDrawState. */ 452 specified explicit local coords or not in the GrDrawState. */
454 const GrGLShaderVar& localCoordsAttribute() const { return *fLocalCoordsVar; } 453 const GrGLShaderVar& localCoordsAttribute() const { return *fLocalCoordsVar; }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 const EffectKey effectKeys[ ], 512 const EffectKey effectKeys[ ],
514 int effectCnt, 513 int effectCnt,
515 GrGLSLExpr4* inOutFSColor) SK_OVERRIDE; 514 GrGLSLExpr4* inOutFSColor) SK_OVERRIDE;
516 515
517 virtual void emitCodeAfterEffects() SK_OVERRIDE {} 516 virtual void emitCodeAfterEffects() SK_OVERRIDE {}
518 517
519 typedef GrGLShaderBuilder INHERITED; 518 typedef GrGLShaderBuilder INHERITED;
520 }; 519 };
521 520
522 #endif 521 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698