Popcorning Guinea Pig
Search Results for

    Show / Hide Table of Contents

    Class AssetRegistry

    Inheritance
    object
    AssetRegistry
    Implements
    IAssetRegistry
    IDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: PopcorningGuineaPig.Engine.Services
    Assembly: PopcorningGuineaPig.Engine.dll
    Syntax
    public class AssetRegistry : IAssetRegistry, IDisposable

    Constructors

    | Edit this page View Source

    AssetRegistry()

    Default constructor — resolves VFS lazily through Instance. Preserves legacy behavior for callers (Game, tests, tools) that construct the registry before any host abstraction exists.

    Declaration
    public AssetRegistry()
    | Edit this page View Source

    AssetRegistry(IVirtualFileSystem?)

    Host-injected constructor. The editor's SceneBridge passes its own VFS so asset loading from a previewed scene routes through the editor's filesystem context instead of falling through to Instance's VFS (story 4-1, AC #3).

    Declaration
    public AssetRegistry(IVirtualFileSystem? vfs)
    Parameters
    Type Name Description
    IVirtualFileSystem vfs

    Methods

    | Edit this page View Source

    Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

    Declaration
    public void Dispose()
    | Edit this page View Source

    EstimateTextureBytes()

    Estimates the total bytes consumed by all registered textures by iterating texture pixel format and dimensions. O(N) over registered textures. Intended for diagnostic snapshots — NOT for the per-frame render loop.

    Declaration
    public long EstimateTextureBytes()
    Returns
    Type Description
    long
    Remarks

    Thread contract: enumerates the underlying texture dictionary. MUST be called on the main thread between frames; concurrent registration will throw InvalidOperationException.

    | Edit this page View Source

    EstimateTextureBytesByScene()

    Returns texture bytes grouped by scene tag (Story 12.3). Untagged assets are aggregated under the empty-string key. O(N) over registered textures — intended for diagnostic snapshots.

    Declaration
    public IReadOnlyDictionary<string, long> EstimateTextureBytesByScene()
    Returns
    Type Description
    IReadOnlyDictionary<string, long>
    Remarks

    Thread contract: enumerates the texture dictionary. Same constraint as EstimateTextureBytes() — main thread, between frames.

    | Edit this page View Source

    EstimateTextureBytesForFormat(int, int, PixelFormat)

    Estimates the bytes consumed by a single texture given its pixel format. Compressed formats round up to the next 4x4 block boundary. Mip levels are intentionally ignored — the asset pipeline does not request mips. Unknown formats fall back to 4 bytes/pixel (RGBA8) and emit a one-time console warning per unknown format value so silent drift becomes visible. Public so editor-side workshop cache estimators (e.g. ThumbnailService, ModelThumbnailRenderer in story 12.3) can reuse the same arithmetic without duplicating the pixel-format table.

    Declaration
    public static long EstimateTextureBytesForFormat(int width, int height, PixelFormat format)
    Parameters
    Type Name Description
    int width
    int height
    PixelFormat format
    Returns
    Type Description
    long
    | Edit this page View Source

    GetAssetCounts()

    Returns the current count of registered assets in each category. O(1) — reads dictionary counts only, no enumeration.

    Declaration
    public AssetCounts GetAssetCounts()
    Returns
    Type Description
    AssetCounts
    Remarks

    Thread contract: registration mutates the internal dictionaries; reads MUST occur on the main thread between frames (i.e., outside any registration path). Concurrent registration on a worker thread will throw InvalidOperationException from the dictionary enumerator in EstimateTextureBytes(); this method is count-only and safer but is documented under the same constraint for consistency.

    | Edit this page View Source

    GetAssetCountsByScene()

    Returns asset counts grouped by scene tag (Story 12.3). The empty-string key holds untagged assets. O(N) over registrations.

    Declaration
    public IReadOnlyDictionary<string, AssetCounts> GetAssetCountsByScene()
    Returns
    Type Description
    IReadOnlyDictionary<string, AssetCounts>
    | Edit this page View Source

    GetAsset<T>(string)

    Declaration
    public T GetAsset<T>(string id) where T : struct
    Parameters
    Type Name Description
    string id
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T
    | Edit this page View Source

    GetFont(string)

    Declaration
    public Font? GetFont(string id)
    Parameters
    Type Name Description
    string id
    Returns
    Type Description
    Font?
    | Edit this page View Source

    GetModelAsset(string)

    Declaration
    public AnimatedModelData? GetModelAsset(string id)
    Parameters
    Type Name Description
    string id
    Returns
    Type Description
    AnimatedModelData
    | Edit this page View Source

    GetShader(string)

    Declaration
    public Shader? GetShader(string id)
    Parameters
    Type Name Description
    string id
    Returns
    Type Description
    Shader?
    | Edit this page View Source

    GetShaderCount()

    Returns the count of registered shaders. Shader GPU memory is opaque to the engine, so byte estimation is intentionally not provided. O(1).

    Declaration
    public int GetShaderCount()
    Returns
    Type Description
    int
    | Edit this page View Source

    GetSoundAsset(string)

    Declaration
    public IAudioSource? GetSoundAsset(string id)
    Parameters
    Type Name Description
    string id
    Returns
    Type Description
    IAudioSource
    | Edit this page View Source

    RegisterAsset(string, string, AssetType)

    Declaration
    public void RegisterAsset(string id, string path, AssetType type)
    Parameters
    Type Name Description
    string id
    string path
    AssetType type
    | Edit this page View Source

    RegisterAsset(string, string, AssetType, string?)

    Registers an asset and tags it with a scene identifier so per-scene memory breakdowns are possible (Story 12.3 Task 1 — diagnostics snapshots report bytes attributed by source scene). When sceneTag is null or empty the asset is treated as untagged ("shared" in snapshot reports). Tags are free-form and chosen by the caller — SceneLoader uses Scene.GetType().Name.

    Declaration
    public void RegisterAsset(string id, string path, AssetType type, string? sceneTag)
    Parameters
    Type Name Description
    string id
    string path
    AssetType type
    string sceneTag
    | Edit this page View Source

    RegisterShader(string, string?, string?)

    Declaration
    public void RegisterShader(string id, string? vertexPath, string? fragmentPath)
    Parameters
    Type Name Description
    string id
    string vertexPath
    string fragmentPath
    | Edit this page View Source

    RegisterShader(string, string?, string?, string?)

    Registers a shader with a scene tag for per-scene attribution. See RegisterAsset(string, string, AssetType, string?) for the tag contract.

    Declaration
    public void RegisterShader(string id, string? vertexPath, string? fragmentPath, string? sceneTag)
    Parameters
    Type Name Description
    string id
    string vertexPath
    string fragmentPath
    string sceneTag

    Implements

    IAssetRegistry
    IDisposable
    • Edit this page
    • View Source
    In this article
    Back to top © 2024 Popcorning Guinea Pig Game Engine. A custom C# game engine for indie developers.