1 /**************************************************************************
3 Copyright 2006 Stephane Marchesin
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 on the rights to use, copy, modify, merge, publish, distribute, sub
10 license, and/or sell copies of the Software, and to permit persons to whom
11 the Software is furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice (including the next
14 paragraph) shall be included in all copies or substantial portions of the
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
20 ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM,
21 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23 USE OR OTHER DEALINGS IN THE SOFTWARE.
25 **************************************************************************/
29 #ifndef __NOUVEAU_CONTEXT_H__
30 #define __NOUVEAU_CONTEXT_H__
34 #include "nouveau_drm.h"
37 #include "tnl/t_vertex.h"
39 #include "nouveau_screen.h"
40 #include "nouveau_state_cache.h"
41 #include "nouveau_buffers.h"
42 #include "nouveau_shader.h"
44 #include "xmlconfig.h"
46 typedef struct nouveau_fifo_t
{
57 #define TAG(x) nouveau##x
58 #include "tnl_dd/t_dd_vertex.h"
61 /* Subpixel offsets for window coordinates (triangles): */
62 #define SUBPIXEL_X (0.0F)
63 #define SUBPIXEL_Y (0.125F)
65 struct nouveau_context
;
67 typedef void (*nouveau_tri_func
)( struct nouveau_context
*,
72 typedef void (*nouveau_line_func
)( struct nouveau_context
*,
76 typedef void (*nouveau_point_func
)( struct nouveau_context
*,
79 typedef struct nouveau_hw_func_t
{
80 /* Initialise any card-specific non-GL related state */
81 GLboolean (*InitCard
)(struct nouveau_context
*);
82 /* Update buffer offset/pitch/format */
83 GLboolean (*BindBuffers
)(struct nouveau_context
*, int num_color
,
84 nouveau_renderbuffer
**color
,
85 nouveau_renderbuffer
*depth
);
86 /* Update anything that depends on the window position/size */
87 void (*WindowMoved
)(struct nouveau_context
*);
90 typedef struct nouveau_context
{
94 /* The per-context fifo */
97 /* The read-only regs */
98 volatile unsigned char* mmio
;
100 /* Physical addresses of AGP/VRAM apertures */
104 /* Additional hw-specific functions */
105 nouveau_hw_func hw_func
;
107 /* FIXME : do we want to put all state into a separate struct ? */
110 GLuint specular_offset
;
115 struct tnl_attr_map vertex_attrs
[VERT_ATTRIB_MAX
];
116 GLuint vertex_attr_count
;
118 /* Depth/stencil clear state */
119 uint32_t clear_value
;
122 GLboolean lighting_enabled
;
123 uint32_t enabled_lights
;
126 nouveau_state_cache state_cache
;
128 /* The drawing fallbacks */
130 nouveau_tri_func draw_tri
;
131 nouveau_line_func draw_line
;
132 nouveau_point_func draw_point
;
134 /* Cliprects information */
136 drm_clip_rect_t
*pClipRects
;
138 /* The rendering context information */
139 GLenum current_primitive
; /* the current primitive enum */
140 DECLARE_RENDERINPUTS(render_inputs_bitset
); /* the current render inputs */
145 nouveauShader
*current_fragprog
;
146 nouveauShader
*current_vertprog
;
148 nouveauScreenRec
*screen
;
149 drm_nouveau_sarea_t
*sarea
;
151 __DRIcontextPrivate
*driContext
; /* DRI context */
152 __DRIscreenPrivate
*driScreen
; /* DRI screen */
153 __DRIdrawablePrivate
*driDrawable
; /* DRI drawable bound to this ctx */
156 drm_context_t hHWContext
;
157 drm_hw_lock_t
*driHwLock
;
160 /* Configuration cache */
161 driOptionCache optionCache
;
164 uint32_t vblank_flags
;
168 GLuint new_render_state
;
173 }nouveauContextRec
, *nouveauContextPtr
;
176 #define NOUVEAU_CONTEXT(ctx) ((nouveauContextPtr)(ctx->DriverCtx))
178 /* Flags for software fallback cases: */
179 #define NOUVEAU_FALLBACK_TEXTURE 0x0001
180 #define NOUVEAU_FALLBACK_DRAW_BUFFER 0x0002
181 #define NOUVEAU_FALLBACK_READ_BUFFER 0x0004
182 #define NOUVEAU_FALLBACK_STENCIL 0x0008
183 #define NOUVEAU_FALLBACK_RENDER_MODE 0x0010
184 #define NOUVEAU_FALLBACK_LOGICOP 0x0020
185 #define NOUVEAU_FALLBACK_SEP_SPECULAR 0x0040
186 #define NOUVEAU_FALLBACK_BLEND_EQ 0x0080
187 #define NOUVEAU_FALLBACK_BLEND_FUNC 0x0100
188 #define NOUVEAU_FALLBACK_PROJTEX 0x0200
189 #define NOUVEAU_FALLBACK_DISABLE 0x0400
192 extern GLboolean
nouveauCreateContext( const __GLcontextModes
*glVisual
,
193 __DRIcontextPrivate
*driContextPriv
,
194 void *sharedContextPrivate
);
196 extern void nouveauDestroyContext( __DRIcontextPrivate
* );
198 extern GLboolean
nouveauMakeCurrent( __DRIcontextPrivate
*driContextPriv
,
199 __DRIdrawablePrivate
*driDrawPriv
,
200 __DRIdrawablePrivate
*driReadPriv
);
202 extern GLboolean
nouveauUnbindContext( __DRIcontextPrivate
*driContextPriv
);
204 extern void nouveauSwapBuffers(__DRIdrawablePrivate
*dPriv
);
206 extern void nouveauCopySubBuffer(__DRIdrawablePrivate
*dPriv
,
207 int x
, int y
, int w
, int h
);
209 #endif /* __NOUVEAU_CONTEXT_H__ */