xf86-video-ati: Branch 'kms-support' - 3 commits
Dave Airlie
airlied at kemper.freedesktop.org
Wed Jun 17 22:59:13 PDT 2009
src/radeon_exa_funcs.c | 17 +---
src/radeon_exa_render.c | 152 ++++++++-------------------------------
src/radeon_macros.h | 29 +++++++
src/radeon_textured_video.c | 5 +
src/radeon_textured_videofuncs.c | 61 +++------------
5 files changed, 89 insertions(+), 175 deletions(-)
New commits:
commit 2174d880152ad5c47e2a28b3e9ab65a8d319a9af
Author: Dave Airlie <airlied at itt42.(none)>
Date: Thu Jun 18 15:56:52 2009 +1000
radeon: consolidate more code in macros/inline.
in theory we should be able to add some of the EXA ifdefs around these macros
diff --git a/src/radeon_exa.c b/src/radeon_exa.c
index 12d0eb7..cc48a7a 100644
--- a/src/radeon_exa.c
+++ b/src/radeon_exa.c
@@ -471,35 +471,6 @@ static Bool RADEONEXAPixmapIsOffscreen(PixmapPtr pPix)
return FALSE;
}
-#define BEGIN_ACCEL_RELOC(n, r) do { \
- int _nqw = (n) + (info->new_cs ? (r) : 0); \
- BEGIN_ACCEL(_nqw); \
- } while (0)
-
-#define CHECK_OFFSET(pPix, mask, type) do { \
- if (!info->new_cs) { \
- uint32_t _pix_offset = exaGetPixmapOffset(pPix); \
- if ((_pix_offset & mask) != 0) \
- RADEON_FALLBACK(("Bad %s offset 0x%x\n", type, (int)pix_offset)); \
- } \
- } while(0)
-
-#define EMIT_OFFSET(reg, value, pPix, rd, wd) do { \
- if (info->new_cs) { \
- driver_priv = exaGetPixmapDriverPrivate(pPix); \
- OUT_ACCEL_REG((reg), 0); \
- OUT_RELOC(driver_priv->bo, (rd), (wd)); \
- } else { \
- uint32_t _pix_offset; \
- _pix_offset = exaGetPixmapOffset(pPix); \
- _pix_offset += info->fbLocation + pScrn->fbOffset; \
- OUT_ACCEL_REG((reg), _pix_offset | value); \
- } \
- } while(0)
-
-#define EMIT_READ_OFFSET(reg, value, pPix) EMIT_OFFSET(reg, value, pPix, (RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT), 0)
-#define EMIT_WRITE_OFFSET(reg, value, pPix) EMIT_OFFSET(reg, value, pPix, 0, RADEON_GEM_DOMAIN_VRAM)
-
#define ENTER_DRAW(x) TRACE
#define LEAVE_DRAW(x) TRACE
/***********************************************************************/
diff --git a/src/radeon_macros.h b/src/radeon_macros.h
index b7056b0..3634cea 100644
--- a/src/radeon_macros.h
+++ b/src/radeon_macros.h
@@ -157,4 +157,33 @@ do { \
#define INPCIE(pScrn, addr) RADEONINPCIE(pScrn, addr)
#define OUTPCIE(pScrn, addr, val) RADEONOUTPCIE(pScrn, addr, val
+#define BEGIN_ACCEL_RELOC(n, r) do { \
+ int _nqw = (n) + (info->new_cs ? (r) : 0); \
+ BEGIN_ACCEL(_nqw); \
+ } while (0)
+
+#define CHECK_OFFSET(pPix, mask, type) do { \
+ if (!info->new_cs) { \
+ uint32_t _pix_offset = radeonGetPixmapOffset(info, pPix); \
+ if ((_pix_offset & mask) != 0) \
+ RADEON_FALLBACK(("Bad %s offset 0x%x\n", type, (int)pix_offset)); \
+ } \
+ } while(0)
+
+#define EMIT_OFFSET(reg, value, pPix, rd, wd) do { \
+ if (info->new_cs) { \
+ driver_priv = exaGetPixmapDriverPrivate(pPix); \
+ OUT_ACCEL_REG((reg), 0); \
+ OUT_RELOC(driver_priv->bo, (rd), (wd)); \
+ } else { \
+ uint32_t _pix_offset; \
+ _pix_offset = radeonGetPixmapOffset(info, pPix); \
+ _pix_offset += info->fbLocation + pScrn->fbOffset; \
+ OUT_ACCEL_REG((reg), _pix_offset | value); \
+ } \
+ } while(0)
+
+#define EMIT_READ_OFFSET(reg, value, pPix) EMIT_OFFSET(reg, value, pPix, (RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT), 0)
+#define EMIT_WRITE_OFFSET(reg, value, pPix) EMIT_OFFSET(reg, value, pPix, 0, RADEON_GEM_DOMAIN_VRAM)
+
#endif
diff --git a/src/radeon_textured_videofuncs.c b/src/radeon_textured_videofuncs.c
index 99a113b..829a5f0 100644
--- a/src/radeon_textured_videofuncs.c
+++ b/src/radeon_textured_videofuncs.c
@@ -120,7 +120,7 @@ FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv
dri_bo *dst_bo;
uint32_t txformat;
uint32_t txfilter, txformat0, txformat1, txoffset, txpitch;
- uint32_t dst_offset, dst_pitch, dst_format;
+ uint32_t dst_pitch, dst_format;
uint32_t txenable, colorpitch;
uint32_t blendcntl;
Bool isplanar = FALSE;
@@ -165,20 +165,12 @@ FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv
#ifdef USE_EXA
if (info->useEXA) {
- if (info->new_cs) {
- driver_priv = exaGetPixmapDriverPrivate(pPixmap);
- if (driver_priv)
- dst_bo = driver_priv->bo;
- } else {
- dst_offset = exaGetPixmapOffset(pPixmap);
- }
dst_pitch = exaGetPixmapPitch(pPixmap);
} else
#endif
- {
- dst_offset = (pPixmap->devPrivate.ptr - info->FB);
- dst_pitch = pPixmap->devKind;
- }
+ {
+ dst_pitch = pPixmap->devKind;
+ }
#ifdef COMPOSITE
dstxoff = -pPixmap->screen_x + pPixmap->drawable.x;
@@ -1613,13 +1605,7 @@ FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv
OUT_ACCEL_REG(R300_TX_INVALTAGS, 0);
OUT_ACCEL_REG(R300_TX_ENABLE, txenable);
- if (info->new_cs) {
- OUT_ACCEL_REG(R300_RB3D_COLOROFFSET0, 0);
- OUT_RELOC(dst_bo, 0, RADEON_GEM_DOMAIN_VRAM);
- } else {
- dst_offset += info->fbLocation + pScrn->fbOffset;
- OUT_ACCEL_REG(R300_RB3D_COLOROFFSET0, dst_offset);
- }
+ EMIT_WRITE_OFFSET(R300_RB3D_COLOROFFSET0, 0, pPixmap);
OUT_ACCEL_REG(R300_RB3D_COLORPITCH0, colorpitch);
blendcntl = RADEON_SRC_BLEND_GL_ONE | RADEON_DST_BLEND_GL_ZERO;
@@ -1671,13 +1657,7 @@ FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv
OUT_ACCEL_REG(RADEON_RB3D_CNTL,
dst_format /*| RADEON_ALPHA_BLEND_ENABLE*/);
- if (info->new_cs) {
- OUT_ACCEL_REG(RADEON_RB3D_COLOROFFSET, 0);
- OUT_RELOC(dst_bo, 0, RADEON_GEM_DOMAIN_VRAM);
- } else {
- dst_offset += info->fbLocation + pScrn->fbOffset;
- OUT_ACCEL_REG(RADEON_RB3D_COLOROFFSET, dst_offset);
- }
+ EMIT_WRITE_OFFSET(RADEON_RB3D_COLOROFFSET, 0, pPixmap);
OUT_ACCEL_REG(RADEON_RB3D_COLORPITCH, colorpitch);
commit 84108cde1623dc2a1b64149426270c66aacc5505
Author: Dave Airlie <airlied at itt42.(none)>
Date: Thu Jun 18 15:48:30 2009 +1000
radeon: add macros around reloc and offset emission for pixmaps
diff --git a/src/radeon_exa.c b/src/radeon_exa.c
index d7c10bd..12d0eb7 100644
--- a/src/radeon_exa.c
+++ b/src/radeon_exa.c
@@ -476,6 +476,30 @@ static Bool RADEONEXAPixmapIsOffscreen(PixmapPtr pPix)
BEGIN_ACCEL(_nqw); \
} while (0)
+#define CHECK_OFFSET(pPix, mask, type) do { \
+ if (!info->new_cs) { \
+ uint32_t _pix_offset = exaGetPixmapOffset(pPix); \
+ if ((_pix_offset & mask) != 0) \
+ RADEON_FALLBACK(("Bad %s offset 0x%x\n", type, (int)pix_offset)); \
+ } \
+ } while(0)
+
+#define EMIT_OFFSET(reg, value, pPix, rd, wd) do { \
+ if (info->new_cs) { \
+ driver_priv = exaGetPixmapDriverPrivate(pPix); \
+ OUT_ACCEL_REG((reg), 0); \
+ OUT_RELOC(driver_priv->bo, (rd), (wd)); \
+ } else { \
+ uint32_t _pix_offset; \
+ _pix_offset = exaGetPixmapOffset(pPix); \
+ _pix_offset += info->fbLocation + pScrn->fbOffset; \
+ OUT_ACCEL_REG((reg), _pix_offset | value); \
+ } \
+ } while(0)
+
+#define EMIT_READ_OFFSET(reg, value, pPix) EMIT_OFFSET(reg, value, pPix, (RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT), 0)
+#define EMIT_WRITE_OFFSET(reg, value, pPix) EMIT_OFFSET(reg, value, pPix, 0, RADEON_GEM_DOMAIN_VRAM)
+
#define ENTER_DRAW(x) TRACE
#define LEAVE_DRAW(x) TRACE
/***********************************************************************/
diff --git a/src/radeon_exa_render.c b/src/radeon_exa_render.c
index 8c028ae..e11492f 100644
--- a/src/radeon_exa_render.c
+++ b/src/radeon_exa_render.c
@@ -373,10 +373,10 @@ static Bool FUNC_NAME(R100TextureSetup)(PicturePtr pPict, PixmapPtr pPix,
ACCEL_PREAMBLE();
txpitch = exaGetPixmapPitch(pPix);
- txoffset = exaGetPixmapOffset(pPix);
+ txoffset = 0;
+
+ CHECK_OFFSET(pPix, 0x1f, "texture");
- if (!info->new_cs && ((txoffset & 0x1f) != 0))
- RADEON_FALLBACK(("Bad texture offset 0x%x\n", (int)txoffset));
if ((txpitch & 0x1f) != 0)
RADEON_FALLBACK(("Bad texture pitch 0x%x\n", (int)txpitch));
@@ -440,14 +440,7 @@ static Bool FUNC_NAME(R100TextureSetup)(PicturePtr pPict, PixmapPtr pPix,
((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
OUT_ACCEL_REG(RADEON_PP_TEX_PITCH_0, txpitch - 32);
- if (info->new_cs) {
- driver_priv = exaGetPixmapDriverPrivate(pPix);
- OUT_ACCEL_REG(RADEON_PP_TXOFFSET_0, 0);
- OUT_RELOC(driver_priv->bo, RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT, 0);
- } else {
- txoffset += info->fbLocation + pScrn->fbOffset;
- OUT_ACCEL_REG(RADEON_PP_TXOFFSET_0, txoffset);
- }
+ EMIT_READ_OFFSET(RADEON_PP_TXOFFSET_0, txoffset, pPix);
/* emit a texture relocation */
} else {
OUT_ACCEL_REG(RADEON_PP_TXFILTER_1, txfilter);
@@ -457,15 +450,7 @@ static Bool FUNC_NAME(R100TextureSetup)(PicturePtr pPict, PixmapPtr pPix,
(pPix->drawable.width - 1) |
((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
OUT_ACCEL_REG(RADEON_PP_TEX_PITCH_1, txpitch - 32);
- if (info->new_cs) {
- driver_priv = exaGetPixmapDriverPrivate(pPix);
- OUT_ACCEL_REG(RADEON_PP_TXOFFSET_1, 0);
- OUT_RELOC(driver_priv->bo, RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT, 0);
- } else {
- txoffset += info->fbLocation + pScrn->fbOffset;
- OUT_ACCEL_REG(RADEON_PP_TXOFFSET_1, txoffset);
- }
-
+ EMIT_READ_OFFSET(RADEON_PP_TXOFFSET_1, txoffset, pPix);
/* emit a texture relocation */
}
FINISH_ACCEL();
@@ -572,7 +557,7 @@ static Bool FUNC_NAME(R100PrepareComposite)(int op,
PixmapPtr pDst)
{
RINFO_FROM_SCREEN(pDst->drawable.pScreen);
- uint32_t dst_format, dst_offset, dst_pitch, colorpitch;
+ uint32_t dst_format, dst_pitch, colorpitch;
uint32_t pp_cntl, blendcntl, cblend, ablend;
int pixel_shift;
struct radeon_exa_pixmap_priv *driver_priv;
@@ -633,14 +618,13 @@ static Bool FUNC_NAME(R100PrepareComposite)(int op,
pixel_shift = pDst->drawable.bitsPerPixel >> 4;
- dst_offset = exaGetPixmapOffset(pDst);
dst_pitch = exaGetPixmapPitch(pDst);
colorpitch = dst_pitch >> pixel_shift;
if (RADEONPixmapIsColortiled(pDst))
colorpitch |= RADEON_COLOR_TILE_ENABLE;
- if (!info->new_cs && (dst_offset & 0x0f) != 0)
- RADEON_FALLBACK(("Bad destination offset 0x%x\n", (int)dst_offset));
+ CHECK_OFFSET(pDst, 0x0f, "destination");
+
if (((dst_pitch >> pixel_shift) & 0x7) != 0)
RADEON_FALLBACK(("Bad destination pitch 0x%x\n", (int)dst_pitch));
@@ -665,14 +649,7 @@ static Bool FUNC_NAME(R100PrepareComposite)(int op,
BEGIN_ACCEL_RELOC(8, 1);
OUT_ACCEL_REG(RADEON_PP_CNTL, pp_cntl);
OUT_ACCEL_REG(RADEON_RB3D_CNTL, dst_format | RADEON_ALPHA_BLEND_ENABLE);
- if (info->new_cs) {
- driver_priv = exaGetPixmapDriverPrivate(pDst);
- OUT_ACCEL_REG(RADEON_RB3D_COLOROFFSET, 0);
- OUT_RELOC(driver_priv->bo, 0, RADEON_GEM_DOMAIN_VRAM);
- } else {
- dst_offset += info->fbLocation + pScrn->fbOffset;
- OUT_ACCEL_REG(RADEON_RB3D_COLOROFFSET, dst_offset);
- }
+ EMIT_WRITE_OFFSET(RADEON_RB3D_COLOROFFSET, 0, pDst);
OUT_ACCEL_REG(RADEON_RB3D_COLORPITCH, colorpitch);
/* IN operator: Multiply src by mask components or mask alpha.
@@ -776,12 +753,10 @@ static Bool FUNC_NAME(R200TextureSetup)(PicturePtr pPict, PixmapPtr pPix,
ACCEL_PREAMBLE();
txpitch = exaGetPixmapPitch(pPix);
- txoffset = exaGetPixmapOffset(pPix);
- if (!info->new_cs) {
- if ((txoffset & 0x1f) != 0)
- RADEON_FALLBACK(("Bad texture offset 0x%x\n", (int)txoffset));
- }
+ txoffset = 0;
+ CHECK_OFFSET(pPix, 0x1f, "texture");
+
if ((txpitch & 0x1f) != 0)
RADEON_FALLBACK(("Bad texture pitch 0x%x\n", (int)txpitch));
@@ -846,15 +821,7 @@ static Bool FUNC_NAME(R200TextureSetup)(PicturePtr pPict, PixmapPtr pPix,
OUT_ACCEL_REG(R200_PP_TXSIZE_0, (pPix->drawable.width - 1) |
((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
OUT_ACCEL_REG(R200_PP_TXPITCH_0, txpitch - 32);
- if (info->new_cs) {
- driver_priv = exaGetPixmapDriverPrivate(pPix);
-
- OUT_ACCEL_REG(R200_PP_TXOFFSET_0, driver_priv ? 0 : txoffset);
- OUT_RELOC(driver_priv->bo, RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT, 0);
- } else {
- txoffset += info->fbLocation + pScrn->fbOffset;
- OUT_ACCEL_REG(R200_PP_TXOFFSET_0, txoffset);
- }
+ EMIT_READ_OFFSET(R200_PP_TXOFFSET_0, txoffset, pPix);
} else {
OUT_ACCEL_REG(R200_PP_TXFILTER_1, txfilter);
OUT_ACCEL_REG(R200_PP_TXFORMAT_1, txformat);
@@ -862,16 +829,7 @@ static Bool FUNC_NAME(R200TextureSetup)(PicturePtr pPict, PixmapPtr pPix,
OUT_ACCEL_REG(R200_PP_TXSIZE_1, (pPix->drawable.width - 1) |
((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
OUT_ACCEL_REG(R200_PP_TXPITCH_1, txpitch - 32);
- if (info->new_cs) {
- uint32_t handle = 0;
- driver_priv = exaGetPixmapDriverPrivate(pPix);
-
- OUT_ACCEL_REG(R200_PP_TXOFFSET_1, driver_priv ? 0 : txoffset);
- OUT_RELOC(driver_priv->bo, RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT, 0);
- } else {
- txoffset += info->fbLocation + pScrn->fbOffset;
- OUT_ACCEL_REG(R200_PP_TXOFFSET_1, txoffset);
- }
+ EMIT_READ_OFFSET(R200_PP_TXOFFSET_1, txoffset, pPix);
/* emit a texture relocation */
}
FINISH_ACCEL();
@@ -962,7 +920,7 @@ static Bool FUNC_NAME(R200PrepareComposite)(int op, PicturePtr pSrcPicture,
PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst)
{
RINFO_FROM_SCREEN(pDst->drawable.pScreen);
- uint32_t dst_format, dst_offset, dst_pitch;
+ uint32_t dst_format, dst_pitch;
uint32_t pp_cntl, blendcntl, cblend, ablend, colorpitch;
int pixel_shift;
struct radeon_exa_pixmap_priv *driver_priv;
@@ -1023,14 +981,13 @@ static Bool FUNC_NAME(R200PrepareComposite)(int op, PicturePtr pSrcPicture,
pixel_shift = pDst->drawable.bitsPerPixel >> 4;
- dst_offset = exaGetPixmapOffset(pDst);
dst_pitch = exaGetPixmapPitch(pDst);
colorpitch = dst_pitch >> pixel_shift;
if (RADEONPixmapIsColortiled(pDst))
colorpitch |= RADEON_COLOR_TILE_ENABLE;
- if (!info->new_cs && (dst_offset & 0x0f) != 0)
- RADEON_FALLBACK(("Bad destination offset 0x%x\n", (int)dst_offset));
+ CHECK_OFFSET(pDst, 0xf, "destination");
+
if (((dst_pitch >> pixel_shift) & 0x7) != 0)
RADEON_FALLBACK(("Bad destination pitch 0x%x\n", (int)dst_pitch));
@@ -1056,16 +1013,7 @@ static Bool FUNC_NAME(R200PrepareComposite)(int op, PicturePtr pSrcPicture,
OUT_ACCEL_REG(RADEON_PP_CNTL, pp_cntl);
OUT_ACCEL_REG(RADEON_RB3D_CNTL, dst_format | RADEON_ALPHA_BLEND_ENABLE);
- if (info->new_cs) {
- driver_priv = exaGetPixmapDriverPrivate(pDst);
- assert(driver_priv);
-
- OUT_ACCEL_REG(RADEON_RB3D_COLOROFFSET, 0);
- OUT_RELOC(driver_priv->bo, 0, RADEON_GEM_DOMAIN_VRAM);
- } else {
- dst_offset += info->fbLocation + pScrn->fbOffset;
- OUT_ACCEL_REG(RADEON_RB3D_COLOROFFSET, dst_offset);
- }
+ EMIT_WRITE_OFFSET(RADEON_RB3D_COLOROFFSET, 0, pDst);
OUT_ACCEL_REG(R200_SE_VTX_FMT_0, R200_VTX_XY);
if (pMask)
@@ -1211,12 +1159,10 @@ static Bool FUNC_NAME(R300TextureSetup)(PicturePtr pPict, PixmapPtr pPix,
TRACE;
txpitch = exaGetPixmapPitch(pPix);
- txoffset = exaGetPixmapOffset(pPix);
+ txoffset = 0;
+
+ CHECK_OFFSET(pPix, 0x1f, "texture");
- if (!info->new_cs) {
- if ((txoffset & 0x1f) != 0)
- RADEON_FALLBACK(("Bad texture offset 0x%x\n", (int)txoffset));
- }
if ((txpitch & 0x1f) != 0)
RADEON_FALLBACK(("Bad texture pitch 0x%x\n", (int)txpitch));
@@ -1310,16 +1256,8 @@ static Bool FUNC_NAME(R300TextureSetup)(PicturePtr pPict, PixmapPtr pPix,
OUT_ACCEL_REG(R300_TX_FORMAT1_0 + (unit * 4), txformat1);
OUT_ACCEL_REG(R300_TX_FORMAT2_0 + (unit * 4), txpitch);
- if (info->new_cs) {
- uint32_t handle = 0;
- driver_priv = exaGetPixmapDriverPrivate(pPix);
+ EMIT_READ_OFFSET((R300_TX_OFFSET_0 + (unit * 4)), txoffset, pPix);
- OUT_ACCEL_REG(R300_TX_OFFSET_0 + (unit * 4), driver_priv ? 0 : txoffset);
- OUT_RELOC(driver_priv->bo, RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT, 0);
- } else {
- txoffset += info->fbLocation + pScrn->fbOffset;
- OUT_ACCEL_REG(R300_TX_OFFSET_0 + (unit * 4), txoffset);
- }
if (!pPict->repeat)
OUT_ACCEL_REG(R300_TX_BORDER_COLOR_0 + (unit * 4), 0);
FINISH_ACCEL();
@@ -1426,7 +1364,7 @@ static Bool FUNC_NAME(R300PrepareComposite)(int op, PicturePtr pSrcPicture,
PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst)
{
RINFO_FROM_SCREEN(pDst->drawable.pScreen);
- uint32_t dst_format, dst_offset, dst_pitch;
+ uint32_t dst_format, dst_pitch;
uint32_t txenable, colorpitch;
uint32_t blendcntl;
int pixel_shift;
@@ -1485,7 +1423,6 @@ static Bool FUNC_NAME(R300PrepareComposite)(int op, PicturePtr pSrcPicture,
pixel_shift = pDst->drawable.bitsPerPixel >> 4;
- dst_offset = exaGetPixmapOffset(pDst);
dst_pitch = exaGetPixmapPitch(pDst);
colorpitch = dst_pitch >> pixel_shift;
@@ -1494,8 +1431,8 @@ static Bool FUNC_NAME(R300PrepareComposite)(int op, PicturePtr pSrcPicture,
colorpitch |= dst_format;
- if (!info->new_cs && ((dst_offset & 0x0f) != 0))
- RADEON_FALLBACK(("Bad destination offset 0x%x\n", (int)dst_offset));
+ CHECK_OFFSET(pDst, 0x0f, "destination");
+
if (((dst_pitch >> pixel_shift) & 0x7) != 0)
RADEON_FALLBACK(("Bad destination pitch 0x%x\n", (int)dst_pitch));
@@ -2171,16 +2108,7 @@ static Bool FUNC_NAME(R300PrepareComposite)(int op, PicturePtr pSrcPicture,
BEGIN_ACCEL_RELOC(3, 1);
- if (info->new_cs) {
- driver_priv = exaGetPixmapDriverPrivate(pDst);
- assert(driver_priv);
-
- OUT_ACCEL_REG(R300_RB3D_COLOROFFSET0, 0);
- OUT_RELOC(driver_priv->bo, 0, RADEON_GEM_DOMAIN_VRAM);
- } else {
- dst_offset += info->fbLocation + pScrn->fbOffset;
- OUT_ACCEL_REG(R300_RB3D_COLOROFFSET0, dst_offset);
- }
+ EMIT_WRITE_OFFSET(R300_RB3D_COLOROFFSET0, 0, pDst);
OUT_ACCEL_REG(R300_RB3D_COLORPITCH0, colorpitch);
blendcntl = RADEONGetBlendCntl(op, pMaskPicture, pDstPicture->format);
commit bd96e8a71fa4593d888729fd9831fba72fde74b7
Author: Dave Airlie <airlied at itt42.(none)>
Date: Thu Jun 18 15:23:59 2009 +1000
radeon/cs: cleanup reloc accel begin with a macro.
All the qwords calcs were pretty ugly - clean this up a lot
diff --git a/src/radeon_exa.c b/src/radeon_exa.c
index cc48a7a..d7c10bd 100644
--- a/src/radeon_exa.c
+++ b/src/radeon_exa.c
@@ -471,6 +471,11 @@ static Bool RADEONEXAPixmapIsOffscreen(PixmapPtr pPix)
return FALSE;
}
+#define BEGIN_ACCEL_RELOC(n, r) do { \
+ int _nqw = (n) + (info->new_cs ? (r) : 0); \
+ BEGIN_ACCEL(_nqw); \
+ } while (0)
+
#define ENTER_DRAW(x) TRACE
#define LEAVE_DRAW(x) TRACE
/***********************************************************************/
diff --git a/src/radeon_exa_funcs.c b/src/radeon_exa_funcs.c
index c51bab2..e554952 100644
--- a/src/radeon_exa_funcs.c
+++ b/src/radeon_exa_funcs.c
@@ -90,7 +90,6 @@ FUNC_NAME(RADEONSync)(ScreenPtr pScreen, int marker)
static void FUNC_NAME(Emit2DState)(ScrnInfoPtr pScrn, int op)
{
RADEONInfoPtr info = RADEONPTR(pScrn);
- uint32_t qwords;
int has_src;
ACCEL_PREAMBLE();
@@ -100,10 +99,11 @@ static void FUNC_NAME(Emit2DState)(ScrnInfoPtr pScrn, int op)
has_src = info->state_2d.src_pitch_offset || (info->new_cs && info->state_2d.src_bo);
- qwords = info->new_cs ? 10 : 9;
- qwords += (has_src ? (info->new_cs ? 2 : 1) : 0);
-
- BEGIN_ACCEL(qwords);
+ if (has_src) {
+ BEGIN_ACCEL_RELOC(10, 2);
+ } else {
+ BEGIN_ACCEL_RELOC(9, 1);
+ }
OUT_ACCEL_REG(RADEON_DEFAULT_SC_BOTTOM_RIGHT, info->state_2d.default_sc_bottom_right);
OUT_ACCEL_REG(RADEON_DP_GUI_MASTER_CNTL, info->state_2d.dp_gui_master_cntl);
OUT_ACCEL_REG(RADEON_DP_BRUSH_FRGD_CLR, info->state_2d.dp_brush_frgd_clr);
@@ -450,14 +450,9 @@ RADEONBlitChunk(ScrnInfoPtr pScrn, uint32_t datatype, dri_bo *src_bo, dri_bo *ds
int w, int h)
{
RADEONInfoPtr info = RADEONPTR(pScrn);
- uint32_t qwords;
ACCEL_PREAMBLE();
- qwords = 6;
- if (src_bo && dst_bo)
- qwords += 2;
-
- BEGIN_ACCEL(qwords);
+ BEGIN_ACCEL_RELOC(6, (src_bo && dst_bo) ? 2 : 0);
OUT_ACCEL_REG(RADEON_DP_GUI_MASTER_CNTL,
RADEON_GMC_DST_PITCH_OFFSET_CNTL |
RADEON_GMC_SRC_PITCH_OFFSET_CNTL |
diff --git a/src/radeon_exa_render.c b/src/radeon_exa_render.c
index 4d96ae5..8c028ae 100644
--- a/src/radeon_exa_render.c
+++ b/src/radeon_exa_render.c
@@ -370,7 +370,6 @@ static Bool FUNC_NAME(R100TextureSetup)(PicturePtr pPict, PixmapPtr pPix,
!(unit == 0 && (info->accel_state->need_src_tile_x || info->accel_state->need_src_tile_y));
int i;
struct radeon_exa_pixmap_priv *driver_priv;
- int qwords;
ACCEL_PREAMBLE();
txpitch = exaGetPixmapPitch(pPix);
@@ -432,8 +431,7 @@ static Bool FUNC_NAME(R100TextureSetup)(PicturePtr pPict, PixmapPtr pPix,
}
}
- qwords = info->new_cs ? 6 : 5;
- BEGIN_ACCEL(qwords);
+ BEGIN_ACCEL_RELOC(5, 1);
if (unit == 0) {
OUT_ACCEL_REG(RADEON_PP_TXFILTER_0, txfilter);
OUT_ACCEL_REG(RADEON_PP_TXFORMAT_0, txformat);
@@ -578,7 +576,6 @@ static Bool FUNC_NAME(R100PrepareComposite)(int op,
uint32_t pp_cntl, blendcntl, cblend, ablend;
int pixel_shift;
struct radeon_exa_pixmap_priv *driver_priv;
- int qwords;
int retry_count = 0;
struct radeon_space_check bos[3];
int i, ret;
@@ -665,8 +662,7 @@ static Bool FUNC_NAME(R100PrepareComposite)(int op,
info->accel_state->is_transform[1] = FALSE;
}
- qwords = info->new_cs ? 9 : 8;
- BEGIN_ACCEL(qwords);
+ BEGIN_ACCEL_RELOC(8, 1);
OUT_ACCEL_REG(RADEON_PP_CNTL, pp_cntl);
OUT_ACCEL_REG(RADEON_RB3D_CNTL, dst_format | RADEON_ALPHA_BLEND_ENABLE);
if (info->new_cs) {
@@ -777,7 +773,6 @@ static Bool FUNC_NAME(R200TextureSetup)(PicturePtr pPict, PixmapPtr pPix,
!(unit == 0 && (info->accel_state->need_src_tile_x || info->accel_state->need_src_tile_y));
int i;
struct radeon_exa_pixmap_priv *driver_priv;
- int qwords;
ACCEL_PREAMBLE();
txpitch = exaGetPixmapPitch(pPix);
@@ -843,8 +838,7 @@ static Bool FUNC_NAME(R200TextureSetup)(PicturePtr pPict, PixmapPtr pPix,
}
}
- qwords = info->new_cs ? 7 : 6;
- BEGIN_ACCEL(qwords);
+ BEGIN_ACCEL_RELOC(6, 1);
if (unit == 0) {
OUT_ACCEL_REG(R200_PP_TXFILTER_0, txfilter);
OUT_ACCEL_REG(R200_PP_TXFORMAT_0, txformat);
@@ -972,7 +966,6 @@ static Bool FUNC_NAME(R200PrepareComposite)(int op, PicturePtr pSrcPicture,
uint32_t pp_cntl, blendcntl, cblend, ablend, colorpitch;
int pixel_shift;
struct radeon_exa_pixmap_priv *driver_priv;
- int qwords;
int retry_count = 0;
struct radeon_space_check bos[3];
int i, ret;
@@ -1058,8 +1051,7 @@ static Bool FUNC_NAME(R200PrepareComposite)(int op, PicturePtr pSrcPicture,
info->accel_state->is_transform[1] = FALSE;
}
- qwords = info->new_cs ? 12 : 11;
- BEGIN_ACCEL(qwords);
+ BEGIN_ACCEL_RELOC(11, 1);
OUT_ACCEL_REG(RADEON_PP_CNTL, pp_cntl);
OUT_ACCEL_REG(RADEON_RB3D_CNTL, dst_format | RADEON_ALPHA_BLEND_ENABLE);
@@ -1214,7 +1206,6 @@ static Bool FUNC_NAME(R300TextureSetup)(PicturePtr pPict, PixmapPtr pPix,
int h = pPict->pDrawable->height;
int i, pixel_shift;
struct radeon_exa_pixmap_priv *driver_priv;
- int qwords;
ACCEL_PREAMBLE();
TRACE;
@@ -1312,10 +1303,7 @@ static Bool FUNC_NAME(R300TextureSetup)(PicturePtr pPict, PixmapPtr pPix,
RADEON_FALLBACK(("Bad filter 0x%x\n", pPict->filter));
}
- qwords = pPict->repeat ? 6 : 7;
- qwords += info->new_cs ? 1 : 0;
-
- BEGIN_ACCEL(qwords);
+ BEGIN_ACCEL_RELOC(pPict->repeat ? 6 : 7, 1);
OUT_ACCEL_REG(R300_TX_FILTER0_0 + (unit * 4), txfilter);
OUT_ACCEL_REG(R300_TX_FILTER1_0 + (unit * 4), 0);
OUT_ACCEL_REG(R300_TX_FORMAT0_0 + (unit * 4), txformat0);
@@ -1442,7 +1430,7 @@ static Bool FUNC_NAME(R300PrepareComposite)(int op, PicturePtr pSrcPicture,
uint32_t txenable, colorpitch;
uint32_t blendcntl;
int pixel_shift;
- int qwords, ret;
+ int ret;
int retry_count = 0;
struct radeon_exa_pixmap_priv *driver_priv;
struct radeon_space_check bos[3];
@@ -2181,8 +2169,8 @@ static Bool FUNC_NAME(R300PrepareComposite)(int op, PicturePtr pSrcPicture,
FINISH_ACCEL();
}
- qwords = info->new_cs ? 4 : 3;
- BEGIN_ACCEL(qwords);
+
+ BEGIN_ACCEL_RELOC(3, 1);
if (info->new_cs) {
driver_priv = exaGetPixmapDriverPrivate(pDst);
assert(driver_priv);
diff --git a/src/radeon_textured_video.c b/src/radeon_textured_video.c
index aed229c..73ab5fe 100644
--- a/src/radeon_textured_video.c
+++ b/src/radeon_textured_video.c
@@ -129,6 +129,11 @@ static __inline__ uint32_t float4touint(float fr, float fg, float fb, float fa)
return (ua << 24) | (ur << 16) | (ug << 8) | ub;
}
+#define BEGIN_ACCEL_RELOC(n, r) do { \
+ int _nqw = (n) + (info->new_cs ? (r) : 0); \
+ BEGIN_ACCEL(_nqw); \
+ } while (0)
+
#define ACCEL_MMIO
#define ACCEL_PREAMBLE() unsigned char *RADEONMMIO = info->MMIO
#define BEGIN_ACCEL(n) RADEONWaitForFifo(pScrn, (n))
diff --git a/src/radeon_textured_videofuncs.c b/src/radeon_textured_videofuncs.c
index 5b22993..99a113b 100644
--- a/src/radeon_textured_videofuncs.c
+++ b/src/radeon_textured_videofuncs.c
@@ -127,7 +127,6 @@ FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv
int dstxoff, dstyoff, pixel_shift, vtx_count;
BoxPtr pBox = REGION_RECTS(&pPriv->clip);
int nBox = REGION_NUM_RECTS(&pPriv->clip);
- int qwords;
ACCEL_PREAMBLE();
retry:
@@ -291,8 +290,7 @@ FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv
else
txoffset = pPriv->src_offset;
- qwords = info->new_cs ? 7 : 6;
- BEGIN_ACCEL(qwords);
+ BEGIN_ACCEL_RELOC(6, 1);
OUT_ACCEL_REG(R300_TX_FILTER0_0, txfilter);
OUT_ACCEL_REG(R300_TX_FILTER1_0, 0);
OUT_ACCEL_REG(R300_TX_FORMAT0_0, txformat0);
@@ -314,8 +312,7 @@ FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv
R300_TX_MIN_FILTER_LINEAR |
R300_TX_MAG_FILTER_LINEAR);
- qwords = info->new_cs ? 14 : 12;
- BEGIN_ACCEL(qwords);
+ BEGIN_ACCEL_RELOC(12, 2);
OUT_ACCEL_REG(R300_TX_FILTER0_1, txfilter | (1 << R300_TX_ID_SHIFT));
OUT_ACCEL_REG(R300_TX_FILTER1_1, 0);
OUT_ACCEL_REG(R300_TX_FORMAT0_1, txformat0);
@@ -350,8 +347,7 @@ FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv
R300_TX_MAG_FILTER_NEAREST |
(1 << R300_TX_ID_SHIFT));
- qwords = info->new_cs ? 7 : 6;
- BEGIN_ACCEL(qwords);
+ BEGIN_ACCEL_RELOC(6, 1);
OUT_ACCEL_REG(R300_TX_FILTER0_1, txfilter);
OUT_ACCEL_REG(R300_TX_FILTER1_1, 0);
OUT_ACCEL_REG(R300_TX_FORMAT0_1, txformat0);
@@ -1613,8 +1609,7 @@ FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv
}
}
- qwords = info->new_cs ? 7 : 6;
- BEGIN_ACCEL(qwords);
+ BEGIN_ACCEL_RELOC(6, 1);
OUT_ACCEL_REG(R300_TX_INVALTAGS, 0);
OUT_ACCEL_REG(R300_TX_ENABLE, txenable);
@@ -1671,8 +1666,7 @@ FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv
if (RADEONTilingEnabled(pScrn, pPixmap))
colorpitch |= RADEON_COLOR_TILE_ENABLE;
- qwords = info->new_cs ? 5 : 4;
- BEGIN_ACCEL(qwords);
+ BEGIN_ACCEL_RELOC(4, 1);
OUT_ACCEL_REG(RADEON_RB3D_CNTL,
dst_format /*| RADEON_ALPHA_BLEND_ENABLE*/);
@@ -1722,8 +1716,7 @@ FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv
R200_CLAMP_S_CLAMP_LAST |
R200_CLAMP_T_CLAMP_LAST;
- qwords = info->new_cs ? 39 : 36;
- BEGIN_ACCEL(qwords);
+ BEGIN_ACCEL_RELOC(36, 3);
OUT_ACCEL_REG(RADEON_PP_CNTL,
RADEON_TEX_0_ENABLE | RADEON_TEX_1_ENABLE | RADEON_TEX_2_ENABLE |
@@ -1893,8 +1886,7 @@ FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv
R200_CLAMP_S_CLAMP_LAST |
R200_CLAMP_T_CLAMP_LAST;
- qwords = info->new_cs ? 25 : 24;
- BEGIN_ACCEL(qwords);
+ BEGIN_ACCEL_RELOC(24, 1);
OUT_ACCEL_REG(RADEON_PP_CNTL,
RADEON_TEX_0_ENABLE |
@@ -1996,8 +1988,7 @@ FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv
FINISH_ACCEL();
}
else {
- qwords = info->new_cs ? 14 : 13;
- BEGIN_ACCEL(qwords);
+ BEGIN_ACCEL_RELOC(13, 1);
OUT_ACCEL_REG(RADEON_PP_CNTL,
RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE);
@@ -2041,9 +2032,7 @@ FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv
info->accel_state->texW[0] = 1;
info->accel_state->texH[0] = 1;
- qwords = info->new_cs ? 10 : 9;
- BEGIN_ACCEL(qwords);
-
+ BEGIN_ACCEL_RELOC(9, 1);
OUT_ACCEL_REG(RADEON_PP_CNTL,
RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE);
More information about the xorg-commit
mailing list