summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoland Scheidegger <rscheidegger_lists@hispeed.ch>2012-02-18 21:12:34 +0100
committerRoland Scheidegger <rscheidegger_lists@hispeed.ch>2012-02-20 15:24:04 +0100
commit688c8a54a00b01e73a11970ad2abe858f8c7c5c4 (patch)
treefcc2cc6d56df1818f01302527534bd7c2908dfd1 /src
parent2778b56252124ef6f636a493d2e1457b43911c37 (diff)
radeon: avoid rounding errors in texture coords for textured xv
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.
Diffstat (limited to 'src')
-rw-r--r--src/r600_textured_videofuncs.c10
-rw-r--r--src/radeon_textured_videofuncs.c60
2 files changed, 35 insertions, 35 deletions
diff --git a/src/r600_textured_videofuncs.c b/src/r600_textured_videofuncs.c
index 986650a4..62da992c 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 7d4a1c11..71195530 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) |