VirtualBox

Changeset 43488 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Oct 1, 2012 11:54:33 AM (12 years ago)
Author:
vboxsync
Message:

wined3d: profiling; export flushToHost and Finish commands

Location:
trunk/src/VBox/Additions/WINNT/Graphics/Wine
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/Makefile.kmk

    r42408 r43488  
    225225        IN_VBOXLIBWINE \
    226226        VBOX_WINE_WITH_SHADER_CACHE
     227ifdef VBOX_WINE_WITH_PROFILE
     228 wined3dwddm_DEFS       += VBOX_WINE_WITH_PROFILE
     229endif
    227230 wined3dwddm_INCS           = $(wined3d_INCS) \
    228231        $(PATH_ROOT)/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/d3d9wddm.def

    r43334 r43488  
    1313  Direct3DCreate9Ex
    1414  VBoxWineExD3DDev9Flush
     15  VBoxWineExD3DDev9FlushToHost
     16  VBoxWineExD3DDev9Finish
    1517  VBoxWineExD3DDev9CreateTexture
    1618  VBoxWineExD3DDev9CreateCubeTexture
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/device.c

    r43334 r43488  
    786786    wined3d_mutex_lock();
    787787    hr = IWineD3DDevice_Flush(This->WineD3DDevice);
     788    wined3d_mutex_unlock();
     789
     790    return hr;
     791}
     792
     793VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DDev9FlushToHost(IDirect3DDevice9Ex *iface)
     794{
     795    IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
     796    HRESULT hr;
     797
     798    TRACE("iface %p, FlushToHost\n", iface);
     799
     800    wined3d_mutex_lock();
     801    hr = IWineD3DDevice_FlushToHost(This->WineD3DDevice);
     802    wined3d_mutex_unlock();
     803
     804    return hr;
     805}
     806
     807VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DDev9Finish(IDirect3DDevice9Ex *iface)
     808{
     809    IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
     810    HRESULT hr;
     811
     812    TRACE("iface %p, Finish\n", iface);
     813
     814    wined3d_mutex_lock();
     815    hr = IWineD3DDevice_Finish(This->WineD3DDevice);
    788816    wined3d_mutex_unlock();
    789817
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/vbox/VBoxWineEx.h

    r43334 r43488  
    6969typedef FNVBOXWINEEXD3DDEV9_FLUSH *PFNVBOXWINEEXD3DDEV9_FLUSH;
    7070
     71typedef VBOXWINEEX_DECL(HRESULT) FNVBOXWINEEXD3DDEV9_FLUSHTOHOST(IDirect3DDevice9Ex *iface);
     72typedef FNVBOXWINEEXD3DDEV9_FLUSHTOHOST *PFNVBOXWINEEXD3DDEV9_FLUSHTOHOST;
     73
     74typedef VBOXWINEEX_DECL(HRESULT) FNVBOXWINEEXD3DDEV9_FINISH(IDirect3DDevice9Ex *iface);
     75typedef FNVBOXWINEEXD3DDEV9_FINISH *PFNVBOXWINEEXD3DDEV9_FINISH;
     76
    7177typedef VBOXWINEEX_DECL(HRESULT) FNVBOXWINEEXD3DDEV9_UPDATE(IDirect3DDevice9Ex *iface, D3DPRESENT_PARAMETERS * pParams, IDirect3DDevice9Ex **outIface);
    7278typedef FNVBOXWINEEXD3DDEV9_UPDATE *PFNVBOXWINEEXD3DDEV9_UPDATE;
     
    114120VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DDev9Flush(IDirect3DDevice9Ex *iface); /* perform glFlush */
    115121
     122VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DDev9Finish(IDirect3DDevice9Ex *iface); /* perform glFinish */
     123
     124VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DDev9FlushToHost(IDirect3DDevice9Ex *iface); /* flash data to host */
     125
    116126VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DDev9Update(IDirect3DDevice9Ex *iface, D3DPRESENT_PARAMETERS * pParams,
    117127                                                    IDirect3DDevice9Ex **outIface); /* update device parameters */
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/vbox/libWineStub/include/wine/debug.h

    r41428 r43488  
    359359
    360360
    361 #ifdef DEBUG_misha
    362 //# define VBOXWINEDBG_SHADERS
    363 #endif
    364 
    365 #ifdef VBOXWINEDBG_SHADERS
     361#if 1//fdef DEBUG_misha
     362# define VBOXWINEDBG_SHADERS
     363#endif
     364
     365#if defined(VBOXWINEDBG_SHADERS) || defined(VBOX_WINE_WITH_PROFILE)
    366366#include <stdio.h>
    367367#include <stdarg.h>
    368368
    369369void vboxWDbgPrintF(char * szString, ...);
    370 
     370#endif
     371
     372#ifdef VBOXWINEDBG_SHADERS
    371373# define WDLOG(_m) do {\
    372374        vboxWDbgPrintF _m ; \
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/vbox/libWineStub/include/wine/wined3d.h

    r43334 r43488  
    82528252            const struct VBOXPOINT3D *pDstPoin3D
    82538253            );
     8254
     8255    HRESULT (STDMETHODCALLTYPE *FlushToHost)(
     8256            IWineD3DDevice *iface);
     8257
     8258    HRESULT (STDMETHODCALLTYPE *Finish)(
     8259        IWineD3DDevice* This);
    82548260#endif
    82558261
     
    84278433#define IWineD3DDevice_VolBlt(This, pSourceVolume, pDestinationVolume, pSrcBoxArg, pDstPoin3D) (This)->lpVtbl->VolBlt(This, pSourceVolume, pDestinationVolume, pSrcBoxArg, pDstPoin3D)
    84288434#define IWineD3DDevice_VolTexBlt(This, pSourceTexture, pDestinationTexture, pSrcBoxArg, pDstPoin3D) (This)->lpVtbl->VolTexBlt(This, pSourceTexture, pDestinationTexture, pSrcBoxArg, pDstPoin3D)
     8435#define IWineD3DDevice_FlushToHost(This) (This)->lpVtbl->FlushToHost(This)
     8436#define IWineD3DDevice_Finish(This) (This)->lpVtbl->Finish(This)
    84298437#endif
    84308438#endif
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/device.c

    r43334 r43488  
    18711871    if(!This->d3d_initialized) return WINED3DERR_INVALIDCALL;
    18721872
     1873#ifdef VBOX_WINE_WITH_PROFILE
     1874    VBOXWINEPROFILE_DRAWPRIM_TERM(&This->DrawPrimProfile);
     1875#endif
     1876
    18731877    /* I don't think that the interface guarantees that the device is destroyed from the same thread
    18741878     * it was created. Thus make sure a context is active for the glDelete* calls
     
    72697273    return WINED3D_OK;
    72707274}
     7275
     7276static HRESULT WINAPI IWineD3DDeviceImpl_Finish(IWineD3DDevice *iface)
     7277{
     7278    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     7279    struct wined3d_context *context;
     7280    int i;
     7281
     7282    /* first call swapchain flush to ensure all swapchain-pending data gets flushed */
     7283    for (i = 0; i < This->NumberOfSwapChains; ++i)
     7284    {
     7285        IWineD3DSwapChain *pSwapchain = This->swapchains[i];
     7286        IWineD3DSwapChain_Flush(pSwapchain);
     7287    }
     7288
     7289    for (i = 0; i < This->numContexts; ++i)
     7290    {
     7291        context = This->contexts[i];
     7292        if (context_acquire_context(context, NULL, CTXUSAGE_RESOURCELOAD, TRUE))
     7293        {
     7294            Assert(context->valid);
     7295            wglFinish();
     7296            context_release(context);
     7297        }
     7298        else
     7299        {
     7300            WARN("Invalid context, skipping flush.\n");
     7301        }
     7302    }
     7303    return WINED3D_OK;
     7304}
     7305
     7306static HRESULT WINAPI IWineD3DDeviceImpl_FlushToHost(IWineD3DDevice *iface)
     7307{
     7308    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     7309    struct wined3d_context *context;
     7310    int i;
     7311
     7312    /* no context acquisition is needed */
     7313    for (i = 0; i < This->numContexts; ++i)
     7314    {
     7315        context = This->contexts[i];
     7316        pVBoxFlushToHost(context->glCtx);
     7317    }
     7318    return WINED3D_OK;
     7319}
     7320
    72717321
    72727322/* context activation is done by the caller */
     
    74747524    IWineD3DDeviceImpl_VolBlt,
    74757525    IWineD3DDeviceImpl_VolTexBlt,
     7526    IWineD3DDeviceImpl_FlushToHost,
     7527    IWineD3DDeviceImpl_Finish,
    74767528#endif
    74777529};
     
    75197571    device->createParms.hFocusWindow = focus_window;
    75207572    device->createParms.BehaviorFlags = flags;
     7573
     7574#ifdef VBOX_WINE_WITH_PROFILE
     7575    VBOXWINEPROFILE_DRAWPRIM_INIT(&device->DrawPrimProfile);
     7576#endif
    75217577
    75227578    device->devType = device_type;
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/glsl_shader.c

    r43333 r43488  
    53355335};
    53365336
    5337 #ifdef VBOXWINEDBG_SHADERS
     5337#if defined(VBOXWINEDBG_SHADERS) || defined(VBOX_WINE_WITH_PROFILE)
    53385338void vboxWDbgPrintF(char * szString, ...)
    53395339{
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_gl.h

    r42499 r43488  
    13831383
    13841384HGLRC (WINAPI *pVBoxCreateContext)(HDC, struct VBOXUHGSMI*) DECLSPEC_HIDDEN;
     1385void (WINAPI *pVBoxFlushToHost)(HGLRC) DECLSPEC_HIDDEN;
    13851386
    13861387#define GL_FUNCS_GEN \
     
    17311732
    17321733#define VBOX_FUNCS_GEN \
    1733     USE_WGL_FUNC(VBoxCreateContext)
     1734    USE_WGL_FUNC(VBoxCreateContext) \
     1735    USE_WGL_FUNC(VBoxFlushToHost)
    17341736
    17351737/* OpenGL extensions. */
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_private.h

    r43334 r43488  
    16761676#define WINED3DCREATE_MULTITHREADED 0x00000004
    16771677
     1678#ifdef VBOX_WINE_WITH_PROFILE
     1679
     1680#include <iprt/time.h>
     1681
     1682#define VBOXWINEPROFILE_GET_TIME_NANO() RTTimeNanoTS()
     1683#define VBOXWINEPROFILE_GET_TIME_MILLI() RTTimeMilliTS()
     1684
     1685# define PRLOG(_m) do {\
     1686        vboxWDbgPrintF _m ; \
     1687    } while (0)
     1688
     1689typedef struct VBOXWINEPROFILE_ELEMENT
     1690{
     1691    uint64_t u64Time;
     1692    uint32_t cu32Calls;
     1693} VBOXWINEPROFILE_ELEMENT, *PVBOXWINEPROFILE_ELEMENT;
     1694
     1695typedef struct VBOXWINEPROFILE_HASHMAP_ELEMENT
     1696{
     1697    VBOXEXT_HASHMAP_ENTRY MapEntry;
     1698    VBOXWINEPROFILE_ELEMENT Data;
     1699} VBOXWINEPROFILE_HASHMAP_ELEMENT, *PVBOXWINEPROFILE_HASHMAP_ELEMENT;
     1700
     1701#define VBOXWINEPROFILE_HASHMAP_ELEMENT_FROMENTRY(_p) ((PVBOXWINEPROFILE_HASHMAP_ELEMENT)(((uint8_t*)(_p)) - RT_OFFSETOF(VBOXWINEPROFILE_HASHMAP_ELEMENT, MapEntry)))
     1702
     1703#define VBOXWINEPROFILE_ELEMENT_DUMP(_p, _pn) do { \
     1704        PRLOG(("%s: t(%u);c(%u)\n", \
     1705            (_pn), \
     1706            (uint32_t)((_p)->u64Time / 1000000), \
     1707            (_p)->cu32Calls \
     1708            )); \
     1709    } while (0)
     1710
     1711#define VBOXWINEPROFILE_ELEMENT_RESET(_p) do { \
     1712        memset(_p, 0, sizeof (*(_p))); \
     1713    } while (0)
     1714
     1715#define VBOXWINEPROFILE_ELEMENT_STEP(_p, _t) do { \
     1716        (_p)->u64Time += (_t); \
     1717        ++(_p)->cu32Calls; \
     1718    } while (0)
     1719
     1720#define VBOXWINEPROFILE_HASHMAP_ELEMENT_CREATE()  ( (PVBOXWINEPROFILE_HASHMAP_ELEMENT)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof (VBOXWINEPROFILE_HASHMAP_ELEMENT)) )
     1721
     1722#define VBOXWINEPROFILE_HASHMAP_ELEMENT_TERM(_pe) do { \
     1723        HeapFree(GetProcessHeap(), 0, (_pe)); \
     1724    } while (0)
     1725
     1726DECLINLINE(PVBOXWINEPROFILE_HASHMAP_ELEMENT) vboxWineProfileHashMapElementGet(PVBOXEXT_HASHMAP pMap, void *pvKey)
     1727{
     1728    PVBOXEXT_HASHMAP_ENTRY pEntry = VBoxExtHashGet(pMap, pvKey);
     1729    if (pEntry)
     1730    {
     1731        return VBOXWINEPROFILE_HASHMAP_ELEMENT_FROMENTRY(pEntry);
     1732    }
     1733    else
     1734    {
     1735        PVBOXWINEPROFILE_HASHMAP_ELEMENT pElement = VBOXWINEPROFILE_HASHMAP_ELEMENT_CREATE();
     1736        Assert(pElement);
     1737        if (pElement)
     1738            VBoxExtHashPut(pMap, pvKey, &pElement->MapEntry);
     1739        return pElement;
     1740    }
     1741}
     1742
     1743#define VBOXWINEPROFILE_HASHMAP_ELEMENT_STEP(_pm, _pk, _t) do { \
     1744        PVBOXWINEPROFILE_HASHMAP_ELEMENT pElement = vboxWineProfileHashMapElementGet(_pm, _pk); \
     1745        VBOXWINEPROFILE_ELEMENT_STEP(&pElement->Data, _t); \
     1746    } while (0)
     1747
     1748static DECLCALLBACK(bool) vboxWineProfileElementResetCb(struct VBOXEXT_HASHMAP *pMap, void *pvKey, struct VBOXEXT_HASHMAP_ENTRY *pValue, void *pvVisitor)
     1749{
     1750    PVBOXWINEPROFILE_HASHMAP_ELEMENT pElement = VBOXWINEPROFILE_HASHMAP_ELEMENT_FROMENTRY(pValue);
     1751    VBOXWINEPROFILE_ELEMENT_RESET(&pElement->Data);
     1752    return true;
     1753}
     1754
     1755static DECLCALLBACK(bool) vboxWineProfileElementDumpCb(struct VBOXEXT_HASHMAP *pMap, void *pvKey, struct VBOXEXT_HASHMAP_ENTRY *pValue, void *pvVisitor)
     1756{
     1757    PVBOXWINEPROFILE_HASHMAP_ELEMENT pElement = VBOXWINEPROFILE_HASHMAP_ELEMENT_FROMENTRY(pValue);
     1758    char *pName = (char*)pvVisitor;
     1759    PRLOG(("%s[%d]:", pName, (uint32_t)pvKey));
     1760    VBOXWINEPROFILE_ELEMENT_DUMP(&pElement->Data, "");
     1761    return true;
     1762}
     1763
     1764#define VBOXWINEPROFILE_HASHMAP_RESET(_pm) do { \
     1765        VBoxExtHashVisit((_pm), vboxWineProfileElementResetCb, NULL); \
     1766    } while (0)
     1767
     1768#define VBOXWINEPROFILE_HASHMAP_DUMP(_pm, _pn) do { \
     1769        VBoxExtHashVisit((_pm), vboxWineProfileElementDumpCb, (_pn)); \
     1770    } while (0)
     1771
     1772static DECLCALLBACK(bool) vboxWineProfileElementCleanupCb(struct VBOXEXT_HASHMAP *pMap, void *pvKey, struct VBOXEXT_HASHMAP_ENTRY *pValue, void *pvVisitor)
     1773{
     1774    PVBOXWINEPROFILE_HASHMAP_ELEMENT pElement = VBOXWINEPROFILE_HASHMAP_ELEMENT_FROMENTRY(pValue);
     1775    VBOXWINEPROFILE_HASHMAP_ELEMENT_TERM(pElement);
     1776    return true;
     1777}
     1778
     1779#define VBOXWINEPROFILE_HASHMAP_TERM(_pm) do { \
     1780        VBoxExtHashCleanup((_pm), vboxWineProfileElementCleanupCb, NULL); \
     1781        VBoxExtHashVisit((_pm), vboxWineProfileElementResetCb, NULL); \
     1782    } while (0)
     1783
     1784typedef struct VBOXWINEPROFILE_DRAWPRIM
     1785{
     1786    uint64_t u64LoadLocationTime;
     1787    uint64_t u64CtxAcquireTime;
     1788    uint64_t u64PostProcess;
     1789    VBOXEXT_HASHMAP MapDrawPrimSlowVs;
     1790    VBOXEXT_HASHMAP MapDrawPrimSlow;
     1791    VBOXEXT_HASHMAP MapDrawPrimStrided;
     1792    VBOXEXT_HASHMAP MapDrawPrimFast;
     1793    uint32_t cu32Calls;
     1794} VBOXWINEPROFILE_DRAWPRIM, *PVBOXWINEPROFILE_DRAWPRIM;
     1795
     1796#define VBOXWINEPROFILE_DRAWPRIM_RESET_NEXT(_p) do { \
     1797        (_p)->u64LoadLocationTime = 0; \
     1798        (_p)->u64CtxAcquireTime = 0; \
     1799        (_p)->u64PostProcess = 0; \
     1800        VBOXWINEPROFILE_HASHMAP_RESET(&(_p)->MapDrawPrimSlowVs); \
     1801        VBOXWINEPROFILE_HASHMAP_RESET(&(_p)->MapDrawPrimSlow); \
     1802        VBOXWINEPROFILE_HASHMAP_RESET(&(_p)->MapDrawPrimStrided); \
     1803        VBOXWINEPROFILE_HASHMAP_RESET(&(_p)->MapDrawPrimFast); \
     1804    } while (0)
     1805
     1806static DECLCALLBACK(uint32_t) vboxWineProfileDrawPrimHashMapHash(void *pvKey)
     1807{
     1808    return (uint32_t)pvKey;
     1809}
     1810
     1811static DECLCALLBACK(bool) vboxWineProfileDrawPrimHashMapEqual(void *pvKey1, void *pvKey2)
     1812{
     1813    return ((uint32_t)pvKey1) == ((uint32_t)pvKey2);
     1814}
     1815
     1816#define VBOXWINEPROFILE_DRAWPRIM_INIT(_p) do { \
     1817        memset((_p), 0, sizeof (*(_p))); \
     1818        VBoxExtHashInit(&(_p)->MapDrawPrimSlowVs, vboxWineProfileDrawPrimHashMapHash, vboxWineProfileDrawPrimHashMapEqual); \
     1819        VBoxExtHashInit(&(_p)->MapDrawPrimSlow, vboxWineProfileDrawPrimHashMapHash, vboxWineProfileDrawPrimHashMapEqual); \
     1820        VBoxExtHashInit(&(_p)->MapDrawPrimStrided, vboxWineProfileDrawPrimHashMapHash, vboxWineProfileDrawPrimHashMapEqual); \
     1821        VBoxExtHashInit(&(_p)->MapDrawPrimFast, vboxWineProfileDrawPrimHashMapHash, vboxWineProfileDrawPrimHashMapEqual); \
     1822    } while (0)
     1823
     1824#define VBOXWINEPROFILE_DRAWPRIM_TERM(_p) do { \
     1825        memset((_p), 0, sizeof (*(_p))); \
     1826        VBOXWINEPROFILE_HASHMAP_TERM(&(_p)->MapDrawPrimSlowVs); \
     1827        VBOXWINEPROFILE_HASHMAP_TERM(&(_p)->MapDrawPrimSlow); \
     1828        VBOXWINEPROFILE_HASHMAP_TERM(&(_p)->MapDrawPrimStrided); \
     1829        VBOXWINEPROFILE_HASHMAP_TERM(&(_p)->MapDrawPrimFast); \
     1830    } while (0)
     1831#else
     1832# define PRLOG(_m) do {} while (0)
     1833#endif
    16781834struct IWineD3DDeviceImpl
    16791835{
     
    18121968    VBOXEXT_HASHCACHE vshaderCache;
    18131969    VBOXEXT_HASHCACHE pshaderCache;
     1970#endif
     1971
     1972#ifdef VBOX_WINE_WITH_PROFILE
     1973    VBOXWINEPROFILE_DRAWPRIM DrawPrimProfile;
    18141974#endif
    18151975
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