ReactOS  0.4.12-dev-90-g2e2e63e
extensions.c File Reference

Extension handling. More...

#include <precomp.h>
Include dependency graph for extensions.c:

Go to the source code of this file.

Classes

struct  extension
 An element of the extension_table. More...
 

Macros

#define ALIGN(value, alignment)   (((value) + alignment - 1) & ~(alignment - 1))
 
#define o(x)   offsetof(struct gl_extensions, x)
 

Typedefs

typedef unsigned short extension_index
 

Functions

static size_t name_to_offset (const char *name)
 
void _mesa_enable_sw_extensions (struct gl_context *ctx)
 
void _mesa_enable_1_3_extensions (struct gl_context *ctx)
 
void _mesa_enable_1_4_extensions (struct gl_context *ctx)
 
void _mesa_enable_1_5_extensions (struct gl_context *ctx)
 
void _mesa_enable_2_0_extensions (struct gl_context *ctx)
 
void _mesa_enable_2_1_extensions (struct gl_context *ctx)
 
static GLboolean set_extension (struct gl_context *ctx, const char *name, GLboolean state)
 
void _mesa_enable_extension (struct gl_context *ctx, const char *name)
 
void _mesa_disable_extension (struct gl_context *ctx, const char *name)
 
GLboolean _mesa_extension_is_enabled (struct gl_context *ctx, const char *name)
 
static charget_extension_override (struct gl_context *ctx)
 Apply the MESA_EXTENSION_OVERRIDE environment variable. More...
 
void _mesa_init_extensions (struct gl_context *ctx)
 Initialize extension tables and enable default extensions. More...
 
static int extension_compare (const void *p1, const void *p2)
 
GLubyte_mesa_make_extension_string (struct gl_context *ctx)
 
GLuint _mesa_get_extension_count (struct gl_context *ctx)
 
const GLubyte_mesa_get_enabled_extension (struct gl_context *ctx, GLuint index)
 

Variables

static const struct extension extension_table []
 Table of supported OpenGL extensions for all API's. More...
 
static const size_t default_extensions []
 Extensions enabled by default. More...
 

Detailed Description

Extension handling.

Definition in file extensions.c.

Macro Definition Documentation

◆ ALIGN

#define ALIGN (   value,
  alignment 
)    (((value) + alignment - 1) & ~(alignment - 1))

Definition at line 34 of file extensions.c.

Referenced by _mesa_make_extension_string(), and get_extension_override().

◆ o

#define o (   x)    offsetof(struct gl_extensions, x)

Given a member x of struct gl_extensions, return offset of x in bytes.

Definition at line 56 of file extensions.c.

