#include "fog.h"
#include "formats.h"
#include "framebuffer.h"
+#include "glthread.h"
#include "hint.h"
#include "hash.h"
#include "light.h"
#include "shared.h"
#include "shaderobj.h"
#include "shaderimage.h"
+#include "util/debug.h"
#include "util/disk_cache.h"
#include "util/strtod.h"
#include "stencil.h"
#include "varray.h"
#include "version.h"
#include "viewport.h"
+#include "texturebindless.h"
#include "program/program.h"
#include "math/m_matrix.h"
#include "main/dispatch.h" /* for _gloffset_COUNT */
#include "macros.h"
+#include "git_sha1.h"
#ifdef USE_SPARC_ASM
#include "sparc/sparc.h"
_mesa_locale_init();
- _mesa_one_time_init_extension_overrides();
+ _mesa_one_time_init_extension_overrides(ctx);
_mesa_get_cpu_features();
atexit(one_time_fini);
-#if defined(DEBUG) && defined(__DATE__) && defined(__TIME__)
+#if defined(DEBUG)
if (MESA_VERBOSE != 0) {
- _mesa_debug(ctx, "Mesa %s DEBUG build %s %s\n",
- PACKAGE_VERSION, __DATE__, __TIME__);
+ _mesa_debug(ctx, "Mesa " PACKAGE_VERSION " DEBUG build"
+#ifdef MESA_GIT_SHA1
+ " (" MESA_GIT_SHA1 ")"
+#endif
+ "\n");
}
#endif
}
}
/* redo special cases: */
- ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_WEIGHT], 1.0, 0.0, 0.0, 0.0 );
ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_NORMAL], 0.0, 0.0, 1.0, 1.0 );
ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR0], 1.0, 1.0, 1.0, 1.0 );
ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR1], 0.0, 0.0, 0.0, 1.0 );
consts->UniformBooleanTrue = FLOAT_AS_UNION(1.0f).u;
/* GL_ARB_sync */
- consts->MaxServerWaitTimeout = 0x1fff7fffffffULL;
+ consts->MaxServerWaitTimeout = 0x7fffffff7fffffffULL;
/* GL_EXT_provoking_vertex */
consts->QuadsFollowProvokingVertexConvention = GL_TRUE;
_mesa_init_transform_feedback( ctx );
_mesa_init_varray( ctx );
_mesa_init_viewport( ctx );
+ _mesa_init_resident_handles( ctx );
if (!_mesa_init_texture( ctx ))
return GL_FALSE;
- _mesa_init_texture_s3tc( ctx );
-
/* Miscellaneous */
+ ctx->TileRasterOrderIncreasingX = GL_TRUE;
+ ctx->TileRasterOrderIncreasingY = GL_TRUE;
ctx->NewState = _NEW_ALL;
ctx->NewDriverState = ~0;
ctx->ErrorValue = GL_NO_ERROR;
* populated with pointers to "no-op" functions. In turn, the no-op
* functions will call nop_handler() above.
*/
-static struct _glapi_table *
-alloc_dispatch_table(void)
+struct _glapi_table *
+_mesa_alloc_dispatch_table(void)
{
/* Find the larger of Mesa's dispatch table and libGL's dispatch table.
* In practice, this'll be the same for stand-alone Mesa. But for DRI
{
struct _glapi_table *table;
- table = alloc_dispatch_table();
+ table = _mesa_alloc_dispatch_table();
if (!table)
return NULL;
if (!init_attrib_groups( ctx ))
goto fail;
+ /* KHR_no_error is likely to crash, overflow memory, etc if an application
+ * has errors so don't enable it for setuid processes.
+ */
+ if (env_var_as_boolean("MESA_NO_ERROR", false)) {
+#if !defined(_WIN32)
+ if (geteuid() == getuid())
+#endif
+ ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR;
+ }
+
/* setup the API dispatch tables with all nop functions */
- ctx->OutsideBeginEnd = alloc_dispatch_table();
+ ctx->OutsideBeginEnd = _mesa_alloc_dispatch_table();
if (!ctx->OutsideBeginEnd)
goto fail;
ctx->Exec = ctx->OutsideBeginEnd;
- ctx->CurrentDispatch = ctx->OutsideBeginEnd;
+ ctx->CurrentClientDispatch = ctx->CurrentServerDispatch = ctx->OutsideBeginEnd;
ctx->FragmentProgram._MaintainTexEnvProgram
= (getenv("MESA_TEX_PROG") != NULL);
switch (ctx->API) {
case API_OPENGL_COMPAT:
ctx->BeginEnd = create_beginend_table(ctx);
- ctx->Save = alloc_dispatch_table();
+ ctx->Save = _mesa_alloc_dispatch_table();
if (!ctx->BeginEnd || !ctx->Save)
goto fail;
_mesa_reference_program(ctx, &ctx->FragmentProgram._Current, NULL);
_mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram, NULL);
+ _mesa_reference_program(ctx, &ctx->ComputeProgram._Current, NULL);
+
_mesa_reference_vao(ctx, &ctx->Array.VAO, NULL);
_mesa_reference_vao(ctx, &ctx->Array.DefaultVAO, NULL);
_mesa_free_transform_feedback(ctx);
_mesa_free_performance_monitors(ctx);
_mesa_free_performance_queries(ctx);
+ _mesa_free_resident_handles(ctx);
_mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj, NULL);
_mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj, NULL);
free(ctx->OutsideBeginEnd);
free(ctx->Save);
free(ctx->ContextLost);
+ free(ctx->MarshalExec);
/* Shared context state (display lists, textures, etc) */
_mesa_reference_shared_state(ctx, &ctx->Shared, NULL);
* Check if the viewport/scissor size has not yet been initialized.
* Initialize the size if the given width and height are non-zero.
*/
-void
-_mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height)
+static void
+check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height)
{
if (!ctx->ViewportInitialized && width > 0 && height > 0) {
unsigned i;
return;
}
- ctx->Extensions.String = _mesa_make_extension_string(ctx);
-
check_context_limits(ctx);
/* According to GL_MESA_configless_context the default value of
}
}
+ /* Determine if generic vertex attribute 0 aliases the conventional
+ * glVertex position.
+ */
+ {
+ const bool is_forward_compatible_context =
+ ctx->Const.ContextFlags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
+
+ /* In OpenGL 3.1 attribute 0 becomes non-magic, just like in OpenGL ES
+ * 2.0. Note that we cannot just check for API_OPENGL_COMPAT here because
+ * that will erroneously allow this usage in a 3.0 forward-compatible
+ * context too.
+ */
+ ctx->_AttribZeroAliasesVertex = (ctx->API == API_OPENGLES
+ || (ctx->API == API_OPENGL_COMPAT
+ && !is_forward_compatible_context));
+ }
+
/* We can use this to help debug user's problems. Tell them to set
* the MESA_INFO env variable before running their app. Then the
* first time each context is made current we'll print some useful
/* make sure this context is valid for flushing */
curCtx != newCtx &&
curCtx->Const.ContextReleaseBehavior ==
- GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH)
+ GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH) {
_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);
if (!newCtx) {
_glapi_set_dispatch(NULL); /* none current */
+ /* We need old ctx to correctly release Draw/ReadBuffer
+ * and avoid a surface leak in st_renderbuffer_delete.
+ * Therefore, first drop buffers then set new ctx to NULL.
+ */
if (curCtx) {
_mesa_reference_framebuffer(&curCtx->WinSysDrawBuffer, NULL);
_mesa_reference_framebuffer(&curCtx->WinSysReadBuffer, NULL);
}
+ _glapi_set_context(NULL);
+ assert(_mesa_get_current_context() == NULL);
}
else {
- _glapi_set_dispatch(newCtx->CurrentDispatch);
+ _glapi_set_context((void *) newCtx);
+ assert(_mesa_get_current_context() == newCtx);
+ _glapi_set_dispatch(newCtx->CurrentClientDispatch);
if (drawBuffer && readBuffer) {
assert(_mesa_is_winsys_fbo(drawBuffer));
*/
newCtx->NewState |= _NEW_BUFFERS;
- _mesa_check_init_viewport(newCtx,
- drawBuffer->Width, drawBuffer->Height);
+ check_init_viewport(newCtx, drawBuffer->Width, drawBuffer->Height);
}
if (newCtx->FirstTimeCurrent) {
/**
* Get context's current API dispatch table.
*
- * It'll either be the immediate-mode execute dispatcher or the display list
- * compile dispatcher.
+ * It'll either be the immediate-mode execute dispatcher, the display list
+ * compile dispatcher, or the thread marshalling dispatcher.
*
* \param ctx GL context.
*
* \return pointer to dispatch_table.
*
- * Simply returns __struct gl_contextRec::CurrentDispatch.
+ * Simply returns __struct gl_contextRec::CurrentClientDispatch.
*/
struct _glapi_table *
_mesa_get_dispatch(struct gl_context *ctx)
{
- return ctx->CurrentDispatch;
+ return ctx->CurrentClientDispatch;
}
/*@}*/
}
-/**
- * Flush commands and wait for completion.
- */
-void
-_mesa_finish(struct gl_context *ctx)
-{
- FLUSH_VERTICES( ctx, 0 );
- FLUSH_CURRENT( ctx, 0 );
- if (ctx->Driver.Finish) {
- ctx->Driver.Finish(ctx);
- }
-}
-
-
/**
* Flush commands.
*/
/**
- * Execute glFinish().
+ * Flush commands and wait for completion.
*
* Calls the #ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH macro and the
* dd_function_table::Finish driver callback, if not NULL.
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
- _mesa_finish(ctx);
+
+ FLUSH_VERTICES(ctx, 0);
+ FLUSH_CURRENT(ctx, 0);
+
+ if (ctx->Driver.Finish) {
+ ctx->Driver.Finish(ctx);
+ }
}