Skip to content

EntropyCanvas::ShaderClient

Client API for shader operations. More…

#include <ShaderClient.h>

Name
~ShaderClient()
EntropyEngine::Networking::Result< AssetId >uploadShaderSync(const ShaderBundle & bundle, bool persistent =false)
Upload a shader and wait for completion.
std::shared_ptr< UploadShaderHandle >uploadShader(const ShaderBundle & bundle, bool persistent =false)
Upload a custom shader to CanvasEngine.
ShaderClient &operator=(const ShaderClient & ) =delete
boolisBuiltin(const AssetId & id)
Check if an AssetId is a built-in shader.
boolisAvailable(const AssetId & id) const
Check if a shader is available (built-in or uploaded).
std::optional< ShaderMetadata >getMetadata(const AssetId & id) const
Get cached shader metadata.
const char *getBuiltinName(const AssetId & id)
Get the name of a built-in shader (for debugging).
voidfetchShaderInfo(const AssetId & id, std::function< void(bool found, const ShaderMetadata &metadata)> callback)
Request shader info from server (async).
size_tcachedMetadataCount() const
Get number of cached shader metadata entries.
ShaderClient(CanvasClient & canvasClient)
Construct a ShaderClient attached to a CanvasClient.
ShaderClient(const ShaderClient & ) =delete
Name
classCanvasClient
class EntropyCanvas::ShaderClient;

Client API for shader operations.

ShaderClient provides methods for:

  • Uploading custom shaders to CanvasEngine
  • Checking if shaders are built-in or available
  • Caching shader metadata

Security Note: Built-in shaders are identified by AssetId constants in BuiltinShaders. Do NOT use string lookups - use the constants directly.

Usage:

ShaderClient shaders(canvasClient);
// Check if PBR shader is built-in
if (shaders.isBuiltin(Shaders::BuiltinShaders::PBR)) {
// Use built-in PBR shader
material.shaderAssetId = Shaders::BuiltinShaders::PBR;
}
// Upload custom shader
ShaderBundle bundle;
bundle.mainSource = readFile("MyShader.slang");
bundle.metadata.name = "MyCustomShader";
auto handle = shaders.uploadShader(bundle);
handle.wait();
if (handle.success()) {
AssetId shaderId = handle.result();
material.shaderAssetId = shaderId;
}
~ShaderClient()
EntropyEngine::Networking::Result< AssetId > uploadShaderSync(
const ShaderBundle & bundle,
bool persistent =false
)

Upload a shader and wait for completion.

Parameters:

  • bundle Shader bundle with source and metadata
  • persistent If true, shader survives session disconnect

Return: Result with AssetId on success, or error

Convenience method that blocks until the operation completes.

std::shared_ptr< UploadShaderHandle > uploadShader(
const ShaderBundle & bundle,
bool persistent =false
)

Upload a custom shader to CanvasEngine.

Parameters:

  • bundle Shader bundle with source and metadata
  • persistent If true, shader survives session disconnect

Return: Handle to track operation completion

The shader is registered with the server and assigned an AssetId computed from the source content. Identical shaders get the same ID.

ShaderClient & operator=(
const ShaderClient &
) =delete
static inline bool isBuiltin(
const AssetId & id
)

Check if an AssetId is a built-in shader.

Parameters:

Return: True if this is a built-in shader

Delegates to BuiltinShaders::isBuiltin(). Use this for fast O(1) checks.

bool isAvailable(
const AssetId & id
) const

Check if a shader is available (built-in or uploaded).

Parameters:

Return: True if shader is available

std::optional< ShaderMetadata > getMetadata(
const AssetId & id
) const

Get cached shader metadata.

Parameters:

Return: Metadata if cached, nullopt otherwise

static inline const char * getBuiltinName(
const AssetId & id
)

Get the name of a built-in shader (for debugging).

Parameters:

Return: Shader name or “Custom” if not a built-in

void fetchShaderInfo(
const AssetId & id,
std::function< void(bool found, const ShaderMetadata &metadata)> callback
)

Request shader info from server (async).

Parameters:

  • id Shader AssetId
  • callback Called with result

Fetches shader metadata from the server. Useful for checking if a custom shader exists and getting its parameters.

size_t cachedMetadataCount() const

Get number of cached shader metadata entries.

explicit ShaderClient(
CanvasClient & canvasClient
)

Construct a ShaderClient attached to a CanvasClient.

Parameters:

ShaderClient(
const ShaderClient &
) =delete
friend class CanvasClient(
CanvasClient
);

Updated on 2026-01-26 at 17:14:35 -0500