1 #ifndef __NV50_SCREEN_H__
2 #define __NV50_SCREEN_H__
4 #include "nouveau_screen.h"
5 #include "nouveau_fence.h"
6 #include "nouveau_mm.h"
7 #include "nouveau_heap.h"
9 #include "nv50/nv50_winsys.h"
10 #include "nv50/nv50_stateobj.h"
12 #define NV50_TIC_MAX_ENTRIES 2048
13 #define NV50_TSC_MAX_ENTRIES 2048
15 /* doesn't count reserved slots (for auxiliary constants, immediates, etc.) */
16 #define NV50_MAX_PIPE_CONSTBUFS 14
20 #define NV50_CODE_BO_SIZE_LOG2 19
22 #define NV50_SCREEN_RESIDENT_BO_COUNT 5
24 #define NV50_MAX_VIEWPORTS 16
26 #define NV50_MAX_WINDOW_RECTANGLES 8
28 #define NV50_MAX_GLOBALS 16
30 #define ONE_TEMP_SIZE (4/*vector*/ * sizeof(float))
34 struct nv50_graph_state
{
35 uint32_t instance_elts
; /* bitmask of per-instance elements */
36 uint32_t instance_base
;
37 uint32_t interpolant_ctrl
;
38 uint32_t semantic_color
;
39 uint32_t semantic_psize
;
42 bool uniform_buffer_bound
[3];
47 bool rasterizer_discard
;
52 uint8_t num_textures
[3];
53 uint8_t num_samplers
[3];
56 bool seamless_cube_map
;
61 struct nouveau_screen base
;
63 struct nv50_context
*cur_ctx
;
64 struct nv50_graph_state save_state
;
66 int num_occlusion_queries_active
;
68 struct nouveau_bo
*code
;
69 struct nouveau_bo
*uniforms
;
70 struct nouveau_bo
*txc
; /* TIC (offset 0) and TSC (65536) */
71 struct nouveau_bo
*stack_bo
;
72 struct nouveau_bo
*tls_bo
;
76 unsigned max_tls_space
;
77 unsigned cur_tls_space
;
80 struct nouveau_heap
*vp_code_heap
;
81 struct nouveau_heap
*gp_code_heap
;
82 struct nouveau_heap
*fp_code_heap
;
84 struct nv50_blitter
*blitter
;
89 uint32_t lock
[NV50_TIC_MAX_ENTRIES
/ 32];
95 uint32_t lock
[NV50_TSC_MAX_ENTRIES
/ 32];
100 struct nouveau_bo
*bo
;
104 struct nv50_program
*prog
; /* compute state object to read MP counters */
105 struct nv50_hw_sm_query
*mp_counter
[4]; /* counter to query allocation */
106 uint8_t num_hw_sm_active
;
109 struct nouveau_object
*sync
;
111 struct nouveau_object
*tesla
;
112 struct nouveau_object
*compute
;
113 struct nouveau_object
*eng2d
;
114 struct nouveau_object
*m2mf
;
117 static inline struct nv50_screen
*
118 nv50_screen(struct pipe_screen
*screen
)
120 return (struct nv50_screen
*)screen
;
123 int nv50_screen_get_driver_query_info(struct pipe_screen
*, unsigned,
124 struct pipe_driver_query_info
*);
125 int nv50_screen_get_driver_query_group_info(struct pipe_screen
*, unsigned,
126 struct pipe_driver_query_group_info
*);
128 bool nv50_blitter_create(struct nv50_screen
*);
129 void nv50_blitter_destroy(struct nv50_screen
*);
131 int nv50_screen_tic_alloc(struct nv50_screen
*, void *);
132 int nv50_screen_tsc_alloc(struct nv50_screen
*, void *);
134 int nv50_screen_compute_setup(struct nv50_screen
*, struct nouveau_pushbuf
*);
137 nv50_resource_fence(struct nv04_resource
*res
, uint32_t flags
)
139 struct nv50_screen
*screen
= nv50_screen(res
->base
.screen
);
142 nouveau_fence_ref(screen
->base
.fence
.current
, &res
->fence
);
143 if (flags
& NOUVEAU_BO_WR
)
144 nouveau_fence_ref(screen
->base
.fence
.current
, &res
->fence_wr
);
149 nv50_resource_validate(struct nv04_resource
*res
, uint32_t flags
)
151 if (likely(res
->bo
)) {
152 if (flags
& NOUVEAU_BO_WR
)
153 res
->status
|= NOUVEAU_BUFFER_STATUS_GPU_WRITING
|
154 NOUVEAU_BUFFER_STATUS_DIRTY
;
155 if (flags
& NOUVEAU_BO_RD
)
156 res
->status
|= NOUVEAU_BUFFER_STATUS_GPU_READING
;
158 nv50_resource_fence(res
, flags
);
178 struct nv50_vertex_format
{
183 extern const struct nv50_format nv50_format_table
[];
184 extern const struct nv50_vertex_format nv50_vertex_format
[];
187 nv50_screen_tic_unlock(struct nv50_screen
*screen
, struct nv50_tic_entry
*tic
)
190 screen
->tic
.lock
[tic
->id
/ 32] &= ~(1 << (tic
->id
% 32));
194 nv50_screen_tsc_unlock(struct nv50_screen
*screen
, struct nv50_tsc_entry
*tsc
)
197 screen
->tsc
.lock
[tsc
->id
/ 32] &= ~(1 << (tsc
->id
% 32));
201 nv50_screen_tic_free(struct nv50_screen
*screen
, struct nv50_tic_entry
*tic
)
204 screen
->tic
.entries
[tic
->id
] = NULL
;
205 screen
->tic
.lock
[tic
->id
/ 32] &= ~(1 << (tic
->id
% 32));
210 nv50_screen_tsc_free(struct nv50_screen
*screen
, struct nv50_tsc_entry
*tsc
)
213 screen
->tsc
.entries
[tsc
->id
] = NULL
;
214 screen
->tsc
.lock
[tsc
->id
/ 32] &= ~(1 << (tsc
->id
% 32));
218 extern int nv50_tls_realloc(struct nv50_screen
*screen
, unsigned tls_space
);