Merge commit 'origin/master' into gallium-0.2
[mesa.git] / src / gallium / drivers / nv04 / nv04_context.c
1 #include "draw/draw_context.h"
2 #include "pipe/p_defines.h"
3 #include "pipe/p_winsys.h"
4
5 #include "nv04_context.h"
6 #include "nv04_screen.h"
7
8 static void
9 nv04_flush(struct pipe_context *pipe, unsigned flags,
10 struct pipe_fence_handle **fence)
11 {
12 struct nv04_context *nv04 = nv04_context(pipe);
13
14 draw_flush(nv04->draw);
15
16 FIRE_RING(fence);
17 }
18
19 static void
20 nv04_destroy(struct pipe_context *pipe)
21 {
22 struct nv04_context *nv04 = nv04_context(pipe);
23
24 if (nv04->draw)
25 draw_destroy(nv04->draw);
26
27 FREE(nv04);
28 }
29
30 static void
31 nv04_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
32 {
33 }
34
35 static boolean
36 nv04_init_hwctx(struct nv04_context *nv04)
37 {
38 BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_NOTIFY, 1);
39 OUT_RING(0);
40 BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_NOP, 1);
41 OUT_RING(0);
42
43 BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_CONTROL, 1);
44 OUT_RING(0x40182800);
45 // OUT_RING(1<<20/*no cull*/);
46 BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_BLEND, 1);
47 // OUT_RING(0x24|(1<<6)|(1<<8));
48 OUT_RING(0x120001a4);
49 BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_FORMAT, 1);
50 OUT_RING(0x332213a1);
51 BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_FILTER, 1);
52 OUT_RING(0x11001010);
53 BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_COLORKEY, 1);
54 OUT_RING(0x0);
55 // BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_OFFSET, 1);
56 // OUT_RING(SCREEN_OFFSET);
57 BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_FOGCOLOR, 1);
58 OUT_RING(0xff000000);
59
60
61
62 FIRE_RING (NULL);
63 return TRUE;
64 }
65
66 struct pipe_context *
67 nv04_create(struct pipe_screen *pscreen, unsigned pctx_id)
68 {
69 struct nv04_screen *screen = nv04_screen(pscreen);
70 struct pipe_winsys *ws = pscreen->winsys;
71 struct nv04_context *nv04;
72 struct nouveau_winsys *nvws = screen->nvws;
73
74 nv04 = CALLOC(1, sizeof(struct nv04_context));
75 if (!nv04)
76 return NULL;
77 nv04->screen = screen;
78 nv04->pctx_id = pctx_id;
79
80 nv04->nvws = nvws;
81
82 nv04->pipe.winsys = ws;
83 nv04->pipe.screen = pscreen;
84 nv04->pipe.destroy = nv04_destroy;
85 nv04->pipe.set_edgeflags = nv04_set_edgeflags;
86 nv04->pipe.draw_arrays = nv04_draw_arrays;
87 nv04->pipe.draw_elements = nv04_draw_elements;
88 nv04->pipe.clear = nv04_clear;
89 nv04->pipe.flush = nv04_flush;
90
91 nv04_init_surface_functions(nv04);
92 nv04_init_state_functions(nv04);
93
94 nv04->draw = draw_create();
95 assert(nv04->draw);
96 draw_wide_point_threshold(nv04->draw, 0.0);
97 draw_wide_line_threshold(nv04->draw, 0.0);
98 draw_enable_line_stipple(nv04->draw, FALSE);
99 draw_enable_point_sprites(nv04->draw, FALSE);
100 draw_set_rasterize_stage(nv04->draw, nv04_draw_vbuf_stage(nv04));
101
102 nv04_init_hwctx(nv04);
103
104 return &nv04->pipe;
105 }
106