xref: /aosp_15_r20/external/mesa3d/src/gallium/drivers/lima/lima_screen.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright (c) 2017-2019 Lima Project
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, sub license,
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
12  * next paragraph) shall be included in all copies or substantial portions
13  * of the 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 NON-INFRINGEMENT. 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
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  *
23  */
24 
25 #ifndef H_LIMA_SCREEN
26 #define H_LIMA_SCREEN
27 
28 #include <stdio.h>
29 
30 #include "util/slab.h"
31 #include "util/list.h"
32 #include "util/disk_cache.h"
33 #include "util/u_thread.h"
34 
35 #include "pipe/p_screen.h"
36 
37 #define LIMA_DEBUG_GP             (1 << 0)
38 #define LIMA_DEBUG_PP             (1 << 1)
39 #define LIMA_DEBUG_DUMP           (1 << 2)
40 #define LIMA_DEBUG_SHADERDB       (1 << 3)
41 #define LIMA_DEBUG_NO_BO_CACHE    (1 << 4)
42 #define LIMA_DEBUG_BO_CACHE       (1 << 5)
43 #define LIMA_DEBUG_NO_TILING      (1 << 6)
44 #define LIMA_DEBUG_NO_GROW_HEAP   (1 << 7)
45 #define LIMA_DEBUG_SINGLE_JOB     (1 << 8)
46 #define LIMA_DEBUG_PRECOMPILE     (1 << 9)
47 #define LIMA_DEBUG_DISK_CACHE     (1 << 10)
48 #define LIMA_DEBUG_NO_BLIT        (1 << 11)
49 
50 extern uint32_t lima_debug;
51 extern int lima_ctx_num_plb;
52 extern int lima_plb_max_blk;
53 extern int lima_ppir_force_spilling;
54 extern int lima_plb_pp_stream_cache_size;
55 
56 struct ra_regs;
57 
58 #define MIN_BO_CACHE_BUCKET (12) /* 2^12 = 4KB */
59 #define MAX_BO_CACHE_BUCKET (22) /* 2^22 = 4MB */
60 
61 #define NR_BO_CACHE_BUCKETS (MAX_BO_CACHE_BUCKET - MIN_BO_CACHE_BUCKET + 1)
62 
63 /* const0 1 0 0 -1.67773, mov.v0 $0 ^const0.xxxx, stop */
64 #define PP_CLEAR_PROGRAM \
65    0x00020425, 0x0000000c, 0x01e007cf, 0xb0000000, \
66    0x000005f5, 0x00000000, 0x00000000, 0x00000000, \
67 
68 struct lima_screen {
69    struct pipe_screen base;
70    struct renderonly *ro;
71 
72    int fd;
73    int gpu_type;
74    int num_pp;
75    uint32_t plb_max_blk;
76 
77    /* bo table */
78    mtx_t bo_table_lock;
79    mtx_t bo_cache_lock;
80    struct hash_table *bo_handles;
81    struct hash_table *bo_flink_names;
82    struct list_head bo_cache_buckets[NR_BO_CACHE_BUCKETS];
83    struct list_head bo_cache_time;
84 
85    struct slab_parent_pool transfer_pool;
86 
87    struct ra_regs *pp_ra;
88 
89    struct lima_bo *pp_buffer;
90    #define pp_frame_rsw_offset       0x0000
91    #define pp_clear_program_offset   0x0040
92    #define pp_reload_program_offset  0x0080
93    #define pp_shared_index_offset    0x00c0
94    #define pp_clear_gl_pos_offset    0x0100
95    #define pp_buffer_size            0x1000
96 
97    bool has_growable_heap_buffer;
98 
99    struct disk_cache *disk_cache;
100 };
101 
102 static inline struct lima_screen *
lima_screen(struct pipe_screen * pscreen)103 lima_screen(struct pipe_screen *pscreen)
104 {
105    return (struct lima_screen *)pscreen;
106 }
107 
108 struct pipe_screen *
109 lima_screen_create(int fd, const struct pipe_screen_config *config,
110                    struct renderonly *ro);
111 
112 #endif
113