From 590a78c63ab71d8b7dfd31b97c56af65a0e49f8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Sun, 28 Jun 2009 13:40:23 +0000 Subject: [PATCH] updated mesa to 7.4.4 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31289 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/opengl/mesa/main/context.c | 41 +++++--- src/kits/opengl/mesa/main/context.h | 3 + src/kits/opengl/mesa/main/fbobject.c | 16 +++- src/kits/opengl/mesa/main/get.c | 12 +++ src/kits/opengl/mesa/main/image.c | 40 +++++--- src/kits/opengl/mesa/main/matrix.c | 4 +- src/kits/opengl/mesa/main/mtypes.h | 2 + src/kits/opengl/mesa/main/state.c | 2 +- src/kits/opengl/mesa/main/texrender.c | 1 + src/kits/opengl/mesa/main/texstate.c | 3 +- src/kits/opengl/mesa/main/version.h | 6 +- .../mesa/shader/slang/slang_preprocess.c | 94 +++++++++++++++++-- src/kits/opengl/mesa/swrast/s_texfilter.c | 2 +- src/kits/opengl/mesa/vbo/vbo_exec_array.c | 5 +- src/kits/opengl/mesa/vbo/vbo_exec_draw.c | 1 + 15 files changed, 186 insertions(+), 46 deletions(-) diff --git a/src/kits/opengl/mesa/main/context.c b/src/kits/opengl/mesa/main/context.c index 89a4383aef..e142c852ed 100644 --- a/src/kits/opengl/mesa/main/context.c +++ b/src/kits/opengl/mesa/main/context.c @@ -1549,6 +1549,24 @@ initialize_framebuffer_size(GLcontext *ctx, GLframebuffer *fb) } +/** + * 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(GLcontext *ctx, GLuint width, GLuint height) +{ + if (!ctx->ViewportInitialized && width > 0 && height > 0) { + /* Note: set flag here, before calling _mesa_set_viewport(), to prevent + * potential infinite recursion. + */ + ctx->ViewportInitialized = GL_TRUE; + _mesa_set_viewport(ctx, 0, 0, width, height); + _mesa_set_scissor(ctx, 0, 0, width, height); + } +} + + /** * Bind the given context to the given drawBuffer and readBuffer and * make it the current context for the calling thread. @@ -1651,25 +1669,24 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, ASSERT(drawBuffer->Height > 0); #endif - if (newCtx->FirstTimeCurrent) { - /* set initial viewport and scissor size now */ - _mesa_set_viewport(newCtx, 0, 0, - drawBuffer->Width, drawBuffer->Height); - _mesa_set_scissor(newCtx, 0, 0, - drawBuffer->Width, drawBuffer->Height ); - check_context_limits(newCtx); + if (drawBuffer) { + _mesa_check_init_viewport(newCtx, + drawBuffer->Width, drawBuffer->Height); } } - /* 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 - * information. - */ if (newCtx->FirstTimeCurrent) { + check_context_limits(newCtx); + + /* 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 + * information. + */ if (_mesa_getenv("MESA_INFO")) { _mesa_print_info(); } + newCtx->FirstTimeCurrent = GL_FALSE; } } diff --git a/src/kits/opengl/mesa/main/context.h b/src/kits/opengl/mesa/main/context.h index 54f1af911d..8c1196dd9c 100644 --- a/src/kits/opengl/mesa/main/context.h +++ b/src/kits/opengl/mesa/main/context.h @@ -132,6 +132,9 @@ extern void _mesa_make_current( GLcontext *ctx, GLframebuffer *drawBuffer, GLframebuffer *readBuffer ); +extern void +_mesa_check_init_viewport(GLcontext *ctx, GLuint width, GLuint height); + extern GLboolean _mesa_share_state(GLcontext *ctx, GLcontext *ctxToShare); diff --git a/src/kits/opengl/mesa/main/fbobject.c b/src/kits/opengl/mesa/main/fbobject.c index 876d691c65..5a7ba453aa 100644 --- a/src/kits/opengl/mesa/main/fbobject.c +++ b/src/kits/opengl/mesa/main/fbobject.c @@ -323,6 +323,7 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format, /* OK */ } else if (ctx->Extensions.EXT_packed_depth_stencil && + ctx->Extensions.ARB_depth_texture && texImage->TexFormat->BaseFormat == GL_DEPTH_STENCIL_EXT) { /* OK */ } @@ -332,9 +333,18 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format, } } else { - /* no such thing as stencil textures */ - att->Complete = GL_FALSE; - return; + ASSERT(format == GL_STENCIL); + ASSERT(att->Renderbuffer->StencilBits); + if (ctx->Extensions.EXT_packed_depth_stencil && + ctx->Extensions.ARB_depth_texture && + att->Renderbuffer->_BaseFormat == GL_DEPTH_STENCIL_EXT) { + /* OK */ + } + else { + /* no such thing as stencil-only textures */ + att->Complete = GL_FALSE; + return; + } } } else if (att->Type == GL_RENDERBUFFER_EXT) { diff --git a/src/kits/opengl/mesa/main/get.c b/src/kits/opengl/mesa/main/get.c index d7f80ebbb4..4b60c9e38a 100644 --- a/src/kits/opengl/mesa/main/get.c +++ b/src/kits/opengl/mesa/main/get.c @@ -1905,6 +1905,10 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) CHECK_EXT1(ARB_shader_objects, "GetBooleanv"); params[0] = INT_TO_BOOLEAN(ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0); break; + case GL_VERTEX_ARRAY_BINDING_APPLE: + CHECK_EXT1(APPLE_vertex_array_object, "GetBooleanv"); + params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->Name); + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv(pname=0x%x)", pname); } @@ -3753,6 +3757,10 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) CHECK_EXT1(ARB_shader_objects, "GetFloatv"); params[0] = (GLfloat)(ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0); break; + case GL_VERTEX_ARRAY_BINDING_APPLE: + CHECK_EXT1(APPLE_vertex_array_object, "GetFloatv"); + params[0] = (GLfloat)(ctx->Array.ArrayObj->Name); + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv(pname=0x%x)", pname); } @@ -5601,6 +5609,10 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) CHECK_EXT1(ARB_shader_objects, "GetIntegerv"); params[0] = ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0; break; + case GL_VERTEX_ARRAY_BINDING_APPLE: + CHECK_EXT1(APPLE_vertex_array_object, "GetIntegerv"); + params[0] = ctx->Array.ArrayObj->Name; + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv(pname=0x%x)", pname); } diff --git a/src/kits/opengl/mesa/main/image.c b/src/kits/opengl/mesa/main/image.c index 4d86c54777..b41939cc7f 100644 --- a/src/kits/opengl/mesa/main/image.c +++ b/src/kits/opengl/mesa/main/image.c @@ -1,8 +1,9 @@ /* * Mesa 3-D graphics library - * Version: 7.1 + * Version: 7.5 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -738,12 +739,20 @@ _mesa_image_image_stride( const struct gl_pixelstore_attrib *packing, GLint width, GLint height, GLenum format, GLenum type ) { - ASSERT(packing); - ASSERT(type != GL_BITMAP); + GLint bytesPerRow, bytesPerImage, remainder; - { + ASSERT(packing); + + if (type == GL_BITMAP) { + if (packing->RowLength == 0) { + bytesPerRow = (width + 7) / 8; + } + else { + bytesPerRow = (packing->RowLength + 7) / 8; + } + } + else { const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type); - GLint bytesPerRow, bytesPerImage, remainder; if (bytesPerPixel <= 0) return -1; /* error */ @@ -753,17 +762,18 @@ _mesa_image_image_stride( const struct gl_pixelstore_attrib *packing, else { bytesPerRow = bytesPerPixel * packing->RowLength; } - remainder = bytesPerRow % packing->Alignment; - if (remainder > 0) - bytesPerRow += (packing->Alignment - remainder); - - if (packing->ImageHeight == 0) - bytesPerImage = bytesPerRow * height; - else - bytesPerImage = bytesPerRow * packing->ImageHeight; - - return bytesPerImage; } + + remainder = bytesPerRow % packing->Alignment; + if (remainder > 0) + bytesPerRow += (packing->Alignment - remainder); + + if (packing->ImageHeight == 0) + bytesPerImage = bytesPerRow * height; + else + bytesPerImage = bytesPerRow * packing->ImageHeight; + + return bytesPerImage; } diff --git a/src/kits/opengl/mesa/main/matrix.c b/src/kits/opengl/mesa/main/matrix.c index 0f96f94909..7cfa2dd124 100644 --- a/src/kits/opengl/mesa/main/matrix.c +++ b/src/kits/opengl/mesa/main/matrix.c @@ -580,8 +580,8 @@ _mesa_set_viewport( GLcontext *ctx, GLint x, GLint y, } /* clamp width and height to the implementation dependent range */ - width = CLAMP(width, 1, (GLsizei) ctx->Const.MaxViewportWidth); - height = CLAMP(height, 1, (GLsizei) ctx->Const.MaxViewportHeight); + width = MIN2(width, (GLsizei) ctx->Const.MaxViewportWidth); + height = MIN2(height, (GLsizei) ctx->Const.MaxViewportHeight); ctx->Viewport.X = x; ctx->Viewport.Width = width; diff --git a/src/kits/opengl/mesa/main/mtypes.h b/src/kits/opengl/mesa/main/mtypes.h index a9eb2487d7..f5826cad0a 100644 --- a/src/kits/opengl/mesa/main/mtypes.h +++ b/src/kits/opengl/mesa/main/mtypes.h @@ -3063,6 +3063,8 @@ struct __GLcontextRec GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */ GLbitfield NewState; /**< bitwise-or of _NEW_* flags */ + GLboolean ViewportInitialized; /**< has viewport size been initialized? */ + /** \name Derived state */ /*@{*/ /** Bitwise-or of DD_* flags. Note that this bitfield may be used before diff --git a/src/kits/opengl/mesa/main/state.c b/src/kits/opengl/mesa/main/state.c index 7998e81393..0c977d4531 100644 --- a/src/kits/opengl/mesa/main/state.c +++ b/src/kits/opengl/mesa/main/state.c @@ -157,7 +157,7 @@ update_arrays( GLcontext *ctx ) /* 16..31 */ if (ctx->VertexProgram._Current) { - for (i = VERT_ATTRIB_GENERIC0; i < VERT_ATTRIB_MAX; i++) { + for (i = 0; i < Elements(ctx->Array.ArrayObj->VertexAttrib); i++) { if (ctx->Array.ArrayObj->VertexAttrib[i].Enabled) { min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[i]._MaxElement); } diff --git a/src/kits/opengl/mesa/main/texrender.c b/src/kits/opengl/mesa/main/texrender.c index 49de6f5b8a..cc74d58fbd 100644 --- a/src/kits/opengl/mesa/main/texrender.c +++ b/src/kits/opengl/mesa/main/texrender.c @@ -507,6 +507,7 @@ update_wrapper(GLcontext *ctx, const struct gl_renderbuffer_attachment *att) trb->Base.BlueBits = trb->TexImage->TexFormat->BlueBits; trb->Base.AlphaBits = trb->TexImage->TexFormat->AlphaBits; trb->Base.DepthBits = trb->TexImage->TexFormat->DepthBits; + trb->Base.StencilBits = trb->TexImage->TexFormat->StencilBits; } diff --git a/src/kits/opengl/mesa/main/texstate.c b/src/kits/opengl/mesa/main/texstate.c index 348a2d9e63..71851e1b7b 100644 --- a/src/kits/opengl/mesa/main/texstate.c +++ b/src/kits/opengl/mesa/main/texstate.c @@ -429,7 +429,7 @@ texture_override(GLcontext *ctx, } if (texObj->_Complete) { texUnit->_ReallyEnabled = textureBit; - texUnit->_Current = texObj; + _mesa_reference_texobj(&texUnit->_Current, texObj); update_texture_compare_function(ctx, texObj); } } @@ -485,7 +485,6 @@ update_texture_state( GLcontext *ctx ) GLbitfield enableBits; GLuint tex; - texUnit->_Current = NULL; texUnit->_ReallyEnabled = 0; texUnit->_GenFlags = 0; diff --git a/src/kits/opengl/mesa/main/version.h b/src/kits/opengl/mesa/main/version.h index 9da81ee20e..f52f5c6932 100644 --- a/src/kits/opengl/mesa/main/version.h +++ b/src/kits/opengl/mesa/main/version.h @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 7.4.2 + * Version: 7.4.4 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * Copyright (C) 2009 VMware, Inc. All Rights Reserved. @@ -31,8 +31,8 @@ /* Mesa version */ #define MESA_MAJOR 7 #define MESA_MINOR 4 -#define MESA_PATCH 2 -#define MESA_VERSION_STRING "7.4.2" +#define MESA_PATCH 4 +#define MESA_VERSION_STRING "7.4.4" /* To make version comparison easy */ #define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) diff --git a/src/kits/opengl/mesa/shader/slang/slang_preprocess.c b/src/kits/opengl/mesa/shader/slang/slang_preprocess.c index cd79c8b94a..e03a70fdae 100644 --- a/src/kits/opengl/mesa/shader/slang/slang_preprocess.c +++ b/src/kits/opengl/mesa/shader/slang/slang_preprocess.c @@ -1041,11 +1041,11 @@ preprocess_source (slang_string *output, const char *source, /* Parse optional macro parameters. */ while (prod[i++] != PARAM_END) { - if (state.cond.top->effective) { - pp_symbol *param; + pp_symbol *param; - id = (const char *) (&prod[i]); - idlen = _mesa_strlen (id); + id = (const char *) (&prod[i]); + idlen = _mesa_strlen (id); + if (state.cond.top->effective) { pp_annotate (output, "%s, ", id); param = pp_symbols_push (&symbol->parameters); if (param == NULL) @@ -1059,8 +1059,23 @@ preprocess_source (slang_string *output, const char *source, id = (const char *) (&prod[i]); idlen = _mesa_strlen (id); if (state.cond.top->effective) { + slang_string replacement; + expand_state es; + pp_annotate (output, ") %s", id); - slang_string_pushs (&symbol->replacement, id, idlen); + + slang_string_init(&replacement); + slang_string_pushs(&replacement, id, idlen); + + /* Expand macro replacement. */ + es.output = &symbol->replacement; + es.input = slang_string_cstr(&replacement); + es.state = &state; + if (!expand(&es, &state.symbols)) { + slang_string_free(&replacement); + goto error; + } + slang_string_free(&replacement); } i += idlen + 1; } @@ -1291,6 +1306,45 @@ error: } +/** + * Remove the continuation characters from the input string. + * This is the very first step in preprocessing and is effective + * even inside comment blocks. + * If there is a whitespace between a backslash and a newline, + * this is not considered as a line continuation. + * \return GL_TRUE for success, GL_FALSE otherwise. + */ +static GLboolean +_slang_preprocess_backslashes(slang_string *output, + const char *input) +{ + while (*input) { + if (input[0] == '\\') { + /* If a newline follows, eat the backslash and the newline. */ + if (input[1] == '\r') { + if (input[2] == '\n') { + input += 3; + } else { + input += 2; + } + } else if (input[1] == '\n') { + if (input[2] == '\r') { + input += 3; + } else { + input += 2; + } + } else { + /* Leave the backslash alone. */ + slang_string_pushc(output, *input++); + } + } else { + slang_string_pushc(output, *input++); + } + } + return GL_TRUE; +} + + /** * Run preprocessor on source code. * \param extensions indicates which GL extensions are enabled @@ -1308,6 +1362,7 @@ _slang_preprocess_directives(slang_string *output, { grammar pid, eid; GLboolean success; + slang_string without_backslashes; pid = grammar_load_from_text ((const byte *) (slang_pp_directives_syn)); if (pid == 0) { @@ -1320,9 +1375,36 @@ _slang_preprocess_directives(slang_string *output, grammar_destroy (pid); return GL_FALSE; } - success = preprocess_source (output, input, pid, eid, elog, extensions, pragmas); + + slang_string_init(&without_backslashes); + success = _slang_preprocess_backslashes(&without_backslashes, input); + + if (0) { + _mesa_printf("Pre-processed shader:\n"); + _mesa_printf("%s", slang_string_cstr(&without_backslashes)); + _mesa_printf("----------------------\n"); + } + + if (success) { + success = preprocess_source(output, + slang_string_cstr(&without_backslashes), + pid, + eid, + elog, + extensions, + pragmas); + } + + slang_string_free(&without_backslashes); grammar_destroy (eid); grammar_destroy (pid); + + if (0) { + _mesa_printf("Post-processed shader:\n"); + _mesa_printf("%s", slang_string_cstr(output)); + _mesa_printf("----------------------\n"); + } + return success; } diff --git a/src/kits/opengl/mesa/swrast/s_texfilter.c b/src/kits/opengl/mesa/swrast/s_texfilter.c index fce0bcf0ca..f86dbdb23a 100644 --- a/src/kits/opengl/mesa/swrast/s_texfilter.c +++ b/src/kits/opengl/mesa/swrast/s_texfilter.c @@ -226,7 +226,7 @@ lerp_rgba_3d(GLchan result[4], GLfloat a, GLfloat b, GLfloat c, * If A is a signed integer, A % B doesn't give the right value for A < 0 * (in terms of texture repeat). Just casting to unsigned fixes that. */ -#define REMAINDER(A, B) ((unsigned) (A) % (unsigned) (B)) +#define REMAINDER(A, B) (((A) + (B) * 1024) % (B)) /** diff --git a/src/kits/opengl/mesa/vbo/vbo_exec_array.c b/src/kits/opengl/mesa/vbo/vbo_exec_array.c index 82f4db17d1..660f9695a5 100644 --- a/src/kits/opengl/mesa/vbo/vbo_exec_array.c +++ b/src/kits/opengl/mesa/vbo/vbo_exec_array.c @@ -114,8 +114,11 @@ static void bind_array_obj( GLcontext *ctx ) for (i = 0; i < 8; i++) exec->array.legacy_array[VERT_ATTRIB_TEX0 + i] = &ctx->Array.ArrayObj->TexCoord[i]; - for (i = 0; i < VERT_ATTRIB_MAX; i++) + for (i = 0; i < MAX_VERTEX_ATTRIBS; i++) { + assert(i < Elements(ctx->Array.ArrayObj->VertexAttrib)); + assert(i < Elements(exec->array.generic_array)); exec->array.generic_array[i] = &ctx->Array.ArrayObj->VertexAttrib[i]; + } exec->array.array_obj = ctx->Array.ArrayObj->Name; } diff --git a/src/kits/opengl/mesa/vbo/vbo_exec_draw.c b/src/kits/opengl/mesa/vbo/vbo_exec_draw.c index ad8b6e8a96..74b7a1ffba 100644 --- a/src/kits/opengl/mesa/vbo/vbo_exec_draw.c +++ b/src/kits/opengl/mesa/vbo/vbo_exec_draw.c @@ -184,6 +184,7 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) (ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_GENERIC0)) { exec->vtx.inputs[16] = exec->vtx.inputs[0]; exec->vtx.attrsz[16] = exec->vtx.attrsz[0]; + exec->vtx.attrptr[16] = exec->vtx.attrptr[0]; exec->vtx.attrsz[0] = 0; } break;