VirtualBox

Changeset 69922 in vbox


Ignore:
Timestamp:
Dec 4, 2017 6:24:57 PM (7 years ago)
Author:
vboxsync
Message:

Devices/Graphics: VMSVGA: info vmsvga3dsurf debugger command.

Location:
trunk/src/VBox/Devices/Graphics
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp

    r69904 r69922  
    46164616DECLCALLBACK(void) vmsvgaR3Info3dSurface(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
    46174617{
    4618     /* There might be a specific context ID at the start of the
    4619        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;
    46214621    if (pszArgs)
    46224622        pszArgs = RTStrStripL(pszArgs);
    46234623    if (pszArgs && RT_C_IS_DIGIT(*pszArgs))
    4624         cid = RTStrToUInt32(pszArgs);
     4624        sid = RTStrToUInt32(pszArgs);
    46254625
    46264626    /* Verbose or terse display, we default to verbose. */
     
    46514651        fInvY = true;
    46524652
    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 */
     4660DECLCALLBACK(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);
    46544679}
    46554680
     
    53325357                              "Accepts 'terse', 'invy', and one of 'tiny', 'medium', 'normal', 'big', 'huge', or 'gigantic'.",
    53335358                              vmsvgaR3Info3dSurface);
     5359    PDMDevHlpDBGFInfoRegister(pDevIns, "vmsvga3dsurf",
     5360                              "VMSVGA 3d surface details and bitmap: "
     5361                              "sid[>dir]",
     5362                              vmsvgaR3Info3dSurfaceBmp);
    53345363# endif
    53355364
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-info.cpp

    r69859 r69922  
    2020*   Header Files                                                                                                                 *
    2121*********************************************************************************************************************************/
     22#include <stdio.h>
    2223#define LOG_GROUP LOG_GROUP_DEV_VMSVGA
    2324#include <VBox/vmm/pdmdev.h>
     
    831832     * Skip stuff we can't or won't need to handle.
    832833     */
    833     if (!cx || !cy)
     834    if (!cx || !cy || !cchMaxX || !cchMaxY)
    834835        return;
    835836    switch (enmFormat)
     
    18121813
    18131814
     1815static 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
     1893void 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
    18141940static void vmsvga3dInfoSurfaceWorkerOne(PCDBGFINFOHLP pHlp, PVMSVGA3DSURFACE pSurface,
    18151941                                         bool fVerbose, uint32_t cxAscii, bool fInvY)
     
    19182044
    19192045
    1920 void vmsvga3dInfoSurfaceWorker(PVGASTATE pThis, PCDBGFINFOHLP pHlp, uint32_t sid, bool fVerbose, uint32_t cxAscii, bool fInvY)
     2046void vmsvga3dInfoSurfaceWorker(PVGASTATE pThis, PCDBGFINFOHLP pHlp, uint32_t sid, bool fVerbose, uint32_t cxAscii, bool fInvY, const char *pszBitmapPath)
    19212047{
    19222048    /* Warning! This code is currently racing papSurfaces reallocation! */
     
    19392065                        vmsvga3dSurfaceUpdateHeapBuffersOnFifoThread(pThis, sid);
    19402066                    vmsvga3dInfoSurfaceWorkerOne(pHlp, pSurface, fVerbose, cxAscii, fInvY);
     2067                    if (pszBitmapPath && *pszBitmapPath)
     2068                        vmsvga3dInfoSurfaceToBitmap(pHlp, pSurface, pszBitmapPath, "info", "");
    19412069                    return;
    19422070                }
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-internal.h

    r69905 r69922  
    12271227int vmsvga3dOcclusionQueryGetData(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, uint32_t *pu32Pixels);
    12281228
    1229 #endif
    1230 
     1229void 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  
    29292929
    29302930                /* 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
    29312932                /** @todo not safe with shared objects */
    29322933                Assert(pSurface->pSharedObjectTree == NULL);
     2934#endif
    29332935
    29342936                rc = vmsvga3dSurfaceDestroy(pThis, sid);
     
    59935995    }
    59945996
     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
    59956009    return rc;
    59966010}
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h

    r69163 r69922  
    121121void vmsvga3dUpdateHeapBuffersForSurfaces(PVGASTATE pThis, uint32_t sid);
    122122void 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);
     123void vmsvga3dInfoSurfaceWorker(PVGASTATE pThis, PCDBGFINFOHLP pHlp, uint32_t sid, bool fVerbose, uint32_t cxAscii, bool fInvY, const char *pszBitmapPath);
    124124
    125125
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette