nv50: convert to hwctx-in-screen as nv40 is
[mesa.git] / src / gallium / drivers / nv50 / nv50_context.c
1 #include "draw/draw_context.h"
2 #include "pipe/p_defines.h"
3 #include "pipe/p_winsys.h"
4 #include "pipe/p_util.h"
5
6 #include "nv50_context.h"
7 #include "nv50_screen.h"
8
9 static void
10 nv50_flush(struct pipe_context *pipe, unsigned flags)
11 {
12 struct nv50_context *nv50 = (struct nv50_context *)pipe;
13 struct nv50_screen *screen = nv50->screen;
14 struct nouveau_winsys *nvws = screen->nvws;
15
16 if (flags & PIPE_FLUSH_WAIT) {
17 nvws->notifier_reset(screen->sync, 0);
18 BEGIN_RING(tesla, 0x104, 1);
19 OUT_RING (0);
20 BEGIN_RING(tesla, 0x100, 1);
21 OUT_RING (0);
22 }
23
24 FIRE_RING();
25
26 if (flags & PIPE_FLUSH_WAIT)
27 nvws->notifier_wait(screen->sync, 0, 0, 2000);
28 }
29
30 static void
31 nv50_destroy(struct pipe_context *pipe)
32 {
33 struct nv50_context *nv50 = (struct nv50_context *)pipe;
34
35 draw_destroy(nv50->draw);
36 free(nv50);
37 }
38
39 struct pipe_context *
40 nv50_create(struct pipe_screen *pscreen, unsigned pctx_id)
41 {
42 struct pipe_winsys *pipe_winsys = pscreen->winsys;
43 struct nv50_screen *screen = nv50_screen(pscreen);
44 struct nv50_context *nv50;
45
46 nv50 = CALLOC_STRUCT(nv50_context);
47 if (!nv50)
48 return NULL;
49 nv50->screen = screen;
50 nv50->pctx_id = pctx_id;
51
52 nv50->pipe.winsys = pipe_winsys;
53 nv50->pipe.screen = pscreen;
54
55 nv50->pipe.destroy = nv50_destroy;
56
57 nv50->pipe.draw_arrays = nv50_draw_arrays;
58 nv50->pipe.draw_elements = nv50_draw_elements;
59 nv50->pipe.clear = nv50_clear;
60
61 nv50->pipe.flush = nv50_flush;
62
63 nv50_init_miptree_functions(nv50);
64 nv50_init_surface_functions(nv50);
65 nv50_init_state_functions(nv50);
66 nv50_init_query_functions(nv50);
67
68 nv50->draw = draw_create();
69 assert(nv50->draw);
70 draw_set_rasterize_stage(nv50->draw, nv50_draw_render_stage(nv50));
71
72 return &nv50->pipe;
73 }
74
75