Merge remote branch 'origin/lp-binning'
[mesa.git] / src / gallium / drivers / nv30 / nv30_context.c
1 #include "draw/draw_context.h"
2 #include "pipe/p_defines.h"
3 #include "util/u_simple_screen.h"
4
5 #include "nv30_context.h"
6 #include "nv30_screen.h"
7
8 static void
9 nv30_flush(struct pipe_context *pipe, unsigned flags,
10 struct pipe_fence_handle **fence)
11 {
12 struct nv30_context *nv30 = nv30_context(pipe);
13 struct nv30_screen *screen = nv30->screen;
14 struct nouveau_channel *chan = screen->base.channel;
15 struct nouveau_grobj *rankine = screen->rankine;
16
17 if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
18 BEGIN_RING(chan, rankine, 0x1fd8, 1);
19 OUT_RING (chan, 2);
20 BEGIN_RING(chan, rankine, 0x1fd8, 1);
21 OUT_RING (chan, 1);
22 }
23
24 FIRE_RING(chan);
25 if (fence)
26 *fence = NULL;
27 }
28
29 static void
30 nv30_destroy(struct pipe_context *pipe)
31 {
32 struct nv30_context *nv30 = nv30_context(pipe);
33 unsigned i;
34
35 for (i = 0; i < NV30_STATE_MAX; i++) {
36 if (nv30->state.hw[i])
37 so_ref(NULL, &nv30->state.hw[i]);
38 }
39
40 if (nv30->draw)
41 draw_destroy(nv30->draw);
42 FREE(nv30);
43 }
44
45 struct pipe_context *
46 nv30_create(struct pipe_screen *pscreen, unsigned pctx_id)
47 {
48 struct nv30_screen *screen = nv30_screen(pscreen);
49 struct pipe_winsys *ws = pscreen->winsys;
50 struct nv30_context *nv30;
51 struct nouveau_winsys *nvws = screen->nvws;
52
53 nv30 = CALLOC(1, sizeof(struct nv30_context));
54 if (!nv30)
55 return NULL;
56 nv30->screen = screen;
57 nv30->pctx_id = pctx_id;
58
59 nv30->nvws = nvws;
60
61 nv30->pipe.winsys = ws;
62 nv30->pipe.screen = pscreen;
63 nv30->pipe.destroy = nv30_destroy;
64 nv30->pipe.draw_arrays = nv30_draw_arrays;
65 nv30->pipe.draw_elements = nv30_draw_elements;
66 nv30->pipe.clear = nv30_clear;
67 nv30->pipe.flush = nv30_flush;
68
69 nv30->pipe.is_texture_referenced = nouveau_is_texture_referenced;
70 nv30->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
71
72 screen->base.channel->user_private = nv30;
73 screen->base.channel->flush_notify = nv30_state_flush_notify;
74
75 nv30_init_query_functions(nv30);
76 nv30_init_surface_functions(nv30);
77 nv30_init_state_functions(nv30);
78
79 /* Create, configure, and install fallback swtnl path */
80 nv30->draw = draw_create();
81 draw_wide_point_threshold(nv30->draw, 9999999.0);
82 draw_wide_line_threshold(nv30->draw, 9999999.0);
83 draw_enable_line_stipple(nv30->draw, FALSE);
84 draw_enable_point_sprites(nv30->draw, FALSE);
85 draw_set_rasterize_stage(nv30->draw, nv30_draw_render_stage(nv30));
86
87 return &nv30->pipe;
88 }