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

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

Issue 1116713002: Pull out shader-specific caps into GrShaderCaps and GrGLSLCaps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clean up some comments Created 5 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
« no previous file with comments | « src/gpu/GrDrawTarget.cpp ('k') | src/gpu/GrOvalRenderer.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 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #ifndef GrDrawTargetCaps_DEFINED 8 #ifndef GrDrawTargetCaps_DEFINED
9 #define GrDrawTargetCaps_DEFINED 9 #define GrDrawTargetCaps_DEFINED
10 10
11 #include "GrTypes.h" 11 #include "GrTypes.h"
12 #include "GrTypesPriv.h" 12 #include "GrTypesPriv.h"
13 #include "GrShaderVar.h" 13 #include "GrShaderVar.h"
14 #include "SkRefCnt.h" 14 #include "SkRefCnt.h"
15 #include "SkString.h" 15 #include "SkString.h"
16 16
17 /** 17 class GrShaderCaps : public SkRefCnt {
18 * Represents the draw target capabilities.
19 */
20 class GrDrawTargetCaps : public SkRefCnt {
21 public: 18 public:
22 SK_DECLARE_INST_COUNT(GrDrawTargetCaps) 19 SK_DECLARE_INST_COUNT(GrShaderCaps)
23 20
24 /** Info about shader variable precision within a given shader stage. That i s, this info 21 /** Info about shader variable precision within a given shader stage. That i s, this info
25 is relevant to a float (or vecNf) variable declared with a GrSLPrecision 22 is relevant to a float (or vecNf) variable declared with a GrSLPrecision
26 in a given GrShaderType. The info here is hoisted from the OpenGL spec. */ 23 in a given GrShaderType. The info here is hoisted from the OpenGL spec. */
27 struct PrecisionInfo { 24 struct PrecisionInfo {
28 PrecisionInfo() { 25 PrecisionInfo() {
29 fLogRangeLow = 0; 26 fLogRangeLow = 0;
30 fLogRangeHigh = 0; 27 fLogRangeHigh = 0;
31 fBits = 0; 28 fBits = 0;
32 } 29 }
33 30
34 /** Is this precision level allowed in the shader stage? */ 31 /** Is this precision level allowed in the shader stage? */
35 bool supported() const { return 0 != fBits; } 32 bool supported() const { return 0 != fBits; }
36 33
37 bool operator==(const PrecisionInfo& that) const { 34 bool operator==(const PrecisionInfo& that) const {
38 return fLogRangeLow == that.fLogRangeLow && fLogRangeHigh == that.fL ogRangeHigh && 35 return fLogRangeLow == that.fLogRangeLow && fLogRangeHigh == that.fL ogRangeHigh &&
39 fBits == that.fBits; 36 fBits == that.fBits;
40 } 37 }
41 bool operator!=(const PrecisionInfo& that) const { return !(*this == tha t); } 38 bool operator!=(const PrecisionInfo& that) const { return !(*this == tha t); }
42 39
43 /** floor(log2(|min_value|)) */ 40 /** floor(log2(|min_value|)) */
44 int fLogRangeLow; 41 int fLogRangeLow;
45 /** floor(log2(|max_value|)) */ 42 /** floor(log2(|max_value|)) */
46 int fLogRangeHigh; 43 int fLogRangeHigh;
47 /** Number of bits of precision. As defined in OpenGL (with names modifi ed to reflect this 44 /** Number of bits of precision. As defined in OpenGL (with names modifi ed to reflect this
48 struct) : 45 struct) :
49 """ 46 """
50 If the smallest representable value greater than 1 is 1 + e, the n fBits will 47 If the smallest representable value greater than 1 is 1 + e, then fB its will
51 contain floor(log2(e)), and every value in the range [2^fLogRang eLow, 48 contain floor(log2(e)), and every value in the range [2^fLogRangeLow ,
52 2^fLogRangeHigh] can be represented to at least one part in 2^fB its. 49 2^fLogRangeHigh] can be represented to at least one part in 2^fBits.
53 """ 50 """
54 */ 51 */
55 int fBits; 52 int fBits;
56 }; 53 };
57 54
55 GrShaderCaps() {
56 this->reset();
57 }
58 virtual ~GrShaderCaps() {}
59 GrShaderCaps(const GrShaderCaps& other) : INHERITED() {
60 *this = other;
61 }
62 GrShaderCaps& operator= (const GrShaderCaps&);
63
64 virtual void reset();
65 virtual SkString dump() const;
66
67 bool shaderDerivativeSupport() const { return fShaderDerivativeSupport; }
68 bool geometryShaderSupport() const { return fGeometryShaderSupport; }
69 bool pathRenderingSupport() const { return fPathRenderingSupport; }
70 bool dstReadInShaderSupport() const { return fDstReadInShaderSupport; }
71 bool dualSourceBlendingSupport() const { return fDualSourceBlendingSupport; }
72
73 /**
74 * Get the precision info for a variable of type kFloat_GrSLType, kVec2f_GrSL Type, etc in a
75 * given shader type. If the shader type is not supported or the precision le vel is not
76 * supported in that shader type then the returned struct will report false w hen supported() is
77 * called.
78 */
79 const PrecisionInfo& getFloatShaderPrecisionInfo(GrShaderType shaderType,
80 GrSLPrecision precision) const {
81 return fFloatPrecisions[shaderType][precision];
82 };
83
84 /**
85 * Is there any difference between the float shader variable precision types? If this is true
86 * then unless the shader type is not supported, any call to getFloatShaderPr ecisionInfo() would
87 * report the same info for all precisions in all shader types.
88 */
89 bool floatPrecisionVaries() const { return fShaderPrecisionVaries; }
90
91 protected:
92 bool fShaderDerivativeSupport : 1;
93 bool fGeometryShaderSupport : 1;
94 bool fPathRenderingSupport : 1;
95 bool fDstReadInShaderSupport : 1;
96 bool fDualSourceBlendingSupport : 1;
97
98 bool fShaderPrecisionVaries;
99 PrecisionInfo fFloatPrecisions[kGrShaderTypeCount][kGrSLPrecisionCount];
100
101 private:
102 typedef SkRefCnt INHERITED;
103 };
104
105 /**
106 * Represents the draw target capabilities.
107 */
108 class GrDrawTargetCaps : public SkRefCnt {
109 public:
110 SK_DECLARE_INST_COUNT(GrDrawTargetCaps)
58 111
59 GrDrawTargetCaps() { 112 GrDrawTargetCaps() {
113 fShaderCaps.reset(NULL);
60 this->reset(); 114 this->reset();
61 } 115 }
62 GrDrawTargetCaps(const GrDrawTargetCaps& other) : INHERITED() { 116 GrDrawTargetCaps(const GrDrawTargetCaps& other) : INHERITED() {
63 *this = other; 117 *this = other;
64 } 118 }
65 GrDrawTargetCaps& operator= (const GrDrawTargetCaps&); 119 GrDrawTargetCaps& operator= (const GrDrawTargetCaps&);
66 120
67 virtual void reset(); 121 virtual void reset();
68 virtual SkString dump() const; 122 virtual SkString dump() const;
69 123
124 GrShaderCaps* shaderCaps() const { return fShaderCaps; }
125
70 bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; } 126 bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; }
71 /** To avoid as-yet-unnecessary complexity we don't allow any partial suppor t of MIP Maps (e.g. 127 /** To avoid as-yet-unnecessary complexity we don't allow any partial suppor t of MIP Maps (e.g.
72 only for POT textures) */ 128 only for POT textures) */
73 bool mipMapSupport() const { return fMipMapSupport; } 129 bool mipMapSupport() const { return fMipMapSupport; }
74 bool twoSidedStencilSupport() const { return fTwoSidedStencilSupport; } 130 bool twoSidedStencilSupport() const { return fTwoSidedStencilSupport; }
75 bool stencilWrapOpsSupport() const { return fStencilWrapOpsSupport; } 131 bool stencilWrapOpsSupport() const { return fStencilWrapOpsSupport; }
76 bool shaderDerivativeSupport() const { return fShaderDerivativeSupport; }
77 bool geometryShaderSupport() const { return fGeometryShaderSupport; }
78 bool dualSourceBlendingSupport() const { return fDualSourceBlendingSupport; }
79 bool pathRenderingSupport() const { return fPathRenderingSupport; }
80 bool dstReadInShaderSupport() const { return fDstReadInShaderSupport; }
81 bool discardRenderTargetSupport() const { return fDiscardRenderTargetSupport ; } 132 bool discardRenderTargetSupport() const { return fDiscardRenderTargetSupport ; }
82 #if GR_FORCE_GPU_TRACE_DEBUGGING 133 #if GR_FORCE_GPU_TRACE_DEBUGGING
83 bool gpuTracingSupport() const { return true; } 134 bool gpuTracingSupport() const { return true; }
84 #else 135 #else
85 bool gpuTracingSupport() const { return fGpuTracingSupport; } 136 bool gpuTracingSupport() const { return fGpuTracingSupport; }
86 #endif 137 #endif
87 bool compressedTexSubImageSupport() const { return fCompressedTexSubImageSup port; } 138 bool compressedTexSubImageSupport() const { return fCompressedTexSubImageSup port; }
88 bool oversizedStencilSupport() const { return fOversizedStencilSupport; } 139 bool oversizedStencilSupport() const { return fOversizedStencilSupport; }
89 bool textureBarrierSupport() const { return fTextureBarrierSupport; } 140 bool textureBarrierSupport() const { return fTextureBarrierSupport; }
90 141
(...skipping 27 matching lines...) Expand all
118 bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const { 169 bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const {
119 SkASSERT(kGrPixelConfigCnt > config); 170 SkASSERT(kGrPixelConfigCnt > config);
120 return fConfigRenderSupport[config][withMSAA]; 171 return fConfigRenderSupport[config][withMSAA];
121 } 172 }
122 173
123 bool isConfigTexturable(GrPixelConfig config) const { 174 bool isConfigTexturable(GrPixelConfig config) const {
124 SkASSERT(kGrPixelConfigCnt > config); 175 SkASSERT(kGrPixelConfigCnt > config);
125 return fConfigTextureSupport[config]; 176 return fConfigTextureSupport[config];
126 } 177 }
127 178
128 /** 179 protected:
129 * Get the precision info for a variable of type kFloat_GrSLType, kVec2f_GrS LType, etc in a 180 SkAutoTUnref<GrShaderCaps> fShaderCaps;
130 * given shader type. If the shader type is not supported or the precision l evel is not
131 * supported in that shader type then the returned struct will report false when supported() is
132 * called.
133 */
134 const PrecisionInfo& getFloatShaderPrecisionInfo(GrShaderType shaderType,
135 GrSLPrecision precision) co nst {
136 return fFloatPrecisions[shaderType][precision];
137 };
138 181
139 /**
140 * Is there any difference between the float shader variable precision types ? If this is true
141 * then unless the shader type is not supported, any call to getFloatShaderP recisionInfo() would
142 * report the same info for all precisions in all shader types.
143 */
144 bool floatPrecisionVaries() const { return fShaderPrecisionVaries; }
145
146 protected:
147 bool fNPOTTextureTileSupport : 1; 182 bool fNPOTTextureTileSupport : 1;
148 bool fMipMapSupport : 1; 183 bool fMipMapSupport : 1;
149 bool fTwoSidedStencilSupport : 1; 184 bool fTwoSidedStencilSupport : 1;
150 bool fStencilWrapOpsSupport : 1; 185 bool fStencilWrapOpsSupport : 1;
151 bool fShaderDerivativeSupport : 1;
152 bool fGeometryShaderSupport : 1;
153 bool fDualSourceBlendingSupport : 1;
154 bool fPathRenderingSupport : 1;
155 bool fDstReadInShaderSupport : 1;
156 bool fDiscardRenderTargetSupport : 1; 186 bool fDiscardRenderTargetSupport : 1;
157 bool fReuseScratchTextures : 1; 187 bool fReuseScratchTextures : 1;
158 bool fGpuTracingSupport : 1; 188 bool fGpuTracingSupport : 1;
159 bool fCompressedTexSubImageSupport : 1; 189 bool fCompressedTexSubImageSupport : 1;
160 bool fOversizedStencilSupport : 1; 190 bool fOversizedStencilSupport : 1;
161 bool fTextureBarrierSupport : 1; 191 bool fTextureBarrierSupport : 1;
162 // Driver workaround 192 // Driver workaround
163 bool fUseDrawInsteadOfClear : 1; 193 bool fUseDrawInsteadOfClear : 1;
164 194
165 uint32_t fMapBufferFlags; 195 uint32_t fMapBufferFlags;
166 196
167 int fMaxRenderTargetSize; 197 int fMaxRenderTargetSize;
168 int fMaxTextureSize; 198 int fMaxTextureSize;
169 int fMaxSampleCount; 199 int fMaxSampleCount;
170 200
171 // The first entry for each config is without msaa and the second is with. 201 // The first entry for each config is without msaa and the second is with.
172 bool fConfigRenderSupport[kGrPixelConfigCnt][2]; 202 bool fConfigRenderSupport[kGrPixelConfigCnt][2];
173 bool fConfigTextureSupport[kGrPixelConfigCnt]; 203 bool fConfigTextureSupport[kGrPixelConfigCnt];
174 204
175 bool fShaderPrecisionVaries;
176 PrecisionInfo fFloatPrecisions[kGrShaderTypeCount][kGrSLPrecisionCount];
177
178 private: 205 private:
179 typedef SkRefCnt INHERITED; 206 typedef SkRefCnt INHERITED;
180 }; 207 };
181 208
182 #endif 209 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.cpp ('k') | src/gpu/GrOvalRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698