#include "glheader.h"
-#include "imports.h"
+
#include "accum.h"
#include "api_exec.h"
#include "api_loopback.h"
#endif
#include "compiler/glsl_types.h"
+#include "compiler/glsl/builtin_functions.h"
#include "compiler/glsl/glsl_parser_extras.h"
#include <stdbool.h>
+#include "util/u_memory.h"
#ifndef MESA_VERBOSE
{
if (MESA_VERBOSE & VERBOSE_SWAPBUFFERS)
_mesa_debug(ctx, "SwapBuffers\n");
- FLUSH_CURRENT( ctx, 0 );
+ FLUSH_VERTICES(ctx, 0);
if (ctx->Driver.Flush) {
ctx->Driver.Flush(ctx);
}
* \param stencilBits requested minimum bits per stencil buffer value
* \param accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits number
* of bits per color component in accum buffer.
- * \param indexBits number of bits per pixel if \p rgbFlag is GL_FALSE
* \param redBits number of bits per color component in frame buffer for RGB(A)
* mode. We always use 8 in core Mesa though.
* \param greenBits same as above.
assert(accumBlueBits >= 0);
assert(accumAlphaBits >= 0);
- vis->rgbMode = GL_TRUE;
vis->doubleBufferMode = dbFlag;
vis->stereoMode = stereoFlag;
vis->alphaBits = alphaBits;
vis->rgbBits = redBits + greenBits + blueBits;
- vis->indexBits = 0;
vis->depthBits = depthBits;
vis->stencilBits = stencilBits;
vis->accumBlueBits = accumBlueBits;
vis->accumAlphaBits = accumAlphaBits;
- vis->haveAccumBuffer = accumRedBits > 0;
- vis->haveDepthBuffer = depthBits > 0;
- vis->haveStencilBuffer = stencilBits > 0;
-
vis->numAuxBuffers = 0;
vis->level = 0;
vis->sampleBuffers = numSamples > 0 ? 1 : 0;
static void
one_time_fini(void)
{
- _mesa_destroy_shader_compiler();
+ glsl_type_singleton_decref();
_mesa_locale_fini();
}
*
* \sa _math_init().
*/
-static void
-one_time_init( struct gl_context *ctx )
+void
+_mesa_initialize(void)
{
- static GLbitfield api_init_mask = 0x0;
+ static bool initialized;
mtx_lock(&OneTimeLock);
/* truly one-time init */
- if (!api_init_mask) {
+ if (!initialized) {
GLuint i;
STATIC_ASSERT(sizeof(GLbyte) == 1);
_mesa_locale_init();
- _mesa_one_time_init_extension_overrides(ctx);
+ _mesa_one_time_init_extension_overrides();
_mesa_get_cpu_features();
#if defined(DEBUG)
if (MESA_VERBOSE != 0) {
- _mesa_debug(ctx, "Mesa " PACKAGE_VERSION " DEBUG build" MESA_GIT_SHA1 "\n");
+ _mesa_debug(NULL, "Mesa " PACKAGE_VERSION " DEBUG build" MESA_GIT_SHA1 "\n");
}
#endif
- }
- /* per-API one-time init */
- if (!(api_init_mask & (1 << ctx->API))) {
+ /* Take a glsl type reference for the duration of libGL's life to avoid
+ * unecessary creation/destruction of glsl types.
+ */
+ glsl_type_singleton_init_or_ref();
+
_mesa_init_remap_table();
}
- api_init_mask |= 1 << ctx->API;
+ initialized = true;
mtx_unlock(&OneTimeLock);
}
consts->MaxProgramMatrices = MAX_PROGRAM_MATRICES;
consts->MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH;
+ /* Set the absolute minimum possible GLSL version. API_OPENGL_CORE can
+ * mean an OpenGL 3.0 forward-compatible context, so that implies a minimum
+ * possible version of 1.30. Otherwise, the minimum possible version 1.20.
+ * Since Mesa unconditionally advertises GL_ARB_shading_language_100 and
+ * GL_ARB_shader_objects, every driver has GLSL 1.20... even if they don't
+ * advertise any extensions to enable any shader stages (e.g.,
+ * GL_ARB_vertex_shader).
+ */
+ consts->GLSLVersion = api == API_OPENGL_CORE ? 130 : 120;
+ consts->GLSLVersionCompat = consts->GLSLVersion;
+
+ consts->GLSLLowerConstArrays = true;
+
/* Assume that if GLSL 1.30+ (or GLSL ES 3.00+) is supported that
* gl_VertexID is implemented using a native hardware register with OpenGL
* semantics.
consts->ConservativeRasterDilateRange[0] = 0.0;
consts->ConservativeRasterDilateRange[1] = 0.0;
consts->ConservativeRasterDilateGranularity = 0.0;
+
+ consts->glBeginEndBufferSize = 512 * 1024;
}
_mesa_override_gl_version(ctx);
/* misc one-time initializations */
- one_time_init(ctx);
-
- _mesa_init_shader_compiler_types();
+ _mesa_initialize();
/* Plug in driver functions and context pointer here.
* This is important because when we call alloc_shared_state() below
* \sa _mesa_initialize_context() and init_attrib_groups().
*/
void
-_mesa_free_context_data(struct gl_context *ctx, bool destroy_compiler_types)
+_mesa_free_context_data(struct gl_context *ctx)
{
if (!_mesa_get_current_context()){
/* No current context, but we may need one in order to delete
free(ctx->VersionString);
- if (destroy_compiler_types)
- _mesa_destroy_shader_compiler_types();
+ ralloc_free(ctx->SoftFP64);
/* unbind the context if it's currently bound */
if (ctx == _mesa_get_current_context()) {
_mesa_make_current(NULL, NULL, NULL);
}
+
+ /* Do this after unbinding context to ensure any thread is finished. */
+ if (ctx->shader_builtin_ref) {
+ _mesa_glsl_builtin_functions_decref();
+ ctx->shader_builtin_ref = false;
+ }
+
+ free(ctx->Const.SpirVExtensions);
}
_mesa_destroy_context( struct gl_context *ctx )
{
if (ctx) {
- _mesa_free_context_data(ctx, true);
+ _mesa_free_context_data(ctx);
free( (void *) ctx );
}
}
ctxvis->foo != bufvis->foo) \
return GL_FALSE
- check_component(redMask);
- check_component(greenMask);
- check_component(blueMask);
+ check_component(redShift);
+ check_component(greenShift);
+ check_component(blueShift);
+ check_component(redBits);
+ check_component(greenBits);
+ check_component(blueBits);
check_component(depthBits);
check_component(stencilBits);
* changed since the last time this FBO was bound).
*/
_mesa_update_draw_buffers(newCtx);
+ _mesa_update_allow_draw_out_of_order(newCtx);
}
if (!newCtx->ReadBuffer || _mesa_is_winsys_fbo(newCtx->ReadBuffer)) {
_mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer);
_mesa_flush(struct gl_context *ctx)
{
FLUSH_VERTICES( ctx, 0 );
- FLUSH_CURRENT( ctx, 0 );
if (ctx->Driver.Flush) {
ctx->Driver.Flush(ctx);
}
ASSERT_OUTSIDE_BEGIN_END(ctx);
FLUSH_VERTICES(ctx, 0);
- FLUSH_CURRENT(ctx, 0);
if (ctx->Driver.Finish) {
ctx->Driver.Finish(ctx);