API reference

Types, handles and limits

The small shared types: the handle that names every engine object, the enums and plain structs of rasm/types.h, the window state, the memory stats, and every compile-time limit.

1Handles

CameraHandle index = 3 · generation = 1 index → slot camera list unused camera camera camera camera camera … camera refused 012 345 …3132 ≥ MAX_CAMERAS Each type counts its indices from 1, so slot 0 stays empty and {0, 0} means "no object". A limit of 32 holds 31 live objects. A destroyed object's index comes back, with a new generation.
A handle is an index into one of the engine's lists. It holds no pointer, so it is cheap to copy and to store.
template <typename Tag>
struct Handle
{
    uint64_t index      = 0;
    uint64_t generation = 0;

    [[nodiscard]] bool isValid() const { return generation != 0; }
    bool operator==(const Handle& other) const;
};

The name of an engine object. Tag is an empty struct that makes each kind a different type, so a MeshHandle cannot be passed where a TextureHandle is expected.

index
The slot in the engine's list for that kind of object. Starts at 1.
generation
The generation of the slot when the object was made: 1 the first time, one more each time the slot was reused. 0 for a default-constructed handle.
isValid()
generation != 0. Every create function returns an invalid ({}) handle on failure, so check it.
operator==
Equal when both index and generation are equal.

isValid() does not tell you that the object still exists. The engine does: a call with a handle whose object was destroyed logs an error and does nothing, even when a new object took its index.

struct HandleHash
{
    template <typename Tag>
    std::size_t operator()(const Handle<Tag>& handle) const;
};

A hash for any handle, so handles can be keys: std::unordered_map<TextureHandle, uint32_t, HandleHash>. It combines the hashes of index and generation with hashCombine.

inline std::size_t hashCombine(std::size_t seed, std::size_t value);

Mixes value into seed (the Boost formula with the 64-bit golden ratio). Used by HandleHash and the desc hashes in src/rhi/resource.cpp.

Every handle type

AliasNames, and what makes it
SceneHandlea scene: createScene
EntityHandlean entity: createEntity
MeshHandlea mesh: createMesh, loadMesh, loadGLTF
MaterialHandlea material: createMaterial
LightHandlea light: createLight
CameraHandlea camera: createCamera
TextureHandlea GPU texture: loadTexture, createTexture, render targets, swapchain images
BufferHandlea GPU buffer: createBuffer
RenderTargetHandlean offscreen color + depth target: createRenderTarget
PipelineHandlea graphics or compute pipeline: createPipeline, createComputePipeline
ShaderHandlea compiled shader: createShader
CommandBufferHandlea command buffer: createCommandBuffer; the one being recorded in FrameResources
FenceHandlea timeline fence: createFence
QueryPoolHandletimestamp queries: createTimestampQueryPool
EnvironmentHandlean environment, an HDR sky photo that lights scenes: loadEnvironment
FontHandlea font's distance atlas on the GPU, for labels: createFont
TileHandlea tile record of a TileStreamer: createTile
ReadbackHandlea copy of an image to the CPU, done a few frames later: readFrame, readTexture
PickHandlea question about a view's pixels, answered a few frames later: pick, takePick
ExportHandlea still of a view at any size, drawn over many frames: exportView, getExportProgress
DescriptorSetLayoutHandlea descriptor set layout: createBindlessDescriptorSetLayout
DescriptorPoolHandlea descriptor pool: createDescriptorPool
DescriptorSetHandlea descriptor set: allocateDescriptorSet; the engine's one from getBindlessDescriptorSet
WindowHandlea window the engine draws into, in Window::handle: the main one (getMainWindow, index MAIN_WINDOW_INDEX) or one from addWindow; at most MAX_WINDOWS − 1 at once.
SwapchainHandledeclared, not used
ResourceHandledeclared, not used

Each alias is Handle<XTag> with its own tag: MeshTag, BufferTag, TextureTag, MaterialTag, PipelineTag, CommandBufferTag, FenceTag, SwapchainTag, ShaderTag, SceneTag, EntityTag, CameraTag, WindowTag, ResourceTag, RenderTargetTag, LightTag, DescriptorSetLayoutTag, DescriptorPoolTag, DescriptorSetTag, QueryPoolTag, EnvironmentTag, ReadbackTag. The tags are only declared, never defined.

struct HandleSlot
{
    uint64_t    index       = 0;
    uint64_t    generation  = 0;
};

constexpr uint64_t MAX_HANDLE_GENERATION = UINT32_MAX;

class HandlePool
{
public:
                HandlePool() = default;
    explicit    HandlePool(uint64_t limit, uint64_t maxGeneration = MAX_HANDLE_GENERATION); // indices 1 .. limit - 1

    HandleSlot  allocate();                                         // {0, 0} when every index is in use
    bool        release(uint64_t index, uint64_t generation);       // false for a stale or invalid handle
    bool        isAlive(uint64_t index, uint64_t generation) const;
    uint64_t    size() const;                                       // one past the highest index handed out
    uint64_t    liveCount() const;
};

Where handles come from. Each of the engine's tables has one: the registry's entities, meshes, materials, cameras, lights, scenes, environments and readbacks, and each kind of RenderContext object. Applications never use one: the create functions do.

allocate
The index released last, if there is one (a stack), else a new index. The handle takes the slot's current generation. Index 0 means the pool is full: a pool made with a limit holds at most limit − 1 live indices, which is how the MAX_* limits work.
release
Frees the index and adds 1 to its generation, so every handle made for it before is stale. A slot whose generation reaches maxGeneration (MAX_HANDLE_GENERATION, 232 − 1) is never reused: it costs one index after four billion reuses of it, and every handle fits the C API's 64-bit id (c-api.html).
isAlive
True only for the handle the slot gave out last, while it is not released. Generation 0 is never alive.
size
One past the highest index handed out: a table indexed by handle needs this many rows. Reuse keeps it at the peak number of live objects.

