Add Metal support for degrees() and radians() intrinsics.
Change-Id: I4a483c455c9a12c92b717a0c2713d32ab44dcd6f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/343099 Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
0063a9fa0e
commit
e2d34f8ebf
@ -45,11 +45,13 @@ void MetalCodeGenerator::setupIntrinsics() {
|
||||
fIntrinsicMap[String("floatBitsToUint")] = SPECIAL(Bitcast);
|
||||
fIntrinsicMap[String("intBitsToFloat")] = SPECIAL(Bitcast);
|
||||
fIntrinsicMap[String("uintBitsToFloat")] = SPECIAL(Bitcast);
|
||||
fIntrinsicMap[String("degrees")] = SPECIAL(Degrees);
|
||||
fIntrinsicMap[String("distance")] = SPECIAL(Distance);
|
||||
fIntrinsicMap[String("dot")] = SPECIAL(Dot);
|
||||
fIntrinsicMap[String("length")] = SPECIAL(Length);
|
||||
fIntrinsicMap[String("mod")] = SPECIAL(Mod);
|
||||
fIntrinsicMap[String("normalize")] = SPECIAL(Normalize);
|
||||
fIntrinsicMap[String("radians")] = SPECIAL(Radians);
|
||||
fIntrinsicMap[String("sample")] = SPECIAL(Texture);
|
||||
fIntrinsicMap[String("equal")] = METAL(Equal);
|
||||
fIntrinsicMap[String("notEqual")] = METAL(NotEqual);
|
||||
@ -636,6 +638,18 @@ void MetalCodeGenerator::writeSpecialIntrinsic(const FunctionCall & c, SpecialIn
|
||||
this->write(")");
|
||||
break;
|
||||
}
|
||||
case kDegrees_SpecialIntrinsic: {
|
||||
this->write("((");
|
||||
this->writeExpression(*arguments[0], kSequence_Precedence);
|
||||
this->write(") * 57.2957795)");
|
||||
break;
|
||||
}
|
||||
case kRadians_SpecialIntrinsic: {
|
||||
this->write("((");
|
||||
this->writeExpression(*arguments[0], kSequence_Precedence);
|
||||
this->write(") * 0.0174532925)");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ABORT("unsupported special intrinsic kind");
|
||||
}
|
||||
|
@ -105,11 +105,13 @@ protected:
|
||||
|
||||
enum SpecialIntrinsic {
|
||||
kBitcast_SpecialIntrinsic,
|
||||
kDegrees_SpecialIntrinsic,
|
||||
kDistance_SpecialIntrinsic,
|
||||
kDot_SpecialIntrinsic,
|
||||
kLength_SpecialIntrinsic,
|
||||
kMod_SpecialIntrinsic,
|
||||
kNormalize_SpecialIntrinsic,
|
||||
kRadians_SpecialIntrinsic,
|
||||
kTexture_SpecialIntrinsic,
|
||||
};
|
||||
|
||||
|
@ -11,6 +11,6 @@ struct Outputs {
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
_out->sk_FragColor.x = degrees(_in.a);
|
||||
_out->sk_FragColor.x = ((_in.a) * 57.2957795);
|
||||
return *_out;
|
||||
}
|
||||
|
@ -11,6 +11,6 @@ struct Outputs {
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
_out->sk_FragColor.x = radians(_in.a);
|
||||
_out->sk_FragColor.x = ((_in.a) * 0.0174532925);
|
||||
return *_out;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user