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

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

Issue 14633007: Key shader on whether frag pos read is relative to top-left or bottom-left (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 const char* body, 186 const char* body,
187 SkString* outName); 187 SkString* outName);
188 188
189 /** Generates a EffectKey for the shader code based on the texture access pa rameters and the 189 /** Generates a EffectKey for the shader code based on the texture access pa rameters and the
190 capabilities of the GL context. This is useful for keying the shader pr ograms that may 190 capabilities of the GL context. This is useful for keying the shader pr ograms that may
191 have multiple representations, based on the type/format of textures used . */ 191 have multiple representations, based on the type/format of textures used . */
192 static GrBackendEffectFactory::EffectKey KeyForTextureAccess(const GrTexture Access&, 192 static GrBackendEffectFactory::EffectKey KeyForTextureAccess(const GrTexture Access&,
193 const GrGLCaps& ); 193 const GrGLCaps& );
194 194
195 typedef uint8_t DstReadKey; 195 typedef uint8_t DstReadKey;
196 typedef uint8_t FragPosKey;
196 197
197 /** Returns a key for adding code to read the copy-of-dst color in service of effects that 198 /** Returns a key for adding code to read the copy-of-dst color in service of effects that
198 require reading the dst. It must not return 0 because 0 indicates that there is no dst 199 require reading the dst. It must not return 0 because 0 indicates that there is no dst
199 copy read at all. */ 200 copy read at all. */
200 static DstReadKey KeyForDstRead(const GrTexture* dstCopy, const GrGLCaps&); 201 static DstReadKey KeyForDstRead(const GrTexture* dstCopy, const GrGLCaps&);
201 202
203 /** Returns a key for reading the fragment location. */
204 static FragPosKey KeyForFragmentPosition(const GrRenderTarget* dst, const Gr GLCaps&);
205
202 /** If texture swizzling is available using tex parameters then it is prefer red over mangling 206 /** If texture swizzling is available using tex parameters then it is prefer red over mangling
203 the generated shader code. This potentially allows greater reuse of cach ed shaders. */ 207 the generated shader code. This potentially allows greater reuse of cach ed shaders. */
204 static const GrGLenum* GetTexParamSwizzle(GrPixelConfig config, const GrGLCa ps& caps); 208 static const GrGLenum* GetTexParamSwizzle(GrPixelConfig config, const GrGLCa ps& caps);
205 209
206 /** Add a uniform variable to the current program, that has visibility in on e or more shaders. 210 /** Add a uniform variable to the current program, that has visibility in on e or more shaders.
207 visibility is a bitfield of ShaderType values indicating from which shad ers the uniform 211 visibility is a bitfield of ShaderType values indicating from which shad ers the uniform
208 should be accessible. At least one bit must be set. Geometry shader unif orms are not 212 should be accessible. At least one bit must be set. Geometry shader unif orms are not
209 supported at this time. The actual uniform name will be mangled. If outN ame is not NULL then 213 supported at this time. The actual uniform name will be mangled. If outN ame is not NULL then
210 it will refer to the final uniform name after return. Use the addUniform Array variant to add 214 it will refer to the final uniform name after return. Use the addUniform Array variant to add
211 an array of uniforms. 215 an array of uniforms.
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 void nameVariable(SkString* out, char prefix, const char* name); 421 void nameVariable(SkString* out, char prefix, const char* name);
418 422
419 // Interpretation of DstReadKey when generating code 423 // Interpretation of DstReadKey when generating code
420 enum { 424 enum {
421 kNoDstRead_DstReadKey = 0, 425 kNoDstRead_DstReadKey = 0,
422 kYesDstRead_DstReadKeyBit = 0x1, // Set if we do a dst-copy-read. 426 kYesDstRead_DstReadKeyBit = 0x1, // Set if we do a dst-copy-read.
423 kUseAlphaConfig_DstReadKeyBit = 0x2, // Set if dst-copy config is alpha only. 427 kUseAlphaConfig_DstReadKeyBit = 0x2, // Set if dst-copy config is alpha only.
424 kTopLeftOrigin_DstReadKeyBit = 0x4, // Set if dst-copy origin is top-le ft. 428 kTopLeftOrigin_DstReadKeyBit = 0x4, // Set if dst-copy origin is top-le ft.
425 }; 429 };
426 430
431 enum {
432 kNoFragPosRead_FragPosKey = 0, // The fragment positition wil l not be needed.
433 kTopLeftFragPosRead_FragPosKey = 0x1,// Read frag pos relative to t op-left.
434 kBottomLeftFragPosRead_FragPosKey = 0x2,// Read frag pos relative to b ottom-left.
435 };
436
427 const GrGLContextInfo& fCtxInfo; 437 const GrGLContextInfo& fCtxInfo;
428 GrGLUniformManager& fUniformManager; 438 GrGLUniformManager& fUniformManager;
429 uint32_t fFSFeaturesAddedMask; 439 uint32_t fFSFeaturesAddedMask;
430 SkString fFSFunctions; 440 SkString fFSFunctions;
431 SkString fFSExtensions; 441 SkString fFSExtensions;
432 442
433 bool fUsesGS; 443 bool fUsesGS;
434 444
435 SkString fFSCode; 445 SkString fFSCode;
436 SkString fVSCode; 446 SkString fVSCode;
437 SkString fGSCode; 447 SkString fGSCode;
438 448
439 bool fSetupFragPosition; 449 bool fSetupFragPosition;
440 TextureSampler fDstCopySampler; 450 TextureSampler fDstCopySampler;
441 451
442 GrGLUniformManager::UniformHandle fRTHeightUniform; 452 GrGLUniformManager::UniformHandle fRTHeightUniform;
443 GrGLUniformManager::UniformHandle fDstCopyTopLeftUniform; 453 GrGLUniformManager::UniformHandle fDstCopyTopLeftUniform;
444 GrGLUniformManager::UniformHandle fDstCopyScaleUniform; 454 GrGLUniformManager::UniformHandle fDstCopyScaleUniform;
445 455
456 bool fTopLeftFragPosRead;
457
446 SkSTArray<10, AttributePair, true> fEffectAttributes; 458 SkSTArray<10, AttributePair, true> fEffectAttributes;
447 459
448 GrGLShaderVar* fPositionVar; 460 GrGLShaderVar* fPositionVar;
449 GrGLShaderVar* fLocalCoordsVar; 461 GrGLShaderVar* fLocalCoordsVar;
450 462
451 }; 463 };
452 464
453 #endif 465 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698