[Mesa-dev] [PATCH 5/9] meta: Infer bind_fbo_image parameters from an incoming image.

Eric Anholt eric at anholt.net
Tue Apr 8 14:03:16 PDT 2014


---
 src/mesa/drivers/common/meta.c                 | 10 ++++++++--
 src/mesa/drivers/common/meta.h                 |  3 +--
 src/mesa/drivers/common/meta_generate_mipmap.c |  6 ++++--
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index ee8ad3f..862fa48 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -97,9 +97,12 @@ static void meta_drawpix_cleanup(struct drawpix_state *drawpix);
  * Bind a particular texture level/layer to mipmap->FBO's GL_COLOR_ATTACHMENT0.
  */
 void
-_mesa_meta_bind_fbo_image(struct gl_texture_object *texObj, GLenum target,
-                          GLuint level, GLuint layer)
+_mesa_meta_bind_fbo_image(struct gl_texture_image *texImage, GLuint layer)
 {
+   struct gl_texture_object *texObj = texImage->TexObject;
+   int level = texImage->Level;
+   GLenum target = texObj->Target;
+
    switch (target) {
    case GL_TEXTURE_1D:
       _mesa_FramebufferTexture1D(GL_FRAMEBUFFER,
@@ -118,6 +121,9 @@ _mesa_meta_bind_fbo_image(struct gl_texture_object *texObj, GLenum target,
                                     layer);
       break;
    default: /* 2D / cube */
+      if (target == GL_TEXTURE_CUBE_MAP)
+         target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + texImage->Face;
+
       _mesa_FramebufferTexture2D(GL_FRAMEBUFFER,
                                  GL_COLOR_ATTACHMENT0,
                                  target,
diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index ea05ea5..ad3da9c 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -505,7 +505,6 @@ void
 _mesa_meta_glsl_generate_mipmap_cleanup(struct gen_mipmap_state *mipmap);
 
 void
-_mesa_meta_bind_fbo_image(struct gl_texture_object *texObj, GLenum target,
-                          GLuint level, GLuint layer);
+_mesa_meta_bind_fbo_image(struct gl_texture_image *texImage, GLuint layer);
 
 #endif /* META_H */
diff --git a/src/mesa/drivers/common/meta_generate_mipmap.c b/src/mesa/drivers/common/meta_generate_mipmap.c
index 7c7f64d..deff690 100644
--- a/src/mesa/drivers/common/meta_generate_mipmap.c
+++ b/src/mesa/drivers/common/meta_generate_mipmap.c
@@ -103,7 +103,7 @@ fallback_required(struct gl_context *ctx, GLenum target,
       _mesa_GenFramebuffers(1, &mipmap->FBO);
    _mesa_BindFramebuffer(GL_FRAMEBUFFER_EXT, mipmap->FBO);
 
-   _mesa_meta_bind_fbo_image(texObj, target, srcLevel, 0);
+   _mesa_meta_bind_fbo_image(baseImage, 0);
 
    status = _mesa_CheckFramebufferStatus(GL_FRAMEBUFFER_EXT);
 
@@ -249,6 +249,7 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
 
    for (dstLevel = baseLevel + 1; dstLevel <= maxLevel; dstLevel++) {
       const struct gl_texture_image *srcImage;
+      struct gl_texture_image *dstImage;
       const GLuint srcLevel = dstLevel - 1;
       GLuint layer;
       GLsizei srcWidth, srcHeight, srcDepth;
@@ -293,6 +294,7 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
           */
          break;
       }
+      dstImage = _mesa_select_tex_image(ctx, texObj, faceTarget, dstLevel);
 
       /* limit minification to src level */
       _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel);
@@ -315,7 +317,7 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
          _mesa_BufferData(GL_ARRAY_BUFFER_ARB, sizeof(verts),
                           verts, GL_DYNAMIC_DRAW_ARB);
 
-         _mesa_meta_bind_fbo_image(texObj, faceTarget, dstLevel, layer);
+         _mesa_meta_bind_fbo_image(dstImage, layer);
 
          /* sanity check */
          if (_mesa_CheckFramebufferStatus(GL_FRAMEBUFFER) !=
-- 
1.9.1



More information about the mesa-dev mailing list