~ubuntu-branches/ubuntu/precise/mesa/precise-updates

« back to all changes in this revision

Viewing changes to src/mesa/drivers/dri/r200/r200_context.c

  • Committer: Package Import Robot
  • Author(s): Robert Hooker
  • Date: 2012-02-02 12:05:48 UTC
  • mfrom: (1.7.1) (3.3.27 sid)
  • Revision ID: package-import@ubuntu.com-20120202120548-nvkma85jq0h4coix
Tags: 8.0~rc2-0ubuntu4
Drop drisearchdir handling, it is no longer needed with multiarch
and dri-alternates being removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 *   Keith Whitwell <keith@tungstengraphics.com>
33
33
 */
34
34
 
 
35
#include <stdbool.h>
35
36
#include "main/glheader.h"
36
37
#include "main/api_arrayelt.h"
37
38
#include "main/context.h"
39
40
#include "main/imports.h"
40
41
#include "main/extensions.h"
41
42
#include "main/mfeatures.h"
 
43
#include "main/version.h"
42
44
 
43
45
#include "swrast/swrast.h"
44
46
#include "swrast_setup/swrast_setup.h"
61
63
 
62
64
#include "radeon_span.h"
63
65
 
64
 
#define need_GL_ARB_occlusion_query
65
 
#define need_GL_ARB_vertex_array_object
66
 
#define need_GL_ARB_vertex_program
67
 
#define need_GL_APPLE_vertex_array_object
68
 
#define need_GL_ATI_fragment_shader
69
 
#define need_GL_EXT_blend_minmax
70
 
#define need_GL_EXT_fog_coord
71
 
#define need_GL_EXT_secondary_color
72
 
#define need_GL_EXT_blend_equation_separate
73
 
#define need_GL_EXT_blend_func_separate
74
 
#define need_GL_EXT_gpu_program_parameters
75
 
#define need_GL_NV_vertex_program
76
 
#define need_GL_ARB_point_parameters
77
 
#define need_GL_EXT_framebuffer_object
78
 
#define need_GL_OES_EGL_image
79
 
 
80
 
#include "main/remap_helper.h"
81
 
 
82
66
#include "utils.h"
83
67
#include "xmlpool.h" /* for symbolic values of enum-type options */
84
68
 
111
95
}
112
96
 
113
97
 
114
 
/* Extension strings exported by the R200 driver.
115
 
 */
116
 
static const struct dri_extension card_extensions[] =
117
 
{
118
 
    { "GL_ARB_half_float_pixel",           NULL },
119
 
    { "GL_ARB_multitexture",               NULL },
120
 
    { "GL_ARB_occlusion_query",            GL_ARB_occlusion_query_functions},
121
 
    { "GL_ARB_texture_border_clamp",       NULL },
122
 
    { "GL_ARB_texture_env_add",            NULL },
123
 
    { "GL_ARB_texture_env_combine",        NULL },
124
 
    { "GL_ARB_texture_env_dot3",           NULL },
125
 
    { "GL_ARB_texture_env_crossbar",       NULL },
126
 
    { "GL_ARB_texture_mirrored_repeat",    NULL },
127
 
    { "GL_ARB_vertex_array_object",        GL_ARB_vertex_array_object_functions},
128
 
    { "GL_EXT_blend_minmax",               GL_EXT_blend_minmax_functions },
129
 
    { "GL_EXT_blend_subtract",             NULL },
130
 
    { "GL_EXT_fog_coord",                  GL_EXT_fog_coord_functions },
131
 
    { "GL_EXT_packed_depth_stencil",       NULL},
132
 
    { "GL_EXT_secondary_color",            GL_EXT_secondary_color_functions },
133
 
    { "GL_EXT_stencil_wrap",               NULL },
134
 
    { "GL_EXT_texture_edge_clamp",         NULL },
135
 
    { "GL_EXT_texture_env_combine",        NULL },
136
 
    { "GL_EXT_texture_env_dot3",           NULL },
137
 
    { "GL_EXT_texture_filter_anisotropic", NULL },
138
 
    { "GL_EXT_texture_lod_bias",           NULL },
139
 
    { "GL_EXT_texture_mirror_clamp",       NULL },
140
 
    { "GL_EXT_texture_rectangle",          NULL },
141
 
    { "GL_APPLE_vertex_array_object",      GL_APPLE_vertex_array_object_functions },
142
 
    { "GL_ATI_texture_env_combine3",       NULL },
143
 
    { "GL_ATI_texture_mirror_once",        NULL },
144
 
    { "GL_MESA_pack_invert",               NULL },
145
 
    { "GL_NV_blend_square",                NULL },
146
 
#if FEATURE_OES_EGL_image
147
 
    { "GL_OES_EGL_image",                  GL_OES_EGL_image_functions },
148
 
#endif
149
 
    { NULL,                                NULL }
150
 
};
151
 
 
152
 
