mesa: rework ctx->Driver.CopyTexSubImage() parameters
authorBrian Paul <brianp@vmware.com>
Thu, 29 Dec 2011 13:36:55 +0000 (06:36 -0700)
committerBrian Paul <brianp@vmware.com>
Sat, 7 Jan 2012 22:04:23 +0000 (15:04 -0700)
Replace target, level parameters with gl_texture_image.
Add gl_renderbuffer parameter to indicate source buffer for the copy.

This removes some redundant code in the drivers to find the source
renderbuffer and the destination texture image (which we already had
in _mesa_CopyTexSubImage).

Signed-off-by: Brian Paul <brianp@vmware.com>
src/mesa/drivers/common/meta.c
src/mesa/drivers/common/meta.h
src/mesa/drivers/dri/intel/intel_fbo.c
src/mesa/drivers/dri/intel/intel_tex.h
src/mesa/drivers/dri/intel/intel_tex_copy.c
src/mesa/drivers/dri/radeon/radeon_tex_copy.c
src/mesa/drivers/dri/radeon/radeon_texture.h
src/mesa/main/dd.h
src/mesa/main/teximage.c
src/mesa/state_tracker/st_cb_texture.c

index d8a2591723f98a2e2d2c58cf5c94c2e6ab4e89ac..ad289aa70d08a9634c2b8d899f1cc75f4cb5f5af 100644 (file)
@@ -3098,20 +3098,19 @@ get_temp_image_type(struct gl_context *ctx, GLenum baseFormat)
  */
 static void
 copy_tex_sub_image(struct gl_context *ctx,
-                   GLuint dims, GLenum target, GLint level,
+                   GLuint dims,
+                   struct gl_texture_image *texImage,
                    GLint xoffset, GLint yoffset, GLint zoffset,
+                   struct gl_renderbuffer *rb,
                    GLint x, GLint y,
                    GLsizei width, GLsizei height)
 {
-   struct gl_texture_object *texObj;
-   struct gl_texture_image *texImage;
+   struct gl_texture_object *texObj = texImage->TexObject;
+   const GLenum target = texObj->Target;
    GLenum format, type;
    GLint bpp;
    void *buf;
 
-   texObj = _mesa_get_current_tex_object(ctx, target);
-   texImage = _mesa_select_tex_image(ctx, texObj, target, level);
-
    /* Choose format/type for temporary image buffer */
    format = _mesa_get_format_base_format(texImage->TexFormat);
    if (format == GL_LUMINANCE ||
@@ -3180,34 +3179,40 @@ copy_tex_sub_image(struct gl_context *ctx,
 
 
 void
-_mesa_meta_CopyTexSubImage1D(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_meta_CopyTexSubImage1D(struct gl_context *ctx,
+                             struct gl_texture_image *texImage,
                              GLint xoffset,
+                             struct gl_renderbuffer *rb,
                              GLint x, GLint y, GLsizei width)
 {
-   copy_tex_sub_image(ctx, 1, target, level, xoffset, 0, 0,
-                      x, y, width, 1);
+   copy_tex_sub_image(ctx, 1, texImage, xoffset, 0, 0,
+                      rb, x, y, width, 1);
 }
 
 
 void
-_mesa_meta_CopyTexSubImage2D(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_meta_CopyTexSubImage2D(struct gl_context *ctx,
+                             struct gl_texture_image *texImage,
                              GLint xoffset, GLint yoffset,
+                             struct gl_renderbuffer *rb,
                              GLint x, GLint y,
                              GLsizei width, GLsizei height)
 {
-   copy_tex_sub_image(ctx, 2, target, level, xoffset, yoffset, 0,
-                      x, y, width, height);
+   copy_tex_sub_image(ctx, 2, texImage, xoffset, yoffset, 0,
+                      rb, x, y, width, height);
 }
 
 
 void
-_mesa_meta_CopyTexSubImage3D(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_meta_CopyTexSubImage3D(struct gl_context *ctx,
+                             struct gl_texture_image *texImage,
                              GLint xoffset, GLint yoffset, GLint zoffset,
+                             struct gl_renderbuffer *rb,
                              GLint x, GLint y,
                              GLsizei width, GLsizei height)
 {
-   copy_tex_sub_image(ctx, 3, target, level, xoffset, yoffset, zoffset,
-                      x, y, width, height);
+   copy_tex_sub_image(ctx, 3, texImage, xoffset, yoffset, zoffset,
+                      rb, x, y, width, height);
 }
 
 
index d13796ebed0fd8c826db41a8fd714d53cc61da7b..de039b575e5647d3c66ccb414625e5bca516a584 100644 (file)
@@ -111,19 +111,25 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
                           struct gl_texture_object *texObj);
 
 extern void
-_mesa_meta_CopyTexSubImage1D(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_meta_CopyTexSubImage1D(struct gl_context *ctx,
+                             struct gl_texture_image *texImage,
                              GLint xoffset,
+                             struct gl_renderbuffer *rb,
                              GLint x, GLint y, GLsizei width);
 
 extern void
-_mesa_meta_CopyTexSubImage2D(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_meta_CopyTexSubImage2D(struct gl_context *ctx,
+                             struct gl_texture_image *texImage,
                              GLint xoffset, GLint yoffset,
+                             struct gl_renderbuffer *rb,
                              GLint x, GLint y,
                              GLsizei width, GLsizei height);
 
 extern void
-_mesa_meta_CopyTexSubImage3D(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_meta_CopyTexSubImage3D(struct gl_context *ctx,
+                             struct gl_texture_image *texImage,
                              GLint xoffset, GLint yoffset, GLint zoffset,
+                             struct gl_renderbuffer *rb,
                              GLint x, GLint y,
                              GLsizei width, GLsizei height);
 
index ecb4a86b2436c7463b90229b40f0bb20fd89c5d9..b95193d2b6e4d0766fd14c5fcb76e2aee922be46 100644 (file)
@@ -854,13 +854,15 @@ intel_blit_framebuffer_copy_tex_sub_image(struct gl_context *ctx,
       const struct gl_framebuffer *readFb = ctx->ReadBuffer;
       const struct gl_renderbuffer_attachment *drawAtt =
          &drawFb->Attachment[drawFb->_ColorDrawBufferIndexes[0]];
+      struct intel_renderbuffer *srcRb = 
+         intel_renderbuffer(readFb->_ColorReadBuffer);
 
       /* If the source and destination are the same size with no
          mirroring, the rectangles are within the size of the
          texture and there is no scissor then we can use
          glCopyTexSubimage2D to implement the blit. This will end
          up as a fast hardware blit on some drivers */
-      if (drawAtt && drawAtt->Texture &&
+      if (srcRb && drawAtt && drawAtt->Texture &&
           srcX0 - srcX1 == dstX0 - dstX1 &&
           srcY0 - srcY1 == dstY0 - dstY1 &&
           srcX1 >= srcX0 &&
@@ -880,6 +882,7 @@ intel_blit_framebuffer_copy_tex_sub_image(struct gl_context *ctx,
          if (intel_copy_texsubimage(intel_context(ctx),
                                     intel_texture_image(texImage),
                                     dstX0, dstY0,
+                                    srcRb,
                                     srcX0, srcY0,
                                     srcX1 - srcX0, /* width */
                                     srcY1 - srcY0))
index 42a37e67b487eafa2877163b7d7e3dc74e24e47a..88a7d55414adc773cefe84e936713a41c636bdc5 100644 (file)
@@ -32,6 +32,8 @@
 #include "main/formats.h"
 #include "intel_context.h"
 
+struct intel_renderbuffer;
+
 void intelInitTextureFuncs(struct dd_function_table *functions);
 
 void intelInitTextureImageFuncs(struct dd_function_table *functions);
@@ -77,9 +79,10 @@ intel_tex_image_s8z24_create_renderbuffers(struct intel_context *intel,
 int intel_compressed_num_bytes(GLuint mesaFormat);
 
 bool intel_copy_texsubimage(struct intel_context *intel,
-                                 struct intel_texture_image *intelImage,
-                                 GLint dstx, GLint dsty,
-                                 GLint x, GLint y,
-                                 GLsizei width, GLsizei height);
+                            struct intel_texture_image *intelImage,
+                            GLint dstx, GLint dsty,
+                            struct intel_renderbuffer *irb,
+                            GLint x, GLint y,
+                            GLsizei width, GLsizei height);
 
 #endif
index 543326a05802711b38269a967f73bb2b8c2f00c7..b6e29f78de6ef79321e630af9efd2237a2a3350a 100644 (file)
 
 #define FILE_DEBUG_FLAG DEBUG_TEXTURE
 
-/**
- * Get the intel_region which is the source for any glCopyTex[Sub]Image call.
- *
- * Do the best we can using the blitter.  A future project is to use
- * the texture engine and fragment programs for these copies.
- */
-static struct intel_renderbuffer *
-get_teximage_readbuffer(struct intel_context *intel, GLenum internalFormat)
-{
-   DBG("%s %s\n", __FUNCTION__,
-       _mesa_lookup_enum_by_nr(internalFormat));
-
-   if (_mesa_is_depth_format(internalFormat) ||
-       _mesa_is_depthstencil_format(internalFormat))
-      return intel_get_renderbuffer(intel->ctx.ReadBuffer, BUFFER_DEPTH);
-
-   return intel_renderbuffer(intel->ctx.ReadBuffer->_ColorReadBuffer);
-}
-
 
 bool
 intel_copy_texsubimage(struct intel_context *intel,
                        struct intel_texture_image *intelImage,
                        GLint dstx, GLint dsty,
+                       struct intel_renderbuffer *irb,
                        GLint x, GLint y, GLsizei width, GLsizei height)
 {
    struct gl_context *ctx = &intel->ctx;
-   struct intel_renderbuffer *irb;
    struct intel_region *region;
    const GLenum internalFormat = intelImage->base.Base.InternalFormat;
    bool copy_supported = false;
@@ -78,7 +59,6 @@ intel_copy_texsubimage(struct intel_context *intel,
 
    intel_prepare_render(intel);
 
-   irb = get_teximage_readbuffer(intel, internalFormat);
    if (!intelImage->mt || !irb || !irb->mt) {
       if (unlikely(INTEL_DEBUG & DEBUG_FALLBACKS))
         fprintf(stderr, "%s fail %p %p (0x%08x)\n",
@@ -164,49 +144,38 @@ intel_copy_texsubimage(struct intel_context *intel,
 
 
 static void
-intelCopyTexSubImage1D(struct gl_context * ctx, GLenum target, GLint level,
-                       GLint xoffset, GLint x, GLint y, GLsizei width)
+intelCopyTexSubImage1D(struct gl_context *ctx,
+                       struct gl_texture_image *texImage,
+                       GLint xoffset,
+                       struct gl_renderbuffer *rb,
+                       GLint x, GLint y, GLsizei width)
 {
-   struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
-   struct gl_texture_object *texObj =
-      _mesa_select_tex_object(ctx, texUnit, target);
-   struct gl_texture_image *texImage =
-      _mesa_select_tex_image(ctx, texObj, target, level);
-
-   /* XXX need to check <border> as in above function? */
-
-   /* Need to check texture is compatible with source format. 
-    */
-
    if (!intel_copy_texsubimage(intel_context(ctx),
                                intel_texture_image(texImage),
-                               xoffset, 0, x, y, width, 1)) {
+                               xoffset, 0,
+                               intel_renderbuffer(rb), x, y, width, 1)) {
       fallback_debug("%s - fallback to swrast\n", __FUNCTION__);
-      _mesa_meta_CopyTexSubImage1D(ctx, target, level, xoffset, x, y, width);
+      _mesa_meta_CopyTexSubImage1D(ctx, texImage, xoffset,
+                                   rb, x, y, width);
    }
 }
 
 
 static void
-intelCopyTexSubImage2D(struct gl_context * ctx, GLenum target, GLint level,
+intelCopyTexSubImage2D(struct gl_context *ctx,
+                       struct gl_texture_image *texImage,
                        GLint xoffset, GLint yoffset,
+                       struct gl_renderbuffer *rb,
                        GLint x, GLint y, GLsizei width, GLsizei height)
 {
-   struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
-   struct gl_texture_object *texObj =
-      _mesa_select_tex_object(ctx, texUnit, target);
-   struct gl_texture_image *texImage =
-      _mesa_select_tex_image(ctx, texObj, target, level);
-
-   /* Need to check texture is compatible with source format. 
-    */
-
    if (!intel_copy_texsubimage(intel_context(ctx),
                                intel_texture_image(texImage),
-                               xoffset, yoffset, x, y, width, height)) {
+                               xoffset, yoffset,
+                               intel_renderbuffer(rb), x, y, width, height)) {
       fallback_debug("%s - fallback to swrast\n", __FUNCTION__);
-      _mesa_meta_CopyTexSubImage2D(ctx, target, level,
-                                   xoffset, yoffset, x, y, width, height);
+      _mesa_meta_CopyTexSubImage2D(ctx, texImage,
+                                   xoffset, yoffset,
+                                   rb, x, y, width, height);
    }
 }
 
index 76ca8e6b27dc1e82022c7fe1d36af436fd1028d5..726692ef241e389471b4c48a11a7027187cdd0d0 100644 (file)
 
 static GLboolean
 do_copy_texsubimage(struct gl_context *ctx,
-                    GLenum target, GLint level,
                     struct radeon_tex_obj *tobj,
                     radeon_texture_image *timg,
                     GLint dstx, GLint dsty,
+                    struct radeon_renderbuffer *rrb,
                     GLint x, GLint y,
                     GLsizei width, GLsizei height)
 {
     radeonContextPtr radeon = RADEON_CONTEXT(ctx);
-    struct radeon_renderbuffer *rrb;
+    const GLuint face = timg->base.Base.Face;
+    const GLuint level = timg->base.Base.Level;
     unsigned src_bpp;
     unsigned dst_bpp;
     gl_format src_mesaformat;
@@ -57,22 +58,19 @@ do_copy_texsubimage(struct gl_context *ctx,
         return GL_FALSE;
     }
 
+    // This is software renderbuffer, fallback to swrast
+    if (!rrb) {
+        return GL_FALSE;
+    }
+
     if (_mesa_get_format_bits(timg->base.Base.TexFormat, GL_DEPTH_BITS) > 0) {
-        /* copying a depth values */
-        rrb = radeon_renderbuffer(ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer);
-        assert(rrb);
+        /* copying depth values */
         flip_y = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Type == GL_NONE;
     } else {
         /* copying color */
-        rrb = radeon_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
         flip_y = ctx->ReadBuffer->Attachment[BUFFER_COLOR0].Type == GL_NONE;
     }
 
-    // This is software renderbuffer, fallback to swrast
-    if (!rrb) {
-        return GL_FALSE;
-    }
-
     if (!timg->mt) {
         radeon_validate_texture_miptree(ctx, &tobj->base);
     }
@@ -84,11 +82,11 @@ do_copy_texsubimage(struct gl_context *ctx,
     assert(timg->base.Base.Height >= dsty + height);
 
     intptr_t src_offset = rrb->draw_offset;
-    intptr_t dst_offset = radeon_miptree_image_offset(timg->mt, _mesa_tex_target_to_face(target), level);
+    intptr_t dst_offset = radeon_miptree_image_offset(timg->mt, face, level);
 
     if (0) {
         fprintf(stderr, "%s: copying to face %d, level %d\n",
-                __FUNCTION__, _mesa_tex_target_to_face(target), level);
+                __FUNCTION__, face, level);
         fprintf(stderr, "to: x %d, y %d, offset %d\n", dstx, dsty, (uint32_t) dst_offset);
         fprintf(stderr, "from (%dx%d) width %d, height %d, offset %d, pitch %d\n",
                 x, y, rrb->base.Width, rrb->base.Height, (uint32_t) src_offset, rrb->pitch/rrb->cpp);
@@ -136,26 +134,27 @@ do_copy_texsubimage(struct gl_context *ctx,
 }
 
 void
-radeonCopyTexSubImage2D(struct gl_context *ctx, GLenum target, GLint level,
+radeonCopyTexSubImage2D(struct gl_context *ctx,
+                        struct gl_texture_image *texImage,
                         GLint xoffset, GLint yoffset,
+                        struct gl_renderbuffer *rb,
                         GLint x, GLint y,
                         GLsizei width, GLsizei height)
 {
-    struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
-    struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target);
-    struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texObj, target, level);
-
     radeonContextPtr radeon = RADEON_CONTEXT(ctx);
     radeon_prepare_render(radeon);
 
-    if (!do_copy_texsubimage(ctx, target, level,
-                             radeon_tex_obj(texObj), (radeon_texture_image *)texImage,
-                             xoffset, yoffset, x, y, width, height)) {
+    if (!do_copy_texsubimage(ctx,
+                             radeon_tex_obj(texImage->TexObject),
+                             (radeon_texture_image *)texImage,
+                             xoffset, yoffset,
+                             radeon_renderbuffer(rb),                                                        x, y, width, height)) {
 
         radeon_print(RADEON_FALLBACKS, RADEON_NORMAL,
                      "Falling back to sw for glCopyTexSubImage2D\n");
 
-        _mesa_meta_CopyTexSubImage2D(ctx, target, level,
-                                     xoffset, yoffset, x, y, width, height);
+        _mesa_meta_CopyTexSubImage2D(ctx, texImage,
+                                     xoffset, yoffset,
+                                     rb, x, y, width, height);
     }
 }
index c1e5360ff4e9e5e666f5bf89b30659ad9a072f5e..6cca011bf2f2fa77249a5d1e6f903a5535307b20 100644 (file)
@@ -65,10 +65,12 @@ gl_format radeonChooseTextureFormat(struct gl_context * ctx,
                                     GLenum format,
                                     GLenum type, GLboolean fbo);
 
-void radeonCopyTexSubImage2D(struct gl_context *ctx, GLenum target, GLint level,
-                       GLint xoffset, GLint yoffset,
-                       GLint x, GLint y,
-                       GLsizei width, GLsizei height);
+void radeonCopyTexSubImage2D(struct gl_context *ctx,
+                             struct gl_texture_image *texImage,
+                             GLint xoffset, GLint yoffset,
+                             struct gl_renderbuffer *rb,
+                             GLint x, GLint y,
+                             GLsizei width, GLsizei height);
 
 unsigned radeonIsFormatRenderable(gl_format mesa_format);
 
index 6707e785dc7385d0051e8402e6ceea5a94838978..24f3d4ca5775b85e1fe7ac8ad3851ece72107036 100644 (file)
@@ -283,31 +283,33 @@ struct dd_function_table {
                         struct gl_texture_image *texImage );
 
    /**
-    * Called by glCopyTexSubImage1D().
-    * 
-    * Drivers should use a fallback routine from texstore.c if needed.
+    * Called by glCopyTexSubImage1D() and glCopyTexImage1D().
     */
-   void (*CopyTexSubImage1D)( struct gl_context *ctx, GLenum target, GLint level,
-                              GLint xoffset,
-                              GLint x, GLint y, GLsizei width );
+   void (*CopyTexSubImage1D)(struct gl_context *ctx,
+                             struct gl_texture_image *texImage,
+                             GLint xoffset,
+                             struct gl_renderbuffer *rb,
+                             GLint x, GLint y, GLsizei width);
+
    /**
-    * Called by glCopyTexSubImage2D().
-    * 
-    * Drivers should use a fallback routine from texstore.c if needed.
+    * Called by glCopyTexSubImage2D() and glCopyTexImage2D().
     */
-   void (*CopyTexSubImage2D)( struct gl_context *ctx, GLenum target, GLint level,
-                              GLint xoffset, GLint yoffset,
-                              GLint x, GLint y,
-                              GLsizei width, GLsizei height );
+   void (*CopyTexSubImage2D)(struct gl_context *ctx,
+                             struct gl_texture_image *texImage,
+                             GLint xoffset, GLint yoffset,
+                             struct gl_renderbuffer *rb,
+                             GLint x, GLint y,
+                             GLsizei width, GLsizei height);
+
    /**
-    * Called by glCopyTexSubImage3D().
-    * 
-    * Drivers should use a fallback routine from texstore.c if needed.
+    * Called by glCopyTexSubImage3D() and glCopyTexImage3D().
     */
-   void (*CopyTexSubImage3D)( struct gl_context *ctx, GLenum target, GLint level,
-                              GLint xoffset, GLint yoffset, GLint zoffset,
-                              GLint x, GLint y,
-                              GLsizei width, GLsizei height );
+   void (*CopyTexSubImage3D)(struct gl_context *ctx,
+                             struct gl_texture_image *texImage,
+                             GLint xoffset, GLint yoffset, GLint zoffset,
+                             struct gl_renderbuffer *rb,
+                             GLint x, GLint y,
+                             GLsizei width, GLsizei height);
 
    /**
     * Called by glGenerateMipmap() or when GL_GENERATE_MIPMAP_SGIS is enabled.
index 6dd70b96c3af619a83735d9e642af9eb5ccae96d..9475e84f52dd731bdfbc61f985fdfa279e723212 100644 (file)
@@ -2751,6 +2751,25 @@ _mesa_TexSubImage3D( GLenum target, GLint level,
 
 
 
+/**
+ * For glCopyTexSubImage, return the source renderbuffer to copy texel data
+ * from.  This depends on whether the texture contains color or depth values.
+ */
+static struct gl_renderbuffer *
+get_copy_tex_image_source(struct gl_context *ctx, gl_format texFormat)
+{
+   if (_mesa_get_format_bits(texFormat, GL_DEPTH_BITS) > 0) {
+      /* reading from depth/stencil buffer */
+      return ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+   }
+   else {
+      /* copying from color buffer */
+      return ctx->ReadBuffer->_ColorReadBuffer;
+   }
+}
+
+
+
 /**
  * Implement the glCopyTexImage1/2D() functions.
  */
@@ -2828,13 +2847,16 @@ copyteximage(struct gl_context *ctx, GLuint dims,
 
             if (_mesa_clip_copytexsubimage(ctx, &dstX, &dstY, &srcX, &srcY,
                                            &width, &height)) {
+               struct gl_renderbuffer *srcRb =
+                  get_copy_tex_image_source(ctx, texImage->TexFormat);
+
                if (dims == 1)
-                  ctx->Driver.CopyTexSubImage1D(ctx, target, level, dstX,
-                                                srcX, srcY, width);
+                  ctx->Driver.CopyTexSubImage1D(ctx, texImage, dstX,
+                                                srcRb, srcX, srcY, width);
                                                 
                else
-                  ctx->Driver.CopyTexSubImage2D(ctx, target, level, dstX, dstY,
-                                                srcX, srcY, width, height);
+                  ctx->Driver.CopyTexSubImage2D(ctx, texImage, dstX, dstY,
+                                                srcRb, srcX, srcY, width, height);
             }
 
             check_gen_mipmap(ctx, target, texObj, level);
@@ -2930,20 +2952,22 @@ copytexsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,
 
          if (_mesa_clip_copytexsubimage(ctx, &xoffset, &yoffset, &x, &y,
                                         &width, &height)) {
+            struct gl_renderbuffer *srcRb =
+               get_copy_tex_image_source(ctx, texImage->TexFormat);
+
             switch (dims) {
             case 1:
-               ctx->Driver.CopyTexSubImage1D(ctx, target, level,
-                                             xoffset, x, y, width);
+               ctx->Driver.CopyTexSubImage1D(ctx, texImage, xoffset,
+                                             srcRb, x, y, width);
                break;
             case 2:
-               ctx->Driver.CopyTexSubImage2D(ctx, target, level,
-                                             xoffset, yoffset,
-                                             x, y, width, height);
+               ctx->Driver.CopyTexSubImage2D(ctx, texImage, xoffset, yoffset,
+                                             srcRb, x, y, width, height);
                break;
             case 3:
-               ctx->Driver.CopyTexSubImage3D(ctx, target, level,
+               ctx->Driver.CopyTexSubImage3D(ctx, texImage,
                                              xoffset, yoffset, zoffset,
-                                             x, y, width, height);
+                                             srcRb, x, y, width, height);
                break;
             default:
                _mesa_problem(ctx, "bad dims in copytexsubimage()");
index 592d04b929f98de15d6d1c825ff6014a105876fc..ad4f23c7eb8de43ca7511c7fea9528b697641574 100644 (file)
@@ -736,7 +736,7 @@ st_GetTexImage(struct gl_context * ctx,
  * Note: srcY=0=TOP of renderbuffer
  */
 static void
-fallback_copy_texsubimage(struct gl_context *ctx, GLenum target, GLint level,
+fallback_copy_texsubimage(struct gl_context *ctx,
                           struct st_renderbuffer *strb,
                           struct st_texture_image *stImage,
                           GLenum baseFormat,
@@ -931,17 +931,12 @@ compatible_src_dst_formats(struct gl_context *ctx,
  */
 static void
 st_copy_texsubimage(struct gl_context *ctx,
-                    GLenum target, GLint level,
+                    struct gl_texture_image *texImage,
                     GLint destX, GLint destY, GLint destZ,
+                    struct gl_renderbuffer *rb,
                     GLint srcX, GLint srcY,
                     GLsizei width, GLsizei height)
 {
-   struct gl_texture_unit *texUnit =
-      &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
-   struct gl_texture_object *texObj =
-      _mesa_select_tex_object(ctx, texUnit, target);
-   struct gl_texture_image *texImage =
-      _mesa_select_tex_image(ctx, texObj, target, level);
    struct st_texture_image *stImage = st_texture_image(texImage);
    const GLenum texBaseFormat = texImage->_BaseFormat;
    struct gl_framebuffer *fb = ctx->ReadBuffer;
@@ -1096,7 +1091,7 @@ st_copy_texsubimage(struct gl_context *ctx,
 
 fallback:
    /* software fallback */
-   fallback_copy_texsubimage(ctx, target, level,
+   fallback_copy_texsubimage(ctx,
                              strb, stImage, texBaseFormat,
                              destX, destY, destZ,
                              srcX, srcY, width, height);
@@ -1105,37 +1100,44 @@ fallback:
 
 
 static void
-st_CopyTexSubImage1D(struct gl_context * ctx, GLenum target, GLint level,
-                     GLint xoffset, GLint x, GLint y, GLsizei width)
+st_CopyTexSubImage1D(struct gl_context *ctx,
+                     struct gl_texture_image *texImage,
+                     GLint xoffset,
+                     struct gl_renderbuffer *rb,
+                     GLint x, GLint y, GLsizei width)
 {
    const GLint yoffset = 0, zoffset = 0;
    const GLsizei height = 1;
-   st_copy_texsubimage(ctx, target, level,
+   st_copy_texsubimage(ctx, texImage,
                        xoffset, yoffset, zoffset,  /* destX,Y,Z */
-                       x, y, width, height);  /* src X, Y, size */
+                       rb, x, y, width, height);  /* src X, Y, size */
 }
 
 
 static void
-st_CopyTexSubImage2D(struct gl_context * ctx, GLenum target, GLint level,
+st_CopyTexSubImage2D(struct gl_context *ctx,
+                     struct gl_texture_image *texImage,
                      GLint xoffset, GLint yoffset,
+                     struct gl_renderbuffer *rb,
                      GLint x, GLint y, GLsizei width, GLsizei height)
 {
    const GLint zoffset = 0;
-   st_copy_texsubimage(ctx, target, level,
+   st_copy_texsubimage(ctx, texImage,
                        xoffset, yoffset, zoffset,  /* destX,Y,Z */
-                       x, y, width, height);  /* src X, Y, size */
+                       rb, x, y, width, height);  /* src X, Y, size */
 }
 
 
 static void
-st_CopyTexSubImage3D(struct gl_context * ctx, GLenum target, GLint level,
+st_CopyTexSubImage3D(struct gl_context *ctx,
+                     struct gl_texture_image *texImage,
                      GLint xoffset, GLint yoffset, GLint zoffset,
+                     struct gl_renderbuffer *rb,
                      GLint x, GLint y, GLsizei width, GLsizei height)
 {
-   st_copy_texsubimage(ctx, target, level,
+   st_copy_texsubimage(ctx, texImage,
                        xoffset, yoffset, zoffset,  /* destX,Y,Z */
-                       x, y, width, height);  /* src X, Y, size */
+                       rb, x, y, width, height);  /* src X, Y, size */
 }