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 driver-reserved slot */
18 #define NVC0_MAX_PIPE_CONSTBUFS 15
20 #define NVC0_MAX_SURFACE_SLOTS 16
22 #define NVC0_MAX_VIEWPORTS 16
24 #define NVC0_MAX_BUFFERS 32
26 #define NVC0_MAX_IMAGES 8
28 #define NVC0_MAX_WINDOW_RECTANGLES 8
34 struct nvc0_graph_state
{
36 bool rasterizer_discard
;
39 uint32_t instance_elts
; /* bitmask of per-instance elements */
40 uint32_t instance_base
;
41 uint32_t constant_vbos
;
42 uint32_t constant_elts
;
46 uint8_t patch_vertices
;
47 uint8_t vbo_mode
; /* 0 = normal, 1 = translate, 3 = translate, forced */
50 uint8_t num_textures
[6];
51 uint8_t num_samplers
[6];
52 uint8_t tls_required
; /* bitmask of shader types using l[] */
55 uint32_t uniform_buffer_bound
[6];
56 struct nvc0_transform_feedback_state
*tfb
;
57 bool seamless_cube_map
;
61 struct nouveau_screen base
;
63 struct nvc0_context
*cur_ctx
;
64 struct nvc0_graph_state save_state
;
66 int num_occlusion_queries_active
;
68 struct nouveau_bo
*text
;
69 struct nouveau_bo
*uniform_bo
;
70 struct nouveau_bo
*tls
;
71 struct nouveau_bo
*txc
; /* TIC (offset 0) and TSC (65536) */
72 struct nouveau_bo
*poly_cache
;
76 uint16_t mp_count_compute
; /* magic reg can make compute use fewer MPs */
78 struct nouveau_heap
*text_heap
;
79 struct nouveau_heap
*lib_code
; /* allocated from text_heap */
81 struct nvc0_blitter
*blitter
;
83 struct nv50_tsc_entry
*default_tsc
;
88 uint32_t lock
[NVC0_TIC_MAX_ENTRIES
/ 32];
95 uint32_t lock
[NVC0_TSC_MAX_ENTRIES
/ 32];
99 struct nouveau_bo
*bo
;
104 struct nvc0_program
*prog
; /* compute state object to read MP counters */
105 struct nvc0_hw_sm_query
*mp_counter
[8]; /* counter to query allocation */
106 uint8_t num_hw_sm_active
[2];
107 bool mp_counters_enabled
;
110 struct nouveau_object
*eng3d
; /* sqrt(1/2)|kepler> + sqrt(1/2)|fermi> */
111 struct nouveau_object
*eng2d
;
112 struct nouveau_object
*m2mf
;
113 struct nouveau_object
*compute
;
114 struct nouveau_object
*nvsw
;
117 static inline struct nvc0_screen
*
118 nvc0_screen(struct pipe_screen
*screen
)
120 return (struct nvc0_screen
*)screen
;
123 int nvc0_screen_get_driver_query_info(struct pipe_screen
*, unsigned,
124 struct pipe_driver_query_info
*);
126 int nvc0_screen_get_driver_query_group_info(struct pipe_screen
*, unsigned,
127 struct pipe_driver_query_group_info
*);
129 bool nvc0_blitter_create(struct nvc0_screen
*);
130 void nvc0_blitter_destroy(struct nvc0_screen
*);
132 void nvc0_screen_make_buffers_resident(struct nvc0_screen
*);
134 int nvc0_screen_tic_alloc(struct nvc0_screen
*, void *);
135 int nvc0_screen_tsc_alloc(struct nvc0_screen
*, void *);
137 int nve4_screen_compute_setup(struct nvc0_screen
*, struct nouveau_pushbuf
*);
138 int nvc0_screen_compute_setup(struct nvc0_screen
*, struct nouveau_pushbuf
*);
140 int nvc0_screen_resize_text_area(struct nvc0_screen
*, uint64_t);
143 nvc0_resource_fence(struct nv04_resource
*res
, uint32_t flags
)
145 struct nvc0_screen
*screen
= nvc0_screen(res
->base
.screen
);
148 nouveau_fence_ref(screen
->base
.fence
.current
, &res
->fence
);
149 if (flags
& NOUVEAU_BO_WR
)
150 nouveau_fence_ref(screen
->base
.fence
.current
, &res
->fence_wr
);
155 nvc0_resource_validate(struct nv04_resource
*res
, uint32_t flags
)
157 if (likely(res
->bo
)) {
158 if (flags
& NOUVEAU_BO_WR
)
159 res
->status
|= NOUVEAU_BUFFER_STATUS_GPU_WRITING
|
160 NOUVEAU_BUFFER_STATUS_DIRTY
;
161 if (flags
& NOUVEAU_BO_RD
)
162 res
->status
|= NOUVEAU_BUFFER_STATUS_GPU_READING
;
164 nvc0_resource_fence(res
, flags
);
184 struct nvc0_vertex_format
{
189 extern const struct nvc0_format nvc0_format_table
[];
190 extern const struct nvc0_vertex_format nvc0_vertex_format
[];
193 nvc0_screen_tic_unlock(struct nvc0_screen
*screen
, struct nv50_tic_entry
*tic
)
196 screen
->tic
.lock
[tic
->id
/ 32] &= ~(1 << (tic
->id
% 32));
200 nvc0_screen_tsc_unlock(struct nvc0_screen
*screen
, struct nv50_tsc_entry
*tsc
)
203 screen
->tsc
.lock
[tsc
->id
/ 32] &= ~(1 << (tsc
->id
% 32));
207 nvc0_screen_tic_free(struct nvc0_screen
*screen
, struct nv50_tic_entry
*tic
)
210 screen
->tic
.entries
[tic
->id
] = NULL
;
211 screen
->tic
.lock
[tic
->id
/ 32] &= ~(1 << (tic
->id
% 32));
216 nvc0_screen_tsc_free(struct nvc0_screen
*screen
, struct nv50_tsc_entry
*tsc
)
219 screen
->tsc
.entries
[tsc
->id
] = NULL
;
220 screen
->tsc
.lock
[tsc
->id
/ 32] &= ~(1 << (tsc
->id
% 32));