mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 06:58:05 +02:00
tu/common: Generalize TU_GENX macro
Now it doesn't require generated macro. Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23217>
This commit is contained in:
parent
7a01325200
commit
e19272a7a2
1 changed files with 24 additions and 17 deletions
|
|
@ -17,6 +17,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <tuple>
|
||||
#ifdef HAVE_VALGRIND
|
||||
#include <memcheck.h>
|
||||
#include <valgrind.h>
|
||||
|
|
@ -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 <chip... CHIPs> constexpr auto FUNC_NAME##instantiate() \
|
||||
{ \
|
||||
return std::tuple_cat(std::make_tuple(FUNC_NAME<CHIPs>)...); \
|
||||
} \
|
||||
static constexpr auto FUNC_NAME##tmpl __attribute__((used)) = \
|
||||
FUNC_NAME##instantiate<TU_GPU_GENS>();
|
||||
|
||||
#define TU_CALLX(device, thing) \
|
||||
({ \
|
||||
decltype(&thing<A6XX>) genX_thing; \
|
||||
switch ((device)->physical_device->info->chip) { \
|
||||
case 6: \
|
||||
genX_thing = &thing<A6XX>; \
|
||||
break; \
|
||||
case 7: \
|
||||
genX_thing = &thing<A7XX>; \
|
||||
break; \
|
||||
default: \
|
||||
unreachable("Unknown hardware generation"); \
|
||||
} \
|
||||
genX_thing; \
|
||||
})
|
||||
|
||||
/* vk object types */
|
||||
struct tu_buffer;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue