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

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

Issue 554833002: Calculate Primary and Secondary output types in the GrOptDrawState (Closed) Base URL: https://skia.googlesource.com/skia.git@optReadDst
Patch Set: Rebase Created 6 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 | « src/gpu/GrDrawState.cpp ('k') | src/gpu/GrOptDrawState.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 GrOptDrawState_DEFINED 8 #ifndef GrOptDrawState_DEFINED
9 #define GrOptDrawState_DEFINED 9 #define GrOptDrawState_DEFINED
10 10
(...skipping 10 matching lines...) Expand all
21 bool operator== (const GrOptDrawState& that) const; 21 bool operator== (const GrOptDrawState& that) const;
22 22
23 bool inputColorIsUsed() const { return fInputColorIsUsed; } 23 bool inputColorIsUsed() const { return fInputColorIsUsed; }
24 bool inputCoverageIsUsed() const { return fInputCoverageIsUsed; } 24 bool inputCoverageIsUsed() const { return fInputCoverageIsUsed; }
25 25
26 bool readsDst() const { return fReadsDst; } 26 bool readsDst() const { return fReadsDst; }
27 bool readsFragPosition() const { return fReadsFragPosition; } 27 bool readsFragPosition() const { return fReadsFragPosition; }
28 bool requiresVertexShader() const { return fRequiresVertexShader; } 28 bool requiresVertexShader() const { return fRequiresVertexShader; }
29 bool requiresLocalCoordAttrib() const { return fRequiresLocalCoordAttrib; } 29 bool requiresLocalCoordAttrib() const { return fRequiresLocalCoordAttrib; }
30 30
31 ///////////////////////////////////////////////////////////////////////////
32 /// @name Stage Output Types
33 ////
34
35 enum PrimaryOutputType {
36 // Modulate color and coverage, write result as the color output.
37 kModulate_PrimaryOutputType,
38 // Combines the coverage, dst, and color as coverage * color + (1 - cove rage) * dst. This
39 // can only be set if fDstReadKey is non-zero.
40 kCombineWithDst_PrimaryOutputType,
41
42 kPrimaryOutputTypeCnt,
43 };
44
45 enum SecondaryOutputType {
46 // There is no secondary output
47 kNone_SecondaryOutputType,
48 // Writes coverage as the secondary output. Only set if dual source blen ding is supported
49 // and primary output is kModulate.
50 kCoverage_SecondaryOutputType,
51 // Writes coverage * (1 - colorA) as the secondary output. Only set if d ual source blending
52 // is supported and primary output is kModulate.
53 kCoverageISA_SecondaryOutputType,
54 // Writes coverage * (1 - colorRGBA) as the secondary output. Only set i f dual source
55 // blending is supported and primary output is kModulate.
56 kCoverageISC_SecondaryOutputType,
57
58 kSecondaryOutputTypeCnt,
59 };
60
61 PrimaryOutputType getPrimaryOutputType() const { return fPrimaryOutputType; }
62 SecondaryOutputType getSecondaryOutputType() const { return fSecondaryOutput Type; }
63
64 /// @}
65
31 private: 66 private:
32 /** 67 /**
33 * Constructs and optimized drawState out of a GrRODrawState. 68 * Constructs and optimized drawState out of a GrRODrawState.
34 */ 69 */
35 GrOptDrawState(const GrDrawState& drawState, BlendOptFlags blendOptFlags, 70 GrOptDrawState(const GrDrawState& drawState, BlendOptFlags blendOptFlags,
36 GrBlendCoeff optSrcCoeff, GrBlendCoeff optDstCoeff); 71 GrBlendCoeff optSrcCoeff, GrBlendCoeff optDstCoeff,
72 const GrDrawTargetCaps& caps);
37 73
38 /** 74 /**
39 * Loops through all the color stage effects to check if the stage will igno re color input or 75 * Loops through all the color stage effects to check if the stage will igno re color input or
40 * always output a constant color. In the ignore color input case we can ign ore all previous 76 * always output a constant color. In the ignore color input case we can ign ore all previous
41 * stages. In the constant color case, we can ignore all previous stages and 77 * stages. In the constant color case, we can ignore all previous stages and
42 * the current one and set the state color to the constant color. Once we de termine the so 78 * the current one and set the state color to the constant color. Once we de termine the so
43 * called first effective stage, we copy all the effective stages into our o ptimized 79 * called first effective stage, we copy all the effective stages into our o ptimized
44 * state. 80 * state.
45 */ 81 */
46 void copyEffectiveColorStages(const GrDrawState& ds); 82 void copyEffectiveColorStages(const GrDrawState& ds);
(...skipping 18 matching lines...) Expand all
65 * BlendOptFlags. 101 * BlendOptFlags.
66 */ 102 */
67 void adjustFromBlendOpts(); 103 void adjustFromBlendOpts();
68 104
69 /** 105 /**
70 * Loop over the effect stages to determine various info like what data they will read and what 106 * Loop over the effect stages to determine various info like what data they will read and what
71 * shaders they require. 107 * shaders they require.
72 */ 108 */
73 void getStageStats(); 109 void getStageStats();
74 110
111 /**
112 * Calculates the primary and secondary output types of the shader. For cert ain output types
113 * the function may adjust the blend coefficients. After this function is ca lled the src and dst
114 * blend coeffs will represent those used by backend API.
115 */
116 void setOutputStateInfo(const GrDrawTargetCaps&);
117
75 // These flags are needed to protect the code from creating an unused unifor m color/coverage 118 // These flags are needed to protect the code from creating an unused unifor m color/coverage
76 // which will cause shader compiler errors. 119 // which will cause shader compiler errors.
77 bool fInputColorIsUsed; 120 bool fInputColorIsUsed;
78 bool fInputCoverageIsUsed; 121 bool fInputCoverageIsUsed;
79 122
80 // These flags give aggregated info on the effect stages that are used when building programs. 123 // These flags give aggregated info on the effect stages that are used when building programs.
81 bool fReadsDst; 124 bool fReadsDst;
82 bool fReadsFragPosition; 125 bool fReadsFragPosition;
83 bool fRequiresVertexShader; 126 bool fRequiresVertexShader;
84 bool fRequiresLocalCoordAttrib; 127 bool fRequiresLocalCoordAttrib;
85 128
86 SkAutoSTArray<4, GrVertexAttrib> fOptVA; 129 SkAutoSTArray<4, GrVertexAttrib> fOptVA;
87 130
88 BlendOptFlags fBlendOptFlags; 131 BlendOptFlags fBlendOptFlags;
89 132
90 friend GrOptDrawState* GrDrawState::createOptState() const; 133 // Fragment shader color outputs
134 PrimaryOutputType fPrimaryOutputType : 8;
135 SecondaryOutputType fSecondaryOutputType : 8;
136
137 friend GrOptDrawState* GrDrawState::createOptState(const GrDrawTargetCaps&) const;
91 typedef GrRODrawState INHERITED; 138 typedef GrRODrawState INHERITED;
92 }; 139 };
93 140
94 #endif 141 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDrawState.cpp ('k') | src/gpu/GrOptDrawState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698