nvfx: comment-out unused var
[mesa.git] / src / gallium / drivers / nvfx / nvfx_context.c
1 #include "draw/draw_context.h"
2 #include "pipe/p_defines.h"
3 #include "util/u_framebuffer.h"
4
5 #include "nvfx_context.h"
6 #include "nvfx_screen.h"
7 #include "nvfx_resource.h"
8
9 static void
10 nvfx_flush(struct pipe_context *pipe,
11 struct pipe_fence_handle **fence)
12 {
13 struct nvfx_context *nvfx = nvfx_context(pipe);
14 struct nvfx_screen *screen = nvfx->screen;
15 struct nouveau_channel *chan = screen->base.channel;
16 /*struct nouveau_grobj *eng3d = screen->eng3d;*/
17
18 /* XXX: we need to actually be intelligent here */
19 /* XXX This flag wasn't set by the state tracker anyway. */
20 /*if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
21 BEGIN_RING(chan, eng3d, 0x1fd8, 1);
22 OUT_RING(chan, 2);
23 BEGIN_RING(chan, eng3d, 0x1fd8, 1);
24 OUT_RING(chan, 1);
25 }*/
26
27 FIRE_RING(chan);
28 if (fence)
29 *fence = NULL;
30 }
31
32 static void
33 nvfx_destroy(struct pipe_context *pipe)
34 {
35 struct nvfx_context *nvfx = nvfx_context(pipe);
36
37 if(nvfx->dummy_fs)
38 pipe->delete_fs_state(pipe, nvfx->dummy_fs);
39
40 for(unsigned i = 0; i < nvfx->vtxbuf_nr; ++i)
41 pipe_resource_reference(&nvfx->vtxbuf[i].buffer, 0);
42 pipe_resource_reference(&nvfx->idxbuf.buffer, 0);
43 util_unreference_framebuffer_state(&nvfx->framebuffer);
44 for(unsigned i = 0; i < PIPE_MAX_SAMPLERS; ++i)
45 pipe_sampler_view_reference(&nvfx->fragment_sampler_views[i], 0);
46
47 if (nvfx->draw)
48 draw_destroy(nvfx->draw);
49
50 if(nvfx->screen->cur_ctx == nvfx)
51 nvfx->screen->cur_ctx = NULL;
52
53 FREE(nvfx);
54 }
55
56 struct pipe_context *
57 nvfx_create(struct pipe_screen *pscreen, void *priv)
58 {
59 struct nvfx_screen *screen = nvfx_screen(pscreen);
60 struct pipe_winsys *ws = pscreen->winsys;
61 struct nvfx_context *nvfx;
62 struct nouveau_winsys *nvws = screen->nvws;
63
64 nvfx = CALLOC(1, sizeof(struct nvfx_context));
65 if (!nvfx)
66 return NULL;
67 nvfx->screen = screen;
68
69 nvfx->nvws = nvws;
70
71 nvfx->pipe.winsys = ws;
72 nvfx->pipe.screen = pscreen;
73 nvfx->pipe.priv = priv;
74 nvfx->pipe.destroy = nvfx_destroy;
75 nvfx->pipe.draw_vbo = nvfx_draw_vbo;
76 nvfx->pipe.clear = nvfx_clear;
77 nvfx->pipe.flush = nvfx_flush;
78
79 nvfx->is_nv4x = screen->is_nv4x;
80 nvfx->use_nv4x = screen->use_nv4x;
81 /* TODO: it seems that nv30 might have fixed function clipping usable with vertex programs
82 * However, my code for that doesn't work, so use vp clipping for all cards, which works.
83 */
84 nvfx->use_vp_clipping = TRUE;
85
86 nvfx_init_query_functions(nvfx);
87 nvfx_init_surface_functions(nvfx);
88 nvfx_init_state_functions(nvfx);
89 nvfx_init_sampling_functions(nvfx);
90 nvfx_init_vbo_functions(nvfx);
91 nvfx_init_fragprog_functions(nvfx);
92 nvfx_init_vertprog_functions(nvfx);
93 nvfx_init_resource_functions(&nvfx->pipe);
94 nvfx_init_transfer_functions(&nvfx->pipe);
95
96 /* Create, configure, and install fallback swtnl path */
97 nvfx->draw = draw_create(&nvfx->pipe);
98 draw_wide_point_threshold(nvfx->draw, 9999999.0);
99 draw_wide_line_threshold(nvfx->draw, 9999999.0);
100 draw_enable_line_stipple(nvfx->draw, FALSE);
101 draw_enable_point_sprites(nvfx->draw, FALSE);
102 draw_set_rasterize_stage(nvfx->draw, nvfx_draw_render_stage(nvfx));
103
104 /* set these to that we init them on first validation */
105 nvfx->state.scissor_enabled = ~0;
106 nvfx->hw_pointsprite_control = -1;
107 nvfx->hw_vp_output = -1;
108 nvfx->use_vertex_buffers = -1;
109 nvfx->relocs_needed = NVFX_RELOCATE_ALL;
110
111 LIST_INITHEAD(&nvfx->render_cache);
112
113 return &nvfx->pipe;
114 }