Daniele Bartolini пре 11 година
родитељ
комит
a2b3e8312c

+ 3 - 7
engine/renderers/shader.cpp

@@ -111,11 +111,9 @@ namespace shader_resource
 		opts.delete_file(tmpfs_path.c_str());
 		opts.delete_file(tmpfs_path.c_str());
 	}
 	}
 
 
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id)
+	void* load(File& file, Allocator& a)
 	{
 	{
-		File* file = bundle.open(id);
-
-		BinaryReader br(*file);
+		BinaryReader br(file);
 		uint32_t version;
 		uint32_t version;
 		br.read(version);
 		br.read(version);
 
 
@@ -129,9 +127,7 @@ namespace shader_resource
 		const bgfx::Memory* fsmem = bgfx::alloc(fs_code_size);
 		const bgfx::Memory* fsmem = bgfx::alloc(fs_code_size);
 		br.read(fsmem->data, fs_code_size);
 		br.read(fsmem->data, fs_code_size);
 
 
-		bundle.close(file);
-
-		Shader* shader = (Shader*) default_allocator().allocate(sizeof(Shader));
+		Shader* shader = (Shader*) a.allocate(sizeof(Shader));
 		shader->vs = vsmem;
 		shader->vs = vsmem;
 		shader->fs = fsmem;
 		shader->fs = fsmem;
 		shader->program.idx = bgfx::invalidHandle;
 		shader->program.idx = bgfx::invalidHandle;

+ 1 - 1
engine/renderers/shader.h

@@ -47,7 +47,7 @@ struct Shader
 namespace shader_resource
 namespace shader_resource
 {
 {
 	void compile(const char* path, CompileOptions& opts);
 	void compile(const char* path, CompileOptions& opts);
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id);
+	void* load(File& file, Allocator& a);
 	void online(StringId64 id, ResourceManager& rm);
 	void online(StringId64 id, ResourceManager& rm);
 	void offline(StringId64 id, ResourceManager& rm);
 	void offline(StringId64 id, ResourceManager& rm);
 	void unload(Allocator& a, void* res);
 	void unload(Allocator& a, void* res);

+ 0 - 18
engine/resource/bundle.h

@@ -31,24 +31,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 namespace crown
 {
 {
 
 
-const uint32_t ARCHIVE_VERSION	= 1;	// Version of the archive
-
-struct ArchiveHeader
-{
-	uint32_t	version;			// The version number of the archive
-	uint32_t	entries_count;		// Number of resource entries in the archive
-	uint32_t	checksum;			// MD5 checksum of the archive
-	uint8_t		padding[64];		// Padding for additional data
-};
-
-struct ArchiveEntry
-{
-	uint32_t	name;				// Name of the resource (fnv1a hash)
-	uint32_t	type;				// Type of the resource (fnv1a hash)
-	uint64_t	offset;				// First byte of the resource (as absolute offset)
-	uint32_t	size;				// Size of the resource data (in bytes)
-};
-
 class Filesystem;
 class Filesystem;
 class File;
 class File;
 
 

+ 4 - 9
engine/resource/font_resource.cpp

@@ -96,16 +96,11 @@ namespace font_resource
 		}
 		}
 	}
 	}
 
 
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id)
+	void* load(File& file, Allocator& a)
 	{
 	{
-		File* file = bundle.open(id);
-		const size_t file_size = file->size();
-
-		void* res = allocator.allocate(file_size);
-		file->read(res, file_size);
-
-		bundle.close(file);
-
+		const size_t file_size = file.size();
+		void* res = a.allocate(file_size);
+		file.read(res, file_size);
 		return res;
 		return res;
 	}
 	}
 
 

+ 1 - 1
engine/resource/font_resource.h

