meta: Infer bind_fbo_image parameters from an incoming image.
authorEric Anholt <eric@anholt.net>
Mon, 17 Mar 2014 23:45:48 +0000 (16:45 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 15 Apr 2014 21:34:22 +0000 (14:34 -0700)
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/common/meta.c
src/mesa/drivers/common/meta.h
src/mesa/drivers/common/meta_generate_mipmap.c

index ca5d851fff1499e787b02b000a9e88576bc198eb..6dc71c9d54206cddec80161e884b9b224cc3db5a 100644 (file)
@@ -94,9 +94,12 @@ static void meta_decompress_cleanup(struct decompress_state *decompress);
 static void meta_drawpix_cleanup(struct drawpix_state *drawpix);
 
 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,
@@ -115,6 +118,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,
index ea05ea5ea975e6ce81bb08e8abf99fbd839a581b..ad3da9cd8d4b88f296efd8d4ad073eebe1733894 100644 (file)
@@ -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 */
index 7c7f64d7368dd3d6276c9d76b8f3474ba2d45447..deff6904ab7797283012174789005a74044eed38 100644 (file)
@@ -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) !=