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