#include "glheader.h"
#include "mfeatures.h"
#include "imports.h"
#include "accum.h"
#include "api_exec.h"
#include "arrayobj.h"
#include "attrib.h"
#include "blend.h"
#include "buffers.h"
#include "bufferobj.h"
#include "colortab.h"
#include "context.h"
#include "cpuinfo.h"
#include "debug.h"
#include "depth.h"
#include "dlist.h"
#include "eval.h"
#include "enums.h"
#include "extensions.h"
#include "fbobject.h"
#include "feedback.h"
#include "fog.h"
#include "framebuffer.h"
#include "get.h"
#include "histogram.h"
#include "hint.h"
#include "hash.h"
#include "light.h"
#include "lines.h"
#include "macros.h"
#include "matrix.h"
#include "multisample.h"
#include "pixel.h"
#include "pixelstore.h"
#include "points.h"
#include "polygon.h"
#include "queryobj.h"
#include "syncobj.h"
#include "rastpos.h"
#include "scissor.h"
#include "shared.h"
#include "simple_list.h"
#include "state.h"
#include "stencil.h"
#include "texcompress.h"
#include "teximage.h"
#include "texobj.h"
#include "texstate.h"
#include "mtypes.h"
#include "varray.h"
#include "version.h"
#include "viewport.h"
#include "vtxfmt.h"
#include "glapi/glthread.h"
#include "glapi/glapioffsets.h"
#include "glapi/glapitable.h"
#include "shader/program.h"
#include "shader/prog_print.h"
#include "shader/shader_api.h"
#include "shader/atifragshader.h"
#include "math/m_matrix.h"
Functions | |
void | _mesa_notifySwapBuffers (__GLcontext *ctx) |
Swap buffers notification callback. | |
GL Visual allocation/destruction | |
GLvisual * | _mesa_create_visual (GLboolean rgbFlag, GLboolean dbFlag, GLboolean stereoFlag, GLint redBits, GLint greenBits, GLint blueBits, GLint alphaBits, GLint indexBits, GLint depthBits, GLint stencilBits, GLint accumRedBits, GLint accumGreenBits, GLint accumBlueBits, GLint accumAlphaBits, GLint numSamples) |
Allocates a GLvisual structure and initializes it via _mesa_initialize_visual(). | |
GLboolean | _mesa_initialize_visual (GLvisual *vis, GLboolean rgbFlag, GLboolean dbFlag, GLboolean stereoFlag, GLint redBits, GLint greenBits, GLint blueBits, GLint alphaBits, GLint indexBits, GLint depthBits, GLint stencilBits, GLint accumRedBits, GLint accumGreenBits, GLint accumBlueBits, GLint accumAlphaBits, GLint numSamples) |
Makes some sanity checks and fills in the fields of the GLvisual object with the given parameters. | |
void | _mesa_destroy_visual (GLvisual *vis) |
Destroy a visual and free its memory. | |
Context allocation, initialization, destroying | |
The purpose of the most initialization functions here is to provide the default state values according to the OpenGL specification. | |
static void | dummy_enum_func (void) |
This is lame. | |
_glthread_DECLARE_STATIC_MUTEX (OneTimeLock) | |
One-time initialization mutex lock. | |
static void | one_time_init (GLcontext *ctx) |
Calls all the various one-time-init functions in Mesa. | |
static void | _mesa_init_current (GLcontext *ctx) |
Initialize fields of gl_current_attrib (aka ctx->Current. | |
static void | init_program_limits (GLenum type, struct gl_program_constants *prog) |
Init vertex/fragment program limits. | |
static void | _mesa_init_constants (GLcontext *ctx) |
Initialize fields of gl_constants (aka ctx->Const. | |
static void | check_context_limits (GLcontext *ctx) |
Do some sanity checks on the limits/constants for the given context. | |
static GLboolean | init_attrib_groups (GLcontext *ctx) |
Initialize the attribute groups in a GL context. | |
static GLboolean | update_default_objects (GLcontext *ctx) |
Update default objects in a GL context with respect to shared state. | |
static int | generic_nop (void) |
This is the default function we plug into all dispatch table slots This helps prevents a segfault when someone calls a GL function without first checking if the extension's supported. | |
static struct _glapi_table * | alloc_dispatch_table (void) |
Allocate and initialize a new dispatch table. | |
GLboolean | _mesa_initialize_context (GLcontext *ctx, const GLvisual *visual, GLcontext *share_list, const struct dd_function_table *driverFunctions, void *driverContext) |
Initialize a GLcontext struct (rendering context). | |
GLcontext * | _mesa_create_context (const GLvisual *visual, GLcontext *share_list, const struct dd_function_table *driverFunctions, void *driverContext) |
Allocate and initialize a GLcontext structure. | |
void | _mesa_free_context_data (GLcontext *ctx) |
Free the data associated with the given context. | |
void | _mesa_destroy_context (GLcontext *ctx) |
Destroy a GLcontext structure. | |
void | _mesa_copy_context (const GLcontext *src, GLcontext *dst, GLuint mask) |
Copy attribute groups from one context to another. | |
static GLboolean | check_compatible (const GLcontext *ctx, const GLframebuffer *buffer) |
Check if the given context can render into the given framebuffer by checking visual attributes. | |
static void | initialize_framebuffer_size (GLcontext *ctx, GLframebuffer *fb) |
Do one-time initialization for the given framebuffer. | |
void | _mesa_check_init_viewport (GLcontext *ctx, GLuint width, GLuint height) |
Check if the viewport/scissor size has not yet been initialized. | |
GLboolean | _mesa_make_current (GLcontext *newCtx, GLframebuffer *drawBuffer, GLframebuffer *readBuffer) |
Bind the given context to the given drawBuffer and readBuffer and make it the current context for the calling thread. | |
GLboolean | _mesa_share_state (GLcontext *ctx, GLcontext *ctxToShare) |
Make context 'ctx' share the display lists, textures and programs that are associated with 'ctxToShare'. | |
GLcontext * | _mesa_get_current_context (void) |
| |
struct _glapi_table * | _mesa_get_dispatch (GLcontext *ctx) |
Get context's current API dispatch table. | |
Miscellaneous functions | |
void | _mesa_record_error (GLcontext *ctx, GLenum error) |
Record an error. | |
void GLAPIENTRY | _mesa_Finish (void) |
Execute glFinish(). | |
void GLAPIENTRY | _mesa_Flush (void) |
Execute glFlush(). | |
void | _mesa_set_mvp_with_dp4 (GLcontext *ctx, GLboolean flag) |
Set mvp_with_dp4 flag. | |
GLboolean | _mesa_valid_to_render (GLcontext *ctx, const char *where) |
Prior to drawing anything with glBegin, glDrawArrays, etc. | |
Variables | |
GLfloat | _mesa_ubyte_to_float_color_tab [256] |
Convert GLubyte in [0,255] to GLfloat in [0.0,1.0]. |
_glthread_DECLARE_STATIC_MUTEX | ( | OneTimeLock | ) |
void _mesa_check_init_viewport | ( | GLcontext * | ctx, | |
GLuint | width, | |||
GLuint | height | |||
) |
Check if the viewport/scissor size has not yet been initialized.
Initialize the size if the given width and height are non-zero.
Copy attribute groups from one context to another.
src | source context | |
dst | destination context | |
mask | bitwise OR of GL_*_BIT flags |
mask
, copies the corresponding attributes from src
into dst
. For many of the attributes a simple memcpy
is not enough due to the existence of internal pointers in their data structures.
GLcontext* _mesa_create_context | ( | const GLvisual * | visual, | |
GLcontext * | share_list, | |||
const struct dd_function_table * | driverFunctions, | |||
void * | driverContext | |||
) |
Allocate and initialize a GLcontext structure.
Note that the driver needs to pass in its dd_function_table here since we need to at least call driverFunctions->NewTextureObject to initialize the rendering context.
visual | a GLvisual pointer (we copy the struct contents) | |
share_list | another context to share display lists with or NULL | |
driverFunctions | points to the dd_function_table into which the driver has plugged in all its special functions. | |
driverContext | points to the device driver's private context state |
GLvisual* _mesa_create_visual | ( | GLboolean | rgbFlag, | |
GLboolean | dbFlag, | |||
GLboolean | stereoFlag, | |||
GLint | redBits, | |||
GLint | greenBits, | |||
GLint | blueBits, | |||
GLint | alphaBits, | |||
GLint | indexBits, | |||
GLint | depthBits, | |||
GLint | stencilBits, | |||
GLint | accumRedBits, | |||
GLint | accumGreenBits, | |||
GLint | accumBlueBits, | |||
GLint | accumAlphaBits, | |||
GLint | numSamples | |||
) |
Allocates a GLvisual structure and initializes it via _mesa_initialize_visual().
rgbFlag | GL_TRUE for RGB(A) mode, GL_FALSE for Color Index mode. | |
dbFlag | double buffering | |
stereoFlag | stereo buffer | |
depthBits | requested bits per depth buffer value. Any value in [0, 32] is acceptable but the actual depth type will be GLushort or GLuint as needed. | |
stencilBits | requested minimum bits per stencil buffer value | |
accumRedBits,accumGreenBits,accumBlueBits,accumAlphaBits | number of bits per color component in accum buffer. | |
indexBits | number of bits per pixel if rgbFlag is GL_FALSE | |
redBits | number of bits per color component in frame buffer for RGB(A) mode. We always use 8 in core Mesa though. | |
greenBits | same as above. | |
blueBits | same as above. | |
alphaBits | same as above. | |
numSamples | not really used. |
void _mesa_destroy_context | ( | GLcontext * | ctx | ) |
Destroy a GLcontext structure.
ctx | GL context. |
void _mesa_destroy_visual | ( | GLvisual * | vis | ) |
Destroy a visual and free its memory.
vis | visual. |
void GLAPIENTRY _mesa_Finish | ( | void | ) |
Execute glFinish().
Calls the ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH macro and the dd_function_table::Finish driver callback, if not NULL.
void GLAPIENTRY _mesa_Flush | ( | void | ) |
Execute glFlush().
Calls the ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH macro and the dd_function_table::Flush driver callback, if not NULL.
void _mesa_free_context_data | ( | GLcontext * | ctx | ) |
Free the data associated with the given context.
But doesn't free the GLcontext struct itself.
GLcontext* _mesa_get_current_context | ( | void | ) |
Calls _glapi_get_context(). This isn't the fastest way to get the current context. If you need speed, see the GET_CURRENT_CONTEXT macro in context.h.
struct _glapi_table* _mesa_get_dispatch | ( | GLcontext * | ctx | ) | [read] |
Get context's current API dispatch table.
It'll either be the immediate-mode execute dispatcher or the display list compile dispatcher.
ctx | GL context. |
static void _mesa_init_constants | ( | GLcontext * | ctx | ) | [static] |
Initialize fields of gl_constants (aka ctx->Const.
*). Use defaults from config.h. The device drivers will often override some of these values (such as number of texture units).
static void _mesa_init_current | ( | GLcontext * | ctx | ) | [static] |
Initialize fields of gl_current_attrib (aka ctx->Current.
*)
GLboolean _mesa_initialize_context | ( | GLcontext * | ctx, | |
const GLvisual * | visual, | |||
GLcontext * | share_list, | |||
const struct dd_function_table * | driverFunctions, | |||
void * | driverContext | |||
) |
Initialize a GLcontext struct (rendering context).
This includes allocating all the other structs and arrays which hang off of the context by pointers. Note that the driver needs to pass in its dd_function_table here since we need to at least call driverFunctions->NewTextureObject to create the default texture objects.
Called by _mesa_create_context().
Performs the imports and exports callback tables initialization, and miscellaneous one-time initializations. If no shared context is supplied one is allocated, and increase its reference count. Setups the GL API dispatch tables. Initialize the TNL module. Sets the maximum Z buffer depth. Finally queries the MESA_DEBUG
and MESA_VERBOSE
environment variables for debug flags.
ctx | the context to initialize | |
visual | describes the visual attributes for this context | |
share_list | points to context to share textures, display lists, etc with, or NULL | |
driverFunctions | table of device driver functions for this context to use | |
driverContext | pointer to driver-specific context data |
GLboolean _mesa_initialize_visual | ( | GLvisual * | vis, | |
GLboolean | rgbFlag, | |||
GLboolean | dbFlag, | |||
GLboolean | stereoFlag, | |||
GLint | redBits, | |||
GLint | greenBits, | |||
GLint | blueBits, | |||
GLint | alphaBits, | |||
GLint | indexBits, | |||
GLint | depthBits, | |||
GLint | stencilBits, | |||
GLint | accumRedBits, | |||
GLint | accumGreenBits, | |||
GLint | accumBlueBits, | |||
GLint | accumAlphaBits, | |||
GLint | numSamples | |||
) |
Makes some sanity checks and fills in the fields of the GLvisual object with the given parameters.
If the caller needs to set additional fields, he should just probably init the whole GLvisual object himself.
GLboolean _mesa_make_current | ( | GLcontext * | newCtx, | |
GLframebuffer * | drawBuffer, | |||
GLframebuffer * | readBuffer | |||
) |
Bind the given context to the given drawBuffer and readBuffer and make it the current context for the calling thread.
We'll render into the drawBuffer and read pixels from the readBuffer (i.e. glRead/CopyPixels, glCopyTexImage, etc).
We check that the context's and framebuffer's visuals are compatible and return immediately if they're not.
newCtx | the new GL context. If NULL then there will be no current GL context. | |
drawBuffer | the drawing framebuffer | |
readBuffer | the reading framebuffer |
void _mesa_notifySwapBuffers | ( | __GLcontext * | ctx | ) |
Swap buffers notification callback.
ctx | GL context. |
void _mesa_record_error | ( | GLcontext * | ctx, | |
GLenum | error | |||
) |
Record an error.
ctx | GL context. | |
error | error code. |
void _mesa_set_mvp_with_dp4 | ( | GLcontext * | ctx, | |
GLboolean | flag | |||
) |
Set mvp_with_dp4 flag.
If a driver has a preference for DP4 over MUL/MAD, or vice versa, call this function to register that. Otherwise we default to MUL/MAD.
Make context 'ctx' share the display lists, textures and programs that are associated with 'ctxToShare'.
Any display lists, textures or programs associated with 'ctx' will be deleted if nobody else is sharing them.
GLboolean _mesa_valid_to_render | ( | GLcontext * | ctx, | |
const char * | where | |||
) |
Prior to drawing anything with glBegin, glDrawArrays, etc.
this function is called to see if it's valid to render. This involves checking that the current shader is valid and the framebuffer is complete. If an error is detected it'll be recorded here.
static struct _glapi_table* alloc_dispatch_table | ( | void | ) | [static, read] |
Allocate and initialize a new dispatch table.
static GLboolean check_compatible | ( | const GLcontext * | ctx, | |
const GLframebuffer * | buffer | |||
) | [static] |
Check if the given context can render into the given framebuffer by checking visual attributes.
Most of these tests could go away because Mesa is now pretty flexible in terms of mixing rendering contexts with framebuffers. As long as RGB vs. CI mode agree, we're probably good.
static void check_context_limits | ( | GLcontext * | ctx | ) | [static] |
Do some sanity checks on the limits/constants for the given context.
Only called the first time a context is bound.
static void dummy_enum_func | ( | void | ) | [static] |
This is lame.
gdb only seems to recognize enum types that are actually used somewhere. We want to be able to print/use enum values such as TEXTURE_2D_INDEX in gdb. But we don't actually use the gl_texture_index type anywhere. Thus, this lame function.
static int generic_nop | ( | void | ) | [static] |
This is the default function we plug into all dispatch table slots This helps prevents a segfault when someone calls a GL function without first checking if the extension's supported.
static GLboolean init_attrib_groups | ( | GLcontext * | ctx | ) | [static] |
Initialize the attribute groups in a GL context.
ctx | GL context. |
init*
functions for the more complex data structures.
static void init_program_limits | ( | GLenum | type, | |
struct gl_program_constants * | prog | |||
) | [static] |
Init vertex/fragment program limits.
Important: drivers should override these with actual limits.
static void initialize_framebuffer_size | ( | GLcontext * | ctx, | |
GLframebuffer * | fb | |||
) | [static] |
Do one-time initialization for the given framebuffer.
Specifically, ask the driver for the window's current size and update the framebuffer object to match. Really, the device driver should totally take care of this.
static void one_time_init | ( | GLcontext * | ctx | ) | [static] |
Calls all the various one-time-init functions in Mesa.
While holding a global mutex lock, calls several initialization functions, and sets the glapi callbacks if the MESA_DEBUG
environment variable is defined.
static GLboolean update_default_objects | ( | GLcontext * | ctx | ) | [static] |
Update default objects in a GL context with respect to shared state.
ctx | GL context. |
GLfloat _mesa_ubyte_to_float_color_tab[256] |
Convert GLubyte in [0,255] to GLfloat in [0.0,1.0].