1bf215546Sopenharmony_ci#ifndef __NVC0_CONTEXT_H__
2bf215546Sopenharmony_ci#define __NVC0_CONTEXT_H__
3bf215546Sopenharmony_ci
4bf215546Sopenharmony_ci#include "pipe/p_context.h"
5bf215546Sopenharmony_ci#include "pipe/p_defines.h"
6bf215546Sopenharmony_ci#include "pipe/p_state.h"
7bf215546Sopenharmony_ci
8bf215546Sopenharmony_ci#include "util/list.h"
9bf215546Sopenharmony_ci#include "util/u_memory.h"
10bf215546Sopenharmony_ci#include "util/u_math.h"
11bf215546Sopenharmony_ci#include "util/u_inlines.h"
12bf215546Sopenharmony_ci#include "util/u_dynarray.h"
13bf215546Sopenharmony_ci
14bf215546Sopenharmony_ci#include "nvc0/nvc0_winsys.h"
15bf215546Sopenharmony_ci#include "nvc0/nvc0_stateobj.h"
16bf215546Sopenharmony_ci#include "nvc0/nvc0_screen.h"
17bf215546Sopenharmony_ci#include "nvc0/nvc0_program.h"
18bf215546Sopenharmony_ci#include "nvc0/nvc0_resource.h"
19bf215546Sopenharmony_ci#include "nvc0/nvc0_query.h"
20bf215546Sopenharmony_ci
21bf215546Sopenharmony_ci#include "nv50/nv50_transfer.h"
22bf215546Sopenharmony_ci
23bf215546Sopenharmony_ci#include "nouveau_context.h"
24bf215546Sopenharmony_ci#include "nouveau_debug.h"
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ci#include "nv50/nv50_3ddefs.xml.h"
27bf215546Sopenharmony_ci#include "nvc0/nvc0_3d.xml.h"
28bf215546Sopenharmony_ci#include "nv50/nv50_2d.xml.h"
29bf215546Sopenharmony_ci#include "nvc0/nvc0_m2mf.xml.h"
30bf215546Sopenharmony_ci#include "nvc0/nve4_copy.xml.h"
31bf215546Sopenharmony_ci#include "nvc0/nve4_p2mf.xml.h"
32bf215546Sopenharmony_ci#include "nvc0/nvc0_compute.xml.h"
33bf215546Sopenharmony_ci#include "nvc0/nvc0_macros.h"
34bf215546Sopenharmony_ci
35bf215546Sopenharmony_ci/* NOTE: must keep NVC0_NEW_3D_...PROG in consecutive bits in this order */
36bf215546Sopenharmony_ci#define NVC0_NEW_3D_BLEND        (1 << 0)
37bf215546Sopenharmony_ci#define NVC0_NEW_3D_RASTERIZER   (1 << 1)
38bf215546Sopenharmony_ci#define NVC0_NEW_3D_ZSA          (1 << 2)
39bf215546Sopenharmony_ci#define NVC0_NEW_3D_VERTPROG     (1 << 3)
40bf215546Sopenharmony_ci#define NVC0_NEW_3D_TCTLPROG     (1 << 4)
41bf215546Sopenharmony_ci#define NVC0_NEW_3D_TEVLPROG     (1 << 5)
42bf215546Sopenharmony_ci#define NVC0_NEW_3D_GMTYPROG     (1 << 6)
43bf215546Sopenharmony_ci#define NVC0_NEW_3D_FRAGPROG     (1 << 7)
44bf215546Sopenharmony_ci#define NVC0_NEW_3D_BLEND_COLOUR (1 << 8)
45bf215546Sopenharmony_ci#define NVC0_NEW_3D_STENCIL_REF  (1 << 9)
46bf215546Sopenharmony_ci#define NVC0_NEW_3D_CLIP         (1 << 10)
47bf215546Sopenharmony_ci#define NVC0_NEW_3D_SAMPLE_MASK  (1 << 11)
48bf215546Sopenharmony_ci#define NVC0_NEW_3D_FRAMEBUFFER  (1 << 12)
49bf215546Sopenharmony_ci#define NVC0_NEW_3D_STIPPLE      (1 << 13)
50bf215546Sopenharmony_ci#define NVC0_NEW_3D_SCISSOR      (1 << 14)
51bf215546Sopenharmony_ci#define NVC0_NEW_3D_VIEWPORT     (1 << 15)
52bf215546Sopenharmony_ci#define NVC0_NEW_3D_ARRAYS       (1 << 16)
53bf215546Sopenharmony_ci#define NVC0_NEW_3D_VERTEX       (1 << 17)
54bf215546Sopenharmony_ci#define NVC0_NEW_3D_CONSTBUF     (1 << 18)
55bf215546Sopenharmony_ci#define NVC0_NEW_3D_TEXTURES     (1 << 19)
56bf215546Sopenharmony_ci#define NVC0_NEW_3D_SAMPLERS     (1 << 20)
57bf215546Sopenharmony_ci#define NVC0_NEW_3D_TFB_TARGETS  (1 << 21)
58bf215546Sopenharmony_ci
59bf215546Sopenharmony_ci#define NVC0_NEW_3D_SURFACES     (1 << 23)
60bf215546Sopenharmony_ci#define NVC0_NEW_3D_MIN_SAMPLES  (1 << 24)
61bf215546Sopenharmony_ci#define NVC0_NEW_3D_TESSFACTOR   (1 << 25)
62bf215546Sopenharmony_ci#define NVC0_NEW_3D_BUFFERS      (1 << 26)
63bf215546Sopenharmony_ci#define NVC0_NEW_3D_DRIVERCONST  (1 << 27)
64bf215546Sopenharmony_ci#define NVC0_NEW_3D_WINDOW_RECTS (1 << 28)
65bf215546Sopenharmony_ci
66bf215546Sopenharmony_ci#define NVC0_NEW_3D_SAMPLE_LOCATIONS (1 << 29)
67bf215546Sopenharmony_ci
68bf215546Sopenharmony_ci#define NVC0_NEW_CP_PROGRAM   (1 << 0)
69bf215546Sopenharmony_ci#define NVC0_NEW_CP_SURFACES  (1 << 1)
70bf215546Sopenharmony_ci#define NVC0_NEW_CP_TEXTURES  (1 << 2)
71bf215546Sopenharmony_ci#define NVC0_NEW_CP_SAMPLERS  (1 << 3)
72bf215546Sopenharmony_ci#define NVC0_NEW_CP_CONSTBUF  (1 << 4)
73bf215546Sopenharmony_ci#define NVC0_NEW_CP_GLOBALS   (1 << 5)
74bf215546Sopenharmony_ci#define NVC0_NEW_CP_DRIVERCONST (1 << 6)
75bf215546Sopenharmony_ci#define NVC0_NEW_CP_BUFFERS   (1 << 7)
76bf215546Sopenharmony_ci
77bf215546Sopenharmony_ci/* 3d bufctx (during draw_vbo, blit_3d) */
78bf215546Sopenharmony_ci#define NVC0_BIND_3D_FB            0
79bf215546Sopenharmony_ci#define NVC0_BIND_3D_VTX           1
80bf215546Sopenharmony_ci#define NVC0_BIND_3D_VTX_TMP       2
81bf215546Sopenharmony_ci#define NVC0_BIND_3D_IDX           3
82bf215546Sopenharmony_ci#define NVC0_BIND_3D_TEX(s, i)  (  4 + 32 * (s) + (i))
83bf215546Sopenharmony_ci#define NVC0_BIND_3D_CB(s, i)   (164 + 16 * (s) + (i))
84bf215546Sopenharmony_ci#define NVC0_BIND_3D_TFB         244
85bf215546Sopenharmony_ci#define NVC0_BIND_3D_SUF         245
86bf215546Sopenharmony_ci#define NVC0_BIND_3D_BUF         246
87bf215546Sopenharmony_ci#define NVC0_BIND_3D_SCREEN      247
88bf215546Sopenharmony_ci#define NVC0_BIND_3D_BINDLESS    248
89bf215546Sopenharmony_ci#define NVC0_BIND_3D_TLS         249
90bf215546Sopenharmony_ci#define NVC0_BIND_3D_TEXT        250
91bf215546Sopenharmony_ci#define NVC0_BIND_3D_COUNT       251
92bf215546Sopenharmony_ci
93bf215546Sopenharmony_ci/* compute bufctx (during launch_grid) */
94bf215546Sopenharmony_ci#define NVC0_BIND_CP_CB(i)     (  0 + (i))
95bf215546Sopenharmony_ci#define NVC0_BIND_CP_TEX(i)    ( 16 + (i))
96bf215546Sopenharmony_ci#define NVC0_BIND_CP_SUF         48
97bf215546Sopenharmony_ci#define NVC0_BIND_CP_GLOBAL      49
98bf215546Sopenharmony_ci#define NVC0_BIND_CP_DESC        50
99bf215546Sopenharmony_ci#define NVC0_BIND_CP_SCREEN      51
100bf215546Sopenharmony_ci#define NVC0_BIND_CP_QUERY       52
101bf215546Sopenharmony_ci#define NVC0_BIND_CP_BUF         53
102bf215546Sopenharmony_ci#define NVC0_BIND_CP_TEXT        54
103bf215546Sopenharmony_ci#define NVC0_BIND_CP_BINDLESS    55
104bf215546Sopenharmony_ci#define NVC0_BIND_CP_COUNT       56
105bf215546Sopenharmony_ci
106bf215546Sopenharmony_ci/* bufctx for other operations */
107bf215546Sopenharmony_ci#define NVC0_BIND_2D            0
108bf215546Sopenharmony_ci#define NVC0_BIND_M2MF          0
109bf215546Sopenharmony_ci#define NVC0_BIND_FENCE         1
110bf215546Sopenharmony_ci
111bf215546Sopenharmony_ci/* 6 user uniform buffers, at 64K each */
112bf215546Sopenharmony_ci#define NVC0_CB_USR_INFO(s)         (s << 16)
113bf215546Sopenharmony_ci#define NVC0_CB_USR_SIZE            (6 << 16)
114bf215546Sopenharmony_ci/* 6 driver constbuts, at 64K each */
115bf215546Sopenharmony_ci#define NVC0_CB_AUX_INFO(s)         NVC0_CB_USR_SIZE + (s << 16)
116bf215546Sopenharmony_ci#define NVC0_CB_AUX_SIZE            (1 << 16)
117bf215546Sopenharmony_ci/* XXX: Figure out what this UNK data is. */
118bf215546Sopenharmony_ci#define NVC0_CB_AUX_UNK_INFO        0x000
119bf215546Sopenharmony_ci#define NVC0_CB_AUX_UNK_SIZE        (8 * 4)
120bf215546Sopenharmony_ci/* 40 textures handles (8 for GM107+ images only), at 1 32-bits integer each */
121bf215546Sopenharmony_ci#define NVC0_CB_AUX_TEX_INFO(i)     0x020 + (i) * 4
122bf215546Sopenharmony_ci#define NVC0_CB_AUX_TEX_SIZE        (40 * 4)
123bf215546Sopenharmony_ci/* 8 sets of 32-bits coordinate offsets */
124bf215546Sopenharmony_ci#define NVC0_CB_AUX_MS_INFO         0x0c0
125bf215546Sopenharmony_ci#define NVC0_CB_AUX_MS_SIZE         (8 * 2 * 4)
126bf215546Sopenharmony_ci/* block/grid size, at 3 32-bits integers each, gridid and work_dim */
127bf215546Sopenharmony_ci#define NVC0_CB_AUX_GRID_INFO(i)    0x100 + (i) * 4 /* CP */
128bf215546Sopenharmony_ci#define NVC0_CB_AUX_GRID_SIZE       (8 * 4)
129bf215546Sopenharmony_ci/* FB texture handle */
130bf215546Sopenharmony_ci#define NVC0_CB_AUX_FB_TEX_INFO     0x100 /* FP */
131bf215546Sopenharmony_ci#define NVC0_CB_AUX_FB_TEX_SIZE     (4)
132bf215546Sopenharmony_ci/* 8 user clip planes, at 4 32-bits floats each */
133bf215546Sopenharmony_ci#define NVC0_CB_AUX_UCP_INFO        0x120
134bf215546Sopenharmony_ci#define NVC0_CB_AUX_UCP_SIZE        (PIPE_MAX_CLIP_PLANES * 4 * 4)
135bf215546Sopenharmony_ci/* 13 ubos, at 4 32-bits integer each */
136bf215546Sopenharmony_ci#define NVC0_CB_AUX_UBO_INFO(i)     0x120 + (i) * 4 * 4 /* CP */
137bf215546Sopenharmony_ci#define NVC0_CB_AUX_UBO_SIZE        ((NVC0_MAX_PIPE_CONSTBUFS - 1) * 4 * 4)
138bf215546Sopenharmony_ci/* 8 sets of 32-bits integer pairs sample offsets */
139bf215546Sopenharmony_ci#define NVC0_CB_AUX_SAMPLE_INFO     0x1a0 /* FP */
140bf215546Sopenharmony_ci/* 256 bytes, though only 64 bytes used before GM200 */
141bf215546Sopenharmony_ci#define NVC0_CB_AUX_SAMPLE_SIZE     (8 * 2 * 4 * 4)
142bf215546Sopenharmony_ci/* draw parameters (index bias, base instance, drawid)
143bf215546Sopenharmony_ci * be sure to update the indirect draw macros in com9097.mme when changing this
144bf215546Sopenharmony_ci */
145bf215546Sopenharmony_ci#define NVC0_CB_AUX_DRAW_INFO       0x1a0 /* VP */
146bf215546Sopenharmony_ci/* 32 user buffers, at 4 32-bits integers each */
147bf215546Sopenharmony_ci#define NVC0_CB_AUX_BUF_INFO(i)     0x2a0 + (i) * 4 * 4
148bf215546Sopenharmony_ci#define NVC0_CB_AUX_BUF_SIZE        (NVC0_MAX_BUFFERS * 4 * 4)
149bf215546Sopenharmony_ci/* 8 surfaces, at 16 32-bits integers each */
150bf215546Sopenharmony_ci#define NVC0_CB_AUX_SU_INFO(i)      0x4a0 + (i) * 16 * 4
151bf215546Sopenharmony_ci#define NVC0_CB_AUX_SU_SIZE         (NVC0_MAX_IMAGES * 16 * 4)
152bf215546Sopenharmony_ci/* 1 64-bits address and 1 32-bits sequence
153bf215546Sopenharmony_ci * be sure to update the shaders in nvc0_query_hw_sm.c when changing this
154bf215546Sopenharmony_ci */
155bf215546Sopenharmony_ci#define NVC0_CB_AUX_MP_INFO         0x6a0
156bf215546Sopenharmony_ci#define NVC0_CB_AUX_MP_SIZE         3 * 4
157bf215546Sopenharmony_ci/* 512 64-byte blocks for bindless image handles */
158bf215546Sopenharmony_ci#define NVC0_CB_AUX_BINDLESS_INFO(i) 0x6b0 + (i) * 16 * 4
159bf215546Sopenharmony_ci#define NVC0_CB_AUX_BINDLESS_SIZE   (NVE4_IMG_MAX_HANDLES * 16 * 4)
160bf215546Sopenharmony_ci/* 4 32-bits floats for the vertex runout, put at the end */
161bf215546Sopenharmony_ci#define NVC0_CB_AUX_RUNOUT_INFO     NVC0_CB_USR_SIZE + (NVC0_CB_AUX_SIZE * 6)
162bf215546Sopenharmony_ci
163bf215546Sopenharmony_cistruct nvc0_blitctx;
164bf215546Sopenharmony_ci
165bf215546Sopenharmony_cibool nvc0_blitctx_create(struct nvc0_context *);
166bf215546Sopenharmony_civoid nvc0_blitctx_destroy(struct nvc0_context *);
167bf215546Sopenharmony_ci
168bf215546Sopenharmony_cistruct nvc0_resident {
169bf215546Sopenharmony_ci   struct list_head list;
170bf215546Sopenharmony_ci   uint64_t handle;
171bf215546Sopenharmony_ci   struct nv04_resource *buf;
172bf215546Sopenharmony_ci   uint32_t flags;
173bf215546Sopenharmony_ci};
174bf215546Sopenharmony_ci
175bf215546Sopenharmony_cistruct nvc0_context {
176bf215546Sopenharmony_ci   struct nouveau_context base;
177bf215546Sopenharmony_ci
178bf215546Sopenharmony_ci   struct nouveau_bufctx *bufctx_3d;
179bf215546Sopenharmony_ci   struct nouveau_bufctx *bufctx;
180bf215546Sopenharmony_ci   struct nouveau_bufctx *bufctx_cp;
181bf215546Sopenharmony_ci
182bf215546Sopenharmony_ci   struct nvc0_screen *screen;
183bf215546Sopenharmony_ci
184bf215546Sopenharmony_ci   void (*m2mf_copy_rect)(struct nvc0_context *,
185bf215546Sopenharmony_ci                          const struct nv50_m2mf_rect *dst,
186bf215546Sopenharmony_ci                          const struct nv50_m2mf_rect *src,
187bf215546Sopenharmony_ci                          uint32_t nblocksx, uint32_t nblocksy);
188bf215546Sopenharmony_ci
189bf215546Sopenharmony_ci   uint32_t dirty_3d; /* dirty flags for 3d state */
190bf215546Sopenharmony_ci   uint32_t dirty_cp; /* dirty flags for compute state */
191bf215546Sopenharmony_ci
192bf215546Sopenharmony_ci   struct nvc0_graph_state state;
193bf215546Sopenharmony_ci
194bf215546Sopenharmony_ci   struct nvc0_blend_stateobj *blend;
195bf215546Sopenharmony_ci   struct nvc0_rasterizer_stateobj *rast;
196bf215546Sopenharmony_ci   struct nvc0_zsa_stateobj *zsa;
197bf215546Sopenharmony_ci   struct nvc0_vertex_stateobj *vertex;
198bf215546Sopenharmony_ci
199bf215546Sopenharmony_ci   struct nvc0_program *vertprog;
200bf215546Sopenharmony_ci   struct nvc0_program *tctlprog;
201bf215546Sopenharmony_ci   struct nvc0_program *tevlprog;
202bf215546Sopenharmony_ci   struct nvc0_program *gmtyprog;
203bf215546Sopenharmony_ci   struct nvc0_program *fragprog;
204bf215546Sopenharmony_ci   struct nvc0_program *compprog;
205bf215546Sopenharmony_ci
206bf215546Sopenharmony_ci   struct nvc0_program *tcp_empty;
207bf215546Sopenharmony_ci
208bf215546Sopenharmony_ci   struct nvc0_constbuf constbuf[6][NVC0_MAX_PIPE_CONSTBUFS];
209bf215546Sopenharmony_ci   uint16_t constbuf_dirty[6];
210bf215546Sopenharmony_ci   uint16_t constbuf_valid[6];
211bf215546Sopenharmony_ci   uint16_t constbuf_coherent[6];
212bf215546Sopenharmony_ci   bool cb_dirty;
213bf215546Sopenharmony_ci
214bf215546Sopenharmony_ci   struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
215bf215546Sopenharmony_ci   unsigned num_vtxbufs;
216bf215546Sopenharmony_ci   uint32_t vtxbufs_coherent;
217bf215546Sopenharmony_ci   uint32_t constant_vbos;
218bf215546Sopenharmony_ci   uint32_t vbo_user; /* bitmask of vertex buffers pointing to user memory */
219bf215546Sopenharmony_ci   uint32_t vb_elt_first; /* from pipe_draw_info, for vertex upload */
220bf215546Sopenharmony_ci   uint32_t vb_elt_limit; /* max - min element (count - 1) */
221bf215546Sopenharmony_ci   uint32_t instance_off; /* current base vertex for instanced arrays */
222bf215546Sopenharmony_ci   uint32_t instance_max; /* last instance for current draw call */
223bf215546Sopenharmony_ci
224bf215546Sopenharmony_ci   struct pipe_sampler_view *textures[6][PIPE_MAX_SAMPLERS];
225bf215546Sopenharmony_ci   unsigned num_textures[6];
226bf215546Sopenharmony_ci   uint32_t textures_dirty[6];
227bf215546Sopenharmony_ci   uint32_t textures_coherent[6];
228bf215546Sopenharmony_ci   struct nv50_tsc_entry *samplers[6][PIPE_MAX_SAMPLERS];
229bf215546Sopenharmony_ci   unsigned num_samplers[6];
230bf215546Sopenharmony_ci   uint32_t samplers_dirty[6];
231bf215546Sopenharmony_ci   bool seamless_cube_map;
232bf215546Sopenharmony_ci   struct pipe_sampler_view *fbtexture;
233bf215546Sopenharmony_ci
234bf215546Sopenharmony_ci   uint32_t tex_handles[6][PIPE_MAX_SAMPLERS]; /* for nve4 */
235bf215546Sopenharmony_ci
236bf215546Sopenharmony_ci   struct list_head tex_head;
237bf215546Sopenharmony_ci   struct list_head img_head;
238bf215546Sopenharmony_ci
239bf215546Sopenharmony_ci   struct pipe_framebuffer_state framebuffer;
240bf215546Sopenharmony_ci   bool sample_locations_enabled;
241bf215546Sopenharmony_ci   uint8_t sample_locations[2 * 4 * 8];
242bf215546Sopenharmony_ci   struct pipe_blend_color blend_colour;
243bf215546Sopenharmony_ci   struct pipe_stencil_ref stencil_ref;
244bf215546Sopenharmony_ci   struct pipe_poly_stipple stipple;
245bf215546Sopenharmony_ci   struct pipe_scissor_state scissors[NVC0_MAX_VIEWPORTS];
246bf215546Sopenharmony_ci   unsigned scissors_dirty;
247bf215546Sopenharmony_ci   struct pipe_viewport_state viewports[NVC0_MAX_VIEWPORTS];
248bf215546Sopenharmony_ci   unsigned viewports_dirty;
249bf215546Sopenharmony_ci   struct pipe_clip_state clip;
250bf215546Sopenharmony_ci   struct nvc0_window_rect_stateobj window_rect;
251bf215546Sopenharmony_ci
252bf215546Sopenharmony_ci   unsigned sample_mask;
253bf215546Sopenharmony_ci   unsigned min_samples;
254bf215546Sopenharmony_ci
255bf215546Sopenharmony_ci   float default_tess_outer[4];
256bf215546Sopenharmony_ci   float default_tess_inner[2];
257bf215546Sopenharmony_ci   uint8_t patch_vertices;
258bf215546Sopenharmony_ci
259bf215546Sopenharmony_ci   bool vbo_push_hint;
260bf215546Sopenharmony_ci
261bf215546Sopenharmony_ci   uint8_t tfbbuf_dirty;
262bf215546Sopenharmony_ci   struct pipe_stream_output_target *tfbbuf[4];
263bf215546Sopenharmony_ci   unsigned num_tfbbufs;
264bf215546Sopenharmony_ci
265bf215546Sopenharmony_ci   struct pipe_query *cond_query;
266bf215546Sopenharmony_ci   bool cond_cond; /* inverted rendering condition */
267bf215546Sopenharmony_ci   uint cond_mode;
268bf215546Sopenharmony_ci   uint32_t cond_condmode; /* the calculated condition */
269bf215546Sopenharmony_ci
270bf215546Sopenharmony_ci   struct nvc0_blitctx *blit;
271bf215546Sopenharmony_ci
272bf215546Sopenharmony_ci   /* NOTE: some of these surfaces may reference buffers */
273bf215546Sopenharmony_ci   struct pipe_surface *surfaces[2][NVC0_MAX_SURFACE_SLOTS];
274bf215546Sopenharmony_ci   uint16_t surfaces_dirty[2];
275bf215546Sopenharmony_ci   uint16_t surfaces_valid[2];
276bf215546Sopenharmony_ci
277bf215546Sopenharmony_ci   struct pipe_shader_buffer buffers[6][NVC0_MAX_BUFFERS];
278bf215546Sopenharmony_ci   uint32_t buffers_dirty[6];
279bf215546Sopenharmony_ci   uint32_t buffers_valid[6];
280bf215546Sopenharmony_ci
281bf215546Sopenharmony_ci   struct pipe_image_view images[6][NVC0_MAX_IMAGES];
282bf215546Sopenharmony_ci   struct pipe_sampler_view *images_tic[6][NVC0_MAX_IMAGES]; /* GM107+ */
283bf215546Sopenharmony_ci   uint16_t images_dirty[6];
284bf215546Sopenharmony_ci   uint16_t images_valid[6];
285bf215546Sopenharmony_ci
286bf215546Sopenharmony_ci   struct util_dynarray global_residents;
287bf215546Sopenharmony_ci
288bf215546Sopenharmony_ci   uint64_t compute_invocations;
289bf215546Sopenharmony_ci};
290bf215546Sopenharmony_ci
291bf215546Sopenharmony_cistatic inline struct nvc0_context *
292bf215546Sopenharmony_cinvc0_context(struct pipe_context *pipe)
293bf215546Sopenharmony_ci{
294bf215546Sopenharmony_ci   return (struct nvc0_context *)pipe;
295bf215546Sopenharmony_ci}
296bf215546Sopenharmony_ci
297bf215546Sopenharmony_cistatic inline unsigned
298bf215546Sopenharmony_cinvc0_shader_stage(unsigned pipe)
299bf215546Sopenharmony_ci{
300bf215546Sopenharmony_ci   switch (pipe) {
301bf215546Sopenharmony_ci   case PIPE_SHADER_VERTEX: return 0;
302bf215546Sopenharmony_ci   case PIPE_SHADER_TESS_CTRL: return 1;
303bf215546Sopenharmony_ci   case PIPE_SHADER_TESS_EVAL: return 2;
304bf215546Sopenharmony_ci   case PIPE_SHADER_GEOMETRY: return 3;
305bf215546Sopenharmony_ci   case PIPE_SHADER_FRAGMENT: return 4;
306bf215546Sopenharmony_ci   case PIPE_SHADER_COMPUTE: return 5;
307bf215546Sopenharmony_ci   default:
308bf215546Sopenharmony_ci      assert(!"invalid PIPE_SHADER type");
309bf215546Sopenharmony_ci      return 0;
310bf215546Sopenharmony_ci   }
311bf215546Sopenharmony_ci}
312bf215546Sopenharmony_ci
313bf215546Sopenharmony_ci
314bf215546Sopenharmony_ci/* nvc0_context.c */
315bf215546Sopenharmony_cistruct pipe_context *nvc0_create(struct pipe_screen *, void *, unsigned flags);
316bf215546Sopenharmony_civoid nvc0_bufctx_fence(struct nvc0_context *, struct nouveau_bufctx *,
317bf215546Sopenharmony_ci                       bool on_flush);
318bf215546Sopenharmony_civoid nvc0_default_kick_notify(struct nouveau_pushbuf *);
319bf215546Sopenharmony_ciconst void *nvc0_get_sample_locations(unsigned);
320bf215546Sopenharmony_ci
321bf215546Sopenharmony_ci/* nvc0_draw.c */
322bf215546Sopenharmony_ciextern struct draw_stage *nvc0_draw_render_stage(struct nvc0_context *);
323bf215546Sopenharmony_ci
324bf215546Sopenharmony_ci/* nvc0_program.c */
325bf215546Sopenharmony_cibool nvc0_program_translate(struct nvc0_program *, uint16_t chipset,
326bf215546Sopenharmony_ci                            struct disk_cache *,
327bf215546Sopenharmony_ci                            struct util_debug_callback *);
328bf215546Sopenharmony_cibool nvc0_program_upload(struct nvc0_context *, struct nvc0_program *);
329bf215546Sopenharmony_civoid nvc0_program_destroy(struct nvc0_context *, struct nvc0_program *);
330bf215546Sopenharmony_civoid nvc0_program_library_upload(struct nvc0_context *);
331bf215546Sopenharmony_civoid nvc0_program_init_tcp_empty(struct nvc0_context *);
332bf215546Sopenharmony_ci
333bf215546Sopenharmony_ci/* nvc0_shader_state.c */
334bf215546Sopenharmony_civoid nvc0_vertprog_validate(struct nvc0_context *);
335bf215546Sopenharmony_civoid nvc0_tctlprog_validate(struct nvc0_context *);
336bf215546Sopenharmony_civoid nvc0_tevlprog_validate(struct nvc0_context *);
337bf215546Sopenharmony_civoid nvc0_gmtyprog_validate(struct nvc0_context *);
338bf215546Sopenharmony_civoid nvc0_fragprog_validate(struct nvc0_context *);
339bf215546Sopenharmony_civoid nvc0_compprog_validate(struct nvc0_context *);
340bf215546Sopenharmony_ci
341bf215546Sopenharmony_civoid nvc0_tfb_validate(struct nvc0_context *);
342bf215546Sopenharmony_civoid nvc0_layer_validate(struct nvc0_context *);
343bf215546Sopenharmony_ci
344bf215546Sopenharmony_ci/* nvc0_state.c */
345bf215546Sopenharmony_ciextern void nvc0_init_state_functions(struct nvc0_context *);
346bf215546Sopenharmony_ci
347bf215546Sopenharmony_ci/* nvc0_state_validate.c */
348bf215546Sopenharmony_cistruct nvc0_state_validate {
349bf215546Sopenharmony_ci   void (*func)(struct nvc0_context *);
350bf215546Sopenharmony_ci   uint32_t states;
351bf215546Sopenharmony_ci};
352bf215546Sopenharmony_ci
353bf215546Sopenharmony_cibool nvc0_state_validate(struct nvc0_context *, uint32_t,
354bf215546Sopenharmony_ci                         struct nvc0_state_validate *, int, uint32_t *,
355bf215546Sopenharmony_ci                         struct nouveau_bufctx *);
356bf215546Sopenharmony_cibool nvc0_state_validate_3d(struct nvc0_context *, uint32_t);
357bf215546Sopenharmony_ci
358bf215546Sopenharmony_ci/* nvc0_surface.c */
359bf215546Sopenharmony_ciextern void nvc0_clear(struct pipe_context *, unsigned buffers,
360bf215546Sopenharmony_ci                       const struct pipe_scissor_state *scissor_state,
361bf215546Sopenharmony_ci                       const union pipe_color_union *color,
362bf215546Sopenharmony_ci                       double depth, unsigned stencil);
363bf215546Sopenharmony_ciextern void nvc0_init_surface_functions(struct nvc0_context *);
364bf215546Sopenharmony_ci
365bf215546Sopenharmony_ci/* nvc0_tex.c */
366bf215546Sopenharmony_cibool nvc0_validate_tic(struct nvc0_context *nvc0, int s);
367bf215546Sopenharmony_cibool nvc0_validate_tsc(struct nvc0_context *nvc0, int s);
368bf215546Sopenharmony_cibool nve4_validate_tsc(struct nvc0_context *nvc0, int s);
369bf215546Sopenharmony_civoid nvc0_validate_suf(struct nvc0_context *nvc0, int s);
370bf215546Sopenharmony_civoid nvc0_validate_textures(struct nvc0_context *);
371bf215546Sopenharmony_civoid nvc0_validate_samplers(struct nvc0_context *);
372bf215546Sopenharmony_civoid nvc0_upload_tsc0(struct nvc0_context *);
373bf215546Sopenharmony_civoid nve4_set_tex_handles(struct nvc0_context *);
374bf215546Sopenharmony_civoid nvc0_validate_surfaces(struct nvc0_context *);
375bf215546Sopenharmony_civoid nve4_set_surface_info(struct nouveau_pushbuf *,
376bf215546Sopenharmony_ci                           const struct pipe_image_view *,
377bf215546Sopenharmony_ci                           struct nvc0_context *);
378bf215546Sopenharmony_civoid nvc0_mark_image_range_valid(const struct pipe_image_view *);
379bf215546Sopenharmony_cibool nvc0_update_tic(struct nvc0_context *, struct nv50_tic_entry *,
380bf215546Sopenharmony_ci                     struct nv04_resource *);
381bf215546Sopenharmony_ci
382bf215546Sopenharmony_cistruct pipe_sampler_view *
383bf215546Sopenharmony_cinvc0_create_texture_view(struct pipe_context *,
384bf215546Sopenharmony_ci                         struct pipe_resource *,
385bf215546Sopenharmony_ci                         const struct pipe_sampler_view *,
386bf215546Sopenharmony_ci                         uint32_t flags);
387bf215546Sopenharmony_cistruct pipe_sampler_view *
388bf215546Sopenharmony_cinvc0_create_sampler_view(struct pipe_context *,
389bf215546Sopenharmony_ci                         struct pipe_resource *,
390bf215546Sopenharmony_ci                         const struct pipe_sampler_view *);
391bf215546Sopenharmony_cistruct pipe_sampler_view *
392bf215546Sopenharmony_cigm107_create_texture_view_from_image(struct pipe_context *,
393bf215546Sopenharmony_ci                                     const struct pipe_image_view *);
394bf215546Sopenharmony_ci
395bf215546Sopenharmony_civoid nvc0_init_bindless_functions(struct pipe_context *);
396bf215546Sopenharmony_ci
397bf215546Sopenharmony_ci/* nvc0_transfer.c */
398bf215546Sopenharmony_civoid
399bf215546Sopenharmony_cinvc0_init_transfer_functions(struct nvc0_context *);
400bf215546Sopenharmony_ci
401bf215546Sopenharmony_civoid
402bf215546Sopenharmony_cinvc0_m2mf_push_linear(struct nouveau_context *nv,
403bf215546Sopenharmony_ci                      struct nouveau_bo *dst, unsigned offset, unsigned domain,
404bf215546Sopenharmony_ci                      unsigned size, const void *data);
405bf215546Sopenharmony_civoid
406bf215546Sopenharmony_cinve4_p2mf_push_linear(struct nouveau_context *nv,
407bf215546Sopenharmony_ci                      struct nouveau_bo *dst, unsigned offset, unsigned domain,
408bf215546Sopenharmony_ci                      unsigned size, const void *data);
409bf215546Sopenharmony_civoid
410bf215546Sopenharmony_cinvc0_cb_bo_push(struct nouveau_context *,
411bf215546Sopenharmony_ci                struct nouveau_bo *bo, unsigned domain,
412bf215546Sopenharmony_ci                unsigned base, unsigned size,
413bf215546Sopenharmony_ci                unsigned offset, unsigned words, const uint32_t *data);
414bf215546Sopenharmony_ci
415bf215546Sopenharmony_ci/* nvc0_vbo.c */
416bf215546Sopenharmony_civoid nvc0_draw_vbo(struct pipe_context *, const struct pipe_draw_info *, unsigned,
417bf215546Sopenharmony_ci                   const struct pipe_draw_indirect_info *indirect,
418bf215546Sopenharmony_ci                   const struct pipe_draw_start_count_bias *draws,
419bf215546Sopenharmony_ci                   unsigned num_draws);
420bf215546Sopenharmony_ci
421bf215546Sopenharmony_civoid *
422bf215546Sopenharmony_cinvc0_vertex_state_create(struct pipe_context *pipe,
423bf215546Sopenharmony_ci                         unsigned num_elements,
424bf215546Sopenharmony_ci                         const struct pipe_vertex_element *elements);
425bf215546Sopenharmony_civoid
426bf215546Sopenharmony_cinvc0_vertex_state_delete(struct pipe_context *pipe, void *hwcso);
427bf215546Sopenharmony_ci
428bf215546Sopenharmony_civoid nvc0_vertex_arrays_validate(struct nvc0_context *);
429bf215546Sopenharmony_ci
430bf215546Sopenharmony_civoid nvc0_idxbuf_validate(struct nvc0_context *);
431bf215546Sopenharmony_ci
432bf215546Sopenharmony_ci/* nvc0_video.c */
433bf215546Sopenharmony_cistruct pipe_video_codec *
434bf215546Sopenharmony_cinvc0_create_decoder(struct pipe_context *context,
435bf215546Sopenharmony_ci                    const struct pipe_video_codec *templ);
436bf215546Sopenharmony_ci
437bf215546Sopenharmony_cistruct pipe_video_buffer *
438bf215546Sopenharmony_cinvc0_video_buffer_create(struct pipe_context *pipe,
439bf215546Sopenharmony_ci                         const struct pipe_video_buffer *templat);
440bf215546Sopenharmony_ci
441bf215546Sopenharmony_ci/* nvc0_push.c */
442bf215546Sopenharmony_civoid nvc0_push_vbo(struct nvc0_context *, const struct pipe_draw_info *,
443bf215546Sopenharmony_ci                   const struct pipe_draw_indirect_info *indirect,
444bf215546Sopenharmony_ci                   const struct pipe_draw_start_count_bias *draw);
445bf215546Sopenharmony_civoid nvc0_push_vbo_indirect(struct nvc0_context *, const struct pipe_draw_info *,
446bf215546Sopenharmony_ci                            unsigned drawid_offset,
447bf215546Sopenharmony_ci                            const struct pipe_draw_indirect_info *indirect,
448bf215546Sopenharmony_ci                            const struct pipe_draw_start_count_bias *draw);
449bf215546Sopenharmony_ci
450bf215546Sopenharmony_ci/* nve4_compute.c */
451bf215546Sopenharmony_civoid nve4_launch_grid(struct pipe_context *, const struct pipe_grid_info *);
452bf215546Sopenharmony_ci
453bf215546Sopenharmony_ci/* nvc0_compute.c */
454bf215546Sopenharmony_civoid nvc0_launch_grid(struct pipe_context *, const struct pipe_grid_info *);
455bf215546Sopenharmony_civoid nvc0_compute_validate_globals(struct nvc0_context *);
456bf215546Sopenharmony_civoid nvc0_update_compute_invocations_counter(struct nvc0_context *nvc0,
457bf215546Sopenharmony_ci                                             const struct pipe_grid_info *info);
458bf215546Sopenharmony_ci
459bf215546Sopenharmony_ci#endif
460