Skip to content

Engine → RHI → shader_library.h

shader_library

Syntax

class CONJURE_API shader_library

Constructors

AccessSignatureDescription
publicexplicit shader_library( create_tag);

Important

Copy constructor and assignment has been deleted.

Destructors

AccessSignatureDescription
public~shader_library();

Variables

AccessNameTypeDefaultDescription
privatemImplstd::unique_ptr<impl>{}

Functions

Public

backend

[[nodiscard]] graphics_backend backend() const noexcept;

The backend whose blob column was selected.

contains

[[nodiscard]] bool contains(
    const shader_key &key) const;

True when an entry with a blob for this backend matches the key (no file access; the lookup key is composed in a heap string, so the call may allocate).

directory

[[nodiscard]] const std::filesystem::path &directory() const noexcept;

The directory index.json was opened from.

entry_count

[[nodiscard]] usize entry_count() const noexcept;

Number of entries in the index, including entries without a blob for this backend.

get

[[nodiscard]] core::result<shader_blob> get(
    const shader_key &key);

Returns the compiled blob, loading it lazily. Fails with core::error_code::NOT_FOUND when no entry matches the key or the entry has no blob for this backend, and IO_FAILURE when the blob file cannot be read or is empty. A returned blob is never empty.

loaded_blob_count

[[nodiscard]] usize loaded_blob_count() const noexcept;

Number of blobs currently loaded in memory.

open

[[nodiscard]] static core::result<std::unique_ptr<shader_library>> open(
    device &device,
    const std::filesystem::path &shaderDirectory);

Opens <shaderDirectory>/index.json and selects the blob set for the device's backend. Fails with core::error_code::NOT_FOUND when the index is missing, IO_FAILURE when it cannot be read and PARSE_FAILURE when it is not valid JSON or not a valid index (the message names the entry).

reload

[[nodiscard]] core::result<void> reload();

Re-reads index.json and drops every cached blob (development hot reload). On failure the previous index stays in effect and the error is returned.