VirtualBox

Changeset 32577 in vbox


Ignore:
Timestamp:
Sep 16, 2010 6:11:27 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
65970
Message:

wddm/3d: aero working on win7 (window contents still corrupted)

Location:
trunk/src/VBox/Additions/WINNT/Graphics
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp

    r32562 r32577  
    17471747    if (!pSwapchain)
    17481748    {
    1749 //        Assert(0);
     1749#ifdef DEBUG_misha
     1750        Assert(0);
     1751#endif
    17501752        /* first search for the swapchain the alloc might be added to */
    17511753        PVBOXWDDMDISP_SWAPCHAIN pCur = RTListNodeGetFirst(&pDevice->SwapchainList, VBOXWDDMDISP_SWAPCHAIN, ListEntry);
     
    17681770                                    || (pBbRc->fFlags == pRtRc->fFlags
    17691771                                            && pBbRc->RcDesc.enmPool == pRtRc->RcDesc.enmPool
    1770                                             && pBbRc->RcDesc.fFlags.Value == pRtRc->RcDesc.fFlags.Value
     1772//                                            && pBbRc->RcDesc.fFlags.Value == pRtRc->RcDesc.fFlags.Value
    17711773                                        )
    17721774                                ))
     
    23492351        {
    23502352            PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[i];
    2351             pAlloc->SurfDesc.width = 0x400;
    2352             pAlloc->SurfDesc.height = 0x300;
     2353            pAlloc->SurfDesc.width = 0x4;
     2354            pAlloc->SurfDesc.height = 0x4;
    23532355            pAlloc->SurfDesc.format = D3DDDIFMT_A8R8G8B8;
    23542356        }
     
    36143616    Assert(pSrcRc->RcDesc.enmPool == D3DDDIPOOL_SYSTEMMEM);
    36153617    Assert(pDstRc->RcDesc.enmPool != D3DDDIPOOL_SYSTEMMEM);
    3616     IDirect3DTexture9 *pD3DIfSrcTex = (IDirect3DTexture9*)pSrcRc->aAllocations[0].pD3DIf;
    3617     IDirect3DTexture9 *pD3DIfDstTex = (IDirect3DTexture9*)pDstRc->aAllocations[0].pD3DIf;
    3618     Assert(pD3DIfSrcTex);
    3619     Assert(pD3DIfDstTex);
    36203618    HRESULT hr = S_OK;
    36213619
    36223620    if (pSrcRc->aAllocations[0].SurfDesc.width == pDstRc->aAllocations[0].SurfDesc.width
    36233621            && pSrcRc->aAllocations[0].SurfDesc.height == pDstRc->aAllocations[0].SurfDesc.height
    3624             && pSrcRc->RcDesc.enmFormat == pDstRc->RcDesc.enmFormat)
    3625     {
    3626         /* first check if we can do IDirect3DDevice9::UpdateTexture */
    3627         if (pData->DstPoint.x == 0 && pData->DstPoint.y == 0
     3622            && pSrcRc->RcDesc.enmFormat == pDstRc->RcDesc.enmFormat
     3623                &&pData->DstPoint.x == 0 && pData->DstPoint.y == 0
    36283624                && pData->SrcRect.left == 0 && pData->SrcRect.top == 0
    36293625                && pData->SrcRect.right - pData->SrcRect.left == pSrcRc->aAllocations[0].SurfDesc.width
    36303626                && pData->SrcRect.bottom - pData->SrcRect.top == pSrcRc->aAllocations[0].SurfDesc.height)
    3631         {
    3632             hr = pDevice9If->UpdateTexture(pD3DIfSrcTex, pD3DIfDstTex);
     3627    {
     3628        IDirect3DTexture9 *pD3DIfSrcTex = (IDirect3DTexture9*)pSrcRc->aAllocations[0].pD3DIf;
     3629        IDirect3DTexture9 *pD3DIfDstTex = (IDirect3DTexture9*)pDstRc->aAllocations[0].pD3DIf;
     3630        Assert(pD3DIfSrcTex);
     3631        Assert(pD3DIfDstTex);
     3632        hr = pDevice9If->UpdateTexture(pD3DIfSrcTex, pD3DIfDstTex);
     3633        Assert(hr == S_OK);
     3634    }
     3635    else
     3636    {
     3637        IDirect3DSurface9 *pSrcSurfIf = NULL;
     3638        IDirect3DSurface9 *pDstSurfIf = NULL;
     3639        hr = vboxWddmSurfGet(pDstRc, 0, &pDstSurfIf);
     3640        Assert(hr == S_OK);
     3641        if (hr == S_OK)
     3642        {
     3643            hr = vboxWddmSurfGet(pSrcRc, 0, &pSrcSurfIf);
    36333644            Assert(hr == S_OK);
    3634         }
    3635         else
    3636         {
    3637             Assert(0);
    3638             /* @todo: impl */
    3639         }
    3640     }
    3641     else
    3642     {
    3643         Assert(0);
    3644         /* @todo: impl */
     3645            if (hr == S_OK)
     3646            {
     3647                RECT DstRect;
     3648                vboxWddmRectMoved(&DstRect, &pData->SrcRect, pData->DstPoint.x, pData->DstPoint.y);
     3649#ifdef DEBUG
     3650                RECT tstRect = {0,0, pDstRc->aAllocations[0].SurfDesc.width, pDstRc->aAllocations[0].SurfDesc.height};
     3651                Assert(vboxWddmRectIsCoveres(&tstRect, &DstRect));
     3652#endif
     3653                hr = pDevice9If->StretchRect(pSrcSurfIf, &pData->SrcRect, pDstSurfIf, &DstRect, D3DTEXF_NONE);
     3654                Assert(hr == S_OK);
     3655                pSrcSurfIf->Release();
     3656            }
     3657            pDstSurfIf->Release();
     3658        }
    36453659    }
    36463660
     
    47614775                            if (hr == S_OK)
    47624776                            {
     4777#if 0
    47634778                                if(pResource->Flags.Primary)
    47644779                                {
     
    47694784                                    Assert(bIssueCreateResource);
    47704785                                }
     4786#endif
    47714787                                continue;
    47724788                            }
     
    67526768                    }
    67536769#else
    6754 # define VBOXDISP_TEST_SWAPCHAIN
     6770//# define VBOXDISP_TEST_SWAPCHAIN
    67556771# ifdef VBOXDISP_TEST_SWAPCHAIN
    67566772                    VBOXDISP_D3DEV(pDevice);
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoIf.h

    r32496 r32577  
    419419}
    420420
    421 DECLINLINE(bool) vboxWddmRectIsEmpty(RECT * pRect)
     421DECLINLINE(bool) vboxWddmRectIsEmpty(const RECT * pRect)
    422422{
    423423    return pRect->left == pRect->right-1 && pRect->top == pRect->bottom-1;
    424424}
    425425
    426 DECLINLINE(bool) vboxWddmRectIsIntersect(RECT * pRect1, RECT * pRect2)
     426DECLINLINE(bool) vboxWddmRectIsIntersect(const RECT * pRect1, const RECT * pRect2)
    427427{
    428428    return !((pRect1->left < pRect2->left && pRect1->right < pRect2->left)
     
    432432}
    433433
    434 DECLINLINE(bool) vboxWddmRectIsInclude(RECT * pRect1, RECT * pRect2)
    435 {
    436     return ((pRect1->left <= pRect2->left && pRect1->right >= pRect2->right)
    437             && (pRect1->top <= pRect2->top && pRect1->bottom >= pRect2->bottom));
    438 }
    439 
    440434DECLINLINE(void) vboxWddmRectUnited(RECT * pDst, const RECT * pRect1, const RECT * pRect2)
    441435{
     
    452446    pRect->right  += x;
    453447    pRect->bottom += y;
     448}
     449
     450DECLINLINE(void) vboxWddmRectMove(RECT * pRect, int x, int y)
     451{
     452    LONG w = pRect->right - pRect->left;
     453    LONG h = pRect->bottom - pRect->top;
     454    pRect->left   = x;
     455    pRect->top    = y;
     456    pRect->right  = w + x;
     457    pRect->bottom = h + y;
     458}
     459
     460DECLINLINE(void) vboxWddmRectTranslated(RECT *pDst, const RECT * pRect, int x, int y)
     461{
     462    *pDst = *pRect;
     463    vboxWddmRectTranslate(pDst, x, y);
     464}
     465
     466DECLINLINE(void) vboxWddmRectMoved(RECT *pDst, const RECT * pRect, int x, int y)
     467{
     468    *pDst = *pRect;
     469    vboxWddmRectMove(pDst, x, y);
    454470}
    455471
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/context.c

    r32546 r32577  
    855855    context_validate(context
    856856#ifdef VBOXWDDM/* tmp work-around */
    857             , context->device->swapchains[context->device->NumberOfSwapChains-1]
     857            , (IWineD3DSwapChainImpl*)context->device->swapchains[context->device->NumberOfSwapChains-1]
    858858#endif
    859859            );
     
    12931293    HDC hdc;
    12941294
     1295#if defined(VBOXWDDM) && defined(DEBUG_misha)
     1296    Assert(0);
     1297#endif
     1298
    12951299    TRACE("swapchain %p, target %p, window %p.\n", swapchain, target, swapchain->win_handle);
    12961300
     
    15921596#ifdef VBOXWDDM
    15931597static void context_setup_target(IWineD3DDeviceImpl *device, struct wined3d_context *context, IWineD3DSurface *target);
     1598static void context_apply_state(struct wined3d_context *context, IWineD3DDeviceImpl *device, enum ContextUsage usage);
     1599
     1600BOOL context_acquire_context(struct wined3d_context * context, IWineD3DSurface *target, enum ContextUsage usage, BOOL bReValidate)
     1601{
     1602    IWineD3DDeviceImpl *device = context->device;
     1603    struct wined3d_context *current_context = context_get_current();
     1604    if (bReValidate)
     1605    {
     1606        IWineD3DSwapChain *swapchain = NULL;
     1607        if (target && SUCCEEDED(IWineD3DSurface_GetContainer(target, &IID_IWineD3DSwapChain, (void **)&swapchain))) {
     1608            context_validate(current_context, (IWineD3DSwapChainImpl*)swapchain);
     1609            IWineD3DSwapChain_Release(swapchain);
     1610        }
     1611        else {
     1612                                                                                                    /* tmp work-around */
     1613            context_validate(current_context, (IWineD3DSwapChainImpl*)current_context->device->swapchains[current_context->device->NumberOfSwapChains-1]);
     1614        }
     1615    }
     1616    context_setup_target(device, context, target);
     1617    context_enter(context);
     1618    Assert(context->valid);
     1619    if (!context->valid) return FALSE;
     1620
     1621    if (context != current_context)
     1622    {
     1623        if (!context_set_current(context)) ERR("Failed to activate the new context.\n");
     1624        else device->frag_pipe->enable_extension((IWineD3DDevice *)device, !context->last_was_blit);
     1625
     1626        if (context->vshader_const_dirty)
     1627        {
     1628            memset(context->vshader_const_dirty, 1,
     1629                    sizeof(*context->vshader_const_dirty) * device->d3d_vshader_constantF);
     1630            device->highest_dirty_vs_const = device->d3d_vshader_constantF;
     1631        }
     1632        if (context->pshader_const_dirty)
     1633        {
     1634            memset(context->pshader_const_dirty, 1,
     1635                   sizeof(*context->pshader_const_dirty) * device->d3d_pshader_constantF);
     1636            device->highest_dirty_ps_const = device->d3d_pshader_constantF;
     1637        }
     1638    }
     1639    else if (context->restore_ctx)
     1640    {
     1641        if (!pwglMakeCurrent(context->hdc, context->glCtx))
     1642        {
     1643            DWORD err = GetLastError();
     1644            ERR("Failed to make GL context %p current on device context %p, last error %#x.\n",
     1645                    context->hdc, context->glCtx, err);
     1646        }
     1647    }
     1648
     1649    context_apply_state(context, device, usage);
     1650
     1651    return TRUE;
     1652}
    15941653
    15951654struct wined3d_context *context_find_create(IWineD3DDeviceImpl *device, IWineD3DSwapChainImpl *swapchain, IWineD3DSurfaceImpl *target,
    15961655        const struct wined3d_format_desc *ds_format_desc)
    15971656{
    1598     int i;
     1657    UINT i;
    15991658    DWORD tid = GetCurrentThreadId();
    16001659    struct wined3d_context *context = NULL;
     
    16191678    else
    16201679    {
    1621         context_validate(context, swapchain);
    1622         context_setup_target(device, context, target);
    1623         context_enter(context);
    1624         Assert(context->valid);
     1680        if(!context_acquire_context(context, (IWineD3DSurface*)target, CTXUSAGE_RESOURCELOAD, TRUE))
     1681        {
     1682            ERR("Failed to acquire the context.\n");
     1683            Assert(0);
     1684            Assert(!context->valid);
     1685            context = NULL;
     1686        }
     1687        else
     1688        {
     1689            Assert(context->valid);
     1690        }
    16251691    }
    16261692
     
    19702036    {
    19712037#ifdef VBOXWDDM
    1972         IWineD3DSwapChainImpl *swapchain = NULL;
     2038        IWineD3DSwapChain *swapchain = NULL;
    19732039        if (SUCCEEDED(IWineD3DSurface_GetContainer(target, &IID_IWineD3DSwapChain, (void **)&swapchain))) {
    1974             context_validate(current_context, swapchain);
     2040            context_validate(current_context, (IWineD3DSwapChainImpl*)swapchain);
    19752041            IWineD3DSwapChain_Release(swapchain);
    19762042        }
    19772043        else {
    19782044                                                                                                    /* tmp work-around */
    1979             context_validate(current_context, current_context->device->swapchains[current_context->device->NumberOfSwapChains-1]);
     2045            context_validate(current_context, (IWineD3DSwapChainImpl*)current_context->device->swapchains[current_context->device->NumberOfSwapChains-1]);
    19802046        }
    19812047#else
     
    19902056        context = findThreadContextForSwapChain(swapchain, tid);
    19912057#ifdef VBOXWDDM
    1992         context_validate(context, swapchain);
     2058        context_validate(context, (IWineD3DSwapChainImpl*)swapchain);
    19932059#endif
    19942060        IWineD3DSwapChain_Release(swapchain);
     
    20252091#ifdef VBOXWDDM
    20262092        context_validate(context,
    2027                 This->swapchains[This->NumberOfSwapChains-1] /* tmp work-around */
     2093                (IWineD3DSwapChainImpl*)This->swapchains[This->NumberOfSwapChains-1] /* tmp work-around */
    20282094                                 );
    20292095#endif
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/device.c

    r32545 r32577  
    68636863static HRESULT WINAPI IWineD3DDeviceImpl_Flush(IWineD3DDevice *iface)
    68646864{
    6865     IWineD3DSwapChain *swapChain = NULL;
     6865    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     6866    struct wined3d_context *context;
    68666867    int i;
    6867     int swapchains = IWineD3DDeviceImpl_GetNumberOfSwapChains(iface);
    6868 
    6869     TRACE("iface %p.\n", iface);
    6870 
    6871     for(i = 0 ; i < swapchains ; i ++) {
    6872 
    6873         IWineD3DDeviceImpl_GetSwapChain(iface, i, &swapChain);
    6874         TRACE("presentinng chain %d, %p\n", i, swapChain);
    6875         IWineD3DSwapChain_Flush(swapChain);
    6876         IWineD3DSwapChain_Release(swapChain);
    6877     }
    6878 
     6868    for (i = 0; i < This->numContexts; ++i)
     6869    {
     6870        context = This->contexts[i];
     6871        if (context_acquire_context(context, NULL, CTXUSAGE_RESOURCELOAD, TRUE))
     6872        {
     6873            Assert(context->valid);
     6874            wglFlush();
     6875            context_release(context);
     6876        }
     6877        else
     6878        {
     6879            WARN("Invalid context, skipping flush.\n");
     6880        }
     6881    }
    68796882    return WINED3D_OK;
    68806883}
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/swapchain.c

    r32545 r32577  
    555555}
    556556
    557 #ifdef VBOXWDDM
    558 static HRESULT WINAPI IWineD3DSwapChainImpl_Flush(IWineD3DSwapChain *iface)
    559 {
    560     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
    561     struct wined3d_context *context;
    562     RECT src_rect, dst_rect;
    563     BOOL render_to_fbo;
    564     unsigned int sync;
    565     int retval;
    566 
    567     context = context_acquire(This->device, This->backBuffer[0], CTXUSAGE_RESOURCELOAD);
    568 
    569     if (context->valid) wglFlush();
    570     else  WARN("Invalid context, skipping flush.\n");
    571 
    572     context_release(context);
    573 
    574     return WINED3D_OK;
    575 }
    576 #endif
    577 
    578557static const IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl =
    579558{
     
    595574    IWineD3DBaseSwapChainImpl_SetGammaRamp,
    596575    IWineD3DBaseSwapChainImpl_GetGammaRamp,
    597 #ifdef VBOXWDDM
    598     IWineD3DSwapChainImpl_Flush,
    599 #endif
    600576};
    601577
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/swapchain_gdi.c

    r32545 r32577  
    254254    return WINED3D_OK;
    255255}
    256 
    257 #ifdef VBOXWDDM
    258 static HRESULT WINAPI IWineGDISwapChainImpl_Flush(IWineD3DSwapChain *iface) {
    259     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *) iface;
    260 
    261     WARN("GDI Swapchain doesn't implement flush, returning WINED3DERR_INVALIDCALL\n");
    262     return WINED3DERR_INVALIDCALL;
    263 }
    264 #endif
    265256
    266257const IWineD3DSwapChainVtbl IWineGDISwapChain_Vtbl =
     
    283274    IWineD3DBaseSwapChainImpl_SetGammaRamp,
    284275    IWineD3DBaseSwapChainImpl_GetGammaRamp,
    285 #ifdef VBOXWDM
    286     IWineGDISwapChainImpl_Flush,
    287 #endif
    288276};
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_private.h

    r32545 r32577  
    12491249struct wined3d_context *context_find_create(IWineD3DDeviceImpl *device, IWineD3DSwapChainImpl *swapchain, IWineD3DSurfaceImpl *target,
    12501250        const struct wined3d_format_desc *ds_format_desc) DECLSPEC_HIDDEN;
     1251BOOL context_acquire_context(struct wined3d_context * context, IWineD3DSurface *target, enum ContextUsage usage, BOOL bReValidate) DECLSPEC_HIDDEN;
    12511252#endif
    12521253void context_destroy(IWineD3DDeviceImpl *This, struct wined3d_context *context) DECLSPEC_HIDDEN;
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