SkSL: Support bitwise negation on unsigned integers
Change-Id: I5558891882923b4e554a8b97a87da6bc4386b645 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/243817 Commit-Queue: Brian Osman <brianosman@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Auto-Submit: Brian Osman <brianosman@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
parent
4524e84a74
commit
73fb39c9b0
@ -2082,7 +2082,7 @@ std::unique_ptr<Expression> IRGenerator::convertPrefixExpression(const ASTNode&
|
||||
}
|
||||
break;
|
||||
case Token::BITWISENOT:
|
||||
if (base->fType != *fContext.fInt_Type) {
|
||||
if (base->fType != *fContext.fInt_Type && base->fType != *fContext.fUInt_Type) {
|
||||
fErrors.error(expression.fOffset,
|
||||
String("'") + Compiler::OperatorName(expression.getToken().fKind) +
|
||||
"' cannot operate on '" + base->fType.description() + "'");
|
||||
|
@ -247,6 +247,15 @@ DEF_TEST(SkSLInterpreterBitwise, r) {
|
||||
test(r, "void main(inout half4 color) { color.r = half(~int(color.r) & 3); }",
|
||||
6, 0, 0, 0, 1, 0, 0, 0);
|
||||
|
||||
test(r, "void main(inout half4 color) { color.r = half(uint(color.r) | 3); }",
|
||||
5, 0, 0, 0, 7, 0, 0, 0);
|
||||
test(r, "void main(inout half4 color) { color.r = half(uint(color.r) & 3); }",
|
||||
6, 0, 0, 0, 2, 0, 0, 0);
|
||||
test(r, "void main(inout half4 color) { color.r = half(uint(color.r) ^ 3); }",
|
||||
5, 0, 0, 0, 6, 0, 0, 0);
|
||||
test(r, "void main(inout half4 color) { color.r = half(~uint(color.r) & 3); }",
|
||||
6, 0, 0, 0, 1, 0, 0, 0);
|
||||
|
||||
// Shift operators
|
||||
unsigned in = 0x80000011;
|
||||
unsigned out;
|
||||
|
Loading…
Reference in New Issue
Block a user