Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/drivers/zink/zink_compiler.h
4570 views
1
/*
2
* Copyright 2018 Collabora Ltd.
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
* on the rights to use, copy, modify, merge, publish, distribute, sub
8
* license, and/or sell copies of the Software, and to permit persons to whom
9
* the 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 NON-INFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21
* USE OR OTHER DEALINGS IN THE SOFTWARE.
22
*/
23
24
#ifndef ZINK_COMPILER_H
25
#define ZINK_COMPILER_H
26
27
#include "pipe/p_defines.h"
28
#include "pipe/p_state.h"
29
30
#include "compiler/nir/nir.h"
31
#include "compiler/shader_info.h"
32
#include "util/u_live_shader_cache.h"
33
34
#include <vulkan/vulkan.h>
35
#include "zink_descriptors.h"
36
37
#define ZINK_WORKGROUP_SIZE_X 1
38
#define ZINK_WORKGROUP_SIZE_Y 2
39
#define ZINK_WORKGROUP_SIZE_Z 3
40
41
struct pipe_screen;
42
struct zink_context;
43
struct zink_screen;
44
struct zink_shader_key;
45
struct zink_shader_module;
46
struct zink_gfx_program;
47
48
struct nir_shader_compiler_options;
49
struct nir_shader;
50
51
struct set;
52
53
struct tgsi_token;
54
struct zink_so_info {
55
struct pipe_stream_output_info so_info;
56
unsigned so_info_slots[PIPE_MAX_SO_OUTPUTS];
57
bool have_xfb;
58
};
59
60
61
const void *
62
zink_get_compiler_options(struct pipe_screen *screen,
63
enum pipe_shader_ir ir,
64
enum pipe_shader_type shader);
65
66
struct nir_shader *
67
zink_tgsi_to_nir(struct pipe_screen *screen, const struct tgsi_token *tokens);
68
69
struct zink_shader {
70
struct util_live_shader base;
71
struct nir_shader *nir;
72
73
struct zink_so_info streamout;
74
75
struct {
76
int index;
77
int binding;
78
VkDescriptorType type;
79
unsigned char size;
80
} bindings[ZINK_DESCRIPTOR_TYPES][ZINK_MAX_DESCRIPTORS_PER_TYPE];
81
size_t num_bindings[ZINK_DESCRIPTOR_TYPES];
82
unsigned num_texel_buffers;
83
uint32_t ubos_used; // bitfield of which ubo indices are used
84
uint32_t ssbos_used; // bitfield of which ssbo indices are used
85
struct set *programs;
86
87
union {
88
struct zink_shader *generated; // a generated shader that this shader "owns"
89
bool is_generated; // if this is a driver-created shader (e.g., tcs)
90
};
91
};
92
93
void
94
zink_screen_init_compiler(struct zink_screen *screen);
95
void
96
zink_compiler_assign_io(nir_shader *producer, nir_shader *consumer);
97
VkShaderModule
98
zink_shader_compile(struct zink_screen *screen, struct zink_shader *zs, nir_shader *nir, struct zink_shader_key *key);
99
100
struct zink_shader *
101
zink_shader_create(struct zink_screen *screen, struct nir_shader *nir,
102
const struct pipe_stream_output_info *so_info);
103
104
void
105
zink_shader_finalize(struct pipe_screen *pscreen, void *nirptr, bool optimize);
106
107
void
108
zink_shader_free(struct zink_context *ctx, struct zink_shader *shader);
109
110
struct zink_shader *
111
zink_shader_tcs_create(struct zink_context *ctx, struct zink_shader *vs);
112
113
static inline bool
114
zink_shader_descriptor_is_buffer(struct zink_shader *zs, enum zink_descriptor_type type, unsigned i)
115
{
116
return zs->bindings[type][i].type == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER ||
117
zs->bindings[type][i].type == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
118
}
119
120
#endif
121
122