@@ -60,7 +60,7 @@ struct FontGlyphData
 namespace font_resource
 namespace font_resource
 {
 {
 	void compile(const char* path, CompileOptions& opts);
 	void compile(const char* path, CompileOptions& opts);
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id);
+	void* load(File& file, Allocator& a);
 	void online(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void online(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void offline(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void offline(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void unload(Allocator& allocator, void* resource);
 	void unload(Allocator& allocator, void* resource);

+ 4 - 9
engine/resource/level_resource.cpp

@@ -243,16 +243,11 @@ namespace level_resource
 			& sounds;
 			& sounds;
 	}
 	}
 
 
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id)
+	void* load(File& file, Allocator& a)
 	{
 	{
-		File* file = bundle.open(id);
-		const size_t file_size = file->size();
-
-		void* res = allocator.allocate(file_size);
-		file->read(res, file_size);
-
-		bundle.close(file);
-
+		const size_t file_size = file.size();
+		void* res = a.allocate(file_size);
+		file.read(res, file_size);
 		return res;
 		return res;
 	}
 	}
 
 

+ 1 - 1
engine/resource/level_resource.h

@@ -68,7 +68,7 @@ struct LevelSound
 namespace level_resource
 namespace level_resource
 {
 {
 	void compile(const char* path, CompileOptions& opts);
 	void compile(const char* path, CompileOptions& opts);
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id);
+	void* load(File& file, Allocator& a);
 	void online(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void online(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void offline(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void offline(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void unload(Allocator& allocator, void* resource);
 	void unload(Allocator& allocator, void* resource);

+ 4 - 9
engine/resource/lua_resource.cpp

@@ -83,16 +83,11 @@ namespace lua_resource
 		opts.write(blob);
 		opts.write(blob);
 	}
 	}
 
 
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id)
+	void* load(File& file, Allocator& a)
 	{
 	{
-		File* file = bundle.open(id);
-		const size_t file_size = file->size();
-
-		void* res = allocator.allocate(file_size);
-		file->read(res, file_size);
-
-		bundle.close(file);
-
+		const size_t file_size = file.size();
+		void* res = a.allocate(file_size);
+		file.read(res, file_size);
 		return res;
 		return res;
 	}
 	}
 
 

+ 1 - 1
engine/resource/lua_resource.h

@@ -44,7 +44,7 @@ struct LuaResource
 namespace lua_resource
 namespace lua_resource
 {
 {
 	void compile(const char* path, CompileOptions& opts);
 	void compile(const char* path, CompileOptions& opts);
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id);
+	void* load(File& file, Allocator& a);
 	void online(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void online(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void offline(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void offline(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void unload(Allocator& allocator, void* resource);
 	void unload(Allocator& allocator, void* resource);

+ 4 - 9
engine/resource/material_resource.cpp

@@ -221,16 +221,11 @@ namespace material_resource
 		opts.write(names);
 		opts.write(names);
 	}
 	}
 
 
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id)
+	void* load(File& file, Allocator& a)
 	{
 	{
-		File* file = bundle.open(id);
-		const size_t file_size = file->size();
-
-		void* res = allocator.allocate(file_size);
-		file->read(res, file_size);
-
-		bundle.close(file);
-
+		const size_t file_size = file.size();
+		void* res = a.allocate(file_size);
+		file.read(res, file_size);
 		return res;
 		return res;
 	}
 	}
 
 

+ 1 - 1
engine/resource/material_resource.h

@@ -97,7 +97,7 @@ struct UniformHandle
 namespace material_resource
 namespace material_resource
 {
 {
 	void compile(const char* path, CompileOptions& opts);
 	void compile(const char* path, CompileOptions& opts);
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id);
+	void* load(File& file, Allocator& a);
 	void online(StringId64 id, ResourceManager& rm);
 	void online(StringId64 id, ResourceManager& rm);
 	void offline(StringId64 id, ResourceManager& rm);
 	void offline(StringId64 id, ResourceManager& rm);
 	void unload(Allocator& a, void* res);
 	void unload(Allocator& a, void* res);

+ 4 - 9
engine/resource/mesh_resource.cpp

@@ -195,16 +195,11 @@ namespace mesh_resource
 		// array::clear(m_indices);
 		// array::clear(m_indices);
 	}
 	}
 
 
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id)
+	void* load(File& file, Allocator& a)
 	{
 	{
-		File* file = bundle.open(id);
-		const size_t file_size = file->size();
-
-		void* res = allocator.allocate(file_size);
-		file->read(res, file_size);
-
-		bundle.close(file);
-
+		const size_t file_size = file.size();
+		void* res = a.allocate(file_size);
+		file.read(res, file_size);
 		return res;
 		return res;
 	}
 	}
 
 

+ 1 - 1
engine/resource/mesh_resource.h

@@ -102,7 +102,7 @@ private:
 namespace mesh_resource
 namespace mesh_resource
 {
 {
 	void compile(const char* path, CompileOptions& opts);
 	void compile(const char* path, CompileOptions& opts);
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id);
+	void* load(File& file, Allocator& a);
 	void online(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void online(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void offline(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void offline(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void unload(Allocator& a, void* res);
 	void unload(Allocator& a, void* res);

+ 4 - 9
engine/resource/package_resource.cpp

@@ -166,16 +166,11 @@ namespace package_resource
 			opts.write(sprite_animation[i].to_resource_id("sprite_animation").name);
 			opts.write(sprite_animation[i].to_resource_id("sprite_animation").name);
 	}
 	}
 
 
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id)
+	void* load(File& file, Allocator& a)
 	{
 	{
-		File* file = bundle.open(id);
-		const size_t file_size = file->size();
-
-		void* res = allocator.allocate(file_size);
-		file->read(res, file_size);
-
-		bundle.close(file);
-
+		const size_t file_size = file.size();
+		void* res = a.allocate(file_size);
+		file.read(res, file_size);
 		return res;
 		return res;
 	}
 	}
 
 

+ 1 - 1
engine/resource/package_resource.h

@@ -69,7 +69,7 @@ struct PackageResource
 namespace package_resource
 namespace package_resource
 {
 {
 	void compile(const char* path, CompileOptions& opts);
 	void compile(const char* path, CompileOptions& opts);
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id);
+	void* load(File& file, Allocator& a);
 	void online(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void online(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void offline(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void offline(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void unload(Allocator& allocator, void* resource);
 	void unload(Allocator& allocator, void* resource);

+ 1 - 1
engine/resource/pepper_resource.cpp

@@ -58,7 +58,7 @@ namespace pepper_resource
 		opts.get_absolute_path("tmpfs", tmpfs_path);
 		opts.get_absolute_path("tmpfs", tmpfs_path);
 	}
 	}
 
 
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id)
+	void* load(File& file, Allocator& a)
 	{
 	{
 
 
 	}
 	}

+ 1 - 1
engine/resource/pepper_resource.h

@@ -38,7 +38,7 @@ namespace crown
 namespace pepper_resource
 namespace pepper_resource
 {
 {
 	void compile(const char* path, CompileOptions& opts);
 	void compile(const char* path, CompileOptions& opts);
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id);
+	void* load(File& file, Allocator& a);
 	void online(StringId64 id, ResourceManager& rm);
 	void online(StringId64 id, ResourceManager& rm);
 	void offline(StringId64 id, ResourceManager& rm);
 	void offline(StringId64 id, ResourceManager& rm);
 	void unload(Allocator& a, void* resource);
 	void unload(Allocator& a, void* resource);

+ 8 - 18
engine/resource/physics_resource.cpp

@@ -373,16 +373,11 @@ namespace physics_resource
 		}
 		}
 	}
 	}
 
 
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id)
+	void* load(File& file, Allocator& a)
 	{
 	{
-		File* file = bundle.open(id);
-		const size_t file_size = file->size();
-
-		void* res = allocator.allocate(file_size);
-		file->read(res, file_size);
-
-		bundle.close(file);
-
+		const size_t file_size = file.size();
+		void* res = a.allocate(file_size);
+		file.read(res, file_size);
 		return res;
 		return res;
 	}
 	}
 
 
@@ -755,16 +750,11 @@ namespace physics_config_resource
 		CE_DELETE(default_allocator(), s_ftm);
 		CE_DELETE(default_allocator(), s_ftm);
 	}
 	}
 
 
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id)
+	void* load(File& file, Allocator& a)
 	{
 	{
-		File* file = bundle.open(id);
-		const size_t file_size = file->size();
-
-		void* res = allocator.allocate(file_size);
-		file->read(res, file_size);
-
-		bundle.close(file);
-
+		const size_t file_size = file.size();
+		void* res = a.allocate(file_size);
+		file.read(res, file_size);
 		return res;
 		return res;
 	}
 	}
 
 

+ 2 - 2
engine/resource/physics_resource.h

@@ -153,7 +153,7 @@ struct PhysicsJoint
 namespace physics_resource
 namespace physics_resource
 {
 {
 	void compile(const char* path, CompileOptions& opts);
 	void compile(const char* path, CompileOptions& opts);
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id);
+	void* load(File& file, Allocator& a);
 	void online(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void online(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void offline(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void offline(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void unload(Allocator& allocator, void* resource);
 	void unload(Allocator& allocator, void* resource);
@@ -222,7 +222,7 @@ struct PhysicsActor2
 namespace physics_config_resource
 namespace physics_config_resource
 {
 {
 	void compile(const char* path, CompileOptions& opts);
 	void compile(const char* path, CompileOptions& opts);
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id);
+	void* load(File& file, Allocator& a);
 	void online(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void online(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void offline(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void offline(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void unload(Allocator& allocator, void* resource);
 	void unload(Allocator& allocator, void* resource);

+ 4 - 1
engine/resource/resource_loader.cpp

@@ -29,6 +29,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "resource_registry.h"
 #include "resource_registry.h"
 #include "log.h"
 #include "log.h"
 #include "queue.h"
 #include "queue.h"
+#include "bundle.h"
 
 
 namespace crown
 namespace crown
 {
 {
@@ -103,7 +104,9 @@ int32_t ResourceLoader::run()
 
 
 		ResourceData rd;
 		ResourceData rd;
 		rd.id = id;
 		rd.id = id;
-		rd.data = resource_on_load(id.type, m_resource_heap, m_bundle, id);
+		File* file = m_bundle.open(id);
+		rd.data = resource_on_load(id.type, *file, m_resource_heap);
+		m_bundle.close(file);
 		add_loaded(rd);
 		add_loaded(rd);
 		m_mutex.lock();
 		m_mutex.lock();
 		queue::pop_front(m_requests);
 		queue::pop_front(m_requests);

+ 3 - 3
engine/resource/resource_registry.cpp

@@ -57,7 +57,7 @@ namespace shr = shader_resource;
 namespace sar = sprite_animation_resource;
 namespace sar = sprite_animation_resource;
 
 
 typedef void  (*ResourceCompileCallback)(const char* path, CompileOptions& opts);
 typedef void  (*ResourceCompileCallback)(const char* path, CompileOptions& opts);
-typedef void* (*ResourceLoadCallback)(Allocator& a, Bundle& b, ResourceId id);
+typedef void* (*ResourceLoadCallback)(File& file, Allocator& a);
 typedef void  (*ResourceOnlineCallback)(StringId64 id, ResourceManager& rm);
 typedef void  (*ResourceOnlineCallback)(StringId64 id, ResourceManager& rm);
 typedef void  (*ResourceOfflineCallback)(StringId64 id, ResourceManager& rm);
 typedef void  (*ResourceOfflineCallback)(StringId64 id, ResourceManager& rm);
 typedef void  (*ResourceUnloadCallback)(Allocator& a, void* resource);
 typedef void  (*ResourceUnloadCallback)(Allocator& a, void* resource);
@@ -109,9 +109,9 @@ void resource_on_compile(uint64_t type, const char* path, CompileOptions& opts)
 	return find_callback(type)->on_compile(path, opts);
 	return find_callback(type)->on_compile(path, opts);
 }
 }
 
 
-void* resource_on_load(uint64_t type, Allocator& allocator, Bundle& bundle, ResourceId id)
+void* resource_on_load(uint64_t type, File& file, Allocator& a)
 {
 {
-	return find_callback(type)->on_load(allocator, bundle, id);
+	return find_callback(type)->on_load(file, a);
 }
 }
 
 
 void resource_on_unload(uint64_t type, Allocator& allocator, void* resource)
 void resource_on_unload(uint64_t type, Allocator& allocator, void* resource)

+ 1 - 1
engine/resource/resource_registry.h

@@ -32,7 +32,7 @@ namespace crown
 {
 {
 
 
 void resource_on_compile(uint64_t type, const char* path, CompileOptions& opts);
 void resource_on_compile(uint64_t type, const char* path, CompileOptions& opts);
-void* resource_on_load(uint64_t type, Allocator& allocator, Bundle& bundle, ResourceId id);
+void* resource_on_load(uint64_t type, File& file, Allocator& a);
 void resource_on_online(uint64_t type, StringId64 id, ResourceManager& rm);
 void resource_on_online(uint64_t type, StringId64 id, ResourceManager& rm);
 void resource_on_offline(uint64_t type, StringId64 id, ResourceManager& rm);
 void resource_on_offline(uint64_t type, StringId64 id, ResourceManager& rm);
 void resource_on_unload(uint64_t type, Allocator& allocator, void* resource);
 void resource_on_unload(uint64_t type, Allocator& allocator, void* resource);

+ 4 - 9
engine/resource/sound_resource.cpp

@@ -136,16 +136,11 @@ namespace sound_resource
 		opts.write(wavdata, wav->data_size);
 		opts.write(wavdata, wav->data_size);
 	}
 	}
 
 
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id)
+	void* load(File& file, Allocator& a)
 	{
 	{
-		File* file = bundle.open(id);
-		const size_t file_size = file->size();
-
-		void* res = allocator.allocate(file_size);
-		file->read(res, file_size);
-
-		bundle.close(file);
-
+		const size_t file_size = file.size();
+		void* res = a.allocate(file_size);
+		file.read(res, file_size);
 		return res;
 		return res;
 	}
 	}
 
 

+ 1 - 1
engine/resource/sound_resource.h

@@ -61,7 +61,7 @@ struct SoundResource
 namespace sound_resource
 namespace sound_resource
 {
 {
 	void compile(const char* path, CompileOptions& opts);
 	void compile(const char* path, CompileOptions& opts);
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id);
+	void* load(File& file, Allocator& a);
 	void online(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void online(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void offline(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void offline(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void unload(Allocator& allocator, void* resource);
 	void unload(Allocator& allocator, void* resource);

+ 7 - 12
engine/resource/sprite_resource.cpp

@@ -136,10 +136,9 @@ namespace sprite_resource
 		}
 		}
 	}
 	}
 
 
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id)
+	void* load(File& file, Allocator& a)
 	{
 	{
-		File* file = bundle.open(id);
-		BinaryReader br(*file);
+		BinaryReader br(file);
 
 
 		uint32_t version;
 		uint32_t version;
 		br.read(version);
 		br.read(version);
@@ -154,9 +153,7 @@ namespace sprite_resource
 		const bgfx::Memory* ibmem = bgfx::alloc(num_inds * sizeof(uint16_t));
 		const bgfx::Memory* ibmem = bgfx::alloc(num_inds * sizeof(uint16_t));
 		br.read(ibmem->data, num_inds * sizeof(uint16_t));
 		br.read(ibmem->data, num_inds * sizeof(uint16_t));
 
 
-		bundle.close(file);
-
-		SpriteResource* so = (SpriteResource*) default_allocator().allocate(sizeof(SpriteResource));
+		SpriteResource* so = (SpriteResource*) a.allocate(sizeof(SpriteResource));
 		so->vbmem = vbmem;
 		so->vbmem = vbmem;
 		so->ibmem = ibmem;
 		so->ibmem = ibmem;
 
 
@@ -263,13 +260,11 @@ namespace sprite_animation_resource
 		}
 		}
 	}
 	}
 
 
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id)
+	void* load(File& file, Allocator& a)
 	{
 	{
-		File* file = bundle.open(id);
-		const size_t file_size = file->size();
-		void* res = allocator.allocate(file_size);
-		file->read(res, file_size);
-		bundle.close(file);
+		const size_t file_size = file.size();
+		void* res = a.allocate(file_size);
+		file.read(res, file_size);
 		return res;
 		return res;
 	}
 	}
 
 

+ 2 - 2
engine/resource/sprite_resource.h

@@ -61,7 +61,7 @@ struct SpriteResource
 namespace sprite_resource
 namespace sprite_resource
 {
 {
 	void compile(const char* path, CompileOptions& opts);
 	void compile(const char* path, CompileOptions& opts);
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id);
+	void* load(File& file, Allocator& a);
 	void online(StringId64 id, ResourceManager& rm);
 	void online(StringId64 id, ResourceManager& rm);
 	void offline(StringId64 id, ResourceManager& rm);
 	void offline(StringId64 id, ResourceManager& rm);
 	void unload(Allocator& a, void* resource);
 	void unload(Allocator& a, void* resource);
@@ -90,7 +90,7 @@ struct SpriteAnimationData
 namespace sprite_animation_resource
 namespace sprite_animation_resource
 {
 {
 	void compile(const char* path, CompileOptions& opts);
 	void compile(const char* path, CompileOptions& opts);
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id);
+	void* load(File& file, Allocator& a);
 	void online(StringId64 id, ResourceManager& rm);
 	void online(StringId64 id, ResourceManager& rm);
 	void offline(StringId64 id, ResourceManager& rm);
 	void offline(StringId64 id, ResourceManager& rm);
 	void unload(Allocator& a, void* resource);
 	void unload(Allocator& a, void* resource);

+ 5 - 7
engine/resource/texture_resource.cpp

@@ -622,16 +622,14 @@ namespace texture_resource
 		default_allocator().deallocate(image.data);
 		default_allocator().deallocate(image.data);
 	}
 	}
 
 
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id)
+	void* load(File& file, Allocator& a)
 	{
 	{
-		File* file = bundle.open(id);
-		const size_t file_size = file->size();
-		file->skip(sizeof(TextureHeader));
+		const size_t file_size = file.size();
+		file.skip(sizeof(TextureHeader));
 		const bgfx::Memory* mem = bgfx::alloc(file_size);
 		const bgfx::Memory* mem = bgfx::alloc(file_size);
-		file->read(mem->data, file_size - sizeof(TextureHeader));
-		bundle.close(file);
+		file.read(mem->data, file_size - sizeof(TextureHeader));
 
 
-		TextureResource* teximg = (TextureResource*) default_allocator().allocate(sizeof(TextureResource));
+		TextureResource* teximg = (TextureResource*) a.allocate(sizeof(TextureResource));
 		teximg->mem = mem;
 		teximg->mem = mem;
 		teximg->handle.idx = bgfx::invalidHandle;
 		teximg->handle.idx = bgfx::invalidHandle;
 
 

+ 1 - 1
engine/resource/texture_resource.h

@@ -53,7 +53,7 @@ struct TextureResource
 namespace texture_resource
 namespace texture_resource
 {
 {
 	void compile(const char* path, CompileOptions& opts);
 	void compile(const char* path, CompileOptions& opts);
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id);
+	void* load(File& file, Allocator& a);
 	void offline(StringId64 id, ResourceManager& rm);
 	void offline(StringId64 id, ResourceManager& rm);
 	void online(StringId64 id, ResourceManager& rm);
 	void online(StringId64 id, ResourceManager& rm);
 	void unload(Allocator& a, void* resource);
 	void unload(Allocator& a, void* resource);

+ 4 - 9
engine/resource/unit_resource.cpp

@@ -472,16 +472,11 @@ namespace unit_resource
 		}
 		}
 	}
 	}
 
 
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id)
+	void* load(File& file, Allocator& a)
 	{
 	{
-		File* file = bundle.open(id);
-		const size_t file_size = file->size();
-
-		void* res = allocator.allocate(file_size);
-		file->read(res, file_size);
-
-		bundle.close(file);
-
+		const size_t file_size = file.size();
+		void* res = a.allocate(file_size);
+		file.read(res, file_size);
 		return res;
 		return res;
 	}
 	}
 
 

+ 1 - 1
engine/resource/unit_resource.h

@@ -115,7 +115,7 @@ struct Key
 namespace unit_resource
 namespace unit_resource
 {
 {
 	void compile(const char* path, CompileOptions& opts);
 	void compile(const char* path, CompileOptions& opts);
-	void* load(Allocator& allocator, Bundle& bundle, ResourceId id);
+	void* load(File& file, Allocator& a);
 	void online(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void online(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void offline(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void offline(StringId64 /*id*/, ResourceManager& /*rm*/);
 	void unload(Allocator& allocator, void* resource);
 	void unload(Allocator& allocator, void* resource);