summaryrefslogtreecommitdiff
path: root/src/mesa/main/context.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/context.c')
-rw-r--r--src/mesa/main/context.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index b60875b712..f42a566c30 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -219,7 +219,7 @@ _mesa_create_visual( GLboolean dbFlag,
GLint accumAlphaBits,
GLint numSamples )
{
- struct gl_config *vis = (struct gl_config *) calloc(1, sizeof(struct gl_config));
+ struct gl_config *vis = CALLOC_STRUCT(gl_config);
if (vis) {
if (!_mesa_initialize_visual(vis, dbFlag, stereoFlag,
redBits, greenBits, blueBits, alphaBits,
@@ -234,11 +234,13 @@ _mesa_create_visual( GLboolean dbFlag,
return vis;
}
+
/**
- * Makes some sanity checks and fills in the fields of the
- * struct gl_config object with the given parameters. If the caller needs
- * to set additional fields, he should just probably init the whole struct gl_config
- * object himself.
+ * Makes some sanity checks and fills in the fields of the struct
+ * gl_config object with the given parameters. If the caller needs to
+ * set additional fields, he should just probably init the whole
+ * gl_config object himself.
+ *
* \return GL_TRUE on success, or GL_FALSE on failure.
*
* \sa _mesa_create_visual() above for the parameter description.
@@ -368,6 +370,8 @@ dummy_enum_func(void)
*/
_glthread_DECLARE_STATIC_MUTEX(OneTimeLock);
+
+
/**
* Calls all the various one-time-init functions in Mesa.
*
@@ -408,8 +412,10 @@ one_time_init( struct gl_context *ctx )
}
#if defined(DEBUG) && defined(__DATE__) && defined(__TIME__)
- _mesa_debug(ctx, "Mesa %s DEBUG build %s %s\n",
- MESA_VERSION_STRING, __DATE__, __TIME__);
+ if (MESA_VERBOSE != 0) {
+ _mesa_debug(ctx, "Mesa %s DEBUG build %s %s\n",
+ MESA_VERSION_STRING, __DATE__, __TIME__);
+ }
#endif
}
@@ -529,6 +535,7 @@ _mesa_init_constants(struct gl_context *ctx)
assert(ctx);
/* Constants, may be overriden (usually only reduced) by device drivers */
+ ctx->Const.MaxTextureMbytes = MAX_TEXTURE_MBYTES;
ctx->Const.MaxTextureLevels = MAX_TEXTURE_LEVELS;
ctx->Const.Max3DTextureLevels = MAX_3D_TEXTURE_LEVELS;
ctx->Const.MaxCubeTextureLevels = MAX_CUBE_TEXTURE_LEVELS;
@@ -988,6 +995,10 @@ _mesa_initialize_context_for_api(struct gl_context *ctx,
return GL_TRUE;
}
+
+/**
+ * Initialize an OpenGL context.
+ */
GLboolean
_mesa_initialize_context(struct gl_context *ctx,
const struct gl_config *visual,
@@ -1003,6 +1014,7 @@ _mesa_initialize_context(struct gl_context *ctx,
driverContext);
}
+
/**
* Allocate and initialize a struct gl_context structure.
* Note that the driver needs to pass in its dd_function_table here since
@@ -1044,6 +1056,10 @@ _mesa_create_context_for_api(gl_api api,
}
}
+
+/**
+ * Create an OpenGL context.
+ */
struct gl_context *
_mesa_create_context(const struct gl_config *visual,
struct gl_context *share_list,
@@ -1056,6 +1072,7 @@ _mesa_create_context(const struct gl_config *visual,
driverContext);
}
+
/**
* Free the data associated with the given context.
*
@@ -1142,7 +1159,7 @@ _mesa_free_context_data( struct gl_context *ctx )
*
* \param ctx GL context.
*
- * Calls _mesa_free_context_data() and frees the struct gl_context structure itself.
+ * Calls _mesa_free_context_data() and frees the gl_context object itself.
*/
void
_mesa_destroy_context( struct gl_context *ctx )
@@ -1287,7 +1304,8 @@ _mesa_copy_context( const struct gl_context *src, struct gl_context *dst, GLuint
* \return GL_TRUE if compatible, GL_FALSE otherwise.
*/
static GLboolean
-check_compatible(const struct gl_context *ctx, const struct gl_framebuffer *buffer)
+check_compatible(const struct gl_context *ctx,
+ const struct gl_framebuffer *buffer)
{
const struct gl_config *ctxvis = &ctx->Visual;
const struct gl_config *bufvis = &buffer->Visual;
@@ -1378,9 +1396,12 @@ _mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height)
* \param readBuffer the reading framebuffer
*/
GLboolean
-_mesa_make_current( struct gl_context *newCtx, struct gl_framebuffer *drawBuffer,
+_mesa_make_current( struct gl_context *newCtx,
+ struct gl_framebuffer *drawBuffer,
struct gl_framebuffer *readBuffer )
{
+ GET_CURRENT_CONTEXT(curCtx);
+
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(newCtx, "_mesa_make_current()\n");
@@ -1401,6 +1422,11 @@ _mesa_make_current( struct gl_context *newCtx, struct gl_framebuffer *drawBuffer
}
}
+ if (curCtx &&
+ (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) && /* make sure this context is valid for flushing */
+ curCtx != newCtx)
+ _mesa_flush(curCtx);
+
/* We used to call _glapi_check_multithread() here. Now do it in drivers */
_glapi_set_context((void *) newCtx);
ASSERT(_mesa_get_current_context() == newCtx);
@@ -1439,7 +1465,8 @@ _mesa_make_current( struct gl_context *newCtx, struct gl_framebuffer *drawBuffer
buffers[i] = newCtx->Color.DrawBuffer[i];
}
- _mesa_drawbuffers(newCtx, newCtx->Const.MaxDrawBuffers, buffers, NULL);
+ _mesa_drawbuffers(newCtx, newCtx->Const.MaxDrawBuffers,
+ buffers, NULL);
}
if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) {
_mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer);
@@ -1803,7 +1830,7 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
#ifdef DEBUG
if (ctx->Shader.Flags & GLSL_LOG) {
struct gl_shader_program *shProg[MESA_SHADER_TYPES];
- unsigned i;
+ gl_shader_type i;
shProg[MESA_SHADER_VERTEX] = ctx->Shader.CurrentVertexProgram;
shProg[MESA_SHADER_GEOMETRY] = ctx->Shader.CurrentGeometryProgram;