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