Skip to content

Commit 3cc03d0

Browse files
committed
feat: expose cache directory in resource ext (v1.1.0)
1 parent 290ffa3 commit 3cc03d0

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

docs/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ the API is complete. It just means we won't break what currently exists.
8383
* Virtual File System v1.0.0 (pl_vfs_ext.h)
8484
* ECS v1.0.0 (pl_ecs_ext.h)
8585
* DDS v1.0.0 (pl_dds_ext.h)
86-
* Resource v1.0.0 (pl_resource_ext.h)
86+
* Resource v1.1.0 (pl_resource_ext.h)
8787

8888
## Nearly Stable Extensions
8989

editor/app.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
251251
gptVfs->mount_directory("/environments", "../data/pilotlight-assets-master/environments", PL_VFS_MOUNT_FLAGS_NONE);
252252
gptVfs->mount_directory("/shaders", "../shaders", PL_VFS_MOUNT_FLAGS_NONE);
253253
gptVfs->mount_directory("/shader-temp", "../shader-temp", PL_VFS_MOUNT_FLAGS_NONE);
254-
gptVfs->mount_directory("/cache", "../cache", PL_VFS_MOUNT_FLAGS_NONE);
254+
255255
gptFile->create_directory("../shader-temp");
256-
gptFile->create_directory("../cache");
256+
257257

258258
// defaults
259259
ptAppData->tSelectedEntity.uData = UINT64_MAX;

editor/editor.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
162162
gptVfs->mount_directory("/shaders", "../shaders", PL_VFS_MOUNT_FLAGS_NONE);
163163
gptVfs->mount_directory("/shader-temp", "../shader-temp", PL_VFS_MOUNT_FLAGS_NONE);
164164
gptFile->create_directory("../shader-temp");
165-
gptFile->create_directory("../cache");
166165

167166
// defaults
168167
ptAppData->tSelectedEntity.uData = UINT64_MAX;

extensions/pl_resource_ext.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Index of this file:
2626
#include "pl_gpu_allocators_ext.h"
2727
#include "pl_image_ext.h"
2828
#include "pl_vfs_ext.h"
29+
#include "pl_platform_ext.h"
2930

3031
// unstable extensions
3132
#include "pl_dxt_ext.h"
@@ -60,6 +61,7 @@ Index of this file:
6061
static const plVfsI* gptVfs = NULL;
6162
static const plDdsI* gptDds = NULL;
6263
static const plDxtI* gptDxt = NULL;
64+
static const plFileI* gptFile = NULL;
6365
#endif
6466

6567
// libs
@@ -159,7 +161,12 @@ pl_resource_initialize(plResourceManagerInit tDesc)
159161
if(tDesc.uMaxTextureResolution == 0)
160162
tDesc.uMaxTextureResolution = 1024;
161163

164+
if(tDesc.pcCacheDirectory == NULL)
165+
tDesc.pcCacheDirectory = "../cache";
166+
162167
gptResourceManager->tDesc = tDesc;
168+
gptFile->create_directory(tDesc.pcCacheDirectory);
169+
gptVfs->mount_directory("/cache", tDesc.pcCacheDirectory, PL_VFS_MOUNT_FLAGS_NONE);
163170

164171
plDevice* ptDevice = tDesc.ptDevice;
165172

@@ -984,6 +991,7 @@ pl_load_resource_ext(plApiRegistryI* ptApiRegistry, bool bReload)
984991
gptVfs = pl_get_api_latest(ptApiRegistry, plVfsI);
985992
gptDds = pl_get_api_latest(ptApiRegistry, plDdsI);
986993
gptDxt = pl_get_api_latest(ptApiRegistry, plDxtI);
994+
gptFile = pl_get_api_latest(ptApiRegistry, plFileI);
987995
#endif
988996

989997
const plDataRegistryI* ptDataRegistry = pl_get_api_latest(ptApiRegistry, plDataRegistryI);

extensions/pl_resource_ext.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Index of this file:
4343
// [SECTION] apis
4444
//-----------------------------------------------------------------------------
4545

46-
#define plResourceI_version {1, 0, 0}
46+
#define plResourceI_version {1, 1, 0}
4747

4848
//-----------------------------------------------------------------------------
4949
// [SECTION] includes
@@ -124,8 +124,9 @@ enum _plResourceLoadFlags
124124

125125
typedef struct _plResourceManagerInit
126126
{
127-
plDevice* ptDevice;
128-
uint32_t uMaxTextureResolution; // default: 1024
127+
plDevice* ptDevice;
128+
uint32_t uMaxTextureResolution; // default: 1024
129+
const char* pcCacheDirectory; // default: ../cache
129130
} plResourceManagerInit;
130131

131132
#endif // PL_RESOURCE_EXT_H

0 commit comments

Comments
 (0)