6#include "core/reflect.h"
20#define VKM_ASSET_KINDS(X) \
21 X(Mesh, MeshAsset, "mesh", "meshes") \
22 X(Texture, TextureAsset, "texture", "textures") \
23 X(Material, MaterialAsset, "material", "materials") \
24 X(Skeleton, SkeletonAsset, "skeleton", "skeletons") \
25 X(AnimationClip, AnimationClipAsset, "animationClip", "clips") \
26 X(AudioClip, AudioClipAsset, "audioClip", "sounds")
34#define VKM_ASSET_ENUMERATOR(tag, type, name, dir) tag,
35enum class AssetType : uint8_t {
36 VKM_ASSET_KINDS(VKM_ASSET_ENUMERATOR)
40#undef VKM_ASSET_ENUMERATOR
42#define VKM_ASSET_FORWARD_DECL(tag, type, name, dir) struct type;
43VKM_ASSET_KINDS(VKM_ASSET_FORWARD_DECL)
44#undef VKM_ASSET_FORWARD_DECL
52inline constexpr AssetType ASSET_DEPENDENCY_ORDER[] = {
56 AssetType::AnimationClip,
63constexpr bool everyKindOrderedOnce() {
64 for (
size_t kind = 0; kind < static_cast<size_t>(AssetType::Count); ++kind) {
66 for (
const AssetType type : ASSET_DEPENDENCY_ORDER) seen +=
static_cast<size_t>(type) == kind ? 1 : 0;
67 if (seen != 1)
return false;
69 return sizeof(ASSET_DEPENDENCY_ORDER) /
sizeof(AssetType) ==
static_cast<size_t>(AssetType::Count);
71static_assert(everyKindOrderedOnce(),
"each VKM_ASSET_KINDS row needs one place in ASSET_DEPENDENCY_ORDER");
81template<
typename Asset>
82inline constexpr AssetType ASSET_TYPE = AssetType::Count;
84#define VKM_ASSET_TRAIT(tag, type, name, dir) \
85 template<> inline constexpr AssetType ASSET_TYPE<type> = AssetType::tag;
86VKM_ASSET_KINDS(VKM_ASSET_TRAIT)
91#define VKM_ASSET_NAME(tag, type, name, dir) name,
92VKM_ENUM_NAMES(::Vkm::Engine::AssetType, VKM_ASSET_KINDS(VKM_ASSET_NAME))