Referenced by __rpc_broadenable(), _Function_class_(), _mesa_init_extensions(), _tiffReadProc(), _tiffWriteProc(), anonymous_namespace{mstscax.cpp}::CoClass::CauuidToString(), Conic_To(), anonymous_namespace{mstscax.cpp}::CoClass::ControlInfoToString(), Convert_Glyph(), Cubic_To(), DecodeURLString(), XMLStorage::DecodeXMLString(), DecomposeVowels(), do_pseudo_reloc(), XMLStorage::EncodeXMLString(), anonymous_namespace{mstscax.cpp}::CoClass::ExcepInfoToString(), Ext2FlushVcb(), Fat8dot3ToString(), anonymous_namespace{mstscax.cpp}::CoClass::FormatEtcToString(), FT_Get_CID_Registry_Ordering_Supplement(), FT_Outline_GetInsideBorder(), FT_Outline_GetOutsideBorder(), FT_Outline_Transform(), gxv_kern_subtable_fmt1_subtable_setup(), gxv_mort_subtable_type1_subtable_setup(), gxv_mort_subtable_type2_subtable_setup(), gxv_morx_subtable_type1_subtable_setup(), gxv_morx_subtable_type2_subtable_setup(), gxv_morx_subtable_type5_subtable_setup(), gxv_StateTable_subtable_setup(), gxv_XStateTable_subtable_setup(), lf2crlf(), make_file_orphan(), anonymous_namespace{mstscax.cpp}::CoClass::MediumToString(), anonymous_namespace{mstscax.cpp}::CoClass::MnemonicToString(), rdp_out_unistr(), anonymous_namespace{mstscax.cpp}::RectToString(), resolveNeutrals(), RSAENH_CPDecrypt(), RSAENH_CPEncrypt(), scrub_raid5_stripe(), scrub_raid6_stripe(), send_inode(), set_extension(), anonymous_namespace{mstscax.cpp}::SizeToString(), SlistTest::slist1(), StrongCheck(), anonymous_namespace{mstscax.cpp}::CoClass::TargetDeviceToString(), SstreamTest::tellp(), FstreamTest::tellp(), test_iocp_fileio(), TIFFFetchNormalTag(), TIFFReadDirectoryCheckOrder(), TIFFWriteDirectorySec(), TIFFWriteDirectoryTagByteArray(), TIFFWriteDirectoryTagCheckedRationalArray(), TIFFWriteDirectoryTagCheckedSrationalArray(), TIFFWriteDirectoryTagColormap(), TIFFWriteDirectoryTagData(), TIFFWriteDirectoryTagDoubleArray(), TIFFWriteDirectoryTagFloatArray(), TIFFWriteDirectoryTagIfdIfd8Array(), TIFFWriteDirectoryTagLongArray(), TIFFWriteDirectoryTagLongLong8Array(), TIFFWriteDirectoryTagSbyteArray(), TIFFWriteDirectoryTagShortPerSample(), TIFFWriteDirectoryTagSlongArray(), TIFFWriteDirectoryTagSshortArray(), TIFFWriteDirectoryTagSubifd(), TIFFWriteDirectoryTagTransferfunction(), anonymous_namespace{mstscax.cpp}::VariantToString(), and vector_at().

Typedef Documentation

◆ extension_index

typedef unsigned short extension_index

Definition at line 461 of file extensions.c.

Function Documentation

◆ _mesa_disable_extension()

void _mesa_disable_extension ( struct gl_context ctx,
const char name 
)

Disable the named extension. XXX is this really needed???

Definition at line 342 of file extensions.c.

343 {
344  if (!set_extension(ctx, name, GL_FALSE))
345  _mesa_problem(ctx, "Trying to disable unknown extension: %s", name);
346 }
#define GL_FALSE
Definition: gl.h:173
static GLboolean set_extension(struct gl_context *ctx, const char *name, GLboolean state)
Definition: extensions.c:298
void _mesa_problem(const struct gl_context *ctx, const char *fmtString,...)
Definition: imports.c:798
Definition: name.c:36

◆ _mesa_enable_1_3_extensions()

void _mesa_enable_1_3_extensions ( struct gl_context ctx)

Enable all OpenGL 1.3 features and extensions. A convenience function to be called by drivers.

Definition at line 232 of file extensions.c.

233 {
234  ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
235  ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
236  ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
237  /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/
238 }
struct gl_extensions Extensions
Definition: mtypes.h:1798
#define GL_TRUE
Definition: gl.h:174

◆ _mesa_enable_1_4_extensions()

void _mesa_enable_1_4_extensions ( struct gl_context ctx)

Enable all OpenGL 1.4 features and extensions. A convenience function to be called by drivers.

Definition at line 247 of file extensions.c.

248 {
249  ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
250  ctx->Extensions.ARB_window_pos = GL_TRUE;
251  ctx->Extensions.EXT_blend_color = GL_TRUE;
252  ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
253  ctx->Extensions.EXT_blend_minmax = GL_TRUE;
254  ctx->Extensions.EXT_fog_coord = GL_TRUE;
255  ctx->Extensions.EXT_point_parameters = GL_TRUE;
256  ctx->Extensions.EXT_secondary_color = GL_TRUE;
257 }
struct gl_extensions Extensions
Definition: mtypes.h:1798
#define GL_TRUE
Definition: gl.h:174

◆ _mesa_enable_1_5_extensions()

void _mesa_enable_1_5_extensions ( struct gl_context ctx)

Enable all OpenGL 1.5 features and extensions. A convenience function to be called by drivers.

Definition at line 265 of file extensions.c.

266 {
267  ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
268 }
struct gl_extensions Extensions
Definition: mtypes.h:1798
#define GL_TRUE
Definition: gl.h:174

◆ _mesa_enable_2_0_extensions()

void _mesa_enable_2_0_extensions ( struct gl_context ctx)

Enable all OpenGL 2.0 features and extensions. A convenience function to be called by drivers.

Definition at line 276 of file extensions.c.

277 {
278  ctx->Extensions.ARB_point_sprite = GL_TRUE;
279  ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
280 }
struct gl_extensions Extensions
Definition: mtypes.h:1798
#define GL_TRUE
Definition: gl.h:174

◆ _mesa_enable_2_1_extensions()

void _mesa_enable_2_1_extensions ( struct gl_context ctx)

Enable all OpenGL 2.1 features and extensions. A convenience function to be called by drivers.

Definition at line 288 of file extensions.c.

289 {
290 }

◆ _mesa_enable_extension()

void _mesa_enable_extension ( struct gl_context ctx,
const char name 
)

Enable the named extension. Typically called by drivers.

Definition at line 330 of file extensions.c.

331 {
332  if (!set_extension(ctx, name, GL_TRUE))
333  _mesa_problem(ctx, "Trying to enable unknown extension: %s", name);
334 }
static GLboolean set_extension(struct gl_context *ctx, const char *name, GLboolean state)
Definition: extensions.c:298
void _mesa_problem(const struct gl_context *ctx, const char *fmtString,...)
Definition: imports.c:798
#define GL_TRUE
Definition: gl.h:174
Definition: name.c:36

◆ _mesa_enable_sw_extensions()

void _mesa_enable_sw_extensions ( struct gl_context ctx)

Enable all extensions suitable for a software-only renderer. This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc.

Definition at line 193 of file extensions.c.

