File: spirv.h

package info (click to toggle)
mpv 0.41.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,404 kB
  • sloc: ansic: 155,875; python: 1,235; sh: 643; javascript: 612; cpp: 468; objc: 302; pascal: 49; xml: 29; makefile: 18
file content (41 lines) | stat: -rw-r--r-- 1,299 bytes parent folder | download | duplicates (5)
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
#pragma once

#include "common/msg.h"
#include "common/common.h"
#include "context.h"

enum glsl_shader {
    GLSL_SHADER_VERTEX,
    GLSL_SHADER_FRAGMENT,
    GLSL_SHADER_COMPUTE,
};

#define SPIRV_NAME_MAX_LEN 32

struct spirv_compiler {
    char name[SPIRV_NAME_MAX_LEN];
    const struct spirv_compiler_fns *fns;
    struct mp_log *log;
    void *priv;

    const char *required_ext; // or NULL
    int glsl_version;         // GLSL version supported
    int compiler_version;     // for cache invalidation, may be left as 0
    int ra_caps;              // RA_CAP_* provided by this implementation, if any
};

struct spirv_compiler_fns {
    // Compile GLSL to SPIR-V, under GL_KHR_vulkan_glsl semantics.
    bool (*compile_glsl)(struct spirv_compiler *spirv, void *tactx,
                         enum glsl_shader type, const char *glsl,
                         struct bstr *out_spirv);

    // Called by spirv_compiler_init / ra_ctx_destroy. These don't need to
    // allocate/free ctx->spirv, that is done by the caller
    bool (*init)(struct ra_ctx *ctx);
    void (*uninit)(struct ra_ctx *ctx); // optional
};

// Initializes ctx->spirv to a valid SPIR-V compiler, or returns false on
// failure. Cleanup will be handled by ra_ctx_destroy.
bool spirv_compiler_init(struct ra_ctx *ctx);