radeonsi: make many shader functions static or move them to .c files

- many non-inline functions are only used in 1 .c file: make them static
- some inline functions are only use in 1 .c file: move them there

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33046>
This commit is contained in:
Marek Olšák 2025-01-01 14:36:26 -05:00 committed by Marge Bot
parent 583348e3b6
commit 03ad2bc782
7 changed files with 36 additions and 56 deletions

View file

@ -8,6 +8,12 @@
#include "si_query.h"
#include "si_shader_internal.h"
static bool gfx10_ngg_writes_user_edgeflags(struct si_shader *shader)
{
return gfx10_has_variable_edgeflags(shader) &&
shader->selector->info.writes_edgeflag;
}
bool gfx10_ngg_export_prim_early(struct si_shader *shader)
{
struct si_shader_selector *sel = shader->selector;

View file

@ -333,8 +333,8 @@ enum
SI_SHADER_MERGED_VERTEX_OR_TESSEVAL_GEOMETRY,
};
void si_add_arg_checked(struct ac_shader_args *args, enum ac_arg_regfile file, unsigned registers,
enum ac_arg_type type, struct ac_arg *arg, unsigned idx)
static void si_add_arg_checked(struct ac_shader_args *args, enum ac_arg_regfile file, unsigned registers,
enum ac_arg_type type, struct ac_arg *arg, unsigned idx)
{
assert(args->arg_count == idx);
ac_add_arg(args, file, registers, type, arg);
@ -767,8 +767,8 @@ static unsigned get_lds_granularity(struct si_screen *screen, gl_shader_stage st
screen->info.gfx_level >= GFX7 ? 512 : 256;
}
bool si_shader_binary_open(struct si_screen *screen, struct si_shader *shader,
struct ac_rtld_binary *rtld)
static bool si_shader_binary_open(struct si_screen *screen, struct si_shader *shader,
struct ac_rtld_binary *rtld)
{
const struct si_shader_selector *sel = shader->selector;
const char *part_elfs[5];
@ -892,8 +892,8 @@ unsigned si_get_shader_prefetch_size(struct si_shader *shader)
return MIN2(max_pref_size, exec_size_gran128);
}
bool si_get_external_symbol(enum amd_gfx_level gfx_level, void *data, const char *name,
uint64_t *value)
static bool si_get_external_symbol(enum amd_gfx_level gfx_level, void *data, const char *name,
uint64_t *value)
{
uint64_t *scratch_va = data;
@ -3318,7 +3318,7 @@ static bool si_shader_select_gs_parts(struct si_screen *sscreen, struct ac_llvm_
* Compute the PS prolog key, which contains all the information needed to
* build the PS prolog function, and set related bits in shader->config.
*/
void si_get_ps_prolog_key(struct si_shader *shader, union si_shader_part_key *key)
static void si_get_ps_prolog_key(struct si_shader *shader, union si_shader_part_key *key)
{
struct si_shader_info *info = &shader->selector->info;
@ -3428,7 +3428,7 @@ void si_get_ps_prolog_key(struct si_shader *shader, union si_shader_part_key *ke
/**
* Check whether a PS prolog is required based on the key.
*/
bool si_need_ps_prolog(const union si_shader_part_key *key)
static bool si_need_ps_prolog(const union si_shader_part_key *key)
{
return key->ps_prolog.colors_read || key->ps_prolog.states.force_persp_sample_interp ||
key->ps_prolog.states.force_linear_sample_interp ||
@ -3443,7 +3443,7 @@ bool si_need_ps_prolog(const union si_shader_part_key *key)
* Compute the PS epilog key, which contains all the information needed to
* build the PS epilog function.
*/
void si_get_ps_epilog_key(struct si_shader *shader, union si_shader_part_key *key)
static void si_get_ps_epilog_key(struct si_shader *shader, union si_shader_part_key *key)
{
struct si_shader_info *info = &shader->selector->info;
memset(key, 0, sizeof(*key));

View file

@ -1068,10 +1068,6 @@ const char *si_get_shader_name(const struct si_shader *shader);
void si_shader_binary_clean(struct si_shader_binary *binary);
struct nir_shader *si_deserialize_shader(struct si_shader_selector *sel);
unsigned si_get_ps_num_interp(struct si_shader *ps);
bool si_shader_binary_open(struct si_screen *screen, struct si_shader *shader,
struct ac_rtld_binary *rtld);
bool si_get_external_symbol(enum amd_gfx_level gfx_level, void *data, const char *name,
uint64_t *value);
unsigned si_get_shader_prefetch_size(struct si_shader *shader);
unsigned si_get_shader_binary_size(struct si_screen *screen, struct si_shader *shader);
@ -1124,16 +1120,6 @@ static inline struct si_shader **si_get_main_shader_part(struct si_shader_select
return &sel->main_shader_part[index];
}
static inline bool si_shader_uses_bindless_samplers(struct si_shader_selector *selector)
{
return selector ? selector->info.uses_bindless_samplers : false;
}
static inline bool si_shader_uses_bindless_images(struct si_shader_selector *selector)
{
return selector ? selector->info.uses_bindless_images : false;
}
static inline bool gfx10_has_variable_edgeflags(struct si_shader *shader)
{
unsigned output_prim = si_get_output_prim_simplified(shader->selector, &shader->key);
@ -1142,12 +1128,6 @@ static inline bool gfx10_has_variable_edgeflags(struct si_shader *shader)
(output_prim == MESA_PRIM_TRIANGLES || output_prim == MESA_PRIM_UNKNOWN);
}
static inline bool gfx10_ngg_writes_user_edgeflags(struct si_shader *shader)
{
return gfx10_has_variable_edgeflags(shader) &&
shader->selector->info.writes_edgeflag;
}
static inline bool si_shader_uses_streamout(const struct si_shader *shader)
{
return shader->selector->stage <= MESA_SHADER_GEOMETRY &&

View file

@ -92,12 +92,7 @@ typedef struct nir_shader nir_shader;
/* si_shader.c */
bool si_is_multi_part_shader(struct si_shader *shader);
bool si_is_merged_shader(struct si_shader *shader);
void si_add_arg_checked(struct ac_shader_args *args, enum ac_arg_regfile file, unsigned registers,
enum ac_arg_type type, struct ac_arg *arg, unsigned idx);
unsigned si_get_max_workgroup_size(const struct si_shader *shader);
bool si_need_ps_prolog(const union si_shader_part_key *key);
void si_get_ps_prolog_key(struct si_shader *shader, union si_shader_part_key *key);
void si_get_ps_epilog_key(struct si_shader *shader, union si_shader_part_key *key);
enum ac_hw_stage si_select_hw_stage(const gl_shader_stage stage, const union si_shader_key *const key,
const enum amd_gfx_level gfx_level);
nir_shader *si_get_prev_stage_nir_shader(struct si_shader *shader,

View file

@ -51,10 +51,10 @@ static void si_diagnostic_handler(LLVMDiagnosticInfoRef di, void *context)
LLVMDisposeMessage(description);
}
bool si_compile_llvm(struct si_screen *sscreen, struct si_shader_binary *binary,
struct ac_shader_config *conf, struct ac_llvm_compiler *compiler,
struct ac_llvm_context *ac, struct util_debug_callback *debug,
gl_shader_stage stage, const char *name)
static bool si_compile_llvm(struct si_screen *sscreen, struct si_shader_binary *binary,
struct ac_shader_config *conf, struct ac_llvm_compiler *compiler,
struct ac_llvm_context *ac, struct util_debug_callback *debug,
gl_shader_stage stage, const char *name)
{
unsigned count = p_atomic_inc_return(&sscreen->num_compilations);
@ -105,10 +105,10 @@ bool si_compile_llvm(struct si_screen *sscreen, struct si_shader_binary *binary,
return ok;
}
void si_llvm_context_init(struct si_shader_context *ctx, struct si_screen *sscreen,
struct ac_llvm_compiler *compiler, unsigned wave_size,
bool exports_color_null, bool exports_mrtz,
enum ac_float_mode float_mode)
static void si_llvm_context_init(struct si_shader_context *ctx, struct si_screen *sscreen,
struct ac_llvm_compiler *compiler, unsigned wave_size,
bool exports_color_null, bool exports_mrtz,
enum ac_float_mode float_mode)
{
memset(ctx, 0, sizeof(*ctx));
ctx->screen = sscreen;
@ -179,7 +179,7 @@ void si_llvm_create_func(struct si_shader_context *ctx, const char *name, LLVMTy
ac_llvm_set_target_features(ctx->main_fn.value, &ctx->ac, false);
}
void si_llvm_create_main_func(struct si_shader_context *ctx)
static void si_llvm_create_main_func(struct si_shader_context *ctx)
{
struct si_shader *shader = ctx->shader;
LLVMTypeRef returns[AC_MAX_ARGS];
@ -216,7 +216,7 @@ void si_llvm_create_main_func(struct si_shader_context *ctx)
}
}
void si_llvm_optimize_module(struct si_shader_context *ctx)
static void si_llvm_optimize_module(struct si_shader_context *ctx)
{
/* Dump LLVM IR before any optimization passes */
if (si_can_dump_shader(ctx->screen, ctx->stage, SI_DUMP_INIT_LLVM_IR))
@ -226,7 +226,7 @@ void si_llvm_optimize_module(struct si_shader_context *ctx)
ac_llvm_optimize_module(ctx->compiler->meo, ctx->ac.module);
}
void si_llvm_dispose(struct si_shader_context *ctx)
static void si_llvm_dispose(struct si_shader_context *ctx)
{
LLVMDisposeModule(ctx->ac.module);
LLVMContextDispose(ctx->ac.context);

View file

@ -41,19 +41,8 @@ static inline struct si_shader_context *si_shader_context_from_abi(struct ac_sha
}
/* si_shader_llvm.c */
bool si_compile_llvm(struct si_screen *sscreen, struct si_shader_binary *binary,
struct ac_shader_config *conf, struct ac_llvm_compiler *compiler,
struct ac_llvm_context *ac, struct util_debug_callback *debug,
gl_shader_stage stage, const char *name);
void si_llvm_context_init(struct si_shader_context *ctx, struct si_screen *sscreen,
struct ac_llvm_compiler *compiler, unsigned wave_size,
bool exports_color_null, bool exports_mrtz,
enum ac_float_mode float_mode);
void si_llvm_create_func(struct si_shader_context *ctx, const char *name, LLVMTypeRef *return_types,
unsigned num_return_elems, unsigned max_workgroup_size);
void si_llvm_create_main_func(struct si_shader_context *ctx);
void si_llvm_optimize_module(struct si_shader_context *ctx);
void si_llvm_dispose(struct si_shader_context *ctx);
LLVMValueRef si_buffer_load_const(struct si_shader_context *ctx, LLVMValueRef resource,
LLVMValueRef offset);
void si_llvm_build_ret(struct si_shader_context *ctx, LLVMValueRef ret);

View file

@ -112,6 +112,16 @@ unsigned si_determine_wave_size(struct si_screen *sscreen, struct si_shader *sha
return 64;
}
static bool si_shader_uses_bindless_samplers(struct si_shader_selector *selector)
{
return selector ? selector->info.uses_bindless_samplers : false;
}
static bool si_shader_uses_bindless_images(struct si_shader_selector *selector)
{
return selector ? selector->info.uses_bindless_images : false;
}
/* SHADER_CACHE */
/**