The design, and why it finds a stale handle, is the guide Generational handles.

struct PoolStats
{
    uint32_t     entities                = 0;
    uint32_t     meshes                  = 0;
    uint32_t     materials               = 0;
    uint32_t     lights                  = 0;
    uint32_t     textures                = 0;        // textures and render target attachments
    uint32_t     bindlessTextures        = 0;        // slots of binding 0 held by a texture
    uint64_t     vertices                = 0;        // of EngineConfig::geometryPoolVertices
    uint64_t     indices                 = 0;        // of geometryPoolIndices
    uint64_t     subMeshes               = 0;        // of geometryPoolSubMeshes
    uint64_t     meshlets                = 0;        // of geometryPoolMeshlets
    uint64_t     instances               = 0;        // instance rows, of maxInstances
    uint64_t     animationPoolBytes      = 0;        // of animationPoolBytes
    uint32_t     releasesWaiting         = 0;        // destroyed objects the GPU may still use
    uint64_t     points                  = 0;        // 8 B units of geometryPoolPoints
};

What getPoolStats returns: the live objects, and the used part of each engine-wide pool. A destroyed object's share comes back once the GPU has finished the frames that may use it, so the numbers of a streaming application go up and down but do not grow. Compare them with the EngineConfig sizes to budget.

struct LoadStats
{
    uint32_t     workers                 = 0;
    uint32_t     queued                  = 0;        // jobs that wait for a worker or for the budget
    uint32_t     running                 = 0;
    uint64_t     decodedBytes            = 0;        // of EngineConfig::loadMemoryBudget
    uint64_t     peakDecodedBytes        = 0;        // since the engine started
};

What getLoadStats returns: the load workers now. decodedBytes counts the loads that started and are not uploaded yet: what their jobs hold, and the decoded results that wait for finishLoads. It stays under EngineConfig::loadMemoryBudget, except for one load bigger than the budget, which runs alone. How the pool works: Job systems.

2Enums in rasm/types.h

enum class Format
{
    UNKNOWN,
    R8G8B8A8_UNORM, R8G8B8A8_SRGB, B8G8R8A8_SRGB, R8G8B8_UNORM,
    R16G16B16A16_SFLOAT, R32G32B32_SFLOAT, R32G32B32A32_SFLOAT,
    D24_UNORM_S8_UINT, D32_SFLOAT, D32_SFLOAT_S8_UINT,
    R32G32_SFLOAT, U16_UINT, U32_UINT,
    BC4_UNORM, BC5_UNORM, BC7_UNORM, BC7_SRGB,
    ASTC_4x4_UNORM, ASTC_4x4_SRGB,
    ETC2_R8G8B8A8_UNORM, ETC2_R8G8B8A8_SRGB,
    EAC_R11_UNORM, EAC_R11G11_UNORM,
    R16G16_SFLOAT,
    R16_UNORM,
    R32_SFLOAT,
    R8_UNORM,
    R32G32B32A32_UINT,
};

Texture, attachment and index formats. Each maps to the Vulkan format of the same name (R8G8B8A8_UNORM → VK_FORMAT_R8G8B8A8_UNORM), except the index types.

ValueUsed for
R8G8B8A8_SRGBcolor textures: albedo, emissive. The default of loadTexture. Gets a mip chain.
R8G8B8A8_UNORMdata textures: normal, metallic-roughness, occlusion. Gets a mip chain.
B8G8R8A8_SRGBthe swapchain format RASM asks for; use getSwapchainImageFormat() for the real one
B8G8R8A8_UNORMthe swapchain's second view, which the UI draws through (getSwapchainEncodedFormat())
D32_SFLOATthe engine's depth format; needed by addScenePasses and createPipeline. The only depth format a pass can sample (readDepth)
D24_UNORM_S8_UINT, D32_SFLOAT_S8_UINTdepth + stencil, for pipelines you build yourself
BC7_SRGB, ASTC_4x4_SRGB, ETC2_R8G8B8A8_SRGBblock-compressed color, 16 bytes per 4 × 4 texels. loadTexture picks one for a .ktx2 file in a color slot.
BC7_UNORM, ASTC_4x4_UNORM, ETC2_R8G8B8A8_UNORMblock-compressed data, 16 bytes per 4 × 4 texels
BC5_UNORM, EAC_R11G11_UNORMtwo channels, 16 bytes per 4 × 4: a normal map's x and y (the shader computes z)
BC4_UNORM, EAC_R11_UNORMone channel, 8 bytes per 4 × 4
R16G16B16A16_SFLOATthe scene color target and environment images
R16G16_SFLOATa scene target's motion color (MOTION_FORMAT), for TAA
R16_UNORM, R32_SFLOATone channel: a terrain tile's heights (TerrainMaterial), one level, filled with fillTexture
R8_UNORMone byte: a font's distance atlas (createFont)
R32G32B32A32_UINTfour 32-bit integers: the pick pass's ids and positions (pick), a color attachment that is never blended
R8G8B8_UNORM, R32G32_SFLOAT, R32G32B32_SFLOAT, R32G32B32A32_SFLOATother texture formats; no engine path uses them.
U16_UINT, U32_UINTindex types for bindIndexBuffer only, not texture formats
UNKNOWNno format (the default in descs; compute pipelines have no attachments)

