eefc614e5b5b39b0df5a6848131195efd00056af
[mesa.git] / src / gallium / drivers / nv30 / nv30_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 "nv30_context.h"
7 #include "nv30_screen.h"
8
9 static void
10 nv30_flush(struct pipe_context *pipe, unsigned flags,
11 struct pipe_fence_handle **fence)
12 {
13 struct nv30_context *nv30 = nv30_context(pipe);
14
15 if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
16 BEGIN_RING(rankine, 0x1fd8, 1);
17 OUT_RING (2);
18 BEGIN_RING(rankine, 0x1fd8, 1);
19 OUT_RING (1);
20 }
21
22 FIRE_RING(fence);
23 }
24
25 static void
26 nv30_destroy(struct pipe_context *pipe)
27 {
28 struct nv30_context *nv30 = nv30_context(pipe);
29
30 if (nv30->draw)
31 draw_destroy(nv30->draw);
32 FREE(nv30);
33 }
34
35 struct pipe_context *
36 nv30_create(struct pipe_screen *pscreen, unsigned pctx_id)
37 {
38 struct nv30_screen *screen = nv30_screen(pscreen);
39 struct pipe_winsys *ws = pscreen->winsys;
40 struct nv30_context *nv30;
41 struct nouveau_winsys *nvws = screen->nvws;
42
43 nv30 = CALLOC(1, sizeof(struct nv30_context));
44 if (!nv30)
45 return NULL;
46 nv30->screen = screen;
47 nv30->pctx_id = pctx_id;
48
49 nv30->nvws = nvws;
50
51 nv30->pipe.winsys = ws;
52 nv30->pipe.screen = pscreen;
53 nv30->pipe.destroy = nv30_destroy;
54 nv30->pipe.draw_arrays = nv30_draw_arrays;
55 nv30->pipe.draw_elements = nv30_draw_elements;
56 nv30->pipe.clear = nv30_clear;
57 nv30->pipe.flush = nv30_flush;
58
59 nv30_init_query_functions(nv30);
60 nv30_init_surface_functions(nv30);
61 nv30_init_state_functions(nv30);
62
63 /* Create, configure, and install fallback swtnl path */
64 nv30->draw = draw_create();
65 draw_wide_point_threshold(nv30->draw, 9999999.0);
66 draw_wide_line_threshold(nv30->draw, 9999999.0);
67 draw_enable_line_stipple(nv30->draw, FALSE);
68 draw_enable_point_sprites(nv30->draw, FALSE);
69 draw_set_rasterize_stage(nv30->draw, nv30_draw_render_stage(nv30));
70
71 return &nv30->pipe;
72 }
73