static const struct dri_extension blend_extensions[] = {
153
 
    { "GL_EXT_blend_equation_separate",    GL_EXT_blend_equation_separate_functions },
154
 
    { "GL_EXT_blend_func_separate",        GL_EXT_blend_func_separate_functions },
155
 
    { NULL,                                NULL }
156
 
};
157
 
 
158
 
static const struct dri_extension ARB_vp_extension[] = {
159
 
    { "GL_ARB_vertex_program",             GL_ARB_vertex_program_functions },
160
 
    { "GL_EXT_gpu_program_parameters",     GL_EXT_gpu_program_parameters_functions},
161
 
    { NULL,                                NULL }
162
 
};
163
 
 
164
 
static const struct dri_extension NV_vp_extension[] = {
165
 
    { "GL_NV_vertex_program",              GL_NV_vertex_program_functions }
166
 
};
167
 
 
168
 
static const struct dri_extension ATI_fs_extension[] = {
169
 
    { "GL_ATI_fragment_shader",            GL_ATI_fragment_shader_functions }
170
 
};
171
 
 
172
 
static const struct dri_extension point_extensions[] = {
173
 
    { "GL_ARB_point_sprite",               NULL },
174
 
    { "GL_ARB_point_parameters",           GL_ARB_point_parameters_functions },
175
 
    { NULL,                                NULL }
176
 
};
177
 
 
178
 
static const struct dri_extension mm_extensions[] = {
179
 
  { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions },
180
 
  { NULL, NULL }
181
 
};
182
 
 
183
98
extern const struct tnl_pipeline_stage _r200_render_stage;
184
99
extern const struct tnl_pipeline_stage _r200_tcl_stage;
185
100
 
240
155
 
241
156
   if ( sarea->ctx_owner != rmesa->radeon.dri.hwContext ) {
242
157
      sarea->ctx_owner = rmesa->radeon.dri.hwContext;
243
 
      if (!radeon->radeonScreen->kernel_mm)
244
 
         radeon_bo_legacy_texture_age(radeon->radeonScreen->bom);
245
158
   }
246
159
 
247
160
}
284
197
GLboolean r200CreateContext( gl_api api,
285
198
                             const struct gl_config *glVisual,
286
199
                             __DRIcontext *driContextPriv,
 
200
                             unsigned major_version,
 
201
                             unsigned minor_version,
 
202
                             uint32_t flags,
 
203
                             unsigned *error,
287
204
                             void *sharedContextPrivate)
288
205
{
289
206
   __DRIscreen *sPriv = driContextPriv->driScreenPriv;
290
 
   radeonScreenPtr screen = (radeonScreenPtr)(sPriv->private);
 
207
   radeonScreenPtr screen = (radeonScreenPtr)(sPriv->driverPrivate);
291
208
   struct dd_function_table functions;
292
209
   r200ContextPtr rmesa;
293
210
   struct gl_context *ctx;
294
211
   int i;
295
212
   int tcl_mode;
296
213
 
 
214
   /* API and flag filtering is handled in dri2CreateContextAttribs.
 
215
    */
 
216
   (void) api;
 
217
   (void) flags;
 
218
 
297
219
   assert(glVisual);
298
220
   assert(driContextPriv);
299
221
   assert(screen);
300
222
 
301
223
   /* Allocate the R200 context */
302
224
   rmesa = (r200ContextPtr) CALLOC( sizeof(*rmesa) );
303
 
   if ( !rmesa )
 
225
   if ( !rmesa ) {
 
226
      *error = __DRI_CTX_ERROR_NO_MEMORY;
304
227
      return GL_FALSE;
 
228
   }
305
229
 
306
230
   rmesa->radeon.radeonScreen = screen;
307
231
   r200_init_vtbl(&rmesa->radeon);
344
268
                          glVisual, driContextPriv,
345
269
                          sharedContextPrivate)) {
346
270
     FREE(rmesa);
 
271
     *error = __DRI_CTX_ERROR_NO_MEMORY;
347
272
     return GL_FALSE;
348
273
   }
