VirtualBox

Ignore:
Timestamp:
Aug 20, 2010 9:40:40 AM (14 years ago)
Author:
vboxsync
Message:

crOpenGL: resource sharing between contexts

Location:
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/get_components.py

    r20916 r31808  
    104104        'GL_BUFFER_ACCESS_ARB': (1, 'CR_ARB_vertex_buffer_object'),
    105105        'GL_BUFFER_MAPPED_ARB': (1, 'CR_ARB_vertex_buffer_object'),
    106         'GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING': (4, 'CR_ARB_vertex_buffer_object'),
     106        'GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB': (1, 'CR_ARB_vertex_buffer_object'),
    107107        'GL_QUERY_COUNTER_BITS_ARB': (1, 'CR_ARB_occlusion_query'),
    108108        'GL_QUERY_RESULT_AVAILABLE_ARB': (1, 'CR_ARB_occlusion_query'),
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h

    r27889 r31808  
    8787GLint crServerSPUWindowID(GLint serverWindow);
    8888
    89 GLuint crServerTranslateTextureID(GLuint id);
    9089GLuint crServerTranslateProgramID(GLuint id);
    9190
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_bufferobject.c

    r22155 r31808  
    5959        }
    6060}
     61
     62void SERVER_DISPATCH_APIENTRY
     63crServerDispatchBindBufferARB(GLenum target, GLuint buffer)
     64{
     65    crStateBindBufferARB(target, buffer);
     66    cr_server.head_spu->dispatch_table.BindBufferARB(target, crStateGetBufferHWID(buffer));
     67}
     68
     69GLboolean SERVER_DISPATCH_APIENTRY
     70crServerDispatchIsBufferARB(GLuint buffer)
     71{
     72    GLboolean retval;
     73    retval = cr_server.head_spu->dispatch_table.IsBufferARB(crStateGetBufferHWID(buffer));
     74    crServerReturnValue( &retval, sizeof(retval) );
     75    return retval; /* WILL PROBABLY BE IGNORED */
     76}
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_framebuffer.c

    r28800 r31808  
    4646void SERVER_DISPATCH_APIENTRY crServerDispatchFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
    4747{
    48     if (texture)
    49     {
    50         texture = crServerTranslateTextureID(texture);
    51     }
    52 
    5348    crStateFramebufferTexture1DEXT(target, attachment, textarget, texture, level);
    54     cr_server.head_spu->dispatch_table.FramebufferTexture1DEXT(target, attachment, textarget, texture, level);
     49    cr_server.head_spu->dispatch_table.FramebufferTexture1DEXT(target, attachment, textarget, crStateGetTextureHWID(texture), level);
    5550}
    5651
    5752void SERVER_DISPATCH_APIENTRY crServerDispatchFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
    5853{
    59     if (texture)
    60     {
    61         texture = crServerTranslateTextureID(texture);
    62     }
    63 
    6454    crStateFramebufferTexture2DEXT(target, attachment, textarget, texture, level);
    65     cr_server.head_spu->dispatch_table.FramebufferTexture2DEXT(target, attachment, textarget, texture, level);
     55    cr_server.head_spu->dispatch_table.FramebufferTexture2DEXT(target, attachment, textarget, crStateGetTextureHWID(texture), level);
    6656}
    6757
    6858void SERVER_DISPATCH_APIENTRY crServerDispatchFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset)
    6959{
    70     if (texture)
    71     {
    72         texture = crServerTranslateTextureID(texture);
    73     }
    74 
    7560    crStateFramebufferTexture3DEXT(target, attachment, textarget, texture, level, zoffset);
    76     cr_server.head_spu->dispatch_table.FramebufferTexture3DEXT(target, attachment, textarget, texture, level, zoffset);
     61    cr_server.head_spu->dispatch_table.FramebufferTexture3DEXT(target, attachment, textarget, crStateGetTextureHWID(texture), level, zoffset);
    7762}
    7863
     
    121106        crStateGetFramebufferAttachmentParameterivEXT(target, attachment, pname, local_params);
    122107
    123     if (GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT==pname)
    124     {
    125         GLint type;
    126         crStateGetFramebufferAttachmentParameterivEXT(target, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT, &type);
    127         if (GL_TEXTURE==type)
    128         {
    129             /*todo, add reverse of crServerTranslateTextureID*/
    130             if (!cr_server.sharedTextureObjects && local_params[0])
    131             {
    132                 int client = cr_server.curClient->number;
    133                 local_params[0] = local_params[0] - client * 100000;
    134             }
    135         }
    136     }
    137 
    138108        crServerReturnValue(&(local_params[0]), 1*sizeof(GLint));
    139109}
     110
     111GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsFramebufferEXT( GLuint framebuffer )
     112{
     113    GLboolean retval;
     114    retval = cr_server.head_spu->dispatch_table.IsFramebufferEXT(crStateGetFramebufferHWID(framebuffer));
     115    crServerReturnValue( &retval, sizeof(retval) );
     116    return retval; /* WILL PROBABLY BE IGNORED */
     117}
     118
     119GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsRenderbufferEXT( GLuint renderbuffer )
     120{
     121    GLboolean retval;
     122    retval = cr_server.head_spu->dispatch_table.IsRenderbufferEXT(crStateGetRenderbufferHWID(renderbuffer));
     123    crServerReturnValue( &retval, sizeof(retval) );
     124    return retval; /* WILL PROBABLY BE IGNORED */
     125}
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_gentextures.c

    r25154 r31808  
    1414void SERVER_DISPATCH_APIENTRY crServerDispatchGenTextures( GLsizei n, GLuint *textures )
    1515{
    16     GLsizei i;
    17     GLuint *local_textures = (GLuint *) crAlloc( n*sizeof( *local_textures) );
     16    GLuint *local_textures = (GLuint *) crAlloc(n*sizeof(*local_textures));
    1817    (void) textures;
    19     cr_server.head_spu->dispatch_table.GenTextures( n, local_textures );
    2018
    21     /* This is somewhat hacky.
    22      * We have to make sure we're going to generate unique texture IDs.
    23      * That wasn't the case before snapshot loading, because we could just rely on host video drivers.
    24      * Now we could have a set of loaded texture IDs which aren't already reserved in the host driver.
    25      * Note: It seems, that it's easy to reserve ATI/NVidia IDs, by simply calling glGenTextures
    26      * with n==number of loaded textures. But it's really implementation dependant. So can't rely that it'll not change.
    27      */
    28     for (i=0; i<n; ++i)
    29     {
    30         /* translate the ID as it'd be done in glBindTexture call */
    31         GLuint tID = crServerTranslateTextureID(local_textures[i]);
    32         /* check if we have a texture with same ID loaded from snapshot */
    33         while (crStateIsTexture(tID))
    34         {
    35             /* request new ID */
    36             cr_server.head_spu->dispatch_table.GenTextures(1, &tID);
    37             local_textures[i] = tID;
    38             tID = crServerTranslateTextureID(tID);
    39         }
    40     }
     19    crStateGenTextures(n, local_textures);
    4120
    42     crServerReturnValue( local_textures, n*sizeof( *local_textures ) );
     21    crServerReturnValue(local_textures, n*sizeof(*local_textures));
    4322    crFree( local_textures );
    4423}
    45 
    4624
    4725void SERVER_DISPATCH_APIENTRY crServerDispatchGenProgramsNV( GLsizei n, GLuint * ids )
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_get.py

    r22155 r31808  
    100100];
    101101
     102convert_bufferid = [
     103    'GetVertexAttribdvARB',
     104    'GetVertexAttribdvNV',
     105    'GetVertexAttribfvARB',
     106    'GetVertexAttribfvNV',
     107    'GetVertexAttribivARB',
     108    'GetVertexAttribivNV'
     109];
     110
    102111from get_components import *;
    103112
     
    125134
    126135        print '\tcr_server.head_spu->dispatch_table.%s( %s );' % ( func_name, apiutil.MakeCallString(params) )
     136
     137        if func_name in convert_bufferid:
     138            print '\tif (pname==GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB){'
     139            print '\t\tlocal_params[0]=(%s)crStateBufferHWIDtoID((GLint)local_params[0]);' % (local_argtype);
     140            print '\t}'
     141
    127142        if func_name in no_pnames:
    128143            print '\tcrServerReturnValue( &(%s[0]), %d*sizeof(%s) );' % (local_argname, max_components[func_name], local_argtype );
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_glsl.c

    r28800 r31808  
    104104}
    105105
     106GLint SERVER_DISPATCH_APIENTRY crServerDispatchGetAttribLocation( GLuint program, const char * name )
     107{
     108    GLint retval;
     109    retval = cr_server.head_spu->dispatch_table.GetAttribLocation(crStateGetProgramHWID(program), name );
     110    crServerReturnValue( &retval, sizeof(retval) );
     111    return retval; /* WILL PROBABLY BE IGNORED */
     112}
     113
     114GLhandleARB SERVER_DISPATCH_APIENTRY crServerDispatchGetHandleARB( GLenum pname )
     115{
     116    GLhandleARB retval;
     117    retval = cr_server.head_spu->dispatch_table.GetHandleARB(pname);
     118    if (pname==GL_PROGRAM_OBJECT_ARB)
     119    {
     120        retval = crStateGLSLProgramHWIDtoID(retval);
     121    }
     122    crServerReturnValue( &retval, sizeof(retval) );
     123    return retval; /* WILL PROBABLY BE IGNORED */
     124}
     125
     126GLint SERVER_DISPATCH_APIENTRY crServerDispatchGetUniformLocation(GLuint program, const char * name)
     127{
     128    GLint retval;
     129    retval = cr_server.head_spu->dispatch_table.GetUniformLocation(crStateGetProgramHWID(program), name);
     130    crServerReturnValue( &retval, sizeof(retval) );
     131    return retval; /* WILL PROBABLY BE IGNORED */
     132}
     133
    106134#endif /* #ifdef CR_OPENGL_VERSION_2_0 */
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_lists.c

    r27889 r31808  
    4141{
    4242    if (!cr_server.sharedDisplayLists) {
    43         int client = cr_server.curClient->number;
    44         return id + client * 100000;
    45     }
    46     return id;
    47 }
    48 
    49 
    50 GLuint crServerTranslateTextureID( GLuint id )
    51 {
    52     if (!cr_server.sharedTextureObjects && id) {
    5343        int client = cr_server.curClient->number;
    5444        return id + client * 100000;
     
    248238void SERVER_DISPATCH_APIENTRY crServerDispatchBindTexture( GLenum target, GLuint texture )
    249239{
    250     texture = crServerTranslateTextureID( texture );
    251240    crStateBindTexture( target, texture );
    252     cr_server.head_spu->dispatch_table.BindTexture( target, texture );
    253 }
    254 
     241    cr_server.head_spu->dispatch_table.BindTexture(target, crStateGetTextureHWID(texture));
     242}
    255243
    256244void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteTextures( GLsizei n, const GLuint *textures)
    257245{
    258     if (!cr_server.sharedTextureObjects) {
    259         GLuint *newTextures = (GLuint *) crAlloc(n * sizeof(GLuint));
    260         GLint i;
    261         if (!newTextures) {
    262             crError("crServerDispatchDeleteTextures: out of memory");
    263             return;
    264         }
    265         for (i = 0; i < n; i++) {
    266             newTextures[i] = crServerTranslateTextureID( textures[i] );
    267         }
    268         crStateDeleteTextures( n, newTextures );
    269         cr_server.head_spu->dispatch_table.DeleteTextures( n, newTextures );
    270         crFree(newTextures);
    271     }
    272     else {
    273         crStateDeleteTextures( n, textures );
    274         cr_server.head_spu->dispatch_table.DeleteTextures( n, textures );
    275     }
     246    GLuint *newTextures = (GLuint *) crAlloc(n * sizeof(GLuint));
     247    GLint i;
     248
     249    if (!newTextures)
     250    {
     251        crError("crServerDispatchDeleteTextures: out of memory");
     252        return;
     253    }
     254
     255    for (i = 0; i < n; i++)
     256    {
     257        newTextures[i] = crStateGetTextureHWID(textures[i]);
     258    }
     259
     260    crStateDeleteTextures(n, textures);
     261    cr_server.head_spu->dispatch_table.DeleteTextures(n, newTextures);
     262    crFree(newTextures);
    276263}
    277264
    278265void SERVER_DISPATCH_APIENTRY crServerDispatchPrioritizeTextures( GLsizei n, const GLuint * textures, const GLclampf * priorities )
    279266{
    280     if (!cr_server.sharedTextureObjects)
     267    GLuint *newTextures = (GLuint *) crAlloc(n * sizeof(GLuint));
     268    GLint i;
     269
     270    if (!newTextures)
    281271    {
    282         GLuint *newTextures = (GLuint *) crAlloc(n * sizeof(GLuint));
    283         GLint i;
    284         if (!newTextures) {
    285             crError("crServerDispatchDeleteTextures: out of memory");
    286             return;
    287         }
    288         for (i = 0; i < n; i++) {
    289             newTextures[i] = crServerTranslateTextureID( textures[i] );
    290         }
    291         crStatePrioritizeTextures(n, newTextures, priorities);
    292         cr_server.head_spu->dispatch_table.PrioritizeTextures(n, newTextures, priorities);
    293         crFree(newTextures);
    294     }
    295     else
     272        crError("crServerDispatchDeleteTextures: out of memory");
     273        return;
     274    }
     275
     276    for (i = 0; i < n; i++)
    296277    {
    297         crStatePrioritizeTextures(n, textures, priorities);
    298         cr_server.head_spu->dispatch_table.PrioritizeTextures(n, textures, priorities);
    299     }
     278        newTextures[i] = crStateGetTextureHWID(textures[i]);
     279    }
     280
     281    crStatePrioritizeTextures(n, textures, priorities);
     282    cr_server.head_spu->dispatch_table.PrioritizeTextures(n, newTextures, priorities);
     283    crFree(newTextures);
    300284}
    301285
     
    320304{
    321305    GLboolean retval;
    322     texture = crServerTranslateTextureID( texture );
    323     retval = cr_server.head_spu->dispatch_table.IsTexture( texture );
     306    retval = cr_server.head_spu->dispatch_table.IsTexture(crStateGetTextureHWID(texture));
    324307    crServerReturnValue( &retval, sizeof(retval) );
    325308    return retval; /* WILL PROBABLY BE IGNORED */
     
    330313{
    331314    GLboolean retval;
    332     program = crServerTranslateTextureID(program);
     315    program = crServerTranslateProgramID(program);
    333316    retval = cr_server.head_spu->dispatch_table.IsProgramARB( program );
    334317    crServerReturnValue( &retval, sizeof(retval) );
     
    349332        GLuint *textures2 = (GLuint *) crAlloc(n * sizeof(GLuint));
    350333        for (i = 0; i < n; i++)
    351             textures2[i] = crServerTranslateTextureID(textures[i]);
     334            textures2[i] = crStateGetTextureHWID(textures[i]);
    352335        retval = cr_server.head_spu->dispatch_table.AreTexturesResident(n, textures2, res);
    353336        crFree(textures2);
    354     }
    355     else {
    356         retval = cr_server.head_spu->dispatch_table.AreTexturesResident(n, textures, res);
    357337    }
    358338    crServerReturnValue(res, n * sizeof(GLboolean));
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c

    r30440 r31808  
    793793        char psz[200];
    794794        GLint ctxID;
     795        CRContext* pContext;
    795796
    796797        rc = SSMR3GetMem(pSSM, &key, sizeof(key));
     
    808809        ctxID = crServerDispatchCreateContextEx(createInfo.pszDpyName, createInfo.visualBits, 0, key, createInfo.internalID);
    809810        CRASSERT((int64_t)ctxID == (int64_t)key);
     811
     812        pContext = (CRContext*) crHashtableSearch(cr_server.contextTable, key);
     813        CRASSERT(pContext);
     814        pContext->shared->id=-1;
    810815    }
    811816
     
    821826        CRASSERT(pContext);
    822827
    823         rc = crStateLoadContext(pContext, pSSM);
     828        rc = crStateLoadContext(pContext, cr_server.contextTable, pSSM);
    824829        AssertRCReturn(rc, rc);
    825830    }
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c

    r27889 r31808  
    216216{
    217217  switch (target) {
     218    case GL_SHARE_CONTEXT_RESOURCES_CR:
     219        crStateShareContext(value);
     220        break;
    218221    case GL_SHARED_DISPLAY_LISTS_CR:
    219222        cr_server.sharedDisplayLists = value;
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_muralfbo.c

    r28800 r31808  
    229229
    230230    /*Restore gl state*/
    231     uid = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->name;
     231    uid = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->hwid;
    232232    cr_server.head_spu->dispatch_table.BindTexture(GL_TEXTURE_2D, uid);
    233233
     
    330330    cr_server.head_spu->dispatch_table.BindTexture(GL_TEXTURE_2D, mural->idColorTex);
    331331    cr_server.head_spu->dispatch_table.GetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
    332     uid = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->name;
     332    uid = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->hwid;
    333333    cr_server.head_spu->dispatch_table.BindTexture(GL_TEXTURE_2D, uid);
    334334
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_simpleget.py

    r27889 r31808  
    6161        CRASSERT(tablesize/sizeof(%s)==1);
    6262        texid = (GLuint) *get_values;
    63         if (texid)
    64         {
    65             *get_values = (%s) (texid - cr_server.curClient->number * 100000);
    66         }
     63        *get_values = (%s) crStateTextureHWIDtoID(texid);
    6764    }
    6865    else if (GL_CURRENT_PROGRAM==pname)
     
    9390        *get_values = (%s) crStateRBOHWIDtoID(rbid);
    9491    }
    95     """ % (types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index])
     92    else if (GL_ARRAY_BUFFER_BINDING_ARB==pname
     93             || GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB==pname
     94             || GL_VERTEX_ARRAY_BUFFER_BINDING_ARB==pname
     95             || GL_NORMAL_ARRAY_BUFFER_BINDING_ARB==pname
     96             || GL_COLOR_ARRAY_BUFFER_BINDING_ARB==pname
     97             || GL_INDEX_ARRAY_BUFFER_BINDING_ARB==pname
     98             || GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB==pname
     99             || GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB==pname
     100             || GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB==pname
     101             || GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB==pname
     102             || GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB==pname)
     103    {
     104        GLuint bufid;
     105        CRASSERT(tablesize/sizeof(%s)==1);
     106        bufid = (GLuint) *get_values;
     107        *get_values = (%s) crStateBufferHWIDtoID(bufid);
     108    }
     109    """ % (types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index])
    96110    print '\tcrServerReturnValue( get_values, tablesize );'
    97111    print '\tcrFree(get_values);'
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_special

    r29856 r31808  
    235235TexImage2D
    236236TexImage3D
     237BindBufferARB
     238IsBufferARB
     239IsFramebufferEXT
     240IsRenderbufferEXT
     241GetAttribLocation
     242GetHandleARB
     243GetUniformLocation
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