summaryrefslogtreecommitdiffstats
path: root/src/glsl/glslang.h
blob: a5965a58d18b496e615ee50f5d861f86e12c397e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
 * This file is part of libplacebo.
 *
 * libplacebo is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * libplacebo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with libplacebo. If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include <stdlib.h>
#include <stdbool.h>

typedef struct TLimits TLimits;
typedef struct TBuiltInResource TBuiltInResource;
#include <glslang/Include/ResourceLimits.h>

#ifdef __cplusplus
extern "C" {
#endif

#include "utils.h"

bool pl_glslang_init(void);
void pl_glslang_uninit(void);

struct pl_glslang_res {
    // Compilation status
    bool success;
    const char *error_msg;

    // Compiled shader memory, or NULL
    void *data;
    size_t size;
};

// Compile GLSL into a SPIRV stream, if possible. The resulting
// pl_glslang_res can simply be freed with pl_free() when done.
struct pl_glslang_res *pl_glslang_compile(struct pl_glsl_version glsl_ver,
                                          struct pl_spirv_version spirv_ver,
                                          enum glsl_shader_stage stage,
                                          const char *shader);

extern const TBuiltInResource DefaultTBuiltInResource;

#ifdef __cplusplus
}
#endif