Fix frexp support in Metal.
Our Metal codegen assumes that out params are pointers, but Metal's built-in frexp actually takes a reference for the exponent, not a pointer. We now add in a helper function to translate. Change-Id: I24686347d07151dd99a1ff1c43aff2b35c3181e5 Bug: skia:10762 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/328387 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
bb9769fb21
commit
a80a3dc170
@ -305,9 +305,9 @@ sksl_settings_tests = [
|
||||
"$_tests/sksl/glsl/TypePrecision.sksl",
|
||||
"$_tests/sksl/inliner/InlinerCanBeDisabled.sksl",
|
||||
"$_tests/sksl/inliner/InlinerWrapsEarlyReturnsWithDoWhileBlock.sksl",
|
||||
"$_tests/sksl/shared/CrossIntrinsic.sksl",
|
||||
"$_tests/sksl/shared/Derivatives.sksl",
|
||||
"$_tests/sksl/shared/DerivativesFlipY.sksl",
|
||||
"$_tests/sksl/shared/CrossIntrinsic.sksl",
|
||||
"$_tests/sksl/workarounds/AbsInt.sksl",
|
||||
"$_tests/sksl/workarounds/BlendGuardedDivide.sksl",
|
||||
"$_tests/sksl/workarounds/BlendModesAllZeroVec.sksl",
|
||||
|
@ -228,6 +228,17 @@ void MetalCodeGenerator::writeFunctionCall(const FunctionCall& c) {
|
||||
} else if (builtin && name == "inverse") {
|
||||
SkASSERT(arguments.size() == 1);
|
||||
this->writeInverseHack(*arguments[0]);
|
||||
} else if (builtin && name == "frexp") {
|
||||
// Our Metal codegen assumes that out params are pointers, but Metal's built-in frexp
|
||||
// actually takes a reference for the exponent, not a pointer. We add in a helper function
|
||||
// here to translate.
|
||||
SkASSERT(arguments.size() == 2);
|
||||
auto [iter, newlyCreated] = fHelpers.insert("frexp");
|
||||
if (newlyCreated) {
|
||||
fExtraFunctions.printf(
|
||||
"float frexp(float arg, thread int* exp) { return frexp(arg, *exp); }\n");
|
||||
}
|
||||
this->write("frexp");
|
||||
} else if (builtin && name == "dFdx") {
|
||||
this->write("dfdx");
|
||||
} else if (builtin && name == "dFdy") {
|
||||
|
@ -6,6 +6,7 @@ struct Inputs {
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
float frexp(float arg, thread int* exp) { return frexp(arg, *exp); }
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
|
Loading…
Reference in New Issue
Block a user