Merge remote branch 'upstream/gallium-0.1' into nouveau-gallium-0.1
[mesa.git] / src / gallium / drivers / nv40 / nv40_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 "nv40_context.h"
7 #include "nv40_screen.h"
8
9 static void
10 nv40_flush(struct pipe_context *pipe, unsigned flags,
11 struct pipe_fence_handle **fence)
12 {
13 struct nv40_context *nv40 = nv40_context(pipe);
14
15 if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
16 BEGIN_RING(curie, 0x1fd8, 1);
17 OUT_RING (2);
18 BEGIN_RING(curie, 0x1fd8, 1);
19 OUT_RING (1);
20 }
21
22 FIRE_RING(fence);
23 }
24
25 static void
26 nv40_destroy(struct pipe_context *pipe)
27 {
28 struct nv40_context *nv40 = nv40_context(pipe);
29
30 if (nv40->draw)
31 draw_destroy(nv40->draw);
32 FREE(nv40);
33 }
34
35 struct pipe_context *
36 nv40_create(struct pipe_screen *pscreen, unsigned pctx_id)
37 {
38 struct nv40_screen *screen = nv40_screen(pscreen);
39 struct pipe_winsys *ws = pscreen->winsys;
40 struct nv40_context *nv40;
41 struct nouveau_winsys *nvws = screen->nvws;
42
43 nv40 = CALLOC(1, sizeof(struct nv40_context));
44 if (!nv40)
45 return NULL;
46 nv40->screen = screen;
47 nv40->pctx_id = pctx_id;
48
49 nv40->nvws = nvws;
50
51 nv40->pipe.winsys = ws;
52 nv40->pipe.screen = pscreen;
53 nv40->pipe.destroy = nv40_destroy;
54 nv40->pipe.draw_arrays = nv40_draw_arrays;
55 nv40->pipe.draw_elements = nv40_draw_elements;
56 nv40->pipe.clear = nv40_clear;
57 nv40->pipe.flush = nv40_flush;
58
59 nv40_init_query_functions(nv40);
60 nv40_init_surface_functions(nv40);
61 nv40_init_state_functions(nv40);
62
63 /* Create, configure, and install fallback swtnl path */
64 nv40->draw = draw_create();
65 draw_wide_point_threshold(nv40->draw, 9999999.0);
66 draw_wide_line_threshold(nv40->draw, 9999999.0);
67 draw_enable_line_stipple(nv40->draw, FALSE);
68 draw_enable_point_sprites(nv40->draw, FALSE);
69 draw_set_rasterize_stage(nv40->draw, nv40_draw_render_stage(nv40));
70
71 return &nv40->pipe;
72 }
73