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") \
27 X(Terrain, TerrainAsset, "terrain", "terrains")
35#define VKM_ASSET_ENUMERATOR(tag, type, name, dir) tag,
36enum class AssetType : uint8_t {
37 VKM_ASSET_KINDS(VKM_ASSET_ENUMERATOR)
41#undef VKM_ASSET_ENUMERATOR
43#define VKM_ASSET_FORWARD_DECL(tag, type, name, dir) struct type;
44VKM_ASSET_KINDS(VKM_ASSET_FORWARD_DECL)
45#undef VKM_ASSET_FORWARD_DECL
54inline constexpr AssetType ASSET_DEPENDENCY_ORDER[] = {
58 AssetType::AnimationClip,
66constexpr bool everyKindOrderedOnce() {
67 for (
size_t kind = 0; kind < static_cast<size_t>(AssetType::Count); ++kind) {
69 for (
const AssetType type : ASSET_DEPENDENCY_ORDER) seen +=
static_cast<size_t>(type) == kind ? 1 : 0;
70 if (seen != 1)
return false;
72 return sizeof(ASSET_DEPENDENCY_ORDER) /
sizeof(AssetType) ==
static_cast<size_t>(AssetType::Count);
74static_assert(everyKindOrderedOnce(),
"each VKM_ASSET_KINDS row needs one place in ASSET_DEPENDENCY_ORDER");
84template<
typename Asset>
85inline constexpr AssetType ASSET_TYPE = AssetType::Count;
87#define VKM_ASSET_TRAIT(tag, type, name, dir) \
88 template<> inline constexpr AssetType ASSET_TYPE<type> = AssetType::tag;
89VKM_ASSET_KINDS(VKM_ASSET_TRAIT)
94#define VKM_ASSET_NAME(tag, type, name, dir) name,
95VKM_ENUM_NAMES(::Vkm::Engine::AssetType, VKM_ASSET_KINDS(VKM_ASSET_NAME))