Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/microsoft/clc/clc_helpers.h
4560 views
1
/*
2
* Copyright © Microsoft Corporation
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice (including the next
12
* paragraph) shall be included in all copies or substantial portions of the
13
* Software.
14
*
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
* IN THE SOFTWARE.
22
*/
23
24
#ifndef CLC_TO_NIR_H
25
#define CLC_TO_NIR_H
26
27
#ifdef __cplusplus
28
extern "C" {
29
#endif
30
31
#include "nir_types.h"
32
33
#include "clc_compiler.h"
34
#include "util/u_string.h"
35
36
#include <assert.h>
37
#include <stddef.h>
38
#include <stdio.h>
39
#include <stdint.h>
40
41
const struct clc_kernel_info *
42
clc_spirv_get_kernels_info(const struct spirv_binary *spvbin,
43
unsigned *num_kernels);
44
45
void
46
clc_free_kernels_info(const struct clc_kernel_info *kernels,
47
unsigned num_kernels);
48
49
int
50
clc_to_spirv(const struct clc_compile_args *args,
51
struct spirv_binary *spvbin,
52
const struct clc_logger *logger);
53
54
int
55
clc_link_spirv_binaries(const struct clc_linker_args *args,
56
struct spirv_binary *dst_bin,
57
const struct clc_logger *logger);
58
59
void
60
clc_dump_spirv(const struct spirv_binary *spvbin, FILE *f);
61
62
void
63
clc_free_spirv_binary(struct spirv_binary *spvbin);
64
65
#define clc_log(logger, level, fmt, ...) do { \
66
if (!logger || !logger->level) break; \
67
char *_msg = NULL; \
68
asprintf(&_msg, fmt, ##__VA_ARGS__); \
69
assert(_msg); \
70
logger->level(logger->priv, _msg); \
71
free(_msg); \
72
} while (0)
73
74
#define clc_error(logger, fmt, ...) clc_log(logger, error, fmt, ##__VA_ARGS__)
75
#define clc_warning(logger, fmt, ...) clc_log(logger, warning, fmt, ##__VA_ARGS__)
76
77
#ifdef __cplusplus
78
}
79
#endif
80
81
#endif
82
83