OLD | NEW |
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 bool operator!= (const GrProgramDesc& other) const { | 49 bool operator!= (const GrProgramDesc& other) const { |
50 return !(*this == other); | 50 return !(*this == other); |
51 } | 51 } |
52 | 52 |
53 static bool Less(const GrProgramDesc& a, const GrProgramDesc& b) { | 53 static bool Less(const GrProgramDesc& a, const GrProgramDesc& b) { |
54 return memcmp(a.asKey(), b.asKey(), a.keyLength() & ~0x3) < 0; | 54 return memcmp(a.asKey(), b.asKey(), a.keyLength() & ~0x3) < 0; |
55 } | 55 } |
56 | 56 |
57 | 57 |
| 58 /////////////////////////////////////////////////////////////////////////// |
| 59 /// @name Stage Output Types |
| 60 //// |
| 61 |
| 62 enum PrimaryOutputType { |
| 63 // Modulate color and coverage, write result as the color output. |
| 64 kModulate_PrimaryOutputType, |
| 65 // Combines the coverage, dst, and color as coverage * color + (1 - cove
rage) * dst. This |
| 66 // can only be set if fDstReadKey is non-zero. |
| 67 kCombineWithDst_PrimaryOutputType, |
| 68 |
| 69 kPrimaryOutputTypeCnt, |
| 70 }; |
| 71 |
| 72 enum SecondaryOutputType { |
| 73 // There is no secondary output |
| 74 kNone_SecondaryOutputType, |
| 75 // Writes coverage as the secondary output. Only set if dual source blen
ding is supported |
| 76 // and primary output is kModulate. |
| 77 kCoverage_SecondaryOutputType, |
| 78 // Writes coverage * (1 - colorA) as the secondary output. Only set if d
ual source blending |
| 79 // is supported and primary output is kModulate. |
| 80 kCoverageISA_SecondaryOutputType, |
| 81 // Writes coverage * (1 - colorRGBA) as the secondary output. Only set i
f dual source |
| 82 // blending is supported and primary output is kModulate. |
| 83 kCoverageISC_SecondaryOutputType, |
| 84 |
| 85 kSecondaryOutputTypeCnt, |
| 86 }; |
| 87 |
58 // Specifies where the initial color comes from before the stages are applie
d. | 88 // Specifies where the initial color comes from before the stages are applie
d. |
59 enum ColorInput { | 89 enum ColorInput { |
60 kAllOnes_ColorInput, | 90 kAllOnes_ColorInput, |
61 kAttribute_ColorInput, | 91 kAttribute_ColorInput, |
62 kUniform_ColorInput, | 92 kUniform_ColorInput, |
63 | 93 |
64 kColorInputCnt | 94 kColorInputCnt |
65 }; | 95 }; |
66 | 96 |
67 struct KeyHeader { | 97 struct KeyHeader { |
68 uint8_t fDstReadKey; // set by GrGLShaderBuilder i
f there | 98 uint8_t fDstReadKey; // set by GrGLShaderBuilder i
f there |
69 // are effects that must read
the dst. | 99 // are effects that must read
the dst. |
70 // Otherwise, 0. | 100 // Otherwise, 0. |
71 uint8_t fFragPosKey; // set by GrGLShaderBuilder i
f there are | 101 uint8_t fFragPosKey; // set by GrGLShaderBuilder i
f there are |
72 // effects that read the frag
ment position. | 102 // effects that read the frag
ment position. |
73 // Otherwise, 0. | 103 // Otherwise, 0. |
74 | 104 |
75 ColorInput fColorInput : 8; | 105 ColorInput fColorInput : 8; |
76 ColorInput fCoverageInput : 8; | 106 ColorInput fCoverageInput : 8; |
77 | 107 |
| 108 PrimaryOutputType fPrimaryOutputType : 8; |
| 109 SecondaryOutputType fSecondaryOutputType : 8; |
| 110 |
78 SkBool8 fHasGeometryProcessor; | 111 SkBool8 fHasGeometryProcessor; |
79 int8_t fColorEffectCnt; | 112 int8_t fColorEffectCnt; |
80 int8_t fCoverageEffectCnt; | 113 int8_t fCoverageEffectCnt; |
81 }; | 114 }; |
82 | 115 |
83 | 116 |
84 bool hasGeometryProcessor() const { | 117 bool hasGeometryProcessor() const { |
85 return SkToBool(this->header().fHasGeometryProcessor); | 118 return SkToBool(this->header().fHasGeometryProcessor); |
86 } | 119 } |
87 | 120 |
(...skipping 12 matching lines...) Expand all Loading... |
100 | 133 |
101 // A struct to communicate descriptor information to the program descriptor
builder | 134 // A struct to communicate descriptor information to the program descriptor
builder |
102 struct DescInfo { | 135 struct DescInfo { |
103 bool operator==(const DescInfo& that) const { | 136 bool operator==(const DescInfo& that) const { |
104 return fHasVertexColor == that.fHasVertexColor && | 137 return fHasVertexColor == that.fHasVertexColor && |
105 fHasVertexCoverage == that.fHasVertexCoverage && | 138 fHasVertexCoverage == that.fHasVertexCoverage && |
106 fInputColorIsUsed == that.fInputColorIsUsed && | 139 fInputColorIsUsed == that.fInputColorIsUsed && |
107 fInputCoverageIsUsed == that.fInputCoverageIsUsed && | 140 fInputCoverageIsUsed == that.fInputCoverageIsUsed && |
108 fReadsDst == that.fReadsDst && | 141 fReadsDst == that.fReadsDst && |
109 fReadsFragPosition == that.fReadsFragPosition && | 142 fReadsFragPosition == that.fReadsFragPosition && |
110 fRequiresLocalCoordAttrib == that.fRequiresLocalCoordAttrib; | 143 fRequiresLocalCoordAttrib == that.fRequiresLocalCoordAttrib &
& |
| 144 fPrimaryOutputType == that.fPrimaryOutputType && |
| 145 fSecondaryOutputType == that.fSecondaryOutputType; |
| 146 |
111 } | 147 } |
112 bool operator!=(const DescInfo& that) const { return !(*this == that); }
; | 148 bool operator!=(const DescInfo& that) const { return !(*this == that); }
; |
113 // TODO when GPs control uniform / attribute handling of color / coverag
e, then we can | 149 // TODO when GPs control uniform / attribute handling of color / coverag
e, then we can |
114 // clean this up | 150 // clean this up |
115 bool fHasVertexColor; | 151 bool fHasVertexColor; |
116 bool fHasVertexCoverage; | 152 bool fHasVertexCoverage; |
117 | 153 |
118 // These flags are needed to protect the code from creating an unused un
iform color/coverage | 154 // These flags are needed to protect the code from creating an unused un
iform color/coverage |
119 // which will cause shader compiler errors. | 155 // which will cause shader compiler errors. |
120 bool fInputColorIsUsed; | 156 bool fInputColorIsUsed; |
121 bool fInputCoverageIsUsed; | 157 bool fInputCoverageIsUsed; |
122 | 158 |
123 // These flags give aggregated info on the processor stages that are use
d when building | 159 // These flags give aggregated info on the processor stages that are use
d when building |
124 // programs. | 160 // programs. |
125 bool fReadsDst; | 161 bool fReadsDst; |
126 bool fReadsFragPosition; | 162 bool fReadsFragPosition; |
127 bool fRequiresLocalCoordAttrib; | 163 bool fRequiresLocalCoordAttrib; |
128 | 164 |
| 165 // Fragment shader color outputs |
| 166 GrProgramDesc::PrimaryOutputType fPrimaryOutputType : 8; |
| 167 GrProgramDesc::SecondaryOutputType fSecondaryOutputType : 8; |
129 }; | 168 }; |
130 | 169 |
131 private: | 170 private: |
132 template<typename T, size_t OFFSET> T* atOffset() { | 171 template<typename T, size_t OFFSET> T* atOffset() { |
133 return reinterpret_cast<T*>(reinterpret_cast<intptr_t>(fKey.begin()) + O
FFSET); | 172 return reinterpret_cast<T*>(reinterpret_cast<intptr_t>(fKey.begin()) + O
FFSET); |
134 } | 173 } |
135 | 174 |
136 template<typename T, size_t OFFSET> const T* atOffset() const { | 175 template<typename T, size_t OFFSET> const T* atOffset() const { |
137 return reinterpret_cast<const T*>(reinterpret_cast<intptr_t>(fKey.begin(
)) + OFFSET); | 176 return reinterpret_cast<const T*>(reinterpret_cast<intptr_t>(fKey.begin(
)) + OFFSET); |
138 } | 177 } |
(...skipping 29 matching lines...) Expand all Loading... |
168 kPreAllocSize = kHeaderOffset + kHeaderSize + | 207 kPreAllocSize = kHeaderOffset + kHeaderSize + |
169 kMaxPreallocProcessors * sizeof(uint32_t) * kIntsPerProc
essor, | 208 kMaxPreallocProcessors * sizeof(uint32_t) * kIntsPerProc
essor, |
170 }; | 209 }; |
171 | 210 |
172 SkSTArray<kPreAllocSize, uint8_t, true> fKey; | 211 SkSTArray<kPreAllocSize, uint8_t, true> fKey; |
173 | 212 |
174 friend class GrGLProgramDescBuilder; | 213 friend class GrGLProgramDescBuilder; |
175 }; | 214 }; |
176 | 215 |
177 #endif | 216 #endif |
OLD | NEW |