VirtualBox

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


Ignore:
Timestamp:
Jun 18, 2009 11:18:42 AM (16 years ago)
Author:
vboxsync
Message:

video hw accel: ddraw command processing fixes

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

Legend:

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

    r20653 r20683  
    610610
    611611#ifdef VBOX_WITH_VIDEOHWACCEL
    612     if(pDev->vhwaInfo.bVHWAEnabled && lpSurfaceLocal->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
    613     {
    614         lBpp = pDev->ulBitCount;
    615         lPitch = pDev->lDeltaScreen;
    616     }
    617     else
    618 #endif
    619     {
    620     lpSurfaceGlobal->dwReserved1    = 0;
    621 
    622     if (lpSurfaceDesc->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED4)
    623     {
    624         lBpp = 4;
    625         lPitch = lpSurfaceGlobal->wWidth/2;
    626         lPitch = (lPitch + 31) & ~31;
    627     }
    628     else
    629     if (lpSurfaceDesc->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8)
    630     {
    631         lBpp = 8;
    632         lPitch = lpSurfaceGlobal->wWidth;
    633         lPitch = (lPitch + 31) & ~31;
    634     }
    635     else
    636     {
    637         lBpp   = lpSurfaceDesc->ddpfPixelFormat.dwRGBBitCount;
    638         lPitch = lpSurfaceGlobal->wWidth*(lBpp/8);
    639     }
    640     DISPDBG((0, "New surface (%d,%d)\n", lpSurfaceGlobal->wWidth, lpSurfaceGlobal->wHeight));
    641     DISPDBG((0, "BPP %d lPitch=%d\n", lBpp, lPitch));
    642 
    643     lpSurfaceGlobal->dwBlockSizeX   = lPitch;
    644     lpSurfaceGlobal->dwBlockSizeY   = lpSurfaceGlobal->wHeight;
    645     lpSurfaceGlobal->lPitch         = lPitch;
    646 
    647     lpSurfaceDesc->lPitch   = lpSurfaceGlobal->lPitch;
    648     lpSurfaceDesc->dwFlags |= DDSD_PITCH;
    649     }
    650 
    651     //
    652     // Modify surface descriptions as appropriate and let Direct
    653     // Draw perform the allocation if the surface was not the primary
    654     //
    655     if (lpSurfaceLocal->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
    656     {
    657         DISPDBG((0, "-> primary surface\n"));
    658         lpSurfaceGlobal->fpVidMem       = 0;
    659     }
    660     else
    661     {
    662         DISPDBG((0, "-> secondary surface\n"));
    663         lpSurfaceGlobal->fpVidMem       = DDHAL_PLEASEALLOC_BLOCKSIZE;
    664     }
    665 
    666 #ifdef VBOX_WITH_VIDEOHWACCEL
    667612    if(pDev->vhwaInfo.bVHWAEnabled)
    668613    {
    669         VBOXVHWACMD* pCmd = vboxVHWACommandCreate (pDev, VBOXVHWACMD_TYPE_SURF_CREATE, sizeof(VBOXVHWACMD_SURF_CREATE));
     614        VBOXVHWACMD* pCmd;
     615        DDPIXELFORMAT * pFormat = &lpSurfaceGlobal->ddpfSurface;
     616
     617        if(lpSurfaceLocal->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
     618        {
     619            lBpp = pDev->ulBitCount;
     620            lPitch = pDev->lDeltaScreen;
     621        }
     622        else
     623        {
     624            if (pFormat->dwFlags & DDPF_PALETTEINDEXED4)
     625            {
     626                lBpp = 4;
     627                lPitch = lpSurfaceGlobal->wWidth/2;
     628                lPitch = (lPitch + 31) & ~31;
     629            }
     630            else
     631            if (pFormat->dwFlags & DDPF_PALETTEINDEXED8)
     632            {
     633                lBpp = 8;
     634                lPitch = lpSurfaceGlobal->wWidth;
     635                lPitch = (lPitch + 31) & ~31;
     636            }
     637            else
     638            {
     639                lBpp   = pFormat->dwRGBBitCount;
     640                lPitch = lpSurfaceGlobal->wWidth*(lBpp/8);
     641            }
     642        }
     643
     644        DISPDBG((0, "New surface (%d,%d)\n", lpSurfaceGlobal->wWidth, lpSurfaceGlobal->wHeight));
     645        DISPDBG((0, "BPP %d lPitch=%d\n", lBpp, lPitch));
     646#if 0
     647        lpSurfaceGlobal->dwBlockSizeX   = lPitch;
     648        lpSurfaceGlobal->dwBlockSizeY   = lpSurfaceGlobal->wHeight;
     649        lpSurfaceGlobal->lPitch         = lPitch;
     650#else
     651        lpSurfaceGlobal->dwBlockSizeX   = lPitch * lpSurfaceGlobal->wHeight;
     652        lpSurfaceGlobal->dwBlockSizeY   = 1;
     653        lpSurfaceGlobal->lPitch         = lPitch;
     654#endif
     655
     656#if 0
     657        lpSurfaceDesc->lPitch   = lpSurfaceGlobal->lPitch;
     658        lpSurfaceDesc->dwFlags |= DDSD_PITCH;
     659#endif
     660
     661        //
     662        // Modify surface descriptions as appropriate and let Direct
     663        // Draw perform the allocation if the surface was not the primary
     664        //
     665        if (lpSurfaceLocal->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
     666        {
     667            DISPDBG((0, "-> primary surface\n"));
     668            lpSurfaceGlobal->fpVidMem       = 0;
     669        }
     670        else
     671        {
     672            DISPDBG((0, "-> secondary surface\n"));
     673            lpSurfaceGlobal->fpVidMem       = DDHAL_PLEASEALLOC_BLOCKSIZE;
     674        }
     675
     676        pCmd = vboxVHWACommandCreate (pDev, VBOXVHWACMD_TYPE_SURF_CREATE, sizeof(VBOXVHWACMD_SURF_CREATE));
    670677        if(pCmd)
    671678        {
    672679            VBOXVHWACMD_SURF_CREATE * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_CREATE);
    673680            PVBOXVHWASURFDESC pDesc;
     681            int rc;
     682
    674683            memset(pBody, 0, sizeof(VBOXVHWACMD_SURF_CREATE));
    675684
     685            rc = vboxVHWAFromDDSURFACEDESC(&pBody->u.in.SurfInfo, lpSurfaceDesc);
     686
    676687            pBody->u.in.SurfInfo.surfCaps = vboxVHWAFromDDSCAPS(lpSurfaceLocal->ddsCaps.dwCaps);
     688            pBody->u.in.SurfInfo.flags |= DDSD_CAPS;
    677689
    678690            pBody->u.in.SurfInfo.height = lpSurfaceGlobal->wHeight;
    679691            pBody->u.in.SurfInfo.width = lpSurfaceGlobal->wWidth;
    680 
    681             vboxVHWAFromDDPIXELFORMAT(&pBody->u.in.SurfInfo.PixelFormat, &lpSurfaceGlobal->ddpfSurface);
     692            pBody->u.in.SurfInfo.flags |= DDSD_HEIGHT | DDSD_WIDTH;
     693
     694            vboxVHWAFromDDPIXELFORMAT(&pBody->u.in.SurfInfo.PixelFormat, pFormat);
     695            pBody->u.in.SurfInfo.flags |= VBOXVHWA_SD_PIXELFORMAT;
    682696
    683697            if (lpSurfaceLocal->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
     
    696710                pDesc->cBitsPerPixel = lBpp;
    697711                vboxVHWACommandSubmit(pDev, pCmd);
     712                Assert(pCmd->rc == VINF_SUCCESS);
    698713                if(pCmd->rc == VINF_SUCCESS)
    699714                {
     
    710725            vboxVHWACommandFree(pDev, pCmd);
    711726        }
    712     }
    713 #endif
     727        return DDHAL_DRIVER_NOTHANDLED;
     728    }
     729#endif
     730    lpSurfaceGlobal->dwReserved1    = 0;
     731
     732    if (lpSurfaceDesc->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED4)
     733    {
     734        lBpp = 4;
     735        lPitch = lpSurfaceGlobal->wWidth/2;
     736        lPitch = (lPitch + 31) & ~31;
     737    }
     738    else
     739    if (lpSurfaceDesc->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8)
     740    {
     741        lBpp = 8;
     742        lPitch = lpSurfaceGlobal->wWidth;
     743        lPitch = (lPitch + 31) & ~31;
     744    }
     745    else
     746    {
     747        lBpp   = lpSurfaceDesc->ddpfPixelFormat.dwRGBBitCount;
     748        lPitch = lpSurfaceGlobal->wWidth*(lBpp/8);
     749    }
     750    DISPDBG((0, "New surface (%d,%d)\n", lpSurfaceGlobal->wWidth, lpSurfaceGlobal->wHeight));
     751    DISPDBG((0, "BPP %d lPitch=%d\n", lBpp, lPitch));
     752
     753    lpSurfaceGlobal->dwBlockSizeX   = lPitch;
     754    lpSurfaceGlobal->dwBlockSizeY   = lpSurfaceGlobal->wHeight;
     755    lpSurfaceGlobal->lPitch         = lPitch;
     756
     757    lpSurfaceDesc->lPitch   = lpSurfaceGlobal->lPitch;
     758    lpSurfaceDesc->dwFlags |= DDSD_PITCH;
     759
     760    //
     761    // Modify surface descriptions as appropriate and let Direct
     762    // Draw perform the allocation if the surface was not the primary
     763    //
     764    if (lpSurfaceLocal->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
     765    {
     766        DISPDBG((0, "-> primary surface\n"));
     767        lpSurfaceGlobal->fpVidMem       = 0;
     768    }
     769    else
     770    {
     771        DISPDBG((0, "-> secondary surface\n"));
     772        lpSurfaceGlobal->fpVidMem       = DDHAL_PLEASEALLOC_BLOCKSIZE;
     773    }
     774
    714775    return DDHAL_DRIVER_NOTHANDLED;
    715776}
     
    741802    DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev));
    742803
    743     if (lpDDS->ddsCaps.dwCaps & DDSCAPS_ZBUFFER)
    744     {
    745         DISPDBG((0, "No Z-Bufer support\n"));
    746         lpCanCreateSurface->ddRVal = DDERR_INVALIDPIXELFORMAT;
    747         return DDHAL_DRIVER_HANDLED;
    748     }
    749     if (lpDDS->ddsCaps.dwCaps & DDSCAPS_TEXTURE)
    750     {
    751         DISPDBG((0, "No texture support\n"));
    752         lpCanCreateSurface->ddRVal = DDERR_INVALIDPIXELFORMAT;
    753         return DDHAL_DRIVER_HANDLED;
    754     }
    755 
    756804#ifdef VBOX_WITH_VIDEOHWACCEL
    757805    if(pDev->vhwaInfo.bVHWAEnabled)
     
    759807        VBOXVHWACMD* pCmd;
    760808        uint32_t unsupportedSCaps = vboxVHWAUnsupportedDDSCAPS(lpDDS->ddsCaps.dwCaps);
     809        Assert(!unsupportedSCaps);
    761810        if(unsupportedSCaps)
    762811        {
     
    767816
    768817        unsupportedSCaps = vboxVHWAUnsupportedDDPFS(lpDDS->ddpfPixelFormat.dwFlags);
     818        Assert(!unsupportedSCaps);
    769819        if(unsupportedSCaps)
    770820        {
     
    777827        if(pCmd)
    778828        {
     829            int rc;
    779830            VBOXVHWACMD_SURF_CANCREATE * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_CANCREATE);
    780831            memset(pBody, 0, sizeof(VBOXVHWACMD_SURF_CANCREATE));
    781832
    782             pBody->u.in.SurfInfo.surfCaps = vboxVHWAFromDDSCAPS(lpDDS->ddsCaps.dwCaps);
    783 
    784             pBody->u.in.SurfInfo.height = lpDDS->dwHeight;
    785             pBody->u.in.SurfInfo.width = lpDDS->dwWidth;
    786             vboxVHWAFromDDPIXELFORMAT(&pBody->u.in.SurfInfo.PixelFormat, &lpDDS->ddpfPixelFormat);
     833            rc = vboxVHWAFromDDSURFACEDESC(&pBody->u.in.SurfInfo, lpDDS);
     834            pBody->u.in.bIsDifferentPixelFormat = lpCanCreateSurface->bIsDifferentPixelFormat;
    787835
    788836            vboxVHWACommandSubmit(pDev, pCmd);
     
    790838            if(pCmd->rc == VINF_SUCCESS)
    791839            {
     840                Assert(!pBody->u.out.ErrInfo);
    792841                if(pBody->u.out.ErrInfo)
    793842                {
     
    812861    }
    813862#endif
     863
     864    if (lpDDS->ddsCaps.dwCaps & DDSCAPS_ZBUFFER)
     865    {
     866        DISPDBG((0, "No Z-Bufer support\n"));
     867        lpCanCreateSurface->ddRVal = DDERR_INVALIDPIXELFORMAT;
     868        return DDHAL_DRIVER_HANDLED;
     869    }
     870    if (lpDDS->ddsCaps.dwCaps & DDSCAPS_TEXTURE)
     871    {
     872        DISPDBG((0, "No texture support\n"));
     873        lpCanCreateSurface->ddRVal = DDERR_INVALIDPIXELFORMAT;
     874        return DDHAL_DRIVER_HANDLED;
     875    }
    814876    if (lpCanCreateSurface->bIsDifferentPixelFormat && (lpDDS->ddpfPixelFormat.dwFlags & DDPF_FOURCC))
    815877    {
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/driver.h

    r20653 r20683  
    315315uint32_t vboxVHWAFromDDPFS(uint32_t caps);
    316316uint32_t vboxVHWAToDDPFS(uint32_t caps);
    317 void vboxVHWAFromDDPIXELFORMAT(VBOXVHWA_PIXELFORMAT *pVHWAFormat, DDPIXELFORMAT *pDdFormat);
     317int vboxVHWAFromDDPIXELFORMAT(VBOXVHWA_PIXELFORMAT *pVHWAFormat, DDPIXELFORMAT *pDdFormat);
     318int vboxVHWAFromDDSURFACEDESC(VBOXVHWA_SURFACEDESC *pVHWADesc, DDSURFACEDESC *pDdDesc);
    318319void vboxVHWAFromRECTL(VBOXVHWA_RECTL *pDst, RECTL *pSrc);
    319320PVBOXVHWASURFDESC vboxVHWASurfDescAlloc();
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