Using it

#include "glslc/glslc.h"

static uint32_t words[SNX_GLSLC_MAX_WORDS];
static GlslcResult result;

/* once for each thread that compiles: glslc allocates nothing, the workspace is all the memory it uses */
GlslcWorkspace workspace;
size_t bytes = snx_glslc_workspace_size();
if (snx_glslc_workspace_init(&workspace, malloc(bytes), bytes, &result) != 0)
    fprintf(stderr, "%s\n", result.error);

/* then for each shader; bind, a binding map, is optional */
GlslcOptions options = {SNX_GLSLC_FRAGMENT, bind, bind_user, 0, 0, 0};
if (snx_glslc_compile(&workspace, &options, source, size, words, SNX_GLSLC_MAX_WORDS, &result) != 0)
    fprintf(stderr, "%u:%u: %s\n", result.line, result.column, result.error);

The library links as snx_glslc. tests/glslc/glslc_cli.c is a small command line around it.


Made from docs/layers/gpu/glslc.md at 69237645142c. GPL-3.0-or-later.