Got RelaxedPrecision decorations working again in SPIR-V, and removed
no-longer-needed old-style precision handling code. Bug: skia:8829 Change-Id: I72fc2ee2a305c9c72a3efa92dd44d18239eabaf2 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/198169 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
parent
1132f74e11
commit
858feccb58
@ -640,110 +640,6 @@ static inline bool GrSLTypeIsCombinedSamplerType(GrSLType type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline bool GrSLTypeAcceptsPrecision(GrSLType type) {
|
||||
switch (type) {
|
||||
case kTexture2DSampler_GrSLType:
|
||||
case kTextureExternalSampler_GrSLType:
|
||||
case kTexture2DRectSampler_GrSLType:
|
||||
return true;
|
||||
|
||||
case kVoid_GrSLType:
|
||||
case kBool_GrSLType:
|
||||
case kByte_GrSLType:
|
||||
case kByte2_GrSLType:
|
||||
case kByte3_GrSLType:
|
||||
case kByte4_GrSLType:
|
||||
case kUByte_GrSLType:
|
||||
case kUByte2_GrSLType:
|
||||
case kUByte3_GrSLType:
|
||||
case kUByte4_GrSLType:
|
||||
case kShort_GrSLType:
|
||||
case kShort2_GrSLType:
|
||||
case kShort3_GrSLType:
|
||||
case kShort4_GrSLType:
|
||||
case kUShort_GrSLType:
|
||||
case kUShort2_GrSLType:
|
||||
case kUShort3_GrSLType:
|
||||
case kUShort4_GrSLType:
|
||||
case kFloat_GrSLType:
|
||||
case kFloat2_GrSLType:
|
||||
case kFloat3_GrSLType:
|
||||
case kFloat4_GrSLType:
|
||||
case kFloat2x2_GrSLType:
|
||||
case kFloat3x3_GrSLType:
|
||||
case kFloat4x4_GrSLType:
|
||||
case kHalf_GrSLType:
|
||||
case kHalf2_GrSLType:
|
||||
case kHalf3_GrSLType:
|
||||
case kHalf4_GrSLType:
|
||||
case kHalf2x2_GrSLType:
|
||||
case kHalf3x3_GrSLType:
|
||||
case kHalf4x4_GrSLType:
|
||||
case kInt_GrSLType:
|
||||
case kInt2_GrSLType:
|
||||
case kInt3_GrSLType:
|
||||
case kInt4_GrSLType:
|
||||
case kUint_GrSLType:
|
||||
case kUint2_GrSLType:
|
||||
return false;
|
||||
}
|
||||
SK_ABORT("Unexpected type");
|
||||
return false;
|
||||
}
|
||||
|
||||
// temporarily accepting (but ignoring) precision modifiers on the new types; this will be killed
|
||||
// in a future CL
|
||||
static inline bool GrSLTypeTemporarilyAcceptsPrecision(GrSLType type) {
|
||||
switch (type) {
|
||||
case kShort_GrSLType:
|
||||
case kUShort_GrSLType:
|
||||
case kFloat_GrSLType:
|
||||
case kFloat2_GrSLType:
|
||||
case kFloat3_GrSLType:
|
||||
case kFloat4_GrSLType:
|
||||
case kFloat2x2_GrSLType:
|
||||
case kFloat3x3_GrSLType:
|
||||
case kFloat4x4_GrSLType:
|
||||
case kHalf_GrSLType:
|
||||
case kHalf2_GrSLType:
|
||||
case kHalf3_GrSLType:
|
||||
case kHalf4_GrSLType:
|
||||
case kHalf2x2_GrSLType:
|
||||
case kHalf3x3_GrSLType:
|
||||
case kHalf4x4_GrSLType:
|
||||
case kInt_GrSLType:
|
||||
case kInt2_GrSLType:
|
||||
case kInt3_GrSLType:
|
||||
case kInt4_GrSLType:
|
||||
case kUint_GrSLType:
|
||||
case kUint2_GrSLType:
|
||||
case kTexture2DSampler_GrSLType:
|
||||
case kTextureExternalSampler_GrSLType:
|
||||
case kTexture2DRectSampler_GrSLType:
|
||||
return true;
|
||||
|
||||
case kVoid_GrSLType:
|
||||
case kBool_GrSLType:
|
||||
case kByte_GrSLType:
|
||||
case kByte2_GrSLType:
|
||||
case kByte3_GrSLType:
|
||||
case kByte4_GrSLType:
|
||||
case kUByte_GrSLType:
|
||||
case kUByte2_GrSLType:
|
||||
case kUByte3_GrSLType:
|
||||
case kUByte4_GrSLType:
|
||||
case kShort2_GrSLType:
|
||||
case kShort3_GrSLType:
|
||||
case kShort4_GrSLType:
|
||||
case kUShort2_GrSLType:
|
||||
case kUShort3_GrSLType:
|
||||
case kUShort4_GrSLType:
|
||||
return false;
|
||||
}
|
||||
SK_ABORT("Unexpected type");
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
|
@ -47,7 +47,7 @@ private:
|
||||
// add uniform
|
||||
const char* xformUniName = nullptr;
|
||||
fXformUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kFloat2x2_GrSLType,
|
||||
kDefault_GrSLPrecision, "Xform", &xformUniName);
|
||||
"Xform", &xformUniName);
|
||||
|
||||
SkString dstNormalColorName("dstNormalColor");
|
||||
this->emitChild(0, &dstNormalColorName, args);
|
||||
|
@ -35,25 +35,7 @@ void GrShaderVar::setIOType(GrIOType ioType) {
|
||||
SK_ABORT("Unknown io type.");
|
||||
}
|
||||
|
||||
// Converts a GrSLPrecision to its corresponding GLSL precision qualifier. TODO: Remove this as we
|
||||
// shouldn't need it with SkSL.
|
||||
static inline const char* glsl_precision_string(GrSLPrecision p) {
|
||||
switch (p) {
|
||||
case kLow_GrSLPrecision:
|
||||
return "lowp";
|
||||
case kMedium_GrSLPrecision:
|
||||
return "mediump";
|
||||
case kHigh_GrSLPrecision:
|
||||
return "highp";
|
||||
case kDefault_GrSLPrecision:
|
||||
return "";
|
||||
}
|
||||
SK_ABORT("Unexpected precision type.");
|
||||
return "";
|
||||
}
|
||||
|
||||
void GrShaderVar::appendDecl(const GrShaderCaps* shaderCaps, SkString* out) const {
|
||||
SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeTemporarilyAcceptsPrecision(fType));
|
||||
SkString layout = fLayoutQualifier;
|
||||
if (!fLayoutQualifier.isEmpty()) {
|
||||
out->appendf("layout(%s) ", fLayoutQualifier.c_str());
|
||||
@ -64,10 +46,6 @@ void GrShaderVar::appendDecl(const GrShaderCaps* shaderCaps, SkString* out) cons
|
||||
out->append(" ");
|
||||
}
|
||||
GrSLType effectiveType = this->getType();
|
||||
if (shaderCaps->usesPrecisionModifiers() && GrSLTypeAcceptsPrecision(effectiveType)) {
|
||||
// Desktop GLSL has added precision qualifiers but they don't do anything.
|
||||
out->appendf("%s ", glsl_precision_string(fPrecision));
|
||||
}
|
||||
if (this->isArray()) {
|
||||
if (this->isUnsizedArray()) {
|
||||
out->appendf("%s %s[]", GrGLSLTypeString(effectiveType), this->getName().c_str());
|
||||
|
@ -46,47 +46,39 @@ public:
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
}
|
||||
|
||||
GrShaderVar(const SkString& name, GrSLType type, int arrayCount = kNonArray,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision)
|
||||
GrShaderVar(const SkString& name, GrSLType type, int arrayCount = kNonArray)
|
||||
: fType(type)
|
||||
, fTypeModifier(kNone_TypeModifier)
|
||||
, fCount(arrayCount)
|
||||
, fPrecision(precision)
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS)
|
||||
, fName(name) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
fUseUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS;
|
||||
}
|
||||
|
||||
GrShaderVar(const char* name, GrSLType type, int arrayCount = kNonArray,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision)
|
||||
GrShaderVar(const char* name, GrSLType type, int arrayCount = kNonArray)
|
||||
: fType(type)
|
||||
, fTypeModifier(kNone_TypeModifier)
|
||||
, fCount(arrayCount)
|
||||
, fPrecision(precision)
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS)
|
||||
, fName(name) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
fUseUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS;
|
||||
}
|
||||
|
||||
GrShaderVar(const char* name, GrSLType type, TypeModifier typeModifier,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision)
|
||||
GrShaderVar(const char* name, GrSLType type, TypeModifier typeModifier)
|
||||
: fType(type)
|
||||
, fTypeModifier(typeModifier)
|
||||
, fCount(kNonArray)
|
||||
, fPrecision(precision)
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS)
|
||||
, fName(name) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
}
|
||||
|
||||
GrShaderVar(const char* name, GrSLType type, TypeModifier typeModifier,
|
||||
int arrayCount, GrSLPrecision precision = kDefault_GrSLPrecision)
|
||||
GrShaderVar(const char* name, GrSLType type, TypeModifier typeModifier, int arrayCount)
|
||||
: fType(type)
|
||||
, fTypeModifier(typeModifier)
|
||||
, fCount(arrayCount)
|
||||
, fPrecision(precision)
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS)
|
||||
, fName(name) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
@ -96,7 +88,6 @@ public:
|
||||
: fType(that.fType)
|
||||
, fTypeModifier(that.fTypeModifier)
|
||||
, fCount(that.fCount)
|
||||
, fPrecision(that.fPrecision)
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS)
|
||||
, fName(that.fName)
|
||||
, fLayoutQualifier(that.fLayoutQualifier)
|
||||
@ -110,17 +101,14 @@ public:
|
||||
void set(GrSLType type,
|
||||
const SkString& name,
|
||||
TypeModifier typeModifier = kNone_TypeModifier,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision,
|
||||
const char* layoutQualifier = nullptr,
|
||||
const char* extraModifiers = nullptr,
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeTemporarilyAcceptsPrecision(type));
|
||||
fType = type;
|
||||
fTypeModifier = typeModifier;
|
||||
fName = name;
|
||||
fCount = kNonArray;
|
||||
fPrecision = precision;
|
||||
fLayoutQualifier = layoutQualifier;
|
||||
if (extraModifiers) {
|
||||
fExtraModifiers.printf("%s ", extraModifiers);
|
||||
@ -134,17 +122,14 @@ public:
|
||||
void set(GrSLType type,
|
||||
const char* name,
|
||||
TypeModifier typeModifier = kNone_TypeModifier,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision,
|
||||
const char* layoutQualifier = nullptr,
|
||||
const char* extraModifiers = nullptr,
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeTemporarilyAcceptsPrecision(type));
|
||||
fType = type;
|
||||
fTypeModifier = typeModifier;
|
||||
fName = name;
|
||||
fCount = kNonArray;
|
||||
fPrecision = precision;
|
||||
fLayoutQualifier = layoutQualifier;
|
||||
if (extraModifiers) {
|
||||
fExtraModifiers.printf("%s ", extraModifiers);
|
||||
@ -159,17 +144,14 @@ public:
|
||||
const SkString& name,
|
||||
int count,
|
||||
TypeModifier typeModifier,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision,
|
||||
const char* layoutQualifier = nullptr,
|
||||
const char* extraModifiers = nullptr,
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeTemporarilyAcceptsPrecision(type));
|
||||
fType = type;
|
||||
fTypeModifier = typeModifier;
|
||||
fName = name;
|
||||
fCount = count;
|
||||
fPrecision = precision;
|
||||
fLayoutQualifier = layoutQualifier;
|
||||
if (extraModifiers) {
|
||||
fExtraModifiers.printf("%s ", extraModifiers);
|
||||
@ -184,17 +166,14 @@ public:
|
||||
const char* name,
|
||||
int count,
|
||||
TypeModifier typeModifier,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision,
|
||||
const char* layoutQualifier = nullptr,
|
||||
const char* extraModifiers = nullptr,
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeTemporarilyAcceptsPrecision(type));
|
||||
fType = type;
|
||||
fTypeModifier = typeModifier;
|
||||
fName = name;
|
||||
fCount = count;
|
||||
fPrecision = precision;
|
||||
fLayoutQualifier = layoutQualifier;
|
||||
if (extraModifiers) {
|
||||
fExtraModifiers.printf("%s ", extraModifiers);
|
||||
@ -259,16 +238,6 @@ public:
|
||||
TypeModifier getTypeModifier() const { return fTypeModifier; }
|
||||
void setTypeModifier(TypeModifier type) { fTypeModifier = type; }
|
||||
|
||||
/**
|
||||
* Get the precision of the var
|
||||
*/
|
||||
GrSLPrecision getPrecision() const { return fPrecision; }
|
||||
|
||||
/**
|
||||
* Set the precision of the var
|
||||
*/
|
||||
void setPrecision(GrSLPrecision p) { fPrecision = p; }
|
||||
|
||||
/**
|
||||
* Appends to the layout qualifier
|
||||
*/
|
||||
@ -314,7 +283,6 @@ private:
|
||||
GrSLType fType;
|
||||
TypeModifier fTypeModifier;
|
||||
int fCount;
|
||||
GrSLPrecision fPrecision;
|
||||
/// Work around driver bugs on some hardware that don't correctly
|
||||
/// support uniform float []
|
||||
bool fUseUniformFloatArrays;
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
(void)rect;
|
||||
prevRect = float4(-1.0);
|
||||
fRectUniformVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat4_GrSLType, kDefault_GrSLPrecision, "rectUniform");
|
||||
kFragment_GrShaderFlag, kFloat4_GrSLType, "rectUniform");
|
||||
fragBuilder->codeAppendf(
|
||||
"float4 prevRect = float4(%f, %f, %f, %f);\nhalf alpha;\n@switch (%d) {\n case "
|
||||
"0:\n case 2:\n alpha = half(all(greaterThan(float4(sk_FragCoord.xy, "
|
||||
|
@ -37,10 +37,10 @@ public:
|
||||
(void)innerThreshold;
|
||||
auto outerThreshold = _outer.outerThreshold();
|
||||
(void)outerThreshold;
|
||||
fInnerThresholdVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kHalf_GrSLType, kDefault_GrSLPrecision, "innerThreshold");
|
||||
fOuterThresholdVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kHalf_GrSLType, kDefault_GrSLPrecision, "outerThreshold");
|
||||
fInnerThresholdVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kHalf_GrSLType, "innerThreshold");
|
||||
fOuterThresholdVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kHalf_GrSLType, "outerThreshold");
|
||||
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
|
||||
fragBuilder->codeAppendf(
|
||||
"half4 color = %s;\nhalf4 mask_color = texture(%s, %s).%s;\nif (mask_color.w < "
|
||||
|
@ -35,7 +35,6 @@ public:
|
||||
const char* atlasSizeInvName;
|
||||
fAtlasSizeInvUniform = uniformHandler->addUniform(kVertex_GrShaderFlag,
|
||||
kFloat2_GrSLType,
|
||||
kHigh_GrSLPrecision,
|
||||
"AtlasSizeInv",
|
||||
&atlasSizeInvName);
|
||||
|
||||
|
@ -271,7 +271,7 @@ public:
|
||||
auto solidRadius = _outer.solidRadius();
|
||||
(void)solidRadius;
|
||||
fCircleDataVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType,
|
||||
kDefault_GrSLPrecision, "circleData");
|
||||
"circleData");
|
||||
fragBuilder->codeAppendf(
|
||||
"half2 vec = half2(half((sk_FragCoord.x - float(%s.x)) * float(%s.w)), "
|
||||
"half((sk_FragCoord.y - float(%s.y)) * float(%s.w)));\nhalf dist = length(vec) + "
|
||||
|
@ -29,8 +29,8 @@ public:
|
||||
auto radius = _outer.radius();
|
||||
(void)radius;
|
||||
prevRadius = -1.0;
|
||||
fCircleVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType,
|
||||
kDefault_GrSLPrecision, "circle");
|
||||
fCircleVar =
|
||||
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "circle");
|
||||
fragBuilder->codeAppendf(
|
||||
"half2 prevCenter;\nhalf prevRadius = %f;\nhalf d;\n@if (%d == 2 || %d == 3) {\n "
|
||||
" d = half((length((float2(%s.xy) - sk_FragCoord.xy) * float(%s.w)) - 1.0) * "
|
||||
|
@ -26,8 +26,8 @@ public:
|
||||
(void)color;
|
||||
auto mode = _outer.mode();
|
||||
(void)mode;
|
||||
fColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType,
|
||||
kDefault_GrSLPrecision, "color");
|
||||
fColorVar =
|
||||
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "color");
|
||||
fragBuilder->codeAppendf(
|
||||
"@switch (%d) {\n case 0:\n %s = %s;\n break;\n case 1:\n "
|
||||
" %s = %s * %s;\n break;\n case 2:\n %s = %s.w * %s;\n "
|
||||
|
@ -41,7 +41,6 @@ public:
|
||||
const char* atlasSizeInvName;
|
||||
fAtlasSizeInvUniform = uniformHandler->addUniform(kVertex_GrShaderFlag,
|
||||
kFloat2_GrSLType,
|
||||
kHigh_GrSLPrecision,
|
||||
"AtlasSizeInv",
|
||||
&atlasSizeInvName);
|
||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||
@ -341,7 +340,6 @@ public:
|
||||
const char* atlasSizeInvName;
|
||||
fAtlasSizeInvUniform = uniformHandler->addUniform(kVertex_GrShaderFlag,
|
||||
kFloat2_GrSLType,
|
||||
kHigh_GrSLPrecision,
|
||||
"AtlasSizeInv",
|
||||
&atlasSizeInvName);
|
||||
|
||||
@ -630,7 +628,6 @@ public:
|
||||
const char* atlasSizeInvName;
|
||||
fAtlasSizeInvUniform = uniformHandler->addUniform(kVertex_GrShaderFlag,
|
||||
kFloat2_GrSLType,
|
||||
kHigh_GrSLPrecision,
|
||||
"AtlasSizeInv",
|
||||
&atlasSizeInvName);
|
||||
|
||||
|
@ -31,10 +31,10 @@ public:
|
||||
prevRadii = float2(-1.0);
|
||||
useScale = !sk_Caps.floatIs32Bits;
|
||||
fEllipseVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
kDefault_GrSLPrecision, "ellipse");
|
||||
"ellipse");
|
||||
if (useScale) {
|
||||
fScaleVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat2_GrSLType,
|
||||
kDefault_GrSLPrecision, "scale");
|
||||
"scale");
|
||||
}
|
||||
fragBuilder->codeAppendf(
|
||||
"float2 prevCenter;\nfloat2 prevRadii = float2(%f, %f);\nbool useScale = "
|
||||
|
@ -35,17 +35,17 @@ public:
|
||||
auto yInvInset = _outer.yInvInset();
|
||||
(void)yInvInset;
|
||||
fBoundsUniformVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat4_GrSLType, kDefault_GrSLPrecision, "boundsUniform");
|
||||
kFragment_GrShaderFlag, kFloat4_GrSLType, "boundsUniform");
|
||||
fXInvZoomVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat_GrSLType, kDefault_GrSLPrecision, "xInvZoom");
|
||||
kFragment_GrShaderFlag, kFloat_GrSLType, "xInvZoom");
|
||||
fYInvZoomVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat_GrSLType, kDefault_GrSLPrecision, "yInvZoom");
|
||||
kFragment_GrShaderFlag, kFloat_GrSLType, "yInvZoom");
|
||||
fXInvInsetVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat_GrSLType, kDefault_GrSLPrecision, "xInvInset");
|
||||
kFragment_GrShaderFlag, kFloat_GrSLType, "xInvInset");
|
||||
fYInvInsetVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat_GrSLType, kDefault_GrSLPrecision, "yInvInset");
|
||||
fOffsetVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kHalf2_GrSLType, kDefault_GrSLPrecision, "offset");
|
||||
kFragment_GrShaderFlag, kFloat_GrSLType, "yInvInset");
|
||||
fOffsetVar =
|
||||
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf2_GrSLType, "offset");
|
||||
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
|
||||
fragBuilder->codeAppendf(
|
||||
"float2 coord = %s;\nfloat2 zoom_coord = float2(%s) + coord * float2(%s, "
|
||||
|
@ -24,8 +24,8 @@ public:
|
||||
(void)_outer;
|
||||
auto weight = _outer.weight();
|
||||
(void)weight;
|
||||
fWeightVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
|
||||
kDefault_GrSLPrecision, "weight");
|
||||
fWeightVar =
|
||||
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType, "weight");
|
||||
SkString _input0 = SkStringPrintf("%s", args.fInputColor);
|
||||
SkString _child0("_child0");
|
||||
this->emitChild(_outer.fp0_index(), _input0.c_str(), &_child0, args);
|
||||
|
@ -69,11 +69,11 @@ public:
|
||||
auto cornerRadius = _outer.cornerRadius();
|
||||
(void)cornerRadius;
|
||||
fCornerRadiusVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
|
||||
kDefault_GrSLPrecision, "cornerRadius");
|
||||
"cornerRadius");
|
||||
fProxyRectVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
kDefault_GrSLPrecision, "proxyRect");
|
||||
"proxyRect");
|
||||
fBlurRadiusVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
|
||||
kDefault_GrSLPrecision, "blurRadius");
|
||||
"blurRadius");
|
||||
fragBuilder->codeAppendf(
|
||||
"\nhalf2 translatedFragPos = half2(sk_FragCoord.xy - %s.xy);\nhalf threshold = %s "
|
||||
"+ 2.0 * %s;\nhalf2 middle = half2((%s.zw - %s.xy) - float(2.0 * threshold));\nif "
|
||||
|
@ -31,20 +31,18 @@ public:
|
||||
abs(rect.bottom()) > 16000.0) ||
|
||||
abs(rect.right() - rect.left()) > 16000.0) ||
|
||||
abs(rect.bottom() - rect.top()) > 16000.0;
|
||||
fRectVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
kDefault_GrSLPrecision, "rect");
|
||||
fRectVar =
|
||||
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType, "rect");
|
||||
if (!highPrecision) {
|
||||
fProxyRectHalfVar =
|
||||
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType,
|
||||
kDefault_GrSLPrecision, "proxyRectHalf");
|
||||
fProxyRectHalfVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kHalf4_GrSLType, "proxyRectHalf");
|
||||
}
|
||||
if (highPrecision) {
|
||||
fProxyRectFloatVar =
|
||||
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
kDefault_GrSLPrecision, "proxyRectFloat");
|
||||
fProxyRectFloatVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat4_GrSLType, "proxyRectFloat");
|
||||
}
|
||||
fProfileSizeVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
|
||||
kDefault_GrSLPrecision, "profileSize");
|
||||
"profileSize");
|
||||
fragBuilder->codeAppendf(
|
||||
"/* key */ bool highPrecision = %s;\n@if (highPrecision) {\n float2 "
|
||||
"translatedPos = sk_FragCoord.xy - %s.xy;\n float width = %s.z - %s.x;\n "
|
||||
|
@ -130,7 +130,6 @@ public:
|
||||
fUniformHandles.push_back(args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag,
|
||||
this->uniformType(v->fType),
|
||||
kDefault_GrSLPrecision,
|
||||
SkSL::String(v->fName).c_str()));
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
(void)colorSpaceMatrix;
|
||||
fColorSpaceMatrixVar =
|
||||
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4x4_GrSLType,
|
||||
kDefault_GrSLPrecision, "colorSpaceMatrix");
|
||||
"colorSpaceMatrix");
|
||||
|
||||
int numSamplers = args.fTexSamplers.count();
|
||||
|
||||
|
@ -27,7 +27,6 @@ bool valid_name(const char* name) {
|
||||
GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray(
|
||||
uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
bool mangleName,
|
||||
int arrayCount,
|
||||
@ -35,7 +34,6 @@ GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray(
|
||||
SkASSERT(name && strlen(name));
|
||||
SkASSERT(valid_name(name));
|
||||
SkASSERT(0 != visibility);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeTemporarilyAcceptsPrecision(type));
|
||||
|
||||
UniformInfo& uni = fUniforms.push_back();
|
||||
uni.fVariable.setType(type);
|
||||
@ -53,7 +51,6 @@ GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray(
|
||||
fProgramBuilder->nameVariable(uni.fVariable.accessName(), prefix, name, mangleName);
|
||||
uni.fVariable.setArrayCount(arrayCount);
|
||||
uni.fVisibility = visibility;
|
||||
uni.fVariable.setPrecision(precision);
|
||||
uni.fLocation = -1;
|
||||
|
||||
if (outName) {
|
||||
@ -72,14 +69,12 @@ GrGLSLUniformHandler::SamplerHandle GrGLUniformHandler::addSampler(const GrTextu
|
||||
char prefix = 'u';
|
||||
fProgramBuilder->nameVariable(&mangleName, prefix, name, true);
|
||||
|
||||
GrSLPrecision precision = GrSLSamplerPrecision(texture->config());
|
||||
GrSwizzle swizzle = shaderCaps->configTextureSwizzle(texture->config());
|
||||
GrTextureType type = texture->texturePriv().textureType();
|
||||
|
||||
UniformInfo& sampler = fSamplers.push_back();
|
||||
sampler.fVariable.setType(GrSLCombinedSamplerTypeForTextureType(type));
|
||||
sampler.fVariable.setTypeModifier(GrShaderVar::kUniform_TypeModifier);
|
||||
sampler.fVariable.setPrecision(precision);
|
||||
sampler.fVariable.setName(mangleName);
|
||||
sampler.fLocation = -1;
|
||||
sampler.fVisibility = kFragment_GrShaderFlag;
|
||||
|
@ -33,7 +33,6 @@ private:
|
||||
|
||||
UniformHandle internalAddUniformArray(uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
bool mangleName,
|
||||
int arrayCount,
|
||||
|
@ -353,18 +353,16 @@ void GrGLSLProgramBuilder::addRTWidthUniform(const char* name) {
|
||||
SkASSERT(!fUniformHandles.fRTWidthUni.isValid());
|
||||
GrGLSLUniformHandler* uniformHandler = this->uniformHandler();
|
||||
fUniformHandles.fRTWidthUni =
|
||||
uniformHandler->internalAddUniformArray(kFragment_GrShaderFlag,
|
||||
kHalf_GrSLType, kDefault_GrSLPrecision,
|
||||
name, false, 0, nullptr);
|
||||
uniformHandler->internalAddUniformArray(kFragment_GrShaderFlag, kHalf_GrSLType, name,
|
||||
false, 0, nullptr);
|
||||
}
|
||||
|
||||
void GrGLSLProgramBuilder::addRTHeightUniform(const char* name) {
|
||||
SkASSERT(!fUniformHandles.fRTHeightUni.isValid());
|
||||
GrGLSLUniformHandler* uniformHandler = this->uniformHandler();
|
||||
fUniformHandles.fRTHeightUni =
|
||||
uniformHandler->internalAddUniformArray(kFragment_GrShaderFlag,
|
||||
kHalf_GrSLType, kDefault_GrSLPrecision,
|
||||
name, false, 0, nullptr);
|
||||
uniformHandler->internalAddUniformArray(kFragment_GrShaderFlag, kHalf_GrSLType, name,
|
||||
false, 0, nullptr);
|
||||
}
|
||||
|
||||
void GrGLSLProgramBuilder::finalizeShaders() {
|
||||
|
@ -45,30 +45,10 @@ public:
|
||||
to add an array of uniforms. */
|
||||
UniformHandle addUniform(uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
const char** outName = nullptr) {
|
||||
SkASSERT(!GrSLTypeIsCombinedSamplerType(type));
|
||||
return this->addUniformArray(visibility, type, precision, name, 0, outName);
|
||||
}
|
||||
|
||||
UniformHandle addUniform(uint32_t visibility,
|
||||
GrSLType type,
|
||||
const char* name,
|
||||
const char** outName = nullptr) {
|
||||
return this->addUniform(visibility, type, kDefault_GrSLPrecision, name, outName);
|
||||
}
|
||||
|
||||
UniformHandle addUniformArray(uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
int arrayCount,
|
||||
const char** outName = nullptr) {
|
||||
SkASSERT(!GrSLTypeIsCombinedSamplerType(type));
|
||||
bool mangle = strncmp(name, GR_NO_MANGLE_PREFIX, strlen(GR_NO_MANGLE_PREFIX));
|
||||
return this->internalAddUniformArray(visibility, type, precision, name, mangle, arrayCount,
|
||||
outName);
|
||||
return this->addUniformArray(visibility, type, name, 0, outName);
|
||||
}
|
||||
|
||||
UniformHandle addUniformArray(uint32_t visibility,
|
||||
@ -78,8 +58,7 @@ public:
|
||||
const char** outName = nullptr) {
|
||||
SkASSERT(!GrSLTypeIsCombinedSamplerType(type));
|
||||
bool mangle = strncmp(name, GR_NO_MANGLE_PREFIX, strlen(GR_NO_MANGLE_PREFIX));
|
||||
return this->internalAddUniformArray(visibility, type, kDefault_GrSLPrecision, name, mangle,
|
||||
arrayCount, outName);
|
||||
return this->internalAddUniformArray(visibility, type, name, mangle, arrayCount, outName);
|
||||
}
|
||||
|
||||
virtual const GrShaderVar& getUniformVariable(UniformHandle u) const = 0;
|
||||
@ -104,7 +83,6 @@ private:
|
||||
|
||||
virtual UniformHandle internalAddUniformArray(uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
bool mangleName,
|
||||
int arrayCount,
|
||||
|
@ -109,22 +109,21 @@ void GrGLSLVaryingHandler::finalize() {
|
||||
const char* modifier = v.fIsFlat ? "flat" : fDefaultInterpolationModifier;
|
||||
if (v.fVisibility & kVertex_GrShaderFlag) {
|
||||
fVertexOutputs.push_back().set(v.fType, v.fVsOut, GrShaderVar::kOut_TypeModifier,
|
||||
kDefault_GrSLPrecision, nullptr, modifier);
|
||||
nullptr, modifier);
|
||||
if (v.fVisibility & kGeometry_GrShaderFlag) {
|
||||
fGeomInputs.push_back().set(v.fType, v.fVsOut, GrShaderVar::kUnsizedArray,
|
||||
GrShaderVar::kIn_TypeModifier, kDefault_GrSLPrecision,
|
||||
nullptr, modifier);
|
||||
GrShaderVar::kIn_TypeModifier, nullptr, modifier);
|
||||
}
|
||||
}
|
||||
if (v.fVisibility & kFragment_GrShaderFlag) {
|
||||
const char* fsIn = v.fVsOut.c_str();
|
||||
if (v.fVisibility & kGeometry_GrShaderFlag) {
|
||||
fGeomOutputs.push_back().set(v.fType, v.fGsOut, GrShaderVar::kOut_TypeModifier,
|
||||
kDefault_GrSLPrecision, nullptr, modifier);
|
||||
nullptr, modifier);
|
||||
fsIn = v.fGsOut.c_str();
|
||||
}
|
||||
fFragInputs.push_back().set(v.fType, fsIn, GrShaderVar::kIn_TypeModifier,
|
||||
kDefault_GrSLPrecision, nullptr, modifier);
|
||||
fFragInputs.push_back().set(v.fType, fsIn, GrShaderVar::kIn_TypeModifier, nullptr,
|
||||
modifier);
|
||||
}
|
||||
}
|
||||
this->onFinalize();
|
||||
|
@ -30,11 +30,10 @@ public:
|
||||
(void)makePremul;
|
||||
auto colorsAreOpaque = _outer.colorsAreOpaque();
|
||||
(void)colorsAreOpaque;
|
||||
fLeftBorderColorVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kHalf4_GrSLType, kDefault_GrSLPrecision, "leftBorderColor");
|
||||
fRightBorderColorVar =
|
||||
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType,
|
||||
kDefault_GrSLPrecision, "rightBorderColor");
|
||||
fLeftBorderColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kHalf4_GrSLType, "leftBorderColor");
|
||||
fRightBorderColorVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kHalf4_GrSLType, "rightBorderColor");
|
||||
SkString _child1("_child1");
|
||||
this->emitChild(_outer.gradLayout_index(), &_child1, args);
|
||||
fragBuilder->codeAppendf(
|
||||
|
@ -34,15 +34,15 @@ public:
|
||||
auto threshold = _outer.threshold();
|
||||
(void)threshold;
|
||||
fScale01Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
kDefault_GrSLPrecision, "scale01");
|
||||
"scale01");
|
||||
fBias01Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
kDefault_GrSLPrecision, "bias01");
|
||||
"bias01");
|
||||
fScale23Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
kDefault_GrSLPrecision, "scale23");
|
||||
"scale23");
|
||||
fBias23Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
kDefault_GrSLPrecision, "bias23");
|
||||
"bias23");
|
||||
fThresholdVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
|
||||
kDefault_GrSLPrecision, "threshold");
|
||||
"threshold");
|
||||
fragBuilder->codeAppendf(
|
||||
"half t = %s.x;\nfloat4 scale, bias;\nif (t < %s) {\n scale = %s;\n bias = "
|
||||
"%s;\n} else {\n scale = %s;\n bias = %s;\n}\n%s = half4(float(t) * scale + "
|
||||
|
@ -27,10 +27,9 @@ public:
|
||||
(void)start;
|
||||
auto end = _outer.end();
|
||||
(void)end;
|
||||
fStartVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType,
|
||||
kDefault_GrSLPrecision, "start");
|
||||
fEndVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType,
|
||||
kDefault_GrSLPrecision, "end");
|
||||
fStartVar =
|
||||
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "start");
|
||||
fEndVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "end");
|
||||
fragBuilder->codeAppendf("half t = %s.x;\n%s = (1.0 - t) * %s + t * %s;\n",
|
||||
args.fInputColor, args.fOutputColor,
|
||||
args.fUniformHandler->getUniformCStr(fStartVar),
|
||||
|
@ -28,10 +28,9 @@ public:
|
||||
(void)bias;
|
||||
auto scale = _outer.scale();
|
||||
(void)scale;
|
||||
fBiasVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
|
||||
kDefault_GrSLPrecision, "bias");
|
||||
fScaleVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
|
||||
kDefault_GrSLPrecision, "scale");
|
||||
fBiasVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType, "bias");
|
||||
fScaleVar =
|
||||
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType, "scale");
|
||||
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
|
||||
fragBuilder->codeAppendf(
|
||||
"half angle;\nif (sk_Caps.atan2ImplementedAsAtanYOverX) {\n angle = half(2.0 * "
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
auto focalParams = _outer.focalParams();
|
||||
(void)focalParams;
|
||||
fFocalParamsVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf2_GrSLType,
|
||||
kDefault_GrSLPrecision, "focalParams");
|
||||
"focalParams");
|
||||
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
|
||||
fragBuilder->codeAppendf(
|
||||
"float2 p = %s;\nfloat t = -1.0;\nhalf v = 1.0;\n@switch (%d) {\n case 1:\n "
|
||||
|
@ -62,69 +62,69 @@ public:
|
||||
auto thresholds9_13 = _outer.thresholds9_13();
|
||||
(void)thresholds9_13;
|
||||
fScale0_1Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
kDefault_GrSLPrecision, "scale0_1");
|
||||
"scale0_1");
|
||||
if (intervalCount > 1) {
|
||||
fScale2_3Var = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat4_GrSLType, kDefault_GrSLPrecision, "scale2_3");
|
||||
fScale2_3Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "scale2_3");
|
||||
}
|
||||
if (intervalCount > 2) {
|
||||
fScale4_5Var = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat4_GrSLType, kDefault_GrSLPrecision, "scale4_5");
|
||||
fScale4_5Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "scale4_5");
|
||||
}
|
||||
if (intervalCount > 3) {
|
||||
fScale6_7Var = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat4_GrSLType, kDefault_GrSLPrecision, "scale6_7");
|
||||
fScale6_7Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "scale6_7");
|
||||
}
|
||||
if (intervalCount > 4) {
|
||||
fScale8_9Var = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat4_GrSLType, kDefault_GrSLPrecision, "scale8_9");
|
||||
fScale8_9Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "scale8_9");
|
||||
}
|
||||
if (intervalCount > 5) {
|
||||
fScale10_11Var = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat4_GrSLType, kDefault_GrSLPrecision, "scale10_11");
|
||||
fScale10_11Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "scale10_11");
|
||||
}
|
||||
if (intervalCount > 6) {
|
||||
fScale12_13Var = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat4_GrSLType, kDefault_GrSLPrecision, "scale12_13");
|
||||
fScale12_13Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "scale12_13");
|
||||
}
|
||||
if (intervalCount > 7) {
|
||||
fScale14_15Var = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat4_GrSLType, kDefault_GrSLPrecision, "scale14_15");
|
||||
fScale14_15Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "scale14_15");
|
||||
}
|
||||
fBias0_1Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
kDefault_GrSLPrecision, "bias0_1");
|
||||
"bias0_1");
|
||||
if (intervalCount > 1) {
|
||||
fBias2_3Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
kDefault_GrSLPrecision, "bias2_3");
|
||||
"bias2_3");
|
||||
}
|
||||
if (intervalCount > 2) {
|
||||
fBias4_5Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
kDefault_GrSLPrecision, "bias4_5");
|
||||
"bias4_5");
|
||||
}
|
||||
if (intervalCount > 3) {
|
||||
fBias6_7Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
kDefault_GrSLPrecision, "bias6_7");
|
||||
"bias6_7");
|
||||
}
|
||||
if (intervalCount > 4) {
|
||||
fBias8_9Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
kDefault_GrSLPrecision, "bias8_9");
|
||||
"bias8_9");
|
||||
}
|
||||
if (intervalCount > 5) {
|
||||
fBias10_11Var = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat4_GrSLType, kDefault_GrSLPrecision, "bias10_11");
|
||||
fBias10_11Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "bias10_11");
|
||||
}
|
||||
if (intervalCount > 6) {
|
||||
fBias12_13Var = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat4_GrSLType, kDefault_GrSLPrecision, "bias12_13");
|
||||
fBias12_13Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "bias12_13");
|
||||
}
|
||||
if (intervalCount > 7) {
|
||||
fBias14_15Var = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat4_GrSLType, kDefault_GrSLPrecision, "bias14_15");
|
||||
fBias14_15Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "bias14_15");
|
||||
}
|
||||
fThresholds1_7Var = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kHalf4_GrSLType, kDefault_GrSLPrecision, "thresholds1_7");
|
||||
fThresholds9_13Var = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kHalf4_GrSLType, kDefault_GrSLPrecision, "thresholds9_13");
|
||||
fThresholds1_7Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kHalf4_GrSLType, "thresholds1_7");
|
||||
fThresholds9_13Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kHalf4_GrSLType, "thresholds9_13");
|
||||
fragBuilder->codeAppendf(
|
||||
"half t = %s.x;\nfloat4 scale, bias;\nif (%d <= 4 || t < %s.w) {\n if (%d <= 2 "
|
||||
"|| t < %s.y) {\n if (%d <= 1 || t < %s.x) {\n scale = %s;\n "
|
||||
|
@ -55,7 +55,6 @@ private:
|
||||
|
||||
UniformHandle internalAddUniformArray(uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
bool mangleName,
|
||||
int arrayCount,
|
||||
|
@ -199,7 +199,6 @@ static void get_ubo_aligned_offset(uint32_t* uniformOffset,
|
||||
GrGLSLUniformHandler::UniformHandle GrMtlUniformHandler::internalAddUniformArray(
|
||||
uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
bool mangleName,
|
||||
int arrayCount,
|
||||
@ -211,7 +210,6 @@ GrGLSLUniformHandler::UniformHandle GrMtlUniformHandler::internalAddUniformArray
|
||||
kGeometry_GrShaderFlag == visibility ||
|
||||
(kVertex_GrShaderFlag | kGeometry_GrShaderFlag) == visibility ||
|
||||
kFragment_GrShaderFlag == visibility);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
|
||||
GrSLTypeIsFloatType(type);
|
||||
|
||||
UniformInfo& uni = fUniforms.push_back();
|
||||
@ -229,7 +227,6 @@ GrGLSLUniformHandler::UniformHandle GrMtlUniformHandler::internalAddUniformArray
|
||||
fProgramBuilder->nameVariable(uni.fVariable.accessName(), prefix, name, mangleName);
|
||||
uni.fVariable.setArrayCount(arrayCount);
|
||||
uni.fVisibility = visibility;
|
||||
uni.fVariable.setPrecision(precision);
|
||||
// When outputing the GLSL, only the outer uniform block will get the Uniform modifier. Thus
|
||||
// we set the modifier to none for all uniforms declared inside the block.
|
||||
uni.fVariable.setTypeModifier(GrShaderVar::kNone_TypeModifier);
|
||||
@ -267,14 +264,12 @@ GrGLSLUniformHandler::SamplerHandle GrMtlUniformHandler::addSampler(const GrText
|
||||
char prefix = 'u';
|
||||
fProgramBuilder->nameVariable(&mangleName, prefix, name, true);
|
||||
|
||||
GrSLPrecision precision = GrSLSamplerPrecision(texture->config());
|
||||
GrSwizzle swizzle = caps->configTextureSwizzle(texture->config());
|
||||
GrTextureType type = texture->texturePriv().textureType();
|
||||
|
||||
UniformInfo& info = fSamplers.push_back();
|
||||
info.fVariable.setType(GrSLCombinedSamplerTypeForTextureType(type));
|
||||
info.fVariable.setTypeModifier(GrShaderVar::kUniform_TypeModifier);
|
||||
info.fVariable.setPrecision(precision);
|
||||
info.fVariable.setName(mangleName);
|
||||
SkString layoutQualifier;
|
||||
layoutQualifier.appendf("binding=%d", fSamplers.count() - 1);
|
||||
|
@ -203,7 +203,6 @@ static void get_ubo_aligned_offset(uint32_t* uniformOffset,
|
||||
GrGLSLUniformHandler::UniformHandle GrVkUniformHandler::internalAddUniformArray(
|
||||
uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
bool mangleName,
|
||||
int arrayCount,
|
||||
@ -215,7 +214,6 @@ GrGLSLUniformHandler::UniformHandle GrVkUniformHandler::internalAddUniformArray(
|
||||
kGeometry_GrShaderFlag == visibility ||
|
||||
(kVertex_GrShaderFlag | kGeometry_GrShaderFlag) == visibility ||
|
||||
kFragment_GrShaderFlag == visibility);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
|
||||
GrSLTypeIsFloatType(type);
|
||||
|
||||
UniformInfo& uni = fUniforms.push_back();
|
||||
@ -233,7 +231,6 @@ GrGLSLUniformHandler::UniformHandle GrVkUniformHandler::internalAddUniformArray(
|
||||
fProgramBuilder->nameVariable(uni.fVariable.accessName(), prefix, name, mangleName);
|
||||
uni.fVariable.setArrayCount(arrayCount);
|
||||
uni.fVisibility = visibility;
|
||||
uni.fVariable.setPrecision(precision);
|
||||
// When outputing the GLSL, only the outer uniform block will get the Uniform modifier. Thus
|
||||
// we set the modifier to none for all uniforms declared inside the block.
|
||||
uni.fVariable.setTypeModifier(GrShaderVar::kNone_TypeModifier);
|
||||
@ -268,14 +265,12 @@ GrGLSLUniformHandler::SamplerHandle GrVkUniformHandler::addSampler(const GrTextu
|
||||
char prefix = 'u';
|
||||
fProgramBuilder->nameVariable(&mangleName, prefix, name, true);
|
||||
|
||||
GrSLPrecision precision = GrSLSamplerPrecision(texture->config());
|
||||
GrSwizzle swizzle = shaderCaps->configTextureSwizzle(texture->config());
|
||||
GrTextureType type = texture->texturePriv().textureType();
|
||||
|
||||
UniformInfo& info = fSamplers.push_back();
|
||||
info.fVariable.setType(GrSLCombinedSamplerTypeForTextureType(type));
|
||||
info.fVariable.setTypeModifier(GrShaderVar::kUniform_TypeModifier);
|
||||
info.fVariable.setPrecision(precision);
|
||||
info.fVariable.setName(mangleName);
|
||||
SkString layoutQualifier;
|
||||
layoutQualifier.appendf("set=%d, binding=%d", kSamplerDescSet, fSamplers.count() - 1);
|
||||
|
@ -64,7 +64,6 @@ private:
|
||||
|
||||
UniformHandle internalAddUniformArray(uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
bool mangleName,
|
||||
int arrayCount,
|
||||
|
@ -150,22 +150,19 @@ private:
|
||||
fLightDirsUni = uniformHandler->addUniformArray(
|
||||
kFragment_GrShaderFlag,
|
||||
kFloat3_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"LightDir",
|
||||
lightingFP.fDirectionalLights.count(),
|
||||
&lightDirsUniName);
|
||||
fLightColorsUni = uniformHandler->addUniformArray(
|
||||
kFragment_GrShaderFlag,
|
||||
kFloat3_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"LightColor",
|
||||
lightingFP.fDirectionalLights.count(),
|
||||
&lightColorsUniName);
|
||||
}
|
||||
|
||||
const char* ambientColorUniName = nullptr;
|
||||
fAmbientColorUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat3_GrSLType, kDefault_GrSLPrecision,
|
||||
fAmbientColorUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kFloat3_GrSLType,
|
||||
"AmbientColor", &ambientColorUniName);
|
||||
|
||||
fragBuilder->codeAppendf("half4 diffuseColor = %s;", args.fInputColor);
|
||||
|
@ -534,16 +534,6 @@ void CPPCodeGenerator::addUniform(const Variable& var) {
|
||||
if (!needs_uniform_var(var)) {
|
||||
return;
|
||||
}
|
||||
const char* precision;
|
||||
if (var.fModifiers.fFlags & Modifiers::kHighp_Flag) {
|
||||
precision = "kHigh_GrSLPrecision";
|
||||
} else if (var.fModifiers.fFlags & Modifiers::kMediump_Flag) {
|
||||
precision = "kMedium_GrSLPrecision";
|
||||
} else if (var.fModifiers.fFlags & Modifiers::kLowp_Flag) {
|
||||
precision = "kLow_GrSLPrecision";
|
||||
} else {
|
||||
precision = "kDefault_GrSLPrecision";
|
||||
}
|
||||
const char* type;
|
||||
if (var.fType == *fContext.fFloat_Type) {
|
||||
type = "kFloat_GrSLType";
|
||||
@ -570,7 +560,7 @@ void CPPCodeGenerator::addUniform(const Variable& var) {
|
||||
}
|
||||
String name(var.fName);
|
||||
this->writef(" %sVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, %s, "
|
||||
"%s, \"%s\");\n", HCodeGenerator::FieldName(name.c_str()).c_str(), type, precision,
|
||||
"\"%s\");\n", HCodeGenerator::FieldName(name.c_str()).c_str(), type,
|
||||
name.c_str());
|
||||
if (var.fModifiers.fLayout.fWhen.size()) {
|
||||
this->write(" }\n");
|
||||
|
@ -24,11 +24,11 @@ public:
|
||||
, fNull_Type(new Type("null"))
|
||||
, fFloatLiteral_Type(new Type("$floatLiteral", Type::kFloat_NumberKind, 3))
|
||||
, fIntLiteral_Type(new Type("$intLiteral", Type::kSigned_NumberKind, 1))
|
||||
, fDouble_Type(new Type("double", Type::kFloat_NumberKind, 6))
|
||||
, fDouble_Type(new Type("double", Type::kFloat_NumberKind, 6, true))
|
||||
, fDouble2_Type(new Type("double2", *fDouble_Type, 2))
|
||||
, fDouble3_Type(new Type("double3", *fDouble_Type, 3))
|
||||
, fDouble4_Type(new Type("double4", *fDouble_Type, 4))
|
||||
, fFloat_Type(new Type("float", Type::kFloat_NumberKind, 5))
|
||||
, fFloat_Type(new Type("float", Type::kFloat_NumberKind, 5, true))
|
||||
, fFloat2_Type(new Type("float2", *fFloat_Type, 2))
|
||||
, fFloat3_Type(new Type("float3", *fFloat_Type, 3))
|
||||
, fFloat4_Type(new Type("float4", *fFloat_Type, 4))
|
||||
@ -36,11 +36,11 @@ public:
|
||||
, fHalf2_Type(new Type("half2", *fHalf_Type, 2))
|
||||
, fHalf3_Type(new Type("half3", *fHalf_Type, 3))
|
||||
, fHalf4_Type(new Type("half4", *fHalf_Type, 4))
|
||||
, fUInt_Type(new Type("uint", Type::kUnsigned_NumberKind, 2))
|
||||
, fUInt_Type(new Type("uint", Type::kUnsigned_NumberKind, 2, true))
|
||||
, fUInt2_Type(new Type("uint2", *fUInt_Type, 2))
|
||||
, fUInt3_Type(new Type("uint3", *fUInt_Type, 3))
|
||||
, fUInt4_Type(new Type("uint4", *fUInt_Type, 4))
|
||||
, fInt_Type(new Type("int", Type::kSigned_NumberKind, 2))
|
||||
, fInt_Type(new Type("int", Type::kSigned_NumberKind, 2, true))
|
||||
, fInt2_Type(new Type("int2", *fInt_Type, 2))
|
||||
, fInt3_Type(new Type("int3", *fInt_Type, 3))
|
||||
, fInt4_Type(new Type("int4", *fInt_Type, 4))
|
||||
|
@ -1140,16 +1140,24 @@ void GLSLCodeGenerator::writeModifiers(const Modifiers& modifiers,
|
||||
if (modifiers.fFlags & Modifiers::kPLSOut_Flag) {
|
||||
this->write("__pixel_local_outEXT ");
|
||||
}
|
||||
if (usesPrecisionModifiers()) {
|
||||
if (modifiers.fFlags & Modifiers::kLowp_Flag) {
|
||||
this->write("lowp ");
|
||||
}
|
||||
if (modifiers.fFlags & Modifiers::kMediump_Flag) {
|
||||
this->write("mediump ");
|
||||
}
|
||||
if (modifiers.fFlags & Modifiers::kHighp_Flag) {
|
||||
switch (modifiers.fLayout.fFormat) {
|
||||
case Layout::Format::kUnspecified:
|
||||
break;
|
||||
case Layout::Format::kRGBA32F: // fall through
|
||||
case Layout::Format::kR32F:
|
||||
this->write("highp ");
|
||||
}
|
||||
break;
|
||||
case Layout::Format::kRGBA16F: // fall through
|
||||
case Layout::Format::kR16F: // fall through
|
||||
case Layout::Format::kRG16F:
|
||||
this->write("mediump ");
|
||||
break;
|
||||
case Layout::Format::kRGBA8: // fall through
|
||||
case Layout::Format::kR8: // fall through
|
||||
case Layout::Format::kRGBA8I: // fall through
|
||||
case Layout::Format::kR8I:
|
||||
this->write("lowp ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1568,14 +1576,20 @@ bool GLSLCodeGenerator::generateCode() {
|
||||
Layout layout;
|
||||
switch (fProgram.fKind) {
|
||||
case Program::kVertex_Kind: {
|
||||
Modifiers modifiers(layout, Modifiers::kOut_Flag | Modifiers::kHighp_Flag);
|
||||
Modifiers modifiers(layout, Modifiers::kOut_Flag);
|
||||
this->writeModifiers(modifiers, true);
|
||||
if (this->usesPrecisionModifiers()) {
|
||||
this->write("highp ");
|
||||
}
|
||||
this->write("vec4 sk_FragCoord_Workaround;\n");
|
||||
break;
|
||||
}
|
||||
case Program::kFragment_Kind: {
|
||||
Modifiers modifiers(layout, Modifiers::kIn_Flag | Modifiers::kHighp_Flag);
|
||||
Modifiers modifiers(layout, Modifiers::kIn_Flag);
|
||||
this->writeModifiers(modifiers, true);
|
||||
if (this->usesPrecisionModifiers()) {
|
||||
this->write("highp ");
|
||||
}
|
||||
this->write("vec4 sk_FragCoord_Workaround;\n");
|
||||
break;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -65,12 +65,6 @@ struct Token {
|
||||
UNIFORM,
|
||||
#undef CONST
|
||||
CONST,
|
||||
#undef LOWP
|
||||
LOWP,
|
||||
#undef MEDIUMP
|
||||
MEDIUMP,
|
||||
#undef HIGHP
|
||||
HIGHP,
|
||||
#undef FLAT
|
||||
FLAT,
|
||||
#undef NOPERSPECTIVE
|
||||
|
@ -943,18 +943,6 @@ Modifiers Parser::modifiers() {
|
||||
flags |= Modifiers::kIn_Flag;
|
||||
flags |= Modifiers::kOut_Flag;
|
||||
break;
|
||||
case Token::LOWP:
|
||||
this->nextToken();
|
||||
flags |= Modifiers::kLowp_Flag;
|
||||
break;
|
||||
case Token::MEDIUMP:
|
||||
this->nextToken();
|
||||
flags |= Modifiers::kMediump_Flag;
|
||||
break;
|
||||
case Token::HIGHP:
|
||||
this->nextToken();
|
||||
flags |= Modifiers::kHighp_Flag;
|
||||
break;
|
||||
case Token::FLAT:
|
||||
this->nextToken();
|
||||
flags |= Modifiers::kFlat_Flag;
|
||||
@ -1047,10 +1035,7 @@ std::unique_ptr<ASTStatement> Parser::statement() {
|
||||
this->nextToken();
|
||||
return std::unique_ptr<ASTStatement>(new ASTBlock(start.fOffset,
|
||||
std::vector<std::unique_ptr<ASTStatement>>()));
|
||||
case Token::CONST: // fall through
|
||||
case Token::HIGHP: // fall through
|
||||
case Token::MEDIUMP: // fall through
|
||||
case Token::LOWP: {
|
||||
case Token::CONST: {
|
||||
auto decl = this->varDeclarations();
|
||||
if (!decl) {
|
||||
return nullptr;
|
||||
|
@ -1884,9 +1884,14 @@ SpvId SPIRVCodeGenerator::writeBinaryOperation(const Type& resultType,
|
||||
this->writeInstruction(ifUInt, this->getType(resultType), result, lhs, rhs, out);
|
||||
} else if (operandType == *fContext.fBool_Type) {
|
||||
this->writeInstruction(ifBool, this->getType(resultType), result, lhs, rhs, out);
|
||||
return result; // skip RelaxedPrecision check
|
||||
} else {
|
||||
ABORT("invalid operandType: %s", operandType.description().c_str());
|
||||
}
|
||||
if (resultType == operandType && !resultType.highPrecision()) {
|
||||
this->writeInstruction(SpvOpDecorate, result, SpvDecorationRelaxedPrecision,
|
||||
fDecorationBuffer);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2712,9 +2717,8 @@ SpvId SPIRVCodeGenerator::writeInterfaceBlock(const InterfaceBlock& intf) {
|
||||
return result;
|
||||
}
|
||||
|
||||
void SPIRVCodeGenerator::writePrecisionModifier(const Modifiers& modifiers, SpvId id) {
|
||||
if ((modifiers.fFlags & Modifiers::kLowp_Flag) |
|
||||
(modifiers.fFlags & Modifiers::kMediump_Flag)) {
|
||||
void SPIRVCodeGenerator::writePrecisionModifier(const Type& type, SpvId id) {
|
||||
if (!type.highPrecision()) {
|
||||
this->writeInstruction(SpvOpDecorate, id, SpvDecorationRelaxedPrecision, fDecorationBuffer);
|
||||
}
|
||||
}
|
||||
@ -2778,7 +2782,7 @@ void SPIRVCodeGenerator::writeGlobalVars(Program::Kind kind, const VarDeclaratio
|
||||
}
|
||||
this->writeInstruction(SpvOpVariable, type, id, storageClass, fConstantBuffer);
|
||||
this->writeInstruction(SpvOpName, id, var->fName, fNameBuffer);
|
||||
this->writePrecisionModifier(var->fModifiers, id);
|
||||
this->writePrecisionModifier(var->fType, id);
|
||||
if (varDecl.fValue) {
|
||||
SkASSERT(!fCurrentBlock);
|
||||
fCurrentBlock = -1;
|
||||
|
@ -120,7 +120,7 @@ private:
|
||||
SpvId getPointerType(const Type& type, const MemoryLayout& layout,
|
||||
SpvStorageClass_ storageClass);
|
||||
|
||||
void writePrecisionModifier(const Modifiers& modifiers, SpvId id);
|
||||
void writePrecisionModifier(const Type& type, SpvId id);
|
||||
|
||||
std::vector<SpvId> getAccessChain(const Expression& expr, OutputStream& out);
|
||||
|
||||
|
@ -21,22 +21,19 @@ struct Modifiers {
|
||||
kConst_Flag = 1 << 0,
|
||||
kIn_Flag = 1 << 1,
|
||||
kOut_Flag = 1 << 2,
|
||||
kLowp_Flag = 1 << 3,
|
||||
kMediump_Flag = 1 << 4,
|
||||
kHighp_Flag = 1 << 5,
|
||||
kUniform_Flag = 1 << 6,
|
||||
kFlat_Flag = 1 << 7,
|
||||
kNoPerspective_Flag = 1 << 8,
|
||||
kReadOnly_Flag = 1 << 9,
|
||||
kWriteOnly_Flag = 1 << 10,
|
||||
kCoherent_Flag = 1 << 11,
|
||||
kVolatile_Flag = 1 << 12,
|
||||
kRestrict_Flag = 1 << 13,
|
||||
kBuffer_Flag = 1 << 14,
|
||||
kHasSideEffects_Flag = 1 << 15,
|
||||
kPLS_Flag = 1 << 16,
|
||||
kPLSIn_Flag = 1 << 17,
|
||||
kPLSOut_Flag = 1 << 18,
|
||||
kUniform_Flag = 1 << 3,
|
||||
kFlat_Flag = 1 << 4,
|
||||
kNoPerspective_Flag = 1 << 5,
|
||||
kReadOnly_Flag = 1 << 6,
|
||||
kWriteOnly_Flag = 1 << 7,
|
||||
kCoherent_Flag = 1 << 8,
|
||||
kVolatile_Flag = 1 << 9,
|
||||
kRestrict_Flag = 1 << 10,
|
||||
kBuffer_Flag = 1 << 11,
|
||||
kHasSideEffects_Flag = 1 << 12,
|
||||
kPLS_Flag = 1 << 13,
|
||||
kPLSIn_Flag = 1 << 14,
|
||||
kPLSOut_Flag = 1 << 15,
|
||||
};
|
||||
|
||||
Modifiers()
|
||||
@ -55,15 +52,6 @@ struct Modifiers {
|
||||
if (fFlags & kConst_Flag) {
|
||||
result += "const ";
|
||||
}
|
||||
if (fFlags & kLowp_Flag) {
|
||||
result += "lowp ";
|
||||
}
|
||||
if (fFlags & kMediump_Flag) {
|
||||
result += "mediump ";
|
||||
}
|
||||
if (fFlags & kHighp_Flag) {
|
||||
result += "highp ";
|
||||
}
|
||||
if (fFlags & kFlat_Flag) {
|
||||
result += "flat ";
|
||||
}
|
||||
|
@ -116,14 +116,15 @@ public:
|
||||
}
|
||||
|
||||
// Create a scalar type.
|
||||
Type(const char* name, NumberKind numberKind, int priority)
|
||||
Type(const char* name, NumberKind numberKind, int priority, bool highPrecision = false)
|
||||
: INHERITED(-1, kType_Kind, StringFragment())
|
||||
, fNameString(name)
|
||||
, fTypeKind(kScalar_Kind)
|
||||
, fNumberKind(numberKind)
|
||||
, fPriority(priority)
|
||||
, fColumns(1)
|
||||
, fRows(1) {
|
||||
, fRows(1)
|
||||
, fHighPrecision(highPrecision) {
|
||||
fName.fChars = fNameString.c_str();
|
||||
fName.fLength = fNameString.size();
|
||||
}
|
||||
@ -372,6 +373,13 @@ public:
|
||||
return fIsSampled;
|
||||
}
|
||||
|
||||
bool highPrecision() const {
|
||||
if (fComponentType) {
|
||||
return fComponentType->highPrecision();
|
||||
}
|
||||
return fHighPrecision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the corresponding vector or matrix type with the specified number of columns and
|
||||
* rows.
|
||||
@ -396,6 +404,7 @@ private:
|
||||
bool fIsArrayed = false;
|
||||
bool fIsMultisampled = false;
|
||||
bool fIsSampled = false;
|
||||
bool fHighPrecision = false;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
@ -22,9 +22,6 @@ OUT = "out"
|
||||
INOUT = "inout"
|
||||
UNIFORM = "uniform"
|
||||
CONST = "const"
|
||||
LOWP = "lowp"
|
||||
MEDIUMP = "mediump"
|
||||
HIGHP = "highp"
|
||||
FLAT = "flat"
|
||||
NOPERSPECTIVE = "noperspective"
|
||||
READONLY = "readonly"
|
||||
|
@ -177,7 +177,7 @@ DEF_TEST(SkSLFPUniform, r) {
|
||||
},
|
||||
{
|
||||
"fColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "
|
||||
"kDefault_GrSLPrecision, \"color\");",
|
||||
"\"color\");",
|
||||
});
|
||||
}
|
||||
|
||||
@ -196,7 +196,7 @@ DEF_TEST(SkSLFPInUniform, r) {
|
||||
},
|
||||
{
|
||||
"fColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "
|
||||
"kDefault_GrSLPrecision, \"color\");",
|
||||
"\"color\");",
|
||||
"pdman.set4fv(fColorVar, 1, reinterpret_cast<const float*>(&(_outer.color())));"
|
||||
});
|
||||
}
|
||||
@ -214,7 +214,7 @@ DEF_TEST(SkSLFPInUniformCType, r) {
|
||||
},
|
||||
{
|
||||
"fColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "
|
||||
"kDefault_GrSLPrecision, \"color\");",
|
||||
"\"color\");",
|
||||
"pdman.set4fv(fColorVar, 1, (_outer.color()).vec());"
|
||||
});
|
||||
}
|
||||
@ -235,7 +235,7 @@ DEF_TEST(SkSLFPTrackedInUniform, r) {
|
||||
{
|
||||
"SkRect fColorPrev = SkRect::MakeEmpty();",
|
||||
"fColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "
|
||||
"kDefault_GrSLPrecision, \"color\");",
|
||||
"\"color\");",
|
||||
"const SkRect& colorValue = _outer.color();",
|
||||
"if (fColorPrev.isEmpty() || fColorPrev != colorValue) {",
|
||||
"fColorPrev = colorValue;",
|
||||
@ -257,7 +257,7 @@ DEF_TEST(SkSLFPNonInlinedInUniform, r) {
|
||||
},
|
||||
{
|
||||
"fPointVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf2_GrSLType, "
|
||||
"kDefault_GrSLPrecision, \"point\");",
|
||||
"\"point\");",
|
||||
"const SkPoint& pointValue = _outer.point();",
|
||||
"pdman.set2f(fPointVar, pointValue.fX, pointValue.fY);"
|
||||
});
|
||||
@ -285,7 +285,7 @@ DEF_TEST(SkSLFPConditionalInUniform, r) {
|
||||
"auto test = _outer.test();",
|
||||
"if (test) {",
|
||||
"fColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "
|
||||
"kDefault_GrSLPrecision, \"color\");",
|
||||
"\"color\");",
|
||||
"if (fColorVar.isValid()) {",
|
||||
"const SkPMColor4f& colorValue = _outer.color();",
|
||||
"if (fColorPrev != colorValue) {",
|
||||
|
Loading…
Reference in New Issue
Block a user