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 "i915simple/i915_screen.h"
30 #include "intel_device.h"
31 #include "intel_context.h"
32 #include "intel_batchbuffer.h"
34 #include "state_tracker/st_public.h"
35 #include "pipe/p_defines.h"
36 #include "pipe/p_context.h"
37 #include "intel_egl.h"
41 int __intel_debug
= 0;
45 #define need_GL_ARB_multisample
46 #define need_GL_ARB_point_parameters
47 #define need_GL_ARB_texture_compression
48 #define need_GL_ARB_vertex_buffer_object
49 #define need_GL_ARB_vertex_program
50 #define need_GL_ARB_window_pos
51 #define need_GL_EXT_blend_color
52 #define need_GL_EXT_blend_equation_separate
53 #define need_GL_EXT_blend_func_separate
54 #define need_GL_EXT_blend_minmax
55 #define need_GL_EXT_cull_vertex
56 #define need_GL_EXT_fog_coord
57 #define need_GL_EXT_framebuffer_object
58 #define need_GL_EXT_multi_draw_arrays
59 #define need_GL_EXT_secondary_color
60 #define need_GL_NV_vertex_program
61 #include "extension_helper.h"
65 * Extension strings exported by the intel driver.
68 * It appears that ARB_texture_env_crossbar has "disappeared" compared to the
69 * old i830-specific driver.
71 const struct dri_extension card_extensions
[] = {
72 {"GL_ARB_multisample", GL_ARB_multisample_functions
},
73 {"GL_ARB_multitexture", NULL
},
74 {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions
},
75 {"GL_ARB_texture_border_clamp", NULL
},
76 {"GL_ARB_texture_compression", GL_ARB_texture_compression_functions
},
77 {"GL_ARB_texture_cube_map", NULL
},
78 {"GL_ARB_texture_env_add", NULL
},
79 {"GL_ARB_texture_env_combine", NULL
},
80 {"GL_ARB_texture_env_dot3", NULL
},
81 {"GL_ARB_texture_mirrored_repeat", NULL
},
82 {"GL_ARB_texture_rectangle", NULL
},
83 {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions
},
84 {"GL_ARB_pixel_buffer_object", NULL
},
85 {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions
},
86 {"GL_ARB_window_pos", GL_ARB_window_pos_functions
},
87 {"GL_EXT_blend_color", GL_EXT_blend_color_functions
},
88 {"GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions
},
89 {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions
},
90 {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions
},
91 {"GL_EXT_blend_subtract", NULL
},
92 {"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions
},
93 {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions
},
94 {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions
},
95 {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions
},
96 {"GL_EXT_packed_depth_stencil", NULL
},
97 {"GL_EXT_pixel_buffer_object", NULL
},
98 {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions
},
99 {"GL_EXT_stencil_wrap", NULL
},
100 {"GL_EXT_texture_edge_clamp", NULL
},
101 {"GL_EXT_texture_env_combine", NULL
},
102 {"GL_EXT_texture_env_dot3", NULL
},
103 {"GL_EXT_texture_filter_anisotropic", NULL
},
104 {"GL_EXT_texture_lod_bias", NULL
},
105 {"GL_3DFX_texture_compression_FXT1", NULL
},
106 {"GL_APPLE_client_storage", NULL
},
107 {"GL_MESA_pack_invert", NULL
},
108 {"GL_MESA_ycbcr_texture", NULL
},
109 {"GL_NV_blend_square", NULL
},
110 {"GL_NV_vertex_program", GL_NV_vertex_program_functions
},
111 {"GL_NV_vertex_program1_1", NULL
},
112 {"GL_SGIS_generate_mipmap", NULL
},
118 * Hardware lock functions.
119 * Doesn't do anything in EGL
123 intel_lock_hardware(struct intel_be_context
*context
)
129 intel_unlock_hardware(struct intel_be_context
*context
)
135 intel_locked_hardware(struct intel_be_context
*context
)
147 intel_create_context(struct egl_drm_context
*egl_context
, const __GLcontextModes
*visual
, void *sharedContextPrivate
)
149 struct intel_context
*intel
= CALLOC_STRUCT(intel_context
);
150 struct intel_device
*device
= (struct intel_device
*)egl_context
->device
->priv
;
151 struct pipe_context
*pipe
;
152 struct st_context
*st_share
= NULL
;
154 egl_context
->priv
= intel
;
156 intel
->intel_device
= device
;
157 intel
->egl_context
= egl_context
;
158 intel
->egl_device
= egl_context
->device
;
160 intel
->base
.hardware_lock
= intel_lock_hardware
;
161 intel
->base
.hardware_unlock
= intel_unlock_hardware
;
162 intel
->base
.hardware_locked
= intel_locked_hardware
;
164 intel_be_init_context(&intel
->base
, &device
->base
);
167 pipe
= intel_create_softpipe(intel
, screen
->winsys
);
169 pipe
= i915_create_context(device
->pipe
, &device
->base
.base
, &intel
->base
.base
);
174 intel
->st
= st_create_context(pipe
, visual
, st_share
);
176 device
->dummy
= intel
;
182 intel_destroy_context(struct egl_drm_context
*egl_context
)
184 struct intel_context
*intel
= egl_context
->priv
;
186 if (intel
->intel_device
->dummy
== intel
)
187 intel
->intel_device
->dummy
= NULL
;
189 st_destroy_context(intel
->st
);
190 intel_be_destroy_context(&intel
->base
);
196 intel_make_current(struct egl_drm_context
*context
, struct egl_drm_drawable
*draw
, struct egl_drm_drawable
*read
)
199 struct intel_context
*intel
= (struct intel_context
*)context
->priv
;
200 struct intel_framebuffer
*draw_fb
= (struct intel_framebuffer
*)draw
->priv
;
201 struct intel_framebuffer
*read_fb
= (struct intel_framebuffer
*)read
->priv
;
203 assert(draw_fb
->stfb
);
204 assert(read_fb
->stfb
);
206 st_make_current(intel
->st
, draw_fb
->stfb
, read_fb
->stfb
);
208 intel
->egl_drawable
= draw
;
210 st_resize_framebuffer(draw_fb
->stfb
, draw
->w
, draw
->h
);
213 st_resize_framebuffer(read_fb
->stfb
, read
->w
, read
->h
);
216 st_make_current(NULL
, NULL
, NULL
);
221 intel_bind_frontbuffer(struct egl_drm_drawable
*draw
, struct egl_drm_frontbuffer
*front
)
223 struct intel_device
*device
= (struct intel_device
*)draw
->device
->priv
;
224 struct intel_framebuffer
*draw_fb
= (struct intel_framebuffer
*)draw
->priv
;
226 if (draw_fb
->front_buffer
)
227 driBOUnReference(draw_fb
->front_buffer
);
229 draw_fb
->front_buffer
= NULL
;
230 draw_fb
->front
= NULL
;
232 /* to unbind just call this function with front == NULL */
236 draw_fb
->front
= front
;
238 driGenBuffers(device
->base
.staticPool
, "front", 1, &draw_fb
->front_buffer
, 0, 0, 0);
239 driBOSetReferenced(draw_fb
->front_buffer
, front
->handle
);
241 st_resize_framebuffer(draw_fb
->stfb
, draw
->w
, draw
->h
);