Merge remote branch 'upstream/gallium-0.1' into nouveau-gallium-0.1
[mesa.git] / src / gallium / drivers / nv50 / nv50_context.c
1 /*
2 * Copyright 2008 Ben Skeggs
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 #include "draw/draw_context.h"
24 #include "pipe/p_defines.h"
25 #include "pipe/p_winsys.h"
26 #include "pipe/p_util.h"
27
28 #include "nv50_context.h"
29 #include "nv50_screen.h"
30
31 static void
32 nv50_flush(struct pipe_context *pipe, unsigned flags,
33 struct pipe_fence_handle **fence)
34 {
35 struct nv50_context *nv50 = (struct nv50_context *)pipe;
36
37 FIRE_RING(fence);
38 }
39
40 static void
41 nv50_destroy(struct pipe_context *pipe)
42 {
43 struct nv50_context *nv50 = (struct nv50_context *)pipe;
44
45 draw_destroy(nv50->draw);
46 FREE(nv50);
47 }
48
49
50 static void
51 nv50_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
52 {
53 }
54
55 struct pipe_context *
56 nv50_create(struct pipe_screen *pscreen, unsigned pctx_id)
57 {
58 struct pipe_winsys *pipe_winsys = pscreen->winsys;
59 struct nv50_screen *screen = nv50_screen(pscreen);
60 struct nv50_context *nv50;
61
62 nv50 = CALLOC_STRUCT(nv50_context);
63 if (!nv50)
64 return NULL;
65 nv50->screen = screen;
66 nv50->pctx_id = pctx_id;
67
68 nv50->pipe.winsys = pipe_winsys;
69 nv50->pipe.screen = pscreen;
70
71 nv50->pipe.destroy = nv50_destroy;
72
73 nv50->pipe.set_edgeflags = nv50_set_edgeflags;
74 nv50->pipe.draw_arrays = nv50_draw_arrays;
75 nv50->pipe.draw_elements = nv50_draw_elements;
76 nv50->pipe.clear = nv50_clear;
77
78 nv50->pipe.flush = nv50_flush;
79
80 nv50_init_surface_functions(nv50);
81 nv50_init_state_functions(nv50);
82 nv50_init_query_functions(nv50);
83
84 nv50->draw = draw_create();
85 assert(nv50->draw);
86 draw_set_rasterize_stage(nv50->draw, nv50_draw_render_stage(nv50));
87
88 return &nv50->pipe;
89 }
90
91