xref: /aosp_15_r20/external/mesa3d/src/panfrost/lib/pan_indirect_dispatch.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright (C) 2021 Collabora, Ltd.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21  * SOFTWARE.
22  */
23 
24 #ifndef __PAN_INDIRECT_DISPATCH_SHADERS_H__
25 #define __PAN_INDIRECT_DISPATCH_SHADERS_H__
26 
27 #include "genxml/gen_macros.h"
28 #include "pan_jc.h"
29 
30 #include "panfrost/util/pan_ir.h"
31 
32 struct pan_jc;
33 struct pan_pool;
34 
35 struct pan_indirect_dispatch_meta {
36    struct panfrost_ubo_push push;
37 
38    unsigned gpu_id;
39 
40    /* Renderer state descriptor. */
41    mali_ptr rsd;
42 
43    /* Thread storage descriptor. */
44    mali_ptr tsd;
45 
46    /* Shader binary pool. */
47    struct pan_pool *bin_pool;
48 
49    /* Shader desc pool for any descriptor that can be re-used across
50     * indirect dispatch calls. Job descriptors are allocated from the pool
51     * passed to pan_indirect_dispatch_emit().
52     */
53    struct pan_pool *desc_pool;
54 };
55 
56 struct pan_indirect_dispatch_info {
57    mali_ptr job;
58    mali_ptr indirect_dim;
59    mali_ptr num_wg_sysval[3];
60 } PACKED;
61 
62 static inline void
pan_indirect_dispatch_meta_init(struct pan_indirect_dispatch_meta * meta,unsigned gpu_id,struct pan_pool * bin_pool,struct pan_pool * desc_pool)63 pan_indirect_dispatch_meta_init(struct pan_indirect_dispatch_meta *meta,
64                                 unsigned gpu_id, struct pan_pool *bin_pool,
65                                 struct pan_pool *desc_pool)
66 {
67    memset(meta, 0, sizeof(*meta));
68    meta->gpu_id = gpu_id;
69    meta->bin_pool = bin_pool;
70    meta->desc_pool = desc_pool;
71 }
72 
73 #ifdef PAN_ARCH
74 unsigned GENX(pan_indirect_dispatch_emit)(
75    struct pan_indirect_dispatch_meta *meta,
76    struct pan_pool *pool, struct pan_jc *jc,
77    const struct pan_indirect_dispatch_info *dispatch_info);
78 #endif
79 
80 #endif
81