diff options
Diffstat (limited to 'src/gpu')
31 files changed, 301 insertions, 304 deletions
diff --git a/src/gpu/GrProgramDesc.cpp b/src/gpu/GrProgramDesc.cpp index 0390df01c0..c6a1bcfc0d 100644 --- a/src/gpu/GrProgramDesc.cpp +++ b/src/gpu/GrProgramDesc.cpp @@ -110,7 +110,7 @@ static void add_sampler_and_image_keys(GrProcessorKeyBuilder* b, const GrProcess * function because it is hairy, though FPs do not have attribs, and GPs do not have transforms */ static bool gen_meta_key(const GrProcessor& proc, - const GrShaderCaps& glslCaps, + const GrShaderCaps& shaderCaps, uint32_t transformKey, GrProcessorKeyBuilder* b) { size_t processorKeySize = b->size(); @@ -122,7 +122,7 @@ static bool gen_meta_key(const GrProcessor& proc, return false; } - add_sampler_and_image_keys(b, proc, glslCaps); + add_sampler_and_image_keys(b, proc, shaderCaps); uint32_t* key = b->add32n(2); key[0] = (classID << 16) | SkToU32(processorKeySize); @@ -132,25 +132,25 @@ static bool gen_meta_key(const GrProcessor& proc, static bool gen_frag_proc_and_meta_keys(const GrPrimitiveProcessor& primProc, const GrFragmentProcessor& fp, - const GrShaderCaps& glslCaps, + const GrShaderCaps& shaderCaps, GrProcessorKeyBuilder* b) { for (int i = 0; i < fp.numChildProcessors(); ++i) { - if (!gen_frag_proc_and_meta_keys(primProc, fp.childProcessor(i), glslCaps, b)) { + if (!gen_frag_proc_and_meta_keys(primProc, fp.childProcessor(i), shaderCaps, b)) { return false; } } - fp.getGLSLProcessorKey(glslCaps, b); + fp.getGLSLProcessorKey(shaderCaps, b); - return gen_meta_key(fp, glslCaps, primProc.getTransformKey(fp.coordTransforms(), - fp.numCoordTransforms()), b); + return gen_meta_key(fp, shaderCaps, primProc.getTransformKey(fp.coordTransforms(), + fp.numCoordTransforms()), b); } bool GrProgramDesc::Build(GrProgramDesc* desc, const GrPrimitiveProcessor& primProc, bool hasPointSize, const GrPipeline& pipeline, - const GrShaderCaps& glslCaps) { + const GrShaderCaps& shaderCaps) { // The descriptor is used as a cache key. Thus when a field of the // descriptor will not affect program generation (because of the attribute // bindings in use or other descriptor field settings) it should be set @@ -163,8 +163,8 @@ bool GrProgramDesc::Build(GrProgramDesc* desc, GrProcessorKeyBuilder b(&desc->key()); - primProc.getGLSLProcessorKey(glslCaps, &b); - if (!gen_meta_key(primProc, glslCaps, 0, &b)) { + primProc.getGLSLProcessorKey(shaderCaps, &b); + if (!gen_meta_key(primProc, shaderCaps, 0, &b)) { desc->key().reset(); return false; } @@ -172,7 +172,7 @@ bool GrProgramDesc::Build(GrProgramDesc* desc, for (int i = 0; i < pipeline.numFragmentProcessors(); ++i) { const GrFragmentProcessor& fp = pipeline.getFragmentProcessor(i); - if (!gen_frag_proc_and_meta_keys(primProc, fp, glslCaps, &b)) { + if (!gen_frag_proc_and_meta_keys(primProc, fp, shaderCaps, &b)) { desc->key().reset(); return false; } @@ -180,8 +180,8 @@ bool GrProgramDesc::Build(GrProgramDesc* desc, } const GrXferProcessor& xp = pipeline.getXferProcessor(); - xp.getGLSLProcessorKey(glslCaps, &b); - if (!gen_meta_key(xp, glslCaps, 0, &b)) { + xp.getGLSLProcessorKey(shaderCaps, &b); + if (!gen_meta_key(xp, shaderCaps, 0, &b)) { desc->key().reset(); return false; } @@ -212,7 +212,7 @@ bool GrProgramDesc::Build(GrProgramDesc* desc, header->fSamplePatternKey = 0; } - header->fOutputSwizzle = glslCaps.configOutputSwizzle(rt->config()).asKey(); + header->fOutputSwizzle = shaderCaps.configOutputSwizzle(rt->config()).asKey(); header->fIgnoresCoverage = pipeline.ignoresCoverage() ? 1 : 0; diff --git a/src/gpu/GrShaderVar.cpp b/src/gpu/GrShaderVar.cpp index da8bc7a934..e938c36d01 100644 --- a/src/gpu/GrShaderVar.cpp +++ b/src/gpu/GrShaderVar.cpp @@ -80,7 +80,7 @@ void GrShaderVar::setIOType(GrIOType ioType) { SkFAIL("Unknown io type."); } -void GrShaderVar::appendDecl(const GrShaderCaps* glslCaps, SkString* out) const { +void GrShaderVar::appendDecl(const GrShaderCaps* shaderCaps, SkString* out) const { SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeAcceptsPrecision(fType)); SkString layout = fLayoutQualifier; if (!fLayoutQualifier.isEmpty()) { @@ -92,7 +92,7 @@ void GrShaderVar::appendDecl(const GrShaderCaps* glslCaps, SkString* out) const out->append(" "); } GrSLType effectiveType = this->getType(); - if (glslCaps->usesPrecisionModifiers() && GrSLTypeAcceptsPrecision(effectiveType)) { + if (shaderCaps->usesPrecisionModifiers() && GrSLTypeAcceptsPrecision(effectiveType)) { // Desktop GLSL has added precision qualifiers but they don't do anything. out->appendf("%s ", GrGLSLPrecisionString(fPrecision)); } diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp index 1465fbb54e..8db60acec8 100644 --- a/src/gpu/effects/GrBezierEffect.cpp +++ b/src/gpu/effects/GrBezierEffect.cpp @@ -110,7 +110,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { // Additionally we should assert that the upstream code only lets us get here if // either high or medium provides the required number of bits. GrSLPrecision precision = kHigh_GrSLPrecision; - const GrShaderCaps::PrecisionInfo& highP = args.fGLSLCaps->getFloatShaderPrecisionInfo( + const GrShaderCaps::PrecisionInfo& highP = args.fShaderCaps->getFloatShaderPrecisionInfo( kFragment_GrShaderType, kHigh_GrSLPrecision); if (!highP.supported()) { diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp index d109ef14a9..8d16f1dd54 100644 --- a/src/gpu/effects/GrBicubicEffect.cpp +++ b/src/gpu/effects/GrBicubicEffect.cpp @@ -102,7 +102,7 @@ void GrGLBicubicEffect::emitCode(EmitArgs& args) { sampleVar.printf("rowColors[%d]", x); fDomain.sampleTexture(fragBuilder, args.fUniformHandler, - args.fGLSLCaps, + args.fShaderCaps, bicubicEffect.domain(), sampleVar.c_str(), coord, diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index becd84aea1..f7003121d7 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -25,7 +25,7 @@ public: // Using highp for GLES here in order to avoid some precision issues on specific GPUs. GrShaderVar tmpVar("tmpColor", kVec4f_GrSLType, 0, kHigh_GrSLPrecision); SkString tmpDecl; - tmpVar.appendDecl(args.fGLSLCaps, &tmpDecl); + tmpVar.appendDecl(args.fShaderCaps, &tmpDecl); GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp index 5e4dc26c97..96f7014284 100644 --- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp +++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp @@ -83,7 +83,7 @@ void GrGLMatrixConvolutionEffect::emitCode(EmitArgs& args) { coord.printf("coord + vec2(%d, %d) * %s", x, y, imgInc); fDomain.sampleTexture(fragBuilder, uniformHandler, - args.fGLSLCaps, + args.fShaderCaps, domain, "c", coord, @@ -102,7 +102,7 @@ void GrGLMatrixConvolutionEffect::emitCode(EmitArgs& args) { } else { fDomain.sampleTexture(fragBuilder, uniformHandler, - args.fGLSLCaps, + args.fShaderCaps, domain, "c", coords2D, diff --git a/src/gpu/effects/GrOvalEffect.cpp b/src/gpu/effects/GrOvalEffect.cpp index 993f269bf9..13cbd25592 100644 --- a/src/gpu/effects/GrOvalEffect.cpp +++ b/src/gpu/effects/GrOvalEffect.cpp @@ -298,7 +298,7 @@ void GLEllipseEffect::emitCode(EmitArgs& args) { // inverse squared radii uniform values are already in this normalized space. The center is // not. const char* scaleName = nullptr; - if (args.fGLSLCaps->floatPrecisionVaries()) { + if (args.fShaderCaps->floatPrecisionVaries()) { fScaleUniform = args.fUniformHandler->addUniform( kFragment_GrShaderFlag, kVec2f_GrSLType, kDefault_GrSLPrecision, "scale", &scaleName); diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp index adf7bfd7ae..4db3957de8 100644 --- a/src/gpu/effects/GrRRectEffect.cpp +++ b/src/gpu/effects/GrRRectEffect.cpp @@ -170,7 +170,7 @@ void GLCircularRRectEffect::emitCode(EmitArgs& args) { // If we're on a device with a "real" mediump then the length calculation could overflow. SkString clampedCircleDistance; - if (args.fGLSLCaps->floatPrecisionVaries()) { + if (args.fShaderCaps->floatPrecisionVaries()) { clampedCircleDistance.printf("clamp(%s.x * (1.0 - length(dxy * %s.y)), 0.0, 1.0);", radiusPlusHalfName, radiusPlusHalfName); } else { @@ -536,7 +536,7 @@ void GLEllipticalRRectEffect::emitCode(EmitArgs& args) { // that is normalized by the largest radius. The scale uniform will be scale, 1/scale. The // radii uniform values are already in this normalized space. const char* scaleName = nullptr; - if (args.fGLSLCaps->floatPrecisionVaries()) { + if (args.fShaderCaps->floatPrecisionVaries()) { fScaleUniform = uniformHandler->addUniform(kFragment_GrShaderFlag, kVec2f_GrSLType, kDefault_GrSLPrecision, "scale", &scaleName); diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp index 78be8fe59c..dd43b15c02 100644 --- a/src/gpu/effects/GrTextureDomain.cpp +++ b/src/gpu/effects/GrTextureDomain.cpp @@ -45,7 +45,7 @@ GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index) void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder, GrGLSLUniformHandler* uniformHandler, - const GrShaderCaps* glslCaps, + const GrShaderCaps* shaderCaps, const GrTextureDomain& textureDomain, const char* outColor, const SkString& inCoords, @@ -90,7 +90,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder, GrGLSLShaderBuilder::ShaderBlock block(builder); const char* domain = fDomainName.c_str(); - if (!glslCaps->canUseAnyFunctionInShader()) { + if (!shaderCaps->canUseAnyFunctionInShader()) { // On the NexusS and GalaxyNexus, the other path (with the 'any' // call) causes the compilation error "Calls to any function that // may require a gradient calculation inside a conditional block @@ -215,7 +215,7 @@ GrGLSLFragmentProcessor* GrTextureDomainEffect::onCreateGLSLInstance() const { SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]); fGLDomain.sampleTexture(fragBuilder, args.fUniformHandler, - args.fGLSLCaps, + args.fShaderCaps, domain, args.fOutputColor, coords2D, @@ -318,7 +318,7 @@ GrGLSLFragmentProcessor* GrDeviceSpaceTextureDecalFragmentProcessor::onCreateGLS scaleAndTranslateName, scaleAndTranslateName); fGLDomain.sampleTexture(args.fFragBuilder, args.fUniformHandler, - args.fGLSLCaps, + args.fShaderCaps, dstdfp.fTextureDomain, args.fOutputColor, SkString("coords"), diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h index 7e7ec74912..644d14c7dd 100644 --- a/src/gpu/effects/GrTextureDomain.h +++ b/src/gpu/effects/GrTextureDomain.h @@ -115,7 +115,7 @@ public: */ void sampleTexture(GrGLSLShaderBuilder* builder, GrGLSLUniformHandler* uniformHandler, - const GrShaderCaps* glslCaps, + const GrShaderCaps* shaderCaps, const GrTextureDomain& textureDomain, const char* outColor, const SkString& inCoords, diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index c47763583c..f961a4b7c0 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -254,98 +254,100 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, // This must be called after fCoreProfile is set on the GrGLCaps this->initGLSL(ctxInfo); - GrShaderCaps* glslCaps = static_cast<GrShaderCaps*>(fShaderCaps.get()); + GrShaderCaps* shaderCaps = fShaderCaps.get(); - glslCaps->fPathRenderingSupport = this->hasPathRenderingSupport(ctxInfo, gli); + shaderCaps->fPathRenderingSupport = this->hasPathRenderingSupport(ctxInfo, gli); // For now these two are equivalent but we could have dst read in shader via some other method. // Before setting this, initGLSL() must have been called. - glslCaps->fDstReadInShaderSupport = glslCaps->fFBFetchSupport; + shaderCaps->fDstReadInShaderSupport = shaderCaps->fFBFetchSupport; // Enable supported shader-related caps if (kGL_GrGLStandard == standard) { - glslCaps->fDualSourceBlendingSupport = (ctxInfo.version() >= GR_GL_VER(3, 3) || + shaderCaps->fDualSourceBlendingSupport = (ctxInfo.version() >= GR_GL_VER(3, 3) || ctxInfo.hasExtension("GL_ARB_blend_func_extended")) && GrGLSLSupportsNamedFragmentShaderOutputs(ctxInfo.glslGeneration()); - glslCaps->fShaderDerivativeSupport = true; + shaderCaps->fShaderDerivativeSupport = true; // we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS - glslCaps->fGeometryShaderSupport = ctxInfo.version() >= GR_GL_VER(3, 2) && + shaderCaps->fGeometryShaderSupport = ctxInfo.version() >= GR_GL_VER(3, 2) && ctxInfo.glslGeneration() >= k150_GrGLSLGeneration; - glslCaps->fIntegerSupport = ctxInfo.version() >= GR_GL_VER(3, 0) && + shaderCaps->fIntegerSupport = ctxInfo.version() >= GR_GL_VER(3, 0) && ctxInfo.glslGeneration() >= k130_GrGLSLGeneration; } else { - glslCaps->fDualSourceBlendingSupport = ctxInfo.hasExtension("GL_EXT_blend_func_extended"); + shaderCaps->fDualSourceBlendingSupport = ctxInfo.hasExtension("GL_EXT_blend_func_extended"); - glslCaps->fShaderDerivativeSupport = ctxInfo.version() >= GR_GL_VER(3, 0) || + shaderCaps->fShaderDerivativeSupport = ctxInfo.version() >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_OES_standard_derivatives"); - glslCaps->fIntegerSupport = ctxInfo.version() >= GR_GL_VER(3, 0) && + shaderCaps->fIntegerSupport = ctxInfo.version() >= GR_GL_VER(3, 0) && ctxInfo.glslGeneration() >= k330_GrGLSLGeneration; // We use this value for GLSL ES 3.0. } if (ctxInfo.hasExtension("GL_EXT_shader_pixel_local_storage")) { #define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT 0x8F63 GR_GL_GetIntegerv(gli, GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT, - &glslCaps->fPixelLocalStorageSize); - glslCaps->fPLSPathRenderingSupport = glslCaps->fFBFetchSupport; + &shaderCaps->fPixelLocalStorageSize); + shaderCaps->fPLSPathRenderingSupport = shaderCaps->fFBFetchSupport; } else { - glslCaps->fPixelLocalStorageSize = 0; - glslCaps->fPLSPathRenderingSupport = false; + shaderCaps->fPixelLocalStorageSize = 0; + shaderCaps->fPLSPathRenderingSupport = false; } // Protect ourselves against tracking huge amounts of texture state. static const uint8_t kMaxSaneSamplers = 32; GrGLint maxSamplers; GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &maxSamplers); - glslCaps->fMaxVertexSamplers = SkTMin<GrGLint>(kMaxSaneSamplers, maxSamplers); - if (glslCaps->fGeometryShaderSupport) { + shaderCaps->fMaxVertexSamplers = SkTMin<GrGLint>(kMaxSaneSamplers, maxSamplers); + if (shaderCaps->fGeometryShaderSupport) { GR_GL_GetIntegerv(gli, GR_GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS, &maxSamplers); - glslCaps->fMaxGeometrySamplers = SkTMin<GrGLint>(kMaxSaneSamplers, maxSamplers); + shaderCaps->fMaxGeometrySamplers = SkTMin<GrGLint>(kMaxSaneSamplers, maxSamplers); } GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &maxSamplers); - glslCaps->fMaxFragmentSamplers = SkTMin<GrGLint>(kMaxSaneSamplers, maxSamplers); + shaderCaps->fMaxFragmentSamplers = SkTMin<GrGLint>(kMaxSaneSamplers, maxSamplers); GR_GL_GetIntegerv(gli, GR_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxSamplers); - glslCaps->fMaxCombinedSamplers = SkTMin<GrGLint>(kMaxSaneSamplers, maxSamplers); + shaderCaps->fMaxCombinedSamplers = SkTMin<GrGLint>(kMaxSaneSamplers, maxSamplers); if (kGL_GrGLStandard == standard) { - glslCaps->fImageLoadStoreSupport = ctxInfo.version() >= GR_GL_VER(4, 2); - if (!glslCaps->fImageLoadStoreSupport && + shaderCaps->fImageLoadStoreSupport = ctxInfo.version() >= GR_GL_VER(4, 2); + if (!shaderCaps->fImageLoadStoreSupport && ctxInfo.hasExtension("GL_ARB_shader_image_load_store")) { - glslCaps->fImageLoadStoreSupport = true; - glslCaps->fImageLoadStoreExtensionString = "GL_ARB_shader_image_load_store"; + shaderCaps->fImageLoadStoreSupport = true; + shaderCaps->fImageLoadStoreExtensionString = "GL_ARB_shader_image_load_store"; } } else { - glslCaps->fImageLoadStoreSupport = ctxInfo.version() >= GR_GL_VER(3, 1); + shaderCaps->fImageLoadStoreSupport = ctxInfo.version() >= GR_GL_VER(3, 1); } - if (glslCaps->fImageLoadStoreSupport) { + if (shaderCaps->fImageLoadStoreSupport) { // Protect ourselves against tracking huge amounts of image state. static constexpr int kMaxSaneImages = 4; GrGLint maxUnits; GR_GL_GetIntegerv(gli, GR_GL_MAX_IMAGE_UNITS, &maxUnits); GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_IMAGE_UNIFORMS, - &glslCaps->fMaxVertexImageStorages); - if (glslCaps->fGeometryShaderSupport) { + &shaderCaps->fMaxVertexImageStorages); + if (shaderCaps->fGeometryShaderSupport) { GR_GL_GetIntegerv(gli, GR_GL_MAX_GEOMETRY_IMAGE_UNIFORMS, - &glslCaps->fMaxGeometryImageStorages); + &shaderCaps->fMaxGeometryImageStorages); } GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_IMAGE_UNIFORMS, - &glslCaps->fMaxFragmentImageStorages); + &shaderCaps->fMaxFragmentImageStorages); GR_GL_GetIntegerv(gli, GR_GL_MAX_COMBINED_IMAGE_UNIFORMS, - &glslCaps->fMaxCombinedImageStorages); + &shaderCaps->fMaxCombinedImageStorages); // We use one unit for every image uniform - glslCaps->fMaxCombinedImageStorages = SkTMin(SkTMin(glslCaps->fMaxCombinedImageStorages, - maxUnits), kMaxSaneImages); - glslCaps->fMaxVertexImageStorages = SkTMin(maxUnits, glslCaps->fMaxVertexImageStorages); - glslCaps->fMaxGeometryImageStorages = SkTMin(maxUnits, glslCaps->fMaxGeometryImageStorages); - glslCaps->fMaxFragmentImageStorages = SkTMin(maxUnits, - glslCaps->fMaxFragmentImageStorages); + shaderCaps->fMaxCombinedImageStorages = SkTMin(SkTMin(shaderCaps->fMaxCombinedImageStorages, + maxUnits), kMaxSaneImages); + shaderCaps->fMaxVertexImageStorages = SkTMin(maxUnits, + shaderCaps->fMaxVertexImageStorages); + shaderCaps->fMaxGeometryImageStorages = SkTMin(maxUnits, + shaderCaps->fMaxGeometryImageStorages); + shaderCaps->fMaxFragmentImageStorages = SkTMin(maxUnits, + shaderCaps->fMaxFragmentImageStorages); // HACK: Currently we only use images in a unit test in the fragment shader. The individual // stage image limits aren't exposed through GrShaderCaps. Soon GrShaderCaps and GrGLSLCaps // will merge and the test can look for fragment support. - if (!glslCaps->fMaxFragmentImageStorages) { - glslCaps->fImageLoadStoreSupport = false; + if (!shaderCaps->fMaxFragmentImageStorages) { + shaderCaps->fImageLoadStoreSupport = false; } } @@ -356,7 +358,7 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, // We need dual source blending and the ability to disable multisample in order to support mixed // samples in every corner case. if (fMultisampleDisableSupport && - glslCaps->dualSourceBlendingSupport() && + shaderCaps->dualSourceBlendingSupport() && fShaderCaps->pathRenderingSupport()) { fUsesMixedSamples = ctxInfo.hasExtension("GL_NV_framebuffer_mixed_samples") || ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_mixed_samples"); @@ -575,7 +577,7 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, fDrawRangeElementsSupport = version >= GR_GL_VER(3,0); } - this->initShaderPrecisionTable(ctxInfo, gli, glslCaps); + this->initShaderPrecisionTable(ctxInfo, gli, shaderCaps); if (contextOptions.fUseShaderSwizzling) { fTextureSwizzleSupport = false; @@ -613,10 +615,10 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, // Requires fTextureRedSupport, fTextureSwizzleSupport, msaa support, ES compatibility have // already been detected. - this->initConfigTable(ctxInfo, gli, glslCaps); + this->initConfigTable(ctxInfo, gli, shaderCaps); this->applyOptionsOverrides(contextOptions); - glslCaps->applyOptionsOverrides(contextOptions); + shaderCaps->applyOptionsOverrides(contextOptions); } const char* get_glsl_version_decl_string(GrGLStandard standard, GrGLSLGeneration generation, @@ -685,109 +687,110 @@ void GrGLCaps::initGLSL(const GrGLContextInfo& ctxInfo) { GrGLVersion version = ctxInfo.version(); /************************************************************************** - * Caps specific to GrGLSLCaps + * Caps specific to GrShaderCaps **************************************************************************/ - GrShaderCaps* glslCaps = fShaderCaps.get(); - glslCaps->fGLSLGeneration = ctxInfo.glslGeneration(); + GrShaderCaps* shaderCaps = fShaderCaps.get(); + shaderCaps->fGLSLGeneration = ctxInfo.glslGeneration(); if (kGLES_GrGLStandard == standard) { if (ctxInfo.hasExtension("GL_EXT_shader_framebuffer_fetch")) { - glslCaps->fFBFetchNeedsCustomOutput = (version >= GR_GL_VER(3, 0)); - glslCaps->fFBFetchSupport = true; - glslCaps->fFBFetchColorName = "gl_LastFragData[0]"; - glslCaps->fFBFetchExtensionString = "GL_EXT_shader_framebuffer_fetch"; + shaderCaps->fFBFetchNeedsCustomOutput = (version >= GR_GL_VER(3, 0)); + shaderCaps->fFBFetchSupport = true; + shaderCaps->fFBFetchColorName = "gl_LastFragData[0]"; + shaderCaps->fFBFetchExtensionString = "GL_EXT_shader_framebuffer_fetch"; } else if (ctxInfo.hasExtension("GL_NV_shader_framebuffer_fetch")) { // Actually, we haven't seen an ES3.0 device with this extension yet, so we don't know - glslCaps->fFBFetchNeedsCustomOutput = false; - glslCaps->fFBFetchSupport = true; - glslCaps->fFBFetchColorName = "gl_LastFragData[0]"; - glslCaps->fFBFetchExtensionString = "GL_NV_shader_framebuffer_fetch"; + shaderCaps->fFBFetchNeedsCustomOutput = false; + shaderCaps->fFBFetchSupport = true; + shaderCaps->fFBFetchColorName = "gl_LastFragData[0]"; + shaderCaps->fFBFetchExtensionString = "GL_NV_shader_framebuffer_fetch"; } else if (ctxInfo.hasExtension("GL_ARM_shader_framebuffer_fetch")) { // The arm extension also requires an additional flag which we will set onResetContext - glslCaps->fFBFetchNeedsCustomOutput = false; - glslCaps->fFBFetchSupport = true; - glslCaps->fFBFetchColorName = "gl_LastFragColorARM"; - glslCaps->fFBFetchExtensionString = "GL_ARM_shader_framebuffer_fetch"; + shaderCaps->fFBFetchNeedsCustomOutput = false; + shaderCaps->fFBFetchSupport = true; + shaderCaps->fFBFetchColorName = "gl_LastFragColorARM"; + shaderCaps->fFBFetchExtensionString = "GL_ARM_shader_framebuffer_fetch"; } - glslCaps->fUsesPrecisionModifiers = true; + shaderCaps->fUsesPrecisionModifiers = true; } // Currently the extension is advertised but fb fetch is broken on 500 series Adrenos like the // Galaxy S7. // TODO: Once this is fixed we can update the check here to look at a driver version number too. if (kAdreno5xx_GrGLRenderer == ctxInfo.renderer()) { - glslCaps->fFBFetchSupport = false; + shaderCaps->fFBFetchSupport = false; } - glslCaps->fBindlessTextureSupport = ctxInfo.hasExtension("GL_NV_bindless_texture"); + shaderCaps->fBindlessTextureSupport = ctxInfo.hasExtension("GL_NV_bindless_texture"); if (kGL_GrGLStandard == standard) { - glslCaps->fFlatInterpolationSupport = ctxInfo.glslGeneration() >= k130_GrGLSLGeneration; + shaderCaps->fFlatInterpolationSupport = ctxInfo.glslGeneration() >= k130_GrGLSLGeneration; } else { - glslCaps->fFlatInterpolationSupport = + shaderCaps->fFlatInterpolationSupport = ctxInfo.glslGeneration() >= k330_GrGLSLGeneration; // This is the value for GLSL ES 3.0. } if (kGL_GrGLStandard == standard) { - glslCaps->fNoPerspectiveInterpolationSupport = + shaderCaps->fNoPerspectiveInterpolationSupport = ctxInfo.glslGeneration() >= k130_GrGLSLGeneration; } else { if (ctxInfo.hasExtension("GL_NV_shader_noperspective_interpolation")) { - glslCaps->fNoPerspectiveInterpolationSupport = true; - glslCaps->fNoPerspectiveInterpolationExtensionString = + shaderCaps->fNoPerspectiveInterpolationSupport = true; + shaderCaps->fNoPerspectiveInterpolationExtensionString = "GL_NV_shader_noperspective_interpolation"; } } if (kGL_GrGLStandard == standard) { - glslCaps->fMultisampleInterpolationSupport = + shaderCaps->fMultisampleInterpolationSupport = ctxInfo.glslGeneration() >= k400_GrGLSLGeneration; } else { if (ctxInfo.glslGeneration() >= k320es_GrGLSLGeneration) { - glslCaps->fMultisampleInterpolationSupport = true; + shaderCaps->fMultisampleInterpolationSupport = true; } else if (ctxInfo.hasExtension("GL_OES_shader_multisample_interpolation")) { - glslCaps->fMultisampleInterpolationSupport = true; - glslCaps->fMultisampleInterpolationExtensionString = + shaderCaps->fMultisampleInterpolationSupport = true; + shaderCaps->fMultisampleInterpolationExtensionString = "GL_OES_shader_multisample_interpolation"; } } if (kGL_GrGLStandard == standard) { - glslCaps->fSampleVariablesSupport = ctxInfo.glslGeneration() >= k400_GrGLSLGeneration; + shaderCaps->fSampleVariablesSupport = ctxInfo.glslGeneration() >= k400_GrGLSLGeneration; } else { if (ctxInfo.glslGeneration() >= k320es_GrGLSLGeneration) { - glslCaps->fSampleVariablesSupport = true; + shaderCaps->fSampleVariablesSupport = true; } else if (ctxInfo.hasExtension("GL_OES_sample_variables")) { - glslCaps->fSampleVariablesSupport = true; - glslCaps->fSampleVariablesExtensionString = "GL_OES_sample_variables"; + shaderCaps->fSampleVariablesSupport = true; + shaderCaps->fSampleVariablesExtensionString = "GL_OES_sample_variables"; } } - if (glslCaps->fSampleVariablesSupport && + if (shaderCaps->fSampleVariablesSupport && ctxInfo.hasExtension("GL_NV_sample_mask_override_coverage")) { // Pre-361 NVIDIA has a bug with NV_sample_mask_override_coverage. - glslCaps->fSampleMaskOverrideCoverageSupport = + shaderCaps->fSampleMaskOverrideCoverageSupport = kNVIDIA_GrGLDriver != ctxInfo.driver() || ctxInfo.driverVersion() >= GR_GL_DRIVER_VER(361,00); } // Adreno GPUs have a tendency to drop tiles when there is a divide-by-zero in a shader - glslCaps->fDropsTileOnZeroDivide = kQualcomm_GrGLVendor == ctxInfo.vendor(); + shaderCaps->fDropsTileOnZeroDivide = kQualcomm_GrGLVendor == ctxInfo.vendor(); // 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. This issue comes into play // from our GrTextureDomain processor. - glslCaps->fCanUseAnyFunctionInShader = kImagination_GrGLVendor != ctxInfo.vendor(); + shaderCaps->fCanUseAnyFunctionInShader = kImagination_GrGLVendor != ctxInfo.vendor(); - glslCaps->fVersionDeclString = get_glsl_version_decl_string(standard, glslCaps->fGLSLGeneration, - fIsCoreProfile); + shaderCaps->fVersionDeclString = get_glsl_version_decl_string(standard, + shaderCaps->fGLSLGeneration, + fIsCoreProfile); - if (kGLES_GrGLStandard == standard && k110_GrGLSLGeneration == glslCaps->fGLSLGeneration) { - glslCaps->fShaderDerivativeExtensionString = "GL_OES_standard_derivatives"; + if (kGLES_GrGLStandard == standard && k110_GrGLSLGeneration == shaderCaps->fGLSLGeneration) { + shaderCaps->fShaderDerivativeExtensionString = "GL_OES_standard_derivatives"; } // Frag Coords Convention support is not part of ES @@ -797,52 +800,52 @@ void GrGLCaps::initGLSL(const GrGLContextInfo& ctxInfo) { kGLES_GrGLStandard != standard && (ctxInfo.glslGeneration() >= k150_GrGLSLGeneration || ctxInfo.hasExtension("GL_ARB_fragment_coord_conventions"))) { - glslCaps->fFragCoordConventionsExtensionString = "GL_ARB_fragment_coord_conventions"; + shaderCaps->fFragCoordConventionsExtensionString = "GL_ARB_fragment_coord_conventions"; } if (kGLES_GrGLStandard == standard) { - glslCaps->fSecondaryOutputExtensionString = "GL_EXT_blend_func_extended"; + shaderCaps->fSecondaryOutputExtensionString = "GL_EXT_blend_func_extended"; } if (ctxInfo.hasExtension("GL_OES_EGL_image_external")) { if (ctxInfo.glslGeneration() == k110_GrGLSLGeneration) { - glslCaps->fExternalTextureSupport = true; + shaderCaps->fExternalTextureSupport = true; } else if (ctxInfo.hasExtension("GL_OES_EGL_image_external_essl3") || ctxInfo.hasExtension("OES_EGL_image_external_essl3")) { // At least one driver has been found that has this extension without the "GL_" prefix. - glslCaps->fExternalTextureSupport = true; + shaderCaps->fExternalTextureSupport = true; } } - if (glslCaps->fExternalTextureSupport) { + if (shaderCaps->fExternalTextureSupport) { if (ctxInfo.glslGeneration() == k110_GrGLSLGeneration) { - glslCaps->fExternalTextureExtensionString = "GL_OES_EGL_image_external"; + shaderCaps->fExternalTextureExtensionString = "GL_OES_EGL_image_external"; } else { - glslCaps->fExternalTextureExtensionString = "GL_OES_EGL_image_external_essl3"; + shaderCaps->fExternalTextureExtensionString = "GL_OES_EGL_image_external_essl3"; } } if (kGL_GrGLStandard == standard) { - glslCaps->fTexelFetchSupport = ctxInfo.glslGeneration() >= k130_GrGLSLGeneration; + shaderCaps->fTexelFetchSupport = ctxInfo.glslGeneration() >= k130_GrGLSLGeneration; } else { - glslCaps->fTexelFetchSupport = + shaderCaps->fTexelFetchSupport = ctxInfo.glslGeneration() >= k330_GrGLSLGeneration; // We use this value for GLSL ES 3.0. } - if (glslCaps->fTexelFetchSupport) { + if (shaderCaps->fTexelFetchSupport) { if (kGL_GrGLStandard == standard) { - glslCaps->fTexelBufferSupport = ctxInfo.version() >= GR_GL_VER(3, 1) && + shaderCaps->fTexelBufferSupport = ctxInfo.version() >= GR_GL_VER(3, 1) && ctxInfo.glslGeneration() >= k330_GrGLSLGeneration; } else { if (ctxInfo.version() >= GR_GL_VER(3, 2) && ctxInfo.glslGeneration() >= k320es_GrGLSLGeneration) { - glslCaps->fTexelBufferSupport = true; + shaderCaps->fTexelBufferSupport = true; } else if (ctxInfo.hasExtension("GL_OES_texture_buffer")) { - glslCaps->fTexelBufferSupport = true; - glslCaps->fTexelBufferExtensionString = "GL_OES_texture_buffer"; + shaderCaps->fTexelBufferSupport = true; + shaderCaps->fTexelBufferExtensionString = "GL_OES_texture_buffer"; } else if (ctxInfo.hasExtension("GL_EXT_texture_buffer")) { - glslCaps->fTexelBufferSupport = true; - glslCaps->fTexelBufferExtensionString = "GL_EXT_texture_buffer"; + shaderCaps->fTexelBufferSupport = true; + shaderCaps->fTexelBufferExtensionString = "GL_EXT_texture_buffer"; } } } @@ -850,20 +853,20 @@ void GrGLCaps::initGLSL(const GrGLContextInfo& ctxInfo) { // 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. if (kTegra3_GrGLRenderer == ctxInfo.renderer()) { - glslCaps->fCanUseMinAndAbsTogether = false; + shaderCaps->fCanUseMinAndAbsTogether = false; } // On Intel GPU there is an issue where it reads the second argument to atan "- %s.x" as an int // thus must us -1.0 * %s.x to work correctly if (kIntel_GrGLVendor == ctxInfo.vendor()) { - glslCaps->fMustForceNegatedAtanParamToFloat = true; + shaderCaps->fMustForceNegatedAtanParamToFloat = true; } // On Adreno devices with framebuffer fetch support, there is a bug where they always return // the original dst color when reading the outColor even after being written to. By using a // local outColor we can work around this bug. - if (glslCaps->fFBFetchSupport && kQualcomm_GrGLVendor == ctxInfo.vendor()) { - glslCaps->fRequiresLocalOutputColorForFBFetch = true; + if (shaderCaps->fFBFetchSupport && kQualcomm_GrGLVendor == ctxInfo.vendor()) { + shaderCaps->fRequiresLocalOutputColorForFBFetch = true; } } @@ -1030,7 +1033,7 @@ void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterfa } void GrGLCaps::initBlendEqationSupport(const GrGLContextInfo& ctxInfo) { - GrShaderCaps* glslCaps = static_cast<GrShaderCaps*>(fShaderCaps.get()); + GrShaderCaps* shaderCaps = static_cast<GrShaderCaps*>(fShaderCaps.get()); // Disabling advanced blend on various platforms with major known issues. We also block Chrome // for now until its own blacklists can be updated. @@ -1043,20 +1046,20 @@ void GrGLCaps::initBlendEqationSupport(const GrGLContextInfo& ctxInfo) { if (ctxInfo.hasExtension("GL_NV_blend_equation_advanced_coherent")) { fBlendEquationSupport = kAdvancedCoherent_BlendEquationSupport; - glslCaps->fAdvBlendEqInteraction = GrShaderCaps::kAutomatic_AdvBlendEqInteraction; + shaderCaps->fAdvBlendEqInteraction = GrShaderCaps::kAutomatic_AdvBlendEqInteraction; } else if (ctxInfo.hasExtension("GL_KHR_blend_equation_advanced_coherent")) { fBlendEquationSupport = kAdvancedCoherent_BlendEquationSupport; - glslCaps->fAdvBlendEqInteraction = GrShaderCaps::kGeneralEnable_AdvBlendEqInteraction; + shaderCaps->fAdvBlendEqInteraction = GrShaderCaps::kGeneralEnable_AdvBlendEqInteraction; } else if (kNVIDIA_GrGLDriver == ctxInfo.driver() && ctxInfo.driverVersion() < GR_GL_DRIVER_VER(337,00)) { // Non-coherent advanced blend has an issue on NVIDIA pre 337.00. return; } else if (ctxInfo.hasExtension("GL_NV_blend_equation_advanced")) { fBlendEquationSupport = kAdvanced_BlendEquationSupport; - glslCaps->fAdvBlendEqInteraction = GrShaderCaps::kAutomatic_AdvBlendEqInteraction; + shaderCaps->fAdvBlendEqInteraction = GrShaderCaps::kAutomatic_AdvBlendEqInteraction; } else if (ctxInfo.hasExtension("GL_KHR_blend_equation_advanced")) { fBlendEquationSupport = kAdvanced_BlendEquationSupport; - glslCaps->fAdvBlendEqInteraction = GrShaderCaps::kGeneralEnable_AdvBlendEqInteraction; + shaderCaps->fAdvBlendEqInteraction = GrShaderCaps::kGeneralEnable_AdvBlendEqInteraction; // TODO: Use kSpecificEnables_AdvBlendEqInteraction if "blend_support_all_equations" is // slow on a particular platform. } else { @@ -1260,7 +1263,7 @@ static GrGLenum shader_type_to_gl_shader(GrShaderType type) { void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* intf, - GrShaderCaps* glslCaps) { + GrShaderCaps* shaderCaps) { if (kGLES_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER(4, 1) || ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) { for (int s = 0; s < kGrShaderTypeCount; ++s) { @@ -1268,7 +1271,7 @@ void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, GrShaderType shaderType = static_cast<GrShaderType>(s); GrGLenum glShader = shader_type_to_gl_shader(shaderType); GrShaderCaps::PrecisionInfo* first = nullptr; - glslCaps->fShaderPrecisionVaries = false; + shaderCaps->fShaderPrecisionVaries = false; for (int p = 0; p < kGrSLPrecisionCount; ++p) { GrSLPrecision precision = static_cast<GrSLPrecision>(p); GrGLenum glPrecision = precision_to_gl_float_type(precision); @@ -1276,15 +1279,15 @@ void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, GrGLint bits; GR_GL_GetShaderPrecisionFormat(intf, glShader, glPrecision, range, &bits); if (bits) { - glslCaps->fFloatPrecisions[s][p].fLogRangeLow = range[0]; - glslCaps->fFloatPrecisions[s][p].fLogRangeHigh = range[1]; - glslCaps->fFloatPrecisions[s][p].fBits = bits; + shaderCaps->fFloatPrecisions[s][p].fLogRangeLow = range[0]; + shaderCaps->fFloatPrecisions[s][p].fLogRangeHigh = range[1]; + shaderCaps->fFloatPrecisions[s][p].fBits = bits; if (!first) { - first = &glslCaps->fFloatPrecisions[s][p]; + first = &shaderCaps->fFloatPrecisions[s][p]; } - else if (!glslCaps->fShaderPrecisionVaries) { - glslCaps->fShaderPrecisionVaries = - (*first != glslCaps->fFloatPrecisions[s][p]); + else if (!shaderCaps->fShaderPrecisionVaries) { + shaderCaps->fShaderPrecisionVaries = + (*first != shaderCaps->fFloatPrecisions[s][p]); } } } @@ -1293,13 +1296,13 @@ void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, } else { // We're on a desktop GL that doesn't have precision info. Assume they're all 32bit float. - glslCaps->fShaderPrecisionVaries = false; + shaderCaps->fShaderPrecisionVaries = false; for (int s = 0; s < kGrShaderTypeCount; ++s) { if (kGeometry_GrShaderType != s) { for (int p = 0; p < kGrSLPrecisionCount; ++p) { - glslCaps->fFloatPrecisions[s][p].fLogRangeLow = 127; - glslCaps->fFloatPrecisions[s][p].fLogRangeHigh = 127; - glslCaps->fFloatPrecisions[s][p].fBits = 23; + shaderCaps->fFloatPrecisions[s][p].fLogRangeLow = 127; + shaderCaps->fFloatPrecisions[s][p].fLogRangeHigh = 127; + shaderCaps->fFloatPrecisions[s][p].fBits = 23; } } } @@ -1308,13 +1311,13 @@ void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, // the same as the vertex shader. Only fragment shaders were ever allowed to omit support for // highp. GS was added after GetShaderPrecisionFormat was added to the list of features that // are recommended against. - if (glslCaps->fGeometryShaderSupport) { + if (shaderCaps->fGeometryShaderSupport) { for (int p = 0; p < kGrSLPrecisionCount; ++p) { - glslCaps->fFloatPrecisions[kGeometry_GrShaderType][p] = - glslCaps->fFloatPrecisions[kVertex_GrShaderType][p]; + shaderCaps->fFloatPrecisions[kGeometry_GrShaderType][p] = + shaderCaps->fFloatPrecisions[kVertex_GrShaderType][p]; } } - glslCaps->initSamplerPrecisionTable(); + shaderCaps->initSamplerPrecisionTable(); } bool GrGLCaps::bgraIsInternalFormat() const { @@ -1393,7 +1396,7 @@ bool GrGLCaps::getExternalFormat(GrPixelConfig surfaceConfig, GrPixelConfig memo } void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli, - GrShaderCaps* glslCaps) { + GrShaderCaps* shaderCaps) { /* Comments on renderability of configs on various GL versions. OpenGL < 3.0: @@ -2019,7 +2022,7 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa // swizzle into shader code. if (!this->textureSwizzleSupport()) { for (int i = 0; i < kGrPixelConfigCnt; ++i) { - glslCaps->fConfigTextureSwizzle[i] = fConfigTable[i].fSwizzle; + shaderCaps->fConfigTextureSwizzle[i] = fConfigTable[i].fSwizzle; } } @@ -2031,7 +2034,7 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa GrPixelConfig config = static_cast<GrPixelConfig>(i); if (GrPixelConfigIsAlphaOnly(config) && fConfigTable[i].fFormats.fBaseInternalFormat == GR_GL_RED) { - glslCaps->fConfigOutputSwizzle[i] = GrSwizzle::AAAA(); + shaderCaps->fConfigOutputSwizzle[i] = GrSwizzle::AAAA(); } } } diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index 155388dd61..5c7e028745 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -356,8 +356,6 @@ public: return fRGBAToBGRAReadbackConversionsAreSlow; } - const GrShaderCaps* glslCaps() const { return fShaderCaps.get(); } - private: enum ExternalFormatUsage { kTexImage_ExternalFormatUsage, @@ -380,11 +378,9 @@ private: void initBlendEqationSupport(const GrGLContextInfo&); void initStencilFormats(const GrGLContextInfo&); // This must be called after initFSAASupport(). - void initConfigTable(const GrGLContextInfo&, const GrGLInterface* gli, GrShaderCaps* glslCaps); + void initConfigTable(const GrGLContextInfo&, const GrGLInterface*, GrShaderCaps*); - void initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, - const GrGLInterface* intf, - GrShaderCaps* glslCaps); + void initShaderPrecisionTable(const GrGLContextInfo&, const GrGLInterface*, GrShaderCaps*); GrGLStandard fStandard; diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 7ec2029f99..81fb835356 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -217,8 +217,8 @@ GrGLGpu::GrGLGpu(GrGLContext* ctx, GrContext* context) SkASSERT(ctx); fCaps.reset(SkRef(ctx->caps())); - fHWBoundTextureUniqueIDs.reset(this->glCaps().glslCaps()->maxCombinedSamplers()); - fHWBoundImageStorages.reset(this->glCaps().glslCaps()->maxCombinedImageStorages()); + fHWBoundTextureUniqueIDs.reset(this->caps()->shaderCaps()->maxCombinedSamplers()); + fHWBoundImageStorages.reset(this->caps()->shaderCaps()->maxCombinedImageStorages()); fHWBufferState[kVertex_GrBufferType].fGLTarget = GR_GL_ARRAY_BUFFER; fHWBufferState[kIndex_GrBufferType].fGLTarget = GR_GL_ELEMENT_ARRAY_BUFFER; @@ -236,7 +236,7 @@ GrGLGpu::GrGLGpu(GrGLContext* ctx, GrContext* context) GR_STATIC_ASSERT(6 == SK_ARRAY_COUNT(fHWBufferState)); if (this->caps()->shaderCaps()->texelBufferSupport()) { - fHWBufferTextures.reset(this->glCaps().glslCaps()->maxCombinedSamplers()); + fHWBufferTextures.reset(this->caps()->shaderCaps()->maxCombinedSamplers()); } if (this->glCaps().shaderCaps()->pathRenderingSupport()) { @@ -333,8 +333,8 @@ bool GrGLGpu::createPLSSetupProgram() { return false; } - const GrShaderCaps* glslCaps = this->glCaps().glslCaps(); - const char* version = glslCaps->versionDeclString(); + const GrShaderCaps* shaderCaps = this->caps()->shaderCaps(); + const char* version = shaderCaps->versionDeclString(); GrShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier); GrShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType, @@ -345,19 +345,19 @@ bool GrGLGpu::createPLSSetupProgram() { GrShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier); SkString vshaderTxt(version); - if (glslCaps->noperspectiveInterpolationSupport()) { - if (const char* extension = glslCaps->noperspectiveInterpolationExtensionString()) { + if (shaderCaps->noperspectiveInterpolationSupport()) { + if (const char* extension = shaderCaps->noperspectiveInterpolationExtensionString()) { vshaderTxt.appendf("#extension %s : require\n", extension); } vTexCoord.addModifier("noperspective"); } - aVertex.appendDecl(glslCaps, &vshaderTxt); + aVertex.appendDecl(shaderCaps, &vshaderTxt); vshaderTxt.append(";"); - uTexCoordXform.appendDecl(glslCaps, &vshaderTxt); + uTexCoordXform.appendDecl(shaderCaps, &vshaderTxt); vshaderTxt.append(";"); - uPosXform.appendDecl(glslCaps, &vshaderTxt); + uPosXform.appendDecl(shaderCaps, &vshaderTxt); vshaderTxt.append(";"); - vTexCoord.appendDecl(glslCaps, &vshaderTxt); + vTexCoord.appendDecl(shaderCaps, &vshaderTxt); vshaderTxt.append(";"); vshaderTxt.append( @@ -369,20 +369,20 @@ bool GrGLGpu::createPLSSetupProgram() { ); SkString fshaderTxt(version); - if (glslCaps->noperspectiveInterpolationSupport()) { - if (const char* extension = glslCaps->noperspectiveInterpolationExtensionString()) { + if (shaderCaps->noperspectiveInterpolationSupport()) { + if (const char* extension = shaderCaps->noperspectiveInterpolationExtensionString()) { fshaderTxt.appendf("#extension %s : require\n", extension); } } fshaderTxt.append("#extension "); - fshaderTxt.append(glslCaps->fbFetchExtensionString()); + fshaderTxt.append(shaderCaps->fbFetchExtensionString()); fshaderTxt.append(" : require\n"); fshaderTxt.append("#extension GL_EXT_shader_pixel_local_storage : require\n"); - GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCaps, &fshaderTxt); + GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *shaderCaps, &fshaderTxt); vTexCoord.setTypeModifier(GrShaderVar::kIn_TypeModifier); - vTexCoord.appendDecl(glslCaps, &fshaderTxt); + vTexCoord.appendDecl(shaderCaps, &fshaderTxt); fshaderTxt.append(";"); - uTexture.appendDecl(glslCaps, &fshaderTxt); + uTexture.appendDecl(shaderCaps, &fshaderTxt); fshaderTxt.append(";"); fshaderTxt.appendf( @@ -648,7 +648,7 @@ sk_sp<GrTexture> GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc, // This combination is not supported. return nullptr; } - if (!this->glCaps().glslCaps()->externalTextureSupport()) { + if (!this->caps()->shaderCaps()->externalTextureSupport()) { return nullptr; } } else if (GR_GL_TEXTURE_RECTANGLE == idDesc.fInfo.fTarget) { @@ -2056,7 +2056,7 @@ bool GrGLGpu::flushGLState(const GrPipeline& pipeline, const GrPrimitiveProcesso if (blendInfo.fWriteColor) { // Swizzle the blend to match what the shader will output. - const GrSwizzle& swizzle = this->glCaps().glslCaps()->configOutputSwizzle( + const GrSwizzle& swizzle = this->caps()->shaderCaps()->configOutputSwizzle( pipeline.getRenderTarget()->config()); this->flushBlend(blendInfo, swizzle); } @@ -2843,7 +2843,7 @@ void GrGLGpu::draw(const GrPipeline& pipeline, } void GrGLGpu::stampPLSSetupRect(const SkRect& bounds) { - SkASSERT(this->glCaps().glslCaps()->plsPathRenderingSupport()); + SkASSERT(this->caps()->shaderCaps()->plsPathRenderingSupport()); if (!fPLSSetupProgram.fProgram) { if (!this->createPLSSetupProgram()) { @@ -3728,8 +3728,8 @@ bool GrGLGpu::onCopySurface(GrSurface* dst, const SkIPoint& dstPoint) { // None of our copy methods can handle a swizzle. TODO: Make copySurfaceAsDraw handle the // swizzle. - if (this->glCaps().glslCaps()->configOutputSwizzle(src->config()) != - this->glCaps().glslCaps()->configOutputSwizzle(dst->config())) { + if (this->caps()->shaderCaps()->configOutputSwizzle(src->config()) != + this->caps()->shaderCaps()->configOutputSwizzle(dst->config())) { return false; } // Don't prefer copying as a draw if the dst doesn't already have a FBO object. @@ -3760,7 +3760,7 @@ bool GrGLGpu::onCopySurface(GrSurface* dst, bool GrGLGpu::createCopyProgram(GrTexture* srcTex) { int progIdx = TextureToCopyProgramIdx(srcTex); - const GrShaderCaps* glslCaps = this->glCaps().glslCaps(); + const GrShaderCaps* shaderCaps = this->caps()->shaderCaps(); GrSLType samplerType = srcTex->texturePriv().samplerType(); if (!fCopyProgramArrayBuffer) { @@ -3783,7 +3783,7 @@ bool GrGLGpu::createCopyProgram(GrTexture* srcTex) { return false; } - const char* version = glslCaps->versionDeclString(); + const char* version = shaderCaps->versionDeclString(); GrShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier); GrShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier); @@ -3793,20 +3793,20 @@ bool GrGLGpu::createCopyProgram(GrTexture* srcTex) { GrShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier); SkString vshaderTxt(version); - if (glslCaps->noperspectiveInterpolationSupport()) { - if (const char* extension = glslCaps->noperspectiveInterpolationExtensionString()) { + if (shaderCaps->noperspectiveInterpolationSupport()) { + if (const char* extension = shaderCaps->noperspectiveInterpolationExtensionString()) { vshaderTxt.appendf("#extension %s : require\n", extension); } vTexCoord.addModifier("noperspective"); } - aVertex.appendDecl(glslCaps, &vshaderTxt); + aVertex.appendDecl(shaderCaps, &vshaderTxt); vshaderTxt.append(";"); - uTexCoordXform.appendDecl(glslCaps, &vshaderTxt); + uTexCoordXform.appendDecl(shaderCaps, &vshaderTxt); vshaderTxt.append(";"); - uPosXform.appendDecl(glslCaps, &vshaderTxt); + uPosXform.appendDecl(shaderCaps, &vshaderTxt); vshaderTxt.append(";"); - vTexCoord.appendDecl(glslCaps, &vshaderTxt); + vTexCoord.appendDecl(shaderCaps, &vshaderTxt); vshaderTxt.append(";"); vshaderTxt.append( @@ -3819,21 +3819,21 @@ bool GrGLGpu::createCopyProgram(GrTexture* srcTex) { ); SkString fshaderTxt(version); - if (glslCaps->noperspectiveInterpolationSupport()) { - if (const char* extension = glslCaps->noperspectiveInterpolationExtensionString()) { + if (shaderCaps->noperspectiveInterpolationSupport()) { + if (const char* extension = shaderCaps->noperspectiveInterpolationExtensionString()) { fshaderTxt.appendf("#extension %s : require\n", extension); } } if (samplerType == kTextureExternalSampler_GrSLType) { fshaderTxt.appendf("#extension %s : require\n", - glslCaps->externalTextureExtensionString()); + shaderCaps->externalTextureExtensionString()); } - GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCaps, + GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *shaderCaps, &fshaderTxt); vTexCoord.setTypeModifier(GrShaderVar::kIn_TypeModifier); - vTexCoord.appendDecl(glslCaps, &fshaderTxt); + vTexCoord.appendDecl(shaderCaps, &fshaderTxt); fshaderTxt.append(";"); - uTexture.appendDecl(glslCaps, &fshaderTxt); + uTexture.appendDecl(shaderCaps, &fshaderTxt); fshaderTxt.append(";"); fshaderTxt.appendf( "// Copy Program FS\n" @@ -3879,7 +3879,7 @@ bool GrGLGpu::createMipmapProgram(int progIdx) { const bool oddHeight = SkToBool(progIdx & 0x1); const int numTaps = (oddWidth ? 2 : 1) * (oddHeight ? 2 : 1); - const GrShaderCaps* glslCaps = this->glCaps().glslCaps(); + const GrShaderCaps* shaderCaps = this->caps()->shaderCaps(); SkASSERT(!fMipmapPrograms[progIdx].fProgram); GL_CALL_RET(fMipmapPrograms[progIdx].fProgram, CreateProgram()); @@ -3887,7 +3887,7 @@ bool GrGLGpu::createMipmapProgram(int progIdx) { return false; } - const char* version = glslCaps->versionDeclString(); + const char* version = shaderCaps->versionDeclString(); GrShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier); GrShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier); @@ -3903,8 +3903,8 @@ bool GrGLGpu::createMipmapProgram(int progIdx) { GrShaderVar oFragColor("o_FragColor", kVec4f_GrSLType,GrShaderVar::kOut_TypeModifier); SkString vshaderTxt(version); - if (glslCaps->noperspectiveInterpolationSupport()) { - if (const char* extension = glslCaps->noperspectiveInterpolationExtensionString()) { + if (shaderCaps->noperspectiveInterpolationSupport()) { + if (const char* extension = shaderCaps->noperspectiveInterpolationExtensionString()) { vshaderTxt.appendf("#extension %s : require\n", extension); } vTexCoords[0].addModifier("noperspective"); @@ -3913,12 +3913,12 @@ bool GrGLGpu::createMipmapProgram(int progIdx) { vTexCoords[3].addModifier("noperspective"); } - aVertex.appendDecl(glslCaps, &vshaderTxt); + aVertex.appendDecl(shaderCaps, &vshaderTxt); vshaderTxt.append(";"); - uTexCoordXform.appendDecl(glslCaps, &vshaderTxt); + uTexCoordXform.appendDecl(shaderCaps, &vshaderTxt); vshaderTxt.append(";"); for (int i = 0; i < numTaps; ++i) { - vTexCoords[i].appendDecl(glslCaps, &vshaderTxt); + vTexCoords[i].appendDecl(shaderCaps, &vshaderTxt); vshaderTxt.append(";"); } @@ -3956,19 +3956,19 @@ bool GrGLGpu::createMipmapProgram(int progIdx) { vshaderTxt.append("}"); SkString fshaderTxt(version); - if (glslCaps->noperspectiveInterpolationSupport()) { - if (const char* extension = glslCaps->noperspectiveInterpolationExtensionString()) { + if (shaderCaps->noperspectiveInterpolationSupport()) { + if (const char* extension = shaderCaps->noperspectiveInterpolationExtensionString()) { fshaderTxt.appendf("#extension %s : require\n", extension); } } - GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCaps, + GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *shaderCaps, &fshaderTxt); for (int i = 0; i < numTaps; ++i) { vTexCoords[i].setTypeModifier(GrShaderVar::kIn_TypeModifier); - vTexCoords[i].appendDecl(glslCaps, &fshaderTxt); + vTexCoords[i].appendDecl(shaderCaps, &fshaderTxt); fshaderTxt.append(";"); } - uTexture.appendDecl(glslCaps, &fshaderTxt); + uTexture.appendDecl(shaderCaps, &fshaderTxt); fshaderTxt.append(";"); fshaderTxt.append( "// Mipmap Program FS\n" @@ -4049,15 +4049,15 @@ bool GrGLGpu::createWireRectProgram() { GrShaderVar uColor("u_color", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier); GrShaderVar uRect("u_rect", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier); GrShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier); - const char* version = this->glCaps().glslCaps()->versionDeclString(); + const char* version = this->caps()->shaderCaps()->versionDeclString(); // The rect uniform specifies the rectangle in NDC space as a vec4 (left,top,right,bottom). The // program is used with a vbo containing the unit square. Vertices are computed from the rect // uniform using the 4 vbo vertices. SkString vshaderTxt(version); - aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); + aVertex.appendDecl(this->caps()->shaderCaps(), &vshaderTxt); vshaderTxt.append(";"); - uRect.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); + uRect.appendDecl(this->caps()->shaderCaps(), &vshaderTxt); vshaderTxt.append(";"); vshaderTxt.append( "// Wire Rect Program VS\n" @@ -4072,9 +4072,9 @@ bool GrGLGpu::createWireRectProgram() { SkString fshaderTxt(version); GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, - *this->glCaps().glslCaps(), + *this->caps()->shaderCaps(), &fshaderTxt); - uColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); + uColor.appendDecl(this->caps()->shaderCaps(), &fshaderTxt); fshaderTxt.append(";"); fshaderTxt.appendf( "// Write Rect Program FS\n" diff --git a/src/gpu/gl/GrGLGpuProgramCache.cpp b/src/gpu/gl/GrGLGpuProgramCache.cpp index 9bca80c1ec..bf6a5980fb 100644 --- a/src/gpu/gl/GrGLGpuProgramCache.cpp +++ b/src/gpu/gl/GrGLGpuProgramCache.cpp @@ -114,7 +114,7 @@ GrGLProgram* GrGLGpu::ProgramCache::refProgram(const GrGLGpu* gpu, // Get GrGLProgramDesc GrProgramDesc desc; - if (!GrProgramDesc::Build(&desc, primProc, isPoints, pipeline, *gpu->glCaps().glslCaps())) { + if (!GrProgramDesc::Build(&desc, primProc, isPoints, pipeline, *gpu->caps()->shaderCaps())) { GrCapsDebugf(gpu->caps(), "Failed to gl program descriptor!\n"); return nullptr; } diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp index 196ec86628..edce7b1f33 100644 --- a/src/gpu/gl/GrGLTexture.cpp +++ b/src/gpu/gl/GrGLTexture.cpp @@ -16,7 +16,7 @@ static inline GrSLType sampler_type(const GrGLTexture::IDDesc& idDesc, GrPixelConfig config, const GrGLGpu* gpu) { if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_EXTERNAL) { - SkASSERT(gpu->glCaps().glslCaps()->externalTextureSupport()); + SkASSERT(gpu->caps()->shaderCaps()->externalTextureSupport()); SkASSERT(!GrPixelConfigIsSint(config)); return kTextureExternalSampler_GrSLType; } else if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_RECTANGLE) { diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp index 63e0aeb78d..cc29022456 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -154,7 +154,7 @@ void GrGLProgramBuilder::bindProgramResourceLocations(GrGLuint programID) { GL_CALL(BindFragDataLocation(programID, 0, GrGLSLFragmentShaderBuilder::DeclaredColorOutputName())); } - if (fFS.hasSecondaryOutput() && caps.glslCaps()->mustDeclareFragmentShaderOutput()) { + if (fFS.hasSecondaryOutput() && caps.shaderCaps()->mustDeclareFragmentShaderOutput()) { GL_CALL(BindFragDataLocationIndexed(programID, 0, 1, GrGLSLFragmentShaderBuilder::DeclaredSecondaryColorOutputName())); } diff --git a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp index 81115c5522..bd4921b650 100644 --- a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp +++ b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp @@ -69,7 +69,7 @@ GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx, ? SkSL::Program::kVertex_Kind : SkSL::Program::kFragment_Kind, sksl, - *glCtx.caps()->glslCaps(), + *glCtx.caps()->shaderCaps(), &glsl); #ifdef SK_DEBUG if (!result) { diff --git a/src/gpu/glsl/GrGLSL.cpp b/src/gpu/glsl/GrGLSL.cpp index 2f69a3c5a2..d54ddee0d6 100644 --- a/src/gpu/glsl/GrGLSL.cpp +++ b/src/gpu/glsl/GrGLSL.cpp @@ -27,9 +27,9 @@ bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration gen) { } void GrGLSLAppendDefaultFloatPrecisionDeclaration(GrSLPrecision p, - const GrShaderCaps& glslCaps, + const GrShaderCaps& shaderCaps, SkString* out) { - if (glslCaps.usesPrecisionModifiers()) { + if (shaderCaps.usesPrecisionModifiers()) { switch (p) { case kHigh_GrSLPrecision: out->append("precision highp float;\n"); diff --git a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp index 8c32482d8e..a779accab2 100644 --- a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp +++ b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp @@ -52,7 +52,7 @@ void GrGLSLFragmentProcessor::internalEmitChild(int childIndex, const char* inpu ImageStorages imageStorages = args.fImageStorages.childInputs(childIndex); EmitArgs childArgs(fragBuilder, args.fUniformHandler, - args.fGLSLCaps, + args.fShaderCaps, childProc, outputColor, inputColor, diff --git a/src/gpu/glsl/GrGLSLFragmentProcessor.h b/src/gpu/glsl/GrGLSLFragmentProcessor.h index c9230e4c92..7a8d51ca83 100644 --- a/src/gpu/glsl/GrGLSLFragmentProcessor.h +++ b/src/gpu/glsl/GrGLSLFragmentProcessor.h @@ -122,7 +122,7 @@ public: bool gpImplementsDistanceVector) : fFragBuilder(fragBuilder) , fUniformHandler(uniformHandler) - , fGLSLCaps(caps) + , fShaderCaps(caps) , fFp(fp) , fOutputColor(outputColor) , fInputColor(inputColor) @@ -133,7 +133,7 @@ public: , fGpImplementsDistanceVector(gpImplementsDistanceVector) {} GrGLSLFPFragmentBuilder* fFragBuilder; GrGLSLUniformHandler* fUniformHandler; - const GrShaderCaps* fGLSLCaps; + const GrShaderCaps* fShaderCaps; const GrFragmentProcessor& fFp; const char* fOutputColor; const char* fInputColor; diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp index 3d9802a720..8355f1de7d 100644 --- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp +++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp @@ -94,20 +94,20 @@ GrGLSLFragmentShaderBuilder::GrGLSLFragmentShaderBuilder(GrGLSLProgramBuilder* p } bool GrGLSLFragmentShaderBuilder::enableFeature(GLSLFeature feature) { - const GrShaderCaps& glslCaps = *fProgramBuilder->shaderCaps(); + const GrShaderCaps& shaderCaps = *fProgramBuilder->shaderCaps(); switch (feature) { case kPixelLocalStorage_GLSLFeature: - if (glslCaps.pixelLocalStorageSize() <= 0) { + if (shaderCaps.pixelLocalStorageSize() <= 0) { return false; } this->addFeature(1 << kPixelLocalStorage_GLSLFeature, "GL_EXT_shader_pixel_local_storage"); return true; case kMultisampleInterpolation_GLSLFeature: - if (!glslCaps.multisampleInterpolationSupport()) { + if (!shaderCaps.multisampleInterpolationSupport()) { return false; } - if (const char* extension = glslCaps.multisampleInterpolationExtensionString()) { + if (const char* extension = shaderCaps.multisampleInterpolationExtensionString()) { this->addFeature(1 << kMultisampleInterpolation_GLSLFeature, extension); } return true; @@ -133,16 +133,16 @@ SkString GrGLSLFragmentShaderBuilder::ensureCoords2D(const GrShaderVar& coords) const char* GrGLSLFragmentShaderBuilder::fragmentPosition() { SkDEBUGCODE(fUsedProcessorFeatures |= GrProcessor::kFragmentPosition_RequiredFeature;) - const GrShaderCaps* glslCaps = fProgramBuilder->shaderCaps(); + const GrShaderCaps* shaderCaps = fProgramBuilder->shaderCaps(); // We only declare "gl_FragCoord" when we're in the case where we want to use layout qualifiers // to reverse y. Otherwise it isn't necessary and whether the "in" qualifier appears in the // declaration varies in earlier GLSL specs. So it is simpler to omit it. if (kTopLeft_GrSurfaceOrigin == this->getSurfaceOrigin()) { fSetupFragPosition = true; return "gl_FragCoord"; - } else if (const char* extension = glslCaps->fragCoordConventionsExtensionString()) { + } else if (const char* extension = shaderCaps->fragCoordConventionsExtensionString()) { if (!fSetupFragPosition) { - if (glslCaps->generation() < k150_GrGLSLGeneration) { + if (shaderCaps->generation() < k150_GrGLSLGeneration) { this->addFeature(1 << kFragCoordConventions_GLSLPrivateFeature, extension); } @@ -193,12 +193,12 @@ void GrGLSLFragmentShaderBuilder::appendOffsetToSample(const char* sampleIdx, Co } void GrGLSLFragmentShaderBuilder::maskSampleCoverage(const char* mask, bool invert) { - const GrShaderCaps& glslCaps = *fProgramBuilder->shaderCaps(); - if (!glslCaps.sampleVariablesSupport()) { + const GrShaderCaps& shaderCaps = *fProgramBuilder->shaderCaps(); + if (!shaderCaps.sampleVariablesSupport()) { SkDEBUGFAIL("Attempted to mask sample coverage without support."); return; } - if (const char* extension = glslCaps.sampleVariablesExtensionString()) { + if (const char* extension = shaderCaps.sampleVariablesExtensionString()) { this->addFeature(1 << kSampleVariables_GLSLPrivateFeature, extension); } if (!fHasInitializedSampleMask) { @@ -213,13 +213,13 @@ void GrGLSLFragmentShaderBuilder::maskSampleCoverage(const char* mask, bool inve } void GrGLSLFragmentShaderBuilder::overrideSampleCoverage(const char* mask) { - const GrShaderCaps& glslCaps = *fProgramBuilder->shaderCaps(); - if (!glslCaps.sampleMaskOverrideCoverageSupport()) { + const GrShaderCaps& shaderCaps = *fProgramBuilder->shaderCaps(); + if (!shaderCaps.sampleMaskOverrideCoverageSupport()) { SkDEBUGFAIL("Attempted to override sample coverage without support."); return; } - SkASSERT(glslCaps.sampleVariablesSupport()); - if (const char* extension = glslCaps.sampleVariablesExtensionString()) { + SkASSERT(shaderCaps.sampleVariablesSupport()); + if (const char* extension = shaderCaps.sampleVariablesExtensionString()) { this->addFeature(1 << kSampleVariables_GLSLPrivateFeature, extension); } if (this->addFeature(1 << kSampleMaskOverrideCoverage_GLSLPrivateFeature, @@ -240,14 +240,14 @@ const char* GrGLSLFragmentShaderBuilder::dstColor() { return override; } - const GrShaderCaps* glslCaps = fProgramBuilder->shaderCaps(); - if (glslCaps->fbFetchSupport()) { + const GrShaderCaps* shaderCaps = fProgramBuilder->shaderCaps(); + if (shaderCaps->fbFetchSupport()) { this->addFeature(1 << kFramebufferFetch_GLSLPrivateFeature, - glslCaps->fbFetchExtensionString()); + shaderCaps->fbFetchExtensionString()); // Some versions of this extension string require declaring custom color output on ES 3.0+ - const char* fbFetchColorName = glslCaps->fbFetchColorName(); - if (glslCaps->fbFetchNeedsCustomOutput()) { + const char* fbFetchColorName = shaderCaps->fbFetchColorName(); + if (shaderCaps->fbFetchNeedsCustomOutput()) { this->enableCustomOutput(); fOutputs[fCustomColorOutputIndex].setTypeModifier(GrShaderVar::kInOut_TypeModifier); fbFetchColorName = DeclaredColorOutputName(); diff --git a/src/gpu/glsl/GrGLSLPrimitiveProcessor.h b/src/gpu/glsl/GrGLSLPrimitiveProcessor.h index 6c3d3a8963..4aae284efe 100644 --- a/src/gpu/glsl/GrGLSLPrimitiveProcessor.h +++ b/src/gpu/glsl/GrGLSLPrimitiveProcessor.h @@ -85,7 +85,7 @@ public: , fFragBuilder(fragBuilder) , fVaryingHandler(varyingHandler) , fUniformHandler(uniformHandler) - , fGLSLCaps(caps) + , fShaderCaps(caps) , fGP(gp) , fOutputColor(outputColor) , fOutputCoverage(outputCoverage) @@ -99,7 +99,7 @@ public: GrGLSLPPFragmentBuilder* fFragBuilder; GrGLSLVaryingHandler* fVaryingHandler; GrGLSLUniformHandler* fUniformHandler; - const GrShaderCaps* fGLSLCaps; + const GrShaderCaps* fShaderCaps; const GrPrimitiveProcessor& fGP; const char* fOutputColor; const char* fOutputCoverage; diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp index 40e5a43ded..590439d629 100644 --- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp +++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp @@ -364,22 +364,22 @@ void GrGLSLProgramBuilder::emitFSOutputSwizzle(bool hasSecondaryOutput) { } bool GrGLSLProgramBuilder::checkSamplerCounts() { - const GrShaderCaps& glslCaps = *this->shaderCaps(); - if (fNumVertexSamplers > glslCaps.maxVertexSamplers()) { + const GrShaderCaps& shaderCaps = *this->shaderCaps(); + if (fNumVertexSamplers > shaderCaps.maxVertexSamplers()) { GrCapsDebugf(this->caps(), "Program would use too many vertex samplers\n"); return false; } - if (fNumGeometrySamplers > glslCaps.maxGeometrySamplers()) { + if (fNumGeometrySamplers > shaderCaps.maxGeometrySamplers()) { GrCapsDebugf(this->caps(), "Program would use too many geometry samplers\n"); return false; } - if (fNumFragmentSamplers > glslCaps.maxFragmentSamplers()) { + if (fNumFragmentSamplers > shaderCaps.maxFragmentSamplers()) { GrCapsDebugf(this->caps(), "Program would use too many fragment samplers\n"); return false; } // If the same sampler is used in two different shaders, it counts as two combined samplers. int numCombinedSamplers = fNumVertexSamplers + fNumGeometrySamplers + fNumFragmentSamplers; - if (numCombinedSamplers > glslCaps.maxCombinedSamplers()) { + if (numCombinedSamplers > shaderCaps.maxCombinedSamplers()) { GrCapsDebugf(this->caps(), "Program would use too many combined samplers\n"); return false; } @@ -387,23 +387,23 @@ bool GrGLSLProgramBuilder::checkSamplerCounts() { } bool GrGLSLProgramBuilder::checkImageStorageCounts() { - const GrShaderCaps& glslCaps = *this->shaderCaps(); - if (fNumVertexImageStorages > glslCaps.maxVertexImageStorages()) { + const GrShaderCaps& shaderCaps = *this->shaderCaps(); + if (fNumVertexImageStorages > shaderCaps.maxVertexImageStorages()) { GrCapsDebugf(this->caps(), "Program would use too many vertex images\n"); return false; } - if (fNumGeometryImageStorages > glslCaps.maxGeometryImageStorages()) { + if (fNumGeometryImageStorages > shaderCaps.maxGeometryImageStorages()) { GrCapsDebugf(this->caps(), "Program would use too many geometry images\n"); return false; } - if (fNumFragmentImageStorages > glslCaps.maxFragmentImageStorages()) { + if (fNumFragmentImageStorages > shaderCaps.maxFragmentImageStorages()) { GrCapsDebugf(this->caps(), "Program would use too many fragment images\n"); return false; } // If the same image is used in two different shaders, it counts as two combined images. int numCombinedImages = fNumVertexImageStorages + fNumGeometryImageStorages + fNumFragmentImageStorages; - if (numCombinedImages > glslCaps.maxCombinedImageStorages()) { + if (numCombinedImages > shaderCaps.maxCombinedImageStorages()) { GrCapsDebugf(this->caps(), "Program would use too many combined images\n"); return false; } diff --git a/src/gpu/glsl/GrGLSLXferProcessor.cpp b/src/gpu/glsl/GrGLSLXferProcessor.cpp index 0588513040..e2698199fd 100644 --- a/src/gpu/glsl/GrGLSLXferProcessor.cpp +++ b/src/gpu/glsl/GrGLSLXferProcessor.cpp @@ -63,7 +63,7 @@ void GrGLSLXferProcessor::emitCode(const EmitArgs& args) { fragBuilder->appendTextureLookup(args.fTexSamplers[0], "_dstTexCoord", kVec2f_GrSLType); fragBuilder->codeAppend(";"); } else { - needsLocalOutColor = args.fGLSLCaps->requiresLocalOutputColorForFBFetch(); + needsLocalOutColor = args.fShaderCaps->requiresLocalOutputColorForFBFetch(); } const char* outColor = "_localColorOut"; diff --git a/src/gpu/glsl/GrGLSLXferProcessor.h b/src/gpu/glsl/GrGLSLXferProcessor.h index f3a1c688da..90c1bce5b2 100644 --- a/src/gpu/glsl/GrGLSLXferProcessor.h +++ b/src/gpu/glsl/GrGLSLXferProcessor.h @@ -39,7 +39,7 @@ public: const bool usePLSDstRead) : fXPFragBuilder(fragBuilder) , fUniformHandler(uniformHandler) - , fGLSLCaps(caps) + , fShaderCaps(caps) , fXP(xp) , fInputColor(inputColor) , fInputCoverage(inputCoverage) @@ -52,7 +52,7 @@ public: GrGLSLXPFragmentBuilder* fXPFragBuilder; GrGLSLUniformHandler* fUniformHandler; - const GrShaderCaps* fGLSLCaps; + const GrShaderCaps* fShaderCaps; const GrXferProcessor& fXP; const char* fInputColor; const char* fInputCoverage; diff --git a/src/gpu/instanced/GLInstancedRendering.cpp b/src/gpu/instanced/GLInstancedRendering.cpp index 7503204a1c..49b059d3af 100644 --- a/src/gpu/instanced/GLInstancedRendering.cpp +++ b/src/gpu/instanced/GLInstancedRendering.cpp @@ -38,7 +38,7 @@ GrCaps::InstancedSupport GLInstancedRendering::CheckSupport(const GrGLCaps& glCa (!glCaps.drawIndirectSupport() && !glCaps.drawInstancedSupport())) { return GrCaps::InstancedSupport::kNone; } - return InstanceProcessor::CheckSupport(*glCaps.glslCaps(), glCaps); + return InstanceProcessor::CheckSupport(*glCaps.shaderCaps(), glCaps); } GLInstancedRendering::GLInstancedRendering(GrGLGpu* gpu) diff --git a/src/gpu/instanced/InstanceProcessor.cpp b/src/gpu/instanced/InstanceProcessor.cpp index f6213a3c3d..4560d2bbdc 100644 --- a/src/gpu/instanced/InstanceProcessor.cpp +++ b/src/gpu/instanced/InstanceProcessor.cpp @@ -19,23 +19,23 @@ namespace gr_instanced { -GrCaps::InstancedSupport InstanceProcessor::CheckSupport(const GrShaderCaps& glslCaps, +GrCaps::InstancedSupport InstanceProcessor::CheckSupport(const GrShaderCaps& shaderCaps, const GrCaps& caps) { - if (!glslCaps.canUseAnyFunctionInShader() || - !glslCaps.flatInterpolationSupport() || - !glslCaps.integerSupport() || - 0 == glslCaps.maxVertexSamplers() || + if (!shaderCaps.canUseAnyFunctionInShader() || + !shaderCaps.flatInterpolationSupport() || + !shaderCaps.integerSupport() || + 0 == shaderCaps.maxVertexSamplers() || !caps.shaderCaps()->texelBufferSupport() || caps.maxVertexAttributes() < kNumAttribs) { return GrCaps::InstancedSupport::kNone; } if (!caps.sampleLocationsSupport() || - !glslCaps.sampleVariablesSupport() || - !glslCaps.shaderDerivativeSupport()) { + !shaderCaps.sampleVariablesSupport() || + !shaderCaps.shaderDerivativeSupport()) { return GrCaps::InstancedSupport::kBasic; } if (0 == caps.maxRasterSamples() || - !glslCaps.sampleMaskOverrideCoverageSupport()) { + !shaderCaps.sampleMaskOverrideCoverageSupport()) { return GrCaps::InstancedSupport::kMultisampled; } return GrCaps::InstancedSupport::kMixedSampled; diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp index 4e5e99fd99..0c52643ee8 100644 --- a/src/gpu/vk/GrVkCaps.cpp +++ b/src/gpu/vk/GrVkCaps.cpp @@ -60,7 +60,7 @@ void GrVkCaps::init(const GrContextOptions& contextOptions, const GrVkInterface* GR_VK_CALL(vkInterface, GetPhysicalDeviceMemoryProperties(physDev, &memoryProperties)); this->initGrCaps(properties, memoryProperties, featureFlags); - this->initGLSLCaps(properties, featureFlags); + this->initShaderCaps(properties, featureFlags); this->initConfigTable(vkInterface, physDev); this->initStencilFormat(vkInterface, physDev); @@ -80,8 +80,7 @@ void GrVkCaps::init(const GrContextOptions& contextOptions, const GrVkInterface* } this->applyOptionsOverrides(contextOptions); - GrShaderCaps* glslCaps = fShaderCaps.get(); - glslCaps->applyOptionsOverrides(contextOptions); + fShaderCaps->applyOptionsOverrides(contextOptions); } int get_max_sample_count(VkSampleCountFlags flags) { @@ -137,68 +136,69 @@ void GrVkCaps::initGrCaps(const VkPhysicalDeviceProperties& properties, fSampleShadingSupport = SkToBool(featureFlags & kSampleRateShading_GrVkFeatureFlag); } -void GrVkCaps::initGLSLCaps(const VkPhysicalDeviceProperties& properties, - uint32_t featureFlags) { - GrShaderCaps* glslCaps = fShaderCaps.get(); - glslCaps->fVersionDeclString = "#version 330\n"; +void GrVkCaps::initShaderCaps(const VkPhysicalDeviceProperties& properties, uint32_t featureFlags) { + GrShaderCaps* shaderCaps = fShaderCaps.get(); + shaderCaps->fVersionDeclString = "#version 330\n"; // fConfigOutputSwizzle will default to RGBA so we only need to set it for alpha only config. for (int i = 0; i < kGrPixelConfigCnt; ++i) { GrPixelConfig config = static_cast<GrPixelConfig>(i); if (GrPixelConfigIsAlphaOnly(config)) { - glslCaps->fConfigTextureSwizzle[i] = GrSwizzle::RRRR(); - glslCaps->fConfigOutputSwizzle[i] = GrSwizzle::AAAA(); + shaderCaps->fConfigTextureSwizzle[i] = GrSwizzle::RRRR(); + shaderCaps->fConfigOutputSwizzle[i] = GrSwizzle::AAAA(); } else { if (kRGBA_4444_GrPixelConfig == config) { // The vulkan spec does not require R4G4B4A4 to be supported for texturing so we // store the data in a B4G4R4A4 texture and then swizzle it when doing texture reads // or writing to outputs. Since we're not actually changing the data at all, the // only extra work is the swizzle in the shader for all operations. - glslCaps->fConfigTextureSwizzle[i] = GrSwizzle::BGRA(); - glslCaps->fConfigOutputSwizzle[i] = GrSwizzle::BGRA(); + shaderCaps->fConfigTextureSwizzle[i] = GrSwizzle::BGRA(); + shaderCaps->fConfigOutputSwizzle[i] = GrSwizzle::BGRA(); } else { - glslCaps->fConfigTextureSwizzle[i] = GrSwizzle::RGBA(); + shaderCaps->fConfigTextureSwizzle[i] = GrSwizzle::RGBA(); } } } // Vulkan is based off ES 3.0 so the following should all be supported - glslCaps->fUsesPrecisionModifiers = true; - glslCaps->fFlatInterpolationSupport = true; + shaderCaps->fUsesPrecisionModifiers = true; + shaderCaps->fFlatInterpolationSupport = true; // GrShaderCaps - glslCaps->fShaderDerivativeSupport = true; - glslCaps->fGeometryShaderSupport = SkToBool(featureFlags & kGeometryShader_GrVkFeatureFlag); + shaderCaps->fShaderDerivativeSupport = true; + shaderCaps->fGeometryShaderSupport = SkToBool(featureFlags & kGeometryShader_GrVkFeatureFlag); - glslCaps->fDualSourceBlendingSupport = SkToBool(featureFlags & kDualSrcBlend_GrVkFeatureFlag); + shaderCaps->fDualSourceBlendingSupport = SkToBool(featureFlags & kDualSrcBlend_GrVkFeatureFlag); - glslCaps->fIntegerSupport = true; + shaderCaps->fIntegerSupport = true; // Assume the minimum precisions mandated by the SPIR-V spec. - glslCaps->fShaderPrecisionVaries = true; + shaderCaps->fShaderPrecisionVaries = true; for (int s = 0; s < kGrShaderTypeCount; ++s) { - auto& highp = glslCaps->fFloatPrecisions[s][kHigh_GrSLPrecision]; + auto& highp = shaderCaps->fFloatPrecisions[s][kHigh_GrSLPrecision]; highp.fLogRangeLow = highp.fLogRangeHigh = 127; highp.fBits = 23; - auto& mediump = glslCaps->fFloatPrecisions[s][kMedium_GrSLPrecision]; + auto& mediump = shaderCaps->fFloatPrecisions[s][kMedium_GrSLPrecision]; mediump.fLogRangeLow = mediump.fLogRangeHigh = 14; mediump.fBits = 10; - glslCaps->fFloatPrecisions[s][kLow_GrSLPrecision] = mediump; + shaderCaps->fFloatPrecisions[s][kLow_GrSLPrecision] = mediump; } - glslCaps->initSamplerPrecisionTable(); - - glslCaps->fMaxVertexSamplers = - glslCaps->fMaxGeometrySamplers = - glslCaps->fMaxFragmentSamplers = SkTMin(SkTMin(properties.limits.maxPerStageDescriptorSampledImages, - properties.limits.maxPerStageDescriptorSamplers), - (uint32_t)INT_MAX); - glslCaps->fMaxCombinedSamplers = SkTMin(SkTMin(properties.limits.maxDescriptorSetSampledImages, - properties.limits.maxDescriptorSetSamplers), - (uint32_t)INT_MAX); + shaderCaps->initSamplerPrecisionTable(); + + shaderCaps->fMaxVertexSamplers = + shaderCaps->fMaxGeometrySamplers = + shaderCaps->fMaxFragmentSamplers = SkTMin( + SkTMin(properties.limits.maxPerStageDescriptorSampledImages, + properties.limits.maxPerStageDescriptorSamplers), + (uint32_t)INT_MAX); + shaderCaps->fMaxCombinedSamplers = SkTMin( + SkTMin(properties.limits.maxDescriptorSetSampledImages, + properties.limits.maxDescriptorSetSamplers), + (uint32_t)INT_MAX); } bool stencil_format_supported(const GrVkInterface* interface, diff --git a/src/gpu/vk/GrVkCaps.h b/src/gpu/vk/GrVkCaps.h index c1fb889268..b390a9b2af 100644 --- a/src/gpu/vk/GrVkCaps.h +++ b/src/gpu/vk/GrVkCaps.h @@ -83,8 +83,6 @@ public: return fPreferedStencilFormat; } - GrShaderCaps* glslCaps() const { return fShaderCaps.get(); } - private: enum VkVendor { kQualcomm_VkVendor = 20803, @@ -96,7 +94,7 @@ private: void initGrCaps(const VkPhysicalDeviceProperties&, const VkPhysicalDeviceMemoryProperties&, uint32_t featureFlags); - void initGLSLCaps(const VkPhysicalDeviceProperties&, uint32_t featureFlags); + void initShaderCaps(const VkPhysicalDeviceProperties&, uint32_t featureFlags); void initSampleCount(const VkPhysicalDeviceProperties& properties); diff --git a/src/gpu/vk/GrVkCopyManager.cpp b/src/gpu/vk/GrVkCopyManager.cpp index 4d5be9acd7..78194fc068 100644 --- a/src/gpu/vk/GrVkCopyManager.cpp +++ b/src/gpu/vk/GrVkCopyManager.cpp @@ -26,8 +26,8 @@ #include "SkRect.h" bool GrVkCopyManager::createCopyProgram(GrVkGpu* gpu) { - const GrShaderCaps* glslCaps = gpu->vkCaps().glslCaps(); - const char* version = glslCaps->versionDeclString(); + const GrShaderCaps* shaderCaps = gpu->caps()->shaderCaps(); + const char* version = shaderCaps->versionDeclString(); SkString vertShaderText(version); vertShaderText.append( "#extension GL_ARB_separate_shader_objects : enable\n" diff --git a/src/gpu/vk/GrVkPipelineStateCache.cpp b/src/gpu/vk/GrVkPipelineStateCache.cpp index 2bc4210c0e..62ef3c2c9c 100644 --- a/src/gpu/vk/GrVkPipelineStateCache.cpp +++ b/src/gpu/vk/GrVkPipelineStateCache.cpp @@ -110,7 +110,7 @@ sk_sp<GrVkPipelineState> GrVkResourceProvider::PipelineStateCache::refPipelineSt // Get GrVkProgramDesc GrVkPipelineState::Desc desc; if (!GrVkPipelineState::Desc::Build(&desc, primProc, pipeline, stencil, - primitiveType, *fGpu->vkCaps().glslCaps())) { + primitiveType, *fGpu->caps()->shaderCaps())) { GrCapsDebugf(fGpu->caps(), "Failed to build vk program descriptor!\n"); return nullptr; } |