asahi: rename meta -> bg/eot

meta is for making meta gallium calls, we already have something else
appropriately named meta. bg/eot programs are not meta, they're their own
hardware mechanism. use the appropiate powervr name instead.

nfc

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29247>
This commit is contained in:
Alyssa Rosenzweig
2024-04-07 18:38:12 -04:00
parent cd3dabe8e0
commit 06d59d3f5c
7 changed files with 96 additions and 93 deletions
@@ -3,7 +3,7 @@
* SPDX-License-Identifier: MIT
*/
#include "agx_meta.h"
#include "agx_bg_eot.h"
#include "agx_compile.h"
#include "agx_device.h" /* for AGX_MEMORY_TYPE_SHADER */
#include "agx_nir_passes.h"
@@ -26,10 +26,10 @@ lower_tex_handle_to_u0(nir_builder *b, nir_intrinsic_instr *intr, void *data)
return true;
}
static struct agx_meta_shader *
agx_compile_meta_shader(struct agx_meta_cache *cache, nir_shader *shader,
struct agx_shader_key *key,
struct agx_tilebuffer_layout *tib)
static struct agx_bg_eot_shader *
agx_compile_bg_eot_shader(struct agx_bg_eot_cache *cache, nir_shader *shader,
struct agx_shader_key *key,
struct agx_tilebuffer_layout *tib)
{
agx_nir_lower_texture(shader);
agx_preprocess_nir(shader, cache->dev->libagx);
@@ -46,7 +46,7 @@ agx_compile_meta_shader(struct agx_meta_cache *cache, nir_shader *shader,
key->libagx = cache->dev->libagx;
struct agx_meta_shader *res = rzalloc(cache->ht, struct agx_meta_shader);
struct agx_bg_eot_shader *res = rzalloc(cache->ht, struct agx_bg_eot_shader);
struct agx_shader_part bin;
agx_compile_shader_nir(shader, key, NULL, &bin);
@@ -60,10 +60,10 @@ agx_compile_meta_shader(struct agx_meta_cache *cache, nir_shader *shader,
}
static nir_def *
build_background_op(nir_builder *b, enum agx_meta_op op, unsigned rt,
build_background_op(nir_builder *b, enum agx_bg_eot_op op, unsigned rt,
unsigned nr, bool msaa, bool layered)
{
if (op == AGX_META_OP_LOAD) {
if (op == AGX_BG_LOAD) {
nir_def *coord = nir_u2u32(b, nir_load_pixel_coord(b));
if (layered) {
@@ -99,15 +99,15 @@ build_background_op(nir_builder *b, enum agx_meta_op op, unsigned rt,
return nir_trim_vector(b, &tex->def, nr);
} else {
assert(op == AGX_META_OP_CLEAR);
assert(op == AGX_BG_CLEAR);
return nir_load_preamble(b, nr, 32, 4 + (rt * 8));
}
}
static struct agx_meta_shader *
agx_build_background_shader(struct agx_meta_cache *cache,
struct agx_meta_key *key)
static struct agx_bg_eot_shader *
agx_build_background_shader(struct agx_bg_eot_cache *cache,
struct agx_bg_eot_key *key)
{
nir_builder b = nir_builder_init_simple_shader(
MESA_SHADER_FRAGMENT, &agx_nir_options, "agx_background");
@@ -119,7 +119,7 @@ agx_build_background_shader(struct agx_meta_cache *cache,
};
for (unsigned rt = 0; rt < ARRAY_SIZE(key->op); ++rt) {
if (key->op[rt] == AGX_META_OP_NONE)
if (key->op[rt] == AGX_BG_EOT_NONE)
continue;
unsigned nr = util_format_get_nr_components(key->tib.logical_format[rt]);
@@ -137,12 +137,12 @@ agx_build_background_shader(struct agx_meta_cache *cache,
b.shader->info.outputs_written |= BITFIELD64_BIT(FRAG_RESULT_DATA0 + rt);
}
return agx_compile_meta_shader(cache, b.shader, &compiler_key, &key->tib);
return agx_compile_bg_eot_shader(cache, b.shader, &compiler_key, &key->tib);
}
static struct agx_meta_shader *
agx_build_end_of_tile_shader(struct agx_meta_cache *cache,
struct agx_meta_key *key)
static struct agx_bg_eot_shader *
agx_build_end_of_tile_shader(struct agx_bg_eot_cache *cache,
struct agx_bg_eot_key *key)
{
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_COMPUTE,
&agx_nir_options, "agx_eot");
@@ -151,7 +151,7 @@ agx_build_end_of_tile_shader(struct agx_meta_cache *cache,
(key->tib.nr_samples > 1) ? GLSL_SAMPLER_DIM_MS : GLSL_SAMPLER_DIM_2D;
for (unsigned rt = 0; rt < ARRAY_SIZE(key->op); ++rt) {
if (key->op[rt] == AGX_META_OP_NONE)
if (key->op[rt] == AGX_BG_EOT_NONE)
continue;
/* The end-of-tile shader is unsuitable to handle spilled render targets.
@@ -161,7 +161,7 @@ agx_build_end_of_tile_shader(struct agx_meta_cache *cache,
if (key->tib.spilled[rt])
continue;
assert(key->op[rt] == AGX_META_OP_STORE);
assert(key->op[rt] == AGX_EOT_STORE);
unsigned offset_B = agx_tilebuffer_offset_B(&key->tib, rt);
nir_def *layer = nir_undef(&b, 1, 16);
@@ -178,20 +178,21 @@ agx_build_end_of_tile_shader(struct agx_meta_cache *cache,
.reserved_preamble = key->reserved_preamble,
};
return agx_compile_meta_shader(cache, b.shader, &compiler_key, NULL);
return agx_compile_bg_eot_shader(cache, b.shader, &compiler_key, NULL);
}
struct agx_meta_shader *
agx_get_meta_shader(struct agx_meta_cache *cache, struct agx_meta_key *key)
struct agx_bg_eot_shader *
agx_get_bg_eot_shader(struct agx_bg_eot_cache *cache,
struct agx_bg_eot_key *key)
{
struct hash_entry *ent = _mesa_hash_table_search(cache->ht, key);
if (ent)
return ent->data;
struct agx_meta_shader *ret = NULL;
struct agx_bg_eot_shader *ret = NULL;
for (unsigned rt = 0; rt < ARRAY_SIZE(key->op); ++rt) {
if (key->op[rt] == AGX_META_OP_STORE) {
if (key->op[rt] == AGX_EOT_STORE) {
ret = agx_build_end_of_tile_shader(cache, key);
break;
}
@@ -205,18 +206,18 @@ agx_get_meta_shader(struct agx_meta_cache *cache, struct agx_meta_key *key)
return ret;
}
DERIVE_HASH_TABLE(agx_meta_key);
DERIVE_HASH_TABLE(agx_bg_eot_key);
void
agx_meta_init(struct agx_meta_cache *cache, struct agx_device *dev)
agx_bg_eot_init(struct agx_bg_eot_cache *cache, struct agx_device *dev)
{
agx_pool_init(&cache->pool, dev, AGX_BO_EXEC | AGX_BO_LOW_VA, true);
cache->ht = agx_meta_key_table_create(NULL);
cache->ht = agx_bg_eot_key_table_create(NULL);
cache->dev = dev;
}
void
agx_meta_cleanup(struct agx_meta_cache *cache)
agx_bg_eot_cleanup(struct agx_bg_eot_cache *cache)
{
agx_pool_cleanup(&cache->pool);
_mesa_hash_table_destroy(cache->ht, NULL);
+44
View File
@@ -0,0 +1,44 @@
/*
* Copyright 2022 Alyssa Rosenzweig
* SPDX-License-Identifier: MIT
*/
#pragma once
#include "asahi/compiler/agx_compile.h"
#include "agx_tilebuffer.h"
#include "pool.h"
struct agx_bg_eot_cache {
struct agx_device *dev;
struct agx_pool pool;
/* Map from agx_bg_eot_key to agx_bg_eot_shader */
struct hash_table *ht;
};
enum agx_bg_eot_op {
AGX_BG_EOT_NONE,
AGX_BG_CLEAR,
AGX_BG_LOAD,
AGX_EOT_STORE,
};
struct agx_bg_eot_key {
struct agx_tilebuffer_layout tib;
enum agx_bg_eot_op op[8];
unsigned reserved_preamble;
};
struct agx_bg_eot_shader {
struct agx_bg_eot_key key;
struct agx_shader_info info;
struct agx_bo *bo;
uint32_t ptr;
};
struct agx_bg_eot_shader *agx_get_bg_eot_shader(struct agx_bg_eot_cache *cache,
struct agx_bg_eot_key *key);
void agx_bg_eot_init(struct agx_bg_eot_cache *cache, struct agx_device *dev);
void agx_bg_eot_cleanup(struct agx_bg_eot_cache *cache);
-44
View File
@@ -1,44 +0,0 @@
/*
* Copyright 2022 Alyssa Rosenzweig
* SPDX-License-Identifier: MIT
*/
#pragma once
#include "asahi/compiler/agx_compile.h"
#include "agx_tilebuffer.h"
#include "pool.h"
struct agx_meta_cache {
struct agx_device *dev;
struct agx_pool pool;
/* Map from agx_meta_key to agx_meta_shader */
struct hash_table *ht;
};
enum agx_meta_op {
AGX_META_OP_NONE,
AGX_META_OP_CLEAR,
AGX_META_OP_LOAD,
AGX_META_OP_STORE,
};
struct agx_meta_key {
struct agx_tilebuffer_layout tib;
enum agx_meta_op op[8];
unsigned reserved_preamble;
};
struct agx_meta_shader {
struct agx_meta_key key;
struct agx_shader_info info;
struct agx_bo *bo;
uint32_t ptr;
};
struct agx_meta_shader *agx_get_meta_shader(struct agx_meta_cache *cache,
struct agx_meta_key *key);
void agx_meta_init(struct agx_meta_cache *cache, struct agx_device *dev);
void agx_meta_cleanup(struct agx_meta_cache *cache);
+1 -1
View File
@@ -11,7 +11,7 @@ libasahi_lib_files = files(
'agx_device.c',
'agx_formats.c',
'agx_linker.c',
'agx_meta.c',
'agx_bg_eot.c',
'agx_tilebuffer.c',
'agx_nir_lower_alpha.c',
'agx_nir_lower_gs.c',
+6 -5
View File
@@ -39,6 +39,7 @@
#include "util/u_screen.h"
#include "util/u_upload_mgr.h"
#include "util/xmlconfig.h"
#include "agx_bg_eot.h"
#include "agx_device.h"
#include "agx_disk_cache.h"
#include "agx_fence.h"
@@ -1278,12 +1279,12 @@ agx_flush_batch(struct agx_context *ctx, struct agx_batch *batch)
memcpy(batch->vdm.current, stop, sizeof(stop));
struct asahi_bg_eot pipeline_background =
agx_build_meta(batch, false, false);
agx_build_bg_eot(batch, false, false);
struct asahi_bg_eot pipeline_background_partial =
agx_build_meta(batch, false, true);
agx_build_bg_eot(batch, false, true);
struct asahi_bg_eot pipeline_store = agx_build_meta(batch, true, false);
struct asahi_bg_eot pipeline_store = agx_build_bg_eot(batch, true, false);
bool clear_pipeline_textures =
agx_tilebuffer_spills(&batch->tilebuffer_layout);
@@ -1351,7 +1352,7 @@ agx_destroy_context(struct pipe_context *pctx)
util_unreference_framebuffer_state(&ctx->framebuffer);
agx_meta_cleanup(&ctx->meta);
agx_bg_eot_cleanup(&ctx->bg_eot);
agx_destroy_meta_shaders(ctx);
agx_bo_unreference(ctx->result_buf);
@@ -1455,7 +1456,7 @@ agx_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
agx_init_query_functions(pctx);
agx_init_streamout_functions(pctx);
agx_meta_init(&ctx->meta, agx_device(screen));
agx_bg_eot_init(&ctx->bg_eot, agx_device(screen));
agx_init_meta_shaders(ctx);
ctx->blitter = util_blitter_create(pctx);
+12 -11
View File
@@ -53,6 +53,7 @@
#include "util/u_resource.h"
#include "util/u_transfer.h"
#include "util/u_upload_mgr.h"
#include "agx_bg_eot.h"
#include "agx_bo.h"
#include "agx_device.h"
#include "agx_disk_cache.h"
@@ -3031,12 +3032,12 @@ agx_build_pipeline(struct agx_batch *batch, struct agx_compiled_shader *cs,
}
struct asahi_bg_eot
agx_build_meta(struct agx_batch *batch, bool store, bool partial_render)
agx_build_bg_eot(struct agx_batch *batch, bool store, bool partial_render)
{
struct agx_context *ctx = batch->ctx;
/* Construct the key */
struct agx_meta_key key = {.tib = batch->tilebuffer_layout};
struct agx_bg_eot_key key = {.tib = batch->tilebuffer_layout};
bool needs_textures_for_spilled_rts =
agx_tilebuffer_spills(&batch->tilebuffer_layout) && !partial_render &&
@@ -3050,13 +3051,13 @@ agx_build_meta(struct agx_batch *batch, bool store, bool partial_render)
if (store) {
/* TODO: Suppress stores to discarded render targets */
key.op[rt] = AGX_META_OP_STORE;
key.op[rt] = AGX_EOT_STORE;
} else if (batch->tilebuffer_layout.spilled[rt] && partial_render) {
/* Partial render programs exist only to store/load the tilebuffer to
* main memory. When render targets are already spilled to main memory,
* there's nothing to do.
*/
key.op[rt] = AGX_META_OP_NONE;
key.op[rt] = AGX_BG_EOT_NONE;
} else {
bool valid = (batch->load & (PIPE_CLEAR_COLOR0 << rt));
bool clear = (batch->clear & (PIPE_CLEAR_COLOR0 << rt));
@@ -3070,9 +3071,9 @@ agx_build_meta(struct agx_batch *batch, bool store, bool partial_render)
*/
load |= partial_render;
key.op[rt] = load ? AGX_META_OP_LOAD
: clear ? AGX_META_OP_CLEAR
: AGX_META_OP_NONE;
key.op[rt] = load ? AGX_BG_LOAD
: clear ? AGX_BG_CLEAR
: AGX_BG_EOT_NONE;
}
}
@@ -3085,7 +3086,7 @@ agx_build_meta(struct agx_batch *batch, bool store, bool partial_render)
unsigned nr_tex = 0;
for (unsigned rt = 0; rt < PIPE_MAX_COLOR_BUFS; ++rt) {
if (key.op[rt] == AGX_META_OP_LOAD) {
if (key.op[rt] == AGX_BG_LOAD) {
/* Each reloaded render target is textured */
needs_sampler = true;
@@ -3111,11 +3112,11 @@ agx_build_meta(struct agx_batch *batch, bool store, bool partial_render)
}
nr_tex = (rt * 2) + 1;
} else if (key.op[rt] == AGX_META_OP_CLEAR) {
} else if (key.op[rt] == AGX_BG_CLEAR) {
assert(batch->uploaded_clear_color[rt] && "set when cleared");
agx_usc_uniform(&b, 4 + (8 * rt), 8, batch->uploaded_clear_color[rt]);
uniforms = MAX2(uniforms, 4 + (8 * rt) + 8);
} else if (key.op[rt] == AGX_META_OP_STORE) {
} else if (key.op[rt] == AGX_EOT_STORE) {
struct pipe_image_view view =
image_view_for_surface(batch->key.cbufs[rt]);
struct agx_ptr pbe =
@@ -3185,7 +3186,7 @@ agx_build_meta(struct agx_batch *batch, bool store, bool partial_render)
/* Get the shader */
key.reserved_preamble = uniforms;
struct agx_meta_shader *shader = agx_get_meta_shader(&ctx->meta, &key);
struct agx_bg_eot_shader *shader = agx_get_bg_eot_shader(&ctx->bg_eot, &key);
agx_batch_add_bo(batch, shader->bo);
agx_usc_pack(&b, SHADER, cfg) {
+4 -4
View File
@@ -29,8 +29,8 @@
#include "util/disk_cache.h"
#include "util/hash_table.h"
#include "util/u_range.h"
#include "agx_bg_eot.h"
#include "agx_helpers.h"
#include "agx_meta.h"
#include "agx_nir_passes.h"
#ifdef __GLIBC__
@@ -686,7 +686,7 @@ struct agx_context {
struct util_dynarray global_buffers;
struct hash_table *generic_meta;
struct agx_meta_cache meta;
struct agx_bg_eot_cache bg_eot;
bool any_faults;
@@ -1113,8 +1113,8 @@ struct asahi_bg_eot {
struct agx_counts_packed counts;
};
struct asahi_bg_eot agx_build_meta(struct agx_batch *batch, bool store,
bool partial_render);
struct asahi_bg_eot agx_build_bg_eot(struct agx_batch *batch, bool store,
bool partial_render);
/* Query management */
uint16_t agx_get_oq_index(struct agx_batch *batch, struct agx_query *query);