1 /**************************************************************************
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 #include "main/imports.h" /* CALLOC */
29 #include "i915_context.h"
30 #include "i915_winsys.h"
31 #include "i915_state.h"
33 #include "pipe/draw/draw_context.h"
34 #include "pipe/p_defines.h"
39 * Return list of supported surface/texture formats.
40 * If we find texture and drawable support differs, add a selector
41 * parameter or another function.
44 i915_supported_formats(struct pipe_context
*pipe
,
49 static const GLuint tex_supported
[] = {
50 PIPE_FORMAT_U_R8_G8_B8_A8
,
51 PIPE_FORMAT_U_A8_R8_G8_B8
,
52 PIPE_FORMAT_U_R5_G6_B5
,
58 PIPE_FORMAT_YCBCR_REV
,
63 /* Actually a lot more than this - add later:
65 static const GLuint render_supported
[] = {
66 PIPE_FORMAT_U_A8_R8_G8_B8
,
67 PIPE_FORMAT_U_R5_G6_B5
,
72 static const GLuint z_stencil_supported
[] = {
79 case PIPE_RENDER_FORMAT
:
80 *numFormats
= Elements(render_supported
);
81 return render_supported
;
84 *numFormats
= Elements(tex_supported
);
85 return render_supported
;
87 case PIPE_Z_STENCIL_FORMAT
:
88 *numFormats
= Elements(render_supported
);
89 return render_supported
;
96 static const GLuint render_supported
[] = {
97 PIPE_FORMAT_U_A8_R8_G8_B8
,
98 PIPE_FORMAT_U_R5_G6_B5
,
102 return render_supported
;
108 static void i915_destroy( struct pipe_context
*pipe
)
110 struct i915_context
*i915
= i915_context( pipe
);
112 draw_destroy( i915
->draw
);
117 static void i915_draw_vb( struct pipe_context
*pipe
,
118 struct vertex_buffer
*VB
)
120 struct i915_context
*i915
= i915_context( pipe
);
123 // i915_update_derived( i915 );
125 draw_vb( i915
->draw
, VB
);
130 i915_draw_vertices(struct pipe_context
*pipe
,
132 GLuint numVertex
, const GLfloat
*verts
,
133 GLuint numAttribs
, const GLuint attribs
[])
135 struct i915_context
*i915
= i915_context( pipe
);
138 i915_update_derived( i915
);
140 draw_vertices(i915
->draw
, mode
, numVertex
, verts
, numAttribs
, attribs
);
146 struct pipe_context
*i915_create( struct i915_winsys
*winsys
)
148 struct i915_context
*i915
= CALLOC_STRUCT(i915_context
);
150 i915
->pipe
.destroy
= i915_destroy
;
152 i915
->pipe
.supported_formats
= i915_supported_formats
;
154 i915
->pipe
.draw_vb
= i915_draw_vb
;
155 i915
->pipe
.draw_vertices
= i915_draw_vertices
;
156 i915
->pipe
.clear
= i915_clear
;
157 i915
->pipe
.reset_occlusion_counter
= NULL
; /* no support */
158 i915
->pipe
.get_occlusion_counter
= NULL
;
160 i915
->winsys
= winsys
;
163 * Create drawing context and plug our rendering stage into it.
165 i915
->draw
= draw_create();
167 draw_set_setup_stage(i915
->draw
, i915_draw_render_stage(i915
));
169 i915_init_buffer_functions(i915
);
170 i915_init_region_functions(i915
);
171 i915_init_surface_functions(i915
);
172 i915_init_state_functions(i915
);
175 * XXX we could plug GL selection/feedback into the drawing pipeline
176 * by specifying a different setup/render stage.