194 {
195  ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
196  ctx->Extensions.ARB_point_sprite = GL_TRUE;
197  ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
198  ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
199  ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
200  ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
201  /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/
202  ctx->Extensions.ARB_texture_storage = GL_TRUE;
203  ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE;
204  ctx->Extensions.EXT_blend_color = GL_TRUE;
205  ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
206  ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
207  ctx->Extensions.EXT_blend_minmax = GL_TRUE;
208  ctx->Extensions.EXT_depth_bounds_test = GL_TRUE;
209  ctx->Extensions.EXT_fog_coord = GL_TRUE;
210  ctx->Extensions.EXT_point_parameters = GL_TRUE;
211  ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
212  ctx->Extensions.EXT_secondary_color = GL_TRUE;
213  ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
214  ctx->Extensions.EXT_texture_filter_anisotropic = GL_TRUE;
215  /*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/
216  ctx->Extensions.MESA_pack_invert = GL_TRUE;
217  ctx->Extensions.MESA_resize_buffers = GL_TRUE;
218  ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
219  ctx->Extensions.NV_blend_square = GL_TRUE;
220  /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/
221  ctx->Extensions.NV_point_sprite = GL_TRUE;
222  ctx->Extensions.NV_texture_env_combine4 = GL_TRUE;
223  /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/
224 }
struct gl_extensions Extensions
Definition: mtypes.h:1798
#define GL_TRUE
Definition: gl.h:174

◆ _mesa_extension_is_enabled()

GLboolean _mesa_extension_is_enabled ( struct gl_context ctx,
const char name 
)

Test if the named extension is enabled in this context.

Definition at line 353 of file extensions.c.

354 {
355  size_t offset;
356  GLboolean *base;
357 
358  if (name == 0)
359  return GL_FALSE;
360 
361  offset = name_to_offset(name);
362  if (offset == 0)
363  return GL_FALSE;
364  base = (GLboolean *) &ctx->Extensions;
365  return base[offset];
366 }
#define GL_FALSE
Definition: gl.h:173
GLintptr offset
Definition: glext.h:5920
struct gl_extensions Extensions
Definition: mtypes.h:1798
GLuint base
Definition: 3dtext.c:35
unsigned char GLboolean
Definition: gl.h:151
Definition: name.c:36
static size_t name_to_offset(const char *name)
Definition: extensions.c:144

◆ _mesa_get_enabled_extension()

const GLubyte* _mesa_get_enabled_extension ( struct gl_context ctx,
GLuint  index 
)

Return name of i-th enabled extension

Definition at line 603 of file extensions.c.

604 {
605  const GLboolean *base;
606  size_t n;
607  const struct extension *i;
608 
609  if (index < 0)
610  return NULL;
611 
612  base = (GLboolean*) &ctx->Extensions;
613  n = 0;
614  for (i = extension_table; i->name != 0; ++i) {
615  if (n == index && base[i->offset]) {
616  return (GLubyte*) i->name;
617  } else if (base[i->offset]) {
618  ++n;
619  }
620  }
621 
622  return NULL;
623 }
struct gl_extensions Extensions
Definition: mtypes.h:1798
GLuint n
Definition: s_context.h:57
GLenum GLclampf GLint i
Definition: glfuncs.h:14
GLuint base
Definition: 3dtext.c:35
unsigned char GLboolean
Definition: gl.h:151
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
An element of the extension_table.
Definition: extensions.c:39
#define for
Definition: utility.h:88
static const struct extension extension_table[]
Table of supported OpenGL extensions for all API&#39;s.
Definition: extensions.c:62
size_t offset
Definition: extensions.c:44
unsigned char GLubyte
Definition: gl.h:157
const char * name
Definition: extensions.c:41

◆ _mesa_get_extension_count()

GLuint _mesa_get_extension_count ( struct gl_context ctx)

Return number of enabled extensions.

Definition at line 581 of file extensions.c.

Referenced by find_custom_value().

582 {
583  GLboolean *base;
584  const struct extension *i;
585 
586  /* only count once */
587  if (ctx->Extensions.Count != 0)
588  return ctx->Extensions.Count;
589 
590  base = (GLboolean *) &ctx->Extensions;
591  for (i = extension_table; i->name != 0; ++i) {
592  if (base[i->offset]) {
593  ctx->Extensions.Count++;
594  }
595  }
596  return ctx->Extensions.Count;
597 }
struct gl_extensions Extensions
Definition: mtypes.h:1798
GLenum GLclampf GLint i
Definition: glfuncs.h:14
GLuint base
Definition: 3dtext.c:35
unsigned char GLboolean
Definition: gl.h:151
An element of the extension_table.
Definition: extensions.c:39
#define for
Definition: utility.h:88
static const struct extension extension_table[]
Table of supported OpenGL extensions for all API&#39;s.
Definition: extensions.c:62
size_t offset
Definition: extensions.c:44
const char * name
Definition: extensions.c:41

◆ _mesa_init_extensions()

void _mesa_init_extensions ( struct gl_context ctx)

Initialize extension tables and enable default extensions.

This should be called during context initialization. Note: Sets gl_extensions.dummy_true to true.

Definition at line 443 of file extensions.c.

Referenced by init_attrib_groups().

444 {
445  GLboolean *base = (GLboolean *) &ctx->Extensions;
446  GLboolean *sentinel = base + o(extension_sentinel);
447  GLboolean *i;
448  const size_t *j;
449 
450  /* First, turn all extensions off. */
451  for (i = base; i != sentinel; ++i)
452  *i = GL_FALSE;
453 
454  /* Then, selectively turn default extensions on. */
455  ctx->Extensions.dummy_true = GL_TRUE;
456  for (j = default_extensions; *j != 0; ++j)
457  base[*j] = GL_TRUE;
458 }
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
#define GL_FALSE
Definition: gl.h:173
#define o(x)
Definition: extensions.c:56
struct gl_extensions Extensions
Definition: mtypes.h:1798
GLenum GLclampf GLint i
Definition: glfuncs.h:14
unsigned char GLboolean
Definition: gl.h:151
#define GL_TRUE
Definition: gl.h:174
static const size_t default_extensions[]
Extensions enabled by default.
Definition: extensions.c:167

