Remove accessor functions from ShaderCaps.

Change-Id: Ifc4616c99bddd7d40d5a0bd2dd3c57bfb973500f
Bug: skia:12559
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/547825
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
John Stiles 2022-06-07 17:09:17 -04:00 committed by SkCQ
parent 0cb1463f90
commit 2a376045ca
22 changed files with 91 additions and 177 deletions

View File

@ -257,7 +257,7 @@ bool GrDirectContext::init() {
if (GrContextOptions::Enable::kNo == this->options().fAllowMultipleGlyphCacheTextures ||
// multitexturing supported only if range can represent the index + texcoords fully
!(this->caps()->shaderCaps()->fFloatIs32Bits ||
this->caps()->shaderCaps()->integerSupport())) {
this->caps()->shaderCaps()->fIntegerSupport)) {
allowMultitexturing = GrDrawOpAtlas::AllowMultitexturing::kNo;
} else {
allowMultitexturing = GrDrawOpAtlas::AllowMultitexturing::kYes;

View File

@ -23,12 +23,12 @@ struct GrShaderCaps : SkSL::ShaderCaps {
bool supportsDistanceFieldText() const { return fShaderDerivativeSupport; }
const char* noperspectiveInterpolationExtensionString() const {
SkASSERT(this->noperspectiveInterpolationSupport());
SkASSERT(this->fNoPerspectiveInterpolationSupport);
return fNoPerspectiveInterpolationExtensionString;
}
const char* sampleVariablesExtensionString() const {
SkASSERT(this->sampleMaskSupport());
SkASSERT(this->fSampleMaskSupport);
return fSampleVariablesExtensionString;
}

View File

@ -26,7 +26,7 @@ static void append_index_uv_varyings(GrGeometryProcessor::ProgramImpl::EmitArgs&
// Packing structure: texel coordinates have the 2-bit texture page encoded in bits 13 & 14 of
// the x coordinate. It would be nice to use bits 14 and 15, but iphone6 has problem with those
// bits when in gles. Iphone6 works fine with bits 14 and 15 in metal.
if (args.fShaderCaps->integerSupport()) {
if (args.fShaderCaps->fIntegerSupport) {
if (numTextureSamplers <= 1) {
args.fVertBuilder->codeAppendf(R"code(
int texIdx = 0;
@ -64,7 +64,7 @@ static void append_index_uv_varyings(GrGeometryProcessor::ProgramImpl::EmitArgs&
// it is worse to use a float so for now we always do.
texIdx->reset(SkSLType::kFloat);
// If we computed the local var "texIdx" as an int we will need to cast it to float
const char* cast = args.fShaderCaps->integerSupport() ? "float" : "";
const char* cast = args.fShaderCaps->fIntegerSupport ? "float" : "";
args.fVaryingHandler->addVarying("TexIndex", texIdx, Interpolation::kCanBeFlat);
args.fVertBuilder->codeAppendf("%s = %s(texIdx);", texIdx->vsOut(), cast);

View File

@ -141,7 +141,7 @@ GrBitmapTextGeoProc::GrBitmapTextGeoProc(const GrShaderCaps& caps,
}
fInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType,
caps.integerSupport() ? SkSLType::kUShort2 : SkSLType::kFloat2};
caps.fIntegerSupport ? SkSLType::kUShort2 : SkSLType::kFloat2};
this->setVertexAttributesWithImplicitOffsets(&fInPosition, 3);
if (numActiveViews) {

View File

@ -106,9 +106,9 @@ private:
void CustomXP::onAddToKey(const GrShaderCaps& caps, skgpu::KeyBuilder* b) const {
if (this->hasHWBlendEquation()) {
SkASSERT(caps.advBlendEqInteraction() > 0); // 0 will mean !xp.hasHWBlendEquation().
SkASSERT(caps.fAdvBlendEqInteraction > 0); // 0 will mean !xp.hasHWBlendEquation().
b->addBool(true, "has hardware blend equation");
b->add32(caps.advBlendEqInteraction());
b->add32(caps.fAdvBlendEqInteraction);
} else {
b->addBool(false, "has hardware blend equation");
b->add32(GrGLSLBlend::BlendKey(fMode));

View File

@ -228,7 +228,7 @@ GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(const GrShaderCaps& c
}
fInColor = {"inColor", kUByte4_norm_GrVertexAttribType, SkSLType::kHalf4 };
fInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType,
caps.integerSupport() ? SkSLType::kUShort2 : SkSLType::kFloat2};
caps.fIntegerSupport ? SkSLType::kUShort2 : SkSLType::kFloat2};
this->setVertexAttributesWithImplicitOffsets(&fInPosition, 3);
if (numViews) {
@ -494,7 +494,7 @@ GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc(const GrShaderCaps& caps,
fInPosition = {"inPosition", kFloat2_GrVertexAttribType, SkSLType::kFloat2};
fInColor = MakeColorAttribute("inColor", wideColor);
fInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType,
caps.integerSupport() ? SkSLType::kUShort2 : SkSLType::kFloat2};
caps.fIntegerSupport ? SkSLType::kUShort2 : SkSLType::kFloat2};
this->setVertexAttributesWithImplicitOffsets(&fInPosition, 3);
if (numViews) {
@ -807,7 +807,7 @@ GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc(const GrShaderCaps&
}
fInColor = {"inColor", kUByte4_norm_GrVertexAttribType, SkSLType::kHalf4};
fInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType,
caps.integerSupport() ? SkSLType::kUShort2 : SkSLType::kFloat2};
caps.fIntegerSupport ? SkSLType::kUShort2 : SkSLType::kFloat2};
this->setVertexAttributesWithImplicitOffsets(&fInPosition, 3);
if (numViews) {

View File

@ -35,7 +35,7 @@ private:
static bool should_use_variable_length_loop(const GrShaderCaps& caps) {
// If we're in reduced-shader mode, and we can use variable length loops, then use a uniform to
// limit the number of iterations, so we don't need a code variation for each width.
return (caps.generation() >= SkSL::GLSLGeneration::k300es && caps.fReducedShaderMode);
return (caps.fGLSLGeneration >= SkSL::GLSLGeneration::k300es && caps.fReducedShaderMode);
}
void GrGaussianConvolutionFragmentProcessor::Impl::emitCode(EmitArgs& args) {

View File

@ -1064,8 +1064,8 @@ void GrGLCaps::initBlendEqationSupport(const GrGLContextInfo& ctxInfo) {
GrShaderCaps* shaderCaps = static_cast<GrShaderCaps*>(fShaderCaps.get());
bool layoutQualifierSupport = false;
if ((GR_IS_GR_GL(fStandard) && shaderCaps->generation() >= SkSL::GLSLGeneration::k140) ||
(GR_IS_GR_GL_ES(fStandard) && shaderCaps->generation() >= SkSL::GLSLGeneration::k300es)) {
if ((GR_IS_GR_GL(fStandard) && shaderCaps->fGLSLGeneration >= SkSL::GLSLGeneration::k140) ||
(GR_IS_GR_GL_ES(fStandard) && shaderCaps->fGLSLGeneration >= SkSL::GLSLGeneration::k300es)){
layoutQualifierSupport = true;
} else if (GR_IS_GR_WEBGL(fStandard)) {
return;

View File

@ -666,7 +666,7 @@ static bool check_backend_texture(const GrBackendTexture& backendTex,
return false;
}
if (GR_GL_TEXTURE_EXTERNAL == desc->fTarget) {
if (!caps.shaderCaps()->externalTextureSupport()) {
if (!caps.shaderCaps()->fExternalTextureSupport) {
return false;
}
} else if (GR_GL_TEXTURE_RECTANGLE == desc->fTarget) {
@ -3150,7 +3150,7 @@ bool GrGLGpu::createCopyProgram(GrTexture* srcTex) {
GrShaderVar oFragColor("o_FragColor", SkSLType::kHalf4, GrShaderVar::TypeModifier::Out);
SkString vshaderTxt;
if (shaderCaps->noperspectiveInterpolationSupport()) {
if (shaderCaps->fNoPerspectiveInterpolationSupport) {
if (const char* extension = shaderCaps->noperspectiveInterpolationExtensionString()) {
vshaderTxt.appendf("#extension %s : require\n", extension);
}
@ -3176,7 +3176,7 @@ bool GrGLGpu::createCopyProgram(GrTexture* srcTex) {
);
SkString fshaderTxt;
if (shaderCaps->noperspectiveInterpolationSupport()) {
if (shaderCaps->fNoPerspectiveInterpolationSupport) {
if (const char* extension = shaderCaps->noperspectiveInterpolationExtensionString()) {
fshaderTxt.appendf("#extension %s : require\n", extension);
}
@ -3257,7 +3257,7 @@ bool GrGLGpu::createMipmapProgram(int progIdx) {
GrShaderVar oFragColor("o_FragColor", SkSLType::kHalf4,GrShaderVar::TypeModifier::Out);
SkString vshaderTxt;
if (shaderCaps->noperspectiveInterpolationSupport()) {
if (shaderCaps->fNoPerspectiveInterpolationSupport) {
if (const char* extension = shaderCaps->noperspectiveInterpolationExtensionString()) {
vshaderTxt.appendf("#extension %s : require\n", extension);
}
@ -3310,7 +3310,7 @@ bool GrGLGpu::createMipmapProgram(int progIdx) {
vshaderTxt.append("}");
SkString fshaderTxt;
if (shaderCaps->noperspectiveInterpolationSupport()) {
if (shaderCaps->fNoPerspectiveInterpolationSupport) {
if (const char* extension = shaderCaps->noperspectiveInterpolationExtensionString()) {
fshaderTxt.appendf("#extension %s : require\n", extension);
}

View File

@ -121,7 +121,7 @@ void GrGLAttribArrayState::set(GrGLGpu* gpu,
stride,
offsetAsPtr));
} else {
SkASSERT(gpu->caps()->shaderCaps()->integerSupport());
SkASSERT(gpu->caps()->shaderCaps()->fIntegerSupport);
SkASSERT(!layout.fNormalized);
GR_GL_CALL(gpu->glInterface(), VertexAttribIPointer(index,
layout.fCount,

View File

@ -19,13 +19,13 @@ const char* GrGLSLFragmentShaderBuilder::dstColor() {
SkDEBUGCODE(fHasReadDstColorThisStage_DebugOnly = true;)
const GrShaderCaps* shaderCaps = fProgramBuilder->shaderCaps();
if (shaderCaps->fbFetchSupport()) {
if (shaderCaps->fFBFetchSupport) {
this->addFeature(1 << kFramebufferFetch_GLSLPrivateFeature,
shaderCaps->fFBFetchExtensionString);
// Some versions of this extension string require declaring custom color output on ES 3.0+
const char* fbFetchColorName = "sk_LastFragColor";
if (shaderCaps->fbFetchNeedsCustomOutput()) {
if (shaderCaps->fFBFetchNeedsCustomOutput) {
this->enableCustomOutput();
fCustomColorOutput->setTypeModifier(GrShaderVar::TypeModifier::InOut);
fbFetchColorName = DeclaredColorOutputName();

View File

@ -284,7 +284,7 @@ void GrGLSLShaderBuilder::appendDecls(const VarArray& vars, SkString* out) const
}
void GrGLSLShaderBuilder::addLayoutQualifier(const char* param, InterfaceQualifier interface) {
SkASSERT(fProgramBuilder->shaderCaps()->generation() >= SkSL::GLSLGeneration::k330 ||
SkASSERT(fProgramBuilder->shaderCaps()->fGLSLGeneration >= SkSL::GLSLGeneration::k330 ||
fProgramBuilder->shaderCaps()->mustEnableAdvBlendEqs());
fLayoutParams[interface].push_back() = param;
}

View File

@ -78,7 +78,7 @@ void GrGLSLVaryingHandler::addAttribute(const GrShaderVar& var) {
void GrGLSLVaryingHandler::setNoPerspective() {
const GrShaderCaps& caps = *fProgramBuilder->shaderCaps();
if (!caps.noperspectiveInterpolationSupport()) {
if (!caps.fNoPerspectiveInterpolationSupport) {
return;
}
if (const char* extension = caps.noperspectiveInterpolationExtensionString()) {
@ -119,7 +119,7 @@ void GrGLSLVaryingHandler::getVertexDecls(SkString* inputDecls, SkString* output
void GrGLSLVaryingHandler::getFragDecls(SkString* inputDecls, SkString* outputDecls) const {
// We should not have any outputs in the fragment shader when using version 1.10
SkASSERT(SkSL::GLSLGeneration::k110 != fProgramBuilder->shaderCaps()->generation() ||
SkASSERT(SkSL::GLSLGeneration::k110 != fProgramBuilder->shaderCaps()->fGLSLGeneration ||
fFragOutputs.empty());
this->appendDecls(fFragInputs, inputDecls);
this->appendDecls(fFragOutputs, outputDecls);

View File

@ -654,7 +654,7 @@ static std::unique_ptr<GrFragmentProcessor> make_tiled_gradient(
optFlags |= GrSkSLFP::OptFlags::kPreservesOpaqueInput;
}
const bool useFloorAbsWorkaround =
args.fContext->priv().caps()->shaderCaps()->mustDoOpBetweenFloorAndAbs();
args.fContext->priv().caps()->shaderCaps()->fMustDoOpBetweenFloorAndAbs;
return GrSkSLFP::Make(effect, "TiledGradient", /*inputFP=*/nullptr, optFlags,
"colorizer", GrSkSLFP::IgnoreOptFlags(std::move(colorizer)),
@ -811,7 +811,7 @@ std::unique_ptr<GrFragmentProcessor> MakeSweep(const SkSweepGradient& shader,
// undefined behavior of the second paramenter being 0 instead of doing the divide ourselves and
// using atan instead.
int useAtanWorkaround =
args.fContext->priv().caps()->shaderCaps()->atan2ImplementedAsAtanYOverX();
args.fContext->priv().caps()->shaderCaps()->fAtan2ImplementedAsAtanYOverX;
static auto effect = SkMakeRuntimeEffect(SkRuntimeEffect::MakeForShader, R"(
uniform half bias;
uniform half scale;

View File

@ -516,7 +516,7 @@ std::unique_ptr<Program> Compiler::convertProgram(ProgramKind kind,
void Compiler::updateInputsForBuiltinVariable(const Variable& var) {
switch (var.modifiers().fLayout.fBuiltin) {
case SK_FRAGCOORD_BUILTIN:
if (fContext->fCaps.canUseFragCoord()) {
if (fContext->fCaps.fCanUseFragCoord) {
ThreadContext::Inputs().fUseFlipRTUniform =
!fContext->fConfig->fSettings.fForceNoRTFlip;
}

View File

@ -32,7 +32,7 @@ ThreadContext::ThreadContext(SkSL::Compiler* compiler, SkSL::ProgramKind kind,
fOldConfig = fCompiler->fContext->fConfig;
if (!isModule) {
if (compiler->context().fCaps.useNodePools() && settings.fDSLUseMemoryPool) {
if (compiler->context().fCaps.fUseNodePools && settings.fDSLUseMemoryPool) {
fPool = Pool::Create();
fPool->attachToThread();
}

View File

@ -38,41 +38,6 @@ struct ShaderCaps {
kLast_AdvBlendEqInteraction = kGeneralEnable_AdvBlendEqInteraction
};
//
// TODO: Remove these accessors
//
/** Indicates true 32-bit integer support, with unsigned types and bitwise operations */
bool integerSupport() const { return fIntegerSupport; }
/**
* Some helper functions for encapsulating various extensions to read FB Buffer on openglES
*
* TODO: On desktop opengl 4.2+ we can achieve something similar to this effect
*/
bool fbFetchSupport() const { return fFBFetchSupport; }
bool fbFetchNeedsCustomOutput() const { return fFBFetchNeedsCustomOutput; }
const char* versionDeclString() const { return fVersionDeclString; }
const char* fbFetchColorName() const { return fFBFetchColorName; }
bool noperspectiveInterpolationSupport() const { return fNoPerspectiveInterpolationSupport; }
bool sampleMaskSupport() const { return fSampleMaskSupport; }
bool externalTextureSupport() const { return fExternalTextureSupport; }
bool floatIs32Bits() const { return fFloatIs32Bits; }
// SkSL only.
bool builtinFMASupport() const { return fBuiltinFMASupport; }
bool builtinDeterminantSupport() const { return fBuiltinDeterminantSupport; }
AdvBlendEqInteraction advBlendEqInteraction() const { return fAdvBlendEqInteraction; }
bool mustEnableAdvBlendEqs() const {
return fAdvBlendEqInteraction >= kGeneralEnable_AdvBlendEqInteraction;
}
@ -81,74 +46,6 @@ struct ShaderCaps {
return fGLSLGeneration > SkSL::GLSLGeneration::k110;
}
bool usesPrecisionModifiers() const { return fUsesPrecisionModifiers; }
bool canUseMinAndAbsTogether() const { return fCanUseMinAndAbsTogether; }
bool canUseFractForNegativeValues() const { return fCanUseFractForNegativeValues; }
bool mustForceNegatedAtanParamToFloat() const { return fMustForceNegatedAtanParamToFloat; }
// http://skbug.com/12076
bool mustForceNegatedLdexpParamToMultiply() const {
return fMustForceNegatedLdexpParamToMultiply;
}
// Returns whether a device incorrectly implements atan(y,x) as atan(y/x)
bool atan2ImplementedAsAtanYOverX() const { return fAtan2ImplementedAsAtanYOverX; }
// If this returns true some operation (could be a no op) must be called between floor and abs
// to make sure the driver compiler doesn't inline them together which can cause a driver bug in
// the shader.
bool mustDoOpBetweenFloorAndAbs() const { return fMustDoOpBetweenFloorAndAbs; }
// If false, SkSL uses a workaround so that sk_FragCoord doesn't actually query gl_FragCoord
bool canUseFragCoord() const { return fCanUseFragCoord; }
// If true, short ints can't represent every integer in the 16-bit two's complement range as
// required by the spec. SKSL will always emit full ints.
bool incompleteShortIntPrecision() const { return fIncompleteShortIntPrecision; }
// If true, then conditions in for loops need "&& true" to work around driver bugs.
bool addAndTrueToLoopCondition() const { return fAddAndTrueToLoopCondition; }
// If true, then expressions such as "x && y" or "x || y" are rewritten as
// ternary to work around driver bugs.
bool unfoldShortCircuitAsTernary() const { return fUnfoldShortCircuitAsTernary; }
bool emulateAbsIntFunction() const { return fEmulateAbsIntFunction; }
bool rewriteDoWhileLoops() const { return fRewriteDoWhileLoops; }
bool rewriteSwitchStatements() const { return fRewriteSwitchStatements; }
bool removePowWithConstantExponent() const { return fRemovePowWithConstantExponent; }
// The D3D shader compiler, when targeting PS 3.0 (ie within ANGLE) fails to compile certain
// constructs. See detailed comments in GrGLCaps.cpp.
bool mustGuardDivisionEvenAfterExplicitZeroCheck() const {
return fMustGuardDivisionEvenAfterExplicitZeroCheck;
}
// The Android emulator claims samplerExternalOES is an unknown type if a default precision
// statement is made for the type.
bool noDefaultPrecisionForExternalSamplers() const {
return fNoDefaultPrecisionForExternalSamplers;
}
// ARM GPUs calculate `matrix * vector` in SPIR-V at full precision, even when the inputs are
// RelaxedPrecision. Rewriting the multiply as a sum of vector*scalar fixes this. (skia:11769)
bool rewriteMatrixVectorMultiply() const {
return fRewriteMatrixVectorMultiply;
}
// Rewrites matrix equality comparisons to avoid an Adreno driver bug. (skia:11308)
bool rewriteMatrixComparisons() const { return fRewriteMatrixComparisons; }
// By default, SkSL pools IR nodes per-program. To debug memory corruption, it is sometimes
// helpful to disable that feature.
bool useNodePools() const { return fUseNodePools; }
// 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.
@ -162,12 +59,12 @@ struct ShaderCaps {
// by secondExternalTextureExtensionString(). If that function returns nullptr, then only one
// extension is required.
const char* externalTextureExtensionString() const {
SkASSERT(this->externalTextureSupport());
SkASSERT(this->fExternalTextureSupport);
return fExternalTextureExtensionString;
}
const char* secondExternalTextureExtensionString() const {
SkASSERT(this->externalTextureSupport());
SkASSERT(this->fExternalTextureSupport);
return fSecondExternalTextureExtensionString;
}
@ -182,11 +79,10 @@ struct ShaderCaps {
return SkSL::Version::k100;
}
SkSL::GLSLGeneration generation() const { return fGLSLGeneration; }
SkSL::GLSLGeneration fGLSLGeneration = SkSL::GLSLGeneration::k330;
bool fShaderDerivativeSupport = false;
/** Indicates true 32-bit integer support, with unsigned types and bitwise operations */
bool fIntegerSupport = false;
bool fNonsquareMatrixSupport = false;
/** asinh(), acosh(), atanh() */
@ -208,23 +104,41 @@ struct ShaderCaps {
bool fCanUseMinAndAbsTogether = true;
bool fCanUseFractForNegativeValues = true;
bool fMustForceNegatedAtanParamToFloat = false;
bool fMustForceNegatedLdexpParamToMultiply = false;
bool fMustForceNegatedLdexpParamToMultiply = false; // http://skbug.com/12076
// Returns whether a device incorrectly implements atan(y,x) as atan(y/x)
bool fAtan2ImplementedAsAtanYOverX = false;
// If this returns true some operation (could be a no op) must be called between floor and abs
// to make sure the driver compiler doesn't inline them together which can cause a driver bug in
// the shader.
bool fMustDoOpBetweenFloorAndAbs = false;
// The D3D shader compiler, when targeting PS 3.0 (ie within ANGLE) fails to compile certain
// constructs. See detailed comments in GrGLCaps.cpp.
bool fMustGuardDivisionEvenAfterExplicitZeroCheck = false;
// If false, SkSL uses a workaround so that sk_FragCoord doesn't actually query gl_FragCoord
bool fCanUseFragCoord = true;
// If true, short ints can't represent every integer in the 16-bit two's complement range as
// required by the spec. SKSL will always emit full ints.
bool fIncompleteShortIntPrecision = false;
// If true, then conditions in for loops need "&& true" to work around driver bugs.
bool fAddAndTrueToLoopCondition = false;
// If true, then expressions such as "x && y" or "x || y" are rewritten as ternary to work
// around driver bugs.
bool fUnfoldShortCircuitAsTernary = false;
bool fEmulateAbsIntFunction = false;
bool fRewriteDoWhileLoops = false;
bool fRewriteSwitchStatements = false;
bool fRemovePowWithConstantExponent = false;
// The Android emulator claims samplerExternalOES is an unknown type if a default precision
// statement is made for the type.
bool fNoDefaultPrecisionForExternalSamplers = false;
// ARM GPUs calculate `matrix * vector` in SPIR-V at full precision, even when the inputs are
// RelaxedPrecision. Rewriting the multiply as a sum of vector*scalar fixes this. (skia:11769)
bool fRewriteMatrixVectorMultiply = false;
// Rewrites matrix equality comparisons to avoid an Adreno driver bug. (skia:11308)
bool fRewriteMatrixComparisons = false;
// This controls behavior of the SkSL compiler, not the code we generate
// This controls behavior of the SkSL compiler, not the code we generate. By default, SkSL pools
// IR nodes per-program. To debug memory corruption, it can be helpful to disable that feature.
bool fUseNodePools = true;
const char* fVersionDeclString = "";

View File

@ -97,7 +97,7 @@ void GLSLCodeGenerator::writeExtension(std::string_view name, bool require) {
}
bool GLSLCodeGenerator::usesPrecisionModifiers() const {
return this->caps().usesPrecisionModifiers();
return this->caps().fUsesPrecisionModifiers;
}
// Returns the name of the type with array dimensions, e.g. `float[2]`.
@ -260,7 +260,7 @@ static bool is_abs(Expression& expr) {
// turns min(abs(x), y) into ((tmpVar1 = abs(x)) < (tmpVar2 = y) ? tmpVar1 : tmpVar2) to avoid a
// Tegra3 compiler bug.
void GLSLCodeGenerator::writeMinAbsHack(Expression& absExpr, Expression& otherExpr) {
SkASSERT(!this->caps().canUseMinAndAbsTogether());
SkASSERT(!this->caps().fCanUseMinAndAbsTogether);
std::string tmpVar1 = "minAbsHackVar" + std::to_string(fVarCount++);
std::string tmpVar2 = "minAbsHackVar" + std::to_string(fVarCount++);
this->fFunctionHeader += std::string(" ") + this->getTypePrecision(absExpr.type()) +
@ -470,7 +470,7 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
const char* closingParen = ")";
switch (c.function().intrinsicKind()) {
case k_abs_IntrinsicKind: {
if (!this->caps().emulateAbsIntFunction())
if (!this->caps().fEmulateAbsIntFunction)
break;
SkASSERT(arguments.size() == 1);
if (!arguments[0]->type().matches(*fContext.fTypes.fInt)) {
@ -491,7 +491,7 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
break;
}
case k_atan_IntrinsicKind:
if (this->caps().mustForceNegatedAtanParamToFloat() &&
if (this->caps().fMustForceNegatedAtanParamToFloat &&
arguments.size() == 2 &&
arguments[1]->kind() == Expression::Kind::kPrefix) {
const PrefixExpression& p = (PrefixExpression&) *arguments[1];
@ -506,7 +506,7 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
}
break;
case k_ldexp_IntrinsicKind:
if (this->caps().mustForceNegatedLdexpParamToMultiply() &&
if (this->caps().fMustForceNegatedLdexpParamToMultiply &&
arguments.size() == 2 &&
arguments[1]->is<PrefixExpression>()) {
const PrefixExpression& p = arguments[1]->as<PrefixExpression>();
@ -539,14 +539,14 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
}
break;
case k_determinant_IntrinsicKind:
if (!this->caps().builtinDeterminantSupport()) {
if (!this->caps().fBuiltinDeterminantSupport) {
SkASSERT(arguments.size() == 1);
this->writeDeterminantHack(*arguments[0]);
return;
}
break;
case k_fma_IntrinsicKind:
if (!this->caps().builtinFMASupport()) {
if (!this->caps().fBuiltinFMASupport) {
SkASSERT(arguments.size() == 3);
this->write("((");
this->writeExpression(*arguments[0], Precedence::kSequence);
@ -559,7 +559,7 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
}
break;
case k_fract_IntrinsicKind:
if (!this->caps().canUseFractForNegativeValues()) {
if (!this->caps().fCanUseFractForNegativeValues) {
SkASSERT(arguments.size() == 1);
this->write("(0.5 - sign(");
this->writeExpression(*arguments[0], Precedence::kSequence);
@ -570,21 +570,21 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
}
break;
case k_inverse_IntrinsicKind:
if (this->caps().generation() < SkSL::GLSLGeneration::k140) {
if (this->caps().fGLSLGeneration < SkSL::GLSLGeneration::k140) {
SkASSERT(arguments.size() == 1);
this->writeInverseHack(*arguments[0]);
return;
}
break;
case k_inversesqrt_IntrinsicKind:
if (this->caps().generation() < SkSL::GLSLGeneration::k130) {
if (this->caps().fGLSLGeneration < SkSL::GLSLGeneration::k130) {
SkASSERT(arguments.size() == 1);
this->writeInverseSqrtHack(*arguments[0]);
return;
}
break;
case k_min_IntrinsicKind:
if (!this->caps().canUseMinAndAbsTogether()) {
if (!this->caps().fCanUseMinAndAbsTogether) {
SkASSERT(arguments.size() == 2);
if (is_abs(*arguments[0])) {
this->writeMinAbsHack(*arguments[0], *arguments[1]);
@ -599,7 +599,7 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
}
break;
case k_pow_IntrinsicKind:
if (!this->caps().removePowWithConstantExponent()) {
if (!this->caps().fRemovePowWithConstantExponent) {
break;
}
// pow(x, y) on some NVIDIA drivers causes crashes if y is a
@ -678,7 +678,7 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
break;
}
this->write("texture");
if (this->caps().generation() < SkSL::GLSLGeneration::k130) {
if (this->caps().fGLSLGeneration < SkSL::GLSLGeneration::k130) {
this->write(dim);
}
if (proj) {
@ -688,7 +688,7 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
break;
}
case k_transpose_IntrinsicKind:
if (this->caps().generation() < SkSL::GLSLGeneration::k130) {
if (this->caps().fGLSLGeneration < SkSL::GLSLGeneration::k130) {
SkASSERT(arguments.size() == 1);
this->writeTransposeHack(*arguments[0]);
return;
@ -763,9 +763,9 @@ void GLSLCodeGenerator::writeAnyConstructor(const AnyConstructor& c, Precedence
}
void GLSLCodeGenerator::writeFragCoord() {
if (!this->caps().canUseFragCoord()) {
if (!this->caps().fCanUseFragCoord) {
if (!fSetupFragCoordWorkaround) {
const char* precision = usesPrecisionModifiers() ? "highp " : "";
const char* precision = this->usesPrecisionModifiers() ? "highp " : "";
fFunctionHeader += precision;
fFunctionHeader += " float sk_FragCoord_InvW = 1. / sk_FragCoord_Workaround.w;\n";
fFunctionHeader += precision;
@ -831,8 +831,8 @@ void GLSLCodeGenerator::writeVariableReference(const VariableReference& ref) {
this->write("gl_InstanceID");
break;
case SK_LASTFRAGCOLOR_BUILTIN:
if (this->caps().fbFetchSupport()) {
this->write(this->caps().fbFetchColorName());
if (this->caps().fFBFetchSupport) {
this->write(this->caps().fFBFetchColorName);
} else {
fContext.fErrors->error(ref.fPosition,
"sk_LastFragColor requires framebuffer fetch support");
@ -911,13 +911,13 @@ void GLSLCodeGenerator::writeBinaryExpression(const BinaryExpression& b,
const Expression& left = *b.left();
const Expression& right = *b.right();
Operator op = b.getOperator();
if (this->caps().unfoldShortCircuitAsTernary() &&
if (this->caps().fUnfoldShortCircuitAsTernary &&
(op.kind() == Operator::Kind::LOGICALAND || op.kind() == Operator::Kind::LOGICALOR)) {
this->writeShortCircuitWorkaroundExpression(b, parentPrecedence);
return;
}
if (this->caps().rewriteMatrixComparisons() &&
if (this->caps().fRewriteMatrixComparisons &&
left.type().isMatrix() && right.type().isMatrix() &&
(op.kind() == Operator::Kind::EQEQ || op.kind() == Operator::Kind::NEQ)) {
this->writeMatrixComparisonWorkaround(b);
@ -933,7 +933,7 @@ void GLSLCodeGenerator::writeBinaryExpression(const BinaryExpression& b,
left.is<FieldAccess>() &&
is_sk_position(left.as<FieldAccess>()) &&
!right.containsRTAdjust() &&
!this->caps().canUseFragCoord();
!this->caps().fCanUseFragCoord;
if (positionWorkaround) {
this->write("sk_FragCoord_Workaround = (");
}
@ -1128,7 +1128,7 @@ void GLSLCodeGenerator::writeModifiers(const Modifiers& modifiers,
(modifiers.fFlags & Modifiers::kOut_Flag)) {
this->write("inout ");
} else if (modifiers.fFlags & Modifiers::kIn_Flag) {
if (globalContext && this->caps().generation() < SkSL::GLSLGeneration::k130) {
if (globalContext && this->caps().fGLSLGeneration < SkSL::GLSLGeneration::k130) {
this->write(ProgramConfig::IsVertex(fProgram.fConfig->fKind) ? "attribute "
: "varying ");
} else {
@ -1136,7 +1136,7 @@ void GLSLCodeGenerator::writeModifiers(const Modifiers& modifiers,
}
} else if (modifiers.fFlags & Modifiers::kOut_Flag) {
if (globalContext &&
this->caps().generation() < SkSL::GLSLGeneration::k130) {
this->caps().fGLSLGeneration < SkSL::GLSLGeneration::k130) {
this->write("varying ");
} else {
this->write("out ");
@ -1181,13 +1181,13 @@ void GLSLCodeGenerator::writeVarInitializer(const Variable& var, const Expressio
}
const char* GLSLCodeGenerator::getTypePrecision(const Type& type) {
if (usesPrecisionModifiers()) {
if (this->usesPrecisionModifiers()) {
switch (type.typeKind()) {
case Type::TypeKind::kScalar:
if (type.matches(*fContext.fTypes.fShort) ||
type.matches(*fContext.fTypes.fUShort)) {
if (fProgram.fConfig->fSettings.fForceHighPrecision ||
this->caps().incompleteShortIntPrecision()) {
this->caps().fIncompleteShortIntPrecision) {
return "highp ";
}
return "mediump ";
@ -1338,7 +1338,7 @@ void GLSLCodeGenerator::writeForStatement(const ForStatement& f) {
this->write("; ");
}
if (f.test()) {
if (this->caps().addAndTrueToLoopCondition()) {
if (this->caps().fAddAndTrueToLoopCondition) {
std::unique_ptr<Expression> and_true(new BinaryExpression(
Position(), f.test()->clone(), Operator::Kind::LOGICALAND,
Literal::MakeBool(fContext, Position(), /*value=*/true),
@ -1357,7 +1357,7 @@ void GLSLCodeGenerator::writeForStatement(const ForStatement& f) {
}
void GLSLCodeGenerator::writeDoStatement(const DoStatement& d) {
if (!this->caps().rewriteDoWhileLoops()) {
if (!this->caps().fRewriteDoWhileLoops) {
this->write("do ");
this->writeStatement(*d.statement());
this->write(" while (");
@ -1419,7 +1419,7 @@ void GLSLCodeGenerator::writeExpressionStatement(const ExpressionStatement& s) {
}
void GLSLCodeGenerator::writeSwitchStatement(const SwitchStatement& s) {
if (this->caps().rewriteSwitchStatements()) {
if (this->caps().fRewriteSwitchStatements) {
std::string fallthroughVar = "_tmpSwitchFallthrough" + std::to_string(fVarCount++);
std::string valueVar = "_tmpSwitchValue" + std::to_string(fVarCount++);
std::string loopVar = "_tmpSwitchLoop" + std::to_string(fVarCount++);
@ -1523,8 +1523,8 @@ void GLSLCodeGenerator::writeReturnStatement(const ReturnStatement& r) {
}
void GLSLCodeGenerator::writeHeader() {
if (this->caps().versionDeclString()) {
this->write(this->caps().versionDeclString());
if (this->caps().fVersionDeclString) {
this->write(this->caps().fVersionDeclString);
this->finishLine();
}
}
@ -1549,7 +1549,7 @@ void GLSLCodeGenerator::writeProgramElement(const ProgramElement& e) {
} else {
this->write("out ");
}
if (usesPrecisionModifiers()) {
if (this->usesPrecisionModifiers()) {
this->write("mediump ");
}
this->writeLine("vec4 sk_FragColor;");
@ -1582,7 +1582,7 @@ void GLSLCodeGenerator::writeProgramElement(const ProgramElement& e) {
void GLSLCodeGenerator::writeInputVars() {
if (fProgram.fInputs.fUseFlipRTUniform) {
const char* precision = usesPrecisionModifiers() ? "highp " : "";
const char* precision = this->usesPrecisionModifiers() ? "highp " : "";
fGlobals.writeText("uniform ");
fGlobals.writeText(precision);
fGlobals.writeText("vec2 " SKSL_RTFLIP_NAME ";\n");
@ -1615,7 +1615,7 @@ bool GLSLCodeGenerator::generateCode() {
this->writeInputVars();
write_stringstream(fGlobals, *rawOut);
if (!this->caps().canUseFragCoord()) {
if (!this->caps().fCanUseFragCoord) {
Layout layout;
if (ProgramConfig::IsVertex(fProgram.fConfig->fKind)) {
Modifiers modifiers(layout, Modifiers::kOut_Flag);
@ -1639,7 +1639,7 @@ bool GLSLCodeGenerator::generateCode() {
fProgram.fConfig->fSettings.fForceHighPrecision ? "highp" : "mediump";
this->write(String::printf("precision %s float;\n", precision));
this->write(String::printf("precision %s sampler2D;\n", precision));
if (fFoundExternalSamplerDecl && !this->caps().noDefaultPrecisionForExternalSamplers()) {
if (fFoundExternalSamplerDecl && !this->caps().fNoDefaultPrecisionForExternalSamplers) {
this->write(String::printf("precision %s samplerExternalOES;\n", precision));
}
if (fFoundRectSamplerDecl) {

View File

@ -77,7 +77,7 @@ protected:
virtual void writeHeader();
virtual bool usesPrecisionModifiers() const;
bool usesPrecisionModifiers() const;
virtual std::string getTypeName(const Type& type);

View File

@ -54,7 +54,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
return;
}
GrGLGpu* gpu0 = static_cast<GrGLGpu*>(context0->priv().getGpu());
if (!gpu0->glCaps().shaderCaps()->externalTextureSupport()) {
if (!gpu0->glCaps().shaderCaps()->fExternalTextureSupport) {
return;
}

View File

@ -30,7 +30,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(TextureBindingsResetTest, reporter, ctxInf
SkTDArray<Target> targets;
targets.push_back({GR_GL_TEXTURE_2D, GR_GL_TEXTURE_BINDING_2D});
bool supportExternal;
if ((supportExternal = glGpu->glCaps().shaderCaps()->externalTextureSupport())) {
if ((supportExternal = glGpu->glCaps().shaderCaps()->fExternalTextureSupport)) {
targets.push_back({GR_GL_TEXTURE_EXTERNAL, GR_GL_TEXTURE_BINDING_EXTERNAL});
}
bool supportRectangle;

View File

@ -1888,9 +1888,9 @@ static std::string build_metal_highlight_shader(const std::string& inShader) {
}
static std::string build_glsl_highlight_shader(const GrShaderCaps& shaderCaps) {
const char* versionDecl = shaderCaps.versionDeclString();
const char* versionDecl = shaderCaps.fVersionDeclString;
std::string highlight = versionDecl ? versionDecl : "";
if (shaderCaps.usesPrecisionModifiers()) {
if (shaderCaps.fUsesPrecisionModifiers) {
highlight.append("precision mediump float;\n");
}
SkSL::String::appendf(&highlight, "out vec4 sk_FragColor;\n"