Changeset 23123 in vbox
- Timestamp:
- Sep 18, 2009 11:21:22 AM (15 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/include/state/cr_bufferobject.h
r15532 r23123 46 46 47 47 CRHashTable *buffers; 48 49 GLboolean bResyncNeeded; 48 50 } CRBufferObjectState; 49 51 -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_bufferobject.c
r22832 r23123 48 48 49 49 b->buffers = crAllocHashtable(); 50 51 b->bResyncNeeded = GL_FALSE; 50 52 } 51 53 … … 72 74 crFree(b->nullBuffer); 73 75 } 74 75 76 76 77 void STATE_APIENTRY … … 750 751 } 751 752 753 static void crStateBufferObjectSyncCB(unsigned long key, void *data1, void *data2) 754 { 755 CRBufferObject *pBufferObj = (CRBufferObject *) data1; 756 CRBufferObjectState *pState = (CRBufferObjectState *) data2; 757 758 if (pBufferObj->data) 759 { 760 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, pBufferObj->name); 761 diff_api.BufferDataARB(GL_ARRAY_BUFFER_ARB, pBufferObj->size, pBufferObj->data, pBufferObj->usage); 762 763 if (!pState->retainBufferData) 764 { 765 crFree(pBufferObj->data); 766 pBufferObj->data = NULL; 767 } 768 } 769 } 752 770 753 771 /* … … 758 776 { 759 777 const CRBufferObjectState *from = &(fromCtx->bufferobject); 760 const CRBufferObjectState *to = &(toCtx->bufferobject); 778 CRBufferObjectState *to = &(toCtx->bufferobject); 779 int i; 761 780 762 781 if (!HaveBufferObjectExtension()) 763 782 return; 783 784 if (to->bResyncNeeded) 785 { 786 CRClientPointer *cp; 787 788 crHashtableWalk(to->buffers, crStateBufferObjectSyncCB, to); 789 to->bResyncNeeded = GL_FALSE; 790 791 /*@todo, move to state_client.c*/ 792 793 cp = &toCtx->client.array.v; 794 if (cp->buffer->name) 795 { 796 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->name); 797 diff_api.VertexPointer(cp->size, cp->type, cp->stride, cp->p); 798 } 799 800 cp = &toCtx->client.array.c; 801 if (cp->buffer->name) 802 { 803 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->name); 804 diff_api.ColorPointer(cp->size, cp->type, cp->stride, cp->p); 805 } 806 807 cp = &toCtx->client.array.f; 808 if (cp->buffer->name) 809 { 810 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->name); 811 diff_api.FogCoordPointerEXT(cp->type, cp->stride, cp->p); 812 } 813 814 cp = &toCtx->client.array.s; 815 if (cp->buffer->name) 816 { 817 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->name); 818 diff_api.SecondaryColorPointerEXT(cp->size, cp->type, cp->stride, cp->p); 819 } 820 821 cp = &toCtx->client.array.e; 822 if (cp->buffer->name) 823 { 824 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->name); 825 diff_api.EdgeFlagPointer(cp->stride, cp->p); 826 } 827 828 cp = &toCtx->client.array.i; 829 if (cp->buffer->name) 830 { 831 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->name); 832 diff_api.IndexPointer(cp->type, cp->stride, cp->p); 833 } 834 835 cp = &toCtx->client.array.n; 836 if (cp->buffer->name) 837 { 838 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->name); 839 diff_api.NormalPointer(cp->type, cp->stride, cp->p); 840 } 841 842 for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) 843 { 844 cp = &toCtx->client.array.t[i]; 845 if (cp->buffer->name) 846 { 847 if (diff_api.ActiveTextureARB) 848 diff_api.ActiveTextureARB(i+GL_TEXTURE0_ARB); 849 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->name); 850 diff_api.TexCoordPointer(cp->size, cp->type, cp->stride, cp->p); 851 } 852 } 853 854 if (diff_api.ActiveTextureARB) 855 diff_api.ActiveTextureARB(toCtx->client.curClientTextureUnit+GL_TEXTURE0_ARB); 856 857 #ifdef CR_NV_vertex_program 858 for (i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++) 859 { 860 cp = &toCtx->client.array.a[i]; 861 if (cp->buffer->name) 862 { 863 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->name); 864 diff_api.VertexAttribPointerARB(i, cp->size, cp->type, cp->normalized, cp->stride, cp->p); 865 } 866 } 867 #endif 868 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, to->arrayBuffer->name); 869 diff_api.BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, to->elementsBuffer->name); 870 } 764 871 765 872 /* ARRAY_BUFFER binding */ -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_client.c
r23110 r23123 133 133 c->array.v.enabled = 0; 134 134 #ifdef CR_ARB_vertex_buffer_object 135 c->array.v.buffer = g ->bufferobject.arrayBuffer;135 c->array.v.buffer = g ? g->bufferobject.arrayBuffer : NULL; 136 136 #endif 137 137 #ifdef CR_EXT_compiled_vertex_array … … 148 148 c->array.c.enabled = 0; 149 149 #ifdef CR_ARB_vertex_buffer_object 150 c->array.c.buffer = g ->bufferobject.arrayBuffer;150 c->array.c.buffer = g ? g->bufferobject.arrayBuffer : NULL; 151 151 #endif 152 152 #ifdef CR_EXT_compiled_vertex_array … … 163 163 c->array.f.enabled = 0; 164 164 #ifdef CR_ARB_vertex_buffer_object 165 c->array.f.buffer = g ->bufferobject.arrayBuffer;165 c->array.f.buffer = g ? g->bufferobject.arrayBuffer : NULL; 166 166 #endif 167 167 #ifdef CR_EXT_compiled_vertex_array … … 178 178 c->array.s.enabled = 0; 179 179 #ifdef CR_ARB_vertex_buffer_object 180 c->array.s.buffer = g ->bufferobject.arrayBuffer;180 c->array.s.buffer = g ? g->bufferobject.arrayBuffer : NULL; 181 181 #endif 182 182 #ifdef CR_EXT_compiled_vertex_array … … 193 193 c->array.e.enabled = 0; 194 194 #ifdef CR_ARB_vertex_buffer_object 195 c->array.e.buffer = g ->bufferobject.arrayBuffer;195 c->array.e.buffer = g ? g->bufferobject.arrayBuffer : NULL; 196 196 #endif 197 197 #ifdef CR_EXT_compiled_vertex_array … … 208 208 c->array.i.enabled = 0; 209 209 #ifdef CR_ARB_vertex_buffer_object 210 c->array.i.buffer = g ->bufferobject.arrayBuffer;210 c->array.i.buffer = g ? g->bufferobject.arrayBuffer : NULL; 211 211 #endif 212 212 #ifdef CR_EXT_compiled_vertex_array … … 223 223 c->array.n.enabled = 0; 224 224 #ifdef CR_ARB_vertex_buffer_object 225 c->array.n.buffer = g ->bufferobject.arrayBuffer;225 c->array.n.buffer = g ? g->bufferobject.arrayBuffer : NULL; 226 226 #endif 227 227 #ifdef CR_EXT_compiled_vertex_array … … 240 240 c->array.t[i].enabled = 0; 241 241 #ifdef CR_ARB_vertex_buffer_object 242 c->array.t[i].buffer = g ->bufferobject.arrayBuffer;242 c->array.t[i].buffer = g ? g->bufferobject.arrayBuffer : NULL; 243 243 #endif 244 244 #ifdef CR_EXT_compiled_vertex_array … … 257 257 c->array.a[i].stride = 0; 258 258 #ifdef CR_ARB_vertex_buffer_object 259 c->array.a[i].buffer = g ->bufferobject.arrayBuffer;259 c->array.a[i].buffer = g ? g->bufferobject.arrayBuffer : NULL; 260 260 #endif 261 261 #ifdef CR_EXT_compiled_vertex_array -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_snapshot.c
r23094 r23123 425 425 rc = SSMR3PutMem(pSSM, pBufferObj, sizeof(*pBufferObj)); 426 426 CRASSERT(rc == VINF_SUCCESS); 427 427 428 if (pBufferObj->data) 428 429 { 430 /*We could get here even though retainBufferData is false on host side, in case when we're taking snapshot 431 after state load and before this context was ever made current*/ 429 432 CRASSERT(pBufferObj->size>0); 430 433 rc = SSMR3PutMem(pSSM, pBufferObj->data, pBufferObj->size); 431 434 CRASSERT(rc == VINF_SUCCESS); 435 } 436 else if (pBufferObj->name!=0 && pBufferObj->size>0) 437 { 438 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, pBufferObj->name); 439 pBufferObj->pointer = diff_api.MapBufferARB(GL_ARRAY_BUFFER_ARB, GL_READ_ONLY_ARB); 440 rc = SSMR3PutMem(pSSM, &pBufferObj->pointer, sizeof(pBufferObj->pointer)); 441 CRASSERT(rc == VINF_SUCCESS); 442 if (pBufferObj->pointer) 443 { 444 rc = SSMR3PutMem(pSSM, pBufferObj->pointer, pBufferObj->size); 445 CRASSERT(rc == VINF_SUCCESS); 446 } 447 diff_api.UnmapBufferARB(GL_ARRAY_BUFFER_ARB); 448 pBufferObj->pointer = NULL; 432 449 } 433 450 } … … 715 732 /* Save all the rest */ 716 733 crHashtableWalk(pContext->bufferobject.buffers, crStateSaveBufferObjectCB, pSSM); 734 /* Restore binding */ 735 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, pContext->bufferobject.arrayBuffer->name); 717 736 /* Save pointers */ 718 737 rc = SSMR3PutU32(pSSM, pContext->bufferobject.arrayBuffer->name); … … 720 739 rc = SSMR3PutU32(pSSM, pContext->bufferobject.elementsBuffer->name); 721 740 AssertRCReturn(rc, rc); 722 #endif 741 /* Save bound array buffers*/ /*@todo vertexArrayStack*/ 742 rc = SSMR3PutU32(pSSM, pContext->client.array.v.buffer->name); 743 AssertRCReturn(rc, rc); 744 rc = SSMR3PutU32(pSSM, pContext->client.array.c.buffer->name); 745 AssertRCReturn(rc, rc); 746 rc = SSMR3PutU32(pSSM, pContext->client.array.f.buffer->name); 747 AssertRCReturn(rc, rc); 748 rc = SSMR3PutU32(pSSM, pContext->client.array.s.buffer->name); 749 AssertRCReturn(rc, rc); 750 rc = SSMR3PutU32(pSSM, pContext->client.array.e.buffer->name); 751 AssertRCReturn(rc, rc); 752 rc = SSMR3PutU32(pSSM, pContext->client.array.i.buffer->name); 753 AssertRCReturn(rc, rc); 754 rc = SSMR3PutU32(pSSM, pContext->client.array.n.buffer->name); 755 AssertRCReturn(rc, rc); 756 for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) 757 { 758 rc = SSMR3PutU32(pSSM, pContext->client.array.t[i].buffer->name); 759 AssertRCReturn(rc, rc); 760 } 761 # ifdef CR_NV_vertex_program 762 for (i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++) 763 { 764 rc = SSMR3PutU32(pSSM, pContext->client.array.a[i].buffer->name); 765 AssertRCReturn(rc, rc); 766 } 767 # endif 768 #endif /*CR_ARB_vertex_buffer_object*/ 723 769 724 770 /* Save pixel/vertex programs */ … … 804 850 #endif 805 851 806 SLC_COPYPTR(client.array.v.p); /*@todo*/ 807 SLC_COPYPTR(client.array.c.p); /*@todo*/ 808 SLC_COPYPTR(client.array.f.p); /*@todo*/ 809 SLC_COPYPTR(client.array.s.p); /*@todo*/ 810 SLC_COPYPTR(client.array.e.p); /*@todo*/ 811 SLC_COPYPTR(client.array.i.p); /*@todo*/ 812 SLC_COPYPTR(client.array.n.p); /*@todo*/ 852 /*@todo, that should be removed probably as those should hold the offset values, so loading should be fine 853 but better check*/ 854 #if 0 855 #ifdef CR_EXT_compiled_vertex_array 856 SLC_COPYPTR(client.array.v.prevPtr); 857 SLC_COPYPTR(client.array.c.prevPtr); 858 SLC_COPYPTR(client.array.f.prevPtr); 859 SLC_COPYPTR(client.array.s.prevPtr); 860 SLC_COPYPTR(client.array.e.prevPtr); 861 SLC_COPYPTR(client.array.i.prevPtr); 862 SLC_COPYPTR(client.array.n.prevPtr); 813 863 for (i = 0 ; i < CR_MAX_TEXTURE_UNITS ; i++) 814 864 { 815 SLC_COPYPTR(client.array.t[i].p); /*@todo*/ 816 } 817 818 #ifdef CR_ARB_vertex_buffer_object2 819 SLC_COPYPTR(client.array.v.buffer); /*@todo*/ 820 SLC_COPYPTR(client.array.c.buffer); /*@todo*/ 821 SLC_COPYPTR(client.array.f.buffer); /*@todo*/ 822 SLC_COPYPTR(client.array.s.buffer); /*@todo*/ 823 SLC_COPYPTR(client.array.e.buffer); /*@todo*/ 824 SLC_COPYPTR(client.array.i.buffer); /*@todo*/ 825 SLC_COPYPTR(client.array.n.buffer); /*@todo*/ 865 SLC_COPYPTR(client.array.t[i].prevPtr); 866 } 867 868 # ifdef CR_NV_vertex_program 869 for (i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++) 870 { 871 SLC_COPYPTR(client.array.a[i].prevPtr); 872 } 873 # endif 874 #endif 875 #endif 876 877 #ifdef CR_ARB_vertex_buffer_object 878 /*That just sets those pointers to NULL*/ 879 SLC_COPYPTR(client.array.v.buffer); 880 SLC_COPYPTR(client.array.c.buffer); 881 SLC_COPYPTR(client.array.f.buffer); 882 SLC_COPYPTR(client.array.s.buffer); 883 SLC_COPYPTR(client.array.e.buffer); 884 SLC_COPYPTR(client.array.i.buffer); 885 SLC_COPYPTR(client.array.n.buffer); 826 886 for (i = 0 ; i < CR_MAX_TEXTURE_UNITS ; i++) 827 887 { 828 SLC_COPYPTR(client.array.t[i].buffer); /*@todo*/829 } 830 # ifdef CR_NV_vertex_program831 for (i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++) {832 { 833 SLC_COPYPTR(client.array.a[i].buffer); /*@todo*/834 } 835 # endif836 #endif /*CR_ARB_vertex_buffer_object 2*/888 SLC_COPYPTR(client.array.t[i].buffer); 889 } 890 # ifdef CR_NV_vertex_program 891 for (i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++) 892 { 893 SLC_COPYPTR(client.array.a[i].buffer); 894 } 895 # endif 896 #endif /*CR_ARB_vertex_buffer_object*/ 837 897 838 898 /*@todo CR_NV_vertex_program*/ … … 1093 1153 //pBufferObj->dirtyStart = 0; 1094 1154 //pBufferObj->dirtyLength = pBufferObj->size; 1095 } 1155 } 1156 else if (pBufferObj->name!=0 && pBufferObj->size>0) 1157 { 1158 rc = SSMR3GetMem(pSSM, &pBufferObj->data, sizeof(pBufferObj->data)); 1159 AssertRCReturn(rc, rc); 1160 1161 if (pBufferObj->data) 1162 { 1163 pBufferObj->data = crAlloc(pBufferObj->size); 1164 rc = SSMR3GetMem(pSSM, pBufferObj->data, pBufferObj->size); 1165 AssertRCReturn(rc, rc); 1166 } 1167 } 1168 1096 1169 1097 1170 if (key!=0) … … 1100 1173 //FILLDIRTY(GetCurrentBits()->bufferobject.dirty); 1101 1174 /* Load pointers */ 1175 #define CRS_GET_BO(name) (((name)==0) ? (pContext->bufferobject.nullBuffer) : crHashtableSearch(pContext->bufferobject.buffers, name)) 1102 1176 rc = SSMR3GetU32(pSSM, &ui); 1103 1177 AssertRCReturn(rc, rc); 1104 pContext->bufferobject.arrayBuffer = ui==0 ? pContext->bufferobject.nullBuffer 1105 : crHashtableSearch(pContext->bufferobject.buffers, ui); 1178 pContext->bufferobject.arrayBuffer = CRS_GET_BO(ui); 1106 1179 rc = SSMR3GetU32(pSSM, &ui); 1107 1180 AssertRCReturn(rc, rc); 1108 pContext->bufferobject.elementsBuffer = ui==0 ? pContext->bufferobject.nullBuffer 1109 : crHashtableSearch(pContext->bufferobject.buffers, ui); 1181 pContext->bufferobject.elementsBuffer = CRS_GET_BO(ui); 1182 1183 /* Load bound array buffers*/ 1184 rc = SSMR3GetU32(pSSM, &ui); 1185 AssertRCReturn(rc, rc); 1186 pContext->client.array.v.buffer = CRS_GET_BO(ui); 1187 1188 rc = SSMR3GetU32(pSSM, &ui); 1189 AssertRCReturn(rc, rc); 1190 pContext->client.array.c.buffer = CRS_GET_BO(ui); 1191 1192 rc = SSMR3GetU32(pSSM, &ui); 1193 AssertRCReturn(rc, rc); 1194 pContext->client.array.f.buffer = CRS_GET_BO(ui); 1195 1196 rc = SSMR3GetU32(pSSM, &ui); 1197 AssertRCReturn(rc, rc); 1198 pContext->client.array.s.buffer = CRS_GET_BO(ui); 1199 1200 rc = SSMR3GetU32(pSSM, &ui); 1201 AssertRCReturn(rc, rc); 1202 pContext->client.array.e.buffer = CRS_GET_BO(ui); 1203 1204 rc = SSMR3GetU32(pSSM, &ui); 1205 AssertRCReturn(rc, rc); 1206 pContext->client.array.i.buffer = CRS_GET_BO(ui); 1207 1208 rc = SSMR3GetU32(pSSM, &ui); 1209 AssertRCReturn(rc, rc); 1210 pContext->client.array.n.buffer = CRS_GET_BO(ui); 1211 1212 for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) 1213 { 1214 rc = SSMR3GetU32(pSSM, &ui); 1215 AssertRCReturn(rc, rc); 1216 pContext->client.array.t[i].buffer = CRS_GET_BO(ui); 1217 } 1218 # ifdef CR_NV_vertex_program 1219 for (i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++) 1220 { 1221 rc = SSMR3GetU32(pSSM, &ui); 1222 AssertRCReturn(rc, rc); 1223 pContext->client.array.a[i].buffer = CRS_GET_BO(ui); 1224 } 1225 # endif 1226 #undef CRS_GET_BO 1227 1228 pContext->bufferobject.bResyncNeeded = GL_TRUE; 1110 1229 #endif 1111 1230 -
trunk/src/VBox/HostServices/SharedOpenGL/crserver/crservice.cpp
r23094 r23123 71 71 72 72 static const char* gszVBoxOGLSSMMagic = "***OpenGL state data***"; 73 #define SHCROGL_SSM_VERSION 773 #define SHCROGL_SSM_VERSION 8 74 74 75 75 typedef struct
Note:
See TracChangeset
for help on using the changeset viewer.