diff --git a/src/freedreno/vulkan/tu_common.h b/src/freedreno/vulkan/tu_common.h index 48ec6505191..7056b578144 100644 --- a/src/freedreno/vulkan/tu_common.h +++ b/src/freedreno/vulkan/tu_common.h @@ -17,6 +17,7 @@ #include #include #include +#include #ifdef HAVE_VALGRIND #include #include @@ -132,24 +133,30 @@ #define TU_FROM_HANDLE(__tu_type, __name, __handle) \ VK_FROM_HANDLE(__tu_type, __name, __handle) -#define ACT_0(ACTION) -#define ACT_1(ACTION, X) ACTION(X) -#define ACT_2(ACTION, X, ...) ACTION(X) ACT_1(ACTION, __VA_ARGS__) -#define ACT_3(ACTION, X, ...) ACTION(X) ACT_2(ACTION, __VA_ARGS__) -#define ACT_4(ACTION, X, ...) ACTION(X) ACT_3(ACTION, __VA_ARGS__) -#define ACT_5(ACTION, X, ...) ACTION(X) ACT_4(ACTION, __VA_ARGS__) -#define ACT_6(ACTION, X, ...) ACTION(X) ACT_5(ACTION, __VA_ARGS__) - -#define GET_ACT_MACRO(_0, _1, _2, _3, _4, _5, _6, NAME, ...) NAME - -/* Do the action for the each vararg. It could be macro, function call, etc. */ -#define ACTION_FOR_EACH(action, ...) \ - GET_ACT_MACRO(_0, __VA_ARGS__, ACT_6, ACT_5, ACT_4, ACT_3, ACT_2, ACT_1, ACT_0) \ - (action, __VA_ARGS__) - #define TU_GPU_GENS A6XX, A7XX -#define TU_GENX(entrypoint) \ - ACTION_FOR_EACH(entrypoint ## _GENS, TU_GPU_GENS) +#define TU_GENX(FUNC_NAME) \ + template constexpr auto FUNC_NAME##instantiate() \ + { \ + return std::tuple_cat(std::make_tuple(FUNC_NAME)...); \ + } \ + static constexpr auto FUNC_NAME##tmpl __attribute__((used)) = \ + FUNC_NAME##instantiate(); + +#define TU_CALLX(device, thing) \ + ({ \ + decltype(&thing) genX_thing; \ + switch ((device)->physical_device->info->chip) { \ + case 6: \ + genX_thing = &thing; \ + break; \ + case 7: \ + genX_thing = &thing; \ + break; \ + default: \ + unreachable("Unknown hardware generation"); \ + } \ + genX_thing; \ + }) /* vk object types */ struct tu_buffer;