|
Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
|
Central manager for GPU resources. More...
#include <ResourceManager.hpp>
Classes | |
| struct | OwedTexture |
| Textures the device is waiting for content for, with who refills them. More... | |
| struct | MeshRealization |
| One live mesh and whether its geometry is on the device. More... | |
Public Types | |
| using | ShaderRetiredCallback = void (*)(void*, ShaderHandle) |
| One renderer owns shader-derived metadata. Notify after final pool retirement. | |
Public Member Functions | |
| ResourceManager ()=default | |
| ~ResourceManager ()=default | |
| ResourceManager (const ResourceManager &)=delete | |
| ResourceManager & | operator= (const ResourceManager &)=delete |
| ResourceManager (ResourceManager &&)=default | |
| ResourceManager & | operator= (ResourceManager &&)=default |
| void | init (GfxDevice &device) |
| Initializes the resource manager. | |
| GfxDevice * | device () const |
| void | shutdown () |
| Shuts down and releases all resources. | |
| bool | isInitialized () const |
| Checks if the manager is initialized. | |
| void | update () |
| Updates resource manager (processes hot reload, call once per frame). | |
| GfxShaderLanguage | preferredShaderLanguage () const |
| The language embedded pipelines must author their sources in. | |
| ShaderTargetLanguage | preferredShaderTarget () const |
| preferredShaderLanguage() as a ShaderParser assembly target. | |
| bool | deferLinks () const |
| Creates a shader from source strings. | |
| ShaderHandle | createShader (const std::string &vertSrc, const std::string &fragSrc, bool rewriteLoose=true, GfxShaderLanguage language=GfxShaderLanguage::GLSL_ES300, bool deferLink=false) |
| ShaderHandle | createShaderWithBindings (const std::string &vertSrc, const std::string &fragSrc, std::initializer_list< AttribBinding > bindings, GfxShaderLanguage language=GfxShaderLanguage::GLSL_ES300, bool deferLink=false) |
| ShaderHandle | loadShader (const std::string &vertPath, const std::string &fragPath) |
| Loads a shader from file paths (with caching). | |
| Shader * | getShader (ShaderHandle handle) |
| Gets a shader by handle. | |
| const Shader * | getShader (ShaderHandle handle) const |
| Gets a shader by handle (const). | |
| void | releaseShader (ShaderHandle handle) |
| Releases a shader (decrements ref count). | |
| void | setShaderRetiredCallback (void *owner, ShaderRetiredCallback callback) |
| void | clearShaderRetiredCallback (void *owner) |
| u32 | getShaderRefCount (ShaderHandle handle) const |
| Gets the current reference count for a shader. | |
| TextureHandle | createTexture (ResourceContent content, const TextureSpecification &spec) |
| Creates a texture from specification. | |
| TextureHandle | createTexture (ResourceContent content, u32 width, u32 height, ConstSpan< u8 > pixels, TextureFormat format, bool flipY=false) |
| Creates a texture from pixel data. | |
| TextureHandle | createTextureArray (ResourceContent content, const TextureSpecification &spec, ConstSpan< u8 > pixels) |
| Creates a 2D texture array from spec.layers same-size RGBA8 (or SRGB8A8) layers. | |
| TextureHandle | createCompressedTexture (ResourceContent content, u32 width, u32 height, GfxCompressedFormat format, ConstSpan< u8 > data, u32 mipLevels=1) |
| Creates a block-compressed texture (KTX2 → ETC2/ASTC/BC), uploading the pre-compressed blocks for mip level 0. Tracked like any texture; its residency cost is the real (compressed) byte size. | |
| TextureHandle | loadTexture (const std::string &path) |
| Loads a texture from file (with caching). | |
| Texture * | getTexture (TextureHandle handle) |
| Gets a texture by handle. | |
| const Texture * | getTexture (TextureHandle handle) const |
| Gets a texture by handle (const). | |
| void | releaseTexture (TextureHandle handle) |
| Releases a texture (decrements ref count). | |
| u32 | getTextureRefCount (TextureHandle handle) const |
| Gets the current reference count for a texture. | |
| TextureHandle | registerExternalTexture (ResourceContent content, u32 glTextureId, u32 width, u32 height, usize bytes=0) |
| Registers an externally-created GL texture. | |
| TextureHandle | wrapDeviceTexture (::esengine::TextureHandle texture, u32 width, u32 height) |
| Names a texture the device holds for another owner (a render target's colour plane) by a resource handle, without taking it over. | |
| void | registerTextureWithPath (TextureHandle handle, const std::string &path) |
| Registers a texture with a path for cache lookup. | |
| bool | adoptTextureContent (TextureHandle target, TextureHandle source) |
| Moves a freshly loaded texture's pixels behind an owed handle. | |
| std::vector< OwedTexture > | texturesAwaitingReupload () const |
| void | forgoTextureContent (TextureHandle handle) |
| Gives up on an owed texture's content: it keeps blank storage. | |
| void | restoreTextureContent (TextureHandle handle) |
| Settles an owed texture whose provider wrote the pixels itself. | |
| u32 | textureNativeId (TextureHandle handle) const |
| The backend's own name for a texture's object, for a host that writes its pixels itself; 0 when there is none. See GfxDevice::nativeTextureName. | |
| const std::string & | getTexturePath (TextureHandle handle) const |
| Gets the cached path for a texture. | |
| TextureHandle | loadTextureByGUID (const std::string &guid, const std::string &path) |
| Loads a texture by GUID (with caching). | |
| TextureHandle | getTextureByGUID (const std::string &guid) const |
| Gets a texture handle by GUID if already loaded. | |
| void | releaseTextureByGUID (const std::string &guid) |
| Releases a texture by GUID. | |
| void | setTextureBudget (usize bytes) |
| Sets the texture pool's resident-byte budget (0 = no eviction). Over budget, refCount==0 textures are evicted oldest-first. | |
| void | setRetainedBudget (usize bytes) |
| See GfxDevice::setRetainedBudget. | |
| TextureHandle | acquireTextureByPath (const std::string &path) |
| Reuses a cached texture by its build path: returns its handle with an added reference (reviving an evictable one), or an invalid handle if none is cached. Lets the runtime dedupe + reuse textures across loads. | |
| bool | invalidateTexturePath (const std::string &path) |
| Severs a path's texture-cache identity (hot reload). The next acquireTextureByPath for it misses, so stale bytes are never revived; an evictable entry under that path is freed immediately. | |
| usize | trimTextureCache () |
| Frees every evictable cached texture now (memory pressure). Held textures and the budget are untouched. | |
| void | setTextureMetadata (TextureHandle handle, const TextureMetadata &metadata) |
| Sets metadata for a texture. | |
| const TextureMetadata * | getTextureMetadata (TextureHandle handle) const |
| Gets metadata for a texture. | |
| bool | hasTextureMetadata (TextureHandle handle) const |
| Checks if a texture has metadata. | |
| void | removeTextureMetadata (TextureHandle handle) |
| Removes metadata for a texture. | |
| template<typename T> | |
| VertexBufferHandle | createVertexBuffer (GfxContent content, ConstSpan< T > data) |
| Creates a vertex buffer from typed data. | |
| VertexBufferHandle | createVertexBuffer (GfxContent content, u32 sizeBytes) |
| Creates a dynamic vertex buffer. | |
| bool | setMeshClusters (MeshHandle target, lod::ClusterHierarchy hierarchy) |
| Uploads geometry that stays on the GPU, drawn from its own buffers. | |
| bool | setMeshSkinChunks (MeshHandle target, std::vector< MeshSkinChunk > chunks, std::vector< u16 > bones) |
| Gives a realized skinned mesh the chunks it is drawn in (Mesh::skinChunks). | |
| MeshHandle | createMesh (ConstSpan< u8 > vertexBytes, ConstSpan< u32 > indices, ConstSpan< GfxVertexAttribute > channels, u32 vertexStride, const glm::vec3 &localMin, const glm::vec3 &localMax, MeshRecovery recovery, ConstSpan< f32 > inverseBind={}, const MeshMorphSource &morph={}) |
| bool | rematerializeMesh (MeshHandle target, ConstSpan< u8 > vertexBytes, ConstSpan< u32 > indices, ConstSpan< GfxVertexAttribute > channels, u32 vertexStride, const glm::vec3 &localMin, const glm::vec3 &localMax, ConstSpan< f32 > inverseBind={}, const MeshMorphSource &morph={}) |
| Puts new geometry behind an EXISTING mesh handle. | |
| void | setMeshEdgeBuffers (bool enabled) |
| Whether meshes realized FROM NOW ON also get an edge buffer. | |
| bool | meshEdgeBuffers () const |
| Mesh * | getMesh (MeshHandle handle) |
| The mesh a handle names, or null. | |
| const Mesh * | getMesh (MeshHandle handle) const |
| void | releaseMesh (MeshHandle handle) |
| Releases a mesh and the buffers it owns. | |
| u64 | meshesRevision () const |
| Changes whenever any mesh is realized (each takes a new Mesh::revision) or released: while it holds, every mesh a reader looked at is the one it was. | |
| u64 | textureMetadataRevision () const |
| Moves whenever a texture's metadata (its nine-slice borders and the rest) is set or dropped. | |
| std::vector< MeshHandle > | meshesAwaitingRematerialization () const |
| Replayable meshes whose geometry the device is still waiting for. | |
| std::vector< MeshRealization > | meshRealizations () |
| Every live mesh, for a recovery criterion to read. | |
| EnvironmentHandle | createEnvironment (ConstSpan< f32 > irradiance, TextureHandle specular, f32 faceSize, u32 mipCount, f32 maxRange, u32 columns=1) |
| Registers a baked environment. | |
| Environment * | getEnvironment (EnvironmentHandle handle) |
| The environment a handle names, or null. | |
| const Environment * | getEnvironment (EnvironmentHandle handle) const |
| void | releaseEnvironment (EnvironmentHandle handle) |
| Releases an environment. The atlas is an ordinary texture asset with its own lifetime, so it is NOT released here. | |
| ProbeVolumeHandle | createProbeVolume (const glm::ivec3 &resolution, ConstSpan< f32 > irradiance) |
| Registers a grid of baked irradiance. | |
| ProbeVolumeHandle | createProbeVolumeBricks (const glm::ivec3 &resolution, ConstSpan< i32 > bricks, ConstSpan< f32 > irradiance) |
| Registers a SPARSE grid: bricks at their own spacing (see ProbeVolume). | |
| ProbeVolume * | getProbeVolume (ProbeVolumeHandle handle) |
| The probe volume a handle names, or null. | |
| const ProbeVolume * | getProbeVolume (ProbeVolumeHandle handle) const |
| void | releaseProbeVolume (ProbeVolumeHandle handle) |
| Releases a probe volume. | |
| VertexBuffer * | getVertexBuffer (VertexBufferHandle handle) |
| Gets a vertex buffer by handle. | |
| const VertexBuffer * | getVertexBuffer (VertexBufferHandle handle) const |
| Gets a vertex buffer by handle (const). | |
| void | releaseVertexBuffer (VertexBufferHandle handle) |
| Releases a vertex buffer (decrements ref count). | |
| IndexBufferHandle | createIndexBuffer (GfxContent content, ConstSpan< u32 > indices) |
| Creates an index buffer from 32-bit indices. | |
| IndexBufferHandle | createIndexBuffer (GfxContent content, ConstSpan< u16 > indices) |
| Creates an index buffer from 16-bit indices. | |
| IndexBuffer * | getIndexBuffer (IndexBufferHandle handle) |
| Gets an index buffer by handle. | |
| const IndexBuffer * | getIndexBuffer (IndexBufferHandle handle) const |
| Gets an index buffer by handle (const). | |
| void | releaseIndexBuffer (IndexBufferHandle handle) |
| Releases an index buffer (decrements ref count). | |
| BitmapFontHandle | loadBitmapFont (const std::string &fntPath) |
| BitmapFontHandle | createBitmapFont (const std::string &fntContent, TextureHandle texture, u32 texWidth, u32 texHeight) |
| BitmapFontHandle | createLabelAtlasFont (TextureHandle texture, u32 texWidth, u32 texHeight, const std::string &chars, u32 charWidth, u32 charHeight) |
| text::BitmapFont * | getBitmapFont (BitmapFontHandle handle) |
| const text::BitmapFont * | getBitmapFont (BitmapFontHandle handle) const |
| void | releaseBitmapFont (BitmapFontHandle handle) |
| u32 | getBitmapFontRefCount (BitmapFontHandle handle) const |
| Gets the current reference count for a bitmap font. | |
| ResourceStats | getStats () const |
| Gets current resource statistics. | |
| void | resetCacheStats () |
| Resets cache hit/miss counters. | |
| u32 | meshPageCount () const |
| u64 | meshPageBytes () const |
Central manager for GPU resources.
Manages the lifecycle of shaders, textures, and buffers. Provides handle-based access with reference counting and path-based caching for deduplication.
Definition at line 112 of file ResourceManager.hpp.
| using esengine::resource::ResourceManager::ShaderRetiredCallback = void (*)(void*, ShaderHandle) |
One renderer owns shader-derived metadata. Notify after final pool retirement.
Definition at line 228 of file ResourceManager.hpp.
|
default |
Referenced by ResourceManager(), ResourceManager(), operator=(), and operator=().
|
default |
|
delete |
References ResourceManager().
|
default |
References ResourceManager().
| TextureHandle esengine::resource::ResourceManager::acquireTextureByPath | ( | const std::string & | path | ) |
Reuses a cached texture by its build path: returns its handle with an added reference (reviving an evictable one), or an invalid handle if none is cached. Lets the runtime dedupe + reuse textures across loads.
Definition at line 417 of file ResourceManager.cpp.
References esengine::Texture::getId(), and esengine::GfxOwedContent::Texture.
Referenced by esengine::rm_acquireTextureByPath().
| bool esengine::resource::ResourceManager::adoptTextureContent | ( | TextureHandle | target, |
| TextureHandle | source ) |
Moves a freshly loaded texture's pixels behind an owed handle.
How the asset layer pays: it loads the texture the ordinary way and hands the result over, which leaves source empty for its release.
Definition at line 350 of file ResourceManager.cpp.
References esengine::Texture::adoptContent().
Referenced by esengine::rm_adoptTextureContent().
|
inline |
Definition at line 232 of file ResourceManager.hpp.
| BitmapFontHandle esengine::resource::ResourceManager::createBitmapFont | ( | const std::string & | fntContent, |
| TextureHandle | texture, | ||
| u32 | texWidth, | ||
| u32 | texHeight ) |
Definition at line 1133 of file ResourceManager.cpp.
References esengine::makeUnique().
| TextureHandle esengine::resource::ResourceManager::createCompressedTexture | ( | ResourceContent | content, |
| u32 | width, | ||
| u32 | height, | ||
| GfxCompressedFormat | format, | ||
| ConstSpan< u8 > | data, | ||
| u32 | mipLevels = 1 ) |
Creates a block-compressed texture (KTX2 → ETC2/ASTC/BC), uploading the pre-compressed blocks for mip level 0. Tracked like any texture; its residency cost is the real (compressed) byte size.
| data | All mipLevels concatenated (level 0 first, block-aligned). |
| mipLevels | Mip levels present (1 = base only). |
Definition at line 266 of file ResourceManager.cpp.
References esengine::Texture::createCompressed(), ES_LOG_ERROR, and esengine::resource::toGfxContent().
Referenced by esengine::rm_createCompressedTexture().
| EnvironmentHandle esengine::resource::ResourceManager::createEnvironment | ( | ConstSpan< f32 > | irradiance, |
| TextureHandle | specular, | ||
| f32 | faceSize, | ||
| u32 | mipCount, | ||
| f32 | maxRange, | ||
| u32 | columns = 1 ) |
Registers a baked environment.
| irradiance | Nine RGB spherical-harmonic coefficients. |
| specular | The prefiltered octahedral atlas; may be invalid, leaving the environment diffuse-only. |
Definition at line 987 of file ResourceManager.cpp.
References ES_LOG_ERROR.
| IndexBufferHandle esengine::resource::ResourceManager::createIndexBuffer | ( | GfxContent | content, |
| ConstSpan< u16 > | indices ) |
Creates an index buffer from 16-bit indices.
| indices | Span of index data |
Definition at line 1090 of file ResourceManager.cpp.
References esengine::IndexBuffer::create(), and ES_LOG_ERROR.
| IndexBufferHandle esengine::resource::ResourceManager::createIndexBuffer | ( | GfxContent | content, |
| ConstSpan< u32 > | indices ) |
Creates an index buffer from 32-bit indices.
| indices | Span of index data |
Definition at line 1080 of file ResourceManager.cpp.
References esengine::IndexBuffer::create(), and ES_LOG_ERROR.
| BitmapFontHandle esengine::resource::ResourceManager::createLabelAtlasFont | ( | TextureHandle | texture, |
| u32 | texWidth, | ||
| u32 | texHeight, | ||
| const std::string & | chars, | ||
| u32 | charWidth, | ||
| u32 | charHeight ) |
Definition at line 1143 of file ResourceManager.cpp.
References esengine::makeUnique().
| MeshHandle esengine::resource::ResourceManager::createMesh | ( | ConstSpan< u8 > | vertexBytes, |
| ConstSpan< u32 > | indices, | ||
| ConstSpan< GfxVertexAttribute > | channels, | ||
| u32 | vertexStride, | ||
| const glm::vec3 & | localMin, | ||
| const glm::vec3 & | localMax, | ||
| MeshRecovery | recovery, | ||
| ConstSpan< f32 > | inverseBind = {}, | ||
| const MeshMorphSource & | morph = {} ) |
Definition at line 834 of file ResourceManager.cpp.
References esengine::makeUnique(), and esengine::Mesh::recovery.
Referenced by esengine::mesh_createFromChannels().
| ProbeVolumeHandle esengine::resource::ResourceManager::createProbeVolume | ( | const glm::ivec3 & | resolution, |
| ConstSpan< f32 > | irradiance ) |
Registers a grid of baked irradiance.
| resolution | Probes along x, y and z. |
| irradiance | Nine RGB coefficients per probe, x fastest then y then z. |
Definition at line 1019 of file ResourceManager.cpp.
References ES_LOG_ERROR, and esengine::ProbeVolume::nextRevision().
| ProbeVolumeHandle esengine::resource::ResourceManager::createProbeVolumeBricks | ( | const glm::ivec3 & | resolution, |
| ConstSpan< i32 > | bricks, | ||
| ConstSpan< f32 > | irradiance ) |
Registers a SPARSE grid: bricks at their own spacing (see ProbeVolume).
| resolution | The finest grid's probes along x, y and z. |
| bricks | Four ints a brick: its first finest-brick cell x, y, z and its span in those cells. |
| irradiance | Nine RGB coefficients per probe, ProbeVolume::kBrickProbes probes a brick, brick after brick. |
Definition at line 1037 of file ResourceManager.cpp.
References ES_LOG_ERROR, and esengine::ProbeVolume::nextRevision().
| ShaderHandle esengine::resource::ResourceManager::createShader | ( | const std::string & | vertSrc, |
| const std::string & | fragSrc, | ||
| bool | rewriteLoose = true, | ||
| GfxShaderLanguage | language = GfxShaderLanguage::GLSL_ES300, | ||
| bool | deferLink = false ) |
Definition at line 119 of file ResourceManager.cpp.
References esengine::Shader::create(), esengine::Shader::createEx(), esengine::DrawParamsLayout::empty(), ES_LOG_ERROR, ES_LOG_WARN, esengine::DrawParamsRewrite::fragmentSrc, esengine::GLSL_ES300, esengine::DrawParamsRewrite::layout, esengine::rewriteLooseUniforms(), and esengine::DrawParamsRewrite::vertexSrc.
Referenced by esengine::rm_createShader().
| ShaderHandle esengine::resource::ResourceManager::createShaderWithBindings | ( | const std::string & | vertSrc, |
| const std::string & | fragSrc, | ||
| std::initializer_list< AttribBinding > | bindings, | ||
| GfxShaderLanguage | language = GfxShaderLanguage::GLSL_ES300, | ||
| bool | deferLink = false ) |
Definition at line 155 of file ResourceManager.cpp.
References esengine::Shader::createWithBindings(), and ES_LOG_ERROR.
Referenced by esengine::MaterialStore::prepassCoverageProgram(), and esengine::MaterialStore::shadowProgram().
| TextureHandle esengine::resource::ResourceManager::createTexture | ( | ResourceContent | content, |
| const TextureSpecification & | spec ) |
Creates a texture from specification.
| spec | Texture creation parameters |
Definition at line 223 of file ResourceManager.cpp.
References esengine::Texture::create(), ES_LOG_ERROR, and esengine::resource::toGfxContent().
Referenced by esengine::rm_createTexture(), and esengine::rm_createTextureEx().
| TextureHandle esengine::resource::ResourceManager::createTexture | ( | ResourceContent | content, |
| u32 | width, | ||
| u32 | height, | ||
| ConstSpan< u8 > | pixels, | ||
| TextureFormat | format, | ||
| bool | flipY = false ) |
Creates a texture from pixel data.
| width | Texture width in pixels |
| height | Texture height in pixels |
| pixels | Pixel data |
| format | Pixel format (default RGBA8) |
Definition at line 234 of file ResourceManager.cpp.
References esengine::Texture::create(), ES_LOG_ERROR, and esengine::resource::toGfxContent().
| TextureHandle esengine::resource::ResourceManager::createTextureArray | ( | ResourceContent | content, |
| const TextureSpecification & | spec, | ||
| ConstSpan< u8 > | pixels ) |
Creates a 2D texture array from spec.layers same-size RGBA8 (or SRGB8A8) layers.
| pixels | The layers back to back, layer 0 first; exactly spec.width * spec.height * 4 * spec.layers bytes, or nothing is made. |
Definition at line 247 of file ResourceManager.cpp.
References esengine::Texture::createArray(), ES_LOG_ERROR, esengine::TextureSpecification::format, esengine::TextureSpecification::height, esengine::TextureSpecification::layers, esengine::RGBA8, esengine::SRGB8A8, esengine::resource::toGfxContent(), and esengine::TextureSpecification::width.
Referenced by esengine::rm_createTextureArray().
| VertexBufferHandle esengine::resource::ResourceManager::createVertexBuffer | ( | GfxContent | content, |
| ConstSpan< T > | data ) |
Creates a vertex buffer from typed data.
| T | Vertex type |
| data | Span of vertex data |
Definition at line 778 of file ResourceManager.hpp.
References esengine::VertexBuffer::create().
| VertexBufferHandle esengine::resource::ResourceManager::createVertexBuffer | ( | GfxContent | content, |
| u32 | sizeBytes ) |
Creates a dynamic vertex buffer.
| sizeBytes | Buffer size in bytes |
Definition at line 515 of file ResourceManager.cpp.
References esengine::VertexBuffer::create(), and ES_LOG_ERROR.
| bool esengine::resource::ResourceManager::deferLinks | ( | ) | const |
Creates a shader from source strings.
| vertSrc | Vertex shader GLSL source |
| fragSrc | Fragment shader GLSL source |
| rewriteLoose | Lift loose non-sampler uniforms into a std140 DrawParams block (see renderer/DrawParams.hpp). Pass false for sources whose uniform blocks are already assembled (ShaderParser material output). |
Whether a shader that is known to compile is made without waiting for it (the device's skip-what-is-not-ready policy is on).
Definition at line 115 of file ResourceManager.cpp.
|
inline |
The device resources are created on, or null before init. Read by callers that must ASK the backend what it supports.
Definition at line 138 of file ResourceManager.hpp.
Referenced by init(), operator=(), and esengine::rm_supportsCompressedFormat().
| void esengine::resource::ResourceManager::forgoTextureContent | ( | TextureHandle | handle | ) |
Gives up on an owed texture's content: it keeps blank storage.
For content nothing can bring back; the caller says so in the log.
Definition at line 372 of file ResourceManager.cpp.
References esengine::Texture::getId(), and esengine::GfxOwedContent::Texture.
Referenced by esengine::rm_forgoTextureContent().
| text::BitmapFont * esengine::resource::ResourceManager::getBitmapFont | ( | BitmapFontHandle | handle | ) |
Definition at line 1152 of file ResourceManager.cpp.
| const text::BitmapFont * esengine::resource::ResourceManager::getBitmapFont | ( | BitmapFontHandle | handle | ) | const |
Definition at line 1156 of file ResourceManager.cpp.
| u32 esengine::resource::ResourceManager::getBitmapFontRefCount | ( | BitmapFontHandle | handle | ) | const |
Gets the current reference count for a bitmap font.
| handle | The font handle |
Definition at line 1166 of file ResourceManager.cpp.
| Environment * esengine::resource::ResourceManager::getEnvironment | ( | EnvironmentHandle | handle | ) |
The environment a handle names, or null.
Definition at line 1007 of file ResourceManager.cpp.
| const Environment * esengine::resource::ResourceManager::getEnvironment | ( | EnvironmentHandle | handle | ) | const |
Definition at line 1011 of file ResourceManager.cpp.
| IndexBuffer * esengine::resource::ResourceManager::getIndexBuffer | ( | IndexBufferHandle | handle | ) |
Gets an index buffer by handle.
| handle | The buffer handle |
Definition at line 1100 of file ResourceManager.cpp.
| const IndexBuffer * esengine::resource::ResourceManager::getIndexBuffer | ( | IndexBufferHandle | handle | ) | const |
Gets an index buffer by handle (const).
| handle | The buffer handle |
Definition at line 1104 of file ResourceManager.cpp.
| Mesh * esengine::resource::ResourceManager::getMesh | ( | MeshHandle | handle | ) |
The mesh a handle names, or null.
Definition at line 927 of file ResourceManager.cpp.
Referenced by esengine::gatherLodLevels(), and esengine::placementCoarseMesh().
| const Mesh * esengine::resource::ResourceManager::getMesh | ( | MeshHandle | handle | ) | const |
Definition at line 931 of file ResourceManager.cpp.
| ProbeVolume * esengine::resource::ResourceManager::getProbeVolume | ( | ProbeVolumeHandle | handle | ) |
The probe volume a handle names, or null.
Definition at line 1064 of file ResourceManager.cpp.
| const ProbeVolume * esengine::resource::ResourceManager::getProbeVolume | ( | ProbeVolumeHandle | handle | ) | const |
Definition at line 1068 of file ResourceManager.cpp.
| Shader * esengine::resource::ResourceManager::getShader | ( | ShaderHandle | handle | ) |
Gets a shader by handle.
| handle | The shader handle |
Definition at line 191 of file ResourceManager.cpp.
Referenced by esengine::MaterialStore::meshProgram(), esengine::MaterialStore::prepassCoverageProgram(), and esengine::MaterialStore::shadowProgram().
| const Shader * esengine::resource::ResourceManager::getShader | ( | ShaderHandle | handle | ) | const |
Gets a shader by handle (const).
| handle | The shader handle |
Definition at line 195 of file ResourceManager.cpp.
| u32 esengine::resource::ResourceManager::getShaderRefCount | ( | ShaderHandle | handle | ) | const |
Gets the current reference count for a shader.
| handle | The shader handle |
Definition at line 207 of file ResourceManager.cpp.
Referenced by esengine::rm_getShaderRefCount().
| ResourceStats esengine::resource::ResourceManager::getStats | ( | ) | const |
Gets current resource statistics.
Definition at line 1174 of file ResourceManager.cpp.
References esengine::resource::ResourceStats::shaderCount.
| Texture * esengine::resource::ResourceManager::getTexture | ( | TextureHandle | handle | ) |
Gets a texture by handle.
| handle | The texture handle |
Definition at line 295 of file ResourceManager.cpp.
Referenced by esengine::text::BitmapFont::loadFromFntText(), esengine::rm_createTextureEx(), esengine::rm_getTextureGLId(), and esengine::rm_updateTextureSubregion().
| const Texture * esengine::resource::ResourceManager::getTexture | ( | TextureHandle | handle | ) | const |
Gets a texture by handle (const).
| handle | The texture handle |
Definition at line 299 of file ResourceManager.cpp.
| TextureHandle esengine::resource::ResourceManager::getTextureByGUID | ( | const std::string & | guid | ) | const |
Gets a texture handle by GUID if already loaded.
| guid | Asset GUID |
Definition at line 464 of file ResourceManager.cpp.
| const TextureMetadata * esengine::resource::ResourceManager::getTextureMetadata | ( | TextureHandle | handle | ) | const |
Gets metadata for a texture.
| handle | The texture handle |
Definition at line 491 of file ResourceManager.cpp.
References esengine::resource::Handle< T >::id(), and esengine::resource::Handle< T >::isValid().
| const std::string & esengine::resource::ResourceManager::getTexturePath | ( | TextureHandle | handle | ) | const |
Gets the cached path for a texture.
| handle | The texture handle |
Definition at line 405 of file ResourceManager.cpp.
Referenced by esengine::rm_texturesAwaitingReupload().
| u32 esengine::resource::ResourceManager::getTextureRefCount | ( | TextureHandle | handle | ) | const |
Gets the current reference count for a texture.
| handle | The texture handle |
Definition at line 323 of file ResourceManager.cpp.
Referenced by esengine::rm_getTextureRefCount().
| VertexBuffer * esengine::resource::ResourceManager::getVertexBuffer | ( | VertexBufferHandle | handle | ) |
Gets a vertex buffer by handle.
| handle | The buffer handle |
Definition at line 525 of file ResourceManager.cpp.
| const VertexBuffer * esengine::resource::ResourceManager::getVertexBuffer | ( | VertexBufferHandle | handle | ) | const |
Gets a vertex buffer by handle (const).
| handle | The buffer handle |
Definition at line 529 of file ResourceManager.cpp.
| bool esengine::resource::ResourceManager::hasTextureMetadata | ( | TextureHandle | handle | ) | const |
Checks if a texture has metadata.
| handle | The texture handle |
Definition at line 500 of file ResourceManager.cpp.
References esengine::resource::Handle< T >::id(), and esengine::resource::Handle< T >::isValid().
| void esengine::resource::ResourceManager::init | ( | GfxDevice & | device | ) |
Initializes the resource manager.
| device | The graphics device used to create all GPU resources (shaders, textures, buffers). ResourceManager is the GPU-resource factory, so it owns the single device reference the resource classes route through. |
Definition at line 51 of file ResourceManager.cpp.
References device(), and ES_LOG_WARN.
| bool esengine::resource::ResourceManager::invalidateTexturePath | ( | const std::string & | path | ) |
Severs a path's texture-cache identity (hot reload). The next acquireTextureByPath for it misses, so stale bytes are never revived; an evictable entry under that path is freed immediately.
| path | The path to invalidate |
Definition at line 441 of file ResourceManager.cpp.
Referenced by esengine::rm_invalidateTexturePath().
|
inline |
Checks if the manager is initialized.
Definition at line 149 of file ResourceManager.hpp.
| BitmapFontHandle esengine::resource::ResourceManager::loadBitmapFont | ( | const std::string & | fntPath | ) |
Definition at line 1118 of file ResourceManager.cpp.
References ES_LOG_ERROR.
| ShaderHandle esengine::resource::ResourceManager::loadShader | ( | const std::string & | vertPath, |
| const std::string & | fragPath ) |
Loads a shader from file paths (with caching).
| vertPath | Path to vertex shader file |
| fragPath | Path to fragment shader file |
Definition at line 167 of file ResourceManager.cpp.
References esengine::Shader::createFromFile().
| TextureHandle esengine::resource::ResourceManager::loadTexture | ( | const std::string & | path | ) |
Loads a texture from file (with caching).
| path | Path to the image file |
Definition at line 280 of file ResourceManager.cpp.
References ES_LOG_ERROR.
Referenced by esengine::text::BitmapFont::loadFromFntText(), and loadTextureByGUID().
| TextureHandle esengine::resource::ResourceManager::loadTextureByGUID | ( | const std::string & | guid, |
| const std::string & | path ) |
Loads a texture by GUID (with caching).
| guid | Asset GUID from AssetDatabase |
| path | File path to load if not cached |
Definition at line 449 of file ResourceManager.cpp.
References esengine::resource::Handle< T >::isValid(), and loadTexture().
|
inline |
Definition at line 549 of file ResourceManager.hpp.
| std::vector< MeshHandle > esengine::resource::ResourceManager::meshesAwaitingRematerialization | ( | ) | const |
Replayable meshes whose geometry the device is still waiting for.
Read off the device's ledger, so the list empties exactly when a rematerialization has put the geometry back.
Definition at line 944 of file ResourceManager.cpp.
Referenced by esengine::rm_meshesAwaitingRemat().
|
inline |
Changes whenever any mesh is realized (each takes a new Mesh::revision) or released: while it holds, every mesh a reader looked at is the one it was.
Definition at line 562 of file ResourceManager.hpp.
Referenced by esengine::ecs::UISystem::hitInputsChanged().
|
inline |
Definition at line 748 of file ResourceManager.hpp.
|
inline |
The shared mesh pages standing and the bytes they hold, for a profiler.
Definition at line 747 of file ResourceManager.hpp.
| std::vector< ResourceManager::MeshRealization > esengine::resource::ResourceManager::meshRealizations | ( | ) |
Every live mesh, for a recovery criterion to read.
Definition at line 935 of file ResourceManager.cpp.
References esengine::Mesh::hasRealization(), and esengine::resource::Handle< T >::id().
Referenced by esengine::rm_meshRealizations().
|
delete |
References ResourceManager().
|
default |
References ResourceManager(), and device().
| GfxShaderLanguage esengine::resource::ResourceManager::preferredShaderLanguage | ( | ) | const |
The language embedded pipelines must author their sources in.
GLSL when the backend compiles it (the GL device); otherwise the backend's own language (WGSL). Embedded shader creation sites branch on this to pick the .esshader assembly or its WGSL twin — the one seam that keeps plugins backend-agnostic.
Definition at line 103 of file ResourceManager.cpp.
References esengine::GLSL_ES300, and esengine::WGSL.
Referenced by preferredShaderTarget(), esengine::MaterialStore::prepassCoverageProgram(), and esengine::MaterialStore::shadowProgram().
| ShaderTargetLanguage esengine::resource::ResourceManager::preferredShaderTarget | ( | ) | const |
preferredShaderLanguage() as a ShaderParser assembly target.
The other half of the seam: creation sites parse one .esshader (whose WGSL twin rides the same file) and assemble both stages for this target — no per-backend branches.
Definition at line 109 of file ResourceManager.cpp.
References esengine::resource::GLSL_ES300, preferredShaderLanguage(), esengine::WGSL, and esengine::resource::WGSL.
Referenced by esengine::MaterialStore::prepassCoverageProgram(), and esengine::MaterialStore::shadowProgram().
| TextureHandle esengine::resource::ResourceManager::registerExternalTexture | ( | ResourceContent | content, |
| u32 | glTextureId, | ||
| u32 | width, | ||
| u32 | height, | ||
| usize | bytes = 0 ) |
Registers an externally-created GL texture.
| glTextureId | The OpenGL texture ID |
| width | Texture width in pixels |
| height | Texture height in pixels |
| bytes | Actual GPU size for the eviction budget; 0 = estimate as RGBA8 (width × height × 4). Compressed uploads (KTX2 → ASTC/ETC2/S3TC) pass their real block size, 4–8× smaller — billing them as RGBA8 would waste most of the budget. |
Definition at line 327 of file ResourceManager.cpp.
References esengine::Texture::createFromExternalId(), ES_LOG_ERROR, esengine::Invalid, esengine::RGBA8, and esengine::resource::toGfxContent().
Referenced by esengine::rm_registerExternalTexture(), and esengine::rm_registerExternalTextureSized().
| void esengine::resource::ResourceManager::registerTextureWithPath | ( | TextureHandle | handle, |
| const std::string & | path ) |
Registers a texture with a path for cache lookup.
| handle | The texture handle |
| path | The path to associate (used by loadTexture cache) |
Definition at line 399 of file ResourceManager.cpp.
References esengine::resource::Handle< T >::isValid().
Referenced by esengine::rm_registerTextureWithPath().
| void esengine::resource::ResourceManager::releaseBitmapFont | ( | BitmapFontHandle | handle | ) |
Definition at line 1160 of file ResourceManager.cpp.
References esengine::resource::Handle< T >::id(), and esengine::resource::Handle< T >::isValid().
| void esengine::resource::ResourceManager::releaseEnvironment | ( | EnvironmentHandle | handle | ) |
Releases an environment. The atlas is an ordinary texture asset with its own lifetime, so it is NOT released here.
Definition at line 1015 of file ResourceManager.cpp.
References esengine::resource::Handle< T >::id().
| void esengine::resource::ResourceManager::releaseIndexBuffer | ( | IndexBufferHandle | handle | ) |
Releases an index buffer (decrements ref count).
| handle | The buffer handle |
Definition at line 1108 of file ResourceManager.cpp.
References esengine::resource::Handle< T >::id(), and esengine::resource::Handle< T >::isValid().
Referenced by releaseMesh().
| void esengine::resource::ResourceManager::releaseMesh | ( | MeshHandle | handle | ) |
Releases a mesh and the buffers it owns.
Definition at line 969 of file ResourceManager.cpp.
References esengine::Mesh::arenaFirstVertex, esengine::Mesh::arenaPage, esengine::Mesh::edges, esengine::Mesh::firstIndex, esengine::resource::Handle< T >::id(), esengine::Mesh::indexCount, esengine::Mesh::indices, esengine::Invalid, esengine::Mesh::layout, esengine::Mesh::morphTexture, esengine::nextRevision(), releaseIndexBuffer(), esengine::Mesh::vertexCount, and esengine::Mesh::vertices.
Referenced by shutdown().
| void esengine::resource::ResourceManager::releaseProbeVolume | ( | ProbeVolumeHandle | handle | ) |
Releases a probe volume.
Definition at line 1072 of file ResourceManager.cpp.
References esengine::resource::Handle< T >::id().
| void esengine::resource::ResourceManager::releaseShader | ( | ShaderHandle | handle | ) |
Releases a shader (decrements ref count).
| handle | The shader handle |
Definition at line 199 of file ResourceManager.cpp.
References esengine::resource::Handle< T >::id(), and esengine::resource::Handle< T >::isValid().
Referenced by esengine::MaterialStore::prepassCoverageProgram(), esengine::rm_releaseShader(), and esengine::MaterialStore::shadowProgram().
| void esengine::resource::ResourceManager::releaseTexture | ( | TextureHandle | handle | ) |
Releases a texture (decrements ref count).
| handle | The texture handle |
Definition at line 303 of file ResourceManager.cpp.
References esengine::resource::Handle< T >::id(), and esengine::resource::Handle< T >::isValid().
Referenced by releaseTextureByGUID(), and esengine::rm_releaseTexture().
| void esengine::resource::ResourceManager::releaseTextureByGUID | ( | const std::string & | guid | ) |
Releases a texture by GUID.
| guid | Asset GUID |
Definition at line 472 of file ResourceManager.cpp.
References releaseTexture().
| void esengine::resource::ResourceManager::releaseVertexBuffer | ( | VertexBufferHandle | handle | ) |
Releases a vertex buffer (decrements ref count).
| handle | The buffer handle |
Definition at line 533 of file ResourceManager.cpp.
References esengine::resource::Handle< T >::id(), and esengine::resource::Handle< T >::isValid().
| bool esengine::resource::ResourceManager::rematerializeMesh | ( | MeshHandle | target, |
| ConstSpan< u8 > | vertexBytes, | ||
| ConstSpan< u32 > | indices, | ||
| ConstSpan< GfxVertexAttribute > | channels, | ||
| u32 | vertexStride, | ||
| const glm::vec3 & | localMin, | ||
| const glm::vec3 & | localMax, | ||
| ConstSpan< f32 > | inverseBind = {}, | ||
| const MeshMorphSource & | morph = {} ) |
Puts new geometry behind an EXISTING mesh handle.
Same identity, a fresh realization. Re-uploading through createMesh would mint a SECOND handle and leave every component on the dead one. Refuses a host-only mesh; clears the debt only on success.
Definition at line 848 of file ResourceManager.cpp.
References ES_LOG_ERROR, esengine::resource::Handle< T >::id(), esengine::Mesh::recovery, and esengine::SourceReplayable.
Referenced by esengine::mesh_rematerializeFromChannels().
| void esengine::resource::ResourceManager::removeTextureMetadata | ( | TextureHandle | handle | ) |
Removes metadata for a texture.
| handle | The texture handle |
Definition at line 505 of file ResourceManager.cpp.
References esengine::resource::Handle< T >::id(), and esengine::resource::Handle< T >::isValid().
| void esengine::resource::ResourceManager::resetCacheStats | ( | ) |
Resets cache hit/miss counters.
Definition at line 1186 of file ResourceManager.cpp.
| void esengine::resource::ResourceManager::restoreTextureContent | ( | TextureHandle | handle | ) |
Settles an owed texture whose provider wrote the pixels itself.
See GfxDevice::restoreContent — for a JS-side upload straight into the native texture, which the device cannot see.
Definition at line 383 of file ResourceManager.cpp.
References esengine::Texture::getId(), and esengine::GfxOwedContent::Texture.
Referenced by esengine::rm_restoreTextureContent().
| bool esengine::resource::ResourceManager::setMeshClusters | ( | MeshHandle | target, |
| lod::ClusterHierarchy | hierarchy ) |
Uploads geometry that stays on the GPU, drawn from its own buffers.
The frame's transient pool, which every renderable uses today, is rewritten by the CPU each frame — a per-frame re-upload of anything that does not change. The layout travels with the buffers: one whose attribute description lives elsewhere is a rename from garbage. Every caller is a mesh PRODUCER and owes a row in tools/meshProducers.mjs saying how the handles it mints come back after a device generation ends; check-mesh-provenance keeps that census closed in both directions.
| vertexBytes | Raw vertex data, laid out as layout describes. |
| indices | Triangle-list indices into it. |
Gives a realized mesh its cluster hierarchy, which a view then draws it through.
Definition at line 910 of file ResourceManager.cpp.
References esengine::lod::clusterHierarchyValid(), esengine::Mesh::clusters, ES_LOG_ERROR, esengine::resource::Handle< T >::id(), esengine::nextRevision(), esengine::Mesh::revision, and esengine::Mesh::vertexCount.
|
inline |
Whether meshes realized FROM NOW ON also get an edge buffer.
Diagnostic geometry for a wireframe view, off by default because it is a second index buffer per mesh. Set before the assets load: a mesh realized earlier has no edges, and a view that wants them draws it filled.
Definition at line 548 of file ResourceManager.hpp.
| bool esengine::resource::ResourceManager::setMeshSkinChunks | ( | MeshHandle | target, |
| std::vector< MeshSkinChunk > | chunks, | ||
| std::vector< u16 > | bones ) |
Gives a realized skinned mesh the chunks it is drawn in (Mesh::skinChunks).
Definition at line 874 of file ResourceManager.cpp.
References ES_LOG_ERROR, esengine::resource::Handle< T >::id(), esengine::Mesh::indexCount, esengine::Mesh::inverseBind, esengine::Mesh::isSkinned(), esengine::MESH_MAX_BONES, esengine::nextRevision(), esengine::Mesh::revision, esengine::Mesh::skinChunkBones, and esengine::Mesh::skinChunks.
| void esengine::resource::ResourceManager::setRetainedBudget | ( | usize | bytes | ) |
See GfxDevice::setRetainedBudget.
Definition at line 413 of file ResourceManager.cpp.
Referenced by esengine::rm_setRetainedBudget().
|
inline |
Definition at line 229 of file ResourceManager.hpp.
Referenced by esengine::MaterialStore::setResourceManager().
| void esengine::resource::ResourceManager::setTextureBudget | ( | usize | bytes | ) |
Sets the texture pool's resident-byte budget (0 = no eviction). Over budget, refCount==0 textures are evicted oldest-first.
Definition at line 409 of file ResourceManager.cpp.
Referenced by esengine::rm_setTextureBudget().
| void esengine::resource::ResourceManager::setTextureMetadata | ( | TextureHandle | handle, |
| const TextureMetadata & | metadata ) |
Sets metadata for a texture.
| handle | The texture handle |
| metadata | The metadata to associate |
Definition at line 484 of file ResourceManager.cpp.
References esengine::resource::Handle< T >::id(), and esengine::resource::Handle< T >::isValid().
Referenced by esengine::rm_setTextureMetadata().
| void esengine::resource::ResourceManager::shutdown | ( | ) |
Shuts down and releases all resources.
Definition at line 64 of file ResourceManager.cpp.
References ES_LOG_INFO, and releaseMesh().
|
inline |
Moves whenever a texture's metadata (its nine-slice borders and the rest) is set or dropped.
Definition at line 564 of file ResourceManager.hpp.
| u32 esengine::resource::ResourceManager::textureNativeId | ( | TextureHandle | handle | ) | const |
The backend's own name for a texture's object, for a host that writes its pixels itself; 0 when there is none. See GfxDevice::nativeTextureName.
Definition at line 394 of file ResourceManager.cpp.
References esengine::Texture::handle().
Referenced by esengine::rm_getTextureNativeId().
| std::vector< ResourceManager::OwedTexture > esengine::resource::ResourceManager::texturesAwaitingReupload | ( | ) | const |
Definition at line 356 of file ResourceManager.cpp.
References esengine::Texture::getId(), and esengine::GfxOwedContent::Texture.
Referenced by esengine::rm_texturesAwaitingReupload().
| usize esengine::resource::ResourceManager::trimTextureCache | ( | ) |
Frees every evictable cached texture now (memory pressure). Held textures and the budget are untouched.
Definition at line 445 of file ResourceManager.cpp.
Referenced by esengine::rm_trimTextureCache().
| void esengine::resource::ResourceManager::update | ( | ) |
Updates resource manager (processes hot reload, call once per frame).
Definition at line 95 of file ResourceManager.cpp.
| TextureHandle esengine::resource::ResourceManager::wrapDeviceTexture | ( | ::esengine::TextureHandle | texture, |
| u32 | width, | ||
| u32 | height ) |
Names a texture the device holds for another owner (a render target's colour plane) by a resource handle, without taking it over.
Definition at line 342 of file ResourceManager.cpp.
References esengine::Texture::borrow().
Referenced by esengine::rm_wrapDeviceTexture().