◆ _mesa_make_extension_string()

GLubyte* _mesa_make_extension_string ( struct gl_context ctx)

Construct the GL_EXTENSIONS string. Called the first time that glGetString(GL_EXTENSIONS) is called.

Definition at line 494 of file extensions.c.

Referenced by _mesa_make_current().

495 {
496  /* The extension string. */
497  char *exts = 0;
498  /* Length of extension string. */
499  size_t length = 0;
500  /* Number of extensions */
501  unsigned count;
502  /* Indices of the extensions sorted by year */
503  extension_index *extension_indices;
504  /* String of extra extensions. */
505  char *extra_extensions = get_extension_override(ctx);
506  GLboolean *base = (GLboolean *) &ctx->Extensions;
507  const struct extension *i;
508  unsigned j;
509  unsigned maxYear = ~0;
510 
511  /* Check if the MESA_EXTENSION_MAX_YEAR env var is set */
512  {
513  const char *env = getenv("MESA_EXTENSION_MAX_YEAR");
514  if (env) {
515  maxYear = atoi(env);
516  _mesa_debug(ctx, "Note: limiting GL extensions to %u or earlier\n",
517  maxYear);
518  }
519  }
520 
521  /* Compute length of the extension string. */
522  count = 0;
523  for (i = extension_table; i->name != 0; ++i) {
524  if (base[i->offset] &&
525  i->year <= maxYear) {
526  length += strlen(i->name) + 1; /* +1 for space */
527  ++count;
528  }
529  }
530  if (extra_extensions != NULL)
531  length += 1 + strlen(extra_extensions); /* +1 for space */
532 
533  exts = (char *) calloc(ALIGN(length + 1, 4), sizeof(char));
534  if (exts == NULL) {
535  free(extra_extensions);
536  return NULL;
537  }
538 
539  extension_indices = malloc(count * sizeof(extension_index));
540  if (extension_indices == NULL) {
541  free(exts);
542  free(extra_extensions);
543  return NULL;
544  }
545 
546  /* Sort extensions in chronological order because certain old applications (e.g.,
547  * Quake3 demo) store the extension list in a static size buffer so chronologically
548  * order ensure that the extensions that such applications expect will fit into
549  * that buffer.
550  */
551  j = 0;
552  for (i = extension_table; i->name != 0; ++i) {
553  if (base[i->offset] &&
554  i->year <= maxYear) {
555  extension_indices[j++] = i - extension_table;
556  }
557  }
558  assert(j == count);
559  qsort(extension_indices, count, sizeof *extension_indices, extension_compare);
560 
561  /* Build the extension string.*/
562  for (j = 0; j < count; ++j) {
563  i = &extension_table[extension_indices[j]];
564  assert(base[i->offset]);
565  strcat(exts, i->name);
566  strcat(exts, " ");
567  }
568  free(extension_indices);
569  if (extra_extensions != 0) {
570  strcat(exts, extra_extensions);
571  free(extra_extensions);
572  }
573 
574  return (GLubyte *) exts;
575 }
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define free
Definition: debug_ros.c:5
#define assert(x)
Definition: debug.h:53
void _mesa_debug(const struct gl_context *ctx, const char *fmtString,...)
Definition: imports.c:889
struct gl_extensions Extensions
Definition: mtypes.h:1798
static char * get_extension_override(struct gl_context *ctx)
Apply the MESA_EXTENSION_OVERRIDE environment variable.
Definition: extensions.c:383
GLenum GLclampf GLint i
Definition: glfuncs.h:14
unsigned char GLboolean
Definition: gl.h:151
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
smooth NULL
Definition: ftsmooth.c:416
unsigned char
Definition: typeof.h:27
An element of the extension_table.
Definition: extensions.c:39
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
static const struct extension extension_table[]
Table of supported OpenGL extensions for all API&#39;s.
Definition: extensions.c:62
unsigned short extension_index
Definition: extensions.c:461
static const struct encodedExtensions exts[]
Definition: encode.c:2703
unsigned char GLubyte
Definition: gl.h:157
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
#define ALIGN(value, alignment)
Definition: extensions.c:34
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:158
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define calloc
Definition: rosglue.h:14
#define malloc
Definition: debug_ros.c:4
static int extension_compare(const void *p1, const void *p2)
Definition: extensions.c:471

