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);
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);
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);
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));
}
}
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);
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);
}