Reduced skslc memory consumption

The big change here is smarter generic type handling which allows us to
keep far fewer entries in the core symboltable. This also comments out
a number of OpenGL builtin functions which Skia does not use and is
unlikely to in the future.
BUG=655673
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2442063002

Review-Url: https://codereview.chromium.org/2442063002
This commit is contained in:
ethannicholas 2016-10-27 08:15:50 -07:00 committed by Commit bot
parent 7929e3ae76
commit cffaa70896
9 changed files with 180 additions and 116 deletions

View File

@ -19,7 +19,8 @@ namespace SkSL {
class Context {
public:
Context()
: fVoid_Type(new Type("void"))
: fInvalid_Type(new Type("<INVALID>"))
, fVoid_Type(new Type("void"))
, fDouble_Type(new Type("double", true))
, fDVec2_Type(new Type("dvec2", *fDouble_Type, 2))
, fDVec3_Type(new Type("dvec3", *fDouble_Type, 3))
@ -104,24 +105,27 @@ public:
, fGenBType_Type(new Type("$genBType", { fBool_Type.get(), fBVec2_Type.get(), fBVec3_Type.get(),
fBVec4_Type.get() }))
, fMat_Type(new Type("$mat"))
, fVec_Type(new Type("$vec", { fVec2_Type.get(), fVec2_Type.get(), fVec3_Type.get(),
, fVec_Type(new Type("$vec", { fInvalid_Type.get(), fVec2_Type.get(), fVec3_Type.get(),
fVec4_Type.get() }))
, fGVec_Type(new Type("$gvec"))
, fGVec2_Type(new Type("$gvec2"))
, fGVec3_Type(new Type("$gvec3"))
, fGVec4_Type(new Type("$gvec4", static_type(*fVec4_Type)))
, fDVec_Type(new Type("$dvec"))
, fIVec_Type(new Type("$ivec"))
, fUVec_Type(new Type("$uvec"))
, fBVec_Type(new Type("$bvec", { fBVec2_Type.get(), fBVec2_Type.get(), fBVec3_Type.get(),
, fDVec_Type(new Type("$dvec", { fInvalid_Type.get(), fDVec2_Type.get(), fDVec3_Type.get(),
fDVec4_Type.get() }))
, fIVec_Type(new Type("$ivec", { fInvalid_Type.get(), fIVec2_Type.get(), fIVec3_Type.get(),
fIVec4_Type.get() }))
, fUVec_Type(new Type("$uvec", { fInvalid_Type.get(), fUVec2_Type.get(), fUVec3_Type.get(),
fUVec4_Type.get() }))
, fBVec_Type(new Type("$bvec", { fInvalid_Type.get(), fBVec2_Type.get(), fBVec3_Type.get(),
fBVec4_Type.get() }))
, fInvalid_Type(new Type("<INVALID>"))
, fDefined_Expression(new Defined(*fInvalid_Type)) {}
static std::vector<const Type*> static_type(const Type& t) {
return { &t, &t, &t, &t };
}
const std::unique_ptr<Type> fInvalid_Type;
const std::unique_ptr<Type> fVoid_Type;
const std::unique_ptr<Type> fDouble_Type;
@ -223,8 +227,6 @@ public:
const std::unique_ptr<Type> fBVec_Type;
const std::unique_ptr<Type> fInvalid_Type;
// dummy expression used to mark that a variable has a value during dataflow analysis (when it
// could have several different values, or the analyzer is otherwise unable to assign it a
// specific expression)

View File

@ -371,40 +371,11 @@ std::unique_ptr<Statement> IRGenerator::convertDiscard(const ASTDiscardStatement
return std::unique_ptr<Statement>(new DiscardStatement(d.fPosition));
}
static const Type& expand_generics(const Type& type, int i) {
if (type.kind() == Type::kGeneric_Kind) {
return *type.coercibleTypes()[i];
}
return type;
}
static void expand_generics(const FunctionDeclaration& decl,
std::shared_ptr<SymbolTable> symbolTable) {
for (int i = 0; i < 4; i++) {
const Type& returnType = expand_generics(decl.fReturnType, i);
std::vector<const Variable*> parameters;
for (const auto& p : decl.fParameters) {
Variable* var = new Variable(p->fPosition, Modifiers(p->fModifiers), p->fName,
expand_generics(p->fType, i),
Variable::kParameter_Storage);
symbolTable->takeOwnership(var);
parameters.push_back(var);
}
symbolTable->add(decl.fName, std::unique_ptr<FunctionDeclaration>(new FunctionDeclaration(
decl.fPosition,
decl.fName,
std::move(parameters),
std::move(returnType))));
}
}
std::unique_ptr<FunctionDefinition> IRGenerator::convertFunction(const ASTFunction& f) {
bool isGeneric;
const Type* returnType = this->convertType(*f.fReturnType);
if (!returnType) {
return nullptr;
}
isGeneric = returnType->kind() == Type::kGeneric_Kind;
std::vector<const Variable*> parameters;
for (const auto& param : f.fParameters) {
const Type* type = this->convertType(*param->fType);
@ -425,7 +396,6 @@ std::unique_ptr<FunctionDefinition> IRGenerator::convertFunction(const ASTFuncti
Variable::kParameter_Storage);
fSymbolTable->takeOwnership(var);
parameters.push_back(var);
isGeneric |= type->kind() == Type::kGeneric_Kind;
}
// find existing declaration
@ -483,19 +453,12 @@ std::unique_ptr<FunctionDefinition> IRGenerator::convertFunction(const ASTFuncti
}
if (!decl) {
// couldn't find an existing declaration
if (isGeneric) {
ASSERT(!f.fBody);
expand_generics(FunctionDeclaration(f.fPosition, f.fName, parameters, *returnType),
fSymbolTable);
} else {
auto newDecl = std::unique_ptr<FunctionDeclaration>(new FunctionDeclaration(
f.fPosition,
f.fName,
parameters,
*returnType));
decl = newDecl.get();
fSymbolTable->add(decl->fName, std::move(newDecl));
}
auto newDecl = std::unique_ptr<FunctionDeclaration>(new FunctionDeclaration(f.fPosition,
f.fName,
parameters,
*returnType));
decl = newDecl.get();
fSymbolTable->add(decl->fName, std::move(newDecl));
}
if (f.fBody) {
ASSERT(!fCurrentFunction);
@ -915,8 +878,22 @@ std::unique_ptr<Expression> IRGenerator::call(Position position,
fErrors.error(position, msg);
return nullptr;
}
std::vector<const Type*> types;
const Type* returnType;
if (!function.determineFinalTypes(arguments, &types, &returnType)) {
std::string msg = "no match for " + function.fName + "(";
std::string separator = "";
for (size_t i = 0; i < arguments.size(); i++) {
msg += separator;
separator = ", ";
msg += arguments[i]->fType.description();
}
msg += ")";
fErrors.error(position, msg);
return nullptr;
}
for (size_t i = 0; i < arguments.size(); i++) {
arguments[i] = this->coerce(std::move(arguments[i]), function.fParameters[i]->fType);
arguments[i] = this->coerce(std::move(arguments[i]), *types[i]);
if (!arguments[i]) {
return nullptr;
}
@ -924,7 +901,7 @@ std::unique_ptr<Expression> IRGenerator::call(Position position,
this->markWrittenTo(*arguments[i]);
}
}
return std::unique_ptr<FunctionCall>(new FunctionCall(position, function,
return std::unique_ptr<FunctionCall>(new FunctionCall(position, *returnType, function,
std::move(arguments)));
}
@ -940,9 +917,14 @@ bool IRGenerator::determineCallCost(const FunctionDeclaration& function,
return false;
}
int total = 0;
std::vector<const Type*> types;
const Type* ignored;
if (!function.determineFinalTypes(arguments, &types, &ignored)) {
return false;
}
for (size_t i = 0; i < arguments.size(); i++) {
int cost;
if (arguments[i]->fType.determineCoercionCost(function.fParameters[i]->fType, &cost)) {
if (arguments[i]->fType.determineCoercionCost(*types[i], &cost)) {
total += cost;
} else {
return false;

View File

@ -132,9 +132,18 @@ Token Parser::nextToken() {
return result;
}
int token = sksllex(fScanner);
return Token(Position(skslget_lineno(fScanner), -1), (Token::Kind) token,
token == Token::END_OF_FILE ? "<end of file>" :
std::string(skslget_text(fScanner)));
std::string text;
switch ((Token::Kind) token) {
case Token::IDENTIFIER: // fall through
case Token::INT_LITERAL: // fall through
case Token::FLOAT_LITERAL: // fall through
case Token::DIRECTIVE:
text = std::string(skslget_text(fScanner));
break;
default:
break;
}
return Token(Position(skslget_lineno(fScanner), -1), (Token::Kind) token, text);
}
void Parser::pushback(Token t) {

View File

@ -157,6 +157,8 @@ struct Token {
Position fPosition;
Kind fKind;
// will be the empty string unless the token has variable text content (identifiers, numeric
// literals, and directives)
std::string fText;
};

View File

@ -17,9 +17,9 @@ namespace SkSL {
* A function invocation.
*/
struct FunctionCall : public Expression {
FunctionCall(Position position, const FunctionDeclaration& function,
FunctionCall(Position position, const Type& type, const FunctionDeclaration& function,
std::vector<std::unique_ptr<Expression>> arguments)
: INHERITED(position, kFunctionCall_Kind, function.fReturnType)
: INHERITED(position, kFunctionCall_Kind, type)
, fFunction(std::move(function))
, fArguments(std::move(arguments)) {}

View File

@ -8,6 +8,7 @@
#ifndef SKSL_FUNCTIONDECLARATION
#define SKSL_FUNCTIONDECLARATION
#include "SkSLExpression.h"
#include "SkSLModifiers.h"
#include "SkSLSymbol.h"
#include "SkSLSymbolTable.h"
@ -55,6 +56,50 @@ struct FunctionDeclaration : public Symbol {
return true;
}
/**
* Determine the effective types of this function's parameters and return value when called with
* the given arguments. This is relevant for functions with generic parameter types, where this
* will collapse the generic types down into specific concrete types.
*
* Returns true if it was able to select a concrete set of types for the generic function, false
* if there is no possible way this can match the argument types. Note that even a true return
* does not guarantee that the function can be successfully called with those arguments, merely
* indicates that an attempt should be made. If false is returned, the state of
* outParameterTypes and outReturnType are undefined.
*/
bool determineFinalTypes(const std::vector<std::unique_ptr<Expression>>& arguments,
std::vector<const Type*>* outParameterTypes,
const Type** outReturnType) const {
assert(arguments.size() == fParameters.size());
int genericIndex = -1;
for (size_t i = 0; i < arguments.size(); i++) {
if (fParameters[i]->fType.kind() == Type::kGeneric_Kind) {
std::vector<const Type*> types = fParameters[i]->fType.coercibleTypes();
if (genericIndex == -1) {
for (size_t j = 0; j < types.size(); j++) {
if (arguments[i]->fType.canCoerceTo(*types[j])) {
genericIndex = j;
break;
}
}
if (genericIndex == -1) {
return false;
}
}
outParameterTypes->push_back(types[genericIndex]);
} else {
outParameterTypes->push_back(&fParameters[i]->fType);
}
}
if (fReturnType.kind() == Type::kGeneric_Kind) {
assert(genericIndex != -1);
*outReturnType = fReturnType.coercibleTypes()[genericIndex];
} else {
*outReturnType = &fReturnType;
}
return true;
}
mutable bool fDefined;
bool fBuiltin;
const std::vector<const Variable*> fParameters;

View File

@ -57,7 +57,9 @@ public:
: INHERITED(Position(), kType_Kind, std::move(name))
, fTypeKind(kOther_Kind) {}
// Create a generic type which maps to the listed types.
// Create a generic type which maps to the listed types. As currently implemented, there are
// always exactly four coercion targets, mapping to the scalar, vec2, vec3, and vec4 versions of
// a type.
Type(std::string name, std::vector<const Type*> types)
: INHERITED(Position(), kType_Kind, std::move(name))
, fTypeKind(kGeneric_Kind)

View File

@ -22,88 +22,88 @@ $genType log($genType x);
$genType exp2($genType x);
$genType log2($genType x);
$genType sqrt($genType x);
$genDType sqrt($genDType x);
//$genDType sqrt($genDType x);
$genType inversesqrt($genType x);
$genDType inversesqrt($genDType x);
//$genDType inversesqrt($genDType x);
$genType abs($genType x);
$genIType abs($genIType x);
$genDType abs($genDType x);
//$genDType abs($genDType x);
$genType sign($genType x);
$genIType sign($genIType x);
$genDType sign($genDType x);
//$genDType sign($genDType x);
$genType floor($genType x);
$genDType floor($genDType x);
//$genDType floor($genDType x);
$genType trunc($genType x);
$genDType trunc($genDType x);
//$genDType trunc($genDType x);
$genType round($genType x);
$genDType round($genDType x);
//$genDType round($genDType x);
$genType roundEven($genType x);
$genDType roundEven($genDType x);
//$genDType roundEven($genDType x);
$genType ceil($genType x);
$genDType ceil($genDType x);
//$genDType ceil($genDType x);
$genType fract($genType x);
$genDType fract($genDType x);
//$genDType fract($genDType x);
$genType mod($genType x, float y);
$genType mod($genType x, $genType y);
$genDType mod($genDType x, double y);
$genDType mod($genDType x, $genDType y);
//$genDType mod($genDType x, double y);
//$genDType mod($genDType x, $genDType y);
$genType modf($genType x, out $genType i);
$genDType modf($genDType x, out $genDType i);
//$genDType modf($genDType x, out $genDType i);
$genType min($genType x, $genType y);
$genType min($genType x, float y);
$genDType min($genDType x, $genDType y);
$genDType min($genDType x, double y);
//$genDType min($genDType x, $genDType y);
//$genDType min($genDType x, double y);
$genIType min($genIType x, $genIType y);
$genIType min($genIType x, int y);
$genUType min($genUType x, $genUType y);
$genUType min($genUType x, uint y);
//$genUType min($genUType x, $genUType y);
//$genUType min($genUType x, uint y);
$genType max($genType x, $genType y);
$genType max($genType x, float y);
$genDType max($genDType x, $genDType y);
$genDType max($genDType x, double y);
//$genDType max($genDType x, $genDType y);
//$genDType max($genDType x, double y);
$genIType max($genIType x, $genIType y);
$genIType max($genIType x, int y);
$genUType max($genUType x, $genUType y);
$genUType max($genUType x, uint y);
//$genUType max($genUType x, $genUType y);
//$genUType max($genUType x, uint y);
$genType clamp($genType x, $genType minVal, $genType maxVal);
$genType clamp($genType x, float minVal, float maxVal);
$genDType clamp($genDType x, $genDType minVal, $genDType maxVal);
$genDType clamp($genDType x, double minVal, double maxVal);
//$genDType clamp($genDType x, $genDType minVal, $genDType maxVal);
//$genDType clamp($genDType x, double minVal, double maxVal);
$genIType clamp($genIType x, $genIType minVal, $genIType maxVal);
$genIType clamp($genIType x, int minVal, int maxVal);
$genUType clamp($genUType x, $genUType minVal, $genUType maxVal);
$genUType clamp($genUType x, uint minVal, uint maxVal);
//$genUType clamp($genUType x, $genUType minVal, $genUType maxVal);
//$genUType clamp($genUType x, uint minVal, uint maxVal);
$genType mix($genType x, $genType y, $genType a);
$genType mix($genType x, $genType y, float a);
$genDType mix($genDType x, $genDType y, $genDType a);
$genDType mix($genDType x, $genDType y, double a);
//$genDType mix($genDType x, $genDType y, $genDType a);
//$genDType mix($genDType x, $genDType y, double a);
$genType mix($genType x, $genType y, $genBType a);
$genDType mix($genDType x, $genDType y, $genBType a);
//$genDType mix($genDType x, $genDType y, $genBType a);
$genIType mix($genIType x, $genIType y, $genBType a);
$genUType mix($genUType x, $genUType y, $genBType a);
//$genUType mix($genUType x, $genUType y, $genBType a);
$genBType mix($genBType x, $genBType y, $genBType a);
$genType step($genType edge, $genType x);
$genType step(float edge, $genType x);
$genDType step($genDType edge, $genDType x);
$genDType step(double edge, $genDType x);
//$genDType step($genDType edge, $genDType x);
//$genDType step(double edge, $genDType x);
$genType smoothstep($genType edge0, $genType edge1, $genType x);
$genType smoothstep(float edge0, float edge1, $genType x);
$genDType smoothstep($genDType edge0, $genDType edge1, $genDType x);
$genDType smoothstep(double edge0, double edge1, $genDType x);
//$genDType smoothstep($genDType edge0, $genDType edge1, $genDType x);
//$genDType smoothstep(double edge0, double edge1, $genDType x);
$genBType isnan($genType x);
$genBType isnan($genDType x);
$genBType isinf($genType x);
$genBType isinf($genDType x);
$genIType floatBitsToInt($genType value);
$genUType floatBitsToUint($genType value);
//$genUType floatBitsToUint($genType value);
$genType intBitsToFloat($genIType value);
$genType uintBitsToFloat($genUType value);
$genType fma($genType a, $genType b, $genType c);
$genDType fma($genDType a, $genDType b, $genDType c);
//$genDType fma($genDType a, $genDType b, $genDType c);
$genType frexp($genType x, out $genIType exp);
$genDType frexp($genDType x, out $genIType exp);
//$genDType frexp($genDType x, out $genIType exp);
$genType ldexp($genType x, in $genIType exp);
$genDType ldexp($genDType x, in $genIType exp);
//$genDType ldexp($genDType x, in $genIType exp);
uint packUnorm2x16(vec2 v);
uint packSnorm2x16(vec2 v);
uint packUnorm4x8(vec4 v);
@ -112,27 +112,27 @@ vec2 unpackUnorm2x16(uint p);
vec2 unpackSnorm2x16(uint p);
vec4 unpackUnorm4x8(uint p);
vec4 unpackSnorm4x8(uint p);
double packDouble2x32(uvec2 v);
//double packDouble2x32(uvec2 v);
uvec2 unpackDouble2x32(double v);
uint packHalf2x16(vec2 v);
vec2 unpackHalf2x16(uint v);
float length($genType x);
double length($genDType x);
//double length($genDType x);
float distance($genType p0, $genType p1);
double distance($genDType p0, $genDType p1);
//double distance($genDType p0, $genDType p1);
float dot($genType x, $genType y);
double dot($genDType x, $genDType y);
//double dot($genDType x, $genDType y);
vec3 cross(vec3 x, vec3 y);
dvec3 cross(dvec3 x, dvec3 y);
//dvec3 cross(dvec3 x, dvec3 y);
$genType normalize($genType x);
$genDType normalize($genDType x);
//$genDType normalize($genDType x);
vec4 ftransform();
$genType faceforward($genType N, $genType I, $genType Nref);
$genDType faceforward($genDType N, $genDType I, $genDType Nref);
//$genDType faceforward($genDType N, $genDType I, $genDType Nref);
$genType reflect($genType I, $genType N);
$genDType reflect($genDType I, $genDType N);
//$genDType reflect($genDType I, $genDType N);
$genType refract($genType I, $genType N, float eta);
$genDType refract($genDType I, $genDType N, float eta);
//$genDType refract($genDType I, $genDType N, float eta);
$mat matrixCompMult($mat x, $mat y);
mat2 outerProduct(vec2 c, vec2 r);
mat3 outerProduct(vec3 c, vec3 r);
@ -181,16 +181,18 @@ $bvec notEqual($bvec x, $bvec y);
bool any($bvec x);
bool all($bvec x);
$bvec not($bvec x);
$genUType uaddCarry($genUType x, $genUType y, out $genUType carry);
$genUType usubBorrow($genUType x, $genUType y, out $genUType borrow);
/*
//$genUType uaddCarry($genUType x, $genUType y, out $genUType carry);
//$genUType usubBorrow($genUType x, $genUType y, out $genUType borrow);
void umulExtended($genUType x, $genUType y, out $genUType msb, out $genUType lsb);
void imulExtended($genIType x, $genIType y, out $genIType msb, out $genIType lsb);
$genIType bitfieldExtract($genIType value, int offset, int bits);
$genUType bitfieldExtract($genUType value, int offset, int bits);
//$genUType bitfieldExtract($genUType value, int offset, int bits);
$genIType bitfieldInsert($genIType base, $genIType insert, int offset, int bits);
$genUType bitfieldInsert($genUType base, $genUType insert, int offset, int bits);
//$genUType bitfieldInsert($genUType base, $genUType insert, int offset, int bits);
$genIType bitfieldReverse($genIType value);
$genUType bitfieldReverse($genUType value);
//$genUType bitfieldReverse($genUType value);
$genIType bitCount($genIType value);
$genIType bitCount($genUType value);
$genIType findLSB($genIType value);
@ -206,7 +208,9 @@ ivec2 textureSize(sampler2DShadow sampler, int lod);
ivec2 textureSize(samplerCubeShadow sampler, int lod);
ivec3 textureSize($gsamplerCubeArray sampler, int lod);
ivec3 textureSize(samplerCubeArrayShadow sampler, int lod);
*/
ivec2 textureSize($gsampler2DRect sampler);
/*
ivec2 textureSize(sampler2DRectShadow sampler);
ivec2 textureSize($gsampler1DArray sampler, int lod);
ivec3 textureSize($gsampler2DArray sampler, int lod);
@ -241,11 +245,15 @@ int textureQueryLevels(samplerCubeShadow sampler);
int textureQueryLevels(sampler1DArrayShadow sampler);
int textureQueryLevels(sampler2DArrayShadow sampler);
int textureQueryLevels(samplerCubeArrayShadow sampler);
*/
$gvec4 texture($gsampler1D sampler, float P);
$gvec4 texture($gsampler1D sampler, float P, float bias);
$gvec4 texture($gsampler2D sampler, vec2 P);
vec4 texture(samplerExternalOES sampler, vec2 P, float bias);
vec4 texture(samplerExternalOES sampler, vec2 P);
/*
$gvec4 texture($gsampler2D sampler, vec2 P, float bias);
$gvec4 texture($gsampler3D sampler, vec3 P);
$gvec4 texture($gsampler3D sampler, vec3 P, float bias);
@ -266,10 +274,14 @@ $gvec4 texture($gsamplerCubeArray sampler, vec4 P, float bias);
float texture(sampler1DArrayShadow sampler, vec3 P);
float texture(sampler1DArrayShadow sampler, vec3 P, float bias);
float texture(sampler2DArrayShadow sampler, vec4 P);
*/
$gvec4 texture($gsampler2DRect sampler, vec2 P);
/*
float texture(sampler2DRectShadow sampler, vec3 P);
float texture($gsamplerCubeArrayShadow sampler, vec4 P, float compare);
*/
)
// split into multiple chunks, as MSVC++ complains if a single string is too long
@ -284,6 +296,7 @@ $gvec4 textureProj($gsampler2D sampler, vec3 P);
$gvec4 textureProj($gsampler2D sampler, vec3 P, float bias);
$gvec4 textureProj($gsampler2D sampler, vec4 P);
$gvec4 textureProj($gsampler2D sampler, vec4 P, float bias);
/*
$gvec4 textureProj($gsampler3D sampler, vec4 P);
$gvec4 textureProj($gsampler3D sampler, vec4 P, float bias);
float textureProj(sampler1DShadow sampler, vec4 P);
@ -445,7 +458,6 @@ $gvec4 textureGatherOffset($gsampler2DRect sampler, vec2 P, ivec2 offset, int co
vec4 textureGatherOffset(sampler2DShadow sampler, vec2 P, float refZ, ivec2 offset);
vec4 textureGatherOffset(sampler2DArrayShadow sampler, vec3 P, float refZ, ivec2 offset);
vec4 textureGatherOffset(sampler2DRectShadow sampler, vec2 P, float refZ, ivec2 offset);
/*
$gvec4 textureGatherOffsets($gsampler2D sampler, vec2 P, ivec2 offsets[4]);
$gvec4 textureGatherOffsets($gsampler2D sampler, vec2 P, ivec2 offsets[4], int comp);
$gvec4 textureGatherOffsets($gsampler2DArray sampler, vec3 P, ivec2 offsets[4]);
@ -458,6 +470,7 @@ vec4 textureGatherOffsets(sampler2DRectShadow sampler, vec2 P, float refZ, ivec2
*/
vec4 texture1D(sampler1D sampler, float coord);
vec4 texture1D(sampler1D sampler, float coord, float bias);
/*
vec4 texture1DProj(sampler1D sampler, vec2 coord);
vec4 texture1DProj(sampler1D sampler, vec2 coord, float bias);
vec4 texture1DProj(sampler1D sampler, vec4 coord);
@ -465,9 +478,11 @@ vec4 texture1DProj(sampler1D sampler, vec4 coord, float bias);
vec4 texture1DLod(sampler1D sampler, float coord, float lod);
vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod);
vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod);
*/
vec4 texture2D(sampler2D sampler, vec2 coord);
vec4 texture2D(samplerExternalOES sampler, vec2 coord);
vec4 texture2D(sampler2D sampler, vec2 coord, float bias);
/*
vec4 texture2DProj(sampler2D sampler, vec3 coord);
vec4 texture2DProj(sampler2D sampler, vec3 coord, float bias);
vec4 texture2DProj(sampler2D sampler, vec4 coord);
@ -496,7 +511,6 @@ vec4 shadow1DLod(sampler1DShadow sampler, vec3 coord, float lod);
vec4 shadow2DLod(sampler2DShadow sampler, vec3 coord, float lod);
vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod);
vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod);
/*
uint atomicCounterIncrement(atomic_uint c);
uint atomicCounter(atomic_uint c);
uint atomicAdd(inout uint mem, uint data);
@ -520,6 +534,8 @@ int atomicCompSwap(inout int mem, int compare, int data);
$genType dFdx($genType p);
$genType dFdy($genType p);
/*
$genType fwidth($genType p);
$genType fwidthCoarse($genType p);
$genType fwidthFine($genType p);
@ -542,6 +558,7 @@ void memoryBarrierBuffer();
void memoryBarrierShared();
void memoryBarrierImage();
void groupMemoryBarrier();
*/
)

View File

@ -43,7 +43,12 @@ DEF_TEST(SkSLUndefinedFunction, r) {
DEF_TEST(SkSLGenericArgumentMismatch, r) {
test_failure(r,
"void main() { float x = sin(1, 2); }",
"error: 1: no match for sin(int, int)\n1 error\n");
"error: 1: call to 'sin' expected 1 argument, but found 2\n1 error\n");
test_failure(r,
"void main() { float x = sin(true); }",
"error: 1: no match for sin(bool)\n1 error\n");
test_success(r,
"void main() { float x = sin(1); }");
}
DEF_TEST(SkSLArgumentCountMismatch, r) {