1 #ifndef __NVC0_SCREEN_H__
2 #define __NVC0_SCREEN_H__
5 #include "nouveau/nouveau_screen.h"
6 #include "nouveau/nouveau_mm.h"
7 #include "nouveau/nouveau_fence.h"
9 #include "nvc0_winsys.h"
10 #include "nvc0_stateobj.h"
12 #define NVC0_TIC_MAX_ENTRIES 2048
13 #define NVC0_TSC_MAX_ENTRIES 2048
17 #define NVC0_SCRATCH_SIZE (2 << 20)
18 #define NVC0_SCRATCH_NR_BUFFERS 2
20 #define NVC0_SCREEN_RESIDENT_BO_COUNT 5
25 struct nouveau_screen base
;
27 struct nvc0_context
*cur_ctx
;
29 int num_occlusion_queries_active
;
31 struct nouveau_bo
*text
;
32 struct nouveau_bo
*uniforms
;
33 struct nouveau_bo
*tls
;
34 struct nouveau_bo
*txc
; /* TIC (offset 0) and TSC (65536) */
35 struct nouveau_bo
*vfetch_cache
;
39 struct nouveau_resource
*text_heap
;
40 struct nouveau_resource
*lib_code
; /* allocated from text_heap */
42 struct nvc0_blitctx
*blitctx
;
45 struct nouveau_bo
*bo
[NVC0_SCRATCH_NR_BUFFERS
];
54 uint32_t lock
[NVC0_TIC_MAX_ENTRIES
/ 32];
60 uint32_t lock
[NVC0_TSC_MAX_ENTRIES
/ 32];
64 struct nouveau_bo
*bo
;
68 struct nouveau_mman
*mm_VRAM_fe0
;
70 struct nouveau_grobj
*fermi
;
71 struct nouveau_grobj
*eng2d
;
72 struct nouveau_grobj
*m2mf
;
75 static INLINE
struct nvc0_screen
*
76 nvc0_screen(struct pipe_screen
*screen
)
78 return (struct nvc0_screen
*)screen
;
81 boolean
nvc0_blitctx_create(struct nvc0_screen
*);
83 void nvc0_screen_make_buffers_resident(struct nvc0_screen
*);
85 int nvc0_screen_tic_alloc(struct nvc0_screen
*, void *);
86 int nvc0_screen_tsc_alloc(struct nvc0_screen
*, void *);
89 nvc0_resource_fence(struct nv04_resource
*res
, uint32_t flags
)
91 struct nvc0_screen
*screen
= nvc0_screen(res
->base
.screen
);
94 nouveau_fence_ref(screen
->base
.fence
.current
, &res
->fence
);
96 if (flags
& NOUVEAU_BO_WR
)
97 nouveau_fence_ref(screen
->base
.fence
.current
, &res
->fence_wr
);
102 nvc0_resource_validate(struct nv04_resource
*res
, uint32_t flags
)
104 struct nvc0_screen
*screen
= nvc0_screen(res
->base
.screen
);
106 if (likely(res
->bo
)) {
107 nouveau_bo_validate(screen
->base
.channel
, res
->bo
, flags
);
109 if (flags
& NOUVEAU_BO_WR
)
110 res
->status
|= NOUVEAU_BUFFER_STATUS_GPU_WRITING
;
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));