Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/drivers/zink/zink_shader_keys.h
4570 views
1
/*
2
* Copyright 2020 Mike Blumenkrantz
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
25
/** this file exists for organization and to be included in nir_to_spirv/ without pulling in extra deps */
26
#ifndef ZINK_SHADER_KEYS_H
27
# define ZINK_SHADER_KEYS_H
28
29
struct zink_vs_key {
30
bool clip_halfz;
31
bool push_drawid;
32
bool last_vertex_stage;
33
};
34
35
struct zink_fs_key {
36
uint8_t coord_replace_bits;
37
bool coord_replace_yinvert;
38
bool samples;
39
bool force_dual_color_blend;
40
};
41
42
struct zink_tcs_key {
43
unsigned vertices_per_patch;
44
uint64_t vs_outputs_written;
45
};
46
47
struct zink_shader_key_base {
48
uint32_t inlined_uniform_values[MAX_INLINABLE_UNIFORMS];
49
};
50
51
/* a shader key is used for swapping out shader modules based on pipeline states,
52
* e.g., if sampleCount changes, we must verify that the fs doesn't need a recompile
53
* to account for GL ignoring gl_SampleMask in some cases when VK will not
54
* which allows us to avoid recompiling shaders when the pipeline state changes repeatedly
55
*/
56
struct zink_shader_key {
57
union {
58
/* reuse vs key for now with tes/gs since we only use clip_halfz */
59
struct zink_vs_key vs;
60
struct zink_fs_key fs;
61
struct zink_tcs_key tcs;
62
} key;
63
struct zink_shader_key_base base;
64
unsigned inline_uniforms:1;
65
uint32_t size;
66
bool is_default_variant;
67
};
68
69
static inline const struct zink_fs_key *
70
zink_fs_key(const struct zink_shader_key *key)
71
{
72
return &key->key.fs;
73
}
74
75
static inline const struct zink_vs_key *
76
zink_vs_key(const struct zink_shader_key *key)
77
{
78
return &key->key.vs;
79
}
80
81
82
83
#endif
84
85