From 40d69e7e40a18865a31af2f55efcde369d36dbbb Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Tue, 20 May 2025 21:08:19 -0400 Subject: pke: serialization overhaul + embedded assets --- src/asset-manager.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/asset-manager.hpp') diff --git a/src/asset-manager.hpp b/src/asset-manager.hpp index ec98d08..5106375 100644 --- a/src/asset-manager.hpp +++ b/src/asset-manager.hpp @@ -12,6 +12,7 @@ constexpr AssetHandle AssetHandle_MAX = AssetHandle{ pk_handle_MAX_constexpr }; TypeSafeInt_constexpr(AssetLoadingState, uint8_t, 0xFF); TypeSafeInt_constexpr(AssetType, uint8_t, 0xFF); +TypeSafeInt_constexpr(AssetFlags, uint8_t, 0xFF); const int64_t AssetKeyLength = 16; using AssetKey = char[AssetKeyLength]; @@ -29,6 +30,9 @@ const AssetType PKE_ASSET_TYPE_AUDIO = AssetType {0x08}; const AssetType PKE_ASSET_TYPE_FONT = AssetType {0x10}; const AssetType PKE_ASSET_TYPE_ALL = AssetType {0xFF}; +const AssetFlags PKE_ASSET_FLAGS_NONE = AssetFlags {0x00}; +const AssetFlags PKE_ASSET_FLAGS_MEM_STATIC = AssetFlags {0x01}; + constexpr int64_t EngineDefinedAssetCount = 8; extern AssetKey EngineDefinedAssets[EngineDefinedAssetCount]; @@ -37,17 +41,19 @@ struct Asset { AssetKey key = {'\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0'}; const char *basePath = nullptr; int64_t size = 0; - void *ptr = nullptr; + const void *ptr = nullptr; std::future future; int8_t referenceCount = 0; AssetLoadingState state = PKE_ASSET_LOADING_STATE_UNLOADED; AssetType type = PKE_ASSET_TYPE_UNSET; + AssetFlags flags = PKE_ASSET_FLAGS_NONE; }; void AM_Init(); AssetHandle AM_Register(AssetKey key, AssetType type, const void *data, int64_t size, std::size_t alignment); AssetHandle AM_Register(const char *path, AssetType type); AssetHandle AM_Register(AssetKey key, AssetType type, const char *path); +AssetHandle AM_Register_Static(AssetKey key, AssetType type, const void *data, int64_t size); void AM_Release(AssetHandle assetHandle); const Asset *AM_Get(AssetHandle assetHandle); const AssetHandle AM_GetHandle(AssetKey key); -- cgit v1.2.3