nvc0: use NOUVEAU_GETPARAM_GRAPH_UNITS to get MP count
[mesa.git] / src / gallium / drivers / nvc0 / nvc0_screen.h
1 #ifndef __NVC0_SCREEN_H__
2 #define __NVC0_SCREEN_H__
3
4 #include "nouveau/nouveau_screen.h"
5 #include "nouveau/nouveau_mm.h"
6 #include "nouveau/nouveau_fence.h"
7 #include "nouveau/nouveau_heap.h"
8
9 #include "nouveau/nv_object.xml.h"
10
11 #include "nvc0_winsys.h"
12 #include "nvc0_stateobj.h"
13
14 #define NVC0_TIC_MAX_ENTRIES 2048
15 #define NVC0_TSC_MAX_ENTRIES 2048
16
17 /* doesn't count reserved slots (for auxiliary constants, immediates, etc.) */
18 #define NVC0_MAX_PIPE_CONSTBUFS 14
19 #define NVE4_MAX_PIPE_CONSTBUFS_COMPUTE 7
20
21 #define NVC0_MAX_SURFACE_SLOTS 16
22
23 struct nvc0_context;
24
25 struct nvc0_blitter;
26
27 struct nvc0_screen {
28 struct nouveau_screen base;
29
30 struct nvc0_context *cur_ctx;
31
32 int num_occlusion_queries_active;
33
34 struct nouveau_bo *text;
35 struct nouveau_bo *parm; /* for COMPUTE */
36 struct nouveau_bo *uniform_bo; /* for 3D */
37 struct nouveau_bo *tls;
38 struct nouveau_bo *txc; /* TIC (offset 0) and TSC (65536) */
39 struct nouveau_bo *poly_cache;
40
41 uint16_t mp_count;
42
43 struct nouveau_heap *text_heap;
44 struct nouveau_heap *lib_code; /* allocated from text_heap */
45
46 struct nvc0_blitter *blitter;
47
48 struct {
49 void **entries;
50 int next;
51 uint32_t lock[NVC0_TIC_MAX_ENTRIES / 32];
52 } tic;
53
54 struct {
55 void **entries;
56 int next;
57 uint32_t lock[NVC0_TSC_MAX_ENTRIES / 32];
58 } tsc;
59
60 struct {
61 struct nouveau_bo *bo;
62 uint32_t *map;
63 } fence;
64
65 struct nouveau_mman *mm_VRAM_fe0;
66
67 struct nouveau_object *eng3d; /* sqrt(1/2)|kepler> + sqrt(1/2)|fermi> */
68 struct nouveau_object *eng2d;
69 struct nouveau_object *m2mf;
70 struct nouveau_object *compute;
71 };
72
73 static INLINE struct nvc0_screen *
74 nvc0_screen(struct pipe_screen *screen)
75 {
76 return (struct nvc0_screen *)screen;
77 }
78
79 boolean nvc0_blitter_create(struct nvc0_screen *);
80 void nvc0_blitter_destroy(struct nvc0_screen *);
81
82 void nvc0_screen_make_buffers_resident(struct nvc0_screen *);
83
84 int nvc0_screen_tic_alloc(struct nvc0_screen *, void *);
85 int nvc0_screen_tsc_alloc(struct nvc0_screen *, void *);
86
87 int nve4_screen_compute_setup(struct nvc0_screen *, struct nouveau_pushbuf *);
88
89 boolean nvc0_screen_resize_tls_area(struct nvc0_screen *, uint32_t lpos,
90 uint32_t lneg, uint32_t cstack);
91
92 static INLINE void
93 nvc0_resource_fence(struct nv04_resource *res, uint32_t flags)
94 {
95 struct nvc0_screen *screen = nvc0_screen(res->base.screen);
96
97 if (res->mm) {
98 nouveau_fence_ref(screen->base.fence.current, &res->fence);
99 if (flags & NOUVEAU_BO_WR)
100 nouveau_fence_ref(screen->base.fence.current, &res->fence_wr);
101 }
102 }
103
104 static INLINE void
105 nvc0_resource_validate(struct nv04_resource *res, uint32_t flags)
106 {
107 if (likely(res->bo)) {
108 if (flags & NOUVEAU_BO_WR)
109 res->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING |
110 NOUVEAU_BUFFER_STATUS_DIRTY;
111 if (flags & NOUVEAU_BO_RD)
112 res->status |= NOUVEAU_BUFFER_STATUS_GPU_READING;
113
114 nvc0_resource_fence(res, flags);
115 }
116 }
117
118 struct nvc0_format {
119 uint32_t rt;
120 uint32_t tic;
121 uint32_t vtx;
122 uint32_t usage;
123 };
124
125 extern const struct nvc0_format nvc0_format_table[];
126
127 static INLINE void
128 nvc0_screen_tic_unlock(struct nvc0_screen *screen, struct nv50_tic_entry *tic)
129 {
130 if (tic->id >= 0)
131 screen->tic.lock[tic->id / 32] &= ~(1 << (tic->id % 32));
132 }
133
134 static INLINE void
135 nvc0_screen_tsc_unlock(struct nvc0_screen *screen, struct nv50_tsc_entry *tsc)
136 {
137 if (tsc->id >= 0)
138 screen->tsc.lock[tsc->id / 32] &= ~(1 << (tsc->id % 32));
139 }
140
141 static INLINE void
142 nvc0_screen_tic_free(struct nvc0_screen *screen, struct nv50_tic_entry *tic)
143 {
144 if (tic->id >= 0) {
145 screen->tic.entries[tic->id] = NULL;
146 screen->tic.lock[tic->id / 32] &= ~(1 << (tic->id % 32));
147 }
148 }
149
150 static INLINE void
151 nvc0_screen_tsc_free(struct nvc0_screen *screen, struct nv50_tsc_entry *tsc)
152 {
153 if (tsc->id >= 0) {
154 screen->tsc.entries[tsc->id] = NULL;
155 screen->tsc.lock[tsc->id / 32] &= ~(1 << (tsc->id % 32));
156 }
157 }
158
159 #endif