VirtualBox

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


Ignore:
Timestamp:
May 10, 2011 1:41:47 PM (14 years ago)
Author:
vboxsync
Message:

crOpenGL: fix corrupted textures for gnome3 under ubuntu 11.04

Location:
trunk/src/VBox/Additions/common/crOpenGL
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/crOpenGL/glx.c

    r35263 r37030  
    1414#include "dri_glx.h"
    1515#include "GL/internal/glcore.h"
     16#include "cr_glstate.h"
    1617
    1718#include <X11/Xregion.h>
     
    22192220}
    22202221
     2222static const CRPixelPackState defaultPacking =
     2223{
     2224    0,          /*rowLength*/
     2225    0,          /*skipRows*/
     2226    0,          /*skipPixels*/
     2227    1,          /*alignment*/
     2228    0,          /*imageHeight*/
     2229    0,          /*skipImages*/
     2230    GL_FALSE,   /*swapBytes*/
     2231    GL_FALSE    /*lsbFirst*/
     2232};
     2233
     2234static void stubGetUnpackState(CRPixelPackState *pUnpackState)
     2235{
     2236    stub.spu->dispatch_table.GetIntegerv(GL_UNPACK_ROW_LENGTH, &pUnpackState->rowLength);
     2237    stub.spu->dispatch_table.GetIntegerv(GL_UNPACK_SKIP_ROWS, &pUnpackState->skipRows);
     2238    stub.spu->dispatch_table.GetIntegerv(GL_UNPACK_SKIP_PIXELS, &pUnpackState->skipPixels);
     2239    stub.spu->dispatch_table.GetIntegerv(GL_UNPACK_ALIGNMENT, &pUnpackState->alignment);
     2240    stub.spu->dispatch_table.GetBooleanv(GL_UNPACK_SWAP_BYTES, &pUnpackState->swapBytes);
     2241    stub.spu->dispatch_table.GetBooleanv(GL_UNPACK_LSB_FIRST, &pUnpackState->psLSBFirst);
     2242}
     2243
     2244static void stubSetUnpackState(const CRPixelPackState *pUnpackState)
     2245{
     2246    stub.spu->dispatch_table.PixelStorei(GL_UNPACK_ROW_LENGTH, pUnpackState->rowLength);
     2247    stub.spu->dispatch_table.PixelStorei(GL_UNPACK_SKIP_ROWS, pUnpackState->skipRows);
     2248    stub.spu->dispatch_table.PixelStorei(GL_UNPACK_SKIP_PIXELS, pUnpackState->skipPixels);
     2249    stub.spu->dispatch_table.PixelStorei(GL_UNPACK_ALIGNMENT, pUnpackState->alignment);
     2250    stub.spu->dispatch_table.PixelStorei(GL_UNPACK_SWAP_BYTES, pUnpackState->swapBytes);
     2251    stub.spu->dispatch_table.PixelStorei(GL_UNPACK_LSB_FIRST, pUnpackState->psLSBFirst);
     2252}
     2253
    22212254static GLX_Pixmap_t* stubInitGlxPixmap(GLX_Pixmap_t* pCreateInfoPixmap, Display *dpy, GLXDrawable draw, ContextInfo *pContext)
    22222255{
     
    23552388    else
    23562389    {
     2390        CRPixelPackState unpackState;
     2391
    23572392        XLOCK(dpy);
    23582393        XCopyArea(dpy, (Pixmap)draw, pGlxPixmap->hShmPixmap, pGlxPixmap->gc,
     
    23612396        XSync(dpy, False);
    23622397        XUNLOCK(dpy);
     2398       
     2399        stubGetUnpackState(&unpackState);
     2400        stubSetUnpackState(&defaultPacking);
    23632401        stub.spu->dispatch_table.TexImage2D(pGlxPixmap->target, 0, pGlxPixmap->format, pGlxPixmap->w, pGlxPixmap->h, 0,
    23642402                                            GL_BGRA, GL_UNSIGNED_BYTE, stub.xshmSI.shmaddr);
     2403        stubSetUnpackState(&unpackState);
    23652404        /*crDebug("Sync texture for drawable 0x%x(dmg handle 0x%x) [%i,%i,%i,%i]",
    23662405                  (unsigned int) draw, (unsigned int)pGlxPixmap->hDamage,
     
    23972436    else
    23982437    {
    2399         GLint origUnpackRowLength;
     2438        CRPixelPackState unpackState;
    24002439
    24012440        XLOCK(dpy);
     
    24062445        XUNLOCK(dpy);
    24072446
    2408         /* Save original value, doesn't cause sync as it's reported by state tracker*/
     2447        stubGetUnpackState(&unpackState);
     2448        stubSetUnpackState(&defaultPacking);
    24092449        if (pRect->width!=pGlxPixmap->w)
    24102450        {
    2411             stub.spu->dispatch_table.GetIntegerv(GL_UNPACK_ROW_LENGTH, &origUnpackRowLength);
    24122451            stub.spu->dispatch_table.PixelStorei(GL_UNPACK_ROW_LENGTH, pGlxPixmap->w);
    24132452        }
    24142453        stub.spu->dispatch_table.TexSubImage2D(pGlxPixmap->target, 0, pRect->x, pRect->y, pRect->width, pRect->height,
    24152454                                               GL_BGRA, GL_UNSIGNED_BYTE, stub.xshmSI.shmaddr);
    2416         if (pRect->width!=pGlxPixmap->w)
    2417         {
    2418             /* Restore original value*/
    2419             stub.spu->dispatch_table.PixelStorei(GL_UNPACK_ROW_LENGTH, origUnpackRowLength);
    2420         }
     2455        stubSetUnpackState(&unpackState);
    24212456
    24222457        /*crDebug("Region sync texture for drawable 0x%x(dmg handle 0x%x) [%i,%i,%i,%i]",
     
    25032538        /*@todo add damage support here too*/
    25042539        XImage *pxim;
     2540        CRPixelPackState unpackState;
    25052541
    25062542        XLOCK(dpy);
     
    25322568        }
    25332569
     2570        stubGetUnpackState(&unpackState);
     2571        stubSetUnpackState(&defaultPacking);
    25342572        stub.spu->dispatch_table.TexImage2D(pGlxPixmap->target, 0, pGlxPixmap->format, pxim->width, pxim->height, 0,
    25352573                                            GL_BGRA, GL_UNSIGNED_BYTE, (void*)(&(pxim->data[0])));
     2574        stubSetUnpackState(&unpackState);
    25362575        XDestroyImage(pxim);
    25372576    }
  • trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py

    r33988 r37030  
    1818#include "cr_mem.h"
    1919#include "packspu_proto.h"
     20"""
     21
     22print """
     23GLboolean crPackIsPixelStoreParm(GLenum pname)
     24{
     25    if (pname == GL_UNPACK_ALIGNMENT
     26        || pname == GL_UNPACK_ROW_LENGTH
     27        || pname == GL_UNPACK_SKIP_PIXELS
     28        || pname == GL_UNPACK_LSB_FIRST
     29        || pname == GL_UNPACK_SWAP_BYTES
     30#ifdef CR_OPENGL_VERSION_1_2
     31        || pname == GL_UNPACK_IMAGE_HEIGHT
     32#endif
     33        || pname == GL_UNPACK_SKIP_ROWS
     34        || pname == GL_PACK_ALIGNMENT
     35        || pname == GL_PACK_ROW_LENGTH
     36        || pname == GL_PACK_SKIP_PIXELS
     37        || pname == GL_PACK_LSB_FIRST
     38        || pname == GL_PACK_SWAP_BYTES
     39#ifdef CR_OPENGL_VERSION_1_2
     40        || pname == GL_PACK_IMAGE_HEIGHT
     41#endif
     42        || pname == GL_PACK_SKIP_ROWS)
     43    {
     44        return GL_TRUE;
     45    }
     46    return GL_FALSE;
     47}
    2048"""
    2149
     
    7199        if func_name in simple_funcs:
    72100            print """
    73     if (pname == GL_UNPACK_ALIGNMENT
    74         || pname == GL_UNPACK_ROW_LENGTH
    75         || pname == GL_UNPACK_SKIP_PIXELS
    76         || pname == GL_UNPACK_LSB_FIRST
    77         || pname == GL_UNPACK_SWAP_BYTES
    78 #ifdef CR_OPENGL_VERSION_1_2
    79         || pname == GL_UNPACK_IMAGE_HEIGHT
    80 #endif
    81         || pname == GL_UNPACK_SKIP_ROWS
    82         || pname == GL_PACK_ALIGNMENT
    83         || pname == GL_PACK_ROW_LENGTH
    84         || pname == GL_PACK_SKIP_PIXELS
    85         || pname == GL_PACK_LSB_FIRST
    86         || pname == GL_PACK_SWAP_BYTES
    87 #ifdef CR_OPENGL_VERSION_1_2
    88         || pname == GL_PACK_IMAGE_HEIGHT
    89 #endif
    90         || pname == GL_PACK_SKIP_ROWS
     101    if (crPackIsPixelStoreParm(pname)
    91102        || pname == GL_DRAW_BUFFER
    92103#ifdef CR_OPENGL_VERSION_1_3
     
    106117        )
    107118        {
    108 #ifndef DEBUG
    109             crState%s( pname, params );
    110             return;
    111 #else
    112             %s localparams;
    113             localparams = (%s) crAlloc(__numValues(pname) * sizeof(*localparams));
    114             crState%s(pname, localparams);
    115             crPack%s(%s, &writeback);
    116             packspuFlush( (void *) thread );
    117             while (writeback)
    118                 crNetRecv();
    119             for (i=0; i<__numValues(pname); ++i)
     119#ifdef DEBUG
     120            if (!crPackIsPixelStoreParm(pname))
    120121            {
    121                 if (localparams[i] != params[i])
     122                %s localparams;
     123                localparams = (%s) crAlloc(__numValues(pname) * sizeof(*localparams));
     124                crState%s(pname, localparams);
     125                crPack%s(%s, &writeback);
     126                packspuFlush( (void *) thread );
     127                while (writeback)
     128                    crNetRecv();
     129                for (i=0; i<__numValues(pname); ++i)
    122130                {
    123                     crWarning("Incorrect local state in %s for %%x param %%i", pname, i);
    124                     crWarning("Expected %%i but got %%i", (int)localparams[i], (int)params[i]);
     131                    if (localparams[i] != params[i])
     132                    {
     133                        crWarning("Incorrect local state in %s for %%x param %%i", pname, i);
     134                        crWarning("Expected %%i but got %%i", (int)localparams[i], (int)params[i]);
     135                    }
    125136                }
     137                crFree(localparams);
     138                return;
    126139            }
    127             crFree(localparams);
    128             return;
    129 #endif
     140            else
     141#endif
     142            {
     143                crState%s(pname, params);
     144                return;
     145            }
    130146           
    131147        }
    132             """ % (func_name, params[-1][1], params[-1][1], func_name, func_name, apiutil.MakeCallString(params), func_name)
     148            """ % (params[-1][1], params[-1][1], func_name, func_name, apiutil.MakeCallString(params), func_name, func_name)
    133149        params.append( ("&writeback", "foo", 0) )
    134150        print '\tif (pack_spu.swap)'
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