nvc0/ir: detect AND/SHR pairs and convert into EXTBF
[mesa.git] / src / gallium / drivers / nouveau / nouveau_screen.h
1 #ifndef __NOUVEAU_SCREEN_H__
2 #define __NOUVEAU_SCREEN_H__
3
4 #include "pipe/p_screen.h"
5 #include "util/u_memory.h"
6
7 #ifdef DEBUG
8 # define NOUVEAU_ENABLE_DRIVER_STATISTICS
9 #endif
10
11 typedef uint32_t u32;
12 typedef uint16_t u16;
13
14 extern int nouveau_mesa_debug;
15
16 struct nouveau_bo;
17
18 struct nouveau_screen {
19 struct pipe_screen base;
20 struct nouveau_device *device;
21 struct nouveau_object *channel;
22 struct nouveau_client *client;
23 struct nouveau_pushbuf *pushbuf;
24
25 int refcount;
26
27 unsigned vidmem_bindings; /* PIPE_BIND_* where VRAM placement is desired */
28 unsigned sysmem_bindings; /* PIPE_BIND_* where GART placement is desired */
29 unsigned lowmem_bindings; /* PIPE_BIND_* that require an address < 4 GiB */
30 /*
31 * For bindings with (vidmem & sysmem) bits set, PIPE_USAGE_* decides
32 * placement.
33 */
34
35 uint16_t class_3d;
36
37 struct {
38 struct nouveau_fence *head;
39 struct nouveau_fence *tail;
40 struct nouveau_fence *current;
41 u32 sequence;
42 u32 sequence_ack;
43 void (*emit)(struct pipe_screen *, u32 *sequence);
44 u32 (*update)(struct pipe_screen *);
45 } fence;
46
47 struct nouveau_mman *mm_VRAM;
48 struct nouveau_mman *mm_GART;
49
50 int64_t cpu_gpu_time_delta;
51
52 bool hint_buf_keep_sysmem_copy;
53
54 unsigned vram_domain;
55
56 struct {
57 unsigned profiles_checked;
58 unsigned profiles_present;
59 } firmware_info;
60
61 #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS
62 union {
63 uint64_t v[29];
64 struct {
65 uint64_t tex_obj_current_count;
66 uint64_t tex_obj_current_bytes;
67 uint64_t buf_obj_current_count;
68 uint64_t buf_obj_current_bytes_vid;
69 uint64_t buf_obj_current_bytes_sys;
70 uint64_t tex_transfers_rd;
71 uint64_t tex_transfers_wr;
72 uint64_t tex_copy_count;
73 uint64_t tex_blit_count;
74 uint64_t tex_cache_flush_count;
75 uint64_t buf_transfers_rd;
76 uint64_t buf_transfers_wr;
77 uint64_t buf_read_bytes_staging_vid;
78 uint64_t buf_write_bytes_direct;
79 uint64_t buf_write_bytes_staging_vid;
80 uint64_t buf_write_bytes_staging_sys;
81 uint64_t buf_copy_bytes;
82 uint64_t buf_non_kernel_fence_sync_count;
83 uint64_t any_non_kernel_fence_sync_count;
84 uint64_t query_sync_count;
85 uint64_t gpu_serialize_count;
86 uint64_t draw_calls_array;
87 uint64_t draw_calls_indexed;
88 uint64_t draw_calls_fallback_count;
89 uint64_t user_buffer_upload_bytes;
90 uint64_t constbuf_upload_count;
91 uint64_t constbuf_upload_bytes;
92 uint64_t pushbuf_count;
93 uint64_t resource_validate_count;
94 } named;
95 } stats;
96 #endif
97 };
98
99 #define NV_VRAM_DOMAIN(screen) ((screen)->vram_domain)
100
101 #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS
102 # define NOUVEAU_DRV_STAT(s, n, v) do { \
103 (s)->stats.named.n += (v); \
104 } while(0)
105 # define NOUVEAU_DRV_STAT_RES(r, n, v) do { \
106 nouveau_screen((r)->base.screen)->stats.named.n += (v); \
107 } while(0)
108 # define NOUVEAU_DRV_STAT_IFD(x) x
109 #else
110 # define NOUVEAU_DRV_STAT(s, n, v) do { } while(0)
111 # define NOUVEAU_DRV_STAT_RES(r, n, v) do { } while(0)
112 # define NOUVEAU_DRV_STAT_IFD(x)
113 #endif
114
115 static inline struct nouveau_screen *
116 nouveau_screen(struct pipe_screen *pscreen)
117 {
118 return (struct nouveau_screen *)pscreen;
119 }
120
121 bool nouveau_drm_screen_unref(struct nouveau_screen *screen);
122
123 bool
124 nouveau_screen_bo_get_handle(struct pipe_screen *pscreen,
125 struct nouveau_bo *bo,
126 unsigned stride,
127 struct winsys_handle *whandle);
128 struct nouveau_bo *
129 nouveau_screen_bo_from_handle(struct pipe_screen *pscreen,
130 struct winsys_handle *whandle,
131 unsigned *out_stride);
132
133
134 int nouveau_screen_init(struct nouveau_screen *, struct nouveau_device *);
135 void nouveau_screen_fini(struct nouveau_screen *);
136
137 void nouveau_screen_init_vdec(struct nouveau_screen *);
138
139 #endif