Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[xsrc/trunk]: xsrc/external/mit/xf86-video-nv/dist/src add mostly working EXA...



details:   https://anonhg.NetBSD.org/xsrc/rev/5fe39cb6c292
branches:  trunk
changeset: 9975:5fe39cb6c292
user:      macallan <macallan%NetBSD.org@localhost>
date:      Thu Jul 12 21:19:54 2018 +0000

description:
add mostly working EXA support
tested on a GeForce 6800 Ultra in a G5
still produces occasional artifacts but good enough to run a bunch of xterms
and gtk2 applications

diffstat:

 external/mit/xf86-video-nv/dist/src/nv_driver.c |   19 +-
 external/mit/xf86-video-nv/dist/src/nv_exa.c    |  334 ++++++++++++++++++++++++
 external/mit/xf86-video-nv/dist/src/nv_proto.h  |    5 +
 external/mit/xf86-video-nv/dist/src/nv_type.h   |    2 +
 external/mit/xf86-video-nv/dist/src/nv_xaa.c    |   28 +-
 5 files changed, 379 insertions(+), 9 deletions(-)

diffs (truncated from 478 to 300 lines):

diff -r 48fb8c6c6603 -r 5fe39cb6c292 external/mit/xf86-video-nv/dist/src/nv_driver.c
--- a/external/mit/xf86-video-nv/dist/src/nv_driver.c   Thu Jul 12 21:16:33 2018 +0000
+++ b/external/mit/xf86-video-nv/dist/src/nv_driver.c   Thu Jul 12 21:19:54 2018 +0000
@@ -2058,11 +2058,22 @@
 
     /* Load XAA if needed */
     if (!pNv->NoAccel) {
+       pNv->UseEXA = 1;
+#ifdef HAVE_XAA_H
        if (!xf86LoadSubModule(pScrn, "xaa")) {
-           xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Falling back to shadwwfb\n");
+           xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Falling back to shadowfb\n");
            pNv->NoAccel = 1;
            pNv->ShadowFB = 1;
+       } else
+           pNv->UseEXA = 0;
+#else
+       if (!xf86LoadSubModule(pScrn, "exa")) {
+           xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Falling back to shadowfb\n");
+           pNv->NoAccel = 1;
+           pNv->UseEXA = 0;
+           pNv->ShadowFB = 1;
        }
+#endif
     }
 
     /* Load ramdac if needed */
@@ -2591,6 +2602,7 @@
     if(offscreenHeight > 32767)
         offscreenHeight = 32767;
 
+#ifdef HAVE_XAA_H
     AvailFBArea.x1 = 0;
     AvailFBArea.y1 = 0;
     AvailFBArea.x2 = pScrn->displayWidth;
@@ -2599,7 +2611,10 @@
     
     if (!pNv->NoAccel)
        NVAccelInit(pScreen);
-    
+#endif
+    if ((!pNv->NoAccel) && (pNv->UseEXA == 1))
+       NvInitExa(pScreen);
+
     xf86SetBackingStore(pScreen);
     xf86SetSilkenMouse(pScreen);
 
