Rename vars and functions from 'glslcaps'->'shadercaps'

Change-Id: I34d226d866dd4ba8e5f33f95cb8cbf01292f9314
Reviewed-on: https://skia-review.googlesource.com/5312
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2016-11-29 13:43:46 -05:00 committed by Skia Commit-Bot
parent a0c4c3407d
commit 1edc5b92fe
45 changed files with 345 additions and 348 deletions

View File

@ -72,7 +72,7 @@ GrGLuint GLBench::CompileShader(const GrGLContext* context, const char* sksl, Gr
? SkSL::Program::kVertex_Kind
: SkSL::Program::kFragment_Kind,
SkString(sksl),
*context->caps()->glslCaps(),
*context->caps()->shaderCaps(),
&glsl);
if (!result) {
SkDebugf("SkSL compilation failed:\n%s\n%s\n", sksl,

View File

@ -107,8 +107,8 @@ private:
///////////////////////////////////////////////////////////////////////////////////////////////////
GrGLuint GLCpuPosInstancedArraysBench::setupShader(const GrGLContext* ctx) {
const GrShaderCaps* glslCaps = ctx->caps()->glslCaps();
const char* version = glslCaps->versionDeclString();
const GrShaderCaps* shaderCaps = ctx->caps()->shaderCaps();
const char* version = shaderCaps->versionDeclString();
// setup vertex shader
GrShaderVar aPosition("a_position", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
@ -116,11 +116,11 @@ GrGLuint GLCpuPosInstancedArraysBench::setupShader(const GrGLContext* ctx) {
GrShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kOut_TypeModifier);
SkString vshaderTxt(version);
aPosition.appendDecl(glslCaps, &vshaderTxt);
aPosition.appendDecl(shaderCaps, &vshaderTxt);
vshaderTxt.append(";\n");
aColor.appendDecl(glslCaps, &vshaderTxt);
aColor.appendDecl(shaderCaps, &vshaderTxt);
vshaderTxt.append(";\n");
oColor.appendDecl(glslCaps, &vshaderTxt);
oColor.appendDecl(shaderCaps, &vshaderTxt);
vshaderTxt.append(";\n");
vshaderTxt.append(
@ -133,14 +133,14 @@ GrGLuint GLCpuPosInstancedArraysBench::setupShader(const GrGLContext* ctx) {
// setup fragment shader
GrShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
SkString fshaderTxt(version);
GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCaps, &fshaderTxt);
GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *shaderCaps, &fshaderTxt);
oColor.setTypeModifier(GrShaderVar::kIn_TypeModifier);
oColor.appendDecl(glslCaps, &fshaderTxt);
oColor.appendDecl(shaderCaps, &fshaderTxt);
fshaderTxt.append(";\n");
const char* fsOutName;
if (glslCaps->mustDeclareFragmentShaderOutput()) {
oFragColor.appendDecl(glslCaps, &fshaderTxt);
if (shaderCaps->mustDeclareFragmentShaderOutput()) {
oFragColor.appendDecl(shaderCaps, &fshaderTxt);
fshaderTxt.append(";\n");
fsOutName = oFragColor.c_str();
} else {

View File

@ -93,8 +93,8 @@ private:
///////////////////////////////////////////////////////////////////////////////////////////////////
GrGLuint GLVec4ScalarBench::setupShader(const GrGLContext* ctx) {
const GrShaderCaps* glslCaps = ctx->caps()->glslCaps();
const char* version = glslCaps->versionDeclString();
const GrShaderCaps* shaderCaps = ctx->caps()->shaderCaps();
const char* version = shaderCaps->versionDeclString();
// this shader draws fNumStages overlapping circles of increasing opacity (coverage) and
// decreasing size, with the center of each subsequent circle closer to the bottom-right
@ -107,13 +107,13 @@ GrGLuint GLVec4ScalarBench::setupShader(const GrGLContext* ctx) {
GrShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kOut_TypeModifier);
SkString vshaderTxt(version);
aPosition.appendDecl(glslCaps, &vshaderTxt);
aPosition.appendDecl(shaderCaps, &vshaderTxt);
vshaderTxt.append(";\n");
aColor.appendDecl(glslCaps, &vshaderTxt);
aColor.appendDecl(shaderCaps, &vshaderTxt);
vshaderTxt.append(";\n");
oPosition.appendDecl(glslCaps, &vshaderTxt);
oPosition.appendDecl(shaderCaps, &vshaderTxt);
vshaderTxt.append(";\n");
oColor.appendDecl(glslCaps, &vshaderTxt);
oColor.appendDecl(shaderCaps, &vshaderTxt);
vshaderTxt.append(";\n");
vshaderTxt.append(
@ -131,17 +131,17 @@ GrGLuint GLVec4ScalarBench::setupShader(const GrGLContext* ctx) {
// next stage.
GrShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
SkString fshaderTxt(version);
GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCaps, &fshaderTxt);
GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *shaderCaps, &fshaderTxt);
oPosition.setTypeModifier(GrShaderVar::kIn_TypeModifier);
oPosition.appendDecl(glslCaps, &fshaderTxt);
oPosition.appendDecl(shaderCaps, &fshaderTxt);
fshaderTxt.append(";\n");
oColor.setTypeModifier(GrShaderVar::kIn_TypeModifier);
oColor.appendDecl(glslCaps, &fshaderTxt);
oColor.appendDecl(shaderCaps, &fshaderTxt);
fshaderTxt.append(";\n");
const char* fsOutName;
if (glslCaps->mustDeclareFragmentShaderOutput()) {
oFragColor.appendDecl(glslCaps, &fshaderTxt);
if (shaderCaps->mustDeclareFragmentShaderOutput()) {
oFragColor.appendDecl(shaderCaps, &fshaderTxt);
fshaderTxt.append(";\n");
fsOutName = oFragColor.c_str();
} else {

View File

@ -65,8 +65,8 @@ private:
GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t attribs,
uint32_t maxAttribs) {
const GrShaderCaps* glslCaps = ctx->caps()->glslCaps();
const char* version = glslCaps->versionDeclString();
const GrShaderCaps* shaderCaps = ctx->caps()->shaderCaps();
const char* version = shaderCaps->versionDeclString();
// setup vertex shader
GrShaderVar aPosition("a_position", kVec4f_GrSLType, GrShaderVar::kIn_TypeModifier);
@ -74,7 +74,7 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
SkTArray<GrShaderVar> oVars;
SkString vshaderTxt(version);
aPosition.appendDecl(glslCaps, &vshaderTxt);
aPosition.appendDecl(shaderCaps, &vshaderTxt);
vshaderTxt.append(";\n");
for (uint32_t i = 0; i < attribs; i++) {
@ -83,7 +83,7 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
aVars.push_back(GrShaderVar(aname.c_str(),
kVec4f_GrSLType,
GrShaderVar::kIn_TypeModifier));
aVars.back().appendDecl(glslCaps, &vshaderTxt);
aVars.back().appendDecl(shaderCaps, &vshaderTxt);
vshaderTxt.append(";\n");
}
@ -94,7 +94,7 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
oVars.push_back(GrShaderVar(oname.c_str(),
kVec4f_GrSLType,
GrShaderVar::kOut_TypeModifier));
oVars.back().appendDecl(glslCaps, &vshaderTxt);
oVars.back().appendDecl(shaderCaps, &vshaderTxt);
vshaderTxt.append(";\n");
}
@ -117,11 +117,11 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
// setup fragment shader
GrShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
SkString fshaderTxt(version);
GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCaps, &fshaderTxt);
GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *shaderCaps, &fshaderTxt);
const char* fsOutName;
if (glslCaps->mustDeclareFragmentShaderOutput()) {
oFragColor.appendDecl(glslCaps, &fshaderTxt);
if (shaderCaps->mustDeclareFragmentShaderOutput()) {
oFragColor.appendDecl(shaderCaps, &fshaderTxt);
fshaderTxt.append(";\n");
fsOutName = oFragColor.c_str();
} else {
@ -130,7 +130,7 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
for (uint32_t i = 0; i < maxAttribs; i++) {
oVars[i].setTypeModifier(GrShaderVar::kIn_TypeModifier);
oVars[i].appendDecl(glslCaps, &fshaderTxt);
oVars[i].appendDecl(shaderCaps, &fshaderTxt);
fshaderTxt.append(";\n");
}

View File

@ -885,7 +885,7 @@ void GrGLRectBlurEffect::emitCode(EmitArgs& args) {
const char *profileSizeName;
SkString precisionString;
if (args.fGLSLCaps->usesPrecisionModifiers()) {
if (args.fShaderCaps->usesPrecisionModifiers()) {
precisionString.printf("%s ", GrGLSLPrecisionString(rbe.precision()));
}
fProxyRectUniform = uniformHandler->addUniform(kFragment_GrShaderFlag,

View File

@ -614,7 +614,7 @@ void GrGLDisplacementMapEffect::emitCode(EmitArgs& args) {
fGLDomain.sampleTexture(fragBuilder,
args.fUniformHandler,
args.fGLSLCaps,
args.fShaderCaps,
domain,
args.fOutputColor,
SkString(cCoords),

View File

@ -1864,7 +1864,7 @@ void GrGLLightingEffect::emitCode(EmitArgs& args) {
fragBuilder->codeAppendf("vec4 %s;", temp.c_str());
fDomain.sampleTexture(fragBuilder,
args.fUniformHandler,
args.fGLSLCaps,
args.fShaderCaps,
le.domain(),
temp.c_str(),
texCoords,

View File

@ -1377,7 +1377,7 @@ uint32_t GrGradientEffect::GLSLProcessor::GenBaseGradientKey(const GrProcessor&
void GrGradientEffect::GLSLProcessor::emitColor(GrGLSLFPFragmentBuilder* fragBuilder,
GrGLSLUniformHandler* uniformHandler,
const GrShaderCaps* glslCaps,
const GrShaderCaps* shaderCaps,
const GrGradientEffect& ge,
const char* gradientTValue,
const char* outputColor,
@ -1531,7 +1531,7 @@ void GrGradientEffect::GLSLProcessor::emitColor(GrGLSLFPFragmentBuilder* fragBui
fragBuilder->codeAppendf("float oneMinus2t = 1.0 - (2.0 * %s);", t);
fragBuilder->codeAppendf("vec4 colorTemp = clamp(oneMinus2t, 0.0, 1.0) * %s[0];",
colors);
if (!glslCaps->canUseMinAndAbsTogether()) {
if (!shaderCaps->canUseMinAndAbsTogether()) {
// The Tegra3 compiler will sometimes never return if we have
// min(abs(oneMinus2t), 1.0), or do the abs first in a separate expression.
fragBuilder->codeAppendf("float minAbs = abs(oneMinus2t);");

View File

@ -481,7 +481,7 @@ protected:
// of hard stop gradients
void emitColor(GrGLSLFPFragmentBuilder* fragBuilder,
GrGLSLUniformHandler* uniformHandler,
const GrShaderCaps* caps,
const GrShaderCaps* shaderCaps,
const GrGradientEffect&,
const char* gradientTValue,
const char* outputColor,

View File

@ -435,7 +435,7 @@ void GrLinearGradient::GLSLLinearProcessor::emitCode(EmitArgs& args) {
t.append(".x");
this->emitColor(args.fFragBuilder,
args.fUniformHandler,
args.fGLSLCaps,
args.fShaderCaps,
ge,
t.c_str(),
args.fOutputColor,

View File

@ -330,7 +330,7 @@ void GrRadialGradient::GLSLRadialProcessor::emitCode(EmitArgs& args) {
t.append(")");
this->emitColor(args.fFragBuilder,
args.fUniformHandler,
args.fGLSLCaps,
args.fShaderCaps,
ge, t.c_str(),
args.fOutputColor,
args.fInputColor,

View File

@ -214,7 +214,7 @@ void GrSweepGradient::GLSLSweepProcessor::emitCode(EmitArgs& args) {
coords2D.c_str(), coords2D.c_str());
this->emitColor(args.fFragBuilder,
args.fUniformHandler,
args.fGLSLCaps,
args.fShaderCaps,
ge, t.c_str(),
args.fOutputColor,
args.fInputColor,

View File

@ -274,7 +274,7 @@ void Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::emitCode(EmitArgs& args)
fragBuilder->codeAppend("\t");
this->emitColor(fragBuilder,
uniformHandler,
args.fGLSLCaps,
args.fShaderCaps,
ge,
tName.c_str(),
args.fOutputColor,
@ -540,7 +540,7 @@ void FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::emitCode
fragBuilder->codeAppend("\t\t");
this->emitColor(fragBuilder,
uniformHandler,
args.fGLSLCaps,
args.fShaderCaps,
ge,
tName.c_str(),
args.fOutputColor,
@ -721,7 +721,7 @@ void FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::emitCode(E
this->emitColor(fragBuilder,
uniformHandler,
args.fGLSLCaps,
args.fShaderCaps,
ge,
tName.c_str(),
args.fOutputColor,
@ -985,7 +985,7 @@ void CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::emitCode
this->emitColor(fragBuilder,
uniformHandler,
args.fGLSLCaps,
args.fShaderCaps,
ge,
tName.c_str(),
args.fOutputColor,
@ -1237,7 +1237,7 @@ void CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::emitCo
fragBuilder->codeAppend("\t\t");
this->emitColor(fragBuilder,
uniformHandler,
args.fGLSLCaps,
args.fShaderCaps,
ge,
tName.c_str(),
args.fOutputColor,

View File

@ -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;

View File

@ -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));
}

View File

@ -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()) {

View File

@ -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,

View File

@ -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;

View File

@ -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,

View File

@ -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);

View File

@ -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);

View File

@ -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"),

View File

@ -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,

View File

@ -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();
}
}
}

View File

@ -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;

View File

@ -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"

View File

@ -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;
}

View File

@ -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) {

View File

@ -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()));
}

View File

@ -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) {

View File

@ -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");

View File

@ -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,

View File

@ -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;

View File

@ -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();

View File

@ -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;

View File

@ -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;
}

View File

@ -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";

View File

@ -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;

View File

@ -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)

View File

@ -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;

View File

@ -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();
shaderCaps->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->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,

View File

@ -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);

View File

@ -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"

View File

@ -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;
}

View File

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