◆ extension_compare()

static int extension_compare ( const void p1,
const void p2 
)
static

Compare two entries of the extensions table. Sorts first by year, then by name.

Arguments are indices into extension_table.

Definition at line 471 of file extensions.c.

Referenced by _mesa_make_extension_string().

472 {
473  extension_index i1 = * (const extension_index *) p1;
474  extension_index i2 = * (const extension_index *) p2;
475  const struct extension *e1 = &extension_table[i1];
476  const struct extension *e2 = &extension_table[i2];
477  int res;
478 
479  res = (int)e1->year - (int)e2->year;
480 
481  if (res == 0) {
482  res = strcmp(e1->name, e2->name);
483  }
484 
485  return res;
486 }
uint16_t year
Definition: extensions.c:48
An element of the extension_table.
Definition: extensions.c:39
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint i2
Definition: glfuncs.h:96
static const struct extension extension_table[]
Table of supported OpenGL extensions for all API&#39;s.
Definition: extensions.c:62
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint i1
Definition: glfuncs.h:96
unsigned short extension_index
Definition: extensions.c:461
GLuint res
Definition: glext.h:9613
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
const char * name
Definition: extensions.c:41
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29

◆ get_extension_override()

static char* get_extension_override ( struct gl_context ctx)
static

Apply the MESA_EXTENSION_OVERRIDE environment variable.

MESA_EXTENSION_OVERRIDE is a space-separated list of extensions to enable or disable. The list is processed thus:

  • Enable recognized extension names that are prefixed with '+'.
  • Disable recognized extension names that are prefixed with '-'.
  • Enable recognized extension names that are not prefixed.
  • Collect unrecognized extension names in a new string.
Returns
Space-separated list of unrecognized extension names (which must be freed). Does not return NULL.

Definition at line 383 of file extensions.c.

Referenced by _mesa_make_extension_string().

