blob: 136bef466c0642b3cd07547b611b5bb1c4a6cf88 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrGLSLCaps_DEFINED
#define GrGLSLCaps_DEFINED
#include "GrCaps.h"
#include "GrGLSL.h"
#include "GrSwizzle.h"
class GrGLSLCaps : public GrShaderCaps {
public:
/**
* Indicates how GLSL must interact with advanced blend equations. The KHR extension requires
* special layout qualifiers in the fragment shader.
*/
enum AdvBlendEqInteraction {
kNotSupported_AdvBlendEqInteraction, //<! No _blend_equation_advanced extension
kAutomatic_AdvBlendEqInteraction, //<! No interaction required
kGeneralEnable_AdvBlendEqInteraction, //<! layout(blend_support_all_equations) out
kSpecificEnables_AdvBlendEqInteraction, //<! Specific layout qualifiers per equation
kLast_AdvBlendEqInteraction = kSpecificEnables_AdvBlendEqInteraction
};
/**
* Initializes the GrGLSLCaps to a default set of features
*/
GrGLSLCaps(const GrContextOptions&);
/**
* Some helper functions for encapsulating various extensions to read FB Buffer on openglES
*
* TODO(joshualitt) On desktop opengl 4.2+ we can achieve something similar to this effect
*/
bool fbFetchSupport() const { return fFBFetchSupport; }
bool fbFetchNeedsCustomOutput() const { return fFBFetchNeedsCustomOutput; }
bool bindlessTextureSupport() const { return fBindlessTextureSupport; }
const char* versionDeclString() const { return fVersionDeclString; }
const char* fbFetchColorName() const { return fFBFetchColorName; }
const char* fbFetchExtensionString() const { return fFBFetchExtensionString; }
bool dropsTileOnZeroDivide() const { return fDropsTileOnZeroDivide; }
AdvBlendEqInteraction advBlendEqInteraction() const { return fAdvBlendEqInteraction; }
bool mustEnableAdvBlendEqs() const {
return fAdvBlendEqInteraction >= kGeneralEnable_AdvBlendEqInteraction;
}
bool mustEnableSpecificAdvBlendEqs() const {
return fAdvBlendEqInteraction == kSpecificEnables_AdvBlendEqInteraction;
}
bool mustDeclareFragmentShaderOutput() const {
return fGLSLGeneration > k110_GrGLSLGeneration;
}
bool usesPrecisionModifiers() const { return fUsesPrecisionModifiers; }
// Returns whether we can use the glsl funciton any() in our shader code.
bool canUseAnyFunctionInShader() const { return fCanUseAnyFunctionInShader; }
bool canUseMinAndAbsTogether() const { return fCanUseMinAndAbsTogether; }
bool mustForceNegatedAtanParamToFloat() const { return fMustForceNegatedAtanParamToFloat; }
// Returns the string of an extension that must be enabled in the shader to support
// derivatives. If nullptr is returned then no extension needs to be enabled. Before calling
// this function, the caller should check that shaderDerivativeSupport exists.
const char* shaderDerivativeExtensionString() const {
SkASSERT(this->shaderDerivativeSupport());
return fShaderDerivativeExtensionString;
}
// Returns the string of an extension that will do all necessary coord transfomations needed
// when reading the fragment position. If such an extension does not exisits, this function
// returns a nullptr, and all transforms of the frag position must be done manually in the
// shader.
const char* fragCoordConventionsExtensionString() const {
return fFragCoordConventionsExtensionString;
}
// This returns the name of an extension that must be enabled in the shader, if such a thing is
// required in order to use a secondary output in the shader. This returns a nullptr if no such
// extension is required. However, the return value of this function does not say whether dual
// source blending is supported.
const char* secondaryOutputExtensionString() const {
return fSecondaryOutputExtensionString;
}
const char* externalTextureExtensionString() const {
return fExternalTextureExtensionString;
}
/**
* Given a texture's config, this determines what swizzle must be appended to accesses to the
* texture in generated shader code. Swizzling may be implemented in texture parameters or a
* sampler rather than in the shader. In this case the returned swizzle will always be "rgba".
*/
const GrSwizzle& configTextureSwizzle(GrPixelConfig config) const {
return fConfigTextureSwizzle[config];
}
/** Swizzle that should occur on the fragment shader outputs for a given config. */
const GrSwizzle& configOutputSwizzle(GrPixelConfig config) const {
return fConfigOutputSwizzle[config];
}
GrGLSLGeneration generation() const { return fGLSLGeneration; }
/**
* Returns a string containing the caps info.
*/
SkString dump() const override;
private:
void onApplyOptionsOverrides(const GrContextOptions& options) override;
GrGLSLGeneration fGLSLGeneration;
bool fDropsTileOnZeroDivide : 1;
bool fFBFetchSupport : 1;
bool fFBFetchNeedsCustomOutput : 1;
bool fBindlessTextureSupport : 1;
bool fUsesPrecisionModifiers : 1;
bool fCanUseAnyFunctionInShader : 1;
// Used for specific driver bug work arounds
bool fCanUseMinAndAbsTogether : 1;
bool fMustForceNegatedAtanParamToFloat : 1;
const char* fVersionDeclString;
const char* fShaderDerivativeExtensionString;
const char* fFragCoordConventionsExtensionString;
const char* fSecondaryOutputExtensionString;
const char* fExternalTextureExtensionString;
const char* fFBFetchColorName;
const char* fFBFetchExtensionString;
AdvBlendEqInteraction fAdvBlendEqInteraction;
GrSwizzle fConfigTextureSwizzle[kGrPixelConfigCnt];
GrSwizzle fConfigOutputSwizzle[kGrPixelConfigCnt];
friend class GrGLCaps; // For initialization.
typedef GrShaderCaps INHERITED;
};
#endif
|