From 8a4d7393bd8a752eba2ee687c1c3e2df5c82745d Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Tue, 19 Jan 2010 23:34:56 +0100 Subject: radeon/r300/r600: share common glCopyTex(Sub)Image code --- src/mesa/drivers/dri/r300/r300_texcopy.c | 163 ------------------------------- 1 file changed, 163 deletions(-) delete mode 100644 src/mesa/drivers/dri/r300/r300_texcopy.c (limited to 'src/mesa/drivers/dri/r300/r300_texcopy.c') diff --git a/src/mesa/drivers/dri/r300/r300_texcopy.c b/src/mesa/drivers/dri/r300/r300_texcopy.c deleted file mode 100644 index c7d57fb5de..0000000000 --- a/src/mesa/drivers/dri/r300/r300_texcopy.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (C) 2009 Maciej Cencora - * - * 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
- -// 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 -- cgit v1.2.3