mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-19 08:10:32 +01:00
asahi,agx: Plumb libagx
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25498>
This commit is contained in:
parent
0be124b77e
commit
eecd8390d0
7 changed files with 44 additions and 10 deletions
|
|
@ -2733,6 +2733,22 @@ agx_compile_function_nir(nir_shader *nir, nir_function_impl *impl,
|
|||
return offset;
|
||||
}
|
||||
|
||||
static void
|
||||
link_libagx(nir_shader *nir, const nir_shader *libagx)
|
||||
{
|
||||
nir_link_shader_functions(nir, libagx);
|
||||
NIR_PASS_V(nir, nir_inline_functions);
|
||||
NIR_PASS_V(nir, nir_remove_non_entrypoints);
|
||||
NIR_PASS_V(nir, nir_lower_vars_to_explicit_types, nir_var_function_temp,
|
||||
glsl_get_cl_type_size_align);
|
||||
NIR_PASS_V(nir, nir_opt_deref);
|
||||
NIR_PASS_V(nir, nir_lower_vars_to_ssa);
|
||||
NIR_PASS_V(nir, nir_lower_explicit_io,
|
||||
nir_var_shader_temp | nir_var_function_temp | nir_var_mem_shared |
|
||||
nir_var_mem_global,
|
||||
nir_address_format_62bit_generic);
|
||||
}
|
||||
|
||||
/*
|
||||
* Preprocess NIR. In particular, this lowers I/O. Drivers should call this
|
||||
* as soon as they don't need unlowered I/O.
|
||||
|
|
@ -2749,7 +2765,8 @@ agx_compile_function_nir(nir_shader *nir, nir_function_impl *impl,
|
|||
* lowered here to avoid duplicate work with shader variants.
|
||||
*/
|
||||
void
|
||||
agx_preprocess_nir(nir_shader *nir, bool support_lod_bias, bool allow_mediump,
|
||||
agx_preprocess_nir(nir_shader *nir, const nir_shader *libagx,
|
||||
bool support_lod_bias, bool allow_mediump,
|
||||
struct agx_uncompiled_shader_info *out)
|
||||
{
|
||||
if (out)
|
||||
|
|
@ -2800,6 +2817,8 @@ agx_preprocess_nir(nir_shader *nir, bool support_lod_bias, bool allow_mediump,
|
|||
NIR_PASS_V(nir, nir_opt_dce);
|
||||
NIR_PASS_V(nir, agx_nir_lower_texture, support_lod_bias);
|
||||
|
||||
link_libagx(nir, libagx);
|
||||
|
||||
/* Runs before we lower away idiv, to work at all. But runs after lowering
|
||||
* textures, since the cube map array lowering generates division by 6.
|
||||
*/
|
||||
|
|
@ -2860,8 +2879,10 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key,
|
|||
if (nir->info.stage == MESA_SHADER_FRAGMENT)
|
||||
out->tag_write_disable = !nir->info.writes_memory;
|
||||
|
||||
bool needs_libagx = false;
|
||||
|
||||
/* Late tilebuffer lowering creates multisampled image stores */
|
||||
NIR_PASS_V(nir, agx_nir_lower_multisampled_image_store);
|
||||
NIR_PASS(needs_libagx, nir, agx_nir_lower_multisampled_image_store);
|
||||
|
||||
/* Late sysval lowering creates large loads. Load lowering creates unpacks */
|
||||
nir_lower_mem_access_bit_sizes_options lower_mem_access_options = {
|
||||
|
|
@ -2878,7 +2899,10 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key,
|
|||
NIR_PASS_V(nir, nir_lower_load_const_to_scalar);
|
||||
|
||||
if (nir->info.stage == MESA_SHADER_FRAGMENT)
|
||||
NIR_PASS_V(nir, agx_nir_lower_interpolation);
|
||||
NIR_PASS(needs_libagx, nir, agx_nir_lower_interpolation);
|
||||
|
||||
if (needs_libagx)
|
||||
link_libagx(nir, key->libagx);
|
||||
|
||||
/* Late VBO lowering creates constant udiv instructions */
|
||||
NIR_PASS_V(nir, nir_opt_idiv_const, 16);
|
||||
|
|
|
|||
|
|
@ -213,6 +213,9 @@ struct agx_shader_key {
|
|||
*/
|
||||
bool needs_g13x_coherency;
|
||||
|
||||
/* Library routines to link against */
|
||||
const nir_shader *libagx;
|
||||
|
||||
union {
|
||||
struct agx_vs_shader_key vs;
|
||||
struct agx_fs_shader_key fs;
|
||||
|
|
@ -224,8 +227,8 @@ struct agx_shader_key {
|
|||
|
||||
bool agx_nir_lower_texture_early(nir_shader *s);
|
||||
|
||||
void agx_preprocess_nir(nir_shader *nir, bool support_lod_bias,
|
||||
bool allow_mediump,
|
||||
void agx_preprocess_nir(nir_shader *nir, const nir_shader *libagx,
|
||||
bool support_lod_bias, bool allow_mediump,
|
||||
struct agx_uncompiled_shader_info *out);
|
||||
|
||||
bool agx_nir_lower_discard_zs_emit(nir_shader *s);
|
||||
|
|
|
|||
|
|
@ -612,8 +612,8 @@ calculate_twiddled_coordinates(nir_builder *b, nir_def *coord,
|
|||
}
|
||||
|
||||
static nir_def *
|
||||
image_texel_address(nir_builder *b, nir_intrinsic_instr *intr,
|
||||
bool return_index)
|
||||
image_texel_address(nir_builder *b, const nir_shader *libagx,
|
||||
nir_intrinsic_instr *intr, bool return_index)
|
||||
{
|
||||
/* First, calculate the address of the PBE descriptor */
|
||||
nir_def *desc_address =
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ idep_agx_builder_h = declare_dependency(
|
|||
|
||||
libasahi_compiler = static_library(
|
||||
'asahi_compiler',
|
||||
[libasahi_agx_files, agx_opcodes_c, agx_nir_algebraic_c],
|
||||
[libasahi_agx_files, libagx_shaders, agx_opcodes_c, agx_nir_algebraic_c],
|
||||
dependencies: [idep_nir, idep_agx_opcodes_h, idep_agx_builder_h, idep_agx_pack],
|
||||
c_args : [no_override_init_args],
|
||||
gnu_symbol_visibility : 'hidden',
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ agx_compile_meta_shader(struct agx_meta_cache *cache, nir_shader *shader,
|
|||
struct util_dynarray binary;
|
||||
util_dynarray_init(&binary, NULL);
|
||||
|
||||
agx_preprocess_nir(shader, false, false, NULL);
|
||||
agx_preprocess_nir(shader, cache->dev->libagx, false, false, NULL);
|
||||
if (tib) {
|
||||
unsigned bindless_base = 0;
|
||||
agx_nir_lower_tilebuffer(shader, tib, NULL, &bindless_base, NULL, true);
|
||||
|
|
@ -25,6 +25,8 @@ agx_compile_meta_shader(struct agx_meta_cache *cache, nir_shader *shader,
|
|||
shader, &(struct agx_msaa_state){.nr_samples = tib->nr_samples});
|
||||
}
|
||||
|
||||
key->libagx = cache->dev->libagx;
|
||||
|
||||
struct agx_meta_shader *res = rzalloc(cache->ht, struct agx_meta_shader);
|
||||
agx_compile_shader_nir(shader, key, NULL, &binary, &res->info);
|
||||
|
||||
|
|
@ -200,6 +202,7 @@ agx_meta_init(struct agx_meta_cache *cache, struct agx_device *dev)
|
|||
{
|
||||
agx_pool_init(&cache->pool, dev, AGX_BO_EXEC | AGX_BO_LOW_VA, true);
|
||||
cache->ht = _mesa_hash_table_create(NULL, key_hash, key_compare);
|
||||
cache->dev = dev;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -208,4 +211,5 @@ agx_meta_cleanup(struct agx_meta_cache *cache)
|
|||
agx_pool_cleanup(&cache->pool);
|
||||
_mesa_hash_table_destroy(cache->ht, NULL);
|
||||
cache->ht = NULL;
|
||||
cache->dev = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include "pool.h"
|
||||
|
||||
struct agx_meta_cache {
|
||||
struct agx_device *dev;
|
||||
struct agx_pool pool;
|
||||
|
||||
/* Map from agx_meta_key to agx_meta_shader */
|
||||
|
|
|
|||
|
|
@ -1675,6 +1675,7 @@ agx_compile_variant(struct agx_device *dev, struct agx_uncompiled_shader *so,
|
|||
.needs_g13x_coherency = (dev->params.gpu_generation == 13 &&
|
||||
dev->params.num_clusters_total > 1) ||
|
||||
dev->params.num_dies > 1,
|
||||
.libagx = dev->libagx,
|
||||
};
|
||||
|
||||
if (nir->info.stage == MESA_SHADER_FRAGMENT)
|
||||
|
|
@ -1788,7 +1789,8 @@ agx_shader_initialize(struct agx_device *dev, struct agx_uncompiled_shader *so,
|
|||
}
|
||||
|
||||
bool allow_mediump = !(dev->debug & AGX_DBG_NO16);
|
||||
agx_preprocess_nir(nir, support_lod_bias, allow_mediump, &so->info);
|
||||
agx_preprocess_nir(nir, dev->libagx, support_lod_bias, allow_mediump,
|
||||
&so->info);
|
||||
|
||||
blob_init(&so->serialized_nir);
|
||||
nir_serialize(&so->serialized_nir, nir, true);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue