The "olight" application from the OpenGL GLUT examples [1] crashes with a segmentation fault straight after turning off two-sided ligthing. A backtrace from a debug build shows that function pointers still point to the [line|triangle|quadr]_twoside routines after switching to one-sided mode, and, most likely, the backside color pointer is invalid by then:
Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb7b97b40 (LWP 6128)] 0xb78b7281 in quadr_twoside (ctx=0x8801a70, e0=2, e1=0, e2=1, e3=3) at ../../../../../src/mesa/tnl_dd/t_dd_tritmp.h:439 439 GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data; (gdb) bt full 2 #0 0xb78b7281 in quadr_twoside (ctx=0x8801a70, e0=2, e1=0, e2=1, e3=3) at ../../../../../src/mesa/tnl_dd/t_dd_tritmp.h:439 vbcolor = (GLfloat (*)[4]) 0x87fc2a8 ey = -0.511383057 fx = 4.85803223 cc = 121.689102 ex = 13.5482025 fy = 8.79856873 VB = (struct vertex_buffer *) 0x8854788 v = {0xb4eca040, 0xb4eca020, 0xb4eca030, 0xb4eca050} offset = 0 z = {0.219999999, 7.15869246e-05, 0.219999999, 1.21898691e-33} mode = 6914 facing = 1 rmesa = (r128ContextPtr) 0x87fc2a8 color = {3082268660, 3214637304, 3035411741, 952796816} spec = {939524192, 1046562734, 939524100, 1046562734} coloroffset = 3 specoffset = 0 havespec = 0 '\0' __PRETTY_FUNCTION__ = "quadr_twoside" #1 0xb79c0b23 in _tnl_render_quad_strip_verts (ctx=0x8801a70, start=0, count=42, flags=56) at tnl/t_vb_rendertmp.h:378 j = 3 tnl = (TNLcontext *) 0x8854348 VB = (struct vertex_buffer *) 0x8854788 elt = (const GLuint * const) 0x0 LineFunc = (const tnl_line_func) 0xb78bbbbb <line_twoside> TriangleFunc = (const tnl_triangle_func) 0xb78b38a9 <triangle_twoside> QuadFunc = (const tnl_quad_func) 0xb78b710d <quadr_twoside> stipple = 0 '\0' (More stack frames follow...) In this patch r128ChooseRenderState is called to update the function pointers when GL_LIGHT_MODEL_TWO_SIDE changes. [1] http://www.opengl.org/resources/code/samples/glut_examples/examples/examples.html --- diff --git a/src/mesa/drivers/dri/r128/r128_state.c b/src/mesa/drivers/dri/r128/r128_state.c index 451dcd1..4ae7bf5 100644 --- a/src/mesa/drivers/dri/r128/r128_state.c +++ b/src/mesa/drivers/dri/r128/r128_state.c @@ -771,6 +771,11 @@ static void r128DDLightModelfv( GLcontext *ctx, GLenum pname, FLUSH_BATCH( rmesa ); updateSpecularLighting(ctx); } + + if ( pname == GL_LIGHT_MODEL_TWO_SIDE ) { + FLUSH_BATCH( rmesa ); + r128ChooseRenderState( ctx ); + } } static void r128DDShadeModel( GLcontext *ctx, GLenum mode ) diff --git a/src/mesa/drivers/dri/r128/r128_tris.c b/src/mesa/drivers/dri/r128/r128_tris.c index bcc9ffa..5b91271 100644 --- a/src/mesa/drivers/dri/r128/r128_tris.c +++ b/src/mesa/drivers/dri/r128/r128_tris.c @@ -426,7 +426,7 @@ r128_fallback_point( r128ContextPtr rmesa, #define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED) #define _R128_NEW_RENDER_STATE (ANY_FALLBACK_FLAGS | ANY_RASTER_FLAGS) -static void r128ChooseRenderState(GLcontext *ctx) +void r128ChooseRenderState(GLcontext *ctx) { r128ContextPtr rmesa = R128_CONTEXT(ctx); GLuint flags = ctx->_TriangleCaps; diff --git a/src/mesa/drivers/dri/r128/r128_tris.h b/src/mesa/drivers/dri/r128/r128_tris.h index d90ca31..c0667ed 100644 --- a/src/mesa/drivers/dri/r128/r128_tris.h +++ b/src/mesa/drivers/dri/r128/r128_tris.h @@ -38,7 +38,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/mtypes.h" extern void r128InitTriFuncs( GLcontext *ctx ); - +extern void r128ChooseRenderState( GLcontext *ctx ); extern void r128Fallback( GLcontext *ctx, GLuint bit, GLboolean mode ); #define FALLBACK( rmesa, bit, mode ) r128Fallback( rmesa->glCtx, bit, mode ) ------------------------------------------------------------------------------ Enter the BlackBerry Developer Challenge This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge -- _______________________________________________ Dri-devel mailing list Dri-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dri-devel