00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "i915simple/i915_screen.h"
00029
00030 #include "intel_device.h"
00031 #include "intel_context.h"
00032 #include "intel_batchbuffer.h"
00033
00034 #include "state_tracker/st_public.h"
00035 #include "pipe/p_defines.h"
00036 #include "pipe/p_context.h"
00037 #include "intel_egl.h"
00038 #include "utils.h"
00039
00040 #ifdef DEBUG
00041 int __intel_debug = 0;
00042 #endif
00043
00044
00045 #define need_GL_ARB_multisample
00046 #define need_GL_ARB_point_parameters
00047 #define need_GL_ARB_texture_compression
00048 #define need_GL_ARB_vertex_buffer_object
00049 #define need_GL_ARB_vertex_program
00050 #define need_GL_ARB_window_pos
00051 #define need_GL_EXT_blend_color
00052 #define need_GL_EXT_blend_equation_separate
00053 #define need_GL_EXT_blend_func_separate
00054 #define need_GL_EXT_blend_minmax
00055 #define need_GL_EXT_cull_vertex
00056 #define need_GL_EXT_fog_coord
00057 #define need_GL_EXT_framebuffer_object
00058 #define need_GL_EXT_multi_draw_arrays
00059 #define need_GL_EXT_secondary_color
00060 #define need_GL_NV_vertex_program
00061 #include "extension_helper.h"
00062
00063
00071 const struct dri_extension card_extensions[] = {
00072 {"GL_ARB_multisample", GL_ARB_multisample_functions},
00073 {"GL_ARB_multitexture", NULL},
00074 {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions},
00075 {"GL_ARB_texture_border_clamp", NULL},
00076 {"GL_ARB_texture_compression", GL_ARB_texture_compression_functions},
00077 {"GL_ARB_texture_cube_map", NULL},
00078 {"GL_ARB_texture_env_add", NULL},
00079 {"GL_ARB_texture_env_combine", NULL},
00080 {"GL_ARB_texture_env_dot3", NULL},
00081 {"GL_ARB_texture_mirrored_repeat", NULL},
00082 {"GL_ARB_texture_rectangle", NULL},
00083 {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions},
00084 {"GL_ARB_pixel_buffer_object", NULL},
00085 {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions},
00086 {"GL_ARB_window_pos", GL_ARB_window_pos_functions},
00087 {"GL_EXT_blend_color", GL_EXT_blend_color_functions},
00088 {"GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions},
00089 {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions},
00090 {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions},
00091 {"GL_EXT_blend_subtract", NULL},
00092 {"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions},
00093 {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions},
00094 {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions},
00095 {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions},
00096 {"GL_EXT_packed_depth_stencil", NULL},
00097 {"GL_EXT_pixel_buffer_object", NULL},
00098 {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions},
00099 {"GL_EXT_stencil_wrap", NULL},
00100 {"GL_EXT_texture_edge_clamp", NULL},
00101 {"GL_EXT_texture_env_combine", NULL},
00102 {"GL_EXT_texture_env_dot3", NULL},
00103 {"GL_EXT_texture_filter_anisotropic", NULL},
00104 {"GL_EXT_texture_lod_bias", NULL},
00105 {"GL_3DFX_texture_compression_FXT1", NULL},
00106 {"GL_APPLE_client_storage", NULL},
00107 {"GL_MESA_pack_invert", NULL},
00108 {"GL_MESA_ycbcr_texture", NULL},
00109 {"GL_NV_blend_square", NULL},
00110 {"GL_NV_vertex_program", GL_NV_vertex_program_functions},
00111 {"GL_NV_vertex_program1_1", NULL},
00112 {"GL_SGIS_generate_mipmap", NULL },
00113 {NULL, NULL}
00114 };
00115
00116
00117
00118
00119
00120
00121
00122 static void
00123 intel_lock_hardware(struct intel_be_context *context)
00124 {
00125 (void)context;
00126 }
00127
00128 static void
00129 intel_unlock_hardware(struct intel_be_context *context)
00130 {
00131 (void)context;
00132 }
00133
00134 static boolean
00135 intel_locked_hardware(struct intel_be_context *context)
00136 {
00137 (void)context;
00138 return FALSE;
00139 }
00140
00141
00142
00143
00144
00145
00146 int
00147 intel_create_context(struct egl_drm_context *egl_context, const __GLcontextModes *visual, void *sharedContextPrivate)
00148 {
00149 struct intel_context *intel = CALLOC_STRUCT(intel_context);
00150 struct intel_device *device = (struct intel_device *)egl_context->device->priv;
00151 struct pipe_context *pipe;
00152 struct st_context *st_share = NULL;
00153
00154 egl_context->priv = intel;
00155
00156 intel->intel_device = device;
00157 intel->egl_context = egl_context;
00158 intel->egl_device = egl_context->device;
00159
00160 intel->base.hardware_lock = intel_lock_hardware;
00161 intel->base.hardware_unlock = intel_unlock_hardware;
00162 intel->base.hardware_locked = intel_locked_hardware;
00163
00164 intel_be_init_context(&intel->base, &device->base);
00165
00166 #if 0
00167 pipe = intel_create_softpipe(intel, screen->winsys);
00168 #else
00169 pipe = i915_create_context(device->pipe, &device->base.base, &intel->base.base);
00170 #endif
00171
00172 pipe->priv = intel;
00173
00174 intel->st = st_create_context(pipe, visual, st_share);
00175
00176 device->dummy = intel;
00177
00178 return TRUE;
00179 }
00180
00181 int
00182 intel_destroy_context(struct egl_drm_context *egl_context)
00183 {
00184 struct intel_context *intel = egl_context->priv;
00185
00186 if (intel->intel_device->dummy == intel)
00187 intel->intel_device->dummy = NULL;
00188
00189 st_destroy_context(intel->st);
00190 intel_be_destroy_context(&intel->base);
00191 free(intel);
00192 return TRUE;
00193 }
00194
00195 void
00196 intel_make_current(struct egl_drm_context *context, struct egl_drm_drawable *draw, struct egl_drm_drawable *read)
00197 {
00198 if (context) {
00199 struct intel_context *intel = (struct intel_context *)context->priv;
00200 struct intel_framebuffer *draw_fb = (struct intel_framebuffer *)draw->priv;
00201 struct intel_framebuffer *read_fb = (struct intel_framebuffer *)read->priv;
00202
00203 assert(draw_fb->stfb);
00204 assert(read_fb->stfb);
00205
00206 st_make_current(intel->st, draw_fb->stfb, read_fb->stfb);
00207
00208 intel->egl_drawable = draw;
00209
00210 st_resize_framebuffer(draw_fb->stfb, draw->w, draw->h);
00211
00212 if (draw != read)
00213 st_resize_framebuffer(read_fb->stfb, read->w, read->h);
00214
00215 } else {
00216 st_make_current(NULL, NULL, NULL);
00217 }
00218 }
00219
00220 void
00221 intel_bind_frontbuffer(struct egl_drm_drawable *draw, struct egl_drm_frontbuffer *front)
00222 {
00223 struct intel_device *device = (struct intel_device *)draw->device->priv;
00224 struct intel_framebuffer *draw_fb = (struct intel_framebuffer *)draw->priv;
00225
00226 if (draw_fb->front_buffer)
00227 driBOUnReference(draw_fb->front_buffer);
00228
00229 draw_fb->front_buffer = NULL;
00230 draw_fb->front = NULL;
00231
00232
00233 if (!front)
00234 return;
00235
00236 draw_fb->front = front;
00237
00238 driGenBuffers(device->base.staticPool, "front", 1, &draw_fb->front_buffer, 0, 0, 0);
00239 driBOSetReferenced(draw_fb->front_buffer, front->handle);
00240
00241 st_resize_framebuffer(draw_fb->stfb, draw->w, draw->h);
00242 }