Add a few more SkRuntimeEffect unit tests
Validating that only certain types are allowed as in or uniform. Change-Id: I941da448bffec06158e67fbf653833846d9fe3db Reviewed-on: https://skia-review.googlesource.com/c/skia/+/262222 Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
7165ca9fc5
commit
8783b78b38
@ -120,6 +120,32 @@ SkRuntimeEffect::EffectResult SkRuntimeEffect::Make(SkString sksl) {
|
||||
|
||||
#undef SET_TYPES
|
||||
|
||||
switch (v.fType) {
|
||||
case Variable::Type::kBool:
|
||||
case Variable::Type::kInt:
|
||||
if (v.fQualifier == Variable::Qualifier::kUniform) {
|
||||
RETURN_FAILURE("'uniform' variables may not have '%s' type",
|
||||
type->displayName().c_str());
|
||||
}
|
||||
break;
|
||||
|
||||
case Variable::Type::kFloat:
|
||||
// Floats can be 'in' or 'uniform'
|
||||
break;
|
||||
|
||||
case Variable::Type::kFloat2:
|
||||
case Variable::Type::kFloat3:
|
||||
case Variable::Type::kFloat4:
|
||||
case Variable::Type::kFloat2x2:
|
||||
case Variable::Type::kFloat3x3:
|
||||
case Variable::Type::kFloat4x4:
|
||||
if (v.fQualifier == Variable::Qualifier::kIn) {
|
||||
RETURN_FAILURE("'in' variables may not have '%s' type",
|
||||
type->displayName().c_str());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (v.fType != Variable::Type::kBool) {
|
||||
offset = SkAlign4(offset);
|
||||
}
|
||||
|
@ -31,4 +31,14 @@ DEF_TEST(SkRuntimeEffectInvalidInputs, r) {
|
||||
|
||||
// 'in' variables can't be arrays
|
||||
test("in int Input[2];", "array");
|
||||
|
||||
// Type specific restrictions:
|
||||
|
||||
// 'bool', 'int' can't be 'uniform'
|
||||
test("uniform bool Input;", "'uniform'");
|
||||
test("uniform int Input;", "'uniform'");
|
||||
|
||||
// vector and matrix types can't be 'in'
|
||||
test("in float2 Input;", "'in'");
|
||||
test("in half3x3 Input;", "'in'");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user