1 #ifndef __NVC0_SCREEN_H__
2 #define __NVC0_SCREEN_H__
4 #include "nouveau/nouveau_screen.h"
5 #include "nouveau/nouveau_mm.h"
6 #include "nouveau/nouveau_fence.h"
7 #include "nouveau/nouveau_heap.h"
9 #include "nouveau/nv_object.xml.h"
11 #include "nvc0_winsys.h"
12 #include "nvc0_stateobj.h"
14 #define NVC0_TIC_MAX_ENTRIES 2048
15 #define NVC0_TSC_MAX_ENTRIES 2048
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
21 #define NVC0_MAX_SURFACE_SLOTS 16
28 struct nouveau_screen base
;
30 struct nvc0_context
*cur_ctx
;
32 int num_occlusion_queries_active
;
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
;
43 struct nouveau_heap
*text_heap
;
44 struct nouveau_heap
*lib_code
; /* allocated from text_heap */
46 struct nvc0_blitter
*blitter
;
51 uint32_t lock
[NVC0_TIC_MAX_ENTRIES
/ 32];
57 uint32_t lock
[NVC0_TSC_MAX_ENTRIES
/ 32];
61 struct nouveau_bo
*bo
;
65 struct nouveau_mman
*mm_VRAM_fe0
;
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
;
73 static INLINE
struct nvc0_screen
*
74 nvc0_screen(struct pipe_screen
*screen
)
76 return (struct nvc0_screen
*)screen
;
79 boolean
nvc0_blitter_create(struct nvc0_screen
*);
80 void nvc0_blitter_destroy(struct nvc0_screen
*);
82 void nvc0_screen_make_buffers_resident(struct nvc0_screen
*);
84 int nvc0_screen_tic_alloc(struct nvc0_screen
*, void *);
85 int nvc0_screen_tsc_alloc(struct nvc0_screen
*, void *);
87 int nve4_screen_compute_setup(struct nvc0_screen
*, struct nouveau_pushbuf
*);
89 boolean
nvc0_screen_resize_tls_area(struct nvc0_screen
*, uint32_t lpos
,
90 uint32_t lneg
, uint32_t cstack
);
93 nvc0_resource_fence(struct nv04_resource
*res
, uint32_t flags
)
95 struct nvc0_screen
*screen
= nvc0_screen(res
->base
.screen
);
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
);
105 nvc0_resource_validate(struct nv04_resource
*res
, uint32_t flags
)
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
;
114 nvc0_resource_fence(res
, flags
);
125 extern const struct nvc0_format nvc0_format_table
[];
128 nvc0_screen_tic_unlock(struct nvc0_screen
*screen
, struct nv50_tic_entry
*tic
)
131 screen
->tic
.lock
[tic
->id
/ 32] &= ~(1 << (tic
->id
% 32));
135 nvc0_screen_tsc_unlock(struct nvc0_screen
*screen
, struct nv50_tsc_entry
*tsc
)
138 screen
->tsc
.lock
[tsc
->id
/ 32] &= ~(1 << (tsc
->id
% 32));
142 nvc0_screen_tic_free(struct nvc0_screen
*screen
, struct nv50_tic_entry
*tic
)
145 screen
->tic
.entries
[tic
->id
] = NULL
;
146 screen
->tic
.lock
[tic
->id
/ 32] &= ~(1 << (tic
->id
% 32));
151 nvc0_screen_tsc_free(struct nvc0_screen
*screen
, struct nv50_tsc_entry
*tsc
)
154 screen
->tsc
.entries
[tsc
->id
] = NULL
;
155 screen
->tsc
.lock
[tsc
->id
/ 32] &= ~(1 << (tsc
->id
% 32));