| 1 |
/* |
| 2 |
* Copyright 2012 Google Inc. |
| 3 |
* |
| 4 |
* Use of this source code is governed by a BSD-style license that can be |
| 5 |
* found in the LICENSE file. |
| 6 |
*/ |
| 7 |
|
| 8 |
|
| 9 |
#include "src/gpu/ganesh/GrShaderCaps.h" |
| 10 |
|
| 11 |
#include "include/gpu/ganesh/GrContextOptions.h" |
| 12 |
|
| 13 |
//////////////////////////////////////////////////////////////////////////////////////////// |
| 14 |
|
| 15 |
#ifdef SK_ENABLE_DUMP_GPU |
| 16 |
#include "src/utils/SkJSONWriter.h" |
| 17 |
|
| 18 |
void GrShaderCaps::dumpJSON(SkJSONWriter* writer) const { |
| 19 |
writer->beginObject(); |
| 20 |
|
| 21 |
writer->appendBool("Shader Derivative Support", fShaderDerivativeSupport); |
| 22 |
writer->appendBool("Dst Read In Shader Support", fDstReadInShaderSupport); |
| 23 |
writer->appendBool("Dual Source Blending Support", fDualSourceBlendingSupport); |
| 24 |
writer->appendBool("Integer Support", fIntegerSupport); |
| 25 |
writer->appendBool("Nonsquare Matrix Support", fNonsquareMatrixSupport); |
| 26 |
writer->appendBool("Inverse Hyperbolic Support", fInverseHyperbolicSupport); |
| 27 |
|
| 28 |
static const char* kAdvBlendEqInteractionStr[] = { |
| 29 |
"Not Supported", |
| 30 |
"Automatic", |
| 31 |
"General Enable", |
| 32 |
}; |
| 33 |
static_assert(0 == kNotSupported_AdvBlendEqInteraction); |
| 34 |
static_assert(1 == kAutomatic_AdvBlendEqInteraction); |
| 35 |
static_assert(2 == kGeneralEnable_AdvBlendEqInteraction); |
| 36 |
static_assert(std::size(kAdvBlendEqInteractionStr) == kLast_AdvBlendEqInteraction + 1); |
| 37 |
|
| 38 |
writer->appendBool("FB Fetch Support", fFBFetchSupport); |
| 39 |
writer->appendBool("Uses precision modifiers", fUsesPrecisionModifiers); |
| 40 |
writer->appendBool("Can use void-typed expressions in a sequence expression", |
| 41 |
fCanUseVoidInSequenceExpressions); |
| 42 |
writer->appendBool("Can use min() and abs() together", fCanUseMinAndAbsTogether); |
| 43 |
writer->appendBool("Can use fract() for negative values", fCanUseFractForNegativeValues); |
| 44 |
writer->appendBool("Must force negated atan param to float", fMustForceNegatedAtanParamToFloat); |
| 45 |
writer->appendBool("Must force negated ldexp param to multiply", |
| 46 |
fMustForceNegatedLdexpParamToMultiply); |
| 47 |
writer->appendBool("Must do op between floor and abs", fMustDoOpBetweenFloorAndAbs); |
| 48 |
writer->appendBool("Must use local out color for FBFetch", fRequiresLocalOutputColorForFBFetch); |
| 49 |
writer->appendBool("Must obfuscate uniform color", fMustObfuscateUniformColor); |
| 50 |
writer->appendBool("Must guard division even after explicit zero check", |
| 51 |
fMustGuardDivisionEvenAfterExplicitZeroCheck); |
| 52 |
writer->appendBool("Can use gl_FragCoord", fCanUseFragCoord); |
| 53 |
writer->appendBool("Add and true to loops workaround", fAddAndTrueToLoopCondition); |
| 54 |
writer->appendBool("Unfold short circuit as ternary", fUnfoldShortCircuitAsTernary); |
| 55 |
writer->appendBool("Emulate abs(int) function", fEmulateAbsIntFunction); |
| 56 |
writer->appendBool("Rewrite do while loops", fRewriteDoWhileLoops); |
| 57 |
writer->appendBool("Rewrite switch statements", fRewriteSwitchStatements); |
| 58 |
writer->appendBool("Rewrite pow with constant exponent", fRemovePowWithConstantExponent); |
| 59 |
writer->appendBool("Must write to sk_FragColor [workaround]", fMustWriteToFragColor); |
| 60 |
writer->appendBool("Don't add default precision statement for samplerExternalOES", |
| 61 |
fNoDefaultPrecisionForExternalSamplers); |
| 62 |
writer->appendBool("Rewrite matrix-vector multiply", fRewriteMatrixVectorMultiply); |
| 63 |
writer->appendBool("Rewrite matrix equality comparisons", fRewriteMatrixComparisons); |
| 64 |
writer->appendBool("Rounding fix required for Perlin noise", fPerlinNoiseRoundingFix); |
| 65 |
writer->appendBool("Must declare fragment front-facing", fMustDeclareFragmentFrontFacing); |
| 66 |
writer->appendBool("Cannot apply RelaxedPrecision to YCbCr sampling op", |
| 67 |
fCannotUseRelaxedPrecisionOnImageSample); |
| 68 |
writer->appendBool("Flat interpolation support", fFlatInterpolationSupport); |
| 69 |
writer->appendBool("Prefer flat interpolation", fPreferFlatInterpolation); |
| 70 |
writer->appendBool("No perspective interpolation support", fNoPerspectiveInterpolationSupport); |
| 71 |
writer->appendBool("Sample mask support", fSampleMaskSupport); |
| 72 |
writer->appendBool("External texture support", fExternalTextureSupport); |
| 73 |
writer->appendBool("sk_VertexID support", fVertexIDSupport); |
| 74 |
writer->appendBool("Infinity support", fInfinitySupport); |
| 75 |
writer->appendBool("Non-constant array index support", fNonconstantArrayIndexSupport); |
| 76 |
writer->appendBool("Bit manipulation support", fBitManipulationSupport); |
| 77 |
writer->appendBool("float == fp32", fFloatIs32Bits); |
| 78 |
writer->appendBool("half == fp32", fHalfIs32Bits); |
| 79 |
writer->appendBool("Has poor fragment precision", fHasLowFragmentPrecision); |
| 80 |
writer->appendBool("Builtin fma() support", fBuiltinFMASupport); |
| 81 |
writer->appendBool("Builtin determinant() support", fBuiltinDeterminantSupport); |
| 82 |
|
| 83 |
writer->appendS32("Max FS Samplers", fMaxFragmentSamplers); |
| 84 |
writer->appendCString("Advanced blend equation interaction", |
| 85 |
kAdvBlendEqInteractionStr[fAdvBlendEqInteraction]); |
| 86 |
|
| 87 |
writer->endObject(); |
| 88 |
} |
| 89 |
#else |
| 90 |
void GrShaderCaps::dumpJSON(SkJSONWriter* writer) const { } |
| 91 |
#endif |
| 92 |
|
| 93 |
void GrShaderCaps::applyOptionsOverrides(const GrContextOptions& options) { |
| 94 |
if (options.fDisableDriverCorrectnessWorkarounds) { |
| 95 |
SkASSERT(fCanUseVoidInSequenceExpressions); |
| 96 |
SkASSERT(fCanUseMinAndAbsTogether); |
| 97 |
SkASSERT(fCanUseFractForNegativeValues); |
| 98 |
SkASSERT(!fMustForceNegatedAtanParamToFloat); |
| 99 |
SkASSERT(!fMustForceNegatedLdexpParamToMultiply); |
| 100 |
SkASSERT(!fAtan2ImplementedAsAtanYOverX); |
| 101 |
SkASSERT(!fMustDoOpBetweenFloorAndAbs); |
| 102 |
SkASSERT(!fRequiresLocalOutputColorForFBFetch); |
| 103 |
SkASSERT(!fMustObfuscateUniformColor); |
| 104 |
SkASSERT(!fMustGuardDivisionEvenAfterExplicitZeroCheck); |
| 105 |
SkASSERT(fCanUseFragCoord); |
| 106 |
SkASSERT(!fAddAndTrueToLoopCondition); |
| 107 |
SkASSERT(!fUnfoldShortCircuitAsTernary); |
| 108 |
SkASSERT(!fEmulateAbsIntFunction); |
| 109 |
SkASSERT(!fRewriteDoWhileLoops); |
| 110 |
SkASSERT(!fRewriteSwitchStatements); |
| 111 |
SkASSERT(!fRemovePowWithConstantExponent); |
| 112 |
SkASSERT(!fMustWriteToFragColor); |
| 113 |
SkASSERT(!fNoDefaultPrecisionForExternalSamplers); |
| 114 |
SkASSERT(!fRewriteMatrixVectorMultiply); |
| 115 |
SkASSERT(!fRewriteMatrixComparisons); |
| 116 |
SkASSERT(!fPerlinNoiseRoundingFix); |
| 117 |
SkASSERT(!fMustDeclareFragmentFrontFacing); |
| 118 |
SkASSERT(!fCannotUseRelaxedPrecisionOnImageSample); |
| 119 |
} |
| 120 |
if (options.fReducedShaderVariations) { |
| 121 |
fReducedShaderMode = true; |
| 122 |
} |
| 123 |
#if defined(GPU_TEST_UTILS) |
| 124 |
if (options.fSuppressDualSourceBlending) { |
| 125 |
fDualSourceBlendingSupport = false; |
| 126 |
} |
| 127 |
if (options.fSuppressFramebufferFetch) { |
| 128 |
fFBFetchSupport = false; |
| 129 |
} |
| 130 |
#endif |
| 131 |
} |