Color textures must be sRGB and data textures UNORM. Shaders work in linear color, and sampling an sRGB texture converts it. A GPU samples only some of the block-compressed formats: ask supportsTextureFormat, and see texture compression. Only RGBA8 textures get their mips made by fillTexture; the others take every level.

enum class Backend { VULKAN, DX12, METAL, WEBGPU };

EngineConfig::preferredBackend. Only VULKAN exists today. The others log The … backend is not implemented yet., and the engine does not start (running returns false).

enum class ShaderType { VERTEX, FRAGMENT, VERTEX_FRAGMENT, COMPUTE, ALL, TASK, MESH };

A shader stage. ShaderDesc::type is VERTEX, FRAGMENT, COMPUTE, TASK or MESH (the last two only where RenderContext::hasMeshShaders is true). ALL is every stage, for descriptor set layouts: the engine's bindless layout uses it, so compute shaders can sample textures too.

enum class PrimitiveTopology
{
    TRIANGLE_LIST,
    LINE_LIST,
    POINT_LIST,
    TRIANGLE_STRIP,
    LINE_STRIP,
};

How vertices form primitives, in PipelineDesc::topology. Renderer::createPipeline always uses TRIANGLE_LIST; the others need RenderContext::createPipeline.

enum class CullMode { NONE, FRONT, BACK };

Which triangles setCullMode skips. Front faces are counter-clockwise. Each pass starts with NONE. The scene's draw passes pick one per sub-mesh: NONE for a doubleSided or a BLEND material, else BACK, or FRONT when the transform mirrors the mesh.

enum class BlendMode
{
    NONE,
    PREMULTIPLIED_ALPHA,
    ADDITIVE,
    WEIGHTED,
    WEIGHTED_MOTION,
    ADDITIVE_COLOR,
};

How a pipeline's colors mix with what the target holds (PipelineDesc::blendMode).

NONE
The shader's color replaces the target's.
PREMULTIPLIED_ALPHA
result = source + (1 − source alpha) × target, for color and alpha. The shader outputs its color already multiplied by its alpha. This is the "over" operator of see-through (glTF BLEND) draws; see the transparency guide.
ADDITIVE
result = source + target, for color and alpha. Draws that write 1 count the fragments that reach a pixel: the overdraw view does this (Debug views).
WEIGHTED
Color 1 blends as PREMULTIPLIED_ALPHA, every other color as ADDITIVE: the sums and the coverage of weighted blended transparency.
WEIGHTED_MOTION
As WEIGHTED, but color 1's color channels add and only its alpha blends as PREMULTIPLIED_ALPHA: motion sums beside the coverage, with TAA.
ADDITIVE_COLOR
Color 0 blends as ADDITIVE, every other color as PREMULTIPLIED_ALPHA: added light that lays its motion over the motion behind it by its alpha.

WEIGHTED, WEIGHTED_MOTION and ADDITIVE_COLOR blend each color differently, which needs the device's independentBlend feature (RenderContext::hasIndependentBlend).

enum class SwapchainStatus { OK, SUBOPTIMAL, OUT_OF_DATE, FAILURE };

Result of acquire, present and swapchain re-creation.

OK
Done.
SUBOPTIMAL
The image was acquired or presented, but the swapchain should be re-created. The engine finishes the frame and re-creates it at the next beginFrame.
OUT_OF_DATE
The swapchain cannot be used (or the window is 0 × 0) until it is re-created. The engine skips the frame.
FAILURE
An error. When acquiring, the engine skips the frame.

3Plain structs

struct EngineConfig
{
    std::string  appName                 = {};
    PlatformType platform                = PlatformType::SDL;
    int          windowWidth             = 0;
    int          windowHeight            = 0;
    NativeWindow nativeWindow            = {};
    bool         enableValidation        = false;
    bool         enableSyncValidation    = false;
    bool         enableGpuValidation     = false;
    Backend      preferredBackend        = Backend::VULKAN;
    std::string  assetRoot               = {};
    std::string  shaderDir               = {};
    std::string  cacheDir                = "cache";
    uint32_t     shaderThreads           = 0;
    uint32_t     geometryPoolVertices    = 1u << 21;
    uint32_t     geometryPoolColors      = 1u << 20;
    uint32_t     geometryPoolSkins       = 1u << 20;
    uint32_t     geometryPoolMorphs      = 1u << 20;
    uint32_t     geometryPoolIndices     = 1u << 24;
    uint32_t     geometryPoolSubMeshes   = 1u << 14;
    uint32_t     geometryPoolMeshlets    = 1u << 17;
    uint32_t     geometryPoolMeshletData = 1u << 23;
    uint32_t     maxInstances            = 1u << 16;
    uint32_t     maxLights               = 1u << 14;
    uint32_t     maxMaterials            = 1u << 12;
    uint32_t     maxBindlessTextures     = 1u << 14;
    uint32_t     maxAnimatedEntities     = 1u << 14;
    uint32_t     animationPoolBytes      = 16u << 20;
    uint32_t     maxMorphWeights         = 1u << 16;
    uint32_t     loadThreads             = 0;
    uint64_t     loadMemoryBudget        = 512ull << 20;
    bool         showStats               = false;
    float        fixedDeltaTime          = 0.0f;
    bool         occlusionCulling        = true;
    bool         meshLods                = true;
    float        lodErrorPixels          = 1.0f;
    int32_t      forcedLod               = -1;
    MeshletPath  meshletPath             = MeshletPath::AUTO;
    uint32_t     maxViewMeshlets         = 1u << 16;
    bool         asyncCompute            = false;
    bool         transferQueue           = true;
    bool         clusteredLighting       = true;
    bool         hostImageCopy           = true;
    bool         bloom                   = false;
    bool         ui                      = false;
    AntiAliasing antiAliasing            = AntiAliasing::NONE;
    bool         computePoints           = true;
};

