Changeset 37030 in vbox for trunk/src/VBox/Additions
- Timestamp:
- May 10, 2011 1:41:47 PM (14 years ago)
- Location:
- trunk/src/VBox/Additions/common/crOpenGL
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/crOpenGL/glx.c
r35263 r37030 14 14 #include "dri_glx.h" 15 15 #include "GL/internal/glcore.h" 16 #include "cr_glstate.h" 16 17 17 18 #include <X11/Xregion.h> … … 2219 2220 } 2220 2221 2222 static 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 2234 static 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 2244 static 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 2221 2254 static GLX_Pixmap_t* stubInitGlxPixmap(GLX_Pixmap_t* pCreateInfoPixmap, Display *dpy, GLXDrawable draw, ContextInfo *pContext) 2222 2255 { … … 2355 2388 else 2356 2389 { 2390 CRPixelPackState unpackState; 2391 2357 2392 XLOCK(dpy); 2358 2393 XCopyArea(dpy, (Pixmap)draw, pGlxPixmap->hShmPixmap, pGlxPixmap->gc, … … 2361 2396 XSync(dpy, False); 2362 2397 XUNLOCK(dpy); 2398 2399 stubGetUnpackState(&unpackState); 2400 stubSetUnpackState(&defaultPacking); 2363 2401 stub.spu->dispatch_table.TexImage2D(pGlxPixmap->target, 0, pGlxPixmap->format, pGlxPixmap->w, pGlxPixmap->h, 0, 2364 2402 GL_BGRA, GL_UNSIGNED_BYTE, stub.xshmSI.shmaddr); 2403 stubSetUnpackState(&unpackState); 2365 2404 /*crDebug("Sync texture for drawable 0x%x(dmg handle 0x%x) [%i,%i,%i,%i]", 2366 2405 (unsigned int) draw, (unsigned int)pGlxPixmap->hDamage, … … 2397 2436 else 2398 2437 { 2399 GLint origUnpackRowLength;2438 CRPixelPackState unpackState; 2400 2439 2401 2440 XLOCK(dpy); … … 2406 2445 XUNLOCK(dpy); 2407 2446 2408 /* Save original value, doesn't cause sync as it's reported by state tracker*/ 2447 stubGetUnpackState(&unpackState); 2448 stubSetUnpackState(&defaultPacking); 2409 2449 if (pRect->width!=pGlxPixmap->w) 2410 2450 { 2411 stub.spu->dispatch_table.GetIntegerv(GL_UNPACK_ROW_LENGTH, &origUnpackRowLength);2412 2451 stub.spu->dispatch_table.PixelStorei(GL_UNPACK_ROW_LENGTH, pGlxPixmap->w); 2413 2452 } 2414 2453 stub.spu->dispatch_table.TexSubImage2D(pGlxPixmap->target, 0, pRect->x, pRect->y, pRect->width, pRect->height, 2415 2454 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); 2421 2456 2422 2457 /*crDebug("Region sync texture for drawable 0x%x(dmg handle 0x%x) [%i,%i,%i,%i]", … … 2503 2538 /*@todo add damage support here too*/ 2504 2539 XImage *pxim; 2540 CRPixelPackState unpackState; 2505 2541 2506 2542 XLOCK(dpy); … … 2532 2568 } 2533 2569 2570 stubGetUnpackState(&unpackState); 2571 stubSetUnpackState(&defaultPacking); 2534 2572 stub.spu->dispatch_table.TexImage2D(pGlxPixmap->target, 0, pGlxPixmap->format, pxim->width, pxim->height, 0, 2535 2573 GL_BGRA, GL_UNSIGNED_BYTE, (void*)(&(pxim->data[0]))); 2574 stubSetUnpackState(&unpackState); 2536 2575 XDestroyImage(pxim); 2537 2576 } -
trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py
r33988 r37030 18 18 #include "cr_mem.h" 19 19 #include "packspu_proto.h" 20 """ 21 22 print """ 23 GLboolean 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 } 20 48 """ 21 49 … … 71 99 if func_name in simple_funcs: 72 100 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) 91 102 || pname == GL_DRAW_BUFFER 92 103 #ifdef CR_OPENGL_VERSION_1_3 … … 106 117 ) 107 118 { 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)) 120 121 { 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) 122 130 { 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 } 125 136 } 137 crFree(localparams); 138 return; 126 139 } 127 crFree(localparams); 128 return; 129 #endif 140 else 141 #endif 142 { 143 crState%s(pname, params); 144 return; 145 } 130 146 131 147 } 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) 133 149 params.append( ("&writeback", "foo", 0) ) 134 150 print '\tif (pack_spu.swap)'
Note:
See TracChangeset
for help on using the changeset viewer.