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_GLOBALS 16
28 #define ONE_TEMP_SIZE (4/*vector*/ * sizeof(float))
32 struct nv50_graph_state
{
33 uint32_t instance_elts
; /* bitmask of per-instance elements */
34 uint32_t instance_base
;
35 uint32_t interpolant_ctrl
;
36 uint32_t semantic_color
;
37 uint32_t semantic_psize
;
39 bool uniform_buffer_bound
[3];
44 bool rasterizer_discard
;
49 uint8_t num_textures
[3];
50 uint8_t num_samplers
[3];
56 struct nouveau_screen base
;
58 struct nv50_context
*cur_ctx
;
59 struct nv50_graph_state save_state
;
61 int num_occlusion_queries_active
;
63 struct nouveau_bo
*code
;
64 struct nouveau_bo
*uniforms
;
65 struct nouveau_bo
*txc
; /* TIC (offset 0) and TSC (65536) */
66 struct nouveau_bo
*stack_bo
;
67 struct nouveau_bo
*tls_bo
;
71 unsigned max_tls_space
;
72 unsigned cur_tls_space
;
75 struct nouveau_heap
*vp_code_heap
;
76 struct nouveau_heap
*gp_code_heap
;
77 struct nouveau_heap
*fp_code_heap
;
79 struct nv50_blitter
*blitter
;
84 uint32_t lock
[NV50_TIC_MAX_ENTRIES
/ 32];
90 uint32_t lock
[NV50_TSC_MAX_ENTRIES
/ 32];
95 struct nouveau_bo
*bo
;
99 struct nv50_program
*prog
; /* compute state object to read MP counters */
100 struct nv50_hw_sm_query
*mp_counter
[4]; /* counter to query allocation */
101 uint8_t num_hw_sm_active
;
104 struct nouveau_object
*sync
;
106 struct nouveau_object
*tesla
;
107 struct nouveau_object
*compute
;
108 struct nouveau_object
*eng2d
;
109 struct nouveau_object
*m2mf
;
112 static inline struct nv50_screen
*
113 nv50_screen(struct pipe_screen
*screen
)
115 return (struct nv50_screen
*)screen
;
118 int nv50_screen_get_driver_query_info(struct pipe_screen
*, unsigned,
119 struct pipe_driver_query_info
*);
120 int nv50_screen_get_driver_query_group_info(struct pipe_screen
*, unsigned,
121 struct pipe_driver_query_group_info
*);
123 bool nv50_blitter_create(struct nv50_screen
*);
124 void nv50_blitter_destroy(struct nv50_screen
*);
126 int nv50_screen_tic_alloc(struct nv50_screen
*, void *);
127 int nv50_screen_tsc_alloc(struct nv50_screen
*, void *);
129 int nv50_screen_compute_setup(struct nv50_screen
*, struct nouveau_pushbuf
*);
132 nv50_resource_fence(struct nv04_resource
*res
, uint32_t flags
)
134 struct nv50_screen
*screen
= nv50_screen(res
->base
.screen
);
137 nouveau_fence_ref(screen
->base
.fence
.current
, &res
->fence
);
138 if (flags
& NOUVEAU_BO_WR
)
139 nouveau_fence_ref(screen
->base
.fence
.current
, &res
->fence_wr
);
144 nv50_resource_validate(struct nv04_resource
*res
, uint32_t flags
)
146 if (likely(res
->bo
)) {
147 if (flags
& NOUVEAU_BO_WR
)
148 res
->status
|= NOUVEAU_BUFFER_STATUS_GPU_WRITING
|
149 NOUVEAU_BUFFER_STATUS_DIRTY
;
150 if (flags
& NOUVEAU_BO_RD
)
151 res
->status
|= NOUVEAU_BUFFER_STATUS_GPU_READING
;
153 nv50_resource_fence(res
, flags
);
173 struct nv50_vertex_format
{
178 extern const struct nv50_format nv50_format_table
[];
179 extern const struct nv50_vertex_format nv50_vertex_format
[];
182 nv50_screen_tic_unlock(struct nv50_screen
*screen
, struct nv50_tic_entry
*tic
)
185 screen
->tic
.lock
[tic
->id
/ 32] &= ~(1 << (tic
->id
% 32));
189 nv50_screen_tsc_unlock(struct nv50_screen
*screen
, struct nv50_tsc_entry
*tsc
)
192 screen
->tsc
.lock
[tsc
->id
/ 32] &= ~(1 << (tsc
->id
% 32));
196 nv50_screen_tic_free(struct nv50_screen
*screen
, struct nv50_tic_entry
*tic
)
199 screen
->tic
.entries
[tic
->id
] = NULL
;
200 screen
->tic
.lock
[tic
->id
/ 32] &= ~(1 << (tic
->id
% 32));
205 nv50_screen_tsc_free(struct nv50_screen
*screen
, struct nv50_tsc_entry
*tsc
)
208 screen
->tsc
.entries
[tsc
->id
] = NULL
;
209 screen
->tsc
.lock
[tsc
->id
/ 32] &= ~(1 << (tsc
->id
% 32));
213 extern int nv50_tls_realloc(struct nv50_screen
*screen
, unsigned tls_space
);