Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/microsoft/spirv_to_dxil/spirv_to_dxil.h
4564 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 SPIRV_TO_DXIL_H
25
#define SPIRV_TO_DXIL_H
26
27
#include <stdbool.h>
28
#include <stddef.h>
29
#include <stdint.h>
30
31
#ifdef __cplusplus
32
extern "C" {
33
#endif
34
35
// NB: I've copy and pasted some types into this header so we don't have to
36
// include other headers. This will surely break if any of these types change.
37
38
// Copy of gl_shader_stage
39
typedef enum {
40
DXIL_SPIRV_SHADER_NONE = -1,
41
DXIL_SPIRV_SHADER_VERTEX = 0,
42
DXIL_SPIRV_SHADER_TESS_CTRL = 1,
43
DXIL_SPIRV_SHADER_TESS_EVAL = 2,
44
DXIL_SPIRV_SHADER_GEOMETRY = 3,
45
DXIL_SPIRV_SHADER_FRAGMENT = 4,
46
DXIL_SPIRV_SHADER_COMPUTE = 5,
47
DXIL_SPIRV_SHADER_KERNEL = 6,
48
} dxil_spirv_shader_stage;
49
50
// Copy of nir_spirv_const_value
51
typedef union {
52
bool b;
53
float f32;
54
double f64;
55
int8_t i8;
56
uint8_t u8;
57
int16_t i16;
58
uint16_t u16;
59
int32_t i32;
60
uint32_t u32;
61
int64_t i64;
62
uint64_t u64;
63
} dxil_spirv_const_value;
64
65
// Copy of nir_spirv_specialization
66
struct dxil_spirv_specialization {
67
uint32_t id;
68
dxil_spirv_const_value value;
69
bool defined_on_module;
70
};
71
72
/**
73
* Compile a SPIR-V module into DXIL.
74
* \param words SPIR-V module to compile
75
* \param word_count number of words in the SPIR-V module
76
* \param specializations specialization constants to compile with the shader
77
* \param num_specializations number of specialization constants
78
* \param buffer will contain the DXIL bytes on success. Needs to be freed()
79
* \param size length of returned buffer
80
* \return true if compilation succeeded
81
*/
82
bool
83
spirv_to_dxil(const uint32_t* words,
84
size_t word_count,
85
struct dxil_spirv_specialization* specializations,
86
unsigned int num_specializations,
87
dxil_spirv_shader_stage stage,
88
const char* entry_point_name,
89
void** buffer,
90
size_t* size);
91
92
/**
93
* Free the buffer allocated by spirv_to_dxil.
94
*/
95
void
96
spirv_to_dxil_free(void* buffer);
97
98
#ifdef __cplusplus
99
}
100
#endif
101
102
#endif
103
104