384 {
385  const char *env_const = _mesa_getenv("MESA_EXTENSION_OVERRIDE");
386  char *env;
387  char *ext;
388  char *extra_exts;
389  int len;
390 
391  if (env_const == NULL) {
392  /* Return the empty string rather than NULL. This simplifies the logic
393  * of client functions. */
394  return calloc(4, sizeof(char));
395  }
396 
397  /* extra_exts: List of unrecognized extensions. */
398  extra_exts = calloc(ALIGN(strlen(env_const) + 2, 4), sizeof(char));
399 
400  /* Copy env_const because strtok() is destructive. */
401  env = _strdup(env_const);
402  for (ext = strtok(env, " "); ext != NULL; ext = strtok(NULL, " ")) {
403  int enable;
404  int recognized;
405  switch (ext[0]) {
406  case '+':
407  enable = 1;
408  ++ext;
409  break;
410  case '-':
411  enable = 0;
412  ++ext;
413  break;
414  default:
415  enable = 1;
416  break;
417  }
418  recognized = set_extension(ctx, ext, enable);
419  if (!recognized) {
420  strcat(extra_exts, ext);
421  strcat(extra_exts, " ");
422  }
423  }
424 
425  free(env);
426 
427  /* Remove trailing space. */
428  len = strlen(extra_exts);
429  if (extra_exts[len - 1] == ' ')
430  extra_exts[len - 1] = '\0';
431 
432  return extra_exts;
433 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define free
Definition: debug_ros.c:5
#define _strdup
Definition: debug_ros.c:7
static GLboolean set_extension(struct gl_context *ctx, const char *name, GLboolean state)
Definition: extensions.c:298
char * _mesa_getenv(const char *var)
Definition: imports.c:585
smooth NULL
Definition: ftsmooth.c:416
char ext[3]
Definition: mkdosfs.c:358
GLenum GLsizei len
Definition: glext.h:6722
GLboolean enable
Definition: glext.h:11120
#define ALIGN(value, alignment)
Definition: extensions.c:34
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:158
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338
#define calloc
Definition: rosglue.h:14

◆ name_to_offset()

static size_t name_to_offset ( const char name)
static

Given an extension name, lookup up the corresponding member of struct gl_extensions and return that member's offset (in bytes). If the name is not found in the extension_table, return 0.

Parameters
nameName of extension.
Returns
Offset of member in struct gl_extensions.

Definition at line 144 of file extensions.c.

Referenced by _mesa_extension_is_enabled(), and set_extension().

145 {
146  const struct extension *i;
147 
148  if (name == 0)
149  return 0;
150 
151  for (i = extension_table; i->name != 0; ++i) {
152  if (strcmp(name, i->name) == 0)
153  return i->offset;
154  }
155 
156  return 0;
157 }
GLenum GLclampf GLint i
Definition: glfuncs.h:14
An element of the extension_table.
Definition: extensions.c:39
static const struct extension extension_table[]
Table of supported OpenGL extensions for all API&#39;s.
Definition: extensions.c:62
size_t offset
Definition: extensions.c:44
Definition: name.c:36
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
const char * name
Definition: extensions.c:41

◆ set_extension()

static GLboolean set_extension ( struct gl_context ctx,
const char name,
GLboolean  state 
)
static

Either enable or disable the named extension.

Returns
GL_TRUE for success, GL_FALSE if invalid extension name

Definition at line 298 of file extensions.c.

Referenced by _mesa_disable_extension(), _mesa_enable_extension(), and get_extension_override().

299 {
300  size_t offset;
301 
302  if (ctx->Extensions.String) {
303  /* The string was already queried - can't change it now! */
304  _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name);
305  return GL_FALSE;
306  }
307 
308  offset = name_to_offset(name);
309  if (offset == 0) {
310  _mesa_problem(ctx, "Trying to enable/disable unknown extension %s",
311  name);
312  return GL_FALSE;
313  } else if (offset == o(dummy_true) && state == GL_FALSE) {
314  _mesa_problem(ctx, "Trying to disable a permanently enabled extension: "
315  "%s", name);
316  return GL_FALSE;
317  } else {
318  GLboolean *base = (GLboolean *) &ctx->Extensions;
319  base[offset] = state;
320  return GL_TRUE;
321  }
322 }
#define GL_FALSE
Definition: gl.h:173
GLintptr offset
Definition: glext.h:5920
#define o(x)
Definition: extensions.c:56
struct gl_extensions Extensions
Definition: mtypes.h:1798
unsigned char GLboolean
Definition: gl.h:151
void _mesa_problem(const struct gl_context *ctx, const char *fmtString,...)
Definition: imports.c:798
static int state
Definition: maze.c:121
#define GL_TRUE
Definition: gl.h:174
Definition: name.c:36
static size_t name_to_offset(const char *name)
Definition: extensions.c:144

Variable Documentation

◆ default_extensions

const size_t default_extensions[]
static
Initial value:
= {
o(ARB_transpose_matrix),
o(ARB_window_pos),
o(EXT_compiled_vertex_array),
o(EXT_draw_range_elements),
o(EXT_packed_pixels),
o(EXT_rescale_normal),
o(EXT_separate_specular_color),
o(APPLE_packed_pixels),
o(IBM_multimode_draw_arrays),
o(IBM_rasterpos_clip),
o(NV_light_max_exponent),
o(NV_texgen_reflection),
0,
}
#define o(x)
Definition: extensions.c:56

Extensions enabled by default.

These extensions are enabled by _mesa_init_extensions().

XXX: Should these defaults also apply to GLES?

Definition at line 167 of file extensions.c.

Referenced by _mesa_init_extensions().

◆ extension_table

const struct extension extension_table[]
static

Table of supported OpenGL extensions for all API's.

Definition at line 62 of file extensions.c.

Referenced by _mesa_make_extension_string().