Rename GLvisual and __GLcontextModes to struct gl_config
[mesa.git] / src / mesa / drivers / dri / nouveau / nouveau_context.h
1 /*
2 * Copyright (C) 2009 Francisco Jerez.
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial
15 * portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 *
25 */
26
27 #ifndef __NOUVEAU_CONTEXT_H__
28 #define __NOUVEAU_CONTEXT_H__
29
30 #include "nouveau_screen.h"
31 #include "nouveau_state.h"
32 #include "nouveau_bo_state.h"
33 #include "nouveau_render.h"
34
35 #include "main/bitset.h"
36
37 enum nouveau_fallback {
38 HWTNL = 0,
39 SWTNL,
40 SWRAST,
41 };
42
43 struct nouveau_hw_state {
44 struct nouveau_channel *chan;
45
46 struct nouveau_notifier *ntfy;
47 struct nouveau_grobj *eng3d;
48 struct nouveau_grobj *eng3dm;
49 struct nouveau_grobj *surf3d;
50 struct nouveau_grobj *m2mf;
51 struct nouveau_grobj *surf2d;
52 struct nouveau_grobj *rop;
53 struct nouveau_grobj *patt;
54 struct nouveau_grobj *rect;
55 struct nouveau_grobj *swzsurf;
56 struct nouveau_grobj *sifm;
57 };
58
59 struct nouveau_context {
60 GLcontext base;
61 __DRIcontext *dri_context;
62 struct nouveau_screen *screen;
63
64 BITSET_DECLARE(dirty, MAX_NOUVEAU_STATE);
65 enum nouveau_fallback fallback;
66
67 struct nouveau_hw_state hw;
68 struct nouveau_bo_state bo;
69 struct nouveau_render_state render;
70
71 struct {
72 GLboolean clear_blocked;
73 int clear_seq;
74 } hierz;
75 };
76
77 #define to_nouveau_context(ctx) ((struct nouveau_context *)(ctx))
78
79 #define context_dev(ctx) \
80 (to_nouveau_context(ctx)->screen->device)
81 #define context_chipset(ctx) \
82 (context_dev(ctx)->chipset)
83 #define context_chan(ctx) \
84 (to_nouveau_context(ctx)->hw.chan)
85 #define context_eng3d(ctx) \
86 (to_nouveau_context(ctx)->hw.eng3d)
87 #define context_drv(ctx) \
88 (to_nouveau_context(ctx)->screen->driver)
89 #define context_dirty(ctx, s) \
90 BITSET_SET(to_nouveau_context(ctx)->dirty, NOUVEAU_STATE_##s)
91 #define context_dirty_i(ctx, s, i) \
92 BITSET_SET(to_nouveau_context(ctx)->dirty, NOUVEAU_STATE_##s##0 + i)
93 #define context_emit(ctx, s) \
94 context_drv(ctx)->emit[NOUVEAU_STATE_##s](ctx, NOUVEAU_STATE_##s)
95
96 GLboolean
97 nouveau_context_create(gl_api api,
98 const struct gl_config *visual, __DRIcontext *dri_ctx,
99 void *share_ctx);
100
101 GLboolean
102 nouveau_context_init(GLcontext *ctx, struct nouveau_screen *screen,
103 const struct gl_config *visual, GLcontext *share_ctx);
104
105 void
106 nouveau_context_deinit(GLcontext *ctx);
107
108 void
109 nouveau_context_destroy(__DRIcontext *dri_ctx);
110
111 void
112 nouveau_update_renderbuffers(__DRIcontext *dri_ctx, __DRIdrawable *draw);
113
114 GLboolean
115 nouveau_context_make_current(__DRIcontext *dri_ctx, __DRIdrawable *ddraw,
116 __DRIdrawable *rdraw);
117
118 GLboolean
119 nouveau_context_unbind(__DRIcontext *dri_ctx);
120
121 void
122 nouveau_fallback(GLcontext *ctx, enum nouveau_fallback mode);
123
124 void
125 nouveau_validate_framebuffer(GLcontext *ctx);
126
127 #endif
128