-
Notifications
You must be signed in to change notification settings - Fork 6
Allow passthrough for no-op intercepts #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Still needs testing, and would like some performance numbers from a Mali timeline capture to see how much difference this really makes. |
|
This isn't working reliably - currently we're testing function pointer equality, but there is no guarantee that |
|
A standalone PoC for how to do this without altering the layer-provided code at all. We can use #include <cstdio>
#include <type_traits>
using FunctionPtr = void (*)();
struct default_tag {};
struct user_tag {};
// Force delete the match-all implementation
template<class T>
void demo() = delete;
// Default implementation
template<> void demo<default_tag>()
{
printf("default_tag\n");
}
#if 0
// User implementation
template<> void demo<user_tag>()
{
printf("user_tag\n");
}
#endif
// Helper to detect if specialization <T> exists
template<class T>
concept has_demo = requires { demo<T>(); };
// Function to return the suitable function pointer
consteval FunctionPtr getPointer(void)
{
// Wrap in a template to allow constexpr to not complain about the if body
// if demo<T> doesn't exist.
return [] <typename T> {
if constexpr(has_demo<T>)
{
return demo<T>;
}
return demo<default_tag>;
}.operator()<user_tag>();
}
int main(void)
{
auto* function = getPointer();
function();
return 0;
} |
|
No it doesn't ... Clang++ 18 allows Both allow resolution using a callable rather than a raw name resolution ( |
|
Android test seems to show that this reduces the added CPU overhead of the timeline layer by ~25%. |
Prior to this PR, layers would intercept all Vulkan functions, routing through a dummy pass-through implementation in a layer if it did not provide a more specialized implementation to actually do something. This obviously has a runtime cost in terms of additional dispatch indirection.
With this PR the layer now only intercepts functions that either have a required implementation in the layer framework itself, or that have a
<user_tag>specialization provided by the specific layer being built. This dispatch optimization is optional and, although on by default, can still be disabled because it is useful to intercept everything for API tracing and support investigations.This PR also makes existing config options for tracing and logging CMake options that can be set dynamically at configure time.
Fixes #14.