xref: /aosp_15_r20/external/mesa3d/src/asahi/lib/agx_scratch.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright 2023 Asahi Lina
3  * SPDX-License-Identifier: MIT
4  */
5 
6 #pragma once
7 
8 #include "agx_device.h"
9 #include <agx_pack.h>
10 
11 // #define SCRATCH_DEBUG
12 
13 struct agx_scratch {
14    struct agx_device *dev;
15    struct agx_bo *buf;
16    uint32_t max_core_id;
17    uint32_t num_cores;
18 
19    uint32_t subgroups;
20    uint32_t size_dwords;
21 
22    struct agx_helper_header *header;
23 
24 #ifdef SCRATCH_DEBUG
25    bool core_present[1024];
26    struct agx_helper_block *blocklist;
27    void *data;
28    size_t core_size;
29 #endif
30 };
31 
32 struct agx_bo *agx_build_helper(struct agx_device *dev);
33 
34 void agx_scratch_init(struct agx_device *dev, struct agx_scratch *scratch);
35 void agx_scratch_fini(struct agx_scratch *scratch);
36 void agx_scratch_debug_pre(struct agx_scratch *scratch);
37 void agx_scratch_debug_post(struct agx_scratch *scratch);
38 
39 uint32_t agx_scratch_get_bucket(uint32_t dwords);
40 void agx_scratch_alloc(struct agx_scratch *scratch, uint32_t dwords,
41                        size_t subgroups);
42