Commit b7dad7d7 by Antonio Maiorano

Reactor: add test for external call to routine

Tests calling an external function that, itself, calls back into a Reactor-generated routine. Bug: b/142132927 Change-Id: I5d89000d4c23804b211aec67d5b7a36778245eba Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/37270Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com> Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 29ba7a01
......@@ -1237,7 +1237,54 @@ TEST(ReactorUnitTests, Call)
EXPECT_EQ(c.f, 20.0f);
}
}
}
TEST(ReactorUnitTests, CallExternalCallRoutine)
{
if (!rr::Caps.CallSupported)
{
SUCCEED() << "rr::Call() not supported";
return;
}
// routine1 calls Class::Func, passing it a pointer to routine2, and Class::Func calls routine2
auto routine2 = [] {
Function<Float(Float, Int)> function;
{
Float a = function.Arg<0>();
Int b = function.Arg<1>();
Return(a + Float(b));
}
return function("two");
}();
struct Class
{
static float Func(void* p, float a, int b)
{
auto funcToCall = reinterpret_cast<float(*)(float, int)>(p);
return funcToCall(a, b);
}
};
auto routine1 = [] {
Function<Float(Pointer<Byte>, Float, Int)> function;
{
Pointer<Byte> funcToCall = function.Arg<0>();
Float a = function.Arg<1>();
Int b = function.Arg<2>();
Float result = Call(Class::Func, funcToCall, a, b);
Return(result);
}
return function("one");
}();
auto callable2 = (float(*)(float, int))routine2->getEntry();
auto callable1 = (float(*)(void*, float, int))routine1->getEntry();
float result = callable1((void*)callable2, 12.f, 13);
EXPECT_EQ(result, 25.f);
}
// Check that a complex generated function which utilizes all 8 or 16 XMM
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment