radeon/r300/r600: share common glCopyTex(Sub)Image code
authorMaciej Cencora <m.cencora@gmail.com>
Tue, 19 Jan 2010 22:34:56 +0000 (23:34 +0100)
committerMaciej Cencora <m.cencora@gmail.com>
Tue, 19 Jan 2010 22:38:34 +0000 (23:38 +0100)
18 files changed:
src/mesa/drivers/dri/r300/Makefile
src/mesa/drivers/dri/r300/r300_context.c
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_tex.c
src/mesa/drivers/dri/r300/r300_tex.h
src/mesa/drivers/dri/r300/r300_texcopy.c [deleted file]
src/mesa/drivers/dri/r300/radeon_tex_copy.c [new symlink]
src/mesa/drivers/dri/r600/Makefile
src/mesa/drivers/dri/r600/r600_blit.c
src/mesa/drivers/dri/r600/r600_blit.h
src/mesa/drivers/dri/r600/r600_context.c
src/mesa/drivers/dri/r600/r600_context.h
src/mesa/drivers/dri/r600/r600_tex.c
src/mesa/drivers/dri/r600/r600_tex.h
src/mesa/drivers/dri/r600/r600_texcopy.c [deleted file]
src/mesa/drivers/dri/r600/radeon_tex_copy.c [new symlink]
src/mesa/drivers/dri/radeon/radeon_tex_copy.c [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_texture.h

index be005bd1641f3edeac04c52d9f06641f036e9d1b..0d0fbcc4081d535815384298b9f3d93fd54ced20 100644 (file)
@@ -39,7 +39,8 @@ RADEON_COMMON_SOURCES = \
        radeon_mipmap_tree.c \
        radeon_span.c \
        radeon_queryobj.c \
-       radeon_texture.c
+       radeon_texture.c \
+       radeon_tex_copy.c
 
 DRIVER_SOURCES = \
                 radeon_screen.c \
@@ -50,7 +51,6 @@ DRIVER_SOURCES = \
                 r300_state.c \
                 r300_render.c \
                 r300_tex.c \
-                r300_texcopy.c \
                 r300_texstate.c \
                 r300_vertprog.c \
                 r300_fragprog_common.c \
index e449590fbb832d923307ec8e91a17851d6daa5b4..bb0e6db31395b568baa2932a8e62bb6c018fa790 100644 (file)
@@ -93,8 +93,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "main/remap_helper.h"
 
-void r300_init_texcopy_functions(struct dd_function_table *table);
-
 static const struct dri_extension card_extensions[] = {
   /* *INDENT-OFF* */
   {"GL_ARB_depth_texture",             NULL},
@@ -490,15 +488,11 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
        _mesa_init_driver_functions(&functions);
        r300InitIoctlFuncs(&functions);
        r300InitStateFuncs(&functions);
-       r300InitTextureFuncs(&functions);
+       r300InitTextureFuncs(&r300->radeon, &functions);
        r300InitShaderFuncs(&functions);
        radeonInitQueryObjFunctions(&functions);
        radeonInitBufferObjectFuncs(&functions);
 
-       if (r300->radeon.radeonScreen->kernel_mm) {
-               r300_init_texcopy_functions(&functions);
-       }
-
        if (!radeonInitContext(&r300->radeon, &functions,
                               glVisual, driContextPriv,
                               sharedContextPrivate)) {
index 546cd8ddde37b53e286bfbb26ead254840bb46a5..78ab43a99f98747a90746906e489910519906a2d 100644 (file)
@@ -554,8 +554,6 @@ extern void r300InitShaderFunctions(r300ContextPtr r300);
 
 extern void r300InitDraw(GLcontext *ctx);
 
-extern void r300_init_texcopy_functions(struct dd_function_table *table);
-
 #define r300PackFloat32 radeonPackFloat32
 #define r300PackFloat24 radeonPackFloat24
 
index 963f648cb14b5af8d11bc3e4be1fa7386123fd4f..eb5d2d500418c8dc44466ed4ec1fec9e00e4721a 100644 (file)
@@ -312,7 +312,7 @@ static struct gl_texture_object *r300NewTextureObject(GLcontext * ctx,
        return &t->base;
 }
 
-void r300InitTextureFuncs(struct dd_function_table *functions)
+void r300InitTextureFuncs(radeonContextPtr radeon, struct dd_function_table *functions)
 {
        /* Note: we only plug in the functions we implement in the driver
         * since _mesa_init_driver_functions() was already called.
@@ -340,6 +340,11 @@ void r300InitTextureFuncs(struct dd_function_table *functions)
        functions->CompressedTexImage2D = radeonCompressedTexImage2D;
        functions->CompressedTexSubImage2D = radeonCompressedTexSubImage2D;
 
+       if (radeon->radeonScreen->kernel_mm) {
+               functions->CopyTexImage2D = radeonCopyTexImage2D;
+               functions->CopyTexSubImage2D = radeonCopyTexSubImage2D;
+       }
+
        functions->GenerateMipmap = radeonGenerateMipmap;
 
        driInitTextureFormats();
index 6ede0fe25c9047241a2bea540403b6f4e050f55d..9694e703b83480c41d366e671b9e01106d2dccfd 100644 (file)
@@ -49,7 +49,7 @@ extern void r300SetTexOffset(__DRIcontext *pDRICtx, GLint texname,
 
 extern GLboolean r300ValidateBuffers(GLcontext * ctx);
 
-extern void r300InitTextureFuncs(struct dd_function_table *functions);
+extern void r300InitTextureFuncs(radeonContextPtr radeon, struct dd_function_table *functions);
 
 int32_t r300TranslateTexFormat(gl_format mesaFormat);
 
diff --git a/src/mesa/drivers/dri/r300/r300_texcopy.c b/src/mesa/drivers/dri/r300/r300_texcopy.c
deleted file mode 100644 (file)
index c7d57fb..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (C) 2009 Maciej Cencora <m.cencora@gmail.com>
- *
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial
- * portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-
-#include "radeon_common.h"
-#include "r300_context.h"
-
-#include "main/image.h"
-#include "main/teximage.h"
-#include "main/texstate.h"
-#include "drivers/common/meta.h"
-
-#include "radeon_mipmap_tree.h"
-#include <main/debug.h>
-
-// TODO:
-// need to pass correct pitch for small dst textures!
-static GLboolean
-do_copy_texsubimage(GLcontext *ctx,
-                    GLenum target, GLint level,
-                    struct radeon_tex_obj *tobj,
-                    radeon_texture_image *timg,
-                    GLint dstx, GLint dsty,
-                    GLint x, GLint y,
-                    GLsizei width, GLsizei height)
-{
-    struct r300_context *r300 = R300_CONTEXT(ctx);
-    struct radeon_renderbuffer *rrb;
-
-    if (_mesa_get_format_bits(timg->base.TexFormat, GL_DEPTH_BITS) > 0) {
-        rrb = radeon_get_depthbuffer(&r300->radeon);
-    } else {
-        rrb = radeon_get_colorbuffer(&r300->radeon);
-    }
-
-    if (!timg->mt) {
-        radeon_validate_texture_miptree(ctx, &tobj->base);
-    }
-
-    assert(rrb && rrb->bo);
-    assert(timg->mt->bo);
-    assert(timg->base.Width >= dstx + width);
-    assert(timg->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);
-
-    if (0) {
-        fprintf(stderr, "%s: copying to face %d, level %d\n",
-                __FUNCTION__, _mesa_tex_target_to_face(target), 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);
-        fprintf(stderr, "src size %d, dst size %d\n", rrb->bo->size, timg->mt->bo->size);
-
-    }
-
-    /* blit from src buffer to texture */
-    return r300->radeon.vtbl.blit(ctx, rrb->bo, src_offset, rrb->base.Format, rrb->pitch/rrb->cpp,
-                     rrb->base.Width, rrb->base.Height, x, y,
-                     timg->mt->bo, dst_offset, timg->base.TexFormat,
-                     timg->base.Width, timg->base.Width, timg->base.Height,
-                     dstx, dsty, width, height, 1);
-}
-
-static void
-r300CopyTexImage2D(GLcontext *ctx, GLenum target, GLint level,
-                   GLenum internalFormat,
-                   GLint x, GLint y, GLsizei width, GLsizei height,
-                   GLint border)
-{
-    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);
-    int srcx, srcy, dstx, dsty;
-
-    if (border)
-        goto fail;
-
-    /* Setup or redefine the texture object, mipmap tree and texture
-     * image.  Don't populate yet.
-     */
-    ctx->Driver.TexImage2D(ctx, target, level, internalFormat,
-                           width, height, border,
-                           GL_RGBA, GL_UNSIGNED_BYTE, NULL,
-                           &ctx->DefaultPacking, texObj, texImage);
-
-    srcx = x;
-    srcy = y;
-    dstx = 0;
-    dsty = 0;
-    if (!_mesa_clip_copytexsubimage(ctx,
-                                    &dstx, &dsty,
-                                    &srcx, &srcy,
-                                    &width, &height)) {
-        return;
-    }
-
-    if (!do_copy_texsubimage(ctx, target, level,
-                             radeon_tex_obj(texObj), (radeon_texture_image *)texImage,
-                             0, 0, x, y, width, height)) {
-        goto fail;
-    }
-
-    return;
-
-fail:
-    _mesa_meta_CopyTexImage2D(ctx, target, level, internalFormat, x, y,
-                              width, height, border);
-}
-
-static void
-r300CopyTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
-                      GLint xoffset, GLint yoffset,
-                      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);
-
-    if (!do_copy_texsubimage(ctx, target, level,
-                             radeon_tex_obj(texObj), (radeon_texture_image *)texImage,
-                             xoffset, yoffset, x, y, width, height)) {
-
-       //DEBUG_FALLBACKS
-
-        _mesa_meta_CopyTexSubImage2D(ctx, target, level,
-                                     xoffset, yoffset, x, y, width, height);
-    }
-}
-
-
-void r300_init_texcopy_functions(struct dd_function_table *table)
-{
-    table->CopyTexImage2D = r300CopyTexImage2D;
-    table->CopyTexSubImage2D = r300CopyTexSubImage2D;
-}
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/r300/radeon_tex_copy.c b/src/mesa/drivers/dri/r300/radeon_tex_copy.c
new file mode 120000 (symlink)
index 0000000..dfa5ba3
--- /dev/null
@@ -0,0 +1 @@
+../radeon/radeon_tex_copy.c
\ No newline at end of file
index b90efce17a1754350b2a1f86fe9d2d4e74b69867..e55d0babd858d721bc37ecf2c5f368743944f6ad 100644 (file)
@@ -39,7 +39,8 @@ RADEON_COMMON_SOURCES = \
        radeon_mipmap_tree.c \
        radeon_span.c \
        radeon_texture.c \
-       radeon_queryobj.c
+       radeon_queryobj.c \
+       radeon_tex_copy.c
 
 DRIVER_SOURCES = \
                 radeon_screen.c \
@@ -60,7 +61,6 @@ DRIVER_SOURCES = \
                 r600_tex.c      \
                 r600_texstate.c      \
                 r600_blit.c     \
-                r600_texcopy.c  \
                 r700_debug.c    \
                 $(RADEON_COMMON_SOURCES) \
                 $(EGL_SOURCES) \
index 0205a438cc7f038b3b284d7a55683de521e1940f..d7cd59ade62b7d9089bf24c54cac397ac006fcf4 100644 (file)
@@ -1556,32 +1556,32 @@ static GLboolean validate_buffers(context_t *rmesa,
     return GL_TRUE;
 }
 
-GLboolean r600_blit(GLcontext *ctx,
-                    struct radeon_bo *src_bo,
-                    intptr_t src_offset,
-                    gl_format src_mesaformat,
-                    unsigned src_pitch,
-                    unsigned src_width,
-                    unsigned src_height,
-                    unsigned src_x,
-                    unsigned src_y,
-                    struct radeon_bo *dst_bo,
-                    intptr_t dst_offset,
-                    gl_format dst_mesaformat,
-                    unsigned dst_pitch,
-                    unsigned dst_width,
-                    unsigned dst_height,
-                    unsigned dst_x,
-                    unsigned dst_y,
-                    unsigned w,
-                    unsigned h,
-                    unsigned flip_y)
+unsigned r600_blit(GLcontext *ctx,
+                   struct radeon_bo *src_bo,
+                   intptr_t src_offset,
+                   gl_format src_mesaformat,
+                   unsigned src_pitch,
+                   unsigned src_width,
+                   unsigned src_height,
+                   unsigned src_x,
+                   unsigned src_y,
+                   struct radeon_bo *dst_bo,
+                   intptr_t dst_offset,
+                   gl_format dst_mesaformat,
+                   unsigned dst_pitch,
+                   unsigned dst_width,
+                   unsigned dst_height,
+                   unsigned dst_x,
+                   unsigned dst_y,
+                   unsigned w,
+                   unsigned h,
+                   unsigned flip_y)
 {
     context_t *context = R700_CONTEXT(ctx);
     int id = 0;
 
     if (!is_blit_supported(dst_mesaformat))
-           return GL_FALSE;
+        return GL_FALSE;
 
     if (src_bo == dst_bo) {
         return GL_FALSE;
@@ -1603,7 +1603,7 @@ GLboolean r600_blit(GLcontext *ctx,
     }
 
     /* Flush is needed to make sure that source buffer has correct data */
-    radeonFlush(context->radeon.glCtx);
+    radeonFlush(ctx);
 
     rcommonEnsureCmdBufSpace(&context->radeon, 304, __FUNCTION__);
 
@@ -1654,7 +1654,7 @@ GLboolean r600_blit(GLcontext *ctx,
     /* 5 */
     r700WaitForIdleClean(context);
 
-    radeonFlush(context->radeon.glCtx);
+    radeonFlush(ctx);
 
     return GL_TRUE;
 }
index 97dc2e57ffac15d07b50c660c90508fbd20a3607..f280e23489e014608be682bc672811d79e97212c 100644 (file)
@@ -1,21 +1,21 @@
-GLboolean r600_blit(GLcontext *ctx,
-                    struct radeon_bo *src_bo,
-                    intptr_t src_offset,
-                    gl_format src_mesaformat,
-                    unsigned src_pitch,
-                    unsigned src_width,
-                    unsigned src_height,
-                    unsigned src_x_offset,
-                    unsigned src_y_offset,
-                    struct radeon_bo *dst_bo,
-                    intptr_t dst_offset,
-                    gl_format dst_mesaformat,
-                    unsigned dst_pitch,
-                    unsigned dst_width,
-                    unsigned dst_height,
-                    unsigned dst_x_offset,
-                    unsigned dst_y_offset,
-                    unsigned w,
-                    unsigned h,
-                    unsigned flip_y);
+unsigned r600_blit(GLcontext *ctx,
+                   struct radeon_bo *src_bo,
+                   intptr_t src_offset,
+                   gl_format src_mesaformat,
+                   unsigned src_pitch,
+                   unsigned src_width,
+                   unsigned src_height,
+                   unsigned src_x_offset,
+                   unsigned src_y_offset,
+                   struct radeon_bo *dst_bo,
+                   intptr_t dst_offset,
+                   gl_format dst_mesaformat,
+                   unsigned dst_pitch,
+                   unsigned dst_width,
+                   unsigned dst_height,
+                   unsigned dst_x_offset,
+                   unsigned dst_y_offset,
+                   unsigned w,
+                   unsigned h,
+                   unsigned flip_y);
 
index 55680fad32d8543debfac4fde3c2ec8bb863d517..68112c49dc362ecd04f2edce72125a228ff61e09 100644 (file)
@@ -65,6 +65,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r600_emit.h"
 #include "radeon_bocs_wrapper.h"
 #include "radeon_queryobj.h"
+#include "r600_blit.h"
 
 #include "r700_state.h"
 #include "r700_ioctl.h"
@@ -240,6 +241,7 @@ static void r600_init_vtbl(radeonContextPtr radeon)
        radeon->vtbl.pre_emit_atoms = r600_vtbl_pre_emit_atoms;
        radeon->vtbl.fallback = r600_fallback;
        radeon->vtbl.emit_query_finish = r600_emit_query_finish;
+       radeon->vtbl.blit = r600_blit;
 }
 
 static void r600InitConstValues(GLcontext *ctx, radeonScreenPtr screen)
@@ -378,16 +380,12 @@ GLboolean r600CreateContext(const __GLcontextModes * glVisual,
        _mesa_init_driver_functions(&functions);
 
        r700InitStateFuncs(&functions);
-       r600InitTextureFuncs(&functions);
+       r600InitTextureFuncs(&r600->radeon, &functions);
        r700InitShaderFuncs(&functions);
        radeonInitQueryObjFunctions(&functions);
        r700InitIoctlFuncs(&functions);
        radeonInitBufferObjectFuncs(&functions);
 
-       if (r600->radeon.radeonScreen->kernel_mm) {
-                r600_init_texcopy_functions(&functions);
-        }
-       
        if (!radeonInitContext(&r600->radeon, &functions,
                               glVisual, driContextPriv,
                               sharedContextPrivate)) {
index 1f7cd4096bf869dcec780b35500a61279a58b54a..72c8c869b702eab92b4dcbbd7a3c8a2d2208b405 100644 (file)
@@ -185,7 +185,6 @@ extern void r700WaitForIdleClean(context_t *context);
 extern void r700Start3D(context_t *context);
 extern void r600InitAtoms(context_t *context);
 extern void r700InitDraw(GLcontext *ctx);
-extern void r600_init_texcopy_functions(struct dd_function_table *table);
 
 #define RADEON_D_CAPTURE 0
 #define RADEON_D_PLAYBACK 1
index f745fe3e8a635fb35e9c225e633e1708084f3c22..71dfd7e059193c5d828b03fb46a7bbce483bb41c 100644 (file)
@@ -396,7 +396,7 @@ static struct gl_texture_object *r600NewTextureObject(GLcontext * ctx,
        return &t->base;
 }
 
-void r600InitTextureFuncs(struct dd_function_table *functions)
+void r600InitTextureFuncs(radeonContextPtr radeon, struct dd_function_table *functions)
 {
        /* Note: we only plug in the functions we implement in the driver
         * since _mesa_init_driver_functions() was already called.
@@ -424,6 +424,11 @@ void r600InitTextureFuncs(struct dd_function_table *functions)
        functions->CompressedTexImage2D = radeonCompressedTexImage2D;
        functions->CompressedTexSubImage2D = radeonCompressedTexSubImage2D;
 
+       if (radeon->radeonScreen->kernel_mm) {
+               functions->CopyTexImage2D = radeonCopyTexImage2D;
+               functions->CopyTexSubImage2D = radeonCopyTexSubImage2D;
+       }
+
        functions->GenerateMipmap = radeonGenerateMipmap;
 
        driInitTextureFormats();
index fb0e1a023e1c0b86cfc749fa5095f0b5605ae038..c2141ef5e5c87e50c64bd5848aa8f6eb7f0e5035 100644 (file)
@@ -58,6 +58,6 @@ extern void r600SetTexOffset(__DRIcontext *pDRICtx, GLint texname,
 
 extern GLboolean r600ValidateBuffers(GLcontext * ctx);
 
-extern void r600InitTextureFuncs(struct dd_function_table *functions);
+extern void r600InitTextureFuncs(radeonContextPtr radeon, struct dd_function_table *functions);
 
 #endif                         /* __r600_TEX_H__ */
diff --git a/src/mesa/drivers/dri/r600/r600_texcopy.c b/src/mesa/drivers/dri/r600/r600_texcopy.c
deleted file mode 100644 (file)
index 21bf840..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (C) 2009 Maciej Cencora <m.cencora@gmail.com>
- *
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial
- * portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-
-#include "radeon_common.h"
-#include "r600_context.h"
-
-#include "main/image.h"
-#include "main/teximage.h"
-#include "main/texstate.h"
-#include "drivers/common/meta.h"
-
-#include "radeon_mipmap_tree.h"
-#include "r600_blit.h"
-#include <main/debug.h>
-
-// TODO:
-// need to pass correct pitch for small dst textures!
-static GLboolean
-do_copy_texsubimage(GLcontext *ctx,
-                    GLenum target, GLint level,
-                    struct radeon_tex_obj *tobj,
-                    radeon_texture_image *timg,
-                    GLint dstx, GLint dsty,
-                    GLint x, GLint y,
-                    GLsizei width, GLsizei height)
-{
-    context_t *context = R700_CONTEXT(ctx);
-    struct radeon_renderbuffer *rrb;
-
-    if (_mesa_get_format_bits(timg->base.TexFormat, GL_DEPTH_BITS) > 0) {
-        rrb = radeon_get_depthbuffer(&context->radeon);
-    } else {
-        rrb = radeon_get_colorbuffer(&context->radeon);
-    }
-
-    if (!timg->mt) {
-        radeon_validate_texture_miptree(ctx, &tobj->base);
-    }
-
-    assert(rrb && rrb->bo);
-    assert(timg->mt->bo);
-    assert(timg->base.Width >= dstx + width);
-    assert(timg->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);
-
-    if (0) {
-        fprintf(stderr, "%s: copying to face %d, level %d\n",
-                __FUNCTION__, _mesa_tex_target_to_face(target), 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);
-        fprintf(stderr, "src size %d, dst size %d\n", rrb->bo->size, timg->mt->bo->size);
-
-    }
-
-
-    /* blit from src buffer to texture */
-    return r600_blit(ctx, rrb->bo, src_offset, rrb->base.Format, rrb->pitch/rrb->cpp,
-                     rrb->base.Width, rrb->base.Height, x, y,
-                     timg->mt->bo, dst_offset, timg->base.TexFormat,
-                     timg->mt->levels[level].rowstride / _mesa_get_format_bytes(timg->base.TexFormat),
-                     timg->base.Width, timg->base.Height,
-                     dstx, dsty, width, height, 1);
-}
-
-static void
-r600CopyTexImage2D(GLcontext *ctx, GLenum target, GLint level,
-                   GLenum internalFormat,
-                   GLint x, GLint y, GLsizei width, GLsizei height,
-                   GLint border)
-{
-    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);
-    int srcx, srcy, dstx, dsty;
-
-    if (border)
-        goto fail;
-
-    /* Setup or redefine the texture object, mipmap tree and texture
-     * image.  Don't populate yet.
-     */
-    ctx->Driver.TexImage2D(ctx, target, level, internalFormat,
-                           width, height, border,
-                           GL_RGBA, GL_UNSIGNED_BYTE, NULL,
-                           &ctx->DefaultPacking, texObj, texImage);
-
-    srcx = x;
-    srcy = y;
-    dstx = 0;
-    dsty = 0;
-    if (!_mesa_clip_copytexsubimage(ctx,
-                                    &dstx, &dsty,
-                                    &srcx, &srcy,
-                                    &width, &height)) {
-        return;
-    }
-
-    if (!do_copy_texsubimage(ctx, target, level,
-                             radeon_tex_obj(texObj), (radeon_texture_image *)texImage,
-                             0, 0, x, y, width, height)) {
-        goto fail;
-    }
-
-    return;
-
-fail:
-    _mesa_meta_CopyTexImage2D(ctx, target, level, internalFormat, x, y,
-                              width, height, border);
-}
-
-static void
-r600CopyTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
-                      GLint xoffset, GLint yoffset,
-                      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);
-
-    if (!do_copy_texsubimage(ctx, target, level,
-                             radeon_tex_obj(texObj), (radeon_texture_image *)texImage,
-                             xoffset, yoffset, x, y, width, height)) {
-
-       //DEBUG_FALLBACKS
-
-        _mesa_meta_CopyTexSubImage2D(ctx, target, level,
-                                     xoffset, yoffset, x, y, width, height);
-    }
-}
-
-
-void r600_init_texcopy_functions(struct dd_function_table *table)
-{
-    table->CopyTexImage2D = r600CopyTexImage2D;
-    table->CopyTexSubImage2D = r600CopyTexSubImage2D;
-}
diff --git a/src/mesa/drivers/dri/r600/radeon_tex_copy.c b/src/mesa/drivers/dri/r600/radeon_tex_copy.c
new file mode 120000 (symlink)
index 0000000..dfa5ba3
--- /dev/null
@@ -0,0 +1 @@
+../radeon/radeon_tex_copy.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/radeon/radeon_tex_copy.c b/src/mesa/drivers/dri/radeon/radeon_tex_copy.c
new file mode 100644 (file)
index 0000000..44e144c
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2009 Maciej Cencora <m.cencora@gmail.com>
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "radeon_common.h"
+#include "radeon_texture.h"
+
+#include "main/image.h"
+#include "main/teximage.h"
+#include "main/texstate.h"
+#include "drivers/common/meta.h"
+
+#include "radeon_mipmap_tree.h"
+#include <main/debug.h>
+
+static GLboolean
+do_copy_texsubimage(GLcontext *ctx,
+                    GLenum target, GLint level,
+                    struct radeon_tex_obj *tobj,
+                    radeon_texture_image *timg,
+                    GLint dstx, GLint dsty,
+                    GLint x, GLint y,
+                    GLsizei width, GLsizei height)
+{
+    radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+    struct radeon_renderbuffer *rrb;
+
+    if (_mesa_get_format_bits(timg->base.TexFormat, GL_DEPTH_BITS) > 0) {
+        rrb = radeon_get_depthbuffer(radeon);
+    } else {
+        rrb = radeon_get_colorbuffer(radeon);
+    }
+
+    if (!timg->mt) {
+        radeon_validate_texture_miptree(ctx, &tobj->base);
+    }
+
+    assert(rrb && rrb->bo);
+    assert(timg->mt->bo);
+    assert(timg->base.Width >= dstx + width);
+    assert(timg->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);
+
+    if (0) {
+        fprintf(stderr, "%s: copying to face %d, level %d\n",
+                __FUNCTION__, _mesa_tex_target_to_face(target), 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);
+        fprintf(stderr, "src size %d, dst size %d\n", rrb->bo->size, timg->mt->bo->size);
+
+    }
+
+    /* blit from src buffer to texture */
+    return radeon->vtbl.blit(ctx, rrb->bo, src_offset, rrb->base.Format, rrb->pitch/rrb->cpp,
+                             rrb->base.Width, rrb->base.Height, x, y,
+                             timg->mt->bo, dst_offset, timg->base.TexFormat,
+                             timg->mt->levels[level].rowstride / _mesa_get_format_bytes(timg->base.TexFormat),
+                             timg->base.Width, timg->base.Height,
+                             dstx, dsty, width, height, 1);
+}
+
+void
+radeonCopyTexImage2D(GLcontext *ctx, GLenum target, GLint level,
+                     GLenum internalFormat,
+                     GLint x, GLint y, GLsizei width, GLsizei height,
+                     GLint border)
+{
+    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);
+    int srcx, srcy, dstx, dsty;
+
+    if (border)
+        goto fail;
+
+    /* Setup or redefine the texture object, mipmap tree and texture
+     * image.  Don't populate yet.
+     */
+    ctx->Driver.TexImage2D(ctx, target, level, internalFormat,
+                           width, height, border,
+                           GL_RGBA, GL_UNSIGNED_BYTE, NULL,
+                           &ctx->DefaultPacking, texObj, texImage);
+
+    srcx = x;
+    srcy = y;
+    dstx = 0;
+    dsty = 0;
+    if (!_mesa_clip_copytexsubimage(ctx,
+                                    &dstx, &dsty,
+                                    &srcx, &srcy,
+                                    &width, &height)) {
+        return;
+    }
+
+    if (!do_copy_texsubimage(ctx, target, level,
+                             radeon_tex_obj(texObj), (radeon_texture_image *)texImage,
+                             0, 0, x, y, width, height)) {
+        goto fail;
+    }
+
+    return;
+
+fail:
+    _mesa_meta_CopyTexImage2D(ctx, target, level, internalFormat, x, y,
+                              width, height, border);
+}
+
+void
+radeonCopyTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
+                        GLint xoffset, GLint yoffset,
+                        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);
+
+    if (!do_copy_texsubimage(ctx, target, level,
+                             radeon_tex_obj(texObj), (radeon_texture_image *)texImage,
+                             xoffset, yoffset, x, y, width, height)) {
+
+       //DEBUG_FALLBACKS
+
+        _mesa_meta_CopyTexSubImage2D(ctx, target, level,
+                                     xoffset, yoffset, x, y, width, height);
+    }
+}
index 4ec6a2945fb40ba6de91cdf5e7a8a84c8736c612..f09dd65214229665aaf303e46bd2b4ebd1a33490 100644 (file)
@@ -125,4 +125,14 @@ void radeonGetCompressedTexImage(GLcontext *ctx, GLenum target, GLint level,
                                 struct gl_texture_object *texObj,
                                 struct gl_texture_image *texImage);
 
+void radeonCopyTexImage2D(GLcontext *ctx, GLenum target, GLint level,
+                       GLenum internalFormat,
+                       GLint x, GLint y, GLsizei width, GLsizei height,
+                       GLint border);
+
+void radeonCopyTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
+                       GLint xoffset, GLint yoffset,
+                       GLint x, GLint y,
+                       GLsizei width, GLsizei height);
+
 #endif