xref: /aosp_15_r20/external/mesa3d/src/panfrost/lib/pan_blitter.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 
25 #ifndef __PAN_BLITTER_H
26 #define __PAN_BLITTER_H
27 
28 #include "util/format/u_format.h"
29 #include "pan_desc.h"
30 #include "pan_pool.h"
31 #include "pan_texture.h"
32 #include "pan_util.h"
33 
34 struct pan_blend_shader_cache;
35 struct pan_fb_info;
36 struct pan_jc;
37 struct pan_pool;
38 
39 struct pan_blitter_cache {
40    unsigned gpu_id;
41    struct {
42       struct pan_pool *pool;
43       struct hash_table *blit;
44       struct hash_table *blend;
45       pthread_mutex_t lock;
46    } shaders;
47    struct {
48       struct pan_pool *pool;
49       struct hash_table *rsds;
50       pthread_mutex_t lock;
51    } rsds;
52    struct pan_blend_shader_cache *blend_shader_cache;
53 };
54 
55 struct pan_blit_info {
56    struct {
57       struct {
58          const struct pan_image *image;
59          enum pipe_format format;
60       } planes[MAX_IMAGE_PLANES];
61       unsigned level;
62       struct {
63          int32_t x, y, z;
64          unsigned layer;
65       } start, end;
66    } src, dst;
67    struct {
68       bool enable;
69       uint16_t minx, miny, maxx, maxy;
70    } scissor;
71    bool nearest;
72 };
73 
74 struct pan_blit_context {
75    mali_ptr rsd, vpd;
76    mali_ptr textures;
77    mali_ptr samplers;
78    mali_ptr position;
79    struct {
80       enum mali_texture_dimension dim;
81       struct {
82          float x, y;
83       } start, end;
84       union {
85          unsigned layer_offset;
86          float z_offset;
87       };
88    } src;
89    struct {
90       int32_t layer_offset;
91       int32_t cur_layer;
92       int32_t last_layer;
93    } dst;
94    float z_scale;
95 };
96 
97 #ifdef PAN_ARCH
98 void GENX(pan_blitter_cache_init)(struct pan_blitter_cache *cache,
99                                   unsigned gpu_id,
100                                   struct pan_blend_shader_cache *blend_shader_cache,
101                                   struct pan_pool *bin_pool,
102                                   struct pan_pool *desc_pool);
103 
104 void GENX(pan_blitter_cache_cleanup)(struct pan_blitter_cache *cache);
105 
106 unsigned GENX(pan_preload_fb)(struct pan_blitter_cache *cache,
107                               struct pan_pool *desc_pool,
108                               struct pan_fb_info *fb, unsigned layer_idx,
109                               mali_ptr tsd, struct panfrost_ptr *jobs);
110 #endif
111 
112 #endif
113