• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2016 Red Hat.
3  * Copyright © 2016 Bas Nieuwenhuizen
4  *
5  * based in part on anv driver which is:
6  * Copyright © 2015 Intel Corporation
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice (including the next
16  * paragraph) shall be included in all copies or substantial portions of the
17  * Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25  * IN THE SOFTWARE.
26  */
27 #ifndef RADV_ACO_SHADER_INFO_H
28 #define RADV_ACO_SHADER_INFO_H
29 
30 /* this will convert from radv shader info to the ACO one. */
31 
32 #include "aco_shader_info.h"
33 
34 #define ASSIGN_FIELD(x) aco_info->x = radv->x
35 #define ASSIGN_FIELD_CP(x) memcpy(&aco_info->x, &radv->x, sizeof(radv->x))
36 
37 static inline void
radv_aco_convert_shader_so_info(struct aco_shader_info * aco_info,const struct radv_shader_info * radv)38 radv_aco_convert_shader_so_info(struct aco_shader_info *aco_info,
39                        const struct radv_shader_info *radv)
40 {
41    ASSIGN_FIELD(so.num_outputs);
42    ASSIGN_FIELD_CP(so.outputs);
43    ASSIGN_FIELD_CP(so.strides);
44    /* enabled_stream_buffers_mask unused */
45 }
46 
47 static inline void
radv_aco_convert_shader_vp_info(struct aco_vp_output_info * aco_info,const struct radv_vs_output_info * radv)48 radv_aco_convert_shader_vp_info(struct aco_vp_output_info *aco_info,
49 				const struct radv_vs_output_info *radv)
50 {
51    ASSIGN_FIELD_CP(vs_output_param_offset);
52    ASSIGN_FIELD(clip_dist_mask);
53    ASSIGN_FIELD(cull_dist_mask);
54    ASSIGN_FIELD(param_exports);
55    ASSIGN_FIELD(prim_param_exports);
56    ASSIGN_FIELD(writes_pointsize);
57    ASSIGN_FIELD(writes_layer);
58    ASSIGN_FIELD(writes_layer_per_primitive);
59    ASSIGN_FIELD(writes_viewport_index);
60    ASSIGN_FIELD(writes_viewport_index_per_primitive);
61    ASSIGN_FIELD(writes_primitive_shading_rate);
62    ASSIGN_FIELD(writes_primitive_shading_rate_per_primitive);
63    ASSIGN_FIELD(export_prim_id);
64    ASSIGN_FIELD(export_clip_dists);
65    /* don't use export params */
66 }
67 
68 #define ASSIGN_OUTINFO(x) radv_aco_convert_shader_vp_info(&aco_info->x.outinfo, &radv->x.outinfo);
69 static inline void
radv_aco_convert_shader_info(struct aco_shader_info * aco_info,const struct radv_shader_info * radv)70 radv_aco_convert_shader_info(struct aco_shader_info *aco_info,
71 			     const struct radv_shader_info *radv)
72 {
73    ASSIGN_FIELD(wave_size);
74    ASSIGN_FIELD(is_ngg);
75    ASSIGN_FIELD(has_ngg_culling);
76    ASSIGN_FIELD(has_ngg_early_prim_export);
77    ASSIGN_FIELD(num_tess_patches);
78    ASSIGN_FIELD(workgroup_size);
79    ASSIGN_OUTINFO(vs);
80    ASSIGN_FIELD(vs.as_es);
81    ASSIGN_FIELD(vs.as_ls);
82    ASSIGN_FIELD(vs.tcs_in_out_eq);
83    ASSIGN_FIELD(vs.tcs_temp_only_input_mask);
84    ASSIGN_FIELD(vs.use_per_attribute_vb_descs);
85    ASSIGN_FIELD(vs.vb_desc_usage_mask);
86    ASSIGN_FIELD(vs.has_prolog);
87    ASSIGN_FIELD(vs.dynamic_inputs);
88    ASSIGN_FIELD_CP(gs.output_usage_mask);
89    ASSIGN_FIELD_CP(gs.num_stream_output_components);
90    ASSIGN_FIELD_CP(gs.output_streams);
91    ASSIGN_FIELD(gs.vertices_out);
92    ASSIGN_FIELD(tcs.num_lds_blocks);
93    ASSIGN_OUTINFO(tes);
94    ASSIGN_FIELD(tes.as_es);
95    ASSIGN_FIELD(ps.writes_z);
96    ASSIGN_FIELD(ps.writes_stencil);
97    ASSIGN_FIELD(ps.writes_sample_mask);
98    ASSIGN_FIELD(ps.has_epilog);
99    ASSIGN_FIELD(ps.num_interp);
100    ASSIGN_FIELD(ps.spi_ps_input);
101    ASSIGN_FIELD(cs.subgroup_size);
102    ASSIGN_OUTINFO(ms);
103    radv_aco_convert_shader_so_info(aco_info, radv);
104    aco_info->gfx9_gs_ring_lds_size = radv->gs_ring_info.lds_size;
105 }
106 
107 #define ASSIGN_VS_STATE_FIELD(x) aco_info->state.x = radv->state->x
108 #define ASSIGN_VS_STATE_FIELD_CP(x) memcpy(&aco_info->state.x, &radv->state->x, sizeof(radv->state->x))
109 static inline void
radv_aco_convert_vs_prolog_key(struct aco_vs_prolog_key * aco_info,const struct radv_vs_prolog_key * radv)110 radv_aco_convert_vs_prolog_key(struct aco_vs_prolog_key *aco_info,
111 			       const struct radv_vs_prolog_key *radv)
112 {
113    ASSIGN_VS_STATE_FIELD(instance_rate_inputs);
114    ASSIGN_VS_STATE_FIELD(nontrivial_divisors);
115    ASSIGN_VS_STATE_FIELD(post_shuffle);
116    ASSIGN_VS_STATE_FIELD(alpha_adjust_lo);
117    ASSIGN_VS_STATE_FIELD(alpha_adjust_hi);
118    ASSIGN_VS_STATE_FIELD_CP(divisors);
119    ASSIGN_VS_STATE_FIELD_CP(formats);
120    ASSIGN_FIELD(num_attributes);
121    ASSIGN_FIELD(misaligned_mask);
122    ASSIGN_FIELD(is_ngg);
123    ASSIGN_FIELD(next_stage);
124 }
125 
126 static inline void
radv_aco_convert_ps_epilog_key(struct aco_ps_epilog_key * aco_info,const struct radv_ps_epilog_key * radv)127 radv_aco_convert_ps_epilog_key(struct aco_ps_epilog_key *aco_info,
128 			       const struct radv_ps_epilog_key *radv)
129 {
130    ASSIGN_FIELD(spi_shader_col_format);
131    ASSIGN_FIELD(color_is_int8);
132    ASSIGN_FIELD(color_is_int10);
133    ASSIGN_FIELD(enable_mrt_output_nan_fixup);
134 }
135 
136 static inline void
radv_aco_convert_pipe_key(struct aco_stage_input * aco_info,const struct radv_pipeline_key * radv)137 radv_aco_convert_pipe_key(struct aco_stage_input *aco_info,
138                           const struct radv_pipeline_key *radv)
139 {
140    ASSIGN_FIELD(optimisations_disabled);
141    ASSIGN_FIELD(image_2d_view_of_3d);
142    ASSIGN_FIELD(vs.instance_rate_inputs);
143    ASSIGN_FIELD_CP(vs.instance_rate_divisors);
144    ASSIGN_FIELD_CP(vs.vertex_attribute_formats);
145    ASSIGN_FIELD_CP(vs.vertex_attribute_bindings);
146    ASSIGN_FIELD_CP(vs.vertex_attribute_offsets);
147    ASSIGN_FIELD_CP(vs.vertex_attribute_strides);
148    ASSIGN_FIELD_CP(vs.vertex_binding_align);
149    ASSIGN_FIELD(tcs.tess_input_vertices);
150    ASSIGN_FIELD(ps.col_format);
151    ASSIGN_FIELD(ps.num_samples);
152    ASSIGN_FIELD(ps.alpha_to_coverage_via_mrtz);
153 }
154 
155 static inline void
radv_aco_convert_opts(struct aco_compiler_options * aco_info,const struct radv_nir_compiler_options * radv)156 radv_aco_convert_opts(struct aco_compiler_options *aco_info,
157                       const struct radv_nir_compiler_options *radv)
158 {
159    radv_aco_convert_pipe_key(&aco_info->key, &radv->key);
160    ASSIGN_FIELD(robust_buffer_access);
161    ASSIGN_FIELD(dump_shader);
162    ASSIGN_FIELD(dump_preoptir);
163    ASSIGN_FIELD(record_ir);
164    ASSIGN_FIELD(record_stats);
165    ASSIGN_FIELD(has_ls_vgpr_init_bug);
166    ASSIGN_FIELD(wgp_mode);
167    ASSIGN_FIELD(family);
168    ASSIGN_FIELD(gfx_level);
169    ASSIGN_FIELD(address32_hi);
170    ASSIGN_FIELD(debug.func);
171    ASSIGN_FIELD(debug.private_data);
172 }
173 #undef ASSIGN_VS_STATE_FIELD
174 #undef ASSIGN_VS_STATE_FIELD_CP
175 #undef ASSIGN_FIELD
176 #undef ASSIGN_FIELD_CP
177 #undef ASSIGN_OUTINFO
178 
179 #endif
180