The engine's settings, given to its constructor. Every field is explained on the Engine page. A field goes in this struct and in its part's, RendererConfig or AssetLoaderConfig, and into the conversions below.

struct RendererConfig
{
    // every field of EngineConfig but platform, assetRoot, loadThreads and loadMemoryBudget, with the same defaults
};

struct AssetLoaderConfig
{
    std::string  assetRoot               = {};
    uint32_t     loadThreads             = 0;
    uint64_t     loadMemoryBudget        = 512ull << 20;
};

inline RendererConfig    toRendererConfig(const EngineConfig& config);
inline AssetLoaderConfig toAssetLoaderConfig(const EngineConfig& config);
inline EngineConfig      toEngineConfig(const RendererConfig& config, PlatformType platform, const AssetLoaderConfig& loader);

An EngineConfig in its parts. A Renderer's settings are RendererConfig: without platform, which a Renderer does not choose, and without the loading fields. With nativeWindow set it draws into that window; without one it draws into offscreen images of windowWidth × windowHeight pixels. An AssetLoader's are AssetLoaderConfig: the folder relative paths resolve against (itself relative to the executable's folder), the worker threads (0: the hardware's minus one) and the bytes of decoded loads in memory at once. All three structs stay flat, so designated initializers work. Engine's constructor splits its config with toRendererConfig and toAssetLoaderConfig, and Engine::getConfig joins it again with toEngineConfig; tests/rendererConfigTests.cpp checks that every field arrives both ways. A new field goes in EngineConfig, in its part's struct and in the conversions.

enum class PlatformType
{
    SDL,
    HEADLESS,
    NATIVE,
};

Who owns the window and the input (EngineConfig::platform). SDL: the engine opens an SDL3 window and reads its events. HEADLESS: no window and no SDL; each frame renders into an offscreen swapchain of windowWidth × windowHeight pixels, which readFrame copies back. NATIVE: the engine draws into the application's window (EngineConfig::nativeWindow), and the application runs the event loop and sends the input with addInputEvent, setWindowSize and setWindowContentScale. See Engine: your own window, Engine: headless and The platform layer.

enum class NativeWindowType
{
    NONE,
    WINDOWS,
    X11,
    XCB,
    WAYLAND,
    METAL,
};

Which window system a NativeWindow comes from. WINDOWS on Windows, METAL (a CAMetalLayer) on macOS, X11, XCB or WAYLAND on Linux. A type another operating system's build has no surface for makes the engine fail to start, with an error.

enum class AntiAliasing
{
    NONE,
    MSAA_2X,
    MSAA_4X,
    MSAA_8X,
    TAA,
    DEFAULT,    // View::antiAliasing: the EngineConfig value; in EngineConfig, NONE
};

