From b2e083eba2668517e40bc94e3a19cd15824ce93c Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Fri, 12 Sep 2008 09:25:34 +0800 Subject: i965: Add support for G41 chipset which is another 4 series. --- src/mesa/drivers/dri/intel/intel_chipset.h | 4 +++- src/mesa/drivers/dri/intel/intel_context.c | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/intel/intel_chipset.h b/src/mesa/drivers/dri/intel/intel_chipset.h index 15b9ef4312..170efd060a 100644 --- a/src/mesa/drivers/dri/intel/intel_chipset.h +++ b/src/mesa/drivers/dri/intel/intel_chipset.h @@ -58,6 +58,7 @@ #define PCI_CHIP_IGD_E_G 0x2E02 #define PCI_CHIP_Q45_G 0x2E12 #define PCI_CHIP_G45_G 0x2E22 +#define PCI_CHIP_G41_G 0x2E32 #define IS_MOBILE(devid) (devid == PCI_CHIP_I855_GM || \ devid == PCI_CHIP_I915_GM || \ @@ -70,7 +71,8 @@ #define IS_GM45_GM(devid) (devid == PCI_CHIP_GM45_GM) #define IS_G4X(devid) (devid == PCI_CHIP_IGD_E_G || \ devid == PCI_CHIP_Q45_G || \ - devid == PCI_CHIP_G45_G) + devid == PCI_CHIP_G45_G || \ + devid == PCI_CHIP_G41_G) #define IS_915(devid) (devid == PCI_CHIP_I915_G || \ devid == PCI_CHIP_E7221_G || \ diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 4d1a742698..7065bb35ee 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -179,6 +179,9 @@ intelGetString(GLcontext * ctx, GLenum name) case PCI_CHIP_Q45_G: chipset = "Intel(R) Q45/Q43"; break; + case PCI_CHIP_G41_G: + chipset = "Intel(R) G41"; + break; default: chipset = "Unknown Intel Chipset"; break; -- cgit v1.2.3 From 201d3419a6432a0f35dff48e606649092afb7ff7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 11 Sep 2008 09:50:47 -0700 Subject: intel: Remove dead allow_batchbuffer param. --- src/mesa/drivers/dri/intel/intel_screen.c | 5 ----- src/mesa/drivers/dri/intel/intel_screen.h | 1 - 2 files changed, 6 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 1de1ac49ea..de098e5b72 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -298,11 +298,6 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) &intelScreen->irq_active)) return GL_FALSE; - /* Determine if batchbuffers are allowed */ - if (!intel_get_param(sPriv, I915_PARAM_ALLOW_BATCHBUFFER, - &intelScreen->allow_batchbuffer)) - return GL_FALSE; - sPriv->extensions = intelScreenExtensions; return GL_TRUE; diff --git a/src/mesa/drivers/dri/intel/intel_screen.h b/src/mesa/drivers/dri/intel/intel_screen.h index daf2ab4c58..fc913da5bf 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.h +++ b/src/mesa/drivers/dri/intel/intel_screen.h @@ -74,7 +74,6 @@ typedef struct int drmMinor; int irq_active; - int allow_batchbuffer; GLboolean no_hw; -- cgit v1.2.3 From 34bba445a12f7b81654a416fd1630c8890cfc178 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 12 Sep 2008 13:47:37 -0700 Subject: intel: Don't segfault on TFP from a bad drawable. --- src/mesa/drivers/dri/intel/intel_context.c | 3 +++ src/mesa/drivers/dri/intel/intel_tex_image.c | 6 ++++++ 2 files changed, 9 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 7065bb35ee..007dee449c 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -233,6 +233,9 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable) &count, drawable->loaderPrivate); + if (buffers == NULL) + return; + drawable->x = 0; drawable->y = 0; drawable->backX = 0; diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index d1f540b0f1..70b0b3e245 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -733,6 +733,12 @@ intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv) intel_update_renderbuffers(pDRICtx, dPriv); rb = intel_fb->color_rb[0]; + /* If the region isn't set, then intel_update_renderbuffers was unable + * to get the buffers for the drawable. + */ + if (rb->region == NULL) + return; + type = GL_BGRA; format = GL_UNSIGNED_BYTE; internalFormat = (rb->region->cpp == 3 ? 3 : 4); -- cgit v1.2.3 From 8db761409dadc2e899d4e7107eff3aa07b07aa11 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 12 Sep 2008 15:48:13 -0700 Subject: intel: Add a width field to regions, and use it for making miptrees in TFP. Otherwise, we would use the pitch as width of the texture, and compiz would render the pitch padding on the right hand side. --- src/mesa/drivers/dri/intel/intel_context.c | 3 ++- src/mesa/drivers/dri/intel/intel_fbo.c | 2 +- src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 7 +++++-- src/mesa/drivers/dri/intel/intel_regions.c | 16 ++++++++++------ src/mesa/drivers/dri/intel/intel_regions.h | 10 ++++++---- src/mesa/drivers/dri/intel/intel_tex_image.c | 2 +- 6 files changed, 25 insertions(+), 15 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 007dee449c..23e0f6331a 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -301,8 +301,9 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable) } else region = intel_region_alloc_for_handle(intel, buffers[i].cpp, - buffers[i].pitch / buffers[i].cpp, + drawable->w, drawable->h, + buffers[i].pitch / buffers[i].cpp, buffers[i].name, region_name); diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c index 5bd2ebfdcf..6570f6e69b 100644 --- a/src/mesa/drivers/dri/intel/intel_fbo.c +++ b/src/mesa/drivers/dri/intel/intel_fbo.c @@ -296,7 +296,7 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, DBG("Allocating %d x %d Intel RBO (pitch %d)\n", width, height, pitch); - irb->region = intel_region_alloc(intel, cpp, pitch, height); + irb->region = intel_region_alloc(intel, cpp, width, height, pitch); if (!irb->region) return GL_FALSE; /* out of memory? */ diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index 9be7e02eff..f28fac8394 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -117,7 +117,10 @@ intel_miptree_create(struct intel_context *intel, return NULL; mt->region = intel_region_alloc(intel, - mt->cpp, mt->pitch, mt->total_height); + mt->cpp, + mt->pitch, + mt->total_height, + mt->pitch); if (!mt->region) { free(mt); @@ -141,7 +144,7 @@ intel_miptree_create_for_region(struct intel_context *intel, mt = intel_miptree_create_internal(intel, target, internal_format, first_level, last_level, - region->pitch, region->height, depth0, + region->width, region->height, 1, region->cpp, compress_byte); if (!mt) return mt; diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c index 1cfc8ddd64..cb0f4ba083 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.c +++ b/src/mesa/drivers/dri/intel/intel_regions.c @@ -105,7 +105,8 @@ intel_set_region_tiling_gem(struct intel_context *intel, static struct intel_region * intel_region_alloc_internal(struct intel_context *intel, - GLuint cpp, GLuint pitch, GLuint height, + GLuint cpp, + GLuint width, GLuint height, GLuint pitch, dri_bo *buffer) { struct intel_region *region; @@ -117,8 +118,9 @@ intel_region_alloc_internal(struct intel_context *intel, region = calloc(sizeof(*region), 1); region->cpp = cpp; + region->width = width; + region->height = height; region->pitch = pitch; - region->height = height; /* needed? */ region->refcount = 1; region->buffer = buffer; @@ -131,19 +133,20 @@ intel_region_alloc_internal(struct intel_context *intel, struct intel_region * intel_region_alloc(struct intel_context *intel, - GLuint cpp, GLuint pitch, GLuint height) + GLuint cpp, GLuint width, GLuint height, GLuint pitch) { dri_bo *buffer; buffer = dri_bo_alloc(intel->bufmgr, "region", pitch * cpp * height, 64); - return intel_region_alloc_internal(intel, cpp, pitch, height, buffer); + return intel_region_alloc_internal(intel, cpp, width, height, pitch, buffer); } struct intel_region * intel_region_alloc_for_handle(struct intel_context *intel, - GLuint cpp, GLuint pitch, GLuint height, + GLuint cpp, + GLuint width, GLuint height, GLuint pitch, GLuint handle, const char *name) { struct intel_region *region; @@ -151,7 +154,8 @@ intel_region_alloc_for_handle(struct intel_context *intel, buffer = intel_bo_gem_create_from_name(intel->bufmgr, name, handle); - region = intel_region_alloc_internal(intel, cpp, pitch, height, buffer); + region = intel_region_alloc_internal(intel, cpp, + width, height, pitch, buffer); if (region == NULL) return region; diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h index a561de485e..62eb049fba 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.h +++ b/src/mesa/drivers/dri/intel/intel_regions.h @@ -55,8 +55,9 @@ struct intel_region dri_bo *buffer; /**< buffer manager's buffer */ GLuint refcount; /**< Reference count for region */ GLuint cpp; /**< bytes per pixel */ - GLuint pitch; /**< in pixels */ + GLuint width; /**< in pixels */ GLuint height; /**< in pixels */ + GLuint pitch; /**< in pixels */ GLubyte *map; /**< only non-NULL when region is actually mapped */ GLuint map_refcount; /**< Reference count for mapping */ @@ -72,12 +73,13 @@ struct intel_region * copied by calling intel_reference_region(). */ struct intel_region *intel_region_alloc(struct intel_context *intel, - GLuint cpp, - GLuint pitch, GLuint height); + GLuint cpp, GLuint width, + GLuint height, GLuint pitch); struct intel_region * intel_region_alloc_for_handle(struct intel_context *intel, - GLuint cpp, GLuint pitch, GLuint height, + GLuint cpp, + GLuint width, GLuint height, GLuint pitch, unsigned int handle, const char *name); void intel_region_reference(struct intel_region **dst, diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index 70b0b3e245..1820d3dc05 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -757,7 +757,7 @@ intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv) intelObj->mt = mt; texImage = _mesa_get_tex_image(&intel->ctx, texObj, target, level); _mesa_init_teximage_fields(&intel->ctx, target, texImage, - rb->region->pitch, rb->region->height, 1, + rb->region->width, rb->region->height, 1, 0, internalFormat); intelImage = intel_texture_image(texImage); -- cgit v1.2.3 From d2e0504d4e1d00bfc59d6661f9f0d33db1768f42 Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Sat, 13 Sep 2008 14:23:14 -0600 Subject: mesa: #include --- src/mesa/glapi/glthread.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/mesa') diff --git a/src/mesa/glapi/glthread.c b/src/mesa/glapi/glthread.c index 813d6f9dbc..b818f4e26e 100644 --- a/src/mesa/glapi/glthread.c +++ b/src/mesa/glapi/glthread.c @@ -34,6 +34,7 @@ #endif #include +#include #include "glthread.h" -- cgit v1.2.3 From 11a889db8f182fb1d11c998e5156deac8ca9f91d Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Sat, 13 Sep 2008 14:23:39 -0600 Subject: mesa: return after _mesa_problem() calls --- src/mesa/main/texformat_tmp.h | 1 + src/mesa/swrast/s_texfilter.c | 2 ++ 2 files changed, 3 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h index 63939f4011..7499ba7b36 100644 --- a/src/mesa/main/texformat_tmp.h +++ b/src/mesa/main/texformat_tmp.h @@ -1117,6 +1117,7 @@ static void FETCH(ci8)( const struct gl_texture_image *texImage, break;; default: _mesa_problem(ctx, "Bad palette format in fetch_texel_ci8"); + return; } #if CHAN_TYPE == GL_UNSIGNED_BYTE COPY_4UBV(texel, texelUB); diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index c9e9db132f..ee6131649a 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -342,6 +342,7 @@ lerp_rgba_3d(GLchan result[4], GLfloat a, GLfloat b, GLfloat c, break; \ default: \ _mesa_problem(ctx, "Bad wrap mode"); \ + return; \ } \ } @@ -462,6 +463,7 @@ lerp_rgba_3d(GLchan result[4], GLfloat a, GLfloat b, GLfloat c, break; \ default: \ _mesa_problem(ctx, "Bad wrap mode"); \ + return; \ } \ } -- cgit v1.2.3 From 87ccb9504dfda502746c3a00eb607f1837dd265d Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Sat, 13 Sep 2008 14:25:02 -0600 Subject: i915: fix himask constant init for 64-bit build --- src/mesa/drivers/dri/i915/i915_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i915/i915_debug.c b/src/mesa/drivers/dri/i915/i915_debug.c index 8eb1c5b49e..eb1a052b9e 100644 --- a/src/mesa/drivers/dri/i915/i915_debug.c +++ b/src/mesa/drivers/dri/i915/i915_debug.c @@ -177,7 +177,7 @@ static GLboolean debug_variable_length_prim( struct debug_stream *stream ) #define BITS( dw, hi, lo, ... ) \ do { \ - unsigned himask = ~0UL >> (31 - (hi)); \ + unsigned himask = 0xffffffffU >> (31 - (hi)); \ PRINTF("\t\t "); \ PRINTF(__VA_ARGS__); \ PRINTF(": 0x%x\n", ((dw) & himask) >> (lo)); \ -- cgit v1.2.3 From 68a19e353e1f68d6a5725c6bcb5d89949a4efe3f Mon Sep 17 00:00:00 2001 From: Jakub Bogusz Date: Sat, 13 Sep 2008 14:35:02 -0600 Subject: tdfx: fix crash and lack of visuals bug --- src/mesa/drivers/dri/tdfx/tdfx_screen.c | 77 +++++++++++---------------------- 1 file changed, 25 insertions(+), 52 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/tdfx/tdfx_screen.c b/src/mesa/drivers/dri/tdfx/tdfx_screen.c index fd21d8d51b..bb1f362540 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_screen.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_screen.c @@ -65,6 +65,7 @@ DRI_CONF_END; static const __DRIextension *tdfxExtensions[] = { &driReadDrawableExtension, + NULL }; static const GLuint __driNConfigOptions = 1; @@ -350,12 +351,7 @@ tdfxFillInModes(__DRIscreenPrivate *psp, unsigned stencil_bits, GLboolean have_back_buffer) { - __DRIconfig **configs, **c; - __GLcontextModes *m; - unsigned num_modes; - unsigned vis[2] = { GLX_TRUE_COLOR, GLX_DIRECT_COLOR }; unsigned deep = (depth_bits > 17); - unsigned i, db, depth, accum, stencil; /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy * enough to add support. Basically, if a context is created with an @@ -363,55 +359,32 @@ tdfxFillInModes(__DRIscreenPrivate *psp, * will never be used. */ - num_modes = (depth_bits == 16) ? 32 : 16; - - configs = _mesa_malloc(num_modes * sizeof *configs); - c = configs; - - for (i = 0; i <= 1; i++) { - for (db = 0; db <= 1; db++) { - for (depth = 0; depth <= 1; depth++) { - for (accum = 0; accum <= 1; accum++) { - for (stencil = 0; stencil <= !deep; stencil++) { - *c = _mesa_malloc(sizeof **c); - m = &(*c++)->modes; - if (deep) stencil = depth; - m->redBits = deep ? 8 : 5; - m->greenBits = deep ? 8 : 6; - m->blueBits = deep ? 8 : 5; - m->alphaBits = deep ? 8 : 0; - m->redMask = deep ?0xFF000000 :0x0000F800; - m->greenMask = deep ?0x00FF0000 :0x000007E0; - m->blueMask = deep ?0x0000FF00 :0x0000001F; - m->alphaMask = deep ? 0x000000FF : 0; - m->rgbBits = m->redBits + m->greenBits + - m->blueBits + m->alphaBits; - m->accumRedBits = accum ? 16 : 0; - m->accumGreenBits = accum ? 16 : 0; - m->accumBlueBits = accum ? 16 : 0; - m->accumAlphaBits = (accum && deep) ? 16 : 0; - m->stencilBits = stencil ? 8 : 0; - m->depthBits = deep - ? (depth ? 24 : 0) - : (depth ? 0 : depth_bits); - m->visualType = vis[i]; - m->renderType = GLX_RGBA_BIT; - m->drawableType = GLX_WINDOW_BIT; - m->rgbMode = GL_TRUE; - m->doubleBufferMode = db ? GL_TRUE : GL_FALSE; - if (db) - m->swapMethod = GLX_SWAP_UNDEFINED_OML; - m->visualRating = ((stencil && !deep) || accum) - ? GLX_SLOW_CONFIG - : GLX_NONE; - if (deep) stencil = 0; - } - } - } - } + static const GLenum db_modes[2] = { GLX_NONE, GLX_SWAP_UNDEFINED_OML }; + uint8_t depth_bits_array[4]; + uint8_t stencil_bits_array[4]; + if(deep) { + depth_bits_array[0] = 0; + depth_bits_array[1] = 24; + stencil_bits_array[0] = 0; + stencil_bits_array[1] = 8; + } else { + depth_bits_array[0] = depth_bits; + depth_bits_array[1] = 0; + depth_bits_array[2] = depth_bits; + depth_bits_array[3] = 0; + stencil_bits_array[0] = 0; + stencil_bits_array[1] = 0; + stencil_bits_array[2] = 8; + stencil_bits_array[3] = 8; } - return (const __DRIconfig **) configs; + return driCreateConfigs( + deep ? GL_RGBA : GL_RGB, + deep ? GL_UNSIGNED_INT_8_8_8_8 : GL_UNSIGNED_SHORT_5_6_5, + depth_bits_array, + stencil_bits_array, + deep ? 2 : 4, + db_modes, 2); } /** -- cgit v1.2.3 From bd953e872f22690bd232a758383883100d9347d0 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 15 Sep 2008 13:47:25 +0100 Subject: mesa: get another class of degenerate dlists working Primitive begin in one dlist, end in another. --- src/mesa/main/dlist.c | 7 +++++-- src/mesa/vbo/vbo_save_api.c | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 63a00e04f5..9f6f4d96f4 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -6788,6 +6788,11 @@ _mesa_EndList(void) _mesa_error(ctx, GL_INVALID_OPERATION, "glEndList"); return; } + + /* Call before emitting END_OF_LIST, in case the driver wants to + * emit opcodes itself. + */ + ctx->Driver.EndList(ctx); (void) ALLOC_INSTRUCTION(ctx, OPCODE_END_OF_LIST, 0); @@ -6801,8 +6806,6 @@ _mesa_EndList(void) if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) mesa_print_display_list(ctx->ListState.CurrentListNum); - ctx->Driver.EndList(ctx); - ctx->ListState.CurrentList = NULL; ctx->ListState.CurrentListNum = 0; ctx->ListState.CurrentListPtr = NULL; diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index 88d573f128..f93ef3a02a 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -1045,6 +1045,30 @@ void vbo_save_NewList( GLcontext *ctx, GLuint list, GLenum mode ) void vbo_save_EndList( GLcontext *ctx ) { struct vbo_save_context *save = &vbo_context(ctx)->save; + + /* EndList called inside a (saved) Begin/End pair? + */ + if (ctx->Driver.CurrentSavePrimitive != PRIM_OUTSIDE_BEGIN_END) { + GLint i = save->prim_count - 1; + + ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END; + save->prim[i].end = 0; + save->prim[i].count = (save->vert_count - + save->prim[i].start); + + /* Make sure this vertex list gets replayed by the "loopback" + * mechanism: + */ + save->dangling_attr_ref = 1; + vbo_save_SaveFlushVertices( ctx ); + + /* Swap out this vertex format while outside begin/end. Any color, + * etc. received between here and the next begin will be compiled + * as opcodes. + */ + _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); + } + unmap_vertex_store( ctx, save->vertex_store ); assert(save->vertex_size == 0); -- cgit v1.2.3 From d36f4ef16b338f42342cac5a7f2ec55e17fc0893 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 15 Sep 2008 09:07:32 -0600 Subject: mesa: remove some assertions that are invalid during context tear-down --- src/mesa/main/bufferobj.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 1b58f5e96a..918e87246f 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -205,11 +205,14 @@ _mesa_reference_buffer_object(GLcontext *ctx, if (deleteFlag) { /* some sanity checking: don't delete a buffer still in use */ +#if 0 + /* unfortunately, these tests are invalid during context tear-down */ ASSERT(ctx->Array.ArrayBufferObj != bufObj); ASSERT(ctx->Array.ElementArrayBufferObj != bufObj); ASSERT(ctx->Array.ArrayObj->Vertex.BufferObj != bufObj); - ASSERT(ctx->Driver.DeleteBuffer); +#endif + ASSERT(ctx->Driver.DeleteBuffer); ctx->Driver.DeleteBuffer(ctx, oldObj); } -- cgit v1.2.3 From 9d48a7832b78658d2422ae5a185276c41750010d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 15 Sep 2008 17:10:04 -0600 Subject: mesa: fix MSAA enable state in update_multisample() --- src/mesa/main/state.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 7192bed4a3..d60b9a13d8 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -1067,10 +1067,10 @@ static void update_multisample(GLcontext *ctx) { ctx->Multisample._Enabled = GL_FALSE; - if (ctx->DrawBuffer) { - if (ctx->DrawBuffer->Visual.sampleBuffers) - ctx->Multisample._Enabled = GL_TRUE; - } + if (ctx->Multisample.Enabled && + ctx->DrawBuffer && + ctx->DrawBuffer->Visual.sampleBuffers) + ctx->Multisample._Enabled = GL_TRUE; } -- cgit v1.2.3 From d43951192baa7b76d3e035d689f73c1d2955cddb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Sep 2008 13:23:01 -0600 Subject: mesa: fix display list regression (check if save->prim_count > 0 in vbo_save_EndList()) --- src/mesa/vbo/vbo_save_api.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index f93ef3a02a..f69a33d817 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -1049,12 +1049,14 @@ void vbo_save_EndList( GLcontext *ctx ) /* EndList called inside a (saved) Begin/End pair? */ if (ctx->Driver.CurrentSavePrimitive != PRIM_OUTSIDE_BEGIN_END) { - GLint i = save->prim_count - 1; - ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END; - save->prim[i].end = 0; - save->prim[i].count = (save->vert_count - - save->prim[i].start); + if (save->prim_count > 0) { + GLint i = save->prim_count - 1; + ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END; + save->prim[i].end = 0; + save->prim[i].count = (save->vert_count - + save->prim[i].start); + } /* Make sure this vertex list gets replayed by the "loopback" * mechanism: -- cgit v1.2.3 From 27341a97a17b23fdf57d33f78b475a474db71e4a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Sep 2008 16:28:36 -0600 Subject: mesa: rework GLSL vertex attribute binding Calls to glBindAttribLocation() should not take effect until the next time that glLinkProgram() is called. gl_shader_program::Attributes now just contains user-defined bindings. gl_shader_program::VertexProgram->Attributes contains the actual/final bindings. --- src/mesa/main/mtypes.h | 4 +- src/mesa/shader/shader_api.c | 62 +++++++++-------- src/mesa/shader/slang/slang_link.c | 139 +++++++++++++++++++------------------ src/mesa/shader/slang/slang_link.h | 8 +-- 4 files changed, 110 insertions(+), 103 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 6f17e46d0e..f06e4a446c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2125,12 +2125,14 @@ struct gl_shader_program GLuint NumShaders; /**< number of attached shaders */ struct gl_shader **Shaders; /**< List of attached the shaders */ + /** User-defined attribute bindings (glBindAttribLocation) */ + struct gl_program_parameter_list *Attributes; + /* post-link info: */ struct gl_vertex_program *VertexProgram; /**< Linked vertex program */ struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */ struct gl_uniform_list *Uniforms; struct gl_program_parameter_list *Varying; - struct gl_program_parameter_list *Attributes; /**< Vertex attributes */ GLboolean LinkStatus; /**< GL_LINK_STATUS */ GLboolean Validated; GLchar *InfoLog; diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 64b023119b..430d165a82 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 7.1 + * Version: 7.2 * * Copyright (C) 2004-2008 Brian Paul All Rights Reserved. * @@ -492,10 +492,14 @@ _mesa_get_attrib_location(GLcontext *ctx, GLuint program, if (!name) return -1; - if (shProg->Attributes) { - GLint i = _mesa_lookup_parameter_index(shProg->Attributes, -1, name); - if (i >= 0) { - return shProg->Attributes->Parameters[i].StateIndexes[0]; + if (shProg->VertexProgram) { + const struct gl_program_parameter_list *attribs = + shProg->VertexProgram->Base.Attributes; + if (attribs) { + GLint i = _mesa_lookup_parameter_index(attribs, -1, name); + if (i >= 0) { + return attribs->Parameters[i].StateIndexes[0]; + } } } return -1; @@ -508,7 +512,7 @@ _mesa_bind_attrib_location(GLcontext *ctx, GLuint program, GLuint index, { struct gl_shader_program *shProg; const GLint size = -1; /* unknown size */ - GLint i, oldIndex; + GLint i; GLenum datatype = GL_FLOAT_VEC4; shProg = _mesa_lookup_shader_program_err(ctx, program, @@ -531,14 +535,6 @@ _mesa_bind_attrib_location(GLcontext *ctx, GLuint program, GLuint index, return; } - if (shProg->LinkStatus) { - /* get current index/location for the attribute */ - oldIndex = _mesa_get_attrib_location(ctx, program, name); - } - else { - oldIndex = -1; - } - /* this will replace the current value if it's already in the list */ i = _mesa_add_attribute(shProg->Attributes, name, size, datatype, index); if (i < 0) { @@ -546,12 +542,10 @@ _mesa_bind_attrib_location(GLcontext *ctx, GLuint program, GLuint index, return; } - if (shProg->VertexProgram && oldIndex >= 0 && oldIndex != index) { - /* If the index changed, need to search/replace references to that attribute - * in the vertex program. - */ - _slang_remap_attribute(&shProg->VertexProgram->Base, oldIndex, index); - } + /* + * Note that this attribute binding won't go into effect until + * glLinkProgram is called again. + */ } @@ -763,24 +757,29 @@ _mesa_get_active_attrib(GLcontext *ctx, GLuint program, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLchar *nameOut) { + const struct gl_program_parameter_list *attribs = NULL; struct gl_shader_program *shProg; shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveAttrib"); if (!shProg) return; - if (!shProg->Attributes || index >= shProg->Attributes->NumParameters) { + if (shProg->VertexProgram) + attribs = shProg->VertexProgram->Base.Attributes; + + if (!attribs || index >= attribs->NumParameters) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveAttrib(index)"); return; } - copy_string(nameOut, maxLength, length, - shProg->Attributes->Parameters[index].Name); + copy_string(nameOut, maxLength, length, attribs->Parameters[index].Name); + if (size) - *size = shProg->Attributes->Parameters[index].Size - / sizeof_glsl_type(shProg->Attributes->Parameters[index].DataType); + *size = attribs->Parameters[index].Size + / sizeof_glsl_type(attribs->Parameters[index].DataType); + if (type) - *type = shProg->Attributes->Parameters[index].DataType; + *type = attribs->Parameters[index].DataType; } @@ -878,6 +877,7 @@ static void _mesa_get_programiv(GLcontext *ctx, GLuint program, GLenum pname, GLint *params) { + const struct gl_program_parameter_list *attribs; struct gl_shader_program *shProg = _mesa_lookup_shader_program(ctx, program); @@ -886,6 +886,11 @@ _mesa_get_programiv(GLcontext *ctx, GLuint program, return; } + if (shProg->VertexProgram) + attribs = shProg->VertexProgram->Base.Attributes; + else + attribs = NULL; + switch (pname) { case GL_DELETE_STATUS: *params = shProg->DeletePending; @@ -903,11 +908,10 @@ _mesa_get_programiv(GLcontext *ctx, GLuint program, *params = shProg->NumShaders; break; case GL_ACTIVE_ATTRIBUTES: - *params = shProg->Attributes ? shProg->Attributes->NumParameters : 0; + *params = attribs ? attribs->NumParameters : 0; break; case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: - *params = _mesa_longest_parameter_name(shProg->Attributes, - PROGRAM_INPUT) + 1; + *params = _mesa_longest_parameter_name(attribs, PROGRAM_INPUT) + 1; break; case GL_ACTIVE_UNIFORMS: *params = shProg->Uniforms ? shProg->Uniforms->NumUniforms : 0; diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index 57dbfc2388..30035b4fee 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.2 * - * Copyright (C) 2007 Brian Paul All Rights Reserved. + * Copyright (C) 2008 Brian Paul 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"), @@ -215,74 +215,110 @@ link_uniform_vars(struct gl_shader_program *shProg, * For example, if the vertex shader declared "attribute vec4 foobar" we'll * allocate a generic vertex attribute for "foobar" and plug that value into * the vertex program instructions. + * But if the user called glBindAttributeLocation(), those bindings will + * have priority. */ static GLboolean _slang_resolve_attributes(struct gl_shader_program *shProg, - struct gl_program *prog) + const struct gl_program *origProg, + struct gl_program *linkedProg) { + GLint attribMap[MAX_VERTEX_ATTRIBS]; GLuint i, j; GLbitfield usedAttributes; - assert(prog->Target == GL_VERTEX_PROGRAM_ARB); + assert(origProg != linkedProg); + assert(origProg->Target == GL_VERTEX_PROGRAM_ARB); + assert(linkedProg->Target == GL_VERTEX_PROGRAM_ARB); if (!shProg->Attributes) shProg->Attributes = _mesa_new_parameter_list(); + if (linkedProg->Attributes) { + _mesa_free_parameter_list(linkedProg->Attributes); + } + linkedProg->Attributes = _mesa_new_parameter_list(); + + /* Build a bitmask indicating which attribute indexes have been * explicitly bound by the user with glBindAttributeLocation(). */ usedAttributes = 0x0; for (i = 0; i < shProg->Attributes->NumParameters; i++) { GLint attr = shProg->Attributes->Parameters[i].StateIndexes[0]; - usedAttributes |= attr; + usedAttributes |= (1 << attr); + } + + /* initialize the generic attribute map entries to -1 */ + for (i = 0; i < MAX_VERTEX_ATTRIBS; i++) { + attribMap[i] = -1; } /* * Scan program for generic attribute references */ - for (i = 0; i < prog->NumInstructions; i++) { - struct prog_instruction *inst = prog->Instructions + i; + for (i = 0; i < linkedProg->NumInstructions; i++) { + struct prog_instruction *inst = linkedProg->Instructions + i; for (j = 0; j < 3; j++) { if (inst->SrcReg[j].File == PROGRAM_INPUT && inst->SrcReg[j].Index >= VERT_ATTRIB_GENERIC0) { - /* this is a generic attrib */ - const GLint k = inst->SrcReg[j].Index - VERT_ATTRIB_GENERIC0; - const char *name = prog->Attributes->Parameters[k].Name; - /* See if this attrib name is in the program's attribute list - * (i.e. was bound by the user). + /* + * OK, we've found a generic vertex attribute reference. */ - GLint index = _mesa_lookup_parameter_index(shProg->Attributes, - -1, name); - GLint attr; - if (index >= 0) { - /* found, user must have specified a binding */ - attr = shProg->Attributes->Parameters[index].StateIndexes[0]; - } - else { - /* Not found, choose our own attribute number. - * Start at 1 since generic attribute 0 always aliases - * glVertex/position. + const GLint k = inst->SrcReg[j].Index - VERT_ATTRIB_GENERIC0; + + GLint attr = attribMap[k]; + + if (attr < 0) { + /* Need to figure out attribute mapping now. + */ + const char *name = origProg->Attributes->Parameters[k].Name; + const GLint size = origProg->Attributes->Parameters[k].Size; + const GLenum type =origProg->Attributes->Parameters[k].DataType; + GLint index, attr; + + /* See if there's a user-defined attribute binding for + * this name. */ - GLint size = prog->Attributes->Parameters[k].Size; - GLenum datatype = prog->Attributes->Parameters[k].DataType; - for (attr = 1; attr < MAX_VERTEX_ATTRIBS; attr++) { - if (((1 << attr) & usedAttributes) == 0) - break; + index = _mesa_lookup_parameter_index(shProg->Attributes, + -1, name); + if (index >= 0) { + /* Found a user-defined binding */ + attr = shProg->Attributes->Parameters[index].StateIndexes[0]; } - if (attr == MAX_VERTEX_ATTRIBS) { - /* too many! XXX record error log */ - return GL_FALSE; + else { + /* No user-defined binding, choose our own attribute number. + * Start at 1 since generic attribute 0 always aliases + * glVertex/position. + */ + for (attr = 1; attr < MAX_VERTEX_ATTRIBS; attr++) { + if (((1 << attr) & usedAttributes) == 0) + break; + } + if (attr == MAX_VERTEX_ATTRIBS) { + link_error(shProg, "Too many vertex attributes"); + return GL_FALSE; + } + + /* mark this attribute as used */ + usedAttributes |= (1 << attr); } - _mesa_add_attribute(shProg->Attributes, name, size, datatype,attr); - /* set the attribute as used */ - usedAttributes |= 1<attrib binding so it can be queried + * with glGetAttributeLocation(). + */ + _mesa_add_attribute(linkedProg->Attributes, name, + size, type, attr); } + /* update the instruction's src reg */ inst->SrcReg[j].Index = VERT_ATTRIB_GENERIC0 + attr; } } } + return GL_TRUE; } @@ -344,36 +380,6 @@ _slang_update_inputs_outputs(struct gl_program *prog) } -/** - * Scan a vertex program looking for instances of - * (PROGRAM_INPUT, VERT_ATTRIB_GENERIC0 + oldAttrib) and replace with - * (PROGRAM_INPUT, VERT_ATTRIB_GENERIC0 + newAttrib). - * This is used when the user calls glBindAttribLocation on an already linked - * shader program. - */ -void -_slang_remap_attribute(struct gl_program *prog, GLuint oldAttrib, GLuint newAttrib) -{ - GLuint i, j; - - assert(prog->Target == GL_VERTEX_PROGRAM_ARB); - - for (i = 0; i < prog->NumInstructions; i++) { - struct prog_instruction *inst = prog->Instructions + i; - for (j = 0; j < 3; j++) { - if (inst->SrcReg[j].File == PROGRAM_INPUT) { - if (inst->SrcReg[j].Index == VERT_ATTRIB_GENERIC0 + oldAttrib) { - inst->SrcReg[j].Index = VERT_ATTRIB_GENERIC0 + newAttrib; - } - } - } - } - - _slang_update_inputs_outputs(prog); -} - - - /** cast wrapper */ static struct gl_vertex_program * vertex_program(struct gl_program *prog) @@ -492,9 +498,8 @@ _slang_link(GLcontext *ctx, /*_mesa_print_uniforms(shProg->Uniforms);*/ if (shProg->VertexProgram) { - if (!_slang_resolve_attributes(shProg, &shProg->VertexProgram->Base)) { - /*goto cleanup;*/ - _mesa_problem(ctx, "_slang_resolve_attributes() failed"); + if (!_slang_resolve_attributes(shProg, &vertProg->Base, + &shProg->VertexProgram->Base)) { return; } } diff --git a/src/mesa/shader/slang/slang_link.h b/src/mesa/shader/slang/slang_link.h index 8ef8a6b4b3..2b44d20787 100644 --- a/src/mesa/shader/slang/slang_link.h +++ b/src/mesa/shader/slang/slang_link.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.2 * - * Copyright (C) 2007 Brian Paul All Rights Reserved. + * Copyright (C) 2008 Brian Paul 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"), @@ -32,10 +32,6 @@ extern void _slang_link(GLcontext *ctx, GLhandleARB h, struct gl_shader_program *shProg); -extern void -_slang_remap_attribute(struct gl_program *prog, GLuint oldAttrib, - GLuint newAttrib); - #endif -- cgit v1.2.3 From 904f31a62444d9f7e9b12ddafaa4beeb7fed6dfa Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 16 Sep 2008 17:01:06 -0700 Subject: intel: Destroy bufmgr in screen destroy, not context. Caused server crashes on second context creation since 7e0bbdcf033981282978554c2e68ce48b55aa291. Bug #17600. --- src/mesa/drivers/dri/intel/intel_context.c | 2 -- src/mesa/drivers/dri/intel/intel_screen.c | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 23e0f6331a..2ca5732606 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -822,8 +822,6 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv) /* free the Mesa context */ _mesa_free_context_data(&intel->ctx); - - dri_bufmgr_destroy(intel->bufmgr); } } diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index de098e5b72..373e0e155e 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -309,6 +309,7 @@ intelDestroyScreen(__DRIscreenPrivate * sPriv) { intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private; + dri_bufmgr_destroy(intelScreen->bufmgr); intelUnmapScreenRegions(intelScreen); FREE(intelScreen); -- cgit v1.2.3 From 5e530d8384b0d9bb867d6407315587c84a443902 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Sep 2008 09:05:04 -0600 Subject: mesa: fix bug in previous changes to _slang_resolve_attributes() --- src/mesa/shader/slang/slang_link.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index 30035b4fee..a6390846b2 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -275,7 +275,7 @@ _slang_resolve_attributes(struct gl_shader_program *shProg, const char *name = origProg->Attributes->Parameters[k].Name; const GLint size = origProg->Attributes->Parameters[k].Size; const GLenum type =origProg->Attributes->Parameters[k].DataType; - GLint index, attr; + GLint index; /* See if there's a user-defined attribute binding for * this name. @@ -313,6 +313,8 @@ _slang_resolve_attributes(struct gl_shader_program *shProg, size, type, attr); } + assert(attr >= 0); + /* update the instruction's src reg */ inst->SrcReg[j].Index = VERT_ATTRIB_GENERIC0 + attr; } -- cgit v1.2.3