Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
TextureAsset.cpp
Go to the documentation of this file.
2
6#include "plog/Log.h"
7
8#include <cassert>
9#include <filesystem>
10#include <format>
11
12namespace EngineCore {
13 TextureAsset::TextureAsset(bool initEcsData) : AssetBase(initEcsData)
14 {
15
16 }
17
18 void TextureAsset::setImage( tinygltf::Image && image )
19 {
20 TRACY_ZONE_SCOPED_NAMED("Setting image data");
21 if (data == entt::null)
22 {
23 PLOGW << "Tried to set the image for an asset where the entity is invalid!";
24 return;
25 }
26
27 PLOGD << "TextureAsset::setImage - entity=" << static_cast<uint32_t>(data)
28 << " dims=" << image.width << "x" << image.height;
29
30 auto& imageData = mainRegistry.get_or_emplace<Ecs::ImageData>(data);
31 imageData.image = std::move(image);
33 }
34
36 {
37 AssetBase::unload();
38 }
39
41 {
42 if (data == entt::null)
43 {
45 return;
46 }
47 if (mainRegistry.all_of<Ecs::ImageData>(data))
48 {
50 return;
51 }
52 // Entity exists but no ImageData component yet - still loading
54 {
56 }
57 }
58
60
62 if (data == entt::null)
63 {
65 }
66 auto& component = mainRegistry.get_or_emplace<Ecs::ExrHeaderData>( data );
67 component.header = std::move(header);
68 }
69
71 TRACY_ZONE_SCOPED_NAMED( "Gltf Texture Asset constructor" );
72 // glTF images are already loaded by tinygltf, so we initialize with ECS data ready
73 // Note: TextureAsset(true) already created the entity, so we just update the state
74 // (Previously called requestLoad() which would create a duplicate entity, leaking the first one)
76 PLOGD << "GltfTextureAsset created with entity=" << static_cast<uint32_t>(data);
77 }
78
82}
#define TRACY_ZONE_SCOPED_NAMED(name)
entt::entity data
Definition Asset.h:98
AssetBase(bool initializeDefaultEntity=false)
Definition Asset.h:52
CpuLoadingState loadingState
Definition Asset.h:95
entt::registry & mainRegistry
Definition Asset.h:97
void setHeader(ExrHeader &header)
void setImage(tinygltf::Image &&image)
sets the image data to an image. The image data will be moved into this asset
void updateLoadingState() override
updates the loading state according to all components required by this asset
void unload() override
unloads all data of this asset
TextureAsset(bool initEcsData=false)
@ LOADED
All components of the asset have been loaded, and it is ready to be used.
Definition Asset.h:39
@ LOADING
While the asset is currently being processed in the asset pipeline.
Definition Asset.h:35
@ UNLOADED
When the asset is not loaded yet but the frame is already existing for the heavy data to be loaded in...
Definition Asset.h:26
Log category system implementation.
EngineCore::ExrHeader header
Definition EcsData.h:70
tinygltf::Image image
Definition EcsData.h:90
Wrapper for EXR file header information with owned data.
Definition ExrLoader.h:42