summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenri Verbeet <hverbeet@gmail.com>2010-09-04 18:03:17 +0200
committerHenri Verbeet <hverbeet@gmail.com>2010-09-05 20:26:14 +0200
commit50b9c54ef6b813b348df7e63a0cf291d3d9d39f4 (patch)
treee2fb3c9e4ae71808726947b58e0119c9989ae50b
parent029c1815717ea62bae28e86798c86dfa98cbc8a7 (diff)
radeon: Make do_blit_readpixels() into a PBO work.
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_pixel_read.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/mesa/drivers/dri/radeon/radeon_pixel_read.c b/src/mesa/drivers/dri/radeon/radeon_pixel_read.c
index fb741173ca..216eb932db 100644
--- a/src/mesa/drivers/dri/radeon/radeon_pixel_read.c
+++ b/src/mesa/drivers/dri/radeon/radeon_pixel_read.c
@@ -32,6 +32,7 @@
#include "main/state.h"
#include "swrast/swrast.h"
+#include "radeon_buffer_objects.h"
#include "radeon_common_context.h"
#include "radeon_debug.h"
#include "radeon_mipmap_tree.h"
@@ -96,6 +97,7 @@ do_blit_readpixels(GLcontext * ctx,
unsigned dst_rowstride, dst_imagesize, aligned_rowstride, flip_y;
struct radeon_bo *dst_buffer;
GLint dst_x = 0, dst_y = 0;
+ intptr_t dst_offset;
/* It's not worth if number of pixels to copy is really small */
if (width * height < 100) {
@@ -127,10 +129,23 @@ do_blit_readpixels(GLcontext * ctx,
assert(x >= 0 && y >= 0);
aligned_rowstride = get_texture_image_row_stride(radeon, dst_format, dst_rowstride, 0);
+ dst_rowstride *= _mesa_get_format_bytes(dst_format);
+ if (_mesa_is_bufferobj(pack->BufferObj) && aligned_rowstride != dst_rowstride)
+ return GL_FALSE;
dst_imagesize = get_texture_image_size(dst_format,
aligned_rowstride,
height, 1, 0);
- dst_buffer = radeon_bo_open(radeon->radeonScreen->bom, 0, dst_imagesize, 1024, RADEON_GEM_DOMAIN_GTT, 0);
+
+ if (!_mesa_is_bufferobj(pack->BufferObj))
+ {
+ dst_buffer = radeon_bo_open(radeon->radeonScreen->bom, 0, dst_imagesize, 1024, RADEON_GEM_DOMAIN_GTT, 0);
+ dst_offset = 0;
+ }
+ else
+ {
+ dst_buffer = get_radeon_buffer_object(pack->BufferObj)->bo;
+ dst_offset = (intptr_t)pixels;
+ }
/* Disable source Y flipping for FBOs */
flip_y = (ctx->ReadBuffer->Name == 0);
@@ -149,7 +164,7 @@ do_blit_readpixels(GLcontext * ctx,
x,
y,
dst_buffer,
- 0, /* dst_offset */
+ dst_offset,
dst_format,
aligned_rowstride / _mesa_get_format_bytes(dst_format),
width,
@@ -160,17 +175,22 @@ do_blit_readpixels(GLcontext * ctx,
height,
flip_y))
{
- radeon_bo_map(dst_buffer, 0);
- dst_rowstride *= _mesa_get_format_bytes(dst_format);
- copy_rows(pixels, dst_rowstride, dst_buffer->ptr,
- aligned_rowstride, height, dst_rowstride);
- radeon_bo_unmap(dst_buffer);
- radeon_bo_unref(dst_buffer);
+ if (!_mesa_is_bufferobj(pack->BufferObj))
+ {
+ radeon_bo_map(dst_buffer, 0);
+ copy_rows(pixels, dst_rowstride, dst_buffer->ptr,
+ aligned_rowstride, height, dst_rowstride);
+ radeon_bo_unmap(dst_buffer);
+ radeon_bo_unref(dst_buffer);
+ }
+
return GL_TRUE;
- } else {
- radeon_bo_unref(dst_buffer);
- return GL_FALSE;
}
+
+ if (!_mesa_is_bufferobj(pack->BufferObj))
+ radeon_bo_unref(dst_buffer);
+
+ return GL_FALSE;
}
void