VirtualBox

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


Ignore:
Timestamp:
May 2, 2012 8:37:46 AM (13 years ago)
Author:
vboxsync
Message:

crOpenGL,wined3d,wddm: second part of fixing resource leakage, basics for cr commands submission from r0 miniport driver (for r0 visible region reporting, WPF 3D rendering fixes w/o Aero, etc.)

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/OpenGL/include/chromium.h

    r38143 r41109  
    2121#include "cr_compiler.h"
    2222
     23#ifdef IN_RING0
     24#include <common/VBoxMPUtils.h>
     25#define WINGDIAPI
     26#endif
    2327/*
    2428 * We effectively wrap gl.h, glu.h, etc, just like GLUT
     
    3034
    3135#if defined(WINDOWS)
     36# ifdef IN_RING0
     37#  error "should not happen!"
     38# endif
    3239#define WIN32_LEAN_AND_MEAN
    3340#define WGL_APIENTRY __stdcall
     
    3643/* nothing */
    3744#else
    38 #define GLX
     45# ifndef IN_RING0
     46#  define GLX
     47# endif
    3948#endif
    4049
     
    688697/*Global resource ids sharing*/
    689698#define GL_SHARE_CONTEXT_RESOURCES_CR 0x8B27
     699/*do flush for the command buffer of a thread the context was previusly current for*/
    690700#define GL_FLUSH_ON_THREAD_SWITCH_CR  0x8B28
     701/*report that the shared resource is used by this context, the parameter value is a texture name*/
     702#define GL_RCUSAGE_TEXTURE_SET_CR     0x8B29
     703/*report that the shared resource is no longer used by this context, the parameter value is a texture name*/
     704#define GL_RCUSAGE_TEXTURE_CLEAR_CR   0x8B2A
    691705
    692706/**********************************************************************/
  • trunk/src/VBox/GuestHost/OpenGL/include/cr_glstate.h

    r41071 r41109  
    6060# define CR_STATE_SHAREDOBJ_USAGE_CLEAR(_pObj, _pCtx) (ASMBitClear((_pObj)->ctxUsage, (_pCtx)->id))
    6161# define CR_STATE_SHAREDOBJ_USAGE_IS_USED(_pObj) (ASMBitFirstSet((_pObj)->ctxUsage, sizeof ((_pObj)->ctxUsage)<<3) >= 0)
     62#else
     63# define CR_STATE_SHAREDOBJ_USAGE_INIT(_pObj) do {} while (0)
     64# define CR_STATE_SHAREDOBJ_USAGE_SET(_pObj, _pCtx) do {} while (0)
     65# define CR_STATE_SHAREDOBJ_USAGE_CLEAR(_pObj, _pCtx) do {} while (0)
     66# define CR_STATE_SHAREDOBJ_USAGE_IS_USED(_pObj) (GL_FALSE)
    6267#endif
    6368
     
    237242DECLEXPORT(int32_t) crStateLoadContext(CRContext *pContext, CRHashTable * pCtxTable, PFNCRSTATE_CONTEXT_GET pfnCtxGet, PSSMHANDLE pSSM);
    238243DECLEXPORT(void)    crStateFreeShared(CRContext *pContext, CRSharedState *s);
    239 #endif
    240 
     244DECLEXPORT(void) crStateFreeShared(CRContext *pContext, CRSharedState *s);
     245#endif
     246
     247DECLEXPORT(void) crStateSetTextureUsed(GLuint texture, GLboolean used);
     248DECLEXPORT(void) crStateDeleteTextureCallback(void *texObj);
    241249
    242250   /* XXX move these! */
  • trunk/src/VBox/GuestHost/OpenGL/include/cr_pack.h

    r39265 r41109  
    7373    int swapping;
    7474    CRPackBuffer *currentBuffer;
     75#ifdef CHROMIUM_THREADSAFE
    7576    CRmutex mutex;
     77#endif
    7678    char *file;  /**< for debugging only */
    7779    int line;    /**< for debugging only */
     
    149151#define CR_LOCK_PACKER_CONTEXT(PC) crLockMutex(&((PC)->mutex))
    150152#define CR_UNLOCK_PACKER_CONTEXT(PC) crUnlockMutex(&((PC)->mutex))
    151 #else
     153#elif !defined IN_RING0
    152154extern DLLDATA(CRPackContext) cr_packer_globals;
    153155#define CR_GET_PACKER_CONTEXT(C) CRPackContext *C = &cr_packer_globals
  • trunk/src/VBox/GuestHost/OpenGL/packer/pack_buffer.c

    r34358 r41109  
    1010#include "cr_error.h"
    1111#include "cr_protocol.h"
     12#ifndef IN_RING0
    1213#include "cr_unpack.h"
    13 
    14 
     14#endif
     15
     16#ifndef IN_RING0
    1517void crWriteUnalignedDouble( void *buffer, double d )
    1618{
     
    3537        return d;
    3638}
    37 
     39#endif
    3840/*
    3941 * We need the packer to run as efficiently as possible.  To avoid one
     
    7274}
    7375
     76#ifndef IN_RING0
    7477/* This is useful for debugging packer problems */
    7578void crPackSetBufferDEBUG( const char *file, int line,
     
    8285        pc->line = line;
    8386}
    84 
     87#endif
    8588
    8689/*
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_init.c

    r41057 r41109  
    5252 * Callback used for crFreeHashtable().
    5353 */
    54 static void
    55 DeleteTextureCallback(void *texObj)
     54DECLEXPORT(void)
     55crStateDeleteTextureCallback(void *texObj)
    5656{
    5757#ifndef IN_GUEST
     
    7474    CR_STATE_SHAREDOBJ_USAGE_CLEAR(pObj, pData->pCtx);
    7575    if (!CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj))
    76         crHashtableDelete(pData->s->textureTable, key, DeleteTextureCallback);
     76        crHashtableDelete(pData->s->textureTable, key, crStateDeleteTextureCallback);
    7777}
    7878
     
    116116            gSharedState = NULL;
    117117        }
    118         crFreeHashtable(s->textureTable, DeleteTextureCallback);
     118        crFreeHashtable(s->textureTable, crStateDeleteTextureCallback);
    119119        crFreeHashtable(s->dlistTable, crFree); /* call crFree for each entry */
    120120        crFreeHashtable(s->buffersTable, crStateFreeBufferObject);
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_texture.c

    r41057 r41109  
    688688}
    689689
     690static void crStateCleanupTextureRefs(CRContext *g, CRTextureObj *tObj)
     691{
     692    CRTextureState *t = &(g->texture);
     693    GLuint u;
     694
     695    /*
     696     ** reset back to the base texture.
     697     */
     698    for (u = 0; u < g->limits.maxTextureUnits; u++)
     699    {
     700        if (tObj == t->unit[u].currentTexture1D)
     701        {
     702            t->unit[u].currentTexture1D = &(t->base1D);
     703        }
     704        if (tObj == t->unit[u].currentTexture2D)
     705        {
     706            t->unit[u].currentTexture2D = &(t->base2D);
     707        }
     708#ifdef CR_OPENGL_VERSION_1_2
     709        if (tObj == t->unit[u].currentTexture3D)
     710        {
     711            t->unit[u].currentTexture3D = &(t->base3D);
     712        }
     713#endif
     714#ifdef CR_ARB_texture_cube_map
     715        if (tObj == t->unit[u].currentTextureCubeMap)
     716        {
     717            t->unit[u].currentTextureCubeMap = &(t->baseCubeMap);
     718        }
     719#endif
     720#ifdef CR_NV_texture_rectangle
     721        if (tObj == t->unit[u].currentTextureRect)
     722        {
     723            t->unit[u].currentTextureRect = &(t->baseRect);
     724        }
     725#endif
     726
     727#ifdef CR_EXT_framebuffer_object
     728        crStateTextureCheckFBOAPs(GL_DRAW_FRAMEBUFFER, tObj->id);
     729        crStateTextureCheckFBOAPs(GL_READ_FRAMEBUFFER, tObj->id);
     730#endif
     731    }
     732
     733}
     734
    690735void STATE_APIENTRY crStateDeleteTextures(GLsizei n, const GLuint *textures)
    691736{
     
    719764        if (name && tObj)
    720765        {
    721             GLuint u;
    722             /* remove from hashtable */
    723             crHashtableDelete(g->shared->textureTable, name, NULL);
    724 
    725             /* if the currentTexture is deleted,
    726              ** reset back to the base texture.
    727              */
    728             for (u = 0; u < g->limits.maxTextureUnits; u++)
    729             {
    730                 if (tObj == t->unit[u].currentTexture1D)
    731                 {
    732                     t->unit[u].currentTexture1D = &(t->base1D);
    733                 }
    734                 if (tObj == t->unit[u].currentTexture2D)
    735                 {
    736                     t->unit[u].currentTexture2D = &(t->base2D);
    737                 }
    738 #ifdef CR_OPENGL_VERSION_1_2
    739                 if (tObj == t->unit[u].currentTexture3D)
    740                 {
    741                     t->unit[u].currentTexture3D = &(t->base3D);
    742                 }
    743 #endif
    744 #ifdef CR_ARB_texture_cube_map
    745                 if (tObj == t->unit[u].currentTextureCubeMap)
    746                 {
    747                     t->unit[u].currentTextureCubeMap = &(t->baseCubeMap);
    748                 }
    749 #endif
    750 #ifdef CR_NV_texture_rectangle
    751                 if (tObj == t->unit[u].currentTextureRect)
    752                 {
    753                     t->unit[u].currentTextureRect = &(t->baseRect);
    754                 }
    755 #endif
    756             }
    757 
    758 #ifdef CR_EXT_framebuffer_object
    759             crStateTextureCheckFBOAPs(GL_DRAW_FRAMEBUFFER, name);
    760             crStateTextureCheckFBOAPs(GL_READ_FRAMEBUFFER, name);
    761 #endif
    762             crStateDeleteTextureObject(tObj);
     766            crStateCleanupTextureRefs(g, tObj);
     767
     768            crHashtableDelete(g->shared->textureTable, name, crStateDeleteTextureObject);
    763769        }
    764770    }
     
    834840    if (g->transform.matrixMode == GL_TEXTURE) {
    835841        crStateMatrixMode(GL_TEXTURE);
     842    }
     843}
     844
     845DECLEXPORT(void) crStateSetTextureUsed(GLuint texture, GLboolean used)
     846{
     847    CRContext *g = GetCurrentContext();
     848    CRTextureObj *tobj;
     849
     850    if (!texture)
     851    {
     852        crWarning("crStateSetTextureUsed: null texture name specified!");
     853        return;
     854    }
     855
     856    GET_TOBJ(tobj, g, texture);
     857    if (!tobj)
     858    {
     859        crWarning("crStateSetTextureUsed: failed to fined a HW name for texture(%d)!", texture);
     860        return;
     861    }
     862
     863    if (used)
     864        CR_STATE_SHAREDOBJ_USAGE_SET(tobj, g);
     865    else
     866    {
     867        CRStateBits *sb = GetCurrentBits();
     868        CRTextureBits *tb = &(sb->texture);
     869        CRTextureState *t = &(g->texture);
     870
     871        CR_STATE_SHAREDOBJ_USAGE_CLEAR(tobj, g);
     872
     873        crStateCleanupTextureRefs(g, tobj);
     874
     875        if (!CR_STATE_SHAREDOBJ_USAGE_IS_USED(tobj))
     876            crHashtableDelete(g->shared->textureTable, texture, crStateDeleteTextureCallback);
     877
     878        DIRTY(tb->dirty, g->neg_bitid);
     879        DIRTY(tb->current[t->curTextureUnit], g->neg_bitid);
    836880    }
    837881}
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