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  * 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 D3D12_NIR_PASSES_H
25 #define D3D12_NIR_PASSES_H
26 
27 #include "nir.h"
28 #include "nir_builder.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 struct d3d12_shader;
35 struct d3d12_image_format_conversion_info;
36 enum d3d12_state_var;
37 
38 nir_ssa_def *
39 d3d12_get_state_var(nir_builder *b,
40                     enum d3d12_state_var var_enum,
41                     const char *var_name,
42                     const struct glsl_type *var_type,
43                     nir_variable **out_var);
44 
45 nir_ssa_def *
46 d3d12_get_state_var(nir_builder *b,
47                     enum d3d12_state_var var_enum,
48                     const char *var_name,
49                     const struct glsl_type *var_type,
50                     nir_variable **out_var);
51 
52 bool
53 d3d12_lower_point_sprite(nir_shader *shader,
54                          bool sprite_origin_lower_left,
55                          bool point_size_per_vertex,
56                          unsigned point_coord_enable,
57                          uint64_t next_inputs_read);
58 
59 bool
60 d3d12_lower_state_vars(struct nir_shader *s, struct d3d12_shader *shader);
61 
62 void
63 d3d12_lower_yflip(nir_shader *s);
64 
65 void
66 d3d12_forward_front_face(nir_shader *nir);
67 
68 void
69 d3d12_lower_depth_range(nir_shader *nir);
70 
71 bool
72 d3d12_lower_load_draw_params(nir_shader *nir);
73 
74 bool
75 d3d12_lower_load_patch_vertices_in(nir_shader *nir);
76 
77 bool
78 d3d12_lower_compute_state_vars(nir_shader *nir);
79 
80 void
81 d3d12_lower_uint_cast(nir_shader *nir, bool is_signed);
82 
83 void
84 d3d12_add_missing_dual_src_target(struct nir_shader *s,
85                                   unsigned missing_mask);
86 
87 bool
88 d3d12_fix_io_uint_type(struct nir_shader *s, uint64_t in_mask, uint64_t out_mask);
89 
90 void
91 d3d12_nir_invert_depth(nir_shader *s, unsigned viewport_mask, bool clip_halfz);
92 
93 bool
94 nir_lower_packed_ubo_loads(struct nir_shader *nir);
95 
96 void
97 d3d12_lower_primitive_id(nir_shader *shader);
98 
99 void
100 d3d12_lower_triangle_strip(nir_shader *shader);
101 
102 bool
103 d3d12_lower_image_casts(nir_shader *s, struct d3d12_image_format_conversion_info *info);
104 
105 bool
106 d3d12_lower_sample_pos(nir_shader *s);
107 
108 bool
109 d3d12_disable_multisampling(nir_shader *s);
110 
111 bool
112 d3d12_split_multistream_varyings(nir_shader *s);
113 
114 void
115 d3d12_write_0_to_new_varying(nir_shader *s, nir_variable *var);
116 
117 #ifdef __cplusplus
118 }
119 #endif
120 
121 #endif // D3D12_NIR_PASSES_H
122