Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / mesa / src / gallium / drivers / nvfx / nvfx_context.c
blob98603bedde1d85f639c5e33819b2c50ec2e6d39d
1 #include "draw/draw_context.h"
2 #include "pipe/p_defines.h"
3 #include "util/u_framebuffer.h"
5 #include "nvfx_context.h"
6 #include "nvfx_screen.h"
7 #include "nvfx_resource.h"
9 static void
10 nvfx_flush(struct pipe_context *pipe,
11 struct pipe_fence_handle **fence)
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;*/
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 }*/
27 if (fence) {
28 /* horrific hack to make glFinish() work in the absence of
29 * having proper fences in nvfx. a pending rewrite will
30 * fix this properly, but may be a while off.
32 MARK_RING(chan, 1, 1);
33 OUT_RELOC(chan, screen->fence, 0, NOUVEAU_BO_WR |
34 NOUVEAU_BO_DUMMY, 0, 0);
35 FIRE_RING(chan);
36 nouveau_bo_map(screen->fence, NOUVEAU_BO_RDWR);
37 nouveau_bo_unmap(screen->fence);
38 *fence = NULL;
39 } else {
40 FIRE_RING(chan);
44 static void
45 nvfx_destroy(struct pipe_context *pipe)
47 struct nvfx_context *nvfx = nvfx_context(pipe);
49 if(nvfx->dummy_fs)
50 pipe->delete_fs_state(pipe, nvfx->dummy_fs);
52 for(unsigned i = 0; i < nvfx->vtxbuf_nr; ++i)
53 pipe_resource_reference(&nvfx->vtxbuf[i].buffer, 0);
54 pipe_resource_reference(&nvfx->idxbuf.buffer, 0);
55 util_unreference_framebuffer_state(&nvfx->framebuffer);
56 for(unsigned i = 0; i < PIPE_MAX_SAMPLERS; ++i)
57 pipe_sampler_view_reference(&nvfx->fragment_sampler_views[i], 0);
59 if (nvfx->draw)
60 draw_destroy(nvfx->draw);
62 if(nvfx->screen->cur_ctx == nvfx)
63 nvfx->screen->cur_ctx = NULL;
65 FREE(nvfx);
68 struct pipe_context *
69 nvfx_create(struct pipe_screen *pscreen, void *priv)
71 struct nvfx_screen *screen = nvfx_screen(pscreen);
72 struct pipe_winsys *ws = pscreen->winsys;
73 struct nvfx_context *nvfx;
74 struct nouveau_winsys *nvws = screen->nvws;
76 nvfx = CALLOC(1, sizeof(struct nvfx_context));
77 if (!nvfx)
78 return NULL;
79 nvfx->screen = screen;
81 nvfx->nvws = nvws;
83 nvfx->pipe.winsys = ws;
84 nvfx->pipe.screen = pscreen;
85 nvfx->pipe.priv = priv;
86 nvfx->pipe.destroy = nvfx_destroy;
87 nvfx->pipe.draw_vbo = nvfx_draw_vbo;
88 nvfx->pipe.clear = nvfx_clear;
89 nvfx->pipe.flush = nvfx_flush;
91 nvfx->is_nv4x = screen->is_nv4x;
92 nvfx->use_nv4x = screen->use_nv4x;
93 /* TODO: it seems that nv30 might have fixed function clipping usable with vertex programs
94 * However, my code for that doesn't work, so use vp clipping for all cards, which works.
96 nvfx->use_vp_clipping = TRUE;
98 nvfx_init_query_functions(nvfx);
99 nvfx_init_surface_functions(nvfx);
100 nvfx_init_state_functions(nvfx);
101 nvfx_init_sampling_functions(nvfx);
102 nvfx_init_vbo_functions(nvfx);
103 nvfx_init_fragprog_functions(nvfx);
104 nvfx_init_vertprog_functions(nvfx);
105 nvfx_init_resource_functions(&nvfx->pipe);
106 nvfx_init_transfer_functions(&nvfx->pipe);
108 /* Create, configure, and install fallback swtnl path */
109 nvfx->draw = draw_create(&nvfx->pipe);
110 draw_wide_point_threshold(nvfx->draw, 9999999.0);
111 draw_wide_line_threshold(nvfx->draw, 9999999.0);
112 draw_enable_line_stipple(nvfx->draw, FALSE);
113 draw_enable_point_sprites(nvfx->draw, FALSE);
114 draw_set_rasterize_stage(nvfx->draw, nvfx_draw_render_stage(nvfx));
116 /* set these to that we init them on first validation */
117 nvfx->state.scissor_enabled = ~0;
118 nvfx->hw_pointsprite_control = -1;
119 nvfx->hw_vp_output = -1;
120 nvfx->use_vertex_buffers = -1;
121 nvfx->relocs_needed = NVFX_RELOCATE_ALL;
123 LIST_INITHEAD(&nvfx->render_cache);
125 return &nvfx->pipe;