summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Deucher <alexdeucher@gmail.com>2009-03-02 00:21:12 -0500
committerAlex Deucher <alexdeucher@gmail.com>2009-03-02 00:21:12 -0500
commitb35c26fc4a318ec30b76bae6d420a1b73fa14fa6 (patch)
tree5128bcac8d3a78cd1f5a756955e4d29b06c75636
parent347b23d419c877de0ac95b1f2f69d6953dddfebd (diff)
R6xx/R7xx: write vertexes directly to the IB
Reduces the vertex buffer setup overhead
-rw-r--r--src/r600_exa.c188
-rw-r--r--src/r600_textured_videofuncs.c46
-rw-r--r--src/r6xx_accel.h28
3 files changed, 90 insertions, 172 deletions
diff --git a/src/r600_exa.c b/src/r600_exa.c
index 39c9737..7c677b4 100644
--- a/src/r600_exa.c
+++ b/src/r600_exa.c
@@ -263,8 +263,7 @@ R600Solid(PixmapPtr pPix, int x1, int y1, int x2, int y2)
ScrnInfoPtr pScrn = xf86Screens[pPix->drawable.pScreen->myNum];
RHDPtr rhdPtr = RHDPTR(pScrn);
struct r6xx_accel_state *accel_state = rhdPtr->TwoDPrivate;
- struct r6xx_solid_vertex vertex[3];
- struct r6xx_solid_vertex *solid_vb;
+ float *vb;
if (((accel_state->vb_index + 3) * 8) > (accel_state->ib->total / 2)) {
R600DoneSolid(pPix);
@@ -272,27 +271,21 @@ R600Solid(PixmapPtr pPix, int x1, int y1, int x2, int y2)
accel_state->ib = RHDDRMCPBuffer(pScrn->scrnIndex);
}
- solid_vb = (pointer)((char*)accel_state->ib->address + (accel_state->ib->total / 2));
+ vb = (pointer)((char*)accel_state->ib->address +
+ (accel_state->ib->total / 2) +
+ accel_state->vb_index * 8);
- vertex[0].x = (float)x1;
- vertex[0].y = (float)y1;
+ vb[0] = (float)x1;
+ vb[1] = (float)y1;
- vertex[1].x = (float)x1;
- vertex[1].y = (float)y2;
+ vb[2] = (float)x1;
+ vb[3] = (float)y2;
- vertex[2].x = (float)x2;
- vertex[2].y = (float)y2;
+ vb[4] = (float)x2;
+ vb[5] = (float)y2;
-#ifdef SHOW_VERTEXES
- ErrorF("vertex 0: %f, %f\n", vertex[0].x, vertex[0].y);
- ErrorF("vertex 1: %f, %f\n", vertex[1].x, vertex[1].y);
- ErrorF("vertex 2: %f\n", vertex[2].x, vertex[2].y);
-#endif
+ accel_state->vb_index += 3;
- /* append to vertex buffer */
- solid_vb[accel_state->vb_index++] = vertex[0];
- solid_vb[accel_state->vb_index++] = vertex[1];
- solid_vb[accel_state->vb_index++] = vertex[2];
}
static void
@@ -606,8 +599,7 @@ R600AppendCopyVertex(ScrnInfoPtr pScrn,
{
RHDPtr rhdPtr = RHDPTR(pScrn);
struct r6xx_accel_state *accel_state = rhdPtr->TwoDPrivate;
- struct r6xx_copy_vertex *copy_vb;
- struct r6xx_copy_vertex vertex[3];
+ float *vb;
if (((accel_state->vb_index + 3) * 16) > (accel_state->ib->total / 2)) {
R600DoCopy(pScrn);
@@ -615,34 +607,26 @@ R600AppendCopyVertex(ScrnInfoPtr pScrn,
accel_state->ib = RHDDRMCPBuffer(pScrn->scrnIndex);
}
- copy_vb = (pointer)((char*)accel_state->ib->address + (accel_state->ib->total / 2));
-
- vertex[0].x = (float)dstX;
- vertex[0].y = (float)dstY;
- vertex[0].s = (float)srcX;
- vertex[0].t = (float)srcY;
+ vb = (pointer)((char*)accel_state->ib->address +
+ (accel_state->ib->total / 2) +
+ accel_state->vb_index * 16);
- vertex[1].x = (float)dstX;
- vertex[1].y = (float)(dstY + h);
- vertex[1].s = (float)srcX;
- vertex[1].t = (float)(srcY + h);
+ vb[0] = (float)dstX;
+ vb[1] = (float)dstY;
+ vb[2] = (float)srcX;
+ vb[3] = (float)srcY;
- vertex[2].x = (float)(dstX + w);
- vertex[2].y = (float)(dstY + h);
- vertex[2].s = (float)(srcX + w);
- vertex[2].t = (float)(srcY + h);
-
-#ifdef SHOW_VERTEXES
- ErrorF("vertex 0: %f, %f, %f, %d\n", vertex[0].x, vertex[0].y, vertex[0].s, vertex[0].t);
- ErrorF("vertex 1: %f, %f, %f, %d\n", vertex[1].x, vertex[1].y, vertex[1].s, vertex[1].t);
- ErrorF("vertex 2: %f, %f, %f, %d\n", vertex[2].x, vertex[2].y, vertex[2].s, vertex[2].t);
-#endif
+ vb[4] = (float)dstX;
+ vb[5] = (float)(dstY + h);
+ vb[6] = (float)srcX;
+ vb[7] = (float)(srcY + h);
- /* append to vertex buffer */
- copy_vb[accel_state->vb_index++] = vertex[0];
- copy_vb[accel_state->vb_index++] = vertex[1];
- copy_vb[accel_state->vb_index++] = vertex[2];
+ vb[8] = (float)(dstX + w);
+ vb[9] = (float)(dstY + h);
+ vb[10] = (float)(srcX + w);
+ vb[11] = (float)(srcY + h);
+ accel_state->vb_index += 3;
}
static Bool
@@ -1675,6 +1659,7 @@ static void R600Composite(PixmapPtr pDst,
ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum];
RHDPtr rhdPtr = RHDPTR(pScrn);
struct r6xx_accel_state *accel_state = rhdPtr->TwoDPrivate;
+ float *vb;
xPointFixed srcTopLeft, srcTopRight, srcBottomLeft, srcBottomRight;
/* ErrorF("R600Composite (%d,%d) (%d,%d) (%d,%d) (%d,%d)\n",
@@ -1698,8 +1683,6 @@ static void R600Composite(PixmapPtr pDst,
}
if (accel_state->has_mask) {
- struct r6xx_comp_mask_vertex *comp_vb;
- struct r6xx_comp_mask_vertex vertex[3];
xPointFixed maskTopLeft, maskTopRight, maskBottomLeft, maskBottomRight;
if (((accel_state->vb_index + 3) * 24) > (accel_state->ib->total / 2)) {
@@ -1708,7 +1691,9 @@ static void R600Composite(PixmapPtr pDst,
accel_state->ib = RHDDRMCPBuffer(pScrn->scrnIndex);
}
- comp_vb = (pointer)((char*)accel_state->ib->address + (accel_state->ib->total / 2));
+ vb = (pointer)((char*)accel_state->ib->address +
+ (accel_state->ib->total / 2) +
+ accel_state->vb_index * 24);
maskTopLeft.x = IntToxFixed(maskX);
maskTopLeft.y = IntToxFixed(maskY);
@@ -1726,80 +1711,49 @@ static void R600Composite(PixmapPtr pDst,
transformPoint(accel_state->transform[1], &maskBottomRight);
}
- vertex[0].x = (float)dstX;
- vertex[0].y = (float)dstY;
- vertex[0].src_s = xFixedToFloat(srcTopLeft.x) / accel_state->texW[0];
- vertex[0].src_t = xFixedToFloat(srcTopLeft.y) / accel_state->texH[0];
- vertex[0].mask_s = xFixedToFloat(maskTopLeft.x) / accel_state->texW[1];
- vertex[0].mask_t = xFixedToFloat(maskTopLeft.y) / accel_state->texH[1];
-
- vertex[1].x = (float)dstX;
- vertex[1].y = (float)(dstY + h);
- vertex[1].src_s = xFixedToFloat(srcBottomLeft.x) / accel_state->texW[0];
- vertex[1].src_t = xFixedToFloat(srcBottomLeft.y) / accel_state->texH[0];
- vertex[1].mask_s = xFixedToFloat(maskBottomLeft.x) / accel_state->texW[1];
- vertex[1].mask_t = xFixedToFloat(maskBottomLeft.y) / accel_state->texH[1];
-
- vertex[2].x = (float)(dstX + w);
- vertex[2].y = (float)(dstY + h);
- vertex[2].src_s = xFixedToFloat(srcBottomRight.x) / accel_state->texW[0];
- vertex[2].src_t = xFixedToFloat(srcBottomRight.y) / accel_state->texH[0];
- vertex[2].mask_s = xFixedToFloat(maskBottomRight.x) / accel_state->texW[1];
- vertex[2].mask_t = xFixedToFloat(maskBottomRight.y) / accel_state->texH[1];
-
-#ifdef SHOW_VERTEXES
- ErrorF("vertex 0: %d, %d, %f, %f, %f, %f\n", vertex[0].x, vertex[0].y,
- vertex[0].src_s, vertex[0].src_t, vertex[0].mask_s, vertex[0].mask_t);
- ErrorF("vertex 1: %d, %d, %f, %f, %f, %f\n", vertex[1].x, vertex[1].y,
- vertex[1].src_s, vertex[1].src_t, vertex[1].mask_s, vertex[1].mask_t);
- ErrorF("vertex 2: %d, %d, %f, %f, %f, %f\n", vertex[2].x, vertex[2].y,
- vertex[2].src_s, vertex[2].src_t, vertex[2].mask_s, vertex[2].mask_t);
-#endif
-
- /* append to vertex buffer */
- comp_vb[accel_state->vb_index++] = vertex[0];
- comp_vb[accel_state->vb_index++] = vertex[1];
- comp_vb[accel_state->vb_index++] = vertex[2];
+ vb[0] = (float)dstX;
+ vb[1] = (float)dstY;
+ vb[2] = xFixedToFloat(srcTopLeft.x) / accel_state->texW[0];
+ vb[3] = xFixedToFloat(srcTopLeft.y) / accel_state->texH[0];
+ vb[4] = xFixedToFloat(maskTopLeft.x) / accel_state->texW[1];
+ vb[5] = xFixedToFloat(maskTopLeft.y) / accel_state->texH[1];
+
+ vb[6] = (float)dstX;
+ vb[7] = (float)(dstY + h);
+ vb[8] = xFixedToFloat(srcBottomLeft.x) / accel_state->texW[0];
+ vb[9] = xFixedToFloat(srcBottomLeft.y) / accel_state->texH[0];
+ vb[10] = xFixedToFloat(maskBottomLeft.x) / accel_state->texW[1];
+ vb[11] = xFixedToFloat(maskBottomLeft.y) / accel_state->texH[1];
+
+ vb[12] = (float)(dstX + w);
+ vb[13] = (float)(dstY + h);
+ vb[14] = xFixedToFloat(srcBottomRight.x) / accel_state->texW[0];
+ vb[15] = xFixedToFloat(srcBottomRight.y) / accel_state->texH[0];
+ vb[16] = xFixedToFloat(maskBottomRight.x) / accel_state->texW[1];
+ vb[17] = xFixedToFloat(maskBottomRight.y) / accel_state->texH[1];
} else {
- struct r6xx_comp_vertex *comp_vb;
- struct r6xx_comp_vertex vertex[3];
-
- if (((accel_state->vb_index + 3) * 16) > (accel_state->ib->total / 2)) {
- R600DoneComposite(pDst);
- accel_state->vb_index = 0;
- accel_state->ib = RHDDRMCPBuffer(pScrn->scrnIndex);
- }
-
- comp_vb = (pointer)((char*)accel_state->ib->address + (accel_state->ib->total / 2));
-
- vertex[0].x = (float)dstX;
- vertex[0].y = (float)dstY;
- vertex[0].src_s = xFixedToFloat(srcTopLeft.x) / accel_state->texW[0];
- vertex[0].src_t = xFixedToFloat(srcTopLeft.y) / accel_state->texH[0];
-
- vertex[1].x = (float)dstX;
- vertex[1].y = (float)(dstY + h);
- vertex[1].src_s = xFixedToFloat(srcBottomLeft.x) / accel_state->texW[0];
- vertex[1].src_t = xFixedToFloat(srcBottomLeft.y) / accel_state->texH[0];
-
- vertex[2].x = (float)(dstX + w);
- vertex[2].y = (float)(dstY + h);
- vertex[2].src_s = xFixedToFloat(srcBottomRight.x) / accel_state->texW[0];
- vertex[2].src_t = xFixedToFloat(srcBottomRight.y) / accel_state->texH[0];
-
- /* append to vertex buffer */
- comp_vb[accel_state->vb_index++] = vertex[0];
- comp_vb[accel_state->vb_index++] = vertex[1];
- comp_vb[accel_state->vb_index++] = vertex[2];
-
-#ifdef SHOW_VERTEXES
- ErrorF("vertex 0: %d, %d, %f, %f\n", vertex[0].x, vertex[0].y, vertex[0].src_s, vertex[0].src_t);
- ErrorF("vertex 1: %d, %d, %f, %f\n", vertex[1].x, vertex[1].y, vertex[1].src_s, vertex[1].src_t);
- ErrorF("vertex 2: %d, %d, %f, %f\n", vertex[2].x, vertex[2].y, vertex[2].src_s, vertex[2].src_t);
-#endif
+ vb = (pointer)((char*)accel_state->ib->address +
+ (accel_state->ib->total / 2) +
+ accel_state->vb_index * 16);
+
+ vb[0] = (float)dstX;
+ vb[1] = (float)dstY;
+ vb[2] = xFixedToFloat(srcTopLeft.x) / accel_state->texW[0];
+ vb[3] = xFixedToFloat(srcTopLeft.y) / accel_state->texH[0];
+
+ vb[4] = (float)dstX;
+ vb[5] = (float)(dstY + h);
+ vb[6] = xFixedToFloat(srcBottomLeft.x) / accel_state->texW[0];
+ vb[7] = xFixedToFloat(srcBottomLeft.y) / accel_state->texH[0];
+
+ vb[8] = (float)(dstX + w);
+ vb[9] = (float)(dstY + h);
+ vb[10] = xFixedToFloat(srcBottomRight.x) / accel_state->texW[0];
+ vb[11] = xFixedToFloat(srcBottomRight.y) / accel_state->texH[0];
}
+ accel_state->vb_index += 3;
}
diff --git a/src/r600_textured_videofuncs.c b/src/r600_textured_videofuncs.c
index 261c4d5..3b77e2e 100644
--- a/src/r600_textured_videofuncs.c
+++ b/src/r600_textured_videofuncs.c
@@ -478,8 +478,7 @@ R600DisplayTexturedVideo(ScrnInfoPtr pScrn, struct RHDPortPriv *pPriv)
while (nBox--) {
int srcX, srcY, srcw, srch;
int dstX, dstY, dstw, dsth;
- struct r6xx_copy_vertex *xv_vb;
- struct r6xx_copy_vertex vertex[3];
+ float *vb;
if (((accel_state->vb_index + 3) * 16) > (accel_state->ib->total / 2)) {
R600DoneTexturedVideo(pScrn);
@@ -487,7 +486,9 @@ R600DisplayTexturedVideo(ScrnInfoPtr pScrn, struct RHDPortPriv *pPriv)
accel_state->ib = RHDDRMCPBuffer(pScrn->scrnIndex);
}
- xv_vb = (pointer)((char*)accel_state->ib->address + (accel_state->ib->total / 2));
+ vb = (pointer)((char*)accel_state->ib->address +
+ (accel_state->ib->total / 2) +
+ accel_state->vb_index * 16);
dstX = pBox->x1 + dstxoff;
dstY = pBox->y1 + dstyoff;
@@ -502,31 +503,22 @@ R600DisplayTexturedVideo(ScrnInfoPtr pScrn, struct RHDPortPriv *pPriv)
srcw = (pPriv->src_w * dstw) / pPriv->dst_w;
srch = (pPriv->src_h * dsth) / pPriv->dst_h;
- vertex[0].x = (float)dstX;
- vertex[0].y = (float)dstY;
- vertex[0].s = (float)srcX / pPriv->w;
- vertex[0].t = (float)srcY / pPriv->h;
-
- vertex[1].x = (float)dstX;
- vertex[1].y = (float)(dstY + dsth);
- vertex[1].s = (float)srcX / pPriv->w;
- vertex[1].t = (float)(srcY + srch) / pPriv->h;
-
- vertex[2].x = (float)(dstX + dstw);
- vertex[2].y = (float)(dstY + dsth);
- vertex[2].s = (float)(srcX + srcw) / pPriv->w;
- vertex[2].t = (float)(srcY + srch) / pPriv->h;
-
-#if 0
- ErrorF("vertex 0: %f, %f, %f, %f\n", vertex[0].x, vertex[0].y, vertex[0].s, vertex[0].t);
- ErrorF("vertex 1: %f, %f, %f, %f\n", vertex[1].x, vertex[1].y, vertex[1].s, vertex[1].t);
- ErrorF("vertex 2: %f, %f, %f, %f\n", vertex[2].x, vertex[2].y, vertex[2].s, vertex[2].t);
-#endif
+ vb[0] = (float)dstX;
+ vb[1] = (float)dstY;
+ vb[2] = (float)srcX / pPriv->w;
+ vb[3] = (float)srcY / pPriv->h;
+
+ vb[4] = (float)dstX;
+ vb[5] = (float)(dstY + dsth);
+ vb[6] = (float)srcX / pPriv->w;
+ vb[7] = (float)(srcY + srch) / pPriv->h;
+
+ vb[8] = (float)(dstX + dstw);
+ vb[9] = (float)(dstY + dsth);
+ vb[10] = (float)(srcX + srcw) / pPriv->w;
+ vb[11] = (float)(srcY + srch) / pPriv->h;
- // append to vertex buffer
- xv_vb[accel_state->vb_index++] = vertex[0];
- xv_vb[accel_state->vb_index++] = vertex[1];
- xv_vb[accel_state->vb_index++] = vertex[2];
+ accel_state->vb_index += 3;
pBox++;
}
diff --git a/src/r6xx_accel.h b/src/r6xx_accel.h
index c39b971..17cb6bc 100644
--- a/src/r6xx_accel.h
+++ b/src/r6xx_accel.h
@@ -21,34 +21,6 @@ RADEONGetDrawablePixmap(DrawablePtr pDrawable);
void
R6xxIdle(ScrnInfoPtr pScrn);
-struct r6xx_solid_vertex {
- float x;
- float y;
-};
-
-struct r6xx_copy_vertex {
- float x;
- float y;
- float s;
- float t;
-};
-
-struct r6xx_comp_vertex {
- float x;
- float y;
- float src_s;
- float src_t;
-};
-
-struct r6xx_comp_mask_vertex {
- float x;
- float y;
- float src_s;
- float src_t;
- float mask_s;
- float mask_t;
-};
-
struct r6xx_accel_state {
Bool XHas3DEngineState;