From 2956a0c8a8395e4d9ae00888aeb88ea5c38b89ad Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 14 Dec 2006 00:34:44 +0100 Subject: submit vertex weights to make World of Warcraft maybe happy (bug 8250) submit the vertex weights to hw, which will enable broken vertex programs errorneously using them to work. Note however that this will only work if glWeight is used, there is no code in mesa at all to deal with weight vertex array (glWeightPointerARB). --- src/mesa/drivers/dri/r200/r200_context.h | 1 + src/mesa/drivers/dri/r200/r200_maos_arrays.c | 19 ++++++++++++++++++- src/mesa/drivers/dri/r200/r200_vertprog.c | 1 - 3 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/r200/r200_context.h b/src/mesa/drivers/dri/r200/r200_context.h index fa38a78e26..44c67b68cb 100644 --- a/src/mesa/drivers/dri/r200/r200_context.h +++ b/src/mesa/drivers/dri/r200/r200_context.h @@ -735,6 +735,7 @@ struct r200_tcl_info { GLuint *Elts; struct r200_dma_region indexed_verts; + struct r200_dma_region weight; struct r200_dma_region obj; struct r200_dma_region rgba; struct r200_dma_region spec; diff --git a/src/mesa/drivers/dri/r200/r200_maos_arrays.c b/src/mesa/drivers/dri/r200/r200_maos_arrays.c index 39c1f68911..270dc35a46 100644 --- a/src/mesa/drivers/dri/r200/r200_maos_arrays.c +++ b/src/mesa/drivers/dri/r200/r200_maos_arrays.c @@ -423,7 +423,21 @@ void r200EmitArrays( GLcontext *ctx, GLuint inputs ) count ); } component[nr++] = &rmesa->tcl.generic[geninput]; - vfmt0 |= R200_VTX_W0 | R200_VTX_Z0; + vfmt0 |= R200_VTX_W0 | R200_VTX_Z0; + } + + if (inputs & VERT_BIT_WEIGHT) { + if (!rmesa->tcl.weight.buf) + emit_vector( ctx, + &rmesa->tcl.weight, + (char *)VB->AttribPtr[VERT_ATTRIB_WEIGHT]->data, + VB->AttribPtr[VERT_ATTRIB_WEIGHT]->size, + VB->AttribPtr[VERT_ATTRIB_WEIGHT]->stride, + count); + + assert(VB->AttribPtr[VERT_ATTRIB_WEIGHT]->size <= 4); + vfmt0 |= VB->AttribPtr[VERT_ATTRIB_WEIGHT]->size << R200_VTX_WEIGHT_COUNT_SHIFT; + component[nr++] = &rmesa->tcl.weight; } if (inputs & VERT_BIT_NORMAL) { @@ -672,6 +686,9 @@ void r200ReleaseArrays( GLcontext *ctx, GLuint newinputs ) if (newinputs & VERT_BIT_POS) r200ReleaseDmaRegion( rmesa, &rmesa->tcl.obj, __FUNCTION__ ); + if (newinputs & VERT_BIT_WEIGHT) + r200ReleaseDmaRegion( rmesa, &rmesa->tcl.weight, __FUNCTION__ ); + if (newinputs & VERT_BIT_NORMAL) r200ReleaseDmaRegion( rmesa, &rmesa->tcl.norm, __FUNCTION__ ); diff --git a/src/mesa/drivers/dri/r200/r200_vertprog.c b/src/mesa/drivers/dri/r200/r200_vertprog.c index 899e84caa0..491701b796 100644 --- a/src/mesa/drivers/dri/r200/r200_vertprog.c +++ b/src/mesa/drivers/dri/r200/r200_vertprog.c @@ -503,7 +503,6 @@ static GLboolean r200_translate_vertex_program(GLcontext *ctx, struct r200_verte array_count++; } if (mesa_vp->Base.InputsRead & VERT_BIT_WEIGHT) { - /* we don't actually handle that later. Then again, we don't have to... */ vp->inputs[VERT_ATTRIB_WEIGHT] = 12; array_count++; } -- cgit v1.2.3 From 9c09259b8bef8f120cc6f4bb1a44f0eae37d71b3 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Thu, 14 Dec 2006 10:01:43 +0100 Subject: _mesa_swizzle_ubyte_image: Only use single swizzle_copy call when strides match. This fixes texture data corruption with glTexSubimage (and probably glTexImage under some circumstances) with the texstore swizzle path. --- src/mesa/main/texstore.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 89563842c2..87f8fa7a0d 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -808,7 +808,8 @@ _mesa_swizzle_ubyte_image(GLcontext *ctx, /* _mesa_printf("map %d %d %d %d\n", map[0], map[1], map[2], map[3]); */ - if (srcRowStride == srcWidth * srcComponents && + if (srcRowStride == dstRowStride && + srcRowStride == srcWidth * srcComponents && dimensions < 3) { /* 1 and 2D images only */ GLubyte *dstImage = (GLubyte *) dstAddr -- cgit v1.2.3 From 4cb09df015068f6d75e6457b6c98836dd58aaf29 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Thu, 14 Dec 2006 10:24:09 +0100 Subject: intelTexSubimage: Fix last parameter for intel_miptree_image_map(). --- src/mesa/drivers/dri/i915tex/intel_tex_subimage.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i915tex/intel_tex_subimage.c b/src/mesa/drivers/dri/i915tex/intel_tex_subimage.c index 25a2dca685..3935787806 100644 --- a/src/mesa/drivers/dri/i915tex/intel_tex_subimage.c +++ b/src/mesa/drivers/dri/i915tex/intel_tex_subimage.c @@ -50,7 +50,6 @@ intelTexSubimage(GLcontext * ctx, { struct intel_context *intel = intel_context(ctx); struct intel_texture_image *intelImage = intel_texture_image(texImage); - GLuint dstImageStride; GLuint dstRowStride; DBG("%s target %s level %d offset %d,%d %dx%d\n", __FUNCTION__, @@ -79,7 +78,7 @@ intelTexSubimage(GLcontext * ctx, intelImage->face, intelImage->level, &dstRowStride, - &dstImageStride); + texImage->ImageOffsets); assert(dstRowStride); -- cgit v1.2.3 From 5f8a3e586f21219d02912635a93ce312bcf5987c Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Thu, 14 Dec 2006 10:49:26 +0100 Subject: intel_batchbuffer_flush: Don't assert cliprects when lock is not held. This is a legitimate situation when copying texture data between mipmap trees. --- src/mesa/drivers/dri/i915tex/intel_batchbuffer.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c index b4e0b74f16..be2750d041 100644 --- a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c @@ -252,6 +252,7 @@ intel_batchbuffer_flush(struct intel_batchbuffer *batch) { struct intel_context *intel = batch->intel; GLuint used = batch->ptr - batch->map; + GLboolean was_locked = intel->locked; if (used == 0) return batch->last_fence; @@ -278,17 +279,14 @@ intel_batchbuffer_flush(struct intel_batchbuffer *batch) /* TODO: Just pass the relocation list and dma buffer up to the * kernel. */ - if (!intel->locked) { - assert(!(batch->flags & INTEL_BATCH_NO_CLIPRECTS)); - + if (!was_locked) LOCK_HARDWARE(intel); - do_flush_locked(batch, used, GL_FALSE, GL_TRUE); + + do_flush_locked(batch, used, !(batch->flags & INTEL_BATCH_CLIPRECTS), + GL_FALSE); + + if (!was_locked) UNLOCK_HARDWARE(intel); - } - else { - GLboolean ignore_cliprects = !(batch->flags & INTEL_BATCH_CLIPRECTS); - do_flush_locked(batch, used, ignore_cliprects, GL_FALSE); - } /* Reset the buffer: */ -- cgit v1.2.3 From cc1afed6718882d13ab66ba0bbeaab6334e0629c Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Thu, 14 Dec 2006 10:56:10 +0100 Subject: intel_finalize_mipmap_tree: Add more conditions for rebuilding mipmap trees. These are taken from the i965 driver and fix corruption of some mipmap levels under some circumsances with 945 chipsets at least. Also flush the batchbuffer after copying data between trees, or some apps fail an assertion elsewhere. --- src/mesa/drivers/dri/i915tex/intel_tex_validate.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i915tex/intel_tex_validate.c b/src/mesa/drivers/dri/i915tex/intel_tex_validate.c index 5f82dfa19e..e73c9c2f21 100644 --- a/src/mesa/drivers/dri/i915tex/intel_tex_validate.c +++ b/src/mesa/drivers/dri/i915tex/intel_tex_validate.c @@ -2,6 +2,7 @@ #include "macros.h" #include "intel_context.h" +#include "intel_batchbuffer.h" #include "intel_mipmap_tree.h" #include "intel_tex.h" @@ -155,9 +156,15 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit) * leaving the tree alone. */ if (intelObj->mt && - ((intelObj->mt->first_level > intelObj->firstLevel) || - (intelObj->mt->last_level < intelObj->lastLevel) || - (intelObj->mt->internal_format != firstImage->base.InternalFormat))) { + (intelObj->mt->target != intelObj->base.Target || + intelObj->mt->internal_format != firstImage->base.InternalFormat || + intelObj->mt->first_level != intelObj->firstLevel || + intelObj->mt->last_level != intelObj->lastLevel || + intelObj->mt->width0 != firstImage->base.Width || + intelObj->mt->height0 != firstImage->base.Height || + intelObj->mt->depth0 != firstImage->base.Depth || + intelObj->mt->cpp != firstImage->base.TexFormat->TexelBytes || + intelObj->mt->compressed != firstImage->base.IsCompressed)) { intel_miptree_release(intel, &intelObj->mt); } @@ -198,6 +205,8 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit) } } + intel_batchbuffer_flush(intel->batch); + return GL_TRUE; } -- cgit v1.2.3 From 3416ef303af633668cece0b199b4a8b2388c1e2f Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Thu, 14 Dec 2006 12:32:41 +0100 Subject: Share code to lay out >= 945 style 2D mipmaps between i915tex and i965 drivers. Use the i965 version as it has some fixes over the i915tex version. --- src/mesa/drivers/dri/i915tex/Makefile | 5 +- src/mesa/drivers/dri/i915tex/i915_tex_layout.c | 54 +--------------- src/mesa/drivers/dri/i915tex/intel_tex_layout.c | 1 + src/mesa/drivers/dri/i965/Makefile | 5 +- src/mesa/drivers/dri/i965/brw_tex_layout.c | 55 +---------------- src/mesa/drivers/dri/i965/intel_tex_layout.c | 1 + src/mesa/drivers/dri/intel/intel_tex_layout.c | 82 +++++++++++++++++++++++++ src/mesa/drivers/dri/intel/intel_tex_layout.h | 41 +++++++++++++ 8 files changed, 139 insertions(+), 105 deletions(-) create mode 120000 src/mesa/drivers/dri/i915tex/intel_tex_layout.c create mode 120000 src/mesa/drivers/dri/i965/intel_tex_layout.c create mode 100644 src/mesa/drivers/dri/intel/intel_tex_layout.c create mode 100644 src/mesa/drivers/dri/intel/intel_tex_layout.h (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i915tex/Makefile b/src/mesa/drivers/dri/i915tex/Makefile index 94879d209f..3b3f3f5a3f 100644 --- a/src/mesa/drivers/dri/i915tex/Makefile +++ b/src/mesa/drivers/dri/i915tex/Makefile @@ -20,6 +20,7 @@ DRIVER_SOURCES = \ intel_batchbuffer.c \ intel_mipmap_tree.c \ i915_tex_layout.c \ + intel_tex_layout.c \ intel_tex_image.c \ intel_tex_subimage.c \ intel_tex_copy.c \ @@ -59,8 +60,10 @@ C_SOURCES = \ ASM_SOURCES = - +DRIVER_DEFINES = -I../intel include ../Makefile.template +intel_tex_layout.o: ../intel/intel_tex_layout.c + symlinks: diff --git a/src/mesa/drivers/dri/i915tex/i915_tex_layout.c b/src/mesa/drivers/dri/i915tex/i915_tex_layout.c index e9360ecea8..fc98611d31 100644 --- a/src/mesa/drivers/dri/i915tex/i915_tex_layout.c +++ b/src/mesa/drivers/dri/i915tex/i915_tex_layout.c @@ -30,6 +30,7 @@ */ #include "intel_mipmap_tree.h" +#include "intel_tex_layout.h" #include "macros.h" #include "intel_context.h" @@ -52,12 +53,6 @@ static GLint step_offsets[6][2] = { {0, 2}, {-1, 1} }; -static GLuint -minify(GLuint d) -{ - return MAX2(1, d >> 1); -} - GLboolean i915_miptree_layout(struct intel_mipmap_tree * mt) { @@ -322,52 +317,9 @@ i945_miptree_layout(struct intel_mipmap_tree * mt) case GL_TEXTURE_1D: case GL_TEXTURE_2D: - case GL_TEXTURE_RECTANGLE_ARB:{ - GLuint x = 0; - GLuint y = 0; - GLuint width = mt->width0; - GLuint height = mt->height0; - GLint align_h = 2; - - mt->pitch = ((mt->width0 * mt->cpp + 3) & ~3) / mt->cpp; - mt->total_height = 0; - - for (level = mt->first_level; level <= mt->last_level; level++) { - GLuint img_height; - - intel_miptree_set_level_info(mt, level, 1, - x, y, - width, - mt->compressed ? height/4 : height, 1); - - - if (mt->compressed) - img_height = MAX2(1, height / 4); - else - img_height = MAX2(align_h, height); - - /* LPT change: step right after second mipmap. - */ - if (level == mt->first_level + 1) { - x += mt->pitch / 2; - x = (x + 3) & ~3; - } - else { - y += img_height; - y += align_h - 1; - y &= ~(align_h - 1); - } - - /* Because the images are packed better, the final offset - * might not be the maximal one: - */ - mt->total_height = MAX2(mt->total_height, y); - - width = minify(width); - height = minify(height); - } + case GL_TEXTURE_RECTANGLE_ARB: + i945_miptree_layout_2d(mt); break; - } default: _mesa_problem(NULL, "Unexpected tex target in i945_miptree_layout()"); } diff --git a/src/mesa/drivers/dri/i915tex/intel_tex_layout.c b/src/mesa/drivers/dri/i915tex/intel_tex_layout.c new file mode 120000 index 0000000000..fe61b44194 --- /dev/null +++ b/src/mesa/drivers/dri/i915tex/intel_tex_layout.c @@ -0,0 +1 @@ +../intel/intel_tex_layout.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/i965/Makefile b/src/mesa/drivers/dri/i965/Makefile index 213eac895c..f0a6fa5740 100644 --- a/src/mesa/drivers/dri/i965/Makefile +++ b/src/mesa/drivers/dri/i965/Makefile @@ -20,6 +20,7 @@ DRIVER_SOURCES = \ intel_pixel_bitmap.c \ intel_state.c \ intel_tex.c \ + intel_tex_layout.c \ intel_tex_validate.c \ brw_aub.c \ brw_aub_playback.c \ @@ -92,8 +93,10 @@ C_SOURCES = \ ASM_SOURCES = - +DRIVER_DEFINES = -I../intel include ../Makefile.template +intel_tex_layout.o: ../intel/intel_tex_layout.c + symlinks: diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c b/src/mesa/drivers/dri/i965/brw_tex_layout.c index 1353325aff..af1ad0f1ef 100644 --- a/src/mesa/drivers/dri/i965/brw_tex_layout.c +++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c @@ -34,21 +34,15 @@ */ #include "intel_mipmap_tree.h" +#include "intel_tex_layout.h" #include "macros.h" -static GLuint minify( GLuint d ) -{ - return MAX2(1, d>>1); -} - GLboolean brw_miptree_layout( struct intel_mipmap_tree *mt ) { /* XXX: these vary depending on image format: */ /* GLint align_w = 4; */ - GLint align_h = 2; - switch (mt->target) { case GL_TEXTURE_CUBE_MAP: @@ -107,53 +101,10 @@ GLboolean brw_miptree_layout( struct intel_mipmap_tree *mt ) break; } - default: { - GLuint level; - GLuint x = 0; - GLuint y = 0; - GLuint width = mt->width0; - GLuint height = mt->height0; - - mt->pitch = ((mt->width0 * mt->cpp + 3) & ~3) / mt->cpp; - mt->total_height = 0; - - for ( level = mt->first_level ; level <= mt->last_level ; level++ ) { - GLuint img_height; - - intel_miptree_set_level_info(mt, level, 1, - x, y, - width, - mt->compressed ? height/4 : height, 1); - - if (mt->compressed) - img_height = MAX2(1, height/4); - else - img_height = MAX2(align_h, height); - - - /* Because the images are packed better, the final offset - * might not be the maximal one: - */ - mt->total_height = MAX2(mt->total_height, y + img_height); - - /* Layout_below: step right after second mipmap. - */ - if (level == mt->first_level + 1) { - x += mt->pitch / 2; - x = (x + 3) & ~ 3; - } - else { - y += img_height; - y += align_h - 1; - y &= ~(align_h - 1); - } - - width = minify(width); - height = minify(height); - } + default: + i945_miptree_layout_2d(mt); break; } - } DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__, mt->pitch, mt->total_height, diff --git a/src/mesa/drivers/dri/i965/intel_tex_layout.c b/src/mesa/drivers/dri/i965/intel_tex_layout.c new file mode 120000 index 0000000000..fe61b44194 --- /dev/null +++ b/src/mesa/drivers/dri/i965/intel_tex_layout.c @@ -0,0 +1 @@ +../intel/intel_tex_layout.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/intel/intel_tex_layout.c b/src/mesa/drivers/dri/intel/intel_tex_layout.c new file mode 100644 index 0000000000..6b9e1de2ed --- /dev/null +++ b/src/mesa/drivers/dri/intel/intel_tex_layout.c @@ -0,0 +1,82 @@ +/************************************************************************** + * + * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas. + * 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"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + /* + * Authors: + * Keith Whitwell + * Michel Dänzer + */ + +#include "intel_mipmap_tree.h" +#include "intel_tex_layout.h" +#include "macros.h" + + +void i945_miptree_layout_2d( struct intel_mipmap_tree *mt ) +{ + GLint align_h = 2; + GLuint level; + GLuint x = 0; + GLuint y = 0; + GLuint width = mt->width0; + GLuint height = mt->height0; + + mt->pitch = ((mt->width0 * mt->cpp + 3) & ~3) / mt->cpp; + mt->total_height = 0; + + for ( level = mt->first_level ; level <= mt->last_level ; level++ ) { + GLuint img_height; + + intel_miptree_set_level_info(mt, level, 1, x, y, width, + mt->compressed ? height/4 : height, 1); + + if (mt->compressed) + img_height = MAX2(1, height/4); + else + img_height = MAX2(align_h, height); + + + /* Because the images are packed better, the final offset + * might not be the maximal one: + */ + mt->total_height = MAX2(mt->total_height, y + img_height); + + /* Layout_below: step right after second mipmap. + */ + if (level == mt->first_level + 1) { + x += mt->pitch / 2; + x = (x + 3) & ~ 3; + } + else { + y += img_height; + y += align_h - 1; + y &= ~(align_h - 1); + } + + width = minify(width); + height = minify(height); + } +} diff --git a/src/mesa/drivers/dri/intel/intel_tex_layout.h b/src/mesa/drivers/dri/intel/intel_tex_layout.h new file mode 100644 index 0000000000..e685d474ec --- /dev/null +++ b/src/mesa/drivers/dri/intel/intel_tex_layout.h @@ -0,0 +1,41 @@ +/************************************************************************** + * + * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas. + * 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"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + /* + * Authors: + * Keith Whitwell + * Michel Dänzer + */ + +#include "macros.h" + + +static GLuint minify( GLuint d ) +{ + return MAX2(1, d>>1); +} + +extern void i945_miptree_layout_2d( struct intel_mipmap_tree *mt ); -- cgit v1.2.3 From 81855f22cd8d8df5bd96fdbd76ff975b6cf4150b Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Thu, 14 Dec 2006 12:42:51 +0100 Subject: Fix some corner cases in i945_miptree_layout_2d(). Based on a patch from Keith Whitwell, with some further fixes. --- src/mesa/drivers/dri/intel/intel_tex_layout.c | 34 +++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/intel/intel_tex_layout.c b/src/mesa/drivers/dri/intel/intel_tex_layout.c index 6b9e1de2ed..b503175001 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_layout.c +++ b/src/mesa/drivers/dri/intel/intel_tex_layout.c @@ -35,16 +35,39 @@ #include "macros.h" +static int align(int value, int alignment) +{ + return (value + alignment - 1) & ~(alignment - 1); +} + void i945_miptree_layout_2d( struct intel_mipmap_tree *mt ) { - GLint align_h = 2; + GLint align_h = 2, align_w = 4; GLuint level; GLuint x = 0; GLuint y = 0; GLuint width = mt->width0; GLuint height = mt->height0; - mt->pitch = ((mt->width0 * mt->cpp + 3) & ~3) / mt->cpp; + mt->pitch = mt->width0; + + /* May need to adjust pitch to accomodate the placement of + * the 2nd mipmap. This occurs when the alignment + * constraints of mipmap placement push the right edge of the + * 2nd mipmap out past the width of its parent. + */ + if (mt->first_level != mt->last_level) { + GLuint mip1_width = align(minify(mt->width0), align_w) + + minify(minify(mt->width0)); + + if (mip1_width > mt->width0) + mt->pitch = mip1_width; + } + + /* Pitch must be a whole number of dwords, even though we + * express it in texels. + */ + mt->pitch = align(mt->pitch * mt->cpp, 4) / mt->cpp; mt->total_height = 0; for ( level = mt->first_level ; level <= mt->last_level ; level++ ) { @@ -56,7 +79,7 @@ void i945_miptree_layout_2d( struct intel_mipmap_tree *mt ) if (mt->compressed) img_height = MAX2(1, height/4); else - img_height = MAX2(align_h, height); + img_height = align(height, align_h); /* Because the images are packed better, the final offset @@ -67,13 +90,10 @@ void i945_miptree_layout_2d( struct intel_mipmap_tree *mt ) /* Layout_below: step right after second mipmap. */ if (level == mt->first_level + 1) { - x += mt->pitch / 2; - x = (x + 3) & ~ 3; + x += align(width, align_w); } else { y += img_height; - y += align_h - 1; - y &= ~(align_h - 1); } width = minify(width); -- cgit v1.2.3 From e0c9361a7cd16cc008220cf1933fba4371f46753 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Thu, 14 Dec 2006 12:47:44 +0100 Subject: Avoid failing assertion in intel_miptree_set_image_offset() with cube maps. Cube maps still aren't working quite correctly though. --- src/mesa/drivers/dri/i915tex/i915_tex_layout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i915tex/i915_tex_layout.c b/src/mesa/drivers/dri/i915tex/i915_tex_layout.c index fc98611d31..333fefef85 100644 --- a/src/mesa/drivers/dri/i915tex/i915_tex_layout.c +++ b/src/mesa/drivers/dri/i915tex/i915_tex_layout.c @@ -212,7 +212,7 @@ i945_miptree_layout(struct intel_mipmap_tree * mt) y = mt->total_height - 4; x = (face - 4) * 8; } - else if (dim < 4) { + else if (dim < 4 && (face > 0 || mt->first_level > 0)) { y = mt->total_height - 4; x = face * 8; } -- cgit v1.2.3 From fde908444af5c826bce84203a9cb4273d8341ed0 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Thu, 14 Dec 2006 12:57:59 +0100 Subject: Fix copy-and-paste-o of my e-mail address. --- src/mesa/drivers/dri/intel/intel_tex_layout.c | 2 +- src/mesa/drivers/dri/intel/intel_tex_layout.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/intel/intel_tex_layout.c b/src/mesa/drivers/dri/intel/intel_tex_layout.c index b503175001..f356480217 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_layout.c +++ b/src/mesa/drivers/dri/intel/intel_tex_layout.c @@ -27,7 +27,7 @@ /* * Authors: * Keith Whitwell - * Michel Dänzer + * Michel Dänzer */ #include "intel_mipmap_tree.h" diff --git a/src/mesa/drivers/dri/intel/intel_tex_layout.h b/src/mesa/drivers/dri/intel/intel_tex_layout.h index e685d474ec..1e37f8f525 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_layout.h +++ b/src/mesa/drivers/dri/intel/intel_tex_layout.h @@ -27,7 +27,7 @@ /* * Authors: * Keith Whitwell - * Michel Dänzer + * Michel Dänzer */ #include "macros.h" -- cgit v1.2.3