1 /* 2 * Copyright 2022 Alyssa Rosenzweig 3 * SPDX-License-Identifier: MIT 4 */ 5 6 #pragma once 7 8 #include "asahi/compiler/agx_compile.h" 9 #include "util/simple_mtx.h" 10 #include "agx_tilebuffer.h" 11 #include "libagx_dgc.h" 12 #include "libagx_shaders.h" 13 #include "pool.h" 14 15 struct agx_precompiled_shader { 16 struct agx_shader b; 17 struct agx_bo *bo; 18 uint64_t ptr; 19 }; 20 21 struct agx_bg_eot_cache { 22 struct agx_device *dev; 23 struct agx_pool pool; 24 simple_mtx_t lock; 25 26 /* Map from agx_bg_eot_key to agx_bg_eot_shader */ 27 struct hash_table *ht; 28 29 struct agx_precompiled_shader *precomp[LIBAGX_NUM_PROGRAMS]; 30 }; 31 32 /* 33 * Get a precompiled shader, uploading if necessary. This is thread-safe. 34 */ 35 struct agx_precompiled_shader * 36 agx_get_precompiled(struct agx_bg_eot_cache *cache, unsigned program); 37 38 /* 39 * Get the address of the cached helper program. This is thread-safe. 40 */ 41 uint64_t agx_helper_program(struct agx_bg_eot_cache *cache); 42 43 enum agx_bg_eot_op { 44 AGX_BG_EOT_NONE, 45 AGX_BG_CLEAR, 46 AGX_BG_LOAD, 47 AGX_EOT_STORE, 48 }; 49 50 struct agx_bg_eot_key { 51 struct agx_tilebuffer_layout tib; 52 enum agx_bg_eot_op op[8]; 53 unsigned reserved_preamble; 54 }; 55 56 struct agx_bg_eot_shader { 57 struct agx_bg_eot_key key; 58 struct agx_shader_info info; 59 struct agx_bo *bo; 60 uint64_t ptr; 61 }; 62 63 struct agx_bg_eot_shader *agx_get_bg_eot_shader(struct agx_bg_eot_cache *cache, 64 struct agx_bg_eot_key *key); 65 66 void agx_bg_eot_init(struct agx_bg_eot_cache *cache, struct agx_device *dev); 67 void agx_bg_eot_cleanup(struct agx_bg_eot_cache *cache); 68