Changeset 69922 in vbox
- Timestamp:
- Dec 4, 2017 6:24:57 PM (7 years ago)
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 5 edited
-
DevVGA-SVGA.cpp (modified) (3 diffs)
-
DevVGA-SVGA3d-info.cpp (modified) (5 diffs)
-
DevVGA-SVGA3d-internal.h (modified) (1 diff)
-
DevVGA-SVGA3d-win.cpp (modified) (2 diffs)
-
DevVGA-SVGA3d.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp
r69904 r69922 4616 4616 DECLCALLBACK(void) vmsvgaR3Info3dSurface(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 4617 4617 { 4618 /* There might be a specific contextID at the start of the4619 arguments, if not show all contexts. */4620 uint32_t cid = UINT32_MAX;4618 /* There might be a specific surface ID at the start of the 4619 arguments, if not show all surfaces. */ 4620 uint32_t sid = UINT32_MAX; 4621 4621 if (pszArgs) 4622 4622 pszArgs = RTStrStripL(pszArgs); 4623 4623 if (pszArgs && RT_C_IS_DIGIT(*pszArgs)) 4624 cid = RTStrToUInt32(pszArgs);4624 sid = RTStrToUInt32(pszArgs); 4625 4625 4626 4626 /* Verbose or terse display, we default to verbose. */ … … 4651 4651 fInvY = true; 4652 4652 4653 vmsvga3dInfoSurfaceWorker(PDMINS_2_DATA(pDevIns, PVGASTATE), pHlp, cid, fVerbose, cxAscii, fInvY); 4653 vmsvga3dInfoSurfaceWorker(PDMINS_2_DATA(pDevIns, PVGASTATE), pHlp, sid, fVerbose, cxAscii, fInvY, NULL); 4654 } 4655 4656 4657 /** 4658 * @callback_method_impl{FNDBGFHANDLERDEV, "vmsvga3dsurf"} 4659 */ 4660 DECLCALLBACK(void) vmsvgaR3Info3dSurfaceBmp(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 4661 { 4662 /* pszArg = "sid[>dir]" 4663 * Writes %dir%/info-S-sidI.bmp, where S - sequential bitmap number, I - decimal surface id. 4664 */ 4665 char *pszBitmapPath = NULL; 4666 uint32_t sid = UINT32_MAX; 4667 if (pszArgs) 4668 pszArgs = RTStrStripL(pszArgs); 4669 if (pszArgs && RT_C_IS_DIGIT(*pszArgs)) 4670 RTStrToUInt32Ex(pszArgs, &pszBitmapPath, 0, &sid); 4671 if ( pszBitmapPath 4672 && *pszBitmapPath == '>') 4673 ++pszBitmapPath; 4674 4675 const bool fVerbose = true; 4676 const uint32_t cxAscii = 0; /* No ASCII */ 4677 const bool fInvY = false; /* Do not invert. */ 4678 vmsvga3dInfoSurfaceWorker(PDMINS_2_DATA(pDevIns, PVGASTATE), pHlp, sid, fVerbose, cxAscii, fInvY, pszBitmapPath); 4654 4679 } 4655 4680 … … 5332 5357 "Accepts 'terse', 'invy', and one of 'tiny', 'medium', 'normal', 'big', 'huge', or 'gigantic'.", 5333 5358 vmsvgaR3Info3dSurface); 5359 PDMDevHlpDBGFInfoRegister(pDevIns, "vmsvga3dsurf", 5360 "VMSVGA 3d surface details and bitmap: " 5361 "sid[>dir]", 5362 vmsvgaR3Info3dSurfaceBmp); 5334 5363 # endif 5335 5364 -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-info.cpp
r69859 r69922 20 20 * Header Files * 21 21 *********************************************************************************************************************************/ 22 #include <stdio.h> 22 23 #define LOG_GROUP LOG_GROUP_DEV_VMSVGA 23 24 #include <VBox/vmm/pdmdev.h> … … 831 832 * Skip stuff we can't or won't need to handle. 832 833 */ 833 if (!cx || !cy )834 if (!cx || !cy || !cchMaxX || !cchMaxY) 834 835 return; 835 836 switch (enmFormat) … … 1812 1813 1813 1814 1815 static int vmsvga3dInfoBmpWrite(const char *pszFilename, const void *pvBits, int w, int h, uint32_t cbPixel, uint32_t u32Mask) 1816 { 1817 if ( cbPixel != 4 1818 && cbPixel != 2 1819 && cbPixel != 1) 1820 return VERR_NOT_SUPPORTED; 1821 1822 /* Always write BGRX bitmap for now. */ 1823 const int cbBitmap = w * h * 4; 1824 1825 FILE *f = fopen(pszFilename, "wb"); 1826 if (!f) 1827 return VERR_FILE_NOT_FOUND; 1828 1829 BITMAPFILEHEADER bf; 1830 bf.bfType = 'MB'; 1831 bf.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + cbBitmap; 1832 bf.bfReserved1 = 0; 1833 bf.bfReserved2 = 0; 1834 bf.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); 1835 1836 BITMAPINFOHEADER bi; 1837 bi.biSize = sizeof(bi); 1838 bi.biWidth = w; 1839 bi.biHeight = -h; 1840 bi.biPlanes = 1; 1841 bi.biBitCount = 32; 1842 bi.biCompression = 0; 1843 bi.biSizeImage = cbBitmap; 1844 bi.biXPelsPerMeter = 0; 1845 bi.biYPelsPerMeter = 0; 1846 bi.biClrUsed = 0; 1847 bi.biClrImportant = 0; 1848 1849 fwrite(&bf, 1, sizeof(bf), f); 1850 fwrite(&bi, 1, sizeof(bi), f); 1851 1852 if (cbPixel == 4) 1853 { 1854 const uint32_t *s = (uint32_t *)pvBits; 1855 int i; 1856 for (i = 0; i < w * h; ++i) 1857 { 1858 const uint32_t u32 = *s++; 1859 uint32_t u = u32 & u32Mask; 1860 fwrite(&u, 1, 4, f); 1861 } 1862 } 1863 else if (cbPixel == 2) 1864 { 1865 const uint16_t *s = (uint16_t *)pvBits; 1866 int i; 1867 for (i = 0; i < w * h; ++i) 1868 { 1869 const uint16_t u16 = *s++; 1870 uint32_t u32 = u16; 1871 uint32_t u = u32 & u32Mask; 1872 fwrite(&u, 1, 4, f); 1873 } 1874 } 1875 else if (cbPixel == 1) 1876 { 1877 const uint8_t *s = (uint8_t *)pvBits; 1878 int i; 1879 for (i = 0; i < w * h; ++i) 1880 { 1881 const uint8_t u8 = *s++; 1882 uint32_t u32 = u8 * 0x10000 + u8 * 0x100 + u8; 1883 uint32_t u = u32 & u32Mask; 1884 fwrite(&u, 1, 4, f); 1885 } 1886 } 1887 1888 fclose(f); 1889 1890 return VINF_SUCCESS; 1891 } 1892 1893 void vmsvga3dInfoSurfaceToBitmap(PCDBGFINFOHLP pHlp, PVMSVGA3DSURFACE pSurface, 1894 const char *pszPath, const char *pszNamePrefix, const char *pszNameSuffix) 1895 { 1896 static volatile uint32_t sSeq = 0; 1897 1898 if (!pSurface->pMipmapLevels[0].pSurfaceData) 1899 return; 1900 1901 const uint32_t u32Seq = ASMAtomicIncU32(&sSeq); 1902 1903 char szFilepath[4096]; 1904 RTStrPrintf(szFilepath, sizeof(szFilepath), 1905 "%s\\%s-%u-sid%u%s.bmp", 1906 pszPath, pszNamePrefix, u32Seq, pSurface->id, pszNameSuffix); 1907 1908 const uint32_t cbPixel = vmsvga3dSurfaceFormatSize(pSurface->format, NULL, NULL); 1909 int rc = vmsvga3dInfoBmpWrite(szFilepath, 1910 pSurface->pMipmapLevels[0].pSurfaceData, 1911 pSurface->pMipmapLevels[0].mipmapSize.width, 1912 pSurface->pMipmapLevels[0].mipmapSize.height, 1913 cbPixel, 0xFFFFFFFF); 1914 if (RT_SUCCESS(rc)) 1915 { 1916 Log(("Bitmap: %s\n", szFilepath)); 1917 if (pHlp) 1918 pHlp->pfnPrintf(pHlp, "Bitmap: %s\n", szFilepath); 1919 } 1920 else 1921 { 1922 Log(("Bitmap: %s %Rrc\n", szFilepath, rc)); 1923 if (pHlp) 1924 pHlp->pfnPrintf(pHlp, "Bitmap: %s %Rrc\n", szFilepath, rc); 1925 } 1926 1927 #if 0 1928 /* Alpha channel alone. */ 1929 RTStrPrintf(szFilepath, sizeof(szFilepath), 1930 "%s\\%s-%u-sid%u%s-a.bmp", 1931 pszPath, pszNamePrefix, u32Seq, pSurface->id, pszNameSuffix); 1932 vmsvga3dInfoBmpWrite(szFilepath, 1933 pSurface->pMipmapLevels[0].pSurfaceData, 1934 pSurface->pMipmapLevels[0].mipmapSize.width, 1935 pSurface->pMipmapLevels[0].mipmapSize.height, 1936 cbPixel, 0xFF000000); 1937 #endif 1938 } 1939 1814 1940 static void vmsvga3dInfoSurfaceWorkerOne(PCDBGFINFOHLP pHlp, PVMSVGA3DSURFACE pSurface, 1815 1941 bool fVerbose, uint32_t cxAscii, bool fInvY) … … 1918 2044 1919 2045 1920 void vmsvga3dInfoSurfaceWorker(PVGASTATE pThis, PCDBGFINFOHLP pHlp, uint32_t sid, bool fVerbose, uint32_t cxAscii, bool fInvY )2046 void vmsvga3dInfoSurfaceWorker(PVGASTATE pThis, PCDBGFINFOHLP pHlp, uint32_t sid, bool fVerbose, uint32_t cxAscii, bool fInvY, const char *pszBitmapPath) 1921 2047 { 1922 2048 /* Warning! This code is currently racing papSurfaces reallocation! */ … … 1939 2065 vmsvga3dSurfaceUpdateHeapBuffersOnFifoThread(pThis, sid); 1940 2066 vmsvga3dInfoSurfaceWorkerOne(pHlp, pSurface, fVerbose, cxAscii, fInvY); 2067 if (pszBitmapPath && *pszBitmapPath) 2068 vmsvga3dInfoSurfaceToBitmap(pHlp, pSurface, pszBitmapPath, "info", ""); 1941 2069 return; 1942 2070 } -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-internal.h
r69905 r69922 1227 1227 int vmsvga3dOcclusionQueryGetData(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, uint32_t *pu32Pixels); 1228 1228 1229 #endif 1230 1229 void vmsvga3dInfoSurfaceToBitmap(PCDBGFINFOHLP pHlp, PVMSVGA3DSURFACE pSurface, 1230 const char *pszPath, const char *pszNamePrefix, const char *pszNameSuffix); 1231 1232 #endif 1233 -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp
r69905 r69922 2929 2929 2930 2930 /* Recreate the surface with the original settings; destroys the contents, but that seems fairly safe since the context is also destroyed. */ 2931 #ifdef DEBUG_sunlover 2931 2932 /** @todo not safe with shared objects */ 2932 2933 Assert(pSurface->pSharedObjectTree == NULL); 2934 #endif 2933 2935 2934 2936 rc = vmsvga3dSurfaceDestroy(pThis, sid); … … 5993 5995 } 5994 5996 5997 #if 0 5998 /* Dump render target to a bitmap. */ 5999 if (pContext->state.aRenderTargets[SVGA3D_RT_COLOR0] != SVGA3D_INVALID_ID) 6000 { 6001 vmsvga3dUpdateHeapBuffersForSurfaces(pThis, pContext->state.aRenderTargets[SVGA3D_RT_COLOR0]); 6002 PVMSVGA3DSURFACE pSurface; 6003 int rc2 = vmsvga3dSurfaceFromSid(pState, pContext->state.aRenderTargets[SVGA3D_RT_COLOR0], &pSurface); 6004 if (RT_SUCCESS(rc2)) 6005 vmsvga3dInfoSurfaceToBitmap(NULL, pSurface, "bmp", "rt", "-post"); 6006 } 6007 #endif 6008 5995 6009 return rc; 5996 6010 } -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h
r69163 r69922 121 121 void vmsvga3dUpdateHeapBuffersForSurfaces(PVGASTATE pThis, uint32_t sid); 122 122 void vmsvga3dInfoContextWorker(PVGASTATE pThis, PCDBGFINFOHLP pHlp, uint32_t cid, bool fVerbose); 123 void vmsvga3dInfoSurfaceWorker(PVGASTATE pThis, PCDBGFINFOHLP pHlp, uint32_t sid, bool fVerbose, uint32_t cxAscii, bool fInvY );123 void vmsvga3dInfoSurfaceWorker(PVGASTATE pThis, PCDBGFINFOHLP pHlp, uint32_t sid, bool fVerbose, uint32_t cxAscii, bool fInvY, const char *pszBitmapPath); 124 124 125 125
Note:
See TracChangeset
for help on using the changeset viewer.

