- Timestamp:
- Nov 4, 2014 3:30:43 PM (10 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 704 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp
r50328 r53201 46 46 #endif 47 47 48 /** Converts a display port interface pointer to a vga state pointer. */ 49 #define IDISPLAYPORT_2_VGASTATE(pInterface) ( (PVGASTATE)((uintptr_t)pInterface - RT_OFFSETOF(VGASTATE, IPort)) ) 50 48 51 #include "DevVGA-SVGA.h" 49 52 #include "vmsvga/svga_reg.h" … … 69 72 typedef struct 70 73 { 74 uint32_t cMaxPages; 71 75 uint32_t cbTotal; 72 76 uint32_t numDescriptors; … … 84 88 SVGAGMRImageFormat format; 85 89 } GMRFB; 90 struct 91 { 92 bool fActive; 93 uint32_t xHotspot; 94 uint32_t yHotspot; 95 uint32_t width; 96 uint32_t height; 97 uint32_t cbData; 98 void *pData; 99 } Cursor; 86 100 SVGAColorBGRX colorAnnotation; 87 101 STAMPROFILE StatR3CmdPresent; … … 107 121 static SSMFIELD const g_aGMRFields[] = 108 122 { 123 SSMFIELD_ENTRY( GMR, cMaxPages), 109 124 SSMFIELD_ENTRY( GMR, cbTotal), 110 125 SSMFIELD_ENTRY( GMR, numDescriptors), … … 120 135 SSMFIELD_ENTRY_IGNORE( VMSVGASTATE, aGMR), 121 136 SSMFIELD_ENTRY( VMSVGASTATE, GMRFB), 137 SSMFIELD_ENTRY( VMSVGASTATE, Cursor.fActive), 138 SSMFIELD_ENTRY( VMSVGASTATE, Cursor.xHotspot), 139 SSMFIELD_ENTRY( VMSVGASTATE, Cursor.yHotspot), 140 SSMFIELD_ENTRY( VMSVGASTATE, Cursor.width), 141 SSMFIELD_ENTRY( VMSVGASTATE, Cursor.height), 142 SSMFIELD_ENTRY( VMSVGASTATE, Cursor.cbData), 143 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGASTATE, Cursor.pData), 122 144 SSMFIELD_ENTRY( VMSVGASTATE, colorAnnotation), 123 145 SSMFIELD_ENTRY_IGNORE( VMSVGASTATE, StatR3CmdPresent), … … 132 154 static SSMFIELD const g_aVGAStateSVGAFields[] = 133 155 { 134 SSMFIELD_ENTRY_IGNORE( VGAState, svga.u64HostWindowId), 135 SSMFIELD_ENTRY_IGN_HCPTR( VGAState, svga.pFIFOR3), 136 SSMFIELD_ENTRY_IGN_HCPTR( VGAState, svga.pFIFOR0), 137 SSMFIELD_ENTRY_IGN_HCPTR( VGAState, svga.pSVGAState), 138 SSMFIELD_ENTRY_IGN_HCPTR( VGAState, svga.p3dState), 139 SSMFIELD_ENTRY_IGNORE( VGAState, svga.pFrameBufferBackup), 140 SSMFIELD_ENTRY_IGN_GCPHYS( VGAState, svga.GCPhysFIFO), 141 SSMFIELD_ENTRY_IGNORE( VGAState, svga.cbFIFO), 142 SSMFIELD_ENTRY( VGAState, svga.u32SVGAId), 143 SSMFIELD_ENTRY( VGAState, svga.fEnabled), 144 SSMFIELD_ENTRY( VGAState, svga.fConfigured), 145 SSMFIELD_ENTRY( VGAState, svga.fBusy), 146 SSMFIELD_ENTRY( VGAState, svga.fTraces), 147 SSMFIELD_ENTRY( VGAState, svga.u32GuestId), 148 SSMFIELD_ENTRY( VGAState, svga.cScratchRegion), 149 SSMFIELD_ENTRY( VGAState, svga.au32ScratchRegion), 150 SSMFIELD_ENTRY( VGAState, svga.u32IrqStatus), 151 SSMFIELD_ENTRY( VGAState, svga.u32IrqMask), 152 SSMFIELD_ENTRY( VGAState, svga.u32PitchLock), 153 SSMFIELD_ENTRY( VGAState, svga.u32CurrentGMRId), 154 SSMFIELD_ENTRY( VGAState, svga.u32RegCaps), 155 SSMFIELD_ENTRY_IGNORE( VGAState, svga.BasePort), 156 SSMFIELD_ENTRY( VGAState, svga.u32IndexReg), 157 SSMFIELD_ENTRY_IGNORE( VGAState, svga.FIFORequestSem), 158 SSMFIELD_ENTRY_IGN_HCPTR( VGAState, svga.pFIFOIOThread), 159 SSMFIELD_ENTRY( VGAState, svga.iWidth), 160 SSMFIELD_ENTRY( VGAState, svga.iHeight), 161 SSMFIELD_ENTRY( VGAState, svga.iBpp), 162 SSMFIELD_ENTRY( VGAState, svga.cbScanline), 163 SSMFIELD_ENTRY( VGAState, svga.u32MaxWidth), 164 SSMFIELD_ENTRY( VGAState, svga.u32MaxHeight), 165 SSMFIELD_ENTRY( VGAState, svga.u32ActionFlags), 166 SSMFIELD_ENTRY( VGAState, svga.f3DEnabled), 167 SSMFIELD_ENTRY( VGAState, svga.fVRAMTracking), 168 SSMFIELD_ENTRY( VGAState, svga.Padding6), 156 SSMFIELD_ENTRY_IGNORE( VMSVGAState, u64HostWindowId), 157 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGAState, pFIFOR3), 158 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGAState, pFIFOR0), 159 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGAState, pSVGAState), 160 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGAState, p3dState), 161 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGAState, pFrameBufferBackup), 162 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGAState, pFIFOExtCmdParam), 163 SSMFIELD_ENTRY_IGN_GCPHYS( VMSVGAState, GCPhysFIFO), 164 SSMFIELD_ENTRY_IGNORE( VMSVGAState, cbFIFO), 165 SSMFIELD_ENTRY( VMSVGAState, u32SVGAId), 166 SSMFIELD_ENTRY( VMSVGAState, fEnabled), 167 SSMFIELD_ENTRY( VMSVGAState, fConfigured), 168 SSMFIELD_ENTRY( VMSVGAState, fBusy), 169 SSMFIELD_ENTRY( VMSVGAState, fTraces), 170 SSMFIELD_ENTRY( VMSVGAState, u32GuestId), 171 SSMFIELD_ENTRY( VMSVGAState, cScratchRegion), 172 SSMFIELD_ENTRY( VMSVGAState, au32ScratchRegion), 173 SSMFIELD_ENTRY( VMSVGAState, u32IrqStatus), 174 SSMFIELD_ENTRY( VMSVGAState, u32IrqMask), 175 SSMFIELD_ENTRY( VMSVGAState, u32PitchLock), 176 SSMFIELD_ENTRY( VMSVGAState, u32CurrentGMRId), 177 SSMFIELD_ENTRY( VMSVGAState, u32RegCaps), 178 SSMFIELD_ENTRY_IGNORE( VMSVGAState, BasePort), 179 SSMFIELD_ENTRY( VMSVGAState, u32IndexReg), 180 SSMFIELD_ENTRY_IGNORE( VMSVGAState, FIFORequestSem), 181 SSMFIELD_ENTRY_IGNORE( VMSVGAState, FIFOExtCmdSem), 182 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGAState, pFIFOIOThread), 183 SSMFIELD_ENTRY( VMSVGAState, uWidth), 184 SSMFIELD_ENTRY( VMSVGAState, uHeight), 185 SSMFIELD_ENTRY( VMSVGAState, uBpp), 186 SSMFIELD_ENTRY( VMSVGAState, cbScanline), 187 SSMFIELD_ENTRY( VMSVGAState, u32MaxWidth), 188 SSMFIELD_ENTRY( VMSVGAState, u32MaxHeight), 189 SSMFIELD_ENTRY( VMSVGAState, u32ActionFlags), 190 SSMFIELD_ENTRY( VMSVGAState, f3DEnabled), 191 SSMFIELD_ENTRY( VMSVGAState, fVRAMTracking), 192 SSMFIELD_ENTRY_IGNORE( VMSVGAState, u8FIFOExtCommand), 169 193 SSMFIELD_ENTRY_TERM() 170 194 }; … … 423 447 424 448 /** 449 * Inform the VGA device of viewport changes (as a result of e.g. scrolling) 450 * 451 * @param pInterface Pointer to this interface. 452 * @param 453 * @param uScreenId The screen updates are for. 454 * @param x The upper left corner x coordinate of the new viewport rectangle 455 * @param y The upper left corner y coordinate of the new viewport rectangle 456 * @param cx The width of the new viewport rectangle 457 * @param cy The height of the new viewport rectangle 458 * @thread The emulation thread. 459 */ 460 DECLCALLBACK(void) vmsvgaPortSetViewPort(PPDMIDISPLAYPORT pInterface, uint32_t uScreenId, uint32_t x, uint32_t y, uint32_t cx, uint32_t cy) 461 { 462 PVGASTATE pThis = IDISPLAYPORT_2_VGASTATE(pInterface); 463 464 Log(("vmsvgaPortSetViewPort: screen %d (%d,%d)(%d,%d)\n", uScreenId, x, y, cx, cy)); 465 466 pThis->svga.viewport.x = x; 467 pThis->svga.viewport.y = y; 468 pThis->svga.viewport.cx = RT_MIN(cx, (uint32_t)pThis->svga.uWidth); 469 pThis->svga.viewport.cy = RT_MIN(cy, (uint32_t)pThis->svga.uHeight); 470 return; 471 } 472 473 /** 425 474 * Read port register 426 475 * … … 447 496 { 448 497 if ( pThis->svga.fEnabled 449 && pThis->svga. iWidth != -1)450 { 451 *pu32 = pThis->svga. iWidth;498 && pThis->svga.uWidth != VMSVGA_VAL_UNINITIALIZED) 499 { 500 *pu32 = pThis->svga.uWidth; 452 501 } 453 502 else … … 465 514 { 466 515 if ( pThis->svga.fEnabled 467 && pThis->svga. iHeight != -1)468 { 469 *pu32 = pThis->svga. iHeight;516 && pThis->svga.uHeight != VMSVGA_VAL_UNINITIALIZED) 517 { 518 *pu32 = pThis->svga.uHeight; 470 519 } 471 520 else … … 490 539 case SVGA_REG_DEPTH: 491 540 /* This returns the color depth of the current mode. */ 492 switch (pThis->svga. iBpp)541 switch (pThis->svga.uBpp) 493 542 { 494 543 case 15: 495 544 case 16: 496 545 case 24: 497 *pu32 = pThis->svga. iBpp;546 *pu32 = pThis->svga.uBpp; 498 547 break; 499 548 … … 507 556 case SVGA_REG_HOST_BITS_PER_PIXEL: /* (Deprecated) */ 508 557 if ( pThis->svga.fEnabled 509 && pThis->svga. iBpp != (unsigned)-1)510 { 511 *pu32 = pThis->svga. iBpp;558 && pThis->svga.uBpp != VMSVGA_VAL_UNINITIALIZED) 559 { 560 *pu32 = pThis->svga.uBpp; 512 561 } 513 562 else … … 523 572 case SVGA_REG_BITS_PER_PIXEL: /* Current bpp in the guest */ 524 573 if ( pThis->svga.fEnabled 525 && pThis->svga. iBpp != (unsigned)-1)526 { 527 *pu32 = (pThis->svga. iBpp + 7) & ~7;574 && pThis->svga.uBpp != VMSVGA_VAL_UNINITIALIZED) 575 { 576 *pu32 = (pThis->svga.uBpp + 7) & ~7; 528 577 } 529 578 else … … 545 594 case SVGA_REG_BLUE_MASK: 546 595 { 547 uint32_t iBpp;596 uint32_t uBpp; 548 597 549 598 if ( pThis->svga.fEnabled 550 && pThis->svga. iBpp != (unsigned)-1)551 { 552 iBpp = pThis->svga.iBpp;599 && pThis->svga.uBpp != VMSVGA_VAL_UNINITIALIZED) 600 { 601 uBpp = pThis->svga.uBpp; 553 602 } 554 603 else … … 558 607 break; 559 608 #else 560 iBpp = pThis->pDrv->cBits;609 uBpp = pThis->pDrv->cBits; 561 610 #endif 562 611 } 563 612 uint32_t u32RedMask, u32GreenMask, u32BlueMask; 564 switch ( iBpp)613 switch (uBpp) 565 614 { 566 615 case 8: … … 646 695 /* VMWare testcases want at least 4 MB in case the hardware is disabled. */ 647 696 if ( pThis->svga.fEnabled 648 && pThis->svga. iHeight != -1)697 && pThis->svga.uHeight != VMSVGA_VAL_UNINITIALIZED) 649 698 { 650 699 /* Hardware enabled; return real framebuffer size .*/ 651 *pu32 = (uint32_t)pThis->svga. iHeight * pThis->svga.cbScanline;700 *pu32 = (uint32_t)pThis->svga.uHeight * pThis->svga.cbScanline; 652 701 } 653 702 else … … 772 821 773 822 case SVGA_REG_DISPLAY_WIDTH: /* The display's width */ 774 *pu32 = pThis->svga. iWidth;823 *pu32 = pThis->svga.uWidth; 775 824 break; 776 825 777 826 case SVGA_REG_DISPLAY_HEIGHT: /* The display's height */ 778 *pu32 = pThis->svga. iHeight;827 *pu32 = pThis->svga.uHeight; 779 828 break; 780 829 … … 806 855 int rc; 807 856 808 if ( pThis->svga. iWidth == -1809 || pThis->svga. iHeight == -1810 || pThis->svga. iBpp == (unsigned)-1)857 if ( pThis->svga.uWidth == VMSVGA_VAL_UNINITIALIZED 858 || pThis->svga.uHeight == VMSVGA_VAL_UNINITIALIZED 859 || pThis->svga.uBpp == VMSVGA_VAL_UNINITIALIZED) 811 860 { 812 861 /* Mode change in progress; wait for all values to be set. */ 813 Log(("vmsvgaChangeMode: BOGUS sEnable LFB mode and resize to (%d,%d) bpp=%d\n", pThis->svga. iWidth, pThis->svga.iHeight, pThis->svga.iBpp));862 Log(("vmsvgaChangeMode: BOGUS sEnable LFB mode and resize to (%d,%d) bpp=%d\n", pThis->svga.uWidth, pThis->svga.uHeight, pThis->svga.uBpp)); 814 863 return VINF_SUCCESS; 815 864 } 816 865 817 if ( pThis->last_bpp == (unsigned)pThis->svga.iBpp 818 && pThis->last_scr_width == (unsigned)pThis->svga.iWidth 819 && pThis->last_scr_height == (unsigned)pThis->svga.iHeight 820 && pThis->last_width == (unsigned)pThis->svga.iWidth 821 && pThis->last_height == (unsigned)pThis->svga.iHeight 866 if ( pThis->svga.uWidth == 0 867 || pThis->svga.uHeight == 0 868 || pThis->svga.uBpp == 0) 869 { 870 /* Invalid mode change. */ 871 Log(("vmsvgaChangeMode: BOGUS sEnable LFB mode and resize to (%d,%d) bpp=%d\n", pThis->svga.uWidth, pThis->svga.uHeight, pThis->svga.uBpp)); 872 return VINF_SUCCESS; 873 } 874 875 if ( pThis->last_bpp == (unsigned)pThis->svga.uBpp 876 && pThis->last_scr_width == (unsigned)pThis->svga.uWidth 877 && pThis->last_scr_height == (unsigned)pThis->svga.uHeight 878 && pThis->last_width == (unsigned)pThis->svga.uWidth 879 && pThis->last_height == (unsigned)pThis->svga.uHeight 822 880 ) 823 881 { … … 827 885 } 828 886 829 Log(("vmsvgaChangeMode: sEnable LFB mode and resize to (%d,%d) bpp=%d\n", pThis->svga. iWidth, pThis->svga.iHeight, pThis->svga.iBpp));830 pThis->svga.cbScanline = ((pThis->svga. iWidth * pThis->svga.iBpp + 7) & ~7) / 8;887 Log(("vmsvgaChangeMode: sEnable LFB mode and resize to (%d,%d) bpp=%d\n", pThis->svga.uWidth, pThis->svga.uHeight, pThis->svga.uBpp)); 888 pThis->svga.cbScanline = ((pThis->svga.uWidth * pThis->svga.uBpp + 7) & ~7) / 8; 831 889 832 890 pThis->pDrv->pfnLFBModeChange(pThis->pDrv, true); 833 rc = pThis->pDrv->pfnResize(pThis->pDrv, pThis->svga. iBpp, pThis->CTX_SUFF(vram_ptr), pThis->svga.cbScanline, pThis->svga.iWidth, pThis->svga.iHeight);891 rc = pThis->pDrv->pfnResize(pThis->pDrv, pThis->svga.uBpp, pThis->CTX_SUFF(vram_ptr), pThis->svga.cbScanline, pThis->svga.uWidth, pThis->svga.uHeight); 834 892 AssertRC(rc); 835 893 AssertReturn(rc == VINF_SUCCESS || rc == VINF_VGA_RESIZE_IN_PROGRESS, rc); 836 894 837 895 /* last stuff */ 838 pThis->last_bpp = pThis->svga. iBpp;839 pThis->last_scr_width = pThis->svga. iWidth;840 pThis->last_scr_height = pThis->svga. iHeight;841 pThis->last_width = pThis->svga. iWidth;842 pThis->last_height = pThis->svga. iHeight;896 pThis->last_bpp = pThis->svga.uBpp; 897 pThis->last_scr_width = pThis->svga.uWidth; 898 pThis->last_scr_height = pThis->svga.uHeight; 899 pThis->last_width = pThis->svga.uWidth; 900 pThis->last_height = pThis->svga.uHeight; 843 901 844 902 ASMAtomicOrU32(&pThis->svga.u32ActionFlags, VMSVGA_ACTION_CHANGEMODE); 845 903 904 /* vmsvgaPortSetViewPort not called after state load; set sensible defaults. */ 905 if ( pThis->svga.viewport.cx == 0 906 && pThis->svga.viewport.cy == 0) 907 { 908 pThis->svga.viewport.cx = pThis->svga.uWidth; 909 pThis->svga.viewport.cy = pThis->svga.uHeight; 910 } 846 911 return VINF_SUCCESS; 847 912 } … … 872 937 case SVGA_REG_ENABLE: 873 938 if ( pThis->svga.fEnabled == u32 874 && pThis->last_bpp == (unsigned)pThis->svga. iBpp875 && pThis->last_scr_width == (unsigned)pThis->svga. iWidth876 && pThis->last_scr_height == (unsigned)pThis->svga. iHeight877 && pThis->last_width == (unsigned)pThis->svga. iWidth878 && pThis->last_height == (unsigned)pThis->svga. iHeight939 && pThis->last_bpp == (unsigned)pThis->svga.uBpp 940 && pThis->last_scr_width == (unsigned)pThis->svga.uWidth 941 && pThis->last_scr_height == (unsigned)pThis->svga.uHeight 942 && pThis->last_width == (unsigned)pThis->svga.uWidth 943 && pThis->last_height == (unsigned)pThis->svga.uHeight 879 944 ) 880 945 /* Nothing to do. */ … … 892 957 if (pThis->svga.fEnabled) 893 958 { 894 if ( pThis->svga. iWidth == -1895 && pThis->svga. iHeight == -1896 && pThis->svga. iBpp == (unsigned)-1)959 if ( pThis->svga.uWidth == VMSVGA_VAL_UNINITIALIZED 960 && pThis->svga.uHeight == VMSVGA_VAL_UNINITIALIZED 961 && pThis->svga.uBpp == VMSVGA_VAL_UNINITIALIZED) 897 962 { 898 963 /* Keep the current mode. */ 899 pThis->svga. iWidth = pThis->pDrv->cx;900 pThis->svga. iHeight = pThis->pDrv->cy;901 pThis->svga. iBpp = (pThis->pDrv->cBits + 7) & ~7;964 pThis->svga.uWidth = pThis->pDrv->cx; 965 pThis->svga.uHeight = pThis->pDrv->cy; 966 pThis->svga.uBpp = (pThis->pDrv->cBits + 7) & ~7; 902 967 } 903 968 904 if ( pThis->svga. iWidth != -1905 && pThis->svga. iHeight != -1906 && pThis->svga. iBpp != (unsigned)-1)969 if ( pThis->svga.uWidth != VMSVGA_VAL_UNINITIALIZED 970 && pThis->svga.uHeight != VMSVGA_VAL_UNINITIALIZED 971 && pThis->svga.uBpp != VMSVGA_VAL_UNINITIALIZED) 907 972 { 908 973 rc = vmsvgaChangeMode(pThis); … … 921 986 memcpy(pThis->vram_ptrR3, pThis->svga.pFrameBufferBackup, VMSVGA_FRAMEBUFFER_BACKUP_SIZE); 922 987 923 /* pThis->svga. iHeight = -1;924 pThis->svga. iWidth = -1;925 pThis->svga. iBpp = -1;988 /* pThis->svga.uHeight = -1; 989 pThis->svga.uWidth = -1; 990 pThis->svga.uBpp = -1; 926 991 pThis->svga.cbScanline = 0; */ 927 992 pThis->pDrv->pfnLFBModeChange(pThis->pDrv, false); … … 936 1001 937 1002 case SVGA_REG_WIDTH: 938 if (pThis->svga. iWidth == (int)u32)1003 if (pThis->svga.uWidth == u32) 939 1004 break; /* nop */ 940 1005 941 pThis->svga. iWidth = (int)u32;1006 pThis->svga.uWidth = u32; 942 1007 if (pThis->svga.fEnabled) 943 1008 { … … 953 1018 954 1019 case SVGA_REG_HEIGHT: 955 if (pThis->svga. iHeight == (int)u32)1020 if (pThis->svga.uHeight == u32) 956 1021 break; /* nop */ 957 1022 958 pThis->svga. iHeight = (int)u32;1023 pThis->svga.uHeight = u32; 959 1024 if (pThis->svga.fEnabled) 960 1025 { … … 974 1039 975 1040 case SVGA_REG_BITS_PER_PIXEL: /* Current bpp in the guest */ 976 if (pThis->svga. iBpp == u32)1041 if (pThis->svga.uBpp == u32) 977 1042 break; /* nop */ 978 1043 979 pThis->svga. iBpp = u32;1044 pThis->svga.uBpp = u32; 980 1045 if (pThis->svga.fEnabled) 981 1046 { … … 1253 1318 1254 1319 case SVGA_IRQSTATUS_PORT: 1255 Log (("vmsvgaIORead: SVGA_IRQSTATUS_PORT %x\n", pThis->svga.u32IrqStatus));1320 LogFlow(("vmsvgaIORead: SVGA_IRQSTATUS_PORT %x\n", pThis->svga.u32IrqStatus)); 1256 1321 *pu32 = pThis->svga.u32IrqStatus; 1257 1322 break; … … 1803 1868 1804 1869 Assert(ppfBounceBuffer); 1870 /* Commands bigger than the fifo buffer are invalid. */ 1871 AssertReturn(cbCmd <= cbFIFOCmd, NULL); 1805 1872 1806 1873 *pSize += cbCmd; … … 1881 1948 Log(("vmsvgaFIFOLoop: min %x max %x\n", pFIFO[SVGA_FIFO_MIN], pFIFO[SVGA_FIFO_MAX])); 1882 1949 Log(("vmsvgaFIFOLoop: next %x stop %x\n", pFIFO[SVGA_FIFO_NEXT_CMD], pFIFO[SVGA_FIFO_STOP])); 1950 1951 if (pThis->svga.u8FIFOExtCommand != VMSVGA_FIFO_EXTCMD_NONE) 1952 { 1953 switch (pThis->svga.u8FIFOExtCommand) 1954 { 1955 case VMSVGA_FIFO_EXTCMD_RESET: 1956 Log(("vmsvgaFIFOLoop: reset the fifo thread.\n")); 1957 #ifdef VBOX_WITH_VMSVGA3D 1958 if (pThis->svga.f3DEnabled) 1959 { 1960 /* The 3d subsystem must be reset from the fifo thread. */ 1961 vmsvga3dReset(pThis); 1962 } 1963 #endif 1964 break; 1965 1966 case VMSVGA_FIFO_EXTCMD_TERMINATE: 1967 Log(("vmsvgaFIFOLoop: terminate the fifo thread.\n")); 1968 #ifdef VBOX_WITH_VMSVGA3D 1969 if (pThis->svga.f3DEnabled) 1970 { 1971 /* The 3d subsystem must be shut down from the fifo thread. */ 1972 vmsvga3dTerminate(pThis); 1973 } 1974 #endif 1975 break; 1976 1977 case VMSVGA_FIFO_EXTCMD_SAVESTATE: 1978 Log(("vmsvgaFIFOLoop: VMSVGA_FIFO_EXTCMD_SAVESTATE.\n")); 1979 #ifdef VBOX_WITH_VMSVGA3D 1980 vmsvga3dSaveExec(pThis, (PSSMHANDLE)pThis->svga.pFIFOExtCmdParam); 1981 #endif 1982 break; 1983 1984 case VMSVGA_FIFO_EXTCMD_LOADSTATE: 1985 { 1986 Log(("vmsvgaFIFOLoop: VMSVGA_FIFO_EXTCMD_LOADSTATE.\n")); 1987 #ifdef VBOX_WITH_VMSVGA3D 1988 PVMSVGA_STATE_LOAD pLoadState = (PVMSVGA_STATE_LOAD)pThis->svga.pFIFOExtCmdParam; 1989 vmsvga3dLoadExec(pThis, pLoadState->pSSM, pLoadState->uVersion, pLoadState->uPass); 1990 #endif 1991 break; 1992 } 1993 } 1994 1995 pThis->svga.u8FIFOExtCommand = VMSVGA_FIFO_EXTCMD_NONE; 1996 1997 /* Signal the end of the external command. */ 1998 RTSemEventSignal(pThis->svga.FIFOExtCmdSem); 1999 continue; 2000 } 1883 2001 1884 2002 if ( !pThis->svga.fEnabled … … 1927 2045 {} 1928 2046 #endif 2047 /* Check for pending external commands. */ 2048 if (pThis->svga.u8FIFOExtCommand != VMSVGA_FIFO_EXTCMD_NONE) 2049 break; 2050 1929 2051 u32Current = pFIFO[SVGA_FIFO_STOP]; 1930 2052 … … 1988 2110 Log(("vmsvgaFIFOLoop: ALPHA_CURSOR id=%d size (%d,%d) hotspot (%d,%d)\n", pCursor->id, pCursor->width, pCursor->height, pCursor->hotspotX, pCursor->hotspotY)); 1989 2111 2112 /* Check against a reasonable upper limit to prevent integer overflows in the sanity checks below. */ 2113 AssertReturn(pCursor->height < 2048 && pCursor->width < 2048, VERR_INVALID_PARAMETER); 2114 1990 2115 /* Refetch the command buffer with the added bitmap data; undo size increase (ugly) */ 1991 2116 cbCmd = sizeof(SVGAFifoCmdDefineAlphaCursor) + pCursor->width * pCursor->height * sizeof(uint32_t) /* 32-bit BRGA format */; … … 2019 2144 pCursorCopy); 2020 2145 AssertRC(rc); 2021 RTMemFree(pCursorCopy); 2022 2146 2147 if (pSVGAState->Cursor.fActive) 2148 RTMemFree(pSVGAState->Cursor.pData); 2149 2150 pSVGAState->Cursor.fActive = true; 2151 pSVGAState->Cursor.xHotspot = pCursor->hotspotX; 2152 pSVGAState->Cursor.yHotspot = pCursor->hotspotY; 2153 pSVGAState->Cursor.width = pCursor->width; 2154 pSVGAState->Cursor.height = pCursor->height; 2155 pSVGAState->Cursor.cbData = cbCursorShape; 2156 pSVGAState->Cursor.pData = pCursorCopy; 2023 2157 break; 2024 2158 } … … 2080 2214 2081 2215 if (!pCmd->numPages) 2216 { 2082 2217 vmsvgaGMRFree(pThis, pCmd->gmrId); 2083 /* else everything done in remap */ 2084 2218 } 2219 else 2220 { 2221 PGMR pGMR = &pSVGAState->aGMR[pCmd->gmrId]; 2222 pGMR->cMaxPages = pCmd->numPages; 2223 } 2224 /* everything done in remap */ 2085 2225 break; 2086 2226 } … … 2092 2232 uint32_t cbPageDesc = (pCmd->flags & SVGA_REMAP_GMR2_PPN64) ? sizeof(uint64_t) : sizeof(uint32_t); 2093 2233 uint32_t cbCmd; 2234 uint64_t *paNewPage64 = NULL; 2094 2235 2095 2236 Log(("vmsvgaFIFOLoop: SVGA_CMD_REMAP_GMR2 id=%x flags=%x offset=%x npages=%x\n", pCmd->gmrId, pCmd->flags, pCmd->offsetPages, pCmd->numPages)); 2096 2097 /* @todo */2098 AssertBreak(pCmd->offsetPages == 0);2099 2237 2100 2238 /* Refetch the command buffer with the variable data; undo size increase (ugly) */ … … 2121 2259 /* Validate current GMR id. */ 2122 2260 AssertBreak(pCmd->gmrId < VMSVGA_MAX_GMR_IDS); 2123 AssertBreak(pCmd->numPages <= VMSVGA_MAX_GMR_PAGES); 2261 AssertBreak(pCmd->offsetPages + pCmd->numPages <= pGMR->cMaxPages); 2262 AssertBreak(!pCmd->offsetPages || pGMR->paDesc); /* @todo */ 2263 2264 /* Save the old page descriptors as an array of page addresses (>> PAGE_SHIFT) */ 2265 if (pGMR->paDesc) 2266 { 2267 uint32_t idxPage = 0; 2268 paNewPage64 = (uint64_t *)RTMemAllocZ(pGMR->cMaxPages * sizeof(uint64_t)); 2269 AssertBreak(paNewPage64); 2270 2271 for (uint32_t i = 0; i < pGMR->numDescriptors; i++) 2272 { 2273 for (uint32_t j = 0; j < pGMR->paDesc[i].numPages; j++) 2274 { 2275 paNewPage64[idxPage++] = (pGMR->paDesc[i].GCPhys + j * PAGE_SIZE) >> PAGE_SHIFT; 2276 } 2277 } 2278 AssertBreak(idxPage == pGMR->cbTotal >> PAGE_SHIFT); 2279 } 2124 2280 2125 2281 /* Free the old GMR if present. */ 2126 vmsvgaGMRFree(pThis, pCmd->gmrId); 2127 2128 pGMR->paDesc = (PVMSVGAGMRDESCRIPTOR)RTMemAllocZ(pCmd->numPages * sizeof(VMSVGAGMRDESCRIPTOR)); 2282 if (pGMR->paDesc) 2283 RTMemFree(pGMR->paDesc); 2284 2285 /* Allocate the maximum amount possible (everything non-continuous) */ 2286 pGMR->paDesc = (PVMSVGAGMRDESCRIPTOR)RTMemAllocZ(pGMR->cMaxPages * sizeof(VMSVGAGMRDESCRIPTOR)); 2129 2287 AssertBreak(pGMR->paDesc); 2130 2288 … … 2136 2294 else 2137 2295 { 2138 uint32_t *pPage32 = (uint32_t *)(pCmd + 1); 2139 uint64_t *pPage64 = (uint64_t *)(pCmd + 1); 2140 uint32_t iDescriptor = 0; 2141 RTGCPHYS GCPhys; 2142 2143 if (pCmd->flags & SVGA_REMAP_GMR2_PPN64) 2296 uint32_t *pPage32 = (uint32_t *)(pCmd + 1); 2297 uint64_t *pPage64 = (uint64_t *)(pCmd + 1); 2298 uint32_t iDescriptor = 0; 2299 RTGCPHYS GCPhys; 2300 PVMSVGAGMRDESCRIPTOR paDescOld = NULL; 2301 bool fGCPhys64 = !!(pCmd->flags & SVGA_REMAP_GMR2_PPN64); 2302 2303 if (paNewPage64) 2304 { 2305 /* Overwrite the old page array with the new page values. */ 2306 for (uint32_t i = pCmd->offsetPages; i < pCmd->offsetPages + pCmd->numPages; i++) 2307 { 2308 if (pCmd->flags & SVGA_REMAP_GMR2_PPN64) 2309 paNewPage64[i] = pPage64[i - pCmd->offsetPages]; 2310 else 2311 paNewPage64[i] = pPage32[i - pCmd->offsetPages]; 2312 } 2313 /* Use the updated page array instead of the command data. */ 2314 fGCPhys64 = true; 2315 pPage64 = paNewPage64; 2316 pCmd->numPages = pGMR->cbTotal >> PAGE_SHIFT; 2317 } 2318 2319 if (fGCPhys64) 2144 2320 GCPhys = (pPage64[0] << PAGE_SHIFT) & 0x00000FFFFFFFFFFFULL; /* seeing rubbish in the top bits with certain linux guests*/ 2145 2321 else … … 2178 2354 } 2179 2355 2356 if (paNewPage64) 2357 RTMemFree(paNewPage64); 2358 2180 2359 #ifdef DEBUG_GMR_ACCESS 2181 2360 VMR3ReqCallWait(PDMDevHlpGetVM(pThis->pDevInsR3), VMCPUID_ANY, (PFNRT)vmsvgaRegisterGMR, 2, pThis->pDevInsR3, pCmd->gmrId); … … 2202 2381 Log(("vmsvgaFIFOLoop: SVGA_CMD_DEFINE_SCREEN flags SVGA_SCREEN_BLANKING\n")); 2203 2382 2204 pThis->svga. iWidth = pCmd->screen.size.width;2205 pThis->svga. iHeight = pCmd->screen.size.height;2383 pThis->svga.uWidth = pCmd->screen.size.width; 2384 pThis->svga.uHeight = pCmd->screen.size.height; 2206 2385 vmsvgaChangeMode(pThis); 2207 2386 break; … … 2230 2409 { 2231 2410 SVGAFifoCmdBlitGMRFBToScreen *pCmd = (SVGAFifoCmdBlitGMRFBToScreen *)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, sizeof(SVGAFifoCmdBlitGMRFBToScreen), &size, &pBounceBuffer); 2232 int32_t width, height;2411 uint32_t width, height; 2233 2412 2234 2413 Log(("vmsvgaFIFOLoop: SVGA_CMD_BLIT_GMRFB_TO_SCREEN src=(%d,%d) dest id=%d (%d,%d)(%d,%d)\n", pCmd->srcOrigin.x, pCmd->srcOrigin.y, pCmd->destScreenId, pCmd->destRect.left, pCmd->destRect.top, pCmd->destRect.right, pCmd->destRect.bottom)); 2235 2414 2236 2415 /* @todo */ 2237 AssertBreak(pSVGAState->GMRFB.format.s.bitsPerPixel == pThis->svga. iBpp);2416 AssertBreak(pSVGAState->GMRFB.format.s.bitsPerPixel == pThis->svga.uBpp); 2238 2417 AssertBreak(pCmd->destScreenId == 0); 2239 2418 … … 2255 2434 2256 2435 /* Clip to screen dimensions. */ 2257 if (width > pThis->svga. iWidth)2258 width = pThis->svga. iWidth;2259 if (height > pThis->svga. iHeight)2260 height = pThis->svga. iHeight;2436 if (width > pThis->svga.uWidth) 2437 width = pThis->svga.uWidth; 2438 if (height > pThis->svga.uHeight) 2439 height = pThis->svga.uHeight; 2261 2440 2262 2441 unsigned offsetSource = (pCmd->srcOrigin.x * pSVGAState->GMRFB.format.s.bitsPerPixel) / 8 + pSVGAState->GMRFB.bytesPerLine * pCmd->srcOrigin.y; 2263 unsigned offsetDest = (pCmd->destRect.left * RT_ALIGN(pThis->svga.iBpp, 8)) / 8 + pThis->svga.cbScanline * pCmd->destRect.top; 2264 unsigned cbCopyWidth = (width * RT_ALIGN(pThis->svga.iBpp, 8)) / 8; 2442 unsigned offsetDest = (pCmd->destRect.left * RT_ALIGN(pThis->svga.uBpp, 8)) / 8 + pThis->svga.cbScanline * pCmd->destRect.top; 2443 unsigned cbCopyWidth = (width * RT_ALIGN(pThis->svga.uBpp, 8)) / 8; 2444 2445 AssertReturn(offsetDest < pThis->vram_size, VERR_INVALID_PARAMETER); 2265 2446 2266 2447 rc = vmsvgaGMRTransfer(pThis, SVGA3D_WRITE_HOST_VRAM, pThis->CTX_SUFF(vram_ptr) + offsetDest, pThis->svga.cbScanline, pSVGAState->GMRFB.ptr, offsetSource, pSVGAState->GMRFB.bytesPerLine, cbCopyWidth, height); 2267 2448 AssertRC(rc); 2268 2269 2449 vgaR3UpdateDisplay(pThis, pCmd->destRect.left, pCmd->destRect.top, pCmd->destRect.right - pCmd->destRect.left, pCmd->destRect.bottom - pCmd->destRect.top); 2270 2450 break; … … 2663 2843 if (pSVGAState->aGMR[idGMR].numDescriptors) 2664 2844 { 2845 PGMR pGMR = &pSVGAState->aGMR[idGMR]; 2665 2846 #ifdef DEBUG_GMR_ACCESS 2666 2847 VMR3ReqCallWait(PDMDevHlpGetVM(pThis->pDevInsR3), VMCPUID_ANY, (PFNRT)vmsvgaUnregisterGMR, 2, pThis->pDevInsR3, idGMR); 2667 2848 #endif 2668 2849 2669 Assert(pSVGAState->aGMR[idGMR].paDesc); 2670 RTMemFree(pSVGAState->aGMR[idGMR].paDesc); 2671 pSVGAState->aGMR[idGMR].paDesc = NULL; 2672 pSVGAState->aGMR[idGMR].numDescriptors = 0; 2673 pSVGAState->aGMR[idGMR].cbTotal = 0; 2850 Assert(pGMR->paDesc); 2851 RTMemFree(pGMR->paDesc); 2852 pGMR->paDesc = NULL; 2853 pGMR->numDescriptors = 0; 2854 pGMR->cbTotal = 0; 2855 pGMR->cMaxPages = 0; 2674 2856 } 2675 2857 Assert(!pSVGAState->aGMR[idGMR].cbTotal); … … 2690 2872 * @param cHeight Source height 2691 2873 */ 2692 int vmsvgaGMRTransfer(PVGASTATE pThis, const SVGA3dTransferType transfer, uint8_t *pDest, uint32_t cbDestPitch, SVGAGuestPtr src, uint32_t cbSrcOffset, uint32_t cbSrcPitch, uint32_t cbWidth, uint32_t cHeight)2874 int vmsvgaGMRTransfer(PVGASTATE pThis, const SVGA3dTransferType transfer, uint8_t *pDest, int32_t cbDestPitch, SVGAGuestPtr src, uint32_t cbSrcOffset, int32_t cbSrcPitch, uint32_t cbWidth, uint32_t cHeight) 2693 2875 { 2694 2876 PVMSVGASTATE pSVGAState = (PVMSVGASTATE)pThis->svga.pSVGAState; … … 2705 2887 { 2706 2888 cbSrcOffset += src.offset; 2889 AssertReturn(src.offset < pThis->vram_size, VERR_INVALID_PARAMETER); 2707 2890 AssertReturn(cbSrcOffset + cbSrcPitch * (cHeight - 1) + cbWidth <= pThis->vram_size, VERR_INVALID_PARAMETER); 2708 2891 … … 2712 2895 { 2713 2896 /* switch src & dest */ 2714 uint8_t *pTemp 2715 uint32_t cbTempPitch = cbDestPitch;2897 uint8_t *pTemp = pDest; 2898 int32_t cbTempPitch = cbDestPitch; 2716 2899 2717 2900 pDest = pSrc; … … 2723 2906 2724 2907 if ( pThis->svga.cbScanline == cbDestPitch 2725 && cbWidth == cbDestPitch) 2908 && cbWidth == cbDestPitch 2909 && cbSrcPitch == cbDestPitch) 2726 2910 { 2727 2911 memcpy(pDest, pSrc, cbWidth * cHeight); … … 2745 2929 2746 2930 cbSrcOffset += src.offset; 2931 AssertReturn(src.offset < pGMR->cbTotal, VERR_INVALID_PARAMETER); 2747 2932 AssertReturn(cbSrcOffset + cbSrcPitch * (cHeight - 1) + cbWidth <= pGMR->cbTotal, VERR_INVALID_PARAMETER); 2748 2933 2749 2934 for (unsigned i = 0; i < cHeight; i++) 2750 2935 { … … 2766 2951 2767 2952 if (uCurrentOffset + cbCurrentWidth <= uDescOffset + pDesc->numPages * PAGE_SIZE) 2953 { 2768 2954 cbToCopy = cbCurrentWidth; 2955 } 2769 2956 else 2957 { 2770 2958 cbToCopy = (uDescOffset + pDesc->numPages * PAGE_SIZE - uCurrentOffset); 2959 AssertReturn(cbToCopy <= cbCurrentWidth, VERR_INVALID_PARAMETER); 2960 } 2771 2961 2772 2962 LogFlow(("vmsvgaGMRTransfer: %s phys=%RGp\n", (transfer == SVGA3D_WRITE_HOST_VRAM) ? "READ" : "WRITE", pDesc->GCPhys + uCurrentOffset - uDescOffset)); … … 2833 3023 2834 3024 Log(("vmsvgaSetTraces: enable dirty page handling for the frame buffer only (%x bytes)\n", 0)); 2835 if (pThis->svga. iHeight != -1)3025 if (pThis->svga.uHeight != VMSVGA_VAL_UNINITIALIZED) 2836 3026 { 2837 3027 Assert(pThis->svga.cbScanline); 2838 3028 /* Hardware enabled; return real framebuffer size .*/ 2839 cbFrameBuffer = (uint32_t)pThis->svga. iHeight * pThis->svga.cbScanline;3029 cbFrameBuffer = (uint32_t)pThis->svga.uHeight * pThis->svga.cbScanline; 2840 3030 cbFrameBuffer = RT_ALIGN(cbFrameBuffer, PAGE_SIZE); 2841 3031 } … … 2879 3069 PVGASTATE pThis = PDMINS_2_DATA(pDevIns, PVGASTATE); 2880 3070 3071 Log(("vgasvgaR3IORegionMap: iRegion=%d GCPhysAddress=%RGp cb=%#x enmType=%d\n", iRegion, GCPhysAddress, cb, enmType)); 2881 3072 if (enmType == PCI_ADDRESS_SPACE_IO) 2882 3073 { … … 2944 3135 2945 3136 /* Load our part of the VGAState */ 2946 rc = SSMR3GetStruct (pSSM, &pThis->svga, g_aVGAStateSVGAFields);2947 AssertR eturn(rc, rc);3137 rc = SSMR3GetStructEx(pSSM, &pThis->svga, sizeof(pThis->svga), 0, g_aVGAStateSVGAFields, NULL); 3138 AssertRCReturn(rc, rc); 2948 3139 2949 3140 /* Load the framebuffer backup. */ 2950 3141 rc = SSMR3GetMem(pSSM, pThis->svga.pFrameBufferBackup, VMSVGA_FRAMEBUFFER_BACKUP_SIZE); 2951 AssertR eturn(rc, rc);3142 AssertRCReturn(rc, rc); 2952 3143 2953 3144 /* Load the VMSVGA state. */ 2954 rc = SSMR3GetStruct(pSSM, pSVGAState, g_aVMSVGASTATEFields); 2955 AssertReturn(rc, rc); 2956 2957 /* Save the GMR state */ 3145 rc = SSMR3GetStructEx(pSSM, pSVGAState, sizeof(*pSVGAState), 0, g_aVMSVGASTATEFields, NULL); 3146 AssertRCReturn(rc, rc); 3147 3148 /* Load the active cursor bitmaps. */ 3149 if (pSVGAState->Cursor.fActive) 3150 { 3151 pSVGAState->Cursor.pData = RTMemAlloc(pSVGAState->Cursor.cbData); 3152 AssertReturn(pSVGAState->Cursor.pData, VERR_NO_MEMORY); 3153 3154 rc = SSMR3GetMem(pSSM, pSVGAState->Cursor.pData, pSVGAState->Cursor.cbData); 3155 AssertRCReturn(rc, rc); 3156 } 3157 3158 /* Load the GMR state */ 2958 3159 for (uint32_t i = 0; i < RT_ELEMENTS(pSVGAState->aGMR); i++) 2959 3160 { 2960 rc = SSMR3GetStruct(pSSM, &pSVGAState->aGMR[i], g_aGMRFields); 2961 AssertReturn(rc, rc); 2962 2963 for (uint32_t j = 0; j < pSVGAState->aGMR[i].numDescriptors; j++) 2964 { 2965 rc = SSMR3GetStruct(pSSM, &pSVGAState->aGMR[i].paDesc[j], g_aVMSVGAGMRDESCRIPTORFields); 2966 AssertReturn(rc, rc); 3161 PGMR pGMR = &pSVGAState->aGMR[i]; 3162 3163 rc = SSMR3GetStructEx(pSSM, pGMR, sizeof(*pGMR), 0, g_aGMRFields, NULL); 3164 AssertRCReturn(rc, rc); 3165 3166 if (pGMR->numDescriptors) 3167 { 3168 /* Allocate the maximum amount possible (everything non-continuous) */ 3169 Assert(pGMR->cMaxPages || pGMR->cbTotal); 3170 pGMR->paDesc = (PVMSVGAGMRDESCRIPTOR)RTMemAllocZ((pGMR->cMaxPages) ? pGMR->cMaxPages : (pGMR->cbTotal >> PAGE_SHIFT) * sizeof(VMSVGAGMRDESCRIPTOR)); 3171 AssertReturn(pGMR->paDesc, VERR_NO_MEMORY); 3172 3173 for (uint32_t j = 0; j < pGMR->numDescriptors; j++) 3174 { 3175 rc = SSMR3GetStructEx(pSSM, &pGMR->paDesc[j], sizeof(pGMR->paDesc[j]), 0, g_aVMSVGAGMRDESCRIPTORFields, NULL); 3176 AssertRCReturn(rc, rc); 3177 } 2967 3178 } 2968 3179 } 2969 3180 2970 3181 #ifdef VBOX_WITH_VMSVGA3D 2971 if ( uVersion >= VGA_SAVEDSTATE_VERSION_VMSVGA 2972 && pThis->svga.f3DEnabled) 2973 vmsvga3dLoadExec(pThis, pSSM, uVersion, uPass); 3182 if (pThis->svga.f3DEnabled) 3183 { 3184 VMSVGA_STATE_LOAD loadstate; 3185 3186 loadstate.pSSM = pSSM; 3187 loadstate.uVersion = uVersion; 3188 loadstate.uPass = uPass; 3189 3190 /* Save the 3d state in the FIFO thread. */ 3191 pThis->svga.u8FIFOExtCommand = VMSVGA_FIFO_EXTCMD_LOADSTATE; 3192 pThis->svga.pFIFOExtCmdParam = (void *)&loadstate; 3193 /* Hack alert: resume the IO thread as it has been suspended before the destruct callback. 3194 * The PowerOff notification isn't working, so not an option in this case. 3195 */ 3196 PDMR3ThreadResume(pThis->svga.pFIFOIOThread); 3197 RTSemEventSignal(pThis->svga.FIFORequestSem); 3198 /* Wait for the end of the command. */ 3199 rc = RTSemEventWait(pThis->svga.FIFOExtCmdSem, RT_INDEFINITE_WAIT); 3200 AssertRC(rc); 3201 PDMR3ThreadSuspend(pThis->svga.pFIFOIOThread); 3202 } 2974 3203 #endif 2975 3204 … … 2977 3206 } 2978 3207 3208 /** 3209 * Reinit the video mode after the state has been loaded. 3210 */ 3211 int vmsvgaLoadDone(PPDMDEVINS pDevIns) 3212 { 3213 PVGASTATE pThis = PDMINS_2_DATA(pDevIns, PVGASTATE); 3214 PVMSVGASTATE pSVGAState = (PVMSVGASTATE)pThis->svga.pSVGAState; 3215 3216 pThis->last_bpp = VMSVGA_VAL_UNINITIALIZED; /* force mode reset */ 3217 vmsvgaChangeMode(pThis); 3218 3219 /* Set the active cursor. */ 3220 if (pSVGAState->Cursor.fActive) 3221 { 3222 int rc; 3223 3224 rc = pThis->pDrv->pfnVBVAMousePointerShape (pThis->pDrv, 3225 true, 3226 true, 3227 pSVGAState->Cursor.xHotspot, 3228 pSVGAState->Cursor.yHotspot, 3229 pSVGAState->Cursor.width, 3230 pSVGAState->Cursor.height, 3231 pSVGAState->Cursor.pData); 3232 AssertRC(rc); 3233 } 3234 return VINF_SUCCESS; 3235 } 2979 3236 2980 3237 /** … … 2988 3245 2989 3246 /* Save our part of the VGAState */ 2990 rc = SSMR3PutStruct (pSSM, &pThis->svga, g_aVGAStateSVGAFields);2991 AssertR eturn(rc, rc);3247 rc = SSMR3PutStructEx(pSSM, &pThis->svga, sizeof(pThis->svga), 0, g_aVGAStateSVGAFields, NULL); 3248 AssertRCReturn(rc, rc); 2992 3249 2993 3250 /* Save the framebuffer backup. */ 2994 3251 rc = SSMR3PutMem(pSSM, pThis->svga.pFrameBufferBackup, VMSVGA_FRAMEBUFFER_BACKUP_SIZE); 2995 AssertR eturn(rc, rc);3252 AssertRCReturn(rc, rc); 2996 3253 2997 3254 /* Save the VMSVGA state. */ 2998 rc = SSMR3PutStruct(pSSM, pSVGAState, g_aVMSVGASTATEFields); 2999 AssertReturn(rc, rc); 3255 rc = SSMR3PutStructEx(pSSM, pSVGAState, sizeof(*pSVGAState), 0, g_aVMSVGASTATEFields, NULL); 3256 AssertRCReturn(rc, rc); 3257 3258 /* Save the active cursor bitmaps. */ 3259 if (pSVGAState->Cursor.fActive) 3260 { 3261 rc = SSMR3PutMem(pSSM, pSVGAState->Cursor.pData, pSVGAState->Cursor.cbData); 3262 AssertRCReturn(rc, rc); 3263 } 3000 3264 3001 3265 /* Save the GMR state */ 3002 3266 for (uint32_t i = 0; i < RT_ELEMENTS(pSVGAState->aGMR); i++) 3003 3267 { 3004 rc = SSMR3PutStruct (pSSM, &pSVGAState->aGMR[i], g_aGMRFields);3005 AssertR eturn(rc, rc);3268 rc = SSMR3PutStructEx(pSSM, &pSVGAState->aGMR[i], sizeof(pSVGAState->aGMR[i]), 0, g_aGMRFields, NULL); 3269 AssertRCReturn(rc, rc); 3006 3270 3007 3271 for (uint32_t j = 0; j < pSVGAState->aGMR[i].numDescriptors; j++) 3008 3272 { 3009 rc = SSMR3PutStruct (pSSM, &pSVGAState->aGMR[i].paDesc[j], g_aVMSVGAGMRDESCRIPTORFields);3010 AssertR eturn(rc, rc);3273 rc = SSMR3PutStructEx(pSSM, &pSVGAState->aGMR[i].paDesc[j], sizeof(pSVGAState->aGMR[i].paDesc[j]), 0, g_aVMSVGAGMRDESCRIPTORFields, NULL); 3274 AssertRCReturn(rc, rc); 3011 3275 } 3012 3276 } … … 3014 3278 #ifdef VBOX_WITH_VMSVGA3D 3015 3279 if (pThis->svga.f3DEnabled) 3016 vmsvga3dSaveExec(pThis, pSSM); 3280 { 3281 /* Save the 3d state in the FIFO thread. */ 3282 pThis->svga.u8FIFOExtCommand = VMSVGA_FIFO_EXTCMD_SAVESTATE; 3283 pThis->svga.pFIFOExtCmdParam = (void *)pSSM; 3284 /* Hack alert: resume the IO thread as it has been suspended before the destruct callback. 3285 * The PowerOff notification isn't working, so not an option in this case. 3286 */ 3287 PDMR3ThreadResume(pThis->svga.pFIFOIOThread); 3288 RTSemEventSignal(pThis->svga.FIFORequestSem); 3289 /* Wait for the end of the external command. */ 3290 rc = RTSemEventWait(pThis->svga.FIFOExtCmdSem, RT_INDEFINITE_WAIT); 3291 AssertRC(rc); 3292 PDMR3ThreadSuspend(pThis->svga.pFIFOIOThread); 3293 } 3017 3294 #endif 3018 3295 return VINF_SUCCESS; 3296 } 3297 3298 /** 3299 * Resets the SVGA hardware state 3300 * 3301 * @returns VBox status code. 3302 * @param pDevIns The device instance. 3303 */ 3304 int vmsvgaReset(PPDMDEVINS pDevIns) 3305 { 3306 PVGASTATE pThis = PDMINS_2_DATA(pDevIns, PVGASTATE); 3307 PVMSVGASTATE pSVGAState = (PVMSVGASTATE)pThis->svga.pSVGAState; 3308 3309 /* Reset before init? */ 3310 if (!pSVGAState) 3311 return VINF_SUCCESS; 3312 3313 Log(("vmsvgaReset\n")); 3314 3315 pThis->svga.pFIFOR3[SVGA_FIFO_NEXT_CMD] = pThis->svga.pFIFOR3[SVGA_FIFO_STOP] = 0; 3316 3317 /* Reset the FIFO thread. */ 3318 pThis->svga.u8FIFOExtCommand = VMSVGA_FIFO_EXTCMD_RESET; 3319 RTSemEventSignal(pThis->svga.FIFORequestSem); 3320 /* Wait for the end of the termination sequence. */ 3321 int rc = RTSemEventWait(pThis->svga.FIFOExtCmdSem, 10000); 3322 AssertRC(rc); 3323 3324 pThis->svga.cScratchRegion = VMSVGA_SCRATCH_SIZE; 3325 memset(pThis->svga.au32ScratchRegion, 0, sizeof(pThis->svga.au32ScratchRegion)); 3326 memset(pThis->svga.pSVGAState, 0, sizeof(VMSVGASTATE)); 3327 memset(pThis->svga.pFrameBufferBackup, 0, VMSVGA_FRAMEBUFFER_BACKUP_SIZE); 3328 3329 /* Register caps. */ 3330 pThis->svga.u32RegCaps = SVGA_CAP_GMR | SVGA_CAP_GMR2 | SVGA_CAP_CURSOR | SVGA_CAP_CURSOR_BYPASS_2 | SVGA_CAP_EXTENDED_FIFO | SVGA_CAP_IRQMASK | SVGA_CAP_PITCHLOCK | SVGA_CAP_TRACES | SVGA_CAP_SCREEN_OBJECT_2 | SVGA_CAP_ALPHA_CURSOR; 3331 #ifdef VBOX_WITH_VMSVGA3D 3332 pThis->svga.u32RegCaps |= SVGA_CAP_3D; 3333 #endif 3334 3335 /* Setup FIFO capabilities. */ 3336 pThis->svga.pFIFOR3[SVGA_FIFO_CAPABILITIES] = SVGA_FIFO_CAP_FENCE | SVGA_FIFO_CAP_CURSOR_BYPASS_3 | SVGA_FIFO_CAP_GMR2 | SVGA_FIFO_CAP_3D_HWVERSION_REVISED | SVGA_FIFO_CAP_SCREEN_OBJECT_2; 3337 3338 /* Valid with SVGA_FIFO_CAP_SCREEN_OBJECT_2 */ 3339 pThis->svga.pFIFOR3[SVGA_FIFO_CURSOR_SCREEN_ID] = SVGA_ID_INVALID; 3340 3341 /* VRAM tracking is enabled by default during bootup. */ 3342 pThis->svga.fVRAMTracking = true; 3343 pThis->svga.fEnabled = false; 3344 3345 /* Invalidate current settings. */ 3346 pThis->svga.uWidth = VMSVGA_VAL_UNINITIALIZED; 3347 pThis->svga.uHeight = VMSVGA_VAL_UNINITIALIZED; 3348 pThis->svga.uBpp = VMSVGA_VAL_UNINITIALIZED; 3349 pThis->svga.cbScanline = 0; 3350 3351 return rc; 3019 3352 } 3020 3353 … … 3029 3362 PVGASTATE pThis = PDMINS_2_DATA(pDevIns, PVGASTATE); 3030 3363 PVMSVGASTATE pSVGAState = (PVMSVGASTATE)pThis->svga.pSVGAState; 3364 int rc; 3365 3366 /* Stop the FIFO thread. */ 3367 pThis->svga.u8FIFOExtCommand = VMSVGA_FIFO_EXTCMD_TERMINATE; 3368 /* Hack alert: resume the IO thread as it has been suspended before the destruct callback. 3369 * The PowerOff notification isn't working, so not an option in this case. 3370 */ 3371 PDMR3ThreadResume(pThis->svga.pFIFOIOThread); 3372 RTSemEventSignal(pThis->svga.FIFORequestSem); 3373 /* Wait for the end of the termination sequence. */ 3374 rc = RTSemEventWait(pThis->svga.FIFOExtCmdSem, 10000); 3375 AssertRC(rc); 3376 PDMR3ThreadSuspend(pThis->svga.pFIFOIOThread); 3031 3377 3032 3378 if (pSVGAState) 3033 3379 { 3380 if (pSVGAState->Cursor.fActive) 3381 RTMemFree(pSVGAState->Cursor.pData); 3382 3034 3383 for (unsigned i = 0; i < RT_ELEMENTS(pSVGAState->aGMR); i++) 3035 3384 { … … 3039 3388 RTMemFree(pSVGAState); 3040 3389 } 3041 3042 #ifdef VBOX_WITH_VMSVGA3D 3043 /** @todo */ 3044 if (pThis->svga.f3DEnabled) 3045 vmsvga3dTerminate(pThis); 3046 #endif 3390 if (pThis->svga.pFrameBufferBackup) 3391 RTMemFree(pThis->svga.pFrameBufferBackup); 3392 if (pThis->svga.FIFOExtCmdSem) 3393 RTSemEventDestroy(pThis->svga.FIFOExtCmdSem); 3394 if (pThis->svga.FIFORequestSem) 3395 RTSemEventDestroy(pThis->svga.FIFORequestSem); 3396 3047 3397 return VINF_SUCCESS; 3048 3398 } … … 3080 3430 } 3081 3431 3432 /* Create event semaphore. */ 3433 rc = RTSemEventCreate(&pThis->svga.FIFOExtCmdSem); 3434 if (RT_FAILURE(rc)) 3435 { 3436 Log(("%s: Failed to create event semaphore for external fifo cmd handling.\n", __FUNCTION__)); 3437 return rc; 3438 } 3439 3082 3440 /* Register caps. */ 3083 pThis->svga.u32RegCaps = SVGA_CAP_GMR | SVGA_CAP_GMR2 | SVGA_CAP_CURSOR | SVGA_CAP_CURSOR_BYPASS_2 | SVGA_CAP_EXTENDED_FIFO | SVGA_CAP_IRQMASK | SVGA_CAP_PITCHLOCK | SVGA_CAP_TRACES | SVGA_CAP_SCREEN_OBJECT_2 ;3441 pThis->svga.u32RegCaps = SVGA_CAP_GMR | SVGA_CAP_GMR2 | SVGA_CAP_CURSOR | SVGA_CAP_CURSOR_BYPASS_2 | SVGA_CAP_EXTENDED_FIFO | SVGA_CAP_IRQMASK | SVGA_CAP_PITCHLOCK | SVGA_CAP_TRACES | SVGA_CAP_SCREEN_OBJECT_2 | SVGA_CAP_ALPHA_CURSOR; 3084 3442 #ifdef VBOX_WITH_VMSVGA3D 3085 3443 pThis->svga.u32RegCaps |= SVGA_CAP_3D; … … 3105 3463 3106 3464 /* Invalidate current settings. */ 3107 pThis->svga. iWidth = -1;3108 pThis->svga. iHeight = -1;3109 pThis->svga. iBpp = -1;3465 pThis->svga.uWidth = VMSVGA_VAL_UNINITIALIZED; 3466 pThis->svga.uHeight = VMSVGA_VAL_UNINITIALIZED; 3467 pThis->svga.uBpp = VMSVGA_VAL_UNINITIALIZED; 3110 3468 pThis->svga.cbScanline = 0; 3111 3469 … … 3151 3509 PVGASTATE pThis = PDMINS_2_DATA(pDevIns, PVGASTATE); 3152 3510 int rc; 3511 3153 3512 #ifdef VBOX_WITH_VMSVGA3D 3154 3513 if (pThis->svga.f3DEnabled) -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.h
r49985 r53201 13 13 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 14 14 */ 15 16 15 #ifndef __DEVVGA_SVGA_H__ 17 16 #define __DEVVGA_SVGA_H__ … … 25 24 #define VMSVGA_SURFACE_SIZE (512*1024*1024) 26 25 /** Maximum GMR pages. */ 27 #define VMSVGA_MAX_GMR_PAGES 0x 200026 #define VMSVGA_MAX_GMR_PAGES 0x100000 28 27 /** Maximum nr of GMR ids. */ 29 28 #define VMSVGA_MAX_GMR_IDS 0x100 30 29 /** Size of the region to backup when switching into svga mode. */ 31 30 #define VMSVGA_FRAMEBUFFER_BACKUP_SIZE (32*1024) 31 32 #define VMSVGA_VAL_UNINITIALIZED (unsigned)-1 32 33 33 34 /* u32ActionFlags */ … … 37 38 DECLCALLBACK(int) vmsvgaR3IORegionMap(PPCIDEVICE pPciDev, int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType); 38 39 40 DECLCALLBACK(void) vmsvgaPortSetViewPort(PPDMIDISPLAYPORT pInterface, uint32_t uScreenId, uint32_t x, uint32_t y, uint32_t cx, uint32_t cy); 41 39 42 int vmsvgaInit(PPDMDEVINS pDevIns); 43 int vmsvgaReset(PPDMDEVINS pDevIns); 40 44 int vmsvgaDestruct(PPDMDEVINS pDevIns); 41 45 int vmsvgaLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass); 46 int vmsvgaLoadDone(PPDMDEVINS pDevIns); 42 47 int vmsvgaSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM); 43 48 DECLCALLBACK(void) vmsvgaR3PowerOn(PPDMDEVINS pDevIns); 49 DECLCALLBACK(void) vmsvgaR3PowerOff(PPDMDEVINS pDevIns); 44 50 45 51 #endif /* __DEVVGA_SVGA_H__ */ 46 -
trunk/src/VBox/Devices/Graphics/DevVGA.cpp
r52885 r53201 2101 2101 /* @todo might crash if a blit follows a resolution change very quickly (seen this many times!) */ 2102 2102 2103 if ( s->svga. iWidth == -12104 || s->svga. iHeight == -12105 || s->svga. iBpp == UINT32_MAX)2103 if ( s->svga.uWidth == VMSVGA_VAL_UNINITIALIZED 2104 || s->svga.uHeight == VMSVGA_VAL_UNINITIALIZED 2105 || s->svga.uBpp == VMSVGA_VAL_UNINITIALIZED) 2106 2106 { 2107 2107 /* Intermediate state; skip redraws. */ … … 2110 2110 } 2111 2111 2112 switch(s->svga. iBpp) {2112 switch(s->svga.uBpp) { 2113 2113 default: 2114 2114 case 0: … … 2166 2166 vga_draw_line_func *vga_draw_line; 2167 2167 2168 if ( pThis->svga. iWidth == -12169 || pThis->svga. iHeight == -12170 || pThis->svga. iBpp == UINT32_MAX)2168 if ( pThis->svga.uWidth == VMSVGA_VAL_UNINITIALIZED 2169 || pThis->svga.uHeight == VMSVGA_VAL_UNINITIALIZED 2170 || pThis->svga.uBpp == VMSVGA_VAL_UNINITIALIZED) 2171 2171 { 2172 2172 /* Intermediate state; skip redraws. */ … … 2174 2174 } 2175 2175 2176 width = pThis->svga. iWidth;2177 height = pThis->svga. iHeight;2176 width = pThis->svga.uWidth; 2177 height = pThis->svga.uHeight; 2178 2178 2179 2179 disp_width = width; 2180 2180 2181 switch(pThis->svga. iBpp) {2181 switch(pThis->svga.uBpp) { 2182 2182 default: 2183 2183 case 0: … … 5329 5329 PPDMDEVINS pDevIns = pPciDev->pDevIns; 5330 5330 PVGASTATE pThis = PDMINS_2_DATA(pDevIns, PVGASTATE); 5331 Log Flow(("vgaR3IORegionMap: iRegion=%d GCPhysAddress=%RGp cb=%#x enmType=%d\n", iRegion, GCPhysAddress, cb, enmType));5331 Log(("vgaR3IORegionMap: iRegion=%d GCPhysAddress=%RGp cb=%#x enmType=%d\n", iRegion, GCPhysAddress, cb, enmType)); 5332 5332 #ifdef VBOX_WITH_VMSVGA 5333 5333 AssertReturn((iRegion == ((pThis->fVMSVGAEnabled) ? 1 : 0)) && (enmType == ((pThis->fVMSVGAEnabled) ? PCI_ADDRESS_SPACE_MEM : PCI_ADDRESS_SPACE_MEM_PREFETCH)), VERR_INTERNAL_ERROR); … … 5371 5371 Assert(pThis->GCPhysVRAM); 5372 5372 #ifdef VBOX_WITH_VMSVGA 5373 Assert(!pThis->svga.fEnabled); 5373 Assert(!pThis->svga.fEnabled || !pThis->svga.fVRAMTracking); 5374 if ( !pThis->svga.fEnabled 5375 || ( pThis->svga.fEnabled 5376 && pThis->svga.fVRAMTracking 5377 ) 5378 ) 5379 { 5374 5380 #endif 5375 5381 rc = PGMHandlerPhysicalDeregister(PDMDevHlpGetVM(pDevIns), pThis->GCPhysVRAM); 5376 5382 AssertRC(rc); 5383 #ifdef VBOX_WITH_VMSVGA 5384 } 5385 else 5386 rc = VINF_SUCCESS; 5387 #endif 5377 5388 pThis->GCPhysVRAM = 0; 5378 5389 /* NB: VBE_DISPI_INDEX_FB_BASE_HI is left unchanged here. */ … … 5547 5558 5548 5559 #ifdef VBOX_WITH_VMSVGA 5549 if ( uVersion >= VGA_SAVEDSTATE_VERSION_VMSVGA_2D 5550 && pThis->fVMSVGAEnabled) 5560 if (pThis->fVMSVGAEnabled) 5551 5561 { 5552 5562 rc = vmsvgaLoadExec(pDevIns, pSSM, uVersion, uPass); … … 5564 5574 static DECLCALLBACK(int) vgaR3LoadDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 5565 5575 { 5576 int rc = VINF_SUCCESS; 5577 5566 5578 #ifdef VBOX_WITH_HGSMI 5567 5579 PVGASTATE pThis = PDMINS_2_DATA(pDevIns, PVGASTATE); 5568 5580 VBVAPause(pThis, (pThis->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED) == 0); 5569 intrc = vboxVBVALoadStateDone(pDevIns, pSSM);5581 rc = vboxVBVALoadStateDone(pDevIns, pSSM); 5570 5582 AssertRCReturn(rc, rc); 5571 5583 # ifdef VBOX_WITH_VDMA … … 5573 5585 AssertRCReturn(rc, rc); 5574 5586 # endif 5575 return VINF_SUCCESS; 5576 #else 5577 return VINF_SUCCESS; 5578 #endif 5587 #endif 5588 #ifdef VBOX_WITH_VMSVGA 5589 rc = vmsvgaLoadDone(pDevIns); 5590 #endif 5591 return rc; 5579 5592 } 5580 5593 … … 5594 5607 if (pThis->pVdma) 5595 5608 vboxVDMAReset(pThis->pVdma); 5609 5610 #ifdef VBOX_WITH_VMSVGA 5611 if (pThis->fVMSVGAEnabled) 5612 vmsvgaReset(pDevIns); 5613 #endif 5596 5614 5597 5615 #ifdef VBOX_WITH_HGSMI … … 6035 6053 pThis->IPort.pfnCopyRect = vgaPortCopyRect; 6036 6054 pThis->IPort.pfnSetRenderVRAM = vgaPortSetRenderVRAM; 6055 #ifdef VBOX_WITH_VMSVGA 6056 pThis->IPort.pfnSetViewPort = vmsvgaPortSetViewPort; 6057 #endif 6037 6058 6038 6059 #if defined(VBOX_WITH_HGSMI) -
trunk/src/VBox/Devices/Graphics/DevVGA.h
r52504 r53201 212 212 #endif 213 213 214 #ifdef VBOX_WITH_VMSVGA 215 216 #define VMSVGA_FIFO_EXTCMD_NONE 0 217 #define VMSVGA_FIFO_EXTCMD_TERMINATE 1 218 #define VMSVGA_FIFO_EXTCMD_SAVESTATE 2 219 #define VMSVGA_FIFO_EXTCMD_LOADSTATE 3 220 #define VMSVGA_FIFO_EXTCMD_RESET 4 221 222 typedef struct 223 { 224 PSSMHANDLE pSSM; 225 uint32_t uVersion; 226 uint32_t uPass; 227 } VMSVGA_STATE_LOAD, *PVMSVGA_STATE_LOAD; 228 229 typedef struct 230 { 231 /** The host window handle */ 232 uint64_t u64HostWindowId; 233 /** The R3 FIFO pointer. */ 234 R3PTRTYPE(uint32_t *) pFIFOR3; 235 /** The R0 FIFO pointer. */ 236 R0PTRTYPE(uint32_t *) pFIFOR0; 237 /** R3 Opaque pointer to svga state. */ 238 R3PTRTYPE(void *) pSVGAState; 239 /** R3 Opaque pointer to 3d state. */ 240 R3PTRTYPE(void *) p3dState; 241 /** R3 Opaque pointer to a copy of the first 32k of the framebuffer before switching into svga mode. */ 242 R3PTRTYPE(void *) pFrameBufferBackup; 243 /** R3 Opaque pointer to an external fifo cmd parameter. */ 244 R3PTRTYPE(void *) pFIFOExtCmdParam; 245 246 /** Guest physical address of the FIFO memory range. */ 247 RTGCPHYS GCPhysFIFO; 248 /** Size in bytes of the FIFO memory range. */ 249 uint32_t cbFIFO; 250 /** SVGA id. */ 251 uint32_t u32SVGAId; 252 /** SVGA extensions enabled or not. */ 253 uint32_t fEnabled; 254 /** SVGA memory area configured status. */ 255 uint32_t fConfigured; 256 /** Device is busy handling FIFO requests. */ 257 uint32_t fBusy; 258 /** Traces (dirty page detection) enabled or not. */ 259 uint32_t fTraces; 260 /** Guest OS identifier. */ 261 uint32_t u32GuestId; 262 /** Scratch region size. */ 263 uint32_t cScratchRegion; 264 /** Scratch array. */ 265 uint32_t au32ScratchRegion[VMSVGA_SCRATCH_SIZE]; 266 /** Irq status. */ 267 uint32_t u32IrqStatus; 268 /** Irq mask. */ 269 uint32_t u32IrqMask; 270 /** Pitch lock. */ 271 uint32_t u32PitchLock; 272 /** Current GMR id. (SVGA_REG_GMR_ID) */ 273 uint32_t u32CurrentGMRId; 274 /** Register caps. */ 275 uint32_t u32RegCaps; 276 uint32_t Padding2; 277 /** Physical address of command mmio range. */ 278 RTIOPORT BasePort; 279 /** Port io index register. */ 280 uint32_t u32IndexReg; 281 /** FIFO request semaphore. */ 282 RTSEMEVENT FIFORequestSem; 283 /** FIFO external command semaphore. */ 284 RTSEMEVENT FIFOExtCmdSem; 285 /** FIFO IO Thread. */ 286 R3PTRTYPE(PPDMTHREAD) pFIFOIOThread; 287 uint32_t uWidth; 288 uint32_t uHeight; 289 uint32_t uBpp; 290 uint32_t cbScanline; 291 /** Maximum width supported. */ 292 uint32_t u32MaxWidth; 293 /** Maximum height supported. */ 294 uint32_t u32MaxHeight; 295 /** Viewport rectangle */ 296 struct 297 { 298 uint32_t x; 299 uint32_t y; 300 uint32_t cx; 301 uint32_t cy; 302 } viewport; 303 /** Action flags */ 304 uint32_t u32ActionFlags; 305 /** SVGA 3d extensions enabled or not. */ 306 bool f3DEnabled; 307 /** VRAM page monitoring enabled or not. */ 308 bool fVRAMTracking; 309 /** External command to be executed in the FIFO thread. */ 310 uint8_t u8FIFOExtCommand; 311 bool Padding6[1]; 312 } VMSVGAState; 313 #endif /* VBOX_WITH_VMSVGA */ 314 315 214 316 typedef struct VGAState { 215 317 #ifndef VBOX … … 320 422 321 423 #ifdef VBOX_WITH_VMSVGA 322 struct 323 { 324 /** The host window handle */ 325 uint64_t u64HostWindowId; 326 /** The R3 FIFO pointer. */ 327 R3PTRTYPE(uint32_t *) pFIFOR3; 328 /** The R0 FIFO pointer. */ 329 R0PTRTYPE(uint32_t *) pFIFOR0; 330 /** R3 Opaque pointer to svga state. */ 331 R3PTRTYPE(void *) pSVGAState; 332 /** R3 Opaque pointer to 3d state. */ 333 R3PTRTYPE(void *) p3dState; 334 /** R3 Opaque pointer to a copy of the first 32k of the framebuffer before switching into svga mode. */ 335 R3PTRTYPE(void *) pFrameBufferBackup; 336 #if HC_ARCH_BITS == 32 337 uint32_t Padding3; 338 #endif 339 /** Guest physical address of the FIFO memory range. */ 340 RTGCPHYS GCPhysFIFO; 341 /** Size in bytes of the FIFO memory range. */ 342 uint32_t cbFIFO; 343 /** SVGA id. */ 344 uint32_t u32SVGAId; 345 /** SVGA extensions enabled or not. */ 346 uint32_t fEnabled; 347 /** SVGA memory area configured status. */ 348 uint32_t fConfigured; 349 /** Device is busy handling FIFO requests. */ 350 uint32_t fBusy; 351 /** Traces (dirty page detection) enabled or not. */ 352 uint32_t fTraces; 353 /** Guest OS identifier. */ 354 uint32_t u32GuestId; 355 /** Scratch region size. */ 356 uint32_t cScratchRegion; 357 /** Scratch array. */ 358 uint32_t au32ScratchRegion[VMSVGA_SCRATCH_SIZE]; 359 /** Irq status. */ 360 uint32_t u32IrqStatus; 361 /** Irq mask. */ 362 uint32_t u32IrqMask; 363 /** Pitch lock. */ 364 uint32_t u32PitchLock; 365 /** Current GMR id. (SVGA_REG_GMR_ID) */ 366 uint32_t u32CurrentGMRId; 367 /** Register caps. */ 368 uint32_t u32RegCaps; 369 /** Physical address of command mmio range. */ 370 uint32_t Padding2; 371 RTIOPORT BasePort; 372 /** Port io index register. */ 373 uint32_t u32IndexReg; 374 /** FIFO request semaphore. */ 375 RTSEMEVENT FIFORequestSem; 376 /** FIFO IO Thread. */ 377 R3PTRTYPE(PPDMTHREAD) pFIFOIOThread; 378 int32_t iWidth; 379 int32_t iHeight; 380 uint32_t iBpp; 381 uint32_t cbScanline; 382 /** Maximum width supported. */ 383 uint32_t u32MaxWidth; 384 /** Maximum height supported. */ 385 uint32_t u32MaxHeight; 386 /** Action flags */ 387 uint32_t u32ActionFlags; 388 /** SVGA 3d extensions enabled or not. */ 389 bool f3DEnabled; 390 /** VRAM page monitoring enabled or not. */ 391 bool fVRAMTracking; 392 bool Padding6[2]; 393 } svga; 424 VMSVGAState svga; 394 425 #endif 395 426 -
trunk/src/VBox/Devices/Graphics/DevVGASavedState.h
r51631 r53201 27 27 #define VGA_SAVEDSTATE_VERSION_3D 13 28 28 #define VGA_SAVEDSTATE_VERSION_HGSMIMA 12 /* HGSMI memory allocator. */ 29 #define VGA_SAVEDSTATE_VERSION_VMSVGA 1130 29 #define VGA_SAVEDSTATE_VERSION_VMSVGA_2D 10 /* <- internal build with 2d state only */ 31 30 #define VGA_SAVEDSTATE_VERSION_WITH_PENDVHWA 10 -
trunk/src/VBox/Devices/Makefile.kmk
r53062 r53201 246 246 else 247 247 VBoxDD_SOURCES += Graphics/DevVGA-SVGA3d-ogl.cpp 248 VBoxDD_LIBS += $(PATH_STAGE_BIN)/ vmsvgashader$(VBOX_SUFF_DLL)248 VBoxDD_LIBS += $(PATH_STAGE_BIN)/VBoxSVGA3D$(VBOX_SUFF_DLL) 249 249 endif 250 250 VBoxDD_LIBS.win += d3d9.lib 251 251 VBoxDD_LIBS.linux += GL X11 252 VBoxDD_LDFLAGS.darwin += -framework OpenGL 252 253 endif 253 254 … … 928 929 VBoxDDGC_DEFS += VBOX_WITH_VMSVGA 929 930 VBoxDDGC_SOURCES += \ 930 931 Graphics/DevVGA-SVGA.cpp 931 932 endif 932 933 ifdef VBOX_WITH_VMSVGA3D … … 1082 1083 VBoxDDR0_DEFS += VBOX_WITH_VMSVGA 1083 1084 VBoxDDR0_SOURCES += \ 1084 1085 Graphics/DevVGA-SVGA.cpp 1085 1086 endif 1086 1087 ifdef VBOX_WITH_VMSVGA3D … … 1345 1346 endif # VBOX_WITH_EXTPACK_PUEL 1346 1347 1348 1349 TEMPLATE_VBoxSVGA3D = VBoxSVGA3D 1350 TEMPLATE_VBoxSVGA3D_EXTENDS = VBOXR3 1351 TEMPLATE_VBoxSVGA3D_CFLAGS = \ 1352 $(filter-out -pedantic -fno-common,$(TEMPLATE_VBOXR3_CFLAGS)) 1353 TEMPLATE_VBoxSVGA3D_CXXFLAG = \ 1354 $(filter-out -pedantic -fno-common,$(TEMPLATE_VBOXR3_CXXFLAGS)) 1355 TEMPLATE_VBoxSVGA3D_CFLAGS.darwin = \ 1356 $(filter-out -fno-common,$(TEMPLATE_VBOXR3_CFLAGS.darwin)) 1357 TEMPLATE_VBoxSVGA3D_LDFLAGS.darwin += \ 1358 -framework AppKit -framework OpenGL 1359 1360 if defined(VBOX_WITH_VMSVGA3D) 1361 DLLS += VBoxSVGA3D 1362 endif 1363 1364 VBoxSVGA3D_TEMPLATE = VBoxSVGA3D 1365 VBoxSVGA3D_SDKS = ReorderCompilerIncs 1366 VBoxSVGA3D_DEFS = \ 1367 __WINESRC__ \ 1368 WINE_UNICODE_API="" \ 1369 _REENTRANT \ 1370 WINE_NOWINSOCK \ 1371 IN_RING3 \ 1372 VBOX_WITH_VMSVGA \ 1373 VBOX_WITH_VMSVGA3D \ 1374 DLLDIR=\"\" \ 1375 BINDIR=\"\" \ 1376 LIB_TO_BINDIR=\"\" \ 1377 LIB_TO_DLLDIR=\"\" \ 1378 BIN_TO_DLLDIR=\"\" \ 1379 LIB_TO_DATADIR=\"\" \ 1380 BIN_TO_DATADIR=\"\" \ 1381 _USE_MATH_DEFINES \ 1382 VBOX_USING_WINDDK_W7_OR_LATER \ 1383 VBOX_WINE_WITH_SINGLE_SWAPCHAIN_CONTEXT \ 1384 IN_vmsvgashader_STATIC \ 1385 VBOX_WINE_WITH_IPRT 1386 if "$(KBUILD_TYPE)" != "debug" || defined(VBOX_WINE_NO_DEBUG_MSGS) 1387 VBoxSVGA3D_DEFS += WINE_NO_DEBUG_MSGS 1388 endif 1389 VBoxSVGA3D_DEFS.x86 += __i386__ 1390 VBoxSVGA3D_DEFS.amd64 += __x86_64__ 1391 VBoxSVGA3D_DEFS.win += USE_WIN32_OPENGL 1392 # WINE relies on a gcc 4.4 feature but we have 4.2 on Darwin 1393 VBoxSVGA3D_DEFS.darwin += \ 1394 __builtin_ms_va_list=va_list \ 1395 __stdcall= 1396 VBoxSVGA3D_CFLAGS = \ 1397 $(filter-out -pedantic -Wattributes,$(VBoxR3DllWarnNoPic_CFLAGS)) 1398 VBoxSVGA3D_INCS.win += \ 1399 VBOX_WINE_WITHOUT_LIBWINE 1400 VBoxSVGA3D_INCS.win := \ 1401 Graphics/shaderlib/libWineStub/include 1402 VBoxSVGA3D_INCS.linux := \ 1403 Graphics/shaderlib/wine/include 1404 VBoxSVGA3D_INCS.darwin := \ 1405 Graphics/shaderlib/wine/include 1406 VBoxSVGA3D_SOURCES := \ 1407 Graphics/shaderlib/glsl_shader.c \ 1408 Graphics/shaderlib/shader.c \ 1409 Graphics/shaderlib/shader_sm1.c \ 1410 Graphics/shaderlib/shader_sm4.c \ 1411 Graphics/shaderlib/shaderapi.c \ 1412 Graphics/shaderlib/utils.c \ 1413 Graphics/shaderlib/stateblock.c \ 1414 Graphics/shaderlib/directx.c \ 1415 Graphics/shaderlib/libWineStub/debug.c 1416 VBoxSVGA3D_SOURCES.darwin += \ 1417 Graphics/DevVGA-SVGA3d-cocoa.m 1418 VBoxSVGA3D_LIBS = \ 1419 $(LIB_RUNTIME) 1420 VBoxSVGA3D_LIBS.win += $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/Opengl32.lib 1421 if1of ($(KBUILD_TARGET), solaris linux freebsd) 1422 VBoxSVGA3D_LIBS += GL 1423 endif 1424 VBoxSVGA3D_LDFLAGS.darwin += \ 1425 -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/VBoxSVGA3D.dylib 1426 1347 1427 include $(FILE_KBUILD_SUB_FOOTER) 1348 1428 -
trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp
r52817 r53201 339 339 GEN_CHECK_OFF(VGASTATE, svga.BasePort); 340 340 GEN_CHECK_OFF(VGASTATE, svga.pFIFOIOThread); 341 GEN_CHECK_OFF(VGASTATE, svga. iWidth);341 GEN_CHECK_OFF(VGASTATE, svga.uWidth); 342 342 GEN_CHECK_OFF(VGASTATE, svga.u32ActionFlags); 343 343 GEN_CHECK_OFF(VGASTATE, svga.f3DEnabled); -
trunk/src/VBox/Main/src-client/DisplayImpl.cpp
r53053 r53201 2560 2560 } 2561 2561 #endif /* VBOX_WITH_CROGL && VBOX_WITH_HGCM */ 2562 2563 #ifdef VBOX_WITH_VMSVGA 2564 /* The driver might not have been constructed yet */ 2565 if (mpDrv) 2566 { 2567 mpDrv->pUpPort->pfnSetViewPort(mpDrv->pUpPort, aScreenId, aX, aY, aWidth, aHeight); 2568 } 2569 #endif 2570 2562 2571 return S_OK; 2563 2572 }
Note:
See TracChangeset
for help on using the changeset viewer.