1 #ifndef __NVC0_SCREEN_H__
2 #define __NVC0_SCREEN_H__
5 #include "nouveau/nouveau_screen.h"
7 #include "nvc0_winsys.h"
8 #include "nvc0_stateobj.h"
10 #define NVC0_TIC_MAX_ENTRIES 2048
11 #define NVC0_TSC_MAX_ENTRIES 2048
17 #define NVC0_SCRATCH_SIZE (2 << 20)
18 #define NVC0_SCRATCH_NR_BUFFERS 2
21 struct nouveau_screen base
;
22 struct nouveau_winsys
*nvws
;
24 struct nvc0_context
*cur_ctx
;
26 struct nouveau_bo
*text
;
27 struct nouveau_bo
*uniforms
;
28 struct nouveau_bo
*tls
;
29 struct nouveau_bo
*txc
; /* TIC (offset 0) and TSC (65536) */
30 struct nouveau_bo
*mp_stack_bo
;
34 struct nouveau_resource
*text_heap
;
37 struct nouveau_bo
*bo
[NVC0_SCRATCH_NR_BUFFERS
];
46 uint32_t lock
[NVC0_TIC_MAX_ENTRIES
/ 32];
52 uint32_t lock
[NVC0_TSC_MAX_ENTRIES
/ 32];
57 struct nvc0_fence
*head
;
58 struct nvc0_fence
*tail
;
59 struct nvc0_fence
*current
;
61 uint32_t sequence_ack
;
62 struct nouveau_bo
*bo
;
65 struct nvc0_mman
*mm_GART
;
66 struct nvc0_mman
*mm_VRAM
;
67 struct nvc0_mman
*mm_VRAM_fe0
;
69 struct nouveau_grobj
*fermi
;
70 struct nouveau_grobj
*eng2d
;
71 struct nouveau_grobj
*m2mf
;
74 static INLINE
struct nvc0_screen
*
75 nvc0_screen(struct pipe_screen
*screen
)
77 return (struct nvc0_screen
*)screen
;
80 /* Since a resource can be migrated, we need to decouple allocations from
81 * them. This struct is linked with fences for delayed freeing of allocs.
83 struct nvc0_mm_allocation
{
84 struct nvc0_mm_allocation
*next
;
89 extern struct nvc0_mman
*
90 nvc0_mm_create(struct nouveau_device
*, uint32_t domain
, uint32_t storage_type
);
92 extern struct nvc0_mm_allocation
*
93 nvc0_mm_allocate(struct nvc0_mman
*,
94 uint32_t size
, struct nouveau_bo
**, uint32_t *offset
);
96 nvc0_mm_free(struct nvc0_mm_allocation
*);
98 void nvc0_screen_make_buffers_resident(struct nvc0_screen
*);
100 int nvc0_screen_tic_alloc(struct nvc0_screen
*, void *);
101 int nvc0_screen_tsc_alloc(struct nvc0_screen
*, void *);
104 nvc0_resource_validate(struct nvc0_resource
*res
, uint32_t flags
)
106 struct nvc0_screen
*screen
= nvc0_screen(res
->base
.screen
);
110 nvc0_fence_reference(&res
->fence
, screen
->fence
.current
);
112 if (flags
& NOUVEAU_BO_WR
)
113 nvc0_fence_reference(&res
->fence_wr
, screen
->fence
.current
);
115 nouveau_reloc_emit(screen
->base
.channel
,
116 NULL
, 0, NULL
, res
->bo
, 0, 0, NOUVEAU_BO_RDWR
, 0, 0);
121 nvc0_screen_fence_new(struct nvc0_screen
*, struct nvc0_fence
**, boolean emit
);
124 nvc0_screen_fence_next(struct nvc0_screen
*);
126 static INLINE boolean
127 nvc0_screen_fence_emit(struct nvc0_screen
*screen
)
129 nvc0_fence_emit(screen
->fence
.current
);
131 return nvc0_screen_fence_new(screen
, &screen
->fence
.current
, FALSE
);
141 extern const struct nvc0_format nvc0_format_table
[];
144 nvc0_screen_tic_unlock(struct nvc0_screen
*screen
, struct nvc0_tic_entry
*tic
)
147 screen
->tic
.lock
[tic
->id
/ 32] &= ~(1 << (tic
->id
% 32));
151 nvc0_screen_tsc_unlock(struct nvc0_screen
*screen
, struct nvc0_tsc_entry
*tsc
)
154 screen
->tsc
.lock
[tsc
->id
/ 32] &= ~(1 << (tsc
->id
% 32));
158 nvc0_screen_tic_free(struct nvc0_screen
*screen
, struct nvc0_tic_entry
*tic
)
161 screen
->tic
.entries
[tic
->id
] = NULL
;
162 screen
->tic
.lock
[tic
->id
/ 32] &= ~(1 << (tic
->id
% 32));
167 nvc0_screen_tsc_free(struct nvc0_screen
*screen
, struct nvc0_tsc_entry
*tsc
)
170 screen
->tsc
.entries
[tsc
->id
] = NULL
;
171 screen
->tsc
.lock
[tsc
->id
/ 32] &= ~(1 << (tsc
->id
% 32));