mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-25 00:40:40 +01:00
aco/radv: drop radv_nir_compiler_options from aco.
Add a new aco input and options structs, then convert from radv pieces on submit. Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16521>
This commit is contained in:
parent
8198900071
commit
a179e1aede
11 changed files with 124 additions and 32 deletions
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "aco_builder.h"
|
||||
#include "aco_ir.h"
|
||||
#include "aco_interface.h"
|
||||
|
||||
#include "common/ac_nir.h"
|
||||
#include "common/sid.h"
|
||||
|
|
@ -11375,7 +11376,7 @@ ngg_emit_sendmsg_gs_alloc_req(isel_context* ctx, Temp vtx_cnt, Temp prm_cnt)
|
|||
|
||||
void
|
||||
select_program(Program* program, unsigned shader_count, struct nir_shader* const* shaders,
|
||||
ac_shader_config* config, const struct radv_nir_compiler_options* options,
|
||||
ac_shader_config* config, const struct aco_compiler_options* options,
|
||||
const struct aco_shader_info* info,
|
||||
const struct radv_shader_args* args)
|
||||
{
|
||||
|
|
@ -11503,7 +11504,7 @@ select_program(Program* program, unsigned shader_count, struct nir_shader* const
|
|||
|
||||
void
|
||||
select_gs_copy_shader(Program* program, struct nir_shader* gs_shader, ac_shader_config* config,
|
||||
const struct radv_nir_compiler_options* options,
|
||||
const struct aco_compiler_options* options,
|
||||
const struct aco_shader_info* info,
|
||||
const struct radv_shader_args* args)
|
||||
{
|
||||
|
|
@ -11602,7 +11603,7 @@ select_gs_copy_shader(Program* program, struct nir_shader* gs_shader, ac_shader_
|
|||
|
||||
void
|
||||
select_trap_handler_shader(Program* program, struct nir_shader* shader, ac_shader_config* config,
|
||||
const struct radv_nir_compiler_options* options,
|
||||
const struct aco_compiler_options* options,
|
||||
const struct aco_shader_info* info,
|
||||
const struct radv_shader_args* args)
|
||||
{
|
||||
|
|
@ -11766,7 +11767,7 @@ calc_nontrivial_instance_id(Builder& bld, const struct radv_shader_args* args, u
|
|||
|
||||
void
|
||||
select_vs_prolog(Program* program, const struct aco_vs_prolog_key* key, ac_shader_config* config,
|
||||
const struct radv_nir_compiler_options* options,
|
||||
const struct aco_compiler_options* options,
|
||||
const struct aco_shader_info* info,
|
||||
const struct radv_shader_args* args, unsigned* num_preserved_sgprs)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ struct shader_io_state {
|
|||
};
|
||||
|
||||
struct isel_context {
|
||||
const struct radv_nir_compiler_options* options;
|
||||
const struct aco_compiler_options* options;
|
||||
const struct radv_shader_args* args;
|
||||
Program* program;
|
||||
nir_shader* shader;
|
||||
|
|
@ -116,7 +116,7 @@ void cleanup_context(isel_context* ctx);
|
|||
|
||||
isel_context setup_isel_context(Program* program, unsigned shader_count,
|
||||
struct nir_shader* const* shaders, ac_shader_config* config,
|
||||
const struct radv_nir_compiler_options* options,
|
||||
const struct aco_compiler_options* options,
|
||||
const struct aco_shader_info* info,
|
||||
const struct radv_shader_args* args, bool is_gs_copy_shader);
|
||||
|
||||
|
|
|
|||
|
|
@ -843,7 +843,7 @@ cleanup_context(isel_context* ctx)
|
|||
|
||||
isel_context
|
||||
setup_isel_context(Program* program, unsigned shader_count, struct nir_shader* const* shaders,
|
||||
ac_shader_config* config, const struct radv_nir_compiler_options* options,
|
||||
ac_shader_config* config, const struct aco_compiler_options* options,
|
||||
const struct aco_shader_info* info,
|
||||
const struct radv_shader_args* args, bool is_gs_copy_shader)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ get_disasm_string(aco::Program* program, std::vector<uint32_t>& code,
|
|||
}
|
||||
|
||||
void
|
||||
aco_compile_shader(const struct radv_nir_compiler_options* options,
|
||||
aco_compile_shader(const struct aco_compiler_options* options,
|
||||
const struct aco_shader_info* info,
|
||||
unsigned shader_count, struct nir_shader* const* shaders,
|
||||
const struct radv_shader_args *args,
|
||||
|
|
@ -279,7 +279,7 @@ aco_compile_shader(const struct radv_nir_compiler_options* options,
|
|||
}
|
||||
|
||||
void
|
||||
aco_compile_vs_prolog(const struct radv_nir_compiler_options* options,
|
||||
aco_compile_vs_prolog(const struct aco_compiler_options* options,
|
||||
const struct aco_shader_info* info,
|
||||
const struct aco_vs_prolog_key* key,
|
||||
const struct radv_shader_args* args,
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@
|
|||
|
||||
#include "nir.h"
|
||||
|
||||
#include "amd_family.h"
|
||||
|
||||
#include "aco_shader_info.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -43,13 +46,13 @@ struct aco_compiler_statistic_info {
|
|||
extern const unsigned aco_num_statistics;
|
||||
extern const struct aco_compiler_statistic_info* aco_statistic_infos;
|
||||
|
||||
void aco_compile_shader(const struct radv_nir_compiler_options* options,
|
||||
void aco_compile_shader(const struct aco_compiler_options* options,
|
||||
const struct aco_shader_info* info,
|
||||
unsigned shader_count, struct nir_shader* const* shaders,
|
||||
const struct radv_shader_args *args,
|
||||
struct radv_shader_binary** binary);
|
||||
|
||||
void aco_compile_vs_prolog(const struct radv_nir_compiler_options* options,
|
||||
void aco_compile_vs_prolog(const struct aco_compiler_options* options,
|
||||
const struct aco_shader_info* info,
|
||||
const struct aco_vs_prolog_key* key,
|
||||
const struct radv_shader_args* args,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include "aco_opcodes.h"
|
||||
#include "aco_util.h"
|
||||
|
||||
#include "aco_interface.h"
|
||||
#include "aco_shader_info.h"
|
||||
#include "vulkan/radv_shader.h"
|
||||
|
||||
|
|
@ -2090,7 +2090,7 @@ public:
|
|||
struct {
|
||||
FILE* output = stderr;
|
||||
bool shorten_messages = false;
|
||||
void (*func)(void* private_data, enum radv_compiler_debug_level level, const char* message);
|
||||
void (*func)(void* private_data, enum aco_compiler_debug_level level, const char* message);
|
||||
void* private_data;
|
||||
} debug;
|
||||
|
||||
|
|
@ -2155,21 +2155,21 @@ void init_program(Program* program, Stage stage, const struct aco_shader_info* i
|
|||
ac_shader_config* config);
|
||||
|
||||
void select_program(Program* program, unsigned shader_count, struct nir_shader* const* shaders,
|
||||
ac_shader_config* config, const struct radv_nir_compiler_options* options,
|
||||
ac_shader_config* config, const struct aco_compiler_options* options,
|
||||
const struct aco_shader_info* info,
|
||||
const struct radv_shader_args* args);
|
||||
void select_gs_copy_shader(Program* program, struct nir_shader* gs_shader, ac_shader_config* config,
|
||||
const struct radv_nir_compiler_options* options,
|
||||
const struct aco_compiler_options* options,
|
||||
const struct aco_shader_info* info,
|
||||
const struct radv_shader_args* args);
|
||||
void select_trap_handler_shader(Program* program, struct nir_shader* shader,
|
||||
ac_shader_config* config,
|
||||
const struct radv_nir_compiler_options* options,
|
||||
const struct aco_compiler_options* options,
|
||||
const struct aco_shader_info* info,
|
||||
const struct radv_shader_args* args);
|
||||
void select_vs_prolog(Program* program, const struct aco_vs_prolog_key* key,
|
||||
ac_shader_config* config,
|
||||
const struct radv_nir_compiler_options* options,
|
||||
const struct aco_compiler_options* options,
|
||||
const struct aco_shader_info* info,
|
||||
const struct radv_shader_args* args,
|
||||
unsigned* num_preserved_sgprs);
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ extern "C" {
|
|||
#define ACO_MAX_SO_OUTPUTS 64
|
||||
#define ACO_MAX_SO_BUFFERS 4
|
||||
#define ACO_MAX_VERTEX_ATTRIBS 32
|
||||
#define ACO_MAX_VBS 32
|
||||
|
||||
struct aco_vs_input_state {
|
||||
uint32_t instance_rate_inputs;
|
||||
|
|
@ -139,6 +140,55 @@ struct aco_shader_info {
|
|||
uint32_t gfx9_gs_ring_lds_size;
|
||||
};
|
||||
|
||||
enum aco_compiler_debug_level {
|
||||
ACO_COMPILER_DEBUG_LEVEL_PERFWARN,
|
||||
ACO_COMPILER_DEBUG_LEVEL_ERROR,
|
||||
};
|
||||
|
||||
struct aco_stage_input {
|
||||
uint32_t optimisations_disabled : 1;
|
||||
uint32_t image_2d_view_of_3d : 1;
|
||||
struct {
|
||||
uint32_t instance_rate_inputs;
|
||||
uint32_t instance_rate_divisors[ACO_MAX_VERTEX_ATTRIBS];
|
||||
uint8_t vertex_attribute_formats[ACO_MAX_VERTEX_ATTRIBS];
|
||||
uint32_t vertex_attribute_bindings[ACO_MAX_VERTEX_ATTRIBS];
|
||||
uint32_t vertex_attribute_offsets[ACO_MAX_VERTEX_ATTRIBS];
|
||||
uint32_t vertex_attribute_strides[ACO_MAX_VERTEX_ATTRIBS];
|
||||
uint8_t vertex_binding_align[ACO_MAX_VBS];
|
||||
} vs;
|
||||
|
||||
struct {
|
||||
unsigned tess_input_vertices;
|
||||
} tcs;
|
||||
|
||||
struct {
|
||||
uint32_t col_format;
|
||||
uint8_t num_samples;
|
||||
|
||||
/* Used to export alpha through MRTZ for alpha-to-coverage (GFX11+). */
|
||||
bool alpha_to_coverage_via_mrtz;
|
||||
} ps;
|
||||
};
|
||||
|
||||
struct aco_compiler_options {
|
||||
struct aco_stage_input key;
|
||||
bool robust_buffer_access;
|
||||
bool dump_shader;
|
||||
bool dump_preoptir;
|
||||
bool record_ir;
|
||||
bool record_stats;
|
||||
bool has_ls_vgpr_init_bug;
|
||||
bool wgp_mode;
|
||||
enum radeon_family family;
|
||||
enum amd_gfx_level gfx_level;
|
||||
uint32_t address32_hi;
|
||||
struct {
|
||||
void (*func)(void *private_data, enum aco_compiler_debug_level level, const char *message);
|
||||
void *private_data;
|
||||
} debug;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
namespace aco {
|
||||
|
||||
static void
|
||||
aco_log(Program* program, enum radv_compiler_debug_level level, const char* prefix,
|
||||
aco_log(Program* program, enum aco_compiler_debug_level level, const char* prefix,
|
||||
const char* file, unsigned line, const char* fmt, va_list args)
|
||||
{
|
||||
char* msg;
|
||||
|
|
@ -62,7 +62,7 @@ _aco_perfwarn(Program* program, const char* file, unsigned line, const char* fmt
|
|||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
aco_log(program, RADV_COMPILER_DEBUG_LEVEL_PERFWARN, "ACO PERFWARN:\n", file, line, fmt, args);
|
||||
aco_log(program, ACO_COMPILER_DEBUG_LEVEL_PERFWARN, "ACO PERFWARN:\n", file, line, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ _aco_err(Program* program, const char* file, unsigned line, const char* fmt, ...
|
|||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
aco_log(program, RADV_COMPILER_DEBUG_LEVEL_ERROR, "ACO ERROR:\n", file, line, fmt, args);
|
||||
aco_log(program, ACO_COMPILER_DEBUG_LEVEL_ERROR, "ACO ERROR:\n", file, line, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,11 +121,48 @@ radv_aco_convert_vs_prolog_key(struct aco_vs_prolog_key *aco_info,
|
|||
ASSIGN_FIELD(is_ngg);
|
||||
ASSIGN_FIELD(next_stage);
|
||||
}
|
||||
|
||||
static inline void
|
||||
radv_aco_convert_pipe_key(struct aco_stage_input *aco_info,
|
||||
const struct radv_pipeline_key *radv)
|
||||
{
|
||||
ASSIGN_FIELD(optimisations_disabled);
|
||||
ASSIGN_FIELD(image_2d_view_of_3d);
|
||||
ASSIGN_FIELD(vs.instance_rate_inputs);
|
||||
ASSIGN_FIELD_CP(vs.instance_rate_divisors);
|
||||
ASSIGN_FIELD_CP(vs.vertex_attribute_formats);
|
||||
ASSIGN_FIELD_CP(vs.vertex_attribute_bindings);
|
||||
ASSIGN_FIELD_CP(vs.vertex_attribute_offsets);
|
||||
ASSIGN_FIELD_CP(vs.vertex_attribute_strides);
|
||||
ASSIGN_FIELD_CP(vs.vertex_binding_align);
|
||||
ASSIGN_FIELD(tcs.tess_input_vertices);
|
||||
ASSIGN_FIELD(ps.col_format);
|
||||
ASSIGN_FIELD(ps.num_samples);
|
||||
ASSIGN_FIELD(ps.alpha_to_coverage_via_mrtz);
|
||||
}
|
||||
|
||||
static inline void
|
||||
radv_aco_convert_opts(struct aco_compiler_options *aco_info,
|
||||
const struct radv_nir_compiler_options *radv)
|
||||
{
|
||||
radv_aco_convert_pipe_key(&aco_info->key, &radv->key);
|
||||
ASSIGN_FIELD(robust_buffer_access);
|
||||
ASSIGN_FIELD(dump_shader);
|
||||
ASSIGN_FIELD(dump_preoptir);
|
||||
ASSIGN_FIELD(record_ir);
|
||||
ASSIGN_FIELD(record_stats);
|
||||
ASSIGN_FIELD(has_ls_vgpr_init_bug);
|
||||
ASSIGN_FIELD(wgp_mode);
|
||||
ASSIGN_FIELD(family);
|
||||
ASSIGN_FIELD(gfx_level);
|
||||
ASSIGN_FIELD(address32_hi);
|
||||
ASSIGN_FIELD(debug.func);
|
||||
ASSIGN_FIELD(debug.private_data);
|
||||
}
|
||||
#undef ASSIGN_VS_STATE_FIELD
|
||||
#undef ASSIGN_VS_STATE_FIELD_CP
|
||||
#undef ASSIGN_FIELD
|
||||
#undef ASSIGN_FIELD_CP
|
||||
#undef ASSIGN_OUTINFO
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -275,14 +275,14 @@ radv_spirv_nir_debug(void *private_data, enum nir_spirv_debug_level level, size_
|
|||
}
|
||||
|
||||
static void
|
||||
radv_compiler_debug(void *private_data, enum radv_compiler_debug_level level, const char *message)
|
||||
radv_compiler_debug(void *private_data, enum aco_compiler_debug_level level, const char *message)
|
||||
{
|
||||
struct radv_shader_debug_data *debug_data = private_data;
|
||||
struct radv_instance *instance = debug_data->device->instance;
|
||||
|
||||
static const VkDebugReportFlagsEXT vk_flags[] = {
|
||||
[RADV_COMPILER_DEBUG_LEVEL_PERFWARN] = VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT,
|
||||
[RADV_COMPILER_DEBUG_LEVEL_ERROR] = VK_DEBUG_REPORT_ERROR_BIT_EXT,
|
||||
[ACO_COMPILER_DEBUG_LEVEL_PERFWARN] = VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT,
|
||||
[ACO_COMPILER_DEBUG_LEVEL_ERROR] = VK_DEBUG_REPORT_ERROR_BIT_EXT,
|
||||
};
|
||||
|
||||
/* VK_DEBUG_REPORT_DEBUG_BIT_EXT specifies diagnostic information
|
||||
|
|
@ -2012,8 +2012,10 @@ shader_compile(struct radv_device *device, struct nir_shader *const *shaders, in
|
|||
#endif
|
||||
} else {
|
||||
struct aco_shader_info ac_info;
|
||||
struct aco_compiler_options ac_opts;
|
||||
radv_aco_convert_opts(&ac_opts, options);
|
||||
radv_aco_convert_shader_info(&ac_info, info);
|
||||
aco_compile_shader(options, &ac_info, shader_count, shaders, args, &binary);
|
||||
aco_compile_shader(&ac_opts, &ac_info, shader_count, shaders, args, &binary);
|
||||
}
|
||||
|
||||
binary->info = *info;
|
||||
|
|
@ -2208,9 +2210,11 @@ radv_create_vs_prolog(struct radv_device *device, const struct radv_vs_prolog_ke
|
|||
struct radv_prolog_binary *binary = NULL;
|
||||
struct aco_shader_info ac_info;
|
||||
struct aco_vs_prolog_key ac_key;
|
||||
struct aco_compiler_options ac_opts;
|
||||
radv_aco_convert_shader_info(&ac_info, &info);
|
||||
radv_aco_convert_opts(&ac_opts, &options);
|
||||
radv_aco_convert_vs_prolog_key(&ac_key, key);
|
||||
aco_compile_vs_prolog(&options, &ac_info, &ac_key, &args, &binary);
|
||||
aco_compile_vs_prolog(&ac_opts, &ac_info, &ac_key, &args, &binary);
|
||||
struct radv_shader_prolog *prolog = upload_vs_prolog(device, binary, info.wave_size);
|
||||
if (prolog) {
|
||||
prolog->nontrivial_divisors = key->state->nontrivial_divisors;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@
|
|||
#include "vulkan/runtime/vk_shader_module.h"
|
||||
#include "vulkan/vulkan.h"
|
||||
|
||||
#include "aco_shader_info.h"
|
||||
|
||||
#define RADV_VERT_ATTRIB_MAX MAX2(VERT_ATTRIB_MAX, VERT_ATTRIB_GENERIC0 + MAX_VERTEX_ATTRIBS)
|
||||
|
||||
struct radv_physical_device;
|
||||
|
|
@ -112,11 +114,6 @@ struct radv_pipeline_key {
|
|||
} cs;
|
||||
};
|
||||
|
||||
enum radv_compiler_debug_level {
|
||||
RADV_COMPILER_DEBUG_LEVEL_PERFWARN,
|
||||
RADV_COMPILER_DEBUG_LEVEL_ERROR,
|
||||
};
|
||||
|
||||
struct radv_nir_compiler_options {
|
||||
struct radv_pipeline_key key;
|
||||
bool robust_buffer_access;
|
||||
|
|
@ -134,7 +131,7 @@ struct radv_nir_compiler_options {
|
|||
bool has_3d_cube_border_color_mipmap;
|
||||
|
||||
struct {
|
||||
void (*func)(void *private_data, enum radv_compiler_debug_level level, const char *message);
|
||||
void (*func)(void *private_data, enum aco_compiler_debug_level level, const char *message);
|
||||
void *private_data;
|
||||
} debug;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue