Updated wfb'ish patches
These two patches make nv50 usable with driver allocated pixmaps.
I am aware that some cards (NV9X?) have a slightly different texture layout somehow, i would encourage people to use the test program i sent a few days ago to try and figure it out, or at least sent in the output (see the last email for details).
Sorry for all the bitmasking, shifting and such in the first patch but is absolutely necessary for good performance (a division or modulus in a hot code path sucks).
The first patch also uses the larger texture modes where possible (obviously not for classic exa).
The 2nd patch is needed to make initial pixmap upload and especially known software rendering ops acceptable again (the regression was more than an order of magnitude).
These are not a 100% commit ready obviously, but i wouldn't want to loose the patches either.
Maarten.
From f723f5cc9757d1fa255b371a43dd4394c254b1d2 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Sat, 7 Mar 2009 23:49:19 +0100
Subject: [PATCH 1/2] nv50: implement wfb
- Only for sufficiently new xserver's and exa_driver_pixmaps.
--- src/nouveau_exa.c | 279 +++++++++++++++++++++++++++++++++++++++++++++++++++-- src/nv50_exa.c | 31 ++++++- src/nv_driver.c | 52 +++++++++-- src/nv_proto.h | 6 + src/nv_type.h | 4 +- 5 files changed, 350 insertions(+), 22 deletions(-)
src/nouveau_exa.c +269 -10
@@ -89,7 +89,7 @@ NVAccelDownloadM2MF(PixmapPtr pspix, int x, int y, int w, int h,if (!linear) {BEGIN_RING (chan, m2mf,0x0200 ,7 );OUT_RING (chan,0 ); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (pspix));OUT_RING (chan, pspix->drawable.width * cpp);OUT_RING (chan, pspix->drawable.height);OUT_RING (chan,1 );
@@ -210,7 +210,7 @@ NVAccelUploadM2MF(PixmapPtr pdpix, int x, int y, int w, int h,if (!linear) {BEGIN_RING (chan, m2mf,0x021c ,7 );OUT_RING (chan,0 ); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (pdpix));OUT_RING (chan, pdpix->drawable.width * cpp);OUT_RING (chan, pdpix->drawable.height);OUT_RING (chan,1 );
@@ -259,7 +259,11 @@ nouveau_exa_mark_sync(ScreenPtr pScreen)static void nouveau_exa_wait_marker (ScreenPtr pScreen,int marker) { -NVSync (xf86Screens[pScreen->myNum]); +ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; +NVPtr pNv =NVPTR (pScrn); + +if (!pNv->exa_driver_pixmaps) +NVSync (xf86Screens[pScreen->myNum]); } static Bool
@@ -351,17 +355,32 @@ nouveau_exa_modify_pixmap_header(PixmapPtr ppix, int width, int height,if (!nvpix->bo && nvpix->size) {uint32_t cpp = ppix->drawable.bitsPerPixel >>3 ; -/* At some point we should just keep 1bpp pixmaps in sysram */ uint32_t flags =NOUVEAU_BO_VRAM ;int ret;if (pNv->Architecture >=NV_ARCH_50 && cpp) { -uint32_t aw = (width +7 ) & ~7 ; -uint32_t ah = (height +7 ) & ~7 ; +uint32_t ah; +if (height >47 ) { + ah = (height +63 ) & ~63 ; + nvpix->tiling_mode =5 ; + }else if (height >23 ) { + ah = (height +31 ) & ~31 ; + nvpix->tiling_mode =4 ; + }else if (height >11 ) { + ah = (height +15 ) & ~15 ; + nvpix->tiling_mode =3 ; + }else if (height >5 ) { + ah = (height +7 ) & ~7 ; + nvpix->tiling_mode =2 ; + }else { + ah = (height +3 ) & ~3 ; + nvpix->tiling_mode =1 ; + } flags |=NOUVEAU_BO_TILED ; - devkind = ((aw * cpp) +63 ) & ~63 ; +/* This allignment is very important. */ + devkind = (width * cpp +63 ) & ~63 ; nvpix->size = devkind * ah; }
@@ -390,8 +409,11 @@ nouveau_exa_pixmap_is_tiled(PixmapPtr ppix)NVPtr pNv =NVPTR (pScrn);if (pNv->exa_driver_pixmaps) { -if (!nouveau_pixmap_bo (ppix)->tiled) +if (!nouveau_pixmap_bo (ppix)) +return false; +if (nouveau_pixmap_bo (ppix)->tiled ==0 )return false; +return true; }else if (pNv->Architecture <NV_ARCH_50 ||exaGetPixmapOffset (ppix) < pNv->EXADriverPtr->offScreenBase)
@@ -403,10 +425,12 @@ nouveau_exa_pixmap_is_tiled(PixmapPtr ppix)static void *nouveau_exa_pixmap_map (PixmapPtr ppix) { +ScrnInfoPtr pScrn = xf86Screens[ppix->drawable.pScreen->myNum]; +NVPtr pNv =NVPTR (pScrn);struct nouveau_bo *bo =nouveau_pixmap_bo (ppix);unsigned delta =nouveau_pixmap_offset (ppix); -if (bo->tiled) { +if (!pNv->wfb_enabled && bo->tiled) {struct nouveau_pixmap *nvpix =nouveau_pixmap (ppix); nvpix->linear =xcalloc (1 , ppix->devKind * ppix->drawable.height);
@@ -426,9 +450,11 @@ nouveau_exa_pixmap_map(PixmapPtr ppix)static void nouveau_exa_pixmap_unmap (PixmapPtr ppix) { +ScrnInfoPtr pScrn = xf86Screens[ppix->drawable.pScreen->myNum]; +NVPtr pNv =NVPTR (pScrn);struct nouveau_bo *bo =nouveau_pixmap_bo (ppix); -if (bo->tiled) { +if (!pNv->wfb_enabled && bo->tiled) {struct nouveau_pixmap *nvpix =nouveau_pixmap (ppix); NVAccelUploadM2MF(ppix, 0, 0, ppix->drawable.width,
@@ -674,3 +700,236 @@ nouveau_exa_init(ScreenPtr pScreen) pNv->EXADriverPtr = exa;return TRUE; } + +/* WFB functions. */ + +static inline FbBits +nouveau_exa_wfb_read_memory_linear (const void *src,int size) +{ +FbBits bits =0 ; + +memcpy (&bits, src, size); + +return bits; +} + +static inline void +nouveau_exa_wfb_write_memory_linear (void *dst,FbBits value,int size) +{ +memcpy (dst, &value, size); +} + +#define LINEAR_PITCH (pPixmap->devKind) + +/* Wfb related data. */ +static struct { +PixmapPtr ppix; +bool used; +bool tiled; +unsigned long start; +unsigned long end; +uint64_t multiply_factor; +uint8_t cpp; +unsigned int tile_height; +unsigned int num_tiles_width; +} wfb_pixmaps[6 ]; + +/* height: empty, 2, 4, 8, 16, 32, 64 */ +static unsigned int num_tiles[] = {0 ,0 ,4 ,2 ,1 ,1 ,1 }; +static unsigned int tile_pitch[] = {0 ,3 ,5 ,6 ,6 ,6 ,6 }; +static unsigned int mask_height_inv[] = {~0 , ~1 , ~3 , ~7 , ~15 , ~31 , ~63 }; +static unsigned int mask_pitch_inv[] = {~0 , ~7 , ~31 , ~63 , ~63 , ~63 , ~63 }; +static unsigned int mask_height[] = {0 ,1 ,3 ,7 ,15 ,31 ,63 }; +static unsigned int mask_pitch[] = {0 ,7 ,31 ,63 ,63 ,63 ,63 }; + +#define X_REMAINDER (x & mask_pitch[tile_height]) +#define Y_REMAINDER (y & mask_height[tile_height]) + +/* tile_height and tile_pitch are expressed in powers of two */ +static inline unsigned int +nouveau_exa_wfb_recurse_offset (unsigned int offset,unsigned int tile_height, +unsigned int x,unsigned int y,unsigned int num_tiles_width) +{ + offset += (((x & mask_pitch_inv[tile_height]) >> tile_pitch[tile_height]) + (((y & mask_height_inv[tile_height]) >> tile_height) * num_tiles_width)) * (1 << (tile_height + tile_pitch[tile_height])); + +if (tile_height >1 ) + offset =nouveau_exa_wfb_recurse_offset (offset, tile_height -1 ,X_REMAINDER ,Y_REMAINDER , num_tiles[tile_height]); +else + offset += (Y_REMAINDER * (1 << tile_pitch[tile_height])) +X_REMAINDER ; + +return offset; +} + +/* Note, we can only expose one read and write function, the linear versions are for internal consumption. */ +static FbBits +nouveau_exa_wfb_read_memory (const void *src,int size) +{ +int i; +uint64_t line_x, line_y; +unsigned long offset = (unsigned long ) src, subpixel_offset; +PixmapPtr pPixmap =NULL ; +FbBits bits =0 ; +void *new_src; + +/* Find the right pixmap. */ +for (i =0 ; i <6 ; i++) +if (offset >= wfb_pixmaps[i].start && offset < wfb_pixmaps[i].end) { + pPixmap = wfb_pixmaps[i].ppix; +break ; + } + +if (!pPixmap || !wfb_pixmaps[i].tiled) +return nouveau_exa_wfb_read_memory_linear (src, size); + +/* Now comes the decoding. */ + offset -= (unsigned long ) pPixmap->devPrivate.ptr; +/* Assuming dword alligned offsets. */ + subpixel_offset = offset & (wfb_pixmaps[i].cpp -1 ); + offset &= ~(wfb_pixmaps[i].cpp -1 ); + +/* Determine the coordinate first. */ +/* Division is too expensive for large numbers, so we precalculate a multiplication factor. */ + line_y = (offset * wfb_pixmaps[i].multiply_factor) >>32 ; + line_x = offset - line_y *LINEAR_PITCH ; + + new_src = pPixmap->devPrivate.ptr + +nouveau_exa_wfb_recurse_offset (0 , wfb_pixmaps[i].tile_height, line_x, line_y, wfb_pixmaps[i].num_tiles_width) + + subpixel_offset; + +memcpy (&bits, new_src, size); + +return bits; +} + +static void +nouveau_exa_wfb_write_memory (void *dst,FbBits value,int size) +{ +int i; +uint64_t line_x, line_y; +unsigned long offset = (unsigned long ) dst, subpixel_offset; +PixmapPtr pPixmap =NULL ; +void *new_dst; + +/* Find the right pixmap. */ +for (i =0 ; i <6 ; i++) +if (offset >= wfb_pixmaps[i].start && offset < wfb_pixmaps[i].end) { + pPixmap = wfb_pixmaps[i].ppix; +break ; + } + +if (!pPixmap || !wfb_pixmaps[i].tiled) { +nouveau_exa_wfb_write_memory_linear (dst, value, size); +return ; + } + +/* Now comes the decoding. */ + offset -= (unsigned long ) pPixmap->devPrivate.ptr; +/* Assuming dword alligned offsets. */ + subpixel_offset = offset & (wfb_pixmaps[i].cpp -1 ); + offset &= ~(wfb_pixmaps[i].cpp -1 ); + +/* Determine the coordinate first. */ +/* Division is too expensive for large numbers, so we precalculate a multiplication factor. */ + line_y = (offset * wfb_pixmaps[i].multiply_factor) >>32 ; + line_x = offset - line_y *LINEAR_PITCH ; + + new_dst = pPixmap->devPrivate.ptr + +nouveau_exa_wfb_recurse_offset (0 , wfb_pixmaps[i].tile_height, line_x, line_y, wfb_pixmaps[i].num_tiles_width) + + subpixel_offset; + +memcpy (new_dst, &value, size); +} + +void +nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead, +WriteMemoryProcPtr *pWrite, +DrawablePtr pDraw) +{ +PixmapPtr pPixmap; +struct nouveau_pixmap *nvpix; + +if (!pRead || !pWrite) +return ; + + pPixmap =NVGetDrawablePixmap (pDraw); +if (!pPixmap) +return ; + + nvpix =nouveau_pixmap (pPixmap); + +int i; +for (i =0 ; i <6 ; i++) +if (!wfb_pixmaps[i].used) +break ; + +if (i ==6 ) { +ErrorF ("More than 6 wraps are setup, what the hell is going on?\n" ); + *pRead =NULL ; + *pWrite =NULL ; +return ; + } + +/* We will get a pointer, somewhere in the range of this pixmap. */ +/* Based on linear representation ofcource. */ + wfb_pixmaps[i].ppix = pPixmap; + wfb_pixmaps[i].start = (unsigned long ) pPixmap->devPrivate.ptr; + wfb_pixmaps[i].end = wfb_pixmaps[i].start +exaGetPixmapPitch (pPixmap) * ((pPixmap->drawable.height +15 ) & ~15 ); + wfb_pixmaps[i].used = true; + wfb_pixmaps[i].tiled =nouveau_exa_pixmap_is_tiled (pPixmap); +/* Division is too expensive for large numbers, so we precalculate a multiplication factor. */ + wfb_pixmaps[i].multiply_factor = (0xFFFFFFFF /exaGetPixmapPitch (pPixmap)) +1 ; + wfb_pixmaps[i].cpp = (pPixmap->drawable.bitsPerPixel >>3 ); +if (!nvpix) { + wfb_pixmaps[i].tile_height =0 ; + wfb_pixmaps[i].num_tiles_width =0 ; + }else { + wfb_pixmaps[i].tile_height = nvpix->tiling_mode +1 ; + wfb_pixmaps[i].num_tiles_width =LINEAR_PITCH /(1 << tile_pitch[wfb_pixmaps[i].tile_height]); + } + + *pRead = nouveau_exa_wfb_read_memory; + *pWrite = nouveau_exa_wfb_write_memory; +} + +void +nouveau_exa_wfb_finish_wrap (DrawablePtr pDraw) +{ +PixmapPtr pPixmap; +int i; + + pPixmap =NVGetDrawablePixmap (pDraw); +if (!pPixmap) +return ; + +for (i =0 ; i <6 ; i++) +if (wfb_pixmaps[i].ppix == pPixmap) { + wfb_pixmaps[i].ppix =NULL ; + wfb_pixmaps[i].start =0 ; + wfb_pixmaps[i].end =0 ; + wfb_pixmaps[i].used = false; + wfb_pixmaps[i].tiled = false; + wfb_pixmaps[i].multiply_factor =0 ; + wfb_pixmaps[i].cpp =0 ; + wfb_pixmaps[i].tile_height =0 ; + wfb_pixmaps[i].num_tiles_width =0 ; +break ; + } +} + +void +nouveau_exa_wfb_init () +{ +int i; + +for (i =0 ; i <6 ; i++) { + wfb_pixmaps[i].ppix =NULL ; + wfb_pixmaps[i].start =0 ; + wfb_pixmaps[i].end =0 ; + wfb_pixmaps[i].used = false; + wfb_pixmaps[i].tiled = false; + wfb_pixmaps[i].multiply_factor =0 ; + wfb_pixmaps[i].cpp =0 ; + wfb_pixmaps[i].tile_height =0 ; + wfb_pixmaps[i].num_tiles_width =0 ; + } +}
src/nv50_exa.c +28 -3
@@ -72,6 +72,31 @@ NV50EXABlendOp[] = { /* Add */ { 0, 0, BF( ONE), BF( ONE) }, }; + +uint32_t +nv50_exa_get_tile_mode (PixmapPtr ppix) +{ +struct nouveau_pixmap *nvpix =nouveau_pixmap (ppix); + +if (!nvpix) +return 0x00 ; + +switch (nvpix->tiling_mode) { +case 1 :/* pitch 32, height 4 */ +return 0x00 ; +case 2 :/* pitch 64, height 8 */ +return 0x10 ; +case 3 :/* pitch 64, height 16 */ +return 0x20 ; +case 4 :/* pitch 64, height 32 */ +return 0x30 ; +case 5 :/* pitch 64, height 64 */ +return 0x40 ; +default : +return 0x00 ; + } +} +static Bool NV50EXA2DSurfaceFormat (PixmapPtr ppix,uint32_t *fmt) {
@@ -128,7 +153,7 @@ NV50EXAAcquireSurface2D(PixmapPtr ppix, int is_src)BEGIN_RING (chan, eng2d, mthd,5 );OUT_RING (chan, fmt);OUT_RING (chan,0 ); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,1 );OUT_RING (chan,0 ); }
@@ -457,7 +482,7 @@ NV50EXARenderTarget(PixmapPtr ppix, PicturePtr ppict)OUT_RELOCh (chan, bo, delta,NOUVEAU_BO_VRAM |NOUVEAU_BO_WR );OUT_RELOCl (chan, bo, delta,NOUVEAU_BO_VRAM |NOUVEAU_BO_WR );OUT_RING (chan, format); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,0x00000000 );BEGIN_RING (chan, tesla,NV50TCL_RT_HORIZ (0 ),2 );OUT_RING (chan, ppix->drawable.width);
@@ -577,7 +602,7 @@ NV50EXATexture(PixmapPtr ppix, PicturePtr ppict, unsigned unit)NOUVEAU_FALLBACK ("invalid picture format, this SHOULD NOT HAPPEN. Expect trouble.\n" ); }OUT_RELOCl (chan, bo, delta,NOUVEAU_BO_VRAM |NOUVEAU_BO_RD ); -OUT_RING (chan,0xd0005000 ); +OUT_RING (chan,0xd0005000 | (nv50_exa_get_tile_mode (ppix) <<18 ));OUT_RING (chan,0x00300000 );OUT_RING (chan, ppix->drawable.width);OUT_RING (chan, (1 <<NV50TIC_0_5_DEPTH_SHIFT ) | ppix->drawable.height);
src/nv_driver.c +44 -8
83 lines not on this page · raw message
src/nv_proto.h +6 -0
@@ -65,6 +65,11 @@ void NVTakedownDma(ScrnInfoPtr pScrn);Bool nouveau_exa_init (ScreenPtr pScreen);Bool nouveau_exa_pixmap_is_onscreen (PixmapPtr pPixmap);bool nouveau_exa_pixmap_is_tiled (PixmapPtr ppix); +void nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead, +WriteMemoryProcPtr *pWrite, +DrawablePtr pDraw); +void nouveau_exa_wfb_finish_wrap (DrawablePtr pDraw); +void nouveau_exa_wfb_init ();/* in nv_hw.c */ void NVCalcStateExt (ScrnInfoPtr ,struct _riva_hw_state *,int ,int ,int ,int ,int ,int );
@@ -221,6 +226,7 @@ int NV40SetTexturePortAttribute(ScrnInfoPtr, Atom, INT32, pointer);Bool NVAccelInitNV50TCL (ScrnInfoPtr pScrn);/* in nv50_exa.c */ +uint32_t nv50_exa_get_tile_mode (PixmapPtr ppix);Bool NV50EXAPrepareSolid (PixmapPtr ,int ,Pixel ,Pixel );void NV50EXASolid (PixmapPtr ,int ,int ,int ,int );void NV50EXADoneSolid (PixmapPtr );
src/nv_type.h +3 -1
@@ -305,7 +305,8 @@ typedef struct _NVRec {uint8_t cur_head;ExaDriverPtr EXADriverPtr; -Bool exa_driver_pixmaps; +Bool exa_driver_pixmaps; +bool wfb_enabled;xf86CursorInfoPtr CursorInfoRec;ScreenBlockHandlerProcPtr BlockHandler;CloseScreenProcPtr CloseScreen;
@@ -479,6 +480,7 @@ struct nouveau_pixmap {struct nouveau_bo *bo;void *linear;unsigned size; +int tiling_mode; }; static inline struct nouveau_pixmap *
Signature · 1 line
1.6.2
From 9594a53f475b138b25ef24b1efce99500ff47746 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Fri, 13 Mar 2009 09:57:12 +0100
Subject: [PATCH 2/2] exa: smarter initial mapping of driver allocated pixmaps
- Use a software copy until the first accelerated op, then UTS it.
- The path back does not exist.
--- src/nouveau_exa.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++----- src/nv04_exa.c | 5 ++++ src/nv10_exa.c | 5 ++++ src/nv30_exa.c | 5 ++++ src/nv40_exa.c | 5 ++++ src/nv50_exa.c | 10 ++++++++ src/nv_include.h | 2 + src/nv_proto.h | 1 + src/nv_type.h | 1 + 9 files changed, 91 insertions(+), 7 deletions(-)
src/nouveau_exa.c +57 -7
109 lines not on this page · raw message
src/nv04_exa.c +5 -0
@@ -83,6 +83,8 @@ NV04EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg)unsigned delta =nouveau_pixmap_offset (pPixmap);unsigned int fmt, pitch, color; +nouveau_exa_pixmap_prepare_for_accel (pPixmap); +WAIT_RING (chan,64 ); planemask |= ~0 << pPixmap->drawable.bitsPerPixel;
@@ -190,6 +192,9 @@ NV04EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int dx, int dy,unsigned dst_delta =nouveau_pixmap_offset (pDstPixmap);int fmt; +nouveau_exa_pixmap_prepare_for_accel (pSrcPixmap); +nouveau_exa_pixmap_prepare_for_accel (pDstPixmap); +WAIT_RING (chan,64 ); if (pSrcPixmap->drawable.bitsPerPixel !=
src/nv10_exa.c +5 -0
@@ -626,6 +626,11 @@ Bool NV10EXAPrepareComposite(int op,NVPtr pNv =NVPTR (pScrn);struct nouveau_channel *chan = pNv->chan; +nouveau_exa_pixmap_prepare_for_accel (pSrc); +if (pMask) +nouveau_exa_pixmap_prepare_for_accel (pMask); +nouveau_exa_pixmap_prepare_for_accel (pDst); +WAIT_RING (chan,128 );if (NV10Check_A8plusA8_Feasability (pSrcPicture,pMaskPicture,pDstPicture,op))
src/nv30_exa.c +5 -0
@@ -447,6 +447,11 @@ NV30EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV30EXA_FPID_PASS_COL0 ;NV30EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV30_GetPictOpRec (op);
src/nv40_exa.c +5 -0
@@ -406,6 +406,11 @@ NV40EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV40EXA_FPID_PASS_COL0 ;NV40EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV40_GetPictOpRec (op);
src/nv50_exa.c +10 -0
@@ -250,6 +250,8 @@ NV50EXAPrepareSolid(PixmapPtr pdpix, int alu, Pixel planemask, Pixel fg)NV50EXA_LOCALS (pdpix);uint32_t fmt; +nouveau_exa_pixmap_prepare_for_accel (pdpix); +WAIT_RING (chan,64 );if (!NV50EXA2DSurfaceFormat (pdpix, &fmt))
@@ -311,6 +313,9 @@ NV50EXAPrepareCopy(PixmapPtr pspix, PixmapPtr pdpix, int dx, int dy, {NV50EXA_LOCALS (pdpix); +nouveau_exa_pixmap_prepare_for_accel (pspix); +nouveau_exa_pixmap_prepare_for_accel (pdpix); +WAIT_RING (chan,64 );if (!NV50EXAAcquireSurface2D (pspix,1 ))
@@ -769,6 +774,11 @@ NV50EXAPrepareComposite(int op,NV50EXA_LOCALS (pspix);const unsigned shd_flags =NOUVEAU_BO_VRAM |NOUVEAU_BO_RD ; +nouveau_exa_pixmap_prepare_for_accel (pspix); +if (pmpix) +nouveau_exa_pixmap_prepare_for_accel (pmpix); +nouveau_exa_pixmap_prepare_for_accel (pdpix); +WAIT_RING (chan,128 );BEGIN_RING (chan, eng2d,0x0110 ,1 );OUT_RING (chan,0 );
src/nv_include.h +2 -0
@@ -64,6 +64,8 @@#include <X11/extensions/randr.h> +#include "damagestr.h" +#define NV_DMA_DEBUG 0#include "nv_local.h"
src/nv_proto.h +1 -0
@@ -65,6 +65,7 @@ void NVTakedownDma(ScrnInfoPtr pScrn);Bool nouveau_exa_init (ScreenPtr pScreen);Bool nouveau_exa_pixmap_is_onscreen (PixmapPtr pPixmap);bool nouveau_exa_pixmap_is_tiled (PixmapPtr ppix); +void nouveau_exa_pixmap_prepare_for_accel (PixmapPtr ppix);void nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead,WriteMemoryProcPtr *pWrite,DrawablePtr pDraw);
src/nv_type.h +1 -0
@@ -481,6 +481,7 @@ struct nouveau_pixmap {void *linear;unsigned size;int tiling_mode; +bool dirty; }; static inline struct nouveau_pixmap *
Signature · 1 line
1.6.2
_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 6d4bc9fc0903130217g2b9b93fdx944283f8c076a0e-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Again updated patches that should make NV9X work as well.
Maarten.
From ae06e9286c8a26b6bd048e727d9bc6e09146ea07 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Sat, 7 Mar 2009 23:49:19 +0100
Subject: [PATCH 1/3] nv50: implement wfb
- Only for sufficiently new xserver's and exa_driver_pixmaps.
--- src/nouveau_exa.c | 279 +++++++++++++++++++++++++++++++++++++++++++++++++++-- src/nv50_exa.c | 31 ++++++- src/nv_driver.c | 52 +++++++++-- src/nv_proto.h | 6 + src/nv_type.h | 4 +- 5 files changed, 350 insertions(+), 22 deletions(-)
src/nouveau_exa.c +269 -10
@@ -89,7 +89,7 @@ NVAccelDownloadM2MF(PixmapPtr pspix, int x, int y, int w, int h,if (!linear) {BEGIN_RING (chan, m2mf,0x0200 ,7 );OUT_RING (chan,0 ); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (pspix));OUT_RING (chan, pspix->drawable.width * cpp);OUT_RING (chan, pspix->drawable.height);OUT_RING (chan,1 );
@@ -210,7 +210,7 @@ NVAccelUploadM2MF(PixmapPtr pdpix, int x, int y, int w, int h,if (!linear) {BEGIN_RING (chan, m2mf,0x021c ,7 );OUT_RING (chan,0 ); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (pdpix));OUT_RING (chan, pdpix->drawable.width * cpp);OUT_RING (chan, pdpix->drawable.height);OUT_RING (chan,1 );
@@ -259,7 +259,11 @@ nouveau_exa_mark_sync(ScreenPtr pScreen)static void nouveau_exa_wait_marker (ScreenPtr pScreen,int marker) { -NVSync (xf86Screens[pScreen->myNum]); +ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; +NVPtr pNv =NVPTR (pScrn); + +if (!pNv->exa_driver_pixmaps) +NVSync (xf86Screens[pScreen->myNum]); } static Bool
@@ -351,17 +355,32 @@ nouveau_exa_modify_pixmap_header(PixmapPtr ppix, int width, int height,if (!nvpix->bo && nvpix->size) {uint32_t cpp = ppix->drawable.bitsPerPixel >>3 ; -/* At some point we should just keep 1bpp pixmaps in sysram */ uint32_t flags =NOUVEAU_BO_VRAM ;int ret;if (pNv->Architecture >=NV_ARCH_50 && cpp) { -uint32_t aw = (width +7 ) & ~7 ; -uint32_t ah = (height +7 ) & ~7 ; +uint32_t ah; +if (height >47 ) { + ah = (height +63 ) & ~63 ; + nvpix->tiling_mode =5 ; + }else if (height >23 ) { + ah = (height +31 ) & ~31 ; + nvpix->tiling_mode =4 ; + }else if (height >11 ) { + ah = (height +15 ) & ~15 ; + nvpix->tiling_mode =3 ; + }else if (height >5 ) { + ah = (height +7 ) & ~7 ; + nvpix->tiling_mode =2 ; + }else { + ah = (height +3 ) & ~3 ; + nvpix->tiling_mode =1 ; + } flags |=NOUVEAU_BO_TILED ; - devkind = ((aw * cpp) +63 ) & ~63 ; +/* This allignment is very important. */ + devkind = (width * cpp +63 ) & ~63 ; nvpix->size = devkind * ah; }
@@ -390,8 +409,11 @@ nouveau_exa_pixmap_is_tiled(PixmapPtr ppix)NVPtr pNv =NVPTR (pScrn);if (pNv->exa_driver_pixmaps) { -if (!nouveau_pixmap_bo (ppix)->tiled) +if (!nouveau_pixmap_bo (ppix)) +return false; +if (nouveau_pixmap_bo (ppix)->tiled ==0 )return false; +return true; }else if (pNv->Architecture <NV_ARCH_50 ||exaGetPixmapOffset (ppix) < pNv->EXADriverPtr->offScreenBase)
@@ -403,10 +425,12 @@ nouveau_exa_pixmap_is_tiled(PixmapPtr ppix)static void *nouveau_exa_pixmap_map (PixmapPtr ppix) { +ScrnInfoPtr pScrn = xf86Screens[ppix->drawable.pScreen->myNum]; +NVPtr pNv =NVPTR (pScrn);struct nouveau_bo *bo =nouveau_pixmap_bo (ppix);unsigned delta =nouveau_pixmap_offset (ppix); -if (bo->tiled) { +if (!pNv->wfb_enabled && bo->tiled) {struct nouveau_pixmap *nvpix =nouveau_pixmap (ppix); nvpix->linear =xcalloc (1 , ppix->devKind * ppix->drawable.height);
@@ -426,9 +450,11 @@ nouveau_exa_pixmap_map(PixmapPtr ppix)static void nouveau_exa_pixmap_unmap (PixmapPtr ppix) { +ScrnInfoPtr pScrn = xf86Screens[ppix->drawable.pScreen->myNum]; +NVPtr pNv =NVPTR (pScrn);struct nouveau_bo *bo =nouveau_pixmap_bo (ppix); -if (bo->tiled) { +if (!pNv->wfb_enabled && bo->tiled) {struct nouveau_pixmap *nvpix =nouveau_pixmap (ppix); NVAccelUploadM2MF(ppix, 0, 0, ppix->drawable.width,
@@ -674,3 +700,236 @@ nouveau_exa_init(ScreenPtr pScreen) pNv->EXADriverPtr = exa;return TRUE; } + +/* WFB functions. */ + +static inline FbBits +nouveau_exa_wfb_read_memory_linear (const void *src,int size) +{ +FbBits bits =0 ; + +memcpy (&bits, src, size); + +return bits; +} + +static inline void +nouveau_exa_wfb_write_memory_linear (void *dst,FbBits value,int size) +{ +memcpy (dst, &value, size); +} + +#define LINEAR_PITCH (pPixmap->devKind) + +/* Wfb related data. */ +static struct { +PixmapPtr ppix; +bool used; +bool tiled; +unsigned long start; +unsigned long end; +uint64_t multiply_factor; +uint8_t cpp; +unsigned int tile_height; +unsigned int num_tiles_width; +} wfb_pixmaps[6 ]; + +/* height: empty, 2, 4, 8, 16, 32, 64 */ +const unsigned int num_tiles[] = {0 ,0 ,4 ,2 ,1 ,1 ,1 }; +const unsigned int tile_pitch[] = {0 ,3 ,5 ,6 ,6 ,6 ,6 }; +const unsigned int mask_height_inv[] = {~0 , ~1 , ~3 , ~7 , ~15 , ~31 , ~63 }; +const unsigned int mask_pitch_inv[] = {~0 , ~7 , ~31 , ~63 , ~63 , ~63 , ~63 }; +const unsigned int mask_height[] = {0 ,1 ,3 ,7 ,15 ,31 ,63 }; +const unsigned int mask_pitch[] = {0 ,7 ,31 ,63 ,63 ,63 ,63 }; + +#define X_REMAINDER (x & mask_pitch[tile_height]) +#define Y_REMAINDER (y & mask_height[tile_height]) + +/* tile_height and tile_pitch are expressed in powers of two */ +static inline unsigned int +nouveau_exa_wfb_recurse_offset (unsigned int offset,unsigned int tile_height, +unsigned int x,unsigned int y,unsigned int num_tiles_width) +{ + offset += (((x & mask_pitch_inv[tile_height]) >> tile_pitch[tile_height]) + (((y & mask_height_inv[tile_height]) >> tile_height) * num_tiles_width)) * (1 << (tile_height + tile_pitch[tile_height])); + +if (tile_height >1 ) + offset =nouveau_exa_wfb_recurse_offset (offset, tile_height -1 ,X_REMAINDER ,Y_REMAINDER , num_tiles[tile_height]); +else + offset += (Y_REMAINDER * (1 << tile_pitch[tile_height])) +X_REMAINDER ; + +return offset; +} + +/* Note, we can only expose one read and write function, the linear versions are for internal consumption. */ +static FbBits +nouveau_exa_wfb_read_memory (const void *src,int size) +{ +int i; +uint64_t line_x, line_y; +unsigned long offset = (unsigned long ) src, subpixel_offset; +PixmapPtr pPixmap =NULL ; +FbBits bits =0 ; +void *new_src; + +/* Find the right pixmap. */ +for (i =0 ; i <6 ; i++) +if (offset >= wfb_pixmaps[i].start && offset < wfb_pixmaps[i].end) { + pPixmap = wfb_pixmaps[i].ppix; +break ; + } + +if (!pPixmap || !wfb_pixmaps[i].tiled) +return nouveau_exa_wfb_read_memory_linear (src, size); + +/* Now comes the decoding. */ + offset -= (unsigned long ) pPixmap->devPrivate.ptr; +/* Assuming dword alligned offsets. */ + subpixel_offset = offset & (wfb_pixmaps[i].cpp -1 ); + offset &= ~(wfb_pixmaps[i].cpp -1 ); + +/* Determine the coordinate first. */ +/* Division is too expensive for large numbers, so we precalculate a multiplication factor. */ + line_y = (offset * wfb_pixmaps[i].multiply_factor) >>32 ; + line_x = offset - line_y *LINEAR_PITCH ; + + new_src = pPixmap->devPrivate.ptr + +nouveau_exa_wfb_recurse_offset (0 , wfb_pixmaps[i].tile_height, line_x, line_y, wfb_pixmaps[i].num_tiles_width) + + subpixel_offset; + +memcpy (&bits, new_src, size); + +return bits; +} + +static void +nouveau_exa_wfb_write_memory (void *dst,FbBits value,int size) +{ +int i; +uint64_t line_x, line_y; +unsigned long offset = (unsigned long ) dst, subpixel_offset; +PixmapPtr pPixmap =NULL ; +void *new_dst; + +/* Find the right pixmap. */ +for (i =0 ; i <6 ; i++) +if (offset >= wfb_pixmaps[i].start && offset < wfb_pixmaps[i].end) { + pPixmap = wfb_pixmaps[i].ppix; +break ; + } + +if (!pPixmap || !wfb_pixmaps[i].tiled) { +nouveau_exa_wfb_write_memory_linear (dst, value, size); +return ; + } + +/* Now comes the decoding. */ + offset -= (unsigned long ) pPixmap->devPrivate.ptr; +/* Assuming dword alligned offsets. */ + subpixel_offset = offset & (wfb_pixmaps[i].cpp -1 ); + offset &= ~(wfb_pixmaps[i].cpp -1 ); + +/* Determine the coordinate first. */ +/* Division is too expensive for large numbers, so we precalculate a multiplication factor. */ + line_y = (offset * wfb_pixmaps[i].multiply_factor) >>32 ; + line_x = offset - line_y *LINEAR_PITCH ; + + new_dst = pPixmap->devPrivate.ptr + +nouveau_exa_wfb_recurse_offset (0 , wfb_pixmaps[i].tile_height, line_x, line_y, wfb_pixmaps[i].num_tiles_width) + + subpixel_offset; + +memcpy (new_dst, &value, size); +} + +void +nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead, +WriteMemoryProcPtr *pWrite, +DrawablePtr pDraw) +{ +PixmapPtr pPixmap; +struct nouveau_pixmap *nvpix; + +if (!pRead || !pWrite) +return ; + + pPixmap =NVGetDrawablePixmap (pDraw); +if (!pPixmap) +return ; + + nvpix =nouveau_pixmap (pPixmap); + +int i; +for (i =0 ; i <6 ; i++) +if (!wfb_pixmaps[i].used) +break ; + +if (i ==6 ) { +ErrorF ("More than 6 wraps are setup, what the hell is going on?\n" ); + *pRead =NULL ; + *pWrite =NULL ; +return ; + } + +/* We will get a pointer, somewhere in the range of this pixmap. */ +/* Based on linear representation ofcource. */ + wfb_pixmaps[i].ppix = pPixmap; + wfb_pixmaps[i].start = (unsigned long ) pPixmap->devPrivate.ptr; + wfb_pixmaps[i].end = wfb_pixmaps[i].start +exaGetPixmapPitch (pPixmap) * ((pPixmap->drawable.height +15 ) & ~15 ); + wfb_pixmaps[i].used = true; + wfb_pixmaps[i].tiled =nouveau_exa_pixmap_is_tiled (pPixmap); +/* Division is too expensive for large numbers, so we precalculate a multiplication factor. */ + wfb_pixmaps[i].multiply_factor = (0xFFFFFFFF /exaGetPixmapPitch (pPixmap)) +1 ; + wfb_pixmaps[i].cpp = (pPixmap->drawable.bitsPerPixel >>3 ); +if (!nvpix) { + wfb_pixmaps[i].tile_height =0 ; + wfb_pixmaps[i].num_tiles_width =0 ; + }else { + wfb_pixmaps[i].tile_height = nvpix->tiling_mode +1 ; + wfb_pixmaps[i].num_tiles_width =LINEAR_PITCH /(1 << tile_pitch[wfb_pixmaps[i].tile_height]); + } + + *pRead = nouveau_exa_wfb_read_memory; + *pWrite = nouveau_exa_wfb_write_memory; +} + +void +nouveau_exa_wfb_finish_wrap (DrawablePtr pDraw) +{ +PixmapPtr pPixmap; +int i; + + pPixmap =NVGetDrawablePixmap (pDraw); +if (!pPixmap) +return ; + +for (i =0 ; i <6 ; i++) +if (wfb_pixmaps[i].ppix == pPixmap) { + wfb_pixmaps[i].ppix =NULL ; + wfb_pixmaps[i].start =0 ; + wfb_pixmaps[i].end =0 ; + wfb_pixmaps[i].used = false; + wfb_pixmaps[i].tiled = false; + wfb_pixmaps[i].multiply_factor =0 ; + wfb_pixmaps[i].cpp =0 ; + wfb_pixmaps[i].tile_height =0 ; + wfb_pixmaps[i].num_tiles_width =0 ; +break ; + } +} + +void +nouveau_exa_wfb_init () +{ +int i; + +for (i =0 ; i <6 ; i++) { + wfb_pixmaps[i].ppix =NULL ; + wfb_pixmaps[i].start =0 ; + wfb_pixmaps[i].end =0 ; + wfb_pixmaps[i].used = false; + wfb_pixmaps[i].tiled = false; + wfb_pixmaps[i].multiply_factor =0 ; + wfb_pixmaps[i].cpp =0 ; + wfb_pixmaps[i].tile_height =0 ; + wfb_pixmaps[i].num_tiles_width =0 ; + } +}
src/nv50_exa.c +28 -3
@@ -72,6 +72,31 @@ NV50EXABlendOp[] = { /* Add */ { 0, 0, BF( ONE), BF( ONE) }, }; + +uint32_t +nv50_exa_get_tile_mode (PixmapPtr ppix) +{ +struct nouveau_pixmap *nvpix =nouveau_pixmap (ppix); + +if (!nvpix) +return 0x00 ; + +switch (nvpix->tiling_mode) { +case 1 :/* pitch 32, height 4 */ +return 0x00 ; +case 2 :/* pitch 64, height 8 */ +return 0x10 ; +case 3 :/* pitch 64, height 16 */ +return 0x20 ; +case 4 :/* pitch 64, height 32 */ +return 0x30 ; +case 5 :/* pitch 64, height 64 */ +return 0x40 ; +default : +return 0x00 ; + } +} +static Bool NV50EXA2DSurfaceFormat (PixmapPtr ppix,uint32_t *fmt) {
@@ -128,7 +153,7 @@ NV50EXAAcquireSurface2D(PixmapPtr ppix, int is_src)BEGIN_RING (chan, eng2d, mthd,5 );OUT_RING (chan, fmt);OUT_RING (chan,0 ); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,1 );OUT_RING (chan,0 ); }
@@ -457,7 +482,7 @@ NV50EXARenderTarget(PixmapPtr ppix, PicturePtr ppict)OUT_RELOCh (chan, bo, delta,NOUVEAU_BO_VRAM |NOUVEAU_BO_WR );OUT_RELOCl (chan, bo, delta,NOUVEAU_BO_VRAM |NOUVEAU_BO_WR );OUT_RING (chan, format); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,0x00000000 );BEGIN_RING (chan, tesla,NV50TCL_RT_HORIZ (0 ),2 );OUT_RING (chan, ppix->drawable.width);
@@ -577,7 +602,7 @@ NV50EXATexture(PixmapPtr ppix, PicturePtr ppict, unsigned unit)NOUVEAU_FALLBACK ("invalid picture format, this SHOULD NOT HAPPEN. Expect trouble.\n" ); }OUT_RELOCl (chan, bo, delta,NOUVEAU_BO_VRAM |NOUVEAU_BO_RD ); -OUT_RING (chan,0xd0005000 ); +OUT_RING (chan,0xd0005000 | (nv50_exa_get_tile_mode (ppix) <<18 ));OUT_RING (chan,0x00300000 );OUT_RING (chan, ppix->drawable.width);OUT_RING (chan, (1 <<NV50TIC_0_5_DEPTH_SHIFT ) | ppix->drawable.height);
src/nv_driver.c +44 -8
83 lines not on this page · raw message
src/nv_proto.h +6 -0
@@ -64,6 +64,11 @@ void NVTakedownDma(ScrnInfoPtr pScrn);Bool nouveau_exa_init (ScreenPtr pScreen);Bool nouveau_exa_pixmap_is_onscreen (PixmapPtr pPixmap);bool nouveau_exa_pixmap_is_tiled (PixmapPtr ppix); +void nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead, +WriteMemoryProcPtr *pWrite, +DrawablePtr pDraw); +void nouveau_exa_wfb_finish_wrap (DrawablePtr pDraw); +void nouveau_exa_wfb_init ();/* in nv_hw.c */ void NVCalcStateExt (ScrnInfoPtr ,struct _riva_hw_state *,int ,int ,int ,int ,int ,int );
@@ -220,6 +225,7 @@ int NV40SetTexturePortAttribute(ScrnInfoPtr, Atom, INT32, pointer);Bool NVAccelInitNV50TCL (ScrnInfoPtr pScrn);/* in nv50_exa.c */ +uint32_t nv50_exa_get_tile_mode (PixmapPtr ppix);Bool NV50EXAPrepareSolid (PixmapPtr ,int ,Pixel ,Pixel );void NV50EXASolid (PixmapPtr ,int ,int ,int ,int );void NV50EXADoneSolid (PixmapPtr );
src/nv_type.h +3 -1
@@ -302,7 +302,8 @@ typedef struct _NVRec {uint8_t cur_head;ExaDriverPtr EXADriverPtr; -Bool exa_driver_pixmaps; +Bool exa_driver_pixmaps; +bool wfb_enabled;ScreenBlockHandlerProcPtr BlockHandler;CloseScreenProcPtr CloseScreen;/* Cursor */
@@ -473,6 +474,7 @@ struct nouveau_pixmap {struct nouveau_bo *bo;void *linear;unsigned size; +int tiling_mode; }; static inline struct nouveau_pixmap *
Signature · 1 line
1.6.2
From b872ab64a6581354a036434da5d53555d3628e66 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Fri, 13 Mar 2009 09:57:12 +0100
Subject: [PATCH 2/3] exa: smarter initial mapping of driver allocated pixmaps
- Use a software copy until the first accelerated op, then UTS it.
- The path back does not exist.
--- src/nouveau_exa.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++----- src/nv04_exa.c | 5 ++++ src/nv10_exa.c | 5 ++++ src/nv30_exa.c | 5 ++++ src/nv40_exa.c | 5 ++++ src/nv50_exa.c | 10 ++++++++ src/nv_proto.h | 1 + src/nv_type.h | 1 + 8 files changed, 89 insertions(+), 7 deletions(-)
src/nouveau_exa.c +57 -7
109 lines not on this page · raw message
src/nv04_exa.c +5 -0
@@ -83,6 +83,8 @@ NV04EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg)unsigned delta =nouveau_pixmap_offset (pPixmap);unsigned int fmt, pitch, color; +nouveau_exa_pixmap_prepare_for_accel (pPixmap); +WAIT_RING (chan,64 ); planemask |= ~0 << pPixmap->drawable.bitsPerPixel;
@@ -190,6 +192,9 @@ NV04EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int dx, int dy,unsigned dst_delta =nouveau_pixmap_offset (pDstPixmap);int fmt; +nouveau_exa_pixmap_prepare_for_accel (pSrcPixmap); +nouveau_exa_pixmap_prepare_for_accel (pDstPixmap); +WAIT_RING (chan,64 ); if (pSrcPixmap->drawable.bitsPerPixel !=
src/nv10_exa.c +5 -0
@@ -626,6 +626,11 @@ Bool NV10EXAPrepareComposite(int op,NVPtr pNv =NVPTR (pScrn);struct nouveau_channel *chan = pNv->chan; +nouveau_exa_pixmap_prepare_for_accel (pSrc); +if (pMask) +nouveau_exa_pixmap_prepare_for_accel (pMask); +nouveau_exa_pixmap_prepare_for_accel (pDst); +WAIT_RING (chan,128 );if (NV10Check_A8plusA8_Feasability (pSrcPicture,pMaskPicture,pDstPicture,op))
src/nv30_exa.c +5 -0
@@ -447,6 +447,11 @@ NV30EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV30EXA_FPID_PASS_COL0 ;NV30EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV30_GetPictOpRec (op);
src/nv40_exa.c +5 -0
@@ -406,6 +406,11 @@ NV40EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV40EXA_FPID_PASS_COL0 ;NV40EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV40_GetPictOpRec (op);
src/nv50_exa.c +10 -0
@@ -250,6 +250,8 @@ NV50EXAPrepareSolid(PixmapPtr pdpix, int alu, Pixel planemask, Pixel fg)NV50EXA_LOCALS (pdpix);uint32_t fmt; +nouveau_exa_pixmap_prepare_for_accel (pdpix); +WAIT_RING (chan,64 );if (!NV50EXA2DSurfaceFormat (pdpix, &fmt))
@@ -311,6 +313,9 @@ NV50EXAPrepareCopy(PixmapPtr pspix, PixmapPtr pdpix, int dx, int dy, {NV50EXA_LOCALS (pdpix); +nouveau_exa_pixmap_prepare_for_accel (pspix); +nouveau_exa_pixmap_prepare_for_accel (pdpix); +WAIT_RING (chan,64 );if (!NV50EXAAcquireSurface2D (pspix,1 ))
@@ -769,6 +774,11 @@ NV50EXAPrepareComposite(int op,NV50EXA_LOCALS (pspix);const unsigned shd_flags =NOUVEAU_BO_VRAM |NOUVEAU_BO_RD ; +nouveau_exa_pixmap_prepare_for_accel (pspix); +if (pmpix) +nouveau_exa_pixmap_prepare_for_accel (pmpix); +nouveau_exa_pixmap_prepare_for_accel (pdpix); +WAIT_RING (chan,128 );BEGIN_RING (chan, eng2d,0x0110 ,1 );OUT_RING (chan,0 );
src/nv_proto.h +1 -0
@@ -64,6 +64,7 @@ void NVTakedownDma(ScrnInfoPtr pScrn);Bool nouveau_exa_init (ScreenPtr pScreen);Bool nouveau_exa_pixmap_is_onscreen (PixmapPtr pPixmap);bool nouveau_exa_pixmap_is_tiled (PixmapPtr ppix); +void nouveau_exa_pixmap_prepare_for_accel (PixmapPtr ppix);void nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead,WriteMemoryProcPtr *pWrite,DrawablePtr pDraw);
src/nv_type.h +1 -0
@@ -475,6 +475,7 @@ struct nouveau_pixmap {void *linear;unsigned size;int tiling_mode; +bool dirty; }; static inline struct nouveau_pixmap *
Signature · 1 line
1.6.2
From b8ef3c53622972ca70a6db4598b27a460116917f Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Sat, 14 Mar 2009 18:07:31 +0100
Subject: [PATCH 3/3] nv50: support NV9X hw with wfb
--- src/nouveau_exa.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 58 insertions(+), 4 deletions(-)
src/nouveau_exa.c +58 -4
105 lines not on this page · raw message
Signature · 1 line
1.6.2
src/nouveau_exa.c +377 -14
471 lines not on this page · raw message
src/nv04_exa.c +5 -0
@@ -83,6 +83,8 @@ NV04EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg)unsigned delta =nouveau_pixmap_offset (pPixmap);unsigned int fmt, pitch, color; +nouveau_exa_pixmap_prepare_for_accel (pPixmap); +WAIT_RING (chan,64 ); planemask |= ~0 << pPixmap->drawable.bitsPerPixel;
@@ -190,6 +192,9 @@ NV04EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int dx, int dy,unsigned dst_delta =nouveau_pixmap_offset (pDstPixmap);int fmt; +nouveau_exa_pixmap_prepare_for_accel (pSrcPixmap); +nouveau_exa_pixmap_prepare_for_accel (pDstPixmap); +WAIT_RING (chan,64 ); if (pSrcPixmap->drawable.bitsPerPixel !=
src/nv10_exa.c +5 -0
@@ -626,6 +626,11 @@ Bool NV10EXAPrepareComposite(int op,NVPtr pNv =NVPTR (pScrn);struct nouveau_channel *chan = pNv->chan; +nouveau_exa_pixmap_prepare_for_accel (pSrc); +if (pMask) +nouveau_exa_pixmap_prepare_for_accel (pMask); +nouveau_exa_pixmap_prepare_for_accel (pDst); +WAIT_RING (chan,128 );if (NV10Check_A8plusA8_Feasability (pSrcPicture,pMaskPicture,pDstPicture,op))
src/nv30_exa.c +5 -0
@@ -447,6 +447,11 @@ NV30EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV30EXA_FPID_PASS_COL0 ;NV30EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV30_GetPictOpRec (op);
src/nv40_exa.c +5 -0
@@ -406,6 +406,11 @@ NV40EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV40EXA_FPID_PASS_COL0 ;NV40EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV40_GetPictOpRec (op);
src/nv50_exa.c +38 -3
83 lines not on this page · raw message
src/nv_driver.c +44 -8
83 lines not on this page · raw message
src/nv_proto.h +7 -0
@@ -64,6 +64,12 @@ void NVTakedownDma(ScrnInfoPtr pScrn);Bool nouveau_exa_init (ScreenPtr pScreen);Bool nouveau_exa_pixmap_is_onscreen (PixmapPtr pPixmap);bool nouveau_exa_pixmap_is_tiled (PixmapPtr ppix); +void nouveau_exa_pixmap_prepare_for_accel (PixmapPtr ppix); +void nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead, +WriteMemoryProcPtr *pWrite, +DrawablePtr pDraw); +void nouveau_exa_wfb_finish_wrap (DrawablePtr pDraw); +void nouveau_exa_wfb_init ();/* in nv_hw.c */ void NVCalcStateExt (ScrnInfoPtr ,struct _riva_hw_state *,int ,int ,int ,int ,int ,int );
@@ -220,6 +226,7 @@ int NV40SetTexturePortAttribute(ScrnInfoPtr, Atom, INT32, pointer);Bool NVAccelInitNV50TCL (ScrnInfoPtr pScrn);/* in nv50_exa.c */ +uint32_t nv50_exa_get_tile_mode (PixmapPtr ppix);Bool NV50EXAPrepareSolid (PixmapPtr ,int ,Pixel ,Pixel );void NV50EXASolid (PixmapPtr ,int ,int ,int ,int );void NV50EXADoneSolid (PixmapPtr );
src/nv_type.h +4 -1
@@ -302,7 +302,8 @@ typedef struct _NVRec {uint8_t cur_head;ExaDriverPtr EXADriverPtr; -Bool exa_driver_pixmaps; +Bool exa_driver_pixmaps; +bool wfb_enabled;ScreenBlockHandlerProcPtr BlockHandler;CloseScreenProcPtr CloseScreen;/* Cursor */
@@ -473,6 +474,8 @@ struct nouveau_pixmap {struct nouveau_bo *bo;void *linear;unsigned size; +int tiling_mode; +bool dirty; }; static inline struct nouveau_pixmap *
_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 6d4bc9fc0903141029g958e293n34ba9328f6458cee-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Updated patch set.
From ae06e9286c8a26b6bd048e727d9bc6e09146ea07 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Sat, 7 Mar 2009 23:49:19 +0100
Subject: [PATCH 1/5] nv50: implement wfb
- Only for sufficiently new xserver's and exa_driver_pixmaps.
--- src/nouveau_exa.c | 279 +++++++++++++++++++++++++++++++++++++++++++++++++++-- src/nv50_exa.c | 31 ++++++- src/nv_driver.c | 52 +++++++++-- src/nv_proto.h | 6 + src/nv_type.h | 4 +- 5 files changed, 350 insertions(+), 22 deletions(-)
src/nouveau_exa.c +269 -10
@@ -89,7 +89,7 @@ NVAccelDownloadM2MF(PixmapPtr pspix, int x, int y, int w, int h,if (!linear) {BEGIN_RING (chan, m2mf,0x0200 ,7 );OUT_RING (chan,0 ); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (pspix));OUT_RING (chan, pspix->drawable.width * cpp);OUT_RING (chan, pspix->drawable.height);OUT_RING (chan,1 );
@@ -210,7 +210,7 @@ NVAccelUploadM2MF(PixmapPtr pdpix, int x, int y, int w, int h,if (!linear) {BEGIN_RING (chan, m2mf,0x021c ,7 );OUT_RING (chan,0 ); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (pdpix));OUT_RING (chan, pdpix->drawable.width * cpp);OUT_RING (chan, pdpix->drawable.height);OUT_RING (chan,1 );
@@ -259,7 +259,11 @@ nouveau_exa_mark_sync(ScreenPtr pScreen)static void nouveau_exa_wait_marker (ScreenPtr pScreen,int marker) { -NVSync (xf86Screens[pScreen->myNum]); +ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; +NVPtr pNv =NVPTR (pScrn); + +if (!pNv->exa_driver_pixmaps) +NVSync (xf86Screens[pScreen->myNum]); } static Bool
@@ -351,17 +355,32 @@ nouveau_exa_modify_pixmap_header(PixmapPtr ppix, int width, int height,if (!nvpix->bo && nvpix->size) {uint32_t cpp = ppix->drawable.bitsPerPixel >>3 ; -/* At some point we should just keep 1bpp pixmaps in sysram */ uint32_t flags =NOUVEAU_BO_VRAM ;int ret;if (pNv->Architecture >=NV_ARCH_50 && cpp) { -uint32_t aw = (width +7 ) & ~7 ; -uint32_t ah = (height +7 ) & ~7 ; +uint32_t ah; +if (height >47 ) { + ah = (height +63 ) & ~63 ; + nvpix->tiling_mode =5 ; + }else if (height >23 ) { + ah = (height +31 ) & ~31 ; + nvpix->tiling_mode =4 ; + }else if (height >11 ) { + ah = (height +15 ) & ~15 ; + nvpix->tiling_mode =3 ; + }else if (height >5 ) { + ah = (height +7 ) & ~7 ; + nvpix->tiling_mode =2 ; + }else { + ah = (height +3 ) & ~3 ; + nvpix->tiling_mode =1 ; + } flags |=NOUVEAU_BO_TILED ; - devkind = ((aw * cpp) +63 ) & ~63 ; +/* This allignment is very important. */ + devkind = (width * cpp +63 ) & ~63 ; nvpix->size = devkind * ah; }
@@ -390,8 +409,11 @@ nouveau_exa_pixmap_is_tiled(PixmapPtr ppix)NVPtr pNv =NVPTR (pScrn);if (pNv->exa_driver_pixmaps) { -if (!nouveau_pixmap_bo (ppix)->tiled) +if (!nouveau_pixmap_bo (ppix)) +return false; +if (nouveau_pixmap_bo (ppix)->tiled ==0 )return false; +return true; }else if (pNv->Architecture <NV_ARCH_50 ||exaGetPixmapOffset (ppix) < pNv->EXADriverPtr->offScreenBase)
@@ -403,10 +425,12 @@ nouveau_exa_pixmap_is_tiled(PixmapPtr ppix)static void *nouveau_exa_pixmap_map (PixmapPtr ppix) { +ScrnInfoPtr pScrn = xf86Screens[ppix->drawable.pScreen->myNum]; +NVPtr pNv =NVPTR (pScrn);struct nouveau_bo *bo =nouveau_pixmap_bo (ppix);unsigned delta =nouveau_pixmap_offset (ppix); -if (bo->tiled) { +if (!pNv->wfb_enabled && bo->tiled) {struct nouveau_pixmap *nvpix =nouveau_pixmap (ppix); nvpix->linear =xcalloc (1 , ppix->devKind * ppix->drawable.height);
@@ -426,9 +450,11 @@ nouveau_exa_pixmap_map(PixmapPtr ppix)static void nouveau_exa_pixmap_unmap (PixmapPtr ppix) { +ScrnInfoPtr pScrn = xf86Screens[ppix->drawable.pScreen->myNum]; +NVPtr pNv =NVPTR (pScrn);struct nouveau_bo *bo =nouveau_pixmap_bo (ppix); -if (bo->tiled) { +if (!pNv->wfb_enabled && bo->tiled) {struct nouveau_pixmap *nvpix =nouveau_pixmap (ppix); NVAccelUploadM2MF(ppix, 0, 0, ppix->drawable.width,
@@ -674,3 +700,236 @@ nouveau_exa_init(ScreenPtr pScreen) pNv->EXADriverPtr = exa;return TRUE; } + +/* WFB functions. */ + +static inline FbBits +nouveau_exa_wfb_read_memory_linear (const void *src,int size) +{ +FbBits bits =0 ; + +memcpy (&bits, src, size); + +return bits; +} + +static inline void +nouveau_exa_wfb_write_memory_linear (void *dst,FbBits value,int size) +{ +memcpy (dst, &value, size); +} + +#define LINEAR_PITCH (pPixmap->devKind) + +/* Wfb related data. */ +static struct { +PixmapPtr ppix; +bool used; +bool tiled; +unsigned long start; +unsigned long end; +uint64_t multiply_factor; +uint8_t cpp; +unsigned int tile_height; +unsigned int num_tiles_width; +} wfb_pixmaps[6 ]; + +/* height: empty, 2, 4, 8, 16, 32, 64 */ +const unsigned int num_tiles[] = {0 ,0 ,4 ,2 ,1 ,1 ,1 }; +const unsigned int tile_pitch[] = {0 ,3 ,5 ,6 ,6 ,6 ,6 }; +const unsigned int mask_height_inv[] = {~0 , ~1 , ~3 , ~7 , ~15 , ~31 , ~63 }; +const unsigned int mask_pitch_inv[] = {~0 , ~7 , ~31 , ~63 , ~63 , ~63 , ~63 }; +const unsigned int mask_height[] = {0 ,1 ,3 ,7 ,15 ,31 ,63 }; +const unsigned int mask_pitch[] = {0 ,7 ,31 ,63 ,63 ,63 ,63 }; + +#define X_REMAINDER (x & mask_pitch[tile_height]) +#define Y_REMAINDER (y & mask_height[tile_height]) + +/* tile_height and tile_pitch are expressed in powers of two */ +static inline unsigned int +nouveau_exa_wfb_recurse_offset (unsigned int offset,unsigned int tile_height, +unsigned int x,unsigned int y,unsigned int num_tiles_width) +{ + offset += (((x & mask_pitch_inv[tile_height]) >> tile_pitch[tile_height]) + (((y & mask_height_inv[tile_height]) >> tile_height) * num_tiles_width)) * (1 << (tile_height + tile_pitch[tile_height])); + +if (tile_height >1 ) + offset =nouveau_exa_wfb_recurse_offset (offset, tile_height -1 ,X_REMAINDER ,Y_REMAINDER , num_tiles[tile_height]); +else + offset += (Y_REMAINDER * (1 << tile_pitch[tile_height])) +X_REMAINDER ; + +return offset; +} + +/* Note, we can only expose one read and write function, the linear versions are for internal consumption. */ +static FbBits +nouveau_exa_wfb_read_memory (const void *src,int size) +{ +int i; +uint64_t line_x, line_y; +unsigned long offset = (unsigned long ) src, subpixel_offset; +PixmapPtr pPixmap =NULL ; +FbBits bits =0 ; +void *new_src; + +/* Find the right pixmap. */ +for (i =0 ; i <6 ; i++) +if (offset >= wfb_pixmaps[i].start && offset < wfb_pixmaps[i].end) { + pPixmap = wfb_pixmaps[i].ppix; +break ; + } + +if (!pPixmap || !wfb_pixmaps[i].tiled) +return nouveau_exa_wfb_read_memory_linear (src, size); + +/* Now comes the decoding. */ + offset -= (unsigned long ) pPixmap->devPrivate.ptr; +/* Assuming dword alligned offsets. */ + subpixel_offset = offset & (wfb_pixmaps[i].cpp -1 ); + offset &= ~(wfb_pixmaps[i].cpp -1 ); + +/* Determine the coordinate first. */ +/* Division is too expensive for large numbers, so we precalculate a multiplication factor. */ + line_y = (offset * wfb_pixmaps[i].multiply_factor) >>32 ; + line_x = offset - line_y *LINEAR_PITCH ; + + new_src = pPixmap->devPrivate.ptr + +nouveau_exa_wfb_recurse_offset (0 , wfb_pixmaps[i].tile_height, line_x, line_y, wfb_pixmaps[i].num_tiles_width) + + subpixel_offset; + +memcpy (&bits, new_src, size); + +return bits; +} + +static void +nouveau_exa_wfb_write_memory (void *dst,FbBits value,int size) +{ +int i; +uint64_t line_x, line_y; +unsigned long offset = (unsigned long ) dst, subpixel_offset; +PixmapPtr pPixmap =NULL ; +void *new_dst; + +/* Find the right pixmap. */ +for (i =0 ; i <6 ; i++) +if (offset >= wfb_pixmaps[i].start && offset < wfb_pixmaps[i].end) { + pPixmap = wfb_pixmaps[i].ppix; +break ; + } + +if (!pPixmap || !wfb_pixmaps[i].tiled) { +nouveau_exa_wfb_write_memory_linear (dst, value, size); +return ; + } + +/* Now comes the decoding. */ + offset -= (unsigned long ) pPixmap->devPrivate.ptr; +/* Assuming dword alligned offsets. */ + subpixel_offset = offset & (wfb_pixmaps[i].cpp -1 ); + offset &= ~(wfb_pixmaps[i].cpp -1 ); + +/* Determine the coordinate first. */ +/* Division is too expensive for large numbers, so we precalculate a multiplication factor. */ + line_y = (offset * wfb_pixmaps[i].multiply_factor) >>32 ; + line_x = offset - line_y *LINEAR_PITCH ; + + new_dst = pPixmap->devPrivate.ptr + +nouveau_exa_wfb_recurse_offset (0 , wfb_pixmaps[i].tile_height, line_x, line_y, wfb_pixmaps[i].num_tiles_width) + + subpixel_offset; + +memcpy (new_dst, &value, size); +} + +void +nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead, +WriteMemoryProcPtr *pWrite, +DrawablePtr pDraw) +{ +PixmapPtr pPixmap; +struct nouveau_pixmap *nvpix; + +if (!pRead || !pWrite) +return ; + + pPixmap =NVGetDrawablePixmap (pDraw); +if (!pPixmap) +return ; + + nvpix =nouveau_pixmap (pPixmap); + +int i; +for (i =0 ; i <6 ; i++) +if (!wfb_pixmaps[i].used) +break ; + +if (i ==6 ) { +ErrorF ("More than 6 wraps are setup, what the hell is going on?\n" ); + *pRead =NULL ; + *pWrite =NULL ; +return ; + } + +/* We will get a pointer, somewhere in the range of this pixmap. */ +/* Based on linear representation ofcource. */ + wfb_pixmaps[i].ppix = pPixmap; + wfb_pixmaps[i].start = (unsigned long ) pPixmap->devPrivate.ptr; + wfb_pixmaps[i].end = wfb_pixmaps[i].start +exaGetPixmapPitch (pPixmap) * ((pPixmap->drawable.height +15 ) & ~15 ); + wfb_pixmaps[i].used = true; + wfb_pixmaps[i].tiled =nouveau_exa_pixmap_is_tiled (pPixmap); +/* Division is too expensive for large numbers, so we precalculate a multiplication factor. */ + wfb_pixmaps[i].multiply_factor = (0xFFFFFFFF /exaGetPixmapPitch (pPixmap)) +1 ; + wfb_pixmaps[i].cpp = (pPixmap->drawable.bitsPerPixel >>3 ); +if (!nvpix) { + wfb_pixmaps[i].tile_height =0 ; + wfb_pixmaps[i].num_tiles_width =0 ; + }else { + wfb_pixmaps[i].tile_height = nvpix->tiling_mode +1 ; + wfb_pixmaps[i].num_tiles_width =LINEAR_PITCH /(1 << tile_pitch[wfb_pixmaps[i].tile_height]); + } + + *pRead = nouveau_exa_wfb_read_memory; + *pWrite = nouveau_exa_wfb_write_memory; +} + +void +nouveau_exa_wfb_finish_wrap (DrawablePtr pDraw) +{ +PixmapPtr pPixmap; +int i; + + pPixmap =NVGetDrawablePixmap (pDraw); +if (!pPixmap) +return ; + +for (i =0 ; i <6 ; i++) +if (wfb_pixmaps[i].ppix == pPixmap) { + wfb_pixmaps[i].ppix =NULL ; + wfb_pixmaps[i].start =0 ; + wfb_pixmaps[i].end =0 ; + wfb_pixmaps[i].used = false; + wfb_pixmaps[i].tiled = false; + wfb_pixmaps[i].multiply_factor =0 ; + wfb_pixmaps[i].cpp =0 ; + wfb_pixmaps[i].tile_height =0 ; + wfb_pixmaps[i].num_tiles_width =0 ; +break ; + } +} + +void +nouveau_exa_wfb_init () +{ +int i; + +for (i =0 ; i <6 ; i++) { + wfb_pixmaps[i].ppix =NULL ; + wfb_pixmaps[i].start =0 ; + wfb_pixmaps[i].end =0 ; + wfb_pixmaps[i].used = false; + wfb_pixmaps[i].tiled = false; + wfb_pixmaps[i].multiply_factor =0 ; + wfb_pixmaps[i].cpp =0 ; + wfb_pixmaps[i].tile_height =0 ; + wfb_pixmaps[i].num_tiles_width =0 ; + } +}
src/nv50_exa.c +28 -3
@@ -72,6 +72,31 @@ NV50EXABlendOp[] = { /* Add */ { 0, 0, BF( ONE), BF( ONE) }, }; + +uint32_t +nv50_exa_get_tile_mode (PixmapPtr ppix) +{ +struct nouveau_pixmap *nvpix =nouveau_pixmap (ppix); + +if (!nvpix) +return 0x00 ; + +switch (nvpix->tiling_mode) { +case 1 :/* pitch 32, height 4 */ +return 0x00 ; +case 2 :/* pitch 64, height 8 */ +return 0x10 ; +case 3 :/* pitch 64, height 16 */ +return 0x20 ; +case 4 :/* pitch 64, height 32 */ +return 0x30 ; +case 5 :/* pitch 64, height 64 */ +return 0x40 ; +default : +return 0x00 ; + } +} +static Bool NV50EXA2DSurfaceFormat (PixmapPtr ppix,uint32_t *fmt) {
@@ -128,7 +153,7 @@ NV50EXAAcquireSurface2D(PixmapPtr ppix, int is_src)BEGIN_RING (chan, eng2d, mthd,5 );OUT_RING (chan, fmt);OUT_RING (chan,0 ); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,1 );OUT_RING (chan,0 ); }
@@ -457,7 +482,7 @@ NV50EXARenderTarget(PixmapPtr ppix, PicturePtr ppict)OUT_RELOCh (chan, bo, delta,NOUVEAU_BO_VRAM |NOUVEAU_BO_WR );OUT_RELOCl (chan, bo, delta,NOUVEAU_BO_VRAM |NOUVEAU_BO_WR );OUT_RING (chan, format); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,0x00000000 );BEGIN_RING (chan, tesla,NV50TCL_RT_HORIZ (0 ),2 );OUT_RING (chan, ppix->drawable.width);
@@ -577,7 +602,7 @@ NV50EXATexture(PixmapPtr ppix, PicturePtr ppict, unsigned unit)NOUVEAU_FALLBACK ("invalid picture format, this SHOULD NOT HAPPEN. Expect trouble.\n" ); }OUT_RELOCl (chan, bo, delta,NOUVEAU_BO_VRAM |NOUVEAU_BO_RD ); -OUT_RING (chan,0xd0005000 ); +OUT_RING (chan,0xd0005000 | (nv50_exa_get_tile_mode (ppix) <<18 ));OUT_RING (chan,0x00300000 );OUT_RING (chan, ppix->drawable.width);OUT_RING (chan, (1 <<NV50TIC_0_5_DEPTH_SHIFT ) | ppix->drawable.height);
src/nv_driver.c +44 -8
83 lines not on this page · raw message
src/nv_proto.h +6 -0
@@ -64,6 +64,11 @@ void NVTakedownDma(ScrnInfoPtr pScrn);Bool nouveau_exa_init (ScreenPtr pScreen);Bool nouveau_exa_pixmap_is_onscreen (PixmapPtr pPixmap);bool nouveau_exa_pixmap_is_tiled (PixmapPtr ppix); +void nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead, +WriteMemoryProcPtr *pWrite, +DrawablePtr pDraw); +void nouveau_exa_wfb_finish_wrap (DrawablePtr pDraw); +void nouveau_exa_wfb_init ();/* in nv_hw.c */ void NVCalcStateExt (ScrnInfoPtr ,struct _riva_hw_state *,int ,int ,int ,int ,int ,int );
@@ -220,6 +225,7 @@ int NV40SetTexturePortAttribute(ScrnInfoPtr, Atom, INT32, pointer);Bool NVAccelInitNV50TCL (ScrnInfoPtr pScrn);/* in nv50_exa.c */ +uint32_t nv50_exa_get_tile_mode (PixmapPtr ppix);Bool NV50EXAPrepareSolid (PixmapPtr ,int ,Pixel ,Pixel );void NV50EXASolid (PixmapPtr ,int ,int ,int ,int );void NV50EXADoneSolid (PixmapPtr );
src/nv_type.h +3 -1
@@ -302,7 +302,8 @@ typedef struct _NVRec {uint8_t cur_head;ExaDriverPtr EXADriverPtr; -Bool exa_driver_pixmaps; +Bool exa_driver_pixmaps; +bool wfb_enabled;ScreenBlockHandlerProcPtr BlockHandler;CloseScreenProcPtr CloseScreen;/* Cursor */
@@ -473,6 +474,7 @@ struct nouveau_pixmap {struct nouveau_bo *bo;void *linear;unsigned size; +int tiling_mode; }; static inline struct nouveau_pixmap *
Signature · 1 line
1.6.2
From b872ab64a6581354a036434da5d53555d3628e66 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Fri, 13 Mar 2009 09:57:12 +0100
Subject: [PATCH 2/5] exa: smarter initial mapping of driver allocated pixmaps
- Use a software copy until the first accelerated op, then UTS it.
- The path back does not exist.
--- src/nouveau_exa.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++----- src/nv04_exa.c | 5 ++++ src/nv10_exa.c | 5 ++++ src/nv30_exa.c | 5 ++++ src/nv40_exa.c | 5 ++++ src/nv50_exa.c | 10 ++++++++ src/nv_proto.h | 1 + src/nv_type.h | 1 + 8 files changed, 89 insertions(+), 7 deletions(-)
src/nouveau_exa.c +57 -7
109 lines not on this page · raw message
src/nv04_exa.c +5 -0
@@ -83,6 +83,8 @@ NV04EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg)unsigned delta =nouveau_pixmap_offset (pPixmap);unsigned int fmt, pitch, color; +nouveau_exa_pixmap_prepare_for_accel (pPixmap); +WAIT_RING (chan,64 ); planemask |= ~0 << pPixmap->drawable.bitsPerPixel;
@@ -190,6 +192,9 @@ NV04EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int dx, int dy,unsigned dst_delta =nouveau_pixmap_offset (pDstPixmap);int fmt; +nouveau_exa_pixmap_prepare_for_accel (pSrcPixmap); +nouveau_exa_pixmap_prepare_for_accel (pDstPixmap); +WAIT_RING (chan,64 ); if (pSrcPixmap->drawable.bitsPerPixel !=
src/nv10_exa.c +5 -0
@@ -626,6 +626,11 @@ Bool NV10EXAPrepareComposite(int op,NVPtr pNv =NVPTR (pScrn);struct nouveau_channel *chan = pNv->chan; +nouveau_exa_pixmap_prepare_for_accel (pSrc); +if (pMask) +nouveau_exa_pixmap_prepare_for_accel (pMask); +nouveau_exa_pixmap_prepare_for_accel (pDst); +WAIT_RING (chan,128 );if (NV10Check_A8plusA8_Feasability (pSrcPicture,pMaskPicture,pDstPicture,op))
src/nv30_exa.c +5 -0
@@ -447,6 +447,11 @@ NV30EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV30EXA_FPID_PASS_COL0 ;NV30EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV30_GetPictOpRec (op);
src/nv40_exa.c +5 -0
@@ -406,6 +406,11 @@ NV40EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV40EXA_FPID_PASS_COL0 ;NV40EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV40_GetPictOpRec (op);
src/nv50_exa.c +10 -0
@@ -250,6 +250,8 @@ NV50EXAPrepareSolid(PixmapPtr pdpix, int alu, Pixel planemask, Pixel fg)NV50EXA_LOCALS (pdpix);uint32_t fmt; +nouveau_exa_pixmap_prepare_for_accel (pdpix); +WAIT_RING (chan,64 );if (!NV50EXA2DSurfaceFormat (pdpix, &fmt))
@@ -311,6 +313,9 @@ NV50EXAPrepareCopy(PixmapPtr pspix, PixmapPtr pdpix, int dx, int dy, {NV50EXA_LOCALS (pdpix); +nouveau_exa_pixmap_prepare_for_accel (pspix); +nouveau_exa_pixmap_prepare_for_accel (pdpix); +WAIT_RING (chan,64 );if (!NV50EXAAcquireSurface2D (pspix,1 ))
@@ -769,6 +774,11 @@ NV50EXAPrepareComposite(int op,NV50EXA_LOCALS (pspix);const unsigned shd_flags =NOUVEAU_BO_VRAM |NOUVEAU_BO_RD ; +nouveau_exa_pixmap_prepare_for_accel (pspix); +if (pmpix) +nouveau_exa_pixmap_prepare_for_accel (pmpix); +nouveau_exa_pixmap_prepare_for_accel (pdpix); +WAIT_RING (chan,128 );BEGIN_RING (chan, eng2d,0x0110 ,1 );OUT_RING (chan,0 );
src/nv_proto.h +1 -0
@@ -64,6 +64,7 @@ void NVTakedownDma(ScrnInfoPtr pScrn);Bool nouveau_exa_init (ScreenPtr pScreen);Bool nouveau_exa_pixmap_is_onscreen (PixmapPtr pPixmap);bool nouveau_exa_pixmap_is_tiled (PixmapPtr ppix); +void nouveau_exa_pixmap_prepare_for_accel (PixmapPtr ppix);void nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead,WriteMemoryProcPtr *pWrite,DrawablePtr pDraw);
src/nv_type.h +1 -0
@@ -475,6 +475,7 @@ struct nouveau_pixmap {void *linear;unsigned size;int tiling_mode; +bool dirty; }; static inline struct nouveau_pixmap *
Signature · 1 line
1.6.2
From b8ef3c53622972ca70a6db4598b27a460116917f Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Sat, 14 Mar 2009 18:07:31 +0100
Subject: [PATCH 3/5] nv50: support NV9X hw with wfb
--- src/nouveau_exa.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 58 insertions(+), 4 deletions(-)
src/nouveau_exa.c +58 -4
105 lines not on this page · raw message
Signature · 1 line
1.6.2
From 8666377679df3cbcb571fd2137941d66e5635ca3 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Sat, 14 Mar 2009 19:38:09 +0100
Subject: [PATCH 4/5] exa: don't put cpp == 0 pixmaps in vram
--- src/nouveau_exa.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
src/nouveau_exa.c +5 -1
@@ -358,9 +358,13 @@ nouveau_exa_modify_pixmap_header(PixmapPtr ppix, int width, int height,if (!nvpix->bo && nvpix->size) {uint32_t cpp = ppix->drawable.bitsPerPixel >>3 ; -uint32_t flags =NOUVEAU_BO_VRAM ; +uint32_t flags =0 ;int ret; +/* Let's not waste vram on useless pixmaps. */ +if (cpp) + flags |=NOUVEAU_BO_VRAM ; +if (pNv->Architecture >=NV_ARCH_50 && cpp) {uint32_t ah;if (height >47 ) {
Signature · 1 line
1.6.2
From 08ffafe32a71ebaaa955972ba5e1be2896d13634 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Sat, 14 Mar 2009 23:26:46 +0100
Subject: [PATCH 5/5] xv: some fixes
--- src/nouveau_xv.c | 24 +++++++++++++----------- src/nv50_xv.c | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-)
src/nouveau_xv.c +13 -11
@@ -718,10 +718,8 @@ NV_calculate_pitches_and_mem_size(NVPtr pNv, int action_flags, int *srcPitch, {int tmp; -if (pNv->Architecture >=NV_ARCH_50 ) { - npixels = (npixels +7 ) & ~7 ; - nlines = (nlines +7 ) & ~7 ; - } +if (pNv->Architecture >=NV_ARCH_50 ) + nlines = (nlines +3 ) & ~3 ;if (action_flags &IS_YV12 ) { *srcPitch = (width +3 ) & ~3 ;/* of luma */
@@ -1252,13 +1250,17 @@ CPU_copy:exaMoveInPixmap (ppix);/* check if it made it offscreen */ -#if NOUVEAU_EXA_PIXMAPS -if (!pNv->EXADriverPtr->PixmapIsOffscreen (ppix)) -#else - if (exaGetPixmapOffset(ppix) >= pNv->EXADriverPtr->memorySize) -#endif -/* we lost, insufficient space probably */ -return BadAlloc; +if (pNv->EXADriverPtr->PixmapIsOffscreen) { +if (!pNv->EXADriverPtr->PixmapIsOffscreen (ppix)) { +/* we lost, insufficient space probably */ +return BadAlloc; + } + }else { +if (exaGetPixmapOffset (ppix) >= pNv->EXADriverPtr->memorySize) { +/* we lost, insufficient space probably */ +return BadAlloc; + } + }ExaOffscreenMarkUsed (ppix);
src/nv50_xv.c +1 -1
@@ -76,7 +76,7 @@ nv50_xv_state_emit(PixmapPtr ppix, int id, struct nouveau_bo *src,case 24 :OUT_RING (chan,NV50TCL_RT_FORMAT_24BPP );break ;case 16 :OUT_RING (chan,NV50TCL_RT_FORMAT_16BPP );break ; } -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,0 );BEGIN_RING (chan, tesla,NV50TCL_RT_HORIZ (0 ),2 );OUT_RING (chan, ppix->drawable.width);
Signature · 1 line
1.6.2
src/nouveau_exa.c +382 -15
476 lines not on this page · raw message
src/nouveau_xv.c +13 -11
@@ -718,10 +718,8 @@ NV_calculate_pitches_and_mem_size(NVPtr pNv, int action_flags, int *srcPitch, {int tmp; -if (pNv->Architecture >=NV_ARCH_50 ) { - npixels = (npixels +7 ) & ~7 ; - nlines = (nlines +7 ) & ~7 ; - } +if (pNv->Architecture >=NV_ARCH_50 ) + nlines = (nlines +3 ) & ~3 ;if (action_flags &IS_YV12 ) { *srcPitch = (width +3 ) & ~3 ;/* of luma */
@@ -1252,13 +1250,17 @@ CPU_copy:exaMoveInPixmap (ppix);/* check if it made it offscreen */ -#if NOUVEAU_EXA_PIXMAPS -if (!pNv->EXADriverPtr->PixmapIsOffscreen (ppix)) -#else - if (exaGetPixmapOffset(ppix) >= pNv->EXADriverPtr->memorySize) -#endif -/* we lost, insufficient space probably */ -return BadAlloc; +if (pNv->EXADriverPtr->PixmapIsOffscreen) { +if (!pNv->EXADriverPtr->PixmapIsOffscreen (ppix)) { +/* we lost, insufficient space probably */ +return BadAlloc; + } + }else { +if (exaGetPixmapOffset (ppix) >= pNv->EXADriverPtr->memorySize) { +/* we lost, insufficient space probably */ +return BadAlloc; + } + }ExaOffscreenMarkUsed (ppix);
src/nv04_exa.c +5 -0
@@ -83,6 +83,8 @@ NV04EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg)unsigned delta =nouveau_pixmap_offset (pPixmap);unsigned int fmt, pitch, color; +nouveau_exa_pixmap_prepare_for_accel (pPixmap); +WAIT_RING (chan,64 ); planemask |= ~0 << pPixmap->drawable.bitsPerPixel;
@@ -190,6 +192,9 @@ NV04EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int dx, int dy,unsigned dst_delta =nouveau_pixmap_offset (pDstPixmap);int fmt; +nouveau_exa_pixmap_prepare_for_accel (pSrcPixmap); +nouveau_exa_pixmap_prepare_for_accel (pDstPixmap); +WAIT_RING (chan,64 ); if (pSrcPixmap->drawable.bitsPerPixel !=
src/nv10_exa.c +5 -0
@@ -626,6 +626,11 @@ Bool NV10EXAPrepareComposite(int op,NVPtr pNv =NVPTR (pScrn);struct nouveau_channel *chan = pNv->chan; +nouveau_exa_pixmap_prepare_for_accel (pSrc); +if (pMask) +nouveau_exa_pixmap_prepare_for_accel (pMask); +nouveau_exa_pixmap_prepare_for_accel (pDst); +WAIT_RING (chan,128 );if (NV10Check_A8plusA8_Feasability (pSrcPicture,pMaskPicture,pDstPicture,op))
src/nv30_exa.c +5 -0
@@ -447,6 +447,11 @@ NV30EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV30EXA_FPID_PASS_COL0 ;NV30EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV30_GetPictOpRec (op);
src/nv40_exa.c +5 -0
@@ -406,6 +406,11 @@ NV40EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV40EXA_FPID_PASS_COL0 ;NV40EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV40_GetPictOpRec (op);
src/nv50_exa.c +38 -3
83 lines not on this page · raw message
src/nv50_xv.c +1 -1
@@ -76,7 +76,7 @@ nv50_xv_state_emit(PixmapPtr ppix, int id, struct nouveau_bo *src,case 24 :OUT_RING (chan,NV50TCL_RT_FORMAT_24BPP );break ;case 16 :OUT_RING (chan,NV50TCL_RT_FORMAT_16BPP );break ; } -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,0 );BEGIN_RING (chan, tesla,NV50TCL_RT_HORIZ (0 ),2 );OUT_RING (chan, ppix->drawable.width);
src/nv_driver.c +44 -8
83 lines not on this page · raw message
src/nv_proto.h +7 -0
@@ -64,6 +64,12 @@ void NVTakedownDma(ScrnInfoPtr pScrn);Bool nouveau_exa_init (ScreenPtr pScreen);Bool nouveau_exa_pixmap_is_onscreen (PixmapPtr pPixmap);bool nouveau_exa_pixmap_is_tiled (PixmapPtr ppix); +void nouveau_exa_pixmap_prepare_for_accel (PixmapPtr ppix); +void nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead, +WriteMemoryProcPtr *pWrite, +DrawablePtr pDraw); +void nouveau_exa_wfb_finish_wrap (DrawablePtr pDraw); +void nouveau_exa_wfb_init ();/* in nv_hw.c */ void NVCalcStateExt (ScrnInfoPtr ,struct _riva_hw_state *,int ,int ,int ,int ,int ,int );
@@ -220,6 +226,7 @@ int NV40SetTexturePortAttribute(ScrnInfoPtr, Atom, INT32, pointer);Bool NVAccelInitNV50TCL (ScrnInfoPtr pScrn);/* in nv50_exa.c */ +uint32_t nv50_exa_get_tile_mode (PixmapPtr ppix);Bool NV50EXAPrepareSolid (PixmapPtr ,int ,Pixel ,Pixel );void NV50EXASolid (PixmapPtr ,int ,int ,int ,int );void NV50EXADoneSolid (PixmapPtr );
src/nv_type.h +4 -1
@@ -302,7 +302,8 @@ typedef struct _NVRec {uint8_t cur_head;ExaDriverPtr EXADriverPtr; -Bool exa_driver_pixmaps; +Bool exa_driver_pixmaps; +bool wfb_enabled;ScreenBlockHandlerProcPtr BlockHandler;CloseScreenProcPtr CloseScreen;/* Cursor */
@@ -473,6 +474,8 @@ struct nouveau_pixmap {struct nouveau_bo *bo;void *linear;unsigned size; +int tiling_mode; +bool dirty; }; static inline struct nouveau_pixmap *
_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 6d4bc9fc0903141737p21f3d82bg7aef6c65355ac9b1-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
This one fixes a small bug for NV9X, where i forgot to overallocate memory for the potential memory shift. This could fix the trailing pixel issue.
Maarten.
From ae06e9286c8a26b6bd048e727d9bc6e09146ea07 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Sat, 7 Mar 2009 23:49:19 +0100
Subject: [PATCH 1/5] nv50: implement wfb
- Only for sufficiently new xserver's and exa_driver_pixmaps.
--- src/nouveau_exa.c | 279 +++++++++++++++++++++++++++++++++++++++++++++++++++-- src/nv50_exa.c | 31 ++++++- src/nv_driver.c | 52 +++++++++-- src/nv_proto.h | 6 + src/nv_type.h | 4 +- 5 files changed, 350 insertions(+), 22 deletions(-)
src/nouveau_exa.c +269 -10
@@ -89,7 +89,7 @@ NVAccelDownloadM2MF(PixmapPtr pspix, int x, int y, int w, int h,if (!linear) {BEGIN_RING (chan, m2mf,0x0200 ,7 );OUT_RING (chan,0 ); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (pspix));OUT_RING (chan, pspix->drawable.width * cpp);OUT_RING (chan, pspix->drawable.height);OUT_RING (chan,1 );
@@ -210,7 +210,7 @@ NVAccelUploadM2MF(PixmapPtr pdpix, int x, int y, int w, int h,if (!linear) {BEGIN_RING (chan, m2mf,0x021c ,7 );OUT_RING (chan,0 ); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (pdpix));OUT_RING (chan, pdpix->drawable.width * cpp);OUT_RING (chan, pdpix->drawable.height);OUT_RING (chan,1 );
@@ -259,7 +259,11 @@ nouveau_exa_mark_sync(ScreenPtr pScreen)static void nouveau_exa_wait_marker (ScreenPtr pScreen,int marker) { -NVSync (xf86Screens[pScreen->myNum]); +ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; +NVPtr pNv =NVPTR (pScrn); + +if (!pNv->exa_driver_pixmaps) +NVSync (xf86Screens[pScreen->myNum]); } static Bool
@@ -351,17 +355,32 @@ nouveau_exa_modify_pixmap_header(PixmapPtr ppix, int width, int height,if (!nvpix->bo && nvpix->size) {uint32_t cpp = ppix->drawable.bitsPerPixel >>3 ; -/* At some point we should just keep 1bpp pixmaps in sysram */ uint32_t flags =NOUVEAU_BO_VRAM ;int ret;if (pNv->Architecture >=NV_ARCH_50 && cpp) { -uint32_t aw = (width +7 ) & ~7 ; -uint32_t ah = (height +7 ) & ~7 ; +uint32_t ah; +if (height >47 ) { + ah = (height +63 ) & ~63 ; + nvpix->tiling_mode =5 ; + }else if (height >23 ) { + ah = (height +31 ) & ~31 ; + nvpix->tiling_mode =4 ; + }else if (height >11 ) { + ah = (height +15 ) & ~15 ; + nvpix->tiling_mode =3 ; + }else if (height >5 ) { + ah = (height +7 ) & ~7 ; + nvpix->tiling_mode =2 ; + }else { + ah = (height +3 ) & ~3 ; + nvpix->tiling_mode =1 ; + } flags |=NOUVEAU_BO_TILED ; - devkind = ((aw * cpp) +63 ) & ~63 ; +/* This allignment is very important. */ + devkind = (width * cpp +63 ) & ~63 ; nvpix->size = devkind * ah; }
@@ -390,8 +409,11 @@ nouveau_exa_pixmap_is_tiled(PixmapPtr ppix)NVPtr pNv =NVPTR (pScrn);if (pNv->exa_driver_pixmaps) { -if (!nouveau_pixmap_bo (ppix)->tiled) +if (!nouveau_pixmap_bo (ppix)) +return false; +if (nouveau_pixmap_bo (ppix)->tiled ==0 )return false; +return true; }else if (pNv->Architecture <NV_ARCH_50 ||exaGetPixmapOffset (ppix) < pNv->EXADriverPtr->offScreenBase)
@@ -403,10 +425,12 @@ nouveau_exa_pixmap_is_tiled(PixmapPtr ppix)static void *nouveau_exa_pixmap_map (PixmapPtr ppix) { +ScrnInfoPtr pScrn = xf86Screens[ppix->drawable.pScreen->myNum]; +NVPtr pNv =NVPTR (pScrn);struct nouveau_bo *bo =nouveau_pixmap_bo (ppix);unsigned delta =nouveau_pixmap_offset (ppix); -if (bo->tiled) { +if (!pNv->wfb_enabled && bo->tiled) {struct nouveau_pixmap *nvpix =nouveau_pixmap (ppix); nvpix->linear =xcalloc (1 , ppix->devKind * ppix->drawable.height);
@@ -426,9 +450,11 @@ nouveau_exa_pixmap_map(PixmapPtr ppix)static void nouveau_exa_pixmap_unmap (PixmapPtr ppix) { +ScrnInfoPtr pScrn = xf86Screens[ppix->drawable.pScreen->myNum]; +NVPtr pNv =NVPTR (pScrn);struct nouveau_bo *bo =nouveau_pixmap_bo (ppix); -if (bo->tiled) { +if (!pNv->wfb_enabled && bo->tiled) {struct nouveau_pixmap *nvpix =nouveau_pixmap (ppix); NVAccelUploadM2MF(ppix, 0, 0, ppix->drawable.width,
@@ -674,3 +700,236 @@ nouveau_exa_init(ScreenPtr pScreen) pNv->EXADriverPtr = exa;return TRUE; } + +/* WFB functions. */ + +static inline FbBits +nouveau_exa_wfb_read_memory_linear (const void *src,int size) +{ +FbBits bits =0 ; + +memcpy (&bits, src, size); + +return bits; +} + +static inline void +nouveau_exa_wfb_write_memory_linear (void *dst,FbBits value,int size) +{ +memcpy (dst, &value, size); +} + +#define LINEAR_PITCH (pPixmap->devKind) + +/* Wfb related data. */ +static struct { +PixmapPtr ppix; +bool used; +bool tiled; +unsigned long start; +unsigned long end; +uint64_t multiply_factor; +uint8_t cpp; +unsigned int tile_height; +unsigned int num_tiles_width; +} wfb_pixmaps[6 ]; + +/* height: empty, 2, 4, 8, 16, 32, 64 */ +const unsigned int num_tiles[] = {0 ,0 ,4 ,2 ,1 ,1 ,1 }; +const unsigned int tile_pitch[] = {0 ,3 ,5 ,6 ,6 ,6 ,6 }; +const unsigned int mask_height_inv[] = {~0 , ~1 , ~3 , ~7 , ~15 , ~31 , ~63 }; +const unsigned int mask_pitch_inv[] = {~0 , ~7 , ~31 , ~63 , ~63 , ~63 , ~63 }; +const unsigned int mask_height[] = {0 ,1 ,3 ,7 ,15 ,31 ,63 }; +const unsigned int mask_pitch[] = {0 ,7 ,31 ,63 ,63 ,63 ,63 }; + +#define X_REMAINDER (x & mask_pitch[tile_height]) +#define Y_REMAINDER (y & mask_height[tile_height]) + +/* tile_height and tile_pitch are expressed in powers of two */ +static inline unsigned int +nouveau_exa_wfb_recurse_offset (unsigned int offset,unsigned int tile_height, +unsigned int x,unsigned int y,unsigned int num_tiles_width) +{ + offset += (((x & mask_pitch_inv[tile_height]) >> tile_pitch[tile_height]) + (((y & mask_height_inv[tile_height]) >> tile_height) * num_tiles_width)) * (1 << (tile_height + tile_pitch[tile_height])); + +if (tile_height >1 ) + offset =nouveau_exa_wfb_recurse_offset (offset, tile_height -1 ,X_REMAINDER ,Y_REMAINDER , num_tiles[tile_height]); +else + offset += (Y_REMAINDER * (1 << tile_pitch[tile_height])) +X_REMAINDER ; + +return offset; +} + +/* Note, we can only expose one read and write function, the linear versions are for internal consumption. */ +static FbBits +nouveau_exa_wfb_read_memory (const void *src,int size) +{ +int i; +uint64_t line_x, line_y; +unsigned long offset = (unsigned long ) src, subpixel_offset; +PixmapPtr pPixmap =NULL ; +FbBits bits =0 ; +void *new_src; + +/* Find the right pixmap. */ +for (i =0 ; i <6 ; i++) +if (offset >= wfb_pixmaps[i].start && offset < wfb_pixmaps[i].end) { + pPixmap = wfb_pixmaps[i].ppix; +break ; + } + +if (!pPixmap || !wfb_pixmaps[i].tiled) +return nouveau_exa_wfb_read_memory_linear (src, size); + +/* Now comes the decoding. */ + offset -= (unsigned long ) pPixmap->devPrivate.ptr; +/* Assuming dword alligned offsets. */ + subpixel_offset = offset & (wfb_pixmaps[i].cpp -1 ); + offset &= ~(wfb_pixmaps[i].cpp -1 ); + +/* Determine the coordinate first. */ +/* Division is too expensive for large numbers, so we precalculate a multiplication factor. */ + line_y = (offset * wfb_pixmaps[i].multiply_factor) >>32 ; + line_x = offset - line_y *LINEAR_PITCH ; + + new_src = pPixmap->devPrivate.ptr + +nouveau_exa_wfb_recurse_offset (0 , wfb_pixmaps[i].tile_height, line_x, line_y, wfb_pixmaps[i].num_tiles_width) + + subpixel_offset; + +memcpy (&bits, new_src, size); + +return bits; +} + +static void +nouveau_exa_wfb_write_memory (void *dst,FbBits value,int size) +{ +int i; +uint64_t line_x, line_y; +unsigned long offset = (unsigned long ) dst, subpixel_offset; +PixmapPtr pPixmap =NULL ; +void *new_dst; + +/* Find the right pixmap. */ +for (i =0 ; i <6 ; i++) +if (offset >= wfb_pixmaps[i].start && offset < wfb_pixmaps[i].end) { + pPixmap = wfb_pixmaps[i].ppix; +break ; + } + +if (!pPixmap || !wfb_pixmaps[i].tiled) { +nouveau_exa_wfb_write_memory_linear (dst, value, size); +return ; + } + +/* Now comes the decoding. */ + offset -= (unsigned long ) pPixmap->devPrivate.ptr; +/* Assuming dword alligned offsets. */ + subpixel_offset = offset & (wfb_pixmaps[i].cpp -1 ); + offset &= ~(wfb_pixmaps[i].cpp -1 ); + +/* Determine the coordinate first. */ +/* Division is too expensive for large numbers, so we precalculate a multiplication factor. */ + line_y = (offset * wfb_pixmaps[i].multiply_factor) >>32 ; + line_x = offset - line_y *LINEAR_PITCH ; + + new_dst = pPixmap->devPrivate.ptr + +nouveau_exa_wfb_recurse_offset (0 , wfb_pixmaps[i].tile_height, line_x, line_y, wfb_pixmaps[i].num_tiles_width) + + subpixel_offset; + +memcpy (new_dst, &value, size); +} + +void +nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead, +WriteMemoryProcPtr *pWrite, +DrawablePtr pDraw) +{ +PixmapPtr pPixmap; +struct nouveau_pixmap *nvpix; + +if (!pRead || !pWrite) +return ; + + pPixmap =NVGetDrawablePixmap (pDraw); +if (!pPixmap) +return ; + + nvpix =nouveau_pixmap (pPixmap); + +int i; +for (i =0 ; i <6 ; i++) +if (!wfb_pixmaps[i].used) +break ; + +if (i ==6 ) { +ErrorF ("More than 6 wraps are setup, what the hell is going on?\n" ); + *pRead =NULL ; + *pWrite =NULL ; +return ; + } + +/* We will get a pointer, somewhere in the range of this pixmap. */ +/* Based on linear representation ofcource. */ + wfb_pixmaps[i].ppix = pPixmap; + wfb_pixmaps[i].start = (unsigned long ) pPixmap->devPrivate.ptr; + wfb_pixmaps[i].end = wfb_pixmaps[i].start +exaGetPixmapPitch (pPixmap) * ((pPixmap->drawable.height +15 ) & ~15 ); + wfb_pixmaps[i].used = true; + wfb_pixmaps[i].tiled =nouveau_exa_pixmap_is_tiled (pPixmap); +/* Division is too expensive for large numbers, so we precalculate a multiplication factor. */ + wfb_pixmaps[i].multiply_factor = (0xFFFFFFFF /exaGetPixmapPitch (pPixmap)) +1 ; + wfb_pixmaps[i].cpp = (pPixmap->drawable.bitsPerPixel >>3 ); +if (!nvpix) { + wfb_pixmaps[i].tile_height =0 ; + wfb_pixmaps[i].num_tiles_width =0 ; + }else { + wfb_pixmaps[i].tile_height = nvpix->tiling_mode +1 ; + wfb_pixmaps[i].num_tiles_width =LINEAR_PITCH /(1 << tile_pitch[wfb_pixmaps[i].tile_height]); + } + + *pRead = nouveau_exa_wfb_read_memory; + *pWrite = nouveau_exa_wfb_write_memory; +} + +void +nouveau_exa_wfb_finish_wrap (DrawablePtr pDraw) +{ +PixmapPtr pPixmap; +int i; + + pPixmap =NVGetDrawablePixmap (pDraw); +if (!pPixmap) +return ; + +for (i =0 ; i <6 ; i++) +if (wfb_pixmaps[i].ppix == pPixmap) { + wfb_pixmaps[i].ppix =NULL ; + wfb_pixmaps[i].start =0 ; + wfb_pixmaps[i].end =0 ; + wfb_pixmaps[i].used = false; + wfb_pixmaps[i].tiled = false; + wfb_pixmaps[i].multiply_factor =0 ; + wfb_pixmaps[i].cpp =0 ; + wfb_pixmaps[i].tile_height =0 ; + wfb_pixmaps[i].num_tiles_width =0 ; +break ; + } +} + +void +nouveau_exa_wfb_init () +{ +int i; + +for (i =0 ; i <6 ; i++) { + wfb_pixmaps[i].ppix =NULL ; + wfb_pixmaps[i].start =0 ; + wfb_pixmaps[i].end =0 ; + wfb_pixmaps[i].used = false; + wfb_pixmaps[i].tiled = false; + wfb_pixmaps[i].multiply_factor =0 ; + wfb_pixmaps[i].cpp =0 ; + wfb_pixmaps[i].tile_height =0 ; + wfb_pixmaps[i].num_tiles_width =0 ; + } +}
src/nv50_exa.c +28 -3
@@ -72,6 +72,31 @@ NV50EXABlendOp[] = { /* Add */ { 0, 0, BF( ONE), BF( ONE) }, }; + +uint32_t +nv50_exa_get_tile_mode (PixmapPtr ppix) +{ +struct nouveau_pixmap *nvpix =nouveau_pixmap (ppix); + +if (!nvpix) +return 0x00 ; + +switch (nvpix->tiling_mode) { +case 1 :/* pitch 32, height 4 */ +return 0x00 ; +case 2 :/* pitch 64, height 8 */ +return 0x10 ; +case 3 :/* pitch 64, height 16 */ +return 0x20 ; +case 4 :/* pitch 64, height 32 */ +return 0x30 ; +case 5 :/* pitch 64, height 64 */ +return 0x40 ; +default : +return 0x00 ; + } +} +static Bool NV50EXA2DSurfaceFormat (PixmapPtr ppix,uint32_t *fmt) {
@@ -128,7 +153,7 @@ NV50EXAAcquireSurface2D(PixmapPtr ppix, int is_src)BEGIN_RING (chan, eng2d, mthd,5 );OUT_RING (chan, fmt);OUT_RING (chan,0 ); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,1 );OUT_RING (chan,0 ); }
@@ -457,7 +482,7 @@ NV50EXARenderTarget(PixmapPtr ppix, PicturePtr ppict)OUT_RELOCh (chan, bo, delta,NOUVEAU_BO_VRAM |NOUVEAU_BO_WR );OUT_RELOCl (chan, bo, delta,NOUVEAU_BO_VRAM |NOUVEAU_BO_WR );OUT_RING (chan, format); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,0x00000000 );BEGIN_RING (chan, tesla,NV50TCL_RT_HORIZ (0 ),2 );OUT_RING (chan, ppix->drawable.width);
@@ -577,7 +602,7 @@ NV50EXATexture(PixmapPtr ppix, PicturePtr ppict, unsigned unit)NOUVEAU_FALLBACK ("invalid picture format, this SHOULD NOT HAPPEN. Expect trouble.\n" ); }OUT_RELOCl (chan, bo, delta,NOUVEAU_BO_VRAM |NOUVEAU_BO_RD ); -OUT_RING (chan,0xd0005000 ); +OUT_RING (chan,0xd0005000 | (nv50_exa_get_tile_mode (ppix) <<18 ));OUT_RING (chan,0x00300000 );OUT_RING (chan, ppix->drawable.width);OUT_RING (chan, (1 <<NV50TIC_0_5_DEPTH_SHIFT ) | ppix->drawable.height);
src/nv_driver.c +44 -8
83 lines not on this page · raw message
src/nv_proto.h +6 -0
@@ -64,6 +64,11 @@ void NVTakedownDma(ScrnInfoPtr pScrn);Bool nouveau_exa_init (ScreenPtr pScreen);Bool nouveau_exa_pixmap_is_onscreen (PixmapPtr pPixmap);bool nouveau_exa_pixmap_is_tiled (PixmapPtr ppix); +void nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead, +WriteMemoryProcPtr *pWrite, +DrawablePtr pDraw); +void nouveau_exa_wfb_finish_wrap (DrawablePtr pDraw); +void nouveau_exa_wfb_init ();/* in nv_hw.c */ void NVCalcStateExt (ScrnInfoPtr ,struct _riva_hw_state *,int ,int ,int ,int ,int ,int );
@@ -220,6 +225,7 @@ int NV40SetTexturePortAttribute(ScrnInfoPtr, Atom, INT32, pointer);Bool NVAccelInitNV50TCL (ScrnInfoPtr pScrn);/* in nv50_exa.c */ +uint32_t nv50_exa_get_tile_mode (PixmapPtr ppix);Bool NV50EXAPrepareSolid (PixmapPtr ,int ,Pixel ,Pixel );void NV50EXASolid (PixmapPtr ,int ,int ,int ,int );void NV50EXADoneSolid (PixmapPtr );
src/nv_type.h +3 -1
@@ -302,7 +302,8 @@ typedef struct _NVRec {uint8_t cur_head;ExaDriverPtr EXADriverPtr; -Bool exa_driver_pixmaps; +Bool exa_driver_pixmaps; +bool wfb_enabled;ScreenBlockHandlerProcPtr BlockHandler;CloseScreenProcPtr CloseScreen;/* Cursor */
@@ -473,6 +474,7 @@ struct nouveau_pixmap {struct nouveau_bo *bo;void *linear;unsigned size; +int tiling_mode; }; static inline struct nouveau_pixmap *
Signature · 1 line
1.6.2
From b872ab64a6581354a036434da5d53555d3628e66 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Fri, 13 Mar 2009 09:57:12 +0100
Subject: [PATCH 2/5] exa: smarter initial mapping of driver allocated pixmaps
- Use a software copy until the first accelerated op, then UTS it.
- The path back does not exist.
--- src/nouveau_exa.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++----- src/nv04_exa.c | 5 ++++ src/nv10_exa.c | 5 ++++ src/nv30_exa.c | 5 ++++ src/nv40_exa.c | 5 ++++ src/nv50_exa.c | 10 ++++++++ src/nv_proto.h | 1 + src/nv_type.h | 1 + 8 files changed, 89 insertions(+), 7 deletions(-)
src/nouveau_exa.c +57 -7
109 lines not on this page · raw message
src/nv04_exa.c +5 -0
@@ -83,6 +83,8 @@ NV04EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg)unsigned delta =nouveau_pixmap_offset (pPixmap);unsigned int fmt, pitch, color; +nouveau_exa_pixmap_prepare_for_accel (pPixmap); +WAIT_RING (chan,64 ); planemask |= ~0 << pPixmap->drawable.bitsPerPixel;
@@ -190,6 +192,9 @@ NV04EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int dx, int dy,unsigned dst_delta =nouveau_pixmap_offset (pDstPixmap);int fmt; +nouveau_exa_pixmap_prepare_for_accel (pSrcPixmap); +nouveau_exa_pixmap_prepare_for_accel (pDstPixmap); +WAIT_RING (chan,64 ); if (pSrcPixmap->drawable.bitsPerPixel !=
src/nv10_exa.c +5 -0
@@ -626,6 +626,11 @@ Bool NV10EXAPrepareComposite(int op,NVPtr pNv =NVPTR (pScrn);struct nouveau_channel *chan = pNv->chan; +nouveau_exa_pixmap_prepare_for_accel (pSrc); +if (pMask) +nouveau_exa_pixmap_prepare_for_accel (pMask); +nouveau_exa_pixmap_prepare_for_accel (pDst); +WAIT_RING (chan,128 );if (NV10Check_A8plusA8_Feasability (pSrcPicture,pMaskPicture,pDstPicture,op))
src/nv30_exa.c +5 -0
@@ -447,6 +447,11 @@ NV30EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV30EXA_FPID_PASS_COL0 ;NV30EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV30_GetPictOpRec (op);
src/nv40_exa.c +5 -0
@@ -406,6 +406,11 @@ NV40EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV40EXA_FPID_PASS_COL0 ;NV40EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV40_GetPictOpRec (op);
src/nv50_exa.c +10 -0
@@ -250,6 +250,8 @@ NV50EXAPrepareSolid(PixmapPtr pdpix, int alu, Pixel planemask, Pixel fg)NV50EXA_LOCALS (pdpix);uint32_t fmt; +nouveau_exa_pixmap_prepare_for_accel (pdpix); +WAIT_RING (chan,64 );if (!NV50EXA2DSurfaceFormat (pdpix, &fmt))
@@ -311,6 +313,9 @@ NV50EXAPrepareCopy(PixmapPtr pspix, PixmapPtr pdpix, int dx, int dy, {NV50EXA_LOCALS (pdpix); +nouveau_exa_pixmap_prepare_for_accel (pspix); +nouveau_exa_pixmap_prepare_for_accel (pdpix); +WAIT_RING (chan,64 );if (!NV50EXAAcquireSurface2D (pspix,1 ))
@@ -769,6 +774,11 @@ NV50EXAPrepareComposite(int op,NV50EXA_LOCALS (pspix);const unsigned shd_flags =NOUVEAU_BO_VRAM |NOUVEAU_BO_RD ; +nouveau_exa_pixmap_prepare_for_accel (pspix); +if (pmpix) +nouveau_exa_pixmap_prepare_for_accel (pmpix); +nouveau_exa_pixmap_prepare_for_accel (pdpix); +WAIT_RING (chan,128 );BEGIN_RING (chan, eng2d,0x0110 ,1 );OUT_RING (chan,0 );
src/nv_proto.h +1 -0
@@ -64,6 +64,7 @@ void NVTakedownDma(ScrnInfoPtr pScrn);Bool nouveau_exa_init (ScreenPtr pScreen);Bool nouveau_exa_pixmap_is_onscreen (PixmapPtr pPixmap);bool nouveau_exa_pixmap_is_tiled (PixmapPtr ppix); +void nouveau_exa_pixmap_prepare_for_accel (PixmapPtr ppix);void nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead,WriteMemoryProcPtr *pWrite,DrawablePtr pDraw);
src/nv_type.h +1 -0
@@ -475,6 +475,7 @@ struct nouveau_pixmap {void *linear;unsigned size;int tiling_mode; +bool dirty; }; static inline struct nouveau_pixmap *
Signature · 1 line
1.6.2
From 3e3977ac1f907fbfca806246cec5fe68a07e1bc7 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Sat, 14 Mar 2009 18:07:31 +0100
Subject: [PATCH 3/5] nv50: support NV9X hw with wfb
--- src/nouveau_exa.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 64 insertions(+), 4 deletions(-)
src/nouveau_exa.c +64 -4
117 lines not on this page · raw message
Signature · 1 line
1.6.2
From b0ec6d716c61f9c26c59e585c8cbf796d1bd3143 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Sat, 14 Mar 2009 19:38:09 +0100
Subject: [PATCH 4/5] exa: don't put cpp == 0 pixmaps in vram
--- src/nouveau_exa.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
src/nouveau_exa.c +5 -1
@@ -358,9 +358,13 @@ nouveau_exa_modify_pixmap_header(PixmapPtr ppix, int width, int height,if (!nvpix->bo && nvpix->size) {uint32_t cpp = ppix->drawable.bitsPerPixel >>3 ; -uint32_t flags =NOUVEAU_BO_VRAM ; +uint32_t flags =0 ;int ret; +/* Let's not waste vram on useless pixmaps. */ +if (cpp) + flags |=NOUVEAU_BO_VRAM ; +if (pNv->Architecture >=NV_ARCH_50 && cpp) {uint32_t ah;if (height >47 ) {
Signature · 1 line
1.6.2
From f30dabe7118e1bd4459c5c07c16ae83470101cfb Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Sat, 14 Mar 2009 23:26:46 +0100
Subject: [PATCH 5/5] xv: some fixes
--- src/nouveau_xv.c | 24 +++++++++++++----------- src/nv50_xv.c | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-)
src/nouveau_xv.c +13 -11
@@ -718,10 +718,8 @@ NV_calculate_pitches_and_mem_size(NVPtr pNv, int action_flags, int *srcPitch, {int tmp; -if (pNv->Architecture >=NV_ARCH_50 ) { - npixels = (npixels +7 ) & ~7 ; - nlines = (nlines +7 ) & ~7 ; - } +if (pNv->Architecture >=NV_ARCH_50 ) + nlines = (nlines +3 ) & ~3 ;if (action_flags &IS_YV12 ) { *srcPitch = (width +3 ) & ~3 ;/* of luma */
@@ -1252,13 +1250,17 @@ CPU_copy:exaMoveInPixmap (ppix);/* check if it made it offscreen */ -#if NOUVEAU_EXA_PIXMAPS -if (!pNv->EXADriverPtr->PixmapIsOffscreen (ppix)) -#else - if (exaGetPixmapOffset(ppix) >= pNv->EXADriverPtr->memorySize) -#endif -/* we lost, insufficient space probably */ -return BadAlloc; +if (pNv->EXADriverPtr->PixmapIsOffscreen) { +if (!pNv->EXADriverPtr->PixmapIsOffscreen (ppix)) { +/* we lost, insufficient space probably */ +return BadAlloc; + } + }else { +if (exaGetPixmapOffset (ppix) >= pNv->EXADriverPtr->memorySize) { +/* we lost, insufficient space probably */ +return BadAlloc; + } + }ExaOffscreenMarkUsed (ppix);
src/nv50_xv.c +1 -1
@@ -76,7 +76,7 @@ nv50_xv_state_emit(PixmapPtr ppix, int id, struct nouveau_bo *src,case 24 :OUT_RING (chan,NV50TCL_RT_FORMAT_24BPP );break ;case 16 :OUT_RING (chan,NV50TCL_RT_FORMAT_16BPP );break ; } -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,0 );BEGIN_RING (chan, tesla,NV50TCL_RT_HORIZ (0 ),2 );OUT_RING (chan, ppix->drawable.width);
Signature · 1 line
1.6.2
src/nouveau_exa.c +388 -15
483 lines not on this page · raw message
src/nouveau_xv.c +13 -11
@@ -718,10 +718,8 @@ NV_calculate_pitches_and_mem_size(NVPtr pNv, int action_flags, int *srcPitch, {int tmp; -if (pNv->Architecture >=NV_ARCH_50 ) { - npixels = (npixels +7 ) & ~7 ; - nlines = (nlines +7 ) & ~7 ; - } +if (pNv->Architecture >=NV_ARCH_50 ) + nlines = (nlines +3 ) & ~3 ;if (action_flags &IS_YV12 ) { *srcPitch = (width +3 ) & ~3 ;/* of luma */
@@ -1252,13 +1250,17 @@ CPU_copy:exaMoveInPixmap (ppix);/* check if it made it offscreen */ -#if NOUVEAU_EXA_PIXMAPS -if (!pNv->EXADriverPtr->PixmapIsOffscreen (ppix)) -#else - if (exaGetPixmapOffset(ppix) >= pNv->EXADriverPtr->memorySize) -#endif -/* we lost, insufficient space probably */ -return BadAlloc; +if (pNv->EXADriverPtr->PixmapIsOffscreen) { +if (!pNv->EXADriverPtr->PixmapIsOffscreen (ppix)) { +/* we lost, insufficient space probably */ +return BadAlloc; + } + }else { +if (exaGetPixmapOffset (ppix) >= pNv->EXADriverPtr->memorySize) { +/* we lost, insufficient space probably */ +return BadAlloc; + } + }ExaOffscreenMarkUsed (ppix);
src/nv04_exa.c +5 -0
@@ -83,6 +83,8 @@ NV04EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg)unsigned delta =nouveau_pixmap_offset (pPixmap);unsigned int fmt, pitch, color; +nouveau_exa_pixmap_prepare_for_accel (pPixmap); +WAIT_RING (chan,64 ); planemask |= ~0 << pPixmap->drawable.bitsPerPixel;
@@ -190,6 +192,9 @@ NV04EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int dx, int dy,unsigned dst_delta =nouveau_pixmap_offset (pDstPixmap);int fmt; +nouveau_exa_pixmap_prepare_for_accel (pSrcPixmap); +nouveau_exa_pixmap_prepare_for_accel (pDstPixmap); +WAIT_RING (chan,64 ); if (pSrcPixmap->drawable.bitsPerPixel !=
src/nv10_exa.c +5 -0
@@ -626,6 +626,11 @@ Bool NV10EXAPrepareComposite(int op,NVPtr pNv =NVPTR (pScrn);struct nouveau_channel *chan = pNv->chan; +nouveau_exa_pixmap_prepare_for_accel (pSrc); +if (pMask) +nouveau_exa_pixmap_prepare_for_accel (pMask); +nouveau_exa_pixmap_prepare_for_accel (pDst); +WAIT_RING (chan,128 );if (NV10Check_A8plusA8_Feasability (pSrcPicture,pMaskPicture,pDstPicture,op))
src/nv30_exa.c +5 -0
@@ -447,6 +447,11 @@ NV30EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV30EXA_FPID_PASS_COL0 ;NV30EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV30_GetPictOpRec (op);
src/nv40_exa.c +5 -0
@@ -406,6 +406,11 @@ NV40EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV40EXA_FPID_PASS_COL0 ;NV40EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV40_GetPictOpRec (op);
src/nv50_exa.c +38 -3
83 lines not on this page · raw message
src/nv50_xv.c +1 -1
@@ -76,7 +76,7 @@ nv50_xv_state_emit(PixmapPtr ppix, int id, struct nouveau_bo *src,case 24 :OUT_RING (chan,NV50TCL_RT_FORMAT_24BPP );break ;case 16 :OUT_RING (chan,NV50TCL_RT_FORMAT_16BPP );break ; } -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,0 );BEGIN_RING (chan, tesla,NV50TCL_RT_HORIZ (0 ),2 );OUT_RING (chan, ppix->drawable.width);
src/nv_driver.c +44 -8
83 lines not on this page · raw message
src/nv_proto.h +7 -0
@@ -64,6 +64,12 @@ void NVTakedownDma(ScrnInfoPtr pScrn);Bool nouveau_exa_init (ScreenPtr pScreen);Bool nouveau_exa_pixmap_is_onscreen (PixmapPtr pPixmap);bool nouveau_exa_pixmap_is_tiled (PixmapPtr ppix); +void nouveau_exa_pixmap_prepare_for_accel (PixmapPtr ppix); +void nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead, +WriteMemoryProcPtr *pWrite, +DrawablePtr pDraw); +void nouveau_exa_wfb_finish_wrap (DrawablePtr pDraw); +void nouveau_exa_wfb_init ();/* in nv_hw.c */ void NVCalcStateExt (ScrnInfoPtr ,struct _riva_hw_state *,int ,int ,int ,int ,int ,int );
@@ -220,6 +226,7 @@ int NV40SetTexturePortAttribute(ScrnInfoPtr, Atom, INT32, pointer);Bool NVAccelInitNV50TCL (ScrnInfoPtr pScrn);/* in nv50_exa.c */ +uint32_t nv50_exa_get_tile_mode (PixmapPtr ppix);Bool NV50EXAPrepareSolid (PixmapPtr ,int ,Pixel ,Pixel );void NV50EXASolid (PixmapPtr ,int ,int ,int ,int );void NV50EXADoneSolid (PixmapPtr );
src/nv_type.h +4 -1
@@ -302,7 +302,8 @@ typedef struct _NVRec {uint8_t cur_head;ExaDriverPtr EXADriverPtr; -Bool exa_driver_pixmaps; +Bool exa_driver_pixmaps; +bool wfb_enabled;ScreenBlockHandlerProcPtr BlockHandler;CloseScreenProcPtr CloseScreen;/* Cursor */
@@ -473,6 +474,8 @@ struct nouveau_pixmap {struct nouveau_bo *bo;void *linear;unsigned size; +int tiling_mode; +bool dirty; }; static inline struct nouveau_pixmap *
_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 6d4bc9fc0903141902p7146199rc7c010edfacb69f8-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
This time with NV9X properly fixed, and the suspicion based on one sample that 0xAX hw doesn't have this strange rearranging.
Now it's (performance) regression hunting time.
Maarten.
From da6e7befc63fb29085611d5df1c739d5a87be5f4 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Sat, 7 Mar 2009 23:49:19 +0100
Subject: [PATCH 1/5] nv50: implement wfb
- Only for sufficiently new xserver's and exa_driver_pixmaps.
--- src/nouveau_exa.c | 282 +++++++++++++++++++++++++++++++++++++++++++++++++++-- src/nv50_exa.c | 31 +++++- src/nv_driver.c | 52 ++++++++-- src/nv_proto.h | 6 + src/nv_type.h | 4 +- 5 files changed, 353 insertions(+), 22 deletions(-)
src/nouveau_exa.c +272 -10
@@ -89,7 +89,7 @@ NVAccelDownloadM2MF(PixmapPtr pspix, int x, int y, int w, int h,if (!linear) {BEGIN_RING (chan, m2mf,0x0200 ,7 );OUT_RING (chan,0 ); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (pspix));OUT_RING (chan, pspix->drawable.width * cpp);OUT_RING (chan, pspix->drawable.height);OUT_RING (chan,1 );
@@ -210,7 +210,7 @@ NVAccelUploadM2MF(PixmapPtr pdpix, int x, int y, int w, int h,if (!linear) {BEGIN_RING (chan, m2mf,0x021c ,7 );OUT_RING (chan,0 ); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (pdpix));OUT_RING (chan, pdpix->drawable.width * cpp);OUT_RING (chan, pdpix->drawable.height);OUT_RING (chan,1 );
@@ -259,7 +259,11 @@ nouveau_exa_mark_sync(ScreenPtr pScreen)static void nouveau_exa_wait_marker (ScreenPtr pScreen,int marker) { -NVSync (xf86Screens[pScreen->myNum]); +ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; +NVPtr pNv =NVPTR (pScrn); + +if (!pNv->exa_driver_pixmaps) +NVSync (xf86Screens[pScreen->myNum]); } static Bool
@@ -351,17 +355,32 @@ nouveau_exa_modify_pixmap_header(PixmapPtr ppix, int width, int height,if (!nvpix->bo && nvpix->size) {uint32_t cpp = ppix->drawable.bitsPerPixel >>3 ; -/* At some point we should just keep 1bpp pixmaps in sysram */ uint32_t flags =NOUVEAU_BO_VRAM ;int ret;if (pNv->Architecture >=NV_ARCH_50 && cpp) { -uint32_t aw = (width +7 ) & ~7 ; -uint32_t ah = (height +7 ) & ~7 ; +uint32_t ah; +if (height >47 ) { + ah = (height +63 ) & ~63 ; + nvpix->tiling_mode =5 ; + }else if (height >23 ) { + ah = (height +31 ) & ~31 ; + nvpix->tiling_mode =4 ; + }else if (height >11 ) { + ah = (height +15 ) & ~15 ; + nvpix->tiling_mode =3 ; + }else if (height >5 ) { + ah = (height +7 ) & ~7 ; + nvpix->tiling_mode =2 ; + }else { + ah = (height +3 ) & ~3 ; + nvpix->tiling_mode =1 ; + } flags |=NOUVEAU_BO_TILED ; - devkind = ((aw * cpp) +63 ) & ~63 ; +/* This allignment is very important. */ + devkind = (width * cpp +63 ) & ~63 ; nvpix->size = devkind * ah; }
@@ -390,8 +409,11 @@ nouveau_exa_pixmap_is_tiled(PixmapPtr ppix)NVPtr pNv =NVPTR (pScrn);if (pNv->exa_driver_pixmaps) { -if (!nouveau_pixmap_bo (ppix)->tiled) +if (!nouveau_pixmap_bo (ppix)) +return false; +if (nouveau_pixmap_bo (ppix)->tiled ==0 )return false; +return true; }else if (pNv->Architecture <NV_ARCH_50 ||exaGetPixmapOffset (ppix) < pNv->EXADriverPtr->offScreenBase)
@@ -403,10 +425,12 @@ nouveau_exa_pixmap_is_tiled(PixmapPtr ppix)static void *nouveau_exa_pixmap_map (PixmapPtr ppix) { +ScrnInfoPtr pScrn = xf86Screens[ppix->drawable.pScreen->myNum]; +NVPtr pNv =NVPTR (pScrn);struct nouveau_bo *bo =nouveau_pixmap_bo (ppix);unsigned delta =nouveau_pixmap_offset (ppix); -if (bo->tiled) { +if (!pNv->wfb_enabled && bo->tiled) {struct nouveau_pixmap *nvpix =nouveau_pixmap (ppix); nvpix->map_refcount++;
@@ -430,9 +454,11 @@ nouveau_exa_pixmap_map(PixmapPtr ppix)static void nouveau_exa_pixmap_unmap (PixmapPtr ppix) { +ScrnInfoPtr pScrn = xf86Screens[ppix->drawable.pScreen->myNum]; +NVPtr pNv =NVPTR (pScrn);struct nouveau_bo *bo =nouveau_pixmap_bo (ppix); -if (bo->tiled) { +if (!pNv->wfb_enabled && bo->tiled) {struct nouveau_pixmap *nvpix =nouveau_pixmap (ppix);if (--nvpix->map_refcount)
@@ -682,3 +708,239 @@ nouveau_exa_init(ScreenPtr pScreen) pNv->EXADriverPtr = exa;return TRUE; } + +/* WFB functions. */ + +static inline FbBits +nouveau_exa_wfb_read_memory_linear (const void *src,int size) +{ +FbBits bits =0 ; + +memcpy (&bits, src, size); + +return bits; +} + +static inline void +nouveau_exa_wfb_write_memory_linear (void *dst,FbBits value,int size) +{ +memcpy (dst, &value, size); +} + +#define LINEAR_PITCH (pPixmap->devKind) + +/* Wfb related data. */ +static struct { +PixmapPtr ppix; +bool used; +bool tiled; +unsigned long start; +unsigned long end; +uint64_t multiply_factor; +uint8_t cpp; +unsigned int tile_height; +unsigned int num_tiles_width; +} wfb_pixmaps[6 ]; + +/* height: empty, 2, 4, 8, 16, 32, 64 */ +const unsigned int num_tiles[] = {0 ,0 ,4 ,2 ,1 ,1 ,1 }; +const unsigned int tile_pitch[] = {0 ,3 ,5 ,6 ,6 ,6 ,6 }; +const unsigned int mask_height_inv[] = {~0 , ~1 , ~3 , ~7 , ~15 , ~31 , ~63 }; +const unsigned int mask_pitch_inv[] = {~0 , ~7 , ~31 , ~63 , ~63 , ~63 , ~63 }; +const unsigned int mask_height[] = {0 ,1 ,3 ,7 ,15 ,31 ,63 }; +const unsigned int mask_pitch[] = {0 ,7 ,31 ,63 ,63 ,63 ,63 }; + +#define X_REMAINDER (x & mask_pitch[tile_height]) +#define Y_REMAINDER (y & mask_height[tile_height]) + +/* tile_height and tile_pitch are expressed in powers of two */ +static inline unsigned int +nouveau_exa_wfb_recurse_offset (unsigned int offset,unsigned int tile_height, +unsigned int x,unsigned int y,unsigned int num_tiles_width) +{ + offset += (((x & mask_pitch_inv[tile_height]) >> tile_pitch[tile_height]) + (((y & mask_height_inv[tile_height]) >> tile_height) * num_tiles_width)) * (1 << (tile_height + tile_pitch[tile_height])); + +if (tile_height >1 ) + offset =nouveau_exa_wfb_recurse_offset (offset, tile_height -1 ,X_REMAINDER ,Y_REMAINDER , num_tiles[tile_height]); +else + offset += (Y_REMAINDER * (1 << tile_pitch[tile_height])) +X_REMAINDER ; + +return offset; +} + +/* Note, we can only expose one read and write function, the linear versions are for internal consumption. */ +static FbBits +nouveau_exa_wfb_read_memory (const void *src,int size) +{ +int i; +uint64_t line_x, line_y; +unsigned long offset = (unsigned long ) src, subpixel_offset; +PixmapPtr pPixmap =NULL ; +FbBits bits =0 ; +void *new_src; + +/* Find the right pixmap. */ +for (i =0 ; i <6 ; i++) +if (offset >= wfb_pixmaps[i].start && offset < wfb_pixmaps[i].end) { + pPixmap = wfb_pixmaps[i].ppix; +break ; + } + +if (!pPixmap || !wfb_pixmaps[i].tiled) +return nouveau_exa_wfb_read_memory_linear (src, size); + +/* Now comes the decoding. */ + offset -= (unsigned long ) pPixmap->devPrivate.ptr; +/* Assuming dword alligned offsets. */ + subpixel_offset = offset & (wfb_pixmaps[i].cpp -1 ); + offset &= ~(wfb_pixmaps[i].cpp -1 ); + +/* Determine the coordinate first. */ +/* Division is too expensive for large numbers, so we precalculate a multiplication factor. */ + line_y = (offset * wfb_pixmaps[i].multiply_factor) >>32 ; + line_x = offset - line_y *LINEAR_PITCH ; + + new_src = pPixmap->devPrivate.ptr + +nouveau_exa_wfb_recurse_offset (0 , wfb_pixmaps[i].tile_height, line_x, line_y, wfb_pixmaps[i].num_tiles_width) + + subpixel_offset; + +memcpy (&bits, new_src, size); + +return bits; +} + +static void +nouveau_exa_wfb_write_memory (void *dst,FbBits value,int size) +{ +int i; +uint64_t line_x, line_y; +unsigned long offset = (unsigned long ) dst, subpixel_offset; +PixmapPtr pPixmap =NULL ; +void *new_dst; + +/* Find the right pixmap. */ +for (i =0 ; i <6 ; i++) +if (offset >= wfb_pixmaps[i].start && offset < wfb_pixmaps[i].end) { + pPixmap = wfb_pixmaps[i].ppix; +break ; + } + +if (!pPixmap || !wfb_pixmaps[i].tiled) { +nouveau_exa_wfb_write_memory_linear (dst, value, size); +return ; + } + +/* Now comes the decoding. */ + offset -= (unsigned long ) pPixmap->devPrivate.ptr; +/* Assuming dword alligned offsets. */ + subpixel_offset = offset & (wfb_pixmaps[i].cpp -1 ); + offset &= ~(wfb_pixmaps[i].cpp -1 ); + +/* Determine the coordinate first. */ +/* Division is too expensive for large numbers, so we precalculate a multiplication factor. */ + line_y = (offset * wfb_pixmaps[i].multiply_factor) >>32 ; + line_x = offset - line_y *LINEAR_PITCH ; + + new_dst = pPixmap->devPrivate.ptr + +nouveau_exa_wfb_recurse_offset (0 , wfb_pixmaps[i].tile_height, line_x, line_y, wfb_pixmaps[i].num_tiles_width) + + subpixel_offset; + +memcpy (new_dst, &value, size); +} + +void +nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead, +WriteMemoryProcPtr *pWrite, +DrawablePtr pDraw) +{ +PixmapPtr pPixmap; +struct nouveau_pixmap *nvpix; + +if (!pRead || !pWrite) +return ; + + pPixmap =NVGetDrawablePixmap (pDraw); +if (!pPixmap) +return ; + + nvpix =nouveau_pixmap (pPixmap); + +int i; +for (i =0 ; i <6 ; i++) +if (!wfb_pixmaps[i].used) +break ; + +if (i ==6 ) { +ErrorF ("More than 6 wraps are setup, what the hell is going on?\n" ); + *pRead =NULL ; + *pWrite =NULL ; +return ; + } + +/* We will get a pointer, somewhere in the range of this pixmap. */ +/* Based on linear representation ofcource. */ + wfb_pixmaps[i].ppix = pPixmap; + wfb_pixmaps[i].start = (unsigned long ) pPixmap->devPrivate.ptr; +if (!nvpix || !nvpix->bo) + wfb_pixmaps[i].end = wfb_pixmaps[i].start; +else + wfb_pixmaps[i].end = wfb_pixmaps[i].start + nvpix->bo->size; + wfb_pixmaps[i].used = true; + wfb_pixmaps[i].tiled =nouveau_exa_pixmap_is_tiled (pPixmap); +/* Division is too expensive for large numbers, so we precalculate a multiplication factor. */ + wfb_pixmaps[i].multiply_factor = (0xFFFFFFFF /exaGetPixmapPitch (pPixmap)) +1 ; + wfb_pixmaps[i].cpp = (pPixmap->drawable.bitsPerPixel >>3 ); +if (!nvpix) { + wfb_pixmaps[i].tile_height =0 ; + wfb_pixmaps[i].num_tiles_width =0 ; + }else { + wfb_pixmaps[i].tile_height = nvpix->tiling_mode +1 ; + wfb_pixmaps[i].num_tiles_width =LINEAR_PITCH /(1 << tile_pitch[wfb_pixmaps[i].tile_height]); + } + + *pRead = nouveau_exa_wfb_read_memory; + *pWrite = nouveau_exa_wfb_write_memory; +} + +void +nouveau_exa_wfb_finish_wrap (DrawablePtr pDraw) +{ +PixmapPtr pPixmap; +int i; + + pPixmap =NVGetDrawablePixmap (pDraw); +if (!pPixmap) +return ; + +for (i =0 ; i <6 ; i++) +if (wfb_pixmaps[i].ppix == pPixmap) { + wfb_pixmaps[i].ppix =NULL ; + wfb_pixmaps[i].start =0 ; + wfb_pixmaps[i].end =0 ; + wfb_pixmaps[i].used = false; + wfb_pixmaps[i].tiled = false; + wfb_pixmaps[i].multiply_factor =0 ; + wfb_pixmaps[i].cpp =0 ; + wfb_pixmaps[i].tile_height =0 ; + wfb_pixmaps[i].num_tiles_width =0 ; +break ; + } +} + +void +nouveau_exa_wfb_init () +{ +int i; + +for (i =0 ; i <6 ; i++) { + wfb_pixmaps[i].ppix =NULL ; + wfb_pixmaps[i].start =0 ; + wfb_pixmaps[i].end =0 ; + wfb_pixmaps[i].used = false; + wfb_pixmaps[i].tiled = false; + wfb_pixmaps[i].multiply_factor =0 ; + wfb_pixmaps[i].cpp =0 ; + wfb_pixmaps[i].tile_height =0 ; + wfb_pixmaps[i].num_tiles_width =0 ; + } +}
src/nv50_exa.c +28 -3
@@ -72,6 +72,31 @@ NV50EXABlendOp[] = { /* Add */ { 0, 0, BF( ONE), BF( ONE) }, }; + +uint32_t +nv50_exa_get_tile_mode (PixmapPtr ppix) +{ +struct nouveau_pixmap *nvpix =nouveau_pixmap (ppix); + +if (!nvpix) +return 0x00 ; + +switch (nvpix->tiling_mode) { +case 1 :/* pitch 32, height 4 */ +return 0x00 ; +case 2 :/* pitch 64, height 8 */ +return 0x10 ; +case 3 :/* pitch 64, height 16 */ +return 0x20 ; +case 4 :/* pitch 64, height 32 */ +return 0x30 ; +case 5 :/* pitch 64, height 64 */ +return 0x40 ; +default : +return 0x00 ; + } +} +static Bool NV50EXA2DSurfaceFormat (PixmapPtr ppix,uint32_t *fmt) {
@@ -128,7 +153,7 @@ NV50EXAAcquireSurface2D(PixmapPtr ppix, int is_src)BEGIN_RING (chan, eng2d, mthd,5 );OUT_RING (chan, fmt);OUT_RING (chan,0 ); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,1 );OUT_RING (chan,0 ); }
@@ -457,7 +482,7 @@ NV50EXARenderTarget(PixmapPtr ppix, PicturePtr ppict)OUT_RELOCh (chan, bo, delta,NOUVEAU_BO_VRAM |NOUVEAU_BO_WR );OUT_RELOCl (chan, bo, delta,NOUVEAU_BO_VRAM |NOUVEAU_BO_WR );OUT_RING (chan, format); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,0x00000000 );BEGIN_RING (chan, tesla,NV50TCL_RT_HORIZ (0 ),2 );OUT_RING (chan, ppix->drawable.width);
@@ -577,7 +602,7 @@ NV50EXATexture(PixmapPtr ppix, PicturePtr ppict, unsigned unit)NOUVEAU_FALLBACK ("invalid picture format, this SHOULD NOT HAPPEN. Expect trouble.\n" ); }OUT_RELOCl (chan, bo, delta,NOUVEAU_BO_VRAM |NOUVEAU_BO_RD ); -OUT_RING (chan,0xd0005000 ); +OUT_RING (chan,0xd0005000 | (nv50_exa_get_tile_mode (ppix) <<18 ));OUT_RING (chan,0x00300000 );OUT_RING (chan, ppix->drawable.width);OUT_RING (chan, (1 <<NV50TIC_0_5_DEPTH_SHIFT ) | ppix->drawable.height);
src/nv_driver.c +44 -8
83 lines not on this page · raw message
src/nv_proto.h +6 -0
@@ -64,6 +64,11 @@ void NVTakedownDma(ScrnInfoPtr pScrn);Bool nouveau_exa_init (ScreenPtr pScreen);Bool nouveau_exa_pixmap_is_onscreen (PixmapPtr pPixmap);bool nouveau_exa_pixmap_is_tiled (PixmapPtr ppix); +void nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead, +WriteMemoryProcPtr *pWrite, +DrawablePtr pDraw); +void nouveau_exa_wfb_finish_wrap (DrawablePtr pDraw); +void nouveau_exa_wfb_init ();/* in nv_hw.c */ void NVCalcStateExt (ScrnInfoPtr ,struct _riva_hw_state *,int ,int ,int ,int ,int ,int );
@@ -220,6 +225,7 @@ int NV40SetTexturePortAttribute(ScrnInfoPtr, Atom, INT32, pointer);Bool NVAccelInitNV50TCL (ScrnInfoPtr pScrn);/* in nv50_exa.c */ +uint32_t nv50_exa_get_tile_mode (PixmapPtr ppix);Bool NV50EXAPrepareSolid (PixmapPtr ,int ,Pixel ,Pixel );void NV50EXASolid (PixmapPtr ,int ,int ,int ,int );void NV50EXADoneSolid (PixmapPtr );
src/nv_type.h +3 -1
@@ -299,7 +299,8 @@ typedef struct _NVRec {uint8_t cur_head;ExaDriverPtr EXADriverPtr; -Bool exa_driver_pixmaps; +Bool exa_driver_pixmaps; +bool wfb_enabled;ScreenBlockHandlerProcPtr BlockHandler;CloseScreenProcPtr CloseScreen;/* Cursor */
@@ -471,6 +472,7 @@ struct nouveau_pixmap {void *linear;unsigned size;int map_refcount; +int tiling_mode; }; static inline struct nouveau_pixmap *
Signature · 1 line
1.6.2
From c34c45bce57d15058965b618f05885ba40b0964c Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Fri, 13 Mar 2009 09:57:12 +0100
Subject: [PATCH 2/5] exa: smarter initial mapping of driver allocated pixmaps
- Use a software copy until the first accelerated op, then UTS it.
- The path back does not exist.
--- src/nouveau_exa.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++----- src/nv04_exa.c | 5 ++++ src/nv10_exa.c | 5 ++++ src/nv30_exa.c | 5 ++++ src/nv40_exa.c | 5 ++++ src/nv50_exa.c | 10 ++++++++ src/nv_proto.h | 1 + src/nv_type.h | 1 + 8 files changed, 89 insertions(+), 7 deletions(-)
src/nouveau_exa.c +57 -7
113 lines not on this page · raw message
src/nv04_exa.c +5 -0
@@ -83,6 +83,8 @@ NV04EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg)unsigned delta =nouveau_pixmap_offset (pPixmap);unsigned int fmt, pitch, color; +nouveau_exa_pixmap_prepare_for_accel (pPixmap); +WAIT_RING (chan,64 ); planemask |= ~0 << pPixmap->drawable.bitsPerPixel;
@@ -190,6 +192,9 @@ NV04EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int dx, int dy,unsigned dst_delta =nouveau_pixmap_offset (pDstPixmap);int fmt; +nouveau_exa_pixmap_prepare_for_accel (pSrcPixmap); +nouveau_exa_pixmap_prepare_for_accel (pDstPixmap); +WAIT_RING (chan,64 ); if (pSrcPixmap->drawable.bitsPerPixel !=
src/nv10_exa.c +5 -0
@@ -626,6 +626,11 @@ Bool NV10EXAPrepareComposite(int op,NVPtr pNv =NVPTR (pScrn);struct nouveau_channel *chan = pNv->chan; +nouveau_exa_pixmap_prepare_for_accel (pSrc); +if (pMask) +nouveau_exa_pixmap_prepare_for_accel (pMask); +nouveau_exa_pixmap_prepare_for_accel (pDst); +WAIT_RING (chan,128 );if (NV10Check_A8plusA8_Feasability (pSrcPicture,pMaskPicture,pDstPicture,op))
src/nv30_exa.c +5 -0
@@ -447,6 +447,11 @@ NV30EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV30EXA_FPID_PASS_COL0 ;NV30EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV30_GetPictOpRec (op);
src/nv40_exa.c +5 -0
@@ -406,6 +406,11 @@ NV40EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV40EXA_FPID_PASS_COL0 ;NV40EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV40_GetPictOpRec (op);
src/nv50_exa.c +10 -0
@@ -250,6 +250,8 @@ NV50EXAPrepareSolid(PixmapPtr pdpix, int alu, Pixel planemask, Pixel fg)NV50EXA_LOCALS (pdpix);uint32_t fmt; +nouveau_exa_pixmap_prepare_for_accel (pdpix); +WAIT_RING (chan,64 );if (!NV50EXA2DSurfaceFormat (pdpix, &fmt))
@@ -311,6 +313,9 @@ NV50EXAPrepareCopy(PixmapPtr pspix, PixmapPtr pdpix, int dx, int dy, {NV50EXA_LOCALS (pdpix); +nouveau_exa_pixmap_prepare_for_accel (pspix); +nouveau_exa_pixmap_prepare_for_accel (pdpix); +WAIT_RING (chan,64 );if (!NV50EXAAcquireSurface2D (pspix,1 ))
@@ -769,6 +774,11 @@ NV50EXAPrepareComposite(int op,NV50EXA_LOCALS (pspix);const unsigned shd_flags =NOUVEAU_BO_VRAM |NOUVEAU_BO_RD ; +nouveau_exa_pixmap_prepare_for_accel (pspix); +if (pmpix) +nouveau_exa_pixmap_prepare_for_accel (pmpix); +nouveau_exa_pixmap_prepare_for_accel (pdpix); +WAIT_RING (chan,128 );BEGIN_RING (chan, eng2d,0x0110 ,1 );OUT_RING (chan,0 );
src/nv_proto.h +1 -0
@@ -64,6 +64,7 @@ void NVTakedownDma(ScrnInfoPtr pScrn);Bool nouveau_exa_init (ScreenPtr pScreen);Bool nouveau_exa_pixmap_is_onscreen (PixmapPtr pPixmap);bool nouveau_exa_pixmap_is_tiled (PixmapPtr ppix); +void nouveau_exa_pixmap_prepare_for_accel (PixmapPtr ppix);void nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead,WriteMemoryProcPtr *pWrite,DrawablePtr pDraw);
src/nv_type.h +1 -0
@@ -473,6 +473,7 @@ struct nouveau_pixmap {unsigned size;int map_refcount;int tiling_mode; +bool dirty; }; static inline struct nouveau_pixmap *
Signature · 1 line
1.6.2
From ca571dbb1e448c71ba371c3728f45ae77aea6009 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Sat, 14 Mar 2009 18:07:31 +0100
Subject: [PATCH 3/5] nv50: support NV9X hw with wfb
- NVAX hardware seems to have the NV5X and NV8X beheaviour (based on one sample).
--- src/nouveau_exa.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 46 insertions(+), 4 deletions(-)
src/nouveau_exa.c +46 -4
99 lines not on this page · raw message
Signature · 1 line
1.6.2
From 698145ec01e0a89324e38c6547404694b27c01a6 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Sat, 14 Mar 2009 19:38:09 +0100
Subject: [PATCH 4/5] exa: don't put cpp == 0 pixmaps in vram
--- src/nouveau_exa.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
src/nouveau_exa.c +5 -1
@@ -358,9 +358,13 @@ nouveau_exa_modify_pixmap_header(PixmapPtr ppix, int width, int height,if (!nvpix->bo && nvpix->size) {uint32_t cpp = ppix->drawable.bitsPerPixel >>3 ; -uint32_t flags =NOUVEAU_BO_VRAM ; +uint32_t flags =0 ;int ret; +/* Let's not waste vram on useless pixmaps. */ +if (cpp) + flags |=NOUVEAU_BO_VRAM ; +if (pNv->Architecture >=NV_ARCH_50 && cpp) {uint32_t ah;if (height >47 ) {
Signature · 1 line
1.6.2
From a01639070e6b31679a8de91b65a718aafe9a2ae3 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Sat, 14 Mar 2009 23:26:46 +0100
Subject: [PATCH 5/5] xv: some fixes
--- src/nouveau_xv.c | 24 +++++++++++++----------- src/nv50_xv.c | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-)
src/nouveau_xv.c +13 -11
@@ -718,10 +718,8 @@ NV_calculate_pitches_and_mem_size(NVPtr pNv, int action_flags, int *srcPitch, {int tmp; -if (pNv->Architecture >=NV_ARCH_50 ) { - npixels = (npixels +7 ) & ~7 ; - nlines = (nlines +7 ) & ~7 ; - } +if (pNv->Architecture >=NV_ARCH_50 ) + nlines = (nlines +3 ) & ~3 ;if (action_flags &IS_YV12 ) { *srcPitch = (width +3 ) & ~3 ;/* of luma */
@@ -1252,13 +1250,17 @@ CPU_copy:exaMoveInPixmap (ppix);/* check if it made it offscreen */ -#if NOUVEAU_EXA_PIXMAPS -if (!pNv->EXADriverPtr->PixmapIsOffscreen (ppix)) -#else - if (exaGetPixmapOffset(ppix) >= pNv->EXADriverPtr->memorySize) -#endif -/* we lost, insufficient space probably */ -return BadAlloc; +if (pNv->EXADriverPtr->PixmapIsOffscreen) { +if (!pNv->EXADriverPtr->PixmapIsOffscreen (ppix)) { +/* we lost, insufficient space probably */ +return BadAlloc; + } + }else { +if (exaGetPixmapOffset (ppix) >= pNv->EXADriverPtr->memorySize) { +/* we lost, insufficient space probably */ +return BadAlloc; + } + }ExaOffscreenMarkUsed (ppix);
src/nv50_xv.c +1 -1
@@ -76,7 +76,7 @@ nv50_xv_state_emit(PixmapPtr ppix, int id, struct nouveau_bo *src,case 24 :OUT_RING (chan,NV50TCL_RT_FORMAT_24BPP );break ;case 16 :OUT_RING (chan,NV50TCL_RT_FORMAT_16BPP );break ; } -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,0 );BEGIN_RING (chan, tesla,NV50TCL_RT_HORIZ (0 ),2 );OUT_RING (chan, ppix->drawable.width);
Signature · 1 line
1.6.2
src/nouveau_exa.c +373 -15
472 lines not on this page · raw message
src/nouveau_xv.c +13 -11
@@ -718,10 +718,8 @@ NV_calculate_pitches_and_mem_size(NVPtr pNv, int action_flags, int *srcPitch, {int tmp; -if (pNv->Architecture >=NV_ARCH_50 ) { - npixels = (npixels +7 ) & ~7 ; - nlines = (nlines +7 ) & ~7 ; - } +if (pNv->Architecture >=NV_ARCH_50 ) + nlines = (nlines +3 ) & ~3 ;if (action_flags &IS_YV12 ) { *srcPitch = (width +3 ) & ~3 ;/* of luma */
@@ -1252,13 +1250,17 @@ CPU_copy:exaMoveInPixmap (ppix);/* check if it made it offscreen */ -#if NOUVEAU_EXA_PIXMAPS -if (!pNv->EXADriverPtr->PixmapIsOffscreen (ppix)) -#else - if (exaGetPixmapOffset(ppix) >= pNv->EXADriverPtr->memorySize) -#endif -/* we lost, insufficient space probably */ -return BadAlloc; +if (pNv->EXADriverPtr->PixmapIsOffscreen) { +if (!pNv->EXADriverPtr->PixmapIsOffscreen (ppix)) { +/* we lost, insufficient space probably */ +return BadAlloc; + } + }else { +if (exaGetPixmapOffset (ppix) >= pNv->EXADriverPtr->memorySize) { +/* we lost, insufficient space probably */ +return BadAlloc; + } + }ExaOffscreenMarkUsed (ppix);
src/nv04_exa.c +5 -0
@@ -83,6 +83,8 @@ NV04EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg)unsigned delta =nouveau_pixmap_offset (pPixmap);unsigned int fmt, pitch, color; +nouveau_exa_pixmap_prepare_for_accel (pPixmap); +WAIT_RING (chan,64 ); planemask |= ~0 << pPixmap->drawable.bitsPerPixel;
@@ -190,6 +192,9 @@ NV04EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int dx, int dy,unsigned dst_delta =nouveau_pixmap_offset (pDstPixmap);int fmt; +nouveau_exa_pixmap_prepare_for_accel (pSrcPixmap); +nouveau_exa_pixmap_prepare_for_accel (pDstPixmap); +WAIT_RING (chan,64 ); if (pSrcPixmap->drawable.bitsPerPixel !=
src/nv10_exa.c +5 -0
@@ -626,6 +626,11 @@ Bool NV10EXAPrepareComposite(int op,NVPtr pNv =NVPTR (pScrn);struct nouveau_channel *chan = pNv->chan; +nouveau_exa_pixmap_prepare_for_accel (pSrc); +if (pMask) +nouveau_exa_pixmap_prepare_for_accel (pMask); +nouveau_exa_pixmap_prepare_for_accel (pDst); +WAIT_RING (chan,128 );if (NV10Check_A8plusA8_Feasability (pSrcPicture,pMaskPicture,pDstPicture,op))
src/nv30_exa.c +5 -0
@@ -447,6 +447,11 @@ NV30EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV30EXA_FPID_PASS_COL0 ;NV30EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV30_GetPictOpRec (op);
src/nv40_exa.c +5 -0
@@ -406,6 +406,11 @@ NV40EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV40EXA_FPID_PASS_COL0 ;NV40EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV40_GetPictOpRec (op);
src/nv50_exa.c +38 -3
83 lines not on this page · raw message
src/nv50_xv.c +1 -1
@@ -76,7 +76,7 @@ nv50_xv_state_emit(PixmapPtr ppix, int id, struct nouveau_bo *src,case 24 :OUT_RING (chan,NV50TCL_RT_FORMAT_24BPP );break ;case 16 :OUT_RING (chan,NV50TCL_RT_FORMAT_16BPP );break ; } -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,0 );BEGIN_RING (chan, tesla,NV50TCL_RT_HORIZ (0 ),2 );OUT_RING (chan, ppix->drawable.width);
src/nv_driver.c +44 -8
83 lines not on this page · raw message
src/nv_proto.h +7 -0
@@ -64,6 +64,12 @@ void NVTakedownDma(ScrnInfoPtr pScrn);Bool nouveau_exa_init (ScreenPtr pScreen);Bool nouveau_exa_pixmap_is_onscreen (PixmapPtr pPixmap);bool nouveau_exa_pixmap_is_tiled (PixmapPtr ppix); +void nouveau_exa_pixmap_prepare_for_accel (PixmapPtr ppix); +void nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead, +WriteMemoryProcPtr *pWrite, +DrawablePtr pDraw); +void nouveau_exa_wfb_finish_wrap (DrawablePtr pDraw); +void nouveau_exa_wfb_init ();/* in nv_hw.c */ void NVCalcStateExt (ScrnInfoPtr ,struct _riva_hw_state *,int ,int ,int ,int ,int ,int );
@@ -220,6 +226,7 @@ int NV40SetTexturePortAttribute(ScrnInfoPtr, Atom, INT32, pointer);Bool NVAccelInitNV50TCL (ScrnInfoPtr pScrn);/* in nv50_exa.c */ +uint32_t nv50_exa_get_tile_mode (PixmapPtr ppix);Bool NV50EXAPrepareSolid (PixmapPtr ,int ,Pixel ,Pixel );void NV50EXASolid (PixmapPtr ,int ,int ,int ,int );void NV50EXADoneSolid (PixmapPtr );
src/nv_type.h +4 -1
@@ -299,7 +299,8 @@ typedef struct _NVRec {uint8_t cur_head;ExaDriverPtr EXADriverPtr; -Bool exa_driver_pixmaps; +Bool exa_driver_pixmaps; +bool wfb_enabled;ScreenBlockHandlerProcPtr BlockHandler;CloseScreenProcPtr CloseScreen;/* Cursor */
@@ -471,6 +472,8 @@ struct nouveau_pixmap {void *linear;unsigned size;int map_refcount; +int tiling_mode; +bool dirty; }; static inline struct nouveau_pixmap *
_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 6d4bc9fc0903161454n228d83a6y35a1745d652b5198-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
These latest patches work quite nicely with 9600GT.
Quoted 13 lines · Maarten Maathuis
This time with NV9X properly fixed, and the suspicion based on one sample that 0xAX hw doesn't have this strange rearranging.
Now it's (performance) regression hunting time.
Maarten.
_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): aa85b9420903162309i7d5f22efn8f4188fac9edc187-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Updated with the NV84 memory layout.
Maarten.
From 5e0d117965c582ea64552c19383d69bc806b33f7 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Sat, 7 Mar 2009 23:49:19 +0100
Subject: [PATCH 1/6] nv50: implement wfb
- Only for sufficiently new xserver's and exa_driver_pixmaps.
--- src/nouveau_exa.c | 282 +++++++++++++++++++++++++++++++++++++++++++++++++++-- src/nv50_exa.c | 31 +++++- src/nv_driver.c | 52 ++++++++-- src/nv_proto.h | 6 + src/nv_type.h | 4 +- 5 files changed, 353 insertions(+), 22 deletions(-)
src/nouveau_exa.c +272 -10
@@ -89,7 +89,7 @@ NVAccelDownloadM2MF(PixmapPtr pspix, int x, int y, int w, int h,if (!linear) {BEGIN_RING (chan, m2mf,0x0200 ,7 );OUT_RING (chan,0 ); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (pspix));OUT_RING (chan, pspix->drawable.width * cpp);OUT_RING (chan, pspix->drawable.height);OUT_RING (chan,1 );
@@ -210,7 +210,7 @@ NVAccelUploadM2MF(PixmapPtr pdpix, int x, int y, int w, int h,if (!linear) {BEGIN_RING (chan, m2mf,0x021c ,7 );OUT_RING (chan,0 ); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (pdpix));OUT_RING (chan, pdpix->drawable.width * cpp);OUT_RING (chan, pdpix->drawable.height);OUT_RING (chan,1 );
@@ -259,7 +259,11 @@ nouveau_exa_mark_sync(ScreenPtr pScreen)static void nouveau_exa_wait_marker (ScreenPtr pScreen,int marker) { -NVSync (xf86Screens[pScreen->myNum]); +ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; +NVPtr pNv =NVPTR (pScrn); + +if (!pNv->exa_driver_pixmaps) +NVSync (xf86Screens[pScreen->myNum]); } static Bool
@@ -351,17 +355,32 @@ nouveau_exa_modify_pixmap_header(PixmapPtr ppix, int width, int height,if (!nvpix->bo && nvpix->size) {uint32_t cpp = ppix->drawable.bitsPerPixel >>3 ; -/* At some point we should just keep 1bpp pixmaps in sysram */ uint32_t flags =NOUVEAU_BO_VRAM ;int ret;if (pNv->Architecture >=NV_ARCH_50 && cpp) { -uint32_t aw = (width +7 ) & ~7 ; -uint32_t ah = (height +7 ) & ~7 ; +uint32_t ah; +if (height >47 ) { + ah = (height +63 ) & ~63 ; + nvpix->tiling_mode =5 ; + }else if (height >23 ) { + ah = (height +31 ) & ~31 ; + nvpix->tiling_mode =4 ; + }else if (height >11 ) { + ah = (height +15 ) & ~15 ; + nvpix->tiling_mode =3 ; + }else if (height >5 ) { + ah = (height +7 ) & ~7 ; + nvpix->tiling_mode =2 ; + }else { + ah = (height +3 ) & ~3 ; + nvpix->tiling_mode =1 ; + } flags |=NOUVEAU_BO_TILED ; - devkind = ((aw * cpp) +63 ) & ~63 ; +/* This allignment is very important. */ + devkind = (width * cpp +63 ) & ~63 ; nvpix->size = devkind * ah; }
@@ -390,8 +409,11 @@ nouveau_exa_pixmap_is_tiled(PixmapPtr ppix)NVPtr pNv =NVPTR (pScrn);if (pNv->exa_driver_pixmaps) { -if (!nouveau_pixmap_bo (ppix)->tiled) +if (!nouveau_pixmap_bo (ppix)) +return false; +if (nouveau_pixmap_bo (ppix)->tiled ==0 )return false; +return true; }else if (pNv->Architecture <NV_ARCH_50 ||exaGetPixmapOffset (ppix) < pNv->EXADriverPtr->offScreenBase)
@@ -403,10 +425,12 @@ nouveau_exa_pixmap_is_tiled(PixmapPtr ppix)static void *nouveau_exa_pixmap_map (PixmapPtr ppix) { +ScrnInfoPtr pScrn = xf86Screens[ppix->drawable.pScreen->myNum]; +NVPtr pNv =NVPTR (pScrn);struct nouveau_bo *bo =nouveau_pixmap_bo (ppix);unsigned delta =nouveau_pixmap_offset (ppix); -if (bo->tiled) { +if (!pNv->wfb_enabled && bo->tiled) {struct nouveau_pixmap *nvpix =nouveau_pixmap (ppix); nvpix->map_refcount++;
@@ -430,9 +454,11 @@ nouveau_exa_pixmap_map(PixmapPtr ppix)static void nouveau_exa_pixmap_unmap (PixmapPtr ppix) { +ScrnInfoPtr pScrn = xf86Screens[ppix->drawable.pScreen->myNum]; +NVPtr pNv =NVPTR (pScrn);struct nouveau_bo *bo =nouveau_pixmap_bo (ppix); -if (bo->tiled) { +if (!pNv->wfb_enabled && bo->tiled) {struct nouveau_pixmap *nvpix =nouveau_pixmap (ppix);if (--nvpix->map_refcount)
@@ -682,3 +708,239 @@ nouveau_exa_init(ScreenPtr pScreen) pNv->EXADriverPtr = exa;return TRUE; } + +/* WFB functions. */ + +static inline FbBits +nouveau_exa_wfb_read_memory_linear (const void *src,int size) +{ +FbBits bits =0 ; + +memcpy (&bits, src, size); + +return bits; +} + +static inline void +nouveau_exa_wfb_write_memory_linear (void *dst,FbBits value,int size) +{ +memcpy (dst, &value, size); +} + +#define LINEAR_PITCH (pPixmap->devKind) + +/* Wfb related data. */ +static struct { +PixmapPtr ppix; +bool used; +bool tiled; +unsigned long start; +unsigned long end; +uint64_t multiply_factor; +uint8_t cpp; +unsigned int tile_height; +unsigned int num_tiles_width; +} wfb_pixmaps[6 ]; + +/* height: empty, 2, 4, 8, 16, 32, 64 */ +const unsigned int num_tiles[] = {0 ,0 ,4 ,2 ,1 ,1 ,1 }; +const unsigned int tile_pitch[] = {0 ,3 ,5 ,6 ,6 ,6 ,6 }; +const unsigned int mask_height_inv[] = {~0 , ~1 , ~3 , ~7 , ~15 , ~31 , ~63 }; +const unsigned int mask_pitch_inv[] = {~0 , ~7 , ~31 , ~63 , ~63 , ~63 , ~63 }; +const unsigned int mask_height[] = {0 ,1 ,3 ,7 ,15 ,31 ,63 }; +const unsigned int mask_pitch[] = {0 ,7 ,31 ,63 ,63 ,63 ,63 }; + +#define X_REMAINDER (x & mask_pitch[tile_height]) +#define Y_REMAINDER (y & mask_height[tile_height]) + +/* tile_height and tile_pitch are expressed in powers of two */ +static inline unsigned int +nouveau_exa_wfb_recurse_offset (unsigned int offset,unsigned int tile_height, +unsigned int x,unsigned int y,unsigned int num_tiles_width) +{ + offset += (((x & mask_pitch_inv[tile_height]) >> tile_pitch[tile_height]) + (((y & mask_height_inv[tile_height]) >> tile_height) * num_tiles_width)) * (1 << (tile_height + tile_pitch[tile_height])); + +if (tile_height >1 ) + offset =nouveau_exa_wfb_recurse_offset (offset, tile_height -1 ,X_REMAINDER ,Y_REMAINDER , num_tiles[tile_height]); +else + offset += (Y_REMAINDER * (1 << tile_pitch[tile_height])) +X_REMAINDER ; + +return offset; +} + +/* Note, we can only expose one read and write function, the linear versions are for internal consumption. */ +static FbBits +nouveau_exa_wfb_read_memory (const void *src,int size) +{ +int i; +uint64_t line_x, line_y; +unsigned long offset = (unsigned long ) src, subpixel_offset; +PixmapPtr pPixmap =NULL ; +FbBits bits =0 ; +void *new_src; + +/* Find the right pixmap. */ +for (i =0 ; i <6 ; i++) +if (offset >= wfb_pixmaps[i].start && offset < wfb_pixmaps[i].end) { + pPixmap = wfb_pixmaps[i].ppix; +break ; + } + +if (!pPixmap || !wfb_pixmaps[i].tiled) +return nouveau_exa_wfb_read_memory_linear (src, size); + +/* Now comes the decoding. */ + offset -= (unsigned long ) pPixmap->devPrivate.ptr; +/* Assuming dword alligned offsets. */ + subpixel_offset = offset & (wfb_pixmaps[i].cpp -1 ); + offset &= ~(wfb_pixmaps[i].cpp -1 ); + +/* Determine the coordinate first. */ +/* Division is too expensive for large numbers, so we precalculate a multiplication factor. */ + line_y = (offset * wfb_pixmaps[i].multiply_factor) >>32 ; + line_x = offset - line_y *LINEAR_PITCH ; + + new_src = pPixmap->devPrivate.ptr + +nouveau_exa_wfb_recurse_offset (0 , wfb_pixmaps[i].tile_height, line_x, line_y, wfb_pixmaps[i].num_tiles_width) + + subpixel_offset; + +memcpy (&bits, new_src, size); + +return bits; +} + +static void +nouveau_exa_wfb_write_memory (void *dst,FbBits value,int size) +{ +int i; +uint64_t line_x, line_y; +unsigned long offset = (unsigned long ) dst, subpixel_offset; +PixmapPtr pPixmap =NULL ; +void *new_dst; + +/* Find the right pixmap. */ +for (i =0 ; i <6 ; i++) +if (offset >= wfb_pixmaps[i].start && offset < wfb_pixmaps[i].end) { + pPixmap = wfb_pixmaps[i].ppix; +break ; + } + +if (!pPixmap || !wfb_pixmaps[i].tiled) { +nouveau_exa_wfb_write_memory_linear (dst, value, size); +return ; + } + +/* Now comes the decoding. */ + offset -= (unsigned long ) pPixmap->devPrivate.ptr; +/* Assuming dword alligned offsets. */ + subpixel_offset = offset & (wfb_pixmaps[i].cpp -1 ); + offset &= ~(wfb_pixmaps[i].cpp -1 ); + +/* Determine the coordinate first. */ +/* Division is too expensive for large numbers, so we precalculate a multiplication factor. */ + line_y = (offset * wfb_pixmaps[i].multiply_factor) >>32 ; + line_x = offset - line_y *LINEAR_PITCH ; + + new_dst = pPixmap->devPrivate.ptr + +nouveau_exa_wfb_recurse_offset (0 , wfb_pixmaps[i].tile_height, line_x, line_y, wfb_pixmaps[i].num_tiles_width) + + subpixel_offset; + +memcpy (new_dst, &value, size); +} + +void +nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead, +WriteMemoryProcPtr *pWrite, +DrawablePtr pDraw) +{ +PixmapPtr pPixmap; +struct nouveau_pixmap *nvpix; + +if (!pRead || !pWrite) +return ; + + pPixmap =NVGetDrawablePixmap (pDraw); +if (!pPixmap) +return ; + + nvpix =nouveau_pixmap (pPixmap); + +int i; +for (i =0 ; i <6 ; i++) +if (!wfb_pixmaps[i].used) +break ; + +if (i ==6 ) { +ErrorF ("More than 6 wraps are setup, what the hell is going on?\n" ); + *pRead =NULL ; + *pWrite =NULL ; +return ; + } + +/* We will get a pointer, somewhere in the range of this pixmap. */ +/* Based on linear representation ofcource. */ + wfb_pixmaps[i].ppix = pPixmap; + wfb_pixmaps[i].start = (unsigned long ) pPixmap->devPrivate.ptr; +if (!nvpix || !nvpix->bo) + wfb_pixmaps[i].end = wfb_pixmaps[i].start; +else + wfb_pixmaps[i].end = wfb_pixmaps[i].start + nvpix->bo->size; + wfb_pixmaps[i].used = true; + wfb_pixmaps[i].tiled =nouveau_exa_pixmap_is_tiled (pPixmap); +/* Division is too expensive for large numbers, so we precalculate a multiplication factor. */ + wfb_pixmaps[i].multiply_factor = (0xFFFFFFFF /exaGetPixmapPitch (pPixmap)) +1 ; + wfb_pixmaps[i].cpp = (pPixmap->drawable.bitsPerPixel >>3 ); +if (!nvpix) { + wfb_pixmaps[i].tile_height =0 ; + wfb_pixmaps[i].num_tiles_width =0 ; + }else { + wfb_pixmaps[i].tile_height = nvpix->tiling_mode +1 ; + wfb_pixmaps[i].num_tiles_width =LINEAR_PITCH /(1 << tile_pitch[wfb_pixmaps[i].tile_height]); + } + + *pRead = nouveau_exa_wfb_read_memory; + *pWrite = nouveau_exa_wfb_write_memory; +} + +void +nouveau_exa_wfb_finish_wrap (DrawablePtr pDraw) +{ +PixmapPtr pPixmap; +int i; + + pPixmap =NVGetDrawablePixmap (pDraw); +if (!pPixmap) +return ; + +for (i =0 ; i <6 ; i++) +if (wfb_pixmaps[i].ppix == pPixmap) { + wfb_pixmaps[i].ppix =NULL ; + wfb_pixmaps[i].start =0 ; + wfb_pixmaps[i].end =0 ; + wfb_pixmaps[i].used = false; + wfb_pixmaps[i].tiled = false; + wfb_pixmaps[i].multiply_factor =0 ; + wfb_pixmaps[i].cpp =0 ; + wfb_pixmaps[i].tile_height =0 ; + wfb_pixmaps[i].num_tiles_width =0 ; +break ; + } +} + +void +nouveau_exa_wfb_init () +{ +int i; + +for (i =0 ; i <6 ; i++) { + wfb_pixmaps[i].ppix =NULL ; + wfb_pixmaps[i].start =0 ; + wfb_pixmaps[i].end =0 ; + wfb_pixmaps[i].used = false; + wfb_pixmaps[i].tiled = false; + wfb_pixmaps[i].multiply_factor =0 ; + wfb_pixmaps[i].cpp =0 ; + wfb_pixmaps[i].tile_height =0 ; + wfb_pixmaps[i].num_tiles_width =0 ; + } +}
src/nv50_exa.c +28 -3
@@ -72,6 +72,31 @@ NV50EXABlendOp[] = { /* Add */ { 0, 0, BF( ONE), BF( ONE) }, }; + +uint32_t +nv50_exa_get_tile_mode (PixmapPtr ppix) +{ +struct nouveau_pixmap *nvpix =nouveau_pixmap (ppix); + +if (!nvpix) +return 0x00 ; + +switch (nvpix->tiling_mode) { +case 1 :/* pitch 32, height 4 */ +return 0x00 ; +case 2 :/* pitch 64, height 8 */ +return 0x10 ; +case 3 :/* pitch 64, height 16 */ +return 0x20 ; +case 4 :/* pitch 64, height 32 */ +return 0x30 ; +case 5 :/* pitch 64, height 64 */ +return 0x40 ; +default : +return 0x00 ; + } +} +static Bool NV50EXA2DSurfaceFormat (PixmapPtr ppix,uint32_t *fmt) {
@@ -128,7 +153,7 @@ NV50EXAAcquireSurface2D(PixmapPtr ppix, int is_src)BEGIN_RING (chan, eng2d, mthd,5 );OUT_RING (chan, fmt);OUT_RING (chan,0 ); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,1 );OUT_RING (chan,0 ); }
@@ -457,7 +482,7 @@ NV50EXARenderTarget(PixmapPtr ppix, PicturePtr ppict)OUT_RELOCh (chan, bo, delta,NOUVEAU_BO_VRAM |NOUVEAU_BO_WR );OUT_RELOCl (chan, bo, delta,NOUVEAU_BO_VRAM |NOUVEAU_BO_WR );OUT_RING (chan, format); -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,0x00000000 );BEGIN_RING (chan, tesla,NV50TCL_RT_HORIZ (0 ),2 );OUT_RING (chan, ppix->drawable.width);
@@ -577,7 +602,7 @@ NV50EXATexture(PixmapPtr ppix, PicturePtr ppict, unsigned unit)NOUVEAU_FALLBACK ("invalid picture format, this SHOULD NOT HAPPEN. Expect trouble.\n" ); }OUT_RELOCl (chan, bo, delta,NOUVEAU_BO_VRAM |NOUVEAU_BO_RD ); -OUT_RING (chan,0xd0005000 ); +OUT_RING (chan,0xd0005000 | (nv50_exa_get_tile_mode (ppix) <<18 ));OUT_RING (chan,0x00300000 );OUT_RING (chan, ppix->drawable.width);OUT_RING (chan, (1 <<NV50TIC_0_5_DEPTH_SHIFT ) | ppix->drawable.height);
src/nv_driver.c +44 -8
83 lines not on this page · raw message
src/nv_proto.h +6 -0
@@ -68,6 +68,11 @@ void NVTakedownDma(ScrnInfoPtr pScrn);Bool nouveau_exa_init (ScreenPtr pScreen);Bool nouveau_exa_pixmap_is_onscreen (PixmapPtr pPixmap);bool nouveau_exa_pixmap_is_tiled (PixmapPtr ppix); +void nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead, +WriteMemoryProcPtr *pWrite, +DrawablePtr pDraw); +void nouveau_exa_wfb_finish_wrap (DrawablePtr pDraw); +void nouveau_exa_wfb_init ();/* in nv_hw.c */ void NVCalcStateExt (ScrnInfoPtr ,struct _riva_hw_state *,int ,int ,int ,int ,int ,int );
@@ -224,6 +229,7 @@ int NV40SetTexturePortAttribute(ScrnInfoPtr, Atom, INT32, pointer);Bool NVAccelInitNV50TCL (ScrnInfoPtr pScrn);/* in nv50_exa.c */ +uint32_t nv50_exa_get_tile_mode (PixmapPtr ppix);Bool NV50EXAPrepareSolid (PixmapPtr ,int ,Pixel ,Pixel );void NV50EXASolid (PixmapPtr ,int ,int ,int ,int );void NV50EXADoneSolid (PixmapPtr );
src/nv_type.h +3 -1
@@ -299,7 +299,8 @@ typedef struct _NVRec {uint8_t cur_head;ExaDriverPtr EXADriverPtr; -Bool exa_driver_pixmaps; +Bool exa_driver_pixmaps; +bool wfb_enabled;ScreenBlockHandlerProcPtr BlockHandler;CloseScreenProcPtr CloseScreen;/* Cursor */
@@ -472,6 +473,7 @@ struct nouveau_pixmap {void *linear;unsigned size;int map_refcount; +int tiling_mode; }; static inline struct nouveau_pixmap *
Signature · 1 line
1.6.2
From c358a7bcaea69804121da293aa690936589c5a83 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Fri, 13 Mar 2009 09:57:12 +0100
Subject: [PATCH 2/6] exa: smarter initial mapping of driver allocated pixmaps
- Use a software copy until the first accelerated op, then UTS it.
- The path back does not exist.
--- src/nouveau_exa.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++----- src/nv04_exa.c | 5 ++++ src/nv10_exa.c | 5 ++++ src/nv30_exa.c | 5 ++++ src/nv40_exa.c | 5 ++++ src/nv50_exa.c | 10 ++++++++ src/nv_proto.h | 1 + src/nv_type.h | 1 + 8 files changed, 89 insertions(+), 7 deletions(-)
src/nouveau_exa.c +57 -7
113 lines not on this page · raw message
src/nv04_exa.c +5 -0
@@ -83,6 +83,8 @@ NV04EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg)unsigned delta =nouveau_pixmap_offset (pPixmap);unsigned int fmt, pitch, color; +nouveau_exa_pixmap_prepare_for_accel (pPixmap); +WAIT_RING (chan,64 ); planemask |= ~0 << pPixmap->drawable.bitsPerPixel;
@@ -190,6 +192,9 @@ NV04EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int dx, int dy,unsigned dst_delta =nouveau_pixmap_offset (pDstPixmap);int fmt; +nouveau_exa_pixmap_prepare_for_accel (pSrcPixmap); +nouveau_exa_pixmap_prepare_for_accel (pDstPixmap); +WAIT_RING (chan,64 ); if (pSrcPixmap->drawable.bitsPerPixel !=
src/nv10_exa.c +5 -0
@@ -626,6 +626,11 @@ Bool NV10EXAPrepareComposite(int op,NVPtr pNv =NVPTR (pScrn);struct nouveau_channel *chan = pNv->chan; +nouveau_exa_pixmap_prepare_for_accel (pSrc); +if (pMask) +nouveau_exa_pixmap_prepare_for_accel (pMask); +nouveau_exa_pixmap_prepare_for_accel (pDst); +WAIT_RING (chan,128 );if (NV10Check_A8plusA8_Feasability (pSrcPicture,pMaskPicture,pDstPicture,op))
src/nv30_exa.c +5 -0
@@ -447,6 +447,11 @@ NV30EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV30EXA_FPID_PASS_COL0 ;NV30EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV30_GetPictOpRec (op);
src/nv40_exa.c +5 -0
@@ -406,6 +406,11 @@ NV40EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV40EXA_FPID_PASS_COL0 ;NV40EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV40_GetPictOpRec (op);
src/nv50_exa.c +10 -0
@@ -250,6 +250,8 @@ NV50EXAPrepareSolid(PixmapPtr pdpix, int alu, Pixel planemask, Pixel fg)NV50EXA_LOCALS (pdpix);uint32_t fmt; +nouveau_exa_pixmap_prepare_for_accel (pdpix); +WAIT_RING (chan,64 );if (!NV50EXA2DSurfaceFormat (pdpix, &fmt))
@@ -311,6 +313,9 @@ NV50EXAPrepareCopy(PixmapPtr pspix, PixmapPtr pdpix, int dx, int dy, {NV50EXA_LOCALS (pdpix); +nouveau_exa_pixmap_prepare_for_accel (pspix); +nouveau_exa_pixmap_prepare_for_accel (pdpix); +WAIT_RING (chan,64 );if (!NV50EXAAcquireSurface2D (pspix,1 ))
@@ -769,6 +774,11 @@ NV50EXAPrepareComposite(int op,NV50EXA_LOCALS (pspix);const unsigned shd_flags =NOUVEAU_BO_VRAM |NOUVEAU_BO_RD ; +nouveau_exa_pixmap_prepare_for_accel (pspix); +if (pmpix) +nouveau_exa_pixmap_prepare_for_accel (pmpix); +nouveau_exa_pixmap_prepare_for_accel (pdpix); +WAIT_RING (chan,128 );BEGIN_RING (chan, eng2d,0x0110 ,1 );OUT_RING (chan,0 );
src/nv_proto.h +1 -0
@@ -68,6 +68,7 @@ void NVTakedownDma(ScrnInfoPtr pScrn);Bool nouveau_exa_init (ScreenPtr pScreen);Bool nouveau_exa_pixmap_is_onscreen (PixmapPtr pPixmap);bool nouveau_exa_pixmap_is_tiled (PixmapPtr ppix); +void nouveau_exa_pixmap_prepare_for_accel (PixmapPtr ppix);void nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead,WriteMemoryProcPtr *pWrite,DrawablePtr pDraw);
src/nv_type.h +1 -0
@@ -474,6 +474,7 @@ struct nouveau_pixmap {unsigned size;int map_refcount;int tiling_mode; +bool dirty; }; static inline struct nouveau_pixmap *
Signature · 1 line
1.6.2
From e57b9ba6acc75bcaba348e6f6ace5dfa97f43018 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Sat, 14 Mar 2009 18:07:31 +0100
Subject: [PATCH 3/6] nv50: support NV9X hw with wfb
- NVAX hardware seems to have the NV5X and NV8X beheaviour (based on one sample).
--- src/nouveau_exa.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 46 insertions(+), 4 deletions(-)
src/nouveau_exa.c +46 -4
99 lines not on this page · raw message
Signature · 1 line
1.6.2
From 0d5de9d505d790f38d6d60d7e4c72a858619b707 Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Sat, 14 Mar 2009 19:38:09 +0100
Subject: [PATCH 4/6] exa: don't put cpp == 0 pixmaps in vram
--- src/nouveau_exa.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
src/nouveau_exa.c +5 -1
@@ -358,9 +358,13 @@ nouveau_exa_modify_pixmap_header(PixmapPtr ppix, int width, int height,if (!nvpix->bo && nvpix->size) {uint32_t cpp = ppix->drawable.bitsPerPixel >>3 ; -uint32_t flags =NOUVEAU_BO_VRAM ; +uint32_t flags =0 ;int ret; +/* Let's not waste vram on useless pixmaps. */ +if (cpp) + flags |=NOUVEAU_BO_VRAM ; +if (pNv->Architecture >=NV_ARCH_50 && cpp) {uint32_t ah;if (height >47 ) {
Signature · 1 line
1.6.2
From f7682ab4168d48819e7db7d54cca083c0b0eb7dc Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Sat, 14 Mar 2009 23:26:46 +0100
Subject: [PATCH 5/6] xv: some fixes
--- src/nouveau_xv.c | 24 +++++++++++++----------- src/nv50_xv.c | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-)
src/nouveau_xv.c +13 -11
@@ -718,10 +718,8 @@ NV_calculate_pitches_and_mem_size(NVPtr pNv, int action_flags, int *srcPitch, {int tmp; -if (pNv->Architecture >=NV_ARCH_50 ) { - npixels = (npixels +7 ) & ~7 ; - nlines = (nlines +7 ) & ~7 ; - } +if (pNv->Architecture >=NV_ARCH_50 ) + nlines = (nlines +3 ) & ~3 ;if (action_flags &IS_YV12 ) { *srcPitch = (width +3 ) & ~3 ;/* of luma */
@@ -1252,13 +1250,17 @@ CPU_copy:exaMoveInPixmap (ppix);/* check if it made it offscreen */ -#if NOUVEAU_EXA_PIXMAPS -if (!pNv->EXADriverPtr->PixmapIsOffscreen (ppix)) -#else - if (exaGetPixmapOffset(ppix) >= pNv->EXADriverPtr->memorySize) -#endif -/* we lost, insufficient space probably */ -return BadAlloc; +if (pNv->EXADriverPtr->PixmapIsOffscreen) { +if (!pNv->EXADriverPtr->PixmapIsOffscreen (ppix)) { +/* we lost, insufficient space probably */ +return BadAlloc; + } + }else { +if (exaGetPixmapOffset (ppix) >= pNv->EXADriverPtr->memorySize) { +/* we lost, insufficient space probably */ +return BadAlloc; + } + }ExaOffscreenMarkUsed (ppix);
src/nv50_xv.c +1 -1
@@ -76,7 +76,7 @@ nv50_xv_state_emit(PixmapPtr ppix, int id, struct nouveau_bo *src,case 24 :OUT_RING (chan,NV50TCL_RT_FORMAT_24BPP );break ;case 16 :OUT_RING (chan,NV50TCL_RT_FORMAT_16BPP );break ; } -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,0 );BEGIN_RING (chan, tesla,NV50TCL_RT_HORIZ (0 ),2 );OUT_RING (chan, ppix->drawable.width);
Signature · 1 line
1.6.2
From 56b5fb0aeb93b847c2fa3ec08e1e19af5e9b147e Mon Sep 17 00:00:00 2001
From: Maarten Maathuis <[email protected]>
Date: Wed, 18 Mar 2009 09:36:51 +0100
Subject: [PATCH 6/6] NV50: add NV84 wfb support
--- src/nouveau_exa.c | 55 +++++++++++++++++++++++++++++++++++++++------------- src/nv_driver.c | 2 +- src/nv_proto.h | 2 +- 3 files changed, 43 insertions(+), 16 deletions(-)
src/nouveau_exa.c +41 -14
100 lines not on this page · raw message
src/nv_driver.c +1 -1
@@ -1525,7 +1525,7 @@ NVPreInit(ScrnInfoPtr pScrn, int flags)#if XORG_VERSION_CURRENT >=XORG_VERSION_NUMERIC (1 ,6 ,99 ,0 ,0 )if (!pNv->NoAccel && pNv->exa_driver_pixmaps && pNv->Architecture ==NV_ARCH_50 ) { pNv->wfb_enabled = true; -nouveau_exa_wfb_init (); +nouveau_exa_wfb_init (pScrn);if (xf86LoadSubModule (pScrn,"wfb" ) ==NULL )NVPreInitFail ("\n" );
src/nv_proto.h +1 -1
@@ -73,7 +73,7 @@ void nouveau_exa_wfb_setup_wrap(ReadMemoryProcPtr *pRead,WriteMemoryProcPtr *pWrite, DrawablePtr pDraw);void nouveau_exa_wfb_finish_wrap (DrawablePtr pDraw); -void nouveau_exa_wfb_init (); +void nouveau_exa_wfb_init (ScrnInfoPtr pScrn);/* in nv_hw.c */ void NVCalcStateExt (ScrnInfoPtr ,struct _riva_hw_state *,int ,int ,int ,int ,int ,int );
Signature · 1 line
1.6.2
src/nouveau_exa.c +400 -15
499 lines not on this page · raw message
src/nouveau_xv.c +13 -11
@@ -718,10 +718,8 @@ NV_calculate_pitches_and_mem_size(NVPtr pNv, int action_flags, int *srcPitch, {int tmp; -if (pNv->Architecture >=NV_ARCH_50 ) { - npixels = (npixels +7 ) & ~7 ; - nlines = (nlines +7 ) & ~7 ; - } +if (pNv->Architecture >=NV_ARCH_50 ) + nlines = (nlines +3 ) & ~3 ;if (action_flags &IS_YV12 ) { *srcPitch = (width +3 ) & ~3 ;/* of luma */
@@ -1252,13 +1250,17 @@ CPU_copy:exaMoveInPixmap (ppix);/* check if it made it offscreen */ -#if NOUVEAU_EXA_PIXMAPS -if (!pNv->EXADriverPtr->PixmapIsOffscreen (ppix)) -#else - if (exaGetPixmapOffset(ppix) >= pNv->EXADriverPtr->memorySize) -#endif -/* we lost, insufficient space probably */ -return BadAlloc; +if (pNv->EXADriverPtr->PixmapIsOffscreen) { +if (!pNv->EXADriverPtr->PixmapIsOffscreen (ppix)) { +/* we lost, insufficient space probably */ +return BadAlloc; + } + }else { +if (exaGetPixmapOffset (ppix) >= pNv->EXADriverPtr->memorySize) { +/* we lost, insufficient space probably */ +return BadAlloc; + } + }ExaOffscreenMarkUsed (ppix);
src/nv04_exa.c +5 -0
@@ -83,6 +83,8 @@ NV04EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg)unsigned delta =nouveau_pixmap_offset (pPixmap);unsigned int fmt, pitch, color; +nouveau_exa_pixmap_prepare_for_accel (pPixmap); +WAIT_RING (chan,64 ); planemask |= ~0 << pPixmap->drawable.bitsPerPixel;
@@ -190,6 +192,9 @@ NV04EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int dx, int dy,unsigned dst_delta =nouveau_pixmap_offset (pDstPixmap);int fmt; +nouveau_exa_pixmap_prepare_for_accel (pSrcPixmap); +nouveau_exa_pixmap_prepare_for_accel (pDstPixmap); +WAIT_RING (chan,64 ); if (pSrcPixmap->drawable.bitsPerPixel !=
src/nv10_exa.c +5 -0
@@ -626,6 +626,11 @@ Bool NV10EXAPrepareComposite(int op,NVPtr pNv =NVPTR (pScrn);struct nouveau_channel *chan = pNv->chan; +nouveau_exa_pixmap_prepare_for_accel (pSrc); +if (pMask) +nouveau_exa_pixmap_prepare_for_accel (pMask); +nouveau_exa_pixmap_prepare_for_accel (pDst); +WAIT_RING (chan,128 );if (NV10Check_A8plusA8_Feasability (pSrcPicture,pMaskPicture,pDstPicture,op))
src/nv30_exa.c +5 -0
@@ -447,6 +447,11 @@ NV30EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV30EXA_FPID_PASS_COL0 ;NV30EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV30_GetPictOpRec (op);
src/nv40_exa.c +5 -0
@@ -406,6 +406,11 @@ NV40EXAPrepareComposite(int op, PicturePtr psPict,int fpid =NV40EXA_FPID_PASS_COL0 ;NV40EXA_STATE ; +nouveau_exa_pixmap_prepare_for_accel (psPix); +if (pmPix) +nouveau_exa_pixmap_prepare_for_accel (pmPix); +nouveau_exa_pixmap_prepare_for_accel (pdPix); +WAIT_RING (chan,128 ); blend =NV40_GetPictOpRec (op);
src/nv50_exa.c +38 -3
83 lines not on this page · raw message
src/nv50_xv.c +1 -1
@@ -76,7 +76,7 @@ nv50_xv_state_emit(PixmapPtr ppix, int id, struct nouveau_bo *src,case 24 :OUT_RING (chan,NV50TCL_RT_FORMAT_24BPP );break ;case 16 :OUT_RING (chan,NV50TCL_RT_FORMAT_16BPP );break ; } -OUT_RING (chan,0 ); +OUT_RING (chan,nv50_exa_get_tile_mode (ppix));OUT_RING (chan,0 );BEGIN_RING (chan, tesla,NV50TCL_RT_HORIZ (0 ),2 );OUT_RING (chan, ppix->drawable.width);
src/nv_driver.c +44 -8
83 lines not on this page · raw message
src/nv_proto.h +7 -0
@@ -68,6 +68,12 @@ void NVTakedownDma(ScrnInfoPtr pScrn);Bool nouveau_exa_init (ScreenPtr pScreen);Bool nouveau_exa_pixmap_is_onscreen (PixmapPtr pPixmap);bool nouveau_exa_pixmap_is_tiled (PixmapPtr ppix); +void nouveau_exa_pixmap_prepare_for_accel (PixmapPtr ppix); +void nouveau_exa_wfb_setup_wrap (ReadMemoryProcPtr *pRead, +WriteMemoryProcPtr *pWrite, +DrawablePtr pDraw); +void nouveau_exa_wfb_finish_wrap (DrawablePtr pDraw); +void nouveau_exa_wfb_init (ScrnInfoPtr pScrn);/* in nv_hw.c */ void NVCalcStateExt (ScrnInfoPtr ,struct _riva_hw_state *,int ,int ,int ,int ,int ,int );
@@ -224,6 +230,7 @@ int NV40SetTexturePortAttribute(ScrnInfoPtr, Atom, INT32, pointer);Bool NVAccelInitNV50TCL (ScrnInfoPtr pScrn);/* in nv50_exa.c */ +uint32_t nv50_exa_get_tile_mode (PixmapPtr ppix);Bool NV50EXAPrepareSolid (PixmapPtr ,int ,Pixel ,Pixel );void NV50EXASolid (PixmapPtr ,int ,int ,int ,int );void NV50EXADoneSolid (PixmapPtr );
src/nv_type.h +4 -1
@@ -299,7 +299,8 @@ typedef struct _NVRec {uint8_t cur_head;ExaDriverPtr EXADriverPtr; -Bool exa_driver_pixmaps; +Bool exa_driver_pixmaps; +bool wfb_enabled;ScreenBlockHandlerProcPtr BlockHandler;CloseScreenProcPtr CloseScreen;/* Cursor */
@@ -472,6 +473,8 @@ struct nouveau_pixmap {void *linear;unsigned size;int map_refcount; +int tiling_mode; +bool dirty; }; static inline struct nouveau_pixmap *
_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau