Module: Mesa Branch: main Commit: 87df607ff5e65040c3c681bc398889395b22f30a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=87df607ff5e65040c3c681bc398889395b22f30a
Author: Dave Airlie <[email protected]> Date: Thu May 5 11:51:50 2022 +1000 aco: move to a minimal aco shader info struct. This should be kept to only things aco uses, and expanded when radeonsi support is added. Things should be removed if lowered in NIR. Reviewed-by: Timur Kristóf <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16342> --- src/amd/compiler/aco_ir.cpp | 4 +- src/amd/compiler/aco_ir.h | 3 +- src/amd/compiler/aco_shader_info.h | 85 +++++++++++++++++++++++++++++++++++ src/amd/vulkan/radv_aco_shader_info.h | 71 +++++++++++++++++++++++++++++ 4 files changed, 161 insertions(+), 2 deletions(-) diff --git a/src/amd/compiler/aco_ir.cpp b/src/amd/compiler/aco_ir.cpp index e1590518ed5..58dfc795e5a 100644 --- a/src/amd/compiler/aco_ir.cpp +++ b/src/amd/compiler/aco_ir.cpp @@ -30,6 +30,8 @@ #include "c11/threads.h" +#include "vulkan/radv_aco_shader_info.h" + namespace aco { uint64_t debug_flags = 0; @@ -71,7 +73,7 @@ init_program(Program* program, Stage stage, const struct radv_shader_info* info, { program->stage = stage; program->config = config; - program->info = *info; + radv_aco_convert_shader_info(&program->info, info); program->chip_class = chip_class; if (family == CHIP_UNKNOWN) { switch (chip_class) { diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h index 2e38e159402..6507be67ed3 100644 --- a/src/amd/compiler/aco_ir.h +++ b/src/amd/compiler/aco_ir.h @@ -28,6 +28,7 @@ #include "aco_opcodes.h" #include "aco_util.h" +#include "aco_shader_info.h" #include "vulkan/radv_shader.h" #include "nir.h" @@ -2053,7 +2054,7 @@ public: std::vector<RegClass> temp_rc = {s1}; RegisterDemand max_reg_demand = RegisterDemand(); ac_shader_config* config; - struct radv_shader_info info; + struct aco_shader_info info; enum chip_class chip_class; enum radeon_family family; DeviceInfo dev; diff --git a/src/amd/compiler/aco_shader_info.h b/src/amd/compiler/aco_shader_info.h new file mode 100644 index 00000000000..2600a6998f8 --- /dev/null +++ b/src/amd/compiler/aco_shader_info.h @@ -0,0 +1,85 @@ +/* + * Copyright © 2016 Red Hat. + * Copyright © 2016 Bas Nieuwenhuizen + * + * based in part on anv driver which is: + * Copyright © 2015 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ +#ifndef ACO_SHADER_INFO_H +#define ACO_SHADER_INFO_H + +#include "shader_enums.h" +/* temporary */ +#include "vulkan/radv_shader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct aco_shader_info { + bool has_ngg_culling; + bool has_ngg_early_prim_export; + uint32_t num_tess_patches; + unsigned workgroup_size; + struct { + struct radv_vs_output_info outinfo; + bool tcs_in_out_eq; + uint64_t tcs_temp_only_input_mask; + bool use_per_attribute_vb_descs; + uint32_t vb_desc_usage_mask; + bool has_prolog; + bool dynamic_inputs; + } vs; + struct { + uint8_t output_usage_mask[VARYING_SLOT_VAR31 + 1]; + uint8_t num_stream_output_components[4]; + uint8_t output_streams[VARYING_SLOT_VAR31 + 1]; + unsigned vertices_out; + } gs; + struct { + uint32_t num_lds_blocks; + } tcs; + struct { + struct radv_vs_output_info outinfo; + } tes; + struct { + bool writes_z; + bool writes_stencil; + bool writes_sample_mask; + uint32_t num_interp; + unsigned spi_ps_input; + } ps; + struct { + uint8_t subgroup_size; + } cs; + struct { + struct radv_vs_output_info outinfo; + } ms; + struct radv_streamout_info so; + + struct gfx9_gs_info gs_ring_info; +}; + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/amd/vulkan/radv_aco_shader_info.h b/src/amd/vulkan/radv_aco_shader_info.h new file mode 100644 index 00000000000..2e1a9a47698 --- /dev/null +++ b/src/amd/vulkan/radv_aco_shader_info.h @@ -0,0 +1,71 @@ +/* + * Copyright © 2016 Red Hat. + * Copyright © 2016 Bas Nieuwenhuizen + * + * based in part on anv driver which is: + * Copyright © 2015 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ +#ifndef RADV_ACO_SHADER_INFO_H +#define RADV_ACO_SHADER_INFO_H + +/* this will convert from radv shader info to the ACO one. */ + +#include "aco_shader_info.h" + +#define ASSIGN_FIELD(x) aco_info->x = radv->x +#define ASSIGN_FIELD_CP(x) memcpy(&aco_info->x, &radv->x, sizeof(radv->x)) + +static inline void +radv_aco_convert_shader_info(struct aco_shader_info *aco_info, + const struct radv_shader_info *radv) +{ + ASSIGN_FIELD(has_ngg_culling); + ASSIGN_FIELD(has_ngg_early_prim_export); + ASSIGN_FIELD(num_tess_patches); + ASSIGN_FIELD(workgroup_size); + ASSIGN_FIELD(vs.outinfo); + ASSIGN_FIELD(vs.tcs_in_out_eq); + ASSIGN_FIELD(vs.tcs_temp_only_input_mask); + ASSIGN_FIELD(vs.use_per_attribute_vb_descs); + ASSIGN_FIELD(vs.vb_desc_usage_mask); + ASSIGN_FIELD(vs.has_prolog); + ASSIGN_FIELD(vs.dynamic_inputs); + ASSIGN_FIELD_CP(gs.output_usage_mask); + ASSIGN_FIELD_CP(gs.num_stream_output_components); + ASSIGN_FIELD_CP(gs.output_streams); + ASSIGN_FIELD(gs.vertices_out); + ASSIGN_FIELD(tcs.num_lds_blocks); + ASSIGN_FIELD(tes.outinfo); + ASSIGN_FIELD(ps.writes_z); + ASSIGN_FIELD(ps.writes_stencil); + ASSIGN_FIELD(ps.writes_sample_mask); + ASSIGN_FIELD(ps.num_interp); + ASSIGN_FIELD(ps.spi_ps_input); + ASSIGN_FIELD(cs.subgroup_size); + ASSIGN_FIELD(ms.outinfo); + ASSIGN_FIELD(so); + ASSIGN_FIELD(gs_ring_info); +} +#undef ASSIGN_FIELD +#undef ASSIGN_FIELD_CP + +#endif
