Use the mapped_file class instead of asset for assets

This commit is contained in:
Guillaume Meunier
2025-10-25 10:30:27 +02:00
parent 7963efc034
commit a9f774c67c
14 changed files with 143 additions and 241 deletions
+4 -4
View File
@@ -21,10 +21,10 @@
#include "implot.h"
#include "application.h"
#include "asset.h"
#include "constants.h"
#include "image_loader.h"
#include "openxr/openxr.h"
#include "utils/mapped_file.h"
#include "utils/ranges.h"
#include "utils/strings.h"
#include "vulkan/vulkan_enums.hpp"
@@ -527,8 +527,8 @@ void imgui_context::initialize_fonts()
}
}
asset font_awesome_regular("Font Awesome 6 Free-Regular-400.otf");
asset font_awesome_solid("Font Awesome 6 Free-Solid-900.otf");
utils::mapped_file font_awesome_regular("assets://Font Awesome 6 Free-Regular-400.otf");
utils::mapped_file font_awesome_solid("assets://Font Awesome 6 Free-Solid-900.otf");
ImFontConfig config;
config.FontDataOwnedByAtlas = false;
@@ -1041,7 +1041,7 @@ imgui_context::~imgui_context()
ImTextureID imgui_textures::load_texture(const std::string & filename, vk::raii::Sampler && sampler)
{
return load_texture(std::span<const std::byte>{asset{filename}}, std::move(sampler), filename);
return load_texture(utils::mapped_file{filename}, std::move(sampler), filename);
}
ImTextureID imgui_textures::load_texture(const std::span<const std::byte> & bytes, vk::raii::Sampler && sampler, const std::string & name)
+4 -4
View File
@@ -18,11 +18,11 @@
#include "scene_loader.h"
#include "asset.h"
#include "gpu_buffer.h"
#include "image_loader.h"
#include "render/scene_components.h"
#include "render/vertex_layout.h"
#include "utils/mapped_file.h"
#include "utils/ranges.h"
#include "vk/shader.h"
#include <algorithm>
@@ -465,8 +465,8 @@ class loader_context
thread_safe<vk::raii::Queue> & queue;
vk::raii::CommandPool & cb_pool;
std::vector<asset> loaded_assets;
asset & load_from_asset(const std::filesystem::path & path)
std::vector<utils::mapped_file> loaded_assets;
utils::mapped_file & load_from_asset(const std::filesystem::path & path)
{
try
{
@@ -1098,7 +1098,7 @@ std::shared_ptr<entt::registry> scene_loader::operator()(const std::filesystem::
{
spdlog::debug("Loading {}", gltf_path.native());
asset asset_file(gltf_path);
utils::mapped_file asset_file(gltf_path);
auto data_buffer = fastgltf::GltfDataBuffer::FromBytes(asset_file.data(), asset_file.size());
if (auto error = data_buffer.error(); error != fastgltf::Error::None)