349
274
 
364
289
 
365
290
   ctx->Const.MaxCombinedTextureImageUnits = ctx->Const.MaxTextureUnits;
366
291
 
 
292
   ctx->Const.StripTextureBorder = GL_TRUE;
 
293
 
367
294
   i = driQueryOptioni( &rmesa->radeon.optionCache, "allow_large_textures");
368
295
 
369
296
   /* FIXME: When no memory manager is available we should set this 
382
309
   ctx->Const.MinPointSizeAA = 1.0;
383
310
   ctx->Const.MaxPointSizeAA = 1.0;
384
311
   ctx->Const.PointSizeGranularity = 0.0625;
385
 
   if (rmesa->radeon.radeonScreen->drmSupportsPointSprites)
386
 
      ctx->Const.MaxPointSize = 2047.0;
387
 
   else
388
 
      ctx->Const.MaxPointSize = 1.0;
 
312
   ctx->Const.MaxPointSize = 2047.0;
389
313
 
390
314
   /* mesa initialization problem - _mesa_init_point was already called */
391
315
   ctx->Point.MaxSize = ctx->Const.MaxPointSize;
440
364
   _math_matrix_ctr( &rmesa->tmpmat );
441
365
   _math_matrix_set_identity( &rmesa->tmpmat );
442
366
 
443
 
   driInitExtensions( ctx, card_extensions, GL_TRUE );
444
 
 
445
 
   if (rmesa->radeon.radeonScreen->kernel_mm)
446
 
     driInitExtensions(ctx, mm_extensions, GL_FALSE);
 
367
   ctx->Extensions.ARB_half_float_pixel = true;
 
368
   ctx->Extensions.ARB_occlusion_query = true;
 
369
   ctx->Extensions.ARB_texture_border_clamp = true;
 
370
   ctx->Extensions.ARB_texture_env_combine = true;
 
371
   ctx->Extensions.ARB_texture_env_dot3 = true;
 
372
   ctx->Extensions.ARB_texture_env_crossbar = true;
 
373
   ctx->Extensions.ARB_vertex_array_object = true;
 
374
   ctx->Extensions.EXT_blend_color = true;
 
375
   ctx->Extensions.EXT_blend_minmax = true;
 
376
   ctx->Extensions.EXT_fog_coord = true;
 
377
   ctx->Extensions.EXT_packed_depth_stencil = true;
 
378
   ctx->Extensions.EXT_secondary_color = true;
 
379
   ctx->Extensions.EXT_texture_env_dot3 = true;
 
380
   ctx->Extensions.EXT_texture_filter_anisotropic = true;
 
381
   ctx->Extensions.EXT_texture_mirror_clamp = true;
 
382
   ctx->Extensions.APPLE_vertex_array_object = true;
 
383
   ctx->Extensions.ATI_texture_env_combine3 = true;
 
384
   ctx->Extensions.ATI_texture_mirror_once = true;
 
385
   ctx->Extensions.MESA_pack_invert = true;
 
386
   ctx->Extensions.NV_blend_square = true;
 
387
   ctx->Extensions.NV_texture_rectangle = true;
 
388
#if FEATURE_OES_EGL_image
 
389
   ctx->Extensions.OES_EGL_image = true;
 
390
#endif
 
391
 
 
392
   ctx->Extensions.EXT_framebuffer_object = true;
 
393
   ctx->Extensions.ARB_occlusion_query = true;
 
394
 
