Mesa (master): st/mesa: fix gallium texture level selection for RTT

Brian Paul brianp at kemper.freedesktop.org
Thu Feb 11 16:42:27 UTC 2010


Module: Mesa
Branch: master
Commit: 6352f4c854e9ec39c440054109ccb92caa5ff0bb
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6352f4c854e9ec39c440054109ccb92caa5ff0bb

Author: Brian Paul <brianp at vmware.com>
Date:   Thu Feb 11 09:40:49 2010 -0700

st/mesa: fix gallium texture level selection for RTT

Fixes invalid texture level when rendering to a texture where
GL_BASE_LEVEL > 0.

This will be cherry-picked to the 7.7 branch after additional
testing.

---

 src/mesa/state_tracker/st_cb_fbo.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 9f2fe74..4638879 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -37,6 +37,7 @@
 #include "main/context.h"
 #include "main/fbobject.h"
 #include "main/framebuffer.h"
+#include "main/macros.h"
 #include "main/renderbuffer.h"
 
 #include "pipe/p_context.h"
@@ -340,12 +341,17 @@ st_render_texture(GLcontext *ctx,
    struct gl_renderbuffer *rb;
    struct pipe_texture *pt = st_get_texobj_texture(att->Texture);
    struct st_texture_object *stObj;
-   const struct gl_texture_image *texImage =
-      att->Texture->Image[att->CubeMapFace][att->TextureLevel];
+   const struct gl_texture_image *texImage;
+   GLint pt_level;
 
+   /* When would this fail?  Perhaps assert? */
    if (!pt) 
       return;
 
+   /* The first gallium texture level = Mesa BaseLevel */
+   pt_level = MAX2(0, (GLint) att->TextureLevel - att->Texture->BaseLevel);
+   texImage = att->Texture->Image[att->CubeMapFace][pt_level];
+
    /* create new renderbuffer which wraps the texture image */
    rb = st_new_renderbuffer(ctx, 0);
    if (!rb) {
@@ -365,7 +371,7 @@ st_render_texture(GLcontext *ctx,
 
    /* point renderbuffer at texobject */
    strb->rtt = stObj;
-   strb->rtt_level = att->TextureLevel;
+   strb->rtt_level = pt_level;
    strb->rtt_face = att->CubeMapFace;
    strb->rtt_slice = att->Zoffset;
 
@@ -380,6 +386,8 @@ st_render_texture(GLcontext *ctx,
 
    pipe_surface_reference(&strb->surface, NULL);
 
+   assert(strb->rtt_level <= strb->texture->last_level);
+
    /* new surface for rendering into the texture */
    strb->surface = screen->get_tex_surface(screen,
                                            strb->texture,




More information about the mesa-commit mailing list