VirtualBox

Changeset 46343 in vbox for trunk/src/VBox/GuestHost/OpenGL


Ignore:
Timestamp:
May 31, 2013 1:27:10 PM (12 years ago)
Author:
vboxsync
Message:

crOpenGL: bugfixes, debugging, dumping draw commands to html

Location:
trunk/src/VBox/GuestHost/OpenGL
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/OpenGL/Makefile.kmk

    r46147 r46343  
    107107        util/warp.c \
    108108        util/vreg.cpp \
     109        util/dump.cpp \
    109110        util/blitter.cpp \
    110111        util/vboxhgcm.c \
     
    135136VBoxOGLcrutil_pixel.c_CFLAGS.win.x86     += -Od
    136137VBoxOGLhostcrutil_pixel.c_CFLAGS.win.x86 += -Od
     138ifdef VBOX_WITH_CRDUMPER
     139VBoxOGLcrutil_DEFS        += VBOX_WITH_CRDUMPER
     140endif
    137141
    138142#
     
    175179    $(PATH_SDK_$(VBOX_WINDDK)_LIB)/dxguid.lib
    176180VBoxOGLhostcrutil_LIBS     = $(LIB_RUNTIME)
     181ifdef VBOX_WITH_CRDUMPER
     182VBoxOGLhostcrutil_DEFS    += VBOX_WITH_CRDUMPER
     183endif
    177184ifdef VBOX_WITH_CRHGSMI
    178185VBoxOGLhostcrutil_DEFS    += VBOX_WITH_CRHGSMI
  • trunk/src/VBox/GuestHost/OpenGL/include/cr_blitter.h

    r45526 r46343  
    8282} CR_BLITTER_WINDOW, *PCR_BLITTER_WINDOW;
    8383
     84typedef struct CR_BLITTER_IMG
     85{
     86    void *pvData;
     87    GLuint cbData;
     88    GLenum enmFormat;
     89    GLuint width, height;
     90    GLuint bpp;
     91    GLuint pitch;
     92} CR_BLITTER_IMG, *PCR_BLITTER_IMG;
     93
    8494typedef struct CR_BLITTER
    8595{
     
    143153VBOXBLITTERDECL(void) CrBltLeave(PCR_BLITTER pBlitter);
    144154VBOXBLITTERDECL(int) CrBltEnter(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pRestoreCtxInfo, const CR_BLITTER_WINDOW *pRestoreMural);
    145 VBOXBLITTERDECL(void) CrBltBlitTexMural(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags);
     155VBOXBLITTERDECL(void) CrBltBlitTexMural(PCR_BLITTER pBlitter, bool fBb, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags);
    146156VBOXBLITTERDECL(void) CrBltBlitTexTex(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *pSrcRect, const VBOXVR_TEXTURE *pDst, const RTRECT *pDstRect, uint32_t cRects, uint32_t fFlags);
     157VBOXBLITTERDECL(int) CrBltImgGetTex(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, GLenum enmFormat, CR_BLITTER_IMG *pDst);
     158
     159VBOXBLITTERDECL(int) CrBltImgGetMural(PCR_BLITTER pBlitter, bool fBb, CR_BLITTER_IMG *pDst);
     160VBOXBLITTERDECL(void) CrBltImgFree(PCR_BLITTER pBlitter, CR_BLITTER_IMG *pDst);
    147161VBOXBLITTERDECL(void) CrBltPresent(PCR_BLITTER pBlitter);
    148162/* */
  • trunk/src/VBox/GuestHost/OpenGL/include/cr_pixeldata.h

    r33280 r46343  
    4444
    4545DECLEXPORT(void) crDumpNamedTGA(const char *fname, GLint w, GLint h, GLvoid *data);
     46DECLEXPORT(void) crDumpNamedTGAV(const char* fname, GLint w, GLint h, GLvoid *data, va_list va);
     47DECLEXPORT(void) crDumpNamedTGAF(const char* fname, GLint w, GLint h, GLvoid *data, ...);
    4648DECLEXPORT(void) crDumpTGA(GLint w, GLint h, GLvoid *data);
    4749#ifdef __cplusplus
  • trunk/src/VBox/GuestHost/OpenGL/include/cr_server.h

    r46173 r46343  
    1616#include "cr_blitter.h"
    1717#include "spu_dispatch_table.h"
     18#include "cr_dump.h"
    1819
    1920#include "state/cr_currentpointers.h"
     
    530531    PFNCRSERVERNOTIFYEVENT pfnNotifyEventCB;
    531532
     533    SPUDispatchTable TmpCtxDispatch;
     534
     535#ifdef VBOX_WITH_CRSERVER_DUMPER
     536    CR_RECORDER Recorder;
     537    CR_BLITTER RecorderBlitter;
     538    CR_DBGPRINT_DUMPER DbgPrintDumper;
     539    CR_HTML_DUMPER HtmlDumper;
     540    CR_DUMPER *pDumper;
     541#endif
     542
    532543    /* @todo: should we use just one blitter?
    533544     * we use two currently because the drawable attribs can differ*/
  • trunk/src/VBox/GuestHost/OpenGL/util/blitter.cpp

    r46085 r46343  
    8888    if (pBlitter->Flags.CtxCreated)
    8989        pBlitter->pDispatch->DestroyContext(pBlitter->CtxInfo.Base.id);
     90    memset(pBlitter, 0, sizeof (pBlitter));
    9091}
    9192
     
    515516void CrBltLeave(PCR_BLITTER pBlitter)
    516517{
    517     Assert(CrBltIsEntered(pBlitter));
     518    if (!CrBltIsEntered(pBlitter))
     519    {
     520        crWarning("CrBltLeave: blitter not entered");
     521        return;
     522    }
    518523
    519524    if (pBlitter->Flags.SupportsFBO)
     
    610615}
    611616
    612 void CrBltBlitTexMural(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags)
    613 {
     617void CrBltBlitTexMural(PCR_BLITTER pBlitter, bool fBb, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags)
     618{
     619    if (!CrBltIsEntered(pBlitter))
     620    {
     621        crWarning("CrBltBlitTexMural: blitter not entered");
     622        return;
     623    }
     624
    614625    RTRECTSIZE DstSize = {pBlitter->CurrentMural.width, pBlitter->CurrentMural.height};
    615626
    616627    pBlitter->pDispatch->BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, 0);
    617628
    618     crBltBlitTexBuf(pBlitter, pSrc, paSrcRects, GL_BACK, &DstSize, paDstRects, cRects, fFlags);
     629    crBltBlitTexBuf(pBlitter, pSrc, paSrcRects, fBb ? GL_BACK : GL_FRONT, &DstSize, paDstRects, cRects, fFlags);
    619630}
    620631
    621632void CrBltBlitTexTex(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *pSrcRect, const VBOXVR_TEXTURE *pDst, const RTRECT *pDstRect, uint32_t cRects, uint32_t fFlags)
    622633{
     634    if (!CrBltIsEntered(pBlitter))
     635    {
     636        crWarning("CrBltBlitTexTex: blitter not entered");
     637        return;
     638    }
     639
    623640    RTRECTSIZE DstSize = {(uint32_t)pDst->width, (uint32_t)pDst->height};
    624641
     
    639656void CrBltPresent(PCR_BLITTER pBlitter)
    640657{
     658    if (!CrBltIsEntered(pBlitter))
     659    {
     660        crWarning("CrBltPresent: blitter not entered");
     661        return;
     662    }
     663
    641664    if (pBlitter->CtxInfo.Base.visualBits & CR_DOUBLE_BIT)
    642665        pBlitter->pDispatch->SwapBuffers(pBlitter->CurrentMural.Base.id, 0);
     
    644667        pBlitter->pDispatch->Flush();
    645668}
     669
     670static int crBltImgCreateForTex(const VBOXVR_TEXTURE *pSrc, CR_BLITTER_IMG *pDst, GLenum enmFormat)
     671{
     672    memset(pDst, 0, sizeof (*pDst));
     673    if (enmFormat != GL_RGBA
     674            && enmFormat != GL_BGRA)
     675    {
     676        crWarning("unsupported format 0x%x", enmFormat);
     677        return VERR_NOT_IMPLEMENTED;
     678    }
     679
     680    uint32_t bpp = 32;
     681
     682    uint32_t pitch = ((bpp * pSrc->width) + 7) >> 3;
     683    uint32_t cbData = pitch * pSrc->height;
     684    pDst->pvData = RTMemAllocZ(cbData);
     685    if (!pDst->pvData)
     686    {
     687        crWarning("RTMemAlloc failed");
     688        return VERR_NO_MEMORY;
     689    }
     690
     691#ifdef DEBUG_misha
     692    {
     693        char *pTmp = (char*)pDst->pvData;
     694        for (uint32_t i = 0; i < cbData; ++i)
     695        {
     696            pTmp[i] = (char)((1 << i) % 255);
     697        }
     698    }
     699#endif
     700
     701    pDst->cbData = cbData;
     702    pDst->enmFormat = enmFormat;
     703    pDst->width = pSrc->width;
     704    pDst->height = pSrc->height;
     705    pDst->bpp = bpp;
     706    pDst->pitch = pitch;
     707    return VINF_SUCCESS;
     708}
     709
     710VBOXBLITTERDECL(int) CrBltImgGetTex(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, GLenum enmFormat, CR_BLITTER_IMG *pDst)
     711{
     712    if (!CrBltIsEntered(pBlitter))
     713    {
     714        crWarning("CrBltImgGetTex: blitter not entered");
     715        return VERR_INVALID_STATE;
     716    }
     717
     718    int rc = crBltImgCreateForTex(pSrc, pDst, enmFormat);
     719    if (!RT_SUCCESS(rc))
     720    {
     721        crWarning("crBltImgCreateForTex failed, rc %d", rc);
     722        return rc;
     723    }
     724    pBlitter->pDispatch->BindTexture(pSrc->target, pSrc->hwid);
     725
     726#ifdef DEBUG_misha
     727    {
     728        GLint width = 0, height = 0, depth = 0;
     729        pBlitter->pDispatch->GetTexLevelParameteriv(pSrc->target, 0, GL_TEXTURE_WIDTH, &width);
     730        pBlitter->pDispatch->GetTexLevelParameteriv(pSrc->target, 0, GL_TEXTURE_HEIGHT, &height);
     731        pBlitter->pDispatch->GetTexLevelParameteriv(pSrc->target, 0, GL_TEXTURE_DEPTH, &depth);
     732
     733        Assert(width == pSrc->width);
     734        Assert(height == pSrc->height);
     735//        Assert(depth == pSrc->depth);
     736    }
     737#endif
     738
     739    pBlitter->pDispatch->GetTexImage(pSrc->target, 0, enmFormat, GL_UNSIGNED_BYTE, pDst->pvData);
     740
     741    pBlitter->pDispatch->BindTexture(pSrc->target, 0);
     742    return VINF_SUCCESS;
     743}
     744
     745VBOXBLITTERDECL(int) CrBltImgGetMural(PCR_BLITTER pBlitter, bool fBb, CR_BLITTER_IMG *pDst)
     746{
     747    if (!CrBltIsEntered(pBlitter))
     748    {
     749        crWarning("CrBltImgGetMural: blitter not entered");
     750        return VERR_INVALID_STATE;
     751    }
     752
     753    crWarning("NOT IMPLEMENTED");
     754    return VERR_NOT_IMPLEMENTED;
     755}
     756
     757VBOXBLITTERDECL(void) CrBltImgFree(PCR_BLITTER pBlitter, CR_BLITTER_IMG *pDst)
     758{
     759    if (!CrBltIsEntered(pBlitter))
     760    {
     761        crWarning("CrBltImgFree: blitter not entered");
     762        return;
     763    }
     764
     765    if (pDst->pvData)
     766    {
     767        RTMemFree(pDst->pvData);
     768        pDst->pvData = NULL;
     769    }
     770}
     771
  • trunk/src/VBox/GuestHost/OpenGL/util/pixel.c

    r35263 r46343  
    1111#include <stdio.h>
    1212#include <math.h>
     13
     14#include <iprt/string.h>
    1315
    1416#if defined(WINDOWS)
     
    18421844    fclose(out);
    18431845}
     1846
     1847void crDumpNamedTGAV(const char* fname, GLint w, GLint h, GLvoid *data, va_list va)
     1848{
     1849    char szName[4096];
     1850    RTStrPrintfV(szName, sizeof(szName), fname, va);
     1851    crDumpNamedTGA(szName, w, h, data);
     1852}
     1853
     1854void crDumpNamedTGAF(const char* fname, GLint w, GLint h, GLvoid *data, ...)
     1855{
     1856    va_list va;
     1857    int rc;
     1858    va_start(va, fname);
     1859    crDumpNamedTGAV(fname, w, h, data, va);
     1860    va_end(va);
     1861}
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