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
20 #define NVC0_MAX_SURFACE_SLOTS 16
22 #define NVC0_MAX_VIEWPORTS 16
24 #define NVC0_MAX_BUFFERS 32
31 struct nvc0_graph_state
{
33 bool rasterizer_discard
;
36 uint32_t instance_elts
; /* bitmask of per-instance elements */
37 uint32_t instance_base
;
38 uint32_t constant_vbos
;
39 uint32_t constant_elts
;
43 uint8_t patch_vertices
;
44 uint8_t vbo_mode
; /* 0 = normal, 1 = translate, 3 = translate, forced */
47 uint8_t num_textures
[6];
48 uint8_t num_samplers
[6];
49 uint8_t tls_required
; /* bitmask of shader types using l[] */
50 uint8_t c14_bound
; /* whether immediate array constbuf is bound */
53 uint32_t uniform_buffer_bound
[6];
54 struct nvc0_transform_feedback_state
*tfb
;
55 bool seamless_cube_map
;
59 struct nouveau_screen base
;
61 struct nvc0_context
*cur_ctx
;
62 struct nvc0_graph_state save_state
;
64 int num_occlusion_queries_active
;
66 struct nouveau_bo
*text
;
67 struct nouveau_bo
*parm
; /* for COMPUTE */
68 struct nouveau_bo
*uniform_bo
;
69 struct nouveau_bo
*tls
;
70 struct nouveau_bo
*txc
; /* TIC (offset 0) and TSC (65536) */
71 struct nouveau_bo
*poly_cache
;
75 uint16_t mp_count_compute
; /* magic reg can make compute use fewer MPs */
77 struct nouveau_heap
*text_heap
;
78 struct nouveau_heap
*lib_code
; /* allocated from text_heap */
80 struct nvc0_blitter
*blitter
;
85 uint32_t lock
[NVC0_TIC_MAX_ENTRIES
/ 32];
92 uint32_t lock
[NVC0_TSC_MAX_ENTRIES
/ 32];
96 struct nouveau_bo
*bo
;
101 struct nvc0_program
*prog
; /* compute state object to read MP counters */
102 struct nvc0_hw_sm_query
*mp_counter
[8]; /* counter to query allocation */
103 uint8_t num_hw_sm_active
[2];
104 bool mp_counters_enabled
;
107 struct nouveau_object
*eng3d
; /* sqrt(1/2)|kepler> + sqrt(1/2)|fermi> */
108 struct nouveau_object
*eng2d
;
109 struct nouveau_object
*m2mf
;
110 struct nouveau_object
*compute
;
111 struct nouveau_object
*nvsw
;
114 static inline struct nvc0_screen
*
115 nvc0_screen(struct pipe_screen
*screen
)
117 return (struct nvc0_screen
*)screen
;
120 int nvc0_screen_get_driver_query_info(struct pipe_screen
*, unsigned,
121 struct pipe_driver_query_info
*);
123 int nvc0_screen_get_driver_query_group_info(struct pipe_screen
*, unsigned,
124 struct pipe_driver_query_group_info
*);
126 bool nvc0_blitter_create(struct nvc0_screen
*);
127 void nvc0_blitter_destroy(struct nvc0_screen
*);
129 void nvc0_screen_make_buffers_resident(struct nvc0_screen
*);
131 int nvc0_screen_tic_alloc(struct nvc0_screen
*, void *);
132 int nvc0_screen_tsc_alloc(struct nvc0_screen
*, void *);
134 int nve4_screen_compute_setup(struct nvc0_screen
*, struct nouveau_pushbuf
*);
135 int nvc0_screen_compute_setup(struct nvc0_screen
*, struct nouveau_pushbuf
*);
137 bool nvc0_screen_resize_tls_area(struct nvc0_screen
*, uint32_t lpos
,
138 uint32_t lneg
, uint32_t cstack
);
141 nvc0_resource_fence(struct nv04_resource
*res
, uint32_t flags
)
143 struct nvc0_screen
*screen
= nvc0_screen(res
->base
.screen
);
146 nouveau_fence_ref(screen
->base
.fence
.current
, &res
->fence
);
147 if (flags
& NOUVEAU_BO_WR
)
148 nouveau_fence_ref(screen
->base
.fence
.current
, &res
->fence_wr
);
153 nvc0_resource_validate(struct nv04_resource
*res
, uint32_t flags
)
155 if (likely(res
->bo
)) {
156 if (flags
& NOUVEAU_BO_WR
)
157 res
->status
|= NOUVEAU_BUFFER_STATUS_GPU_WRITING
|
158 NOUVEAU_BUFFER_STATUS_DIRTY
;
159 if (flags
& NOUVEAU_BO_RD
)
160 res
->status
|= NOUVEAU_BUFFER_STATUS_GPU_READING
;
162 nvc0_resource_fence(res
, flags
);
182 struct nvc0_vertex_format
{
187 extern const struct nvc0_format nvc0_format_table
[];
188 extern const struct nvc0_vertex_format nvc0_vertex_format
[];
191 nvc0_screen_tic_unlock(struct nvc0_screen
*screen
, struct nv50_tic_entry
*tic
)
194 screen
->tic
.lock
[tic
->id
/ 32] &= ~(1 << (tic
->id
% 32));
198 nvc0_screen_tsc_unlock(struct nvc0_screen
*screen
, struct nv50_tsc_entry
*tsc
)
201 screen
->tsc
.lock
[tsc
->id
/ 32] &= ~(1 << (tsc
->id
% 32));
205 nvc0_screen_tic_free(struct nvc0_screen
*screen
, struct nv50_tic_entry
*tic
)
208 screen
->tic
.entries
[tic
->id
] = NULL
;
209 screen
->tic
.lock
[tic
->id
/ 32] &= ~(1 << (tic
->id
% 32));
214 nvc0_screen_tsc_free(struct nvc0_screen
*screen
, struct nv50_tsc_entry
*tsc
)
217 screen
->tsc
.entries
[tsc
->id
] = NULL
;
218 screen
->tsc
.lock
[tsc
->id
/ 32] &= ~(1 << (tsc
->id
% 32));