• 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 VC5_SCREEN_H
25 #define VC5_SCREEN_H
26 
27 #include "pipe/p_screen.h"
28 #include "os/os_thread.h"
29 #include "state_tracker/drm_driver.h"
30 #include "util/list.h"
31 #include "util/slab.h"
32 #include "broadcom/common/v3d_debug.h"
33 #include "broadcom/common/v3d_device_info.h"
34 
35 struct vc5_bo;
36 
37 #define VC5_MAX_MIP_LEVELS 12
38 #define VC5_MAX_TEXTURE_SAMPLERS 32
39 #define VC5_MAX_SAMPLES 4
40 #define VC5_MAX_DRAW_BUFFERS 4
41 #define VC5_MAX_ATTRIBUTES 16
42 
43 struct vc5_simulator_file;
44 
45 struct vc5_screen {
46         struct pipe_screen base;
47         int fd;
48 
49         struct v3d_device_info devinfo;
50 
51         const char *name;
52 
53         /** The last seqno we've completed a wait for.
54          *
55          * This lets us slightly optimize our waits by skipping wait syscalls
56          * if we know the job's already done.
57          */
58         uint64_t finished_seqno;
59 
60         struct slab_parent_pool transfer_pool;
61 
62         struct vc5_bo_cache {
63                 /** List of struct vc5_bo freed, by age. */
64                 struct list_head time_list;
65                 /** List of struct vc5_bo freed, per size, by age. */
66                 struct list_head *size_list;
67                 uint32_t size_list_size;
68 
69                 mtx_t lock;
70 
71                 uint32_t bo_size;
72                 uint32_t bo_count;
73         } bo_cache;
74 
75         const struct v3d_compiler *compiler;
76 
77         struct util_hash_table *bo_handles;
78         mtx_t bo_handles_mutex;
79 
80         uint32_t bo_size;
81         uint32_t bo_count;
82 
83         struct vc5_simulator_file *sim_file;
84 };
85 
86 static inline struct vc5_screen *
vc5_screen(struct pipe_screen * screen)87 vc5_screen(struct pipe_screen *screen)
88 {
89         return (struct vc5_screen *)screen;
90 }
91 
92 struct pipe_screen *vc5_screen_create(int fd);
93 
94 void
95 vc5_fence_init(struct vc5_screen *screen);
96 
97 struct vc5_fence *
98 vc5_fence_create(struct vc5_screen *screen, uint64_t seqno);
99 
100 #endif /* VC5_SCREEN_H */
101