Changeset 16969 in vbox for trunk/src/VBox/GuestHost/OpenGL/state_tracker
- Timestamp:
- Feb 20, 2009 11:25:55 AM (16 years ago)
- Location:
- trunk/src/VBox/GuestHost/OpenGL/state_tracker
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_snapshot.c
r16551 r16969 23 23 #include "state.h" 24 24 #include "state/cr_statetypes.h" 25 #include "state/cr_texture.h" 25 26 #include "cr_mem.h" 26 27 … … 84 85 AssertRCReturn(rc, rc); 85 86 } 87 #ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE 88 /* Note, this is not a bug. 89 * Even with CR_STATE_NO_TEXTURE_IMAGE_STORE defined, it's possible that ptl->img!=NULL. 90 * For ex. we're saving snapshot right after it was loaded 91 * and some context hasn't been used by the guest application yet 92 * (pContext->texture.bResyncNeeded==GL_TRUE). 93 */ 94 else if (ptl->bytes) 95 { 96 char *pImg; 97 98 pImg = crAlloc(ptl->bytes); 99 if (!pImg) return VERR_NO_MEMORY; 100 101 diff_api.BindTexture(pTexture->target, pTexture->name); 102 diff_api.GetTexImage(pTexture->target, i, ptl->format, ptl->type, pImg); 103 104 rc = SSMR3PutMem(pSSM, pImg, ptl->bytes); 105 crFree(pImg); 106 AssertRCReturn(rc, rc); 107 } 108 #endif 86 109 } 87 110 } … … 115 138 AssertRCReturn(rc, rc); 116 139 } 140 #ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE 141 /* Same story as in crStateSaveTextureObjData */ 142 else if (ptl->bytes) 143 { 144 ptl->img = crAlloc(ptl->bytes); 145 if (!ptl->img) return VERR_NO_MEMORY; 146 147 rc = SSMR3GetMem(pSSM, ptl->img, ptl->bytes); 148 AssertRCReturn(rc, rc); 149 } 150 #endif 117 151 crStateTextureInitTextureFormat(ptl, ptl->internalFormat); 118 152 … … 557 591 crHashtableWalk(pContext->shared->textureTable, crStateSaveSharedTextureCB, pSSM); 558 592 593 #ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE 594 /* Restore previous texture bindings via diff_api */ 595 if (ui32) 596 { 597 CRTextureUnit *pTexUnit; 598 599 pTexUnit = &pContext->texture.unit[pContext->texture.curTextureUnit]; 600 601 diff_api.BindTexture(GL_TEXTURE_1D, pTexUnit->currentTexture1D->name); 602 diff_api.BindTexture(GL_TEXTURE_2D, pTexUnit->currentTexture2D->name); 603 diff_api.BindTexture(GL_TEXTURE_3D, pTexUnit->currentTexture3D->name); 604 #ifdef CR_ARB_texture_cube_map 605 diff_api.BindTexture(GL_TEXTURE_CUBE_MAP_ARB, pTexUnit->currentTextureCubeMap->name); 606 #endif 607 #ifdef CR_NV_texture_rectangle 608 diff_api.BindTexture(GL_TEXTURE_RECTANGLE_NV, pTexUnit->currentTextureRect->name); 609 #endif 610 } 611 #endif 612 559 613 /* Save current texture pointers */ 560 614 for (i=0; i<CR_MAX_TEXTURE_UNITS; ++i) -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_texdiff.c
r15532 r16969 594 594 void 595 595 crStateTextureObjectDiff(CRContext *fromCtx, 596 597 596 const CRbitvalue *bitID, const CRbitvalue *nbitID, 597 CRTextureObj *tobj, GLboolean alwaysDirty) 598 598 { 599 599 CRTextureState *from = &(fromCtx->texture); … … 684 684 if (tl->compressed) { 685 685 diff_api.CompressedTexImage1DARB(GL_TEXTURE_1D, lvl, 686 687 686 tl->internalFormat, tl->width, 687 tl->border, tl->bytes, tl->img); 688 688 } 689 689 else { … … 697 697 } 698 698 diff_api.TexImage1D(GL_TEXTURE_1D, lvl, 699 700 701 699 tl->internalFormat, 700 tl->width, tl->border, 701 tl->format, tl->type, tl->img); 702 702 } 703 703 if (!alwaysDirty) 704 { 704 705 CLEARDIRTY(tl->dirty, nbitID); 706 } 707 #ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE 708 else 709 { 710 crFree(tl->img); 711 tl->img = NULL; 712 } 713 #endif 705 714 } 706 715 } … … 715 724 diff_api.TexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, 1); 716 725 } 726 717 727 if (tl->compressed) { 718 728 diff_api.CompressedTexImage2DARB(GL_TEXTURE_2D, lvl, 719 720 721 729 tl->internalFormat, tl->width, 730 tl->height, tl->border, 731 tl->bytes, tl->img); 722 732 } 723 733 else { … … 728 738 diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); 729 739 diff_api.TexImage2D(GL_TEXTURE_2D, lvl, 730 tl->internalFormat, 731 tl->width, tl->height, tl->border, 732 tl->format, tl->type, tl->img); 733 } 740 tl->internalFormat, 741 tl->width, tl->height, tl->border, 742 tl->format, tl->type, tl->img); 743 } 744 734 745 if (!alwaysDirty) 746 { 735 747 CLEARDIRTY(tl->dirty, nbitID); 748 } 749 #ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE 750 else 751 { 752 crFree(tl->img); 753 tl->img = NULL; 754 } 755 #endif 736 756 } 737 757 } … … 749 769 if (tl->compressed) { 750 770 diff_api.CompressedTexImage3DARB(GL_TEXTURE_3D, lvl, 751 752 753 771 tl->internalFormat, tl->width, 772 tl->height, tl->depth, 773 tl->border, tl->bytes, tl->img); 754 774 } 755 775 else { … … 760 780 diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); 761 781 diff_api.TexImage3D(GL_TEXTURE_3D, lvl, 762 763 764 765 782 tl->internalFormat, 783 tl->width, tl->height, tl->depth, 784 tl->border, tl->format, 785 tl->type, tl->img); 766 786 } 767 787 if (!alwaysDirty) 788 { 768 789 CLEARDIRTY(tl->dirty, nbitID); 790 } 791 #ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE 792 else 793 { 794 crFree(tl->img); 795 tl->img = NULL; 796 } 797 #endif 769 798 } 770 799 } … … 781 810 if (tl->compressed) { 782 811 diff_api.CompressedTexImage2DARB(GL_TEXTURE_RECTANGLE_NV, lvl, 783 784 785 812 tl->internalFormat, tl->width, 813 tl->height, tl->border, 814 tl->bytes, tl->img); 786 815 } 787 816 else { … … 792 821 diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); 793 822 diff_api.TexImage2D(GL_TEXTURE_RECTANGLE_NV, lvl, 794 795 796 823 tl->internalFormat, 824 tl->width, tl->height, tl->border, 825 tl->format, tl->type, tl->img); 797 826 } 798 827 if (!alwaysDirty) 828 { 799 829 CLEARDIRTY(tl->dirty, nbitID); 830 } 831 #ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE 832 else 833 { 834 crFree(tl->img); 835 tl->img = NULL; 836 } 837 #endif 800 838 } 801 839 } … … 814 852 if (tl->generateMipmap) { 815 853 diff_api.TexParameteri(GL_TEXTURE_CUBE_MAP_ARB, 816 854 GL_GENERATE_MIPMAP_SGIS, 1); 817 855 } 818 856 if (tl->compressed) { 819 857 diff_api.CompressedTexImage2DARB(target, 820 821 822 858 lvl, tl->internalFormat, 859 tl->width, tl->height, 860 tl->border, tl->bytes, tl->img); 823 861 } 824 862 else { … … 829 867 diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); 830 868 diff_api.TexImage2D(target, lvl, 831 832 833 869 tl->internalFormat, 870 tl->width, tl->height, tl->border, 871 tl->format, tl->type, tl->img); 834 872 } 835 873 if (!alwaysDirty) 874 { 836 875 CLEARDIRTY(tl->dirty, nbitID); 876 } 877 #ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE 878 else 879 { 880 crFree(tl->img); 881 tl->img = NULL; 882 } 883 #endif 837 884 } 838 885 } /* for lvl */ -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_teximage.c
r16939 r16969 544 544 tl->bytes = crImageSize(format, type, width, 1); 545 545 546 #ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE 546 547 if (tl->bytes) 547 548 { … … 553 554 { 554 555 crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, 555 556 "glTexImage1D out of memory"); 556 557 return; 557 558 } 558 559 if (pixels) 559 560 crPixelCopy1D((GLvoid *) tl->img, format, type, 560 pixels, format, type, width, &(c->unpack)); 561 } 561 pixels, format, type, width, &(c->unpack)); 562 } 563 #endif 562 564 563 565 tl->width = width; … … 594 596 void STATE_APIENTRY 595 597 crStateTexImage2D(GLenum target, GLint level, GLint internalFormat, 596 597 598 GLsizei width, GLsizei height, GLint border, 599 GLenum format, GLenum type, const GLvoid * pixels) 598 600 { 599 601 CRContext *g = GetCurrentContext(); … … 639 641 } 640 642 643 #ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE 641 644 /* allocate the image buffer and fill it */ 642 645 if (tl->bytes) … … 649 652 { 650 653 crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, 651 654 "glTexImage2D out of memory"); 652 655 return; 653 656 } … … 661 664 { 662 665 crPixelCopy2D(width, height, 663 664 666 (GLvoid *) tl->img, format, type, NULL, /* dst */ 667 pixels, format, type, &(c->unpack)); /* src */ 665 668 } 666 669 } 667 670 } 671 #endif 668 672 669 673 tl->width = width; … … 741 745 tl->bytes = crTextureSize(format, type, width, height, depth); 742 746 747 #ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE 743 748 if (tl->bytes) 744 749 { … … 750 755 { 751 756 crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, 752 757 "glTexImage3D out of memory"); 753 758 return; 754 759 } 755 760 if (pixels) 756 761 crPixelCopy3D(width, height, depth, (GLvoid *) (tl->img), format, type, 757 NULL, pixels, format, type, &(c->unpack)); 758 } 762 NULL, pixels, format, type, &(c->unpack)); 763 } 764 #endif 759 765 760 766 tl->internalFormat = internalFormat; … … 820 826 } 821 827 828 #ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE 822 829 xoffset += tl->border; 823 830 824 831 crPixelCopy1D((void *) (tl->img + xoffset * tl->bytesPerPixel), 825 tl->format, tl->type, 826 pixels, format, type, width, &(c->unpack)); 832 tl->format, tl->type, 833 pixels, format, type, width, &(c->unpack)); 834 #endif 827 835 828 836 #ifdef CR_SGIS_generate_mipmap … … 844 852 void STATE_APIENTRY 845 853 crStateTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 846 847 854 GLsizei width, GLsizei height, 855 GLenum format, GLenum type, const GLvoid * pixels) 848 856 { 849 857 CRContext *g = GetCurrentContext(); … … 855 863 GLubyte *subimg = NULL; 856 864 GLubyte *img = NULL; 865 #ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE 857 866 GLubyte *src; 858 867 int i; 868 #endif 859 869 860 870 FLUSH(); … … 869 879 CRASSERT(tl); 870 880 881 #ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE 871 882 xoffset += tl->border; 872 883 yoffset += tl->border; 873 884 874 subimg = 875 (GLubyte *) crAlloc(crImageSize(tl->format, tl->type, width, height)); 885 subimg = (GLubyte *) crAlloc(crImageSize(tl->format, tl->type, width, height)); 876 886 877 887 crPixelCopy2D(width, height, subimg, tl->format, tl->type, NULL, /* dst */ 878 pixels, format, type, &(c->unpack));/* src */888 pixels, format, type, &(c->unpack)); /* src */ 879 889 880 890 img = tl->img + … … 892 902 893 903 crFree(subimg); 904 #endif 894 905 895 906 #ifdef CR_SGIS_generate_mipmap … … 925 936 GLubyte *subimg = NULL; 926 937 GLubyte *img = NULL; 938 #ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE 927 939 GLubyte *src; 928 940 int i; 941 #endif 929 942 930 943 FLUSH(); … … 935 948 } 936 949 950 #ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE 937 951 xoffset += tl->border; 938 952 yoffset += tl->border; … … 944 958 945 959 crPixelCopy3D(width, height, depth, subimg, tl->format, tl->type, NULL, 946 960 pixels, format, type, &(c->unpack)); 947 961 948 962 img = tl->img + xoffset * tl->bytesPerPixel + … … 961 975 962 976 crFree(subimg); 977 #endif 963 978 964 979 #ifdef CR_SGIS_generate_mipmap … … 1014 1029 tl->bytes = imageSize; 1015 1030 1031 #ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE 1016 1032 if (tl->bytes) 1017 1033 { … … 1023 1039 { 1024 1040 crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, 1025 1041 "glTexImage1D out of memory"); 1026 1042 return; 1027 1043 } … … 1029 1045 crMemcpy(tl->img, data, imageSize); 1030 1046 } 1047 #endif 1031 1048 1032 1049 tl->width = width; … … 1059 1076 void STATE_APIENTRY 1060 1077 crStateCompressedTexImage2DARB(GLenum target, GLint level, 1061 1062 1063 1078 GLenum internalFormat, GLsizei width, 1079 GLsizei height, GLint border, 1080 GLsizei imageSize, const GLvoid * data) 1064 1081 { 1065 1082 CRContext *g = GetCurrentContext(); … … 1092 1109 tl->bytes = imageSize; 1093 1110 1111 #ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE 1094 1112 if (tl->bytes) 1095 1113 { … … 1101 1119 { 1102 1120 crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, 1103 1121 "glTexImage2D out of memory"); 1104 1122 return; 1105 1123 } … … 1107 1125 crMemcpy(tl->img, data, imageSize); 1108 1126 } 1127 #endif 1109 1128 1110 1129 tl->width = width; … … 1171 1190 tl->bytes = imageSize; 1172 1191 1192 #ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE 1173 1193 if (tl->bytes) 1174 1194 { … … 1180 1200 { 1181 1201 crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, 1182 1202 "glCompressedTexImage3D out of memory"); 1183 1203 return; 1184 1204 } … … 1186 1206 crMemcpy(tl->img, data, imageSize); 1187 1207 } 1208 #endif 1188 1209 1189 1210 tl->width = width; … … 1234 1255 } 1235 1256 1257 #ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE 1236 1258 xoffset += tl->border; 1237 1259 … … 1242 1264 else { 1243 1265 /* XXX this depends on the exact compression method */ 1244 } 1266 crWarning("Not implemented part crStateCompressedTexSubImage1DARB"); 1267 } 1268 #endif 1245 1269 1246 1270 #ifdef CR_SGIS_generate_mipmap … … 1281 1305 } 1282 1306 1307 #ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE 1283 1308 xoffset += tl->border; 1284 1309 yoffset += tl->border; 1285 1310 1286 if (xoffset == 0 && width == tl->width && 1287 yoffset == 0 && height == tl->height) { 1311 if (xoffset == 0 && width == tl->width 1312 && yoffset == 0 && height == tl->height) 1313 { 1288 1314 /* just memcpy */ 1289 1315 crMemcpy(tl->img, data, imageSize); … … 1291 1317 else { 1292 1318 /* XXX this depends on the exact compression method */ 1293 } 1319 crWarning("Not implemented part crStateCompressedTexSubImage2DARB"); 1320 } 1321 #endif 1294 1322 1295 1323 #ifdef CR_SGIS_generate_mipmap … … 1331 1359 } 1332 1360 1361 #ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE 1333 1362 xoffset += tl->border; 1334 1363 yoffset += tl->border; … … 1336 1365 1337 1366 if (xoffset == 0 && width == tl->width && 1338 1339 1367 yoffset == 0 && height == tl->height && 1368 zoffset == 0 && depth == tl->depth) { 1340 1369 /* just memcpy */ 1341 1370 crMemcpy(tl->img, data, imageSize); … … 1343 1372 else { 1344 1373 /* XXX this depends on the exact compression method */ 1345 } 1374 crWarning("Not implemented part crStateCompressedTexSubImage3DARB"); 1375 } 1376 #endif 1346 1377 1347 1378 #ifdef CR_SGIS_generate_mipmap … … 1388 1419 } 1389 1420 1421 #ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE 1390 1422 crMemcpy(img, tl->img, tl->bytes); 1423 #else 1424 diff_api.GetCompressedTexImageARB(target, level, img); 1425 #endif 1391 1426 } 1392 1427 … … 1394 1429 void STATE_APIENTRY 1395 1430 crStateGetTexImage(GLenum target, GLint level, GLenum format, 1396 1431 GLenum type, GLvoid * pixels) 1397 1432 { 1398 1433 CRContext *g = GetCurrentContext(); … … 1453 1488 } 1454 1489 1490 #ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE 1455 1491 #ifdef CR_OPENGL_VERSION_1_2 1456 1492 if (target == GL_TEXTURE_3D) 1457 1493 { 1458 1494 crPixelCopy3D(tl->width, tl->height, tl->depth, (GLvoid *) pixels, format, 1459 1495 type, NULL, (tl->img), format, type, &(c->pack)); 1460 1496 } 1461 1497 else 1462 1498 #endif 1463 if ((target == GL_TEXTURE_ 2D) || (target == GL_TEXTURE_1D))1499 if ((target == GL_TEXTURE_1D) || (target == GL_TEXTURE_2D)) 1464 1500 { 1465 1501 crPixelCopy2D(tl->width, tl->height, (GLvoid *) pixels, format, type, NULL, /* dst */ 1466 (tl->img), format, type, &(c->pack)); /* src */ 1467 } 1468 } 1502 tl->img, format, type, &(c->pack)); /* src */ 1503 } 1504 #else 1505 diff_api.GetTexImage(target, level, format, type, pixels); 1506 #endif 1507 }
Note:
See TracChangeset
for help on using the changeset viewer.