nshader

Cross-platform shader compiler and runtime library

View the Project on GitHub luppichristian/nshader

nshader

Cross-platform shader compiler and runtime library. Compiles HLSL shaders to multiple GPU backends (DXIL, DXBC, MSL, SPIR-V) and packages them with reflection metadata into a single binary format.

Built on SDL_shadercross.

Features

Quick Start

# Compile graphics shader
nshader compile shader.hlsl -o shader.nshader \
  --vertex main_vs --fragment main_fs

# Inspect shader
nshader info shader.nshader -v
#include <nshader.h>

// Load at runtime
nshader_t* shader = nshader_read_from_path("shader.nshader");
const nshader_info_t* info = nshader_get_info(shader);

// Get compiled blob for specific backend/stage
const nshader_blob_t* blob = nshader_get_blob(shader,
    NSHADER_STAGE_TYPE_VERTEX, NSHADER_BACKEND_SPV);

nshader_destroy(shader);

Documentation

Header Reference

Header Description
nshader_base.h Memory allocation, format constants
nshader_info.h Types and metadata structures
nshader_compiler.h HLSL compilation
nshader_reader.h Loading shaders
nshader_writer.h Saving shaders
nshader_type.h Core opaque type and accessors
nshader_sdl3_gpu.h SDL3 GPU integration

Source

GitHub Repository