summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaciej Cencora <[email protected]>2009-12-15 23:57:05 +0100
committerMaciej Cencora <[email protected]>2009-12-19 14:43:08 +0100
commita1428868a66ab70a762ad863dafa00c3099f3d8a (patch)
treebc624e8da2677b7cf3ed33259db139a599bda027
parent759fd1f25f33273e0b7c02598bfa5b97d1a82d77 (diff)
r300: better fix for glCopyTexSubImage
-rw-r--r--src/mesa/drivers/dri/r300/r300_blit.c32
-rw-r--r--src/mesa/drivers/dri/r300/r300_texcopy.c6
2 files changed, 22 insertions, 16 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_blit.c b/src/mesa/drivers/dri/r300/r300_blit.c
index ca6dd3bcf8e..d03fbfa07d6 100644
--- a/src/mesa/drivers/dri/r300/r300_blit.c
+++ b/src/mesa/drivers/dri/r300/r300_blit.c
@@ -162,7 +162,7 @@ static void r300_emit_tx_setup(struct r300_context *r300,
R300_TX_SIZE_TXPITCH_EN);
OUT_BATCH_REGVAL(R300_TX_FORMAT_0, r300TranslateTexFormat(mesa_format));
- OUT_BATCH_REGVAL(R300_TX_FORMAT2_0, pitch/_mesa_get_format_bytes(mesa_format) - 1);
+ OUT_BATCH_REGVAL(R300_TX_FORMAT2_0, pitch - 1);
OUT_BATCH_REGSEQ(R300_TX_OFFSET_0, 1);
OUT_BATCH_RELOC(0, bo, offset, RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
@@ -339,7 +339,7 @@ static void emit_pvs_setup(struct r300_context *r300,
END_BATCH();
}
-static void emit_vap_setup(struct r300_context *r300, unsigned width, unsigned height)
+static void emit_vap_setup(struct r300_context *r300)
{
BATCH_LOCALS(&r300->radeon);
@@ -389,12 +389,14 @@ static GLboolean validate_buffers(struct r300_context *r300,
return GL_TRUE;
}
-static void emit_draw_packet(struct r300_context *r300, float width, float height)
+static void emit_draw_packet(struct r300_context *r300,
+ float src_width, float src_height,
+ float dst_width, float dst_height)
{
- float verts[] = { 0.0, 0.0, 0.0, 1.0,
- 0.0, height, 0.0, 0.0,
- width, height, 1.0, 0.0,
- width, 0.0, 1.0, 1.0 };
+ float verts[] = { 0.0, 0.0, 0.0, 1.0,
+ 0.0, dst_height, 0.0, 1.0 - dst_height/src_height,
+ dst_width, dst_height, dst_width/src_width, 1.0 - dst_height/src_height,
+ dst_width, 0.0, dst_width/src_width, 1.0 };
BATCH_LOCALS(&r300->radeon);
@@ -473,18 +475,22 @@ GLboolean r300_blit(struct r300_context *r300,
unsigned dst_width,
unsigned dst_height)
{
+ /* Need to clamp the destination size to make sure
+ * we don't write outside of the buffer
+ */
+ dst_width = MIN2(dst_width, src_width);
+ dst_height = MIN2(src_height, dst_height);
+
if (src_bo == dst_bo) {
return GL_FALSE;
}
if (0) {
- fprintf(stderr, "src: width %d, height %d, pitch %d vs %d, format %s\n",
+ fprintf(stderr, "src: width %d, height %d, pitch %d, format %s\n",
src_width, src_height, src_pitch,
- _mesa_format_row_stride(src_mesaformat, src_width),
_mesa_get_format_name(src_mesaformat));
fprintf(stderr, "dst: width %d, height %d, pitch %d, format %s\n",
- dst_width, dst_height,
- _mesa_format_row_stride(dst_mesaformat, dst_width),
+ dst_width, dst_height, dst_pitch,
_mesa_get_format_name(dst_mesaformat));
}
@@ -506,11 +512,11 @@ GLboolean r300_blit(struct r300_context *r300,
}
emit_pvs_setup(r300, r300->blit.vp_code.body.d, 2);
- emit_vap_setup(r300, dst_width, dst_height);
+ emit_vap_setup(r300);
emit_cb_setup(r300, dst_bo, dst_offset, dst_mesaformat, dst_pitch, dst_width, dst_height);
- emit_draw_packet(r300, dst_width, dst_height);
+ emit_draw_packet(r300, src_width, src_height, dst_width, dst_height);
r300EmitCacheFlush(r300);
diff --git a/src/mesa/drivers/dri/r300/r300_texcopy.c b/src/mesa/drivers/dri/r300/r300_texcopy.c
index 7702a1d67df..893c8586f7e 100644
--- a/src/mesa/drivers/dri/r300/r300_texcopy.c
+++ b/src/mesa/drivers/dri/r300/r300_texcopy.c
@@ -77,14 +77,14 @@ do_copy_texsubimage(GLcontext *ctx,
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, width %d\n",
- x, y, width, height, (uint32_t) src_offset, rrb->pitch, rrb->pitch/rrb->cpp);
+ 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_blit(r300, rrb->bo, src_offset, rrb->base.Format, rrb->pitch,
+ return r300_blit(r300, rrb->bo, src_offset, rrb->base.Format, rrb->pitch/rrb->cpp,
rrb->base.Width, rrb->base.Height, timg->mt->bo ? timg->mt->bo : timg->bo, dst_offset,
timg->base.TexFormat, timg->base.Width, width, height);
}