• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2014-2017 Broadcom
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
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 
24 #ifndef V3D_SCREEN_H
25 #define V3D_SCREEN_H
26 
27 #include "pipe/p_screen.h"
28 #include "renderonly/renderonly.h"
29 #include "util/u_thread.h"
30 #include "frontend/drm_driver.h"
31 #include "util/disk_cache.h"
32 #include "util/list.h"
33 #include "util/slab.h"
34 #include "broadcom/common/v3d_debug.h"
35 #include "broadcom/common/v3d_device_info.h"
36 #include "broadcom/perfcntrs/v3d_perfcntrs.h"
37 
38 struct v3d_bo;
39 
40 /* These are tunable parameters in the HW design, but all the V3D
41  * implementations agree.
42  */
43 #define V3D_UIFCFG_BANKS 8
44 #define V3D_UIFCFG_PAGE_SIZE 4096
45 #define V3D_UIFCFG_XOR_VALUE (1 << 4)
46 #define V3D_PAGE_CACHE_SIZE (V3D_UIFCFG_PAGE_SIZE * V3D_UIFCFG_BANKS)
47 #define V3D_UBLOCK_SIZE 64
48 #define V3D_UIFBLOCK_SIZE (4 * V3D_UBLOCK_SIZE)
49 #define V3D_UIFBLOCK_ROW_SIZE (4 * V3D_UIFBLOCK_SIZE)
50 
51 struct v3d_simulator_file;
52 
53 struct v3d_screen {
54         struct pipe_screen base;
55         struct renderonly *ro;
56         int fd;
57 
58         struct v3d_device_info devinfo;
59 
60         const char *name;
61 
62         struct v3d_perfcntrs *perfcnt;
63 
64         struct slab_parent_pool transfer_pool;
65 
66         struct v3d_bo_cache {
67                 /** List of struct v3d_bo freed, by age. */
68                 struct list_head time_list;
69                 /** List of struct v3d_bo freed, per size, by age. */
70                 struct list_head *size_list;
71                 uint32_t size_list_size;
72 
73                 mtx_t lock;
74         } bo_cache;
75 
76         const struct v3d_compiler *compiler;
77 
78         struct hash_table *bo_handles;
79         mtx_t bo_handles_mutex;
80 
81         uint32_t bo_size;
82         uint32_t bo_count;
83         uint32_t prim_types;
84 
85         bool has_csd;
86         bool has_cache_flush;
87         bool has_perfmon;
88         bool nonmsaa_texture_size_limit;
89         bool has_cpu_queue;
90         bool has_multisync;
91 
92 #if USE_V3D_SIMULATOR
93         struct v3d_simulator_file *sim_file;
94 #endif
95 
96 #ifdef ENABLE_SHADER_CACHE
97         struct disk_cache *disk_cache;
98 #endif
99 };
100 
101 static inline struct v3d_screen *
v3d_screen(struct pipe_screen * screen)102 v3d_screen(struct pipe_screen *screen)
103 {
104         return (struct v3d_screen *)screen;
105 }
106 
107 struct pipe_screen *v3d_screen_create(int fd,
108                                       const struct pipe_screen_config *config,
109                                       struct renderonly *ro);
110 
111 const char *v3d_screen_get_name(struct pipe_screen *pscreen);
112 
113 void
114 v3d_fence_screen_init(struct v3d_screen *screen);
115 
116 #ifdef ENABLE_SHADER_CACHE
117 void
118 v3d_disk_cache_init(struct v3d_screen *screen);
119 #endif
120 
121 #endif /* V3D_SCREEN_H */
122