How Renderer::render smooths edges (EngineConfig::antiAliasing, or per view View::antiAliasing, where DEFAULT takes the engine's value). MSAA_nX draws the scene with n samples per pixel and resolves them in a pass of the graph (addMsaaResolvePass); a count the device does not have falls back to the most it has, with a warning. TAA jitters the view and blends the frames (addTaaPass, Temporal anti-aliasing). See MSAA and alpha-to-coverage.

enum class DebugView
{
    NONE,
    NORMALS,
    UVS,
    OVERDRAW,
    LODS,
    CULLING,
    LIGHT_COUNT,
    MESHLETS,
};

What the scene's views show instead of their shading (Renderer::setDebugView). OVERDRAW and LIGHT_COUNT are counts, shown as a heat color. MESHLETS gives each meshlet of a draw drawn by meshlets its own color. See Debug views for what each one shows and the guide for how to read it.

enum class MeshletPath
{
    OFF,
    VERTEX_PULLING,
    MESH_SHADERS,
    AUTO,
};

How the scene passes draw a visible mesh whose LOD has 8 meshlets or more (EngineConfig::meshletPath, Renderer::setMeshletPath). OFF: the whole draw. VERTEX_PULLING: compute culls each meshlet and writes the visible ones as indirect draws, which the usual vertex shader draws. MESH_SHADERS: a task shader culls them inside the draw and mesh shaders draw the visible ones; where the GPU has no mesh shaders (RenderContext::hasMeshShaders, e.g. MoltenVK) it draws by vertex pulling. AUTO, the default: MESH_SHADERS where the GPU has them, else OFF. All draw the same triangles. See Meshlets and cluster culling.

enum class InspectKind
{
    COLOR,
    DEPTH,
    HIZ,
    LIGHT_CLUSTERS,
};

constexpr uint32_t  INSPECT_ALL_SAMPLES     = UINT32_MAX;
constexpr uint32_t  INSPECT_TILES           = 24;

What the RASM window's Buffers section shows of a resource (Renderer::setInspection).

KindReadsShown as
COLORa color of a render targettimes the exposure, clamped to 0..1, or one channel as gray; a MOTION_FORMAT color as a hue for its direction and a strength for its length
DEPTHthe depth of a target a scene view drawsview depth, white at the camera and black at depthRange; an orthographic view's depth as it is
HIZone level of a scene view's Hi-Zlike DEPTH
LIGHT_CLUSTERSa scene view's lights per cluster of one depth slice, or per screen tile (INSPECT_TILES)heat colors on the 16 × 9 tiles

INSPECT_ALL_SAMPLES as Inspection::sample averages a multisampled target's samples. See Inspecting GPU resources.

struct Inspection
{
    std::string  target                  = {};
    InspectKind  kind                    = InspectKind::COLOR;
    uint32_t     attachment              = 0;
    uint32_t     face                    = 0;
    uint32_t     level                   = 0;
    uint32_t     sample                  = 0;
    uint32_t     channel                 = 0;
    float        exposure                = 1.0f;
    float        depthRange              = 50.0f;
    EntityHandle entity                  = {};
};

What the RASM window's Buffers and GPU tables sections show (Renderer::setInspection). Each field is a control of the window.

target
The render target's RenderTargetDesc::name; for HIZ and LIGHT_CLUSTERS the name of the scene view's target. Empty: nothing is copied.
attachment
COLOR: which color of the target.
face
A cube target's face, 0 to 5 (+X, -X, +Y, -Y, +Z, -Z); for HIZ and LIGHT_CLUSTERS the face the view draws.
level
HIZ: the level, 0 is half the view's size. LIGHT_CLUSTERS: the depth slice, 0 to 23, or INSPECT_TILES for the screen tiles.
sample
A multisampled target's sample, or INSPECT_ALL_SAMPLES.
channel
COLOR: 0 all, 1 to 4 red, green, blue or alpha alone, as gray.
exposure
COLOR: the multiplier before the clamp; for motion, the gain (full color at 16 pixels divided by it).
depthRange
DEPTH, HIZ: the view depth shown black.
entity
The GPU tables section shows this entity's rows. Invalid: none.
struct FrameResources
{
    CommandBufferHandle commandBuffer;
    uint64_t            fenceValue          = 0;
    uint64_t            computeFenceValue   = 0;
};

One frame slot's objects, from getCurrentFrameResources.

commandBuffer
The command buffer being recorded right now. Record into it between beginFrame and endFrame. With EngineConfig::asyncCompute a frame has several, one per batch of passes on one queue, and the render graph moves this field between them as passes change queue. So fetch it inside each pass.
fenceValue
The frame fence value that this slot's last graphics submit signals; beginFrame waits for it.
computeFenceValue
The compute fence value that this slot's last compute submit signals. With async compute beginFrame waits for it too. 0 without a compute queue.
struct RenderTargetAttachments
{
    TextureHandle color[rasm::MAX_COLOR_ATTACHMENTS];
    TextureHandle depth;
};

struct RenderTarget
{
    RenderTargetAttachments attachments[rasm::MAX_FRAMES_IN_FLIGHT];
    uint32_t                width;
    uint32_t                height;
    Format                  colorFormats[rasm::MAX_COLOR_ATTACHMENTS];
    uint32_t                colorCount;
    Format                  depthFormat;
    glm::vec4               clearColor;
    bool                    history;
    uint32_t                samples = 1;
    uint32_t                version = 0;
    uint32_t                storageSlots[rasm::MAX_FRAMES_IN_FLIGHT][rasm::MAX_COLOR_ATTACHMENTS] = {};
};

A render target as RenderContext::getRenderTarget returns it: the values of its RenderTargetDesc, plus one RenderTargetAttachments entry (its colors, its depth) per frame slot. Only the first colorCount colors are used. Without history every entry holds the same textures; with it each slot has its own. getRenderTargetTexture(rt, i) picks attachments[slot].color[i] for the current slot, and getPreviousRenderTargetTexture the previous slot's. samples is the desc's samples per pixel; version counts the times its textures were made (a resize, a new placement): they keep their handles but not their contents, so a reader of its history starts over when it changes. storageSlots holds a storage target's slot per frame slot and color (UINT32_MAX for any other target; both frame slots share one without history), which getRenderTargetStorageIndex returns.

struct Swapchain
{
    std::vector<TextureHandle> imageHandles;
    Format                     imageFormat;
    uint32_t                   width  = 0;
    uint32_t                   height = 0;
};

The engine's own copy of the swapchain state (images, format, size in pixels). It is not reachable from outside the engine; use getSwapchainImages, getSwapchainImageFormat and getSwapchainExtent on the RenderContext.

struct TextureRaw
{
    uint32_t                    width  = 0;
    uint32_t                    height = 0;
    Format                      format = Format::UNKNOWN;
    std::vector<unsigned char>  levels;
    std::vector<uint64_t>       levelSizes;
};

A decoded texture with every mip level, made on a worker thread: loadTexture's worker and a glTF import fill it from a PNG or JPEG (the mips made there) or a KTX2 file, and the main thread only copies it into the texture. levels holds the levels one after another, level 0 first, and levelSizes the size of each. levelSizes is empty when decoding failed. Applications do not see it. See texture uploads.

struct EnvironmentRaw
{
    uint32_t                width   = 0;
    uint32_t                height  = 0;
    std::vector<uint16_t>   pixels;
};

A decoded environment image: loadEnvironment's worker thread fills pixels with RGBA half floats (linear, clamped to 65504), and the main thread uploads it. pixels is empty when decoding failed. Applications do not see it.

struct NativeWindow
{
    NativeWindowType type                = NativeWindowType::NONE;
    void*            display             = nullptr;
    void*            window              = nullptr;
    uint32_t         pixelWidth          = 0;
    uint32_t         pixelHeight         = 0;
    float            contentScale        = 1.0f;
};

A window of the application's, for PlatformType::NATIVE (EngineConfig::nativeWindow). RASM makes its surface from the handles and never changes the window. The window must live longer than the engine. The struct has no type of any window system, so the same one serves every backend and a C API.

typedisplaywindow
WINDOWSHINSTANCE, or nullptr for the executable'sHWND
X11Display*the Window id, cast to a pointer
XCBxcb_connection_t*the xcb_window_t, cast to a pointer
WAYLANDwl_display*wl_surface*
METALunusedCAMetalLayer* (from an NSView with a Metal layer, or SDL_Metal_GetLayer)
pixelWidth, pixelHeight
The drawable's size in pixels at the start. 0: the same as windowWidth × windowHeight. Later sizes come from setWindowSize.
contentScale
The display's scale setting (1.5 at 150 %), without the pixel density. It sizes the UI; later changes come from setWindowContentScale.
struct Window
{
    WindowHandle    handle;
    void*           platformWindow  = nullptr;
    NativeWindow    native          = {};
    uint32_t        width           = 0;
    uint32_t        height          = 0;
    uint32_t        pixelWidth      = 0;
    uint32_t        pixelHeight     = 0;
    float           contentScale    = 1.0f;
    bool            resized         = false;
    bool            minimized       = false;
};

The state of a window the engine draws into, read with getMainWindow or getWindow. pollEvents keeps it up to date with SDL; with NATIVE and headless, setWindowSize and setWindowContentScale do. A headless engine's window has no native handle, and its pixel size is its offscreen swapchain's. An engine draws into at most MAX_WINDOWS − 1 (7) windows at once; the main window's handle index is MAIN_WINDOW_INDEX (1).

handle
The engine's handle of the window, on every platform: what addWindow returned, or the main window's.
platformWindow
The SDL platform's SDL_Window; null for NATIVE and headless.
native
The handles the surface is made from: SDL's window's, or EngineConfig::nativeWindow. Type NONE headless.
width, height
Logical size, the units of mouse coordinates.
pixelWidth, pixelHeight
Drawable size in pixels. Larger than width and height on HiDPI displays. The swapchain, the render targets sized from it and the camera aspect follow these. Use them for viewport math, as examples/01_render_graph does.
contentScale
The display's scale setting, which sizes the UI. 1 headless.
resized
The pixel size changed; beginFrame re-creates the swapchain and clears it.
minimized
The window is minimized, or its pixel size is 0: it sits the frames out, and a frame is skipped when no window can show.
struct VRAMStats
{
    uint64_t vramBudget    = 0;
    uint64_t vramUsage     = 0;
    uint64_t vramAllocated = 0;
    uint64_t hostBudget    = 0;
    uint64_t hostUsage     = 0;
};

GPU memory in bytes, summed over the memory heaps, from queryVRAMStats, Renderer::queryMemoryStats or FrameStats::memory.

vramBudget, vramUsage
Device-local heaps (video memory): how much this process may use now, and how much it uses. The usage counts whole memory blocks, and the allocator puts many textures and buffers in one block, so it grows in steps (256 MiB on a large heap).
vramAllocated
The bytes of the resources inside those blocks: what the buffers and textures take. Use it to see what a load or a destroy changed; the stats overlay and the RASM window show it as allocated.
hostBudget, hostUsage
The other heaps (system memory the GPU can reach).
struct Viewport
{
    float x        = 0.0f;
    float y        = 0.0f;
    float width    = 0.0f;
    float height   = 0.0f;
    float minDepth = 0.0f;
    float maxDepth = 1.0f;
};

The last viewport set with setViewport, from getViewport. Pixels, with x, y at the top-left corner.

enum class ReadbackFormat
{
    RGBA8_SRGB,
    RGBA32_FLOAT,
};

What takeReadback converts the copied texels to (rasm/readback.h).

RGBA8_SRGB
4 bytes per pixel, sRGB-encoded: 8-bit sources keep their bytes (BGRA is swizzled), float sources are clamped to 0..1 and encoded. Ready for writePng.
RGBA32_FLOAT
16 bytes per pixel, linear: sRGB sources are decoded, half floats widened. The only format a depth reads as: the depth in red, then 0, 0, 1.
struct ReadbackImage
{
    uint32_t                    width       = 0;
    uint32_t                    height      = 0;
    ReadbackFormat              format      = ReadbackFormat::RGBA8_SRGB;
    std::vector<uint8_t>        pixels;
};

An image copied back by takeReadback: width × height pixels in format, rows from top to bottom, with no padding between them.

bool writePng(const std::string& path, const ReadbackImage& image);

Writes an RGBA8_SRGB image as a PNG file at a UTF-8 path. Returns false (with an error in the log) for an RGBA32_FLOAT image or when the file can't be written.

rasm::ReadbackImage image;
if (engine.takeReadback(copy, image))
    rasm::writePng("screenshot.png", image);
bool readPng(const std::string& path, ReadbackImage& image);

Reads a PNG file at a UTF-8 path into an RGBA8_SRGB image, the format writePng writes, so a frame can be compared with a stored one byte by byte (Image tests). Returns false (with an error in the log) when the file can't be opened or decoded.

rasm::ReadbackImage golden;
if (rasm::readPng("golden.png", golden) && golden.width == image.width)
    std::printf("%zu bytes to compare\n", golden.pixels.size());

4Input events in rasm/input.h

What an application that owns its window sends with Renderer::addInputEvent. RASM's SDL platform makes the same events from its window, so every input reaches the camera, Dear ImGui and the built-in keys the same way (The platform layer). The types are plain: an enum for the kind and plain fields, so a C API can copy them as they are.

struct InputEvent
{
    InputEventType  type            = InputEventType::NONE;
    WindowHandle    window;
    Key             key             = Key::NONE;
    Key             physicalKey     = Key::NONE;
    bool            down            = false;
    bool            repeat          = false;
    uint8_t         modifiers       = 0;
    MouseButton     button          = MouseButton::LEFT;
    float           x               = 0.0f;
    float           y               = 0.0f;
    uint32_t        codepoint       = 0;
    float           dx              = 0.0f;
    float           dy              = 0.0f;
};

One input event. Only the fields its type names are read:

typeFieldsGoes to
KEYkey, physicalKey, down, repeat, modifiersImGui and F1–F3 by key (ImGui by physicalKey when key is NONE); the camera's W/A/S/D by physicalKey
MOUSE_BUTTONbutton, down, x, yImGui; the camera's drag its CameraButtons map gives the button
MOUSE_MOVEx, y, dx, dyImGui by x, y; the camera's drag by dx, dy
MOUSE_WHEELx, y: steps, y > 0 away from the user, x > 0 to the rightImGui; the camera's zoom
MOUSE_LEAVEnoneImGui: no window is hovered
TEXTcodepoint: one Unicode characterImGui's text fields
FOCUSdown: gained, else lostImGui; losing it lets go of every held key and ends the camera's drag
WINDOW_CLOSEnonethe application: the user closed a window other than the main one (the SDL platform sends it; closing the main window quits). Remove it with removeWindow.

Only the main window's events (an invalid window, or the main window's handle) reach ImGui, the built-in keys and the engine's camera input; getInputEvents gives every window's.

