diff options
Diffstat (limited to 'driver/xf86-video-r128/src/r128_exa_render.c')
-rw-r--r-- | driver/xf86-video-r128/src/r128_exa_render.c | 125 |
1 files changed, 88 insertions, 37 deletions
diff --git a/driver/xf86-video-r128/src/r128_exa_render.c b/driver/xf86-video-r128/src/r128_exa_render.c index db14bb126..0d81a09a6 100644 --- a/driver/xf86-video-r128/src/r128_exa_render.c +++ b/driver/xf86-video-r128/src/r128_exa_render.c @@ -34,14 +34,24 @@ /* The following is based on the kdrive ATI driver. */ -#include <stdio.h> -#include <string.h> +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#if defined(R128DRI) && defined(RENDER) +#include "xf86.h" +#include "exa.h" + +#include "r128.h" +#include "r128_reg.h" +#include "r128_rop.h" + static struct { Bool dst_alpha; Bool src_alpha; - CARD32 sblend; - CARD32 dblend; + uint32_t sblend; + uint32_t dblend; } R128BlendOp[] = { /* Clear */ {0, 0, R128_ALPHA_BLEND_ZERO , R128_ALPHA_BLEND_ZERO}, @@ -102,6 +112,17 @@ R128SolidPixmap(ScreenPtr pScreen, uint32_t solid) return NULL; } info->ExaDriver->WaitMarker(pScreen, 0); + +#if X_BYTE_ORDER == X_BIG_ENDIAN + if (pScrn->bitsPerPixel == 32) + R128CopySwap(info->ExaDriver->memoryBase + exaGetPixmapOffset(pPix), (uint8_t*)&solid, 4, + APER_0_BIG_ENDIAN_32BPP_SWAP); + else if (pScrn->bitsPerPixel == 16) + R128CopySwap(info->ExaDriver->memoryBase + exaGetPixmapOffset(pPix), (uint8_t*)&solid, 4, + APER_0_BIG_ENDIAN_16BPP_SWAP); + else + /* Fall through for 8 bpp */ +#endif memcpy(info->ExaDriver->memoryBase + exaGetPixmapOffset(pPix), &solid, 4); return pPix; @@ -146,8 +167,10 @@ R128GetDatatypePict2(uint32_t format, uint32_t *type) static Bool R128CheckCompositeTexture(PicturePtr pPict, PicturePtr pDstPict, int op) { +#if R128_DEBUG ScreenPtr pScreen = pDstPict->pDrawable->pScreen; ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); +#endif unsigned int repeatType = pPict->repeat ? pPict->repeatType : RepeatNone; uint32_t tmp1; @@ -159,66 +182,84 @@ R128CheckCompositeTexture(PicturePtr pPict, PicturePtr pDstPict, int op) int h = pPict->pDrawable->height; if (pPict->repeat && ((w & (w - 1)) != 0 || (h & (h - 1)) != 0)) { - R128TRACE(("NPOT repeat unsupported (%dx%d)\n", w, h)); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "NPOT repeat unsupported (%dx%d)\n", w, h)); return FALSE; } } if (pPict->filter != PictFilterNearest && pPict->filter != PictFilterBilinear) { - R128TRACE(("Unsupported filter 0x%x\n", pPict->filter)); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Unsupported filter 0x%x\n", + pPict->filter)); return FALSE; } /* The radeon driver has a long explanation about this part that I don't really understand */ if (pPict->transform != 0 && repeatType == RepeatNone && PICT_FORMAT_A(pPict->format) == 0) { if (!(((op == PictOpSrc) || (op == PictOpClear)) && (PICT_FORMAT_A(pDstPict->format) == 0))) { - R128TRACE(("REPEAT_NONE unsupported for transformed xRGB source\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "REPEAT_NONE unsupported for " + "transformed xRGB source\n")); return FALSE; } } if (!R128TransformAffineOrScaled(pPict->transform)) { - R128TRACE(("Non-affine transforms not supported\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Non-affine transforms not supported\n")); return FALSE; } return TRUE; } -static Bool +Bool R128CCECheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, PicturePtr pDstPicture) { +#if R128_DEBUG ScreenPtr pScreen = pDstPicture->pDrawable->pScreen; ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); +#endif PixmapPtr pSrcPixmap, pDstPixmap; uint32_t tmp1; /* Check for unsupported compositing operations. */ if (op >= sizeof(R128BlendOp) / sizeof(R128BlendOp[0])) { - R128TRACE(("Unsupported Composite op 0x%x\n", op)); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Unsupported Composite op 0x%x\n", op)); return FALSE; } pDstPixmap = R128GetDrawablePixmap(pDstPicture->pDrawable); if (pDstPixmap->drawable.width > 1024 || pDstPixmap->drawable.height > 1024) { - R128TRACE(("Dest w/h too large (%d,%d).\n", pDstPixmap->drawable.width, pDstPixmap->drawable.height)); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Dest w/h too large (%d,%d).\n", + pDstPixmap->drawable.width, + pDstPixmap->drawable.height)); return FALSE; } if (pSrcPicture->pDrawable) { pSrcPixmap = R128GetDrawablePixmap(pSrcPicture->pDrawable); if (pSrcPixmap->drawable.width > 1024 || pSrcPixmap->drawable.height > 1024) { - R128TRACE(("Source w/h too large (%d,%d).\n", pSrcPixmap->drawable.width, pSrcPixmap->drawable.height)); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Source w/h too large (%d,%d).\n", + pSrcPixmap->drawable.width, + pSrcPixmap->drawable.height)); return FALSE; } } else if (pSrcPicture->pSourcePict->type != SourcePictTypeSolidFill) { - R128TRACE(("Gradient pictures not supported yet\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Gradient pictures not supported yet\n")); return FALSE; } if (pDstPicture->format == PICT_a8) { if (R128BlendOp[op].src_alpha || R128BlendOp[op].dst_alpha || pMaskPicture != NULL) { - R128TRACE(("Alpha blending unsupported with A8 dst?\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Alpha blending unsupported with " + "A8 dst?\n")); return FALSE; } } else { @@ -231,16 +272,22 @@ R128CCECheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, P if (pMaskPicture->pDrawable) { pMaskPixmap = R128GetDrawablePixmap(pMaskPicture->pDrawable); if (pMaskPixmap->drawable.width > 1024 || pMaskPixmap->drawable.height > 1024) { - R128TRACE(("Mask w/h too large (%d,%d).\n", pMaskPixmap->drawable.width, pMaskPixmap->drawable.height)); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Mask w/h too large (%d,%d).\n", + pMaskPixmap->drawable.width, + pMaskPixmap->drawable.height)); return FALSE; } } else if (pMaskPicture->pSourcePict->type != SourcePictTypeSolidFill) { - R128TRACE(("Gradient pictures not supported yet\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Gradient pictures not supported yet\n")); return FALSE; } if (pMaskPicture->componentAlpha && R128BlendOp[op].src_alpha) { - R128TRACE(("Component alpha not supported with source alpha blending\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Component alpha not supported with " + "source alpha blending\n")); return FALSE; } @@ -269,7 +316,8 @@ R128TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit, uint32_t *txsize, u pitch = exaGetPixmapPitch(pPix); if ((pitch & (pitch - 1)) != 0) { - R128TRACE(("NPOT pitch 0x%x unsupported\n", pitch)); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "NPOT pitch 0x%x unsupported\n", pitch)); return FALSE; } @@ -283,7 +331,8 @@ R128TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit, uint32_t *txsize, u } else if (pPict->filter == PictFilterNearest) { *tex_cntl_c |= R128_MIN_BLEND_NEAREST | R128_MAG_BLEND_NEAREST; } else { - R128TRACE(("Bad filter 0x%x\n", pPict->filter)); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Bad filter 0x%x\n", pPict->filter)); return FALSE; } @@ -301,7 +350,9 @@ R128TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit, uint32_t *txsize, u if (pPict->repeat && w == 1 && h == 1) { l2p = 0; } else if (pPict->repeat && l2p != l2w) { - R128TRACE(("Repeat not supported for pitch != width\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Repeat not supported for pitch != " + "width\n")); return FALSE; } @@ -339,7 +390,7 @@ do { \ R128_TEX_MAP_ALPHA_IN_TEXTURE | \ R128_TEX_CACHE_LINE_SIZE_4QW); \ OUT_RING_REG(R128_SETUP_CNTL, \ - R128_COLOR_SOLID_COLOR | \ + R128_COLOR_GOURAUD | \ R128_PRIM_TYPE_TRI | \ R128_TEXTURE_ST_MULT_W | \ R128_STARTING_VERTEX_1 | \ @@ -347,9 +398,9 @@ do { \ R128_SUB_PIX_4BITS); \ OUT_RING_REG(R128_PM4_VC_FPU_SETUP, \ R128_FRONT_DIR_CCW | \ - R128_BACKFACE_CULL | \ + R128_BACKFACE_SOLID | \ R128_FRONTFACE_SOLID | \ - R128_FPU_COLOR_SOLID | \ + R128_FPU_COLOR_GOURAUD | \ R128_FPU_SUB_PIX_4BITS | \ R128_FPU_MODE_3D | \ R128_TRAP_BITS_DISABLE | \ @@ -364,7 +415,7 @@ do { \ ADVANCE_RING(); \ } while(0) -static Bool +Bool R128CCEPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, PicturePtr pDstPicture, PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst) { @@ -383,7 +434,8 @@ R128CCEPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, if (pDstPicture->format == PICT_a8) { if (R128BlendOp[op].dst_alpha) { - R128TRACE(("Can't dst alpha blend A8\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Can't dst alpha blend A8\n")); return FALSE; } dstDatatype = R128_DATATYPE_Y8; @@ -394,7 +446,9 @@ R128CCEPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, if (!pSrc) { pSrc = R128SolidPixmap(pScreen, cpu_to_le32(pSrcPicture->pSourcePict->solidFill.color)); if (!pSrc) { - R128TRACE(("Failed to create solid scratch pixmap\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Failed to create solid scratch " + "pixmap\n")); return FALSE; } add_src = TRUE; @@ -407,7 +461,9 @@ R128CCEPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, if (!pSrcPicture->pDrawable) pScreen->DestroyPixmap(pSrc); info->state_2d.has_mask = FALSE; - R128TRACE(("Failed to create solid scratch pixmap\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Failed to create " + "solid scratch pixmap\n")); return FALSE; } add_msk = TRUE; @@ -447,12 +503,7 @@ R128CCEPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, if (!info->state_2d.composite_setup) { COMPOSITE_SETUP(); - /* DRI and EXA are fighting over control of the texture hardware. - * That means we need to set up the compositing hardware every time - * while a 3D app is running and once after it closes. - */ - if (!info->have3DWindows) - info->state_2d.composite_setup = TRUE; + info->state_2d.composite_setup = TRUE; } /* We cannot guarantee that this register will stay zero - DRI needs it too. */ @@ -576,9 +627,9 @@ R128CCEPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, return TRUE; } -typedef union { float f; CARD32 i; } fi_type; +typedef union { float f; uint32_t i; } fi_type; -static inline CARD32 +static inline uint32_t R128FloatAsInt(float val) { fi_type fi; @@ -609,7 +660,7 @@ do { \ OUT_RING(R128FloatAsInt((((float)(_srcY)) + 0.5) / (info->state_2d.heights[0]))); \ } while (0) -static void +void R128CCEComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, int dstX, int dstY, int w, int h) { ScreenPtr pScreen = pDst->drawable.pScreen; @@ -692,4 +743,4 @@ R128CCEComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, int d ADVANCE_RING(); } -#define R128CCEDoneComposite R128Done +#endif |