Changeset 72241 in vbox
- Timestamp:
- May 17, 2018 12:48:56 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp
r71686 r72241 2390 2390 2391 2391 2392 int vmsvga3dSurfaceBlitToScreen(PVGASTATE pThis, uint32_t dest, SVGASignedRect destRect, SVGA3dSurfaceImageId src, SVGASignedRect srcRect, uint32_t cRects, SVGASignedRect *pRect)2392 int vmsvga3dSurfaceBlitToScreen(PVGASTATE pThis, uint32_t idDstScreen, SVGASignedRect destRect, SVGA3dSurfaceImageId src, SVGASignedRect srcRect, uint32_t cRects, SVGASignedRect *pRect) 2393 2393 { 2394 2394 /* Requires SVGA_FIFO_CAP_SCREEN_OBJECT support */ 2395 Log(("vmsvga3dSurfaceBlitToScreen: dest=%d (%d,%d)(%d,%d) sid=%x (face=%d, mipmap=%d) (%d,%d)(%d,%d) cRects=%d\n", dest, destRect.left, destRect.top, destRect.right, destRect.bottom, src.sid, src.face, src.mipmap, srcRect.left, srcRect.top, srcRect.right, srcRect.bottom, cRects)); 2395 LogFunc(("dest=%d (%d,%d)(%d,%d) sid=%x (face=%d, mipmap=%d) (%d,%d)(%d,%d) cRects=%d\n", 2396 idDstScreen, destRect.left, destRect.top, destRect.right, destRect.bottom, src.sid, src.face, src.mipmap, 2397 srcRect.left, srcRect.top, srcRect.right, srcRect.bottom, cRects)); 2396 2398 for (uint32_t i = 0; i < cRects; i++) 2397 2399 { 2398 Log (("vmsvga3dSurfaceBlitToScreen:clipping rect %d (%d,%d)(%d,%d)\n", i, pRect[i].left, pRect[i].top, pRect[i].right, pRect[i].bottom));2400 LogFunc(("clipping rect %d (%d,%d)(%d,%d)\n", i, pRect[i].left, pRect[i].top, pRect[i].right, pRect[i].bottom)); 2399 2401 } 2400 2402 2401 2403 /** @todo Only screen 0 for now. */ 2402 AssertReturn( dest== 0, VERR_INTERNAL_ERROR);2404 AssertReturn(idDstScreen == 0, VERR_INTERNAL_ERROR); 2403 2405 AssertReturn(src.mipmap == 0 && src.face == 0, VERR_INVALID_PARAMETER); 2404 2406 /** @todo scaling */ 2405 2407 AssertReturn(destRect.right - destRect.left == srcRect.right - srcRect.left && destRect.bottom - destRect.top == srcRect.bottom - srcRect.top, VERR_INVALID_PARAMETER); 2406 2408 2409 SVGA3dCopyBox box; 2410 SVGA3dGuestImage dest; 2411 2412 box.srcz = 0; 2413 box.z = 0; 2414 box.d = 1; 2415 2416 /** @todo SVGA_GMR_FRAMEBUFFER is not the screen object 2417 * and might not point to the start of VRAM as assumed here. 2418 */ 2419 dest.ptr.gmrId = SVGA_GMR_FRAMEBUFFER; 2420 dest.ptr.offset = pThis->svga.uScreenOffset; 2421 dest.pitch = pThis->svga.cbScanline; 2422 2407 2423 if (cRects == 0) 2408 2424 { 2409 2425 /* easy case; no clipping */ 2410 SVGA3dCopyBox box; 2411 SVGA3dGuestImage dest; 2412 2413 box.x = destRect.left; 2414 box.y = destRect.top; 2415 box.z = 0; 2416 box.w = destRect.right - destRect.left; 2417 box.h = destRect.bottom - destRect.top; 2418 box.d = 1; 2419 box.srcx = srcRect.left; 2420 box.srcy = srcRect.top; 2421 box.srcz = 0; 2422 2423 dest.ptr.gmrId = SVGA_GMR_FRAMEBUFFER; 2424 dest.ptr.offset = pThis->svga.uScreenOffset; 2425 dest.pitch = pThis->svga.cbScanline; 2426 2427 /* SVGA_3D_CMD_SURFACE_DMA: 2428 * 'define the "source" in each copyBox as the guest image and the 2429 * "destination" as the host image, regardless of transfer direction.' 2430 * 2431 * Since the BlitToScreen operation transfers from a host surface to the guest VRAM, 2432 * it must set the copyBox "source" to the guest destination coords and 2433 * the copyBox "destination" to the host surface source coords. 2434 */ 2435 /* Host image. */ 2436 box.x = srcRect.left; 2437 box.y = srcRect.top; 2438 box.w = srcRect.right - srcRect.left; 2439 box.h = srcRect.bottom - srcRect.top; 2440 /* Guest image. */ 2441 box.srcx = destRect.left; 2442 box.srcy = destRect.top; 2426 2443 2427 2444 int rc = vmsvga3dSurfaceDMA(pThis, dest, src, SVGA3D_READ_HOST_VRAM, 1, &box); 2428 2445 AssertRCReturn(rc, rc); 2429 2446 2430 vgaR3UpdateDisplay(pThis, box.x, box.y, box.w, box.h);2431 return VINF_SUCCESS;2447 /* Update the guest image, which is at box.src. */ 2448 vgaR3UpdateDisplay(pThis, box.srcx, box.srcy, box.w, box.h); 2432 2449 } 2433 2450 else 2434 2451 { 2435 SVGA3dGuestImage dest;2436 SVGA3dCopyBox box;2437 2438 box.srcz = 0;2439 box.z = 0;2440 box.d = 1;2441 2442 dest.ptr.gmrId = SVGA_GMR_FRAMEBUFFER;2443 dest.ptr.offset = pThis->svga.uScreenOffset;2444 dest.pitch = pThis->svga.cbScanline;2445 2446 2452 /** @todo merge into one SurfaceDMA call */ 2447 2453 for (uint32_t i = 0; i < cRects; i++) 2448 2454 { 2449 2455 /* The clipping rectangle is relative to the top-left corner of srcRect & destRect. Adjust here. */ 2450 box.srcx = srcRect.left + pRect[i].left; 2451 box.srcy = srcRect.top + pRect[i].top; 2452 2453 box.x = pRect[i].left + destRect.left; 2454 box.y = pRect[i].top + destRect.top; 2456 /* Host image. See 'SVGA_3D_CMD_SURFACE_DMA:' commant in the 'if' branch. */ 2457 box.x = srcRect.left + pRect[i].left; 2458 box.y = srcRect.top + pRect[i].top; 2455 2459 box.z = 0; 2456 2460 box.w = pRect[i].right - pRect[i].left; 2457 2461 box.h = pRect[i].bottom - pRect[i].top; 2462 /* Guest image. */ 2463 box.srcx = destRect.left + pRect[i].left; 2464 box.srcy = destRect.top + pRect[i].top; 2458 2465 2459 2466 int rc = vmsvga3dSurfaceDMA(pThis, dest, src, SVGA3D_READ_HOST_VRAM, 1, &box); 2460 2467 AssertRCReturn(rc, rc); 2461 2468 2462 vgaR3UpdateDisplay(pThis, box.x, box.y, box.w, box.h); 2463 } 2464 2465 #if 0 2466 { 2467 PVMSVGA3DSTATE pState = pThis->svga.p3dState; 2468 HRESULT hr; 2469 PVMSVGA3DSURFACE pSurface; 2470 PVMSVGA3DCONTEXT pContext; 2471 uint32_t sid = src.sid; 2472 AssertReturn(sid < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER); 2473 AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER); 2474 2475 pSurface = pState->papSurfaces[sid]; 2476 uint32_t cid; 2477 2478 /** @todo stricter checks for associated context */ 2479 cid = pSurface->idAssociatedContext; 2480 2481 if ( cid >= pState->cContexts 2482 || pState->papContexts[cid]->id != cid) 2483 { 2484 Log(("vmsvga3dGenerateMipmaps invalid context id!\n")); 2485 return VERR_INVALID_PARAMETER; 2486 } 2487 pContext = pState->papContexts[cid]; 2488 2489 if (pSurface->id == 0x5e) 2490 { 2491 IDirect3DSurface9 *pSrc; 2492 2493 hr = pSurface->u.pTexture->GetSurfaceLevel(0/* Texture level */, 2494 &pSrc); 2495 AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceStretchBlt: GetSurfaceLevel failed with %x\n", hr), VERR_INTERNAL_ERROR); 2496 2497 pContext->pDevice->ColorFill(pSrc, NULL, (D3DCOLOR)0x11122255); 2498 D3D_RELEASE(pSrc); 2499 } 2500 } 2501 #endif 2502 2503 return VINF_SUCCESS; 2504 } 2469 /* Update the guest image, which is at box.src. */ 2470 vgaR3UpdateDisplay(pThis, box.srcx, box.srcy, box.w, box.h); 2471 } 2472 } 2473 2474 return VINF_SUCCESS; 2505 2475 } 2506 2476
Note:
See TracChangeset
for help on using the changeset viewer.