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
;
41 uint8_t patch_vertices
;
42 uint8_t vbo_mode
; /* 0 = normal, 1 = translate, 3 = translate, forced */
45 uint8_t num_textures
[6];
46 uint8_t num_samplers
[6];
47 uint8_t tls_required
; /* bitmask of shader types using l[] */
48 uint8_t c14_bound
; /* whether immediate array constbuf is bound */
51 uint32_t uniform_buffer_bound
[5];
52 struct nvc0_transform_feedback_state
*tfb
;
56 struct nouveau_screen base
;
58 struct nvc0_context
*cur_ctx
;
59 struct nvc0_graph_state save_state
;
61 int num_occlusion_queries_active
;
63 struct nouveau_bo
*text
;
64 struct nouveau_bo
*parm
; /* for COMPUTE */
65 struct nouveau_bo
*uniform_bo
; /* for 3D */
66 struct nouveau_bo
*tls
;
67 struct nouveau_bo
*txc
; /* TIC (offset 0) and TSC (65536) */
68 struct nouveau_bo
*poly_cache
;
71 uint16_t mp_count_compute
; /* magic reg can make compute use fewer MPs */
73 struct nouveau_heap
*text_heap
;
74 struct nouveau_heap
*lib_code
; /* allocated from text_heap */
76 struct nvc0_blitter
*blitter
;
81 uint32_t lock
[NVC0_TIC_MAX_ENTRIES
/ 32];
87 uint32_t lock
[NVC0_TSC_MAX_ENTRIES
/ 32];
91 struct nouveau_bo
*bo
;
96 struct nvc0_program
*prog
; /* compute state object to read MP counters */
97 struct pipe_query
*mp_counter
[8]; /* counter to query allocation */
98 uint8_t num_hw_sm_active
[2];
99 bool mp_counters_enabled
;
102 struct nouveau_object
*eng3d
; /* sqrt(1/2)|kepler> + sqrt(1/2)|fermi> */
103 struct nouveau_object
*eng2d
;
104 struct nouveau_object
*m2mf
;
105 struct nouveau_object
*compute
;
106 struct nouveau_object
*nvsw
;
109 static inline struct nvc0_screen
*
110 nvc0_screen(struct pipe_screen
*screen
)
112 return (struct nvc0_screen
*)screen
;
115 int nvc0_screen_get_driver_query_info(struct pipe_screen
*, unsigned,
116 struct pipe_driver_query_info
*);
118 int nvc0_screen_get_driver_query_group_info(struct pipe_screen
*, unsigned,
119 struct pipe_driver_query_group_info
*);
121 bool nvc0_blitter_create(struct nvc0_screen
*);
122 void nvc0_blitter_destroy(struct nvc0_screen
*);
124 void nvc0_screen_make_buffers_resident(struct nvc0_screen
*);
126 int nvc0_screen_tic_alloc(struct nvc0_screen
*, void *);
127 int nvc0_screen_tsc_alloc(struct nvc0_screen
*, void *);
129 int nve4_screen_compute_setup(struct nvc0_screen
*, struct nouveau_pushbuf
*);
130 int nvc0_screen_compute_setup(struct nvc0_screen
*, struct nouveau_pushbuf
*);
132 bool nvc0_screen_resize_tls_area(struct nvc0_screen
*, uint32_t lpos
,
133 uint32_t lneg
, uint32_t cstack
);
136 nvc0_resource_fence(struct nv04_resource
*res
, uint32_t flags
)
138 struct nvc0_screen
*screen
= nvc0_screen(res
->base
.screen
);
141 nouveau_fence_ref(screen
->base
.fence
.current
, &res
->fence
);
142 if (flags
& NOUVEAU_BO_WR
)
143 nouveau_fence_ref(screen
->base
.fence
.current
, &res
->fence_wr
);
148 nvc0_resource_validate(struct nv04_resource
*res
, uint32_t flags
)
150 if (likely(res
->bo
)) {
151 if (flags
& NOUVEAU_BO_WR
)
152 res
->status
|= NOUVEAU_BUFFER_STATUS_GPU_WRITING
|
153 NOUVEAU_BUFFER_STATUS_DIRTY
;
154 if (flags
& NOUVEAU_BO_RD
)
155 res
->status
|= NOUVEAU_BUFFER_STATUS_GPU_READING
;
157 nvc0_resource_fence(res
, flags
);
168 extern const struct nvc0_format nvc0_format_table
[];
171 nvc0_screen_tic_unlock(struct nvc0_screen
*screen
, struct nv50_tic_entry
*tic
)
174 screen
->tic
.lock
[tic
->id
/ 32] &= ~(1 << (tic
->id
% 32));
178 nvc0_screen_tsc_unlock(struct nvc0_screen
*screen
, struct nv50_tsc_entry
*tsc
)
181 screen
->tsc
.lock
[tsc
->id
/ 32] &= ~(1 << (tsc
->id
% 32));
185 nvc0_screen_tic_free(struct nvc0_screen
*screen
, struct nv50_tic_entry
*tic
)
188 screen
->tic
.entries
[tic
->id
] = NULL
;
189 screen
->tic
.lock
[tic
->id
/ 32] &= ~(1 << (tic
->id
% 32));
194 nvc0_screen_tsc_free(struct nvc0_screen
*screen
, struct nv50_tsc_entry
*tsc
)
197 screen
->tsc
.entries
[tsc
->id
] = NULL
;
198 screen
->tsc
.lock
[tsc
->id
/ 32] &= ~(1 << (tsc
->id
% 32));