nvc0: import nvc0 gallium driver
[mesa.git] / src / gallium / drivers / nvc0 / nvc0_screen.h
1 #ifndef __NVC0_SCREEN_H__
2 #define __NVC0_SCREEN_H__
3
4 #define NOUVEAU_NVC0
5 #include "nouveau/nouveau_screen.h"
6 #undef NOUVEAU_NVC0
7 #include "nvc0_winsys.h"
8 #include "nvc0_stateobj.h"
9
10 #define NVC0_TIC_MAX_ENTRIES 2048
11 #define NVC0_TSC_MAX_ENTRIES 2048
12
13 struct nvc0_context;
14 struct nvc0_fence;
15
16 struct nvc0_screen {
17 struct nouveau_screen base;
18 struct nouveau_winsys *nvws;
19
20 struct nvc0_context *cur_ctx;
21
22 struct nouveau_bo *text;
23 struct nouveau_bo *uniforms;
24 struct nouveau_bo *tls;
25 struct nouveau_bo *txc; /* TIC (offset 0) and TSC (65536) */
26 struct nouveau_bo *mp_stack_bo;
27
28 uint64_t tls_size;
29
30 struct nouveau_resource *text_heap;
31
32 struct {
33 void **entries;
34 int next;
35 uint32_t lock[NVC0_TIC_MAX_ENTRIES / 32];
36 } tic;
37
38 struct {
39 void **entries;
40 int next;
41 uint32_t lock[NVC0_TSC_MAX_ENTRIES / 32];
42 } tsc;
43
44 struct {
45 uint32_t *map;
46 struct nvc0_fence *head;
47 struct nvc0_fence *tail;
48 struct nvc0_fence *current;
49 uint32_t sequence;
50 uint32_t sequence_ack;
51 struct nouveau_bo *bo;
52 } fence;
53 };
54
55 static INLINE struct nvc0_screen *
56 nvc0_screen(struct pipe_screen *screen)
57 {
58 return (struct nvc0_screen *)screen;
59 }
60
61 void nvc0_screen_make_buffers_resident(struct nvc0_screen *);
62
63 int nvc0_screen_tic_alloc(struct nvc0_screen *, void *);
64 int nvc0_screen_tsc_alloc(struct nvc0_screen *, void *);
65
66 boolean
67 nvc0_screen_fence_new(struct nvc0_screen *, struct nvc0_fence **, boolean emit);
68
69 struct nvc0_format {
70 uint32_t rt;
71 uint32_t tic;
72 uint32_t vtx;
73 uint32_t usage;
74 };
75
76 extern const struct nvc0_format nvc0_format_table[];
77
78 static INLINE void
79 nvc0_screen_tic_unlock(struct nvc0_screen *screen, struct nvc0_tic_entry *tic)
80 {
81 if (tic->id >= 0)
82 screen->tic.lock[tic->id / 32] &= ~(1 << (tic->id % 32));
83 }
84
85 static INLINE void
86 nvc0_screen_tsc_unlock(struct nvc0_screen *screen, struct nvc0_tsc_entry *tsc)
87 {
88 if (tsc->id >= 0)
89 screen->tsc.lock[tsc->id / 32] &= ~(1 << (tsc->id % 32));
90 }
91
92 static INLINE void
93 nvc0_screen_tic_free(struct nvc0_screen *screen, struct nvc0_tic_entry *tic)
94 {
95 if (tic->id >= 0) {
96 screen->tic.entries[tic->id] = NULL;
97 screen->tic.lock[tic->id / 32] &= ~(1 << (tic->id % 32));
98 }
99 }
100
101 static INLINE void
102 nvc0_screen_tsc_free(struct nvc0_screen *screen, struct nvc0_tsc_entry *tsc)
103 {
104 if (tsc->id >= 0) {
105 screen->tsc.entries[tsc->id] = NULL;
106 screen->tsc.lock[tsc->id / 32] &= ~(1 << (tsc->id % 32));
107 }
108 }
109
110 #endif