From 48dad9c93fd6fb46bf33a58a87de79eb5ffd6e67 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 26 Oct 2009 10:42:45 -0600 Subject: intel: fix GL state bugs in intel_texture_bitmap() Need to push texture state and polygon state too. Fixes rendering glitches seen in progs/demos/engine when changing the rendering mode (wireframe, texture modes). This makes bitmap rendering a little slower, unfortunately. --- src/mesa/drivers/dri/intel/intel_pixel_bitmap.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c index b543a0bbc3..18e6ebd17c 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c @@ -435,13 +435,14 @@ intel_texture_bitmap(GLcontext * ctx, } /* Save GL state before we start setting up our drawing */ - _mesa_PushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | - GL_VIEWPORT_BIT); + _mesa_PushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_POLYGON_BIT | + GL_TEXTURE_BIT | GL_VIEWPORT_BIT); _mesa_PushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT | GL_CLIENT_PIXEL_STORE_BIT); old_active_texture = ctx->Texture.CurrentUnit; _mesa_Disable(GL_POLYGON_STIPPLE); + _mesa_PolygonMode(GL_FRONT_AND_BACK, GL_FILL); /* Upload our bitmap data to an alpha texture */ _mesa_ActiveTextureARB(GL_TEXTURE0_ARB); @@ -501,8 +502,6 @@ intel_texture_bitmap(GLcontext * ctx, meta_restore_vertex_program(&intel->meta); _mesa_PopClientAttrib(); - _mesa_Disable(GL_TEXTURE_2D); /* asserted that it was disabled at entry */ - _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + old_active_texture); _mesa_PopAttrib(); _mesa_DeleteTextures(1, &texname); -- cgit v1.2.3 From 0a4763184971662b23980b533b78d34600ecf06d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 26 Oct 2009 10:58:47 -0600 Subject: docs: document Intel glBitmap fixes --- docs/relnotes-7.6.1.html | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/relnotes-7.6.1.html b/docs/relnotes-7.6.1.html index 11421bede6..e17ee67255 100644 --- a/docs/relnotes-7.6.1.html +++ b/docs/relnotes-7.6.1.html @@ -50,6 +50,7 @@ tbd
  • Fixed Gallium Cell driver compilation failure.
  • Fixed glGetTexLevelParameter(GL_TEXTURE_INTERNAL_FORMAT) query so that it returns the actual compressed format chosen. +
  • Fixed glBitmap bugs in Intel drivers. -- cgit v1.2.3 From 42732611d3bd3c428b376089a58c40537bbfe180 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Tue, 27 Oct 2009 09:13:27 -0600 Subject: draw: Fix memory leak. This would only be hit if we got and invalid index_size. --- src/gallium/auxiliary/draw/draw_pt_vcache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c b/src/gallium/auxiliary/draw/draw_pt_vcache.c index 1a0527be63..d3f179ced1 100644 --- a/src/gallium/auxiliary/draw/draw_pt_vcache.c +++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c @@ -394,6 +394,7 @@ vcache_check_run( struct draw_pt_front_end *frontend, default: assert(0); + FREE(storage); return; } } @@ -422,6 +423,7 @@ vcache_check_run( struct draw_pt_front_end *frontend, default: assert(0); + FREE(storage); return; } } -- cgit v1.2.3 From f9e334cb32152fd342ac6b1dd4776215af6e1d49 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 Oct 2009 09:27:44 -0600 Subject: Revert "i965: fix hacked Fallback usage in brw_prepare_vertices()" This reverts commit 8810b8f67135185d1044746bb861fe2ff997626c. It turns out the i965 driver uses the intel->Fallback field as a boolean, not as a bitmask. The intelFallback() function is a no-op in the i965 driver. It would have been nice if there were some comments about this. I'll fix that next... --- src/mesa/drivers/dri/i965/brw_context.h | 2 -- src/mesa/drivers/dri/i965/brw_draw_upload.c | 6 ++---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index b1e7ec8465..da0e091bfd 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -116,8 +116,6 @@ */ -#define BRW_FALLBACK_DRAW (INTEL_FALLBACK_DRIVER << 0) - #define BRW_MAX_CURBE (32*16) struct brw_context; diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index 4f8ceb37bd..9d089e113e 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -375,10 +375,9 @@ static void brw_prepare_vertices(struct brw_context *brw) * isn't an issue at this point. */ if (brw->vb.nr_enabled >= BRW_VEP_MAX) { - FALLBACK(intel, BRW_FALLBACK_DRAW, GL_TRUE); + intel->Fallback = 1; return; } - FALLBACK(intel, BRW_FALLBACK_DRAW, GL_FALSE); for (i = 0; i < brw->vb.nr_enabled; i++) { struct brw_vertex_element *input = brw->vb.enabled[i]; @@ -428,10 +427,9 @@ static void brw_prepare_vertices(struct brw_context *brw) /* Position array not properly enabled: */ if (input->glarray->StrideB == 0) { - FALLBACK(intel, BRW_FALLBACK_DRAW, GL_TRUE); + intel->Fallback = 1; return; } - FALLBACK(intel, BRW_FALLBACK_DRAW, GL_FALSE); interleave = input->glarray->StrideB; ptr = input->glarray->Ptr; -- cgit v1.2.3 From 43dc91f8bbb69499a6a0326a78e434b313f73c2c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 Oct 2009 09:31:31 -0600 Subject: i965: be clear that the Fallback field is a boolean, not a bitfield --- src/mesa/drivers/dri/i965/brw_draw_upload.c | 4 ++-- src/mesa/drivers/dri/i965/brw_fallback.c | 6 +++++- src/mesa/drivers/dri/i965/brw_state_upload.c | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index 9d089e113e..348c66154f 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -375,7 +375,7 @@ static void brw_prepare_vertices(struct brw_context *brw) * isn't an issue at this point. */ if (brw->vb.nr_enabled >= BRW_VEP_MAX) { - intel->Fallback = 1; + intel->Fallback = GL_TRUE; /* boolean, not bitfield */ return; } @@ -427,7 +427,7 @@ static void brw_prepare_vertices(struct brw_context *brw) /* Position array not properly enabled: */ if (input->glarray->StrideB == 0) { - intel->Fallback = 1; + intel->Fallback = GL_TRUE; /* boolean, not bitfield */ return; } diff --git a/src/mesa/drivers/dri/i965/brw_fallback.c b/src/mesa/drivers/dri/i965/brw_fallback.c index d27c6c24ca..562a17844b 100644 --- a/src/mesa/drivers/dri/i965/brw_fallback.c +++ b/src/mesa/drivers/dri/i965/brw_fallback.c @@ -133,7 +133,11 @@ const struct brw_tracked_state brw_check_fallback = { -/* Not used: +/** + * Called by the INTEL_FALLBACK() macro. + * NOTE: this is a no-op for the i965 driver. The brw->intel.Fallback + * field is treated as a boolean, not a bitmask. It's only set in a + * couple of places. */ void intelFallback( struct intel_context *intel, GLuint bit, GLboolean mode ) { diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index b817b741e7..ee447afa62 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -308,7 +308,7 @@ void brw_validate_state( struct brw_context *brw ) if (brw->state.dirty.brw & BRW_NEW_CONTEXT) brw_clear_batch_cache(brw); - brw->intel.Fallback = 0; + brw->intel.Fallback = GL_FALSE; /* boolean, not bitfield */ /* do prepare stage for all atoms */ for (i = 0; i < Elements(atoms); i++) { -- cgit v1.2.3 From 70b17db918a2784296434877a43b4c4036be792a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 27 Oct 2009 10:26:09 -0700 Subject: i915: Fix driver for the miptree x/y offset changes. Bug #24734. --- src/mesa/drivers/dri/i915/i830_texstate.c | 13 ++++++++++--- src/mesa/drivers/dri/i915/i915_texstate.c | 13 ++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i915/i830_texstate.c b/src/mesa/drivers/dri/i915/i830_texstate.c index 6f998fa6f7..20ff46b0b0 100644 --- a/src/mesa/drivers/dri/i915/i830_texstate.c +++ b/src/mesa/drivers/dri/i915/i830_texstate.c @@ -160,11 +160,18 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3) pitch = intelObj->pitchOverride; } else { + GLuint dst_x, dst_y; + + intel_miptree_get_image_offset(intelObj->mt, intelObj->firstLevel, 0, 0, + &dst_x, &dst_y); + dri_bo_reference(intelObj->mt->region->buffer); i830->state.tex_buffer[unit] = intelObj->mt->region->buffer; - i830->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt, - 0, intelObj-> - firstLevel); + /* XXX: This calculation is probably broken for tiled images with + * a non-page-aligned offset. + */ + i830->state.tex_offset[unit] = (dst_x + dst_y * intelObj->mt->pitch) * + intelObj->mt->cpp; format = translate_texture_format(firstImage->TexFormat->MesaFormat, firstImage->InternalFormat); diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c b/src/mesa/drivers/dri/i915/i915_texstate.c index 32d4b30cf9..998a04f794 100644 --- a/src/mesa/drivers/dri/i915/i915_texstate.c +++ b/src/mesa/drivers/dri/i915/i915_texstate.c @@ -171,11 +171,18 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3) pitch = intelObj->pitchOverride; } else { + GLuint dst_x, dst_y; + + intel_miptree_get_image_offset(intelObj->mt, intelObj->firstLevel, 0, 0, + &dst_x, &dst_y); + dri_bo_reference(intelObj->mt->region->buffer); i915->state.tex_buffer[unit] = intelObj->mt->region->buffer; - i915->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt, - 0, intelObj-> - firstLevel); + /* XXX: This calculation is probably broken for tiled images with + * a non-page-aligned offset. + */ + i915->state.tex_offset[unit] = (dst_x + dst_y * intelObj->mt->pitch) * + intelObj->mt->cpp; format = translate_texture_format(firstImage->TexFormat->MesaFormat, firstImage->InternalFormat, -- cgit v1.2.3 From 517ae7a3b65bca6770e8738464aa0ef526cc88b4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 Oct 2009 16:28:39 -0600 Subject: glsl: fix memory leak A slightly modified version of a patch from Vinson Lee. --- src/mesa/shader/slang/slang_link.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index 71038d2d94..144c126525 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -104,7 +104,7 @@ link_varying_vars(GLcontext *ctx, GLuint *map, i, firstVarying, newFile; GLbitfield *inOutFlags; - map = (GLuint *) malloc(prog->Varying->NumParameters * sizeof(GLuint)); + map = (GLuint *) _mesa_malloc(prog->Varying->NumParameters * sizeof(GLuint)); if (!map) return GL_FALSE; @@ -135,6 +135,7 @@ link_varying_vars(GLcontext *ctx, &shProg->Varying->Parameters[j]; if (var->Size != v->Size) { link_error(shProg, "mismatched varying variable types"); + _mesa_free(map); return GL_FALSE; } if (!bits_agree(var->Flags, v->Flags, PROG_PARAM_BIT_CENTROID)) { @@ -142,6 +143,7 @@ link_varying_vars(GLcontext *ctx, _mesa_snprintf(msg, sizeof(msg), "centroid modifier mismatch for '%s'", var->Name); link_error(shProg, msg); + _mesa_free(map); return GL_FALSE; } if (!bits_agree(var->Flags, v->Flags, PROG_PARAM_BIT_INVARIANT)) { @@ -149,6 +151,7 @@ link_varying_vars(GLcontext *ctx, _mesa_snprintf(msg, sizeof(msg), "invariant modifier mismatch for '%s'", var->Name); link_error(shProg, msg); + _mesa_free(map); return GL_FALSE; } } @@ -160,6 +163,7 @@ link_varying_vars(GLcontext *ctx, if (shProg->Varying->NumParameters > ctx->Const.MaxVarying) { link_error(shProg, "Too many varying variables"); + _mesa_free(map); return GL_FALSE; } @@ -199,7 +203,7 @@ link_varying_vars(GLcontext *ctx, } } - free(map); + _mesa_free(map); /* these will get recomputed before linking is completed */ prog->InputsRead = 0x0; -- cgit v1.2.3 From 22575abdec73312e010e016e381f7cf8761ad652 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 Oct 2009 16:39:01 -0600 Subject: intel: fix src offset bug in do_copy_texsubimage() Use src->draw_offset intead of zero. Zero usually worked, except when the src renderbuffer is actually a texture mipmap level higher than zero. Fixes progs/test/blitfb.c test. --- src/mesa/drivers/dri/intel/intel_tex_copy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/intel/intel_tex_copy.c b/src/mesa/drivers/dri/intel/intel_tex_copy.c index 9d58b11b14..95dee60f9c 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_copy.c +++ b/src/mesa/drivers/dri/intel/intel_tex_copy.c @@ -158,7 +158,7 @@ do_copy_texsubimage(struct intel_context *intel, intelImage->mt->cpp, src_pitch, src->buffer, - 0, + src->draw_offset, src->tiling, intelImage->mt->pitch, dst_bo, -- cgit v1.2.3 From 498fcfd315325365a7c58520ea956f298d6bc94c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 Oct 2009 16:46:07 -0600 Subject: progs/tests: added new blitfb.c test Tests glBlitFramebuffer() between two texture/renderbuffer surfaces. In particular, blit from level[1] of a cube map face to a 2D texture. Used to find/fix bug in intel do_copy_texsubimage(). See commit aef1ab1073f3e30d699b99dae17518ed48b57c72 --- progs/tests/Makefile | 1 + progs/tests/SConscript | 1 + progs/tests/blitfb.c | 259 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 261 insertions(+) create mode 100644 progs/tests/blitfb.c diff --git a/progs/tests/Makefile b/progs/tests/Makefile index 4d9b4e8388..8c310df095 100644 --- a/progs/tests/Makefile +++ b/progs/tests/Makefile @@ -28,6 +28,7 @@ SOURCES = \ blendminmax.c \ blendsquare.c \ blendxor.c \ + blitfb.c \ bufferobj.c \ bumpmap.c \ bug_3050.c \ diff --git a/progs/tests/SConscript b/progs/tests/SConscript index bb6a1d2b8a..3a0da62717 100644 --- a/progs/tests/SConscript +++ b/progs/tests/SConscript @@ -52,6 +52,7 @@ progs = [ 'blendminmax', 'blendsquare', 'blendxor', + 'blitfb', 'bufferobj', 'bug_3050', 'bug_3101', diff --git a/progs/tests/blitfb.c b/progs/tests/blitfb.c new file mode 100644 index 0000000000..18c8380a5e --- /dev/null +++ b/progs/tests/blitfb.c @@ -0,0 +1,259 @@ +/** + * Test glFramebufferBlit() + * Brian Paul + * 27 Oct 2009 + */ + +#include +#include +#include +#include +#include +#include +#include + + +static int Win; +static int WinWidth = 1100, WinHeight = 600; + +static int SrcWidth = 512, SrcHeight = 512; +static int DstWidth = 512, DstHeight = 512; + +static GLuint SrcFB, DstFB; +static GLuint SrcTex, DstTex; + +#if 0 +static GLenum SrcTexTarget = GL_TEXTURE_2D, SrcTexFace = GL_TEXTURE_2D; +#else +static GLenum SrcTexTarget = GL_TEXTURE_CUBE_MAP, SrcTexFace = GL_TEXTURE_CUBE_MAP_POSITIVE_X; +#endif + +static GLenum DstTexTarget = GL_TEXTURE_2D, DstTexFace = GL_TEXTURE_2D; + +static GLuint SrcTexLevel = 01, DstTexLevel = 0; + + +static void +Draw(void) +{ + GLboolean rp = GL_FALSE; + GLubyte *buf; + GLint srcWidth = SrcWidth >> SrcTexLevel; + GLint srcHeight = SrcHeight >> SrcTexLevel; + GLint dstWidth = DstWidth >> DstTexLevel; + GLint dstHeight = DstHeight >> DstTexLevel; + GLenum status; + + /* clear window */ + glBindFramebufferEXT(GL_FRAMEBUFFER, 0); + glClearColor(0.5, 0.5, 0.5, 1.0); + glClear(GL_COLOR_BUFFER_BIT); + + + /* clear src buf */ + glBindFramebufferEXT(GL_FRAMEBUFFER, SrcFB); + status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + assert(status == GL_FRAMEBUFFER_COMPLETE_EXT); + glClearColor(0, 1, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); + + /* clear dst buf */ + glBindFramebufferEXT(GL_FRAMEBUFFER, DstFB); + status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + assert(status == GL_FRAMEBUFFER_COMPLETE_EXT); + glClearColor(1, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); + + /* blit src -> dst */ + glBindFramebufferEXT(GL_READ_FRAMEBUFFER, SrcFB); + glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, DstFB); + glBlitFramebufferEXT(0, 0, srcWidth, srcHeight, + 0, 0, dstWidth, dstHeight, + GL_COLOR_BUFFER_BIT, GL_NEAREST); + +#if 01 + /* read src results */ + buf = malloc(4 * srcWidth * srcHeight); + memset(buf, 0x88, 4 * srcWidth * srcHeight); + glBindFramebufferEXT(GL_FRAMEBUFFER, SrcFB); + if (rp) + glReadPixels(0, 0, srcWidth, srcHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf); + else { + glBindTexture(SrcTexTarget, SrcTex); + glGetTexImage(SrcTexFace, SrcTexLevel, GL_RGBA, GL_UNSIGNED_BYTE, buf); + } + + /* draw dst in window */ + glBindFramebufferEXT(GL_FRAMEBUFFER, 0); + glWindowPos2i(0, 0); + glDrawPixels(srcWidth, srcHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf); + + printf("Src Pix[0] = %d %d %d %d\n", buf[0], buf[1], buf[2], buf[3]); + free(buf); +#endif + + glFinish(); + + /* read dst results */ + buf = malloc(4 * dstWidth * dstHeight); + memset(buf, 0x88, 4 * dstWidth * dstHeight); + glBindFramebufferEXT(GL_FRAMEBUFFER, DstFB); + if (rp) + glReadPixels(0, 0, dstWidth, dstHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf); + else { + glBindTexture(DstTexTarget, DstTex); + glGetTexImage(DstTexFace, DstTexLevel, GL_RGBA, GL_UNSIGNED_BYTE, buf); + } + + /* draw dst in window */ + glBindFramebufferEXT(GL_FRAMEBUFFER, 0); + glWindowPos2i(srcWidth + 2, 0); + glDrawPixels(dstWidth, dstHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf); + + printf("Dst Pix[0] = %d %d %d %d\n", buf[0], buf[1], buf[2], buf[3]); + free(buf); + + glFinish(); + + glutSwapBuffers(); +} + + +static void +Reshape(int width, int height) +{ + WinWidth = width; + WinHeight = height; + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -15.0); +} + + +static void +Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + case 27: + glutDestroyWindow(Win); + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void +SpecialKey(int key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + } + glutPostRedisplay(); +} + + +static void +InitFBOs(void) +{ + GLuint w, h, lvl; + + /* Src */ + glGenTextures(1, &SrcTex); + glBindTexture(SrcTexTarget, SrcTex); + w = SrcWidth; + h = SrcHeight; + lvl = 0; + for (lvl = 0; ; lvl++) { + if (SrcTexTarget == GL_TEXTURE_CUBE_MAP) { + GLuint f; + for (f = 0; f < 6; f++) { + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, lvl, GL_RGBA8, + w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + } + } + else { + /* single face */ + glTexImage2D(SrcTexFace, lvl, GL_RGBA8, w, h, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + } + if (w == 1 && h == 1) + break; + if (w > 1) + w /= 2; + if (h > 1) + h /= 2; + } + + glGenFramebuffersEXT(1, &SrcFB); + glBindFramebufferEXT(GL_FRAMEBUFFER, SrcFB); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + SrcTexFace, SrcTex, SrcTexLevel); + + /* Dst */ + glGenTextures(1, &DstTex); + glBindTexture(DstTexTarget, DstTex); + w = DstWidth; + h = DstHeight; + lvl = 0; + for (lvl = 0; ; lvl++) { + glTexImage2D(DstTexFace, lvl, GL_RGBA8, w, h, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + if (w == 1 && h == 1) + break; + if (w > 1) + w /= 2; + if (h > 1) + h /= 2; + } + + glGenFramebuffersEXT(1, &DstFB); + glBindFramebufferEXT(GL_FRAMEBUFFER, DstFB); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + DstTexFace, DstTex, DstTexLevel); +} + + +static void +Init(void) +{ + if (!glutExtensionSupported("GL_EXT_framebuffer_object")) { + fprintf(stderr, "This test requires GL_EXT_framebuffer_object\n"); + exit(1); + } + + if (!glutExtensionSupported("GL_EXT_framebuffer_blit")) { + fprintf(stderr, "This test requires GL_EXT_framebuffer_blit,\n"); + exit(1); + } + + InitFBOs(); + + printf("Left rect = src FBO, Right rect = dst FBO.\n"); + printf("Both should be green.\n"); +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowSize(WinWidth, WinHeight); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); + Win = glutCreateWindow(argv[0]); + glewInit(); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(SpecialKey); + glutDisplayFunc(Draw); + Init(); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From b7eea8c616092f5473a323fba585b04c47ae2010 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 Oct 2009 17:34:29 -0600 Subject: intel: added region draw_x/y offsets in x/y_tile_swizzle() funcs This fixes the second part of bug 23552. --- src/mesa/drivers/dri/intel/intel_span.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c index 8df4990880..e71366a182 100644 --- a/src/mesa/drivers/dri/intel/intel_span.c +++ b/src/mesa/drivers/dri/intel/intel_span.c @@ -163,6 +163,9 @@ static uint32_t x_tile_swizzle(struct intel_renderbuffer *irb, int x_tile_number, y_tile_number; int tile_off, tile_base; + x += irb->region->draw_x; + y += irb->region->draw_y; + tile_stride = (irb->region->pitch * irb->region->cpp) << 3; xbyte = x * irb->region->cpp; @@ -218,6 +221,9 @@ static uint32_t y_tile_swizzle(struct intel_renderbuffer *irb, int x_tile_number, y_tile_number; int tile_off, tile_base; + x += irb->region->draw_x; + y += irb->region->draw_y; + tile_stride = (irb->region->pitch * irb->region->cpp) << 5; xbyte = x * irb->region->cpp; -- cgit v1.2.3 From 2643a7ba2972ab8284aa911cc92ab0be163cb92f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 20 Oct 2009 14:51:53 -0700 Subject: intel: Fix flipped condition in ARB_sync GetSYnciv(GL_SYNC_STATUS). Bug #24435 (cherry picked from commit d56125a298106d81e10674f1c4b3b43b51a5139d) --- src/mesa/drivers/dri/intel/intel_syncobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/intel/intel_syncobj.c b/src/mesa/drivers/dri/intel/intel_syncobj.c index 1286fe929b..0d7889d3c2 100644 --- a/src/mesa/drivers/dri/intel/intel_syncobj.c +++ b/src/mesa/drivers/dri/intel/intel_syncobj.c @@ -114,7 +114,7 @@ static void intel_check_sync(GLcontext *ctx, struct gl_sync_object *s) { struct intel_sync_object *sync = (struct intel_sync_object *)s; - if (sync->bo && drm_intel_bo_busy(sync->bo)) { + if (sync->bo && !drm_intel_bo_busy(sync->bo)) { drm_intel_bo_unreference(sync->bo); sync->bo = NULL; s->StatusFlag = 1; -- cgit v1.2.3 From 0f255d195651f104a0c0bed84039b656d94ac4cc Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 27 Oct 2009 11:44:56 -0700 Subject: ARB prog parser: Don't leak symbol table header structures --- src/mesa/shader/symbol_table.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/mesa/shader/symbol_table.c b/src/mesa/shader/symbol_table.c index 7a9aa7b8f6..42601a7765 100644 --- a/src/mesa/shader/symbol_table.c +++ b/src/mesa/shader/symbol_table.c @@ -73,6 +73,9 @@ struct symbol { /** */ struct symbol_header { + /** Linkage in list of all headers in a given symbol table. */ + struct symbol_header *next; + /** Symbol name. */ const char *name; @@ -102,6 +105,9 @@ struct _mesa_symbol_table { /** Top of scope stack. */ struct scope_level *current_scope; + + /** List of all symbol headers in the table. */ + struct symbol_header *hdr; }; @@ -301,6 +307,8 @@ _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *table, hdr->name = name; hash_table_insert(table->ht, hdr, name); + hdr->next = table->hdr; + table->hdr = hdr; } check_symbol_table(table); @@ -341,10 +349,18 @@ _mesa_symbol_table_ctor(void) void _mesa_symbol_table_dtor(struct _mesa_symbol_table *table) { + struct symbol_header *hdr; + struct symbol_header *next; + while (table->current_scope != NULL) { _mesa_symbol_table_pop_scope(table); } + for (hdr = table->hdr; hdr != NULL; hdr = next) { + next = hdr->next; + _mesa_free(hdr); + } + hash_table_dtor(table->ht); free(table); } -- cgit v1.2.3 From 8df9587d68752f3369cc1eda1606d3b7c1041ec6 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 27 Oct 2009 11:46:29 -0700 Subject: ARB prog parser: Don't leak program string The program string is kept in the program object. On the second call into glProgramStringARB the previous kept string would be leaked. --- src/mesa/shader/program_parse.y | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index ae9e15ae5a..c3152aa2f8 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -2278,6 +2278,10 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str, _mesa_memcpy (strz, str, len); strz[len] = '\0'; + if (state->prog->String != NULL) { + _mesa_free(state->prog->String); + } + state->prog->String = strz; state->st = _mesa_symbol_table_ctor(); -- cgit v1.2.3 From 93dae6761bc90bbd43b450d2673620ec189b2c7a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 27 Oct 2009 13:40:18 -0700 Subject: ARB prog parser: Fix epic memory leak in lexer / parser interface Anything that matched IDENTIFIER was strdup'ed and returned to the parser. However, almost every case of IDENTIFIER in the parser just dropped the returned string on the floor. Every swizzle string, every option string, every use of a variable, etc. leaked memory. Create a temporary buffer in the parser state (string_dumpster and dumpster_size). Return strings from the lexer to the parser in the buffer. Grow the buffer as needed. When the parser needs to keep a string (i.e., delcaring a new variable), let it make a copy then. The only leak that valgrind now detects is /occasionally/ the copy of the program string in gl_program::String is leaked. I'm not seeing how. :( --- src/mesa/shader/lex.yy.c | 445 ++++++++++++++++++++---------------- src/mesa/shader/program_lexer.l | 45 +++- src/mesa/shader/program_parse.tab.c | 21 +- src/mesa/shader/program_parse.y | 17 +- src/mesa/shader/program_parser.h | 16 ++ 5 files changed, 337 insertions(+), 207 deletions(-) diff --git a/src/mesa/shader/lex.yy.c b/src/mesa/shader/lex.yy.c index fefef573ee..728c2dc272 100644 --- a/src/mesa/shader/lex.yy.c +++ b/src/mesa/shader/lex.yy.c @@ -53,7 +53,6 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -84,6 +83,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -157,7 +158,15 @@ typedef void* yyscan_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -918,7 +927,7 @@ static yyconst flex_int16_t yy_chk[1023] = if (condition) { \ return token; \ } else { \ - yylval->string = strdup(yytext); \ + yylval->string = return_string(yyextra, yytext); \ return IDENTIFIER; \ } \ } while (0) @@ -941,7 +950,7 @@ static yyconst flex_int16_t yy_chk[1023] = yylval->temp_inst.SaturateMode = SATURATE_ ## sat; \ return token; \ } else { \ - yylval->string = strdup(yytext); \ + yylval->string = return_string(yyextra, yytext); \ return IDENTIFIER; \ } \ } while (0) @@ -949,6 +958,45 @@ static yyconst flex_int16_t yy_chk[1023] = #define SWIZZLE_INVAL MAKE_SWIZZLE4(SWIZZLE_NIL, SWIZZLE_NIL, \ SWIZZLE_NIL, SWIZZLE_NIL) +/** + * Send a string to the parser using asm_parser_state::string_dumpster + * + * Sends a string to the parser using asm_parser_state::string_dumpster as a + * temporary storage buffer. Data previously stored in + * asm_parser_state::string_dumpster will be lost. If + * asm_parser_state::string_dumpster is not large enough to hold the new + * string, the buffer size will be increased. The buffer size is \b never + * decreased. + * + * \param state Assembler parser state tracking + * \param str String to be passed to the parser + * + * \return + * A pointer to asm_parser_state::string_dumpster on success or \c NULL on + * failure. Currently the only failure case is \c ENOMEM. + */ +static char * +return_string(struct asm_parser_state *state, const char *str) +{ + const size_t len = strlen(str); + + if (len >= state->dumpster_size) { + char *const dumpster = _mesa_realloc(state->string_dumpster, + state->dumpster_size, + len + 1); + if (dumpster == NULL) { + return NULL; + } + + state->string_dumpster = dumpster; + state->dumpster_size = len + 1; + } + + memcpy(state->string_dumpster, str, len + 1); + return state->string_dumpster; +} + + static unsigned mask_from_char(char c) { @@ -1004,7 +1052,7 @@ swiz_from_char(char c) } while(0); #define YY_EXTRA_TYPE struct asm_parser_state * -#line 1008 "lex.yy.c" +#line 1056 "lex.yy.c" #define INITIAL 0 @@ -1141,7 +1189,12 @@ static int input (yyscan_t yyscanner ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -1149,7 +1202,7 @@ static int input (yyscan_t yyscanner ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO fwrite( yytext, yyleng, 1, yyout ) +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -1160,7 +1213,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - unsigned n; \ + size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1245,10 +1298,10 @@ YY_DECL register int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -#line 137 "program_lexer.l" +#line 176 "program_lexer.l" -#line 1252 "lex.yy.c" +#line 1305 "lex.yy.c" yylval = yylval_param; @@ -1337,17 +1390,17 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 139 "program_lexer.l" +#line 178 "program_lexer.l" { return ARBvp_10; } YY_BREAK case 2: YY_RULE_SETUP -#line 140 "program_lexer.l" +#line 179 "program_lexer.l" { return ARBfp_10; } YY_BREAK case 3: YY_RULE_SETUP -#line 141 "program_lexer.l" +#line 180 "program_lexer.l" { yylval->integer = at_address; return_token_or_IDENTIFIER(require_ARB_vp, ADDRESS); @@ -1355,760 +1408,760 @@ YY_RULE_SETUP YY_BREAK case 4: YY_RULE_SETUP -#line 145 "program_lexer.l" +#line 184 "program_lexer.l" { return ALIAS; } YY_BREAK case 5: YY_RULE_SETUP -#line 146 "program_lexer.l" +#line 185 "program_lexer.l" { return ATTRIB; } YY_BREAK case 6: YY_RULE_SETUP -#line 147 "program_lexer.l" +#line 186 "program_lexer.l" { return END; } YY_BREAK case 7: YY_RULE_SETUP -#line 148 "program_lexer.l" +#line 187 "program_lexer.l" { return OPTION; } YY_BREAK case 8: YY_RULE_SETUP -#line 149 "program_lexer.l" +#line 188 "program_lexer.l" { return OUTPUT; } YY_BREAK case 9: YY_RULE_SETUP -#line 150 "program_lexer.l" +#line 189 "program_lexer.l" { return PARAM; } YY_BREAK case 10: YY_RULE_SETUP -#line 151 "program_lexer.l" +#line 190 "program_lexer.l" { yylval->integer = at_temp; return TEMP; } YY_BREAK case 11: YY_RULE_SETUP -#line 153 "program_lexer.l" +#line 192 "program_lexer.l" { return_opcode( 1, VECTOR_OP, ABS, OFF); } YY_BREAK case 12: YY_RULE_SETUP -#line 154 "program_lexer.l" +#line 193 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, ABS, ZERO_ONE); } YY_BREAK case 13: YY_RULE_SETUP -#line 155 "program_lexer.l" +#line 194 "program_lexer.l" { return_opcode( 1, BIN_OP, ADD, OFF); } YY_BREAK case 14: YY_RULE_SETUP -#line 156 "program_lexer.l" +#line 195 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, ADD, ZERO_ONE); } YY_BREAK case 15: YY_RULE_SETUP -#line 157 "program_lexer.l" +#line 196 "program_lexer.l" { return_opcode(require_ARB_vp, ARL, ARL, OFF); } YY_BREAK case 16: YY_RULE_SETUP -#line 159 "program_lexer.l" +#line 198 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, CMP, OFF); } YY_BREAK case 17: YY_RULE_SETUP -#line 160 "program_lexer.l" +#line 199 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, CMP, ZERO_ONE); } YY_BREAK case 18: YY_RULE_SETUP -#line 161 "program_lexer.l" +#line 200 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, COS, OFF); } YY_BREAK case 19: YY_RULE_SETUP -#line 162 "program_lexer.l" +#line 201 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, COS, ZERO_ONE); } YY_BREAK case 20: YY_RULE_SETUP -#line 164 "program_lexer.l" +#line 203 "program_lexer.l" { return_opcode( 1, BIN_OP, DP3, OFF); } YY_BREAK case 21: YY_RULE_SETUP -#line 165 "program_lexer.l" +#line 204 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, DP3, ZERO_ONE); } YY_BREAK case 22: YY_RULE_SETUP -#line 166 "program_lexer.l" +#line 205 "program_lexer.l" { return_opcode( 1, BIN_OP, DP4, OFF); } YY_BREAK case 23: YY_RULE_SETUP -#line 167 "program_lexer.l" +#line 206 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, DP4, ZERO_ONE); } YY_BREAK case 24: YY_RULE_SETUP -#line 168 "program_lexer.l" +#line 207 "program_lexer.l" { return_opcode( 1, BIN_OP, DPH, OFF); } YY_BREAK case 25: YY_RULE_SETUP -#line 169 "program_lexer.l" +#line 208 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, DPH, ZERO_ONE); } YY_BREAK case 26: YY_RULE_SETUP -#line 170 "program_lexer.l" +#line 209 "program_lexer.l" { return_opcode( 1, BIN_OP, DST, OFF); } YY_BREAK case 27: YY_RULE_SETUP -#line 171 "program_lexer.l" +#line 210 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, DST, ZERO_ONE); } YY_BREAK case 28: YY_RULE_SETUP -#line 173 "program_lexer.l" +#line 212 "program_lexer.l" { return_opcode( 1, SCALAR_OP, EX2, OFF); } YY_BREAK case 29: YY_RULE_SETUP -#line 174 "program_lexer.l" +#line 213 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, EX2, ZERO_ONE); } YY_BREAK case 30: YY_RULE_SETUP -#line 175 "program_lexer.l" +#line 214 "program_lexer.l" { return_opcode(require_ARB_vp, SCALAR_OP, EXP, OFF); } YY_BREAK case 31: YY_RULE_SETUP -#line 177 "program_lexer.l" +#line 216 "program_lexer.l" { return_opcode( 1, VECTOR_OP, FLR, OFF); } YY_BREAK case 32: YY_RULE_SETUP -#line 178 "program_lexer.l" +#line 217 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, FLR, ZERO_ONE); } YY_BREAK case 33: YY_RULE_SETUP -#line 179 "program_lexer.l" +#line 218 "program_lexer.l" { return_opcode( 1, VECTOR_OP, FRC, OFF); } YY_BREAK case 34: YY_RULE_SETUP -#line 180 "program_lexer.l" +#line 219 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, FRC, ZERO_ONE); } YY_BREAK case 35: YY_RULE_SETUP -#line 182 "program_lexer.l" +#line 221 "program_lexer.l" { return_opcode(require_ARB_fp, KIL, KIL, OFF); } YY_BREAK case 36: YY_RULE_SETUP -#line 184 "program_lexer.l" +#line 223 "program_lexer.l" { return_opcode( 1, VECTOR_OP, LIT, OFF); } YY_BREAK case 37: YY_RULE_SETUP -#line 185 "program_lexer.l" +#line 224 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, LIT, ZERO_ONE); } YY_BREAK case 38: YY_RULE_SETUP -#line 186 "program_lexer.l" +#line 225 "program_lexer.l" { return_opcode( 1, SCALAR_OP, LG2, OFF); } YY_BREAK case 39: YY_RULE_SETUP -#line 187 "program_lexer.l" +#line 226 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, LG2, ZERO_ONE); } YY_BREAK case 40: YY_RULE_SETUP -#line 188 "program_lexer.l" +#line 227 "program_lexer.l" { return_opcode(require_ARB_vp, SCALAR_OP, LOG, OFF); } YY_BREAK case 41: YY_RULE_SETUP -#line 189 "program_lexer.l" +#line 228 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, LRP, OFF); } YY_BREAK case 42: YY_RULE_SETUP -#line 190 "program_lexer.l" +#line 229 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, LRP, ZERO_ONE); } YY_BREAK case 43: YY_RULE_SETUP -#line 192 "program_lexer.l" +#line 231 "program_lexer.l" { return_opcode( 1, TRI_OP, MAD, OFF); } YY_BREAK case 44: YY_RULE_SETUP -#line 193 "program_lexer.l" +#line 232 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, MAD, ZERO_ONE); } YY_BREAK case 45: YY_RULE_SETUP -#line 194 "program_lexer.l" +#line 233 "program_lexer.l" { return_opcode( 1, BIN_OP, MAX, OFF); } YY_BREAK case 46: YY_RULE_SETUP -#line 195 "program_lexer.l" +#line 234 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, MAX, ZERO_ONE); } YY_BREAK case 47: YY_RULE_SETUP -#line 196 "program_lexer.l" +#line 235 "program_lexer.l" { return_opcode( 1, BIN_OP, MIN, OFF); } YY_BREAK case 48: YY_RULE_SETUP -#line 197 "program_lexer.l" +#line 236 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, MIN, ZERO_ONE); } YY_BREAK case 49: YY_RULE_SETUP -#line 198 "program_lexer.l" +#line 237 "program_lexer.l" { return_opcode( 1, VECTOR_OP, MOV, OFF); } YY_BREAK case 50: YY_RULE_SETUP -#line 199 "program_lexer.l" +#line 238 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, MOV, ZERO_ONE); } YY_BREAK case 51: YY_RULE_SETUP -#line 200 "program_lexer.l" +#line 239 "program_lexer.l" { return_opcode( 1, BIN_OP, MUL, OFF); } YY_BREAK case 52: YY_RULE_SETUP -#line 201 "program_lexer.l" +#line 240 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, MUL, ZERO_ONE); } YY_BREAK case 53: YY_RULE_SETUP -#line 203 "program_lexer.l" +#line 242 "program_lexer.l" { return_opcode( 1, BINSC_OP, POW, OFF); } YY_BREAK case 54: YY_RULE_SETUP -#line 204 "program_lexer.l" +#line 243 "program_lexer.l" { return_opcode(require_ARB_fp, BINSC_OP, POW, ZERO_ONE); } YY_BREAK case 55: YY_RULE_SETUP -#line 206 "program_lexer.l" +#line 245 "program_lexer.l" { return_opcode( 1, SCALAR_OP, RCP, OFF); } YY_BREAK case 56: YY_RULE_SETUP -#line 207 "program_lexer.l" +#line 246 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, RCP, ZERO_ONE); } YY_BREAK case 57: YY_RULE_SETUP -#line 208 "program_lexer.l" +#line 247 "program_lexer.l" { return_opcode( 1, SCALAR_OP, RSQ, OFF); } YY_BREAK case 58: YY_RULE_SETUP -#line 209 "program_lexer.l" +#line 248 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, RSQ, ZERO_ONE); } YY_BREAK case 59: YY_RULE_SETUP -#line 211 "program_lexer.l" +#line 250 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, SCS, OFF); } YY_BREAK case 60: YY_RULE_SETUP -#line 212 "program_lexer.l" +#line 251 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, SCS, ZERO_ONE); } YY_BREAK case 61: YY_RULE_SETUP -#line 213 "program_lexer.l" +#line 252 "program_lexer.l" { return_opcode( 1, BIN_OP, SGE, OFF); } YY_BREAK case 62: YY_RULE_SETUP -#line 214 "program_lexer.l" +#line 253 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, SGE, ZERO_ONE); } YY_BREAK case 63: YY_RULE_SETUP -#line 215 "program_lexer.l" +#line 254 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, SIN, OFF); } YY_BREAK case 64: YY_RULE_SETUP -#line 216 "program_lexer.l" +#line 255 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, SIN, ZERO_ONE); } YY_BREAK case 65: YY_RULE_SETUP -#line 217 "program_lexer.l" +#line 256 "program_lexer.l" { return_opcode( 1, BIN_OP, SLT, OFF); } YY_BREAK case 66: YY_RULE_SETUP -#line 218 "program_lexer.l" +#line 257 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, SLT, ZERO_ONE); } YY_BREAK case 67: YY_RULE_SETUP -#line 219 "program_lexer.l" +#line 258 "program_lexer.l" { return_opcode( 1, BIN_OP, SUB, OFF); } YY_BREAK case 68: YY_RULE_SETUP -#line 220 "program_lexer.l" +#line 259 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, SUB, ZERO_ONE); } YY_BREAK case 69: YY_RULE_SETUP -#line 221 "program_lexer.l" +#line 260 "program_lexer.l" { return_opcode( 1, SWZ, SWZ, OFF); } YY_BREAK case 70: YY_RULE_SETUP -#line 222 "program_lexer.l" +#line 261 "program_lexer.l" { return_opcode(require_ARB_fp, SWZ, SWZ, ZERO_ONE); } YY_BREAK case 71: YY_RULE_SETUP -#line 224 "program_lexer.l" +#line 263 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TEX, OFF); } YY_BREAK case 72: YY_RULE_SETUP -#line 225 "program_lexer.l" +#line 264 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TEX, ZERO_ONE); } YY_BREAK case 73: YY_RULE_SETUP -#line 226 "program_lexer.l" +#line 265 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TXB, OFF); } YY_BREAK case 74: YY_RULE_SETUP -#line 227 "program_lexer.l" +#line 266 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TXB, ZERO_ONE); } YY_BREAK case 75: YY_RULE_SETUP -#line 228 "program_lexer.l" +#line 267 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TXP, OFF); } YY_BREAK case 76: YY_RULE_SETUP -#line 229 "program_lexer.l" +#line 268 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TXP, ZERO_ONE); } YY_BREAK case 77: YY_RULE_SETUP -#line 231 "program_lexer.l" +#line 270 "program_lexer.l" { return_opcode( 1, BIN_OP, XPD, OFF); } YY_BREAK case 78: YY_RULE_SETUP -#line 232 "program_lexer.l" +#line 271 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, XPD, ZERO_ONE); } YY_BREAK case 79: YY_RULE_SETUP -#line 234 "program_lexer.l" +#line 273 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_vp, VERTEX); } YY_BREAK case 80: YY_RULE_SETUP -#line 235 "program_lexer.l" +#line 274 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, FRAGMENT); } YY_BREAK case 81: YY_RULE_SETUP -#line 236 "program_lexer.l" +#line 275 "program_lexer.l" { return PROGRAM; } YY_BREAK case 82: YY_RULE_SETUP -#line 237 "program_lexer.l" +#line 276 "program_lexer.l" { return STATE; } YY_BREAK case 83: YY_RULE_SETUP -#line 238 "program_lexer.l" +#line 277 "program_lexer.l" { return RESULT; } YY_BREAK case 84: YY_RULE_SETUP -#line 240 "program_lexer.l" +#line 279 "program_lexer.l" { return AMBIENT; } YY_BREAK case 85: YY_RULE_SETUP -#line 241 "program_lexer.l" +#line 280 "program_lexer.l" { return ATTENUATION; } YY_BREAK case 86: YY_RULE_SETUP -#line 242 "program_lexer.l" +#line 281 "program_lexer.l" { return BACK; } YY_BREAK case 87: YY_RULE_SETUP -#line 243 "program_lexer.l" +#line 282 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, CLIP); } YY_BREAK case 88: YY_RULE_SETUP -#line 244 "program_lexer.l" +#line 283 "program_lexer.l" { return COLOR; } YY_BREAK case 89: YY_RULE_SETUP -#line 245 "program_lexer.l" +#line 284 "program_lexer.l" { return_token_or_DOT(require_ARB_fp, DEPTH); } YY_BREAK case 90: YY_RULE_SETUP -#line 246 "program_lexer.l" +#line 285 "program_lexer.l" { return DIFFUSE; } YY_BREAK case 91: YY_RULE_SETUP -#line 247 "program_lexer.l" +#line 286 "program_lexer.l" { return DIRECTION; } YY_BREAK case 92: YY_RULE_SETUP -#line 248 "program_lexer.l" +#line 287 "program_lexer.l" { return EMISSION; } YY_BREAK case 93: YY_RULE_SETUP -#line 249 "program_lexer.l" +#line 288 "program_lexer.l" { return ENV; } YY_BREAK case 94: YY_RULE_SETUP -#line 250 "program_lexer.l" +#line 289 "program_lexer.l" { return EYE; } YY_BREAK case 95: YY_RULE_SETUP -#line 251 "program_lexer.l" +#line 290 "program_lexer.l" { return FOGCOORD; } YY_BREAK case 96: YY_RULE_SETUP -#line 252 "program_lexer.l" +#line 291 "program_lexer.l" { return FOG; } YY_BREAK case 97: YY_RULE_SETUP -#line 253 "program_lexer.l" +#line 292 "program_lexer.l" { return FRONT; } YY_BREAK case 98: YY_RULE_SETUP -#line 254 "program_lexer.l" +#line 293 "program_lexer.l" { return HALF; } YY_BREAK case 99: YY_RULE_SETUP -#line 255 "program_lexer.l" +#line 294 "program_lexer.l" { return INVERSE; } YY_BREAK case 100: YY_RULE_SETUP -#line 256 "program_lexer.l" +#line 295 "program_lexer.l" { return INVTRANS; } YY_BREAK case 101: YY_RULE_SETUP -#line 257 "program_lexer.l" +#line 296 "program_lexer.l" { return LIGHT; } YY_BREAK case 102: YY_RULE_SETUP -#line 258 "program_lexer.l" +#line 297 "program_lexer.l" { return LIGHTMODEL; } YY_BREAK case 103: YY_RULE_SETUP -#line 259 "program_lexer.l" +#line 298 "program_lexer.l" { return LIGHTPROD; } YY_BREAK case 104: YY_RULE_SETUP -#line 260 "program_lexer.l" +#line 299 "program_lexer.l" { return LOCAL; } YY_BREAK case 105: YY_RULE_SETUP -#line 261 "program_lexer.l" +#line 300 "program_lexer.l" { return MATERIAL; } YY_BREAK case 106: YY_RULE_SETUP -#line 262 "program_lexer.l" +#line 301 "program_lexer.l" { return MAT_PROGRAM; } YY_BREAK case 107: YY_RULE_SETUP -#line 263 "program_lexer.l" +#line 302 "program_lexer.l" { return MATRIX; } YY_BREAK case 108: YY_RULE_SETUP -#line 264 "program_lexer.l" +#line 303 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, MATRIXINDEX); } YY_BREAK case 109: YY_RULE_SETUP -#line 265 "program_lexer.l" +#line 304 "program_lexer.l" { return MODELVIEW; } YY_BREAK case 110: YY_RULE_SETUP -#line 266 "program_lexer.l" +#line 305 "program_lexer.l" { return MVP; } YY_BREAK case 111: YY_RULE_SETUP -#line 267 "program_lexer.l" +#line 306 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, NORMAL); } YY_BREAK case 112: YY_RULE_SETUP -#line 268 "program_lexer.l" +#line 307 "program_lexer.l" { return OBJECT; } YY_BREAK case 113: YY_RULE_SETUP -#line 269 "program_lexer.l" +#line 308 "program_lexer.l" { return PALETTE; } YY_BREAK case 114: YY_RULE_SETUP -#line 270 "program_lexer.l" +#line 309 "program_lexer.l" { return PARAMS; } YY_BREAK case 115: YY_RULE_SETUP -#line 271 "program_lexer.l" +#line 310 "program_lexer.l" { return PLANE; } YY_BREAK case 116: YY_RULE_SETUP -#line 272 "program_lexer.l" +#line 311 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, POINT_TOK); } YY_BREAK case 117: YY_RULE_SETUP -#line 273 "program_lexer.l" +#line 312 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, POINTSIZE); } YY_BREAK case 118: YY_RULE_SETUP -#line 274 "program_lexer.l" +#line 313 "program_lexer.l" { return POSITION; } YY_BREAK case 119: YY_RULE_SETUP -#line 275 "program_lexer.l" +#line 314 "program_lexer.l" { return PRIMARY; } YY_BREAK case 120: YY_RULE_SETUP -#line 276 "program_lexer.l" +#line 315 "program_lexer.l" { return PROJECTION; } YY_BREAK case 121: YY_RULE_SETUP -#line 277 "program_lexer.l" +#line 316 "program_lexer.l" { return_token_or_DOT(require_ARB_fp, RANGE); } YY_BREAK case 122: YY_RULE_SETUP -#line 278 "program_lexer.l" +#line 317 "program_lexer.l" { return ROW; } YY_BREAK case 123: YY_RULE_SETUP -#line 279 "program_lexer.l" +#line 318 "program_lexer.l" { return SCENECOLOR; } YY_BREAK case 124: YY_RULE_SETUP -#line 280 "program_lexer.l" +#line 319 "program_lexer.l" { return SECONDARY; } YY_BREAK case 125: YY_RULE_SETUP -#line 281 "program_lexer.l" +#line 320 "program_lexer.l" { return SHININESS; } YY_BREAK case 126: YY_RULE_SETUP -#line 282 "program_lexer.l" +#line 321 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, SIZE_TOK); } YY_BREAK case 127: YY_RULE_SETUP -#line 283 "program_lexer.l" +#line 322 "program_lexer.l" { return SPECULAR; } YY_BREAK case 128: YY_RULE_SETUP -#line 284 "program_lexer.l" +#line 323 "program_lexer.l" { return SPOT; } YY_BREAK case 129: YY_RULE_SETUP -#line 285 "program_lexer.l" +#line 324 "program_lexer.l" { return TEXCOORD; } YY_BREAK case 130: YY_RULE_SETUP -#line 286 "program_lexer.l" +#line 325 "program_lexer.l" { return_token_or_DOT(require_ARB_fp, TEXENV); } YY_BREAK case 131: YY_RULE_SETUP -#line 287 "program_lexer.l" +#line 326 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, TEXGEN); } YY_BREAK case 132: YY_RULE_SETUP -#line 288 "program_lexer.l" +#line 327 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, TEXGEN_Q); } YY_BREAK case 133: YY_RULE_SETUP -#line 289 "program_lexer.l" +#line 328 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, TEXGEN_S); } YY_BREAK case 134: YY_RULE_SETUP -#line 290 "program_lexer.l" +#line 329 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, TEXGEN_T); } YY_BREAK case 135: YY_RULE_SETUP -#line 291 "program_lexer.l" +#line 330 "program_lexer.l" { return TEXTURE; } YY_BREAK case 136: YY_RULE_SETUP -#line 292 "program_lexer.l" +#line 331 "program_lexer.l" { return TRANSPOSE; } YY_BREAK case 137: YY_RULE_SETUP -#line 293 "program_lexer.l" +#line 332 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, VTXATTRIB); } YY_BREAK case 138: YY_RULE_SETUP -#line 294 "program_lexer.l" +#line 333 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, WEIGHT); } YY_BREAK case 139: YY_RULE_SETUP -#line 296 "program_lexer.l" +#line 335 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEXTURE_UNIT); } YY_BREAK case 140: YY_RULE_SETUP -#line 297 "program_lexer.l" +#line 336 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEX_1D); } YY_BREAK case 141: YY_RULE_SETUP -#line 298 "program_lexer.l" +#line 337 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEX_2D); } YY_BREAK case 142: YY_RULE_SETUP -#line 299 "program_lexer.l" +#line 338 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEX_3D); } YY_BREAK case 143: YY_RULE_SETUP -#line 300 "program_lexer.l" +#line 339 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEX_CUBE); } YY_BREAK case 144: YY_RULE_SETUP -#line 301 "program_lexer.l" +#line 340 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_rect, TEX_RECT); } YY_BREAK case 145: YY_RULE_SETUP -#line 302 "program_lexer.l" +#line 341 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW1D); } YY_BREAK case 146: YY_RULE_SETUP -#line 303 "program_lexer.l" +#line 342 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW2D); } YY_BREAK case 147: YY_RULE_SETUP -#line 304 "program_lexer.l" +#line 343 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_rect, TEX_SHADOWRECT); } YY_BREAK case 148: YY_RULE_SETUP -#line 305 "program_lexer.l" +#line 344 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY1D); } YY_BREAK case 149: YY_RULE_SETUP -#line 306 "program_lexer.l" +#line 345 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY2D); } YY_BREAK case 150: YY_RULE_SETUP -#line 307 "program_lexer.l" +#line 346 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW1D); } YY_BREAK case 151: YY_RULE_SETUP -#line 308 "program_lexer.l" +#line 347 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW2D); } YY_BREAK case 152: YY_RULE_SETUP -#line 310 "program_lexer.l" +#line 349 "program_lexer.l" { - yylval->string = strdup(yytext); + yylval->string = return_string(yyextra, yytext); return IDENTIFIER; } YY_BREAK case 153: YY_RULE_SETUP -#line 315 "program_lexer.l" +#line 354 "program_lexer.l" { return DOT_DOT; } YY_BREAK case 154: YY_RULE_SETUP -#line 317 "program_lexer.l" +#line 356 "program_lexer.l" { yylval->integer = strtol(yytext, NULL, 10); return INTEGER; @@ -2116,7 +2169,7 @@ YY_RULE_SETUP YY_BREAK case 155: YY_RULE_SETUP -#line 321 "program_lexer.l" +#line 360 "program_lexer.l" { yylval->real = _mesa_strtod(yytext, NULL); return REAL; @@ -2128,7 +2181,7 @@ case 156: yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 325 "program_lexer.l" +#line 364 "program_lexer.l" { yylval->real = _mesa_strtod(yytext, NULL); return REAL; @@ -2136,7 +2189,7 @@ YY_RULE_SETUP YY_BREAK case 157: YY_RULE_SETUP -#line 329 "program_lexer.l" +#line 368 "program_lexer.l" { yylval->real = _mesa_strtod(yytext, NULL); return REAL; @@ -2144,7 +2197,7 @@ YY_RULE_SETUP YY_BREAK case 158: YY_RULE_SETUP -#line 333 "program_lexer.l" +#line 372 "program_lexer.l" { yylval->real = _mesa_strtod(yytext, NULL); return REAL; @@ -2152,7 +2205,7 @@ YY_RULE_SETUP YY_BREAK case 159: YY_RULE_SETUP -#line 338 "program_lexer.l" +#line 377 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_NOOP; yylval->swiz_mask.mask = WRITEMASK_XYZW; @@ -2161,7 +2214,7 @@ YY_RULE_SETUP YY_BREAK case 160: YY_RULE_SETUP -#line 344 "program_lexer.l" +#line 383 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_XY @@ -2171,7 +2224,7 @@ YY_RULE_SETUP YY_BREAK case 161: YY_RULE_SETUP -#line 350 "program_lexer.l" +#line 389 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_XZW; @@ -2180,7 +2233,7 @@ YY_RULE_SETUP YY_BREAK case 162: YY_RULE_SETUP -#line 355 "program_lexer.l" +#line 394 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_YZW; @@ -2189,7 +2242,7 @@ YY_RULE_SETUP YY_BREAK case 163: YY_RULE_SETUP -#line 361 "program_lexer.l" +#line 400 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_X @@ -2199,7 +2252,7 @@ YY_RULE_SETUP YY_BREAK case 164: YY_RULE_SETUP -#line 367 "program_lexer.l" +#line 406 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_Y @@ -2209,7 +2262,7 @@ YY_RULE_SETUP YY_BREAK case 165: YY_RULE_SETUP -#line 373 "program_lexer.l" +#line 412 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_ZW; @@ -2218,7 +2271,7 @@ YY_RULE_SETUP YY_BREAK case 166: YY_RULE_SETUP -#line 379 "program_lexer.l" +#line 418 "program_lexer.l" { const unsigned s = swiz_from_char(yytext[1]); yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s); @@ -2228,7 +2281,7 @@ YY_RULE_SETUP YY_BREAK case 167: YY_RULE_SETUP -#line 386 "program_lexer.l" +#line 425 "program_lexer.l" { yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]), swiz_from_char(yytext[2]), @@ -2240,7 +2293,7 @@ YY_RULE_SETUP YY_BREAK case 168: YY_RULE_SETUP -#line 395 "program_lexer.l" +#line 434 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_NOOP; yylval->swiz_mask.mask = WRITEMASK_XYZW; @@ -2249,7 +2302,7 @@ YY_RULE_SETUP YY_BREAK case 169: YY_RULE_SETUP -#line 401 "program_lexer.l" +#line 440 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_XY @@ -2259,7 +2312,7 @@ YY_RULE_SETUP YY_BREAK case 170: YY_RULE_SETUP -#line 407 "program_lexer.l" +#line 446 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_XZW; @@ -2268,7 +2321,7 @@ YY_RULE_SETUP YY_BREAK case 171: YY_RULE_SETUP -#line 412 "program_lexer.l" +#line 451 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_YZW; @@ -2277,7 +2330,7 @@ YY_RULE_SETUP YY_BREAK case 172: YY_RULE_SETUP -#line 418 "program_lexer.l" +#line 457 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_X @@ -2287,7 +2340,7 @@ YY_RULE_SETUP YY_BREAK case 173: YY_RULE_SETUP -#line 424 "program_lexer.l" +#line 463 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_Y @@ -2297,7 +2350,7 @@ YY_RULE_SETUP YY_BREAK case 174: YY_RULE_SETUP -#line 430 "program_lexer.l" +#line 469 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_ZW; @@ -2306,7 +2359,7 @@ YY_RULE_SETUP YY_BREAK case 175: YY_RULE_SETUP -#line 436 "program_lexer.l" +#line 475 "program_lexer.l" { const unsigned s = swiz_from_char(yytext[1]); yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s); @@ -2316,7 +2369,7 @@ YY_RULE_SETUP YY_BREAK case 176: YY_RULE_SETUP -#line 444 "program_lexer.l" +#line 483 "program_lexer.l" { if (require_ARB_vp) { return TEXGEN_R; @@ -2330,7 +2383,7 @@ YY_RULE_SETUP YY_BREAK case 177: YY_RULE_SETUP -#line 455 "program_lexer.l" +#line 494 "program_lexer.l" { yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]), swiz_from_char(yytext[2]), @@ -2342,13 +2395,13 @@ YY_RULE_SETUP YY_BREAK case 178: YY_RULE_SETUP -#line 464 "program_lexer.l" +#line 503 "program_lexer.l" { return DOT; } YY_BREAK case 179: /* rule 179 can match eol */ YY_RULE_SETUP -#line 466 "program_lexer.l" +#line 505 "program_lexer.l" { yylloc->first_line++; yylloc->first_column = 1; @@ -2359,7 +2412,7 @@ YY_RULE_SETUP YY_BREAK case 180: YY_RULE_SETUP -#line 473 "program_lexer.l" +#line 512 "program_lexer.l" /* eat whitespace */ ; YY_BREAK case 181: @@ -2367,20 +2420,20 @@ case 181: yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 474 "program_lexer.l" +#line 513 "program_lexer.l" /* eat comments */ ; YY_BREAK case 182: YY_RULE_SETUP -#line 475 "program_lexer.l" +#line 514 "program_lexer.l" { return yytext[0]; } YY_BREAK case 183: YY_RULE_SETUP -#line 476 "program_lexer.l" +#line 515 "program_lexer.l" ECHO; YY_BREAK -#line 2384 "lex.yy.c" +#line 2437 "lex.yy.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -3148,8 +3201,8 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) /** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ @@ -3555,7 +3608,7 @@ void yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 476 "program_lexer.l" +#line 515 "program_lexer.l" diff --git a/src/mesa/shader/program_lexer.l b/src/mesa/shader/program_lexer.l index c2803ff707..6c4fad3037 100644 --- a/src/mesa/shader/program_lexer.l +++ b/src/mesa/shader/program_lexer.l @@ -40,7 +40,7 @@ if (condition) { \ return token; \ } else { \ - yylval->string = strdup(yytext); \ + yylval->string = return_string(yyextra, yytext); \ return IDENTIFIER; \ } \ } while (0) @@ -63,7 +63,7 @@ yylval->temp_inst.SaturateMode = SATURATE_ ## sat; \ return token; \ } else { \ - yylval->string = strdup(yytext); \ + yylval->string = return_string(yyextra, yytext); \ return IDENTIFIER; \ } \ } while (0) @@ -71,6 +71,45 @@ #define SWIZZLE_INVAL MAKE_SWIZZLE4(SWIZZLE_NIL, SWIZZLE_NIL, \ SWIZZLE_NIL, SWIZZLE_NIL) +/** + * Send a string to the parser using asm_parser_state::string_dumpster + * + * Sends a string to the parser using asm_parser_state::string_dumpster as a + * temporary storage buffer. Data previously stored in + * asm_parser_state::string_dumpster will be lost. If + * asm_parser_state::string_dumpster is not large enough to hold the new + * string, the buffer size will be increased. The buffer size is \b never + * decreased. + * + * \param state Assembler parser state tracking + * \param str String to be passed to the parser + * + * \return + * A pointer to asm_parser_state::string_dumpster on success or \c NULL on + * failure. Currently the only failure case is \c ENOMEM. + */ +static char * +return_string(struct asm_parser_state *state, const char *str) +{ + const size_t len = strlen(str); + + if (len >= state->dumpster_size) { + char *const dumpster = _mesa_realloc(state->string_dumpster, + state->dumpster_size, + len + 1); + if (dumpster == NULL) { + return NULL; + } + + state->string_dumpster = dumpster; + state->dumpster_size = len + 1; + } + + memcpy(state->string_dumpster, str, len + 1); + return state->string_dumpster; +} + + static unsigned mask_from_char(char c) { @@ -308,7 +347,7 @@ ARRAYSHADOW1D { return_token_or_IDENTIFIER(require_ARB_fp && require ARRAYSHADOW2D { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW2D); } [_a-zA-Z$][_a-zA-Z0-9$]* { - yylval->string = strdup(yytext); + yylval->string = return_string(yyextra, yytext); return IDENTIFIER; } diff --git a/src/mesa/shader/program_parse.tab.c b/src/mesa/shader/program_parse.tab.c index c255e912ed..261b605a2d 100644 --- a/src/mesa/shader/program_parse.tab.c +++ b/src/mesa/shader/program_parse.tab.c @@ -4565,7 +4565,7 @@ yyreduce: "undefined variable binding in ALIAS statement"); YYERROR; } else { - _mesa_symbol_table_add_symbol(state->st, 0, (yyvsp[(2) - (4)].string), target); + _mesa_symbol_table_add_symbol(state->st, 0, strdup((yyvsp[(2) - (4)].string)), target); } ;} break; @@ -4896,10 +4896,14 @@ declare_variable(struct asm_parser_state *state, char *name, enum asm_type t, if (exist != NULL) { yyerror(locp, state, "redeclared identifier"); } else { - s = calloc(1, sizeof(struct asm_symbol)); - s->name = name; + const size_t name_len = strlen(name); + + s = calloc(1, sizeof(struct asm_symbol) + name_len + 1); + s->name = (char *)(s + 1); s->type = t; + memcpy((char *) s->name, name, name_len + 1); + switch (t) { case at_temp: if (state->prog->NumTemporaries >= state->limits->MaxTemps) { @@ -5147,6 +5151,11 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str, _mesa_memcpy (strz, str, len); strz[len] = '\0'; + if (state->prog->String != NULL) { + _mesa_free(state->prog->String); + state->prog->String = NULL; + } + state->prog->String = strz; state->st = _mesa_symbol_table_ctor(); @@ -5236,7 +5245,6 @@ error: for (sym = state->sym; sym != NULL; sym = temp) { temp = sym->next; - _mesa_free((void *) sym->name); _mesa_free(sym); } state->sym = NULL; @@ -5244,6 +5252,11 @@ error: _mesa_symbol_table_dtor(state->st); state->st = NULL; + if (state->string_dumpster != NULL) { + _mesa_free(state->string_dumpster); + state->dumpster_size = 0; + } + return result; } diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index c3152aa2f8..a23625d3fb 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -1919,7 +1919,7 @@ ALIAS_statement: ALIAS IDENTIFIER '=' IDENTIFIER "undefined variable binding in ALIAS statement"); YYERROR; } else { - _mesa_symbol_table_add_symbol(state->st, 0, $2, target); + _mesa_symbol_table_add_symbol(state->st, 0, strdup($2), target); } } ; @@ -2027,10 +2027,14 @@ declare_variable(struct asm_parser_state *state, char *name, enum asm_type t, if (exist != NULL) { yyerror(locp, state, "redeclared identifier"); } else { - s = calloc(1, sizeof(struct asm_symbol)); - s->name = name; + const size_t name_len = strlen(name); + + s = calloc(1, sizeof(struct asm_symbol) + name_len + 1); + s->name = (char *)(s + 1); s->type = t; + memcpy((char *) s->name, name, name_len + 1); + switch (t) { case at_temp: if (state->prog->NumTemporaries >= state->limits->MaxTemps) { @@ -2280,6 +2284,7 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str, if (state->prog->String != NULL) { _mesa_free(state->prog->String); + state->prog->String = NULL; } state->prog->String = strz; @@ -2371,7 +2376,6 @@ error: for (sym = state->sym; sym != NULL; sym = temp) { temp = sym->next; - _mesa_free((void *) sym->name); _mesa_free(sym); } state->sym = NULL; @@ -2379,5 +2383,10 @@ error: _mesa_symbol_table_dtor(state->st); state->st = NULL; + if (state->string_dumpster != NULL) { + _mesa_free(state->string_dumpster); + state->dumpster_size = 0; + } + return result; } diff --git a/src/mesa/shader/program_parser.h b/src/mesa/shader/program_parser.h index fa47d84565..8d8b4d89bc 100644 --- a/src/mesa/shader/program_parser.h +++ b/src/mesa/shader/program_parser.h @@ -38,6 +38,13 @@ enum asm_type { at_output, }; +/** + * \note + * Objects of this type are allocated as the object plus the name of the + * symbol. That is, malloc(sizeof(struct asm_symbol) + strlen(name) + 1). + * Alternately, asm_symbol::name could be moved to the bottom of the structure + * and declared as 'char name[0];'. + */ struct asm_symbol { struct asm_symbol *next; /**< List linkage for freeing. */ const char *name; @@ -157,6 +164,15 @@ struct asm_parser_state { /*@}*/ + /** + * Buffer to hold strings transfered from the lexer to the parser + */ + /*@{*/ + char *string_dumpster; /**< String data transfered. */ + size_t dumpster_size; /**< Total size, in bytes, of the buffer. */ + /*@}*/ + + /** * Selected limits copied from gl_constants * -- cgit v1.2.3 From a7d0665c00053839065592c339bfb298187a82be Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 28 Oct 2009 11:09:50 -0600 Subject: intel: Fix memory leak in event of mip tree allocation failure Signed-off-by: Brian Paul --- src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index 0589d82db2..459e8fbd4b 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -134,8 +134,10 @@ intel_miptree_create(struct intel_context *intel, /* * pitch == 0 || height == 0 indicates the null texture */ - if (!mt || !mt->pitch || !mt->total_height) + if (!mt || !mt->pitch || !mt->total_height) { + free(mt); return NULL; + } mt->region = intel_region_alloc(intel, tiling, -- cgit v1.2.3 From 5e3b2baae74e6cde494b2fe5c6b32e3e8ef0ce87 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 Oct 2009 11:11:30 -0600 Subject: mesa: include imports.h to silence warning --- src/mesa/shader/symbol_table.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/shader/symbol_table.c b/src/mesa/shader/symbol_table.c index 42601a7765..73eeb616f3 100644 --- a/src/mesa/shader/symbol_table.c +++ b/src/mesa/shader/symbol_table.c @@ -26,6 +26,7 @@ #include #include +#include "main/imports.h" #include "symbol_table.h" #include "hash_table.h" -- cgit v1.2.3 From 0219cd0961e6b47761fe6984dc6c0a8bfa6057d8 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 Oct 2009 11:13:21 -0600 Subject: mesa: remove unneeded #includes --- src/mesa/shader/hash_table.c | 4 ---- src/mesa/shader/symbol_table.c | 5 ----- 2 files changed, 9 deletions(-) diff --git a/src/mesa/shader/hash_table.c b/src/mesa/shader/hash_table.c index 881179f9d8..e89a2564d7 100644 --- a/src/mesa/shader/hash_table.c +++ b/src/mesa/shader/hash_table.c @@ -27,10 +27,6 @@ * * \author Ian Romanick */ -#include -#include - -#include #include "main/imports.h" #include "main/simple_list.h" diff --git a/src/mesa/shader/symbol_table.c b/src/mesa/shader/symbol_table.c index 73eeb616f3..1f6d9b844d 100644 --- a/src/mesa/shader/symbol_table.c +++ b/src/mesa/shader/symbol_table.c @@ -20,11 +20,6 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ -#include -#include -#include -#include -#include #include "main/imports.h" #include "symbol_table.h" -- cgit v1.2.3