- Timestamp:
- Aug 24, 2012 11:19:31 AM (12 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3D.cpp
r42683 r42971 449 449 } 450 450 451 static void vboxResourceInit(PVBOXWDDMDISP_RESOURCE pRc, UINT cAllocs) 452 { 453 memset(pRc, 0, RT_OFFSETOF(VBOXWDDMDISP_RESOURCE, aAllocations[cAllocs])); 454 pRc->cAllocations = cAllocs; 455 for (UINT i = 0; i < cAllocs; ++i) 456 { 457 pRc->aAllocations[i].iAlloc = i; 458 pRc->aAllocations[i].pRc = pRc; 459 } 460 } 461 451 462 static PVBOXWDDMDISP_RESOURCE vboxResourceAlloc(UINT cAllocs) 452 463 { 453 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)RTMemAlloc Z(RT_OFFSETOF(VBOXWDDMDISP_RESOURCE, aAllocations[cAllocs]));464 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)RTMemAlloc(RT_OFFSETOF(VBOXWDDMDISP_RESOURCE, aAllocations[cAllocs])); 454 465 Assert(pRc); 455 466 if (pRc) 456 467 { 457 pRc->cAllocations = cAllocs; 458 for (UINT i = 0; i < cAllocs; ++i) 459 { 460 pRc->aAllocations[i].iAlloc = i; 461 pRc->aAllocations[i].pRc = pRc; 462 } 468 vboxResourceInit(pRc, cAllocs); 463 469 return pRc; 464 470 } … … 1243 1249 && pBbAlloc->SurfDesc.format == pRt->pAlloc->SurfDesc.format 1244 1250 && pBbAlloc->SurfDesc.VidPnSourceId == pRt->pAlloc->SurfDesc.VidPnSourceId 1245 #if 01246 && (pBbRc == pRtRc1247 || (pBbRc->fFlags == pRtRc->fFlags1248 && pBbRc->RcDesc.enmPool == pRtRc->RcDesc.enmPool1249 // && pBbRc->RcDesc.fFlags.Value == pRtRc->RcDesc.fFlags.Value1250 )1251 1252 )1253 #endif1254 1251 ) 1255 1252 { … … 1460 1457 } 1461 1458 1462 static VOID vboxWddmSwapchainFillParams(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, D3DPRESENT_PARAMETERS *pParams) 1459 static VOID vboxWddmFillPresentParams(D3DPRESENT_PARAMETERS *pParams, PVBOXWDDMDISP_RESOURCE pRc, UINT cRTs) 1460 { 1461 Assert(cRTs); 1462 memset(pParams, 0, sizeof (D3DPRESENT_PARAMETERS)); 1463 pParams->BackBufferWidth = pRc->aAllocations[0].SurfDesc.width; 1464 pParams->BackBufferHeight = pRc->aAllocations[0].SurfDesc.height; 1465 pParams->BackBufferFormat = vboxDDI2D3DFormat(pRc->aAllocations[0].SurfDesc.format); 1466 pParams->BackBufferCount = cRTs - 1; 1467 pParams->MultiSampleType = vboxDDI2D3DMultiSampleType(pRc->RcDesc.enmMultisampleType); 1468 pParams->MultiSampleQuality = pRc->RcDesc.MultisampleQuality; 1469 #if 0 //def VBOXDISP_WITH_WINE_BB_WORKAROUND /* this does not work so far any way :( */ 1470 if (cRTs == 1) 1471 pParams->SwapEffect = D3DSWAPEFFECT_COPY; 1472 else 1473 #endif 1474 if (pRc->RcDesc.fFlags.DiscardRenderTarget) 1475 pParams->SwapEffect = D3DSWAPEFFECT_DISCARD; 1476 pParams->Windowed = TRUE; 1477 } 1478 1479 static VOID vboxWddmSwapchainFillPresentParams(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, D3DPRESENT_PARAMETERS *pParams) 1463 1480 { 1464 1481 Assert(pSwapchain->cRTs); … … 1467 1484 Assert(pSwapchain->cRTs <= 2); 1468 1485 #endif 1469 memset(pParams, 0, sizeof (D3DPRESENT_PARAMETERS));1470 1486 PVBOXWDDMDISP_RENDERTGT pRt = vboxWddmSwapchainGetBb(pSwapchain); 1471 1487 PVBOXWDDMDISP_RESOURCE pRc = pRt->pAlloc->pRc; 1472 pParams->BackBufferWidth = pRt->pAlloc->SurfDesc.width; 1473 pParams->BackBufferHeight = pRt->pAlloc->SurfDesc.height; 1474 pParams->BackBufferFormat = vboxDDI2D3DFormat(pRt->pAlloc->SurfDesc.format); 1475 pParams->BackBufferCount = pSwapchain->cRTs - 1; 1476 pParams->MultiSampleType = vboxDDI2D3DMultiSampleType(pRc->RcDesc.enmMultisampleType); 1477 pParams->MultiSampleQuality = pRc->RcDesc.MultisampleQuality; 1478 #if 0 //def VBOXDISP_WITH_WINE_BB_WORKAROUND /* this does not work so far any way :( */ 1479 if (pSwapchain->cRTs == 1) 1480 pParams->SwapEffect = D3DSWAPEFFECT_COPY; 1481 else 1482 #endif 1483 if (pRc->RcDesc.fFlags.DiscardRenderTarget) 1484 pParams->SwapEffect = D3DSWAPEFFECT_DISCARD; 1488 vboxWddmFillPresentParams(pParams, pRc, pSwapchain->cRTs); 1485 1489 } 1486 1490 … … 1489 1493 { 1490 1494 D3DPRESENT_PARAMETERS Params; 1491 vboxWddmSwapchainFillP arams(pSwapchain, &Params);1495 vboxWddmSwapchainFillPresentParams(pSwapchain, &Params); 1492 1496 IDirect3DSurface9* pD3D9OldFb = NULL; 1493 1497 IDirect3DSwapChain9 * pOldIf = pSwapchain->pSwapChainIf; … … 1701 1705 { 1702 1706 VBOXWINEEX_D3DPRESENT_PARAMETERS Params; 1703 vboxWddmSwapchainFillP arams(pSwapchain, &Params.Base);1707 vboxWddmSwapchainFillPresentParams(pSwapchain, &Params.Base); 1704 1708 Params.pHgsmi = NULL; 1705 1709 … … 1810 1814 { 1811 1815 D3DPRESENT_PARAMETERS Params; 1812 vboxWddmSwapchainFillP arams(pSwapchain, &Params);1816 vboxWddmSwapchainFillPresentParams(pSwapchain, &Params); 1813 1817 IDirect3DSurface9* pD3D9Surf; 1814 1818 hr = pDevice9If->CreateRenderTarget( … … 2130 2134 static HRESULT vboxWddmD3DDeviceCreateDummy(PVBOXWDDMDISP_DEVICE pDevice) 2131 2135 { 2132 HRESULT hr; 2133 PVBOXWDDMDISP_RESOURCE pRc = vboxResourceAlloc(2); 2134 Assert(pRc); 2135 if (pRc) 2136 { 2137 pRc->RcDesc.enmFormat = D3DDDIFMT_A8R8G8B8; 2138 pRc->RcDesc.enmPool = D3DDDIPOOL_LOCALVIDMEM; 2139 pRc->RcDesc.enmMultisampleType = D3DDDIMULTISAMPLE_NONE; 2140 pRc->RcDesc.MultisampleQuality = 0; 2141 for (UINT i = 0 ; i < pRc->cAllocations; ++i) 2142 { 2143 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[i]; 2144 pAlloc->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE; 2145 pAlloc->SurfDesc.width = 0x4; 2146 pAlloc->SurfDesc.height = 0x4; 2147 pAlloc->SurfDesc.format = D3DDDIFMT_A8R8G8B8; 2148 } 2149 2150 PVBOXWDDMDISP_SWAPCHAIN pSwapchain; 2151 hr = vboxWddmSwapchainCreateIfForRc(pDevice, pRc, &pSwapchain); 2152 Assert(hr == S_OK); 2153 if (hr != S_OK) 2154 vboxResourceFree(pRc); 2155 } 2156 else 2157 { 2158 hr = E_OUTOFMEMORY; 2159 } 2160 2161 return hr; 2136 VBOXWDDMDISP_RESOURCE Rc; 2137 vboxResourceInit(&Rc, 1); 2138 2139 Rc.RcDesc.enmFormat = D3DDDIFMT_A8R8G8B8; 2140 Rc.RcDesc.enmPool = D3DDDIPOOL_LOCALVIDMEM; 2141 Rc.RcDesc.enmMultisampleType = D3DDDIMULTISAMPLE_NONE; 2142 Rc.RcDesc.MultisampleQuality = 0; 2143 PVBOXWDDMDISP_ALLOCATION pAlloc = &Rc.aAllocations[0]; 2144 pAlloc->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE; 2145 pAlloc->SurfDesc.width = 0x4; 2146 pAlloc->SurfDesc.height = 0x4; 2147 pAlloc->SurfDesc.format = D3DDDIFMT_A8R8G8B8; 2148 Assert(!pDevice->pDevice9If); 2149 VBOXWINEEX_D3DPRESENT_PARAMETERS Params; 2150 vboxWddmFillPresentParams(&Params.Base, &Rc, 2); 2151 Params.pHgsmi = &pDevice->Uhgsmi.BasePrivate.Base; 2152 DWORD fFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING; 2153 PVBOXWDDMDISP_ADAPTER pAdapter = pDevice->pAdapter; 2154 IDirect3DDevice9 * pDevice9If = NULL; 2155 2156 HRESULT hr = pAdapter->D3D.pD3D9If->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, NULL, fFlags, &Params.Base, &pDevice9If); 2157 if (!SUCCEEDED(hr)) 2158 { 2159 WARN(("CreateDevice failed hr 0x%x", hr)); 2160 return hr; 2161 } 2162 2163 pDevice->pDevice9If = pDevice9If; 2164 return S_OK; 2162 2165 } 2163 2166 -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/device.c
r42516 r42971 1958 1958 } 1959 1959 1960 if (This->swapchains) 1961 { 1960 1962 HeapFree(GetProcessHeap(), 0, This->swapchains); 1961 1963 This->swapchains = NULL; 1962 1964 This->NumberOfSwapChains = 0; 1965 } 1966 else 1967 { 1968 Assert(!This->NumberOfSwapChains); 1969 } 1963 1970 1964 1971 for (i = 0; i < This->NumberOfPalettes; i++) HeapFree(GetProcessHeap(), 0, This->palettes[i]); … … 7005 7012 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; 7006 7013 int i; 7014 IWineD3DSwapChain **pvOldBuf = This->swapchains; 7015 7007 7016 for (i = 0; i < This->NumberOfSwapChains; ++i) 7008 7017 { … … 7042 7051 context_destroy(This, This->contexts[0]); 7043 7052 } 7044 } 7053 This->swapchains = NULL; 7054 } 7055 7056 if (pvOldBuf) 7057 HeapFree(GetProcessHeap(), 0, pvOldBuf); 7058 7045 7059 return WINED3D_OK; 7046 7060 } -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/swapchain.c
r42499 r42971 62 62 } 63 63 64 VOID swapchain_invalidate(IWineD3DSwapChainImpl *pSwapchain) 64 static VOID swapchain_cleanup_rt_refs(IWineD3DSwapChainImpl *pSwapchain, IWineD3DSurface *rt, int iBb) 65 { 66 IWineD3DDeviceImpl *device = pSwapchain->device; 67 struct wined3d_context *context; 68 UINT i; 69 for (i = 0; i < device->numContexts; ++i) 70 { 71 context = device->contexts[i]; 72 73 if (rt == context->current_rt) 74 { 75 context->current_rt = NULL; 76 } 77 } 78 79 if (device->NumberOfSwapChains) 80 { 81 IWineD3DSwapChainImpl *pDefaultSwapchain = (IWineD3DSwapChainImpl*)device->swapchains[0]; 82 for (i = 0; i < device->adapter->gl_info.limits.buffers; ++i) 83 { 84 if (device->render_targets[i] == rt) 85 { 86 IWineD3DSurface *newRt; 87 if (i) 88 newRt = NULL; 89 else if (iBb == -1) /* front buffer */ 90 newRt = pDefaultSwapchain->frontBuffer; 91 else 92 newRt = pDefaultSwapchain->backBuffer ? pDefaultSwapchain->backBuffer[0] : pDefaultSwapchain->frontBuffer; 93 94 IWineD3DDevice_SetRenderTarget((IWineD3DDevice*)device, i, newRt, TRUE); 95 } 96 } 97 } 98 } 99 100 static VOID swapchain_cleanup_refs(IWineD3DSwapChainImpl *pSwapchain) 65 101 { 66 102 /* first make sure the swapchain is not used by anyone */ … … 76 112 context->currentSwapchain = NULL; 77 113 } 78 79 if (pSwapchain->frontBuffer == context->current_rt) 80 {81 context->current_rt = NULL;82 } 83 elseif (pSwapchain->backBuffer)84 85 86 87 88 if (pSwapchain->backBuffer[j] == context->current_rt)89 {90 context->current_rt = NULL;91 break; 92 } 93 } 94 } 95 }114 } 115 116 if (pSwapchain->frontBuffer) 117 swapchain_cleanup_rt_refs(pSwapchain, pSwapchain->frontBuffer, -1); 118 119 if (pSwapchain->backBuffer) 120 { 121 UINT j; 122 for (j = 0; j < pSwapchain->presentParms.BackBufferCount; ++j) 123 { 124 swapchain_cleanup_rt_refs(pSwapchain, pSwapchain->backBuffer[j], j); 125 } 126 } 127 } 128 129 static VOID swapchain_invalidate(IWineD3DSwapChainImpl *pSwapchain) 130 { 131 swapchain_cleanup_refs(pSwapchain); 96 132 97 133 pSwapchain->win_handle = NULL; … … 105 141 { 106 142 IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface; 107 WINED3DDISPLAYMODE mode;108 143 unsigned int i; 109 144 … … 111 146 112 147 IWineD3DSwapChain_SetGammaRamp(iface, 0, &This->orig_gamma); 148 149 #ifdef VBOX_WITH_WDDM 150 /* first remove swapchain from a list to ensure context is properly acquired 151 * & gl resources are properly cleared on last swapchain destruction */ 152 IWineD3DDevice_RemoveSwapChain((IWineD3DDevice*)This->device, (IWineD3DSwapChain*)This); 153 154 swapchain_cleanup_refs(This); 155 #endif 113 156 114 157 /* Release the swapchain's draw buffers. Make sure This->backBuffer[0] is … … 154 197 This->presentRt = NULL; 155 198 } 156 #endif 157 199 200 if(This->win_handle) { 201 VBoxExtWndDestroy(This->win_handle, This->hDC); 202 swapchain_invalidate(This); 203 } 204 else 205 { 206 WARN("null win info"); 207 } 208 #else 158 209 IWineD3DDevice_RemoveSwapChain((IWineD3DDevice*)This->device, (IWineD3DSwapChain*)This); 159 210 if (!This->device->NumberOfSwapChains) … … 165 216 */ 166 217 if(This->presentParms.Windowed == FALSE && This->presentParms.AutoRestoreDisplayMode) { 218 WINED3DDISPLAYMODE mode; 167 219 mode.Width = This->orig_width; 168 220 mode.Height = This->orig_height; … … 172 224 } 173 225 } 174 #ifdef VBOX_WITH_WDDM 175 if(This->win_handle) { 176 VBoxExtWndDestroy(This->win_handle, This->hDC); 177 swapchain_invalidate(This); 178 } 179 else 180 { 181 WARN("null win info"); 182 } 183 #else 226 184 227 HeapFree(GetProcessHeap(), 0, This->context); 185 228 #endif 229 186 230 HeapFree(GetProcessHeap(), 0, This); 187 231 }
Note:
See TracChangeset
for help on using the changeset viewer.