[PATCH] radeon: avoid rounding errors in texture coords for textured xv
Roland Scheidegger
rscheidegger_lists at hispeed.ch
Sat Feb 18 12:21:48 PST 2012
make sure the division is done with floats, otherwise the coordinate
can be wrong up to 1 texel.
Particularly visible with clipping and small source scaled up (since one
texel can be a shift of several pixels) but could be seen even unscaled.
Should provide more accurate coords without clipping too depending on the
scale factor probably.
Changed for r100-r600, though only tested on r300.
---
src/r600_textured_videofuncs.c | 10 +++---
src/radeon_textured_videofuncs.c | 60 +++++++++++++++++++-------------------
2 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/src/r600_textured_videofuncs.c b/src/r600_textured_videofuncs.c
index 986650a..62da992 100644
--- a/src/r600_textured_videofuncs.c
+++ b/src/r600_textured_videofuncs.c
@@ -503,7 +503,7 @@ R600DisplayTexturedVideo(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
}
while (nBox--) {
- int srcX, srcY, srcw, srch;
+ float srcX, srcY, srcw, srch;
int dstX, dstY, dstw, dsth;
float *vb;
@@ -515,13 +515,13 @@ R600DisplayTexturedVideo(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
srcX = pPriv->src_x;
srcX += ((pBox->x1 - pPriv->drw_x) *
- pPriv->src_w) / pPriv->dst_w;
+ pPriv->src_w) / (float)pPriv->dst_w;
srcY = pPriv->src_y;
srcY += ((pBox->y1 - pPriv->drw_y) *
- pPriv->src_h) / pPriv->dst_h;
+ pPriv->src_h) / (float)pPriv->dst_h;
- srcw = (pPriv->src_w * dstw) / pPriv->dst_w;
- srch = (pPriv->src_h * dsth) / pPriv->dst_h;
+ srcw = (pPriv->src_w * dstw) / (float)pPriv->dst_w;
+ srch = (pPriv->src_h * dsth) / (float)pPriv->dst_h;
vb = radeon_vbo_space(pScrn, &accel_state->vbo, 16);
diff --git a/src/radeon_textured_videofuncs.c b/src/radeon_textured_videofuncs.c
index 7d4a1c1..7119553 100644
--- a/src/radeon_textured_videofuncs.c
+++ b/src/radeon_textured_videofuncs.c
@@ -437,7 +437,7 @@ FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv
((loop_boxes * 3) << RADEON_CP_VC_CNTL_NUM_SHIFT));
while (loop_boxes--) {
- int srcX, srcY, srcw, srch;
+ float srcX, srcY, srcw, srch;
int dstX, dstY, dstw, dsth;
dstX = pBox->x1 + dstxoff;
dstY = pBox->y1 + dstyoff;
@@ -446,13 +446,13 @@ FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv
srcX = pPriv->src_x;
srcX += ((pBox->x1 - pPriv->drw_x) *
- pPriv->src_w) / pPriv->dst_w;
+ pPriv->src_w) / (float)pPriv->dst_w;
srcY = pPriv->src_y;
srcY += ((pBox->y1 - pPriv->drw_y) *
- pPriv->src_h) / pPriv->dst_h;
+ pPriv->src_h) / (float)pPriv->dst_h;
- srcw = (pPriv->src_w * dstw) / pPriv->dst_w;
- srch = (pPriv->src_h * dsth) / pPriv->dst_h;
+ srcw = (pPriv->src_w * dstw) / (float)pPriv->dst_w;
+ srch = (pPriv->src_h * dsth) / (float)pPriv->dst_h;
if (pPriv->is_planar) {
@@ -493,7 +493,7 @@ FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv
RADEON_VF_RADEON_MODE |
((nBox * 3) << RADEON_VF_NUM_VERTICES_SHIFT)));
while (nBox--) {
- int srcX, srcY, srcw, srch;
+ float srcX, srcY, srcw, srch;
int dstX, dstY, dstw, dsth;
dstX = pBox->x1 + dstxoff;
dstY = pBox->y1 + dstyoff;
@@ -502,13 +502,13 @@ FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv
srcX = pPriv->src_x;
srcX += ((pBox->x1 - pPriv->drw_x) *
- pPriv->src_w) / pPriv->dst_w;
+ pPriv->src_w) / (float)pPriv->dst_w;
srcY = pPriv->src_y;
srcY += ((pBox->y1 - pPriv->drw_y) *
- pPriv->src_h) / pPriv->dst_h;
+ pPriv->src_h) / (float)pPriv->dst_h;
- srcw = (pPriv->src_w * dstw) / pPriv->dst_w;
- srch = (pPriv->src_h * dsth) / pPriv->dst_h;
+ srcw = (pPriv->src_w * dstw) / (float)pPriv->dst_w;
+ srch = (pPriv->src_h * dsth) / (float)pPriv->dst_h;
if (pPriv->is_planar) {
@@ -1070,7 +1070,7 @@ FUNC_NAME(R200DisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
((loop_boxes * 3) << RADEON_CP_VC_CNTL_NUM_SHIFT));
while (loop_boxes--) {
- int srcX, srcY, srcw, srch;
+ float srcX, srcY, srcw, srch;
int dstX, dstY, dstw, dsth;
dstX = pBox->x1 + dstxoff;
dstY = pBox->y1 + dstyoff;
@@ -1079,13 +1079,13 @@ FUNC_NAME(R200DisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
srcX = pPriv->src_x;
srcX += ((pBox->x1 - pPriv->drw_x) *
- pPriv->src_w) / pPriv->dst_w;
+ pPriv->src_w) / (float)pPriv->dst_w;
srcY = pPriv->src_y;
srcY += ((pBox->y1 - pPriv->drw_y) *
- pPriv->src_h) / pPriv->dst_h;
+ pPriv->src_h) / (float)pPriv->dst_h;
- srcw = (pPriv->src_w * dstw) / pPriv->dst_w;
- srch = (pPriv->src_h * dsth) / pPriv->dst_h;
+ srcw = (pPriv->src_w * dstw) / (float)pPriv->dst_w;
+ srch = (pPriv->src_h * dsth) / (float)pPriv->dst_h;
if (pPriv->is_planar) {
/*
@@ -1124,7 +1124,7 @@ FUNC_NAME(R200DisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
RADEON_VF_PRIM_WALK_DATA |
((nBox * 3) << RADEON_VF_NUM_VERTICES_SHIFT)));
while (nBox--) {
- int srcX, srcY, srcw, srch;
+ float srcX, srcY, srcw, srch;
int dstX, dstY, dstw, dsth;
dstX = pBox->x1 + dstxoff;
dstY = pBox->y1 + dstyoff;
@@ -1133,13 +1133,13 @@ FUNC_NAME(R200DisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
srcX = pPriv->src_x;
srcX += ((pBox->x1 - pPriv->drw_x) *
- pPriv->src_w) / pPriv->dst_w;
+ pPriv->src_w) / (float)pPriv->dst_w;
srcY = pPriv->src_y;
srcY += ((pBox->y1 - pPriv->drw_y) *
- pPriv->src_h) / pPriv->dst_h;
+ pPriv->src_h) / (float)pPriv->dst_h;
- srcw = (pPriv->src_w * dstw) / pPriv->dst_w;
- srch = (pPriv->src_h * dsth) / pPriv->dst_h;
+ srcw = (pPriv->src_w * dstw) / (float)pPriv->dst_w;
+ srch = (pPriv->src_h * dsth) / (float)pPriv->dst_h;
if (pPriv->is_planar) {
/*
@@ -2499,7 +2499,7 @@ FUNC_NAME(R300DisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
*/
while (nBox--) {
- int srcX, srcY, srcw, srch;
+ float srcX, srcY, srcw, srch;
int dstX, dstY, dstw, dsth;
Bool use_quad = FALSE;
#ifdef ACCEL_CP
@@ -2522,13 +2522,13 @@ FUNC_NAME(R300DisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
srcX = pPriv->src_x;
srcX += ((pBox->x1 - pPriv->drw_x) *
- pPriv->src_w) / pPriv->dst_w;
+ pPriv->src_w) / (float)pPriv->dst_w;
srcY = pPriv->src_y;
srcY += ((pBox->y1 - pPriv->drw_y) *
- pPriv->src_h) / pPriv->dst_h;
+ pPriv->src_h) / (float)pPriv->dst_h;
- srcw = (pPriv->src_w * dstw) / pPriv->dst_w;
- srch = (pPriv->src_h * dsth) / pPriv->dst_h;
+ srcw = (pPriv->src_w * dstw) / (float)pPriv->dst_w;
+ srch = (pPriv->src_h * dsth) / (float)pPriv->dst_h;
if (IS_R400_3D) {
if ((dstw+dsth) > 4021)
@@ -4130,7 +4130,7 @@ FUNC_NAME(R500DisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
*/
while (nBox--) {
- int srcX, srcY, srcw, srch;
+ float srcX, srcY, srcw, srch;
int dstX, dstY, dstw, dsth;
#ifdef ACCEL_CP
int draw_size = 3 * pPriv->vtx_count + 4 + 2 + 3;
@@ -4152,13 +4152,13 @@ FUNC_NAME(R500DisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
srcX = pPriv->src_x;
srcX += ((pBox->x1 - pPriv->drw_x) *
- pPriv->src_w) / pPriv->dst_w;
+ pPriv->src_w) / (float)pPriv->dst_w;
srcY = pPriv->src_y;
srcY += ((pBox->y1 - pPriv->drw_y) *
- pPriv->src_h) / pPriv->dst_h;
+ pPriv->src_h) / (float)pPriv->dst_h;
- srcw = (pPriv->src_w * dstw) / pPriv->dst_w;
- srch = (pPriv->src_h * dsth) / pPriv->dst_h;
+ srcw = (pPriv->src_w * dstw) / (float)pPriv->dst_w;
+ srch = (pPriv->src_h * dsth) / (float)pPriv->dst_h;
BEGIN_ACCEL(2);
OUT_ACCEL_REG(R300_SC_SCISSOR0, (((dstX) << R300_SCISSOR_X_SHIFT) |
--
1.7.1
More information about the xorg-driver-ati
mailing list