summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/radeon/Makefile4
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_blit.c50
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_blit.h40
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_context.c8
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_context.h1
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_tex.c7
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_tex.h2
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_texcopy.c168
8 files changed, 60 insertions, 220 deletions
diff --git a/src/mesa/drivers/dri/radeon/Makefile b/src/mesa/drivers/dri/radeon/Makefile
index 70b946b2fd5..c776be0e605 100644
--- a/src/mesa/drivers/dri/radeon/Makefile
+++ b/src/mesa/drivers/dri/radeon/Makefile
@@ -26,7 +26,8 @@ RADEON_COMMON_SOURCES = \
radeon_mipmap_tree.c \
radeon_queryobj.c \
radeon_span.c \
- radeon_texture.c
+ radeon_texture.c \
+ radeon_tex_copy.c
DRIVER_SOURCES = \
radeon_context.c \
@@ -41,7 +42,6 @@ DRIVER_SOURCES = \
radeon_maos.c \
radeon_sanity.c \
radeon_blit.c \
- radeon_texcopy.c \
$(RADEON_COMMON_SOURCES)
C_SOURCES = \
diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c b/src/mesa/drivers/dri/radeon/radeon_blit.c
index 1ccfa4e78e3..c1bb51a6eff 100644
--- a/src/mesa/drivers/dri/radeon/radeon_blit.c
+++ b/src/mesa/drivers/dri/radeon/radeon_blit.c
@@ -307,27 +307,29 @@ static inline void emit_draw_packet(struct r100_context *r100,
* @param[in] height region height
* @param[in] flip_y set if y coords of the source image need to be flipped
*/
-GLboolean r100_blit(struct r100_context *r100,
- 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 reg_width,
- unsigned reg_height,
- unsigned flip_y)
+unsigned r100_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 reg_width,
+ unsigned reg_height,
+ unsigned flip_y)
{
+ struct r100_context *r100 = R100_CONTEXT(ctx);
+
if (!is_blit_supported(dst_mesaformat))
return GL_FALSE;
@@ -358,6 +360,10 @@ GLboolean r100_blit(struct r100_context *r100,
return GL_FALSE;
}
+ if (src_offset % 32 || dst_offset % 32) {
+ return GL_FALSE;
+ }
+
if (0) {
fprintf(stderr, "src: size [%d x %d], pitch %d, "
"offset [%d x %d], format %s, bo %p\n",
@@ -372,7 +378,7 @@ GLboolean r100_blit(struct r100_context *r100,
}
/* Flush is needed to make sure that source buffer has correct data */
- radeonFlush(r100->radeon.glCtx);
+ radeonFlush(ctx);
rcommonEnsureCmdBufSpace(&r100->radeon, 59, __FUNCTION__);
@@ -392,7 +398,7 @@ GLboolean r100_blit(struct r100_context *r100,
reg_width, reg_height,
flip_y);
- radeonFlush(r100->radeon.glCtx);
+ radeonFlush(ctx);
return GL_TRUE;
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.h b/src/mesa/drivers/dri/radeon/radeon_blit.h
index c0203d0a54d..d36366ff791 100644
--- a/src/mesa/drivers/dri/radeon/radeon_blit.h
+++ b/src/mesa/drivers/dri/radeon/radeon_blit.h
@@ -30,25 +30,25 @@
void r100_blit_init(struct r100_context *r100);
-GLboolean r100_blit(struct r100_context *r100,
- 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 width,
- unsigned height,
- unsigned flip_y);
+unsigned r100_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 width,
+ unsigned height,
+ unsigned flip_y);
#endif // RADEON_BLIT_H
diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c
index 1182fc7f0d7..6c08a90bbd6 100644
--- a/src/mesa/drivers/dri/radeon/radeon_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_context.c
@@ -63,6 +63,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "radeon_tcl.h"
#include "radeon_maos.h"
#include "radeon_queryobj.h"
+#include "radeon_blit.h"
#define need_GL_ARB_occlusion_query
#define need_GL_EXT_blend_minmax
@@ -202,6 +203,7 @@ static void r100_init_vtbl(radeonContextPtr radeon)
radeon->vtbl.fallback = radeonFallback;
radeon->vtbl.free_context = r100_vtbl_free_context;
radeon->vtbl.emit_query_finish = r100_emit_query_finish;
+ radeon->vtbl.blit = r100_blit;
}
/* Create the device specific context.
@@ -258,13 +260,9 @@ r100CreateContext( const __GLcontextModes *glVisual,
* (the texture functions are especially important)
*/
_mesa_init_driver_functions( &functions );
- radeonInitTextureFuncs( &functions );
+ radeonInitTextureFuncs( &rmesa->radeon, &functions );
radeonInitQueryObjFunctions(&functions);
- if (rmesa->radeon.radeonScreen->kernel_mm) {
- r100_init_texcopy_functions(&functions);
- }
-
if (!radeonInitContext(&rmesa->radeon, &functions,
glVisual, driContextPriv,
sharedContextPrivate)) {
diff --git a/src/mesa/drivers/dri/radeon/radeon_context.h b/src/mesa/drivers/dri/radeon/radeon_context.h
index c52eff855f2..d84760bf74f 100644
--- a/src/mesa/drivers/dri/radeon/radeon_context.h
+++ b/src/mesa/drivers/dri/radeon/radeon_context.h
@@ -453,7 +453,6 @@ struct r100_context {
extern GLboolean r100CreateContext( const __GLcontextModes *glVisual,
__DRIcontext *driContextPriv,
void *sharedContextPrivate);
-extern void r100_init_texcopy_functions(struct dd_function_table *table);
#endif /* __RADEON_CONTEXT_H__ */
diff --git a/src/mesa/drivers/dri/radeon/radeon_tex.c b/src/mesa/drivers/dri/radeon/radeon_tex.c
index 14163f13af4..882ee5c194b 100644
--- a/src/mesa/drivers/dri/radeon/radeon_tex.c
+++ b/src/mesa/drivers/dri/radeon/radeon_tex.c
@@ -434,7 +434,7 @@ radeonNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
-void radeonInitTextureFuncs( struct dd_function_table *functions )
+void radeonInitTextureFuncs( radeonContextPtr radeon, struct dd_function_table *functions )
{
functions->ChooseTextureFormat = radeonChooseTextureFormat_mesa;
functions->TexImage1D = radeonTexImage1D;
@@ -455,6 +455,11 @@ void radeonInitTextureFuncs( 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;
functions->NewTextureImage = radeonNewTextureImage;
diff --git a/src/mesa/drivers/dri/radeon/radeon_tex.h b/src/mesa/drivers/dri/radeon/radeon_tex.h
index a4aaddc74fa..0113ffd3dac 100644
--- a/src/mesa/drivers/dri/radeon/radeon_tex.h
+++ b/src/mesa/drivers/dri/radeon/radeon_tex.h
@@ -52,6 +52,6 @@ extern int radeonUploadTexImages( r100ContextPtr rmesa, radeonTexObjPtr t,
extern void radeonDestroyTexObj( r100ContextPtr rmesa, radeonTexObjPtr t );
-extern void radeonInitTextureFuncs( struct dd_function_table *functions );
+extern void radeonInitTextureFuncs( radeonContextPtr radeon, struct dd_function_table *functions );
#endif /* __RADEON_TEX_H__ */
diff --git a/src/mesa/drivers/dri/radeon/radeon_texcopy.c b/src/mesa/drivers/dri/radeon/radeon_texcopy.c
deleted file mode 100644
index d4328982c3a..00000000000
--- a/src/mesa/drivers/dri/radeon/radeon_texcopy.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2009 Maciej Cencora <[email protected]>
- *
- * 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_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 "radeon_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)
-{
- struct r100_context *r100 = R100_CONTEXT(ctx);
- struct radeon_renderbuffer *rrb;
-
- if (_mesa_get_format_bits(timg->base.TexFormat, GL_DEPTH_BITS) > 0) {
- rrb = radeon_get_depthbuffer(&r100->radeon);
- } else {
- rrb = radeon_get_colorbuffer(&r100->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 (src_offset % 32 || dst_offset % 32) {
- return GL_FALSE;
- }
-
- 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 r100_blit(r100, rrb->bo, src_offset, rrb->base.Format, rrb->pitch,
- 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
-r100CopyTexImage2D(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
-r100CopyTexSubImage2D(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 r100_init_texcopy_functions(struct dd_function_table *table)
-{
- table->CopyTexImage2D = r100CopyTexImage2D;
- table->CopyTexSubImage2D = r100CopyTexSubImage2D;
-}