window
The window the event happened in (addWindow). The SDL platform sets it; an application that sends another window's events sets it too. Invalid: the main window.
key
The key's meaning in the current keyboard layout: the key that types Z on an AZERTY keyboard is Key::Z.
physicalKey
Where the key is, named after the US layout: the same key is Key::W, so the camera's W/A/S/D keep their places. Key::NONE: the same as key, for an application that knows only one of the two.
x, y
Mouse positions in window points from the top-left corner, the units of EngineConfig::windowWidth.
dx, dy
A move's motion since the last move, in window points. During a mouse grab (setMouseGrab) the pointer stands still and only these move. Both 0: the camera's drag moves by the change of x and y, so a script needs only positions.
engine.addInputEvent({.type = rasm::InputEventType::KEY, .key = rasm::Key::Z, .physicalKey = rasm::Key::W, .down = true});
engine.addInputEvent({.type = rasm::InputEventType::MOUSE_BUTTON, .down = true, .button = rasm::MouseButton::LEFT, .x = 400.0f, .y = 300.0f});
engine.addInputEvent({.type = rasm::InputEventType::TEXT, .codepoint = 0x00E9});
enum class InputEventType : uint8_t
{
    NONE,
    KEY,
    MOUSE_BUTTON,
    MOUSE_MOVE,
    MOUSE_WHEEL,
    MOUSE_LEAVE,
    TEXT,
    FOCUS,
    WINDOW_CLOSE,
};

