Merge branch 'register-negate'
[mesa.git] / src / gallium / drivers / nv30 / nv30_context.c
1 #include "draw/draw_context.h"
2 #include "pipe/p_defines.h"
3 #include "pipe/internal/p_winsys_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
14 if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
15 BEGIN_RING(rankine, 0x1fd8, 1);
16 OUT_RING (2);
17 BEGIN_RING(rankine, 0x1fd8, 1);
18 OUT_RING (1);
19 }
20
21 FIRE_RING(fence);
22 }
23
24 static void
25 nv30_destroy(struct pipe_context *pipe)
26 {
27 struct nv30_context *nv30 = nv30_context(pipe);
28
29 if (nv30->draw)
30 draw_destroy(nv30->draw);
31 FREE(nv30);
32 }
33
34 static unsigned int
35 nv30_is_texture_referenced( struct pipe_context *pipe,
36 struct pipe_texture *texture,
37 unsigned face, unsigned level)
38 {
39 /**
40 * FIXME: Optimize.
41 */
42
43 return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
44 }
45
46 static unsigned int
47 nv30_is_buffer_referenced( struct pipe_context *pipe,
48 struct pipe_buffer *buf)
49 {
50 /**
51 * FIXME: Optimize.
52 */
53
54 return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
55 }
56
57 struct pipe_context *
58 nv30_create(struct pipe_screen *pscreen, unsigned pctx_id)
59 {
60 struct nv30_screen *screen = nv30_screen(pscreen);
61 struct pipe_winsys *ws = pscreen->winsys;
62 struct nv30_context *nv30;
63 struct nouveau_winsys *nvws = screen->nvws;
64
65 nv30 = CALLOC(1, sizeof(struct nv30_context));
66 if (!nv30)
67 return NULL;
68 nv30->screen = screen;
69 nv30->pctx_id = pctx_id;
70
71 nv30->nvws = nvws;
72
73 nv30->pipe.winsys = ws;
74 nv30->pipe.screen = pscreen;
75 nv30->pipe.destroy = nv30_destroy;
76 nv30->pipe.draw_arrays = nv30_draw_arrays;
77 nv30->pipe.draw_elements = nv30_draw_elements;
78 nv30->pipe.clear = nv30_clear;
79 nv30->pipe.flush = nv30_flush;
80
81 nv30->pipe.is_texture_referenced = nv30_is_texture_referenced;
82 nv30->pipe.is_buffer_referenced = nv30_is_buffer_referenced;
83
84 nv30_init_query_functions(nv30);
85 nv30_init_surface_functions(nv30);
86 nv30_init_state_functions(nv30);
87
88 /* Create, configure, and install fallback swtnl path */
89 nv30->draw = draw_create();
90 draw_wide_point_threshold(nv30->draw, 9999999.0);
91 draw_wide_line_threshold(nv30->draw, 9999999.0);
92 draw_enable_line_stipple(nv30->draw, FALSE);
93 draw_enable_point_sprites(nv30->draw, FALSE);
94 draw_set_rasterize_stage(nv30->draw, nv30_draw_render_stage(nv30));
95
96 return &nv30->pipe;
97 }
98