Remove various sk_Caps settings

"canUseAnyFunction" was totally unused. All of the others that I removed
are only used from C++ code to control higher level logic (not within
shaders). A few of the remainders don't have sk_Caps references today,
but adding usage seems plausible.

Change-Id: I196f7d8abacde9dc6903d792cd18b58a34dc19f3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/546858
Reviewed-by: Arman Uguray <armansito@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2022-06-03 14:59:46 -04:00 committed by SkCQ
parent 39352983ea
commit 47b6b5897b
13 changed files with 10 additions and 34 deletions

View File

@ -2,8 +2,8 @@ void main() {
int x = 0;
int y = 0;
int z = 0;
if (sk_Caps.externalTextureSupport) x = 1;
if (sk_Caps.fbFetchSupport) y = 1;
if (sk_Caps.canUseAnyFunctionInShader) z = 1;
if (sk_Caps.floatIs32Bits) x = 1;
if (sk_Caps.integerSupport) y = 1;
if (sk_Caps.builtinDeterminantSupport) z = 1;
sk_FragColor.rgb = half3(x, y, z);
}

View File

@ -37,7 +37,6 @@ void GrShaderCaps::dumpJSON(SkJSONWriter* writer) const {
writer->appendBool("FB Fetch Support", fFBFetchSupport);
writer->appendBool("Uses precision modifiers", fUsesPrecisionModifiers);
writer->appendBool("Can use any() function", fCanUseAnyFunctionInShader);
writer->appendBool("Can use min() and abs() together", fCanUseMinAndAbsTogether);
writer->appendBool("Can use fract() for negative values", fCanUseFractForNegativeValues);
writer->appendBool("Must force negated atan param to float", fMustForceNegatedAtanParamToFloat);
@ -90,7 +89,6 @@ void GrShaderCaps::dumpJSON(SkJSONWriter* writer) const { }
void GrShaderCaps::applyOptionsOverrides(const GrContextOptions& options) {
if (options.fDisableDriverCorrectnessWorkarounds) {
SkASSERT(fCanUseAnyFunctionInShader);
SkASSERT(fCanUseMinAndAbsTogether);
SkASSERT(fCanUseFractForNegativeValues);
SkASSERT(!fMustForceNegatedAtanParamToFloat);

View File

@ -3927,12 +3927,6 @@ void GrGLCaps::applyDriverCorrectnessWorkarounds(const GrGLContextInfo& ctxInfo,
shaderCaps->fFBFetchSupport = false;
}
// On the NexusS and GalaxyNexus, the use of 'any' causes the compilation error "Calls to any
// function that may require a gradient calculation inside a conditional block may return
// undefined results". This appears to be an issue with the 'any' call since even the simple
// "result=black; if (any()) result=white;" code fails to compile.
shaderCaps->fCanUseAnyFunctionInShader = (ctxInfo.vendor() != GrGLVendor::kImagination);
if (ctxInfo.renderer() == GrGLRenderer::kTegra_PreK1) {
// The Tegra3 compiler will sometimes never return if we have min(abs(x), 1.0),
// so we must do the abs first in a separate expression.

View File

@ -24,12 +24,12 @@ Differences from GLSL
the same as if and switch in all respects other than it being a compile-time
error to use a non-constant expression as a test.
* GLSL caps can be referenced via the syntax 'sk_Caps.<name>', e.g.
sk_Caps.canUseAnyFunctionInShader. The value will be a constant boolean or int,
sk_Caps.integerSupport. The value will be a constant boolean or int,
as appropriate. As SkSL supports constant folding and branch elimination, this
means that an 'if' statement which statically queries a cap will collapse down
to the chosen branch, meaning that:
if (sk_Caps.externalTextureSupport)
if (sk_Caps.integerSupport)
do_something();
else
do_something_else();

View File

@ -24,7 +24,7 @@ class ExternalFunction;
struct ProgramSettings {
// If true the destination fragment color is read sk_FragColor. It must be declared inout.
bool fFragColorIsInOut = false;
// if true, Setting objects (e.g. sk_Caps.fbFetchSupport) should be replaced with their
// if true, Setting objects (e.g. sk_Caps.integerSupport) should be replaced with their
// constant equivalents during compilation
bool fReplaceSettings = true;
// if true, all halfs are forced to be floats

View File

@ -90,9 +90,6 @@ struct ShaderCaps {
bool usesPrecisionModifiers() const { return fUsesPrecisionModifiers; }
// Returns whether we can use the glsl function any() in our shader code.
bool canUseAnyFunctionInShader() const { return fCanUseAnyFunctionInShader; }
bool canUseMinAndAbsTogether() const { return fCanUseMinAndAbsTogether; }
bool canUseFractForNegativeValues() const { return fCanUseFractForNegativeValues; }
@ -214,7 +211,6 @@ struct ShaderCaps {
bool fBuiltinDeterminantSupport = false;
// Used for specific driver bug work arounds
bool fCanUseAnyFunctionInShader = true;
bool fCanUseMinAndAbsTogether = true;
bool fCanUseFractForNegativeValues = true;
bool fMustForceNegatedAtanParamToFloat = false;

View File

@ -575,7 +575,7 @@ Represents applying the prefix operator `op` to `operand`.
|----------|------------|
| `String` | name |
Represents a field of `sk_Caps`, such as `“builtinDeterminantSupport”`.
Represents a field of `sk_Caps`, such as `“integerSupport”`.
---

View File

@ -87,20 +87,11 @@ static const CapsLookupTable& caps_lookup_table() {
// Create a lookup table that converts strings into the equivalent ShaderCaps methods.
static CapsLookupTable* sCapsLookupTable = new CapsLookupTable({
#define CAP(T, name) CapsLookupTable::Pair{#name, new T##CapsLookup{&ShaderCaps::name}}
CAP(Bool, fbFetchSupport),
CAP(Bool, fbFetchNeedsCustomOutput),
CAP(Bool, flatInterpolationSupport),
CAP(Bool, noperspectiveInterpolationSupport),
CAP(Bool, externalTextureSupport),
CAP(Bool, mustEnableAdvBlendEqs),
CAP(Bool, mustDeclareFragmentShaderOutput),
CAP(Bool, mustDoOpBetweenFloorAndAbs),
CAP(Bool, mustGuardDivisionEvenAfterExplicitZeroCheck),
CAP(Bool, atan2ImplementedAsAtanYOverX),
CAP(Bool, canUseAnyFunctionInShader),
CAP(Bool, floatIs32Bits),
CAP(Bool, integerSupport),
CAP(Bool, builtinFMASupport),
CAP(Bool, builtinDeterminantSupport),
CAP(Bool, rewriteMatrixVectorMultiply),
#undef CAP

View File

@ -22,7 +22,7 @@ class Context;
class Type;
/**
* Represents a compile-time constant setting, such as sk_Caps.fbFetchSupport. These IRNodes should
* Represents a compile-time constant setting, such as sk_Caps.integerSupport. These IRNodes should
* only exist in a dehydrated module. These nodes are replaced with the value of the setting during
* rehydration or compilation (i.e., whenever fReplaceSettings is true).
*/

View File

@ -65,7 +65,7 @@ DEF_TEST(SkRuntimeEffectInvalid_SkCapsDisallowed, r) {
// sk_Caps is an internal system. It should not be visible to runtime effects
test_invalid_effect(
r,
"half4 main(float2 p) { return sk_Caps.integerSupport ? half4(1) : half4(0); }",
"half4 main(float2 p) { return sk_Caps.floatIs32Bits ? half4(1) : half4(0); }",
"unknown identifier 'sk_Caps'");
}

View File

@ -42,10 +42,9 @@ OpStore %x %int_0
OpStore %y %int_0
OpStore %z %int_0
OpStore %x %int_1
OpStore %z %int_1
%20 = OpConvertSToF %float %int_1
%21 = OpConvertSToF %float %int_0
%22 = OpConvertSToF %float %int_1
%22 = OpConvertSToF %float %int_0
%24 = OpCompositeConstruct %v3float %20 %21 %22
%25 = OpLoad %v4float %sk_FragColor
%26 = OpVectorShuffle %v4float %25 %24 4 5 6 3

View File

@ -5,6 +5,5 @@ void main() {
int y = 0;
int z = 0;
x = 1;
z = 1;
sk_FragColor.xyz = vec3(float(x), float(y), float(z));
}

View File

@ -13,7 +13,6 @@ fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front
int y = 0;
int z = 0;
x = 1;
z = 1;
_out.sk_FragColor.xyz = half3(half(x), half(y), half(z));
return _out;
}