The kind of an InputEvent, which says which of its fields are read.

enum class Key : uint16_t
{
    NONE,
    A, B, C, /* ... */ Z,
    DIGIT_0, /* ... */ DIGIT_9,
    F1, /* ... */ F12,
    ESCAPE, ENTER, TAB, BACKSPACE, SPACE, INSERT, DEL, HOME, END, PAGE_UP, PAGE_DOWN,
    LEFT, RIGHT, UP, DOWN,
    LEFT_SHIFT, RIGHT_SHIFT, LEFT_CTRL, RIGHT_CTRL, LEFT_ALT, RIGHT_ALT, LEFT_SUPER, RIGHT_SUPER, MENU,
    APOSTROPHE, COMMA, MINUS, PERIOD, SLASH, SEMICOLON, EQUAL, LEFT_BRACKET, BACKSLASH, RIGHT_BRACKET, GRAVE,
    CAPS_LOCK, SCROLL_LOCK, NUM_LOCK, PRINT_SCREEN, PAUSE,
    KEYPAD_0, /* ... */ KEYPAD_9,
    KEYPAD_DECIMAL, KEYPAD_DIVIDE, KEYPAD_MULTIPLY, KEYPAD_SUBTRACT, KEYPAD_ADD, KEYPAD_ENTER, KEYPAD_EQUAL,
    COUNT
};

A key, named after its place on a US keyboard. The same enum names a key's meaning (InputEvent::key) and its position (InputEvent::physicalKey). DEL is the Delete key (DELETE is a macro in <windows.h>). Each key maps to the ImGui key of the same name.

enum class MouseButton : uint8_t
{
    LEFT,
    RIGHT,
    MIDDLE,
    BACK,
    FORWARD,
};

A mouse button, in Dear ImGui's order. BACK and FORWARD are the side buttons (SDL's X1 and X2).

ConstantValueIn InputEvent::modifiers
KEY_MOD_SHIFT1a Shift key is held
KEY_MOD_CTRL2a Ctrl key is held
KEY_MOD_ALT4an Alt key is held
KEY_MOD_SUPER8a Windows or Command key is held

5Constants and limits

All are constexpr in the public headers. Exceeding a create limit logs a warning or error and returns an invalid handle. Because handle indices start at 1, the limits on handle indices hold one live object less than their value. A destroyed object gives its index back; loadMesh keeps the index of a file that does not parse (B13).

