meta: Move bind_fbo_image() code back to meta.c, to reuse it elsewhere.
authorEric Anholt <eric@anholt.net>
Mon, 17 Mar 2014 23:26:42 +0000 (16:26 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 15 Apr 2014 21:34:22 +0000 (14:34 -0700)
I need to do the same code again for CopyTexSubImage().

v2: Drop incorrect, not-terribly-useful comment (review by Ken)

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> (v1)
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 acf927b09a00fd737ee0c762ea61ebc51b4ad809..ca5d851fff1499e787b02b000a9e88576bc198eb 100644 (file)
@@ -93,6 +93,36 @@ 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);
 
+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)
index 1177ced3aaa519a402dce19833130452cbc9ff3e..ea05ea5ea975e6ce81bb08e8abf99fbd839a581b 100644 (file)
@@ -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 */
index d62819c4c2243842a2a6b493d32b84ed8b411b5e..7c7f64d7368dd3d6276c9d76b8f3474ba2d45447 100644 (file)
 #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) !=