[Mesa-dev] [PATCH 4/9] meta: Move bind_fbo_image() code back to meta.c, to reuse it elsewhere.

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


I need to do the same code again for CopyTexSubImage().
---
 src/mesa/drivers/common/meta.c                 | 33 +++++++++++++++++++++++
 src/mesa/drivers/common/meta.h                 |  4 +++
 src/mesa/drivers/common/meta_generate_mipmap.c | 36 ++------------------------
 3 files changed, 39 insertions(+), 34 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index acf927b..ee8ad3f 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -93,6 +93,39 @@ static void meta_glsl_clear_cleanup(struct clear_state *clear);
 static void meta_decompress_cleanup(struct decompress_state *decompress);
 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)
+{
+   switch (target) {
+   case GL_TEXTURE_1D:
+      _mesa_FramebufferTexture1D(GL_FRAMEBUFFER,
+                                 GL_COLOR_ATTACHMENT0,
+                                 target,
+                                 texObj->Name,
+                                 level);
+      break;
+   case GL_TEXTURE_1D_ARRAY:
+   case GL_TEXTURE_2D_ARRAY:
+   case GL_TEXTURE_3D:
+      _mesa_FramebufferTextureLayer(GL_FRAMEBUFFER,
+                                    GL_COLOR_ATTACHMENT0,
+                                    texObj->Name,
+                                    level,
+                                    layer);
+      break;
+   default: /* 2D / cube */
+      _mesa_FramebufferTexture2D(GL_FRAMEBUFFER,
+                                 GL_COLOR_ATTACHMENT0,
+                                 target,
+                                 texObj->Name,
+                                 level);
+   }
+}
+
 GLuint
 _mesa_meta_compile_shader_with_debug(struct gl_context *ctx, GLenum target,
                                      const GLcharARB *source)
diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index 1177ced..ea05ea5 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -504,4 +504,8 @@ _mesa_meta_blit_shader_table_cleanup(struct blit_shader_table *table);
 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);
+
 #endif /* META_H */
diff --git a/src/mesa/drivers/common/meta_generate_mipmap.c b/src/mesa/drivers/common/meta_generate_mipmap.c
index d62819c..7c7f64d 100644
--- a/src/mesa/drivers/common/meta_generate_mipmap.c
+++ b/src/mesa/drivers/common/meta_generate_mipmap.c
@@ -44,38 +44,6 @@
 #include "main/viewport.h"
 #include "drivers/common/meta.h"
 
-/**
- * Bind a particular texture level/layer to mipmap->FBO's GL_COLOR_ATTACHMENT0.
- */
-static void
-bind_fbo_image(struct gl_texture_object *texObj, GLenum target,
-               GLuint level, GLuint layer)
-{
-   switch (target) {
-   case GL_TEXTURE_1D:
-      _mesa_FramebufferTexture1D(GL_FRAMEBUFFER,
-                                 GL_COLOR_ATTACHMENT0,
-                                 target,
-                                 texObj->Name,
-                                 level);
-      break;
-   case GL_TEXTURE_1D_ARRAY:
-   case GL_TEXTURE_2D_ARRAY:
-   case GL_TEXTURE_3D:
-      _mesa_FramebufferTextureLayer(GL_FRAMEBUFFER,
-                                    GL_COLOR_ATTACHMENT0,
-                                    texObj->Name,
-                                    level,
-                                    layer);
-      break;
-   default: /* 2D / cube */
-      _mesa_FramebufferTexture2D(GL_FRAMEBUFFER,
-                                 GL_COLOR_ATTACHMENT0,
-                                 target,
-                                 texObj->Name,
-                                 level);
-   }
-}
 
 /**
  * Check if the call to _mesa_meta_GenerateMipmap() will require a
@@ -135,7 +103,7 @@ fallback_required(struct gl_context *ctx, GLenum target,
       _mesa_GenFramebuffers(1, &mipmap->FBO);
    _mesa_BindFramebuffer(GL_FRAMEBUFFER_EXT, mipmap->FBO);
 
-   bind_fbo_image(texObj, target, srcLevel, 0);
+   _mesa_meta_bind_fbo_image(texObj, target, srcLevel, 0);
 
    status = _mesa_CheckFramebufferStatus(GL_FRAMEBUFFER_EXT);
 
@@ -347,7 +315,7 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
          _mesa_BufferData(GL_ARRAY_BUFFER_ARB, sizeof(verts),
                           verts, GL_DYNAMIC_DRAW_ARB);
 
-         bind_fbo_image(texObj, faceTarget, dstLevel, layer);
+         _mesa_meta_bind_fbo_image(texObj, faceTarget, dstLevel, layer);
 
          /* sanity check */
          if (_mesa_CheckFramebufferStatus(GL_FRAMEBUFFER) !=
-- 
1.9.1



More information about the mesa-dev mailing list