Constant and headerValueWhat it limits
MAX_FRAMES_IN_FLIGHT
rasm/types.h
2Frame slots. The CPU records one frame while the GPU runs the other.
MAX_COLOR_ATTACHMENTS
rasm/types.h
4Color attachments of one render target or pipeline. Vulkan guarantees at least 4.
MAX_BINDLESS_TEXTURES
rasm/types.h
65536The most bindless texture slots RendererConfig::maxBindlessTextures may ask for (a slot fits 16 bits), and the slot value that asks for any free slot. The slots the set has: maxBindlessTextures, 16384 by default, lowered with a warning to what the device allows (Vulkan: maxDescriptorSetUpdateAfterBindSampledImages and Samplers, per stage too); the renderer's getConfig gives the count it got. Each loaded texture takes 1. A render target takes 1 per color texture, and 1 per depth texture with EngineConfig::occlusionCulling, on a depth-only target or with a MOTION_FORMAT color; a history target twice that. A destroyed texture's slot is reused once the GPU is done with it.
MAX_DESCRIPTOR_TYPES
rasm/types.h
1Entries in DescriptorPoolDesc::sizes.
MAX_BINDLESS_STORAGE_IMAGES
rasm/types.h
1024Storage image slots, binding 1 of the bindless set: one mip of a texture each, which compute writes (updateBindlessStorageImage). The first RESERVED_STORAGE_IMAGES (32) are the environment bake's, which uses up to 19 of them for one frame at a time. Each color of a storage render target takes one of the others for the target's life; addBloomPasses takes 11. A target that does not fit logs an error that names this limit and is not made. Startup checks it against the device (Vulkan: maxDescriptorSetUpdateAfterBindStorageImages), with an error that names both numbers.
RESERVED_STORAGE_IMAGES
rasm/types.h
32Storage image slots 0 to 31, kept for the environment bake. updateBindlessStorageImage with your own slot must stay out of the storage targets' slots too.
PUSH_CONSTANTS_SIZE
rasm/types.h
16Push constant bytes of every pipeline.
INVALID_TEXTURE_INDEX
rasm/types.h
0xFFFFFFFFNot a limit: the bindless index written for a material slot with no texture. Shaders must not sample it.
EngineConfig::maxMaterials
rasm/types.h
4096Materials alive at once, the engine's default material included. A field, not a constant.
MAX_CAMERAS
rasm/engine.h
32Cameras: 31 fit.
MAX_WINDOWS
rasm/types.h
8Windows an engine draws into at once, the main one included: 7 fit (addWindow). The main window's handle index is MAIN_WINDOW_INDEX (1).
MAX_TONE_MAP_FORMATS
rasm/engine.h
4Output formats the tone-map pass keeps pipelines for: the swapchain's and its view textures' (addToneMapPass). A fifth format logs an error and draws nothing.
MAX_GPU_TIMERS
rasm/engine.h
256GPU timers per frame: the frame, and 255 for passes and beginGpuTimer. FrameStats::gpuTimers has 255 entries.
SCENE_COLOR_FORMAT
rasm/engine.h
Format::R16G16B16A16_SFLOATNot a limit: the color format of a target that addScenePasses draws into, linear light with no upper limit. addToneMapPass brings it to the window.
MOTION_FORMAT
rasm/engine.h
Format::R16G16_SFLOATNot a limit: the format of a scene target's second color, each pixel's motion since the last frame in texture coordinates, which addScenePasses writes and addTaaPass reads.
MAX_ENTITIES
rasm/entity.h
262144 (218)Entities: 262143 fit.
MAX_CLUSTER_LIGHTS
rasm/light.h
256Lights that reach one cluster of a shaded view; more are left out of it (FrameStats::lightsDropped). The number of lights is EngineConfig::maxLights.
MAX_TEXTURE_SLOTS
rasm/material.h
6 (PbrSlot::COUNT)Textures per material, one per PbrSlot.
MAX_PARAM_SLOTS
rasm/material.h
10 (PbrParam::COUNT)Floats in Material::params, indexed by PbrParam.
MAX_VERTEX_UV_SETS
rasm/mesh.h
3UV sets per Vertex. Mirrored in shaders/lib/core.slang.
MAX_MORPH_TARGETS
rasm/mesh.h
256Morph targets per glTF primitive; the rest are dropped with a warning (MorphDelta). Mirrored in shaders/lib/geometryTypes.slang.
MAX_MESH_LODS
rasm/mesh.h
8LODs per sub-mesh, LOD 0 included, so ObjRaw::lods holds at most 7 (MeshLod). Mirrored in shaders/lib/core.slang.
MAX_ENTITIES_PER_SCENE
rasm/scene.h
= MAX_ENTITIESaddEntityToScene per scene.
MAX_CAMERAS_PER_SCENE
rasm/scene.h
32addCameraToScene per scene (31 cameras exist at most, MAX_CAMERAS).
MAX_SCENES
rasm/scene.h
16Scenes: 15 fit.
MAX_SCENE_VIEWS
rasm/scene.h
32Scene views: the (scene, camera, target) sets given to addScenePasses and held by render graphs at once. A graph lets go of its views when it is destroyed or replaced. One more logs an error, and addScenePasses adds nothing and returns false; render(views, count) leaves that view out.
MAX_SHADOW_CASCADES
rasm/scene.h
4Cascades of one shadow (ShadowDesc::cascadeCount). Each cascade is one scene view.
MAX_VIEW_SHADOWS
rasm/scene.h
4Shadows one scene view reads (addScenePasses), each of a different light.

Meshes have no count limit. Mesh, instance and light capacity on the GPU is not a constant: it comes from EngineConfig::geometryPoolVertices, geometryPoolIndices, geometryPoolSubMeshes, maxInstances and maxLights; animation capacity from maxAnimatedEntities, animationPoolBytes and maxMorphWeights.

Known limits

The limits are fixed at compile time and spread over several headers (D15). Every object can be destroyed, and its index, rows, ranges and slots are reused, so the limits count what is alive at once (getPoolStats).