• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef __NOUVEAU_SCREEN_H__
2 #define __NOUVEAU_SCREEN_H__
3 
4 #include "pipe/p_screen.h"
5 #include "util/disk_cache.h"
6 #include "util/u_atomic.h"
7 #include "util/u_memory.h"
8 
9 #include "nouveau_fence.h"
10 
11 #ifndef NDEBUG
12 # define NOUVEAU_ENABLE_DRIVER_STATISTICS
13 #endif
14 
15 typedef uint32_t u32;
16 typedef uint16_t u16;
17 
18 extern int nouveau_mesa_debug;
19 
20 struct nouveau_bo;
21 
22 #define NOUVEAU_SHADER_CACHE_FLAGS_IR_TGSI 0 << 0
23 #define NOUVEAU_SHADER_CACHE_FLAGS_IR_NIR  1 << 0
24 
25 struct nouveau_screen {
26    struct pipe_screen base;
27    struct nouveau_drm *drm;
28    struct nouveau_device *device;
29    struct nouveau_object *channel;
30    struct nouveau_client *client;
31    struct nouveau_pushbuf *pushbuf;
32 
33    char chipset_name[8];
34 
35    bool initialized;
36 
37    unsigned transfer_pushbuf_threshold;
38 
39    unsigned vidmem_bindings; /* PIPE_BIND_* where VRAM placement is desired */
40    unsigned sysmem_bindings; /* PIPE_BIND_* where GART placement is desired */
41    unsigned lowmem_bindings; /* PIPE_BIND_* that require an address < 4 GiB */
42    /*
43     * For bindings with (vidmem & sysmem) bits set, PIPE_USAGE_* decides
44     * placement.
45     */
46 
47    uint16_t class_3d;
48 
49    struct nouveau_fence_list fence;
50 
51    struct nouveau_mman *mm_VRAM;
52    struct nouveau_mman *mm_GART;
53 
54    int64_t cpu_gpu_time_delta;
55 
56    bool hint_buf_keep_sysmem_copy;
57    bool tegra_sector_layout;
58 
59    unsigned vram_domain;
60 
61    struct {
62       unsigned profiles_checked;
63       unsigned profiles_present;
64    } firmware_info;
65 
66    struct disk_cache *disk_shader_cache;
67 
68    bool has_svm;
69    bool is_uma;
70    bool disable_fences;
71    void *svm_cutout;
72    size_t svm_cutout_size;
73 
74 #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS
75    union {
76       uint64_t v[29];
77       struct {
78          uint64_t tex_obj_current_count;
79          uint64_t tex_obj_current_bytes;
80          uint64_t buf_obj_current_count;
81          uint64_t buf_obj_current_bytes_vid;
82          uint64_t buf_obj_current_bytes_sys;
83          uint64_t tex_transfers_rd;
84          uint64_t tex_transfers_wr;
85          uint64_t tex_copy_count;
86          uint64_t tex_blit_count;
87          uint64_t tex_cache_flush_count;
88          uint64_t buf_transfers_rd;
89          uint64_t buf_transfers_wr;
90          uint64_t buf_read_bytes_staging_vid;
91          uint64_t buf_write_bytes_direct;
92          uint64_t buf_write_bytes_staging_vid;
93          uint64_t buf_write_bytes_staging_sys;
94          uint64_t buf_copy_bytes;
95          uint64_t buf_non_kernel_fence_sync_count;
96          uint64_t any_non_kernel_fence_sync_count;
97          uint64_t query_sync_count;
98          uint64_t gpu_serialize_count;
99          uint64_t draw_calls_array;
100          uint64_t draw_calls_indexed;
101          uint64_t draw_calls_fallback_count;
102          uint64_t user_buffer_upload_bytes;
103          uint64_t constbuf_upload_count;
104          uint64_t constbuf_upload_bytes;
105          uint64_t pushbuf_count;
106          uint64_t resource_validate_count;
107       } named;
108    } stats;
109 #endif
110 };
111 
112 struct nouveau_pushbuf_priv {
113    struct nouveau_screen *screen;
114    struct nouveau_context *context;
115 };
116 
117 #define NV_VRAM_DOMAIN(screen) ((screen)->vram_domain)
118 
119 #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS
120 # define NOUVEAU_DRV_STAT(s, n, v) do {         \
121       p_atomic_add(&(s)->stats.named.n, (v));   \
122    } while(0)
123 # define NOUVEAU_DRV_STAT_RES(r, n, v) do {                                \
124       p_atomic_add(&nouveau_screen((r)->base.screen)->stats.named.n, v);   \
125    } while(0)
126 # define NOUVEAU_DRV_STAT_IFD(x) x
127 #else
128 # define NOUVEAU_DRV_STAT(s, n, v)     do { } while(0)
129 # define NOUVEAU_DRV_STAT_RES(r, n, v) do { } while(0)
130 # define NOUVEAU_DRV_STAT_IFD(x)
131 #endif
132 
133 static inline struct nouveau_screen *
nouveau_screen(struct pipe_screen * pscreen)134 nouveau_screen(struct pipe_screen *pscreen)
135 {
136    return (struct nouveau_screen *)pscreen;
137 }
138 
139 bool
140 nouveau_screen_bo_get_handle(struct pipe_screen *pscreen,
141                              struct nouveau_bo *bo,
142                              unsigned stride,
143                              struct winsys_handle *whandle);
144 struct nouveau_bo *
145 nouveau_screen_bo_from_handle(struct pipe_screen *pscreen,
146                               struct winsys_handle *whandle,
147                               unsigned *out_stride);
148 
149 
150 int nouveau_screen_init(struct nouveau_screen *, struct nouveau_device *);
151 void nouveau_screen_fini(struct nouveau_screen *);
152 
153 void nouveau_screen_init_vdec(struct nouveau_screen *);
154 
155 int
156 nouveau_pushbuf_create(struct nouveau_screen *, struct nouveau_context *, struct nouveau_client *,
157                        struct nouveau_object *chan, int nr, uint32_t size,
158                        struct nouveau_pushbuf **);
159 void nouveau_pushbuf_destroy(struct nouveau_pushbuf **);
160 
161 #endif
162