ffb_loops.h revision dbbd9e4b
1dbbd9e4bSmacallan/* 2dbbd9e4bSmacallan * Acceleration for the Creator and Creator3D framebuffer - fast inner loops. 3dbbd9e4bSmacallan * 4dbbd9e4bSmacallan * Copyright (C) 1999 David S. Miller (davem@redhat.com) 5dbbd9e4bSmacallan * Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com) 6dbbd9e4bSmacallan * 7dbbd9e4bSmacallan * Permission is hereby granted, free of charge, to any person obtaining a copy 8dbbd9e4bSmacallan * of this software and associated documentation files (the "Software"), to deal 9dbbd9e4bSmacallan * in the Software without restriction, including without limitation the rights 10dbbd9e4bSmacallan * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11dbbd9e4bSmacallan * copies of the Software, and to permit persons to whom the Software is 12dbbd9e4bSmacallan * furnished to do so, subject to the following conditions: 13dbbd9e4bSmacallan * 14dbbd9e4bSmacallan * The above copyright notice and this permission notice shall be included in 15dbbd9e4bSmacallan * all copies or substantial portions of the Software. 16dbbd9e4bSmacallan * 17dbbd9e4bSmacallan * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18dbbd9e4bSmacallan * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19dbbd9e4bSmacallan * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20dbbd9e4bSmacallan * JAKUB JELINEK OR DAVID MILLER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21dbbd9e4bSmacallan * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22dbbd9e4bSmacallan * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23dbbd9e4bSmacallan * IN THE SOFTWARE. 24dbbd9e4bSmacallan * 25dbbd9e4bSmacallan */ 26dbbd9e4bSmacallan/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_loops.h,v 1.1 2000/05/18 23:21:37 dawes Exp $ */ 27dbbd9e4bSmacallan 28dbbd9e4bSmacallan#ifndef FFBLOOPS_H 29dbbd9e4bSmacallan#define FFBLOOPS_H 30dbbd9e4bSmacallan 31dbbd9e4bSmacallan#ifdef USE_VIS 32dbbd9e4bSmacallanextern void FFB_STIPPLE_LOAD(volatile unsigned int *d, 33dbbd9e4bSmacallan unsigned int *s); 34dbbd9e4bSmacallan 35dbbd9e4bSmacallanextern void FFB_PPT_BOX_LOOP(FFBPtr ffbpriv, 36dbbd9e4bSmacallan ffb_fbcPtr ffb, 37dbbd9e4bSmacallan BoxPtr pbox, BoxPtr pbox_last, 38dbbd9e4bSmacallan DDXPointPtr ppt); 39dbbd9e4bSmacallan 40dbbd9e4bSmacallanextern void FFB_BOX_LOOP(FFBPtr ffbpriv, 41dbbd9e4bSmacallan ffb_fbcPtr ffb, 42dbbd9e4bSmacallan BoxPtr pbox, 43dbbd9e4bSmacallan BoxPtr pbox_last); 44dbbd9e4bSmacallan 45dbbd9e4bSmacallanextern void FFB_RECT_LOOP(FFBPtr ffbpriv, 46dbbd9e4bSmacallan ffb_fbcPtr ffb, 47dbbd9e4bSmacallan xRectangle *prect, 48dbbd9e4bSmacallan xRectangle *prect_last, 49dbbd9e4bSmacallan int xOrg, int yOrg); 50dbbd9e4bSmacallan 51dbbd9e4bSmacallanextern void FFB_PPT_WIDTH_LOOP(FFBPtr ffbpriv, 52dbbd9e4bSmacallan ffb_fbcPtr ffb, 53dbbd9e4bSmacallan DDXPointPtr ppt, DDXPointPtr ppt_last, 54dbbd9e4bSmacallan int *pwidth); 55dbbd9e4bSmacallan 56dbbd9e4bSmacallanextern DDXPointPtr FFB_PPT_LOOP1(FFBPtr ffbpriv, 57dbbd9e4bSmacallan ffb_fbcPtr ffb, 58dbbd9e4bSmacallan DDXPointPtr ppt, DDXPointPtr ppt_last, 59dbbd9e4bSmacallan int xOrg, int yOrg); 60dbbd9e4bSmacallan 61dbbd9e4bSmacallanextern DDXPointPtr FFB_PPT_LOOP2(FFBPtr ffbpriv, 62dbbd9e4bSmacallan ffb_fbcPtr ffb, 63dbbd9e4bSmacallan DDXPointPtr ppt, DDXPointPtr ppt_last, 64dbbd9e4bSmacallan int x, int y); 65dbbd9e4bSmacallan 66dbbd9e4bSmacallanextern DDXPointPtr FFB_LINE_LOOP1(FFBPtr ffbpriv, 67dbbd9e4bSmacallan ffb_fbcPtr ffb, 68dbbd9e4bSmacallan DDXPointPtr ppt, DDXPointPtr ppt_last, 69dbbd9e4bSmacallan int xOrg, int yOrg); 70dbbd9e4bSmacallan 71dbbd9e4bSmacallanextern DDXPointPtr FFB_LINE_LOOP2(FFBPtr ffbpriv, 72dbbd9e4bSmacallan ffb_fbcPtr ffb, 73dbbd9e4bSmacallan DDXPointPtr ppt, DDXPointPtr ppt_last, 74dbbd9e4bSmacallan int *x, int *y); 75dbbd9e4bSmacallan 76dbbd9e4bSmacallan#else /* !USE_VIS */ 77dbbd9e4bSmacallan 78dbbd9e4bSmacallan#define FFB_STIPPLE_LOAD(_d,_s) \ 79dbbd9e4bSmacallando { \ 80dbbd9e4bSmacallan volatile unsigned int *d = (_d); \ 81dbbd9e4bSmacallan unsigned int *s = (_s); \ 82dbbd9e4bSmacallan int i; \ 83dbbd9e4bSmacallan \ 84dbbd9e4bSmacallan for (i = 0; i < (32 / 2); i++, d+=2, s+=2) \ 85dbbd9e4bSmacallan FFB_WRITE64(d, s[0], s[1]); \ 86dbbd9e4bSmacallan} while (0) 87dbbd9e4bSmacallan 88dbbd9e4bSmacallan#define FFB_PPT_BOX_LOOP(pFfb, ffb, pbox, _pbox_last, ppt) \ 89dbbd9e4bSmacallando { \ 90dbbd9e4bSmacallan BoxPtr pbox_last = (BoxPtr)(_pbox_last); \ 91dbbd9e4bSmacallan while (pbox <= pbox_last) { \ 92dbbd9e4bSmacallan FFBFifo(pFfb, 7); \ 93dbbd9e4bSmacallan ffb->drawop = FFB_DRAWOP_VSCROLL; \ 94dbbd9e4bSmacallan FFB_WRITE64(&ffb->by, ppt->y, ppt->x); \ 95dbbd9e4bSmacallan FFB_WRITE64_2(&ffb->dy, pbox->y1, pbox->x1); \ 96dbbd9e4bSmacallan FFB_WRITE64_3(&ffb->bh, (pbox->y2 - pbox->y1), (pbox->x2 - pbox->x1)); \ 97dbbd9e4bSmacallan pbox++; ppt++; \ 98dbbd9e4bSmacallan } \ 99dbbd9e4bSmacallan} while (0) 100dbbd9e4bSmacallan 101dbbd9e4bSmacallan#define FFB_BOX_LOOP(pFfb, ffb, pbox, _pbox_last) \ 102dbbd9e4bSmacallando { \ 103dbbd9e4bSmacallan BoxPtr pbox_last = (BoxPtr)(_pbox_last); \ 104dbbd9e4bSmacallan while (pbox <= pbox_last) { \ 105dbbd9e4bSmacallan FFBFifo(pFfb, 4); \ 106dbbd9e4bSmacallan FFB_WRITE64(&ffb->by, pbox->y1, pbox->x1); \ 107dbbd9e4bSmacallan FFB_WRITE64_2(&ffb->bh, (pbox->y2 - pbox->y1), (pbox->x2 - pbox->x1)); \ 108dbbd9e4bSmacallan pbox++; \ 109dbbd9e4bSmacallan } \ 110dbbd9e4bSmacallan} while (0) 111dbbd9e4bSmacallan 112dbbd9e4bSmacallan#define FFB_RECT_LOOP(pFfb, ffb, prect, _prect_last, xOrg, yOrg) \ 113dbbd9e4bSmacallando { \ 114dbbd9e4bSmacallan xRectangle *prect_last = (xRectangle *)(_prect_last); \ 115dbbd9e4bSmacallan for (; prect <= prect_last; prect++) { \ 116dbbd9e4bSmacallan register int x, y, w, h; \ 117dbbd9e4bSmacallan x = prect->x + xOrg; \ 118dbbd9e4bSmacallan y = prect->y + yOrg; \ 119dbbd9e4bSmacallan w = prect->width; \ 120dbbd9e4bSmacallan h = prect->height; \ 121dbbd9e4bSmacallan if (extents->x2 <= x || \ 122dbbd9e4bSmacallan extents->x1 >= x + w || \ 123dbbd9e4bSmacallan extents->y2 <= y || \ 124dbbd9e4bSmacallan extents->y1 >= y + h) \ 125dbbd9e4bSmacallan continue; \ 126dbbd9e4bSmacallan FFBFifo(pFfb, 4); \ 127dbbd9e4bSmacallan FFB_WRITE64(&ffb->by, y, x); \ 128dbbd9e4bSmacallan FFB_WRITE64_2(&ffb->bh, h, w); \ 129dbbd9e4bSmacallan } \ 130dbbd9e4bSmacallan} while (0) 131dbbd9e4bSmacallan 132dbbd9e4bSmacallan#define FFB_PPT_WIDTH_LOOP(pFfb, ffb, ppt, _ppt_last, pwidth) \ 133dbbd9e4bSmacallando { \ 134dbbd9e4bSmacallan DDXPointPtr ppt_last = (DDXPointPtr)(_ppt_last); \ 135dbbd9e4bSmacallan while (ppt <= ppt_last) { \ 136dbbd9e4bSmacallan register int x, y, w; \ 137dbbd9e4bSmacallan x = ppt->x; \ 138dbbd9e4bSmacallan y = ppt->y; \ 139dbbd9e4bSmacallan w = *pwidth++; \ 140dbbd9e4bSmacallan FFBFifo(pFfb, 5); \ 141dbbd9e4bSmacallan ffb->ppc = 0; \ 142dbbd9e4bSmacallan FFB_WRITE64(&ffb->by, y, x); \ 143dbbd9e4bSmacallan FFB_WRITE64_2(&ffb->bh, y, (x + w)); \ 144dbbd9e4bSmacallan ppt++; \ 145dbbd9e4bSmacallan } \ 146dbbd9e4bSmacallan} while (0) 147dbbd9e4bSmacallan 148dbbd9e4bSmacallanstatic __inline__ DDXPointPtr FFB_PPT_LOOP1(FFBPtr pFfb, 149dbbd9e4bSmacallan ffb_fbcPtr ffb, 150dbbd9e4bSmacallan DDXPointPtr ppt, DDXPointPtr ppt_last, 151dbbd9e4bSmacallan int xOrg, int yOrg) 152dbbd9e4bSmacallan{ 153dbbd9e4bSmacallan while (ppt <= ppt_last) { 154dbbd9e4bSmacallan FFBFifo(pFfb, 2); 155dbbd9e4bSmacallan FFB_WRITE64_2(&ffb->bh, (ppt->y + yOrg), (ppt->x + xOrg)); 156dbbd9e4bSmacallan ppt++; 157dbbd9e4bSmacallan } 158dbbd9e4bSmacallan return ppt; 159dbbd9e4bSmacallan} 160dbbd9e4bSmacallan 161dbbd9e4bSmacallanstatic __inline__ DDXPointPtr FFB_PPT_LOOP2(FFBPtr pFfb, 162dbbd9e4bSmacallan ffb_fbcPtr ffb, 163dbbd9e4bSmacallan DDXPointPtr ppt, DDXPointPtr ppt_last, 164dbbd9e4bSmacallan int x, int y) 165dbbd9e4bSmacallan{ 166dbbd9e4bSmacallan register int __x = x, __y = y; 167dbbd9e4bSmacallan while (ppt <= ppt_last) { 168dbbd9e4bSmacallan FFBFifo(pFfb, 2); 169dbbd9e4bSmacallan __x += ppt->x; 170dbbd9e4bSmacallan __y += ppt->y; 171dbbd9e4bSmacallan FFB_WRITE64_2(&ffb->bh, __y, __x); 172dbbd9e4bSmacallan ppt++; 173dbbd9e4bSmacallan } 174dbbd9e4bSmacallan return ppt; 175dbbd9e4bSmacallan} 176dbbd9e4bSmacallan 177dbbd9e4bSmacallanstatic __inline__ DDXPointPtr FFB_LINE_LOOP1(FFBPtr pFfb, 178dbbd9e4bSmacallan ffb_fbcPtr ffb, 179dbbd9e4bSmacallan DDXPointPtr ppt, DDXPointPtr ppt_last, 180dbbd9e4bSmacallan int xOrg, int yOrg) 181dbbd9e4bSmacallan{ 182dbbd9e4bSmacallan while (ppt <= ppt_last) { 183dbbd9e4bSmacallan FFBFifo(pFfb, 3); 184dbbd9e4bSmacallan ffb->ppc = 0; 185dbbd9e4bSmacallan FFB_WRITE64_2(&ffb->bh, (ppt->y + yOrg), (ppt->x + xOrg)); 186dbbd9e4bSmacallan ppt++; 187dbbd9e4bSmacallan } 188dbbd9e4bSmacallan return ppt; 189dbbd9e4bSmacallan} 190dbbd9e4bSmacallan 191dbbd9e4bSmacallanstatic __inline__ DDXPointPtr FFB_LINE_LOOP2(FFBPtr pFfb, 192dbbd9e4bSmacallan ffb_fbcPtr ffb, 193dbbd9e4bSmacallan DDXPointPtr ppt, DDXPointPtr ppt_last, 194dbbd9e4bSmacallan int *x, int *y) 195dbbd9e4bSmacallan{ 196dbbd9e4bSmacallan register int __x = *x, __y = *y; 197dbbd9e4bSmacallan while (ppt <= ppt_last) { 198dbbd9e4bSmacallan FFBFifo(pFfb, 3); 199dbbd9e4bSmacallan ffb->ppc = 0; 200dbbd9e4bSmacallan __x += ppt->x; 201dbbd9e4bSmacallan __y += ppt->y; 202dbbd9e4bSmacallan FFB_WRITE64_2(&ffb->bh, __y, __x); 203dbbd9e4bSmacallan ppt++; 204dbbd9e4bSmacallan } 205dbbd9e4bSmacallan *x = __x; 206dbbd9e4bSmacallan *y = __y; 207dbbd9e4bSmacallan return ppt; 208dbbd9e4bSmacallan} 209dbbd9e4bSmacallan 210dbbd9e4bSmacallan#endif /* !USE_VIS */ 211dbbd9e4bSmacallan 212dbbd9e4bSmacallan#endif /* FFBLOOPS_H */ 213