2 * Copyright (C) 2009 Francisco Jerez.
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:
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.
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.
27 #ifndef __NOUVEAU_CONTEXT_H__
28 #define __NOUVEAU_CONTEXT_H__
30 #include "nouveau_screen.h"
31 #include "nouveau_state.h"
32 #include "nouveau_bo_state.h"
33 #include "nouveau_render.h"
35 #include "main/bitset.h"
37 enum nouveau_fallback
{
43 struct nouveau_drawable_state
{
49 struct nouveau_context
{
51 __DRIcontext
*dri_context
;
52 struct nouveau_screen
*screen
;
54 BITSET_DECLARE(dirty
, MAX_NOUVEAU_STATE
);
55 enum nouveau_fallback fallback
;
57 struct nouveau_bo_state bo
;
58 struct nouveau_render_state render
;
59 struct nouveau_drawable_state drawable
;
62 #define to_nouveau_context(ctx) ((struct nouveau_context *)(ctx))
64 #define context_dev(ctx) \
65 (to_nouveau_context(ctx)->screen->device)
66 #define context_chipset(ctx) \
67 (context_dev(ctx)->chipset)
68 #define context_chan(ctx) \
69 (to_nouveau_context(ctx)->screen->chan)
70 #define context_eng3d(ctx) \
71 (to_nouveau_context(ctx)->screen->eng3d)
72 #define context_drv(ctx) \
73 (to_nouveau_context(ctx)->screen->driver)
74 #define context_dirty(ctx, s) \
75 BITSET_SET(to_nouveau_context(ctx)->dirty, NOUVEAU_STATE_##s)
76 #define context_dirty_i(ctx, s, i) \
77 BITSET_SET(to_nouveau_context(ctx)->dirty, NOUVEAU_STATE_##s##0 + i)
80 nouveau_context_create(const __GLcontextModes
*visual
, __DRIcontext
*dri_ctx
,
84 nouveau_context_init(GLcontext
*ctx
, struct nouveau_screen
*screen
,
85 const GLvisual
*visual
, GLcontext
*share_ctx
);
88 nouveau_context_destroy(__DRIcontext
*dri_ctx
);
91 nouveau_context_make_current(__DRIcontext
*dri_ctx
,
93 __DRIdrawable
*rdraw
);
96 nouveau_context_unbind(__DRIcontext
*dri_ctx
);
99 nouveau_fallback(GLcontext
*ctx
, enum nouveau_fallback mode
);
102 nouveau_validate_framebuffer(GLcontext
*ctx
);