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

Side by Side Diff: src/gpu/GrProgramDesc.h

Issue 2358843002: Conditionally insert gl_PointSize into shaders. (Closed)
Patch Set: minor Created 4 years, 3 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 | « no previous file | src/gpu/GrProgramDesc.cpp » ('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 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 GrProgramDesc_DEFINED 8 #ifndef GrProgramDesc_DEFINED
9 #define GrProgramDesc_DEFINED 9 #define GrProgramDesc_DEFINED
10 10
(...skipping 10 matching lines...) Expand all
21 class GrProgramDesc { 21 class GrProgramDesc {
22 public: 22 public:
23 // Creates an uninitialized key that must be populated by GrGpu::buildProgra mDesc() 23 // Creates an uninitialized key that must be populated by GrGpu::buildProgra mDesc()
24 GrProgramDesc() {} 24 GrProgramDesc() {}
25 25
26 /** 26 /**
27 * Builds a program descriptor. Before the descriptor can be used, the client must call finalize 27 * Builds a program descriptor. Before the descriptor can be used, the client must call finalize
28 * on the returned GrProgramDesc. 28 * on the returned GrProgramDesc.
29 * 29 *
30 * @param GrPrimitiveProcessor The geometry 30 * @param GrPrimitiveProcessor The geometry
31 * @param hasPointSize Controls whether the shader will output a point size.
31 * @param GrPipeline The optimized drawstate. The descriptor will represent a program 32 * @param GrPipeline The optimized drawstate. The descriptor will represent a program
32 * which this optstate can use to draw with. The opts tate contains 33 * which this optstate can use to draw with. The opts tate contains
33 * general draw information, as well as the specific c olor, geometry, 34 * general draw information, as well as the specific c olor, geometry,
34 * and coverage stages which will be used to generate the GL Program for 35 * and coverage stages which will be used to generate the GL Program for
35 * this optstate. 36 * this optstate.
36 * @param GrGLSLCaps Capabilities of the GLSL backend. 37 * @param GrGLSLCaps Capabilities of the GLSL backend.
37 * @param GrProgramDesc The built and finalized descriptor 38 * @param GrProgramDesc The built and finalized descriptor
38 **/ 39 **/
39 static bool Build(GrProgramDesc*, 40 static bool Build(GrProgramDesc*,
40 const GrPrimitiveProcessor&, 41 const GrPrimitiveProcessor&,
42 bool hasPointSize,
41 const GrPipeline&, 43 const GrPipeline&,
42 const GrGLSLCaps&); 44 const GrGLSLCaps&);
43 45
44 // Returns this as a uint32_t array to be used as a key in the program cache . 46 // Returns this as a uint32_t array to be used as a key in the program cache .
45 const uint32_t* asKey() const { 47 const uint32_t* asKey() const {
46 return reinterpret_cast<const uint32_t*>(fKey.begin()); 48 return reinterpret_cast<const uint32_t*>(fKey.begin());
47 } 49 }
48 50
49 // Gets the number of bytes in asKey(). It will be a 4-byte aligned value. W hen comparing two 51 // Gets the number of bytes in asKey(). It will be a 4-byte aligned value. W hen comparing two
50 // keys the size of either key can be used with memcmp() since the lengths t hemselves begin the 52 // keys the size of either key can be used with memcmp() since the lengths t hemselves begin the
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 const uint32_t* bKey = b.asKey(); 87 const uint32_t* bKey = b.asKey();
86 for (int i = 0; i < l; ++i) { 88 for (int i = 0; i < l; ++i) {
87 if (aKey[i] != bKey[i]) { 89 if (aKey[i] != bKey[i]) {
88 return aKey[i] < bKey[i] ? true : false; 90 return aKey[i] < bKey[i] ? true : false;
89 } 91 }
90 } 92 }
91 return false; 93 return false;
92 } 94 }
93 95
94 struct KeyHeader { 96 struct KeyHeader {
95 // Set to uniquely identify the rt's origin, or 0 if the shader does not require this info.
96 uint8_t fSurfaceOriginKey;
97 // Set to uniquely identify the sample pattern, or 0 if the shader doesn 't use sample 97 // Set to uniquely identify the sample pattern, or 0 if the shader doesn 't use sample
98 // locations. 98 // locations.
99 uint8_t fSamplePatternKey; 99 uint8_t fSamplePatternKey;
100 // Set to uniquely idenitify any swizzling of the shader's output color( s). 100 // Set to uniquely idenitify any swizzling of the shader's output color( s).
101 uint8_t fOutputSwizzle; 101 uint8_t fOutputSwizzle;
102 uint8_t fSnapVerticesToPixelCenters; 102 uint8_t fColorFragmentProcessorCnt : 4;
103 int8_t fColorEffectCnt; 103 uint8_t fCoverageFragmentProcessorCnt : 4;
104 int8_t fCoverageEffectCnt; 104 // Set to uniquely identify the rt's origin, or 0 if the shader does not require this info.
105 uint8_t fIgnoresCoverage; 105 uint8_t fSurfaceOriginKey : 2;
106 uint8_t fIgnoresCoverage : 1;
107 uint8_t fSnapVerticesToPixelCenters : 1;
108 uint8_t fHasPointSize : 1;
109 uint8_t fPad : 3;
106 }; 110 };
107 111 GR_STATIC_ASSERT(sizeof(KeyHeader) == 4);
108 int numColorEffects() const {
109 return this->header().fColorEffectCnt;
110 }
111
112 int numCoverageEffects() const {
113 return this->header().fCoverageEffectCnt;
114 }
115
116 int numTotalEffects() const { return this->numColorEffects() + this->numCove rageEffects(); }
117 112
118 // This should really only be used internally, base classes should return th eir own headers 113 // This should really only be used internally, base classes should return th eir own headers
119 const KeyHeader& header() const { return *this->atOffset<KeyHeader, kHeaderO ffset>(); } 114 const KeyHeader& header() const { return *this->atOffset<KeyHeader, kHeaderO ffset>(); }
120 115
121 void finalize() { 116 void finalize() {
122 int keyLength = fKey.count(); 117 int keyLength = fKey.count();
123 SkASSERT(0 == (keyLength % 4)); 118 SkASSERT(0 == (keyLength % 4));
124 *(this->atOffset<uint32_t, GrProgramDesc::kLengthOffset>()) = SkToU32(ke yLength); 119 *(this->atOffset<uint32_t, GrProgramDesc::kLengthOffset>()) = SkToU32(ke yLength);
125 120
126 uint32_t* checksum = this->atOffset<uint32_t, GrProgramDesc::kChecksumOf fset>(); 121 uint32_t* checksum = this->atOffset<uint32_t, GrProgramDesc::kChecksumOf fset>();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 }; 159 };
165 160
166 SkSTArray<kPreAllocSize, uint8_t, true>& key() { return fKey; } 161 SkSTArray<kPreAllocSize, uint8_t, true>& key() { return fKey; }
167 const SkSTArray<kPreAllocSize, uint8_t, true>& key() const { return fKey; } 162 const SkSTArray<kPreAllocSize, uint8_t, true>& key() const { return fKey; }
168 163
169 private: 164 private:
170 SkSTArray<kPreAllocSize, uint8_t, true> fKey; 165 SkSTArray<kPreAllocSize, uint8_t, true> fKey;
171 }; 166 };
172 167
173 #endif 168 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrProgramDesc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698