xref: /aosp_15_r20/external/mesa3d/src/gallium/drivers/panfrost/pan_afbc_cso.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright (C) 2023 Amazon.com, Inc. or its affiliates
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_AFBC_CSO_H__
25 #define __PAN_AFBC_CSO_H__
26 
27 #include "util/hash_table.h"
28 
29 #include "panfrost/util/pan_ir.h"
30 #include "pan_texture.h"
31 
32 struct panfrost_context;
33 struct panfrost_resource;
34 struct panfrost_screen;
35 
36 struct pan_afbc_shader_key {
37    unsigned bpp;
38    unsigned align;
39    bool tiled;
40 };
41 
42 struct pan_afbc_shader_data {
43    struct pan_afbc_shader_key key;
44    void *size_cso;
45    void *pack_cso;
46 };
47 
48 struct pan_afbc_shaders {
49    struct hash_table *shaders;
50    pthread_mutex_t lock;
51 };
52 
53 struct pan_afbc_block_info {
54    uint32_t size;
55    uint32_t offset;
56 };
57 
58 struct panfrost_afbc_size_info {
59    mali_ptr src;
60    mali_ptr metadata;
61 } PACKED;
62 
63 struct panfrost_afbc_pack_info {
64    mali_ptr src;
65    mali_ptr dst;
66    mali_ptr metadata;
67    uint32_t header_size;
68    uint32_t src_stride;
69    uint32_t dst_stride;
70    uint32_t padding[3]; // FIXME
71 } PACKED;
72 
73 void panfrost_afbc_context_init(struct panfrost_context *ctx);
74 void panfrost_afbc_context_destroy(struct panfrost_context *ctx);
75 
76 struct pan_afbc_shader_data *
77 panfrost_afbc_get_shaders(struct panfrost_context *ctx,
78                           struct panfrost_resource *rsrc, unsigned align);
79 
80 #endif
81