how about this patch, considering both mipmap and non-mipmap cases. Cooper On Wed, Sep 30, 2009 at 12:49 PM, Cooper Yuan <coopery...@gmail.com> wrote:
> Hi Brian, > > for non-mipmap case, the value of LastLevel might be wrong. because the > function st_finalize_texture() might be called from non-mipmap case. > The MaxLevel is related to log2(texture width), for non-mipmap case, I > think the LastLevel should be the same as BaseLevel. > > Cooper > > On Tue, Sep 29, 2009 at 12:06 AM, Brian Paul < > bri...@kemper.freedesktop.org> wrote: > >> Module: Mesa >> Branch: master >> Commit: e3a6f57ad6c0e7bda5d45eb146194ed39f45abdd >> URL: >> http://cgit.freedesktop.org/mesa/mesa/commit/?id=e3a6f57ad6c0e7bda5d45eb146194ed39f45abdd >> >> Author: Brian Paul <bri...@vmware.com> >> Date: Mon Sep 28 09:28:50 2009 -0600 >> >> st/mesa: fix/simplify st_texture_object::lastLevel calculation >> >> Don't compute the st_texture_object::lastLevel field based on the texture >> filters. Use the _MaxLevel value that core Mesa computes for us. >> When called from the GenerateMipmap path, we'll use the lastLevel field >> as-is. >> >> --- >> >> src/mesa/state_tracker/st_cb_texture.c | 62 >> +++++--------------------------- >> 1 files changed, 9 insertions(+), 53 deletions(-) >> >> diff --git a/src/mesa/state_tracker/st_cb_texture.c >> b/src/mesa/state_tracker/st_cb_texture.c >> index cfa33d4..085da3e 100644 >> --- a/src/mesa/state_tracker/st_cb_texture.c >> +++ b/src/mesa/state_tracker/st_cb_texture.c >> @@ -1708,53 +1708,6 @@ st_CopyTexSubImage3D(GLcontext * ctx, GLenum >> target, GLint level, >> } >> >> >> -/** >> - * Compute which mipmap levels that really need to be sent to the >> hardware. >> - * This depends on the base image size, GL_TEXTURE_MIN_LOD, >> - * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL. >> - */ >> -static void >> -calculate_first_last_level(struct st_texture_object *stObj) >> -{ >> - struct gl_texture_object *tObj = &stObj->base; >> - >> - /* These must be signed values. MinLod and MaxLod can be negative >> numbers, >> - * and having firstLevel and lastLevel as signed prevents the need for >> - * extra sign checks. >> - */ >> - GLint firstLevel; >> - GLint lastLevel; >> - >> - /* Yes, this looks overly complicated, but it's all needed. >> - */ >> - switch (tObj->Target) { >> - case GL_TEXTURE_1D: >> - case GL_TEXTURE_2D: >> - case GL_TEXTURE_3D: >> - case GL_TEXTURE_CUBE_MAP: >> - if (tObj->MinFilter == GL_NEAREST || tObj->MinFilter == GL_LINEAR) >> { >> - /* GL_NEAREST and GL_LINEAR only care about >> GL_TEXTURE_BASE_LEVEL. >> - */ >> - firstLevel = lastLevel = tObj->BaseLevel; >> - } >> - else { >> - firstLevel = 0; >> - lastLevel = MIN2(tObj->MaxLevel, >> - (int) >> tObj->Image[0][tObj->BaseLevel]->WidthLog2); >> - } >> - break; >> - case GL_TEXTURE_RECTANGLE_NV: >> - case GL_TEXTURE_4D_SGIS: >> - firstLevel = lastLevel = 0; >> - break; >> - default: >> - return; >> - } >> - >> - stObj->lastLevel = lastLevel; >> -} >> - >> - >> static void >> copy_image_data_to_texture(struct st_context *st, >> struct st_texture_object *stObj, >> @@ -1818,13 +1771,16 @@ st_finalize_texture(GLcontext *ctx, >> >> *needFlush = GL_FALSE; >> >> - /* We know/require this is true by now: >> - */ >> - assert(stObj->base._Complete); >> + if (stObj->base._Complete) { >> + /* The texture is complete and we know exactly how many mipmap >> levels >> + * are present/needed. This is conditional because we may be >> called >> + * from the st_generate_mipmap() function when the texture object >> is >> + * incomplete. In that case, we'll have set stObj->lastLevel >> before >> + * we get here. >> + */ >> + stObj->lastLevel = stObj->base._MaxLevel - stObj->base.BaseLevel; >> + } >> >> - /* What levels must the texture include at a minimum? >> - */ >> - calculate_first_last_level(stObj); >> firstImage = >> st_texture_image(stObj->base.Image[0][stObj->base.BaseLevel]); >> >> /* If both firstImage and stObj point to a texture which can contain >> >> _______________________________________________ >> mesa-commit mailing list >> mesa-com...@lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/mesa-commit >> > >
0001-st-mesa-fix-texture-lastLevel-calculation.patch
Description: Binary data
------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf
_______________________________________________ Mesa3d-dev mailing list Mesa3d-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mesa3d-dev