1 #ifndef __NVC0_SCREEN_H__
2 #define __NVC0_SCREEN_H__
4 #include "nouveau_screen.h"
5 #include "nouveau_mm.h"
6 #include "nouveau_fence.h"
7 #include "nouveau_heap.h"
9 #include "nv_object.xml.h"
11 #include "nvc0/nvc0_winsys.h"
12 #include "nvc0/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
23 #define NVC0_MAX_VIEWPORTS 16
30 struct nvc0_graph_state
{
32 bool rasterizer_discard
;
35 uint32_t instance_elts
; /* bitmask of per-instance elements */
36 uint32_t instance_base
;
37 uint32_t constant_vbos
;
38 uint32_t constant_elts
;
42 uint8_t patch_vertices
;
43 uint8_t vbo_mode
; /* 0 = normal, 1 = translate, 3 = translate, forced */
46 uint8_t num_textures
[6];
47 uint8_t num_samplers
[6];
48 uint8_t tls_required
; /* bitmask of shader types using l[] */
49 uint8_t c14_bound
; /* whether immediate array constbuf is bound */
52 uint32_t uniform_buffer_bound
[5];
53 struct nvc0_transform_feedback_state
*tfb
;
57 struct nouveau_screen base
;
59 struct nvc0_context
*cur_ctx
;
60 struct nvc0_graph_state save_state
;
62 int num_occlusion_queries_active
;
64 struct nouveau_bo
*text
;
65 struct nouveau_bo
*parm
; /* for COMPUTE */
66 struct nouveau_bo
*uniform_bo
; /* for 3D */
67 struct nouveau_bo
*tls
;
68 struct nouveau_bo
*txc
; /* TIC (offset 0) and TSC (65536) */
69 struct nouveau_bo
*poly_cache
;
73 uint16_t mp_count_compute
; /* magic reg can make compute use fewer MPs */
75 struct nouveau_heap
*text_heap
;
76 struct nouveau_heap
*lib_code
; /* allocated from text_heap */
78 struct nvc0_blitter
*blitter
;
83 uint32_t lock
[NVC0_TIC_MAX_ENTRIES
/ 32];
89 uint32_t lock
[NVC0_TSC_MAX_ENTRIES
/ 32];
93 struct nouveau_bo
*bo
;
98 struct nvc0_program
*prog
; /* compute state object to read MP counters */
99 struct nvc0_hw_sm_query
*mp_counter
[8]; /* counter to query allocation */
100 uint8_t num_hw_sm_active
[2];
101 bool mp_counters_enabled
;
104 struct nouveau_object
*eng3d
; /* sqrt(1/2)|kepler> + sqrt(1/2)|fermi> */
105 struct nouveau_object
*eng2d
;
106 struct nouveau_object
*m2mf
;
107 struct nouveau_object
*compute
;
108 struct nouveau_object
*nvsw
;
111 static inline struct nvc0_screen
*
112 nvc0_screen(struct pipe_screen
*screen
)
114 return (struct nvc0_screen
*)screen
;
117 int nvc0_screen_get_driver_query_info(struct pipe_screen
*, unsigned,
118 struct pipe_driver_query_info
*);
120 int nvc0_screen_get_driver_query_group_info(struct pipe_screen
*, unsigned,
121 struct pipe_driver_query_group_info
*);
123 bool nvc0_blitter_create(struct nvc0_screen
*);
124 void nvc0_blitter_destroy(struct nvc0_screen
*);
126 void nvc0_screen_make_buffers_resident(struct nvc0_screen
*);
128 int nvc0_screen_tic_alloc(struct nvc0_screen
*, void *);
129 int nvc0_screen_tsc_alloc(struct nvc0_screen
*, void *);
131 int nve4_screen_compute_setup(struct nvc0_screen
*, struct nouveau_pushbuf
*);
132 int nvc0_screen_compute_setup(struct nvc0_screen
*, struct nouveau_pushbuf
*);
134 bool nvc0_screen_resize_tls_area(struct nvc0_screen
*, uint32_t lpos
,
135 uint32_t lneg
, uint32_t cstack
);
138 nvc0_resource_fence(struct nv04_resource
*res
, uint32_t flags
)
140 struct nvc0_screen
*screen
= nvc0_screen(res
->base
.screen
);
143 nouveau_fence_ref(screen
->base
.fence
.current
, &res
->fence
);
144 if (flags
& NOUVEAU_BO_WR
)
145 nouveau_fence_ref(screen
->base
.fence
.current
, &res
->fence_wr
);
150 nvc0_resource_validate(struct nv04_resource
*res
, uint32_t flags
)
152 if (likely(res
->bo
)) {
153 if (flags
& NOUVEAU_BO_WR
)
154 res
->status
|= NOUVEAU_BUFFER_STATUS_GPU_WRITING
|
155 NOUVEAU_BUFFER_STATUS_DIRTY
;
156 if (flags
& NOUVEAU_BO_RD
)
157 res
->status
|= NOUVEAU_BUFFER_STATUS_GPU_READING
;
159 nvc0_resource_fence(res
, flags
);
170 extern const struct nvc0_format nvc0_format_table
[];
173 nvc0_screen_tic_unlock(struct nvc0_screen
*screen
, struct nv50_tic_entry
*tic
)
176 screen
->tic
.lock
[tic
->id
/ 32] &= ~(1 << (tic
->id
% 32));
180 nvc0_screen_tsc_unlock(struct nvc0_screen
*screen
, struct nv50_tsc_entry
*tsc
)
183 screen
->tsc
.lock
[tsc
->id
/ 32] &= ~(1 << (tsc
->id
% 32));
187 nvc0_screen_tic_free(struct nvc0_screen
*screen
, struct nv50_tic_entry
*tic
)
190 screen
->tic
.entries
[tic
->id
] = NULL
;
191 screen
->tic
.lock
[tic
->id
/ 32] &= ~(1 << (tic
->id
% 32));
196 nvc0_screen_tsc_free(struct nvc0_screen
*screen
, struct nv50_tsc_entry
*tsc
)
199 screen
->tsc
.entries
[tsc
->id
] = NULL
;
200 screen
->tsc
.lock
[tsc
->id
/ 32] &= ~(1 << (tsc
->id
% 32));