diff -r 48fb8c6c6603 -r 5fe39cb6c292 external/mit/xf86-video-nv/dist/src/nv_exa.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/mit/xf86-video-nv/dist/src/nv_exa.c      Thu Jul 12 21:19:54 2018 +0000
@@ -0,0 +1,334 @@
+/*
+ * crude EXA support for geforce chips
+ *
+ * Copyright (C) 2018 Michael Lorenz
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * MICHAEL LORENZ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/* $NetBSD: nv_exa.c,v 1.1 2018/07/12 21:19:54 macallan Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "nv_include.h"
+#include "miline.h"
+#include "nv_dma.h"
+#include "exa.h"
+
+//#define DEBUG
+
+#ifdef DEBUG
+#define ENTER xf86Msg(X_ERROR, "%s\n", __func__)
+#define LEAVE xf86Msg(X_ERROR, "%s done\n", __func__)
+#else
+#define ENTER
+#define LEAVE
+#endif
+
+static void
+NvWaitMarker(ScreenPtr pScreen, int Marker)
+{
+       ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+       ENTER;
+       NVSync(pScrn);
+       LEAVE;
+}
+
+static Bool
+NvPrepareCopy
+(
+    PixmapPtr pSrcPixmap,
+    PixmapPtr pDstPixmap,
+    int       xdir,
+    int       ydir,
+    int       rop,
+    Pixel     planemask
+)
+{
+       ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
+       NVPtr pNv = NVPTR(pScrn);
+       int srcpitch, srcoff, dstpitch, dstoff;
+
+       ENTER;
+       if (pSrcPixmap->drawable.bitsPerPixel != 32)
+               xf86Msg(X_ERROR, "%s %d bpp\n", __func__, pSrcPixmap->drawable.bitsPerPixel);
+       planemask |= ~0 << pNv->CurrentLayout.depth;
+       NVSetRopSolid(pScrn, rop, planemask);
+       pNv->DMAKickoffCallback = NVDMAKickoffCallback;
+       dstpitch = exaGetPixmapPitch(pDstPixmap);
+       dstoff = exaGetPixmapOffset(pDstPixmap);
+       srcpitch = exaGetPixmapPitch(pSrcPixmap);
+       srcoff = exaGetPixmapOffset(pSrcPixmap);
+
+       NVDmaStart(pNv, SURFACE_PITCH, 3);
+       NVDmaNext (pNv, srcpitch | (dstpitch << 16));
+       NVDmaNext (pNv, srcoff);
+       NVDmaNext (pNv, dstoff);
+
+       LEAVE;
+       return TRUE;
+}
+
+static void
+NvCopy
+(
+    PixmapPtr pDstPixmap,
+    int       srcX,
+    int       srcY,
+    int       dstX,
+    int       dstY,
+    int       w,
+    int       h
+)
+{
+       ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
+       NVPtr pNv = NVPTR(pScrn);
+
+       NVDmaStart(pNv, BLIT_POINT_SRC, 3);
+       NVDmaNext (pNv, (srcY << 16) | srcX);
+       NVDmaNext (pNv, (dstY << 16) | dstX);
+       NVDmaNext (pNv, (h  << 16) | w);
+
+       if((w * h) >= 512)
+               NVDmaKickoff(pNv); 
+
+       LEAVE;
+}
+
+static void
+NvDoneCopy(PixmapPtr pDstPixmap)
+{
+    ENTER;
+    LEAVE;
+}
+
+static Bool
+NvPrepareSolid(
+    PixmapPtr pPixmap,
+    int rop,
+    Pixel planemask,
+    Pixel color)
+{
+       ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+       NVPtr pNv = NVPTR(pScrn);
+       int pitch, off;
+
+       ENTER;
+       if (pPixmap->drawable.bitsPerPixel != 32)
+               xf86Msg(X_ERROR, "%s %d bpp\n", __func__, pPixmap->drawable.bitsPerPixel);
+       planemask |= ~0 << pNv->CurrentLayout.depth;
+
+
+       pitch = exaGetPixmapPitch(pPixmap);
+       off = exaGetPixmapOffset(pPixmap);
+
+       NVDmaStart(pNv, SURFACE_PITCH, 3);
+       NVDmaNext (pNv, pitch | (pitch << 16));
+       NVDmaNext (pNv, off);
+       NVDmaNext (pNv, off);
+
+       NVSetRopSolid(pScrn, rop, planemask);
+       pNv->DMAKickoffCallback = NVDMAKickoffCallback;
+       NVDmaStart(pNv, RECT_SOLID_COLOR, 1);
+       NVDmaNext (pNv, color);
+
+       LEAVE;
+       return TRUE;
+}
+
+static void
+NvSolid(
+    PixmapPtr pPixmap,
+    int x1,
+    int y1,
+    int x2,
+    int y2)
+{
+       ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+       NVPtr pNv = NVPTR(pScrn);
+       int w = x2 - x1, h = y2 - y1;
+
+       ENTER;
+       NVDmaStart(pNv, RECT_SOLID_RECTS(0), 2);
+       NVDmaNext (pNv, (x1 << 16) | y1);
+       NVDmaNext (pNv, (w << 16) | h);
+
+       if((w * h) >= 512)
+               NVDmaKickoff(pNv);
+
+       LEAVE;
+}
+
+/*
+ * Memcpy-based UTS.
+ */
+static Bool
+NvUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h,
+    char *src, int src_pitch)
+{
+       ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum];
+       NVPtr pNv = NVPTR(pScrn);
+       unsigned char *dst = pNv->FbStart + exaGetPixmapOffset(pDst);
+       int dst_pitch = exaGetPixmapPitch(pDst);
+
+       int bpp    = pDst->drawable.bitsPerPixel;
+       int cpp    = (bpp + 7) >> 3;
+       int wBytes = w * cpp;
+
+       ENTER;
+       dst += (x * cpp) + (y * dst_pitch);
+
+       NVSync(pScrn);
+
+       while (h--) {
+               memcpy(dst, src, wBytes);
+               src += src_pitch;
+               dst += dst_pitch;
+       }
+       _NV_FENCE()
+       LEAVE;
+       return TRUE;
+}
+
+/*
+ * Memcpy-based DFS.
+ */
+static Bool
+NvDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h,
+    char *dst, int dst_pitch)
+{
+       ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum];
+       NVPtr pNv = NVPTR(pScrn);
+       unsigned char *src = pNv->FbStart + exaGetPixmapOffset(pSrc);
+       int src_pitch = exaGetPixmapPitch(pSrc);
+
+       int bpp    = pSrc->drawable.bitsPerPixel;
+       int cpp    = (bpp + 7) >> 3;
+       int wBytes = w * cpp;
+
+       ENTER;
+       src += (x * cpp) + (y * src_pitch);
+
+       NVSync(pScrn);
+
+       while (h--) {
+               memcpy(dst, src, wBytes);
+               src += src_pitch;
+               dst += dst_pitch;
+       }
+       LEAVE;
+       return TRUE;
+}
+
+#ifdef __arm__
+static Bool
+NvPrepareAccess(PixmapPtr pPix, int index)
+{
+       ScrnInfoPtr pScrn = xf86Screens[pPix->drawable.pScreen->myNum];
+       NVPtr pNv = NVPTR(pScrn);
+
+       IgsWaitReady(fPtr);
+       return TRUE;    



Home | Main Index | Thread Index | Old Index