VirtualBox

Changeset 19515 in vbox for trunk/src/VBox/Additions/WINNT


Ignore:
Timestamp:
May 8, 2009 8:44:45 AM (16 years ago)
Author:
vboxsync
Message:

video hw accel: basic for ddcaps initialization to support acceleration in VBoxDisp win driver

Location:
trunk/src/VBox/Additions/WINNT/Graphics/Display
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/dd.c

    r18246 r19515  
    2626* Module Name: ddenable.c
    2727*
    28 * Content:   
     28* Content:
    2929*
    3030* Copyright (c) 1994-1998 3Dlabs Inc. Ltd. All rights reserved.
     
    3737#include <winerror.h>
    3838
    39 
    4039#if 0
    4140static DWORD APIENTRY DdCreateSurface(PDD_CREATESURFACEDATA  lpCreateSurface);
    4241#endif
    4342
     43#ifdef VBOX_WITH_VIDEOHWACCEL
     44void getDDHALInfo(PPDEV pDev, DD_HALINFO* pHALInfo);
     45#endif
    4446
    4547/**
     
    4951 *
    5052 * Parameters:
    51  * 
     53 *
    5254 * dhpdev
    5355 *     Handle to the PDEV returned by the driver’s DrvEnablePDEV routine.
     
    6163 *     Points to the location in which the driver should return the number of DWORDs pointed to by pdwFourCC.
    6264 * pdwFourCC
    63  *     Points to an array of DWORDs in which the driver should return information about each FOURCC that it supports. The driver should ignore this parameter when it is NULL. 
     65 *     Points to an array of DWORDs in which the driver should return information about each FOURCC that it supports. The driver should ignore this parameter when it is NULL.
    6466 *
    6567 * Return Value:
     
    8991    /* Setup the HAL driver caps. */
    9092    pHalInfo->dwSize    = sizeof(DD_HALINFO);
     93#ifndef VBOX_WITH_VIDEOHWACCEL
    9194    pHalInfo->dwFlags   = 0;
    92 
    93     if (!(pvmList && pdwFourCC))
    94     {
     95#endif
     96
     97    if (!(pvmList && pdwFourCC))
     98    {
     99#ifdef VBOX_WITH_VIDEOHWACCEL
     100        memset(pHalInfo, 0, sizeof(DD_HALINFO));
     101        pHalInfo->dwSize    = sizeof(DD_HALINFO);
     102#else
    95103        memset(&pHalInfo->ddCaps, 0, sizeof(DDNTCORECAPS));
     104#endif
     105
    96106        pHalInfo->ddCaps.dwSize         = sizeof(DDNTCORECAPS);
    97107        pHalInfo->ddCaps.dwVidMemTotal  = pDev->layout.cbDDRAWHeap;
     
    105115
    106116        pHalInfo->ddCaps.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
    107        
     117
    108118        /* Create primary surface attributes */
    109119        pHalInfo->vmiData.pvPrimary                 = pDev->pjScreen;
     
    136146        pHalInfo->vmiData.dwZBufferAlign            = 4;
    137147        pHalInfo->vmiData.dwTextureAlign            = 4;
    138     }
    139    
     148
     149
     150#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)
     158        {
     159            getDDHALInfo(pDev, pHalInfo);
     160        }
     161#endif
     162    }
     163
    140164    cHeaps = 0;
    141165
     
    171195            pVm->fpStart        = pDev->layout.offDDRAWHeap;
    172196            pVm->fpEnd          = pDev->layout.offDDRAWHeap + pDev->layout.cbDDRAWHeap - 1; /* inclusive */
    173 
     197#ifndef VBOX_WITH_VIDEOHWACCEL
    174198            pVm->ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     199#endif
    175200            DISPDBG((0, "fpStart %x fpEnd %x\n", pVm->fpStart, pVm->fpEnd));
    176201
     
    178203        }
    179204    }
     205
     206#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)
     218        {
     219            memcpy(pdwFourCC, fourCC, sizeof(fourCC));
     220        }
     221    }
     222#endif
    180223
    181224#if 0 /* not mandatory */
     
    198241/**
    199242 * DrvEnableDirectDraw
    200  * 
     243 *
    201244 * The DrvEnableDirectDraw function enables hardware for DirectDraw use.
    202  * 
     245 *
    203246 * Parameters
    204  * 
     247 *
    205248 * dhpdev
    206249 *     Handle to the PDEV returned by the driver’s DrvEnablePDEV routine.
     
    210253 *     Points to the DD_SURFACECALLBACKS structure to be initialized by the driver.
    211254 * pPaletteCallBacks
    212  *     Points to the DD_PALETTECALLBACKS structure to be initialized by the driver. 
    213  * 
     255 *     Points to the DD_PALETTECALLBACKS structure to be initialized by the driver.
     256 *
    214257 * Return Value
    215  * 
     258 *
    216259 * DrvEnableDirectDraw returns TRUE if it succeeds; otherwise, it returns FALSE.
    217260 *
     
    224267    )
    225268{
     269#ifdef VBOX_WITH_VIDEOHWACCEL
     270    PPDEV pDev = (PPDEV)dhpdev;
     271
     272#endif
     273
    226274    DISPDBG((0, "%s: %p, %p, %p, %p\n", __FUNCTION__, dhpdev, pCallBacks, pSurfaceCallBacks, pPaletteCallBacks));
    227275
     
    236284    // pCallBacks->WaitForVerticalBlank  = DdWaitForVerticalBlank;
    237285    // pCallBacks->GetScanLine           = DdGetScanLine;
    238     // DDHAL_CB32_WAITFORVERTICALBLANK | DDHAL_CB32_GETSCANLINE 
     286    // DDHAL_CB32_WAITFORVERTICALBLANK | DDHAL_CB32_GETSCANLINE
    239287    /* Note: pCallBacks->SetMode & pCallBacks->DestroyDriver are unused in Windows 2000 and up */
    240288
     
    262310    pPaletteCallBacks->dwFlags          = 0;
    263311
     312#ifdef VBOX_WITH_VIDEOHWACCEL
     313    if(pDev->bVHWAEnabled)
     314    {
     315        //TODO: filter out those we do not need in case not supported by hw
     316        pSurfaceCallBacks->DestroySurface = DdDestroySurface;
     317//        pSurfaceCallBacks->Lock = DdLock;
     318//        pSurfaceCallBacks->Unlock = DdUnlock;
     319        pSurfaceCallBacks->GetBltStatus = DdGetBltStatus;
     320        pSurfaceCallBacks->GetFlipStatus = DdGetFlipStatus;
     321        pSurfaceCallBacks->SetColorKey = DdSetColorKey;
     322        pSurfaceCallBacks->Flip = DdFlip;
     323        pSurfaceCallBacks->Blt = DdBlt;
     324
     325        pSurfaceCallBacks->dwFlags |= DDHAL_SURFCB32_DESTROYSURFACE     |
     326                         DDHAL_SURFCB32_FLIP
     327//                         | DDHAL_SURFCB32_LOCK
     328                         | DDHAL_SURFCB32_BLT                |
     329                         DDHAL_SURFCB32_GETBLTSTATUS       |
     330                         DDHAL_SURFCB32_GETFLIPSTATUS      |
     331                         DDHAL_SURFCB32_SETCOLORKEY
     332//                         | DDHAL_SURFCB32_UNLOCK
     333                         ;
     334
     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.
     340    }
     341#endif
    264342    return TRUE;
    265343}
     
    267345/**
    268346 * DrvDisableDirectDraw
    269  * 
     347 *
    270348 * The DrvDisableDirectDraw function disables hardware for DirectDraw use.
    271  * 
     349 *
    272350 * Parameters
    273  * 
     351 *
    274352 * dhpdev
    275353 *     Handle to the PDEV returned by the driver’s DrvEnablePDEV routine.
     
    283361/**
    284362 * DdGetDriverInfo
    285  * 
     363 *
    286364 * The DdGetDriverInfo function queries the driver for additional DirectDraw and Direct3D functionality that the driver supports.
    287  * 
     365 *
    288366 * Parameters
    289367 * lpGetDriverInfo
    290368 *     Points to a DD_GETDRIVERINFODATA structure that contains the information required to perform the query.
    291  * 
     369 *
    292370 * Return Value
    293  * 
    294  * DdGetDriverInfo must return DDHAL_DRIVER_HANDLED. 
     371 *
     372 * DdGetDriverInfo must return DDHAL_DRIVER_HANDLED.
    295373 *
    296374 */
     
    310388        DISPDBG((0, " -> GUID_D3DCallbacks3\n"));
    311389    }
    312     else 
     390    else
    313391    if (IsEqualIID(&lpData->guidInfo, &GUID_D3DExtendedCaps))
    314392    {
    315393        DISPDBG((0, " -> GUID_D3DExtendedCaps\n"));
    316394    }
    317     else 
     395    else
    318396    if (IsEqualIID(&lpData->guidInfo, &GUID_ZPixelFormats))
    319397    {
    320398        DISPDBG((0, " -> GUID_ZPixelFormats\n"));
    321399    }
    322     else 
     400    else
    323401    if (IsEqualIID(&(lpData->guidInfo), &GUID_D3DParseUnknownCommandCallback))
    324402    {
    325403        DISPDBG((0, " -> GUID_D3DParseUnknownCommandCallback\n"));
    326404    }
    327     else 
     405    else
    328406    if (IsEqualIID(&(lpData->guidInfo), &GUID_Miscellaneous2Callbacks))
    329407    {
    330408        DISPDBG((0, " -> GUID_Miscellaneous2Callbacks\n"));
    331409    }
    332     else 
     410    else
    333411    if (IsEqualIID(&(lpData->guidInfo), &GUID_UpdateNonLocalHeap))
    334412    {
    335413        DISPDBG((0, " -> GUID_UpdateNonLocalHeap\n"));
    336414    }
    337     else 
     415    else
    338416    if (IsEqualIID(&(lpData->guidInfo), &GUID_GetHeapAlignment))
    339417    {
    340418        DISPDBG((0, " -> GUID_GetHeapAlignment\n"));
    341419    }
    342     else 
     420    else
    343421    if (IsEqualIID(&(lpData->guidInfo), &GUID_NTPrivateDriverCaps))
    344422    {
     
    358436        lpData->ddRVal = DD_OK;
    359437    }
    360     else 
     438    else
    361439    if (IsEqualIID(&(lpData->guidInfo), &GUID_DDMoreSurfaceCaps))
    362440    {
     
    395473        lpData->ddRVal = DD_OK;
    396474    }
    397     else 
     475    else
    398476    if (IsEqualIID(&(lpData->guidInfo), &GUID_DDStereoMode))
    399477    {
    400478        DISPDBG((0, " -> GUID_DDStereoMode\n"));
    401479    }
    402     else 
     480    else
    403481    if (IsEqualIID(&(lpData->guidInfo), &GUID_NonLocalVidMemCaps))
    404482    {
    405483        DISPDBG((0, " -> GUID_NonLocalVidMemCaps\n"));
    406     } 
    407     else 
     484    }
     485    else
    408486    if (IsEqualIID(&lpData->guidInfo, &GUID_NTCallbacks))
    409487    {
     
    475553/**
    476554 * DdCreateSurface
    477  * 
     555 *
    478556 * The DdCreateSurface callback function creates a DirectDraw surface.
    479  * 
     557 *
    480558 * lpCreateSurface
    481559 *     Points to a DD_CREATESURFACEDATA structure that contains the information required to create a surface.
    482  * 
     560 *
    483561 * Return Value
    484  * 
     562 *
    485563 * DdCreateSurface returns one of the following callback codes:
    486564 * DDHAL_DRIVER_HANDLED
    487565 * DDHAL_DRIVER_NOTHANDLED
    488  * 
     566 *
    489567 */
    490568DWORD APIENTRY DdCreateSurface(PDD_CREATESURFACEDATA  lpCreateSurface)
     
    499577
    500578    lpSurfaceLocal                  = lpCreateSurface->lplpSList[0];
    501     lpSurfaceGlobal                 = lpSurfaceLocal->lpGbl;   
     579    lpSurfaceGlobal                 = lpSurfaceLocal->lpGbl;
    502580    lpSurfaceDesc                   = lpCreateSurface->lpDDSurfaceDesc;
    503581
     
    510588        lPitch = (lPitch + 31) & ~31;
    511589    }
    512     else 
     590    else
    513591    if (lpSurfaceDesc->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8)
    514592    {
     
    543621        lpSurfaceGlobal->fpVidMem       = DDHAL_PLEASEALLOC_BLOCKSIZE;
    544622    }
    545    
     623
    546624    lpSurfaceDesc->lPitch   = lpSurfaceGlobal->lPitch;
    547625    lpSurfaceDesc->dwFlags |= DDSD_PITCH;
     
    553631/**
    554632 * DdCanCreateSurface
    555  * 
     633 *
    556634 * The DdCanCreateSurface callback function indicates whether the driver can create a surface of the specified surface description.
    557  * 
    558  * 
     635 *
     636 *
    559637 * Parameters
    560638 * lpCanCreateSurface
    561639 *     Points to the DD_CANCREATESURFACEDATA structure containing the information required for the driver to determine whether a surface can be created.
    562  * 
     640 *
    563641 * Return Value
    564  * 
     642 *
    565643 * DdCanCreateSurface returns one of the following callback codes:
    566  * 
     644 *
    567645 * DDHAL_DRIVER_HANDLED
    568646 * DDHAL_DRIVER_NOTHANDLED
     
    590668    }
    591669
     670#ifndef VBOX_WITH_VIDEOHWACCEL
    592671    if (lpCanCreateSurface->bIsDifferentPixelFormat && (lpDDS->ddpfPixelFormat.dwFlags & DDPF_FOURCC))
    593672    {
     
    596675        return DDHAL_DRIVER_HANDLED;
    597676    }
     677#else
     678    /* TODO: filter out unsupported formats */
     679#endif
    598680
    599681    lpCanCreateSurface->ddRVal = DD_OK;
     
    605687// DdMapMemory
    606688//
    607 // Maps application-modifiable portions of the frame buffer into the 
     689// Maps application-modifiable portions of the frame buffer into the
    608690// user-mode address space of the specified process, or unmaps memory.
    609691//
    610 // DdMapMemory is called to perform memory mapping before the first call to 
    611 // DdLock. The handle returned by the driver in fpProcess will be passed to 
    612 // every DdLock call made on the driver. 
    613 //
    614 // DdMapMemory is also called to unmap memory after the last DdUnLock call is 
     692// DdMapMemory is called to perform memory mapping before the first call to
     693// DdLock. The handle returned by the driver in fpProcess will be passed to
     694// every DdLock call made on the driver.
     695//
     696// DdMapMemory is also called to unmap memory after the last DdUnLock call is
    615697// made.
    616698//
     
    619701//
    620702// Parameters
    621 //      lpMapMemory 
    622 //          Points to a DD_MAPMEMORYDATA structure that contains details for 
    623 //          the memory mapping or unmapping operation. 
    624 //
    625 //          .lpDD 
    626 //              Points to a DD_DIRECTDRAW_GLOBAL structure that represents 
    627 //              the driver. 
    628 //          .bMap 
    629 //              Specifies the memory operation that the driver should perform. 
    630 //              A value of TRUE indicates that the driver should map memory; 
    631 //              FALSE means that the driver should unmap memory. 
    632 //          .hProcess 
    633 //              Specifies a handle to the process whose address space is 
    634 //              affected. 
    635 //          .fpProcess 
    636 //              Specifies the location in which the driver should return the 
    637 //              base address of the process's memory mapped space when bMap 
    638 //              is TRUE. When bMap is FALSE, fpProcess contains the base 
     703//      lpMapMemory
     704//          Points to a DD_MAPMEMORYDATA structure that contains details for
     705//          the memory mapping or unmapping operation.
     706//
     707//          .lpDD
     708//              Points to a DD_DIRECTDRAW_GLOBAL structure that represents
     709//              the driver.
     710//          .bMap
     711//              Specifies the memory operation that the driver should perform.
     712//              A value of TRUE indicates that the driver should map memory;
     713//              FALSE means that the driver should unmap memory.
     714//          .hProcess
     715//              Specifies a handle to the process whose address space is
     716//              affected.
     717//          .fpProcess
     718//              Specifies the location in which the driver should return the
     719//              base address of the process's memory mapped space when bMap
     720//              is TRUE. When bMap is FALSE, fpProcess contains the base
    639721//              address of the memory to be unmapped by the driver.
    640 //          .ddRVal 
    641 //              Specifies the location in which the driver writes the return 
    642 //              value of the DdMapMemory callback. A return code of DD_OK 
    643 //              indicates success. 
     722//          .ddRVal
     723//              Specifies the location in which the driver writes the return
     724//              value of the DdMapMemory callback. A return code of DD_OK
     725//              indicates success.
    644726//
    645727//-----------------------------------------------------------------------------
     
    683765
    684766            lpMapMemory->ddRVal = DDERR_GENERIC;
    685      
     767
    686768            DISPDBG((0, "DdMapMemory: Exit GEN, DDHAL_DRIVER_HANDLED\n"));
    687            
     769
    688770            return(DDHAL_DRIVER_HANDLED);
    689771        }
    690772
    691         lpMapMemory->fpProcess = 
     773        lpMapMemory->fpProcess =
    692774                            (FLATPTR) ShareMemoryInformation.VirtualAddress;
    693775    }
     
    718800/**
    719801 * DdLock
    720  * 
     802 *
    721803 * The DdLock callback function locks a specified area of surface memory and provides a valid pointer to a block of memory associated with a surface.
    722  * 
     804 *
    723805 * Parameters
    724806 * lpLock
    725807 *     Points to a DD_LOCKDATA structure that contains the information required to perform the lockdown.
    726  * 
     808 *
    727809 * Return Value
    728  * 
     810 *
    729811 * DdLock returns one of the following callback codes:
    730  * 
     812 *
    731813 * DDHAL_DRIVER_HANDLED
    732814 * DDHAL_DRIVER_NOTHANDLED
     
    736818{
    737819    PPDEV pDev = (PPDEV)lpLock->lpDD->dhpdev;
    738    
     820
    739821    PDD_SURFACE_LOCAL lpSurfaceLocal = lpLock->lpDDSurface;
    740822
     
    774856/**
    775857 * DdUnlock
    776  * 
     858 *
    777859 * The DdUnLock callback function releases the lock held on the specified surface.
    778  * 
     860 *
    779861 * Parameters
    780862 * lpUnlock
    781  *     Points to a DD_UNLOCKDATA structure that contains the information required to perform the lock release. * 
    782  * 
     863 *     Points to a DD_UNLOCKDATA structure that contains the information required to perform the lock release. *
     864 *
    783865 * Return Value
    784  * 
     866 *
    785867 * DdLock returns one of the following callback codes:
    786  * 
     868 *
    787869 * DDHAL_DRIVER_HANDLED
    788870 * DDHAL_DRIVER_NOTHANDLED
     
    797879    {
    798880        DISPDBG((0, "%d,%d %dx%d\n", pDev->ddLock.rArea.left, pDev->ddLock.rArea.top, pDev->ddLock.rArea.right - pDev->ddLock.rArea.left, pDev->ddLock.rArea.bottom - pDev->ddLock.rArea.top));
    799        
     881
    800882#ifndef VBOX_WITH_HGSMI
    801883        if (pDev->pInfo && vboxHwBufferBeginUpdate (pDev))
     
    853935/**
    854936 * DdDestroySurface
    855  * 
     937 *
    856938 * The DdDestroySurface callback function destroys a DirectDraw surface.
    857  * 
     939 *
    858940 * Parameters
    859941 * lpDestroySurface
    860942 *     Points to a DD_DESTROYSURFACEDATA structure that contains the information needed to destroy a surface.
    861  * 
     943 *
    862944 * Return Value
    863  * 
     945 *
    864946 * DdDestroySurface returns one of the following callback codes:
    865  * 
     947 *
    866948 * DDHAL_DRIVER_HANDLED
    867949 * DDHAL_DRIVER_NOTHANDLED
     
    9571039}
    9581040
     1041#ifdef VBOX_WITH_VIDEOHWACCEL
     1042DWORD APIENTRY DdSetColorKey(PDD_SETCOLORKEYDATA  lpSetColorKey)
     1043{
     1044    DISPDBG((0, "%s\n", __FUNCTION__));
     1045    lpSetColorKey->ddRVal = DD_OK;
     1046    return DDHAL_DRIVER_HANDLED;
     1047}
     1048
     1049DWORD APIENTRY DdAddAttachedSurface(PDD_ADDATTACHEDSURFACEDATA  lpAddAttachedSurface)
     1050{
     1051    DISPDBG((0, "%s\n", __FUNCTION__));
     1052    lpAddAttachedSurface->ddRVal = DD_OK;
     1053    return DDHAL_DRIVER_HANDLED;
     1054}
     1055
     1056DWORD APIENTRY DdBlt(PDD_BLTDATA  lpBlt)
     1057{
     1058    DISPDBG((0, "%s\n", __FUNCTION__));
     1059    lpBlt->ddRVal = DD_OK;
     1060    return DDHAL_DRIVER_HANDLED;
     1061}
     1062
     1063//DWORD APIENTRY DdDestroySurface(PDD_DESTROYSURFACEDATA  lpDestroySurface)
     1064//{
     1065//    DISPDBG((0, "%s\n", __FUNCTION__));
     1066//    lpDestroySurface->ddRVal = DD_OK;
     1067//    return DDHAL_DRIVER_HANDLED;
     1068//}
     1069
     1070DWORD APIENTRY DdFlip(PDD_FLIPDATA  lpFlip)
     1071{
     1072    DISPDBG((0, "%s\n", __FUNCTION__));
     1073    lpFlip->ddRVal = DD_OK;
     1074    return DDHAL_DRIVER_HANDLED;
     1075}
     1076
     1077DWORD APIENTRY DdGetBltStatus(PDD_GETBLTSTATUSDATA  lpGetBltStatus)
     1078{
     1079    DISPDBG((0, "%s\n", __FUNCTION__));
     1080
     1081    if(lpGetBltStatus->dwFlags == DDGBS_CANBLT)
     1082    {
     1083        lpGetBltStatus->ddRVal = DD_OK;
     1084    }
     1085    else
     1086    {
     1087        lpGetBltStatus->ddRVal = DD_OK;
     1088    }
     1089
     1090    return DDHAL_DRIVER_HANDLED;
     1091}
     1092
     1093DWORD APIENTRY DdGetFlipStatus(PDD_GETFLIPSTATUSDATA  lpGetFlipStatus)
     1094{
     1095    DISPDBG((0, "%s\n", __FUNCTION__));
     1096    if(lpGetFlipStatus->dwFlags == DDGFS_CANFLIP)
     1097    {
     1098        lpGetFlipStatus->ddRVal = DD_OK;
     1099    }
     1100    else
     1101    {
     1102        lpGetFlipStatus->ddRVal = DD_OK;
     1103    }
     1104
     1105    return DDHAL_DRIVER_HANDLED;
     1106}
     1107
     1108DWORD APIENTRY DdSetOverlayPosition(PDD_SETOVERLAYPOSITIONDATA  lpSetOverlayPosition)
     1109{
     1110    DISPDBG((0, "%s\n", __FUNCTION__));
     1111
     1112    lpSetOverlayPosition->ddRVal = DD_OK;
     1113    return DDHAL_DRIVER_HANDLED;
     1114}
     1115
     1116DWORD APIENTRY DdUpdateOverlay(PDD_UPDATEOVERLAYDATA  lpUpdateOverlay)
     1117{
     1118    DISPDBG((0, "%s\n", __FUNCTION__));
     1119
     1120    lpUpdateOverlay->ddRVal = DD_OK;
     1121    return DDHAL_DRIVER_HANDLED;
     1122}
     1123
     1124//-----------------------------------------------------------------------------
     1125// setupRops
     1126//
     1127// Build array for supported ROPS
     1128//-----------------------------------------------------------------------------
     1129static void
     1130setupRops(
     1131    LPBYTE proplist,
     1132    LPDWORD proptable,
     1133    int cnt )
     1134{
     1135    int         i;
     1136    DWORD       idx;
     1137    DWORD       bit;
     1138    DWORD       rop;
     1139
     1140    for(i=0; i<cnt; i++)
     1141    {
     1142        rop = proplist[i];
     1143        idx = rop / 32;
     1144        bit = 1L << ((DWORD)(rop % 32));
     1145        proptable[idx] |= bit;
     1146    }
     1147
     1148} // setupRops
     1149
     1150//-----------------------------------------------------------------------------
     1151//
     1152// Function: __GetDDHALInfo
     1153//
     1154// Returns: void
     1155//
     1156// Description:
     1157//
     1158// Takes a pointer to a partially or fully filled in pThisDisplay and a pointer
     1159// to an empty DDHALINFO and fills in the DDHALINFO.  This eases porting to NT
     1160// and means that caps changes are done in only one place.  The pThisDisplay
     1161// may not be fully constructed here, so you should only:
     1162// a) Query the registry
     1163// b) DISPDBG
     1164// If you need to add anything to pThisDisplay for NT, you should fill it in
     1165// during the DrvGetDirectDraw call.
     1166//
     1167// The problem here is when the code is run on NT.  If there was any other way...
     1168//
     1169// The following caps have been found to cause NT to bail....
     1170// DDCAPS_GDI, DDFXCAPS_BLTMIRRORUPDOWN, DDFXCAPS_BLTMIRRORLEFTRIGHT
     1171//
     1172//
     1173//-----------------------------------------------------------------------------
     1174
     1175//
     1176// use bits to indicate which ROPs you support.
     1177//
     1178// DWORD 0, bit 0 == ROP 0
     1179// DWORD 8, bit 31 == ROP 255
     1180//
     1181
     1182//static DWORD ropsAGP[DD_ROP_SPACE] = { 0 };
     1183static BYTE ropListNT[] =
     1184{
     1185    SRCCOPY >> 16
     1186//        WHITENESS >> 16,
     1187//        BLACKNESS >> 16
     1188};
     1189
     1190static DWORD rops[DD_ROP_SPACE] = { 0 };
     1191
     1192void
     1193getDDHALInfo(
     1194    PPDEV pDev,
     1195    DD_HALINFO* pHALInfo)
     1196{
     1197    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
     1211//                                | DDCAPS_READSCANLINE
     1212                                ;
     1213
     1214    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;
     1224    pHALInfo->ddCaps.dwCaps2 = 0;
     1225
     1226//#if DX7_TEXMANAGEMENT
     1227    // We need to set this bit up in order to be able to do
     1228    // out own texture management
     1229//    pHALInfo->ddCaps.dwCaps2 |= DDCAPS2_CANMANAGETEXTURE;
     1230//#if DX8_DDI
     1231//    pHALInfo->ddCaps.dwCaps2 |= DDCAPS2_CANMANAGERESOURCE;
     1232//#endif
     1233//#endif
     1234
     1235//#if DX8_DDI
     1236    // We need to flag we can run in windowed mode, otherwise we
     1237    // might get restricted by apps to run in fullscreen only
     1238    pHALInfo->ddCaps.dwCaps2 |= DDCAPS2_CANRENDERWINDOWED;
     1239//#endif
     1240
     1241//#if DX8_DDI
     1242    // We need to flag we support dynamic textures. That is , apps can
     1243        // lock with high frequency video memory textures without paying a
     1244        // penalty for it. Since on this sample driver we only support
     1245        // linear memory formats for textures we don't need to do anything
     1246        // else for this support. Otherwise we would have to keep two surfaces
     1247        // for textures created with the DDSCAPS2_HINTDYNAMIC hint in order
     1248        // to efficiently do the linear<->swizzled transformation or keep the
     1249        // texture permanantly in an unswizzled state.
     1250//        pHALInfo->ddCaps.dwCaps2 |= DDCAPS2_DYNAMICTEXTURES;
     1251    #if DX9_DDI
     1252        // Notice that dynamic textures MUST be supported in order to instantiate a DX9 device
     1253    #endif // DX9_DDI
     1254//#endif
     1255
     1256//    pHALInfo->ddCaps.dwFXCaps = 0;
     1257
     1258    // P3RX can do:
     1259    // 1. Stretching/Shrinking
     1260    // 2. YUV->RGB conversion
     1261    // 3. Mirroring in X and Y
     1262    // 4. ColorKeying from a source color and a source color space
     1263    pHALInfo->ddCaps.dwCaps |= DDCAPS_BLTSTRETCH
     1264                               | DDCAPS_BLTFOURCC
     1265                               | DDCAPS_COLORKEY
     1266//                               | 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
     1285//    pHALInfo->ddCaps.dwSVBCaps = DDCAPS_BLT;
     1286
     1287//    // We can do a texture from sysmem to video mem.
     1288//    pHALInfo->ddCaps.dwSVBCKeyCaps |= DDCKEYCAPS_DESTBLT         |
     1289//                                     DDCKEYCAPS_DESTBLTCLRSPACE;
     1290    pHALInfo->ddCaps.dwSVBFXCaps = 0;
     1291
     1292//    // Fill in the sysmem->vidmem rops (only can copy);
     1293//    for( i=0;i<DD_ROP_SPACE;i++ )
     1294//    {
     1295//        pHALInfo->ddCaps.dwSVBRops[i] = rops[i];
     1296//    }
     1297
     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;
     1305
     1306//#if DX7_STEREO
     1307//    // Report the stereo capability back to runtime
     1308//    pHALInfo->ddCaps.dwCaps2 |= DDCAPS2_STEREO;
     1309//    pHALInfo->ddCaps.dwSVCaps = DDSVCAPS_STEREOSEQUENTIAL;
     1310//#endif
     1311
     1312    // Z Buffer is only 16 Bits
     1313//    pHALInfo->ddCaps.dwZBufferBitDepths = DDBD_16;
     1314//    pHALInfo->ddCaps.ddsCaps.dwCaps |= DDSCAPS_MIPMAP;
     1315
     1316        pHALInfo->ddCaps.ddsCaps.dwCaps |= DDSCAPS_LOCALVIDMEM;
     1317
     1318    {
     1319//#ifdef SUPPORT_VIDEOPORT
     1320//        // We support 1 video port.  Must set CurrVideoPorts to 0
     1321//        // We can't do interleaved bobbing yet - maybe in the future.
     1322//        pHALInfo->ddCaps.dwCaps2 |= DDCAPS2_VIDEOPORT            |
     1323//                                    DDCAPS2_CANBOBNONINTERLEAVED;
     1324//
     1325//        pHALInfo->ddCaps.dwMaxVideoPorts = 1;
     1326//        pHALInfo->ddCaps.dwCurrVideoPorts = 0;
     1327//
     1328//
     1329//#endif // SUPPORT_VIDEOPORT
     1330
     1331
     1332        {
     1333            // Overlay is free to use.
     1334            pHALInfo->ddCaps.dwMaxVisibleOverlays = 1;
     1335            pHALInfo->ddCaps.dwCurrVisibleOverlays = 0;
     1336
     1337            pHALInfo->ddCaps.dwCaps |=  DDCAPS_OVERLAY          |
     1338                                        DDCAPS_OVERLAYFOURCC    |
     1339                                        DDCAPS_OVERLAYSTRETCH   |
     1340                                        DDCAPS_COLORKEYHWASSIST |
     1341                                        DDCAPS_OVERLAYCANTCLIP;
     1342
     1343            pHALInfo->ddCaps.dwCKeyCaps |= DDCKEYCAPS_SRCOVERLAY           |
     1344                                           DDCKEYCAPS_SRCOVERLAYONEACTIVE  |
     1345                                           DDCKEYCAPS_SRCOVERLAYYUV        |
     1346                                           DDCKEYCAPS_DESTOVERLAY          |
     1347                                           DDCKEYCAPS_DESTOVERLAYONEACTIVE |
     1348                                           DDCKEYCAPS_DESTOVERLAYYUV;
     1349
     1350            pHALInfo->ddCaps.ddsCaps.dwCaps |= DDSCAPS_OVERLAY;
     1351
     1352            pHALInfo->ddCaps.dwFXCaps |= DDFXCAPS_OVERLAYSHRINKX   |
     1353                                         DDFXCAPS_OVERLAYSHRINKXN  |
     1354                                         DDFXCAPS_OVERLAYSHRINKY   |
     1355                                         DDFXCAPS_OVERLAYSHRINKYN  |
     1356                                         DDFXCAPS_OVERLAYSTRETCHX  |
     1357                                         DDFXCAPS_OVERLAYSTRETCHXN |
     1358                                         DDFXCAPS_OVERLAYSTRETCHY  |
     1359                                         DDFXCAPS_OVERLAYSTRETCHYN;
     1360
     1361            // Indicates that Perm3 has no stretch ratio limitation
     1362            pHALInfo->ddCaps.dwMinOverlayStretch = 1;
     1363            pHALInfo->ddCaps.dwMaxOverlayStretch = 32000;
     1364        }
     1365    }
     1366
     1367//#ifdef W95_DDRAW
     1368//#ifdef USE_DD_CONTROL_COLOR
     1369//    // Enable colour control asc brightness, contrast, gamma.
     1370//    pHALInfo->ddCaps.dwCaps2 |= DDCAPS2_COLORCONTROLPRIMARY;
     1371//#endif
     1372//#endif
     1373
     1374    // Also permit surfaces wider than the display buffer.
     1375    pHALInfo->ddCaps.dwCaps2 |= DDCAPS2_WIDESURFACES;
     1376
     1377    // Enable copy blts betweemn Four CC formats for DShow acceleration
     1378    pHALInfo->ddCaps.dwCaps2 |= DDCAPS2_COPYFOURCC;
     1379
     1380    // Won't do Video-Sys mem Blits.
     1381    pHALInfo->ddCaps.dwVSBCaps = 0;
     1382    pHALInfo->ddCaps.dwVSBCKeyCaps = 0;
     1383    pHALInfo->ddCaps.dwVSBFXCaps = 0;
     1384    for( i=0;i<DD_ROP_SPACE;i++ )
     1385    {
     1386        pHALInfo->ddCaps.dwVSBRops[i] = 0;
     1387    }
     1388
     1389    // Won't do Sys-Sys mem Blits
     1390    pHALInfo->ddCaps.dwSSBCaps = 0;
     1391    pHALInfo->ddCaps.dwSSBCKeyCaps = 0;
     1392    pHALInfo->ddCaps.dwSSBFXCaps = 0;
     1393    for( i=0;i<DD_ROP_SPACE;i++ )
     1394    {
     1395        pHALInfo->ddCaps.dwSSBRops[i] = 0;
     1396    }
     1397
     1398    //
     1399    // bit depths supported for alpha and Z
     1400    //
     1401//    pHALInfo->ddCaps.dwAlphaBltConstBitDepths = DDBD_2 |
     1402//                                                DDBD_4 |
     1403//                                                DDBD_8;
     1404//
     1405//    pHALInfo->ddCaps.dwAlphaBltPixelBitDepths = DDBD_1 |
     1406//                                                DDBD_8;
     1407//    pHALInfo->ddCaps.dwAlphaBltSurfaceBitDepths = DDBD_1 |
     1408//                                                  DDBD_2 |
     1409//                                                  DDBD_4 |
     1410//                                                  DDBD_8;
     1411
     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;
     1426
     1427    //
     1428    // ROPS supported
     1429    //
     1430    for( i=0;i<DD_ROP_SPACE;i++ )
     1431    {
     1432        pHALInfo->ddCaps.dwRops[i] = rops[i];
     1433    }
     1434
     1435//Reenable:    // For DX5 and beyond we support this new informational callback.
     1436//    pHALInfo->GetDriverInfo = DdGetDriverInfo;
     1437//    pHALInfo->dwFlags |= DDHALINFO_GETDRIVERINFOSET;
     1438//
     1439//#if DX8_DDI
     1440//    // Flag our support for a new class of GUIDs that may come through
     1441//    // GetDriverInfo for DX8 drivers. (This support will be compulsory)
     1442//    pHALInfo->dwFlags |= DDHALINFO_GETDRIVERINFO2;
     1443//#endif DX8_DDI
     1444
     1445
     1446} // getDDHALInfo
     1447
     1448
     1449#endif
     1450
     1451
    9591452
    9601453#endif /* VBOX_WITH_DDRAW */
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/dd.h

    r8387 r19515  
    3939DWORD CALLBACK DdMapMemory(PDD_MAPMEMORYDATA lpMapMemory);
    4040
     41#ifdef VBOX_WITH_VIDEOHWACCEL
     42DWORD APIENTRY DdSetColorKey(PDD_SETCOLORKEYDATA  lpSetColorKey);
     43DWORD APIENTRY DdAddAttachedSurface(PDD_ADDATTACHEDSURFACEDATA  lpAddAttachedSurface);
     44DWORD APIENTRY DdBlt(PDD_BLTDATA  lpBlt);
     45DWORD APIENTRY DdDestroySurface(PDD_DESTROYSURFACEDATA  lpDestroySurface);
     46DWORD APIENTRY DdFlip(PDD_FLIPDATA  lpFlip);
     47DWORD APIENTRY DdGetBltStatus(PDD_GETBLTSTATUSDATA  lpGetBltStatus);
     48DWORD APIENTRY DdGetFlipStatus(PDD_GETFLIPSTATUSDATA  lpGetFlipStatus);
     49DWORD APIENTRY DdSetOverlayPosition(PDD_SETOVERLAYPOSITIONDATA  lpSetOverlayPosition);
     50DWORD APIENTRY DdUpdateOverlay(PDD_UPDATEOVERLAYDATA  lpUpdateOverlay);
     51#endif
     52
    4153#endif /* __VBOX_DD_H__*/
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