9 #ifndef GrShaderCaps_DEFINED
10 #define GrShaderCaps_DEFINED
12 #include "../private/GrSwizzle.h"
13 #include "../private/GrGLSL.h"
16 class ShaderCapsFactory;
39 bool operator!=(
const PrecisionInfo& that)
const {
return !(*
this == that); }
61 kNotSupported_AdvBlendEqInteraction,
62 kAutomatic_AdvBlendEqInteraction,
63 kGeneralEnable_AdvBlendEqInteraction,
64 kSpecificEnables_AdvBlendEqInteraction,
66 kLast_AdvBlendEqInteraction = kSpecificEnables_AdvBlendEqInteraction
73 bool shaderDerivativeSupport()
const {
return fShaderDerivativeSupport; }
74 bool geometryShaderSupport()
const {
return fGeometryShaderSupport; }
75 bool pathRenderingSupport()
const {
return fPathRenderingSupport; }
76 bool dstReadInShaderSupport()
const {
return fDstReadInShaderSupport; }
77 bool dualSourceBlendingSupport()
const {
return fDualSourceBlendingSupport; }
78 bool integerSupport()
const {
return fIntegerSupport; }
79 bool texelBufferSupport()
const {
return fTexelBufferSupport; }
80 int imageLoadStoreSupport()
const {
return fImageLoadStoreSupport; }
89 GrSLPrecision precision)
const {
90 return fFloatPrecisions[shaderType][precision];
107 bool fbFetchNeedsCustomOutput()
const {
return fFBFetchNeedsCustomOutput; }
109 bool bindlessTextureSupport()
const {
return fBindlessTextureSupport; }
111 const char* versionDeclString()
const {
return fVersionDeclString; }
113 const char* fbFetchColorName()
const {
return fFBFetchColorName; }
115 const char* fbFetchExtensionString()
const {
return fFBFetchExtensionString; }
117 bool dropsTileOnZeroDivide()
const {
return fDropsTileOnZeroDivide; }
119 bool flatInterpolationSupport()
const {
return fFlatInterpolationSupport; }
121 bool noperspectiveInterpolationSupport()
const {
return fNoPerspectiveInterpolationSupport; }
123 bool multisampleInterpolationSupport()
const {
return fMultisampleInterpolationSupport; }
125 bool sampleVariablesSupport()
const {
return fSampleVariablesSupport; }
127 bool sampleMaskOverrideCoverageSupport()
const {
return fSampleMaskOverrideCoverageSupport; }
129 bool externalTextureSupport()
const {
return fExternalTextureSupport; }
131 bool texelFetchSupport()
const {
return fTexelFetchSupport; }
133 bool vertexIDSupport()
const {
return fVertexIDSupport; }
137 bool mustEnableAdvBlendEqs()
const {
138 return fAdvBlendEqInteraction >= kGeneralEnable_AdvBlendEqInteraction;
141 bool mustEnableSpecificAdvBlendEqs()
const {
142 return fAdvBlendEqInteraction == kSpecificEnables_AdvBlendEqInteraction;
145 bool mustDeclareFragmentShaderOutput()
const {
146 return fGLSLGeneration > k110_GrGLSLGeneration;
149 bool usesPrecisionModifiers()
const {
return fUsesPrecisionModifiers; }
152 bool canUseAnyFunctionInShader()
const {
return fCanUseAnyFunctionInShader; }
154 bool canUseMinAndAbsTogether()
const {
return fCanUseMinAndAbsTogether; }
156 bool mustForceNegatedAtanParamToFloat()
const {
return fMustForceNegatedAtanParamToFloat; }
159 bool atan2ImplementedAsAtanYOverX()
const {
return fAtan2ImplementedAsAtanYOverX; }
161 bool requiresLocalOutputColorForFBFetch()
const {
return fRequiresLocalOutputColorForFBFetch; }
164 bool mustImplementGSInvocationsWithLoop()
const {
return fMustImplementGSInvocationsWithLoop; }
166 bool mustObfuscateUniformColor()
const {
return fMustObfuscateUniformColor; }
171 const char* shaderDerivativeExtensionString()
const {
172 SkASSERT(this->shaderDerivativeSupport());
173 return fShaderDerivativeExtensionString;
180 const char* fragCoordConventionsExtensionString()
const {
181 return fFragCoordConventionsExtensionString;
188 const char* secondaryOutputExtensionString()
const {
189 return fSecondaryOutputExtensionString;
192 const char* externalTextureExtensionString()
const {
193 SkASSERT(this->externalTextureSupport());
194 return fExternalTextureExtensionString;
197 const char* texelBufferExtensionString()
const {
198 SkASSERT(this->texelBufferSupport());
199 return fTexelBufferExtensionString;
202 const char* noperspectiveInterpolationExtensionString()
const {
203 SkASSERT(this->noperspectiveInterpolationSupport());
204 return fNoPerspectiveInterpolationExtensionString;
207 const char* multisampleInterpolationExtensionString()
const {
208 SkASSERT(this->multisampleInterpolationSupport());
209 return fMultisampleInterpolationExtensionString;
212 const char* sampleVariablesExtensionString()
const {
213 SkASSERT(this->sampleVariablesSupport());
214 return fSampleVariablesExtensionString;
217 const char* imageLoadStoreExtensionString()
const {
218 SkASSERT(this->imageLoadStoreSupport());
219 return fImageLoadStoreExtensionString;
222 int maxVertexSamplers()
const {
return fMaxVertexSamplers; }
224 int maxGeometrySamplers()
const {
return fMaxGeometrySamplers; }
226 int maxFragmentSamplers()
const {
return fMaxFragmentSamplers; }
228 int maxCombinedSamplers()
const {
return fMaxCombinedSamplers; }
230 int maxVertexImageStorages()
const {
return fMaxVertexImageStorages; }
232 int maxGeometryImageStorages()
const {
return fMaxGeometryImageStorages; }
234 int maxFragmentImageStorages()
const {
return fMaxFragmentImageStorages; }
236 int maxCombinedImageStorages()
const {
return fMaxCombinedImageStorages; }
244 return fConfigTextureSwizzle[config];
249 return fConfigOutputSwizzle[config];
254 return static_cast<GrSLPrecision
>(fSamplerPrecisions[visibility][config]);
257 GrGLSLGeneration generation()
const {
return fGLSLGeneration; }
265 GrGLSLGeneration fGLSLGeneration;
267 bool fShaderDerivativeSupport : 1;
268 bool fGeometryShaderSupport : 1;
269 bool fPathRenderingSupport : 1;
270 bool fDstReadInShaderSupport : 1;
271 bool fDualSourceBlendingSupport : 1;
272 bool fIntegerSupport : 1;
273 bool fTexelBufferSupport : 1;
274 bool fImageLoadStoreSupport : 1;
275 bool fShaderPrecisionVaries : 1;
276 bool fDropsTileOnZeroDivide : 1;
277 bool fFBFetchSupport : 1;
278 bool fFBFetchNeedsCustomOutput : 1;
279 bool fBindlessTextureSupport : 1;
280 bool fUsesPrecisionModifiers : 1;
281 bool fCanUseAnyFunctionInShader : 1;
282 bool fFlatInterpolationSupport : 1;
283 bool fNoPerspectiveInterpolationSupport : 1;
284 bool fMultisampleInterpolationSupport : 1;
285 bool fSampleVariablesSupport : 1;
286 bool fSampleMaskOverrideCoverageSupport : 1;
287 bool fExternalTextureSupport : 1;
288 bool fTexelFetchSupport : 1;
289 bool fVertexIDSupport : 1;
292 bool fCanUseMinAndAbsTogether : 1;
293 bool fMustForceNegatedAtanParamToFloat : 1;
294 bool fAtan2ImplementedAsAtanYOverX : 1;
295 bool fRequiresLocalOutputColorForFBFetch : 1;
296 bool fMustImplementGSInvocationsWithLoop : 1;
297 bool fMustObfuscateUniformColor : 1;
299 PrecisionInfo fFloatPrecisions[kGrShaderTypeCount][kGrSLPrecisionCount];
301 const char* fVersionDeclString;
303 const char* fShaderDerivativeExtensionString;
304 const char* fFragCoordConventionsExtensionString;
305 const char* fSecondaryOutputExtensionString;
306 const char* fExternalTextureExtensionString;
307 const char* fTexelBufferExtensionString;
308 const char* fNoPerspectiveInterpolationExtensionString;
309 const char* fMultisampleInterpolationExtensionString;
310 const char* fSampleVariablesExtensionString;
311 const char* fImageLoadStoreExtensionString;
313 const char* fFBFetchColorName;
314 const char* fFBFetchExtensionString;
316 int fMaxVertexSamplers;
317 int fMaxGeometrySamplers;
318 int fMaxFragmentSamplers;
319 int fMaxCombinedSamplers;
321 int fMaxVertexImageStorages;
322 int fMaxGeometryImageStorages;
323 int fMaxFragmentImageStorages;
324 int fMaxCombinedImageStorages;
328 GrSwizzle fConfigTextureSwizzle[kGrPixelConfigCnt];
329 GrSwizzle fConfigOutputSwizzle[kGrPixelConfigCnt];
331 uint8_t fSamplerPrecisions[(1 << kGrShaderTypeCount)][kGrPixelConfigCnt];
333 friend class GrGLCaps;
334 friend class GrVkCaps;
335 friend class SkSL::ShaderCapsFactory;
Definition: GrContextOptions.h:14
Info about shader variable precision within a given shader stage.
Definition: GrShaderCaps.h:25
bool supported() const
Is this precision level allowed in the shader stage?
Definition: GrShaderCaps.h:33
const GrSwizzle & configTextureSwizzle(GrPixelConfig config) const
Given a texture's config, this determines what swizzle must be appended to accesses to the texture in...
Definition: GrShaderCaps.h:243
const GrSwizzle & configOutputSwizzle(GrPixelConfig config) const
Swizzle that should occur on the fragment shader outputs for a given config.
Definition: GrShaderCaps.h:248
GrSLPrecision samplerPrecision(GrPixelConfig config, GrShaderFlags visibility) const
Precision qualifier that should be used with a sampler, given its config and visibility.
Definition: GrShaderCaps.h:253
bool fbFetchSupport() const
Some helper functions for encapsulating various extensions to read FB Buffer on openglES.
Definition: GrShaderCaps.h:105
int fLogRangeLow
floor(log2(|min_value|))
Definition: GrShaderCaps.h:42
Definition: SkRefCnt.h:125
void initSamplerPrecisionTable()
GrCaps subclasses must call this after filling in the shader precision table.
int fBits
Number of bits of precision.
Definition: GrShaderCaps.h:53
bool floatPrecisionVaries() const
Is there any difference between the float shader variable precision types? If this is true then unles...
Definition: GrShaderCaps.h:98
int fLogRangeHigh
floor(log2(|max_value|))
Definition: GrShaderCaps.h:44
Definition: GrShaderCaps.h:20
const PrecisionInfo & getFloatShaderPrecisionInfo(GrShaderType shaderType, GrSLPrecision precision) const
Get the precision info for a variable of type kFloat_GrSLType, kVec2f_GrSLType, etc in a given shader...
Definition: GrShaderCaps.h:88
Light weight class for managing strings.
Definition: SkString.h:121
AdvBlendEqInteraction
Indicates how GLSL must interact with advanced blend equations.
Definition: GrShaderCaps.h:60