Changeset 37613 in vbox for trunk/src/VBox/GuestHost/OpenGL
- Timestamp:
- Jun 23, 2011 12:42:08 PM (13 years ago)
- Location:
- trunk/src/VBox/GuestHost/OpenGL
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/include/cr_glstate.h
r35346 r37613 169 169 #endif 170 170 171 /*@todo add back buffer, depth and fbos and move out of here*/172 GLvoid *pImage; /*stored front buffer image*/173 174 171 /** For buffering vertices for selection/feedback */ 175 172 /*@{*/ -
trunk/src/VBox/GuestHost/OpenGL/include/cr_server.h
r36845 r37613 27 27 #endif 28 28 29 #define SHCROGL_SSM_VERSION 2 629 #define SHCROGL_SSM_VERSION 27 30 30 31 31 #define CR_MAX_WINDOWS 100 -
trunk/src/VBox/GuestHost/OpenGL/include/state/cr_buffer.h
r15532 r37613 75 75 GLenum blendEquation; 76 76 #endif 77 78 GLint width, height; 79 GLint storedWidth, storedHeight; 80 GLvoid *pFrontImg; 81 GLvoid *pBackImg; 77 82 } CRBufferState; 78 83 -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_buffer.c
r33595 r37613 16 16 CRBufferBits *bb = &(sb->buffer); 17 17 GLcolorf zero_colorf = {0.0f, 0.0f, 0.0f, 0.0f}; 18 19 b->width = 640; 20 b->height = 480; 21 b->storedWidth = 0; 22 b->storedHeight = 0; 23 b->pFrontImg = NULL; 24 b->pBackImg = NULL; 18 25 19 26 b->depthTest = GL_FALSE; -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_diff.c
r29205 r37613 8 8 #include "cr_error.h" 9 9 #include "cr_mem.h" 10 #include "cr_pixeldata.h" 10 11 11 12 void crStateDiffContext( CRContext *from, CRContext *to ) … … 123 124 void crStateApplyFBImage(CRContext *to) 124 125 { 125 if (to-> pImage)126 if (to->buffer.pFrontImg || to->buffer.pBackImg) 126 127 { 127 CR ViewportState *pVP = &to->viewport;128 CRBufferState *pBuf = &to->buffer; 128 129 CRPixelPackState unpack = to->client.unpack; 129 130 … … 137 138 diff_api.PixelStorei(GL_UNPACK_LSB_FIRST, 0); 138 139 139 diff_api.DrawBuffer(GL_FRONT); 140 diff_api.WindowPos2iARB(0, 0); 141 diff_api.DrawPixels(pVP->viewportW, pVP->viewportH, GL_RGBA, GL_UNSIGNED_BYTE, to->pImage); 140 if (to->framebufferobject.drawFB) 141 { 142 diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, 0); 143 } 144 145 if (to->bufferobject.unpackBuffer->hwid>0) 146 { 147 diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0); 148 } 149 150 diff_api.Disable(GL_ALPHA_TEST); 151 diff_api.Disable(GL_SCISSOR_TEST); 152 diff_api.Disable(GL_BLEND); 153 diff_api.Disable(GL_COLOR_LOGIC_OP); 154 155 if (pBuf->pFrontImg) 156 { 157 diff_api.DrawBuffer(GL_FRONT); 158 diff_api.WindowPos2iARB(0, 0); 159 diff_api.DrawPixels(pBuf->storedWidth, pBuf->storedHeight, GL_RGBA, GL_UNSIGNED_BYTE, pBuf->pFrontImg); 160 crDebug("Applied %ix%i fb image", pBuf->storedWidth, pBuf->storedHeight); 161 crFree(pBuf->pFrontImg); 162 pBuf->pFrontImg = NULL; 163 } 164 165 if (pBuf->pBackImg) 166 { 167 diff_api.DrawBuffer(GL_BACK); 168 diff_api.WindowPos2iARB(0, 0); 169 diff_api.DrawPixels(pBuf->storedWidth, pBuf->storedHeight, GL_RGBA, GL_UNSIGNED_BYTE, pBuf->pBackImg); 170 crDebug("Applied %ix%i bb image", pBuf->storedWidth, pBuf->storedHeight); 171 crFree(pBuf->pBackImg); 172 pBuf->pBackImg = NULL; 173 } 142 174 143 175 diff_api.WindowPos3fvARB(to->current.rasterAttrib[VERT_ATTRIB_POS]); 176 if (to->bufferobject.unpackBuffer->hwid>0) 177 { 178 diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, to->bufferobject.unpackBuffer->hwid); 179 } 180 if (to->framebufferobject.drawFB) 181 { 182 diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, to->framebufferobject.drawFB->hwid); 183 } 144 184 diff_api.DrawBuffer(to->framebufferobject.drawFB ? 145 185 to->framebufferobject.drawFB->drawbuffer[0] : to->buffer.drawBuffer); 186 if (to->buffer.alphaTest) 187 { 188 diff_api.Enable(GL_ALPHA_TEST); 189 } 190 if (to->viewport.scissorTest) 191 { 192 diff_api.Enable(GL_SCISSOR_TEST); 193 } 194 if (to->buffer.blend) 195 { 196 diff_api.Enable(GL_BLEND); 197 } 198 if (to->buffer.logicOp) 199 { 200 diff_api.Enable(GL_COLOR_LOGIC_OP); 201 } 202 146 203 diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, unpack.skipRows); 147 204 diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, unpack.skipPixels); … … 154 211 155 212 diff_api.Finish(); 156 157 crDebug("Applied %ix%i fb image", pVP->viewportW, pVP->viewportH);158 159 crFree(to->pImage);160 to->pImage = NULL;161 213 } 162 214 } -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_init.c
r34053 r37613 156 156 int node32 = i >> 5; 157 157 int node = i & 0x1f; 158 159 ctx->pImage = NULL;160 158 161 159 ctx->id = i; … … 276 274 crStateFramebufferObjectDestroy(ctx); 277 275 crStateGLSLDestroy(ctx); 278 if (ctx->pImage) crFree(ctx->pImage); 276 if (ctx->buffer.pFrontImg) crFree(ctx->buffer.pFrontImg); 277 if (ctx->buffer.pBackImg) crFree(ctx->buffer.pBackImg); 279 278 crFree( ctx ); 280 279 } -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_snapshot.c
r34107 r37613 1011 1011 CRASSERT(pContext && pSSM); 1012 1012 1013 pContext->buffer.storedWidth = pContext->buffer.width; 1014 pContext->buffer.storedHeight = pContext->buffer.height; 1015 1013 1016 rc = SSMR3PutMem(pSSM, pContext, sizeof(*pContext)); 1014 1017 AssertRCReturn(rc, rc); … … 1283 1286 #endif 1284 1287 1285 { 1286 CRViewportState *pVP = &pContext->viewport; 1288 if (pContext->buffer.storedWidth && pContext->buffer.storedHeight) 1289 { 1290 CRBufferState *pBuf = &pContext->buffer; 1287 1291 CRPixelPackState packing = pContext->client.pack; 1288 GLint cbData = crPixelSize(GL_RGBA, GL_UNSIGNED_BYTE) * pVP->viewportH * pVP->viewportW; 1289 void *pData = crAlloc(cbData); 1292 GLint cbData; 1293 void *pData; 1294 1295 cbData = crPixelSize(GL_RGBA, GL_UNSIGNED_BYTE) * pBuf->storedWidth * pBuf->storedHeight; 1296 pData = crAlloc(cbData); 1290 1297 1291 1298 if (!pData) … … 1303 1310 diff_api.PixelStorei(GL_PACK_LSB_FIRST, 0); 1304 1311 1312 if (pContext->framebufferobject.readFB) 1313 { 1314 diff_api.BindFramebufferEXT(GL_READ_FRAMEBUFFER, 0); 1315 } 1316 if (pContext->bufferobject.packBuffer->hwid>0) 1317 { 1318 diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); 1319 } 1320 1305 1321 diff_api.ReadBuffer(GL_FRONT); 1306 diff_api.ReadPixels(0, 0, pVP->viewportW, pVP->viewportH, GL_RGBA, GL_UNSIGNED_BYTE, pData); 1307 1322 diff_api.ReadPixels(0, 0, pBuf->storedWidth, pBuf->storedHeight, GL_RGBA, GL_UNSIGNED_BYTE, pData); 1323 rc = SSMR3PutMem(pSSM, pData, cbData); 1324 AssertRCReturn(rc, rc); 1325 1326 diff_api.ReadBuffer(GL_BACK); 1327 diff_api.ReadPixels(0, 0, pBuf->storedWidth, pBuf->storedHeight, GL_RGBA, GL_UNSIGNED_BYTE, pData); 1328 rc = SSMR3PutMem(pSSM, pData, cbData); 1329 AssertRCReturn(rc, rc); 1330 1331 if (pContext->bufferobject.packBuffer->hwid>0) 1332 { 1333 diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pContext->bufferobject.packBuffer->hwid); 1334 } 1335 if (pContext->framebufferobject.readFB) 1336 { 1337 diff_api.BindFramebufferEXT(GL_READ_FRAMEBUFFER, pContext->framebufferobject.readFB->hwid); 1338 } 1308 1339 diff_api.ReadBuffer(pContext->framebufferobject.readFB ? 1309 1340 pContext->framebufferobject.readFB->readbuffer : pContext->buffer.readBuffer); 1341 1310 1342 diff_api.PixelStorei(GL_PACK_SKIP_ROWS, packing.skipRows); 1311 1343 diff_api.PixelStorei(GL_PACK_SKIP_PIXELS, packing.skipPixels); … … 1316 1348 diff_api.PixelStorei(GL_PACK_SWAP_BYTES, packing.swapBytes); 1317 1349 diff_api.PixelStorei(GL_PACK_LSB_FIRST, packing.psLSBFirst); 1318 1319 rc = SSMR3PutMem(pSSM, pData, cbData);1320 AssertRCReturn(rc, rc);1321 1350 1322 1351 crFree(pData); … … 1989 2018 1990 2019 1991 /*Restore front buffer image*/ 1992 { 1993 CRViewportState *pVP = &pContext->viewport; 1994 GLint cbData = crPixelSize(GL_RGBA, GL_UNSIGNED_BYTE) * pVP->viewportH * pVP->viewportW; 1995 void *pData = crAlloc(cbData); 1996 2020 /*Restore front/back buffer images*/ 2021 if (pContext->buffer.storedWidth && pContext->buffer.storedHeight) 2022 { 2023 CRBufferState *pBuf = &pContext->buffer; 2024 GLint cbData; 2025 void *pData; 2026 2027 cbData = crPixelSize(GL_RGBA, GL_UNSIGNED_BYTE) * pBuf->storedWidth * pBuf->storedHeight; 2028 2029 pData = crAlloc(cbData); 1997 2030 if (!pData) 1998 2031 { 1999 pContext->pImage = NULL; 2032 pBuf->pFrontImg = NULL; 2033 pBuf->pBackImg = NULL; 2000 2034 return VERR_NO_MEMORY; 2001 2035 } … … 2004 2038 AssertRCReturn(rc, rc); 2005 2039 2006 pContext->pImage = pData; 2040 pBuf->pFrontImg = pData; 2041 2042 pData = crAlloc(cbData); 2043 if (!pData) 2044 { 2045 pBuf->pBackImg = NULL; 2046 return VERR_NO_MEMORY; 2047 } 2048 2049 rc = SSMR3GetMem(pSSM, pData, cbData); 2050 AssertRCReturn(rc, rc); 2051 2052 pBuf->pBackImg = pData; 2007 2053 } 2008 2054 -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_texdiff.c
r34107 r37613 686 686 diff_api.TexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, 1); 687 687 } 688 if (tl->compressed) { 689 diff_api.CompressedTexImage1DARB(GL_TEXTURE_1D, lvl, 690 tl->internalFormat, tl->width, 691 tl->border, tl->bytes, tl->img); 692 } 693 else { 694 /* alignment must be one */ 695 diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, 0); 696 diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, 0); 697 diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, 0); 698 diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); 699 if (tl->generateMipmap) { 700 diff_api.TexParameteri(GL_TEXTURE_1D, GL_GENERATE_MIPMAP_SGIS, 1); 688 if (tl->width) 689 { 690 if (tl->compressed) { 691 diff_api.CompressedTexImage1DARB(GL_TEXTURE_1D, lvl, 692 tl->internalFormat, tl->width, 693 tl->border, tl->bytes, tl->img); 701 694 } 702 diff_api.TexImage1D(GL_TEXTURE_1D, lvl, 703 tl->internalFormat, 704 tl->width, tl->border, 705 tl->format, tl->type, tl->img); 695 else { 696 /* alignment must be one */ 697 diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, 0); 698 diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, 0); 699 diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, 0); 700 diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); 701 if (tl->generateMipmap) { 702 diff_api.TexParameteri(GL_TEXTURE_1D, GL_GENERATE_MIPMAP_SGIS, 1); 703 } 704 diff_api.TexImage1D(GL_TEXTURE_1D, lvl, 705 tl->internalFormat, 706 tl->width, tl->border, 707 tl->format, tl->type, tl->img); 708 } 706 709 } 707 710 if (!alwaysDirty) … … 729 732 } 730 733 731 if (tl->compressed) { 732 diff_api.CompressedTexImage2DARB(GL_TEXTURE_2D, lvl, 733 tl->internalFormat, tl->width, 734 tl->height, tl->border, 735 tl->bytes, tl->img); 736 } 737 else { 738 /* alignment must be one */ 739 diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, 0); 740 diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, 0); 741 diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, 0); 742 diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); 743 diff_api.TexImage2D(GL_TEXTURE_2D, lvl, 744 tl->internalFormat, 745 tl->width, tl->height, tl->border, 746 tl->format, tl->type, tl->img); 734 if (tl->width && tl->height) 735 { 736 if (tl->compressed) { 737 diff_api.CompressedTexImage2DARB(GL_TEXTURE_2D, lvl, 738 tl->internalFormat, tl->width, 739 tl->height, tl->border, 740 tl->bytes, tl->img); 741 } 742 else { 743 /* alignment must be one */ 744 diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, 0); 745 diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, 0); 746 diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, 0); 747 diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); 748 diff_api.TexImage2D(GL_TEXTURE_2D, lvl, 749 tl->internalFormat, 750 tl->width, tl->height, tl->border, 751 tl->format, tl->type, tl->img); 752 } 747 753 } 748 754 … … 771 777 diff_api.TexParameteri(GL_TEXTURE_3D, GL_GENERATE_MIPMAP_SGIS, 1); 772 778 } 773 if (tl->compressed) { 774 diff_api.CompressedTexImage3DARB(GL_TEXTURE_3D, lvl, 775 tl->internalFormat, tl->width, 776 tl->height, tl->depth, 777 tl->border, tl->bytes, tl->img); 778 } 779 else { 780 /* alignment must be one */ 781 diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, 0); 782 diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, 0); 783 diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, 0); 784 diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); 785 diff_api.TexImage3D(GL_TEXTURE_3D, lvl, 786 tl->internalFormat, 787 tl->width, tl->height, tl->depth, 788 tl->border, tl->format, 789 tl->type, tl->img); 790 } 779 780 if (tl->width && tl->height) 781 { 782 if (tl->compressed) { 783 diff_api.CompressedTexImage3DARB(GL_TEXTURE_3D, lvl, 784 tl->internalFormat, tl->width, 785 tl->height, tl->depth, 786 tl->border, tl->bytes, tl->img); 787 } 788 else { 789 /* alignment must be one */ 790 diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, 0); 791 diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, 0); 792 diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, 0); 793 diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); 794 diff_api.TexImage3D(GL_TEXTURE_3D, lvl, 795 tl->internalFormat, 796 tl->width, tl->height, tl->depth, 797 tl->border, tl->format, 798 tl->type, tl->img); 799 } 800 } 801 791 802 if (!alwaysDirty) 792 803 { … … 812 823 if (alwaysDirty || CHECKDIRTY(tl->dirty, bitID)) 813 824 { 814 if (tl->compressed) { 815 diff_api.CompressedTexImage2DARB(GL_TEXTURE_RECTANGLE_NV, lvl, 816 tl->internalFormat, tl->width, 817 tl->height, tl->border, 818 tl->bytes, tl->img); 819 } 820 else { 821 /* alignment must be one */ 822 diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, 0); 823 diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, 0); 824 diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, 0); 825 diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); 826 diff_api.TexImage2D(GL_TEXTURE_RECTANGLE_NV, lvl, 827 tl->internalFormat, 828 tl->width, tl->height, tl->border, 829 tl->format, tl->type, tl->img); 830 } 825 if (tl->width && tl->height) 826 { 827 if (tl->compressed) { 828 diff_api.CompressedTexImage2DARB(GL_TEXTURE_RECTANGLE_NV, lvl, 829 tl->internalFormat, tl->width, 830 tl->height, tl->border, 831 tl->bytes, tl->img); 832 } 833 else { 834 /* alignment must be one */ 835 diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, 0); 836 diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, 0); 837 diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, 0); 838 diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); 839 diff_api.TexImage2D(GL_TEXTURE_RECTANGLE_NV, lvl, 840 tl->internalFormat, 841 tl->width, tl->height, tl->border, 842 tl->format, tl->type, tl->img); 843 } 844 } 845 831 846 if (!alwaysDirty) 832 847 { … … 858 873 GL_GENERATE_MIPMAP_SGIS, 1); 859 874 } 860 if (tl->compressed) { 861 diff_api.CompressedTexImage2DARB(target, 862 lvl, tl->internalFormat, 863 tl->width, tl->height, 864 tl->border, tl->bytes, tl->img); 875 876 if (tl->width && tl->height) 877 { 878 if (tl->compressed) { 879 diff_api.CompressedTexImage2DARB(target, 880 lvl, tl->internalFormat, 881 tl->width, tl->height, 882 tl->border, tl->bytes, tl->img); 883 } 884 else { 885 /* alignment must be one */ 886 diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, 0); 887 diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, 0); 888 diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, 0); 889 diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); 890 diff_api.TexImage2D(target, lvl, 891 tl->internalFormat, 892 tl->width, tl->height, tl->border, 893 tl->format, tl->type, tl->img); 894 } 865 895 } 866 else { 867 /* alignment must be one */ 868 diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, 0); 869 diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, 0); 870 diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, 0); 871 diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); 872 diff_api.TexImage2D(target, lvl, 873 tl->internalFormat, 874 tl->width, tl->height, tl->border, 875 tl->format, tl->type, tl->img); 876 } 896 877 897 if (!alwaysDirty) 878 898 { -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_texture.c
r35912 r37613 56 56 /* compute max levels from max sizes */ 57 57 for (i=0, a=limits->maxTextureSize; a; i++, a=a>>1); 58 t->maxLevel = i ;58 t->maxLevel = i-1; 59 59 for (i=0, a=limits->max3DTextureSize; a; i++, a=a>>1); 60 t->max3DLevel = i ;60 t->max3DLevel = i-1; 61 61 #ifdef CR_ARB_texture_cube_map 62 62 for (i=0, a=limits->maxCubeMapTextureSize; a; i++, a=a>>1); 63 t->maxCubeMapLevel = i ;63 t->maxCubeMapLevel = i-1; 64 64 #endif 65 65 #ifdef CR_NV_texture_rectangle 66 66 for (i=0, a=limits->maxRectTextureSize; a; i++, a=a>>1); 67 t->maxRectLevel = i ;67 t->maxRectLevel = i-1; 68 68 #endif 69 69
Note:
See TracChangeset
for help on using the changeset viewer.