X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fcontext.c;h=4b5b694a7fb21c60574d882f399278d4159d50de;hb=60e3bfddaf6ab4f8385561654dfe4e0034d8bc9d;hp=8b5693e3771c841673eb290d1d552b059203f7c0;hpb=d67db73458c8d66861b97675660289a9555695ce;p=mesa.git diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 8b5693e3771..4b5b694a7fb 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -133,6 +133,7 @@ #include "program/prog_print.h" #include "math/m_matrix.h" #include "main/dispatch.h" /* for _gloffset_COUNT */ +#include "uniforms.h" #ifdef USE_SPARC_ASM #include "sparc/sparc.h" @@ -622,8 +623,11 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api) consts->MaxProgramMatrices = MAX_PROGRAM_MATRICES; consts->MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH; - /* CheckArrayBounds is overriden by drivers/x11 for X server */ - consts->CheckArrayBounds = GL_FALSE; + /* 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->VertexID_is_zero_based = false; /* GL_ARB_draw_buffers */ consts->MaxDrawBuffers = MAX_DRAW_BUFFERS; @@ -639,16 +643,14 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api) consts->MaxGeometryTotalOutputComponents = MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS; /* Shading language version */ - if (api == API_OPENGL_COMPAT || api == API_OPENGL_CORE) { - consts->GLSLVersion = 120; - _mesa_override_glsl_version(consts); - } - else if (api == API_OPENGLES2) { - consts->GLSLVersion = 100; - } - else if (api == API_OPENGLES) { - consts->GLSLVersion = 0; /* GLSL not supported */ - } + consts->GLSLVersion = 120; + _mesa_override_glsl_version(consts); + +#ifdef DEBUG + consts->GenerateTemporaryNames = true; +#else + consts->GenerateTemporaryNames = false; +#endif /* GL_ARB_framebuffer_object */ consts->MaxSamples = 0; @@ -687,9 +689,6 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api) /* GL_ARB_robustness */ consts->ResetStrategy = GL_NO_RESET_NOTIFICATION_ARB; - /* PrimitiveRestart */ - consts->PrimitiveRestartInSoftware = GL_FALSE; - /* ES 3.0 or ARB_ES3_compatibility */ consts->MaxElementIndex = 0xffffffffu; @@ -720,6 +719,9 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api) /** GL_ARB_gpu_shader5 */ consts->MinFragmentInterpolationOffset = MIN_FRAGMENT_INTERPOLATION_OFFSET; consts->MaxFragmentInterpolationOffset = MAX_FRAGMENT_INTERPOLATION_OFFSET; + + /** GL_KHR_context_flush_control */ + consts->ContextReleaseBehavior = GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH; } @@ -730,6 +732,8 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api) static void check_context_limits(struct gl_context *ctx) { + (void) ctx; + /* check that we don't exceed the size of various bitfields */ assert(VARYING_SLOT_MAX <= (8 * sizeof(ctx->VertexProgram._Current->Base.OutputsWritten))); @@ -893,10 +897,27 @@ _mesa_generic_nop(void) /** - * Allocate and initialize a new dispatch table. + * Special no-op glFlush, see below. + */ +#if defined(_WIN32) +static void GLAPIENTRY +nop_glFlush(void) +{ + /* don't record an error like we do in _mesa_generic_nop() */ +} +#endif + + +extern void (*__glapi_noop_table[])(void); + + +/** + * Allocate and initialize a new dispatch table. All the dispatch + * function pointers will point at the _mesa_generic_nop() function + * which raises GL_INVALID_OPERATION. */ struct _glapi_table * -_mesa_alloc_dispatch_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 @@ -911,8 +932,34 @@ _mesa_alloc_dispatch_table() _glapi_proc *entry = (_glapi_proc *) table; GLint i; for (i = 0; i < numEntries; i++) { +#if defined(_WIN32) + /* FIXME: This will not generate an error, but at least it won't + * corrupt the stack like _mesa_generic_nop does. */ + entry[i] = __glapi_noop_table[i]; +#else entry[i] = (_glapi_proc) _mesa_generic_nop; +#endif } + +#if defined(_WIN32) + /* This is a special case for Windows in the event that + * wglGetProcAddress is called between glBegin/End(). + * + * The MS opengl32.dll library apparently calls glFlush from + * wglGetProcAddress(). If we're inside glBegin/End(), glFlush + * will dispatch to _mesa_generic_nop() and we'll generate a + * GL_INVALID_OPERATION error. + * + * The specific case which hits this is piglit's primitive-restart + * test which calls glPrimitiveRestartNV() inside glBegin/End. The + * first time we call glPrimitiveRestartNV() Piglit's API dispatch + * code will try to resolve the function by calling wglGetProcAddress. + * This raises GL_INVALID_OPERATION and an assert(glGetError()==0) + * will fail causing the test to fail. By suppressing the error, the + * assertion passes and the test continues. + */ + SET_Flush(table, nop_glFlush); +#endif } return table; } @@ -1095,10 +1142,10 @@ _mesa_initialize_context(struct gl_context *ctx, ctx->CurrentDispatch = ctx->OutsideBeginEnd; ctx->FragmentProgram._MaintainTexEnvProgram - = (_mesa_getenv("MESA_TEX_PROG") != NULL); + = (getenv("MESA_TEX_PROG") != NULL); ctx->VertexProgram._MaintainTnlProgram - = (_mesa_getenv("MESA_TNL_PROG") != NULL); + = (getenv("MESA_TNL_PROG") != NULL); if (ctx->VertexProgram._MaintainTnlProgram) { /* this is required... */ ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; @@ -1501,7 +1548,10 @@ handle_first_current(struct gl_context *ctx) GLenum buffer; GLint bufferIndex; - assert(ctx->Version > 0); + if (ctx->Version == 0) { + /* probably in the process of tearing down the context */ + return; + } ctx->Extensions.String = _mesa_make_extension_string(ctx); @@ -1539,7 +1589,7 @@ handle_first_current(struct gl_context *ctx) * first time each context is made current we'll print some useful * information. */ - if (_mesa_getenv("MESA_INFO")) { + if (getenv("MESA_INFO")) { _mesa_print_info(ctx); } } @@ -1586,9 +1636,11 @@ _mesa_make_current( struct gl_context *newCtx, } if (curCtx && - (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) && + (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) && /* make sure this context is valid for flushing */ - curCtx != newCtx) + curCtx != newCtx && + curCtx->Const.ContextReleaseBehavior == + GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH) _mesa_flush(curCtx); /* We used to call _glapi_check_multithread() here. Now do it in drivers */ @@ -1914,6 +1966,17 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where) } } + /* If a program is active and SSO not in use, check if validation of + * samplers succeeded for the active program. */ + if (ctx->_Shader->ActiveProgram && ctx->_Shader != ctx->Pipeline.Current) { + char errMsg[100]; + if (!_mesa_sampler_uniforms_are_valid(ctx->_Shader->ActiveProgram, + errMsg, 100)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "%s", errMsg); + return GL_FALSE; + } + } + if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "%s(incomplete framebuffer)", where);