Changeset 38903 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm
- Timestamp:
- Sep 29, 2011 4:20:22 PM (13 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3D.cpp
r38884 r38903 1925 1925 } 1926 1926 pSwapchain->fFlags.bChanged = TRUE; 1927 } 1927 pSwapchain->fFlags.bSwitchReportingPresent = TRUE; 1928 } 1929 1930 DECLINLINE(VOID) vboxWddmSwapchainSetBb(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_RENDERTGT pRT) 1931 { 1932 UINT iRt = vboxWddmSwapchainRtIndex(pSwapchain, pRT); 1933 Assert(iRt < pSwapchain->cRTs); 1934 pSwapchain->iBB = iRt; 1935 pSwapchain->fFlags.bChanged = TRUE; 1936 } 1937 1928 1938 1929 1939 #if 0 … … 2032 2042 * or by removing the pBbAlloc out of it */ 2033 2043 Assert(0); 2044 2045 PVBOXWDDMDISP_RENDERTGT pRt = vboxWddmSwapchainRtForAlloc(pSwapchain, pBbAlloc); 2046 Assert(pRt); 2047 vboxWddmSwapchainSetBb(pSwapchain, pRt); 2048 pSwapchain->fFlags.bSwitchReportingPresent = TRUE; 2034 2049 } 2035 2050 } … … 2111 2126 static HRESULT vboxWddmSwapchainRtSynch(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain, uint32_t iBb) 2112 2127 { 2128 if (pSwapchain->fFlags.bRtReportingPresent) 2129 return S_OK; 2130 2113 2131 IDirect3DSurface9 *pD3D9Surf; 2114 2132 #ifdef VBOXDISP_WITH_WINE_BB_WORKAROUND … … 2290 2308 } 2291 2309 2310 /* copy current rt data to offscreen render targets */ 2311 static HRESULT vboxWddmSwapchainSwtichOffscreenRt(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain, BOOL fForceCreate) 2312 { 2313 D3DPRESENT_PARAMETERS Params; 2314 vboxWddmSwapchainFillParams(pSwapchain, &Params); 2315 IDirect3DSurface9* pD3D9OldFb = NULL; 2316 IDirect3DSwapChain9 * pOldIf = pSwapchain->pSwapChainIf; 2317 HRESULT hr = S_OK; 2318 if (pOldIf) 2319 { 2320 hr = pOldIf->GetBackBuffer(~0, D3DBACKBUFFER_TYPE_MONO, &pD3D9OldFb); 2321 if (FAILED(hr)) 2322 { 2323 WARN(("GetBackBuffer ~0 failed, hr (%d)", hr)); 2324 return hr; 2325 } 2326 /* just need a pointer to match */ 2327 pD3D9OldFb->Release(); 2328 } 2329 2330 for (UINT i = 0; i < pSwapchain->cRTs; ++i) 2331 { 2332 PVBOXWDDMDISP_RENDERTGT pRT = &pSwapchain->aRTs[i]; 2333 BOOL fHasSurf = !!pRT->pAlloc->pRc->aAllocations[0].pD3DIf; 2334 if (!fForceCreate && !fHasSurf) 2335 continue; 2336 2337 IDirect3DSurface9* pD3D9OldSurf = NULL; 2338 if (fHasSurf) 2339 { 2340 VOID *pvSwapchain = NULL; 2341 /* since this can be texture, need to do the vboxWddmSurfGet magic */ 2342 hr = vboxWddmSurfGet(pRT->pAlloc->pRc, pRT->pAlloc->iAlloc, &pD3D9OldSurf); 2343 Assert(hr == S_OK); 2344 hr = pD3D9OldSurf->GetContainer(IID_IDirect3DSwapChain9, &pvSwapchain); 2345 if (hr == S_OK) 2346 { 2347 Assert(pvSwapchain); 2348 ((IDirect3DSwapChain9 *)pvSwapchain)->Release(); 2349 } 2350 else 2351 { 2352 hr = S_OK; 2353 Assert(!pvSwapchain); 2354 } 2355 2356 if (!pvSwapchain) /* no swapchain, it is already offscreen */ 2357 { 2358 pD3D9OldSurf->Release(); 2359 continue; 2360 } 2361 Assert (pvSwapchain == pOldIf); 2362 } 2363 2364 IDirect3DSurface9* pD3D9NewSurf; 2365 IDirect3DDevice9 *pDevice9If = pDevice->pDevice9If; 2366 hr = pDevice9If->CreateRenderTarget( 2367 Params.BackBufferWidth, Params.BackBufferHeight, 2368 Params.BackBufferFormat, 2369 Params.MultiSampleType, 2370 Params.MultiSampleQuality, 2371 TRUE, /*bLockable*/ 2372 &pD3D9NewSurf, 2373 pRT->pAlloc->hSharedHandle ? &pRT->pAlloc->hSharedHandle : NULL 2374 ); 2375 Assert(hr == S_OK); 2376 if (FAILED(hr)) 2377 { 2378 if (pD3D9OldSurf) 2379 pD3D9OldSurf->Release(); 2380 break; 2381 } 2382 2383 if (pD3D9OldSurf) 2384 { 2385 if (pD3D9OldSurf != pD3D9OldFb) 2386 { 2387 hr = pDevice9If->StretchRect(pD3D9OldSurf, NULL, pD3D9NewSurf, NULL, D3DTEXF_NONE); 2388 Assert(hr == S_OK); 2389 } 2390 else 2391 { 2392 hr = pOldIf->GetFrontBufferData(pD3D9NewSurf); 2393 Assert(hr == S_OK); 2394 } 2395 } 2396 if (FAILED(hr)) 2397 { 2398 if (pD3D9OldSurf) 2399 pD3D9OldSurf->Release(); 2400 break; 2401 } 2402 2403 pRT->pAlloc->pD3DIf->Release(); 2404 pRT->pAlloc->pD3DIf = pD3D9NewSurf; 2405 if (pD3D9OldSurf) 2406 pD3D9OldSurf->Release(); 2407 } 2408 2409 return hr; 2410 } 2411 2412 2413 /** 2414 * @return old RtReportingPresent state 2415 */ 2416 static HRESULT vboxWddmSwapchainSwtichRtPresent(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain) 2417 { 2418 if (pSwapchain->fFlags.bRtReportingPresent) 2419 return S_OK; 2420 2421 HRESULT hr; 2422 pSwapchain->bRTFbCopyUpToDate = FALSE; 2423 if (pSwapchain->pRenderTargetFbCopy) 2424 { 2425 pSwapchain->pRenderTargetFbCopy->Release(); 2426 pSwapchain->pRenderTargetFbCopy = NULL; 2427 } 2428 2429 hr = vboxWddmSwapchainSwtichOffscreenRt(pDevice, pSwapchain, 2430 TRUE /* force offscreen surface creation right away. This way we ensure the swapchain data 2431 * is always uptodate which allows making the vboxWddmSwapchainRtSynch behave as a nop */ 2432 ); 2433 Assert(hr == S_OK); 2434 if (FAILED(hr)) 2435 return hr; 2436 2437 /* ensure we update device RTs to offscreen ones we just created */ 2438 for (UINT i = 0; i < pDevice->cRTs; ++i) 2439 { 2440 PVBOXWDDMDISP_ALLOCATION pRtAlloc = pDevice->apRTs[i]; 2441 for (UINT j = 0; j < pSwapchain->cRTs; ++j) 2442 { 2443 PVBOXWDDMDISP_ALLOCATION pAlloc = pSwapchain->aRTs[j].pAlloc; 2444 if (pRtAlloc == pAlloc) 2445 { 2446 hr = vboxWddmRenderTargetSet(pDevice, i, pAlloc, TRUE); 2447 Assert(hr == S_OK); 2448 } 2449 } 2450 } 2451 2452 pSwapchain->fFlags.bRtReportingPresent = TRUE; 2453 return hr; 2454 } 2455 2292 2456 static HRESULT vboxWddmSwapchainChkCreateIf(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain) 2293 2457 { … … 2298 2462 HRESULT hr = S_OK; 2299 2463 BOOL bReuseSwapchain = FALSE; 2300 D3DPRESENT_PARAMETERS Params; 2301 D3DPRESENT_PARAMETERS OldParams; 2302 vboxWddmSwapchainFillParams(pSwapchain, &Params); 2464 2465 if (pSwapchain->fFlags.bSwitchReportingPresent || pSwapchain->cRTs > VBOXWDDMDISP_MAX_DIRECT_RTS) 2466 { 2467 pSwapchain->fFlags.bSwitchReportingPresent = FALSE; 2468 /* switch to Render Target Reporting Present mode */ 2469 vboxWddmSwapchainSwtichRtPresent(pDevice, pSwapchain); 2470 } 2471 2303 2472 /* check if we need to re-create the swapchain */ 2304 2473 if (pOldIf) 2305 2474 { 2306 hr = pOldIf->GetPresentParameters(&OldParams); 2307 Assert(hr == S_OK); 2308 if (hr == S_OK) 2309 { 2310 if (OldParams.BackBufferCount == Params.BackBufferCount 2311 // && OldParams.SwapEffect == Params.SwapEffect 2312 ) 2313 { 2314 bReuseSwapchain = TRUE; 2475 if (pSwapchain->fFlags.bRtReportingPresent) 2476 { 2477 /* the number of swapchain backbuffers does not matter */ 2478 bReuseSwapchain = TRUE; 2479 } 2480 else 2481 { 2482 D3DPRESENT_PARAMETERS OldParams; 2483 hr = pOldIf->GetPresentParameters(&OldParams); 2484 Assert(hr == S_OK); 2485 if (hr == S_OK) 2486 { 2487 if (OldParams.BackBufferCount == pSwapchain->cRTs-1) 2488 { 2489 bReuseSwapchain = TRUE; 2490 } 2315 2491 } 2316 2492 } … … 2326 2502 if (!bReuseSwapchain) 2327 2503 { 2328 //#define VBOXDISP_NEWWND_ON_SWAPCHAINUPDATE 2504 D3DPRESENT_PARAMETERS Params; 2505 vboxWddmSwapchainFillParams(pSwapchain, &Params); 2506 2329 2507 if (hr == S_OK) 2330 2508 { 2331 2509 DWORD fFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING; 2332 // if (pDevice->fFlags.AllowMultithreading)2333 // fFlags |= D3DCREATE_MULTITHREADED;2334 2510 2335 2511 Params.hDeviceWindow = NULL; … … 2366 2542 { 2367 2543 pDevice9If = pDevice->pDevice9If; 2544 2368 2545 if (pOldIf) 2369 2546 { 2370 /* copy current rt data to offscreen render targets */ 2371 IDirect3DSurface9* pD3D9OldFb = NULL; 2372 HRESULT tmpHr = pOldIf->GetBackBuffer(~0, D3DBACKBUFFER_TYPE_MONO, &pD3D9OldFb); 2373 Assert(tmpHr == S_OK); 2374 if (tmpHr == S_OK) 2375 { 2376 /* just need a pointer to match */ 2377 pD3D9OldFb->Release(); 2378 } 2379 UINT cOldRts = OldParams.SwapEffect == D3DSWAPEFFECT_COPY ? 1 : OldParams.BackBufferCount + 1; 2380 for (UINT i = 0; i < pSwapchain->cRTs; ++i) 2381 { 2382 PVBOXWDDMDISP_RENDERTGT pRT = &pSwapchain->aRTs[i]; 2383 if (!pRT->pAlloc->pD3DIf) 2384 continue; 2385 IDirect3DSurface9* pD3D9OldSurf = NULL; 2386 VOID *pvSwapchain = NULL; 2387 /* since this can be texture, need to do the vboxWddmSurfGet magic */ 2388 hr = vboxWddmSurfGet(pRT->pAlloc->pRc, pRT->pAlloc->iAlloc, &pD3D9OldSurf); 2389 Assert(hr == S_OK); 2390 tmpHr = pD3D9OldSurf->GetContainer(IID_IDirect3DSwapChain9, &pvSwapchain); 2391 if (tmpHr == S_OK) 2392 { 2393 Assert(pvSwapchain); 2394 ((IDirect3DSwapChain9 *)pvSwapchain)->Release(); 2395 } 2396 else 2397 { 2398 Assert(!pvSwapchain); 2399 } 2400 if (pvSwapchain != pOldIf) 2401 continue; 2402 2403 IDirect3DSurface9* pD3D9NewSurf; 2404 tmpHr = pDevice9If->CreateRenderTarget( 2405 Params.BackBufferWidth, Params.BackBufferHeight, 2406 Params.BackBufferFormat, 2407 Params.MultiSampleType, 2408 Params.MultiSampleQuality, 2409 TRUE, /*bLockable*/ 2410 &pD3D9NewSurf, 2411 pRT->pAlloc->hSharedHandle ? &pRT->pAlloc->hSharedHandle : NULL 2412 ); 2413 Assert(tmpHr == S_OK); 2414 if (tmpHr != S_OK) 2415 continue; 2416 2417 if (pD3D9OldSurf != pD3D9OldFb && cOldRts != 1) 2418 { 2419 tmpHr = pDevice9If->StretchRect(pD3D9OldSurf, NULL, pD3D9NewSurf, NULL, D3DTEXF_NONE); 2420 Assert(tmpHr == S_OK); 2421 } 2422 else 2423 { 2424 tmpHr = pOldIf->GetFrontBufferData(pD3D9NewSurf); 2425 Assert(tmpHr == S_OK); 2426 } 2427 2428 if (tmpHr != S_OK) 2429 continue; 2430 2431 pRT->pAlloc->pD3DIf->Release(); 2432 pRT->pAlloc->pD3DIf = pD3D9NewSurf; 2433 pD3D9OldSurf->Release(); 2434 } 2547 /* need to copy data to offscreen rt to ensure the data is preserved 2548 * since the swapchain data may become invalid once we create a new swapchain 2549 * and pass the current swapchain's window to it 2550 * thus vboxWddmSwapchainSynch will not be able to do synchronization */ 2551 hr = vboxWddmSwapchainSwtichOffscreenRt(pDevice, pSwapchain, FALSE); 2552 Assert(hr == S_OK); 2435 2553 } 2436 2554 … … 2464 2582 pSwapchain->pSwapChainIf = pNewIf; 2465 2583 #ifndef VBOXWDDM_WITH_VISIBLE_FB 2466 pSwapchain->bRTFbCopyUpToDate = FALSE; 2584 if (!pSwapchain->fFlags.bRtReportingPresent) 2585 { 2586 pSwapchain->bRTFbCopyUpToDate = FALSE; 2467 2587 # if defined(VBOXDISP_WITH_WINE_BB_WORKAROUND) && defined(VBOX_WINE_WITH_FAST_INTERSWAPCHAIN_BLT) 2468 /* if wine is able to do fast fb->bb blits, we will use backbuffer directly,2469 * this is NOT possible currently */2470 if (pSwapchain->cRTs == 1)2471 {2472 /* we will assign it to wine backbuffer on a swapchain synch */2473 if (pSwapchain->pRenderTargetFbCopy)2474 {2475 pSwapchain->pRenderTargetFbCopy->Release();2476 pSwapchain->pRenderTargetFbCopy = NULL;2477 }2478 }2479 else2588 /* if wine is able to do fast fb->bb blits, we will use backbuffer directly, 2589 * this is NOT possible currently */ 2590 if (pSwapchain->cRTs == 1) 2591 { 2592 /* we will assign it to wine backbuffer on a swapchain synch */ 2593 if (pSwapchain->pRenderTargetFbCopy) 2594 { 2595 pSwapchain->pRenderTargetFbCopy->Release(); 2596 pSwapchain->pRenderTargetFbCopy = NULL; 2597 } 2598 } 2599 else 2480 2600 # endif 2481 if (!pSwapchain->pRenderTargetFbCopy) 2482 { 2483 IDirect3DSurface9* pD3D9Surf; 2484 hr = pDevice9If->CreateRenderTarget( 2485 Params.BackBufferWidth, Params.BackBufferHeight, 2486 Params.BackBufferFormat, 2487 Params.MultiSampleType, 2488 Params.MultiSampleQuality, 2489 TRUE, /*bLockable*/ 2490 &pD3D9Surf, 2491 NULL /* HANDLE* pSharedHandle */ 2492 ); 2493 Assert(hr == S_OK); 2494 if (hr == S_OK) 2495 { 2496 Assert(pD3D9Surf); 2497 pSwapchain->pRenderTargetFbCopy = pD3D9Surf; 2498 } 2499 } 2500 #endif 2501 2601 if (!pSwapchain->pRenderTargetFbCopy) 2602 { 2603 D3DPRESENT_PARAMETERS Params; 2604 vboxWddmSwapchainFillParams(pSwapchain, &Params); 2605 IDirect3DSurface9* pD3D9Surf; 2606 hr = pDevice9If->CreateRenderTarget( 2607 Params.BackBufferWidth, Params.BackBufferHeight, 2608 Params.BackBufferFormat, 2609 Params.MultiSampleType, 2610 Params.MultiSampleQuality, 2611 TRUE, /*bLockable*/ 2612 &pD3D9Surf, 2613 NULL /* HANDLE* pSharedHandle */ 2614 ); 2615 Assert(hr == S_OK); 2616 if (hr == S_OK) 2617 { 2618 Assert(pD3D9Surf); 2619 pSwapchain->pRenderTargetFbCopy = pD3D9Surf; 2620 } 2621 } 2622 } 2623 #endif 2502 2624 if (hr == S_OK) 2503 2625 { … … 2508 2630 Assert(pRt->pAlloc->enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE 2509 2631 || pRt->pAlloc->enmD3DIfType == VBOXDISP_D3DIFTYPE_TEXTURE); 2632 Assert(pRt->pAlloc->pRc->RcDesc.enmPool == D3DDDIPOOL_LOCALVIDMEM); 2510 2633 } 2511 2634 #endif … … 2514 2637 if (hr == S_OK) 2515 2638 { 2516 for (UINT i = 0; i < cSurfs; ++i)2517 {2518 PVBOXWDDMDISP_RENDERTGT pRt = &pSwapchain->aRTs[i];2519 hr = vboxWddmSurfSynchMem(pRt->pAlloc->pRc, pRt->pAlloc);2520 Assert(hr == S_OK);2521 if (hr != S_OK)2522 {2523 break;2524 }2525 }2526 2639 2527 2640 Assert(hr == S_OK); 2528 2641 if (hr == S_OK) 2529 2642 { 2530 Assert(pSwapchain->fFlags.Value == 0); 2643 Assert(!pSwapchain->fFlags.bChanged); 2644 Assert(!pSwapchain->fFlags.bSwitchReportingPresent); 2531 2645 if (pOldIf) 2532 2646 { … … 2570 2684 } 2571 2685 2572 static HRESULT vboxWddmSwapchainPresentPerform(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain) 2573 { 2574 HRESULT hr = pSwapchain->pSwapChainIf->Present(NULL, NULL, NULL, NULL, 0); 2575 Assert(hr == S_OK); 2576 if (hr == S_OK) 2577 { 2578 pSwapchain->bRTFbCopyUpToDate = FALSE; 2579 vboxWddmSwapchainFlip(pSwapchain); 2580 Assert(pSwapchain->fFlags.Value == 0); 2581 hr = vboxWddmSwapchainSynch(pDevice, pSwapchain); 2582 Assert(hr == S_OK); 2583 } 2584 return hr; 2585 } 2686 static HRESULT vboxWddmSwapchainPresentPerform(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain); 2586 2687 2587 2688 static HRESULT vboxWddmSwapchainBbUpdate(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_ALLOCATION pBbAlloc) 2588 2689 { 2690 Assert(!pSwapchain->fFlags.bRtReportingPresent); 2589 2691 for (UINT i = 0; i < pSwapchain->cRTs; ++i) 2590 2692 { … … 2611 2713 2612 2714 #ifndef VBOXWDDM_WITH_VISIBLE_FB 2613 if (vboxWddmSwapchainGetFb(pSwapchain)->pAlloc == pAlloc 2715 if (!pSwapchain->fFlags.bRtReportingPresent 2716 && vboxWddmSwapchainGetFb(pSwapchain)->pAlloc == pAlloc 2614 2717 # ifdef VBOXDISP_WITH_WINE_BB_WORKAROUND 2615 2718 … … 2654 2757 { 2655 2758 2656 /* iRt != 0 is untested here !! */ 2657 Assert(iRt == 0); 2658 if (iRt == 0) 2659 { 2660 hr = vboxWddmSwapchainBbUpdate(pDevice, pSwapchain, pAlloc); 2661 if (FAILED(hr)) 2662 { 2663 WARN(("vboxWddmSwapchainBbUpdate failed, hr(0x%)",hr)); 2664 return hr; 2759 if (!pSwapchain->fFlags.bRtReportingPresent) 2760 { 2761 /* iRt != 0 is untested here !! */ 2762 Assert(iRt == 0); 2763 if (iRt == 0) 2764 { 2765 hr = vboxWddmSwapchainBbUpdate(pDevice, pSwapchain, pAlloc); 2766 if (FAILED(hr)) 2767 { 2768 WARN(("vboxWddmSwapchainBbUpdate failed, hr(0x%)",hr)); 2769 return hr; 2770 } 2665 2771 } 2666 2772 } … … 2676 2782 } 2677 2783 2678 2679 2784 Assert(vboxWddmSwapchainGetBb(pSwapchain)->pAlloc == pAlloc || iRt != 0); 2680 2785 IDirect3DSurface9 *pSurf; … … 2689 2794 return S_OK; 2690 2795 2796 } 2797 2798 static HRESULT vboxWddmSwapchainPresentPerform(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain) 2799 { 2800 HRESULT hr; 2801 if (!pSwapchain->fFlags.bRtReportingPresent) 2802 { 2803 hr = pSwapchain->pSwapChainIf->Present(NULL, NULL, NULL, NULL, 0); 2804 Assert(hr == S_OK); 2805 if (FAILED(hr)) 2806 return hr; 2807 } 2808 else 2809 { 2810 PVBOXWDDMDISP_ALLOCATION pCurBb = vboxWddmSwapchainGetBb(pSwapchain)->pAlloc; 2811 IDirect3DSurface9 *pSurf; 2812 hr = vboxWddmSwapchainSurfGet(pDevice, pSwapchain, pCurBb, &pSurf); 2813 Assert(hr == S_OK); 2814 if (FAILED(hr)) 2815 return hr; 2816 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DSwapchain9Present(pSwapchain->pSwapChainIf, pSurf); 2817 Assert(hr == S_OK); 2818 pSurf->Release(); 2819 if (FAILED(hr)) 2820 return hr; 2821 } 2822 2823 pSwapchain->bRTFbCopyUpToDate = FALSE; 2824 vboxWddmSwapchainFlip(pSwapchain); 2825 Assert(!pSwapchain->fFlags.bChanged); 2826 Assert(!pSwapchain->fFlags.bSwitchReportingPresent); 2827 hr = vboxWddmSwapchainSynch(pDevice, pSwapchain); 2828 Assert(hr == S_OK); 2829 return hr; 2691 2830 } 2692 2831 … … 2779 2918 { 2780 2919 pRc->RcDesc.enmFormat = D3DDDIFMT_A8R8G8B8; 2920 pRc->RcDesc.enmPool = D3DDDIPOOL_LOCALVIDMEM; 2781 2921 pRc->RcDesc.enmMultisampleType = D3DDDIMULTISAMPLE_NONE; 2782 2922 pRc->RcDesc.MultisampleQuality = 0; … … 5042 5182 vboxDDI2D3DPool(pResource->Pool), 5043 5183 &pD3DIfTex, 5184 #ifdef VBOXWDDMDISP_DEBUG_NOSHARED 5185 NULL, 5186 #else 5044 5187 pResource->Flags.SharedResource ? &hSharedHandle : NULL, 5188 #endif 5045 5189 pavClientMem); 5046 5190 Assert(hr == S_OK); … … 5050 5194 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_TEXTURE; 5051 5195 pAllocation->pD3DIf = pD3DIfTex; 5196 #ifndef VBOXWDDMDISP_DEBUG_NOSHARED 5052 5197 Assert(!!(pResource->Flags.SharedResource) == !!(hSharedHandle)); 5198 #endif 5053 5199 pAllocation->hSharedHandle = hSharedHandle; 5054 5200 #ifdef DEBUG_misha … … 5106 5252 vboxDDI2D3DPool(pResource->Pool), 5107 5253 &pD3DIfCubeTex, 5254 #ifdef VBOXWDDMDISP_DEBUG_NOSHARED 5255 NULL, 5256 #else 5108 5257 pResource->Flags.SharedResource ? &hSharedHandle : NULL, 5258 #endif 5109 5259 pavClientMem); 5110 5260 Assert(hr == S_OK); … … 5114 5264 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_CUBE_TEXTURE; 5115 5265 pAllocation->pD3DIf = pD3DIfCubeTex; 5266 #ifndef VBOXWDDMDISP_DEBUG_NOSHARED 5116 5267 Assert(!!(pResource->Flags.SharedResource) == !!(hSharedHandle)); 5268 #endif 5117 5269 pAllocation->hSharedHandle = hSharedHandle; 5118 5270 } … … 5154 5306 !pResource->Flags.NotLockable /* BOOL Lockable */, 5155 5307 &pD3D9Surf, 5308 #ifdef VBOXWDDMDISP_DEBUG_NOSHARED 5309 NULL 5310 #else 5156 5311 pResource->Flags.SharedResource ? &hSharedHandle : NULL 5312 #endif 5157 5313 ); 5158 5314 Assert(hr == S_OK); … … 5162 5318 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE; 5163 5319 pAllocation->pD3DIf = pD3D9Surf; 5320 #ifndef VBOXWDDMDISP_DEBUG_NOSHARED 5164 5321 Assert(!!(pResource->Flags.SharedResource) == !!(hSharedHandle)); 5322 #endif 5165 5323 pAllocation->hSharedHandle = hSharedHandle; 5166 5324 hr = vboxWddmSurfSynchMem(pRc, pAllocation); … … 6804 6962 pAllocation->hSharedHandle = (HANDLE)pAllocInfo->hSharedHandle; 6805 6963 pAllocation->SurfDesc = pAllocInfo->SurfDesc; 6964 #ifndef VBOXWDDMDISP_DEBUG_NOSHARED 6806 6965 Assert(pAllocation->hSharedHandle); 6966 #endif 6807 6967 } 6808 6968 … … 6813 6973 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[0]; 6814 6974 HANDLE hSharedHandle = pAllocation->hSharedHandle; 6975 #ifndef VBOXWDDMDISP_DEBUG_NOSHARED 6815 6976 Assert(pAllocation->hSharedHandle); 6977 #endif 6816 6978 6817 6979 #ifdef DEBUG_misha … … 6832 6994 vboxDDI2D3DPool(pRc->RcDesc.enmPool), 6833 6995 &pD3DIfTex, 6996 #ifdef VBOXWDDMDISP_DEBUG_NOSHARED 6997 NULL, 6998 #else 6834 6999 &hSharedHandle, 7000 #endif 6835 7001 NULL); 6836 7002 Assert(hr == S_OK); … … 6841 7007 pAllocation->pD3DIf = pD3DIfTex; 6842 7008 Assert(pAllocation->hSharedHandle == hSharedHandle); 7009 #ifndef VBOXWDDMDISP_DEBUG_NOSHARED 6843 7010 Assert(pAllocation->hSharedHandle); 7011 #endif 6844 7012 } 6845 7013 } … … 6862 7030 vboxDDI2D3DPool(pRc->RcDesc.enmPool), 6863 7031 &pD3DIfCubeTex, 7032 #ifdef VBOXWDDMDISP_DEBUG_NOSHARED 7033 NULL, 7034 #else 6864 7035 &hSharedHandle, 7036 #endif 6865 7037 NULL); 6866 7038 Assert(hr == S_OK); … … 6871 7043 pAllocation->pD3DIf = pD3DIfCubeTex; 6872 7044 Assert(pAllocation->hSharedHandle == hSharedHandle); 7045 #ifndef VBOXWDDMDISP_DEBUG_NOSHARED 6873 7046 Assert(pAllocation->hSharedHandle); 7047 #endif 6874 7048 } 6875 7049 -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3D.h
r38363 r38903 31 31 #define VBOXWDDMDISP_MAX_VERTEX_STREAMS 16 32 32 #define VBOXWDDMDISP_MAX_SWAPCHAIN_SIZE 16 33 /* maximum number of direct render targets to be used before 34 * switching to offscreen rendering */ 35 #define VBOXWDDMDISP_MAX_DIRECT_RTS 3 33 36 34 37 #define VBOXWDDMDISP_IS_TEXTURE(_f) ((_f).Texture || (_f).Value == 0) … … 129 132 struct 130 133 { 131 UINT bChanged : 1; 132 UINT Reserved : 31; 134 UINT bChanged : 1; 135 UINT bRtReportingPresent : 1; /* use VBox extension method for performing present */ 136 UINT bSwitchReportingPresent : 1; /* switch to use VBox extension method for performing present on next present */ 137 UINT Reserved : 30; 133 138 }; 134 139 uint32_t Value; -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3DIf.cpp
r38363 r38903 59 59 if (pD3D->pfnVBoxWineExD3DDev9Update) 60 60 { 61 return S_OK; 61 pD3D->pfnVBoxWineExD3DSwapchain9Present = (PFNVBOXWINEEXD3DSWAPCHAIN9_PRESENT)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DSwapchain9Present"); 62 Assert(pD3D->pfnVBoxWineExD3DSwapchain9Present); 63 if (pD3D->pfnVBoxWineExD3DSwapchain9Present) 64 { 65 return S_OK; 66 } 62 67 } 63 68 } -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3DIf.h
r38363 r38903 45 45 PFNVBOXWINEEXD3DDEV9_UPDATE pfnVBoxWineExD3DDev9Update; 46 46 47 PFNVBOXWINEEXD3DSWAPCHAIN9_PRESENT pfnVBoxWineExD3DSwapchain9Present; 47 48 48 49 /* module handle */ -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispDbg.h
r38117 r38903 34 34 /* adds vectored exception handler to be able to catch non-debug UM exceptions in kernel debugger */ 35 35 # define VBOXWDDMDISP_DEBUG_VEHANDLER 36 /* disable shared resource creation with wine */ 37 //# define VBOXWDDMDISP_DEBUG_NOSHARED 36 38 # endif 37 39 #endif -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dbg/VBoxVideoWinDbg.cpp
r36867 r38903 106 106 PCSTR pExpr = args; 107 107 108 /* address */ 108 109 if (!pExpr) { dprintf("address not specified\n"); return; } 109 110 if (!GetExpressionEx(pExpr, &u64Mem, &pExpr)) { dprintf("error evaluating address\n"); return; } 110 111 if (!u64Mem) { dprintf("address value can not be NULL\n"); return; } 111 112 113 /* width */ 112 114 if (!pExpr) { dprintf("width not specified\n"); return; } 113 115 if (!GetExpressionEx(pExpr, &u64Width, &pExpr)) { dprintf("error evaluating width\n"); return; } 114 116 if (!u64Width) { dprintf("width value can not be NULL\n"); return; } 115 117 118 /* height */ 116 119 if (!pExpr) { dprintf("height not specified\n"); return; } 117 120 if (!GetExpressionEx(pExpr, &u64Height, &pExpr)) { dprintf("error evaluating height\n"); return; } 118 121 if (!u64Height) { dprintf("height value can not be NULL\n"); return; } 119 122 123 #if 0 120 124 if (pExpr && GetExpressionEx(pExpr, &u64NumColors, &pExpr)) 121 125 { 122 126 if (!u64NumColors) { dprintf("Num Colors value can not be NULL\n"); return; } 123 127 } 124 128 #endif 129 130 /* bpp */ 125 131 if (pExpr && GetExpressionEx(pExpr, &u64Bpp, &pExpr)) 126 132 { … … 128 134 } 129 135 136 /* pitch */ 130 137 u64DefaultPitch = (((((u64Width * u64Bpp) + 7) >> 3) + 3) & ~3ULL); 131 138 if (pExpr && GetExpressionEx(pExpr, &u64Pitch, &pExpr)) 132 139 { 133 if (u64Pitch < u64DefaultPitch) { dprintf("pitch value can not be less than (% I)\n",u64DefaultPitch); return; }140 if (u64Pitch < u64DefaultPitch) { dprintf("pitch value can not be less than (%d)\n", (UINT)u64DefaultPitch); return; } 134 141 } 135 142 else … … 143 150 ULONG64 cbSize = u64DefaultPitch * u64Height; 144 151 PVOID pvBuf = malloc(cbSize); 145 if (pvBuf) 146 { 147 ULONG uRc = 0; 148 if(u64DefaultPitch == u64Pitch) 152 if (!pvBuf) 153 { 154 dprintf("failed to allocate memory buffer of size(%d)\n", (UINT)cbSize); 155 return; 156 } 157 ULONG uRc = 0; 158 #if 0 159 if(u64DefaultPitch == u64Pitch) 160 #else 161 if(0) 162 #endif 163 { 164 ULONG cbRead = 0; 165 dprintf("reading the entire memory buffer...\n"); 166 uRc = ReadMemory(u64Mem, pvBuf, cbSize, &cbRead); 167 if (!uRc) 168 { 169 dprintf("Failed to read the memory buffer of size(%d)\n", (UINT)cbSize); 170 } 171 else if (cbRead != cbSize) 172 { 173 dprintf("the actual number of bytes read(%d) no equal the requested size(%d)\n", (UINT)cbRead, (UINT)cbSize); 174 uRc = 0; 175 } 176 177 } 178 else 179 { 180 ULONG64 u64Offset = u64Mem; 181 char* pvcBuf = (char*)pvBuf; 182 ULONG64 i; 183 dprintf("reading memory by chunks since custom pitch is specified...\n"); 184 for (i = 0; i < u64Height; ++i, u64Offset+=u64Pitch, pvcBuf+=u64DefaultPitch) 149 185 { 150 186 ULONG cbRead = 0; 151 dprintf("reading the entire memory buffer...\n"); 152 uRc = ReadMemory(u64Mem, pvBuf, cbSize, &cbRead); 187 uRc = ReadMemory(u64Offset, pvcBuf, u64DefaultPitch, &cbRead); 153 188 if (!uRc) 154 189 { 155 dprintf("Failed to read the memory buffer of size(%I)\n", cbSize); 156 } 157 else if (cbRead != cbSize) 158 { 159 dprintf("the actual number of bytes read(%I) no equal the requested size(%I)\n", cbRead, cbSize); 160 uRc = 0; 161 } 162 163 } 164 else 165 { 166 ULONG64 u64Offset = u64Mem; 167 char* pvcBuf = (char*)pvBuf; 168 ULONG64 i; 169 dprintf("reading memory by chunks since custom pitch is specified...\n"); 170 for (i = 0; i < u64Height; ++i, u64Offset+=u64Pitch, pvcBuf+=u64DefaultPitch) 171 { 172 ULONG cbRead = 0; 173 uRc = ReadMemory(u64Offset, pvcBuf, u64DefaultPitch, &cbRead); 174 if (!uRc) 190 dprintf("WARNING!!! Failed to read the memory buffer of size(%d), chunk(%d)\n", (UINT)u64DefaultPitch, (UINT)i); 191 dprintf("ignoring this one and the all the rest, using height(%d)\n", (UINT)i); 192 u64Height = i; 193 uRc = 1; 194 break; 195 } 196 else if (cbRead != u64DefaultPitch) 197 { 198 dprintf("WARNING!!! the actual number of bytes read(%d) not equal the requested size(%d), chunk(%d)\n", (UINT)cbRead, (UINT)u64DefaultPitch, (UINT)i); 199 dprintf("ignoring this one and the all the rest, using height(%d)\n", (UINT)i); 200 u64Height = i; 201 break; 202 } 203 } 204 } 205 206 if (!uRc) 207 { 208 dprintf("read memory failed\n"); 209 free(pvBuf); 210 return; 211 } 212 213 if (!u64Height) 214 { 215 dprintf("no data to be processed since height it 0\n"); 216 free(pvBuf); 217 return; 218 } 219 220 switch (u64Bpp) 221 { 222 case 32: 223 case 24: 224 case 16: 225 #if 0 226 if (u64NumColors != 3) 227 { 228 dprintf("WARNING: unsupported number colors: (%d)\n", (UINT)u64NumColors); 229 } 230 #else 231 u64NumColors = 3; 232 #endif 233 break; 234 case 8: 235 { 236 #if 1 237 u64NumColors = 1; 238 #endif 239 240 if (u64NumColors == 1) 175 241 { 176 dprintf("Failed to read the memory buffer of size(%I), chunk(%I)\n", u64DefaultPitch, i); 177 break; 178 } 179 else if (cbRead != u64DefaultPitch) 180 { 181 dprintf("the actual number of bytes read(%I) no equal the requested size(%I), chunk(%I)\n", cbRead, u64DefaultPitch, i); 182 uRc = 0; 183 break; 184 } 185 } 186 } 187 188 if (uRc) 189 { 190 switch (u64Bpp) 191 { 192 case 32: 193 case 24: 194 case 16: 195 if (u64NumColors != 3) 242 ULONG64 cbSize32 = u64DefaultPitch * 4 * u64Height; 243 PVOID pvBuf32 = malloc(cbSize32); 244 if (!pvBuf32) 196 245 { 197 dprintf("WARNING: unsupported number colors: (%d)\n", u64NumColors); 246 dprintf("ERROR: failed to allocate memory buffer of size(%d)", cbSize32); 247 free(pvBuf); 248 return; 198 249 } 199 break; 200 case 8: 250 byte* pByteBuf32 = (byte*)pvBuf32; 251 byte* pByteBuf = (byte*)pvBuf; 252 memset(pvBuf32, 0, cbSize32); 253 for (UINT i = 0; i < u64Height; ++i) 201 254 { 202 if (u64NumColors == 1)255 for (UINT j = 0; j < u64Width; ++j) 203 256 { 204 ULONG64 cbSize32 = u64DefaultPitch * 4 * u64Height; 205 PVOID pvBuf32 = malloc(cbSize32); 206 if (pvBuf32) 207 { 208 byte* pByteBuf32 = (byte*)pvBuf32; 209 byte* pByteBuf = (byte*)pvBuf; 210 memset(pvBuf32, 0, cbSize32); 211 for (UINT i = 0; i < u64Height; ++i) 212 { 213 for (UINT j = 0; j < u64Width; ++j) 214 { 215 pByteBuf32[0] = pByteBuf[0]; 216 pByteBuf32[1] = pByteBuf[0]; 217 pByteBuf32[2] = pByteBuf[0]; 218 pByteBuf32 += 4; 219 pByteBuf += 1; 220 } 221 } 222 free(pvBuf); 223 pvBuf = pvBuf32; 224 u64DefaultPitch *= 4; 225 u64Bpp *= 4; 226 } 227 } 228 else 229 { 230 dprintf("WARNING: unsupported number colors: (%d)\n", u64NumColors); 257 pByteBuf32[0] = pByteBuf[0]; 258 pByteBuf32[1] = pByteBuf[0]; 259 pByteBuf32[2] = pByteBuf[0]; 260 pByteBuf32 += 4; 261 pByteBuf += 1; 231 262 } 232 263 } 233 break; 234 } 235 BITMAP Bmp = {0}; 236 HBITMAP hBmp; 237 dprintf("read memory succeeded..\n"); 238 Bmp.bmType = 0; 239 Bmp.bmWidth = (LONG)u64Width; 240 Bmp.bmHeight = (LONG)u64Height; 241 Bmp.bmWidthBytes = (LONG)u64DefaultPitch; 242 Bmp.bmPlanes = 1; 243 Bmp.bmBitsPixel = (WORD)u64Bpp; 244 Bmp.bmBits = (LPVOID)pvBuf; 245 hBmp = CreateBitmapIndirect(&Bmp); 246 if (hBmp) 247 { 248 if (OpenClipboard(GetDesktopWindow())) 264 free(pvBuf); 265 pvBuf = pvBuf32; 266 u64DefaultPitch *= 4; 267 u64Bpp *= 4; 268 } 269 else 249 270 { 250 if (EmptyClipboard()) 251 { 252 if (SetClipboardData(CF_BITMAP, hBmp)) 253 { 254 dprintf("succeeded!! You can now do <ctrl>+v in your favourite image editor\n"); 255 } 256 else 257 { 258 DWORD winEr = GetLastError(); 259 dprintf("SetClipboardData failed, err(%I)\n", winEr); 260 } 261 } 262 else 263 { 264 DWORD winEr = GetLastError(); 265 dprintf("EmptyClipboard failed, err(%I)\n", winEr); 266 } 267 268 CloseClipboard(); 271 dprintf("WARNING: unsupported number colors: (%d)\n", (UINT)u64NumColors); 272 } 273 } 274 break; 275 } 276 BITMAP Bmp = {0}; 277 HBITMAP hBmp; 278 dprintf("read memory succeeded..\n"); 279 Bmp.bmType = 0; 280 Bmp.bmWidth = (LONG)u64Width; 281 Bmp.bmHeight = (LONG)u64Height; 282 Bmp.bmWidthBytes = (LONG)u64DefaultPitch; 283 Bmp.bmPlanes = 1; 284 Bmp.bmBitsPixel = (WORD)u64Bpp; 285 Bmp.bmBits = (LPVOID)pvBuf; 286 hBmp = CreateBitmapIndirect(&Bmp); 287 if (hBmp) 288 { 289 if (OpenClipboard(GetDesktopWindow())) 290 { 291 if (EmptyClipboard()) 292 { 293 if (SetClipboardData(CF_BITMAP, hBmp)) 294 { 295 dprintf("succeeded!! You can now do <ctrl>+v in your favourite image editor\n"); 269 296 } 270 297 else 271 298 { 272 299 DWORD winEr = GetLastError(); 273 dprintf(" OpenClipboard failed, err(%I)\n", winEr);300 dprintf("SetClipboardData failed, err(%d)\n", winEr); 274 301 } 275 276 DeleteObject(hBmp);277 302 } 278 303 else 279 304 { 280 305 DWORD winEr = GetLastError(); 281 dprintf("CreateBitmapIndirect failed, err(%I)\n", winEr); 282 } 306 dprintf("EmptyClipboard failed, err(%d)\n", winEr); 307 } 308 309 CloseClipboard(); 283 310 } 284 311 else 285 312 { 286 dprintf("read memory failed\n"); 287 } 288 free(pvBuf); 313 DWORD winEr = GetLastError(); 314 dprintf("OpenClipboard failed, err(%d)\n", winEr); 315 } 316 317 DeleteObject(hBmp); 289 318 } 290 319 else 291 320 { 292 dprintf("failed to allocate memory buffer of size(%I)\n", cbSize); 293 } 294 } 321 DWORD winEr = GetLastError(); 322 dprintf("CreateBitmapIndirect failed, err(%d)\n", winEr); 323 } 324 }
Note:
See TracChangeset
for help on using the changeset viewer.