VirtualBox

Changeset 20478 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jun 11, 2009 4:54:19 PM (16 years ago)
Author:
vboxsync
Message:

video hw accel: guest driver -> host framebuffer commands processing impl

Location:
trunk/src/VBox
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/Makefile.kmk

    r19464 r20478  
    5353        VBoxDisp.def \
    5454        VBoxDisp.rc
     55       
     56ifdef VBOX_WITH_VIDEOHWACCEL
     57VBoxDisp_SOURCES     += vhwa.c
     58endif
    5559VBoxDisp_LDFLAGS.x86   = /Entry:DrvEnableDriver@12
    5660VBoxDisp_LDFLAGS.amd64 = /Entry:DrvEnableDriver
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/dd.c

    r19515 r20478  
    4242
    4343#ifdef VBOX_WITH_VIDEOHWACCEL
    44 void getDDHALInfo(PPDEV pDev, DD_HALINFO* pHALInfo);
     44#define VBOXVHWA_CAP(_pdev, _cap) ((_pdev)->vhwaInfo.caps & (_cap))
     45static bool getDDHALInfo(PPDEV pDev, DD_HALINFO* pHALInfo);
    4546#endif
    4647
     
    9899    {
    99100#ifdef VBOX_WITH_VIDEOHWACCEL
     101        vboxVHWAInit();
     102
    100103        memset(pHalInfo, 0, sizeof(DD_HALINFO));
    101104        pHalInfo->dwSize    = sizeof(DD_HALINFO);
     105
     106        vboxVHWAInitHostInfo1(pDev);
    102107#else
    103108        memset(&pHalInfo->ddCaps, 0, sizeof(DDNTCORECAPS));
     
    149154
    150155#ifdef VBOX_WITH_VIDEOHWACCEL
    151         pHalInfo->vmiData.dwOverlayAlign = 4;
    152 
    153 #if 1
    154         /* teesting */
    155         pDev->bVHWAEnabled = TRUE;
    156 #endif
    157         if(pDev->bVHWAEnabled)
     156        if(pDev->vhwaInfo.bVHWAEnabled)
    158157        {
    159             getDDHALInfo(pDev, pHalInfo);
     158            pHalInfo->vmiData.dwOverlayAlign = 4;
     159
     160            pDev->vhwaInfo.bVHWAEnabled = getDDHALInfo(pDev, pHalInfo);
    160161        }
    161162#endif
     
    205206
    206207#ifdef VBOX_WITH_VIDEOHWACCEL
    207     if(pDev->bVHWAEnabled)
    208     {
    209         // TODO: filter out hw-unsupported fourccs
    210 #define FOURCC_YUV422  (MAKEFOURCC('Y','U','Y','2'))
    211 #define FOURCC_YUV411  (MAKEFOURCC('Y','4','1','1'))
    212 
    213         static DWORD fourCC[] =  { FOURCC_YUV422, FOURCC_YUV411 };  // The FourCC's we support
    214 
    215         *pdwNumFourCCCodes = sizeof( fourCC ) / sizeof( fourCC[0] );
    216 
    217         if (pdwFourCC)
     208    if(pDev->vhwaInfo.bVHWAEnabled)
     209    {
     210//        // TODO: filter out hw-unsupported fourccs
     211//#define FOURCC_YUV422  (MAKEFOURCC('Y','U','Y','2'))
     212//#define FOURCC_YUV411  (MAKEFOURCC('Y','4','1','1'))
     213//
     214//        static DWORD fourCC[] =  { FOURCC_YUV422, FOURCC_YUV411 };  // The FourCC's we support
     215
     216        *pdwNumFourCCCodes = pDev->vhwaInfo.numFourCC;
     217
     218        if (pdwFourCC && pDev->vhwaInfo.numFourCC)
    218219        {
    219             memcpy(pdwFourCC, fourCC, sizeof(fourCC));
     220            int rc = vboxVHWAInitHostInfo2(pDev, pdwFourCC);
     221            if(RT_FAILURE(rc))
     222            {
     223                *pdwNumFourCCCodes = 0;
     224                pDev->vhwaInfo.numFourCC = 0;
     225            }
    220226        }
    221227    }
     
    311317
    312318#ifdef VBOX_WITH_VIDEOHWACCEL
    313     if(pDev->bVHWAEnabled)
     319    if(pDev->vhwaInfo.bVHWAEnabled)
    314320    {
    315321        //TODO: filter out those we do not need in case not supported by hw
     
    333339                         ;
    334340
    335         pSurfaceCallBacks->UpdateOverlay = DdUpdateOverlay;   // Now supporting overlays.
    336         pSurfaceCallBacks->SetOverlayPosition = DdSetOverlayPosition;
    337         pSurfaceCallBacks->dwFlags |=
    338                          DDHAL_SURFCB32_UPDATEOVERLAY      | // Now supporting
    339                          DDHAL_SURFCB32_SETOVERLAYPOSITION ; // overlays.
     341        if(pDev->vhwaInfo.caps & VBOXVHWA_CAPS_OVERLAY)
     342        {
     343            pSurfaceCallBacks->UpdateOverlay = DdUpdateOverlay;   // Now supporting overlays.
     344            pSurfaceCallBacks->SetOverlayPosition = DdSetOverlayPosition;
     345            pSurfaceCallBacks->dwFlags |=
     346                             DDHAL_SURFCB32_UPDATEOVERLAY      | // Now supporting
     347                             DDHAL_SURFCB32_SETOVERLAYPOSITION ; // overlays.
     348        }
    340349    }
    341350#endif
     
    625634    lpSurfaceDesc->dwFlags |= DDSD_PITCH;
    626635
     636#ifdef VBOX_WITH_VIDEOHWACCEL
     637    vboxVHWASurfCreate(pDev, lpCreateSurface);
     638#endif
    627639
    628640    return DDHAL_DRIVER_NOTHANDLED;
     
    675687        return DDHAL_DRIVER_HANDLED;
    676688    }
     689    lpCanCreateSurface->ddRVal = DD_OK;
    677690#else
    678     /* TODO: filter out unsupported formats */
    679 #endif
    680 
    681     lpCanCreateSurface->ddRVal = DD_OK;
     691    vboxVHWASurfCanCreate(pDev, lpCanCreateSurface);
     692#endif
     693
    682694    return DDHAL_DRIVER_HANDLED;
    683695}
     
    955967    DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev));
    956968
     969#ifdef VBOX_WITH_VIDEOHWACCEL
     970    vboxVHWASurfDestroy(pDev, lpDestroySurface);
     971#else
    957972    lpDestroySurface->ddRVal = DD_OK;
     973#endif
    958974    return DDHAL_DRIVER_HANDLED;
    959975}
     
    11841200{
    11851201    SRCCOPY >> 16
    1186 //        WHITENESS >> 16,
     1202//    WHITENESS >> 16,
    11871203//        BLACKNESS >> 16
    11881204};
     
    11901206static DWORD rops[DD_ROP_SPACE] = { 0 };
    11911207
    1192 void
     1208bool
    11931209getDDHALInfo(
    11941210    PPDEV pDev,
     
    11961212{
    11971213    int i;
    1198 
    1199     /* TODO: only enable features supported by the host backend & host hw
    1200      * for now this just combines all caps we might use */
    1201 
    1202     // Setup the ROPS we do.
    1203     setupRops( ropListNT,
    1204                  rops,
    1205                  sizeof(ropListNT)/sizeof(ropListNT[0]));
    1206 
    1207     // The most basic DirectDraw functionality
    1208     pHALInfo->ddCaps.dwCaps |=   DDCAPS_BLT
    1209                                  | DDCAPS_BLTQUEUE
    1210                                  | DDCAPS_BLTCOLORFILL
     1214    if(!VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_BLT) && !VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_OVERLAY))
     1215        return false;
     1216
     1217    if(VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_BLT))
     1218    {
     1219        // Setup the ROPS we do.
     1220        //TODO: hardcoded for now
     1221        setupRops( ropListNT,
     1222                     rops,
     1223                     sizeof(ropListNT)/sizeof(ropListNT[0]));
     1224
     1225        // The most basic DirectDraw functionality
     1226        pHALInfo->ddCaps.dwCaps |=   DDCAPS_BLT
     1227                                     | DDCAPS_BLTQUEUE;
     1228        if(VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_BLTCOLORFILL))
     1229        {
     1230            pHALInfo->ddCaps.dwCaps |= DDCAPS_BLTCOLORFILL;
     1231        }
     1232    }
     1233
    12111234//                                | DDCAPS_READSCANLINE
    1212                                 ;
     1235
    12131236
    12141237    pHALInfo->ddCaps.ddsCaps.dwCaps |=   DDSCAPS_OFFSCREENPLAIN
    1215                                          | DDSCAPS_PRIMARYSURFACE
    1216                                          | DDSCAPS_FLIP;
    1217 
    1218     pHALInfo->ddCaps.dwCaps |= DDCAPS_3D           |
    1219                                DDCAPS_BLTDEPTHFILL;
    1220 
    1221     pHALInfo->ddCaps.ddsCaps.dwCaps |= DDSCAPS_3DDEVICE |
    1222                                        DDSCAPS_ZBUFFER |
    1223                                        DDSCAPS_ALPHA;
     1238                                         | DDSCAPS_PRIMARYSURFACE;
     1239    if(pDev->vhwaInfo.surfaceCaps & VBOXVHWA_SCAPS_FLIP)
     1240    {
     1241        pHALInfo->ddCaps.ddsCaps.dwCaps |= DDSCAPS_FLIP;
     1242    }
     1243//disabled
     1244//    pHALInfo->ddCaps.dwCaps |= DDCAPS_3D           |
     1245//                               DDCAPS_BLTDEPTHFILL;
     1246//
     1247//    pHALInfo->ddCaps.ddsCaps.dwCaps |= DDSCAPS_3DDEVICE |
     1248//                                       DDSCAPS_ZBUFFER |
     1249//                                       DDSCAPS_ALPHA;
    12241250    pHALInfo->ddCaps.dwCaps2 = 0;
    12251251
     
    12611287    // 3. Mirroring in X and Y
    12621288    // 4. ColorKeying from a source color and a source color space
    1263     pHALInfo->ddCaps.dwCaps |= DDCAPS_BLTSTRETCH
    1264                                | DDCAPS_BLTFOURCC
    1265                                | DDCAPS_COLORKEY
     1289    if(VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_BLT)
     1290            && VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_BLTSTRETCH))
     1291    {
     1292        pHALInfo->ddCaps.dwCaps |= DDCAPS_BLTSTRETCH;
     1293
     1294        // Special effects caps
     1295        //TODO: filter them out
     1296        pHALInfo->ddCaps.dwFXCaps |= DDFXCAPS_BLTSTRETCHY  |
     1297                                    DDFXCAPS_BLTSTRETCHX  |
     1298                                    DDFXCAPS_BLTSTRETCHYN |
     1299                                    DDFXCAPS_BLTSTRETCHXN |
     1300                                    DDFXCAPS_BLTSHRINKY   |
     1301                                    DDFXCAPS_BLTSHRINKX   |
     1302                                    DDFXCAPS_BLTSHRINKYN  |
     1303                                    DDFXCAPS_BLTSHRINKXN;
     1304
     1305
     1306        //mirroring with blitting
     1307        pHALInfo->ddCaps.dwFXCaps |= DDFXCAPS_BLTMIRRORUPDOWN
     1308                                     | DDFXCAPS_BLTMIRRORLEFTRIGHT;
     1309
     1310    }
     1311
     1312    if(VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_BLT)
     1313            && VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_BLTFOURCC))
     1314    {
     1315        pHALInfo->ddCaps.dwCaps |= DDCAPS_BLTFOURCC;
     1316
     1317        // Enable copy blts between Four CC formats for DShow acceleration
     1318        pHALInfo->ddCaps.dwCaps2 |= DDCAPS2_COPYFOURCC;
     1319    }
     1320
     1321    if(VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_BLT)
     1322            && VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_COLORKEY))
     1323    {
     1324        pHALInfo->ddCaps.dwCaps |= DDCAPS_COLORKEY;
    12661325//                               | DDCAPS_CANBLTSYSMEM
    1267                                ;
    1268 
    1269     // Special effects caps
    1270     pHALInfo->ddCaps.dwFXCaps |= DDFXCAPS_BLTSTRETCHY  |
    1271                                 DDFXCAPS_BLTSTRETCHX  |
    1272                                 DDFXCAPS_BLTSTRETCHYN |
    1273                                 DDFXCAPS_BLTSTRETCHXN |
    1274                                 DDFXCAPS_BLTSHRINKY   |
    1275                                 DDFXCAPS_BLTSHRINKX   |
    1276                                 DDFXCAPS_BLTSHRINKYN  |
    1277                                 DDFXCAPS_BLTSHRINKXN;
    1278 
    1279     // ColorKey caps
    1280     pHALInfo->ddCaps.dwCKeyCaps |= DDCKEYCAPS_SRCBLT         |
    1281                                   DDCKEYCAPS_SRCBLTCLRSPACE |
    1282                                   DDCKEYCAPS_DESTBLT        |
    1283                                   DDCKEYCAPS_DESTBLTCLRSPACE;
    1284 
     1326
     1327        // ColorKey caps
     1328        //TODO: filter them out
     1329        pHALInfo->ddCaps.dwCKeyCaps |= DDCKEYCAPS_SRCBLT         |
     1330                                      DDCKEYCAPS_SRCBLTCLRSPACE |
     1331                                      DDCKEYCAPS_DESTBLT        |
     1332                                      DDCKEYCAPS_DESTBLTCLRSPACE;
     1333
     1334        pHALInfo->ddCaps.dwCKeyCaps |=  DDCKEYCAPS_SRCBLTCLRSPACEYUV
     1335                                        | DDCKEYCAPS_DESTBLTCLRSPACEYUV;
     1336
     1337#if 0
     1338        DDCKEYCAPS_DESTBLT Supports transparent blitting with a color key that identifies the replaceable bits of the destination surface for RGB colors.
     1339        DDCKEYCAPS_DESTBLTCLRSPACE Supports transparent blitting with a color space that identifies the replaceable bits of the destination surface for RGB colors.
     1340        DDCKEYCAPS_DESTBLTCLRSPACEYUV Supports transparent blitting with a color space that identifies the replaceable bits of the destination surface for YUV colors.
     1341        DDCKEYCAPS_DESTBLTYUV Supports transparent blitting with a color key that identifies the replaceable bits of the destination surface for YUV colors.
     1342
     1343        DDCKEYCAPS_SRCBLT Supports transparent blitting using the color key for the source with this surface for RGB colors.
     1344        DDCKEYCAPS_SRCBLTCLRSPACE Supports transparent blitting using a color space for the source with this surface for RGB colors.
     1345        DDCKEYCAPS_SRCBLTCLRSPACEYUV Supports transparent blitting using a color space for the source with this surface for YUV colors.
     1346        DDCKEYCAPS_SRCBLTYUV Supports transparent blitting using the color key for the source with this surface for YUV colors.
     1347#endif
     1348
     1349    }
     1350
     1351    if(VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_OVERLAY)
     1352            && VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_COLORKEY))
     1353    {
     1354#if 0
     1355        DDCKEYCAPS_DESTOVERLAY Supports overlaying with color keying of the replaceable bits of the destination surface being overlaid for RGB colors.
     1356        DDCKEYCAPS_DESTOVERLAYCLRSPACE Supports a color space as the color key for the destination of RGB colors.
     1357        DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV Supports a color space as the color key for the destination of YUV colors.
     1358        DDCKEYCAPS_DESTOVERLAYONEACTIVE Supports only one active destination color key value for visible overlay surfaces.
     1359        DDCKEYCAPS_DESTOVERLAYYUV Supports overlaying using color keying of the replaceable bits of the destination surface being overlaid for YUV colors.
     1360        DDCKEYCAPS_NOCOSTOVERLAY Indicates that there are no bandwidth tradeoffs for using the color key with an overlay.
     1361
     1362        DDCKEYCAPS_SRCOVERLAY Supports overlaying using the color key for the source with this overlay surface for RGB colors.
     1363        DDCKEYCAPS_SRCOVERLAYCLRSPACE Supports overlaying using a color space as the source color key for the overlay surface for RGB colors.
     1364        DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV Supports overlaying using a color space as the source color key for the overlay surface for YUV colors.
     1365        DDCKEYCAPS_SRCOVERLAYONEACTIVE Supports only one active source color key value for visible overlay surfaces.
     1366        DDCKEYCAPS_SRCOVERLAYYUV Supports overlaying using the color key for the source with this overlay surface for YUV colors.
     1367#endif
     1368    }
    12851369//    pHALInfo->ddCaps.dwSVBCaps = DDCAPS_BLT;
    12861370
     
    12961380//    }
    12971381
    1298     //mirroring with blitting
    1299     pHALInfo->ddCaps.dwFXCaps |= DDFXCAPS_BLTMIRRORUPDOWN  |
    1300                                 DDFXCAPS_BLTMIRRORLEFTRIGHT;
    1301 
    1302     pHALInfo->ddCaps.dwCKeyCaps |=  DDCKEYCAPS_SRCBLTCLRSPACEYUV;
    1303 
    1304     pHALInfo->ddCaps.ddsCaps.dwCaps |= DDSCAPS_TEXTURE;
     1382
     1383
     1384//disabled
     1385//    pHALInfo->ddCaps.ddsCaps.dwCaps |= DDSCAPS_TEXTURE;
    13051386
    13061387//#if DX7_STEREO
     
    13291410//#endif // SUPPORT_VIDEOPORT
    13301411
    1331 
     1412        if(VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_OVERLAY)) /* no overlay support for now */
    13321413        {
    13331414            // Overlay is free to use.
    1334             pHALInfo->ddCaps.dwMaxVisibleOverlays = 1;
     1415            pHALInfo->ddCaps.dwMaxVisibleOverlays = pDev->vhwaInfo.numOverlays;
    13351416            pHALInfo->ddCaps.dwCurrVisibleOverlays = 0;
    13361417
     
    13751456    pHALInfo->ddCaps.dwCaps2 |= DDCAPS2_WIDESURFACES;
    13761457
    1377     // Enable copy blts betweemn Four CC formats for DShow acceleration
    1378     pHALInfo->ddCaps.dwCaps2 |= DDCAPS2_COPYFOURCC;
    13791458
    13801459    // Won't do Video-Sys mem Blits.
     
    14101489//                                                  DDBD_8;
    14111490
    1412     // No alpha blending for overlays, so I'm not sure what these should be.
    1413     // Because we support 32bpp overlays, it's just that you can't use the
    1414     // alpha bits for blending. Pass.
    1415     pHALInfo->ddCaps.dwAlphaBltConstBitDepths = DDBD_2 |
    1416                                                 DDBD_4 |
    1417                                                 DDBD_8;
    1418 
    1419     pHALInfo->ddCaps.dwAlphaBltPixelBitDepths = DDBD_1 |
    1420                                                 DDBD_8;
    1421 
    1422     pHALInfo->ddCaps.dwAlphaBltSurfaceBitDepths = DDBD_1 |
    1423                                                   DDBD_2 |
    1424                                                   DDBD_4 |
    1425                                                   DDBD_8;
     1491//disabled
     1492//    // No alpha blending for overlays, so I'm not sure what these should be.
     1493//    // Because we support 32bpp overlays, it's just that you can't use the
     1494//    // alpha bits for blending. Pass.
     1495//    pHALInfo->ddCaps.dwAlphaBltConstBitDepths = DDBD_2 |
     1496//                                                DDBD_4 |
     1497//                                                DDBD_8;
     1498//
     1499//    pHALInfo->ddCaps.dwAlphaBltPixelBitDepths = DDBD_1 |
     1500//                                                DDBD_8;
     1501//
     1502//    pHALInfo->ddCaps.dwAlphaBltSurfaceBitDepths = DDBD_1 |
     1503//                                                  DDBD_2 |
     1504//                                                  DDBD_4 |
     1505//                                                  DDBD_8;
    14261506
    14271507    //
     
    14431523//#endif DX8_DDI
    14441524
    1445 
     1525    return true;
    14461526} // getDDHALInfo
    14471527
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/debug.h

    r18246 r20478  
    3939
    4040#define DISPDBG(arg) DebugPrint arg
     41#define VHWADBG(arg)
    4142#define RIP(x) { DebugPrint(0, x); }
    4243#else
    4344#define DISPDBG(arg)
     45#define VHWADBG(arg)
    4446#define RIP(x)
    4547#endif
    4648
    4749// #if DBG
    48 // 
     50//
    4951// VOID
    5052// DebugPrint(
     
    5355//     ...
    5456//     );
    55 // 
     57//
    5658// #define DISPDBG(arg) DebugPrint arg
    5759// #define RIP(x) { DebugPrint(0, x); EngDebugBreak();}
    58 // 
     60//
    5961// #else
    60 // 
     62//
    6163// #define DISPDBG(arg)
    6264// #define RIP(x)
    63 // 
     65//
    6466// #endif
    6567
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/driver.h

    r20009 r20478  
    9494} VBOXSURF, *PVBOXSURF;
    9595
     96#ifdef VBOX_WITH_VIDEOHWACCEL
     97typedef struct _VBOXVHWASURFDESC
     98{
     99    VBOXVHWA_SURFHANDLE hHostHandle;
     100}VBOXVHWASURFDESC, *PVBOXVHWASURFDESC;
     101typedef struct _VBOXVHWAINFO
     102{
     103    uint32_t caps;
     104    uint32_t colorKeyCaps;
     105    uint32_t stretchCaps;
     106    uint32_t surfaceCaps;
     107    uint32_t numOverlays;
     108    uint32_t numFourCC;
     109    HGSMIOFFSET FourCC;
     110    BOOLEAN bVHWAEnabled;
     111} VBOXVHWAINFO;
     112#endif
     113
    96114struct  _PDEV
    97115{
     
    167185    HVBOXVIDEOHGSMI hMpHGSMI; /* context handler passed to miniport HGSMI callbacks */
    168186    PFNVBOXVIDEOHGSMICOMPLETION pfnHGSMICommandComplete; /* called to complete the command we receive from the miniport */
     187    PFNVBOXVIDEOHGSMICOMMANDS   pfnHGSMIRequestCommands; /* called to requests the commands posted to us from the host */
    169188#endif /* VBOX_WITH_HGSMI */
    170189
    171190#ifdef VBOX_WITH_VIDEOHWACCEL
    172     BOOLEAN bVHWAEnabled;
     191    VBOXVHWAINFO vhwaInfo;
    173192#endif
    174193};
     
    253272
    254273#ifdef VBOX_WITH_HGSMI
    255 DECLCALLBACK(int) vboxVBVAHostCommandHanlder(void *pvHandler, uint16_t u16ChannelInfo, void *pvBuffer, HGSMISIZE cbBuffer);
    256 void vboxVBVAHostCommandComplete(PPDEV ppdev, void *pvBuffer);
     274void vboxVBVAHostCommandComplete(PPDEV ppdev, VBVAHOSTCMD * pCmd);
    257275
    258276 #ifdef VBOX_WITH_VIDEOHWACCEL
     
    264282void vboxVHWACommandFree (PPDEV ppdev, VBOXVHWACMD* pCmd);
    265283BOOL vboxVHWACommandSubmit (PPDEV ppdev, VBOXVHWACMD* pCmd);
    266 void vboxVHWACommandSubmitAssynch (PPDEV ppdev, VBOXVHWACMD* pCmd, PFNVBOXVHWACMDCOMPLETION pfnCompletion, void * pContext);
     284void vboxVHWACommandSubmitAsynch (PPDEV ppdev, VBOXVHWACMD* pCmd, PFNVBOXVHWACMDCOMPLETION pfnCompletion, void * pContext);
     285void vboxVHWACommandSubmitAsynchByEvent (PPDEV ppdev, VBOXVHWACMD* pCmd, PEVENT pEvent);
     286void vboxVHWACommandCheckHostCmds(PPDEV ppdev);
     287
     288int vboxVHWAInitHostInfo1(PPDEV ppdev);
     289int vboxVHWAInitHostInfo2(PPDEV ppdev, DWORD *pFourCC);
     290
     291VBOXVHWACMD_QUERYINFO1* vboxVHWAQueryHostInfo1(PPDEV ppdev);
     292void vboxVHWAFreeHostInfo1(PPDEV ppdev, VBOXVHWACMD_QUERYINFO1* pInfo);
     293VBOXVHWACMD_QUERYINFO2* vboxVHWAQueryHostInfo2(PPDEV ppdev, uint32_t numFourCC);
     294void vboxVHWAFreeHostInfo2(PPDEV ppdev, VBOXVHWACMD_QUERYINFO2* pInfo);
     295
     296void vboxVHWAInit();
     297void vboxVHWATerm();
     298void vboxVHWASurfCanCreate(PPDEV ppdev, PDD_CANCREATESURFACEDATA  lpCanCreateSurface);
     299void vboxVHWASurfCreate(PPDEV ppdev, PDD_CREATESURFACEDATA  lpCreateSurface);
     300void vboxVHWASurfDestroy(PPDEV ppdev, PDD_DESTROYSURFACEDATA  lpDestroySurface);
    267301 #endif
    268302#endif
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/screen.c

    r20009 r20478  
    119119        if(!err)
    120120        {
    121             HGSMIHANDLERREGISTER HandlerReg;
     121            HGSMIHANDLERENABLE HandlerReg;
    122122            RtlZeroMemory(&HandlerReg, sizeof(HandlerReg));
    123123
    124124            ppdev->hMpHGSMI = Callbacks.hContext;
    125125            ppdev->pfnHGSMICommandComplete = Callbacks.pfnCompletionHandler;
    126             HandlerReg.pfnHandler = vboxVBVAHostCommandHanlder;
    127             HandlerReg.pvHandler = ppdev;
     126            ppdev->pfnHGSMIRequestCommands = Callbacks.pfnRequestCommandsHandler;
     127
    128128            HandlerReg.u8Channel = HGSMI_CH_VBVA;
    129129            err = EngDeviceIoControl(ppdev->hDriver,
    130                     IOCTL_VIDEO_HGSMI_HANDLER_REGISTER,
     130                    IOCTL_VIDEO_HGSMI_HANDLER_ENABLE,
    131131                    &HandlerReg,
    132132                    sizeof(HandlerReg),
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/vbox.c

    r20242 r20478  
    695695{
    696696    VBOXVHWACMD* pHdr = (VBOXVHWACMD*)HGSMIHeapAlloc (&ppdev->hgsmiDisplayHeap,
    697                               cbCmd,
     697                              cbCmd + VBOXVHWACMD_HEADSIZE(),
    698698                              HGSMI_CH_VBVA,
    699699                              VBVA_VHWA_CMD);
     
    703703    }
    704704
     705    /* temporary hack */
     706    vboxVHWACommandCheckHostCmds(ppdev);
     707
    705708    return pHdr;
    706709}
     
    718721}
    719722
     723static int vboxVHWAHanldeVHWACmdCompletion(PPDEV ppdev, VBVAHOSTCMD * pHostCmd)
     724{
     725    VBVAHOSTCMDVHWACMDCOMPLETE * pComplete = VBVAHOSTCMD_BODY(pHostCmd, VBVAHOSTCMDVHWACMDCOMPLETE);
     726    VBOXVHWACMD* pComplCmd = (VBOXVHWACMD*)HGSMIOffsetToPointer (&ppdev->hgsmiDisplayHeap.area, pComplete->offCmd);
     727    PFNVBOXVHWACMDCOMPLETION pfnCompletion = (PFNVBOXVHWACMDCOMPLETION)pComplCmd->GuestVBVAReserved1;
     728    void * pContext = (void *)pComplCmd->GuestVBVAReserved2;
     729
     730    pfnCompletion(ppdev, pComplCmd, pContext);
     731
     732    vboxVBVAHostCommandComplete(ppdev, pHostCmd);
     733
     734    return 0;
     735}
     736
     737static void vboxVBVAHostCommandHanlder(PPDEV ppdev, VBVAHOSTCMD * pCmd)
     738{
     739    int rc = VINF_SUCCESS;
     740    switch(pCmd->customOpCode)
     741    {
     742# ifdef VBOX_WITH_VIDEOHWACCEL
     743        case VBVAHG_DCUSTOM_VHWA_CMDCOMPLETE:
     744        {
     745            vboxVHWAHanldeVHWACmdCompletion(ppdev, pCmd);
     746            break;
     747        }
     748# endif
     749        default:
     750        {
     751            vboxVBVAHostCommandComplete(ppdev, pCmd);
     752        }
     753    }
     754}
     755
     756void vboxVHWACommandCheckHostCmds(PPDEV ppdev)
     757{
     758    VBVAHOSTCMD * pCmd;
     759    int rc = ppdev->pfnHGSMIRequestCommands(ppdev->hMpHGSMI, HGSMI_CH_VBVA, &pCmd);
     760    if(RT_SUCCESS(rc))
     761    {
     762        for(; pCmd; pCmd = pCmd->u.pNext)
     763        {
     764            vboxVBVAHostCommandHanlder(ppdev, pCmd);
     765        }
     766    }
     767}
     768
     769void vboxVHWACommandSubmitAsynchByEvent (PPDEV ppdev, VBOXVHWACMD* pCmd, PEVENT pEvent)
     770{
     771//    Assert(0);
     772    pCmd->GuestVBVAReserved1 = (uintptr_t)pEvent;
     773    pCmd->GuestVBVAReserved2 = 0;
     774
     775    /* complete it asynchronously by setting event */
     776    pCmd->Flags = VBOXVHWACMD_FLAG_ASYNCH_EVENT;
     777    vboxHGSMIBufferSubmit (ppdev, pCmd);
     778
     779    if(!(ASMAtomicReadU32((volatile uint32_t *)&pCmd->Flags)  & VBOXVHWACMD_FLAG_ASYNCH))
     780    {
     781        /* the command is completed */
     782        EngSetEvent(pEvent);
     783    }
     784}
     785
    720786BOOL vboxVHWACommandSubmit (PPDEV ppdev, VBOXVHWACMD* pCmd)
    721787{
     
    723789    BOOL brc = EngCreateEvent(&pEvent);
    724790    Assert(brc);
     791
    725792    if(brc)
    726793    {
    727         vboxVHWACommandSubmitAssynch (ppdev, pCmd, vboxVHWACommandCompletionCallbackEvent, pEvent);
     794        vboxVHWACommandSubmitAsynchByEvent (ppdev, pCmd, pEvent);
    728795
    729796        brc = EngWaitForSingleObject(pEvent,
     
    740807
    741808/* do not wait for completion */
    742 void vboxVHWACommandSubmitAssynch (PPDEV ppdev, VBOXVHWACMD* pCmd, PFNVBOXVHWACMDCOMPLETION pfnCompletion, void * pContext)
    743 {
     809void vboxVHWACommandSubmitAsynch (PPDEV ppdev, VBOXVHWACMD* pCmd, PFNVBOXVHWACMDCOMPLETION pfnCompletion, void * pContext)
     810{
     811//    Assert(0);
    744812    pCmd->GuestVBVAReserved1 = (uintptr_t)pfnCompletion;
    745813    pCmd->GuestVBVAReserved2 = (uintptr_t)pContext;
    746814
     815    pCmd->Flags = 0;
    747816    vboxHGSMIBufferSubmit (ppdev, pCmd);
    748817
    749     if(pCmd->rc != VINF_VHWA_CMD_PENDING)
     818    if(!(pCmd->Flags  & VBOXVHWACMD_FLAG_ASYNCH))
    750819    {
    751820        /* the command is completed */
    752821        pfnCompletion(ppdev, pCmd, pContext);
    753822    }
    754 
    755 }
    756 
    757 static int vboxVHWAHanldeVHWACmdCompletion(PPDEV ppdev, void *pvBuffer, HGSMISIZE cbBuffer)
    758 {
    759     VBOXVHWACMD* pCmd = (VBOXVHWACMD*)pvBuffer;
    760     PFNVBOXVHWACMDCOMPLETION pfnCompletion = (PFNVBOXVHWACMDCOMPLETION)pCmd->GuestVBVAReserved1;
    761     void * pContext = (void *)pCmd->GuestVBVAReserved2;
    762 
    763     pfnCompletion(ppdev, pCmd, pContext);
    764     return 0;
    765 }
     823}
     824
     825void vboxVHWAFreeHostInfo1(PPDEV ppdev, VBOXVHWACMD_QUERYINFO1* pInfo)
     826{
     827    VBOXVHWACMD* pCmd = VBOXVHWACMD_HEAD(pInfo);
     828    vboxVHWACommandFree (ppdev, pCmd);
     829}
     830
     831void vboxVHWAFreeHostInfo2(PPDEV ppdev, VBOXVHWACMD_QUERYINFO2* pInfo)
     832{
     833    VBOXVHWACMD* pCmd = VBOXVHWACMD_HEAD(pInfo);
     834    vboxVHWACommandFree (ppdev, pCmd);
     835}
     836
     837VBOXVHWACMD_QUERYINFO1* vboxVHWAQueryHostInfo1(PPDEV ppdev)
     838{
     839    VBOXVHWACMD* pCmd = vboxVHWACommandCreate (ppdev, sizeof(VBOXVHWACMD_QUERYINFO1));
     840    if (!pCmd)
     841    {
     842        DISPDBG((0, "VBoxDISP::vboxVHWAQueryHostInfo1: vboxVHWACommandCreate failed\n"));
     843        return NULL;
     844    }
     845
     846    pCmd->enmCmd = VBOXVHWACMD_TYPE_QUERY_INFO1;
     847    if(vboxVHWACommandSubmit (ppdev, pCmd))
     848    {
     849        if(RT_SUCCESS(pCmd->rc))
     850        {
     851            return VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_QUERYINFO1);
     852        }
     853    }
     854
     855    vboxVHWACommandFree (ppdev, pCmd);
     856    return NULL;
     857}
     858
     859VBOXVHWACMD_QUERYINFO2* vboxVHWAQueryHostInfo2(PPDEV ppdev, uint32_t numFourCC)
     860{
     861    VBOXVHWACMD* pCmd = vboxVHWACommandCreate (ppdev, sizeof(VBOXVHWACMD_QUERYINFO2));
     862    VBOXVHWACMD_QUERYINFO2 *pInfo2;
     863    if (!pCmd)
     864    {
     865        DISPDBG((0, "VBoxDISP::vboxVHWAQueryHostInfo1: vboxVHWACommandCreate failed\n"));
     866        return NULL;
     867    }
     868
     869    pCmd->enmCmd = VBOXVHWACMD_TYPE_QUERY_INFO2;
     870    pInfo2 = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_QUERYINFO2);
     871    pInfo2->numFourCC = numFourCC;
     872
     873    if(vboxVHWACommandSubmit (ppdev, pCmd))
     874    {
     875        if(RT_SUCCESS(pCmd->rc))
     876        {
     877            if(pInfo2->numFourCC == numFourCC)
     878            {
     879                return pInfo2;
     880            }
     881        }
     882    }
     883
     884    vboxVHWACommandFree (ppdev, pCmd);
     885    return NULL;
     886}
     887
     888int vboxVHWAInitHostInfo1(PPDEV ppdev)
     889{
     890    VBOXVHWACMD_QUERYINFO1* pInfo = vboxVHWAQueryHostInfo1(ppdev);
     891    if(!pInfo)
     892    {
     893        ppdev->vhwaInfo.bVHWAEnabled = false;
     894        return VERR_OUT_OF_RESOURCES;
     895    }
     896
     897    ppdev->vhwaInfo.caps = pInfo->caps;
     898    ppdev->vhwaInfo.colorKeyCaps = pInfo->colorKeyCaps;
     899    ppdev->vhwaInfo.stretchCaps = pInfo->stretchCaps;
     900    ppdev->vhwaInfo.surfaceCaps = pInfo->surfaceCaps;
     901    ppdev->vhwaInfo.numOverlays = pInfo->numOverlays;
     902    ppdev->vhwaInfo.numFourCC = pInfo->numFourCC;
     903    ppdev->vhwaInfo.bVHWAEnabled = (pInfo->cfgFlags & VBOXVHWA_CFG_ENABLED);
     904
     905    vboxVHWAFreeHostInfo1(ppdev, pInfo);
     906    return VINF_SUCCESS;
     907}
     908
     909int vboxVHWAInitHostInfo2(PPDEV ppdev, DWORD *pFourCC)
     910{
     911    VBOXVHWACMD_QUERYINFO2* pInfo = vboxVHWAQueryHostInfo2(ppdev, ppdev->vhwaInfo.numFourCC);
     912    int rc = VINF_SUCCESS;
     913
     914    if(pInfo)
     915        return VERR_OUT_OF_RESOURCES;
     916
     917    if(ppdev->vhwaInfo.numFourCC)
     918    {
     919        memcpy(pFourCC, pInfo->FourCC, ppdev->vhwaInfo.numFourCC * sizeof(pFourCC[0]));
     920    }
     921    else
     922    {
     923        Assert(0);
     924        rc = VERR_GENERAL_FAILURE;
     925    }
     926
     927    vboxVHWAFreeHostInfo2(ppdev, pInfo);
     928
     929    return rc;
     930}
     931
    766932
    767933# endif
    768934
    769 void vboxVBVAHostCommandComplete(PPDEV ppdev, void *pvBuffer)
    770 {
    771     ppdev->pfnHGSMICommandComplete(ppdev->hMpHGSMI, pvBuffer);
    772 }
    773 
    774 DECLCALLBACK(int) vboxVBVAHostCommandHanlder(void *pvHandler, uint16_t u16ChannelInfo, void *pvBuffer, HGSMISIZE cbBuffer)
    775 {
    776     int rc = VINF_SUCCESS;
    777     PPDEV ppdev = (PPDEV)pvHandler;
    778 
    779     switch(u16ChannelInfo)
    780     {
    781 # ifdef VBOX_WITH_VIDEOHWACCEL
    782         case VBVAHG_VHWA_CMDCOMPLETE:
    783         {
    784             vboxVHWAHanldeVHWACmdCompletion(ppdev, pvBuffer, cbBuffer);
    785             break;
    786         }
    787 # endif
    788         default:
    789         {
    790             vboxVBVAHostCommandComplete(ppdev, pvBuffer);
    791         }
    792     }
    793     return rc;
     935void vboxVBVAHostCommandComplete(PPDEV ppdev, VBVAHOSTCMD * pCmd)
     936{
     937    ppdev->pfnHGSMICommandComplete(ppdev->hMpHGSMI, pCmd);
    794938}
    795939
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp

    r19844 r20478  
    18951895            HGSMIQUERYCALLBACKS *pInfo = (HGSMIQUERYCALLBACKS *)RequestPacket->OutputBuffer;
    18961896
    1897             pInfo->hContext = pDevExt->pPrimary;
    1898             pInfo->pfnCompletionHandler = hgsmiHostCmdHandlerComplete;
     1897            pInfo->hContext = pDevExt;
     1898            pInfo->pfnCompletionHandler = hgsmiHostCmdComplete;
     1899            pInfo->pfnRequestCommandsHandler = hgsmiHostCmdRequest;
    18991900
    19001901            RequestPacket->StatusBlock->Information = sizeof(HGSMIQUERYCALLBACKS);
     
    19021903            break;
    19031904        }
    1904         case IOCTL_VIDEO_HGSMI_HANDLER_REGISTER:
    1905         {
    1906             dprintf(("VBoxVideo::VBoxVideoStartIO: IOCTL_VIDEO_HGSMI_HANDLER_REGISTER\n"));
    1907 
    1908             if (RequestPacket->InputBufferLength< sizeof(HGSMIHANDLERREGISTER))
     1905        case IOCTL_VIDEO_HGSMI_HANDLER_ENABLE:
     1906        {
     1907            dprintf(("VBoxVideo::VBoxVideoStartIO: IOCTL_VIDEO_HGSMI_HANDLER_ENABLE\n"));
     1908
     1909            if (RequestPacket->InputBufferLength< sizeof(HGSMIHANDLERENABLE))
    19091910            {
    19101911                dprintf(("VBoxVideo::VBoxVideoStartIO: Output buffer too small: %d needed: %d!!!\n",
    1911                          RequestPacket->InputBufferLength, sizeof(HGSMIHANDLERREGISTER)));
     1912                         RequestPacket->InputBufferLength, sizeof(HGSMIHANDLERENABLE)));
    19121913                RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
    19131914                return FALSE;
     
    19201921            }
    19211922
    1922             HGSMIHANDLERREGISTER *pInfo = (HGSMIHANDLERREGISTER *)RequestPacket->InputBuffer;
    1923 
    1924             int rc = vboxHGSMIChannelDisplayRegister (pDevExt->pPrimary,
    1925                     pDevExt->iDevice, /* negative would mean this is a miniport handler */
    1926                     pInfo->u8Channel,
    1927                     pInfo->pfnHandler,
    1928                     pInfo->pvHandler);
     1923            HGSMIHANDLERENABLE *pInfo = (HGSMIHANDLERENABLE *)RequestPacket->InputBuffer;
     1924
     1925            int rc = vboxVBVAChannelDisplayEnable(pDevExt->pPrimary,
     1926                    pDevExt->iDevice,
     1927                    pInfo->u8Channel);
    19291928            if(RT_FAILURE(rc))
    19301929            {
     
    19341933            break;
    19351934        }
    1936         case IOCTL_VIDEO_HGSMI_HANDLER_DEREGISTER:
     1935        case IOCTL_VIDEO_HGSMI_HANDLER_DISABLE:
    19371936        {
    19381937            /* TODO: implement */
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h

    r20374 r20478  
    258258                                uint32_t cbLength);
    259259
    260 DECLCALLBACK(void) hgsmiHostCmdHandlerComplete (HVBOXVIDEOHGSMI hHGSMI, void * pvMem);
    261 
    262 int vboxHGSMIChannelDisplayRegister (PDEVICE_EXTENSION PrimaryExtension,
     260DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd);
     261DECLCALLBACK(int) hgsmiHostCmdRequest (HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, struct _VBVAHOSTCMD ** ppCmd);
     262
     263
     264int vboxVBVAChannelDisplayEnable(PDEVICE_EXTENSION PrimaryExtension,
    263265        int iDisplay, /* negative would mean this is a miniport handler */
    264         uint8_t u8Channel,
    265         PFNHGSMICHANNELHANDLER pfnChannelHandler,
    266         void *pvChannelHandler);
     266        uint8_t u8Channel);
    267267#endif /* VBOX_WITH_HGSMI */
    268268} /* extern "C" */
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/vboxioctl.h

    r19844 r20478  
    5353    CTL_CODE(FILE_DEVICE_VIDEO, 0x431, METHOD_BUFFERED, FILE_ANY_ACCESS)
    5454
    55 #define IOCTL_VIDEO_HGSMI_HANDLER_REGISTER \
     55#define IOCTL_VIDEO_HGSMI_HANDLER_ENABLE \
    5656    CTL_CODE(FILE_DEVICE_VIDEO, 0x432, METHOD_BUFFERED, FILE_ANY_ACCESS)
    5757
    58 #define IOCTL_VIDEO_HGSMI_HANDLER_DEREGISTER \
     58#define IOCTL_VIDEO_HGSMI_HANDLER_DISABLE \
    5959    CTL_CODE(FILE_DEVICE_VIDEO, 0x433, METHOD_BUFFERED, FILE_ANY_ACCESS)
    6060
     
    129129    HVBOXVIDEOHGSMI hContext;
    130130    PFNVBOXVIDEOHGSMICOMPLETION pfnCompletionHandler;
     131    PFNVBOXVIDEOHGSMICOMMANDS   pfnRequestCommandsHandler;
    131132} HGSMIQUERYCALLBACKS;
    132133
    133134/**
    134  * Data returned by IOCTL_VIDEO_HGSMI_HANDLER_REGISTER.
     135 * Data returned by IOCTL_VIDEO_HGSMI_HANDLER_ENABLE.
    135136 *
    136137 */
    137 typedef struct _HGSMIHANDLERREGISTER
     138typedef struct _HGSMIHANDLERENABLE
    138139{
    139     PFNHGSMICHANNELHANDLER pfnHandler;
    140     void * pvHandler;
    141140    uint8_t u8Channel;
    142 } HGSMIHANDLERREGISTER;
     141} HGSMIHANDLERENABLE;
    143142
    144143/**
    145  * Data passed by IOCTL_VIDEO_HGSMI_HANDLER_DEREGISTER.
     144 * Data passed by IOCTL_VIDEO_HGSMI_HANDLER_DISABLE.
    146145 *
    147146 */
    148 typedef struct _HGSMIHANDLERDEREGISTER
     147typedef struct _HGSMIHANDLERDISABLE
    149148{
    150     PFNHGSMICHANNELHANDLER pfnHandler;
    151149    uint8_t u8Channel;
    152 } HGSMIHANDLERDEREGISTER;
     150} HGSMIHANDLERDISABLE;
    153151
    154152#endif /* VBOX_WITH_HGSMI */
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxFrameBuffer.h

    r20349 r20478  
    495495    void vboxResizeEvent (VBoxResizeEvent *re);
    496496
     497    VBoxVHWASurfacePrimary * vboxGetSurface() { return pDisplay; }
    497498protected:
    498499//    void resizeGL (int height, int width);
     
    547548private:
    548549#ifdef VBOX_WITH_VIDEOHWACCEL
     550    int vhwaSurfaceCanCreate(struct _VBOXVHWACMD_SURF_CANCREATE *pCmd);
    549551    int vhwaSurfaceCreate(struct _VBOXVHWACMD_SURF_CREATE *pCmd);
    550552    int vhwaSurfaceDestroy(struct _VBOXVHWACMD_SURF_DESTROY *pCmd);
     
    552554    int vhwaSurfaceUnlock(struct _VBOXVHWACMD_SURF_UNLOCK *pCmd);
    553555    int vhwaSurfaceBlt(struct _VBOXVHWACMD_SURF_BLT *pCmd);
     556    int vhwaQueryInfo1(struct _VBOXVHWACMD_QUERYINFO1 *pCmd);
     557    int vhwaQueryInfo2(struct _VBOXVHWACMD_QUERYINFO2 *pCmd);
    554558#endif
    555559    void vboxMakeCurrent();
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette