Changeset 44196 in vbox for trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_snapshot.c
- Timestamp:
- Dec 21, 2012 12:02:47 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_snapshot.c
r44048 r44196 1322 1322 CRASSERT(VBoxTlsRefIsFunctional(pContext)); 1323 1323 1324 /* do not increment the saved state version due to VBOXTLSREFDATA addition to CRContext */ 1325 rc = SSMR3PutMem(pSSM, pContext, VBOXTLSREFDATA_OFFSET(CRContext)); 1326 AssertRCReturn(rc, rc); 1327 1328 /* now store bitid & neg_bitid */ 1329 rc = SSMR3PutMem(pSSM, pContext->bitid, sizeof (pContext->bitid) + sizeof (pContext->neg_bitid)); 1330 AssertRCReturn(rc, rc); 1331 1332 /* the pre-VBOXTLSREFDATA CRContext structure might have additional allignment bits before the CRContext::shared */ 1333 ui32 = VBOXTLSREFDATA_OFFSET(CRContext) + sizeof (pContext->bitid) + sizeof (pContext->neg_bitid); 1334 ui32 &= (sizeof (void*) - 1); 1335 if (ui32) 1336 { 1337 void* pTmp = NULL; 1338 rc = SSMR3PutMem(pSSM, &pTmp, ui32); 1339 AssertRCReturn(rc, rc); 1340 } 1341 1342 rc = SSMR3PutMem(pSSM, &pContext->shared, sizeof (CRContext) - RT_OFFSETOF(CRContext, shared)); 1324 /* make sure the gl error state is captured by our state mechanism to store the correct gl error value */ 1325 crStateSyncHWErrorState(pContext); 1326 1327 rc = SSMR3PutMem(pSSM, pContext, sizeof (*pContext)); 1343 1328 AssertRCReturn(rc, rc); 1344 1329 … … 1712 1697 unsigned long key; 1713 1698 GLboolean bLoadShared = GL_TRUE; 1714 union { 1715 CRbitvalue bitid[CR_MAX_BITARRAY]; 1716 struct { 1717 VBOXTLSREFDATA 1718 } tlsRef; 1719 } bitid; 1699 GLenum err; 1720 1700 1721 1701 CRASSERT(pContext && pSSM); … … 1728 1708 CRASSERT(VBoxTlsRefIsFunctional(pContext)); 1729 1709 1730 /* do not increment the saved state version due to VBOXTLSREFDATA addition to CRContext */ 1731 rc = SSMR3GetMem(pSSM, pTmpContext, VBOXTLSREFDATA_OFFSET(CRContext)); 1732 AssertRCReturn(rc, rc); 1733 1734 /* VBox 4.1.8 had a bug that VBOXTLSREFDATA was also stored in the snapshot, 1735 * thus the saved state data format was changed w/o changing the saved state version. 1736 * here we determine whether the saved state contains VBOXTLSREFDATA, and if so, treat it accordingly */ 1737 rc = SSMR3GetMem(pSSM, &bitid, sizeof (bitid)); 1738 AssertRCReturn(rc, rc); 1739 1740 /* the bitid array has one bit set only. this is why if bitid.tlsRef has both cTlsRefs 1741 * and enmTlsRefState non-zero - this is definitely NOT a bit id and is a VBOXTLSREFDATA */ 1742 if (bitid.tlsRef.enmTlsRefState == VBOXTLSREFDATA_STATE_INITIALIZED 1743 && bitid.tlsRef.cTlsRefs) 1744 { 1745 /* VBOXTLSREFDATA is stored, skip it */ 1746 crMemcpy(&pTmpContext->bitid, ((uint8_t*)&bitid) + VBOXTLSREFDATA_SIZE(), sizeof (bitid) - VBOXTLSREFDATA_SIZE()); 1747 rc = SSMR3GetMem(pSSM, ((uint8_t*)&pTmpContext->bitid) + sizeof (pTmpContext->bitid) - VBOXTLSREFDATA_SIZE(), sizeof (pTmpContext->neg_bitid) + VBOXTLSREFDATA_SIZE()); 1748 AssertRCReturn(rc, rc); 1749 1750 ui = VBOXTLSREFDATA_OFFSET(CRContext) + VBOXTLSREFDATA_SIZE() + sizeof (pTmpContext->bitid) + sizeof (pTmpContext->neg_bitid); 1751 ui = RT_OFFSETOF(CRContext, shared) - ui; 1710 if (u32Version <= SHCROGL_SSM_VERSION_WITH_INVALID_ERROR_STATE) 1711 { 1712 union { 1713 CRbitvalue bitid[CR_MAX_BITARRAY]; 1714 struct { 1715 VBOXTLSREFDATA 1716 } tlsRef; 1717 } bitid; 1718 1719 /* do not increment the saved state version due to VBOXTLSREFDATA addition to CRContext */ 1720 rc = SSMR3GetMem(pSSM, pTmpContext, VBOXTLSREFDATA_OFFSET(CRContext)); 1721 AssertRCReturn(rc, rc); 1722 1723 /* VBox 4.1.8 had a bug that VBOXTLSREFDATA was also stored in the snapshot, 1724 * thus the saved state data format was changed w/o changing the saved state version. 1725 * here we determine whether the saved state contains VBOXTLSREFDATA, and if so, treat it accordingly */ 1726 rc = SSMR3GetMem(pSSM, &bitid, sizeof (bitid)); 1727 AssertRCReturn(rc, rc); 1728 1729 /* the bitid array has one bit set only. this is why if bitid.tlsRef has both cTlsRefs 1730 * and enmTlsRefState non-zero - this is definitely NOT a bit id and is a VBOXTLSREFDATA */ 1731 if (bitid.tlsRef.enmTlsRefState == VBOXTLSREFDATA_STATE_INITIALIZED 1732 && bitid.tlsRef.cTlsRefs) 1733 { 1734 /* VBOXTLSREFDATA is stored, skip it */ 1735 crMemcpy(&pTmpContext->bitid, ((uint8_t*)&bitid) + VBOXTLSREFDATA_SIZE(), sizeof (bitid) - VBOXTLSREFDATA_SIZE()); 1736 rc = SSMR3GetMem(pSSM, ((uint8_t*)&pTmpContext->bitid) + sizeof (pTmpContext->bitid) - VBOXTLSREFDATA_SIZE(), sizeof (pTmpContext->neg_bitid) + VBOXTLSREFDATA_SIZE()); 1737 AssertRCReturn(rc, rc); 1738 1739 ui = VBOXTLSREFDATA_OFFSET(CRContext) + VBOXTLSREFDATA_SIZE() + sizeof (pTmpContext->bitid) + sizeof (pTmpContext->neg_bitid); 1740 ui = RT_OFFSETOF(CRContext, shared) - ui; 1741 } 1742 else 1743 { 1744 /* VBOXTLSREFDATA is NOT stored */ 1745 crMemcpy(&pTmpContext->bitid, &bitid, sizeof (bitid)); 1746 rc = SSMR3GetMem(pSSM, &pTmpContext->neg_bitid, sizeof (pTmpContext->neg_bitid)); 1747 AssertRCReturn(rc, rc); 1748 1749 /* the pre-VBOXTLSREFDATA CRContext structure might have additional allignment bits before the CRContext::shared */ 1750 ui = VBOXTLSREFDATA_OFFSET(CRContext) + sizeof (pTmpContext->bitid) + sizeof (pTmpContext->neg_bitid); 1751 1752 ui &= (sizeof (void*) - 1); 1753 } 1754 1755 if (ui) 1756 { 1757 void* pTmp = NULL; 1758 rc = SSMR3GetMem(pSSM, &pTmp, ui); 1759 AssertRCReturn(rc, rc); 1760 } 1761 1762 if (u32Version == SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS) 1763 { 1764 SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, shared, attrib); 1765 rc = crStateLoadAttribState_v_BEFORE_CTXUSAGE_BITS(&pTmpContext->attrib, pSSM); 1766 AssertRCReturn(rc, rc); 1767 SHCROGL_CUT_FIELD_ALIGNMENT(CRContext, attrib, buffer); 1768 SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, buffer, texture); 1769 rc = crStateLoadTextureState_v_BEFORE_CTXUSAGE_BITS(&pTmpContext->texture, pSSM); 1770 AssertRCReturn(rc, rc); 1771 SHCROGL_CUT_FIELD_ALIGNMENT(CRContext, texture, transform); 1772 SHCROGL_GET_STRUCT_TAIL(pTmpContext, CRContext, transform); 1773 } 1774 else 1775 { 1776 SHCROGL_GET_STRUCT_TAIL(pTmpContext, CRContext, shared); 1777 } 1778 1779 pTmpContext->error = GL_NO_ERROR; /* <- the error state contained some random error data here 1780 * treat as no error */ 1752 1781 } 1753 1782 else 1754 1783 { 1755 /* VBOXTLSREFDATA is NOT stored */ 1756 crMemcpy(&pTmpContext->bitid, &bitid, sizeof (bitid)); 1757 rc = SSMR3GetMem(pSSM, &pTmpContext->neg_bitid, sizeof (pTmpContext->neg_bitid)); 1758 AssertRCReturn(rc, rc); 1759 1760 /* the pre-VBOXTLSREFDATA CRContext structure might have additional allignment bits before the CRContext::shared */ 1761 ui = VBOXTLSREFDATA_OFFSET(CRContext) + sizeof (pTmpContext->bitid) + sizeof (pTmpContext->neg_bitid); 1762 1763 ui &= (sizeof (void*) - 1); 1764 } 1765 1766 if (ui) 1767 { 1768 void* pTmp = NULL; 1769 rc = SSMR3GetMem(pSSM, &pTmp, ui); 1770 AssertRCReturn(rc, rc); 1771 } 1784 rc = SSMR3GetMem(pSSM, pTmpContext, sizeof (*pTmpContext)); 1785 AssertRCReturn(rc, rc); 1786 } 1787 1788 /* preserve the error to restore it at the end of context creation, 1789 * it should not normally change, but just in case it it changed */ 1790 err = pTmpContext->error; 1772 1791 1773 1792 /* we will later do crMemcpy from entire pTmpContext to pContext, 1774 1793 * for simplicity store the VBOXTLSREFDATA from the pContext to pTmpContext */ 1775 1794 VBOXTLSREFDATA_COPY(pTmpContext, pContext); 1776 1777 if (u32Version == SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS)1778 {1779 SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, shared, attrib);1780 rc = crStateLoadAttribState_v_BEFORE_CTXUSAGE_BITS(&pTmpContext->attrib, pSSM);1781 AssertRCReturn(rc, rc);1782 SHCROGL_CUT_FIELD_ALIGNMENT(CRContext, attrib, buffer);1783 SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, buffer, texture);1784 rc = crStateLoadTextureState_v_BEFORE_CTXUSAGE_BITS(&pTmpContext->texture, pSSM);1785 AssertRCReturn(rc, rc);1786 SHCROGL_CUT_FIELD_ALIGNMENT(CRContext, texture, transform);1787 SHCROGL_GET_STRUCT_TAIL(pTmpContext, CRContext, transform);1788 }1789 else1790 {1791 SHCROGL_GET_STRUCT_TAIL(pTmpContext, CRContext, shared);1792 }1793 1795 1794 1796 /* Deal with shared state */ … … 2261 2263 AssertRCReturn(rc, rc); 2262 2264 2265 Assert(key == pFBO->id); 2266 2263 2267 crHashtableAdd(pContext->shared->fbTable, key, pFBO); 2264 2268 } … … 2457 2461 } 2458 2462 2463 if (pContext->error != err) 2464 { 2465 crWarning("context error state changed on context restore, was 0x%x, but became 0x%x, resetting to its original value", 2466 err, pContext->error); 2467 pContext->error = err; 2468 } 2459 2469 2460 2470 /*Mark all as dirty to make sure we'd restore correct context state*/
Note:
See TracChangeset
for help on using the changeset viewer.