447
395
   if (!(rmesa->radeon.radeonScreen->chip_flags & R200_CHIPSET_YCBCR_BROKEN)) {
448
396
     /* yuv textures don't work with some chips - R200 / rv280 okay so far
449
397
        others get the bit ordering right but don't actually do YUV-RGB conversion */
450
 
      _mesa_enable_extension( ctx, "GL_MESA_ycbcr_texture" );
 
398
      ctx->Extensions.MESA_ycbcr_texture = true;
451
399
   }
452
400
   if (rmesa->radeon.glCtx->Mesa_DXTn) {
453
 
      _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
454
 
      _mesa_enable_extension( ctx, "GL_S3_s3tc" );
 
401
      ctx->Extensions.EXT_texture_compression_s3tc = true;
 
402
      ctx->Extensions.S3_s3tc = true;
455
403
   }
456
404
   else if (driQueryOptionb (&rmesa->radeon.optionCache, "force_s3tc_enable")) {
457
 
      _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
458
 
   }
459
 
 
460
 
   if (rmesa->radeon.radeonScreen->drmSupportsCubeMapsR200)
461
 
      _mesa_enable_extension( ctx, "GL_ARB_texture_cube_map" );
462
 
   if (rmesa->radeon.radeonScreen->drmSupportsBlendColor) {
463
 
       driInitExtensions( ctx, blend_extensions, GL_FALSE );
464
 
   }
465
 
   if(rmesa->radeon.radeonScreen->drmSupportsVertexProgram)
466
 
      driInitExtensions( ctx, ARB_vp_extension, GL_FALSE );
467
 
   if(driQueryOptionb(&rmesa->radeon.optionCache, "nv_vertex_program"))
468
 
      driInitSingleExtension( ctx, NV_vp_extension );
469
 
 
470
 
   if ((ctx->Const.MaxTextureUnits == 6) && rmesa->radeon.radeonScreen->drmSupportsFragShader)
471
 
      driInitSingleExtension( ctx, ATI_fs_extension );
472
 
   if (rmesa->radeon.radeonScreen->drmSupportsPointSprites)
473
 
      driInitExtensions( ctx, point_extensions, GL_FALSE );
474
 
 
475
 
   if (!rmesa->radeon.radeonScreen->kernel_mm)
476
 
      _mesa_disable_extension(ctx, "GL_ARB_occlusion_query");
 
405
      ctx->Extensions.EXT_texture_compression_s3tc = true;
 
406
   }
 
407
 
 
408
   ctx->Extensions.ARB_texture_cube_map = true;
 
409
 
 
410
   ctx->Extensions.EXT_blend_equation_separate = true;
 
411
   ctx->Extensions.EXT_blend_func_separate = true;
 
412
 
 
413
   ctx->Extensions.ARB_vertex_program = true;
 
414
   ctx->Extensions.EXT_gpu_program_parameters = true;
 
415
 
 
416
   ctx->Extensions.NV_vertex_program =
 
417
      driQueryOptionb(&rmesa->radeon.optionCache, "nv_vertex_program");
 
418
 
 
419
   ctx->Extensions.ATI_fragment_shader = (ctx->Const.MaxTextureUnits == 6);
 
420
 
 
421
   ctx->Extensions.ARB_point_sprite = true;
 
422
   ctx->Extensions.EXT_point_parameters = true;
 
423
 
477
424
#if 0
478
425
   r200InitDriverFuncs( ctx );
479
426
   r200InitIoctlFuncs( ctx );
505
452
      TCL_FALLBACK(rmesa->radeon.glCtx, R200_TCL_FALLBACK_TCL_DISABLE, 1);
506
453
   }
507
454
 
 
455
   _mesa_compute_version(ctx);
 
456
   if (ctx->VersionMajor < major_version
 
457
       || (ctx->VersionMajor == major_version
 
458
           && ctx->VersionMinor < minor_version)) {
 
459
      r200DestroyContext(driContextPriv);
 
460
      *error = __DRI_CTX_ERROR_BAD_VERSION;
 
461
      return GL_FALSE;
 
462
   }
 
463
 
 
464
   *error = __DRI_CTX_ERROR_SUCCESS;
508
465
   return GL_TRUE;
509
466
}
510
467