nvfx: so->RING_3D: scissor
[mesa.git] / src / gallium / drivers / nvfx / nvfx_context.c
1 #include "draw/draw_context.h"
2 #include "pipe/p_defines.h"
3
4 #include "nvfx_context.h"
5 #include "nvfx_screen.h"
6 #include "nvfx_resource.h"
7
8 static void
9 nvfx_flush(struct pipe_context *pipe, unsigned flags,
10 struct pipe_fence_handle **fence)
11 {
12 struct nvfx_context *nvfx = nvfx_context(pipe);
13 struct nvfx_screen *screen = nvfx->screen;
14 struct nouveau_channel *chan = screen->base.channel;
15 struct nouveau_grobj *eng3d = screen->eng3d;
16
17 if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
18 BEGIN_RING(chan, eng3d, 0x1fd8, 1);
19 OUT_RING (chan, 2);
20 BEGIN_RING(chan, eng3d, 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 nvfx_destroy(struct pipe_context *pipe)
31 {
32 struct nvfx_context *nvfx = nvfx_context(pipe);
33 unsigned i;
34
35 for (i = 0; i < NVFX_STATE_MAX; i++) {
36 if (nvfx->state.hw[i])
37 so_ref(NULL, &nvfx->state.hw[i]);
38 }
39
40 if (nvfx->draw)
41 draw_destroy(nvfx->draw);
42 FREE(nvfx);
43 }
44
45 struct pipe_context *
46 nvfx_create(struct pipe_screen *pscreen, void *priv)
47 {
48 struct nvfx_screen *screen = nvfx_screen(pscreen);
49 struct pipe_winsys *ws = pscreen->winsys;
50 struct nvfx_context *nvfx;
51 struct nouveau_winsys *nvws = screen->nvws;
52
53 nvfx = CALLOC(1, sizeof(struct nvfx_context));
54 if (!nvfx)
55 return NULL;
56 nvfx->screen = screen;
57
58 nvfx->nvws = nvws;
59
60 nvfx->pipe.winsys = ws;
61 nvfx->pipe.screen = pscreen;
62 nvfx->pipe.priv = priv;
63 nvfx->pipe.destroy = nvfx_destroy;
64 nvfx->pipe.draw_arrays = nvfx_draw_arrays;
65 nvfx->pipe.draw_elements = nvfx_draw_elements;
66 nvfx->pipe.clear = nvfx_clear;
67 nvfx->pipe.flush = nvfx_flush;
68
69 screen->base.channel->user_private = nvfx;
70
71 nvfx->is_nv4x = screen->is_nv4x;
72
73 nvfx_init_query_functions(nvfx);
74 nvfx_init_surface_functions(nvfx);
75 nvfx_init_state_functions(nvfx);
76 nvfx_init_resource_functions(&nvfx->pipe);
77
78 /* Create, configure, and install fallback swtnl path */
79 nvfx->draw = draw_create();
80 draw_wide_point_threshold(nvfx->draw, 9999999.0);
81 draw_wide_line_threshold(nvfx->draw, 9999999.0);
82 draw_enable_line_stipple(nvfx->draw, FALSE);
83 draw_enable_point_sprites(nvfx->draw, FALSE);
84 draw_set_rasterize_stage(nvfx->draw, nvfx_draw_render_stage(nvfx));
85
86 /* set these to that we init them on first validation */
87 nvfx->state.scissor_enabled = ~0;
88 return &nvfx->pipe;
89 }